@ahoo-wang/wow-client 9.2.0-rc.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/LICENSE +201 -0
- package/README.md +291 -0
- package/README.zh-CN.md +267 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.es.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.es.js +6 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.es.js +8 -0
- package/dist/client/bindMethods.cjs +2 -0
- package/dist/client/bindMethods.cjs.map +1 -0
- package/dist/client/bindMethods.d.cts +13 -0
- package/dist/client/bindMethods.d.ts +13 -0
- package/dist/client/bindMethods.es.js +19 -0
- package/dist/client/bindMethods.es.js.map +1 -0
- package/dist/client/command/commandClient.cjs +2 -0
- package/dist/client/command/commandClient.cjs.map +1 -0
- package/dist/client/command/commandClient.d.cts +67 -0
- package/dist/client/command/commandClient.d.ts +67 -0
- package/dist/client/command/commandClient.es.js +38 -0
- package/dist/client/command/commandClient.es.js.map +1 -0
- package/dist/client/command/commandHeaders.cjs +2 -0
- package/dist/client/command/commandHeaders.cjs.map +1 -0
- package/dist/client/command/commandHeaders.d.cts +75 -0
- package/dist/client/command/commandHeaders.d.ts +75 -0
- package/dist/client/command/commandHeaders.es.js +31 -0
- package/dist/client/command/commandHeaders.es.js.map +1 -0
- package/dist/client/command/commandRequest.cjs +2 -0
- package/dist/client/command/commandRequest.cjs.map +1 -0
- package/dist/client/command/commandRequest.d.cts +180 -0
- package/dist/client/command/commandRequest.d.ts +180 -0
- package/dist/client/command/commandRequest.es.js +31 -0
- package/dist/client/command/commandRequest.es.js.map +1 -0
- package/dist/client/command/commandResult.d.cts +15 -0
- package/dist/client/command/commandResult.d.ts +15 -0
- package/dist/client/command/index.d.cts +5 -0
- package/dist/client/command/index.d.ts +5 -0
- package/dist/client/command/types.d.cts +71 -0
- package/dist/client/command/types.d.ts +71 -0
- package/dist/client/metadata/index.d.cts +2 -0
- package/dist/client/metadata/index.d.ts +2 -0
- package/dist/client/metadata/wowMetadata.d.cts +48 -0
- package/dist/client/metadata/wowMetadata.d.ts +48 -0
- package/dist/client/metadata/wowMetadataClient.cjs +2 -0
- package/dist/client/metadata/wowMetadataClient.cjs.map +1 -0
- package/dist/client/metadata/wowMetadataClient.d.cts +23 -0
- package/dist/client/metadata/wowMetadataClient.d.ts +23 -0
- package/dist/client/metadata/wowMetadataClient.es.js +25 -0
- package/dist/client/metadata/wowMetadataClient.es.js.map +1 -0
- package/dist/client/query/descriptor/descriptorEndpoints.cjs +2 -0
- package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +1 -0
- package/dist/client/query/descriptor/descriptorEndpoints.d.cts +29 -0
- package/dist/client/query/descriptor/descriptorEndpoints.d.ts +29 -0
- package/dist/client/query/descriptor/descriptorEndpoints.es.js +69 -0
- package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +1 -0
- package/dist/client/query/descriptor/endpointPaths.cjs +2 -0
- package/dist/client/query/descriptor/endpointPaths.cjs.map +1 -0
- package/dist/client/query/descriptor/endpointPaths.d.cts +4 -0
- package/dist/client/query/descriptor/endpointPaths.d.ts +4 -0
- package/dist/client/query/descriptor/endpointPaths.es.js +9 -0
- package/dist/client/query/descriptor/endpointPaths.es.js.map +1 -0
- package/dist/client/query/descriptor/index.d.cts +2 -0
- package/dist/client/query/descriptor/index.d.ts +2 -0
- package/dist/client/query/descriptor/queryDescriptorApi.d.cts +58 -0
- package/dist/client/query/descriptor/queryDescriptorApi.d.ts +58 -0
- package/dist/client/query/descriptor/queryDescriptorClient.cjs +2 -0
- package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +1 -0
- package/dist/client/query/descriptor/queryDescriptorClient.d.cts +61 -0
- package/dist/client/query/descriptor/queryDescriptorClient.d.ts +61 -0
- package/dist/client/query/descriptor/queryDescriptorClient.es.js +20 -0
- package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +1 -0
- package/dist/client/query/event/domainEventStream.cjs +2 -0
- package/dist/client/query/event/domainEventStream.cjs.map +1 -0
- package/dist/client/query/event/domainEventStream.d.cts +105 -0
- package/dist/client/query/event/domainEventStream.d.ts +105 -0
- package/dist/client/query/event/domainEventStream.es.js +23 -0
- package/dist/client/query/event/domainEventStream.es.js.map +1 -0
- package/dist/client/query/event/endpointPaths.cjs +2 -0
- package/dist/client/query/event/endpointPaths.cjs.map +1 -0
- package/dist/client/query/event/endpointPaths.d.cts +8 -0
- package/dist/client/query/event/endpointPaths.d.ts +8 -0
- package/dist/client/query/event/endpointPaths.es.js +13 -0
- package/dist/client/query/event/endpointPaths.es.js.map +1 -0
- package/dist/client/query/event/eventStreamQueryApi.d.cts +29 -0
- package/dist/client/query/event/eventStreamQueryApi.d.ts +29 -0
- package/dist/client/query/event/eventStreamQueryClient.cjs +2 -0
- package/dist/client/query/event/eventStreamQueryClient.cjs.map +1 -0
- package/dist/client/query/event/eventStreamQueryClient.d.cts +190 -0
- package/dist/client/query/event/eventStreamQueryClient.d.ts +190 -0
- package/dist/client/query/event/eventStreamQueryClient.es.js +160 -0
- package/dist/client/query/event/eventStreamQueryClient.es.js.map +1 -0
- package/dist/client/query/event/index.d.cts +3 -0
- package/dist/client/query/event/index.d.ts +3 -0
- package/dist/client/query/factory.cjs +2 -0
- package/dist/client/query/factory.cjs.map +1 -0
- package/dist/client/query/factory.d.cts +165 -0
- package/dist/client/query/factory.d.ts +165 -0
- package/dist/client/query/factory.es.js +45 -0
- package/dist/client/query/factory.es.js.map +1 -0
- package/dist/client/query/index.d.cts +6 -0
- package/dist/client/query/index.d.ts +6 -0
- package/dist/client/query/queryApi.d.cts +68 -0
- package/dist/client/query/queryApi.d.ts +68 -0
- package/dist/client/query/requests.d.cts +24 -0
- package/dist/client/query/requests.d.ts +24 -0
- package/dist/client/query/snapshot/endpointPaths.cjs +2 -0
- package/dist/client/query/snapshot/endpointPaths.cjs.map +1 -0
- package/dist/client/query/snapshot/endpointPaths.d.cts +12 -0
- package/dist/client/query/snapshot/endpointPaths.d.ts +12 -0
- package/dist/client/query/snapshot/endpointPaths.es.js +17 -0
- package/dist/client/query/snapshot/endpointPaths.es.js.map +1 -0
- package/dist/client/query/snapshot/index.d.cts +3 -0
- package/dist/client/query/snapshot/index.d.ts +3 -0
- package/dist/client/query/snapshot/snapshot.cjs +2 -0
- package/dist/client/query/snapshot/snapshot.cjs.map +1 -0
- package/dist/client/query/snapshot/snapshot.d.cts +51 -0
- package/dist/client/query/snapshot/snapshot.d.ts +51 -0
- package/dist/client/query/snapshot/snapshot.es.js +20 -0
- package/dist/client/query/snapshot/snapshot.es.js.map +1 -0
- package/dist/client/query/snapshot/snapshotQueryApi.d.cts +101 -0
- package/dist/client/query/snapshot/snapshotQueryApi.d.ts +101 -0
- package/dist/client/query/snapshot/snapshotQueryClient.cjs +2 -0
- package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +1 -0
- package/dist/client/query/snapshot/snapshotQueryClient.d.cts +369 -0
- package/dist/client/query/snapshot/snapshotQueryClient.d.ts +369 -0
- package/dist/client/query/snapshot/snapshotQueryClient.es.js +239 -0
- package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +1 -0
- package/dist/client/query/state/endpointPaths.cjs +2 -0
- package/dist/client/query/state/endpointPaths.cjs.map +1 -0
- package/dist/client/query/state/endpointPaths.d.cts +10 -0
- package/dist/client/query/state/endpointPaths.d.ts +10 -0
- package/dist/client/query/state/endpointPaths.es.js +14 -0
- package/dist/client/query/state/endpointPaths.es.js.map +1 -0
- package/dist/client/query/state/index.d.cts +4 -0
- package/dist/client/query/state/index.d.ts +4 -0
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +36 -0
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +36 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +2 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +1 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +58 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +58 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +56 -0
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +1 -0
- package/dist/client/query/state/loadStateAggregateApi.d.cts +37 -0
- package/dist/client/query/state/loadStateAggregateApi.d.ts +37 -0
- package/dist/client/query/state/loadStateAggregateClient.cjs +2 -0
- package/dist/client/query/state/loadStateAggregateClient.cjs.map +1 -0
- package/dist/client/query/state/loadStateAggregateClient.d.cts +62 -0
- package/dist/client/query/state/loadStateAggregateClient.d.ts +62 -0
- package/dist/client/query/state/loadStateAggregateClient.es.js +65 -0
- package/dist/client/query/state/loadStateAggregateClient.es.js.map +1 -0
- package/dist/client/routing.cjs +2 -0
- package/dist/client/routing.cjs.map +1 -0
- package/dist/client/routing.d.cts +47 -0
- package/dist/client/routing.d.ts +47 -0
- package/dist/client/routing.es.js +8 -0
- package/dist/client/routing.es.js.map +1 -0
- package/dist/dsl/aggregation/admit.cjs +2 -0
- package/dist/dsl/aggregation/admit.cjs.map +1 -0
- package/dist/dsl/aggregation/admit.d.cts +6 -0
- package/dist/dsl/aggregation/admit.d.ts +6 -0
- package/dist/dsl/aggregation/admit.es.js +142 -0
- package/dist/dsl/aggregation/admit.es.js.map +1 -0
- package/dist/dsl/aggregation/builders.cjs +2 -0
- package/dist/dsl/aggregation/builders.cjs.map +1 -0
- package/dist/dsl/aggregation/builders.d.cts +309 -0
- package/dist/dsl/aggregation/builders.d.ts +309 -0
- package/dist/dsl/aggregation/builders.es.js +188 -0
- package/dist/dsl/aggregation/builders.es.js.map +1 -0
- package/dist/dsl/aggregation/derived.cjs +2 -0
- package/dist/dsl/aggregation/derived.cjs.map +1 -0
- package/dist/dsl/aggregation/derived.d.cts +33 -0
- package/dist/dsl/aggregation/derived.d.ts +33 -0
- package/dist/dsl/aggregation/derived.es.js +31 -0
- package/dist/dsl/aggregation/derived.es.js.map +1 -0
- package/dist/dsl/aggregation/expressionTrees.cjs +2 -0
- package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -0
- package/dist/dsl/aggregation/expressionTrees.d.cts +10 -0
- package/dist/dsl/aggregation/expressionTrees.d.ts +10 -0
- package/dist/dsl/aggregation/expressionTrees.es.js +44 -0
- package/dist/dsl/aggregation/expressionTrees.es.js.map +1 -0
- package/dist/dsl/aggregation/having.cjs +2 -0
- package/dist/dsl/aggregation/having.cjs.map +1 -0
- package/dist/dsl/aggregation/having.d.cts +94 -0
- package/dist/dsl/aggregation/having.d.ts +94 -0
- package/dist/dsl/aggregation/having.es.js +62 -0
- package/dist/dsl/aggregation/having.es.js.map +1 -0
- package/dist/dsl/aggregation/index.d.cts +4 -0
- package/dist/dsl/aggregation/index.d.ts +4 -0
- package/dist/dsl/aggregation/sort.cjs +2 -0
- package/dist/dsl/aggregation/sort.cjs.map +1 -0
- package/dist/dsl/aggregation/sort.d.cts +7 -0
- package/dist/dsl/aggregation/sort.d.ts +7 -0
- package/dist/dsl/aggregation/sort.es.js +10 -0
- package/dist/dsl/aggregation/sort.es.js.map +1 -0
- package/dist/dsl/aggregation/types.cjs +2 -0
- package/dist/dsl/aggregation/types.cjs.map +1 -0
- package/dist/dsl/aggregation/types.d.cts +608 -0
- package/dist/dsl/aggregation/types.d.ts +608 -0
- package/dist/dsl/aggregation/types.es.js +37 -0
- package/dist/dsl/aggregation/types.es.js.map +1 -0
- package/dist/dsl/cursorQuery.cjs +2 -0
- package/dist/dsl/cursorQuery.cjs.map +1 -0
- package/dist/dsl/cursorQuery.d.cts +69 -0
- package/dist/dsl/cursorQuery.d.ts +69 -0
- package/dist/dsl/cursorQuery.es.js +19 -0
- package/dist/dsl/cursorQuery.es.js.map +1 -0
- package/dist/dsl/deletionState.cjs +2 -0
- package/dist/dsl/deletionState.cjs.map +1 -0
- package/dist/dsl/deletionState.d.cts +19 -0
- package/dist/dsl/deletionState.d.ts +19 -0
- package/dist/dsl/deletionState.es.js +8 -0
- package/dist/dsl/deletionState.es.js.map +1 -0
- package/dist/dsl/descriptor.cjs +2 -0
- package/dist/dsl/descriptor.cjs.map +1 -0
- package/dist/dsl/descriptor.d.cts +629 -0
- package/dist/dsl/descriptor.d.ts +629 -0
- package/dist/dsl/descriptor.es.js +37 -0
- package/dist/dsl/descriptor.es.js.map +1 -0
- package/dist/dsl/documents.d.cts +8 -0
- package/dist/dsl/documents.d.ts +8 -0
- package/dist/dsl/field.cjs +2 -0
- package/dist/dsl/field.cjs.map +1 -0
- package/dist/dsl/field.d.cts +2 -0
- package/dist/dsl/field.d.ts +2 -0
- package/dist/dsl/field.es.js +10 -0
- package/dist/dsl/field.es.js.map +1 -0
- package/dist/dsl/filter/builders.cjs +2 -0
- package/dist/dsl/filter/builders.cjs.map +1 -0
- package/dist/dsl/filter/builders.d.cts +962 -0
- package/dist/dsl/filter/builders.d.ts +962 -0
- package/dist/dsl/filter/builders.es.js +289 -0
- package/dist/dsl/filter/builders.es.js.map +1 -0
- package/dist/dsl/filter/datePattern.cjs +2 -0
- package/dist/dsl/filter/datePattern.cjs.map +1 -0
- package/dist/dsl/filter/datePattern.d.cts +8 -0
- package/dist/dsl/filter/datePattern.d.ts +8 -0
- package/dist/dsl/filter/datePattern.es.js +100 -0
- package/dist/dsl/filter/datePattern.es.js.map +1 -0
- package/dist/dsl/filter/index.d.cts +3 -0
- package/dist/dsl/filter/index.d.ts +3 -0
- package/dist/dsl/filter/operator.cjs +2 -0
- package/dist/dsl/filter/operator.cjs.map +1 -0
- package/dist/dsl/filter/operator.d.cts +113 -0
- package/dist/dsl/filter/operator.d.ts +113 -0
- package/dist/dsl/filter/operator.es.js +14 -0
- package/dist/dsl/filter/operator.es.js.map +1 -0
- package/dist/dsl/filter/scope.cjs +2 -0
- package/dist/dsl/filter/scope.cjs.map +1 -0
- package/dist/dsl/filter/scope.d.cts +15 -0
- package/dist/dsl/filter/scope.d.ts +15 -0
- package/dist/dsl/filter/scope.es.js +32 -0
- package/dist/dsl/filter/scope.es.js.map +1 -0
- package/dist/dsl/filter/types.d.cts +274 -0
- package/dist/dsl/filter/types.d.ts +274 -0
- package/dist/dsl/filter/validate.cjs +2 -0
- package/dist/dsl/filter/validate.cjs.map +1 -0
- package/dist/dsl/filter/validate.d.cts +18 -0
- package/dist/dsl/filter/validate.d.ts +18 -0
- package/dist/dsl/filter/validate.es.js +56 -0
- package/dist/dsl/filter/validate.es.js.map +1 -0
- package/dist/dsl/pagination.cjs +2 -0
- package/dist/dsl/pagination.cjs.map +1 -0
- package/dist/dsl/pagination.d.cts +28 -0
- package/dist/dsl/pagination.d.ts +28 -0
- package/dist/dsl/pagination.es.js +15 -0
- package/dist/dsl/pagination.es.js.map +1 -0
- package/dist/dsl/projection.cjs +2 -0
- package/dist/dsl/projection.cjs.map +1 -0
- package/dist/dsl/projection.d.cts +27 -0
- package/dist/dsl/projection.d.ts +27 -0
- package/dist/dsl/projection.es.js +12 -0
- package/dist/dsl/projection.es.js.map +1 -0
- package/dist/dsl/queryable.cjs +2 -0
- package/dist/dsl/queryable.cjs.map +1 -0
- package/dist/dsl/queryable.d.cts +101 -0
- package/dist/dsl/queryable.d.ts +101 -0
- package/dist/dsl/queryable.es.js +40 -0
- package/dist/dsl/queryable.es.js.map +1 -0
- package/dist/dsl/sort.cjs +2 -0
- package/dist/dsl/sort.cjs.map +1 -0
- package/dist/dsl/sort.d.cts +33 -0
- package/dist/dsl/sort.d.ts +33 -0
- package/dist/dsl/sort.es.js +21 -0
- package/dist/dsl/sort.es.js.map +1 -0
- package/dist/dsl.cjs +1 -0
- package/dist/dsl.d.cts +23 -0
- package/dist/dsl.d.ts +23 -0
- package/dist/dsl.es.js +14 -0
- package/dist/error/errorInfo.cjs +2 -0
- package/dist/error/errorInfo.cjs.map +1 -0
- package/dist/error/errorInfo.d.cts +139 -0
- package/dist/error/errorInfo.d.ts +139 -0
- package/dist/error/errorInfo.es.js +32 -0
- package/dist/error/errorInfo.es.js.map +1 -0
- package/dist/error/headers.cjs +2 -0
- package/dist/error/headers.cjs.map +1 -0
- package/dist/error/headers.d.cts +38 -0
- package/dist/error/headers.d.ts +38 -0
- package/dist/error/headers.es.js +10 -0
- package/dist/error/headers.es.js.map +1 -0
- package/dist/error/index.d.cts +21 -0
- package/dist/error/index.d.ts +21 -0
- package/dist/error/queryErrorCodes.cjs +2 -0
- package/dist/error/queryErrorCodes.cjs.map +1 -0
- package/dist/error/queryErrorCodes.d.cts +199 -0
- package/dist/error/queryErrorCodes.d.ts +199 -0
- package/dist/error/queryErrorCodes.es.js +53 -0
- package/dist/error/queryErrorCodes.es.js.map +1 -0
- package/dist/error/wowError.cjs +2 -0
- package/dist/error/wowError.cjs.map +1 -0
- package/dist/error/wowError.d.cts +99 -0
- package/dist/error/wowError.d.ts +99 -0
- package/dist/error/wowError.es.js +53 -0
- package/dist/error/wowError.es.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.es.js +34 -0
- package/dist/legacy/condition.cjs +2 -0
- package/dist/legacy/condition.cjs.map +1 -0
- package/dist/legacy/condition.d.cts +517 -0
- package/dist/legacy/condition.d.ts +517 -0
- package/dist/legacy/condition.es.js +338 -0
- package/dist/legacy/condition.es.js.map +1 -0
- package/dist/legacy/index.d.cts +16 -0
- package/dist/legacy/index.d.ts +16 -0
- package/dist/legacy/locale/en_US.cjs +2 -0
- package/dist/legacy/locale/en_US.cjs.map +1 -0
- package/dist/legacy/locale/en_US.d.cts +7 -0
- package/dist/legacy/locale/en_US.d.ts +7 -0
- package/dist/legacy/locale/en_US.es.js +50 -0
- package/dist/legacy/locale/en_US.es.js.map +1 -0
- package/dist/legacy/locale/operatorLocale.d.cts +10 -0
- package/dist/legacy/locale/operatorLocale.d.ts +10 -0
- package/dist/legacy/locale/zh_CN.cjs +2 -0
- package/dist/legacy/locale/zh_CN.cjs.map +1 -0
- package/dist/legacy/locale/zh_CN.d.cts +7 -0
- package/dist/legacy/locale/zh_CN.d.ts +7 -0
- package/dist/legacy/locale/zh_CN.es.js +50 -0
- package/dist/legacy/locale/zh_CN.es.js.map +1 -0
- package/dist/legacy/operator.cjs +2 -0
- package/dist/legacy/operator.cjs.map +1 -0
- package/dist/legacy/operator.d.cts +218 -0
- package/dist/legacy/operator.d.ts +218 -0
- package/dist/legacy/operator.es.js +25 -0
- package/dist/legacy/operator.es.js.map +1 -0
- package/dist/legacy/queryable.cjs +2 -0
- package/dist/legacy/queryable.cjs.map +1 -0
- package/dist/legacy/queryable.d.cts +61 -0
- package/dist/legacy/queryable.d.ts +61 -0
- package/dist/legacy/queryable.es.js +34 -0
- package/dist/legacy/queryable.es.js.map +1 -0
- package/dist/legacy.cjs +1 -0
- package/dist/legacy.es.js +6 -0
- package/dist/model/abac.cjs +2 -0
- package/dist/model/abac.cjs.map +1 -0
- package/dist/model/abac.d.cts +33 -0
- package/dist/model/abac.d.ts +33 -0
- package/dist/model/abac.es.js +6 -0
- package/dist/model/abac.es.js.map +1 -0
- package/dist/model/bi.cjs +2 -0
- package/dist/model/bi.cjs.map +1 -0
- package/dist/model/bi.d.cts +12 -0
- package/dist/model/bi.d.ts +12 -0
- package/dist/model/bi.es.js +8 -0
- package/dist/model/bi.es.js.map +1 -0
- package/dist/model/command.cjs +2 -0
- package/dist/model/command.cjs.map +1 -0
- package/dist/model/command.d.cts +137 -0
- package/dist/model/command.d.ts +137 -0
- package/dist/model/command.es.js +8 -0
- package/dist/model/command.es.js.map +1 -0
- package/dist/model/common.d.cts +19 -0
- package/dist/model/common.d.ts +19 -0
- package/dist/model/function.cjs +2 -0
- package/dist/model/function.cjs.map +1 -0
- package/dist/model/function.d.cts +41 -0
- package/dist/model/function.d.ts +41 -0
- package/dist/model/function.es.js +8 -0
- package/dist/model/function.es.js.map +1 -0
- package/dist/model/index.d.cts +22 -0
- package/dist/model/index.d.ts +22 -0
- package/dist/model/messaging.d.cts +5 -0
- package/dist/model/messaging.d.ts +5 -0
- package/dist/model/modeling.d.cts +145 -0
- package/dist/model/modeling.d.ts +145 -0
- package/dist/model/naming.d.cts +27 -0
- package/dist/model/naming.d.ts +27 -0
- package/dist/transport/endpoints.cjs +2 -0
- package/dist/transport/endpoints.cjs.map +1 -0
- package/dist/transport/endpoints.d.cts +79 -0
- package/dist/transport/endpoints.d.ts +79 -0
- package/dist/transport/endpoints.es.js +14 -0
- package/dist/transport/endpoints.es.js.map +1 -0
- package/dist/transport/eventStreams.cjs +2 -0
- package/dist/transport/eventStreams.cjs.map +1 -0
- package/dist/transport/eventStreams.d.cts +23 -0
- package/dist/transport/eventStreams.d.ts +23 -0
- package/dist/transport/eventStreams.es.js +22 -0
- package/dist/transport/eventStreams.es.js.map +1 -0
- package/dist/transport/index.d.cts +1 -0
- package/dist/transport/index.d.ts +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Header Constants
|
|
3
|
+
*
|
|
4
|
+
* The HTTP headers a Wow command route reads. Each value is a string literal
|
|
5
|
+
* type, so `CommandRequestHeaders` can type the value of every header by its
|
|
6
|
+
* name. {@link commandHeaders} and {@link waitStrategy} build them from typed
|
|
7
|
+
* options.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `CommandComponent.Header` in
|
|
10
|
+
* `wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/aggregate/command/CommandComponent.kt`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const headers: CommandRequestHeaders = {
|
|
15
|
+
* [CommandHeaders.TENANT_ID]: 'tenant-123',
|
|
16
|
+
* [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const CommandHeaders: Readonly<{
|
|
21
|
+
/** Prefix of the command headers */
|
|
22
|
+
readonly COMMAND_HEADERS_PREFIX: "Command-";
|
|
23
|
+
/** Tenant of the command, when the route has no tenant path segment */
|
|
24
|
+
readonly TENANT_ID: "Command-Tenant-Id";
|
|
25
|
+
/** Owner of the command, when the route has no owner path segment */
|
|
26
|
+
readonly OWNER_ID: "Command-Owner-Id";
|
|
27
|
+
/**
|
|
28
|
+
* Space identifier header, `Wow-Space-Id`
|
|
29
|
+
* Used to send the command into a space. The server reads it only for an
|
|
30
|
+
* aggregate declared `@AggregateRoute(spaced = true)`; any other aggregate
|
|
31
|
+
* ignores it and keeps the default space.
|
|
32
|
+
*
|
|
33
|
+
* The server shares this header with queries, so it has the `Wow-` prefix
|
|
34
|
+
* rather than `Command-`; it is the same value as {@link WowHeaders.SPACE_ID}.
|
|
35
|
+
*/
|
|
36
|
+
readonly SPACE_ID: "Wow-Space-Id";
|
|
37
|
+
/** Aggregate the command targets, when the route has no id path segment */
|
|
38
|
+
readonly AGGREGATE_ID: "Command-Aggregate-Id";
|
|
39
|
+
/** The aggregate version the command expects; a mismatch is a conflict */
|
|
40
|
+
readonly AGGREGATE_VERSION: "Command-Aggregate-Version";
|
|
41
|
+
/** Prefix of the wait headers */
|
|
42
|
+
readonly WAIT_PREFIX: "Command-Wait-";
|
|
43
|
+
/** How long the server waits for the wait stage, in milliseconds */
|
|
44
|
+
readonly WAIT_TIME_OUT: "Command-Wait-Timeout";
|
|
45
|
+
/** The stage to wait for; the server waits for `PROCESSED` when absent */
|
|
46
|
+
readonly WAIT_STAGE: "Command-Wait-Stage";
|
|
47
|
+
/** The bounded context whose processing the wait stage refers to */
|
|
48
|
+
readonly WAIT_CONTEXT: "Command-Wait-Context";
|
|
49
|
+
/** The processor whose processing the wait stage refers to */
|
|
50
|
+
readonly WAIT_PROCESSOR: "Command-Wait-Processor";
|
|
51
|
+
/** The function whose processing the wait stage refers to */
|
|
52
|
+
readonly WAIT_FUNCTION: "Command-Wait-Function";
|
|
53
|
+
/** Prefix of the wait-chain tail headers */
|
|
54
|
+
readonly WAIT_TAIL_PREFIX: "Command-Wait-Tail-";
|
|
55
|
+
/** The stage the command a saga sends must reach; only with `SAGA_HANDLED` */
|
|
56
|
+
readonly WAIT_TAIL_STAGE: "Command-Wait-Tail-Stage";
|
|
57
|
+
/** The bounded context of the wait-chain tail */
|
|
58
|
+
readonly WAIT_TAIL_CONTEXT: "Command-Wait-Tail-Context";
|
|
59
|
+
/** The processor of the wait-chain tail */
|
|
60
|
+
readonly WAIT_TAIL_PROCESSOR: "Command-Wait-Tail-Processor";
|
|
61
|
+
/** The function of the wait-chain tail */
|
|
62
|
+
readonly WAIT_TAIL_FUNCTION: "Command-Wait-Tail-Function";
|
|
63
|
+
/** Idempotency key of the command; a repeated one is refused */
|
|
64
|
+
readonly REQUEST_ID: "Command-Request-Id";
|
|
65
|
+
/** Whether the server may process the command locally, `true` or `false` */
|
|
66
|
+
readonly LOCAL_FIRST: "Command-Local-First";
|
|
67
|
+
/** Bounded context of the aggregate, for the `/wow/command/send` route */
|
|
68
|
+
readonly COMMAND_AGGREGATE_CONTEXT: "Command-Aggregate-Context";
|
|
69
|
+
/** Name of the aggregate, for the `/wow/command/send` route */
|
|
70
|
+
readonly COMMAND_AGGREGATE_NAME: "Command-Aggregate-Name";
|
|
71
|
+
/** Fully qualified command type, for the `/wow/command/send` route */
|
|
72
|
+
readonly COMMAND_TYPE: "Command-Type";
|
|
73
|
+
/** Prefix of the custom headers the server copies into the command header */
|
|
74
|
+
readonly COMMAND_HEADER_X_PREFIX: "Command-Header-";
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Header Constants
|
|
3
|
+
*
|
|
4
|
+
* The HTTP headers a Wow command route reads. Each value is a string literal
|
|
5
|
+
* type, so `CommandRequestHeaders` can type the value of every header by its
|
|
6
|
+
* name. {@link commandHeaders} and {@link waitStrategy} build them from typed
|
|
7
|
+
* options.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `CommandComponent.Header` in
|
|
10
|
+
* `wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/aggregate/command/CommandComponent.kt`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const headers: CommandRequestHeaders = {
|
|
15
|
+
* [CommandHeaders.TENANT_ID]: 'tenant-123',
|
|
16
|
+
* [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const CommandHeaders: Readonly<{
|
|
21
|
+
/** Prefix of the command headers */
|
|
22
|
+
readonly COMMAND_HEADERS_PREFIX: "Command-";
|
|
23
|
+
/** Tenant of the command, when the route has no tenant path segment */
|
|
24
|
+
readonly TENANT_ID: "Command-Tenant-Id";
|
|
25
|
+
/** Owner of the command, when the route has no owner path segment */
|
|
26
|
+
readonly OWNER_ID: "Command-Owner-Id";
|
|
27
|
+
/**
|
|
28
|
+
* Space identifier header, `Wow-Space-Id`
|
|
29
|
+
* Used to send the command into a space. The server reads it only for an
|
|
30
|
+
* aggregate declared `@AggregateRoute(spaced = true)`; any other aggregate
|
|
31
|
+
* ignores it and keeps the default space.
|
|
32
|
+
*
|
|
33
|
+
* The server shares this header with queries, so it has the `Wow-` prefix
|
|
34
|
+
* rather than `Command-`; it is the same value as {@link WowHeaders.SPACE_ID}.
|
|
35
|
+
*/
|
|
36
|
+
readonly SPACE_ID: "Wow-Space-Id";
|
|
37
|
+
/** Aggregate the command targets, when the route has no id path segment */
|
|
38
|
+
readonly AGGREGATE_ID: "Command-Aggregate-Id";
|
|
39
|
+
/** The aggregate version the command expects; a mismatch is a conflict */
|
|
40
|
+
readonly AGGREGATE_VERSION: "Command-Aggregate-Version";
|
|
41
|
+
/** Prefix of the wait headers */
|
|
42
|
+
readonly WAIT_PREFIX: "Command-Wait-";
|
|
43
|
+
/** How long the server waits for the wait stage, in milliseconds */
|
|
44
|
+
readonly WAIT_TIME_OUT: "Command-Wait-Timeout";
|
|
45
|
+
/** The stage to wait for; the server waits for `PROCESSED` when absent */
|
|
46
|
+
readonly WAIT_STAGE: "Command-Wait-Stage";
|
|
47
|
+
/** The bounded context whose processing the wait stage refers to */
|
|
48
|
+
readonly WAIT_CONTEXT: "Command-Wait-Context";
|
|
49
|
+
/** The processor whose processing the wait stage refers to */
|
|
50
|
+
readonly WAIT_PROCESSOR: "Command-Wait-Processor";
|
|
51
|
+
/** The function whose processing the wait stage refers to */
|
|
52
|
+
readonly WAIT_FUNCTION: "Command-Wait-Function";
|
|
53
|
+
/** Prefix of the wait-chain tail headers */
|
|
54
|
+
readonly WAIT_TAIL_PREFIX: "Command-Wait-Tail-";
|
|
55
|
+
/** The stage the command a saga sends must reach; only with `SAGA_HANDLED` */
|
|
56
|
+
readonly WAIT_TAIL_STAGE: "Command-Wait-Tail-Stage";
|
|
57
|
+
/** The bounded context of the wait-chain tail */
|
|
58
|
+
readonly WAIT_TAIL_CONTEXT: "Command-Wait-Tail-Context";
|
|
59
|
+
/** The processor of the wait-chain tail */
|
|
60
|
+
readonly WAIT_TAIL_PROCESSOR: "Command-Wait-Tail-Processor";
|
|
61
|
+
/** The function of the wait-chain tail */
|
|
62
|
+
readonly WAIT_TAIL_FUNCTION: "Command-Wait-Tail-Function";
|
|
63
|
+
/** Idempotency key of the command; a repeated one is refused */
|
|
64
|
+
readonly REQUEST_ID: "Command-Request-Id";
|
|
65
|
+
/** Whether the server may process the command locally, `true` or `false` */
|
|
66
|
+
readonly LOCAL_FIRST: "Command-Local-First";
|
|
67
|
+
/** Bounded context of the aggregate, for the `/wow/command/send` route */
|
|
68
|
+
readonly COMMAND_AGGREGATE_CONTEXT: "Command-Aggregate-Context";
|
|
69
|
+
/** Name of the aggregate, for the `/wow/command/send` route */
|
|
70
|
+
readonly COMMAND_AGGREGATE_NAME: "Command-Aggregate-Name";
|
|
71
|
+
/** Fully qualified command type, for the `/wow/command/send` route */
|
|
72
|
+
readonly COMMAND_TYPE: "Command-Type";
|
|
73
|
+
/** Prefix of the custom headers the server copies into the command header */
|
|
74
|
+
readonly COMMAND_HEADER_X_PREFIX: "Command-Header-";
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WowHeaders as e } from "../../error/headers.es.js";
|
|
2
|
+
//#region src/client/command/commandHeaders.ts
|
|
3
|
+
var t = Object.freeze({
|
|
4
|
+
COMMAND_HEADERS_PREFIX: "Command-",
|
|
5
|
+
TENANT_ID: "Command-Tenant-Id",
|
|
6
|
+
OWNER_ID: "Command-Owner-Id",
|
|
7
|
+
SPACE_ID: e.SPACE_ID,
|
|
8
|
+
AGGREGATE_ID: "Command-Aggregate-Id",
|
|
9
|
+
AGGREGATE_VERSION: "Command-Aggregate-Version",
|
|
10
|
+
WAIT_PREFIX: "Command-Wait-",
|
|
11
|
+
WAIT_TIME_OUT: "Command-Wait-Timeout",
|
|
12
|
+
WAIT_STAGE: "Command-Wait-Stage",
|
|
13
|
+
WAIT_CONTEXT: "Command-Wait-Context",
|
|
14
|
+
WAIT_PROCESSOR: "Command-Wait-Processor",
|
|
15
|
+
WAIT_FUNCTION: "Command-Wait-Function",
|
|
16
|
+
WAIT_TAIL_PREFIX: "Command-Wait-Tail-",
|
|
17
|
+
WAIT_TAIL_STAGE: "Command-Wait-Tail-Stage",
|
|
18
|
+
WAIT_TAIL_CONTEXT: "Command-Wait-Tail-Context",
|
|
19
|
+
WAIT_TAIL_PROCESSOR: "Command-Wait-Tail-Processor",
|
|
20
|
+
WAIT_TAIL_FUNCTION: "Command-Wait-Tail-Function",
|
|
21
|
+
REQUEST_ID: "Command-Request-Id",
|
|
22
|
+
LOCAL_FIRST: "Command-Local-First",
|
|
23
|
+
COMMAND_AGGREGATE_CONTEXT: "Command-Aggregate-Context",
|
|
24
|
+
COMMAND_AGGREGATE_NAME: "Command-Aggregate-Name",
|
|
25
|
+
COMMAND_TYPE: "Command-Type",
|
|
26
|
+
COMMAND_HEADER_X_PREFIX: "Command-Header-"
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { t as CommandHeaders };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=commandHeaders.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandHeaders.es.js","names":["CommandHeaders","WowHeaders"],"sources":["../../../src/client/command/commandHeaders.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { WowHeaders } from '../../error/headers.js';\n\n/**\n * Command Header Constants\n *\n * The HTTP headers a Wow command route reads. Each value is a string literal\n * type, so `CommandRequestHeaders` can type the value of every header by its\n * name. {@link commandHeaders} and {@link waitStrategy} build them from typed\n * options.\n *\n * Mirrors `CommandComponent.Header` in\n * `wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/aggregate/command/CommandComponent.kt`.\n *\n * @example\n * ```typescript\n * const headers: CommandRequestHeaders = {\n * [CommandHeaders.TENANT_ID]: 'tenant-123',\n * [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,\n * };\n * ```\n */\nexport const CommandHeaders = Object.freeze({\n /** Prefix of the command headers */\n COMMAND_HEADERS_PREFIX: 'Command-',\n\n /** Tenant of the command, when the route has no tenant path segment */\n TENANT_ID: 'Command-Tenant-Id',\n\n /** Owner of the command, when the route has no owner path segment */\n OWNER_ID: 'Command-Owner-Id',\n\n /**\n * Space identifier header, `Wow-Space-Id`\n * Used to send the command into a space. The server reads it only for an\n * aggregate declared `@AggregateRoute(spaced = true)`; any other aggregate\n * ignores it and keeps the default space.\n *\n * The server shares this header with queries, so it has the `Wow-` prefix\n * rather than `Command-`; it is the same value as {@link WowHeaders.SPACE_ID}.\n */\n SPACE_ID: WowHeaders.SPACE_ID,\n\n /** Aggregate the command targets, when the route has no id path segment */\n AGGREGATE_ID: 'Command-Aggregate-Id',\n\n /** The aggregate version the command expects; a mismatch is a conflict */\n AGGREGATE_VERSION: 'Command-Aggregate-Version',\n\n /** Prefix of the wait headers */\n WAIT_PREFIX: 'Command-Wait-',\n\n /** How long the server waits for the wait stage, in milliseconds */\n WAIT_TIME_OUT: 'Command-Wait-Timeout',\n\n /** The stage to wait for; the server waits for `PROCESSED` when absent */\n WAIT_STAGE: 'Command-Wait-Stage',\n\n /** The bounded context whose processing the wait stage refers to */\n WAIT_CONTEXT: 'Command-Wait-Context',\n\n /** The processor whose processing the wait stage refers to */\n WAIT_PROCESSOR: 'Command-Wait-Processor',\n\n /** The function whose processing the wait stage refers to */\n WAIT_FUNCTION: 'Command-Wait-Function',\n\n /** Prefix of the wait-chain tail headers */\n WAIT_TAIL_PREFIX: 'Command-Wait-Tail-',\n\n /** The stage the command a saga sends must reach; only with `SAGA_HANDLED` */\n WAIT_TAIL_STAGE: 'Command-Wait-Tail-Stage',\n\n /** The bounded context of the wait-chain tail */\n WAIT_TAIL_CONTEXT: 'Command-Wait-Tail-Context',\n\n /** The processor of the wait-chain tail */\n WAIT_TAIL_PROCESSOR: 'Command-Wait-Tail-Processor',\n\n /** The function of the wait-chain tail */\n WAIT_TAIL_FUNCTION: 'Command-Wait-Tail-Function',\n\n /** Idempotency key of the command; a repeated one is refused */\n REQUEST_ID: 'Command-Request-Id',\n\n /** Whether the server may process the command locally, `true` or `false` */\n LOCAL_FIRST: 'Command-Local-First',\n\n /** Bounded context of the aggregate, for the `/wow/command/send` route */\n COMMAND_AGGREGATE_CONTEXT: 'Command-Aggregate-Context',\n\n /** Name of the aggregate, for the `/wow/command/send` route */\n COMMAND_AGGREGATE_NAME: 'Command-Aggregate-Name',\n\n /** Fully qualified command type, for the `/wow/command/send` route */\n COMMAND_TYPE: 'Command-Type',\n\n /** Prefix of the custom headers the server copies into the command header */\n COMMAND_HEADER_X_PREFIX: 'Command-Header-',\n} as const);\n"],"mappings":";;AAkCA,IAAaA,IAAiB,OAAO,OAAO;CAE1C,wBAAwB;CAGxB,WAAW;CAGX,UAAU;CAWV,UAAUC,EAAW;CAGrB,cAAc;CAGd,mBAAmB;CAGnB,aAAa;CAGb,eAAe;CAGf,YAAY;CAGZ,cAAc;CAGd,gBAAgB;CAGhB,eAAe;CAGf,kBAAkB;CAGlB,iBAAiB;CAGjB,mBAAmB;CAGnB,qBAAqB;CAGrB,oBAAoB;CAGpB,YAAY;CAGZ,aAAa;CAGb,2BAA2B;CAG3B,wBAAwB;CAGxB,cAAc;CAGd,yBAAyB;AAC3B,CAAU"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../../model/command.cjs"),t=require("./commandHeaders.cjs");var n=new Set(Object.values(e.CommandStage));function r(e,t){if(!n.has(t))throw TypeError(`${e} must be one of ${[...n].join(`, `)}, got [${t}].`);return t}function i(e,t,n){if(!Number.isSafeInteger(t)||t<n)throw TypeError(`${e} must be an integer of at least ${n}, got [${t}].`);return`${t}`}function a(e,t,n){n!==void 0&&(e[t]=n)}function o(e){let n={};return a(n,t.CommandHeaders.TENANT_ID,e.tenantId),a(n,t.CommandHeaders.OWNER_ID,e.ownerId),a(n,t.CommandHeaders.SPACE_ID,e.spaceId),a(n,t.CommandHeaders.AGGREGATE_ID,e.aggregateId),e.aggregateVersion!==void 0&&(n[t.CommandHeaders.AGGREGATE_VERSION]=i(`aggregateVersion`,e.aggregateVersion,0)),a(n,t.CommandHeaders.REQUEST_ID,e.requestId),e.localFirst!==void 0&&(n[t.CommandHeaders.LOCAL_FIRST]=e.localFirst?`true`:`false`),n}function s(n){let o={};if(n.stage!==void 0&&(o[t.CommandHeaders.WAIT_STAGE]=r(`stage`,n.stage)),a(o,t.CommandHeaders.WAIT_CONTEXT,n.context),a(o,t.CommandHeaders.WAIT_PROCESSOR,n.processor),a(o,t.CommandHeaders.WAIT_FUNCTION,n.function),n.tail!==void 0){if(n.stage!==e.CommandStage.SAGA_HANDLED)throw TypeError(`A wait tail needs the SAGA_HANDLED stage.`);o[t.CommandHeaders.WAIT_TAIL_STAGE]=r(`tail.stage`,n.tail.stage),a(o,t.CommandHeaders.WAIT_TAIL_CONTEXT,n.tail.context),a(o,t.CommandHeaders.WAIT_TAIL_PROCESSOR,n.tail.processor),a(o,t.CommandHeaders.WAIT_TAIL_FUNCTION,n.tail.function)}return n.timeoutMs!==void 0&&(o[t.CommandHeaders.WAIT_TIME_OUT]=i(`timeoutMs`,n.timeoutMs,1)),o}exports.commandHeaders=o,exports.waitStrategy=s;
|
|
2
|
+
//# sourceMappingURL=commandRequest.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandRequest.cjs","names":["CommandStage","CommandHeaders","require_command","require_commandHeaders","STAGES","stageName","stage","label","integer","value","minimum","put","name","commandHeaders","headers","options","waitStrategy"],"sources":["../../../src/client/command/commandRequest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RequestHeaders, UrlParams } from '@ahoo-wang/fetcher';\nimport { CommandHeaders } from './commandHeaders.js';\nimport type { UrlPathParams } from '../routing.js';\nimport type { ParameterRequest } from '@ahoo-wang/fetcher-decorator';\nimport { CommandStage } from '../../model/index.js';\nimport type { CommandBody } from './types.js';\n\n/** A command stage, as the enum member or as its name. */\nexport type CommandStageName = CommandStage | `${CommandStage}`;\n\n/**\n * The headers of a command request.\n *\n * Every command header is optional and typed by what the server parses:\n * a stage is a {@link CommandStage}, a version or a timeout is an integer,\n * `Local-First` is a boolean. Any other header (`Authorization`, a\n * `Command-Header-*` extension, …) is still allowed as a string. Build these\n * with {@link commandHeaders} and {@link waitStrategy} rather than by hand.\n *\n * @example\n * ```typescript\n * const headers: CommandRequestHeaders = {\n * ...commandHeaders({ ownerId: 'user-1', requestId }),\n * ...waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 10_000 }),\n * };\n * ```\n */\nexport interface CommandRequestHeaders extends RequestHeaders {\n /** Tenant of the command, when the route has no tenant path segment */\n [CommandHeaders.TENANT_ID]?: string;\n /** Owner of the command, when the route has no owner path segment */\n [CommandHeaders.OWNER_ID]?: string;\n /** Space of the command, `Wow-Space-Id` */\n [CommandHeaders.SPACE_ID]?: string;\n /** Aggregate the command targets, when the route has no id path segment */\n [CommandHeaders.AGGREGATE_ID]?: string;\n /** The aggregate version the command expects, an integer */\n [CommandHeaders.AGGREGATE_VERSION]?: `${number}`;\n /** How long the server waits, in whole milliseconds */\n [CommandHeaders.WAIT_TIME_OUT]?: `${number}`;\n /** The stage to wait for; `PROCESSED` when absent */\n [CommandHeaders.WAIT_STAGE]?: CommandStageName;\n /** The bounded context the wait stage refers to */\n [CommandHeaders.WAIT_CONTEXT]?: string;\n /** The processor the wait stage refers to */\n [CommandHeaders.WAIT_PROCESSOR]?: string;\n /** The function the wait stage refers to */\n [CommandHeaders.WAIT_FUNCTION]?: string;\n /** The stage of the wait-chain tail; only with a `SAGA_HANDLED` wait stage */\n [CommandHeaders.WAIT_TAIL_STAGE]?: CommandStageName;\n /** The bounded context of the wait-chain tail */\n [CommandHeaders.WAIT_TAIL_CONTEXT]?: string;\n /** The processor of the wait-chain tail */\n [CommandHeaders.WAIT_TAIL_PROCESSOR]?: string;\n /** The function of the wait-chain tail */\n [CommandHeaders.WAIT_TAIL_FUNCTION]?: string;\n /** Idempotency key of the command */\n [CommandHeaders.REQUEST_ID]?: string;\n /** Whether the server may process the command locally */\n [CommandHeaders.LOCAL_FIRST]?: 'true' | 'false';\n /** Bounded context of the aggregate, for `/wow/command/send` */\n [CommandHeaders.COMMAND_AGGREGATE_CONTEXT]?: string;\n /** Name of the aggregate, for `/wow/command/send` */\n [CommandHeaders.COMMAND_AGGREGATE_NAME]?: string;\n /** Fully qualified command type, for `/wow/command/send` */\n [CommandHeaders.COMMAND_TYPE]?: string;\n}\n\n/** Who a command is for; each option sets one command header. */\nexport interface CommandHeaderOptions {\n /** The tenant, `Command-Tenant-Id`; for a route without a tenant segment. */\n tenantId?: string;\n /** The owner, `Command-Owner-Id`; for a route without an owner segment. */\n ownerId?: string;\n /**\n * The space, `Wow-Space-Id`; the tenant's default space when absent. Only a\n * spaced aggregate reads it.\n */\n spaceId?: string;\n /**\n * The target aggregate, `Command-Aggregate-Id`; for a route without an id\n * segment.\n */\n aggregateId?: string;\n /** The aggregate version the command expects: a non-negative integer. */\n aggregateVersion?: number;\n /** Idempotency key; the server refuses a repeated one. */\n requestId?: string;\n /**\n * Whether the server may process the command in its own process when it\n * hosts the aggregate, `Command-Local-First`; it does unless this is `false`.\n */\n localFirst?: boolean;\n}\n\n/** The processing a wait stage refers to; blank means any. */\nexport interface WaitFunction {\n context?: string;\n processor?: string;\n function?: string;\n}\n\n/** Wait for one stage of the command. */\nexport interface WaitStageOptions extends WaitFunction {\n /** The stage to wait for. The server waits for `PROCESSED` when absent. */\n stage?: CommandStageName;\n /** How long the server waits, in whole milliseconds. */\n timeoutMs?: number;\n tail?: never;\n}\n\n/**\n * Wait for a saga to handle the command's events, and then for the command\n * that saga sends to reach `tail.stage` — Wow's wait chain.\n */\nexport interface WaitChainOptions extends WaitFunction {\n stage: CommandStage.SAGA_HANDLED | 'SAGA_HANDLED';\n tail: WaitFunction & { stage: CommandStageName };\n /** How long the server waits, in whole milliseconds. */\n timeoutMs?: number;\n}\n\n/** What {@link waitStrategy} takes: one stage, or a wait chain. */\nexport type WaitStrategyOptions = WaitStageOptions | WaitChainOptions;\n\nconst STAGES: ReadonlySet<string> = new Set(Object.values(CommandStage));\n\nfunction stageName(label: string, stage: string): CommandStageName {\n if (!STAGES.has(stage)) {\n throw new TypeError(\n `${label} must be one of ${[...STAGES].join(', ')}, got [${stage}].`,\n );\n }\n return stage as CommandStageName;\n}\n\nfunction integer(label: string, value: number, minimum: number): `${number}` {\n if (!Number.isSafeInteger(value) || value < minimum) {\n throw new TypeError(\n `${label} must be an integer of at least ${minimum}, got [${value}].`,\n );\n }\n return `${value}`;\n}\n\nfunction put(\n headers: CommandRequestHeaders,\n name: keyof CommandRequestHeaders,\n value: string | undefined,\n): void {\n if (value !== undefined) headers[name] = value as never;\n}\n\n/**\n * Builds the headers that say who a command is for. Options left out send\n * no header.\n *\n * @throws TypeError when `aggregateVersion` is not a non-negative integer.\n *\n * @example\n * ```typescript\n * await commandClient.send({\n * path: 'owner/{ownerId}/cart/add_cart_item',\n * method: 'POST',\n * headers: commandHeaders({ spaceId: 'store-1', requestId: crypto.randomUUID() }),\n * body: { productId: 'p-1', quantity: 1 },\n * });\n * ```\n */\nexport function commandHeaders(\n options: CommandHeaderOptions,\n): CommandRequestHeaders {\n const headers: CommandRequestHeaders = {};\n put(headers, CommandHeaders.TENANT_ID, options.tenantId);\n put(headers, CommandHeaders.OWNER_ID, options.ownerId);\n put(headers, CommandHeaders.SPACE_ID, options.spaceId);\n put(headers, CommandHeaders.AGGREGATE_ID, options.aggregateId);\n if (options.aggregateVersion !== undefined) {\n headers[CommandHeaders.AGGREGATE_VERSION] = integer(\n 'aggregateVersion',\n options.aggregateVersion,\n 0,\n );\n }\n put(headers, CommandHeaders.REQUEST_ID, options.requestId);\n if (options.localFirst !== undefined) {\n headers[CommandHeaders.LOCAL_FIRST] = options.localFirst ? 'true' : 'false';\n }\n return headers;\n}\n\n/**\n * Builds the headers that say how long, and for what, the server waits\n * before it answers a command — Kotlin's `WaitingFor`. Options left out send\n * no header, and the server's defaults apply: `PROCESSED` in the command's own\n * bounded context.\n *\n * @throws TypeError when a stage is not a `CommandStage`, when `timeoutMs` is\n * not a positive integer, or when a `tail` is given with a stage other than\n * `SAGA_HANDLED` (the server ignores the tail then).\n *\n * @example\n * ```typescript\n * // Answer once the snapshot is written, or after five seconds.\n * waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 5_000 });\n *\n * // Answer once the saga's command has been processed.\n * waitStrategy({\n * stage: 'SAGA_HANDLED',\n * processor: 'TransferSaga',\n * tail: { stage: 'PROCESSED', context: 'account' },\n * });\n * ```\n */\nexport function waitStrategy(\n options: WaitStrategyOptions,\n): CommandRequestHeaders {\n const headers: CommandRequestHeaders = {};\n if (options.stage !== undefined) {\n headers[CommandHeaders.WAIT_STAGE] = stageName('stage', options.stage);\n }\n put(headers, CommandHeaders.WAIT_CONTEXT, options.context);\n put(headers, CommandHeaders.WAIT_PROCESSOR, options.processor);\n put(headers, CommandHeaders.WAIT_FUNCTION, options.function);\n if (options.tail !== undefined) {\n if (options.stage !== CommandStage.SAGA_HANDLED) {\n throw new TypeError('A wait tail needs the SAGA_HANDLED stage.');\n }\n headers[CommandHeaders.WAIT_TAIL_STAGE] = stageName(\n 'tail.stage',\n options.tail.stage,\n );\n put(headers, CommandHeaders.WAIT_TAIL_CONTEXT, options.tail.context);\n put(headers, CommandHeaders.WAIT_TAIL_PROCESSOR, options.tail.processor);\n put(headers, CommandHeaders.WAIT_TAIL_FUNCTION, options.tail.function);\n }\n if (options.timeoutMs !== undefined) {\n headers[CommandHeaders.WAIT_TIME_OUT] = integer(\n 'timeoutMs',\n options.timeoutMs,\n 1,\n );\n }\n return headers;\n}\n\n/**\n * The URL parameters of a {@link CommandRequest}: the values of the route's\n * path variables. A command takes no query string.\n */\nexport interface CommandUrlParams extends Omit<UrlParams, 'path' | 'query'> {\n /** The path variables, such as `{ ownerId, id }`. */\n path?: UrlPathParams;\n}\n\n/**\n * A command request: the path of the command route, its URL parameters, its\n * typed headers and its body.\n */\nexport interface CommandRequest<\n C extends object = object,\n> extends ParameterRequest<CommandBody<C>> {\n urlParams?: CommandUrlParams;\n headers?: CommandRequestHeaders;\n /**\n * The body of the command request.\n */\n body?: CommandBody<C>;\n}\n"],"mappings":"6EA0IA,IAAMI,EAA8B,IAAI,IAAI,OAAO,OAAOJ,EAAAA,YAAY,CAAC,EAEvE,SAASK,EAAU,EAAe,EAAiC,CACjE,GAAI,CAACD,EAAO,IAAIE,CAAK,EACnB,MAAU,UACR,GAAGC,EAAM,kBAAkB,CAAC,GAAGH,CAAM,CAAC,CAAC,KAAK,IAAI,EAAE,SAASE,EAAM,GACnE,EAEF,OAAOA,CACT,CAEA,SAASE,EAAQ,EAAe,EAAe,EAA8B,CAC3E,GAAI,CAAC,OAAO,cAAcC,CAAK,GAAKA,EAAQC,EAC1C,MAAU,UACR,GAAGH,EAAM,kCAAkCG,EAAQ,SAASD,EAAM,GACpE,EAEF,MAAO,GAAGA,GACZ,CAEA,SAASE,EACP,EACA,EACA,EACM,CACFF,IAAU,IAAA,KAAW,EAAQG,GAAQH,EAC3C,CAkBA,SAAgBI,EACd,EACuB,CACvB,IAAMC,EAAiC,CAAC,EAgBxC,OAfAH,EAAIG,EAASb,EAAAA,eAAe,UAAWc,EAAQ,QAAQ,EACvDJ,EAAIG,EAASb,EAAAA,eAAe,SAAUc,EAAQ,OAAO,EACrDJ,EAAIG,EAASb,EAAAA,eAAe,SAAUc,EAAQ,OAAO,EACrDJ,EAAIG,EAASb,EAAAA,eAAe,aAAcc,EAAQ,WAAW,EACzDA,EAAQ,mBAAqB,IAAA,KAC/B,EAAQd,EAAAA,eAAe,mBAAqBO,EAC1C,mBACAO,EAAQ,iBACR,CACF,GAEFJ,EAAIG,EAASb,EAAAA,eAAe,WAAYc,EAAQ,SAAS,EACrDA,EAAQ,aAAe,IAAA,KACzB,EAAQd,EAAAA,eAAe,aAAec,EAAQ,WAAa,OAAS,SAE/DD,CACT,CAyBA,SAAgBE,EACd,EACuB,CACvB,IAAMF,EAAiC,CAAC,EAOxC,GANIC,EAAQ,QAAU,IAAA,KACpB,EAAQd,EAAAA,eAAe,YAAcI,EAAU,QAASU,EAAQ,KAAK,GAEvEJ,EAAIG,EAASb,EAAAA,eAAe,aAAcc,EAAQ,OAAO,EACzDJ,EAAIG,EAASb,EAAAA,eAAe,eAAgBc,EAAQ,SAAS,EAC7DJ,EAAIG,EAASb,EAAAA,eAAe,cAAec,EAAQ,QAAQ,EACvDA,EAAQ,OAAS,IAAA,GAAW,CAC9B,GAAIA,EAAQ,QAAUf,EAAAA,aAAa,aACjC,MAAU,UAAU,2CAA2C,EAEjE,EAAQC,EAAAA,eAAe,iBAAmBI,EACxC,aACAU,EAAQ,KAAK,KACf,EACAJ,EAAIG,EAASb,EAAAA,eAAe,kBAAmBc,EAAQ,KAAK,OAAO,EACnEJ,EAAIG,EAASb,EAAAA,eAAe,oBAAqBc,EAAQ,KAAK,SAAS,EACvEJ,EAAIG,EAASb,EAAAA,eAAe,mBAAoBc,EAAQ,KAAK,QAAQ,CACvE,CAQA,OAPIA,EAAQ,YAAc,IAAA,KACxB,EAAQd,EAAAA,eAAe,eAAiBO,EACtC,YACAO,EAAQ,UACR,CACF,GAEKD,CACT"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { RequestHeaders, UrlParams } from '@ahoo-wang/fetcher';
|
|
2
|
+
import { CommandHeaders } from './commandHeaders.cjs';
|
|
3
|
+
import { UrlPathParams } from '../routing.cjs';
|
|
4
|
+
import { ParameterRequest } from '@ahoo-wang/fetcher-decorator';
|
|
5
|
+
import { CommandStage } from '../../model/index.cjs';
|
|
6
|
+
import { CommandBody } from './types.cjs';
|
|
7
|
+
/** A command stage, as the enum member or as its name. */
|
|
8
|
+
export type CommandStageName = CommandStage | `${CommandStage}`;
|
|
9
|
+
/**
|
|
10
|
+
* The headers of a command request.
|
|
11
|
+
*
|
|
12
|
+
* Every command header is optional and typed by what the server parses:
|
|
13
|
+
* a stage is a {@link CommandStage}, a version or a timeout is an integer,
|
|
14
|
+
* `Local-First` is a boolean. Any other header (`Authorization`, a
|
|
15
|
+
* `Command-Header-*` extension, …) is still allowed as a string. Build these
|
|
16
|
+
* with {@link commandHeaders} and {@link waitStrategy} rather than by hand.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const headers: CommandRequestHeaders = {
|
|
21
|
+
* ...commandHeaders({ ownerId: 'user-1', requestId }),
|
|
22
|
+
* ...waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 10_000 }),
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface CommandRequestHeaders extends RequestHeaders {
|
|
27
|
+
/** Tenant of the command, when the route has no tenant path segment */
|
|
28
|
+
[CommandHeaders.TENANT_ID]?: string;
|
|
29
|
+
/** Owner of the command, when the route has no owner path segment */
|
|
30
|
+
[CommandHeaders.OWNER_ID]?: string;
|
|
31
|
+
/** Space of the command, `Wow-Space-Id` */
|
|
32
|
+
[CommandHeaders.SPACE_ID]?: string;
|
|
33
|
+
/** Aggregate the command targets, when the route has no id path segment */
|
|
34
|
+
[CommandHeaders.AGGREGATE_ID]?: string;
|
|
35
|
+
/** The aggregate version the command expects, an integer */
|
|
36
|
+
[CommandHeaders.AGGREGATE_VERSION]?: `${number}`;
|
|
37
|
+
/** How long the server waits, in whole milliseconds */
|
|
38
|
+
[CommandHeaders.WAIT_TIME_OUT]?: `${number}`;
|
|
39
|
+
/** The stage to wait for; `PROCESSED` when absent */
|
|
40
|
+
[CommandHeaders.WAIT_STAGE]?: CommandStageName;
|
|
41
|
+
/** The bounded context the wait stage refers to */
|
|
42
|
+
[CommandHeaders.WAIT_CONTEXT]?: string;
|
|
43
|
+
/** The processor the wait stage refers to */
|
|
44
|
+
[CommandHeaders.WAIT_PROCESSOR]?: string;
|
|
45
|
+
/** The function the wait stage refers to */
|
|
46
|
+
[CommandHeaders.WAIT_FUNCTION]?: string;
|
|
47
|
+
/** The stage of the wait-chain tail; only with a `SAGA_HANDLED` wait stage */
|
|
48
|
+
[CommandHeaders.WAIT_TAIL_STAGE]?: CommandStageName;
|
|
49
|
+
/** The bounded context of the wait-chain tail */
|
|
50
|
+
[CommandHeaders.WAIT_TAIL_CONTEXT]?: string;
|
|
51
|
+
/** The processor of the wait-chain tail */
|
|
52
|
+
[CommandHeaders.WAIT_TAIL_PROCESSOR]?: string;
|
|
53
|
+
/** The function of the wait-chain tail */
|
|
54
|
+
[CommandHeaders.WAIT_TAIL_FUNCTION]?: string;
|
|
55
|
+
/** Idempotency key of the command */
|
|
56
|
+
[CommandHeaders.REQUEST_ID]?: string;
|
|
57
|
+
/** Whether the server may process the command locally */
|
|
58
|
+
[CommandHeaders.LOCAL_FIRST]?: 'true' | 'false';
|
|
59
|
+
/** Bounded context of the aggregate, for `/wow/command/send` */
|
|
60
|
+
[CommandHeaders.COMMAND_AGGREGATE_CONTEXT]?: string;
|
|
61
|
+
/** Name of the aggregate, for `/wow/command/send` */
|
|
62
|
+
[CommandHeaders.COMMAND_AGGREGATE_NAME]?: string;
|
|
63
|
+
/** Fully qualified command type, for `/wow/command/send` */
|
|
64
|
+
[CommandHeaders.COMMAND_TYPE]?: string;
|
|
65
|
+
}
|
|
66
|
+
/** Who a command is for; each option sets one command header. */
|
|
67
|
+
export interface CommandHeaderOptions {
|
|
68
|
+
/** The tenant, `Command-Tenant-Id`; for a route without a tenant segment. */
|
|
69
|
+
tenantId?: string;
|
|
70
|
+
/** The owner, `Command-Owner-Id`; for a route without an owner segment. */
|
|
71
|
+
ownerId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The space, `Wow-Space-Id`; the tenant's default space when absent. Only a
|
|
74
|
+
* spaced aggregate reads it.
|
|
75
|
+
*/
|
|
76
|
+
spaceId?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The target aggregate, `Command-Aggregate-Id`; for a route without an id
|
|
79
|
+
* segment.
|
|
80
|
+
*/
|
|
81
|
+
aggregateId?: string;
|
|
82
|
+
/** The aggregate version the command expects: a non-negative integer. */
|
|
83
|
+
aggregateVersion?: number;
|
|
84
|
+
/** Idempotency key; the server refuses a repeated one. */
|
|
85
|
+
requestId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the server may process the command in its own process when it
|
|
88
|
+
* hosts the aggregate, `Command-Local-First`; it does unless this is `false`.
|
|
89
|
+
*/
|
|
90
|
+
localFirst?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** The processing a wait stage refers to; blank means any. */
|
|
93
|
+
export interface WaitFunction {
|
|
94
|
+
context?: string;
|
|
95
|
+
processor?: string;
|
|
96
|
+
function?: string;
|
|
97
|
+
}
|
|
98
|
+
/** Wait for one stage of the command. */
|
|
99
|
+
export interface WaitStageOptions extends WaitFunction {
|
|
100
|
+
/** The stage to wait for. The server waits for `PROCESSED` when absent. */
|
|
101
|
+
stage?: CommandStageName;
|
|
102
|
+
/** How long the server waits, in whole milliseconds. */
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
tail?: never;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Wait for a saga to handle the command's events, and then for the command
|
|
108
|
+
* that saga sends to reach `tail.stage` — Wow's wait chain.
|
|
109
|
+
*/
|
|
110
|
+
export interface WaitChainOptions extends WaitFunction {
|
|
111
|
+
stage: CommandStage.SAGA_HANDLED | 'SAGA_HANDLED';
|
|
112
|
+
tail: WaitFunction & {
|
|
113
|
+
stage: CommandStageName;
|
|
114
|
+
};
|
|
115
|
+
/** How long the server waits, in whole milliseconds. */
|
|
116
|
+
timeoutMs?: number;
|
|
117
|
+
}
|
|
118
|
+
/** What {@link waitStrategy} takes: one stage, or a wait chain. */
|
|
119
|
+
export type WaitStrategyOptions = WaitStageOptions | WaitChainOptions;
|
|
120
|
+
/**
|
|
121
|
+
* Builds the headers that say who a command is for. Options left out send
|
|
122
|
+
* no header.
|
|
123
|
+
*
|
|
124
|
+
* @throws TypeError when `aggregateVersion` is not a non-negative integer.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await commandClient.send({
|
|
129
|
+
* path: 'owner/{ownerId}/cart/add_cart_item',
|
|
130
|
+
* method: 'POST',
|
|
131
|
+
* headers: commandHeaders({ spaceId: 'store-1', requestId: crypto.randomUUID() }),
|
|
132
|
+
* body: { productId: 'p-1', quantity: 1 },
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function commandHeaders(options: CommandHeaderOptions): CommandRequestHeaders;
|
|
137
|
+
/**
|
|
138
|
+
* Builds the headers that say how long, and for what, the server waits
|
|
139
|
+
* before it answers a command — Kotlin's `WaitingFor`. Options left out send
|
|
140
|
+
* no header, and the server's defaults apply: `PROCESSED` in the command's own
|
|
141
|
+
* bounded context.
|
|
142
|
+
*
|
|
143
|
+
* @throws TypeError when a stage is not a `CommandStage`, when `timeoutMs` is
|
|
144
|
+
* not a positive integer, or when a `tail` is given with a stage other than
|
|
145
|
+
* `SAGA_HANDLED` (the server ignores the tail then).
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* // Answer once the snapshot is written, or after five seconds.
|
|
150
|
+
* waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 5_000 });
|
|
151
|
+
*
|
|
152
|
+
* // Answer once the saga's command has been processed.
|
|
153
|
+
* waitStrategy({
|
|
154
|
+
* stage: 'SAGA_HANDLED',
|
|
155
|
+
* processor: 'TransferSaga',
|
|
156
|
+
* tail: { stage: 'PROCESSED', context: 'account' },
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function waitStrategy(options: WaitStrategyOptions): CommandRequestHeaders;
|
|
161
|
+
/**
|
|
162
|
+
* The URL parameters of a {@link CommandRequest}: the values of the route's
|
|
163
|
+
* path variables. A command takes no query string.
|
|
164
|
+
*/
|
|
165
|
+
export interface CommandUrlParams extends Omit<UrlParams, 'path' | 'query'> {
|
|
166
|
+
/** The path variables, such as `{ ownerId, id }`. */
|
|
167
|
+
path?: UrlPathParams;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* A command request: the path of the command route, its URL parameters, its
|
|
171
|
+
* typed headers and its body.
|
|
172
|
+
*/
|
|
173
|
+
export interface CommandRequest<C extends object = object> extends ParameterRequest<CommandBody<C>> {
|
|
174
|
+
urlParams?: CommandUrlParams;
|
|
175
|
+
headers?: CommandRequestHeaders;
|
|
176
|
+
/**
|
|
177
|
+
* The body of the command request.
|
|
178
|
+
*/
|
|
179
|
+
body?: CommandBody<C>;
|
|
180
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { RequestHeaders, UrlParams } from '@ahoo-wang/fetcher';
|
|
2
|
+
import { CommandHeaders } from './commandHeaders.js';
|
|
3
|
+
import { UrlPathParams } from '../routing.js';
|
|
4
|
+
import { ParameterRequest } from '@ahoo-wang/fetcher-decorator';
|
|
5
|
+
import { CommandStage } from '../../model/index.js';
|
|
6
|
+
import { CommandBody } from './types.js';
|
|
7
|
+
/** A command stage, as the enum member or as its name. */
|
|
8
|
+
export type CommandStageName = CommandStage | `${CommandStage}`;
|
|
9
|
+
/**
|
|
10
|
+
* The headers of a command request.
|
|
11
|
+
*
|
|
12
|
+
* Every command header is optional and typed by what the server parses:
|
|
13
|
+
* a stage is a {@link CommandStage}, a version or a timeout is an integer,
|
|
14
|
+
* `Local-First` is a boolean. Any other header (`Authorization`, a
|
|
15
|
+
* `Command-Header-*` extension, …) is still allowed as a string. Build these
|
|
16
|
+
* with {@link commandHeaders} and {@link waitStrategy} rather than by hand.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const headers: CommandRequestHeaders = {
|
|
21
|
+
* ...commandHeaders({ ownerId: 'user-1', requestId }),
|
|
22
|
+
* ...waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 10_000 }),
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface CommandRequestHeaders extends RequestHeaders {
|
|
27
|
+
/** Tenant of the command, when the route has no tenant path segment */
|
|
28
|
+
[CommandHeaders.TENANT_ID]?: string;
|
|
29
|
+
/** Owner of the command, when the route has no owner path segment */
|
|
30
|
+
[CommandHeaders.OWNER_ID]?: string;
|
|
31
|
+
/** Space of the command, `Wow-Space-Id` */
|
|
32
|
+
[CommandHeaders.SPACE_ID]?: string;
|
|
33
|
+
/** Aggregate the command targets, when the route has no id path segment */
|
|
34
|
+
[CommandHeaders.AGGREGATE_ID]?: string;
|
|
35
|
+
/** The aggregate version the command expects, an integer */
|
|
36
|
+
[CommandHeaders.AGGREGATE_VERSION]?: `${number}`;
|
|
37
|
+
/** How long the server waits, in whole milliseconds */
|
|
38
|
+
[CommandHeaders.WAIT_TIME_OUT]?: `${number}`;
|
|
39
|
+
/** The stage to wait for; `PROCESSED` when absent */
|
|
40
|
+
[CommandHeaders.WAIT_STAGE]?: CommandStageName;
|
|
41
|
+
/** The bounded context the wait stage refers to */
|
|
42
|
+
[CommandHeaders.WAIT_CONTEXT]?: string;
|
|
43
|
+
/** The processor the wait stage refers to */
|
|
44
|
+
[CommandHeaders.WAIT_PROCESSOR]?: string;
|
|
45
|
+
/** The function the wait stage refers to */
|
|
46
|
+
[CommandHeaders.WAIT_FUNCTION]?: string;
|
|
47
|
+
/** The stage of the wait-chain tail; only with a `SAGA_HANDLED` wait stage */
|
|
48
|
+
[CommandHeaders.WAIT_TAIL_STAGE]?: CommandStageName;
|
|
49
|
+
/** The bounded context of the wait-chain tail */
|
|
50
|
+
[CommandHeaders.WAIT_TAIL_CONTEXT]?: string;
|
|
51
|
+
/** The processor of the wait-chain tail */
|
|
52
|
+
[CommandHeaders.WAIT_TAIL_PROCESSOR]?: string;
|
|
53
|
+
/** The function of the wait-chain tail */
|
|
54
|
+
[CommandHeaders.WAIT_TAIL_FUNCTION]?: string;
|
|
55
|
+
/** Idempotency key of the command */
|
|
56
|
+
[CommandHeaders.REQUEST_ID]?: string;
|
|
57
|
+
/** Whether the server may process the command locally */
|
|
58
|
+
[CommandHeaders.LOCAL_FIRST]?: 'true' | 'false';
|
|
59
|
+
/** Bounded context of the aggregate, for `/wow/command/send` */
|
|
60
|
+
[CommandHeaders.COMMAND_AGGREGATE_CONTEXT]?: string;
|
|
61
|
+
/** Name of the aggregate, for `/wow/command/send` */
|
|
62
|
+
[CommandHeaders.COMMAND_AGGREGATE_NAME]?: string;
|
|
63
|
+
/** Fully qualified command type, for `/wow/command/send` */
|
|
64
|
+
[CommandHeaders.COMMAND_TYPE]?: string;
|
|
65
|
+
}
|
|
66
|
+
/** Who a command is for; each option sets one command header. */
|
|
67
|
+
export interface CommandHeaderOptions {
|
|
68
|
+
/** The tenant, `Command-Tenant-Id`; for a route without a tenant segment. */
|
|
69
|
+
tenantId?: string;
|
|
70
|
+
/** The owner, `Command-Owner-Id`; for a route without an owner segment. */
|
|
71
|
+
ownerId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The space, `Wow-Space-Id`; the tenant's default space when absent. Only a
|
|
74
|
+
* spaced aggregate reads it.
|
|
75
|
+
*/
|
|
76
|
+
spaceId?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The target aggregate, `Command-Aggregate-Id`; for a route without an id
|
|
79
|
+
* segment.
|
|
80
|
+
*/
|
|
81
|
+
aggregateId?: string;
|
|
82
|
+
/** The aggregate version the command expects: a non-negative integer. */
|
|
83
|
+
aggregateVersion?: number;
|
|
84
|
+
/** Idempotency key; the server refuses a repeated one. */
|
|
85
|
+
requestId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the server may process the command in its own process when it
|
|
88
|
+
* hosts the aggregate, `Command-Local-First`; it does unless this is `false`.
|
|
89
|
+
*/
|
|
90
|
+
localFirst?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** The processing a wait stage refers to; blank means any. */
|
|
93
|
+
export interface WaitFunction {
|
|
94
|
+
context?: string;
|
|
95
|
+
processor?: string;
|
|
96
|
+
function?: string;
|
|
97
|
+
}
|
|
98
|
+
/** Wait for one stage of the command. */
|
|
99
|
+
export interface WaitStageOptions extends WaitFunction {
|
|
100
|
+
/** The stage to wait for. The server waits for `PROCESSED` when absent. */
|
|
101
|
+
stage?: CommandStageName;
|
|
102
|
+
/** How long the server waits, in whole milliseconds. */
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
tail?: never;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Wait for a saga to handle the command's events, and then for the command
|
|
108
|
+
* that saga sends to reach `tail.stage` — Wow's wait chain.
|
|
109
|
+
*/
|
|
110
|
+
export interface WaitChainOptions extends WaitFunction {
|
|
111
|
+
stage: CommandStage.SAGA_HANDLED | 'SAGA_HANDLED';
|
|
112
|
+
tail: WaitFunction & {
|
|
113
|
+
stage: CommandStageName;
|
|
114
|
+
};
|
|
115
|
+
/** How long the server waits, in whole milliseconds. */
|
|
116
|
+
timeoutMs?: number;
|
|
117
|
+
}
|
|
118
|
+
/** What {@link waitStrategy} takes: one stage, or a wait chain. */
|
|
119
|
+
export type WaitStrategyOptions = WaitStageOptions | WaitChainOptions;
|
|
120
|
+
/**
|
|
121
|
+
* Builds the headers that say who a command is for. Options left out send
|
|
122
|
+
* no header.
|
|
123
|
+
*
|
|
124
|
+
* @throws TypeError when `aggregateVersion` is not a non-negative integer.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await commandClient.send({
|
|
129
|
+
* path: 'owner/{ownerId}/cart/add_cart_item',
|
|
130
|
+
* method: 'POST',
|
|
131
|
+
* headers: commandHeaders({ spaceId: 'store-1', requestId: crypto.randomUUID() }),
|
|
132
|
+
* body: { productId: 'p-1', quantity: 1 },
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function commandHeaders(options: CommandHeaderOptions): CommandRequestHeaders;
|
|
137
|
+
/**
|
|
138
|
+
* Builds the headers that say how long, and for what, the server waits
|
|
139
|
+
* before it answers a command — Kotlin's `WaitingFor`. Options left out send
|
|
140
|
+
* no header, and the server's defaults apply: `PROCESSED` in the command's own
|
|
141
|
+
* bounded context.
|
|
142
|
+
*
|
|
143
|
+
* @throws TypeError when a stage is not a `CommandStage`, when `timeoutMs` is
|
|
144
|
+
* not a positive integer, or when a `tail` is given with a stage other than
|
|
145
|
+
* `SAGA_HANDLED` (the server ignores the tail then).
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* // Answer once the snapshot is written, or after five seconds.
|
|
150
|
+
* waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 5_000 });
|
|
151
|
+
*
|
|
152
|
+
* // Answer once the saga's command has been processed.
|
|
153
|
+
* waitStrategy({
|
|
154
|
+
* stage: 'SAGA_HANDLED',
|
|
155
|
+
* processor: 'TransferSaga',
|
|
156
|
+
* tail: { stage: 'PROCESSED', context: 'account' },
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
export declare function waitStrategy(options: WaitStrategyOptions): CommandRequestHeaders;
|
|
161
|
+
/**
|
|
162
|
+
* The URL parameters of a {@link CommandRequest}: the values of the route's
|
|
163
|
+
* path variables. A command takes no query string.
|
|
164
|
+
*/
|
|
165
|
+
export interface CommandUrlParams extends Omit<UrlParams, 'path' | 'query'> {
|
|
166
|
+
/** The path variables, such as `{ ownerId, id }`. */
|
|
167
|
+
path?: UrlPathParams;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* A command request: the path of the command route, its URL parameters, its
|
|
171
|
+
* typed headers and its body.
|
|
172
|
+
*/
|
|
173
|
+
export interface CommandRequest<C extends object = object> extends ParameterRequest<CommandBody<C>> {
|
|
174
|
+
urlParams?: CommandUrlParams;
|
|
175
|
+
headers?: CommandRequestHeaders;
|
|
176
|
+
/**
|
|
177
|
+
* The body of the command request.
|
|
178
|
+
*/
|
|
179
|
+
body?: CommandBody<C>;
|
|
180
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CommandStage as e } from "../../model/command.es.js";
|
|
2
|
+
import { CommandHeaders as t } from "./commandHeaders.es.js";
|
|
3
|
+
//#region src/client/command/commandRequest.ts
|
|
4
|
+
var n = new Set(Object.values(e));
|
|
5
|
+
function r(e, t) {
|
|
6
|
+
if (!n.has(t)) throw TypeError(`${e} must be one of ${[...n].join(", ")}, got [${t}].`);
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
9
|
+
function i(e, t, n) {
|
|
10
|
+
if (!Number.isSafeInteger(t) || t < n) throw TypeError(`${e} must be an integer of at least ${n}, got [${t}].`);
|
|
11
|
+
return `${t}`;
|
|
12
|
+
}
|
|
13
|
+
function a(e, t, n) {
|
|
14
|
+
n !== void 0 && (e[t] = n);
|
|
15
|
+
}
|
|
16
|
+
function o(e) {
|
|
17
|
+
let n = {};
|
|
18
|
+
return a(n, t.TENANT_ID, e.tenantId), a(n, t.OWNER_ID, e.ownerId), a(n, t.SPACE_ID, e.spaceId), a(n, t.AGGREGATE_ID, e.aggregateId), e.aggregateVersion !== void 0 && (n[t.AGGREGATE_VERSION] = i("aggregateVersion", e.aggregateVersion, 0)), a(n, t.REQUEST_ID, e.requestId), e.localFirst !== void 0 && (n[t.LOCAL_FIRST] = e.localFirst ? "true" : "false"), n;
|
|
19
|
+
}
|
|
20
|
+
function s(n) {
|
|
21
|
+
let o = {};
|
|
22
|
+
if (n.stage !== void 0 && (o[t.WAIT_STAGE] = r("stage", n.stage)), a(o, t.WAIT_CONTEXT, n.context), a(o, t.WAIT_PROCESSOR, n.processor), a(o, t.WAIT_FUNCTION, n.function), n.tail !== void 0) {
|
|
23
|
+
if (n.stage !== e.SAGA_HANDLED) throw TypeError("A wait tail needs the SAGA_HANDLED stage.");
|
|
24
|
+
o[t.WAIT_TAIL_STAGE] = r("tail.stage", n.tail.stage), a(o, t.WAIT_TAIL_CONTEXT, n.tail.context), a(o, t.WAIT_TAIL_PROCESSOR, n.tail.processor), a(o, t.WAIT_TAIL_FUNCTION, n.tail.function);
|
|
25
|
+
}
|
|
26
|
+
return n.timeoutMs !== void 0 && (o[t.WAIT_TIME_OUT] = i("timeoutMs", n.timeoutMs, 1)), o;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { o as commandHeaders, s as waitStrategy };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=commandRequest.es.js.map
|