@ai0x0/utils 0.0.9 → 0.0.11
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/route-operation/post-operation.d.ts +1 -1
- package/es/backend/route-operation/post-operation.js +2 -2
- package/es/backend/route-operation/put-operation.js +2 -2
- package/es/backend/schemas/index.d.ts +899 -3635
- package/es/backend/schemas/index.js +7 -2
- package/lib/backend/route-operation/post-operation.d.ts +1 -1
- package/lib/backend/route-operation/post-operation.js +2 -2
- package/lib/backend/route-operation/put-operation.js +2 -2
- package/lib/backend/schemas/index.d.ts +899 -3635
- package/lib/backend/schemas/index.js +7 -2
- package/package.json +1 -1
|
@@ -66,15 +66,20 @@ export var createTableSchema = function createTableSchema(_ref) {
|
|
|
66
66
|
var table = pgTable(name, _objectSpread(_objectSpread({}, basicFields), columns), extraConfig);
|
|
67
67
|
// 创建基础的schema
|
|
68
68
|
var selectSchema = createSelectSchema(table, refineSchema);
|
|
69
|
+
// 去掉基础的字段的table
|
|
70
|
+
var insertTable = pgTable(name, columns);
|
|
71
|
+
var updateTable = pgTable(name, _objectSpread({
|
|
72
|
+
id: uuid()
|
|
73
|
+
}, columns));
|
|
69
74
|
return {
|
|
70
75
|
table: table,
|
|
71
76
|
selectSchema: selectSchema,
|
|
72
77
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
73
78
|
// @ts-ignore
|
|
74
|
-
insertSchema: createInsertSchema(
|
|
79
|
+
insertSchema: createInsertSchema(insertTable, refineSchema),
|
|
75
80
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
81
|
// @ts-ignore
|
|
77
|
-
updateSchema: createUpdateSchema(
|
|
82
|
+
updateSchema: createUpdateSchema(updateTable, _objectSpread({
|
|
78
83
|
id: z.string()
|
|
79
84
|
}, refineSchema)),
|
|
80
85
|
querySchema: selectSchema.pick({
|
|
@@ -5,7 +5,7 @@ import { TypedNextResponse } from "next-rest-framework";
|
|
|
5
5
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
6
6
|
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
7
7
|
bodySchema: IB;
|
|
8
|
-
outputBodySchema
|
|
8
|
+
outputBodySchema?: IB;
|
|
9
9
|
setBody?: (req: NextRequest) => Promise<Partial<z.infer<IB>>>;
|
|
10
10
|
summary?: string;
|
|
11
11
|
onSuccess?: (data: z.infer<OB>) => Promise<z.infer<OB>>;
|
|
@@ -70,8 +70,8 @@ var createPostOperation = ({
|
|
|
70
70
|
await (setBody == null ? void 0 : setBody(req)) || {}
|
|
71
71
|
);
|
|
72
72
|
let [data] = await (0, import_actions.createPostAction)({ bodySchema, db, table })({
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
creatorId: userId,
|
|
74
|
+
...body
|
|
75
75
|
});
|
|
76
76
|
if (onSuccess) {
|
|
77
77
|
data = await onSuccess(data);
|