@ai0x0/utils 0.0.47 → 0.0.48
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 +40 -38
- package/SKILL.md +39 -37
- package/es/__shims__/next-rest-framework.d.ts +2 -0
- package/es/backend/route-operation/delete-operation.d.ts +7 -24
- package/es/backend/route-operation/delete-operation.js +9 -127
- package/es/backend/route-operation/get-list-operation.d.ts +5 -31
- package/es/backend/route-operation/get-list-operation.js +10 -142
- package/es/backend/route-operation/get-operation.d.ts +5 -25
- package/es/backend/route-operation/get-operation.js +10 -139
- package/es/backend/route-operation/get-table-name.js +0 -2
- package/es/backend/route-operation/index.d.ts +1 -0
- package/es/backend/route-operation/index.js +2 -1
- package/es/backend/route-operation/open-api-operation.d.ts +6 -0
- package/es/backend/route-operation/open-api-operation.js +13 -0
- package/es/backend/route-operation/operation-common.d.ts +38 -0
- package/es/backend/route-operation/operation-common.js +148 -0
- package/es/backend/route-operation/operation-core.d.ts +3 -0
- package/es/backend/route-operation/operation-core.js +3 -0
- package/es/backend/route-operation/post-operation.d.ts +5 -25
- package/es/backend/route-operation/post-operation.js +13 -189
- package/es/backend/route-operation/put-operation.d.ts +4 -23
- package/es/backend/route-operation/put-operation.js +10 -155
- package/es/backend/route-operation/read-operation-core.d.ts +55 -0
- package/es/backend/route-operation/read-operation-core.js +224 -0
- package/es/backend/route-operation/write-operation-core.d.ts +94 -0
- package/es/backend/route-operation/write-operation-core.js +390 -0
- package/es/backend/sqlite/route-operation/delete-operation.d.ts +9 -26
- package/es/backend/sqlite/route-operation/delete-operation.js +9 -127
- package/es/backend/sqlite/route-operation/get-list-operation.d.ts +6 -32
- package/es/backend/sqlite/route-operation/get-list-operation.js +10 -142
- package/es/backend/sqlite/route-operation/get-operation.d.ts +6 -26
- package/es/backend/sqlite/route-operation/get-operation.js +10 -139
- package/es/backend/sqlite/route-operation/index.d.ts +1 -0
- package/es/backend/sqlite/route-operation/index.js +2 -1
- package/es/backend/sqlite/route-operation/post-operation.d.ts +6 -26
- package/es/backend/sqlite/route-operation/post-operation.js +13 -189
- package/es/backend/sqlite/route-operation/put-operation.d.ts +6 -25
- package/es/backend/sqlite/route-operation/put-operation.js +10 -155
- package/lib/__shims__/next-rest-framework.d.ts +2 -0
- package/lib/backend/route-operation/delete-operation.d.ts +7 -24
- package/lib/backend/route-operation/delete-operation.js +6 -56
- package/lib/backend/route-operation/get-list-operation.d.ts +5 -31
- package/lib/backend/route-operation/get-list-operation.js +7 -72
- package/lib/backend/route-operation/get-operation.d.ts +5 -25
- package/lib/backend/route-operation/get-operation.js +7 -71
- package/lib/backend/route-operation/index.d.ts +1 -0
- package/lib/backend/route-operation/index.js +3 -1
- package/lib/backend/route-operation/open-api-operation.d.ts +6 -0
- package/lib/backend/route-operation/open-api-operation.js +37 -0
- package/lib/backend/route-operation/operation-common.d.ts +38 -0
- package/lib/backend/route-operation/operation-common.js +90 -0
- package/lib/backend/route-operation/operation-core.d.ts +3 -0
- package/lib/backend/route-operation/operation-core.js +27 -0
- package/lib/backend/route-operation/post-operation.d.ts +5 -25
- package/lib/backend/route-operation/post-operation.js +7 -71
- package/lib/backend/route-operation/put-operation.d.ts +4 -23
- package/lib/backend/route-operation/put-operation.js +7 -68
- package/lib/backend/route-operation/read-operation-core.d.ts +55 -0
- package/lib/backend/route-operation/read-operation-core.js +151 -0
- package/lib/backend/route-operation/write-operation-core.d.ts +94 -0
- package/lib/backend/route-operation/write-operation-core.js +181 -0
- package/lib/backend/sqlite/route-operation/delete-operation.d.ts +9 -26
- package/lib/backend/sqlite/route-operation/delete-operation.js +6 -56
- package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +6 -32
- package/lib/backend/sqlite/route-operation/get-list-operation.js +7 -75
- package/lib/backend/sqlite/route-operation/get-operation.d.ts +6 -26
- package/lib/backend/sqlite/route-operation/get-operation.js +7 -71
- package/lib/backend/sqlite/route-operation/index.d.ts +1 -0
- package/lib/backend/sqlite/route-operation/index.js +3 -1
- package/lib/backend/sqlite/route-operation/post-operation.d.ts +6 -26
- package/lib/backend/sqlite/route-operation/post-operation.js +7 -71
- package/lib/backend/sqlite/route-operation/put-operation.d.ts +6 -25
- package/lib/backend/sqlite/route-operation/put-operation.js +7 -68
- package/package.json +1 -1
|
@@ -1,147 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
-
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
1
|
+
import { createGetListAction } from "../actions/create-get-list-action.js";
|
|
2
|
+
import { createGetListOperationFactory } from "../../route-operation/operation-core.js";
|
|
11
3
|
import getTableName from "./get-table-name.js";
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
var createOperation = createGetListOperationFactory({
|
|
5
|
+
createAction: createGetListAction,
|
|
6
|
+
getTableName: getTableName
|
|
7
|
+
});
|
|
14
8
|
export var createGetListOperation = function createGetListOperation(_ref) {
|
|
15
9
|
var db = _ref.db,
|
|
16
10
|
getSession = _ref.getSession;
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
description = _ref2.description,
|
|
22
|
-
summary = _ref2.summary,
|
|
23
|
-
tags = _ref2.tags,
|
|
24
|
-
relations = _ref2.relations,
|
|
25
|
-
jsonArrayFields = _ref2.jsonArrayFields,
|
|
26
|
-
setParams = _ref2.setParams,
|
|
27
|
-
onSuccess = _ref2.onSuccess,
|
|
28
|
-
onError = _ref2.onError,
|
|
29
|
-
_ref2$byCreator = _ref2.byCreator,
|
|
30
|
-
byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
|
|
31
|
-
return routeOperation({
|
|
32
|
-
method: "GET",
|
|
33
|
-
openApiOperation: {
|
|
34
|
-
description: description,
|
|
35
|
-
summary: summary,
|
|
36
|
-
tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
|
|
37
|
-
}
|
|
38
|
-
}).input({
|
|
39
|
-
query: querySchema
|
|
40
|
-
}).outputs([{
|
|
41
|
-
body: listBodySchema(bodySchema),
|
|
42
|
-
contentType: "application/json",
|
|
43
|
-
status: 200
|
|
44
|
-
}]).handler( /*#__PURE__*/function () {
|
|
45
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
46
|
-
var extraParams, _ref4, userId, queryParams, mergedParams, tableParams, result, response;
|
|
47
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
48
|
-
while (1) switch (_context.prev = _context.next) {
|
|
49
|
-
case 0:
|
|
50
|
-
_context.prev = 0;
|
|
51
|
-
_context.next = 3;
|
|
52
|
-
return setParams === null || setParams === void 0 ? void 0 : setParams(req);
|
|
53
|
-
case 3:
|
|
54
|
-
_context.t0 = _context.sent;
|
|
55
|
-
if (_context.t0) {
|
|
56
|
-
_context.next = 6;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
_context.t0 = {};
|
|
60
|
-
case 6:
|
|
61
|
-
extraParams = _context.t0;
|
|
62
|
-
if (!byCreator) {
|
|
63
|
-
_context.next = 16;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
_context.next = 10;
|
|
67
|
-
return getSession(req);
|
|
68
|
-
case 10:
|
|
69
|
-
_context.t1 = _context.sent;
|
|
70
|
-
if (_context.t1) {
|
|
71
|
-
_context.next = 13;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
_context.t1 = {};
|
|
75
|
-
case 13:
|
|
76
|
-
_ref4 = _context.t1;
|
|
77
|
-
userId = _ref4.userId;
|
|
78
|
-
extraParams.creatorId = userId;
|
|
79
|
-
case 16:
|
|
80
|
-
queryParams = querySchema.parse(Object.fromEntries(new URL(req.url).searchParams));
|
|
81
|
-
mergedParams = _objectSpread(_objectSpread({}, queryParams), extraParams);
|
|
82
|
-
tableParams = mergedParams;
|
|
83
|
-
if (!(table && db)) {
|
|
84
|
-
_context.next = 25;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
_context.next = 22;
|
|
88
|
-
return createGetListAction({
|
|
89
|
-
bodySchema: bodySchema,
|
|
90
|
-
db: db,
|
|
91
|
-
jsonArrayFields: jsonArrayFields,
|
|
92
|
-
relations: relations,
|
|
93
|
-
table: table
|
|
94
|
-
})(tableParams);
|
|
95
|
-
case 22:
|
|
96
|
-
_context.t2 = _context.sent;
|
|
97
|
-
_context.next = 26;
|
|
98
|
-
break;
|
|
99
|
-
case 25:
|
|
100
|
-
_context.t2 = {
|
|
101
|
-
data: [],
|
|
102
|
-
total: 0
|
|
103
|
-
};
|
|
104
|
-
case 26:
|
|
105
|
-
result = _context.t2;
|
|
106
|
-
if (!onSuccess) {
|
|
107
|
-
_context.next = 31;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
_context.next = 30;
|
|
111
|
-
return onSuccess({
|
|
112
|
-
data: result,
|
|
113
|
-
params: mergedParams
|
|
114
|
-
});
|
|
115
|
-
case 30:
|
|
116
|
-
result = _context.sent;
|
|
117
|
-
case 31:
|
|
118
|
-
return _context.abrupt("return", TypedNextResponse.json(result, {
|
|
119
|
-
status: 200
|
|
120
|
-
}));
|
|
121
|
-
case 34:
|
|
122
|
-
_context.prev = 34;
|
|
123
|
-
_context.t3 = _context["catch"](0);
|
|
124
|
-
console.error(_context.t3);
|
|
125
|
-
_context.next = 39;
|
|
126
|
-
return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
|
|
127
|
-
case 39:
|
|
128
|
-
response = _context.sent;
|
|
129
|
-
if (!response) {
|
|
130
|
-
_context.next = 44;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
return _context.abrupt("return", response);
|
|
134
|
-
case 44:
|
|
135
|
-
throw _context.t3;
|
|
136
|
-
case 45:
|
|
137
|
-
case "end":
|
|
138
|
-
return _context.stop();
|
|
139
|
-
}
|
|
140
|
-
}, _callee, null, [[0, 34]]);
|
|
141
|
-
}));
|
|
142
|
-
return function (_x) {
|
|
143
|
-
return _ref3.apply(this, arguments);
|
|
144
|
-
};
|
|
145
|
-
}());
|
|
146
|
-
};
|
|
11
|
+
return createOperation({
|
|
12
|
+
db: db,
|
|
13
|
+
getSession: getSession
|
|
14
|
+
});
|
|
147
15
|
};
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import { z, ZodSchema } from "zod";
|
|
2
1
|
import { NextRequest } from "next/server";
|
|
3
|
-
import {
|
|
2
|
+
import { ZodSchema } from "zod";
|
|
4
3
|
import { BaseTable, GetListRelations } from "../types.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
9
|
-
bodySchema: T;
|
|
10
|
-
jsonArrayFields?: string[];
|
|
11
|
-
querySchema: Q;
|
|
12
|
-
relations?: GetListRelations;
|
|
13
|
-
setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
|
|
14
|
-
onSuccess?: (_payload: {
|
|
15
|
-
params: GetOperationParams<Q>;
|
|
16
|
-
data: z.infer<T>;
|
|
17
|
-
}) => Promise<z.infer<T>>;
|
|
18
|
-
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
19
|
-
description?: string;
|
|
20
|
-
summary?: string;
|
|
21
|
-
tags?: string[];
|
|
22
|
-
table?: TTable;
|
|
23
|
-
byCreator?: boolean;
|
|
24
|
-
}
|
|
4
|
+
import { type GetOperationOptions as CoreGetOperationOptions } from "../../route-operation/operation-core.js";
|
|
5
|
+
export type GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> = CoreGetOperationOptions<T, Q, TTable, GetListRelations>;
|
|
25
6
|
export declare const createGetOperation: ({ getSession, db, }: {
|
|
26
|
-
db?:
|
|
27
|
-
getSession
|
|
7
|
+
db?: unknown;
|
|
8
|
+
getSession(req: NextRequest): Promise<{
|
|
28
9
|
userId?: string;
|
|
29
10
|
} | undefined>;
|
|
30
|
-
}) => <T extends
|
|
31
|
-
export {};
|
|
11
|
+
}) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, setParams, jsonArrayFields, handler, catch: catchHandler, }: CoreGetOperationOptions<T, Q, BaseTable, GetListRelations>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
|
|
@@ -1,144 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
-
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
1
|
+
import { createGetAction } from "../actions/create-get-action.js";
|
|
2
|
+
import { createGetOperationFactory } from "../../route-operation/operation-core.js";
|
|
11
3
|
import getTableName from "./get-table-name.js";
|
|
12
|
-
|
|
4
|
+
var createOperation = createGetOperationFactory({
|
|
5
|
+
createAction: createGetAction,
|
|
6
|
+
getTableName: getTableName
|
|
7
|
+
});
|
|
13
8
|
export var createGetOperation = function createGetOperation(_ref) {
|
|
14
9
|
var getSession = _ref.getSession,
|
|
15
10
|
db = _ref.db;
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
description = _ref2.description,
|
|
21
|
-
summary = _ref2.summary,
|
|
22
|
-
tags = _ref2.tags,
|
|
23
|
-
relations = _ref2.relations,
|
|
24
|
-
setParams = _ref2.setParams,
|
|
25
|
-
jsonArrayFields = _ref2.jsonArrayFields,
|
|
26
|
-
onSuccess = _ref2.onSuccess,
|
|
27
|
-
onError = _ref2.onError,
|
|
28
|
-
_ref2$byCreator = _ref2.byCreator,
|
|
29
|
-
byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
|
|
30
|
-
return routeOperation({
|
|
31
|
-
method: "GET",
|
|
32
|
-
openApiOperation: {
|
|
33
|
-
description: description,
|
|
34
|
-
summary: summary,
|
|
35
|
-
tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
|
|
36
|
-
}
|
|
37
|
-
}).input({
|
|
38
|
-
query: querySchema
|
|
39
|
-
}).outputs([{
|
|
40
|
-
body: bodySchema,
|
|
41
|
-
contentType: "application/json",
|
|
42
|
-
status: 200
|
|
43
|
-
}]).handler( /*#__PURE__*/function () {
|
|
44
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
45
|
-
var extraParams, _ref4, userId, queryParams, mergedParams, tableParams, rawResult, result, response;
|
|
46
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
|
-
while (1) switch (_context.prev = _context.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
_context.prev = 0;
|
|
50
|
-
_context.next = 3;
|
|
51
|
-
return setParams === null || setParams === void 0 ? void 0 : setParams(req);
|
|
52
|
-
case 3:
|
|
53
|
-
_context.t0 = _context.sent;
|
|
54
|
-
if (_context.t0) {
|
|
55
|
-
_context.next = 6;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
_context.t0 = {};
|
|
59
|
-
case 6:
|
|
60
|
-
extraParams = _context.t0;
|
|
61
|
-
if (!byCreator) {
|
|
62
|
-
_context.next = 16;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
_context.next = 10;
|
|
66
|
-
return getSession(req);
|
|
67
|
-
case 10:
|
|
68
|
-
_context.t1 = _context.sent;
|
|
69
|
-
if (_context.t1) {
|
|
70
|
-
_context.next = 13;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
_context.t1 = {};
|
|
74
|
-
case 13:
|
|
75
|
-
_ref4 = _context.t1;
|
|
76
|
-
userId = _ref4.userId;
|
|
77
|
-
extraParams.creatorId = userId;
|
|
78
|
-
case 16:
|
|
79
|
-
queryParams = querySchema.parse(Object.fromEntries(new URL(req.url).searchParams));
|
|
80
|
-
mergedParams = _objectSpread(_objectSpread({}, queryParams), extraParams);
|
|
81
|
-
tableParams = mergedParams;
|
|
82
|
-
if (!(table && db)) {
|
|
83
|
-
_context.next = 25;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
_context.next = 22;
|
|
87
|
-
return createGetAction({
|
|
88
|
-
bodySchema: bodySchema,
|
|
89
|
-
db: db,
|
|
90
|
-
jsonArrayFields: jsonArrayFields,
|
|
91
|
-
relations: relations,
|
|
92
|
-
table: table
|
|
93
|
-
})(tableParams);
|
|
94
|
-
case 22:
|
|
95
|
-
_context.t2 = _context.sent;
|
|
96
|
-
_context.next = 26;
|
|
97
|
-
break;
|
|
98
|
-
case 25:
|
|
99
|
-
_context.t2 = mergedParams;
|
|
100
|
-
case 26:
|
|
101
|
-
rawResult = _context.t2;
|
|
102
|
-
result = rawResult !== null && rawResult !== void 0 ? rawResult : {};
|
|
103
|
-
if (!onSuccess) {
|
|
104
|
-
_context.next = 32;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
_context.next = 31;
|
|
108
|
-
return onSuccess({
|
|
109
|
-
data: result,
|
|
110
|
-
params: mergedParams
|
|
111
|
-
});
|
|
112
|
-
case 31:
|
|
113
|
-
result = _context.sent;
|
|
114
|
-
case 32:
|
|
115
|
-
return _context.abrupt("return", TypedNextResponse.json(result, {
|
|
116
|
-
status: 200
|
|
117
|
-
}));
|
|
118
|
-
case 35:
|
|
119
|
-
_context.prev = 35;
|
|
120
|
-
_context.t3 = _context["catch"](0);
|
|
121
|
-
console.error(_context.t3);
|
|
122
|
-
_context.next = 40;
|
|
123
|
-
return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
|
|
124
|
-
case 40:
|
|
125
|
-
response = _context.sent;
|
|
126
|
-
if (!response) {
|
|
127
|
-
_context.next = 45;
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
return _context.abrupt("return", response);
|
|
131
|
-
case 45:
|
|
132
|
-
throw _context.t3;
|
|
133
|
-
case 46:
|
|
134
|
-
case "end":
|
|
135
|
-
return _context.stop();
|
|
136
|
-
}
|
|
137
|
-
}, _callee, null, [[0, 35]]);
|
|
138
|
-
}));
|
|
139
|
-
return function (_x) {
|
|
140
|
-
return _ref3.apply(this, arguments);
|
|
141
|
-
};
|
|
142
|
-
}());
|
|
143
|
-
};
|
|
11
|
+
return createOperation({
|
|
12
|
+
db: db,
|
|
13
|
+
getSession: getSession
|
|
14
|
+
});
|
|
144
15
|
};
|
|
@@ -2,4 +2,5 @@ export * from "./get-operation.js";
|
|
|
2
2
|
export * from "./get-list-operation.js";
|
|
3
3
|
export * from "./delete-operation.js";
|
|
4
4
|
export * from "./post-operation.js";
|
|
5
|
-
export * from "./put-operation.js";
|
|
5
|
+
export * from "./put-operation.js";
|
|
6
|
+
export * from "../../route-operation/open-api-operation.js";
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import { z, ZodSchema } from "zod";
|
|
2
1
|
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
3
2
|
import { NextRequest } from "next/server";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
9
|
-
bodySchema: IB;
|
|
10
|
-
contentType?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
outputBodySchema?: OB;
|
|
13
|
-
parseBody?: (_req: NextRequest) => Promise<Record<string, unknown>>;
|
|
14
|
-
setBody?: (_req: NextRequest) => Promise<Partial<z.infer<IB>>>;
|
|
15
|
-
summary?: string;
|
|
16
|
-
tags?: string[];
|
|
17
|
-
onSuccess?: (_payload: {
|
|
18
|
-
params: PostOperationParams<IB>;
|
|
19
|
-
data: z.infer<OB>;
|
|
20
|
-
req: NextRequest;
|
|
21
|
-
}) => Promise<z.infer<OB>>;
|
|
22
|
-
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
23
|
-
table?: TTable;
|
|
24
|
-
}
|
|
3
|
+
import { ZodSchema } from "zod";
|
|
4
|
+
import { type PostOperationOptions as CorePostOperationOptions } from "../../route-operation/operation-core.js";
|
|
5
|
+
export type PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> = CorePostOperationOptions<IB, OB, TTable>;
|
|
25
6
|
export declare const createPostOperation: ({ getSession, db, }: {
|
|
26
|
-
db?:
|
|
27
|
-
getSession
|
|
7
|
+
db?: unknown;
|
|
8
|
+
getSession(req: NextRequest): Promise<{
|
|
28
9
|
userId?: string;
|
|
29
10
|
} | undefined>;
|
|
30
|
-
}) => <IB extends
|
|
31
|
-
export {};
|
|
11
|
+
}) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, contentType, openApiOperation, parseBody, setBody, table, handler, catch: catchHandler, }: CorePostOperationOptions<IB, OB, SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|