@gct-paas/render 0.1.4-dev.7 → 0.1.4-dev.9
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/dist/index.esm.min.mjs +7684 -15
- package/dist/index.min.cjs +9 -1
- package/dist/index.system.min.js +9 -1
- package/es/Event/Dependency/controller.d.ts +13 -0
- package/es/Event/Dependency/controller.mjs +97 -0
- package/es/Event/Dependency/displayRule.d.ts +19 -0
- package/es/Event/Dependency/displayRule.mjs +76 -0
- package/es/Event/Dependency/useDependency.d.ts +7 -0
- package/es/Event/Dependency/useDependencyToShow.d.ts +10 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +109 -0
- package/es/Event/baseEvent.d.ts +160 -0
- package/es/Event/baseEvent.mjs +445 -0
- package/es/Event/bizServiceRequest.d.ts +26 -0
- package/es/Event/bizServiceRequest.mjs +47 -0
- package/es/Event/eventType.d.ts +20 -0
- package/es/Event/index.d.ts +4 -0
- package/es/Event/utils/appRedis.d.ts +29 -0
- package/es/Event/utils/appRedis.mjs +50 -0
- package/es/Event/utils/processRovedInfo.d.ts +100 -0
- package/es/Event/utils/processRovedInfo.mjs +297 -0
- package/es/Event/utils/runGlobalByPage.d.ts +332 -0
- package/es/Event/utils/runGlobalByPage.mjs +306 -0
- package/es/Event/utils/verificationVar.d.ts +2 -0
- package/es/Event/utils/verificationVar.mjs +42 -0
- package/es/enums/index.d.ts +14 -0
- package/es/enums/index.mjs +6 -0
- package/es/hooks/useStorageRef.d.ts +9 -0
- package/es/hooks/useStorageRef.mjs +33 -0
- package/es/index.d.ts +2 -0
- package/es/index.mjs +22 -0
- package/es/register/index.d.ts +1 -0
- package/es/register/render-register/render-register.d.ts +54 -0
- package/es/register/render-register/render-register.mjs +59 -0
- package/es/types/index.d.ts +6 -0
- package/es/utils/cacheAdapter.d.ts +7 -0
- package/es/utils/cacheAdapter.mjs +57 -0
- package/es/utils/expression/index.d.ts +6 -0
- package/es/utils/expression/index.mjs +133 -0
- package/es/utils/expression/regularExpression/methods.d.ts +77 -0
- package/es/utils/expression/regularExpression/methods.mjs +729 -0
- package/es/utils/field-attrs/index.d.ts +1 -1
- package/es/utils/get-ref-data.d.ts +1 -0
- package/es/utils/get-ref-data.mjs +62 -0
- package/es/utils/getFieldSchema.d.ts +1 -3
- package/es/utils/getFieldSchema.mjs +83 -0
- package/es/utils/index.d.ts +5 -0
- package/es/utils/model-transformer.d.ts +46 -0
- package/es/utils/model-transformer.mjs +77 -0
- package/es/utils/useStyle.d.ts +21 -0
- package/es/utils/useStyle.mjs +17 -0
- package/package.json +26 -6
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { isEqual, isNull, isUndefined } from 'lodash-es';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import utc from 'dayjs/plugin/utc';
|
|
4
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
5
|
+
import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
6
|
+
import toArray from 'dayjs/plugin/toArray';
|
|
7
|
+
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
8
|
+
import BigNumberJS from 'bignumber.js';
|
|
9
|
+
|
|
10
|
+
dayjs.extend(utc);
|
|
11
|
+
dayjs.extend(timezone);
|
|
12
|
+
dayjs.extend(quarterOfYear);
|
|
13
|
+
dayjs.extend(toArray);
|
|
14
|
+
dayjs.extend(isoWeek);
|
|
15
|
+
function IF(expr, v, l) {
|
|
16
|
+
const fn = () => {
|
|
17
|
+
return expr ? v : l;
|
|
18
|
+
};
|
|
19
|
+
const isIfFn = fn;
|
|
20
|
+
return isIfFn();
|
|
21
|
+
}
|
|
22
|
+
function ISEMPTY(v) {
|
|
23
|
+
const func = () => v == null || v === "" || v === 0;
|
|
24
|
+
const isEmptyFn = func;
|
|
25
|
+
return isEmptyFn();
|
|
26
|
+
}
|
|
27
|
+
function ISNULL(v) {
|
|
28
|
+
const func = () => isNull(v);
|
|
29
|
+
const isNullFn = func;
|
|
30
|
+
return isNullFn();
|
|
31
|
+
}
|
|
32
|
+
function ISUNDEFINED(v) {
|
|
33
|
+
const func = () => isUndefined(v);
|
|
34
|
+
const isUndefinedFn = func;
|
|
35
|
+
return isUndefinedFn();
|
|
36
|
+
}
|
|
37
|
+
function AND(...e) {
|
|
38
|
+
const func = () => {
|
|
39
|
+
for (const i of e) {
|
|
40
|
+
if (!i) return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
44
|
+
const isAndFn = func;
|
|
45
|
+
return isAndFn();
|
|
46
|
+
}
|
|
47
|
+
function OR(...e) {
|
|
48
|
+
const func = () => e.some((i) => i);
|
|
49
|
+
const isOrFn = func;
|
|
50
|
+
return isOrFn();
|
|
51
|
+
}
|
|
52
|
+
function EQ(v, o) {
|
|
53
|
+
const func = () => isEqual(v, o);
|
|
54
|
+
const isEqFn = func;
|
|
55
|
+
return isEqFn();
|
|
56
|
+
}
|
|
57
|
+
function NE(v, o) {
|
|
58
|
+
const func = () => v !== o;
|
|
59
|
+
const isNotEqual = func;
|
|
60
|
+
return isNotEqual();
|
|
61
|
+
}
|
|
62
|
+
function LE(v, o) {
|
|
63
|
+
const fn = () => {
|
|
64
|
+
if (typeof v === "number" && typeof o === "number" || typeof v === "string" && typeof o === "string" || v instanceof Date && o instanceof Date) {
|
|
65
|
+
if (v <= o) {
|
|
66
|
+
return true;
|
|
67
|
+
} else {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const isLeFn = fn;
|
|
75
|
+
return isLeFn();
|
|
76
|
+
}
|
|
77
|
+
function LT(v, o) {
|
|
78
|
+
const fn = () => {
|
|
79
|
+
if (typeof v === "number" && typeof o === "number" || typeof v === "string" && typeof o === "string" || v instanceof Date && o instanceof Date) {
|
|
80
|
+
return v < o;
|
|
81
|
+
} else {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const isLtFn = fn;
|
|
86
|
+
return isLtFn();
|
|
87
|
+
}
|
|
88
|
+
function GE(v, o) {
|
|
89
|
+
const fn = () => {
|
|
90
|
+
if (typeof v === "number" && typeof o === "number" || typeof v === "string" && typeof o === "string" || v instanceof Date && o instanceof Date) {
|
|
91
|
+
if (v >= o) {
|
|
92
|
+
return true;
|
|
93
|
+
} else {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const isGeFn = fn;
|
|
101
|
+
return isGeFn();
|
|
102
|
+
}
|
|
103
|
+
function GT(v, o) {
|
|
104
|
+
const fn = () => {
|
|
105
|
+
if (typeof v === "number" && typeof o === "number" || typeof v === "string" && typeof o === "string" || v instanceof Date && o instanceof Date) {
|
|
106
|
+
if (v > o) {
|
|
107
|
+
return true;
|
|
108
|
+
} else {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const isGtFn = fn;
|
|
116
|
+
return isGtFn();
|
|
117
|
+
}
|
|
118
|
+
function LEN(v) {
|
|
119
|
+
const fn = () => v?.length || 0;
|
|
120
|
+
const isLenFn = fn;
|
|
121
|
+
return isLenFn();
|
|
122
|
+
}
|
|
123
|
+
function CONCAT(...args) {
|
|
124
|
+
const fn = () => args.join("");
|
|
125
|
+
const isConcatFn = fn;
|
|
126
|
+
return isConcatFn();
|
|
127
|
+
}
|
|
128
|
+
function SUBSTRING(v = "", s, e) {
|
|
129
|
+
const fn = () => {
|
|
130
|
+
const val = (s < 0 ? [...v].reverse().join("") : v).slice(
|
|
131
|
+
Math.abs(s + Number(s < 0)),
|
|
132
|
+
Math.abs(e) + Number(s >= 0)
|
|
133
|
+
);
|
|
134
|
+
return s < 0 ? [...val].reverse().join("") : val;
|
|
135
|
+
};
|
|
136
|
+
const isSubstringFn = fn;
|
|
137
|
+
return isSubstringFn();
|
|
138
|
+
}
|
|
139
|
+
function SUBSTR(v = "", s, l) {
|
|
140
|
+
const fn = () => {
|
|
141
|
+
const val = (s < 0 ? [...v].reverse().join("") : v).slice(
|
|
142
|
+
Math.abs(s + Number(s < 0)),
|
|
143
|
+
Math.abs(s + Number(s < 0)) + Math.abs(l)
|
|
144
|
+
);
|
|
145
|
+
return s < 0 ? [...val].reverse().join("") : val;
|
|
146
|
+
};
|
|
147
|
+
const isSubstrFn = fn;
|
|
148
|
+
return isSubstrFn();
|
|
149
|
+
}
|
|
150
|
+
function UPPER(v = "") {
|
|
151
|
+
const fn = () => v.toUpperCase();
|
|
152
|
+
const isUpperFn = fn;
|
|
153
|
+
return isUpperFn();
|
|
154
|
+
}
|
|
155
|
+
function LOWER(v = "") {
|
|
156
|
+
const fn = () => v.toLowerCase();
|
|
157
|
+
const isLowerFn = fn;
|
|
158
|
+
return isLowerFn();
|
|
159
|
+
}
|
|
160
|
+
function TRIM(v = "") {
|
|
161
|
+
const fn = () => v.trim();
|
|
162
|
+
const isTrimFn = fn;
|
|
163
|
+
return isTrimFn();
|
|
164
|
+
}
|
|
165
|
+
function LTRIM(v = "") {
|
|
166
|
+
const fn = () => v.replace(/^\s\s*/, "");
|
|
167
|
+
const isTrimFn = fn;
|
|
168
|
+
return isTrimFn();
|
|
169
|
+
}
|
|
170
|
+
function RTRIM(v = "") {
|
|
171
|
+
const fn = () => v.replace(/\s\s*$/, "");
|
|
172
|
+
const isTrimFn = fn;
|
|
173
|
+
return isTrimFn();
|
|
174
|
+
}
|
|
175
|
+
function REPEAT(v = "", c = "") {
|
|
176
|
+
const fn = () => v.match(new RegExp(c, "g"))?.length || null;
|
|
177
|
+
const isRepeatFn = fn;
|
|
178
|
+
return isRepeatFn();
|
|
179
|
+
}
|
|
180
|
+
function REPLACE(v = "", o = "", t = "") {
|
|
181
|
+
const fn = () => v.replace(new RegExp(o, "g"), t);
|
|
182
|
+
const isReplaceFn = fn;
|
|
183
|
+
return isReplaceFn();
|
|
184
|
+
}
|
|
185
|
+
function FINDSTR(v = "", c = "") {
|
|
186
|
+
const fn = () => v.includes(c);
|
|
187
|
+
const isFindStrFn = fn;
|
|
188
|
+
return isFindStrFn();
|
|
189
|
+
}
|
|
190
|
+
function SEARCHSTR(v = "", c = "") {
|
|
191
|
+
const fn = () => {
|
|
192
|
+
const l = v.match(new RegExp(c, "g"))?.length;
|
|
193
|
+
return l ? l : 0;
|
|
194
|
+
};
|
|
195
|
+
const isSearchstrFn = fn;
|
|
196
|
+
return isSearchstrFn();
|
|
197
|
+
}
|
|
198
|
+
function PARSENUMBER(v = "") {
|
|
199
|
+
const fn = () => {
|
|
200
|
+
const num = parseFloat(v);
|
|
201
|
+
return isNaN(num) ? null : num;
|
|
202
|
+
};
|
|
203
|
+
const isParsenumberFn = fn;
|
|
204
|
+
return isParsenumberFn();
|
|
205
|
+
}
|
|
206
|
+
function SPLIT(v = "", c = "") {
|
|
207
|
+
const fn = () => v.split(c);
|
|
208
|
+
const isSplitFn = fn;
|
|
209
|
+
return isSplitFn();
|
|
210
|
+
}
|
|
211
|
+
function SUM(...args) {
|
|
212
|
+
const v = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
213
|
+
if (!v.length) return "";
|
|
214
|
+
const fn = () => v.reduce(plus, 0);
|
|
215
|
+
const isSumFn = fn;
|
|
216
|
+
return isSumFn();
|
|
217
|
+
}
|
|
218
|
+
function ADD(...args) {
|
|
219
|
+
const v = args.flat();
|
|
220
|
+
const fn = () => v.reduce(plus, 0);
|
|
221
|
+
const isSumFn = fn;
|
|
222
|
+
return isSumFn();
|
|
223
|
+
}
|
|
224
|
+
function REDUCE(v, ...args) {
|
|
225
|
+
const fn = () => args.reduce(minus, v);
|
|
226
|
+
const isReduceFN = fn;
|
|
227
|
+
return isReduceFN();
|
|
228
|
+
}
|
|
229
|
+
function MULTIPLICATION(val, ...args) {
|
|
230
|
+
const v = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
231
|
+
if (!v.length) return "";
|
|
232
|
+
const fn = () => v.reduce(multipliedBy, val);
|
|
233
|
+
const isMultiFn = fn;
|
|
234
|
+
return isMultiFn();
|
|
235
|
+
}
|
|
236
|
+
function DIVISION(v, ...args) {
|
|
237
|
+
const fn = () => args.reduce(div, v);
|
|
238
|
+
const isDivision = fn;
|
|
239
|
+
return isDivision();
|
|
240
|
+
}
|
|
241
|
+
function FIXED(v, n) {
|
|
242
|
+
const fn = () => {
|
|
243
|
+
if (n < 0) {
|
|
244
|
+
throw new Error("Decimal places should be non-negative.");
|
|
245
|
+
}
|
|
246
|
+
const arr = v.toString().split(".");
|
|
247
|
+
const [integer, decimal = ""] = arr;
|
|
248
|
+
if (n == 0) {
|
|
249
|
+
return integer;
|
|
250
|
+
}
|
|
251
|
+
let decimalArr = decimal.split("");
|
|
252
|
+
if (decimalArr.length > n) {
|
|
253
|
+
decimalArr = decimalArr.slice(0, n);
|
|
254
|
+
} else {
|
|
255
|
+
const count = decimalArr.length;
|
|
256
|
+
for (let i = 0; i < n - count; i++) {
|
|
257
|
+
decimalArr.push("0");
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return `${integer}.${decimalArr.join("")}`;
|
|
261
|
+
};
|
|
262
|
+
const isFixedFn = fn;
|
|
263
|
+
return isFixedFn();
|
|
264
|
+
}
|
|
265
|
+
function ROUND(v, n) {
|
|
266
|
+
const fn = () => {
|
|
267
|
+
if (v === null || v === "" || v === void 0) return "";
|
|
268
|
+
if (n < 0) {
|
|
269
|
+
throw new Error("Decimal places should be non-negative.");
|
|
270
|
+
}
|
|
271
|
+
const digits = Math.trunc(n);
|
|
272
|
+
const numValue = Number(v);
|
|
273
|
+
if (isNaN(numValue)) return "";
|
|
274
|
+
const num = numValue > 0 ? (+(Math.round(Number(numValue + `e${digits}`)) + `e-${digits}`)).toFixed(digits) : -(+(Math.round(Number(-numValue + `e${digits}`)) + `e-${digits}`)).toFixed(digits);
|
|
275
|
+
return parseFloat(num + "");
|
|
276
|
+
};
|
|
277
|
+
const isRoundFn = fn;
|
|
278
|
+
return isRoundFn();
|
|
279
|
+
}
|
|
280
|
+
function ROUNDUP(v, n) {
|
|
281
|
+
if (v === null || v === "" || v === void 0) return "";
|
|
282
|
+
if (n < 0) {
|
|
283
|
+
throw new Error("Decimal places should be non-negative.");
|
|
284
|
+
}
|
|
285
|
+
n = n ? parseInt(n + "") : 0;
|
|
286
|
+
return new BigNumberJS(v).decimalPlaces(n, BigNumberJS.ROUND_UP).toNumber();
|
|
287
|
+
}
|
|
288
|
+
function MAX(...args) {
|
|
289
|
+
const v = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
290
|
+
if (!v.length) return "";
|
|
291
|
+
const fn = () => Math.max.apply(null, v);
|
|
292
|
+
const isMaxFn = fn;
|
|
293
|
+
return isMaxFn();
|
|
294
|
+
}
|
|
295
|
+
function LARGE(v, n) {
|
|
296
|
+
const fn = () => {
|
|
297
|
+
if (n < 1 || n > v.length) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
"Invalid value of n. It should be between 1 and the array length."
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
const s = v.sort((a, b) => b - a);
|
|
303
|
+
return s[n - 1];
|
|
304
|
+
};
|
|
305
|
+
const isLargeFn = fn;
|
|
306
|
+
return isLargeFn();
|
|
307
|
+
}
|
|
308
|
+
function MIN(...args) {
|
|
309
|
+
const v = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
310
|
+
if (!v.length) return "";
|
|
311
|
+
const fn = () => Math.min.apply(null, v);
|
|
312
|
+
const isMinFn = fn;
|
|
313
|
+
return isMinFn();
|
|
314
|
+
}
|
|
315
|
+
function SMALL(v, n) {
|
|
316
|
+
const fn = () => {
|
|
317
|
+
if (n < 1 || n > v.length) {
|
|
318
|
+
throw new Error(
|
|
319
|
+
"Invalid value of n. It should be between 1 and the array length."
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
const s = v.sort((a, b) => a - b);
|
|
323
|
+
return s[n - 1];
|
|
324
|
+
};
|
|
325
|
+
const isSmallFn = fn;
|
|
326
|
+
return isSmallFn();
|
|
327
|
+
}
|
|
328
|
+
function AVERAGE(...args) {
|
|
329
|
+
const numbers = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
330
|
+
const count = numbers.length;
|
|
331
|
+
if (!count) return "";
|
|
332
|
+
let sum = new BigNumberJS(0);
|
|
333
|
+
for (const number of numbers) {
|
|
334
|
+
sum = sum.plus(number);
|
|
335
|
+
}
|
|
336
|
+
return sum.dividedBy(count).toNumber();
|
|
337
|
+
}
|
|
338
|
+
function ABS(v) {
|
|
339
|
+
const fn = () => Math.abs.call(null, v);
|
|
340
|
+
const isAbsFn = fn;
|
|
341
|
+
return isAbsFn();
|
|
342
|
+
}
|
|
343
|
+
function MOD(v, n) {
|
|
344
|
+
const fn = () => {
|
|
345
|
+
if (v === 0) {
|
|
346
|
+
throw new Error("The second value should not be zero.");
|
|
347
|
+
}
|
|
348
|
+
const result = new BigNumberJS(v).mod(n).toNumber();
|
|
349
|
+
if (isNaN(result)) return "";
|
|
350
|
+
return result;
|
|
351
|
+
};
|
|
352
|
+
const isModFn = fn;
|
|
353
|
+
return isModFn();
|
|
354
|
+
}
|
|
355
|
+
function toSafeNumber(x) {
|
|
356
|
+
if (typeof x === "number") {
|
|
357
|
+
return Number.isFinite(x) ? x : null;
|
|
358
|
+
}
|
|
359
|
+
if (typeof x === "string") {
|
|
360
|
+
const s = x.trim();
|
|
361
|
+
if (s === "") return null;
|
|
362
|
+
const n = Number(s);
|
|
363
|
+
return Number.isFinite(n) ? n : null;
|
|
364
|
+
}
|
|
365
|
+
if (typeof x === "bigint") {
|
|
366
|
+
const n = Number(x);
|
|
367
|
+
return Number.isFinite(n) ? n : null;
|
|
368
|
+
}
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
function POWER(v, n) {
|
|
372
|
+
const fn = () => {
|
|
373
|
+
const base = toSafeNumber(v);
|
|
374
|
+
const exp = toSafeNumber(n);
|
|
375
|
+
if (base === null || exp === null) return NaN;
|
|
376
|
+
const MAX_EXP = 1e9;
|
|
377
|
+
if (Math.abs(exp) > MAX_EXP) {
|
|
378
|
+
return exp > 0 ? Infinity : 0;
|
|
379
|
+
}
|
|
380
|
+
const result = Math.pow(base, exp);
|
|
381
|
+
return result;
|
|
382
|
+
};
|
|
383
|
+
const isProwerFn = fn;
|
|
384
|
+
return isProwerFn();
|
|
385
|
+
}
|
|
386
|
+
function SQRT(v) {
|
|
387
|
+
const fn = () => {
|
|
388
|
+
const n = toSafeNumber(v);
|
|
389
|
+
if (n === null) return NaN;
|
|
390
|
+
return Math.sqrt(n);
|
|
391
|
+
};
|
|
392
|
+
const isSqrt = fn;
|
|
393
|
+
return isSqrt();
|
|
394
|
+
}
|
|
395
|
+
function GET(v, p) {
|
|
396
|
+
const fn = () => {
|
|
397
|
+
if (Array.isArray(v)) {
|
|
398
|
+
if (typeof p === "number") {
|
|
399
|
+
return v[p];
|
|
400
|
+
} else {
|
|
401
|
+
throw new Error("For arrays, the second argument should be a number.");
|
|
402
|
+
}
|
|
403
|
+
} else if (typeof v === "object") {
|
|
404
|
+
if (typeof p === "string") {
|
|
405
|
+
return v[p];
|
|
406
|
+
} else {
|
|
407
|
+
throw new Error(
|
|
408
|
+
"For objects, the second argument (b) should be a string."
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
throw new Error(
|
|
413
|
+
"Unsupported data type. The first argument (a) should be an array or an object."
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const isGetFn = fn;
|
|
418
|
+
return isGetFn();
|
|
419
|
+
}
|
|
420
|
+
function PUT(a, b, c) {
|
|
421
|
+
const fn = () => {
|
|
422
|
+
if (Array.isArray(a)) {
|
|
423
|
+
if (typeof b === "number" && b >= 0 && b < a.length) {
|
|
424
|
+
a[b] = c;
|
|
425
|
+
} else {
|
|
426
|
+
throw new Error(
|
|
427
|
+
"For arrays, the second argument (b) should be a number."
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
} else if (typeof a === "object") {
|
|
431
|
+
if (typeof b === "string" && a) {
|
|
432
|
+
a[b] = c;
|
|
433
|
+
} else {
|
|
434
|
+
throw new Error(
|
|
435
|
+
"For objects, the second argument (b) should be a string."
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
throw new Error(
|
|
440
|
+
"Unsupported data type. The first argument (a) should be an array or an object."
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
return a;
|
|
444
|
+
};
|
|
445
|
+
const isPutFn = fn;
|
|
446
|
+
return isPutFn();
|
|
447
|
+
}
|
|
448
|
+
function PUSH(v, n) {
|
|
449
|
+
const fn = () => {
|
|
450
|
+
if (!n) {
|
|
451
|
+
throw new Error(
|
|
452
|
+
"For arrays, the second argument should not be null or undefined"
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
v.push(n);
|
|
456
|
+
return v;
|
|
457
|
+
};
|
|
458
|
+
const isPushFn = fn;
|
|
459
|
+
return isPushFn();
|
|
460
|
+
}
|
|
461
|
+
function HEADPUSH(v, n) {
|
|
462
|
+
const fn = () => {
|
|
463
|
+
if (!n) {
|
|
464
|
+
throw new Error(
|
|
465
|
+
"For arrays, the second argument should not be null or undefined"
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
v.unshift(n);
|
|
469
|
+
return v;
|
|
470
|
+
};
|
|
471
|
+
const isHeadpushFn = fn;
|
|
472
|
+
return isHeadpushFn();
|
|
473
|
+
}
|
|
474
|
+
function TIMESTAMP2DATE(v) {
|
|
475
|
+
if (!v) return;
|
|
476
|
+
const fn = () => {
|
|
477
|
+
if (!v) {
|
|
478
|
+
throw new Error("the frist argument should not be null");
|
|
479
|
+
}
|
|
480
|
+
const dateObj = new Date(v * 1e3);
|
|
481
|
+
const year = dateObj.getFullYear();
|
|
482
|
+
const month = String(dateObj.getMonth() + 1).padStart(2, "0");
|
|
483
|
+
const day = String(dateObj.getDate()).padStart(2, "0");
|
|
484
|
+
const hours = String(dateObj.getHours()).padStart(2, "0");
|
|
485
|
+
const minutes = String(dateObj.getMinutes()).padStart(2, "0");
|
|
486
|
+
const seconds = String(dateObj.getSeconds()).padStart(2, "0");
|
|
487
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
488
|
+
};
|
|
489
|
+
const isTimeStampFn = fn;
|
|
490
|
+
return isTimeStampFn();
|
|
491
|
+
}
|
|
492
|
+
function DATE2TIMESTAMP(v) {
|
|
493
|
+
if (!v) return;
|
|
494
|
+
const fn = () => dayjs(v).unix();
|
|
495
|
+
const isDateToTimestampFn = fn;
|
|
496
|
+
return isDateToTimestampFn();
|
|
497
|
+
}
|
|
498
|
+
function DATEFORMAT(v, f) {
|
|
499
|
+
if (!v) return;
|
|
500
|
+
const fn = () => dayjs(v).format(f);
|
|
501
|
+
const isDateFormatFn = fn;
|
|
502
|
+
return isDateFormatFn();
|
|
503
|
+
}
|
|
504
|
+
function NOW() {
|
|
505
|
+
return dayjs().format("YYYY-MM-DD HH:MM:ss");
|
|
506
|
+
}
|
|
507
|
+
function TODAY() {
|
|
508
|
+
return dayjs().format("YYYY-MM-DD");
|
|
509
|
+
}
|
|
510
|
+
function YEAR(v) {
|
|
511
|
+
return dayjs(v).year();
|
|
512
|
+
}
|
|
513
|
+
function MONTH(v) {
|
|
514
|
+
const fn = () => {
|
|
515
|
+
const m = dayjs(v).month();
|
|
516
|
+
return m;
|
|
517
|
+
};
|
|
518
|
+
const isMonthFn = fn;
|
|
519
|
+
return isMonthFn();
|
|
520
|
+
}
|
|
521
|
+
function DAY(v) {
|
|
522
|
+
const fn = () => {
|
|
523
|
+
const d = dayjs(v).day();
|
|
524
|
+
return d;
|
|
525
|
+
};
|
|
526
|
+
const isDayFn = fn;
|
|
527
|
+
return isDayFn();
|
|
528
|
+
}
|
|
529
|
+
function HOUR(v) {
|
|
530
|
+
const fn = () => {
|
|
531
|
+
const h = dayjs(v).hour();
|
|
532
|
+
return h;
|
|
533
|
+
};
|
|
534
|
+
const isHourFn = fn;
|
|
535
|
+
return isHourFn();
|
|
536
|
+
}
|
|
537
|
+
function MINUTE(v) {
|
|
538
|
+
const fn = () => {
|
|
539
|
+
const m = dayjs(v).minute();
|
|
540
|
+
return m;
|
|
541
|
+
};
|
|
542
|
+
const isMinuteFn = fn;
|
|
543
|
+
return isMinuteFn();
|
|
544
|
+
}
|
|
545
|
+
function WEEKRANGE() {
|
|
546
|
+
const fn = () => {
|
|
547
|
+
const startOfWeek = convertToCST(dayjs().startOf("week").toDate());
|
|
548
|
+
const endOfWeek = convertToCST(dayjs().endOf("week").toDate());
|
|
549
|
+
return [startOfWeek, endOfWeek];
|
|
550
|
+
};
|
|
551
|
+
const isWeekDayFn = fn;
|
|
552
|
+
return isWeekDayFn();
|
|
553
|
+
}
|
|
554
|
+
function LASTWEEKRANGE() {
|
|
555
|
+
const fn = () => {
|
|
556
|
+
const startOfLastWeek = convertToCST(
|
|
557
|
+
dayjs().subtract(1, "week").startOf("week").toDate()
|
|
558
|
+
);
|
|
559
|
+
const endOfLastWeek = convertToCST(
|
|
560
|
+
dayjs().subtract(1, "week").endOf("week").toDate()
|
|
561
|
+
);
|
|
562
|
+
return [startOfLastWeek, endOfLastWeek];
|
|
563
|
+
};
|
|
564
|
+
const isLastWeekFn = fn;
|
|
565
|
+
return isLastWeekFn();
|
|
566
|
+
}
|
|
567
|
+
function MONTHRANGE() {
|
|
568
|
+
const fn = () => {
|
|
569
|
+
const startOfLastMonth = convertToCST(dayjs().startOf("month").toDate());
|
|
570
|
+
const endOfLastMonth = convertToCST(dayjs().endOf("month").toDate());
|
|
571
|
+
return [startOfLastMonth, endOfLastMonth];
|
|
572
|
+
};
|
|
573
|
+
const isMonthRangeFn = fn;
|
|
574
|
+
return isMonthRangeFn();
|
|
575
|
+
}
|
|
576
|
+
function LASTMONTHRANGE() {
|
|
577
|
+
const fn = () => {
|
|
578
|
+
const startOfLastMonth = convertToCST(
|
|
579
|
+
dayjs().subtract(1, "month").startOf("month").toDate()
|
|
580
|
+
);
|
|
581
|
+
const endOfLastMonth = convertToCST(
|
|
582
|
+
dayjs().subtract(1, "month").endOf("month").toDate()
|
|
583
|
+
);
|
|
584
|
+
return [startOfLastMonth, endOfLastMonth];
|
|
585
|
+
};
|
|
586
|
+
const isLastMonthRangeFn = fn;
|
|
587
|
+
return isLastMonthRangeFn();
|
|
588
|
+
}
|
|
589
|
+
function YEARRANGE() {
|
|
590
|
+
const fn = () => {
|
|
591
|
+
const startOfYear = convertToCST(dayjs().startOf("year").toDate());
|
|
592
|
+
const endOfYear = convertToCST(dayjs().endOf("year").toDate());
|
|
593
|
+
return [startOfYear, endOfYear];
|
|
594
|
+
};
|
|
595
|
+
const isYearRange = fn;
|
|
596
|
+
return isYearRange();
|
|
597
|
+
}
|
|
598
|
+
function LASTYEARRANGE() {
|
|
599
|
+
const fn = () => {
|
|
600
|
+
const startOfLastYear = convertToCST(
|
|
601
|
+
dayjs().subtract(1, "year").startOf("year").toDate()
|
|
602
|
+
);
|
|
603
|
+
const endOfLastYear = convertToCST(
|
|
604
|
+
dayjs().subtract(1, "year").endOf("year").toDate()
|
|
605
|
+
);
|
|
606
|
+
return [startOfLastYear, endOfLastYear];
|
|
607
|
+
};
|
|
608
|
+
const isLastYearRange = fn;
|
|
609
|
+
return isLastYearRange();
|
|
610
|
+
}
|
|
611
|
+
function QUARTER() {
|
|
612
|
+
const fn = () => {
|
|
613
|
+
const currentQuarter = Math.floor((dayjs().month() + 3) / 3);
|
|
614
|
+
const startOfCurrentQuarter = convertToCST(
|
|
615
|
+
dayjs().quarter(currentQuarter).startOf("quarter").toDate()
|
|
616
|
+
);
|
|
617
|
+
const endOfCurrentQuarter = convertToCST(
|
|
618
|
+
dayjs().quarter(currentQuarter).endOf("quarter").toDate()
|
|
619
|
+
);
|
|
620
|
+
return [startOfCurrentQuarter, endOfCurrentQuarter];
|
|
621
|
+
};
|
|
622
|
+
const isQuarterFn = fn;
|
|
623
|
+
return isQuarterFn();
|
|
624
|
+
}
|
|
625
|
+
function LASTQUARTER() {
|
|
626
|
+
const fn = () => {
|
|
627
|
+
const currentQuarter = Math.floor((dayjs().month() + 3) / 3);
|
|
628
|
+
const startOfLastQuarter = convertToCST(
|
|
629
|
+
dayjs().quarter(currentQuarter - 1).startOf("quarter").toDate()
|
|
630
|
+
);
|
|
631
|
+
const endOfLastQuarter = convertToCST(
|
|
632
|
+
dayjs().quarter(currentQuarter - 1).endOf("quarter").toDate()
|
|
633
|
+
);
|
|
634
|
+
return [startOfLastQuarter, endOfLastQuarter];
|
|
635
|
+
};
|
|
636
|
+
const isLastQuarter = fn;
|
|
637
|
+
return isLastQuarter();
|
|
638
|
+
}
|
|
639
|
+
function ISDATERANGE(v, r) {
|
|
640
|
+
const fn = () => {
|
|
641
|
+
const [startDate, endDate] = r;
|
|
642
|
+
return v >= startDate && v <= endDate;
|
|
643
|
+
};
|
|
644
|
+
const isDateRangFn = fn;
|
|
645
|
+
return isDateRangFn();
|
|
646
|
+
}
|
|
647
|
+
function ISTIMERANGE(v, r) {
|
|
648
|
+
const fn = () => {
|
|
649
|
+
const [startTime, endTime] = r;
|
|
650
|
+
const dtTime = dayjs(v, "HH:mm");
|
|
651
|
+
if (startTime > endTime) {
|
|
652
|
+
const startTimeAfterMidnight = dayjs(startTime, "HH:mm");
|
|
653
|
+
const endTimeBeforeMidnight = dayjs(endTime, "HH:mm").add(1, "day");
|
|
654
|
+
return dtTime >= startTimeAfterMidnight || dtTime <= endTimeBeforeMidnight;
|
|
655
|
+
} else {
|
|
656
|
+
return dtTime >= dayjs(startTime, "HH:mm") && dtTime <= dayjs(endTime, "HH:mm");
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const isTimeRangFn = fn;
|
|
660
|
+
return isTimeRangFn();
|
|
661
|
+
}
|
|
662
|
+
function convertToCST(isoDateString) {
|
|
663
|
+
const cstFormattedDate = dayjs(isoDateString).tz("America/Chicago").format("YYYY-MM-DD HH:mm:ss.SSSSSSSSS ZZ");
|
|
664
|
+
return cstFormattedDate;
|
|
665
|
+
}
|
|
666
|
+
function TUPLE(...args) {
|
|
667
|
+
return [...args];
|
|
668
|
+
}
|
|
669
|
+
function SEQMAP(...args) {
|
|
670
|
+
const len = (args.length - args.length % 2) / 2;
|
|
671
|
+
const map = {};
|
|
672
|
+
Array(len).forEach((i) => {
|
|
673
|
+
const key = args[i * 2];
|
|
674
|
+
const value = args[i * 2 + 1];
|
|
675
|
+
map[key] = value;
|
|
676
|
+
});
|
|
677
|
+
return map;
|
|
678
|
+
}
|
|
679
|
+
function SUMSQ(...args) {
|
|
680
|
+
args = args.flat().filter((i) => i !== "" && i !== null && i !== void 0);
|
|
681
|
+
if (args.length === 0) return "";
|
|
682
|
+
const squares = args.map((value) => {
|
|
683
|
+
const square = multipliedBy(value, value);
|
|
684
|
+
return square !== "" ? square : new BigNumberJS(0).toNumber();
|
|
685
|
+
});
|
|
686
|
+
return squares.reduce((sum, square) => {
|
|
687
|
+
return plus(sum, square) || BigNumberJS(0).toNumber();
|
|
688
|
+
}, new BigNumberJS(0).toNumber());
|
|
689
|
+
}
|
|
690
|
+
function COUNT(v) {
|
|
691
|
+
if (!Array.isArray(v)) {
|
|
692
|
+
return "";
|
|
693
|
+
}
|
|
694
|
+
return v.length;
|
|
695
|
+
}
|
|
696
|
+
function STDEV(...args) {
|
|
697
|
+
const data = args.flat().map((v) => Number(v)).filter((v) => Number.isFinite(v));
|
|
698
|
+
if (data.length < 2) {
|
|
699
|
+
return "";
|
|
700
|
+
}
|
|
701
|
+
const mean = data.reduce((sum, val) => sum + val, 0) / data.length;
|
|
702
|
+
const variance = data.reduce((sum, val) => {
|
|
703
|
+
const diff = val - mean;
|
|
704
|
+
return sum + diff * diff;
|
|
705
|
+
}, 0) / (data.length - 1);
|
|
706
|
+
return Math.sqrt(variance);
|
|
707
|
+
}
|
|
708
|
+
function plus(a, b) {
|
|
709
|
+
const result = new BigNumberJS(a).plus(new BigNumberJS(b)).toNumber();
|
|
710
|
+
if (isNaN(result)) return "";
|
|
711
|
+
return result;
|
|
712
|
+
}
|
|
713
|
+
function minus(a, b) {
|
|
714
|
+
const result = new BigNumberJS(a).minus(new BigNumberJS(b)).toNumber();
|
|
715
|
+
if (isNaN(result)) return "";
|
|
716
|
+
return result;
|
|
717
|
+
}
|
|
718
|
+
function multipliedBy(a, b) {
|
|
719
|
+
const result = new BigNumberJS(a).multipliedBy(new BigNumberJS(b)).toNumber();
|
|
720
|
+
if (isNaN(result)) return "";
|
|
721
|
+
return result;
|
|
722
|
+
}
|
|
723
|
+
function div(a, b) {
|
|
724
|
+
const result = new BigNumberJS(a).div(new BigNumberJS(b)).toNumber();
|
|
725
|
+
if (isNaN(result)) return "";
|
|
726
|
+
return result;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export { ABS, ADD, AND, AVERAGE, CONCAT, COUNT, DATE2TIMESTAMP, DATEFORMAT, DAY, DIVISION, EQ, FINDSTR, FIXED, GE, GET, GT, HEADPUSH, HOUR, IF, ISDATERANGE, ISEMPTY, ISNULL, ISTIMERANGE, ISUNDEFINED, LARGE, LASTMONTHRANGE, LASTQUARTER, LASTWEEKRANGE, LASTYEARRANGE, LE, LEN, LOWER, LT, LTRIM, MAX, MIN, MINUTE, MOD, MONTH, MONTHRANGE, MULTIPLICATION, NE, NOW, OR, PARSENUMBER, POWER, PUSH, PUT, QUARTER, REDUCE, REPEAT, REPLACE, ROUND, ROUNDUP, RTRIM, SEARCHSTR, SEQMAP, SMALL, SPLIT, SQRT, STDEV, SUBSTR, SUBSTRING, SUM, SUMSQ, TIMESTAMP2DATE, TODAY, TRIM, TUPLE, UPPER, WEEKRANGE, YEAR, YEARRANGE };
|