@ahoo-wang/wow-client 10.0.0-alpha.7 → 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 +8 -5
- package/README.zh-CN.md +4 -3
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +9 -13
- package/dist/commands.d.ts +9 -13
- package/dist/commands.es.js +60 -54
- 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 +24 -379
- package/dist/dsl/descriptor.d.ts +24 -379
- package/dist/dsl/descriptor.es.js +6 -32
- 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 +5 -5
- package/dist/frameworkErrors.d.ts +5 -5
- 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 +30 -2
- package/dist/manifest.d.ts +30 -2
- package/dist/manifest.es.js +34 -6
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +21 -4
- package/dist/manifestTypes.d.ts +21 -4
- 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 +18 -5
- package/dist/wait.d.ts +18 -5
- 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 +76 -31
- package/dist/wire.d.ts +76 -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/http.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.es.js","names":["defaultFetcher","WowHeaders","quote","value","formatScope","members","scope","member","queryString","query","params","name","text","send","options","call","headers","exact","marksNothing","url","client","fetcher","stringifyJson","error","response","toWowProblemError","json","numbers","parseJson","entityTag","tag"],"sources":["../src/http.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 Fetcher, fetcher as defaultFetcher } from '@ahoo-wang/fetcher';\nimport {\n marksNothing,\n parseJson,\n stringifyJson,\n type TextNumbers,\n} from './exactJson.js';\nimport { toWowProblemError } from './problem.js';\n\n/**\n * The request headers of a Wow service's public port.\n */\nexport const WowHeaders = {\n /** The caller's id of the request: a retry with the same one is deduplicated. */\n REQUEST_ID: 'Wow-Request-Id',\n /** The wait plan (decision D99). */\n WAIT: 'Wow-Wait',\n /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */\n WAIT_TIMEOUT: 'Wow-Wait-Timeout',\n /** The scope to act in, for a caller allowed to act across scopes (decision D95). */\n SCOPE: 'Wow-Scope',\n /** The space, among the caller's own, to act in (decision D96). */\n SPACE: 'Wow-Space',\n /** The expected version of the aggregate, as an entity tag. */\n IF_MATCH: 'If-Match',\n /** The version, or descriptor version, a read already holds. */\n IF_NONE_MATCH: 'If-None-Match',\n /** The version of a state read, or of a query descriptor. */\n ETAG: 'ETag',\n /** The seconds after which a failed request may be retried. */\n RETRY_AFTER: 'Retry-After',\n /** The position a streamed list resumes after (decision D253). */\n LAST_EVENT_ID: 'Last-Event-ID',\n} as const;\n\n/** How a client reaches its service. */\nexport interface WowClientOptions {\n /**\n * The fetcher requests go through, with its base URL and interceptors\n * (authentication, say); the default fetcher when absent.\n */\n readonly fetcher?: Fetcher;\n /** A path put before every route, such as a gateway's prefix. */\n readonly basePath?: string;\n}\n\n/**\n * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`\n * header.\n */\nexport interface TargetScope {\n readonly tenantId?: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n}\n\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * A target scope as the `Wow-Scope` header spells it, an RFC 8941\n * dictionary: `tenant=\"t1\", owner=\"u1\", space=\"s1\"`.\n *\n * @param scope - The scope; at least one of its members is set\n */\nexport function formatScope(scope: TargetScope): string {\n const members = [\n scope.tenantId === undefined\n ? undefined\n : `tenant=${quote(scope.tenantId)}`,\n scope.ownerId === undefined ? undefined : `owner=${quote(scope.ownerId)}`,\n scope.spaceId === undefined ? undefined : `space=${quote(scope.spaceId)}`,\n ].filter(member => member !== undefined);\n if (members.length === 0) {\n throw new TypeError('Wow-Scope names a tenant, an owner or a space.');\n }\n return members.join(', ');\n}\n\n/** What every request may carry beside its own parameters. */\nexport interface RequestOptions {\n /** The scope to act in (`Wow-Scope`), for a caller allowed to. */\n readonly scope?: TargetScope;\n /** The space to act in (`Wow-Space`), among the caller's own. */\n readonly space?: string;\n /** More headers: the request facts the service records, say. */\n readonly headers?: Readonly<Record<string, string>>;\n /** Cancels the request. */\n readonly signal?: AbortSignal;\n}\n\n/** One request of a client. */\nexport interface Call {\n readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n readonly path: string;\n readonly query?: Readonly<Record<string, string | number | undefined>>;\n readonly headers?: Readonly<Record<string, string | undefined>>;\n readonly body?: unknown;\n /** The body's numbers written as their exact text ({@link TextNumbers}). */\n readonly bodyNumbers?: TextNumbers;\n readonly options?: RequestOptions;\n /** Answers a 304 rather than rejecting with it. */\n readonly notModified?: boolean;\n}\n\nfunction queryString(\n query: Readonly<Record<string, string | number | undefined>> | undefined,\n): string {\n if (!query) return '';\n const params = new URLSearchParams();\n for (const [name, value] of Object.entries(query)) {\n if (value !== undefined) params.append(name, String(value));\n }\n const text = params.toString();\n return text ? `?${text}` : '';\n}\n\n/**\n * Sends one request through the client's fetcher and answers its response;\n * a response that is not 2xx rejects with a {@link WowProblemError}.\n *\n * @param client - The client's options\n * @param call - The request\n */\nexport async function send(\n client: WowClientOptions,\n call: Call,\n): Promise<Response> {\n const options = call.options ?? {};\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries({\n ...call.headers,\n ...(options.scope === undefined\n ? {}\n : { [WowHeaders.SCOPE]: formatScope(options.scope) }),\n ...(options.space === undefined\n ? {}\n : { [WowHeaders.SPACE]: options.space }),\n ...options.headers,\n })) {\n if (value !== undefined) headers[name] = value;\n }\n // A body with exact numbers goes as its own JSON text, those numbers unquoted.\n const exact = call.body !== undefined && !marksNothing(call.bodyNumbers);\n if (exact) headers['Content-Type'] = 'application/json';\n const url = `${client.basePath ?? ''}${call.path}${queryString(call.query)}`;\n try {\n return await (client.fetcher ?? defaultFetcher).fetch(url, {\n method: call.method,\n headers,\n ...(call.body === undefined\n ? {}\n : {\n body: exact\n ? stringifyJson(call.body, call.bodyNumbers)\n : (call.body as object),\n }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const response = (error as { exchange?: { response?: Response } })?.exchange\n ?.response;\n if (call.notModified && response?.status === 304) return response;\n throw (await toWowProblemError(error)) ?? error;\n }\n}\n\n/**\n * The JSON body of a 2xx response; the numbers `numbers` marks come back as\n * their exact text, and without marks it is\n * `response.json()` itself.\n */\nexport async function json<T>(\n response: Response,\n numbers?: TextNumbers,\n): Promise<T> {\n if (marksNothing(numbers)) return (await response.json()) as T;\n return parseJson(await response.text(), numbers) as T;\n}\n\n/** The entity tag of a response without its quotes or weak marker. */\nexport function entityTag(response: Response): string | undefined {\n const tag = response.headers.get(WowHeaders.ETAG);\n return tag === null ? undefined : tag.replace(/^W\\//, '').replace(/\"/g, '');\n}\n"],"mappings":";;;;AAyBA,IAAaC,IAAa;CAExB,YAAY;CAEZ,MAAM;CAEN,cAAc;CAEd,OAAO;CAEP,OAAO;CAEP,UAAU;CAEV,eAAe;CAEf,MAAM;CAEN,aAAa;CAEb,eAAe;AACjB;AAuBA,SAASC,EAAM,GAAuB;CACpC,OAAO,IAAIC,EAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK,EAAE;AAC/D;AAQA,SAAgBC,EAAY,GAA4B;CACtD,IAAMC,IAAU;EACdC,EAAM,aAAa,KAAA,IACf,KAAA,IACA,UAAUJ,EAAMI,EAAM,QAAQ;EAClCA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;EACtEA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;CACxE,CAAC,CAAC,QAAO,MAAUC,MAAW,KAAA,CAAS;CACvC,IAAIF,EAAQ,WAAW,GACrB,MAAU,UAAU,gDAAgD;CAEtE,OAAOA,EAAQ,KAAK,IAAI;AAC1B;AA4BA,SAASG,EACP,GACQ;CACR,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMC,IAAS,IAAI,gBAAgB;CACnC,KAAK,IAAM,CAACC,GAAMR,MAAU,OAAO,QAAQM,CAAK,GAC9C,AAAIN,MAAU,KAAA,KAAWO,EAAO,OAAOC,GAAM,OAAOR,CAAK,CAAC;CAE5D,IAAMS,IAAOF,EAAO,SAAS;CAC7B,OAAOE,IAAO,IAAIA,MAAS;AAC7B;AASA,eAAsBC,EACpB,GACA,GACmB;CACnB,IAAMC,IAAUC,EAAK,WAAW,CAAC,GAC3BC,IAAkC,CAAC;CACzC,KAAK,IAAM,CAACL,GAAMR,MAAU,OAAO,QAAQ;EACzC,GAAGY,EAAK;EACR,GAAID,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGb,EAAW,QAAQG,EAAYU,EAAQ,KAAK,EAAE;EACrD,GAAIA,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGb,EAAW,QAAQa,EAAQ,MAAM;EACxC,GAAGA,EAAQ;CACb,CAAC,GACC,AAAIX,MAAU,KAAA,MAAW,EAAQQ,KAAQR;CAG3C,IAAMc,IAAQF,EAAK,SAAS,KAAA,KAAa,CAACG,EAAaH,EAAK,WAAW;CACvE,AAAIE,MAAO,EAAQ,kBAAkB;CACrC,IAAME,IAAM,GAAGC,EAAO,YAAY,KAAKL,EAAK,OAAOP,EAAYO,EAAK,KAAK;CACzE,IAAI;EACF,OAAO,OAAOK,EAAO,WAAWpB,EAAAA,CAAgB,MAAMmB,GAAK;GACzD,QAAQJ,EAAK;GACb;GACA,GAAIA,EAAK,SAAS,KAAA,IACd,CAAC,IACD,EACE,MAAME,IACFK,EAAcP,EAAK,MAAMA,EAAK,WAAW,IACxCA,EAAK,KACZ;GACJ,GAAID,EAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQA,EAAQ,OAAO;EACnE,CAAC;CACH,SAASS,GAAO;EACd,IAAMC,IAAYD,GAAkD,UAChE;EACJ,IAAIR,EAAK,eAAeS,GAAU,WAAW,KAAK,OAAOA;EACzD,MAAO,MAAMC,EAAkBF,CAAK,KAAMA;CAC5C;AACF;AAOA,eAAsBG,EACpB,GACA,GACY;CAEZ,OADIR,EAAaS,CAAO,IAAW,MAAMH,EAAS,KAAK,IAChDI,EAAU,MAAMJ,EAAS,KAAK,GAAGG,CAAO;AACjD;AAGA,SAAgBE,EAAU,GAAwC;CAChE,IAAMC,IAAMN,EAAS,QAAQ,IAAIvB,EAAW,IAAI;CAChD,OAAO6B,MAAQ,OAAO,KAAA,IAAYA,EAAI,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AAC5E"}
|
|
1
|
+
{"version":3,"file":"http.es.js","names":["defaultFetcher","WowHeaders","quote","value","formatScope","members","scope","member","queryString","query","params","name","text","Answer","response","numbers","marksNothing","parseJson","send","options","call","headers","exact","url","client","fetcher","stringifyJson","error","toWowProblemError","entityTag","tag"],"sources":["../src/http.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 Fetcher, fetcher as defaultFetcher } from '@ahoo-wang/fetcher';\nimport {\n marksNothing,\n parseJson,\n stringifyJson,\n type TextNumbers,\n} from './exactJson.js';\nimport { toWowProblemError } from './problem.js';\n\n/**\n * The request headers of a Wow service's public port.\n */\nexport const WowHeaders = {\n /** The caller's id of the request: a retry with the same one is deduplicated. */\n REQUEST_ID: 'Wow-Request-Id',\n /** The wait plan (decision D99). */\n WAIT: 'Wow-Wait',\n /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */\n WAIT_TIMEOUT: 'Wow-Wait-Timeout',\n /** The scope to act in, for a caller allowed to act across scopes (decision D95). */\n SCOPE: 'Wow-Scope',\n /** The space, among the caller's own, to act in (decision D96). */\n SPACE: 'Wow-Space',\n /** The expected version of the aggregate, as an entity tag. */\n IF_MATCH: 'If-Match',\n /** The version, or descriptor version, a read already holds. */\n IF_NONE_MATCH: 'If-None-Match',\n /** The version of a state read, or of a query descriptor. */\n ETAG: 'ETag',\n /** The seconds after which a failed request may be retried. */\n RETRY_AFTER: 'Retry-After',\n /** The position a streamed list resumes after (decision D253). */\n LAST_EVENT_ID: 'Last-Event-ID',\n} as const;\n\n/** How a client reaches its service. */\nexport interface WowClientOptions {\n /**\n * The fetcher requests go through, with its base URL and interceptors\n * (authentication, say); the default fetcher when absent.\n */\n readonly fetcher?: Fetcher;\n /** A path put before every route, such as a gateway's prefix. */\n readonly basePath?: string;\n}\n\n/**\n * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`\n * header.\n */\nexport interface TargetScope {\n readonly tenantId?: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n}\n\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * A target scope as the `Wow-Scope` header spells it, an RFC 8941\n * dictionary: `tenant=\"t1\", owner=\"u1\", space=\"s1\"`.\n *\n * @param scope - The scope; at least one of its members is set\n */\nexport function formatScope(scope: TargetScope): string {\n const members = [\n scope.tenantId === undefined\n ? undefined\n : `tenant=${quote(scope.tenantId)}`,\n scope.ownerId === undefined ? undefined : `owner=${quote(scope.ownerId)}`,\n scope.spaceId === undefined ? undefined : `space=${quote(scope.spaceId)}`,\n ].filter(member => member !== undefined);\n if (members.length === 0) {\n throw new TypeError('Wow-Scope names a tenant, an owner or a space.');\n }\n return members.join(', ');\n}\n\n/** What every request may carry beside its own parameters. */\nexport interface RequestOptions {\n /** The scope to act in (`Wow-Scope`), for a caller allowed to. */\n readonly scope?: TargetScope;\n /** The space to act in (`Wow-Space`), among the caller's own. */\n readonly space?: string;\n /** More headers: the request facts the service records, say. */\n readonly headers?: Readonly<Record<string, string>>;\n /** Cancels the request. */\n readonly signal?: AbortSignal;\n}\n\n/**\n * The exact numbers ({@link TextNumbers}) of one call: of the body it writes\n * and of the JSON it reads back.\n */\nexport interface CallNumbers {\n readonly body?: TextNumbers;\n readonly answer?: TextNumbers;\n}\n\n/** One request of a client. */\nexport interface Call {\n readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n readonly path: string;\n readonly query?: Readonly<Record<string, string | number | undefined>>;\n readonly headers?: Readonly<Record<string, string | undefined>>;\n readonly body?: unknown;\n /**\n * Its exact numbers, required of every call: a call with none says so\n * (`{}`), so no way of reading or writing JSON leaves them out.\n */\n readonly numbers: CallNumbers;\n readonly options?: RequestOptions;\n /** Answers a 304 rather than rejecting with it. */\n readonly notModified?: boolean;\n}\n\nfunction queryString(\n query: Readonly<Record<string, string | number | undefined>> | undefined,\n): string {\n if (!query) return '';\n const params = new URLSearchParams();\n for (const [name, value] of Object.entries(query)) {\n if (value !== undefined) params.append(name, String(value));\n }\n const text = params.toString();\n return text ? `?${text}` : '';\n}\n\n/**\n * A call's response: its JSON is read only with the exact numbers the call\n * declared ({@link Call.numbers}), here or by a stream reader given it.\n */\nexport class Answer {\n /**\n * @param response - The response\n * @param numbers - The exact numbers of its JSON, or of each event's\n */\n constructor(\n readonly response: Response,\n readonly numbers: TextNumbers | undefined,\n ) {}\n\n /** The JSON body, its exact numbers as their text. */\n async json<T>(): Promise<T> {\n return (\n marksNothing(this.numbers)\n ? await this.response.json()\n : parseJson(await this.response.text(), this.numbers)\n ) as T;\n }\n}\n\n/**\n * Sends one request through the client's fetcher and answers its response;\n * a response that is not 2xx rejects with a {@link WowProblemError}.\n *\n * @param client - The client's options\n * @param call - The request\n */\nexport async function send(\n client: WowClientOptions,\n call: Call,\n): Promise<Answer> {\n const options = call.options ?? {};\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries({\n ...call.headers,\n ...(options.scope === undefined\n ? {}\n : { [WowHeaders.SCOPE]: formatScope(options.scope) }),\n ...(options.space === undefined\n ? {}\n : { [WowHeaders.SPACE]: options.space }),\n ...options.headers,\n })) {\n if (value !== undefined) headers[name] = value;\n }\n // A body with exact numbers goes as its own JSON text, those numbers unquoted.\n const exact = call.body !== undefined && !marksNothing(call.numbers.body);\n if (exact) headers['Content-Type'] = 'application/json';\n const url = `${client.basePath ?? ''}${call.path}${queryString(call.query)}`;\n try {\n const response = await (client.fetcher ?? defaultFetcher).fetch(url, {\n method: call.method,\n headers,\n ...(call.body === undefined\n ? {}\n : {\n body: exact\n ? stringifyJson(call.body, call.numbers.body)\n : (call.body as object),\n }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n return new Answer(response, call.numbers.answer);\n } catch (error) {\n const response = (error as { exchange?: { response?: Response } })?.exchange\n ?.response;\n if (call.notModified && response?.status === 304) {\n return new Answer(response, undefined);\n }\n throw (await toWowProblemError(error)) ?? error;\n }\n}\n\n/** The entity tag of a response without its quotes or weak marker. */\nexport function entityTag(response: Response): string | undefined {\n const tag = response.headers.get(WowHeaders.ETAG);\n return tag === null ? undefined : tag.replace(/^W\\//, '').replace(/\"/g, '');\n}\n"],"mappings":";;;;AAyBA,IAAaC,IAAa;CAExB,YAAY;CAEZ,MAAM;CAEN,cAAc;CAEd,OAAO;CAEP,OAAO;CAEP,UAAU;CAEV,eAAe;CAEf,MAAM;CAEN,aAAa;CAEb,eAAe;AACjB;AAuBA,SAASC,EAAM,GAAuB;CACpC,OAAO,IAAIC,EAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK,EAAE;AAC/D;AAQA,SAAgBC,EAAY,GAA4B;CACtD,IAAMC,IAAU;EACdC,EAAM,aAAa,KAAA,IACf,KAAA,IACA,UAAUJ,EAAMI,EAAM,QAAQ;EAClCA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;EACtEA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;CACxE,CAAC,CAAC,QAAO,MAAUC,MAAW,KAAA,CAAS;CACvC,IAAIF,EAAQ,WAAW,GACrB,MAAU,UAAU,gDAAgD;CAEtE,OAAOA,EAAQ,KAAK,IAAI;AAC1B;AAwCA,SAASG,EACP,GACQ;CACR,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMC,IAAS,IAAI,gBAAgB;CACnC,KAAK,IAAM,CAACC,GAAMR,MAAU,OAAO,QAAQM,CAAK,GAC9C,AAAIN,MAAU,KAAA,KAAWO,EAAO,OAAOC,GAAM,OAAOR,CAAK,CAAC;CAE5D,IAAMS,IAAOF,EAAO,SAAS;CAC7B,OAAOE,IAAO,IAAIA,MAAS;AAC7B;AAMA,IAAaC,IAAb,MAAoB;CAKlB,YACE,GACA,GACA;EADS,AADA,KAAA,WAAAC,GACA,KAAA,UAAAC;CACR;CAGH,MAAM,OAAsB;EAC1B,OACEC,EAAa,KAAK,OAAO,IACrB,MAAM,KAAK,SAAS,KAAK,IACzBC,EAAU,MAAM,KAAK,SAAS,KAAK,GAAG,KAAK,OAAO;CAE1D;AACF;AASA,eAAsBC,EACpB,GACA,GACiB;CACjB,IAAMC,IAAUC,EAAK,WAAW,CAAC,GAC3BC,IAAkC,CAAC;CACzC,KAAK,IAAM,CAACV,GAAMR,MAAU,OAAO,QAAQ;EACzC,GAAGiB,EAAK;EACR,GAAID,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGlB,EAAW,QAAQG,EAAYe,EAAQ,KAAK,EAAE;EACrD,GAAIA,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGlB,EAAW,QAAQkB,EAAQ,MAAM;EACxC,GAAGA,EAAQ;CACb,CAAC,GACC,AAAIhB,MAAU,KAAA,MAAW,EAAQQ,KAAQR;CAG3C,IAAMmB,IAAQF,EAAK,SAAS,KAAA,KAAa,CAACJ,EAAaI,EAAK,QAAQ,IAAI;CACxE,AAAIE,MAAO,EAAQ,kBAAkB;CACrC,IAAMC,IAAM,GAAGC,EAAO,YAAY,KAAKJ,EAAK,OAAOZ,EAAYY,EAAK,KAAK;CACzE,IAAI;EAaF,OAAO,IAAIP,EAAO,OAZMW,EAAO,WAAWxB,EAAAA,CAAgB,MAAMuB,GAAK;GACnE,QAAQH,EAAK;GACb;GACA,GAAIA,EAAK,SAAS,KAAA,IACd,CAAC,IACD,EACE,MAAME,IACFI,EAAcN,EAAK,MAAMA,EAAK,QAAQ,IAAI,IACzCA,EAAK,KACZ;GACJ,GAAID,EAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQA,EAAQ,OAAO;EACnE,CAAC,GAC2BC,EAAK,QAAQ,MAAM;CACjD,SAASO,GAAO;EACd,IAAMb,IAAYa,GAAkD,UAChE;EACJ,IAAIP,EAAK,eAAeN,GAAU,WAAW,KAC3C,OAAO,IAAID,EAAOC,GAAU,KAAA,CAAS;EAEvC,MAAO,MAAMc,EAAkBD,CAAK,KAAMA;CAC5C;AACF;AAGA,SAAgBE,EAAU,GAAwC;CAChE,IAAMC,IAAMhB,EAAS,QAAQ,IAAIb,EAAW,IAAI;CAChD,OAAO6B,MAAQ,OAAO,KAAA,IAAYA,EAAI,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AAC5E"}
|
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
|
@@ -3,8 +3,12 @@ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceR
|
|
|
3
3
|
export type * from './manifestTypes.cjs';
|
|
4
4
|
/** Whether a command creates its aggregate. */
|
|
5
5
|
export type Creation = CommandManifest['creation'];
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A command as a {@link RoutingManifest} lists it: its name, former names and
|
|
8
|
+
* routes, and the property of its body that names its aggregate, for a command
|
|
9
|
+
* whose body does (`idProperty`).
|
|
10
|
+
*/
|
|
11
|
+
export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
|
|
8
12
|
/** A service route as a {@link RoutingManifest} lists it: its name and its route. */
|
|
9
13
|
export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
|
|
10
14
|
/**
|
|
@@ -45,3 +49,27 @@ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M
|
|
|
45
49
|
* @param options - Headers and cancellation
|
|
46
50
|
*/
|
|
47
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
|
@@ -3,8 +3,12 @@ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceR
|
|
|
3
3
|
export type * from './manifestTypes.js';
|
|
4
4
|
/** Whether a command creates its aggregate. */
|
|
5
5
|
export type Creation = CommandManifest['creation'];
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A command as a {@link RoutingManifest} lists it: its name, former names and
|
|
8
|
+
* routes, and the property of its body that names its aggregate, for a command
|
|
9
|
+
* whose body does (`idProperty`).
|
|
10
|
+
*/
|
|
11
|
+
export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
|
|
8
12
|
/** A service route as a {@link RoutingManifest} lists it: its name and its route. */
|
|
9
13
|
export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
|
|
10
14
|
/**
|
|
@@ -45,3 +49,27 @@ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M
|
|
|
45
49
|
* @param options - Headers and cancellation
|
|
46
50
|
*/
|
|
47
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,7 +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[];
|
|
122
|
+
/** The property of the command's body that holds its aggregate's id. */
|
|
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;
|
|
109
126
|
readonly description?: string;
|
|
110
127
|
}
|
|
111
128
|
/** An event of an aggregate and its revision. */
|
|
@@ -150,7 +167,7 @@ export interface SubscriptionManifest {
|
|
|
150
167
|
readonly rejected?: readonly string[];
|
|
151
168
|
readonly committed?: readonly string[];
|
|
152
169
|
readonly calls?: readonly string[];
|
|
153
|
-
readonly start?: 'beginning' | 'end' | (string & {});
|
|
170
|
+
readonly start?: 'beginning' | 'end' | 'join' | (string & {});
|
|
154
171
|
readonly schedules?: readonly string[];
|
|
155
172
|
readonly retry?: RetryManifest;
|
|
156
173
|
readonly job?: JobManifest;
|
|
@@ -178,16 +195,16 @@ export interface RetryManifest {
|
|
|
178
195
|
readonly timeout?: string;
|
|
179
196
|
readonly recoverable?: readonly string[];
|
|
180
197
|
readonly unrecoverable?: readonly string[];
|
|
198
|
+
readonly systemic?: readonly string[];
|
|
181
199
|
readonly multiplier?: number;
|
|
182
200
|
}
|
|
183
201
|
/** The scheduled job a subscription runs. */
|
|
184
202
|
export interface JobManifest {
|
|
185
203
|
readonly name: string;
|
|
186
204
|
readonly cron: string;
|
|
187
|
-
readonly
|
|
205
|
+
readonly timeZone: string;
|
|
188
206
|
/** Who the job runs for. */
|
|
189
|
-
readonly scope: 'system' | 'tenant' | (string & {});
|
|
190
|
-
readonly sharded: boolean;
|
|
207
|
+
readonly scope: 'system' | 'tenant' | 'sharded' | (string & {});
|
|
191
208
|
/** What the job does with the slots it missed. */
|
|
192
209
|
readonly misfire: 'coalesce' | 'catch-up' | (string & {});
|
|
193
210
|
}
|
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,7 +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[];
|
|
122
|
+
/** The property of the command's body that holds its aggregate's id. */
|
|
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;
|
|
109
126
|
readonly description?: string;
|
|
110
127
|
}
|
|
111
128
|
/** An event of an aggregate and its revision. */
|
|
@@ -150,7 +167,7 @@ export interface SubscriptionManifest {
|
|
|
150
167
|
readonly rejected?: readonly string[];
|
|
151
168
|
readonly committed?: readonly string[];
|
|
152
169
|
readonly calls?: readonly string[];
|
|
153
|
-
readonly start?: 'beginning' | 'end' | (string & {});
|
|
170
|
+
readonly start?: 'beginning' | 'end' | 'join' | (string & {});
|
|
154
171
|
readonly schedules?: readonly string[];
|
|
155
172
|
readonly retry?: RetryManifest;
|
|
156
173
|
readonly job?: JobManifest;
|
|
@@ -178,16 +195,16 @@ export interface RetryManifest {
|
|
|
178
195
|
readonly timeout?: string;
|
|
179
196
|
readonly recoverable?: readonly string[];
|
|
180
197
|
readonly unrecoverable?: readonly string[];
|
|
198
|
+
readonly systemic?: readonly string[];
|
|
181
199
|
readonly multiplier?: number;
|
|
182
200
|
}
|
|
183
201
|
/** The scheduled job a subscription runs. */
|
|
184
202
|
export interface JobManifest {
|
|
185
203
|
readonly name: string;
|
|
186
204
|
readonly cron: string;
|
|
187
|
-
readonly
|
|
205
|
+
readonly timeZone: string;
|
|
188
206
|
/** Who the job runs for. */
|
|
189
|
-
readonly scope: 'system' | 'tenant' | (string & {});
|
|
190
|
-
readonly sharded: boolean;
|
|
207
|
+
readonly scope: 'system' | 'tenant' | 'sharded' | (string & {});
|
|
191
208
|
/** What the job does with the slots it missed. */
|
|
192
209
|
readonly misfire: 'coalesce' | 'catch-up' | (string & {});
|
|
193
210
|
}
|
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
|