@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SQL } from "drizzle-orm";
|
|
2
|
+
import { BaseTable } from "./types.js";
|
|
3
|
+
/** 归属值:单个(等值匹配)或多个(IN)。 */
|
|
4
|
+
export type ScopeValue = string | string[];
|
|
5
|
+
/** 解析完的作用域:限定哪一列、限定成什么值。 */
|
|
6
|
+
export interface ScopeCondition {
|
|
7
|
+
/** 承载归属的列名,如 "creatorId" / "ownerId"。 */
|
|
8
|
+
column: string;
|
|
9
|
+
value: ScopeValue;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 明确表示「这条查询不做行级隔离」。
|
|
13
|
+
*
|
|
14
|
+
* 用一个可辨识的值而不是 undefined:调用方漏传参数时 TypeScript 会报错,而不是悄悄
|
|
15
|
+
* 退化成「查全表」。凡是接受作用域的地方都必须收到 ScopeCondition 或 NO_SCOPE 之一。
|
|
16
|
+
*/
|
|
17
|
+
export declare const NO_SCOPE: null;
|
|
18
|
+
export type ScopeArg = ScopeCondition | typeof NO_SCOPE;
|
|
19
|
+
/** 空作用域值(undefined / 空串 / 空数组)—— 拿到它一律视为「解析失败」,不是「不筛」。 */
|
|
20
|
+
export declare function isEmptyScopeValue(value: ScopeValue | undefined): value is undefined;
|
|
21
|
+
/**
|
|
22
|
+
* 作用域 → drizzle 条件。NO_SCOPE 返回 undefined(调用方据此不加条件)。
|
|
23
|
+
*
|
|
24
|
+
* 列不在表上直接抛:这多半是配错了列名,而一个「配错了就不加条件」的实现等于把配置错误
|
|
25
|
+
* 变成越权漏洞。
|
|
26
|
+
*/
|
|
27
|
+
export declare function scopeCondition(table: BaseTable, scope: ScopeArg): SQL | undefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/backend/scope.ts
|
|
20
|
+
var scope_exports = {};
|
|
21
|
+
__export(scope_exports, {
|
|
22
|
+
NO_SCOPE: () => NO_SCOPE,
|
|
23
|
+
isEmptyScopeValue: () => isEmptyScopeValue,
|
|
24
|
+
scopeCondition: () => scopeCondition
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(scope_exports);
|
|
27
|
+
var import_drizzle_orm = require("drizzle-orm");
|
|
28
|
+
var NO_SCOPE = null;
|
|
29
|
+
function isEmptyScopeValue(value) {
|
|
30
|
+
if (value === void 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return Array.isArray(value) ? value.length === 0 : value.trim() === "";
|
|
34
|
+
}
|
|
35
|
+
function scopeCondition(table, scope) {
|
|
36
|
+
if (scope === NO_SCOPE) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
const column = table[scope.column];
|
|
40
|
+
if (!column) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`作用域列 "${scope.column}" 不在这张表上。检查 access.scope.column 是否写错,或这张表是否真的有归属列。`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (isEmptyScopeValue(scope.value)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`作用域列 "${scope.column}" 拿到的是空值。这不是「不筛」—— 上游应当在解析阶段就拒绝这个请求。`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return Array.isArray(scope.value) ? (0, import_drizzle_orm.inArray)(column, scope.value) : (0, import_drizzle_orm.eq)(column, scope.value);
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
NO_SCOPE,
|
|
55
|
+
isEmptyScopeValue,
|
|
56
|
+
scopeCondition
|
|
57
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BaseTable } from "../types.js";
|
|
2
|
+
import { ScopeArg } from "../../scope.js";
|
|
2
3
|
export declare function createDeleteAction<TTable extends BaseTable>({ table, db, }: {
|
|
3
4
|
db: any;
|
|
4
5
|
table: TTable;
|
|
5
|
-
}): ({ id
|
|
6
|
+
}): ({ id }: {
|
|
6
7
|
id: string;
|
|
7
|
-
|
|
8
|
+
}, { scope }: {
|
|
9
|
+
scope: ScopeArg;
|
|
8
10
|
}) => Promise<any>;
|
|
@@ -23,28 +23,22 @@ __export(create_delete_action_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(create_delete_action_exports);
|
|
25
25
|
var import_drizzle_orm = require("drizzle-orm");
|
|
26
|
-
var
|
|
27
|
-
var import_zod = require("zod");
|
|
26
|
+
var import_scope = require("../../scope");
|
|
28
27
|
var import_errors = require("../errors");
|
|
29
28
|
function createDeleteAction({
|
|
30
29
|
table,
|
|
31
30
|
db
|
|
32
31
|
}) {
|
|
33
|
-
return async ({ id,
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
db,
|
|
37
|
-
table,
|
|
38
|
-
bodySchema: import_zod.z.object({
|
|
39
|
-
creatorId: import_zod.z.string(),
|
|
40
|
-
id: import_zod.z.string()
|
|
41
|
-
})
|
|
42
|
-
})({ creatorId, id });
|
|
43
|
-
if (!data) {
|
|
44
|
-
throw new import_errors.HttpError(404, "未找到删除对象,或没有权限");
|
|
45
|
-
}
|
|
32
|
+
return async ({ id }, { scope }) => {
|
|
33
|
+
if (!id) {
|
|
34
|
+
throw new import_errors.HttpError(400, "缺少 id");
|
|
46
35
|
}
|
|
47
|
-
|
|
36
|
+
const guard = (0, import_scope.scopeCondition)(table, scope);
|
|
37
|
+
const rows = await db.delete(table).where(guard ? (0, import_drizzle_orm.and)((0, import_drizzle_orm.eq)(table.id, id), guard) : (0, import_drizzle_orm.eq)(table.id, id)).returning();
|
|
38
|
+
if (rows.length === 0 && scope !== import_scope.NO_SCOPE) {
|
|
39
|
+
throw new import_errors.HttpError(404, "未找到删除对象,或没有权限");
|
|
40
|
+
}
|
|
41
|
+
return rows;
|
|
48
42
|
};
|
|
49
43
|
}
|
|
50
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScopeArg } from "../../scope.js";
|
|
1
2
|
import { BaseTable, GetListRelations } from "../types.js";
|
|
2
3
|
export declare function createGetAction<TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
3
4
|
bodySchema: any;
|
|
@@ -5,4 +6,6 @@ export declare function createGetAction<TTable extends BaseTable>({ bodySchema,
|
|
|
5
6
|
jsonArrayFields?: string[];
|
|
6
7
|
relations?: GetListRelations;
|
|
7
8
|
table: TTable;
|
|
8
|
-
}): (params: Record<string, unknown
|
|
9
|
+
}): (params: Record<string, unknown>, { scope }: {
|
|
10
|
+
scope: ScopeArg;
|
|
11
|
+
}) => Promise<unknown>;
|
|
@@ -31,7 +31,7 @@ function createGetAction({
|
|
|
31
31
|
relations,
|
|
32
32
|
table
|
|
33
33
|
}) {
|
|
34
|
-
return async (params) => {
|
|
34
|
+
return async (params, { scope }) => {
|
|
35
35
|
const fields = {};
|
|
36
36
|
for (const key of Object.keys(bodySchema.shape)) {
|
|
37
37
|
const field = table[key];
|
|
@@ -44,6 +44,7 @@ function createGetAction({
|
|
|
44
44
|
fields,
|
|
45
45
|
jsonArrayFields,
|
|
46
46
|
params,
|
|
47
|
+
scope,
|
|
47
48
|
relations,
|
|
48
49
|
table
|
|
49
50
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ScopeArg } from "../../scope.js";
|
|
1
2
|
import { BaseTable, GetListRelations } from "../types.js";
|
|
2
3
|
export declare function createGetListAction<TTable extends BaseTable>({ bodySchema, db, jsonArrayFields, relations, table, }: {
|
|
3
4
|
bodySchema: any;
|
|
@@ -5,7 +6,9 @@ export declare function createGetListAction<TTable extends BaseTable>({ bodySche
|
|
|
5
6
|
jsonArrayFields?: string[];
|
|
6
7
|
relations?: GetListRelations;
|
|
7
8
|
table: TTable;
|
|
8
|
-
}): (params: Record<string, unknown
|
|
9
|
+
}): (params: Record<string, unknown>, { scope }: {
|
|
10
|
+
scope: ScopeArg;
|
|
11
|
+
}) => Promise<{
|
|
9
12
|
data: unknown[];
|
|
10
13
|
total: number;
|
|
11
14
|
}>;
|
|
@@ -31,7 +31,7 @@ function createGetListAction({
|
|
|
31
31
|
relations,
|
|
32
32
|
table
|
|
33
33
|
}) {
|
|
34
|
-
return async (params) => {
|
|
34
|
+
return async (params, { scope }) => {
|
|
35
35
|
const { current, pageSize, ...other } = params;
|
|
36
36
|
const fields = {};
|
|
37
37
|
for (const key of Object.keys(bodySchema.shape)) {
|
|
@@ -45,6 +45,7 @@ function createGetListAction({
|
|
|
45
45
|
fields,
|
|
46
46
|
jsonArrayFields,
|
|
47
47
|
params: other,
|
|
48
|
+
scope,
|
|
48
49
|
relations,
|
|
49
50
|
table
|
|
50
51
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BaseTable } from "../types.js";
|
|
2
|
+
import { ScopeArg } from "../../scope.js";
|
|
2
3
|
export declare function createPutAction<TTable extends BaseTable>({ db, table, }: {
|
|
3
4
|
bodySchema: any;
|
|
4
5
|
db: any;
|
|
5
6
|
table: TTable;
|
|
6
|
-
}): (body: Record<string, unknown>, {
|
|
7
|
-
|
|
7
|
+
}): (body: Record<string, unknown>, { scope }: {
|
|
8
|
+
scope: ScopeArg;
|
|
8
9
|
}) => Promise<any>;
|
|
@@ -22,35 +22,24 @@ __export(create_put_action_exports, {
|
|
|
22
22
|
createPutAction: () => createPutAction
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(create_put_action_exports);
|
|
25
|
-
var import_zod = require("zod");
|
|
26
25
|
var import_transform_body = require("./transform-body");
|
|
27
26
|
var import_drizzle_orm = require("drizzle-orm");
|
|
28
|
-
var
|
|
27
|
+
var import_scope = require("../../scope");
|
|
29
28
|
var import_errors = require("../errors");
|
|
30
29
|
function createPutAction({
|
|
31
30
|
db,
|
|
32
31
|
table
|
|
33
32
|
}) {
|
|
34
|
-
return async (body, {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
id: import_zod.z.string()
|
|
44
|
-
})
|
|
45
|
-
})({
|
|
46
|
-
creatorId: body.editorId,
|
|
47
|
-
id: body.id
|
|
48
|
-
});
|
|
49
|
-
if (!data2) {
|
|
50
|
-
throw new import_errors.HttpError(404, "未找到编辑对象,或没有权限");
|
|
51
|
-
}
|
|
33
|
+
return async (body, { scope }) => {
|
|
34
|
+
const id = body.id;
|
|
35
|
+
if (!id) {
|
|
36
|
+
throw new import_errors.HttpError(400, "缺少 id");
|
|
37
|
+
}
|
|
38
|
+
const guard = (0, import_scope.scopeCondition)(table, scope);
|
|
39
|
+
const [data] = await db.update(table).set((0, import_transform_body.transformBody)(body)).where(guard ? (0, import_drizzle_orm.and)((0, import_drizzle_orm.eq)(table.id, id), guard) : (0, import_drizzle_orm.eq)(table.id, id)).returning();
|
|
40
|
+
if (!data && scope !== import_scope.NO_SCOPE) {
|
|
41
|
+
throw new import_errors.HttpError(404, "未找到编辑对象,或没有权限");
|
|
52
42
|
}
|
|
53
|
-
const [data] = await db.update(table).set((0, import_transform_body.transformBody)(body)).where((0, import_drizzle_orm.eq)(table.id, body.id)).returning();
|
|
54
43
|
return data;
|
|
55
44
|
};
|
|
56
45
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { ScopeArg } from "../../scope.js";
|
|
1
2
|
import { BaseTable, GetListRelations } from "../types.js";
|
|
2
3
|
import { SelectedFields } from "drizzle-orm/sqlite-core/query-builders/select.types";
|
|
3
|
-
export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, relations, table, }: {
|
|
4
|
+
export declare function getListQuery<TTable extends BaseTable, TSelection extends SelectedFields>({ db, fields, jsonArrayFields, params, scope, relations, table, }: {
|
|
4
5
|
db: any;
|
|
5
6
|
fields: TSelection;
|
|
6
7
|
jsonArrayFields?: string[];
|
|
8
|
+
/** 必填。与 pg 那套同义,见 backend/scope.ts。 */
|
|
9
|
+
scope: ScopeArg;
|
|
7
10
|
params: {
|
|
8
11
|
[field: string]: unknown;
|
|
9
12
|
orderBy?: keyof BaseTable;
|
|
@@ -22,12 +22,14 @@ __export(get_list_query_exports, {
|
|
|
22
22
|
getListQuery: () => getListQuery
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(get_list_query_exports);
|
|
25
|
+
var import_scope = require("../../scope");
|
|
25
26
|
var import_drizzle_orm = require("drizzle-orm");
|
|
26
27
|
function getListQuery({
|
|
27
28
|
db,
|
|
28
29
|
fields,
|
|
29
30
|
jsonArrayFields,
|
|
30
31
|
params,
|
|
32
|
+
scope,
|
|
31
33
|
relations,
|
|
32
34
|
table
|
|
33
35
|
}) {
|
|
@@ -146,7 +148,9 @@ function getListQuery({
|
|
|
146
148
|
return orderDir2 === "asc" ? (0, import_drizzle_orm.asc)(orderColumn) : (0, import_drizzle_orm.desc)(orderColumn);
|
|
147
149
|
}
|
|
148
150
|
const baseQuery = buildBaseQuery(table, fields, relations);
|
|
149
|
-
const
|
|
151
|
+
const scopeSql = (0, import_scope.scopeCondition)(table, scope);
|
|
152
|
+
const conditions = scopeSql ? [scopeSql] : [];
|
|
153
|
+
conditions.push(...buildConditions(filters, table, relations));
|
|
150
154
|
const query = baseQuery.where(conditions.length > 0 ? (0, import_drizzle_orm.and)(...conditions) : void 0).orderBy(buildOrderBy(table, orderBy, orderDir)).limit(pageSize).offset((page - 1) * pageSize);
|
|
151
155
|
const countQuery = db.select({ count: import_drizzle_orm.sql`COUNT(DISTINCT ${table.id})` }).from(table).where(conditions.length > 0 ? (0, import_drizzle_orm.and)(...conditions) : void 0);
|
|
152
156
|
if (relations == null ? void 0 : relations.length) {
|
|
@@ -10,4 +10,6 @@ export declare const createDeleteOperation: ({ db, getSession, }: {
|
|
|
10
10
|
} | undefined>;
|
|
11
11
|
}) => <B extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>> = import("zod").ZodObject<{
|
|
12
12
|
id: import("zod").ZodString;
|
|
13
|
-
}, import("zod/v4/core").$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: CoreDeleteOperationOptions<BaseTable, B
|
|
13
|
+
}, import("zod/v4/core").$strip>>({ table, schemas, access, openApiOperation, handler, catch: catchHandler, }: CoreDeleteOperationOptions<BaseTable, B, {
|
|
14
|
+
userId?: string | undefined;
|
|
15
|
+
}>) => import("next-rest-framework").RouteOperationDefinition<"DELETE">;
|
|
@@ -8,4 +8,6 @@ export declare const createGetListOperation: ({ db, getSession, }: {
|
|
|
8
8
|
getSession(req: NextRequest): Promise<{
|
|
9
9
|
userId?: string;
|
|
10
10
|
} | undefined>;
|
|
11
|
-
}) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, jsonArrayFields, setParams, handler, catch: catchHandler, }: CoreGetListOperationOptions<T, Q, BaseTable, GetListRelations
|
|
11
|
+
}) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, jsonArrayFields, setParams, handler, catch: catchHandler, }: CoreGetListOperationOptions<T, Q, BaseTable, GetListRelations, {
|
|
12
|
+
userId?: string | undefined;
|
|
13
|
+
}>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
|
|
@@ -8,4 +8,6 @@ export declare const createGetOperation: ({ getSession, db, }: {
|
|
|
8
8
|
getSession(req: NextRequest): Promise<{
|
|
9
9
|
userId?: string;
|
|
10
10
|
} | undefined>;
|
|
11
|
-
}) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, setParams, jsonArrayFields, handler, catch: catchHandler, }: CoreGetOperationOptions<T, Q, BaseTable, GetListRelations
|
|
11
|
+
}) => <T extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, Q extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, table, openApiOperation, relations, setParams, jsonArrayFields, handler, catch: catchHandler, }: CoreGetOperationOptions<T, Q, BaseTable, GetListRelations, {
|
|
12
|
+
userId?: string | undefined;
|
|
13
|
+
}>) => import("next-rest-framework").RouteOperationDefinition<"GET">;
|
|
@@ -8,4 +8,6 @@ export declare const createPostOperation: ({ getSession, db, }: {
|
|
|
8
8
|
getSession(req: NextRequest): Promise<{
|
|
9
9
|
userId?: string;
|
|
10
10
|
} | undefined>;
|
|
11
|
-
}) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, contentType, openApiOperation, parseBody, setBody, table, handler, catch: catchHandler, }: CorePostOperationOptions<IB, OB, SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig
|
|
11
|
+
}) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, contentType, openApiOperation, parseBody, setBody, table, handler, catch: catchHandler, }: CorePostOperationOptions<IB, OB, SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>, {
|
|
12
|
+
userId?: string | undefined;
|
|
13
|
+
}>) => import("next-rest-framework").RouteOperationDefinition<"POST">;
|
|
@@ -8,4 +8,6 @@ export declare const createPutOperation: ({ getSession, db, }: {
|
|
|
8
8
|
userId?: string;
|
|
9
9
|
} | undefined>;
|
|
10
10
|
db?: unknown;
|
|
11
|
-
}) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, openApiOperation, table, setBody, handler, catch: catchHandler, }: CorePutOperationOptions<IB, OB, SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig
|
|
11
|
+
}) => <IB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>, OB extends ZodSchema<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>({ schemas, access, openApiOperation, table, setBody, handler, catch: catchHandler, }: CorePutOperationOptions<IB, OB, SQLiteTable<import("drizzle-orm/sqlite-core").TableConfig>, {
|
|
12
|
+
userId?: string | undefined;
|
|
13
|
+
}>) => import("next-rest-framework").RouteOperationDefinition<"PUT">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai0x0/utils",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "AI0x0 utils",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai0x0"
|
|
@@ -19,6 +19,42 @@
|
|
|
19
19
|
"main": "./lib/index.js",
|
|
20
20
|
"module": "./es/index.js",
|
|
21
21
|
"types": "./lib/index.d.ts",
|
|
22
|
+
"//exports": "调用方写 `@ai0x0/utils/backend`,不要再写 `@ai0x0/utils/es/backend/index.js` —— 那是在指名道姓地引构建产物,等于把「有 es/ 和 lib/ 两套输出」这个内部细节焊进每一个 import。./es/* 与 ./lib/* 两条通配留着只为不打断已有调用方,新代码别用。",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"import": "./es/index.js",
|
|
27
|
+
"default": "./lib/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./backend": {
|
|
30
|
+
"types": "./lib/backend/index.d.ts",
|
|
31
|
+
"import": "./es/backend/index.js",
|
|
32
|
+
"default": "./lib/backend/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./backend/schemas": {
|
|
35
|
+
"types": "./lib/backend/schemas/index.d.ts",
|
|
36
|
+
"import": "./es/backend/schemas/index.js",
|
|
37
|
+
"default": "./lib/backend/schemas/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./backend/sqlite": {
|
|
40
|
+
"types": "./lib/backend/sqlite/index.d.ts",
|
|
41
|
+
"import": "./es/backend/sqlite/index.js",
|
|
42
|
+
"default": "./lib/backend/sqlite/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./backend/sqlite/schemas": {
|
|
45
|
+
"types": "./lib/backend/sqlite/schemas/index.d.ts",
|
|
46
|
+
"import": "./es/backend/sqlite/schemas/index.js",
|
|
47
|
+
"default": "./lib/backend/sqlite/schemas/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./eslint-config": "./eslint-config/index.js",
|
|
50
|
+
"./eslint-rules": "./eslint-rules/index.js",
|
|
51
|
+
"./eslint-rules/*": "./eslint-rules/*",
|
|
52
|
+
"./es/*": "./es/*",
|
|
53
|
+
"./lib/*": "./lib/*",
|
|
54
|
+
"./SKILL.md": "./SKILL.md",
|
|
55
|
+
"./.agents/*": "./.agents/*",
|
|
56
|
+
"./package.json": "./package.json"
|
|
57
|
+
},
|
|
22
58
|
"files": [
|
|
23
59
|
"es",
|
|
24
60
|
"lib",
|
|
@@ -60,6 +96,7 @@
|
|
|
60
96
|
"drizzle-orm": "^0.45.2",
|
|
61
97
|
"drizzle-zod": "^0.8.3",
|
|
62
98
|
"eslint": "9",
|
|
99
|
+
"eslint-config-next": "^16.3.0",
|
|
63
100
|
"eslint-config-prettier": "^10.1.8",
|
|
64
101
|
"eslint-plugin-prettier": "^5.5.5",
|
|
65
102
|
"father": "^4.6.18",
|