@ai0x0/utils 0.0.40 → 0.0.41
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 +3 -1
- package/SKILL.md +3 -1
- package/es/backend/route-operation/delete-operation.js +1 -1
- package/es/backend/route-operation/get-list-operation.js +1 -1
- package/es/backend/route-operation/get-operation.js +1 -1
- package/es/backend/route-operation/post-operation.js +1 -1
- package/es/backend/route-operation/put-operation.js +1 -1
- package/es/backend/sqlite/route-operation/delete-operation.js +1 -1
- package/es/backend/sqlite/route-operation/get-list-operation.js +1 -1
- package/es/backend/sqlite/route-operation/get-operation.js +1 -1
- package/es/backend/sqlite/route-operation/post-operation.js +1 -1
- package/es/backend/sqlite/route-operation/put-operation.js +1 -1
- package/lib/backend/route-operation/delete-operation.js +1 -1
- package/lib/backend/route-operation/get-list-operation.js +1 -1
- package/lib/backend/route-operation/get-operation.js +1 -1
- package/lib/backend/route-operation/post-operation.js +3 -1
- package/lib/backend/route-operation/put-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/delete-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/get-list-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/get-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/post-operation.js +3 -1
- package/lib/backend/sqlite/route-operation/put-operation.js +1 -1
- package/package.json +1 -1
|
@@ -81,6 +81,8 @@ export const getOperation = createGetOperation({ db, getSession });
|
|
|
81
81
|
export const getListOperation = createGetListOperation({ db, getSession });
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
`db` may be omitted for operation-only endpoints that should not touch the database even when `table` is supplied for OpenAPI tags.
|
|
85
|
+
|
|
84
86
|
`getSession(req)` **must** return `{ userId?: string } | undefined` (a Promise is fine). Throwing rejects the request; returning `undefined` disables ownership checks for that call.
|
|
85
87
|
|
|
86
88
|
## Factory Catalog
|
|
@@ -96,7 +98,7 @@ export const getListOperation = createGetListOperation({ db, getSession });
|
|
|
96
98
|
|
|
97
99
|
`tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
|
|
98
100
|
|
|
99
|
-
`table`
|
|
101
|
+
`table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
|
|
100
102
|
|
|
101
103
|
## Canonical Examples
|
|
102
104
|
|
package/SKILL.md
CHANGED
|
@@ -60,6 +60,8 @@ export const getOperation = createGetOperation({ db, getSession });
|
|
|
60
60
|
export const getListOperation = createGetListOperation({ db, getSession });
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
`db` may be omitted for operation-only endpoints that should not touch the database even when `table` is supplied for OpenAPI tags.
|
|
64
|
+
|
|
63
65
|
`getSession(req)` **must** return `{ userId?: string } | undefined` (a Promise is fine). Throwing rejects the request; returning `undefined` disables ownership checks for that call.
|
|
64
66
|
|
|
65
67
|
## Factory Catalog
|
|
@@ -75,7 +77,7 @@ export const getListOperation = createGetListOperation({ db, getSession });
|
|
|
75
77
|
|
|
76
78
|
`tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
|
|
77
79
|
|
|
78
|
-
`table`
|
|
80
|
+
`table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
|
|
79
81
|
|
|
80
82
|
## Canonical Examples
|
|
81
83
|
|
|
@@ -71,7 +71,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
|
|
|
71
71
|
params.creatorId = userId;
|
|
72
72
|
case 16:
|
|
73
73
|
mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
|
|
74
|
-
if (!table) {
|
|
74
|
+
if (!(table && db)) {
|
|
75
75
|
_context.next = 23;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
@@ -70,7 +70,7 @@ export var createGetOperation = function createGetOperation(_ref) {
|
|
|
70
70
|
params.creatorId = userId;
|
|
71
71
|
case 16:
|
|
72
72
|
mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
|
|
73
|
-
if (!table) {
|
|
73
|
+
if (!(table && db)) {
|
|
74
74
|
_context.next = 23;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
@@ -71,7 +71,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
|
|
|
71
71
|
params.creatorId = userId;
|
|
72
72
|
case 16:
|
|
73
73
|
mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
|
|
74
|
-
if (!table) {
|
|
74
|
+
if (!(table && db)) {
|
|
75
75
|
_context.next = 23;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
@@ -70,7 +70,7 @@ export var createGetOperation = function createGetOperation(_ref) {
|
|
|
70
70
|
params.creatorId = userId;
|
|
71
71
|
case 16:
|
|
72
72
|
mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
|
|
73
|
-
if (!table) {
|
|
73
|
+
if (!(table && db)) {
|
|
74
74
|
_context.next = 23;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
@@ -65,7 +65,7 @@ var createDeleteOperation = ({
|
|
|
65
65
|
const { userId } = await getSession(req) || {};
|
|
66
66
|
body.creatorId = userId;
|
|
67
67
|
}
|
|
68
|
-
const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
68
|
+
const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
69
69
|
await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
|
|
70
70
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
71
71
|
status: 200
|
|
@@ -78,7 +78,7 @@ var createGetListOperation = ({
|
|
|
78
78
|
Object.fromEntries(new URL(req.url).searchParams),
|
|
79
79
|
params
|
|
80
80
|
);
|
|
81
|
-
let result = table ? await (0, import_actions.createGetListAction)({
|
|
81
|
+
let result = table && db ? await (0, import_actions.createGetListAction)({
|
|
82
82
|
bodySchema,
|
|
83
83
|
db,
|
|
84
84
|
jsonArrayFields,
|
|
@@ -77,7 +77,7 @@ var createGetOperation = ({
|
|
|
77
77
|
Object.fromEntries(new URL(req.url).searchParams),
|
|
78
78
|
params
|
|
79
79
|
);
|
|
80
|
-
const rawResult = table ? await (0, import_actions.createGetAction)({
|
|
80
|
+
const rawResult = table && db ? await (0, import_actions.createGetAction)({
|
|
81
81
|
bodySchema,
|
|
82
82
|
db,
|
|
83
83
|
jsonArrayFields,
|
|
@@ -72,7 +72,9 @@ var createPostOperation = ({
|
|
|
72
72
|
)) || {};
|
|
73
73
|
const mergedBody = { ...body, ...extraBody };
|
|
74
74
|
const params = { creatorId: userId, ...mergedBody };
|
|
75
|
-
const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
|
|
75
|
+
const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
|
|
76
|
+
params
|
|
77
|
+
))[0] : params;
|
|
76
78
|
const data = onSuccess ? await onSuccess({
|
|
77
79
|
data: raw,
|
|
78
80
|
params
|
|
@@ -74,7 +74,7 @@ var createPutOperation = ({
|
|
|
74
74
|
)) || {};
|
|
75
75
|
const mergedBody = { ...body, ...extraBody };
|
|
76
76
|
const params = { editorId: userId, ...mergedBody };
|
|
77
|
-
const raw = table ? await (0, import_actions.createPutAction)({
|
|
77
|
+
const raw = table && db ? await (0, import_actions.createPutAction)({
|
|
78
78
|
bodySchema,
|
|
79
79
|
table,
|
|
80
80
|
db
|
|
@@ -65,7 +65,7 @@ var createDeleteOperation = ({
|
|
|
65
65
|
const { userId } = await getSession(req) || {};
|
|
66
66
|
body.creatorId = userId;
|
|
67
67
|
}
|
|
68
|
-
const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
68
|
+
const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
69
69
|
await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
|
|
70
70
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
71
71
|
status: 200
|
|
@@ -78,7 +78,7 @@ var createGetListOperation = ({
|
|
|
78
78
|
Object.fromEntries(new URL(req.url).searchParams),
|
|
79
79
|
params
|
|
80
80
|
);
|
|
81
|
-
let result = table ? await (0, import_actions.createGetListAction)({
|
|
81
|
+
let result = table && db ? await (0, import_actions.createGetListAction)({
|
|
82
82
|
bodySchema,
|
|
83
83
|
db,
|
|
84
84
|
jsonArrayFields,
|
|
@@ -77,7 +77,7 @@ var createGetOperation = ({
|
|
|
77
77
|
Object.fromEntries(new URL(req.url).searchParams),
|
|
78
78
|
params
|
|
79
79
|
);
|
|
80
|
-
const rawResult = table ? await (0, import_actions.createGetAction)({
|
|
80
|
+
const rawResult = table && db ? await (0, import_actions.createGetAction)({
|
|
81
81
|
bodySchema,
|
|
82
82
|
db,
|
|
83
83
|
jsonArrayFields,
|
|
@@ -72,7 +72,9 @@ var createPostOperation = ({
|
|
|
72
72
|
)) || {};
|
|
73
73
|
const mergedBody = { ...body, ...extraBody };
|
|
74
74
|
const params = { creatorId: userId, ...mergedBody };
|
|
75
|
-
const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
|
|
75
|
+
const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
|
|
76
|
+
params
|
|
77
|
+
))[0] : params;
|
|
76
78
|
const data = onSuccess ? await onSuccess({
|
|
77
79
|
data: raw,
|
|
78
80
|
params
|
|
@@ -74,7 +74,7 @@ var createPutOperation = ({
|
|
|
74
74
|
)) || {};
|
|
75
75
|
const mergedBody = { ...body, ...extraBody };
|
|
76
76
|
const params = { editorId: userId, ...mergedBody };
|
|
77
|
-
const raw = table ? await (0, import_actions.createPutAction)({
|
|
77
|
+
const raw = table && db ? await (0, import_actions.createPutAction)({
|
|
78
78
|
bodySchema,
|
|
79
79
|
table,
|
|
80
80
|
db
|