@tachybase/utils 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -0
- package/LICENSE +201 -0
- package/lib/assign.d.ts +9 -0
- package/lib/assign.js +136 -0
- package/lib/client.d.ts +21 -0
- package/lib/client.js +77 -0
- package/lib/cluster.d.ts +2 -0
- package/lib/cluster.js +39 -0
- package/lib/collections-graph.d.ts +16 -0
- package/lib/collections-graph.js +98 -0
- package/lib/common.d.ts +7 -0
- package/lib/common.js +98 -0
- package/lib/currencyUtils.d.ts +44 -0
- package/lib/currencyUtils.js +75 -0
- package/lib/date.d.ts +22 -0
- package/lib/date.js +186 -0
- package/lib/dayjs.d.ts +10 -0
- package/lib/dayjs.js +73 -0
- package/lib/decorators.d.ts +16 -0
- package/lib/decorators.js +94 -0
- package/lib/dom.d.ts +4 -0
- package/lib/dom.js +52 -0
- package/lib/forEach.d.ts +1 -0
- package/lib/forEach.js +36 -0
- package/lib/fs-exists.d.ts +1 -0
- package/lib/fs-exists.js +37 -0
- package/lib/getCurrentStacks.d.ts +1 -0
- package/lib/getCurrentStacks.js +35 -0
- package/lib/getValuesByPath.d.ts +1 -0
- package/lib/getValuesByPath.js +62 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +97 -0
- package/lib/isPortalInBody.d.ts +5 -0
- package/lib/isPortalInBody.js +45 -0
- package/lib/json-templates.d.ts +1 -0
- package/lib/json-templates.js +145 -0
- package/lib/koa-multer.d.ts +6 -0
- package/lib/koa-multer.js +83 -0
- package/lib/log.d.ts +1 -0
- package/lib/log.js +30 -0
- package/lib/measure-execution-time.d.ts +1 -0
- package/lib/measure-execution-time.js +35 -0
- package/lib/merge.d.ts +1 -0
- package/lib/merge.js +46 -0
- package/lib/mixin/AsyncEmitter.d.ts +3 -0
- package/lib/mixin/AsyncEmitter.js +73 -0
- package/lib/mixin/index.d.ts +1 -0
- package/lib/mixin/index.js +39 -0
- package/lib/notification.d.ts +1 -0
- package/lib/notification.js +34 -0
- package/lib/number.d.ts +1 -0
- package/lib/number.js +36 -0
- package/lib/parse-date.d.ts +3 -0
- package/lib/parse-date.js +237 -0
- package/lib/parse-filter.d.ts +146 -0
- package/lib/parse-filter.js +305 -0
- package/lib/parseHTML.d.ts +7 -0
- package/lib/parseHTML.js +33 -0
- package/lib/perf-hooks.d.ts +6 -0
- package/lib/perf-hooks.js +60 -0
- package/lib/plugin-symlink.d.ts +4 -0
- package/lib/plugin-symlink.js +131 -0
- package/lib/registry.d.ts +14 -0
- package/lib/registry.js +60 -0
- package/lib/requireModule.d.ts +3 -0
- package/lib/requireModule.js +64 -0
- package/lib/toposort.d.ts +13 -0
- package/lib/toposort.js +90 -0
- package/lib/typedi/container-instance.class.d.ts +109 -0
- package/lib/typedi/container-instance.class.js +349 -0
- package/lib/typedi/container-registry.class.d.ts +51 -0
- package/lib/typedi/container-registry.class.js +97 -0
- package/lib/typedi/decorators/inject-many.decorator.d.ts +8 -0
- package/lib/typedi/decorators/inject-many.decorator.js +56 -0
- package/lib/typedi/decorators/inject.decorator.d.ts +9 -0
- package/lib/typedi/decorators/inject.decorator.js +56 -0
- package/lib/typedi/decorators/service.decorator.d.ts +6 -0
- package/lib/typedi/decorators/service.decorator.js +49 -0
- package/lib/typedi/empty.const.d.ts +6 -0
- package/lib/typedi/empty.const.js +27 -0
- package/lib/typedi/error/cannot-inject-value.error.d.ts +11 -0
- package/lib/typedi/error/cannot-inject-value.error.js +40 -0
- package/lib/typedi/error/cannot-instantiate-value.error.d.ts +11 -0
- package/lib/typedi/error/cannot-instantiate-value.error.js +49 -0
- package/lib/typedi/error/service-not-found.error.d.ts +11 -0
- package/lib/typedi/error/service-not-found.error.js +49 -0
- package/lib/typedi/index.d.ts +17 -0
- package/lib/typedi/index.js +64 -0
- package/lib/typedi/interfaces/container-options.interface.d.ts +45 -0
- package/lib/typedi/interfaces/container-options.interface.js +15 -0
- package/lib/typedi/interfaces/handler.interface.d.ts +27 -0
- package/lib/typedi/interfaces/handler.interface.js +15 -0
- package/lib/typedi/interfaces/service-metadata.interface.d.ts +53 -0
- package/lib/typedi/interfaces/service-metadata.interface.js +15 -0
- package/lib/typedi/interfaces/service-options.interface.d.ts +6 -0
- package/lib/typedi/interfaces/service-options.interface.js +15 -0
- package/lib/typedi/token.class.d.ts +11 -0
- package/lib/typedi/token.class.js +37 -0
- package/lib/typedi/types/abstract-constructable.type.d.ts +9 -0
- package/lib/typedi/types/abstract-constructable.type.js +15 -0
- package/lib/typedi/types/constructable.type.d.ts +10 -0
- package/lib/typedi/types/constructable.type.js +15 -0
- package/lib/typedi/types/container-identifier.type.d.ts +4 -0
- package/lib/typedi/types/container-identifier.type.js +15 -0
- package/lib/typedi/types/container-scope.type.d.ts +1 -0
- package/lib/typedi/types/container-scope.type.js +15 -0
- package/lib/typedi/types/service-identifier.type.d.ts +8 -0
- package/lib/typedi/types/service-identifier.type.js +15 -0
- package/lib/typedi/utils/resolve-to-type-wrapper.util.d.ts +15 -0
- package/lib/typedi/utils/resolve-to-type-wrapper.util.js +39 -0
- package/lib/uid.d.ts +1 -0
- package/lib/uid.js +35 -0
- package/lib/url.d.ts +1 -0
- package/lib/url.js +37 -0
- package/package.json +49 -0
- package/tsconfig.json +31 -0
package/lib/common.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var common_exports = {};
|
|
20
|
+
__export(common_exports, {
|
|
21
|
+
fuzzysearch: () => fuzzysearch,
|
|
22
|
+
hasEmptyValue: () => hasEmptyValue,
|
|
23
|
+
isArray: () => isArray,
|
|
24
|
+
isEmpty: () => isEmpty,
|
|
25
|
+
isPlainObject: () => isPlainObject,
|
|
26
|
+
isString: () => isString,
|
|
27
|
+
nextTick: () => nextTick
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(common_exports);
|
|
30
|
+
const isString = /* @__PURE__ */ __name((value) => {
|
|
31
|
+
return typeof value === "string";
|
|
32
|
+
}, "isString");
|
|
33
|
+
const isArray = /* @__PURE__ */ __name((value) => {
|
|
34
|
+
return Array.isArray(value);
|
|
35
|
+
}, "isArray");
|
|
36
|
+
const isEmpty = /* @__PURE__ */ __name((value) => {
|
|
37
|
+
if (isPlainObject(value)) {
|
|
38
|
+
return Object.keys(value).length === 0;
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
return value.length === 0;
|
|
42
|
+
}
|
|
43
|
+
return !value;
|
|
44
|
+
}, "isEmpty");
|
|
45
|
+
const isPlainObject = /* @__PURE__ */ __name((value) => {
|
|
46
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const prototype = Object.getPrototypeOf(value);
|
|
50
|
+
return prototype === null || prototype === Object.prototype;
|
|
51
|
+
}, "isPlainObject");
|
|
52
|
+
const hasEmptyValue = /* @__PURE__ */ __name((objOrArr) => {
|
|
53
|
+
let result = true;
|
|
54
|
+
for (const key in objOrArr) {
|
|
55
|
+
result = false;
|
|
56
|
+
if (isArray(objOrArr[key]) && objOrArr[key].length === 0) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (!objOrArr[key]) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (isPlainObject(objOrArr[key]) || isArray(objOrArr[key])) {
|
|
63
|
+
return hasEmptyValue(objOrArr[key]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}, "hasEmptyValue");
|
|
68
|
+
const nextTick = /* @__PURE__ */ __name((fn) => {
|
|
69
|
+
setTimeout(fn);
|
|
70
|
+
}, "nextTick");
|
|
71
|
+
function fuzzysearch(needle, haystack) {
|
|
72
|
+
const hlen = haystack.length;
|
|
73
|
+
const nlen = needle.length;
|
|
74
|
+
if (nlen === hlen) {
|
|
75
|
+
return needle === haystack;
|
|
76
|
+
}
|
|
77
|
+
outer: for (let i = 0, j = 0; i < nlen; i++) {
|
|
78
|
+
const nch = needle.charCodeAt(i);
|
|
79
|
+
while (j < hlen) {
|
|
80
|
+
if (haystack.charCodeAt(j++) === nch) {
|
|
81
|
+
continue outer;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
__name(fuzzysearch, "fuzzysearch");
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
fuzzysearch,
|
|
92
|
+
hasEmptyValue,
|
|
93
|
+
isArray,
|
|
94
|
+
isEmpty,
|
|
95
|
+
isPlainObject,
|
|
96
|
+
isString,
|
|
97
|
+
nextTick
|
|
98
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare enum FormatType {
|
|
2
|
+
/**
|
|
3
|
+
* 金额
|
|
4
|
+
*/
|
|
5
|
+
currency = "currency",
|
|
6
|
+
/**
|
|
7
|
+
* 百分比
|
|
8
|
+
*/
|
|
9
|
+
percent = "percent",
|
|
10
|
+
/**
|
|
11
|
+
* 数量
|
|
12
|
+
*/
|
|
13
|
+
quantity = "quantity"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 格式化数字,支持金额、百分比、数量等
|
|
17
|
+
* @param _number 数字
|
|
18
|
+
* @param fractionDigits 保留位数
|
|
19
|
+
* @param formatType 格式化类型: 'currency' | 'percent' | 'quantity' / 金额,百分比,数量
|
|
20
|
+
* @returns 格式化后的字符串
|
|
21
|
+
*/
|
|
22
|
+
declare const format: (_number: number, fractionDigits: number, formatType: FormatType) => string;
|
|
23
|
+
/**
|
|
24
|
+
* 计算金额
|
|
25
|
+
* @param number 金额
|
|
26
|
+
* @param fractionDigits 需要保留的位数
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export declare const formatCurrency: (number: number, fractionDigits: number) => string;
|
|
30
|
+
/**
|
|
31
|
+
*计算百分比
|
|
32
|
+
* @param number 需要转化的百分比
|
|
33
|
+
* @param fractionDigits 保留位数
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatPercent: (number: number, fractionDigits: number) => string;
|
|
37
|
+
/**
|
|
38
|
+
* 计算数量
|
|
39
|
+
* @param number 数字
|
|
40
|
+
* @param fractionDigits 需要保留的位数
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare const formatQuantity: (number: number, fractionDigits?: number) => string;
|
|
44
|
+
export default format;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var currencyUtils_exports = {};
|
|
20
|
+
__export(currencyUtils_exports, {
|
|
21
|
+
FormatType: () => FormatType,
|
|
22
|
+
default: () => currencyUtils_default,
|
|
23
|
+
formatCurrency: () => formatCurrency,
|
|
24
|
+
formatPercent: () => formatPercent,
|
|
25
|
+
formatQuantity: () => formatQuantity
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(currencyUtils_exports);
|
|
28
|
+
var FormatType = /* @__PURE__ */ ((FormatType2) => {
|
|
29
|
+
FormatType2["currency"] = "currency";
|
|
30
|
+
FormatType2["percent"] = "percent";
|
|
31
|
+
FormatType2["quantity"] = "quantity";
|
|
32
|
+
return FormatType2;
|
|
33
|
+
})(FormatType || {});
|
|
34
|
+
const format = /* @__PURE__ */ __name((_number, fractionDigits, formatType) => {
|
|
35
|
+
const number = typeof _number === "undefined" || Number.isNaN(_number) ? 0 : _number;
|
|
36
|
+
let style;
|
|
37
|
+
let currency;
|
|
38
|
+
switch (formatType) {
|
|
39
|
+
case "currency":
|
|
40
|
+
style = "currency";
|
|
41
|
+
currency = "CNY";
|
|
42
|
+
break;
|
|
43
|
+
case "percent":
|
|
44
|
+
style = "percent";
|
|
45
|
+
break;
|
|
46
|
+
case "quantity":
|
|
47
|
+
style = "decimal";
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
throw new Error('Invalid formatType. Supported values are "currency", "percent", and "quantity".');
|
|
51
|
+
}
|
|
52
|
+
const options = {
|
|
53
|
+
style,
|
|
54
|
+
currency,
|
|
55
|
+
minimumFractionDigits: fractionDigits,
|
|
56
|
+
maximumFractionDigits: fractionDigits
|
|
57
|
+
};
|
|
58
|
+
const numberFormat = new Intl.NumberFormat("zh-CN", options);
|
|
59
|
+
return numberFormat.format(number);
|
|
60
|
+
}, "format");
|
|
61
|
+
const formatCurrency = /* @__PURE__ */ __name((number, fractionDigits) => format(number, fractionDigits, "currency" /* currency */), "formatCurrency");
|
|
62
|
+
const formatPercent = /* @__PURE__ */ __name((number, fractionDigits) => format(number, fractionDigits, "percent" /* percent */), "formatPercent");
|
|
63
|
+
const formatQuantity = /* @__PURE__ */ __name((number, fractionDigits = 2) => format(number, fractionDigits, "quantity" /* quantity */), "formatQuantity");
|
|
64
|
+
var currencyUtils_default = format;
|
|
65
|
+
function _isDecimal(num) {
|
|
66
|
+
return Number.isFinite(num) && !Number.isInteger(num);
|
|
67
|
+
}
|
|
68
|
+
__name(_isDecimal, "_isDecimal");
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
FormatType,
|
|
72
|
+
formatCurrency,
|
|
73
|
+
formatPercent,
|
|
74
|
+
formatQuantity
|
|
75
|
+
});
|
package/lib/date.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dayjs } from './dayjs';
|
|
2
|
+
export interface Str2momentOptions {
|
|
3
|
+
gmt?: boolean;
|
|
4
|
+
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
5
|
+
utcOffset?: any;
|
|
6
|
+
utc?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const getDefaultFormat: (props: any) => any;
|
|
9
|
+
export declare const toGmt: (value: dayjs.Dayjs) => string | dayjs.Dayjs;
|
|
10
|
+
export declare const toLocal: (value: dayjs.Dayjs) => string | any[] | dayjs.Dayjs;
|
|
11
|
+
export declare const convertUTCToLocal: (utcString: any, formater?: string) => string;
|
|
12
|
+
export declare const str2moment: (value?: string | string[], options?: Str2momentOptions) => any;
|
|
13
|
+
export interface Moment2strOptions {
|
|
14
|
+
showTime?: boolean;
|
|
15
|
+
gmt?: boolean;
|
|
16
|
+
picker?: 'year' | 'month' | 'week' | 'quarter';
|
|
17
|
+
}
|
|
18
|
+
export declare const moment2str: (value?: dayjs.Dayjs, options?: Moment2strOptions) => string | any[] | dayjs.Dayjs;
|
|
19
|
+
/**
|
|
20
|
+
* from https://github.com/moment/moment/blob/dca02edaeceda3fcd52b20b51c130631a058a022/src/lib/units/offset.js#L55-L70
|
|
21
|
+
*/
|
|
22
|
+
export declare function offsetFromString(string: string | number): number;
|
package/lib/date.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var date_exports = {};
|
|
30
|
+
__export(date_exports, {
|
|
31
|
+
convertUTCToLocal: () => convertUTCToLocal,
|
|
32
|
+
getDefaultFormat: () => getDefaultFormat,
|
|
33
|
+
moment2str: () => moment2str,
|
|
34
|
+
offsetFromString: () => offsetFromString,
|
|
35
|
+
str2moment: () => str2moment,
|
|
36
|
+
toGmt: () => toGmt,
|
|
37
|
+
toLocal: () => toLocal
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(date_exports);
|
|
40
|
+
var import_lodash = __toESM(require("lodash"));
|
|
41
|
+
var import_dayjs = require("./dayjs");
|
|
42
|
+
const getDefaultFormat = /* @__PURE__ */ __name((props) => {
|
|
43
|
+
if (props.format) {
|
|
44
|
+
return props.format;
|
|
45
|
+
}
|
|
46
|
+
if (props.dateFormat) {
|
|
47
|
+
if (props["showTime"]) {
|
|
48
|
+
return `${props.dateFormat} ${props.timeFormat || "HH:mm:ss"}`;
|
|
49
|
+
}
|
|
50
|
+
return props.dateFormat;
|
|
51
|
+
}
|
|
52
|
+
if (props["picker"] === "month") {
|
|
53
|
+
return "YYYY-MM";
|
|
54
|
+
} else if (props["picker"] === "quarter") {
|
|
55
|
+
return "YYYY-\\QQ";
|
|
56
|
+
} else if (props["picker"] === "year") {
|
|
57
|
+
return "YYYY";
|
|
58
|
+
} else if (props["picker"] === "week") {
|
|
59
|
+
return "YYYY-wo";
|
|
60
|
+
}
|
|
61
|
+
return props["showTime"] ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
|
|
62
|
+
}, "getDefaultFormat");
|
|
63
|
+
const toGmt = /* @__PURE__ */ __name((value) => {
|
|
64
|
+
if (!value || !import_dayjs.dayjs.isDayjs(value)) {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
return `${value.format("YYYY-MM-DD")}T${value.format("HH:mm:ss.SSS")}Z`;
|
|
68
|
+
}, "toGmt");
|
|
69
|
+
const toLocal = /* @__PURE__ */ __name((value) => {
|
|
70
|
+
if (!value) {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value)) {
|
|
74
|
+
return value.map((val) => val.startOf("second").toISOString());
|
|
75
|
+
}
|
|
76
|
+
if (import_dayjs.dayjs.isDayjs(value)) {
|
|
77
|
+
return value.startOf("second").toISOString();
|
|
78
|
+
}
|
|
79
|
+
}, "toLocal");
|
|
80
|
+
const convertUTCToLocal = /* @__PURE__ */ __name((utcString, formater = "YYYY-MM-DD HH:mm:ss") => {
|
|
81
|
+
const localDate = import_dayjs.dayjs.utc(utcString).local().format(formater);
|
|
82
|
+
return localDate;
|
|
83
|
+
}, "convertUTCToLocal");
|
|
84
|
+
const toMoment = /* @__PURE__ */ __name((val, options) => {
|
|
85
|
+
if (!val) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const offset = options.utcOffset || -1 * (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
89
|
+
const { gmt, picker, utc = true } = options;
|
|
90
|
+
if (!utc) {
|
|
91
|
+
return (0, import_dayjs.dayjs)(val);
|
|
92
|
+
}
|
|
93
|
+
if (import_dayjs.dayjs.isDayjs(val)) {
|
|
94
|
+
return val.utcOffset(offsetFromString(offset));
|
|
95
|
+
}
|
|
96
|
+
if (gmt || picker) {
|
|
97
|
+
return (0, import_dayjs.dayjs)(val).utcOffset(0);
|
|
98
|
+
}
|
|
99
|
+
return (0, import_dayjs.dayjs)(val).utcOffset(offsetFromString(offset));
|
|
100
|
+
}, "toMoment");
|
|
101
|
+
const str2moment = /* @__PURE__ */ __name((value, options = {}) => {
|
|
102
|
+
return Array.isArray(value) ? value.map((val) => {
|
|
103
|
+
return toMoment(val, options);
|
|
104
|
+
}) : value ? toMoment(value, options) : value;
|
|
105
|
+
}, "str2moment");
|
|
106
|
+
const toStringByPicker = /* @__PURE__ */ __name((value, picker) => {
|
|
107
|
+
if (picker === "year") {
|
|
108
|
+
return value.format("YYYY") + "-01-01T00:00:00.000Z";
|
|
109
|
+
}
|
|
110
|
+
if (picker === "month") {
|
|
111
|
+
return value.format("YYYY-MM") + "-01T00:00:00.000Z";
|
|
112
|
+
}
|
|
113
|
+
if (picker === "quarter") {
|
|
114
|
+
return value.format("YYYY-MM") + "-01T00:00:00.000Z";
|
|
115
|
+
}
|
|
116
|
+
if (picker === "week") {
|
|
117
|
+
return value.format("YYYY-MM-DD") + "T00:00:00.000Z";
|
|
118
|
+
}
|
|
119
|
+
return value.format("YYYY-MM-DD") + "T00:00:00.000Z";
|
|
120
|
+
}, "toStringByPicker");
|
|
121
|
+
const toGmtByPicker = /* @__PURE__ */ __name((value, picker) => {
|
|
122
|
+
if (!value) {
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
return value.map((val) => toStringByPicker(val, picker));
|
|
127
|
+
}
|
|
128
|
+
if (import_dayjs.dayjs.isDayjs(value)) {
|
|
129
|
+
return toStringByPicker(value, picker);
|
|
130
|
+
}
|
|
131
|
+
}, "toGmtByPicker");
|
|
132
|
+
const moment2str = /* @__PURE__ */ __name((value, options = {}) => {
|
|
133
|
+
const { showTime, gmt, picker } = options;
|
|
134
|
+
if (!value) {
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
if (showTime) {
|
|
138
|
+
return gmt ? toGmt(value) : toLocal(value);
|
|
139
|
+
}
|
|
140
|
+
return toGmtByPicker(value, picker);
|
|
141
|
+
}, "moment2str");
|
|
142
|
+
function offsetFromString(string) {
|
|
143
|
+
if (!import_lodash.default.isString(string)) {
|
|
144
|
+
return string;
|
|
145
|
+
}
|
|
146
|
+
const chunkOffset = /([+-]|\d\d)/gi;
|
|
147
|
+
const matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, matchTimestamp = /[+-]?\d+(\.\d{1,3})?/;
|
|
148
|
+
let matches = (string || "").match(matchShortOffset);
|
|
149
|
+
if (matches === null) {
|
|
150
|
+
matches = (string || "").match(matchTimestamp);
|
|
151
|
+
}
|
|
152
|
+
if (matches === null) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const chunk = matches[matches.length - 1] || [];
|
|
156
|
+
const parts = (chunk + "").match(chunkOffset) || ["-", 0, 0];
|
|
157
|
+
const minutes = +(Number(parts[1]) * 60) + toInt(parts[2]);
|
|
158
|
+
return minutes === 0 ? 0 : parts[0] === "+" ? minutes : -minutes;
|
|
159
|
+
}
|
|
160
|
+
__name(offsetFromString, "offsetFromString");
|
|
161
|
+
function toInt(argumentForCoercion) {
|
|
162
|
+
let coercedNumber = +argumentForCoercion, value = 0;
|
|
163
|
+
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
|
164
|
+
value = absFloor(coercedNumber);
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
__name(toInt, "toInt");
|
|
169
|
+
function absFloor(number) {
|
|
170
|
+
if (number < 0) {
|
|
171
|
+
return Math.ceil(number) || 0;
|
|
172
|
+
} else {
|
|
173
|
+
return Math.floor(number);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
__name(absFloor, "absFloor");
|
|
177
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
178
|
+
0 && (module.exports = {
|
|
179
|
+
convertUTCToLocal,
|
|
180
|
+
getDefaultFormat,
|
|
181
|
+
moment2str,
|
|
182
|
+
offsetFromString,
|
|
183
|
+
str2moment,
|
|
184
|
+
toGmt,
|
|
185
|
+
toLocal
|
|
186
|
+
});
|
package/lib/dayjs.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import dayjs, { type Dayjs } from 'dayjs';
|
|
2
|
+
import 'dayjs/plugin/isBetween';
|
|
3
|
+
import 'dayjs/plugin/isSameOrAfter';
|
|
4
|
+
import 'dayjs/plugin/isSameOrBefore';
|
|
5
|
+
import 'dayjs/plugin/isoWeek';
|
|
6
|
+
import 'dayjs/plugin/localeData';
|
|
7
|
+
import 'dayjs/plugin/quarterOfYear';
|
|
8
|
+
import 'dayjs/plugin/utc';
|
|
9
|
+
import 'dayjs/plugin/weekday';
|
|
10
|
+
export { dayjs, Dayjs };
|
package/lib/dayjs.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var dayjs_exports = {};
|
|
29
|
+
__export(dayjs_exports, {
|
|
30
|
+
dayjs: () => import_dayjs.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(dayjs_exports);
|
|
33
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
34
|
+
var import_advancedFormat = __toESM(require("dayjs/plugin/advancedFormat"));
|
|
35
|
+
var import_calendar = __toESM(require("dayjs/plugin/calendar"));
|
|
36
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
37
|
+
var import_isBetween = __toESM(require("dayjs/plugin/isBetween"));
|
|
38
|
+
var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
|
|
39
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
40
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
41
|
+
var import_localeData = __toESM(require("dayjs/plugin/localeData"));
|
|
42
|
+
var import_quarterOfYear = __toESM(require("dayjs/plugin/quarterOfYear"));
|
|
43
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
44
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
45
|
+
var import_weekday = __toESM(require("dayjs/plugin/weekday"));
|
|
46
|
+
var import_weekOfYear = __toESM(require("dayjs/plugin/weekOfYear"));
|
|
47
|
+
var import_weekYear = __toESM(require("dayjs/plugin/weekYear"));
|
|
48
|
+
var import_isBetween2 = require("dayjs/plugin/isBetween");
|
|
49
|
+
var import_isSameOrAfter2 = require("dayjs/plugin/isSameOrAfter");
|
|
50
|
+
var import_isSameOrBefore2 = require("dayjs/plugin/isSameOrBefore");
|
|
51
|
+
var import_isoWeek2 = require("dayjs/plugin/isoWeek");
|
|
52
|
+
var import_localeData2 = require("dayjs/plugin/localeData");
|
|
53
|
+
var import_quarterOfYear2 = require("dayjs/plugin/quarterOfYear");
|
|
54
|
+
var import_utc2 = require("dayjs/plugin/utc");
|
|
55
|
+
var import_weekday2 = require("dayjs/plugin/weekday");
|
|
56
|
+
import_dayjs.default.extend(import_weekday.default);
|
|
57
|
+
import_dayjs.default.extend(import_localeData.default);
|
|
58
|
+
import_dayjs.default.extend(import_timezone.default);
|
|
59
|
+
import_dayjs.default.extend(import_utc.default);
|
|
60
|
+
import_dayjs.default.extend(import_quarterOfYear.default);
|
|
61
|
+
import_dayjs.default.extend(import_isoWeek.default);
|
|
62
|
+
import_dayjs.default.extend(import_isBetween.default);
|
|
63
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
64
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
65
|
+
import_dayjs.default.extend(import_weekOfYear.default);
|
|
66
|
+
import_dayjs.default.extend(import_weekYear.default);
|
|
67
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
68
|
+
import_dayjs.default.extend(import_advancedFormat.default);
|
|
69
|
+
import_dayjs.default.extend(import_calendar.default);
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
dayjs
|
|
73
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ActionDef {
|
|
2
|
+
type: string;
|
|
3
|
+
resourceName?: string;
|
|
4
|
+
actionName?: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
options?: {
|
|
7
|
+
acl?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function App(): Function;
|
|
11
|
+
export declare function Db(): Function;
|
|
12
|
+
export declare function InjectLog(): Function;
|
|
13
|
+
export declare function Controller(name: string): (target: any, context: ClassDecoratorContext) => void;
|
|
14
|
+
export declare function Action(name: string, options?: {
|
|
15
|
+
acl?: string;
|
|
16
|
+
}): (_: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var decorators_exports = {};
|
|
30
|
+
__export(decorators_exports, {
|
|
31
|
+
Action: () => Action,
|
|
32
|
+
App: () => App,
|
|
33
|
+
Controller: () => Controller,
|
|
34
|
+
Db: () => Db,
|
|
35
|
+
InjectLog: () => InjectLog
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(decorators_exports);
|
|
38
|
+
var import_typedi = __toESM(require("./typedi"));
|
|
39
|
+
import_typedi.default.set({ id: "actions", value: /* @__PURE__ */ new Map() });
|
|
40
|
+
function App() {
|
|
41
|
+
return (0, import_typedi.Inject)("app");
|
|
42
|
+
}
|
|
43
|
+
__name(App, "App");
|
|
44
|
+
function Db() {
|
|
45
|
+
return (0, import_typedi.Inject)("db");
|
|
46
|
+
}
|
|
47
|
+
__name(Db, "Db");
|
|
48
|
+
function InjectLog() {
|
|
49
|
+
return (0, import_typedi.Inject)("logger");
|
|
50
|
+
}
|
|
51
|
+
__name(InjectLog, "InjectLog");
|
|
52
|
+
function Controller(name) {
|
|
53
|
+
return function(target, context) {
|
|
54
|
+
const serviceOptions = { id: "controller", multiple: true };
|
|
55
|
+
(0, import_typedi.Service)(serviceOptions)(target, context);
|
|
56
|
+
const actions = import_typedi.default.get("actions");
|
|
57
|
+
if (!actions.has(target)) {
|
|
58
|
+
actions.set(target, []);
|
|
59
|
+
}
|
|
60
|
+
actions.get(target).push({
|
|
61
|
+
type: "resource",
|
|
62
|
+
resourceName: name
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
__name(Controller, "Controller");
|
|
67
|
+
function Action(name, options) {
|
|
68
|
+
return function(_, context) {
|
|
69
|
+
if (!context.metadata.injects) {
|
|
70
|
+
context.metadata.injects = [];
|
|
71
|
+
}
|
|
72
|
+
context.metadata.injects.push((target) => {
|
|
73
|
+
const actions = import_typedi.default.get("actions");
|
|
74
|
+
if (!actions.has(target)) {
|
|
75
|
+
actions.set(target, []);
|
|
76
|
+
}
|
|
77
|
+
actions.get(target).push({
|
|
78
|
+
type: "action",
|
|
79
|
+
method: String(context.name),
|
|
80
|
+
actionName: name,
|
|
81
|
+
options
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
__name(Action, "Action");
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
Action,
|
|
90
|
+
App,
|
|
91
|
+
Controller,
|
|
92
|
+
Db,
|
|
93
|
+
InjectLog
|
|
94
|
+
});
|
package/lib/dom.d.ts
ADDED
package/lib/dom.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var dom_exports = {};
|
|
20
|
+
__export(dom_exports, {
|
|
21
|
+
canUseDom: () => canUseDom,
|
|
22
|
+
getScrollParent: () => getScrollParent
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(dom_exports);
|
|
25
|
+
const canUseDom = !!(typeof window !== "undefined" && typeof document !== "undefined" && window.document && window.document.createElement);
|
|
26
|
+
const defaultRoot = canUseDom ? window : void 0;
|
|
27
|
+
const overflowStylePatterns = ["scroll", "auto", "overlay"];
|
|
28
|
+
function isElement(node) {
|
|
29
|
+
const ELEMENT_NODE_TYPE = 1;
|
|
30
|
+
return node.nodeType === ELEMENT_NODE_TYPE;
|
|
31
|
+
}
|
|
32
|
+
__name(isElement, "isElement");
|
|
33
|
+
function getScrollParent(el, root = defaultRoot) {
|
|
34
|
+
let node = el;
|
|
35
|
+
while (node && node !== root && isElement(node)) {
|
|
36
|
+
if (node === document.body) {
|
|
37
|
+
return root;
|
|
38
|
+
}
|
|
39
|
+
const { overflowY } = window.getComputedStyle(node);
|
|
40
|
+
if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
node = node.parentNode;
|
|
44
|
+
}
|
|
45
|
+
return root;
|
|
46
|
+
}
|
|
47
|
+
__name(getScrollParent, "getScrollParent");
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
canUseDom,
|
|
51
|
+
getScrollParent
|
|
52
|
+
});
|
package/lib/forEach.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const forEach: (obj: any, callback: (value: any, key: string | number) => void) => void;
|