@ai0x0/utils 0.0.38 → 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.
Files changed (43) hide show
  1. package/.agents/skills/ai0x0-utils/backend/SKILL.md +13 -9
  2. package/SKILL.md +13 -9
  3. package/es/backend/route-operation/delete-operation.d.ts +10 -3
  4. package/es/backend/route-operation/delete-operation.js +39 -23
  5. package/es/backend/route-operation/get-list-operation.d.ts +11 -7
  6. package/es/backend/route-operation/get-list-operation.js +41 -23
  7. package/es/backend/route-operation/get-operation.d.ts +8 -4
  8. package/es/backend/route-operation/get-operation.js +38 -23
  9. package/es/backend/route-operation/post-operation.d.ts +8 -4
  10. package/es/backend/route-operation/post-operation.js +45 -38
  11. package/es/backend/route-operation/put-operation.d.ts +8 -4
  12. package/es/backend/route-operation/put-operation.js +53 -36
  13. package/es/backend/sqlite/route-operation/delete-operation.d.ts +9 -2
  14. package/es/backend/sqlite/route-operation/delete-operation.js +39 -26
  15. package/es/backend/sqlite/route-operation/get-list-operation.d.ts +8 -4
  16. package/es/backend/sqlite/route-operation/get-list-operation.js +41 -25
  17. package/es/backend/sqlite/route-operation/get-operation.d.ts +6 -2
  18. package/es/backend/sqlite/route-operation/get-operation.js +38 -25
  19. package/es/backend/sqlite/route-operation/post-operation.d.ts +6 -2
  20. package/es/backend/sqlite/route-operation/post-operation.js +44 -38
  21. package/es/backend/sqlite/route-operation/put-operation.d.ts +6 -2
  22. package/es/backend/sqlite/route-operation/put-operation.js +51 -37
  23. package/lib/backend/route-operation/delete-operation.d.ts +10 -3
  24. package/lib/backend/route-operation/delete-operation.js +6 -4
  25. package/lib/backend/route-operation/get-list-operation.d.ts +11 -7
  26. package/lib/backend/route-operation/get-list-operation.js +9 -9
  27. package/lib/backend/route-operation/get-operation.d.ts +8 -4
  28. package/lib/backend/route-operation/get-operation.js +9 -9
  29. package/lib/backend/route-operation/post-operation.d.ts +8 -4
  30. package/lib/backend/route-operation/post-operation.js +8 -6
  31. package/lib/backend/route-operation/put-operation.d.ts +8 -4
  32. package/lib/backend/route-operation/put-operation.js +11 -5
  33. package/lib/backend/sqlite/route-operation/delete-operation.d.ts +9 -2
  34. package/lib/backend/sqlite/route-operation/delete-operation.js +4 -3
  35. package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +8 -4
  36. package/lib/backend/sqlite/route-operation/get-list-operation.js +12 -9
  37. package/lib/backend/sqlite/route-operation/get-operation.d.ts +6 -2
  38. package/lib/backend/sqlite/route-operation/get-operation.js +9 -9
  39. package/lib/backend/sqlite/route-operation/post-operation.d.ts +6 -2
  40. package/lib/backend/sqlite/route-operation/post-operation.js +8 -6
  41. package/lib/backend/sqlite/route-operation/put-operation.d.ts +6 -2
  42. package/lib/backend/sqlite/route-operation/put-operation.js +9 -4
  43. package/package.json +1 -1
@@ -85,14 +85,18 @@ export const getListOperation = createGetListOperation({ db, getSession });
85
85
 
86
86
  ## Factory Catalog
87
87
 
88
- | Export | Purpose | Required options | Notable optional options |
89
- | ------------------- | -------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------- |
90
- | `createTableSchema` | pg `Table` + 5 zod schemas | `name`, `columns` | `refineSchema`, `extraConfig` |
91
- | `getOperation` | GET one by filters | `table`, `bodySchema`, `querySchema` | `setParams`, `relations`, `jsonArrayFields`, `byCreator`, `onSuccess`, `onError`, `summary` |
92
- | `getListOperation` | GET paginated list | `table`, `bodySchema`, `querySchema` | `setParams`, `relations`, `jsonArrayFields`, `onSuccess`, `onError`, `summary` |
93
- | `postOperation` | POST create | `table`, `bodySchema` | `outputBodySchema`, `setBody`, `onSuccess`, `onError`, `summary` |
94
- | `putOperation` | PUT update | `table`, `bodySchema` | `outputBodySchema`, `setBody`, `byCreator`, `onSuccess`, `onError`, `summary` |
95
- | `deleteOperation` | DELETE | `table` | `byCreator`, `onSuccess`, `onError`, `summary` |
88
+ | Export | Purpose | Required options | Notable optional options |
89
+ | ------------------- | -------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------ |
90
+ | `createTableSchema` | pg `Table` + 5 zod schemas | `name`, `columns` | `refineSchema`, `extraConfig` |
91
+ | `getOperation` | GET one by filters | `bodySchema`, `querySchema` | `table`, `setParams`, `relations`, `jsonArrayFields`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
92
+ | `getListOperation` | GET paginated list | `bodySchema`, `querySchema` | `table`, `setParams`, `relations`, `jsonArrayFields`, `onSuccess`, `onError`, `summary`, `tags` |
93
+ | `postOperation` | POST create | `bodySchema` | `table`, `outputBodySchema`, `setBody`, `onSuccess`, `onError`, `summary`, `tags` |
94
+ | `putOperation` | PUT update | `bodySchema` | `table`, `outputBodySchema`, `setBody`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
95
+ | `deleteOperation` | DELETE | — | `table`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
96
+
97
+ `tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
98
+
99
+ `table` is optional for route operations. When omitted, 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.
96
100
 
97
101
  ## Canonical Examples
98
102
 
@@ -342,7 +346,7 @@ export const { GET } = route({
342
346
 
343
347
  - Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
344
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`.
345
- - Post-processing output — `onSuccess(data) => Promise<data>`; on GET_LIST the payload is `{ data, total }`.
349
+ - Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
346
350
  - Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
347
351
 
348
352
  ## Imports
package/SKILL.md CHANGED
@@ -64,14 +64,18 @@ export const getListOperation = createGetListOperation({ db, getSession });
64
64
 
65
65
  ## Factory Catalog
66
66
 
67
- | Export | Purpose | Required options | Notable optional options |
68
- | ------------------- | -------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------- |
69
- | `createTableSchema` | pg `Table` + 5 zod schemas | `name`, `columns` | `refineSchema`, `extraConfig` |
70
- | `getOperation` | GET one by filters | `table`, `bodySchema`, `querySchema` | `setParams`, `relations`, `jsonArrayFields`, `byCreator`, `onSuccess`, `onError`, `summary` |
71
- | `getListOperation` | GET paginated list | `table`, `bodySchema`, `querySchema` | `setParams`, `relations`, `jsonArrayFields`, `onSuccess`, `onError`, `summary` |
72
- | `postOperation` | POST create | `table`, `bodySchema` | `outputBodySchema`, `setBody`, `onSuccess`, `onError`, `summary` |
73
- | `putOperation` | PUT update | `table`, `bodySchema` | `outputBodySchema`, `setBody`, `byCreator`, `onSuccess`, `onError`, `summary` |
74
- | `deleteOperation` | DELETE | `table` | `byCreator`, `onSuccess`, `onError`, `summary` |
67
+ | Export | Purpose | Required options | Notable optional options |
68
+ | ------------------- | -------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------ |
69
+ | `createTableSchema` | pg `Table` + 5 zod schemas | `name`, `columns` | `refineSchema`, `extraConfig` |
70
+ | `getOperation` | GET one by filters | `bodySchema`, `querySchema` | `table`, `setParams`, `relations`, `jsonArrayFields`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
71
+ | `getListOperation` | GET paginated list | `bodySchema`, `querySchema` | `table`, `setParams`, `relations`, `jsonArrayFields`, `onSuccess`, `onError`, `summary`, `tags` |
72
+ | `postOperation` | POST create | `bodySchema` | `table`, `outputBodySchema`, `setBody`, `onSuccess`, `onError`, `summary`, `tags` |
73
+ | `putOperation` | PUT update | `bodySchema` | `table`, `outputBodySchema`, `setBody`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
74
+ | `deleteOperation` | DELETE | — | `table`, `byCreator`, `onSuccess`, `onError`, `summary`, `tags` |
75
+
76
+ `tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
77
+
78
+ `table` is optional for route operations. When omitted, 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.
75
79
 
76
80
  ## Canonical Examples
77
81
 
@@ -321,7 +325,7 @@ export const { GET } = route({
321
325
 
322
326
  - Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
323
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`.
324
- - Post-processing output — `onSuccess(data) => Promise<data>`; on GET_LIST the payload is `{ data, total }`.
328
+ - Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
325
329
  - Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
326
330
 
327
331
  ## Imports
@@ -1,10 +1,17 @@
1
1
  import { TypedNextResponse } from "next-rest-framework";
2
2
  import { BaseTable } from "../types.js";
3
3
  export interface DeleteOperationOptions<TTable extends BaseTable> {
4
- table: TTable;
4
+ table?: TTable;
5
5
  summary?: string;
6
- onSuccess?: () => Promise<void>;
7
- onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
6
+ tags?: string[];
7
+ onSuccess?: (payload: {
8
+ params: {
9
+ id: string;
10
+ creatorId?: string;
11
+ };
12
+ data: unknown;
13
+ }) => Promise<void>;
14
+ onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
8
15
  byCreator?: boolean;
9
16
  }
10
17
  export declare const createDeleteOperation: any;
@@ -13,6 +13,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
13
13
  return function (_ref2) {
14
14
  var table = _ref2.table,
15
15
  summary = _ref2.summary,
16
+ tags = _ref2.tags,
16
17
  onSuccess = _ref2.onSuccess,
17
18
  onError = _ref2.onError,
18
19
  _ref2$byCreator = _ref2.byCreator,
@@ -21,7 +22,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
21
22
  method: "DELETE",
22
23
  openApiOperation: {
23
24
  summary: summary,
24
- tags: [getTableName(table)]
25
+ tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
25
26
  }
26
27
  }).input({
27
28
  body: z.object({
@@ -57,49 +58,64 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
57
58
  userId = _ref4.userId;
58
59
  body.creatorId = userId;
59
60
  case 13:
60
- _context.next = 15;
61
+ if (!table) {
62
+ _context.next = 19;
63
+ break;
64
+ }
65
+ _context.next = 16;
61
66
  return createDeleteAction({
62
67
  table: table,
63
68
  db: db
64
69
  })(body);
65
- case 15:
66
- data = _context.sent;
67
- _context.next = 18;
68
- return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
69
- case 18:
70
+ case 16:
71
+ _context.t1 = _context.sent;
72
+ _context.next = 20;
73
+ break;
74
+ case 19:
75
+ _context.t1 = body;
76
+ case 20:
77
+ data = _context.t1;
78
+ _context.next = 23;
79
+ return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
80
+ data: data,
81
+ params: body
82
+ });
83
+ case 23:
70
84
  return _context.abrupt("return", TypedNextResponse.json(data, {
71
85
  status: 200
72
86
  }));
73
- case 21:
74
- _context.prev = 21;
75
- _context.t1 = _context["catch"](0);
76
- if (!(_context.t1 instanceof HttpError)) console.error(_context.t1);
77
- _context.next = 26;
78
- return onError === null || onError === void 0 ? void 0 : onError(_context.t1);
79
87
  case 26:
88
+ _context.prev = 26;
89
+ _context.t2 = _context["catch"](0);
90
+ if (!(_context.t2 instanceof HttpError)) {
91
+ console.error(_context.t2);
92
+ }
93
+ _context.next = 31;
94
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t2);
95
+ case 31:
80
96
  response = _context.sent;
81
97
  if (!response) {
82
- _context.next = 29;
98
+ _context.next = 34;
83
99
  break;
84
100
  }
85
101
  return _context.abrupt("return", response);
86
- case 29:
87
- if (!(_context.t1 instanceof HttpError)) {
88
- _context.next = 31;
102
+ case 34:
103
+ if (!(_context.t2 instanceof HttpError)) {
104
+ _context.next = 36;
89
105
  break;
90
106
  }
91
107
  return _context.abrupt("return", TypedNextResponse.json({
92
- message: _context.t1.message
108
+ message: _context.t2.message
93
109
  }, {
94
- status: _context.t1.status
110
+ status: _context.t2.status
95
111
  }));
96
- case 31:
97
- throw _context.t1;
98
- case 32:
112
+ case 36:
113
+ throw _context.t2;
114
+ case 37:
99
115
  case "end":
100
116
  return _context.stop();
101
117
  }
102
- }, _callee, null, [[0, 21]]);
118
+ }, _callee, null, [[0, 26]]);
103
119
  }));
104
120
  return function (_x) {
105
121
  return _ref3.apply(this, arguments);
@@ -6,17 +6,21 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
6
6
  jsonArrayFields?: string[];
7
7
  querySchema: Q;
8
8
  relations?: GetListRelations;
9
- setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
9
+ setParams?(req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>): Promise<Record<string, unknown>>;
10
10
  byCreator?: boolean;
11
11
  summary?: string;
12
- table: TTable;
13
- onSuccess?: <D extends T>(data: {
14
- data: z.infer<D>[];
15
- total: number;
16
- }) => Promise<{
12
+ tags?: string[];
13
+ table?: TTable;
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
+ };
20
+ }): Promise<{
17
21
  data: z.infer<T>[];
18
22
  total: number;
19
23
  }>;
20
- onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
24
+ onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
21
25
  }
22
26
  export declare const createGetListOperation: any;
@@ -14,6 +14,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
14
14
  bodySchema = _ref2.bodySchema,
15
15
  table = _ref2.table,
16
16
  summary = _ref2.summary,
17
+ tags = _ref2.tags,
17
18
  relations = _ref2.relations,
18
19
  jsonArrayFields = _ref2.jsonArrayFields,
19
20
  setParams = _ref2.setParams,
@@ -25,7 +26,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
25
26
  method: "GET",
26
27
  openApiOperation: {
27
28
  summary: summary,
28
- tags: [getTableName(table)]
29
+ tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
29
30
  }
30
31
  }).input({
31
32
  query: querySchema
@@ -35,7 +36,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
35
36
  status: 200
36
37
  }]).handler( /*#__PURE__*/function () {
37
38
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
38
- var params, _ref4, userId, result, response;
39
+ var params, _ref4, userId, mergedParams, result, response;
39
40
  return _regeneratorRuntime().wrap(function _callee$(_context) {
40
41
  while (1) switch (_context.prev = _context.next) {
41
42
  case 0:
@@ -69,48 +70,65 @@ export var createGetListOperation = function createGetListOperation(_ref) {
69
70
  userId = _ref4.userId;
70
71
  params.creatorId = userId;
71
72
  case 16:
72
- _context.next = 18;
73
+ mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
74
+ if (!table) {
75
+ _context.next = 23;
76
+ break;
77
+ }
78
+ _context.next = 20;
73
79
  return createGetListAction({
74
80
  bodySchema: bodySchema,
75
81
  db: db,
76
82
  jsonArrayFields: jsonArrayFields,
77
83
  relations: relations,
78
84
  table: table
79
- })(Object.assign(Object.fromEntries(new URL(req.url).searchParams), params));
80
- case 18:
81
- result = _context.sent;
85
+ })(mergedParams);
86
+ case 20:
87
+ _context.t2 = _context.sent;
88
+ _context.next = 24;
89
+ break;
90
+ case 23:
91
+ _context.t2 = {
92
+ data: [],
93
+ total: 0
94
+ };
95
+ case 24:
96
+ result = _context.t2;
82
97
  if (!onSuccess) {
83
- _context.next = 23;
98
+ _context.next = 29;
84
99
  break;
85
100
  }
86
- _context.next = 22;
87
- return onSuccess(result);
88
- case 22:
101
+ _context.next = 28;
102
+ return onSuccess({
103
+ data: result,
104
+ params: mergedParams
105
+ });
106
+ case 28:
89
107
  result = _context.sent;
90
- case 23:
108
+ case 29:
91
109
  return _context.abrupt("return", TypedNextResponse.json(result, {
92
110
  status: 200
93
111
  }));
94
- case 26:
95
- _context.prev = 26;
96
- _context.t2 = _context["catch"](0);
97
- console.error(_context.t2);
98
- _context.next = 31;
99
- return onError === null || onError === void 0 ? void 0 : onError(_context.t2);
100
- case 31:
112
+ case 32:
113
+ _context.prev = 32;
114
+ _context.t3 = _context["catch"](0);
115
+ console.error(_context.t3);
116
+ _context.next = 37;
117
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
118
+ case 37:
101
119
  response = _context.sent;
102
120
  if (!response) {
103
- _context.next = 36;
121
+ _context.next = 42;
104
122
  break;
105
123
  }
106
124
  return _context.abrupt("return", response);
107
- case 36:
108
- throw _context.t2;
109
- case 37:
125
+ case 42:
126
+ throw _context.t3;
127
+ case 43:
110
128
  case "end":
111
129
  return _context.stop();
112
130
  }
113
- }, _callee, null, [[0, 26]]);
131
+ }, _callee, null, [[0, 32]]);
114
132
  }));
115
133
  return function (_x) {
116
134
  return _ref3.apply(this, arguments);
@@ -6,11 +6,15 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
6
6
  jsonArrayFields?: string[];
7
7
  querySchema: Q;
8
8
  relations?: GetListRelations;
9
- setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
10
- onSuccess?: (data: z.infer<T>) => Promise<z.infer<T>>;
11
- onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
9
+ setParams?(req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>): Promise<Record<string, unknown>>;
10
+ onSuccess?(payload: {
11
+ params: Partial<z.infer<T>> & Record<string, unknown>;
12
+ data: z.infer<T>;
13
+ }): Promise<z.infer<T>>;
14
+ onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
12
15
  summary?: string;
13
- table: TTable;
16
+ tags?: string[];
17
+ table?: TTable;
14
18
  byCreator?: boolean;
15
19
  }
16
20
  export declare const createGetOperation: any;
@@ -13,6 +13,7 @@ export var createGetOperation = function createGetOperation(_ref) {
13
13
  bodySchema = _ref2.bodySchema,
14
14
  table = _ref2.table,
15
15
  summary = _ref2.summary,
16
+ tags = _ref2.tags,
16
17
  relations = _ref2.relations,
17
18
  setParams = _ref2.setParams,
18
19
  jsonArrayFields = _ref2.jsonArrayFields,
@@ -24,7 +25,7 @@ export var createGetOperation = function createGetOperation(_ref) {
24
25
  method: "GET",
25
26
  openApiOperation: {
26
27
  summary: summary,
27
- tags: [getTableName(table)]
28
+ tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
28
29
  }
29
30
  }).input({
30
31
  query: querySchema
@@ -34,7 +35,7 @@ export var createGetOperation = function createGetOperation(_ref) {
34
35
  status: 200
35
36
  }]).handler( /*#__PURE__*/function () {
36
37
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
37
- var params, _ref4, userId, rawResult, result, response;
38
+ var params, _ref4, userId, mergedParams, rawResult, result, response;
38
39
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
40
  while (1) switch (_context.prev = _context.next) {
40
41
  case 0:
@@ -68,49 +69,63 @@ export var createGetOperation = function createGetOperation(_ref) {
68
69
  userId = _ref4.userId;
69
70
  params.creatorId = userId;
70
71
  case 16:
71
- _context.next = 18;
72
+ mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
73
+ if (!table) {
74
+ _context.next = 23;
75
+ break;
76
+ }
77
+ _context.next = 20;
72
78
  return createGetAction({
73
79
  bodySchema: bodySchema,
74
80
  db: db,
75
81
  jsonArrayFields: jsonArrayFields,
76
82
  relations: relations,
77
83
  table: table
78
- })(Object.assign(Object.fromEntries(new URL(req.url).searchParams), params));
79
- case 18:
80
- rawResult = _context.sent;
84
+ })(mergedParams);
85
+ case 20:
86
+ _context.t2 = _context.sent;
87
+ _context.next = 24;
88
+ break;
89
+ case 23:
90
+ _context.t2 = mergedParams;
91
+ case 24:
92
+ rawResult = _context.t2;
81
93
  result = rawResult !== null && rawResult !== void 0 ? rawResult : {};
82
94
  if (!onSuccess) {
83
- _context.next = 24;
95
+ _context.next = 30;
84
96
  break;
85
97
  }
86
- _context.next = 23;
87
- return onSuccess(result);
88
- case 23:
98
+ _context.next = 29;
99
+ return onSuccess({
100
+ data: result,
101
+ params: mergedParams
102
+ });
103
+ case 29:
89
104
  result = _context.sent;
90
- case 24:
105
+ case 30:
91
106
  return _context.abrupt("return", TypedNextResponse.json(result, {
92
107
  status: 200
93
108
  }));
94
- case 27:
95
- _context.prev = 27;
96
- _context.t2 = _context["catch"](0);
97
- console.error(_context.t2);
98
- _context.next = 32;
99
- return onError === null || onError === void 0 ? void 0 : onError(_context.t2);
100
- case 32:
109
+ case 33:
110
+ _context.prev = 33;
111
+ _context.t3 = _context["catch"](0);
112
+ console.error(_context.t3);
113
+ _context.next = 38;
114
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
115
+ case 38:
101
116
  response = _context.sent;
102
117
  if (!response) {
103
- _context.next = 37;
118
+ _context.next = 43;
104
119
  break;
105
120
  }
106
121
  return _context.abrupt("return", response);
107
- case 37:
108
- throw _context.t2;
109
- case 38:
122
+ case 43:
123
+ throw _context.t3;
124
+ case 44:
110
125
  case "end":
111
126
  return _context.stop();
112
127
  }
113
- }, _callee, null, [[0, 27]]);
128
+ }, _callee, null, [[0, 33]]);
114
129
  }));
115
130
  return function (_x) {
116
131
  return _ref3.apply(this, arguments);
@@ -4,10 +4,14 @@ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
4
4
  export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
5
5
  bodySchema: IB;
6
6
  outputBodySchema?: IB;
7
- setBody?: (req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
7
+ setBody?(req: TypedNextRequest<"POST", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
8
8
  summary?: string;
9
- onSuccess?: (data: z.infer<OB>) => Promise<z.infer<OB>>;
10
- onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
11
- table: TTable;
9
+ tags?: string[];
10
+ onSuccess?(payload: {
11
+ params: Record<string, unknown>;
12
+ data: z.infer<OB>;
13
+ }): Promise<z.infer<OB>>;
14
+ onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
15
+ table?: TTable;
12
16
  }
13
17
  export declare const createPostOperation: any;