@ahoo-wang/wow-client 10.0.0-alpha.3 → 10.0.0-alpha.5
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 +85 -230
- package/README.zh-CN.md +74 -209
- package/dist/commands.cjs +2 -0
- package/dist/commands.cjs.map +1 -0
- package/dist/{v10/commands.d.cts → commands.d.cts} +21 -3
- package/dist/{v10/commands.d.ts → commands.d.ts} +21 -3
- package/dist/commands.es.js +96 -0
- package/dist/commands.es.js.map +1 -0
- package/dist/dsl/aggregation/types.cjs.map +1 -1
- package/dist/dsl/aggregation/types.d.cts +1 -1
- package/dist/dsl/aggregation/types.d.ts +1 -1
- package/dist/dsl/aggregation/types.es.js.map +1 -1
- package/dist/dsl/cursorQuery.cjs.map +1 -1
- package/dist/dsl/cursorQuery.d.cts +7 -8
- package/dist/dsl/cursorQuery.d.ts +7 -8
- package/dist/dsl/cursorQuery.es.js.map +1 -1
- package/dist/dsl/descriptor.cjs.map +1 -1
- package/dist/dsl/descriptor.d.cts +1 -1
- package/dist/dsl/descriptor.d.ts +1 -1
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/dsl/documents.d.cts +1 -1
- package/dist/dsl/documents.d.ts +1 -1
- package/dist/dsl/filter/types.d.cts +2 -1
- package/dist/dsl/filter/types.d.ts +2 -1
- package/dist/dsl/projection.cjs.map +1 -1
- package/dist/dsl/projection.d.cts +22 -0
- package/dist/dsl/projection.d.ts +22 -0
- package/dist/dsl/projection.es.js.map +1 -1
- package/dist/dsl/queryErrorCodes.cjs +2 -0
- package/dist/dsl/queryErrorCodes.cjs.map +1 -0
- package/dist/{error → dsl}/queryErrorCodes.d.cts +25 -24
- package/dist/{error → dsl}/queryErrorCodes.d.ts +25 -24
- package/dist/{error → dsl}/queryErrorCodes.es.js +2 -1
- package/dist/{error/queryErrorCodes.cjs.map → dsl/queryErrorCodes.es.js.map} +1 -1
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.d.cts +1 -2
- package/dist/dsl.d.ts +1 -2
- package/dist/dsl.es.js +2 -3
- package/dist/exactJson.cjs +3 -0
- package/dist/exactJson.cjs.map +1 -0
- package/dist/exactJson.d.cts +54 -0
- package/dist/exactJson.d.ts +54 -0
- package/dist/exactJson.es.js +213 -0
- package/dist/exactJson.es.js.map +1 -0
- package/dist/http.cjs +2 -0
- package/dist/http.cjs.map +1 -0
- package/dist/{v10/http.d.cts → http.d.cts} +16 -7
- package/dist/{v10/http.d.ts → http.d.ts} +16 -7
- package/dist/http.es.js +77 -0
- package/dist/http.es.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +19 -17
- package/dist/index.d.ts +19 -17
- package/dist/index.es.js +10 -36
- package/dist/manifest.cjs.map +1 -0
- package/dist/{v10/manifest.es.js → manifest.es.js} +1 -1
- package/dist/manifest.es.js.map +1 -0
- package/dist/problem.cjs +2 -0
- package/dist/problem.cjs.map +1 -0
- package/dist/{v10/problem.d.cts → problem.d.cts} +51 -4
- package/dist/{v10/problem.d.ts → problem.d.ts} +51 -4
- package/dist/{v10/problem.es.js → problem.es.js} +30 -11
- package/dist/problem.es.js.map +1 -0
- package/dist/queries.cjs +2 -0
- package/dist/queries.cjs.map +1 -0
- package/dist/{v10/queries.d.cts → queries.d.cts} +63 -17
- package/dist/{v10/queries.d.ts → queries.d.ts} +63 -17
- package/dist/queries.es.js +112 -0
- package/dist/queries.es.js.map +1 -0
- package/dist/state.cjs +2 -0
- package/dist/state.cjs.map +1 -0
- package/dist/{v10/state.d.cts → state.d.cts} +26 -4
- package/dist/{v10/state.d.ts → state.d.ts} +26 -4
- package/dist/state.es.js +70 -0
- package/dist/state.es.js.map +1 -0
- package/dist/streams.cjs +2 -0
- package/dist/streams.cjs.map +1 -0
- package/dist/streams.d.cts +74 -0
- package/dist/streams.d.ts +74 -0
- package/dist/streams.es.js +103 -0
- package/dist/streams.es.js.map +1 -0
- package/dist/wait.cjs.map +1 -0
- package/dist/{v10/wait.es.js → wait.es.js} +1 -1
- package/dist/wait.es.js.map +1 -0
- package/dist/wire.cjs.map +1 -0
- package/dist/{v10/wire.d.cts → wire.d.cts} +32 -7
- package/dist/{v10/wire.d.ts → wire.d.ts} +32 -7
- package/dist/{v10/wire.es.js → wire.es.js} +1 -1
- package/dist/wire.es.js.map +1 -0
- package/package.json +4 -26
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.cjs +0 -1
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.es.js +0 -9
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.cjs +0 -1
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.es.js +0 -6
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.cjs +0 -1
- package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.es.js +0 -8
- package/dist/client/bindMethods.cjs +0 -2
- package/dist/client/bindMethods.cjs.map +0 -1
- package/dist/client/bindMethods.d.cts +0 -13
- package/dist/client/bindMethods.d.ts +0 -13
- package/dist/client/bindMethods.es.js +0 -19
- package/dist/client/bindMethods.es.js.map +0 -1
- package/dist/client/command/commandClient.cjs +0 -2
- package/dist/client/command/commandClient.cjs.map +0 -1
- package/dist/client/command/commandClient.d.cts +0 -67
- package/dist/client/command/commandClient.d.ts +0 -67
- package/dist/client/command/commandClient.es.js +0 -38
- package/dist/client/command/commandClient.es.js.map +0 -1
- package/dist/client/command/commandHeaders.cjs +0 -2
- package/dist/client/command/commandHeaders.cjs.map +0 -1
- package/dist/client/command/commandHeaders.d.cts +0 -75
- package/dist/client/command/commandHeaders.d.ts +0 -75
- package/dist/client/command/commandHeaders.es.js +0 -31
- package/dist/client/command/commandHeaders.es.js.map +0 -1
- package/dist/client/command/commandRequest.cjs +0 -2
- package/dist/client/command/commandRequest.cjs.map +0 -1
- package/dist/client/command/commandRequest.d.cts +0 -180
- package/dist/client/command/commandRequest.d.ts +0 -180
- package/dist/client/command/commandRequest.es.js +0 -31
- package/dist/client/command/commandRequest.es.js.map +0 -1
- package/dist/client/command/commandResult.d.cts +0 -15
- package/dist/client/command/commandResult.d.ts +0 -15
- package/dist/client/command/index.d.cts +0 -5
- package/dist/client/command/index.d.ts +0 -5
- package/dist/client/command/types.d.cts +0 -71
- package/dist/client/command/types.d.ts +0 -71
- package/dist/client/metadata/index.d.cts +0 -2
- package/dist/client/metadata/index.d.ts +0 -2
- package/dist/client/metadata/wowMetadata.d.cts +0 -48
- package/dist/client/metadata/wowMetadata.d.ts +0 -48
- package/dist/client/metadata/wowMetadataClient.cjs +0 -2
- package/dist/client/metadata/wowMetadataClient.cjs.map +0 -1
- package/dist/client/metadata/wowMetadataClient.d.cts +0 -23
- package/dist/client/metadata/wowMetadataClient.d.ts +0 -23
- package/dist/client/metadata/wowMetadataClient.es.js +0 -25
- package/dist/client/metadata/wowMetadataClient.es.js.map +0 -1
- package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs +0 -2
- package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs.map +0 -1
- package/dist/client/query/dataset/datasetDescriptorEndpoint.d.cts +0 -8
- package/dist/client/query/dataset/datasetDescriptorEndpoint.d.ts +0 -8
- package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js +0 -34
- package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js.map +0 -1
- package/dist/client/query/dataset/datasetDirectoryClient.cjs +0 -2
- package/dist/client/query/dataset/datasetDirectoryClient.cjs.map +0 -1
- package/dist/client/query/dataset/datasetDirectoryClient.d.cts +0 -29
- package/dist/client/query/dataset/datasetDirectoryClient.d.ts +0 -29
- package/dist/client/query/dataset/datasetDirectoryClient.es.js +0 -25
- package/dist/client/query/dataset/datasetDirectoryClient.es.js.map +0 -1
- package/dist/client/query/dataset/datasetQueryApi.d.cts +0 -40
- package/dist/client/query/dataset/datasetQueryApi.d.ts +0 -40
- package/dist/client/query/dataset/datasetQueryClient.cjs +0 -2
- package/dist/client/query/dataset/datasetQueryClient.cjs.map +0 -1
- package/dist/client/query/dataset/datasetQueryClient.d.cts +0 -57
- package/dist/client/query/dataset/datasetQueryClient.d.ts +0 -57
- package/dist/client/query/dataset/datasetQueryClient.es.js +0 -154
- package/dist/client/query/dataset/datasetQueryClient.es.js.map +0 -1
- package/dist/client/query/dataset/endpointPaths.cjs +0 -2
- package/dist/client/query/dataset/endpointPaths.cjs.map +0 -1
- package/dist/client/query/dataset/endpointPaths.d.cts +0 -9
- package/dist/client/query/dataset/endpointPaths.d.ts +0 -9
- package/dist/client/query/dataset/endpointPaths.es.js +0 -14
- package/dist/client/query/dataset/endpointPaths.es.js.map +0 -1
- package/dist/client/query/dataset/index.d.cts +0 -3
- package/dist/client/query/dataset/index.d.ts +0 -3
- package/dist/client/query/descriptor/descriptorEndpoints.cjs +0 -2
- package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +0 -1
- package/dist/client/query/descriptor/descriptorEndpoints.d.cts +0 -29
- package/dist/client/query/descriptor/descriptorEndpoints.d.ts +0 -29
- package/dist/client/query/descriptor/descriptorEndpoints.es.js +0 -69
- package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +0 -1
- package/dist/client/query/descriptor/endpointPaths.cjs +0 -2
- package/dist/client/query/descriptor/endpointPaths.cjs.map +0 -1
- package/dist/client/query/descriptor/endpointPaths.d.cts +0 -4
- package/dist/client/query/descriptor/endpointPaths.d.ts +0 -4
- package/dist/client/query/descriptor/endpointPaths.es.js +0 -9
- package/dist/client/query/descriptor/endpointPaths.es.js.map +0 -1
- package/dist/client/query/descriptor/index.d.cts +0 -2
- package/dist/client/query/descriptor/index.d.ts +0 -2
- package/dist/client/query/descriptor/queryDescriptorApi.d.cts +0 -58
- package/dist/client/query/descriptor/queryDescriptorApi.d.ts +0 -58
- package/dist/client/query/descriptor/queryDescriptorClient.cjs +0 -2
- package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +0 -1
- package/dist/client/query/descriptor/queryDescriptorClient.d.cts +0 -61
- package/dist/client/query/descriptor/queryDescriptorClient.d.ts +0 -61
- package/dist/client/query/descriptor/queryDescriptorClient.es.js +0 -20
- package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +0 -1
- package/dist/client/query/event/endpointPaths.cjs +0 -2
- package/dist/client/query/event/endpointPaths.cjs.map +0 -1
- package/dist/client/query/event/endpointPaths.d.cts +0 -8
- package/dist/client/query/event/endpointPaths.d.ts +0 -8
- package/dist/client/query/event/endpointPaths.es.js +0 -13
- package/dist/client/query/event/endpointPaths.es.js.map +0 -1
- package/dist/client/query/event/eventStreamQueryApi.d.cts +0 -29
- package/dist/client/query/event/eventStreamQueryApi.d.ts +0 -29
- package/dist/client/query/event/eventStreamQueryClient.cjs +0 -2
- package/dist/client/query/event/eventStreamQueryClient.cjs.map +0 -1
- package/dist/client/query/event/eventStreamQueryClient.d.cts +0 -193
- package/dist/client/query/event/eventStreamQueryClient.d.ts +0 -193
- package/dist/client/query/event/eventStreamQueryClient.es.js +0 -160
- package/dist/client/query/event/eventStreamQueryClient.es.js.map +0 -1
- package/dist/client/query/event/index.d.cts +0 -2
- package/dist/client/query/event/index.d.ts +0 -2
- package/dist/client/query/factory.cjs +0 -2
- package/dist/client/query/factory.cjs.map +0 -1
- package/dist/client/query/factory.d.cts +0 -165
- package/dist/client/query/factory.d.ts +0 -165
- package/dist/client/query/factory.es.js +0 -45
- package/dist/client/query/factory.es.js.map +0 -1
- package/dist/client/query/index.d.cts +0 -7
- package/dist/client/query/index.d.ts +0 -7
- package/dist/client/query/queryApi.d.cts +0 -68
- package/dist/client/query/queryApi.d.ts +0 -68
- package/dist/client/query/requests.d.cts +0 -24
- package/dist/client/query/requests.d.ts +0 -24
- package/dist/client/query/snapshot/endpointPaths.cjs +0 -2
- package/dist/client/query/snapshot/endpointPaths.cjs.map +0 -1
- package/dist/client/query/snapshot/endpointPaths.d.cts +0 -12
- package/dist/client/query/snapshot/endpointPaths.d.ts +0 -12
- package/dist/client/query/snapshot/endpointPaths.es.js +0 -17
- package/dist/client/query/snapshot/endpointPaths.es.js.map +0 -1
- package/dist/client/query/snapshot/index.d.cts +0 -2
- package/dist/client/query/snapshot/index.d.ts +0 -2
- package/dist/client/query/snapshot/snapshotQueryApi.d.cts +0 -101
- package/dist/client/query/snapshot/snapshotQueryApi.d.ts +0 -101
- package/dist/client/query/snapshot/snapshotQueryClient.cjs +0 -2
- package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +0 -1
- package/dist/client/query/snapshot/snapshotQueryClient.d.cts +0 -372
- package/dist/client/query/snapshot/snapshotQueryClient.d.ts +0 -372
- package/dist/client/query/snapshot/snapshotQueryClient.es.js +0 -239
- package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +0 -1
- package/dist/client/query/state/endpointPaths.cjs +0 -2
- package/dist/client/query/state/endpointPaths.cjs.map +0 -1
- package/dist/client/query/state/endpointPaths.d.cts +0 -10
- package/dist/client/query/state/endpointPaths.d.ts +0 -10
- package/dist/client/query/state/endpointPaths.es.js +0 -14
- package/dist/client/query/state/endpointPaths.es.js.map +0 -1
- package/dist/client/query/state/index.d.cts +0 -4
- package/dist/client/query/state/index.d.ts +0 -4
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +0 -36
- package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +0 -36
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +0 -2
- package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +0 -1
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +0 -58
- package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +0 -58
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +0 -56
- package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +0 -1
- package/dist/client/query/state/loadStateAggregateApi.d.cts +0 -37
- package/dist/client/query/state/loadStateAggregateApi.d.ts +0 -37
- package/dist/client/query/state/loadStateAggregateClient.cjs +0 -2
- package/dist/client/query/state/loadStateAggregateClient.cjs.map +0 -1
- package/dist/client/query/state/loadStateAggregateClient.d.cts +0 -62
- package/dist/client/query/state/loadStateAggregateClient.d.ts +0 -62
- package/dist/client/query/state/loadStateAggregateClient.es.js +0 -65
- package/dist/client/query/state/loadStateAggregateClient.es.js.map +0 -1
- package/dist/client/routing.cjs +0 -2
- package/dist/client/routing.cjs.map +0 -1
- package/dist/client/routing.d.cts +0 -47
- package/dist/client/routing.d.ts +0 -47
- package/dist/client/routing.es.js +0 -8
- package/dist/client/routing.es.js.map +0 -1
- package/dist/error/errorInfo.cjs +0 -2
- package/dist/error/errorInfo.cjs.map +0 -1
- package/dist/error/errorInfo.d.cts +0 -139
- package/dist/error/errorInfo.d.ts +0 -139
- package/dist/error/errorInfo.es.js +0 -32
- package/dist/error/errorInfo.es.js.map +0 -1
- package/dist/error/headers.cjs +0 -2
- package/dist/error/headers.cjs.map +0 -1
- package/dist/error/headers.d.cts +0 -39
- package/dist/error/headers.d.ts +0 -39
- package/dist/error/headers.es.js +0 -10
- package/dist/error/headers.es.js.map +0 -1
- package/dist/error/index.d.cts +0 -21
- package/dist/error/index.d.ts +0 -21
- package/dist/error/queryErrorCodes.cjs +0 -2
- package/dist/error/queryErrorCodes.es.js.map +0 -1
- package/dist/error/wowError.cjs +0 -2
- package/dist/error/wowError.cjs.map +0 -1
- package/dist/error/wowError.d.cts +0 -99
- package/dist/error/wowError.d.ts +0 -99
- package/dist/error/wowError.es.js +0 -53
- package/dist/error/wowError.es.js.map +0 -1
- package/dist/legacy/condition.cjs +0 -2
- package/dist/legacy/condition.cjs.map +0 -1
- package/dist/legacy/condition.d.cts +0 -517
- package/dist/legacy/condition.d.ts +0 -517
- package/dist/legacy/condition.es.js +0 -338
- package/dist/legacy/condition.es.js.map +0 -1
- package/dist/legacy/index.d.cts +0 -16
- package/dist/legacy/index.d.ts +0 -16
- package/dist/legacy/locale/en_US.cjs +0 -2
- package/dist/legacy/locale/en_US.cjs.map +0 -1
- package/dist/legacy/locale/en_US.d.cts +0 -7
- package/dist/legacy/locale/en_US.d.ts +0 -7
- package/dist/legacy/locale/en_US.es.js +0 -50
- package/dist/legacy/locale/en_US.es.js.map +0 -1
- package/dist/legacy/locale/operatorLocale.d.cts +0 -10
- package/dist/legacy/locale/operatorLocale.d.ts +0 -10
- package/dist/legacy/locale/zh_CN.cjs +0 -2
- package/dist/legacy/locale/zh_CN.cjs.map +0 -1
- package/dist/legacy/locale/zh_CN.d.cts +0 -7
- package/dist/legacy/locale/zh_CN.d.ts +0 -7
- package/dist/legacy/locale/zh_CN.es.js +0 -50
- package/dist/legacy/locale/zh_CN.es.js.map +0 -1
- package/dist/legacy/operator.cjs +0 -2
- package/dist/legacy/operator.cjs.map +0 -1
- package/dist/legacy/operator.d.cts +0 -218
- package/dist/legacy/operator.d.ts +0 -218
- package/dist/legacy/operator.es.js +0 -25
- package/dist/legacy/operator.es.js.map +0 -1
- package/dist/legacy/queryable.cjs +0 -2
- package/dist/legacy/queryable.cjs.map +0 -1
- package/dist/legacy/queryable.d.cts +0 -61
- package/dist/legacy/queryable.d.ts +0 -61
- package/dist/legacy/queryable.es.js +0 -34
- package/dist/legacy/queryable.es.js.map +0 -1
- package/dist/legacy.cjs +0 -1
- package/dist/legacy.es.js +0 -6
- package/dist/model/abac.cjs +0 -2
- package/dist/model/abac.cjs.map +0 -1
- package/dist/model/abac.d.cts +0 -33
- package/dist/model/abac.d.ts +0 -33
- package/dist/model/abac.es.js +0 -6
- package/dist/model/abac.es.js.map +0 -1
- package/dist/model/bi.cjs +0 -2
- package/dist/model/bi.cjs.map +0 -1
- package/dist/model/bi.d.cts +0 -12
- package/dist/model/bi.d.ts +0 -12
- package/dist/model/bi.es.js +0 -8
- package/dist/model/bi.es.js.map +0 -1
- package/dist/model/command.cjs +0 -2
- package/dist/model/command.cjs.map +0 -1
- package/dist/model/command.d.cts +0 -137
- package/dist/model/command.d.ts +0 -137
- package/dist/model/command.es.js +0 -8
- package/dist/model/command.es.js.map +0 -1
- package/dist/model/common.d.cts +0 -19
- package/dist/model/common.d.ts +0 -19
- package/dist/model/domainEventStream.cjs +0 -2
- package/dist/model/domainEventStream.cjs.map +0 -1
- package/dist/model/domainEventStream.d.cts +0 -109
- package/dist/model/domainEventStream.d.ts +0 -109
- package/dist/model/domainEventStream.es.js +0 -23
- package/dist/model/domainEventStream.es.js.map +0 -1
- package/dist/model/function.cjs +0 -2
- package/dist/model/function.cjs.map +0 -1
- package/dist/model/function.d.cts +0 -41
- package/dist/model/function.d.ts +0 -41
- package/dist/model/function.es.js +0 -8
- package/dist/model/function.es.js.map +0 -1
- package/dist/model/index.d.cts +0 -24
- package/dist/model/index.d.ts +0 -24
- package/dist/model/messaging.d.cts +0 -5
- package/dist/model/messaging.d.ts +0 -5
- package/dist/model/modeling.d.cts +0 -145
- package/dist/model/modeling.d.ts +0 -145
- package/dist/model/naming.d.cts +0 -27
- package/dist/model/naming.d.ts +0 -27
- package/dist/model/snapshot.cjs +0 -2
- package/dist/model/snapshot.cjs.map +0 -1
- package/dist/model/snapshot.d.cts +0 -53
- package/dist/model/snapshot.d.ts +0 -53
- package/dist/model/snapshot.es.js +0 -20
- package/dist/model/snapshot.es.js.map +0 -1
- package/dist/transport/endpoints.cjs +0 -2
- package/dist/transport/endpoints.cjs.map +0 -1
- package/dist/transport/endpoints.d.cts +0 -79
- package/dist/transport/endpoints.d.ts +0 -79
- package/dist/transport/endpoints.es.js +0 -14
- package/dist/transport/endpoints.es.js.map +0 -1
- package/dist/transport/eventStreams.cjs +0 -2
- package/dist/transport/eventStreams.cjs.map +0 -1
- package/dist/transport/eventStreams.d.cts +0 -25
- package/dist/transport/eventStreams.d.ts +0 -25
- package/dist/transport/eventStreams.es.js +0 -21
- package/dist/transport/eventStreams.es.js.map +0 -1
- package/dist/transport/index.d.cts +0 -1
- package/dist/transport/index.d.ts +0 -1
- package/dist/v10/commands.cjs +0 -2
- package/dist/v10/commands.cjs.map +0 -1
- package/dist/v10/commands.es.js +0 -68
- package/dist/v10/commands.es.js.map +0 -1
- package/dist/v10/http.cjs +0 -2
- package/dist/v10/http.cjs.map +0 -1
- package/dist/v10/http.es.js +0 -73
- package/dist/v10/http.es.js.map +0 -1
- package/dist/v10/index.d.cts +0 -19
- package/dist/v10/index.d.ts +0 -19
- package/dist/v10/manifest.cjs.map +0 -1
- package/dist/v10/manifest.es.js.map +0 -1
- package/dist/v10/problem.cjs +0 -2
- package/dist/v10/problem.cjs.map +0 -1
- package/dist/v10/problem.es.js.map +0 -1
- package/dist/v10/queries.cjs +0 -2
- package/dist/v10/queries.cjs.map +0 -1
- package/dist/v10/queries.es.js +0 -88
- package/dist/v10/queries.es.js.map +0 -1
- package/dist/v10/state.cjs +0 -2
- package/dist/v10/state.cjs.map +0 -1
- package/dist/v10/state.es.js +0 -51
- package/dist/v10/state.es.js.map +0 -1
- package/dist/v10/streams.cjs +0 -2
- package/dist/v10/streams.cjs.map +0 -1
- package/dist/v10/streams.d.cts +0 -14
- package/dist/v10/streams.d.ts +0 -14
- package/dist/v10/streams.es.js +0 -22
- package/dist/v10/streams.es.js.map +0 -1
- package/dist/v10/wait.cjs.map +0 -1
- package/dist/v10/wait.es.js.map +0 -1
- package/dist/v10/wire.cjs.map +0 -1
- package/dist/v10/wire.es.js.map +0 -1
- package/dist/v10.cjs +0 -1
- package/dist/v10.es.js +0 -9
- /package/dist/{v10/manifest.cjs → manifest.cjs} +0 -0
- /package/dist/{v10/manifest.d.cts → manifest.d.cts} +0 -0
- /package/dist/{v10/manifest.d.ts → manifest.d.ts} +0 -0
- /package/dist/{v10/wait.cjs → wait.cjs} +0 -0
- /package/dist/{v10/wait.d.cts → wait.d.cts} +0 -0
- /package/dist/{v10/wait.d.ts → wait.d.ts} +0 -0
- /package/dist/{v10/wire.cjs → wire.cjs} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TextNumbers } from './exactJson.cjs';
|
|
2
|
+
import { CommandResult } from './wire.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* The results of a command's event stream (`Accept: text/event-stream`), one
|
|
5
|
+
* per hop, each event named by its stage. A rejection or a failure after
|
|
6
|
+
* admission is the stream's last result, not an error.
|
|
7
|
+
*/
|
|
8
|
+
export type CommandResultStream<R = Record<string, unknown>> = ReadableStream<CommandResult<R>>;
|
|
9
|
+
/** The data of each event of `response`'s server-sent event stream. */
|
|
10
|
+
export declare function commandResults<R>(response: Response): CommandResultStream<R>;
|
|
11
|
+
/**
|
|
12
|
+
* Why a resumable streamed list ended (decision D253): `complete` once every
|
|
13
|
+
* record was sent; the others are the server's, and resumable: the stream ran
|
|
14
|
+
* for its hold time, its store had no query permit for its next chunk, or
|
|
15
|
+
* the node is stopping.
|
|
16
|
+
*/
|
|
17
|
+
export type StreamEndReason = 'complete' | 'hold-expired' | 'permit-reclaimed' | 'node-stopping';
|
|
18
|
+
/** The data of the `end` event that ends a resumable streamed list. */
|
|
19
|
+
export interface StreamEnd {
|
|
20
|
+
/** Why it ended. */
|
|
21
|
+
readonly reason: StreamEndReason | (string & {});
|
|
22
|
+
/** Whether asking again with `Last-Event-ID` goes on where it ended. */
|
|
23
|
+
readonly resumable: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** One record of a streamed list, with its position. */
|
|
26
|
+
export interface StreamedRow<T> {
|
|
27
|
+
/** The record. */
|
|
28
|
+
readonly record: T;
|
|
29
|
+
/**
|
|
30
|
+
* The record's position, its event's `id`: an opaque cursor token to
|
|
31
|
+
* resume after it ({@link StreamResumeOptions.lastEventId}). Absent from a
|
|
32
|
+
* list whose sort cannot order a cursor, which cannot be resumed.
|
|
33
|
+
*/
|
|
34
|
+
readonly position?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* How a streamed list resumes (decision D253). A stream the server ends with
|
|
38
|
+
* a resumable `end`, one cut off before its `end`, and one that fails with a
|
|
39
|
+
* retryable problem (a 429 after its `Retry-After`) are asked for again with
|
|
40
|
+
* `Last-Event-ID`, the position of the last record read, and go on strictly
|
|
41
|
+
* after it.
|
|
42
|
+
*/
|
|
43
|
+
export interface StreamResumeOptions {
|
|
44
|
+
/** Starts after this position: a {@link StreamedRow.position} read before. */
|
|
45
|
+
readonly lastEventId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* How many times in a row the stream may be resumed without a record in
|
|
48
|
+
* between before it fails with what stopped it; 5 by default, 0 never
|
|
49
|
+
* resumes.
|
|
50
|
+
*/
|
|
51
|
+
readonly maxRetries?: number;
|
|
52
|
+
/** The wait before the first such retry, doubled for each next; 200 ms by default. */
|
|
53
|
+
readonly initialDelayMs?: number;
|
|
54
|
+
/** The longest wait between retries; 10 s by default. */
|
|
55
|
+
readonly maxDelayMs?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The records of a resumable streamed list (decision D253), read from
|
|
59
|
+
* `response` and, each time the stream is to be resumed, from what `reopen`
|
|
60
|
+
* answers for the position of the last record read (none before the first),
|
|
61
|
+
* with how many records were read so far: `undefined` when no more are
|
|
62
|
+
* wanted. Each record comes with its position. An `error` event that is not
|
|
63
|
+
* retryable, a failure `reopen` cannot get past, and an abort of `signal`
|
|
64
|
+
* error the stream.
|
|
65
|
+
*
|
|
66
|
+
* @param response - The first response
|
|
67
|
+
* @param reopen - Asks for the stream again after a position
|
|
68
|
+
* @param options - How the stream resumes, and what cancels it
|
|
69
|
+
*/
|
|
70
|
+
export declare function resumableQueryRows<T>(response: Response, reopen: (lastEventId: string | undefined, received: number) => Promise<Response | undefined>, options?: StreamResumeOptions & {
|
|
71
|
+
readonly signal?: AbortSignal;
|
|
72
|
+
/** The numbers of each record read as their exact text (review R4-Q, Q-9). */
|
|
73
|
+
readonly numbers?: TextNumbers;
|
|
74
|
+
}): ReadableStream<StreamedRow<T>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TextNumbers } from './exactJson.js';
|
|
2
|
+
import { CommandResult } from './wire.js';
|
|
3
|
+
/**
|
|
4
|
+
* The results of a command's event stream (`Accept: text/event-stream`), one
|
|
5
|
+
* per hop, each event named by its stage. A rejection or a failure after
|
|
6
|
+
* admission is the stream's last result, not an error.
|
|
7
|
+
*/
|
|
8
|
+
export type CommandResultStream<R = Record<string, unknown>> = ReadableStream<CommandResult<R>>;
|
|
9
|
+
/** The data of each event of `response`'s server-sent event stream. */
|
|
10
|
+
export declare function commandResults<R>(response: Response): CommandResultStream<R>;
|
|
11
|
+
/**
|
|
12
|
+
* Why a resumable streamed list ended (decision D253): `complete` once every
|
|
13
|
+
* record was sent; the others are the server's, and resumable: the stream ran
|
|
14
|
+
* for its hold time, its store had no query permit for its next chunk, or
|
|
15
|
+
* the node is stopping.
|
|
16
|
+
*/
|
|
17
|
+
export type StreamEndReason = 'complete' | 'hold-expired' | 'permit-reclaimed' | 'node-stopping';
|
|
18
|
+
/** The data of the `end` event that ends a resumable streamed list. */
|
|
19
|
+
export interface StreamEnd {
|
|
20
|
+
/** Why it ended. */
|
|
21
|
+
readonly reason: StreamEndReason | (string & {});
|
|
22
|
+
/** Whether asking again with `Last-Event-ID` goes on where it ended. */
|
|
23
|
+
readonly resumable: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** One record of a streamed list, with its position. */
|
|
26
|
+
export interface StreamedRow<T> {
|
|
27
|
+
/** The record. */
|
|
28
|
+
readonly record: T;
|
|
29
|
+
/**
|
|
30
|
+
* The record's position, its event's `id`: an opaque cursor token to
|
|
31
|
+
* resume after it ({@link StreamResumeOptions.lastEventId}). Absent from a
|
|
32
|
+
* list whose sort cannot order a cursor, which cannot be resumed.
|
|
33
|
+
*/
|
|
34
|
+
readonly position?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* How a streamed list resumes (decision D253). A stream the server ends with
|
|
38
|
+
* a resumable `end`, one cut off before its `end`, and one that fails with a
|
|
39
|
+
* retryable problem (a 429 after its `Retry-After`) are asked for again with
|
|
40
|
+
* `Last-Event-ID`, the position of the last record read, and go on strictly
|
|
41
|
+
* after it.
|
|
42
|
+
*/
|
|
43
|
+
export interface StreamResumeOptions {
|
|
44
|
+
/** Starts after this position: a {@link StreamedRow.position} read before. */
|
|
45
|
+
readonly lastEventId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* How many times in a row the stream may be resumed without a record in
|
|
48
|
+
* between before it fails with what stopped it; 5 by default, 0 never
|
|
49
|
+
* resumes.
|
|
50
|
+
*/
|
|
51
|
+
readonly maxRetries?: number;
|
|
52
|
+
/** The wait before the first such retry, doubled for each next; 200 ms by default. */
|
|
53
|
+
readonly initialDelayMs?: number;
|
|
54
|
+
/** The longest wait between retries; 10 s by default. */
|
|
55
|
+
readonly maxDelayMs?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The records of a resumable streamed list (decision D253), read from
|
|
59
|
+
* `response` and, each time the stream is to be resumed, from what `reopen`
|
|
60
|
+
* answers for the position of the last record read (none before the first),
|
|
61
|
+
* with how many records were read so far: `undefined` when no more are
|
|
62
|
+
* wanted. Each record comes with its position. An `error` event that is not
|
|
63
|
+
* retryable, a failure `reopen` cannot get past, and an abort of `signal`
|
|
64
|
+
* error the stream.
|
|
65
|
+
*
|
|
66
|
+
* @param response - The first response
|
|
67
|
+
* @param reopen - Asks for the stream again after a position
|
|
68
|
+
* @param options - How the stream resumes, and what cancels it
|
|
69
|
+
*/
|
|
70
|
+
export declare function resumableQueryRows<T>(response: Response, reopen: (lastEventId: string | undefined, received: number) => Promise<Response | undefined>, options?: StreamResumeOptions & {
|
|
71
|
+
readonly signal?: AbortSignal;
|
|
72
|
+
/** The numbers of each record read as their exact text (review R4-Q, Q-9). */
|
|
73
|
+
readonly numbers?: TextNumbers;
|
|
74
|
+
}): ReadableStream<StreamedRow<T>>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { marksNothing as e, parseJson as t } from "./exactJson.es.js";
|
|
2
|
+
import { WowProblemError as n, isProblem as r } from "./problem.es.js";
|
|
3
|
+
import { toJsonServerSentEventStream as i, toServerSentEventStream as a } from "@ahoo-wang/fetcher-eventstream";
|
|
4
|
+
//#region src/streams.ts
|
|
5
|
+
var o = "row", s = "error", c = "end", l = "message";
|
|
6
|
+
function u(e) {
|
|
7
|
+
return i(a(e)).pipeThrough(new TransformStream({ transform(e, t) {
|
|
8
|
+
t.enqueue(e.data);
|
|
9
|
+
} }));
|
|
10
|
+
}
|
|
11
|
+
var d = "hold-expired", f = "complete";
|
|
12
|
+
function p(e, t) {
|
|
13
|
+
return new Promise((n, r) => {
|
|
14
|
+
let i = () => {
|
|
15
|
+
clearTimeout(a), r(t?.reason);
|
|
16
|
+
}, a = setTimeout(() => {
|
|
17
|
+
t?.removeEventListener("abort", i), n();
|
|
18
|
+
}, e);
|
|
19
|
+
t?.addEventListener("abort", i);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function m(e) {
|
|
23
|
+
return new n(r(e) ? e : {
|
|
24
|
+
type: "about:blank",
|
|
25
|
+
title: "Query failed",
|
|
26
|
+
status: 500
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function h(r, u, h = {}) {
|
|
30
|
+
let { maxRetries: g = 5, initialDelayMs: _ = 200, maxDelayMs: v = 1e4, signal: y } = h, b = h.numbers, x = (n) => (e(b) ? i(a(n)) : a(n).pipeThrough(new TransformStream({ transform(e, n) {
|
|
31
|
+
let r = e.event === o || e.event === l;
|
|
32
|
+
n.enqueue({
|
|
33
|
+
...e,
|
|
34
|
+
data: t(e.data, r ? b : void 0)
|
|
35
|
+
});
|
|
36
|
+
} }))).getReader(), S = x(r), C = h.lastEventId, w = 0, T = 0, E = !1;
|
|
37
|
+
async function D(e, t) {
|
|
38
|
+
for (;;) {
|
|
39
|
+
if (y?.aborted) throw y.reason;
|
|
40
|
+
if (T++ >= g) throw e;
|
|
41
|
+
let r = t ?? Math.min(v, _ * 2 ** (T - 1));
|
|
42
|
+
r > 0 && await p(r, y);
|
|
43
|
+
try {
|
|
44
|
+
let e = await u(C, w);
|
|
45
|
+
return e && (S = x(e)), e !== void 0;
|
|
46
|
+
} catch (r) {
|
|
47
|
+
if (y?.aborted || r instanceof n && !r.retry.retryable) throw r;
|
|
48
|
+
t = r.retry?.afterMs, e = r;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return new ReadableStream({
|
|
53
|
+
async pull(e) {
|
|
54
|
+
for (;;) {
|
|
55
|
+
let t, r;
|
|
56
|
+
try {
|
|
57
|
+
let n = await S.read();
|
|
58
|
+
if (n.done) t = /* @__PURE__ */ TypeError("The query stream was cut off.");
|
|
59
|
+
else {
|
|
60
|
+
let { event: i, id: a, data: u } = n.value;
|
|
61
|
+
if (i === o || i === l) {
|
|
62
|
+
a && (C = a), w++, T = 0, e.enqueue(a ? {
|
|
63
|
+
record: u,
|
|
64
|
+
position: a
|
|
65
|
+
} : { record: u });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (i === c) {
|
|
69
|
+
let n = u;
|
|
70
|
+
if (n.reason === f) {
|
|
71
|
+
e.close();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (t = /* @__PURE__ */ TypeError(`The query stream ended: ${n.reason}.`), !n.resumable) throw t;
|
|
75
|
+
n.reason === d && (r = 0);
|
|
76
|
+
} else if (i === s) {
|
|
77
|
+
let e = m(u);
|
|
78
|
+
if (!e.retry.retryable) throw e;
|
|
79
|
+
t = e, r = e.retry.afterMs;
|
|
80
|
+
} else continue;
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
if (e === t || e instanceof n) throw e;
|
|
84
|
+
t = e;
|
|
85
|
+
}
|
|
86
|
+
if (E) return;
|
|
87
|
+
if (y?.aborted) throw y.reason;
|
|
88
|
+
if (C === void 0 && w > 0) throw t;
|
|
89
|
+
if (!await D(t, r)) {
|
|
90
|
+
e.close();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
cancel(e) {
|
|
96
|
+
return E = !0, S.cancel(e);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { u as commandResults, h as resumableQueryRows };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=streams.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streams.es.js","names":["ROW_EVENT","ERROR_EVENT","END_EVENT","UNNAMED_EVENT","commandResults","toJsonServerSentEventStream","toServerSentEventStream","response","event","HOLD_EXPIRED","COMPLETE","sleep","abort","timer","reject","signal","resolve","ms","problemOf","WowProblemError","isProblem","data","resumableQueryRows","options","numbers","events","marksNothing","from","row","parseJson","reader","lastEventId","received","failures","cancelled","resume","maxRetries","cause","wait","delayMs","maxDelayMs","initialDelayMs","next","reopen","error","stop","id","controller","end","reason"],"sources":["../src/streams.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 {\n type JsonServerSentEvent,\n type ServerSentEvent,\n toJsonServerSentEventStream,\n toServerSentEventStream,\n} from '@ahoo-wang/fetcher-eventstream';\nimport { marksNothing, parseJson, type TextNumbers } from './exactJson.js';\nimport type { CommandResult } from './wire.js';\nimport { isProblem, WowProblemError } from './problem.js';\n\n/** The event of each record of a streamed query list. */\nconst ROW_EVENT = 'row';\n\n/** The event that ends a streamed query list that failed: the problem. */\nconst ERROR_EVENT = 'error';\n\n/** The event that ends a resumable streamed query list (decision D253). */\nconst END_EVENT = 'end';\n\n/** The name an event without one is read under. */\nconst UNNAMED_EVENT = 'message';\n\n/**\n * The results of a command's event stream (`Accept: text/event-stream`), one\n * per hop, each event named by its stage. A rejection or a failure after\n * admission is the stream's last result, not an error.\n */\nexport type CommandResultStream<R = Record<string, unknown>> = ReadableStream<\n CommandResult<R>\n>;\n\n/** The data of each event of `response`'s server-sent event stream. */\nexport function commandResults<R>(response: Response): CommandResultStream<R> {\n return toJsonServerSentEventStream<CommandResult<R>>(\n toServerSentEventStream(response),\n ).pipeThrough(\n new TransformStream<\n JsonServerSentEvent<CommandResult<R>>,\n CommandResult<R>\n >({\n transform(event, controller) {\n controller.enqueue(event.data);\n },\n }),\n );\n}\n\n/**\n * Why a resumable streamed list ended (decision D253): `complete` once every\n * record was sent; the others are the server's, and resumable: the stream ran\n * for its hold time, its store had no query permit for its next chunk, or\n * the node is stopping.\n */\nexport type StreamEndReason =\n 'complete' | 'hold-expired' | 'permit-reclaimed' | 'node-stopping';\n\n/** The data of the `end` event that ends a resumable streamed list. */\nexport interface StreamEnd {\n /** Why it ended. */\n readonly reason: StreamEndReason | (string & {});\n /** Whether asking again with `Last-Event-ID` goes on where it ended. */\n readonly resumable: boolean;\n}\n\n/** One record of a streamed list, with its position. */\nexport interface StreamedRow<T> {\n /** The record. */\n readonly record: T;\n /**\n * The record's position, its event's `id`: an opaque cursor token to\n * resume after it ({@link StreamResumeOptions.lastEventId}). Absent from a\n * list whose sort cannot order a cursor, which cannot be resumed.\n */\n readonly position?: string;\n}\n\n/**\n * How a streamed list resumes (decision D253). A stream the server ends with\n * a resumable `end`, one cut off before its `end`, and one that fails with a\n * retryable problem (a 429 after its `Retry-After`) are asked for again with\n * `Last-Event-ID`, the position of the last record read, and go on strictly\n * after it.\n */\nexport interface StreamResumeOptions {\n /** Starts after this position: a {@link StreamedRow.position} read before. */\n readonly lastEventId?: string;\n /**\n * How many times in a row the stream may be resumed without a record in\n * between before it fails with what stopped it; 5 by default, 0 never\n * resumes.\n */\n readonly maxRetries?: number;\n /** The wait before the first such retry, doubled for each next; 200 ms by default. */\n readonly initialDelayMs?: number;\n /** The longest wait between retries; 10 s by default. */\n readonly maxDelayMs?: number;\n}\n\nconst HOLD_EXPIRED: StreamEndReason = 'hold-expired';\nconst COMPLETE: StreamEndReason = 'complete';\n\n/** Waits `ms`, or rejects once `signal` aborts. */\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n const abort = () => {\n clearTimeout(timer);\n reject(signal?.reason);\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', abort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', abort);\n });\n}\n\nfunction problemOf(data: unknown): WowProblemError {\n return new WowProblemError(\n isProblem(data)\n ? data\n : { type: 'about:blank', title: 'Query failed', status: 500 },\n );\n}\n\n/**\n * The records of a resumable streamed list (decision D253), read from\n * `response` and, each time the stream is to be resumed, from what `reopen`\n * answers for the position of the last record read (none before the first),\n * with how many records were read so far: `undefined` when no more are\n * wanted. Each record comes with its position. An `error` event that is not\n * retryable, a failure `reopen` cannot get past, and an abort of `signal`\n * error the stream.\n *\n * @param response - The first response\n * @param reopen - Asks for the stream again after a position\n * @param options - How the stream resumes, and what cancels it\n */\nexport function resumableQueryRows<T>(\n response: Response,\n reopen: (\n lastEventId: string | undefined,\n received: number,\n ) => Promise<Response | undefined>,\n options: StreamResumeOptions & {\n readonly signal?: AbortSignal;\n /** The numbers of each record read as their exact text (review R4-Q, Q-9). */\n readonly numbers?: TextNumbers;\n } = {},\n): ReadableStream<StreamedRow<T>> {\n const {\n maxRetries = 5,\n initialDelayMs = 200,\n maxDelayMs = 10_000,\n signal,\n } = options;\n const numbers = options.numbers;\n const events = (from: Response) =>\n (marksNothing(numbers)\n ? toJsonServerSentEventStream<unknown>(toServerSentEventStream(from))\n : toServerSentEventStream(from).pipeThrough(\n new TransformStream<ServerSentEvent, JsonServerSentEvent<unknown>>({\n transform(event, controller) {\n const row =\n event.event === ROW_EVENT || event.event === UNNAMED_EVENT;\n controller.enqueue({\n ...event,\n data: parseJson(event.data, row ? numbers : undefined),\n });\n },\n }),\n )\n ).getReader();\n let reader = events(response);\n let lastEventId = options.lastEventId;\n let received = 0;\n let failures = 0;\n // Set once the reader cancels: a read in flight then ends, and must not be\n // taken for a cut-off stream to ask for again.\n let cancelled = false;\n\n /** Asks for the stream again, or throws `cause` once out of retries. */\n async function resume(cause: unknown, delayMs?: number): Promise<boolean> {\n for (;;) {\n if (signal?.aborted) throw signal.reason;\n if (failures++ >= maxRetries) throw cause;\n const wait =\n delayMs ?? Math.min(maxDelayMs, initialDelayMs * 2 ** (failures - 1));\n if (wait > 0) await sleep(wait, signal);\n try {\n const next = await reopen(lastEventId, received);\n if (next) reader = events(next);\n return next !== undefined;\n } catch (error) {\n if (\n signal?.aborted ||\n (error instanceof WowProblemError && !error.retry.retryable)\n ) {\n throw error;\n }\n delayMs = (error as WowProblemError).retry?.afterMs;\n cause = error;\n }\n }\n }\n\n return new ReadableStream<StreamedRow<T>>({\n async pull(controller) {\n for (;;) {\n let stop: unknown;\n let delayMs: number | undefined;\n try {\n const next = await reader.read();\n if (next.done) {\n // Every stream ends with `end`: one without was cut off.\n stop = new TypeError('The query stream was cut off.');\n } else {\n const { event, id, data } = next.value;\n if (event === ROW_EVENT || event === UNNAMED_EVENT) {\n if (id) lastEventId = id;\n received++;\n failures = 0;\n controller.enqueue(\n id\n ? { record: data as T, position: id }\n : { record: data as T },\n );\n return;\n }\n if (event === END_EVENT) {\n const end = data as StreamEnd;\n if (end.reason === COMPLETE) {\n controller.close();\n return;\n }\n stop = new TypeError(`The query stream ended: ${end.reason}.`);\n if (!end.resumable) throw stop;\n if (end.reason === HOLD_EXPIRED) delayMs = 0;\n } else if (event === ERROR_EVENT) {\n const error = problemOf(data);\n if (!error.retry.retryable) throw error;\n stop = error;\n delayMs = error.retry.afterMs;\n } else {\n continue;\n }\n }\n } catch (error) {\n if (error === stop || error instanceof WowProblemError) throw error;\n stop = error;\n }\n if (cancelled) return;\n // Only a stream read from the start, or whose records have positions, can be asked for again.\n if (signal?.aborted) throw signal.reason;\n if (lastEventId === undefined && received > 0) throw stop;\n if (!(await resume(stop, delayMs))) {\n controller.close();\n return;\n }\n }\n },\n cancel(reason) {\n cancelled = true;\n return reader.cancel(reason);\n },\n });\n}\n"],"mappings":";;;;AAwBA,IAAMA,IAAY,OAGZC,IAAc,SAGdC,IAAY,OAGZC,IAAgB;AAYtB,SAAgBC,EAAkB,GAA4C;CAC5E,OAAOC,EACLC,EAAwBC,CAAQ,CAClC,CAAC,CAAC,YACA,IAAI,gBAGF,EACA,UAAU,GAAO,GAAY;EAC3B,EAAW,QAAQC,EAAM,IAAI;CAC/B,EACF,CAAC,CACH;AACF;AAqDA,IAAMC,IAAgC,gBAChCC,IAA4B;AAGlC,SAASC,EAAM,GAAY,GAAqC;CAC9D,OAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAMC,UAAc;GAElB,AADA,aAAaC,CAAK,GAClBC,EAAOC,GAAQ,MAAM;EACvB,GACMF,IAAQ,iBAAiB;GAE7B,AADAE,GAAQ,oBAAoB,SAASH,CAAK,GAC1CI,EAAQ;EACV,GAAGC,CAAE;EACL,GAAQ,iBAAiB,SAASL,CAAK;CACzC,CAAC;AACH;AAEA,SAASM,EAAU,GAAgC;CACjD,OAAO,IAAIC,EACTC,EAAUC,CAAI,IACVA,IACA;EAAE,MAAM;EAAe,OAAO;EAAgB,QAAQ;CAAI,CAChE;AACF;AAeA,SAAgBC,EACd,GACA,GAIA,IAII,CAAC,GAC2B;CAChC,IAAM,EACJ,gBAAa,GACb,oBAAiB,KACjB,gBAAa,KACb,cACEC,GACEC,IAAUD,EAAQ,SAClBE,KAAU,OACbC,EAAaF,CAAO,IACjBnB,EAAqCC,EAAwBqB,CAAI,CAAC,IAClErB,EAAwBqB,CAAI,CAAC,CAAC,YAC5B,IAAI,gBAA+D,EACjE,UAAU,GAAO,GAAY;EAC3B,IAAMC,IACJpB,EAAM,UAAUR,KAAaQ,EAAM,UAAUL;EAC/C,EAAW,QAAQ;GACjB,GAAGK;GACH,MAAMqB,EAAUrB,EAAM,MAAMoB,IAAMJ,IAAU,KAAA,CAAS;EACvD,CAAC;CACH,EACF,CAAC,CACH,EAAA,CACF,UAAU,GACVM,IAASL,EAAOlB,CAAQ,GACxBwB,IAAcR,EAAQ,aACtBS,IAAW,GACXC,IAAW,GAGXC,IAAY;CAGhB,eAAeC,EAAO,GAAgB,GAAoC;EACxE,SAAS;GACP,IAAIpB,GAAQ,SAAS,MAAMA,EAAO;GAClC,IAAI,OAAcqB,GAAY,MAAMC;GACpC,IAAMC,IACJC,KAAW,KAAK,IAAIC,GAAYC,IAAiB,MAAMR,IAAW,EAAE;GACtE,AAAIK,IAAO,KAAG,MAAM3B,EAAM2B,GAAMvB,CAAM;GACtC,IAAI;IACF,IAAM2B,IAAO,MAAMC,EAAOZ,GAAaC,CAAQ;IAE/C,OADIU,MAAM,IAASjB,EAAOiB,CAAI,IACvBA,MAAS,KAAA;GAClB,SAASE,GAAO;IACd,IACE7B,GAAQ,WACP6B,aAAiBzB,KAAmB,CAACyB,EAAM,MAAM,WAElD,MAAMA;IAGR,AADA,IAAWA,EAA0B,OAAO,SAC5C,IAAQA;GACV;EACF;CACF;CAEA,OAAO,IAAI,eAA+B;EACxC,MAAM,KAAK,GAAY;GACrB,SAAS;IACP,IAAIC,GACAN;IACJ,IAAI;KACF,IAAMG,IAAO,MAAMZ,EAAO,KAAK;KAC/B,IAAIY,EAAK,MAEP,IAAO,gBAAI,UAAU,+BAA+B;UAC/C;MACL,IAAM,EAAE,UAAO,OAAI,YAASA,EAAK;MACjC,IAAIlC,MAAUR,KAAaQ,MAAUL,GAAe;OAIlD,AAHI2C,MAAI,IAAcA,IACtB,KACA,IAAW,GACXC,EAAW,QACTD,IACI;QAAE,QAAQzB;QAAW,UAAUyB;OAAG,IAClC,EAAE,QAAQzB,EAAU,CAC1B;OACA;MACF;MACA,IAAIb,MAAUN,GAAW;OACvB,IAAM8C,IAAM3B;OACZ,IAAI2B,EAAI,WAAWtC,GAAU;QAC3B,EAAW,MAAM;QACjB;OACF;OAEA,IADA,IAAO,gBAAI,UAAU,2BAA2BsC,EAAI,OAAO,EAAE,GACzD,CAACA,EAAI,WAAW,MAAMH;OAC1B,AAAIG,EAAI,WAAWvC,MAAc,IAAU;MAC7C,OAAO,IAAID,MAAUP,GAAa;OAChC,IAAM2C,IAAQ1B,EAAUG,CAAI;OAC5B,IAAI,CAACuB,EAAM,MAAM,WAAW,MAAMA;OAElC,AADA,IAAOA,GACP,IAAUA,EAAM,MAAM;MACxB,OACE;KAEJ;IACF,SAASA,GAAO;KACd,IAAIA,MAAUC,KAAQD,aAAiBzB,GAAiB,MAAMyB;KAC9D,IAAOA;IACT;IACA,IAAIV,GAAW;IAEf,IAAInB,GAAQ,SAAS,MAAMA,EAAO;IAClC,IAAIgB,MAAgB,KAAA,KAAaC,IAAW,GAAG,MAAMa;IACrD,IAAI,CAAE,MAAMV,EAAOU,GAAMN,CAAO,GAAI;KAClC,EAAW,MAAM;KACjB;IACF;GACF;EACF;EACA,OAAO,GAAQ;GAEb,OADA,IAAY,IACLT,EAAO,OAAOmB,CAAM;EAC7B;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.cjs","names":["Stage","require_wire","SNAPSHOT_SUBSCRIPTION","NAME","checkName","value","kind","hop","context","subscription","wait","formatHop","keyword","formatWaitPlan","plan","formatWaitTimeout","timeout"],"sources":["../src/wait.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 Hop, Stage } from './wire.js';\n\n/** The name of the built-in subscription that writes snapshots. */\nexport const SNAPSHOT_SUBSCRIPTION = 'snapshot';\n\nconst NAME = /^[A-Za-z0-9_.-]+$/;\n\nfunction checkName(kind: string, value: string): string {\n if (!NAME.test(value)) {\n throw new TypeError(`Not a ${kind} name: '${value}'.`);\n }\n return value;\n}\n\nfunction hop(stage: Stage, context?: string, subscription?: string): Hop {\n return {\n stage,\n ...(context === undefined\n ? {}\n : { context: checkName('context', context) }),\n ...(subscription === undefined\n ? {}\n : { subscription: checkName('subscription', subscription) }),\n };\n}\n\n/**\n * Builds the hops of a wait chain (decisions D62, D99). A context left out is\n * the command's own. A saga's `handled` hop may be followed by hops of the\n * commands it derived, in their contexts:\n *\n * @example\n * ```typescript\n * const plan = [\n * wait.committed(),\n * wait.handled('BasketCheckoutSaga.onBasketCheckedOut', 'eshop-basket'),\n * wait.committed('eshop-ordering'),\n * ];\n * ```\n */\nexport const wait = {\n /** Until the command passed admission; the route answers 202. */\n accepted: (context?: string): Hop => hop(Stage.ACCEPTED, context),\n /** Until the command's events are appended to the log. */\n committed: (context?: string): Hop => hop(Stage.COMMITTED, context),\n /** Until the snapshot holds the commit: the caller reads its own write. */\n snapshot: (context?: string): Hop =>\n hop(Stage.HANDLED, context, SNAPSHOT_SUBSCRIPTION),\n /** Until the subscription named `processor.function` handled the commit. */\n handled: (subscription: string, context?: string): Hop =>\n hop(Stage.HANDLED, context, subscription),\n} as const;\n\n/**\n * A hop as `Wow-Wait` spells it: `accepted`, `committed`, `snapshot` and\n * `handled(subscription)`, each with its context when it has one:\n * `committed(ctx)`, `snapshot(ctx)`, `handled(ctx/subscription)`.\n *\n * @param value - The hop\n */\nexport function formatHop(value: Hop): string {\n const context = value.context ?? undefined;\n const subscription = value.subscription ?? undefined;\n if (value.stage === Stage.HANDLED) {\n if (subscription === undefined) {\n throw new TypeError('A HANDLED hop names its subscription.');\n }\n if (subscription === SNAPSHOT_SUBSCRIPTION) {\n return context === undefined ? 'snapshot' : `snapshot(${context})`;\n }\n return context === undefined\n ? `handled(${subscription})`\n : `handled(${context}/${subscription})`;\n }\n if (subscription !== undefined) {\n throw new TypeError(`Only a HANDLED hop names a subscription.`);\n }\n const keyword = value.stage.toLowerCase();\n return context === undefined ? keyword : `${keyword}(${context})`;\n}\n\n/**\n * A wait plan as the `Wow-Wait` header spells it: its hops, in order,\n * separated by `>`. A string is taken as already spelled.\n *\n * @param plan - The hops, or the header's value\n */\nexport function formatWaitPlan(plan: readonly Hop[] | string): string {\n if (typeof plan === 'string') return plan;\n if (plan.length === 0) {\n throw new TypeError('A wait plan has at least one hop.');\n }\n return plan.map(formatHop).join(' > ');\n}\n\n/**\n * A wait timeout as the `Wow-Wait-Timeout` header spells it: milliseconds\n * as `<n>s` when whole seconds, else `<n>ms`. A string (`10s`, `PT10S`) is\n * taken as already spelled.\n *\n * @param timeout - Milliseconds, or the header's value\n */\nexport function formatWaitTimeout(timeout: number | string): string {\n if (typeof timeout === 'string') return timeout;\n if (!Number.isInteger(timeout) || timeout <= 0) {\n throw new TypeError(\n `A wait timeout is a positive whole number of milliseconds: ${timeout}.`,\n );\n }\n return timeout % 1000 === 0 ? `${timeout / 1000}s` : `${timeout}ms`;\n}\n\n/**\n * What a command waits for (`Wow-Wait`, `Wow-Wait-Timeout`). Without either,\n * the server waits for the snapshot, or for the commit where the aggregate\n * keeps no snapshot (decision D69), within its default timeout.\n */\nexport interface WaitOptions {\n /** The hops, or the `Wow-Wait` value. */\n readonly plan?: readonly Hop[] | string;\n /** Milliseconds, or the `Wow-Wait-Timeout` value. */\n readonly timeout?: number | string;\n}\n"],"mappings":"8BAgBA,IAAaE,EAAwB,WAE/BC,EAAO,oBAEb,SAASC,EAAU,EAAc,EAAuB,CACtD,GAAI,CAACD,EAAK,KAAKE,CAAK,EAClB,MAAU,UAAU,SAASC,EAAK,UAAUD,EAAM,GAAG,EAEvD,OAAOA,CACT,CAEA,SAASE,EAAI,EAAc,EAAkB,EAA4B,CACvE,MAAO,CACL,QACA,GAAIC,IAAY,IAAA,GACZ,CAAC,EACD,CAAE,QAASJ,EAAU,UAAWI,CAAO,CAAE,EAC7C,GAAIC,IAAiB,IAAA,GACjB,CAAC,EACD,CAAE,aAAcL,EAAU,eAAgBK,CAAY,CAAE,CAC9D,CACF,CAgBA,IAAaC,EAAO,CAElB,SAAW,GAA0BH,EAAIP,EAAAA,MAAM,SAAUQ,CAAO,EAEhE,UAAY,GAA0BD,EAAIP,EAAAA,MAAM,UAAWQ,CAAO,EAElE,SAAW,GACTD,EAAIP,EAAAA,MAAM,QAASQ,EAASN,CAAqB,EAEnD,SAAU,EAAsB,IAC9BK,EAAIP,EAAAA,MAAM,QAASQ,EAASC,CAAY,CAC5C,EASA,SAAgBE,EAAU,EAAoB,CAC5C,IAAMH,EAAUH,EAAM,SAAW,IAAA,GAC3BI,EAAeJ,EAAM,cAAgB,IAAA,GAC3C,GAAIA,EAAM,QAAUL,EAAAA,MAAM,QAAS,CACjC,GAAIS,IAAiB,IAAA,GACnB,MAAU,UAAU,uCAAuC,EAK7D,OAHIA,IAAA,WACKD,IAAY,IAAA,GAAY,WAAa,YAAYA,EAAQ,GAE3DA,IAAY,IAAA,GACf,WAAWC,EAAa,GACxB,WAAWD,EAAQ,GAAGC,EAAa,EACzC,CACA,GAAIA,IAAiB,IAAA,GACnB,MAAU,UAAU,0CAA0C,EAEhE,IAAMG,EAAUP,EAAM,MAAM,YAAY,EACxC,OAAOG,IAAY,IAAA,GAAYI,EAAU,GAAGA,EAAQ,GAAGJ,EAAQ,EACjE,CAQA,SAAgBK,EAAe,EAAuC,CACpE,GAAI,OAAOC,GAAS,SAAU,OAAOA,EACrC,GAAIA,EAAK,SAAW,EAClB,MAAU,UAAU,mCAAmC,EAEzD,OAAOA,EAAK,IAAIH,CAAS,CAAC,CAAC,KAAK,KAAK,CACvC,CASA,SAAgBI,EAAkB,EAAkC,CAClE,GAAI,OAAOC,GAAY,SAAU,OAAOA,EACxC,GAAI,CAAC,OAAO,UAAUA,CAAO,GAAKA,GAAW,EAC3C,MAAU,UACR,8DAA8DA,EAAQ,EACxE,EAEF,OAAOA,EAAU,KAAS,EAAI,GAAGA,EAAU,IAAK,GAAK,GAAGA,EAAQ,GAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait.es.js","names":["SNAPSHOT_SUBSCRIPTION","NAME","checkName","value","kind","hop","context","subscription","wait","Stage","formatHop","keyword","formatWaitPlan","plan","formatWaitTimeout","timeout"],"sources":["../src/wait.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 Hop, Stage } from './wire.js';\n\n/** The name of the built-in subscription that writes snapshots. */\nexport const SNAPSHOT_SUBSCRIPTION = 'snapshot';\n\nconst NAME = /^[A-Za-z0-9_.-]+$/;\n\nfunction checkName(kind: string, value: string): string {\n if (!NAME.test(value)) {\n throw new TypeError(`Not a ${kind} name: '${value}'.`);\n }\n return value;\n}\n\nfunction hop(stage: Stage, context?: string, subscription?: string): Hop {\n return {\n stage,\n ...(context === undefined\n ? {}\n : { context: checkName('context', context) }),\n ...(subscription === undefined\n ? {}\n : { subscription: checkName('subscription', subscription) }),\n };\n}\n\n/**\n * Builds the hops of a wait chain (decisions D62, D99). A context left out is\n * the command's own. A saga's `handled` hop may be followed by hops of the\n * commands it derived, in their contexts:\n *\n * @example\n * ```typescript\n * const plan = [\n * wait.committed(),\n * wait.handled('BasketCheckoutSaga.onBasketCheckedOut', 'eshop-basket'),\n * wait.committed('eshop-ordering'),\n * ];\n * ```\n */\nexport const wait = {\n /** Until the command passed admission; the route answers 202. */\n accepted: (context?: string): Hop => hop(Stage.ACCEPTED, context),\n /** Until the command's events are appended to the log. */\n committed: (context?: string): Hop => hop(Stage.COMMITTED, context),\n /** Until the snapshot holds the commit: the caller reads its own write. */\n snapshot: (context?: string): Hop =>\n hop(Stage.HANDLED, context, SNAPSHOT_SUBSCRIPTION),\n /** Until the subscription named `processor.function` handled the commit. */\n handled: (subscription: string, context?: string): Hop =>\n hop(Stage.HANDLED, context, subscription),\n} as const;\n\n/**\n * A hop as `Wow-Wait` spells it: `accepted`, `committed`, `snapshot` and\n * `handled(subscription)`, each with its context when it has one:\n * `committed(ctx)`, `snapshot(ctx)`, `handled(ctx/subscription)`.\n *\n * @param value - The hop\n */\nexport function formatHop(value: Hop): string {\n const context = value.context ?? undefined;\n const subscription = value.subscription ?? undefined;\n if (value.stage === Stage.HANDLED) {\n if (subscription === undefined) {\n throw new TypeError('A HANDLED hop names its subscription.');\n }\n if (subscription === SNAPSHOT_SUBSCRIPTION) {\n return context === undefined ? 'snapshot' : `snapshot(${context})`;\n }\n return context === undefined\n ? `handled(${subscription})`\n : `handled(${context}/${subscription})`;\n }\n if (subscription !== undefined) {\n throw new TypeError(`Only a HANDLED hop names a subscription.`);\n }\n const keyword = value.stage.toLowerCase();\n return context === undefined ? keyword : `${keyword}(${context})`;\n}\n\n/**\n * A wait plan as the `Wow-Wait` header spells it: its hops, in order,\n * separated by `>`. A string is taken as already spelled.\n *\n * @param plan - The hops, or the header's value\n */\nexport function formatWaitPlan(plan: readonly Hop[] | string): string {\n if (typeof plan === 'string') return plan;\n if (plan.length === 0) {\n throw new TypeError('A wait plan has at least one hop.');\n }\n return plan.map(formatHop).join(' > ');\n}\n\n/**\n * A wait timeout as the `Wow-Wait-Timeout` header spells it: milliseconds\n * as `<n>s` when whole seconds, else `<n>ms`. A string (`10s`, `PT10S`) is\n * taken as already spelled.\n *\n * @param timeout - Milliseconds, or the header's value\n */\nexport function formatWaitTimeout(timeout: number | string): string {\n if (typeof timeout === 'string') return timeout;\n if (!Number.isInteger(timeout) || timeout <= 0) {\n throw new TypeError(\n `A wait timeout is a positive whole number of milliseconds: ${timeout}.`,\n );\n }\n return timeout % 1000 === 0 ? `${timeout / 1000}s` : `${timeout}ms`;\n}\n\n/**\n * What a command waits for (`Wow-Wait`, `Wow-Wait-Timeout`). Without either,\n * the server waits for the snapshot, or for the commit where the aggregate\n * keeps no snapshot (decision D69), within its default timeout.\n */\nexport interface WaitOptions {\n /** The hops, or the `Wow-Wait` value. */\n readonly plan?: readonly Hop[] | string;\n /** Milliseconds, or the `Wow-Wait-Timeout` value. */\n readonly timeout?: number | string;\n}\n"],"mappings":";;AAgBA,IAAaA,IAAwB,YAE/BC,IAAO;AAEb,SAASC,EAAU,GAAc,GAAuB;CACtD,IAAI,CAACD,EAAK,KAAKE,CAAK,GAClB,MAAU,UAAU,SAASC,EAAK,UAAUD,EAAM,GAAG;CAEvD,OAAOA;AACT;AAEA,SAASE,EAAI,GAAc,GAAkB,GAA4B;CACvE,OAAO;EACL;EACA,GAAIC,MAAY,KAAA,IACZ,CAAC,IACD,EAAE,SAASJ,EAAU,WAAWI,CAAO,EAAE;EAC7C,GAAIC,MAAiB,KAAA,IACjB,CAAC,IACD,EAAE,cAAcL,EAAU,gBAAgBK,CAAY,EAAE;CAC9D;AACF;AAgBA,IAAaC,IAAO;CAElB,WAAW,MAA0BH,EAAII,EAAM,UAAUH,CAAO;CAEhE,YAAY,MAA0BD,EAAII,EAAM,WAAWH,CAAO;CAElE,WAAW,MACTD,EAAII,EAAM,SAASH,GAASN,CAAqB;CAEnD,UAAU,GAAsB,MAC9BK,EAAII,EAAM,SAASH,GAASC,CAAY;AAC5C;AASA,SAAgBG,EAAU,GAAoB;CAC5C,IAAMJ,IAAUH,EAAM,WAAW,KAAA,GAC3BI,IAAeJ,EAAM,gBAAgB,KAAA;CAC3C,IAAIA,EAAM,UAAUM,EAAM,SAAS;EACjC,IAAIF,MAAiB,KAAA,GACnB,MAAU,UAAU,uCAAuC;EAK7D,OAHIA,MAAA,aACKD,MAAY,KAAA,IAAY,aAAa,YAAYA,EAAQ,KAE3DA,MAAY,KAAA,IACf,WAAWC,EAAa,KACxB,WAAWD,EAAQ,GAAGC,EAAa;CACzC;CACA,IAAIA,MAAiB,KAAA,GACnB,MAAU,UAAU,0CAA0C;CAEhE,IAAMI,IAAUR,EAAM,MAAM,YAAY;CACxC,OAAOG,MAAY,KAAA,IAAYK,IAAU,GAAGA,EAAQ,GAAGL,EAAQ;AACjE;AAQA,SAAgBM,EAAe,GAAuC;CACpE,IAAI,OAAOC,KAAS,UAAU,OAAOA;CACrC,IAAIA,EAAK,WAAW,GAClB,MAAU,UAAU,mCAAmC;CAEzD,OAAOA,EAAK,IAAIH,CAAS,CAAC,CAAC,KAAK,KAAK;AACvC;AASA,SAAgBI,EAAkB,GAAkC;CAClE,IAAI,OAAOC,KAAY,UAAU,OAAOA;CACxC,IAAI,CAAC,OAAO,UAAUA,CAAO,KAAKA,KAAW,GAC3C,MAAU,UACR,8DAA8DA,EAAQ,EACxE;CAEF,OAAOA,IAAU,OAAS,IAAI,GAAGA,IAAU,IAAK,KAAK,GAAGA,EAAQ;AAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.cjs","names":["Stage"],"sources":["../src/wire.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 { TextNumbers } from './exactJson.js';\n\n/**\n * The wire model of a Wow service: what its routes answer, as the server\n * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query\n * records). Types and wire values only.\n */\n\n/** An aggregate type: its bounded context and its name. */\nexport interface AggregateType {\n readonly context: string;\n readonly name: string;\n /**\n * Which numbers of its states, events and commands are read and written\n * as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and\n * `decimal` fields of its Manifest, as wow-generator writes them.\n */\n readonly textNumbers?: AggregateTextNumbers;\n}\n\n/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */\nexport interface AggregateTextNumbers {\n /** Those of its state. */\n readonly state?: TextNumbers;\n /** Those of each event's body, by the event's name as the server sends it. */\n readonly events?: Readonly<Record<string, TextNumbers>>;\n /** Those of each command's body, by the command's name. */\n readonly commands?: Readonly<Record<string, TextNumbers>>;\n}\n\n/** One aggregate: its type, its tenant and its id. */\nexport interface AggregateRef {\n readonly type: AggregateType;\n readonly tenantId: string;\n readonly id: string;\n}\n\n/** The owner and the space an aggregate belongs to, beside its tenant. */\nexport interface Scope {\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n}\n\n/**\n * Who sent a command (decision D163): the opaque id of the authenticated\n * subject, its own tenant, and whether it acted in another tenant or scope.\n * Resolve the id to a display name in the application, never from Wow.\n */\nexport interface Operator {\n readonly id: string;\n readonly tenantId: string;\n readonly crossScope: boolean;\n}\n\n/** How far a command has come (decision D61). */\nexport const Stage = {\n /** The command passed admission. */\n ACCEPTED: 'ACCEPTED',\n /** The command's events are appended to the log. */\n COMMITTED: 'COMMITTED',\n /** A named subscription has handled the commit. */\n HANDLED: 'HANDLED',\n} as const;\n\n/** A {@link Stage} value. */\nexport type Stage = (typeof Stage)[keyof typeof Stage];\n\n/**\n * One hop of a wait chain (decision D62): a stage, in a context (the\n * command's own when absent), of a subscription when the stage is\n * `HANDLED`. The snapshot is the subscription named `snapshot`.\n */\nexport interface Hop {\n readonly stage: Stage;\n readonly context?: string | null;\n readonly subscription?: string | null;\n}\n\n/** The kind of function that produced a result. */\nexport type FunctionKind =\n | 'COMMAND'\n | 'PROJECT'\n | 'REACT'\n | 'SAGA'\n | 'SNAPSHOT'\n | 'RESERVATION'\n | 'TIMERS';\n\n/** Who produced a result: a function of `kind` in `context`. */\nexport interface FunctionInfo {\n readonly kind: FunctionKind;\n readonly context: string;\n readonly processor: string;\n readonly name: string;\n}\n\n/** A field-level validation error. */\nexport interface Violation {\n /** The path of the field, or the query part, that broke the rule. */\n readonly path: string;\n /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */\n readonly code: string;\n /** A human-readable message. */\n readonly message: string;\n}\n\n/** Why a command was rejected or failed. */\nexport interface ErrorInfo {\n /** A framework code (`wow.*`) or the domain's own. */\n readonly code: string;\n readonly message: string;\n readonly violations?: readonly Violation[];\n /**\n * The rejection's structured data (decision D211), which a problem\n * writes as its extension members.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** How a command ended at a hop. */\nexport type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';\n\n/**\n * The command a request named before a transformer turned it into the one\n * that ran (decision D182).\n */\nexport interface TransformedFrom {\n /** The full type name, `context.aggregate.Command`. */\n readonly command: string;\n readonly aggregateId?: string | null;\n}\n\n/**\n * The one outward result of a command (design 08 §7): what it reached at one\n * hop of its wait chain. A command route answers the last one; its event\n * stream sends one per hop.\n *\n * A chain can end before its plan does (decision D212): a hop, such as a\n * saga's that sent no command (a declined payment, say), leaves nothing to\n * reach the later hops. Its result is then the last one, at that hop with its\n * own status, `chainEnded` and the hops not reached in `pending`; a server\n * before D212 sends neither, so read them as `false` and empty when absent.\n *\n * @typeParam R - The shape of `results`, what the command's decide function\n * answered with.\n */\nexport interface CommandResult<R = Record<string, unknown>> {\n readonly format: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly correlationId: string;\n readonly ref: AggregateRef;\n readonly hop: Hop;\n readonly function: FunctionInfo;\n readonly status: CommandResultStatus;\n /** The aggregate's version after the commit, or the unchanged one. */\n readonly version?: number | null;\n /** The request was already committed: it was not decided again. */\n readonly duplicate: boolean;\n /** Set when `status` is `REJECTED` or `FAILED`. */\n readonly error?: ErrorInfo | null;\n readonly results: R;\n /** On a saga's hop, the ids of the commands it derived. */\n readonly derived: readonly string[];\n /** When it was produced, in epoch milliseconds. */\n readonly signalTime: number;\n readonly transformedFrom?: TransformedFrom | null;\n /**\n * The chain ended at this hop before its plan did (decision D212): the\n * hops in `pending` will not come.\n */\n readonly chainEnded?: boolean;\n /** When `chainEnded`, the hops of the plan not reached, in order. */\n readonly pending?: readonly Hop[];\n}\n\n/** The tags of an aggregate: names to values. */\nexport type Tags = Readonly<Record<string, readonly string[]>>;\n\n/**\n * An aggregate's state at a version (decision D40), as\n * `GET /{context}/{aggregate}/{id}/state` answers it.\n *\n * @typeParam S - The state's type.\n */\nexport interface StateView<S = unknown> {\n readonly ref: AggregateRef;\n readonly version: number;\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n}\n\n/**\n * An event as Wow reads it now: under its current name, upgraded to its latest revision. The `events` query gives\n * every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated\n * `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.\n *\n * @typeParam N - The event's name.\n * @typeParam B - The event's body.\n */\nexport interface EventView<N extends string = string, B = unknown> {\n readonly name: N;\n readonly revision: number;\n readonly body: B;\n}\n\n/** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */\nexport interface OwnerTransferred {\n readonly ownerId: string;\n}\n\n/** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */\nexport interface SpaceTransferred {\n readonly spaceId: string;\n}\n\n/** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */\nexport interface TagsApplied {\n readonly tags: Tags;\n}\n\n/**\n * The body of `wow.ScheduleSet` (decision D198): the aggregate set its\n * schedule `key`, to send `target` the command of type `commandType`\n * (`command` its JSON text) as `rule` says.\n */\nexport interface ScheduleSet {\n readonly key: string;\n readonly rule: ScheduleRule;\n readonly target: AggregateRef;\n readonly commandType: string;\n readonly command: string;\n}\n\n/** The body of `wow.ScheduleCancelled` (decision D198). */\nexport interface ScheduleCancelled {\n readonly key: string;\n}\n\n/**\n * The system events the kernel gives every aggregate (decisions D113, D198):\n * the lifecycle events and the schedule events. A state trace and an event\n * stream carry them beside the aggregate's own events, so the event union\n * `wow-generator` writes for an aggregate includes this one.\n */\nexport type SystemEvent =\n | EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>>\n | EventView<\n 'wow.lifecycle.AggregateRestored',\n Readonly<Record<string, never>>\n >\n | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred>\n | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred>\n | EventView<'wow.lifecycle.TagsApplied', TagsApplied>\n | EventView<'wow.ScheduleSet', ScheduleSet>\n | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;\n\n/**\n * One commit of a state trace (decision D40): the events of a version and the\n * aggregate after it.\n *\n * @typeParam S - The state's type.\n * @typeParam E - The events' type.\n */\nexport interface CommitView<S = unknown, E extends EventView = EventView> {\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly events: readonly E[];\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n readonly operator?: Operator | null;\n}\n\n/**\n * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate\n * and its commits in version order.\n */\nexport interface StateTrace<S = unknown, E extends EventView = EventView> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E>[];\n}\n\n/**\n * A record of the `snapshot` query model (decisions D128, D163): the\n * aggregate's system fields and its state.\n *\n * @typeParam S - The state's type.\n */\nexport interface SnapshotRecord<S = unknown> {\n readonly tenantId: string;\n readonly aggregateId: string;\n readonly version: number;\n readonly ownerId: string | null;\n readonly spaceId: string | null;\n readonly deleted: boolean;\n readonly tags: Tags;\n /** The first commit's time, in epoch milliseconds. */\n readonly firstEventTime: number;\n /** The last commit's time, in epoch milliseconds. */\n readonly lastEventTime: number;\n /** Who sent the last command; null for an anonymous caller. */\n readonly operator: Operator | null;\n /** Who created the aggregate; null for an anonymous caller. */\n readonly firstOperator: Operator | null;\n /**\n * The schedules the aggregate keeps (decision D198): each rule, `{type,\n * ...}`, by its key; absent from a server before 6.8c.\n */\n readonly schedules?: Readonly<Record<string, ScheduleRule>>;\n readonly state: S;\n}\n\n/**\n * The system fields of a snapshot record a query can filter, sort and\n * project on; a state field is `state.<path>`.\n */\nexport type SnapshotSystemField =\n | 'tenantId'\n | 'aggregateId'\n | 'version'\n | 'ownerId'\n | 'spaceId'\n | 'deleted'\n | 'tags'\n | 'firstEventTime'\n | 'lastEventTime'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'firstOperator'\n | 'firstOperator.id'\n | 'firstOperator.tenantId'\n | 'firstOperator.crossScope'\n | 'schedules';\n\n/** A schedule rule of a snapshot's `schedules` (decision D198). */\nexport interface ScheduleRule {\n /** The rule's type: `at`, `after`, `cron`, … */\n readonly type: string;\n readonly [property: string]: unknown;\n}\n\n/**\n * A record of the `events` query model (decision D131): one commit of one\n * aggregate and its events.\n *\n * @typeParam E - The events' type.\n */\nexport interface EventStreamRecord<E extends EventView = EventView> {\n readonly aggregateId: string;\n readonly tenantId: string;\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n /** Null when the stream has none (`Scope.NONE`). */\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n /** Null for an anonymous caller (decision D163). */\n readonly operator?: Operator | null;\n readonly events: readonly E[];\n}\n\n/**\n * The fields of an event stream record a query names (decision D235): its\n * system fields and `events`, the array an `elementMatch` filter and an\n * aggregation's `elements` reach an event through, by the event's own\n * `name`, `revision` and `body.*`.\n */\nexport type EventStreamField =\n | 'aggregateId'\n | 'tenantId'\n | 'version'\n | 'commitTime'\n | 'commandId'\n | 'requestId'\n | 'commandType'\n | 'ownerId'\n | 'spaceId'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'events';\n\n/** How an aggregate belongs to its callers (decision D189). */\nexport type Ownership = 'OWNER' | 'TENANT';\n\n/** One dataset of `GET /wow/dataset` (decision D145). */\nexport interface DatasetEntry {\n /** `{context}.{dataset}`. */\n readonly name: string;\n readonly context: string;\n readonly dataset: string;\n readonly title?: string | null;\n /** The path of its query route. */\n readonly path: string;\n}\n"],"mappings":"AAoEA,IAAaA,EAAQ,CAEnB,SAAU,WAEV,UAAW,YAEX,QAAS,SACX"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { TextNumbers } from './exactJson.cjs';
|
|
1
2
|
/**
|
|
2
|
-
* The wire model of a Wow
|
|
3
|
+
* The wire model of a Wow service: what its routes answer, as the server
|
|
3
4
|
* writes it (`wow-api`'s `CommandResult`, the edge's state views, the query
|
|
4
5
|
* records). Types and wire values only.
|
|
5
6
|
*/
|
|
@@ -7,6 +8,21 @@
|
|
|
7
8
|
export interface AggregateType {
|
|
8
9
|
readonly context: string;
|
|
9
10
|
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Which numbers of its states, events and commands are read and written
|
|
13
|
+
* as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and
|
|
14
|
+
* `decimal` fields of its Manifest, as wow-generator writes them.
|
|
15
|
+
*/
|
|
16
|
+
readonly textNumbers?: AggregateTextNumbers;
|
|
17
|
+
}
|
|
18
|
+
/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */
|
|
19
|
+
export interface AggregateTextNumbers {
|
|
20
|
+
/** Those of its state. */
|
|
21
|
+
readonly state?: TextNumbers;
|
|
22
|
+
/** Those of each event's body, by the event's name as the server sends it. */
|
|
23
|
+
readonly events?: Readonly<Record<string, TextNumbers>>;
|
|
24
|
+
/** Those of each command's body, by the command's name. */
|
|
25
|
+
readonly commands?: Readonly<Record<string, TextNumbers>>;
|
|
10
26
|
}
|
|
11
27
|
/** One aggregate: its type, its tenant and its id. */
|
|
12
28
|
export interface AggregateRef {
|
|
@@ -151,7 +167,9 @@ export interface StateView<S = unknown> {
|
|
|
151
167
|
readonly state: S;
|
|
152
168
|
}
|
|
153
169
|
/**
|
|
154
|
-
* An event as Wow reads it now, upgraded to its latest revision.
|
|
170
|
+
* An event as Wow reads it now: under its current name, upgraded to its latest revision. The `events` query gives
|
|
171
|
+
* every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated
|
|
172
|
+
* `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.
|
|
155
173
|
*
|
|
156
174
|
* @typeParam N - The event's name.
|
|
157
175
|
* @typeParam B - The event's body.
|
|
@@ -280,13 +298,20 @@ export interface EventStreamRecord<E extends EventView = EventView> {
|
|
|
280
298
|
readonly commandId: string;
|
|
281
299
|
readonly requestId: string;
|
|
282
300
|
readonly commandType: string;
|
|
283
|
-
|
|
284
|
-
readonly
|
|
285
|
-
readonly
|
|
301
|
+
/** Null when the stream has none (`Scope.NONE`). */
|
|
302
|
+
readonly ownerId?: string | null;
|
|
303
|
+
readonly spaceId?: string | null;
|
|
304
|
+
/** Null for an anonymous caller (decision D163). */
|
|
305
|
+
readonly operator?: Operator | null;
|
|
286
306
|
readonly events: readonly E[];
|
|
287
307
|
}
|
|
288
|
-
/**
|
|
289
|
-
|
|
308
|
+
/**
|
|
309
|
+
* The fields of an event stream record a query names (decision D235): its
|
|
310
|
+
* system fields and `events`, the array an `elementMatch` filter and an
|
|
311
|
+
* aggregation's `elements` reach an event through, by the event's own
|
|
312
|
+
* `name`, `revision` and `body.*`.
|
|
313
|
+
*/
|
|
314
|
+
export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime' | 'commandId' | 'requestId' | 'commandType' | 'ownerId' | 'spaceId' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.crossScope' | 'events';
|
|
290
315
|
/** How an aggregate belongs to its callers (decision D189). */
|
|
291
316
|
export type Ownership = 'OWNER' | 'TENANT';
|
|
292
317
|
/** One dataset of `GET /wow/dataset` (decision D145). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { TextNumbers } from './exactJson.js';
|
|
1
2
|
/**
|
|
2
|
-
* The wire model of a Wow
|
|
3
|
+
* The wire model of a Wow service: what its routes answer, as the server
|
|
3
4
|
* writes it (`wow-api`'s `CommandResult`, the edge's state views, the query
|
|
4
5
|
* records). Types and wire values only.
|
|
5
6
|
*/
|
|
@@ -7,6 +8,21 @@
|
|
|
7
8
|
export interface AggregateType {
|
|
8
9
|
readonly context: string;
|
|
9
10
|
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Which numbers of its states, events and commands are read and written
|
|
13
|
+
* as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and
|
|
14
|
+
* `decimal` fields of its Manifest, as wow-generator writes them.
|
|
15
|
+
*/
|
|
16
|
+
readonly textNumbers?: AggregateTextNumbers;
|
|
17
|
+
}
|
|
18
|
+
/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */
|
|
19
|
+
export interface AggregateTextNumbers {
|
|
20
|
+
/** Those of its state. */
|
|
21
|
+
readonly state?: TextNumbers;
|
|
22
|
+
/** Those of each event's body, by the event's name as the server sends it. */
|
|
23
|
+
readonly events?: Readonly<Record<string, TextNumbers>>;
|
|
24
|
+
/** Those of each command's body, by the command's name. */
|
|
25
|
+
readonly commands?: Readonly<Record<string, TextNumbers>>;
|
|
10
26
|
}
|
|
11
27
|
/** One aggregate: its type, its tenant and its id. */
|
|
12
28
|
export interface AggregateRef {
|
|
@@ -151,7 +167,9 @@ export interface StateView<S = unknown> {
|
|
|
151
167
|
readonly state: S;
|
|
152
168
|
}
|
|
153
169
|
/**
|
|
154
|
-
* An event as Wow reads it now, upgraded to its latest revision.
|
|
170
|
+
* An event as Wow reads it now: under its current name, upgraded to its latest revision. The `events` query gives
|
|
171
|
+
* every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated
|
|
172
|
+
* `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.
|
|
155
173
|
*
|
|
156
174
|
* @typeParam N - The event's name.
|
|
157
175
|
* @typeParam B - The event's body.
|
|
@@ -280,13 +298,20 @@ export interface EventStreamRecord<E extends EventView = EventView> {
|
|
|
280
298
|
readonly commandId: string;
|
|
281
299
|
readonly requestId: string;
|
|
282
300
|
readonly commandType: string;
|
|
283
|
-
|
|
284
|
-
readonly
|
|
285
|
-
readonly
|
|
301
|
+
/** Null when the stream has none (`Scope.NONE`). */
|
|
302
|
+
readonly ownerId?: string | null;
|
|
303
|
+
readonly spaceId?: string | null;
|
|
304
|
+
/** Null for an anonymous caller (decision D163). */
|
|
305
|
+
readonly operator?: Operator | null;
|
|
286
306
|
readonly events: readonly E[];
|
|
287
307
|
}
|
|
288
|
-
/**
|
|
289
|
-
|
|
308
|
+
/**
|
|
309
|
+
* The fields of an event stream record a query names (decision D235): its
|
|
310
|
+
* system fields and `events`, the array an `elementMatch` filter and an
|
|
311
|
+
* aggregation's `elements` reach an event through, by the event's own
|
|
312
|
+
* `name`, `revision` and `body.*`.
|
|
313
|
+
*/
|
|
314
|
+
export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime' | 'commandId' | 'requestId' | 'commandType' | 'ownerId' | 'spaceId' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.crossScope' | 'events';
|
|
290
315
|
/** How an aggregate belongs to its callers (decision D189). */
|
|
291
316
|
export type Ownership = 'OWNER' | 'TENANT';
|
|
292
317
|
/** One dataset of `GET /wow/dataset` (decision D145). */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire.es.js","names":["Stage"],"sources":["../src/wire.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 { TextNumbers } from './exactJson.js';\n\n/**\n * The wire model of a Wow service: what its routes answer, as the server\n * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query\n * records). Types and wire values only.\n */\n\n/** An aggregate type: its bounded context and its name. */\nexport interface AggregateType {\n readonly context: string;\n readonly name: string;\n /**\n * Which numbers of its states, events and commands are read and written\n * as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and\n * `decimal` fields of its Manifest, as wow-generator writes them.\n */\n readonly textNumbers?: AggregateTextNumbers;\n}\n\n/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */\nexport interface AggregateTextNumbers {\n /** Those of its state. */\n readonly state?: TextNumbers;\n /** Those of each event's body, by the event's name as the server sends it. */\n readonly events?: Readonly<Record<string, TextNumbers>>;\n /** Those of each command's body, by the command's name. */\n readonly commands?: Readonly<Record<string, TextNumbers>>;\n}\n\n/** One aggregate: its type, its tenant and its id. */\nexport interface AggregateRef {\n readonly type: AggregateType;\n readonly tenantId: string;\n readonly id: string;\n}\n\n/** The owner and the space an aggregate belongs to, beside its tenant. */\nexport interface Scope {\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n}\n\n/**\n * Who sent a command (decision D163): the opaque id of the authenticated\n * subject, its own tenant, and whether it acted in another tenant or scope.\n * Resolve the id to a display name in the application, never from Wow.\n */\nexport interface Operator {\n readonly id: string;\n readonly tenantId: string;\n readonly crossScope: boolean;\n}\n\n/** How far a command has come (decision D61). */\nexport const Stage = {\n /** The command passed admission. */\n ACCEPTED: 'ACCEPTED',\n /** The command's events are appended to the log. */\n COMMITTED: 'COMMITTED',\n /** A named subscription has handled the commit. */\n HANDLED: 'HANDLED',\n} as const;\n\n/** A {@link Stage} value. */\nexport type Stage = (typeof Stage)[keyof typeof Stage];\n\n/**\n * One hop of a wait chain (decision D62): a stage, in a context (the\n * command's own when absent), of a subscription when the stage is\n * `HANDLED`. The snapshot is the subscription named `snapshot`.\n */\nexport interface Hop {\n readonly stage: Stage;\n readonly context?: string | null;\n readonly subscription?: string | null;\n}\n\n/** The kind of function that produced a result. */\nexport type FunctionKind =\n | 'COMMAND'\n | 'PROJECT'\n | 'REACT'\n | 'SAGA'\n | 'SNAPSHOT'\n | 'RESERVATION'\n | 'TIMERS';\n\n/** Who produced a result: a function of `kind` in `context`. */\nexport interface FunctionInfo {\n readonly kind: FunctionKind;\n readonly context: string;\n readonly processor: string;\n readonly name: string;\n}\n\n/** A field-level validation error. */\nexport interface Violation {\n /** The path of the field, or the query part, that broke the rule. */\n readonly path: string;\n /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */\n readonly code: string;\n /** A human-readable message. */\n readonly message: string;\n}\n\n/** Why a command was rejected or failed. */\nexport interface ErrorInfo {\n /** A framework code (`wow.*`) or the domain's own. */\n readonly code: string;\n readonly message: string;\n readonly violations?: readonly Violation[];\n /**\n * The rejection's structured data (decision D211), which a problem\n * writes as its extension members.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** How a command ended at a hop. */\nexport type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';\n\n/**\n * The command a request named before a transformer turned it into the one\n * that ran (decision D182).\n */\nexport interface TransformedFrom {\n /** The full type name, `context.aggregate.Command`. */\n readonly command: string;\n readonly aggregateId?: string | null;\n}\n\n/**\n * The one outward result of a command (design 08 §7): what it reached at one\n * hop of its wait chain. A command route answers the last one; its event\n * stream sends one per hop.\n *\n * A chain can end before its plan does (decision D212): a hop, such as a\n * saga's that sent no command (a declined payment, say), leaves nothing to\n * reach the later hops. Its result is then the last one, at that hop with its\n * own status, `chainEnded` and the hops not reached in `pending`; a server\n * before D212 sends neither, so read them as `false` and empty when absent.\n *\n * @typeParam R - The shape of `results`, what the command's decide function\n * answered with.\n */\nexport interface CommandResult<R = Record<string, unknown>> {\n readonly format: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly correlationId: string;\n readonly ref: AggregateRef;\n readonly hop: Hop;\n readonly function: FunctionInfo;\n readonly status: CommandResultStatus;\n /** The aggregate's version after the commit, or the unchanged one. */\n readonly version?: number | null;\n /** The request was already committed: it was not decided again. */\n readonly duplicate: boolean;\n /** Set when `status` is `REJECTED` or `FAILED`. */\n readonly error?: ErrorInfo | null;\n readonly results: R;\n /** On a saga's hop, the ids of the commands it derived. */\n readonly derived: readonly string[];\n /** When it was produced, in epoch milliseconds. */\n readonly signalTime: number;\n readonly transformedFrom?: TransformedFrom | null;\n /**\n * The chain ended at this hop before its plan did (decision D212): the\n * hops in `pending` will not come.\n */\n readonly chainEnded?: boolean;\n /** When `chainEnded`, the hops of the plan not reached, in order. */\n readonly pending?: readonly Hop[];\n}\n\n/** The tags of an aggregate: names to values. */\nexport type Tags = Readonly<Record<string, readonly string[]>>;\n\n/**\n * An aggregate's state at a version (decision D40), as\n * `GET /{context}/{aggregate}/{id}/state` answers it.\n *\n * @typeParam S - The state's type.\n */\nexport interface StateView<S = unknown> {\n readonly ref: AggregateRef;\n readonly version: number;\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n}\n\n/**\n * An event as Wow reads it now: under its current name, upgraded to its latest revision. The `events` query gives\n * every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated\n * `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.\n *\n * @typeParam N - The event's name.\n * @typeParam B - The event's body.\n */\nexport interface EventView<N extends string = string, B = unknown> {\n readonly name: N;\n readonly revision: number;\n readonly body: B;\n}\n\n/** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */\nexport interface OwnerTransferred {\n readonly ownerId: string;\n}\n\n/** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */\nexport interface SpaceTransferred {\n readonly spaceId: string;\n}\n\n/** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */\nexport interface TagsApplied {\n readonly tags: Tags;\n}\n\n/**\n * The body of `wow.ScheduleSet` (decision D198): the aggregate set its\n * schedule `key`, to send `target` the command of type `commandType`\n * (`command` its JSON text) as `rule` says.\n */\nexport interface ScheduleSet {\n readonly key: string;\n readonly rule: ScheduleRule;\n readonly target: AggregateRef;\n readonly commandType: string;\n readonly command: string;\n}\n\n/** The body of `wow.ScheduleCancelled` (decision D198). */\nexport interface ScheduleCancelled {\n readonly key: string;\n}\n\n/**\n * The system events the kernel gives every aggregate (decisions D113, D198):\n * the lifecycle events and the schedule events. A state trace and an event\n * stream carry them beside the aggregate's own events, so the event union\n * `wow-generator` writes for an aggregate includes this one.\n */\nexport type SystemEvent =\n | EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>>\n | EventView<\n 'wow.lifecycle.AggregateRestored',\n Readonly<Record<string, never>>\n >\n | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred>\n | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred>\n | EventView<'wow.lifecycle.TagsApplied', TagsApplied>\n | EventView<'wow.ScheduleSet', ScheduleSet>\n | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;\n\n/**\n * One commit of a state trace (decision D40): the events of a version and the\n * aggregate after it.\n *\n * @typeParam S - The state's type.\n * @typeParam E - The events' type.\n */\nexport interface CommitView<S = unknown, E extends EventView = EventView> {\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly events: readonly E[];\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n readonly operator?: Operator | null;\n}\n\n/**\n * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate\n * and its commits in version order.\n */\nexport interface StateTrace<S = unknown, E extends EventView = EventView> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E>[];\n}\n\n/**\n * A record of the `snapshot` query model (decisions D128, D163): the\n * aggregate's system fields and its state.\n *\n * @typeParam S - The state's type.\n */\nexport interface SnapshotRecord<S = unknown> {\n readonly tenantId: string;\n readonly aggregateId: string;\n readonly version: number;\n readonly ownerId: string | null;\n readonly spaceId: string | null;\n readonly deleted: boolean;\n readonly tags: Tags;\n /** The first commit's time, in epoch milliseconds. */\n readonly firstEventTime: number;\n /** The last commit's time, in epoch milliseconds. */\n readonly lastEventTime: number;\n /** Who sent the last command; null for an anonymous caller. */\n readonly operator: Operator | null;\n /** Who created the aggregate; null for an anonymous caller. */\n readonly firstOperator: Operator | null;\n /**\n * The schedules the aggregate keeps (decision D198): each rule, `{type,\n * ...}`, by its key; absent from a server before 6.8c.\n */\n readonly schedules?: Readonly<Record<string, ScheduleRule>>;\n readonly state: S;\n}\n\n/**\n * The system fields of a snapshot record a query can filter, sort and\n * project on; a state field is `state.<path>`.\n */\nexport type SnapshotSystemField =\n | 'tenantId'\n | 'aggregateId'\n | 'version'\n | 'ownerId'\n | 'spaceId'\n | 'deleted'\n | 'tags'\n | 'firstEventTime'\n | 'lastEventTime'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'firstOperator'\n | 'firstOperator.id'\n | 'firstOperator.tenantId'\n | 'firstOperator.crossScope'\n | 'schedules';\n\n/** A schedule rule of a snapshot's `schedules` (decision D198). */\nexport interface ScheduleRule {\n /** The rule's type: `at`, `after`, `cron`, … */\n readonly type: string;\n readonly [property: string]: unknown;\n}\n\n/**\n * A record of the `events` query model (decision D131): one commit of one\n * aggregate and its events.\n *\n * @typeParam E - The events' type.\n */\nexport interface EventStreamRecord<E extends EventView = EventView> {\n readonly aggregateId: string;\n readonly tenantId: string;\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n /** Null when the stream has none (`Scope.NONE`). */\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n /** Null for an anonymous caller (decision D163). */\n readonly operator?: Operator | null;\n readonly events: readonly E[];\n}\n\n/**\n * The fields of an event stream record a query names (decision D235): its\n * system fields and `events`, the array an `elementMatch` filter and an\n * aggregation's `elements` reach an event through, by the event's own\n * `name`, `revision` and `body.*`.\n */\nexport type EventStreamField =\n | 'aggregateId'\n | 'tenantId'\n | 'version'\n | 'commitTime'\n | 'commandId'\n | 'requestId'\n | 'commandType'\n | 'ownerId'\n | 'spaceId'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'events';\n\n/** How an aggregate belongs to its callers (decision D189). */\nexport type Ownership = 'OWNER' | 'TENANT';\n\n/** One dataset of `GET /wow/dataset` (decision D145). */\nexport interface DatasetEntry {\n /** `{context}.{dataset}`. */\n readonly name: string;\n readonly context: string;\n readonly dataset: string;\n readonly title?: string | null;\n /** The path of its query route. */\n readonly path: string;\n}\n"],"mappings":";AAoEA,IAAaA,IAAQ;CAEnB,UAAU;CAEV,WAAW;CAEX,SAAS;AACX"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/wow-client",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
4
|
-
"description": "TypeScript client for Wow (https://github.com/Ahoo-Wang/Wow): commands, snapshot and
|
|
3
|
+
"version": "10.0.0-alpha.5",
|
|
4
|
+
"description": "TypeScript client for Wow (https://github.com/Ahoo-Wang/Wow): commands with their waits and event streams, state reads, snapshot, event and dataset queries, the Manifest and RFC 9457 problems, and the query DSL, built on Fetcher.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wow",
|
|
7
7
|
"wow-client",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"author": "Ahoo-Wang",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
|
-
"homepage": "https://
|
|
19
|
+
"homepage": "https://github.com/Ahoo-Wang/Wow/tree/main/typescript/wow-client#readme",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
22
|
"url": "git+https://github.com/Ahoo-Wang/Wow.git",
|
|
@@ -53,26 +53,6 @@
|
|
|
53
53
|
"default": "./dist/dsl.cjs"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"./legacy": {
|
|
57
|
-
"import": {
|
|
58
|
-
"types": "./dist/legacy/index.d.ts",
|
|
59
|
-
"default": "./dist/legacy.es.js"
|
|
60
|
-
},
|
|
61
|
-
"require": {
|
|
62
|
-
"types": "./dist/legacy/index.d.cts",
|
|
63
|
-
"default": "./dist/legacy.cjs"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"./v10": {
|
|
67
|
-
"import": {
|
|
68
|
-
"types": "./dist/v10/index.d.ts",
|
|
69
|
-
"default": "./dist/v10.es.js"
|
|
70
|
-
},
|
|
71
|
-
"require": {
|
|
72
|
-
"types": "./dist/v10/index.d.cts",
|
|
73
|
-
"default": "./dist/v10.cjs"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
56
|
"./package.json": "./package.json"
|
|
77
57
|
},
|
|
78
58
|
"files": [
|
|
@@ -83,19 +63,17 @@
|
|
|
83
63
|
"sideEffects": false,
|
|
84
64
|
"peerDependencies": {
|
|
85
65
|
"@ahoo-wang/fetcher": "^5.1.5 || ^6.0.0",
|
|
86
|
-
"@ahoo-wang/fetcher-decorator": "^5.1.5 || ^6.0.0",
|
|
87
66
|
"@ahoo-wang/fetcher-eventstream": "^5.1.5 || ^6.0.0"
|
|
88
67
|
},
|
|
89
68
|
"devDependencies": {
|
|
90
69
|
"@ahoo-wang/fetcher": "^6.0.1",
|
|
91
|
-
"@ahoo-wang/fetcher-decorator": "^6.0.1",
|
|
92
70
|
"@ahoo-wang/fetcher-eventstream": "^6.0.1",
|
|
93
71
|
"@eslint/js": "^10.0.1",
|
|
94
72
|
"@microsoft/api-extractor": "^7.59.4",
|
|
95
73
|
"@types/node": "^26.6.5",
|
|
96
74
|
"@vitest/coverage-v8": "4.1.11",
|
|
97
75
|
"@vitest/ui": "^4.1.11",
|
|
98
|
-
"eslint": "^10.
|
|
76
|
+
"eslint": "^10.13.0",
|
|
99
77
|
"globals": "^17.13.0",
|
|
100
78
|
"prettier": "3.9.9",
|
|
101
79
|
"typescript": "~6.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}exports.default=e;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
2
|
-
function e(e, t, n, r) {
|
|
3
|
-
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
4
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
5
|
-
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
6
|
-
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { e as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}exports.default=e;
|