@ai0x0/utils 0.0.16 → 0.0.17
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/es/backend/actions/create-delete-action.d.ts +3 -4
- package/es/backend/actions/create-get-action.d.ts +2 -3
- package/es/backend/actions/create-get-list-action.d.ts +2 -3
- package/es/backend/actions/create-post-action.d.ts +4 -4
- package/es/backend/actions/create-put-action.d.ts +2 -3
- package/es/backend/actions/get-list-query.d.ts +4 -12
- package/es/backend/actions/get-list-query.js +11 -8
- package/es/backend/route-operation/delete-operation.d.ts +2 -3
- package/es/backend/route-operation/get-list-operation.d.ts +2 -3
- package/es/backend/route-operation/get-operation.d.ts +2 -3
- package/es/backend/route-operation/get-table-name.d.ts +2 -2
- package/es/backend/route-operation/post-operation.d.ts +5 -5
- package/es/backend/route-operation/put-operation.d.ts +4 -5
- package/es/backend/schemas/index.d.ts +598 -597
- package/es/backend/schemas/index.js +19 -31
- package/es/backend/types.d.ts +14 -8
- package/lib/backend/actions/create-delete-action.d.ts +3 -4
- package/lib/backend/actions/create-get-action.d.ts +2 -3
- package/lib/backend/actions/create-get-list-action.d.ts +2 -3
- package/lib/backend/actions/create-post-action.d.ts +4 -4
- package/lib/backend/actions/create-post-action.js +1 -4
- package/lib/backend/actions/create-put-action.d.ts +2 -3
- package/lib/backend/actions/get-list-query.d.ts +4 -12
- package/lib/backend/actions/get-list-query.js +7 -6
- package/lib/backend/route-operation/delete-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-list-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-operation.d.ts +2 -3
- package/lib/backend/route-operation/get-table-name.d.ts +2 -2
- package/lib/backend/route-operation/post-operation.d.ts +5 -5
- package/lib/backend/route-operation/put-operation.d.ts +4 -5
- package/lib/backend/schemas/index.d.ts +598 -597
- package/lib/backend/schemas/index.js +21 -21
- package/lib/backend/types.d.ts +14 -8
- package/package.json +1 -1
|
@@ -5,44 +5,35 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import {
|
|
8
|
+
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
9
9
|
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
10
|
|
|
11
11
|
//============================基本字段============================//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
// SQLite / D1:用 text 存 ISO 时间戳,用 text 存 uuid(crypto.randomUUID())
|
|
13
|
+
var timestamp = function timestamp(name) {
|
|
14
|
+
return text(name).$defaultFn(function () {
|
|
15
|
+
return new Date().toISOString();
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
|
-
var createdAt = function createdAt() {
|
|
18
|
-
return timestamptz("created_at").notNull().defaultNow();
|
|
19
|
-
};
|
|
20
|
-
var updatedAt = function updatedAt() {
|
|
21
|
-
return timestamptz("updated_at").notNull().defaultNow();
|
|
22
|
-
};
|
|
23
|
-
var accessedAt = function accessedAt() {
|
|
24
|
-
return timestamptz("accessed_at").notNull().defaultNow();
|
|
25
|
-
};
|
|
26
18
|
export var basicFields = {
|
|
27
|
-
id:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
id: text("id").primaryKey().$defaultFn(function () {
|
|
20
|
+
return crypto.randomUUID();
|
|
21
|
+
}),
|
|
22
|
+
creatorId: text("creator_id"),
|
|
23
|
+
editorId: text("editor_id"),
|
|
24
|
+
accessedAt: timestamp("accessed_at").notNull(),
|
|
25
|
+
createdAt: timestamp("created_at").notNull(),
|
|
26
|
+
updatedAt: timestamp("updated_at").notNull()
|
|
33
27
|
};
|
|
28
|
+
export { integer, text };
|
|
34
29
|
|
|
35
30
|
//============================列表查询字段============================//
|
|
36
31
|
export var queryListSchema = function queryListSchema(schema) {
|
|
37
32
|
return z.object({
|
|
38
33
|
current: z.string().optional().default("1"),
|
|
39
|
-
// 默认页码为 1
|
|
40
34
|
pageSize: z.string().optional().default("10"),
|
|
41
|
-
// 默认每页条数为 10
|
|
42
35
|
createdAtFrom: z.string().optional(),
|
|
43
|
-
// 筛选开始日期
|
|
44
36
|
createdAtTo: z.string().optional(),
|
|
45
|
-
// 筛选结束日期
|
|
46
37
|
orderBy: z.string().optional(),
|
|
47
38
|
creatorId: z.string().optional(),
|
|
48
39
|
orderDir: z.enum(["asc", "desc"]).optional()
|
|
@@ -57,20 +48,17 @@ export var listBodySchema = function listBodySchema(schema) {
|
|
|
57
48
|
});
|
|
58
49
|
};
|
|
59
50
|
|
|
60
|
-
//============================创建一个
|
|
51
|
+
//============================创建一个 SQLite 表(D1)============================//
|
|
61
52
|
export var createTableSchema = function createTableSchema(_ref) {
|
|
62
53
|
var name = _ref.name,
|
|
63
54
|
columns = _ref.columns,
|
|
64
55
|
refineSchema = _ref.refineSchema,
|
|
65
56
|
extraConfig = _ref.extraConfig;
|
|
66
|
-
|
|
67
|
-
var table = pgTable(name, _objectSpread(_objectSpread({}, basicFields), columns), extraConfig);
|
|
68
|
-
// 创建基础的schema
|
|
57
|
+
var table = sqliteTable(name, _objectSpread(_objectSpread({}, basicFields), columns), extraConfig);
|
|
69
58
|
var selectSchema = createSelectSchema(table, refineSchema);
|
|
70
|
-
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
id: uuid()
|
|
59
|
+
var insertTable = sqliteTable(name, columns);
|
|
60
|
+
var updateTable = sqliteTable(name, _objectSpread({
|
|
61
|
+
id: text("id")
|
|
74
62
|
}, columns));
|
|
75
63
|
return {
|
|
76
64
|
table: table,
|
package/es/backend/types.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SQLiteColumn, SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
2
2
|
import { SQL } from "drizzle-orm";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
/**
|
|
4
|
+
* 对底层 drizzle 数据库实例做最宽松的约束:
|
|
5
|
+
* 只要能 `select / insert / update / delete` 并支持 drizzle 语法即可,
|
|
6
|
+
* 从而允许在不同 driver(如 drizzle-orm/d1)之间切换。
|
|
7
|
+
*/
|
|
8
|
+
export type AnyDatabase = any;
|
|
9
|
+
export interface BaseTable extends SQLiteTable {
|
|
10
|
+
id: SQLiteColumn;
|
|
11
|
+
creatorId: SQLiteColumn;
|
|
12
|
+
editorId: SQLiteColumn;
|
|
13
|
+
accessedAt: SQLiteColumn;
|
|
14
|
+
createdAt: SQLiteColumn;
|
|
15
|
+
updatedAt: SQLiteColumn;
|
|
10
16
|
}
|
|
11
17
|
export type GetListRelations = {
|
|
12
18
|
groupBy?: boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseTable } from "../types";
|
|
1
|
+
import { BaseTable, AnyDatabase } from "../types";
|
|
3
2
|
export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
|
|
4
|
-
db:
|
|
3
|
+
db: AnyDatabase;
|
|
5
4
|
table: TTable;
|
|
6
5
|
}): ({ id, creatorId }: {
|
|
7
6
|
id: string;
|
|
8
7
|
creatorId?: string | undefined;
|
|
9
|
-
}) => Promise<
|
|
8
|
+
}) => Promise<any>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
+
import { BaseTable, GetListRelations, AnyDatabase } from "../types";
|
|
4
3
|
export declare function createGetAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
4
|
bodySchema: T;
|
|
6
|
-
db:
|
|
5
|
+
db: AnyDatabase;
|
|
7
6
|
jsonArrayFields?: string[];
|
|
8
7
|
relations?: GetListRelations;
|
|
9
8
|
table: TTable;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
3
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
import { BaseTable, GetListRelations, AnyDatabase } from "../types";
|
|
4
3
|
export declare function createGetListAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
5
4
|
bodySchema: T;
|
|
6
|
-
db:
|
|
5
|
+
db: AnyDatabase;
|
|
7
6
|
jsonArrayFields?: string[];
|
|
8
7
|
relations?: GetListRelations;
|
|
9
8
|
table: TTable;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare function createPostAction<T extends ZodSchema, TTable extends
|
|
2
|
+
import { AnyDatabase } from "../types";
|
|
3
|
+
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
4
|
+
export declare function createPostAction<T extends ZodSchema, TTable extends SQLiteTable>({ table, db }: {
|
|
5
5
|
bodySchema: T;
|
|
6
|
-
db:
|
|
6
|
+
db: AnyDatabase;
|
|
7
7
|
table: TTable;
|
|
8
8
|
}): (body: z.infer<T>) => Promise<z.infer<T>[]>;
|
|
@@ -23,10 +23,7 @@ __export(create_post_action_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(create_post_action_exports);
|
|
25
25
|
var import_transform_body = require("./transform-body");
|
|
26
|
-
function createPostAction({
|
|
27
|
-
table,
|
|
28
|
-
db
|
|
29
|
-
}) {
|
|
26
|
+
function createPostAction({ table, db }) {
|
|
30
27
|
return async (body) => {
|
|
31
28
|
const values = (0, import_transform_body.transformBody)(body);
|
|
32
29
|
const result = await db.insert(table).values(values).returning();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseTable } from "../types";
|
|
2
|
+
import { BaseTable, AnyDatabase } from "../types";
|
|
4
3
|
export declare function createPutAction<T extends ZodSchema, TTable extends BaseTable>({ db, table, }: {
|
|
5
4
|
bodySchema: T;
|
|
6
|
-
db:
|
|
5
|
+
db: AnyDatabase;
|
|
7
6
|
table: TTable;
|
|
8
7
|
}): (body: Partial<z.infer<T>> & Record<string, unknown>, { byCreator, }?: {
|
|
9
8
|
byCreator?: boolean | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
-
import { SelectedFields } from "drizzle-orm/
|
|
3
|
-
import { SQL } from "drizzle-orm";
|
|
4
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
1
|
+
import { BaseTable, GetListRelations, AnyDatabase } from "../types";
|
|
2
|
+
import { SelectedFields } from "drizzle-orm/sqlite-core/query-builders/select.types";
|
|
5
3
|
export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, relations, table, }: {
|
|
6
|
-
db:
|
|
4
|
+
db: AnyDatabase;
|
|
7
5
|
fields: TSelection;
|
|
8
6
|
jsonArrayFields?: string[];
|
|
9
7
|
params: {
|
|
@@ -16,12 +14,6 @@ export declare function getListQuery<TTable extends BaseTable, TSelection extend
|
|
|
16
14
|
relations?: GetListRelations;
|
|
17
15
|
table: TTable;
|
|
18
16
|
}): {
|
|
19
|
-
countQuery:
|
|
20
|
-
count: SQL<unknown>;
|
|
21
|
-
}, "partial", Record<string, "not-null">, false, "where", {
|
|
22
|
-
count: unknown;
|
|
23
|
-
}[], {
|
|
24
|
-
count: import("drizzle-orm").DrizzleTypeError<"You cannot reference this field without assigning it an alias first - use `.as(<alias>)`">;
|
|
25
|
-
}>, "where">;
|
|
17
|
+
countQuery: any;
|
|
26
18
|
query: any;
|
|
27
19
|
};
|
|
@@ -23,6 +23,7 @@ __export(get_list_query_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(get_list_query_exports);
|
|
25
25
|
var import_drizzle_orm = require("drizzle-orm");
|
|
26
|
+
var ciLike = (col, value) => import_drizzle_orm.sql`LOWER(${col}) LIKE ${value.toLowerCase()}`;
|
|
26
27
|
function getListQuery({
|
|
27
28
|
db,
|
|
28
29
|
fields,
|
|
@@ -71,8 +72,8 @@ function getListQuery({
|
|
|
71
72
|
conditions2.push(
|
|
72
73
|
import_drizzle_orm.sql`
|
|
73
74
|
EXISTS (
|
|
74
|
-
SELECT 1 FROM
|
|
75
|
-
WHERE
|
|
75
|
+
SELECT 1 FROM json_each(${targetColumn})
|
|
76
|
+
WHERE LOWER(json_each.value) LIKE ${`%${values[0]}%`}
|
|
76
77
|
)
|
|
77
78
|
`
|
|
78
79
|
);
|
|
@@ -81,7 +82,7 @@ function getListQuery({
|
|
|
81
82
|
} else {
|
|
82
83
|
conditions2.push(
|
|
83
84
|
(0, import_drizzle_orm.or)(
|
|
84
|
-
...values.map((v) => (
|
|
85
|
+
...values.map((v) => ciLike(targetColumn, `%${v}%`))
|
|
85
86
|
)
|
|
86
87
|
);
|
|
87
88
|
}
|
|
@@ -91,15 +92,15 @@ function getListQuery({
|
|
|
91
92
|
conditions2.push(
|
|
92
93
|
import_drizzle_orm.sql`
|
|
93
94
|
EXISTS (
|
|
94
|
-
SELECT 1 FROM
|
|
95
|
-
WHERE
|
|
95
|
+
SELECT 1 FROM json_each(${targetColumn})
|
|
96
|
+
WHERE LOWER(json_each.value) LIKE ${`%${value}%`}
|
|
96
97
|
)
|
|
97
98
|
`
|
|
98
99
|
);
|
|
99
100
|
} else if (isIdField) {
|
|
100
101
|
conditions2.push((0, import_drizzle_orm.eq)(targetColumn, value));
|
|
101
102
|
} else {
|
|
102
|
-
conditions2.push((
|
|
103
|
+
conditions2.push(ciLike(targetColumn, `%${value}%`));
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
} else {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TypedNextResponse } from "next-rest-framework";
|
|
2
|
-
import { BaseTable } from "../types";
|
|
3
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
import { BaseTable, AnyDatabase } from "../types";
|
|
4
3
|
import { NextRequest } from "next/server";
|
|
5
4
|
export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
6
5
|
table: TTable;
|
|
@@ -10,7 +9,7 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
10
9
|
byCreator?: boolean;
|
|
11
10
|
}
|
|
12
11
|
export declare const createDeleteOperation: ({ db, getSession, }: {
|
|
13
|
-
db:
|
|
12
|
+
db: AnyDatabase;
|
|
14
13
|
getSession: (req: NextRequest) => Promise<{
|
|
15
14
|
userId?: string;
|
|
16
15
|
} | undefined>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
|
-
import {
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
4
|
+
import { BaseTable, GetListRelations, AnyDatabase } from "../types";
|
|
6
5
|
export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
6
|
bodySchema: T;
|
|
8
7
|
jsonArrayFields?: string[];
|
|
@@ -22,7 +21,7 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
22
21
|
onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
23
22
|
}
|
|
24
23
|
export declare const createGetListOperation: ({ db, getSession, }: {
|
|
25
|
-
db:
|
|
24
|
+
db: AnyDatabase;
|
|
26
25
|
getSession: (req: NextRequest) => Promise<{
|
|
27
26
|
userId?: string;
|
|
28
27
|
} | undefined>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
2
|
import { NextRequest } from "next/server";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
|
-
import {
|
|
5
|
-
import { BaseTable, GetListRelations } from "../types";
|
|
4
|
+
import { BaseTable, GetListRelations, AnyDatabase } from "../types";
|
|
6
5
|
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
7
6
|
bodySchema: T;
|
|
8
7
|
jsonArrayFields?: string[];
|
|
@@ -16,7 +15,7 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
16
15
|
byCreator?: boolean;
|
|
17
16
|
}
|
|
18
17
|
export declare const createGetOperation: ({ getSession, db, }: {
|
|
19
|
-
db:
|
|
18
|
+
db: AnyDatabase;
|
|
20
19
|
getSession: (req: NextRequest) => Promise<{
|
|
21
20
|
userId?: string;
|
|
22
21
|
} | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function getTableName(table:
|
|
1
|
+
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
2
|
+
declare function getTableName(table: SQLiteTable): string;
|
|
3
3
|
export default getTableName;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { AnyDatabase } from "../types";
|
|
3
|
+
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
3
4
|
import { NextRequest } from "next/server";
|
|
4
5
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
5
|
-
|
|
6
|
-
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
6
|
+
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
7
7
|
bodySchema: IB;
|
|
8
8
|
outputBodySchema?: IB;
|
|
9
9
|
setBody?: (req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
@@ -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:
|
|
16
|
+
db: AnyDatabase;
|
|
17
17
|
getSession: (req: NextRequest) => Promise<{
|
|
18
18
|
userId?: string;
|
|
19
19
|
} | undefined>;
|
|
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
|
|
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 SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>>({ bodySchema, outputBodySchema, setBody, summary, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
|
-
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
4
|
import { NextRequest } from "next/server";
|
|
6
|
-
import { BaseTable } from "../types";
|
|
7
|
-
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends
|
|
5
|
+
import { BaseTable, AnyDatabase } from "../types";
|
|
6
|
+
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
8
7
|
bodySchema: IB;
|
|
9
8
|
outputBodySchema?: OB;
|
|
10
9
|
table: TTable;
|
|
@@ -18,5 +17,5 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
18
17
|
getSession: (req: NextRequest) => Promise<{
|
|
19
18
|
userId?: string;
|
|
20
19
|
} | undefined>;
|
|
21
|
-
db:
|
|
20
|
+
db: AnyDatabase;
|
|
22
21
|
}) => <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">;
|