@ahoo-wang/wow-client 10.0.0-alpha.3 → 10.0.0-alpha.4
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
|
@@ -32,12 +32,16 @@ export declare const FrameworkErrorCodes: {
|
|
|
32
32
|
readonly COMMAND_CONTENDED: "wow.command.contended";
|
|
33
33
|
/** 410: the aggregate is deleted; only RestoreAggregate applies. */
|
|
34
34
|
readonly AGGREGATE_DELETED: "wow.aggregate.deleted";
|
|
35
|
-
/** 429: the
|
|
35
|
+
/** 429: the command was not taken, its aggregate or the node being busy; retry later. */
|
|
36
36
|
readonly COMMAND_BUSY: "wow.command.busy";
|
|
37
37
|
/** 503: whether the command committed is unknown; retrying with the same request id is safe. */
|
|
38
38
|
readonly COMMAND_UNKNOWN: "wow.command.unknown";
|
|
39
|
+
/** 500: the command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */
|
|
40
|
+
readonly COMMAND_FAILED: "wow.command.failed";
|
|
39
41
|
/** 503: the node is shutting down; retry on another node. */
|
|
40
42
|
readonly NODE_CLOSING: "wow.node.closing";
|
|
43
|
+
/** 503: the node is on standby until a migration's cut-over; it serves reads only. */
|
|
44
|
+
readonly NODE_STANDBY: "wow.node.standby";
|
|
41
45
|
/** 503, with `Retry-After`: a store could not be reached in time; retry later. */
|
|
42
46
|
readonly STORAGE_UNAVAILABLE: "wow.storage.unavailable";
|
|
43
47
|
/** 503: a scheduled command arrived too long before its due time; it is sent again later. */
|
|
@@ -54,8 +58,27 @@ export declare const FrameworkErrorCodes: {
|
|
|
54
58
|
readonly QUERY_INVALID: "wow.query.invalid";
|
|
55
59
|
/** 500: the query backend failed to run the query. */
|
|
56
60
|
readonly QUERY_FAILED: "wow.query.failed";
|
|
57
|
-
/**
|
|
61
|
+
/** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */
|
|
58
62
|
readonly QUERY_TIMEOUT: "wow.query.timeout";
|
|
63
|
+
/** 429, with `Retry-After`: the query's store runs as many queries as it allows; retry later. */
|
|
64
|
+
readonly QUERY_BUSY: "wow.query.busy";
|
|
65
|
+
/**
|
|
66
|
+
* 404: a `single` query matched no record, whatever its model (review R4-Q,
|
|
67
|
+
* Q-4); a state read by id that finds none is `wow.aggregate.not-found`.
|
|
68
|
+
*/
|
|
69
|
+
readonly QUERY_NOT_FOUND: "wow.query.not-found";
|
|
70
|
+
/** 404: no dataset of that name is served to the caller. */
|
|
71
|
+
readonly QUERY_DATASET_NOT_FOUND: "wow.query.dataset-not-found";
|
|
72
|
+
/**
|
|
73
|
+
* 409, with `Retry-After`: a state read asked for a version (`minVersion`) the
|
|
74
|
+
* aggregate has not reached within the wait; the problem's `version` is its
|
|
75
|
+
* current one (review R4-Q, Q-13).
|
|
76
|
+
*/
|
|
77
|
+
readonly QUERY_MIN_VERSION_NOT_REACHED: "wow.query.min-version-not-reached";
|
|
78
|
+
/** 409: the dataset is served but cannot be queried now (it needs revision, decision D259). */
|
|
79
|
+
readonly QUERY_DATASET_UNAVAILABLE: "wow.query.dataset-unavailable";
|
|
80
|
+
/** 403: the calling service may not call this command (a synchronous call on the internal port, decision D226). */
|
|
81
|
+
readonly CALL_COMMAND_FORBIDDEN: "wow.call.command-forbidden";
|
|
59
82
|
};
|
|
60
83
|
/** A {@link FrameworkErrorCodes} value. */
|
|
61
84
|
export type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
|
|
@@ -64,7 +87,7 @@ export declare const FRAMEWORK_ERROR_PREFIX = "wow.";
|
|
|
64
87
|
/** The prefix of a problem's `type` that carries a Wow code. */
|
|
65
88
|
export declare const PROBLEM_TYPE_PREFIX = "urn:wow:error:";
|
|
66
89
|
/**
|
|
67
|
-
* An RFC 9457 problem as a Wow
|
|
90
|
+
* An RFC 9457 problem as a Wow service writes it (decisions D101, D102):
|
|
68
91
|
* `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is
|
|
69
92
|
* only HTTP's (a missing route, 406, 415).
|
|
70
93
|
*/
|
|
@@ -107,7 +130,7 @@ export interface RetryHint {
|
|
|
107
130
|
*/
|
|
108
131
|
export declare function retryHintOf(code: string | undefined, status: number, afterMs?: number): RetryHint;
|
|
109
132
|
/**
|
|
110
|
-
* A request a Wow
|
|
133
|
+
* A request a Wow service answered with a problem: a non-2xx response, a
|
|
111
134
|
* command result that did not succeed, or the `error` event that ends a
|
|
112
135
|
* streamed query.
|
|
113
136
|
*/
|
|
@@ -126,6 +149,12 @@ export declare class WowProblemError extends Error {
|
|
|
126
149
|
readonly retry: RetryHint;
|
|
127
150
|
/** The error this one explains: the fetcher's, or the stream's. */
|
|
128
151
|
readonly cause?: unknown;
|
|
152
|
+
/**
|
|
153
|
+
* The request id (`Wow-Request-Id`) of the command this answers: its
|
|
154
|
+
* result's, else the one the client sent. Retry with it when
|
|
155
|
+
* {@link RetryHint.sameRequestId} says so.
|
|
156
|
+
*/
|
|
157
|
+
get requestId(): string | undefined;
|
|
129
158
|
/**
|
|
130
159
|
* @param problem - The problem the server answered with
|
|
131
160
|
* @param options - The response's `Retry-After` in milliseconds, and the
|
|
@@ -138,6 +167,24 @@ export declare class WowProblemError extends Error {
|
|
|
138
167
|
/** Whether the code is a framework one (`wow.*`) rather than the domain's. */
|
|
139
168
|
get isFramework(): boolean;
|
|
140
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Remembers that the request that failed with `error` was sent with
|
|
172
|
+
* `requestId` (internal): {@link requestIdOf} answers it.
|
|
173
|
+
*
|
|
174
|
+
* @param error - What the request failed with
|
|
175
|
+
* @param requestId - The `Wow-Request-Id` it was sent with
|
|
176
|
+
*/
|
|
177
|
+
export declare function rememberRequestId(error: unknown, requestId: string): void;
|
|
178
|
+
/**
|
|
179
|
+
* The request id (`Wow-Request-Id`) a command that failed with `error` was
|
|
180
|
+
* sent with: also after a failure no server answered (the network, a proxy,
|
|
181
|
+
* an abort), so the command can be retried with the same id and the service
|
|
182
|
+
* answers a commit that did happen as a duplicate (decision D223).
|
|
183
|
+
* Undefined for an error of no command the client sent.
|
|
184
|
+
*
|
|
185
|
+
* @param error - What a command rejected with
|
|
186
|
+
*/
|
|
187
|
+
export declare function requestIdOf(error: unknown): string | undefined;
|
|
141
188
|
/** Whether `value` reads as a problem: an object with a numeric `status`. */
|
|
142
189
|
export declare function isProblem(value: unknown): value is Problem;
|
|
143
190
|
/**
|
|
@@ -32,12 +32,16 @@ export declare const FrameworkErrorCodes: {
|
|
|
32
32
|
readonly COMMAND_CONTENDED: "wow.command.contended";
|
|
33
33
|
/** 410: the aggregate is deleted; only RestoreAggregate applies. */
|
|
34
34
|
readonly AGGREGATE_DELETED: "wow.aggregate.deleted";
|
|
35
|
-
/** 429: the
|
|
35
|
+
/** 429: the command was not taken, its aggregate or the node being busy; retry later. */
|
|
36
36
|
readonly COMMAND_BUSY: "wow.command.busy";
|
|
37
37
|
/** 503: whether the command committed is unknown; retrying with the same request id is safe. */
|
|
38
38
|
readonly COMMAND_UNKNOWN: "wow.command.unknown";
|
|
39
|
+
/** 500: the command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */
|
|
40
|
+
readonly COMMAND_FAILED: "wow.command.failed";
|
|
39
41
|
/** 503: the node is shutting down; retry on another node. */
|
|
40
42
|
readonly NODE_CLOSING: "wow.node.closing";
|
|
43
|
+
/** 503: the node is on standby until a migration's cut-over; it serves reads only. */
|
|
44
|
+
readonly NODE_STANDBY: "wow.node.standby";
|
|
41
45
|
/** 503, with `Retry-After`: a store could not be reached in time; retry later. */
|
|
42
46
|
readonly STORAGE_UNAVAILABLE: "wow.storage.unavailable";
|
|
43
47
|
/** 503: a scheduled command arrived too long before its due time; it is sent again later. */
|
|
@@ -54,8 +58,27 @@ export declare const FrameworkErrorCodes: {
|
|
|
54
58
|
readonly QUERY_INVALID: "wow.query.invalid";
|
|
55
59
|
/** 500: the query backend failed to run the query. */
|
|
56
60
|
readonly QUERY_FAILED: "wow.query.failed";
|
|
57
|
-
/**
|
|
61
|
+
/** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */
|
|
58
62
|
readonly QUERY_TIMEOUT: "wow.query.timeout";
|
|
63
|
+
/** 429, with `Retry-After`: the query's store runs as many queries as it allows; retry later. */
|
|
64
|
+
readonly QUERY_BUSY: "wow.query.busy";
|
|
65
|
+
/**
|
|
66
|
+
* 404: a `single` query matched no record, whatever its model (review R4-Q,
|
|
67
|
+
* Q-4); a state read by id that finds none is `wow.aggregate.not-found`.
|
|
68
|
+
*/
|
|
69
|
+
readonly QUERY_NOT_FOUND: "wow.query.not-found";
|
|
70
|
+
/** 404: no dataset of that name is served to the caller. */
|
|
71
|
+
readonly QUERY_DATASET_NOT_FOUND: "wow.query.dataset-not-found";
|
|
72
|
+
/**
|
|
73
|
+
* 409, with `Retry-After`: a state read asked for a version (`minVersion`) the
|
|
74
|
+
* aggregate has not reached within the wait; the problem's `version` is its
|
|
75
|
+
* current one (review R4-Q, Q-13).
|
|
76
|
+
*/
|
|
77
|
+
readonly QUERY_MIN_VERSION_NOT_REACHED: "wow.query.min-version-not-reached";
|
|
78
|
+
/** 409: the dataset is served but cannot be queried now (it needs revision, decision D259). */
|
|
79
|
+
readonly QUERY_DATASET_UNAVAILABLE: "wow.query.dataset-unavailable";
|
|
80
|
+
/** 403: the calling service may not call this command (a synchronous call on the internal port, decision D226). */
|
|
81
|
+
readonly CALL_COMMAND_FORBIDDEN: "wow.call.command-forbidden";
|
|
59
82
|
};
|
|
60
83
|
/** A {@link FrameworkErrorCodes} value. */
|
|
61
84
|
export type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
|
|
@@ -64,7 +87,7 @@ export declare const FRAMEWORK_ERROR_PREFIX = "wow.";
|
|
|
64
87
|
/** The prefix of a problem's `type` that carries a Wow code. */
|
|
65
88
|
export declare const PROBLEM_TYPE_PREFIX = "urn:wow:error:";
|
|
66
89
|
/**
|
|
67
|
-
* An RFC 9457 problem as a Wow
|
|
90
|
+
* An RFC 9457 problem as a Wow service writes it (decisions D101, D102):
|
|
68
91
|
* `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is
|
|
69
92
|
* only HTTP's (a missing route, 406, 415).
|
|
70
93
|
*/
|
|
@@ -107,7 +130,7 @@ export interface RetryHint {
|
|
|
107
130
|
*/
|
|
108
131
|
export declare function retryHintOf(code: string | undefined, status: number, afterMs?: number): RetryHint;
|
|
109
132
|
/**
|
|
110
|
-
* A request a Wow
|
|
133
|
+
* A request a Wow service answered with a problem: a non-2xx response, a
|
|
111
134
|
* command result that did not succeed, or the `error` event that ends a
|
|
112
135
|
* streamed query.
|
|
113
136
|
*/
|
|
@@ -126,6 +149,12 @@ export declare class WowProblemError extends Error {
|
|
|
126
149
|
readonly retry: RetryHint;
|
|
127
150
|
/** The error this one explains: the fetcher's, or the stream's. */
|
|
128
151
|
readonly cause?: unknown;
|
|
152
|
+
/**
|
|
153
|
+
* The request id (`Wow-Request-Id`) of the command this answers: its
|
|
154
|
+
* result's, else the one the client sent. Retry with it when
|
|
155
|
+
* {@link RetryHint.sameRequestId} says so.
|
|
156
|
+
*/
|
|
157
|
+
get requestId(): string | undefined;
|
|
129
158
|
/**
|
|
130
159
|
* @param problem - The problem the server answered with
|
|
131
160
|
* @param options - The response's `Retry-After` in milliseconds, and the
|
|
@@ -138,6 +167,24 @@ export declare class WowProblemError extends Error {
|
|
|
138
167
|
/** Whether the code is a framework one (`wow.*`) rather than the domain's. */
|
|
139
168
|
get isFramework(): boolean;
|
|
140
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Remembers that the request that failed with `error` was sent with
|
|
172
|
+
* `requestId` (internal): {@link requestIdOf} answers it.
|
|
173
|
+
*
|
|
174
|
+
* @param error - What the request failed with
|
|
175
|
+
* @param requestId - The `Wow-Request-Id` it was sent with
|
|
176
|
+
*/
|
|
177
|
+
export declare function rememberRequestId(error: unknown, requestId: string): void;
|
|
178
|
+
/**
|
|
179
|
+
* The request id (`Wow-Request-Id`) a command that failed with `error` was
|
|
180
|
+
* sent with: also after a failure no server answered (the network, a proxy,
|
|
181
|
+
* an abort), so the command can be retried with the same id and the service
|
|
182
|
+
* answers a commit that did happen as a duplicate (decision D223).
|
|
183
|
+
* Undefined for an error of no command the client sent.
|
|
184
|
+
*
|
|
185
|
+
* @param error - What a command rejected with
|
|
186
|
+
*/
|
|
187
|
+
export declare function requestIdOf(error: unknown): string | undefined;
|
|
141
188
|
/** Whether `value` reads as a problem: an object with a numeric `status`. */
|
|
142
189
|
export declare function isProblem(value: unknown): value is Problem;
|
|
143
190
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/problem.ts
|
|
2
2
|
var e = {
|
|
3
3
|
AUTH_UNAUTHENTICATED: "wow.auth.unauthenticated",
|
|
4
4
|
AUTH_FORBIDDEN: "wow.auth.forbidden",
|
|
@@ -15,7 +15,9 @@ var e = {
|
|
|
15
15
|
AGGREGATE_DELETED: "wow.aggregate.deleted",
|
|
16
16
|
COMMAND_BUSY: "wow.command.busy",
|
|
17
17
|
COMMAND_UNKNOWN: "wow.command.unknown",
|
|
18
|
+
COMMAND_FAILED: "wow.command.failed",
|
|
18
19
|
NODE_CLOSING: "wow.node.closing",
|
|
20
|
+
NODE_STANDBY: "wow.node.standby",
|
|
19
21
|
STORAGE_UNAVAILABLE: "wow.storage.unavailable",
|
|
20
22
|
SCHEDULE_NOT_DUE: "wow.schedule.not-due",
|
|
21
23
|
SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid",
|
|
@@ -24,7 +26,13 @@ var e = {
|
|
|
24
26
|
QUERY_MALFORMED: "wow.query.malformed",
|
|
25
27
|
QUERY_INVALID: "wow.query.invalid",
|
|
26
28
|
QUERY_FAILED: "wow.query.failed",
|
|
27
|
-
QUERY_TIMEOUT: "wow.query.timeout"
|
|
29
|
+
QUERY_TIMEOUT: "wow.query.timeout",
|
|
30
|
+
QUERY_BUSY: "wow.query.busy",
|
|
31
|
+
QUERY_NOT_FOUND: "wow.query.not-found",
|
|
32
|
+
QUERY_DATASET_NOT_FOUND: "wow.query.dataset-not-found",
|
|
33
|
+
QUERY_MIN_VERSION_NOT_REACHED: "wow.query.min-version-not-reached",
|
|
34
|
+
QUERY_DATASET_UNAVAILABLE: "wow.query.dataset-unavailable",
|
|
35
|
+
CALL_COMMAND_FORBIDDEN: "wow.call.command-forbidden"
|
|
28
36
|
}, t = "wow.", n = "urn:wow:error:", r = /* @__PURE__ */ new Set([
|
|
29
37
|
"type",
|
|
30
38
|
"title",
|
|
@@ -47,10 +55,12 @@ function i(e) {
|
|
|
47
55
|
var a = /* @__PURE__ */ new Map([
|
|
48
56
|
[e.COMMAND_UNKNOWN, !0],
|
|
49
57
|
[e.NODE_CLOSING, !0],
|
|
58
|
+
[e.NODE_STANDBY, !0],
|
|
50
59
|
[e.STORAGE_UNAVAILABLE, !0],
|
|
51
60
|
[e.SCHEDULE_NOT_DUE, !0],
|
|
52
|
-
[e.QUERY_TIMEOUT, !1],
|
|
53
61
|
[e.COMMAND_BUSY, !0],
|
|
62
|
+
[e.QUERY_BUSY, !1],
|
|
63
|
+
[e.QUERY_MIN_VERSION_NOT_REACHED, !1],
|
|
54
64
|
[e.COMMAND_CONTENDED, !0],
|
|
55
65
|
[e.WAIT_TIMEOUT, !0]
|
|
56
66
|
]);
|
|
@@ -63,29 +73,38 @@ function o(e, t, n) {
|
|
|
63
73
|
};
|
|
64
74
|
}
|
|
65
75
|
var s = class extends Error {
|
|
76
|
+
get requestId() {
|
|
77
|
+
return this.result?.requestId ?? c.get(this);
|
|
78
|
+
}
|
|
66
79
|
constructor(e, t = {}) {
|
|
67
80
|
super(e.code ? `[${e.code}] ${e.detail ?? e.title}` : `${e.status} ${e.detail ?? e.title}`), this.name = "WowProblemError", this.problem = i(e), this.status = e.status, e.code !== void 0 && (this.code = e.code), this.violations = e.violations ?? [], e.result !== void 0 && (this.result = e.result), this.retry = o(e.code, e.status, t.retryAfterMs), t.cause !== void 0 && (this.cause = t.cause);
|
|
68
81
|
}
|
|
69
82
|
get isFramework() {
|
|
70
83
|
return this.code?.startsWith("wow.") ?? !1;
|
|
71
84
|
}
|
|
72
|
-
};
|
|
73
|
-
function
|
|
85
|
+
}, c = /* @__PURE__ */ new WeakMap();
|
|
86
|
+
function l(e, t) {
|
|
87
|
+
(typeof e == "object" && e || typeof e == "function") && (c.has(e) || c.set(e, t));
|
|
88
|
+
}
|
|
89
|
+
function u(e) {
|
|
90
|
+
return e instanceof s ? e.requestId : typeof e == "object" && e || typeof e == "function" ? c.get(e) : void 0;
|
|
91
|
+
}
|
|
92
|
+
function d(e) {
|
|
74
93
|
return typeof e == "object" && !!e && typeof e.status == "number";
|
|
75
94
|
}
|
|
76
|
-
function
|
|
95
|
+
function f(e, t = Date.now()) {
|
|
77
96
|
if (!e) return;
|
|
78
97
|
let n = e.trim();
|
|
79
98
|
if (/^\d+$/.test(n)) return Number(n) * 1e3;
|
|
80
99
|
let r = Date.parse(n);
|
|
81
100
|
return Number.isNaN(r) ? void 0 : Math.max(0, r - t);
|
|
82
101
|
}
|
|
83
|
-
async function
|
|
102
|
+
async function p(e) {
|
|
84
103
|
let t;
|
|
85
104
|
try {
|
|
86
105
|
t = await e.clone().json();
|
|
87
106
|
} catch {}
|
|
88
|
-
if (
|
|
107
|
+
if (d(t)) {
|
|
89
108
|
let n = t.code ?? (t.type?.startsWith("urn:wow:error:") ? t.type.slice(14) : void 0);
|
|
90
109
|
return i({
|
|
91
110
|
...t,
|
|
@@ -100,20 +119,20 @@ async function u(e) {
|
|
|
100
119
|
status: e.status
|
|
101
120
|
};
|
|
102
121
|
}
|
|
103
|
-
async function
|
|
122
|
+
async function m(e) {
|
|
104
123
|
if (e instanceof s) return e;
|
|
105
124
|
if (typeof e != "object" || !e) return;
|
|
106
125
|
let { exchange: t, cause: n } = e;
|
|
107
126
|
if (n instanceof s) return n;
|
|
108
127
|
let r = t?.response;
|
|
109
128
|
if (!r || r.ok) return;
|
|
110
|
-
let i = await
|
|
129
|
+
let i = await p(r), a = f(r.headers.get("Retry-After"));
|
|
111
130
|
return new s(i, {
|
|
112
131
|
cause: e,
|
|
113
132
|
...a === void 0 ? {} : { retryAfterMs: a }
|
|
114
133
|
});
|
|
115
134
|
}
|
|
116
135
|
//#endregion
|
|
117
|
-
export { t as FRAMEWORK_ERROR_PREFIX, e as FrameworkErrorCodes, n as PROBLEM_TYPE_PREFIX, s as WowProblemError,
|
|
136
|
+
export { t as FRAMEWORK_ERROR_PREFIX, e as FrameworkErrorCodes, n as PROBLEM_TYPE_PREFIX, s as WowProblemError, d as isProblem, f as parseRetryAfter, p as readProblem, l as rememberRequestId, u as requestIdOf, o as retryHintOf, m as toWowProblemError };
|
|
118
137
|
|
|
119
138
|
//# sourceMappingURL=problem.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.es.js","names":["FrameworkErrorCodes","FRAMEWORK_ERROR_PREFIX","PROBLEM_TYPE_PREFIX","PROBLEM_MEMBERS","withExtensions","problem","extensions","name","RETRYABLE","retryHintOf","sameRequestId","code","retryable","status","afterMs","WowProblemError","SENT_REQUEST_IDS","options","rememberRequestId","error","requestId","requestIdOf","isProblem","value","parseRetryAfter","trimmed","date","now","readProblem","body","response","toWowProblemError","cause","exchange","retryAfterMs"],"sources":["../src/problem.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 { CommandResult, Violation } from './wire.js';\n\n/**\n * The framework's error codes (design 05 §3, decisions D102, D103, D130),\n * each answered with the status of the Manifest's `errors` table. A domain\n * rejection has a code of its own, answered with 422 unless the service\n * configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401: the request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403: the caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403: the aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400: the command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400: the command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400: the wait is not a chain the runtime can follow. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400: the aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404: the aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409: the aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409, or 412 with `If-Match`: the aggregate is not at the expected version. */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409: the request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409: concurrent writers kept winning; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410: the aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429: the command was not taken, its aggregate or the node being busy; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503: whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500: the command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 503: the node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503: the node is on standby until a migration's cut-over; it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503, with `Retry-After`: a store could not be reached in time; retry later. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503: a scheduled command arrived too long before its due time; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400: the job command does not fit its job or instance (decision D198). */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 500: a subscription on the wait chain parked the aggregate. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504: the wait ran out of time; the command may have committed. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400: the query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400: the query failed admission; each violation has its code. */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500: the query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 429, with `Retry-After`: the query's store runs as many queries as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /**\n * 404: a `single` query matched no record, whatever its model (review R4-Q,\n * Q-4); a state read by id that finds none is `wow.aggregate.not-found`.\n */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404: no dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /**\n * 409, with `Retry-After`: a state read asked for a version (`minVersion`) the\n * aggregate has not reached within the wait; the problem's `version` is its\n * current one (review R4-Q, Q-13).\n */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 409: the dataset is served but cannot be queried now (it needs revision, decision D259). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403: the calling service may not call this command (a synchronous call on the internal port, decision D226). */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** The prefix of every framework code, and of no domain code. */\nexport const FRAMEWORK_ERROR_PREFIX = 'wow.';\n\n/** The prefix of a problem's `type` that carries a Wow code. */\nexport const PROBLEM_TYPE_PREFIX = 'urn:wow:error:';\n\n/**\n * An RFC 9457 problem as a Wow service writes it (decisions D101, D102):\n * `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is\n * only HTTP's (a missing route, 406, 415).\n */\nexport interface Problem {\n readonly type: string;\n readonly title: string;\n readonly status: number;\n readonly detail?: string;\n /** The Wow code; absent for an error that is only HTTP's. */\n readonly code?: string;\n readonly violations?: readonly Violation[];\n /** The whole result of a command that has a ref. */\n readonly result?: CommandResult;\n /**\n * The problem's extension members (RFC 9457): every member the server\n * wrote besides the ones above and `instance`, such as a rejection's\n * structured data (decision D211). Absent when it wrote none.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** The members of a problem that are not extension members. */\nconst PROBLEM_MEMBERS: ReadonlySet<string> = new Set([\n 'type',\n 'title',\n 'status',\n 'detail',\n 'instance',\n 'code',\n 'violations',\n 'result',\n 'extensions',\n]);\n\n/**\n * `problem` with its extension members gathered as `extensions` (internal):\n * a problem read from the wire carries them as top-level members.\n */\nfunction withExtensions(problem: Problem): Problem {\n if (problem.extensions !== undefined) return problem;\n const extensions = Object.fromEntries(\n Object.entries(problem).filter(([name]) => !PROBLEM_MEMBERS.has(name)),\n );\n return Object.keys(extensions).length === 0\n ? problem\n : { ...problem, extensions };\n}\n\n/**\n * What a client may do about a failed request: whether retrying can succeed,\n * whether to keep the request id (`Wow-Request-Id`) so the server\n * deduplicates a command that did commit, and how long to wait first.\n */\nexport interface RetryHint {\n readonly retryable: boolean;\n /** Retry with the same `Wow-Request-Id`: a commit is then answered as a duplicate. */\n readonly sameRequestId: boolean;\n /** The server's `Retry-After`, in milliseconds. */\n readonly afterMs?: number;\n}\n\n/**\n * The codes a retry may get past, each with whether to keep the request id:\n * the 503s (`wow.command.unknown`, `wow.node.closing`, `wow.node.standby`,\n * `wow.storage.unavailable`, `wow.schedule.not-due`),\n * the 429s `wow.command.busy` and `wow.query.busy`, the 409s `wow.command.contended` and\n * `wow.query.min-version-not-reached` (once the command commits), and the 504\n * `wow.wait.timeout`, whose command may have committed.\n */\nconst RETRYABLE: ReadonlyMap<string, boolean> = new Map([\n [FrameworkErrorCodes.COMMAND_UNKNOWN, true],\n [FrameworkErrorCodes.NODE_CLOSING, true],\n [FrameworkErrorCodes.NODE_STANDBY, true],\n [FrameworkErrorCodes.STORAGE_UNAVAILABLE, true],\n [FrameworkErrorCodes.SCHEDULE_NOT_DUE, true],\n [FrameworkErrorCodes.COMMAND_BUSY, true],\n [FrameworkErrorCodes.QUERY_BUSY, false],\n [FrameworkErrorCodes.QUERY_MIN_VERSION_NOT_REACHED, false],\n [FrameworkErrorCodes.COMMAND_CONTENDED, true],\n [FrameworkErrorCodes.WAIT_TIMEOUT, true],\n]);\n\n/**\n * The retry hint of a problem with `code` and `status`: a code of the\n * retryable table, or a 503 without a code (a proxy's), may be retried.\n *\n * @param code - The problem's Wow code, if any\n * @param status - The HTTP status\n * @param afterMs - The `Retry-After` the response carried, in milliseconds\n */\nexport function retryHintOf(\n code: string | undefined,\n status: number,\n afterMs?: number,\n): RetryHint {\n const sameRequestId = code === undefined ? undefined : RETRYABLE.get(code);\n const retryable =\n sameRequestId !== undefined || (code === undefined && status === 503);\n return {\n retryable,\n sameRequestId: sameRequestId ?? retryable,\n ...(afterMs === undefined ? {} : { afterMs }),\n };\n}\n\n/**\n * A request a Wow service answered with a problem: a non-2xx response, a\n * command result that did not succeed, or the `error` event that ends a\n * streamed query.\n */\nexport class WowProblemError extends Error {\n override readonly name = 'WowProblemError';\n /** The problem as the server wrote it. */\n readonly problem: Problem;\n /** The HTTP status. */\n readonly status: number;\n /** The Wow code; absent for an error that is only HTTP's. */\n readonly code?: string;\n readonly violations: readonly Violation[];\n /** The command's result, when the command had a ref. */\n readonly result?: CommandResult;\n /** What a client may do about it. */\n readonly retry: RetryHint;\n /** The error this one explains: the fetcher's, or the stream's. */\n readonly cause?: unknown;\n\n /**\n * The request id (`Wow-Request-Id`) of the command this answers: its\n * result's, else the one the client sent. Retry with it when\n * {@link RetryHint.sameRequestId} says so.\n */\n get requestId(): string | undefined {\n return this.result?.requestId ?? SENT_REQUEST_IDS.get(this);\n }\n\n /**\n * @param problem - The problem the server answered with\n * @param options - The response's `Retry-After` in milliseconds, and the\n * error this one explains\n */\n constructor(\n problem: Problem,\n options: { retryAfterMs?: number; cause?: unknown } = {},\n ) {\n super(\n problem.code\n ? `[${problem.code}] ${problem.detail ?? problem.title}`\n : `${problem.status} ${problem.detail ?? problem.title}`,\n );\n this.problem = withExtensions(problem);\n this.status = problem.status;\n if (problem.code !== undefined) this.code = problem.code;\n this.violations = problem.violations ?? [];\n if (problem.result !== undefined) this.result = problem.result;\n this.retry = retryHintOf(\n problem.code,\n problem.status,\n options.retryAfterMs,\n );\n if (options.cause !== undefined) this.cause = options.cause;\n }\n\n /** Whether the code is a framework one (`wow.*`) rather than the domain's. */\n get isFramework(): boolean {\n return this.code?.startsWith(FRAMEWORK_ERROR_PREFIX) ?? false;\n }\n}\n\n/** The request ids the client sent, by the errors the requests failed with. */\nconst SENT_REQUEST_IDS = new WeakMap<object, string>();\n\n/**\n * Remembers that the request that failed with `error` was sent with\n * `requestId` (internal): {@link requestIdOf} answers it.\n *\n * @param error - What the request failed with\n * @param requestId - The `Wow-Request-Id` it was sent with\n */\nexport function rememberRequestId(error: unknown, requestId: string): void {\n if (\n (typeof error === 'object' && error !== null) ||\n typeof error === 'function'\n ) {\n if (!SENT_REQUEST_IDS.has(error)) SENT_REQUEST_IDS.set(error, requestId);\n }\n}\n\n/**\n * The request id (`Wow-Request-Id`) a command that failed with `error` was\n * sent with: also after a failure no server answered (the network, a proxy,\n * an abort), so the command can be retried with the same id and the service\n * answers a commit that did happen as a duplicate (decision D223).\n * Undefined for an error of no command the client sent.\n *\n * @param error - What a command rejected with\n */\nexport function requestIdOf(error: unknown): string | undefined {\n if (error instanceof WowProblemError) return error.requestId;\n return (typeof error === 'object' && error !== null) ||\n typeof error === 'function'\n ? SENT_REQUEST_IDS.get(error)\n : undefined;\n}\n\n/** Whether `value` reads as a problem: an object with a numeric `status`. */\nexport function isProblem(value: unknown): value is Problem {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { status?: unknown }).status === 'number'\n );\n}\n\n/**\n * The milliseconds of a `Retry-After` header: delay seconds or an HTTP date.\n *\n * @param value - The header's value\n * @param now - The current time, in epoch milliseconds\n */\nexport function parseRetryAfter(\n value: string | null | undefined,\n now: number = Date.now(),\n): number | undefined {\n if (!value) return undefined;\n const trimmed = value.trim();\n if (/^\\d+$/.test(trimmed)) return Number(trimmed) * 1000;\n const date = Date.parse(trimmed);\n return Number.isNaN(date) ? undefined : Math.max(0, date - now);\n}\n\n/**\n * The problem a response that did not succeed carries: its body when it is\n * a problem (or a code the `type` names), else one made of its status.\n *\n * @param response - A response that is not 2xx\n */\nexport async function readProblem(response: Response): Promise<Problem> {\n let body: unknown;\n try {\n body = await response.clone().json();\n } catch {\n // Not JSON, or already read: the status is all there is.\n }\n if (isProblem(body)) {\n const code =\n body.code ??\n (body.type?.startsWith(PROBLEM_TYPE_PREFIX)\n ? body.type.slice(PROBLEM_TYPE_PREFIX.length)\n : undefined);\n return withExtensions({\n ...body,\n type: body.type ?? 'about:blank',\n title: body.title ?? response.statusText,\n ...(code === undefined ? {} : { code }),\n });\n }\n return {\n type: 'about:blank',\n title: response.statusText,\n status: response.status,\n };\n}\n\ninterface ExchangeLike {\n exchange?: { response?: Response };\n cause?: unknown;\n}\n\n/**\n * The {@link WowProblemError} of an error a request rejected with: the\n * fetcher's `ExchangeError` of a response that is not 2xx, read as a problem.\n * Undefined for a failure no server answered (a network error, an abort).\n *\n * @param error - What the request rejected with\n */\nexport async function toWowProblemError(\n error: unknown,\n): Promise<WowProblemError | undefined> {\n if (error instanceof WowProblemError) return error;\n if (typeof error !== 'object' || error === null) return undefined;\n const { exchange, cause } = error as ExchangeLike;\n if (cause instanceof WowProblemError) return cause;\n const response = exchange?.response;\n if (!response || response.ok) return undefined;\n const problem = await readProblem(response);\n const retryAfterMs = parseRetryAfter(response.headers.get('Retry-After'));\n return new WowProblemError(problem, {\n cause: error,\n ...(retryAfterMs === undefined ? {} : { retryAfterMs }),\n });\n}\n"],"mappings":";AAqBA,IAAaA,IAAsB;CA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,EAAS,IAAI;CAC9B,IAAMzB,IAAU,MAAMuB,EAAYE,CAAQ,GACpCI,IAAeV,EAAgBM,EAAS,QAAQ,IAAI,aAAa,CAAC;CACxE,OAAO,IAAIf,EAAgBV,GAAS;EAClC,OAAOc;EACP,GAAIe,MAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAa;CACvD,CAAC;AACH"}
|
package/dist/queries.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./exactJson.cjs"),t=require("./http.cjs"),n=require("./streams.cjs");var r=class{constructor(e,t={},n){this.path=e,this.client=t,this.numbers=n}get listNumbers(){return this.numbers===void 0?void 0:{"*":this.numbers}}get pageNumbers(){return this.numbers===void 0?void 0:{list:{"*":this.numbers}}}async list(e,n){return t.json(await this.post(`list`,e,n),this.listNumbers)}async listStream(e,t){return(await this.listStreamRows(e,t)).pipeThrough(new TransformStream({transform(e,t){t.enqueue(e.record)}}))}async listStreamRows(e,t={}){let r=t.resume===!1?{maxRetries:0}:t.resume,i=e.limit??0,a=(n,r)=>this.post(`list`,i>0?{...e,limit:i-r}:e,t,`text/event-stream`,n),o=await a(r?.lastEventId,0);return n.resumableQueryRows(o,(e,t)=>i>0&&t>=i?Promise.resolve(void 0):a(e,t),{...r,...t.signal===void 0?{}:{signal:t.signal},...this.numbers===void 0?{}:{numbers:this.numbers}})}async paged(e,n){return t.json(await this.post(`paged`,e,n),this.pageNumbers)}async cursor(e,n){return t.json(await this.post(`cursor`,e,n),this.pageNumbers)}async single(e,n){return t.json(await this.post(`single`,e,n),this.numbers)}async count(e,n){return t.json(await this.post(`count`,e,n))}async aggregate(e,n){return t.json(await this.post(`aggregate`,e,n))}async describe(e,n){let r=await t.send(this.client,{method:`GET`,path:this.path,headers:{[t.WowHeaders.IF_NONE_MATCH]:e===void 0?void 0:`"${e}"`},options:n,notModified:!0}),i=t.entityTag(r);return r.status===304?{notModified:!0,version:i??e??``}:{notModified:!1,...i===void 0?{}:{version:i},descriptor:await t.json(r)}}post(e,n,r,i,a){return t.send(this.client,{method:`POST`,path:this.path,headers:{Accept:i,[t.WowHeaders.LAST_EVENT_ID]:a},body:{...n,kind:e},options:r})}};function i(e,t){return`/${e.context}/${e.name}/${t}/query`}var a=class extends r{constructor(e,t){super(i(e,`snapshot`),t,e.textNumbers?.state===void 0?void 0:{state:e.textNumbers.state}),this.type=e}},o=class extends r{constructor(t,n){let r=e.eventNumbers(t);super(i(t,`events`),n,r===void 0?void 0:{events:{"*":r}}),this.type=t}},s=class{constructor(e={}){this.client=e}async list(e){return t.json(await t.send(this.client,{method:`GET`,path:`/wow/dataset`,options:e}))}dataset(e,t){return new r(`/wow/dataset/${encodeURIComponent(e)}/${encodeURIComponent(t)}/query`,this.client)}};exports.DatasetClient=s,exports.EventQueryClient=o,exports.QueryModelClient=r,exports.SnapshotQueryClient=a,exports.queryPath=i;
|
|
2
|
+
//# sourceMappingURL=queries.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.cjs","names":["json","resumableQueryRows","send","WowHeaders","entityTag","eventNumbers","require_exactJson","require_http","require_streams","QueryModelClient","path","client","numbers","query","options","controller","row","resume","limit","open","received","lastEventId","first","response","version","tag","accept","queryPath","type","model","SnapshotQueryClient","EventQueryClient","events","DatasetClient","context","dataset"],"sources":["../src/queries.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 { AggregationQuery } from './dsl/aggregation/index.js';\nimport type { CursorPage, CursorQuery } from './dsl/cursorQuery.js';\nimport type { Projected } from './dsl/projection.js';\nimport { eventNumbers, type TextNumbers } from './exactJson.js';\nimport type { QueryModelDescriptor } from './dsl/descriptor.js';\nimport type { FilterCapable } from './dsl/filter/index.js';\nimport type {\n FilterListQuery,\n FilterPagedQuery,\n FilterSingleQuery,\n} from './dsl/queryable.js';\nimport {\n entityTag,\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n WowHeaders,\n} from './http.js';\nimport type {\n AggregateType,\n DatasetEntry,\n EventStreamField,\n EventStreamRecord,\n EventView,\n SnapshotRecord,\n SnapshotSystemField,\n} from './wire.js';\nimport {\n resumableQueryRows,\n type StreamedRow,\n type StreamResumeOptions,\n} from './streams.js';\n\n/** How a list is streamed: the request's options, and how it resumes. */\nexport interface ListStreamOptions extends RequestOptions {\n /** How the stream resumes (decision D253); `false` never resumes it. */\n readonly resume?: StreamResumeOptions | false;\n}\n\n/** How a paged query counts its total (`TotalMode`, decision D150). */\nexport type TotalMode = 'EXACT' | 'BOUNDED' | 'NONE';\n\n/** A paged query of a query route: a page, and how its total is counted. */\nexport interface PagedQuery<\n FIELDS extends string = string,\n> extends FilterPagedQuery<FIELDS> {\n /** `BOUNDED` (the server's default) counts up to the budget's limit. */\n total?: TotalMode;\n}\n\n/** A count of a query route (decision D150). */\nexport interface CountQuery<\n FIELDS extends string = string,\n> extends FilterCapable<FIELDS> {\n /** The most matches to count; the budget's default when absent. */\n limit?: number;\n}\n\n/** What a count answers: exact below its limit, else the limit itself. */\nexport interface CountResult {\n readonly count: number;\n readonly exact: boolean;\n}\n\n/**\n * A page of a paged query: `total` is exact when `exact`, a lower bound\n * otherwise, and null for `TotalMode.NONE`.\n */\nexport interface PagedResult<T> {\n readonly total: number | null;\n readonly exact: boolean;\n readonly list: readonly T[];\n}\n\n/**\n * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * Queries one query model of a Wow service: `POST {path}` with a body\n * whose `kind` names the operation, `GET {path}` for the capability\n * descriptor (decisions D127, D145). A query written with literal `include`\n * paths answers records narrowed to them ({@link Projected}, review R4-Q,\n * Q-14).\n *\n * @typeParam R - The record's type.\n * @typeParam FIELDS - The field paths a filter, sort or projection takes.\n */\nexport class QueryModelClient<R, FIELDS extends string = string> {\n /**\n * @param path - The query route, `/{context}/{aggregate}/{model}/query`\n * @param client - How the service is reached\n * @param numbers - The numbers of each record read as their exact text\n * (review R4-Q, Q-9)\n */\n constructor(\n readonly path: string,\n readonly client: WowClientOptions = {},\n readonly numbers?: TextNumbers,\n ) {}\n\n /** The marks of a list of records. */\n private get listNumbers(): TextNumbers | undefined {\n return this.numbers === undefined ? undefined : { '*': this.numbers };\n }\n\n /** The marks of a page of records. */\n private get pageNumbers(): TextNumbers | undefined {\n return this.numbers === undefined\n ? undefined\n : { list: { '*': this.numbers } };\n }\n\n /** The records that match, at most `limit` (the server's default when absent). */\n list<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<Projected<R, INCLUDE>[]>;\n list(query: FilterListQuery<FIELDS>, options?: RequestOptions): Promise<R[]>;\n async list(\n query: FilterListQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return json<R[]>(await this.post('list', query, options), this.listNumbers);\n }\n\n /**\n * The records that match, as server-sent events read one at a time; a\n * failure after the first record errors the stream with its problem. The\n * stream resumes where it stopped (decision D253) when the server ends it\n * to be resumed, when it is cut off and when it fails with a retryable\n * problem: see {@link StreamResumeOptions}. A `limit` counts every record\n * read, resumed or not.\n */\n listStream<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: ListStreamOptions,\n ): Promise<ReadableStream<Projected<R, INCLUDE>>>;\n listStream(\n query: FilterListQuery<FIELDS>,\n options?: ListStreamOptions,\n ): Promise<ReadableStream<R>>;\n async listStream(\n query: FilterListQuery<FIELDS>,\n options?: ListStreamOptions,\n ): Promise<unknown> {\n return (await this.listStreamRows(query, options)).pipeThrough(\n new TransformStream<StreamedRow<R>, R>({\n transform(row, controller) {\n controller.enqueue(row.record);\n },\n }),\n );\n }\n\n /**\n * The records that match as {@link listStream} reads them, each with its\n * position: keep the last one read to resume the stream later\n * ({@link StreamResumeOptions.lastEventId}), on another page or after a\n * restart.\n */\n listStreamRows<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: ListStreamOptions,\n ): Promise<ReadableStream<StreamedRow<Projected<R, INCLUDE>>>>;\n listStreamRows(\n query: FilterListQuery<FIELDS>,\n options?: ListStreamOptions,\n ): Promise<ReadableStream<StreamedRow<R>>>;\n async listStreamRows(\n query: FilterListQuery<FIELDS>,\n options: ListStreamOptions = {},\n ): Promise<ReadableStream<StreamedRow<R>>> {\n const resume =\n options.resume === false ? { maxRetries: 0 } : options.resume;\n const limit = query.limit ?? 0;\n const open = (lastEventId: string | undefined, received: number) => {\n return this.post(\n 'list',\n limit > 0 ? { ...query, limit: limit - received } : query,\n options,\n 'text/event-stream',\n lastEventId,\n );\n };\n const first = await open(resume?.lastEventId, 0);\n return resumableQueryRows<R>(\n first,\n (lastEventId, received) =>\n limit > 0 && received >= limit\n ? Promise.resolve(undefined)\n : open(lastEventId, received),\n {\n ...resume,\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n ...(this.numbers === undefined ? {} : { numbers: this.numbers }),\n },\n );\n }\n\n /** One page of the records that match, and their total. */\n paged<const INCLUDE extends FIELDS>(\n query: Including<PagedQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<PagedResult<Projected<R, INCLUDE>>>;\n paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<PagedResult<R>>;\n async paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return json<PagedResult<R>>(\n await this.post('paged', query, options),\n this.pageNumbers,\n );\n }\n\n /** One page of a forward-only cursor over the records that match. */\n cursor<const INCLUDE extends FIELDS>(\n query: Including<CursorQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<CursorPage<Projected<R, INCLUDE>>>;\n cursor(\n query: CursorQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<CursorPage<R>>;\n async cursor(\n query: CursorQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return json<CursorPage<R>>(\n await this.post('cursor', query, options),\n this.pageNumbers,\n );\n }\n\n /** The first record that matches; rejects with 404 `wow.query.not-found` when none does. */\n single<const INCLUDE extends FIELDS>(\n query: Including<FilterSingleQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<Projected<R, INCLUDE>>;\n single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<R>;\n async single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return json<R>(await this.post('single', query, options), this.numbers);\n }\n\n /** How many records match, bounded by the count's limit. */\n async count(\n query: CountQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<CountResult> {\n return json<CountResult>(await this.post('count', query, options));\n }\n\n /** The groups and metrics of an aggregation, one row per group. */\n async aggregate<ROW = Record<string, unknown>>(\n query: AggregationQuery<FIELDS, string>,\n options?: RequestOptions,\n ): Promise<ROW[]> {\n return json<ROW[]>(await this.post('aggregate', query, options));\n }\n\n /**\n * The model's capability descriptor; with the `version` already held, a\n * 304 answers `notModified`.\n */\n async describe(\n version?: string,\n options?: RequestOptions,\n ): Promise<DescriptorResult> {\n const response = await send(this.client, {\n method: 'GET',\n path: this.path,\n headers: {\n [WowHeaders.IF_NONE_MATCH]:\n version === undefined ? undefined : `\"${version}\"`,\n },\n options,\n notModified: true,\n });\n const tag = entityTag(response);\n if (response.status === 304) {\n return { notModified: true, version: tag ?? version ?? '' };\n }\n return {\n notModified: false,\n ...(tag === undefined ? {} : { version: tag }),\n descriptor: await json<QueryModelDescriptor>(response),\n };\n }\n\n private post(\n kind: string,\n query: object,\n options?: RequestOptions,\n accept?: string,\n lastEventId?: string,\n ): Promise<Response> {\n return send(this.client, {\n method: 'POST',\n path: this.path,\n headers: { Accept: accept, [WowHeaders.LAST_EVENT_ID]: lastEventId },\n body: { ...query, kind },\n options,\n });\n }\n}\n\n/**\n * A query whose projection includes the literal paths `INCLUDE`: a query\n * client narrows its records to them ({@link Projected}).\n */\nexport type Including<Q, INCLUDE extends string> = Q & {\n readonly projection: { readonly include: readonly INCLUDE[] };\n};\n\n/** The query route of a model of an aggregate type. */\nexport function queryPath(type: AggregateType, model: string): string {\n return `/${type.context}/${type.name}/${model}/query`;\n}\n\n/**\n * Queries an aggregate type's snapshots (decision D128), the default read\n * model; only where the aggregate keeps them.\n *\n * @typeParam S - The state's type.\n * @typeParam STATE_FIELDS - The `state.*` paths of the state.\n */\nexport class SnapshotQueryClient<\n S = unknown,\n STATE_FIELDS extends string = `state.${string}`,\n> extends QueryModelClient<\n SnapshotRecord<S>,\n SnapshotSystemField | STATE_FIELDS\n> {\n /**\n * @param type - The aggregate type\n * @param client - How the service is reached\n */\n constructor(\n readonly type: AggregateType,\n client?: WowClientOptions,\n ) {\n super(\n queryPath(type, 'snapshot'),\n client,\n type.textNumbers?.state === undefined\n ? undefined\n : { state: type.textNumbers.state },\n );\n }\n}\n\n/**\n * Queries an aggregate type's event streams (decision D235) on the same\n * engine as its snapshots: one record per commit, `count` counts commits, a\n * condition on an event is an `elementMatch` on `events`, and per-event\n * analytics expand `events` in an aggregation (`elements`). A filter need\n * not name the aggregate, but one that does not reads the log the service\n * appends to: the budget bounds it.\n *\n * @typeParam E - The events' type.\n */\nexport class EventQueryClient<\n E extends EventView = EventView,\n> extends QueryModelClient<EventStreamRecord<E>, EventStreamField> {\n /**\n * @param type - The aggregate type\n * @param client - How the service is reached\n */\n constructor(\n readonly type: AggregateType,\n client?: WowClientOptions,\n ) {\n const events = eventNumbers(type);\n super(\n queryPath(type, 'events'),\n client,\n events === undefined ? undefined : { events: { '*': events } },\n );\n }\n}\n\n/**\n * The datasets of a Wow service (decisions D75, D145): registered at run\n * time, so not in the Manifest. Lists those the caller sees and queries\n * each as a snapshot model is queried.\n */\nexport class DatasetClient {\n /** @param client - How the service is reached */\n constructor(readonly client: WowClientOptions = {}) {}\n\n /** The datasets the caller sees, by name. */\n async list(options?: RequestOptions): Promise<DatasetEntry[]> {\n return json<DatasetEntry[]>(\n await send(this.client, { method: 'GET', path: '/wow/dataset', options }),\n );\n }\n\n /**\n * The query client of the dataset `context.dataset`.\n *\n * @typeParam R - The row's type.\n * @typeParam FIELDS - The dataset's field paths.\n */\n dataset<R = Record<string, unknown>, FIELDS extends string = string>(\n context: string,\n dataset: string,\n ): QueryModelClient<R, FIELDS> {\n return new QueryModelClient<R, FIELDS>(\n `/wow/dataset/${encodeURIComponent(context)}/${encodeURIComponent(dataset)}/query`,\n this.client,\n );\n }\n}\n"],"mappings":"sFA8GA,IAAaS,EAAb,KAAiE,CAO/D,YACE,EACA,EAAoC,CAAC,EACrC,EACA,CAHS,KAAA,KAAAC,EACA,KAAA,OAAAC,EACA,KAAA,QAAAC,CACR,CAGH,IAAY,aAAuC,CACjD,OAAO,KAAK,UAAY,IAAA,GAAY,IAAA,GAAY,CAAE,IAAK,KAAK,OAAQ,CACtE,CAGA,IAAY,aAAuC,CACjD,OAAO,KAAK,UAAY,IAAA,GACpB,IAAA,GACA,CAAE,KAAM,CAAE,IAAK,KAAK,OAAQ,CAAE,CACpC,CAQA,MAAM,KACJ,EACA,EACkB,CAClB,OAAOZ,EAAAA,KAAU,MAAM,KAAK,KAAK,OAAQa,EAAOC,CAAO,EAAG,KAAK,WAAW,CAC5E,CAkBA,MAAM,WACJ,EACA,EACkB,CAClB,OAAQ,MAAM,KAAK,eAAeD,EAAOC,CAAO,EAAA,CAAG,YACjD,IAAI,gBAAmC,CACrC,UAAU,EAA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,CAAE,IAAKA,CAAO,CAAE,CAC/D,EARS,KAAA,KAAAJ,CASX,CACF,EAOaK,EAAb,KAA2B,CAEzB,YAAY,EAAoC,CAAC,EAAG,CAA/B,KAAA,OAAAtB,CAAgC,CAGrD,MAAM,KAAK,EAAmD,CAC5D,OAAOX,EAAAA,KACL,MAAME,EAAAA,KAAK,KAAK,OAAQ,CAAE,OAAQ,MAAO,KAAM,eAAgB,SAAQ,CAAC,CAC1E,CACF,CAQA,QACE,EACA,EAC6B,CAC7B,OAAO,IAAIO,EACT,gBAAgB,mBAAmByB,CAAO,EAAE,GAAG,mBAAmBC,CAAO,EAAE,QAC3E,KAAK,MACP,CACF,CACF"}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import { AggregationQuery } from '
|
|
2
|
-
import { CursorPage, CursorQuery } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { AggregationQuery } from './dsl/aggregation/index.cjs';
|
|
2
|
+
import { CursorPage, CursorQuery } from './dsl/cursorQuery.cjs';
|
|
3
|
+
import { Projected } from './dsl/projection.cjs';
|
|
4
|
+
import { TextNumbers } from './exactJson.cjs';
|
|
5
|
+
import { QueryModelDescriptor } from './dsl/descriptor.cjs';
|
|
6
|
+
import { FilterCapable } from './dsl/filter/index.cjs';
|
|
7
|
+
import { FilterListQuery, FilterPagedQuery, FilterSingleQuery } from './dsl/queryable.cjs';
|
|
6
8
|
import { RequestOptions, WowClientOptions } from './http.cjs';
|
|
7
9
|
import { AggregateType, DatasetEntry, EventStreamField, EventStreamRecord, EventView, SnapshotRecord, SnapshotSystemField } from './wire.cjs';
|
|
10
|
+
import { StreamedRow, StreamResumeOptions } from './streams.cjs';
|
|
11
|
+
/** How a list is streamed: the request's options, and how it resumes. */
|
|
12
|
+
export interface ListStreamOptions extends RequestOptions {
|
|
13
|
+
/** How the stream resumes (decision D253); `false` never resumes it. */
|
|
14
|
+
readonly resume?: StreamResumeOptions | false;
|
|
15
|
+
}
|
|
8
16
|
/** How a paged query counts its total (`TotalMode`, decision D150). */
|
|
9
17
|
export type TotalMode = 'EXACT' | 'BOUNDED' | 'NONE';
|
|
10
|
-
/** A paged query of a
|
|
18
|
+
/** A paged query of a query route: a page, and how its total is counted. */
|
|
11
19
|
export interface PagedQuery<FIELDS extends string = string> extends FilterPagedQuery<FIELDS> {
|
|
12
20
|
/** `BOUNDED` (the server's default) counts up to the budget's limit. */
|
|
13
21
|
total?: TotalMode;
|
|
14
22
|
}
|
|
15
|
-
/** A count of a
|
|
23
|
+
/** A count of a query route (decision D150). */
|
|
16
24
|
export interface CountQuery<FIELDS extends string = string> extends FilterCapable<FIELDS> {
|
|
17
25
|
/** The most matches to count; the budget's default when absent. */
|
|
18
26
|
limit?: number;
|
|
@@ -44,9 +52,11 @@ export type DescriptorResult = {
|
|
|
44
52
|
readonly version: string;
|
|
45
53
|
};
|
|
46
54
|
/**
|
|
47
|
-
* Queries one query model of a Wow
|
|
55
|
+
* Queries one query model of a Wow service: `POST {path}` with a body
|
|
48
56
|
* whose `kind` names the operation, `GET {path}` for the capability
|
|
49
|
-
* descriptor (decisions D127, D145).
|
|
57
|
+
* descriptor (decisions D127, D145). A query written with literal `include`
|
|
58
|
+
* paths answers records narrowed to them ({@link Projected}, review R4-Q,
|
|
59
|
+
* Q-14).
|
|
50
60
|
*
|
|
51
61
|
* @typeParam R - The record's type.
|
|
52
62
|
* @typeParam FIELDS - The field paths a filter, sort or projection takes.
|
|
@@ -54,23 +64,47 @@ export type DescriptorResult = {
|
|
|
54
64
|
export declare class QueryModelClient<R, FIELDS extends string = string> {
|
|
55
65
|
readonly path: string;
|
|
56
66
|
readonly client: WowClientOptions;
|
|
67
|
+
readonly numbers?: TextNumbers | undefined;
|
|
57
68
|
/**
|
|
58
69
|
* @param path - The query route, `/{context}/{aggregate}/{model}/query`
|
|
59
70
|
* @param client - How the service is reached
|
|
71
|
+
* @param numbers - The numbers of each record read as their exact text
|
|
72
|
+
* (review R4-Q, Q-9)
|
|
60
73
|
*/
|
|
61
|
-
constructor(path: string, client?: WowClientOptions);
|
|
74
|
+
constructor(path: string, client?: WowClientOptions, numbers?: TextNumbers | undefined);
|
|
75
|
+
/** The marks of a list of records. */
|
|
76
|
+
private get listNumbers();
|
|
77
|
+
/** The marks of a page of records. */
|
|
78
|
+
private get pageNumbers();
|
|
62
79
|
/** The records that match, at most `limit` (the server's default when absent). */
|
|
80
|
+
list<const INCLUDE extends FIELDS>(query: Including<FilterListQuery<FIELDS>, INCLUDE>, options?: RequestOptions): Promise<Projected<R, INCLUDE>[]>;
|
|
63
81
|
list(query: FilterListQuery<FIELDS>, options?: RequestOptions): Promise<R[]>;
|
|
64
82
|
/**
|
|
65
83
|
* The records that match, as server-sent events read one at a time; a
|
|
66
|
-
* failure after the first record errors the stream with its problem.
|
|
84
|
+
* failure after the first record errors the stream with its problem. The
|
|
85
|
+
* stream resumes where it stopped (decision D253) when the server ends it
|
|
86
|
+
* to be resumed, when it is cut off and when it fails with a retryable
|
|
87
|
+
* problem: see {@link StreamResumeOptions}. A `limit` counts every record
|
|
88
|
+
* read, resumed or not.
|
|
89
|
+
*/
|
|
90
|
+
listStream<const INCLUDE extends FIELDS>(query: Including<FilterListQuery<FIELDS>, INCLUDE>, options?: ListStreamOptions): Promise<ReadableStream<Projected<R, INCLUDE>>>;
|
|
91
|
+
listStream(query: FilterListQuery<FIELDS>, options?: ListStreamOptions): Promise<ReadableStream<R>>;
|
|
92
|
+
/**
|
|
93
|
+
* The records that match as {@link listStream} reads them, each with its
|
|
94
|
+
* position: keep the last one read to resume the stream later
|
|
95
|
+
* ({@link StreamResumeOptions.lastEventId}), on another page or after a
|
|
96
|
+
* restart.
|
|
67
97
|
*/
|
|
68
|
-
|
|
98
|
+
listStreamRows<const INCLUDE extends FIELDS>(query: Including<FilterListQuery<FIELDS>, INCLUDE>, options?: ListStreamOptions): Promise<ReadableStream<StreamedRow<Projected<R, INCLUDE>>>>;
|
|
99
|
+
listStreamRows(query: FilterListQuery<FIELDS>, options?: ListStreamOptions): Promise<ReadableStream<StreamedRow<R>>>;
|
|
69
100
|
/** One page of the records that match, and their total. */
|
|
101
|
+
paged<const INCLUDE extends FIELDS>(query: Including<PagedQuery<FIELDS>, INCLUDE>, options?: RequestOptions): Promise<PagedResult<Projected<R, INCLUDE>>>;
|
|
70
102
|
paged(query: PagedQuery<FIELDS>, options?: RequestOptions): Promise<PagedResult<R>>;
|
|
71
103
|
/** One page of a forward-only cursor over the records that match. */
|
|
104
|
+
cursor<const INCLUDE extends FIELDS>(query: Including<CursorQuery<FIELDS>, INCLUDE>, options?: RequestOptions): Promise<CursorPage<Projected<R, INCLUDE>>>;
|
|
72
105
|
cursor(query: CursorQuery<FIELDS>, options?: RequestOptions): Promise<CursorPage<R>>;
|
|
73
|
-
/** The first record that matches; rejects with 404 when none does. */
|
|
106
|
+
/** The first record that matches; rejects with 404 `wow.query.not-found` when none does. */
|
|
107
|
+
single<const INCLUDE extends FIELDS>(query: Including<FilterSingleQuery<FIELDS>, INCLUDE>, options?: RequestOptions): Promise<Projected<R, INCLUDE>>;
|
|
74
108
|
single(query: FilterSingleQuery<FIELDS>, options?: RequestOptions): Promise<R>;
|
|
75
109
|
/** How many records match, bounded by the count's limit. */
|
|
76
110
|
count(query: CountQuery<FIELDS>, options?: RequestOptions): Promise<CountResult>;
|
|
@@ -83,6 +117,15 @@ export declare class QueryModelClient<R, FIELDS extends string = string> {
|
|
|
83
117
|
describe(version?: string, options?: RequestOptions): Promise<DescriptorResult>;
|
|
84
118
|
private post;
|
|
85
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* A query whose projection includes the literal paths `INCLUDE`: a query
|
|
122
|
+
* client narrows its records to them ({@link Projected}).
|
|
123
|
+
*/
|
|
124
|
+
export type Including<Q, INCLUDE extends string> = Q & {
|
|
125
|
+
readonly projection: {
|
|
126
|
+
readonly include: readonly INCLUDE[];
|
|
127
|
+
};
|
|
128
|
+
};
|
|
86
129
|
/** The query route of a model of an aggregate type. */
|
|
87
130
|
export declare function queryPath(type: AggregateType, model: string): string;
|
|
88
131
|
/**
|
|
@@ -101,9 +144,12 @@ export declare class SnapshotQueryClient<S = unknown, STATE_FIELDS extends strin
|
|
|
101
144
|
constructor(type: AggregateType, client?: WowClientOptions);
|
|
102
145
|
}
|
|
103
146
|
/**
|
|
104
|
-
* Queries an aggregate type's event streams (decision
|
|
105
|
-
*
|
|
106
|
-
* `
|
|
147
|
+
* Queries an aggregate type's event streams (decision D235) on the same
|
|
148
|
+
* engine as its snapshots: one record per commit, `count` counts commits, a
|
|
149
|
+
* condition on an event is an `elementMatch` on `events`, and per-event
|
|
150
|
+
* analytics expand `events` in an aggregation (`elements`). A filter need
|
|
151
|
+
* not name the aggregate, but one that does not reads the log the service
|
|
152
|
+
* appends to: the budget bounds it.
|
|
107
153
|
*
|
|
108
154
|
* @typeParam E - The events' type.
|
|
109
155
|
*/
|
|
@@ -116,7 +162,7 @@ export declare class EventQueryClient<E extends EventView = EventView> extends Q
|
|
|
116
162
|
constructor(type: AggregateType, client?: WowClientOptions);
|
|
117
163
|
}
|
|
118
164
|
/**
|
|
119
|
-
* The datasets of a Wow
|
|
165
|
+
* The datasets of a Wow service (decisions D75, D145): registered at run
|
|
120
166
|
* time, so not in the Manifest. Lists those the caller sees and queries
|
|
121
167
|
* each as a snapshot model is queried.
|
|
122
168
|
*/
|