@ai0x0/utils 0.0.39 → 0.0.40
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 +1 -1
- package/SKILL.md +1 -1
- package/es/backend/route-operation/delete-operation.d.ts +7 -1
- package/es/backend/route-operation/delete-operation.js +4 -1
- package/es/backend/route-operation/get-list-operation.d.ts +6 -3
- package/es/backend/route-operation/get-list-operation.js +4 -1
- package/es/backend/route-operation/get-operation.d.ts +4 -1
- package/es/backend/route-operation/get-operation.js +4 -1
- package/es/backend/route-operation/post-operation.d.ts +4 -1
- package/es/backend/route-operation/post-operation.js +31 -29
- package/es/backend/route-operation/put-operation.d.ts +4 -1
- package/es/backend/route-operation/put-operation.js +33 -31
- package/es/backend/sqlite/route-operation/delete-operation.d.ts +7 -1
- package/es/backend/sqlite/route-operation/delete-operation.js +4 -1
- package/es/backend/sqlite/route-operation/get-list-operation.d.ts +6 -3
- package/es/backend/sqlite/route-operation/get-list-operation.js +4 -1
- package/es/backend/sqlite/route-operation/get-operation.d.ts +4 -1
- package/es/backend/sqlite/route-operation/get-operation.js +4 -1
- package/es/backend/sqlite/route-operation/post-operation.d.ts +4 -1
- package/es/backend/sqlite/route-operation/post-operation.js +29 -27
- package/es/backend/sqlite/route-operation/put-operation.d.ts +4 -1
- package/es/backend/sqlite/route-operation/put-operation.js +31 -29
- package/lib/backend/route-operation/delete-operation.d.ts +7 -1
- package/lib/backend/route-operation/delete-operation.js +1 -1
- package/lib/backend/route-operation/get-list-operation.d.ts +6 -3
- package/lib/backend/route-operation/get-list-operation.js +1 -1
- package/lib/backend/route-operation/get-operation.d.ts +4 -1
- package/lib/backend/route-operation/get-operation.js +1 -1
- package/lib/backend/route-operation/post-operation.d.ts +4 -1
- package/lib/backend/route-operation/post-operation.js +6 -5
- package/lib/backend/route-operation/put-operation.d.ts +4 -1
- package/lib/backend/route-operation/put-operation.js +6 -2
- package/lib/backend/sqlite/route-operation/delete-operation.d.ts +7 -1
- package/lib/backend/sqlite/route-operation/delete-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +6 -3
- package/lib/backend/sqlite/route-operation/get-list-operation.js +4 -1
- package/lib/backend/sqlite/route-operation/get-operation.d.ts +4 -1
- package/lib/backend/sqlite/route-operation/get-operation.js +1 -1
- package/lib/backend/sqlite/route-operation/post-operation.d.ts +4 -1
- package/lib/backend/sqlite/route-operation/post-operation.js +6 -5
- package/lib/backend/sqlite/route-operation/put-operation.d.ts +4 -1
- package/lib/backend/sqlite/route-operation/put-operation.js +6 -2
- package/package.json +1 -1
|
@@ -346,7 +346,7 @@ export const { GET } = route({
|
|
|
346
346
|
|
|
347
347
|
- Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
|
|
348
348
|
- Extra columns on write — `setBody(req) => Promise<Partial<infer<IB>>>` on POST/PUT; returned fields are merged into the body before validation runs against `bodySchema`.
|
|
349
|
-
- Post-processing output — `onSuccess(data) => Promise<data>`; on GET_LIST
|
|
349
|
+
- Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
|
|
350
350
|
- Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
|
|
351
351
|
|
|
352
352
|
## Imports
|
package/SKILL.md
CHANGED
|
@@ -325,7 +325,7 @@ export const { GET } = route({
|
|
|
325
325
|
|
|
326
326
|
- Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
|
|
327
327
|
- Extra columns on write — `setBody(req) => Promise<Partial<infer<IB>>>` on POST/PUT; returned fields are merged into the body before validation runs against `bodySchema`.
|
|
328
|
-
- Post-processing output — `onSuccess(data) => Promise<data>`; on GET_LIST
|
|
328
|
+
- Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
|
|
329
329
|
- Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
|
|
330
330
|
|
|
331
331
|
## Imports
|
|
@@ -4,7 +4,13 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
4
4
|
table?: TTable;
|
|
5
5
|
summary?: string;
|
|
6
6
|
tags?: string[];
|
|
7
|
-
onSuccess?: (
|
|
7
|
+
onSuccess?: (payload: {
|
|
8
|
+
params: {
|
|
9
|
+
id: string;
|
|
10
|
+
creatorId?: string;
|
|
11
|
+
};
|
|
12
|
+
data: unknown;
|
|
13
|
+
}) => Promise<void>;
|
|
8
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
9
15
|
byCreator?: boolean;
|
|
10
16
|
}
|
|
@@ -76,7 +76,10 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
|
|
|
76
76
|
case 20:
|
|
77
77
|
data = _context.t1;
|
|
78
78
|
_context.next = 23;
|
|
79
|
-
return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(
|
|
79
|
+
return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
|
|
80
|
+
data: data,
|
|
81
|
+
params: body
|
|
82
|
+
});
|
|
80
83
|
case 23:
|
|
81
84
|
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
82
85
|
status: 200
|
|
@@ -11,9 +11,12 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
11
11
|
summary?: string;
|
|
12
12
|
tags?: string[];
|
|
13
13
|
table?: TTable;
|
|
14
|
-
onSuccess?<D extends T>(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
onSuccess?<D extends T>(payload: {
|
|
15
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
16
|
+
data: {
|
|
17
|
+
data: z.infer<D>[];
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
17
20
|
}): Promise<{
|
|
18
21
|
data: z.infer<T>[];
|
|
19
22
|
total: number;
|
|
@@ -99,7 +99,10 @@ export var createGetListOperation = function createGetListOperation(_ref) {
|
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
101
|
_context.next = 28;
|
|
102
|
-
return onSuccess(
|
|
102
|
+
return onSuccess({
|
|
103
|
+
data: result,
|
|
104
|
+
params: mergedParams
|
|
105
|
+
});
|
|
103
106
|
case 28:
|
|
104
107
|
result = _context.sent;
|
|
105
108
|
case 29:
|
|
@@ -7,7 +7,10 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
7
7
|
querySchema: Q;
|
|
8
8
|
relations?: GetListRelations;
|
|
9
9
|
setParams?(req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>): Promise<Record<string, unknown>>;
|
|
10
|
-
onSuccess?(
|
|
10
|
+
onSuccess?(payload: {
|
|
11
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
12
|
+
data: z.infer<T>;
|
|
13
|
+
}): Promise<z.infer<T>>;
|
|
11
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
@@ -96,7 +96,10 @@ export var createGetOperation = function createGetOperation(_ref) {
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
_context.next = 29;
|
|
99
|
-
return onSuccess(
|
|
99
|
+
return onSuccess({
|
|
100
|
+
data: result,
|
|
101
|
+
params: mergedParams
|
|
102
|
+
});
|
|
100
103
|
case 29:
|
|
101
104
|
result = _context.sent;
|
|
102
105
|
case 30:
|
|
@@ -7,7 +7,10 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
7
7
|
setBody?(req: TypedNextRequest<"POST", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
|
-
onSuccess?(
|
|
10
|
+
onSuccess?(payload: {
|
|
11
|
+
params: Record<string, unknown>;
|
|
12
|
+
data: z.infer<OB>;
|
|
13
|
+
}): Promise<z.infer<OB>>;
|
|
11
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
table?: TTable;
|
|
13
16
|
}
|
|
@@ -40,7 +40,7 @@ export var createPostOperation = function createPostOperation(_ref) {
|
|
|
40
40
|
status: 200
|
|
41
41
|
}]).handler( /*#__PURE__*/function () {
|
|
42
42
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
43
|
-
var _ref4, userId, body, extraBody, mergedBody, raw,
|
|
43
|
+
var _ref4, userId, body, extraBody, mergedBody, params, raw, data, response;
|
|
44
44
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
45
|
while (1) switch (_context.prev = _context.next) {
|
|
46
46
|
case 0:
|
|
@@ -73,65 +73,67 @@ export var createPostOperation = function createPostOperation(_ref) {
|
|
|
73
73
|
case 16:
|
|
74
74
|
extraBody = _context.t1;
|
|
75
75
|
mergedBody = _objectSpread(_objectSpread({}, body), extraBody);
|
|
76
|
+
params = _objectSpread({
|
|
77
|
+
creatorId: userId
|
|
78
|
+
}, mergedBody);
|
|
76
79
|
if (!table) {
|
|
77
|
-
_context.next =
|
|
80
|
+
_context.next = 25;
|
|
78
81
|
break;
|
|
79
82
|
}
|
|
80
|
-
_context.next =
|
|
83
|
+
_context.next = 22;
|
|
81
84
|
return createPostAction({
|
|
82
85
|
bodySchema: bodySchema,
|
|
83
86
|
db: db,
|
|
84
87
|
table: table
|
|
85
|
-
})(
|
|
86
|
-
|
|
87
|
-
}, mergedBody));
|
|
88
|
-
case 21:
|
|
88
|
+
})(params);
|
|
89
|
+
case 22:
|
|
89
90
|
_context.t2 = _context.sent[0];
|
|
90
|
-
_context.next =
|
|
91
|
+
_context.next = 26;
|
|
91
92
|
break;
|
|
92
|
-
case 24:
|
|
93
|
-
_context.t2 = _objectSpread({
|
|
94
|
-
creatorId: userId
|
|
95
|
-
}, mergedBody);
|
|
96
93
|
case 25:
|
|
94
|
+
_context.t2 = params;
|
|
95
|
+
case 26:
|
|
97
96
|
raw = _context.t2;
|
|
98
97
|
if (!onSuccess) {
|
|
99
|
-
_context.next =
|
|
98
|
+
_context.next = 33;
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
102
|
-
_context.next =
|
|
103
|
-
return onSuccess(
|
|
104
|
-
|
|
101
|
+
_context.next = 30;
|
|
102
|
+
return onSuccess({
|
|
103
|
+
data: raw,
|
|
104
|
+
params: params
|
|
105
|
+
});
|
|
106
|
+
case 30:
|
|
105
107
|
_context.t3 = _context.sent;
|
|
106
|
-
_context.next =
|
|
108
|
+
_context.next = 34;
|
|
107
109
|
break;
|
|
108
|
-
case 32:
|
|
109
|
-
_context.t3 = raw;
|
|
110
110
|
case 33:
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
_context.t3 = raw;
|
|
112
|
+
case 34:
|
|
113
|
+
data = _context.t3;
|
|
114
|
+
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
113
115
|
status: 200
|
|
114
116
|
}));
|
|
115
|
-
case
|
|
116
|
-
_context.prev =
|
|
117
|
+
case 38:
|
|
118
|
+
_context.prev = 38;
|
|
117
119
|
_context.t4 = _context["catch"](0);
|
|
118
120
|
console.error(_context.t4);
|
|
119
|
-
_context.next =
|
|
121
|
+
_context.next = 43;
|
|
120
122
|
return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
|
|
121
|
-
case
|
|
123
|
+
case 43:
|
|
122
124
|
response = _context.sent;
|
|
123
125
|
if (!response) {
|
|
124
|
-
_context.next =
|
|
126
|
+
_context.next = 48;
|
|
125
127
|
break;
|
|
126
128
|
}
|
|
127
129
|
return _context.abrupt("return", response);
|
|
128
|
-
case 47:
|
|
129
|
-
throw _context.t4;
|
|
130
130
|
case 48:
|
|
131
|
+
throw _context.t4;
|
|
132
|
+
case 49:
|
|
131
133
|
case "end":
|
|
132
134
|
return _context.stop();
|
|
133
135
|
}
|
|
134
|
-
}, _callee, null, [[0,
|
|
136
|
+
}, _callee, null, [[0, 38]]);
|
|
135
137
|
}));
|
|
136
138
|
return function (_x) {
|
|
137
139
|
return _ref3.apply(this, arguments);
|
|
@@ -8,7 +8,10 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
10
|
setBody?(req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
11
|
-
onSuccess?(
|
|
11
|
+
onSuccess?(payload: {
|
|
12
|
+
params: Record<string, unknown>;
|
|
13
|
+
data: z.infer<OB>;
|
|
14
|
+
}): Promise<z.infer<OB>>;
|
|
12
15
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
13
16
|
byCreator?: boolean;
|
|
14
17
|
}
|
|
@@ -41,7 +41,7 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
41
41
|
contentType: "application/json"
|
|
42
42
|
}]).handler( /*#__PURE__*/function () {
|
|
43
43
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
44
|
-
var _ref4, userId, body, extraBody, mergedBody, raw,
|
|
44
|
+
var _ref4, userId, body, extraBody, mergedBody, params, raw, data, response;
|
|
45
45
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
46
|
while (1) switch (_context.prev = _context.next) {
|
|
47
47
|
case 0:
|
|
@@ -74,65 +74,67 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
74
74
|
case 16:
|
|
75
75
|
extraBody = _context.t1;
|
|
76
76
|
mergedBody = _objectSpread(_objectSpread({}, body), extraBody);
|
|
77
|
+
params = _objectSpread({
|
|
78
|
+
editorId: userId
|
|
79
|
+
}, mergedBody);
|
|
77
80
|
if (!table) {
|
|
78
|
-
_context.next =
|
|
81
|
+
_context.next = 25;
|
|
79
82
|
break;
|
|
80
83
|
}
|
|
81
|
-
_context.next =
|
|
84
|
+
_context.next = 22;
|
|
82
85
|
return createPutAction({
|
|
83
86
|
bodySchema: bodySchema,
|
|
84
87
|
table: table,
|
|
85
88
|
db: db
|
|
86
|
-
})(
|
|
87
|
-
editorId: userId
|
|
88
|
-
}, mergedBody), {
|
|
89
|
+
})(params, {
|
|
89
90
|
byCreator: byCreator
|
|
90
91
|
});
|
|
91
|
-
case
|
|
92
|
+
case 22:
|
|
92
93
|
_context.t2 = _context.sent;
|
|
93
|
-
_context.next =
|
|
94
|
+
_context.next = 26;
|
|
94
95
|
break;
|
|
95
|
-
case 24:
|
|
96
|
-
_context.t2 = _objectSpread({
|
|
97
|
-
editorId: userId
|
|
98
|
-
}, mergedBody);
|
|
99
96
|
case 25:
|
|
97
|
+
_context.t2 = params;
|
|
98
|
+
case 26:
|
|
100
99
|
raw = _context.t2;
|
|
101
100
|
if (!onSuccess) {
|
|
102
|
-
_context.next =
|
|
101
|
+
_context.next = 33;
|
|
103
102
|
break;
|
|
104
103
|
}
|
|
105
|
-
_context.next =
|
|
106
|
-
return onSuccess(
|
|
107
|
-
|
|
104
|
+
_context.next = 30;
|
|
105
|
+
return onSuccess({
|
|
106
|
+
data: raw,
|
|
107
|
+
params: params
|
|
108
|
+
});
|
|
109
|
+
case 30:
|
|
108
110
|
_context.t3 = _context.sent;
|
|
109
|
-
_context.next =
|
|
111
|
+
_context.next = 34;
|
|
110
112
|
break;
|
|
111
|
-
case 32:
|
|
112
|
-
_context.t3 = raw;
|
|
113
113
|
case 33:
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
_context.t3 = raw;
|
|
115
|
+
case 34:
|
|
116
|
+
data = _context.t3;
|
|
117
|
+
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
116
118
|
status: 200
|
|
117
119
|
}));
|
|
118
|
-
case
|
|
119
|
-
_context.prev =
|
|
120
|
+
case 38:
|
|
121
|
+
_context.prev = 38;
|
|
120
122
|
_context.t4 = _context["catch"](0);
|
|
121
123
|
if (!(_context.t4 instanceof HttpError)) {
|
|
122
124
|
console.error(_context.t4);
|
|
123
125
|
}
|
|
124
|
-
_context.next =
|
|
126
|
+
_context.next = 43;
|
|
125
127
|
return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
|
|
126
|
-
case
|
|
128
|
+
case 43:
|
|
127
129
|
response = _context.sent;
|
|
128
130
|
if (!response) {
|
|
129
|
-
_context.next =
|
|
131
|
+
_context.next = 46;
|
|
130
132
|
break;
|
|
131
133
|
}
|
|
132
134
|
return _context.abrupt("return", response);
|
|
133
|
-
case
|
|
135
|
+
case 46:
|
|
134
136
|
if (!(_context.t4 instanceof HttpError)) {
|
|
135
|
-
_context.next =
|
|
137
|
+
_context.next = 48;
|
|
136
138
|
break;
|
|
137
139
|
}
|
|
138
140
|
return _context.abrupt("return", TypedNextResponse.json({
|
|
@@ -140,13 +142,13 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
140
142
|
}, {
|
|
141
143
|
status: _context.t4.status
|
|
142
144
|
}));
|
|
143
|
-
case 47:
|
|
144
|
-
throw _context.t4;
|
|
145
145
|
case 48:
|
|
146
|
+
throw _context.t4;
|
|
147
|
+
case 49:
|
|
146
148
|
case "end":
|
|
147
149
|
return _context.stop();
|
|
148
150
|
}
|
|
149
|
-
}, _callee, null, [[0,
|
|
151
|
+
}, _callee, null, [[0, 38]]);
|
|
150
152
|
}));
|
|
151
153
|
return function (_x) {
|
|
152
154
|
return _ref3.apply(this, arguments);
|
|
@@ -4,7 +4,13 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
4
4
|
table?: TTable;
|
|
5
5
|
summary?: string;
|
|
6
6
|
tags?: string[];
|
|
7
|
-
onSuccess?: (
|
|
7
|
+
onSuccess?: (_payload: {
|
|
8
|
+
params: {
|
|
9
|
+
id: string;
|
|
10
|
+
creatorId?: string;
|
|
11
|
+
};
|
|
12
|
+
data: unknown;
|
|
13
|
+
}) => Promise<void>;
|
|
8
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
9
15
|
byCreator?: boolean;
|
|
10
16
|
}
|
|
@@ -76,7 +76,10 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
|
|
|
76
76
|
case 20:
|
|
77
77
|
data = _context.t1;
|
|
78
78
|
_context.next = 23;
|
|
79
|
-
return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(
|
|
79
|
+
return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
|
|
80
|
+
data: data,
|
|
81
|
+
params: body
|
|
82
|
+
});
|
|
80
83
|
case 23:
|
|
81
84
|
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
82
85
|
status: 200
|
|
@@ -11,9 +11,12 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
11
11
|
summary?: string;
|
|
12
12
|
tags?: string[];
|
|
13
13
|
table?: TTable;
|
|
14
|
-
onSuccess?: <D extends T>(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
onSuccess?: <D extends T>(_payload: {
|
|
15
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
16
|
+
data: {
|
|
17
|
+
data: z.infer<D>[];
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
17
20
|
}) => Promise<{
|
|
18
21
|
data: z.infer<T>[];
|
|
19
22
|
total: number;
|
|
@@ -99,7 +99,10 @@ export var createGetListOperation = function createGetListOperation(_ref) {
|
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
101
|
_context.next = 28;
|
|
102
|
-
return onSuccess(
|
|
102
|
+
return onSuccess({
|
|
103
|
+
data: result,
|
|
104
|
+
params: mergedParams
|
|
105
|
+
});
|
|
103
106
|
case 28:
|
|
104
107
|
result = _context.sent;
|
|
105
108
|
case 29:
|
|
@@ -7,7 +7,10 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
7
7
|
querySchema: Q;
|
|
8
8
|
relations?: GetListRelations;
|
|
9
9
|
setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
|
|
10
|
-
onSuccess?: (
|
|
10
|
+
onSuccess?: (_payload: {
|
|
11
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
12
|
+
data: z.infer<T>;
|
|
13
|
+
}) => Promise<z.infer<T>>;
|
|
11
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
@@ -96,7 +96,10 @@ export var createGetOperation = function createGetOperation(_ref) {
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
_context.next = 29;
|
|
99
|
-
return onSuccess(
|
|
99
|
+
return onSuccess({
|
|
100
|
+
data: result,
|
|
101
|
+
params: mergedParams
|
|
102
|
+
});
|
|
100
103
|
case 29:
|
|
101
104
|
result = _context.sent;
|
|
102
105
|
case 30:
|
|
@@ -7,7 +7,10 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
7
7
|
setBody?: (_req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
|
-
onSuccess?: (
|
|
10
|
+
onSuccess?: (_payload: {
|
|
11
|
+
params: Record<string, unknown>;
|
|
12
|
+
data: z.infer<OB>;
|
|
13
|
+
}) => Promise<z.infer<OB>>;
|
|
11
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
table?: TTable;
|
|
13
16
|
}
|
|
@@ -40,7 +40,7 @@ export var createPostOperation = function createPostOperation(_ref) {
|
|
|
40
40
|
status: 200
|
|
41
41
|
}]).handler( /*#__PURE__*/function () {
|
|
42
42
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
43
|
-
var _ref4, userId, body, extraBody, mergedBody, raw, data, response;
|
|
43
|
+
var _ref4, userId, body, extraBody, mergedBody, params, raw, data, response;
|
|
44
44
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
45
|
while (1) switch (_context.prev = _context.next) {
|
|
46
46
|
case 0:
|
|
@@ -73,65 +73,67 @@ export var createPostOperation = function createPostOperation(_ref) {
|
|
|
73
73
|
case 16:
|
|
74
74
|
extraBody = _context.t1;
|
|
75
75
|
mergedBody = _objectSpread(_objectSpread({}, body), extraBody);
|
|
76
|
+
params = _objectSpread({
|
|
77
|
+
creatorId: userId
|
|
78
|
+
}, mergedBody);
|
|
76
79
|
if (!table) {
|
|
77
|
-
_context.next =
|
|
80
|
+
_context.next = 25;
|
|
78
81
|
break;
|
|
79
82
|
}
|
|
80
|
-
_context.next =
|
|
83
|
+
_context.next = 22;
|
|
81
84
|
return createPostAction({
|
|
82
85
|
bodySchema: bodySchema,
|
|
83
86
|
db: db,
|
|
84
87
|
table: table
|
|
85
|
-
})(
|
|
86
|
-
|
|
87
|
-
}, mergedBody));
|
|
88
|
-
case 21:
|
|
88
|
+
})(params);
|
|
89
|
+
case 22:
|
|
89
90
|
_context.t2 = _context.sent[0];
|
|
90
|
-
_context.next =
|
|
91
|
+
_context.next = 26;
|
|
91
92
|
break;
|
|
92
|
-
case 24:
|
|
93
|
-
_context.t2 = _objectSpread({
|
|
94
|
-
creatorId: userId
|
|
95
|
-
}, mergedBody);
|
|
96
93
|
case 25:
|
|
94
|
+
_context.t2 = params;
|
|
95
|
+
case 26:
|
|
97
96
|
raw = _context.t2;
|
|
98
97
|
if (!onSuccess) {
|
|
99
|
-
_context.next =
|
|
98
|
+
_context.next = 33;
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
102
|
-
_context.next =
|
|
103
|
-
return onSuccess(
|
|
104
|
-
|
|
101
|
+
_context.next = 30;
|
|
102
|
+
return onSuccess({
|
|
103
|
+
data: raw,
|
|
104
|
+
params: params
|
|
105
|
+
});
|
|
106
|
+
case 30:
|
|
105
107
|
_context.t3 = _context.sent;
|
|
106
|
-
_context.next =
|
|
108
|
+
_context.next = 34;
|
|
107
109
|
break;
|
|
108
|
-
case 32:
|
|
109
|
-
_context.t3 = raw;
|
|
110
110
|
case 33:
|
|
111
|
+
_context.t3 = raw;
|
|
112
|
+
case 34:
|
|
111
113
|
data = _context.t3;
|
|
112
114
|
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
113
115
|
status: 200
|
|
114
116
|
}));
|
|
115
|
-
case
|
|
116
|
-
_context.prev =
|
|
117
|
+
case 38:
|
|
118
|
+
_context.prev = 38;
|
|
117
119
|
_context.t4 = _context["catch"](0);
|
|
118
120
|
console.error(_context.t4);
|
|
119
|
-
_context.next =
|
|
121
|
+
_context.next = 43;
|
|
120
122
|
return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
|
|
121
|
-
case
|
|
123
|
+
case 43:
|
|
122
124
|
response = _context.sent;
|
|
123
125
|
if (!response) {
|
|
124
|
-
_context.next =
|
|
126
|
+
_context.next = 48;
|
|
125
127
|
break;
|
|
126
128
|
}
|
|
127
129
|
return _context.abrupt("return", response);
|
|
128
|
-
case 47:
|
|
129
|
-
throw _context.t4;
|
|
130
130
|
case 48:
|
|
131
|
+
throw _context.t4;
|
|
132
|
+
case 49:
|
|
131
133
|
case "end":
|
|
132
134
|
return _context.stop();
|
|
133
135
|
}
|
|
134
|
-
}, _callee, null, [[0,
|
|
136
|
+
}, _callee, null, [[0, 38]]);
|
|
135
137
|
}));
|
|
136
138
|
return function (_x) {
|
|
137
139
|
return _ref3.apply(this, arguments);
|
|
@@ -8,7 +8,10 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
10
|
setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
11
|
-
onSuccess?: (
|
|
11
|
+
onSuccess?: (_payload: {
|
|
12
|
+
params: Record<string, unknown>;
|
|
13
|
+
data: z.infer<OB>;
|
|
14
|
+
}) => Promise<z.infer<OB>>;
|
|
12
15
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
13
16
|
byCreator?: boolean;
|
|
14
17
|
}
|
|
@@ -41,7 +41,7 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
41
41
|
contentType: "application/json"
|
|
42
42
|
}]).handler( /*#__PURE__*/function () {
|
|
43
43
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
44
|
-
var _ref4, userId, body, extraBody, mergedBody, raw, data, response;
|
|
44
|
+
var _ref4, userId, body, extraBody, mergedBody, params, raw, data, response;
|
|
45
45
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
46
|
while (1) switch (_context.prev = _context.next) {
|
|
47
47
|
case 0:
|
|
@@ -74,65 +74,67 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
74
74
|
case 16:
|
|
75
75
|
extraBody = _context.t1;
|
|
76
76
|
mergedBody = _objectSpread(_objectSpread({}, body), extraBody);
|
|
77
|
+
params = _objectSpread({
|
|
78
|
+
editorId: userId
|
|
79
|
+
}, mergedBody);
|
|
77
80
|
if (!table) {
|
|
78
|
-
_context.next =
|
|
81
|
+
_context.next = 25;
|
|
79
82
|
break;
|
|
80
83
|
}
|
|
81
|
-
_context.next =
|
|
84
|
+
_context.next = 22;
|
|
82
85
|
return createPutAction({
|
|
83
86
|
bodySchema: bodySchema,
|
|
84
87
|
table: table,
|
|
85
88
|
db: db
|
|
86
|
-
})(
|
|
87
|
-
editorId: userId
|
|
88
|
-
}, mergedBody), {
|
|
89
|
+
})(params, {
|
|
89
90
|
byCreator: byCreator
|
|
90
91
|
});
|
|
91
|
-
case
|
|
92
|
+
case 22:
|
|
92
93
|
_context.t2 = _context.sent;
|
|
93
|
-
_context.next =
|
|
94
|
+
_context.next = 26;
|
|
94
95
|
break;
|
|
95
|
-
case 24:
|
|
96
|
-
_context.t2 = _objectSpread({
|
|
97
|
-
editorId: userId
|
|
98
|
-
}, mergedBody);
|
|
99
96
|
case 25:
|
|
97
|
+
_context.t2 = params;
|
|
98
|
+
case 26:
|
|
100
99
|
raw = _context.t2;
|
|
101
100
|
if (!onSuccess) {
|
|
102
|
-
_context.next =
|
|
101
|
+
_context.next = 33;
|
|
103
102
|
break;
|
|
104
103
|
}
|
|
105
|
-
_context.next =
|
|
106
|
-
return onSuccess(
|
|
107
|
-
|
|
104
|
+
_context.next = 30;
|
|
105
|
+
return onSuccess({
|
|
106
|
+
data: raw,
|
|
107
|
+
params: params
|
|
108
|
+
});
|
|
109
|
+
case 30:
|
|
108
110
|
_context.t3 = _context.sent;
|
|
109
|
-
_context.next =
|
|
111
|
+
_context.next = 34;
|
|
110
112
|
break;
|
|
111
|
-
case 32:
|
|
112
|
-
_context.t3 = raw;
|
|
113
113
|
case 33:
|
|
114
|
+
_context.t3 = raw;
|
|
115
|
+
case 34:
|
|
114
116
|
data = _context.t3;
|
|
115
117
|
return _context.abrupt("return", TypedNextResponse.json(data, {
|
|
116
118
|
status: 200
|
|
117
119
|
}));
|
|
118
|
-
case
|
|
119
|
-
_context.prev =
|
|
120
|
+
case 38:
|
|
121
|
+
_context.prev = 38;
|
|
120
122
|
_context.t4 = _context["catch"](0);
|
|
121
123
|
if (!(_context.t4 instanceof HttpError)) {
|
|
122
124
|
console.error(_context.t4);
|
|
123
125
|
}
|
|
124
|
-
_context.next =
|
|
126
|
+
_context.next = 43;
|
|
125
127
|
return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
|
|
126
|
-
case
|
|
128
|
+
case 43:
|
|
127
129
|
response = _context.sent;
|
|
128
130
|
if (!response) {
|
|
129
|
-
_context.next =
|
|
131
|
+
_context.next = 46;
|
|
130
132
|
break;
|
|
131
133
|
}
|
|
132
134
|
return _context.abrupt("return", response);
|
|
133
|
-
case
|
|
135
|
+
case 46:
|
|
134
136
|
if (!(_context.t4 instanceof HttpError)) {
|
|
135
|
-
_context.next =
|
|
137
|
+
_context.next = 48;
|
|
136
138
|
break;
|
|
137
139
|
}
|
|
138
140
|
return _context.abrupt("return", TypedNextResponse.json({
|
|
@@ -140,13 +142,13 @@ export var createPutOperation = function createPutOperation(_ref) {
|
|
|
140
142
|
}, {
|
|
141
143
|
status: _context.t4.status
|
|
142
144
|
}));
|
|
143
|
-
case 47:
|
|
144
|
-
throw _context.t4;
|
|
145
145
|
case 48:
|
|
146
|
+
throw _context.t4;
|
|
147
|
+
case 49:
|
|
146
148
|
case "end":
|
|
147
149
|
return _context.stop();
|
|
148
150
|
}
|
|
149
|
-
}, _callee, null, [[0,
|
|
151
|
+
}, _callee, null, [[0, 38]]);
|
|
150
152
|
}));
|
|
151
153
|
return function (_x) {
|
|
152
154
|
return _ref3.apply(this, arguments);
|
|
@@ -4,7 +4,13 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
4
4
|
table?: TTable;
|
|
5
5
|
summary?: string;
|
|
6
6
|
tags?: string[];
|
|
7
|
-
onSuccess?: (
|
|
7
|
+
onSuccess?: (payload: {
|
|
8
|
+
params: {
|
|
9
|
+
id: string;
|
|
10
|
+
creatorId?: string;
|
|
11
|
+
};
|
|
12
|
+
data: unknown;
|
|
13
|
+
}) => Promise<void>;
|
|
8
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
9
15
|
byCreator?: boolean;
|
|
10
16
|
}
|
|
@@ -66,7 +66,7 @@ var createDeleteOperation = ({
|
|
|
66
66
|
body.creatorId = userId;
|
|
67
67
|
}
|
|
68
68
|
const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
69
|
-
await (onSuccess == null ? void 0 : onSuccess());
|
|
69
|
+
await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
|
|
70
70
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
71
71
|
status: 200
|
|
72
72
|
});
|
|
@@ -11,9 +11,12 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
11
11
|
summary?: string;
|
|
12
12
|
tags?: string[];
|
|
13
13
|
table?: TTable;
|
|
14
|
-
onSuccess?<D extends T>(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
onSuccess?<D extends T>(payload: {
|
|
15
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
16
|
+
data: {
|
|
17
|
+
data: z.infer<D>[];
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
17
20
|
}): Promise<{
|
|
18
21
|
data: z.infer<T>[];
|
|
19
22
|
total: number;
|
|
@@ -86,7 +86,7 @@ var createGetListOperation = ({
|
|
|
86
86
|
table
|
|
87
87
|
})(mergedParams) : { data: [], total: 0 };
|
|
88
88
|
if (onSuccess) {
|
|
89
|
-
result = await onSuccess(result);
|
|
89
|
+
result = await onSuccess({ data: result, params: mergedParams });
|
|
90
90
|
}
|
|
91
91
|
return import_next_rest_framework.TypedNextResponse.json(
|
|
92
92
|
result,
|
|
@@ -7,7 +7,10 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
7
7
|
querySchema: Q;
|
|
8
8
|
relations?: GetListRelations;
|
|
9
9
|
setParams?(req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>): Promise<Record<string, unknown>>;
|
|
10
|
-
onSuccess?(
|
|
10
|
+
onSuccess?(payload: {
|
|
11
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
12
|
+
data: z.infer<T>;
|
|
13
|
+
}): Promise<z.infer<T>>;
|
|
11
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
@@ -86,7 +86,7 @@ var createGetOperation = ({
|
|
|
86
86
|
})(mergedParams) : mergedParams;
|
|
87
87
|
let result = rawResult ?? {};
|
|
88
88
|
if (onSuccess) {
|
|
89
|
-
result = await onSuccess(result);
|
|
89
|
+
result = await onSuccess({ data: result, params: mergedParams });
|
|
90
90
|
}
|
|
91
91
|
return import_next_rest_framework.TypedNextResponse.json(result, {
|
|
92
92
|
status: 200
|
|
@@ -7,7 +7,10 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
7
7
|
setBody?(req: TypedNextRequest<"POST", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
|
-
onSuccess?(
|
|
10
|
+
onSuccess?(payload: {
|
|
11
|
+
params: Record<string, unknown>;
|
|
12
|
+
data: z.infer<OB>;
|
|
13
|
+
}): Promise<z.infer<OB>>;
|
|
11
14
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
table?: TTable;
|
|
13
16
|
}
|
|
@@ -71,11 +71,12 @@ var createPostOperation = ({
|
|
|
71
71
|
req
|
|
72
72
|
)) || {};
|
|
73
73
|
const mergedBody = { ...body, ...extraBody };
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const params = { creatorId: userId, ...mergedBody };
|
|
75
|
+
const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(params))[0] : params;
|
|
76
|
+
const data = onSuccess ? await onSuccess({
|
|
77
|
+
data: raw,
|
|
78
|
+
params
|
|
79
|
+
}) : raw;
|
|
79
80
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
80
81
|
status: 200
|
|
81
82
|
});
|
|
@@ -8,7 +8,10 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
10
|
setBody?(req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
11
|
-
onSuccess?(
|
|
11
|
+
onSuccess?(payload: {
|
|
12
|
+
params: Record<string, unknown>;
|
|
13
|
+
data: z.infer<OB>;
|
|
14
|
+
}): Promise<z.infer<OB>>;
|
|
12
15
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
13
16
|
byCreator?: boolean;
|
|
14
17
|
}
|
|
@@ -73,12 +73,16 @@ var createPutOperation = ({
|
|
|
73
73
|
req
|
|
74
74
|
)) || {};
|
|
75
75
|
const mergedBody = { ...body, ...extraBody };
|
|
76
|
+
const params = { editorId: userId, ...mergedBody };
|
|
76
77
|
const raw = table ? await (0, import_actions.createPutAction)({
|
|
77
78
|
bodySchema,
|
|
78
79
|
table,
|
|
79
80
|
db
|
|
80
|
-
})(
|
|
81
|
-
const data = onSuccess ? await onSuccess(
|
|
81
|
+
})(params, { byCreator }) : params;
|
|
82
|
+
const data = onSuccess ? await onSuccess({
|
|
83
|
+
data: raw,
|
|
84
|
+
params
|
|
85
|
+
}) : raw;
|
|
82
86
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
83
87
|
status: 200
|
|
84
88
|
});
|
|
@@ -4,7 +4,13 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
4
4
|
table?: TTable;
|
|
5
5
|
summary?: string;
|
|
6
6
|
tags?: string[];
|
|
7
|
-
onSuccess?: (
|
|
7
|
+
onSuccess?: (_payload: {
|
|
8
|
+
params: {
|
|
9
|
+
id: string;
|
|
10
|
+
creatorId?: string;
|
|
11
|
+
};
|
|
12
|
+
data: unknown;
|
|
13
|
+
}) => Promise<void>;
|
|
8
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
9
15
|
byCreator?: boolean;
|
|
10
16
|
}
|
|
@@ -66,7 +66,7 @@ var createDeleteOperation = ({
|
|
|
66
66
|
body.creatorId = userId;
|
|
67
67
|
}
|
|
68
68
|
const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
|
|
69
|
-
await (onSuccess == null ? void 0 : onSuccess());
|
|
69
|
+
await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
|
|
70
70
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
71
71
|
status: 200
|
|
72
72
|
});
|
|
@@ -11,9 +11,12 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
11
11
|
summary?: string;
|
|
12
12
|
tags?: string[];
|
|
13
13
|
table?: TTable;
|
|
14
|
-
onSuccess?: <D extends T>(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
onSuccess?: <D extends T>(_payload: {
|
|
15
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
16
|
+
data: {
|
|
17
|
+
data: z.infer<D>[];
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
17
20
|
}) => Promise<{
|
|
18
21
|
data: z.infer<T>[];
|
|
19
22
|
total: number;
|
|
@@ -86,7 +86,10 @@ var createGetListOperation = ({
|
|
|
86
86
|
table
|
|
87
87
|
})(mergedParams) : { data: [], total: 0 };
|
|
88
88
|
if (onSuccess) {
|
|
89
|
-
result = await onSuccess(
|
|
89
|
+
result = await onSuccess({
|
|
90
|
+
data: result,
|
|
91
|
+
params: mergedParams
|
|
92
|
+
});
|
|
90
93
|
}
|
|
91
94
|
return import_next_rest_framework.TypedNextResponse.json(
|
|
92
95
|
result,
|
|
@@ -7,7 +7,10 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
7
7
|
querySchema: Q;
|
|
8
8
|
relations?: GetListRelations;
|
|
9
9
|
setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
|
|
10
|
-
onSuccess?: (
|
|
10
|
+
onSuccess?: (_payload: {
|
|
11
|
+
params: Partial<z.infer<T>> & Record<string, unknown>;
|
|
12
|
+
data: z.infer<T>;
|
|
13
|
+
}) => Promise<z.infer<T>>;
|
|
11
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
@@ -86,7 +86,7 @@ var createGetOperation = ({
|
|
|
86
86
|
})(mergedParams) : mergedParams;
|
|
87
87
|
let result = rawResult ?? {};
|
|
88
88
|
if (onSuccess) {
|
|
89
|
-
result = await onSuccess(result);
|
|
89
|
+
result = await onSuccess({ data: result, params: mergedParams });
|
|
90
90
|
}
|
|
91
91
|
return import_next_rest_framework.TypedNextResponse.json(result, {
|
|
92
92
|
status: 200
|
|
@@ -7,7 +7,10 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
7
7
|
setBody?: (_req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
|
-
onSuccess?: (
|
|
10
|
+
onSuccess?: (_payload: {
|
|
11
|
+
params: Record<string, unknown>;
|
|
12
|
+
data: z.infer<OB>;
|
|
13
|
+
}) => Promise<z.infer<OB>>;
|
|
11
14
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
12
15
|
table?: TTable;
|
|
13
16
|
}
|
|
@@ -71,11 +71,12 @@ var createPostOperation = ({
|
|
|
71
71
|
req
|
|
72
72
|
)) || {};
|
|
73
73
|
const mergedBody = { ...body, ...extraBody };
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const params = { creatorId: userId, ...mergedBody };
|
|
75
|
+
const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(params))[0] : params;
|
|
76
|
+
const data = onSuccess ? await onSuccess({
|
|
77
|
+
data: raw,
|
|
78
|
+
params
|
|
79
|
+
}) : raw;
|
|
79
80
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
80
81
|
status: 200
|
|
81
82
|
});
|
|
@@ -8,7 +8,10 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
8
8
|
summary?: string;
|
|
9
9
|
tags?: string[];
|
|
10
10
|
setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
11
|
-
onSuccess?: (
|
|
11
|
+
onSuccess?: (_payload: {
|
|
12
|
+
params: Record<string, unknown>;
|
|
13
|
+
data: z.infer<OB>;
|
|
14
|
+
}) => Promise<z.infer<OB>>;
|
|
12
15
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
13
16
|
byCreator?: boolean;
|
|
14
17
|
}
|
|
@@ -73,12 +73,16 @@ var createPutOperation = ({
|
|
|
73
73
|
req
|
|
74
74
|
)) || {};
|
|
75
75
|
const mergedBody = { ...body, ...extraBody };
|
|
76
|
+
const params = { editorId: userId, ...mergedBody };
|
|
76
77
|
const raw = table ? await (0, import_actions.createPutAction)({
|
|
77
78
|
bodySchema,
|
|
78
79
|
table,
|
|
79
80
|
db
|
|
80
|
-
})(
|
|
81
|
-
const data = onSuccess ? await onSuccess(
|
|
81
|
+
})(params, { byCreator }) : params;
|
|
82
|
+
const data = onSuccess ? await onSuccess({
|
|
83
|
+
data: raw,
|
|
84
|
+
params
|
|
85
|
+
}) : raw;
|
|
82
86
|
return import_next_rest_framework.TypedNextResponse.json(data, {
|
|
83
87
|
status: 200
|
|
84
88
|
});
|