@ai0x0/utils 0.6.0 → 0.7.0
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/.agents/skills/ai0x0-utils/backend/SKILL.md +8 -5
- package/SKILL.md +8 -5
- package/es/backend/actions/create-delete-action.d.ts +2 -3
- package/es/backend/actions/create-delete-action.js +8 -44
- package/es/backend/actions/create-get-action.js +11 -7
- package/es/backend/actions/create-get-list-action.js +11 -6
- package/es/backend/actions/create-put-action.d.ts +1 -1
- package/es/backend/actions/create-put-action.js +15 -39
- package/es/backend/actions/get-list-data.d.ts +1 -1
- package/es/backend/actions/get-list-data.js +12 -5
- package/es/backend/actions/get-list-query-core.d.ts +67 -0
- package/es/backend/actions/get-list-query-core.js +306 -0
- package/es/backend/actions/get-list-query.d.ts +7 -18
- package/es/backend/actions/get-list-query.js +23 -220
- package/es/backend/actions/index.d.ts +1 -0
- package/es/backend/actions/index.js +2 -1
- package/es/backend/actions/paging.d.ts +11 -0
- package/es/backend/actions/paging.js +32 -0
- package/es/backend/actions/write-action-core.d.ts +18 -0
- package/es/backend/actions/write-action-core.js +119 -0
- package/es/backend/route-operation/write-operation-core.js +12 -5
- package/es/backend/schemas/common.d.ts +112 -0
- package/es/backend/schemas/common.js +158 -0
- package/es/backend/schemas/index.d.ts +735 -364
- package/es/backend/schemas/index.js +8 -139
- package/es/backend/sqlite/actions/create-delete-action.d.ts +1 -2
- package/es/backend/sqlite/actions/create-delete-action.js +7 -43
- package/es/backend/sqlite/actions/create-get-action.js +9 -6
- package/es/backend/sqlite/actions/create-get-list-action.js +7 -5
- package/es/backend/sqlite/actions/create-put-action.d.ts +1 -1
- package/es/backend/sqlite/actions/create-put-action.js +13 -36
- package/es/backend/sqlite/actions/get-list-data.d.ts +1 -1
- package/es/backend/sqlite/actions/get-list-data.js +11 -5
- package/es/backend/sqlite/actions/get-list-query.d.ts +6 -9
- package/es/backend/sqlite/actions/get-list-query.js +24 -217
- package/es/backend/sqlite/errors.d.ts +1 -4
- package/es/backend/sqlite/errors.js +6 -31
- package/es/backend/sqlite/schemas/index.d.ts +1 -111
- package/es/backend/sqlite/schemas/index.js +8 -139
- package/lib/backend/actions/create-delete-action.d.ts +2 -3
- package/lib/backend/actions/create-delete-action.js +2 -14
- package/lib/backend/actions/create-get-action.js +3 -1
- package/lib/backend/actions/create-get-list-action.js +3 -1
- package/lib/backend/actions/create-put-action.d.ts +1 -1
- package/lib/backend/actions/create-put-action.js +3 -16
- package/lib/backend/actions/get-list-data.d.ts +1 -1
- package/lib/backend/actions/get-list-data.js +8 -3
- package/lib/backend/actions/get-list-query-core.d.ts +67 -0
- package/lib/backend/actions/get-list-query-core.js +206 -0
- package/lib/backend/actions/get-list-query.d.ts +7 -18
- package/lib/backend/actions/get-list-query.js +16 -141
- package/lib/backend/actions/index.d.ts +1 -0
- package/lib/backend/actions/index.js +7 -2
- package/lib/backend/actions/paging.d.ts +11 -0
- package/lib/backend/actions/paging.js +50 -0
- package/lib/backend/actions/write-action-core.d.ts +18 -0
- package/lib/backend/actions/write-action-core.js +70 -0
- package/lib/backend/schemas/common.d.ts +112 -0
- package/lib/backend/schemas/common.js +112 -0
- package/lib/backend/schemas/index.d.ts +735 -364
- package/lib/backend/schemas/index.js +12 -83
- package/lib/backend/sqlite/actions/create-delete-action.d.ts +1 -2
- package/lib/backend/sqlite/actions/create-delete-action.js +2 -14
- package/lib/backend/sqlite/actions/create-get-action.js +3 -1
- package/lib/backend/sqlite/actions/create-get-list-action.js +3 -1
- package/lib/backend/sqlite/actions/create-put-action.d.ts +1 -1
- package/lib/backend/sqlite/actions/create-put-action.js +3 -16
- package/lib/backend/sqlite/actions/get-list-data.d.ts +1 -1
- package/lib/backend/sqlite/actions/get-list-data.js +8 -3
- package/lib/backend/sqlite/actions/get-list-query.d.ts +6 -9
- package/lib/backend/sqlite/actions/get-list-query.js +16 -141
- package/lib/backend/sqlite/errors.d.ts +1 -4
- package/lib/backend/sqlite/errors.js +2 -8
- package/lib/backend/sqlite/schemas/index.d.ts +1 -111
- package/lib/backend/sqlite/schemas/index.js +12 -83
- package/package.json +1 -1
|
@@ -19,18 +19,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/backend/sqlite/schemas/index.ts
|
|
20
20
|
var schemas_exports = {};
|
|
21
21
|
__export(schemas_exports, {
|
|
22
|
-
BASIC_INSERT_OMIT: () => BASIC_INSERT_OMIT,
|
|
23
|
-
BASIC_UPDATE_OMIT: () => BASIC_UPDATE_OMIT,
|
|
22
|
+
BASIC_INSERT_OMIT: () => import_common2.BASIC_INSERT_OMIT,
|
|
23
|
+
BASIC_UPDATE_OMIT: () => import_common2.BASIC_UPDATE_OMIT,
|
|
24
24
|
basicFields: () => basicFields,
|
|
25
25
|
createTableSchema: () => createTableSchema,
|
|
26
|
-
describeFields: () => describeFields,
|
|
27
|
-
listBodySchema: () => listBodySchema,
|
|
28
|
-
queryListSchema: () => queryListSchema
|
|
26
|
+
describeFields: () => import_common2.describeFields,
|
|
27
|
+
listBodySchema: () => import_common2.listBodySchema,
|
|
28
|
+
queryListSchema: () => import_common2.queryListSchema
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(schemas_exports);
|
|
31
31
|
var import_zod = require("zod");
|
|
32
32
|
var import_sqlite_core = require("drizzle-orm/sqlite-core");
|
|
33
33
|
var import_drizzle_zod = require("drizzle-zod");
|
|
34
|
+
var import_common = require("../../schemas/common");
|
|
35
|
+
var import_common2 = require("../../schemas/common");
|
|
34
36
|
var timestamp = (name) => (0, import_sqlite_core.integer)(name, { mode: "timestamp_ms" });
|
|
35
37
|
var now = () => /* @__PURE__ */ new Date();
|
|
36
38
|
var id = () => crypto.randomUUID();
|
|
@@ -45,79 +47,6 @@ var basicFields = {
|
|
|
45
47
|
createdAt: createdAt(),
|
|
46
48
|
updatedAt: updatedAt()
|
|
47
49
|
};
|
|
48
|
-
var BASIC_INSERT_OMIT = {
|
|
49
|
-
id: true,
|
|
50
|
-
creatorId: true,
|
|
51
|
-
editorId: true,
|
|
52
|
-
accessedAt: true,
|
|
53
|
-
createdAt: true,
|
|
54
|
-
updatedAt: true
|
|
55
|
-
};
|
|
56
|
-
var BASIC_UPDATE_OMIT = {
|
|
57
|
-
creatorId: true,
|
|
58
|
-
editorId: true,
|
|
59
|
-
accessedAt: true,
|
|
60
|
-
createdAt: true,
|
|
61
|
-
updatedAt: true
|
|
62
|
-
};
|
|
63
|
-
var queryListSchema = (schema) => import_zod.z.object({
|
|
64
|
-
current: import_zod.z.string().optional().default("1").describe("Page number, starting at 1."),
|
|
65
|
-
pageSize: import_zod.z.string().optional().default("10").describe(
|
|
66
|
-
"Rows per page. Omitting it yields only 10 — pass a larger value to get the whole set."
|
|
67
|
-
),
|
|
68
|
-
createdAtFrom: import_zod.z.string().optional().describe(
|
|
69
|
-
"Keep only rows created at or after this instant (ISO 8601, e.g. 2026-08-01T00:00:00Z)."
|
|
70
|
-
),
|
|
71
|
-
createdAtTo: import_zod.z.string().optional().describe("Keep only rows created at or before this instant."),
|
|
72
|
-
orderBy: import_zod.z.string().optional().describe(
|
|
73
|
-
"Column to sort by — a column name of this resource (createdAt / updatedAt and the like)."
|
|
74
|
-
),
|
|
75
|
-
creatorId: import_zod.z.string().optional().describe(
|
|
76
|
-
"Keep only rows created by this user. Useful in shared spaces to filter down to one member."
|
|
77
|
-
),
|
|
78
|
-
orderDir: import_zod.z.enum(["asc", "desc"]).optional().describe("Sort ascending or descending.")
|
|
79
|
-
}).merge(schema);
|
|
80
|
-
var listBodySchema = (schema) => import_zod.z.object({
|
|
81
|
-
total: import_zod.z.number().describe(
|
|
82
|
-
"Total number of rows matching the filters — not the length of `data`. Use it to decide whether another page exists."
|
|
83
|
-
),
|
|
84
|
-
data: import_zod.z.array(schema).describe("This page's rows.")
|
|
85
|
-
});
|
|
86
|
-
var BASIC_FIELD_NOTES = {
|
|
87
|
-
creatorId: "User id of the creator. Stamped by the server; clients cannot send it.",
|
|
88
|
-
editorId: "User id of whoever changed this row last. Stamped by the server; clients cannot send it.",
|
|
89
|
-
id: "Primary key of this row (uuid)."
|
|
90
|
-
};
|
|
91
|
-
var BASIC_TIMESTAMP_NOTES = {
|
|
92
|
-
accessedAt: "When this row was last accessed.",
|
|
93
|
-
createdAt: "When this row was created.",
|
|
94
|
-
updatedAt: "When this row was last modified."
|
|
95
|
-
};
|
|
96
|
-
var describeFields = (schema, notes) => {
|
|
97
|
-
const overlay = {};
|
|
98
|
-
for (const [field, note] of Object.entries(notes)) {
|
|
99
|
-
const existing = schema.shape[field];
|
|
100
|
-
if (existing) {
|
|
101
|
-
overlay[field] = existing.describe(note);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return Object.keys(overlay).length ? schema.extend(overlay) : schema;
|
|
105
|
-
};
|
|
106
|
-
var describeBasicFields = (schema) => {
|
|
107
|
-
const withNotes = describeFields(schema, BASIC_FIELD_NOTES);
|
|
108
|
-
const overlay = {};
|
|
109
|
-
for (const [field, note] of Object.entries(BASIC_TIMESTAMP_NOTES)) {
|
|
110
|
-
const existing = withNotes.shape[field];
|
|
111
|
-
if (existing) {
|
|
112
|
-
overlay[field] = existing.meta({
|
|
113
|
-
description: note,
|
|
114
|
-
format: "date-time",
|
|
115
|
-
type: "string"
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return Object.keys(overlay).length ? withNotes.extend(overlay) : withNotes;
|
|
120
|
-
};
|
|
121
50
|
var createTableSchema = ({ name, columns, serverColumns, extraConfig, describe }) => {
|
|
122
51
|
const mergedColumns = {
|
|
123
52
|
...basicFields,
|
|
@@ -130,15 +59,15 @@ var createTableSchema = ({ name, columns, serverColumns, extraConfig, describe }
|
|
|
130
59
|
extraConfig
|
|
131
60
|
);
|
|
132
61
|
const notes = describe ?? {};
|
|
133
|
-
const selectSchema = describeFields(
|
|
134
|
-
describeBasicFields((0, import_drizzle_zod.createSelectSchema)(table)),
|
|
62
|
+
const selectSchema = (0, import_common.describeFields)(
|
|
63
|
+
(0, import_common.describeBasicFields)((0, import_drizzle_zod.createSelectSchema)(table)),
|
|
135
64
|
notes
|
|
136
65
|
);
|
|
137
|
-
const insertSchema = describeFields(
|
|
66
|
+
const insertSchema = (0, import_common.describeFields)(
|
|
138
67
|
(0, import_drizzle_zod.createInsertSchema)((0, import_sqlite_core.sqliteTable)(name, columns)),
|
|
139
68
|
notes
|
|
140
69
|
);
|
|
141
|
-
const updateSchema = describeFields(
|
|
70
|
+
const updateSchema = (0, import_common.describeFields)(
|
|
142
71
|
(0, import_drizzle_zod.createUpdateSchema)(
|
|
143
72
|
(0, import_sqlite_core.sqliteTable)(name, { id: (0, import_sqlite_core.text)("id"), ...columns })
|
|
144
73
|
).extend({
|
|
@@ -149,7 +78,7 @@ var createTableSchema = ({ name, columns, serverColumns, extraConfig, describe }
|
|
|
149
78
|
const querySchema = import_zod.z.object({
|
|
150
79
|
id: import_zod.z.string().describe("Id of the row to fetch.")
|
|
151
80
|
});
|
|
152
|
-
const queryListWithSchema = queryListSchema(
|
|
81
|
+
const queryListWithSchema = (0, import_common.queryListSchema)(
|
|
153
82
|
import_zod.z.object({}).catchall(import_zod.z.unknown())
|
|
154
83
|
);
|
|
155
84
|
return {
|