odm-client 0.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/dist/client/cloudbase-client.d.ts +48 -0
- package/dist/client/cloudbase-index.d.ts +4 -0
- package/dist/client/mongodb-client.d.ts +64 -0
- package/dist/client/mongodb-index.d.ts +4 -0
- package/dist/client/query-builder.d.ts +11 -0
- package/dist/cloudbase-index.cjs +1 -0
- package/dist/cloudbase-index.js +124 -0
- package/dist/decorators/index.d.ts +48 -0
- package/dist/deps/query-builder-h6B2D2BCoQ-4ajykqs3m.js +72 -0
- package/dist/deps/query-builder-h6B2D2BCoQ-wqso6i87o.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +31 -0
- package/dist/mongodb-index.cjs +12 -0
- package/dist/mongodb-index.js +71119 -0
- package/dist/types/index.d.ts +90 -0
- package/dist/utils/index.d.ts +11 -0
- package/package.json +45 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface StringOperators {
|
|
2
|
+
$eq?: string;
|
|
3
|
+
$in?: string[];
|
|
4
|
+
$lt?: string;
|
|
5
|
+
$lte?: string;
|
|
6
|
+
$gt?: string;
|
|
7
|
+
$gte?: string;
|
|
8
|
+
$regex?: RegExp;
|
|
9
|
+
$ne?: string;
|
|
10
|
+
$nin?: string[];
|
|
11
|
+
$not?: StringOperators;
|
|
12
|
+
}
|
|
13
|
+
export interface NumberOperators {
|
|
14
|
+
$eq?: number;
|
|
15
|
+
$in?: number[];
|
|
16
|
+
$lt?: number;
|
|
17
|
+
$lte?: number;
|
|
18
|
+
$gt?: number;
|
|
19
|
+
$gte?: number;
|
|
20
|
+
$regex?: RegExp;
|
|
21
|
+
$ne?: number;
|
|
22
|
+
$nin?: number[];
|
|
23
|
+
$not?: NumberOperators;
|
|
24
|
+
}
|
|
25
|
+
export interface BooleanOperators {
|
|
26
|
+
$eq?: boolean;
|
|
27
|
+
$ne?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface DateOperators {
|
|
30
|
+
$eq?: Date | string;
|
|
31
|
+
$in?: Date[] | string[];
|
|
32
|
+
$lt?: Date | string;
|
|
33
|
+
$lte?: Date | string;
|
|
34
|
+
$gt?: Date | string;
|
|
35
|
+
$gte?: Date | string;
|
|
36
|
+
$ne?: Date | string;
|
|
37
|
+
$nin?: Date[] | string[];
|
|
38
|
+
$not?: DateOperators;
|
|
39
|
+
}
|
|
40
|
+
export type ColumnType = 'string' | 'number' | 'boolean' | 'json' | 'date';
|
|
41
|
+
export type SearchIndexSort = 'asc' | 'desc';
|
|
42
|
+
export interface ColumnMeta {
|
|
43
|
+
name: string;
|
|
44
|
+
type: ColumnType;
|
|
45
|
+
isPrimaryKey: boolean;
|
|
46
|
+
default?: any | ((data: any, context?: any) => any);
|
|
47
|
+
auto?: (data: any, context?: any) => any;
|
|
48
|
+
createdAt?: boolean;
|
|
49
|
+
updatedAt?: boolean;
|
|
50
|
+
searchIndex?: {
|
|
51
|
+
indexSort: SearchIndexSort;
|
|
52
|
+
options?: object;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export interface TableMeta {
|
|
56
|
+
tableName: string;
|
|
57
|
+
primaryKeys: string[];
|
|
58
|
+
columnKeys: string[];
|
|
59
|
+
updatedAtColumns: ColumnMeta[];
|
|
60
|
+
columns: ColumnMeta[];
|
|
61
|
+
searchIndexes?: Array<{
|
|
62
|
+
fieldName: string;
|
|
63
|
+
indexSort: SearchIndexSort;
|
|
64
|
+
options?: object;
|
|
65
|
+
}>;
|
|
66
|
+
}
|
|
67
|
+
export type SchemaMeta = Record<string, TableMeta>;
|
|
68
|
+
export interface PageResult<T = any> {
|
|
69
|
+
data: T[];
|
|
70
|
+
total: number;
|
|
71
|
+
page: number;
|
|
72
|
+
pageCount: number;
|
|
73
|
+
limit: number;
|
|
74
|
+
hasPrev: boolean;
|
|
75
|
+
hasNext: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface FindManyOptions<WHERE = Record<string, any>, ORDER_BY = Record<string, 'asc' | 'desc'>> {
|
|
78
|
+
where?: WHERE;
|
|
79
|
+
orderBy?: ORDER_BY;
|
|
80
|
+
limit?: number;
|
|
81
|
+
offset?: number;
|
|
82
|
+
select?: Record<string, boolean>;
|
|
83
|
+
}
|
|
84
|
+
export interface FindPageOptions<WHERE = Record<string, any>, ORDER_BY = Record<string, 'asc' | 'desc'>> {
|
|
85
|
+
where?: WHERE;
|
|
86
|
+
orderBy?: ORDER_BY;
|
|
87
|
+
page: number;
|
|
88
|
+
limit: number;
|
|
89
|
+
select?: Record<string, boolean>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TableMeta } from '../types/index';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 应用默认值
|
|
5
|
+
* 遍历columns,对缺失的字段应用默认值
|
|
6
|
+
* @param data - 输入数据对象
|
|
7
|
+
* @param tableMeta - 表元数据
|
|
8
|
+
* @param context - 运行时上下文
|
|
9
|
+
*/
|
|
10
|
+
export declare function applyDefaultValues(data: Record<string, any>, tableMeta: TableMeta, context?: any): Record<string, any>;
|
|
11
|
+
export declare function applyUpdateValues(data: Record<string, any>, tableMeta: TableMeta): Record<string, any>;
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "odm-client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "vite-node examples/index.ts",
|
|
17
|
+
"build": "vite build --ssr",
|
|
18
|
+
"publish-module": "npm run build && npm publish --registry=https://registry.npmjs.com",
|
|
19
|
+
"npm:adduser": "npm adduser --registry=https://registry.npmjs.com",
|
|
20
|
+
"init:mongodb": "vite-node generated/odm/mongodb-init.ts"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.com"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"author": "lanbomo",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@cloudbase/database": "^1.4.3",
|
|
31
|
+
"es-toolkit": "^1.44.0",
|
|
32
|
+
"mongodb": "^7.1.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.14.12",
|
|
36
|
+
"fast-glob": "^3.3.2",
|
|
37
|
+
"typescript": "^5.5.4",
|
|
38
|
+
"vite": "^5.3.5",
|
|
39
|
+
"vite-node": "^2.0.4",
|
|
40
|
+
"vite-plugin-dts": "4.0.0-beta.2"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
]
|
|
45
|
+
}
|