@wener/common 1.0.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/lib/cn/DivisionCode.js +55 -32
  2. package/lib/cn/DivisionCode.test.js +140 -0
  3. package/lib/cn/Mod11Checksum.js +80 -37
  4. package/lib/cn/Mod31Checksum.js +89 -40
  5. package/lib/cn/ResidentIdentityCardNumber.js +16 -16
  6. package/lib/cn/ResidentIdentityCardNumber.test.js +21 -0
  7. package/lib/cn/UnifiedSocialCreditCode.js +32 -26
  8. package/lib/cn/UnifiedSocialCreditCode.test.js +16 -0
  9. package/lib/cn/formatDate.js +5 -7
  10. package/lib/cn/index.js +0 -1
  11. package/lib/cn/parseSex.js +0 -2
  12. package/lib/cn/types.d.js +0 -2
  13. package/lib/consola/createStandardConsolaReporter.js +18 -0
  14. package/lib/consola/formatLogObject.js +226 -0
  15. package/lib/consola/index.js +2 -0
  16. package/lib/data/formatSort.js +5 -6
  17. package/lib/data/formatSort.test.js +34 -0
  18. package/lib/data/index.js +0 -1
  19. package/lib/data/maybeNumber.js +11 -5
  20. package/lib/data/parseSort.js +28 -22
  21. package/lib/data/parseSort.test.js +188 -0
  22. package/lib/data/resolvePagination.js +27 -16
  23. package/lib/data/resolvePagination.test.js +232 -0
  24. package/lib/data/types.d.js +0 -2
  25. package/lib/index.js +0 -1
  26. package/lib/jsonschema/JsonSchema.js +80 -54
  27. package/lib/jsonschema/JsonSchema.test.js +137 -0
  28. package/lib/jsonschema/index.js +0 -1
  29. package/lib/jsonschema/types.d.js +5 -3
  30. package/lib/meta/defineFileType.js +103 -20
  31. package/lib/meta/defineInit.js +250 -31
  32. package/lib/meta/defineMetadata.js +140 -24
  33. package/lib/meta/defineMetadata.test.js +13 -0
  34. package/lib/meta/index.js +0 -1
  35. package/lib/password/PHC.js +87 -63
  36. package/lib/password/PHC.test.js +539 -0
  37. package/lib/password/Password.js +291 -29
  38. package/lib/password/Password.test.js +362 -0
  39. package/lib/password/createArgon2PasswordAlgorithm.js +191 -35
  40. package/lib/password/createBase64PasswordAlgorithm.js +141 -8
  41. package/lib/password/createBcryptPasswordAlgorithm.js +168 -13
  42. package/lib/password/createPBKDF2PasswordAlgorithm.js +228 -46
  43. package/lib/password/createScryptPasswordAlgorithm.js +211 -55
  44. package/lib/password/index.js +0 -1
  45. package/lib/password/server/index.js +0 -1
  46. package/lib/resource/Identifiable.js +1 -0
  47. package/lib/resource/getTitleOfResource.js +10 -0
  48. package/lib/resource/index.js +1 -0
  49. package/lib/resource/schema/AnyResourceSchema.js +89 -0
  50. package/lib/resource/schema/BaseResourceSchema.js +29 -0
  51. package/lib/resource/schema/ResourceActionType.js +118 -0
  52. package/lib/resource/schema/ResourceStatus.js +93 -0
  53. package/lib/resource/schema/ResourceType.js +24 -0
  54. package/lib/resource/schema/SchemaRegistry.js +38 -0
  55. package/lib/resource/schema/SexType.js +10 -0
  56. package/lib/resource/schema/types.js +89 -0
  57. package/lib/resource/schema/types.test.js +14 -0
  58. package/lib/schema/TypeSchema.d.js +1 -0
  59. package/lib/schema/createSchemaData.js +173 -0
  60. package/lib/schema/findJsonSchemaByPath.js +49 -0
  61. package/lib/schema/getSchemaCache.js +11 -0
  62. package/lib/schema/getSchemaOptions.js +24 -0
  63. package/lib/schema/index.js +5 -0
  64. package/lib/schema/toJsonSchema.js +441 -0
  65. package/lib/schema/toJsonSchema.test.js +27 -0
  66. package/lib/schema/validate.js +124 -0
  67. package/lib/search/AdvanceSearch.js +0 -1
  68. package/lib/search/AdvanceSearch.test.js +435 -0
  69. package/lib/search/formatAdvanceSearch.js +41 -27
  70. package/lib/search/index.js +0 -1
  71. package/lib/search/optimizeAdvanceSearch.js +79 -25
  72. package/lib/search/parseAdvanceSearch.js +5 -5
  73. package/lib/search/parser.d.js +0 -2
  74. package/lib/search/parser.js +97 -74
  75. package/lib/search/types.d.js +0 -2
  76. package/lib/tools/generateSchema.js +201 -0
  77. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +143 -55
  78. package/package.json +30 -9
  79. package/src/consola/createStandardConsolaReporter.ts +31 -0
  80. package/src/consola/formatLogObject.ts +171 -0
  81. package/src/consola/index.ts +2 -0
  82. package/src/data/maybeNumber.ts +5 -1
  83. package/src/data/resolvePagination.test.ts +1 -1
  84. package/src/data/resolvePagination.ts +18 -7
  85. package/src/data/types.d.ts +12 -0
  86. package/src/jsonschema/JsonSchema.test.ts +17 -0
  87. package/src/jsonschema/JsonSchema.ts +4 -4
  88. package/src/jsonschema/types.d.ts +63 -12
  89. package/src/resource/Identifiable.ts +3 -0
  90. package/src/resource/getTitleOfResource.tsx +6 -0
  91. package/src/resource/index.ts +3 -0
  92. package/src/resource/schema/AnyResourceSchema.ts +113 -0
  93. package/src/resource/schema/BaseResourceSchema.ts +32 -0
  94. package/src/resource/schema/ResourceActionType.ts +123 -0
  95. package/src/resource/schema/ResourceStatus.ts +94 -0
  96. package/src/resource/schema/ResourceType.ts +25 -0
  97. package/src/resource/schema/SchemaRegistry.ts +42 -0
  98. package/src/resource/schema/SexType.ts +13 -0
  99. package/src/resource/schema/types.test.ts +18 -0
  100. package/src/resource/schema/types.ts +105 -0
  101. package/src/schema/TypeSchema.d.ts +32 -0
  102. package/src/schema/createSchemaData.ts +81 -0
  103. package/src/schema/findJsonSchemaByPath.ts +37 -0
  104. package/src/schema/getSchemaCache.ts +21 -0
  105. package/src/schema/getSchemaOptions.ts +24 -0
  106. package/src/schema/index.ts +6 -0
  107. package/src/schema/toJsonSchema.test.ts +37 -0
  108. package/src/schema/toJsonSchema.ts +200 -0
  109. package/src/schema/validate.ts +135 -0
  110. package/src/tools/generateSchema.ts +39 -0
  111. package/lib/cn/DivisionCode.js.map +0 -1
  112. package/lib/cn/Mod11Checksum.js.map +0 -1
  113. package/lib/cn/Mod31Checksum.js.map +0 -1
  114. package/lib/cn/ResidentIdentityCardNumber.js.map +0 -1
  115. package/lib/cn/UnifiedSocialCreditCode.js.map +0 -1
  116. package/lib/cn/formatDate.js.map +0 -1
  117. package/lib/cn/index.js.map +0 -1
  118. package/lib/cn/parseSex.js.map +0 -1
  119. package/lib/cn/types.d.js.map +0 -1
  120. package/lib/data/formatSort.js.map +0 -1
  121. package/lib/data/index.js.map +0 -1
  122. package/lib/data/maybeNumber.js.map +0 -1
  123. package/lib/data/parseSort.js.map +0 -1
  124. package/lib/data/resolvePagination.js.map +0 -1
  125. package/lib/data/types.d.js.map +0 -1
  126. package/lib/index.js.map +0 -1
  127. package/lib/jsonschema/JsonSchema.js.map +0 -1
  128. package/lib/jsonschema/index.js.map +0 -1
  129. package/lib/jsonschema/types.d.js.map +0 -1
  130. package/lib/meta/defineFileType.js.map +0 -1
  131. package/lib/meta/defineInit.js.map +0 -1
  132. package/lib/meta/defineMetadata.js.map +0 -1
  133. package/lib/meta/index.js.map +0 -1
  134. package/lib/password/PHC.js.map +0 -1
  135. package/lib/password/Password.js.map +0 -1
  136. package/lib/password/createArgon2PasswordAlgorithm.js.map +0 -1
  137. package/lib/password/createBase64PasswordAlgorithm.js.map +0 -1
  138. package/lib/password/createBcryptPasswordAlgorithm.js.map +0 -1
  139. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +0 -1
  140. package/lib/password/createScryptPasswordAlgorithm.js.map +0 -1
  141. package/lib/password/index.js.map +0 -1
  142. package/lib/password/server/index.js.map +0 -1
  143. package/lib/search/AdvanceSearch.js.map +0 -1
  144. package/lib/search/formatAdvanceSearch.js.map +0 -1
  145. package/lib/search/index.js.map +0 -1
  146. package/lib/search/optimizeAdvanceSearch.js.map +0 -1
  147. package/lib/search/parseAdvanceSearch.js.map +0 -1
  148. package/lib/search/parser.d.js.map +0 -1
  149. package/lib/search/parser.js.map +0 -1
  150. package/lib/search/types.d.js.map +0 -1
  151. package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +0 -1
@@ -0,0 +1,435 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length)
3
+ len = arr.length;
4
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
5
+ arr2[i] = arr[i];
6
+ return arr2;
7
+ }
8
+ function _array_with_holes(arr) {
9
+ if (Array.isArray(arr))
10
+ return arr;
11
+ }
12
+ function _iterable_to_array_limit(arr, i) {
13
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
14
+ if (_i == null)
15
+ return;
16
+ var _arr = [];
17
+ var _n = true;
18
+ var _d = false;
19
+ var _s, _e;
20
+ try {
21
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
22
+ _arr.push(_s.value);
23
+ if (i && _arr.length === i)
24
+ break;
25
+ }
26
+ }
27
+ catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ }
31
+ finally {
32
+ try {
33
+ if (!_n && _i["return"] != null)
34
+ _i["return"]();
35
+ }
36
+ finally {
37
+ if (_d)
38
+ throw _e;
39
+ }
40
+ }
41
+ return _arr;
42
+ }
43
+ function _non_iterable_rest() {
44
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
+ }
46
+ function _sliced_to_array(arr, i) {
47
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
48
+ }
49
+ function _unsupported_iterable_to_array(o, minLen) {
50
+ if (!o)
51
+ return;
52
+ if (typeof o === "string")
53
+ return _array_like_to_array(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor)
56
+ n = o.constructor.name;
57
+ if (n === "Map" || n === "Set")
58
+ return Array.from(n);
59
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
60
+ return _array_like_to_array(o, minLen);
61
+ }
62
+ import { describe, expect, it } from "vitest";
63
+ import { AdvanceSearch } from "./AdvanceSearch.js";
64
+ describe("AdvanceSearch", function () {
65
+ it("should parse", function () {
66
+ for (var _i = 0, _iter = [
67
+ //
68
+ "-a",
69
+ "a",
70
+ "a b",
71
+ "a -b",
72
+ "a-b",
73
+ "a\"b",
74
+ "a&b",
75
+ "NOT a",
76
+ "NOT -a",
77
+ "HELLO -WORLD",
78
+ "(a)",
79
+ "( a OR B )",
80
+ "A OR B",
81
+ "a:[1,2]",
82
+ "a:*..1",
83
+ "a:ok a:=1 a:>1 a:<1 a:>=1 a:<=1 a:!=1 a:1..2 a:*..1 a:1..* a:[1,2] a:(1,2) a:[1,2) a:(1,2]",
84
+ "NOT (A B) AND (a:ok AND size:>1)",
85
+ "NOT -a",
86
+ "NOT (NOT -a)",
87
+ "owner:@me owner:=@me owner:!=@me",
88
+ "@AI:\"Where is my car\"",
89
+ "/**/ a",
90
+ "/* Hint */ a",
91
+ "/* a */ a /* b */"
92
+ ]; _i < _iter.length; _i++) {
93
+ var input = _iter[_i];
94
+ var out = AdvanceSearch.parse(input);
95
+ var formated = AdvanceSearch.format(out);
96
+ expect(formated, "reformat").toMatchSnapshot();
97
+ var optimized = AdvanceSearch.format(AdvanceSearch.optimize(out));
98
+ expect(optimized, "optimized").toMatchSnapshot();
99
+ expect(out, "parsed").toMatchSnapshot();
100
+ expect(AdvanceSearch.parse(formated), "reformat match original").toMatchObject(out);
101
+ }
102
+ });
103
+ it("should parse as expected", function () {
104
+ var cases = [
105
+ [
106
+ null,
107
+ []
108
+ ],
109
+ [
110
+ undefined,
111
+ []
112
+ ],
113
+ [
114
+ "",
115
+ []
116
+ ],
117
+ // fast path
118
+ [
119
+ "a",
120
+ [
121
+ {
122
+ type: "keyword",
123
+ value: "a"
124
+ }
125
+ ]
126
+ ],
127
+ [
128
+ "a-b",
129
+ [
130
+ {
131
+ type: "keyword",
132
+ value: "a-b"
133
+ }
134
+ ]
135
+ ],
136
+ [
137
+ "a\"b",
138
+ [
139
+ {
140
+ type: "keyword",
141
+ value: "a\"b"
142
+ }
143
+ ]
144
+ ],
145
+ [
146
+ "hello world",
147
+ [
148
+ {
149
+ type: "keyword",
150
+ value: "hello"
151
+ },
152
+ {
153
+ type: "keyword",
154
+ value: "world"
155
+ }
156
+ ]
157
+ ],
158
+ // advance
159
+ [
160
+ "-a",
161
+ [
162
+ {
163
+ type: "keyword",
164
+ value: "a",
165
+ negative: true
166
+ }
167
+ ]
168
+ ],
169
+ [
170
+ "/*Hi*/ hello -world",
171
+ [
172
+ {
173
+ type: "comment",
174
+ value: "Hi"
175
+ },
176
+ {
177
+ type: "keyword",
178
+ value: "hello",
179
+ negative: false
180
+ },
181
+ {
182
+ type: "keyword",
183
+ value: "world",
184
+ negative: true
185
+ }
186
+ ]
187
+ ],
188
+ [
189
+ "\"Hello\"",
190
+ [
191
+ {
192
+ type: "keyword",
193
+ value: "Hello",
194
+ exact: true
195
+ }
196
+ ]
197
+ ],
198
+ [
199
+ "-\"Hello\"",
200
+ [
201
+ {
202
+ type: "keyword",
203
+ value: "Hello",
204
+ exact: true,
205
+ negative: true
206
+ }
207
+ ]
208
+ ],
209
+ [
210
+ "is:ok",
211
+ [
212
+ {
213
+ type: "compare",
214
+ field: "is",
215
+ operator: "match",
216
+ value: {
217
+ value: "ok"
218
+ }
219
+ }
220
+ ]
221
+ ],
222
+ [
223
+ "-is:ok",
224
+ [
225
+ {
226
+ type: "compare",
227
+ field: "is",
228
+ negative: true,
229
+ operator: "match",
230
+ value: {
231
+ value: "ok"
232
+ }
233
+ }
234
+ ]
235
+ ]
236
+ ];
237
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
238
+ try {
239
+ for (var _iterator = cases[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
240
+ var _step_value = _sliced_to_array(_step.value, 2), input = _step_value[0], expected = _step_value[1];
241
+ var out = AdvanceSearch.parse(input);
242
+ expect(out).toMatchObject(expected);
243
+ expect(AdvanceSearch.parse(AdvanceSearch.format(out)), "reformat should match").toMatchObject(expected);
244
+ }
245
+ }
246
+ catch (err) {
247
+ _didIteratorError = true;
248
+ _iteratorError = err;
249
+ }
250
+ finally {
251
+ try {
252
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
253
+ _iterator.return();
254
+ }
255
+ }
256
+ finally {
257
+ if (_didIteratorError) {
258
+ throw _iteratorError;
259
+ }
260
+ }
261
+ }
262
+ });
263
+ it("should optimize simple", function () {
264
+ var cases = [
265
+ // rm empty comment
266
+ {
267
+ input: [
268
+ {
269
+ type: "comment",
270
+ value: ""
271
+ },
272
+ {
273
+ type: "keyword",
274
+ value: "a"
275
+ }
276
+ ],
277
+ expected: [
278
+ {
279
+ type: "keyword",
280
+ value: "a"
281
+ }
282
+ ]
283
+ },
284
+ // unwrap parentheses
285
+ {
286
+ input: [
287
+ {
288
+ type: "parentheses",
289
+ value: [
290
+ {
291
+ type: "keyword",
292
+ value: "a"
293
+ }
294
+ ]
295
+ },
296
+ {
297
+ type: "keyword",
298
+ value: "b"
299
+ }
300
+ ],
301
+ expected: [
302
+ {
303
+ type: "keyword",
304
+ value: "a"
305
+ },
306
+ {
307
+ type: "keyword",
308
+ value: "b"
309
+ }
310
+ ]
311
+ },
312
+ // not not
313
+ {
314
+ input: [
315
+ {
316
+ type: "not",
317
+ value: {
318
+ type: "not",
319
+ value: {
320
+ type: "keyword",
321
+ value: "a"
322
+ }
323
+ }
324
+ }
325
+ ],
326
+ expected: [
327
+ {
328
+ type: "keyword",
329
+ value: "a",
330
+ negative: false
331
+ }
332
+ ]
333
+ },
334
+ // not to negative
335
+ {
336
+ input: [
337
+ {
338
+ type: "not",
339
+ value: {
340
+ type: "keyword",
341
+ value: "a"
342
+ }
343
+ }
344
+ ],
345
+ expected: [
346
+ {
347
+ type: "keyword",
348
+ value: "a",
349
+ negative: true
350
+ }
351
+ ]
352
+ }
353
+ ];
354
+ for (var i = 0; i < cases.length; i++) {
355
+ var _cases_i = cases[i], input = _cases_i.input, expected = _cases_i.expected;
356
+ var out = AdvanceSearch.optimize(input);
357
+ expect(out, "case #".concat(i)).toEqual(expected);
358
+ }
359
+ });
360
+ it("should optimize by formated", function () {
361
+ var cases = [
362
+ [
363
+ "( a )",
364
+ "a"
365
+ ],
366
+ [
367
+ "NOT a",
368
+ "-a"
369
+ ],
370
+ [
371
+ "NOT -a",
372
+ "a"
373
+ ],
374
+ [
375
+ "NOT is:ok",
376
+ "-is:ok"
377
+ ],
378
+ [
379
+ "NOT -is:ok",
380
+ "is:ok"
381
+ ],
382
+ [
383
+ "NOT -is:=ok",
384
+ "is:=ok"
385
+ ],
386
+ [
387
+ "NOT is:=ok",
388
+ "is:!=ok"
389
+ ],
390
+ [
391
+ "NOT (NOT -a)",
392
+ "-a"
393
+ ]
394
+ ];
395
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
396
+ try {
397
+ for (var _iterator = cases[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
398
+ var _step_value = _sliced_to_array(_step.value, 2), input = _step_value[0], expected = _step_value[1];
399
+ var out = AdvanceSearch.optimize(AdvanceSearch.parse(input));
400
+ expect(AdvanceSearch.format(out), "".concat(input, " -> ").concat(expected, ": ").concat(JSON.stringify(out))).toEqual(expected);
401
+ }
402
+ }
403
+ catch (err) {
404
+ _didIteratorError = true;
405
+ _iteratorError = err;
406
+ }
407
+ finally {
408
+ try {
409
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
410
+ _iterator.return();
411
+ }
412
+ }
413
+ finally {
414
+ if (_didIteratorError) {
415
+ throw _iteratorError;
416
+ }
417
+ }
418
+ }
419
+ });
420
+ it.fails("should parse parentheses", function () {
421
+ var out = AdvanceSearch.parse("(a)");
422
+ console.log(out);
423
+ expect(out).toEqual([
424
+ {
425
+ type: "parentheses",
426
+ value: [
427
+ {
428
+ type: "keyword",
429
+ value: "a"
430
+ }
431
+ ]
432
+ }
433
+ ]);
434
+ });
435
+ });
@@ -1,6 +1,6 @@
1
- import { match } from "ts-pattern";
1
+ import { match } from 'ts-pattern';
2
2
  export function formatAdvanceSearch(input) {
3
- const OP = {
3
+ var OP = {
4
4
  match: ':',
5
5
  eq: ':=',
6
6
  ne: ':!=',
@@ -10,55 +10,69 @@ export function formatAdvanceSearch(input) {
10
10
  lte: ':<=',
11
11
  range: ':'
12
12
  };
13
- const _exprs = (s)=>{
13
+ var _exprs = function(s) {
14
14
  return s.map(_expr).join(' ');
15
15
  };
16
- const _expr = (s)=>{
16
+ var _expr = function(s) {
17
17
  return match(s).with({
18
18
  type: 'keyword'
19
- }, ({ value, exact, negative })=>{
20
- return `${negative ? '-' : ''}${exact ? `"${value}"` : value}`;
19
+ }, function(param) {
20
+ var value = param.value, exact = param.exact, negative = param.negative;
21
+ return "".concat(negative ? '-' : '').concat(exact ? '"'.concat(value, '"') : value);
21
22
  }).with({
22
23
  type: 'logical'
23
- }, ({ operator, value })=>value.map(_expr).join(` ${operator.toLocaleUpperCase()} `)).with({
24
+ }, function(param) {
25
+ var operator = param.operator, value = param.value;
26
+ return value.map(_expr).join(" ".concat(operator.toLocaleUpperCase(), " "));
27
+ }).with({
24
28
  type: 'not'
25
- }, ({ value })=>`NOT ${_expr(value)}`).with({
29
+ }, function(param) {
30
+ var value = param.value;
31
+ return "NOT ".concat(_expr(value));
32
+ }).with({
26
33
  type: 'compare'
27
- }, ({ field, operator, value, negative, mention })=>{
28
- return `${negative ? '-' : ''}${mention ? '@' : ''}${field}${OP[operator]}${_value(value)}`;
34
+ }, function(param) {
35
+ var field = param.field, operator = param.operator, value = param.value, negative = param.negative, mention = param.mention;
36
+ return "".concat(negative ? '-' : '').concat(mention ? '@' : '').concat(field).concat(OP[operator]).concat(_value(value));
29
37
  }).with({
30
38
  type: 'comment'
31
- }, ({ value })=>`/* ${value} */`).with({
39
+ }, function(param) {
40
+ var value = param.value;
41
+ return "/* ".concat(value, " */");
42
+ }).with({
32
43
  type: 'parentheses'
33
- }, ({ value })=>`(${_exprs(value)})`).exhaustive();
44
+ }, function(param) {
45
+ var value = param.value;
46
+ return "(".concat(_exprs(value), ")");
47
+ }).exhaustive();
34
48
  };
35
- const _literal = (s)=>{
49
+ var _literal = function(s) {
36
50
  if (typeof s === 'string') {
37
- return s.includes(' ') ? `"${s}"` : s;
51
+ return s.includes(' ') ? '"'.concat(s, '"') : s;
38
52
  }
39
53
  return JSON.stringify(s);
40
54
  };
41
- const _value = (v)=>{
55
+ var _value = function(v) {
42
56
  return match(v).with({
43
57
  type: 'range'
44
- }, ({ minimum, maximum, minimumExclusive, maximumExclusive })=>{
58
+ }, function(param) {
59
+ var minimum = param.minimum, maximum = param.maximum, minimumExclusive = param.minimumExclusive, maximumExclusive = param.maximumExclusive;
45
60
  if (minimumExclusive === undefined && maximumExclusive === undefined) {
46
- let min = minimum === undefined ? '*' : _value(minimum);
47
- let max = maximum === undefined ? '*' : _value(maximum);
48
- return `${min}..${max}`;
61
+ var min = minimum === undefined ? '*' : _value(minimum);
62
+ var max = maximum === undefined ? '*' : _value(maximum);
63
+ return "".concat(min, "..").concat(max);
49
64
  }
50
- let min = minimum === undefined ? '' : _value(minimum);
51
- let max = maximum === undefined ? '' : _value(maximum);
52
- return `${minimumExclusive ? '(' : '['}${min},${max}${maximumExclusive ? ')' : ']'}`;
65
+ var min1 = minimum === undefined ? '' : _value(minimum);
66
+ var max1 = maximum === undefined ? '' : _value(maximum);
67
+ return "".concat(minimumExclusive ? '(' : '[').concat(min1, ",").concat(max1).concat(maximumExclusive ? ')' : ']');
53
68
  }).with({
54
69
  format: 'mention'
55
- }, ({ value })=>{
56
- return `@${value}`;
57
- }).otherwise((value)=>{
70
+ }, function(param) {
71
+ var value = param.value;
72
+ return "@".concat(value);
73
+ }).otherwise(function(value) {
58
74
  return _literal(value.value);
59
75
  });
60
76
  };
61
77
  return _exprs(input);
62
78
  }
63
-
64
- //# sourceMappingURL=formatAdvanceSearch.js.map
@@ -1,2 +1 @@
1
1
  export { AdvanceSearch } from "./AdvanceSearch.js";
2
- //# sourceMappingURL=index.js.map