@ai0x0/utils 0.0.46 → 0.0.48

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 (77) 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 -18
  5. package/es/backend/route-operation/delete-operation.js +10 -122
  6. package/es/backend/route-operation/get-list-operation.d.ts +5 -27
  7. package/es/backend/route-operation/get-list-operation.js +10 -135
  8. package/es/backend/route-operation/get-operation.d.ts +5 -21
  9. package/es/backend/route-operation/get-operation.js +10 -132
  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 -20
  28. package/es/backend/sqlite/route-operation/delete-operation.js +10 -122
  29. package/es/backend/sqlite/route-operation/get-list-operation.d.ts +6 -28
  30. package/es/backend/sqlite/route-operation/get-list-operation.js +10 -135
  31. package/es/backend/sqlite/route-operation/get-operation.d.ts +6 -22
  32. package/es/backend/sqlite/route-operation/get-operation.js +10 -132
  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/es/backend/sqlite/schemas/index.d.ts +69 -5
  40. package/es/backend/sqlite/schemas/index.js +0 -1
  41. package/lib/__shims__/next-rest-framework.d.ts +2 -0
  42. package/lib/backend/route-operation/delete-operation.d.ts +7 -18
  43. package/lib/backend/route-operation/delete-operation.js +7 -52
  44. package/lib/backend/route-operation/get-list-operation.d.ts +5 -27
  45. package/lib/backend/route-operation/get-list-operation.js +7 -68
  46. package/lib/backend/route-operation/get-operation.d.ts +5 -21
  47. package/lib/backend/route-operation/get-operation.js +7 -67
  48. package/lib/backend/route-operation/index.d.ts +1 -0
  49. package/lib/backend/route-operation/index.js +3 -1
  50. package/lib/backend/route-operation/open-api-operation.d.ts +6 -0
  51. package/lib/backend/route-operation/open-api-operation.js +37 -0
  52. package/lib/backend/route-operation/operation-common.d.ts +38 -0
  53. package/lib/backend/route-operation/operation-common.js +90 -0
  54. package/lib/backend/route-operation/operation-core.d.ts +3 -0
  55. package/lib/backend/route-operation/operation-core.js +27 -0
  56. package/lib/backend/route-operation/post-operation.d.ts +5 -25
  57. package/lib/backend/route-operation/post-operation.js +7 -71
  58. package/lib/backend/route-operation/put-operation.d.ts +4 -23
  59. package/lib/backend/route-operation/put-operation.js +7 -68
  60. package/lib/backend/route-operation/read-operation-core.d.ts +55 -0
  61. package/lib/backend/route-operation/read-operation-core.js +151 -0
  62. package/lib/backend/route-operation/write-operation-core.d.ts +94 -0
  63. package/lib/backend/route-operation/write-operation-core.js +181 -0
  64. package/lib/backend/sqlite/route-operation/delete-operation.d.ts +9 -20
  65. package/lib/backend/sqlite/route-operation/delete-operation.js +7 -52
  66. package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +6 -28
  67. package/lib/backend/sqlite/route-operation/get-list-operation.js +7 -71
  68. package/lib/backend/sqlite/route-operation/get-operation.d.ts +6 -22
  69. package/lib/backend/sqlite/route-operation/get-operation.js +7 -67
  70. package/lib/backend/sqlite/route-operation/index.d.ts +1 -0
  71. package/lib/backend/sqlite/route-operation/index.js +3 -1
  72. package/lib/backend/sqlite/route-operation/post-operation.d.ts +6 -26
  73. package/lib/backend/sqlite/route-operation/post-operation.js +7 -71
  74. package/lib/backend/sqlite/route-operation/put-operation.d.ts +6 -25
  75. package/lib/backend/sqlite/route-operation/put-operation.js +7 -68
  76. package/lib/backend/sqlite/schemas/index.d.ts +69 -5
  77. package/package.json +1 -1
@@ -32,81 +32,17 @@ __export(post_operation_exports, {
32
32
  createPostOperation: () => createPostOperation
33
33
  });
34
34
  module.exports = __toCommonJS(post_operation_exports);
35
- var import_zod = require("zod");
36
- var import_next_rest_framework = require("next-rest-framework");
35
+ var import_create_post_action = require("../actions/create-post-action");
37
36
  var import_get_table_name = __toESM(require("./get-table-name"));
38
- var import_actions = require("../actions");
39
- async function readPostBody(req, {
40
- contentType,
41
- parseBody
42
- }) {
43
- if (parseBody) {
44
- return parseBody(req);
45
- }
46
- if (contentType === "multipart/form-data") {
47
- return Object.fromEntries(await req.formData());
48
- }
49
- return await req.json();
50
- }
37
+ var import_operation_core = require("./operation-core");
38
+ var createOperation = (0, import_operation_core.createPostOperationFactory)({
39
+ createAction: import_create_post_action.createPostAction,
40
+ getTableName: import_get_table_name.default
41
+ });
51
42
  var createPostOperation = ({
52
43
  getSession,
53
44
  db
54
- }) => ({
55
- bodySchema,
56
- contentType = "application/json",
57
- description,
58
- outputBodySchema,
59
- parseBody,
60
- setBody,
61
- summary,
62
- tags,
63
- table,
64
- onSuccess,
65
- onError
66
- }) => (0, import_next_rest_framework.routeOperation)({
67
- method: "POST",
68
- openApiOperation: {
69
- description,
70
- summary,
71
- tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
72
- }
73
- }).input({
74
- body: bodySchema,
75
- contentType
76
- }).outputs([
77
- {
78
- body: outputBodySchema || import_zod.z.object({ id: import_zod.z.string() }),
79
- contentType: "application/json",
80
- status: 200
81
- }
82
- ]).handler(async (req) => {
83
- try {
84
- const { userId } = await getSession(req) || {};
85
- const body = await readPostBody(req, { contentType, parseBody });
86
- const extraBody = await (setBody == null ? void 0 : setBody(req)) || {};
87
- const mergedBody = { ...body, ...extraBody };
88
- const params = { creatorId: userId, ...mergedBody };
89
- const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
90
- params
91
- ))[0] : params;
92
- const data = onSuccess ? await onSuccess({
93
- data: raw,
94
- params,
95
- req
96
- }) : raw;
97
- return import_next_rest_framework.TypedNextResponse.json(data, {
98
- status: 200
99
- });
100
- } catch (e) {
101
- console.error(e);
102
- const response = await (onError == null ? void 0 : onError(e));
103
- if (response) {
104
- return response;
105
- } else {
106
- throw e;
107
- }
108
- }
109
- });
45
+ }) => createOperation({ db, getSession });
110
46
  // Annotate the CommonJS export names for ESM import in node:
111
47
  0 && (module.exports = {
112
48
  createPostOperation
@@ -1,31 +1,12 @@
1
- import { z, ZodSchema } from "zod";
2
1
  import { PgTable } from "drizzle-orm/pg-core";
3
- import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
4
2
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
5
3
  import { NextRequest } from "next/server";
6
- import { BaseTable } from "../types.js";
7
- type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
8
- editorId?: string;
9
- };
10
- export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
11
- bodySchema: IB;
12
- description?: string;
13
- outputBodySchema?: OB;
14
- table?: TTable;
15
- summary?: string;
16
- tags?: string[];
17
- setBody?(req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
18
- onSuccess?(payload: {
19
- params: PutOperationParams<IB>;
20
- data: z.infer<OB>;
21
- }): Promise<z.infer<OB>>;
22
- onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
23
- byCreator?: boolean;
24
- }
4
+ import { ZodSchema } from "zod";
5
+ import { type PutOperationOptions as CorePutOperationOptions } from "./operation-core.js";
6
+ export type PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> = CorePutOperationOptions<IB, OB, TTable>;
25
7
  export declare const createPutOperation: ({ getSession, db, }: {
26
8
  getSession(req: NextRequest): Promise<{
27
9
  userId?: string;
28
10
  } | undefined>;
29
11
  db?: NodePgDatabase<Record<string, unknown>> | undefined;
30
- }) => <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, description, outputBodySchema, table, summary, tags, setBody, onSuccess, byCreator, onError, }: PutOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
31
- export {};
12
+ }) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, openApiOperation, table, setBody, handler, catch: catchHandler, }: CorePutOperationOptions<IB, OB, PgTable<import("drizzle-orm/pg-core").TableConfig>>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
@@ -32,78 +32,17 @@ __export(put_operation_exports, {
32
32
  createPutOperation: () => createPutOperation
33
33
  });
34
34
  module.exports = __toCommonJS(put_operation_exports);
35
- var import_zod = require("zod");
36
- var import_next_rest_framework = require("next-rest-framework");
35
+ var import_create_put_action = require("../actions/create-put-action");
37
36
  var import_get_table_name = __toESM(require("./get-table-name"));
38
- var import_actions = require("../actions");
39
- var import_errors = require("../errors");
37
+ var import_operation_core = require("./operation-core");
38
+ var createOperation = (0, import_operation_core.createPutOperationFactory)({
39
+ createAction: import_create_put_action.createPutAction,
40
+ getTableName: import_get_table_name.default
41
+ });
40
42
  var createPutOperation = ({
41
43
  getSession,
42
44
  db
43
- }) => ({
44
- bodySchema,
45
- description,
46
- outputBodySchema,
47
- table,
48
- summary,
49
- tags,
50
- setBody,
51
- onSuccess,
52
- byCreator = true,
53
- onError
54
- }) => (0, import_next_rest_framework.routeOperation)({
55
- method: "PUT",
56
- openApiOperation: {
57
- description,
58
- summary,
59
- tags: tags ?? (table ? [(0, import_get_table_name.default)(table)] : [])
60
- }
61
- }).input({
62
- body: bodySchema,
63
- contentType: "application/json"
64
- }).outputs([
65
- {
66
- body: outputBodySchema || import_zod.z.void(),
67
- status: 200,
68
- contentType: "application/json"
69
- }
70
- ]).handler(async (req) => {
71
- try {
72
- const { userId } = await getSession(req) || {};
73
- const body = await req.json();
74
- const extraBody = await (setBody == null ? void 0 : setBody(
75
- req
76
- )) || {};
77
- const mergedBody = { ...body, ...extraBody };
78
- const params = { editorId: userId, ...mergedBody };
79
- const raw = table && db ? await (0, import_actions.createPutAction)({
80
- bodySchema,
81
- table,
82
- db
83
- })(params, { byCreator }) : params;
84
- const data = onSuccess ? await onSuccess({
85
- data: raw,
86
- params
87
- }) : raw;
88
- return import_next_rest_framework.TypedNextResponse.json(data, {
89
- status: 200
90
- });
91
- } catch (e) {
92
- if (!(e instanceof import_errors.HttpError)) {
93
- console.error(e);
94
- }
95
- const response = await (onError == null ? void 0 : onError(e));
96
- if (response) {
97
- return response;
98
- }
99
- if (e instanceof import_errors.HttpError) {
100
- return import_next_rest_framework.TypedNextResponse.json({ message: e.message }, {
101
- status: e.status
102
- });
103
- }
104
- throw e;
105
- }
106
- });
45
+ }) => createOperation({ db, getSession });
107
46
  // Annotate the CommonJS export names for ESM import in node:
108
47
  0 && (module.exports = {
109
48
  createPutOperation
@@ -0,0 +1,55 @@
1
+ import { NextRequest } from "next/server";
2
+ import { TypedNextRequest } from "next-rest-framework";
3
+ import { z, ZodSchema } from "zod";
4
+ import { type RouteOpenApiOperation } from "./open-api-operation.js";
5
+ import { ActionFactory, GetOperationParams, RouteCatch, SessionGetter } from "./operation-common.js";
6
+ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable, TRelations> {
7
+ schemas: {
8
+ query: Q;
9
+ response: T;
10
+ };
11
+ access?: {
12
+ byCreator?: boolean;
13
+ };
14
+ jsonArrayFields?: string[];
15
+ relations?: TRelations;
16
+ setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
17
+ handler?: (_payload: {
18
+ params: GetOperationParams<Q>;
19
+ data: z.infer<T>;
20
+ req: NextRequest;
21
+ }) => Promise<z.infer<T>>;
22
+ catch?: RouteCatch;
23
+ openApiOperation?: RouteOpenApiOperation;
24
+ table?: TTable;
25
+ }
26
+ export declare function createGetOperationFactory<TTable, TRelations>({ createAction, getTableName, }: {
27
+ createAction: ActionFactory<TTable, (_params: Record<string, unknown>) => Promise<unknown | undefined>>;
28
+ getTableName(table: TTable): string;
29
+ }): ({ db, getSession }: {
30
+ db?: unknown;
31
+ getSession: SessionGetter;
32
+ }) => <T extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, Q extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, setParams, jsonArrayFields, handler, catch: catchHandler, }: GetOperationOptions<T, Q, TTable, TRelations>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
33
+ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable, TRelations> extends Omit<GetOperationOptions<T, Q, TTable, TRelations>, "handler"> {
34
+ handler?: <D extends T>(_payload: {
35
+ params: GetOperationParams<Q>;
36
+ data: {
37
+ data: z.infer<D>[];
38
+ total: number;
39
+ };
40
+ req: NextRequest;
41
+ }) => Promise<{
42
+ data: z.infer<T>[];
43
+ total: number;
44
+ }>;
45
+ }
46
+ export declare function createGetListOperationFactory<TTable, TRelations>({ createAction, getTableName, }: {
47
+ createAction: ActionFactory<TTable, (_params: Record<string, unknown>) => Promise<{
48
+ data: unknown[];
49
+ total: number;
50
+ }>>;
51
+ getTableName(table: TTable): string;
52
+ }): ({ db, getSession }: {
53
+ db?: unknown;
54
+ getSession: SessionGetter;
55
+ }) => <T extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, Q extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, jsonArrayFields, setParams, handler, catch: catchHandler, }: GetListOperationOptions<T, Q, TTable, TRelations>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
@@ -0,0 +1,151 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/backend/route-operation/read-operation-core.ts
20
+ var read_operation_core_exports = {};
21
+ __export(read_operation_core_exports, {
22
+ createGetListOperationFactory: () => createGetListOperationFactory,
23
+ createGetOperationFactory: () => createGetOperationFactory
24
+ });
25
+ module.exports = __toCommonJS(read_operation_core_exports);
26
+ var import_next_rest_framework = require("next-rest-framework");
27
+ var import_schemas = require("../schemas");
28
+ var import_open_api_operation = require("./open-api-operation");
29
+ var import_operation_common = require("./operation-common");
30
+ function createGetOperationFactory({
31
+ createAction,
32
+ getTableName
33
+ }) {
34
+ return ({ db, getSession }) => ({
35
+ schemas,
36
+ access,
37
+ table,
38
+ openApiOperation,
39
+ relations,
40
+ setParams,
41
+ jsonArrayFields,
42
+ handler,
43
+ catch: catchHandler
44
+ }) => (0, import_next_rest_framework.routeOperation)({
45
+ method: "GET",
46
+ openApiOperation: (0, import_open_api_operation.createOpenApiOperation)({
47
+ defaultTags: (0, import_operation_common.getDefaultTags)({ getTableName, table }),
48
+ openApiOperation
49
+ })
50
+ }).input({
51
+ query: schemas.query
52
+ }).outputs([
53
+ {
54
+ body: schemas.response,
55
+ contentType: "application/json",
56
+ status: 200
57
+ }
58
+ ]).handler(async (req) => {
59
+ try {
60
+ const mergedParams = await (0, import_operation_common.getReadParams)({
61
+ access,
62
+ getSession,
63
+ req,
64
+ schemas,
65
+ setParams
66
+ });
67
+ const rawResult = table && db ? await createAction({
68
+ bodySchema: schemas.response,
69
+ db,
70
+ jsonArrayFields,
71
+ relations,
72
+ table
73
+ })(mergedParams) : mergedParams;
74
+ let result = rawResult ?? {};
75
+ if (handler) {
76
+ result = await handler({
77
+ data: result,
78
+ params: mergedParams,
79
+ req
80
+ });
81
+ }
82
+ return import_next_rest_framework.TypedNextResponse.json(result, { status: 200 });
83
+ } catch (error) {
84
+ return (0, import_operation_common.handleOperationError)(error, catchHandler);
85
+ }
86
+ });
87
+ }
88
+ function createGetListOperationFactory({
89
+ createAction,
90
+ getTableName
91
+ }) {
92
+ return ({ db, getSession }) => ({
93
+ schemas,
94
+ access,
95
+ table,
96
+ openApiOperation,
97
+ relations,
98
+ jsonArrayFields,
99
+ setParams,
100
+ handler,
101
+ catch: catchHandler
102
+ }) => (0, import_next_rest_framework.routeOperation)({
103
+ method: "GET",
104
+ openApiOperation: (0, import_open_api_operation.createOpenApiOperation)({
105
+ defaultTags: (0, import_operation_common.getDefaultTags)({ getTableName, table }),
106
+ openApiOperation
107
+ })
108
+ }).input({
109
+ query: schemas.query
110
+ }).outputs([
111
+ {
112
+ body: (0, import_schemas.listBodySchema)(schemas.response),
113
+ contentType: "application/json",
114
+ status: 200
115
+ }
116
+ ]).handler(async (req) => {
117
+ try {
118
+ const mergedParams = await (0, import_operation_common.getReadParams)({
119
+ access,
120
+ getSession,
121
+ req,
122
+ schemas,
123
+ setParams
124
+ });
125
+ let result = table && db ? await createAction({
126
+ bodySchema: schemas.response,
127
+ db,
128
+ jsonArrayFields,
129
+ relations,
130
+ table
131
+ })(mergedParams) : { data: [], total: 0 };
132
+ if (handler) {
133
+ result = await handler({
134
+ data: result,
135
+ params: mergedParams,
136
+ req
137
+ });
138
+ }
139
+ return import_next_rest_framework.TypedNextResponse.json(result, {
140
+ status: 200
141
+ });
142
+ } catch (error) {
143
+ return (0, import_operation_common.handleOperationError)(error, catchHandler);
144
+ }
145
+ });
146
+ }
147
+ // Annotate the CommonJS export names for ESM import in node:
148
+ 0 && (module.exports = {
149
+ createGetListOperationFactory,
150
+ createGetOperationFactory
151
+ });
@@ -0,0 +1,94 @@
1
+ import { NextRequest } from "next/server";
2
+ import { TypedNextRequest } from "next-rest-framework";
3
+ import { z, ZodSchema } from "zod";
4
+ import { type RouteOpenApiOperation } from "./open-api-operation.js";
5
+ import { ActionFactory, RouteCatch, SessionGetter } from "./operation-common.js";
6
+ export type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
7
+ creatorId?: string;
8
+ };
9
+ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable> {
10
+ schemas: {
11
+ body: IB;
12
+ response?: OB;
13
+ };
14
+ contentType?: string;
15
+ openApiOperation?: RouteOpenApiOperation;
16
+ parseBody?: (_req: NextRequest) => Promise<Record<string, unknown>>;
17
+ setBody?: (_req: NextRequest) => Promise<Partial<z.infer<IB>>>;
18
+ handler?: (_payload: {
19
+ params: PostOperationParams<IB>;
20
+ data: z.infer<OB>;
21
+ req: NextRequest;
22
+ }) => Promise<z.infer<OB>>;
23
+ catch?: RouteCatch;
24
+ table?: TTable;
25
+ }
26
+ export declare function createPostOperationFactory<TTable>({ createAction, getTableName, }: {
27
+ createAction: ActionFactory<TTable, (_body: Record<string, unknown>) => Promise<unknown[]>>;
28
+ getTableName(table: TTable): string;
29
+ }): ({ db, getSession }: {
30
+ db?: unknown;
31
+ getSession: SessionGetter;
32
+ }) => <IB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, OB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>({ schemas, contentType, openApiOperation, parseBody, setBody, table, handler, catch: catchHandler, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
33
+ export type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
34
+ editorId?: string;
35
+ };
36
+ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable> {
37
+ schemas: {
38
+ body: IB;
39
+ response?: OB;
40
+ };
41
+ access?: {
42
+ byCreator?: boolean;
43
+ };
44
+ openApiOperation?: RouteOpenApiOperation;
45
+ table?: TTable;
46
+ setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
47
+ handler?: (_payload: {
48
+ params: PutOperationParams<IB>;
49
+ data: z.infer<OB>;
50
+ req: NextRequest;
51
+ }) => Promise<z.infer<OB>>;
52
+ catch?: RouteCatch;
53
+ }
54
+ export declare function createPutOperationFactory<TTable>({ createAction, getTableName, }: {
55
+ createAction: ActionFactory<TTable, (_body: Record<string, unknown>, _options?: {
56
+ byCreator?: boolean;
57
+ }) => Promise<unknown>>;
58
+ getTableName(table: TTable): string;
59
+ }): ({ db, getSession }: {
60
+ db?: unknown;
61
+ getSession: SessionGetter;
62
+ }) => <IB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, OB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>({ schemas, access, openApiOperation, table, setBody, handler, catch: catchHandler, }: PutOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
63
+ export type DeleteOperationParams<B extends ZodSchema> = z.infer<B> & Record<string, unknown> & {
64
+ creatorId?: string;
65
+ id: string;
66
+ };
67
+ export interface DeleteOperationOptions<TTable, B extends ZodSchema> {
68
+ table?: TTable;
69
+ schemas?: {
70
+ body?: B;
71
+ };
72
+ access?: {
73
+ byCreator?: boolean;
74
+ };
75
+ openApiOperation?: RouteOpenApiOperation;
76
+ handler?: (_payload: {
77
+ params: DeleteOperationParams<B>;
78
+ data: unknown;
79
+ req: NextRequest;
80
+ }) => Promise<void>;
81
+ catch?: RouteCatch;
82
+ }
83
+ export declare function createDeleteOperationFactory<TTable>({ createAction, getTableName, }: {
84
+ createAction: ActionFactory<TTable, (_params: {
85
+ id: string;
86
+ creatorId?: string;
87
+ }) => Promise<unknown>>;
88
+ getTableName(table: TTable): string;
89
+ }): ({ db, getSession }: {
90
+ db?: unknown;
91
+ getSession: SessionGetter;
92
+ }) => <B extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> = z.ZodObject<{
93
+ id: z.ZodString;
94
+ }, z.core.$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: DeleteOperationOptions<TTable, B>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;