@aigne/afs-sqlite 1.11.0-beta → 1.11.0-beta.1
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/LICENSE.md +17 -84
- package/README.md +0 -3
- package/dist/actions/built-in.cjs +142 -0
- package/dist/actions/built-in.d.cts +10 -0
- package/dist/actions/built-in.d.cts.map +1 -0
- package/dist/actions/built-in.d.mts +10 -0
- package/dist/actions/built-in.d.mts.map +1 -0
- package/dist/actions/built-in.mjs +143 -0
- package/dist/actions/built-in.mjs.map +1 -0
- package/dist/actions/registry.cjs +91 -0
- package/dist/actions/registry.d.cts +54 -0
- package/dist/actions/registry.d.cts.map +1 -0
- package/dist/actions/registry.d.mts +54 -0
- package/dist/actions/registry.d.mts.map +1 -0
- package/dist/actions/registry.mjs +91 -0
- package/dist/actions/registry.mjs.map +1 -0
- package/dist/actions/types.d.cts +56 -0
- package/dist/actions/types.d.cts.map +1 -0
- package/dist/actions/types.d.mts +56 -0
- package/dist/actions/types.d.mts.map +1 -0
- package/dist/config.cjs +27 -0
- package/dist/config.d.cts +81 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +81 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +28 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.cjs +38 -1324
- package/dist/index.d.cts +14 -758
- package/dist/index.d.mts +14 -758
- package/dist/index.mjs +12 -1299
- package/dist/node/builder.cjs +179 -0
- package/dist/node/builder.d.cts +48 -0
- package/dist/node/builder.d.cts.map +1 -0
- package/dist/node/builder.d.mts +48 -0
- package/dist/node/builder.d.mts.map +1 -0
- package/dist/node/builder.mjs +172 -0
- package/dist/node/builder.mjs.map +1 -0
- package/dist/operations/crud.cjs +176 -0
- package/dist/operations/crud.d.cts +69 -0
- package/dist/operations/crud.d.cts.map +1 -0
- package/dist/operations/crud.d.mts +69 -0
- package/dist/operations/crud.d.mts.map +1 -0
- package/dist/operations/crud.mjs +177 -0
- package/dist/operations/crud.mjs.map +1 -0
- package/dist/operations/query-builder.cjs +77 -0
- package/dist/operations/query-builder.d.cts +34 -0
- package/dist/operations/query-builder.d.cts.map +1 -0
- package/dist/operations/query-builder.d.mts +34 -0
- package/dist/operations/query-builder.d.mts.map +1 -0
- package/dist/operations/query-builder.mjs +72 -0
- package/dist/operations/query-builder.mjs.map +1 -0
- package/dist/operations/search.cjs +141 -0
- package/dist/operations/search.d.cts +79 -0
- package/dist/operations/search.d.cts.map +1 -0
- package/dist/operations/search.d.mts +79 -0
- package/dist/operations/search.d.mts.map +1 -0
- package/dist/operations/search.mjs +141 -0
- package/dist/operations/search.mjs.map +1 -0
- package/dist/router/path-router.cjs +79 -0
- package/dist/router/path-router.d.cts +42 -0
- package/dist/router/path-router.d.cts.map +1 -0
- package/dist/router/path-router.d.mts +42 -0
- package/dist/router/path-router.d.mts.map +1 -0
- package/dist/router/path-router.mjs +76 -0
- package/dist/router/path-router.mjs.map +1 -0
- package/dist/router/types.d.cts +34 -0
- package/dist/router/types.d.cts.map +1 -0
- package/dist/router/types.d.mts +34 -0
- package/dist/router/types.d.mts.map +1 -0
- package/dist/schema/introspector.cjs +160 -0
- package/dist/schema/introspector.d.cts +49 -0
- package/dist/schema/introspector.d.cts.map +1 -0
- package/dist/schema/introspector.d.mts +49 -0
- package/dist/schema/introspector.d.mts.map +1 -0
- package/dist/schema/introspector.mjs +161 -0
- package/dist/schema/introspector.mjs.map +1 -0
- package/dist/schema/types.cjs +15 -0
- package/dist/schema/types.d.cts +104 -0
- package/dist/schema/types.d.cts.map +1 -0
- package/dist/schema/types.d.mts +104 -0
- package/dist/schema/types.d.mts.map +1 -0
- package/dist/schema/types.mjs +15 -0
- package/dist/schema/types.mjs.map +1 -0
- package/dist/sqlite-afs.cjs +264 -0
- package/dist/sqlite-afs.d.cts +152 -0
- package/dist/sqlite-afs.d.cts.map +1 -0
- package/dist/sqlite-afs.d.mts +152 -0
- package/dist/sqlite-afs.d.mts.map +1 -0
- package/dist/sqlite-afs.mjs +265 -0
- package/dist/sqlite-afs.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/actions/registry.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registry for managing action handlers
|
|
4
|
+
*/
|
|
5
|
+
var ActionsRegistry = class {
|
|
6
|
+
handlers = /* @__PURE__ */ new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Registers an action handler
|
|
9
|
+
*/
|
|
10
|
+
register(definition) {
|
|
11
|
+
this.handlers.set(definition.name, definition);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Registers a simple action with just name and handler
|
|
15
|
+
*/
|
|
16
|
+
registerSimple(name, handler, options) {
|
|
17
|
+
this.register({
|
|
18
|
+
name,
|
|
19
|
+
handler,
|
|
20
|
+
description: options?.description,
|
|
21
|
+
tableLevel: options?.tableLevel ?? false,
|
|
22
|
+
rowLevel: options?.rowLevel ?? true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Unregisters an action
|
|
27
|
+
*/
|
|
28
|
+
unregister(name) {
|
|
29
|
+
return this.handlers.delete(name);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if an action is registered
|
|
33
|
+
*/
|
|
34
|
+
has(name) {
|
|
35
|
+
return this.handlers.has(name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets an action definition
|
|
39
|
+
*/
|
|
40
|
+
get(name) {
|
|
41
|
+
return this.handlers.get(name);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Lists all registered actions
|
|
45
|
+
*/
|
|
46
|
+
list(options) {
|
|
47
|
+
const actions = Array.from(this.handlers.values());
|
|
48
|
+
if (options?.tableLevel !== void 0 || options?.rowLevel !== void 0) return actions.filter((a) => {
|
|
49
|
+
if (options.tableLevel && !a.tableLevel) return false;
|
|
50
|
+
if (options.rowLevel && !a.rowLevel) return false;
|
|
51
|
+
return true;
|
|
52
|
+
});
|
|
53
|
+
return actions;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lists action names
|
|
57
|
+
*/
|
|
58
|
+
listNames(options) {
|
|
59
|
+
return this.list(options).map((a) => a.name);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Executes an action
|
|
63
|
+
*/
|
|
64
|
+
async execute(name, ctx, params = {}) {
|
|
65
|
+
const definition = this.handlers.get(name);
|
|
66
|
+
if (!definition) return {
|
|
67
|
+
success: false,
|
|
68
|
+
message: `Unknown action: ${name}`
|
|
69
|
+
};
|
|
70
|
+
if (ctx.pk && !definition.rowLevel) return {
|
|
71
|
+
success: false,
|
|
72
|
+
message: `Action '${name}' is not available at row level`
|
|
73
|
+
};
|
|
74
|
+
if (!ctx.pk && !definition.tableLevel) return {
|
|
75
|
+
success: false,
|
|
76
|
+
message: `Action '${name}' is not available at table level`
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
return await definition.handler(ctx, params);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
message: error instanceof Error ? error.message : String(error)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { ActionsRegistry };
|
|
91
|
+
//# sourceMappingURL=registry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.mjs","names":[],"sources":["../../src/actions/registry.ts"],"sourcesContent":["import type { ActionContext, ActionDefinition, ActionHandler, ActionResult } from \"./types.js\";\n\n/**\n * Registry for managing action handlers\n */\nexport class ActionsRegistry {\n private handlers = new Map<string, ActionDefinition>();\n\n /**\n * Registers an action handler\n */\n register(definition: ActionDefinition): void {\n this.handlers.set(definition.name, definition);\n }\n\n /**\n * Registers a simple action with just name and handler\n */\n registerSimple(\n name: string,\n handler: ActionHandler,\n options?: {\n description?: string;\n tableLevel?: boolean;\n rowLevel?: boolean;\n },\n ): void {\n this.register({\n name,\n handler,\n description: options?.description,\n tableLevel: options?.tableLevel ?? false,\n rowLevel: options?.rowLevel ?? true,\n });\n }\n\n /**\n * Unregisters an action\n */\n unregister(name: string): boolean {\n return this.handlers.delete(name);\n }\n\n /**\n * Checks if an action is registered\n */\n has(name: string): boolean {\n return this.handlers.has(name);\n }\n\n /**\n * Gets an action definition\n */\n get(name: string): ActionDefinition | undefined {\n return this.handlers.get(name);\n }\n\n /**\n * Lists all registered actions\n */\n list(options?: { tableLevel?: boolean; rowLevel?: boolean }): ActionDefinition[] {\n const actions = Array.from(this.handlers.values());\n\n if (options?.tableLevel !== undefined || options?.rowLevel !== undefined) {\n return actions.filter((a) => {\n if (options.tableLevel && !a.tableLevel) return false;\n if (options.rowLevel && !a.rowLevel) return false;\n return true;\n });\n }\n\n return actions;\n }\n\n /**\n * Lists action names\n */\n listNames(options?: { tableLevel?: boolean; rowLevel?: boolean }): string[] {\n return this.list(options).map((a) => a.name);\n }\n\n /**\n * Executes an action\n */\n async execute(\n name: string,\n ctx: ActionContext,\n params: Record<string, unknown> = {},\n ): Promise<ActionResult> {\n const definition = this.handlers.get(name);\n\n if (!definition) {\n return {\n success: false,\n message: `Unknown action: ${name}`,\n };\n }\n\n // Validate action level\n if (ctx.pk && !definition.rowLevel) {\n return {\n success: false,\n message: `Action '${name}' is not available at row level`,\n };\n }\n\n if (!ctx.pk && !definition.tableLevel) {\n return {\n success: false,\n message: `Action '${name}' is not available at table level`,\n };\n }\n\n try {\n return await definition.handler(ctx, params);\n } catch (error) {\n return {\n success: false,\n message: error instanceof Error ? error.message : String(error),\n };\n }\n }\n}\n"],"mappings":";;;;AAKA,IAAa,kBAAb,MAA6B;CAC3B,AAAQ,2BAAW,IAAI,KAA+B;;;;CAKtD,SAAS,YAAoC;AAC3C,OAAK,SAAS,IAAI,WAAW,MAAM,WAAW;;;;;CAMhD,eACE,MACA,SACA,SAKM;AACN,OAAK,SAAS;GACZ;GACA;GACA,aAAa,SAAS;GACtB,YAAY,SAAS,cAAc;GACnC,UAAU,SAAS,YAAY;GAChC,CAAC;;;;;CAMJ,WAAW,MAAuB;AAChC,SAAO,KAAK,SAAS,OAAO,KAAK;;;;;CAMnC,IAAI,MAAuB;AACzB,SAAO,KAAK,SAAS,IAAI,KAAK;;;;;CAMhC,IAAI,MAA4C;AAC9C,SAAO,KAAK,SAAS,IAAI,KAAK;;;;;CAMhC,KAAK,SAA4E;EAC/E,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS,QAAQ,CAAC;AAElD,MAAI,SAAS,eAAe,UAAa,SAAS,aAAa,OAC7D,QAAO,QAAQ,QAAQ,MAAM;AAC3B,OAAI,QAAQ,cAAc,CAAC,EAAE,WAAY,QAAO;AAChD,OAAI,QAAQ,YAAY,CAAC,EAAE,SAAU,QAAO;AAC5C,UAAO;IACP;AAGJ,SAAO;;;;;CAMT,UAAU,SAAkE;AAC1E,SAAO,KAAK,KAAK,QAAQ,CAAC,KAAK,MAAM,EAAE,KAAK;;;;;CAM9C,MAAM,QACJ,MACA,KACA,SAAkC,EAAE,EACb;EACvB,MAAM,aAAa,KAAK,SAAS,IAAI,KAAK;AAE1C,MAAI,CAAC,WACH,QAAO;GACL,SAAS;GACT,SAAS,mBAAmB;GAC7B;AAIH,MAAI,IAAI,MAAM,CAAC,WAAW,SACxB,QAAO;GACL,SAAS;GACT,SAAS,WAAW,KAAK;GAC1B;AAGH,MAAI,CAAC,IAAI,MAAM,CAAC,WAAW,WACzB,QAAO;GACL,SAAS;GACT,SAAS,WAAW,KAAK;GAC1B;AAGH,MAAI;AACF,UAAO,MAAM,WAAW,QAAQ,KAAK,OAAO;WACrC,OAAO;AACd,UAAO;IACL,SAAS;IACT,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAChE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TableSchema } from "../schema/types.cjs";
|
|
2
|
+
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
|
+
|
|
4
|
+
//#region src/actions/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Context provided to action handlers
|
|
7
|
+
*/
|
|
8
|
+
interface ActionContext {
|
|
9
|
+
/** Database instance */
|
|
10
|
+
db: LibSQLDatabase;
|
|
11
|
+
/** All table schemas */
|
|
12
|
+
schemas: Map<string, TableSchema>;
|
|
13
|
+
/** Table this action is being executed on */
|
|
14
|
+
table: string;
|
|
15
|
+
/** Primary key of the row (if row-level action) */
|
|
16
|
+
pk?: string;
|
|
17
|
+
/** The row data (if available) */
|
|
18
|
+
row?: Record<string, unknown>;
|
|
19
|
+
/** Reference to the parent module for advanced operations */
|
|
20
|
+
module: {
|
|
21
|
+
refreshSchema(): Promise<void>;
|
|
22
|
+
exportTable(table: string, format: string): Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Action handler function signature
|
|
27
|
+
*/
|
|
28
|
+
type ActionHandler = (ctx: ActionContext, params: Record<string, unknown>) => Promise<ActionResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Result from an action execution
|
|
31
|
+
*/
|
|
32
|
+
interface ActionResult {
|
|
33
|
+
success: boolean;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
message?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Action definition with metadata
|
|
39
|
+
*/
|
|
40
|
+
interface ActionDefinition {
|
|
41
|
+
/** Action name */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Description of what the action does */
|
|
44
|
+
description?: string;
|
|
45
|
+
/** Whether this action is available at table level (vs row level) */
|
|
46
|
+
tableLevel?: boolean;
|
|
47
|
+
/** Whether this action is available at row level */
|
|
48
|
+
rowLevel?: boolean;
|
|
49
|
+
/** Input schema for the action parameters */
|
|
50
|
+
inputSchema?: Record<string, unknown>;
|
|
51
|
+
/** The handler function */
|
|
52
|
+
handler: ActionHandler;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ActionContext, ActionDefinition, ActionHandler, ActionResult };
|
|
56
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/actions/types.ts"],"mappings":";;;;;AAMA;;UAAiB,aAAA;EAAA;EAAA,EAAA,EAEX,cAAA;EAAA;EAAA,OAAA,EAEK,GAAA,SAAY,WAAA;EAAA;EAAA,KAAA;EAAA;EAAA,EAAA;EAAA;EAAA,GAAA,GAMf,MAAA;EAAA;EAAA,MAAA;IAAA,aAAA,IAGa,OAAA;IAAA,WAAA,CAAA,KAAA,UAAA,MAAA,WAC2B,OAAA;EAAA;AAAA;AAAA;;AAOhD;AAPgD,KAOpC,aAAA,IAAA,GAAA,EACL,aAAA,EAAA,MAAA,EACG,MAAA,sBACL,OAAA,CAAQ,YAAA;AAAA;;;AAAA,UAKI,YAAA;EAAA,OAAA;EAAA,IAAA;EAAA,OAAA;AAAA;AAAA;AASjB;;AATiB,UASA,gBAAA;EAAA;EAAA,IAAA;EAAA;EAAA,WAAA;EAAA;EAAA,UAAA;EAAA;EAAA,QAAA;EAAA;EAAA,WAAA,GAUD,MAAA;EAAA;EAAA,OAAA,EAEL,aAAA;AAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TableSchema } from "../schema/types.mjs";
|
|
2
|
+
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
|
+
|
|
4
|
+
//#region src/actions/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Context provided to action handlers
|
|
7
|
+
*/
|
|
8
|
+
interface ActionContext {
|
|
9
|
+
/** Database instance */
|
|
10
|
+
db: LibSQLDatabase;
|
|
11
|
+
/** All table schemas */
|
|
12
|
+
schemas: Map<string, TableSchema>;
|
|
13
|
+
/** Table this action is being executed on */
|
|
14
|
+
table: string;
|
|
15
|
+
/** Primary key of the row (if row-level action) */
|
|
16
|
+
pk?: string;
|
|
17
|
+
/** The row data (if available) */
|
|
18
|
+
row?: Record<string, unknown>;
|
|
19
|
+
/** Reference to the parent module for advanced operations */
|
|
20
|
+
module: {
|
|
21
|
+
refreshSchema(): Promise<void>;
|
|
22
|
+
exportTable(table: string, format: string): Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Action handler function signature
|
|
27
|
+
*/
|
|
28
|
+
type ActionHandler = (ctx: ActionContext, params: Record<string, unknown>) => Promise<ActionResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Result from an action execution
|
|
31
|
+
*/
|
|
32
|
+
interface ActionResult {
|
|
33
|
+
success: boolean;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
message?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Action definition with metadata
|
|
39
|
+
*/
|
|
40
|
+
interface ActionDefinition {
|
|
41
|
+
/** Action name */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Description of what the action does */
|
|
44
|
+
description?: string;
|
|
45
|
+
/** Whether this action is available at table level (vs row level) */
|
|
46
|
+
tableLevel?: boolean;
|
|
47
|
+
/** Whether this action is available at row level */
|
|
48
|
+
rowLevel?: boolean;
|
|
49
|
+
/** Input schema for the action parameters */
|
|
50
|
+
inputSchema?: Record<string, unknown>;
|
|
51
|
+
/** The handler function */
|
|
52
|
+
handler: ActionHandler;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { ActionContext, ActionDefinition, ActionHandler, ActionResult };
|
|
56
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/actions/types.ts"],"mappings":";;;;;AAMA;;UAAiB,aAAA;EAAA;EAAA,EAAA,EAEX,cAAA;EAAA;EAAA,OAAA,EAEK,GAAA,SAAY,WAAA;EAAA;EAAA,KAAA;EAAA;EAAA,EAAA;EAAA;EAAA,GAAA,GAMf,MAAA;EAAA;EAAA,MAAA;IAAA,aAAA,IAGa,OAAA;IAAA,WAAA,CAAA,KAAA,UAAA,MAAA,WAC2B,OAAA;EAAA;AAAA;AAAA;;AAOhD;AAPgD,KAOpC,aAAA,IAAA,GAAA,EACL,aAAA,EAAA,MAAA,EACG,MAAA,sBACL,OAAA,CAAQ,YAAA;AAAA;;;AAAA,UAKI,YAAA;EAAA,OAAA;EAAA,IAAA;EAAA,OAAA;AAAA;AAAA;AASjB;;AATiB,UASA,gBAAA;EAAA;EAAA,IAAA;EAAA;EAAA,WAAA;EAAA;EAAA,UAAA;EAAA;EAAA,QAAA;EAAA;EAAA,WAAA,GAUD,MAAA;EAAA;EAAA,OAAA,EAEL,aAAA;AAAA"}
|
package/dist/config.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
let _aigne_afs = require("@aigne/afs");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
|
|
4
|
+
//#region src/config.ts
|
|
5
|
+
/**
|
|
6
|
+
* FTS (Full-Text Search) configuration schema
|
|
7
|
+
*/
|
|
8
|
+
const ftsConfigSchema = zod.z.object({
|
|
9
|
+
enabled: zod.z.boolean().default(true).describe("Whether FTS is enabled"),
|
|
10
|
+
tables: zod.z.record(zod.z.array(zod.z.string())).optional().describe("Map of table name to columns to index for FTS")
|
|
11
|
+
}).optional();
|
|
12
|
+
/**
|
|
13
|
+
* SQLite AFS module configuration schema
|
|
14
|
+
*/
|
|
15
|
+
const sqliteAFSConfigSchema = zod.z.object({
|
|
16
|
+
url: zod.z.string().describe("SQLite database URL (file:./path or :memory:)"),
|
|
17
|
+
name: zod.z.string().optional().describe("Module name, defaults to 'sqlite-afs'"),
|
|
18
|
+
description: zod.z.string().optional().describe("Description of this module"),
|
|
19
|
+
accessMode: _aigne_afs.accessModeSchema,
|
|
20
|
+
tables: zod.z.array(zod.z.string()).optional().describe("Whitelist of tables to expose (if not specified, all tables are exposed)"),
|
|
21
|
+
excludeTables: zod.z.array(zod.z.string()).optional().describe("Tables to exclude from exposure"),
|
|
22
|
+
fts: ftsConfigSchema,
|
|
23
|
+
wal: zod.z.boolean().optional().default(true).describe("Enable WAL mode for better concurrency")
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.sqliteAFSConfigSchema = sqliteAFSConfigSchema;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AFSAccessMode } from "@aigne/afs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* SQLite AFS module configuration schema
|
|
7
|
+
*/
|
|
8
|
+
declare const sqliteAFSConfigSchema: z.ZodObject<{
|
|
9
|
+
url: z.ZodString;
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
13
|
+
tables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
excludeTables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
fts: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
tables?: Record<string, string[]> | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
tables?: Record<string, string[]> | undefined;
|
|
23
|
+
enabled?: boolean | undefined;
|
|
24
|
+
}>>;
|
|
25
|
+
wal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
url: string;
|
|
28
|
+
wal: boolean;
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
32
|
+
tables?: string[] | undefined;
|
|
33
|
+
excludeTables?: string[] | undefined;
|
|
34
|
+
fts?: {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
tables?: Record<string, string[]> | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
url: string;
|
|
40
|
+
name?: string | undefined;
|
|
41
|
+
description?: string | undefined;
|
|
42
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
43
|
+
tables?: string[] | undefined;
|
|
44
|
+
excludeTables?: string[] | undefined;
|
|
45
|
+
fts?: {
|
|
46
|
+
tables?: Record<string, string[]> | undefined;
|
|
47
|
+
enabled?: boolean | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
wal?: boolean | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* SQLite AFS module configuration type
|
|
53
|
+
*/
|
|
54
|
+
type SQLiteAFSConfig = z.infer<typeof sqliteAFSConfigSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* SQLite AFS module options (after parsing)
|
|
57
|
+
*/
|
|
58
|
+
interface SQLiteAFSOptions {
|
|
59
|
+
/** SQLite database URL */
|
|
60
|
+
url: string;
|
|
61
|
+
/** Module name */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Module description */
|
|
64
|
+
description?: string;
|
|
65
|
+
/** Access mode */
|
|
66
|
+
accessMode?: AFSAccessMode;
|
|
67
|
+
/** Tables to expose */
|
|
68
|
+
tables?: string[];
|
|
69
|
+
/** Tables to exclude */
|
|
70
|
+
excludeTables?: string[];
|
|
71
|
+
/** FTS configuration */
|
|
72
|
+
fts?: {
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
tables?: Record<string, string[]>;
|
|
75
|
+
};
|
|
76
|
+
/** Enable WAL mode */
|
|
77
|
+
wal?: boolean;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { SQLiteAFSConfig, SQLiteAFSOptions, sqliteAFSConfigSchema };
|
|
81
|
+
//# sourceMappingURL=config.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;AAmBA;;cAAa,qBAAA,EAAqB,CAAA,CAAA,SAAA;EAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBtB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,qBAAA;AAAA;AAK7C;;AAL6C,UAK5B,gBAAA;EAAA;EAAA,GAAA;EAAA;EAAA,IAAA;EAAA;EAAA,WAAA;EAAA;EAAA,UAAA,GAQF,aAAA;EAAA;EAAA,MAAA;EAAA;EAAA,aAAA;EAAA;EAAA,GAAA;IAAA,OAAA;IAAA,MAAA,GAQF,MAAA;EAAA;EAAA;EAAA,GAAA;AAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AFSAccessMode } from "@aigne/afs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* SQLite AFS module configuration schema
|
|
7
|
+
*/
|
|
8
|
+
declare const sqliteAFSConfigSchema: z.ZodObject<{
|
|
9
|
+
url: z.ZodString;
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
accessMode: z.ZodOptional<z.ZodEnum<["readonly", "readwrite"]>>;
|
|
13
|
+
tables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
+
excludeTables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
fts: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
tables?: Record<string, string[]> | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
tables?: Record<string, string[]> | undefined;
|
|
23
|
+
enabled?: boolean | undefined;
|
|
24
|
+
}>>;
|
|
25
|
+
wal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
url: string;
|
|
28
|
+
wal: boolean;
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
32
|
+
tables?: string[] | undefined;
|
|
33
|
+
excludeTables?: string[] | undefined;
|
|
34
|
+
fts?: {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
tables?: Record<string, string[]> | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
url: string;
|
|
40
|
+
name?: string | undefined;
|
|
41
|
+
description?: string | undefined;
|
|
42
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
43
|
+
tables?: string[] | undefined;
|
|
44
|
+
excludeTables?: string[] | undefined;
|
|
45
|
+
fts?: {
|
|
46
|
+
tables?: Record<string, string[]> | undefined;
|
|
47
|
+
enabled?: boolean | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
wal?: boolean | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* SQLite AFS module configuration type
|
|
53
|
+
*/
|
|
54
|
+
type SQLiteAFSConfig = z.infer<typeof sqliteAFSConfigSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* SQLite AFS module options (after parsing)
|
|
57
|
+
*/
|
|
58
|
+
interface SQLiteAFSOptions {
|
|
59
|
+
/** SQLite database URL */
|
|
60
|
+
url: string;
|
|
61
|
+
/** Module name */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Module description */
|
|
64
|
+
description?: string;
|
|
65
|
+
/** Access mode */
|
|
66
|
+
accessMode?: AFSAccessMode;
|
|
67
|
+
/** Tables to expose */
|
|
68
|
+
tables?: string[];
|
|
69
|
+
/** Tables to exclude */
|
|
70
|
+
excludeTables?: string[];
|
|
71
|
+
/** FTS configuration */
|
|
72
|
+
fts?: {
|
|
73
|
+
enabled?: boolean;
|
|
74
|
+
tables?: Record<string, string[]>;
|
|
75
|
+
};
|
|
76
|
+
/** Enable WAL mode */
|
|
77
|
+
wal?: boolean;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { SQLiteAFSConfig, SQLiteAFSOptions, sqliteAFSConfigSchema };
|
|
81
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;AAmBA;;cAAa,qBAAA,EAAqB,CAAA,CAAA,SAAA;EAAA,GAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiBtB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,qBAAA;AAAA;AAK7C;;AAL6C,UAK5B,gBAAA;EAAA;EAAA,GAAA;EAAA;EAAA,IAAA;EAAA;EAAA,WAAA;EAAA;EAAA,UAAA,GAQF,aAAA;EAAA;EAAA,MAAA;EAAA;EAAA,aAAA;EAAA;EAAA,GAAA;IAAA,OAAA;IAAA,MAAA,GAQF,MAAA;EAAA;EAAA;EAAA,GAAA;AAAA"}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { accessModeSchema } from "@aigne/afs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/config.ts
|
|
5
|
+
/**
|
|
6
|
+
* FTS (Full-Text Search) configuration schema
|
|
7
|
+
*/
|
|
8
|
+
const ftsConfigSchema = z.object({
|
|
9
|
+
enabled: z.boolean().default(true).describe("Whether FTS is enabled"),
|
|
10
|
+
tables: z.record(z.array(z.string())).optional().describe("Map of table name to columns to index for FTS")
|
|
11
|
+
}).optional();
|
|
12
|
+
/**
|
|
13
|
+
* SQLite AFS module configuration schema
|
|
14
|
+
*/
|
|
15
|
+
const sqliteAFSConfigSchema = z.object({
|
|
16
|
+
url: z.string().describe("SQLite database URL (file:./path or :memory:)"),
|
|
17
|
+
name: z.string().optional().describe("Module name, defaults to 'sqlite-afs'"),
|
|
18
|
+
description: z.string().optional().describe("Description of this module"),
|
|
19
|
+
accessMode: accessModeSchema,
|
|
20
|
+
tables: z.array(z.string()).optional().describe("Whitelist of tables to expose (if not specified, all tables are exposed)"),
|
|
21
|
+
excludeTables: z.array(z.string()).optional().describe("Tables to exclude from exposure"),
|
|
22
|
+
fts: ftsConfigSchema,
|
|
23
|
+
wal: z.boolean().optional().default(true).describe("Enable WAL mode for better concurrency")
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { sqliteAFSConfigSchema };
|
|
28
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { type AFSAccessMode, accessModeSchema } from \"@aigne/afs\";\nimport { z } from \"zod\";\n\n/**\n * FTS (Full-Text Search) configuration schema\n */\nexport const ftsConfigSchema = z\n .object({\n enabled: z.boolean().default(true).describe(\"Whether FTS is enabled\"),\n tables: z\n .record(z.array(z.string()))\n .optional()\n .describe(\"Map of table name to columns to index for FTS\"),\n })\n .optional();\n\n/**\n * SQLite AFS module configuration schema\n */\nexport const sqliteAFSConfigSchema = z.object({\n url: z.string().describe(\"SQLite database URL (file:./path or :memory:)\"),\n name: z.string().optional().describe(\"Module name, defaults to 'sqlite-afs'\"),\n description: z.string().optional().describe(\"Description of this module\"),\n accessMode: accessModeSchema,\n tables: z\n .array(z.string())\n .optional()\n .describe(\"Whitelist of tables to expose (if not specified, all tables are exposed)\"),\n excludeTables: z.array(z.string()).optional().describe(\"Tables to exclude from exposure\"),\n fts: ftsConfigSchema,\n wal: z.boolean().optional().default(true).describe(\"Enable WAL mode for better concurrency\"),\n});\n\n/**\n * SQLite AFS module configuration type\n */\nexport type SQLiteAFSConfig = z.infer<typeof sqliteAFSConfigSchema>;\n\n/**\n * SQLite AFS module options (after parsing)\n */\nexport interface SQLiteAFSOptions {\n /** SQLite database URL */\n url: string;\n /** Module name */\n name?: string;\n /** Module description */\n description?: string;\n /** Access mode */\n accessMode?: AFSAccessMode;\n /** Tables to expose */\n tables?: string[];\n /** Tables to exclude */\n excludeTables?: string[];\n /** FTS configuration */\n fts?: {\n enabled?: boolean;\n tables?: Record<string, string[]>;\n };\n /** Enable WAL mode */\n wal?: boolean;\n}\n"],"mappings":";;;;;;;AAMA,MAAa,kBAAkB,EAC5B,OAAO;CACN,SAAS,EAAE,SAAS,CAAC,QAAQ,KAAK,CAAC,SAAS,yBAAyB;CACrE,QAAQ,EACL,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAC3B,UAAU,CACV,SAAS,gDAAgD;CAC7D,CAAC,CACD,UAAU;;;;AAKb,MAAa,wBAAwB,EAAE,OAAO;CAC5C,KAAK,EAAE,QAAQ,CAAC,SAAS,gDAAgD;CACzE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,wCAAwC;CAC7E,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,6BAA6B;CACzE,YAAY;CACZ,QAAQ,EACL,MAAM,EAAE,QAAQ,CAAC,CACjB,UAAU,CACV,SAAS,2EAA2E;CACvF,eAAe,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,SAAS,kCAAkC;CACzF,KAAK;CACL,KAAK,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,KAAK,CAAC,SAAS,yCAAyC;CAC7F,CAAC"}
|