@axiom-lattice/protocols 1.0.1

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/src/types.ts ADDED
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 通用类型定义
3
+ *
4
+ * 提供跨Lattice使用的通用类型
5
+ */
6
+
7
+ /**
8
+ * 通用结果接口
9
+ */
10
+ export interface Result<T = any> {
11
+ success: boolean;
12
+ data?: T;
13
+ error?: string;
14
+ metadata?: Record<string, any>;
15
+ }
16
+
17
+ /**
18
+ * 分页请求参数
19
+ */
20
+ export interface PaginationParams {
21
+ page?: number;
22
+ pageSize?: number;
23
+ sortBy?: string;
24
+ sortOrder?: "asc" | "desc";
25
+ }
26
+
27
+ /**
28
+ * 分页响应结果
29
+ */
30
+ export interface PaginatedResult<T = any> {
31
+ items: T[];
32
+ total: number;
33
+ page: number;
34
+ pageSize: number;
35
+ totalPages: number;
36
+ }
37
+
38
+ /**
39
+ * 过滤条件
40
+ */
41
+ export interface FilterCondition {
42
+ field: string;
43
+ operator:
44
+ | "eq"
45
+ | "neq"
46
+ | "gt"
47
+ | "gte"
48
+ | "lt"
49
+ | "lte"
50
+ | "in"
51
+ | "nin"
52
+ | "contains"
53
+ | "startsWith"
54
+ | "endsWith";
55
+ value: any;
56
+ }
57
+
58
+ /**
59
+ * 查询参数
60
+ */
61
+ export interface QueryParams {
62
+ pagination?: PaginationParams;
63
+ filters?: FilterCondition[];
64
+ search?: string;
65
+ includes?: string[];
66
+ }
67
+
68
+ /**
69
+ * 通用ID类型
70
+ */
71
+ export type ID = string | number;
72
+
73
+ /**
74
+ * 时间戳类型
75
+ */
76
+ export type Timestamp = number;
77
+
78
+ /**
79
+ * 通用回调函数类型
80
+ */
81
+ export type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "preserve",
5
+ "lib": ["ES2020"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "moduleResolution": "Bundler",
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "types": ["node", "jest"],
17
+ "sourceMap": true,
18
+ "incremental": true, // 确保启用增量编译
19
+ "tsBuildInfoFile": "./.tsbuildinfo" // 指定构建信息文件位置
20
+ },
21
+ "include": ["src/index.ts"],
22
+ "exclude": ["node_modules", "dist"]
23
+ }