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/triggers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityDict as BaseEntityDict } from
|
|
2
|
-
import { EntityDict } from
|
|
3
|
-
import { Trigger } from
|
|
4
|
-
import { AsyncContext } from
|
|
1
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
2
|
+
import { EntityDict } from "../types/Entity";
|
|
3
|
+
import { Trigger } from "../types";
|
|
4
|
+
import { AsyncContext } from "./AsyncRowStore";
|
|
5
5
|
export declare const actionAuthTriggers: Trigger<EntityDict & BaseEntityDict, 'actionAuth', AsyncContext<EntityDict & BaseEntityDict>>[];
|
|
6
6
|
export declare const triggers: Trigger<EntityDict & BaseEntityDict, keyof (EntityDict & BaseEntityDict), AsyncContext<EntityDict & BaseEntityDict>>[];
|
package/lib/store/triggers.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.triggers = exports.actionAuthTriggers = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const types_1 = require("../types");
|
|
6
5
|
const uuid_1 = require("../utils/uuid");
|
|
7
|
-
const assert_1 =
|
|
6
|
+
const assert_1 = require("../utils/assert");
|
|
8
7
|
const filter_1 = require("./filter");
|
|
9
8
|
exports.actionAuthTriggers = [
|
|
10
9
|
{
|
|
@@ -36,7 +35,7 @@ async function undoLog(log, context) {
|
|
|
36
35
|
const { iState, oper$log } = log;
|
|
37
36
|
for (const oper of oper$log) {
|
|
38
37
|
const { action, targetEntity, filter, undoData, iState } = oper;
|
|
39
|
-
(0, assert_1.
|
|
38
|
+
(0, assert_1.assert)(iState === 'normal', '非正常状态的oper怎能回滚');
|
|
40
39
|
switch (action) {
|
|
41
40
|
case 'create': {
|
|
42
41
|
await context.operate(targetEntity, {
|
|
@@ -52,7 +51,7 @@ async function undoLog(log, context) {
|
|
|
52
51
|
}
|
|
53
52
|
case 'remove': {
|
|
54
53
|
const ids = (0, filter_1.getRelevantIds)(filter);
|
|
55
|
-
(0, assert_1.
|
|
54
|
+
(0, assert_1.assert)(ids.length > 0);
|
|
56
55
|
for (const id of ids) {
|
|
57
56
|
await context.operate(targetEntity, {
|
|
58
57
|
id: 'dummy',
|
|
@@ -68,7 +67,7 @@ async function undoLog(log, context) {
|
|
|
68
67
|
default: {
|
|
69
68
|
// 全按update处理
|
|
70
69
|
const ids = (0, filter_1.getRelevantIds)(filter);
|
|
71
|
-
(0, assert_1.
|
|
70
|
+
(0, assert_1.assert)(ids.length > 0);
|
|
72
71
|
for (const id of ids) {
|
|
73
72
|
await context.operate(targetEntity, {
|
|
74
73
|
id: 'dummy',
|
|
@@ -116,7 +115,7 @@ async function redoLog(log, context) {
|
|
|
116
115
|
const { oper$log } = log;
|
|
117
116
|
for (const oper of oper$log) {
|
|
118
117
|
const { action, targetEntity, filter, data, iState } = oper;
|
|
119
|
-
(0, assert_1.
|
|
118
|
+
(0, assert_1.assert)(iState === 'rollbacked', '非正常状态的oper怎能回滚');
|
|
120
119
|
switch (action) {
|
|
121
120
|
case 'create': {
|
|
122
121
|
await context.operate(targetEntity, {
|
|
@@ -184,9 +183,9 @@ exports.triggers = [
|
|
|
184
183
|
when: 'after',
|
|
185
184
|
fn: async ({ operation }, context) => {
|
|
186
185
|
const { filter } = operation;
|
|
187
|
-
(0, assert_1.
|
|
186
|
+
(0, assert_1.assert)(filter);
|
|
188
187
|
const ids = (0, filter_1.getRelevantIds)(filter);
|
|
189
|
-
(0, assert_1.
|
|
188
|
+
(0, assert_1.assert)(ids.length === 1);
|
|
190
189
|
const [log] = await context.select('log', {
|
|
191
190
|
data: {
|
|
192
191
|
id: 1,
|
|
@@ -245,7 +244,7 @@ exports.triggers = [
|
|
|
245
244
|
}
|
|
246
245
|
]
|
|
247
246
|
}, { dontCollect: true });
|
|
248
|
-
(0, assert_1.
|
|
247
|
+
(0, assert_1.assert)(logs.length > 0);
|
|
249
248
|
for (const log2 of logs) {
|
|
250
249
|
await undoLog(log2, context);
|
|
251
250
|
}
|
|
@@ -259,9 +258,9 @@ exports.triggers = [
|
|
|
259
258
|
when: 'after',
|
|
260
259
|
fn: async ({ operation }, context) => {
|
|
261
260
|
const { filter } = operation;
|
|
262
|
-
(0, assert_1.
|
|
261
|
+
(0, assert_1.assert)(filter);
|
|
263
262
|
const ids = (0, filter_1.getRelevantIds)(filter);
|
|
264
|
-
(0, assert_1.
|
|
263
|
+
(0, assert_1.assert)(ids.length === 1);
|
|
265
264
|
const [log] = await context.select('log', {
|
|
266
265
|
data: {
|
|
267
266
|
id: 1,
|
|
@@ -321,7 +320,7 @@ exports.triggers = [
|
|
|
321
320
|
}
|
|
322
321
|
]
|
|
323
322
|
}, { dontCollect: true, forUpdate: true });
|
|
324
|
-
(0, assert_1.
|
|
323
|
+
(0, assert_1.assert)(logs.length > 0);
|
|
325
324
|
for (const log2 of logs) {
|
|
326
325
|
await redoLog(log2, context);
|
|
327
326
|
}
|
|
@@ -335,7 +334,7 @@ exports.triggers = [
|
|
|
335
334
|
when: 'after',
|
|
336
335
|
fn: async ({ operation }, context, option) => {
|
|
337
336
|
const { data } = operation;
|
|
338
|
-
(0, assert_1.
|
|
337
|
+
(0, assert_1.assert)(!(data instanceof Array));
|
|
339
338
|
const { entity, entityId } = data;
|
|
340
339
|
const result = await context.operate('oper', {
|
|
341
340
|
id: 'dummy',
|
|
@@ -370,7 +369,7 @@ exports.triggers = [
|
|
|
370
369
|
when: 'before',
|
|
371
370
|
fn: async ({ operation }, context) => {
|
|
372
371
|
const { filter } = operation;
|
|
373
|
-
(0, assert_1.
|
|
372
|
+
(0, assert_1.assert)(filter);
|
|
374
373
|
// 查询这次删除操作涉及到的所有log
|
|
375
374
|
const result = await context.operate('oper', {
|
|
376
375
|
id: "dummy",
|
package/lib/timers/oper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityDict } from
|
|
2
|
-
import { EntityDict as BaseEntityDict } from
|
|
3
|
-
import { AsyncContext } from
|
|
1
|
+
import { EntityDict } from "../types/Entity";
|
|
2
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
3
|
+
import { AsyncContext } from "../store/AsyncRowStore";
|
|
4
4
|
export type VaccumOperOption<ED extends EntityDict & BaseEntityDict> = {
|
|
5
5
|
aliveLine: number;
|
|
6
6
|
excludeOpers?: {
|
package/lib/timers/vaccum.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityDict } from
|
|
2
|
-
import { EntityDict as BaseEntityDict } from
|
|
3
|
-
import { AsyncContext } from
|
|
1
|
+
import { EntityDict } from "../types/Entity";
|
|
2
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
3
|
+
import { AsyncContext } from "../store/AsyncRowStore";
|
|
4
4
|
type VaccumOptionEntity<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
|
5
5
|
entity: T;
|
|
6
6
|
filter?: ED[T]['Filter'];
|
package/lib/types/Action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CascadeRelationItem, EntityDict } from "./Entity";
|
|
2
|
-
import { GenericAction } from
|
|
2
|
+
import { GenericAction } from "../actions/action";
|
|
3
3
|
export type Action = string;
|
|
4
4
|
export type State = string;
|
|
5
5
|
export type ActionDef<A extends Action, S extends State> = {
|
package/lib/types/AppLoader.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingHttpHeaders } from "http";
|
|
2
2
|
import { AsyncContext, AsyncRowStore } from "../store/AsyncRowStore";
|
|
3
3
|
import { EntityDict, OpRecord } from "./Entity";
|
|
4
|
-
import { EntityDict as BaseEntityDict } from
|
|
4
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
5
5
|
export declare abstract class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> {
|
|
6
6
|
protected path: string;
|
|
7
7
|
constructor(path: string);
|
package/lib/types/Aspect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntityDict } from "./Entity";
|
|
2
|
-
import { EntityDict as BaseEntityDict } from
|
|
2
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
3
3
|
import { OpRecord } from "./Entity";
|
|
4
4
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
5
5
|
export interface Aspect<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> {
|
package/lib/types/Auth.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { CascadeActionAuth, CascadeRelationAuth, ActionOnRemove, SyncOrAsync, Oa
|
|
|
2
2
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
3
3
|
import { SyncContext } from "../store/SyncRowStore";
|
|
4
4
|
import { EntityDict, OperateOption, SelectOption } from "../types/Entity";
|
|
5
|
-
import { EntityDict as BaseEntityDict } from
|
|
6
|
-
import { ModiTurn } from
|
|
5
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
6
|
+
import { ModiTurn } from "./Trigger";
|
|
7
7
|
export type CheckerType = 'row' | 'data' | 'logical' | 'logicalData' | 'relation';
|
|
8
8
|
/**
|
|
9
9
|
* conditionalFilter是指该action发生时,operation所操作的行中有满足conditionalFilter的行
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AuthDeduceRelationMap, EntityDict } from
|
|
1
|
+
import { AuthDeduceRelationMap, EntityDict } from "./Entity";
|
|
2
2
|
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
3
|
-
import { AttrUpdateMatrix } from
|
|
4
|
-
import { ActionDefDict } from
|
|
5
|
-
import { StyleDict } from
|
|
3
|
+
import { AttrUpdateMatrix } from "./EntityDesc";
|
|
4
|
+
import { ActionDefDict } from "./Action";
|
|
5
|
+
import { StyleDict } from "./Style";
|
|
6
6
|
import type { IKoaBodyOptions } from 'koa-body';
|
|
7
|
-
import Koa from
|
|
8
|
-
import KoaRouter from
|
|
7
|
+
import Koa from "koa";
|
|
8
|
+
import KoaRouter from "koa-router";
|
|
9
9
|
/**
|
|
10
10
|
* redis连接信息,如果是Redis集群,可以配置多个
|
|
11
11
|
*/
|
|
@@ -53,6 +53,7 @@ export type ServerConfiguration = {
|
|
|
53
53
|
};
|
|
54
54
|
internalExceptionMask?: string;
|
|
55
55
|
koaBody?: IKoaBodyOptions;
|
|
56
|
+
socketScope?: string;
|
|
56
57
|
socket?: (ctx: Koa.ParameterizedContext<any, KoaRouter.IRouterParamContext<any, {}>, any>) => {
|
|
57
58
|
url: string;
|
|
58
59
|
} | undefined;
|
package/lib/types/Connector.d.ts
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
import { IncomingHttpHeaders } from "http";
|
|
2
2
|
import { SyncContext } from "../store/SyncRowStore";
|
|
3
3
|
import { EntityDict, OpRecord } from "./Entity";
|
|
4
|
-
import { EntityDict as BaseEntityDict } from
|
|
4
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
5
5
|
import { OakException } from "./Exception";
|
|
6
6
|
type Promisable<T> = T | Promise<T>;
|
|
7
|
+
export type EndpointRequestOptions<FrontCxt> = {
|
|
8
|
+
method?: 'get' | 'post' | 'put' | 'delete';
|
|
9
|
+
params?: Record<string, string | number | boolean | null | undefined>;
|
|
10
|
+
body?: any;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
context?: FrontCxt;
|
|
13
|
+
};
|
|
14
|
+
export type EndpointResponse<ED extends EntityDict & BaseEntityDict> = {
|
|
15
|
+
result: any;
|
|
16
|
+
opRecords?: OpRecord<ED>[];
|
|
17
|
+
message?: string | null;
|
|
18
|
+
status?: number;
|
|
19
|
+
headers?: Headers;
|
|
20
|
+
};
|
|
21
|
+
export type EndpointStreamResponse = {
|
|
22
|
+
result: ReadableStream<Uint8Array>;
|
|
23
|
+
message?: string | null;
|
|
24
|
+
status?: number;
|
|
25
|
+
headers?: Headers;
|
|
26
|
+
};
|
|
27
|
+
export type SSEEndpointRequestOptions<FrontCxt> = {
|
|
28
|
+
body?: any;
|
|
29
|
+
context?: FrontCxt;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
};
|
|
32
|
+
export type SSEEndpointEvent<T> = {
|
|
33
|
+
event: string;
|
|
34
|
+
data: T;
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
export type SSEEndpointClient<T> = {
|
|
38
|
+
onMessage: (callback: (data: T, event: SSEEndpointEvent<T>) => void) => () => void;
|
|
39
|
+
on: (eventName: string, callback: (data: T, event: SSEEndpointEvent<T>) => void) => () => void;
|
|
40
|
+
onError: (callback: (error: any) => void) => () => void;
|
|
41
|
+
onDone: (callback: () => void) => () => void;
|
|
42
|
+
close: () => void;
|
|
43
|
+
};
|
|
7
44
|
export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt extends SyncContext<ED>> {
|
|
8
45
|
callAspect: (name: string, params: any, context?: FrontCxt) => Promise<{
|
|
9
46
|
result: any;
|
|
@@ -32,10 +69,19 @@ export interface Connector<ED extends EntityDict & BaseEntityDict, FrontCxt exte
|
|
|
32
69
|
socketUrl: string;
|
|
33
70
|
subscribeUrl: string;
|
|
34
71
|
path: string;
|
|
72
|
+
scope?: string;
|
|
35
73
|
}>;
|
|
36
74
|
getBridgeRouter: () => string;
|
|
37
75
|
makeBridgeUrl: (url: string, headers?: Record<string, string>) => string;
|
|
38
76
|
getEndpointRouter: () => string;
|
|
77
|
+
makeEndpointUrl: (path: string) => string;
|
|
78
|
+
callEndpoint: (path: string, options?: EndpointRequestOptions<FrontCxt>) => Promise<EndpointResponse<ED>>;
|
|
79
|
+
openEndpointStream: (path: string, options?: EndpointRequestOptions<FrontCxt>) => Promise<EndpointStreamResponse>;
|
|
80
|
+
callSSEEndpoint: <T = any>(path: string, options?: SSEEndpointRequestOptions<FrontCxt>) => Promise<SSEEndpointClient<T>>;
|
|
81
|
+
serializeSSEEndpointResult?: (result: any, headers: IncomingHttpHeaders, body: any, message?: string) => Promise<{
|
|
82
|
+
body: any;
|
|
83
|
+
headers?: Record<string, any>;
|
|
84
|
+
}>;
|
|
39
85
|
parseBridgeRequestQuery: (urlParams: string) => {
|
|
40
86
|
url: string;
|
|
41
87
|
headers?: Record<string, string>;
|
package/lib/types/DataType.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type Int<L extends 1 | 2 | 4 | 8> = number;
|
|
|
3
3
|
export type Uint<L extends 1 | 2 | 4 | 8> = number;
|
|
4
4
|
export type Double<P extends number, S extends number> = number;
|
|
5
5
|
export type Float<P extends number, S extends number> = number;
|
|
6
|
-
export type Decimal<P extends number, S extends number> =
|
|
6
|
+
export type Decimal<P extends number, S extends number> = string;
|
|
7
7
|
export type String<L extends number> = string;
|
|
8
8
|
export type Text = string;
|
|
9
9
|
export type Image = string;
|
|
@@ -12,7 +12,7 @@ export type Datetime = number | Date;
|
|
|
12
12
|
export type Day = number | Date;
|
|
13
13
|
export type Time = number | Date;
|
|
14
14
|
export type Boolean = boolean;
|
|
15
|
-
export type Price =
|
|
15
|
+
export type Price = Decimal<32, 10>;
|
|
16
16
|
export type PrimaryKey = string;
|
|
17
17
|
export type ForeignKey<E extends string> = string;
|
|
18
18
|
export type Sequence = number;
|
package/lib/types/Demand.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RefOrExpression } from "./Expression";
|
|
2
|
+
import type { Geo, Point } from "./Geo";
|
|
2
3
|
import { OneOf } from "./Polyfill";
|
|
4
|
+
import { Language } from "./Locale";
|
|
3
5
|
export declare const EXPRESSION_PREFIX = "$expr";
|
|
4
6
|
export type NodeId = `node-${number}`;
|
|
5
7
|
export type ExpressionKey = '$expr' | '$expr1' | '$expr2' | '$expr3' | '$expr4' | '$expr5' | '$expr6' | '$expr7' | '$expr8' | '$expr9' | '$expr10' | '$expr11' | '$expr12' | '$expr13' | '$expr14' | '$expr15' | '$expr16' | '$expr17' | '$expr18' | '$expr19' | '$expr20';
|
|
@@ -18,6 +20,18 @@ export type Q_NumberComparisonValue = number | OneOf<{
|
|
|
18
20
|
$mod: [number, number];
|
|
19
21
|
$between: [number, number];
|
|
20
22
|
}>;
|
|
23
|
+
export type Q_DecimalComparisonValue = string | OneOf<{
|
|
24
|
+
$gt: string;
|
|
25
|
+
$lt: string;
|
|
26
|
+
$gte: string;
|
|
27
|
+
$lte: string;
|
|
28
|
+
$eq: string;
|
|
29
|
+
$ne: string;
|
|
30
|
+
$in: string[];
|
|
31
|
+
$nin: string[];
|
|
32
|
+
$mod: [string, string];
|
|
33
|
+
$between: [string, string];
|
|
34
|
+
}>;
|
|
21
35
|
export type Q_StringComparisonValue = string | OneOf<{
|
|
22
36
|
$gt: string;
|
|
23
37
|
$lt: string;
|
|
@@ -41,7 +55,15 @@ export type Q_EnumComparisonValue<E> = E | OneOf<{
|
|
|
41
55
|
export type Q_ExistsValue = {
|
|
42
56
|
$exists: boolean;
|
|
43
57
|
};
|
|
58
|
+
export type Q_GeoOperand = Geo | Point[];
|
|
59
|
+
export type Q_GeoValue = Q_ExistsValue | OneOf<{
|
|
60
|
+
$contains: Q_GeoOperand;
|
|
61
|
+
$within: Q_GeoOperand;
|
|
62
|
+
$intersects: Q_GeoOperand;
|
|
63
|
+
$distance: [Q_GeoOperand, Q_NumberComparisonValue];
|
|
64
|
+
}>;
|
|
44
65
|
export type Q_NumberValue = Q_NumberComparisonValue | Q_ExistsValue;
|
|
66
|
+
export type Q_DecimalValue = Q_DecimalComparisonValue | Q_ExistsValue;
|
|
45
67
|
export type Q_StringValue = Q_StringComparisonValue | Q_ExistsValue;
|
|
46
68
|
export type Q_BooleanValue = Q_BooleanComparisonValue | Q_ExistsValue;
|
|
47
69
|
export type Q_DateValue = Q_DateComparisonValue | Q_ExistsValue;
|
|
@@ -53,15 +75,15 @@ export type Q_State<S> = S | {
|
|
|
53
75
|
} | Q_ExistsValue;
|
|
54
76
|
export type Q_FullTextValue = {
|
|
55
77
|
$search: string;
|
|
56
|
-
$language?:
|
|
78
|
+
$language?: Language;
|
|
57
79
|
$ts?: string;
|
|
58
80
|
};
|
|
59
81
|
export type Q_FullTextKey = '$text';
|
|
60
82
|
export type FulltextFilter = {
|
|
61
83
|
[F in Q_FullTextKey]?: Q_FullTextValue;
|
|
62
84
|
};
|
|
63
|
-
type Q_LogicKey = '$and' | '$or';
|
|
64
|
-
type Q_LinearLogicKey = '$not';
|
|
85
|
+
export type Q_LogicKey = '$and' | '$or' | '$xor';
|
|
86
|
+
export type Q_LinearLogicKey = '$not';
|
|
65
87
|
export type MakeFilterWrapper<F extends Object> = {
|
|
66
88
|
[Q in Q_LogicKey]?: Array<MakeFilterWrapper<F>>;
|
|
67
89
|
} & {
|
|
@@ -77,12 +99,24 @@ export type RefAttr<A> = {
|
|
|
77
99
|
'#refAttr': string;
|
|
78
100
|
};
|
|
79
101
|
export declare function isRefAttrNode<A>(node: any): node is RefAttr<A>;
|
|
80
|
-
|
|
102
|
+
type JsonLogicKey = '$and' | '$or';
|
|
103
|
+
type JsonLogicFilter<O> = {
|
|
104
|
+
[Q in JsonLogicKey]?: Array<JsonFilter<O>>;
|
|
105
|
+
};
|
|
106
|
+
type JsonExistsFilter = {
|
|
107
|
+
$exists?: boolean;
|
|
108
|
+
};
|
|
109
|
+
type JsonArrayFilter<P> = JsonLogicFilter<P[]> & JsonExistsFilter & {
|
|
81
110
|
$contains?: P | P[];
|
|
82
111
|
$overlaps?: P | P[];
|
|
83
|
-
|
|
112
|
+
$length?: Q_NumberComparisonValue;
|
|
113
|
+
};
|
|
114
|
+
type JsonObjectFilter<O extends Record<string, any>> = JsonLogicFilter<O> & JsonExistsFilter & {
|
|
84
115
|
[A in keyof O]?: JsonFilter<O[A]>;
|
|
85
|
-
}
|
|
116
|
+
} & {
|
|
117
|
+
[A in Extract<keyof O, string> as `.${A}`]?: JsonFilter<O[A]>;
|
|
118
|
+
};
|
|
119
|
+
export type JsonFilter<O extends any> = O extends Array<infer P> ? (JsonFilter<P> | undefined)[] | JsonArrayFilter<P> : O extends number ? Q_NumberValue : O extends string ? Q_StringValue : O extends boolean ? Q_BooleanValue : O extends Record<string, any> ? JsonObjectFilter<O> : never;
|
|
86
120
|
export type SubQueryPredicateMetadata = {
|
|
87
121
|
'#sqp'?: 'in' | 'not in' | 'all' | 'not all';
|
|
88
122
|
};
|
package/lib/types/Endpoint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
2
2
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
3
3
|
import { EntityDict } from "./Entity";
|
|
4
|
-
import { EntityDict as BaseEntityDict } from
|
|
4
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
5
5
|
export type EndpointItem<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = SimpleEndpoint<ED, BackCxt> | FreeEndpoint<ED, BackCxt>;
|
|
6
6
|
export interface SimpleEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
|
7
7
|
name: string;
|
|
@@ -16,13 +16,29 @@ export interface SimpleEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt
|
|
|
16
16
|
* 返回时可以指定contentType
|
|
17
17
|
*/
|
|
18
18
|
export interface FreeEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
|
19
|
+
/** endpoint 名称,用于日志和重复定义判断;实际路由路径由 endpoints/index.ts 的导出 key 决定 */
|
|
19
20
|
name: string;
|
|
21
|
+
/** 路由路径参数名,会按声明顺序拼成 /:param 形式并注入到 fn 的 params 中 */
|
|
20
22
|
params?: string[];
|
|
23
|
+
/** HTTP 方法 */
|
|
21
24
|
method: 'get' | 'post' | 'put' | 'delete';
|
|
25
|
+
/** 标记该 endpoint 由业务代码完全控制上下文、响应体和响应头 */
|
|
22
26
|
type: "free";
|
|
27
|
+
/** 响应协议。配置为 sse 时,oak-cli 会按 text/event-stream 透传流式响应 */
|
|
28
|
+
protocol?: 'sse';
|
|
29
|
+
/** 是否复用 connector 的请求解析和响应序列化,例如 oak-cxt 还原、加解密和 SSE 包加密 */
|
|
30
|
+
useConnector?: true;
|
|
31
|
+
/**
|
|
32
|
+
* free endpoint 的执行函数。
|
|
33
|
+
* contextBuilder 用于按需创建一个已 begin/initialize 的后端 context,调用方负责 commit/rollback。
|
|
34
|
+
* params 来自路由参数,headers 是请求头,req 是原始 IncomingMessage,body 是解析后的请求体。
|
|
35
|
+
*/
|
|
23
36
|
fn: (contextBuilder: () => Promise<BackCxt>, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<{
|
|
37
|
+
/** 追加到 HTTP 响应上的 header;useConnector/protocol=sse 时会和 connector 生成的 header 合并 */
|
|
24
38
|
headers?: Record<string, string | string[]>;
|
|
39
|
+
/** 可选 HTTP 状态码 */
|
|
25
40
|
statusCode?: number;
|
|
41
|
+
/** 响应数据;普通 endpoint 可返回 JSON/Buffer/Stream,SSE endpoint 返回可读流 */
|
|
26
42
|
data: any;
|
|
27
43
|
}>;
|
|
28
44
|
}
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { OneOf } from
|
|
2
|
-
import { ReadOnlyAction } from
|
|
3
|
-
import { PrimaryKey, Sequence } from
|
|
1
|
+
import { OneOf } from ".";
|
|
2
|
+
import { ReadOnlyAction } from "../actions/action";
|
|
3
|
+
import { PrimaryKey, Sequence } from "./DataType";
|
|
4
|
+
import { RefOrExpression } from "./Expression";
|
|
5
|
+
import { Language } from "./Locale";
|
|
4
6
|
type TriggerDataAttributeType = '$$triggerData$$';
|
|
5
7
|
type TriggerUuidAttributeType = '$$triggerUuid$$';
|
|
6
8
|
type PrimaryKeyAttributeType = 'id';
|
|
@@ -29,6 +31,9 @@ export type SelectOption = {
|
|
|
29
31
|
includedDeleted?: true;
|
|
30
32
|
ignoreAttrMiss?: true;
|
|
31
33
|
dummy?: 1;
|
|
34
|
+
localizedContent?: true | {
|
|
35
|
+
sourceLanguage?: Language;
|
|
36
|
+
};
|
|
32
37
|
};
|
|
33
38
|
export type OperateOption = {
|
|
34
39
|
blockTrigger?: true;
|
|
@@ -43,8 +48,20 @@ export type OperateOption = {
|
|
|
43
48
|
applyingModi?: boolean;
|
|
44
49
|
dummy?: 1;
|
|
45
50
|
};
|
|
51
|
+
type UpdatableKeys<SH extends GeneralEntityShape> = Extract<keyof Omit<SH, "id" | "$$createAt$$" | "$$seq$$">, string>;
|
|
52
|
+
type UpdateSlotValue<SH extends GeneralEntityShape, K extends UpdatableKeys<SH>> = SH[K] | null;
|
|
53
|
+
export type UpdateExpressionValue<A extends string> = {
|
|
54
|
+
$expr: RefOrExpression<A>;
|
|
55
|
+
};
|
|
56
|
+
export declare function isUpdateExpressionValue<A extends string = string>(value: any): value is UpdateExpressionValue<A>;
|
|
57
|
+
export declare function isJsonLiteralAttributeType(type: string | undefined): boolean;
|
|
58
|
+
export declare function isExpressionUpdateAttributeType(type: string | undefined): boolean;
|
|
59
|
+
export declare function shouldTreatAsUpdateExpressionValue<A extends string = string>(attrType: string | undefined, value: any): value is UpdateExpressionValue<A>;
|
|
46
60
|
export type FormUpdateData<SH extends GeneralEntityShape> = Partial<{
|
|
47
|
-
[K in
|
|
61
|
+
[K in UpdatableKeys<SH>]: UpdateSlotValue<SH, K>;
|
|
62
|
+
}>;
|
|
63
|
+
export type DecimalUpdateData<SH extends GeneralEntityShape, DecimalKeys extends UpdatableKeys<SH>> = Omit<FormUpdateData<SH>, DecimalKeys> & Partial<{
|
|
64
|
+
[K in DecimalKeys]: UpdateSlotValue<SH, K> | UpdateExpressionValue<UpdatableKeys<SH>>;
|
|
48
65
|
}>;
|
|
49
66
|
export type FormCreateData<SH extends GeneralEntityShape> = Partial<SH> & {
|
|
50
67
|
id: string;
|
package/lib/types/Entity.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initinctiveAttributes = exports.SeqAttribute = exports.DeleteAtAttribute = exports.UpdateAtAttribute = exports.CreateAtAttribute = exports.PrimaryKeyAttribute = exports.TriggerUuidAttribute = exports.TriggerDataAttribute = void 0;
|
|
4
|
+
exports.isUpdateExpressionValue = isUpdateExpressionValue;
|
|
5
|
+
exports.isJsonLiteralAttributeType = isJsonLiteralAttributeType;
|
|
6
|
+
exports.isExpressionUpdateAttributeType = isExpressionUpdateAttributeType;
|
|
7
|
+
exports.shouldTreatAsUpdateExpressionValue = shouldTreatAsUpdateExpressionValue;
|
|
4
8
|
exports.TriggerDataAttribute = '$$triggerData$$';
|
|
5
9
|
exports.TriggerUuidAttribute = '$$triggerUuid$$';
|
|
6
10
|
exports.PrimaryKeyAttribute = 'id';
|
|
@@ -9,6 +13,29 @@ exports.UpdateAtAttribute = '$$updateAt$$';
|
|
|
9
13
|
exports.DeleteAtAttribute = '$$deleteAt$$';
|
|
10
14
|
exports.SeqAttribute = '$$seq$$';
|
|
11
15
|
exports.initinctiveAttributes = [exports.PrimaryKeyAttribute, exports.TriggerDataAttribute, exports.TriggerUuidAttribute, exports.CreateAtAttribute, exports.UpdateAtAttribute, exports.DeleteAtAttribute, exports.SeqAttribute];
|
|
16
|
+
const JsonLiteralAttributeTypes = new Set([
|
|
17
|
+
'object',
|
|
18
|
+
'array',
|
|
19
|
+
'json',
|
|
20
|
+
'jsonb',
|
|
21
|
+
'simple-json',
|
|
22
|
+
]);
|
|
23
|
+
function isUpdateExpressionValue(value) {
|
|
24
|
+
return !!value
|
|
25
|
+
&& typeof value === 'object'
|
|
26
|
+
&& !Array.isArray(value)
|
|
27
|
+
&& Object.keys(value).length === 1
|
|
28
|
+
&& Object.prototype.hasOwnProperty.call(value, '$expr');
|
|
29
|
+
}
|
|
30
|
+
function isJsonLiteralAttributeType(type) {
|
|
31
|
+
return !!type && JsonLiteralAttributeTypes.has(type);
|
|
32
|
+
}
|
|
33
|
+
function isExpressionUpdateAttributeType(type) {
|
|
34
|
+
return type === 'decimal';
|
|
35
|
+
}
|
|
36
|
+
function shouldTreatAsUpdateExpressionValue(attrType, value) {
|
|
37
|
+
return isExpressionUpdateAttributeType(attrType) && isUpdateExpressionValue(value);
|
|
38
|
+
}
|
|
12
39
|
;
|
|
13
40
|
;
|
|
14
41
|
;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { LocaleDef } from
|
|
2
|
-
import { Index } from
|
|
3
|
-
import { EntityShape, Configuration, EntityDict } from
|
|
4
|
-
import { EntityDict as BaseEntityDict } from
|
|
5
|
-
import { StyleDesc } from
|
|
6
|
-
import { AsyncContext } from
|
|
7
|
-
import { SyncContext } from
|
|
8
|
-
import { SyncOrAsync } from
|
|
1
|
+
import { LocaleDef } from "./Locale";
|
|
2
|
+
import { Index, LocalizedContentConfig } from "./Storage";
|
|
3
|
+
import { EntityShape, Configuration, EntityDict } from "./Entity";
|
|
4
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
5
|
+
import { StyleDesc } from "./Style";
|
|
6
|
+
import { AsyncContext } from "../store/AsyncRowStore";
|
|
7
|
+
import { SyncContext } from "../store/SyncRowStore";
|
|
8
|
+
import { SyncOrAsync } from "./Polyfill";
|
|
9
9
|
type EntityDescValueMap<V extends Record<string, string>> = keyof V extends '##oak_illegal##' ? {} : V;
|
|
10
10
|
type LocalSchemaAttrKeys<Schema extends EntityShape, BaseSchema extends EntityShape> = Exclude<keyof Required<Omit<Schema, keyof EntityShape>>, keyof Required<Omit<BaseSchema, keyof EntityShape>>>;
|
|
11
11
|
type StrictLocaleAttrDef<Schema extends EntityShape, BaseSchema extends EntityShape, V extends Record<string, string>> = {
|
|
@@ -28,6 +28,7 @@ export type EntityDesc<Schema extends EntityShape, Action extends string = '', R
|
|
|
28
28
|
indexes?: Index<Schema>[];
|
|
29
29
|
configuration?: Configuration;
|
|
30
30
|
recursiveDepth?: number;
|
|
31
|
+
localizedContent?: LocalizedContentConfig<Schema>;
|
|
31
32
|
} & (Action extends '' ? (keyof V extends '##oak_illegal##' ? {} : {
|
|
32
33
|
style: StyleDesc<Action, V>;
|
|
33
34
|
}) : {
|
|
@@ -84,10 +84,27 @@ export type NativeEnv = {
|
|
|
84
84
|
type: 'native';
|
|
85
85
|
};
|
|
86
86
|
export type Environment = WechatMpEnv | WebEnv | ServerEnv | NativeEnv;
|
|
87
|
+
export type ClientRuntime = 'browser' | 'tauri' | 'electron' | 'wechatMp' | 'native';
|
|
88
|
+
export type BriefClientEnvironment = {
|
|
89
|
+
runtime: ClientRuntime;
|
|
90
|
+
runtimeVersion?: string;
|
|
91
|
+
appVersion?: string;
|
|
92
|
+
os: {
|
|
93
|
+
name: string;
|
|
94
|
+
version?: string;
|
|
95
|
+
arch?: string;
|
|
96
|
+
};
|
|
97
|
+
device?: {
|
|
98
|
+
brand?: string;
|
|
99
|
+
model?: string;
|
|
100
|
+
cpu?: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
87
103
|
export type BriefEnv = {
|
|
88
104
|
system: string;
|
|
89
105
|
brand?: string;
|
|
90
106
|
model?: string;
|
|
91
107
|
wechat?: string;
|
|
92
108
|
explorer?: string;
|
|
109
|
+
client?: BriefClientEnvironment;
|
|
93
110
|
};
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageSchema } from ".";
|
|
2
2
|
import { EntityDict, OpRecord } from "./Entity";
|
|
3
|
-
import { EntityDict as BaseEntityDict } from
|
|
3
|
+
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
4
4
|
declare const OAK_EXCEPTION_SYMBOL: unique symbol;
|
|
5
5
|
/**
|
|
6
6
|
* 判断一个对象是否为 OakException 实例,作用和 `instanceof` 类似,但更安全可靠。
|
package/lib/types/Exception.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.OakApplicationHasToUpgrade = exports.OakSocketConnectException = exports
|
|
|
4
4
|
exports.isOakException = isOakException;
|
|
5
5
|
exports.makeException = makeException;
|
|
6
6
|
const relation_1 = require("../store/relation");
|
|
7
|
-
const
|
|
7
|
+
const toolkit_1 = require("../utils/toolkit");
|
|
8
8
|
const OAK_EXCEPTION_SYMBOL = Symbol.for('oak-domain:exception');
|
|
9
9
|
/**
|
|
10
10
|
* 判断一个对象是否为 OakException 实例,作用和 `instanceof` 类似,但更安全可靠。
|
|
@@ -109,7 +109,7 @@ class OakException extends Error {
|
|
|
109
109
|
(row[attr]).forEach((ele) => addInner(rel[0], ele));
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
addToRowDict(entity, (0,
|
|
112
|
+
addToRowDict(entity, (0, toolkit_1.pick)(row, ownAttrs));
|
|
113
113
|
};
|
|
114
114
|
for (const row of rows) {
|
|
115
115
|
addInner(entity, row);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RefAttr } from "./Demand";
|
|
2
2
|
import { Geo } from "./Geo";
|
|
3
3
|
export type RefOrExpression<A> = RefAttr<A> | Expression<A>;
|
|
4
|
-
type MathType<A> = RefOrExpression<A> | number;
|
|
4
|
+
type MathType<A> = RefOrExpression<A> | number | string;
|
|
5
5
|
type StringType<A> = RefOrExpression<A> | string;
|
|
6
6
|
interface Add<A> {
|
|
7
7
|
$add: (MathType<A>)[];
|
|
@@ -63,6 +63,17 @@ interface Includes<A> {
|
|
|
63
63
|
$includes: [RefOrExpression<A> | string, RefOrExpression<A> | string];
|
|
64
64
|
}
|
|
65
65
|
type CompareExpression<A> = Lt<A> | Gt<A> | Lte<A> | Gte<A> | Eq<A> | Ne<A> | StartsWith<A> | EndsWith<A> | Includes<A>;
|
|
66
|
+
type CaseValue<A> = RefOrExpression<A> | ExpressionConstant;
|
|
67
|
+
type CaseBranch<A> = {
|
|
68
|
+
when: RefOrExpression<A> | boolean;
|
|
69
|
+
then: CaseValue<A>;
|
|
70
|
+
};
|
|
71
|
+
interface Case<A> {
|
|
72
|
+
$case: {
|
|
73
|
+
branches: CaseBranch<A>[];
|
|
74
|
+
else: CaseValue<A>;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
66
77
|
interface BoolTrue<A> {
|
|
67
78
|
$true: Expression<A>;
|
|
68
79
|
}
|
|
@@ -141,7 +152,7 @@ interface AggrAvgExpression<A> {
|
|
|
141
152
|
$$avg: RefOrExpression<A>;
|
|
142
153
|
}
|
|
143
154
|
export type AggrExpression<A> = AggrAvgExpression<A> | AggrCountExpression<A> | AggrSumExpression<A> | AggrMaxExpression<A> | AggrMinExpression<A>;
|
|
144
|
-
export type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A> | StringExpression<A>;
|
|
155
|
+
export type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A> | StringExpression<A> | Case<A>;
|
|
145
156
|
export type ExpressionConstant = Geo | number | Date | string | boolean;
|
|
146
157
|
export declare function isGeoExpression<A>(expression: any): expression is GeoExpression<A>;
|
|
147
158
|
export declare function isDateExpression<A>(expression: any): expression is DateExpression<A>;
|