@edgenets/utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ ## @edgenets/utils
2
+
3
+ ## 该包已经规划好,主要用于存放各种实用工具函数、类型定义和常用的工具方法,如字符串处理、数组操作、日期格式化等。
4
+
5
+ 包含内容:
6
+
7
+ ```
8
+ • 字符串处理函数
9
+ • 数组处理函数
10
+ • 日期处理函数
11
+ • 通用工具函数(如 debounce、throttle)
12
+ • 类型定义(如 User、Order 等)
13
+ ```
@@ -0,0 +1,5 @@
1
+ export * from "./types/user";
2
+ export * from "./types/product";
3
+ export * from "./types/logger";
4
+ export * from "./types/order";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types/user"), exports);
18
+ __exportStar(require("./types/product"), exports);
19
+ __exportStar(require("./types/logger"), exports);
20
+ __exportStar(require("./types/order"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,iDAA+B;AAC/B,gDAA8B"}
@@ -0,0 +1,5 @@
1
+ export interface Logger {
2
+ info(message: string): void;
3
+ error(message: string): void;
4
+ }
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAE9B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":""}
@@ -0,0 +1,109 @@
1
+ interface BaseOrder {
2
+ orderNumber?: number;
3
+ status: OrderStatus;
4
+ createdAt?: Date;
5
+ updatedAt?: Date;
6
+ expiresAt?: Date;
7
+ completedAt?: Date;
8
+ canceledAt?: Date;
9
+ items: OrderItem[];
10
+ currency: string;
11
+ totalAmount?: number;
12
+ customer: OrderCustomer;
13
+ payment: OrderPayment;
14
+ refund?: OrderRefund;
15
+ shipping?: OrderShipping;
16
+ discount?: OrderDiscount;
17
+ notes?: string;
18
+ }
19
+ export declare enum OrderStatus {
20
+ Pending = "pending",// 订单已创建,待处理
21
+ Confirmed = "confirmed",// 订单已确认,准备发货
22
+ Completed = "completed",// 订单已发货,确认完成
23
+ Canceled = "canceled",// 订单已取消
24
+ Refunded = "refunded"
25
+ }
26
+ export interface OrderCustomer {
27
+ id: string;
28
+ name: string;
29
+ phone?: string;
30
+ email?: string;
31
+ telegram_uid: number;
32
+ walletAddress?: string;
33
+ shippingAddress?: string;
34
+ }
35
+ export interface OrderItem {
36
+ id: string;
37
+ name?: string;
38
+ description?: string;
39
+ quantity: number;
40
+ price?: number;
41
+ totalPrice?: number;
42
+ }
43
+ export interface OrderPayment {
44
+ method: PaymentMethod;
45
+ status: PaymentStatus;
46
+ transactionId?: string;
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ export declare enum PaymentMethod {
50
+ Online = "Online",// 在线支付(如 PayPal, Alipay)
51
+ Credit = "Credit",// 信用卡支付
52
+ Points = "Points",// 积分支付, 无需KYC
53
+ Crypto = "Crypto"
54
+ }
55
+ export declare enum PaymentStatus {
56
+ Pending = "pending",
57
+ Paid = "paid",
58
+ Failed = "failed"
59
+ }
60
+ export declare enum RefundStatus {
61
+ Requested = "requested",// 退款已请求
62
+ Processing = "processing",// 退款处理中
63
+ Completed = "completed",// 退款已完成
64
+ Rejected = "rejected"
65
+ }
66
+ export interface OrderRefund {
67
+ refundId: string;
68
+ refundAmount: number;
69
+ refundReason?: string;
70
+ refundStatus: RefundStatus;
71
+ refundedAt?: Date;
72
+ }
73
+ export interface OrderShipping {
74
+ method: ShippingMethod;
75
+ address: OrderShippingAddress;
76
+ cost: number;
77
+ status: ShippingStatus;
78
+ trackingNumber?: string;
79
+ }
80
+ export declare enum ShippingMethod {
81
+ Standard = "standard",
82
+ Express = "express",
83
+ Pickup = "pickup"
84
+ }
85
+ export declare enum ShippingStatus {
86
+ NotShipped = "not_shipped",
87
+ Shipped = "shipped",
88
+ Delivered = "delivered"
89
+ }
90
+ export interface OrderShippingAddress {
91
+ addressLine1: string;
92
+ addressLine2?: string;
93
+ city: string;
94
+ state?: string;
95
+ postalCode: string;
96
+ country: string;
97
+ }
98
+ export interface OrderDiscount {
99
+ code: string;
100
+ amount: number;
101
+ promoApplied: boolean;
102
+ }
103
+ export interface Order extends BaseOrder {
104
+ id?: string;
105
+ check?: number;
106
+ metadata?: Record<string, unknown>;
107
+ }
108
+ export {};
109
+ //# sourceMappingURL=order.d.ts.map
@@ -0,0 +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,SAAS,cAAc,CAAE,aAAa;IACtC,SAAS,cAAc,CAAE,aAAa;IACtC,QAAQ,aAAa,CAAE,QAAQ;IAC/B,QAAQ,aAAa;CACtB;AAGD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,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YAAY;IACnB,SAAS,cAAc;CACxB;AAGD,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;CACvB;AAGD,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShippingStatus = exports.ShippingMethod = exports.RefundStatus = exports.PaymentStatus = exports.PaymentMethod = exports.OrderStatus = void 0;
4
+ // 订单状态枚举
5
+ var OrderStatus;
6
+ (function (OrderStatus) {
7
+ OrderStatus["Pending"] = "pending";
8
+ OrderStatus["Confirmed"] = "confirmed";
9
+ OrderStatus["Completed"] = "completed";
10
+ OrderStatus["Canceled"] = "canceled";
11
+ OrderStatus["Refunded"] = "refunded";
12
+ })(OrderStatus || (exports.OrderStatus = OrderStatus = {}));
13
+ // 支付方式枚举
14
+ var PaymentMethod;
15
+ (function (PaymentMethod) {
16
+ PaymentMethod["Online"] = "Online";
17
+ PaymentMethod["Credit"] = "Credit";
18
+ PaymentMethod["Points"] = "Points";
19
+ PaymentMethod["Crypto"] = "Crypto";
20
+ })(PaymentMethod || (exports.PaymentMethod = PaymentMethod = {}));
21
+ // 支付状态枚举
22
+ var PaymentStatus;
23
+ (function (PaymentStatus) {
24
+ PaymentStatus["Pending"] = "pending";
25
+ PaymentStatus["Paid"] = "paid";
26
+ PaymentStatus["Failed"] = "failed";
27
+ })(PaymentStatus || (exports.PaymentStatus = PaymentStatus = {}));
28
+ // 退款状态枚举
29
+ var RefundStatus;
30
+ (function (RefundStatus) {
31
+ RefundStatus["Requested"] = "requested";
32
+ RefundStatus["Processing"] = "processing";
33
+ RefundStatus["Completed"] = "completed";
34
+ RefundStatus["Rejected"] = "rejected";
35
+ })(RefundStatus || (exports.RefundStatus = RefundStatus = {}));
36
+ // 配送方式枚举
37
+ var ShippingMethod;
38
+ (function (ShippingMethod) {
39
+ ShippingMethod["Standard"] = "standard";
40
+ ShippingMethod["Express"] = "express";
41
+ ShippingMethod["Pickup"] = "pickup";
42
+ })(ShippingMethod || (exports.ShippingMethod = ShippingMethod = {}));
43
+ // 配送状态枚举
44
+ var ShippingStatus;
45
+ (function (ShippingStatus) {
46
+ ShippingStatus["NotShipped"] = "not_shipped";
47
+ ShippingStatus["Shipped"] = "shipped";
48
+ ShippingStatus["Delivered"] = "delivered";
49
+ })(ShippingStatus || (exports.ShippingStatus = ShippingStatus = {}));
50
+ //# sourceMappingURL=order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/types/order.ts"],"names":[],"mappings":";;;AAsBA,SAAS;AACT,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACvB,CAAC,EANW,WAAW,2BAAX,WAAW,QAMtB;AA+BD,SAAS;AACT,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EALW,aAAa,6BAAb,aAAa,QAKxB;AAED,SAAS;AACT,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,SAAS;AACT,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;AACvB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAoBD,SAAS;AACT,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,SAAS;AACT,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,4CAA0B,CAAA;IAC1B,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;AACzB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB"}
@@ -0,0 +1,7 @@
1
+ export interface Product {
2
+ id: string;
3
+ name: string;
4
+ price: number;
5
+ description: string;
6
+ }
7
+ //# sourceMappingURL=product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/types/product.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/types/product.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ declare interface TelegramUser {
2
+ telegram_uid: number;
3
+ username?: string;
4
+ firstName?: string;
5
+ lastName?: string;
6
+ languageCode?: string;
7
+ isPremium?: boolean;
8
+ }
9
+ interface FirebaseInfo {
10
+ identities: {
11
+ email: string[];
12
+ };
13
+ sign_in_provider: string;
14
+ }
15
+ export interface User extends TelegramUser {
16
+ id: string;
17
+ name: string;
18
+ email: string;
19
+ emailVerified: boolean;
20
+ secret: string;
21
+ iss: string;
22
+ aud: string;
23
+ sub: string;
24
+ iat: number;
25
+ exp: number;
26
+ authTime: number;
27
+ firebase: FirebaseInfo;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,YAAY;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CAErB;AAED,UAAU,YAAY;IACpB,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;IACF,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAGD,MAAM,WAAW,IAAK,SAAQ,YAAY;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import eslint from "@eslint/js";
2
+ import tseslint from "typescript-eslint";
3
+ import prettierConfig from "eslint-config-prettier";
4
+
5
+ export default tseslint.config({
6
+ files: ["src/**/*.ts"],
7
+ extends: [
8
+ eslint.configs.recommended,
9
+ ...tseslint.configs.recommended,
10
+ prettierConfig,
11
+ ],
12
+ rules: {
13
+ "@typescript-eslint/array-type": "error",
14
+ "@typescript-eslint/consistent-type-imports": "error",
15
+ },
16
+ });
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@edgenets/utils",
3
+ "version": "0.0.1",
4
+ "description": "Edgenets utilities package containing common types and utilities.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "author": "Edgenets",
9
+ "scripts": {
10
+ "build": "eslint --fix && tsc -p tsconfig.json",
11
+ "test": "tsx ../../node_modules/tap/dist/esm/run.mjs 'test/**/*.spec.ts' || true"
12
+ }
13
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "rootDir": "./src",
5
+ "sourceMap": true,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "strict": true
9
+ },
10
+ "compileOnSave": true,
11
+ "include": ["src/**/*"],
12
+ "exclude": ["node_modules", "dist"]
13
+ }