oak-domain 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/es/actions/action.d.ts +1 -1
- package/es/base-app-domain/EntityDict.d.ts +27 -0
- package/es/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
- package/es/base-app-domain/LocalizedContent/Schema.js +1 -0
- package/es/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
- package/es/base-app-domain/LocalizedContent/Storage.js +75 -0
- package/es/base-app-domain/LocalizedContent/Style.d.ts +3 -0
- package/es/base-app-domain/LocalizedContent/Style.js +12 -0
- package/es/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
- package/es/base-app-domain/Storage.js +2 -0
- package/es/base-app-domain/StyleDict.js +2 -0
- package/es/compiler/customChecks/i18n.js +4 -1
- package/es/compiler/customChecks/runner.d.ts +1 -1
- package/es/compiler/customChecks/runner.js +1 -1
- package/es/compiler/customChecks/types.d.ts +2 -1
- package/es/compiler/dependencyBuilder.d.ts +11 -2
- package/es/compiler/dependencyBuilder.js +188 -199
- package/es/compiler/entityDescEnum.d.ts +5 -0
- package/es/compiler/entityDescEnum.js +443 -0
- package/es/compiler/entitySource.d.ts +28 -0
- package/es/compiler/entitySource.js +521 -0
- package/es/compiler/localeBuilder.d.ts +7 -2
- package/es/compiler/localeBuilder.js +52 -56
- package/es/compiler/routerBuilder.d.ts +32 -3
- package/es/compiler/routerBuilder.js +157 -45
- package/es/compiler/schemaBuilder.d.ts +12 -2
- package/es/compiler/schemaBuilder.js +653 -148
- package/es/compiler/tscBuilder.d.ts +20 -2
- package/es/compiler/tscBuilder.js +231 -45
- package/es/context/BackendRuntimeContext.d.ts +6 -4
- package/es/context/BackendRuntimeContext.js +9 -1
- package/es/context/ContextComposer.d.ts +93 -0
- package/es/context/ContextComposer.js +353 -0
- package/es/context/SerializedData.d.ts +2 -1
- package/es/data/i18n.d.ts +1 -1
- package/es/data/i18n.js +1 -86
- package/es/data/i18n.json +86 -0
- package/es/entities/ActionAuth.d.ts +3 -3
- package/es/entities/I18n.d.ts +2 -2
- package/es/entities/LocalizedContent.d.ts +22 -0
- package/es/entities/LocalizedContent.js +101 -0
- package/es/entities/Log.d.ts +3 -3
- package/es/entities/Modi.d.ts +2 -2
- package/es/entities/ModiEntity.d.ts +3 -3
- package/es/entities/Oper.d.ts +5 -5
- package/es/entities/OperEntity.d.ts +3 -3
- package/es/entities/Path.d.ts +2 -2
- package/es/entities/Relation.d.ts +2 -2
- package/es/entities/RelationAuth.d.ts +3 -3
- package/es/entities/User.d.ts +4 -4
- package/es/entities/UserEntityClaim.d.ts +6 -6
- package/es/entities/UserEntityGrant.d.ts +2 -2
- package/es/entities/UserRelation.d.ts +4 -4
- package/es/store/AsyncRowStore.d.ts +2 -2
- package/es/store/AsyncRowStore.js +2 -2
- package/es/store/CascadeStore.d.ts +5 -3
- package/es/store/CascadeStore.js +56 -24
- package/es/store/IntrinsicCheckers.d.ts +1 -1
- package/es/store/IntrinsicCheckers.js +2 -2
- package/es/store/IntrinsicLogics.d.ts +1 -1
- package/es/store/RelationAuth.js +3 -3
- package/es/store/SyncRowStore.d.ts +1 -1
- package/es/store/SyncRowStore.js +1 -1
- package/es/store/TriggerExecutor.d.ts +6 -4
- package/es/store/TriggerExecutor.js +16 -4
- package/es/store/checker.d.ts +2 -2
- package/es/store/checker.js +45 -9
- package/es/store/filter.d.ts +3 -3
- package/es/store/filter.js +4 -4
- package/es/store/modi.d.ts +5 -5
- package/es/store/modi.js +4 -4
- package/es/store/projection.d.ts +1 -1
- package/es/store/relation.js +1 -1
- package/es/store/triggers.d.ts +4 -4
- package/es/store/triggers.js +2 -2
- package/es/timers/oper.d.ts +3 -3
- package/es/timers/oper.js +1 -1
- package/es/timers/vaccum.d.ts +3 -3
- package/es/types/Action.d.ts +1 -1
- package/es/types/AppLoader.d.ts +1 -1
- package/es/types/Aspect.d.ts +1 -1
- package/es/types/Auth.d.ts +2 -2
- package/es/types/Configuration.d.ts +7 -6
- package/es/types/Connector.d.ts +47 -1
- package/es/types/DataType.d.ts +2 -2
- package/es/types/Demand.d.ts +40 -6
- package/es/types/Endpoint.d.ts +17 -1
- package/es/types/Entity.d.ts +21 -4
- package/es/types/Entity.js +23 -0
- package/es/types/EntityDesc.d.ts +9 -8
- package/es/types/Environment.d.ts +17 -0
- package/es/types/Exception.d.ts +1 -1
- package/es/types/Exception.js +1 -1
- package/es/types/Expression.d.ts +13 -2
- package/es/types/Expression.js +36 -1
- package/es/types/Locale.d.ts +14 -1
- package/es/types/Locale.js +13 -1
- package/es/types/OakPackage.d.ts +29 -0
- package/es/types/OakPackage.js +30 -0
- package/es/types/Port.d.ts +1 -1
- package/es/types/RowStore.d.ts +9 -7
- package/es/types/Storage.d.ts +11 -3
- package/es/types/Storage.js +12 -1
- package/es/types/Style.d.ts +2 -2
- package/es/types/Sync.d.ts +3 -3
- package/es/types/Timer.d.ts +14 -2
- package/es/types/Trigger.d.ts +1 -1
- package/es/types/Watcher.d.ts +1 -1
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/utils/SimpleConnector.d.ts +30 -4
- package/es/utils/SimpleConnector.js +294 -21
- package/es/utils/concurrent.js +1 -1
- package/es/utils/decimal.d.ts +26 -0
- package/es/utils/decimal.js +87 -0
- package/es/utils/fetch/index.d.ts +1 -0
- package/es/utils/fetch/index.js +3 -0
- package/es/utils/fetch/index.mp.d.ts +3 -0
- package/es/utils/fetch/index.mp.js +280 -0
- package/es/utils/fetch/index.native.d.ts +1 -0
- package/es/utils/fetch/index.native.js +3 -0
- package/es/utils/fetch/index.web.d.ts +1 -0
- package/es/utils/fetch/index.web.js +3 -0
- package/es/utils/fetch/shared.d.ts +6 -0
- package/es/utils/fetch/shared.js +23 -0
- package/es/utils/localizedContent.d.ts +11 -0
- package/es/utils/localizedContent.js +346 -0
- package/es/utils/lodash.d.ts +1 -35
- package/es/utils/lodash.js +1 -52
- package/es/utils/module/combine.common.d.ts +3 -3
- package/es/utils/module/combine.common.js +2 -2
- package/es/utils/module/combine.dev.d.ts +2 -2
- package/es/utils/module/combine.dev.js +2 -2
- package/es/utils/module/combine.prod.d.ts +1 -1
- package/es/utils/module/combine.server.d.ts +2 -2
- package/es/utils/module/combine.server.js +2 -2
- package/es/utils/money.d.ts +2 -2
- package/es/utils/money.js +2 -2
- package/es/utils/operationResult.js +1 -1
- package/es/utils/projection.d.ts +3 -3
- package/es/utils/projection.js +1 -1
- package/es/utils/relationPath.d.ts +1 -1
- package/es/utils/relationPath.js +1 -1
- package/es/utils/row.d.ts +3 -3
- package/es/utils/row.js +2 -2
- package/es/utils/sseEndpoint.d.ts +41 -0
- package/es/utils/sseEndpoint.js +151 -0
- package/es/utils/toolkit.d.ts +28 -0
- package/es/utils/toolkit.js +220 -0
- package/es/utils/url/index.d.ts +1 -3
- package/es/utils/url/index.js +1 -1
- package/es/utils/url/index.mp.d.ts +16 -3
- package/es/utils/url/index.mp.js +2 -2
- package/es/utils/url/index.native.d.ts +13 -1
- package/es/utils/url/index.native.js +3 -1
- package/es/utils/url/index.web.d.ts +13 -1
- package/es/utils/url/index.web.js +3 -1
- package/es/utils/url/lightweight.d.ts +65 -0
- package/es/utils/url/lightweight.js +530 -0
- package/es/utils/url/urlObject.d.ts +16 -0
- package/es/utils/validate/id.d.ts +5 -0
- package/es/utils/validate/id.js +28 -0
- package/es/utils/validate/index.d.ts +4 -0
- package/es/utils/validate/index.js +4 -0
- package/es/utils/validate/mobile.d.ts +6 -0
- package/es/utils/validate/mobile.js +49 -0
- package/es/utils/validate/nationality.d.ts +14 -0
- package/es/utils/validate/nationality.data.d.ts +9 -0
- package/es/utils/validate/nationality.data.js +257 -0
- package/es/utils/validate/nationality.js +64 -0
- package/es/utils/validate/passport.d.ts +3 -0
- package/es/utils/validate/passport.js +19 -0
- package/es/utils/validator.d.ts +10 -8
- package/es/utils/validator.js +24 -40
- package/lib/actions/action.d.ts +1 -1
- package/lib/base-app-domain/EntityDict.d.ts +27 -0
- package/lib/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
- package/lib/base-app-domain/LocalizedContent/Schema.js +4 -0
- package/lib/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
- package/lib/base-app-domain/LocalizedContent/Storage.js +78 -0
- package/lib/base-app-domain/LocalizedContent/Style.d.ts +3 -0
- package/lib/base-app-domain/LocalizedContent/Style.js +15 -0
- package/lib/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
- package/lib/base-app-domain/Storage.js +26 -24
- package/lib/base-app-domain/StyleDict.js +10 -8
- package/lib/compiler/customChecks/i18n.js +5 -2
- package/lib/compiler/customChecks/runner.d.ts +1 -1
- package/lib/compiler/customChecks/types.d.ts +2 -1
- package/lib/compiler/dependencyBuilder.d.ts +11 -2
- package/lib/compiler/dependencyBuilder.js +237 -243
- package/lib/compiler/entityDescEnum.d.ts +5 -0
- package/lib/compiler/entityDescEnum.js +450 -0
- package/lib/compiler/entitySource.d.ts +28 -0
- package/lib/compiler/entitySource.js +529 -0
- package/lib/compiler/localeBuilder.d.ts +7 -2
- package/lib/compiler/localeBuilder.js +52 -56
- package/lib/compiler/routerBuilder.d.ts +32 -3
- package/lib/compiler/routerBuilder.js +160 -48
- package/lib/compiler/schemaBuilder.d.ts +12 -2
- package/lib/compiler/schemaBuilder.js +855 -350
- package/lib/compiler/tscBuilder.d.ts +20 -2
- package/lib/compiler/tscBuilder.js +217 -37
- package/lib/context/BackendRuntimeContext.d.ts +6 -4
- package/lib/context/BackendRuntimeContext.js +10 -3
- package/lib/context/ContextComposer.d.ts +93 -0
- package/lib/context/ContextComposer.js +361 -0
- package/lib/context/SerializedData.d.ts +2 -1
- package/lib/data/i18n.d.ts +1 -1
- package/lib/data/i18n.js +1 -86
- package/lib/data/i18n.json +86 -0
- package/lib/entities/ActionAuth.d.ts +3 -3
- package/lib/entities/I18n.d.ts +2 -2
- package/lib/entities/LocalizedContent.d.ts +22 -0
- package/lib/entities/LocalizedContent.js +104 -0
- package/lib/entities/Log.d.ts +3 -3
- package/lib/entities/Modi.d.ts +2 -2
- package/lib/entities/ModiEntity.d.ts +3 -3
- package/lib/entities/Oper.d.ts +5 -5
- package/lib/entities/OperEntity.d.ts +3 -3
- package/lib/entities/Path.d.ts +2 -2
- package/lib/entities/Relation.d.ts +2 -2
- package/lib/entities/RelationAuth.d.ts +3 -3
- package/lib/entities/User.d.ts +4 -4
- package/lib/entities/UserEntityClaim.d.ts +6 -6
- package/lib/entities/UserEntityGrant.d.ts +2 -2
- package/lib/entities/UserRelation.d.ts +4 -4
- package/lib/store/AsyncRowStore.d.ts +2 -2
- package/lib/store/AsyncRowStore.js +6 -7
- package/lib/store/CascadeStore.d.ts +5 -3
- package/lib/store/CascadeStore.js +101 -70
- package/lib/store/IntrinsicCheckers.d.ts +1 -1
- package/lib/store/IntrinsicCheckers.js +12 -13
- package/lib/store/IntrinsicLogics.d.ts +1 -1
- package/lib/store/RelationAuth.js +42 -43
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/SyncRowStore.js +4 -5
- package/lib/store/TriggerExecutor.d.ts +6 -4
- package/lib/store/TriggerExecutor.js +39 -28
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +55 -20
- package/lib/store/filter.d.ts +3 -3
- package/lib/store/filter.js +47 -48
- package/lib/store/modi.d.ts +5 -5
- package/lib/store/modi.js +5 -6
- package/lib/store/projection.d.ts +1 -1
- package/lib/store/relation.js +4 -5
- package/lib/store/triggers.d.ts +4 -4
- package/lib/store/triggers.js +13 -14
- package/lib/timers/oper.d.ts +3 -3
- package/lib/timers/vaccum.d.ts +3 -3
- package/lib/types/Action.d.ts +1 -1
- package/lib/types/AppLoader.d.ts +1 -1
- package/lib/types/Aspect.d.ts +1 -1
- package/lib/types/Auth.d.ts +2 -2
- package/lib/types/Configuration.d.ts +7 -6
- package/lib/types/Connector.d.ts +47 -1
- package/lib/types/DataType.d.ts +2 -2
- package/lib/types/Demand.d.ts +40 -6
- package/lib/types/Endpoint.d.ts +17 -1
- package/lib/types/Entity.d.ts +21 -4
- package/lib/types/Entity.js +27 -0
- package/lib/types/EntityDesc.d.ts +9 -8
- package/lib/types/Environment.d.ts +17 -0
- package/lib/types/Exception.d.ts +1 -1
- package/lib/types/Exception.js +2 -2
- package/lib/types/Expression.d.ts +13 -2
- package/lib/types/Expression.js +40 -5
- package/lib/types/Locale.d.ts +14 -1
- package/lib/types/Locale.js +14 -0
- package/lib/types/OakPackage.d.ts +29 -0
- package/lib/types/OakPackage.js +36 -0
- package/lib/types/Port.d.ts +1 -1
- package/lib/types/RowStore.d.ts +9 -7
- package/lib/types/Storage.d.ts +11 -3
- package/lib/types/Storage.js +13 -0
- package/lib/types/Style.d.ts +2 -2
- package/lib/types/Sync.d.ts +3 -3
- package/lib/types/Timer.d.ts +14 -2
- package/lib/types/Trigger.d.ts +1 -1
- package/lib/types/Watcher.d.ts +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/utils/SimpleConnector.d.ts +30 -4
- package/lib/utils/SimpleConnector.js +297 -24
- package/lib/utils/concurrent.js +4 -5
- package/lib/utils/decimal.d.ts +26 -0
- package/lib/utils/decimal.js +112 -0
- package/lib/utils/fetch/index.d.ts +1 -0
- package/lib/utils/fetch/index.js +6 -0
- package/lib/utils/fetch/index.mp.d.ts +3 -0
- package/lib/utils/fetch/index.mp.js +285 -0
- package/lib/utils/fetch/index.native.d.ts +1 -0
- package/lib/utils/fetch/index.native.js +6 -0
- package/lib/utils/fetch/index.web.d.ts +1 -0
- package/lib/utils/fetch/index.web.js +6 -0
- package/lib/utils/fetch/shared.d.ts +6 -0
- package/lib/utils/fetch/shared.js +28 -0
- package/lib/utils/localizedContent.d.ts +11 -0
- package/lib/utils/localizedContent.js +352 -0
- package/lib/utils/lodash.d.ts +1 -35
- package/lib/utils/lodash.js +1 -76
- package/lib/utils/module/combine.common.d.ts +3 -3
- package/lib/utils/module/combine.common.js +6 -7
- package/lib/utils/module/combine.dev.d.ts +2 -2
- package/lib/utils/module/combine.dev.js +19 -19
- package/lib/utils/module/combine.prod.d.ts +1 -1
- package/lib/utils/module/combine.server.d.ts +2 -2
- package/lib/utils/module/combine.server.js +19 -19
- package/lib/utils/money.d.ts +2 -2
- package/lib/utils/money.js +2 -2
- package/lib/utils/operationResult.js +4 -4
- package/lib/utils/projection.d.ts +3 -3
- package/lib/utils/relationPath.d.ts +1 -1
- package/lib/utils/relationPath.js +10 -11
- package/lib/utils/row.d.ts +3 -3
- package/lib/utils/row.js +4 -5
- package/lib/utils/sseEndpoint.d.ts +41 -0
- package/lib/utils/sseEndpoint.js +156 -0
- package/lib/utils/toolkit.d.ts +28 -0
- package/lib/utils/toolkit.js +253 -0
- package/lib/utils/url/index.d.ts +1 -3
- package/lib/utils/url/index.js +3 -1
- package/lib/utils/url/index.mp.d.ts +16 -3
- package/lib/utils/url/index.mp.js +6 -4
- package/lib/utils/url/index.native.d.ts +13 -1
- package/lib/utils/url/index.native.js +5 -1
- package/lib/utils/url/index.web.d.ts +13 -1
- package/lib/utils/url/index.web.js +5 -1
- package/lib/utils/url/lightweight.d.ts +65 -0
- package/lib/utils/url/lightweight.js +535 -0
- package/lib/utils/url/urlObject.d.ts +16 -0
- package/lib/utils/url/urlObject.js +2 -0
- package/lib/utils/url/whatwg-url/lib/URL-impl.d.ts +8 -15
- package/lib/utils/url/whatwg-url/lib/infra.js +5 -4
- package/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +3 -1
- package/lib/utils/url/whatwg-url/lib/utils.d.ts +1 -1
- package/lib/utils/validate/id.d.ts +5 -0
- package/lib/utils/validate/id.js +35 -0
- package/lib/utils/validate/index.d.ts +4 -0
- package/lib/utils/validate/index.js +7 -0
- package/lib/utils/validate/mobile.d.ts +6 -0
- package/lib/utils/validate/mobile.js +57 -0
- package/lib/utils/validate/nationality.d.ts +14 -0
- package/lib/utils/validate/nationality.data.d.ts +9 -0
- package/lib/utils/validate/nationality.data.js +260 -0
- package/lib/utils/validate/nationality.js +76 -0
- package/lib/utils/validate/passport.d.ts +3 -0
- package/lib/utils/validate/passport.js +24 -0
- package/lib/utils/validator.d.ts +10 -8
- package/lib/utils/validator.js +38 -42
- package/package.json +19 -9
- package/es/utils/url/whatwg-url/index.d.ts +0 -3
- package/es/utils/url/whatwg-url/index.js +0 -12
- package/es/utils/url/whatwg-url/lib/URL-impl.d.ts +0 -27
- package/es/utils/url/whatwg-url/lib/URL-impl.js +0 -172
- package/es/utils/url/whatwg-url/lib/URL.js +0 -295
- package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
- package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -123
- package/es/utils/url/whatwg-url/lib/URLSearchParams.js +0 -423
- package/es/utils/url/whatwg-url/lib/infra.d.ts +0 -12
- package/es/utils/url/whatwg-url/lib/infra.js +0 -19
- package/es/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
- package/es/utils/url/whatwg-url/lib/url-state-machine.js +0 -1228
- package/es/utils/url/whatwg-url/lib/urlencoded.d.ts +0 -14
- package/es/utils/url/whatwg-url/lib/urlencoded.js +0 -160
- package/es/utils/url/whatwg-url/lib/utils.d.ts +0 -37
- package/es/utils/url/whatwg-url/lib/utils.js +0 -99
- package/lib/store/diffSchema.d.ts +0 -1
- package/lib/utils/url/whatwg-url/index.d.ts +0 -3
- package/lib/utils/url/whatwg-url/index.js +0 -16
- package/lib/utils/url/whatwg-url/lib/URL-impl.js +0 -175
- package/lib/utils/url/whatwg-url/lib/URL.d.ts +0 -1
- package/lib/utils/url/whatwg-url/lib/URL.js +0 -298
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
- package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -126
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.d.ts +0 -1
- package/lib/utils/url/whatwg-url/lib/URLSearchParams.js +0 -426
- package/lib/utils/url/whatwg-url/lib/infra.d.ts +0 -12
- package/lib/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
- package/lib/utils/url/whatwg-url/lib/url-state-machine.js +0 -1238
- package/lib/utils/url/whatwg-url/lib/urlencoded.js +0 -162
- package/lib/utils/url/whatwg-url/lib/utils.js +0 -101
- package/src/entities/ActionAuth.ts +0 -50
- package/src/entities/I18n.ts +0 -53
- package/src/entities/Log.ts +0 -62
- package/src/entities/Modi.ts +0 -107
- package/src/entities/ModiEntity.ts +0 -35
- package/src/entities/Oper.ts +0 -115
- package/src/entities/OperEntity.ts +0 -36
- package/src/entities/Path.ts +0 -56
- package/src/entities/Relation.ts +0 -53
- package/src/entities/RelationAuth.ts +0 -53
- package/src/entities/User.ts +0 -85
- package/src/entities/UserEntityClaim.ts +0 -41
- package/src/entities/UserEntityGrant.ts +0 -33
- package/src/entities/UserRelation.ts +0 -60
- /package/es/{utils/url/whatwg-url/lib/URL.d.ts → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
- /package/es/utils/url/{whatwg-url/lib/URLSearchParams.d.ts → urlObject.js} +0 -0
- /package/lib/{store/diffSchema.js → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
package/lib/store/checker.js
CHANGED
|
@@ -4,12 +4,11 @@ exports.translateCheckerInAsyncContext = translateCheckerInAsyncContext;
|
|
|
4
4
|
exports.translateCheckerInSyncContext = translateCheckerInSyncContext;
|
|
5
5
|
exports.createRemoveCheckers = createRemoveCheckers;
|
|
6
6
|
exports.createCreateCheckers = createCreateCheckers;
|
|
7
|
-
const
|
|
8
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
7
|
+
const assert_1 = require("../utils/assert");
|
|
9
8
|
const filter_1 = require("../store/filter");
|
|
10
9
|
const Exception_1 = require("../types/Exception");
|
|
11
10
|
const types_1 = require("../types");
|
|
12
|
-
const
|
|
11
|
+
const toolkit_1 = require("../utils/toolkit");
|
|
13
12
|
const action_1 = require("../actions/action");
|
|
14
13
|
function getFullProjection(entity, schema) {
|
|
15
14
|
const { attributes } = schema[entity];
|
|
@@ -92,7 +91,7 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
92
91
|
let operationFilter2 = operationFilter;
|
|
93
92
|
if (action === 'create') {
|
|
94
93
|
// 后台进行创建检查时,以传入的data为准
|
|
95
|
-
(0, assert_1.
|
|
94
|
+
(0, assert_1.assert)(data);
|
|
96
95
|
if (data instanceof Array) {
|
|
97
96
|
for (const d of data) {
|
|
98
97
|
await checkSingle((0, filter_1.translateCreateDataToFilter)(schema, entity, d, !!bornAt));
|
|
@@ -103,7 +102,7 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
103
102
|
}
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
|
-
(0, assert_1.
|
|
105
|
+
(0, assert_1.assert)(operationFilter2, 'row类型的checker遇到了操作的filter未定义');
|
|
107
106
|
await checkSingle(operationFilter2);
|
|
108
107
|
return 0;
|
|
109
108
|
}
|
|
@@ -126,7 +125,7 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
126
125
|
};
|
|
127
126
|
}
|
|
128
127
|
default: {
|
|
129
|
-
(0, assert_1.
|
|
128
|
+
(0, assert_1.assert)(false);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -155,12 +154,12 @@ function translateCheckerInSyncContext(checker, schema) {
|
|
|
155
154
|
if (data) {
|
|
156
155
|
// 前端的策略是,有data用data,无data用filter
|
|
157
156
|
// 目前前端应该不可能制造出来createMultiple
|
|
158
|
-
(0, assert_1.
|
|
157
|
+
(0, assert_1.assert)(!(data instanceof Array));
|
|
159
158
|
operationFilter2 = (0, filter_1.translateCreateDataToFilter)(schema, entity, data, !!bornAt);
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
|
-
(0, assert_1.
|
|
163
|
-
(0, assert_1.
|
|
161
|
+
(0, assert_1.assert)(!(filter2 instanceof Promise));
|
|
162
|
+
(0, assert_1.assert)(operationFilter2, '定义了row类型的checker但却进行了无filter操作');
|
|
164
163
|
// @oak-ignore
|
|
165
164
|
if ((0, filter_1.checkFilterContains)(entity, context, filter2, operationFilter2, true)) {
|
|
166
165
|
return;
|
|
@@ -185,7 +184,7 @@ function translateCheckerInSyncContext(checker, schema) {
|
|
|
185
184
|
};
|
|
186
185
|
}
|
|
187
186
|
default: {
|
|
188
|
-
(0, assert_1.
|
|
187
|
+
(0, assert_1.assert)(false);
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
190
|
}
|
|
@@ -238,7 +237,7 @@ function createRemoveCheckers(schema) {
|
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
239
|
// 当删除一时,要确认多上面没有指向一的数据
|
|
241
|
-
const entities = (0,
|
|
240
|
+
const entities = (0, toolkit_1.union)(Object.keys(OneToManyMatrix), Object.keys(OneToManyOnEntityMatrix));
|
|
242
241
|
for (const entity of entities) {
|
|
243
242
|
checkers.push({
|
|
244
243
|
entity: entity,
|
|
@@ -333,7 +332,7 @@ function createRemoveCheckers(schema) {
|
|
|
333
332
|
}
|
|
334
333
|
return checkers;
|
|
335
334
|
}
|
|
336
|
-
function checkAttributeLegal(schema, entity, data) {
|
|
335
|
+
function checkAttributeLegal(schema, entity, data, allowExpressionValue) {
|
|
337
336
|
const { attributes } = schema[entity];
|
|
338
337
|
for (const attr in data) {
|
|
339
338
|
if (attributes[attr]) {
|
|
@@ -349,6 +348,16 @@ function checkAttributeLegal(schema, entity, data) {
|
|
|
349
348
|
}
|
|
350
349
|
continue;
|
|
351
350
|
}
|
|
351
|
+
if ((0, types_1.isUpdateExpressionValue)(data[attr]) && !(0, types_1.isJsonLiteralAttributeType)(type)) {
|
|
352
|
+
const expr = data[attr].$expr;
|
|
353
|
+
if (!(0, types_1.shouldTreatAsUpdateExpressionValue)(type, data[attr]) || !allowExpressionValue || (!(0, types_1.isExpression)(expr) && !(0, types_1.isRefAttrNode)(expr))) {
|
|
354
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesFormatError', 'oak-domain', {
|
|
355
|
+
attribtues: attr,
|
|
356
|
+
format: 'expression',
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
352
361
|
switch (type) {
|
|
353
362
|
case 'char':
|
|
354
363
|
case 'varchar': {
|
|
@@ -371,22 +380,48 @@ function checkAttributeLegal(schema, entity, data) {
|
|
|
371
380
|
case 'smallint':
|
|
372
381
|
case 'tinyint':
|
|
373
382
|
case 'bigint':
|
|
374
|
-
case 'decimal':
|
|
375
383
|
case 'money': {
|
|
376
|
-
|
|
384
|
+
const value = data[attr];
|
|
385
|
+
if (typeof value !== 'number') {
|
|
377
386
|
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesFormatError', 'oak-domain', {
|
|
378
387
|
attribtues: attr,
|
|
379
388
|
format: 'number',
|
|
380
389
|
});
|
|
381
390
|
}
|
|
382
391
|
const { min, max } = params || {};
|
|
383
|
-
if (typeof min === 'number' &&
|
|
392
|
+
if (typeof min === 'number' && value < min) {
|
|
393
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesUnderMin', 'oak-domain', {
|
|
394
|
+
attributes: attr,
|
|
395
|
+
threshold: `${min}`,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
if (typeof max === 'number' && value > max) {
|
|
399
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesOverMax', 'oak-domain', {
|
|
400
|
+
attributes: attr,
|
|
401
|
+
threshold: `${max}`,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
case 'decimal': {
|
|
407
|
+
const value = data[attr];
|
|
408
|
+
const isDecimalString = typeof value === 'string'
|
|
409
|
+
&& /^-?(?:\d+|\d*\.\d+)$/.test(value);
|
|
410
|
+
if (!isDecimalString) {
|
|
411
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesFormatError', 'oak-domain', {
|
|
412
|
+
attribtues: attr,
|
|
413
|
+
format: allowExpressionValue ? 'string | expression' : 'string',
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
const { min, max } = params || {};
|
|
417
|
+
const numericValue = Number(value);
|
|
418
|
+
if (typeof min === 'number' && numericValue < min) {
|
|
384
419
|
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesUnderMin', 'oak-domain', {
|
|
385
420
|
attributes: attr,
|
|
386
421
|
threshold: `${min}`,
|
|
387
422
|
});
|
|
388
423
|
}
|
|
389
|
-
if (typeof max === 'number' &&
|
|
424
|
+
if (typeof max === 'number' && numericValue > max) {
|
|
390
425
|
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesOverMax', 'oak-domain', {
|
|
391
426
|
attributes: attr,
|
|
392
427
|
threshold: `${max}`,
|
|
@@ -395,7 +430,7 @@ function checkAttributeLegal(schema, entity, data) {
|
|
|
395
430
|
break;
|
|
396
431
|
}
|
|
397
432
|
case 'enum': {
|
|
398
|
-
(0, assert_1.
|
|
433
|
+
(0, assert_1.assert)(enumeration);
|
|
399
434
|
if (!enumeration.includes(data[attr])) {
|
|
400
435
|
throw new Exception_1.OakInputIllegalException(entity, [attr], 'error::attributesNotInEnumeration');
|
|
401
436
|
}
|
|
@@ -416,14 +451,14 @@ function createCreateCheckers(schema) {
|
|
|
416
451
|
for (const entity in schema) {
|
|
417
452
|
const { attributes, actions } = schema[entity];
|
|
418
453
|
const notNullAttrs = Object.keys(attributes).filter(ele => attributes[ele].notNull);
|
|
419
|
-
const updateActions = (0,
|
|
454
|
+
const updateActions = (0, toolkit_1.difference)(actions, action_1.excludeUpdateActions);
|
|
420
455
|
checkers.push({
|
|
421
456
|
entity,
|
|
422
457
|
type: 'data',
|
|
423
458
|
action: 'create',
|
|
424
459
|
checker: (data) => {
|
|
425
460
|
const checkData = (data2) => {
|
|
426
|
-
const illegalNullAttrs = (0,
|
|
461
|
+
const illegalNullAttrs = (0, toolkit_1.difference)(notNullAttrs, Object.keys(data2).filter(ele => data2[ele] !== null));
|
|
427
462
|
if (illegalNullAttrs.length > 0) {
|
|
428
463
|
const emtpyAttrs = [];
|
|
429
464
|
// 要处理多对一的cascade create
|
|
@@ -473,7 +508,7 @@ function createCreateCheckers(schema) {
|
|
|
473
508
|
type: 'data',
|
|
474
509
|
action: updateActions,
|
|
475
510
|
checker: (data) => {
|
|
476
|
-
checkAttributeLegal(schema, entity, data);
|
|
511
|
+
checkAttributeLegal(schema, entity, data, true);
|
|
477
512
|
}
|
|
478
513
|
});
|
|
479
514
|
}
|
package/lib/store/filter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EntityDict as BaseEntityDict, StorageSchema } from
|
|
1
|
+
import { EntityDict as BaseEntityDict, StorageSchema } from "../types";
|
|
2
2
|
import { EntityDict } from "../base-app-domain";
|
|
3
|
-
import { AsyncContext } from
|
|
4
|
-
import { SyncContext } from
|
|
3
|
+
import { AsyncContext } from "./AsyncRowStore";
|
|
4
|
+
import { SyncContext } from "./SyncRowStore";
|
|
5
5
|
export declare function translateCreateDataToFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, data: ED[T]['CreateOperationData'], allowUnrecoganized: boolean): ED[T]["Filter"];
|
|
6
6
|
export declare function combineFilters<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(entity: T, schema: StorageSchema<ED>, filters: Array<ED[T]['Filter']>, union?: true): ED[T]["Filter"] | undefined;
|
|
7
7
|
type DeducedFilter<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
package/lib/store/filter.js
CHANGED
|
@@ -12,10 +12,9 @@ exports.makeTreeDescendantFilter = makeTreeDescendantFilter;
|
|
|
12
12
|
exports.checkFilterContains = checkFilterContains;
|
|
13
13
|
exports.checkFilterRepel = checkFilterRepel;
|
|
14
14
|
exports.translateFilterToObjectPredicate = translateFilterToObjectPredicate;
|
|
15
|
-
const
|
|
16
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
15
|
+
const assert_1 = require("../utils/assert");
|
|
17
16
|
const types_1 = require("../types");
|
|
18
|
-
const
|
|
17
|
+
const toolkit_1 = require("../utils/toolkit");
|
|
19
18
|
const relation_1 = require("./relation");
|
|
20
19
|
function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) {
|
|
21
20
|
const data2 = {};
|
|
@@ -57,7 +56,7 @@ function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) {
|
|
|
57
56
|
function addFilterSegment(entity, schema, ...filters) {
|
|
58
57
|
let filter;
|
|
59
58
|
const addIntoAnd = (f) => {
|
|
60
|
-
(0, assert_1.
|
|
59
|
+
(0, assert_1.assert)(filter);
|
|
61
60
|
if (filter.$and) {
|
|
62
61
|
filter.$and.push(f);
|
|
63
62
|
}
|
|
@@ -68,7 +67,7 @@ function addFilterSegment(entity, schema, ...filters) {
|
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
69
|
const addSingleAttr = (attr, value) => {
|
|
71
|
-
(0, assert_1.
|
|
70
|
+
(0, assert_1.assert)(filter);
|
|
72
71
|
if (!filter[attr]) {
|
|
73
72
|
Object.assign(filter, {
|
|
74
73
|
[attr]: value
|
|
@@ -138,7 +137,7 @@ function addFilterSegment(entity, schema, ...filters) {
|
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
else if (attr.startsWith('#')) {
|
|
141
|
-
(0, assert_1.
|
|
140
|
+
(0, assert_1.assert)(!filter[attr] || filter[attr] === f[attr]);
|
|
142
141
|
filter[attr] = f[attr];
|
|
143
142
|
}
|
|
144
143
|
else {
|
|
@@ -153,7 +152,7 @@ function addFilterSegment(entity, schema, ...filters) {
|
|
|
153
152
|
addManyToOneFilter(attr, rel, f[attr]);
|
|
154
153
|
}
|
|
155
154
|
else {
|
|
156
|
-
(0, assert_1.
|
|
155
|
+
(0, assert_1.assert)(rel instanceof Array);
|
|
157
156
|
addOneToManyFilter(attr, rel[0], f[attr]);
|
|
158
157
|
}
|
|
159
158
|
}
|
|
@@ -170,7 +169,7 @@ function addFilterSegment(entity, schema, ...filters) {
|
|
|
170
169
|
const filters2 = oneToManyFilters[attr].map(ele => ele[1]);
|
|
171
170
|
const sqpOps = filters2.map(ele => ele['#sqp'] || 'in');
|
|
172
171
|
// 只有全部是同一个子查询算子才能实施合并,这里有进一步优化的余地,但是貌似没必要
|
|
173
|
-
if ((0,
|
|
172
|
+
if ((0, toolkit_1.uniq)(sqpOps).length > 1) {
|
|
174
173
|
filters2.forEach(ele => {
|
|
175
174
|
addIntoAnd({
|
|
176
175
|
[attr]: ele,
|
|
@@ -236,7 +235,7 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
236
235
|
if (pca1s.length > 1 || pca2s.length > 1) {
|
|
237
236
|
return false;
|
|
238
237
|
}
|
|
239
|
-
(0, assert_1.
|
|
238
|
+
(0, assert_1.assert)(pca1s.length === 1 && pca2s.length === 1);
|
|
240
239
|
if (pca1s[0] !== pca2s[0] && pca1s[0] !== '$or' && pca2s[0] !== '$or') {
|
|
241
240
|
return false;
|
|
242
241
|
}
|
|
@@ -386,7 +385,7 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
386
385
|
}
|
|
387
386
|
else if (pca1 === pca2) {
|
|
388
387
|
if (pca1 === '$and') {
|
|
389
|
-
(0, assert_1.
|
|
388
|
+
(0, assert_1.assert)(false, '只一个属性的时候不应该用$and');
|
|
390
389
|
}
|
|
391
390
|
else if (pca1 === '$not') {
|
|
392
391
|
// 先not后or 等于先and后not
|
|
@@ -426,7 +425,7 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
426
425
|
return true;
|
|
427
426
|
}
|
|
428
427
|
else {
|
|
429
|
-
(0, assert_1.
|
|
428
|
+
(0, assert_1.assert)(rel instanceof Array);
|
|
430
429
|
// 一对多的子查询,只有子查询的语义算子一样才实施合并
|
|
431
430
|
const sqpOp1 = f1[pca1]['#sqp'] || 'in';
|
|
432
431
|
const sqpOp2 = f2[pca1]['#sqp'] || 'in';
|
|
@@ -446,7 +445,7 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
446
445
|
}
|
|
447
446
|
else {
|
|
448
447
|
// not in情况子查询变成and
|
|
449
|
-
(0, assert_1.
|
|
448
|
+
(0, assert_1.assert)(sqpOp1 === 'not in'); // all和not all暂时不支持
|
|
450
449
|
Object.assign(f1, {
|
|
451
450
|
[pca1]: Object.assign(addFilterSegment(rel[0], schema, f1[pca1], f2[pca2]), {
|
|
452
451
|
['#sqp']: sqpOp1,
|
|
@@ -460,7 +459,7 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
460
459
|
return false;
|
|
461
460
|
};
|
|
462
461
|
const addIntoOr = (f) => {
|
|
463
|
-
(0, assert_1.
|
|
462
|
+
(0, assert_1.assert)(filter);
|
|
464
463
|
if (Object.keys(filter).length === 0) {
|
|
465
464
|
Object.assign(filter, f);
|
|
466
465
|
}
|
|
@@ -469,14 +468,14 @@ function unionFilterSegment(entity, schema, ...filters) {
|
|
|
469
468
|
}
|
|
470
469
|
else {
|
|
471
470
|
filter = {
|
|
472
|
-
$or: [(0,
|
|
471
|
+
$or: [(0, toolkit_1.cloneDeep)(filter), f],
|
|
473
472
|
};
|
|
474
473
|
}
|
|
475
474
|
};
|
|
476
475
|
const addInner = (f) => {
|
|
477
476
|
if (f) {
|
|
478
477
|
if (!filter) {
|
|
479
|
-
filter = (0,
|
|
478
|
+
filter = (0, toolkit_1.cloneDeep)(f);
|
|
480
479
|
return;
|
|
481
480
|
}
|
|
482
481
|
if (tryMergeFilters(filter, f)) {
|
|
@@ -739,7 +738,7 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
739
738
|
return false;
|
|
740
739
|
}
|
|
741
740
|
default: {
|
|
742
|
-
(0, assert_1.
|
|
741
|
+
(0, assert_1.assert)(false, `不能处理的算子「${attr}」`);
|
|
743
742
|
}
|
|
744
743
|
}
|
|
745
744
|
}
|
|
@@ -764,9 +763,9 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
764
763
|
else if (['$in', '$nin', '$between'].includes(attr)) {
|
|
765
764
|
switch (attr) {
|
|
766
765
|
case '$in': {
|
|
767
|
-
(0, assert_1.
|
|
766
|
+
(0, assert_1.assert)(value1.$in instanceof Array);
|
|
768
767
|
const attr2 = (typeof value2 === 'object') && Object.keys(value2)[0];
|
|
769
|
-
let c = (attr2 === '$in' && value2[attr2] instanceof Array && (0,
|
|
768
|
+
let c = (attr2 === '$in' && value2[attr2] instanceof Array && (0, toolkit_1.difference)(value1.$in, value2[attr2]).length === 0) || (attr2 === '$nin' && value2[attr2] instanceof Array && (0, toolkit_1.intersection)(value1.$in, value2[attr2]).length === 0) || (attr2 === '$exists' && value2[attr2] === true);
|
|
770
769
|
if (!c && attr2 && ['$gt', '$gte', '$lt', '$lte', '$between'].includes(attr2)) {
|
|
771
770
|
let min33, max33;
|
|
772
771
|
value1.$in.forEach((ele) => {
|
|
@@ -781,7 +780,7 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
781
780
|
|| attr2 === '$lt' && value2[attr2] > max33 || attr2 === '$lte' && value2[attr2] >= max33
|
|
782
781
|
|| attr2 === '$between' && value2[attr2][0] < min33 && value2[attr2][1] > max33;
|
|
783
782
|
}
|
|
784
|
-
let r = (attr2 === '$in' && (0,
|
|
783
|
+
let r = (attr2 === '$in' && (0, toolkit_1.intersection)(value2[attr2], value1.$in).length === 0) || (attr2 === '$eq' && !value1.$in.includes(value2[attr2])) || (attr2 === '$exists' && value2[attr2] === false) || (!value1.$in.includes(value2));
|
|
785
784
|
if (!r && attr2 && ['$gt', '$gte', '$lt', '$lte', '$between'].includes(attr2)) {
|
|
786
785
|
let min44, max44;
|
|
787
786
|
value1.$in.forEach((ele) => {
|
|
@@ -813,11 +812,11 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
813
812
|
return false;
|
|
814
813
|
}
|
|
815
814
|
case '$nin': {
|
|
816
|
-
(0, assert_1.
|
|
815
|
+
(0, assert_1.assert)(value1.$nin instanceof Array);
|
|
817
816
|
const attr2 = (typeof value2 === 'object') && Object.keys(value2)[0];
|
|
818
|
-
const c = attr2 && (attr2 === '$nin' && value2[attr2] instanceof Array && (0,
|
|
817
|
+
const c = attr2 && (attr2 === '$nin' && value2[attr2] instanceof Array && (0, toolkit_1.intersection)(value2[attr2], value1.$nin).length === 0
|
|
819
818
|
|| attr2 === '$ne' && value1.$nin.includes(value2[attr2]));
|
|
820
|
-
const r = attr2 && (attr2 === '$in' && value2[attr2] instanceof Array && (0,
|
|
819
|
+
const r = attr2 && (attr2 === '$in' && value2[attr2] instanceof Array && (0, toolkit_1.intersection)(value2[attr2], value1.$nin).length > 0) || value1.$nin.includes(value2);
|
|
821
820
|
if (contained) {
|
|
822
821
|
// 相容
|
|
823
822
|
if (c) {
|
|
@@ -834,7 +833,7 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
834
833
|
return false;
|
|
835
834
|
}
|
|
836
835
|
case '$between': {
|
|
837
|
-
(0, assert_1.
|
|
836
|
+
(0, assert_1.assert)(value1.$between instanceof Array);
|
|
838
837
|
const attr2 = (typeof value2 === 'object') && Object.keys(value2)[0];
|
|
839
838
|
const c = attr2 && (attr2 === '$between' && value2[attr2][0] <= value1.$between[0] && value2[attr2][1] >= value1.$between[1]
|
|
840
839
|
|| attr2 === '$gt' && value2[attr2] < value1.$between[0] || attr2 === '$gte' && value2[attr2] <= value1.$between[0]
|
|
@@ -862,7 +861,7 @@ function judgeValueRelation(value1, value2, contained) {
|
|
|
862
861
|
return false;
|
|
863
862
|
}
|
|
864
863
|
default: {
|
|
865
|
-
(0, assert_1.
|
|
864
|
+
(0, assert_1.assert)(false, `暂不支持的算子${attr}`);
|
|
866
865
|
}
|
|
867
866
|
}
|
|
868
867
|
}
|
|
@@ -958,7 +957,7 @@ function judgeFilterSingleAttrRelation(entity, schema, attr, filter, compared, c
|
|
|
958
957
|
orDeducedFilters.push(r);
|
|
959
958
|
}
|
|
960
959
|
else {
|
|
961
|
-
(0, assert_1.
|
|
960
|
+
(0, assert_1.assert)(attr2 === '$or');
|
|
962
961
|
andDeducedFilters.push(r);
|
|
963
962
|
}
|
|
964
963
|
}
|
|
@@ -988,7 +987,7 @@ function judgeFilterSingleAttrRelation(entity, schema, attr, filter, compared, c
|
|
|
988
987
|
break;
|
|
989
988
|
}
|
|
990
989
|
default: {
|
|
991
|
-
(0, assert_1.
|
|
990
|
+
(0, assert_1.assert)(false);
|
|
992
991
|
}
|
|
993
992
|
}
|
|
994
993
|
}
|
|
@@ -1136,7 +1135,7 @@ function analyzeFilterRelation(entity, schema, filter, compared, contained) {
|
|
|
1136
1135
|
}
|
|
1137
1136
|
}
|
|
1138
1137
|
else {
|
|
1139
|
-
(0, assert_1.
|
|
1138
|
+
(0, assert_1.assert)(!contained);
|
|
1140
1139
|
// 如果是相斥关系,只要和一个相斥就可以,有一个被证实就成功了
|
|
1141
1140
|
if (r === true) {
|
|
1142
1141
|
orDeducedFilters.splice(0, orDeducedFilters.length);
|
|
@@ -1179,7 +1178,7 @@ function analyzeFilterRelation(entity, schema, filter, compared, contained) {
|
|
|
1179
1178
|
}
|
|
1180
1179
|
}
|
|
1181
1180
|
else {
|
|
1182
|
-
(0, assert_1.
|
|
1181
|
+
(0, assert_1.assert)(!contained);
|
|
1183
1182
|
// 如果是相斥关系,必须和每一个都相斥
|
|
1184
1183
|
if (r === false) {
|
|
1185
1184
|
result = false;
|
|
@@ -1323,7 +1322,7 @@ function judgeFilterRelation(entity, schema, filter, compared, contained) {
|
|
|
1323
1322
|
totalAndDeducedFilters.push({
|
|
1324
1323
|
entity,
|
|
1325
1324
|
filter: combineFilters(entity, schema, [filter, {
|
|
1326
|
-
$not: (0,
|
|
1325
|
+
$not: (0, toolkit_1.pick)(compared, uncertainAttributes),
|
|
1327
1326
|
}]),
|
|
1328
1327
|
});
|
|
1329
1328
|
}
|
|
@@ -1339,7 +1338,7 @@ function judgeFilterRelation(entity, schema, filter, compared, contained) {
|
|
|
1339
1338
|
if (uncertainAttributes.length > 0) {
|
|
1340
1339
|
totalOrDeducedFilters.push({
|
|
1341
1340
|
entity,
|
|
1342
|
-
filter: combineFilters(entity, schema, [filter, (0,
|
|
1341
|
+
filter: combineFilters(entity, schema, [filter, (0, toolkit_1.pick)(compared, uncertainAttributes)]),
|
|
1343
1342
|
});
|
|
1344
1343
|
}
|
|
1345
1344
|
return {
|
|
@@ -1366,8 +1365,8 @@ function judgeFilterRelation(entity, schema, filter, compared, contained) {
|
|
|
1366
1365
|
* @returns
|
|
1367
1366
|
*/
|
|
1368
1367
|
function contains(entity, schema, filter, contained) {
|
|
1369
|
-
(0, assert_1.
|
|
1370
|
-
(0, assert_1.
|
|
1368
|
+
(0, assert_1.assert)(filter);
|
|
1369
|
+
(0, assert_1.assert)(contained);
|
|
1371
1370
|
return judgeFilterRelation(entity, schema, filter, contained, true);
|
|
1372
1371
|
// return false;
|
|
1373
1372
|
}
|
|
@@ -1386,8 +1385,8 @@ function contains(entity, schema, filter, contained) {
|
|
|
1386
1385
|
* @param conditionalFilter
|
|
1387
1386
|
*/
|
|
1388
1387
|
function repel(entity, schema, filter1, filter2) {
|
|
1389
|
-
(0, assert_1.
|
|
1390
|
-
(0, assert_1.
|
|
1388
|
+
(0, assert_1.assert)(filter1);
|
|
1389
|
+
(0, assert_1.assert)(filter2);
|
|
1391
1390
|
/**
|
|
1392
1391
|
* 现在的算法检查相斥有一种情况,若filter1被filter2相容,可以判断出来是false,但如果filter2被filter1相容则检查不出来
|
|
1393
1392
|
* filter1 = {
|
|
@@ -1422,7 +1421,7 @@ function getRelevantIds(filter) {
|
|
|
1422
1421
|
}
|
|
1423
1422
|
// 因为要准确判定id,如果有其它的过滤条件,可能会使实际处理的行数少于id指向的行数,只能返回空数组
|
|
1424
1423
|
const attrs = Object.keys(filter);
|
|
1425
|
-
if ((0,
|
|
1424
|
+
if ((0, toolkit_1.intersection)(attrs, ['id', '$and', '$or']).length > 3) {
|
|
1426
1425
|
return [];
|
|
1427
1426
|
}
|
|
1428
1427
|
if (filter?.$and) {
|
|
@@ -1431,7 +1430,7 @@ function getRelevantIds(filter) {
|
|
|
1431
1430
|
if (idss.find(ele => ele.length === 0)) {
|
|
1432
1431
|
return [];
|
|
1433
1432
|
}
|
|
1434
|
-
idsAnd = (0,
|
|
1433
|
+
idsAnd = (0, toolkit_1.intersection)(...idss);
|
|
1435
1434
|
}
|
|
1436
1435
|
if (filter?.$or) {
|
|
1437
1436
|
const idss = filter.$or.map((ele) => getRelevantIds(ele));
|
|
@@ -1439,7 +1438,7 @@ function getRelevantIds(filter) {
|
|
|
1439
1438
|
if (idss.find(ele => ele.length === 0)) {
|
|
1440
1439
|
return [];
|
|
1441
1440
|
}
|
|
1442
|
-
idsOr = (0,
|
|
1441
|
+
idsOr = (0, toolkit_1.union)(...idss);
|
|
1443
1442
|
}
|
|
1444
1443
|
if (filter?.id) {
|
|
1445
1444
|
if (typeof filter.id === 'string') {
|
|
@@ -1461,13 +1460,13 @@ function getRelevantIds(filter) {
|
|
|
1461
1460
|
}
|
|
1462
1461
|
let result = (ids || idsAnd || idsOr);
|
|
1463
1462
|
if (ids) {
|
|
1464
|
-
result = (0,
|
|
1463
|
+
result = (0, toolkit_1.intersection)(result, ids);
|
|
1465
1464
|
}
|
|
1466
1465
|
if (idsAnd) {
|
|
1467
|
-
result = (0,
|
|
1466
|
+
result = (0, toolkit_1.intersection)(result, idsAnd);
|
|
1468
1467
|
}
|
|
1469
1468
|
if (idsOr) {
|
|
1470
|
-
result = (0,
|
|
1469
|
+
result = (0, toolkit_1.intersection)(result, idsOr);
|
|
1471
1470
|
}
|
|
1472
1471
|
return result;
|
|
1473
1472
|
}
|
|
@@ -1494,7 +1493,7 @@ function same(entity, schema, filter1, filter2) {
|
|
|
1494
1493
|
* @param level
|
|
1495
1494
|
*/
|
|
1496
1495
|
function makeTreeAncestorFilter(entity, parentKey, filter, level = 1, includeAll, includeSelf) {
|
|
1497
|
-
(0, assert_1.
|
|
1496
|
+
(0, assert_1.assert)(level >= 0);
|
|
1498
1497
|
let idInFilters = [];
|
|
1499
1498
|
if (includeSelf) {
|
|
1500
1499
|
idInFilters.push(filter);
|
|
@@ -1534,8 +1533,8 @@ function makeTreeAncestorFilter(entity, parentKey, filter, level = 1, includeAll
|
|
|
1534
1533
|
* @param level
|
|
1535
1534
|
*/
|
|
1536
1535
|
function makeTreeDescendantFilter(entity, parentKey, filter, level = 1, includeAll, includeSelf) {
|
|
1537
|
-
(0, assert_1.
|
|
1538
|
-
(0, assert_1.
|
|
1536
|
+
(0, assert_1.assert)(level >= 0);
|
|
1537
|
+
(0, assert_1.assert)(parentKey.endsWith('Id'));
|
|
1539
1538
|
const parentKeyRef = parentKey.slice(0, parentKey.length - 2);
|
|
1540
1539
|
let idInFilters = [];
|
|
1541
1540
|
if (includeSelf) {
|
|
@@ -1562,7 +1561,7 @@ function makeTreeDescendantFilter(entity, parentKey, filter, level = 1, includeA
|
|
|
1562
1561
|
function checkDeduceFilters(dfc, context) {
|
|
1563
1562
|
const { $and, $or } = dfc;
|
|
1564
1563
|
if ($and) {
|
|
1565
|
-
(0, assert_1.
|
|
1564
|
+
(0, assert_1.assert)(!$or);
|
|
1566
1565
|
const andResult = $and.map((ele) => {
|
|
1567
1566
|
if (ele.hasOwnProperty('entity')) {
|
|
1568
1567
|
const ele2 = ele;
|
|
@@ -1591,7 +1590,7 @@ function checkDeduceFilters(dfc, context) {
|
|
|
1591
1590
|
}
|
|
1592
1591
|
return true;
|
|
1593
1592
|
}
|
|
1594
|
-
(0, assert_1.
|
|
1593
|
+
(0, assert_1.assert)($or);
|
|
1595
1594
|
const orResult = $or.map((ele) => {
|
|
1596
1595
|
if (ele.hasOwnProperty('entity')) {
|
|
1597
1596
|
const ele2 = ele;
|
|
@@ -1630,7 +1629,7 @@ function checkDeduceFilters(dfc, context) {
|
|
|
1630
1629
|
* @returns
|
|
1631
1630
|
*/
|
|
1632
1631
|
function checkFilterContains(entity, context, contained, filter, dataCompare, warningOnDataCompare) {
|
|
1633
|
-
(0, assert_1.
|
|
1632
|
+
(0, assert_1.assert)(filter, `对${entity}的访问必须有filter`);
|
|
1634
1633
|
const schema = context.getSchema();
|
|
1635
1634
|
const result = contains(entity, schema, filter, contained);
|
|
1636
1635
|
if (typeof result === 'boolean') {
|
|
@@ -1645,7 +1644,7 @@ function checkFilterContains(entity, context, contained, filter, dataCompare, wa
|
|
|
1645
1644
|
return false;
|
|
1646
1645
|
}
|
|
1647
1646
|
function checkFilterRepel(entity, context, filter1, filter2, dataCompare, warningOnDataCompare) {
|
|
1648
|
-
(0, assert_1.
|
|
1647
|
+
(0, assert_1.assert)(filter2);
|
|
1649
1648
|
const schema = context.getSchema();
|
|
1650
1649
|
const result = repel(entity, schema, filter2, filter1);
|
|
1651
1650
|
if (typeof result === 'boolean') {
|
|
@@ -1704,4 +1703,4 @@ function translateFilterToObjectPredicate(filter) {
|
|
|
1704
1703
|
if (filters.length > 0) {
|
|
1705
1704
|
return combineFilters(filters);
|
|
1706
1705
|
}
|
|
1707
|
-
} */
|
|
1706
|
+
} */
|
package/lib/store/modi.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EntityDict as BaseEntityDict } from
|
|
2
|
-
import { OpSchema as Modi } from
|
|
3
|
-
import { Operation, StorageSchema, RowChecker, EntityDict, OperateOption, Trigger } from
|
|
4
|
-
import { AsyncContext } from
|
|
5
|
-
import { SyncContext } from
|
|
1
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
2
|
+
import { OpSchema as Modi } from "../base-app-domain/Modi/Schema";
|
|
3
|
+
import { Operation, StorageSchema, RowChecker, EntityDict, OperateOption, Trigger } from "../types";
|
|
4
|
+
import { AsyncContext } from "./AsyncRowStore";
|
|
5
|
+
import { SyncContext } from "./SyncRowStore";
|
|
6
6
|
export declare function createOperationsFromModies(modies: Modi[]): Array<{
|
|
7
7
|
operation: Operation<string, Object, Object>;
|
|
8
8
|
entity: string;
|
package/lib/store/modi.js
CHANGED
|
@@ -5,12 +5,11 @@ exports.applyModis = applyModis;
|
|
|
5
5
|
exports.abandonModis = abandonModis;
|
|
6
6
|
exports.createModiRelatedCheckers = createModiRelatedCheckers;
|
|
7
7
|
exports.createModiRelatedTriggers = createModiRelatedTriggers;
|
|
8
|
-
const tslib_1 = require("tslib");
|
|
9
8
|
const types_1 = require("../types");
|
|
10
9
|
const action_1 = require("../actions/action");
|
|
11
|
-
const
|
|
10
|
+
const toolkit_1 = require("../utils/toolkit");
|
|
12
11
|
const uuid_1 = require("../utils/uuid");
|
|
13
|
-
const assert_1 =
|
|
12
|
+
const assert_1 = require("../utils/assert");
|
|
14
13
|
function createOperationsFromModies(modies) {
|
|
15
14
|
return modies.map((modi) => {
|
|
16
15
|
return {
|
|
@@ -73,7 +72,7 @@ function createModiRelatedCheckers(schema) {
|
|
|
73
72
|
if (!inModi || ['readOnly', 'appendOnly'].includes(actionType)) {
|
|
74
73
|
continue;
|
|
75
74
|
}
|
|
76
|
-
const restActions = (0,
|
|
75
|
+
const restActions = (0, toolkit_1.difference)(actions, action_1.appendOnlyActions);
|
|
77
76
|
if (!process.env.OAK_DISABLE_MODI_LOCK) {
|
|
78
77
|
checkers.push({
|
|
79
78
|
entity,
|
|
@@ -90,8 +89,8 @@ function createModiRelatedCheckers(schema) {
|
|
|
90
89
|
*/
|
|
91
90
|
if (option.modiParentEntity) {
|
|
92
91
|
const { modiParentEntity, modiParentId } = option;
|
|
93
|
-
(0, assert_1.
|
|
94
|
-
(0, assert_1.
|
|
92
|
+
(0, assert_1.assert)(modiParentEntity);
|
|
93
|
+
(0, assert_1.assert)(modiParentId);
|
|
95
94
|
return {
|
|
96
95
|
modiEntity$entity: {
|
|
97
96
|
'#sqp': 'not in',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Projection } from
|
|
1
|
+
import { Projection } from "../base-app-domain/Modi/Schema";
|
|
2
2
|
export declare const fullModi: Projection;
|
package/lib/store/relation.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.judgeRelation = judgeRelation;
|
|
4
|
-
const
|
|
5
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
4
|
+
const assert_1 = require("../utils/assert");
|
|
6
5
|
const Demand_1 = require("../types/Demand");
|
|
7
6
|
const Entity_1 = require("../types/Entity");
|
|
8
7
|
/**
|
|
@@ -65,7 +64,7 @@ function judgeRelation(schema, entity, attr, allowUnrecognized) {
|
|
|
65
64
|
if (attr.includes('$')) {
|
|
66
65
|
const firstDelimiter = attr.indexOf('$');
|
|
67
66
|
const entity2 = attr.slice(0, firstDelimiter);
|
|
68
|
-
(0, assert_1.
|
|
67
|
+
(0, assert_1.assert)(schema.hasOwnProperty(entity2), `schema中不存在名为[${entity2}]的实体,无法解析属性[${attr}]`);
|
|
69
68
|
const secondDelimiter = attr.indexOf('$', firstDelimiter + 1);
|
|
70
69
|
const foreignKey = attr.slice(firstDelimiter + 1, secondDelimiter > 0 ? secondDelimiter : attr.length);
|
|
71
70
|
const { [entity2]: { attributes: attributes2 } } = schema;
|
|
@@ -81,7 +80,7 @@ function judgeRelation(schema, entity, attr, allowUnrecognized) {
|
|
|
81
80
|
}
|
|
82
81
|
else {
|
|
83
82
|
// 这种情况应该不会跑到
|
|
84
|
-
(0, assert_1.
|
|
83
|
+
(0, assert_1.assert)(false, `实体 [${entity2}] 中不存在外键 [${foreignKey}Id] 或该外键未指向 [${String(entity)}],无法解析属性 [${attr}]`);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
else if ((attributes.hasOwnProperty(`${attr}Id`))) {
|
|
@@ -94,7 +93,7 @@ function judgeRelation(schema, entity, attr, allowUnrecognized) {
|
|
|
94
93
|
else if (attributes.hasOwnProperty('entity')
|
|
95
94
|
&& attributes.hasOwnProperty('entityId')
|
|
96
95
|
&& schema.hasOwnProperty(attr)) {
|
|
97
|
-
(0, assert_1.
|
|
96
|
+
(0, assert_1.assert)(attributes.entity.ref.includes(attr), `实体 [${String(entity)}] 的 动态反指为 [${attributes.entity.ref}],但不包含 [${attr}]`);
|
|
98
97
|
// 反向指针的外键
|
|
99
98
|
return 2;
|
|
100
99
|
}
|