@ahoo-wang/wow-client 10.0.0-alpha.6 → 10.0.0-alpha.7
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 +76 -23
- package/README.zh-CN.md +66 -19
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +131 -61
- package/dist/commands.d.ts +131 -61
- package/dist/commands.es.js +117 -59
- package/dist/commands.es.js.map +1 -1
- package/dist/developmentCaller.cjs +2 -0
- package/dist/developmentCaller.cjs.map +1 -0
- package/dist/developmentCaller.d.cts +61 -0
- package/dist/developmentCaller.d.ts +61 -0
- package/dist/developmentCaller.es.js +26 -0
- package/dist/developmentCaller.es.js.map +1 -0
- package/dist/dsl/aggregation/admit.cjs +1 -1
- package/dist/dsl/aggregation/admit.cjs.map +1 -1
- package/dist/dsl/aggregation/admit.es.js +93 -93
- package/dist/dsl/aggregation/admit.es.js.map +1 -1
- package/dist/dsl/aggregation/builders.cjs +1 -1
- package/dist/dsl/aggregation/builders.cjs.map +1 -1
- package/dist/dsl/aggregation/builders.d.cts +20 -20
- package/dist/dsl/aggregation/builders.d.ts +20 -20
- package/dist/dsl/aggregation/builders.es.js +88 -88
- package/dist/dsl/aggregation/builders.es.js.map +1 -1
- package/dist/dsl/aggregation/derived.cjs.map +1 -1
- package/dist/dsl/aggregation/derived.d.cts +8 -8
- package/dist/dsl/aggregation/derived.d.ts +8 -8
- package/dist/dsl/aggregation/derived.es.js +1 -2
- package/dist/dsl/aggregation/derived.es.js.map +1 -1
- package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -1
- package/dist/dsl/aggregation/expressionTrees.es.js +1 -2
- package/dist/dsl/aggregation/having.cjs +1 -1
- package/dist/dsl/aggregation/having.cjs.map +1 -1
- package/dist/dsl/aggregation/having.d.cts +12 -12
- package/dist/dsl/aggregation/having.d.ts +12 -12
- package/dist/dsl/aggregation/having.es.js +33 -33
- package/dist/dsl/aggregation/having.es.js.map +1 -1
- package/dist/dsl/aggregation/sort.cjs.map +1 -1
- package/dist/dsl/aggregation/sort.es.js +1 -2
- package/dist/dsl/aggregation/types.cjs +1 -1
- package/dist/dsl/aggregation/types.cjs.map +1 -1
- package/dist/dsl/aggregation/types.d.cts +69 -69
- package/dist/dsl/aggregation/types.d.ts +69 -69
- package/dist/dsl/aggregation/types.es.js +15 -16
- package/dist/dsl/aggregation/types.es.js.map +1 -1
- package/dist/dsl/constantName.cjs +2 -0
- package/dist/dsl/constantName.cjs.map +1 -0
- package/dist/dsl/constantName.d.cts +9 -0
- package/dist/dsl/constantName.d.ts +9 -0
- package/dist/dsl/constantName.es.js +7 -0
- package/dist/dsl/constantName.es.js.map +1 -0
- package/dist/dsl/cursorQuery.cjs.map +1 -1
- package/dist/dsl/cursorQuery.es.js +1 -2
- package/dist/dsl/deletionState.cjs +1 -1
- package/dist/dsl/deletionState.cjs.map +1 -1
- package/dist/dsl/deletionState.d.cts +3 -3
- package/dist/dsl/deletionState.d.ts +3 -3
- package/dist/dsl/deletionState.es.js +2 -3
- package/dist/dsl/deletionState.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 +92 -42
- package/dist/dsl/descriptor.d.ts +92 -42
- package/dist/dsl/descriptor.es.js +36 -29
- package/dist/dsl/descriptor.es.js.map +1 -1
- package/dist/dsl/field.cjs.map +1 -1
- package/dist/dsl/field.es.js +1 -2
- package/dist/dsl/filter/builders.cjs +1 -1
- package/dist/dsl/filter/builders.cjs.map +1 -1
- package/dist/dsl/filter/builders.d.cts +53 -53
- package/dist/dsl/filter/builders.d.ts +53 -53
- package/dist/dsl/filter/builders.es.js +111 -111
- package/dist/dsl/filter/builders.es.js.map +1 -1
- package/dist/dsl/filter/datePattern.cjs.map +1 -1
- package/dist/dsl/filter/datePattern.es.js +1 -2
- package/dist/dsl/filter/operator.cjs +1 -1
- package/dist/dsl/filter/operator.cjs.map +1 -1
- package/dist/dsl/filter/operator.d.cts +57 -57
- package/dist/dsl/filter/operator.d.ts +57 -57
- package/dist/dsl/filter/operator.es.js +4 -5
- package/dist/dsl/filter/operator.es.js.map +1 -1
- package/dist/dsl/filter/scope.cjs +1 -1
- package/dist/dsl/filter/scope.cjs.map +1 -1
- package/dist/dsl/filter/scope.es.js +12 -12
- package/dist/dsl/filter/scope.es.js.map +1 -1
- package/dist/dsl/filter/validate.cjs +1 -1
- package/dist/dsl/filter/validate.cjs.map +1 -1
- package/dist/dsl/filter/validate.es.js +23 -23
- package/dist/dsl/filter/validate.es.js.map +1 -1
- package/dist/dsl/pagination.cjs.map +1 -1
- package/dist/dsl/pagination.es.js +1 -2
- package/dist/dsl/projection.cjs.map +1 -1
- package/dist/dsl/projection.d.cts +1 -1
- package/dist/dsl/projection.d.ts +1 -1
- package/dist/dsl/projection.es.js +1 -2
- package/dist/dsl/projection.es.js.map +1 -1
- package/dist/dsl/queryErrorCodes.cjs +1 -1
- package/dist/dsl/queryErrorCodes.cjs.map +1 -1
- package/dist/dsl/queryErrorCodes.d.cts +59 -48
- package/dist/dsl/queryErrorCodes.d.ts +59 -48
- package/dist/dsl/queryErrorCodes.es.js +51 -50
- package/dist/dsl/queryErrorCodes.es.js.map +1 -1
- package/dist/dsl/queryable.cjs +1 -1
- package/dist/dsl/queryable.cjs.map +1 -1
- package/dist/dsl/queryable.d.cts +25 -21
- package/dist/dsl/queryable.d.ts +25 -21
- package/dist/dsl/queryable.es.js +5 -5
- package/dist/dsl/queryable.es.js.map +1 -1
- package/dist/dsl/sort.cjs +1 -1
- package/dist/dsl/sort.cjs.map +1 -1
- package/dist/dsl/sort.d.cts +2 -2
- package/dist/dsl/sort.d.ts +2 -2
- package/dist/dsl/sort.es.js +4 -5
- package/dist/dsl/sort.es.js.map +1 -1
- package/dist/dsl.cjs +1 -1
- package/dist/dsl.es.js +3 -3
- package/dist/exactJson.cjs.map +1 -1
- package/dist/exactJson.d.cts +4 -4
- package/dist/exactJson.d.ts +4 -4
- package/dist/exactJson.es.js +1 -2
- package/dist/exactJson.es.js.map +1 -1
- package/dist/frameworkErrors.cjs +2 -0
- package/dist/frameworkErrors.cjs.map +1 -0
- package/dist/frameworkErrors.d.cts +121 -0
- package/dist/frameworkErrors.d.ts +121 -0
- package/dist/frameworkErrors.es.js +95 -0
- package/dist/frameworkErrors.es.js.map +1 -0
- package/dist/http.cjs +1 -1
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +4 -7
- package/dist/http.d.ts +4 -7
- package/dist/http.es.js +12 -20
- package/dist/http.es.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.es.js +11 -9
- package/dist/manifest.cjs +1 -1
- package/dist/manifest.cjs.map +1 -1
- package/dist/manifest.d.cts +33 -95
- package/dist/manifest.d.ts +33 -95
- package/dist/manifest.es.js +12 -7
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +193 -0
- package/dist/manifestTypes.d.ts +193 -0
- package/dist/problem.cjs +1 -1
- package/dist/problem.cjs.map +1 -1
- package/dist/problem.d.cts +76 -115
- package/dist/problem.d.ts +76 -115
- package/dist/problem.es.js +45 -80
- package/dist/problem.es.js.map +1 -1
- package/dist/queries.cjs +1 -1
- package/dist/queries.cjs.map +1 -1
- package/dist/queries.d.cts +28 -51
- package/dist/queries.d.ts +28 -51
- package/dist/queries.es.js +49 -40
- package/dist/queries.es.js.map +1 -1
- package/dist/routes.cjs +2 -0
- package/dist/routes.cjs.map +1 -0
- package/dist/routes.d.cts +49 -0
- package/dist/routes.d.ts +49 -0
- package/dist/routes.es.js +33 -0
- package/dist/routes.es.js.map +1 -0
- package/dist/state.cjs +1 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +56 -11
- package/dist/state.d.ts +56 -11
- package/dist/state.es.js +56 -21
- package/dist/state.es.js.map +1 -1
- package/dist/streams.cjs +1 -1
- package/dist/streams.cjs.map +1 -1
- package/dist/streams.d.cts +17 -13
- package/dist/streams.d.ts +17 -13
- package/dist/streams.es.js +50 -50
- package/dist/streams.es.js.map +1 -1
- package/dist/testing/wire.cjs +2 -0
- package/dist/testing/wire.cjs.map +1 -0
- package/dist/testing/wire.d.cts +29 -0
- package/dist/testing/wire.d.ts +29 -0
- package/dist/testing/wire.es.js +88 -0
- package/dist/testing/wire.es.js.map +1 -0
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +12 -0
- package/dist/testing.d.ts +12 -0
- package/dist/testing.es.js +3 -0
- package/dist/wait.cjs +1 -1
- package/dist/wait.cjs.map +1 -1
- package/dist/wait.d.cts +67 -18
- package/dist/wait.d.ts +67 -18
- package/dist/wait.es.js +59 -12
- package/dist/wait.es.js.map +1 -1
- package/dist/wire.cjs +1 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +100 -50
- package/dist/wire.d.ts +100 -50
- package/dist/wire.es.js +17 -6
- package/dist/wire.es.js.map +1 -1
- package/package.json +23 -3
package/dist/dsl/descriptor.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { AggregationDatePart, AggregationDateUnit, DateDiffUnit, AggregationFunction, AggregationGroupType, AggregationMetricType, WindowFunction } from './aggregation/types.js';
|
|
2
2
|
import { DeletionState } from './deletionState.js';
|
|
3
3
|
import { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* A query model's capability descriptor and its version, the `ETag` of
|
|
6
|
+
* `GET …/query`; `notModified` when the version given is still current.
|
|
7
|
+
*/
|
|
8
|
+
export type DescriptorResult = {
|
|
9
|
+
readonly notModified: false;
|
|
10
|
+
readonly version?: string;
|
|
11
|
+
readonly descriptor: QueryModelDescriptor;
|
|
12
|
+
} | {
|
|
13
|
+
readonly notModified: true;
|
|
14
|
+
readonly version: string;
|
|
15
|
+
};
|
|
4
16
|
/**
|
|
5
17
|
* The query models Wow names in a descriptor's `model`. The set is open: a
|
|
6
18
|
* server may register a model of its own, so a descriptor's `model` is a
|
|
@@ -8,11 +20,11 @@ import { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';
|
|
|
8
20
|
*/
|
|
9
21
|
export declare const QueryModels: Readonly<{
|
|
10
22
|
/** The snapshot query model: `{aggregate}/snapshot/*`. */
|
|
11
|
-
readonly SNAPSHOT: "
|
|
23
|
+
readonly SNAPSHOT: "snapshot";
|
|
12
24
|
/** The event stream query model: `{aggregate}/event/*`. */
|
|
13
|
-
readonly EVENT_STREAM: "
|
|
25
|
+
readonly EVENT_STREAM: "events";
|
|
14
26
|
/** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */
|
|
15
|
-
readonly DATASET: "
|
|
27
|
+
readonly DATASET: "dataset";
|
|
16
28
|
}>;
|
|
17
29
|
/** A query model's name: one of {@link QueryModels}, or one a server added. */
|
|
18
30
|
export type QueryModel = (typeof QueryModels)[keyof typeof QueryModels] | (string & {});
|
|
@@ -22,41 +34,41 @@ export type QueryModel = (typeof QueryModels)[keyof typeof QueryModels] | (strin
|
|
|
22
34
|
*/
|
|
23
35
|
export declare const QueryValueTypes: Readonly<{
|
|
24
36
|
/** A JSON string. */
|
|
25
|
-
readonly STRING: "
|
|
37
|
+
readonly STRING: "string";
|
|
26
38
|
/** A whole number. */
|
|
27
|
-
readonly INTEGER: "
|
|
39
|
+
readonly INTEGER: "integer";
|
|
28
40
|
/** A number with a fraction. */
|
|
29
|
-
readonly DECIMAL: "
|
|
41
|
+
readonly DECIMAL: "decimal";
|
|
30
42
|
/** `true` or `false`. */
|
|
31
|
-
readonly BOOLEAN: "
|
|
43
|
+
readonly BOOLEAN: "boolean";
|
|
32
44
|
/** A JSON object. */
|
|
33
|
-
readonly OBJECT: "
|
|
45
|
+
readonly OBJECT: "object";
|
|
34
46
|
}>;
|
|
35
47
|
/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */
|
|
36
48
|
export type QueryValueType = (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});
|
|
37
49
|
/** The structural shape of a field's value, sent as its `kind`. */
|
|
38
50
|
export declare enum QueryValueKind {
|
|
39
51
|
/** Wow could not tell. */
|
|
40
|
-
UNKNOWN = "
|
|
52
|
+
UNKNOWN = "unknown",
|
|
41
53
|
/** Always `null`. */
|
|
42
|
-
NULL = "
|
|
54
|
+
NULL = "null",
|
|
43
55
|
/** A single string, number or boolean. */
|
|
44
|
-
SCALAR = "
|
|
56
|
+
SCALAR = "scalar",
|
|
45
57
|
/** An object. */
|
|
46
|
-
OBJECT = "
|
|
58
|
+
OBJECT = "object",
|
|
47
59
|
/** An array. */
|
|
48
|
-
ARRAY = "
|
|
60
|
+
ARRAY = "array",
|
|
49
61
|
/** One of several of the above. */
|
|
50
|
-
UNION = "
|
|
62
|
+
UNION = "union"
|
|
51
63
|
}
|
|
52
64
|
/** The ways a model can be read page by page, listed in `record.paging`. */
|
|
53
65
|
export declare enum PagingMode {
|
|
54
|
-
/** `list` and `
|
|
55
|
-
LIST = "
|
|
66
|
+
/** `list` and `stream`: the first `limit` rows. */
|
|
67
|
+
LIST = "list",
|
|
56
68
|
/** `paged`: numbered pages with a total. */
|
|
57
|
-
PAGED = "
|
|
69
|
+
PAGED = "paged",
|
|
58
70
|
/** `cursor`: forward-only pages after the last row seen. */
|
|
59
|
-
CURSOR = "
|
|
71
|
+
CURSOR = "cursor"
|
|
60
72
|
}
|
|
61
73
|
/**
|
|
62
74
|
* The system roles Wow names in a field's `role`: the system fields a root
|
|
@@ -65,28 +77,28 @@ export declare enum PagingMode {
|
|
|
65
77
|
*/
|
|
66
78
|
export declare const QueryFieldRoles: Readonly<{
|
|
67
79
|
/** The record's own identity, `record.identity`. */
|
|
68
|
-
readonly IDENTITY: "
|
|
80
|
+
readonly IDENTITY: "identity";
|
|
69
81
|
/** The aggregate id. */
|
|
70
|
-
readonly AGGREGATE_ID: "
|
|
82
|
+
readonly AGGREGATE_ID: "aggregate-id";
|
|
71
83
|
/** The tenant id. */
|
|
72
|
-
readonly TENANT_ID: "
|
|
84
|
+
readonly TENANT_ID: "tenant-id";
|
|
73
85
|
/** The owner id. */
|
|
74
|
-
readonly OWNER_ID: "
|
|
86
|
+
readonly OWNER_ID: "owner-id";
|
|
75
87
|
/** The space id. */
|
|
76
|
-
readonly SPACE_ID: "
|
|
88
|
+
readonly SPACE_ID: "space-id";
|
|
77
89
|
/** Whether the aggregate is deleted. */
|
|
78
|
-
readonly DELETED: "
|
|
90
|
+
readonly DELETED: "deleted";
|
|
79
91
|
/**
|
|
80
92
|
* When the record's events happened: a snapshot's last event
|
|
81
93
|
* (`eventTime`), an event stream's events (`createTime`). `FIRST` and
|
|
82
94
|
* `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.
|
|
83
95
|
*/
|
|
84
|
-
readonly EVENT_TIME: "
|
|
96
|
+
readonly EVENT_TIME: "event-time";
|
|
85
97
|
/**
|
|
86
98
|
* When a snapshot's aggregate got its first event, i.e. was created
|
|
87
99
|
* (`firstEventTime`). Wow 9.2 and later.
|
|
88
100
|
*/
|
|
89
|
-
readonly FIRST_EVENT_TIME: "
|
|
101
|
+
readonly FIRST_EVENT_TIME: "first-event-time";
|
|
90
102
|
}>;
|
|
91
103
|
/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */
|
|
92
104
|
export type QueryFieldRole = (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});
|
|
@@ -99,18 +111,18 @@ export declare const QueryConstraintTypes: Readonly<{
|
|
|
99
111
|
* A cursor's sort always ends with the identity field; the server appends
|
|
100
112
|
* it (the constraint's `appended`) when the sort does not.
|
|
101
113
|
*/
|
|
102
|
-
readonly CURSOR_UNIQUE_SORT: "
|
|
114
|
+
readonly CURSOR_UNIQUE_SORT: "cursor-unique-sort";
|
|
103
115
|
/** A count or paged query must not match every record. */
|
|
104
|
-
readonly COUNT_REQUIRES_FILTER: "
|
|
116
|
+
readonly COUNT_REQUIRES_FILTER: "count-requires-filter";
|
|
105
117
|
/** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */
|
|
106
|
-
readonly STARTS_WITH_REQUIRES_PREFIX: "
|
|
118
|
+
readonly STARTS_WITH_REQUIRES_PREFIX: "starts-with-requires-prefix";
|
|
107
119
|
/**
|
|
108
120
|
* A sort names at most one of the constraint's `fields`: they are
|
|
109
121
|
* array-valued and the storage cannot order by two independent arrays.
|
|
110
122
|
* Fields on one array path, one nested in the other, may still combine.
|
|
111
123
|
* A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.
|
|
112
124
|
*/
|
|
113
|
-
readonly PARALLEL_ARRAY_SORT: "
|
|
125
|
+
readonly PARALLEL_ARRAY_SORT: "parallel-array-sort";
|
|
114
126
|
/**
|
|
115
127
|
* On the constraint's `fields`, a stored `null` or empty array cannot be
|
|
116
128
|
* told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and
|
|
@@ -118,33 +130,54 @@ export declare const QueryConstraintTypes: Readonly<{
|
|
|
118
130
|
* presence filter on such a field answers "has a non-empty value", not
|
|
119
131
|
* "has the key"; say so to a user who writes one.
|
|
120
132
|
*/
|
|
121
|
-
readonly NULL_OR_EMPTY_AS_MISSING: "
|
|
133
|
+
readonly NULL_OR_EMPTY_AS_MISSING: "null-or-empty-as-missing";
|
|
122
134
|
/**
|
|
123
135
|
* Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,
|
|
124
136
|
* because the storage cannot compare a whole array. Match an array
|
|
125
137
|
* field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or
|
|
126
138
|
* `NE` with an array operand is refused with `ARRAY_EQUALITY`.
|
|
127
139
|
*/
|
|
128
|
-
readonly ARRAY_EQUALITY: "
|
|
140
|
+
readonly ARRAY_EQUALITY: "array-equality";
|
|
129
141
|
}>;
|
|
130
142
|
/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */
|
|
131
143
|
export type QueryConstraintType = (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes] | (string & {});
|
|
144
|
+
/**
|
|
145
|
+
* The semantics Wow names in a field's `semantic.type`, one per member of
|
|
146
|
+
* {@link QuerySemanticType}: read a descriptor's semantic by these rather
|
|
147
|
+
* than by its spelling.
|
|
148
|
+
*/
|
|
149
|
+
export declare const QuerySemanticTypes: Readonly<{
|
|
150
|
+
/** A calendar date: {@link TemporalDate}. */
|
|
151
|
+
readonly TEMPORAL_DATE: "temporal-date";
|
|
152
|
+
/** A number of time units since the epoch: {@link TemporalEpoch}. */
|
|
153
|
+
readonly TEMPORAL_EPOCH: "temporal-epoch";
|
|
154
|
+
/** A time written as text in a pattern: {@link TemporalFormatted}. */
|
|
155
|
+
readonly TEMPORAL_FORMATTED: "temporal-formatted";
|
|
156
|
+
/** A fixed-point decimal: {@link NumericDecimal}. */
|
|
157
|
+
readonly DECIMAL: "decimal";
|
|
158
|
+
/** An amount of money: {@link NumericMoney}. */
|
|
159
|
+
readonly MONEY: "money";
|
|
160
|
+
/** A length of time: {@link DurationSemantic}. */
|
|
161
|
+
readonly DURATION: "duration";
|
|
162
|
+
/** The id of an aggregate: {@link ReferenceSemantic}. */
|
|
163
|
+
readonly REFERENCE: "reference";
|
|
164
|
+
}>;
|
|
132
165
|
/** A field that holds a calendar date. */
|
|
133
166
|
export interface TemporalDate {
|
|
134
167
|
/** The discriminator. */
|
|
135
|
-
type:
|
|
168
|
+
type: typeof QuerySemanticTypes.TEMPORAL_DATE;
|
|
136
169
|
}
|
|
137
170
|
/** A field that holds a number of time units since the epoch. */
|
|
138
171
|
export interface TemporalEpoch {
|
|
139
172
|
/** The discriminator. */
|
|
140
|
-
type:
|
|
173
|
+
type: typeof QuerySemanticTypes.TEMPORAL_EPOCH;
|
|
141
174
|
/** The unit the number counts; milliseconds when absent. */
|
|
142
175
|
timeUnit?: TimeUnit;
|
|
143
176
|
}
|
|
144
177
|
/** A field that holds a time written as text in a `java.time` pattern. */
|
|
145
178
|
export interface TemporalFormatted {
|
|
146
179
|
/** The discriminator. */
|
|
147
|
-
type:
|
|
180
|
+
type: typeof QuerySemanticTypes.TEMPORAL_FORMATTED;
|
|
148
181
|
/** The `java.time` pattern, such as `yyyy-MM-dd`. */
|
|
149
182
|
pattern: string;
|
|
150
183
|
}
|
|
@@ -155,7 +188,7 @@ export interface TemporalFormatted {
|
|
|
155
188
|
*/
|
|
156
189
|
export interface NumericDecimal {
|
|
157
190
|
/** The discriminator. */
|
|
158
|
-
type:
|
|
191
|
+
type: typeof QuerySemanticTypes.DECIMAL;
|
|
159
192
|
/** The number of digits after the decimal point, 0 or more. */
|
|
160
193
|
scale: number;
|
|
161
194
|
}
|
|
@@ -170,7 +203,7 @@ export interface NumericDecimal {
|
|
|
170
203
|
*/
|
|
171
204
|
export type NumericMoney = {
|
|
172
205
|
/** The discriminator. */
|
|
173
|
-
type:
|
|
206
|
+
type: typeof QuerySemanticTypes.MONEY;
|
|
174
207
|
/** The number of digits after the decimal point, 0 or more. */
|
|
175
208
|
scale: number;
|
|
176
209
|
} & ({
|
|
@@ -189,7 +222,7 @@ export type NumericMoney = {
|
|
|
189
222
|
*/
|
|
190
223
|
export interface DurationSemantic {
|
|
191
224
|
/** The discriminator. */
|
|
192
|
-
type:
|
|
225
|
+
type: typeof QuerySemanticTypes.DURATION;
|
|
193
226
|
/** The unit the number counts; always sent. */
|
|
194
227
|
timeUnit: TimeUnit;
|
|
195
228
|
}
|
|
@@ -203,7 +236,7 @@ export interface DurationSemantic {
|
|
|
203
236
|
*/
|
|
204
237
|
export type ReferenceSemantic = {
|
|
205
238
|
/** The discriminator. */
|
|
206
|
-
type:
|
|
239
|
+
type: typeof QuerySemanticTypes.REFERENCE;
|
|
207
240
|
} & ({
|
|
208
241
|
/** The referenced aggregate's bounded context. */
|
|
209
242
|
contextName: string;
|
|
@@ -256,12 +289,12 @@ export declare enum SensitivityLevel {
|
|
|
256
289
|
* unless the server turned that off; grouping, `ANY`, field metrics,
|
|
257
290
|
* arithmetic references and cursor sorts are refused.
|
|
258
291
|
*/
|
|
259
|
-
DISPLAY = "
|
|
292
|
+
DISPLAY = "display",
|
|
260
293
|
/**
|
|
261
294
|
* Masked in results and never compared: no filter, sort, search, grouping
|
|
262
295
|
* or metric may name it.
|
|
263
296
|
*/
|
|
264
|
-
CONFIDENTIAL = "
|
|
297
|
+
CONFIDENTIAL = "confidential"
|
|
265
298
|
}
|
|
266
299
|
/**
|
|
267
300
|
* Why a field is deprecated. The field can still be queried, but new
|
|
@@ -299,6 +332,12 @@ export interface FieldSortDescriptor {
|
|
|
299
332
|
paged: boolean;
|
|
300
333
|
/** In the sort of a cursor query. */
|
|
301
334
|
cursor: boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Whether an index backs the sort, as the storage says: `false` marks a
|
|
337
|
+
* sort it runs without one, which may be slow on a large model; absent
|
|
338
|
+
* when the storage does not say.
|
|
339
|
+
*/
|
|
340
|
+
indexed?: boolean;
|
|
302
341
|
}
|
|
303
342
|
/** How a field may be used in an aggregation. */
|
|
304
343
|
export interface FieldAggregateDescriptor {
|
|
@@ -399,8 +438,19 @@ export interface DynamicFieldDescriptor {
|
|
|
399
438
|
types: QueryValueType[];
|
|
400
439
|
/** The structural shape of their values. */
|
|
401
440
|
kind: QueryValueKind;
|
|
441
|
+
/** Whether their values may be `null`, as a field's `nullable` says. */
|
|
442
|
+
nullable: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* What their values mean beyond their type, as a field's `semantic`
|
|
445
|
+
* says; absent when nothing more.
|
|
446
|
+
*/
|
|
447
|
+
semantic?: QuerySemanticType;
|
|
402
448
|
/** The filter operators they admit. */
|
|
403
449
|
filter: FieldFilterDescriptor;
|
|
450
|
+
/** Where a concrete key may be sorted by. */
|
|
451
|
+
sort: FieldSortDescriptor;
|
|
452
|
+
/** How a concrete key may be aggregated; absent when it cannot be at all. */
|
|
453
|
+
aggregate?: FieldAggregateDescriptor;
|
|
404
454
|
/**
|
|
405
455
|
* The map's keys that are declared as fields of their own and so are not
|
|
406
456
|
* covered by this pattern; absent when there are none. For
|
|
@@ -554,7 +604,7 @@ export interface AnalysisDescriptor {
|
|
|
554
604
|
windows?: WindowFunction[];
|
|
555
605
|
/**
|
|
556
606
|
* Whether a group of a query that expands elements may name a field of the
|
|
557
|
-
* root record (`scope: '
|
|
607
|
+
* root record (`scope: 'root'`); `false` when expensive operators are off.
|
|
558
608
|
* Absent from servers before Wow 9.9, which group elements by element
|
|
559
609
|
* fields only.
|
|
560
610
|
*/
|
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dsl/descriptor.ts
|
|
2
2
|
var e = Object.freeze({
|
|
3
|
-
SNAPSHOT: "
|
|
4
|
-
EVENT_STREAM: "
|
|
5
|
-
DATASET: "
|
|
3
|
+
SNAPSHOT: "snapshot",
|
|
4
|
+
EVENT_STREAM: "events",
|
|
5
|
+
DATASET: "dataset"
|
|
6
6
|
}), t = Object.freeze({
|
|
7
|
-
STRING: "
|
|
8
|
-
INTEGER: "
|
|
9
|
-
DECIMAL: "
|
|
10
|
-
BOOLEAN: "
|
|
11
|
-
OBJECT: "
|
|
7
|
+
STRING: "string",
|
|
8
|
+
INTEGER: "integer",
|
|
9
|
+
DECIMAL: "decimal",
|
|
10
|
+
BOOLEAN: "boolean",
|
|
11
|
+
OBJECT: "object"
|
|
12
12
|
}), n = /* @__PURE__ */ function(e) {
|
|
13
|
-
return e.UNKNOWN = "
|
|
13
|
+
return e.UNKNOWN = "unknown", e.NULL = "null", e.SCALAR = "scalar", e.OBJECT = "object", e.ARRAY = "array", e.UNION = "union", e;
|
|
14
14
|
}({}), r = /* @__PURE__ */ function(e) {
|
|
15
|
-
return e.LIST = "
|
|
15
|
+
return e.LIST = "list", e.PAGED = "paged", e.CURSOR = "cursor", e;
|
|
16
16
|
}({}), i = Object.freeze({
|
|
17
|
-
IDENTITY: "
|
|
18
|
-
AGGREGATE_ID: "
|
|
19
|
-
TENANT_ID: "
|
|
20
|
-
OWNER_ID: "
|
|
21
|
-
SPACE_ID: "
|
|
22
|
-
DELETED: "
|
|
23
|
-
EVENT_TIME: "
|
|
24
|
-
FIRST_EVENT_TIME: "
|
|
17
|
+
IDENTITY: "identity",
|
|
18
|
+
AGGREGATE_ID: "aggregate-id",
|
|
19
|
+
TENANT_ID: "tenant-id",
|
|
20
|
+
OWNER_ID: "owner-id",
|
|
21
|
+
SPACE_ID: "space-id",
|
|
22
|
+
DELETED: "deleted",
|
|
23
|
+
EVENT_TIME: "event-time",
|
|
24
|
+
FIRST_EVENT_TIME: "first-event-time"
|
|
25
25
|
}), a = Object.freeze({
|
|
26
|
-
CURSOR_UNIQUE_SORT: "
|
|
27
|
-
COUNT_REQUIRES_FILTER: "
|
|
28
|
-
STARTS_WITH_REQUIRES_PREFIX: "
|
|
29
|
-
PARALLEL_ARRAY_SORT: "
|
|
30
|
-
NULL_OR_EMPTY_AS_MISSING: "
|
|
31
|
-
ARRAY_EQUALITY: "
|
|
32
|
-
}), o =
|
|
33
|
-
|
|
26
|
+
CURSOR_UNIQUE_SORT: "cursor-unique-sort",
|
|
27
|
+
COUNT_REQUIRES_FILTER: "count-requires-filter",
|
|
28
|
+
STARTS_WITH_REQUIRES_PREFIX: "starts-with-requires-prefix",
|
|
29
|
+
PARALLEL_ARRAY_SORT: "parallel-array-sort",
|
|
30
|
+
NULL_OR_EMPTY_AS_MISSING: "null-or-empty-as-missing",
|
|
31
|
+
ARRAY_EQUALITY: "array-equality"
|
|
32
|
+
}), o = Object.freeze({
|
|
33
|
+
TEMPORAL_DATE: "temporal-date",
|
|
34
|
+
TEMPORAL_EPOCH: "temporal-epoch",
|
|
35
|
+
TEMPORAL_FORMATTED: "temporal-formatted",
|
|
36
|
+
DECIMAL: "decimal",
|
|
37
|
+
MONEY: "money",
|
|
38
|
+
DURATION: "duration",
|
|
39
|
+
REFERENCE: "reference"
|
|
40
|
+
}), s = /* @__PURE__ */ function(e) {
|
|
41
|
+
return e.DISPLAY = "display", e.CONFIDENTIAL = "confidential", e;
|
|
34
42
|
}({});
|
|
35
|
-
|
|
36
|
-
export { r as PagingMode, a as QueryConstraintTypes, i as QueryFieldRoles, e as QueryModels, n as QueryValueKind, t as QueryValueTypes, o as SensitivityLevel };
|
|
43
|
+
export { r as PagingMode, a as QueryConstraintTypes, i as QueryFieldRoles, e as QueryModels, o as QuerySemanticTypes, n as QueryValueKind, t as QueryValueTypes, s as SensitivityLevel };
|
|
37
44
|
|
|
38
45
|
//# sourceMappingURL=descriptor.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.es.js","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","SensitivityLevel","\"DISPLAY\"","\"CONFIDENTIAL\""],"sources":["../../src/dsl/descriptor.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// The capability descriptor `GET {aggregate}/{snapshot|event}/schema`\n// answers with: `wow.api.query.QueryModelDescriptor` of Wow 9.2, mirrored\n// from `wow-api/src/main/kotlin/me/ahoo/wow/api/query/descriptor/`.\n//\n// Kotlin leaves a null out of the JSON of every descriptor class annotated\n// `@JsonInclude(NON_NULL)`, so those properties are optional here; the\n// limits are not annotated and send `null`. A set the OpenAPI document\n// describes as a plain string is open: a known union plus `string & {}`.\n\nimport type {\n AggregationDatePart,\n AggregationDateUnit,\n DateDiffUnit,\n AggregationFunction,\n AggregationGroupType,\n AggregationMetricType,\n WindowFunction,\n} from './aggregation/types.js';\nimport type { DeletionState } from './deletionState.js';\nimport type { FilterOperator, SearchMode, TimeUnit } from './filter/index.js';\n\n/**\n * The query models Wow names in a descriptor's `model`. The set is open: a\n * server may register a model of its own, so a descriptor's `model` is a\n * {@link QueryModel}.\n */\nexport const QueryModels = Object.freeze({\n /** The snapshot query model: `{aggregate}/snapshot/*`. */\n SNAPSHOT: 'SNAPSHOT',\n /** The event stream query model: `{aggregate}/event/*`. */\n EVENT_STREAM: 'EVENT_STREAM',\n /** A declared dataset, such as a ClickHouse wide table: `dataset/{context}/{dataset}/*`. */\n DATASET: 'DATASET',\n} as const);\n\n/** A query model's name: one of {@link QueryModels}, or one a server added. */\nexport type QueryModel =\n (typeof QueryModels)[keyof typeof QueryModels] | (string & {});\n\n/**\n * The value types Wow names in a field's `types`. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryValueTypes = Object.freeze({\n /** A JSON string. */\n STRING: 'STRING',\n /** A whole number. */\n INTEGER: 'INTEGER',\n /** A number with a fraction. */\n DECIMAL: 'DECIMAL',\n /** `true` or `false`. */\n BOOLEAN: 'BOOLEAN',\n /** A JSON object. */\n OBJECT: 'OBJECT',\n} as const);\n\n/** A field's value type: one of {@link QueryValueTypes}, or one a server added. */\nexport type QueryValueType =\n (typeof QueryValueTypes)[keyof typeof QueryValueTypes] | (string & {});\n\n/** The structural shape of a field's value, sent as its `kind`. */\nexport enum QueryValueKind {\n /** Wow could not tell. */\n UNKNOWN = 'UNKNOWN',\n /** Always `null`. */\n NULL = 'NULL',\n /** A single string, number or boolean. */\n SCALAR = 'SCALAR',\n /** An object. */\n OBJECT = 'OBJECT',\n /** An array. */\n ARRAY = 'ARRAY',\n /** One of several of the above. */\n UNION = 'UNION',\n}\n\n/** The ways a model can be read page by page, listed in `record.paging`. */\nexport enum PagingMode {\n /** `list` and `listStream`: the first `limit` rows. */\n LIST = 'LIST',\n /** `paged`: numbered pages with a total. */\n PAGED = 'PAGED',\n /** `cursor`: forward-only pages after the last row seen. */\n CURSOR = 'CURSOR',\n}\n\n/**\n * The system roles Wow names in a field's `role`: the system fields a root\n * operator targets, and the model's times. The set is open, like\n * {@link QueryModels}.\n */\nexport const QueryFieldRoles = Object.freeze({\n /** The record's own identity, `record.identity`. */\n IDENTITY: 'IDENTITY',\n /** The aggregate id. */\n AGGREGATE_ID: 'AGGREGATE_ID',\n /** The tenant id. */\n TENANT_ID: 'TENANT_ID',\n /** The owner id. */\n OWNER_ID: 'OWNER_ID',\n /** The space id. */\n SPACE_ID: 'SPACE_ID',\n /** Whether the aggregate is deleted. */\n DELETED: 'DELETED',\n /**\n * When the record's events happened: a snapshot's last event\n * (`eventTime`), an event stream's events (`createTime`). `FIRST` and\n * `LAST` order by it when they name no `orderBy`. Wow 9.2 and later.\n */\n EVENT_TIME: 'EVENT_TIME',\n /**\n * When a snapshot's aggregate got its first event, i.e. was created\n * (`firstEventTime`). Wow 9.2 and later.\n */\n FIRST_EVENT_TIME: 'FIRST_EVENT_TIME',\n} as const);\n\n/** A system field's role: one of {@link QueryFieldRoles}, or one a server added. */\nexport type QueryFieldRole =\n (typeof QueryFieldRoles)[keyof typeof QueryFieldRoles] | (string & {});\n\n/**\n * The combination rules Wow names in a descriptor's `constraints`: rules\n * that no single capability shows. The set is open, like {@link QueryModels}.\n */\nexport const QueryConstraintTypes = Object.freeze({\n /**\n * A cursor's sort always ends with the identity field; the server appends\n * it (the constraint's `appended`) when the sort does not.\n */\n CURSOR_UNIQUE_SORT: 'CURSOR_UNIQUE_SORT',\n /** A count or paged query must not match every record. */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /** `STARTS_WITH` needs a non-empty, case-sensitive prefix. */\n STARTS_WITH_REQUIRES_PREFIX: 'STARTS_WITH_REQUIRES_PREFIX',\n /**\n * A sort names at most one of the constraint's `fields`: they are\n * array-valued and the storage cannot order by two independent arrays.\n * Fields on one array path, one nested in the other, may still combine.\n * A sort that breaks it is refused with `PARALLEL_ARRAY_SORT`.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * On the constraint's `fields`, a stored `null` or empty array cannot be\n * told from a missing field: `EXISTS` does not match it, `NOT_EXISTS` and\n * `IS_NULL` do, and `IS_EMPTY` also matches a missing or `null` field. A\n * presence filter on such a field answers \"has a non-empty value\", not\n * \"has the key\"; say so to a user who writes one.\n */\n NULL_OR_EMPTY_AS_MISSING: 'NULL_OR_EMPTY_AS_MISSING',\n /**\n * Model-wide, without `fields`: `EQ` and `NE` take only a scalar operand,\n * because the storage cannot compare a whole array. Match an array\n * field's elements instead (`IN`, `CONTAINS_ALL`, `ELEMENT_MATCH`); an `EQ` or\n * `NE` with an array operand is refused with `ARRAY_EQUALITY`.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n} as const);\n\n/** A constraint's type: one of {@link QueryConstraintTypes}, or one a server added. */\nexport type QueryConstraintType =\n | (typeof QueryConstraintTypes)[keyof typeof QueryConstraintTypes]\n | (string & {});\n\n/** A field that holds a calendar date. */\nexport interface TemporalDate {\n /** The discriminator. */\n type: 'TEMPORAL_DATE';\n}\n\n/** A field that holds a number of time units since the epoch. */\nexport interface TemporalEpoch {\n /** The discriminator. */\n type: 'TEMPORAL_EPOCH';\n /** The unit the number counts; milliseconds when absent. */\n timeUnit?: TimeUnit;\n}\n\n/** A field that holds a time written as text in a `java.time` pattern. */\nexport interface TemporalFormatted {\n /** The discriminator. */\n type: 'TEMPORAL_FORMATTED';\n /** The `java.time` pattern, such as `yyyy-MM-dd`. */\n pattern: string;\n}\n\n/**\n * A number field meant as a fixed-point decimal with `scale` fraction\n * digits: format and total it at that precision. Declared on the model\n * (`@QueryDecimal`), never inferred. Wow 9.2 and later.\n */\nexport interface NumericDecimal {\n /** The discriminator. */\n type: 'DECIMAL';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n}\n\n/**\n * A number field meant as an amount of money, in exactly one of a fixed\n * ISO 4217 `currency` or the currency held by the sibling string field\n * `currencyField` (a property of the same object or element). `scale` is\n * always sent: with a fixed currency the server resolves an omitted one to\n * that currency's standard fraction digits (2 for CNY, 0 for JPY).\n * Amounts in different currencies must not be totalled together. Declared\n * on the model (`@QueryMoney`), never inferred. Wow 9.2 and later.\n */\nexport type NumericMoney = {\n /** The discriminator. */\n type: 'MONEY';\n /** The number of digits after the decimal point, 0 or more. */\n scale: number;\n} & (\n | {\n /** The fixed ISO 4217 currency code, such as `CNY`. */\n currency: string;\n currencyField?: undefined;\n }\n | {\n currency?: undefined;\n /** The sibling property that holds each value's currency code. */\n currencyField: string;\n }\n);\n\n/**\n * A number field that is a length of time counted in `timeUnit`, such as a\n * timeout in seconds: format it as a duration. Declared on the model\n * (`@QueryDuration`), never inferred. Wow 9.2 and later.\n */\nexport interface DurationSemantic {\n /** The discriminator. */\n type: 'DURATION';\n /** The unit the number counts; always sent. */\n timeUnit: TimeUnit;\n}\n\n/**\n * A field whose value is the id of an aggregate, to look it up and link to\n * it: either a fixed aggregate, `contextName` and `aggregateName`, or per\n * record the aggregate the sibling string fields `contextNameField` and\n * `aggregateNameField` name (as in an `AggregateId`). The id is always the\n * aggregate's own. Declared on the model (`@QueryReference`), or inferred\n * for an `AggregateId`. Wow 9.2 and later.\n */\nexport type ReferenceSemantic = {\n /** The discriminator. */\n type: 'REFERENCE';\n} & (\n | {\n /** The referenced aggregate's bounded context. */\n contextName: string;\n /** The referenced aggregate's name. */\n aggregateName: string;\n contextNameField?: undefined;\n aggregateNameField?: undefined;\n }\n | {\n contextName?: undefined;\n aggregateName?: undefined;\n /** The sibling property that holds each value's bounded context. */\n contextNameField: string;\n /** The sibling property that holds each value's aggregate name. */\n aggregateNameField: string;\n }\n);\n\n/**\n * What a field's value means beyond its type, sent as its `semantic`: one\n * of the three temporal kinds, which the relative time filters (`TODAY`,\n * `RECENT_DAYS`, …) and date histograms need; one of the two numeric\n * formats, which say how a number is read and displayed; a duration; or a\n * reference to an aggregate. A field has one; an array field's is its\n * items'.\n *\n * The union grows in minor releases, as the server learns a semantic, and a\n * server newer than this client may send a `type` not listed here. The\n * descriptor is read as JSON, not parsed, so it arrives as it is: keep a\n * `default` branch in a `switch` over `type`, and treat a `type` you do not\n * know as no semantic at all. The union stays closed so that narrowing on\n * `type` still works.\n */\nexport type QuerySemanticType =\n | TemporalDate\n | TemporalEpoch\n | TemporalFormatted\n | NumericDecimal\n | NumericMoney\n | DurationSemantic\n | ReferenceSemantic;\n\n/** One declared value of an enum field, with its description when it has one. */\nexport interface EnumValueDescriptor {\n /** The value as it is stored and filtered by. */\n value: unknown;\n /**\n * What the value means, when the model describes it: set by the `enum`\n * entry of the model's declaration file.\n */\n description?: string;\n}\n\n/**\n * How much Wow protects a sensitive field's raw value, sent as its\n * `sensitivity.level`. Both levels mask the value in every query result;\n * they differ in what a query may do with the raw value.\n */\nexport enum SensitivityLevel {\n /**\n * Masked in results. Filters and paged sorts still compare the raw value,\n * unless the server turned that off; grouping, `ANY`, field metrics,\n * arithmetic references and cursor sorts are refused.\n */\n DISPLAY = 'DISPLAY',\n /**\n * Masked in results and never compared: no filter, sort, search, grouping\n * or metric may name it.\n */\n CONFIDENTIAL = 'CONFIDENTIAL',\n}\n\n/**\n * Why a field is deprecated. The field can still be queried, but new\n * queries and view definitions should avoid it.\n */\nexport interface QueryDeprecation {\n /** Why, or what to use instead; absent when the declaration gave no reason. */\n message?: string;\n}\n\n/** How a sensitive field is protected. */\nexport interface SensitivityDescriptor {\n /** How much its raw value is protected. */\n level: SensitivityLevel;\n /**\n * Whether filters and paged sorts may still compare its raw value: `false`\n * for {@link SensitivityLevel.CONFIDENTIAL}, and for\n * {@link SensitivityLevel.DISPLAY} when the server turned comparison off.\n * A field that is not comparable lists no filter operators, has\n * `sort.paged` `false` and is left out of `record.search`; naming it in a\n * filter, sort or search is refused with `PROTECTED_COMPARISON`.\n */\n comparable: boolean;\n}\n\n/** The filter operators a field admits. */\nexport interface FieldFilterDescriptor {\n /**\n * Each operator admitted on this field when used alone; empty when none,\n * as for a sensitive field that is not comparable.\n */\n operators: FilterOperator[];\n}\n\n/** Where a field may appear in a sort. */\nexport interface FieldSortDescriptor {\n /** In the sort of a list or paged query; never for a field that is not comparable. */\n paged: boolean;\n /** In the sort of a cursor query. */\n cursor: boolean;\n}\n\n/** How a field may be used in an aggregation. */\nexport interface FieldAggregateDescriptor {\n /**\n * The group types it may be grouped by; a time field lists both\n * `DATE_HISTOGRAM` and `DATE_PART`.\n */\n groups: (AggregationGroupType | (string & {}))[];\n /** Whether a terms group on it may set `missingKey`. */\n missingKey: boolean;\n /** The numeric functions (`SUM`, `AVG`, …) it may feed. */\n functions: (AggregationFunction | (string & {}))[];\n /** Whether it may feed a `DISTINCT_COUNT` metric. */\n distinctCount: boolean;\n /** Whether it may feed a `PERCENTILE` metric. */\n percentile: boolean;\n /** Whether it may feed an `ANY` metric. */\n any: boolean;\n /** Whether a `FIRST` or `LAST` metric may read its value. */\n firstLast: boolean;\n /** Whether it may appear in an arithmetic expression. */\n expressionInput: boolean;\n /** Whether a metric's filter may name it. */\n inMetricFilter: boolean;\n}\n\n/** One queryable field, by the logical path a query names it with. */\nexport interface FieldDescriptor {\n /** The logical path, such as `state.items.productId`. */\n path: string;\n /** The system role of a system field; absent on ordinary fields. */\n role?: QueryFieldRole;\n /** The value types it holds. */\n types: QueryValueType[];\n /** The structural shape of its value. */\n kind: QueryValueKind;\n /** Whether it may be `null`. */\n nullable: boolean;\n /** What its value means beyond its type; absent when nothing more. */\n semantic?: QuerySemanticType;\n /** Its declared values; never listed for a protected field. */\n enum?: EnumValueDescriptor[];\n /** Its description, when the model gives one. */\n description?: string;\n /** How it is protected; absent when it is not sensitive. */\n sensitivity?: SensitivityDescriptor;\n /** Whether a projection may select it. */\n project: boolean;\n /** The filter operators it admits. */\n filter: FieldFilterDescriptor;\n /** Where it may be sorted by. */\n sort: FieldSortDescriptor;\n /** How it may be aggregated; absent when it cannot be at all. */\n aggregate?: FieldAggregateDescriptor;\n /**\n * The element (array field) it lives in, by path; absent at the record\n * level. A filter on it goes inside `ELEMENT_MATCH` on that element.\n */\n scope?: string;\n /**\n * Set when the field is deprecated: still queryable, but new queries\n * should avoid it. An object, so it is truthy even without a message.\n */\n deprecated?: QueryDeprecation;\n /**\n * Other paths a query may name this field by, sorted; empty when none.\n * The server replaces an alias with `path` before it checks and runs a\n * query, so results, projections and errors use `path`, and an alias is\n * never listed as a field of its own. A variant's field lists them\n * relative to the element, like its `path`.\n */\n aliases: string[];\n}\n\n/** An array field whose elements can be filtered or aggregated one by one. */\nexport interface ElementDescriptor {\n /** The array field's logical path. */\n path: string;\n /** Whether `ELEMENT_MATCH` may filter its elements. */\n filter: boolean;\n /** Whether an aggregation may run over its elements. */\n aggregate: boolean;\n /**\n * Full-text search on its fields: a `SEARCH` that names them, relative\n * to the element, inside an `ELEMENT_MATCH` on it. Absent when the\n * storage can search none of them, as on MongoDB.\n */\n search?: SearchDescriptor;\n}\n\n/**\n * The fields under a map's dynamic keys, written with `{key}` in place of\n * the key: any key matches, except those in `excludedKeys`. Each pattern\n * has one entry, resolved as the server resolves a concrete key: a pattern\n * whose values are arrays is one `ARRAY` entry, its items implicit.\n */\nexport interface DynamicFieldDescriptor {\n /** The path pattern, such as `state.attributes.{key}`. */\n pattern: string;\n /** The value types they hold. */\n types: QueryValueType[];\n /** The structural shape of their values. */\n kind: QueryValueKind;\n /** The filter operators they admit. */\n filter: FieldFilterDescriptor;\n /**\n * The map's keys that are declared as fields of their own and so are not\n * covered by this pattern; absent when there are none. For\n * `state.attributes.{key}` with `state.attributes.color` declared, it is\n * `['color']`: a filter on `state.attributes.color` takes that field's\n * entry in `fields`, with its own operators, not this pattern's.\n */\n excludedKeys?: string[];\n}\n\n/**\n * Full-text search in one scope: the record's (`record.search`) or an\n * element's (`elements[].search`).\n */\nexport interface SearchDescriptor {\n /**\n * For the record, the modes of a model-wide `SEARCH` (without fields);\n * empty when one of its fields is not comparable, since a search across\n * the model would match that field. For an element, the modes every\n * listed field accepts.\n */\n modes: SearchMode[];\n /**\n * The fields a `SEARCH` may name, by full logical path; never one that is\n * not comparable. For the record, only record-level fields, never one\n * inside an element; for an element, its own fields, which the query\n * writes relative to the element.\n */\n fields: string[];\n}\n\n/** What holds for the model's records as a whole. */\nexport interface RecordDescriptor {\n /** The logical path of the field that identifies a record. */\n identity: string;\n /** The ways the model can be read page by page. */\n paging: PagingMode[];\n /** The deletion scope a query without one gets; absent when the model has none. */\n defaultScope?: DeletionState;\n /**\n * Operators that name no field of their own: the system-field ones, such\n * as `ID` or `TENANT_ID`, and `EXPRESSION`, whose expression names its\n * fields, where the server allows expensive operators.\n */\n rootOperators: FilterOperator[];\n /** Model-wide full-text search; absent when the model offers none. */\n search?: SearchDescriptor;\n}\n\n/** The fixed limits of an aggregation query. */\nexport interface AggregationLimitsDescriptor {\n /** Most groups in `groupBy`. */\n maxGroups: number;\n /** Most metrics. */\n maxMetrics: number;\n /** Most elements an aggregation runs over. */\n maxElements: number;\n /** Largest `limit` on the result rows. */\n maxLimit: number;\n /** Deepest arithmetic expression. */\n maxExpressionDepth: number;\n /** Most nodes in one arithmetic expression. */\n maxExpressionNodes: number;\n /**\n * 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":";AAuCA,IAAaA,IAAc,OAAO,OAAO;CAEvC,UAAU;CAEV,cAAc;CAEd,SAAS;AACX,CAAU,GAUGC,IAAkB,OAAO,OAAO;CAE3C,QAAQ;CAER,SAAS;CAET,SAAS;CAET,SAAS;CAET,QAAQ;AACV,CAAU,GAOEC,IAAL,yBAAA,GAAA;QAEL,EAAAC,UAAA,WAEA,EAAAC,OAAA,QAEA,EAAAC,SAAA,UAEA,EAAAC,SAAA,UAEA,EAAAC,QAAA,SAEA,EAAAC,QAAA;AACF,EAAA,CAAA,CAAA,GAGYC,IAAL,yBAAA,GAAA;QAEL,EAAAC,OAAA,QAEA,EAAAC,QAAA,SAEA,EAAAC,SAAA;AACF,EAAA,CAAA,CAAA,GAOaC,IAAkB,OAAO,OAAO;CAE3C,UAAU;CAEV,cAAc;CAEd,WAAW;CAEX,UAAU;CAEV,UAAU;CAEV,SAAS;CAMT,YAAY;CAKZ,kBAAkB;AACpB,CAAU,GAUGC,IAAuB,OAAO,OAAO;CAKhD,oBAAoB;CAEpB,uBAAuB;CAEvB,6BAA6B;CAO7B,qBAAqB;CAQrB,0BAA0B;CAO1B,gBAAgB;AAClB,CAAU,GAsJEC,IAAL,yBAAA,GAAA;QAML,EAAAC,UAAA,WAKA,EAAAC,eAAA;AACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"descriptor.es.js","names":["QueryModels","QueryValueTypes","QueryValueKind","\"UNKNOWN\"","\"NULL\"","\"SCALAR\"","\"OBJECT\"","\"ARRAY\"","\"UNION\"","PagingMode","\"LIST\"","\"PAGED\"","\"CURSOR\"","QueryFieldRoles","QueryConstraintTypes","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"}
|
package/dist/dsl/field.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.cjs","names":["QUERY_FIELD_PATTERN","queryField","field"],"sources":["../../src/dsl/field.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/**\n * Wow's `QueryField` pattern, shared by every place that names a path.\n *\n * Internal on purpose: no entry re-exports this module, so the\n * validator stays an implementation detail rather than becoming public API\n * that has to be documented and kept. A filter, a sort and a projection all\n * hold paths, and Kotlin wraps all three in `QueryField`, so they agree here\n * rather than each inventing its own idea of a path.\n */\nconst QUERY_FIELD_PATTERN =\n /^@?[A-Za-z_][A-Za-z0-9_-]*(\\.(?:@?[A-Za-z_][A-Za-z0-9_-]*|[0-9]+))*$/;\n\n/** Admits a field path, the way `QueryField`'s `init` does. */\nexport function queryField<FIELDS extends string>(field: FIELDS): FIELDS {\n if (typeof field !== 'string' || !QUERY_FIELD_PATTERN.test(field)) {\n throw new TypeError(`Query field is invalid: [${String(field)}].`);\n }\n return field;\n}\n"],"mappings":"AAsBA,IAAMA,EACJ,uEAGF,SAAgBC,EAAkC,EAAuB,CACvE,GAAI,OAAOC,GAAU,UAAY,CAACF,EAAoB,KAAKE,CAAK,EAC9D,MAAU,UAAU,4BAA4B,OAAOA,CAAK,EAAE,GAAG,EAEnE,OAAOA,CACT"}
|
|
1
|
+
{"version":3,"file":"field.cjs","names":["QUERY_FIELD_PATTERN","queryField","field"],"sources":["../../src/dsl/field.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/**\n * Wow's `QueryField` pattern, shared by every place that names a path.\n *\n * Internal on purpose: no entry re-exports this module, so the\n * validator stays an implementation detail rather than becoming public API\n * that has to be documented and kept. A filter, a sort and a projection all\n * hold paths, and Kotlin wraps all three in `QueryField`, so they agree here\n * rather than each inventing its own idea of a path.\n */\nconst QUERY_FIELD_PATTERN =\n /^@?[A-Za-z_][A-Za-z0-9_-]*(\\.(?:@?[A-Za-z_][A-Za-z0-9_-]*|[0-9]+))*$/;\n\n/** Admits a field path, the way `QueryField`'s `init` does. */\nexport function queryField<FIELDS extends string>(field: FIELDS): FIELDS {\n if (typeof field !== 'string' || !QUERY_FIELD_PATTERN.test(field)) {\n throw new TypeError(`Query field is invalid: [${String(field)}].`);\n }\n return field;\n}\n"],"mappings":"AAsBA,IAAMA,EACJ,uEAGF,SAAgBC,EAAkC,EAAuB,CACvE,GAAI,OAAOC,GAAU,UAAY,CAACF,EAAoB,KAAKE,CAAK,EAC9D,MAAU,UAAU,4BAA4B,OAAOA,CAAK,EAAE,GAAG,EAEnE,OAAOA,CACT,C"}
|
package/dist/dsl/field.es.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dsl/field.ts
|
|
2
2
|
var e = /^@?[A-Za-z_][A-Za-z0-9_-]*(\.(?:@?[A-Za-z_][A-Za-z0-9_-]*|[0-9]+))*$/;
|
|
3
3
|
function t(t) {
|
|
4
4
|
if (typeof t != "string" || !e.test(t)) throw TypeError(`Query field is invalid: [${String(t)}].`);
|
|
5
5
|
return t;
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { t as queryField };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=field.es.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./operator.cjs"),t=require("../aggregation/types.cjs"),
|
|
1
|
+
const e=require("./operator.cjs"),t=require("../constantName.cjs"),n=require("../aggregation/types.cjs"),r=require("../aggregation/expressionTrees.cjs"),i=require("../deletionState.cjs"),a=require("../field.cjs"),o=require("./scope.cjs"),s=require("./validate.cjs");function c(e,n){return{op:e,value:s.requiredString(`${t.constantName(e)} value`,n)}}function l(e,n){return s.requireNonEmpty(`${t.constantName(e)} values`,n),n.forEach(n=>s.requiredString(`${t.constantName(e)} value`,n)),{op:e,values:[...n]}}function u(e,n){return s.requireNonEmpty(`${t.constantName(e)} operands`,n),{op:e,operands:[...n]}}function d(e,t,n){return{op:e,field:a.queryField(t),value:s.filterLiteral(n,!0)}}function f(e,t,n){return{op:e,field:a.queryField(t),value:s.filterLiteral(n,!1)}}function p(e,n,r,i){return s.validateStringComparison(i),{op:e,field:a.queryField(n),value:s.requiredString(`${t.constantName(e)} value`,r),stringComparison:i}}function m(e,n,r){return s.requireNonEmpty(`${t.constantName(e)} values`,r),r.forEach(e=>s.filterLiteral(e,!1)),{op:e,field:a.queryField(n),values:[...r]}}function h(e,t){return{op:e,field:a.queryField(t)}}function g(e,t,n){return{...s.validateRelativeTimeOptions(n),op:e,field:a.queryField(t)}}function _(e,t,n,r){return s.validateDays(e,n),{...s.validateRelativeTimeOptions(r),op:e,field:a.queryField(t),days:n}}function v(e,t,n,r){return s.requireDuration(e,n),{...s.validateRelativeTimeOptions(r),op:e,field:a.queryField(t),offset:n}}function y(t){return u(e.FilterOperator.AND,t)}function b(t){return u(e.FilterOperator.OR,t)}function x(t){return u(e.FilterOperator.NOR,t)}function S(t,n){if(typeof t!=`string`||!t.trim())throw TypeError(`SEARCH query cannot be blank.`);if(n!==void 0&&(typeof n!=`object`||!n||Array.isArray(n)))throw TypeError(`SEARCH options must be a non-null object.`);let{fields:r=[],mode:i=e.SearchMode.TERMS}=n??{};if(!Object.values(e.SearchMode).includes(i))throw TypeError(`SEARCH mode is invalid: [${String(i)}].`);return{op:e.FilterOperator.SEARCH,query:t,mode:i,fields:r.map(a.queryField)}}var C={matchAll(){return{op:e.FilterOperator.MATCH_ALL}},matchNone(){return{op:e.FilterOperator.MATCH_NONE}},id(t){return c(e.FilterOperator.ID,t)},ids(t){return l(e.FilterOperator.IDS,t)},aggregateId(t){return c(e.FilterOperator.AGGREGATE_ID,t)},aggregateIds(t){return l(e.FilterOperator.AGGREGATE_IDS,t)},tenantId(t){return c(e.FilterOperator.TENANT_ID,t)},ownerId(t){return c(e.FilterOperator.OWNER_ID,t)},spaceId(t){return c(e.FilterOperator.SPACE_ID,t)},and:y,or:b,nor:x,eq(t,n){return d(e.FilterOperator.EQ,t,n)},ne(t,n){return d(e.FilterOperator.NE,t,n)},gt(t,n){return f(e.FilterOperator.GT,t,n)},gte(t,n){return f(e.FilterOperator.GTE,t,n)},lt(t,n){return f(e.FilterOperator.LT,t,n)},lte(t,n){return f(e.FilterOperator.LTE,t,n)},contains(t,n,r=e.StringComparison.CASE_SENSITIVE){return p(e.FilterOperator.CONTAINS,t,n,r)},startsWith(t,n,r=e.StringComparison.CASE_SENSITIVE){return p(e.FilterOperator.STARTS_WITH,t,n,r)},endsWith(t,n,r=e.StringComparison.CASE_SENSITIVE){return p(e.FilterOperator.ENDS_WITH,t,n,r)},isIn(t,n){return m(e.FilterOperator.IN,t,n)},notIn(t,n){return m(e.FilterOperator.NOT_IN,t,n)},containsAll(t,n){return m(e.FilterOperator.CONTAINS_ALL,t,n)},between(t,n,r){return{op:e.FilterOperator.BETWEEN,field:a.queryField(t),lowerBound:s.filterLiteral(n,!1),upperBound:s.filterLiteral(r,!1)}},isEmpty(t){return h(e.FilterOperator.IS_EMPTY,t)},isEmptyString(t){return h(e.FilterOperator.IS_EMPTY_STRING,t)},isNotEmptyString(t){return h(e.FilterOperator.IS_NOT_EMPTY_STRING,t)},isNull(t){return h(e.FilterOperator.IS_NULL,t)},isNotNull(t){return h(e.FilterOperator.IS_NOT_NULL,t)},exists(t){return h(e.FilterOperator.EXISTS,t)},notExists(t){return h(e.FilterOperator.NOT_EXISTS,t)},deletion(t){if(t!==i.DeletionState.ACTIVE&&t!==i.DeletionState.DELETED&&t!==i.DeletionState.ALL)throw TypeError(`Deletion state is invalid: [${String(t)}].`);return{op:e.FilterOperator.DELETION,state:t}},elementMatch(t,n){return o.requireElementScopedFilter(n,`ELEMENT_MATCH predicate`),{op:e.FilterOperator.ELEMENT_MATCH,field:a.queryField(t),predicate:n}},search:S,today(t,n={}){return g(e.FilterOperator.TODAY,t,n)},beforeToday(t,n,r={}){let i=s.requireLocalTime(n);return{...s.validateRelativeTimeOptions(r),op:e.FilterOperator.BEFORE_TODAY,field:a.queryField(t),time:i}},tomorrow(t,n={}){return g(e.FilterOperator.TOMORROW,t,n)},thisWeek(t,n={}){return g(e.FilterOperator.THIS_WEEK,t,n)},nextWeek(t,n={}){return g(e.FilterOperator.NEXT_WEEK,t,n)},lastWeek(t,n={}){return g(e.FilterOperator.LAST_WEEK,t,n)},thisMonth(t,n={}){return g(e.FilterOperator.THIS_MONTH,t,n)},lastMonth(t,n={}){return g(e.FilterOperator.LAST_MONTH,t,n)},yesterday(t,n={}){return g(e.FilterOperator.YESTERDAY,t,n)},nextMonth(t,n={}){return g(e.FilterOperator.NEXT_MONTH,t,n)},lastYear(t,n={}){return g(e.FilterOperator.LAST_YEAR,t,n)},thisYear(t,n={}){return g(e.FilterOperator.THIS_YEAR,t,n)},nextYear(t,n={}){return g(e.FilterOperator.NEXT_YEAR,t,n)},recentDays(t,n,r={}){return _(e.FilterOperator.RECENT_DAYS,t,n,r)},earlierDays(t,n,r={}){return _(e.FilterOperator.EARLIER_DAYS,t,n,r)},beforeNow(t,n=`PT0S`,r={}){return v(e.FilterOperator.BEFORE_NOW,t,n,r)},afterNow(t,n=`PT0S`,r={}){return v(e.FilterOperator.AFTER_NOW,t,n,r)},expression(t,i,a){if(!Number.isFinite(a))throw TypeError(`EXPRESSION value must be finite.`);if(!Object.values(n.ComparisonOperator).includes(i))throw TypeError(`EXPRESSION comparison is invalid: [${String(i)}].`);if(r.expressionFields(t).length===0)throw TypeError(`EXPRESSION must read at least one field.`);return r.requireValidExpressionTrees([t]),{op:e.FilterOperator.EXPRESSION,expression:t,comparison:i,value:a}}};exports.filter=C;
|
|
2
2
|
//# sourceMappingURL=builders.cjs.map
|