@ahoo-wang/wow-client 10.0.0-alpha.6 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -23
- package/README.zh-CN.md +67 -19
- package/dist/commands.cjs +1 -1
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +134 -61
- package/dist/commands.d.ts +134 -61
- package/dist/commands.es.js +129 -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 +99 -42
- package/dist/dsl/descriptor.d.ts +99 -42
- package/dist/dsl/descriptor.es.js +37 -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 +37 -95
- package/dist/manifest.d.ts +37 -95
- package/dist/manifest.es.js +12 -7
- package/dist/manifest.es.js.map +1 -1
- package/dist/manifestTypes.d.cts +195 -0
- package/dist/manifestTypes.d.ts +195 -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 +68 -19
- package/dist/wait.d.ts +68 -19
- package/dist/wait.es.js +61 -14
- 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 +101 -50
- package/dist/wire.d.ts +101 -50
- package/dist/wire.es.js +17 -6
- package/dist/wire.es.js.map +1 -1
- package/package.json +23 -3
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dsl/queryErrorCodes.ts
|
|
2
2
|
var e = Object.freeze({
|
|
3
|
-
INVALID_JSON: "
|
|
4
|
-
BODY_NOT_OBJECT: "
|
|
5
|
-
EMPTY_BODY: "
|
|
6
|
-
UNKNOWN_PROPERTY: "
|
|
7
|
-
UNKNOWN_TYPE: "
|
|
8
|
-
UNKNOWN_VALUE: "
|
|
9
|
-
INVALID_VALUE: "
|
|
10
|
-
INVALID_REQUEST: "
|
|
11
|
-
CURSOR_SORT_DUPLICATE: "
|
|
12
|
-
CURSOR_SORT_TOO_MANY: "
|
|
13
|
-
INVALID_CURSOR: "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
3
|
+
INVALID_JSON: "invalid-json",
|
|
4
|
+
BODY_NOT_OBJECT: "body-not-object",
|
|
5
|
+
EMPTY_BODY: "empty-body",
|
|
6
|
+
UNKNOWN_PROPERTY: "unknown-property",
|
|
7
|
+
UNKNOWN_TYPE: "unknown-type",
|
|
8
|
+
UNKNOWN_VALUE: "unknown-value",
|
|
9
|
+
INVALID_VALUE: "invalid-value",
|
|
10
|
+
INVALID_REQUEST: "invalid-request",
|
|
11
|
+
CURSOR_SORT_DUPLICATE: "cursor-sort-duplicate",
|
|
12
|
+
CURSOR_SORT_TOO_MANY: "cursor-sort-too-many",
|
|
13
|
+
INVALID_CURSOR: "invalid-cursor",
|
|
14
|
+
STREAM_NOT_RESUMABLE: "stream-not-resumable",
|
|
15
|
+
SIZE_OUT_OF_RANGE: "size-out-of-range",
|
|
16
|
+
FILTER_TOO_LARGE: "filter-too-large",
|
|
17
|
+
EXPENSIVE_OPERATOR_DISABLED: "expensive-operator-disabled",
|
|
18
|
+
COUNT_REQUIRES_FILTER: "count-requires-filter",
|
|
19
|
+
RESIDUAL_GROUPS_EXCEEDED: "residual-groups-exceeded",
|
|
20
|
+
TOO_MANY_GROUPS: "too-many-groups",
|
|
21
|
+
EXPLICIT_ENTRY_REQUIRED: "explicit-entry-required",
|
|
22
|
+
REPLAY_TOO_LONG: "replay-too-long",
|
|
23
|
+
UNKNOWN_FIELD: "unknown-field",
|
|
24
|
+
UNSUPPORTED_CAPABILITY: "unsupported-capability",
|
|
25
|
+
ELEMENT_SCOPE_REQUIRED: "element-scope-required",
|
|
26
|
+
VALUE_MISMATCH: "value-mismatch",
|
|
27
|
+
NOT_COLLECTION: "not-collection",
|
|
28
|
+
NOT_SINGLE_STRING: "not-single-string",
|
|
29
|
+
MODEL_SEARCH_UNSUPPORTED: "model-search-unsupported",
|
|
30
|
+
CURSOR_NOT_ALLOWED: "cursor-not-allowed",
|
|
31
|
+
PROTECTED_AGGREGATION: "protected-aggregation",
|
|
32
|
+
PROTECTED_COMPARISON: "protected-comparison",
|
|
33
|
+
MISSING_KEY_REQUIRES_STRING: "missing-key-requires-string",
|
|
34
|
+
ANY_REQUIRES_SINGLE_VALUE: "any-requires-single-value",
|
|
35
|
+
INCOMPLETE_PROJECTION: "incomplete-projection",
|
|
36
|
+
METRIC_FILTER_SEARCH: "metric-filter-search",
|
|
37
|
+
METRIC_FILTER_ELEMENT_MATCH: "metric-filter-element-match",
|
|
38
|
+
METRIC_FILTER_ARRAY_FIELD: "metric-filter-array-field",
|
|
39
|
+
NOT_PROJECTABLE: "not-projectable",
|
|
40
|
+
EVENT_PROJECTION_TYPE_REQUIRED: "event-projection-type-required",
|
|
41
|
+
TEMPORAL_REPRESENTATION_REQUIRED: "temporal-representation-required",
|
|
42
|
+
TEMPORAL_CONFIGURATION_CONFLICT: "temporal-configuration-conflict",
|
|
43
|
+
PARALLEL_ARRAY_SORT: "parallel-array-sort",
|
|
44
|
+
ARRAY_EQUALITY: "array-equality",
|
|
45
|
+
FIRST_LAST_REQUIRES_SINGLE_VALUE: "first-last-requires-single-value",
|
|
46
|
+
FIRST_LAST_REQUIRES_ORDER_BY: "first-last-requires-order-by",
|
|
47
|
+
TEMPORAL_AGGREGATION_UNSUPPORTED: "temporal-aggregation-unsupported",
|
|
48
|
+
SORT_TOO_MANY: "sort-too-many",
|
|
49
|
+
SORT_FIELD_DUPLICATE: "sort-field-duplicate",
|
|
50
|
+
IDENTITY_UNDEFINED: "identity-undefined",
|
|
51
|
+
STORAGE_UNSUPPORTED: "storage-unsupported",
|
|
52
|
+
PREVIOUS_UNSHIFTABLE: "previous-unshiftable"
|
|
51
53
|
});
|
|
52
|
-
//#endregion
|
|
53
54
|
export { e as QueryErrorCodes };
|
|
54
55
|
|
|
55
56
|
//# sourceMappingURL=queryErrorCodes.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryErrorCodes.es.js","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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 * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'INVALID_JSON',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'BODY_NOT_OBJECT',\n /** The body is empty. */\n EMPTY_BODY: 'EMPTY_BODY',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'UNKNOWN_PROPERTY',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'UNKNOWN_TYPE',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'UNKNOWN_VALUE',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'INVALID_VALUE',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'INVALID_REQUEST',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'CURSOR_SORT_DUPLICATE',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'CURSOR_SORT_TOO_MANY',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'INVALID_CURSOR',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'SIZE_OUT_OF_RANGE',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'FILTER_TOO_LARGE',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'EXPENSIVE_OPERATOR_DISABLED',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'COUNT_REQUIRES_FILTER',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'RESIDUAL_GROUPS_EXCEEDED',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'EXPLICIT_ENTRY_REQUIRED',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'REPLAY_TOO_LONG',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'UNKNOWN_FIELD',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'UNSUPPORTED_CAPABILITY',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'ELEMENT_SCOPE_REQUIRED',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'VALUE_MISMATCH',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'NOT_COLLECTION',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'NOT_SINGLE_STRING',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'MODEL_SEARCH_UNSUPPORTED',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'CURSOR_NOT_ALLOWED',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'PROTECTED_AGGREGATION',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'PROTECTED_COMPARISON',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'MISSING_KEY_REQUIRES_STRING',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'ANY_REQUIRES_SINGLE_VALUE',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'INCOMPLETE_PROJECTION',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'METRIC_FILTER_SEARCH',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'METRIC_FILTER_ELEMENT_MATCH',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'METRIC_FILTER_ARRAY_FIELD',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'NOT_PROJECTABLE',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'EVENT_PROJECTION_TYPE_REQUIRED',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'TEMPORAL_REPRESENTATION_REQUIRED',\n /** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */\n TEMPORAL_CONFIGURATION_CONFLICT: 'TEMPORAL_CONFIGURATION_CONFLICT',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'PARALLEL_ARRAY_SORT',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'ARRAY_EQUALITY',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'FIRST_LAST_REQUIRES_SINGLE_VALUE',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'FIRST_LAST_REQUIRES_ORDER_BY',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'TEMPORAL_AGGREGATION_UNSUPPORTED',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'SORT_TOO_MANY',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'SORT_FIELD_DUPLICATE',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'IDENTITY_UNDEFINED',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'STORAGE_UNSUPPORTED',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'PREVIOUS_UNSHIFTABLE',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":";AAkCA,IAAaA,IAAkB,OAAO,OAAO;CAE3C,cAAc;CAEd,iBAAiB;CAEjB,YAAY;CAEZ,kBAAkB;CAElB,cAAc;CAEd,eAAe;CAEf,eAAe;CAEf,iBAAiB;CAEjB,uBAAuB;CAEvB,sBAAsB;CAKtB,gBAAgB;CAMhB,mBAAmB;CAKnB,kBAAkB;CAOlB,6BAA6B;CAK7B,uBAAuB;CAMvB,0BAA0B;CAK1B,yBAAyB;CAMzB,iBAAiB;CAEjB,eAAe;CAEf,wBAAwB;CAExB,wBAAwB;CAExB,gBAAgB;CAEhB,gBAAgB;CAEhB,mBAAmB;CAEnB,0BAA0B;CAE1B,oBAAoB;CAEpB,uBAAuB;CAMvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,uBAAuB;CAEvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,iBAAiB;CAEjB,gCAAgC;CAEhC,kCAAkC;CAElC,iCAAiC;CAMjC,qBAAqB;CAMrB,gBAAgB;CAKhB,kCAAkC;CAMlC,8BAA8B;CAM9B,kCAAkC;CAElC,eAAe;CAEf,sBAAsB;CAKtB,oBAAoB;CAMpB,qBAAqB;CAOrB,sBAAsB;AACxB,CAAU"}
|
|
1
|
+
{"version":3,"file":"queryErrorCodes.es.js","names":["QueryErrorCodes"],"sources":["../../src/dsl/queryErrorCodes.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 * The codes the violations of a rejected query carry: which rule the request\n * broke, stable where the human text is not. A query route answers a query it\n * refuses with the problem `wow.query.invalid` (`WowProblemError`), each of\n * whose `violations` names one of these codes and where it applies.\n *\n * Mirrors `QueryErrorCodes` in\n * `api/query-api/src/main/kotlin/me/ahoo/wow/api/query/QueryErrorCodes.kt`.\n * The list is open: Wow adds codes and never renames or reuses one, so a\n * client treats a code it does not know as a generic rejection and shows the\n * violation's message. {@link QueryErrorCode} admits those codes too.\n *\n * A violation's `path` locates it three ways:\n * - decoding the request body: the JSON path of the offending value, such as\n * `filter.state` or `metrics[0]`, or `body` for the body as a whole;\n * - the entry's budget and gates: the part of the request the rule bounds,\n * such as `limit` or `filter`;\n * - admission against the query model: the absolute logical field path, such\n * as `state.items.sku`, or `''` when the rule is about the model rather\n * than one field.\n */\nexport const QueryErrorCodes = Object.freeze({\n /** The body is not valid JSON. */\n INVALID_JSON: 'invalid-json',\n /** The body is JSON but not an object. */\n BODY_NOT_OBJECT: 'body-not-object',\n /** The body is empty. */\n EMPTY_BODY: 'empty-body',\n /** The body has a property the query type does not declare. */\n UNKNOWN_PROPERTY: 'unknown-property',\n /** An `op`, metric or other type discriminator names no known type. */\n UNKNOWN_TYPE: 'unknown-type',\n /** An enum value is not one the server knows. */\n UNKNOWN_VALUE: 'unknown-value',\n /** A value is missing or has the wrong JSON type. */\n INVALID_VALUE: 'invalid-value',\n /** Any other request rule; the message names it. */\n INVALID_REQUEST: 'invalid-request',\n /** A cursor sort names a field twice; `path` is the repeated field. */\n CURSOR_SORT_DUPLICATE: 'cursor-sort-duplicate',\n /** A cursor sort has too many fields once the identity tie-breaker is appended. */\n CURSOR_SORT_TOO_MANY: 'cursor-sort-too-many',\n /**\n * The cursor token was not issued for this model and effective sort, or\n * does not decode; `path` is `cursor`. Start again from the first page.\n */\n INVALID_CURSOR: 'invalid-cursor',\n /**\n * A stream that cannot be resumed, its sort having no keyset in its store,\n * names no `limit`: it would stop at a default and say nothing. Name a\n * `limit`, or sort by fields its store keeps a keyset of; `path` is `limit`.\n */\n STREAM_NOT_RESUMABLE: 'stream-not-resumable',\n /**\n * The entry's budget: a list or aggregation `limit`, a page's index, size,\n * window or offset, or a cursor page's `size` is out of range; `path` names\n * which (`limit`, `pagination.size`, `size`, …).\n */\n SIZE_OUT_OF_RANGE: 'size-out-of-range',\n /**\n * The entry's budget: the filter or `having` has too many nodes or values;\n * `path` is `filter` or `having`.\n */\n FILTER_TOO_LARGE: 'filter-too-large',\n /**\n * The entry does not allow expensive operators, and the query uses one: an\n * operator, an element expansion, a metric sort, an arithmetic or\n * expression group, a date part, a dense fill or FIRST / LAST; `path` names\n * the part (`filter`, `elements`, `sort`, `metrics`, `groupBy`).\n */\n EXPENSIVE_OPERATOR_DISABLED: 'expensive-operator-disabled',\n /**\n * A counting query (count, or a paged query's total) would match every\n * record, which the entry refuses; `path` is `filter`.\n */\n COUNT_REQUIRES_FILTER: 'count-requires-filter',\n /**\n * A `having` or metric sort the storage evaluates after grouping read more\n * groups than the server allows; `path` is `body`. It may end a stream\n * partway through.\n */\n RESIDUAL_GROUPS_EXCEEDED: 'residual-groups-exceeded',\n /**\n * An aggregation that names no sort found more groups than its `limit`;\n * `path` is `limit`. Add a sort for a top-N, or raise the limit.\n */\n TOO_MANY_GROUPS: 'too-many-groups',\n /**\n * An in-process query named no entry where one is required. Never\n * answered over HTTP; listed so the mirror stays complete.\n */\n EXPLICIT_ENTRY_REQUIRED: 'explicit-entry-required',\n /**\n * A state point read (`GET …/{id}/state?version=|at=`, `…/state/trace`): the\n * state asked for is more commits away from the snapshot, or from version 1,\n * than a state read replays. The path is the query parameter.\n */\n REPLAY_TOO_LONG: 'replay-too-long',\n /** The model has no such logical field. */\n UNKNOWN_FIELD: 'unknown-field',\n /** The field does not offer the capability the query uses (sort, range, …). */\n UNSUPPORTED_CAPABILITY: 'unsupported-capability',\n /** The field is an element field and must be queried inside its element scope. */\n ELEMENT_SCOPE_REQUIRED: 'element-scope-required',\n /** A filter value falls outside the field's declared domain. */\n VALUE_MISMATCH: 'value-mismatch',\n /** The field is not a known collection (for example under `isEmpty`). */\n NOT_COLLECTION: 'not-collection',\n /** The field is not a single string. */\n NOT_SINGLE_STRING: 'not-single-string',\n /** The model does not support search. */\n MODEL_SEARCH_UNSUPPORTED: 'model-search-unsupported',\n /** The field cannot be used for a cursor. */\n CURSOR_NOT_ALLOWED: 'cursor-not-allowed',\n /** The field is protected and cannot be aggregated. */\n PROTECTED_AGGREGATION: 'protected-aggregation',\n /**\n * The field is protected and cannot be filtered or sorted: its descriptor\n * says `sensitivity.comparable: false`. A search that names it is refused\n * the same way.\n */\n PROTECTED_COMPARISON: 'protected-comparison',\n /** A terms group's `missingKey` needs a single-valued string field. */\n MISSING_KEY_REQUIRES_STRING: 'missing-key-requires-string',\n /** `ANY` needs a single value. */\n ANY_REQUIRES_SINGLE_VALUE: 'any-requires-single-value',\n /** The storage cannot deliver a complete projection; select fields explicitly. */\n INCOMPLETE_PROJECTION: 'incomplete-projection',\n /** A metric filter uses a search filter. */\n METRIC_FILTER_SEARCH: 'metric-filter-search',\n /** A metric filter uses `ELEMENT_MATCH`. */\n METRIC_FILTER_ELEMENT_MATCH: 'metric-filter-element-match',\n /** A metric filter names an array field; it must be scalar. */\n METRIC_FILTER_ARRAY_FIELD: 'metric-filter-array-field',\n /** The field cannot be projected. */\n NOT_PROJECTABLE: 'not-projectable',\n /** An event projection that keeps payloads must keep their `bodyType`. */\n EVENT_PROJECTION_TYPE_REQUIRED: 'event-projection-type-required',\n /** A relative-time filter needs a field with a known temporal representation. */\n TEMPORAL_REPRESENTATION_REQUIRED: 'temporal-representation-required',\n /** A relative-time filter's zone, pattern or unit conflicts with the field's definition. */\n TEMPORAL_CONFIGURATION_CONFLICT: 'temporal-configuration-conflict',\n /**\n * A sort names two array fields on independent arrays, which the storage\n * cannot order by together; `path` is the second of them. The descriptor\n * lists such fields under a `PARALLEL_ARRAY_SORT` constraint.\n */\n PARALLEL_ARRAY_SORT: 'parallel-array-sort',\n /**\n * An `EQ` or `NE` compares the field to an array, which the storage cannot\n * do: it takes only a scalar operand. The descriptor says so with an\n * `ARRAY_EQUALITY` constraint.\n */\n ARRAY_EQUALITY: 'array-equality',\n /**\n * A `FIRST` or `LAST` metric names a field that may hold several values;\n * it needs a single-valued one (`aggregate.firstLast` in the descriptor).\n */\n FIRST_LAST_REQUIRES_SINGLE_VALUE: 'first-last-requires-single-value',\n /**\n * A `FIRST` or `LAST` metric names no `orderBy` where there is no event\n * time to order by, such as inside an element or on a model whose\n * descriptor has no `analysis.firstLastOrderBy`; `path` is its field.\n */\n FIRST_LAST_REQUIRES_ORDER_BY: 'first-last-requires-order-by',\n /**\n * A date group or date difference names a field that stores neither a\n * date nor an epoch (a formatted string, say), so it cannot be aggregated\n * by time.\n */\n TEMPORAL_AGGREGATION_UNSUPPORTED: 'temporal-aggregation-unsupported',\n /** The sort has more fields than the protocol allows; `path` is `''`. */\n SORT_TOO_MANY: 'sort-too-many',\n /** Two sort fields name the same stored field; `path` is the second. */\n SORT_FIELD_DUPLICATE: 'sort-field-duplicate',\n /**\n * An identity filter or a cursor on a model that defines no record\n * identity; `path` is `''`.\n */\n IDENTITY_UNDEFINED: 'identity-undefined',\n /**\n * The storage does not support the feature the query uses, or its native\n * query language cannot express it (a MongoDB PHRASE search with a quote,\n * say); `path` is the field, or `''`.\n */\n STORAGE_UNSUPPORTED: 'storage-unsupported',\n /**\n * A `PREVIOUS` window steps along a date group whose field the filter\n * conditions where its range cannot be shifted to the earlier period:\n * outside the top-level `AND`, or with a value that is not an instant;\n * `path` is the field.\n */\n PREVIOUS_UNSHIFTABLE: 'previous-unshiftable',\n} as const);\n\n/** One of the codes this package knows; see {@link QueryErrorCodes}. */\nexport type KnownQueryErrorCode =\n (typeof QueryErrorCodes)[keyof typeof QueryErrorCodes];\n\n/**\n * The code of a rejected query: one this package knows, which editors\n * complete, or one a newer server added.\n */\nexport type QueryErrorCode = KnownQueryErrorCode | (string & {});\n\n/**\n * Why the server rejected a query: one violation of its `wow.query.invalid`\n * problem, which rule failed, where, and the server's words.\n */\nexport interface QueryViolation {\n /** Which rule failed; switch on it against {@link QueryErrorCodes}. */\n code: QueryErrorCode;\n /**\n * Where: the JSON path of the offending value for a decoding error\n * (`filter.state`, `metrics[0]`, `body`), the absolute logical field path\n * for an admission error (`state.items.sku`), or `''` when the rule is about\n * the model rather than a field.\n */\n path: string;\n /** The server's words. */\n message: string;\n}\n"],"mappings":";AAkCA,IAAaA,IAAkB,OAAO,OAAO;CAE3C,cAAc;CAEd,iBAAiB;CAEjB,YAAY;CAEZ,kBAAkB;CAElB,cAAc;CAEd,eAAe;CAEf,eAAe;CAEf,iBAAiB;CAEjB,uBAAuB;CAEvB,sBAAsB;CAKtB,gBAAgB;CAMhB,sBAAsB;CAMtB,mBAAmB;CAKnB,kBAAkB;CAOlB,6BAA6B;CAK7B,uBAAuB;CAMvB,0BAA0B;CAK1B,iBAAiB;CAKjB,yBAAyB;CAMzB,iBAAiB;CAEjB,eAAe;CAEf,wBAAwB;CAExB,wBAAwB;CAExB,gBAAgB;CAEhB,gBAAgB;CAEhB,mBAAmB;CAEnB,0BAA0B;CAE1B,oBAAoB;CAEpB,uBAAuB;CAMvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,uBAAuB;CAEvB,sBAAsB;CAEtB,6BAA6B;CAE7B,2BAA2B;CAE3B,iBAAiB;CAEjB,gCAAgC;CAEhC,kCAAkC;CAElC,iCAAiC;CAMjC,qBAAqB;CAMrB,gBAAgB;CAKhB,kCAAkC;CAMlC,8BAA8B;CAM9B,kCAAkC;CAElC,eAAe;CAEf,sBAAsB;CAKtB,oBAAoB;CAMpB,qBAAqB;CAOrB,sBAAsB;AACxB,CAAU"}
|
package/dist/dsl/queryable.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./filter/builders.cjs"),t=require("./pagination.cjs");function n(t){if(t===null)throw TypeError(`filter cannot be null.`);return t??e.filter.matchAll()}function r({filter:e,projection:t,sort:r}={}){return{filter:n(e),projection:t,sort:r}}function i({filter:e,projection:t,sort:r,limit:i}={}){return{filter:n(e),projection:t,sort:r,limit:i}}function a({filter:e,projection:r,sort:i,pagination:a={...t.DEFAULT_PAGINATION}}={}){return{filter:n(e),projection:r,sort:i,pagination:a}}function o({total:e,list:
|
|
1
|
+
const e=require("./filter/builders.cjs"),t=require("./pagination.cjs");function n(t){if(t===null)throw TypeError(`filter cannot be null.`);return t??e.filter.matchAll()}function r({filter:e,projection:t,sort:r}={}){return{filter:n(e),projection:t,sort:r}}function i({filter:e,projection:t,sort:r,limit:i}={}){return{filter:n(e),projection:t,sort:r,limit:i}}function a({filter:e,projection:r,sort:i,pagination:a={...t.DEFAULT_PAGINATION}}={}){return{filter:n(e),projection:r,sort:i,pagination:a}}function o({total:e,exact:t=!0,list:n=[]}={}){return{total:e===void 0?n.length:e,exact:t,list:n}}exports.listQuery=i,exports.pagedList=o,exports.pagedQuery=a,exports.singleQuery=r;
|
|
2
2
|
//# sourceMappingURL=queryable.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryable.cjs","names":["filter","filters","DEFAULT_PAGINATION","require_builders","require_pagination","queryFilter","filter$1","singleQuery","filter","listQuery","pagedQuery","pagedList","total","list"],"sources":["../../src/dsl/queryable.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n filter as filters,\n type FilterCapable,\n type FilterExpression,\n} from './filter/index.js';\nimport { type SortCapable } from './sort.js';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination.js';\nimport { type ProjectionCapable } from './projection.js';\n\n/** A query that filters, projects and sorts with Wow's `FilterExpression`. */\nexport interface FilterQueryable<FIELDS extends string = string>\n extends\n FilterCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {}\n\n/** The body of a `single` query: the first match of the filter, or nothing. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FilterSingleQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {}\n\n/** The body of a `list` or `
|
|
1
|
+
{"version":3,"file":"queryable.cjs","names":["filter","filters","DEFAULT_PAGINATION","require_builders","require_pagination","queryFilter","filter$1","singleQuery","filter","listQuery","pagedQuery","pagedList","total","list"],"sources":["../../src/dsl/queryable.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n filter as filters,\n type FilterCapable,\n type FilterExpression,\n} from './filter/index.js';\nimport { type SortCapable } from './sort.js';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination.js';\nimport { type ProjectionCapable } from './projection.js';\n\n/** A query that filters, projects and sorts with Wow's `FilterExpression`. */\nexport interface FilterQueryable<FIELDS extends string = string>\n extends\n FilterCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {}\n\n/** The body of a `single` query: the first match of the filter, or nothing. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FilterSingleQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {}\n\n/** The body of a `list` or `stream` query. */\nexport interface FilterListQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n /**\n * The most rows to return, at least 1. Absent, the server applies its\n * default list size (100 unless it configures another). A limit below 1 is\n * refused with 400 `wow.query.malformed`, and so is a value above the\n * server's maximum list size (1000 by default) with 400\n * `wow.query.invalid`.\n */\n limit?: number;\n}\n\n/** The body of a `paged` query. */\nexport interface FilterPagedQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n pagination?: Pagination;\n}\n\n/** How a paged query counts its total (`TotalMode`). */\nexport type TotalMode = 'exact' | 'bounded' | 'none';\n\n/** A paged query of a query route: a page, and how its total is counted. */\nexport interface PagedQuery<\n FIELDS extends string = string,\n> extends FilterPagedQuery<FIELDS> {\n /** `bounded` (the server's default) counts up to the budget's limit. */\n total?: TotalMode;\n}\n\n/**\n * A page of a paged query: `total` is exact when `exact`, a lower bound\n * otherwise, and null for total `none`. Kotlin's `PagedList`.\n */\nexport interface PagedList<T> {\n readonly total: number | null;\n readonly exact: boolean;\n readonly list: readonly T[];\n}\n\n/** What `singleQuery`, `listQuery` and `pagedQuery` take in common. */\ntype QueryOptions<FIELDS extends string = string> = Partial<\n FilterQueryable<FIELDS>\n>;\n\nfunction queryFilter<FIELDS extends string>(\n filter: FilterExpression<FIELDS> | undefined,\n): FilterExpression<FIELDS> {\n if (filter === null) {\n throw new TypeError('filter cannot be null.');\n }\n return filter ?? filters.matchAll();\n}\n\n/**\n * Builds the body of a `single` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - Which match counts as the first. Optional.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * singleQuery({ filter: filter.eq('status', 'ACTIVE') });\n * ```\n */\nexport function singleQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n}: QueryOptions<FIELDS> = {}): FilterSingleQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort };\n}\n\n/**\n * Builds the body of a `list` or `stream` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.limit - The most rows to return. Absent is sent as absent:\n * Wow 9.1.5 and later apply the server's default list size, Wow 8.11 to\n * 9.1.3 reject the query, so pass it for those servers; see\n * {@link FilterListQuery.limit}.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * listQuery({ filter: filter.eq('status', 'ACTIVE'), limit: 20 });\n * ```\n */\nexport function listQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n limit,\n}: QueryOptions<FIELDS> & { limit?: number } = {}): FilterListQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, limit };\n}\n\n/**\n * Builds the body of a `paged` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.pagination - Which page. Defaults to a copy of\n * {@link DEFAULT_PAGINATION}: the first page of ten.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * pagedQuery({ filter: filter.matchAll(), pagination: { index: 2, size: 20 } });\n * ```\n */\nexport function pagedQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n pagination = { ...DEFAULT_PAGINATION },\n}: QueryOptions<FIELDS> & {\n pagination?: Pagination;\n} = {}): FilterPagedQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, pagination };\n}\n\n/**\n * Builds a `PagedList`, for a placeholder page or a test double.\n *\n * @param options.total - How many rows match in total. Defaults to the length\n * of `list`.\n * @param options.exact - Whether `total` is exact. Defaults to true.\n * @param options.list - The rows of this page. Defaults to a new empty array.\n */\nexport function pagedList<T>({\n total,\n exact = true,\n list = [],\n}: Partial<PagedList<T>> = {}): PagedList<T> {\n return { total: total === undefined ? list.length : total, exact, list };\n}\n"],"mappings":"A,uEAkFA,SAASK,EACP,EAC0B,CAC1B,GAAIL,IAAW,KACb,MAAU,UAAU,wBAAwB,EAE9C,OAAOA,GAAUC,EAAAA,OAAQ,SAAS,CACpC,CAeA,SAAgBM,EAA4C,CAC1D,SACA,aACA,QACwB,CAAC,EAA8B,CACvD,MAAO,CAAE,OAAQF,EAAYG,CAAM,EAAG,aAAY,MAAK,CACzD,CAmBA,SAAgBC,EAA0C,CACxD,SACA,aACA,OACA,SAC6C,CAAC,EAA4B,CAC1E,MAAO,CAAE,OAAQJ,EAAYG,CAAM,EAAG,aAAY,OAAM,OAAM,CAChE,CAiBA,SAAgBE,EAA2C,CACzD,SACA,aACA,OACA,aAAa,CAAE,GAAGR,EAAAA,kBAAmB,GAGnC,CAAC,EAA6B,CAChC,MAAO,CAAE,OAAQG,EAAYG,CAAM,EAAG,aAAY,OAAM,YAAW,CACrE,CAUA,SAAgBG,EAAa,CAC3B,QACA,QAAQ,GACR,OAAO,CAAC,GACiB,CAAC,EAAiB,CAC3C,MAAO,CAAE,MAAOC,IAAU,IAAA,GAAYC,EAAK,OAASD,EAAO,QAAO,MAAK,CACzE,C"}
|
package/dist/dsl/queryable.d.cts
CHANGED
|
@@ -8,22 +8,14 @@ export interface FilterQueryable<FIELDS extends string = string> extends FilterC
|
|
|
8
8
|
/** The body of a `single` query: the first match of the filter, or nothing. */
|
|
9
9
|
export interface FilterSingleQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
10
10
|
}
|
|
11
|
-
/** The body of a `list` or `
|
|
11
|
+
/** The body of a `list` or `stream` query. */
|
|
12
12
|
export interface FilterListQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
13
13
|
/**
|
|
14
|
-
* The most rows to return
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (100 unless the server configures another).
|
|
20
|
-
* - Wow 8.11 to 9.1.3 reject the query with `IllegalArgument: HTTP list
|
|
21
|
-
* query limit[0] must be between 1 and …` (HTTP 400 for a list, the error
|
|
22
|
-
* event that ends a list stream), so pass `limit` explicitly against
|
|
23
|
-
* those servers.
|
|
24
|
-
*
|
|
25
|
-
* Wow 8.11 and later also refuse a value above the server's maximum list
|
|
26
|
-
* size (1000 by default).
|
|
14
|
+
* The most rows to return, at least 1. Absent, the server applies its
|
|
15
|
+
* default list size (100 unless it configures another). A limit below 1 is
|
|
16
|
+
* refused with 400 `wow.query.malformed`, and so is a value above the
|
|
17
|
+
* server's maximum list size (1000 by default) with 400
|
|
18
|
+
* `wow.query.invalid`.
|
|
27
19
|
*/
|
|
28
20
|
limit?: number;
|
|
29
21
|
}
|
|
@@ -31,6 +23,22 @@ export interface FilterListQuery<FIELDS extends string = string> extends FilterQ
|
|
|
31
23
|
export interface FilterPagedQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
32
24
|
pagination?: Pagination;
|
|
33
25
|
}
|
|
26
|
+
/** How a paged query counts its total (`TotalMode`). */
|
|
27
|
+
export type TotalMode = 'exact' | 'bounded' | 'none';
|
|
28
|
+
/** A paged query of a query route: a page, and how its total is counted. */
|
|
29
|
+
export interface PagedQuery<FIELDS extends string = string> extends FilterPagedQuery<FIELDS> {
|
|
30
|
+
/** `bounded` (the server's default) counts up to the budget's limit. */
|
|
31
|
+
total?: TotalMode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A page of a paged query: `total` is exact when `exact`, a lower bound
|
|
35
|
+
* otherwise, and null for total `none`. Kotlin's `PagedList`.
|
|
36
|
+
*/
|
|
37
|
+
export interface PagedList<T> {
|
|
38
|
+
readonly total: number | null;
|
|
39
|
+
readonly exact: boolean;
|
|
40
|
+
readonly list: readonly T[];
|
|
41
|
+
}
|
|
34
42
|
/** What `singleQuery`, `listQuery` and `pagedQuery` take in common. */
|
|
35
43
|
type QueryOptions<FIELDS extends string = string> = Partial<FilterQueryable<FIELDS>>;
|
|
36
44
|
/**
|
|
@@ -48,7 +56,7 @@ type QueryOptions<FIELDS extends string = string> = Partial<FilterQueryable<FIEL
|
|
|
48
56
|
*/
|
|
49
57
|
export declare function singleQuery<FIELDS extends string = string>({ filter, projection, sort, }?: QueryOptions<FIELDS>): FilterSingleQuery<FIELDS>;
|
|
50
58
|
/**
|
|
51
|
-
* Builds the body of a `list` or `
|
|
59
|
+
* Builds the body of a `list` or `stream` query.
|
|
52
60
|
*
|
|
53
61
|
* @param options.filter - What to match. Defaults to `filter.matchAll()`.
|
|
54
62
|
* @param options.projection - Which fields to return. Optional.
|
|
@@ -85,17 +93,13 @@ export declare function listQuery<FIELDS extends string = string>({ filter, proj
|
|
|
85
93
|
export declare function pagedQuery<FIELDS extends string = string>({ filter, projection, sort, pagination, }?: QueryOptions<FIELDS> & {
|
|
86
94
|
pagination?: Pagination;
|
|
87
95
|
}): FilterPagedQuery<FIELDS>;
|
|
88
|
-
/** One page of a `paged` query: its rows, and how many match in total. */
|
|
89
|
-
export interface PagedList<T> {
|
|
90
|
-
total: number;
|
|
91
|
-
list: T[];
|
|
92
|
-
}
|
|
93
96
|
/**
|
|
94
97
|
* Builds a `PagedList`, for a placeholder page or a test double.
|
|
95
98
|
*
|
|
96
99
|
* @param options.total - How many rows match in total. Defaults to the length
|
|
97
100
|
* of `list`.
|
|
101
|
+
* @param options.exact - Whether `total` is exact. Defaults to true.
|
|
98
102
|
* @param options.list - The rows of this page. Defaults to a new empty array.
|
|
99
103
|
*/
|
|
100
|
-
export declare function pagedList<T>({ total, list, }?: Partial<PagedList<T>>): PagedList<T>;
|
|
104
|
+
export declare function pagedList<T>({ total, exact, list, }?: Partial<PagedList<T>>): PagedList<T>;
|
|
101
105
|
export {};
|
package/dist/dsl/queryable.d.ts
CHANGED
|
@@ -8,22 +8,14 @@ export interface FilterQueryable<FIELDS extends string = string> extends FilterC
|
|
|
8
8
|
/** The body of a `single` query: the first match of the filter, or nothing. */
|
|
9
9
|
export interface FilterSingleQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
10
10
|
}
|
|
11
|
-
/** The body of a `list` or `
|
|
11
|
+
/** The body of a `list` or `stream` query. */
|
|
12
12
|
export interface FilterListQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
13
13
|
/**
|
|
14
|
-
* The most rows to return
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (100 unless the server configures another).
|
|
20
|
-
* - Wow 8.11 to 9.1.3 reject the query with `IllegalArgument: HTTP list
|
|
21
|
-
* query limit[0] must be between 1 and …` (HTTP 400 for a list, the error
|
|
22
|
-
* event that ends a list stream), so pass `limit` explicitly against
|
|
23
|
-
* those servers.
|
|
24
|
-
*
|
|
25
|
-
* Wow 8.11 and later also refuse a value above the server's maximum list
|
|
26
|
-
* size (1000 by default).
|
|
14
|
+
* The most rows to return, at least 1. Absent, the server applies its
|
|
15
|
+
* default list size (100 unless it configures another). A limit below 1 is
|
|
16
|
+
* refused with 400 `wow.query.malformed`, and so is a value above the
|
|
17
|
+
* server's maximum list size (1000 by default) with 400
|
|
18
|
+
* `wow.query.invalid`.
|
|
27
19
|
*/
|
|
28
20
|
limit?: number;
|
|
29
21
|
}
|
|
@@ -31,6 +23,22 @@ export interface FilterListQuery<FIELDS extends string = string> extends FilterQ
|
|
|
31
23
|
export interface FilterPagedQuery<FIELDS extends string = string> extends FilterQueryable<FIELDS> {
|
|
32
24
|
pagination?: Pagination;
|
|
33
25
|
}
|
|
26
|
+
/** How a paged query counts its total (`TotalMode`). */
|
|
27
|
+
export type TotalMode = 'exact' | 'bounded' | 'none';
|
|
28
|
+
/** A paged query of a query route: a page, and how its total is counted. */
|
|
29
|
+
export interface PagedQuery<FIELDS extends string = string> extends FilterPagedQuery<FIELDS> {
|
|
30
|
+
/** `bounded` (the server's default) counts up to the budget's limit. */
|
|
31
|
+
total?: TotalMode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A page of a paged query: `total` is exact when `exact`, a lower bound
|
|
35
|
+
* otherwise, and null for total `none`. Kotlin's `PagedList`.
|
|
36
|
+
*/
|
|
37
|
+
export interface PagedList<T> {
|
|
38
|
+
readonly total: number | null;
|
|
39
|
+
readonly exact: boolean;
|
|
40
|
+
readonly list: readonly T[];
|
|
41
|
+
}
|
|
34
42
|
/** What `singleQuery`, `listQuery` and `pagedQuery` take in common. */
|
|
35
43
|
type QueryOptions<FIELDS extends string = string> = Partial<FilterQueryable<FIELDS>>;
|
|
36
44
|
/**
|
|
@@ -48,7 +56,7 @@ type QueryOptions<FIELDS extends string = string> = Partial<FilterQueryable<FIEL
|
|
|
48
56
|
*/
|
|
49
57
|
export declare function singleQuery<FIELDS extends string = string>({ filter, projection, sort, }?: QueryOptions<FIELDS>): FilterSingleQuery<FIELDS>;
|
|
50
58
|
/**
|
|
51
|
-
* Builds the body of a `list` or `
|
|
59
|
+
* Builds the body of a `list` or `stream` query.
|
|
52
60
|
*
|
|
53
61
|
* @param options.filter - What to match. Defaults to `filter.matchAll()`.
|
|
54
62
|
* @param options.projection - Which fields to return. Optional.
|
|
@@ -85,17 +93,13 @@ export declare function listQuery<FIELDS extends string = string>({ filter, proj
|
|
|
85
93
|
export declare function pagedQuery<FIELDS extends string = string>({ filter, projection, sort, pagination, }?: QueryOptions<FIELDS> & {
|
|
86
94
|
pagination?: Pagination;
|
|
87
95
|
}): FilterPagedQuery<FIELDS>;
|
|
88
|
-
/** One page of a `paged` query: its rows, and how many match in total. */
|
|
89
|
-
export interface PagedList<T> {
|
|
90
|
-
total: number;
|
|
91
|
-
list: T[];
|
|
92
|
-
}
|
|
93
96
|
/**
|
|
94
97
|
* Builds a `PagedList`, for a placeholder page or a test double.
|
|
95
98
|
*
|
|
96
99
|
* @param options.total - How many rows match in total. Defaults to the length
|
|
97
100
|
* of `list`.
|
|
101
|
+
* @param options.exact - Whether `total` is exact. Defaults to true.
|
|
98
102
|
* @param options.list - The rows of this page. Defaults to a new empty array.
|
|
99
103
|
*/
|
|
100
|
-
export declare function pagedList<T>({ total, list, }?: Partial<PagedList<T>>): PagedList<T>;
|
|
104
|
+
export declare function pagedList<T>({ total, exact, list, }?: Partial<PagedList<T>>): PagedList<T>;
|
|
101
105
|
export {};
|
package/dist/dsl/queryable.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { filter as e } from "./filter/builders.es.js";
|
|
2
2
|
import { DEFAULT_PAGINATION as t } from "./pagination.es.js";
|
|
3
|
-
|
|
3
|
+
// src/dsl/queryable.ts
|
|
4
4
|
function n(t) {
|
|
5
5
|
if (t === null) throw TypeError("filter cannot be null.");
|
|
6
6
|
return t ?? e.matchAll();
|
|
@@ -28,13 +28,13 @@ function a({ filter: e, projection: r, sort: i, pagination: a = { ...t } } = {})
|
|
|
28
28
|
pagination: a
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function o({ total: e,
|
|
31
|
+
function o({ total: e, exact: t = !0, list: n = [] } = {}) {
|
|
32
32
|
return {
|
|
33
|
-
total: e
|
|
34
|
-
|
|
33
|
+
total: e === void 0 ? n.length : e,
|
|
34
|
+
exact: t,
|
|
35
|
+
list: n
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
|
-
//#endregion
|
|
38
38
|
export { i as listQuery, o as pagedList, a as pagedQuery, r as singleQuery };
|
|
39
39
|
|
|
40
40
|
//# sourceMappingURL=queryable.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryable.es.js","names":["filter","filters","queryFilter","filter$1","filter","singleQuery","listQuery","pagedQuery","DEFAULT_PAGINATION","pagedList","total","list"],"sources":["../../src/dsl/queryable.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n filter as filters,\n type FilterCapable,\n type FilterExpression,\n} from './filter/index.js';\nimport { type SortCapable } from './sort.js';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination.js';\nimport { type ProjectionCapable } from './projection.js';\n\n/** A query that filters, projects and sorts with Wow's `FilterExpression`. */\nexport interface FilterQueryable<FIELDS extends string = string>\n extends\n FilterCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {}\n\n/** The body of a `single` query: the first match of the filter, or nothing. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FilterSingleQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {}\n\n/** The body of a `list` or `
|
|
1
|
+
{"version":3,"file":"queryable.es.js","names":["filter","filters","queryFilter","filter$1","filter","singleQuery","listQuery","pagedQuery","DEFAULT_PAGINATION","pagedList","total","list"],"sources":["../../src/dsl/queryable.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n filter as filters,\n type FilterCapable,\n type FilterExpression,\n} from './filter/index.js';\nimport { type SortCapable } from './sort.js';\nimport { DEFAULT_PAGINATION, type Pagination } from './pagination.js';\nimport { type ProjectionCapable } from './projection.js';\n\n/** A query that filters, projects and sorts with Wow's `FilterExpression`. */\nexport interface FilterQueryable<FIELDS extends string = string>\n extends\n FilterCapable<FIELDS>,\n ProjectionCapable<FIELDS>,\n SortCapable<FIELDS> {}\n\n/** The body of a `single` query: the first match of the filter, or nothing. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FilterSingleQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {}\n\n/** The body of a `list` or `stream` query. */\nexport interface FilterListQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n /**\n * The most rows to return, at least 1. Absent, the server applies its\n * default list size (100 unless it configures another). A limit below 1 is\n * refused with 400 `wow.query.malformed`, and so is a value above the\n * server's maximum list size (1000 by default) with 400\n * `wow.query.invalid`.\n */\n limit?: number;\n}\n\n/** The body of a `paged` query. */\nexport interface FilterPagedQuery<\n FIELDS extends string = string,\n> extends FilterQueryable<FIELDS> {\n pagination?: Pagination;\n}\n\n/** How a paged query counts its total (`TotalMode`). */\nexport type TotalMode = 'exact' | 'bounded' | 'none';\n\n/** A paged query of a query route: a page, and how its total is counted. */\nexport interface PagedQuery<\n FIELDS extends string = string,\n> extends FilterPagedQuery<FIELDS> {\n /** `bounded` (the server's default) counts up to the budget's limit. */\n total?: TotalMode;\n}\n\n/**\n * A page of a paged query: `total` is exact when `exact`, a lower bound\n * otherwise, and null for total `none`. Kotlin's `PagedList`.\n */\nexport interface PagedList<T> {\n readonly total: number | null;\n readonly exact: boolean;\n readonly list: readonly T[];\n}\n\n/** What `singleQuery`, `listQuery` and `pagedQuery` take in common. */\ntype QueryOptions<FIELDS extends string = string> = Partial<\n FilterQueryable<FIELDS>\n>;\n\nfunction queryFilter<FIELDS extends string>(\n filter: FilterExpression<FIELDS> | undefined,\n): FilterExpression<FIELDS> {\n if (filter === null) {\n throw new TypeError('filter cannot be null.');\n }\n return filter ?? filters.matchAll();\n}\n\n/**\n * Builds the body of a `single` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - Which match counts as the first. Optional.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * singleQuery({ filter: filter.eq('status', 'ACTIVE') });\n * ```\n */\nexport function singleQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n}: QueryOptions<FIELDS> = {}): FilterSingleQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort };\n}\n\n/**\n * Builds the body of a `list` or `stream` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.limit - The most rows to return. Absent is sent as absent:\n * Wow 9.1.5 and later apply the server's default list size, Wow 8.11 to\n * 9.1.3 reject the query, so pass it for those servers; see\n * {@link FilterListQuery.limit}.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * listQuery({ filter: filter.eq('status', 'ACTIVE'), limit: 20 });\n * ```\n */\nexport function listQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n limit,\n}: QueryOptions<FIELDS> & { limit?: number } = {}): FilterListQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, limit };\n}\n\n/**\n * Builds the body of a `paged` query.\n *\n * @param options.filter - What to match. Defaults to `filter.matchAll()`.\n * @param options.projection - Which fields to return. Optional.\n * @param options.sort - The order of the rows. Optional.\n * @param options.pagination - Which page. Defaults to a copy of\n * {@link DEFAULT_PAGINATION}: the first page of ten.\n * @throws TypeError when `filter` is `null`.\n *\n * @example\n * ```typescript\n * pagedQuery({ filter: filter.matchAll(), pagination: { index: 2, size: 20 } });\n * ```\n */\nexport function pagedQuery<FIELDS extends string = string>({\n filter,\n projection,\n sort,\n pagination = { ...DEFAULT_PAGINATION },\n}: QueryOptions<FIELDS> & {\n pagination?: Pagination;\n} = {}): FilterPagedQuery<FIELDS> {\n return { filter: queryFilter(filter), projection, sort, pagination };\n}\n\n/**\n * Builds a `PagedList`, for a placeholder page or a test double.\n *\n * @param options.total - How many rows match in total. Defaults to the length\n * of `list`.\n * @param options.exact - Whether `total` is exact. Defaults to true.\n * @param options.list - The rows of this page. Defaults to a new empty array.\n */\nexport function pagedList<T>({\n total,\n exact = true,\n list = [],\n}: Partial<PagedList<T>> = {}): PagedList<T> {\n return { total: total === undefined ? list.length : total, exact, list };\n}\n"],"mappings":";;;AAkFA,SAASE,EACP,GAC0B;CAC1B,IAAIF,MAAW,MACb,MAAU,UAAU,wBAAwB;CAE9C,OAAOA,KAAUC,EAAQ,SAAS;AACpC;AAeA,SAAgBI,EAA4C,EAC1D,WACA,eACA,YACwB,CAAC,GAA8B;CACvD,OAAO;EAAE,QAAQH,EAAYE,CAAM;EAAG;EAAY;CAAK;AACzD;AAmBA,SAAgBE,EAA0C,EACxD,WACA,eACA,SACA,aAC6C,CAAC,GAA4B;CAC1E,OAAO;EAAE,QAAQJ,EAAYE,CAAM;EAAG;EAAY;EAAM;CAAM;AAChE;AAiBA,SAAgBG,EAA2C,EACzD,WACA,eACA,SACA,gBAAa,EAAE,GAAGC,EAAmB,MAGnC,CAAC,GAA6B;CAChC,OAAO;EAAE,QAAQN,EAAYE,CAAM;EAAG;EAAY;EAAM;CAAW;AACrE;AAUA,SAAgBK,EAAa,EAC3B,UACA,WAAQ,IACR,UAAO,CAAC,MACiB,CAAC,GAAiB;CAC3C,OAAO;EAAE,OAAOC,MAAU,KAAA,IAAYC,EAAK,SAASD;EAAO;EAAO;CAAK;AACzE"}
|
package/dist/dsl/sort.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./field.cjs");var t=function(e){return e.ASC=`
|
|
1
|
+
const e=require("./field.cjs");var t=function(e){return e.ASC=`asc`,e.DESC=`desc`,e}({});function n(t){return{field:e.queryField(t),direction:`asc`}}function r(t){return{field:e.queryField(t),direction:`desc`}}exports.SortDirection=t,exports.asc=n,exports.desc=r;
|
|
2
2
|
//# sourceMappingURL=sort.cjs.map
|
package/dist/dsl/sort.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.cjs","names":["queryField","require_field","SortDirection","\"ASC\"","\"DESC\"","asc","field","desc"],"sources":["../../src/dsl/sort.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { queryField } from './field.js';\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = '
|
|
1
|
+
{"version":3,"file":"sort.cjs","names":["queryField","require_field","SortDirection","\"ASC\"","\"DESC\"","asc","field","desc"],"sources":["../../src/dsl/sort.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { queryField } from './field.js';\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = 'asc',\n DESC = 'desc',\n}\n\n/**\n * Interface for sort criteria.\n */\nexport interface FieldSort<FIELDS extends string = string> {\n field: FIELDS;\n direction: SortDirection;\n}\n\n/**\n * Creates a sort object with ascending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and ascending direction\n */\nexport function asc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field: queryField(field),\n direction: SortDirection.ASC,\n };\n}\n\n/**\n * Creates a sort object with descending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and descending direction\n */\nexport function desc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field: queryField(field),\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable<FIELDS extends string = string> {\n sort?: FieldSort<FIELDS>[];\n}\n"],"mappings":"A,+BAmBA,IAAYE,EAAL,SAAA,EAAA,C,MACL,GAAAC,IAAA,MACA,EAAAC,KAAA,O,CACF,EAAA,CAAA,CAAA,EAeA,SAAgBC,EACd,EACmB,CACnB,MAAO,CACL,MAAOL,EAAAA,WAAWM,CAAK,EACvB,UAAA,KACF,CACF,CAOA,SAAgBC,EACd,EACmB,CACnB,MAAO,CACL,MAAOP,EAAAA,WAAWM,CAAK,EACvB,UAAA,MACF,CACF,C"}
|
package/dist/dsl/sort.d.cts
CHANGED
package/dist/dsl/sort.d.ts
CHANGED
package/dist/dsl/sort.es.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { queryField as e } from "./field.es.js";
|
|
2
|
-
|
|
2
|
+
// src/dsl/sort.ts
|
|
3
3
|
var t = /* @__PURE__ */ function(e) {
|
|
4
|
-
return e.ASC = "
|
|
4
|
+
return e.ASC = "asc", e.DESC = "desc", e;
|
|
5
5
|
}({});
|
|
6
6
|
function n(t) {
|
|
7
7
|
return {
|
|
8
8
|
field: e(t),
|
|
9
|
-
direction: "
|
|
9
|
+
direction: "asc"
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
function r(t) {
|
|
13
13
|
return {
|
|
14
14
|
field: e(t),
|
|
15
|
-
direction: "
|
|
15
|
+
direction: "desc"
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { t as SortDirection, n as asc, r as desc };
|
|
20
19
|
|
|
21
20
|
//# sourceMappingURL=sort.es.js.map
|
package/dist/dsl/sort.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.es.js","names":["SortDirection","\"ASC\"","\"DESC\"","asc","queryField","field","desc"],"sources":["../../src/dsl/sort.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { queryField } from './field.js';\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = '
|
|
1
|
+
{"version":3,"file":"sort.es.js","names":["SortDirection","\"ASC\"","\"DESC\"","asc","queryField","field","desc"],"sources":["../../src/dsl/sort.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { queryField } from './field.js';\n\n/**\n * Enumeration of sort directions.\n * ASC for ascending order, DESC for descending order.\n */\nexport enum SortDirection {\n ASC = 'asc',\n DESC = 'desc',\n}\n\n/**\n * Interface for sort criteria.\n */\nexport interface FieldSort<FIELDS extends string = string> {\n field: FIELDS;\n direction: SortDirection;\n}\n\n/**\n * Creates a sort object with ascending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and ascending direction\n */\nexport function asc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field: queryField(field),\n direction: SortDirection.ASC,\n };\n}\n\n/**\n * Creates a sort object with descending direction for the specified field.\n * @param field - The field to sort by\n * @returns A Sort object with the specified field and descending direction\n */\nexport function desc<FIELDS extends string = string>(\n field: FIELDS,\n): FieldSort<FIELDS> {\n return {\n field: queryField(field),\n direction: SortDirection.DESC,\n };\n}\n\n/**\n * Interface for objects that support sorting.\n */\nexport interface SortCapable<FIELDS extends string = string> {\n sort?: FieldSort<FIELDS>[];\n}\n"],"mappings":";;AAmBA,IAAYA,IAAL,yBAAA,GAAA;C,OACL,EAAAC,MAAA,OACA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA;AAeA,SAAgBC,EACd,GACmB;CACnB,OAAO;EACL,OAAOC,EAAWC,CAAK;EACvB,WAAA;CACF;AACF;AAOA,SAAgBC,EACd,GACmB;CACnB,OAAO;EACL,OAAOF,EAAWC,CAAK;EACvB,WAAA;CACF;AACF"}
|
package/dist/dsl.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dsl/filter/operator.cjs"),t=require("./dsl/aggregation/types.cjs"),n=require("./dsl/deletionState.cjs"),r=require("./dsl/filter/builders.cjs"),i=require("./dsl/sort.cjs"),a=require("./dsl/aggregation/builders.cjs"),o=require("./dsl/projection.cjs"),s=require("./dsl/pagination.cjs"),c=require("./dsl/cursorQuery.cjs"),l=require("./dsl/queryable.cjs"),u=require("./dsl/descriptor.cjs"),d=require("./dsl/queryErrorCodes.cjs");exports.AGGREGATION_LIMITS=t.AGGREGATION_LIMITS,exports.AggregationDatePart=t.AggregationDatePart,exports.AggregationDateUnit=t.AggregationDateUnit,exports.AggregationExpressionOperator=t.AggregationExpressionOperator,exports.AggregationExpressionType=t.AggregationExpressionType,exports.AggregationFunction=t.AggregationFunction,exports.AggregationGroupScope=t.AggregationGroupScope,exports.AggregationGroupType=t.AggregationGroupType,exports.AggregationMetricType=t.AggregationMetricType,exports.ComparisonOperator=t.ComparisonOperator,exports.DEFAULT_CURSOR_SIZE=c.DEFAULT_CURSOR_SIZE,exports.DEFAULT_PAGINATION=s.DEFAULT_PAGINATION,exports.DateDiffUnit=t.DateDiffUnit,exports.DeletionState=n.DeletionState,exports.DerivedExpressionType=t.DerivedExpressionType,exports.FilterOperator=e.FilterOperator,exports.HavingExpressionType=t.HavingExpressionType,exports.MAX_CURSOR_SIZE=c.MAX_CURSOR_SIZE,exports.MAX_CURSOR_SORT_FIELDS=c.MAX_CURSOR_SORT_FIELDS,exports.PagingMode=u.PagingMode,exports.QueryConstraintTypes=u.QueryConstraintTypes,exports.QueryErrorCodes=d.QueryErrorCodes,exports.QueryFieldRoles=u.QueryFieldRoles,exports.QueryModels=u.QueryModels,exports.QueryValueKind=u.QueryValueKind,exports.QueryValueTypes=u.QueryValueTypes,exports.RunningFunction=t.RunningFunction,exports.SearchMode=e.SearchMode,exports.SensitivityLevel=u.SensitivityLevel,exports.SortDirection=i.SortDirection,exports.StringComparison=e.StringComparison,exports.TimeUnit=e.TimeUnit,exports.WindowFunction=t.WindowFunction,exports.aggregation=a.aggregation,exports.asc=i.asc,exports.cursorQuery=c.cursorQuery,exports.desc=i.desc,exports.filter=r.filter,exports.listQuery=l.listQuery,exports.pagedList=l.pagedList,exports.pagedQuery=l.pagedQuery,exports.pagination=s.pagination,exports.projection=o.projection,exports.singleQuery=l.singleQuery;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dsl/filter/operator.cjs"),t=require("./dsl/aggregation/types.cjs"),n=require("./dsl/deletionState.cjs"),r=require("./dsl/filter/builders.cjs"),i=require("./dsl/sort.cjs"),a=require("./dsl/aggregation/builders.cjs"),o=require("./dsl/projection.cjs"),s=require("./dsl/pagination.cjs"),c=require("./dsl/cursorQuery.cjs"),l=require("./dsl/queryable.cjs"),u=require("./dsl/descriptor.cjs"),d=require("./dsl/queryErrorCodes.cjs");exports.AGGREGATION_LIMITS=t.AGGREGATION_LIMITS,exports.AggregationDatePart=t.AggregationDatePart,exports.AggregationDateUnit=t.AggregationDateUnit,exports.AggregationExpressionOperator=t.AggregationExpressionOperator,exports.AggregationExpressionType=t.AggregationExpressionType,exports.AggregationFunction=t.AggregationFunction,exports.AggregationGroupScope=t.AggregationGroupScope,exports.AggregationGroupType=t.AggregationGroupType,exports.AggregationMetricType=t.AggregationMetricType,exports.ComparisonOperator=t.ComparisonOperator,exports.DEFAULT_CURSOR_SIZE=c.DEFAULT_CURSOR_SIZE,exports.DEFAULT_PAGINATION=s.DEFAULT_PAGINATION,exports.DateDiffUnit=t.DateDiffUnit,exports.DeletionState=n.DeletionState,exports.DerivedExpressionType=t.DerivedExpressionType,exports.FilterOperator=e.FilterOperator,exports.HavingExpressionType=t.HavingExpressionType,exports.MAX_CURSOR_SIZE=c.MAX_CURSOR_SIZE,exports.MAX_CURSOR_SORT_FIELDS=c.MAX_CURSOR_SORT_FIELDS,exports.PagingMode=u.PagingMode,exports.QueryConstraintTypes=u.QueryConstraintTypes,exports.QueryErrorCodes=d.QueryErrorCodes,exports.QueryFieldRoles=u.QueryFieldRoles,exports.QueryModels=u.QueryModels,exports.QuerySemanticTypes=u.QuerySemanticTypes,exports.QueryValueKind=u.QueryValueKind,exports.QueryValueTypes=u.QueryValueTypes,exports.RunningFunction=t.RunningFunction,exports.SearchMode=e.SearchMode,exports.SensitivityLevel=u.SensitivityLevel,exports.SortDirection=i.SortDirection,exports.StringComparison=e.StringComparison,exports.TimeUnit=e.TimeUnit,exports.WindowFunction=t.WindowFunction,exports.aggregation=a.aggregation,exports.asc=i.asc,exports.cursorQuery=c.cursorQuery,exports.desc=i.desc,exports.filter=r.filter,exports.listQuery=l.listQuery,exports.pagedList=l.pagedList,exports.pagedQuery=l.pagedQuery,exports.pagination=s.pagination,exports.projection=o.projection,exports.singleQuery=l.singleQuery;
|
package/dist/dsl.es.js
CHANGED
|
@@ -8,6 +8,6 @@ import { projection as T } from "./dsl/projection.es.js";
|
|
|
8
8
|
import { DEFAULT_PAGINATION as E, pagination as D } from "./dsl/pagination.es.js";
|
|
9
9
|
import { DEFAULT_CURSOR_SIZE as O, MAX_CURSOR_SIZE as k, MAX_CURSOR_SORT_FIELDS as A, cursorQuery as j } from "./dsl/cursorQuery.es.js";
|
|
10
10
|
import { listQuery as M, pagedList as N, pagedQuery as P, singleQuery as F } from "./dsl/queryable.es.js";
|
|
11
|
-
import { PagingMode as I, QueryConstraintTypes as L, QueryFieldRoles as R, QueryModels as z,
|
|
12
|
-
import { QueryErrorCodes as
|
|
13
|
-
export { i as AGGREGATION_LIMITS, a as AggregationDatePart, o as AggregationDateUnit, s as AggregationExpressionOperator, c as AggregationExpressionType, l as AggregationFunction, u as AggregationGroupScope, d as AggregationGroupType, f as AggregationMetricType, p as ComparisonOperator, O as DEFAULT_CURSOR_SIZE, E as DEFAULT_PAGINATION, m as DateDiffUnit, y as DeletionState, h as DerivedExpressionType, e as FilterOperator, g as HavingExpressionType, k as MAX_CURSOR_SIZE, A as MAX_CURSOR_SORT_FIELDS, I as PagingMode, L as QueryConstraintTypes,
|
|
11
|
+
import { PagingMode as I, QueryConstraintTypes as L, QueryFieldRoles as R, QueryModels as z, QuerySemanticTypes as B, QueryValueKind as V, QueryValueTypes as H, SensitivityLevel as U } from "./dsl/descriptor.es.js";
|
|
12
|
+
import { QueryErrorCodes as W } from "./dsl/queryErrorCodes.es.js";
|
|
13
|
+
export { i as AGGREGATION_LIMITS, a as AggregationDatePart, o as AggregationDateUnit, s as AggregationExpressionOperator, c as AggregationExpressionType, l as AggregationFunction, u as AggregationGroupScope, d as AggregationGroupType, f as AggregationMetricType, p as ComparisonOperator, O as DEFAULT_CURSOR_SIZE, E as DEFAULT_PAGINATION, m as DateDiffUnit, y as DeletionState, h as DerivedExpressionType, e as FilterOperator, g as HavingExpressionType, k as MAX_CURSOR_SIZE, A as MAX_CURSOR_SORT_FIELDS, I as PagingMode, L as QueryConstraintTypes, W as QueryErrorCodes, R as QueryFieldRoles, z as QueryModels, B as QuerySemanticTypes, V as QueryValueKind, H as QueryValueTypes, _ as RunningFunction, t as SearchMode, U as SensitivityLevel, x as SortDirection, n as StringComparison, r as TimeUnit, v as WindowFunction, w as aggregation, S as asc, j as cursorQuery, C as desc, b as filter, M as listQuery, N as pagedList, P as pagedQuery, D as pagination, T as projection, F as singleQuery };
|