@ahoo-wang/wow-client 10.0.0-beta.1 → 10.0.0-beta.2
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 +4 -2
- package/README.zh-CN.md +1 -1
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +1 -8
- package/dist/commands.d.ts +1 -8
- package/dist/commands.es.js +45 -51
- package/dist/commands.es.js.map +1 -1
- package/dist/dsl/aggregation/admit.cjs +1 -1
- package/dist/dsl/aggregation/admit.cjs.map +1 -1
- package/dist/dsl/aggregation/admit.es.js +73 -69
- package/dist/dsl/aggregation/admit.es.js.map +1 -1
- package/dist/dsl/aggregation/aliases.cjs +2 -0
- package/dist/dsl/aggregation/aliases.cjs.map +1 -0
- package/dist/dsl/aggregation/aliases.d.cts +2 -0
- package/dist/dsl/aggregation/aliases.d.ts +2 -0
- package/dist/dsl/aggregation/aliases.es.js +13 -0
- package/dist/dsl/aggregation/aliases.es.js.map +1 -0
- package/dist/dsl/aggregation/builders.cjs +1 -1
- package/dist/dsl/aggregation/builders.cjs.map +1 -1
- package/dist/dsl/aggregation/builders.d.cts +17 -243
- package/dist/dsl/aggregation/builders.d.ts +17 -243
- package/dist/dsl/aggregation/builders.es.js +36 -171
- package/dist/dsl/aggregation/builders.es.js.map +1 -1
- package/dist/dsl/aggregation/derived.cjs +1 -1
- package/dist/dsl/aggregation/derived.cjs.map +1 -1
- package/dist/dsl/aggregation/derived.d.cts +123 -1
- package/dist/dsl/aggregation/derived.d.ts +123 -1
- package/dist/dsl/aggregation/derived.es.js +43 -28
- package/dist/dsl/aggregation/derived.es.js.map +1 -1
- package/dist/dsl/aggregation/groups.cjs +2 -0
- package/dist/dsl/aggregation/groups.cjs.map +1 -0
- package/dist/dsl/aggregation/groups.d.cts +325 -0
- package/dist/dsl/aggregation/groups.d.ts +325 -0
- package/dist/dsl/aggregation/groups.es.js +80 -0
- package/dist/dsl/aggregation/groups.es.js.map +1 -0
- package/dist/dsl/aggregation/having.cjs +1 -1
- package/dist/dsl/aggregation/having.cjs.map +1 -1
- package/dist/dsl/aggregation/having.d.cts +63 -1
- package/dist/dsl/aggregation/having.d.ts +63 -1
- package/dist/dsl/aggregation/having.es.js +33 -30
- package/dist/dsl/aggregation/having.es.js.map +1 -1
- package/dist/dsl/aggregation/index.d.cts +4 -2
- package/dist/dsl/aggregation/index.d.ts +4 -2
- package/dist/dsl/aggregation/metrics.cjs +2 -0
- package/dist/dsl/aggregation/metrics.cjs.map +1 -0
- package/dist/dsl/aggregation/metrics.d.cts +279 -0
- package/dist/dsl/aggregation/metrics.d.ts +279 -0
- package/dist/dsl/aggregation/metrics.es.js +75 -0
- package/dist/dsl/aggregation/metrics.es.js.map +1 -0
- package/dist/dsl/aggregation/types.cjs +1 -1
- package/dist/dsl/aggregation/types.cjs.map +1 -1
- package/dist/dsl/aggregation/types.d.cts +4 -524
- package/dist/dsl/aggregation/types.d.ts +4 -524
- package/dist/dsl/aggregation/types.es.js +5 -25
- package/dist/dsl/aggregation/types.es.js.map +1 -1
- package/dist/dsl/cursorQuery.cjs +1 -1
- package/dist/dsl/cursorQuery.cjs.map +1 -1
- package/dist/dsl/cursorQuery.d.cts +18 -7
- package/dist/dsl/cursorQuery.d.ts +18 -7
- package/dist/dsl/cursorQuery.es.js +13 -12
- package/dist/dsl/cursorQuery.es.js.map +1 -1
- package/dist/dsl/descriptor.cjs +1 -1
- package/dist/dsl/descriptor.cjs.map +1 -1
- package/dist/dsl/descriptor.d.cts +17 -379
- package/dist/dsl/descriptor.d.ts +17 -379
- package/dist/dsl/descriptor.es.js +4 -31
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/dsl/fieldDescriptor.cjs +2 -0
- package/dist/dsl/fieldDescriptor.cjs.map +1 -0
- package/dist/dsl/fieldDescriptor.d.cts +246 -0
- package/dist/dsl/fieldDescriptor.d.ts +246 -0
- package/dist/dsl/fieldDescriptor.es.js +24 -0
- package/dist/dsl/fieldDescriptor.es.js.map +1 -0
- package/dist/dsl/filter/builders.cjs +1 -1
- package/dist/dsl/filter/builders.cjs.map +1 -1
- package/dist/dsl/filter/builders.d.cts +7 -949
- package/dist/dsl/filter/builders.d.ts +7 -949
- package/dist/dsl/filter/builders.es.js +14 -285
- package/dist/dsl/filter/builders.es.js.map +1 -1
- package/dist/dsl/filter/expressionFilter.cjs +2 -0
- package/dist/dsl/filter/expressionFilter.cjs.map +1 -0
- package/dist/dsl/filter/expressionFilter.d.cts +35 -0
- package/dist/dsl/filter/expressionFilter.d.ts +35 -0
- package/dist/dsl/filter/expressionFilter.es.js +18 -0
- package/dist/dsl/filter/expressionFilter.es.js.map +1 -0
- package/dist/dsl/filter/fieldFilters.cjs +2 -0
- package/dist/dsl/filter/fieldFilters.cjs.map +1 -0
- package/dist/dsl/filter/fieldFilters.d.cts +297 -0
- package/dist/dsl/filter/fieldFilters.d.ts +297 -0
- package/dist/dsl/filter/fieldFilters.es.js +110 -0
- package/dist/dsl/filter/fieldFilters.es.js.map +1 -0
- package/dist/dsl/filter/index.d.cts +2 -1
- package/dist/dsl/filter/index.d.ts +2 -1
- package/dist/dsl/filter/logicalFilters.cjs +2 -0
- package/dist/dsl/filter/logicalFilters.cjs.map +1 -0
- package/dist/dsl/filter/logicalFilters.d.cts +109 -0
- package/dist/dsl/filter/logicalFilters.d.ts +109 -0
- package/dist/dsl/filter/logicalFilters.es.js +36 -0
- package/dist/dsl/filter/logicalFilters.es.js.map +1 -0
- package/dist/dsl/filter/metadataFilters.cjs +2 -0
- package/dist/dsl/filter/metadataFilters.cjs.map +1 -0
- package/dist/dsl/filter/metadataFilters.d.cts +132 -0
- package/dist/dsl/filter/metadataFilters.d.ts +132 -0
- package/dist/dsl/filter/metadataFilters.es.js +56 -0
- package/dist/dsl/filter/metadataFilters.es.js.map +1 -0
- package/dist/dsl/filter/operator.cjs +1 -1
- package/dist/dsl/filter/operator.cjs.map +1 -1
- package/dist/dsl/filter/operator.d.cts +11 -9
- package/dist/dsl/filter/operator.d.ts +11 -9
- package/dist/dsl/filter/operator.es.js +1 -1
- package/dist/dsl/filter/operator.es.js.map +1 -1
- package/dist/dsl/filter/searchFilter.cjs +2 -0
- package/dist/dsl/filter/searchFilter.cjs.map +1 -0
- package/dist/dsl/filter/searchFilter.d.cts +39 -0
- package/dist/dsl/filter/searchFilter.d.ts +39 -0
- package/dist/dsl/filter/searchFilter.es.js +19 -0
- package/dist/dsl/filter/searchFilter.es.js.map +1 -0
- package/dist/dsl/filter/timeFilters.cjs +2 -0
- package/dist/dsl/filter/timeFilters.cjs.map +1 -0
- package/dist/dsl/filter/timeFilters.d.cts +290 -0
- package/dist/dsl/filter/timeFilters.d.ts +290 -0
- package/dist/dsl/filter/timeFilters.es.js +89 -0
- package/dist/dsl/filter/timeFilters.es.js.map +1 -0
- package/dist/dsl/filter/types.d.cts +4 -14
- package/dist/dsl/filter/types.d.ts +4 -14
- package/dist/dsl/filter/validate.cjs +1 -1
- package/dist/dsl/filter/validate.cjs.map +1 -1
- package/dist/dsl/filter/validate.d.cts +2 -4
- package/dist/dsl/filter/validate.d.ts +2 -4
- package/dist/dsl/filter/validate.es.js +25 -31
- package/dist/dsl/filter/validate.es.js.map +1 -1
- package/dist/dsl/queryErrorCodes.cjs +1 -1
- package/dist/dsl/queryErrorCodes.cjs.map +1 -1
- package/dist/dsl/queryErrorCodes.d.cts +0 -2
- package/dist/dsl/queryErrorCodes.d.ts +0 -2
- package/dist/dsl/queryErrorCodes.es.js +0 -1
- package/dist/dsl/queryErrorCodes.es.js.map +1 -1
- package/dist/dsl/queryFilter.cjs +2 -0
- package/dist/dsl/queryFilter.cjs.map +1 -0
- package/dist/dsl/queryFilter.d.cts +3 -0
- package/dist/dsl/queryFilter.d.ts +3 -0
- package/dist/dsl/queryFilter.es.js +9 -0
- package/dist/dsl/queryFilter.es.js.map +1 -0
- package/dist/dsl/queryable.cjs +1 -1
- package/dist/dsl/queryable.cjs.map +1 -1
- package/dist/dsl/queryable.es.js +12 -16
- package/dist/dsl/queryable.es.js.map +1 -1
- package/dist/dsl/semanticTypes.cjs +2 -0
- package/dist/dsl/semanticTypes.cjs.map +1 -0
- package/dist/dsl/semanticTypes.d.cts +128 -0
- package/dist/dsl/semanticTypes.d.ts +128 -0
- package/dist/dsl/semanticTypes.es.js +13 -0
- package/dist/dsl/semanticTypes.es.js.map +1 -0
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.d.cts +2 -0
- package/dist/dsl.d.ts +2 -0
- package/dist/dsl.es.js +14 -8
- package/dist/exactJson.cjs +2 -2
- package/dist/exactJson.cjs.map +1 -1
- package/dist/exactJson.d.cts +41 -16
- package/dist/exactJson.d.ts +41 -16
- package/dist/exactJson.es.js +104 -102
- package/dist/exactJson.es.js.map +1 -1
- package/dist/frameworkErrors.cjs.map +1 -1
- package/dist/frameworkErrors.d.cts +4 -4
- package/dist/frameworkErrors.d.ts +4 -4
- package/dist/frameworkErrors.es.js.map +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +29 -9
- package/dist/http.d.ts +29 -9
- package/dist/http.es.js +24 -19
- package/dist/http.es.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.es.js +12 -12
- package/dist/manifest.cjs +1 -1
- package/dist/manifest.cjs.map +1 -1
- package/dist/manifest.d.cts +24 -0
- package/dist/manifest.d.ts +24 -0
- package/dist/manifest.es.js +34 -6
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +16 -1
- package/dist/manifestTypes.d.ts +16 -1
- package/dist/queries.cjs +1 -1
- package/dist/queries.cjs.map +1 -1
- package/dist/queries.d.cts +18 -8
- package/dist/queries.d.ts +18 -8
- package/dist/queries.es.js +46 -35
- package/dist/queries.es.js.map +1 -1
- package/dist/routes.cjs +1 -1
- package/dist/routes.cjs.map +1 -1
- package/dist/routes.d.cts +16 -3
- package/dist/routes.d.ts +16 -3
- package/dist/routes.es.js +24 -25
- package/dist/routes.es.js.map +1 -1
- package/dist/state.cjs +1 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +21 -19
- package/dist/state.d.ts +21 -19
- package/dist/state.es.js +27 -22
- package/dist/state.es.js.map +1 -1
- package/dist/streams.cjs +1 -1
- package/dist/streams.cjs.map +1 -1
- package/dist/streams.d.cts +14 -7
- package/dist/streams.d.ts +14 -7
- package/dist/streams.es.js +65 -50
- package/dist/streams.es.js.map +1 -1
- package/dist/testing/wire.cjs +1 -1
- package/dist/testing/wire.cjs.map +1 -1
- package/dist/testing/wire.es.js +1 -1
- package/dist/testing/wire.es.js.map +1 -1
- package/dist/wait.cjs +1 -1
- package/dist/wait.cjs.map +1 -1
- package/dist/wait.d.cts +17 -4
- package/dist/wait.d.ts +17 -4
- package/dist/wait.es.js +36 -34
- package/dist/wait.es.js.map +1 -1
- package/dist/wire.cjs +1 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +75 -31
- package/dist/wire.d.ts +75 -31
- package/dist/wire.es.js +1 -3
- package/dist/wire.es.js.map +1 -1
- package/package.json +5 -5
- package/dist/dsl/filter/datePattern.cjs +0 -2
- package/dist/dsl/filter/datePattern.cjs.map +0 -1
- package/dist/dsl/filter/datePattern.d.cts +0 -8
- package/dist/dsl/filter/datePattern.d.ts +0 -8
- package/dist/dsl/filter/datePattern.es.js +0 -96
- package/dist/dsl/filter/datePattern.es.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exactJson.cjs"),t=require("./frameworkErrors.cjs"),n=require("./wire.cjs"),r=require("./problem.cjs"),i=require("./http.cjs"),a=require("./manifest.cjs"),o=require("./wait.cjs"),s=require("./commands.cjs"),c=require("./developmentCaller.cjs"),l=require("./queries.cjs"),u=require("./state.cjs");exports.CommandClient=s.CommandClient,exports.CommandRejectedError=r.CommandRejectedError,exports.CommandResultStatus=n.CommandResultStatus,exports.DEFAULT_RETRY=t.DEFAULT_RETRY,exports.DatasetClient=l.DatasetClient,exports.DevelopmentCallerHeaders=c.DevelopmentCallerHeaders,exports.EventQueryClient=l.EventQueryClient,exports.FRAMEWORK_ERROR_PREFIX=r.FRAMEWORK_ERROR_PREFIX,exports.FRAMEWORK_RETRIES=t.FRAMEWORK_RETRIES,exports.FrameworkErrorCodes=t.FrameworkErrorCodes,exports.FunctionKind=n.FunctionKind,exports.LifecycleCommands=s.LifecycleCommands,exports.MANIFEST_FEATURES=a.MANIFEST_FEATURES,exports.MANIFEST_FORMAT=a.MANIFEST_FORMAT,exports.OwnStateClient=u.OwnStateClient,exports.PROBLEM_TYPE_PREFIX=r.PROBLEM_TYPE_PREFIX,exports.QueryModelClient=l.QueryModelClient,exports.SNAPSHOT_SUBSCRIPTION=o.SNAPSHOT_SUBSCRIPTION,exports.SnapshotQueryClient=l.SnapshotQueryClient,exports.Stage=n.Stage,exports.StateClient=u.StateClient,exports.WaitPlan=o.WaitPlan,exports.WowHeaders=i.WowHeaders,exports.WowProblemError=r.WowProblemError,exports.checkManifest=a.checkManifest,exports.developmentCaller=c.developmentCaller,exports.developmentCallerHeaders=c.developmentCallerHeaders,exports.fetchManifest=a.fetchManifest,exports.formatHop=o.formatHop,exports.formatScope=i.formatScope,exports.formatWaitPlan=o.formatWaitPlan,exports.formatWaitTimeout=o.formatWaitTimeout,exports.isProblem=r.isProblem,exports.newRequestId=s.newRequestId,exports.parseHop=o.parseHop,exports.parseJson=e.parseJson,exports.parseRetryAfter=r.parseRetryAfter,exports.parseWaitPlan=o.parseWaitPlan,exports.queryPath=l.queryPath,exports.readProblem=r.readProblem,exports.requestIdOf=r.requestIdOf,exports.retryOf=r.retryOf,exports.stringifyJson=e.stringifyJson,exports.textNumbersBy=e.textNumbersBy,exports.toWowProblemError=r.toWowProblemError,exports.wait=o.wait;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exactJson.cjs"),t=require("./frameworkErrors.cjs"),n=require("./wire.cjs"),r=require("./problem.cjs"),i=require("./http.cjs"),a=require("./manifest.cjs"),o=require("./wait.cjs"),s=require("./commands.cjs"),c=require("./developmentCaller.cjs"),l=require("./queries.cjs"),u=require("./state.cjs");exports.CommandClient=s.CommandClient,exports.CommandRejectedError=r.CommandRejectedError,exports.CommandResultStatus=n.CommandResultStatus,exports.DEFAULT_RETRY=t.DEFAULT_RETRY,exports.DatasetClient=l.DatasetClient,exports.DevelopmentCallerHeaders=c.DevelopmentCallerHeaders,exports.EventQueryClient=l.EventQueryClient,exports.FRAMEWORK_ERROR_PREFIX=r.FRAMEWORK_ERROR_PREFIX,exports.FRAMEWORK_RETRIES=t.FRAMEWORK_RETRIES,exports.FrameworkErrorCodes=t.FrameworkErrorCodes,exports.FunctionKind=n.FunctionKind,exports.LifecycleCommands=s.LifecycleCommands,exports.MANIFEST_FEATURES=a.MANIFEST_FEATURES,exports.MANIFEST_FORMAT=a.MANIFEST_FORMAT,exports.OwnStateClient=u.OwnStateClient,exports.PROBLEM_TYPE_PREFIX=r.PROBLEM_TYPE_PREFIX,exports.QUERYABLE_SUBSCRIPTION=o.QUERYABLE_SUBSCRIPTION,exports.QueryModelClient=l.QueryModelClient,exports.SNAPSHOT_SUBSCRIPTION=o.SNAPSHOT_SUBSCRIPTION,exports.SnapshotQueryClient=l.SnapshotQueryClient,exports.Stage=n.Stage,exports.StateClient=u.StateClient,exports.WaitPlan=o.WaitPlan,exports.WowHeaders=i.WowHeaders,exports.WowProblemError=r.WowProblemError,exports.checkManifest=a.checkManifest,exports.developmentCaller=c.developmentCaller,exports.developmentCallerHeaders=c.developmentCallerHeaders,exports.fetchManifest=a.fetchManifest,exports.formatHop=o.formatHop,exports.formatScope=i.formatScope,exports.formatWaitPlan=o.formatWaitPlan,exports.formatWaitTimeout=o.formatWaitTimeout,exports.isProblem=r.isProblem,exports.newRequestId=s.newRequestId,exports.parseHop=o.parseHop,exports.parseJson=e.parseJson,exports.parseRetryAfter=r.parseRetryAfter,exports.parseWaitPlan=o.parseWaitPlan,exports.queryPath=l.queryPath,exports.readProblem=r.readProblem,exports.requestIdOf=r.requestIdOf,exports.retryOf=r.retryOf,exports.stringifyJson=e.stringifyJson,exports.textNumberOr=e.textNumberOr,exports.textNumbersBy=e.textNumbersBy,exports.toWowProblemError=r.toWowProblemError,exports.wait=o.wait;
|
package/dist/index.d.cts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
|
|
9
9
|
*/
|
|
10
|
-
export {
|
|
11
|
-
export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.cjs';
|
|
10
|
+
export { CommandClient, type CommandClientOptions, type CommandOptions, type CommandRequest, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.cjs';
|
|
11
|
+
export { parseJson, stringifyJson, textNumberOr, type TextNumbers, textNumbersBy, type TextNumbersByName, type TextNumbersOr, } from './exactJson.cjs';
|
|
12
12
|
export { type DevelopmentCaller, developmentCaller, developmentCallerHeaders, DevelopmentCallerHeaders, } from './developmentCaller.cjs';
|
|
13
13
|
export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.cjs';
|
|
14
14
|
export { checkManifest, type Creation, fetchManifest, MANIFEST_FEATURES, MANIFEST_FORMAT, type RoutingCommand, type RoutingManifest, type RoutingServiceRoute, } from './manifest.cjs';
|
|
@@ -18,4 +18,4 @@ export { CommandRejectedError, DEFAULT_RETRY, FRAMEWORK_ERROR_PREFIX, FRAMEWORK_
|
|
|
18
18
|
export { type CountQuery, type CountResult, DatasetClient, EventQueryClient, type StreamOptions, type Including, QueryModelClient, queryPath, SnapshotQueryClient, } from './queries.cjs';
|
|
19
19
|
export { OwnStateClient, StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.cjs';
|
|
20
20
|
export { type CommandResultStream, type Positioned, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.cjs';
|
|
21
|
-
export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.cjs';
|
|
21
|
+
export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, QUERYABLE_SUBSCRIPTION, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
|
|
9
9
|
*/
|
|
10
|
-
export {
|
|
11
|
-
export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.js';
|
|
10
|
+
export { CommandClient, type CommandClientOptions, type CommandOptions, type CommandRequest, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.js';
|
|
11
|
+
export { parseJson, stringifyJson, textNumberOr, type TextNumbers, textNumbersBy, type TextNumbersByName, type TextNumbersOr, } from './exactJson.js';
|
|
12
12
|
export { type DevelopmentCaller, developmentCaller, developmentCallerHeaders, DevelopmentCallerHeaders, } from './developmentCaller.js';
|
|
13
13
|
export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.js';
|
|
14
14
|
export { checkManifest, type Creation, fetchManifest, MANIFEST_FEATURES, MANIFEST_FORMAT, type RoutingCommand, type RoutingManifest, type RoutingServiceRoute, } from './manifest.js';
|
|
@@ -18,4 +18,4 @@ export { CommandRejectedError, DEFAULT_RETRY, FRAMEWORK_ERROR_PREFIX, FRAMEWORK_
|
|
|
18
18
|
export { type CountQuery, type CountResult, DatasetClient, EventQueryClient, type StreamOptions, type Including, QueryModelClient, queryPath, SnapshotQueryClient, } from './queries.js';
|
|
19
19
|
export { OwnStateClient, StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.js';
|
|
20
20
|
export { type CommandResultStream, type Positioned, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.js';
|
|
21
|
-
export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.js';
|
|
21
|
+
export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, QUERYABLE_SUBSCRIPTION, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.js';
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { parseJson as e, stringifyJson as t,
|
|
2
|
-
import { DEFAULT_RETRY as
|
|
3
|
-
import { CommandResultStatus as
|
|
4
|
-
import { CommandRejectedError as
|
|
5
|
-
import { WowHeaders as
|
|
6
|
-
import { MANIFEST_FEATURES as
|
|
7
|
-
import { SNAPSHOT_SUBSCRIPTION as
|
|
8
|
-
import { CommandClient as
|
|
9
|
-
import { DevelopmentCallerHeaders as
|
|
10
|
-
import { DatasetClient as
|
|
11
|
-
import { OwnStateClient as
|
|
12
|
-
export {
|
|
1
|
+
import { parseJson as e, stringifyJson as t, textNumberOr as n, textNumbersBy as r } from "./exactJson.es.js";
|
|
2
|
+
import { DEFAULT_RETRY as i, FRAMEWORK_RETRIES as a, FrameworkErrorCodes as o } from "./frameworkErrors.es.js";
|
|
3
|
+
import { CommandResultStatus as s, FunctionKind as c, Stage as l } from "./wire.es.js";
|
|
4
|
+
import { CommandRejectedError as u, FRAMEWORK_ERROR_PREFIX as d, PROBLEM_TYPE_PREFIX as f, WowProblemError as p, isProblem as m, parseRetryAfter as h, readProblem as g, requestIdOf as _, retryOf as v, toWowProblemError as y } from "./problem.es.js";
|
|
5
|
+
import { WowHeaders as b, formatScope as x } from "./http.es.js";
|
|
6
|
+
import { MANIFEST_FEATURES as S, MANIFEST_FORMAT as C, checkManifest as w, fetchManifest as T } from "./manifest.es.js";
|
|
7
|
+
import { QUERYABLE_SUBSCRIPTION as E, SNAPSHOT_SUBSCRIPTION as D, WaitPlan as O, formatHop as k, formatWaitPlan as A, formatWaitTimeout as j, parseHop as M, parseWaitPlan as N, wait as P } from "./wait.es.js";
|
|
8
|
+
import { CommandClient as F, LifecycleCommands as I, newRequestId as L } from "./commands.es.js";
|
|
9
|
+
import { DevelopmentCallerHeaders as R, developmentCaller as z, developmentCallerHeaders as B } from "./developmentCaller.es.js";
|
|
10
|
+
import { DatasetClient as V, EventQueryClient as H, QueryModelClient as U, SnapshotQueryClient as W, queryPath as G } from "./queries.es.js";
|
|
11
|
+
import { OwnStateClient as K, StateClient as q } from "./state.es.js";
|
|
12
|
+
export { F as CommandClient, u as CommandRejectedError, s as CommandResultStatus, i as DEFAULT_RETRY, V as DatasetClient, R as DevelopmentCallerHeaders, H as EventQueryClient, d as FRAMEWORK_ERROR_PREFIX, a as FRAMEWORK_RETRIES, o as FrameworkErrorCodes, c as FunctionKind, I as LifecycleCommands, S as MANIFEST_FEATURES, C as MANIFEST_FORMAT, K as OwnStateClient, f as PROBLEM_TYPE_PREFIX, E as QUERYABLE_SUBSCRIPTION, U as QueryModelClient, D as SNAPSHOT_SUBSCRIPTION, W as SnapshotQueryClient, l as Stage, q as StateClient, O as WaitPlan, b as WowHeaders, p as WowProblemError, w as checkManifest, z as developmentCaller, B as developmentCallerHeaders, T as fetchManifest, k as formatHop, x as formatScope, A as formatWaitPlan, j as formatWaitTimeout, m as isProblem, L as newRequestId, M as parseHop, e as parseJson, h as parseRetryAfter, N as parseWaitPlan, G as queryPath, g as readProblem, _ as requestIdOf, v as retryOf, t as stringifyJson, n as textNumberOr, r as textNumbersBy, y as toWowProblemError, P as wait };
|
package/dist/manifest.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./http.cjs");var
|
|
1
|
+
const e=require("./problem.cjs"),t=require("./http.cjs");var n=1,r=new Set;function i(e){if(e.format!==1)throw TypeError(`The Manifest is of format ${e.format}; this client reads format 1.`);let t=(e.requires??[]).filter(e=>!r.has(e));if(t.length>0)throw TypeError(`The Manifest requires ${t.join(`, `)}, which this client does not understand: use a newer @ahoo-wang/wow-client.`);return e}async function a(e={},n){return i(await(await t.send(e,{method:`GET`,path:`/wow/manifest`,numbers:{},options:n})).json())}var o=class{constructor(e,t){this.client=e,this.manifest=t===void 0?void 0:Promise.resolve(i(t))}read(e){if(e?.aborted)return Promise.reject(e.reason);let t=this.manifest??=a(this.client).catch(e=>{throw this.manifest=void 0,e});return new Promise((n,r)=>{let i=()=>r(e.reason);e?.addEventListener(`abort`,i,{once:!0}),t.then(n,e=>r(s(e))).finally(()=>e?.removeEventListener(`abort`,i))})}};function s(t){if(t instanceof e.WowProblemError)return new e.WowProblemError(t.problem,{cause:t,...t.retryAfterMs===void 0?{}:{retryAfterMs:t.retryAfterMs}});let n=t instanceof Error?t:void 0;return Object.assign(Error(`The service's Manifest (GET /wow/manifest) could not be read: ${n?.message??String(t)}`),{name:n?.name??`Error`,cause:n?.cause??t})}exports.MANIFEST_FEATURES=r,exports.MANIFEST_FORMAT=n,exports.ManifestSource=o,exports.checkManifest=i,exports.fetchManifest=a;
|
|
2
2
|
//# sourceMappingURL=manifest.cjs.map
|
package/dist/manifest.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.cjs","names":["
|
|
1
|
+
{"version":3,"file":"manifest.cjs","names":["send","WowProblemError","require_problem","require_http","MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","client","ManifestSource","signal","shared","error","abort","reject","resolve","ownFailure","failed"],"sources":["../src/manifest.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 RequestOptions, send, type WowClientOptions } from './http.js';\nimport { WowProblemError } from './problem.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n/**\n * A command as a {@link RoutingManifest} lists it: its name, former names and\n * routes, and the property of its body that names its aggregate, for a command\n * whose body does (`idProperty`).\n */\nexport type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> &\n Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;\n\n/** A service route as a {@link RoutingManifest} lists it: its name and its route. */\nexport type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;\n\n/**\n * What a `CommandClient` reads of a Manifest to send a command: each\n * context's aggregates and their commands with their routes, and the context's\n * own system commands; and what a `ServiceRoutes` reads to call a service\n * route: the context's routes. A whole {@link Manifest} is one; a generated\n * client carries its service's as data (`manifest.ts`), with no schema.\n */\nexport interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {\n readonly contexts: readonly (Pick<ContextManifest, 'name'> & {\n readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {\n readonly commands?: readonly RoutingCommand[];\n })[];\n readonly commands?: readonly RoutingCommand[];\n readonly routes?: readonly RoutingServiceRoute[];\n })[];\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The markers of a Manifest's `requires` this client understands, as the\n * Kotlin reader's `ManifestFeatures`: none yet.\n */\nexport const MANIFEST_FEATURES: ReadonlySet<string> = new Set<string>();\n\n/**\n * Checks that this client can read `manifest`: its format, and every marker it\n * requires.\n *\n * @param manifest - The Manifest\n * @throws TypeError naming what this client does not understand\n */\nexport function checkManifest<M extends RoutingManifest>(manifest: M): M {\n if (manifest.format !== MANIFEST_FORMAT) {\n throw new TypeError(\n `The Manifest is of format ${manifest.format}; this client reads format ${MANIFEST_FORMAT}.`,\n );\n }\n const unknown = (manifest.requires ?? []).filter(\n marker => !MANIFEST_FEATURES.has(marker),\n );\n if (unknown.length > 0) {\n throw new TypeError(\n `The Manifest requires ${unknown.join(', ')}, which this client does not understand: use a newer @ahoo-wang/wow-client.`,\n );\n }\n return manifest;\n}\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n const answer = await send(client, {\n method: 'GET',\n path: '/wow/manifest',\n numbers: {},\n options,\n });\n return checkManifest(await answer.json<Manifest>());\n}\n\n/**\n * The Manifest a client routes by (internal): the one it was given, or the\n * service's, read once for every caller and read again by the next caller\n * after a read that failed.\n */\nexport class ManifestSource {\n private manifest: Promise<RoutingManifest> | undefined;\n\n /**\n * @param client - How the service is reached\n * @param manifest - The Manifest given; without it the service's is read\n */\n constructor(\n private readonly client: WowClientOptions,\n manifest?: RoutingManifest,\n ) {\n this.manifest =\n manifest === undefined\n ? undefined\n : Promise.resolve(checkManifest(manifest));\n }\n\n /**\n * The Manifest, for one caller. The read is shared, but each caller's wait\n * is its own: it ends with the caller's `signal`, rejecting with its reason\n * while the read goes on for the others, and a read that fails rejects each\n * caller with an error of its own, so each carries the request id of its\n * own command.\n *\n * @param signal - Cancels this caller's wait\n */\n read(signal?: AbortSignal): Promise<RoutingManifest> {\n if (signal?.aborted) return Promise.reject(signal.reason);\n const shared = (this.manifest ??= fetchManifest(this.client).catch(\n (error: unknown) => {\n this.manifest = undefined;\n throw error;\n },\n ));\n return new Promise((resolve, reject) => {\n const abort = () => reject(signal!.reason);\n signal?.addEventListener('abort', abort, { once: true });\n shared\n .then(resolve, (error: unknown) => reject(ownFailure(error)))\n .finally(() => signal?.removeEventListener('abort', abort));\n });\n }\n}\n\n/**\n * A caller's own error for a shared Manifest read that failed with `error`:\n * the same problem when the service answered one, else an error that names\n * the read, under the name and with the cause of what it failed with.\n */\nfunction ownFailure(error: unknown): Error {\n if (error instanceof WowProblemError) {\n return new WowProblemError(error.problem, {\n cause: error,\n ...(error.retryAfterMs === undefined\n ? {}\n : { retryAfterMs: error.retryAfterMs }),\n });\n }\n // It reads as the read's own error: its name, and its cause where it has\n // one (a fetcher's timeout or abort), so a caller's check written for a\n // request that failed alike (`error.cause?.name === 'FetchTimeoutError'`)\n // holds. `{ cause }` of an `Error` is ES2022; this package targets ES2020.\n const failed = error instanceof Error ? error : undefined;\n return Object.assign(\n new Error(\n `The service's Manifest (GET /wow/manifest) could not be read: ${\n failed?.message ?? String(error)\n }`,\n ),\n {\n name: failed?.name ?? 'Error',\n cause: (failed as { cause?: unknown } | undefined)?.cause ?? error,\n },\n );\n}\n"],"mappings":"A,yDAyDA,IAAaI,EAAkB,EAMlBC,EAAyC,IAAI,IAS1D,SAAgBC,EAAyC,EAAgB,CACvE,GAAIC,EAAS,SAAA,EACX,MAAU,UACR,6BAA6BA,EAAS,OAAO,8BAC/C,EAEF,IAAMC,GAAWD,EAAS,UAAY,CAAC,EAAA,CAAG,OACxC,GAAU,CAACF,EAAkB,IAAII,CAAM,CACzC,EACA,GAAID,EAAQ,OAAS,EACnB,MAAU,UACR,yBAAyBA,EAAQ,KAAK,IAAI,EAAE,4EAC9C,EAEF,OAAOD,CACT,CAQA,eAAsBG,EACpB,EAA2B,CAAC,EAC5B,EACmB,CAOnB,OAAOJ,EAAc,MAAM,MANNN,EAAAA,KAAKW,EAAQ,CAChC,OAAQ,MACR,KAAM,gBACN,QAAS,CAAC,EACV,SACF,CAAC,EAAA,CACiC,KAAe,CAAC,CACpD,CAOA,IAAaC,EAAb,KAA4B,CAO1B,YACE,EACA,EACA,CAFiB,KAAA,OAAAD,EAGjB,KAAK,SACHJ,IAAa,IAAA,GACT,IAAA,GACA,QAAQ,QAAQD,EAAcC,CAAQ,CAAC,CAC/C,CAWA,KAAK,EAAgD,CACnD,GAAIM,GAAQ,QAAS,OAAO,QAAQ,OAAOA,EAAO,MAAM,EACxD,IAAMC,EAAU,KAAK,WAAaJ,EAAc,KAAK,MAAM,CAAC,CAAC,MAC1D,GAAmB,CAElB,KADA,MAAK,SAAW,IAAA,GACVK,CACR,CACF,EACA,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAMC,MAAcC,EAAOJ,EAAQ,MAAM,EACzCA,GAAQ,iBAAiB,QAASG,EAAO,CAAE,KAAM,EAAK,CAAC,EACvDF,EACG,KAAKI,EAAU,GAAmBD,EAAOE,EAAWJ,CAAK,CAAC,CAAC,CAAC,CAC5D,YAAcF,GAAQ,oBAAoB,QAASG,CAAK,CAAC,CAC9D,CAAC,CACH,CACF,EAOA,SAASG,EAAW,EAAuB,CACzC,GAAIJ,aAAiBd,EAAAA,gBACnB,OAAO,IAAIA,EAAAA,gBAAgBc,EAAM,QAAS,CACxC,MAAOA,EACP,GAAIA,EAAM,eAAiB,IAAA,GACvB,CAAC,EACD,CAAE,aAAcA,EAAM,YAAa,CACzC,CAAC,EAMH,IAAMK,EAASL,aAAiB,MAAQA,EAAQ,IAAA,GAChD,OAAO,OAAO,OACR,MACF,iEACEK,GAAQ,SAAW,OAAOL,CAAK,GAEnC,EACA,CACE,KAAMK,GAAQ,MAAQ,QACtB,MAAQA,GAA4C,OAASL,CAC/D,CACF,CACF,C"}
|
package/dist/manifest.d.cts
CHANGED
|
@@ -49,3 +49,27 @@ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M
|
|
|
49
49
|
* @param options - Headers and cancellation
|
|
50
50
|
*/
|
|
51
51
|
export declare function fetchManifest(client?: WowClientOptions, options?: RequestOptions): Promise<Manifest>;
|
|
52
|
+
/**
|
|
53
|
+
* The Manifest a client routes by (internal): the one it was given, or the
|
|
54
|
+
* service's, read once for every caller and read again by the next caller
|
|
55
|
+
* after a read that failed.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ManifestSource {
|
|
58
|
+
private readonly client;
|
|
59
|
+
private manifest;
|
|
60
|
+
/**
|
|
61
|
+
* @param client - How the service is reached
|
|
62
|
+
* @param manifest - The Manifest given; without it the service's is read
|
|
63
|
+
*/
|
|
64
|
+
constructor(client: WowClientOptions, manifest?: RoutingManifest);
|
|
65
|
+
/**
|
|
66
|
+
* The Manifest, for one caller. The read is shared, but each caller's wait
|
|
67
|
+
* is its own: it ends with the caller's `signal`, rejecting with its reason
|
|
68
|
+
* while the read goes on for the others, and a read that fails rejects each
|
|
69
|
+
* caller with an error of its own, so each carries the request id of its
|
|
70
|
+
* own command.
|
|
71
|
+
*
|
|
72
|
+
* @param signal - Cancels this caller's wait
|
|
73
|
+
*/
|
|
74
|
+
read(signal?: AbortSignal): Promise<RoutingManifest>;
|
|
75
|
+
}
|
package/dist/manifest.d.ts
CHANGED
|
@@ -49,3 +49,27 @@ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M
|
|
|
49
49
|
* @param options - Headers and cancellation
|
|
50
50
|
*/
|
|
51
51
|
export declare function fetchManifest(client?: WowClientOptions, options?: RequestOptions): Promise<Manifest>;
|
|
52
|
+
/**
|
|
53
|
+
* The Manifest a client routes by (internal): the one it was given, or the
|
|
54
|
+
* service's, read once for every caller and read again by the next caller
|
|
55
|
+
* after a read that failed.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ManifestSource {
|
|
58
|
+
private readonly client;
|
|
59
|
+
private manifest;
|
|
60
|
+
/**
|
|
61
|
+
* @param client - How the service is reached
|
|
62
|
+
* @param manifest - The Manifest given; without it the service's is read
|
|
63
|
+
*/
|
|
64
|
+
constructor(client: WowClientOptions, manifest?: RoutingManifest);
|
|
65
|
+
/**
|
|
66
|
+
* The Manifest, for one caller. The read is shared, but each caller's wait
|
|
67
|
+
* is its own: it ends with the caller's `signal`, rejecting with its reason
|
|
68
|
+
* while the read goes on for the others, and a read that fails rejects each
|
|
69
|
+
* caller with an error of its own, so each carries the request id of its
|
|
70
|
+
* own command.
|
|
71
|
+
*
|
|
72
|
+
* @param signal - Cancels this caller's wait
|
|
73
|
+
*/
|
|
74
|
+
read(signal?: AbortSignal): Promise<RoutingManifest>;
|
|
75
|
+
}
|
package/dist/manifest.es.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WowProblemError as e } from "./problem.es.js";
|
|
2
|
+
import { send as t } from "./http.es.js";
|
|
2
3
|
// src/manifest.ts
|
|
3
4
|
var n = 1, r = /* @__PURE__ */ new Set();
|
|
4
5
|
function i(e) {
|
|
@@ -7,13 +8,40 @@ function i(e) {
|
|
|
7
8
|
if (t.length > 0) throw TypeError(`The Manifest requires ${t.join(", ")}, which this client does not understand: use a newer @ahoo-wang/wow-client.`);
|
|
8
9
|
return e;
|
|
9
10
|
}
|
|
10
|
-
async function a(
|
|
11
|
-
return i(await
|
|
11
|
+
async function a(e = {}, n) {
|
|
12
|
+
return i(await (await t(e, {
|
|
12
13
|
method: "GET",
|
|
13
14
|
path: "/wow/manifest",
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
numbers: {},
|
|
16
|
+
options: n
|
|
17
|
+
})).json());
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
var o = class {
|
|
20
|
+
constructor(e, t) {
|
|
21
|
+
this.client = e, this.manifest = t === void 0 ? void 0 : Promise.resolve(i(t));
|
|
22
|
+
}
|
|
23
|
+
read(e) {
|
|
24
|
+
if (e?.aborted) return Promise.reject(e.reason);
|
|
25
|
+
let t = this.manifest ??= a(this.client).catch((e) => {
|
|
26
|
+
throw this.manifest = void 0, e;
|
|
27
|
+
});
|
|
28
|
+
return new Promise((n, r) => {
|
|
29
|
+
let i = () => r(e.reason);
|
|
30
|
+
e?.addEventListener("abort", i, { once: !0 }), t.then(n, (e) => r(s(e))).finally(() => e?.removeEventListener("abort", i));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function s(t) {
|
|
35
|
+
if (t instanceof e) return new e(t.problem, {
|
|
36
|
+
cause: t,
|
|
37
|
+
...t.retryAfterMs === void 0 ? {} : { retryAfterMs: t.retryAfterMs }
|
|
38
|
+
});
|
|
39
|
+
let n = t instanceof Error ? t : void 0;
|
|
40
|
+
return Object.assign(/* @__PURE__ */ Error(`The service's Manifest (GET /wow/manifest) could not be read: ${n?.message ?? String(t)}`), {
|
|
41
|
+
name: n?.name ?? "Error",
|
|
42
|
+
cause: n?.cause ?? t
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export { r as MANIFEST_FEATURES, n as MANIFEST_FORMAT, o as ManifestSource, i as checkManifest, a as fetchManifest };
|
|
18
46
|
|
|
19
47
|
//# sourceMappingURL=manifest.es.js.map
|
package/dist/manifest.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.es.js","names":["MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","
|
|
1
|
+
{"version":3,"file":"manifest.es.js","names":["MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","send","client","ManifestSource","signal","shared","error","abort","reject","resolve","ownFailure","WowProblemError","failed"],"sources":["../src/manifest.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 RequestOptions, send, type WowClientOptions } from './http.js';\nimport { WowProblemError } from './problem.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n/**\n * A command as a {@link RoutingManifest} lists it: its name, former names and\n * routes, and the property of its body that names its aggregate, for a command\n * whose body does (`idProperty`).\n */\nexport type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> &\n Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;\n\n/** A service route as a {@link RoutingManifest} lists it: its name and its route. */\nexport type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;\n\n/**\n * What a `CommandClient` reads of a Manifest to send a command: each\n * context's aggregates and their commands with their routes, and the context's\n * own system commands; and what a `ServiceRoutes` reads to call a service\n * route: the context's routes. A whole {@link Manifest} is one; a generated\n * client carries its service's as data (`manifest.ts`), with no schema.\n */\nexport interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {\n readonly contexts: readonly (Pick<ContextManifest, 'name'> & {\n readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {\n readonly commands?: readonly RoutingCommand[];\n })[];\n readonly commands?: readonly RoutingCommand[];\n readonly routes?: readonly RoutingServiceRoute[];\n })[];\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The markers of a Manifest's `requires` this client understands, as the\n * Kotlin reader's `ManifestFeatures`: none yet.\n */\nexport const MANIFEST_FEATURES: ReadonlySet<string> = new Set<string>();\n\n/**\n * Checks that this client can read `manifest`: its format, and every marker it\n * requires.\n *\n * @param manifest - The Manifest\n * @throws TypeError naming what this client does not understand\n */\nexport function checkManifest<M extends RoutingManifest>(manifest: M): M {\n if (manifest.format !== MANIFEST_FORMAT) {\n throw new TypeError(\n `The Manifest is of format ${manifest.format}; this client reads format ${MANIFEST_FORMAT}.`,\n );\n }\n const unknown = (manifest.requires ?? []).filter(\n marker => !MANIFEST_FEATURES.has(marker),\n );\n if (unknown.length > 0) {\n throw new TypeError(\n `The Manifest requires ${unknown.join(', ')}, which this client does not understand: use a newer @ahoo-wang/wow-client.`,\n );\n }\n return manifest;\n}\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n const answer = await send(client, {\n method: 'GET',\n path: '/wow/manifest',\n numbers: {},\n options,\n });\n return checkManifest(await answer.json<Manifest>());\n}\n\n/**\n * The Manifest a client routes by (internal): the one it was given, or the\n * service's, read once for every caller and read again by the next caller\n * after a read that failed.\n */\nexport class ManifestSource {\n private manifest: Promise<RoutingManifest> | undefined;\n\n /**\n * @param client - How the service is reached\n * @param manifest - The Manifest given; without it the service's is read\n */\n constructor(\n private readonly client: WowClientOptions,\n manifest?: RoutingManifest,\n ) {\n this.manifest =\n manifest === undefined\n ? undefined\n : Promise.resolve(checkManifest(manifest));\n }\n\n /**\n * The Manifest, for one caller. The read is shared, but each caller's wait\n * is its own: it ends with the caller's `signal`, rejecting with its reason\n * while the read goes on for the others, and a read that fails rejects each\n * caller with an error of its own, so each carries the request id of its\n * own command.\n *\n * @param signal - Cancels this caller's wait\n */\n read(signal?: AbortSignal): Promise<RoutingManifest> {\n if (signal?.aborted) return Promise.reject(signal.reason);\n const shared = (this.manifest ??= fetchManifest(this.client).catch(\n (error: unknown) => {\n this.manifest = undefined;\n throw error;\n },\n ));\n return new Promise((resolve, reject) => {\n const abort = () => reject(signal!.reason);\n signal?.addEventListener('abort', abort, { once: true });\n shared\n .then(resolve, (error: unknown) => reject(ownFailure(error)))\n .finally(() => signal?.removeEventListener('abort', abort));\n });\n }\n}\n\n/**\n * A caller's own error for a shared Manifest read that failed with `error`:\n * the same problem when the service answered one, else an error that names\n * the read, under the name and with the cause of what it failed with.\n */\nfunction ownFailure(error: unknown): Error {\n if (error instanceof WowProblemError) {\n return new WowProblemError(error.problem, {\n cause: error,\n ...(error.retryAfterMs === undefined\n ? {}\n : { retryAfterMs: error.retryAfterMs }),\n });\n }\n // It reads as the read's own error: its name, and its cause where it has\n // one (a fetcher's timeout or abort), so a caller's check written for a\n // request that failed alike (`error.cause?.name === 'FetchTimeoutError'`)\n // holds. `{ cause }` of an `Error` is ES2022; this package targets ES2020.\n const failed = error instanceof Error ? error : undefined;\n return Object.assign(\n new Error(\n `The service's Manifest (GET /wow/manifest) could not be read: ${\n failed?.message ?? String(error)\n }`,\n ),\n {\n name: failed?.name ?? 'Error',\n cause: (failed as { cause?: unknown } | undefined)?.cause ?? error,\n },\n );\n}\n"],"mappings":";;;AAyDA,IAAaA,IAAkB,GAMlBC,oBAAyC,IAAI,IAAY;AAStE,SAAgBC,EAAyC,GAAgB;CACvE,IAAIC,EAAS,WAAA,GACX,MAAU,UACR,6BAA6BA,EAAS,OAAO,8BAC/C;CAEF,IAAMC,KAAWD,EAAS,YAAY,CAAC,EAAA,CAAG,QACxC,MAAU,CAACF,EAAkB,IAAII,CAAM,CACzC;CACA,IAAID,EAAQ,SAAS,GACnB,MAAU,UACR,yBAAyBA,EAAQ,KAAK,IAAI,EAAE,4EAC9C;CAEF,OAAOD;AACT;AAQA,eAAsBG,EACpB,IAA2B,CAAC,GAC5B,GACmB;CAOnB,OAAOJ,EAAc,OAAM,MANNK,EAAKC,GAAQ;EAChC,QAAQ;EACR,MAAM;EACN,SAAS,CAAC;EACV;CACF,CAAC,EAAA,CACiC,KAAe,CAAC;AACpD;AAOA,IAAaC,IAAb,MAA4B;CAO1B,YACE,GACA,GACA;EACA,AAHiB,KAAA,SAAAD,GAGjB,KAAK,WACHL,MAAa,KAAA,IACT,KAAA,IACA,QAAQ,QAAQD,EAAcC,CAAQ,CAAC;CAC/C;CAWA,KAAK,GAAgD;EACnD,IAAIO,GAAQ,SAAS,OAAO,QAAQ,OAAOA,EAAO,MAAM;EACxD,IAAMC,IAAU,KAAK,aAAaL,EAAc,KAAK,MAAM,CAAC,CAAC,OAC1D,MAAmB;GAElB,MADA,KAAK,WAAW,KAAA,GACVM;EACR,CACF;EACA,OAAO,IAAI,SAAS,GAAS,MAAW;GACtC,IAAMC,UAAcC,EAAOJ,EAAQ,MAAM;GAEzC,AADAA,GAAQ,iBAAiB,SAASG,GAAO,EAAE,MAAM,GAAK,CAAC,GACvDF,EACG,KAAKI,IAAU,MAAmBD,EAAOE,EAAWJ,CAAK,CAAC,CAAC,CAAC,CAC5D,cAAcF,GAAQ,oBAAoB,SAASG,CAAK,CAAC;EAC9D,CAAC;CACH;AACF;AAOA,SAASG,EAAW,GAAuB;CACzC,IAAIJ,aAAiBK,GACnB,OAAO,IAAIA,EAAgBL,EAAM,SAAS;EACxC,OAAOA;EACP,GAAIA,EAAM,iBAAiB,KAAA,IACvB,CAAC,IACD,EAAE,cAAcA,EAAM,aAAa;CACzC,CAAC;CAMH,IAAMM,IAASN,aAAiB,QAAQA,IAAQ,KAAA;CAChD,OAAO,OAAO,OACZ,gBAAI,MACF,iEACEM,GAAQ,WAAW,OAAON,CAAK,GAEnC,GACA;EACE,MAAMM,GAAQ,QAAQ;EACtB,OAAQA,GAA4C,SAASN;CAC/D,CACF;AACF"}
|
package/dist/manifestTypes.d.cts
CHANGED
|
@@ -41,6 +41,8 @@ export interface ServiceRouteManifest {
|
|
|
41
41
|
readonly request?: unknown;
|
|
42
42
|
/** An inline JSON Schema: a $ref into $defs, or an array of one. */
|
|
43
43
|
readonly response?: unknown;
|
|
44
|
+
/** Whether the route may answer 204 No Content instead of its response. */
|
|
45
|
+
readonly responseOptional?: boolean;
|
|
44
46
|
/** The codes the route refuses with, entries of the context's errors. */
|
|
45
47
|
readonly errors?: readonly string[];
|
|
46
48
|
readonly description?: string;
|
|
@@ -72,6 +74,15 @@ export interface AggregateManifest {
|
|
|
72
74
|
readonly retired?: readonly string[];
|
|
73
75
|
/** Where an aggregate's id comes from; assigned when absent. */
|
|
74
76
|
readonly idSource?: 'assigned' | 'owner' | (string & {});
|
|
77
|
+
/** The aggregate's access attributes; none when absent. */
|
|
78
|
+
readonly access?: readonly AccessAttributeManifest[];
|
|
79
|
+
}
|
|
80
|
+
/** An access attribute of an aggregate: its name, the type of its values, and whether it holds several. */
|
|
81
|
+
export interface AccessAttributeManifest {
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly type: 'string' | 'integer' | 'boolean' | (string & {});
|
|
84
|
+
/** Whether it holds several values; one when absent. */
|
|
85
|
+
readonly multiple?: boolean;
|
|
75
86
|
}
|
|
76
87
|
/** An aggregate's state: its schema, the fingerprint of its shape and, in a contract, its view. */
|
|
77
88
|
export interface StateManifest {
|
|
@@ -105,9 +116,13 @@ export interface CommandManifest {
|
|
|
105
116
|
readonly mounted?: boolean;
|
|
106
117
|
/** A system command (wow.*): a lifecycle command, a rebuild or a job command. */
|
|
107
118
|
readonly system?: boolean;
|
|
119
|
+
/** An internal command: only the platform sends it, on the internal port; the public port does not serve its routes. */
|
|
120
|
+
readonly internal?: boolean;
|
|
108
121
|
readonly transformsTo?: readonly string[];
|
|
109
122
|
/** The property of the command's body that holds its aggregate's id. */
|
|
110
123
|
readonly idProperty?: string;
|
|
124
|
+
/** The property of the creation command's body that declares when what it records happened, epoch milliseconds: the creating commit's time (@OccurredAt). */
|
|
125
|
+
readonly occurredAtProperty?: string;
|
|
111
126
|
readonly description?: string;
|
|
112
127
|
}
|
|
113
128
|
/** An event of an aggregate and its revision. */
|
|
@@ -187,7 +202,7 @@ export interface RetryManifest {
|
|
|
187
202
|
export interface JobManifest {
|
|
188
203
|
readonly name: string;
|
|
189
204
|
readonly cron: string;
|
|
190
|
-
readonly
|
|
205
|
+
readonly timeZone: string;
|
|
191
206
|
/** Who the job runs for. */
|
|
192
207
|
readonly scope: 'system' | 'tenant' | 'sharded' | (string & {});
|
|
193
208
|
/** What the job does with the slots it missed. */
|
package/dist/manifestTypes.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface ServiceRouteManifest {
|
|
|
41
41
|
readonly request?: unknown;
|
|
42
42
|
/** An inline JSON Schema: a $ref into $defs, or an array of one. */
|
|
43
43
|
readonly response?: unknown;
|
|
44
|
+
/** Whether the route may answer 204 No Content instead of its response. */
|
|
45
|
+
readonly responseOptional?: boolean;
|
|
44
46
|
/** The codes the route refuses with, entries of the context's errors. */
|
|
45
47
|
readonly errors?: readonly string[];
|
|
46
48
|
readonly description?: string;
|
|
@@ -72,6 +74,15 @@ export interface AggregateManifest {
|
|
|
72
74
|
readonly retired?: readonly string[];
|
|
73
75
|
/** Where an aggregate's id comes from; assigned when absent. */
|
|
74
76
|
readonly idSource?: 'assigned' | 'owner' | (string & {});
|
|
77
|
+
/** The aggregate's access attributes; none when absent. */
|
|
78
|
+
readonly access?: readonly AccessAttributeManifest[];
|
|
79
|
+
}
|
|
80
|
+
/** An access attribute of an aggregate: its name, the type of its values, and whether it holds several. */
|
|
81
|
+
export interface AccessAttributeManifest {
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly type: 'string' | 'integer' | 'boolean' | (string & {});
|
|
84
|
+
/** Whether it holds several values; one when absent. */
|
|
85
|
+
readonly multiple?: boolean;
|
|
75
86
|
}
|
|
76
87
|
/** An aggregate's state: its schema, the fingerprint of its shape and, in a contract, its view. */
|
|
77
88
|
export interface StateManifest {
|
|
@@ -105,9 +116,13 @@ export interface CommandManifest {
|
|
|
105
116
|
readonly mounted?: boolean;
|
|
106
117
|
/** A system command (wow.*): a lifecycle command, a rebuild or a job command. */
|
|
107
118
|
readonly system?: boolean;
|
|
119
|
+
/** An internal command: only the platform sends it, on the internal port; the public port does not serve its routes. */
|
|
120
|
+
readonly internal?: boolean;
|
|
108
121
|
readonly transformsTo?: readonly string[];
|
|
109
122
|
/** The property of the command's body that holds its aggregate's id. */
|
|
110
123
|
readonly idProperty?: string;
|
|
124
|
+
/** The property of the creation command's body that declares when what it records happened, epoch milliseconds: the creating commit's time (@OccurredAt). */
|
|
125
|
+
readonly occurredAtProperty?: string;
|
|
111
126
|
readonly description?: string;
|
|
112
127
|
}
|
|
113
128
|
/** An event of an aggregate and its revision. */
|
|
@@ -187,7 +202,7 @@ export interface RetryManifest {
|
|
|
187
202
|
export interface JobManifest {
|
|
188
203
|
readonly name: string;
|
|
189
204
|
readonly cron: string;
|
|
190
|
-
readonly
|
|
205
|
+
readonly timeZone: string;
|
|
191
206
|
/** Who the job runs for. */
|
|
192
207
|
readonly scope: 'system' | 'tenant' | 'sharded' | (string & {});
|
|
193
208
|
/** What the job does with the slots it missed. */
|
package/dist/queries.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./exactJson.cjs"),t=require("./frameworkErrors.cjs"),n=require("./problem.cjs"),r=require("./http.cjs"),i=require("./streams.cjs");var a=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,t){return
|
|
1
|
+
const e=require("./exactJson.cjs"),t=require("./frameworkErrors.cjs"),n=require("./problem.cjs"),r=require("./http.cjs"),i=require("./streams.cjs");var a=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,t){return(await this.post(`list`,e,this.listNumbers,t)).json()}async stream(e,t){return(await this.streamRows(e,t)).pipeThrough(new TransformStream({transform(e,t){t.enqueue(e.row)}}))}async streamRows(e,t={}){let n=t.resume===!1?{maxRetries:0}:t.resume,r=e.limit,a=(n,i,a)=>this.post(`list`,r===void 0?e:{...e,limit:r-i},this.numbers,a===void 0?t:{...t,signal:a},`text/event-stream`,n),o=await a(n?.lastEventId,0,t.signal);return i.resumableQueryRows(o,(e,t,n)=>r!==void 0&&t>=r?Promise.resolve(void 0):a(e,t,n),{...n,...t.signal===void 0?{}:{signal:t.signal}})}async paged(e,t){return(await this.post(`paged`,e,this.pageNumbers,t)).json()}async cursor(e,t){return(await this.post(`cursor`,e,this.pageNumbers,t)).json()}async single(e,t){try{return(await this.post(`single`,e,this.numbers,t)).json()}catch(e){if(o(e))return;throw e}}async count(e,t){return(await this.post(`count`,e,void 0,t)).json()}async aggregate(e,t){return(await this.post(`aggregate`,e,void 0,t)).json()}async describe(e,t){let n=await r.send(this.client,{method:`GET`,path:this.path,headers:{[r.WowHeaders.IF_NONE_MATCH]:e===void 0?void 0:`"${e}"`},numbers:{},options:t,notModified:!0}),i=r.entityTag(n.response);return n.response.status===304?{notModified:!0,version:i??e??``}:{notModified:!1,...i===void 0?{}:{version:i},descriptor:await n.json()}}post(e,t,n,i,a,o){return r.send(this.client,{method:`POST`,path:this.path,headers:{Accept:a,[r.WowHeaders.LAST_EVENT_ID]:o},body:{...t,kind:e},numbers:{answer:n},options:i})}};function o(e){return e instanceof n.WowProblemError&&e.status===404&&(e.code===t.FrameworkErrorCodes.QUERY_NOT_FOUND||e.code===t.FrameworkErrorCodes.AGGREGATE_NOT_FOUND)}function s(e,t){return`/${e.context}/${e.name}/${t}/query`}var c=class extends a{constructor(t,n){super(s(t,`snapshot`),n,e.recordNumbers({state:t.textNumbers?.state,access:t.textNumbers?.access})),this.type=t}},l=class extends a{constructor(t,n){let r=e.eventNumbers(t);super(s(t,`events`),n,e.recordNumbers({events:r===void 0?void 0:{"*":r},access:t.textNumbers?.access})),this.type=t}},u=class{constructor(e={}){this.client=e}async list(e){return(await r.send(this.client,{method:`GET`,path:`/wow/dataset`,numbers:{},options:e})).json()}dataset(e,t,n){return new a(`/wow/dataset/${encodeURIComponent(e)}/${encodeURIComponent(t)}/query`,this.client,n)}};exports.DatasetClient=u,exports.EventQueryClient=l,exports.QueryModelClient=a,exports.SnapshotQueryClient=c,exports.queryPath=s;
|
|
2
2
|
//# sourceMappingURL=queries.cjs.map
|
package/dist/queries.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.cjs","names":["json","resumableQueryRows","send","WowHeaders","entityTag","WowProblemError","FrameworkErrorCodes","eventNumbers","require_exactJson","require_frameworkErrors","require_problem","require_http","require_streams","QueryModelClient","path","client","numbers","query","options","controller","positioned","resume","limit","open","received","lastEventId","first","error","isNoMatch","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 {\n DescriptorResult,\n QueryModelDescriptor,\n} from './dsl/descriptor.js';\nimport type { FilterCapable } from './dsl/filter/index.js';\nimport { FrameworkErrorCodes, WowProblemError } from './problem.js';\nimport type {\n FilterListQuery,\n FilterSingleQuery,\n PagedQuery,\n PagedList,\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 EventStream,\n CommittedEvent,\n Snapshot,\n SnapshotSystemField,\n} from './wire.js';\nimport {\n resumableQueryRows,\n type Positioned,\n type StreamResumeOptions,\n} from './streams.js';\n\n/** How a list is streamed: the request's options, and how it resumes. */\nexport interface StreamOptions extends RequestOptions {\n /** How the stream resumes (decision D253); `false` never resumes it. */\n readonly resume?: StreamResumeOptions | false;\n}\n\n/** A count of a query route. */\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 * 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. 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 stream<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Projected<R, INCLUDE>>>;\n stream(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<ReadableStream<R>>;\n async stream(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<unknown> {\n return (await this.streamRows(query, options)).pipeThrough(\n new TransformStream<Positioned<R>, R>({\n transform(positioned, controller) {\n controller.enqueue(positioned.row);\n },\n }),\n );\n }\n\n /**\n * The records that match as {@link stream} 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. Kotlin's `RowQueries.stream` answers these rows (`Positioned`).\n */\n streamRows<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Positioned<Projected<R, INCLUDE>>>>;\n streamRows(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Positioned<R>>>;\n async streamRows(\n query: FilterListQuery<FIELDS>,\n options: StreamOptions = {},\n ): Promise<ReadableStream<Positioned<R>>> {\n const resume =\n options.resume === false ? { maxRetries: 0 } : options.resume;\n const limit = query.limit;\n const open = (lastEventId: string | undefined, received: number) => {\n return this.post(\n 'list',\n limit === undefined ? query : { ...query, limit: limit - received },\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 !== undefined && 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<PagedList<Projected<R, INCLUDE>>>;\n paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<PagedList<R>>;\n async paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return json<PagedList<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 /**\n * The first record that matches, or `undefined` when none does: the\n * service's 404 `wow.query.not-found`, as Kotlin's `QueryApi.single`\n * answers `null`. Any other 404, of a dataset or a route that does not\n * exist, still rejects.\n */\n single<const INCLUDE extends FIELDS>(\n query: Including<FilterSingleQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<Projected<R, INCLUDE> | undefined>;\n single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<R | undefined>;\n async single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n try {\n return json<R>(await this.post('single', query, options), this.numbers);\n } catch (error) {\n if (isNoMatch(error)) return undefined;\n throw error;\n }\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 * Whether `error` is a 404 that answers \"no match\": a query that found no\n * record, or an aggregate that does not exist. A 404 of another code, or of\n * none (a route that does not exist), is a mistake the caller must hear of.\n */\nfunction isNoMatch(error: unknown): boolean {\n return (\n error instanceof WowProblemError &&\n error.status === 404 &&\n (error.code === FrameworkErrorCodes.QUERY_NOT_FOUND ||\n error.code === FrameworkErrorCodes.AGGREGATE_NOT_FOUND)\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, 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<Snapshot<S>, SnapshotSystemField | STATE_FIELDS> {\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 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 CommittedEvent = CommittedEvent,\n> extends QueryModelClient<EventStream<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: 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":"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BC,CAAO,EAAE,QAC3E,KAAK,MACP,CACF,CACF,E"}
|
|
1
|
+
{"version":3,"file":"queries.cjs","names":["resumableQueryRows","send","WowHeaders","entityTag","WowProblemError","FrameworkErrorCodes","recordNumbers","eventNumbers","require_exactJson","require_frameworkErrors","require_problem","require_http","require_streams","QueryModelClient","path","client","numbers","query","options","controller","positioned","resume","limit","open","received","signal","lastEventId","first","error","isNoMatch","answer","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, recordNumbers, type TextNumbers } from './exactJson.js';\nimport type {\n DescriptorResult,\n QueryModelDescriptor,\n} from './dsl/descriptor.js';\nimport type { FilterCapable } from './dsl/filter/index.js';\nimport { FrameworkErrorCodes, WowProblemError } from './problem.js';\nimport type {\n FilterListQuery,\n FilterSingleQuery,\n PagedQuery,\n PagedList,\n} from './dsl/queryable.js';\nimport {\n type Answer,\n entityTag,\n type RequestOptions,\n send,\n type WowClientOptions,\n WowHeaders,\n} from './http.js';\nimport type {\n AccessField,\n AccessValues,\n AggregateType,\n DatasetEntry,\n EventStreamField,\n EventStream,\n CommittedEvent,\n Snapshot,\n SnapshotSystemField,\n} from './wire.js';\nimport {\n resumableQueryRows,\n type Positioned,\n type StreamResumeOptions,\n} from './streams.js';\n\n/** How a list is streamed: the request's options, and how it resumes. */\nexport interface StreamOptions extends RequestOptions {\n /** How the stream resumes (decision D253); `false` never resumes it. */\n readonly resume?: StreamResumeOptions | false;\n}\n\n/** A count of a query route. */\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 * 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. 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 (await this.post('list', query, this.listNumbers, options)).json();\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 stream<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Projected<R, INCLUDE>>>;\n stream(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<ReadableStream<R>>;\n async stream(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<unknown> {\n return (await this.streamRows(query, options)).pipeThrough(\n new TransformStream<Positioned<R>, R>({\n transform(positioned, controller) {\n controller.enqueue(positioned.row);\n },\n }),\n );\n }\n\n /**\n * The records that match as {@link stream} 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. Kotlin's `RowQueries.stream` answers these rows (`Positioned`).\n */\n streamRows<const INCLUDE extends FIELDS>(\n query: Including<FilterListQuery<FIELDS>, INCLUDE>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Positioned<Projected<R, INCLUDE>>>>;\n streamRows(\n query: FilterListQuery<FIELDS>,\n options?: StreamOptions,\n ): Promise<ReadableStream<Positioned<R>>>;\n async streamRows(\n query: FilterListQuery<FIELDS>,\n options: StreamOptions = {},\n ): Promise<ReadableStream<Positioned<R>>> {\n const resume =\n options.resume === false ? { maxRetries: 0 } : options.resume;\n const limit = query.limit;\n const open = (\n lastEventId: string | undefined,\n received: number,\n signal: AbortSignal | undefined,\n ) => {\n return this.post(\n 'list',\n limit === undefined ? query : { ...query, limit: limit - received },\n this.numbers,\n signal === undefined ? options : { ...options, signal },\n 'text/event-stream',\n lastEventId,\n );\n };\n const first = await open(resume?.lastEventId, 0, options.signal);\n return resumableQueryRows<R>(\n first,\n (lastEventId, received, signal) =>\n limit !== undefined && received >= limit\n ? Promise.resolve(undefined)\n : open(lastEventId, received, signal),\n {\n ...resume,\n ...(options.signal === undefined ? {} : { signal: options.signal }),\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<PagedList<Projected<R, INCLUDE>>>;\n paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<PagedList<R>>;\n async paged(\n query: PagedQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n return (await this.post('paged', query, this.pageNumbers, options)).json();\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 (await this.post('cursor', query, this.pageNumbers, options)).json();\n }\n\n /**\n * The first record that matches, or `undefined` when none does: the\n * service's 404 `wow.query.not-found` or `wow.aggregate.not-found`, as\n * Kotlin's `QueryApi.single` answers `null`. Any other 404, of a dataset\n * or a route that does not exist, still rejects.\n */\n single<const INCLUDE extends FIELDS>(\n query: Including<FilterSingleQuery<FIELDS>, INCLUDE>,\n options?: RequestOptions,\n ): Promise<Projected<R, INCLUDE> | undefined>;\n single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<R | undefined>;\n async single(\n query: FilterSingleQuery<FIELDS>,\n options?: RequestOptions,\n ): Promise<unknown> {\n try {\n return (await this.post('single', query, this.numbers, options)).json();\n } catch (error) {\n if (isNoMatch(error)) return undefined;\n throw error;\n }\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 // A count is an integer far below 2^53: no exact numbers.\n return (await this.post('count', query, undefined, options)).json();\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 // Its rows are the query's own shape, which no schema declares.\n return (await this.post('aggregate', query, undefined, options)).json();\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 answer = 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 numbers: {},\n options,\n notModified: true,\n });\n const tag = entityTag(answer.response);\n if (answer.response.status === 304) {\n return { notModified: true, version: tag ?? version ?? '' };\n }\n return {\n notModified: false,\n ...(tag === undefined ? {} : { version: tag }),\n descriptor: await answer.json<QueryModelDescriptor>(),\n };\n }\n\n /** Posts a query of `kind`, its answer's exact numbers `numbers`. */\n private post(\n kind: string,\n query: object,\n numbers: TextNumbers | undefined,\n options?: RequestOptions,\n accept?: string,\n lastEventId?: string,\n ): Promise<Answer> {\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 numbers: { answer: numbers },\n options,\n });\n }\n}\n\n/**\n * Whether `error` is a 404 that answers \"no match\": a query that found no\n * record, or an aggregate that does not exist. A 404 of another code, or of\n * none (a route that does not exist), is a mistake the caller must hear of.\n */\nfunction isNoMatch(error: unknown): boolean {\n return (\n error instanceof WowProblemError &&\n error.status === 404 &&\n (error.code === FrameworkErrorCodes.QUERY_NOT_FOUND ||\n error.code === FrameworkErrorCodes.AGGREGATE_NOT_FOUND)\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, 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 * @typeParam A - Its access attributes, whose `access.<name>` paths a query\n * names ({@link AccessField}); {@link NoAccess} for an aggregate that\n * declares none.\n */\nexport class SnapshotQueryClient<\n S = unknown,\n STATE_FIELDS extends string = `state.${string}`,\n A = AccessValues,\n> extends QueryModelClient<\n Snapshot<S, A>,\n SnapshotSystemField | STATE_FIELDS | AccessField<A>\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 recordNumbers({\n state: type.textNumbers?.state,\n access: type.textNumbers?.access,\n }),\n );\n }\n}\n\n/**\n * Queries an aggregate type's event streams 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 * @typeParam A - The aggregate's declared access attributes, whose\n * `access.<name>` paths a query names beside the built-in `access.owner`\n * and `access.space`.\n */\nexport class EventQueryClient<\n E extends CommittedEvent = CommittedEvent,\n A = AccessValues,\n> extends QueryModelClient<\n EventStream<E, A>,\n EventStreamField | AccessField<A>\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 const events = eventNumbers(type);\n super(\n queryPath(type, 'events'),\n client,\n recordNumbers({\n events: events === undefined ? undefined : { '*': events },\n access: type.textNumbers?.access,\n }),\n );\n }\n}\n\n/**\n * The datasets of a Wow service: 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 const answer = await send(this.client, {\n method: 'GET',\n path: '/wow/dataset',\n numbers: {},\n options,\n });\n return answer.json();\n }\n\n /**\n * The query client of the dataset `context.dataset`. A dataset is\n * registered at run time, so no Manifest declares its rows' exact numbers:\n * a caller that knows them passes them.\n *\n * @typeParam R - The row's type.\n * @typeParam FIELDS - The dataset's field paths.\n * @param numbers - The exact numbers of each row ({@link TextNumbers})\n */\n dataset<R = Record<string, unknown>, FIELDS extends string = string>(\n context: string,\n dataset: string,\n numbers?: TextNumbers,\n ): QueryModelClient<R, FIELDS> {\n return new QueryModelClient<R, FIELDS>(\n `/wow/dataset/${encodeURIComponent(context)}/${encodeURIComponent(dataset)}/query`,\n this.client,\n numbers,\n );\n }\n}\n"],"mappings":"A,oJAoFA,IAAaa,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,OAAQ,MAAM,KAAK,KAAK,OAAQC,EAAO,KAAK,YAAaC,CAAO,EAAA,CAAG,KAAK,CAC1E,CAkBA,MAAM,OACJ,EACA,EACkB,CAClB,OAAQ,MAAM,KAAK,WAAWD,EAAOC,CAAO,EAAA,CAAG,YAC7C,IAAI,gBAAkC,CACpC,UAAU,EAAY,EAAY,CAChCC,EAAW,QAAQC,EAAW,GAAG,CACnC,C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pB,EACAT,EAAAA,cAAc,CACZ,MAAO6B,EAAK,aAAa,MACzB,OAAQA,EAAK,aAAa,MAC5B,CAAC,CACH,EAVS,KAAA,KAAAA,CAWX,CACF,EAeaG,EAAb,cAGUzB,CAGR,CAKA,YACE,EACA,EACA,CACA,IAAM0B,EAAShC,EAAAA,aAAa4B,CAAI,EAChC,MACED,EAAUC,EAAM,QAAQ,EACxBpB,EACAT,EAAAA,cAAc,CACZ,OAAQiC,IAAW,IAAA,GAAY,IAAA,GAAY,CAAE,IAAKA,CAAO,EACzD,OAAQJ,EAAK,aAAa,MAC5B,CAAC,CACH,EAXS,KAAA,KAAAA,CAYX,CACF,EAOaK,EAAb,KAA2B,CAEzB,YAAY,EAAoC,CAAC,EAAG,CAA/B,KAAA,OAAAzB,CAAgC,CAGrD,MAAM,KAAK,EAAmD,CAO5D,OAAO,MANcd,EAAAA,KAAK,KAAK,OAAQ,CACrC,OAAQ,MACR,KAAM,eACN,QAAS,CAAC,EACV,SACF,CAAC,EAAA,CACa,KAAK,CACrB,CAWA,QACE,EACA,EACA,EAC6B,CAC7B,OAAO,IAAIY,EACT,gBAAgB,mBAAmB4B,CAAO,EAAE,GAAG,mBAAmBC,CAAO,EAAE,QAC3E,KAAK,OACL1B,CACF,CACF,CACF,E"}
|
package/dist/queries.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { DescriptorResult } from './dsl/descriptor.cjs';
|
|
|
6
6
|
import { FilterCapable } from './dsl/filter/index.cjs';
|
|
7
7
|
import { FilterListQuery, FilterSingleQuery, PagedQuery, PagedList } from './dsl/queryable.cjs';
|
|
8
8
|
import { RequestOptions, WowClientOptions } from './http.cjs';
|
|
9
|
-
import { AggregateType, DatasetEntry, EventStreamField, EventStream, CommittedEvent, Snapshot, SnapshotSystemField } from './wire.cjs';
|
|
9
|
+
import { AccessField, AccessValues, AggregateType, DatasetEntry, EventStreamField, EventStream, CommittedEvent, Snapshot, SnapshotSystemField } from './wire.cjs';
|
|
10
10
|
import { Positioned, StreamResumeOptions } from './streams.cjs';
|
|
11
11
|
/** How a list is streamed: the request's options, and how it resumes. */
|
|
12
12
|
export interface StreamOptions extends RequestOptions {
|
|
@@ -77,9 +77,9 @@ export declare class QueryModelClient<R, FIELDS extends string = string> {
|
|
|
77
77
|
cursor(query: CursorQuery<FIELDS>, options?: RequestOptions): Promise<CursorPage<R>>;
|
|
78
78
|
/**
|
|
79
79
|
* The first record that matches, or `undefined` when none does: the
|
|
80
|
-
* service's 404 `wow.query.not-found
|
|
81
|
-
* answers `null`. Any other 404, of a dataset
|
|
82
|
-
* exist, still rejects.
|
|
80
|
+
* service's 404 `wow.query.not-found` or `wow.aggregate.not-found`, as
|
|
81
|
+
* Kotlin's `QueryApi.single` answers `null`. Any other 404, of a dataset
|
|
82
|
+
* or a route that does not exist, still rejects.
|
|
83
83
|
*/
|
|
84
84
|
single<const INCLUDE extends FIELDS>(query: Including<FilterSingleQuery<FIELDS>, INCLUDE>, options?: RequestOptions): Promise<Projected<R, INCLUDE> | undefined>;
|
|
85
85
|
single(query: FilterSingleQuery<FIELDS>, options?: RequestOptions): Promise<R | undefined>;
|
|
@@ -92,6 +92,7 @@ export declare class QueryModelClient<R, FIELDS extends string = string> {
|
|
|
92
92
|
* 304 answers `notModified`.
|
|
93
93
|
*/
|
|
94
94
|
describe(version?: string, options?: RequestOptions): Promise<DescriptorResult>;
|
|
95
|
+
/** Posts a query of `kind`, its answer's exact numbers `numbers`. */
|
|
95
96
|
private post;
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
@@ -111,8 +112,11 @@ export declare function queryPath(type: AggregateType, model: string): string;
|
|
|
111
112
|
*
|
|
112
113
|
* @typeParam S - The state's type.
|
|
113
114
|
* @typeParam STATE_FIELDS - The `state.*` paths of the state.
|
|
115
|
+
* @typeParam A - Its access attributes, whose `access.<name>` paths a query
|
|
116
|
+
* names ({@link AccessField}); {@link NoAccess} for an aggregate that
|
|
117
|
+
* declares none.
|
|
114
118
|
*/
|
|
115
|
-
export declare class SnapshotQueryClient<S = unknown, STATE_FIELDS extends string = `state.${string}
|
|
119
|
+
export declare class SnapshotQueryClient<S = unknown, STATE_FIELDS extends string = `state.${string}`, A = AccessValues> extends QueryModelClient<Snapshot<S, A>, SnapshotSystemField | STATE_FIELDS | AccessField<A>> {
|
|
116
120
|
readonly type: AggregateType;
|
|
117
121
|
/**
|
|
118
122
|
* @param type - The aggregate type
|
|
@@ -129,8 +133,11 @@ export declare class SnapshotQueryClient<S = unknown, STATE_FIELDS extends strin
|
|
|
129
133
|
* appends to: the budget bounds it.
|
|
130
134
|
*
|
|
131
135
|
* @typeParam E - The events' type.
|
|
136
|
+
* @typeParam A - The aggregate's declared access attributes, whose
|
|
137
|
+
* `access.<name>` paths a query names beside the built-in `access.owner`
|
|
138
|
+
* and `access.space`.
|
|
132
139
|
*/
|
|
133
|
-
export declare class EventQueryClient<E extends CommittedEvent = CommittedEvent> extends QueryModelClient<EventStream<E>, EventStreamField
|
|
140
|
+
export declare class EventQueryClient<E extends CommittedEvent = CommittedEvent, A = AccessValues> extends QueryModelClient<EventStream<E, A>, EventStreamField | AccessField<A>> {
|
|
134
141
|
readonly type: AggregateType;
|
|
135
142
|
/**
|
|
136
143
|
* @param type - The aggregate type
|
|
@@ -150,10 +157,13 @@ export declare class DatasetClient {
|
|
|
150
157
|
/** The datasets the caller sees, by name. */
|
|
151
158
|
list(options?: RequestOptions): Promise<DatasetEntry[]>;
|
|
152
159
|
/**
|
|
153
|
-
* The query client of the dataset `context.dataset`.
|
|
160
|
+
* The query client of the dataset `context.dataset`. A dataset is
|
|
161
|
+
* registered at run time, so no Manifest declares its rows' exact numbers:
|
|
162
|
+
* a caller that knows them passes them.
|
|
154
163
|
*
|
|
155
164
|
* @typeParam R - The row's type.
|
|
156
165
|
* @typeParam FIELDS - The dataset's field paths.
|
|
166
|
+
* @param numbers - The exact numbers of each row ({@link TextNumbers})
|
|
157
167
|
*/
|
|
158
|
-
dataset<R = Record<string, unknown>, FIELDS extends string = string>(context: string, dataset: string): QueryModelClient<R, FIELDS>;
|
|
168
|
+
dataset<R = Record<string, unknown>, FIELDS extends string = string>(context: string, dataset: string, numbers?: TextNumbers): QueryModelClient<R, FIELDS>;
|
|
159
169
|
}
|