@aigne/afs-sqlite 1.11.0-beta.1 → 1.11.0-beta.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/README.md +3 -3
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/actions/built-in.cjs +1262 -15
- package/dist/actions/built-in.d.cts.map +1 -1
- package/dist/actions/built-in.d.mts.map +1 -1
- package/dist/actions/built-in.mjs +1262 -15
- package/dist/actions/built-in.mjs.map +1 -1
- package/dist/actions/operators.cjs +156 -0
- package/dist/actions/operators.mjs +157 -0
- package/dist/actions/operators.mjs.map +1 -0
- package/dist/actions/registry.cjs +35 -3
- package/dist/actions/registry.d.cts +36 -17
- package/dist/actions/registry.d.cts.map +1 -1
- package/dist/actions/registry.d.mts +36 -17
- package/dist/actions/registry.d.mts.map +1 -1
- package/dist/actions/registry.mjs +35 -3
- package/dist/actions/registry.mjs.map +1 -1
- package/dist/actions/types.cjs +33 -0
- package/dist/actions/types.d.cts +46 -5
- package/dist/actions/types.d.cts.map +1 -1
- package/dist/actions/types.d.mts +46 -5
- package/dist/actions/types.d.mts.map +1 -1
- package/dist/actions/types.mjs +32 -0
- package/dist/actions/types.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +9 -36
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +9 -36
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +1 -1
- package/dist/config.mjs.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -2
- package/dist/node/builder.cjs +74 -91
- package/dist/node/builder.d.cts +11 -15
- package/dist/node/builder.d.cts.map +1 -1
- package/dist/node/builder.d.mts +11 -15
- package/dist/node/builder.d.mts.map +1 -1
- package/dist/node/builder.mjs +72 -89
- package/dist/node/builder.mjs.map +1 -1
- package/dist/operations/crud.cjs +24 -68
- package/dist/operations/crud.d.cts +23 -38
- package/dist/operations/crud.d.cts.map +1 -1
- package/dist/operations/crud.d.mts +23 -38
- package/dist/operations/crud.d.mts.map +1 -1
- package/dist/operations/crud.mjs +25 -69
- package/dist/operations/crud.mjs.map +1 -1
- package/dist/operations/query-builder.cjs +2 -2
- package/dist/operations/query-builder.d.cts.map +1 -1
- package/dist/operations/query-builder.d.mts.map +1 -1
- package/dist/operations/query-builder.mjs +2 -2
- package/dist/operations/query-builder.mjs.map +1 -1
- package/dist/operations/search.cjs +5 -11
- package/dist/operations/search.d.cts +19 -23
- package/dist/operations/search.d.cts.map +1 -1
- package/dist/operations/search.d.mts +19 -23
- package/dist/operations/search.d.mts.map +1 -1
- package/dist/operations/search.mjs +5 -11
- package/dist/operations/search.mjs.map +1 -1
- package/dist/router/path-router.cjs +7 -15
- package/dist/router/path-router.d.cts +4 -7
- package/dist/router/path-router.d.cts.map +1 -1
- package/dist/router/path-router.d.mts +4 -7
- package/dist/router/path-router.d.mts.map +1 -1
- package/dist/router/path-router.mjs +7 -15
- package/dist/router/path-router.mjs.map +1 -1
- package/dist/router/types.d.cts.map +1 -1
- package/dist/router/types.d.mts.map +1 -1
- package/dist/schema/introspector.d.cts +19 -19
- package/dist/schema/introspector.d.cts.map +1 -1
- package/dist/schema/introspector.d.mts +19 -19
- package/dist/schema/introspector.d.mts.map +1 -1
- package/dist/schema/service.cjs +86 -0
- package/dist/schema/service.d.cts +52 -0
- package/dist/schema/service.d.cts.map +1 -0
- package/dist/schema/service.d.mts +52 -0
- package/dist/schema/service.d.mts.map +1 -0
- package/dist/schema/service.mjs +87 -0
- package/dist/schema/service.mjs.map +1 -0
- package/dist/schema/types.d.cts.map +1 -1
- package/dist/schema/types.d.mts.map +1 -1
- package/dist/sqlite-afs.cjs +693 -121
- package/dist/sqlite-afs.d.cts +279 -101
- package/dist/sqlite-afs.d.cts.map +1 -1
- package/dist/sqlite-afs.d.mts +279 -101
- package/dist/sqlite-afs.d.mts.map +1 -1
- package/dist/sqlite-afs.mjs +696 -123
- package/dist/sqlite-afs.mjs.map +1 -1
- package/package.json +5 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionContext, ActionDefinition, ActionHandler, ActionResult } from "./types.cjs";
|
|
1
|
+
import { ActionContext, ActionDefinition, ActionHandler, ActionResult, SchemaGeneratorContext } from "./types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/actions/registry.d.ts
|
|
4
4
|
/**
|
|
@@ -7,46 +7,65 @@ import { ActionContext, ActionDefinition, ActionHandler, ActionResult } from "./
|
|
|
7
7
|
declare class ActionsRegistry {
|
|
8
8
|
private handlers;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Registers an action handler
|
|
11
|
+
*/
|
|
12
12
|
register(definition: ActionDefinition): void;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* Registers a simple action with just name and handler
|
|
15
|
+
*/
|
|
16
16
|
registerSimple(name: string, handler: ActionHandler, options?: {
|
|
17
17
|
description?: string;
|
|
18
18
|
tableLevel?: boolean;
|
|
19
19
|
rowLevel?: boolean;
|
|
20
20
|
}): void;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* Unregisters an action
|
|
23
|
+
*/
|
|
24
24
|
unregister(name: string): boolean;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
* Checks if an action is registered
|
|
27
|
+
*/
|
|
28
28
|
has(name: string): boolean;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
* Gets an action definition
|
|
31
|
+
*/
|
|
32
32
|
get(name: string): ActionDefinition | undefined;
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* Lists all registered actions
|
|
35
|
+
*/
|
|
36
36
|
list(options?: {
|
|
37
|
+
rootLevel?: boolean;
|
|
37
38
|
tableLevel?: boolean;
|
|
38
39
|
rowLevel?: boolean;
|
|
39
40
|
}): ActionDefinition[];
|
|
40
41
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
* Lists action names
|
|
43
|
+
*/
|
|
43
44
|
listNames(options?: {
|
|
45
|
+
rootLevel?: boolean;
|
|
44
46
|
tableLevel?: boolean;
|
|
45
47
|
rowLevel?: boolean;
|
|
46
48
|
}): string[];
|
|
47
49
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
* Lists actions with their metadata (name, description, inputSchema)
|
|
51
|
+
* If schemaContext is provided, dynamic schemas will be generated
|
|
52
|
+
*/
|
|
53
|
+
listWithInfo(options?: {
|
|
54
|
+
rootLevel?: boolean;
|
|
55
|
+
tableLevel?: boolean;
|
|
56
|
+
rowLevel?: boolean;
|
|
57
|
+
}, schemaContext?: SchemaGeneratorContext): Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
inputSchema?: Record<string, unknown>;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Gets an action's input schema, optionally with dynamic generation
|
|
64
|
+
*/
|
|
65
|
+
getInputSchema(name: string, schemaContext?: SchemaGeneratorContext): Record<string, unknown> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Executes an action
|
|
68
|
+
*/
|
|
50
69
|
execute(name: string, ctx: ActionContext, params?: Record<string, unknown>): Promise<ActionResult>;
|
|
51
70
|
}
|
|
52
71
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.cts","names":[],"sources":["../../src/actions/registry.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.cts","names":[],"sources":["../../src/actions/registry.ts"],"mappings":";;;;;AAWA;cAAa,eAAA;EAAA,QACH,QAAA;EAKa;;;EAArB,QAAA,CAAS,UAAA,EAAY,gBAAA;EAyFH;;;EAlFlB,cAAA,CACE,IAAA,UACA,OAAA,EAAS,aAAA,EACT,OAAA;IACE,WAAA;IACA,UAAA;IACA,QAAA;EAAA;EAoHD;;;EArGH,UAAA,CAAW,IAAA;EA5BX;;;EAmCA,GAAA,CAAI,IAAA;EA3BF;;;EAkCF,GAAA,CAAI,IAAA,WAAe,gBAAA;EA9Bf;;;EAqCJ,IAAA,CAAK,OAAA;IACH,SAAA;IACA,UAAA;IACA,QAAA;EAAA,IACE,gBAAA;EAXA;;;EAiCJ,SAAA,CAAU,OAAA;IAAY,SAAA;IAAqB,UAAA;IAAsB,QAAA;EAAA;EAAjE;;;;EAQA,YAAA,CACE,OAAA;IACE,SAAA;IACA,UAAA;IACA,QAAA;EAAA,GAEF,aAAA,GAAgB,sBAAA,GACf,KAAA;IAAQ,IAAA;IAAc,WAAA;IAAsB,WAAA,GAAc,MAAA;EAAA;EAAlD;;;EAmBX,cAAA,CACE,IAAA,UACA,aAAA,GAAgB,sBAAA,GACf,MAAA;EAHH;;;EAgBM,OAAA,CACJ,IAAA,UACA,GAAA,EAAK,aAAA,EACL,MAAA,GAAQ,MAAA,oBACP,OAAA,CAAQ,YAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionContext, ActionDefinition, ActionHandler, ActionResult } from "./types.mjs";
|
|
1
|
+
import { ActionContext, ActionDefinition, ActionHandler, ActionResult, SchemaGeneratorContext } from "./types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/actions/registry.d.ts
|
|
4
4
|
/**
|
|
@@ -7,46 +7,65 @@ import { ActionContext, ActionDefinition, ActionHandler, ActionResult } from "./
|
|
|
7
7
|
declare class ActionsRegistry {
|
|
8
8
|
private handlers;
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Registers an action handler
|
|
11
|
+
*/
|
|
12
12
|
register(definition: ActionDefinition): void;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* Registers a simple action with just name and handler
|
|
15
|
+
*/
|
|
16
16
|
registerSimple(name: string, handler: ActionHandler, options?: {
|
|
17
17
|
description?: string;
|
|
18
18
|
tableLevel?: boolean;
|
|
19
19
|
rowLevel?: boolean;
|
|
20
20
|
}): void;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
* Unregisters an action
|
|
23
|
+
*/
|
|
24
24
|
unregister(name: string): boolean;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
* Checks if an action is registered
|
|
27
|
+
*/
|
|
28
28
|
has(name: string): boolean;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
* Gets an action definition
|
|
31
|
+
*/
|
|
32
32
|
get(name: string): ActionDefinition | undefined;
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
* Lists all registered actions
|
|
35
|
+
*/
|
|
36
36
|
list(options?: {
|
|
37
|
+
rootLevel?: boolean;
|
|
37
38
|
tableLevel?: boolean;
|
|
38
39
|
rowLevel?: boolean;
|
|
39
40
|
}): ActionDefinition[];
|
|
40
41
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
* Lists action names
|
|
43
|
+
*/
|
|
43
44
|
listNames(options?: {
|
|
45
|
+
rootLevel?: boolean;
|
|
44
46
|
tableLevel?: boolean;
|
|
45
47
|
rowLevel?: boolean;
|
|
46
48
|
}): string[];
|
|
47
49
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
* Lists actions with their metadata (name, description, inputSchema)
|
|
51
|
+
* If schemaContext is provided, dynamic schemas will be generated
|
|
52
|
+
*/
|
|
53
|
+
listWithInfo(options?: {
|
|
54
|
+
rootLevel?: boolean;
|
|
55
|
+
tableLevel?: boolean;
|
|
56
|
+
rowLevel?: boolean;
|
|
57
|
+
}, schemaContext?: SchemaGeneratorContext): Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
inputSchema?: Record<string, unknown>;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Gets an action's input schema, optionally with dynamic generation
|
|
64
|
+
*/
|
|
65
|
+
getInputSchema(name: string, schemaContext?: SchemaGeneratorContext): Record<string, unknown> | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Executes an action
|
|
68
|
+
*/
|
|
50
69
|
execute(name: string, ctx: ActionContext, params?: Record<string, unknown>): Promise<ActionResult>;
|
|
51
70
|
}
|
|
52
71
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.mts","names":[],"sources":["../../src/actions/registry.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.mts","names":[],"sources":["../../src/actions/registry.ts"],"mappings":";;;;;AAWA;cAAa,eAAA;EAAA,QACH,QAAA;EAKa;;;EAArB,QAAA,CAAS,UAAA,EAAY,gBAAA;EAyFH;;;EAlFlB,cAAA,CACE,IAAA,UACA,OAAA,EAAS,aAAA,EACT,OAAA;IACE,WAAA;IACA,UAAA;IACA,QAAA;EAAA;EAoHD;;;EArGH,UAAA,CAAW,IAAA;EA5BX;;;EAmCA,GAAA,CAAI,IAAA;EA3BF;;;EAkCF,GAAA,CAAI,IAAA,WAAe,gBAAA;EA9Bf;;;EAqCJ,IAAA,CAAK,OAAA;IACH,SAAA;IACA,UAAA;IACA,QAAA;EAAA,IACE,gBAAA;EAXA;;;EAiCJ,SAAA,CAAU,OAAA;IAAY,SAAA;IAAqB,UAAA;IAAsB,QAAA;EAAA;EAAjE;;;;EAQA,YAAA,CACE,OAAA;IACE,SAAA;IACA,UAAA;IACA,QAAA;EAAA,GAEF,aAAA,GAAgB,sBAAA,GACf,KAAA;IAAQ,IAAA;IAAc,WAAA;IAAsB,WAAA,GAAc,MAAA;EAAA;EAAlD;;;EAmBX,cAAA,CACE,IAAA,UACA,aAAA,GAAgB,sBAAA,GACf,MAAA;EAHH;;;EAgBM,OAAA,CACJ,IAAA,UACA,GAAA,EAAK,aAAA,EACL,MAAA,GAAQ,MAAA,oBACP,OAAA,CAAQ,YAAA;AAAA"}
|
|
@@ -45,7 +45,8 @@ var ActionsRegistry = class {
|
|
|
45
45
|
*/
|
|
46
46
|
list(options) {
|
|
47
47
|
const actions = Array.from(this.handlers.values());
|
|
48
|
-
if (options?.tableLevel !== void 0 || options?.rowLevel !== void 0) return actions.filter((a) => {
|
|
48
|
+
if (options?.rootLevel !== void 0 || options?.tableLevel !== void 0 || options?.rowLevel !== void 0) return actions.filter((a) => {
|
|
49
|
+
if (options.rootLevel && !a.rootLevel) return false;
|
|
49
50
|
if (options.tableLevel && !a.tableLevel) return false;
|
|
50
51
|
if (options.rowLevel && !a.rowLevel) return false;
|
|
51
52
|
return true;
|
|
@@ -59,6 +60,30 @@ var ActionsRegistry = class {
|
|
|
59
60
|
return this.list(options).map((a) => a.name);
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
63
|
+
* Lists actions with their metadata (name, description, inputSchema)
|
|
64
|
+
* If schemaContext is provided, dynamic schemas will be generated
|
|
65
|
+
*/
|
|
66
|
+
listWithInfo(options, schemaContext) {
|
|
67
|
+
return this.list(options).map((a) => {
|
|
68
|
+
let inputSchema = a.inputSchema;
|
|
69
|
+
if (a.inputSchemaGenerator && schemaContext) inputSchema = a.inputSchemaGenerator(schemaContext);
|
|
70
|
+
return {
|
|
71
|
+
name: a.name,
|
|
72
|
+
description: a.description,
|
|
73
|
+
inputSchema
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets an action's input schema, optionally with dynamic generation
|
|
79
|
+
*/
|
|
80
|
+
getInputSchema(name, schemaContext) {
|
|
81
|
+
const definition = this.handlers.get(name);
|
|
82
|
+
if (!definition) return void 0;
|
|
83
|
+
if (definition.inputSchemaGenerator && schemaContext) return definition.inputSchemaGenerator(schemaContext);
|
|
84
|
+
return definition.inputSchema;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
62
87
|
* Executes an action
|
|
63
88
|
*/
|
|
64
89
|
async execute(name, ctx, params = {}) {
|
|
@@ -67,11 +92,18 @@ var ActionsRegistry = class {
|
|
|
67
92
|
success: false,
|
|
68
93
|
message: `Unknown action: ${name}`
|
|
69
94
|
};
|
|
70
|
-
|
|
95
|
+
const isRootLevel = !ctx.table;
|
|
96
|
+
const isTableLevel = ctx.table && !ctx.pk;
|
|
97
|
+
const isRowLevel = ctx.table && ctx.pk;
|
|
98
|
+
if (isRootLevel && !definition.rootLevel) return {
|
|
99
|
+
success: false,
|
|
100
|
+
message: `Action '${name}' is not available at root level`
|
|
101
|
+
};
|
|
102
|
+
if (isRowLevel && !definition.rowLevel) return {
|
|
71
103
|
success: false,
|
|
72
104
|
message: `Action '${name}' is not available at row level`
|
|
73
105
|
};
|
|
74
|
-
if (
|
|
106
|
+
if (isTableLevel && !definition.tableLevel) return {
|
|
75
107
|
success: false,
|
|
76
108
|
message: `Action '${name}' is not available at table level`
|
|
77
109
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.mjs","names":[],"sources":["../../src/actions/registry.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"registry.mjs","names":[],"sources":["../../src/actions/registry.ts"],"sourcesContent":["import type {\n ActionContext,\n ActionDefinition,\n ActionHandler,\n ActionResult,\n SchemaGeneratorContext,\n} 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?: {\n rootLevel?: boolean;\n tableLevel?: boolean;\n rowLevel?: boolean;\n }): ActionDefinition[] {\n const actions = Array.from(this.handlers.values());\n\n if (\n options?.rootLevel !== undefined ||\n options?.tableLevel !== undefined ||\n options?.rowLevel !== undefined\n ) {\n return actions.filter((a) => {\n if (options.rootLevel && !a.rootLevel) return false;\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?: { rootLevel?: boolean; tableLevel?: boolean; rowLevel?: boolean }): string[] {\n return this.list(options).map((a) => a.name);\n }\n\n /**\n * Lists actions with their metadata (name, description, inputSchema)\n * If schemaContext is provided, dynamic schemas will be generated\n */\n listWithInfo(\n options?: {\n rootLevel?: boolean;\n tableLevel?: boolean;\n rowLevel?: boolean;\n },\n schemaContext?: SchemaGeneratorContext,\n ): Array<{ name: string; description?: string; inputSchema?: Record<string, unknown> }> {\n return this.list(options).map((a) => {\n // Use dynamic schema generator if available, otherwise use static schema\n let inputSchema = a.inputSchema;\n if (a.inputSchemaGenerator && schemaContext) {\n inputSchema = a.inputSchemaGenerator(schemaContext);\n }\n\n return {\n name: a.name,\n description: a.description,\n inputSchema,\n };\n });\n }\n\n /**\n * Gets an action's input schema, optionally with dynamic generation\n */\n getInputSchema(\n name: string,\n schemaContext?: SchemaGeneratorContext,\n ): Record<string, unknown> | undefined {\n const definition = this.handlers.get(name);\n if (!definition) return undefined;\n\n if (definition.inputSchemaGenerator && schemaContext) {\n return definition.inputSchemaGenerator(schemaContext);\n }\n return definition.inputSchema;\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 // Determine the level of this execution\n const isRootLevel = !ctx.table;\n const isTableLevel = ctx.table && !ctx.pk;\n const isRowLevel = ctx.table && ctx.pk;\n\n // Validate action level\n if (isRootLevel && !definition.rootLevel) {\n return {\n success: false,\n message: `Action '${name}' is not available at root level`,\n };\n }\n\n if (isRowLevel && !definition.rowLevel) {\n return {\n success: false,\n message: `Action '${name}' is not available at row level`,\n };\n }\n\n if (isTableLevel && !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":";;;;AAWA,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,SAIkB;EACrB,MAAM,UAAU,MAAM,KAAK,KAAK,SAAS,QAAQ,CAAC;AAElD,MACE,SAAS,cAAc,UACvB,SAAS,eAAe,UACxB,SAAS,aAAa,OAEtB,QAAO,QAAQ,QAAQ,MAAM;AAC3B,OAAI,QAAQ,aAAa,CAAC,EAAE,UAAW,QAAO;AAC9C,OAAI,QAAQ,cAAc,CAAC,EAAE,WAAY,QAAO;AAChD,OAAI,QAAQ,YAAY,CAAC,EAAE,SAAU,QAAO;AAC5C,UAAO;IACP;AAGJ,SAAO;;;;;CAMT,UAAU,SAAuF;AAC/F,SAAO,KAAK,KAAK,QAAQ,CAAC,KAAK,MAAM,EAAE,KAAK;;;;;;CAO9C,aACE,SAKA,eACsF;AACtF,SAAO,KAAK,KAAK,QAAQ,CAAC,KAAK,MAAM;GAEnC,IAAI,cAAc,EAAE;AACpB,OAAI,EAAE,wBAAwB,cAC5B,eAAc,EAAE,qBAAqB,cAAc;AAGrD,UAAO;IACL,MAAM,EAAE;IACR,aAAa,EAAE;IACf;IACD;IACD;;;;;CAMJ,eACE,MACA,eACqC;EACrC,MAAM,aAAa,KAAK,SAAS,IAAI,KAAK;AAC1C,MAAI,CAAC,WAAY,QAAO;AAExB,MAAI,WAAW,wBAAwB,cACrC,QAAO,WAAW,qBAAqB,cAAc;AAEvD,SAAO,WAAW;;;;;CAMpB,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;EAIH,MAAM,cAAc,CAAC,IAAI;EACzB,MAAM,eAAe,IAAI,SAAS,CAAC,IAAI;EACvC,MAAM,aAAa,IAAI,SAAS,IAAI;AAGpC,MAAI,eAAe,CAAC,WAAW,UAC7B,QAAO;GACL,SAAS;GACT,SAAS,WAAW,KAAK;GAC1B;AAGH,MAAI,cAAc,CAAC,WAAW,SAC5B,QAAO;GACL,SAAS;GACT,SAAS,WAAW,KAAK;GAC1B;AAGH,MAAI,gBAAgB,CAAC,WAAW,WAC9B,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,33 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/actions/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* Error codes for SQLite actions
|
|
5
|
+
*
|
|
6
|
+
* Simplified to 3 core codes. Specific error types are distinguished via message.
|
|
7
|
+
*/
|
|
8
|
+
let SQLiteActionErrorCode = /* @__PURE__ */ function(SQLiteActionErrorCode) {
|
|
9
|
+
/** Input parameters invalid (schema, type, format errors) */
|
|
10
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["INVALID_INPUT"] = 1001] = "INVALID_INPUT";
|
|
11
|
+
/** Table, column, index, or row not found */
|
|
12
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["NOT_FOUND"] = 2001] = "NOT_FOUND";
|
|
13
|
+
/** Constraint violation (unique, foreign key, not null, etc.) */
|
|
14
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["CONSTRAINT_VIOLATION"] = 3001] = "CONSTRAINT_VIOLATION";
|
|
15
|
+
return SQLiteActionErrorCode;
|
|
16
|
+
}({});
|
|
17
|
+
/**
|
|
18
|
+
* Helper to create an error result
|
|
19
|
+
*/
|
|
20
|
+
function errorResult(code, message, details) {
|
|
21
|
+
return {
|
|
22
|
+
success: false,
|
|
23
|
+
error: {
|
|
24
|
+
code,
|
|
25
|
+
message,
|
|
26
|
+
details
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.SQLiteActionErrorCode = SQLiteActionErrorCode;
|
|
33
|
+
exports.errorResult = errorResult;
|
package/dist/actions/types.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableSchema } from "../schema/types.cjs";
|
|
2
|
+
import { SchemaService } from "../schema/service.cjs";
|
|
2
3
|
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/types.d.ts
|
|
@@ -8,8 +9,8 @@ import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
|
8
9
|
interface ActionContext {
|
|
9
10
|
/** Database instance */
|
|
10
11
|
db: LibSQLDatabase;
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/** Schema service for querying table schemas on-demand */
|
|
13
|
+
schemaService: SchemaService;
|
|
13
14
|
/** Table this action is being executed on */
|
|
14
15
|
table: string;
|
|
15
16
|
/** Primary key of the row (if row-level action) */
|
|
@@ -18,14 +19,49 @@ interface ActionContext {
|
|
|
18
19
|
row?: Record<string, unknown>;
|
|
19
20
|
/** Reference to the parent module for advanced operations */
|
|
20
21
|
module: {
|
|
21
|
-
refreshSchema(): Promise<void>;
|
|
22
22
|
exportTable(table: string, format: string): Promise<unknown>;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Context for generating dynamic input schemas
|
|
27
|
+
*/
|
|
28
|
+
interface SchemaGeneratorContext {
|
|
29
|
+
/** Table schema (for table/row-level actions) */
|
|
30
|
+
tableSchema?: TableSchema;
|
|
31
|
+
/** Table name */
|
|
32
|
+
tableName?: string;
|
|
33
|
+
/** Schema service for querying schemas */
|
|
34
|
+
schemaService: SchemaService;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Function that generates input schema dynamically based on context
|
|
38
|
+
*/
|
|
39
|
+
type InputSchemaGenerator = (ctx: SchemaGeneratorContext) => Record<string, unknown>;
|
|
25
40
|
/**
|
|
26
41
|
* Action handler function signature
|
|
27
42
|
*/
|
|
28
43
|
type ActionHandler = (ctx: ActionContext, params: Record<string, unknown>) => Promise<ActionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Error codes for SQLite actions
|
|
46
|
+
*
|
|
47
|
+
* Simplified to 3 core codes. Specific error types are distinguished via message.
|
|
48
|
+
*/
|
|
49
|
+
declare enum SQLiteActionErrorCode {
|
|
50
|
+
/** Input parameters invalid (schema, type, format errors) */
|
|
51
|
+
INVALID_INPUT = 1001,
|
|
52
|
+
/** Table, column, index, or row not found */
|
|
53
|
+
NOT_FOUND = 2001,
|
|
54
|
+
/** Constraint violation (unique, foreign key, not null, etc.) */
|
|
55
|
+
CONSTRAINT_VIOLATION = 3001
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Error details for failed actions
|
|
59
|
+
*/
|
|
60
|
+
interface ActionError {
|
|
61
|
+
code: SQLiteActionErrorCode;
|
|
62
|
+
message: string;
|
|
63
|
+
details?: Record<string, unknown>;
|
|
64
|
+
}
|
|
29
65
|
/**
|
|
30
66
|
* Result from an action execution
|
|
31
67
|
*/
|
|
@@ -33,6 +69,7 @@ interface ActionResult {
|
|
|
33
69
|
success: boolean;
|
|
34
70
|
data?: unknown;
|
|
35
71
|
message?: string;
|
|
72
|
+
error?: ActionError;
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* Action definition with metadata
|
|
@@ -42,15 +79,19 @@ interface ActionDefinition {
|
|
|
42
79
|
name: string;
|
|
43
80
|
/** Description of what the action does */
|
|
44
81
|
description?: string;
|
|
82
|
+
/** Whether this action is available at root level (database operations) */
|
|
83
|
+
rootLevel?: boolean;
|
|
45
84
|
/** Whether this action is available at table level (vs row level) */
|
|
46
85
|
tableLevel?: boolean;
|
|
47
86
|
/** Whether this action is available at row level */
|
|
48
87
|
rowLevel?: boolean;
|
|
49
|
-
/**
|
|
88
|
+
/** Static input schema for the action parameters */
|
|
50
89
|
inputSchema?: Record<string, unknown>;
|
|
90
|
+
/** Dynamic input schema generator (takes precedence over static inputSchema) */
|
|
91
|
+
inputSchemaGenerator?: InputSchemaGenerator;
|
|
51
92
|
/** The handler function */
|
|
52
93
|
handler: ActionHandler;
|
|
53
94
|
}
|
|
54
95
|
//#endregion
|
|
55
|
-
export { ActionContext, ActionDefinition, ActionHandler, ActionResult };
|
|
96
|
+
export { ActionContext, ActionDefinition, ActionHandler, ActionResult, SchemaGeneratorContext };
|
|
56
97
|
//# sourceMappingURL=types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/actions/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/actions/types.ts"],"mappings":";;;;;;;AAOA;UAAiB,aAAA;;EAEf,EAAA,EAAI,cAAA;EAEW;EAAf,aAAA,EAAe,aAAA;EAS+B;EAP9C,KAAA;EAOqD;EALrD,EAAA;EANI;EAQJ,GAAA,GAAM,MAAA;EANS;EAQf,MAAA;IACE,WAAA,CAAY,KAAA,UAAe,MAAA,WAAiB,OAAA;EAAA;AAAA;;;;UAO/B,sBAAA;EAP+B;EAS9C,WAAA,GAAc,WAAA;EATuC;EAWrD,SAAA;EAJqC;EAMrC,aAAA,EAAe,aAAA;AAAA;;;;KAML,oBAAA,IAAwB,GAAA,EAAK,sBAAA,KAA2B,MAAA;;;;KAKxD,aAAA,IACV,GAAA,EAAK,aAAA,EACL,MAAA,EAAQ,MAAA,sBACL,OAAA,CAAQ,YAAA;;;;;;aAOD,qBAAA;EAf8D;EAiBxE,aAAA;EAZU;EAcV,SAAA;;EAEA,oBAAA;AAAA;;;;UAMe,WAAA;EACf,IAAA,EAAM,qBAAA;EACN,OAAA;EACA,OAAA,GAAU,MAAA;AAAA;;;;UAMK,YAAA;EACf,OAAA;EACA,IAAA;EACA,OAAA;EACA,KAAA,GAAQ,WAAA;AAAA;AAbV;;;AAAA,UAiCiB,gBAAA;EAhCf;EAkCA,IAAA;EAjCA;EAmCA,WAAA;EAlCU;EAoCV,SAAA;EApCgB;EAsChB,UAAA;EAhC2B;EAkC3B,QAAA;EA9BmB;EAgCnB,WAAA,GAAc,MAAA;EAlCd;EAoCA,oBAAA,GAAuB,oBAAA;EAlCvB;EAoCA,OAAA,EAAS,aAAA;AAAA"}
|
package/dist/actions/types.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableSchema } from "../schema/types.mjs";
|
|
2
|
+
import { SchemaService } from "../schema/service.mjs";
|
|
2
3
|
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
3
4
|
|
|
4
5
|
//#region src/actions/types.d.ts
|
|
@@ -8,8 +9,8 @@ import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
|
8
9
|
interface ActionContext {
|
|
9
10
|
/** Database instance */
|
|
10
11
|
db: LibSQLDatabase;
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
/** Schema service for querying table schemas on-demand */
|
|
13
|
+
schemaService: SchemaService;
|
|
13
14
|
/** Table this action is being executed on */
|
|
14
15
|
table: string;
|
|
15
16
|
/** Primary key of the row (if row-level action) */
|
|
@@ -18,14 +19,49 @@ interface ActionContext {
|
|
|
18
19
|
row?: Record<string, unknown>;
|
|
19
20
|
/** Reference to the parent module for advanced operations */
|
|
20
21
|
module: {
|
|
21
|
-
refreshSchema(): Promise<void>;
|
|
22
22
|
exportTable(table: string, format: string): Promise<unknown>;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Context for generating dynamic input schemas
|
|
27
|
+
*/
|
|
28
|
+
interface SchemaGeneratorContext {
|
|
29
|
+
/** Table schema (for table/row-level actions) */
|
|
30
|
+
tableSchema?: TableSchema;
|
|
31
|
+
/** Table name */
|
|
32
|
+
tableName?: string;
|
|
33
|
+
/** Schema service for querying schemas */
|
|
34
|
+
schemaService: SchemaService;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Function that generates input schema dynamically based on context
|
|
38
|
+
*/
|
|
39
|
+
type InputSchemaGenerator = (ctx: SchemaGeneratorContext) => Record<string, unknown>;
|
|
25
40
|
/**
|
|
26
41
|
* Action handler function signature
|
|
27
42
|
*/
|
|
28
43
|
type ActionHandler = (ctx: ActionContext, params: Record<string, unknown>) => Promise<ActionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Error codes for SQLite actions
|
|
46
|
+
*
|
|
47
|
+
* Simplified to 3 core codes. Specific error types are distinguished via message.
|
|
48
|
+
*/
|
|
49
|
+
declare enum SQLiteActionErrorCode {
|
|
50
|
+
/** Input parameters invalid (schema, type, format errors) */
|
|
51
|
+
INVALID_INPUT = 1001,
|
|
52
|
+
/** Table, column, index, or row not found */
|
|
53
|
+
NOT_FOUND = 2001,
|
|
54
|
+
/** Constraint violation (unique, foreign key, not null, etc.) */
|
|
55
|
+
CONSTRAINT_VIOLATION = 3001
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Error details for failed actions
|
|
59
|
+
*/
|
|
60
|
+
interface ActionError {
|
|
61
|
+
code: SQLiteActionErrorCode;
|
|
62
|
+
message: string;
|
|
63
|
+
details?: Record<string, unknown>;
|
|
64
|
+
}
|
|
29
65
|
/**
|
|
30
66
|
* Result from an action execution
|
|
31
67
|
*/
|
|
@@ -33,6 +69,7 @@ interface ActionResult {
|
|
|
33
69
|
success: boolean;
|
|
34
70
|
data?: unknown;
|
|
35
71
|
message?: string;
|
|
72
|
+
error?: ActionError;
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* Action definition with metadata
|
|
@@ -42,15 +79,19 @@ interface ActionDefinition {
|
|
|
42
79
|
name: string;
|
|
43
80
|
/** Description of what the action does */
|
|
44
81
|
description?: string;
|
|
82
|
+
/** Whether this action is available at root level (database operations) */
|
|
83
|
+
rootLevel?: boolean;
|
|
45
84
|
/** Whether this action is available at table level (vs row level) */
|
|
46
85
|
tableLevel?: boolean;
|
|
47
86
|
/** Whether this action is available at row level */
|
|
48
87
|
rowLevel?: boolean;
|
|
49
|
-
/**
|
|
88
|
+
/** Static input schema for the action parameters */
|
|
50
89
|
inputSchema?: Record<string, unknown>;
|
|
90
|
+
/** Dynamic input schema generator (takes precedence over static inputSchema) */
|
|
91
|
+
inputSchemaGenerator?: InputSchemaGenerator;
|
|
51
92
|
/** The handler function */
|
|
52
93
|
handler: ActionHandler;
|
|
53
94
|
}
|
|
54
95
|
//#endregion
|
|
55
|
-
export { ActionContext, ActionDefinition, ActionHandler, ActionResult };
|
|
96
|
+
export { ActionContext, ActionDefinition, ActionHandler, ActionResult, SchemaGeneratorContext };
|
|
56
97
|
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/actions/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/actions/types.ts"],"mappings":";;;;;;;AAOA;UAAiB,aAAA;;EAEf,EAAA,EAAI,cAAA;EAEW;EAAf,aAAA,EAAe,aAAA;EAS+B;EAP9C,KAAA;EAOqD;EALrD,EAAA;EANI;EAQJ,GAAA,GAAM,MAAA;EANS;EAQf,MAAA;IACE,WAAA,CAAY,KAAA,UAAe,MAAA,WAAiB,OAAA;EAAA;AAAA;;;;UAO/B,sBAAA;EAP+B;EAS9C,WAAA,GAAc,WAAA;EATuC;EAWrD,SAAA;EAJqC;EAMrC,aAAA,EAAe,aAAA;AAAA;;;;KAML,oBAAA,IAAwB,GAAA,EAAK,sBAAA,KAA2B,MAAA;;;;KAKxD,aAAA,IACV,GAAA,EAAK,aAAA,EACL,MAAA,EAAQ,MAAA,sBACL,OAAA,CAAQ,YAAA;;;;;;aAOD,qBAAA;EAf8D;EAiBxE,aAAA;EAZU;EAcV,SAAA;;EAEA,oBAAA;AAAA;;;;UAMe,WAAA;EACf,IAAA,EAAM,qBAAA;EACN,OAAA;EACA,OAAA,GAAU,MAAA;AAAA;;;;UAMK,YAAA;EACf,OAAA;EACA,IAAA;EACA,OAAA;EACA,KAAA,GAAQ,WAAA;AAAA;AAbV;;;AAAA,UAiCiB,gBAAA;EAhCf;EAkCA,IAAA;EAjCA;EAmCA,WAAA;EAlCU;EAoCV,SAAA;EApCgB;EAsChB,UAAA;EAhC2B;EAkC3B,QAAA;EA9BmB;EAgCnB,WAAA,GAAc,MAAA;EAlCd;EAoCA,oBAAA,GAAuB,oBAAA;EAlCvB;EAoCA,OAAA,EAAS,aAAA;AAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/actions/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Error codes for SQLite actions
|
|
4
|
+
*
|
|
5
|
+
* Simplified to 3 core codes. Specific error types are distinguished via message.
|
|
6
|
+
*/
|
|
7
|
+
let SQLiteActionErrorCode = /* @__PURE__ */ function(SQLiteActionErrorCode) {
|
|
8
|
+
/** Input parameters invalid (schema, type, format errors) */
|
|
9
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["INVALID_INPUT"] = 1001] = "INVALID_INPUT";
|
|
10
|
+
/** Table, column, index, or row not found */
|
|
11
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["NOT_FOUND"] = 2001] = "NOT_FOUND";
|
|
12
|
+
/** Constraint violation (unique, foreign key, not null, etc.) */
|
|
13
|
+
SQLiteActionErrorCode[SQLiteActionErrorCode["CONSTRAINT_VIOLATION"] = 3001] = "CONSTRAINT_VIOLATION";
|
|
14
|
+
return SQLiteActionErrorCode;
|
|
15
|
+
}({});
|
|
16
|
+
/**
|
|
17
|
+
* Helper to create an error result
|
|
18
|
+
*/
|
|
19
|
+
function errorResult(code, message, details) {
|
|
20
|
+
return {
|
|
21
|
+
success: false,
|
|
22
|
+
error: {
|
|
23
|
+
code,
|
|
24
|
+
message,
|
|
25
|
+
details
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { SQLiteActionErrorCode, errorResult };
|
|
32
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../../src/actions/types.ts"],"sourcesContent":["import type { LibSQLDatabase } from \"drizzle-orm/libsql\";\nimport type { SchemaService } from \"../schema/service.js\";\nimport type { TableSchema } from \"../schema/types.js\";\n\n/**\n * Context provided to action handlers\n */\nexport interface ActionContext {\n /** Database instance */\n db: LibSQLDatabase;\n /** Schema service for querying table schemas on-demand */\n schemaService: SchemaService;\n /** Table this action is being executed on */\n table: string;\n /** Primary key of the row (if row-level action) */\n pk?: string;\n /** The row data (if available) */\n row?: Record<string, unknown>;\n /** Reference to the parent module for advanced operations */\n module: {\n exportTable(table: string, format: string): Promise<unknown>;\n };\n}\n\n/**\n * Context for generating dynamic input schemas\n */\nexport interface SchemaGeneratorContext {\n /** Table schema (for table/row-level actions) */\n tableSchema?: TableSchema;\n /** Table name */\n tableName?: string;\n /** Schema service for querying schemas */\n schemaService: SchemaService;\n}\n\n/**\n * Function that generates input schema dynamically based on context\n */\nexport type InputSchemaGenerator = (ctx: SchemaGeneratorContext) => Record<string, unknown>;\n\n/**\n * Action handler function signature\n */\nexport type ActionHandler = (\n ctx: ActionContext,\n params: Record<string, unknown>,\n) => Promise<ActionResult>;\n\n/**\n * Error codes for SQLite actions\n *\n * Simplified to 3 core codes. Specific error types are distinguished via message.\n */\nexport enum SQLiteActionErrorCode {\n /** Input parameters invalid (schema, type, format errors) */\n INVALID_INPUT = 1001,\n /** Table, column, index, or row not found */\n NOT_FOUND = 2001,\n /** Constraint violation (unique, foreign key, not null, etc.) */\n CONSTRAINT_VIOLATION = 3001,\n}\n\n/**\n * Error details for failed actions\n */\nexport interface ActionError {\n code: SQLiteActionErrorCode;\n message: string;\n details?: Record<string, unknown>;\n}\n\n/**\n * Result from an action execution\n */\nexport interface ActionResult {\n success: boolean;\n data?: unknown;\n message?: string;\n error?: ActionError;\n}\n\n/**\n * Helper to create an error result\n */\nexport function errorResult(\n code: SQLiteActionErrorCode,\n message: string,\n details?: Record<string, unknown>,\n): ActionResult {\n return {\n success: false,\n error: { code, message, details },\n };\n}\n\n/**\n * Action definition with metadata\n */\nexport interface ActionDefinition {\n /** Action name */\n name: string;\n /** Description of what the action does */\n description?: string;\n /** Whether this action is available at root level (database operations) */\n rootLevel?: boolean;\n /** Whether this action is available at table level (vs row level) */\n tableLevel?: boolean;\n /** Whether this action is available at row level */\n rowLevel?: boolean;\n /** Static input schema for the action parameters */\n inputSchema?: Record<string, unknown>;\n /** Dynamic input schema generator (takes precedence over static inputSchema) */\n inputSchemaGenerator?: InputSchemaGenerator;\n /** The handler function */\n handler: ActionHandler;\n}\n"],"mappings":";;;;;;AAsDA,IAAY,wEAAL;;AAEL;;AAEA;;AAEA;;;;;;AAyBF,SAAgB,YACd,MACA,SACA,SACc;AACd,QAAO;EACL,SAAS;EACT,OAAO;GAAE;GAAM;GAAS;GAAS;EAClC"}
|
package/dist/config.cjs
CHANGED
|
@@ -7,7 +7,7 @@ let zod = require("zod");
|
|
|
7
7
|
*/
|
|
8
8
|
const ftsConfigSchema = zod.z.object({
|
|
9
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")
|
|
10
|
+
tables: zod.z.record(zod.z.string(), zod.z.array(zod.z.string())).optional().describe("Map of table name to columns to index for FTS")
|
|
11
11
|
}).optional();
|
|
12
12
|
/**
|
|
13
13
|
* SQLite AFS module configuration schema
|
package/dist/config.d.cts
CHANGED
|
@@ -9,45 +9,18 @@ declare const sqliteAFSConfigSchema: z.ZodObject<{
|
|
|
9
9
|
url: z.ZodString;
|
|
10
10
|
name: z.ZodOptional<z.ZodString>;
|
|
11
11
|
description: z.ZodOptional<z.ZodString>;
|
|
12
|
-
accessMode: z.ZodOptional<z.ZodEnum<
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
accessMode: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
readonly: "readonly";
|
|
14
|
+
readwrite: "readwrite";
|
|
15
|
+
}>>;
|
|
16
|
+
tables: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
+
excludeTables: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
15
18
|
fts: z.ZodOptional<z.ZodObject<{
|
|
16
19
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
-
tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString
|
|
18
|
-
},
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
tables?: Record<string, string[]> | undefined;
|
|
21
|
-
}, {
|
|
22
|
-
tables?: Record<string, string[]> | undefined;
|
|
23
|
-
enabled?: boolean | undefined;
|
|
24
|
-
}>>;
|
|
20
|
+
tables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
25
22
|
wal: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
|
-
},
|
|
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
|
-
}>;
|
|
23
|
+
}, z.core.$strip>;
|
|
51
24
|
/**
|
|
52
25
|
* SQLite AFS module configuration type
|
|
53
26
|
*/
|
package/dist/config.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;cAmBa,qBAAA,EAAqB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;KAiBtB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,qBAAA;;;;UAK5B,gBAAA;EAtBiB;EAwBhC,GAAA;EAxBgC;EA0BhC,IAAA;;EAEA,WAAA;;EAEA,UAAA,GAAa,aAAA;;EAEb,MAAA;;EAEA,aAAA;;EAEA,GAAA;IACE,OAAA;IACA,MAAA,GAAS,MAAA;EAAA;;EAGX,GAAA;AAAA"}
|