@ai0x0/utils 0.0.15 → 0.0.17
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/SKILL.md +336 -0
- package/es/backend/actions/create-delete-action.d.ts +3 -4
- package/es/backend/actions/create-get-action.d.ts +2 -3
- package/es/backend/actions/create-get-list-action.d.ts +2 -3
- package/es/backend/actions/create-post-action.d.ts +4 -4
- package/es/backend/actions/create-put-action.d.ts +2 -3
- package/es/backend/actions/get-list-query.d.ts +4 -12
- package/es/backend/actions/get-list-query.js +11 -8
- package/es/backend/route-operation/delete-operation.d.ts +2 -3
- package/es/backend/route-operation/get-list-operation.d.ts +2 -3
- package/es/backend/route-operation/get-operation.d.ts +2 -3
- package/es/backend/route-operation/get-table-name.d.ts +2 -2
- package/es/backend/route-operation/post-operation.d.ts +5 -5
- package/es/backend/route-operation/put-operation.d.ts +4 -5
- package/es/backend/schemas/index.d.ts +598 -597
- package/es/backend/schemas/index.js +19 -31
- package/es/backend/types.d.ts +14 -8
- package/lib/backend/actions/create-delete-action.d.ts +3 -4
- package/lib/backend/actions/create-get-action.d.ts +2 -3
- package/lib/backend/actions/create-get-list-action.d.ts +2 -3
- package/lib/backend/actions/create-post-action.d.ts +4 -4
- package/lib/backend/actions/create-post-action.js +1 -4
- package/lib/backend/actions/create-put-action.d.ts +2 -3
- package/lib/backend/actions/get-list-query.d.ts +4 -12
- package/lib/backend/actions/get-list-query.js +7 -6
- package/lib/backend/route-operation/delete-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-list-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-table-name.d.ts +2 -2
- package/lib/backend/route-operation/post-operation.d.ts +5 -5
- package/lib/backend/route-operation/put-operation.d.ts +4 -5
- package/lib/backend/schemas/index.d.ts +598 -597
- package/lib/backend/schemas/index.js +21 -21
- package/lib/backend/types.d.ts +14 -8
- package/package.json +3 -2
|
@@ -21,34 +21,29 @@ var schemas_exports = {};
|
|
|
21
21
|
__export(schemas_exports, {
|
|
22
22
|
basicFields: () => basicFields,
|
|
23
23
|
createTableSchema: () => createTableSchema,
|
|
24
|
+
integer: () => import_sqlite_core.integer,
|
|
24
25
|
listBodySchema: () => listBodySchema,
|
|
25
|
-
queryListSchema: () => queryListSchema
|
|
26
|
+
queryListSchema: () => queryListSchema,
|
|
27
|
+
text: () => import_sqlite_core.text
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(schemas_exports);
|
|
28
30
|
var import_zod = require("zod");
|
|
29
|
-
var
|
|
31
|
+
var import_sqlite_core = require("drizzle-orm/sqlite-core");
|
|
30
32
|
var import_drizzle_zod = require("drizzle-zod");
|
|
31
|
-
var
|
|
32
|
-
var createdAt = () => timestamptz("created_at").notNull().defaultNow();
|
|
33
|
-
var updatedAt = () => timestamptz("updated_at").notNull().defaultNow();
|
|
34
|
-
var accessedAt = () => timestamptz("accessed_at").notNull().defaultNow();
|
|
33
|
+
var timestamp = (name) => (0, import_sqlite_core.text)(name).$defaultFn(() => (/* @__PURE__ */ new Date()).toISOString());
|
|
35
34
|
var basicFields = {
|
|
36
|
-
id: (0,
|
|
37
|
-
creatorId: (0,
|
|
38
|
-
editorId: (0,
|
|
39
|
-
accessedAt:
|
|
40
|
-
createdAt:
|
|
41
|
-
updatedAt:
|
|
35
|
+
id: (0, import_sqlite_core.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
36
|
+
creatorId: (0, import_sqlite_core.text)("creator_id"),
|
|
37
|
+
editorId: (0, import_sqlite_core.text)("editor_id"),
|
|
38
|
+
accessedAt: timestamp("accessed_at").notNull(),
|
|
39
|
+
createdAt: timestamp("created_at").notNull(),
|
|
40
|
+
updatedAt: timestamp("updated_at").notNull()
|
|
42
41
|
};
|
|
43
42
|
var queryListSchema = (schema) => import_zod.z.object({
|
|
44
43
|
current: import_zod.z.string().optional().default("1"),
|
|
45
|
-
// 默认页码为 1
|
|
46
44
|
pageSize: import_zod.z.string().optional().default("10"),
|
|
47
|
-
// 默认每页条数为 10
|
|
48
45
|
createdAtFrom: import_zod.z.string().optional(),
|
|
49
|
-
// 筛选开始日期
|
|
50
46
|
createdAtTo: import_zod.z.string().optional(),
|
|
51
|
-
// 筛选结束日期
|
|
52
47
|
orderBy: import_zod.z.string().optional(),
|
|
53
48
|
creatorId: import_zod.z.string().optional(),
|
|
54
49
|
orderDir: import_zod.z.enum(["asc", "desc"]).optional()
|
|
@@ -63,7 +58,7 @@ var createTableSchema = ({
|
|
|
63
58
|
refineSchema,
|
|
64
59
|
extraConfig
|
|
65
60
|
}) => {
|
|
66
|
-
const table = (0,
|
|
61
|
+
const table = (0, import_sqlite_core.sqliteTable)(
|
|
67
62
|
name,
|
|
68
63
|
{
|
|
69
64
|
...basicFields,
|
|
@@ -75,9 +70,12 @@ var createTableSchema = ({
|
|
|
75
70
|
table,
|
|
76
71
|
refineSchema
|
|
77
72
|
);
|
|
78
|
-
const insertTable = (0,
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
const insertTable = (0, import_sqlite_core.sqliteTable)(
|
|
74
|
+
name,
|
|
75
|
+
columns
|
|
76
|
+
);
|
|
77
|
+
const updateTable = (0, import_sqlite_core.sqliteTable)(name, {
|
|
78
|
+
id: (0, import_sqlite_core.text)("id"),
|
|
81
79
|
...columns
|
|
82
80
|
});
|
|
83
81
|
return {
|
|
@@ -103,6 +101,8 @@ var createTableSchema = ({
|
|
|
103
101
|
0 && (module.exports = {
|
|
104
102
|
basicFields,
|
|
105
103
|
createTableSchema,
|
|
104
|
+
integer,
|
|
106
105
|
listBodySchema,
|
|
107
|
-
queryListSchema
|
|
106
|
+
queryListSchema,
|
|
107
|
+
text
|
|
108
108
|
});
|
package/lib/backend/types.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SQLiteColumn, SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
2
2
|
import { SQL } from "drizzle-orm";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 对底层 drizzle 数据库实例做最宽松的约束:
|
|
5
|
+
* 只要能 `select / insert / update / delete` 并支持 drizzle 语法即可,
|
|
6
|
+
* 从而允许在不同 driver(如 drizzle-orm/d1)之间切换。
|
|
7
|
+
*/
|
|
8
|
+
export type AnyDatabase = any;
|
|
9
|
+
export interface BaseTable extends SQLiteTable {
|
|
10
|
+
id: SQLiteColumn;
|
|
11
|
+
creatorId: SQLiteColumn;
|
|
12
|
+
editorId: SQLiteColumn;
|
|
13
|
+
accessedAt: SQLiteColumn;
|
|
14
|
+
createdAt: SQLiteColumn;
|
|
15
|
+
updatedAt: SQLiteColumn;
|
|
10
16
|
}
|
|
11
17
|
export type GetListRelations = {
|
|
12
18
|
groupBy?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai0x0/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "AI0x0 utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai0x0"
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"types": "./lib/index.d.ts",
|
|
22
22
|
"files": [
|
|
23
23
|
"lib",
|
|
24
|
-
"es"
|
|
24
|
+
"es",
|
|
25
|
+
"SKILL.md"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build": "node scripts/build.mjs",
|