@ai0x0/utils 0.0.17 → 0.0.18
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 +4 -3
- package/es/backend/actions/create-get-action.d.ts +3 -2
- package/es/backend/actions/create-get-list-action.d.ts +3 -2
- package/es/backend/actions/create-post-action.d.ts +4 -4
- package/es/backend/actions/create-put-action.d.ts +3 -2
- package/es/backend/actions/get-list-query.d.ts +12 -4
- package/es/backend/actions/get-list-query.js +8 -11
- package/es/backend/route-operation/delete-operation.d.ts +3 -2
- package/es/backend/route-operation/get-list-operation.d.ts +3 -2
- package/es/backend/route-operation/get-operation.d.ts +3 -2
- 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 +5 -4
- package/es/backend/schemas/index.d.ts +597 -598
- package/es/backend/schemas/index.js +31 -19
- package/es/backend/types.d.ts +8 -14
- package/lib/backend/actions/create-delete-action.d.ts +4 -3
- package/lib/backend/actions/create-get-action.d.ts +3 -2
- package/lib/backend/actions/create-get-list-action.d.ts +3 -2
- package/lib/backend/actions/create-post-action.d.ts +4 -4
- package/lib/backend/actions/create-post-action.js +4 -1
- package/lib/backend/actions/create-put-action.d.ts +3 -2
- package/lib/backend/actions/get-list-query.d.ts +12 -4
- package/lib/backend/actions/get-list-query.js +6 -7
- package/lib/backend/route-operation/delete-operation.d.ts +3 -2
- package/lib/backend/route-operation/get-list-operation.d.ts +3 -2
- package/lib/backend/route-operation/get-operation.d.ts +3 -2
- 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 +5 -4
- package/lib/backend/schemas/index.d.ts +597 -598
- package/lib/backend/schemas/index.js +21 -21
- package/lib/backend/types.d.ts +8 -14
- package/package.json +1 -1
|
@@ -5,35 +5,44 @@ 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 { pgTable, timestamp, uuid } from "drizzle-orm/pg-core";
|
|
9
9
|
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
10
10
|
|
|
11
11
|
//============================基本字段============================//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return new Date().toISOString();
|
|
12
|
+
var timestamptz = function timestamptz(name) {
|
|
13
|
+
return timestamp(name, {
|
|
14
|
+
withTimezone: true
|
|
16
15
|
});
|
|
17
16
|
};
|
|
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
|
+
};
|
|
18
26
|
export var basicFields = {
|
|
19
|
-
id:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
createdAt: timestamp("created_at").notNull(),
|
|
26
|
-
updatedAt: timestamp("updated_at").notNull()
|
|
27
|
+
id: uuid("id").defaultRandom().primaryKey(),
|
|
28
|
+
creatorId: uuid("creator_id"),
|
|
29
|
+
editorId: uuid("editor_id"),
|
|
30
|
+
accessedAt: accessedAt(),
|
|
31
|
+
createdAt: createdAt(),
|
|
32
|
+
updatedAt: updatedAt()
|
|
27
33
|
};
|
|
28
|
-
export { integer, text };
|
|
29
34
|
|
|
30
35
|
//============================列表查询字段============================//
|
|
31
36
|
export var queryListSchema = function queryListSchema(schema) {
|
|
32
37
|
return z.object({
|
|
33
38
|
current: z.string().optional().default("1"),
|
|
39
|
+
// 默认页码为 1
|
|
34
40
|
pageSize: z.string().optional().default("10"),
|
|
41
|
+
// 默认每页条数为 10
|
|
35
42
|
createdAtFrom: z.string().optional(),
|
|
43
|
+
// 筛选开始日期
|
|
36
44
|
createdAtTo: z.string().optional(),
|
|
45
|
+
// 筛选结束日期
|
|
37
46
|
orderBy: z.string().optional(),
|
|
38
47
|
creatorId: z.string().optional(),
|
|
39
48
|
orderDir: z.enum(["asc", "desc"]).optional()
|
|
@@ -48,17 +57,20 @@ export var listBodySchema = function listBodySchema(schema) {
|
|
|
48
57
|
});
|
|
49
58
|
};
|
|
50
59
|
|
|
51
|
-
//============================创建一个
|
|
60
|
+
//============================创建一个pg表============================//
|
|
52
61
|
export var createTableSchema = function createTableSchema(_ref) {
|
|
53
62
|
var name = _ref.name,
|
|
54
63
|
columns = _ref.columns,
|
|
55
64
|
refineSchema = _ref.refineSchema,
|
|
56
65
|
extraConfig = _ref.extraConfig;
|
|
57
|
-
|
|
66
|
+
// 创建表
|
|
67
|
+
var table = pgTable(name, _objectSpread(_objectSpread({}, basicFields), columns), extraConfig);
|
|
68
|
+
// 创建基础的schema
|
|
58
69
|
var selectSchema = createSelectSchema(table, refineSchema);
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
70
|
+
// 去掉基础的字段的table
|
|
71
|
+
var insertTable = pgTable(name, columns);
|
|
72
|
+
var updateTable = pgTable(name, _objectSpread({
|
|
73
|
+
id: uuid()
|
|
62
74
|
}, columns));
|
|
63
75
|
return {
|
|
64
76
|
table: table,
|
package/es/backend/types.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PgColumn, PgTable } from "drizzle-orm/pg-core";
|
|
2
2
|
import { SQL } from "drizzle-orm";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
id: SQLiteColumn;
|
|
11
|
-
creatorId: SQLiteColumn;
|
|
12
|
-
editorId: SQLiteColumn;
|
|
13
|
-
accessedAt: SQLiteColumn;
|
|
14
|
-
createdAt: SQLiteColumn;
|
|
15
|
-
updatedAt: SQLiteColumn;
|
|
3
|
+
export interface BaseTable extends PgTable {
|
|
4
|
+
id: PgColumn;
|
|
5
|
+
creatorId: PgColumn;
|
|
6
|
+
editorId: PgColumn;
|
|
7
|
+
accessedAt: PgColumn;
|
|
8
|
+
createdAt: PgColumn;
|
|
9
|
+
updatedAt: PgColumn;
|
|
16
10
|
}
|
|
17
11
|
export type GetListRelations = {
|
|
18
12
|
groupBy?: boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
import { BaseTable } from "../types";
|
|
2
3
|
export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
|
|
3
|
-
db:
|
|
4
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
4
5
|
table: TTable;
|
|
5
6
|
}): ({ id, creatorId }: {
|
|
6
7
|
id: string;
|
|
7
8
|
creatorId?: string | undefined;
|
|
8
|
-
}) => Promise<
|
|
9
|
+
}) => Promise<TTable["$inferSelect"] extends infer T ? T extends TTable["$inferSelect"] ? T extends undefined ? QueryResult<import("drizzle-orm").Assume<this["row"], QueryResultRow>> : T[] : never : never>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
3
4
|
export declare function createGetAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
4
5
|
bodySchema: T;
|
|
5
|
-
db:
|
|
6
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
6
7
|
jsonArrayFields?: string[];
|
|
7
8
|
relations?: GetListRelations;
|
|
8
9
|
table: TTable;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import { BaseTable, GetListRelations
|
|
2
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
4
|
export declare function createGetListAction<T extends ZodSchema, TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
4
5
|
bodySchema: T;
|
|
5
|
-
db:
|
|
6
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
6
7
|
jsonArrayFields?: string[];
|
|
7
8
|
relations?: GetListRelations;
|
|
8
9
|
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 { PgTable } from "drizzle-orm/pg-core";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
|
+
export declare function createPostAction<T extends ZodSchema, TTable extends PgTable>({ table, db, }: {
|
|
5
5
|
bodySchema: T;
|
|
6
|
-
db:
|
|
6
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
7
7
|
table: TTable;
|
|
8
8
|
}): (body: z.infer<T>) => Promise<z.infer<T>[]>;
|
|
@@ -23,7 +23,10 @@ __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({
|
|
26
|
+
function createPostAction({
|
|
27
|
+
table,
|
|
28
|
+
db
|
|
29
|
+
}) {
|
|
27
30
|
return async (body) => {
|
|
28
31
|
const values = (0, import_transform_body.transformBody)(body);
|
|
29
32
|
const result = await db.insert(table).values(values).returning();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
+
import { BaseTable } from "../types";
|
|
3
4
|
export declare function createPutAction<T extends ZodSchema, TTable extends BaseTable>({ db, table, }: {
|
|
4
5
|
bodySchema: T;
|
|
5
|
-
db:
|
|
6
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
6
7
|
table: TTable;
|
|
7
8
|
}): (body: Partial<z.infer<T>> & Record<string, unknown>, { byCreator, }?: {
|
|
8
9
|
byCreator?: boolean | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { BaseTable, GetListRelations
|
|
2
|
-
import { SelectedFields } from "drizzle-orm/
|
|
1
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
2
|
+
import { SelectedFields } from "drizzle-orm/pg-core/query-builders/select.types";
|
|
3
|
+
import { SQL } from "drizzle-orm";
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
5
|
export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, relations, table, }: {
|
|
4
|
-
db:
|
|
6
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
5
7
|
fields: TSelection;
|
|
6
8
|
jsonArrayFields?: string[];
|
|
7
9
|
params: {
|
|
@@ -14,6 +16,12 @@ export declare function getListQuery<TTable extends BaseTable, TSelection extend
|
|
|
14
16
|
relations?: GetListRelations;
|
|
15
17
|
table: TTable;
|
|
16
18
|
}): {
|
|
17
|
-
countQuery:
|
|
19
|
+
countQuery: Omit<import("drizzle-orm/pg-core").PgSelectBase<string, {
|
|
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">;
|
|
18
26
|
query: any;
|
|
19
27
|
};
|
|
@@ -23,7 +23,6 @@ __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()}`;
|
|
27
26
|
function getListQuery({
|
|
28
27
|
db,
|
|
29
28
|
fields,
|
|
@@ -72,8 +71,8 @@ function getListQuery({
|
|
|
72
71
|
conditions2.push(
|
|
73
72
|
import_drizzle_orm.sql`
|
|
74
73
|
EXISTS (
|
|
75
|
-
SELECT 1 FROM
|
|
76
|
-
WHERE
|
|
74
|
+
SELECT 1 FROM jsonb_array_elements_text(${targetColumn}) tag
|
|
75
|
+
WHERE tag LIKE ${`%${values[0]}%`}
|
|
77
76
|
)
|
|
78
77
|
`
|
|
79
78
|
);
|
|
@@ -82,7 +81,7 @@ function getListQuery({
|
|
|
82
81
|
} else {
|
|
83
82
|
conditions2.push(
|
|
84
83
|
(0, import_drizzle_orm.or)(
|
|
85
|
-
...values.map((v) =>
|
|
84
|
+
...values.map((v) => (0, import_drizzle_orm.ilike)(targetColumn, `%${v}%`))
|
|
86
85
|
)
|
|
87
86
|
);
|
|
88
87
|
}
|
|
@@ -92,15 +91,15 @@ function getListQuery({
|
|
|
92
91
|
conditions2.push(
|
|
93
92
|
import_drizzle_orm.sql`
|
|
94
93
|
EXISTS (
|
|
95
|
-
SELECT 1 FROM
|
|
96
|
-
WHERE
|
|
94
|
+
SELECT 1 FROM jsonb_array_elements_text(${targetColumn}) tag
|
|
95
|
+
WHERE tag LIKE ${`%${value}%`}
|
|
97
96
|
)
|
|
98
97
|
`
|
|
99
98
|
);
|
|
100
99
|
} else if (isIdField) {
|
|
101
100
|
conditions2.push((0, import_drizzle_orm.eq)(targetColumn, value));
|
|
102
101
|
} else {
|
|
103
|
-
conditions2.push(
|
|
102
|
+
conditions2.push((0, import_drizzle_orm.ilike)(targetColumn, `%${value}%`));
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
} else {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypedNextResponse } from "next-rest-framework";
|
|
2
|
-
import { BaseTable
|
|
2
|
+
import { BaseTable } from "../types";
|
|
3
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
4
|
import { NextRequest } from "next/server";
|
|
4
5
|
export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
5
6
|
table: TTable;
|
|
@@ -9,7 +10,7 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
|
|
|
9
10
|
byCreator?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare const createDeleteOperation: ({ db, getSession, }: {
|
|
12
|
-
db:
|
|
13
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
13
14
|
getSession: (req: NextRequest) => Promise<{
|
|
14
15
|
userId?: string;
|
|
15
16
|
} | undefined>;
|
|
@@ -1,7 +1,8 @@
|
|
|
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 {
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
5
6
|
export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
6
7
|
bodySchema: T;
|
|
7
8
|
jsonArrayFields?: string[];
|
|
@@ -21,7 +22,7 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
|
|
|
21
22
|
onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
22
23
|
}
|
|
23
24
|
export declare const createGetListOperation: ({ db, getSession, }: {
|
|
24
|
-
db:
|
|
25
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
25
26
|
getSession: (req: NextRequest) => Promise<{
|
|
26
27
|
userId?: string;
|
|
27
28
|
} | undefined>;
|
|
@@ -1,7 +1,8 @@
|
|
|
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 {
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
|
+
import { BaseTable, GetListRelations } from "../types";
|
|
5
6
|
export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
|
|
6
7
|
bodySchema: T;
|
|
7
8
|
jsonArrayFields?: string[];
|
|
@@ -15,7 +16,7 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
|
|
|
15
16
|
byCreator?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare const createGetOperation: ({ getSession, db, }: {
|
|
18
|
-
db:
|
|
19
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
19
20
|
getSession: (req: NextRequest) => Promise<{
|
|
20
21
|
userId?: string;
|
|
21
22
|
} | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function getTableName(table:
|
|
1
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
2
|
+
declare function getTableName(table: PgTable): string;
|
|
3
3
|
export default getTableName;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
2
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
4
3
|
import { NextRequest } from "next/server";
|
|
5
4
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
6
|
-
|
|
5
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
6
|
+
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
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: NodePgDatabase<Record<string, unknown>>;
|
|
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 PgTable<import("drizzle-orm/pg-core").TableConfig>>({ bodySchema, outputBodySchema, setBody, summary, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z, ZodSchema } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
4
5
|
import { NextRequest } from "next/server";
|
|
5
|
-
import { BaseTable
|
|
6
|
-
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends
|
|
6
|
+
import { BaseTable } from "../types";
|
|
7
|
+
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
7
8
|
bodySchema: IB;
|
|
8
9
|
outputBodySchema?: OB;
|
|
9
10
|
table: TTable;
|
|
@@ -17,5 +18,5 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
17
18
|
getSession: (req: NextRequest) => Promise<{
|
|
18
19
|
userId?: string;
|
|
19
20
|
} | undefined>;
|
|
20
|
-
db:
|
|
21
|
+
db: NodePgDatabase<Record<string, unknown>>;
|
|
21
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">;
|