@lark-apaas/devtool-kits 1.2.6 → 1.2.7
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/error.html +30 -197
- package/dist/index.cjs +1363 -28599
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +1346 -28610
- package/dist/index.js.map +1 -1
- package/dist/template/types.ts +69 -0
- package/package.json +3 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { sql } from 'drizzle-orm';
|
|
2
|
+
import { customType } from 'drizzle-orm/pg-core';
|
|
3
|
+
|
|
4
|
+
export const userProfile = customType<{
|
|
5
|
+
data: string;
|
|
6
|
+
driverData: string;
|
|
7
|
+
}>({
|
|
8
|
+
dataType() {
|
|
9
|
+
return 'user_profile';
|
|
10
|
+
},
|
|
11
|
+
toDriver(value: string) {
|
|
12
|
+
return sql`ROW(${value})::user_profile`;
|
|
13
|
+
},
|
|
14
|
+
fromDriver(value: string) {
|
|
15
|
+
const [userId] = value.slice(1, -1).split(',');
|
|
16
|
+
return userId.trim();
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type FileAttachment = {
|
|
21
|
+
bucket_id: string;
|
|
22
|
+
file_path: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const fileAttachment = customType<{
|
|
26
|
+
data: FileAttachment;
|
|
27
|
+
driverData: string;
|
|
28
|
+
}>({
|
|
29
|
+
dataType() {
|
|
30
|
+
return 'file_attachment';
|
|
31
|
+
},
|
|
32
|
+
toDriver(value: FileAttachment) {
|
|
33
|
+
return sql`ROW(${value.bucket_id},${value.file_path})::file_attachment`;
|
|
34
|
+
},
|
|
35
|
+
fromDriver(value: string): FileAttachment {
|
|
36
|
+
const [bucketId, filePath] = value.slice(1, -1).split(',');
|
|
37
|
+
return { bucket_id: bucketId.trim(), file_path: filePath.trim() };
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const customTimestamptz = customType<{
|
|
42
|
+
data: Date;
|
|
43
|
+
driverData: string;
|
|
44
|
+
config: { precision?: number};
|
|
45
|
+
}>({
|
|
46
|
+
dataType(config) {
|
|
47
|
+
const precision = typeof config?.precision !== 'undefined'
|
|
48
|
+
? ` (${config.precision})`
|
|
49
|
+
: '';
|
|
50
|
+
return `timestamptz${precision}`;
|
|
51
|
+
},
|
|
52
|
+
toDriver(value: Date | string | number){
|
|
53
|
+
if(value == null) return value as any;
|
|
54
|
+
if (typeof value === 'number') {
|
|
55
|
+
return new Date(value).toISOString();
|
|
56
|
+
}
|
|
57
|
+
if(typeof value === 'string') {
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
if (value instanceof Date) {
|
|
61
|
+
return value.toISOString();
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Invalid timestamp value');
|
|
64
|
+
},
|
|
65
|
+
fromDriver(value: string | Date): Date {
|
|
66
|
+
if(value instanceof Date) return value;
|
|
67
|
+
return new Date(value);
|
|
68
|
+
},
|
|
69
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/devtool-kits",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "FullStack Devtool Kits",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"test": "vitest run",
|
|
35
35
|
"test:watch": "vitest",
|
|
36
36
|
"lint": "echo 'ESLint skipped for TypeScript files'",
|
|
37
|
-
"lint:fix": "eslint src --ext .ts --fix"
|
|
37
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
38
|
+
"prepublishOnly": "npm run build"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"inflection": "^3.0.2",
|