@nocobase/utils 1.2.13-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.
- package/package.json +2 -2
- package/lib/assign.d.ts +0 -17
- package/lib/assign.js +0 -143
- package/lib/client.d.ts +0 -29
- package/lib/client.js +0 -86
- package/lib/collections-graph.d.ts +0 -24
- package/lib/collections-graph.js +0 -108
- package/lib/common.d.ts +0 -14
- package/lib/common.js +0 -87
- package/lib/date.d.ts +0 -37
- package/lib/date.js +0 -189
- package/lib/dayjs.d.ts +0 -10
- package/lib/dayjs.js +0 -72
- package/lib/forEach.d.ts +0 -9
- package/lib/forEach.js +0 -45
- package/lib/fs-exists.d.ts +0 -9
- package/lib/fs-exists.js +0 -46
- package/lib/getValuesByPath.d.ts +0 -9
- package/lib/getValuesByPath.js +0 -71
- package/lib/i18n.d.ts +0 -10
- package/lib/i18n.js +0 -43
- package/lib/index.d.ts +0 -35
- package/lib/index.js +0 -98
- package/lib/isPortalInBody.d.ts +0 -13
- package/lib/isPortalInBody.js +0 -54
- package/lib/isValidFilter.d.ts +0 -9
- package/lib/isValidFilter.js +0 -63
- package/lib/json-templates.d.ts +0 -9
- package/lib/json-templates.js +0 -141
- package/lib/koa-multer.d.ts +0 -15
- package/lib/koa-multer.js +0 -94
- package/lib/log.d.ts +0 -9
- package/lib/log.js +0 -39
- package/lib/measure-execution-time.d.ts +0 -9
- package/lib/measure-execution-time.js +0 -44
- package/lib/merge.d.ts +0 -9
- package/lib/merge.js +0 -55
- package/lib/mixin/AsyncEmitter.d.ts +0 -11
- package/lib/mixin/AsyncEmitter.js +0 -80
- package/lib/mixin/index.d.ts +0 -9
- package/lib/mixin/index.js +0 -48
- package/lib/notification.d.ts +0 -9
- package/lib/notification.js +0 -43
- package/lib/number.d.ts +0 -9
- package/lib/number.js +0 -45
- package/lib/parse-date.d.ts +0 -15
- package/lib/parse-date.js +0 -262
- package/lib/parse-filter.d.ts +0 -159
- package/lib/parse-filter.js +0 -317
- package/lib/parseHTML.d.ts +0 -15
- package/lib/parseHTML.js +0 -42
- package/lib/perf-hooks.d.ts +0 -14
- package/lib/perf-hooks.js +0 -69
- package/lib/registry.d.ts +0 -22
- package/lib/registry.js +0 -69
- package/lib/requireModule.d.ts +0 -12
- package/lib/requireModule.js +0 -90
- package/lib/server.d.ts +0 -19
- package/lib/server.js +0 -50
- package/lib/toposort.d.ts +0 -18
- package/lib/toposort.js +0 -83
- package/lib/uid.d.ts +0 -9
- package/lib/uid.js +0 -46
- package/lib/url.d.ts +0 -9
- package/lib/url.js +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"multer": "^1.4.5-lts.1",
|
|
15
15
|
"object-path": "^0.11.8"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4"
|
|
18
18
|
}
|
package/lib/assign.d.ts
DELETED
|
@@ -1,17 +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
|
-
type MergeStrategyType = 'merge' | 'deepMerge' | 'overwrite' | 'andMerge' | 'orMerge' | 'intersect' | 'union';
|
|
10
|
-
type MergeStrategyFunc = (x: any, y: any) => any;
|
|
11
|
-
export type MergeStrategy = MergeStrategyType | MergeStrategyFunc;
|
|
12
|
-
export interface MergeStrategies {
|
|
13
|
-
[key: string]: MergeStrategy;
|
|
14
|
-
}
|
|
15
|
-
export declare const mergeStrategies: Map<MergeStrategyType, MergeStrategyFunc>;
|
|
16
|
-
export declare function assign(target: any, source: any, strategies?: MergeStrategies): any;
|
|
17
|
-
export {};
|
package/lib/assign.js
DELETED
|
@@ -1,143 +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 assign_exports = {};
|
|
39
|
-
__export(assign_exports, {
|
|
40
|
-
assign: () => assign,
|
|
41
|
-
mergeStrategies: () => mergeStrategies
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(assign_exports);
|
|
44
|
-
var import_deepmerge = __toESM(require("deepmerge"));
|
|
45
|
-
var import_lodash = __toESM(require("lodash"));
|
|
46
|
-
var import_common = require("./common");
|
|
47
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
48
|
-
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter((symbol) => target.propertyIsEnumerable(symbol)) : [];
|
|
49
|
-
}
|
|
50
|
-
__name(getEnumerableOwnPropertySymbols, "getEnumerableOwnPropertySymbols");
|
|
51
|
-
function getKeys(target) {
|
|
52
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
53
|
-
}
|
|
54
|
-
__name(getKeys, "getKeys");
|
|
55
|
-
const mergeStrategies = /* @__PURE__ */ new Map();
|
|
56
|
-
mergeStrategies.set("overwrite", (_, y) => {
|
|
57
|
-
if (typeof y === "string") {
|
|
58
|
-
y = y.split(",");
|
|
59
|
-
}
|
|
60
|
-
return y;
|
|
61
|
-
});
|
|
62
|
-
mergeStrategies.set("andMerge", (x, y) => {
|
|
63
|
-
if (!x && !y) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (!x) {
|
|
67
|
-
return y;
|
|
68
|
-
}
|
|
69
|
-
if (!y) {
|
|
70
|
-
return x;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
$and: [x, y]
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
mergeStrategies.set("orMerge", (x, y) => {
|
|
77
|
-
if (!x && !y) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!x) {
|
|
81
|
-
return y;
|
|
82
|
-
}
|
|
83
|
-
if (!y) {
|
|
84
|
-
return x;
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
$or: [x, y]
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
mergeStrategies.set("deepMerge", (x, y) => {
|
|
91
|
-
return (0, import_common.isPlainObject)(x) && (0, import_common.isPlainObject)(y) ? (0, import_deepmerge.default)(x, y, {
|
|
92
|
-
arrayMerge: (x2, y2) => y2
|
|
93
|
-
}) : y;
|
|
94
|
-
});
|
|
95
|
-
mergeStrategies.set("merge", (x, y) => {
|
|
96
|
-
return (0, import_common.isPlainObject)(x) && (0, import_common.isPlainObject)(y) ? Object.assign(x, y) : y;
|
|
97
|
-
});
|
|
98
|
-
mergeStrategies.set("union", (x, y) => {
|
|
99
|
-
if (typeof x === "string") {
|
|
100
|
-
x = x.split(",");
|
|
101
|
-
}
|
|
102
|
-
if (typeof y === "string") {
|
|
103
|
-
y = y.split(",");
|
|
104
|
-
}
|
|
105
|
-
return import_lodash.default.uniq((x || []).concat(y || [])).filter(Boolean);
|
|
106
|
-
});
|
|
107
|
-
mergeStrategies.set(
|
|
108
|
-
"intersect",
|
|
109
|
-
(x, y) => (() => {
|
|
110
|
-
if (typeof x === "string") {
|
|
111
|
-
x = x.split(",");
|
|
112
|
-
}
|
|
113
|
-
if (typeof y === "string") {
|
|
114
|
-
y = y.split(",");
|
|
115
|
-
}
|
|
116
|
-
if (!Array.isArray(x) || x.length === 0) {
|
|
117
|
-
return y || [];
|
|
118
|
-
}
|
|
119
|
-
if (!Array.isArray(y) || y.length === 0) {
|
|
120
|
-
return x || [];
|
|
121
|
-
}
|
|
122
|
-
return x.filter((v) => y.includes(v));
|
|
123
|
-
})().filter(Boolean)
|
|
124
|
-
);
|
|
125
|
-
function assign(target, source, strategies = {}) {
|
|
126
|
-
getKeys(source).forEach((sourceKey) => {
|
|
127
|
-
const strategy = strategies[sourceKey];
|
|
128
|
-
let func = mergeStrategies.get("deepMerge");
|
|
129
|
-
if (typeof strategy === "function") {
|
|
130
|
-
func = strategy;
|
|
131
|
-
} else if (typeof strategy === "string" && mergeStrategies.has(strategy)) {
|
|
132
|
-
func = mergeStrategies.get(strategy);
|
|
133
|
-
}
|
|
134
|
-
target[sourceKey] = func(target[sourceKey], source[sourceKey]);
|
|
135
|
-
});
|
|
136
|
-
return target;
|
|
137
|
-
}
|
|
138
|
-
__name(assign, "assign");
|
|
139
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
140
|
-
0 && (module.exports = {
|
|
141
|
-
assign,
|
|
142
|
-
mergeStrategies
|
|
143
|
-
});
|
package/lib/client.d.ts
DELETED
|
@@ -1,29 +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
|
-
import lodash from 'lodash';
|
|
10
|
-
import { dayjs } from './dayjs';
|
|
11
|
-
export * from './collections-graph';
|
|
12
|
-
export * from './common';
|
|
13
|
-
export * from './date';
|
|
14
|
-
export * from './forEach';
|
|
15
|
-
export * from './getValuesByPath';
|
|
16
|
-
export * from './isValidFilter';
|
|
17
|
-
export * from './json-templates';
|
|
18
|
-
export * from './log';
|
|
19
|
-
export * from './merge';
|
|
20
|
-
export * from './notification';
|
|
21
|
-
export * from './number';
|
|
22
|
-
export * from './parse-filter';
|
|
23
|
-
export * from './registry';
|
|
24
|
-
export * from './isPortalInBody';
|
|
25
|
-
export * from './uid';
|
|
26
|
-
export * from './url';
|
|
27
|
-
export { dayjs, lodash };
|
|
28
|
-
export * from './parseHTML';
|
|
29
|
-
export * from './i18n';
|
package/lib/client.js
DELETED
|
@@ -1,86 +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 __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
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 client_exports = {};
|
|
39
|
-
__export(client_exports, {
|
|
40
|
-
dayjs: () => import_dayjs.dayjs,
|
|
41
|
-
lodash: () => import_lodash.default
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(client_exports);
|
|
44
|
-
var import_lodash = __toESM(require("lodash"));
|
|
45
|
-
var import_dayjs = require("./dayjs");
|
|
46
|
-
__reExport(client_exports, require("./collections-graph"), module.exports);
|
|
47
|
-
__reExport(client_exports, require("./common"), module.exports);
|
|
48
|
-
__reExport(client_exports, require("./date"), module.exports);
|
|
49
|
-
__reExport(client_exports, require("./forEach"), module.exports);
|
|
50
|
-
__reExport(client_exports, require("./getValuesByPath"), module.exports);
|
|
51
|
-
__reExport(client_exports, require("./isValidFilter"), module.exports);
|
|
52
|
-
__reExport(client_exports, require("./json-templates"), module.exports);
|
|
53
|
-
__reExport(client_exports, require("./log"), module.exports);
|
|
54
|
-
__reExport(client_exports, require("./merge"), module.exports);
|
|
55
|
-
__reExport(client_exports, require("./notification"), module.exports);
|
|
56
|
-
__reExport(client_exports, require("./number"), module.exports);
|
|
57
|
-
__reExport(client_exports, require("./parse-filter"), module.exports);
|
|
58
|
-
__reExport(client_exports, require("./registry"), module.exports);
|
|
59
|
-
__reExport(client_exports, require("./isPortalInBody"), module.exports);
|
|
60
|
-
__reExport(client_exports, require("./uid"), module.exports);
|
|
61
|
-
__reExport(client_exports, require("./url"), module.exports);
|
|
62
|
-
__reExport(client_exports, require("./parseHTML"), module.exports);
|
|
63
|
-
__reExport(client_exports, require("./i18n"), module.exports);
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
dayjs,
|
|
67
|
-
lodash,
|
|
68
|
-
...require("./collections-graph"),
|
|
69
|
-
...require("./common"),
|
|
70
|
-
...require("./date"),
|
|
71
|
-
...require("./forEach"),
|
|
72
|
-
...require("./getValuesByPath"),
|
|
73
|
-
...require("./isValidFilter"),
|
|
74
|
-
...require("./json-templates"),
|
|
75
|
-
...require("./log"),
|
|
76
|
-
...require("./merge"),
|
|
77
|
-
...require("./notification"),
|
|
78
|
-
...require("./number"),
|
|
79
|
-
...require("./parse-filter"),
|
|
80
|
-
...require("./registry"),
|
|
81
|
-
...require("./isPortalInBody"),
|
|
82
|
-
...require("./uid"),
|
|
83
|
-
...require("./url"),
|
|
84
|
-
...require("./parseHTML"),
|
|
85
|
-
...require("./i18n")
|
|
86
|
-
});
|
|
@@ -1,24 +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
|
-
type BuildGraphOptions = {
|
|
10
|
-
direction?: 'forward' | 'reverse';
|
|
11
|
-
collections: any[];
|
|
12
|
-
};
|
|
13
|
-
export declare class CollectionsGraph {
|
|
14
|
-
static graphlib(): any;
|
|
15
|
-
static connectedNodes(options: BuildGraphOptions & {
|
|
16
|
-
nodes: Array<string>;
|
|
17
|
-
excludes?: Array<string>;
|
|
18
|
-
}): unknown[];
|
|
19
|
-
static preOrder(options: BuildGraphOptions & {
|
|
20
|
-
node: string;
|
|
21
|
-
}): any;
|
|
22
|
-
static build(options: BuildGraphOptions): any;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
package/lib/collections-graph.js
DELETED
|
@@ -1,108 +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 collections_graph_exports = {};
|
|
39
|
-
__export(collections_graph_exports, {
|
|
40
|
-
CollectionsGraph: () => CollectionsGraph
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(collections_graph_exports);
|
|
43
|
-
var graphlib = __toESM(require("graphlib"));
|
|
44
|
-
var import_lodash = require("lodash");
|
|
45
|
-
const _CollectionsGraph = class _CollectionsGraph {
|
|
46
|
-
static graphlib() {
|
|
47
|
-
return graphlib;
|
|
48
|
-
}
|
|
49
|
-
static connectedNodes(options) {
|
|
50
|
-
const nodes = (0, import_lodash.castArray)(options.nodes);
|
|
51
|
-
const excludes = (0, import_lodash.castArray)(options.excludes || []);
|
|
52
|
-
const graph = _CollectionsGraph.build(options);
|
|
53
|
-
const connectedNodes = /* @__PURE__ */ new Set();
|
|
54
|
-
for (const node of nodes) {
|
|
55
|
-
const connected = graphlib.alg.preorder(graph, node);
|
|
56
|
-
for (const connectedNode of connected) {
|
|
57
|
-
if (excludes.includes(connectedNode))
|
|
58
|
-
continue;
|
|
59
|
-
connectedNodes.add(connectedNode);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return Array.from(connectedNodes);
|
|
63
|
-
}
|
|
64
|
-
static preOrder(options) {
|
|
65
|
-
return _CollectionsGraph.graphlib().alg.preorder(_CollectionsGraph.build(options), options.node);
|
|
66
|
-
}
|
|
67
|
-
static build(options) {
|
|
68
|
-
const collections = options.collections;
|
|
69
|
-
const direction = (options == null ? void 0 : options.direction) || "forward";
|
|
70
|
-
const isForward = direction === "forward";
|
|
71
|
-
const graph = new graphlib.Graph();
|
|
72
|
-
for (const collection of collections) {
|
|
73
|
-
graph.setNode(collection.name);
|
|
74
|
-
}
|
|
75
|
-
for (const collection of collections) {
|
|
76
|
-
const parents = collection.inherits || [];
|
|
77
|
-
for (const parent of parents) {
|
|
78
|
-
if (isForward) {
|
|
79
|
-
graph.setEdge(collection.name, parent);
|
|
80
|
-
} else {
|
|
81
|
-
graph.setEdge(parent, collection.name);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
for (const field of collection.fields || []) {
|
|
85
|
-
if (field.type === "hasMany" || field.type === "belongsTo" || field.type === "hasOne") {
|
|
86
|
-
isForward ? graph.setEdge(collection.name, field.target) : graph.setEdge(field.target, collection.name);
|
|
87
|
-
}
|
|
88
|
-
if (field.type === "belongsToMany") {
|
|
89
|
-
const throughCollection = field.through;
|
|
90
|
-
if (isForward) {
|
|
91
|
-
graph.setEdge(collection.name, throughCollection);
|
|
92
|
-
graph.setEdge(throughCollection, field.target);
|
|
93
|
-
} else {
|
|
94
|
-
graph.setEdge(field.target, throughCollection);
|
|
95
|
-
graph.setEdge(throughCollection, collection.name);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return graph;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
__name(_CollectionsGraph, "CollectionsGraph");
|
|
104
|
-
let CollectionsGraph = _CollectionsGraph;
|
|
105
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
-
0 && (module.exports = {
|
|
107
|
-
CollectionsGraph
|
|
108
|
-
});
|
package/lib/common.d.ts
DELETED
|
@@ -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 isString: (value: any) => value is string;
|
|
10
|
-
export declare const isArray: (value: any) => value is any[];
|
|
11
|
-
export declare const isEmpty: (value: unknown) => boolean;
|
|
12
|
-
export declare const isPlainObject: (value: any) => boolean;
|
|
13
|
-
export declare const hasEmptyValue: (objOrArr: object | any[]) => any;
|
|
14
|
-
export declare const nextTick: (fn: () => void) => void;
|
package/lib/common.js
DELETED
|
@@ -1,87 +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 common_exports = {};
|
|
29
|
-
__export(common_exports, {
|
|
30
|
-
hasEmptyValue: () => hasEmptyValue,
|
|
31
|
-
isArray: () => isArray,
|
|
32
|
-
isEmpty: () => isEmpty,
|
|
33
|
-
isPlainObject: () => isPlainObject,
|
|
34
|
-
isString: () => isString,
|
|
35
|
-
nextTick: () => nextTick
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(common_exports);
|
|
38
|
-
const isString = /* @__PURE__ */ __name((value) => {
|
|
39
|
-
return typeof value === "string";
|
|
40
|
-
}, "isString");
|
|
41
|
-
const isArray = /* @__PURE__ */ __name((value) => {
|
|
42
|
-
return Array.isArray(value);
|
|
43
|
-
}, "isArray");
|
|
44
|
-
const isEmpty = /* @__PURE__ */ __name((value) => {
|
|
45
|
-
if (isPlainObject(value)) {
|
|
46
|
-
return Object.keys(value).length === 0;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
return value.length === 0;
|
|
50
|
-
}
|
|
51
|
-
return !value;
|
|
52
|
-
}, "isEmpty");
|
|
53
|
-
const isPlainObject = /* @__PURE__ */ __name((value) => {
|
|
54
|
-
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
const prototype = Object.getPrototypeOf(value);
|
|
58
|
-
return prototype === null || prototype === Object.prototype;
|
|
59
|
-
}, "isPlainObject");
|
|
60
|
-
const hasEmptyValue = /* @__PURE__ */ __name((objOrArr) => {
|
|
61
|
-
let result = true;
|
|
62
|
-
for (const key in objOrArr) {
|
|
63
|
-
result = false;
|
|
64
|
-
if (isArray(objOrArr[key]) && objOrArr[key].length === 0) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if (!objOrArr[key]) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
if (isPlainObject(objOrArr[key]) || isArray(objOrArr[key])) {
|
|
71
|
-
return hasEmptyValue(objOrArr[key]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}, "hasEmptyValue");
|
|
76
|
-
const nextTick = /* @__PURE__ */ __name((fn) => {
|
|
77
|
-
setTimeout(fn);
|
|
78
|
-
}, "nextTick");
|
|
79
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
-
0 && (module.exports = {
|
|
81
|
-
hasEmptyValue,
|
|
82
|
-
isArray,
|
|
83
|
-
isEmpty,
|
|
84
|
-
isPlainObject,
|
|
85
|
-
isString,
|
|
86
|
-
nextTick
|
|
87
|
-
});
|
package/lib/date.d.ts
DELETED
|
@@ -1,37 +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
|
-
import { dayjs } from './dayjs';
|
|
10
|
-
export interface Str2momentOptions {
|
|
11
|
-
gmt?: boolean;
|
|
12
|
-
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
13
|
-
utcOffset?: number;
|
|
14
|
-
utc?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export type Str2momentValue = string | string[] | dayjs.Dayjs | dayjs.Dayjs[];
|
|
17
|
-
export interface GetDefaultFormatProps {
|
|
18
|
-
format?: string;
|
|
19
|
-
dateFormat?: string;
|
|
20
|
-
timeFormat?: string;
|
|
21
|
-
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
22
|
-
showTime?: boolean;
|
|
23
|
-
}
|
|
24
|
-
export declare const getDefaultFormat: (props: GetDefaultFormatProps) => string;
|
|
25
|
-
export declare const toGmt: (value: dayjs.Dayjs) => string | dayjs.Dayjs;
|
|
26
|
-
export declare const toLocal: (value: dayjs.Dayjs) => string | any[] | dayjs.Dayjs;
|
|
27
|
-
export declare const str2moment: (value?: string | string[] | dayjs.Dayjs | dayjs.Dayjs[], options?: Str2momentOptions) => any;
|
|
28
|
-
export interface Moment2strOptions {
|
|
29
|
-
showTime?: boolean;
|
|
30
|
-
gmt?: boolean;
|
|
31
|
-
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
32
|
-
}
|
|
33
|
-
export declare const moment2str: (value?: dayjs.Dayjs, options?: Moment2strOptions) => string | any[] | dayjs.Dayjs;
|
|
34
|
-
/**
|
|
35
|
-
* from https://github.com/moment/moment/blob/dca02edaeceda3fcd52b20b51c130631a058a022/src/lib/units/offset.js#L55-L70
|
|
36
|
-
*/
|
|
37
|
-
export declare function offsetFromString(string: string | number): number;
|