From 9e1375e99a2944238c142c15e1ba330446b74c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Tue, 2 Aug 2022 12:53:37 +0200 Subject: [PATCH] Refactor DAL capabilities into operations and properties --- .../gocode/store/rdbms/aux_types.go.tpl | 1 - compose/dalutils/records.go | 58 ++-- compose/service/dal_interfaces.go | 15 +- compose/service/module.go | 45 ++- compose/service/module_test.go | 2 +- compose/service/record_test.go | 2 +- compose/types/module.go | 5 +- compose/types/module_field.go | 7 +- compose/types/record.go | 3 +- pkg/dal/capabilities/capabilities.go | 173 ----------- pkg/dal/diff.go | 2 +- pkg/dal/driver.go | 21 +- pkg/dal/model.go | 7 +- pkg/dal/operations.go | 160 ++++++++++ ...apabilities_test.go => operations_test.go} | 56 ++-- pkg/dal/service.go | 139 +++++---- pkg/envoy/store/compose.go | 9 +- pkg/provision/dal.go | 22 +- pkg/revisions/model.go | 7 +- pkg/revisions/service.go | 10 +- pkg/seeder/seeder.go | 7 +- store/adapters/rdbms/aux_types.gen.go | 48 +-- store/adapters/rdbms/dal/connection.go | 31 +- store/adapters/rdbms/drivers/mysql/connect.go | 7 +- store/adapters/rdbms/drivers/mysql/dal.go | 3 +- .../rdbms/drivers/postgres/connect.go | 7 +- store/adapters/rdbms/drivers/postgres/dal.go | 3 +- .../adapters/rdbms/drivers/sqlite/connect.go | 7 +- store/adapters/rdbms/drivers/sqlite/dal.go | 3 +- store/adapters/rdbms/queries.gen.go | 80 ++--- store/adapters/rdbms/rdbms.gen.go | 3 - store/adapters/rdbms/upgrade_tables.go | 8 +- system/dal_connection.cue | 11 +- system/rest.yaml | 57 +--- system/rest/dal_connection.go | 75 ++--- system/rest/request/dalConnection.go | 291 +++--------------- system/service/dal_connection.go | 17 +- system/types/dal_connection.go | 77 +++-- tests/compose/main_test.go | 15 +- tests/compose/record_test.go | 1 + tests/dal/dal_codec_alias_test.go | 5 +- tests/dal/dal_codec_json_test.go | 5 +- tests/dal/dal_codec_plain_test.go | 7 +- tests/dal/dal_crud_compose_record_test.go | 8 +- tests/dal/dal_crud_connection_test.go | 2 +- tests/dal/dal_crud_driver_test.go | 2 +- .../dal_crud_issues_compose_record_test.go | 8 +- tests/dal/dal_utils_test.go | 27 +- tests/dal/main_test.go | 69 ++--- .../connection.json | 65 ++-- .../module.json | 6 +- .../generic/nok_connection_connectivity.json | 65 ++-- .../generic/nok_connection_invalid_type.json | 65 ++-- .../generic/nok_connection_sensitivity.json | 78 ++--- ...odule_missing_field_sensitivity_level.json | 6 +- .../nok_module_missing_sensitivity_level.json | 6 +- .../generic/nok_module_sensitivity_level.json | 6 +- tests/dal/testdata/generic/ok_connection.json | 65 ++-- .../generic/ok_connection_update.json | 65 ++-- tests/dal/testdata/generic/ok_module.json | 4 +- tests/system/dal_connection_crud_test.go | 43 +-- tests/system/dal_driver_crud_test.go | 2 +- .../dal_connection_create/generic.json | 65 ++-- .../generic.json | 65 ++-- .../generic.json | 65 ++-- .../dal_connection_update/generic.json | 65 ++-- .../generic.json | 65 ++-- .../generic.json | 65 ++-- tests/workflows/main_test.go | 15 +- vendor/github.com/beevik/etree/README.md | 2 +- .../en/corteza-webapp-admin/notification.yaml | 6 +- .../mattn/go-sqlite3/sqlite3-binding.c | 4 +- .../mattn/go-sqlite3/sqlite3-binding.h | 4 +- .../minio/sha256-simd/cpuid_linux_arm64.go | 3 +- vendor/go.uber.org/zap/zapcore/doc.go | 2 +- 75 files changed, 1129 insertions(+), 1401 deletions(-) delete mode 100644 pkg/dal/capabilities/capabilities.go create mode 100644 pkg/dal/operations.go rename pkg/dal/{capabilities/capabilities_test.go => operations_test.go} (66%) diff --git a/codegen/assets/templates/gocode/store/rdbms/aux_types.go.tpl b/codegen/assets/templates/gocode/store/rdbms/aux_types.go.tpl index e107a534e..6721e9c6c 100644 --- a/codegen/assets/templates/gocode/store/rdbms/aux_types.go.tpl +++ b/codegen/assets/templates/gocode/store/rdbms/aux_types.go.tpl @@ -5,7 +5,6 @@ package rdbms import ( "time" "github.com/cortezaproject/corteza-server/pkg/expr" - "github.com/cortezaproject/corteza-server/pkg/geolocation" {{- range $path, $alias := .imports }} {{ $alias }} {{ printf "%q" $path }} {{- end }} diff --git a/compose/dalutils/records.go b/compose/dalutils/records.go index d3dd211d9..080f3a5ef 100644 --- a/compose/dalutils/records.go +++ b/compose/dalutils/records.go @@ -2,32 +2,32 @@ package dalutils import ( "context" + "math" + "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" - "math" ) type ( creator interface { - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error } updater interface { - Update(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) + Update(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) } searcher interface { - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) } lookuper interface { - Lookup(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) + Lookup(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) } deleter interface { - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) } ) @@ -57,7 +57,7 @@ func ComposeRecordsIterator(ctx context.Context, s searcher, mod *types.Module, func ComposeRecordsFind(ctx context.Context, l lookuper, mod *types.Module, recordID uint64) (out *types.Record, err error) { out = prepareRecordTarget(mod) - err = l.Lookup(ctx, mod.ModelRef(), recLookupCapabilities(mod), dal.PKValues{"id": recordID}, out) + err = l.Lookup(ctx, mod.ModelRef(), recLookupOperations(mod), dal.PKValues{"id": recordID}, out) if err != nil { return } @@ -66,19 +66,19 @@ func ComposeRecordsFind(ctx context.Context, l lookuper, mod *types.Module, reco } func ComposeRecordCreate(ctx context.Context, c creator, mod *types.Module, records ...*types.Record) (err error) { - return c.Create(ctx, mod.ModelRef(), recCreateCapabilities(mod), recToGetters(records...)...) + return c.Create(ctx, mod.ModelRef(), recCreateOperations(mod), recToGetters(records...)...) } func ComposeRecordUpdate(ctx context.Context, u updater, mod *types.Module, records ...*types.Record) (err error) { - return u.Update(ctx, mod.ModelRef(), recUpdateCapabilities(mod), recToGetters(records...)...) + return u.Update(ctx, mod.ModelRef(), recUpdateOperations(mod), recToGetters(records...)...) } func ComposeRecordSoftDelete(ctx context.Context, u updater, mod *types.Module, records ...*types.Record) (err error) { - return u.Update(ctx, mod.ModelRef(), recUpdateCapabilities(mod), recToGetters(records...)...) + return u.Update(ctx, mod.ModelRef(), recUpdateOperations(mod), recToGetters(records...)...) } func ComposeRecordDelete(ctx context.Context, d deleter, mod *types.Module, records ...*types.Record) (err error) { - return d.Delete(ctx, mod.ModelRef(), recDeleteCapabilities(mod), recToGetters(records...)...) + return d.Delete(ctx, mod.ModelRef(), recDeleteOperations(mod), recToGetters(records...)...) } func WalkIterator(ctx context.Context, iter dal.Iterator, mod *types.Module, f func(r *types.Record) error) (err error) { @@ -111,7 +111,7 @@ func prepFilter(filter types.RecordFilter, mod *types.Module) (dalFilter filter. func prepIterator(ctx context.Context, dal searcher, mod *types.Module, filter types.RecordFilter) (iter dal.Iterator, err error) { dalFilter := prepFilter(filter, mod) - iter, err = dal.Search(ctx, mod.ModelRef(), recSearchCapabilities(mod, filter), dalFilter) + iter, err = dal.Search(ctx, mod.ModelRef(), recSearchOperations(mod, filter), dalFilter) return } @@ -252,43 +252,43 @@ func recToGetters(rr ...*types.Record) (out []dal.ValueGetter) { return } -func recCreateCapabilities(m *types.Module) (out capabilities.Set) { - return capabilities.CreateCapabilities(m.Config.DAL.Capabilities...) +func recCreateOperations(m *types.Module) (out dal.OperationSet) { + return dal.CreateOperations(m.Config.DAL.Operations...) } -func recUpdateCapabilities(m *types.Module) (out capabilities.Set) { - return capabilities.UpdateCapabilities(m.Config.DAL.Capabilities...) +func recUpdateOperations(m *types.Module) (out dal.OperationSet) { + return dal.UpdateOperations(m.Config.DAL.Operations...) } -func recDeleteCapabilities(m *types.Module) (out capabilities.Set) { - return capabilities.DeleteCapabilities(m.Config.DAL.Capabilities...) +func recDeleteOperations(m *types.Module) (out dal.OperationSet) { + return dal.DeleteOperations(m.Config.DAL.Operations...) } -func recFilterCapabilities(f types.RecordFilter) (out capabilities.Set) { +func recFilterOperations(f types.RecordFilter) (out dal.OperationSet) { if f.PageCursor != nil { - out = append(out, capabilities.Paging) + out = append(out, dal.Paging) } if f.IncPageNavigation { - out = append(out, capabilities.Paging) + out = append(out, dal.Paging) } if f.IncTotal { - out = append(out, capabilities.Stats) + out = append(out, dal.Analyze) } if f.Sort != nil { - out = append(out, capabilities.Sorting) + out = append(out, dal.Sorting) } return } -func recSearchCapabilities(m *types.Module, f types.RecordFilter) (out capabilities.Set) { - return capabilities.SearchCapabilities(m.Config.DAL.Capabilities...). - Union(recFilterCapabilities(f)) +func recSearchOperations(m *types.Module, f types.RecordFilter) (out dal.OperationSet) { + return dal.SearchOperations(m.Config.DAL.Operations...). + Union(recFilterOperations(f)) } -func recLookupCapabilities(m *types.Module) (out capabilities.Set) { - return capabilities.LookupCapabilities(m.Config.DAL.Capabilities...) +func recLookupOperations(m *types.Module) (out dal.OperationSet) { + return dal.LookupOperations(m.Config.DAL.Operations...) } diff --git a/compose/service/dal_interfaces.go b/compose/service/dal_interfaces.go index 78b6280f3..74e2d4aa3 100644 --- a/compose/service/dal_interfaces.go +++ b/compose/service/dal_interfaces.go @@ -4,7 +4,6 @@ import ( "context" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" ) @@ -15,18 +14,18 @@ type ( RemoveModel(ctx context.Context, connectionID, ID uint64) (err error) ReplaceModelAttribute(ctx context.Context, model *dal.Model, old, new *dal.Attribute, trans ...dal.TransformationFunction) (err error) - GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionMeta, err error) + GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionConfig, err error) SearchModelIssues(connectionID, resourceID uint64) (out []error) } dalDater interface { - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error - Update(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Lookup(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) - Truncate(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set) (err error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error + Update(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Lookup(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) + Truncate(ctx context.Context, m dal.ModelRef, operations dal.OperationSet) (err error) } dalService interface { diff --git a/compose/service/module.go b/compose/service/module.go index 9219aad8b..97a3f8384 100644 --- a/compose/service/module.go +++ b/compose/service/module.go @@ -11,7 +11,6 @@ import ( "github.com/cortezaproject/corteza-server/pkg/revisions" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/compose/dalutils" @@ -72,8 +71,8 @@ type ( // Model management on DAL Service dalModelManager interface { - GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionMeta, err error) - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) + GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionConfig, err error) + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) ReplaceModel(context.Context, *dal.Model) error RemoveModel(ctx context.Context, connectionID, ID uint64) error @@ -541,7 +540,7 @@ func (svc module) updater(ctx context.Context, namespaceID, moduleID uint64, act if changes&moduleChanged > 0 { { // properly resolve connection ID 0 to the actual ID of the default connection - var defConn dal.ConnectionMeta + var defConn dal.ConnectionConfig defConn, err = svc.dal.GetConnectionMeta(ctx, 0) if err != nil { return err @@ -1176,7 +1175,7 @@ func DalModelRemove(ctx context.Context, dmm dalModelManager, mm ...*types.Modul func moduleToModel(ctx context.Context, dmm dalModelManager, ns *types.Namespace, modules ...*types.Module) (out dal.ModelSet, err error) { var ( - cm dal.ConnectionMeta + cm dal.ConnectionConfig attrAux dal.AttributeSet ) @@ -1200,16 +1199,16 @@ func moduleToModel(ctx context.Context, dmm dalModelManager, ns *types.Namespace for _, mod := range modules { // - base params model := &dal.Model{ - ConnectionID: connectionID, - Label: mod.Handle, - Resource: mod.RbacResource(), - ResourceID: mod.ID, - ResourceType: types.ModuleResourceType, - SensitivityLevel: mod.Config.Privacy.SensitivityLevel, - Capabilities: mod.Config.DAL.Capabilities, + ConnectionID: connectionID, + Label: mod.Handle, + Resource: mod.RbacResource(), + ResourceID: mod.ID, + ResourceType: types.ModuleResourceType, + SensitivityLevelID: mod.Config.Privacy.SensitivityLevelID, + Operations: mod.Config.DAL.Operations, } - model.Ident = cm.DefaultModelIdent + model.Ident = cm.ModelIdent if mod.Config.DAL.Partitioned { model.Ident, err = makeModelIdent(ctx, ff, cm, mod, mod.Config.DAL.PartitionFormat) if err != nil { @@ -1261,13 +1260,13 @@ func moduleToModel(ctx context.Context, dmm dalModelManager, ns *types.Namespace return } -func makeModelIdent(ctx context.Context, ff identFormatter, cm dal.ConnectionMeta, mod *types.Module, ident string) (_ string, err error) { +func makeModelIdent(ctx context.Context, ff identFormatter, cm dal.ConnectionConfig, mod *types.Module, ident string) (_ string, err error) { var ( ok bool ) if ident == "" { - ident = cm.DefaultPartitionFormat + ident = cm.PartitionFormat } ident, ok = ff.Format(ctx, ident, formatterModuleParams(mod)...) @@ -1280,7 +1279,7 @@ func makeModelIdent(ctx context.Context, ff identFormatter, cm dal.ConnectionMet } // moduleFieldsToAttributes converts all user-defined module fields to attributes -func moduleFieldsToAttributes(ctx context.Context, cm dal.ConnectionMeta, ns *types.Namespace, mod *types.Module) (out dal.AttributeSet, err error) { +func moduleFieldsToAttributes(ctx context.Context, cm dal.ConnectionConfig, ns *types.Namespace, mod *types.Module) (out dal.AttributeSet, err error) { out = make(dal.AttributeSet, 0, len(mod.Fields)) var ( attr *dal.Attribute @@ -1298,7 +1297,7 @@ func moduleFieldsToAttributes(ctx context.Context, cm dal.ConnectionMeta, ns *ty } // moduleSystemFieldsToAttributes converts all system-defined module fields to attributes -func moduleSystemFieldsToAttributes(ctx context.Context, cm dal.ConnectionMeta, ns *types.Namespace, mod *types.Module) (out dal.AttributeSet, err error) { +func moduleSystemFieldsToAttributes(ctx context.Context, cm dal.ConnectionConfig, ns *types.Namespace, mod *types.Module) (out dal.AttributeSet, err error) { if mod.Config.DAL.Partitioned { return partitionedModuleSystemFieldsToAttributes(cm, mod), nil } @@ -1307,7 +1306,7 @@ func moduleSystemFieldsToAttributes(ctx context.Context, cm dal.ConnectionMeta, // partitionedModuleSystemFieldsToAttributes converts all system-defined module fields to attributes // keeping user-defined codec in mind -func partitionedModuleSystemFieldsToAttributes(cm dal.ConnectionMeta, mod *types.Module) (out dal.AttributeSet) { +func partitionedModuleSystemFieldsToAttributes(cm dal.ConnectionConfig, mod *types.Module) (out dal.AttributeSet) { var ( sysEnc = mod.Config.DAL.SystemFieldEncoding @@ -1393,7 +1392,7 @@ func defaultModuleSystemFieldsToAttributes() dal.AttributeSet { } // moduleFieldToAttribute converts the given module field to a DAL attribute -func moduleFieldToAttribute(ctx context.Context, cm dal.ConnectionMeta, mod *types.Module, f *types.ModuleField) (out *dal.Attribute, err error) { +func moduleFieldToAttribute(ctx context.Context, cm dal.ConnectionConfig, mod *types.Module, f *types.ModuleField) (out *dal.Attribute, err error) { kind := f.Kind if kind == "" { kind = "String" @@ -1470,7 +1469,7 @@ func moduleFieldToAttribute(ctx context.Context, cm dal.ConnectionMeta, mod *typ return nil, fmt.Errorf("invalid field %s: kind %s not supported", f.Name, f.Kind) } - out.SensitivityLevel = f.Config.Privacy.SensitivityLevel + out.SensitivityLevelID = f.Config.Privacy.SensitivityLevelID out.Label = f.Name out.MultiValue = f.Multi @@ -1504,7 +1503,7 @@ func formatterModuleParams(mod *types.Module) []string { } // modelFieldCodec returns the DAL codec the given module field should use -func modelFieldCodec(cm dal.ConnectionMeta, mod *types.Module, f *types.ModuleField) (c dal.Codec) { +func modelFieldCodec(cm dal.ConnectionConfig, mod *types.Module, f *types.ModuleField) (c dal.Codec) { c = baseModelFieldCodec(cm, mod, f) switch { @@ -1522,12 +1521,12 @@ func modelFieldCodec(cm dal.ConnectionMeta, mod *types.Module, f *types.ModuleFi } // baseModelFieldCodec returns the DAL codec the given module field should use by default -func baseModelFieldCodec(cm dal.ConnectionMeta, mod *types.Module, f *types.ModuleField) dal.Codec { +func baseModelFieldCodec(cm dal.ConnectionConfig, mod *types.Module, f *types.ModuleField) dal.Codec { if mod.Config.DAL.Partitioned { return &dal.CodecPlain{} } - ident := cm.DefaultAttributeIdent + ident := cm.AttributeIdent if ident == "" { // @todo put in configs or something ident = "values" diff --git a/compose/service/module_test.go b/compose/service/module_test.go index fcd1c6a44..a2a80a3f4 100644 --- a/compose/service/module_test.go +++ b/compose/service/module_test.go @@ -93,7 +93,7 @@ func makeTestModuleService(t *testing.T, mods ...any) *module { ctx, dal.MakeConnection(1, svc.store.ToDalConn(), dal.ConnectionParams{}, - dal.ConnectionMeta{DefaultModelIdent: recordsTable, DefaultAttributeIdent: "values"}, + dal.ConnectionConfig{ModelIdent: recordsTable, AttributeIdent: "values"}, ), true, ), diff --git a/compose/service/record_test.go b/compose/service/record_test.go index 7b683c229..e8e3830ff 100644 --- a/compose/service/record_test.go +++ b/compose/service/record_test.go @@ -100,7 +100,7 @@ func makeTestRecordService(t *testing.T, mods ...any) *record { ctx, dal.MakeConnection(1, svc.store.ToDalConn(), dal.ConnectionParams{}, - dal.ConnectionMeta{DefaultModelIdent: recordsTable, DefaultAttributeIdent: "values"}, + dal.ConnectionConfig{ModelIdent: recordsTable, AttributeIdent: "values"}, ), true, ), diff --git a/compose/types/module.go b/compose/types/module.go index dd0e5f1ec..d3621a8ed 100644 --- a/compose/types/module.go +++ b/compose/types/module.go @@ -10,7 +10,6 @@ import ( "github.com/jmoiron/sqlx/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/locale" ) @@ -83,7 +82,7 @@ type ( ModuleConfigDAL struct { ConnectionID uint64 `json:"connectionID,string"` - Capabilities capabilities.Set `json:"capabilities"` + Operations dal.OperationSet `json:"operations"` Constraints map[string][]any `json:"constraints"` @@ -104,7 +103,7 @@ type ( ModuleConfigDataPrivacy struct { // Define the highest sensitivity level which // can be configured on the module fields - SensitivityLevel uint64 `json:"sensitivityLevel,string,omitempty"` + SensitivityLevelID uint64 `json:"sensitivityLevelID,string,omitempty"` UsageDisclosure string `json:"usageDisclosure"` } diff --git a/compose/types/module_field.go b/compose/types/module_field.go index 6beb1a735..13c0dc0e4 100644 --- a/compose/types/module_field.go +++ b/compose/types/module_field.go @@ -3,12 +3,13 @@ package types import ( "database/sql/driver" "encoding/json" - "github.com/cortezaproject/corteza-server/pkg/sql" "sort" "strconv" "strings" "time" + "github.com/cortezaproject/corteza-server/pkg/sql" + "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/locale" "github.com/spf13/cast" @@ -64,7 +65,7 @@ type ( ModuleFieldConfigDataPrivacy struct { // Define the highest sensitivity level which // can be configured on the module fields - SensitivityLevel uint64 `json:"sensitivityLevel,string,omitempty"` + SensitivityLevelID uint64 `json:"sensitivityLevelID,string,omitempty"` UsageDisclosure string `json:"usageDisclosure"` } @@ -523,7 +524,7 @@ func (f ModuleField) IsRef() bool { } func (f ModuleField) IsSensitive() bool { - return f.Config.Privacy.SensitivityLevel > 0 + return f.Config.Privacy.SensitivityLevelID > 0 } func (p *ModuleFieldConfig) Scan(src any) error { return sql.ParseJSON(src, p) } diff --git a/compose/types/record.go b/compose/types/record.go index 98a8caf4b..97aaa6b8f 100644 --- a/compose/types/record.go +++ b/compose/types/record.go @@ -3,10 +3,11 @@ package types import ( "encoding/json" "fmt" - "github.com/cortezaproject/corteza-server/pkg/cast2" "strconv" "time" + "github.com/cortezaproject/corteza-server/pkg/cast2" + "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/modern-go/reflect2" "github.com/spf13/cast" diff --git a/pkg/dal/capabilities/capabilities.go b/pkg/dal/capabilities/capabilities.go deleted file mode 100644 index c5fa8a70f..000000000 --- a/pkg/dal/capabilities/capabilities.go +++ /dev/null @@ -1,173 +0,0 @@ -package capabilities - -type ( - Capability string - Set []Capability -) - -const ( - Create Capability = "corteza::dal:capability:create" - Update Capability = "corteza::dal:capability:update" - Delete Capability = "corteza::dal:capability:delete" - Search Capability = "corteza::dal:capability:search" - Lookup Capability = "corteza::dal:capability:lookup" - Paging Capability = "corteza::dal:capability:paging" - Stats Capability = "corteza::dal:capability:stats" - Sorting Capability = "corteza::dal:capability:sorting" - RBAC Capability = "corteza::dal:capability:RBAC" -) - -var ( - full = Set{ - Create, - Update, - Search, - Lookup, - Paging, - Stats, - Sorting, - RBAC, - } - - accessControlCapabilities = Set{ - RBAC, - } - - createCapabilities = Set{ - RBAC, - Create, - } - - updateCapabilities = Set{ - RBAC, - Update, - } - - deleteCapabilities = Set{ - RBAC, - Update, - } - - searchCapabilities = Set{ - Search, - Paging, - Sorting, - Stats, - RBAC, - } - - lookupCapabilities = Set{ - Lookup, - RBAC, - } -) - -// FullCapabilities returns all base system defined capabilities -func FullCapabilities() (cc Set) { - // Doing an union just to make a fresh copy - return full.Union(nil) -} - -// AccessControlCapabilities returns only requested capabilities used for AccessControl operations -func AccessControlCapabilities(requested ...Capability) (required Set) { - return common(accessControlCapabilities, requested) -} - -// CreateCapabilities returns only requested capabilities used for Create operations -func CreateCapabilities(requested ...Capability) (required Set) { - return common(createCapabilities, requested) -} - -// UpdateCapabilities returns only requested capabilities used for Update operations -func UpdateCapabilities(requested ...Capability) (required Set) { - return common(updateCapabilities, requested) -} - -// DeleteCapabilities returns only requested capabilities used for delete operations -func DeleteCapabilities(requested ...Capability) (required Set) { - return common(deleteCapabilities, requested) -} - -// SearchCapabilities returns only requested capabilities used for Search operations -func SearchCapabilities(requested ...Capability) (required Set) { - return common(searchCapabilities, requested) -} - -// LookupCapabilities returns only requested capabilities used for Search operations -func LookupCapabilities(requested ...Capability) (required Set) { - return common(lookupCapabilities, requested) -} - -func common(aa, bb Set) Set { - return aa.Intersect(bb) -} - -// --- - -// IsSuperset is inverse IsSubset -// -// IsSuperset checks if all bb capabilities are inside aa -func (aa Set) IsSuperset(bb ...Capability) bool { - return Set(bb).IsSubset(aa...) -} - -// IsSubset checks if all aa capabilities are inside bb -func (aa Set) IsSubset(bb ...Capability) bool { - if len(aa) > len(bb) { - return false - } - - // When A is subset of B, the difference between the two must be 0 - return len(aa.Diff(bb)) == 0 -} - -// Intersect returns the intersection between the two sets -func (aa Set) Intersect(bb Set) (cc Set) { - cc = make(Set, 0, len(aa)) - for _, a := range aa { - for _, b := range bb { - if a == b { - cc = append(cc, a) - break - } - } - } - - return -} - -// Intersect returns the union between the two sets -// -// Duplicates are omitted -func (aa Set) Union(bb Set) (cc Set) { - ix := make(map[Capability]bool) - for _, c := range append(aa, bb...) { - if !ix[c] { - ix[c] = true - cc = append(cc, c) - } - } - return -} - -// Diff calculates the difference between the two capability sets -// -// The diff uses aa as base -func (aa Set) Diff(bb Set) (cc Set) { - for _, a := range aa { - found := false - for _, b := range bb { - found = a == b - if found { - break - } - } - - if found { - continue - } - cc = append(cc, a) - } - - return -} diff --git a/pkg/dal/diff.go b/pkg/dal/diff.go index 814332756..0cfcd612e 100644 --- a/pkg/dal/diff.go +++ b/pkg/dal/diff.go @@ -76,7 +76,7 @@ func (a *Model) Diff(b *Model) (out ModelDiffSet) { // Other stuff // @todo improve; for now it'll do - if attrA.SensitivityLevel != attrBAux.attr.SensitivityLevel { + if attrA.SensitivityLevelID != attrBAux.attr.SensitivityLevelID { out = append(out, &ModelDiff{ Type: AttributeSensitivityMissmatch, Original: attrA, diff --git a/pkg/dal/driver.go b/pkg/dal/driver.go index 5ce3e1665..38341a11b 100644 --- a/pkg/dal/driver.go +++ b/pkg/dal/driver.go @@ -7,7 +7,6 @@ import ( "regexp" "strings" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/expr" "github.com/cortezaproject/corteza-server/pkg/filter" "go.uber.org/zap" @@ -30,11 +29,11 @@ type ( // can work out of the box. Models(context.Context) (ModelSet, error) - // Capabilities returns all of the capabilities the given store supports - Capabilities() capabilities.Set + // Operations returns all of the operations the given store supports + Operations() OperationSet - // Can returns true if this store can handle the given capabilities - Can(capabilities ...capabilities.Capability) bool + // Can returns true if this store can handle the given operations + Can(operations ...Operation) bool // DML stuff @@ -101,7 +100,7 @@ type ( SetValue(string, uint, any) error } - ConnectorFn func(ctx context.Context, dsn string, cc ...capabilities.Capability) (Connection, error) + ConnectorFn func(ctx context.Context, dsn string, oo ...Operation) (Connection, error) DriverConnectionParam struct { Key string `json:"key"` @@ -115,9 +114,9 @@ type ( } Driver struct { - Type string `json:"type"` - Connection DriverConnectionConfig `json:"connection"` - Capabilities capabilities.Set `json:"capabilities"` + Type string `json:"type"` + Connection DriverConnectionConfig `json:"connection"` + Operations OperationSet `json:"operations"` } ) @@ -157,7 +156,7 @@ func RegisterDriver(d Driver) { } // connect opens a new StoreConnection for the given CRS -func connect(ctx context.Context, log *zap.Logger, isDevelopment bool, cp ConnectionParams, capabilities ...capabilities.Capability) (Connection, error) { +func connect(ctx context.Context, log *zap.Logger, isDevelopment bool, cp ConnectionParams, operations ...Operation) (Connection, error) { if cp.Type != "corteza::dal:connection:dsn" { return nil, fmt.Errorf("cannot open connection: only DSN connections supported (got: %q)", cp.Type) } @@ -181,7 +180,7 @@ func connect(ctx context.Context, log *zap.Logger, isDevelopment bool, cp Connec } if conn, ok := registeredConnectors[storeType]; ok { - return conn(ctx, dsn, capabilities...) + return conn(ctx, dsn, operations...) } else { return nil, fmt.Errorf("unknown store type used: %q (check your database configuration)", storeType) } diff --git a/pkg/dal/model.go b/pkg/dal/model.go index 575b99d65..e98272766 100644 --- a/pkg/dal/model.go +++ b/pkg/dal/model.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/handle" "github.com/modern-go/reflect2" ) @@ -30,11 +29,11 @@ type ( ResourceID uint64 ResourceType string - SensitivityLevel uint64 + SensitivityLevelID uint64 Attributes AttributeSet - Capabilities capabilities.Set + Operations OperationSet } ModelSet []*Model @@ -43,7 +42,7 @@ type ( Ident string Label string - SensitivityLevel uint64 + SensitivityLevelID uint64 MultiValue bool diff --git a/pkg/dal/operations.go b/pkg/dal/operations.go new file mode 100644 index 000000000..7cc408b4c --- /dev/null +++ b/pkg/dal/operations.go @@ -0,0 +1,160 @@ +package dal + +type ( + Operation string + OperationSet []Operation +) + +const ( + Create Operation = "corteza::dal:operation:create" + Update Operation = "corteza::dal:operation:update" + Delete Operation = "corteza::dal:operation:delete" + Search Operation = "corteza::dal:operation:search" + Lookup Operation = "corteza::dal:operation:lookup" + Paging Operation = "corteza::dal:operation:paging" + Sorting Operation = "corteza::dal:operation:sorting" + Analyze Operation = "corteza::dal:operation:analyze" + + // @todo reporter operations +) + +var ( + full = OperationSet{ + Create, + Update, + Delete, + Search, + Lookup, + Paging, + Sorting, + Analyze, + } + + createOperations = OperationSet{ + Create, + } + + updateOperations = OperationSet{ + Update, + } + + deleteOperations = OperationSet{ + Update, + } + + searchOperations = OperationSet{ + Search, + Paging, + Sorting, + Analyze, + } + + lookupOperations = OperationSet{ + Lookup, + } +) + +// FullOperations returns all base system defined operations +func FullOperations() (cc OperationSet) { + // Doing an union just to make a fresh copy + return full.Union(nil) +} + +// CreateOperations returns only requested operations used for Create operations +func CreateOperations(requested ...Operation) (required OperationSet) { + return common(createOperations, requested) +} + +// UpdateOperations returns only requested operations used for Update operations +func UpdateOperations(requested ...Operation) (required OperationSet) { + return common(updateOperations, requested) +} + +// DeleteOperations returns only requested operations used for delete operations +func DeleteOperations(requested ...Operation) (required OperationSet) { + return common(deleteOperations, requested) +} + +// SearchOperations returns only requested operations used for Search operations +func SearchOperations(requested ...Operation) (required OperationSet) { + return common(searchOperations, requested) +} + +// LookupOperations returns only requested operations used for Search operations +func LookupOperations(requested ...Operation) (required OperationSet) { + return common(lookupOperations, requested) +} + +func common(aa, bb OperationSet) OperationSet { + return aa.Intersect(bb) +} + +// --- + +// IsSuperset is inverse IsSubset +// +// IsSuperset checks if all bb operations are inside aa +func (aa OperationSet) IsSuperset(bb ...Operation) bool { + return OperationSet(bb).IsSubset(aa...) +} + +// IsSubset checks if all aa operations are inside bb +func (aa OperationSet) IsSubset(bb ...Operation) bool { + if len(aa) > len(bb) { + return false + } + + // When A is subset of B, the difference between the two must be 0 + return len(aa.Diff(bb)) == 0 +} + +// Intersect returns the intersection between the two sets +func (aa OperationSet) Intersect(bb OperationSet) (cc OperationSet) { + cc = make(OperationSet, 0, len(aa)) + for _, a := range aa { + for _, b := range bb { + if a == b { + cc = append(cc, a) + break + } + } + } + + return +} + +// Intersect returns the union between the two sets +// +// Duplicates are omitted +func (aa OperationSet) Union(bb OperationSet) (cc OperationSet) { + ix := make(map[Operation]bool) + for _, c := range append(aa, bb...) { + if !ix[c] { + ix[c] = true + cc = append(cc, c) + } + } + return +} + +// Diff calculates the difference between the two operation sets +// +// The diff uses aa as base +func (aa OperationSet) Diff(bb OperationSet) (cc OperationSet) { + for _, a := range aa { + found := false + for _, b := range bb { + found = a == b + if found { + break + } + } + + if found { + continue + } + cc = append(cc, a) + } + + return +} diff --git a/pkg/dal/capabilities/capabilities_test.go b/pkg/dal/operations_test.go similarity index 66% rename from pkg/dal/capabilities/capabilities_test.go rename to pkg/dal/operations_test.go index 52a3c675c..5d5f13d88 100644 --- a/pkg/dal/capabilities/capabilities_test.go +++ b/pkg/dal/operations_test.go @@ -1,4 +1,4 @@ -package capabilities +package dal import ( "testing" @@ -6,50 +6,50 @@ import ( "github.com/stretchr/testify/require" ) -func TestCommonCapabilities(t *testing.T) { +func TestCommonOperations(t *testing.T) { cases := []struct { name string - aa Set - bb Set - cc Set + aa OperationSet + bb OperationSet + cc OperationSet }{{ name: "regular", - aa: Set{ + aa: OperationSet{ Create, Update, }, - bb: Set{ + bb: OperationSet{ Update, Delete, }, - cc: Set{ + cc: OperationSet{ Update, }, }, { name: "no commons", - aa: Set{ + aa: OperationSet{ Create, }, - bb: Set{ + bb: OperationSet{ Delete, }, - cc: Set{}, + cc: OperationSet{}, }, { name: "aa empty", aa: nil, - bb: Set{ + bb: OperationSet{ Update, Delete, }, - cc: Set{}, + cc: OperationSet{}, }, { name: "bb empty", - aa: Set{ + aa: OperationSet{ Create, Update, }, bb: nil, - cc: Set{}, + cc: OperationSet{}, }} for _, c := range cases { @@ -60,56 +60,56 @@ func TestCommonCapabilities(t *testing.T) { } } -func TestCapabilityChecking(t *testing.T) { +func TestOperationChecking(t *testing.T) { cases := []struct { name string - support Set - require Set + support OperationSet + require OperationSet out bool }{{ name: "passing: complete match", - support: Set{ + support: OperationSet{ Create, Update, }, - require: Set{ + require: OperationSet{ Create, Update, }, out: true, }, { name: "passing: supports more then required", - support: Set{ + support: OperationSet{ Create, Update, Delete, }, - require: Set{ + require: OperationSet{ Create, Update, }, out: true, }, { name: "passing: no required", - support: Set{ + support: OperationSet{ Create, Update, Delete, }, - require: Set{}, + require: OperationSet{}, out: true, }, { name: "passing: no required nor supported", - support: Set{}, - require: Set{}, + support: OperationSet{}, + require: OperationSet{}, out: true, }, { name: "failing: missing support", - support: Set{ + support: OperationSet{ Create, Update, }, - require: Set{ + require: OperationSet{ Delete, }, out: false, diff --git a/pkg/dal/service.go b/pkg/dal/service.go index 0b379dffd..7f4da89b1 100644 --- a/pkg/dal/service.go +++ b/pkg/dal/service.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "go.uber.org/zap" ) @@ -14,30 +13,28 @@ type ( ConnectionWrap struct { connectionID uint64 - connection Connection - params ConnectionParams - meta ConnectionMeta - capabilities capabilities.Set + connection Connection + params ConnectionParams + meta ConnectionConfig + operations OperationSet } - ConnectionMeta struct { - ConnectionID uint64 - SensitivityLevel uint64 - Label string + ConnectionConfig struct { + ConnectionID uint64 + SensitivityLevelID uint64 + Label string // When model does not specifiy the ident (table name for example), fallback to this - // @todo we can lose "Default" prefix // @todo do we need a separate setting or can we get away with using just PartitionFormat - DefaultModelIdent string + ModelIdent string // If model attribute(s) do not specify // @todo needs to be more explicit that this is for JSON encode attributes - // @todo we can lose "Default" prefix - DefaultAttributeIdent string + AttributeIdent string // If data is partitioned we fallback to this, // @todo we can lose "Default" prefix - DefaultPartitionFormat string + PartitionFormat string PartitionValidator string } @@ -94,7 +91,7 @@ func New(log *zap.Logger, inDev bool) (*service, error) { // Function will panic if DAL service is not set (via SetGlobal) func Service() *service { if gSvc == nil { - panic("DAL global service not initialized: call dal.InitGlobalService() first") + panic("DAL global service not initialized: call dal.SetGlobal first") } return gSvc @@ -118,6 +115,10 @@ func (svc *service) Purge(ctx context.Context) { // // // // // // // // // // // // // // // // // // // // // // // // // // meta +// Drivers returns a set of drivers registered to the DAL service +// +// The driver outlines connection params and operations supported by the +// underlying system. func (svc *service) Drivers() (drivers []Driver) { for _, d := range registeredDrivers { drivers = append(drivers, d) @@ -126,6 +127,7 @@ func (svc *service) Drivers() (drivers []Driver) { return } +// MakeSensitivityLevel prepares a new sensitivity level func MakeSensitivityLevel(ID uint64, level int, handle string) SensitivityLevel { return SensitivityLevel{ ID: ID, @@ -134,6 +136,7 @@ func MakeSensitivityLevel(ID uint64, level int, handle string) SensitivityLevel } } +// ReplaceSensitivityLevel creates or updates the provided sensitivity levels func (svc *service) ReplaceSensitivityLevel(levels ...SensitivityLevel) (err error) { var ( log = svc.logger.Named("sensitivity level") @@ -170,6 +173,7 @@ func (svc *service) ReplaceSensitivityLevel(levels ...SensitivityLevel) (err err return } +// RemoveSensitivityLevel removes the provided sensitivity levels func (svc *service) RemoveSensitivityLevel(levelIDs ...uint64) (err error) { var ( log = svc.logger.Named("sensitivity level") @@ -216,14 +220,14 @@ func (svc *service) RemoveSensitivityLevel(levelIDs ...uint64) (err error) { // Connection management // MakeConnection makes and returns a new connection (wrap) -func MakeConnection(ID uint64, conn Connection, p ConnectionParams, m ConnectionMeta, cap ...capabilities.Capability) *ConnectionWrap { +func MakeConnection(ID uint64, conn Connection, p ConnectionParams, m ConnectionConfig, oo ...Operation) *ConnectionWrap { return &ConnectionWrap{ connectionID: ID, connection: conn, - params: p, - meta: m, - capabilities: cap, + params: p, + meta: m, + operations: oo, } } @@ -263,29 +267,29 @@ func (svc *service) ReplaceConnection(ctx context.Context, cw *ConnectionWrap, i defer svc.updateIssues(issues) // Sensitivity level validations - if !svc.sensitivityLevels.includes(cw.meta.SensitivityLevel) { - issues.addConnectionIssue(ID, errConnectionCreateMissingSensitivityLevel(ID, cw.meta.SensitivityLevel)) + if !svc.sensitivityLevels.includes(cw.meta.SensitivityLevelID) { + issues.addConnectionIssue(ID, errConnectionCreateMissingSensitivityLevel(ID, cw.meta.SensitivityLevelID)) } if oldConn = svc.getConnectionByID(ID); oldConn != nil { // Connection exists, validate models and sensitivity levels and close and remove connection at the end log.Debug("found existing") - // Check already registered models and their capabilities + // Check already registered models and their operations // // Defer the return till the end so we can get a nicer report of what all is wrong errored := false for _, model := range svc.models[ID] { log.Debug("validating model before connection is updated", zap.String("ident", model.Ident)) - // - capabilities - if !model.Capabilities.IsSubset(cw.capabilities...) { + // - operations + if !model.Operations.IsSubset(cw.operations...) { issues.addConnectionIssue(ID, fmt.Errorf("cannot update connection %d: new connection does not support existing models", ID)) errored = true } // - sensitivity levels - if !svc.sensitivityLevels.isSubset(model.SensitivityLevel, cw.meta.SensitivityLevel) { + if !svc.sensitivityLevels.isSubset(model.SensitivityLevelID, cw.meta.SensitivityLevelID) { issues.addConnectionIssue(ID, fmt.Errorf("cannot update connection %d: new connection sensitivity level does not support model %d", ID, model.ResourceID)) errored = true } @@ -311,7 +315,7 @@ func (svc *service) ReplaceConnection(ctx context.Context, cw *ConnectionWrap, i } if cw.connection == nil { - cw.connection, err = connect(ctx, svc.logger, svc.inDev, cw.params, cw.capabilities...) + cw.connection, err = connect(ctx, svc.logger, svc.inDev, cw.params, cw.operations...) if err != nil { log.Warn("could not connect", zap.Error(err)) issues.addConnectionIssue(ID, err) @@ -320,7 +324,6 @@ func (svc *service) ReplaceConnection(ctx context.Context, cw *ConnectionWrap, i } } else { log.Debug("using preexisting connection") - } svc.addConnection(cw) @@ -332,7 +335,7 @@ func (svc *service) ReplaceConnection(ctx context.Context, cw *ConnectionWrap, i // // The function is primarily used by services which need to know a little bit // about the connection their resources are located in (ident formatting for example). -func (svc *service) GetConnectionMeta(_ context.Context, ID uint64) (cm ConnectionMeta, err error) { +func (svc *service) GetConnectionMeta(_ context.Context, ID uint64) (cm ConnectionConfig, err error) { if ID == 0 { ID = svc.defConnID } @@ -389,12 +392,12 @@ func (svc *service) RemoveConnection(ctx context.Context, ID uint64) (err error) // DML // Create stores new data (create data entry) -func (svc *service) Create(ctx context.Context, mf ModelRef, capabilities capabilities.Set, rr ...ValueGetter) (err error) { +func (svc *service) Create(ctx context.Context, mf ModelRef, operations OperationSet, rr ...ValueGetter) (err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { return fmt.Errorf("cannot create data entry: %w", err) } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { return fmt.Errorf("cannot create data entry: %w", err) } @@ -402,12 +405,12 @@ func (svc *service) Create(ctx context.Context, mf ModelRef, capabilities capabi return cw.connection.Create(ctx, model, rr...) } -func (svc *service) Update(ctx context.Context, mf ModelRef, capabilities capabilities.Set, rr ...ValueGetter) (err error) { +func (svc *service) Update(ctx context.Context, mf ModelRef, operations OperationSet, rr ...ValueGetter) (err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { return fmt.Errorf("cannot update data entry: %w", err) } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { return fmt.Errorf("cannot update data entry: %w", err) } @@ -421,13 +424,13 @@ func (svc *service) Update(ctx context.Context, mf ModelRef, capabilities capabi return } -func (svc *service) Search(ctx context.Context, mf ModelRef, capabilities capabilities.Set, f filter.Filter) (iter Iterator, err error) { +func (svc *service) Search(ctx context.Context, mf ModelRef, operations OperationSet, f filter.Filter) (iter Iterator, err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { err = fmt.Errorf("cannot search data entry: %w", err) return } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { err = fmt.Errorf("cannot search data entry: %w", err) return @@ -436,24 +439,24 @@ func (svc *service) Search(ctx context.Context, mf ModelRef, capabilities capabi return cw.connection.Search(ctx, model, f) } -func (svc *service) Lookup(ctx context.Context, mf ModelRef, capabilities capabilities.Set, lookup ValueGetter, dst ValueSetter) (err error) { +func (svc *service) Lookup(ctx context.Context, mf ModelRef, operations OperationSet, lookup ValueGetter, dst ValueSetter) (err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { return fmt.Errorf("cannot lookup data entry: %w", err) } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { return fmt.Errorf("cannot lookup data entry: %w", err) } return cw.connection.Lookup(ctx, model, lookup, dst) } -func (svc *service) Delete(ctx context.Context, mf ModelRef, capabilities capabilities.Set, vv ...ValueGetter) (err error) { +func (svc *service) Delete(ctx context.Context, mf ModelRef, operations OperationSet, vv ...ValueGetter) (err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { return fmt.Errorf("cannot delete data entry: %w", err) } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { return fmt.Errorf("cannot delete data entry: %w", err) } @@ -466,12 +469,12 @@ func (svc *service) Delete(ctx context.Context, mf ModelRef, capabilities capabi return } -func (svc *service) Truncate(ctx context.Context, mf ModelRef, capabilities capabilities.Set) (err error) { +func (svc *service) Truncate(ctx context.Context, mf ModelRef, operations OperationSet) (err error) { if err = svc.canOpData(mf.ConnectionID, mf.ResourceID); err != nil { return fmt.Errorf("cannot truncate data entry: %w", err) } - model, cw, err := svc.storeOpPrep(ctx, mf, capabilities) + model, cw, err := svc.storeOpPrep(ctx, mf, operations) if err != nil { return fmt.Errorf("cannot truncate data entry: %w", err) } @@ -479,14 +482,14 @@ func (svc *service) Truncate(ctx context.Context, mf ModelRef, capabilities capa return cw.connection.Truncate(ctx, model) } -func (svc *service) storeOpPrep(ctx context.Context, mf ModelRef, capabilities capabilities.Set) (model *Model, cw *ConnectionWrap, err error) { +func (svc *service) storeOpPrep(ctx context.Context, mf ModelRef, operations OperationSet) (model *Model, cw *ConnectionWrap, err error) { model = svc.getModelByFilter(mf) if model == nil { err = errModelNotFound(mf.ResourceID) return } - cw, _, err = svc.getConnection(model.ConnectionID, capabilities...) + cw, _, err = svc.getConnection(model.ConnectionID, operations...) if err != nil { return } @@ -650,22 +653,22 @@ func (svc *service) validateModel(issues *issueHelper, model, oldModel *Model) { } // Sensitivity level ok and valid? - if !svc.sensitivityLevels.includes(model.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateMissingSensitivityLevel(model.ConnectionID, model.ResourceID, model.SensitivityLevel)) + if !svc.sensitivityLevels.includes(model.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateMissingSensitivityLevel(model.ConnectionID, model.ResourceID, model.SensitivityLevelID)) } else { // Only check if it is present - if !svc.sensitivityLevels.isSubset(model.SensitivityLevel, conn.meta.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateGreaterSensitivityLevel(model.ConnectionID, model.ResourceID, model.SensitivityLevel, conn.meta.SensitivityLevel)) + if !svc.sensitivityLevels.isSubset(model.SensitivityLevelID, conn.meta.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateGreaterSensitivityLevel(model.ConnectionID, model.ResourceID, model.SensitivityLevelID, conn.meta.SensitivityLevelID)) } } } func (svc *service) validateAttribute(issues *issueHelper, model *Model, attr *Attribute) { - if !svc.sensitivityLevels.includes(attr.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateMissingAttributeSensitivityLevel(model.ConnectionID, model.ResourceID, attr.SensitivityLevel)) + if !svc.sensitivityLevels.includes(attr.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateMissingAttributeSensitivityLevel(model.ConnectionID, model.ResourceID, attr.SensitivityLevelID)) } else { - if !svc.sensitivityLevels.isSubset(attr.SensitivityLevel, model.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateGreaterAttributeSensitivityLevel(model.ConnectionID, model.ResourceID, attr.SensitivityLevel, model.SensitivityLevel)) + if !svc.sensitivityLevels.isSubset(attr.SensitivityLevelID, model.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errModelCreateGreaterAttributeSensitivityLevel(model.ConnectionID, model.ResourceID, attr.SensitivityLevelID, model.SensitivityLevelID)) } } @@ -733,11 +736,11 @@ func (svc *service) ReplaceModelAttribute(ctx context.Context, model *Model, old // In case we're deleting it we can ignore this check if new != nil { - if !svc.sensitivityLevels.includes(new.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errAttributeUpdateMissingSensitivityLevel(model.ConnectionID, model.ResourceID, new.SensitivityLevel)) + if !svc.sensitivityLevels.includes(new.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errAttributeUpdateMissingSensitivityLevel(model.ConnectionID, model.ResourceID, new.SensitivityLevelID)) } else { - if !svc.sensitivityLevels.isSubset(new.SensitivityLevel, model.SensitivityLevel) { - issues.addModelIssue(model.ConnectionID, model.ResourceID, errAttributeUpdateGreaterSensitivityLevel(model.ConnectionID, model.ResourceID, new.SensitivityLevel, model.SensitivityLevel)) + if !svc.sensitivityLevels.isSubset(new.SensitivityLevelID, model.SensitivityLevelID) { + issues.addModelIssue(model.ConnectionID, model.ResourceID, errAttributeUpdateGreaterSensitivityLevel(model.ConnectionID, model.ResourceID, new.SensitivityLevelID, model.SensitivityLevelID)) } } } @@ -835,7 +838,7 @@ func (svc *service) getConnectionByID(connectionID uint64) (cw *ConnectionWrap) return svc.connections[connectionID] } -func (svc *service) getConnection(connectionID uint64, cc ...capabilities.Capability) (cw *ConnectionWrap, can capabilities.Set, err error) { +func (svc *service) getConnection(connectionID uint64, cc ...Operation) (cw *ConnectionWrap, can OperationSet, err error) { err = func() error { // get the requested connection cw = svc.getConnectionByID(connectionID) @@ -843,11 +846,11 @@ func (svc *service) getConnection(connectionID uint64, cc ...capabilities.Capabi return fmt.Errorf("connection %d does not exist", connectionID) } - // check if connection supports requested capabilities + // check if connection supports requested operations if !cw.connection.Can(cc...) { - return fmt.Errorf("connection %d does not support requested capabilities %v", connectionID, capabilities.Set(cc).Diff(cw.connection.Capabilities())) + return fmt.Errorf("connection %d does not support requested operations %v", connectionID, OperationSet(cc).Diff(cw.connection.Operations())) } - can = cw.connection.Capabilities() + can = cw.connection.Operations() return nil }() @@ -910,27 +913,27 @@ func (svc *service) validateNewSensitivityLevels(levels *sensitivityLevelIndex) c := _c cIndex[c.connectionID] = c - if !levels.includes(c.meta.SensitivityLevel) { - return fmt.Errorf("connection sensitivity level missing %d", c.meta.SensitivityLevel) + if !levels.includes(c.meta.SensitivityLevelID) { + return fmt.Errorf("connection sensitivity level missing %d", c.meta.SensitivityLevelID) } } // - models for _, mm := range svc.models { for _, m := range mm { - if !levels.includes(m.SensitivityLevel) { - return fmt.Errorf("model sensitivity level missing %d", m.SensitivityLevel) + if !levels.includes(m.SensitivityLevelID) { + return fmt.Errorf("model sensitivity level missing %d", m.SensitivityLevelID) } - if !levels.isSubset(m.SensitivityLevel, cIndex[m.ConnectionID].meta.SensitivityLevel) { - return fmt.Errorf("model sensitivity level missing %d", m.SensitivityLevel) + if !levels.isSubset(m.SensitivityLevelID, cIndex[m.ConnectionID].meta.SensitivityLevelID) { + return fmt.Errorf("model sensitivity level missing %d", m.SensitivityLevelID) } for _, attr := range m.Attributes { - if !levels.includes(attr.SensitivityLevel) { - return fmt.Errorf("attribute sensitivity level missing %d", attr.SensitivityLevel) + if !levels.includes(attr.SensitivityLevelID) { + return fmt.Errorf("attribute sensitivity level missing %d", attr.SensitivityLevelID) } - if !levels.isSubset(attr.SensitivityLevel, m.SensitivityLevel) { - return fmt.Errorf("attribute sensitivity level %d greater then model sensitivity level %d", attr.SensitivityLevel, m.SensitivityLevel) + if !levels.isSubset(attr.SensitivityLevelID, m.SensitivityLevelID) { + return fmt.Errorf("attribute sensitivity level %d greater then model sensitivity level %d", attr.SensitivityLevelID, m.SensitivityLevelID) } } } diff --git a/pkg/envoy/store/compose.go b/pkg/envoy/store/compose.go index e0c6de8b9..eff57b4dc 100644 --- a/pkg/envoy/store/compose.go +++ b/pkg/envoy/store/compose.go @@ -9,7 +9,6 @@ import ( "github.com/cortezaproject/corteza-server/compose/service" "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/envoy" "github.com/cortezaproject/corteza-server/pkg/envoy/resource" "github.com/cortezaproject/corteza-server/pkg/filter" @@ -34,10 +33,10 @@ type ( } dalService interface { - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) - Update(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) + Update(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) } composeDecoder struct { diff --git a/pkg/provision/dal.go b/pkg/provision/dal.go index 888289e2b..c2ea09db5 100644 --- a/pkg/provision/dal.go +++ b/pkg/provision/dal.go @@ -2,8 +2,9 @@ package provision import ( "context" + "github.com/cortezaproject/corteza-server/pkg/auth" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" + "github.com/cortezaproject/corteza-server/pkg/dal" "github.com/cortezaproject/corteza-server/pkg/id" "github.com/cortezaproject/corteza-server/store" "github.com/cortezaproject/corteza-server/system/types" @@ -32,18 +33,23 @@ func defaultDalConnection(ctx context.Context, s store.DalConnections) (err erro // Using id.Next since we dropped "special" ids a while ago. // If needed, use the handle ID: id.Next(), - Name: "Primary Database", Handle: types.DalPrimaryConnectionHandle, Type: types.DalPrimaryConnectionResourceType, + Meta: types.ConnectionMeta{ + Name: "Primary Database", + }, + Config: types.ConnectionConfig{ - DefaultModelIdent: DefaultComposeRecordTable, - DefaultAttributeIdent: DefaultComposeRecordValueCol, - DefaultPartitionFormat: DefaultPartitionFormat, - }, - Capabilities: types.ConnectionCapabilities{ - Supported: capabilities.FullCapabilities(), + DAL: types.ConnectionConfigDAL{ + ModelIdent: DefaultComposeRecordTable, + AttributeIdent: DefaultComposeRecordValueCol, + PartitionFormat: DefaultPartitionFormat, + + Operations: dal.FullOperations(), + }, }, + CreatedAt: *now(), CreatedBy: auth.ServiceUser().ID, } diff --git a/pkg/revisions/model.go b/pkg/revisions/model.go index 39faad5df..4d4a6ccc7 100644 --- a/pkg/revisions/model.go +++ b/pkg/revisions/model.go @@ -2,7 +2,6 @@ package revisions import ( "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/id" ) @@ -32,9 +31,9 @@ func Model() *dal.Model { &dal.Attribute{Ident: "comment", Store: &dal.CodecPlain{}, Type: &dal.TypeText{}}, }, - Capabilities: capabilities.Set{ - capabilities.Create, - capabilities.Search, + Operations: dal.OperationSet{ + dal.Create, + dal.Search, }, } } diff --git a/pkg/revisions/service.go b/pkg/revisions/service.go index bf84316f7..fd802dd60 100644 --- a/pkg/revisions/service.go +++ b/pkg/revisions/service.go @@ -2,8 +2,8 @@ package revisions import ( "context" + "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" ) @@ -14,8 +14,8 @@ type ( } creatorSearcher interface { - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error } service struct { @@ -28,10 +28,10 @@ func Service(dal creatorSearcher) *service { } func (svc *service) Search(ctx context.Context, mf dal.ModelRef, f filter.Filter) (_ dal.Iterator, err error) { - return svc.dal.Search(ctx, mf, capabilities.Set{capabilities.Search}, f) + return svc.dal.Search(ctx, mf, dal.OperationSet{dal.Search}, f) } func (svc *service) Create(ctx context.Context, mf dal.ModelRef, revision *Revision) error { - return svc.dal.Create(ctx, mf, capabilities.Set{capabilities.Create}, revision) + return svc.dal.Create(ctx, mf, dal.OperationSet{dal.Create}, revision) } diff --git a/pkg/seeder/seeder.go b/pkg/seeder/seeder.go index ce5752897..58232a55b 100644 --- a/pkg/seeder/seeder.go +++ b/pkg/seeder/seeder.go @@ -10,7 +10,6 @@ import ( cTypes "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/id" lTypes "github.com/cortezaproject/corteza-server/pkg/label/types" @@ -59,9 +58,9 @@ type ( } dalService interface { - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) } moduleService interface { diff --git a/store/adapters/rdbms/aux_types.gen.go b/store/adapters/rdbms/aux_types.gen.go index 9fc1aafa4..8fc7ef5b6 100644 --- a/store/adapters/rdbms/aux_types.gen.go +++ b/store/adapters/rdbms/aux_types.gen.go @@ -7,6 +7,8 @@ package rdbms // import ( + "time" + automationType "github.com/cortezaproject/corteza-server/automation/types" composeType "github.com/cortezaproject/corteza-server/compose/types" federationType "github.com/cortezaproject/corteza-server/federation/types" @@ -14,11 +16,9 @@ import ( discoveryType "github.com/cortezaproject/corteza-server/pkg/discovery/types" "github.com/cortezaproject/corteza-server/pkg/expr" flagType "github.com/cortezaproject/corteza-server/pkg/flag/types" - "github.com/cortezaproject/corteza-server/pkg/geolocation" labelsType "github.com/cortezaproject/corteza-server/pkg/label/types" rbacType "github.com/cortezaproject/corteza-server/pkg/rbac" systemType "github.com/cortezaproject/corteza-server/system/types" - "time" ) type ( @@ -321,21 +321,17 @@ type ( // auxDalConnection is an auxiliary structure used for transporting to/from RDBMS store auxDalConnection struct { - ID uint64 `db:"id"` - Name string `db:"name"` - Handle string `db:"handle"` - Type string `db:"type"` - Location geolocation.Full `db:"location"` - Ownership string `db:"ownership"` - SensitivityLevel uint64 `db:"sensitivity_level"` - Config systemType.ConnectionConfig `db:"config"` - Capabilities systemType.ConnectionCapabilities `db:"capabilities"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt *time.Time `db:"updated_at"` - DeletedAt *time.Time `db:"deleted_at"` - CreatedBy uint64 `db:"created_by"` - UpdatedBy uint64 `db:"updated_by"` - DeletedBy uint64 `db:"deleted_by"` + ID uint64 `db:"id"` + Handle string `db:"handle"` + Type string `db:"type"` + Meta systemType.ConnectionMeta `db:"meta"` + Config systemType.ConnectionConfig `db:"config"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt *time.Time `db:"updated_at"` + DeletedAt *time.Time `db:"deleted_at"` + CreatedBy uint64 `db:"created_by"` + UpdatedBy uint64 `db:"updated_by"` + DeletedBy uint64 `db:"deleted_by"` } // auxDalSensitivityLevel is an auxiliary structure used for transporting to/from RDBMS store @@ -1722,14 +1718,10 @@ func (aux *auxCredential) scan(row scanner) error { // This function is auto-generated func (aux *auxDalConnection) encode(res *systemType.DalConnection) (_ error) { aux.ID = res.ID - aux.Name = res.Name aux.Handle = res.Handle aux.Type = res.Type - aux.Location = res.Location - aux.Ownership = res.Ownership - aux.SensitivityLevel = res.SensitivityLevel + aux.Meta = res.Meta aux.Config = res.Config - aux.Capabilities = res.Capabilities aux.CreatedAt = res.CreatedAt aux.UpdatedAt = res.UpdatedAt aux.DeletedAt = res.DeletedAt @@ -1745,14 +1737,10 @@ func (aux *auxDalConnection) encode(res *systemType.DalConnection) (_ error) { func (aux auxDalConnection) decode() (res *systemType.DalConnection, _ error) { res = new(systemType.DalConnection) res.ID = aux.ID - res.Name = aux.Name res.Handle = aux.Handle res.Type = aux.Type - res.Location = aux.Location - res.Ownership = aux.Ownership - res.SensitivityLevel = aux.SensitivityLevel + res.Meta = aux.Meta res.Config = aux.Config - res.Capabilities = aux.Capabilities res.CreatedAt = aux.CreatedAt res.UpdatedAt = aux.UpdatedAt res.DeletedAt = aux.DeletedAt @@ -1768,14 +1756,10 @@ func (aux auxDalConnection) decode() (res *systemType.DalConnection, _ error) { func (aux *auxDalConnection) scan(row scanner) error { return row.Scan( &aux.ID, - &aux.Name, &aux.Handle, &aux.Type, - &aux.Location, - &aux.Ownership, - &aux.SensitivityLevel, + &aux.Meta, &aux.Config, - &aux.Capabilities, &aux.CreatedAt, &aux.UpdatedAt, &aux.DeletedAt, diff --git a/store/adapters/rdbms/dal/connection.go b/store/adapters/rdbms/dal/connection.go index 4a6a6f847..479fd43a8 100644 --- a/store/adapters/rdbms/dal/connection.go +++ b/store/adapters/rdbms/dal/connection.go @@ -5,7 +5,6 @@ import ( "sync" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/store/adapters/rdbms/drivers" "github.com/jmoiron/sqlx" @@ -16,9 +15,9 @@ type ( // // In other words: this allows Corteza to read Records from the supported SQL databases connection struct { - mux sync.RWMutex - models map[string]*model - capabilities capabilities.Set + mux sync.RWMutex + models map[string]*model + operations dal.OperationSet db sqlx.ExtContext dialect drivers.Dialect @@ -27,18 +26,18 @@ type ( func init() { dal.RegisterDriver(dal.Driver{ - Type: "corteza::dal:driver:rdbms", - Capabilities: capabilities.FullCapabilities(), - Connection: dal.NewDSNDriverConnectionConfig(), + Type: "corteza::dal:driver:rdbms", + Operations: dal.FullOperations(), + Connection: dal.NewDSNDriverConnectionConfig(), }) } -func Connection(db sqlx.ExtContext, dialect drivers.Dialect, cc ...capabilities.Capability) *connection { +func Connection(db sqlx.ExtContext, dialect drivers.Dialect, cc ...dal.Operation) *connection { return &connection{ - db: db, - dialect: dialect, - models: make(map[string]*model), - capabilities: cc, + db: db, + dialect: dialect, + models: make(map[string]*model), + operations: cc, } } @@ -68,12 +67,12 @@ func (c *connection) model(m *dal.Model) *model { return c.models[key] } -func (c *connection) Capabilities() capabilities.Set { - return c.capabilities +func (c *connection) Operations() dal.OperationSet { + return c.operations } -func (c *connection) Can(capabilities ...capabilities.Capability) bool { - return c.capabilities.IsSuperset(capabilities...) +func (c *connection) Can(operations ...dal.Operation) bool { + return c.operations.IsSuperset(operations...) } func (c *connection) Create(ctx context.Context, m *dal.Model, rr ...dal.ValueGetter) error { diff --git a/store/adapters/rdbms/drivers/mysql/connect.go b/store/adapters/rdbms/drivers/mysql/connect.go index f1e27c77a..60327f60a 100644 --- a/store/adapters/rdbms/drivers/mysql/connect.go +++ b/store/adapters/rdbms/drivers/mysql/connect.go @@ -4,10 +4,11 @@ import ( "context" "database/sql" "fmt" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" - "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" "strings" + pkgdal "github.com/cortezaproject/corteza-server/pkg/dal" + "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" + "github.com/cortezaproject/corteza-server/pkg/errors" "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/store" @@ -45,7 +46,7 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) { s := &rdbms.Store{ DB: db, - DAL: dal.Connection(db, Dialect(), capabilities.FullCapabilities()...), + DAL: dal.Connection(db, Dialect(), pkgdal.FullOperations()...), Dialect: goquDialectWrapper, TxRetryErrHandler: txRetryErrHandler, diff --git a/store/adapters/rdbms/drivers/mysql/dal.go b/store/adapters/rdbms/drivers/mysql/dal.go index 4c4151efb..84de47c86 100644 --- a/store/adapters/rdbms/drivers/mysql/dal.go +++ b/store/adapters/rdbms/drivers/mysql/dal.go @@ -4,7 +4,6 @@ import ( "context" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" rdbmsdal "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" ) @@ -12,7 +11,7 @@ func init() { dal.RegisterConnector(dalConnector, baseSchema, debugSchema) } -func dalConnector(ctx context.Context, dsn string, cc ...capabilities.Capability) (_ dal.Connection, err error) { +func dalConnector(ctx context.Context, dsn string, cc ...dal.Operation) (_ dal.Connection, err error) { cfg, err := NewConfig(dsn) if err != nil { return diff --git a/store/adapters/rdbms/drivers/postgres/connect.go b/store/adapters/rdbms/drivers/postgres/connect.go index eff1393ff..87db82eb2 100644 --- a/store/adapters/rdbms/drivers/postgres/connect.go +++ b/store/adapters/rdbms/drivers/postgres/connect.go @@ -3,11 +3,12 @@ package postgres import ( "context" "database/sql" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" - "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" "net/url" "strings" + pkgdal "github.com/cortezaproject/corteza-server/pkg/dal" + "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" + "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/store" "github.com/cortezaproject/corteza-server/store/adapters/rdbms" @@ -48,7 +49,7 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) { s := &rdbms.Store{ DB: db, - DAL: dal.Connection(db, Dialect(), capabilities.FullCapabilities()...), + DAL: dal.Connection(db, Dialect(), pkgdal.FullOperations()...), Dialect: goquDialectWrapper, ErrorHandler: errorHandler, diff --git a/store/adapters/rdbms/drivers/postgres/dal.go b/store/adapters/rdbms/drivers/postgres/dal.go index adf5548a1..4ac50e0c1 100644 --- a/store/adapters/rdbms/drivers/postgres/dal.go +++ b/store/adapters/rdbms/drivers/postgres/dal.go @@ -4,7 +4,6 @@ import ( "context" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/store/adapters/rdbms" rdbmsdal "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" @@ -15,7 +14,7 @@ func init() { dal.RegisterConnector(dalConnector, baseSchema, debugSchema) } -func dalConnector(ctx context.Context, dsn string, cc ...capabilities.Capability) (_ dal.Connection, err error) { +func dalConnector(ctx context.Context, dsn string, cc ...dal.Operation) (_ dal.Connection, err error) { var ( db *sqlx.DB cfg *rdbms.ConnConfig diff --git a/store/adapters/rdbms/drivers/sqlite/connect.go b/store/adapters/rdbms/drivers/sqlite/connect.go index feeeb85e2..4452c5334 100644 --- a/store/adapters/rdbms/drivers/sqlite/connect.go +++ b/store/adapters/rdbms/drivers/sqlite/connect.go @@ -4,11 +4,12 @@ import ( "context" "database/sql" "fmt" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" - "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" "regexp" "strings" + pkgdal "github.com/cortezaproject/corteza-server/pkg/dal" + "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" + "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/store" "github.com/cortezaproject/corteza-server/store/adapters/rdbms" @@ -69,7 +70,7 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) { s := &rdbms.Store{ DB: db, - DAL: dal.Connection(db, Dialect(), capabilities.FullCapabilities()...), + DAL: dal.Connection(db, Dialect(), pkgdal.FullOperations()...), Dialect: goquDialectWrapper, ErrorHandler: errorHandler, diff --git a/store/adapters/rdbms/drivers/sqlite/dal.go b/store/adapters/rdbms/drivers/sqlite/dal.go index 4ecacb4bf..75748e6f3 100644 --- a/store/adapters/rdbms/drivers/sqlite/dal.go +++ b/store/adapters/rdbms/drivers/sqlite/dal.go @@ -4,7 +4,6 @@ import ( "context" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/logger" "github.com/cortezaproject/corteza-server/store/adapters/rdbms" rdbmsdal "github.com/cortezaproject/corteza-server/store/adapters/rdbms/dal" @@ -15,7 +14,7 @@ func init() { dal.RegisterConnector(dalConnector, baseSchema, altSchema, debugSchema) } -func dalConnector(ctx context.Context, dsn string, cc ...capabilities.Capability) (_ dal.Connection, err error) { +func dalConnector(ctx context.Context, dsn string, cc ...dal.Operation) (_ dal.Connection, err error) { var ( db *sqlx.DB cfg *rdbms.ConnConfig diff --git a/store/adapters/rdbms/queries.gen.go b/store/adapters/rdbms/queries.gen.go index 29b0f8383..a56208bdb 100644 --- a/store/adapters/rdbms/queries.gen.go +++ b/store/adapters/rdbms/queries.gen.go @@ -2202,14 +2202,10 @@ var ( dalConnectionSelectQuery = func(d goqu.DialectWrapper) *goqu.SelectDataset { return d.Select( "id", - "name", "handle", "type", - "location", - "ownership", - "sensitivity_level", + "meta", "config", - "capabilities", "created_at", "updated_at", "deleted_at", @@ -2225,21 +2221,17 @@ var ( dalConnectionInsertQuery = func(d goqu.DialectWrapper, res *systemType.DalConnection) *goqu.InsertDataset { return d.Insert(dalConnectionTable). Rows(goqu.Record{ - "id": res.ID, - "name": res.Name, - "handle": res.Handle, - "type": res.Type, - "location": res.Location, - "ownership": res.Ownership, - "sensitivity_level": res.SensitivityLevel, - "config": res.Config, - "capabilities": res.Capabilities, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "id": res.ID, + "handle": res.Handle, + "type": res.Type, + "meta": res.Meta, + "config": res.Config, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }) } @@ -2253,20 +2245,16 @@ var ( OnConflict( goqu.DoUpdate(target[1:], goqu.Record{ - "name": res.Name, - "handle": res.Handle, - "type": res.Type, - "location": res.Location, - "ownership": res.Ownership, - "sensitivity_level": res.SensitivityLevel, - "config": res.Config, - "capabilities": res.Capabilities, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "type": res.Type, + "meta": res.Meta, + "config": res.Config, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }, ), ) @@ -2278,20 +2266,16 @@ var ( dalConnectionUpdateQuery = func(d goqu.DialectWrapper, res *systemType.DalConnection) *goqu.UpdateDataset { return d.Update(dalConnectionTable). Set(goqu.Record{ - "name": res.Name, - "handle": res.Handle, - "type": res.Type, - "location": res.Location, - "ownership": res.Ownership, - "sensitivity_level": res.SensitivityLevel, - "config": res.Config, - "capabilities": res.Capabilities, - "created_at": res.CreatedAt, - "updated_at": res.UpdatedAt, - "deleted_at": res.DeletedAt, - "created_by": res.CreatedBy, - "updated_by": res.UpdatedBy, - "deleted_by": res.DeletedBy, + "handle": res.Handle, + "type": res.Type, + "meta": res.Meta, + "config": res.Config, + "created_at": res.CreatedAt, + "updated_at": res.UpdatedAt, + "deleted_at": res.DeletedAt, + "created_by": res.CreatedBy, + "updated_by": res.UpdatedBy, + "deleted_by": res.DeletedBy, }). Where(dalConnectionPrimaryKeys(res)) } diff --git a/store/adapters/rdbms/rdbms.gen.go b/store/adapters/rdbms/rdbms.gen.go index 5d4ea4610..96277de8c 100644 --- a/store/adapters/rdbms/rdbms.gen.go +++ b/store/adapters/rdbms/rdbms.gen.go @@ -9270,7 +9270,6 @@ func (Store) sortableDalConnectionFields() map[string]string { "deletedat": "deleted_at", "handle": "handle", "id": "id", - "name": "name", "type": "type", "updated_at": "updated_at", "updatedat": "updated_at", @@ -9302,8 +9301,6 @@ func (s *Store) collectDalConnectionCursorValues(res *systemType.DalConnection, case "id": cur.Set(c.Column, res.ID, c.Descending) pkID = true - case "name": - cur.Set(c.Column, res.Name, c.Descending) case "handle": cur.Set(c.Column, res.Handle, c.Descending) hasUnique = true diff --git a/store/adapters/rdbms/upgrade_tables.go b/store/adapters/rdbms/upgrade_tables.go index 5fc389de3..a226905ba 100644 --- a/store/adapters/rdbms/upgrade_tables.go +++ b/store/adapters/rdbms/upgrade_tables.go @@ -103,15 +103,11 @@ func tableDalConnections() *Table { ID, ColumnDef("handle", ColumnTypeVarchar, ColumnTypeLength(handleLength)), - ColumnDef("name", ColumnTypeText), ColumnDef("type", ColumnTypeText), - ColumnDef("location", ColumnTypeJson, Null), - ColumnDef("ownership", ColumnTypeText), - ColumnDef("sensitivity_level", ColumnTypeIdentifier), - ColumnDef("config", ColumnTypeJson), - ColumnDef("capabilities", ColumnTypeJson), + ColumnDef("meta", ColumnTypeJson), + CUDTimestamps, CUDUsers, diff --git a/system/dal_connection.cue b/system/dal_connection.cue index 4ab1023b7..38eecb73c 100644 --- a/system/dal_connection.cue +++ b/system/dal_connection.cue @@ -7,18 +7,11 @@ import ( dal_connection: { model: { id: schema.IdField - name: { sortable: true, goType: "string" } handle: schema.HandleField - - // omitting isPrimary and replacing with a special type type: { sortable: true } - location: { goType: "geolocation.Full" } - ownership: {} - sensitivity_level: { goType: "uint64" } - - config: {goType: "types.ConnectionConfig"} - capabilities: {goType: "types.ConnectionCapabilities"} + meta: { goType: "types.ConnectionMeta" } + config: { goType: "types.ConnectionConfig" } created_at: schema.SortableTimestampField updated_at: schema.SortableTimestampNilField diff --git a/system/rest.yaml b/system/rest.yaml index a7bbd4f14..75761ad1f 100644 --- a/system/rest.yaml +++ b/system/rest.yaml @@ -856,7 +856,6 @@ endpoints: - Session ID imports: - github.com/cortezaproject/corteza-server/system/types - - github.com/cortezaproject/corteza-server/pkg/geolocation apis: - name: list method: GET @@ -890,39 +889,21 @@ endpoints: type: string required: true title: handle - - name: name - type: string - required: true - title: name - name: type type: string required: true title: type - - - name: location - type: "geolocation.Full" + - name: meta + type: types.ConnectionMeta required: true - title: location - parser: geolocation.Parse - - name: ownership - type: string - required: true - title: ownership - - name: sensitivityLevel - type: uint64 - required: false - title: sensitivityLevel - + title: meta + parser: types.ParseConnectionMeta - name: config type: types.ConnectionConfig required: true title: config parser: types.ParseConnectionConfig - - name: capabilities - type: types.ConnectionCapabilities - required: true - title: capabilities - parser: types.ParseConnectionCapabilities + - name: update method: PUT title: Update connection details @@ -938,39 +919,21 @@ endpoints: type: string required: true title: handle - - name: name - type: string - required: true - title: name - name: type type: string required: true title: type - - - name: location - type: "geolocation.Full" + - name: meta + type: types.ConnectionMeta required: true - title: location - parser: geolocation.Parse - - name: ownership - type: string - required: true - title: ownership - - name: sensitivityLevel - type: uint64 - required: false - title: sensitivityLevel - + title: meta + parser: types.ParseConnectionMeta - name: config type: types.ConnectionConfig required: true title: config parser: types.ParseConnectionConfig - - name: capabilities - type: types.ConnectionCapabilities - required: true - title: capabilities - parser: types.ParseConnectionCapabilities + - name: read method: GET title: Read connection details diff --git a/system/rest/dal_connection.go b/system/rest/dal_connection.go index b3e96358b..9c1ae1a8b 100644 --- a/system/rest/dal_connection.go +++ b/system/rest/dal_connection.go @@ -10,7 +10,6 @@ import ( federationTypes "github.com/cortezaproject/corteza-server/federation/types" "github.com/cortezaproject/corteza-server/pkg/api" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/handle" "github.com/cortezaproject/corteza-server/pkg/payload" @@ -39,14 +38,24 @@ type ( } connectionWrapSet []connectionWrap + connectionPayload struct { + *types.DalConnection + + CanGrant bool `json:"canGrant"` + CanUpdateConnection bool `json:"canUpdateConnection"` + CanDeleteConnection bool `json:"canDeleteConnection"` + } + connectionSetPayload struct { Filter types.DalConnectionFilter `json:"filter"` - Set types.DalConnectionSet `json:"set"` + Set []*connectionPayload `json:"set"` } connectionAccessController interface { + CanGrant(context.Context) bool CanCreateDalConnection(context.Context) bool CanUpdateDalConnection(context.Context, *types.DalConnection) bool + CanDeleteDalConnection(context.Context, *types.DalConnection) bool } connectionService interface { @@ -100,16 +109,10 @@ func (ctrl DalConnection) List(ctx context.Context, r *request.DalConnectionList func (ctrl DalConnection) Create(ctx context.Context, r *request.DalConnectionCreate) (interface{}, error) { connection := &types.DalConnection{ - Name: r.Name, Handle: r.Handle, Type: r.Type, - - Location: r.Location, - Ownership: r.Ownership, - SensitivityLevel: r.SensitivityLevel, - - Config: r.Config, - Capabilities: r.Capabilities, + Meta: r.Meta, + Config: r.Config, } return ctrl.svc.Create(ctx, connection) @@ -118,16 +121,10 @@ func (ctrl DalConnection) Create(ctx context.Context, r *request.DalConnectionCr func (ctrl DalConnection) Update(ctx context.Context, r *request.DalConnectionUpdate) (interface{}, error) { connection := &types.DalConnection{ ID: r.ConnectionID, - Name: r.Name, Handle: r.Handle, Type: r.Type, - - Location: r.Location, - Ownership: r.Ownership, - SensitivityLevel: r.SensitivityLevel, - - Config: r.Config, - Capabilities: r.Capabilities, + Meta: r.Meta, + Config: r.Config, } return ctrl.svc.Update(ctx, connection) @@ -148,36 +145,40 @@ func (ctrl DalConnection) Undelete(ctx context.Context, r *request.DalConnection func (ctrl DalConnection) makeFilterPayload(ctx context.Context, connections types.DalConnectionSet, f types.DalConnectionFilter) (out *connectionSetPayload, err error) { out = &connectionSetPayload{ Filter: f, - Set: make(types.DalConnectionSet, 0), + Set: make([]*connectionPayload, 0, len(connections)), } for _, c := range connections { - if c.Capabilities.Enforced == nil { - c.Capabilities.Enforced = capabilities.Set{} - } - if c.Capabilities.Supported == nil { - c.Capabilities.Supported = capabilities.Set{} - } - if c.Capabilities.Unsupported == nil { - c.Capabilities.Unsupported = capabilities.Set{} - } - if c.Capabilities.Enabled == nil { - c.Capabilities.Enabled = capabilities.Set{} - } + c.Config.DAL.Operations = append(dal.OperationSet{}, c.Config.DAL.Operations...) + + out.Set = append(out.Set, ctrl.makePayload(ctx, c)) } - out.Set = append(out.Set, connections...) return } +func (ctrl DalConnection) makePayload(ctx context.Context, c *types.DalConnection) *connectionPayload { + return &connectionPayload{ + DalConnection: c, + + CanGrant: ctrl.connectionAc.CanGrant(ctx), + CanUpdateConnection: ctrl.connectionAc.CanUpdateDalConnection(ctx, c), + CanDeleteConnection: ctrl.connectionAc.CanDeleteDalConnection(ctx, c), + } +} + func (ctrl DalConnection) federatedNodeToConnection(f *federationTypes.Node) *types.DalConnection { h, _ := handle.Cast(nil, f.Name) return &types.DalConnection{ - ID: f.ID, - Name: f.Name, - Handle: h, - Type: federationTypes.NodeResourceType, - Ownership: f.Contact, + ID: f.ID, + + Meta: types.ConnectionMeta{ + Name: f.Name, + Ownership: f.Contact, + }, + + Handle: h, + Type: federationTypes.NodeResourceType, Config: types.ConnectionConfig{ Connection: dal.NewFederatedNodeCOnnection(f.BaseURL, f.PairToken, f.AuthToken), diff --git a/system/rest/request/dalConnection.go b/system/rest/request/dalConnection.go index c6db5e4e4..52dd79d90 100644 --- a/system/rest/request/dalConnection.go +++ b/system/rest/request/dalConnection.go @@ -11,7 +11,6 @@ package request import ( "encoding/json" "fmt" - "github.com/cortezaproject/corteza-server/pkg/geolocation" "github.com/cortezaproject/corteza-server/pkg/payload" "github.com/cortezaproject/corteza-server/system/types" "github.com/go-chi/chi/v5" @@ -63,40 +62,20 @@ type ( // handle Handle string - // Name POST parameter - // - // name - Name string - // Type POST parameter // // type Type string - // Location POST parameter + // Meta POST parameter // - // location - Location geolocation.Full - - // Ownership POST parameter - // - // ownership - Ownership string - - // SensitivityLevel POST parameter - // - // sensitivityLevel - SensitivityLevel uint64 `json:",string"` + // meta + Meta types.ConnectionMeta // Config POST parameter // // config Config types.ConnectionConfig - - // Capabilities POST parameter - // - // capabilities - Capabilities types.ConnectionCapabilities } DalConnectionUpdate struct { @@ -110,40 +89,20 @@ type ( // handle Handle string - // Name POST parameter - // - // name - Name string - // Type POST parameter // // type Type string - // Location POST parameter + // Meta POST parameter // - // location - Location geolocation.Full - - // Ownership POST parameter - // - // ownership - Ownership string - - // SensitivityLevel POST parameter - // - // sensitivityLevel - SensitivityLevel uint64 `json:",string"` + // meta + Meta types.ConnectionMeta // Config POST parameter // // config Config types.ConnectionConfig - - // Capabilities POST parameter - // - // capabilities - Capabilities types.ConnectionCapabilities } DalConnectionRead struct { @@ -252,14 +211,10 @@ func NewDalConnectionCreate() *DalConnectionCreate { // Auditable returns all auditable/loggable parameters func (r DalConnectionCreate) Auditable() map[string]interface{} { return map[string]interface{}{ - "handle": r.Handle, - "name": r.Name, - "type": r.Type, - "location": r.Location, - "ownership": r.Ownership, - "sensitivityLevel": r.SensitivityLevel, - "config": r.Config, - "capabilities": r.Capabilities, + "handle": r.Handle, + "type": r.Type, + "meta": r.Meta, + "config": r.Config, } } @@ -268,29 +223,14 @@ func (r DalConnectionCreate) GetHandle() string { return r.Handle } -// Auditable returns all auditable/loggable parameters -func (r DalConnectionCreate) GetName() string { - return r.Name -} - // Auditable returns all auditable/loggable parameters func (r DalConnectionCreate) GetType() string { return r.Type } // Auditable returns all auditable/loggable parameters -func (r DalConnectionCreate) GetLocation() geolocation.Full { - return r.Location -} - -// Auditable returns all auditable/loggable parameters -func (r DalConnectionCreate) GetOwnership() string { - return r.Ownership -} - -// Auditable returns all auditable/loggable parameters -func (r DalConnectionCreate) GetSensitivityLevel() uint64 { - return r.SensitivityLevel +func (r DalConnectionCreate) GetMeta() types.ConnectionMeta { + return r.Meta } // Auditable returns all auditable/loggable parameters @@ -298,11 +238,6 @@ func (r DalConnectionCreate) GetConfig() types.ConnectionConfig { return r.Config } -// Auditable returns all auditable/loggable parameters -func (r DalConnectionCreate) GetCapabilities() types.ConnectionCapabilities { - return r.Capabilities -} - // Fill processes request and fills internal variables func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { @@ -331,13 +266,6 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { } } - if val, ok := req.MultipartForm.Value["name"]; ok && len(val) > 0 { - r.Name, err = val[0], nil - if err != nil { - return err - } - } - if val, ok := req.MultipartForm.Value["type"]; ok && len(val) > 0 { r.Type, err = val[0], nil if err != nil { @@ -345,27 +273,13 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { } } - if val, ok := req.MultipartForm.Value["location[]"]; ok { - r.Location, err = geolocation.Parse(val) + if val, ok := req.MultipartForm.Value["meta[]"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } - } else if val, ok := req.MultipartForm.Value["location"]; ok { - r.Location, err = geolocation.Parse(val) - if err != nil { - return err - } - } - - if val, ok := req.MultipartForm.Value["ownership"]; ok && len(val) > 0 { - r.Ownership, err = val[0], nil - if err != nil { - return err - } - } - - if val, ok := req.MultipartForm.Value["sensitivityLevel"]; ok && len(val) > 0 { - r.SensitivityLevel, err = payload.ParseUint64(val[0]), nil + } else if val, ok := req.MultipartForm.Value["meta"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } @@ -382,18 +296,6 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { return err } } - - if val, ok := req.MultipartForm.Value["capabilities[]"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } else if val, ok := req.MultipartForm.Value["capabilities"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } } } @@ -411,13 +313,6 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { } } - if val, ok := req.Form["name"]; ok && len(val) > 0 { - r.Name, err = val[0], nil - if err != nil { - return err - } - } - if val, ok := req.Form["type"]; ok && len(val) > 0 { r.Type, err = val[0], nil if err != nil { @@ -425,27 +320,13 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { } } - if val, ok := req.Form["location[]"]; ok { - r.Location, err = geolocation.Parse(val) + if val, ok := req.Form["meta[]"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } - } else if val, ok := req.Form["location"]; ok { - r.Location, err = geolocation.Parse(val) - if err != nil { - return err - } - } - - if val, ok := req.Form["ownership"]; ok && len(val) > 0 { - r.Ownership, err = val[0], nil - if err != nil { - return err - } - } - - if val, ok := req.Form["sensitivityLevel"]; ok && len(val) > 0 { - r.SensitivityLevel, err = payload.ParseUint64(val[0]), nil + } else if val, ok := req.Form["meta"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } @@ -462,18 +343,6 @@ func (r *DalConnectionCreate) Fill(req *http.Request) (err error) { return err } } - - if val, ok := req.Form["capabilities[]"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } else if val, ok := req.Form["capabilities"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } } return err @@ -487,15 +356,11 @@ func NewDalConnectionUpdate() *DalConnectionUpdate { // Auditable returns all auditable/loggable parameters func (r DalConnectionUpdate) Auditable() map[string]interface{} { return map[string]interface{}{ - "connectionID": r.ConnectionID, - "handle": r.Handle, - "name": r.Name, - "type": r.Type, - "location": r.Location, - "ownership": r.Ownership, - "sensitivityLevel": r.SensitivityLevel, - "config": r.Config, - "capabilities": r.Capabilities, + "connectionID": r.ConnectionID, + "handle": r.Handle, + "type": r.Type, + "meta": r.Meta, + "config": r.Config, } } @@ -509,29 +374,14 @@ func (r DalConnectionUpdate) GetHandle() string { return r.Handle } -// Auditable returns all auditable/loggable parameters -func (r DalConnectionUpdate) GetName() string { - return r.Name -} - // Auditable returns all auditable/loggable parameters func (r DalConnectionUpdate) GetType() string { return r.Type } // Auditable returns all auditable/loggable parameters -func (r DalConnectionUpdate) GetLocation() geolocation.Full { - return r.Location -} - -// Auditable returns all auditable/loggable parameters -func (r DalConnectionUpdate) GetOwnership() string { - return r.Ownership -} - -// Auditable returns all auditable/loggable parameters -func (r DalConnectionUpdate) GetSensitivityLevel() uint64 { - return r.SensitivityLevel +func (r DalConnectionUpdate) GetMeta() types.ConnectionMeta { + return r.Meta } // Auditable returns all auditable/loggable parameters @@ -539,11 +389,6 @@ func (r DalConnectionUpdate) GetConfig() types.ConnectionConfig { return r.Config } -// Auditable returns all auditable/loggable parameters -func (r DalConnectionUpdate) GetCapabilities() types.ConnectionCapabilities { - return r.Capabilities -} - // Fill processes request and fills internal variables func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { @@ -572,13 +417,6 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { } } - if val, ok := req.MultipartForm.Value["name"]; ok && len(val) > 0 { - r.Name, err = val[0], nil - if err != nil { - return err - } - } - if val, ok := req.MultipartForm.Value["type"]; ok && len(val) > 0 { r.Type, err = val[0], nil if err != nil { @@ -586,27 +424,13 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { } } - if val, ok := req.MultipartForm.Value["location[]"]; ok { - r.Location, err = geolocation.Parse(val) + if val, ok := req.MultipartForm.Value["meta[]"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } - } else if val, ok := req.MultipartForm.Value["location"]; ok { - r.Location, err = geolocation.Parse(val) - if err != nil { - return err - } - } - - if val, ok := req.MultipartForm.Value["ownership"]; ok && len(val) > 0 { - r.Ownership, err = val[0], nil - if err != nil { - return err - } - } - - if val, ok := req.MultipartForm.Value["sensitivityLevel"]; ok && len(val) > 0 { - r.SensitivityLevel, err = payload.ParseUint64(val[0]), nil + } else if val, ok := req.MultipartForm.Value["meta"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } @@ -623,18 +447,6 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { return err } } - - if val, ok := req.MultipartForm.Value["capabilities[]"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } else if val, ok := req.MultipartForm.Value["capabilities"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } } } @@ -652,13 +464,6 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { } } - if val, ok := req.Form["name"]; ok && len(val) > 0 { - r.Name, err = val[0], nil - if err != nil { - return err - } - } - if val, ok := req.Form["type"]; ok && len(val) > 0 { r.Type, err = val[0], nil if err != nil { @@ -666,27 +471,13 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { } } - if val, ok := req.Form["location[]"]; ok { - r.Location, err = geolocation.Parse(val) + if val, ok := req.Form["meta[]"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } - } else if val, ok := req.Form["location"]; ok { - r.Location, err = geolocation.Parse(val) - if err != nil { - return err - } - } - - if val, ok := req.Form["ownership"]; ok && len(val) > 0 { - r.Ownership, err = val[0], nil - if err != nil { - return err - } - } - - if val, ok := req.Form["sensitivityLevel"]; ok && len(val) > 0 { - r.SensitivityLevel, err = payload.ParseUint64(val[0]), nil + } else if val, ok := req.Form["meta"]; ok { + r.Meta, err = types.ParseConnectionMeta(val) if err != nil { return err } @@ -703,18 +494,6 @@ func (r *DalConnectionUpdate) Fill(req *http.Request) (err error) { return err } } - - if val, ok := req.Form["capabilities[]"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } else if val, ok := req.Form["capabilities"]; ok { - r.Capabilities, err = types.ParseConnectionCapabilities(val) - if err != nil { - return err - } - } } { diff --git a/system/service/dal_connection.go b/system/service/dal_connection.go index 086918d4a..b5f7be4ab 100644 --- a/system/service/dal_connection.go +++ b/system/service/dal_connection.go @@ -3,9 +3,10 @@ package service import ( "context" "fmt" - "github.com/cortezaproject/corteza-server/pkg/errors" "reflect" + "github.com/cortezaproject/corteza-server/pkg/errors" + "github.com/cortezaproject/corteza-server/pkg/actionlog" a "github.com/cortezaproject/corteza-server/pkg/auth" "github.com/cortezaproject/corteza-server/pkg/dal" @@ -334,14 +335,14 @@ func dalConnectionReplace(ctx context.Context, primary dal.Connection, dcm dalCo return nil }(), c.Config.Connection, - dal.ConnectionMeta{ - DefaultModelIdent: c.Config.DefaultModelIdent, - DefaultAttributeIdent: c.Config.DefaultAttributeIdent, - DefaultPartitionFormat: c.Config.DefaultPartitionFormat, - SensitivityLevel: c.SensitivityLevel, - Label: c.Handle, + dal.ConnectionConfig{ + SensitivityLevelID: c.Config.Privacy.SensitivityLevelID, + ModelIdent: c.Config.DAL.ModelIdent, + AttributeIdent: c.Config.DAL.AttributeIdent, + PartitionFormat: c.Config.DAL.PartitionFormat, + Label: c.Handle, }, - c.ActiveCapabilities()..., + c.Config.DAL.Operations..., ) if err = dcm.ReplaceConnection(ctx, cw, isPrimary); err != nil { diff --git a/system/types/dal_connection.go b/system/types/dal_connection.go index 436608a66..2d36aef2a 100644 --- a/system/types/dal_connection.go +++ b/system/types/dal_connection.go @@ -3,32 +3,26 @@ package types import ( "database/sql/driver" "encoding/json" - "github.com/cortezaproject/corteza-server/pkg/sql" "time" - "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" - "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/geolocation" + "github.com/cortezaproject/corteza-server/pkg/sql" + + "github.com/cortezaproject/corteza-server/pkg/dal" + "github.com/cortezaproject/corteza-server/pkg/filter" ) type ( DalConnection struct { ID uint64 `json:"connectionID,string"` - Name string `json:"name"` Handle string `json:"handle"` + Type string `json:"type"` - Type string `json:"type"` - - Location geolocation.Full `json:"location"` - Ownership string `json:"ownership"` - SensitivityLevel uint64 `json:"sensitivityLevel,string,omitempty"` + Meta ConnectionMeta `json:"meta"` + Config ConnectionConfig `json:"config"` Issues []string `json:"issues,omitempty" db:"-"` - Config ConnectionConfig `json:"config"` - Capabilities ConnectionCapabilities `json:"capabilities"` - Labels map[string]string `json:"labels,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` @@ -39,22 +33,45 @@ type ( DeletedBy uint64 `json:"deletedBy,string,omitempty" ` } - ConnectionCapabilities struct { - Enforced capabilities.Set `json:"enforced"` - Supported capabilities.Set `json:"supported"` - Unsupported capabilities.Set `json:"unsupported"` - Enabled capabilities.Set `json:"enabled"` + ConnectionConfig struct { + Connection dal.ConnectionParams `json:"connection"` + Privacy ConnectionConfigPrivacy `json:"privacy"` + DAL ConnectionConfigDAL `json:"dal"` } - ConnectionConfig struct { - DefaultModelIdent string `json:"defaultModelIdent"` - DefaultAttributeIdent string `json:"defaultAttributeIdent"` + ConnectionProperties struct { + DataAtRestEncryption ConnectionPropertyMeta `json:"dataAtRestEncryption"` + DataAtRestProtection ConnectionPropertyMeta `json:"dataAtRestProtection"` + DataAtTransitEncryption ConnectionPropertyMeta `json:"dataAtTransitEncryption"` + DataRestoration ConnectionPropertyMeta `json:"dataRestoration"` + } - DefaultPartitionFormat string `json:"defaultPartitionFormat"` + ConnectionPropertyMeta struct { + Enabled bool `json:"enabled"` + Notes string `json:"notes"` + } - PartitionFormatValidator string `json:"partitionFormatValidator"` + ConnectionMeta struct { + Location geolocation.Full `json:"location"` + Ownership string `json:"ownership"` + Name string `json:"name"` + } - Connection dal.ConnectionParams `json:"connection"` + ConnectionConfigPrivacy struct { + SensitivityLevelID uint64 `json:"sensitivityLevelID,string,omitempty"` + } + + ConnectionConfigDAL struct { + Properties ConnectionProperties `json:"properties"` + // @note operations, for now, will only be available on connections + // with a fallback on modules + Operations dal.OperationSet `json:"operations"` + + ModelIdent string `json:"modelIdent"` + AttributeIdent string `json:"attributeIdent"` + + PartitionFormat string `json:"partitionFormat"` + PartitionIdentValidator string `json:"partitionIdentValidator"` } DalConnectionFilter struct { @@ -81,12 +98,6 @@ var ( DalPrimaryConnectionHandle = "primary-database" ) -func (c DalConnection) ActiveCapabilities() capabilities.Set { - return c.Capabilities.Supported. - Union(c.Capabilities.Enforced). - Union(c.Capabilities.Enabled) -} - func (c DalConnection) HasIssues() bool { return len(c.Issues) > 0 } @@ -100,7 +111,7 @@ func ParseConnectionConfig(ss []string) (m ConnectionConfig, err error) { return } -func ParseConnectionCapabilities(ss []string) (m ConnectionCapabilities, err error) { +func ParseConnectionMeta(ss []string) (m ConnectionMeta, err error) { if len(ss) == 0 { return } @@ -112,5 +123,5 @@ func ParseConnectionCapabilities(ss []string) (m ConnectionCapabilities, err err func (nm *ConnectionConfig) Scan(src any) error { return sql.ParseJSON(src, nm) } func (nm ConnectionConfig) Value() (driver.Value, error) { return json.Marshal(nm) } -func (nm *ConnectionCapabilities) Scan(src any) error { return sql.ParseJSON(src, nm) } -func (nm ConnectionCapabilities) Value() (driver.Value, error) { return json.Marshal(nm) } +func (nm *ConnectionMeta) Scan(src any) error { return sql.ParseJSON(src, nm) } +func (nm ConnectionMeta) Value() (driver.Value, error) { return json.Marshal(nm) } diff --git a/tests/compose/main_test.go b/tests/compose/main_test.go index 4dd60727e..a7805bf69 100644 --- a/tests/compose/main_test.go +++ b/tests/compose/main_test.go @@ -15,7 +15,6 @@ import ( "testing" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/app" @@ -62,7 +61,7 @@ type ( dalSvc interface { Purge(ctx context.Context) - GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionMeta, err error) + GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionConfig, err error) SearchModels(ctx context.Context) (out dal.ModelSet, err error) RemoveModel(ctx context.Context, connectionID, ID uint64) (err error) @@ -70,12 +69,12 @@ type ( ReplaceModelAttribute(ctx context.Context, model *dal.Model, old, new *dal.Attribute, trans ...dal.TransformationFunction) (err error) SearchModelIssues(connectionID, resourceID uint64) (out []error) - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error - Update(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Lookup(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) - Truncate(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set) (err error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error + Update(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Lookup(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) + Truncate(ctx context.Context, m dal.ModelRef, operations dal.OperationSet) (err error) } ) diff --git a/tests/compose/record_test.go b/tests/compose/record_test.go index 602baa859..4a9169052 100644 --- a/tests/compose/record_test.go +++ b/tests/compose/record_test.go @@ -160,6 +160,7 @@ func (h helper) makeRecord(module *types.Module, rvs ...*types.RecordValue) *typ // when stored through the service Values: values.Formatter().Run(module, rvs), } + rec.SetModule(module) rec.SetModule(module) diff --git a/tests/dal/dal_codec_alias_test.go b/tests/dal/dal_codec_alias_test.go index 7fbdf4e49..1891df476 100644 --- a/tests/dal/dal_codec_alias_test.go +++ b/tests/dal/dal_codec_alias_test.go @@ -6,7 +6,6 @@ import ( "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" ) func Test_dal_codec_alias(t *testing.T) { @@ -54,9 +53,9 @@ func Test_dal_codec_alias(t *testing.T) { bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dalService) { h.a.NoError(svc.ReplaceModel(ctx, model)) - h.a.NoError(svc.Create(ctx, model.ToFilter(), capabilities.CreateCapabilities(model.Capabilities...), &rIn)) + h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(model.Operations...), &rIn)) - h.a.NoError(svc.Lookup(ctx, model.ToFilter(), capabilities.LookupCapabilities(model.Capabilities...), dal.PKValues{"id": rIn.ID}, &rOut)) + h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(model.Operations...), dal.PKValues{"id": rIn.ID}, &rOut)) for _, inVal := range rIn.Values { outVal := rOut.Values.Get(inVal.Name, 0) diff --git a/tests/dal/dal_codec_json_test.go b/tests/dal/dal_codec_json_test.go index f52a4b712..6b53bc323 100644 --- a/tests/dal/dal_codec_json_test.go +++ b/tests/dal/dal_codec_json_test.go @@ -6,7 +6,6 @@ import ( "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" ) func Test_dal_codec_json(t *testing.T) { @@ -54,9 +53,9 @@ func Test_dal_codec_json(t *testing.T) { bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dalService) { h.a.NoError(svc.ReplaceModel(ctx, model)) - h.a.NoError(svc.Create(ctx, model.ToFilter(), capabilities.CreateCapabilities(model.Capabilities...), &rIn)) + h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(model.Operations...), &rIn)) - h.a.NoError(svc.Lookup(ctx, model.ToFilter(), capabilities.LookupCapabilities(model.Capabilities...), dal.PKValues{"id": rIn.ID}, &rOut)) + h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(model.Operations...), dal.PKValues{"id": rIn.ID}, &rOut)) for _, inVal := range rIn.Values { outVal := rOut.Values.Get(inVal.Name, 0) diff --git a/tests/dal/dal_codec_plain_test.go b/tests/dal/dal_codec_plain_test.go index 236e83b4e..488702465 100644 --- a/tests/dal/dal_codec_plain_test.go +++ b/tests/dal/dal_codec_plain_test.go @@ -6,7 +6,6 @@ import ( "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" ) func Test_dal_codec_plain(t *testing.T) { @@ -54,9 +53,9 @@ func Test_dal_codec_plain(t *testing.T) { bootstrap(t, func(ctx context.Context, t *testing.T, h helper, svc dalService) { h.a.NoError(svc.ReplaceModel(ctx, model)) - h.a.NoError(svc.Create(ctx, model.ToFilter(), capabilities.CreateCapabilities(model.Capabilities...), &rIn)) + h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(model.Operations...), &rIn)) - h.a.NoError(svc.Lookup(ctx, model.ToFilter(), capabilities.LookupCapabilities(model.Capabilities...), dal.PKValues{"id": rIn.ID}, &rOut)) + h.a.NoError(svc.Lookup(ctx, model.ToFilter(), dal.LookupOperations(model.Operations...), dal.PKValues{"id": rIn.ID}, &rOut)) for _, inVal := range rIn.Values { outVal := rOut.Values.Get(inVal.Name, 0) @@ -122,7 +121,7 @@ func benchmark_dal_codec_plain(b *testing.B, count int) { } b.StartTimer() - h.a.NoError(svc.Create(ctx, model.ToFilter(), capabilities.CreateCapabilities(model.Capabilities...), insert...)) + h.a.NoError(svc.Create(ctx, model.ToFilter(), dal.CreateOperations(model.Operations...), insert...)) b.StopTimer() } }) diff --git a/tests/dal/dal_crud_compose_record_test.go b/tests/dal/dal_crud_compose_record_test.go index d358e953b..c1a509b07 100644 --- a/tests/dal/dal_crud_compose_record_test.go +++ b/tests/dal/dal_crud_compose_record_test.go @@ -8,7 +8,7 @@ import ( "time" "github.com/cortezaproject/corteza-server/compose/types" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" + "github.com/cortezaproject/corteza-server/pkg/dal" "github.com/cortezaproject/corteza-server/tests/helpers" ) @@ -25,7 +25,7 @@ func Test_dal_crud_compose_record_create(t *testing.T) { module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: 0, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) @@ -86,7 +86,7 @@ func Test_dal_crud_compose_record_update(t *testing.T) { module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: 0, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) @@ -147,7 +147,7 @@ func Test_dal_crud_compose_record_delete(t *testing.T) { module := createModuleFromGenerics(ctx, t, "ok_module.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: 0, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) diff --git a/tests/dal/dal_crud_connection_test.go b/tests/dal/dal_crud_connection_test.go index e83897f5d..4a2730f7d 100644 --- a/tests/dal/dal_crud_connection_test.go +++ b/tests/dal/dal_crud_connection_test.go @@ -143,7 +143,7 @@ func Test_dal_crud_connection_update_primary(t *testing.T) { Expect(t). Status(http.StatusOK). Assert(helpers.AssertNoErrors). - Assert(jsonpath.Equal("$.response.name", "Primary Connection EDITED")). + Assert(jsonpath.Equal("$.response.meta.name", "Primary Connection EDITED")). End() } diff --git a/tests/dal/dal_crud_driver_test.go b/tests/dal/dal_crud_driver_test.go index e0ad23179..75b3afb6b 100644 --- a/tests/dal/dal_crud_driver_test.go +++ b/tests/dal/dal_crud_driver_test.go @@ -17,6 +17,6 @@ func Test_dal_crud_driver_list(t *testing.T) { Status(http.StatusOK). Assert(helpers.AssertNoErrors). Assert(jsonpath.GreaterThan("$.response.set", 0)). - Assert(jsonpath.Present("$.response.set[0].capabilities")). + Assert(jsonpath.Present("$.response.set[0].operations")). End() } diff --git a/tests/dal/dal_crud_issues_compose_record_test.go b/tests/dal/dal_crud_issues_compose_record_test.go index 3d5575833..5f924d092 100644 --- a/tests/dal/dal_crud_issues_compose_record_test.go +++ b/tests/dal/dal_crud_issues_compose_record_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/cortezaproject/corteza-server/compose/types" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" + "github.com/cortezaproject/corteza-server/pkg/dal" "github.com/cortezaproject/corteza-server/tests/helpers" ) @@ -24,7 +24,7 @@ func Test_dal_crud_issues_compose_record_nok_connection(t *testing.T) { module := createModuleFromGenerics(h.secCtx(), t, "ok_module.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: connection.ID, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) @@ -53,7 +53,7 @@ func Test_dal_crud_issues_compose_record_nok_model(t *testing.T) { module := createModuleFromGenerics(h.secCtx(), t, "nok_module_sensitivity_level.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: connection.ID, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) @@ -82,7 +82,7 @@ func Test_dal_crud_issues_compose_record_ok(t *testing.T) { module := createModuleFromGenerics(h.secCtx(), t, "ok_module.json", ns.ID, &types.ModuleConfig{ DAL: types.ModuleConfigDAL{ ConnectionID: connection.ID, - Capabilities: capabilities.FullCapabilities(), + Operations: dal.FullOperations(), }, }) diff --git a/tests/dal/dal_utils_test.go b/tests/dal/dal_utils_test.go index fba20fa1b..05a71e798 100644 --- a/tests/dal/dal_utils_test.go +++ b/tests/dal/dal_utils_test.go @@ -10,7 +10,6 @@ import ( composeTypes "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/auth" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/filter" "github.com/cortezaproject/corteza-server/pkg/id" "github.com/cortezaproject/corteza-server/store" @@ -45,12 +44,12 @@ type ( FindModelByResourceIdent(connectionID uint64, resourceType, resourceIdent string) *dal.Model FindModelByIdent(connectionID uint64, ident string) *dal.Model - Create(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) - Update(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) - Search(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (iter dal.Iterator, err error) - Lookup(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) - Delete(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) (err error) - Truncate(ctx context.Context, mf dal.ModelRef, capabilities capabilities.Set) (err error) + Create(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) + Update(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) + Search(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet, f filter.Filter) (iter dal.Iterator, err error) + Lookup(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) + Delete(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) (err error) + Truncate(ctx context.Context, mf dal.ModelRef, operations dal.OperationSet) (err error) SearchConnectionIssues(connectionID uint64) (out []error) SearchModelIssues(connectionID, resourceID uint64) (out []error) @@ -138,12 +137,12 @@ func (h helper) cleanupDal() { func initSvc(ctx context.Context, d driver) (dalService, error) { c := makeConnectionDefinition(d.dsn) - cm := dal.ConnectionMeta{ - DefaultModelIdent: c.Config.DefaultModelIdent, - DefaultAttributeIdent: c.Config.DefaultAttributeIdent, - DefaultPartitionFormat: c.Config.DefaultPartitionFormat, - SensitivityLevel: c.SensitivityLevel, - Label: c.Handle, + cm := dal.ConnectionConfig{ + ModelIdent: c.Config.DAL.ModelIdent, + AttributeIdent: c.Config.DAL.AttributeIdent, + PartitionFormat: c.Config.DAL.PartitionFormat, + SensitivityLevelID: c.Config.Privacy.SensitivityLevelID, + Label: c.Handle, } svc, err := dal.New(zap.NewNop(), false) @@ -151,7 +150,7 @@ func initSvc(ctx context.Context, d driver) (dalService, error) { return nil, err } - err = svc.ReplaceConnection(ctx, dal.MakeConnection(c.ID, nil, c.Config.Connection, cm, capabilities.FullCapabilities()...), true) + err = svc.ReplaceConnection(ctx, dal.MakeConnection(c.ID, nil, c.Config.Connection, cm, dal.FullOperations()...), true) if err != nil { return nil, err } diff --git a/tests/dal/main_test.go b/tests/dal/main_test.go index 2b4343691..5165e754d 100644 --- a/tests/dal/main_test.go +++ b/tests/dal/main_test.go @@ -5,19 +5,19 @@ import ( "context" "encoding/json" "fmt" - "github.com/cortezaproject/corteza-server/pkg/auth" - "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" - "github.com/cortezaproject/corteza-server/pkg/id" - "github.com/cortezaproject/corteza-server/pkg/rbac" - "github.com/cortezaproject/corteza-server/store" - "github.com/steinfletcher/apitest" "io/ioutil" "os" "path" "testing" "time" + "github.com/cortezaproject/corteza-server/pkg/auth" + "github.com/cortezaproject/corteza-server/pkg/dal" + "github.com/cortezaproject/corteza-server/pkg/id" + "github.com/cortezaproject/corteza-server/pkg/rbac" + "github.com/cortezaproject/corteza-server/store" + "github.com/steinfletcher/apitest" + "github.com/cortezaproject/corteza-server/app" "github.com/cortezaproject/corteza-server/auth/handlers" "github.com/cortezaproject/corteza-server/auth/request" @@ -240,8 +240,8 @@ func (h helper) createDalConnection(res *types.DalConnection) *types.DalConnecti res.ID = id.Next() } - if res.Name == "" { - res.Name = "Test Connection" + if res.Meta.Name == "" { + res.Meta.Name = "Test Connection" } if res.Handle == "" { res.Handle = "test_connection" @@ -249,40 +249,28 @@ func (h helper) createDalConnection(res *types.DalConnection) *types.DalConnecti if res.Type == "" { res.Type = types.DalConnectionResourceType } - if res.Ownership == "" { - res.Ownership = "tester" + if res.Meta.Ownership == "" { + res.Meta.Ownership = "tester" } - if res.Config.DefaultModelIdent == "" { - res.Config.DefaultModelIdent = "compose_records" + if res.Config.DAL.ModelIdent == "" { + res.Config.DAL.ModelIdent = "compose_records" } - if res.Config.DefaultAttributeIdent == "" { - res.Config.DefaultAttributeIdent = "values" + if res.Config.DAL.AttributeIdent == "" { + res.Config.DAL.AttributeIdent = "values" } - if res.Config.DefaultPartitionFormat == "" { - res.Config.DefaultPartitionFormat = "compose_records_{{namespace}}_{{module}}" + if res.Config.DAL.PartitionFormat == "" { + res.Config.DAL.PartitionFormat = "compose_records_{{namespace}}_{{module}}" } - if res.Config.PartitionFormatValidator == "" { - res.Config.PartitionFormatValidator = "" + if res.Config.DAL.PartitionIdentValidator == "" { + res.Config.DAL.PartitionIdentValidator = "" } if res.Config.Connection.Params == nil { res.Config.Connection = dal.NewDSNConnection("sqlite3://file::memory:?cache=shared&mode=memory") } - if len(res.Capabilities.Enforced) == 0 { - res.Capabilities.Enforced = capabilities.FullCapabilities() - } - - if len(res.Capabilities.Supported) == 0 { - res.Capabilities.Supported = capabilities.Set{} - } - - if len(res.Capabilities.Unsupported) == 0 { - res.Capabilities.Unsupported = capabilities.Set{} - } - - if len(res.Capabilities.Enabled) == 0 { - res.Capabilities.Enabled = capabilities.Set{} + if len(res.Config.DAL.Operations) == 0 { + res.Config.DAL.Operations = dal.FullOperations() } if res.CreatedAt.IsZero() { @@ -313,18 +301,19 @@ func makeConnectionDefinition(dsn string) *types.DalConnection { ID: id.Next(), Type: types.DalConnectionResourceType, Config: types.ConnectionConfig{ - DefaultModelIdent: "compose_record", - DefaultAttributeIdent: "values", + DAL: types.ConnectionConfigDAL{ + ModelIdent: "compose_record", + AttributeIdent: "values", - DefaultPartitionFormat: "compose_record_{{namespace}}_{{module}}", + PartitionFormat: "compose_record_{{namespace}}_{{module}}", - PartitionFormatValidator: "", + PartitionIdentValidator: "", + + Operations: dal.FullOperations(), + }, Connection: dal.NewDSNConnection(dsn), }, - Capabilities: types.ConnectionCapabilities{ - Supported: capabilities.FullCapabilities(), - }, } } diff --git a/tests/dal/testdata/dal_crud_connection_update_primary/connection.json b/tests/dal/testdata/dal_crud_connection_update_primary/connection.json index 83a97550e..1b1bbba4d 100644 --- a/tests/dal/testdata/dal_crud_connection_update_primary/connection.json +++ b/tests/dal/testdata/dal_crud_connection_update_primary/connection.json @@ -1,43 +1,48 @@ { - "name": "Primary Connection EDITED", "handle": "primary_connection", "type": "corteza::system:primary-dal-connection", - "location": { + + "meta": { + "name": "Primary Connection EDITED", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/dal/testdata/dal_crud_issues_compose_module_nok_connection/module.json b/tests/dal/testdata/dal_crud_issues_compose_module_nok_connection/module.json index 7ef3803f5..3b81bd6cc 100644 --- a/tests/dal/testdata/dal_crud_issues_compose_module_nok_connection/module.json +++ b/tests/dal/testdata/dal_crud_issues_compose_module_nok_connection/module.json @@ -5,12 +5,12 @@ "config": { "dal": { "connectionID": "42", - "capabilities": [], + "operations": [], "partitioned": false }, "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, @@ -22,7 +22,7 @@ "kind": "String", "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, diff --git a/tests/dal/testdata/generic/nok_connection_connectivity.json b/tests/dal/testdata/generic/nok_connection_connectivity.json index db818f7f3..f9182cd93 100644 --- a/tests/dal/testdata/generic/nok_connection_connectivity.json +++ b/tests/dal/testdata/generic/nok_connection_connectivity.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "NO" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "NO" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/dal/testdata/generic/nok_connection_invalid_type.json b/tests/dal/testdata/generic/nok_connection_invalid_type.json index 708c1ba48..a4f08e3c7 100644 --- a/tests/dal/testdata/generic/nok_connection_invalid_type.json +++ b/tests/dal/testdata/generic/nok_connection_invalid_type.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:primary-dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/dal/testdata/generic/nok_connection_sensitivity.json b/tests/dal/testdata/generic/nok_connection_sensitivity.json index 1c39e2cf9..0ef373f6a 100644 --- a/tests/dal/testdata/generic/nok_connection_sensitivity.json +++ b/tests/dal/testdata/generic/nok_connection_sensitivity.json @@ -1,44 +1,48 @@ { + "handle": "test_connection", + "type": "corteza::system:dal-connection", + + "meta": { "name": "Test Connection", - "handle": "test_connection", - "type": "corteza::system:dal-connection", "location": { - "geometry": { - "type": "", - "coordinates": null - }, - "properties": { - "name": "" - } + "geometry": { + "type": "", + "coordinates": null + }, + "properties": { + "name": "" + } }, - "ownership": "", - "sensitivityLevel": "42", - "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } - } + "ownership": "" + }, + + "config": { + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" + } }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" - ], - "unsupported": [], - "enabled": [] + "privacy": { + "sensitivityLevelID": "42" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" + ], + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" } } - \ No newline at end of file +} diff --git a/tests/dal/testdata/generic/nok_module_missing_field_sensitivity_level.json b/tests/dal/testdata/generic/nok_module_missing_field_sensitivity_level.json index 03d9211fc..cd88820a9 100644 --- a/tests/dal/testdata/generic/nok_module_missing_field_sensitivity_level.json +++ b/tests/dal/testdata/generic/nok_module_missing_field_sensitivity_level.json @@ -5,11 +5,11 @@ "config": { "dal": { "connectionID": "0", - "capabilities": [], + "operations": [], "partitioned": false }, "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, @@ -21,7 +21,7 @@ "config": { "privacy": { - "sensitivityLevel": "42", + "sensitivityLevelID": "42", "usageDisclosure": "A" } } diff --git a/tests/dal/testdata/generic/nok_module_missing_sensitivity_level.json b/tests/dal/testdata/generic/nok_module_missing_sensitivity_level.json index 683b584d2..92331346a 100644 --- a/tests/dal/testdata/generic/nok_module_missing_sensitivity_level.json +++ b/tests/dal/testdata/generic/nok_module_missing_sensitivity_level.json @@ -5,11 +5,11 @@ "config": { "dal": { "connectionID": "0", - "capabilities": [], + "operations": [], "partitioned": false }, "privacy": { - "sensitivityLevel": "42", + "sensitivityLevelID": "42", "usageDisclosure": "A" } }, @@ -20,7 +20,7 @@ "kind": "String", "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, diff --git a/tests/dal/testdata/generic/nok_module_sensitivity_level.json b/tests/dal/testdata/generic/nok_module_sensitivity_level.json index 894a41a88..80b040ba8 100644 --- a/tests/dal/testdata/generic/nok_module_sensitivity_level.json +++ b/tests/dal/testdata/generic/nok_module_sensitivity_level.json @@ -5,12 +5,12 @@ "config": { "dal": { "connectionID": "0", - "capabilities": [], + "operations": [], "partitioned": false }, "privacy": { - "sensitivityLevel": "42", + "sensitivityLevelID": "42", "usageDisclosure": "A" } }, @@ -21,7 +21,7 @@ "kind": "String", "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, diff --git a/tests/dal/testdata/generic/ok_connection.json b/tests/dal/testdata/generic/ok_connection.json index 187696e8b..b819598e9 100644 --- a/tests/dal/testdata/generic/ok_connection.json +++ b/tests/dal/testdata/generic/ok_connection.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/dal/testdata/generic/ok_connection_update.json b/tests/dal/testdata/generic/ok_connection_update.json index 4364d9f60..7c1db2212 100644 --- a/tests/dal/testdata/generic/ok_connection_update.json +++ b/tests/dal/testdata/generic/ok_connection_update.json @@ -1,43 +1,48 @@ { - "name": "Test Connection EDITED", "handle": "test_connection_edited", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection EDITED", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/dal/testdata/generic/ok_module.json b/tests/dal/testdata/generic/ok_module.json index 5f0e8130d..8408da945 100644 --- a/tests/dal/testdata/generic/ok_module.json +++ b/tests/dal/testdata/generic/ok_module.json @@ -5,11 +5,11 @@ "config": { "dal": { "connectionID": "0", - "capabilities": [], + "operations": [], "partitioned": false }, "privacy": { - "sensitivityLevel": "0", + "sensitivityLevelID": "0", "usageDisclosure": "A" } }, diff --git a/tests/system/dal_connection_crud_test.go b/tests/system/dal_connection_crud_test.go index 4826c6a99..f13e6146b 100644 --- a/tests/system/dal_connection_crud_test.go +++ b/tests/system/dal_connection_crud_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/id" "github.com/cortezaproject/corteza-server/store" "github.com/cortezaproject/corteza-server/system/service" @@ -45,8 +44,8 @@ func (h helper) createDalConnection(res *types.DalConnection) *types.DalConnecti res.ID = id.Next() } - if res.Name == "" { - res.Name = "Test Connection" + if res.Meta.Name == "" { + res.Meta.Name = "Test Connection" } if res.Handle == "" { res.Handle = "test_connection" @@ -54,40 +53,28 @@ func (h helper) createDalConnection(res *types.DalConnection) *types.DalConnecti if res.Type == "" { res.Type = types.DalConnectionResourceType } - if res.Ownership == "" { - res.Ownership = "tester" + if res.Meta.Ownership == "" { + res.Meta.Ownership = "tester" } - if res.Config.DefaultModelIdent == "" { - res.Config.DefaultModelIdent = "compose_records" + if res.Config.DAL.ModelIdent == "" { + res.Config.DAL.ModelIdent = "compose_records" } - if res.Config.DefaultAttributeIdent == "" { - res.Config.DefaultAttributeIdent = "values" + if res.Config.DAL.AttributeIdent == "" { + res.Config.DAL.AttributeIdent = "values" } - if res.Config.DefaultPartitionFormat == "" { - res.Config.DefaultPartitionFormat = "compose_records_{{namespace}}_{{module}}" + if res.Config.DAL.PartitionFormat == "" { + res.Config.DAL.PartitionFormat = "compose_records_{{namespace}}_{{module}}" } - if res.Config.PartitionFormatValidator == "" { - res.Config.PartitionFormatValidator = "" + if res.Config.DAL.PartitionIdentValidator == "" { + res.Config.DAL.PartitionIdentValidator = "" } if res.Config.Connection.Params == nil { res.Config.Connection = dal.NewDSNConnection("sqlite3://file::memory:?cache=shared&mode=memory") } - if len(res.Capabilities.Enforced) == 0 { - res.Capabilities.Enforced = capabilities.FullCapabilities() - } - - if len(res.Capabilities.Supported) == 0 { - res.Capabilities.Supported = capabilities.Set{} - } - - if len(res.Capabilities.Unsupported) == 0 { - res.Capabilities.Unsupported = capabilities.Set{} - } - - if len(res.Capabilities.Enabled) == 0 { - res.Capabilities.Enabled = capabilities.Set{} + if len(res.Config.DAL.Operations) == 0 { + res.Config.DAL.Operations = dal.FullOperations() } if res.CreatedAt.IsZero() { @@ -218,7 +205,7 @@ func Test_dal_connection_update_primary(t *testing.T) { Expect(t). Status(http.StatusOK). Assert(helpers.AssertNoErrors). - Assert(jsonpath.Equal("$.response.name", "Primary Connection EDITED")). + Assert(jsonpath.Equal("$.response.meta.name", "Primary Connection EDITED")). End() } diff --git a/tests/system/dal_driver_crud_test.go b/tests/system/dal_driver_crud_test.go index dc6971a45..400f30c8f 100644 --- a/tests/system/dal_driver_crud_test.go +++ b/tests/system/dal_driver_crud_test.go @@ -17,6 +17,6 @@ func Test_dal_driver_list(t *testing.T) { Status(http.StatusOK). Assert(helpers.AssertNoErrors). Assert(jsonpath.Len("$.response.set", 1)). - Assert(jsonpath.Present("$.response.set[0].capabilities")). + Assert(jsonpath.Present("$.response.set[0].operations")). End() } diff --git a/tests/system/testdata/dal_connection_create/generic.json b/tests/system/testdata/dal_connection_create/generic.json index 54e430d77..b819598e9 100644 --- a/tests/system/testdata/dal_connection_create/generic.json +++ b/tests/system/testdata/dal_connection_create/generic.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "mysql://user:pass@tcp(localhost:3308)/corteza?collation=utf8mb4_general_ci" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/system/testdata/dal_connection_create_forbidden/generic.json b/tests/system/testdata/dal_connection_create_forbidden/generic.json index 54e430d77..b819598e9 100644 --- a/tests/system/testdata/dal_connection_create_forbidden/generic.json +++ b/tests/system/testdata/dal_connection_create_forbidden/generic.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "mysql://user:pass@tcp(localhost:3308)/corteza?collation=utf8mb4_general_ci" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/system/testdata/dal_connection_create_invalid_type/generic.json b/tests/system/testdata/dal_connection_create_invalid_type/generic.json index 648dfa9e4..a4f08e3c7 100644 --- a/tests/system/testdata/dal_connection_create_invalid_type/generic.json +++ b/tests/system/testdata/dal_connection_create_invalid_type/generic.json @@ -1,43 +1,48 @@ { - "name": "Test Connection", "handle": "test_connection", "type": "corteza::system:primary-dal-connection", - "location": { + + "meta": { + "name": "Test Connection", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "mysql://user:pass@tcp(localhost:3308)/corteza?collation=utf8mb4_general_ci" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/system/testdata/dal_connection_update/generic.json b/tests/system/testdata/dal_connection_update/generic.json index 226591943..7c1db2212 100644 --- a/tests/system/testdata/dal_connection_update/generic.json +++ b/tests/system/testdata/dal_connection_update/generic.json @@ -1,43 +1,48 @@ { - "name": "Test Connection EDITED", "handle": "test_connection_edited", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection EDITED", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/system/testdata/dal_connection_update_forbidden/generic.json b/tests/system/testdata/dal_connection_update_forbidden/generic.json index 226591943..7c1db2212 100644 --- a/tests/system/testdata/dal_connection_update_forbidden/generic.json +++ b/tests/system/testdata/dal_connection_update_forbidden/generic.json @@ -1,43 +1,48 @@ { - "name": "Test Connection EDITED", "handle": "test_connection_edited", "type": "corteza::system:dal-connection", - "location": { + + "meta": { + "name": "Test Connection EDITED", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/system/testdata/dal_connection_update_primary/generic.json b/tests/system/testdata/dal_connection_update_primary/generic.json index 83a97550e..1b1bbba4d 100644 --- a/tests/system/testdata/dal_connection_update_primary/generic.json +++ b/tests/system/testdata/dal_connection_update_primary/generic.json @@ -1,43 +1,48 @@ { - "name": "Primary Connection EDITED", "handle": "primary_connection", "type": "corteza::system:primary-dal-connection", - "location": { + + "meta": { + "name": "Primary Connection EDITED", + "location": { "geometry": { - "type": "", - "coordinates": null + "type": "", + "coordinates": null }, "properties": { - "name": "" + "name": "" } + }, + "ownership": "" }, - "ownership": "", - "sensitivityLevel": "0", + "config": { - "defaultModelIdent": "compose_record", - "defaultAttributeIdent": "values", - "defaultPartitionFormat": "compose_record_{{namespace}}_{{module}}", - "partitionFormatValidator": "", - "connection": { - "type": "corteza::dal:connection:dsn", - "params": { - "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" - } + "connection": { + "type": "corteza::dal:connection:dsn", + "params": { + "dsn": "sqlite3://file::memory:?cache=shared&mode=memory" } - }, - "capabilities": { - "enforced": [], - "supported": [ - "corteza::dal:capability:create", - "corteza::dal:capability:update", - "corteza::dal:capability:search", - "corteza::dal:capability:lookup", - "corteza::dal:capability:paging", - "corteza::dal:capability:stats", - "corteza::dal:capability:sorting", - "corteza::dal:capability:RBAC" + }, + "privacy": { + "sensitivityLevelID": "0" + }, + "dal": { + "properties": {}, + "operations": [ + "corteza::dal:operation:create", + "corteza::dal:operation:update", + "corteza::dal:operation:search", + "corteza::dal:operation:lookup", + "corteza::dal:operation:paging", + "corteza::dal:operation:stats", + "corteza::dal:operation:sorting", + "corteza::dal:operation:RBAC" ], - "unsupported": [], - "enabled": [] + + "modelIdent": "compose_record", + "attributeIdent": "values", + "partitionFormat": "compose_record_{{namespace}}_{{module}}", + "partitionIdentValidator": "" + } } } diff --git a/tests/workflows/main_test.go b/tests/workflows/main_test.go index 1dbeec1ad..a1f9c5310 100644 --- a/tests/workflows/main_test.go +++ b/tests/workflows/main_test.go @@ -11,7 +11,6 @@ import ( autTypes "github.com/cortezaproject/corteza-server/automation/types" "github.com/cortezaproject/corteza-server/pkg/auth" "github.com/cortezaproject/corteza-server/pkg/dal" - "github.com/cortezaproject/corteza-server/pkg/dal/capabilities" "github.com/cortezaproject/corteza-server/pkg/envoy" "github.com/cortezaproject/corteza-server/pkg/envoy/csv" "github.com/cortezaproject/corteza-server/pkg/envoy/directory" @@ -33,7 +32,7 @@ type ( dalSvc interface { Purge(ctx context.Context) - GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionMeta, err error) + GetConnectionMeta(ctx context.Context, ID uint64) (cm dal.ConnectionConfig, err error) SearchModels(ctx context.Context) (out dal.ModelSet, err error) RemoveModel(ctx context.Context, connectionID, ID uint64) (err error) @@ -41,12 +40,12 @@ type ( ReplaceModelAttribute(ctx context.Context, model *dal.Model, old, new *dal.Attribute, trans ...dal.TransformationFunction) (err error) SearchModelIssues(connectionID, resourceID uint64) (out []error) - Create(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, vv ...dal.ValueGetter) error - Update(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, rr ...dal.ValueGetter) (err error) - Search(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, f filter.Filter) (dal.Iterator, error) - Lookup(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) - Delete(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set, pkv ...dal.ValueGetter) (err error) - Truncate(ctx context.Context, m dal.ModelRef, capabilities capabilities.Set) (err error) + Create(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, vv ...dal.ValueGetter) error + Update(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, rr ...dal.ValueGetter) (err error) + Search(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, f filter.Filter) (dal.Iterator, error) + Lookup(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, lookup dal.ValueGetter, dst dal.ValueSetter) (err error) + Delete(ctx context.Context, m dal.ModelRef, operations dal.OperationSet, pkv ...dal.ValueGetter) (err error) + Truncate(ctx context.Context, m dal.ModelRef, operations dal.OperationSet) (err error) } ) diff --git a/vendor/github.com/beevik/etree/README.md b/vendor/github.com/beevik/etree/README.md index 08ec26b0a..574c15f0d 100644 --- a/vendor/github.com/beevik/etree/README.md +++ b/vendor/github.com/beevik/etree/README.md @@ -197,7 +197,7 @@ search with the same path more than once. These are just a few examples of the things the etree package can do. See the [documentation](http://godoc.org/github.com/beevik/etree) for a complete -description of its capabilities. +description of its dal. ### Contributing diff --git a/vendor/github.com/cortezaproject/corteza-locale/src/en/corteza-webapp-admin/notification.yaml b/vendor/github.com/cortezaproject/corteza-locale/src/en/corteza-webapp-admin/notification.yaml index c18f1e76a..7c669c0b8 100644 --- a/vendor/github.com/cortezaproject/corteza-locale/src/en/corteza-webapp-admin/notification.yaml +++ b/vendor/github.com/cortezaproject/corteza-locale/src/en/corteza-webapp-admin/notification.yaml @@ -244,7 +244,7 @@ connection: undelete: success: Connection restored error: Connection restore failed - capabilities: - success: Connection capabilities updated - error: Connection capability update failed + operations: + success: Connection operations updated + error: Connection operation update failed diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c index d079f1adf..bb5157ade 100644 --- a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c +++ b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c @@ -7129,7 +7129,7 @@ SQLITE_API int sqlite3_table_column_metadata( ** interface. The use of the [sqlite3_enable_load_extension()] interface ** should be avoided. This will keep the SQL function [load_extension()] ** disabled and prevent SQL injections from giving attackers -** access to extension loading capabilities. +** access to extension loading dal. ** ** See also the [load_extension() SQL function]. */ @@ -7163,7 +7163,7 @@ SQLITE_API int sqlite3_load_extension( ** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method ** rather than this interface, so the [load_extension()] SQL function ** remains disabled. This will prevent SQL injections from giving attackers -** access to extension loading capabilities. +** access to extension loading dal. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h index 20bc97805..43491e43f 100644 --- a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h +++ b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h @@ -6823,7 +6823,7 @@ SQLITE_API int sqlite3_table_column_metadata( ** interface. The use of the [sqlite3_enable_load_extension()] interface ** should be avoided. This will keep the SQL function [load_extension()] ** disabled and prevent SQL injections from giving attackers -** access to extension loading capabilities. +** access to extension loading dal. ** ** See also the [load_extension() SQL function]. */ @@ -6857,7 +6857,7 @@ SQLITE_API int sqlite3_load_extension( ** be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method ** rather than this interface, so the [load_extension()] SQL function ** remains disabled. This will prevent SQL injections from giving attackers -** access to extension loading capabilities. +** access to extension loading dal. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); diff --git a/vendor/github.com/minio/sha256-simd/cpuid_linux_arm64.go b/vendor/github.com/minio/sha256-simd/cpuid_linux_arm64.go index e739996d9..714b6dc93 100644 --- a/vendor/github.com/minio/sha256-simd/cpuid_linux_arm64.go +++ b/vendor/github.com/minio/sha256-simd/cpuid_linux_arm64.go @@ -1,3 +1,4 @@ +//go:build arm64 && linux // +build arm64,linux // Minio Cloud Storage, (C) 2016 Minio, Inc. @@ -34,7 +35,7 @@ func xgetbv(index uint32) (eax, edx uint32) { return 0, 0 } -// File to check for cpu capabilities. +// File to check for cpu dal. const procCPUInfo = "/proc/cpuinfo" // Feature to check for. diff --git a/vendor/go.uber.org/zap/zapcore/doc.go b/vendor/go.uber.org/zap/zapcore/doc.go index 31000e91f..74dcbc40a 100644 --- a/vendor/go.uber.org/zap/zapcore/doc.go +++ b/vendor/go.uber.org/zap/zapcore/doc.go @@ -20,5 +20,5 @@ // Package zapcore defines and implements the low-level interfaces upon which // zap is built. By providing alternate implementations of these interfaces, -// external packages can extend zap's capabilities. +// external packages can extend zap's dal. package zapcore // import "go.uber.org/zap/zapcore"