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
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWechatMpFetch = createWechatMpFetch;
|
|
4
|
+
exports.ensureWechatMpFetch = ensureWechatMpFetch;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
/// <reference types="wechat-miniprogram" />
|
|
7
|
+
const shared_1 = require("./shared");
|
|
8
|
+
function normalizeFetchHeaders(headers) {
|
|
9
|
+
const result = {
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
};
|
|
12
|
+
if (!headers) {
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(headers)) {
|
|
16
|
+
headers.forEach(([key, value]) => {
|
|
17
|
+
result[key] = value;
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
if (typeof headers.forEach === 'function') {
|
|
22
|
+
headers.forEach((value, key) => {
|
|
23
|
+
result[key] = value;
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
Object.assign(result, headers);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function getHeader(headers, key) {
|
|
31
|
+
const matchedKey = Object.keys(headers).find((headerKey) => headerKey.toLowerCase() === key.toLowerCase());
|
|
32
|
+
return matchedKey ? headers[matchedKey] : undefined;
|
|
33
|
+
}
|
|
34
|
+
function updateResponseHeaders(target, headers) {
|
|
35
|
+
Object.keys(target).forEach((key) => {
|
|
36
|
+
if (key !== 'get') {
|
|
37
|
+
delete target[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.entries(headers || {}).forEach(([key, value]) => {
|
|
41
|
+
target[key] = Array.isArray(value) ? value.join(',') : value?.toString() || '';
|
|
42
|
+
});
|
|
43
|
+
return target;
|
|
44
|
+
}
|
|
45
|
+
function createResponseHeaders(headers) {
|
|
46
|
+
const responseHeaders = {
|
|
47
|
+
get(key) {
|
|
48
|
+
return getHeader(this, key);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return updateResponseHeaders(responseHeaders, headers);
|
|
52
|
+
}
|
|
53
|
+
function resolveRequestUrl(url) {
|
|
54
|
+
if (typeof url === 'string') {
|
|
55
|
+
return url;
|
|
56
|
+
}
|
|
57
|
+
if ('url' in url) {
|
|
58
|
+
return url.url;
|
|
59
|
+
}
|
|
60
|
+
return String(url);
|
|
61
|
+
}
|
|
62
|
+
function resolveRequestData(body) {
|
|
63
|
+
return body === undefined || body === null ? {} : body;
|
|
64
|
+
}
|
|
65
|
+
function createWechatMpChunkedBody() {
|
|
66
|
+
const chunks = [];
|
|
67
|
+
const pendingReads = [];
|
|
68
|
+
let closed = false;
|
|
69
|
+
let error;
|
|
70
|
+
let abortTransport;
|
|
71
|
+
const flush = () => {
|
|
72
|
+
while (pendingReads.length > 0) {
|
|
73
|
+
const pending = pendingReads.shift();
|
|
74
|
+
if (chunks.length > 0) {
|
|
75
|
+
pending.resolve({
|
|
76
|
+
value: chunks.shift(),
|
|
77
|
+
done: false,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (error) {
|
|
81
|
+
pending.reject(error);
|
|
82
|
+
}
|
|
83
|
+
else if (closed) {
|
|
84
|
+
pending.resolve({
|
|
85
|
+
value: undefined,
|
|
86
|
+
done: true,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
pendingReads.unshift(pending);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const body = {
|
|
96
|
+
getReader() {
|
|
97
|
+
return {
|
|
98
|
+
read() {
|
|
99
|
+
if (chunks.length > 0) {
|
|
100
|
+
return Promise.resolve({
|
|
101
|
+
value: chunks.shift(),
|
|
102
|
+
done: false,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (error) {
|
|
106
|
+
return Promise.reject(error);
|
|
107
|
+
}
|
|
108
|
+
if (closed) {
|
|
109
|
+
return Promise.resolve({
|
|
110
|
+
value: undefined,
|
|
111
|
+
done: true,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
pendingReads.push({ resolve, reject });
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
cancel() {
|
|
119
|
+
closed = true;
|
|
120
|
+
chunks.length = 0;
|
|
121
|
+
abortTransport?.();
|
|
122
|
+
flush();
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
},
|
|
125
|
+
releaseLock() { },
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
body,
|
|
131
|
+
enqueue(data) {
|
|
132
|
+
if (closed || error) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
chunks.push(new Uint8Array(data));
|
|
136
|
+
flush();
|
|
137
|
+
},
|
|
138
|
+
close() {
|
|
139
|
+
if (closed) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
closed = true;
|
|
143
|
+
flush();
|
|
144
|
+
},
|
|
145
|
+
fail(reason) {
|
|
146
|
+
if (closed || error) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
error = reason;
|
|
150
|
+
closed = true;
|
|
151
|
+
flush();
|
|
152
|
+
},
|
|
153
|
+
setAbort(callback) {
|
|
154
|
+
abortTransport = callback;
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function createWechatMpSSEFetchResponse(requestUrl, options, headers) {
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
const responseHeaders = createResponseHeaders();
|
|
161
|
+
const chunkedBody = createWechatMpChunkedBody();
|
|
162
|
+
let requestTask;
|
|
163
|
+
let resolved = false;
|
|
164
|
+
const resolveResponse = () => {
|
|
165
|
+
if (resolved) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
resolved = true;
|
|
169
|
+
const response = {
|
|
170
|
+
status: 200,
|
|
171
|
+
ok: true,
|
|
172
|
+
headers: responseHeaders,
|
|
173
|
+
body: chunkedBody.body,
|
|
174
|
+
arrayBuffer: async () => new ArrayBuffer(0),
|
|
175
|
+
json: async () => ({}),
|
|
176
|
+
text: async () => '',
|
|
177
|
+
clone: () => response,
|
|
178
|
+
url: requestUrl,
|
|
179
|
+
statusText: 'ok',
|
|
180
|
+
};
|
|
181
|
+
resolve(response);
|
|
182
|
+
};
|
|
183
|
+
const requestOption = {
|
|
184
|
+
url: requestUrl,
|
|
185
|
+
data: resolveRequestData(options.body),
|
|
186
|
+
method: (options.method || 'GET'),
|
|
187
|
+
header: headers,
|
|
188
|
+
dataType: '其他',
|
|
189
|
+
responseType: 'text',
|
|
190
|
+
enableChunked: true,
|
|
191
|
+
success: (res) => {
|
|
192
|
+
if (res.header) {
|
|
193
|
+
updateResponseHeaders(responseHeaders, res.header);
|
|
194
|
+
}
|
|
195
|
+
if (res.statusCode > 299) {
|
|
196
|
+
const error = new Error(`HTTP ${res.statusCode}`);
|
|
197
|
+
chunkedBody.fail(error);
|
|
198
|
+
if (!resolved) {
|
|
199
|
+
reject(error);
|
|
200
|
+
}
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
resolveResponse();
|
|
204
|
+
chunkedBody.close();
|
|
205
|
+
},
|
|
206
|
+
fail: (err) => {
|
|
207
|
+
chunkedBody.fail(err);
|
|
208
|
+
if (!resolved) {
|
|
209
|
+
reject(err);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
complete: () => {
|
|
213
|
+
chunkedBody.close();
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
requestTask = wx.request(requestOption);
|
|
217
|
+
chunkedBody.setAbort(() => requestTask?.abort());
|
|
218
|
+
if (!requestTask.onChunkReceived) {
|
|
219
|
+
requestTask.abort();
|
|
220
|
+
const error = new Error('wechatMp.RequestTask.onChunkReceived is not available');
|
|
221
|
+
reject(error);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
requestTask.onHeadersReceived((result) => {
|
|
225
|
+
updateResponseHeaders(responseHeaders, result.header);
|
|
226
|
+
resolveResponse();
|
|
227
|
+
});
|
|
228
|
+
requestTask.onChunkReceived((result) => {
|
|
229
|
+
chunkedBody.enqueue(result.data);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function createWechatMpFetch() {
|
|
234
|
+
return async (url, options) => {
|
|
235
|
+
const oakOptions = options;
|
|
236
|
+
const headers = normalizeFetchHeaders(options?.headers);
|
|
237
|
+
const accept = getHeader(headers, 'Accept');
|
|
238
|
+
const responseType = accept && [
|
|
239
|
+
'image/jpg',
|
|
240
|
+
'image/jpeg',
|
|
241
|
+
'image/png',
|
|
242
|
+
'application/octet-stream',
|
|
243
|
+
].includes(accept)
|
|
244
|
+
? 'arraybuffer'
|
|
245
|
+
: 'text';
|
|
246
|
+
const requestUrl = resolveRequestUrl(url);
|
|
247
|
+
if (oakOptions?.oakSSE) {
|
|
248
|
+
return createWechatMpSSEFetchResponse(requestUrl, oakOptions, headers);
|
|
249
|
+
}
|
|
250
|
+
return new Promise((resolve, reject) => {
|
|
251
|
+
wx.request({
|
|
252
|
+
url: requestUrl,
|
|
253
|
+
data: resolveRequestData(options?.body),
|
|
254
|
+
method: (options?.method || 'GET'),
|
|
255
|
+
header: headers,
|
|
256
|
+
dataType: '其他',
|
|
257
|
+
responseType,
|
|
258
|
+
success: (res) => {
|
|
259
|
+
const responseHeaders = createResponseHeaders(res.header);
|
|
260
|
+
const response = {
|
|
261
|
+
status: res.statusCode,
|
|
262
|
+
ok: res.statusCode >= 200 && res.statusCode < 300,
|
|
263
|
+
headers: responseHeaders,
|
|
264
|
+
arrayBuffer: async () => res.data,
|
|
265
|
+
json: async () => JSON.parse(res.data),
|
|
266
|
+
text: async () => res.data,
|
|
267
|
+
clone: () => response,
|
|
268
|
+
url: requestUrl,
|
|
269
|
+
statusText: res.statusCode >= 200 && res.statusCode < 300 ? 'ok' : 'error',
|
|
270
|
+
};
|
|
271
|
+
resolve(response);
|
|
272
|
+
},
|
|
273
|
+
fail: reject,
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function ensureWechatMpFetch() {
|
|
279
|
+
if (typeof globalThis.fetch === 'function') {
|
|
280
|
+
return (0, shared_1.getGlobalFetch)();
|
|
281
|
+
}
|
|
282
|
+
return (0, shared_1.installGlobalFetch)(createWechatMpFetch());
|
|
283
|
+
}
|
|
284
|
+
ensureWechatMpFetch();
|
|
285
|
+
tslib_1.__exportStar(require("./shared"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shared';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shared';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type OakFetchRequestInit = RequestInit & {
|
|
2
|
+
oakSSE?: true;
|
|
3
|
+
};
|
|
4
|
+
export declare function getGlobalFetch(): typeof fetch;
|
|
5
|
+
export declare function installGlobalFetch(fetchFn: typeof fetch): typeof fetch;
|
|
6
|
+
export declare function ensureGlobalFetch(fetchFn?: typeof fetch): typeof fetch;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalFetch = getGlobalFetch;
|
|
4
|
+
exports.installGlobalFetch = installGlobalFetch;
|
|
5
|
+
exports.ensureGlobalFetch = ensureGlobalFetch;
|
|
6
|
+
function getGlobalFetch() {
|
|
7
|
+
const fetchFn = globalThis.fetch;
|
|
8
|
+
if (typeof fetchFn !== 'function') {
|
|
9
|
+
throw new Error('oak-domain requires global fetch support. Use Node.js >= 18 or install a platform fetch polyfill.');
|
|
10
|
+
}
|
|
11
|
+
return fetchFn.bind(globalThis);
|
|
12
|
+
}
|
|
13
|
+
function installGlobalFetch(fetchFn) {
|
|
14
|
+
const normalizedFetch = fetchFn.bind(globalThis);
|
|
15
|
+
Object.assign(globalThis, {
|
|
16
|
+
fetch: normalizedFetch,
|
|
17
|
+
});
|
|
18
|
+
return normalizedFetch;
|
|
19
|
+
}
|
|
20
|
+
function ensureGlobalFetch(fetchFn) {
|
|
21
|
+
if (typeof globalThis.fetch === 'function') {
|
|
22
|
+
return getGlobalFetch();
|
|
23
|
+
}
|
|
24
|
+
if (fetchFn) {
|
|
25
|
+
return installGlobalFetch(fetchFn);
|
|
26
|
+
}
|
|
27
|
+
throw new Error('oak-domain requires global fetch support. Use Node.js >= 18 or install a platform fetch polyfill.');
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AsyncContext } from '../store/AsyncRowStore';
|
|
2
|
+
import { SyncContext } from '../store/SyncRowStore';
|
|
3
|
+
import { EntityDict, SelectOption } from '../types/Entity';
|
|
4
|
+
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
5
|
+
import { Language } from '../types/Locale';
|
|
6
|
+
import { StorageSchema } from '../types/Storage';
|
|
7
|
+
import { SelectionRewriteResult } from '../types/RowStore';
|
|
8
|
+
export declare const LOCALIZED_CONTENT_AUTO_INJECTED: unique symbol;
|
|
9
|
+
export declare function rewriteLocalizedContentSelection<ED extends EntityDict & BaseEntityDict>(schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection'] | ED[keyof ED]['Aggregation'], context: AsyncContext<ED> | SyncContext<ED>, option: SelectOption, isAggr?: true): SelectionRewriteResult<ED> | Promise<SelectionRewriteResult<ED>>;
|
|
10
|
+
export declare function makeTranslationDigest(value: string, sourceLanguage?: Language): string;
|
|
11
|
+
export declare function normalizeTranslationStringValue(value: unknown): string;
|