@ai0x0/utils 0.0.47 → 0.0.49

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 (74) hide show
  1. package/.agents/skills/ai0x0-utils/backend/SKILL.md +40 -38
  2. package/SKILL.md +39 -37
  3. package/es/__shims__/next-rest-framework.d.ts +2 -0
  4. package/es/backend/route-operation/delete-operation.d.ts +7 -24
  5. package/es/backend/route-operation/delete-operation.js +9 -127
  6. package/es/backend/route-operation/get-list-operation.d.ts +5 -31
  7. package/es/backend/route-operation/get-list-operation.js +10 -142
  8. package/es/backend/route-operation/get-operation.d.ts +5 -25
  9. package/es/backend/route-operation/get-operation.js +10 -139
  10. package/es/backend/route-operation/get-table-name.js +0 -2
  11. package/es/backend/route-operation/index.d.ts +1 -0
  12. package/es/backend/route-operation/index.js +2 -1
  13. package/es/backend/route-operation/open-api-operation.d.ts +6 -0
  14. package/es/backend/route-operation/open-api-operation.js +13 -0
  15. package/es/backend/route-operation/operation-common.d.ts +38 -0
  16. package/es/backend/route-operation/operation-common.js +148 -0
  17. package/es/backend/route-operation/operation-core.d.ts +3 -0
  18. package/es/backend/route-operation/operation-core.js +3 -0
  19. package/es/backend/route-operation/post-operation.d.ts +5 -25
  20. package/es/backend/route-operation/post-operation.js +13 -189
  21. package/es/backend/route-operation/put-operation.d.ts +4 -23
  22. package/es/backend/route-operation/put-operation.js +10 -155
  23. package/es/backend/route-operation/read-operation-core.d.ts +55 -0
  24. package/es/backend/route-operation/read-operation-core.js +224 -0
  25. package/es/backend/route-operation/write-operation-core.d.ts +94 -0
  26. package/es/backend/route-operation/write-operation-core.js +390 -0
  27. package/es/backend/sqlite/route-operation/delete-operation.d.ts +9 -26
  28. package/es/backend/sqlite/route-operation/delete-operation.js +9 -127
  29. package/es/backend/sqlite/route-operation/get-list-operation.d.ts +6 -32
  30. package/es/backend/sqlite/route-operation/get-list-operation.js +10 -142
  31. package/es/backend/sqlite/route-operation/get-operation.d.ts +6 -26
  32. package/es/backend/sqlite/route-operation/get-operation.js +10 -139
  33. package/es/backend/sqlite/route-operation/index.d.ts +1 -0
  34. package/es/backend/sqlite/route-operation/index.js +2 -1
  35. package/es/backend/sqlite/route-operation/post-operation.d.ts +6 -26
  36. package/es/backend/sqlite/route-operation/post-operation.js +13 -189
  37. package/es/backend/sqlite/route-operation/put-operation.d.ts +6 -25
  38. package/es/backend/sqlite/route-operation/put-operation.js +10 -155
  39. package/lib/__shims__/next-rest-framework.d.ts +2 -0
  40. package/lib/backend/route-operation/delete-operation.d.ts +7 -24
  41. package/lib/backend/route-operation/delete-operation.js +6 -56
  42. package/lib/backend/route-operation/get-list-operation.d.ts +5 -31
  43. package/lib/backend/route-operation/get-list-operation.js +7 -72
  44. package/lib/backend/route-operation/get-operation.d.ts +5 -25
  45. package/lib/backend/route-operation/get-operation.js +7 -71
  46. package/lib/backend/route-operation/index.d.ts +1 -0
  47. package/lib/backend/route-operation/index.js +3 -1
  48. package/lib/backend/route-operation/open-api-operation.d.ts +6 -0
  49. package/lib/backend/route-operation/open-api-operation.js +37 -0
  50. package/lib/backend/route-operation/operation-common.d.ts +38 -0
  51. package/lib/backend/route-operation/operation-common.js +90 -0
  52. package/lib/backend/route-operation/operation-core.d.ts +3 -0
  53. package/lib/backend/route-operation/operation-core.js +27 -0
  54. package/lib/backend/route-operation/post-operation.d.ts +5 -25
  55. package/lib/backend/route-operation/post-operation.js +7 -71
  56. package/lib/backend/route-operation/put-operation.d.ts +4 -23
  57. package/lib/backend/route-operation/put-operation.js +7 -68
  58. package/lib/backend/route-operation/read-operation-core.d.ts +55 -0
  59. package/lib/backend/route-operation/read-operation-core.js +151 -0
  60. package/lib/backend/route-operation/write-operation-core.d.ts +94 -0
  61. package/lib/backend/route-operation/write-operation-core.js +181 -0
  62. package/lib/backend/sqlite/route-operation/delete-operation.d.ts +9 -26
  63. package/lib/backend/sqlite/route-operation/delete-operation.js +6 -56
  64. package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +6 -32
  65. package/lib/backend/sqlite/route-operation/get-list-operation.js +7 -75
  66. package/lib/backend/sqlite/route-operation/get-operation.d.ts +6 -26
  67. package/lib/backend/sqlite/route-operation/get-operation.js +7 -71
  68. package/lib/backend/sqlite/route-operation/index.d.ts +1 -0
  69. package/lib/backend/sqlite/route-operation/index.js +3 -1
  70. package/lib/backend/sqlite/route-operation/post-operation.d.ts +6 -26
  71. package/lib/backend/sqlite/route-operation/post-operation.js +7 -71
  72. package/lib/backend/sqlite/route-operation/put-operation.d.ts +6 -25
  73. package/lib/backend/sqlite/route-operation/put-operation.js +7 -68
  74. package/package.json +1 -1
@@ -0,0 +1,390 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ import { routeOperation, TypedNextResponse } from "next-rest-framework";
11
+ import { z } from "zod";
12
+ import { createOpenApiOperation } from "./open-api-operation.js";
13
+ import { getDefaultTags, handleOperationError, readPostBody } from "./operation-common.js";
14
+
15
+ // ==============================================================================
16
+ // POST create operation
17
+ // ==============================================================================
18
+
19
+ export function createPostOperationFactory(_ref) {
20
+ var createAction = _ref.createAction,
21
+ getTableName = _ref.getTableName;
22
+ return function (_ref2) {
23
+ var db = _ref2.db,
24
+ getSession = _ref2.getSession;
25
+ return function (_ref3) {
26
+ var schemas = _ref3.schemas,
27
+ _ref3$contentType = _ref3.contentType,
28
+ contentType = _ref3$contentType === void 0 ? "application/json" : _ref3$contentType,
29
+ openApiOperation = _ref3.openApiOperation,
30
+ parseBody = _ref3.parseBody,
31
+ setBody = _ref3.setBody,
32
+ table = _ref3.table,
33
+ handler = _ref3.handler,
34
+ catchHandler = _ref3.catch;
35
+ return routeOperation({
36
+ method: "POST",
37
+ openApiOperation: createOpenApiOperation({
38
+ defaultTags: getDefaultTags({
39
+ getTableName: getTableName,
40
+ table: table
41
+ }),
42
+ openApiOperation: openApiOperation
43
+ })
44
+ }).input({
45
+ body: schemas.body,
46
+ contentType: contentType
47
+ }).outputs([{
48
+ body: schemas.response || z.object({
49
+ id: z.string()
50
+ }),
51
+ contentType: "application/json",
52
+ status: 200
53
+ }]).handler( /*#__PURE__*/function () {
54
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
55
+ var _ref5, userId, body, extraBody, params, raw, data;
56
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
57
+ while (1) switch (_context.prev = _context.next) {
58
+ case 0:
59
+ _context.prev = 0;
60
+ _context.next = 3;
61
+ return getSession(req);
62
+ case 3:
63
+ _context.t0 = _context.sent;
64
+ if (_context.t0) {
65
+ _context.next = 6;
66
+ break;
67
+ }
68
+ _context.t0 = {};
69
+ case 6:
70
+ _ref5 = _context.t0;
71
+ userId = _ref5.userId;
72
+ _context.next = 10;
73
+ return readPostBody(req, {
74
+ contentType: contentType,
75
+ parseBody: parseBody
76
+ });
77
+ case 10:
78
+ body = _context.sent;
79
+ _context.next = 13;
80
+ return setBody === null || setBody === void 0 ? void 0 : setBody(req);
81
+ case 13:
82
+ _context.t1 = _context.sent;
83
+ if (_context.t1) {
84
+ _context.next = 16;
85
+ break;
86
+ }
87
+ _context.t1 = {};
88
+ case 16:
89
+ extraBody = _context.t1;
90
+ params = _objectSpread(_objectSpread({
91
+ creatorId: userId
92
+ }, body), extraBody);
93
+ if (!(table && db)) {
94
+ _context.next = 24;
95
+ break;
96
+ }
97
+ _context.next = 21;
98
+ return createAction({
99
+ bodySchema: schemas.body,
100
+ db: db,
101
+ table: table
102
+ })(params);
103
+ case 21:
104
+ _context.t2 = _context.sent[0];
105
+ _context.next = 25;
106
+ break;
107
+ case 24:
108
+ _context.t2 = params;
109
+ case 25:
110
+ raw = _context.t2;
111
+ if (!handler) {
112
+ _context.next = 32;
113
+ break;
114
+ }
115
+ _context.next = 29;
116
+ return handler({
117
+ data: raw,
118
+ params: params,
119
+ req: req
120
+ });
121
+ case 29:
122
+ _context.t3 = _context.sent;
123
+ _context.next = 33;
124
+ break;
125
+ case 32:
126
+ _context.t3 = raw;
127
+ case 33:
128
+ data = _context.t3;
129
+ return _context.abrupt("return", TypedNextResponse.json(data, {
130
+ status: 200
131
+ }));
132
+ case 37:
133
+ _context.prev = 37;
134
+ _context.t4 = _context["catch"](0);
135
+ return _context.abrupt("return", handleOperationError(_context.t4, catchHandler));
136
+ case 40:
137
+ case "end":
138
+ return _context.stop();
139
+ }
140
+ }, _callee, null, [[0, 37]]);
141
+ }));
142
+ return function (_x) {
143
+ return _ref4.apply(this, arguments);
144
+ };
145
+ }());
146
+ };
147
+ };
148
+ }
149
+
150
+ // ==============================================================================
151
+ // PUT update operation
152
+ // ==============================================================================
153
+
154
+ export function createPutOperationFactory(_ref6) {
155
+ var createAction = _ref6.createAction,
156
+ getTableName = _ref6.getTableName;
157
+ return function (_ref7) {
158
+ var db = _ref7.db,
159
+ getSession = _ref7.getSession;
160
+ return function (_ref8) {
161
+ var schemas = _ref8.schemas,
162
+ access = _ref8.access,
163
+ openApiOperation = _ref8.openApiOperation,
164
+ table = _ref8.table,
165
+ setBody = _ref8.setBody,
166
+ handler = _ref8.handler,
167
+ catchHandler = _ref8.catch;
168
+ return routeOperation({
169
+ method: "PUT",
170
+ openApiOperation: createOpenApiOperation({
171
+ defaultTags: getDefaultTags({
172
+ getTableName: getTableName,
173
+ table: table
174
+ }),
175
+ openApiOperation: openApiOperation
176
+ })
177
+ }).input({
178
+ body: schemas.body,
179
+ contentType: "application/json"
180
+ }).outputs([{
181
+ body: schemas.response || z.void(),
182
+ contentType: "application/json",
183
+ status: 200
184
+ }]).handler( /*#__PURE__*/function () {
185
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req) {
186
+ var _access$byCreator, _ref10, userId, body, extraBody, params, raw, data;
187
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
188
+ while (1) switch (_context2.prev = _context2.next) {
189
+ case 0:
190
+ _context2.prev = 0;
191
+ _context2.next = 3;
192
+ return getSession(req);
193
+ case 3:
194
+ _context2.t0 = _context2.sent;
195
+ if (_context2.t0) {
196
+ _context2.next = 6;
197
+ break;
198
+ }
199
+ _context2.t0 = {};
200
+ case 6:
201
+ _ref10 = _context2.t0;
202
+ userId = _ref10.userId;
203
+ _context2.next = 10;
204
+ return req.json();
205
+ case 10:
206
+ body = _context2.sent;
207
+ _context2.next = 13;
208
+ return setBody === null || setBody === void 0 ? void 0 : setBody(req);
209
+ case 13:
210
+ _context2.t1 = _context2.sent;
211
+ if (_context2.t1) {
212
+ _context2.next = 16;
213
+ break;
214
+ }
215
+ _context2.t1 = {};
216
+ case 16:
217
+ extraBody = _context2.t1;
218
+ params = _objectSpread(_objectSpread({
219
+ editorId: userId
220
+ }, body), extraBody);
221
+ if (!(table && db)) {
222
+ _context2.next = 24;
223
+ break;
224
+ }
225
+ _context2.next = 21;
226
+ return createAction({
227
+ bodySchema: schemas.body,
228
+ db: db,
229
+ table: table
230
+ })(params, {
231
+ byCreator: (_access$byCreator = access === null || access === void 0 ? void 0 : access.byCreator) !== null && _access$byCreator !== void 0 ? _access$byCreator : true
232
+ });
233
+ case 21:
234
+ _context2.t2 = _context2.sent;
235
+ _context2.next = 25;
236
+ break;
237
+ case 24:
238
+ _context2.t2 = params;
239
+ case 25:
240
+ raw = _context2.t2;
241
+ if (!handler) {
242
+ _context2.next = 32;
243
+ break;
244
+ }
245
+ _context2.next = 29;
246
+ return handler({
247
+ data: raw,
248
+ params: params,
249
+ req: req
250
+ });
251
+ case 29:
252
+ _context2.t3 = _context2.sent;
253
+ _context2.next = 33;
254
+ break;
255
+ case 32:
256
+ _context2.t3 = raw;
257
+ case 33:
258
+ data = _context2.t3;
259
+ return _context2.abrupt("return", TypedNextResponse.json(data, {
260
+ status: 200
261
+ }));
262
+ case 37:
263
+ _context2.prev = 37;
264
+ _context2.t4 = _context2["catch"](0);
265
+ return _context2.abrupt("return", handleOperationError(_context2.t4, catchHandler));
266
+ case 40:
267
+ case "end":
268
+ return _context2.stop();
269
+ }
270
+ }, _callee2, null, [[0, 37]]);
271
+ }));
272
+ return function (_x2) {
273
+ return _ref9.apply(this, arguments);
274
+ };
275
+ }());
276
+ };
277
+ };
278
+ }
279
+
280
+ // ==============================================================================
281
+ // DELETE operation
282
+ // ==============================================================================
283
+
284
+ var defaultDeleteBodySchema = z.object({
285
+ id: z.string()
286
+ });
287
+ export function createDeleteOperationFactory(_ref11) {
288
+ var createAction = _ref11.createAction,
289
+ getTableName = _ref11.getTableName;
290
+ return function (_ref12) {
291
+ var db = _ref12.db,
292
+ getSession = _ref12.getSession;
293
+ return function (_ref13) {
294
+ var table = _ref13.table,
295
+ schemas = _ref13.schemas,
296
+ access = _ref13.access,
297
+ openApiOperation = _ref13.openApiOperation,
298
+ handler = _ref13.handler,
299
+ catchHandler = _ref13.catch;
300
+ return routeOperation({
301
+ method: "DELETE",
302
+ openApiOperation: createOpenApiOperation({
303
+ defaultTags: getDefaultTags({
304
+ getTableName: getTableName,
305
+ table: table
306
+ }),
307
+ openApiOperation: openApiOperation
308
+ })
309
+ }).input({
310
+ body: (schemas === null || schemas === void 0 ? void 0 : schemas.body) || defaultDeleteBodySchema,
311
+ contentType: "application/json"
312
+ }).handler( /*#__PURE__*/function () {
313
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(req) {
314
+ var _access$byCreator2, bodySchema, body, _ref15, userId, data;
315
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
316
+ while (1) switch (_context3.prev = _context3.next) {
317
+ case 0:
318
+ _context3.prev = 0;
319
+ bodySchema = (schemas === null || schemas === void 0 ? void 0 : schemas.body) || defaultDeleteBodySchema;
320
+ _context3.t0 = bodySchema;
321
+ _context3.next = 5;
322
+ return req.json();
323
+ case 5:
324
+ _context3.t1 = _context3.sent;
325
+ body = _context3.t0.parse.call(_context3.t0, _context3.t1);
326
+ if (!((_access$byCreator2 = access === null || access === void 0 ? void 0 : access.byCreator) !== null && _access$byCreator2 !== void 0 ? _access$byCreator2 : true)) {
327
+ _context3.next = 16;
328
+ break;
329
+ }
330
+ _context3.next = 10;
331
+ return getSession(req);
332
+ case 10:
333
+ _context3.t2 = _context3.sent;
334
+ if (_context3.t2) {
335
+ _context3.next = 13;
336
+ break;
337
+ }
338
+ _context3.t2 = {};
339
+ case 13:
340
+ _ref15 = _context3.t2;
341
+ userId = _ref15.userId;
342
+ body.creatorId = userId;
343
+ case 16:
344
+ if (!(table && db)) {
345
+ _context3.next = 22;
346
+ break;
347
+ }
348
+ _context3.next = 19;
349
+ return createAction({
350
+ db: db,
351
+ table: table
352
+ })({
353
+ creatorId: body.creatorId,
354
+ id: body.id
355
+ });
356
+ case 19:
357
+ _context3.t3 = _context3.sent;
358
+ _context3.next = 23;
359
+ break;
360
+ case 22:
361
+ _context3.t3 = body;
362
+ case 23:
363
+ data = _context3.t3;
364
+ _context3.next = 26;
365
+ return handler === null || handler === void 0 ? void 0 : handler({
366
+ data: data,
367
+ params: body,
368
+ req: req
369
+ });
370
+ case 26:
371
+ return _context3.abrupt("return", TypedNextResponse.json(data, {
372
+ status: 200
373
+ }));
374
+ case 29:
375
+ _context3.prev = 29;
376
+ _context3.t4 = _context3["catch"](0);
377
+ return _context3.abrupt("return", handleOperationError(_context3.t4, catchHandler));
378
+ case 32:
379
+ case "end":
380
+ return _context3.stop();
381
+ }
382
+ }, _callee3, null, [[0, 29]]);
383
+ }));
384
+ return function (_x3) {
385
+ return _ref14.apply(this, arguments);
386
+ };
387
+ }());
388
+ };
389
+ };
390
+ }
@@ -1,30 +1,13 @@
1
- import { TypedNextResponse } from "next-rest-framework";
2
- import { z } from "zod";
3
- import { BaseTable } from "../types.js";
4
1
  import { NextRequest } from "next/server";
5
- type DeleteOperationParams<B extends z.ZodSchema> = z.infer<B> & Record<string, unknown> & {
6
- creatorId?: string;
7
- id: string;
8
- };
9
- export interface DeleteOperationOptions<TTable extends BaseTable, B extends z.ZodSchema> {
10
- table?: TTable;
11
- bodySchema?: B;
12
- description?: string;
13
- summary?: string;
14
- tags?: string[];
15
- onSuccess?: (_payload: {
16
- params: DeleteOperationParams<B>;
17
- data: unknown;
18
- }) => Promise<void>;
19
- onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
20
- byCreator?: boolean;
21
- }
2
+ import { ZodSchema } from "zod";
3
+ import { BaseTable } from "../types.js";
4
+ import { type DeleteOperationOptions as CoreDeleteOperationOptions } from "../../route-operation/operation-core.js";
5
+ export type DeleteOperationOptions<TTable extends BaseTable, B extends ZodSchema> = CoreDeleteOperationOptions<TTable, B>;
22
6
  export declare const createDeleteOperation: ({ db, getSession, }: {
23
- db?: any;
24
- getSession: (_req: NextRequest) => Promise<{
7
+ db?: unknown;
8
+ getSession(req: NextRequest): Promise<{
25
9
  userId?: string;
26
10
  } | undefined>;
27
- }) => <TTable extends BaseTable, B extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> = z.ZodObject<{
28
- id: z.ZodString;
29
- }, z.core.$strip>>({ table, bodySchema, description, summary, tags, onSuccess, onError, byCreator, }: DeleteOperationOptions<TTable, B>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
30
- export {};
11
+ }) => <B extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>> = import("zod").ZodObject<{
12
+ id: import("zod").ZodString;
13
+ }, import("zod/v4/core").$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: CoreDeleteOperationOptions<BaseTable, B>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
@@ -1,133 +1,15 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- import { routeOperation, TypedNextResponse } from "next-rest-framework";
6
- import { z } from "zod";
1
+ import { createDeleteAction } from "../actions/create-delete-action.js";
2
+ import { createDeleteOperationFactory } from "../../route-operation/operation-core.js";
7
3
  import getTableName from "./get-table-name.js";
8
- import { createDeleteAction } from "../actions/index.js";
9
- import { HttpError } from "../errors.js";
10
- var defaultDeleteBodySchema = z.object({
11
- id: z.string()
4
+ var createOperation = createDeleteOperationFactory({
5
+ createAction: createDeleteAction,
6
+ getTableName: getTableName
12
7
  });
13
8
  export var createDeleteOperation = function createDeleteOperation(_ref) {
14
9
  var db = _ref.db,
15
10
  getSession = _ref.getSession;
16
- return function (_ref2) {
17
- var table = _ref2.table,
18
- _ref2$bodySchema = _ref2.bodySchema,
19
- bodySchema = _ref2$bodySchema === void 0 ? defaultDeleteBodySchema : _ref2$bodySchema,
20
- description = _ref2.description,
21
- summary = _ref2.summary,
22
- tags = _ref2.tags,
23
- onSuccess = _ref2.onSuccess,
24
- onError = _ref2.onError,
25
- _ref2$byCreator = _ref2.byCreator,
26
- byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
27
- return routeOperation({
28
- method: "DELETE",
29
- openApiOperation: {
30
- description: description,
31
- summary: summary,
32
- tags: tags !== null && tags !== void 0 ? tags : table ? [getTableName(table)] : []
33
- }
34
- }).input({
35
- body: bodySchema,
36
- contentType: "application/json"
37
- }).handler( /*#__PURE__*/function () {
38
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
39
- var body, _ref4, userId, tableParams, data, response;
40
- return _regeneratorRuntime().wrap(function _callee$(_context) {
41
- while (1) switch (_context.prev = _context.next) {
42
- case 0:
43
- _context.prev = 0;
44
- _context.t0 = bodySchema;
45
- _context.next = 4;
46
- return req.json();
47
- case 4:
48
- _context.t1 = _context.sent;
49
- body = _context.t0.parse.call(_context.t0, _context.t1);
50
- if (!byCreator) {
51
- _context.next = 15;
52
- break;
53
- }
54
- _context.next = 9;
55
- return getSession(req);
56
- case 9:
57
- _context.t2 = _context.sent;
58
- if (_context.t2) {
59
- _context.next = 12;
60
- break;
61
- }
62
- _context.t2 = {};
63
- case 12:
64
- _ref4 = _context.t2;
65
- userId = _ref4.userId;
66
- body.creatorId = userId;
67
- case 15:
68
- tableParams = body;
69
- if (!(table && db)) {
70
- _context.next = 22;
71
- break;
72
- }
73
- _context.next = 19;
74
- return createDeleteAction({
75
- table: table,
76
- db: db
77
- })(tableParams);
78
- case 19:
79
- _context.t3 = _context.sent;
80
- _context.next = 23;
81
- break;
82
- case 22:
83
- _context.t3 = body;
84
- case 23:
85
- data = _context.t3;
86
- _context.next = 26;
87
- return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
88
- data: data,
89
- params: body
90
- });
91
- case 26:
92
- return _context.abrupt("return", TypedNextResponse.json(data, {
93
- status: 200
94
- }));
95
- case 29:
96
- _context.prev = 29;
97
- _context.t4 = _context["catch"](0);
98
- if (!(_context.t4 instanceof HttpError)) {
99
- console.error(_context.t4);
100
- }
101
- _context.next = 34;
102
- return onError === null || onError === void 0 ? void 0 : onError(_context.t4);
103
- case 34:
104
- response = _context.sent;
105
- if (!response) {
106
- _context.next = 37;
107
- break;
108
- }
109
- return _context.abrupt("return", response);
110
- case 37:
111
- if (!(_context.t4 instanceof HttpError)) {
112
- _context.next = 39;
113
- break;
114
- }
115
- return _context.abrupt("return", TypedNextResponse.json({
116
- message: _context.t4.message
117
- }, {
118
- status: _context.t4.status
119
- }));
120
- case 39:
121
- throw _context.t4;
122
- case 40:
123
- case "end":
124
- return _context.stop();
125
- }
126
- }, _callee, null, [[0, 29]]);
127
- }));
128
- return function (_x) {
129
- return _ref3.apply(this, arguments);
130
- };
131
- }());
132
- };
11
+ return createOperation({
12
+ db: db,
13
+ getSession: getSession
14
+ });
133
15
  };
@@ -1,37 +1,11 @@
1
- import { z, ZodSchema } from "zod";
2
1
  import { NextRequest } from "next/server";
3
- import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
2
+ import { ZodSchema } from "zod";
4
3
  import { BaseTable, GetListRelations } from "../types.js";
5
- type GetListOperationParams<Q extends ZodSchema> = z.infer<Q> & Record<string, unknown> & {
6
- creatorId?: string;
7
- };
8
- export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
9
- bodySchema: T;
10
- jsonArrayFields?: string[];
11
- querySchema: Q;
12
- relations?: GetListRelations;
13
- setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
14
- byCreator?: boolean;
15
- description?: string;
16
- summary?: string;
17
- tags?: string[];
18
- table?: TTable;
19
- onSuccess?: <D extends T>(_payload: {
20
- params: GetListOperationParams<Q>;
21
- data: {
22
- data: z.infer<D>[];
23
- total: number;
24
- };
25
- }) => Promise<{
26
- data: z.infer<T>[];
27
- total: number;
28
- }>;
29
- onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
30
- }
4
+ import { type GetListOperationOptions as CoreGetListOperationOptions } from "../../route-operation/operation-core.js";
5
+ export type GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> = CoreGetListOperationOptions<T, Q, TTable, GetListRelations>;
31
6
  export declare const createGetListOperation: ({ db, getSession, }: {
32
- db?: any;
33
- getSession: (_req: NextRequest) => Promise<{
7
+ db?: unknown;
8
+ getSession(req: NextRequest): Promise<{
34
9
  userId?: string;
35
10
  } | undefined>;
36
- }) => <T extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, Q extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, TTable extends BaseTable>({ querySchema, bodySchema, table, description, summary, tags, relations, jsonArrayFields, setParams, onSuccess, onError, byCreator, }: GetListOperationOptions<T, Q, TTable>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
37
- export {};
11
+ }) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, jsonArrayFields, setParams, handler, catch: catchHandler, }: CoreGetListOperationOptions<T, Q, BaseTable, GetListRelations>) => import("next-rest-framework").RouteOperationDefinition<"GET">;