@ai0x0/utils 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/es/backend/actions/create-delete-action.d.ts +1 -1
- package/es/backend/actions/create-delete-action.js +2 -2
- package/es/backend/actions/create-get-action.d.ts +1 -1
- package/es/backend/actions/create-get-action.js +2 -2
- package/es/backend/actions/create-get-list-action.d.ts +1 -1
- package/es/backend/actions/create-get-list-action.js +2 -2
- package/es/backend/actions/create-post-action.js +1 -1
- package/es/backend/actions/create-put-action.d.ts +1 -1
- package/es/backend/actions/create-put-action.js +3 -3
- package/es/backend/actions/get-list-data.d.ts +1 -1
- package/es/backend/actions/get-list-data.js +1 -1
- package/es/backend/actions/get-list-query.d.ts +1 -1
- package/es/backend/actions/get-list-query.js +6 -6
- package/es/backend/actions/index.d.ts +6 -6
- package/es/backend/actions/index.js +6 -6
- package/es/backend/index.d.ts +4 -4
- package/es/backend/index.js +4 -4
- package/es/backend/route-operation/delete-operation.d.ts +1 -1
- package/es/backend/route-operation/delete-operation.js +3 -3
- package/es/backend/route-operation/get-list-operation.d.ts +1 -1
- package/es/backend/route-operation/get-list-operation.js +3 -3
- package/es/backend/route-operation/get-operation.d.ts +1 -1
- package/es/backend/route-operation/get-operation.js +2 -2
- package/es/backend/route-operation/index.d.ts +5 -5
- package/es/backend/route-operation/index.js +5 -5
- package/es/backend/route-operation/post-operation.js +2 -2
- package/es/backend/route-operation/put-operation.d.ts +1 -1
- package/es/backend/route-operation/put-operation.js +3 -3
- package/lib/backend/actions/create-delete-action.d.ts +1 -1
- package/lib/backend/actions/create-get-action.d.ts +1 -1
- package/lib/backend/actions/create-get-list-action.d.ts +1 -1
- package/lib/backend/actions/create-put-action.d.ts +1 -1
- package/lib/backend/actions/get-list-data.d.ts +1 -1
- package/lib/backend/actions/get-list-query.d.ts +1 -1
- package/lib/backend/actions/get-list-query.js +3 -3
- package/lib/backend/actions/index.d.ts +6 -6
- package/lib/backend/index.d.ts +4 -4
- package/lib/backend/route-operation/delete-operation.d.ts +1 -1
- package/lib/backend/route-operation/get-list-operation.d.ts +1 -1
- package/lib/backend/route-operation/get-operation.d.ts +1 -1
- package/lib/backend/route-operation/index.d.ts +5 -5
- package/lib/backend/route-operation/put-operation.d.ts +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @ai0x0/utils
|
|
2
|
+
|
|
3
|
+
AI0x0 shared utilities — backend CRUD factories for Next.js App Router + drizzle-orm, and custom ESLint rules.
|
|
4
|
+
|
|
5
|
+
## Backend (`src/backend/`)
|
|
6
|
+
|
|
7
|
+
Declarative CRUD factories on top of `next-rest-framework`, `drizzle-orm/pg-core`, `drizzle-zod`, and `zod`. Each factory returns a `RouteOperationDefinition` that plugs directly into `route({ … })`.
|
|
8
|
+
|
|
9
|
+
| Export | HTTP | Description |
|
|
10
|
+
| ------------------------ | ------ | ---------------------------------------- |
|
|
11
|
+
| `createPostOperation` | POST | Create a record |
|
|
12
|
+
| `createGetOperation` | GET | Get one record by filters |
|
|
13
|
+
| `createGetListOperation` | GET | Paginated list with filters, sort, joins |
|
|
14
|
+
| `createPutOperation` | PUT | Update a record |
|
|
15
|
+
| `createDeleteOperation` | DELETE | Delete a record |
|
|
16
|
+
| `createTableSchema` | — | Generate pg table + 5 Zod schemas |
|
|
17
|
+
|
|
18
|
+
**Built-in conventions:** base fields (`id`, `creatorId`, `editorId`, `createdAt`, `updatedAt`, `accessedAt`), ownership checks via `byCreator`, automatic date coercion, pagination (`current`/`pageSize`/`orderBy`/`orderDir`), list filtering with `ILIKE`, `IN`, `jsonb` array matching, and relation joins.
|
|
19
|
+
|
|
20
|
+
See [SKILL.md](./SKILL.md) for detailed workflow, setup, and escape hatches.
|
|
21
|
+
|
|
22
|
+
## ESLint Rules (`eslint-rules/`)
|
|
23
|
+
|
|
24
|
+
Custom ESLint 9 flat-config rules ported from production projects. All enabled via `configs.recommended`:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
// eslint.config.js
|
|
28
|
+
import localPlugin from "./eslint-rules/index.js";
|
|
29
|
+
|
|
30
|
+
export default [
|
|
31
|
+
localPlugin.configs.recommended,
|
|
32
|
+
// ... other config
|
|
33
|
+
];
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Rule | Description |
|
|
37
|
+
| ------------------------- | --------------------------------------- |
|
|
38
|
+
| `no-hardcoded-style` | Forbid hardcoded style values |
|
|
39
|
+
| `no-one-letter-vars` | Forbid single-letter variable names |
|
|
40
|
+
| `no-then` | Prefer `async/await` over `.then()` |
|
|
41
|
+
| `no-antd-space` | Use `<Flex>` instead of `<Space>` |
|
|
42
|
+
| `require-pro-components` | Require ProComponents usage |
|
|
43
|
+
| `require-section-divider` | Large files need `===` comment dividers |
|
|
44
|
+
| `no-consecutive-setstate` | Merge consecutive `setState` calls |
|
|
45
|
+
| `no-use-request-run` | Forbid `useRequest.run()` |
|
|
46
|
+
| `require-use-form` | Use `useForm()` for form state |
|
|
47
|
+
| `require-form-convention` | Form naming conventions |
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm add @ai0x0/utils
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Peer dependencies: `drizzle-orm ^0.45.x`, `drizzle-zod ^0.8.x`, `zod ^4.x`.
|
|
56
|
+
|
|
57
|
+
## Docs
|
|
58
|
+
|
|
59
|
+
- [SKILL.md](./SKILL.md) — full backend CRUD workflow and API reference
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
-
import { BaseTable } from "../types";
|
|
2
|
+
import { BaseTable } from "../types.js";
|
|
3
3
|
export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
|
|
4
4
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
5
5
|
table: TTable;
|
|
@@ -3,9 +3,9 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
3
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
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
5
|
import { eq } from "drizzle-orm";
|
|
6
|
-
import { createGetAction } from "
|
|
6
|
+
import { createGetAction } from "./../index.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { HttpError } from "../errors";
|
|
8
|
+
import { HttpError } from "../errors.js";
|
|
9
9
|
export function createDeleteAction(_ref) {
|
|
10
10
|
var table = _ref.table,
|
|
11
11
|
db = _ref.db;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
3
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
4
4
|
export declare function createGetAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
6
6
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
@@ -8,8 +8,8 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
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); } }
|
|
10
10
|
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); }); }; }
|
|
11
|
-
import { getListQuery } from "./get-list-query";
|
|
12
|
-
import { getListData } from "./get-list-data";
|
|
11
|
+
import { getListQuery } from "./get-list-query.js";
|
|
12
|
+
import { getListData } from "./get-list-data.js";
|
|
13
13
|
export function createGetAction(_ref) {
|
|
14
14
|
var bodySchema = _ref.bodySchema,
|
|
15
15
|
db = _ref.db,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
3
3
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
4
|
export declare function createGetListAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
@@ -5,8 +5,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
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); } }
|
|
7
7
|
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); }); }; }
|
|
8
|
-
import { getListQuery } from "./get-list-query";
|
|
9
|
-
import { getListData } from "./get-list-data";
|
|
8
|
+
import { getListQuery } from "./get-list-query.js";
|
|
9
|
+
import { getListData } from "./get-list-data.js";
|
|
10
10
|
export function createGetListAction(_ref) {
|
|
11
11
|
var bodySchema = _ref.bodySchema,
|
|
12
12
|
db = _ref.db,
|
|
@@ -2,7 +2,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
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
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
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 { transformBody } from "./transform-body";
|
|
5
|
+
import { transformBody } from "./transform-body.js";
|
|
6
6
|
export function createPostAction(_ref) {
|
|
7
7
|
var table = _ref.table,
|
|
8
8
|
db = _ref.db;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { BaseTable } from "../types";
|
|
3
|
+
import { BaseTable } from "../types.js";
|
|
4
4
|
export declare function createPutAction<T extends ZodSchema, TTable extends BaseTable>({ db, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
6
6
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
@@ -9,10 +9,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
9
9
|
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); } }
|
|
10
10
|
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); }); }; }
|
|
11
11
|
import { z } from "zod";
|
|
12
|
-
import { transformBody } from "./transform-body";
|
|
12
|
+
import { transformBody } from "./transform-body.js";
|
|
13
13
|
import { eq } from "drizzle-orm";
|
|
14
|
-
import { createGetAction } from "
|
|
15
|
-
import { HttpError } from "../errors";
|
|
14
|
+
import { createGetAction } from "./../index.js";
|
|
15
|
+
import { HttpError } from "../errors.js";
|
|
16
16
|
export function createPutAction(_ref) {
|
|
17
17
|
var db = _ref.db,
|
|
18
18
|
table = _ref.table;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZodSchema } from "zod";
|
|
2
|
-
import { getListQuery } from "./get-list-query";
|
|
2
|
+
import { getListQuery } from "./get-list-query.js";
|
|
3
3
|
export declare function getListData<B extends ZodSchema>({ query, countQuery, pageSize, current, bodySchema, }: {
|
|
4
4
|
bodySchema: B;
|
|
5
5
|
current?: number;
|
|
@@ -9,7 +9,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
9
9
|
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); } }
|
|
10
10
|
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); }); }; }
|
|
11
11
|
import { rpcOperation } from "next-rest-framework";
|
|
12
|
-
import { listBodySchema } from "../schemas";
|
|
12
|
+
import { listBodySchema } from "../schemas/index.js";
|
|
13
13
|
export function getListData(_ref) {
|
|
14
14
|
var query = _ref.query,
|
|
15
15
|
countQuery = _ref.countQuery,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
1
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
2
2
|
import { SelectedFields } from "drizzle-orm/pg-core/query-builders/select.types";
|
|
3
3
|
import { SQL } from "drizzle-orm";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
@@ -84,8 +84,8 @@ export function getListQuery(_ref) {
|
|
|
84
84
|
}).map(function (_ref6) {
|
|
85
85
|
var table = _ref6.table;
|
|
86
86
|
return table;
|
|
87
|
-
})) || []).find(function (
|
|
88
|
-
return
|
|
87
|
+
})) || []).find(function (table) {
|
|
88
|
+
return table[key];
|
|
89
89
|
})) === null || _concat$find === void 0 ? void 0 : _concat$find[key];
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -96,8 +96,8 @@ export function getListQuery(_ref) {
|
|
|
96
96
|
if (typeof value === "string") {
|
|
97
97
|
if (value.includes(",")) {
|
|
98
98
|
// 处理多值
|
|
99
|
-
var values = value.split(",").map(function (
|
|
100
|
-
return
|
|
99
|
+
var values = value.split(",").map(function (val) {
|
|
100
|
+
return val.trim();
|
|
101
101
|
}).filter(Boolean);
|
|
102
102
|
if (values.length > 0) {
|
|
103
103
|
if (isJsonArray) {
|
|
@@ -106,8 +106,8 @@ export function getListQuery(_ref) {
|
|
|
106
106
|
} else if (isIdField) {
|
|
107
107
|
conditions.push(inArray(targetColumn, values));
|
|
108
108
|
} else {
|
|
109
|
-
conditions.push(or.apply(void 0, _toConsumableArray(values.map(function (
|
|
110
|
-
return ilike(targetColumn, "%".concat(
|
|
109
|
+
conditions.push(or.apply(void 0, _toConsumableArray(values.map(function (val) {
|
|
110
|
+
return ilike(targetColumn, "%".concat(val, "%"));
|
|
111
111
|
}))));
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createDeleteAction } from "./create-delete-action";
|
|
2
|
-
export { createGetAction } from "./create-get-action";
|
|
3
|
-
export { createGetListAction } from "./create-get-list-action";
|
|
4
|
-
export { createPostAction } from "./create-post-action";
|
|
5
|
-
export { createPutAction } from "./create-put-action";
|
|
6
|
-
export { getListQuery } from "./get-list-query";
|
|
1
|
+
export { createDeleteAction } from "./create-delete-action.js";
|
|
2
|
+
export { createGetAction } from "./create-get-action.js";
|
|
3
|
+
export { createGetListAction } from "./create-get-list-action.js";
|
|
4
|
+
export { createPostAction } from "./create-post-action.js";
|
|
5
|
+
export { createPutAction } from "./create-put-action.js";
|
|
6
|
+
export { getListQuery } from "./get-list-query.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createDeleteAction } from "./create-delete-action";
|
|
2
|
-
export { createGetAction } from "./create-get-action";
|
|
3
|
-
export { createGetListAction } from "./create-get-list-action";
|
|
4
|
-
export { createPostAction } from "./create-post-action";
|
|
5
|
-
export { createPutAction } from "./create-put-action";
|
|
6
|
-
export { getListQuery } from "./get-list-query";
|
|
1
|
+
export { createDeleteAction } from "./create-delete-action.js";
|
|
2
|
+
export { createGetAction } from "./create-get-action.js";
|
|
3
|
+
export { createGetListAction } from "./create-get-list-action.js";
|
|
4
|
+
export { createPostAction } from "./create-post-action.js";
|
|
5
|
+
export { createPutAction } from "./create-put-action.js";
|
|
6
|
+
export { getListQuery } from "./get-list-query.js";
|
package/es/backend/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./actions";
|
|
2
|
-
export * from "./route-operation";
|
|
3
|
-
export * from "./schemas";
|
|
4
|
-
export * from "./errors";
|
|
1
|
+
export * from "./actions/index.js";
|
|
2
|
+
export * from "./route-operation/index.js";
|
|
3
|
+
export * from "./schemas/index.js";
|
|
4
|
+
export * from "./errors.js";
|
package/es/backend/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./actions";
|
|
2
|
-
export * from "./route-operation";
|
|
3
|
-
export * from "./schemas";
|
|
4
|
-
export * from "./errors";
|
|
1
|
+
export * from "./actions/index.js";
|
|
2
|
+
export * from "./route-operation/index.js";
|
|
3
|
+
export * from "./schemas/index.js";
|
|
4
|
+
export * from "./errors.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedNextResponse } from "next-rest-framework";
|
|
2
|
-
import { BaseTable } from "../types";
|
|
2
|
+
import { BaseTable } from "../types.js";
|
|
3
3
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
4
|
import { NextRequest } from "next/server";
|
|
5
5
|
export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
@@ -4,9 +4,9 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
4
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
5
|
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import getTableName from "./get-table-name";
|
|
8
|
-
import { createDeleteAction } from "../actions";
|
|
9
|
-
import { HttpError } from "../errors";
|
|
7
|
+
import getTableName from "./get-table-name.js";
|
|
8
|
+
import { createDeleteAction } from "../actions/index.js";
|
|
9
|
+
import { HttpError } from "../errors.js";
|
|
10
10
|
export var createDeleteOperation = function createDeleteOperation(_ref) {
|
|
11
11
|
var db = _ref.db,
|
|
12
12
|
getSession = _ref.getSession;
|
|
@@ -2,7 +2,7 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
6
6
|
export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
7
|
bodySchema: T;
|
|
8
8
|
jsonArrayFields?: string[];
|
|
@@ -3,9 +3,9 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
3
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
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
5
|
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
6
|
-
import getTableName from "./get-table-name";
|
|
7
|
-
import { listBodySchema } from "../schemas";
|
|
8
|
-
import { createGetListAction } from "../actions";
|
|
6
|
+
import getTableName from "./get-table-name.js";
|
|
7
|
+
import { listBodySchema } from "../schemas/index.js";
|
|
8
|
+
import { createGetListAction } from "../actions/index.js";
|
|
9
9
|
export var createGetListOperation = function createGetListOperation(_ref) {
|
|
10
10
|
var db = _ref.db,
|
|
11
11
|
getSession = _ref.getSession;
|
|
@@ -2,7 +2,7 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
6
6
|
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
7
|
bodySchema: T;
|
|
8
8
|
jsonArrayFields?: string[];
|
|
@@ -3,8 +3,8 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
3
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
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
5
|
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
6
|
-
import getTableName from "./get-table-name";
|
|
7
|
-
import { createGetAction } from "../actions";
|
|
6
|
+
import getTableName from "./get-table-name.js";
|
|
7
|
+
import { createGetAction } from "../actions/index.js";
|
|
8
8
|
export var createGetOperation = function createGetOperation(_ref) {
|
|
9
9
|
var getSession = _ref.getSession,
|
|
10
10
|
db = _ref.db;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./get-operation";
|
|
2
|
-
export * from "./get-list-operation";
|
|
3
|
-
export * from "./delete-operation";
|
|
4
|
-
export * from "./post-operation";
|
|
5
|
-
export * from "./put-operation";
|
|
1
|
+
export * from "./get-operation.js";
|
|
2
|
+
export * from "./get-list-operation.js";
|
|
3
|
+
export * from "./delete-operation.js";
|
|
4
|
+
export * from "./post-operation.js";
|
|
5
|
+
export * from "./put-operation.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./get-operation";
|
|
2
|
-
export * from "./get-list-operation";
|
|
3
|
-
export * from "./delete-operation";
|
|
4
|
-
export * from "./post-operation";
|
|
5
|
-
export * from "./put-operation";
|
|
1
|
+
export * from "./get-operation.js";
|
|
2
|
+
export * from "./get-list-operation.js";
|
|
3
|
+
export * from "./delete-operation.js";
|
|
4
|
+
export * from "./post-operation.js";
|
|
5
|
+
export * from "./put-operation.js";
|
|
@@ -15,8 +15,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
15
15
|
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); }); }; }
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
18
|
-
import getTableName from "./get-table-name";
|
|
19
|
-
import { createPostAction } from "../actions";
|
|
18
|
+
import getTableName from "./get-table-name.js";
|
|
19
|
+
import { createPostAction } from "../actions/index.js";
|
|
20
20
|
export var createPostOperation = function createPostOperation(_ref) {
|
|
21
21
|
var getSession = _ref.getSession,
|
|
22
22
|
db = _ref.db;
|
|
@@ -3,7 +3,7 @@ import { PgTable } from "drizzle-orm/pg-core";
|
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
5
|
import { NextRequest } from "next/server";
|
|
6
|
-
import { BaseTable } from "../types";
|
|
6
|
+
import { BaseTable } from "../types.js";
|
|
7
7
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
8
8
|
bodySchema: IB;
|
|
9
9
|
outputBodySchema?: OB;
|
|
@@ -9,9 +9,9 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
9
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
10
|
import { z } from "zod";
|
|
11
11
|
import { routeOperation, TypedNextResponse } from "next-rest-framework";
|
|
12
|
-
import getTableName from "./get-table-name";
|
|
13
|
-
import { createPutAction } from "../actions";
|
|
14
|
-
import { HttpError } from "../errors";
|
|
12
|
+
import getTableName from "./get-table-name.js";
|
|
13
|
+
import { createPutAction } from "../actions/index.js";
|
|
14
|
+
import { HttpError } from "../errors.js";
|
|
15
15
|
export var createPutOperation = function createPutOperation(_ref) {
|
|
16
16
|
var getSession = _ref.getSession,
|
|
17
17
|
db = _ref.db;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
-
import { BaseTable } from "../types";
|
|
2
|
+
import { BaseTable } from "../types.js";
|
|
3
3
|
export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
|
|
4
4
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
5
5
|
table: TTable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
3
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
4
4
|
export declare function createGetAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
6
6
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
3
3
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
4
|
export declare function createGetListAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { BaseTable } from "../types";
|
|
3
|
+
import { BaseTable } from "../types.js";
|
|
4
4
|
export declare function createPutAction<T extends ZodSchema, TTable extends BaseTable>({ db, table, }: {
|
|
5
5
|
bodySchema: T;
|
|
6
6
|
db: NodePgDatabase<Record<string, unknown>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ZodSchema } from "zod";
|
|
2
|
-
import { getListQuery } from "./get-list-query";
|
|
2
|
+
import { getListQuery } from "./get-list-query.js";
|
|
3
3
|
export declare function getListData<B extends ZodSchema>({ query, countQuery, pageSize, current, bodySchema, }: {
|
|
4
4
|
bodySchema: B;
|
|
5
5
|
current?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
1
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
2
2
|
import { SelectedFields } from "drizzle-orm/pg-core/query-builders/select.types";
|
|
3
3
|
import { SQL } from "drizzle-orm";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
@@ -58,14 +58,14 @@ function getListQuery({
|
|
|
58
58
|
var _a;
|
|
59
59
|
return (_a = [table2].concat(
|
|
60
60
|
(relations2 == null ? void 0 : relations2.filter(({ table: table3 }) => table3).map(({ table: table3 }) => table3)) || []
|
|
61
|
-
).find((
|
|
61
|
+
).find((table3) => table3[key])) == null ? void 0 : _a[key];
|
|
62
62
|
}
|
|
63
63
|
function addCondition(conditions2, key, value, targetColumn) {
|
|
64
64
|
const isIdField = /id/i.test(key);
|
|
65
65
|
const isJsonArray = jsonArrayFields == null ? void 0 : jsonArrayFields.includes(key);
|
|
66
66
|
if (typeof value === "string") {
|
|
67
67
|
if (value.includes(",")) {
|
|
68
|
-
const values = value.split(",").map((
|
|
68
|
+
const values = value.split(",").map((val) => val.trim()).filter(Boolean);
|
|
69
69
|
if (values.length > 0) {
|
|
70
70
|
if (isJsonArray) {
|
|
71
71
|
conditions2.push(
|
|
@@ -81,7 +81,7 @@ function getListQuery({
|
|
|
81
81
|
} else {
|
|
82
82
|
conditions2.push(
|
|
83
83
|
(0, import_drizzle_orm.or)(
|
|
84
|
-
...values.map((
|
|
84
|
+
...values.map((val) => (0, import_drizzle_orm.ilike)(targetColumn, `%${val}%`))
|
|
85
85
|
)
|
|
86
86
|
);
|
|
87
87
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createDeleteAction } from "./create-delete-action";
|
|
2
|
-
export { createGetAction } from "./create-get-action";
|
|
3
|
-
export { createGetListAction } from "./create-get-list-action";
|
|
4
|
-
export { createPostAction } from "./create-post-action";
|
|
5
|
-
export { createPutAction } from "./create-put-action";
|
|
6
|
-
export { getListQuery } from "./get-list-query";
|
|
1
|
+
export { createDeleteAction } from "./create-delete-action.js";
|
|
2
|
+
export { createGetAction } from "./create-get-action.js";
|
|
3
|
+
export { createGetListAction } from "./create-get-list-action.js";
|
|
4
|
+
export { createPostAction } from "./create-post-action.js";
|
|
5
|
+
export { createPutAction } from "./create-put-action.js";
|
|
6
|
+
export { getListQuery } from "./get-list-query.js";
|
package/lib/backend/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./actions";
|
|
2
|
-
export * from "./route-operation";
|
|
3
|
-
export * from "./schemas";
|
|
4
|
-
export * from "./errors";
|
|
1
|
+
export * from "./actions/index.js";
|
|
2
|
+
export * from "./route-operation/index.js";
|
|
3
|
+
export * from "./schemas/index.js";
|
|
4
|
+
export * from "./errors.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TypedNextResponse } from "next-rest-framework";
|
|
2
|
-
import { BaseTable } from "../types";
|
|
2
|
+
import { BaseTable } from "../types.js";
|
|
3
3
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
4
|
import { NextRequest } from "next/server";
|
|
5
5
|
export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
@@ -2,7 +2,7 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
6
6
|
export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
7
|
bodySchema: T;
|
|
8
8
|
jsonArrayFields?: string[];
|
|
@@ -2,7 +2,7 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types.js";
|
|
6
6
|
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
7
|
bodySchema: T;
|
|
8
8
|
jsonArrayFields?: string[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./get-operation";
|
|
2
|
-
export * from "./get-list-operation";
|
|
3
|
-
export * from "./delete-operation";
|
|
4
|
-
export * from "./post-operation";
|
|
5
|
-
export * from "./put-operation";
|
|
1
|
+
export * from "./get-operation.js";
|
|
2
|
+
export * from "./get-list-operation.js";
|
|
3
|
+
export * from "./delete-operation.js";
|
|
4
|
+
export * from "./post-operation.js";
|
|
5
|
+
export * from "./put-operation.js";
|
|
@@ -3,7 +3,7 @@ import { PgTable } from "drizzle-orm/pg-core";
|
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
5
|
import { NextRequest } from "next/server";
|
|
6
|
-
import { BaseTable } from "../types";
|
|
6
|
+
import { BaseTable } from "../types.js";
|
|
7
7
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
8
8
|
bodySchema: IB;
|
|
9
9
|
outputBodySchema?: OB;
|