@ahoo-wang/wow-client 9.9.0 → 10.0.0-alpha.3
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/dist/dsl/descriptor.cjs.map +1 -1
- package/dist/dsl/descriptor.d.cts +7 -0
- package/dist/dsl/descriptor.d.ts +7 -0
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/v10/commands.cjs +2 -0
- package/dist/v10/commands.cjs.map +1 -0
- package/dist/v10/commands.d.cts +105 -0
- package/dist/v10/commands.d.ts +105 -0
- package/dist/v10/commands.es.js +68 -0
- package/dist/v10/commands.es.js.map +1 -0
- package/dist/v10/http.cjs +2 -0
- package/dist/v10/http.cjs.map +1 -0
- package/dist/v10/http.d.cts +87 -0
- package/dist/v10/http.d.ts +87 -0
- package/dist/v10/http.es.js +73 -0
- package/dist/v10/http.es.js.map +1 -0
- package/dist/v10/index.d.cts +19 -0
- package/dist/v10/index.d.ts +19 -0
- package/dist/v10/manifest.cjs +2 -0
- package/dist/v10/manifest.cjs.map +1 -0
- package/dist/v10/manifest.d.cts +109 -0
- package/dist/v10/manifest.d.ts +109 -0
- package/dist/v10/manifest.es.js +14 -0
- package/dist/v10/manifest.es.js.map +1 -0
- package/dist/v10/problem.cjs +2 -0
- package/dist/v10/problem.cjs.map +1 -0
- package/dist/v10/problem.d.cts +164 -0
- package/dist/v10/problem.d.ts +164 -0
- package/dist/v10/problem.es.js +119 -0
- package/dist/v10/problem.es.js.map +1 -0
- package/dist/v10/queries.cjs +2 -0
- package/dist/v10/queries.cjs.map +1 -0
- package/dist/v10/queries.d.cts +136 -0
- package/dist/v10/queries.d.ts +136 -0
- package/dist/v10/queries.es.js +88 -0
- package/dist/v10/queries.es.js.map +1 -0
- package/dist/v10/state.cjs +2 -0
- package/dist/v10/state.cjs.map +1 -0
- package/dist/v10/state.d.cts +53 -0
- package/dist/v10/state.d.ts +53 -0
- package/dist/v10/state.es.js +51 -0
- package/dist/v10/state.es.js.map +1 -0
- package/dist/v10/streams.cjs +2 -0
- package/dist/v10/streams.cjs.map +1 -0
- package/dist/v10/streams.d.cts +14 -0
- package/dist/v10/streams.d.ts +14 -0
- package/dist/v10/streams.es.js +22 -0
- package/dist/v10/streams.es.js.map +1 -0
- package/dist/v10/wait.cjs +2 -0
- package/dist/v10/wait.cjs.map +1 -0
- package/dist/v10/wait.d.cts +61 -0
- package/dist/v10/wait.d.ts +61 -0
- package/dist/v10/wait.es.js +44 -0
- package/dist/v10/wait.es.js.map +1 -0
- package/dist/v10/wire.cjs +2 -0
- package/dist/v10/wire.cjs.map +1 -0
- package/dist/v10/wire.d.cts +301 -0
- package/dist/v10/wire.d.ts +301 -0
- package/dist/v10/wire.es.js +10 -0
- package/dist/v10/wire.es.js.map +1 -0
- package/dist/v10.cjs +1 -0
- package/dist/v10.es.js +9 -0
- package/package.json +11 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.cjs","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'SNAPSHOT',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'EVENT_STREAM',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'DATASET',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'STRING',\n /** A whole number. */\n INTEGER: 'INTEGER',\n /** A number with a fraction. */\n DECIMAL: 'DECIMAL',\n /** `true` or `false`. */\n BOOLEAN: 'BOOLEAN',\n /** A JSON object. */\n OBJECT: 'OBJECT',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'UNKNOWN',\n /** Always `null`. */\n NULL = 'NULL',\n /** A single string, number or boolean. */\n SCALAR = 'SCALAR',\n /** An object. */\n OBJECT = 'OBJECT',\n /** An array. */\n ARRAY = 'ARRAY',\n /** One of several of the above. */\n UNION = 'UNION',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `listStream`: the first `limit` rows. */\n LIST = 'LIST',\n /** `paged`: numbered pages with a total. */\n PAGED = 'PAGED',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'CURSOR',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'IDENTITY',\n /** The aggregate id. */\n AGGREGATE_ID: 'AGGREGATE_ID',\n /** The tenant id. */\n TENANT_ID: 'TENANT_ID',\n /** The owner id. */\n OWNER_ID: 'OWNER_ID',\n /** The space id. */\n SPACE_ID: 'SPACE_ID',\n /** Whether the aggregate is deleted. */\n DELETED: 'DELETED',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'EVENT_TIME',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'FIRST_EVENT_TIME',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'CURSOR_UNIQUE_SORT',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'STARTS_WITH_REQUIRES_PREFIX',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'NULL_OR_EMPTY_AS_MISSING',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: 'TEMPORAL_DATE';\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: 'TEMPORAL_EPOCH';\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: 'TEMPORAL_FORMATTED';\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: 'DECIMAL';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: 'MONEY';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: 'DURATION';\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: 'REFERENCE';\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'DISPLAY',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'CONFIDENTIAL',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /** The `limit` a list query without one gets. */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: AggregationDateUnit[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: AggregationDatePart[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: DateDiffUnit[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: WindowFunction[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'ROOT'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The server's default time zone, used when a request names none. */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":"AAuCA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,eAEd,QAAS,SACX,CAAU,EAUGC,EAAkB,OAAO,OAAO,CAE3C,OAAQ,SAER,QAAS,UAET,QAAS,UAET,QAAS,UAET,OAAQ,QACV,CAAU,EAOEC,EAAL,SAAA,EAAA,OAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,OAEA,EAAAC,OAAA,SAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,MAAA,SACF,EAAA,CAAA,CAAA,EAGYC,EAAL,SAAA,EAAA,OAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,UACF,EAAA,CAAA,CAAA,EAOaC,EAAkB,OAAO,OAAO,CAE3C,SAAU,WAEV,aAAc,eAEd,UAAW,YAEX,SAAU,WAEV,SAAU,WAEV,QAAS,UAMT,WAAY,aAKZ,iBAAkB,kBACpB,CAAU,EAUGC,EAAuB,OAAO,OAAO,CAKhD,mBAAoB,qBAEpB,sBAAuB,wBAEvB,4BAA6B,8BAO7B,oBAAqB,sBAQrB,yBAA0B,2BAO1B,eAAgB,gBAClB,CAAU,EAsJEC,EAAL,SAAA,EAAA,OAML,GAAAC,QAAA,UAKA,EAAAC,aAAA,gBACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"descriptor.cjs","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'SNAPSHOT',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'EVENT_STREAM',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'DATASET',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'STRING',\n /** A whole number. */\n INTEGER: 'INTEGER',\n /** A number with a fraction. */\n DECIMAL: 'DECIMAL',\n /** `true` or `false`. */\n BOOLEAN: 'BOOLEAN',\n /** A JSON object. */\n OBJECT: 'OBJECT',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'UNKNOWN',\n /** Always `null`. */\n NULL = 'NULL',\n /** A single string, number or boolean. */\n SCALAR = 'SCALAR',\n /** An object. */\n OBJECT = 'OBJECT',\n /** An array. */\n ARRAY = 'ARRAY',\n /** One of several of the above. */\n UNION = 'UNION',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `listStream`: the first `limit` rows. */\n LIST = 'LIST',\n /** `paged`: numbered pages with a total. */\n PAGED = 'PAGED',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'CURSOR',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'IDENTITY',\n /** The aggregate id. */\n AGGREGATE_ID: 'AGGREGATE_ID',\n /** The tenant id. */\n TENANT_ID: 'TENANT_ID',\n /** The owner id. */\n OWNER_ID: 'OWNER_ID',\n /** The space id. */\n SPACE_ID: 'SPACE_ID',\n /** Whether the aggregate is deleted. */\n DELETED: 'DELETED',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'EVENT_TIME',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'FIRST_EVENT_TIME',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'CURSOR_UNIQUE_SORT',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'STARTS_WITH_REQUIRES_PREFIX',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'NULL_OR_EMPTY_AS_MISSING',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: 'TEMPORAL_DATE';\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: 'TEMPORAL_EPOCH';\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: 'TEMPORAL_FORMATTED';\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: 'DECIMAL';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: 'MONEY';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: 'DURATION';\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: 'REFERENCE';\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'DISPLAY',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'CONFIDENTIAL',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n /**\n * The most groups an aggregation may read where the server computes part of\n * it (HAVING, a metric sort, dense fill or windows its storage cannot run),\n * beyond which the query fails; `null` or absent is unlimited. Absent from\n * servers before Wow 9.10.\n */\n maxResidualGroups?: number | null;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /** The `limit` a list query without one gets. */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: AggregationDateUnit[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: AggregationDatePart[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: DateDiffUnit[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: WindowFunction[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'ROOT'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The server's default time zone, used when a request names none. */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":"AAuCA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,eAEd,QAAS,SACX,CAAU,EAUGC,EAAkB,OAAO,OAAO,CAE3C,OAAQ,SAER,QAAS,UAET,QAAS,UAET,QAAS,UAET,OAAQ,QACV,CAAU,EAOEC,EAAL,SAAA,EAAA,OAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,OAEA,EAAAC,OAAA,SAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,MAAA,SACF,EAAA,CAAA,CAAA,EAGYC,EAAL,SAAA,EAAA,OAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,UACF,EAAA,CAAA,CAAA,EAOaC,EAAkB,OAAO,OAAO,CAE3C,SAAU,WAEV,aAAc,eAEd,UAAW,YAEX,SAAU,WAEV,SAAU,WAEV,QAAS,UAMT,WAAY,aAKZ,iBAAkB,kBACpB,CAAU,EAUGC,EAAuB,OAAO,OAAO,CAKhD,mBAAoB,qBAEpB,sBAAuB,wBAEvB,4BAA6B,8BAO7B,oBAAqB,sBAQrB,yBAA0B,2BAO1B,eAAgB,gBAClB,CAAU,EAsJEC,EAAL,SAAA,EAAA,OAML,GAAAC,QAAA,UAKA,EAAAC,aAAA,gBACF,EAAA,CAAA,CAAA"}
|
|
@@ -461,6 +461,13 @@ export interface AggregationLimitsDescriptor {
|
|
|
461
461
|
maxExpressionDepth: number;
|
|
462
462
|
/** Most nodes in one arithmetic expression. */
|
|
463
463
|
maxExpressionNodes: number;
|
|
464
|
+
/**
|
|
465
|
+
* The most groups an aggregation may read where the server computes part of
|
|
466
|
+
* it (HAVING, a metric sort, dense fill or windows its storage cannot run),
|
|
467
|
+
* beyond which the query fails; `null` or absent is unlimited. Absent from
|
|
468
|
+
* servers before Wow 9.10.
|
|
469
|
+
*/
|
|
470
|
+
maxResidualGroups?: number | null;
|
|
464
471
|
}
|
|
465
472
|
/**
|
|
466
473
|
* The effective limits of the entry the descriptor was read from: the
|
package/dist/dsl/descriptor.d.ts
CHANGED
|
@@ -461,6 +461,13 @@ export interface AggregationLimitsDescriptor {
|
|
|
461
461
|
maxExpressionDepth: number;
|
|
462
462
|
/** Most nodes in one arithmetic expression. */
|
|
463
463
|
maxExpressionNodes: number;
|
|
464
|
+
/**
|
|
465
|
+
* The most groups an aggregation may read where the server computes part of
|
|
466
|
+
* it (HAVING, a metric sort, dense fill or windows its storage cannot run),
|
|
467
|
+
* beyond which the query fails; `null` or absent is unlimited. Absent from
|
|
468
|
+
* servers before Wow 9.10.
|
|
469
|
+
*/
|
|
470
|
+
maxResidualGroups?: number | null;
|
|
464
471
|
}
|
|
465
472
|
/**
|
|
466
473
|
* The effective limits of the entry the descriptor was read from: the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.es.js","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'SNAPSHOT',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'EVENT_STREAM',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'DATASET',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'STRING',\n /** A whole number. */\n INTEGER: 'INTEGER',\n /** A number with a fraction. */\n DECIMAL: 'DECIMAL',\n /** `true` or `false`. */\n BOOLEAN: 'BOOLEAN',\n /** A JSON object. */\n OBJECT: 'OBJECT',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'UNKNOWN',\n /** Always `null`. */\n NULL = 'NULL',\n /** A single string, number or boolean. */\n SCALAR = 'SCALAR',\n /** An object. */\n OBJECT = 'OBJECT',\n /** An array. */\n ARRAY = 'ARRAY',\n /** One of several of the above. */\n UNION = 'UNION',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `listStream`: the first `limit` rows. */\n LIST = 'LIST',\n /** `paged`: numbered pages with a total. */\n PAGED = 'PAGED',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'CURSOR',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'IDENTITY',\n /** The aggregate id. */\n AGGREGATE_ID: 'AGGREGATE_ID',\n /** The tenant id. */\n TENANT_ID: 'TENANT_ID',\n /** The owner id. */\n OWNER_ID: 'OWNER_ID',\n /** The space id. */\n SPACE_ID: 'SPACE_ID',\n /** Whether the aggregate is deleted. */\n DELETED: 'DELETED',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'EVENT_TIME',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'FIRST_EVENT_TIME',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'CURSOR_UNIQUE_SORT',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'STARTS_WITH_REQUIRES_PREFIX',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'NULL_OR_EMPTY_AS_MISSING',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: 'TEMPORAL_DATE';\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: 'TEMPORAL_EPOCH';\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: 'TEMPORAL_FORMATTED';\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: 'DECIMAL';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: 'MONEY';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: 'DURATION';\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: 'REFERENCE';\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'DISPLAY',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'CONFIDENTIAL',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /** The `limit` a list query without one gets. */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: AggregationDateUnit[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: AggregationDatePart[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: DateDiffUnit[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: WindowFunction[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'ROOT'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The server's default time zone, used when a request names none. */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":";AAuCA,IAAaA,IAAc,OAAO,OAAO;CAEvC,UAAU;CAEV,cAAc;CAEd,SAAS;AACX,CAAU,GAUGC,IAAkB,OAAO,OAAO;CAE3C,QAAQ;CAER,SAAS;CAET,SAAS;CAET,SAAS;CAET,QAAQ;AACV,CAAU,GAOEC,IAAL,yBAAA,GAAA;QAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,QAEA,EAAAC,SAAA,UAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,QAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,OAAA,QAEA,EAAAC,QAAA,SAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GAOaC,IAAkB,OAAO,OAAO;CAE3C,UAAU;CAEV,cAAc;CAEd,WAAW;CAEX,UAAU;CAEV,UAAU;CAEV,SAAS;CAMT,YAAY;CAKZ,kBAAkB;AACpB,CAAU,GAUGC,IAAuB,OAAO,OAAO;CAKhD,oBAAoB;CAEpB,uBAAuB;CAEvB,6BAA6B;CAO7B,qBAAqB;CAQrB,0BAA0B;CAO1B,gBAAgB;AAClB,CAAU,GAsJEC,IAAL,yBAAA,GAAA;QAML,EAAAC,UAAA,WAKA,EAAAC,eAAA;AACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"descriptor.es.js","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.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\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'SNAPSHOT',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'EVENT_STREAM',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'DATASET',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'STRING',\n /** A whole number. */\n INTEGER: 'INTEGER',\n /** A number with a fraction. */\n DECIMAL: 'DECIMAL',\n /** `true` or `false`. */\n BOOLEAN: 'BOOLEAN',\n /** A JSON object. */\n OBJECT: 'OBJECT',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'UNKNOWN',\n /** Always `null`. */\n NULL = 'NULL',\n /** A single string, number or boolean. */\n SCALAR = 'SCALAR',\n /** An object. */\n OBJECT = 'OBJECT',\n /** An array. */\n ARRAY = 'ARRAY',\n /** One of several of the above. */\n UNION = 'UNION',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `listStream`: the first `limit` rows. */\n LIST = 'LIST',\n /** `paged`: numbered pages with a total. */\n PAGED = 'PAGED',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'CURSOR',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'IDENTITY',\n /** The aggregate id. */\n AGGREGATE_ID: 'AGGREGATE_ID',\n /** The tenant id. */\n TENANT_ID: 'TENANT_ID',\n /** The owner id. */\n OWNER_ID: 'OWNER_ID',\n /** The space id. */\n SPACE_ID: 'SPACE_ID',\n /** Whether the aggregate is deleted. */\n DELETED: 'DELETED',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'EVENT_TIME',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'FIRST_EVENT_TIME',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'CURSOR_UNIQUE_SORT',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'STARTS_WITH_REQUIRES_PREFIX',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'NULL_OR_EMPTY_AS_MISSING',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: 'TEMPORAL_DATE';\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: 'TEMPORAL_EPOCH';\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: 'TEMPORAL_FORMATTED';\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: 'DECIMAL';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: 'MONEY';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: 'DURATION';\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: 'REFERENCE';\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'DISPLAY',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'CONFIDENTIAL',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n /**\n * The most groups an aggregation may read where the server computes part of\n * it (HAVING, a metric sort, dense fill or windows its storage cannot run),\n * beyond which the query fails; `null` or absent is unlimited. Absent from\n * servers before Wow 9.10.\n */\n maxResidualGroups?: number | null;\n}\n\n/**\n * The effective limits of the entry the descriptor was read from: the\n * protocol's and the entry's budget, whichever is smaller. `null` is\n * unlimited.\n */\nexport interface LimitsDescriptor {\n /** Largest `limit` of a list query. */\n maxListSize: number | null;\n /** The `limit` a list query without one gets. */\n defaultListSize: number | null;\n /** Largest page `size` of a paged or cursor query. */\n maxPageSize: number | null;\n /** How far a paged query may reach: page index times size. */\n maxPageWindow: number | null;\n /** Most nodes in one filter. */\n maxFilterNodes: number | null;\n /** Most values in one filter, `IN` lists included. */\n maxFilterValues: number | null;\n /** Most fields in one sort. */\n maxSortFields: number;\n /** The limits of an aggregation query. */\n aggregation: AggregationLimitsDescriptor;\n}\n\n/** The metrics a `having` clause may test. */\nexport interface HavingDescriptor {\n /** The metric types it may name; never `ANY`, `FIRST` or `LAST`. */\n metrics: (AggregationMetricType | (string & {}))[];\n}\n\n/** What an aggregation's result rows may be sorted by. */\nexport interface AnalysisSortDescriptor {\n /** By a group. */\n groups: boolean;\n /** By a metric. */\n metrics: boolean;\n}\n\n/** The aggregation features the model offers. */\nexport interface AnalysisDescriptor {\n /** The metric types it admits. */\n metrics: (AggregationMetricType | (string & {}))[];\n /**\n * The metric types among `metrics` whose results this backend estimates\n * rather than computes exactly, such as `PERCENTILE` on MongoDB, or\n * `DISTINCT_COUNT` and `PERCENTILE` on Elasticsearch; empty when every\n * result is exact. The set is open, like `metrics`: label a result of a\n * listed type as approximate.\n */\n approximate: (AggregationMetricType | (string & {}))[];\n /**\n * Whether computed expressions (arithmetic and `DATE_DIFF`) may feed\n * metrics and TERMS / HISTOGRAM groups, and be compared by an `EXPRESSION`\n * filter. A `DATE_DIFF` operand is any field whose `aggregate.groups`\n * lists `DATE_HISTOGRAM`.\n */\n expressions: boolean;\n /** What `having` may test. */\n having: HavingDescriptor;\n /** What result rows may be sorted by. */\n sort: AnalysisSortDescriptor;\n /**\n * Whether a date histogram or a date part group may fill its empty\n * buckets (`dense`).\n */\n dense: boolean;\n /** The calendar units a `DATE_HISTOGRAM` group may bucket by. */\n dateUnits: AggregationDateUnit[];\n /** The calendar parts a `DATE_PART` group may group by. */\n dateParts: AggregationDatePart[];\n /** The units a `DATE_DIFF` may measure in; empty when `expressions` is `false`. */\n dateDiffUnits: DateDiffUnit[];\n /**\n * The field `FIRST` and `LAST` order by when they name no `orderBy`, at\n * the record level: the model's event time. Absent when the model has no\n * event time or the storage offers no `FIRST` / `LAST`. An explicit\n * `orderBy` may be any single-valued field whose `sort.paged` is `true` in\n * the metric's scope.\n */\n firstLastOrderBy?: string;\n /**\n * The window functions a derived metric may compute over the groups; empty\n * when expensive operators are off. Absent from servers before Wow 9.9,\n * which compute no windows.\n */\n windows?: WindowFunction[];\n /**\n * Whether a group of a query that expands elements may name a field of the\n * root record (`scope: 'ROOT'`); `false` when expensive operators are off.\n * Absent from servers before Wow 9.9, which group elements by element\n * fields only.\n */\n rootGroups?: boolean;\n}\n\n/** A rule about combinations that no single capability shows. */\nexport interface ConstraintDescriptor {\n /** Which rule; see {@link QueryConstraintTypes}. */\n type: QueryConstraintType;\n /** For `CURSOR_UNIQUE_SORT`, the field the server appends to the sort. */\n appended?: string;\n /**\n * The fields the rule is about, when it names several: for\n * `PARALLEL_ARRAY_SORT`, the array fields a sort may name only one of;\n * for `NULL_OR_EMPTY_AS_MISSING`, the fields whose `null` or empty value\n * reads as missing.\n */\n fields?: string[];\n}\n\n/**\n * One variant of an element: the value of its discriminator and the fields\n * that variant has. For an event stream, one event type and its payload\n * fields.\n */\nexport interface VariantDescriptor {\n /** The discriminator's value, such as the event's `bodyType`. */\n value: string;\n /**\n * The variant's fields, by paths relative to the element, such as\n * `body.added.productId` inside `body`. Each field states the variant's\n * own types; its operators, sorts and aggregation are those of the shared\n * logical path, which admission checks. A field's `scope` is relative to\n * the element too, and absent for a field directly in it.\n */\n fields: FieldDescriptor[];\n /** What the variant means, when the model describes it. */\n description?: string;\n}\n\n/**\n * An element of every record whose fields differ by variant: an event\n * stream record's `body` holds events whose payload fields depend on\n * `bodyType`. A condition on one variant's field goes inside an\n * `ELEMENT_MATCH` on `element`, together with a condition on the\n * `discriminator`, so both hold for the same element.\n */\nexport interface VariantsDescriptor {\n /** The element's logical path, such as `body`. */\n element: string;\n /** The element-relative field that names each element's variant, such as `bodyType`. */\n discriminator: string;\n /** Each variant, sorted by `value`. */\n values: VariantDescriptor[];\n}\n\n/**\n * How a query model can be queried over HTTP: the answer\n * `GET {aggregate}/snapshot/schema` and `GET {aggregate}/event/schema` give.\n * Read it with `QueryDescriptorClient`.\n *\n * The contract: every operator, sort, paging mode, group and function it\n * lists is admitted when used on its own, and anything it does not list is\n * rejected; `constraints` names the rules about combinations. A value, a\n * scope or a policy can still reject a query, with a\n * `QueryViolation`. It exposes no storage names and does not depend on\n * the caller, so it can be cached: `version` is a hash of its content and is\n * also the response's ETag.\n */\nexport interface QueryModelDescriptor {\n /** The query model it describes. */\n model: QueryModel;\n /** `sha256:` and the hash of its content; also the ETag, quoted. */\n version: string;\n /** The server's default time zone, used when a request names none. */\n timeZone: string;\n /** What holds for the records as a whole. */\n record: RecordDescriptor;\n /** The entry's effective limits. */\n limits: LimitsDescriptor;\n /** The aggregation features. */\n analysis: AnalysisDescriptor;\n /** Every queryable field, those inside elements included (see `scope`). */\n fields: FieldDescriptor[];\n /** The array fields whose elements can be queried one by one. */\n elements: ElementDescriptor[];\n /** Fields under dynamic map keys. */\n dynamic: DynamicFieldDescriptor[];\n /** The rules about combinations. */\n constraints: ConstraintDescriptor[];\n /**\n * The variants of an element whose fields differ by a discriminator, such\n * as an event stream's event types; absent when the model has none, as a\n * snapshot model never does.\n */\n variants?: VariantsDescriptor;\n}\n"],"mappings":";AAuCA,IAAaA,IAAc,OAAO,OAAO;CAEvC,UAAU;CAEV,cAAc;CAEd,SAAS;AACX,CAAU,GAUGC,IAAkB,OAAO,OAAO;CAE3C,QAAQ;CAER,SAAS;CAET,SAAS;CAET,SAAS;CAET,QAAQ;AACV,CAAU,GAOEC,IAAL,yBAAA,GAAA;QAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,QAEA,EAAAC,SAAA,UAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,QAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,OAAA,QAEA,EAAAC,QAAA,SAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GAOaC,IAAkB,OAAO,OAAO;CAE3C,UAAU;CAEV,cAAc;CAEd,WAAW;CAEX,UAAU;CAEV,UAAU;CAEV,SAAS;CAMT,YAAY;CAKZ,kBAAkB;AACpB,CAAU,GAUGC,IAAuB,OAAO,OAAO;CAKhD,oBAAoB;CAEpB,uBAAuB;CAEvB,6BAA6B;CAO7B,qBAAqB;CAQrB,0BAA0B;CAO1B,gBAAgB;AAClB,CAAU,GAsJEC,IAAL,yBAAA,GAAA;QAML,EAAAC,UAAA,WAKA,EAAAC,eAAA;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./problem.cjs"),t=require("./http.cjs"),n=require("./streams.cjs"),r=require("./wait.cjs");var i={DELETE_AGGREGATE:`wow.lifecycle.DeleteAggregate`,RESTORE_AGGREGATE:`wow.lifecycle.RestoreAggregate`,TRANSFER_OWNER:`wow.lifecycle.TransferOwner`,TRANSFER_SPACE:`wow.lifecycle.TransferSpace`,APPLY_TAGS:`wow.lifecycle.ApplyTags`};function a(e){return e.replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/[_\s]+/g,`-`).toLowerCase()}function o(e,n){let i=e.wait;return{[t.WowV10Headers.REQUEST_ID]:e.requestId,[t.WowV10Headers.WAIT]:i?.plan===void 0?void 0:r.formatWaitPlan(i.plan),[t.WowV10Headers.WAIT_TIMEOUT]:i?.timeout===void 0?void 0:r.formatWaitTimeout(i.timeout),[t.WowV10Headers.IF_MATCH]:e.expectedVersion===void 0?void 0:`"${e.expectedVersion}"`,Accept:n}}var s=class{constructor(e={}){this.client=e}async send(n,r,i={}){try{let e=await this.post(n,r,i);return await t.json(e)}catch(t){if(i.resolveRejected&&t instanceof e.WowProblemError&&t.result!==void 0)return t.result;throw t}}async stream(e,t,r={}){return n.commandResults(await this.post(e,t,r,`text/event-stream`))}async lifecycle(e,n,r,s,c={}){let l=`${e}/${encodeURIComponent(n)}`;if(r===i.DELETE_AGGREGATE){let e=await t.send(this.client,{method:`DELETE`,path:l,headers:o(c),options:c});return t.json(e)}return this.send(`${l}/${a(r)}`,s??{},c)}post(e,n,r,i){return t.send(this.client,{method:`POST`,path:e.includes(`{id}`)?t.expandPath(e,{id:r.id??``}):e,headers:o(r,i),body:n??{},options:r})}};exports.CommandGateway=s,exports.LifecycleCommands=i,exports.commandSegment=a;
|
|
2
|
+
//# sourceMappingURL=commands.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.cjs","names":["WowV10Headers","formatWaitPlan","formatWaitTimeout","json","WowProblemError","commandResults","send","expandPath","require_problem","require_http","require_streams","require_wait","LifecycleCommands","commandSegment","name","commandHeaders","wait","options","accept","CommandGateway","client","response","path","body","error","base","aggregatePath","id","command"],"sources":["../../src/v10/commands.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n expandPath,\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n WowV10Headers,\n} from './http.js';\nimport type { CommandResult } from './wire.js';\nimport { WowProblemError } from './problem.js';\nimport { commandResults, type CommandResultStream } from './streams.js';\nimport { formatWaitPlan, formatWaitTimeout, type WaitOptions } from './wait.js';\n\n/** What a command request carries beside its body (decisions D95–D99). */\nexport interface CommandOptions extends RequestOptions {\n /**\n * The request id (`Wow-Request-Id`): a retry with the same one is\n * deduplicated, answered as the first commit's duplicate.\n */\n readonly requestId?: string;\n /** What to wait for, and for how long. */\n readonly wait?: WaitOptions;\n /** The version the aggregate must be at (`If-Match`). */\n readonly expectedVersion?: number;\n /**\n * Resolve a result that did not succeed instead of rejecting with its\n * {@link WowProblemError}; `false` by default.\n */\n readonly resolveRejected?: boolean;\n}\n\n/** The options of a command whose route may name the aggregate id or not. */\nexport interface CreateCommandOptions extends CommandOptions {\n /**\n * The id of the aggregate to create (decision D176); the service generates\n * one when absent.\n */\n readonly id?: string;\n}\n\n/** The lifecycle commands an aggregate may list (decision D113). */\nexport const LifecycleCommands = {\n DELETE_AGGREGATE: 'wow.lifecycle.DeleteAggregate',\n RESTORE_AGGREGATE: 'wow.lifecycle.RestoreAggregate',\n TRANSFER_OWNER: 'wow.lifecycle.TransferOwner',\n TRANSFER_SPACE: 'wow.lifecycle.TransferSpace',\n APPLY_TAGS: 'wow.lifecycle.ApplyTags',\n} as const;\n\n/** A {@link LifecycleCommands} value. */\nexport type LifecycleCommand =\n (typeof LifecycleCommands)[keyof typeof LifecycleCommands];\n\n/** The body of `wow.lifecycle.TransferOwner`. */\nexport interface TransferOwner {\n readonly ownerId: string;\n}\n\n/** The body of `wow.lifecycle.TransferSpace`. */\nexport interface TransferSpace {\n readonly spaceId: string;\n}\n\n/** The body of `wow.lifecycle.ApplyTags`: the tags, names to values. */\nexport interface ApplyTags {\n readonly tags: Readonly<Record<string, readonly string[]>>;\n}\n\n/**\n * The route segment of a command name, as the server derives it: kebab case,\n * dots kept (`AddCartItem` → `add-cart-item`,\n * `wow.lifecycle.RestoreAggregate` → `wow.lifecycle.restore-aggregate`).\n *\n * @param name - The command's name\n */\nexport function commandSegment(name: string): string {\n return name\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[_\\s]+/g, '-')\n .toLowerCase();\n}\n\nfunction commandHeaders(\n options: CommandOptions,\n accept?: string,\n): Record<string, string | undefined> {\n const wait = options.wait;\n return {\n [WowV10Headers.REQUEST_ID]: options.requestId,\n [WowV10Headers.WAIT]:\n wait?.plan === undefined ? undefined : formatWaitPlan(wait.plan),\n [WowV10Headers.WAIT_TIMEOUT]:\n wait?.timeout === undefined ? undefined : formatWaitTimeout(wait.timeout),\n [WowV10Headers.IF_MATCH]:\n options.expectedVersion === undefined\n ? undefined\n : `\"${options.expectedVersion}\"`,\n Accept: accept,\n };\n}\n\n/**\n * Sends commands to the command routes of a Wow V10 service\n * (`POST /{context}/{aggregate}/{id}/{command}`, and without `{id}` for a\n * command that may create its aggregate). Generated aggregate clients build\n * on it; it serves any route too.\n *\n * A command that did not succeed rejects with a {@link WowProblemError}\n * holding its result, unless the options resolve it.\n */\nexport class CommandGateway {\n /** @param client - How the service is reached */\n constructor(readonly client: WowClientOptions = {}) {}\n\n /**\n * Sends a command and answers the result its wait ends with: 200, or 202\n * for a plan that ends at `accepted`.\n *\n * @param path - The route, `{id}` filled from `id`\n * @param body - The command's body; `{}` when absent\n * @param options - Headers, wait and the aggregate id\n */\n async send<R = Record<string, unknown>>(\n path: string,\n body?: object,\n options: CreateCommandOptions = {},\n ): Promise<CommandResult<R>> {\n try {\n const response = await this.post(path, body, options);\n return await json<CommandResult<R>>(response);\n } catch (error) {\n if (\n options.resolveRejected &&\n error instanceof WowProblemError &&\n error.result !== undefined\n ) {\n return error.result as CommandResult<R>;\n }\n throw error;\n }\n }\n\n /**\n * Sends a command with `Accept: text/event-stream` and answers one result\n * per hop as the wait advances. An admission refusal rejects with its\n * problem; a rejection after admission is the stream's last result.\n *\n * @param path - The route, `{id}` filled from `id`\n * @param body - The command's body; `{}` when absent\n * @param options - Headers, wait and the aggregate id\n */\n async stream<R = Record<string, unknown>>(\n path: string,\n body?: object,\n options: CreateCommandOptions = {},\n ): Promise<CommandResultStream<R>> {\n return commandResults<R>(\n await this.post(path, body, options, 'text/event-stream'),\n );\n }\n\n /**\n * Sends a lifecycle command an aggregate lists: `DELETE\n * /{context}/{aggregate}/{id}` for `DeleteAggregate`, `POST\n * …/{id}/wow.lifecycle.<kebab>` for the others.\n *\n * @param aggregatePath - `/{context}/{aggregate}`\n * @param id - The aggregate's id\n * @param command - The lifecycle command\n * @param body - Its body, for the commands that have one\n * @param options - Headers and wait\n */\n async lifecycle<R = Record<string, unknown>>(\n aggregatePath: string,\n id: string,\n command: LifecycleCommand,\n body?: TransferOwner | TransferSpace | ApplyTags,\n options: CommandOptions = {},\n ): Promise<CommandResult<R>> {\n const base = `${aggregatePath}/${encodeURIComponent(id)}`;\n if (command === LifecycleCommands.DELETE_AGGREGATE) {\n const response = await send(this.client, {\n method: 'DELETE',\n path: base,\n headers: commandHeaders(options),\n options,\n });\n return json<CommandResult<R>>(response);\n }\n return this.send<R>(\n `${base}/${commandSegment(command)}`,\n body ?? {},\n options,\n );\n }\n\n private post(\n path: string,\n body: object | undefined,\n options: CreateCommandOptions,\n accept?: string,\n ): Promise<Response> {\n return send(this.client, {\n method: 'POST',\n path: path.includes('{id}')\n ? expandPath(path, { id: options.id ?? '' })\n : path,\n headers: commandHeaders(options, accept),\n body: body ?? {},\n options,\n });\n }\n}\n"],"mappings":"4GAsDA,IAAaY,EAAoB,CAC/B,iBAAkB,gCAClB,kBAAmB,iCACnB,eAAgB,8BAChB,eAAgB,8BAChB,WAAY,yBACd,EA4BA,SAAgBC,EAAe,EAAsB,CACnD,OAAOC,EACJ,QAAQ,wBAAyB,OAAO,CAAC,CACzC,QAAQ,qBAAsB,OAAO,CAAC,CACtC,QAAQ,UAAW,GAAG,CAAC,CACvB,YAAY,CACjB,CAEA,SAASC,EACP,EACA,EACoC,CACpC,IAAMC,EAAOC,EAAQ,KACrB,MAAO,EACJjB,EAAAA,cAAc,YAAaiB,EAAQ,WACnCjB,EAAAA,cAAc,MACbgB,GAAM,OAAS,IAAA,GAAY,IAAA,GAAYf,EAAAA,eAAee,EAAK,IAAI,GAChEhB,EAAAA,cAAc,cACbgB,GAAM,UAAY,IAAA,GAAY,IAAA,GAAYd,EAAAA,kBAAkBc,EAAK,OAAO,GACzEhB,EAAAA,cAAc,UACbiB,EAAQ,kBAAoB,IAAA,GACxB,IAAA,GACA,IAAIA,EAAQ,gBAAgB,GAClC,OAAQC,CACV,CACF,CAWA,IAAaC,EAAb,KAA4B,CAE1B,YAAY,EAAoC,CAAC,EAAG,CAA/B,KAAA,OAAAC,CAAgC,CAUrD,MAAM,KACJ,EACA,EACA,EAAgC,CAAC,EACN,CAC3B,GAAI,CACF,IAAMC,EAAW,MAAM,KAAK,KAAKC,EAAMC,EAAMN,CAAO,EACpD,OAAO,MAAMd,EAAAA,KAAuBkB,CAAQ,CAC9C,OAASG,EAAO,CACd,GACEP,EAAQ,iBACRO,aAAiBpB,EAAAA,iBACjBoB,EAAM,SAAW,IAAA,GAEjB,OAAOA,EAAM,OAEf,MAAMA,CACR,CACF,CAWA,MAAM,OACJ,EACA,EACA,EAAgC,CAAC,EACA,CACjC,OAAOnB,EAAAA,eACL,MAAM,KAAK,KAAKiB,EAAMC,EAAMN,EAAS,mBAAmB,CAC1D,CACF,CAaA,MAAM,UACJ,EACA,EACA,EACA,EACA,EAA0B,CAAC,EACA,CAC3B,IAAMQ,EAAO,GAAGC,EAAc,GAAG,mBAAmBC,CAAE,IACtD,GAAIC,IAAYhB,EAAkB,iBAAkB,CAClD,IAAMS,EAAW,MAAMf,EAAAA,KAAK,KAAK,OAAQ,CACvC,OAAQ,SACR,KAAMmB,EACN,QAASV,EAAeE,CAAO,EAC/B,SACF,CAAC,EACD,OAAOd,EAAAA,KAAuBkB,CAAQ,CACxC,CACA,OAAO,KAAK,KACV,GAAGI,EAAK,GAAGZ,EAAee,CAAO,IACjCL,GAAQ,CAAC,EACTN,CACF,CACF,CAEA,KACE,EACA,EACA,EACA,EACmB,CACnB,OAAOX,EAAAA,KAAK,KAAK,OAAQ,CACvB,OAAQ,OACR,KAAMgB,EAAK,SAAS,MAAM,EACtBf,EAAAA,WAAWe,EAAM,CAAE,GAAIL,EAAQ,IAAM,EAAG,CAAC,EACzCK,EACJ,QAASP,EAAeE,EAASC,CAAM,EACvC,KAAMK,GAAQ,CAAC,EACf,SACF,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RequestOptions, WowClientOptions } from './http.cjs';
|
|
2
|
+
import { CommandResult } from './wire.cjs';
|
|
3
|
+
import { CommandResultStream } from './streams.cjs';
|
|
4
|
+
import { WaitOptions } from './wait.cjs';
|
|
5
|
+
/** What a command request carries beside its body (decisions D95–D99). */
|
|
6
|
+
export interface CommandOptions extends RequestOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The request id (`Wow-Request-Id`): a retry with the same one is
|
|
9
|
+
* deduplicated, answered as the first commit's duplicate.
|
|
10
|
+
*/
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
/** What to wait for, and for how long. */
|
|
13
|
+
readonly wait?: WaitOptions;
|
|
14
|
+
/** The version the aggregate must be at (`If-Match`). */
|
|
15
|
+
readonly expectedVersion?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a result that did not succeed instead of rejecting with its
|
|
18
|
+
* {@link WowProblemError}; `false` by default.
|
|
19
|
+
*/
|
|
20
|
+
readonly resolveRejected?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** The options of a command whose route may name the aggregate id or not. */
|
|
23
|
+
export interface CreateCommandOptions extends CommandOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The id of the aggregate to create (decision D176); the service generates
|
|
26
|
+
* one when absent.
|
|
27
|
+
*/
|
|
28
|
+
readonly id?: string;
|
|
29
|
+
}
|
|
30
|
+
/** The lifecycle commands an aggregate may list (decision D113). */
|
|
31
|
+
export declare const LifecycleCommands: {
|
|
32
|
+
readonly DELETE_AGGREGATE: "wow.lifecycle.DeleteAggregate";
|
|
33
|
+
readonly RESTORE_AGGREGATE: "wow.lifecycle.RestoreAggregate";
|
|
34
|
+
readonly TRANSFER_OWNER: "wow.lifecycle.TransferOwner";
|
|
35
|
+
readonly TRANSFER_SPACE: "wow.lifecycle.TransferSpace";
|
|
36
|
+
readonly APPLY_TAGS: "wow.lifecycle.ApplyTags";
|
|
37
|
+
};
|
|
38
|
+
/** A {@link LifecycleCommands} value. */
|
|
39
|
+
export type LifecycleCommand = (typeof LifecycleCommands)[keyof typeof LifecycleCommands];
|
|
40
|
+
/** The body of `wow.lifecycle.TransferOwner`. */
|
|
41
|
+
export interface TransferOwner {
|
|
42
|
+
readonly ownerId: string;
|
|
43
|
+
}
|
|
44
|
+
/** The body of `wow.lifecycle.TransferSpace`. */
|
|
45
|
+
export interface TransferSpace {
|
|
46
|
+
readonly spaceId: string;
|
|
47
|
+
}
|
|
48
|
+
/** The body of `wow.lifecycle.ApplyTags`: the tags, names to values. */
|
|
49
|
+
export interface ApplyTags {
|
|
50
|
+
readonly tags: Readonly<Record<string, readonly string[]>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The route segment of a command name, as the server derives it: kebab case,
|
|
54
|
+
* dots kept (`AddCartItem` → `add-cart-item`,
|
|
55
|
+
* `wow.lifecycle.RestoreAggregate` → `wow.lifecycle.restore-aggregate`).
|
|
56
|
+
*
|
|
57
|
+
* @param name - The command's name
|
|
58
|
+
*/
|
|
59
|
+
export declare function commandSegment(name: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Sends commands to the command routes of a Wow V10 service
|
|
62
|
+
* (`POST /{context}/{aggregate}/{id}/{command}`, and without `{id}` for a
|
|
63
|
+
* command that may create its aggregate). Generated aggregate clients build
|
|
64
|
+
* on it; it serves any route too.
|
|
65
|
+
*
|
|
66
|
+
* A command that did not succeed rejects with a {@link WowProblemError}
|
|
67
|
+
* holding its result, unless the options resolve it.
|
|
68
|
+
*/
|
|
69
|
+
export declare class CommandGateway {
|
|
70
|
+
readonly client: WowClientOptions;
|
|
71
|
+
/** @param client - How the service is reached */
|
|
72
|
+
constructor(client?: WowClientOptions);
|
|
73
|
+
/**
|
|
74
|
+
* Sends a command and answers the result its wait ends with: 200, or 202
|
|
75
|
+
* for a plan that ends at `accepted`.
|
|
76
|
+
*
|
|
77
|
+
* @param path - The route, `{id}` filled from `id`
|
|
78
|
+
* @param body - The command's body; `{}` when absent
|
|
79
|
+
* @param options - Headers, wait and the aggregate id
|
|
80
|
+
*/
|
|
81
|
+
send<R = Record<string, unknown>>(path: string, body?: object, options?: CreateCommandOptions): Promise<CommandResult<R>>;
|
|
82
|
+
/**
|
|
83
|
+
* Sends a command with `Accept: text/event-stream` and answers one result
|
|
84
|
+
* per hop as the wait advances. An admission refusal rejects with its
|
|
85
|
+
* problem; a rejection after admission is the stream's last result.
|
|
86
|
+
*
|
|
87
|
+
* @param path - The route, `{id}` filled from `id`
|
|
88
|
+
* @param body - The command's body; `{}` when absent
|
|
89
|
+
* @param options - Headers, wait and the aggregate id
|
|
90
|
+
*/
|
|
91
|
+
stream<R = Record<string, unknown>>(path: string, body?: object, options?: CreateCommandOptions): Promise<CommandResultStream<R>>;
|
|
92
|
+
/**
|
|
93
|
+
* Sends a lifecycle command an aggregate lists: `DELETE
|
|
94
|
+
* /{context}/{aggregate}/{id}` for `DeleteAggregate`, `POST
|
|
95
|
+
* …/{id}/wow.lifecycle.<kebab>` for the others.
|
|
96
|
+
*
|
|
97
|
+
* @param aggregatePath - `/{context}/{aggregate}`
|
|
98
|
+
* @param id - The aggregate's id
|
|
99
|
+
* @param command - The lifecycle command
|
|
100
|
+
* @param body - Its body, for the commands that have one
|
|
101
|
+
* @param options - Headers and wait
|
|
102
|
+
*/
|
|
103
|
+
lifecycle<R = Record<string, unknown>>(aggregatePath: string, id: string, command: LifecycleCommand, body?: TransferOwner | TransferSpace | ApplyTags, options?: CommandOptions): Promise<CommandResult<R>>;
|
|
104
|
+
private post;
|
|
105
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { RequestOptions, WowClientOptions } from './http.js';
|
|
2
|
+
import { CommandResult } from './wire.js';
|
|
3
|
+
import { CommandResultStream } from './streams.js';
|
|
4
|
+
import { WaitOptions } from './wait.js';
|
|
5
|
+
/** What a command request carries beside its body (decisions D95–D99). */
|
|
6
|
+
export interface CommandOptions extends RequestOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The request id (`Wow-Request-Id`): a retry with the same one is
|
|
9
|
+
* deduplicated, answered as the first commit's duplicate.
|
|
10
|
+
*/
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
/** What to wait for, and for how long. */
|
|
13
|
+
readonly wait?: WaitOptions;
|
|
14
|
+
/** The version the aggregate must be at (`If-Match`). */
|
|
15
|
+
readonly expectedVersion?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a result that did not succeed instead of rejecting with its
|
|
18
|
+
* {@link WowProblemError}; `false` by default.
|
|
19
|
+
*/
|
|
20
|
+
readonly resolveRejected?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** The options of a command whose route may name the aggregate id or not. */
|
|
23
|
+
export interface CreateCommandOptions extends CommandOptions {
|
|
24
|
+
/**
|
|
25
|
+
* The id of the aggregate to create (decision D176); the service generates
|
|
26
|
+
* one when absent.
|
|
27
|
+
*/
|
|
28
|
+
readonly id?: string;
|
|
29
|
+
}
|
|
30
|
+
/** The lifecycle commands an aggregate may list (decision D113). */
|
|
31
|
+
export declare const LifecycleCommands: {
|
|
32
|
+
readonly DELETE_AGGREGATE: "wow.lifecycle.DeleteAggregate";
|
|
33
|
+
readonly RESTORE_AGGREGATE: "wow.lifecycle.RestoreAggregate";
|
|
34
|
+
readonly TRANSFER_OWNER: "wow.lifecycle.TransferOwner";
|
|
35
|
+
readonly TRANSFER_SPACE: "wow.lifecycle.TransferSpace";
|
|
36
|
+
readonly APPLY_TAGS: "wow.lifecycle.ApplyTags";
|
|
37
|
+
};
|
|
38
|
+
/** A {@link LifecycleCommands} value. */
|
|
39
|
+
export type LifecycleCommand = (typeof LifecycleCommands)[keyof typeof LifecycleCommands];
|
|
40
|
+
/** The body of `wow.lifecycle.TransferOwner`. */
|
|
41
|
+
export interface TransferOwner {
|
|
42
|
+
readonly ownerId: string;
|
|
43
|
+
}
|
|
44
|
+
/** The body of `wow.lifecycle.TransferSpace`. */
|
|
45
|
+
export interface TransferSpace {
|
|
46
|
+
readonly spaceId: string;
|
|
47
|
+
}
|
|
48
|
+
/** The body of `wow.lifecycle.ApplyTags`: the tags, names to values. */
|
|
49
|
+
export interface ApplyTags {
|
|
50
|
+
readonly tags: Readonly<Record<string, readonly string[]>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The route segment of a command name, as the server derives it: kebab case,
|
|
54
|
+
* dots kept (`AddCartItem` → `add-cart-item`,
|
|
55
|
+
* `wow.lifecycle.RestoreAggregate` → `wow.lifecycle.restore-aggregate`).
|
|
56
|
+
*
|
|
57
|
+
* @param name - The command's name
|
|
58
|
+
*/
|
|
59
|
+
export declare function commandSegment(name: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Sends commands to the command routes of a Wow V10 service
|
|
62
|
+
* (`POST /{context}/{aggregate}/{id}/{command}`, and without `{id}` for a
|
|
63
|
+
* command that may create its aggregate). Generated aggregate clients build
|
|
64
|
+
* on it; it serves any route too.
|
|
65
|
+
*
|
|
66
|
+
* A command that did not succeed rejects with a {@link WowProblemError}
|
|
67
|
+
* holding its result, unless the options resolve it.
|
|
68
|
+
*/
|
|
69
|
+
export declare class CommandGateway {
|
|
70
|
+
readonly client: WowClientOptions;
|
|
71
|
+
/** @param client - How the service is reached */
|
|
72
|
+
constructor(client?: WowClientOptions);
|
|
73
|
+
/**
|
|
74
|
+
* Sends a command and answers the result its wait ends with: 200, or 202
|
|
75
|
+
* for a plan that ends at `accepted`.
|
|
76
|
+
*
|
|
77
|
+
* @param path - The route, `{id}` filled from `id`
|
|
78
|
+
* @param body - The command's body; `{}` when absent
|
|
79
|
+
* @param options - Headers, wait and the aggregate id
|
|
80
|
+
*/
|
|
81
|
+
send<R = Record<string, unknown>>(path: string, body?: object, options?: CreateCommandOptions): Promise<CommandResult<R>>;
|
|
82
|
+
/**
|
|
83
|
+
* Sends a command with `Accept: text/event-stream` and answers one result
|
|
84
|
+
* per hop as the wait advances. An admission refusal rejects with its
|
|
85
|
+
* problem; a rejection after admission is the stream's last result.
|
|
86
|
+
*
|
|
87
|
+
* @param path - The route, `{id}` filled from `id`
|
|
88
|
+
* @param body - The command's body; `{}` when absent
|
|
89
|
+
* @param options - Headers, wait and the aggregate id
|
|
90
|
+
*/
|
|
91
|
+
stream<R = Record<string, unknown>>(path: string, body?: object, options?: CreateCommandOptions): Promise<CommandResultStream<R>>;
|
|
92
|
+
/**
|
|
93
|
+
* Sends a lifecycle command an aggregate lists: `DELETE
|
|
94
|
+
* /{context}/{aggregate}/{id}` for `DeleteAggregate`, `POST
|
|
95
|
+
* …/{id}/wow.lifecycle.<kebab>` for the others.
|
|
96
|
+
*
|
|
97
|
+
* @param aggregatePath - `/{context}/{aggregate}`
|
|
98
|
+
* @param id - The aggregate's id
|
|
99
|
+
* @param command - The lifecycle command
|
|
100
|
+
* @param body - Its body, for the commands that have one
|
|
101
|
+
* @param options - Headers and wait
|
|
102
|
+
*/
|
|
103
|
+
lifecycle<R = Record<string, unknown>>(aggregatePath: string, id: string, command: LifecycleCommand, body?: TransferOwner | TransferSpace | ApplyTags, options?: CommandOptions): Promise<CommandResult<R>>;
|
|
104
|
+
private post;
|
|
105
|
+
}
|