@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
|
@@ -3,73 +3,73 @@
|
|
|
3
3
|
* values match the server-side `FilterOperator` enum.
|
|
4
4
|
*/
|
|
5
5
|
export declare enum FilterOperator {
|
|
6
|
-
MATCH_ALL = "
|
|
7
|
-
MATCH_NONE = "
|
|
8
|
-
ID = "
|
|
9
|
-
IDS = "
|
|
10
|
-
AGGREGATE_ID = "
|
|
11
|
-
AGGREGATE_IDS = "
|
|
12
|
-
TENANT_ID = "
|
|
13
|
-
OWNER_ID = "
|
|
14
|
-
SPACE_ID = "
|
|
15
|
-
AND = "
|
|
16
|
-
OR = "
|
|
17
|
-
NOR = "
|
|
18
|
-
EQ = "
|
|
19
|
-
NE = "
|
|
20
|
-
GT = "
|
|
21
|
-
GTE = "
|
|
22
|
-
LT = "
|
|
23
|
-
LTE = "
|
|
24
|
-
CONTAINS = "
|
|
25
|
-
STARTS_WITH = "
|
|
26
|
-
ENDS_WITH = "
|
|
27
|
-
IN = "
|
|
28
|
-
NOT_IN = "
|
|
29
|
-
BETWEEN = "
|
|
30
|
-
CONTAINS_ALL = "
|
|
31
|
-
IS_EMPTY = "
|
|
32
|
-
IS_EMPTY_STRING = "
|
|
33
|
-
IS_NOT_EMPTY_STRING = "
|
|
34
|
-
IS_NULL = "
|
|
35
|
-
IS_NOT_NULL = "
|
|
36
|
-
EXISTS = "
|
|
37
|
-
NOT_EXISTS = "
|
|
38
|
-
DELETION = "
|
|
39
|
-
ELEMENT_MATCH = "
|
|
40
|
-
SEARCH = "
|
|
41
|
-
TODAY = "
|
|
42
|
-
BEFORE_TODAY = "
|
|
43
|
-
TOMORROW = "
|
|
44
|
-
THIS_WEEK = "
|
|
45
|
-
NEXT_WEEK = "
|
|
46
|
-
LAST_WEEK = "
|
|
47
|
-
THIS_MONTH = "
|
|
48
|
-
LAST_MONTH = "
|
|
49
|
-
YESTERDAY = "
|
|
50
|
-
NEXT_MONTH = "
|
|
51
|
-
LAST_YEAR = "
|
|
52
|
-
THIS_YEAR = "
|
|
53
|
-
NEXT_YEAR = "
|
|
54
|
-
RECENT_DAYS = "
|
|
55
|
-
EARLIER_DAYS = "
|
|
6
|
+
MATCH_ALL = "match-all",
|
|
7
|
+
MATCH_NONE = "match-none",
|
|
8
|
+
ID = "id",
|
|
9
|
+
IDS = "ids",
|
|
10
|
+
AGGREGATE_ID = "aggregate-id",
|
|
11
|
+
AGGREGATE_IDS = "aggregate-ids",
|
|
12
|
+
TENANT_ID = "tenant-id",
|
|
13
|
+
OWNER_ID = "owner-id",
|
|
14
|
+
SPACE_ID = "space-id",
|
|
15
|
+
AND = "and",
|
|
16
|
+
OR = "or",
|
|
17
|
+
NOR = "nor",
|
|
18
|
+
EQ = "eq",
|
|
19
|
+
NE = "ne",
|
|
20
|
+
GT = "gt",
|
|
21
|
+
GTE = "gte",
|
|
22
|
+
LT = "lt",
|
|
23
|
+
LTE = "lte",
|
|
24
|
+
CONTAINS = "contains",
|
|
25
|
+
STARTS_WITH = "starts-with",
|
|
26
|
+
ENDS_WITH = "ends-with",
|
|
27
|
+
IN = "in",
|
|
28
|
+
NOT_IN = "not-in",
|
|
29
|
+
BETWEEN = "between",
|
|
30
|
+
CONTAINS_ALL = "contains-all",
|
|
31
|
+
IS_EMPTY = "is-empty",
|
|
32
|
+
IS_EMPTY_STRING = "is-empty-string",
|
|
33
|
+
IS_NOT_EMPTY_STRING = "is-not-empty-string",
|
|
34
|
+
IS_NULL = "is-null",
|
|
35
|
+
IS_NOT_NULL = "is-not-null",
|
|
36
|
+
EXISTS = "exists",
|
|
37
|
+
NOT_EXISTS = "not-exists",
|
|
38
|
+
DELETION = "deletion",
|
|
39
|
+
ELEMENT_MATCH = "element-match",
|
|
40
|
+
SEARCH = "search",
|
|
41
|
+
TODAY = "today",
|
|
42
|
+
BEFORE_TODAY = "before-today",
|
|
43
|
+
TOMORROW = "tomorrow",
|
|
44
|
+
THIS_WEEK = "this-week",
|
|
45
|
+
NEXT_WEEK = "next-week",
|
|
46
|
+
LAST_WEEK = "last-week",
|
|
47
|
+
THIS_MONTH = "this-month",
|
|
48
|
+
LAST_MONTH = "last-month",
|
|
49
|
+
YESTERDAY = "yesterday",
|
|
50
|
+
NEXT_MONTH = "next-month",
|
|
51
|
+
LAST_YEAR = "last-year",
|
|
52
|
+
THIS_YEAR = "this-year",
|
|
53
|
+
NEXT_YEAR = "next-year",
|
|
54
|
+
RECENT_DAYS = "recent-days",
|
|
55
|
+
EARLIER_DAYS = "earlier-days",
|
|
56
56
|
/**
|
|
57
57
|
* The field is strictly before the server's `now + offset`. Needs a Wow
|
|
58
58
|
* server of 9.2.0 or later.
|
|
59
59
|
*/
|
|
60
|
-
BEFORE_NOW = "
|
|
60
|
+
BEFORE_NOW = "before-now",
|
|
61
61
|
/**
|
|
62
62
|
* The field is strictly after the server's `now + offset`. Needs a Wow
|
|
63
63
|
* server of 9.2.0 or later.
|
|
64
64
|
*/
|
|
65
|
-
AFTER_NOW = "
|
|
65
|
+
AFTER_NOW = "after-now",
|
|
66
66
|
/**
|
|
67
67
|
* A computed expression, such as the hours between two time fields,
|
|
68
68
|
* compared with a number. Evaluated per record, so expensive; a record
|
|
69
69
|
* whose expression has no value never matches. Needs a Wow server of
|
|
70
70
|
* 9.2.0 or later.
|
|
71
71
|
*/
|
|
72
|
-
EXPRESSION = "
|
|
72
|
+
EXPRESSION = "expression"
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Case handling for `CONTAINS`, `STARTS_WITH` and `ENDS_WITH`.
|
|
@@ -78,11 +78,11 @@ export declare enum StringComparison {
|
|
|
78
78
|
/**
|
|
79
79
|
* Characters must match exactly. The default.
|
|
80
80
|
*/
|
|
81
|
-
CASE_SENSITIVE = "
|
|
81
|
+
CASE_SENSITIVE = "case-sensitive",
|
|
82
82
|
/**
|
|
83
83
|
* Ignores case. Backends may execute this more expensively.
|
|
84
84
|
*/
|
|
85
|
-
CASE_INSENSITIVE = "
|
|
85
|
+
CASE_INSENSITIVE = "case-insensitive"
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Matching mode of a full-text `SEARCH` filter.
|
|
@@ -92,11 +92,11 @@ export declare enum SearchMode {
|
|
|
92
92
|
* Analyzed terms match independently; they need not appear together. The
|
|
93
93
|
* default.
|
|
94
94
|
*/
|
|
95
|
-
TERMS = "
|
|
95
|
+
TERMS = "terms",
|
|
96
96
|
/**
|
|
97
97
|
* Analyzed terms must appear in order and at adjacent positions.
|
|
98
98
|
*/
|
|
99
|
-
PHRASE = "
|
|
99
|
+
PHRASE = "phrase"
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Unit of a numeric epoch time field targeted by a relative time filter.
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dsl/filter/operator.ts
|
|
2
2
|
var e = /* @__PURE__ */ function(e) {
|
|
3
|
-
return e.MATCH_ALL = "
|
|
3
|
+
return e.MATCH_ALL = "match-all", e.MATCH_NONE = "match-none", e.ID = "id", e.IDS = "ids", e.AGGREGATE_ID = "aggregate-id", e.AGGREGATE_IDS = "aggregate-ids", e.TENANT_ID = "tenant-id", e.OWNER_ID = "owner-id", e.SPACE_ID = "space-id", e.AND = "and", e.OR = "or", e.NOR = "nor", e.EQ = "eq", e.NE = "ne", e.GT = "gt", e.GTE = "gte", e.LT = "lt", e.LTE = "lte", e.CONTAINS = "contains", e.STARTS_WITH = "starts-with", e.ENDS_WITH = "ends-with", e.IN = "in", e.NOT_IN = "not-in", e.BETWEEN = "between", e.CONTAINS_ALL = "contains-all", e.IS_EMPTY = "is-empty", e.IS_EMPTY_STRING = "is-empty-string", e.IS_NOT_EMPTY_STRING = "is-not-empty-string", e.IS_NULL = "is-null", e.IS_NOT_NULL = "is-not-null", e.EXISTS = "exists", e.NOT_EXISTS = "not-exists", e.DELETION = "deletion", e.ELEMENT_MATCH = "element-match", e.SEARCH = "search", e.TODAY = "today", e.BEFORE_TODAY = "before-today", e.TOMORROW = "tomorrow", e.THIS_WEEK = "this-week", e.NEXT_WEEK = "next-week", e.LAST_WEEK = "last-week", e.THIS_MONTH = "this-month", e.LAST_MONTH = "last-month", e.YESTERDAY = "yesterday", e.NEXT_MONTH = "next-month", e.LAST_YEAR = "last-year", e.THIS_YEAR = "this-year", e.NEXT_YEAR = "next-year", e.RECENT_DAYS = "recent-days", e.EARLIER_DAYS = "earlier-days", e.BEFORE_NOW = "before-now", e.AFTER_NOW = "after-now", e.EXPRESSION = "expression", e;
|
|
4
4
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
|
-
return e.CASE_SENSITIVE = "
|
|
5
|
+
return e.CASE_SENSITIVE = "case-sensitive", e.CASE_INSENSITIVE = "case-insensitive", e;
|
|
6
6
|
}({}), n = /* @__PURE__ */ function(e) {
|
|
7
|
-
return e.TERMS = "
|
|
7
|
+
return e.TERMS = "terms", e.PHRASE = "phrase", e;
|
|
8
8
|
}({}), r = /* @__PURE__ */ function(e) {
|
|
9
9
|
return e.NANOSECONDS = "NANOSECONDS", e.MICROSECONDS = "MICROSECONDS", e.MILLISECONDS = "MILLISECONDS", e.SECONDS = "SECONDS", e.MINUTES = "MINUTES", e.HOURS = "HOURS", e.DAYS = "DAYS", e;
|
|
10
10
|
}({});
|
|
11
|
-
//#endregion
|
|
12
11
|
export { e as FilterOperator, n as SearchMode, t as StringComparison, r as TimeUnit };
|
|
13
12
|
|
|
14
13
|
//# sourceMappingURL=operator.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.es.js","names":["FilterOperator","\"MATCH_ALL\"","\"MATCH_NONE\"","\"ID\"","\"IDS\"","\"AGGREGATE_ID\"","\"AGGREGATE_IDS\"","\"TENANT_ID\"","\"OWNER_ID\"","\"SPACE_ID\"","\"AND\"","\"OR\"","\"NOR\"","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","\"CONTAINS\"","\"STARTS_WITH\"","\"ENDS_WITH\"","\"IN\"","\"NOT_IN\"","\"BETWEEN\"","\"CONTAINS_ALL\"","\"IS_EMPTY\"","\"IS_EMPTY_STRING\"","\"IS_NOT_EMPTY_STRING\"","\"IS_NULL\"","\"IS_NOT_NULL\"","\"EXISTS\"","\"NOT_EXISTS\"","\"DELETION\"","\"ELEMENT_MATCH\"","\"SEARCH\"","\"TODAY\"","\"BEFORE_TODAY\"","\"TOMORROW\"","\"THIS_WEEK\"","\"NEXT_WEEK\"","\"LAST_WEEK\"","\"THIS_MONTH\"","\"LAST_MONTH\"","\"YESTERDAY\"","\"NEXT_MONTH\"","\"LAST_YEAR\"","\"THIS_YEAR\"","\"NEXT_YEAR\"","\"RECENT_DAYS\"","\"EARLIER_DAYS\"","\"BEFORE_NOW\"","\"AFTER_NOW\"","\"EXPRESSION\"","StringComparison","\"CASE_SENSITIVE\"","\"CASE_INSENSITIVE\"","SearchMode","\"TERMS\"","\"PHRASE\"","TimeUnit","\"NANOSECONDS\"","\"MICROSECONDS\"","\"MILLISECONDS\"","\"SECONDS\"","\"MINUTES\"","\"HOURS\"","\"DAYS\""],"sources":["../../../src/dsl/filter/operator.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 * Discriminator sent as the `op` property of every filter expression. The\n * values match the server-side `FilterOperator` enum.\n */\nexport enum FilterOperator {\n MATCH_ALL = '
|
|
1
|
+
{"version":3,"file":"operator.es.js","names":["FilterOperator","\"MATCH_ALL\"","\"MATCH_NONE\"","\"ID\"","\"IDS\"","\"AGGREGATE_ID\"","\"AGGREGATE_IDS\"","\"TENANT_ID\"","\"OWNER_ID\"","\"SPACE_ID\"","\"AND\"","\"OR\"","\"NOR\"","\"EQ\"","\"NE\"","\"GT\"","\"GTE\"","\"LT\"","\"LTE\"","\"CONTAINS\"","\"STARTS_WITH\"","\"ENDS_WITH\"","\"IN\"","\"NOT_IN\"","\"BETWEEN\"","\"CONTAINS_ALL\"","\"IS_EMPTY\"","\"IS_EMPTY_STRING\"","\"IS_NOT_EMPTY_STRING\"","\"IS_NULL\"","\"IS_NOT_NULL\"","\"EXISTS\"","\"NOT_EXISTS\"","\"DELETION\"","\"ELEMENT_MATCH\"","\"SEARCH\"","\"TODAY\"","\"BEFORE_TODAY\"","\"TOMORROW\"","\"THIS_WEEK\"","\"NEXT_WEEK\"","\"LAST_WEEK\"","\"THIS_MONTH\"","\"LAST_MONTH\"","\"YESTERDAY\"","\"NEXT_MONTH\"","\"LAST_YEAR\"","\"THIS_YEAR\"","\"NEXT_YEAR\"","\"RECENT_DAYS\"","\"EARLIER_DAYS\"","\"BEFORE_NOW\"","\"AFTER_NOW\"","\"EXPRESSION\"","StringComparison","\"CASE_SENSITIVE\"","\"CASE_INSENSITIVE\"","SearchMode","\"TERMS\"","\"PHRASE\"","TimeUnit","\"NANOSECONDS\"","\"MICROSECONDS\"","\"MILLISECONDS\"","\"SECONDS\"","\"MINUTES\"","\"HOURS\"","\"DAYS\""],"sources":["../../../src/dsl/filter/operator.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 * Discriminator sent as the `op` property of every filter expression. The\n * values match the server-side `FilterOperator` enum.\n */\nexport enum FilterOperator {\n MATCH_ALL = 'match-all',\n MATCH_NONE = 'match-none',\n ID = 'id',\n IDS = 'ids',\n AGGREGATE_ID = 'aggregate-id',\n AGGREGATE_IDS = 'aggregate-ids',\n TENANT_ID = 'tenant-id',\n OWNER_ID = 'owner-id',\n SPACE_ID = 'space-id',\n AND = 'and',\n OR = 'or',\n NOR = 'nor',\n EQ = 'eq',\n NE = 'ne',\n GT = 'gt',\n GTE = 'gte',\n LT = 'lt',\n LTE = 'lte',\n CONTAINS = 'contains',\n STARTS_WITH = 'starts-with',\n ENDS_WITH = 'ends-with',\n IN = 'in',\n NOT_IN = 'not-in',\n BETWEEN = 'between',\n CONTAINS_ALL = 'contains-all',\n IS_EMPTY = 'is-empty',\n IS_EMPTY_STRING = 'is-empty-string',\n IS_NOT_EMPTY_STRING = 'is-not-empty-string',\n IS_NULL = 'is-null',\n IS_NOT_NULL = 'is-not-null',\n EXISTS = 'exists',\n NOT_EXISTS = 'not-exists',\n DELETION = 'deletion',\n ELEMENT_MATCH = 'element-match',\n SEARCH = 'search',\n TODAY = 'today',\n BEFORE_TODAY = 'before-today',\n TOMORROW = 'tomorrow',\n THIS_WEEK = 'this-week',\n NEXT_WEEK = 'next-week',\n LAST_WEEK = 'last-week',\n THIS_MONTH = 'this-month',\n LAST_MONTH = 'last-month',\n YESTERDAY = 'yesterday',\n NEXT_MONTH = 'next-month',\n LAST_YEAR = 'last-year',\n THIS_YEAR = 'this-year',\n NEXT_YEAR = 'next-year',\n RECENT_DAYS = 'recent-days',\n EARLIER_DAYS = 'earlier-days',\n /**\n * The field is strictly before the server's `now + offset`. Needs a Wow\n * server of 9.2.0 or later.\n */\n BEFORE_NOW = 'before-now',\n /**\n * The field is strictly after the server's `now + offset`. Needs a Wow\n * server of 9.2.0 or later.\n */\n AFTER_NOW = 'after-now',\n /**\n * A computed expression, such as the hours between two time fields,\n * compared with a number. Evaluated per record, so expensive; a record\n * whose expression has no value never matches. Needs a Wow server of\n * 9.2.0 or later.\n */\n EXPRESSION = 'expression',\n}\n\n/**\n * Case handling for `CONTAINS`, `STARTS_WITH` and `ENDS_WITH`.\n */\nexport enum StringComparison {\n /**\n * Characters must match exactly. The default.\n */\n CASE_SENSITIVE = 'case-sensitive',\n /**\n * Ignores case. Backends may execute this more expensively.\n */\n CASE_INSENSITIVE = 'case-insensitive',\n}\n\n/**\n * Matching mode of a full-text `SEARCH` filter.\n */\nexport enum SearchMode {\n /**\n * Analyzed terms match independently; they need not appear together. The\n * default.\n */\n TERMS = 'terms',\n /**\n * Analyzed terms must appear in order and at adjacent positions.\n */\n PHRASE = 'phrase',\n}\n\n/**\n * Unit of a numeric epoch time field targeted by a relative time filter.\n * Ignored when `datePattern` is set.\n */\nexport enum TimeUnit {\n NANOSECONDS = 'NANOSECONDS',\n MICROSECONDS = 'MICROSECONDS',\n MILLISECONDS = 'MILLISECONDS',\n SECONDS = 'SECONDS',\n MINUTES = 'MINUTES',\n HOURS = 'HOURS',\n DAYS = 'DAYS',\n}\n"],"mappings":";AAiBA,IAAYA,IAAL,yBAAA,GAAA;C,OACL,EAAAC,YAAA,aACA,EAAAC,aAAA,cACA,EAAAC,KAAA,MACA,EAAAC,MAAA,OACA,EAAAC,eAAA,gBACA,EAAAC,gBAAA,iBACA,EAAAC,YAAA,aACA,EAAAC,WAAA,YACA,EAAAC,WAAA,YACA,EAAAC,MAAA,OACA,EAAAC,KAAA,MACA,EAAAC,MAAA,OACA,EAAAC,KAAA,MACA,EAAAC,KAAA,MACA,EAAAC,KAAA,MACA,EAAAC,MAAA,OACA,EAAAC,KAAA,MACA,EAAAC,MAAA,OACA,EAAAC,WAAA,YACA,EAAAC,cAAA,eACA,EAAAC,YAAA,aACA,EAAAC,KAAA,MACA,EAAAC,SAAA,UACA,EAAAC,UAAA,WACA,EAAAC,eAAA,gBACA,EAAAC,WAAA,YACA,EAAAC,kBAAA,mBACA,EAAAC,sBAAA,uBACA,EAAAC,UAAA,WACA,EAAAC,cAAA,eACA,EAAAC,SAAA,UACA,EAAAC,aAAA,cACA,EAAAC,WAAA,YACA,EAAAC,gBAAA,iBACA,EAAAC,SAAA,UACA,EAAAC,QAAA,SACA,EAAAC,eAAA,gBACA,EAAAC,WAAA,YACA,EAAAC,YAAA,aACA,EAAAC,YAAA,aACA,EAAAC,YAAA,aACA,EAAAC,aAAA,cACA,EAAAC,aAAA,cACA,EAAAC,YAAA,aACA,EAAAC,aAAA,cACA,EAAAC,YAAA,aACA,EAAAC,YAAA,aACA,EAAAC,YAAA,aACA,EAAAC,cAAA,eACA,EAAAC,eAAA,gBAKA,EAAAC,aAAA,cAKA,EAAAC,YAAA,aAOA,EAAAC,aAAA,c;AACF,EAAA,CAAA,CAAA,GAKYC,IAAL,yBAAA,GAAA;C,OAIL,EAAAC,iBAAA,kBAIA,EAAAC,mBAAA,oB;AACF,EAAA,CAAA,CAAA,GAKYC,IAAL,yBAAA,GAAA;C,OAKL,EAAAC,QAAA,SAIA,EAAAC,SAAA,U;AACF,EAAA,CAAA,CAAA,GAMYC,IAAL,yBAAA,GAAA;C,OACL,EAAAC,cAAA,eACA,EAAAC,eAAA,gBACA,EAAAC,eAAA,gBACA,EAAAC,UAAA,WACA,EAAAC,UAAA,WACA,EAAAC,QAAA,SACA,EAAAC,OAAA,Q;AACF,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./operator.cjs");function
|
|
1
|
+
const e=require("./operator.cjs"),t=require("../constantName.cjs");function n(r,i,a=!0){switch(r.op){case e.FilterOperator.ID:case e.FilterOperator.IDS:case e.FilterOperator.AGGREGATE_ID:case e.FilterOperator.AGGREGATE_IDS:case e.FilterOperator.TENANT_ID:case e.FilterOperator.OWNER_ID:case e.FilterOperator.SPACE_ID:case e.FilterOperator.DELETION:throw TypeError(`${i} cannot contain root filters.`);case e.FilterOperator.EXPRESSION:if(a)throw TypeError(`${i} cannot contain root filters.`);break;case e.FilterOperator.SEARCH:if(!a||!r.fields?.length)throw TypeError(`${i} cannot contain root filters.`);break;case e.FilterOperator.AND:case e.FilterOperator.OR:case e.FilterOperator.NOR:if(r.operands.length===0)throw TypeError(`${t.constantName(r.op)} operands cannot be empty.`);if(r.operands.some(e=>e==null))throw TypeError(`${t.constantName(r.op)} operands cannot contain null.`);r.operands.forEach(e=>n(e,i,a));break;case e.FilterOperator.ELEMENT_MATCH:n(r.predicate,i,a)}}exports.requireElementScopedFilter=n;
|
|
2
2
|
//# sourceMappingURL=scope.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.cjs","names":["FilterOperator","require_operator","requireElementScopedFilter","expression","subject","fieldSearch","operand"],"sources":["../../../src/dsl/filter/scope.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// Internal: not re-exported by filter/index.ts. `filter.elementMatch` and an\n// aggregation element's own filter both scope a filter to an element; this is\n// the one rule they share.\nimport { FilterOperator } from './operator.js';\nimport type { FilterExpression } from './types.js';\n\n/**\n * Refuses the filters that only a whole record can answer.\n *\n * The metadata filters, `DELETION` and a model-wide `SEARCH` ask about the\n * record — its id, its owner, whether it is deleted, its text — and an\n * element is not a record. Wow calls them root filters and refuses them in\n * both places a filter is scoped to an element: an `ELEMENT_MATCH` predicate\n * and an aggregation element's own filter. A `SEARCH` that names its fields\n * asks about the element's text, which an `ELEMENT_MATCH` predicate takes\n * (`fieldSearch`) and an aggregation element's filter does not; an\n * `EXPRESSION` filter goes the other way round. `subject`\n * names which one, so the complaint points at the call that made it.\n */\nexport function requireElementScopedFilter(\n expression: FilterExpression,\n subject: string,\n fieldSearch = true,\n): void {\n switch (expression.op) {\n case FilterOperator.ID:\n case FilterOperator.IDS:\n case FilterOperator.AGGREGATE_ID:\n case FilterOperator.AGGREGATE_IDS:\n case FilterOperator.TENANT_ID:\n case FilterOperator.OWNER_ID:\n case FilterOperator.SPACE_ID:\n case FilterOperator.DELETION:\n throw new TypeError(`${subject} cannot contain root filters.`);\n // A computed comparison cannot run inside ELEMENT_MATCH on every storage;\n // an aggregation element's filter takes it.\n case FilterOperator.EXPRESSION:\n if (fieldSearch)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.SEARCH:\n if (!fieldSearch || !expression.fields?.length)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n if (expression.operands.length === 0) {\n throw new TypeError(`${expression.op} operands cannot be empty
|
|
1
|
+
{"version":3,"file":"scope.cjs","names":["FilterOperator","constantName","require_operator","require_constantName","requireElementScopedFilter","expression","subject","fieldSearch","operand"],"sources":["../../../src/dsl/filter/scope.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// Internal: not re-exported by filter/index.ts. `filter.elementMatch` and an\n// aggregation element's own filter both scope a filter to an element; this is\n// the one rule they share.\nimport { constantName } from '../constantName.js';\nimport { FilterOperator } from './operator.js';\nimport type { FilterExpression } from './types.js';\n\n/**\n * Refuses the filters that only a whole record can answer.\n *\n * The metadata filters, `DELETION` and a model-wide `SEARCH` ask about the\n * record — its id, its owner, whether it is deleted, its text — and an\n * element is not a record. Wow calls them root filters and refuses them in\n * both places a filter is scoped to an element: an `ELEMENT_MATCH` predicate\n * and an aggregation element's own filter. A `SEARCH` that names its fields\n * asks about the element's text, which an `ELEMENT_MATCH` predicate takes\n * (`fieldSearch`) and an aggregation element's filter does not; an\n * `EXPRESSION` filter goes the other way round. `subject`\n * names which one, so the complaint points at the call that made it.\n */\nexport function requireElementScopedFilter(\n expression: FilterExpression,\n subject: string,\n fieldSearch = true,\n): void {\n switch (expression.op) {\n case FilterOperator.ID:\n case FilterOperator.IDS:\n case FilterOperator.AGGREGATE_ID:\n case FilterOperator.AGGREGATE_IDS:\n case FilterOperator.TENANT_ID:\n case FilterOperator.OWNER_ID:\n case FilterOperator.SPACE_ID:\n case FilterOperator.DELETION:\n throw new TypeError(`${subject} cannot contain root filters.`);\n // A computed comparison cannot run inside ELEMENT_MATCH on every storage;\n // an aggregation element's filter takes it.\n case FilterOperator.EXPRESSION:\n if (fieldSearch)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.SEARCH:\n if (!fieldSearch || !expression.fields?.length)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n if (expression.operands.length === 0) {\n throw new TypeError(\n `${constantName(expression.op)} operands cannot be empty.`,\n );\n }\n if (expression.operands.some(operand => operand == null)) {\n throw new TypeError(\n `${constantName(expression.op)} operands cannot contain null.`,\n );\n }\n expression.operands.forEach(operand =>\n requireElementScopedFilter(operand, subject, fieldSearch),\n );\n break;\n case FilterOperator.ELEMENT_MATCH:\n requireElementScopedFilter(expression.predicate, subject, fieldSearch);\n break;\n }\n}\n"],"mappings":"A,mEAiCA,SAAgBI,EACd,EACA,EACA,EAAc,GACR,CACN,OAAQC,EAAW,GAAnB,CACE,KAAKL,EAAAA,eAAe,GACpB,KAAKA,EAAAA,eAAe,IACpB,KAAKA,EAAAA,eAAe,aACpB,KAAKA,EAAAA,eAAe,cACpB,KAAKA,EAAAA,eAAe,UACpB,KAAKA,EAAAA,eAAe,SACpB,KAAKA,EAAAA,eAAe,SACpB,KAAKA,EAAAA,eAAe,SAClB,MAAU,UAAU,GAAGM,EAAQ,8BAA8B,EAG/D,KAAKN,EAAAA,eAAe,WAClB,GAAIO,EACF,MAAU,UAAU,GAAGD,EAAQ,8BAA8B,EAC/D,MACF,KAAKN,EAAAA,eAAe,OAClB,GAAI,CAACO,GAAe,CAACF,EAAW,QAAQ,OACtC,MAAU,UAAU,GAAGC,EAAQ,8BAA8B,EAC/D,MACF,KAAKN,EAAAA,eAAe,IACpB,KAAKA,EAAAA,eAAe,GACpB,KAAKA,EAAAA,eAAe,IAClB,GAAIK,EAAW,SAAS,SAAW,EACjC,MAAU,UACR,GAAGJ,EAAAA,aAAaI,EAAW,EAAE,EAAE,2BACjC,EAEF,GAAIA,EAAW,SAAS,KAAK,GAAWG,GAAW,IAAI,EACrD,MAAU,UACR,GAAGP,EAAAA,aAAaI,EAAW,EAAE,EAAE,+BACjC,EAEFA,EAAW,SAAS,QAAQ,GAC1BD,EAA2BI,EAASF,EAASC,CAAW,CAC1D,EACA,MACF,KAAKP,EAAAA,eAAe,cAClBI,EAA2BC,EAAW,UAAWC,EAASC,CAAW,CAEzE,CACF,C"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FilterOperator as e } from "./operator.es.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { constantName as t } from "../constantName.es.js";
|
|
3
|
+
// src/dsl/filter/scope.ts
|
|
4
|
+
function n(r, i, a = !0) {
|
|
5
|
+
switch (r.op) {
|
|
5
6
|
case e.ID:
|
|
6
7
|
case e.IDS:
|
|
7
8
|
case e.AGGREGATE_ID:
|
|
@@ -9,24 +10,23 @@ function t(n, r, i = !0) {
|
|
|
9
10
|
case e.TENANT_ID:
|
|
10
11
|
case e.OWNER_ID:
|
|
11
12
|
case e.SPACE_ID:
|
|
12
|
-
case e.DELETION: throw TypeError(`${
|
|
13
|
+
case e.DELETION: throw TypeError(`${i} cannot contain root filters.`);
|
|
13
14
|
case e.EXPRESSION:
|
|
14
|
-
if (
|
|
15
|
+
if (a) throw TypeError(`${i} cannot contain root filters.`);
|
|
15
16
|
break;
|
|
16
17
|
case e.SEARCH:
|
|
17
|
-
if (!
|
|
18
|
+
if (!a || !r.fields?.length) throw TypeError(`${i} cannot contain root filters.`);
|
|
18
19
|
break;
|
|
19
20
|
case e.AND:
|
|
20
21
|
case e.OR:
|
|
21
22
|
case e.NOR:
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
|
|
23
|
+
if (r.operands.length === 0) throw TypeError(`${t(r.op)} operands cannot be empty.`);
|
|
24
|
+
if (r.operands.some((e) => e == null)) throw TypeError(`${t(r.op)} operands cannot contain null.`);
|
|
25
|
+
r.operands.forEach((e) => n(e, i, a));
|
|
25
26
|
break;
|
|
26
|
-
case e.ELEMENT_MATCH:
|
|
27
|
+
case e.ELEMENT_MATCH: n(r.predicate, i, a);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
export { t as requireElementScopedFilter };
|
|
30
|
+
export { n as requireElementScopedFilter };
|
|
31
31
|
|
|
32
32
|
//# sourceMappingURL=scope.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.es.js","names":["requireElementScopedFilter","expression","FilterOperator","subject","fieldSearch","operand"],"sources":["../../../src/dsl/filter/scope.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// Internal: not re-exported by filter/index.ts. `filter.elementMatch` and an\n// aggregation element's own filter both scope a filter to an element; this is\n// the one rule they share.\nimport { FilterOperator } from './operator.js';\nimport type { FilterExpression } from './types.js';\n\n/**\n * Refuses the filters that only a whole record can answer.\n *\n * The metadata filters, `DELETION` and a model-wide `SEARCH` ask about the\n * record — its id, its owner, whether it is deleted, its text — and an\n * element is not a record. Wow calls them root filters and refuses them in\n * both places a filter is scoped to an element: an `ELEMENT_MATCH` predicate\n * and an aggregation element's own filter. A `SEARCH` that names its fields\n * asks about the element's text, which an `ELEMENT_MATCH` predicate takes\n * (`fieldSearch`) and an aggregation element's filter does not; an\n * `EXPRESSION` filter goes the other way round. `subject`\n * names which one, so the complaint points at the call that made it.\n */\nexport function requireElementScopedFilter(\n expression: FilterExpression,\n subject: string,\n fieldSearch = true,\n): void {\n switch (expression.op) {\n case FilterOperator.ID:\n case FilterOperator.IDS:\n case FilterOperator.AGGREGATE_ID:\n case FilterOperator.AGGREGATE_IDS:\n case FilterOperator.TENANT_ID:\n case FilterOperator.OWNER_ID:\n case FilterOperator.SPACE_ID:\n case FilterOperator.DELETION:\n throw new TypeError(`${subject} cannot contain root filters.`);\n // A computed comparison cannot run inside ELEMENT_MATCH on every storage;\n // an aggregation element's filter takes it.\n case FilterOperator.EXPRESSION:\n if (fieldSearch)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.SEARCH:\n if (!fieldSearch || !expression.fields?.length)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n if (expression.operands.length === 0) {\n throw new TypeError(`${expression.op} operands cannot be empty
|
|
1
|
+
{"version":3,"file":"scope.es.js","names":["requireElementScopedFilter","expression","FilterOperator","subject","fieldSearch","constantName","operand"],"sources":["../../../src/dsl/filter/scope.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// Internal: not re-exported by filter/index.ts. `filter.elementMatch` and an\n// aggregation element's own filter both scope a filter to an element; this is\n// the one rule they share.\nimport { constantName } from '../constantName.js';\nimport { FilterOperator } from './operator.js';\nimport type { FilterExpression } from './types.js';\n\n/**\n * Refuses the filters that only a whole record can answer.\n *\n * The metadata filters, `DELETION` and a model-wide `SEARCH` ask about the\n * record — its id, its owner, whether it is deleted, its text — and an\n * element is not a record. Wow calls them root filters and refuses them in\n * both places a filter is scoped to an element: an `ELEMENT_MATCH` predicate\n * and an aggregation element's own filter. A `SEARCH` that names its fields\n * asks about the element's text, which an `ELEMENT_MATCH` predicate takes\n * (`fieldSearch`) and an aggregation element's filter does not; an\n * `EXPRESSION` filter goes the other way round. `subject`\n * names which one, so the complaint points at the call that made it.\n */\nexport function requireElementScopedFilter(\n expression: FilterExpression,\n subject: string,\n fieldSearch = true,\n): void {\n switch (expression.op) {\n case FilterOperator.ID:\n case FilterOperator.IDS:\n case FilterOperator.AGGREGATE_ID:\n case FilterOperator.AGGREGATE_IDS:\n case FilterOperator.TENANT_ID:\n case FilterOperator.OWNER_ID:\n case FilterOperator.SPACE_ID:\n case FilterOperator.DELETION:\n throw new TypeError(`${subject} cannot contain root filters.`);\n // A computed comparison cannot run inside ELEMENT_MATCH on every storage;\n // an aggregation element's filter takes it.\n case FilterOperator.EXPRESSION:\n if (fieldSearch)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.SEARCH:\n if (!fieldSearch || !expression.fields?.length)\n throw new TypeError(`${subject} cannot contain root filters.`);\n break;\n case FilterOperator.AND:\n case FilterOperator.OR:\n case FilterOperator.NOR:\n if (expression.operands.length === 0) {\n throw new TypeError(\n `${constantName(expression.op)} operands cannot be empty.`,\n );\n }\n if (expression.operands.some(operand => operand == null)) {\n throw new TypeError(\n `${constantName(expression.op)} operands cannot contain null.`,\n );\n }\n expression.operands.forEach(operand =>\n requireElementScopedFilter(operand, subject, fieldSearch),\n );\n break;\n case FilterOperator.ELEMENT_MATCH:\n requireElementScopedFilter(expression.predicate, subject, fieldSearch);\n break;\n }\n}\n"],"mappings":";;;AAiCA,SAAgBA,EACd,GACA,GACA,IAAc,IACR;CACN,QAAQC,EAAW,IAAnB;EACE,KAAKC,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe,UAClB,MAAU,UAAU,GAAGC,EAAQ,8BAA8B;EAG/D,KAAKD,EAAe;GAClB,IAAIE,GACF,MAAU,UAAU,GAAGD,EAAQ,8BAA8B;GAC/D;EACF,KAAKD,EAAe;GAClB,IAAI,CAACE,KAAe,CAACH,EAAW,QAAQ,QACtC,MAAU,UAAU,GAAGE,EAAQ,8BAA8B;GAC/D;EACF,KAAKD,EAAe;EACpB,KAAKA,EAAe;EACpB,KAAKA,EAAe;GAClB,IAAID,EAAW,SAAS,WAAW,GACjC,MAAU,UACR,GAAGI,EAAaJ,EAAW,EAAE,EAAE,2BACjC;GAEF,IAAIA,EAAW,SAAS,MAAK,MAAWK,KAAW,IAAI,GACrD,MAAU,UACR,GAAGD,EAAaJ,EAAW,EAAE,EAAE,+BACjC;GAEF,EAAW,SAAS,SAAQ,MAC1BD,EAA2BM,GAASH,GAASC,CAAW,CAC1D;GACA;EACF,KAAKF,EAAe,eAClB,EAA2BD,EAAW,WAAWE,GAASC,CAAW;CAEzE;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./operator.cjs"),t=require("./datePattern.cjs");var
|
|
1
|
+
const e=require("./operator.cjs"),t=require("../constantName.cjs"),n=require("./datePattern.cjs");var r=/^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?$/,i=/^(?:UTC|GMT|UT)?[+-](\d{1,2}|\d{4}|\d{6}|\d{2}:\d{2}|\d{2}:\d{2}:\d{2})$/,a=/^(?:UTC|GMT|UT)?[+-]/,o=/^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;function s(e,t){if(!(e===null?t:typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)))throw TypeError(`Filter value must be a JSON scalar.`);return e}function c(e,t){if(typeof t!=`string`)throw TypeError(`${e} must be a string.`);return t}function l(t){if(t!==e.StringComparison.CASE_SENSITIVE&&t!==e.StringComparison.CASE_INSENSITIVE)throw TypeError(`String comparison is invalid: [${String(t)}].`)}function u(e,t){if(t.length===0)throw TypeError(`${e} cannot be empty.`);if(t.some(e=>e==null))throw TypeError(`${e} cannot contain null.`)}function d(e){let t=i.exec(e);if(!t)return!1;let n=t[1],[r,a=0,o=0]=(n.includes(`:`)?n.split(`:`):n.length<=2?[n]:[n.slice(0,2),n.slice(2,4),n.slice(4,6)]).map(Number);return a<=59&&o<=59&&(r<18||r===18&&a===0&&o===0)}function f({zoneId:t,datePattern:r,timeUnit:i=e.TimeUnit.MILLISECONDS}){if(t!==void 0){if(typeof t!=`string`||!t.trim())throw TypeError(`zoneId cannot be blank.`);if(a.test(t)&&!d(t))throw TypeError(`zoneId is invalid: [${t}].`)}if(r!==void 0&&n.validateDatePattern(r),!Object.values(e.TimeUnit).includes(i))throw TypeError(`timeUnit is invalid: [${String(i)}].`);return{...t===void 0?{}:{zoneId:t},...r===void 0?{}:{datePattern:r},timeUnit:i}}function p(e,n){if(!Number.isInteger(n)||n<1||n>2147483647)throw TypeError(`${t.constantName(e)} days must be a positive JVM Int.`)}function m(e,n){if(typeof n!=`string`||!o.test(n))throw TypeError(`${t.constantName(e)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);return n}function h(e){if(typeof e!=`string`||!r.test(e))throw TypeError(`BEFORE_TODAY time is invalid.`);return e}exports.filterLiteral=s,exports.requireDuration=m,exports.requireLocalTime=h,exports.requireNonEmpty=u,exports.requiredString=c,exports.validateDays=p,exports.validateRelativeTimeOptions=f,exports.validateStringComparison=l;
|
|
2
2
|
//# sourceMappingURL=validate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.cjs","names":["StringComparison","TimeUnit","require_operator","require_datePattern","LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","requireNonEmpty","values","isValidOffsetZone","match","zoneId","offset","hours","minutes","seconds","validateRelativeTimeOptions","datePattern","timeUnit","validateDays","days","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { validateDatePattern } from './datePattern.js';\nimport { StringComparison, TimeUnit, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(zoneId: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(zoneId);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n zoneId,\n datePattern,\n timeUnit = TimeUnit.MILLISECONDS,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions & {\n timeUnit: TimeUnit;\n} {\n if (zoneId !== undefined) {\n if (typeof zoneId !== 'string' || !zoneId.trim()) {\n throw new TypeError('zoneId cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(zoneId) &&\n !isValidOffsetZone(zoneId)\n ) {\n throw new TypeError(`zoneId is invalid: [${zoneId}].`);\n }\n }\n if (datePattern !== undefined) {\n validateDatePattern(datePattern);\n }\n if (!Object.values(TimeUnit).includes(timeUnit)) {\n throw new TypeError(`timeUnit is invalid: [${String(timeUnit)}].`);\n }\n return {\n ...(zoneId === undefined ? {} : { zoneId }),\n ...(datePattern === undefined ? {} : { datePattern }),\n timeUnit,\n };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(`${operator} days must be a positive JVM Int
|
|
1
|
+
{"version":3,"file":"validate.cjs","names":["StringComparison","TimeUnit","constantName","require_operator","require_constantName","require_datePattern","LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","requireNonEmpty","values","isValidOffsetZone","match","zoneId","offset","hours","minutes","seconds","validateRelativeTimeOptions","datePattern","timeUnit","validateDays","days","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { constantName } from '../constantName.js';\nimport { validateDatePattern } from './datePattern.js';\nimport { StringComparison, TimeUnit, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(zoneId: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(zoneId);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n zoneId,\n datePattern,\n timeUnit = TimeUnit.MILLISECONDS,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions & {\n timeUnit: TimeUnit;\n} {\n if (zoneId !== undefined) {\n if (typeof zoneId !== 'string' || !zoneId.trim()) {\n throw new TypeError('zoneId cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(zoneId) &&\n !isValidOffsetZone(zoneId)\n ) {\n throw new TypeError(`zoneId is invalid: [${zoneId}].`);\n }\n }\n if (datePattern !== undefined) {\n validateDatePattern(datePattern);\n }\n if (!Object.values(TimeUnit).includes(timeUnit)) {\n throw new TypeError(`timeUnit is invalid: [${String(timeUnit)}].`);\n }\n return {\n ...(zoneId === undefined ? {} : { zoneId }),\n ...(datePattern === undefined ? {} : { datePattern }),\n timeUnit,\n };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(\n `${constantName(operator)} days must be a positive JVM Int.`,\n );\n }\n}\n\n/**\n * Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the\n * server's now, in the grammar `java.time.Duration.parse` accepts. A value\n * too large for a `Duration` is left to the server.\n */\nexport function requireDuration(\n operator: FilterOperator,\n offset: string,\n): string {\n if (typeof offset !== 'string' || !DURATION_PATTERN.test(offset)) {\n throw new TypeError(\n `${constantName(operator)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`,\n );\n }\n return offset;\n}\n\n/** Admits the 24-hour local time `BEFORE_TODAY` compares against. */\nexport function requireLocalTime(time: string): string {\n if (typeof time !== 'string' || !LOCAL_TIME_PATTERN.test(time)) {\n throw new TypeError('BEFORE_TODAY time is invalid.');\n }\n return time;\n}\n"],"mappings":"A,kGAoBA,IAAMM,EACJ,mEACIC,EACJ,2EACIC,EAAgC,uBAIhCC,EACJ,kIAEF,SAAgBC,EACd,EACA,EACG,CAOH,GAAI,EALFC,IAAU,KACNC,EACA,OAAOD,GAAU,UACjB,OAAOA,GAAU,WAChB,OAAOA,GAAU,UAAY,OAAO,SAASA,CAAK,GAEvD,MAAU,UAAU,qCAAqC,EAE3D,OAAOA,CACT,CAEA,SAAgBE,EAAe,EAAc,EAAuB,CAClE,GAAI,OAAOF,GAAU,SACnB,MAAU,UAAU,GAAGG,EAAK,mBAAmB,EAEjD,OAAOH,CACT,CAEA,SAAgBI,EAAyB,EAAoC,CAC3E,GACEC,IAAehB,EAAAA,iBAAiB,gBAChCgB,IAAehB,EAAAA,iBAAiB,iBAEhC,MAAU,UACR,kCAAkC,OAAOgB,CAAU,EAAE,GACvD,CAEJ,CAEA,SAAgBC,EACd,EACA,EACM,CACN,GAAIC,EAAO,SAAW,EACpB,MAAU,UAAU,GAAGJ,EAAK,kBAAkB,EAEhD,GAAII,EAAO,KAAK,GAASP,GAAU,IAA2B,EAC5D,MAAU,UAAU,GAAGG,EAAK,sBAAsB,CAEtD,CAEA,SAASK,EAAkB,EAAyB,CAClD,IAAMC,EAAQb,EAAoB,KAAKc,CAAM,EAC7C,GAAI,CAACD,EAAO,MAAO,GACnB,IAAME,EAASF,EAAM,GAMf,CAACG,EAAOC,EAAU,EAAGC,EAAU,IALvBH,EAAO,SAAS,GAAG,EAC7BA,EAAO,MAAM,GAAG,EAChBA,EAAO,QAAU,EACf,CAACA,CAAM,EACP,CAACA,EAAO,MAAM,EAAG,CAAC,EAAGA,EAAO,MAAM,EAAG,CAAC,EAAGA,EAAO,MAAM,EAAG,CAAC,CAAC,EAAA,CACjB,IAAI,MAAM,EAC1D,OACEE,GAAW,IACXC,GAAW,KACVF,EAAQ,IAAOA,IAAU,IAAMC,IAAY,GAAKC,IAAY,EAEjE,CAEA,SAAgBC,EAA4B,CAC1C,SACA,cACA,WAAWzB,EAAAA,SAAS,cAGpB,CACA,GAAIoB,IAAW,IAAA,GAAW,CACxB,GAAI,OAAOA,GAAW,UAAY,CAACA,EAAO,KAAK,EAC7C,MAAU,UAAU,yBAAyB,EAE/C,GACEb,EAA8B,KAAKa,CAAM,GACzC,CAACF,EAAkBE,CAAM,EAEzB,MAAU,UAAU,uBAAuBA,EAAO,GAAG,CAEzD,CAIA,GAHIM,IAAgB,IAAA,IAClBtB,EAAA,oBAAoBsB,CAAW,EAE7B,CAAC,OAAO,OAAO1B,EAAAA,QAAQ,CAAC,CAAC,SAAS2B,CAAQ,EAC5C,MAAU,UAAU,yBAAyB,OAAOA,CAAQ,EAAE,GAAG,EAEnE,MAAO,CACL,GAAIP,IAAW,IAAA,GAAY,CAAC,EAAI,CAAE,QAAO,EACzC,GAAIM,IAAgB,IAAA,GAAY,CAAC,EAAI,CAAE,aAAY,EACnD,UACF,CACF,CAEA,SAAgBE,EAAa,EAA0B,EAAoB,CACzE,GAAI,CAAC,OAAO,UAAUC,CAAI,GAAKA,EAAO,GAAKA,EAAO,WAChD,MAAU,UACR,GAAG5B,EAAAA,aAAa6B,CAAQ,EAAE,kCAC5B,CAEJ,CAOA,SAAgBC,EACd,EACA,EACQ,CACR,GAAI,OAAOV,GAAW,UAAY,CAACb,EAAiB,KAAKa,CAAM,EAC7D,MAAU,UACR,GAAGpB,EAAAA,aAAa6B,CAAQ,EAAE,6DAC5B,EAEF,OAAOT,CACT,CAGA,SAAgBW,EAAiB,EAAsB,CACrD,GAAI,OAAOC,GAAS,UAAY,CAAC5B,EAAmB,KAAK4B,CAAI,EAC3D,MAAU,UAAU,+BAA+B,EAErD,OAAOA,CACT,C"}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
import { StringComparison as e, TimeUnit as t } from "./operator.es.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { constantName as n } from "../constantName.es.js";
|
|
3
|
+
import { validateDatePattern as r } from "./datePattern.es.js";
|
|
4
|
+
// src/dsl/filter/validate.ts
|
|
5
|
+
var i = /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\.[0-9]{1,9})?)?$/, a = /^(?:UTC|GMT|UT)?[+-](\d{1,2}|\d{4}|\d{6}|\d{2}:\d{2}|\d{2}:\d{2}:\d{2})$/, o = /^(?:UTC|GMT|UT)?[+-]/, s = /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;
|
|
6
|
+
function c(e, t) {
|
|
6
7
|
if (!(e === null ? t : typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e))) throw TypeError("Filter value must be a JSON scalar.");
|
|
7
8
|
return e;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function l(e, t) {
|
|
10
11
|
if (typeof t != "string") throw TypeError(`${e} must be a string.`);
|
|
11
12
|
return t;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function u(t) {
|
|
14
15
|
if (t !== e.CASE_SENSITIVE && t !== e.CASE_INSENSITIVE) throw TypeError(`String comparison is invalid: [${String(t)}].`);
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function d(e, t) {
|
|
17
18
|
if (t.length === 0) throw TypeError(`${e} cannot be empty.`);
|
|
18
19
|
if (t.some((e) => e == null)) throw TypeError(`${e} cannot contain null.`);
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
let t =
|
|
21
|
+
function f(e) {
|
|
22
|
+
let t = a.exec(e);
|
|
22
23
|
if (!t) return !1;
|
|
23
|
-
let n = t[1], [r,
|
|
24
|
+
let n = t[1], [r, i = 0, o = 0] = (n.includes(":") ? n.split(":") : n.length <= 2 ? [n] : [
|
|
24
25
|
n.slice(0, 2),
|
|
25
26
|
n.slice(2, 4),
|
|
26
27
|
n.slice(4, 6)
|
|
27
28
|
]).map(Number);
|
|
28
|
-
return
|
|
29
|
+
return i <= 59 && o <= 59 && (r < 18 || r === 18 && i === 0 && o === 0);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function p({ zoneId: e, datePattern: n, timeUnit: i = t.MILLISECONDS }) {
|
|
31
32
|
if (e !== void 0) {
|
|
32
33
|
if (typeof e != "string" || !e.trim()) throw TypeError("zoneId cannot be blank.");
|
|
33
|
-
if (
|
|
34
|
+
if (o.test(e) && !f(e)) throw TypeError(`zoneId is invalid: [${e}].`);
|
|
34
35
|
}
|
|
35
|
-
if (
|
|
36
|
+
if (n !== void 0 && r(n), !Object.values(t).includes(i)) throw TypeError(`timeUnit is invalid: [${String(i)}].`);
|
|
36
37
|
return {
|
|
37
38
|
...e === void 0 ? {} : { zoneId: e },
|
|
38
|
-
...
|
|
39
|
+
...n === void 0 ? {} : { datePattern: n },
|
|
39
40
|
timeUnit: i
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
|
-
function p(e, t) {
|
|
43
|
-
if (!Number.isInteger(t) || t < 1 || t > 2147483647) throw TypeError(`${e} days must be a positive JVM Int.`);
|
|
44
|
-
}
|
|
45
43
|
function m(e, t) {
|
|
46
|
-
if (
|
|
44
|
+
if (!Number.isInteger(t) || t < 1 || t > 2147483647) throw TypeError(`${n(e)} days must be a positive JVM Int.`);
|
|
45
|
+
}
|
|
46
|
+
function h(e, t) {
|
|
47
|
+
if (typeof t != "string" || !s.test(t)) throw TypeError(`${n(e)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`);
|
|
47
48
|
return t;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
if (typeof e != "string" || !
|
|
50
|
+
function g(e) {
|
|
51
|
+
if (typeof e != "string" || !i.test(e)) throw TypeError("BEFORE_TODAY time is invalid.");
|
|
51
52
|
return e;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
export { s as filterLiteral, m as requireDuration, h as requireLocalTime, u as requireNonEmpty, c as requiredString, p as validateDays, f as validateRelativeTimeOptions, l as validateStringComparison };
|
|
54
|
+
export { c as filterLiteral, h as requireDuration, g as requireLocalTime, d as requireNonEmpty, l as requiredString, m as validateDays, p as validateRelativeTimeOptions, u as validateStringComparison };
|
|
55
55
|
|
|
56
56
|
//# sourceMappingURL=validate.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.es.js","names":["LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","StringComparison","requireNonEmpty","values","isValidOffsetZone","match","zoneId","offset","hours","minutes","seconds","validateRelativeTimeOptions","TimeUnit","datePattern","validateDatePattern","timeUnit","validateDays","days","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { validateDatePattern } from './datePattern.js';\nimport { StringComparison, TimeUnit, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(zoneId: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(zoneId);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n zoneId,\n datePattern,\n timeUnit = TimeUnit.MILLISECONDS,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions & {\n timeUnit: TimeUnit;\n} {\n if (zoneId !== undefined) {\n if (typeof zoneId !== 'string' || !zoneId.trim()) {\n throw new TypeError('zoneId cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(zoneId) &&\n !isValidOffsetZone(zoneId)\n ) {\n throw new TypeError(`zoneId is invalid: [${zoneId}].`);\n }\n }\n if (datePattern !== undefined) {\n validateDatePattern(datePattern);\n }\n if (!Object.values(TimeUnit).includes(timeUnit)) {\n throw new TypeError(`timeUnit is invalid: [${String(timeUnit)}].`);\n }\n return {\n ...(zoneId === undefined ? {} : { zoneId }),\n ...(datePattern === undefined ? {} : { datePattern }),\n timeUnit,\n };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(`${operator} days must be a positive JVM Int
|
|
1
|
+
{"version":3,"file":"validate.es.js","names":["LOCAL_TIME_PATTERN","OFFSET_ZONE_PATTERN","OFFSET_ZONE_CANDIDATE_PATTERN","DURATION_PATTERN","filterLiteral","value","nullable","requiredString","name","validateStringComparison","comparison","StringComparison","requireNonEmpty","values","isValidOffsetZone","match","zoneId","offset","hours","minutes","seconds","validateRelativeTimeOptions","TimeUnit","datePattern","validateDatePattern","timeUnit","validateDays","days","constantName","operator","requireDuration","requireLocalTime","time"],"sources":["../../../src/dsl/filter/validate.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// Internal: not re-exported by filter/index.ts. The argument checks the\n// filter builders share.\nimport { constantName } from '../constantName.js';\nimport { validateDatePattern } from './datePattern.js';\nimport { StringComparison, TimeUnit, type FilterOperator } from './operator.js';\nimport type { FilterLiteral, RelativeTimeFilterOptions } from './types.js';\n\nconst LOCAL_TIME_PATTERN =\n /^([01][0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9](?:\\.[0-9]{1,9})?)?$/;\nconst OFFSET_ZONE_PATTERN =\n /^(?:UTC|GMT|UT)?[+-](\\d{1,2}|\\d{4}|\\d{6}|\\d{2}:\\d{2}|\\d{2}:\\d{2}:\\d{2})$/;\nconst OFFSET_ZONE_CANDIDATE_PATTERN = /^(?:UTC|GMT|UT)?[+-]/;\n// java.time.Duration.parse: signed days, hours, minutes and seconds (up to\n// nine fraction digits after `.` or `,`), at least one of them, in that order,\n// case-insensitive. Weeks, months and years are not durations.\nconst DURATION_PATTERN =\n /^[-+]?P(?=.*[0-9])(?:[-+]?[0-9]+D)?(?:T(?=[-+]?[0-9])(?:[-+]?[0-9]+H)?(?:[-+]?[0-9]+M)?(?:[-+]?[0-9]+(?:[.,][0-9]{0,9})?S)?)?$/i;\n\nexport function filterLiteral<T extends FilterLiteral>(\n value: T,\n nullable: boolean,\n): T {\n const valid =\n value === null\n ? nullable\n : typeof value === 'string' ||\n typeof value === 'boolean' ||\n (typeof value === 'number' && Number.isFinite(value));\n if (!valid) {\n throw new TypeError('Filter value must be a JSON scalar.');\n }\n return value;\n}\n\nexport function requiredString(name: string, value: string): string {\n if (typeof value !== 'string') {\n throw new TypeError(`${name} must be a string.`);\n }\n return value;\n}\n\nexport function validateStringComparison(comparison: StringComparison): void {\n if (\n comparison !== StringComparison.CASE_SENSITIVE &&\n comparison !== StringComparison.CASE_INSENSITIVE\n ) {\n throw new TypeError(\n `String comparison is invalid: [${String(comparison)}].`,\n );\n }\n}\n\nexport function requireNonEmpty(\n name: string,\n values: readonly unknown[],\n): void {\n if (values.length === 0) {\n throw new TypeError(`${name} cannot be empty.`);\n }\n if (values.some(value => value === null || value === undefined)) {\n throw new TypeError(`${name} cannot contain null.`);\n }\n}\n\nfunction isValidOffsetZone(zoneId: string): boolean {\n const match = OFFSET_ZONE_PATTERN.exec(zoneId);\n if (!match) return false;\n const offset = match[1];\n const parts = offset.includes(':')\n ? offset.split(':')\n : offset.length <= 2\n ? [offset]\n : [offset.slice(0, 2), offset.slice(2, 4), offset.slice(4, 6)];\n const [hours, minutes = 0, seconds = 0] = parts.map(Number);\n return (\n minutes <= 59 &&\n seconds <= 59 &&\n (hours < 18 || (hours === 18 && minutes === 0 && seconds === 0))\n );\n}\n\nexport function validateRelativeTimeOptions({\n zoneId,\n datePattern,\n timeUnit = TimeUnit.MILLISECONDS,\n}: RelativeTimeFilterOptions): RelativeTimeFilterOptions & {\n timeUnit: TimeUnit;\n} {\n if (zoneId !== undefined) {\n if (typeof zoneId !== 'string' || !zoneId.trim()) {\n throw new TypeError('zoneId cannot be blank.');\n }\n if (\n OFFSET_ZONE_CANDIDATE_PATTERN.test(zoneId) &&\n !isValidOffsetZone(zoneId)\n ) {\n throw new TypeError(`zoneId is invalid: [${zoneId}].`);\n }\n }\n if (datePattern !== undefined) {\n validateDatePattern(datePattern);\n }\n if (!Object.values(TimeUnit).includes(timeUnit)) {\n throw new TypeError(`timeUnit is invalid: [${String(timeUnit)}].`);\n }\n return {\n ...(zoneId === undefined ? {} : { zoneId }),\n ...(datePattern === undefined ? {} : { datePattern }),\n timeUnit,\n };\n}\n\nexport function validateDays(operator: FilterOperator, days: number): void {\n if (!Number.isInteger(days) || days < 1 || days > 2_147_483_647) {\n throw new TypeError(\n `${constantName(operator)} days must be a positive JVM Int.`,\n );\n }\n}\n\n/**\n * Admits the ISO-8601 duration `BEFORE_NOW` and `AFTER_NOW` add to the\n * server's now, in the grammar `java.time.Duration.parse` accepts. A value\n * too large for a `Duration` is left to the server.\n */\nexport function requireDuration(\n operator: FilterOperator,\n offset: string,\n): string {\n if (typeof offset !== 'string' || !DURATION_PATTERN.test(offset)) {\n throw new TypeError(\n `${constantName(operator)} offset must be an ISO-8601 duration such as PT0S or -PT30M.`,\n );\n }\n return offset;\n}\n\n/** Admits the 24-hour local time `BEFORE_TODAY` compares against. */\nexport function requireLocalTime(time: string): string {\n if (typeof time !== 'string' || !LOCAL_TIME_PATTERN.test(time)) {\n throw new TypeError('BEFORE_TODAY time is invalid.');\n }\n return time;\n}\n"],"mappings":";;;;AAoBA,IAAMA,IACJ,oEACIC,IACJ,4EACIC,IAAgC,wBAIhCC,IACJ;AAEF,SAAgBC,EACd,GACA,GACG;CAOH,IAAI,EALFC,MAAU,OACNC,IACA,OAAOD,KAAU,YACjB,OAAOA,KAAU,aAChB,OAAOA,KAAU,YAAY,OAAO,SAASA,CAAK,IAEvD,MAAU,UAAU,qCAAqC;CAE3D,OAAOA;AACT;AAEA,SAAgBE,EAAe,GAAc,GAAuB;CAClE,IAAI,OAAOF,KAAU,UACnB,MAAU,UAAU,GAAGG,EAAK,mBAAmB;CAEjD,OAAOH;AACT;AAEA,SAAgBI,EAAyB,GAAoC;CAC3E,IACEC,MAAeC,EAAiB,kBAChCD,MAAeC,EAAiB,kBAEhC,MAAU,UACR,kCAAkC,OAAOD,CAAU,EAAE,GACvD;AAEJ;AAEA,SAAgBE,EACd,GACA,GACM;CACN,IAAIC,EAAO,WAAW,GACpB,MAAU,UAAU,GAAGL,EAAK,kBAAkB;CAEhD,IAAIK,EAAO,MAAK,MAASR,KAAU,IAA2B,GAC5D,MAAU,UAAU,GAAGG,EAAK,sBAAsB;AAEtD;AAEA,SAASM,EAAkB,GAAyB;CAClD,IAAMC,IAAQd,EAAoB,KAAKe,CAAM;CAC7C,IAAI,CAACD,GAAO,OAAO;CACnB,IAAME,IAASF,EAAM,IAMf,CAACG,GAAOC,IAAU,GAAGC,IAAU,MALvBH,EAAO,SAAS,GAAG,IAC7BA,EAAO,MAAM,GAAG,IAChBA,EAAO,UAAU,IACf,CAACA,CAAM,IACP;EAACA,EAAO,MAAM,GAAG,CAAC;EAAGA,EAAO,MAAM,GAAG,CAAC;EAAGA,EAAO,MAAM,GAAG,CAAC;CAAC,EAAA,CACjB,IAAI,MAAM;CAC1D,OACEE,KAAW,MACXC,KAAW,OACVF,IAAQ,MAAOA,MAAU,MAAMC,MAAY,KAAKC,MAAY;AAEjE;AAEA,SAAgBC,EAA4B,EAC1C,WACA,gBACA,cAAWC,EAAS,gBAGpB;CACA,IAAIN,MAAW,KAAA,GAAW;EACxB,IAAI,OAAOA,KAAW,YAAY,CAACA,EAAO,KAAK,GAC7C,MAAU,UAAU,yBAAyB;EAE/C,IACEd,EAA8B,KAAKc,CAAM,KACzC,CAACF,EAAkBE,CAAM,GAEzB,MAAU,UAAU,uBAAuBA,EAAO,GAAG;CAEzD;CAIA,IAHIO,MAAgB,KAAA,KAClBC,EAAoBD,CAAW,GAE7B,CAAC,OAAO,OAAOD,CAAQ,CAAC,CAAC,SAASG,CAAQ,GAC5C,MAAU,UAAU,yBAAyB,OAAOA,CAAQ,EAAE,GAAG;CAEnE,OAAO;EACL,GAAIT,MAAW,KAAA,IAAY,CAAC,IAAI,EAAE,UAAO;EACzC,GAAIO,MAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,eAAY;EACnD;CACF;AACF;AAEA,SAAgBG,EAAa,GAA0B,GAAoB;CACzE,IAAI,CAAC,OAAO,UAAUC,CAAI,KAAKA,IAAO,KAAKA,IAAO,YAChD,MAAU,UACR,GAAGC,EAAaC,CAAQ,EAAE,kCAC5B;AAEJ;AAOA,SAAgBC,EACd,GACA,GACQ;CACR,IAAI,OAAOb,KAAW,YAAY,CAACd,EAAiB,KAAKc,CAAM,GAC7D,MAAU,UACR,GAAGW,EAAaC,CAAQ,EAAE,6DAC5B;CAEF,OAAOZ;AACT;AAGA,SAAgBc,EAAiB,GAAsB;CACrD,IAAI,OAAOC,KAAS,YAAY,CAAChC,EAAmB,KAAKgC,CAAI,GAC3D,MAAU,UAAU,+BAA+B;CAErD,OAAOA;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.cjs","names":["DEFAULT_PAGINATION","pagination"],"sources":["../../src/dsl/pagination.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 * Interface for pagination information.\n *\n * Page number, starting from 1\n * Page size\n */\nexport interface Pagination {\n index: number;\n size: number;\n}\n\n/**\n * Default pagination configuration.\n * Page index starts at 1, page size is 10. Frozen: the factories copy it.\n */\nexport const DEFAULT_PAGINATION: Readonly<Pagination> = Object.freeze({\n index: 1,\n size: 10,\n});\n\n/**\n * Creates a Pagination object with the provided parameters.\n *\n * This function is a factory for creating Pagination objects, which represent\n * pagination information including page index and page size. It provides default\n * values for optional properties while allowing customization of index and size.\n *\n * @param options - The pagination options. Optional.\n * @param options.index - The page index, starting from 1. Defaults to DEFAULT_PAGINATION.index.\n * @param options.size - The page size. Defaults to DEFAULT_PAGINATION.size.\n * @returns A Pagination object with the specified parameters\n */\nexport function pagination({\n index = DEFAULT_PAGINATION.index,\n size = DEFAULT_PAGINATION.size,\n}: Partial<Pagination> = {}): Pagination {\n return {\n index,\n size,\n };\n}\n"],"mappings":"AA4BA,IAAaA,EAA2C,OAAO,OAAO,CACpE,MAAO,EACP,KAAM,EACR,CAAC,EAcD,SAAgBC,EAAW,CACzB,QAAQD,EAAmB,MAC3B,OAAOA,EAAmB,MACH,CAAC,EAAe,CACvC,MAAO,CACL,QACA,MACF,CACF"}
|
|
1
|
+
{"version":3,"file":"pagination.cjs","names":["DEFAULT_PAGINATION","pagination"],"sources":["../../src/dsl/pagination.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 * Interface for pagination information.\n *\n * Page number, starting from 1\n * Page size\n */\nexport interface Pagination {\n index: number;\n size: number;\n}\n\n/**\n * Default pagination configuration.\n * Page index starts at 1, page size is 10. Frozen: the factories copy it.\n */\nexport const DEFAULT_PAGINATION: Readonly<Pagination> = Object.freeze({\n index: 1,\n size: 10,\n});\n\n/**\n * Creates a Pagination object with the provided parameters.\n *\n * This function is a factory for creating Pagination objects, which represent\n * pagination information including page index and page size. It provides default\n * values for optional properties while allowing customization of index and size.\n *\n * @param options - The pagination options. Optional.\n * @param options.index - The page index, starting from 1. Defaults to DEFAULT_PAGINATION.index.\n * @param options.size - The page size. Defaults to DEFAULT_PAGINATION.size.\n * @returns A Pagination object with the specified parameters\n */\nexport function pagination({\n index = DEFAULT_PAGINATION.index,\n size = DEFAULT_PAGINATION.size,\n}: Partial<Pagination> = {}): Pagination {\n return {\n index,\n size,\n };\n}\n"],"mappings":"AA4BA,IAAaA,EAA2C,OAAO,OAAO,CACpE,MAAO,EACP,KAAM,EACR,CAAC,EAcD,SAAgBC,EAAW,CACzB,QAAQD,EAAmB,MAC3B,OAAOA,EAAmB,MACH,CAAC,EAAe,CACvC,MAAO,CACL,QACA,MACF,CACF,C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dsl/pagination.ts
|
|
2
2
|
var e = Object.freeze({
|
|
3
3
|
index: 1,
|
|
4
4
|
size: 10
|
|
@@ -9,7 +9,6 @@ function t({ index: t = e.index, size: n = e.size } = {}) {
|
|
|
9
9
|
size: n
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
//#endregion
|
|
13
12
|
export { e as DEFAULT_PAGINATION, t as pagination };
|
|
14
13
|
|
|
15
14
|
//# sourceMappingURL=pagination.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.cjs","names":["queryField","require_field","projection","include","exclude"],"sources":["../../src/dsl/projection.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 * Interface for field projection.\n */\nexport interface Projection<FIELDS extends string = string> {\n include?: FIELDS[];\n exclude?: FIELDS[];\n}\n\n/** The first segment of a dotted path. */\ntype Head<P extends string> = P extends `${infer H}.${string}` ? H : P;\n\n/** What follows `K.` in the dotted paths of `P`. */\ntype Tail<P extends string, K extends string> = P extends `${K}.${infer R}`\n ? R\n : never;\n\n/**\n * `T` with only the dotted paths `P` (and the objects that lead to them): an\n * included path keeps its descendants, an array its items' paths, and a\n * nullable or optional value stays so.\n */\nexport type PickPaths<T, P extends string> = T extends readonly (infer E)[]\n ? PickPaths<E, P>[]\n : T extends object\n ? {\n [K in keyof T as K extends Head<P> ? K : never]: K extends P\n ? T[K]\n : PickPaths<T[K], Tail<P, K & string>>;\n }\n : T;\n\n/**\n * The records of type `R` a query whose projection includes the paths\n * `INCLUDE` returns
|
|
1
|
+
{"version":3,"file":"projection.cjs","names":["queryField","require_field","projection","include","exclude"],"sources":["../../src/dsl/projection.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 * Interface for field projection.\n */\nexport interface Projection<FIELDS extends string = string> {\n include?: FIELDS[];\n exclude?: FIELDS[];\n}\n\n/** The first segment of a dotted path. */\ntype Head<P extends string> = P extends `${infer H}.${string}` ? H : P;\n\n/** What follows `K.` in the dotted paths of `P`. */\ntype Tail<P extends string, K extends string> = P extends `${K}.${infer R}`\n ? R\n : never;\n\n/**\n * `T` with only the dotted paths `P` (and the objects that lead to them): an\n * included path keeps its descendants, an array its items' paths, and a\n * nullable or optional value stays so.\n */\nexport type PickPaths<T, P extends string> = T extends readonly (infer E)[]\n ? PickPaths<E, P>[]\n : T extends object\n ? {\n [K in keyof T as K extends Head<P> ? K : never]: K extends P\n ? T[K]\n : PickPaths<T[K], Tail<P, K & string>>;\n }\n : T;\n\n/**\n * The records of type `R` a query whose projection includes the paths\n * `INCLUDE` returns: `R` narrowed to those paths\n * ({@link PickPaths}), or `R` itself when they are not literal. A query\n * client answers so for a query whose `include` it sees as literal paths;\n * any other query (an exclusion alone, or one whose projection is optional,\n * as the DSL builds it) answers whole records.\n */\nexport type Projected<R, INCLUDE extends string> = string extends INCLUDE\n ? R\n : PickPaths<R, INCLUDE>;\n\n/**\n * Creates a Projection object with the provided parameters.\n *\n * This function is a factory for creating Projection objects, which represent\n * field projection specifications for queries. It allows specifying which fields\n * to include or exclude in query results.\n *\n * @param options - The projection options. Defaults to none, which includes\n * every field.\n * @param options.include - Array of field names to include in the projection. Optional.\n * @param options.exclude - Array of field names to exclude from the projection. Optional.\n * @returns A Projection object with the specified parameters\n */\nexport function projection<FIELDS extends string = string>({\n include,\n exclude,\n}: Projection<FIELDS> = {}): Projection<FIELDS> {\n // Kotlin holds these as `QueryField`, which refuses a path its pattern does\n // not match. A projection entry is a path like any other. Both keys stay\n // present whether or not they were given: the shape this factory returns is\n // its own contract, and validating a path is no reason to change it.\n return {\n include: include?.map(queryField),\n exclude: exclude?.map(queryField),\n };\n}\n\n/**\n * Interface for objects that support field projection.\n */\nexport interface ProjectionCapable<FIELDS extends string = string> {\n projection?: Projection<FIELDS>;\n}\n"],"mappings":"A,+BAuEA,SAAgBE,EAA2C,CACzD,UACA,WACsB,CAAC,EAAuB,CAK9C,MAAO,CACL,QAASC,GAAS,IAAIH,EAAAA,UAAU,EAChC,QAASI,GAAS,IAAIJ,EAAAA,UAAU,CAClC,CACF,C"}
|
|
@@ -19,7 +19,7 @@ export type PickPaths<T, P extends string> = T extends readonly (infer E)[] ? Pi
|
|
|
19
19
|
} : T;
|
|
20
20
|
/**
|
|
21
21
|
* The records of type `R` a query whose projection includes the paths
|
|
22
|
-
* `INCLUDE` returns
|
|
22
|
+
* `INCLUDE` returns: `R` narrowed to those paths
|
|
23
23
|
* ({@link PickPaths}), or `R` itself when they are not literal. A query
|
|
24
24
|
* client answers so for a query whose `include` it sees as literal paths;
|
|
25
25
|
* any other query (an exclusion alone, or one whose projection is optional,
|
package/dist/dsl/projection.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type PickPaths<T, P extends string> = T extends readonly (infer E)[] ? Pi
|
|
|
19
19
|
} : T;
|
|
20
20
|
/**
|
|
21
21
|
* The records of type `R` a query whose projection includes the paths
|
|
22
|
-
* `INCLUDE` returns
|
|
22
|
+
* `INCLUDE` returns: `R` narrowed to those paths
|
|
23
23
|
* ({@link PickPaths}), or `R` itself when they are not literal. A query
|
|
24
24
|
* client answers so for a query whose `include` it sees as literal paths;
|
|
25
25
|
* any other query (an exclusion alone, or one whose projection is optional,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { queryField as e } from "./field.es.js";
|
|
2
|
-
|
|
2
|
+
// src/dsl/projection.ts
|
|
3
3
|
function t({ include: t, exclude: n } = {}) {
|
|
4
4
|
return {
|
|
5
5
|
include: t?.map(e),
|
|
6
6
|
exclude: n?.map(e)
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { t as projection };
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=projection.es.js.map
|