@ai0x0/utils 0.0.12 → 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 +42 -33
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import { z } from "zod";
8
8
  import { pgTable, timestamp, uuid } from "drizzle-orm/pg-core";
9
9
  import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
10
+
10
11
  //============================基本字段============================//
11
12
  var timestamptz = function timestamptz(name) {
12
13
  return timestamp(name, {
@@ -74,17 +75,11 @@ export var createTableSchema = function createTableSchema(_ref) {
74
75
  return {
75
76
  table: table,
76
77
  selectSchema: selectSchema,
77
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
78
- // @ts-ignore
79
78
  insertSchema: createInsertSchema(insertTable, refineSchema),
80
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
81
- // @ts-ignore
82
79
  updateSchema: createUpdateSchema(updateTable, _objectSpread({
83
80
  id: z.string()
84
81
  }, refineSchema)),
85
82
  querySchema: selectSchema.pick({
86
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
87
- // @ts-ignore
88
83
  id: true
89
84
  }),
90
85
  queryListSchema: queryListSchema(selectSchema.partial()),
@@ -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>;
@@ -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
  }>;
@@ -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>[]>;
@@ -28,7 +28,9 @@ function createPostAction({
28
28
  db
29
29
  }) {
30
30
  return async (body) => {
31
- return db.insert(table).values((0, import_transform_body.transformBody)(body)).returning();
31
+ const values = (0, import_transform_body.transformBody)(body);
32
+ const result = await db.insert(table).values(values).returning();
33
+ return result;
32
34
  };
33
35
  }
34
36
  // Annotate the CommonJS export names for ESM import in node:
@@ -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>>;
@@ -41,7 +41,10 @@ function createPutAction({
41
41
  creatorId: import_zod.z.string(),
42
42
  id: import_zod.z.string()
43
43
  })
44
- })({ creatorId: body.editorId, id: body.id });
44
+ })({
45
+ creatorId: body.editorId,
46
+ id: body.id
47
+ });
45
48
  if (!data2) {
46
49
  throw Error("未找到编辑对象,或没有权限");
47
50
  }
@@ -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;
@@ -36,7 +36,9 @@ var import_dayjs = __toESM(require("dayjs"));
36
36
  var transformBody = (body) => {
37
37
  for (const key in body) {
38
38
  if (key.endsWith("At")) {
39
- body[key] = (0, import_dayjs.default)(body[key]).toDate();
39
+ body[key] = (0, import_dayjs.default)(
40
+ body[key]
41
+ ).toDate();
40
42
  }
41
43
  }
42
44
  return body;
@@ -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">;
@@ -66,7 +66,9 @@ var createGetListOperation = ({
66
66
  }
67
67
  ]).handler(async (req) => {
68
68
  try {
69
- const params = await (setParams == null ? void 0 : setParams(req)) || {};
69
+ const params = await (setParams == null ? void 0 : setParams(
70
+ req
71
+ )) || {};
70
72
  if (byCreator) {
71
73
  const { userId } = await getSession(req) || {};
72
74
  params.creatorId = userId;
@@ -86,7 +88,10 @@ var createGetListOperation = ({
86
88
  if (onSuccess) {
87
89
  result = await onSuccess(result);
88
90
  }
89
- return import_next_rest_framework.TypedNextResponse.json(result, { status: 200 });
91
+ return import_next_rest_framework.TypedNextResponse.json(
92
+ result,
93
+ { status: 200 }
94
+ );
90
95
  } catch (e) {
91
96
  const response = await (onError == null ? void 0 : onError(e));
92
97
  if (response) {
@@ -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">;
@@ -65,12 +65,14 @@ var createGetOperation = ({
65
65
  }
66
66
  ]).handler(async (req) => {
67
67
  try {
68
- const params = await (setParams == null ? void 0 : setParams(req)) || {};
68
+ const params = await (setParams == null ? void 0 : setParams(
69
+ req
70
+ )) || {};
69
71
  if (byCreator) {
70
72
  const { userId } = await getSession(req) || {};
71
73
  params.creatorId = userId;
72
74
  }
73
- let result = await (0, import_actions.createGetAction)({
75
+ const rawResult = await (0, import_actions.createGetAction)({
74
76
  bodySchema,
75
77
  db,
76
78
  jsonArrayFields,
@@ -81,7 +83,8 @@ var createGetOperation = ({
81
83
  Object.fromEntries(new URL(req.url).searchParams),
82
84
  params
83
85
  )
84
- ) || {};
86
+ );
87
+ let result = rawResult ?? {};
85
88
  if (onSuccess) {
86
89
  result = await onSuccess(result);
87
90
  }
@@ -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">;
@@ -67,15 +67,15 @@ var createPostOperation = ({
67
67
  const { userId } = await getSession(req) || {};
68
68
  const body = Object.assign(
69
69
  await req.json(),
70
- await (setBody == null ? void 0 : setBody(req)) || {}
70
+ await (setBody == null ? void 0 : setBody(
71
+ req
72
+ )) || {}
71
73
  );
72
- let [data] = await (0, import_actions.createPostAction)({ bodySchema, db, table })({
74
+ const [raw] = await (0, import_actions.createPostAction)({ bodySchema, db, table })({
73
75
  creatorId: userId,
74
76
  ...body
75
77
  });
76
- if (onSuccess) {
77
- data = await onSuccess(data);
78
- }
78
+ const data = onSuccess ? await onSuccess(raw) : raw;
79
79
  return import_next_rest_framework.TypedNextResponse.json(data, { status: 200 });
80
80
  } catch (e) {
81
81
  const response = await (onError == null ? void 0 : onError(e));
@@ -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">;
@@ -68,9 +68,11 @@ var createPutOperation = ({
68
68
  const { userId } = await getSession(req) || {};
69
69
  const body = Object.assign(
70
70
  await req.json(),
71
- await (setBody == null ? void 0 : setBody(req)) || {}
71
+ await (setBody == null ? void 0 : setBody(
72
+ req
73
+ )) || {}
72
74
  );
73
- let data = await (0, import_actions.createPutAction)({
75
+ const raw = await (0, import_actions.createPutAction)({
74
76
  bodySchema,
75
77
  table,
76
78
  db
@@ -81,9 +83,7 @@ var createPutOperation = ({
81
83
  },
82
84
  { byCreator }
83
85
  );
84
- if (onSuccess) {
85
- data = await onSuccess(data);
86
- }
86
+ const data = onSuccess ? await onSuccess(raw) : raw;
87
87
  return import_next_rest_framework.TypedNextResponse.json(data, { status: 200 });
88
88
  } catch (e) {
89
89
  const response = await (onError == null ? void 0 : onError(e));