@nocobase/plugin-field-sort 1.5.0-alpha.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 (142) hide show
  1. package/LICENSE.txt +159 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +15 -0
  6. package/dist/client/index.js +10 -0
  7. package/dist/client/locale.d.ts +10 -0
  8. package/dist/client/sort-interface.d.ts +131 -0
  9. package/dist/externalVersion.js +18 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +48 -0
  12. package/dist/locale/en-US.json +1 -0
  13. package/dist/locale/zh-CN.json +1 -0
  14. package/dist/node_modules/@nocobase/lock-manager/LICENSE +661 -0
  15. package/dist/node_modules/@nocobase/lock-manager/lib/index.d.ts +10 -0
  16. package/dist/node_modules/@nocobase/lock-manager/lib/index.js +1 -0
  17. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.d.ts +46 -0
  18. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.js +171 -0
  19. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/client.js +12 -0
  20. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.d.ts +17 -0
  21. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.js +143 -0
  22. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.d.ts +30 -0
  23. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.js +88 -0
  24. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.d.ts +24 -0
  25. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.js +107 -0
  26. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.d.ts +14 -0
  27. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.js +87 -0
  28. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.d.ts +38 -0
  29. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.js +214 -0
  30. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.d.ts +10 -0
  31. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.js +72 -0
  32. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.d.ts +9 -0
  33. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.js +45 -0
  34. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.d.ts +9 -0
  35. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.js +46 -0
  36. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.d.ts +9 -0
  37. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.js +71 -0
  38. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.d.ts +10 -0
  39. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.js +73 -0
  40. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.d.ts +10 -0
  41. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.js +43 -0
  42. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.d.ts +38 -0
  43. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.js +105 -0
  44. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.d.ts +13 -0
  45. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.js +54 -0
  46. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.d.ts +9 -0
  47. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.js +63 -0
  48. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.d.ts +9 -0
  49. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.js +141 -0
  50. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.d.ts +15 -0
  51. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.js +92 -0
  52. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.d.ts +9 -0
  53. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.js +39 -0
  54. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.d.ts +9 -0
  55. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.js +44 -0
  56. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.d.ts +9 -0
  57. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.js +55 -0
  58. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.d.ts +11 -0
  59. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.js +80 -0
  60. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.d.ts +9 -0
  61. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.js +48 -0
  62. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.d.ts +9 -0
  63. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.js +43 -0
  64. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.d.ts +9 -0
  65. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.js +45 -0
  66. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.d.ts +15 -0
  67. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.js +262 -0
  68. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.d.ts +67 -0
  69. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.js +320 -0
  70. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.d.ts +15 -0
  71. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.js +42 -0
  72. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.d.ts +14 -0
  73. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.js +69 -0
  74. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.d.ts +22 -0
  75. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.js +69 -0
  76. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.d.ts +12 -0
  77. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.js +90 -0
  78. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.d.ts +19 -0
  79. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.js +50 -0
  80. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.d.ts +18 -0
  81. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.js +83 -0
  82. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.d.ts +9 -0
  83. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.js +44 -0
  84. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.d.ts +14 -0
  85. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.js +46 -0
  86. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.d.ts +1 -0
  87. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.js +63 -0
  88. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/package.json +20 -0
  89. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.d.ts +6 -0
  90. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.js +102 -0
  91. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.d.ts +2 -0
  92. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.js +12 -0
  93. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.eslintrc.js +5 -0
  94. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/ci.yml +24 -0
  95. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/lint.yml +23 -0
  96. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-big.js +149 -0
  97. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-small.js +143 -0
  98. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-big.js +154 -0
  99. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-small.js +148 -0
  100. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-100pairs-small.js +101 -0
  101. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-900pairs-small-alt.js +84 -0
  102. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/index.js +57 -0
  103. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/multipart.js +653 -0
  104. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/urlencoded.js +350 -0
  105. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/utils.js +596 -0
  106. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/package.json +22 -0
  107. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/common.js +109 -0
  108. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-charsets.js +94 -0
  109. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-stream-pause.js +102 -0
  110. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart.js +1053 -0
  111. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-urlencoded.js +488 -0
  112. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test.js +20 -0
  113. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/index.js +104 -0
  114. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/counter.js +28 -0
  115. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/file-appender.js +67 -0
  116. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/make-middleware.js +173 -0
  117. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/multer-error.js +24 -0
  118. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/remove-uploaded-files.js +28 -0
  119. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/package.json +52 -0
  120. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/disk.js +66 -0
  121. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/memory.js +21 -0
  122. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.eslintrc.js +5 -0
  123. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/ci.yml +24 -0
  124. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/lint.yml +23 -0
  125. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/lib/sbmh.js +267 -0
  126. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/package.json +34 -0
  127. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/test/test.js +70 -0
  128. package/dist/node_modules/@nocobase/lock-manager/package.json +1 -0
  129. package/dist/node_modules/@nocobase/lock-manager/src/__tests__/lock-manager.test.ts +169 -0
  130. package/dist/node_modules/@nocobase/lock-manager/src/index.ts +11 -0
  131. package/dist/node_modules/@nocobase/lock-manager/src/lock-manager.ts +169 -0
  132. package/dist/server/action.d.ts +26 -0
  133. package/dist/server/action.js +168 -0
  134. package/dist/server/index.d.ts +10 -0
  135. package/dist/server/index.js +48 -0
  136. package/dist/server/plugin.d.ts +19 -0
  137. package/dist/server/plugin.js +69 -0
  138. package/dist/server/sort-field.d.ts +24 -0
  139. package/dist/server/sort-field.js +197 -0
  140. package/package.json +16 -0
  141. package/server.d.ts +2 -0
  142. package/server.js +1 -0
@@ -0,0 +1,262 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var parse_date_exports = {};
29
+ __export(parse_date_exports, {
30
+ parseDate: () => parseDate,
31
+ parseWeek: () => parseWeek
32
+ });
33
+ module.exports = __toCommonJS(parse_date_exports);
34
+ var import_date = require("./date");
35
+ var import_dayjs = require("./dayjs");
36
+ function parseUTC(value) {
37
+ if (value instanceof Date || import_dayjs.dayjs.isDayjs(value)) {
38
+ return {
39
+ unit: "utc",
40
+ start: value.toISOString()
41
+ };
42
+ }
43
+ if (value.endsWith("Z")) {
44
+ return {
45
+ unit: "utc",
46
+ start: value
47
+ };
48
+ }
49
+ }
50
+ __name(parseUTC, "parseUTC");
51
+ function parseYear(value) {
52
+ if (/^\d\d\d\d$/.test(value)) {
53
+ return {
54
+ unit: "year",
55
+ start: `${value}-01-01 00:00:00`
56
+ };
57
+ }
58
+ }
59
+ __name(parseYear, "parseYear");
60
+ function parseQuarter(value) {
61
+ if (/^\d\d\d\dQ\d$/.test(value)) {
62
+ const [year, q] = value.split("Q");
63
+ return {
64
+ unit: "quarter",
65
+ start: (0, import_dayjs.dayjs)(year, "YYYY").quarter(q).format("YYYY-MM-DD HH:mm:ss")
66
+ };
67
+ }
68
+ }
69
+ __name(parseQuarter, "parseQuarter");
70
+ function parseWeek(value) {
71
+ if (/^\d\d\d\d[W]\d\d$/.test(value)) {
72
+ const arr = value.split("W");
73
+ const year = (0, import_dayjs.dayjs)(arr[0], "YYYY").format("GGGG");
74
+ if (year !== arr[0]) {
75
+ return {
76
+ unit: "isoWeek",
77
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").add(1, "week").startOf("isoWeek").isoWeek(Number(arr[1])).format("YYYY-MM-DD HH:mm:ss")
78
+ };
79
+ }
80
+ return {
81
+ unit: "isoWeek",
82
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").isoWeek(Number(arr[1])).format("YYYY-MM-DD HH:mm:ss")
83
+ };
84
+ }
85
+ if (/^\d\d\d\d[w]\d\d$/.test(value)) {
86
+ const arr = value.split("w");
87
+ const year = (0, import_dayjs.dayjs)(arr[0], "YYYY").format("gggg");
88
+ if (year !== arr[0]) {
89
+ return {
90
+ unit: "week",
91
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").add(1, "week").startOf("week").week(Number(arr[1])).format("YYYY-MM-DD HH:mm:ss")
92
+ };
93
+ }
94
+ return {
95
+ unit: "week",
96
+ start: (0, import_dayjs.dayjs)(arr[0], "YYYY").week(Number(arr[1])).format("YYYY-MM-DD HH:mm:ss")
97
+ };
98
+ }
99
+ }
100
+ __name(parseWeek, "parseWeek");
101
+ function parseMonth(value) {
102
+ if (/^\d\d\d\d\-\d\d$/.test(value)) {
103
+ return {
104
+ unit: "month",
105
+ start: `${value}-01 00:00:00`
106
+ };
107
+ }
108
+ }
109
+ __name(parseMonth, "parseMonth");
110
+ function parseDay(value) {
111
+ if (/^\d\d\d\d\-\d\d\-\d\d$/.test(value)) {
112
+ return {
113
+ unit: "day",
114
+ start: `${value} 00:00:00`
115
+ };
116
+ }
117
+ }
118
+ __name(parseDay, "parseDay");
119
+ function parseHour(value) {
120
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d$/.test(value)) {
121
+ return {
122
+ unit: "hour",
123
+ start: `${value}:00:00`
124
+ };
125
+ }
126
+ }
127
+ __name(parseHour, "parseHour");
128
+ function parseMinute(value) {
129
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d$/.test(value)) {
130
+ return {
131
+ unit: "minute",
132
+ start: `${value}:00`
133
+ };
134
+ }
135
+ }
136
+ __name(parseMinute, "parseMinute");
137
+ function parseSecond(value) {
138
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d\:\d\d$/.test(value)) {
139
+ return {
140
+ unit: "second",
141
+ start: `${value}`
142
+ };
143
+ }
144
+ }
145
+ __name(parseSecond, "parseSecond");
146
+ function parseMillisecond(value) {
147
+ if (/^\d\d\d\d\-\d\d\-\d\d(\T|\s)\d\d\:\d\d\:\d\d\.\d\d\d$/.test(value)) {
148
+ return {
149
+ unit: "millisecond",
150
+ start: `${value}`
151
+ };
152
+ }
153
+ }
154
+ __name(parseMillisecond, "parseMillisecond");
155
+ const parsers = [
156
+ parseUTC,
157
+ parseYear,
158
+ parseQuarter,
159
+ parseWeek,
160
+ parseMonth,
161
+ parseDay,
162
+ parseHour,
163
+ parseMinute,
164
+ parseSecond,
165
+ parseMillisecond
166
+ ];
167
+ function toISOString(m) {
168
+ return m.toISOString();
169
+ }
170
+ __name(toISOString, "toISOString");
171
+ function dateRange(r) {
172
+ if (!r.timezone) {
173
+ r.timezone = "+00:00";
174
+ }
175
+ let m;
176
+ if (r.unit === "utc") {
177
+ return (0, import_dayjs.dayjs)(r == null ? void 0 : r.start).toISOString();
178
+ } else {
179
+ m = (0, import_dayjs.dayjs)(`${r == null ? void 0 : r.start}${r == null ? void 0 : r.timezone}`);
180
+ }
181
+ m = m.utcOffset((0, import_date.offsetFromString)(r.timezone));
182
+ return [m = m.startOf(r.unit), m.add(1, r.unit === "isoWeek" ? "weeks" : r.unit).startOf(r.unit)].map(toISOString);
183
+ }
184
+ __name(dateRange, "dateRange");
185
+ function parseDate(value, options = {}) {
186
+ if (!value) {
187
+ return;
188
+ }
189
+ if (Array.isArray(value)) {
190
+ return parseDateBetween(value, options);
191
+ }
192
+ let timezone = options.timezone || "+00:00";
193
+ const input = value;
194
+ if (typeof value === "string") {
195
+ const match = /(.+)((\+|\-)\d\d\:\d\d)$/.exec(value);
196
+ if (match) {
197
+ value = match[1];
198
+ timezone = match[2];
199
+ }
200
+ if (/^(\(|\[)/.test(value)) {
201
+ return parseDateBetween(input, options);
202
+ }
203
+ }
204
+ for (const parse of parsers) {
205
+ const r = parse(value);
206
+ if (r) {
207
+ r["input"] = input;
208
+ if (!r["timezone"]) {
209
+ r["timezone"] = timezone;
210
+ }
211
+ return dateRange(r);
212
+ }
213
+ }
214
+ }
215
+ __name(parseDate, "parseDate");
216
+ function parseDateBetween(value, options = {}) {
217
+ if (Array.isArray(value) && value.length > 1) {
218
+ const [startValue, endValue, op = "[]", timezone2] = value;
219
+ const r0 = parseDate(startValue, { timezone: timezone2 });
220
+ const r1 = parseDate(endValue, { timezone: timezone2 });
221
+ let start;
222
+ let startOp;
223
+ let end;
224
+ let endOp;
225
+ if (typeof r0 === "string") {
226
+ start = r0;
227
+ startOp = op[0];
228
+ } else {
229
+ start = op.startsWith("(") ? r0[1] : r0[0];
230
+ startOp = "[";
231
+ }
232
+ if (typeof r1 === "string") {
233
+ end = r1;
234
+ endOp = op[1];
235
+ } else {
236
+ end = op.endsWith(")") ? r1[0] : r1[1];
237
+ endOp = ")";
238
+ }
239
+ const newOp = startOp + endOp;
240
+ return newOp === "[)" ? [start, end] : [start, end, newOp];
241
+ }
242
+ if (typeof value !== "string") {
243
+ return;
244
+ }
245
+ const match = /(.+)((\+|\-)\d\d\:\d\d)$/.exec(value);
246
+ let timezone = options.timezone || "+00:00";
247
+ if (match) {
248
+ value = match[1];
249
+ timezone = match[2];
250
+ }
251
+ const m = /^(\(|\[)(.+)\,(.+)(\)|\])$/.exec(value);
252
+ if (!m) {
253
+ return;
254
+ }
255
+ return parseDateBetween([m[2], m[3], `${m[1]}${m[4]}`, timezone]);
256
+ }
257
+ __name(parseDateBetween, "parseDateBetween");
258
+ // Annotate the CommonJS export names for ESM import in node:
259
+ 0 && (module.exports = {
260
+ parseDate,
261
+ parseWeek
262
+ });
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare function flatten(target: any, opts?: any): {};
10
+ export declare function unflatten(obj: any, opts?: any): {};
11
+ export type ParseFilterOptions = {
12
+ vars?: Record<string, any>;
13
+ now?: any;
14
+ timezone?: string;
15
+ getField?: any;
16
+ };
17
+ export declare const parseFilter: (filter: any, opts?: ParseFilterOptions) => Promise<{}>;
18
+ export type GetDayRangeOptions = {
19
+ now?: any;
20
+ timezone?: string | number;
21
+ offset: number;
22
+ };
23
+ export declare function getDayRange(options: GetDayRangeOptions): (string | number)[];
24
+ export type Utc2unitOptions = {
25
+ now?: any;
26
+ unit: any;
27
+ timezone?: string | number;
28
+ offset?: number;
29
+ };
30
+ export declare function utc2unit(options: Utc2unitOptions): any;
31
+ type ToUnitParams = {
32
+ now?: any;
33
+ timezone?: string | number;
34
+ field?: {
35
+ timezone?: string | number;
36
+ };
37
+ };
38
+ export declare const toUnit: (unit: any, offset?: number) => ({ now, timezone, field }: ToUnitParams) => any;
39
+ export declare function getDateVars(): {
40
+ now: string;
41
+ today: ({ now, timezone, field }: ToUnitParams) => any;
42
+ yesterday: ({ now, timezone, field }: ToUnitParams) => any;
43
+ tomorrow: ({ now, timezone, field }: ToUnitParams) => any;
44
+ thisWeek: ({ now, timezone, field }: ToUnitParams) => any;
45
+ lastWeek: ({ now, timezone, field }: ToUnitParams) => any;
46
+ nextWeek: ({ now, timezone, field }: ToUnitParams) => any;
47
+ thisIsoWeek: ({ now, timezone, field }: ToUnitParams) => any;
48
+ lastIsoWeek: ({ now, timezone, field }: ToUnitParams) => any;
49
+ nextIsoWeek: ({ now, timezone, field }: ToUnitParams) => any;
50
+ thisMonth: ({ now, timezone, field }: ToUnitParams) => any;
51
+ lastMonth: ({ now, timezone, field }: ToUnitParams) => any;
52
+ nextMonth: ({ now, timezone, field }: ToUnitParams) => any;
53
+ thisQuarter: ({ now, timezone, field }: ToUnitParams) => any;
54
+ lastQuarter: ({ now, timezone, field }: ToUnitParams) => any;
55
+ nextQuarter: ({ now, timezone, field }: ToUnitParams) => any;
56
+ thisYear: ({ now, timezone, field }: ToUnitParams) => any;
57
+ lastYear: ({ now, timezone, field }: ToUnitParams) => any;
58
+ nextYear: ({ now, timezone, field }: ToUnitParams) => any;
59
+ last7Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
60
+ next7Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
61
+ last30Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
62
+ next30Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
63
+ last90Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
64
+ next90Days: ({ now, timezone, field }: ToUnitParams) => (string | number)[];
65
+ };
66
+ export declare function splitPathToTwoParts(path: string): string[];
67
+ export {};
@@ -0,0 +1,320 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var parse_filter_exports = {};
39
+ __export(parse_filter_exports, {
40
+ flatten: () => flatten,
41
+ getDateVars: () => getDateVars,
42
+ getDayRange: () => getDayRange,
43
+ parseFilter: () => parseFilter,
44
+ splitPathToTwoParts: () => splitPathToTwoParts,
45
+ toUnit: () => toUnit,
46
+ unflatten: () => unflatten,
47
+ utc2unit: () => utc2unit
48
+ });
49
+ module.exports = __toCommonJS(parse_filter_exports);
50
+ var import_lodash = __toESM(require("lodash"));
51
+ var import_set = __toESM(require("lodash/set"));
52
+ var import_moment = __toESM(require("moment"));
53
+ var import_date = require("./date");
54
+ var import_dayjs = require("./dayjs");
55
+ var import_getValuesByPath = require("./getValuesByPath");
56
+ const re = /^\s*\{\{([\s\S]*)\}\}\s*$/;
57
+ function isBuffer(obj) {
58
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
59
+ }
60
+ __name(isBuffer, "isBuffer");
61
+ function keyIdentity(key) {
62
+ return key;
63
+ }
64
+ __name(keyIdentity, "keyIdentity");
65
+ function flatten(target, opts) {
66
+ opts = opts || {};
67
+ const delimiter = opts.delimiter || ".";
68
+ const maxDepth = opts.maxDepth;
69
+ const transformKey = opts.transformKey || keyIdentity;
70
+ const transformValue = opts.transformValue || keyIdentity;
71
+ const output = {};
72
+ function step(object, prev, currentDepth) {
73
+ currentDepth = currentDepth || 1;
74
+ if (import_lodash.default.isObjectLike(object)) {
75
+ Object.keys(object).forEach(function(key) {
76
+ var _a;
77
+ const value = object[key];
78
+ const isarray = opts.safe && Array.isArray(value);
79
+ const type = Object.prototype.toString.call(value);
80
+ const isbuffer = isBuffer(value);
81
+ const isobject = type === "[object Object]" || type === "[object Array]";
82
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
83
+ if ((_a = opts.breakOn) == null ? void 0 : _a.call(opts, { key, value, path: newKey })) {
84
+ output[newKey] = transformValue(value, newKey);
85
+ return;
86
+ }
87
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
88
+ return step(value, newKey, currentDepth + 1);
89
+ }
90
+ output[newKey] = transformValue(value, newKey);
91
+ });
92
+ }
93
+ }
94
+ __name(step, "step");
95
+ step(target);
96
+ return output;
97
+ }
98
+ __name(flatten, "flatten");
99
+ function unflatten(obj, opts = {}) {
100
+ const parsed = {};
101
+ const transformValue = opts.transformValue || keyIdentity;
102
+ for (const key of Object.keys(obj)) {
103
+ (0, import_set.default)(parsed, key, transformValue(obj[key], key));
104
+ }
105
+ return parsed;
106
+ }
107
+ __name(unflatten, "unflatten");
108
+ const parsePath = /* @__PURE__ */ __name((path) => {
109
+ let operator = path.split(".").pop() || "";
110
+ if (!operator.startsWith("$")) {
111
+ operator = "";
112
+ }
113
+ return { operator };
114
+ }, "parsePath");
115
+ const isDateOperator = /* @__PURE__ */ __name((op) => {
116
+ return [
117
+ "$dateOn",
118
+ "$dateNotOn",
119
+ "$dateBefore",
120
+ "$dateAfter",
121
+ "$dateNotBefore",
122
+ "$dateNotAfter",
123
+ "$dateBetween"
124
+ ].includes(op);
125
+ }, "isDateOperator");
126
+ function isDate(input) {
127
+ return input instanceof Date || Object.prototype.toString.call(input) === "[object Date]";
128
+ }
129
+ __name(isDate, "isDate");
130
+ const dateValueWrapper = /* @__PURE__ */ __name((value, timezone) => {
131
+ if (!value) {
132
+ return null;
133
+ }
134
+ if (Array.isArray(value)) {
135
+ if (value.length === 2) {
136
+ value.push("[]", timezone);
137
+ } else if (value.length === 3) {
138
+ value.push(timezone);
139
+ }
140
+ return value;
141
+ }
142
+ if (typeof value === "string") {
143
+ if (!timezone || /(\+|-)\d\d:\d\d$/.test(value)) {
144
+ return value;
145
+ }
146
+ return value + timezone;
147
+ }
148
+ if (isDate(value)) {
149
+ return value.toISOString();
150
+ }
151
+ }, "dateValueWrapper");
152
+ const parseFilter = /* @__PURE__ */ __name(async (filter, opts = {}) => {
153
+ const userFieldsSet = /* @__PURE__ */ new Set();
154
+ const vars = opts.vars || {};
155
+ const timezone = opts.timezone;
156
+ const now = opts.now;
157
+ const getField = opts.getField;
158
+ const flat = flatten(filter, {
159
+ breakOn({ key }) {
160
+ return key.startsWith("$") && key !== "$and" && key !== "$or";
161
+ },
162
+ transformValue(value) {
163
+ if (typeof value !== "string") {
164
+ return value;
165
+ }
166
+ const match = re.exec(value);
167
+ if (match) {
168
+ const key = match[1].trim();
169
+ if (key.startsWith("$user")) {
170
+ userFieldsSet.add(key.substring(6));
171
+ }
172
+ }
173
+ return value;
174
+ }
175
+ });
176
+ if (userFieldsSet.size > 0) {
177
+ const $user = await vars.$user({ fields: [...userFieldsSet.values()] });
178
+ Object.assign(vars, { $user });
179
+ }
180
+ return unflatten(flat, {
181
+ transformValue(value, path) {
182
+ const { operator } = parsePath(path);
183
+ if (typeof value === "string") {
184
+ const match = re.exec(value);
185
+ if (match) {
186
+ const key = match[1].trim();
187
+ const val = (0, import_getValuesByPath.getValuesByPath)(vars, key, null);
188
+ const field = getField == null ? void 0 : getField(path);
189
+ value = typeof val === "function" ? val == null ? void 0 : val({ field, operator, timezone, now }) : val;
190
+ }
191
+ }
192
+ if (isDateOperator(operator)) {
193
+ const field = getField == null ? void 0 : getField(path);
194
+ if ((field == null ? void 0 : field.constructor.name) === "DateOnlyField" || (field == null ? void 0 : field.constructor.name) === "DatetimeNoTzField") {
195
+ return value;
196
+ }
197
+ return dateValueWrapper(value, (field == null ? void 0 : field.timezone) || timezone);
198
+ }
199
+ return value;
200
+ }
201
+ });
202
+ }, "parseFilter");
203
+ function getDayRange(options) {
204
+ const { now, timezone = "+00:00", offset } = options;
205
+ let m = toMoment(now).utcOffset((0, import_date.offsetFromString)(timezone));
206
+ if (offset > 0) {
207
+ return [
208
+ // 第二天开始计算
209
+ (m = m.add(1, "day").startOf("day")).format("YYYY-MM-DD"),
210
+ // 第九天开始前结束
211
+ m.clone().add(offset, "day").startOf("day").format("YYYY-MM-DD"),
212
+ "[)",
213
+ timezone
214
+ ];
215
+ }
216
+ return [
217
+ // 今天开始前
218
+ m.clone().subtract(-1 * offset - 1, "day").startOf("day").format("YYYY-MM-DD"),
219
+ // 明天开始前
220
+ m.clone().add(1, "day").startOf("day").format("YYYY-MM-DD"),
221
+ "[)",
222
+ timezone
223
+ ];
224
+ }
225
+ __name(getDayRange, "getDayRange");
226
+ function toMoment(value, useMoment = false) {
227
+ if (!value) {
228
+ return useMoment ? (0, import_moment.default)() : (0, import_dayjs.dayjs)();
229
+ }
230
+ if (import_dayjs.dayjs.isDayjs(value)) {
231
+ return value;
232
+ }
233
+ return useMoment ? (0, import_moment.default)(value) : (0, import_dayjs.dayjs)(value);
234
+ }
235
+ __name(toMoment, "toMoment");
236
+ function utc2unit(options) {
237
+ var _a;
238
+ const { now, unit, timezone = "+00:00", offset } = options;
239
+ let m = toMoment(now, unit === "isoWeek");
240
+ m = m.utcOffset((0, import_date.offsetFromString)(timezone));
241
+ m = m.startOf(unit);
242
+ if (offset > 0) {
243
+ m = m.add(offset, unit);
244
+ } else if (offset < 0) {
245
+ m = m.subtract(-1 * offset, unit);
246
+ }
247
+ const fn = {
248
+ year: /* @__PURE__ */ __name(() => m.format("YYYY"), "year"),
249
+ quarter: /* @__PURE__ */ __name(() => m.format("YYYY[Q]Q"), "quarter"),
250
+ month: /* @__PURE__ */ __name(() => m.format("YYYY-MM"), "month"),
251
+ week: /* @__PURE__ */ __name(() => m.format("gggg[w]ww"), "week"),
252
+ isoWeek: /* @__PURE__ */ __name(() => m.format("GGGG[W]WW"), "isoWeek"),
253
+ day: /* @__PURE__ */ __name(() => m.format("YYYY-MM-DD"), "day")
254
+ };
255
+ const r = (_a = fn[unit]) == null ? void 0 : _a.call(fn);
256
+ return timezone ? r + timezone : r;
257
+ }
258
+ __name(utc2unit, "utc2unit");
259
+ const toUnit = /* @__PURE__ */ __name((unit, offset) => {
260
+ return ({ now, timezone, field }) => {
261
+ if (field == null ? void 0 : field.timezone) {
262
+ timezone = field == null ? void 0 : field.timezone;
263
+ }
264
+ return utc2unit({ now, timezone, unit, offset });
265
+ };
266
+ }, "toUnit");
267
+ const toDays = /* @__PURE__ */ __name((offset) => {
268
+ return ({ now, timezone, field }) => {
269
+ if (field == null ? void 0 : field.timezone) {
270
+ timezone = field == null ? void 0 : field.timezone;
271
+ }
272
+ return getDayRange({ now, timezone, offset });
273
+ };
274
+ }, "toDays");
275
+ function getDateVars() {
276
+ return {
277
+ now: (/* @__PURE__ */ new Date()).toISOString(),
278
+ today: toUnit("day"),
279
+ yesterday: toUnit("day", -1),
280
+ tomorrow: toUnit("day", 1),
281
+ thisWeek: toUnit("week"),
282
+ lastWeek: toUnit("week", -1),
283
+ nextWeek: toUnit("week", 1),
284
+ thisIsoWeek: toUnit("isoWeek"),
285
+ lastIsoWeek: toUnit("isoWeek", -1),
286
+ nextIsoWeek: toUnit("isoWeek", 1),
287
+ thisMonth: toUnit("month"),
288
+ lastMonth: toUnit("month", -1),
289
+ nextMonth: toUnit("month", 1),
290
+ thisQuarter: toUnit("quarter"),
291
+ lastQuarter: toUnit("quarter", -1),
292
+ nextQuarter: toUnit("quarter", 1),
293
+ thisYear: toUnit("year"),
294
+ lastYear: toUnit("year", -1),
295
+ nextYear: toUnit("year", 1),
296
+ last7Days: toDays(-7),
297
+ next7Days: toDays(7),
298
+ last30Days: toDays(-30),
299
+ next30Days: toDays(30),
300
+ last90Days: toDays(-90),
301
+ next90Days: toDays(90)
302
+ };
303
+ }
304
+ __name(getDateVars, "getDateVars");
305
+ function splitPathToTwoParts(path) {
306
+ const parts = path.split(".");
307
+ return [parts.shift(), parts.join(".")];
308
+ }
309
+ __name(splitPathToTwoParts, "splitPathToTwoParts");
310
+ // Annotate the CommonJS export names for ESM import in node:
311
+ 0 && (module.exports = {
312
+ flatten,
313
+ getDateVars,
314
+ getDayRange,
315
+ parseFilter,
316
+ splitPathToTwoParts,
317
+ toUnit,
318
+ unflatten,
319
+ utc2unit
320
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /**
10
+ * parseHTML('<span>{{version}}</span>', { version: '1.0.0' }) -> '<span>1.0.0</span>'
11
+ * @param html
12
+ * @param variables
13
+ * @returns
14
+ */
15
+ export declare function parseHTML(html: string, variables: Record<string, any>): string;