@ahoo-wang/wow-client 9.9.0 → 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/commands.d.cts +123 -0
- package/dist/commands.d.ts +123 -0
- 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 +8 -1
- package/dist/dsl/descriptor.d.ts +8 -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/http.d.cts +96 -0
- package/dist/http.d.ts +96 -0
- 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 +2 -0
- package/dist/manifest.cjs.map +1 -0
- package/dist/manifest.d.cts +109 -0
- package/dist/manifest.d.ts +109 -0
- package/dist/manifest.es.js +14 -0
- package/dist/manifest.es.js.map +1 -0
- package/dist/problem.cjs +2 -0
- package/dist/problem.cjs.map +1 -0
- package/dist/problem.d.cts +211 -0
- package/dist/problem.d.ts +211 -0
- package/dist/problem.es.js +138 -0
- package/dist/problem.es.js.map +1 -0
- package/dist/queries.cjs +2 -0
- package/dist/queries.cjs.map +1 -0
- package/dist/queries.d.cts +182 -0
- package/dist/queries.d.ts +182 -0
- 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/state.d.cts +75 -0
- package/dist/state.d.ts +75 -0
- 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 +2 -0
- package/dist/wait.cjs.map +1 -0
- package/dist/wait.d.cts +61 -0
- package/dist/wait.d.ts +61 -0
- package/dist/wait.es.js +44 -0
- package/dist/wait.es.js.map +1 -0
- package/dist/wire.cjs +2 -0
- package/dist/wire.cjs.map +1 -0
- package/dist/wire.d.cts +326 -0
- package/dist/wire.d.ts +326 -0
- package/dist/wire.es.js +10 -0
- package/dist/wire.es.js.map +1 -0
- package/package.json +4 -16
- 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
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { CommandResult, Violation } from './wire.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* The framework's error codes (design 05 §3, decisions D102, D103, D130),
|
|
4
|
+
* each answered with the status of the Manifest's `errors` table. A domain
|
|
5
|
+
* rejection has a code of its own, answered with 422 unless the service
|
|
6
|
+
* configures another status.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FrameworkErrorCodes: {
|
|
9
|
+
/** 401: the request carries no valid credentials. */
|
|
10
|
+
readonly AUTH_UNAUTHENTICATED: "wow.auth.unauthenticated";
|
|
11
|
+
/** 403: the caller may not send this command. */
|
|
12
|
+
readonly AUTH_FORBIDDEN: "wow.auth.forbidden";
|
|
13
|
+
/** 403: the aggregate is outside the caller's scope. */
|
|
14
|
+
readonly AGGREGATE_FORBIDDEN: "wow.aggregate.forbidden";
|
|
15
|
+
/** 400: the command body cannot be read as the command type. */
|
|
16
|
+
readonly COMMAND_MALFORMED: "wow.command.malformed";
|
|
17
|
+
/** 400: the command failed validation; the problem lists the violations. */
|
|
18
|
+
readonly COMMAND_INVALID: "wow.command.invalid";
|
|
19
|
+
/** 400: the wait is not a chain the runtime can follow. */
|
|
20
|
+
readonly WAIT_INVALID: "wow.wait.invalid";
|
|
21
|
+
/** 400: the aggregate does not handle this command. */
|
|
22
|
+
readonly COMMAND_UNHANDLED: "wow.command.unhandled";
|
|
23
|
+
/** 404: the aggregate does not exist. */
|
|
24
|
+
readonly AGGREGATE_NOT_FOUND: "wow.aggregate.not-found";
|
|
25
|
+
/** 409: the aggregate already exists. */
|
|
26
|
+
readonly AGGREGATE_EXISTS: "wow.aggregate.exists";
|
|
27
|
+
/** 409, or 412 with `If-Match`: the aggregate is not at the expected version. */
|
|
28
|
+
readonly AGGREGATE_VERSION_MISMATCH: "wow.aggregate.version-mismatch";
|
|
29
|
+
/** 409: the request id was used by another command. */
|
|
30
|
+
readonly COMMAND_REQUEST_ID_REUSED: "wow.command.request-id-reused";
|
|
31
|
+
/** 409: concurrent writers kept winning; retrying with the same request id is safe. */
|
|
32
|
+
readonly COMMAND_CONTENDED: "wow.command.contended";
|
|
33
|
+
/** 410: the aggregate is deleted; only RestoreAggregate applies. */
|
|
34
|
+
readonly AGGREGATE_DELETED: "wow.aggregate.deleted";
|
|
35
|
+
/** 429: the command was not taken, its aggregate or the node being busy; retry later. */
|
|
36
|
+
readonly COMMAND_BUSY: "wow.command.busy";
|
|
37
|
+
/** 503: whether the command committed is unknown; retrying with the same request id is safe. */
|
|
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";
|
|
41
|
+
/** 503: the node is shutting down; retry on another node. */
|
|
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";
|
|
45
|
+
/** 503, with `Retry-After`: a store could not be reached in time; retry later. */
|
|
46
|
+
readonly STORAGE_UNAVAILABLE: "wow.storage.unavailable";
|
|
47
|
+
/** 503: a scheduled command arrived too long before its due time; it is sent again later. */
|
|
48
|
+
readonly SCHEDULE_NOT_DUE: "wow.schedule.not-due";
|
|
49
|
+
/** 400: the job command does not fit its job or instance (decision D198). */
|
|
50
|
+
readonly SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid";
|
|
51
|
+
/** 500: a subscription on the wait chain parked the aggregate. */
|
|
52
|
+
readonly SUBSCRIPTION_PARKED: "wow.subscription.parked";
|
|
53
|
+
/** 504: the wait ran out of time; the command may have committed. */
|
|
54
|
+
readonly WAIT_TIMEOUT: "wow.wait.timeout";
|
|
55
|
+
/** 400: the query body cannot be read as a query. */
|
|
56
|
+
readonly QUERY_MALFORMED: "wow.query.malformed";
|
|
57
|
+
/** 400: the query failed admission; each violation has its code. */
|
|
58
|
+
readonly QUERY_INVALID: "wow.query.invalid";
|
|
59
|
+
/** 500: the query backend failed to run the query. */
|
|
60
|
+
readonly QUERY_FAILED: "wow.query.failed";
|
|
61
|
+
/** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */
|
|
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";
|
|
82
|
+
};
|
|
83
|
+
/** A {@link FrameworkErrorCodes} value. */
|
|
84
|
+
export type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
|
|
85
|
+
/** The prefix of every framework code, and of no domain code. */
|
|
86
|
+
export declare const FRAMEWORK_ERROR_PREFIX = "wow.";
|
|
87
|
+
/** The prefix of a problem's `type` that carries a Wow code. */
|
|
88
|
+
export declare const PROBLEM_TYPE_PREFIX = "urn:wow:error:";
|
|
89
|
+
/**
|
|
90
|
+
* An RFC 9457 problem as a Wow service writes it (decisions D101, D102):
|
|
91
|
+
* `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is
|
|
92
|
+
* only HTTP's (a missing route, 406, 415).
|
|
93
|
+
*/
|
|
94
|
+
export interface Problem {
|
|
95
|
+
readonly type: string;
|
|
96
|
+
readonly title: string;
|
|
97
|
+
readonly status: number;
|
|
98
|
+
readonly detail?: string;
|
|
99
|
+
/** The Wow code; absent for an error that is only HTTP's. */
|
|
100
|
+
readonly code?: string;
|
|
101
|
+
readonly violations?: readonly Violation[];
|
|
102
|
+
/** The whole result of a command that has a ref. */
|
|
103
|
+
readonly result?: CommandResult;
|
|
104
|
+
/**
|
|
105
|
+
* The problem's extension members (RFC 9457): every member the server
|
|
106
|
+
* wrote besides the ones above and `instance`, such as a rejection's
|
|
107
|
+
* structured data (decision D211). Absent when it wrote none.
|
|
108
|
+
*/
|
|
109
|
+
readonly extensions?: Readonly<Record<string, unknown>>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What a client may do about a failed request: whether retrying can succeed,
|
|
113
|
+
* whether to keep the request id (`Wow-Request-Id`) so the server
|
|
114
|
+
* deduplicates a command that did commit, and how long to wait first.
|
|
115
|
+
*/
|
|
116
|
+
export interface RetryHint {
|
|
117
|
+
readonly retryable: boolean;
|
|
118
|
+
/** Retry with the same `Wow-Request-Id`: a commit is then answered as a duplicate. */
|
|
119
|
+
readonly sameRequestId: boolean;
|
|
120
|
+
/** The server's `Retry-After`, in milliseconds. */
|
|
121
|
+
readonly afterMs?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The retry hint of a problem with `code` and `status`: a code of the
|
|
125
|
+
* retryable table, or a 503 without a code (a proxy's), may be retried.
|
|
126
|
+
*
|
|
127
|
+
* @param code - The problem's Wow code, if any
|
|
128
|
+
* @param status - The HTTP status
|
|
129
|
+
* @param afterMs - The `Retry-After` the response carried, in milliseconds
|
|
130
|
+
*/
|
|
131
|
+
export declare function retryHintOf(code: string | undefined, status: number, afterMs?: number): RetryHint;
|
|
132
|
+
/**
|
|
133
|
+
* A request a Wow service answered with a problem: a non-2xx response, a
|
|
134
|
+
* command result that did not succeed, or the `error` event that ends a
|
|
135
|
+
* streamed query.
|
|
136
|
+
*/
|
|
137
|
+
export declare class WowProblemError extends Error {
|
|
138
|
+
readonly name = "WowProblemError";
|
|
139
|
+
/** The problem as the server wrote it. */
|
|
140
|
+
readonly problem: Problem;
|
|
141
|
+
/** The HTTP status. */
|
|
142
|
+
readonly status: number;
|
|
143
|
+
/** The Wow code; absent for an error that is only HTTP's. */
|
|
144
|
+
readonly code?: string;
|
|
145
|
+
readonly violations: readonly Violation[];
|
|
146
|
+
/** The command's result, when the command had a ref. */
|
|
147
|
+
readonly result?: CommandResult;
|
|
148
|
+
/** What a client may do about it. */
|
|
149
|
+
readonly retry: RetryHint;
|
|
150
|
+
/** The error this one explains: the fetcher's, or the stream's. */
|
|
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;
|
|
158
|
+
/**
|
|
159
|
+
* @param problem - The problem the server answered with
|
|
160
|
+
* @param options - The response's `Retry-After` in milliseconds, and the
|
|
161
|
+
* error this one explains
|
|
162
|
+
*/
|
|
163
|
+
constructor(problem: Problem, options?: {
|
|
164
|
+
retryAfterMs?: number;
|
|
165
|
+
cause?: unknown;
|
|
166
|
+
});
|
|
167
|
+
/** Whether the code is a framework one (`wow.*`) rather than the domain's. */
|
|
168
|
+
get isFramework(): boolean;
|
|
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;
|
|
188
|
+
/** Whether `value` reads as a problem: an object with a numeric `status`. */
|
|
189
|
+
export declare function isProblem(value: unknown): value is Problem;
|
|
190
|
+
/**
|
|
191
|
+
* The milliseconds of a `Retry-After` header: delay seconds or an HTTP date.
|
|
192
|
+
*
|
|
193
|
+
* @param value - The header's value
|
|
194
|
+
* @param now - The current time, in epoch milliseconds
|
|
195
|
+
*/
|
|
196
|
+
export declare function parseRetryAfter(value: string | null | undefined, now?: number): number | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The problem a response that did not succeed carries: its body when it is
|
|
199
|
+
* a problem (or a code the `type` names), else one made of its status.
|
|
200
|
+
*
|
|
201
|
+
* @param response - A response that is not 2xx
|
|
202
|
+
*/
|
|
203
|
+
export declare function readProblem(response: Response): Promise<Problem>;
|
|
204
|
+
/**
|
|
205
|
+
* The {@link WowProblemError} of an error a request rejected with: the
|
|
206
|
+
* fetcher's `ExchangeError` of a response that is not 2xx, read as a problem.
|
|
207
|
+
* Undefined for a failure no server answered (a network error, an abort).
|
|
208
|
+
*
|
|
209
|
+
* @param error - What the request rejected with
|
|
210
|
+
*/
|
|
211
|
+
export declare function toWowProblemError(error: unknown): Promise<WowProblemError | undefined>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { CommandResult, Violation } from './wire.js';
|
|
2
|
+
/**
|
|
3
|
+
* The framework's error codes (design 05 §3, decisions D102, D103, D130),
|
|
4
|
+
* each answered with the status of the Manifest's `errors` table. A domain
|
|
5
|
+
* rejection has a code of its own, answered with 422 unless the service
|
|
6
|
+
* configures another status.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FrameworkErrorCodes: {
|
|
9
|
+
/** 401: the request carries no valid credentials. */
|
|
10
|
+
readonly AUTH_UNAUTHENTICATED: "wow.auth.unauthenticated";
|
|
11
|
+
/** 403: the caller may not send this command. */
|
|
12
|
+
readonly AUTH_FORBIDDEN: "wow.auth.forbidden";
|
|
13
|
+
/** 403: the aggregate is outside the caller's scope. */
|
|
14
|
+
readonly AGGREGATE_FORBIDDEN: "wow.aggregate.forbidden";
|
|
15
|
+
/** 400: the command body cannot be read as the command type. */
|
|
16
|
+
readonly COMMAND_MALFORMED: "wow.command.malformed";
|
|
17
|
+
/** 400: the command failed validation; the problem lists the violations. */
|
|
18
|
+
readonly COMMAND_INVALID: "wow.command.invalid";
|
|
19
|
+
/** 400: the wait is not a chain the runtime can follow. */
|
|
20
|
+
readonly WAIT_INVALID: "wow.wait.invalid";
|
|
21
|
+
/** 400: the aggregate does not handle this command. */
|
|
22
|
+
readonly COMMAND_UNHANDLED: "wow.command.unhandled";
|
|
23
|
+
/** 404: the aggregate does not exist. */
|
|
24
|
+
readonly AGGREGATE_NOT_FOUND: "wow.aggregate.not-found";
|
|
25
|
+
/** 409: the aggregate already exists. */
|
|
26
|
+
readonly AGGREGATE_EXISTS: "wow.aggregate.exists";
|
|
27
|
+
/** 409, or 412 with `If-Match`: the aggregate is not at the expected version. */
|
|
28
|
+
readonly AGGREGATE_VERSION_MISMATCH: "wow.aggregate.version-mismatch";
|
|
29
|
+
/** 409: the request id was used by another command. */
|
|
30
|
+
readonly COMMAND_REQUEST_ID_REUSED: "wow.command.request-id-reused";
|
|
31
|
+
/** 409: concurrent writers kept winning; retrying with the same request id is safe. */
|
|
32
|
+
readonly COMMAND_CONTENDED: "wow.command.contended";
|
|
33
|
+
/** 410: the aggregate is deleted; only RestoreAggregate applies. */
|
|
34
|
+
readonly AGGREGATE_DELETED: "wow.aggregate.deleted";
|
|
35
|
+
/** 429: the command was not taken, its aggregate or the node being busy; retry later. */
|
|
36
|
+
readonly COMMAND_BUSY: "wow.command.busy";
|
|
37
|
+
/** 503: whether the command committed is unknown; retrying with the same request id is safe. */
|
|
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";
|
|
41
|
+
/** 503: the node is shutting down; retry on another node. */
|
|
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";
|
|
45
|
+
/** 503, with `Retry-After`: a store could not be reached in time; retry later. */
|
|
46
|
+
readonly STORAGE_UNAVAILABLE: "wow.storage.unavailable";
|
|
47
|
+
/** 503: a scheduled command arrived too long before its due time; it is sent again later. */
|
|
48
|
+
readonly SCHEDULE_NOT_DUE: "wow.schedule.not-due";
|
|
49
|
+
/** 400: the job command does not fit its job or instance (decision D198). */
|
|
50
|
+
readonly SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid";
|
|
51
|
+
/** 500: a subscription on the wait chain parked the aggregate. */
|
|
52
|
+
readonly SUBSCRIPTION_PARKED: "wow.subscription.parked";
|
|
53
|
+
/** 504: the wait ran out of time; the command may have committed. */
|
|
54
|
+
readonly WAIT_TIMEOUT: "wow.wait.timeout";
|
|
55
|
+
/** 400: the query body cannot be read as a query. */
|
|
56
|
+
readonly QUERY_MALFORMED: "wow.query.malformed";
|
|
57
|
+
/** 400: the query failed admission; each violation has its code. */
|
|
58
|
+
readonly QUERY_INVALID: "wow.query.invalid";
|
|
59
|
+
/** 500: the query backend failed to run the query. */
|
|
60
|
+
readonly QUERY_FAILED: "wow.query.failed";
|
|
61
|
+
/** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */
|
|
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";
|
|
82
|
+
};
|
|
83
|
+
/** A {@link FrameworkErrorCodes} value. */
|
|
84
|
+
export type FrameworkErrorCode = (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];
|
|
85
|
+
/** The prefix of every framework code, and of no domain code. */
|
|
86
|
+
export declare const FRAMEWORK_ERROR_PREFIX = "wow.";
|
|
87
|
+
/** The prefix of a problem's `type` that carries a Wow code. */
|
|
88
|
+
export declare const PROBLEM_TYPE_PREFIX = "urn:wow:error:";
|
|
89
|
+
/**
|
|
90
|
+
* An RFC 9457 problem as a Wow service writes it (decisions D101, D102):
|
|
91
|
+
* `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is
|
|
92
|
+
* only HTTP's (a missing route, 406, 415).
|
|
93
|
+
*/
|
|
94
|
+
export interface Problem {
|
|
95
|
+
readonly type: string;
|
|
96
|
+
readonly title: string;
|
|
97
|
+
readonly status: number;
|
|
98
|
+
readonly detail?: string;
|
|
99
|
+
/** The Wow code; absent for an error that is only HTTP's. */
|
|
100
|
+
readonly code?: string;
|
|
101
|
+
readonly violations?: readonly Violation[];
|
|
102
|
+
/** The whole result of a command that has a ref. */
|
|
103
|
+
readonly result?: CommandResult;
|
|
104
|
+
/**
|
|
105
|
+
* The problem's extension members (RFC 9457): every member the server
|
|
106
|
+
* wrote besides the ones above and `instance`, such as a rejection's
|
|
107
|
+
* structured data (decision D211). Absent when it wrote none.
|
|
108
|
+
*/
|
|
109
|
+
readonly extensions?: Readonly<Record<string, unknown>>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What a client may do about a failed request: whether retrying can succeed,
|
|
113
|
+
* whether to keep the request id (`Wow-Request-Id`) so the server
|
|
114
|
+
* deduplicates a command that did commit, and how long to wait first.
|
|
115
|
+
*/
|
|
116
|
+
export interface RetryHint {
|
|
117
|
+
readonly retryable: boolean;
|
|
118
|
+
/** Retry with the same `Wow-Request-Id`: a commit is then answered as a duplicate. */
|
|
119
|
+
readonly sameRequestId: boolean;
|
|
120
|
+
/** The server's `Retry-After`, in milliseconds. */
|
|
121
|
+
readonly afterMs?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The retry hint of a problem with `code` and `status`: a code of the
|
|
125
|
+
* retryable table, or a 503 without a code (a proxy's), may be retried.
|
|
126
|
+
*
|
|
127
|
+
* @param code - The problem's Wow code, if any
|
|
128
|
+
* @param status - The HTTP status
|
|
129
|
+
* @param afterMs - The `Retry-After` the response carried, in milliseconds
|
|
130
|
+
*/
|
|
131
|
+
export declare function retryHintOf(code: string | undefined, status: number, afterMs?: number): RetryHint;
|
|
132
|
+
/**
|
|
133
|
+
* A request a Wow service answered with a problem: a non-2xx response, a
|
|
134
|
+
* command result that did not succeed, or the `error` event that ends a
|
|
135
|
+
* streamed query.
|
|
136
|
+
*/
|
|
137
|
+
export declare class WowProblemError extends Error {
|
|
138
|
+
readonly name = "WowProblemError";
|
|
139
|
+
/** The problem as the server wrote it. */
|
|
140
|
+
readonly problem: Problem;
|
|
141
|
+
/** The HTTP status. */
|
|
142
|
+
readonly status: number;
|
|
143
|
+
/** The Wow code; absent for an error that is only HTTP's. */
|
|
144
|
+
readonly code?: string;
|
|
145
|
+
readonly violations: readonly Violation[];
|
|
146
|
+
/** The command's result, when the command had a ref. */
|
|
147
|
+
readonly result?: CommandResult;
|
|
148
|
+
/** What a client may do about it. */
|
|
149
|
+
readonly retry: RetryHint;
|
|
150
|
+
/** The error this one explains: the fetcher's, or the stream's. */
|
|
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;
|
|
158
|
+
/**
|
|
159
|
+
* @param problem - The problem the server answered with
|
|
160
|
+
* @param options - The response's `Retry-After` in milliseconds, and the
|
|
161
|
+
* error this one explains
|
|
162
|
+
*/
|
|
163
|
+
constructor(problem: Problem, options?: {
|
|
164
|
+
retryAfterMs?: number;
|
|
165
|
+
cause?: unknown;
|
|
166
|
+
});
|
|
167
|
+
/** Whether the code is a framework one (`wow.*`) rather than the domain's. */
|
|
168
|
+
get isFramework(): boolean;
|
|
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;
|
|
188
|
+
/** Whether `value` reads as a problem: an object with a numeric `status`. */
|
|
189
|
+
export declare function isProblem(value: unknown): value is Problem;
|
|
190
|
+
/**
|
|
191
|
+
* The milliseconds of a `Retry-After` header: delay seconds or an HTTP date.
|
|
192
|
+
*
|
|
193
|
+
* @param value - The header's value
|
|
194
|
+
* @param now - The current time, in epoch milliseconds
|
|
195
|
+
*/
|
|
196
|
+
export declare function parseRetryAfter(value: string | null | undefined, now?: number): number | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The problem a response that did not succeed carries: its body when it is
|
|
199
|
+
* a problem (or a code the `type` names), else one made of its status.
|
|
200
|
+
*
|
|
201
|
+
* @param response - A response that is not 2xx
|
|
202
|
+
*/
|
|
203
|
+
export declare function readProblem(response: Response): Promise<Problem>;
|
|
204
|
+
/**
|
|
205
|
+
* The {@link WowProblemError} of an error a request rejected with: the
|
|
206
|
+
* fetcher's `ExchangeError` of a response that is not 2xx, read as a problem.
|
|
207
|
+
* Undefined for a failure no server answered (a network error, an abort).
|
|
208
|
+
*
|
|
209
|
+
* @param error - What the request rejected with
|
|
210
|
+
*/
|
|
211
|
+
export declare function toWowProblemError(error: unknown): Promise<WowProblemError | undefined>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
//#region src/problem.ts
|
|
2
|
+
var e = {
|
|
3
|
+
AUTH_UNAUTHENTICATED: "wow.auth.unauthenticated",
|
|
4
|
+
AUTH_FORBIDDEN: "wow.auth.forbidden",
|
|
5
|
+
AGGREGATE_FORBIDDEN: "wow.aggregate.forbidden",
|
|
6
|
+
COMMAND_MALFORMED: "wow.command.malformed",
|
|
7
|
+
COMMAND_INVALID: "wow.command.invalid",
|
|
8
|
+
WAIT_INVALID: "wow.wait.invalid",
|
|
9
|
+
COMMAND_UNHANDLED: "wow.command.unhandled",
|
|
10
|
+
AGGREGATE_NOT_FOUND: "wow.aggregate.not-found",
|
|
11
|
+
AGGREGATE_EXISTS: "wow.aggregate.exists",
|
|
12
|
+
AGGREGATE_VERSION_MISMATCH: "wow.aggregate.version-mismatch",
|
|
13
|
+
COMMAND_REQUEST_ID_REUSED: "wow.command.request-id-reused",
|
|
14
|
+
COMMAND_CONTENDED: "wow.command.contended",
|
|
15
|
+
AGGREGATE_DELETED: "wow.aggregate.deleted",
|
|
16
|
+
COMMAND_BUSY: "wow.command.busy",
|
|
17
|
+
COMMAND_UNKNOWN: "wow.command.unknown",
|
|
18
|
+
COMMAND_FAILED: "wow.command.failed",
|
|
19
|
+
NODE_CLOSING: "wow.node.closing",
|
|
20
|
+
NODE_STANDBY: "wow.node.standby",
|
|
21
|
+
STORAGE_UNAVAILABLE: "wow.storage.unavailable",
|
|
22
|
+
SCHEDULE_NOT_DUE: "wow.schedule.not-due",
|
|
23
|
+
SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid",
|
|
24
|
+
SUBSCRIPTION_PARKED: "wow.subscription.parked",
|
|
25
|
+
WAIT_TIMEOUT: "wow.wait.timeout",
|
|
26
|
+
QUERY_MALFORMED: "wow.query.malformed",
|
|
27
|
+
QUERY_INVALID: "wow.query.invalid",
|
|
28
|
+
QUERY_FAILED: "wow.query.failed",
|
|
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"
|
|
36
|
+
}, t = "wow.", n = "urn:wow:error:", r = /* @__PURE__ */ new Set([
|
|
37
|
+
"type",
|
|
38
|
+
"title",
|
|
39
|
+
"status",
|
|
40
|
+
"detail",
|
|
41
|
+
"instance",
|
|
42
|
+
"code",
|
|
43
|
+
"violations",
|
|
44
|
+
"result",
|
|
45
|
+
"extensions"
|
|
46
|
+
]);
|
|
47
|
+
function i(e) {
|
|
48
|
+
if (e.extensions !== void 0) return e;
|
|
49
|
+
let t = Object.fromEntries(Object.entries(e).filter(([e]) => !r.has(e)));
|
|
50
|
+
return Object.keys(t).length === 0 ? e : {
|
|
51
|
+
...e,
|
|
52
|
+
extensions: t
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var a = /* @__PURE__ */ new Map([
|
|
56
|
+
[e.COMMAND_UNKNOWN, !0],
|
|
57
|
+
[e.NODE_CLOSING, !0],
|
|
58
|
+
[e.NODE_STANDBY, !0],
|
|
59
|
+
[e.STORAGE_UNAVAILABLE, !0],
|
|
60
|
+
[e.SCHEDULE_NOT_DUE, !0],
|
|
61
|
+
[e.COMMAND_BUSY, !0],
|
|
62
|
+
[e.QUERY_BUSY, !1],
|
|
63
|
+
[e.QUERY_MIN_VERSION_NOT_REACHED, !1],
|
|
64
|
+
[e.COMMAND_CONTENDED, !0],
|
|
65
|
+
[e.WAIT_TIMEOUT, !0]
|
|
66
|
+
]);
|
|
67
|
+
function o(e, t, n) {
|
|
68
|
+
let r = e === void 0 ? void 0 : a.get(e), i = r !== void 0 || e === void 0 && t === 503;
|
|
69
|
+
return {
|
|
70
|
+
retryable: i,
|
|
71
|
+
sameRequestId: r ?? i,
|
|
72
|
+
...n === void 0 ? {} : { afterMs: n }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var s = class extends Error {
|
|
76
|
+
get requestId() {
|
|
77
|
+
return this.result?.requestId ?? c.get(this);
|
|
78
|
+
}
|
|
79
|
+
constructor(e, t = {}) {
|
|
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);
|
|
81
|
+
}
|
|
82
|
+
get isFramework() {
|
|
83
|
+
return this.code?.startsWith("wow.") ?? !1;
|
|
84
|
+
}
|
|
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) {
|
|
93
|
+
return typeof e == "object" && !!e && typeof e.status == "number";
|
|
94
|
+
}
|
|
95
|
+
function f(e, t = Date.now()) {
|
|
96
|
+
if (!e) return;
|
|
97
|
+
let n = e.trim();
|
|
98
|
+
if (/^\d+$/.test(n)) return Number(n) * 1e3;
|
|
99
|
+
let r = Date.parse(n);
|
|
100
|
+
return Number.isNaN(r) ? void 0 : Math.max(0, r - t);
|
|
101
|
+
}
|
|
102
|
+
async function p(e) {
|
|
103
|
+
let t;
|
|
104
|
+
try {
|
|
105
|
+
t = await e.clone().json();
|
|
106
|
+
} catch {}
|
|
107
|
+
if (d(t)) {
|
|
108
|
+
let n = t.code ?? (t.type?.startsWith("urn:wow:error:") ? t.type.slice(14) : void 0);
|
|
109
|
+
return i({
|
|
110
|
+
...t,
|
|
111
|
+
type: t.type ?? "about:blank",
|
|
112
|
+
title: t.title ?? e.statusText,
|
|
113
|
+
...n === void 0 ? {} : { code: n }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
type: "about:blank",
|
|
118
|
+
title: e.statusText,
|
|
119
|
+
status: e.status
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function m(e) {
|
|
123
|
+
if (e instanceof s) return e;
|
|
124
|
+
if (typeof e != "object" || !e) return;
|
|
125
|
+
let { exchange: t, cause: n } = e;
|
|
126
|
+
if (n instanceof s) return n;
|
|
127
|
+
let r = t?.response;
|
|
128
|
+
if (!r || r.ok) return;
|
|
129
|
+
let i = await p(r), a = f(r.headers.get("Retry-After"));
|
|
130
|
+
return new s(i, {
|
|
131
|
+
cause: e,
|
|
132
|
+
...a === void 0 ? {} : { retryAfterMs: a }
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
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 };
|
|
137
|
+
|
|
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":"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"}
|
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
|