@ai0x0/utils 0.0.39 → 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.
Files changed (43) hide show
  1. package/.agents/skills/ai0x0-utils/backend/SKILL.md +4 -2
  2. package/SKILL.md +4 -2
  3. package/es/backend/route-operation/delete-operation.d.ts +7 -1
  4. package/es/backend/route-operation/delete-operation.js +5 -2
  5. package/es/backend/route-operation/get-list-operation.d.ts +6 -3
  6. package/es/backend/route-operation/get-list-operation.js +5 -2
  7. package/es/backend/route-operation/get-operation.d.ts +4 -1
  8. package/es/backend/route-operation/get-operation.js +5 -2
  9. package/es/backend/route-operation/post-operation.d.ts +4 -1
  10. package/es/backend/route-operation/post-operation.js +32 -30
  11. package/es/backend/route-operation/put-operation.d.ts +4 -1
  12. package/es/backend/route-operation/put-operation.js +34 -32
  13. package/es/backend/sqlite/route-operation/delete-operation.d.ts +7 -1
  14. package/es/backend/sqlite/route-operation/delete-operation.js +5 -2
  15. package/es/backend/sqlite/route-operation/get-list-operation.d.ts +6 -3
  16. package/es/backend/sqlite/route-operation/get-list-operation.js +5 -2
  17. package/es/backend/sqlite/route-operation/get-operation.d.ts +4 -1
  18. package/es/backend/sqlite/route-operation/get-operation.js +5 -2
  19. package/es/backend/sqlite/route-operation/post-operation.d.ts +4 -1
  20. package/es/backend/sqlite/route-operation/post-operation.js +30 -28
  21. package/es/backend/sqlite/route-operation/put-operation.d.ts +4 -1
  22. package/es/backend/sqlite/route-operation/put-operation.js +32 -30
  23. package/lib/backend/route-operation/delete-operation.d.ts +7 -1
  24. package/lib/backend/route-operation/delete-operation.js +2 -2
  25. package/lib/backend/route-operation/get-list-operation.d.ts +6 -3
  26. package/lib/backend/route-operation/get-list-operation.js +2 -2
  27. package/lib/backend/route-operation/get-operation.d.ts +4 -1
  28. package/lib/backend/route-operation/get-operation.js +2 -2
  29. package/lib/backend/route-operation/post-operation.d.ts +4 -1
  30. package/lib/backend/route-operation/post-operation.js +8 -5
  31. package/lib/backend/route-operation/put-operation.d.ts +4 -1
  32. package/lib/backend/route-operation/put-operation.js +7 -3
  33. package/lib/backend/sqlite/route-operation/delete-operation.d.ts +7 -1
  34. package/lib/backend/sqlite/route-operation/delete-operation.js +2 -2
  35. package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +6 -3
  36. package/lib/backend/sqlite/route-operation/get-list-operation.js +5 -2
  37. package/lib/backend/sqlite/route-operation/get-operation.d.ts +4 -1
  38. package/lib/backend/sqlite/route-operation/get-operation.js +2 -2
  39. package/lib/backend/sqlite/route-operation/post-operation.d.ts +4 -1
  40. package/lib/backend/sqlite/route-operation/post-operation.js +8 -5
  41. package/lib/backend/sqlite/route-operation/put-operation.d.ts +4 -1
  42. package/lib/backend/sqlite/route-operation/put-operation.js +7 -3
  43. 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` 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.
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
 
@@ -346,7 +348,7 @@ export const { GET } = route({
346
348
 
347
349
  - Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
348
350
  - 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 the payload is `{ data, total }`.
351
+ - Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
350
352
  - Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
351
353
 
352
354
  ## Imports
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` 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.
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
 
@@ -325,7 +327,7 @@ export const { GET } = route({
325
327
 
326
328
  - Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
327
329
  - 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 the payload is `{ data, total }`.
330
+ - Post-processing output — `onSuccess({ params, data }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
329
331
  - Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
330
332
 
331
333
  ## 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?: () => Promise<void>;
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
  }
@@ -58,7 +58,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
58
58
  userId = _ref4.userId;
59
59
  body.creatorId = userId;
60
60
  case 13:
61
- if (!table) {
61
+ if (!(table && db)) {
62
62
  _context.next = 19;
63
63
  break;
64
64
  }
@@ -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>(data: {
15
- data: z.infer<D>[];
16
- total: number;
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;
@@ -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
  }
@@ -99,7 +99,10 @@ export var createGetListOperation = function createGetListOperation(_ref) {
99
99
  break;
100
100
  }
101
101
  _context.next = 28;
102
- return onSuccess(result);
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?(data: z.infer<T>): Promise<z.infer<T>>;
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[];
@@ -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
  }
@@ -96,7 +96,10 @@ export var createGetOperation = function createGetOperation(_ref) {
96
96
  break;
97
97
  }
98
98
  _context.next = 29;
99
- return onSuccess(result);
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?(data: z.infer<OB>): Promise<z.infer<OB>>;
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
- if (!table) {
77
- _context.next = 24;
76
+ params = _objectSpread({
77
+ creatorId: userId
78
+ }, mergedBody);
79
+ if (!(table && db)) {
80
+ _context.next = 25;
78
81
  break;
79
82
  }
80
- _context.next = 21;
83
+ _context.next = 22;
81
84
  return createPostAction({
82
85
  bodySchema: bodySchema,
83
86
  db: db,
84
87
  table: table
85
- })(_objectSpread({
86
- creatorId: userId
87
- }, mergedBody));
88
- case 21:
88
+ })(params);
89
+ case 22:
89
90
  _context.t2 = _context.sent[0];
90
- _context.next = 25;
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 = 32;
98
+ _context.next = 33;
100
99
  break;
101
100
  }
102
- _context.next = 29;
103
- return onSuccess(raw);
104
- case 29:
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 = 33;
108
+ _context.next = 34;
107
109
  break;
108
- case 32:
109
- _context.t3 = raw;
110
110
  case 33:
111
- _data = _context.t3;
112
- return _context.abrupt("return", TypedNextResponse.json(_data, {
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 37:
116
- _context.prev = 37;
117
+ case 38:
118
+ _context.prev = 38;
117
119
  _context.t4 = _context["catch"](0);
118
120
  console.error(_context.t4);
119
- _context.next = 42;
121
+ _context.next = 43;
120
122
  return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
121
- case 42:
123
+ case 43:
122
124
  response = _context.sent;
123
125
  if (!response) {
124
- _context.next = 47;
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, 37]]);
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?(data: z.infer<OB>): Promise<z.infer<OB>>;
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
- if (!table) {
78
- _context.next = 24;
77
+ params = _objectSpread({
78
+ editorId: userId
79
+ }, mergedBody);
80
+ if (!(table && db)) {
81
+ _context.next = 25;
79
82
  break;
80
83
  }
81
- _context.next = 21;
84
+ _context.next = 22;
82
85
  return createPutAction({
83
86
  bodySchema: bodySchema,
84
87
  table: table,
85
88
  db: db
86
- })(_objectSpread({
87
- editorId: userId
88
- }, mergedBody), {
89
+ })(params, {
89
90
  byCreator: byCreator
90
91
  });
91
- case 21:
92
+ case 22:
92
93
  _context.t2 = _context.sent;
93
- _context.next = 25;
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 = 32;
101
+ _context.next = 33;
103
102
  break;
104
103
  }
105
- _context.next = 29;
106
- return onSuccess(raw);
107
- case 29:
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 = 33;
111
+ _context.next = 34;
110
112
  break;
111
- case 32:
112
- _context.t3 = raw;
113
113
  case 33:
114
- _data = _context.t3;
115
- return _context.abrupt("return", TypedNextResponse.json(_data, {
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 37:
119
- _context.prev = 37;
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 = 42;
126
+ _context.next = 43;
125
127
  return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
126
- case 42:
128
+ case 43:
127
129
  response = _context.sent;
128
130
  if (!response) {
129
- _context.next = 45;
131
+ _context.next = 46;
130
132
  break;
131
133
  }
132
134
  return _context.abrupt("return", response);
133
- case 45:
135
+ case 46:
134
136
  if (!(_context.t4 instanceof HttpError)) {
135
- _context.next = 47;
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, 37]]);
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?: () => Promise<void>;
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
  }
@@ -58,7 +58,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
58
58
  userId = _ref4.userId;
59
59
  body.creatorId = userId;
60
60
  case 13:
61
- if (!table) {
61
+ if (!(table && db)) {
62
62
  _context.next = 19;
63
63
  break;
64
64
  }
@@ -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>(_data: {
15
- data: z.infer<D>[];
16
- total: number;
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;
@@ -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
  }
@@ -99,7 +99,10 @@ export var createGetListOperation = function createGetListOperation(_ref) {
99
99
  break;
100
100
  }
101
101
  _context.next = 28;
102
- return onSuccess(result);
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?: (_data: z.infer<T>) => Promise<z.infer<T>>;
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[];
@@ -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
  }
@@ -96,7 +96,10 @@ export var createGetOperation = function createGetOperation(_ref) {
96
96
  break;
97
97
  }
98
98
  _context.next = 29;
99
- return onSuccess(result);
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?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
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
- if (!table) {
77
- _context.next = 24;
76
+ params = _objectSpread({
77
+ creatorId: userId
78
+ }, mergedBody);
79
+ if (!(table && db)) {
80
+ _context.next = 25;
78
81
  break;
79
82
  }
80
- _context.next = 21;
83
+ _context.next = 22;
81
84
  return createPostAction({
82
85
  bodySchema: bodySchema,
83
86
  db: db,
84
87
  table: table
85
- })(_objectSpread({
86
- creatorId: userId
87
- }, mergedBody));
88
- case 21:
88
+ })(params);
89
+ case 22:
89
90
  _context.t2 = _context.sent[0];
90
- _context.next = 25;
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 = 32;
98
+ _context.next = 33;
100
99
  break;
101
100
  }
102
- _context.next = 29;
103
- return onSuccess(raw);
104
- case 29:
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 = 33;
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 37:
116
- _context.prev = 37;
117
+ case 38:
118
+ _context.prev = 38;
117
119
  _context.t4 = _context["catch"](0);
118
120
  console.error(_context.t4);
119
- _context.next = 42;
121
+ _context.next = 43;
120
122
  return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
121
- case 42:
123
+ case 43:
122
124
  response = _context.sent;
123
125
  if (!response) {
124
- _context.next = 47;
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, 37]]);
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?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
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
- if (!table) {
78
- _context.next = 24;
77
+ params = _objectSpread({
78
+ editorId: userId
79
+ }, mergedBody);
80
+ if (!(table && db)) {
81
+ _context.next = 25;
79
82
  break;
80
83
  }
81
- _context.next = 21;
84
+ _context.next = 22;
82
85
  return createPutAction({
83
86
  bodySchema: bodySchema,
84
87
  table: table,
85
88
  db: db
86
- })(_objectSpread({
87
- editorId: userId
88
- }, mergedBody), {
89
+ })(params, {
89
90
  byCreator: byCreator
90
91
  });
91
- case 21:
92
+ case 22:
92
93
  _context.t2 = _context.sent;
93
- _context.next = 25;
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 = 32;
101
+ _context.next = 33;
103
102
  break;
104
103
  }
105
- _context.next = 29;
106
- return onSuccess(raw);
107
- case 29:
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 = 33;
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 37:
119
- _context.prev = 37;
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 = 42;
126
+ _context.next = 43;
125
127
  return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
126
- case 42:
128
+ case 43:
127
129
  response = _context.sent;
128
130
  if (!response) {
129
- _context.next = 45;
131
+ _context.next = 46;
130
132
  break;
131
133
  }
132
134
  return _context.abrupt("return", response);
133
- case 45:
135
+ case 46:
134
136
  if (!(_context.t4 instanceof HttpError)) {
135
- _context.next = 47;
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, 37]]);
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?: () => Promise<void>;
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
  }
@@ -65,8 +65,8 @@ 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;
69
- await (onSuccess == null ? void 0 : onSuccess());
68
+ const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
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>(data: {
15
- data: z.infer<D>[];
16
- total: number;
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;
@@ -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,
@@ -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?(data: z.infer<T>): Promise<z.infer<T>>;
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[];
@@ -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,
@@ -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?(data: z.infer<OB>): Promise<z.infer<OB>>;
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,14 @@ var createPostOperation = ({
71
71
  req
72
72
  )) || {};
73
73
  const mergedBody = { ...body, ...extraBody };
74
- const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })({
75
- creatorId: userId,
76
- ...mergedBody
77
- }))[0] : { creatorId: userId, ...mergedBody };
78
- const data = onSuccess ? await onSuccess(raw) : raw;
74
+ const params = { creatorId: userId, ...mergedBody };
75
+ const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
76
+ params
77
+ ))[0] : params;
78
+ const data = onSuccess ? await onSuccess({
79
+ data: raw,
80
+ params
81
+ }) : raw;
79
82
  return import_next_rest_framework.TypedNextResponse.json(data, {
80
83
  status: 200
81
84
  });
@@ -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?(data: z.infer<OB>): Promise<z.infer<OB>>;
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 raw = table ? await (0, import_actions.createPutAction)({
76
+ const params = { editorId: userId, ...mergedBody };
77
+ const raw = table && db ? await (0, import_actions.createPutAction)({
77
78
  bodySchema,
78
79
  table,
79
80
  db
80
- })({ editorId: userId, ...mergedBody }, { byCreator }) : { editorId: userId, ...mergedBody };
81
- const data = onSuccess ? await onSuccess(raw) : raw;
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?: () => Promise<void>;
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
  }
@@ -65,8 +65,8 @@ 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;
69
- await (onSuccess == null ? void 0 : onSuccess());
68
+ const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
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>(_data: {
15
- data: z.infer<D>[];
16
- total: number;
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;
@@ -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,
@@ -86,7 +86,10 @@ var createGetListOperation = ({
86
86
  table
87
87
  })(mergedParams) : { data: [], total: 0 };
88
88
  if (onSuccess) {
89
- result = await onSuccess(result);
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?: (_data: z.infer<T>) => Promise<z.infer<T>>;
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[];
@@ -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,
@@ -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?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
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,14 @@ var createPostOperation = ({
71
71
  req
72
72
  )) || {};
73
73
  const mergedBody = { ...body, ...extraBody };
74
- const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })({
75
- creatorId: userId,
76
- ...mergedBody
77
- }))[0] : { creatorId: userId, ...mergedBody };
78
- const data = onSuccess ? await onSuccess(raw) : raw;
74
+ const params = { creatorId: userId, ...mergedBody };
75
+ const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
76
+ params
77
+ ))[0] : params;
78
+ const data = onSuccess ? await onSuccess({
79
+ data: raw,
80
+ params
81
+ }) : raw;
79
82
  return import_next_rest_framework.TypedNextResponse.json(data, {
80
83
  status: 200
81
84
  });
@@ -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?: (_data: z.infer<OB>) => Promise<z.infer<OB>>;
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 raw = table ? await (0, import_actions.createPutAction)({
76
+ const params = { editorId: userId, ...mergedBody };
77
+ const raw = table && db ? await (0, import_actions.createPutAction)({
77
78
  bodySchema,
78
79
  table,
79
80
  db
80
- })({ editorId: userId, ...mergedBody }, { byCreator }) : { editorId: userId, ...mergedBody };
81
- const data = onSuccess ? await onSuccess(raw) : raw;
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai0x0/utils",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "AI0x0 utils",
5
5
  "keywords": [
6
6
  "ai0x0"