@ai0x0/utils 0.0.50 → 0.1.0
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/.agents/skills/ai0x0-utils/backend/SKILL.md +35 -11
- package/README.md +3 -3
- package/SKILL.md +35 -11
- package/es/backend/actions/create-delete-action.d.ts +4 -2
- package/es/backend/actions/create-delete-action.js +22 -28
- package/es/backend/actions/create-get-action.d.ts +4 -1
- package/es/backend/actions/create-get-action.js +10 -10
- package/es/backend/actions/create-get-list-action.d.ts +4 -1
- package/es/backend/actions/create-get-list-action.js +9 -9
- package/es/backend/actions/create-put-action.d.ts +3 -2
- package/es/backend/actions/create-put-action.js +23 -38
- package/es/backend/actions/get-list-query.d.ts +8 -1
- package/es/backend/actions/get-list-query.js +19 -8
- package/es/backend/index.d.ts +1 -0
- package/es/backend/index.js +2 -1
- package/es/backend/route-operation/delete-operation.d.ts +3 -1
- package/es/backend/route-operation/get-list-operation.d.ts +3 -1
- package/es/backend/route-operation/get-operation.d.ts +3 -1
- package/es/backend/route-operation/operation-common.d.ts +80 -8
- package/es/backend/route-operation/operation-common.js +216 -67
- package/es/backend/route-operation/post-operation.d.ts +3 -1
- package/es/backend/route-operation/put-operation.d.ts +3 -1
- package/es/backend/route-operation/read-operation-core.d.ts +17 -14
- package/es/backend/route-operation/read-operation-core.js +42 -34
- package/es/backend/route-operation/write-operation-core.d.ts +25 -22
- package/es/backend/route-operation/write-operation-core.js +195 -165
- package/es/backend/schemas/index.d.ts +240 -240
- package/es/backend/scope.d.ts +27 -0
- package/es/backend/scope.js +60 -0
- package/es/backend/sqlite/actions/create-delete-action.d.ts +4 -2
- package/es/backend/sqlite/actions/create-delete-action.js +21 -28
- package/es/backend/sqlite/actions/create-get-action.d.ts +4 -1
- package/es/backend/sqlite/actions/create-get-action.js +9 -7
- package/es/backend/sqlite/actions/create-get-list-action.d.ts +4 -1
- package/es/backend/sqlite/actions/create-get-list-action.js +8 -6
- package/es/backend/sqlite/actions/create-put-action.d.ts +3 -2
- package/es/backend/sqlite/actions/create-put-action.js +20 -38
- package/es/backend/sqlite/actions/get-list-query.d.ts +4 -1
- package/es/backend/sqlite/actions/get-list-query.js +8 -3
- package/es/backend/sqlite/route-operation/delete-operation.d.ts +3 -1
- package/es/backend/sqlite/route-operation/get-list-operation.d.ts +3 -1
- package/es/backend/sqlite/route-operation/get-operation.d.ts +3 -1
- package/es/backend/sqlite/route-operation/post-operation.d.ts +3 -1
- package/es/backend/sqlite/route-operation/put-operation.d.ts +3 -1
- package/lib/backend/actions/create-delete-action.d.ts +4 -2
- package/lib/backend/actions/create-delete-action.js +10 -16
- package/lib/backend/actions/create-get-action.d.ts +4 -1
- package/lib/backend/actions/create-get-action.js +2 -1
- package/lib/backend/actions/create-get-list-action.d.ts +4 -1
- package/lib/backend/actions/create-get-list-action.js +2 -1
- package/lib/backend/actions/create-put-action.d.ts +3 -2
- package/lib/backend/actions/create-put-action.js +10 -21
- package/lib/backend/actions/get-list-query.d.ts +8 -1
- package/lib/backend/actions/get-list-query.js +11 -4
- package/lib/backend/index.d.ts +1 -0
- package/lib/backend/index.js +3 -1
- package/lib/backend/route-operation/delete-operation.d.ts +3 -1
- package/lib/backend/route-operation/get-list-operation.d.ts +3 -1
- package/lib/backend/route-operation/get-operation.d.ts +3 -1
- package/lib/backend/route-operation/operation-common.d.ts +80 -8
- package/lib/backend/route-operation/operation-common.js +57 -7
- package/lib/backend/route-operation/post-operation.d.ts +3 -1
- package/lib/backend/route-operation/put-operation.d.ts +3 -1
- package/lib/backend/route-operation/read-operation-core.d.ts +17 -14
- package/lib/backend/route-operation/read-operation-core.js +12 -6
- package/lib/backend/route-operation/write-operation-core.d.ts +25 -22
- package/lib/backend/route-operation/write-operation-core.js +52 -16
- package/lib/backend/schemas/index.d.ts +240 -240
- package/lib/backend/scope.d.ts +27 -0
- package/lib/backend/scope.js +57 -0
- package/lib/backend/sqlite/actions/create-delete-action.d.ts +4 -2
- package/lib/backend/sqlite/actions/create-delete-action.js +10 -16
- package/lib/backend/sqlite/actions/create-get-action.d.ts +4 -1
- package/lib/backend/sqlite/actions/create-get-action.js +2 -1
- package/lib/backend/sqlite/actions/create-get-list-action.d.ts +4 -1
- package/lib/backend/sqlite/actions/create-get-list-action.js +2 -1
- package/lib/backend/sqlite/actions/create-put-action.d.ts +3 -2
- package/lib/backend/sqlite/actions/create-put-action.js +10 -21
- package/lib/backend/sqlite/actions/get-list-query.d.ts +4 -1
- package/lib/backend/sqlite/actions/get-list-query.js +5 -1
- package/lib/backend/sqlite/route-operation/delete-operation.d.ts +3 -1
- package/lib/backend/sqlite/route-operation/get-list-operation.d.ts +3 -1
- package/lib/backend/sqlite/route-operation/get-operation.d.ts +3 -1
- package/lib/backend/sqlite/route-operation/post-operation.d.ts +3 -1
- package/lib/backend/sqlite/route-operation/put-operation.d.ts +3 -1
- package/package.json +38 -1
|
@@ -2,15 +2,14 @@ import { NextRequest } from "next/server";
|
|
|
2
2
|
import { TypedNextRequest } from "next-rest-framework";
|
|
3
3
|
import { z, ZodSchema } from "zod";
|
|
4
4
|
import { type RouteOpenApiOperation } from "./open-api-operation.js";
|
|
5
|
-
import { ActionFactory, GetOperationParams, RouteCatch, SessionGetter } from "./operation-common.js";
|
|
6
|
-
|
|
5
|
+
import { AccessOptions, ActionFactory, DefaultSession, GetOperationParams, RouteCatch, SessionGetter } from "./operation-common.js";
|
|
6
|
+
import { ScopeArg } from "../scope.js";
|
|
7
|
+
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable, TRelations, TSession = DefaultSession> {
|
|
7
8
|
schemas: {
|
|
8
9
|
query: Q;
|
|
9
10
|
response: T;
|
|
10
11
|
};
|
|
11
|
-
access?:
|
|
12
|
-
byCreator?: boolean;
|
|
13
|
-
};
|
|
12
|
+
access?: AccessOptions<TSession>;
|
|
14
13
|
jsonArrayFields?: string[];
|
|
15
14
|
relations?: TRelations;
|
|
16
15
|
setParams?: (_req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
|
|
@@ -24,13 +23,15 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
24
23
|
table?: TTable;
|
|
25
24
|
}
|
|
26
25
|
export declare function createGetOperationFactory<TTable, TRelations>({ createAction, getTableName, }: {
|
|
27
|
-
createAction: ActionFactory<TTable, (_params: Record<string, unknown
|
|
26
|
+
createAction: ActionFactory<TTable, (_params: Record<string, unknown>, _options: {
|
|
27
|
+
scope: ScopeArg;
|
|
28
|
+
}) => Promise<unknown | undefined>>;
|
|
28
29
|
getTableName(table: TTable): string;
|
|
29
|
-
}): ({ db, getSession }: {
|
|
30
|
+
}): <TSession = DefaultSession>({ db, getSession, }: {
|
|
30
31
|
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"> {
|
|
32
|
+
getSession: SessionGetter<TSession>;
|
|
33
|
+
}) => <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, TSession>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
|
|
34
|
+
export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable, TRelations, TSession = DefaultSession> extends Omit<GetOperationOptions<T, Q, TTable, TRelations, TSession>, "handler"> {
|
|
34
35
|
handler?: <D extends T>(_payload: {
|
|
35
36
|
params: GetOperationParams<Q>;
|
|
36
37
|
data: {
|
|
@@ -44,12 +45,14 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
44
45
|
}>;
|
|
45
46
|
}
|
|
46
47
|
export declare function createGetListOperationFactory<TTable, TRelations>({ createAction, getTableName, }: {
|
|
47
|
-
createAction: ActionFactory<TTable, (_params: Record<string, unknown
|
|
48
|
+
createAction: ActionFactory<TTable, (_params: Record<string, unknown>, _options: {
|
|
49
|
+
scope: ScopeArg;
|
|
50
|
+
}) => Promise<{
|
|
48
51
|
data: unknown[];
|
|
49
52
|
total: number;
|
|
50
53
|
}>>;
|
|
51
54
|
getTableName(table: TTable): string;
|
|
52
|
-
}): ({ db, getSession }: {
|
|
55
|
+
}): <TSession = DefaultSession>({ db, getSession, }: {
|
|
53
56
|
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">;
|
|
57
|
+
getSession: SessionGetter<TSession>;
|
|
58
|
+
}) => <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, TSession>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
|
|
@@ -44,7 +44,7 @@ export function createGetOperationFactory(_ref) {
|
|
|
44
44
|
status: 200
|
|
45
45
|
}]).handler( /*#__PURE__*/function () {
|
|
46
46
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
47
|
-
var mergedParams, rawResult, result;
|
|
47
|
+
var _yield$getReadParams, mergedParams, scope, rawResult, result;
|
|
48
48
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
49
49
|
while (1) switch (_context.prev = _context.next) {
|
|
50
50
|
case 0:
|
|
@@ -58,53 +58,57 @@ export function createGetOperationFactory(_ref) {
|
|
|
58
58
|
setParams: setParams
|
|
59
59
|
});
|
|
60
60
|
case 3:
|
|
61
|
-
|
|
61
|
+
_yield$getReadParams = _context.sent;
|
|
62
|
+
mergedParams = _yield$getReadParams.params;
|
|
63
|
+
scope = _yield$getReadParams.scope;
|
|
62
64
|
if (!(table && db)) {
|
|
63
|
-
_context.next =
|
|
65
|
+
_context.next = 12;
|
|
64
66
|
break;
|
|
65
67
|
}
|
|
66
|
-
_context.next =
|
|
68
|
+
_context.next = 9;
|
|
67
69
|
return createAction({
|
|
68
70
|
bodySchema: schemas.response,
|
|
69
71
|
db: db,
|
|
70
72
|
jsonArrayFields: jsonArrayFields,
|
|
71
73
|
relations: relations,
|
|
72
74
|
table: table
|
|
73
|
-
})(mergedParams
|
|
74
|
-
|
|
75
|
+
})(mergedParams, {
|
|
76
|
+
scope: scope
|
|
77
|
+
});
|
|
78
|
+
case 9:
|
|
75
79
|
_context.t0 = _context.sent;
|
|
76
|
-
_context.next =
|
|
80
|
+
_context.next = 13;
|
|
77
81
|
break;
|
|
78
|
-
case
|
|
82
|
+
case 12:
|
|
79
83
|
_context.t0 = mergedParams;
|
|
80
|
-
case
|
|
84
|
+
case 13:
|
|
81
85
|
rawResult = _context.t0;
|
|
82
86
|
result = rawResult !== null && rawResult !== void 0 ? rawResult : {};
|
|
83
87
|
if (!handler) {
|
|
84
|
-
_context.next =
|
|
88
|
+
_context.next = 19;
|
|
85
89
|
break;
|
|
86
90
|
}
|
|
87
|
-
_context.next =
|
|
91
|
+
_context.next = 18;
|
|
88
92
|
return handler({
|
|
89
93
|
data: result,
|
|
90
94
|
params: mergedParams,
|
|
91
95
|
req: req
|
|
92
96
|
});
|
|
93
|
-
case
|
|
97
|
+
case 18:
|
|
94
98
|
result = _context.sent;
|
|
95
|
-
case
|
|
99
|
+
case 19:
|
|
96
100
|
return _context.abrupt("return", TypedNextResponse.json(result, {
|
|
97
101
|
status: 200
|
|
98
102
|
}));
|
|
99
|
-
case
|
|
100
|
-
_context.prev =
|
|
103
|
+
case 22:
|
|
104
|
+
_context.prev = 22;
|
|
101
105
|
_context.t1 = _context["catch"](0);
|
|
102
106
|
return _context.abrupt("return", handleOperationError(_context.t1, catchHandler));
|
|
103
|
-
case
|
|
107
|
+
case 25:
|
|
104
108
|
case "end":
|
|
105
109
|
return _context.stop();
|
|
106
110
|
}
|
|
107
|
-
}, _callee, null, [[0,
|
|
111
|
+
}, _callee, null, [[0, 22]]);
|
|
108
112
|
}));
|
|
109
113
|
return function (_x) {
|
|
110
114
|
return _ref4.apply(this, arguments);
|
|
@@ -151,7 +155,7 @@ export function createGetListOperationFactory(_ref5) {
|
|
|
151
155
|
status: 200
|
|
152
156
|
}]).handler( /*#__PURE__*/function () {
|
|
153
157
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req) {
|
|
154
|
-
var mergedParams, result;
|
|
158
|
+
var _yield$getReadParams2, mergedParams, scope, result;
|
|
155
159
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
156
160
|
while (1) switch (_context2.prev = _context2.next) {
|
|
157
161
|
case 0:
|
|
@@ -165,55 +169,59 @@ export function createGetListOperationFactory(_ref5) {
|
|
|
165
169
|
setParams: setParams
|
|
166
170
|
});
|
|
167
171
|
case 3:
|
|
168
|
-
|
|
172
|
+
_yield$getReadParams2 = _context2.sent;
|
|
173
|
+
mergedParams = _yield$getReadParams2.params;
|
|
174
|
+
scope = _yield$getReadParams2.scope;
|
|
169
175
|
if (!(table && db)) {
|
|
170
|
-
_context2.next =
|
|
176
|
+
_context2.next = 12;
|
|
171
177
|
break;
|
|
172
178
|
}
|
|
173
|
-
_context2.next =
|
|
179
|
+
_context2.next = 9;
|
|
174
180
|
return createAction({
|
|
175
181
|
bodySchema: schemas.response,
|
|
176
182
|
db: db,
|
|
177
183
|
jsonArrayFields: jsonArrayFields,
|
|
178
184
|
relations: relations,
|
|
179
185
|
table: table
|
|
180
|
-
})(mergedParams
|
|
181
|
-
|
|
186
|
+
})(mergedParams, {
|
|
187
|
+
scope: scope
|
|
188
|
+
});
|
|
189
|
+
case 9:
|
|
182
190
|
_context2.t0 = _context2.sent;
|
|
183
|
-
_context2.next =
|
|
191
|
+
_context2.next = 13;
|
|
184
192
|
break;
|
|
185
|
-
case
|
|
193
|
+
case 12:
|
|
186
194
|
_context2.t0 = {
|
|
187
195
|
data: [],
|
|
188
196
|
total: 0
|
|
189
197
|
};
|
|
190
|
-
case
|
|
198
|
+
case 13:
|
|
191
199
|
result = _context2.t0;
|
|
192
200
|
if (!handler) {
|
|
193
|
-
_context2.next =
|
|
201
|
+
_context2.next = 18;
|
|
194
202
|
break;
|
|
195
203
|
}
|
|
196
|
-
_context2.next =
|
|
204
|
+
_context2.next = 17;
|
|
197
205
|
return handler({
|
|
198
206
|
data: result,
|
|
199
207
|
params: mergedParams,
|
|
200
208
|
req: req
|
|
201
209
|
});
|
|
202
|
-
case
|
|
210
|
+
case 17:
|
|
203
211
|
result = _context2.sent;
|
|
204
|
-
case
|
|
212
|
+
case 18:
|
|
205
213
|
return _context2.abrupt("return", TypedNextResponse.json(result, {
|
|
206
214
|
status: 200
|
|
207
215
|
}));
|
|
208
|
-
case
|
|
209
|
-
_context2.prev =
|
|
216
|
+
case 21:
|
|
217
|
+
_context2.prev = 21;
|
|
210
218
|
_context2.t1 = _context2["catch"](0);
|
|
211
219
|
return _context2.abrupt("return", handleOperationError(_context2.t1, catchHandler));
|
|
212
|
-
case
|
|
220
|
+
case 24:
|
|
213
221
|
case "end":
|
|
214
222
|
return _context2.stop();
|
|
215
223
|
}
|
|
216
|
-
}, _callee2, null, [[0,
|
|
224
|
+
}, _callee2, null, [[0, 21]]);
|
|
217
225
|
}));
|
|
218
226
|
return function (_x2) {
|
|
219
227
|
return _ref8.apply(this, arguments);
|
|
@@ -2,15 +2,21 @@ import { NextRequest } from "next/server";
|
|
|
2
2
|
import { TypedNextRequest } from "next-rest-framework";
|
|
3
3
|
import { z, ZodSchema } from "zod";
|
|
4
4
|
import { type RouteOpenApiOperation } from "./open-api-operation.js";
|
|
5
|
-
import { ActionFactory, RouteCatch, SessionGetter } from "./operation-common.js";
|
|
5
|
+
import { AccessOptions, ActionFactory, DefaultSession, RouteCatch, SessionGetter } from "./operation-common.js";
|
|
6
|
+
import { ScopeArg } from "../scope.js";
|
|
6
7
|
export type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
7
8
|
creatorId?: string;
|
|
8
9
|
};
|
|
9
|
-
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable> {
|
|
10
|
+
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable, TSession = DefaultSession> {
|
|
10
11
|
schemas: {
|
|
11
12
|
body: IB;
|
|
12
13
|
response?: OB;
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* 新建时把归属列盖成这次请求的作用域值(默认就是 creatorId = 当前用户)。
|
|
17
|
+
* can 同样生效 —— 只读角色不能新建。
|
|
18
|
+
*/
|
|
19
|
+
access?: AccessOptions<TSession>;
|
|
14
20
|
contentType?: string;
|
|
15
21
|
openApiOperation?: RouteOpenApiOperation;
|
|
16
22
|
parseBody?: (_req: NextRequest) => Promise<Record<string, unknown>>;
|
|
@@ -26,21 +32,19 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
26
32
|
export declare function createPostOperationFactory<TTable>({ createAction, getTableName, }: {
|
|
27
33
|
createAction: ActionFactory<TTable, (_body: Record<string, unknown>) => Promise<unknown[]>>;
|
|
28
34
|
getTableName(table: TTable): string;
|
|
29
|
-
}): ({ db, getSession }: {
|
|
35
|
+
}): <TSession = DefaultSession>({ db, getSession, }: {
|
|
30
36
|
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">;
|
|
37
|
+
getSession: SessionGetter<TSession>;
|
|
38
|
+
}) => <IB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, OB extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>({ schemas, access, contentType, openApiOperation, parseBody, setBody, table, handler, catch: catchHandler, }: PostOperationOptions<IB, OB, TTable, TSession>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
33
39
|
export type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
34
40
|
editorId?: string;
|
|
35
41
|
};
|
|
36
|
-
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable> {
|
|
42
|
+
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable, TSession = DefaultSession> {
|
|
37
43
|
schemas: {
|
|
38
44
|
body: IB;
|
|
39
45
|
response?: OB;
|
|
40
46
|
};
|
|
41
|
-
access?:
|
|
42
|
-
byCreator?: boolean;
|
|
43
|
-
};
|
|
47
|
+
access?: AccessOptions<TSession>;
|
|
44
48
|
openApiOperation?: RouteOpenApiOperation;
|
|
45
49
|
table?: TTable;
|
|
46
50
|
setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
@@ -52,26 +56,24 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
52
56
|
catch?: RouteCatch;
|
|
53
57
|
}
|
|
54
58
|
export declare function createPutOperationFactory<TTable>({ createAction, getTableName, }: {
|
|
55
|
-
createAction: ActionFactory<TTable, (_body: Record<string, unknown>, _options
|
|
56
|
-
|
|
59
|
+
createAction: ActionFactory<TTable, (_body: Record<string, unknown>, _options: {
|
|
60
|
+
scope: ScopeArg;
|
|
57
61
|
}) => Promise<unknown>>;
|
|
58
62
|
getTableName(table: TTable): string;
|
|
59
|
-
}): ({ db, getSession }: {
|
|
63
|
+
}): <TSession = DefaultSession>({ db, getSession, }: {
|
|
60
64
|
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">;
|
|
65
|
+
getSession: SessionGetter<TSession>;
|
|
66
|
+
}) => <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, TSession>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
|
|
63
67
|
export type DeleteOperationParams<B extends ZodSchema> = z.infer<B> & Record<string, unknown> & {
|
|
64
68
|
creatorId?: string;
|
|
65
69
|
id: string;
|
|
66
70
|
};
|
|
67
|
-
export interface DeleteOperationOptions<TTable, B extends ZodSchema> {
|
|
71
|
+
export interface DeleteOperationOptions<TTable, B extends ZodSchema, TSession = DefaultSession> {
|
|
68
72
|
table?: TTable;
|
|
69
73
|
schemas?: {
|
|
70
74
|
body?: B;
|
|
71
75
|
};
|
|
72
|
-
access?:
|
|
73
|
-
byCreator?: boolean;
|
|
74
|
-
};
|
|
76
|
+
access?: AccessOptions<TSession>;
|
|
75
77
|
openApiOperation?: RouteOpenApiOperation;
|
|
76
78
|
handler?: (_payload: {
|
|
77
79
|
params: DeleteOperationParams<B>;
|
|
@@ -83,12 +85,13 @@ export interface DeleteOperationOptions<TTable, B extends ZodSchema> {
|
|
|
83
85
|
export declare function createDeleteOperationFactory<TTable>({ createAction, getTableName, }: {
|
|
84
86
|
createAction: ActionFactory<TTable, (_params: {
|
|
85
87
|
id: string;
|
|
86
|
-
|
|
88
|
+
}, _options: {
|
|
89
|
+
scope: ScopeArg;
|
|
87
90
|
}) => Promise<unknown>>;
|
|
88
91
|
getTableName(table: TTable): string;
|
|
89
|
-
}): ({ db, getSession }: {
|
|
92
|
+
}): <TSession = DefaultSession>({ db, getSession, }: {
|
|
90
93
|
db?: unknown;
|
|
91
|
-
getSession: SessionGetter
|
|
94
|
+
getSession: SessionGetter<TSession>;
|
|
92
95
|
}) => <B extends z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> = z.ZodObject<{
|
|
93
96
|
id: z.ZodString;
|
|
94
|
-
}, z.core.$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: DeleteOperationOptions<TTable, B>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
|
|
97
|
+
}, z.core.$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: DeleteOperationOptions<TTable, B, TSession>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
|