@ai0x0/utils 0.0.45 → 0.0.46
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 +3 -1
- package/SKILL.md +3 -1
- package/es/backend/route-operation/post-operation.d.ts +5 -1
- package/es/backend/route-operation/put-operation.d.ts +5 -1
- package/es/backend/sqlite/route-operation/post-operation.d.ts +5 -1
- package/es/backend/sqlite/route-operation/put-operation.d.ts +5 -1
- package/lib/backend/route-operation/post-operation.d.ts +5 -1
- package/lib/backend/route-operation/put-operation.d.ts +5 -1
- package/lib/backend/sqlite/route-operation/post-operation.d.ts +5 -1
- package/lib/backend/sqlite/route-operation/put-operation.d.ts +5 -1
- package/package.json +1 -1
|
@@ -102,6 +102,8 @@ export const getListOperation = createGetListOperation({ db, getSession });
|
|
|
102
102
|
|
|
103
103
|
`postOperation` defaults to `contentType: "application/json"`. Pass `contentType: "multipart/form-data"` to read `await req.formData()` as body, or pass both a custom `contentType` and `parseBody(req)` for custom payload parsing.
|
|
104
104
|
|
|
105
|
+
In `postOperation` and `putOperation`, `onSuccess({ params })` is typed from `bodySchema` plus the injected `creatorId` / `editorId`, so custom action helpers can usually consume `params` directly without reparsing the body schema.
|
|
106
|
+
|
|
105
107
|
`table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
|
|
106
108
|
|
|
107
109
|
## Canonical Examples
|
|
@@ -352,7 +354,7 @@ export const { GET } = route({
|
|
|
352
354
|
|
|
353
355
|
- Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
|
|
354
356
|
- Extra columns on write — `setBody(req) => Promise<Partial<infer<IB>>>` on POST/PUT; returned fields are merged into the body before validation runs against `bodySchema`.
|
|
355
|
-
- Post-processing output — `onSuccess({ params, data, req }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
|
|
357
|
+
- Post-processing output — `onSuccess({ params, data, req }) => Promise<data>`; POST/PUT params are inferred from `bodySchema`, and on GET_LIST `data` is `{ data, total }`.
|
|
356
358
|
- Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
|
|
357
359
|
|
|
358
360
|
## Imports
|
package/SKILL.md
CHANGED
|
@@ -81,6 +81,8 @@ export const getListOperation = createGetListOperation({ db, getSession });
|
|
|
81
81
|
|
|
82
82
|
`postOperation` defaults to `contentType: "application/json"`. Pass `contentType: "multipart/form-data"` to read `await req.formData()` as body, or pass both a custom `contentType` and `parseBody(req)` for custom payload parsing.
|
|
83
83
|
|
|
84
|
+
In `postOperation` and `putOperation`, `onSuccess({ params })` is typed from `bodySchema` plus the injected `creatorId` / `editorId`, so custom action helpers can usually consume `params` directly without reparsing the body schema.
|
|
85
|
+
|
|
84
86
|
`table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
|
|
85
87
|
|
|
86
88
|
## Canonical Examples
|
|
@@ -331,7 +333,7 @@ export const { GET } = route({
|
|
|
331
333
|
|
|
332
334
|
- Extra server-side filters — `setParams(req) => Promise<Record<string, unknown>>` on GET/GET_LIST; returned keys are merged into the filter.
|
|
333
335
|
- Extra columns on write — `setBody(req) => Promise<Partial<infer<IB>>>` on POST/PUT; returned fields are merged into the body before validation runs against `bodySchema`.
|
|
334
|
-
- Post-processing output — `onSuccess({ params, data, req }) => Promise<data>`; on GET_LIST `data` is `{ data, total }`.
|
|
336
|
+
- Post-processing output — `onSuccess({ params, data, req }) => Promise<data>`; POST/PUT params are inferred from `bodySchema`, and on GET_LIST `data` is `{ data, total }`.
|
|
335
337
|
- Error rewriting — `onError(err) => Promise<Response | undefined>`. Return `undefined` to rethrow.
|
|
336
338
|
|
|
337
339
|
## Imports
|
|
@@ -3,6 +3,9 @@ import { PgTable } from "drizzle-orm/pg-core";
|
|
|
3
3
|
import { NextRequest } from "next/server";
|
|
4
4
|
import { TypedNextResponse } from "next-rest-framework";
|
|
5
5
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
6
|
+
type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
7
|
+
creatorId?: string;
|
|
8
|
+
};
|
|
6
9
|
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
7
10
|
bodySchema: IB;
|
|
8
11
|
contentType?: string;
|
|
@@ -13,7 +16,7 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
13
16
|
summary?: string;
|
|
14
17
|
tags?: string[];
|
|
15
18
|
onSuccess?(payload: {
|
|
16
|
-
params:
|
|
19
|
+
params: PostOperationParams<IB>;
|
|
17
20
|
data: z.infer<OB>;
|
|
18
21
|
req: NextRequest;
|
|
19
22
|
}): Promise<z.infer<OB>>;
|
|
@@ -26,3 +29,4 @@ export declare const createPostOperation: ({ getSession, db, }: {
|
|
|
26
29
|
userId?: string;
|
|
27
30
|
} | undefined>;
|
|
28
31
|
}) => <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, contentType, description, outputBodySchema, parseBody, setBody, summary, tags, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
32
|
+
export {};
|
|
@@ -4,6 +4,9 @@ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
5
|
import { NextRequest } from "next/server";
|
|
6
6
|
import { BaseTable } from "../types.js";
|
|
7
|
+
type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
8
|
+
editorId?: string;
|
|
9
|
+
};
|
|
7
10
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
8
11
|
bodySchema: IB;
|
|
9
12
|
description?: string;
|
|
@@ -13,7 +16,7 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
13
16
|
tags?: string[];
|
|
14
17
|
setBody?(req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
15
18
|
onSuccess?(payload: {
|
|
16
|
-
params:
|
|
19
|
+
params: PutOperationParams<IB>;
|
|
17
20
|
data: z.infer<OB>;
|
|
18
21
|
}): Promise<z.infer<OB>>;
|
|
19
22
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
@@ -25,3 +28,4 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
25
28
|
} | undefined>;
|
|
26
29
|
db?: NodePgDatabase<Record<string, unknown>> | undefined;
|
|
27
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 {};
|
|
@@ -2,6 +2,9 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
3
3
|
import { NextRequest } from "next/server";
|
|
4
4
|
import { TypedNextResponse } from "next-rest-framework";
|
|
5
|
+
type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
6
|
+
creatorId?: string;
|
|
7
|
+
};
|
|
5
8
|
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
6
9
|
bodySchema: IB;
|
|
7
10
|
contentType?: string;
|
|
@@ -12,7 +15,7 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
14
17
|
onSuccess?: (_payload: {
|
|
15
|
-
params:
|
|
18
|
+
params: PostOperationParams<IB>;
|
|
16
19
|
data: z.infer<OB>;
|
|
17
20
|
req: NextRequest;
|
|
18
21
|
}) => Promise<z.infer<OB>>;
|
|
@@ -25,3 +28,4 @@ export declare const createPostOperation: ({ getSession, db, }: {
|
|
|
25
28
|
userId?: string;
|
|
26
29
|
} | undefined>;
|
|
27
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 SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>>({ bodySchema, contentType, description, outputBodySchema, parseBody, setBody, summary, tags, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
31
|
+
export {};
|
|
@@ -3,6 +3,9 @@ import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NextRequest } from "next/server";
|
|
5
5
|
import { BaseTable } from "../types.js";
|
|
6
|
+
type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
7
|
+
editorId?: string;
|
|
8
|
+
};
|
|
6
9
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
7
10
|
bodySchema: IB;
|
|
8
11
|
description?: string;
|
|
@@ -12,7 +15,7 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
12
15
|
tags?: string[];
|
|
13
16
|
setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
14
17
|
onSuccess?: (_payload: {
|
|
15
|
-
params:
|
|
18
|
+
params: PutOperationParams<IB>;
|
|
16
19
|
data: z.infer<OB>;
|
|
17
20
|
}) => Promise<z.infer<OB>>;
|
|
18
21
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
@@ -24,3 +27,4 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
24
27
|
} | undefined>;
|
|
25
28
|
db?: any;
|
|
26
29
|
}) => <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">;
|
|
30
|
+
export {};
|
|
@@ -3,6 +3,9 @@ import { PgTable } from "drizzle-orm/pg-core";
|
|
|
3
3
|
import { NextRequest } from "next/server";
|
|
4
4
|
import { TypedNextResponse } from "next-rest-framework";
|
|
5
5
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
6
|
+
type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
7
|
+
creatorId?: string;
|
|
8
|
+
};
|
|
6
9
|
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
7
10
|
bodySchema: IB;
|
|
8
11
|
contentType?: string;
|
|
@@ -13,7 +16,7 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
13
16
|
summary?: string;
|
|
14
17
|
tags?: string[];
|
|
15
18
|
onSuccess?(payload: {
|
|
16
|
-
params:
|
|
19
|
+
params: PostOperationParams<IB>;
|
|
17
20
|
data: z.infer<OB>;
|
|
18
21
|
req: NextRequest;
|
|
19
22
|
}): Promise<z.infer<OB>>;
|
|
@@ -26,3 +29,4 @@ export declare const createPostOperation: ({ getSession, db, }: {
|
|
|
26
29
|
userId?: string;
|
|
27
30
|
} | undefined>;
|
|
28
31
|
}) => <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, contentType, description, outputBodySchema, parseBody, setBody, summary, tags, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
32
|
+
export {};
|
|
@@ -4,6 +4,9 @@ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
|
4
4
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
5
5
|
import { NextRequest } from "next/server";
|
|
6
6
|
import { BaseTable } from "../types.js";
|
|
7
|
+
type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
8
|
+
editorId?: string;
|
|
9
|
+
};
|
|
7
10
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
|
|
8
11
|
bodySchema: IB;
|
|
9
12
|
description?: string;
|
|
@@ -13,7 +16,7 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
13
16
|
tags?: string[];
|
|
14
17
|
setBody?(req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>): Promise<Partial<z.infer<IB>>>;
|
|
15
18
|
onSuccess?(payload: {
|
|
16
|
-
params:
|
|
19
|
+
params: PutOperationParams<IB>;
|
|
17
20
|
data: z.infer<OB>;
|
|
18
21
|
}): Promise<z.infer<OB>>;
|
|
19
22
|
onError?(error: Error): Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
@@ -25,3 +28,4 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
25
28
|
} | undefined>;
|
|
26
29
|
db?: NodePgDatabase<Record<string, unknown>> | undefined;
|
|
27
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 {};
|
|
@@ -2,6 +2,9 @@ import { z, ZodSchema } from "zod";
|
|
|
2
2
|
import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
3
3
|
import { NextRequest } from "next/server";
|
|
4
4
|
import { TypedNextResponse } from "next-rest-framework";
|
|
5
|
+
type PostOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
6
|
+
creatorId?: string;
|
|
7
|
+
};
|
|
5
8
|
export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
6
9
|
bodySchema: IB;
|
|
7
10
|
contentType?: string;
|
|
@@ -12,7 +15,7 @@ export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema
|
|
|
12
15
|
summary?: string;
|
|
13
16
|
tags?: string[];
|
|
14
17
|
onSuccess?: (_payload: {
|
|
15
|
-
params:
|
|
18
|
+
params: PostOperationParams<IB>;
|
|
16
19
|
data: z.infer<OB>;
|
|
17
20
|
req: NextRequest;
|
|
18
21
|
}) => Promise<z.infer<OB>>;
|
|
@@ -25,3 +28,4 @@ export declare const createPostOperation: ({ getSession, db, }: {
|
|
|
25
28
|
userId?: string;
|
|
26
29
|
} | undefined>;
|
|
27
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 SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>>({ bodySchema, contentType, description, outputBodySchema, parseBody, setBody, summary, tags, table, onSuccess, onError, }: PostOperationOptions<IB, OB, TTable>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
31
|
+
export {};
|
|
@@ -3,6 +3,9 @@ import { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
|
3
3
|
import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
|
|
4
4
|
import { NextRequest } from "next/server";
|
|
5
5
|
import { BaseTable } from "../types.js";
|
|
6
|
+
type PutOperationParams<IB extends ZodSchema> = z.infer<IB> & Record<string, unknown> & {
|
|
7
|
+
editorId?: string;
|
|
8
|
+
};
|
|
6
9
|
export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends SQLiteTable> {
|
|
7
10
|
bodySchema: IB;
|
|
8
11
|
description?: string;
|
|
@@ -12,7 +15,7 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
|
|
|
12
15
|
tags?: string[];
|
|
13
16
|
setBody?: (_req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
|
|
14
17
|
onSuccess?: (_payload: {
|
|
15
|
-
params:
|
|
18
|
+
params: PutOperationParams<IB>;
|
|
16
19
|
data: z.infer<OB>;
|
|
17
20
|
}) => Promise<z.infer<OB>>;
|
|
18
21
|
onError?: (_error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
|
|
@@ -24,3 +27,4 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
24
27
|
} | undefined>;
|
|
25
28
|
db?: any;
|
|
26
29
|
}) => <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">;
|
|
30
|
+
export {};
|