@ai0x0/utils 0.0.14 → 0.0.15

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 (47) hide show
  1. package/es/__shims__/next-rest-framework.d.ts +48 -0
  2. package/es/backend/actions/create-delete-action.d.ts +1 -1
  3. package/es/backend/actions/create-get-action.d.ts +2 -2
  4. package/es/backend/actions/create-get-action.js +1 -1
  5. package/es/backend/actions/create-get-list-action.d.ts +3 -3
  6. package/es/backend/actions/create-get-list-action.js +3 -3
  7. package/es/backend/actions/create-post-action.d.ts +2 -2
  8. package/es/backend/actions/create-post-action.js +8 -2
  9. package/es/backend/actions/create-put-action.d.ts +3 -3
  10. package/es/backend/actions/get-list-data.d.ts +3 -15
  11. package/es/backend/actions/get-list-query.d.ts +5 -7
  12. package/es/backend/actions/transform-body.d.ts +1 -1
  13. package/es/backend/actions/transform-body.js +0 -2
  14. package/es/backend/route-operation/delete-operation.d.ts +2 -2
  15. package/es/backend/route-operation/get-list-operation.d.ts +2 -2
  16. package/es/backend/route-operation/get-operation.d.ts +3 -3
  17. package/es/backend/route-operation/get-operation.js +18 -24
  18. package/es/backend/route-operation/post-operation.d.ts +2 -2
  19. package/es/backend/route-operation/post-operation.js +21 -16
  20. package/es/backend/route-operation/put-operation.d.ts +2 -2
  21. package/es/backend/route-operation/put-operation.js +21 -16
  22. package/es/backend/schemas/index.d.ts +76 -1249
  23. package/es/backend/schemas/index.js +1 -6
  24. package/lib/__shims__/next-rest-framework.d.ts +48 -0
  25. package/lib/backend/actions/create-delete-action.d.ts +1 -1
  26. package/lib/backend/actions/create-get-action.d.ts +2 -2
  27. package/lib/backend/actions/create-get-list-action.d.ts +3 -3
  28. package/lib/backend/actions/create-post-action.d.ts +2 -2
  29. package/lib/backend/actions/create-post-action.js +3 -1
  30. package/lib/backend/actions/create-put-action.d.ts +3 -3
  31. package/lib/backend/actions/create-put-action.js +4 -1
  32. package/lib/backend/actions/get-list-data.d.ts +3 -15
  33. package/lib/backend/actions/get-list-query.d.ts +5 -7
  34. package/lib/backend/actions/transform-body.d.ts +1 -1
  35. package/lib/backend/actions/transform-body.js +3 -1
  36. package/lib/backend/route-operation/delete-operation.d.ts +2 -2
  37. package/lib/backend/route-operation/get-list-operation.d.ts +2 -2
  38. package/lib/backend/route-operation/get-list-operation.js +7 -2
  39. package/lib/backend/route-operation/get-operation.d.ts +3 -3
  40. package/lib/backend/route-operation/get-operation.js +6 -3
  41. package/lib/backend/route-operation/post-operation.d.ts +2 -2
  42. package/lib/backend/route-operation/post-operation.js +5 -5
  43. package/lib/backend/route-operation/put-operation.d.ts +2 -2
  44. package/lib/backend/route-operation/put-operation.js +5 -5
  45. package/lib/backend/schemas/index.d.ts +76 -1249
  46. package/lib/backend/schemas/index.js +12 -14
  47. package/package.json +37 -34
@@ -0,0 +1,48 @@
1
+ import type { NextRequest } from "next/server";
2
+ import type { ZodType } from "zod";
3
+
4
+ declare module "next-rest-framework" {
5
+ export interface RouteOperationDefinition<M extends string = string> {
6
+ _method: M;
7
+ }
8
+
9
+ interface RouteOperationBuilder<M extends string> {
10
+ input: (opts: {
11
+ body?: ZodType;
12
+ query?: ZodType;
13
+ contentType?: string;
14
+ }) => RouteOperationBuilder<M>;
15
+ outputs: (
16
+ opts: { body?: ZodType; status?: number; contentType?: string }[],
17
+ ) => RouteOperationBuilder<M>;
18
+ handler: (
19
+ fn: (req: NextRequest) => Promise<Response>,
20
+ ) => RouteOperationDefinition<M>;
21
+ }
22
+
23
+ export const routeOperation: <M extends string>(opts: {
24
+ method: M;
25
+ openApiOperation?: { summary?: string; tags?: string[] };
26
+ }) => RouteOperationBuilder<M>;
27
+
28
+ export const rpcOperation: () => {
29
+ outputs: (opts: { body?: ZodType; contentType?: string }[]) => {
30
+ handler: <T>(fn: () => Promise<T>) => () => Promise<T>;
31
+ };
32
+ };
33
+
34
+ export const TypedNextResponse: {
35
+ json: <T>(body: T, init?: { status?: number }) => Response;
36
+ };
37
+
38
+ export type TypedNextRequest<
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ M = string,
41
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
+ C = string,
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ B = unknown,
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ Q = Record<string, string>,
47
+ > = NextRequest;
48
+ }
@@ -1,7 +1,7 @@
1
1
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
2
2
  import { BaseTable } from "../types";
3
3
  export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
4
- db: NodePgDatabase<any>;
4
+ db: NodePgDatabase<Record<string, unknown>>;
5
5
  table: TTable;
6
6
  }): ({ id, creatorId }: {
7
7
  id: string;
@@ -3,8 +3,8 @@ import { NodePgDatabase } from "drizzle-orm/node-postgres";
3
3
  import { BaseTable, GetListRelations } from "../types";
4
4
  export declare function createGetAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
5
5
  bodySchema: T;
6
- db: NodePgDatabase<any>;
6
+ db: NodePgDatabase<Record<string, unknown>>;
7
7
  jsonArrayFields?: string[];
8
8
  relations?: GetListRelations;
9
9
  table: TTable;
10
- }): (params: Partial<z.infer<T>>) => Promise<T["_output"]>;
10
+ }): (params: Partial<z.infer<T>> & Record<string, unknown>) => Promise<z.core.output<T> | undefined>;
@@ -40,7 +40,7 @@ export function createGetAction(_ref) {
40
40
  params: params,
41
41
  relations: relations,
42
42
  table: table
43
- }), query = _getListQuery.query, countQuery = _getListQuery.countQuery; // 执行查询
43
+ }), query = _getListQuery.query, countQuery = _getListQuery.countQuery;
44
44
  _context.next = 5;
45
45
  return getListData({
46
46
  bodySchema: bodySchema,
@@ -3,11 +3,11 @@ import { BaseTable, GetListRelations } from "../types";
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;
6
- db: NodePgDatabase<any>;
6
+ db: NodePgDatabase<Record<string, unknown>>;
7
7
  jsonArrayFields?: string[];
8
8
  relations?: GetListRelations;
9
9
  table: TTable;
10
- }): (params: Partial<z.infer<T>>) => Promise<{
11
- data: T["_output"][];
10
+ }): (params: Partial<z.infer<T>> & Record<string, unknown>) => Promise<{
11
+ data: any;
12
12
  total: number;
13
13
  }>;
@@ -15,11 +15,11 @@ export function createGetListAction(_ref) {
15
15
  table = _ref.table;
16
16
  return /*#__PURE__*/function () {
17
17
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
18
- var current, pageSize, other, fields, _i, _Object$keys, key, field, _getListQuery, query, countQuery;
18
+ var _ref3, current, pageSize, other, fields, _i, _Object$keys, key, field, _getListQuery, query, countQuery;
19
19
  return _regeneratorRuntime().wrap(function _callee$(_context) {
20
20
  while (1) switch (_context.prev = _context.next) {
21
21
  case 0:
22
- current = params.current, pageSize = params.pageSize, other = _objectWithoutProperties(params, _excluded);
22
+ _ref3 = params, current = _ref3.current, pageSize = _ref3.pageSize, other = _objectWithoutProperties(_ref3, _excluded);
23
23
  fields = {}; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
24
  // @ts-ignore
25
25
  for (_i = 0, _Object$keys = Object.keys(bodySchema.shape); _i < _Object$keys.length; _i++) {
@@ -38,7 +38,7 @@ export function createGetListAction(_ref) {
38
38
  params: other,
39
39
  relations: relations,
40
40
  table: table
41
- }), query = _getListQuery.query, countQuery = _getListQuery.countQuery; // 执行查询
41
+ }), query = _getListQuery.query, countQuery = _getListQuery.countQuery;
42
42
  return _context.abrupt("return", getListData({
43
43
  bodySchema: bodySchema,
44
44
  countQuery: countQuery,
@@ -3,6 +3,6 @@ import { PgTable } from "drizzle-orm/pg-core";
3
3
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
4
  export declare function createPostAction<T extends ZodSchema, TTable extends PgTable>({ table, db, }: {
5
5
  bodySchema: T;
6
- db: NodePgDatabase<any>;
6
+ db: NodePgDatabase<Record<string, unknown>>;
7
7
  table: TTable;
8
- }): (body: z.infer<T>) => Promise<T["_output"][]>;
8
+ }): (body: z.infer<T>) => Promise<z.infer<T>[]>;
@@ -8,11 +8,17 @@ export function createPostAction(_ref) {
8
8
  db = _ref.db;
9
9
  return /*#__PURE__*/function () {
10
10
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body) {
11
+ var values, result;
11
12
  return _regeneratorRuntime().wrap(function _callee$(_context) {
12
13
  while (1) switch (_context.prev = _context.next) {
13
14
  case 0:
14
- return _context.abrupt("return", db.insert(table).values(transformBody(body)).returning());
15
- case 1:
15
+ values = transformBody(body);
16
+ _context.next = 3;
17
+ return db.insert(table).values(values).returning();
18
+ case 3:
19
+ result = _context.sent;
20
+ return _context.abrupt("return", result);
21
+ case 5:
16
22
  case "end":
17
23
  return _context.stop();
18
24
  }
@@ -3,8 +3,8 @@ import { NodePgDatabase } from "drizzle-orm/node-postgres";
3
3
  import { BaseTable } from "../types";
4
4
  export declare function createPutAction<T extends ZodSchema, TTable extends BaseTable>({ db, table, }: {
5
5
  bodySchema: T;
6
- db: NodePgDatabase<any>;
6
+ db: NodePgDatabase<Record<string, unknown>>;
7
7
  table: TTable;
8
- }): (body: Partial<z.infer<T>>, { byCreator, }?: {
8
+ }): (body: Partial<z.infer<T>> & Record<string, unknown>, { byCreator, }?: {
9
9
  byCreator?: boolean | undefined;
10
- }) => Promise<T["_output"]>;
10
+ }) => Promise<z.infer<T>>;
@@ -4,19 +4,7 @@ export declare function getListData<B extends ZodSchema>({ query, countQuery, pa
4
4
  bodySchema: B;
5
5
  current?: number;
6
6
  pageSize?: number;
7
- } & ReturnType<typeof getListQuery>): import("next-rest-framework/dist/index-Xbs7wi4f").R<"application/json" | "application/x-www-form-urlencoded" | "multipart/form-data", unknown, {
8
- body: import("zod").ZodObject<{
9
- total: import("zod").ZodNumber;
10
- data: import("zod").ZodArray<B, "many">;
11
- }, "strip", import("zod").ZodTypeAny, {
12
- data: B["_output"][];
13
- total: number;
14
- }, {
15
- data: B["_input"][];
16
- total: number;
17
- }>;
18
- contentType: "application/json";
19
- }[], false, Promise<{
20
- data: B["_output"][];
7
+ } & ReturnType<typeof getListQuery>): () => Promise<{
8
+ data: any;
21
9
  total: number;
22
- }>>;
10
+ }>;
@@ -3,11 +3,11 @@ 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";
5
5
  export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, relations, table, }: {
6
- db: NodePgDatabase<any>;
6
+ db: NodePgDatabase<Record<string, unknown>>;
7
7
  fields: TSelection;
8
8
  jsonArrayFields?: string[];
9
9
  params: {
10
- [field: string]: any;
10
+ [field: string]: unknown;
11
11
  orderBy?: keyof BaseTable;
12
12
  orderDir?: "asc" | "desc";
13
13
  page?: number;
@@ -16,13 +16,11 @@ export declare function getListQuery<TTable extends BaseTable, TSelection extend
16
16
  relations?: GetListRelations;
17
17
  table: TTable;
18
18
  }): {
19
- countQuery: Omit<import("drizzle-orm/pg-core").PgSelectBase<any, {
19
+ countQuery: Omit<import("drizzle-orm/pg-core").PgSelectBase<string, {
20
20
  count: SQL<unknown>;
21
- }, "partial", {} | Record<any, "not-null">, false, "where", ({
21
+ }, "partial", Record<string, "not-null">, false, "where", {
22
22
  count: unknown;
23
- } | {
24
- count: unknown;
25
- })[], {
23
+ }[], {
26
24
  count: import("drizzle-orm").DrizzleTypeError<"You cannot reference this field without assigning it an alias first - use `.as(<alias>)`">;
27
25
  }>, "where">;
28
26
  query: any;
@@ -1 +1 @@
1
- export declare const transformBody: (body: Record<string, any>) => any;
1
+ export declare const transformBody: <T extends Record<string, unknown>>(body: T) => T;
@@ -1,9 +1,7 @@
1
1
  import dayjs from "dayjs";
2
2
  export var transformBody = function transformBody(body) {
3
- // 遍历 body 中的每个字段
4
3
  for (var key in body) {
5
4
  if (key.endsWith("At")) {
6
- // 使用 dayjs 将值转换为 Date 对象
7
5
  body[key] = dayjs(body[key]).toDate();
8
6
  }
9
7
  }
@@ -10,8 +10,8 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
10
10
  byCreator?: boolean;
11
11
  }
12
12
  export declare const createDeleteOperation: ({ db, getSession, }: {
13
- db: NodePgDatabase<any>;
13
+ db: NodePgDatabase<Record<string, unknown>>;
14
14
  getSession: (req: NextRequest) => Promise<{
15
15
  userId?: string;
16
16
  } | undefined>;
17
- }) => <TTable extends BaseTable>({ table, summary, onSuccess, onError, byCreator, }: DeleteOperationOptions<TTable>) => any;
17
+ }) => <TTable extends BaseTable>({ table, summary, onSuccess, onError, byCreator, }: DeleteOperationOptions<TTable>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
@@ -22,8 +22,8 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
22
22
  onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
23
23
  }
24
24
  export declare const createGetListOperation: ({ db, getSession, }: {
25
- db: NodePgDatabase<any>;
25
+ db: NodePgDatabase<Record<string, unknown>>;
26
26
  getSession: (req: NextRequest) => Promise<{
27
27
  userId?: string;
28
28
  } | undefined>;
29
- }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, jsonArrayFields, setParams, onSuccess, onError, byCreator, }: GetListOperationOptions<T, Q, TTable>) => any;
29
+ }) => <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, summary, relations, jsonArrayFields, setParams, onSuccess, onError, byCreator, }: GetListOperationOptions<T, Q, TTable>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
@@ -8,7 +8,7 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
8
8
  jsonArrayFields?: string[];
9
9
  querySchema: Q;
10
10
  relations?: GetListRelations;
11
- setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, any>>;
11
+ setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
12
12
  onSuccess?: (data: z.infer<T>) => Promise<z.infer<T>>;
13
13
  onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
14
14
  summary?: string;
@@ -16,8 +16,8 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
16
16
  byCreator?: boolean;
17
17
  }
18
18
  export declare const createGetOperation: ({ getSession, db, }: {
19
- db: NodePgDatabase<any>;
19
+ db: NodePgDatabase<Record<string, unknown>>;
20
20
  getSession: (req: NextRequest) => Promise<{
21
21
  userId?: string;
22
22
  } | undefined>;
23
- }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, setParams, jsonArrayFields, onSuccess, onError, byCreator, }: GetOperationOptions<T, Q, TTable>) => any;
23
+ }) => <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, summary, relations, setParams, jsonArrayFields, onSuccess, onError, byCreator, }: GetOperationOptions<T, Q, TTable>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
@@ -34,7 +34,7 @@ export var createGetOperation = function createGetOperation(_ref) {
34
34
  status: 200
35
35
  }]).handler( /*#__PURE__*/function () {
36
36
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
37
- var params, _ref4, userId, result, response;
37
+ var params, _ref4, userId, rawResult, result, response;
38
38
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
39
  while (1) switch (_context.prev = _context.next) {
40
40
  case 0:
@@ -77,45 +77,39 @@ export var createGetOperation = function createGetOperation(_ref) {
77
77
  table: table
78
78
  })(Object.assign(Object.fromEntries(new URL(req.url).searchParams), params));
79
79
  case 18:
80
- _context.t2 = _context.sent;
81
- if (_context.t2) {
82
- _context.next = 21;
83
- break;
84
- }
85
- _context.t2 = {};
86
- case 21:
87
- result = _context.t2;
80
+ rawResult = _context.sent;
81
+ result = rawResult !== null && rawResult !== void 0 ? rawResult : {};
88
82
  if (!onSuccess) {
89
- _context.next = 26;
83
+ _context.next = 24;
90
84
  break;
91
85
  }
92
- _context.next = 25;
86
+ _context.next = 23;
93
87
  return onSuccess(result);
94
- case 25:
88
+ case 23:
95
89
  result = _context.sent;
96
- case 26:
90
+ case 24:
97
91
  return _context.abrupt("return", TypedNextResponse.json(result, {
98
92
  status: 200
99
93
  }));
100
- case 29:
101
- _context.prev = 29;
102
- _context.t3 = _context["catch"](0);
103
- _context.next = 33;
104
- return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
105
- case 33:
94
+ case 27:
95
+ _context.prev = 27;
96
+ _context.t2 = _context["catch"](0);
97
+ _context.next = 31;
98
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t2);
99
+ case 31:
106
100
  response = _context.sent;
107
101
  if (!response) {
108
- _context.next = 38;
102
+ _context.next = 36;
109
103
  break;
110
104
  }
111
105
  return _context.abrupt("return", response);
112
- case 38:
113
- throw _context.t3;
114
- case 39:
106
+ case 36:
107
+ throw _context.t2;
108
+ case 37:
115
109
  case "end":
116
110
  return _context.stop();
117
111
  }
118
- }, _callee, null, [[0, 29]]);
112
+ }, _callee, null, [[0, 27]]);
119
113
  }));
120
114
  return function (_x) {
121
115
  return _ref3.apply(this, arguments);
@@ -13,8 +13,8 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
13
13
  table: TTable;
14
14
  }
15
15
  export declare const createPostOperation: ({ getSession, db, }: {
16
- db: NodePgDatabase<any>;
16
+ db: NodePgDatabase<Record<string, unknown>>;
17
17
  getSession: (req: NextRequest) => Promise<{
18
18
  userId?: string;
19
19
  } | undefined>;
20
- }) => <IB extends z.ZodType<any, z.ZodTypeDef, any>, OB extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends PgTable<import("drizzle-orm/pg-core").TableConfig>>({ bodySchema, outputBodySchema, setBody, summary, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => any;
20
+ }) => <IB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, OB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, TTable extends PgTable<import("drizzle-orm/pg-core").TableConfig>>({ bodySchema, outputBodySchema, setBody, summary, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
@@ -45,7 +45,7 @@ export var createPostOperation = function createPostOperation(_ref) {
45
45
  status: 200
46
46
  }]).handler( /*#__PURE__*/function () {
47
47
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
48
- var _ref4, userId, body, _yield$createPostActi, _yield$createPostActi2, _data, response;
48
+ var _ref4, userId, body, _yield$createPostActi, _yield$createPostActi2, raw, _data, response;
49
49
  return _regeneratorRuntime().wrap(function _callee$(_context) {
50
50
  while (1) switch (_context.prev = _context.next) {
51
51
  case 0:
@@ -90,38 +90,43 @@ export var createPostOperation = function createPostOperation(_ref) {
90
90
  case 21:
91
91
  _yield$createPostActi = _context.sent;
92
92
  _yield$createPostActi2 = _slicedToArray(_yield$createPostActi, 1);
93
- _data = _yield$createPostActi2[0];
93
+ raw = _yield$createPostActi2[0];
94
94
  if (!onSuccess) {
95
- _context.next = 28;
95
+ _context.next = 30;
96
96
  break;
97
97
  }
98
98
  _context.next = 27;
99
- return onSuccess(_data);
99
+ return onSuccess(raw);
100
100
  case 27:
101
- _data = _context.sent;
102
- case 28:
101
+ _context.t5 = _context.sent;
102
+ _context.next = 31;
103
+ break;
104
+ case 30:
105
+ _context.t5 = raw;
106
+ case 31:
107
+ _data = _context.t5;
103
108
  return _context.abrupt("return", TypedNextResponse.json(_data, {
104
109
  status: 200
105
110
  }));
106
- case 31:
107
- _context.prev = 31;
108
- _context.t5 = _context["catch"](0);
109
- _context.next = 35;
110
- return onError === null || onError === void 0 ? void 0 : onError(_context.t5);
111
111
  case 35:
112
+ _context.prev = 35;
113
+ _context.t6 = _context["catch"](0);
114
+ _context.next = 39;
115
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t6);
116
+ case 39:
112
117
  response = _context.sent;
113
118
  if (!response) {
114
- _context.next = 40;
119
+ _context.next = 44;
115
120
  break;
116
121
  }
117
122
  return _context.abrupt("return", response);
118
- case 40:
119
- throw _context.t5;
120
- case 41:
123
+ case 44:
124
+ throw _context.t6;
125
+ case 45:
121
126
  case "end":
122
127
  return _context.stop();
123
128
  }
124
- }, _callee, null, [[0, 31]]);
129
+ }, _callee, null, [[0, 35]]);
125
130
  }));
126
131
  return function (_x) {
127
132
  return _ref3.apply(this, arguments);
@@ -18,5 +18,5 @@ export declare const createPutOperation: ({ getSession, db, }: {
18
18
  getSession: (req: NextRequest) => Promise<{
19
19
  userId?: string;
20
20
  } | undefined>;
21
- db: NodePgDatabase<any>;
22
- }) => <IB extends z.ZodType<any, z.ZodTypeDef, any>, OB extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ bodySchema, outputBodySchema, table, summary, setBody, onSuccess, byCreator, onError, }: PutOperationOptions<IB, OB, TTable>) => any;
21
+ db: NodePgDatabase<Record<string, unknown>>;
22
+ }) => <IB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, OB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, TTable extends BaseTable>({ bodySchema, outputBodySchema, table, summary, setBody, onSuccess, byCreator, onError, }: PutOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
@@ -39,7 +39,7 @@ export var createPutOperation = function createPutOperation(_ref) {
39
39
  contentType: "application/json"
40
40
  }]).handler( /*#__PURE__*/function () {
41
41
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
42
- var _ref4, userId, body, _data, response;
42
+ var _ref4, userId, body, raw, _data, response;
43
43
  return _regeneratorRuntime().wrap(function _callee$(_context) {
44
44
  while (1) switch (_context.prev = _context.next) {
45
45
  case 0:
@@ -84,38 +84,43 @@ export var createPutOperation = function createPutOperation(_ref) {
84
84
  byCreator: byCreator
85
85
  });
86
86
  case 21:
87
- _data = _context.sent;
87
+ raw = _context.sent;
88
88
  if (!onSuccess) {
89
- _context.next = 26;
89
+ _context.next = 28;
90
90
  break;
91
91
  }
92
92
  _context.next = 25;
93
- return onSuccess(_data);
93
+ return onSuccess(raw);
94
94
  case 25:
95
- _data = _context.sent;
96
- case 26:
95
+ _context.t5 = _context.sent;
96
+ _context.next = 29;
97
+ break;
98
+ case 28:
99
+ _context.t5 = raw;
100
+ case 29:
101
+ _data = _context.t5;
97
102
  return _context.abrupt("return", TypedNextResponse.json(_data, {
98
103
  status: 200
99
104
  }));
100
- case 29:
101
- _context.prev = 29;
102
- _context.t5 = _context["catch"](0);
103
- _context.next = 33;
104
- return onError === null || onError === void 0 ? void 0 : onError(_context.t5);
105
105
  case 33:
106
+ _context.prev = 33;
107
+ _context.t6 = _context["catch"](0);
108
+ _context.next = 37;
109
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t6);
110
+ case 37:
106
111
  response = _context.sent;
107
112
  if (!response) {
108
- _context.next = 38;
113
+ _context.next = 42;
109
114
  break;
110
115
  }
111
116
  return _context.abrupt("return", response);
112
- case 38:
113
- throw _context.t5;
114
- case 39:
117
+ case 42:
118
+ throw _context.t6;
119
+ case 43:
115
120
  case "end":
116
121
  return _context.stop();
117
122
  }
118
- }, _callee, null, [[0, 29]]);
123
+ }, _callee, null, [[0, 33]]);
119
124
  }));
120
125
  return function (_x) {
121
126
  return _ref3.apply(this, arguments);