@ahoo-wang/wow-client 10.0.0-beta.1 → 10.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +4 -2
  2. package/README.zh-CN.md +1 -1
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +1 -8
  6. package/dist/commands.d.ts +1 -8
  7. package/dist/commands.es.js +45 -51
  8. package/dist/commands.es.js.map +1 -1
  9. package/dist/dsl/aggregation/admit.cjs +1 -1
  10. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  11. package/dist/dsl/aggregation/admit.es.js +73 -69
  12. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  13. package/dist/dsl/aggregation/aliases.cjs +2 -0
  14. package/dist/dsl/aggregation/aliases.cjs.map +1 -0
  15. package/dist/dsl/aggregation/aliases.d.cts +2 -0
  16. package/dist/dsl/aggregation/aliases.d.ts +2 -0
  17. package/dist/dsl/aggregation/aliases.es.js +13 -0
  18. package/dist/dsl/aggregation/aliases.es.js.map +1 -0
  19. package/dist/dsl/aggregation/builders.cjs +1 -1
  20. package/dist/dsl/aggregation/builders.cjs.map +1 -1
  21. package/dist/dsl/aggregation/builders.d.cts +17 -243
  22. package/dist/dsl/aggregation/builders.d.ts +17 -243
  23. package/dist/dsl/aggregation/builders.es.js +36 -171
  24. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  25. package/dist/dsl/aggregation/derived.cjs +1 -1
  26. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  27. package/dist/dsl/aggregation/derived.d.cts +123 -1
  28. package/dist/dsl/aggregation/derived.d.ts +123 -1
  29. package/dist/dsl/aggregation/derived.es.js +43 -28
  30. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  31. package/dist/dsl/aggregation/groups.cjs +2 -0
  32. package/dist/dsl/aggregation/groups.cjs.map +1 -0
  33. package/dist/dsl/aggregation/groups.d.cts +325 -0
  34. package/dist/dsl/aggregation/groups.d.ts +325 -0
  35. package/dist/dsl/aggregation/groups.es.js +80 -0
  36. package/dist/dsl/aggregation/groups.es.js.map +1 -0
  37. package/dist/dsl/aggregation/having.cjs +1 -1
  38. package/dist/dsl/aggregation/having.cjs.map +1 -1
  39. package/dist/dsl/aggregation/having.d.cts +63 -1
  40. package/dist/dsl/aggregation/having.d.ts +63 -1
  41. package/dist/dsl/aggregation/having.es.js +33 -30
  42. package/dist/dsl/aggregation/having.es.js.map +1 -1
  43. package/dist/dsl/aggregation/index.d.cts +4 -2
  44. package/dist/dsl/aggregation/index.d.ts +4 -2
  45. package/dist/dsl/aggregation/metrics.cjs +2 -0
  46. package/dist/dsl/aggregation/metrics.cjs.map +1 -0
  47. package/dist/dsl/aggregation/metrics.d.cts +279 -0
  48. package/dist/dsl/aggregation/metrics.d.ts +279 -0
  49. package/dist/dsl/aggregation/metrics.es.js +75 -0
  50. package/dist/dsl/aggregation/metrics.es.js.map +1 -0
  51. package/dist/dsl/aggregation/types.cjs +1 -1
  52. package/dist/dsl/aggregation/types.cjs.map +1 -1
  53. package/dist/dsl/aggregation/types.d.cts +4 -524
  54. package/dist/dsl/aggregation/types.d.ts +4 -524
  55. package/dist/dsl/aggregation/types.es.js +5 -25
  56. package/dist/dsl/aggregation/types.es.js.map +1 -1
  57. package/dist/dsl/cursorQuery.cjs +1 -1
  58. package/dist/dsl/cursorQuery.cjs.map +1 -1
  59. package/dist/dsl/cursorQuery.d.cts +18 -7
  60. package/dist/dsl/cursorQuery.d.ts +18 -7
  61. package/dist/dsl/cursorQuery.es.js +13 -12
  62. package/dist/dsl/cursorQuery.es.js.map +1 -1
  63. package/dist/dsl/descriptor.cjs +1 -1
  64. package/dist/dsl/descriptor.cjs.map +1 -1
  65. package/dist/dsl/descriptor.d.cts +17 -379
  66. package/dist/dsl/descriptor.d.ts +17 -379
  67. package/dist/dsl/descriptor.es.js +4 -31
  68. package/dist/dsl/descriptor.es.js.map +1 -1
  69. package/dist/dsl/fieldDescriptor.cjs +2 -0
  70. package/dist/dsl/fieldDescriptor.cjs.map +1 -0
  71. package/dist/dsl/fieldDescriptor.d.cts +246 -0
  72. package/dist/dsl/fieldDescriptor.d.ts +246 -0
  73. package/dist/dsl/fieldDescriptor.es.js +24 -0
  74. package/dist/dsl/fieldDescriptor.es.js.map +1 -0
  75. package/dist/dsl/filter/builders.cjs +1 -1
  76. package/dist/dsl/filter/builders.cjs.map +1 -1
  77. package/dist/dsl/filter/builders.d.cts +7 -949
  78. package/dist/dsl/filter/builders.d.ts +7 -949
  79. package/dist/dsl/filter/builders.es.js +14 -285
  80. package/dist/dsl/filter/builders.es.js.map +1 -1
  81. package/dist/dsl/filter/expressionFilter.cjs +2 -0
  82. package/dist/dsl/filter/expressionFilter.cjs.map +1 -0
  83. package/dist/dsl/filter/expressionFilter.d.cts +35 -0
  84. package/dist/dsl/filter/expressionFilter.d.ts +35 -0
  85. package/dist/dsl/filter/expressionFilter.es.js +18 -0
  86. package/dist/dsl/filter/expressionFilter.es.js.map +1 -0
  87. package/dist/dsl/filter/fieldFilters.cjs +2 -0
  88. package/dist/dsl/filter/fieldFilters.cjs.map +1 -0
  89. package/dist/dsl/filter/fieldFilters.d.cts +297 -0
  90. package/dist/dsl/filter/fieldFilters.d.ts +297 -0
  91. package/dist/dsl/filter/fieldFilters.es.js +110 -0
  92. package/dist/dsl/filter/fieldFilters.es.js.map +1 -0
  93. package/dist/dsl/filter/index.d.cts +2 -1
  94. package/dist/dsl/filter/index.d.ts +2 -1
  95. package/dist/dsl/filter/logicalFilters.cjs +2 -0
  96. package/dist/dsl/filter/logicalFilters.cjs.map +1 -0
  97. package/dist/dsl/filter/logicalFilters.d.cts +109 -0
  98. package/dist/dsl/filter/logicalFilters.d.ts +109 -0
  99. package/dist/dsl/filter/logicalFilters.es.js +36 -0
  100. package/dist/dsl/filter/logicalFilters.es.js.map +1 -0
  101. package/dist/dsl/filter/metadataFilters.cjs +2 -0
  102. package/dist/dsl/filter/metadataFilters.cjs.map +1 -0
  103. package/dist/dsl/filter/metadataFilters.d.cts +132 -0
  104. package/dist/dsl/filter/metadataFilters.d.ts +132 -0
  105. package/dist/dsl/filter/metadataFilters.es.js +56 -0
  106. package/dist/dsl/filter/metadataFilters.es.js.map +1 -0
  107. package/dist/dsl/filter/operator.cjs +1 -1
  108. package/dist/dsl/filter/operator.cjs.map +1 -1
  109. package/dist/dsl/filter/operator.d.cts +11 -9
  110. package/dist/dsl/filter/operator.d.ts +11 -9
  111. package/dist/dsl/filter/operator.es.js +1 -1
  112. package/dist/dsl/filter/operator.es.js.map +1 -1
  113. package/dist/dsl/filter/searchFilter.cjs +2 -0
  114. package/dist/dsl/filter/searchFilter.cjs.map +1 -0
  115. package/dist/dsl/filter/searchFilter.d.cts +39 -0
  116. package/dist/dsl/filter/searchFilter.d.ts +39 -0
  117. package/dist/dsl/filter/searchFilter.es.js +19 -0
  118. package/dist/dsl/filter/searchFilter.es.js.map +1 -0
  119. package/dist/dsl/filter/timeFilters.cjs +2 -0
  120. package/dist/dsl/filter/timeFilters.cjs.map +1 -0
  121. package/dist/dsl/filter/timeFilters.d.cts +290 -0
  122. package/dist/dsl/filter/timeFilters.d.ts +290 -0
  123. package/dist/dsl/filter/timeFilters.es.js +89 -0
  124. package/dist/dsl/filter/timeFilters.es.js.map +1 -0
  125. package/dist/dsl/filter/types.d.cts +4 -14
  126. package/dist/dsl/filter/types.d.ts +4 -14
  127. package/dist/dsl/filter/validate.cjs +1 -1
  128. package/dist/dsl/filter/validate.cjs.map +1 -1
  129. package/dist/dsl/filter/validate.d.cts +2 -4
  130. package/dist/dsl/filter/validate.d.ts +2 -4
  131. package/dist/dsl/filter/validate.es.js +25 -31
  132. package/dist/dsl/filter/validate.es.js.map +1 -1
  133. package/dist/dsl/queryErrorCodes.cjs +1 -1
  134. package/dist/dsl/queryErrorCodes.cjs.map +1 -1
  135. package/dist/dsl/queryErrorCodes.d.cts +0 -2
  136. package/dist/dsl/queryErrorCodes.d.ts +0 -2
  137. package/dist/dsl/queryErrorCodes.es.js +0 -1
  138. package/dist/dsl/queryErrorCodes.es.js.map +1 -1
  139. package/dist/dsl/queryFilter.cjs +2 -0
  140. package/dist/dsl/queryFilter.cjs.map +1 -0
  141. package/dist/dsl/queryFilter.d.cts +3 -0
  142. package/dist/dsl/queryFilter.d.ts +3 -0
  143. package/dist/dsl/queryFilter.es.js +9 -0
  144. package/dist/dsl/queryFilter.es.js.map +1 -0
  145. package/dist/dsl/queryable.cjs +1 -1
  146. package/dist/dsl/queryable.cjs.map +1 -1
  147. package/dist/dsl/queryable.es.js +12 -16
  148. package/dist/dsl/queryable.es.js.map +1 -1
  149. package/dist/dsl/semanticTypes.cjs +2 -0
  150. package/dist/dsl/semanticTypes.cjs.map +1 -0
  151. package/dist/dsl/semanticTypes.d.cts +128 -0
  152. package/dist/dsl/semanticTypes.d.ts +128 -0
  153. package/dist/dsl/semanticTypes.es.js +13 -0
  154. package/dist/dsl/semanticTypes.es.js.map +1 -0
  155. package/dist/dsl.cjs +1 -1
  156. package/dist/dsl.d.cts +2 -0
  157. package/dist/dsl.d.ts +2 -0
  158. package/dist/dsl.es.js +14 -8
  159. package/dist/exactJson.cjs +2 -2
  160. package/dist/exactJson.cjs.map +1 -1
  161. package/dist/exactJson.d.cts +41 -16
  162. package/dist/exactJson.d.ts +41 -16
  163. package/dist/exactJson.es.js +104 -102
  164. package/dist/exactJson.es.js.map +1 -1
  165. package/dist/frameworkErrors.cjs.map +1 -1
  166. package/dist/frameworkErrors.d.cts +4 -4
  167. package/dist/frameworkErrors.d.ts +4 -4
  168. package/dist/frameworkErrors.es.js.map +1 -1
  169. package/dist/http.cjs +1 -1
  170. package/dist/http.cjs.map +1 -1
  171. package/dist/http.d.cts +29 -9
  172. package/dist/http.d.ts +29 -9
  173. package/dist/http.es.js +24 -19
  174. package/dist/http.es.js.map +1 -1
  175. package/dist/index.cjs +1 -1
  176. package/dist/index.d.cts +3 -3
  177. package/dist/index.d.ts +3 -3
  178. package/dist/index.es.js +12 -12
  179. package/dist/manifest.cjs +1 -1
  180. package/dist/manifest.cjs.map +1 -1
  181. package/dist/manifest.d.cts +24 -0
  182. package/dist/manifest.d.ts +24 -0
  183. package/dist/manifest.es.js +34 -6
  184. package/dist/manifest.es.js.map +1 -1
  185. package/dist/manifestTypes.d.cts +16 -1
  186. package/dist/manifestTypes.d.ts +16 -1
  187. package/dist/queries.cjs +1 -1
  188. package/dist/queries.cjs.map +1 -1
  189. package/dist/queries.d.cts +18 -8
  190. package/dist/queries.d.ts +18 -8
  191. package/dist/queries.es.js +46 -35
  192. package/dist/queries.es.js.map +1 -1
  193. package/dist/routes.cjs +1 -1
  194. package/dist/routes.cjs.map +1 -1
  195. package/dist/routes.d.cts +16 -3
  196. package/dist/routes.d.ts +16 -3
  197. package/dist/routes.es.js +24 -25
  198. package/dist/routes.es.js.map +1 -1
  199. package/dist/state.cjs +1 -1
  200. package/dist/state.cjs.map +1 -1
  201. package/dist/state.d.cts +21 -19
  202. package/dist/state.d.ts +21 -19
  203. package/dist/state.es.js +27 -22
  204. package/dist/state.es.js.map +1 -1
  205. package/dist/streams.cjs +1 -1
  206. package/dist/streams.cjs.map +1 -1
  207. package/dist/streams.d.cts +14 -7
  208. package/dist/streams.d.ts +14 -7
  209. package/dist/streams.es.js +65 -50
  210. package/dist/streams.es.js.map +1 -1
  211. package/dist/testing/wire.cjs +1 -1
  212. package/dist/testing/wire.cjs.map +1 -1
  213. package/dist/testing/wire.es.js +1 -1
  214. package/dist/testing/wire.es.js.map +1 -1
  215. package/dist/wait.cjs +1 -1
  216. package/dist/wait.cjs.map +1 -1
  217. package/dist/wait.d.cts +17 -4
  218. package/dist/wait.d.ts +17 -4
  219. package/dist/wait.es.js +36 -34
  220. package/dist/wait.es.js.map +1 -1
  221. package/dist/wire.cjs +1 -1
  222. package/dist/wire.cjs.map +1 -1
  223. package/dist/wire.d.cts +75 -31
  224. package/dist/wire.d.ts +75 -31
  225. package/dist/wire.es.js +1 -3
  226. package/dist/wire.es.js.map +1 -1
  227. package/package.json +5 -5
  228. package/dist/dsl/filter/datePattern.cjs +0 -2
  229. package/dist/dsl/filter/datePattern.cjs.map +0 -1
  230. package/dist/dsl/filter/datePattern.d.cts +0 -8
  231. package/dist/dsl/filter/datePattern.d.ts +0 -8
  232. package/dist/dsl/filter/datePattern.es.js +0 -96
  233. package/dist/dsl/filter/datePattern.es.js.map +0 -1
@@ -0,0 +1,110 @@
1
+ import { FilterOperator as e, StringComparison as t } from "./operator.es.js";
2
+ import { constantName as n } from "../constantName.es.js";
3
+ import { queryField as r } from "../field.es.js";
4
+ import { filterLiteral as i, requireNonEmpty as a, requiredString as o, validateStringComparison as s } from "./validate.es.js";
5
+ // src/dsl/filter/fieldFilters.ts
6
+ function c(e, t, n) {
7
+ return {
8
+ op: e,
9
+ field: r(t),
10
+ value: i(n, !0)
11
+ };
12
+ }
13
+ function l(e, t, n) {
14
+ return {
15
+ op: e,
16
+ field: r(t),
17
+ value: i(n, !1)
18
+ };
19
+ }
20
+ function u(e, t, i, a) {
21
+ return s(a), {
22
+ op: e,
23
+ field: r(t),
24
+ value: o(`${n(e)} value`, i),
25
+ stringComparison: a
26
+ };
27
+ }
28
+ function d(e, t, o) {
29
+ return a(`${n(e)} values`, o), o.forEach((e) => i(e, !1)), {
30
+ op: e,
31
+ field: r(t),
32
+ values: [...o]
33
+ };
34
+ }
35
+ function f(e, t) {
36
+ return {
37
+ op: e,
38
+ field: r(t)
39
+ };
40
+ }
41
+ var p = {
42
+ eq(t, n) {
43
+ return c(e.EQ, t, n);
44
+ },
45
+ ne(t, n) {
46
+ return c(e.NE, t, n);
47
+ },
48
+ gt(t, n) {
49
+ return l(e.GT, t, n);
50
+ },
51
+ gte(t, n) {
52
+ return l(e.GTE, t, n);
53
+ },
54
+ lt(t, n) {
55
+ return l(e.LT, t, n);
56
+ },
57
+ lte(t, n) {
58
+ return l(e.LTE, t, n);
59
+ },
60
+ contains(n, r, i = t.CASE_SENSITIVE) {
61
+ return u(e.CONTAINS, n, r, i);
62
+ },
63
+ startsWith(n, r, i = t.CASE_SENSITIVE) {
64
+ return u(e.STARTS_WITH, n, r, i);
65
+ },
66
+ endsWith(n, r, i = t.CASE_SENSITIVE) {
67
+ return u(e.ENDS_WITH, n, r, i);
68
+ },
69
+ isIn(t, n) {
70
+ return d(e.IN, t, n);
71
+ },
72
+ notIn(t, n) {
73
+ return d(e.NOT_IN, t, n);
74
+ },
75
+ containsAll(t, n) {
76
+ return d(e.CONTAINS_ALL, t, n);
77
+ },
78
+ between(t, n, a) {
79
+ return {
80
+ op: e.BETWEEN,
81
+ field: r(t),
82
+ lowerBound: i(n, !1),
83
+ upperBound: i(a, !1)
84
+ };
85
+ },
86
+ isEmpty(t) {
87
+ return f(e.IS_EMPTY, t);
88
+ },
89
+ isEmptyString(t) {
90
+ return f(e.IS_EMPTY_STRING, t);
91
+ },
92
+ isNotEmptyString(t) {
93
+ return f(e.IS_NOT_EMPTY_STRING, t);
94
+ },
95
+ isNull(t) {
96
+ return f(e.IS_NULL, t);
97
+ },
98
+ isNotNull(t) {
99
+ return f(e.IS_NOT_NULL, t);
100
+ },
101
+ exists(t) {
102
+ return f(e.EXISTS, t);
103
+ },
104
+ notExists(t) {
105
+ return f(e.NOT_EXISTS, t);
106
+ }
107
+ };
108
+ export { p as fieldFilters };
109
+
110
+ //# sourceMappingURL=fieldFilters.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldFilters.es.js","names":["equality","queryField","field","filterLiteral","value","comparison","stringMatch","validateStringComparison","stringComparison","requiredString","constantName","op","collection","requireNonEmpty","values","presence","fieldFilters","FilterOperator","StringComparison","lowerBound","upperBound"],"sources":["../../../src/dsl/filter/fieldFilters.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 { constantName } from '../constantName.js';\nimport { queryField } from '../field.js';\nimport { FilterOperator, StringComparison } from './operator.js';\nimport type {\n BetweenFilter,\n CollectionFilter,\n ComparableFilterLiteral,\n ComparisonFilter,\n EqualityFilter,\n EqualityFilterValue,\n FieldPresenceFilter,\n StringFilter,\n} from './types.js';\nimport {\n filterLiteral,\n requireNonEmpty,\n requiredString,\n validateStringComparison,\n} from './validate.js';\n\n// One builder per filter shape, keyed by the operator. Each shape's public\n// builders below differ only in the operator they pass, so a new operator of\n// an existing shape is one enum member, one type-union member and one line\n// here; its JSDoc goes on the public builder, where the IDE shows it.\n\nfunction equality<FIELDS extends string>(\n op: EqualityFilter['op'],\n field: FIELDS,\n value: EqualityFilterValue,\n): EqualityFilter<FIELDS> {\n return { op, field: queryField(field), value: filterLiteral(value, true) };\n}\n\nfunction comparison<FIELDS extends string>(\n op: ComparisonFilter['op'],\n field: FIELDS,\n value: ComparableFilterLiteral,\n): ComparisonFilter<FIELDS> {\n return { op, field: queryField(field), value: filterLiteral(value, false) };\n}\n\nfunction stringMatch<FIELDS extends string>(\n op: StringFilter['op'],\n field: FIELDS,\n value: string,\n stringComparison: StringComparison,\n): StringFilter<FIELDS> {\n validateStringComparison(stringComparison);\n return {\n op,\n field: queryField(field),\n value: requiredString(`${constantName(op)} value`, value),\n stringComparison,\n };\n}\n\nfunction collection<FIELDS extends string>(\n op: CollectionFilter['op'],\n field: FIELDS,\n values: readonly ComparableFilterLiteral[],\n): CollectionFilter<FIELDS> {\n requireNonEmpty(`${constantName(op)} values`, values);\n values.forEach(value => filterLiteral(value, false));\n return { op, field: queryField(field), values: [...values] };\n}\n\nfunction presence<FIELDS extends string>(\n op: FieldPresenceFilter['op'],\n field: FIELDS,\n): FieldPresenceFilter<FIELDS> {\n return { op, field: queryField(field) };\n}\n\n/** The filters on a field's value: equality, order, text, collections, ranges and presence. */\nexport const fieldFilters = {\n /**\n * Matches records whose `field` equals `value`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - JSON scalar. `null` is sent as is; the server rewrites it\n * to `IS_NULL`.\n * @returns `{ op: 'eq', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not\n * `null`, a string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.eq('state.status', 'PAID');\n * ```\n */\n eq<FIELDS extends string>(\n field: FIELDS,\n value: EqualityFilterValue,\n ): EqualityFilter<FIELDS> {\n return equality(FilterOperator.EQ, field, value);\n },\n /**\n * Matches records whose `field` does not equal `value`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - JSON scalar. `null` is sent as is; the server rewrites it\n * to `IS_NOT_NULL`.\n * @returns `{ op: 'ne', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not\n * `null`, a string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.ne('state.status', 'CANCELLED');\n * ```\n */\n ne<FIELDS extends string>(\n field: FIELDS,\n value: EqualityFilterValue,\n ): EqualityFilter<FIELDS> {\n return equality(FilterOperator.NE, field, value);\n },\n /**\n * Matches records whose `field` is greater than `value` (`field > value`).\n * Numbers compare at the backend's stored precision.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Non-null JSON scalar.\n * @returns `{ op: 'gt', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not a\n * string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.gt('state.total', 100);\n * ```\n */\n gt<FIELDS extends string>(\n field: FIELDS,\n value: ComparableFilterLiteral,\n ): ComparisonFilter<FIELDS> {\n return comparison(FilterOperator.GT, field, value);\n },\n /**\n * Matches records whose `field` is greater than or equal to `value` (`field >= value`).\n * Numbers compare at the backend's stored precision.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Non-null JSON scalar.\n * @returns `{ op: 'gte', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not a\n * string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.gte('state.total', 100);\n * ```\n */\n gte<FIELDS extends string>(\n field: FIELDS,\n value: ComparableFilterLiteral,\n ): ComparisonFilter<FIELDS> {\n return comparison(FilterOperator.GTE, field, value);\n },\n /**\n * Matches records whose `field` is less than `value` (`field < value`).\n * Numbers compare at the backend's stored precision.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Non-null JSON scalar.\n * @returns `{ op: 'lt', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not a\n * string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.lt('state.total', 100);\n * ```\n */\n lt<FIELDS extends string>(\n field: FIELDS,\n value: ComparableFilterLiteral,\n ): ComparisonFilter<FIELDS> {\n return comparison(FilterOperator.LT, field, value);\n },\n /**\n * Matches records whose `field` is less than or equal to `value` (`field <= value`).\n * Numbers compare at the backend's stored precision.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Non-null JSON scalar.\n * @returns `{ op: 'lte', field, value }`.\n * @throws TypeError If `field` is not a valid query field path, or `value` is not a\n * string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.lte('state.total', 100);\n * ```\n */\n lte<FIELDS extends string>(\n field: FIELDS,\n value: ComparableFilterLiteral,\n ): ComparisonFilter<FIELDS> {\n return comparison(FilterOperator.LTE, field, value);\n },\n /**\n * Matches records whose string `field` contains `value` literally. No\n * full-text analyzer is applied.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Literal text.\n * @param stringComparison - Case handling. Defaults to\n * `StringComparison.CASE_SENSITIVE`.\n * @returns `{ op: 'contains', field, value, stringComparison }`.\n * @throws TypeError If `stringComparison` is not a {@link StringComparison}\n * member, `field` is not a valid query field path, or `value` is not a string.\n * @example\n * ```typescript\n * filter.contains('state.note', 'vip', StringComparison.CASE_INSENSITIVE);\n * ```\n */\n contains<FIELDS extends string>(\n field: FIELDS,\n value: string,\n stringComparison = StringComparison.CASE_SENSITIVE,\n ): StringFilter<FIELDS> {\n return stringMatch(FilterOperator.CONTAINS, field, value, stringComparison);\n },\n /**\n * Matches records whose string `field` starts with `value` literally. No\n * full-text analyzer is applied.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Literal text.\n * @param stringComparison - Case handling. Defaults to\n * `StringComparison.CASE_SENSITIVE`.\n * @returns `{ op: 'starts-with', field, value, stringComparison }`.\n * @throws TypeError If `stringComparison` is not a {@link StringComparison}\n * member, `field` is not a valid query field path, or `value` is not a string.\n * @example\n * ```typescript\n * filter.startsWith('state.note', 'VIP-', StringComparison.CASE_INSENSITIVE);\n * ```\n */\n startsWith<FIELDS extends string>(\n field: FIELDS,\n value: string,\n stringComparison = StringComparison.CASE_SENSITIVE,\n ): StringFilter<FIELDS> {\n return stringMatch(\n FilterOperator.STARTS_WITH,\n field,\n value,\n stringComparison,\n );\n },\n /**\n * Matches records whose string `field` ends with `value` literally. No\n * full-text analyzer is applied.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param value - Literal text.\n * @param stringComparison - Case handling. Defaults to\n * `StringComparison.CASE_SENSITIVE`.\n * @returns `{ op: 'ends-with', field, value, stringComparison }`.\n * @throws TypeError If `stringComparison` is not a {@link StringComparison}\n * member, `field` is not a valid query field path, or `value` is not a string.\n * @example\n * ```typescript\n * filter.endsWith('state.note', '.pdf', StringComparison.CASE_INSENSITIVE);\n * ```\n */\n endsWith<FIELDS extends string>(\n field: FIELDS,\n value: string,\n stringComparison = StringComparison.CASE_SENSITIVE,\n ): StringFilter<FIELDS> {\n return stringMatch(\n FilterOperator.ENDS_WITH,\n field,\n value,\n stringComparison,\n );\n },\n /**\n * Matches records whose `field` equals one of `values`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param values - Non-empty list of non-null JSON scalars.\n * @returns `{ op: 'in', field, values }` with a copy of `values`.\n * @throws TypeError If `values` is empty, contains `null` or `undefined`,\n * or contains a value that is not a string, a boolean or a finite\n * number, or if `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isIn('state.status', ['PAID', 'SHIPPED']);\n * ```\n */\n isIn<FIELDS extends string>(\n field: FIELDS,\n values: readonly ComparableFilterLiteral[],\n ): CollectionFilter<FIELDS> {\n return collection(FilterOperator.IN, field, values);\n },\n /**\n * Matches records whose `field` equals none of `values`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param values - Non-empty list of non-null JSON scalars.\n * @returns `{ op: 'not-in', field, values }` with a copy of `values`.\n * @throws TypeError If `values` is empty, contains `null` or `undefined`,\n * or contains a value that is not a string, a boolean or a finite\n * number, or if `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.notIn('state.status', ['CANCELLED', 'REFUNDED']);\n * ```\n */\n notIn<FIELDS extends string>(\n field: FIELDS,\n values: readonly ComparableFilterLiteral[],\n ): CollectionFilter<FIELDS> {\n return collection(FilterOperator.NOT_IN, field, values);\n },\n /**\n * Matches records whose array `field` contains every value in `values`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param values - Non-empty list of non-null JSON scalars.\n * @returns `{ op: 'contains-all', field, values }` with a copy of `values`.\n * @throws TypeError If `values` is empty, contains `null` or `undefined`,\n * or contains a value that is not a string, a boolean or a finite\n * number, or if `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.containsAll('access.teams', ['sales', 'support']);\n * ```\n */\n containsAll<FIELDS extends string>(\n field: FIELDS,\n values: readonly ComparableFilterLiteral[],\n ): CollectionFilter<FIELDS> {\n return collection(FilterOperator.CONTAINS_ALL, field, values);\n },\n /**\n * Matches records whose `field` lies in the inclusive range\n * `lowerBound <= field <= upperBound`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @param lowerBound - Inclusive lower bound; non-null JSON scalar.\n * @param upperBound - Inclusive upper bound; non-null JSON scalar.\n * @returns `{ op: 'between', field, lowerBound, upperBound }`.\n * @throws TypeError If `field` is not a valid query field path, or either bound is not a\n * string, a boolean or a finite number.\n * @example\n * ```typescript\n * filter.between('state.total', 100, 200);\n * ```\n */\n between<FIELDS extends string>(\n field: FIELDS,\n lowerBound: ComparableFilterLiteral,\n upperBound: ComparableFilterLiteral,\n ): BetweenFilter<FIELDS> {\n return {\n op: FilterOperator.BETWEEN,\n field: queryField(field),\n lowerBound: filterLiteral(lowerBound, false),\n upperBound: filterLiteral(upperBound, false),\n };\n },\n /**\n * Matches records whose array `field` is empty. On Elasticsearch it may also\n * match a missing or `null` field.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'is-empty', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isEmpty('state.items');\n * ```\n */\n isEmpty<FIELDS extends string>(field: FIELDS): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.IS_EMPTY, field);\n },\n /**\n * Matches records whose string `field` equals `\"\"`. Whitespace-only\n * strings do not match.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'is-empty-string', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isEmptyString('state.note');\n * ```\n */\n isEmptyString<FIELDS extends string>(\n field: FIELDS,\n ): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.IS_EMPTY_STRING, field);\n },\n /**\n * Matches records whose string `field` exists, is not `null` and is not\n * `\"\"`.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'is-not-empty-string', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isNotEmptyString('state.note');\n * ```\n */\n isNotEmptyString<FIELDS extends string>(\n field: FIELDS,\n ): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.IS_NOT_EMPTY_STRING, field);\n },\n /**\n * Matches records whose `field` is `null` or missing, following the\n * backend's null semantics.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'is-null', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isNull('state.note');\n * ```\n */\n isNull<FIELDS extends string>(field: FIELDS): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.IS_NULL, field);\n },\n /**\n * Matches records whose `field` exists and is not `null`, following the\n * backend's null semantics.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'is-not-null', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.isNotNull('state.note');\n * ```\n */\n isNotNull<FIELDS extends string>(field: FIELDS): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.IS_NOT_NULL, field);\n },\n /**\n * Matches records where `field` exists. On MongoDB this includes a `null`\n * value.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'exists', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.exists('state.note');\n * ```\n */\n exists<FIELDS extends string>(field: FIELDS): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.EXISTS, field);\n },\n /**\n * Matches records where `field` is missing.\n *\n * @param field - Query field path, e.g. `state.status`.\n * @returns `{ op: 'not-exists', field }`.\n * @throws TypeError If `field` is not a valid query field path.\n * @example\n * ```typescript\n * filter.notExists('state.note');\n * ```\n */\n notExists<FIELDS extends string>(field: FIELDS): FieldPresenceFilter<FIELDS> {\n return presence(FilterOperator.NOT_EXISTS, field);\n },\n};\n"],"mappings":";;;;;AAsCA,SAASA,EACP,GACA,GACA,GACwB;CACxB,OAAO;EAAE;EAAI,OAAOC,EAAWC,CAAK;EAAG,OAAOC,EAAcC,GAAO,EAAI;CAAE;AAC3E;AAEA,SAASC,EACP,GACA,GACA,GAC0B;CAC1B,OAAO;EAAE;EAAI,OAAOJ,EAAWC,CAAK;EAAG,OAAOC,EAAcC,GAAO,EAAK;CAAE;AAC5E;AAEA,SAASE,EACP,GACA,GACA,GACA,GACsB;CAEtB,OADAC,EAAyBC,CAAgB,GAClC;EACL;EACA,OAAOP,EAAWC,CAAK;EACvB,OAAOO,EAAe,GAAGC,EAAaC,CAAE,EAAE,SAASP,CAAK;EACxD;CACF;AACF;AAEA,SAASQ,EACP,GACA,GACA,GAC0B;CAG1B,OAFAC,EAAgB,GAAGH,EAAaC,CAAE,EAAE,UAAUG,CAAM,GACpDA,EAAO,SAAQ,MAASX,EAAcC,GAAO,EAAK,CAAC,GAC5C;EAAE;EAAI,OAAOH,EAAWC,CAAK;EAAG,QAAQ,CAAC,GAAGY,CAAM;CAAE;AAC7D;AAEA,SAASC,EACP,GACA,GAC6B;CAC7B,OAAO;EAAE;EAAI,OAAOd,EAAWC,CAAK;CAAE;AACxC;AAGA,IAAac,IAAe;CAe1B,GACE,GACA,GACwB;EACxB,OAAOhB,EAASiB,EAAe,IAAIf,GAAOE,CAAK;CACjD;CAeA,GACE,GACA,GACwB;EACxB,OAAOJ,EAASiB,EAAe,IAAIf,GAAOE,CAAK;CACjD;CAeA,GACE,GACA,GAC0B;EAC1B,OAAOC,EAAWY,EAAe,IAAIf,GAAOE,CAAK;CACnD;CAeA,IACE,GACA,GAC0B;EAC1B,OAAOC,EAAWY,EAAe,KAAKf,GAAOE,CAAK;CACpD;CAeA,GACE,GACA,GAC0B;EAC1B,OAAOC,EAAWY,EAAe,IAAIf,GAAOE,CAAK;CACnD;CAeA,IACE,GACA,GAC0B;EAC1B,OAAOC,EAAWY,EAAe,KAAKf,GAAOE,CAAK;CACpD;CAiBA,SACE,GACA,GACA,IAAmBc,EAAiB,gBACd;EACtB,OAAOZ,EAAYW,EAAe,UAAUf,GAAOE,GAAOI,CAAgB;CAC5E;CAiBA,WACE,GACA,GACA,IAAmBU,EAAiB,gBACd;EACtB,OAAOZ,EACLW,EAAe,aACff,GACAE,GACAI,CACF;CACF;CAiBA,SACE,GACA,GACA,IAAmBU,EAAiB,gBACd;EACtB,OAAOZ,EACLW,EAAe,WACff,GACAE,GACAI,CACF;CACF;CAeA,KACE,GACA,GAC0B;EAC1B,OAAOI,EAAWK,EAAe,IAAIf,GAAOY,CAAM;CACpD;CAeA,MACE,GACA,GAC0B;EAC1B,OAAOF,EAAWK,EAAe,QAAQf,GAAOY,CAAM;CACxD;CAeA,YACE,GACA,GAC0B;EAC1B,OAAOF,EAAWK,EAAe,cAAcf,GAAOY,CAAM;CAC9D;CAgBA,QACE,GACA,GACA,GACuB;EACvB,OAAO;GACL,IAAIG,EAAe;GACnB,OAAOhB,EAAWC,CAAK;GACvB,YAAYC,EAAcgB,GAAY,EAAK;GAC3C,YAAYhB,EAAciB,GAAY,EAAK;EAC7C;CACF;CAaA,QAA+B,GAA4C;EACzE,OAAOL,EAASE,EAAe,UAAUf,CAAK;CAChD;CAaA,cACE,GAC6B;EAC7B,OAAOa,EAASE,EAAe,iBAAiBf,CAAK;CACvD;CAaA,iBACE,GAC6B;EAC7B,OAAOa,EAASE,EAAe,qBAAqBf,CAAK;CAC3D;CAaA,OAA8B,GAA4C;EACxE,OAAOa,EAASE,EAAe,SAASf,CAAK;CAC/C;CAaA,UAAiC,GAA4C;EAC3E,OAAOa,EAASE,EAAe,aAAaf,CAAK;CACnD;CAaA,OAA8B,GAA4C;EACxE,OAAOa,EAASE,EAAe,QAAQf,CAAK;CAC9C;CAYA,UAAiC,GAA4C;EAC3E,OAAOa,EAASE,EAAe,YAAYf,CAAK;CAClD;AACF"}
@@ -1,3 +1,4 @@
1
1
  export * from './operator.cjs';
2
2
  export * from './types.cjs';
3
- export { filter, type SearchBuilder } from './builders.cjs';
3
+ export { filter } from './builders.cjs';
4
+ export type { SearchBuilder } from './searchFilter.cjs';
@@ -1,3 +1,4 @@
1
1
  export * from './operator.js';
2
2
  export * from './types.js';
3
- export { filter, type SearchBuilder } from './builders.js';
3
+ export { filter } from './builders.js';
4
+ export type { SearchBuilder } from './searchFilter.js';
@@ -0,0 +1,2 @@
1
+ const e=require("./operator.cjs"),t=require("../constantName.cjs"),n=require("../field.cjs"),r=require("./validate.cjs"),i=require("./scope.cjs");function a(e,n){return r.requireNonEmpty(`${t.constantName(e)} operands`,n),{op:e,operands:[...n]}}function o(t){return a(e.FilterOperator.AND,t)}function s(t){return a(e.FilterOperator.OR,t)}function c(t){return a(e.FilterOperator.NOR,t)}var l={and:o,or:s,nor:c,elementMatch(t,r){return i.requireElementScopedFilter(r,`ELEMENT_MATCH predicate`),{op:e.FilterOperator.ELEMENT_MATCH,field:n.queryField(t),predicate:r}}};exports.logicalFilters=l;
2
+ //# sourceMappingURL=logicalFilters.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logicalFilters.cjs","names":["constantName","FilterOperator","queryField","require_operator","require_constantName","require_field","require_validate","require_scope","logical","op","operands","andFilter","orFilter","norFilter","logicalFilters","predicate","field"],"sources":["../../../src/dsl/filter/logicalFilters.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 { constantName } from '../constantName.js';\nimport { queryField } from '../field.js';\nimport { FilterOperator } from './operator.js';\nimport { requireElementScopedFilter } from './scope.js';\nimport type {\n ElementFilterExpression,\n ElementLogicalFilter,\n ElementMatchFilter,\n FilterExpression,\n LogicalFilter,\n} from './types.js';\nimport { requireNonEmpty } from './validate.js';\n\nfunction logical<FIELDS extends string>(\n op: LogicalFilter['op'],\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n requireNonEmpty(`${constantName(op)} operands`, operands);\n return { op, operands: [...operands] };\n}\n\n/**\n * `filter.and`: matches when all of `operands` match. With element-scoped\n * operands only, the result is element-scoped too, so it can be an\n * `ELEMENT_MATCH` predicate.\n */\nfunction andFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.and`: matches when all of `operands` match. */\nfunction andFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction andFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.AND, operands);\n}\n\n/**\n * `filter.or`: matches when at least one of `operands` matches. With\n * element-scoped operands only, the result is element-scoped too, so it can\n * be an `ELEMENT_MATCH` predicate.\n */\nfunction orFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.or`: matches when at least one of `operands` matches. */\nfunction orFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction orFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.OR, operands);\n}\n\n/**\n * `filter.nor`: matches when none of `operands` match. With element-scoped\n * operands only, the result is element-scoped too, so it can be an\n * `ELEMENT_MATCH` predicate.\n */\nfunction norFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.nor`: matches when none of `operands` match. */\nfunction norFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction norFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.NOR, operands);\n}\n\n/** The filters that combine others: `and`, `or`, `nor`, and `elementMatch` over the elements of an array field. */\nexport const logicalFilters = {\n /**\n * Matches when all of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'and', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.and([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n and: andFilter,\n /**\n * Matches when at least one of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'or', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.or([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n or: orFilter,\n /**\n * Matches when none of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'nor', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.nor([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n nor: norFilter,\n /**\n * Matches records where a single element of the array `field` satisfies\n * `predicate`. Fields in `predicate` are relative to the element.\n *\n * @param field - Query field path of the array, e.g. `state.items`.\n * @param predicate - Element-scoped filter expression.\n * @returns `{ op: 'element-match', field, predicate }`.\n * A `SEARCH` inside it must name the fields it searches, relative to the\n * element (Wow 9.2 and later, where the descriptor lists\n * `elements[].search`); a model-wide `SEARCH` is a root filter.\n *\n * @throws TypeError If `predicate` contains, at any depth, a root-only filter\n * (`ID`, `IDS`, `AGGREGATE_ID`, `AGGREGATE_IDS`, `TENANT_ID`, `OWNER_ID`,\n * `SPACE_ID`, `DELETION` or a `SEARCH` without fields) or an `AND`, `OR`\n * or `NOR` whose operands are empty or contain `null`, or if `field` is\n * not a valid query field path.\n * @example\n * ```typescript\n * filter.elementMatch('state.items', filter.gt('quantity', 1));\n * filter.elementMatch(\n * 'state.items',\n * filter.search('usb cable', { fields: ['productName'] }),\n * );\n * ```\n */\n elementMatch<FIELDS extends string, ELEMENT_FIELDS extends string>(\n field: FIELDS,\n predicate: ElementFilterExpression<ELEMENT_FIELDS>,\n ): ElementMatchFilter<FIELDS, ELEMENT_FIELDS> {\n requireElementScopedFilter(predicate, 'ELEMENT_MATCH predicate');\n return {\n op: FilterOperator.ELEMENT_MATCH,\n field: queryField(field),\n predicate,\n };\n },\n};\n"],"mappings":"A,kJA0BA,SAASQ,EACP,EACA,EACuB,CAEvB,OADAF,EAAA,gBAAgB,GAAGN,EAAAA,aAAaS,CAAE,EAAE,WAAYC,CAAQ,EACjD,CAAE,KAAI,SAAU,CAAC,GAAGA,CAAQ,CAAE,CACvC,CAcA,SAASC,EACP,EACuB,CACvB,OAAOH,EAAQP,EAAAA,eAAe,IAAKS,CAAQ,CAC7C,CAcA,SAASE,EACP,EACuB,CACvB,OAAOJ,EAAQP,EAAAA,eAAe,GAAIS,CAAQ,CAC5C,CAcA,SAASG,EACP,EACuB,CACvB,OAAOL,EAAQP,EAAAA,eAAe,IAAKS,CAAQ,CAC7C,CAGA,IAAaI,EAAiB,CAkB5B,IAAKH,EAkBL,GAAIC,EAkBJ,IAAKC,EA0BL,aACE,EACA,EAC4C,CAE5C,OADAN,EAAA,2BAA2BQ,EAAW,yBAAyB,EACxD,CACL,GAAId,EAAAA,eAAe,cACnB,MAAOC,EAAAA,WAAWc,CAAK,EACvB,WACF,CACF,CACF,E"}
@@ -0,0 +1,109 @@
1
+ import { ElementFilterExpression, ElementLogicalFilter, ElementMatchFilter, FilterExpression, LogicalFilter } from './types.cjs';
2
+ /**
3
+ * `filter.and`: matches when all of `operands` match. With element-scoped
4
+ * operands only, the result is element-scoped too, so it can be an
5
+ * `ELEMENT_MATCH` predicate.
6
+ */
7
+ declare function andFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
8
+ /** `filter.and`: matches when all of `operands` match. */
9
+ declare function andFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
10
+ /**
11
+ * `filter.or`: matches when at least one of `operands` matches. With
12
+ * element-scoped operands only, the result is element-scoped too, so it can
13
+ * be an `ELEMENT_MATCH` predicate.
14
+ */
15
+ declare function orFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
16
+ /** `filter.or`: matches when at least one of `operands` matches. */
17
+ declare function orFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
18
+ /**
19
+ * `filter.nor`: matches when none of `operands` match. With element-scoped
20
+ * operands only, the result is element-scoped too, so it can be an
21
+ * `ELEMENT_MATCH` predicate.
22
+ */
23
+ declare function norFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
24
+ /** `filter.nor`: matches when none of `operands` match. */
25
+ declare function norFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
26
+ /** The filters that combine others: `and`, `or`, `nor`, and `elementMatch` over the elements of an array field. */
27
+ export declare const logicalFilters: {
28
+ /**
29
+ * Matches when all of `operands` match. Returns an element-scoped
30
+ * filter when every operand is element-scoped, so the result can be used
31
+ * inside `elementMatch`.
32
+ *
33
+ * @param operands - Non-empty list of filter expressions.
34
+ * @returns `{ op: 'and', operands }` with a copy of `operands`.
35
+ * @throws TypeError If `operands` is empty or contains `null` or
36
+ * `undefined`.
37
+ * @example
38
+ * ```typescript
39
+ * filter.and([
40
+ * filter.eq('state.status', 'PAID'),
41
+ * filter.eq('state.status', 'SHIPPED'),
42
+ * ]);
43
+ * ```
44
+ */
45
+ and: typeof andFilter;
46
+ /**
47
+ * Matches when at least one of `operands` match. Returns an element-scoped
48
+ * filter when every operand is element-scoped, so the result can be used
49
+ * inside `elementMatch`.
50
+ *
51
+ * @param operands - Non-empty list of filter expressions.
52
+ * @returns `{ op: 'or', operands }` with a copy of `operands`.
53
+ * @throws TypeError If `operands` is empty or contains `null` or
54
+ * `undefined`.
55
+ * @example
56
+ * ```typescript
57
+ * filter.or([
58
+ * filter.eq('state.status', 'PAID'),
59
+ * filter.eq('state.status', 'SHIPPED'),
60
+ * ]);
61
+ * ```
62
+ */
63
+ or: typeof orFilter;
64
+ /**
65
+ * Matches when none of `operands` match. Returns an element-scoped
66
+ * filter when every operand is element-scoped, so the result can be used
67
+ * inside `elementMatch`.
68
+ *
69
+ * @param operands - Non-empty list of filter expressions.
70
+ * @returns `{ op: 'nor', operands }` with a copy of `operands`.
71
+ * @throws TypeError If `operands` is empty or contains `null` or
72
+ * `undefined`.
73
+ * @example
74
+ * ```typescript
75
+ * filter.nor([
76
+ * filter.eq('state.status', 'PAID'),
77
+ * filter.eq('state.status', 'SHIPPED'),
78
+ * ]);
79
+ * ```
80
+ */
81
+ nor: typeof norFilter;
82
+ /**
83
+ * Matches records where a single element of the array `field` satisfies
84
+ * `predicate`. Fields in `predicate` are relative to the element.
85
+ *
86
+ * @param field - Query field path of the array, e.g. `state.items`.
87
+ * @param predicate - Element-scoped filter expression.
88
+ * @returns `{ op: 'element-match', field, predicate }`.
89
+ * A `SEARCH` inside it must name the fields it searches, relative to the
90
+ * element (Wow 9.2 and later, where the descriptor lists
91
+ * `elements[].search`); a model-wide `SEARCH` is a root filter.
92
+ *
93
+ * @throws TypeError If `predicate` contains, at any depth, a root-only filter
94
+ * (`ID`, `IDS`, `AGGREGATE_ID`, `AGGREGATE_IDS`, `TENANT_ID`, `OWNER_ID`,
95
+ * `SPACE_ID`, `DELETION` or a `SEARCH` without fields) or an `AND`, `OR`
96
+ * or `NOR` whose operands are empty or contain `null`, or if `field` is
97
+ * not a valid query field path.
98
+ * @example
99
+ * ```typescript
100
+ * filter.elementMatch('state.items', filter.gt('quantity', 1));
101
+ * filter.elementMatch(
102
+ * 'state.items',
103
+ * filter.search('usb cable', { fields: ['productName'] }),
104
+ * );
105
+ * ```
106
+ */
107
+ elementMatch<FIELDS extends string, ELEMENT_FIELDS extends string>(field: FIELDS, predicate: ElementFilterExpression<ELEMENT_FIELDS>): ElementMatchFilter<FIELDS, ELEMENT_FIELDS>;
108
+ };
109
+ export {};
@@ -0,0 +1,109 @@
1
+ import { ElementFilterExpression, ElementLogicalFilter, ElementMatchFilter, FilterExpression, LogicalFilter } from './types.js';
2
+ /**
3
+ * `filter.and`: matches when all of `operands` match. With element-scoped
4
+ * operands only, the result is element-scoped too, so it can be an
5
+ * `ELEMENT_MATCH` predicate.
6
+ */
7
+ declare function andFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
8
+ /** `filter.and`: matches when all of `operands` match. */
9
+ declare function andFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
10
+ /**
11
+ * `filter.or`: matches when at least one of `operands` matches. With
12
+ * element-scoped operands only, the result is element-scoped too, so it can
13
+ * be an `ELEMENT_MATCH` predicate.
14
+ */
15
+ declare function orFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
16
+ /** `filter.or`: matches when at least one of `operands` matches. */
17
+ declare function orFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
18
+ /**
19
+ * `filter.nor`: matches when none of `operands` match. With element-scoped
20
+ * operands only, the result is element-scoped too, so it can be an
21
+ * `ELEMENT_MATCH` predicate.
22
+ */
23
+ declare function norFilter<FIELDS extends string>(operands: readonly ElementFilterExpression<FIELDS>[]): ElementLogicalFilter<FIELDS>;
24
+ /** `filter.nor`: matches when none of `operands` match. */
25
+ declare function norFilter<FIELDS extends string>(operands: readonly FilterExpression<FIELDS>[]): LogicalFilter<FIELDS>;
26
+ /** The filters that combine others: `and`, `or`, `nor`, and `elementMatch` over the elements of an array field. */
27
+ export declare const logicalFilters: {
28
+ /**
29
+ * Matches when all of `operands` match. Returns an element-scoped
30
+ * filter when every operand is element-scoped, so the result can be used
31
+ * inside `elementMatch`.
32
+ *
33
+ * @param operands - Non-empty list of filter expressions.
34
+ * @returns `{ op: 'and', operands }` with a copy of `operands`.
35
+ * @throws TypeError If `operands` is empty or contains `null` or
36
+ * `undefined`.
37
+ * @example
38
+ * ```typescript
39
+ * filter.and([
40
+ * filter.eq('state.status', 'PAID'),
41
+ * filter.eq('state.status', 'SHIPPED'),
42
+ * ]);
43
+ * ```
44
+ */
45
+ and: typeof andFilter;
46
+ /**
47
+ * Matches when at least one of `operands` match. Returns an element-scoped
48
+ * filter when every operand is element-scoped, so the result can be used
49
+ * inside `elementMatch`.
50
+ *
51
+ * @param operands - Non-empty list of filter expressions.
52
+ * @returns `{ op: 'or', operands }` with a copy of `operands`.
53
+ * @throws TypeError If `operands` is empty or contains `null` or
54
+ * `undefined`.
55
+ * @example
56
+ * ```typescript
57
+ * filter.or([
58
+ * filter.eq('state.status', 'PAID'),
59
+ * filter.eq('state.status', 'SHIPPED'),
60
+ * ]);
61
+ * ```
62
+ */
63
+ or: typeof orFilter;
64
+ /**
65
+ * Matches when none of `operands` match. Returns an element-scoped
66
+ * filter when every operand is element-scoped, so the result can be used
67
+ * inside `elementMatch`.
68
+ *
69
+ * @param operands - Non-empty list of filter expressions.
70
+ * @returns `{ op: 'nor', operands }` with a copy of `operands`.
71
+ * @throws TypeError If `operands` is empty or contains `null` or
72
+ * `undefined`.
73
+ * @example
74
+ * ```typescript
75
+ * filter.nor([
76
+ * filter.eq('state.status', 'PAID'),
77
+ * filter.eq('state.status', 'SHIPPED'),
78
+ * ]);
79
+ * ```
80
+ */
81
+ nor: typeof norFilter;
82
+ /**
83
+ * Matches records where a single element of the array `field` satisfies
84
+ * `predicate`. Fields in `predicate` are relative to the element.
85
+ *
86
+ * @param field - Query field path of the array, e.g. `state.items`.
87
+ * @param predicate - Element-scoped filter expression.
88
+ * @returns `{ op: 'element-match', field, predicate }`.
89
+ * A `SEARCH` inside it must name the fields it searches, relative to the
90
+ * element (Wow 9.2 and later, where the descriptor lists
91
+ * `elements[].search`); a model-wide `SEARCH` is a root filter.
92
+ *
93
+ * @throws TypeError If `predicate` contains, at any depth, a root-only filter
94
+ * (`ID`, `IDS`, `AGGREGATE_ID`, `AGGREGATE_IDS`, `TENANT_ID`, `OWNER_ID`,
95
+ * `SPACE_ID`, `DELETION` or a `SEARCH` without fields) or an `AND`, `OR`
96
+ * or `NOR` whose operands are empty or contain `null`, or if `field` is
97
+ * not a valid query field path.
98
+ * @example
99
+ * ```typescript
100
+ * filter.elementMatch('state.items', filter.gt('quantity', 1));
101
+ * filter.elementMatch(
102
+ * 'state.items',
103
+ * filter.search('usb cable', { fields: ['productName'] }),
104
+ * );
105
+ * ```
106
+ */
107
+ elementMatch<FIELDS extends string, ELEMENT_FIELDS extends string>(field: FIELDS, predicate: ElementFilterExpression<ELEMENT_FIELDS>): ElementMatchFilter<FIELDS, ELEMENT_FIELDS>;
108
+ };
109
+ export {};
@@ -0,0 +1,36 @@
1
+ import { FilterOperator as e } from "./operator.es.js";
2
+ import { constantName as t } from "../constantName.es.js";
3
+ import { queryField as n } from "../field.es.js";
4
+ import { requireNonEmpty as r } from "./validate.es.js";
5
+ import { requireElementScopedFilter as i } from "./scope.es.js";
6
+ // src/dsl/filter/logicalFilters.ts
7
+ function a(e, n) {
8
+ return r(`${t(e)} operands`, n), {
9
+ op: e,
10
+ operands: [...n]
11
+ };
12
+ }
13
+ function o(t) {
14
+ return a(e.AND, t);
15
+ }
16
+ function s(t) {
17
+ return a(e.OR, t);
18
+ }
19
+ function c(t) {
20
+ return a(e.NOR, t);
21
+ }
22
+ var l = {
23
+ and: o,
24
+ or: s,
25
+ nor: c,
26
+ elementMatch(t, r) {
27
+ return i(r, "ELEMENT_MATCH predicate"), {
28
+ op: e.ELEMENT_MATCH,
29
+ field: n(t),
30
+ predicate: r
31
+ };
32
+ }
33
+ };
34
+ export { l as logicalFilters };
35
+
36
+ //# sourceMappingURL=logicalFilters.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logicalFilters.es.js","names":["logical","requireNonEmpty","constantName","op","operands","andFilter","FilterOperator","orFilter","norFilter","logicalFilters","requireElementScopedFilter","predicate","queryField","field"],"sources":["../../../src/dsl/filter/logicalFilters.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 { constantName } from '../constantName.js';\nimport { queryField } from '../field.js';\nimport { FilterOperator } from './operator.js';\nimport { requireElementScopedFilter } from './scope.js';\nimport type {\n ElementFilterExpression,\n ElementLogicalFilter,\n ElementMatchFilter,\n FilterExpression,\n LogicalFilter,\n} from './types.js';\nimport { requireNonEmpty } from './validate.js';\n\nfunction logical<FIELDS extends string>(\n op: LogicalFilter['op'],\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n requireNonEmpty(`${constantName(op)} operands`, operands);\n return { op, operands: [...operands] };\n}\n\n/**\n * `filter.and`: matches when all of `operands` match. With element-scoped\n * operands only, the result is element-scoped too, so it can be an\n * `ELEMENT_MATCH` predicate.\n */\nfunction andFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.and`: matches when all of `operands` match. */\nfunction andFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction andFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.AND, operands);\n}\n\n/**\n * `filter.or`: matches when at least one of `operands` matches. With\n * element-scoped operands only, the result is element-scoped too, so it can\n * be an `ELEMENT_MATCH` predicate.\n */\nfunction orFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.or`: matches when at least one of `operands` matches. */\nfunction orFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction orFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.OR, operands);\n}\n\n/**\n * `filter.nor`: matches when none of `operands` match. With element-scoped\n * operands only, the result is element-scoped too, so it can be an\n * `ELEMENT_MATCH` predicate.\n */\nfunction norFilter<FIELDS extends string>(\n operands: readonly ElementFilterExpression<FIELDS>[],\n): ElementLogicalFilter<FIELDS>;\n/** `filter.nor`: matches when none of `operands` match. */\nfunction norFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS>;\nfunction norFilter<FIELDS extends string>(\n operands: readonly FilterExpression<FIELDS>[],\n): LogicalFilter<FIELDS> {\n return logical(FilterOperator.NOR, operands);\n}\n\n/** The filters that combine others: `and`, `or`, `nor`, and `elementMatch` over the elements of an array field. */\nexport const logicalFilters = {\n /**\n * Matches when all of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'and', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.and([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n and: andFilter,\n /**\n * Matches when at least one of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'or', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.or([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n or: orFilter,\n /**\n * Matches when none of `operands` match. Returns an element-scoped\n * filter when every operand is element-scoped, so the result can be used\n * inside `elementMatch`.\n *\n * @param operands - Non-empty list of filter expressions.\n * @returns `{ op: 'nor', operands }` with a copy of `operands`.\n * @throws TypeError If `operands` is empty or contains `null` or\n * `undefined`.\n * @example\n * ```typescript\n * filter.nor([\n * filter.eq('state.status', 'PAID'),\n * filter.eq('state.status', 'SHIPPED'),\n * ]);\n * ```\n */\n nor: norFilter,\n /**\n * Matches records where a single element of the array `field` satisfies\n * `predicate`. Fields in `predicate` are relative to the element.\n *\n * @param field - Query field path of the array, e.g. `state.items`.\n * @param predicate - Element-scoped filter expression.\n * @returns `{ op: 'element-match', field, predicate }`.\n * A `SEARCH` inside it must name the fields it searches, relative to the\n * element (Wow 9.2 and later, where the descriptor lists\n * `elements[].search`); a model-wide `SEARCH` is a root filter.\n *\n * @throws TypeError If `predicate` contains, at any depth, a root-only filter\n * (`ID`, `IDS`, `AGGREGATE_ID`, `AGGREGATE_IDS`, `TENANT_ID`, `OWNER_ID`,\n * `SPACE_ID`, `DELETION` or a `SEARCH` without fields) or an `AND`, `OR`\n * or `NOR` whose operands are empty or contain `null`, or if `field` is\n * not a valid query field path.\n * @example\n * ```typescript\n * filter.elementMatch('state.items', filter.gt('quantity', 1));\n * filter.elementMatch(\n * 'state.items',\n * filter.search('usb cable', { fields: ['productName'] }),\n * );\n * ```\n */\n elementMatch<FIELDS extends string, ELEMENT_FIELDS extends string>(\n field: FIELDS,\n predicate: ElementFilterExpression<ELEMENT_FIELDS>,\n ): ElementMatchFilter<FIELDS, ELEMENT_FIELDS> {\n requireElementScopedFilter(predicate, 'ELEMENT_MATCH predicate');\n return {\n op: FilterOperator.ELEMENT_MATCH,\n field: queryField(field),\n predicate,\n };\n },\n};\n"],"mappings":";;;;;;AA0BA,SAASA,EACP,GACA,GACuB;CAEvB,OADAC,EAAgB,GAAGC,EAAaC,CAAE,EAAE,YAAYC,CAAQ,GACjD;EAAE;EAAI,UAAU,CAAC,GAAGA,CAAQ;CAAE;AACvC;AAcA,SAASC,EACP,GACuB;CACvB,OAAOL,EAAQM,EAAe,KAAKF,CAAQ;AAC7C;AAcA,SAASG,EACP,GACuB;CACvB,OAAOP,EAAQM,EAAe,IAAIF,CAAQ;AAC5C;AAcA,SAASI,EACP,GACuB;CACvB,OAAOR,EAAQM,EAAe,KAAKF,CAAQ;AAC7C;AAGA,IAAaK,IAAiB;CAkB5B,KAAKJ;CAkBL,IAAIE;CAkBJ,KAAKC;CA0BL,aACE,GACA,GAC4C;EAE5C,OADAE,EAA2BC,GAAW,yBAAyB,GACxD;GACL,IAAIL,EAAe;GACnB,OAAOM,EAAWC,CAAK;GACvB;EACF;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./operator.cjs"),t=require("../constantName.cjs"),n=require("./validate.cjs"),r=require("../deletionState.cjs");function i(e,r){return{op:e,value:n.requiredString(`${t.constantName(e)} value`,r)}}function a(e,r){return n.requireNonEmpty(`${t.constantName(e)} values`,r),r.forEach(r=>n.requiredString(`${t.constantName(e)} value`,r)),{op:e,values:[...r]}}var o={matchAll(){return{op:e.FilterOperator.MATCH_ALL}},matchNone(){return{op:e.FilterOperator.MATCH_NONE}},id(t){return i(e.FilterOperator.ID,t)},ids(t){return a(e.FilterOperator.IDS,t)},aggregateId(t){return i(e.FilterOperator.AGGREGATE_ID,t)},aggregateIds(t){return a(e.FilterOperator.AGGREGATE_IDS,t)},tenantId(t){return i(e.FilterOperator.TENANT_ID,t)},ownerId(t){return i(e.FilterOperator.OWNER_ID,t)},spaceId(t){return i(e.FilterOperator.SPACE_ID,t)},deletion(t){if(t!==r.DeletionState.ACTIVE&&t!==r.DeletionState.DELETED&&t!==r.DeletionState.ALL)throw TypeError(`Deletion state is invalid: [${String(t)}].`);return{op:e.FilterOperator.DELETION,state:t}}};exports.metadataFilters=o;
2
+ //# sourceMappingURL=metadataFilters.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadataFilters.cjs","names":["requiredString","constantName","FilterOperator","DeletionState","require_operator","require_constantName","require_validate","require_deletionState","metadataValue","op","value","metadataValues","values","metadataFilters","state"],"sources":["../../../src/dsl/filter/metadataFilters.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 { constantName } from '../constantName.js';\nimport { DeletionState } from '../deletionState.js';\nimport { FilterOperator } from './operator.js';\nimport type {\n DeletionFilter,\n MatchFilter,\n MetadataValueFilter,\n MetadataValuesFilter,\n} from './types.js';\nimport { requireNonEmpty, requiredString } from './validate.js';\n\nfunction metadataValue(\n op: MetadataValueFilter['op'],\n value: string,\n): MetadataValueFilter {\n return { op, value: requiredString(`${constantName(op)} value`, value) };\n}\n\nfunction metadataValues(\n op: MetadataValuesFilter['op'],\n values: readonly string[],\n): MetadataValuesFilter {\n requireNonEmpty(`${constantName(op)} values`, values);\n values.forEach(value => requiredString(`${constantName(op)} value`, value));\n return { op, values: [...values] };\n}\n\n/** The filters on what Wow knows of every record: all or none, its ids, tenant, owner and space, and its deletion state. */\nexport const metadataFilters = {\n /**\n * Matches every record in the query scope.\n *\n * @returns `{ op: 'match-all' }`.\n * @example\n * ```typescript\n * filter.matchAll();\n * ```\n */\n matchAll(): MatchFilter {\n return { op: FilterOperator.MATCH_ALL };\n },\n /**\n * Matches no record.\n *\n * @returns `{ op: 'match-none' }`.\n * @example\n * ```typescript\n * filter.matchNone();\n * ```\n */\n matchNone(): MatchFilter {\n return { op: FilterOperator.MATCH_NONE };\n },\n /**\n * Matches the record whose record ID equals `value`. Root-only: not allowed\n * inside `elementMatch`.\n *\n * @param value - The record ID.\n * @returns `{ op: 'id', value }`.\n * @throws TypeError If `value` is not a string.\n * @example\n * ```typescript\n * filter.id('order-1');\n * ```\n */\n id(value: string): MetadataValueFilter {\n return metadataValue(FilterOperator.ID, value);\n },\n /**\n * Matches records whose record ID is one of `values`. Root-only: not\n * allowed inside `elementMatch`.\n *\n * @param values - Non-empty list of record IDs.\n * @returns `{ op: 'ids', values }` with a copy of `values`.\n * @throws TypeError If `values` is empty, contains `null` or `undefined`,\n * or contains a non-string.\n * @example\n * ```typescript\n * filter.ids(['order-1', 'order-2']);\n * ```\n */\n ids(values: readonly string[]): MetadataValuesFilter {\n return metadataValues(FilterOperator.IDS, values);\n },\n /**\n * Matches the record whose aggregate ID equals `value`. Root-only: not allowed\n * inside `elementMatch`.\n *\n * @param value - The aggregate ID.\n * @returns `{ op: 'aggregate-id', value }`.\n * @throws TypeError If `value` is not a string.\n * @example\n * ```typescript\n * filter.aggregateId('order-1');\n * ```\n */\n aggregateId(value: string): MetadataValueFilter {\n return metadataValue(FilterOperator.AGGREGATE_ID, value);\n },\n /**\n * Matches records whose aggregate ID is one of `values`. Root-only: not\n * allowed inside `elementMatch`.\n *\n * @param values - Non-empty list of aggregate IDs.\n * @returns `{ op: 'aggregate-ids', values }` with a copy of `values`.\n * @throws TypeError If `values` is empty, contains `null` or `undefined`,\n * or contains a non-string.\n * @example\n * ```typescript\n * filter.aggregateIds(['order-1', 'order-2']);\n * ```\n */\n aggregateIds(values: readonly string[]): MetadataValuesFilter {\n return metadataValues(FilterOperator.AGGREGATE_IDS, values);\n },\n /**\n * Matches the record whose tenant ID equals `value`. Root-only: not allowed\n * inside `elementMatch`.\n *\n * @param value - The tenant ID.\n * @returns `{ op: 'tenant-id', value }`.\n * @throws TypeError If `value` is not a string.\n * @example\n * ```typescript\n * filter.tenantId('tenant-a');\n * ```\n */\n tenantId(value: string): MetadataValueFilter {\n return metadataValue(FilterOperator.TENANT_ID, value);\n },\n /**\n * Matches the record whose owner ID equals `value`. Root-only: not allowed\n * inside `elementMatch`.\n *\n * @param value - The owner ID.\n * @returns `{ op: 'owner-id', value }`.\n * @throws TypeError If `value` is not a string.\n * @example\n * ```typescript\n * filter.ownerId('user-1');\n * ```\n */\n ownerId(value: string): MetadataValueFilter {\n return metadataValue(FilterOperator.OWNER_ID, value);\n },\n /**\n * Matches the record whose space ID equals `value`. Root-only: not allowed\n * inside `elementMatch`.\n *\n * @param value - The space ID.\n * @returns `{ op: 'space-id', value }`.\n * @throws TypeError If `value` is not a string.\n * @example\n * ```typescript\n * filter.spaceId('space-1');\n * ```\n */\n spaceId(value: string): MetadataValueFilter {\n return metadataValue(FilterOperator.SPACE_ID, value);\n },\n /**\n * Matches snapshots by deletion state. An explicit `DELETION` at the root or\n * in a root `AND` replaces the gateway's default `ACTIVE` scope. Root-only:\n * not allowed inside `elementMatch`.\n *\n * @param state - `ACTIVE`, `DELETED` or `ALL`.\n * @returns `{ op: 'deletion', state }`.\n * @throws TypeError If `state` is not a {@link DeletionState} member.\n * @example\n * ```typescript\n * filter.deletion(DeletionState.ALL);\n * ```\n */\n deletion(state: DeletionState): DeletionFilter {\n if (\n state !== DeletionState.ACTIVE &&\n state !== DeletionState.DELETED &&\n state !== DeletionState.ALL\n ) {\n throw new TypeError(`Deletion state is invalid: [${String(state)}].`);\n }\n return { op: FilterOperator.DELETION, state };\n },\n};\n"],"mappings":"A,iIAwBA,SAASQ,EACP,EACA,EACqB,CACrB,MAAO,CAAE,KAAI,MAAOR,EAAAA,eAAe,GAAGC,EAAAA,aAAaQ,CAAE,EAAE,QAASC,CAAK,CAAE,CACzE,CAEA,SAASC,EACP,EACA,EACsB,CAGtB,OAFAL,EAAA,gBAAgB,GAAGL,EAAAA,aAAaQ,CAAE,EAAE,SAAUG,CAAM,EACpDA,EAAO,QAAQ,GAASZ,EAAAA,eAAe,GAAGC,EAAAA,aAAaQ,CAAE,EAAE,QAASC,CAAK,CAAC,EACnE,CAAE,KAAI,OAAQ,CAAC,GAAGE,CAAM,CAAE,CACnC,CAGA,IAAaC,EAAkB,CAU7B,UAAwB,CACtB,MAAO,CAAE,GAAIX,EAAAA,eAAe,SAAU,CACxC,EAUA,WAAyB,CACvB,MAAO,CAAE,GAAIA,EAAAA,eAAe,UAAW,CACzC,EAaA,GAAG,EAAoC,CACrC,OAAOM,EAAcN,EAAAA,eAAe,GAAIQ,CAAK,CAC/C,EAcA,IAAI,EAAiD,CACnD,OAAOC,EAAeT,EAAAA,eAAe,IAAKU,CAAM,CAClD,EAaA,YAAY,EAAoC,CAC9C,OAAOJ,EAAcN,EAAAA,eAAe,aAAcQ,CAAK,CACzD,EAcA,aAAa,EAAiD,CAC5D,OAAOC,EAAeT,EAAAA,eAAe,cAAeU,CAAM,CAC5D,EAaA,SAAS,EAAoC,CAC3C,OAAOJ,EAAcN,EAAAA,eAAe,UAAWQ,CAAK,CACtD,EAaA,QAAQ,EAAoC,CAC1C,OAAOF,EAAcN,EAAAA,eAAe,SAAUQ,CAAK,CACrD,EAaA,QAAQ,EAAoC,CAC1C,OAAOF,EAAcN,EAAAA,eAAe,SAAUQ,CAAK,CACrD,EAcA,SAAS,EAAsC,CAC7C,GACEI,IAAUX,EAAAA,cAAc,QACxBW,IAAUX,EAAAA,cAAc,SACxBW,IAAUX,EAAAA,cAAc,IAExB,MAAU,UAAU,+BAA+B,OAAOW,CAAK,EAAE,GAAG,EAEtE,MAAO,CAAE,GAAIZ,EAAAA,eAAe,SAAU,OAAM,CAC9C,CACF,E"}
@@ -0,0 +1,132 @@
1
+ import { DeletionState } from '../deletionState.cjs';
2
+ import { DeletionFilter, MatchFilter, MetadataValueFilter, MetadataValuesFilter } from './types.cjs';
3
+ /** The filters on what Wow knows of every record: all or none, its ids, tenant, owner and space, and its deletion state. */
4
+ export declare const metadataFilters: {
5
+ /**
6
+ * Matches every record in the query scope.
7
+ *
8
+ * @returns `{ op: 'match-all' }`.
9
+ * @example
10
+ * ```typescript
11
+ * filter.matchAll();
12
+ * ```
13
+ */
14
+ matchAll(): MatchFilter;
15
+ /**
16
+ * Matches no record.
17
+ *
18
+ * @returns `{ op: 'match-none' }`.
19
+ * @example
20
+ * ```typescript
21
+ * filter.matchNone();
22
+ * ```
23
+ */
24
+ matchNone(): MatchFilter;
25
+ /**
26
+ * Matches the record whose record ID equals `value`. Root-only: not allowed
27
+ * inside `elementMatch`.
28
+ *
29
+ * @param value - The record ID.
30
+ * @returns `{ op: 'id', value }`.
31
+ * @throws TypeError If `value` is not a string.
32
+ * @example
33
+ * ```typescript
34
+ * filter.id('order-1');
35
+ * ```
36
+ */
37
+ id(value: string): MetadataValueFilter;
38
+ /**
39
+ * Matches records whose record ID is one of `values`. Root-only: not
40
+ * allowed inside `elementMatch`.
41
+ *
42
+ * @param values - Non-empty list of record IDs.
43
+ * @returns `{ op: 'ids', values }` with a copy of `values`.
44
+ * @throws TypeError If `values` is empty, contains `null` or `undefined`,
45
+ * or contains a non-string.
46
+ * @example
47
+ * ```typescript
48
+ * filter.ids(['order-1', 'order-2']);
49
+ * ```
50
+ */
51
+ ids(values: readonly string[]): MetadataValuesFilter;
52
+ /**
53
+ * Matches the record whose aggregate ID equals `value`. Root-only: not allowed
54
+ * inside `elementMatch`.
55
+ *
56
+ * @param value - The aggregate ID.
57
+ * @returns `{ op: 'aggregate-id', value }`.
58
+ * @throws TypeError If `value` is not a string.
59
+ * @example
60
+ * ```typescript
61
+ * filter.aggregateId('order-1');
62
+ * ```
63
+ */
64
+ aggregateId(value: string): MetadataValueFilter;
65
+ /**
66
+ * Matches records whose aggregate ID is one of `values`. Root-only: not
67
+ * allowed inside `elementMatch`.
68
+ *
69
+ * @param values - Non-empty list of aggregate IDs.
70
+ * @returns `{ op: 'aggregate-ids', values }` with a copy of `values`.
71
+ * @throws TypeError If `values` is empty, contains `null` or `undefined`,
72
+ * or contains a non-string.
73
+ * @example
74
+ * ```typescript
75
+ * filter.aggregateIds(['order-1', 'order-2']);
76
+ * ```
77
+ */
78
+ aggregateIds(values: readonly string[]): MetadataValuesFilter;
79
+ /**
80
+ * Matches the record whose tenant ID equals `value`. Root-only: not allowed
81
+ * inside `elementMatch`.
82
+ *
83
+ * @param value - The tenant ID.
84
+ * @returns `{ op: 'tenant-id', value }`.
85
+ * @throws TypeError If `value` is not a string.
86
+ * @example
87
+ * ```typescript
88
+ * filter.tenantId('tenant-a');
89
+ * ```
90
+ */
91
+ tenantId(value: string): MetadataValueFilter;
92
+ /**
93
+ * Matches the record whose owner ID equals `value`. Root-only: not allowed
94
+ * inside `elementMatch`.
95
+ *
96
+ * @param value - The owner ID.
97
+ * @returns `{ op: 'owner-id', value }`.
98
+ * @throws TypeError If `value` is not a string.
99
+ * @example
100
+ * ```typescript
101
+ * filter.ownerId('user-1');
102
+ * ```
103
+ */
104
+ ownerId(value: string): MetadataValueFilter;
105
+ /**
106
+ * Matches the record whose space ID equals `value`. Root-only: not allowed
107
+ * inside `elementMatch`.
108
+ *
109
+ * @param value - The space ID.
110
+ * @returns `{ op: 'space-id', value }`.
111
+ * @throws TypeError If `value` is not a string.
112
+ * @example
113
+ * ```typescript
114
+ * filter.spaceId('space-1');
115
+ * ```
116
+ */
117
+ spaceId(value: string): MetadataValueFilter;
118
+ /**
119
+ * Matches snapshots by deletion state. An explicit `DELETION` at the root or
120
+ * in a root `AND` replaces the gateway's default `ACTIVE` scope. Root-only:
121
+ * not allowed inside `elementMatch`.
122
+ *
123
+ * @param state - `ACTIVE`, `DELETED` or `ALL`.
124
+ * @returns `{ op: 'deletion', state }`.
125
+ * @throws TypeError If `state` is not a {@link DeletionState} member.
126
+ * @example
127
+ * ```typescript
128
+ * filter.deletion(DeletionState.ALL);
129
+ * ```
130
+ */
131
+ deletion(state: DeletionState): DeletionFilter;
132
+ };