@ahoo-wang/wow-client 10.0.0-alpha.7 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/README.zh-CN.md +3 -2
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +8 -5
- package/dist/commands.d.ts +8 -5
- package/dist/commands.es.js +33 -21
- package/dist/commands.es.js.map +1 -1
- package/dist/dsl/descriptor.cjs +1 -1
- package/dist/dsl/descriptor.cjs.map +1 -1
- package/dist/dsl/descriptor.d.cts +7 -0
- package/dist/dsl/descriptor.d.ts +7 -0
- package/dist/dsl/descriptor.es.js +2 -1
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/frameworkErrors.cjs.map +1 -1
- package/dist/frameworkErrors.d.cts +1 -1
- package/dist/frameworkErrors.d.ts +1 -1
- package/dist/frameworkErrors.es.js.map +1 -1
- package/dist/manifest.cjs.map +1 -1
- package/dist/manifest.d.cts +6 -2
- package/dist/manifest.d.ts +6 -2
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +5 -3
- package/dist/manifestTypes.d.ts +5 -3
- package/dist/wait.cjs +1 -1
- package/dist/wait.cjs.map +1 -1
- package/dist/wait.d.cts +1 -1
- package/dist/wait.d.ts +1 -1
- package/dist/wait.es.js +2 -2
- package/dist/wait.es.js.map +1 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +2 -1
- package/dist/wire.d.ts +2 -1
- package/dist/wire.es.js.map +1 -1
- package/package.json +1 -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","QuerySemanticTypes","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 * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * 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: 'events',\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 `stream`: 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/**\n * The semantics Wow names in a field's `semantic.type`, one per member of\n * {@link QuerySemanticType}: read a descriptor's semantic by these rather\n * than by its spelling.\n */\nexport const QuerySemanticTypes = Object.freeze({\n /** A calendar date: {@link TemporalDate}. */\n TEMPORAL_DATE: 'temporal-date',\n /** A number of time units since the epoch: {@link TemporalEpoch}. */\n TEMPORAL_EPOCH: 'temporal-epoch',\n /** A time written as text in a pattern: {@link TemporalFormatted}. */\n TEMPORAL_FORMATTED: 'temporal-formatted',\n /** A fixed-point decimal: {@link NumericDecimal}. */\n DECIMAL: 'decimal',\n /** An amount of money: {@link NumericMoney}. */\n MONEY: 'money',\n /** A length of time: {@link DurationSemantic}. */\n DURATION: 'duration',\n /** The id of an aggregate: {@link ReferenceSemantic}. */\n REFERENCE: 'reference',\n} as const);\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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 * Whether an index backs the sort, as the storage says: `false` marks a\n * sort it runs without one, which may be slow on a large model; absent\n * when the storage does not say.\n */\n indexed?: 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 /** Whether their values may be `null`, as a field's `nullable` says. */\n nullable: boolean;\n /**\n * What their values mean beyond their type, as a field's `semantic`\n * says; absent when nothing more.\n */\n semantic?: QuerySemanticType;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /** Where a concrete key may be sorted by. */\n sort: FieldSortDescriptor;\n /** How a concrete key may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\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 zone a request that names none is read in: UTC (review R4-Q, Q-10). */\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":"AAmDA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,SAEd,QAAS,SACX,CAAU,EAUGC,EAAkB,OAAO,OAAO,CAE3C,OAAQ,SAER,QAAS,UAET,QAAS,UAET,QAAS,UAET,OAAQ,QACV,CAAU,EAOEC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,OAEA,EAAAC,OAAA,SAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,MAAA,Q,CACF,EAAA,CAAA,CAAA,EAGYC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,S,CACF,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,EAYGC,EAAqB,OAAO,OAAO,CAE9C,cAAe,gBAEf,eAAgB,iBAEhB,mBAAoB,qBAEpB,QAAS,UAET,MAAO,QAEP,SAAU,WAEV,UAAW,WACb,CAAU,EAiJEC,EAAL,SAAA,EAAA,C,MAML,GAAAC,QAAA,UAKA,EAAAC,aAAA,e,CACF,EAAA,CAAA,CAAA,E"}
|
|
1
|
+
{"version":3,"file":"descriptor.cjs","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","QuerySemanticTypes","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 * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * 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: 'events',\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 `stream`: 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 /**\n * The queries of an events model must name their aggregates: the\n * constraint's `fields` are the one field to name them by, `aggregateId`.\n * The service lists it where events are visible only per aggregate, and\n * refuses a query that names none.\n */\n AGGREGATE_REQUIRED: 'aggregate-required',\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/**\n * The semantics Wow names in a field's `semantic.type`, one per member of\n * {@link QuerySemanticType}: read a descriptor's semantic by these rather\n * than by its spelling.\n */\nexport const QuerySemanticTypes = Object.freeze({\n /** A calendar date: {@link TemporalDate}. */\n TEMPORAL_DATE: 'temporal-date',\n /** A number of time units since the epoch: {@link TemporalEpoch}. */\n TEMPORAL_EPOCH: 'temporal-epoch',\n /** A time written as text in a pattern: {@link TemporalFormatted}. */\n TEMPORAL_FORMATTED: 'temporal-formatted',\n /** A fixed-point decimal: {@link NumericDecimal}. */\n DECIMAL: 'decimal',\n /** An amount of money: {@link NumericMoney}. */\n MONEY: 'money',\n /** A length of time: {@link DurationSemantic}. */\n DURATION: 'duration',\n /** The id of an aggregate: {@link ReferenceSemantic}. */\n REFERENCE: 'reference',\n} as const);\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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 * Whether an index backs the sort, as the storage says: `false` marks a\n * sort it runs without one, which may be slow on a large model; absent\n * when the storage does not say.\n */\n indexed?: 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 /** Whether their values may be `null`, as a field's `nullable` says. */\n nullable: boolean;\n /**\n * What their values mean beyond their type, as a field's `semantic`\n * says; absent when nothing more.\n */\n semantic?: QuerySemanticType;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /** Where a concrete key may be sorted by. */\n sort: FieldSortDescriptor;\n /** How a concrete key may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\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 zone a request that names none is read in: UTC (review R4-Q, Q-10). */\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":"AAmDA,IAAaA,EAAc,OAAO,OAAO,CAEvC,SAAU,WAEV,aAAc,SAEd,QAAS,SACX,CAAU,EAUGC,EAAkB,OAAO,OAAO,CAE3C,OAAQ,SAER,QAAS,UAET,QAAS,UAET,QAAS,UAET,OAAQ,QACV,CAAU,EAOEC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,QAAA,UAEA,EAAAC,KAAA,OAEA,EAAAC,OAAA,SAEA,EAAAC,OAAA,SAEA,EAAAC,MAAA,QAEA,EAAAC,MAAA,Q,CACF,EAAA,CAAA,CAAA,EAGYC,EAAL,SAAA,EAAA,C,MAEL,GAAAC,KAAA,OAEA,EAAAC,MAAA,QAEA,EAAAC,OAAA,S,CACF,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,iBAOhB,mBAAoB,oBACtB,CAAU,EAYGC,EAAqB,OAAO,OAAO,CAE9C,cAAe,gBAEf,eAAgB,iBAEhB,mBAAoB,qBAEpB,QAAS,UAET,MAAO,QAEP,SAAU,WAEV,UAAW,WACb,CAAU,EAiJEC,EAAL,SAAA,EAAA,C,MAML,GAAAC,QAAA,UAKA,EAAAC,aAAA,e,CACF,EAAA,CAAA,CAAA,E"}
|
|
@@ -138,6 +138,13 @@ export declare const QueryConstraintTypes: Readonly<{
|
|
|
138
138
|
* `NE` with an array operand is refused with `ARRAY_EQUALITY`.
|
|
139
139
|
*/
|
|
140
140
|
readonly ARRAY_EQUALITY: "array-equality";
|
|
141
|
+
/**
|
|
142
|
+
* The queries of an events model must name their aggregates: the
|
|
143
|
+
* constraint's `fields` are the one field to name them by, `aggregateId`.
|
|
144
|
+
* The service lists it where events are visible only per aggregate, and
|
|
145
|
+
* refuses a query that names none.
|
|
146
|
+
*/
|
|
147
|
+
readonly AGGREGATE_REQUIRED: "aggregate-required";
|
|
141
148
|
}>;
|
|
142
149
|
/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */
|
|
143
150
|
export type QueryConstraintType = (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes] | (string & {});
|
package/dist/dsl/descriptor.d.ts
CHANGED
|
@@ -138,6 +138,13 @@ export declare const QueryConstraintTypes: Readonly<{
|
|
|
138
138
|
* `NE` with an array operand is refused with `ARRAY_EQUALITY`.
|
|
139
139
|
*/
|
|
140
140
|
readonly ARRAY_EQUALITY: "array-equality";
|
|
141
|
+
/**
|
|
142
|
+
* The queries of an events model must name their aggregates: the
|
|
143
|
+
* constraint's `fields` are the one field to name them by, `aggregateId`.
|
|
144
|
+
* The service lists it where events are visible only per aggregate, and
|
|
145
|
+
* refuses a query that names none.
|
|
146
|
+
*/
|
|
147
|
+
readonly AGGREGATE_REQUIRED: "aggregate-required";
|
|
141
148
|
}>;
|
|
142
149
|
/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */
|
|
143
150
|
export type QueryConstraintType = (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes] | (string & {});
|
|
@@ -28,7 +28,8 @@ var e = Object.freeze({
|
|
|
28
28
|
STARTS_WITH_REQUIRES_PREFIX: "starts-with-requires-prefix",
|
|
29
29
|
PARALLEL_ARRAY_SORT: "parallel-array-sort",
|
|
30
30
|
NULL_OR_EMPTY_AS_MISSING: "null-or-empty-as-missing",
|
|
31
|
-
ARRAY_EQUALITY: "array-equality"
|
|
31
|
+
ARRAY_EQUALITY: "array-equality",
|
|
32
|
+
AGGREGATE_REQUIRED: "aggregate-required"
|
|
32
33
|
}), o = Object.freeze({
|
|
33
34
|
TEMPORAL_DATE: "temporal-date",
|
|
34
35
|
TEMPORAL_EPOCH: "temporal-epoch",
|
|
@@ -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","QuerySemanticTypes","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 * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * 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: 'events',\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 `stream`: 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/**\n * The semantics Wow names in a field's `semantic.type`, one per member of\n * {@link QuerySemanticType}: read a descriptor's semantic by these rather\n * than by its spelling.\n */\nexport const QuerySemanticTypes = Object.freeze({\n /** A calendar date: {@link TemporalDate}. */\n TEMPORAL_DATE: 'temporal-date',\n /** A number of time units since the epoch: {@link TemporalEpoch}. */\n TEMPORAL_EPOCH: 'temporal-epoch',\n /** A time written as text in a pattern: {@link TemporalFormatted}. */\n TEMPORAL_FORMATTED: 'temporal-formatted',\n /** A fixed-point decimal: {@link NumericDecimal}. */\n DECIMAL: 'decimal',\n /** An amount of money: {@link NumericMoney}. */\n MONEY: 'money',\n /** A length of time: {@link DurationSemantic}. */\n DURATION: 'duration',\n /** The id of an aggregate: {@link ReferenceSemantic}. */\n REFERENCE: 'reference',\n} as const);\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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 * Whether an index backs the sort, as the storage says: `false` marks a\n * sort it runs without one, which may be slow on a large model; absent\n * when the storage does not say.\n */\n indexed?: 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 /** Whether their values may be `null`, as a field's `nullable` says. */\n nullable: boolean;\n /**\n * What their values mean beyond their type, as a field's `semantic`\n * says; absent when nothing more.\n */\n semantic?: QuerySemanticType;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /** Where a concrete key may be sorted by. */\n sort: FieldSortDescriptor;\n /** How a concrete key may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\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 zone a request that names none is read in: UTC (review R4-Q, Q-10). */\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":";AAmDA,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;C,OAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,QAEA,EAAAC,SAAA,UAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,QAAA,S;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,OAAA,QAEA,EAAAC,QAAA,SAEA,EAAAC,SAAA,U;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,GAYGC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,gBAAgB;CAEhB,oBAAoB;CAEpB,SAAS;CAET,OAAO;CAEP,UAAU;CAEV,WAAW;AACb,CAAU,GAiJEC,IAAL,yBAAA,GAAA;C,OAML,EAAAC,UAAA,WAKA,EAAAC,eAAA,gB;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","QuerySemanticTypes","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 * A query model's capability descriptor and its version, the `ETag` of\n * `GET …/query`; `notModified` when the version given is still current.\n */\nexport type DescriptorResult =\n | {\n readonly notModified: false;\n readonly version?: string;\n readonly descriptor: QueryModelDescriptor;\n }\n | { readonly notModified: true; readonly version: string };\n\n/**\n * 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: 'events',\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 `stream`: 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 /**\n * The queries of an events model must name their aggregates: the\n * constraint's `fields` are the one field to name them by, `aggregateId`.\n * The service lists it where events are visible only per aggregate, and\n * refuses a query that names none.\n */\n AGGREGATE_REQUIRED: 'aggregate-required',\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/**\n * The semantics Wow names in a field's `semantic.type`, one per member of\n * {@link QuerySemanticType}: read a descriptor's semantic by these rather\n * than by its spelling.\n */\nexport const QuerySemanticTypes = Object.freeze({\n /** A calendar date: {@link TemporalDate}. */\n TEMPORAL_DATE: 'temporal-date',\n /** A number of time units since the epoch: {@link TemporalEpoch}. */\n TEMPORAL_EPOCH: 'temporal-epoch',\n /** A time written as text in a pattern: {@link TemporalFormatted}. */\n TEMPORAL_FORMATTED: 'temporal-formatted',\n /** A fixed-point decimal: {@link NumericDecimal}. */\n DECIMAL: 'decimal',\n /** An amount of money: {@link NumericMoney}. */\n MONEY: 'money',\n /** A length of time: {@link DurationSemantic}. */\n DURATION: 'duration',\n /** The id of an aggregate: {@link ReferenceSemantic}. */\n REFERENCE: 'reference',\n} as const);\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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: typeof QuerySemanticTypes.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 * Whether an index backs the sort, as the storage says: `false` marks a\n * sort it runs without one, which may be slow on a large model; absent\n * when the storage does not say.\n */\n indexed?: 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 /** Whether their values may be `null`, as a field's `nullable` says. */\n nullable: boolean;\n /**\n * What their values mean beyond their type, as a field's `semantic`\n * says; absent when nothing more.\n */\n semantic?: QuerySemanticType;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /** Where a concrete key may be sorted by. */\n sort: FieldSortDescriptor;\n /** How a concrete key may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\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 zone a request that names none is read in: UTC (review R4-Q, Q-10). */\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":";AAmDA,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;C,OAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,QAEA,EAAAC,SAAA,UAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,QAAA,S;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;C,OAEL,EAAAC,OAAA,QAEA,EAAAC,QAAA,SAEA,EAAAC,SAAA,U;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;CAOhB,oBAAoB;AACtB,CAAU,GAYGC,IAAqB,OAAO,OAAO;CAE9C,eAAe;CAEf,gBAAgB;CAEhB,oBAAoB;CAEpB,SAAS;CAET,OAAO;CAEP,UAAU;CAEV,WAAW;AACb,CAAU,GAiJEC,IAAL,yBAAA,GAAA;C,OAML,EAAAC,UAAA,WAKA,EAAAC,eAAA,gB;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameworkErrors.cjs","names":["FrameworkErrorCodes","FRAMEWORK_RETRIES","DEFAULT_RETRY"],"sources":["../src/frameworkErrors.ts"],"sourcesContent":["// Code generated by scripts/framework-errors.mjs from the error catalog\n// (FrameworkErrors of :manifest, api/manifest/src/test/resources/framework-errors.json).\n// DO NOT EDIT: change FrameworkErrors and run the script.\n\n/**\n * What a retry of a request answered with an error may do, as the error\n * catalog declares it for the error's code and every problem carries it\n * (`retry`): `none`, a retry fails alike; `same-request`, send it again\n * with the same request id (`Wow-Request-Id`), so a command that did commit\n * is answered as its duplicate; `new-request`, send it again as it is.\n */\nexport type Retry = 'none' | 'same-request' | 'new-request';\n\n/**\n * The framework's error codes, each answered with the status of the error\n * catalog. A domain rejection has a code of its own, answered with 422 unless\n * the service configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401 Unauthenticated: The request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403 Command forbidden: The caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403 Aggregate out of scope: The aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400 Malformed request: A request header or parameter does not parse, or names what Wow does not take. */\n REQUEST_MALFORMED: 'wow.request.malformed',\n /** 400 Malformed command: The command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400 Invalid command: The command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400 Invalid wait: The wait is not a chain the runtime can follow; the command was not run. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400 Command not handled: The aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404 Aggregate not found: The aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409 Aggregate exists: The aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409 Version mismatch: The aggregate is not at the expected version (412 when the request carried If-Match). */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409 Request id reused: The request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409 Command contended: Concurrent writers kept winning the version; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410 Aggregate deleted: The aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429 Command busy: The command was not taken: its aggregate has too many commands waiting, or the node too many in flight; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503 Command outcome unknown: Whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500 Command failed: The command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 409 Command refused: The aggregate's current state refuses the command (a check of its decide function); the message says why. */\n COMMAND_REFUSED: 'wow.command.refused',\n /** 500 Undeclared event: The command's handling produced an event its decide function or after hooks do not declare: a bug in the model, which the message names; it committed nothing. */\n COMMAND_UNDECLARED_EVENT: 'wow.command.undeclared-event',\n /** 503 Node closing: The node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503 Node on standby: The node is on standby until the cut-over: it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503 Storage unavailable: A store could not be reached or did not answer in time; retry later, a command with the same request id. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503 Schedule not due: A scheduled command arrived too long before its due time on this node's clock; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400 Invalid schedule job: The job command does not fit its job or instance: an unknown job, another scope, or an instance not enabled. */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */\n LEDGER_STALE: 'wow.ledger.stale',\n /** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until it resumes. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400 Malformed route request: A service route's parameter or body cannot be read as its type; the violation names the parameter. */\n ROUTE_MALFORMED: 'wow.route.malformed',\n /** 400 Malformed query: The query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400 Invalid query: The query failed admission; the problem lists the violations, each with its code (UNKNOWN_FIELD, ...). */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500 Query failed: The query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 404 No matching record: A single query matched no record: a query result, not a statement that an aggregate does not exist. */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404 Dataset not found: No dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /** 400 Too many groups: An aggregation that names no sort has more groups than its limit; add a sort for a top-N, or raise limit. */\n QUERY_TOO_MANY_GROUPS: 'wow.query.too-many-groups',\n /** 504 Query timed out: The query ran longer than its budget allows; narrow it rather than run it again. */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 409 Version not reached: The state read asked for a version the aggregate has not reached within the wait; the problem carries its current version: retry later. */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 429 Query busy: The query was not run: its store has as many queries running as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /** 409 Dataset unavailable: The dataset is served but cannot be queried now, for the reason the problem names (it needs revision). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403 Call forbidden: The calling service may not call this command: its wow.callers.<service>.commands do not list it. */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n /** 503 Peer unavailable: A client reached no node of the peer, or lost the connection before a query's answer; nothing was changed, so the request may be sent again. */\n PEER_UNAVAILABLE: 'wow.peer.unavailable',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** What a retry of a framework code may do, as the error catalog declares it. */\nexport interface FrameworkRetry {\n /** What a retry may do: never `none` here. */\n readonly retry: Retry;\n /** Its `Retry-After`, in milliseconds. */\n readonly retryAfterMs: number;\n}\n\n/**\n * What a retry may do of each framework code a retry may get past, by code;\n * a retry of every other code, a domain's among them, is `none`.\n */\nexport const FRAMEWORK_RETRIES: ReadonlyMap<string, FrameworkRetry> = new Map<\n string,\n FrameworkRetry\n>([\n ['wow.command.contended', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.busy', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.unknown', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.closing', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.standby', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.storage.unavailable', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.schedule.not-due', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.wait.timeout', { retry: 'same-request', retryAfterMs: 1000 }],\n [\n 'wow.query.min-version-not-reached',\n { retry: 'new-request', retryAfterMs: 1000 },\n ],\n ['wow.query.busy', { retry: 'new-request', retryAfterMs: 1000 }],\n ['wow.peer.unavailable', { retry: 'new-request', retryAfterMs: 1000 }],\n]);\n\n/**\n * How often, and after how long, a client sends a request again by default\n * when a retry may get past its error, as the Kotlin client does\n * (`RetryPolicy.DEFAULT`): at most `attempts` attempts, the first included,\n * `backoffMs` before the first retry without a `Retry-After`, doubled at each\n * attempt up to `maxWaitMs`.\n */\nexport const DEFAULT_RETRY = {\n attempts: 5,\n backoffMs: 200,\n maxWaitMs: 5000,\n} as const;\n"],"mappings":"AAkBA,IAAaA,EAAsB,CAEjC,qBAAsB,2BAEtB,eAAgB,qBAEhB,oBAAqB,0BAErB,kBAAmB,wBAEnB,kBAAmB,wBAEnB,gBAAiB,sBAEjB,aAAc,mBAEd,kBAAmB,wBAEnB,oBAAqB,0BAErB,iBAAkB,uBAElB,2BAA4B,iCAE5B,0BAA2B,gCAE3B,kBAAmB,wBAEnB,kBAAmB,wBAEnB,aAAc,mBAEd,gBAAiB,sBAEjB,eAAgB,qBAEhB,gBAAiB,sBAEjB,yBAA0B,+BAE1B,aAAc,mBAEd,aAAc,mBAEd,oBAAqB,0BAErB,iBAAkB,uBAElB,qBAAsB,2BAEtB,aAAc,mBAEd,oBAAqB,0BAErB,aAAc,mBAEd,gBAAiB,sBAEjB,gBAAiB,sBAEjB,cAAe,oBAEf,aAAc,mBAEd,gBAAiB,sBAEjB,wBAAyB,8BAEzB,sBAAuB,4BAEvB,cAAe,oBAEf,8BAA+B,oCAE/B,WAAY,iBAEZ,0BAA2B,gCAE3B,uBAAwB,6BAExB,iBAAkB,sBACpB,EAkBaC,EAAyD,IAAI,IAGxE,CACA,CAAC,wBAAyB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACvE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,sBAAuB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACrE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,0BAA2B,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACzE,CAAC,uBAAwB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACtE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CACE,oCACA,CAAE,MAAO,cAAe,aAAc,GAAK,CAC7C,EACA,CAAC,iBAAkB,CAAE,MAAO,cAAe,aAAc,GAAK,CAAC,EAC/D,CAAC,uBAAwB,CAAE,MAAO,cAAe,aAAc,GAAK,CAAC,CACvE,CAAC,EASYC,EAAgB,CAC3B,SAAU,EACV,UAAW,IACX,UAAW,GACb,E"}
|
|
1
|
+
{"version":3,"file":"frameworkErrors.cjs","names":["FrameworkErrorCodes","FRAMEWORK_RETRIES","DEFAULT_RETRY"],"sources":["../src/frameworkErrors.ts"],"sourcesContent":["// Code generated by scripts/framework-errors.mjs from the error catalog\n// (FrameworkErrors of :manifest, api/manifest/src/test/resources/framework-errors.json).\n// DO NOT EDIT: change FrameworkErrors and run the script.\n\n/**\n * What a retry of a request answered with an error may do, as the error\n * catalog declares it for the error's code and every problem carries it\n * (`retry`): `none`, a retry fails alike; `same-request`, send it again\n * with the same request id (`Wow-Request-Id`), so a command that did commit\n * is answered as its duplicate; `new-request`, send it again as it is.\n */\nexport type Retry = 'none' | 'same-request' | 'new-request';\n\n/**\n * The framework's error codes, each answered with the status of the error\n * catalog. A domain rejection has a code of its own, answered with 422 unless\n * the service configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401 Unauthenticated: The request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403 Command forbidden: The caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403 Aggregate out of scope: The aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400 Malformed request: A request header or parameter does not parse, or names what Wow does not take. */\n REQUEST_MALFORMED: 'wow.request.malformed',\n /** 400 Malformed command: The command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400 Invalid command: The command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400 Invalid wait: The wait is not a chain the runtime can follow; the command was not run. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400 Command not handled: The aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404 Aggregate not found: The aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409 Aggregate exists: The aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409 Version mismatch: The aggregate is not at the expected version (412 when the request carried If-Match). */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409 Request id reused: The request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409 Command contended: Concurrent writers kept winning the version; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410 Aggregate deleted: The aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429 Command busy: The command was not taken: its aggregate has too many commands waiting, or the node too many in flight; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503 Command outcome unknown: Whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500 Command failed: The command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 409 Command refused: The aggregate's current state refuses the command (a check of its decide function); the message says why. */\n COMMAND_REFUSED: 'wow.command.refused',\n /** 500 Undeclared event: The command's handling produced an event its decide function or after hooks do not declare: a bug in the model, which the message names; it committed nothing. */\n COMMAND_UNDECLARED_EVENT: 'wow.command.undeclared-event',\n /** 503 Node closing: The node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503 Node on standby: The node is on standby until the cut-over: it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503 Storage unavailable: A store could not be reached or did not answer in time; retry later, a command with the same request id. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503 Schedule not due: A scheduled command arrived too long before its due time on this node's clock; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400 Invalid schedule job: The job command does not fit its job or instance: an unknown job, another scope, or an instance not enabled. */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */\n LEDGER_STALE: 'wow.ledger.stale',\n /** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until the aggregate is retried. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400 Malformed route request: A service route's parameter or body cannot be read as its type; the violation names the parameter. */\n ROUTE_MALFORMED: 'wow.route.malformed',\n /** 400 Malformed query: The query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400 Invalid query: The query failed admission; the problem lists the violations, each with its code (UNKNOWN_FIELD, ...). */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500 Query failed: The query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 404 No matching record: A single query matched no record: a query result, not a statement that an aggregate does not exist. */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404 Dataset not found: No dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /** 400 Too many groups: An aggregation that names no sort has more groups than its limit; add a sort for a top-N, or raise limit. */\n QUERY_TOO_MANY_GROUPS: 'wow.query.too-many-groups',\n /** 504 Query timed out: The query ran longer than its budget allows; narrow it rather than run it again. */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 409 Version not reached: The state read asked for a version the aggregate has not reached within the wait; the problem carries its current version: retry later. */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 429 Query busy: The query was not run: its store has as many queries running as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /** 409 Dataset unavailable: The dataset is served but cannot be queried now, for the reason the problem names (it needs revision). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403 Call forbidden: The calling service may not call this command: its wow.callers.<service>.commands do not list it. */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n /** 503 Peer unavailable: A client reached no node of the peer, or lost the connection before a query's answer; nothing was changed, so the request may be sent again. */\n PEER_UNAVAILABLE: 'wow.peer.unavailable',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** What a retry of a framework code may do, as the error catalog declares it. */\nexport interface FrameworkRetry {\n /** What a retry may do: never `none` here. */\n readonly retry: Retry;\n /** Its `Retry-After`, in milliseconds. */\n readonly retryAfterMs: number;\n}\n\n/**\n * What a retry may do of each framework code a retry may get past, by code;\n * a retry of every other code, a domain's among them, is `none`.\n */\nexport const FRAMEWORK_RETRIES: ReadonlyMap<string, FrameworkRetry> = new Map<\n string,\n FrameworkRetry\n>([\n ['wow.command.contended', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.busy', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.unknown', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.closing', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.standby', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.storage.unavailable', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.schedule.not-due', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.wait.timeout', { retry: 'same-request', retryAfterMs: 1000 }],\n [\n 'wow.query.min-version-not-reached',\n { retry: 'new-request', retryAfterMs: 1000 },\n ],\n ['wow.query.busy', { retry: 'new-request', retryAfterMs: 1000 }],\n ['wow.peer.unavailable', { retry: 'new-request', retryAfterMs: 1000 }],\n]);\n\n/**\n * How often, and after how long, a client sends a request again by default\n * when a retry may get past its error, as the Kotlin client does\n * (`RetryPolicy.DEFAULT`): at most `attempts` attempts, the first included,\n * `backoffMs` before the first retry without a `Retry-After`, doubled at each\n * attempt up to `maxWaitMs`.\n */\nexport const DEFAULT_RETRY = {\n attempts: 5,\n backoffMs: 200,\n maxWaitMs: 5000,\n} as const;\n"],"mappings":"AAkBA,IAAaA,EAAsB,CAEjC,qBAAsB,2BAEtB,eAAgB,qBAEhB,oBAAqB,0BAErB,kBAAmB,wBAEnB,kBAAmB,wBAEnB,gBAAiB,sBAEjB,aAAc,mBAEd,kBAAmB,wBAEnB,oBAAqB,0BAErB,iBAAkB,uBAElB,2BAA4B,iCAE5B,0BAA2B,gCAE3B,kBAAmB,wBAEnB,kBAAmB,wBAEnB,aAAc,mBAEd,gBAAiB,sBAEjB,eAAgB,qBAEhB,gBAAiB,sBAEjB,yBAA0B,+BAE1B,aAAc,mBAEd,aAAc,mBAEd,oBAAqB,0BAErB,iBAAkB,uBAElB,qBAAsB,2BAEtB,aAAc,mBAEd,oBAAqB,0BAErB,aAAc,mBAEd,gBAAiB,sBAEjB,gBAAiB,sBAEjB,cAAe,oBAEf,aAAc,mBAEd,gBAAiB,sBAEjB,wBAAyB,8BAEzB,sBAAuB,4BAEvB,cAAe,oBAEf,8BAA+B,oCAE/B,WAAY,iBAEZ,0BAA2B,gCAE3B,uBAAwB,6BAExB,iBAAkB,sBACpB,EAkBaC,EAAyD,IAAI,IAGxE,CACA,CAAC,wBAAyB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACvE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,sBAAuB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACrE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CAAC,0BAA2B,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACzE,CAAC,uBAAwB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EACtE,CAAC,mBAAoB,CAAE,MAAO,eAAgB,aAAc,GAAK,CAAC,EAClE,CACE,oCACA,CAAE,MAAO,cAAe,aAAc,GAAK,CAC7C,EACA,CAAC,iBAAkB,CAAE,MAAO,cAAe,aAAc,GAAK,CAAC,EAC/D,CAAC,uBAAwB,CAAE,MAAO,cAAe,aAAc,GAAK,CAAC,CACvE,CAAC,EASYC,EAAgB,CAC3B,SAAU,EACV,UAAW,IACX,UAAW,GACb,E"}
|
|
@@ -62,7 +62,7 @@ export declare const FrameworkErrorCodes: {
|
|
|
62
62
|
readonly SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid";
|
|
63
63
|
/** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */
|
|
64
64
|
readonly LEDGER_STALE: "wow.ledger.stale";
|
|
65
|
-
/** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until
|
|
65
|
+
/** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until the aggregate is retried. */
|
|
66
66
|
readonly SUBSCRIPTION_PARKED: "wow.subscription.parked";
|
|
67
67
|
/** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */
|
|
68
68
|
readonly WAIT_TIMEOUT: "wow.wait.timeout";
|
|
@@ -62,7 +62,7 @@ export declare const FrameworkErrorCodes: {
|
|
|
62
62
|
readonly SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid";
|
|
63
63
|
/** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */
|
|
64
64
|
readonly LEDGER_STALE: "wow.ledger.stale";
|
|
65
|
-
/** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until
|
|
65
|
+
/** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until the aggregate is retried. */
|
|
66
66
|
readonly SUBSCRIPTION_PARKED: "wow.subscription.parked";
|
|
67
67
|
/** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */
|
|
68
68
|
readonly WAIT_TIMEOUT: "wow.wait.timeout";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frameworkErrors.es.js","names":["FrameworkErrorCodes","FRAMEWORK_RETRIES","DEFAULT_RETRY"],"sources":["../src/frameworkErrors.ts"],"sourcesContent":["// Code generated by scripts/framework-errors.mjs from the error catalog\n// (FrameworkErrors of :manifest, api/manifest/src/test/resources/framework-errors.json).\n// DO NOT EDIT: change FrameworkErrors and run the script.\n\n/**\n * What a retry of a request answered with an error may do, as the error\n * catalog declares it for the error's code and every problem carries it\n * (`retry`): `none`, a retry fails alike; `same-request`, send it again\n * with the same request id (`Wow-Request-Id`), so a command that did commit\n * is answered as its duplicate; `new-request`, send it again as it is.\n */\nexport type Retry = 'none' | 'same-request' | 'new-request';\n\n/**\n * The framework's error codes, each answered with the status of the error\n * catalog. A domain rejection has a code of its own, answered with 422 unless\n * the service configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401 Unauthenticated: The request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403 Command forbidden: The caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403 Aggregate out of scope: The aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400 Malformed request: A request header or parameter does not parse, or names what Wow does not take. */\n REQUEST_MALFORMED: 'wow.request.malformed',\n /** 400 Malformed command: The command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400 Invalid command: The command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400 Invalid wait: The wait is not a chain the runtime can follow; the command was not run. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400 Command not handled: The aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404 Aggregate not found: The aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409 Aggregate exists: The aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409 Version mismatch: The aggregate is not at the expected version (412 when the request carried If-Match). */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409 Request id reused: The request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409 Command contended: Concurrent writers kept winning the version; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410 Aggregate deleted: The aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429 Command busy: The command was not taken: its aggregate has too many commands waiting, or the node too many in flight; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503 Command outcome unknown: Whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500 Command failed: The command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 409 Command refused: The aggregate's current state refuses the command (a check of its decide function); the message says why. */\n COMMAND_REFUSED: 'wow.command.refused',\n /** 500 Undeclared event: The command's handling produced an event its decide function or after hooks do not declare: a bug in the model, which the message names; it committed nothing. */\n COMMAND_UNDECLARED_EVENT: 'wow.command.undeclared-event',\n /** 503 Node closing: The node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503 Node on standby: The node is on standby until the cut-over: it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503 Storage unavailable: A store could not be reached or did not answer in time; retry later, a command with the same request id. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503 Schedule not due: A scheduled command arrived too long before its due time on this node's clock; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400 Invalid schedule job: The job command does not fit its job or instance: an unknown job, another scope, or an instance not enabled. */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */\n LEDGER_STALE: 'wow.ledger.stale',\n /** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until it resumes. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400 Malformed route request: A service route's parameter or body cannot be read as its type; the violation names the parameter. */\n ROUTE_MALFORMED: 'wow.route.malformed',\n /** 400 Malformed query: The query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400 Invalid query: The query failed admission; the problem lists the violations, each with its code (UNKNOWN_FIELD, ...). */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500 Query failed: The query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 404 No matching record: A single query matched no record: a query result, not a statement that an aggregate does not exist. */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404 Dataset not found: No dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /** 400 Too many groups: An aggregation that names no sort has more groups than its limit; add a sort for a top-N, or raise limit. */\n QUERY_TOO_MANY_GROUPS: 'wow.query.too-many-groups',\n /** 504 Query timed out: The query ran longer than its budget allows; narrow it rather than run it again. */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 409 Version not reached: The state read asked for a version the aggregate has not reached within the wait; the problem carries its current version: retry later. */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 429 Query busy: The query was not run: its store has as many queries running as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /** 409 Dataset unavailable: The dataset is served but cannot be queried now, for the reason the problem names (it needs revision). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403 Call forbidden: The calling service may not call this command: its wow.callers.<service>.commands do not list it. */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n /** 503 Peer unavailable: A client reached no node of the peer, or lost the connection before a query's answer; nothing was changed, so the request may be sent again. */\n PEER_UNAVAILABLE: 'wow.peer.unavailable',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** What a retry of a framework code may do, as the error catalog declares it. */\nexport interface FrameworkRetry {\n /** What a retry may do: never `none` here. */\n readonly retry: Retry;\n /** Its `Retry-After`, in milliseconds. */\n readonly retryAfterMs: number;\n}\n\n/**\n * What a retry may do of each framework code a retry may get past, by code;\n * a retry of every other code, a domain's among them, is `none`.\n */\nexport const FRAMEWORK_RETRIES: ReadonlyMap<string, FrameworkRetry> = new Map<\n string,\n FrameworkRetry\n>([\n ['wow.command.contended', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.busy', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.unknown', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.closing', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.standby', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.storage.unavailable', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.schedule.not-due', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.wait.timeout', { retry: 'same-request', retryAfterMs: 1000 }],\n [\n 'wow.query.min-version-not-reached',\n { retry: 'new-request', retryAfterMs: 1000 },\n ],\n ['wow.query.busy', { retry: 'new-request', retryAfterMs: 1000 }],\n ['wow.peer.unavailable', { retry: 'new-request', retryAfterMs: 1000 }],\n]);\n\n/**\n * How often, and after how long, a client sends a request again by default\n * when a retry may get past its error, as the Kotlin client does\n * (`RetryPolicy.DEFAULT`): at most `attempts` attempts, the first included,\n * `backoffMs` before the first retry without a `Retry-After`, doubled at each\n * attempt up to `maxWaitMs`.\n */\nexport const DEFAULT_RETRY = {\n attempts: 5,\n backoffMs: 200,\n maxWaitMs: 5000,\n} as const;\n"],"mappings":";AAkBA,IAAaA,IAAsB;CAEjC,sBAAsB;CAEtB,gBAAgB;CAEhB,qBAAqB;CAErB,mBAAmB;CAEnB,mBAAmB;CAEnB,iBAAiB;CAEjB,cAAc;CAEd,mBAAmB;CAEnB,qBAAqB;CAErB,kBAAkB;CAElB,4BAA4B;CAE5B,2BAA2B;CAE3B,mBAAmB;CAEnB,mBAAmB;CAEnB,cAAc;CAEd,iBAAiB;CAEjB,gBAAgB;CAEhB,iBAAiB;CAEjB,0BAA0B;CAE1B,cAAc;CAEd,cAAc;CAEd,qBAAqB;CAErB,kBAAkB;CAElB,sBAAsB;CAEtB,cAAc;CAEd,qBAAqB;CAErB,cAAc;CAEd,iBAAiB;CAEjB,iBAAiB;CAEjB,eAAe;CAEf,cAAc;CAEd,iBAAiB;CAEjB,yBAAyB;CAEzB,uBAAuB;CAEvB,eAAe;CAEf,+BAA+B;CAE/B,YAAY;CAEZ,2BAA2B;CAE3B,wBAAwB;CAExB,kBAAkB;AACpB,GAkBaC,oBAAyD,IAAI,IAGxE;CACA,CAAC,yBAAyB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACvE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,uBAAuB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACrE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,2BAA2B;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACzE,CAAC,wBAAwB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACtE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CACE,qCACA;EAAE,OAAO;EAAe,cAAc;CAAK,CAC7C;CACA,CAAC,kBAAkB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;CAC/D,CAAC,wBAAwB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;AACvE,CAAC,GASYC,IAAgB;CAC3B,UAAU;CACV,WAAW;CACX,WAAW;AACb"}
|
|
1
|
+
{"version":3,"file":"frameworkErrors.es.js","names":["FrameworkErrorCodes","FRAMEWORK_RETRIES","DEFAULT_RETRY"],"sources":["../src/frameworkErrors.ts"],"sourcesContent":["// Code generated by scripts/framework-errors.mjs from the error catalog\n// (FrameworkErrors of :manifest, api/manifest/src/test/resources/framework-errors.json).\n// DO NOT EDIT: change FrameworkErrors and run the script.\n\n/**\n * What a retry of a request answered with an error may do, as the error\n * catalog declares it for the error's code and every problem carries it\n * (`retry`): `none`, a retry fails alike; `same-request`, send it again\n * with the same request id (`Wow-Request-Id`), so a command that did commit\n * is answered as its duplicate; `new-request`, send it again as it is.\n */\nexport type Retry = 'none' | 'same-request' | 'new-request';\n\n/**\n * The framework's error codes, each answered with the status of the error\n * catalog. A domain rejection has a code of its own, answered with 422 unless\n * the service configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401 Unauthenticated: The request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403 Command forbidden: The caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403 Aggregate out of scope: The aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400 Malformed request: A request header or parameter does not parse, or names what Wow does not take. */\n REQUEST_MALFORMED: 'wow.request.malformed',\n /** 400 Malformed command: The command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400 Invalid command: The command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400 Invalid wait: The wait is not a chain the runtime can follow; the command was not run. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400 Command not handled: The aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404 Aggregate not found: The aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409 Aggregate exists: The aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409 Version mismatch: The aggregate is not at the expected version (412 when the request carried If-Match). */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409 Request id reused: The request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409 Command contended: Concurrent writers kept winning the version; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410 Aggregate deleted: The aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429 Command busy: The command was not taken: its aggregate has too many commands waiting, or the node too many in flight; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503 Command outcome unknown: Whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500 Command failed: The command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 409 Command refused: The aggregate's current state refuses the command (a check of its decide function); the message says why. */\n COMMAND_REFUSED: 'wow.command.refused',\n /** 500 Undeclared event: The command's handling produced an event its decide function or after hooks do not declare: a bug in the model, which the message names; it committed nothing. */\n COMMAND_UNDECLARED_EVENT: 'wow.command.undeclared-event',\n /** 503 Node closing: The node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503 Node on standby: The node is on standby until the cut-over: it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503 Storage unavailable: A store could not be reached or did not answer in time; retry later, a command with the same request id. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503 Schedule not due: A scheduled command arrived too long before its due time on this node's clock; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400 Invalid schedule job: The job command does not fit its job or instance: an unknown job, another scope, or an instance not enabled. */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */\n LEDGER_STALE: 'wow.ledger.stale',\n /** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until the aggregate is retried. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400 Malformed route request: A service route's parameter or body cannot be read as its type; the violation names the parameter. */\n ROUTE_MALFORMED: 'wow.route.malformed',\n /** 400 Malformed query: The query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400 Invalid query: The query failed admission; the problem lists the violations, each with its code (UNKNOWN_FIELD, ...). */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500 Query failed: The query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 404 No matching record: A single query matched no record: a query result, not a statement that an aggregate does not exist. */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404 Dataset not found: No dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /** 400 Too many groups: An aggregation that names no sort has more groups than its limit; add a sort for a top-N, or raise limit. */\n QUERY_TOO_MANY_GROUPS: 'wow.query.too-many-groups',\n /** 504 Query timed out: The query ran longer than its budget allows; narrow it rather than run it again. */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 409 Version not reached: The state read asked for a version the aggregate has not reached within the wait; the problem carries its current version: retry later. */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 429 Query busy: The query was not run: its store has as many queries running as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /** 409 Dataset unavailable: The dataset is served but cannot be queried now, for the reason the problem names (it needs revision). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403 Call forbidden: The calling service may not call this command: its wow.callers.<service>.commands do not list it. */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n /** 503 Peer unavailable: A client reached no node of the peer, or lost the connection before a query's answer; nothing was changed, so the request may be sent again. */\n PEER_UNAVAILABLE: 'wow.peer.unavailable',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** What a retry of a framework code may do, as the error catalog declares it. */\nexport interface FrameworkRetry {\n /** What a retry may do: never `none` here. */\n readonly retry: Retry;\n /** Its `Retry-After`, in milliseconds. */\n readonly retryAfterMs: number;\n}\n\n/**\n * What a retry may do of each framework code a retry may get past, by code;\n * a retry of every other code, a domain's among them, is `none`.\n */\nexport const FRAMEWORK_RETRIES: ReadonlyMap<string, FrameworkRetry> = new Map<\n string,\n FrameworkRetry\n>([\n ['wow.command.contended', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.busy', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.unknown', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.closing', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.standby', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.storage.unavailable', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.schedule.not-due', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.wait.timeout', { retry: 'same-request', retryAfterMs: 1000 }],\n [\n 'wow.query.min-version-not-reached',\n { retry: 'new-request', retryAfterMs: 1000 },\n ],\n ['wow.query.busy', { retry: 'new-request', retryAfterMs: 1000 }],\n ['wow.peer.unavailable', { retry: 'new-request', retryAfterMs: 1000 }],\n]);\n\n/**\n * How often, and after how long, a client sends a request again by default\n * when a retry may get past its error, as the Kotlin client does\n * (`RetryPolicy.DEFAULT`): at most `attempts` attempts, the first included,\n * `backoffMs` before the first retry without a `Retry-After`, doubled at each\n * attempt up to `maxWaitMs`.\n */\nexport const DEFAULT_RETRY = {\n attempts: 5,\n backoffMs: 200,\n maxWaitMs: 5000,\n} as const;\n"],"mappings":";AAkBA,IAAaA,IAAsB;CAEjC,sBAAsB;CAEtB,gBAAgB;CAEhB,qBAAqB;CAErB,mBAAmB;CAEnB,mBAAmB;CAEnB,iBAAiB;CAEjB,cAAc;CAEd,mBAAmB;CAEnB,qBAAqB;CAErB,kBAAkB;CAElB,4BAA4B;CAE5B,2BAA2B;CAE3B,mBAAmB;CAEnB,mBAAmB;CAEnB,cAAc;CAEd,iBAAiB;CAEjB,gBAAgB;CAEhB,iBAAiB;CAEjB,0BAA0B;CAE1B,cAAc;CAEd,cAAc;CAEd,qBAAqB;CAErB,kBAAkB;CAElB,sBAAsB;CAEtB,cAAc;CAEd,qBAAqB;CAErB,cAAc;CAEd,iBAAiB;CAEjB,iBAAiB;CAEjB,eAAe;CAEf,cAAc;CAEd,iBAAiB;CAEjB,yBAAyB;CAEzB,uBAAuB;CAEvB,eAAe;CAEf,+BAA+B;CAE/B,YAAY;CAEZ,2BAA2B;CAE3B,wBAAwB;CAExB,kBAAkB;AACpB,GAkBaC,oBAAyD,IAAI,IAGxE;CACA,CAAC,yBAAyB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACvE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,uBAAuB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACrE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,2BAA2B;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACzE,CAAC,wBAAwB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACtE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CACE,qCACA;EAAE,OAAO;EAAe,cAAc;CAAK,CAC7C;CACA,CAAC,kBAAkB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;CAC/D,CAAC,wBAAwB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;AACvE,CAAC,GASYC,IAAgB;CAC3B,UAAU;CACV,WAAW;CACX,WAAW;AACb"}
|
package/dist/manifest.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.cjs","names":["json","send","require_http","MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n
|
|
1
|
+
{"version":3,"file":"manifest.cjs","names":["json","send","require_http","MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n/**\n * A command as a {@link RoutingManifest} lists it: its name, former names and\n * routes, and the property of its body that names its aggregate, for a command\n * whose body does (`idProperty`).\n */\nexport type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> &\n Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;\n\n/** A service route as a {@link RoutingManifest} lists it: its name and its route. */\nexport type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;\n\n/**\n * What a `CommandClient` reads of a Manifest to send a command: each\n * context's aggregates and their commands with their routes, and the context's\n * own system commands; and what a `ServiceRoutes` reads to call a service\n * route: the context's routes. A whole {@link Manifest} is one; a generated\n * client carries its service's as data (`manifest.ts`), with no schema.\n */\nexport interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {\n readonly contexts: readonly (Pick<ContextManifest, 'name'> & {\n readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {\n readonly commands?: readonly RoutingCommand[];\n })[];\n readonly commands?: readonly RoutingCommand[];\n readonly routes?: readonly RoutingServiceRoute[];\n })[];\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The markers of a Manifest's `requires` this client understands, as the\n * Kotlin reader's `ManifestFeatures`: none yet.\n */\nexport const MANIFEST_FEATURES: ReadonlySet<string> = new Set<string>();\n\n/**\n * Checks that this client can read `manifest`: its format, and every marker it\n * requires.\n *\n * @param manifest - The Manifest\n * @throws TypeError naming what this client does not understand\n */\nexport function checkManifest<M extends RoutingManifest>(manifest: M): M {\n if (manifest.format !== MANIFEST_FORMAT) {\n throw new TypeError(\n `The Manifest is of format ${manifest.format}; this client reads format ${MANIFEST_FORMAT}.`,\n );\n }\n const unknown = (manifest.requires ?? []).filter(\n marker => !MANIFEST_FEATURES.has(marker),\n );\n if (unknown.length > 0) {\n throw new TypeError(\n `The Manifest requires ${unknown.join(', ')}, which this client does not understand: use a newer @ahoo-wang/wow-client.`,\n );\n }\n return manifest;\n}\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return checkManifest(\n await json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n ),\n );\n}\n"],"mappings":"A,8BA6DA,IAAaG,EAAkB,EAMlBC,EAAyC,IAAI,IAS1D,SAAgBC,EAAyC,EAAgB,CACvE,GAAIC,EAAS,SAAA,EACX,MAAU,UACR,6BAA6BA,EAAS,OAAO,8BAC/C,EAEF,IAAMC,GAAWD,EAAS,UAAY,CAAC,EAAA,CAAG,OACxC,GAAU,CAACF,EAAkB,IAAII,CAAM,CACzC,EACA,GAAID,EAAQ,OAAS,EACnB,MAAU,UACR,yBAAyBA,EAAQ,KAAK,IAAI,EAAE,4EAC9C,EAEF,OAAOD,CACT,CAQA,eAAsBG,EACpB,EAA2B,CAAC,EAC5B,EACmB,CACnB,OAAOJ,EACL,MAAML,EAAAA,KACJ,MAAMC,EAAAA,KAAKS,EAAQ,CAAE,OAAQ,MAAO,KAAM,gBAAiB,SAAQ,CAAC,CACtE,CACF,CACF,C"}
|
package/dist/manifest.d.cts
CHANGED
|
@@ -3,8 +3,12 @@ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceR
|
|
|
3
3
|
export type * from './manifestTypes.cjs';
|
|
4
4
|
/** Whether a command creates its aggregate. */
|
|
5
5
|
export type Creation = CommandManifest['creation'];
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A command as a {@link RoutingManifest} lists it: its name, former names and
|
|
8
|
+
* routes, and the property of its body that names its aggregate, for a command
|
|
9
|
+
* whose body does (`idProperty`).
|
|
10
|
+
*/
|
|
11
|
+
export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
|
|
8
12
|
/** A service route as a {@link RoutingManifest} lists it: its name and its route. */
|
|
9
13
|
export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
|
|
10
14
|
/**
|
package/dist/manifest.d.ts
CHANGED
|
@@ -3,8 +3,12 @@ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceR
|
|
|
3
3
|
export type * from './manifestTypes.js';
|
|
4
4
|
/** Whether a command creates its aggregate. */
|
|
5
5
|
export type Creation = CommandManifest['creation'];
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* A command as a {@link RoutingManifest} lists it: its name, former names and
|
|
8
|
+
* routes, and the property of its body that names its aggregate, for a command
|
|
9
|
+
* whose body does (`idProperty`).
|
|
10
|
+
*/
|
|
11
|
+
export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
|
|
8
12
|
/** A service route as a {@link RoutingManifest} lists it: its name and its route. */
|
|
9
13
|
export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
|
|
10
14
|
/**
|