@tachybase/utils 0.23.8

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 (116) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/LICENSE +201 -0
  3. package/lib/assign.d.ts +9 -0
  4. package/lib/assign.js +136 -0
  5. package/lib/client.d.ts +21 -0
  6. package/lib/client.js +77 -0
  7. package/lib/cluster.d.ts +2 -0
  8. package/lib/cluster.js +39 -0
  9. package/lib/collections-graph.d.ts +16 -0
  10. package/lib/collections-graph.js +98 -0
  11. package/lib/common.d.ts +7 -0
  12. package/lib/common.js +98 -0
  13. package/lib/currencyUtils.d.ts +44 -0
  14. package/lib/currencyUtils.js +75 -0
  15. package/lib/date.d.ts +22 -0
  16. package/lib/date.js +186 -0
  17. package/lib/dayjs.d.ts +10 -0
  18. package/lib/dayjs.js +73 -0
  19. package/lib/decorators.d.ts +16 -0
  20. package/lib/decorators.js +94 -0
  21. package/lib/dom.d.ts +4 -0
  22. package/lib/dom.js +52 -0
  23. package/lib/forEach.d.ts +1 -0
  24. package/lib/forEach.js +36 -0
  25. package/lib/fs-exists.d.ts +1 -0
  26. package/lib/fs-exists.js +37 -0
  27. package/lib/getCurrentStacks.d.ts +1 -0
  28. package/lib/getCurrentStacks.js +35 -0
  29. package/lib/getValuesByPath.d.ts +1 -0
  30. package/lib/getValuesByPath.js +62 -0
  31. package/lib/index.d.ts +31 -0
  32. package/lib/index.js +97 -0
  33. package/lib/isPortalInBody.d.ts +5 -0
  34. package/lib/isPortalInBody.js +45 -0
  35. package/lib/json-templates.d.ts +1 -0
  36. package/lib/json-templates.js +145 -0
  37. package/lib/koa-multer.d.ts +6 -0
  38. package/lib/koa-multer.js +83 -0
  39. package/lib/log.d.ts +1 -0
  40. package/lib/log.js +30 -0
  41. package/lib/measure-execution-time.d.ts +1 -0
  42. package/lib/measure-execution-time.js +35 -0
  43. package/lib/merge.d.ts +1 -0
  44. package/lib/merge.js +46 -0
  45. package/lib/mixin/AsyncEmitter.d.ts +3 -0
  46. package/lib/mixin/AsyncEmitter.js +73 -0
  47. package/lib/mixin/index.d.ts +1 -0
  48. package/lib/mixin/index.js +39 -0
  49. package/lib/notification.d.ts +1 -0
  50. package/lib/notification.js +34 -0
  51. package/lib/number.d.ts +1 -0
  52. package/lib/number.js +36 -0
  53. package/lib/parse-date.d.ts +3 -0
  54. package/lib/parse-date.js +237 -0
  55. package/lib/parse-filter.d.ts +146 -0
  56. package/lib/parse-filter.js +305 -0
  57. package/lib/parseHTML.d.ts +7 -0
  58. package/lib/parseHTML.js +33 -0
  59. package/lib/perf-hooks.d.ts +6 -0
  60. package/lib/perf-hooks.js +60 -0
  61. package/lib/plugin-symlink.d.ts +4 -0
  62. package/lib/plugin-symlink.js +131 -0
  63. package/lib/registry.d.ts +14 -0
  64. package/lib/registry.js +60 -0
  65. package/lib/requireModule.d.ts +3 -0
  66. package/lib/requireModule.js +64 -0
  67. package/lib/toposort.d.ts +13 -0
  68. package/lib/toposort.js +90 -0
  69. package/lib/typedi/container-instance.class.d.ts +109 -0
  70. package/lib/typedi/container-instance.class.js +349 -0
  71. package/lib/typedi/container-registry.class.d.ts +51 -0
  72. package/lib/typedi/container-registry.class.js +97 -0
  73. package/lib/typedi/decorators/inject-many.decorator.d.ts +8 -0
  74. package/lib/typedi/decorators/inject-many.decorator.js +56 -0
  75. package/lib/typedi/decorators/inject.decorator.d.ts +9 -0
  76. package/lib/typedi/decorators/inject.decorator.js +56 -0
  77. package/lib/typedi/decorators/service.decorator.d.ts +6 -0
  78. package/lib/typedi/decorators/service.decorator.js +49 -0
  79. package/lib/typedi/empty.const.d.ts +6 -0
  80. package/lib/typedi/empty.const.js +27 -0
  81. package/lib/typedi/error/cannot-inject-value.error.d.ts +11 -0
  82. package/lib/typedi/error/cannot-inject-value.error.js +40 -0
  83. package/lib/typedi/error/cannot-instantiate-value.error.d.ts +11 -0
  84. package/lib/typedi/error/cannot-instantiate-value.error.js +49 -0
  85. package/lib/typedi/error/service-not-found.error.d.ts +11 -0
  86. package/lib/typedi/error/service-not-found.error.js +49 -0
  87. package/lib/typedi/index.d.ts +17 -0
  88. package/lib/typedi/index.js +64 -0
  89. package/lib/typedi/interfaces/container-options.interface.d.ts +45 -0
  90. package/lib/typedi/interfaces/container-options.interface.js +15 -0
  91. package/lib/typedi/interfaces/handler.interface.d.ts +27 -0
  92. package/lib/typedi/interfaces/handler.interface.js +15 -0
  93. package/lib/typedi/interfaces/service-metadata.interface.d.ts +53 -0
  94. package/lib/typedi/interfaces/service-metadata.interface.js +15 -0
  95. package/lib/typedi/interfaces/service-options.interface.d.ts +6 -0
  96. package/lib/typedi/interfaces/service-options.interface.js +15 -0
  97. package/lib/typedi/token.class.d.ts +11 -0
  98. package/lib/typedi/token.class.js +37 -0
  99. package/lib/typedi/types/abstract-constructable.type.d.ts +9 -0
  100. package/lib/typedi/types/abstract-constructable.type.js +15 -0
  101. package/lib/typedi/types/constructable.type.d.ts +10 -0
  102. package/lib/typedi/types/constructable.type.js +15 -0
  103. package/lib/typedi/types/container-identifier.type.d.ts +4 -0
  104. package/lib/typedi/types/container-identifier.type.js +15 -0
  105. package/lib/typedi/types/container-scope.type.d.ts +1 -0
  106. package/lib/typedi/types/container-scope.type.js +15 -0
  107. package/lib/typedi/types/service-identifier.type.d.ts +8 -0
  108. package/lib/typedi/types/service-identifier.type.js +15 -0
  109. package/lib/typedi/utils/resolve-to-type-wrapper.util.d.ts +15 -0
  110. package/lib/typedi/utils/resolve-to-type-wrapper.util.js +39 -0
  111. package/lib/uid.d.ts +1 -0
  112. package/lib/uid.js +35 -0
  113. package/lib/url.d.ts +1 -0
  114. package/lib/url.js +37 -0
  115. package/package.json +49 -0
  116. package/tsconfig.json +31 -0
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var measure_execution_time_exports = {};
20
+ __export(measure_execution_time_exports, {
21
+ measureExecutionTime: () => measureExecutionTime
22
+ });
23
+ module.exports = __toCommonJS(measure_execution_time_exports);
24
+ async function measureExecutionTime(operation, operationName) {
25
+ const startTime = Date.now();
26
+ await operation();
27
+ const endTime = Date.now();
28
+ const duration = (endTime - startTime).toFixed(0);
29
+ console.log(`${operationName} completed in ${duration} milliseconds`);
30
+ }
31
+ __name(measureExecutionTime, "measureExecutionTime");
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ measureExecutionTime
35
+ });
package/lib/merge.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function merge(obj1: any, obj2: any, opts?: any): unknown;
package/lib/merge.js ADDED
@@ -0,0 +1,46 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var merge_exports = {};
30
+ __export(merge_exports, {
31
+ merge: () => merge
32
+ });
33
+ module.exports = __toCommonJS(merge_exports);
34
+ var import_deepmerge = __toESM(require("deepmerge"));
35
+ const overwriteMerge = /* @__PURE__ */ __name((destinationArray, sourceArray, options) => sourceArray, "overwriteMerge");
36
+ function merge(obj1, obj2, opts) {
37
+ return (0, import_deepmerge.default)(obj1, obj2, {
38
+ arrayMerge: overwriteMerge,
39
+ ...opts
40
+ });
41
+ }
42
+ __name(merge, "merge");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ merge
46
+ });
@@ -0,0 +1,3 @@
1
+ export declare class AsyncEmitter {
2
+ emitAsync(event: string | symbol, ...args: any[]): Promise<boolean>;
3
+ }
@@ -0,0 +1,73 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var AsyncEmitter_exports = {};
20
+ __export(AsyncEmitter_exports, {
21
+ AsyncEmitter: () => AsyncEmitter
22
+ });
23
+ module.exports = __toCommonJS(AsyncEmitter_exports);
24
+ const _AsyncEmitter = class _AsyncEmitter {
25
+ async emitAsync(event, ...args) {
26
+ const events = this._events;
27
+ let callbacks = events[event];
28
+ if (!callbacks) {
29
+ return false;
30
+ }
31
+ const run = /* @__PURE__ */ __name((cb) => {
32
+ switch (args.length) {
33
+ // fast cases
34
+ case 0:
35
+ cb = cb.call(this);
36
+ break;
37
+ case 1:
38
+ cb = cb.call(this, args[0]);
39
+ break;
40
+ case 2:
41
+ cb = cb.call(this, args[0], args[1]);
42
+ break;
43
+ case 3:
44
+ cb = cb.call(this, args[0], args[1], args[2]);
45
+ break;
46
+ // slower
47
+ default:
48
+ cb = cb.apply(this, args);
49
+ }
50
+ if (cb && (cb instanceof Promise || typeof cb.then === "function")) {
51
+ return cb;
52
+ }
53
+ return Promise.resolve(true);
54
+ }, "run");
55
+ if (typeof callbacks === "function") {
56
+ await run(callbacks);
57
+ } else if (typeof callbacks === "object") {
58
+ callbacks = callbacks.slice().filter(Boolean);
59
+ await callbacks.reduce((prev, next) => {
60
+ return prev.then((res) => {
61
+ return run(next).then((result) => Promise.resolve(res.concat(result)));
62
+ });
63
+ }, Promise.resolve([]));
64
+ }
65
+ return true;
66
+ }
67
+ };
68
+ __name(_AsyncEmitter, "AsyncEmitter");
69
+ let AsyncEmitter = _AsyncEmitter;
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ AsyncEmitter
73
+ });
@@ -0,0 +1 @@
1
+ export declare function applyMixins(derivedCtor: any, constructors: any[]): void;
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var mixin_exports = {};
20
+ __export(mixin_exports, {
21
+ applyMixins: () => applyMixins
22
+ });
23
+ module.exports = __toCommonJS(mixin_exports);
24
+ function applyMixins(derivedCtor, constructors) {
25
+ constructors.forEach((baseCtor) => {
26
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
27
+ Object.defineProperty(
28
+ derivedCtor.prototype,
29
+ name,
30
+ Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || /* @__PURE__ */ Object.create(null)
31
+ );
32
+ });
33
+ });
34
+ }
35
+ __name(applyMixins, "applyMixins");
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ applyMixins
39
+ });
@@ -0,0 +1 @@
1
+ export declare const showToast: (message: any, type?: string, duration?: number) => void;
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var notification_exports = {};
20
+ __export(notification_exports, {
21
+ showToast: () => showToast
22
+ });
23
+ module.exports = __toCommonJS(notification_exports);
24
+ var import_antd = require("antd");
25
+ const showToast = /* @__PURE__ */ __name((message, type = "info", duration = 5e3) => {
26
+ import_antd.notification[type]({
27
+ message,
28
+ duration
29
+ });
30
+ }, "showToast");
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ showToast
34
+ });
@@ -0,0 +1 @@
1
+ export declare function toFixedByStep(value: any, step: string | number): any;
package/lib/number.js ADDED
@@ -0,0 +1,36 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var number_exports = {};
20
+ __export(number_exports, {
21
+ toFixedByStep: () => toFixedByStep
22
+ });
23
+ module.exports = __toCommonJS(number_exports);
24
+ var import_mini_decimal = require("@rc-component/mini-decimal");
25
+ function toFixedByStep(value, step) {
26
+ if (typeof value === "undefined" || value === null || value === "") {
27
+ return "";
28
+ }
29
+ const precision = (0, import_mini_decimal.getNumberPrecision)(step);
30
+ return (0, import_mini_decimal.toFixed)(String(value), ".", precision);
31
+ }
32
+ __name(toFixedByStep, "toFixedByStep");
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ toFixedByStep
36
+ });
@@ -0,0 +1,3 @@
1
+ export declare function parseDate(value: any, options?: {
2
+ timezone?: string;
3
+ }): string | any[];
@@ -0,0 +1,237 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var parse_date_exports = {};
20
+ __export(parse_date_exports, {
21
+ parseDate: () => parseDate
22
+ });
23
+ module.exports = __toCommonJS(parse_date_exports);
24
+ var import_date = require("./date");
25
+ var import_dayjs = require("./dayjs");
26
+ function parseUTC(value) {
27
+ if (value instanceof Date || import_dayjs.dayjs.isDayjs(value)) {
28
+ return {
29
+ unit: "utc",
30
+ start: value.toISOString()
31
+ };
32
+ }
33
+ if (value.endsWith("Z")) {
34
+ return {
35
+ unit: "utc",
36
+ start: value
37
+ };
38
+ }
39
+ }
40
+ __name(parseUTC, "parseUTC");
41
+ function parseYear(value) {
42
+ if (/^\d\d\d\d$/.test(value)) {
43
+ return {
44
+ unit: "year",
45
+ start: `${value}-01-01 00:00:00`
46
+ };
47
+ }
48
+ }
49
+ __name(parseYear, "parseYear");
50
+ function parseQuarter(value) {
51
+ if (/^\d\d\d\dQ\d$/.test(value)) {
52
+ const [year, q] = value.split("Q");
53
+ return {
54
+ unit: "quarter",
55
+ start: (0, import_dayjs.dayjs)(year, "YYYY").quarter(q).format("YYYY-MM-DD HH:mm:ss")
56
+ };
57
+ }
58
+ }
59
+ __name(parseQuarter, "parseQuarter");
60
+ function parseWeek(value) {
61
+ if (/^\d\d\d\d[W]\d\d$/.test(value)) {
62
+ const arr = value.split("W");
63
+ return {
64
+ unit: "isoWeek",
65
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").add(Number(arr[1]), "weeks").format("YYYY-MM-DD HH:mm:ss")
66
+ };
67
+ }
68
+ if (/^\d\d\d\d[w]\d\d$/.test(value)) {
69
+ const arr = value.split("w");
70
+ return {
71
+ unit: "week",
72
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").week(Number(arr[1])).format("YYYY-MM-DD HH:mm:ss")
73
+ };
74
+ }
75
+ }
76
+ __name(parseWeek, "parseWeek");
77
+ function parseMonth(value) {
78
+ if (/^\d\d\d\d\-\d\d$/.test(value)) {
79
+ return {
80
+ unit: "month",
81
+ start: `${value}-01 00:00:00`
82
+ };
83
+ }
84
+ }
85
+ __name(parseMonth, "parseMonth");
86
+ function parseDay(value) {
87
+ if (/^\d\d\d\d\-\d\d\-\d\d$/.test(value)) {
88
+ return {
89
+ unit: "day",
90
+ start: `${value} 00:00:00`
91
+ };
92
+ }
93
+ }
94
+ __name(parseDay, "parseDay");
95
+ function parseHour(value) {
96
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d$/.test(value)) {
97
+ return {
98
+ unit: "hour",
99
+ start: `${value}:00:00`
100
+ };
101
+ }
102
+ }
103
+ __name(parseHour, "parseHour");
104
+ function parseMinute(value) {
105
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d$/.test(value)) {
106
+ return {
107
+ unit: "minute",
108
+ start: `${value}:00`
109
+ };
110
+ }
111
+ }
112
+ __name(parseMinute, "parseMinute");
113
+ function parseSecond(value) {
114
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d\:\d\d$/.test(value)) {
115
+ return {
116
+ unit: "second",
117
+ start: `${value}`
118
+ };
119
+ }
120
+ }
121
+ __name(parseSecond, "parseSecond");
122
+ function parseMillisecond(value) {
123
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d\:\d\d\.\d\d\d$/.test(value)) {
124
+ return {
125
+ unit: "millisecond",
126
+ start: `${value}`
127
+ };
128
+ }
129
+ }
130
+ __name(parseMillisecond, "parseMillisecond");
131
+ const parsers = [
132
+ parseUTC,
133
+ parseYear,
134
+ parseQuarter,
135
+ parseWeek,
136
+ parseMonth,
137
+ parseDay,
138
+ parseHour,
139
+ parseMinute,
140
+ parseSecond,
141
+ parseMillisecond
142
+ ];
143
+ function toISOString(m) {
144
+ return m.toISOString();
145
+ }
146
+ __name(toISOString, "toISOString");
147
+ function dateRange(r) {
148
+ if (!r.timezone) {
149
+ r.timezone = "+00:00";
150
+ }
151
+ let m;
152
+ if (r.unit === "utc") {
153
+ return (0, import_dayjs.dayjs)(r == null ? void 0 : r.start).toISOString();
154
+ } else {
155
+ m = (0, import_dayjs.dayjs)(`${r == null ? void 0 : r.start}${r == null ? void 0 : r.timezone}`);
156
+ }
157
+ m = m.utcOffset((0, import_date.offsetFromString)(r.timezone));
158
+ return [m = m.startOf(r.unit), m.add(1, r.unit === "isoWeek" ? "weeks" : r.unit).startOf(r.unit)].map(toISOString);
159
+ }
160
+ __name(dateRange, "dateRange");
161
+ function parseDate(value, options = {}) {
162
+ if (!value) {
163
+ return;
164
+ }
165
+ if (Array.isArray(value)) {
166
+ return parseDateBetween(value, options);
167
+ }
168
+ let timezone = options.timezone || "+00:00";
169
+ const input = value;
170
+ if (typeof value === "string") {
171
+ const match = /(.+)((\+|\-)\d\d\:\d\d)$/.exec(value);
172
+ if (match) {
173
+ value = match[1];
174
+ timezone = match[2];
175
+ }
176
+ if (/^(\(|\[)/.test(value)) {
177
+ return parseDateBetween(input, options);
178
+ }
179
+ }
180
+ for (const parse of parsers) {
181
+ const r = parse(value);
182
+ if (r) {
183
+ r["input"] = input;
184
+ if (!r["timezone"]) {
185
+ r["timezone"] = timezone;
186
+ }
187
+ return dateRange(r);
188
+ }
189
+ }
190
+ }
191
+ __name(parseDate, "parseDate");
192
+ function parseDateBetween(value, options = {}) {
193
+ if (Array.isArray(value) && value.length > 1) {
194
+ const [startValue, endValue, op = "[]", timezone2] = value;
195
+ const r0 = parseDate(startValue, { timezone: timezone2 });
196
+ const r1 = parseDate(endValue, { timezone: timezone2 });
197
+ let start;
198
+ let startOp;
199
+ let end;
200
+ let endOp;
201
+ if (typeof r0 === "string") {
202
+ start = r0;
203
+ startOp = op[0];
204
+ } else {
205
+ start = op.startsWith("(") ? r0[1] : r0[0];
206
+ startOp = "[";
207
+ }
208
+ if (typeof r1 === "string") {
209
+ end = r1;
210
+ endOp = op[1];
211
+ } else {
212
+ end = op.endsWith(")") ? r1[0] : r1[1];
213
+ endOp = ")";
214
+ }
215
+ const newOp = startOp + endOp;
216
+ return newOp === "[)" ? [start, end] : [start, end, newOp];
217
+ }
218
+ if (typeof value !== "string") {
219
+ return;
220
+ }
221
+ const match = /(.+)((\+|\-)\d\d\:\d\d)$/.exec(value);
222
+ let timezone = options.timezone || "+00:00";
223
+ if (match) {
224
+ value = match[1];
225
+ timezone = match[2];
226
+ }
227
+ const m = /^(\(|\[)(.+)\,(.+)(\)|\])$/.exec(value);
228
+ if (!m) {
229
+ return;
230
+ }
231
+ return parseDateBetween([m[2], m[3], `${m[1]}${m[4]}`, timezone]);
232
+ }
233
+ __name(parseDateBetween, "parseDateBetween");
234
+ // Annotate the CommonJS export names for ESM import in node:
235
+ 0 && (module.exports = {
236
+ parseDate
237
+ });
@@ -0,0 +1,146 @@
1
+ export declare function flatten(target: any, opts?: any): {};
2
+ export declare function unflatten(obj: any, opts?: any): {};
3
+ export type ParseFilterOptions = {
4
+ vars?: Record<string, any>;
5
+ now?: any;
6
+ timezone?: string;
7
+ getField?: any;
8
+ };
9
+ export declare const parseFilter: (filter: any, opts?: ParseFilterOptions) => Promise<{}>;
10
+ export type GetDayRangeOptions = {
11
+ now?: any;
12
+ timezone?: string | number;
13
+ offset: number;
14
+ };
15
+ export declare function getDayRange(options: GetDayRangeOptions): (string | number)[];
16
+ export type Utc2unitOptions = {
17
+ now?: any;
18
+ unit: any;
19
+ timezone?: string | number;
20
+ offset?: number;
21
+ };
22
+ export declare function utc2unit(options: Utc2unitOptions): any;
23
+ export declare function getDateVars(): {
24
+ now: string;
25
+ today: ({ now, timezone, field }: {
26
+ now: any;
27
+ timezone: any;
28
+ field: any;
29
+ }) => any;
30
+ yesterday: ({ now, timezone, field }: {
31
+ now: any;
32
+ timezone: any;
33
+ field: any;
34
+ }) => any;
35
+ tomorrow: ({ now, timezone, field }: {
36
+ now: any;
37
+ timezone: any;
38
+ field: any;
39
+ }) => any;
40
+ thisWeek: ({ now, timezone, field }: {
41
+ now: any;
42
+ timezone: any;
43
+ field: any;
44
+ }) => any;
45
+ lastWeek: ({ now, timezone, field }: {
46
+ now: any;
47
+ timezone: any;
48
+ field: any;
49
+ }) => any;
50
+ nextWeek: ({ now, timezone, field }: {
51
+ now: any;
52
+ timezone: any;
53
+ field: any;
54
+ }) => any;
55
+ thisIsoWeek: ({ now, timezone, field }: {
56
+ now: any;
57
+ timezone: any;
58
+ field: any;
59
+ }) => any;
60
+ lastIsoWeek: ({ now, timezone, field }: {
61
+ now: any;
62
+ timezone: any;
63
+ field: any;
64
+ }) => any;
65
+ nextIsoWeek: ({ now, timezone, field }: {
66
+ now: any;
67
+ timezone: any;
68
+ field: any;
69
+ }) => any;
70
+ thisMonth: ({ now, timezone, field }: {
71
+ now: any;
72
+ timezone: any;
73
+ field: any;
74
+ }) => any;
75
+ lastMonth: ({ now, timezone, field }: {
76
+ now: any;
77
+ timezone: any;
78
+ field: any;
79
+ }) => any;
80
+ nextMonth: ({ now, timezone, field }: {
81
+ now: any;
82
+ timezone: any;
83
+ field: any;
84
+ }) => any;
85
+ thisQuarter: ({ now, timezone, field }: {
86
+ now: any;
87
+ timezone: any;
88
+ field: any;
89
+ }) => any;
90
+ lastQuarter: ({ now, timezone, field }: {
91
+ now: any;
92
+ timezone: any;
93
+ field: any;
94
+ }) => any;
95
+ nextQuarter: ({ now, timezone, field }: {
96
+ now: any;
97
+ timezone: any;
98
+ field: any;
99
+ }) => any;
100
+ thisYear: ({ now, timezone, field }: {
101
+ now: any;
102
+ timezone: any;
103
+ field: any;
104
+ }) => any;
105
+ lastYear: ({ now, timezone, field }: {
106
+ now: any;
107
+ timezone: any;
108
+ field: any;
109
+ }) => any;
110
+ nextYear: ({ now, timezone, field }: {
111
+ now: any;
112
+ timezone: any;
113
+ field: any;
114
+ }) => any;
115
+ last7Days: ({ now, timezone, field }: {
116
+ now: any;
117
+ timezone: any;
118
+ field: any;
119
+ }) => (string | number)[];
120
+ next7Days: ({ now, timezone, field }: {
121
+ now: any;
122
+ timezone: any;
123
+ field: any;
124
+ }) => (string | number)[];
125
+ last30Days: ({ now, timezone, field }: {
126
+ now: any;
127
+ timezone: any;
128
+ field: any;
129
+ }) => (string | number)[];
130
+ next30Days: ({ now, timezone, field }: {
131
+ now: any;
132
+ timezone: any;
133
+ field: any;
134
+ }) => (string | number)[];
135
+ last90Days: ({ now, timezone, field }: {
136
+ now: any;
137
+ timezone: any;
138
+ field: any;
139
+ }) => (string | number)[];
140
+ next90Days: ({ now, timezone, field }: {
141
+ now: any;
142
+ timezone: any;
143
+ field: any;
144
+ }) => (string | number)[];
145
+ };
146
+ export declare function splitPathToTwoParts(path: string): string[];