@nocobase/utils 1.2.12-alpha → 1.3.0-alpha.20240710084543

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 (65) hide show
  1. package/package.json +2 -2
  2. package/lib/assign.d.ts +0 -17
  3. package/lib/assign.js +0 -143
  4. package/lib/client.d.ts +0 -29
  5. package/lib/client.js +0 -86
  6. package/lib/collections-graph.d.ts +0 -24
  7. package/lib/collections-graph.js +0 -108
  8. package/lib/common.d.ts +0 -14
  9. package/lib/common.js +0 -87
  10. package/lib/date.d.ts +0 -37
  11. package/lib/date.js +0 -189
  12. package/lib/dayjs.d.ts +0 -10
  13. package/lib/dayjs.js +0 -72
  14. package/lib/forEach.d.ts +0 -9
  15. package/lib/forEach.js +0 -45
  16. package/lib/fs-exists.d.ts +0 -9
  17. package/lib/fs-exists.js +0 -46
  18. package/lib/getValuesByPath.d.ts +0 -9
  19. package/lib/getValuesByPath.js +0 -71
  20. package/lib/i18n.d.ts +0 -10
  21. package/lib/i18n.js +0 -43
  22. package/lib/index.d.ts +0 -35
  23. package/lib/index.js +0 -98
  24. package/lib/isPortalInBody.d.ts +0 -13
  25. package/lib/isPortalInBody.js +0 -54
  26. package/lib/isValidFilter.d.ts +0 -9
  27. package/lib/isValidFilter.js +0 -63
  28. package/lib/json-templates.d.ts +0 -9
  29. package/lib/json-templates.js +0 -141
  30. package/lib/koa-multer.d.ts +0 -15
  31. package/lib/koa-multer.js +0 -94
  32. package/lib/log.d.ts +0 -9
  33. package/lib/log.js +0 -39
  34. package/lib/measure-execution-time.d.ts +0 -9
  35. package/lib/measure-execution-time.js +0 -44
  36. package/lib/merge.d.ts +0 -9
  37. package/lib/merge.js +0 -55
  38. package/lib/mixin/AsyncEmitter.d.ts +0 -11
  39. package/lib/mixin/AsyncEmitter.js +0 -80
  40. package/lib/mixin/index.d.ts +0 -9
  41. package/lib/mixin/index.js +0 -48
  42. package/lib/notification.d.ts +0 -9
  43. package/lib/notification.js +0 -43
  44. package/lib/number.d.ts +0 -9
  45. package/lib/number.js +0 -45
  46. package/lib/parse-date.d.ts +0 -15
  47. package/lib/parse-date.js +0 -262
  48. package/lib/parse-filter.d.ts +0 -159
  49. package/lib/parse-filter.js +0 -317
  50. package/lib/parseHTML.d.ts +0 -15
  51. package/lib/parseHTML.js +0 -42
  52. package/lib/perf-hooks.d.ts +0 -14
  53. package/lib/perf-hooks.js +0 -69
  54. package/lib/registry.d.ts +0 -22
  55. package/lib/registry.js +0 -69
  56. package/lib/requireModule.d.ts +0 -12
  57. package/lib/requireModule.js +0 -90
  58. package/lib/server.d.ts +0 -19
  59. package/lib/server.js +0 -50
  60. package/lib/toposort.d.ts +0 -18
  61. package/lib/toposort.js +0 -83
  62. package/lib/uid.d.ts +0 -9
  63. package/lib/uid.js +0 -46
  64. package/lib/url.d.ts +0 -9
  65. package/lib/url.js +0 -46
@@ -1,317 +0,0 @@
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
- return dateValueWrapper(value, (field == null ? void 0 : field.timezone) || timezone);
195
- }
196
- return value;
197
- }
198
- });
199
- }, "parseFilter");
200
- function getDayRange(options) {
201
- const { now, timezone = "+00:00", offset } = options;
202
- let m = toMoment(now).utcOffset((0, import_date.offsetFromString)(timezone));
203
- if (offset > 0) {
204
- return [
205
- // 第二天开始计算
206
- (m = m.add(1, "day").startOf("day")).format("YYYY-MM-DD"),
207
- // 第九天开始前结束
208
- m.clone().add(offset, "day").startOf("day").format("YYYY-MM-DD"),
209
- "[)",
210
- timezone
211
- ];
212
- }
213
- return [
214
- // 今天开始前
215
- m.clone().subtract(-1 * offset - 1, "day").startOf("day").format("YYYY-MM-DD"),
216
- // 明天开始前
217
- m.clone().add(1, "day").startOf("day").format("YYYY-MM-DD"),
218
- "[)",
219
- timezone
220
- ];
221
- }
222
- __name(getDayRange, "getDayRange");
223
- function toMoment(value, useMoment = false) {
224
- if (!value) {
225
- return useMoment ? (0, import_moment.default)() : (0, import_dayjs.dayjs)();
226
- }
227
- if (import_dayjs.dayjs.isDayjs(value)) {
228
- return value;
229
- }
230
- return useMoment ? (0, import_moment.default)(value) : (0, import_dayjs.dayjs)(value);
231
- }
232
- __name(toMoment, "toMoment");
233
- function utc2unit(options) {
234
- var _a;
235
- const { now, unit, timezone = "+00:00", offset } = options;
236
- let m = toMoment(now, unit === "isoWeek");
237
- m = m.utcOffset((0, import_date.offsetFromString)(timezone));
238
- m = m.startOf(unit);
239
- if (offset > 0) {
240
- m = m.add(offset, unit);
241
- } else if (offset < 0) {
242
- m = m.subtract(-1 * offset, unit);
243
- }
244
- const fn = {
245
- year: () => m.format("YYYY"),
246
- quarter: () => m.format("YYYY[Q]Q"),
247
- month: () => m.format("YYYY-MM"),
248
- week: () => m.format("gggg[w]ww"),
249
- isoWeek: () => m.format("GGGG[W]WW"),
250
- day: () => m.format("YYYY-MM-DD")
251
- };
252
- const r = (_a = fn[unit]) == null ? void 0 : _a.call(fn);
253
- return timezone ? r + timezone : r;
254
- }
255
- __name(utc2unit, "utc2unit");
256
- const toUnit = /* @__PURE__ */ __name((unit, offset) => {
257
- return ({ now, timezone, field }) => {
258
- if (field == null ? void 0 : field.timezone) {
259
- timezone = field == null ? void 0 : field.timezone;
260
- }
261
- return utc2unit({ now, timezone, unit, offset });
262
- };
263
- }, "toUnit");
264
- const toDays = /* @__PURE__ */ __name((offset) => {
265
- return ({ now, timezone, field }) => {
266
- if (field == null ? void 0 : field.timezone) {
267
- timezone = field == null ? void 0 : field.timezone;
268
- }
269
- return getDayRange({ now, timezone, offset });
270
- };
271
- }, "toDays");
272
- function getDateVars() {
273
- return {
274
- now: (/* @__PURE__ */ new Date()).toISOString(),
275
- today: toUnit("day"),
276
- yesterday: toUnit("day", -1),
277
- tomorrow: toUnit("day", 1),
278
- thisWeek: toUnit("week"),
279
- lastWeek: toUnit("week", -1),
280
- nextWeek: toUnit("week", 1),
281
- thisIsoWeek: toUnit("isoWeek"),
282
- lastIsoWeek: toUnit("isoWeek", -1),
283
- nextIsoWeek: toUnit("isoWeek", 1),
284
- thisMonth: toUnit("month"),
285
- lastMonth: toUnit("month", -1),
286
- nextMonth: toUnit("month", 1),
287
- thisQuarter: toUnit("quarter"),
288
- lastQuarter: toUnit("quarter", -1),
289
- nextQuarter: toUnit("quarter", 1),
290
- thisYear: toUnit("year"),
291
- lastYear: toUnit("year", -1),
292
- nextYear: toUnit("year", 1),
293
- last7Days: toDays(-7),
294
- next7Days: toDays(7),
295
- last30Days: toDays(-30),
296
- next30Days: toDays(30),
297
- last90Days: toDays(-90),
298
- next90Days: toDays(90)
299
- };
300
- }
301
- __name(getDateVars, "getDateVars");
302
- function splitPathToTwoParts(path) {
303
- const parts = path.split(".");
304
- return [parts.shift(), parts.join(".")];
305
- }
306
- __name(splitPathToTwoParts, "splitPathToTwoParts");
307
- // Annotate the CommonJS export names for ESM import in node:
308
- 0 && (module.exports = {
309
- flatten,
310
- getDateVars,
311
- getDayRange,
312
- parseFilter,
313
- splitPathToTwoParts,
314
- toUnit,
315
- unflatten,
316
- utc2unit
317
- });
@@ -1,15 +0,0 @@
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;
package/lib/parseHTML.js DELETED
@@ -1,42 +0,0 @@
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 parseHTML_exports = {};
29
- __export(parseHTML_exports, {
30
- parseHTML: () => parseHTML
31
- });
32
- module.exports = __toCommonJS(parseHTML_exports);
33
- function parseHTML(html, variables) {
34
- return html.replace(/\{\{(\w+)\}\}/g, function(match, key) {
35
- return typeof variables[key] !== "undefined" ? variables[key] : match;
36
- });
37
- }
38
- __name(parseHTML, "parseHTML");
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- parseHTML
42
- });
@@ -1,14 +0,0 @@
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 const prePerfHooksWrap: (handler: any, options?: {
10
- name?: string;
11
- }) => (ctx: any, next: any) => Promise<any>;
12
- export declare const postPerfHooksWrap: (handler: any, options: {
13
- name?: string;
14
- }) => (ctx: any, next: any) => Promise<any>;
package/lib/perf-hooks.js DELETED
@@ -1,69 +0,0 @@
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 perf_hooks_exports = {};
29
- __export(perf_hooks_exports, {
30
- postPerfHooksWrap: () => postPerfHooksWrap,
31
- prePerfHooksWrap: () => prePerfHooksWrap
32
- });
33
- module.exports = __toCommonJS(perf_hooks_exports);
34
- var import_perf_hooks = require("perf_hooks");
35
- const prePerfHooksWrap = /* @__PURE__ */ __name((handler, options) => {
36
- const { name } = options || {};
37
- return async (ctx, next) => {
38
- if (!ctx.getPerfHistogram) {
39
- return await handler(ctx, next);
40
- }
41
- const histogram = ctx.getPerfHistogram(name || handler);
42
- const start = import_perf_hooks.performance.now();
43
- await handler(ctx, async () => {
44
- const duration = import_perf_hooks.performance.now() - start;
45
- histogram.record(Math.ceil(duration * 1e6));
46
- await next();
47
- });
48
- };
49
- }, "prePerfHooksWrap");
50
- const postPerfHooksWrap = /* @__PURE__ */ __name((handler, options) => {
51
- const { name } = options || {};
52
- return async (ctx, next) => {
53
- if (!ctx.getPerfHistogram) {
54
- return await handler(ctx, next);
55
- }
56
- await next();
57
- const histogram = ctx.getPerfHistogram(name || handler);
58
- const start = import_perf_hooks.performance.now();
59
- await handler(ctx, async () => {
60
- });
61
- const duration = import_perf_hooks.performance.now() - start;
62
- histogram.record(Math.ceil(duration * 1e6));
63
- };
64
- }, "postPerfHooksWrap");
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- postPerfHooksWrap,
68
- prePerfHooksWrap
69
- });
package/lib/registry.d.ts DELETED
@@ -1,22 +0,0 @@
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 interface RegistryOptions {
10
- override: boolean;
11
- }
12
- export declare class Registry<T> {
13
- private map;
14
- options: RegistryOptions;
15
- constructor(options?: RegistryOptions);
16
- register(key: string, value: T): void;
17
- get(key: string): T;
18
- getKeys(): Iterable<string>;
19
- getValues(): Iterable<T>;
20
- getEntities(): Iterable<[string, T]>;
21
- }
22
- export default Registry;
package/lib/registry.js DELETED
@@ -1,69 +0,0 @@
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 registry_exports = {};
29
- __export(registry_exports, {
30
- Registry: () => Registry,
31
- default: () => registry_default
32
- });
33
- module.exports = __toCommonJS(registry_exports);
34
- const _Registry = class _Registry {
35
- map = /* @__PURE__ */ new Map();
36
- options;
37
- constructor(options = { override: false }) {
38
- this.options = options;
39
- }
40
- register(key, value) {
41
- if (!this.options.override && this.map.has(key)) {
42
- throw new Error(`this registry does not allow to override existing keys: "${key}"`);
43
- }
44
- this.map.set(key, value);
45
- }
46
- // async import({ directory, extensions = ['.js', '.ts', '.json'] }) {
47
- // const files = await fs.readdir(directory);
48
- // return files.filter(file => extensions.includes(path.extname(file)))
49
- // }
50
- get(key) {
51
- return this.map.get(key);
52
- }
53
- getKeys() {
54
- return this.map.keys();
55
- }
56
- getValues() {
57
- return this.map.values();
58
- }
59
- getEntities() {
60
- return this.map.entries();
61
- }
62
- };
63
- __name(_Registry, "Registry");
64
- let Registry = _Registry;
65
- var registry_default = Registry;
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- Registry
69
- });
@@ -1,12 +0,0 @@
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 requireResolve(m: any): Promise<string>;
10
- export declare function requireModule(m: any): any;
11
- export default requireModule;
12
- export declare function importModule(m: string): Promise<any>;
@@ -1,90 +0,0 @@
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 requireModule_exports = {};
39
- __export(requireModule_exports, {
40
- default: () => requireModule_default,
41
- importModule: () => importModule,
42
- requireModule: () => requireModule,
43
- requireResolve: () => requireResolve
44
- });
45
- module.exports = __toCommonJS(requireModule_exports);
46
- var import_fs = __toESM(require("fs"));
47
- var import_path = __toESM(require("path"));
48
- var import_url = require("url");
49
- async function requireResolve(m) {
50
- if (!process.env.VITEST) {
51
- return require.resolve(m);
52
- }
53
- const json = JSON.parse(
54
- await import_fs.default.promises.readFile(import_path.default.resolve(process.cwd(), "./tsconfig.paths.json"), { encoding: "utf8" })
55
- );
56
- const paths = json.compilerOptions.paths;
57
- if (paths[m]) {
58
- return require.resolve(import_path.default.resolve(process.cwd(), paths[m][0], "index.ts"));
59
- }
60
- return require.resolve(m);
61
- }
62
- __name(requireResolve, "requireResolve");
63
- function requireModule(m) {
64
- if (typeof m === "string") {
65
- m = require(m);
66
- }
67
- if (typeof m !== "object") {
68
- return m;
69
- }
70
- return m.__esModule ? m.default : m;
71
- }
72
- __name(requireModule, "requireModule");
73
- var requireModule_default = requireModule;
74
- async function importModule(m) {
75
- if (!process.env.VITEST) {
76
- return requireModule(m);
77
- }
78
- if (import_path.default.isAbsolute(m)) {
79
- m = (0, import_url.pathToFileURL)(m).href;
80
- }
81
- const r = (await import(m)).default;
82
- return r.__esModule ? r.default : r;
83
- }
84
- __name(importModule, "importModule");
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- importModule,
88
- requireModule,
89
- requireResolve
90
- });
package/lib/server.d.ts DELETED
@@ -1,19 +0,0 @@
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 * from './date';
10
- export * from './fs-exists';
11
- export * from './merge';
12
- export * from './mixin';
13
- export * from './mixin/AsyncEmitter';
14
- export * from './number';
15
- export * from './registry';
16
- export * from './requireModule';
17
- export * from './toposort';
18
- export * from './uid';
19
- export * from './url';