@edgenets/utils 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,6 @@
1
1
  interface BaseOrder {
2
- orderNumber?: number;
2
+ orderNumber: number;
3
3
  status: OrderStatus;
4
- createdAt?: Date;
5
- updatedAt?: Date;
6
- expiresAt?: Date;
7
- completedAt?: Date;
8
- canceledAt?: Date;
9
4
  items: OrderItem[];
10
5
  currency: string;
11
6
  totalAmount?: number;
@@ -15,6 +10,11 @@ interface BaseOrder {
15
10
  shipping?: OrderShipping;
16
11
  discount?: OrderDiscount;
17
12
  notes?: string;
13
+ createdAt?: Date;
14
+ updatedAt?: Date;
15
+ expiresAt?: Date;
16
+ completedAt?: Date;
17
+ canceledAt?: Date;
18
18
  }
19
19
  export declare enum OrderStatus {
20
20
  Pending = "pending",// 订单已创建,待处理
@@ -1 +1 @@
1
- {"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":"AACA,UAAU,SAAS;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,UAAU,CAAC,EAAE,IAAI,CAAC;IAElB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,oBAAY,WAAW;IACrB,OAAO,YAAY,CAAE,YAAY;IACjC,SAA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D,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,4CAA0B,CAAA;IAC1B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":"AAuBA,SAAS;AACT,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AA+BD,SAAS;AACT,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAoBD,SAAS;AACT,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED,SAAS;AACT,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,4CAA0B,CAAA;IAC1B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgenets/utils",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Edgenets utilities package containing common types and utilities.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +0,0 @@
1
- /**
2
- * 生成一个随机且安全的 orderNumber
3
- * @param length - orderNumber 的位数
4
- * @returns 生成的随机数字字符串
5
- */
6
- export declare function generateOrderNumber(orderSequence?: number): number;
7
- //# sourceMappingURL=generate.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.utils.d.ts","sourceRoot":"","sources":["../../src/utils/generate.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,GAAE,MAAU,GAAG,MAAM,CAqBrE"}
@@ -1,30 +0,0 @@
1
- /**
2
- * 生成一个随机且安全的 orderNumber
3
- * @param length - orderNumber 的位数
4
- * @returns 生成的随机数字字符串
5
- */
6
- export function generateOrderNumber(orderSequence = 0) {
7
- const now = new Date();
8
- // 获取年份的后两位
9
- const year = now.getFullYear().toString().slice(-2);
10
- // 获取今年第几天
11
- const start = new Date(now.getFullYear(), 0, 0);
12
- const diff = now.getTime() - start.getTime();
13
- const dayOfYear = Math.floor(diff / (1000 * 60 * 60 * 24))
14
- .toString()
15
- .padStart(3, "0");
16
- // 序列号递增,并重置为三位
17
- if (orderSequence === 0)
18
- orderSequence = generateRandomNumber(3);
19
- orderSequence = (orderSequence + 1) % 1000;
20
- const sequence = orderSequence.toString().padStart(3, "0");
21
- // 生成 8 位的随机数,保证不重复
22
- const randomPart = Math.random().toString().slice(2, 10); // 生成8位随机数字
23
- return Number(`${year}${dayOfYear}${sequence}${randomPart}`);
24
- }
25
- function generateRandomNumber(length) {
26
- const min = Math.pow(10, length - 1); // 最小值,例如:6位数的最小值为100000
27
- const max = Math.pow(10, length) - 1; // 最大值,例如:6位数的最大值为999999
28
- return Math.floor(Math.random() * (max - min + 1)) + min;
29
- }
30
- //# sourceMappingURL=generate.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.utils.js","sourceRoot":"","sources":["../../src/utils/generate.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,gBAAwB,CAAC;IAC3D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,WAAW;IACX,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpD,UAAU;IACV,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;SACvD,QAAQ,EAAE;SACV,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEpB,eAAe;IACf,IAAI,aAAa,KAAK,CAAC;QAAE,aAAa,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACjE,aAAa,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE3D,mBAAmB;IACnB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW;IAErE,OAAO,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAc;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB;IAC9D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,wBAAwB;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC3D,CAAC"}
@@ -1,19 +0,0 @@
1
- type Task = () => Promise<boolean>;
2
- export interface SchedulerOptions {
3
- interval?: number;
4
- taskTimeout?: number;
5
- logInterval?: number;
6
- maxRecursions: number;
7
- maxRetries?: number;
8
- maxTotalTime?: number;
9
- }
10
- export declare class Scheduler {
11
- private tasks;
12
- schedule(task: Task, options: SchedulerOptions): void;
13
- private handleTaskError;
14
- private timeout;
15
- private delay;
16
- cancelAll(): void;
17
- }
18
- export {};
19
- //# sourceMappingURL=scheduler.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.util.d.ts","sourceRoot":"","sources":["../../src/utils/scheduler.util.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAA2D;IAEjE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI;YA0D9C,eAAe;IAmB7B,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,KAAK;IAIN,SAAS,IAAI,IAAI;CAMzB"}
@@ -1,69 +0,0 @@
1
- export class Scheduler {
2
- tasks = new Map();
3
- schedule(task, options) {
4
- const { interval = 1000, // 默认 1000 毫秒
5
- maxRecursions = 0, // 默认 不 迭代
6
- maxRetries = 0, // 默认 不 重试
7
- logInterval = 1, // 默认 完整输出 Log
8
- taskTimeout = 30000, // 默认 单次执行时间30秒
9
- maxTotalTime = 60000, // 默认 最大执行时间60秒
10
- } = options || {};
11
- let counter = 0;
12
- let retries = 0;
13
- const startTime = Date.now();
14
- const executeTask = async () => {
15
- try {
16
- if (maxTotalTime && Date.now() - startTime > maxTotalTime) {
17
- console.log("达到总的最大执行时间,停止任务。");
18
- this.cancelAll();
19
- return;
20
- }
21
- const shouldContinue = await Promise.race([
22
- task(),
23
- this.timeout(taskTimeout),
24
- ]);
25
- counter++;
26
- if (shouldContinue && counter < maxRecursions) {
27
- if (counter % logInterval === 0) {
28
- console.log(`递归执行, 第 ${counter} 次, 已执行 ${(Date.now() - startTime) / 1000} 秒`);
29
- }
30
- this.tasks.set(setTimeout(async () => {
31
- await executeTask();
32
- }, interval), setTimeout(() => { }, interval));
33
- }
34
- else {
35
- this.cancelAll();
36
- }
37
- }
38
- catch (error) {
39
- await this.handleTaskError(error, retries, maxRetries, executeTask, interval);
40
- retries++;
41
- }
42
- };
43
- executeTask();
44
- }
45
- async handleTaskError(error, retries, maxRetries, retryTask, interval) {
46
- if (retries < maxRetries) {
47
- console.error(`Retry attempt ${retries + 1} due to error: ${error}`);
48
- await this.delay(interval * (retries + 1)); // 指数退避
49
- await retryTask(); // 重新执行任务
50
- }
51
- else {
52
- console.error("Max retries reached. Task execution stopped due to persistent errors.");
53
- this.cancelAll();
54
- }
55
- }
56
- timeout(ms) {
57
- return new Promise((_, reject) => setTimeout(() => reject("Task timed out"), ms));
58
- }
59
- delay(ms) {
60
- return new Promise((resolve) => setTimeout(resolve, ms));
61
- }
62
- cancelAll() {
63
- this.tasks.forEach((_, taskId) => {
64
- clearTimeout(taskId);
65
- });
66
- this.tasks.clear();
67
- }
68
- }
69
- //# sourceMappingURL=scheduler.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.util.js","sourceRoot":"","sources":["../../src/utils/scheduler.util.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,SAAS;IACZ,KAAK,GAAiD,IAAI,GAAG,EAAE,CAAC;IAEjE,QAAQ,CAAC,IAAU,EAAE,OAAyB;QACnD,MAAM,EACJ,QAAQ,GAAG,IAAI,EAAE,aAAa;QAC9B,aAAa,GAAG,CAAC,EAAE,UAAU;QAC7B,UAAU,GAAG,CAAC,EAAE,UAAU;QAC1B,WAAW,GAAG,CAAC,EAAE,cAAc;QAC/B,WAAW,GAAG,KAAK,EAAE,eAAe;QACpC,YAAY,GAAG,KAAK,EAAE,eAAe;UACtC,GAAG,OAAO,IAAI,EAAE,CAAC;QAElB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;YAC7B,IAAI,CAAC;gBACH,IAAI,YAAY,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,YAAY,EAAE,CAAC;oBAC1D,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC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I,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;YACnD,MAAM,SAAS,EAAE,CAAC,CAAC,SAAS;QAC9B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,uEAAuE,CACxE,CAAC;YACF,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;IAEO,OAAO,CAAC,EAAU;QACxB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAC/B,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAC/C,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEM,SAAS;QACd,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAC/B,YAAY,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- export declare class StringUtils {
2
- static capitalize(str: string): string;
3
- static trim(str: string): string;
4
- static toNumber(value: string): number | null;
5
- }
6
- //# sourceMappingURL=string.utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.utils.d.ts","sourceRoot":"","sources":["../../src/utils/string.utils.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IAEtB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAKtC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAKhC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAI9C"}
@@ -1,16 +0,0 @@
1
- export class StringUtils {
2
- // 首字母大写
3
- static capitalize(str) {
4
- return str.charAt(0).toUpperCase() + str.slice(1);
5
- }
6
- // 去除空白字符
7
- static trim(str) {
8
- return str.trim();
9
- }
10
- // 将字符串转换为数字
11
- static toNumber(value) {
12
- const num = Number(value);
13
- return isNaN(num) ? null : num;
14
- }
15
- }
16
- //# sourceMappingURL=string.utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.utils.js","sourceRoot":"","sources":["../../src/utils/string.utils.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAW;IACtB,QAAQ;IACR,MAAM,CAAC,UAAU,CAAC,GAAW;QAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,SAAS;IACT,MAAM,CAAC,IAAI,CAAC,GAAW;QACrB,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED,YAAY;IACZ,MAAM,CAAC,QAAQ,CAAC,KAAa;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IACjC,CAAC;CACF"}