@aigne/afs-sqlite 1.11.0-beta.6 → 1.11.0-beta.8
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/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/actions/built-in.cjs +870 -16
- 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 +870 -16
- 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/types.cjs +33 -0
- package/dist/actions/types.d.cts +22 -0
- package/dist/actions/types.d.cts.map +1 -1
- package/dist/actions/types.d.mts +22 -0
- 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 +2 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/node/builder.cjs +11 -8
- package/dist/node/builder.d.cts.map +1 -1
- package/dist/node/builder.d.mts.map +1 -1
- package/dist/node/builder.mjs +11 -8
- package/dist/node/builder.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 +1 -1
- package/dist/operations/search.mjs +1 -1
- package/dist/operations/search.mjs.map +1 -1
- package/dist/sqlite-afs.cjs +268 -26
- package/dist/sqlite-afs.d.cts +50 -48
- package/dist/sqlite-afs.d.cts.map +1 -1
- package/dist/sqlite-afs.d.mts +50 -48
- package/dist/sqlite-afs.d.mts.map +1 -1
- package/dist/sqlite-afs.mjs +270 -27
- package/dist/sqlite-afs.mjs.map +1 -1
- package/package.json +5 -4
|
@@ -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
|
@@ -41,6 +41,27 @@ type InputSchemaGenerator = (ctx: SchemaGeneratorContext) => Record<string, unkn
|
|
|
41
41
|
* Action handler function signature
|
|
42
42
|
*/
|
|
43
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
|
+
}
|
|
44
65
|
/**
|
|
45
66
|
* Result from an action execution
|
|
46
67
|
*/
|
|
@@ -48,6 +69,7 @@ interface ActionResult {
|
|
|
48
69
|
success: boolean;
|
|
49
70
|
data?: unknown;
|
|
50
71
|
message?: string;
|
|
72
|
+
error?: ActionError;
|
|
51
73
|
}
|
|
52
74
|
/**
|
|
53
75
|
* Action definition with metadata
|
|
@@ -1 +1 @@
|
|
|
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,WAA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;AAAA"}
|
package/dist/actions/types.d.mts
CHANGED
|
@@ -41,6 +41,27 @@ type InputSchemaGenerator = (ctx: SchemaGeneratorContext) => Record<string, unkn
|
|
|
41
41
|
* Action handler function signature
|
|
42
42
|
*/
|
|
43
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
|
+
}
|
|
44
65
|
/**
|
|
45
66
|
* Result from an action execution
|
|
46
67
|
*/
|
|
@@ -48,6 +69,7 @@ interface ActionResult {
|
|
|
48
69
|
success: boolean;
|
|
49
70
|
data?: unknown;
|
|
50
71
|
message?: string;
|
|
72
|
+
error?: ActionError;
|
|
51
73
|
}
|
|
52
74
|
/**
|
|
53
75
|
* Action definition with metadata
|
|
@@ -1 +1 @@
|
|
|
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;EAQ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AkC3B,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":";;;;;;;cAmBa,qBAAA,EAAqB,CAAA,CAAA,SAAA
|
|
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"}
|
package/dist/config.d.mts
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.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;cAmBa,qBAAA,EAAqB,CAAA,CAAA,SAAA
|
|
1
|
+
{"version":3,"file":"config.d.mts","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"}
|
package/dist/config.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { z } from "zod";
|
|
|
7
7
|
*/
|
|
8
8
|
const ftsConfigSchema = z.object({
|
|
9
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")
|
|
10
|
+
tables: z.record(z.string(), z.array(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.mjs.map
CHANGED
|
@@ -1 +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,
|
|
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.string(), 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,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CACvC,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1
2
|
const require_built_in = require('./actions/built-in.cjs');
|
|
2
3
|
const require_registry = require('./actions/registry.cjs');
|
|
3
4
|
const require_config = require('./config.cjs');
|
|
@@ -30,6 +31,7 @@ exports.buildTableEntry = require_builder.buildTableEntry;
|
|
|
30
31
|
exports.buildUpdate = require_query_builder.buildUpdate;
|
|
31
32
|
exports.createFTSConfig = require_search.createFTSConfig;
|
|
32
33
|
exports.createPathRouter = require_path_router.createPathRouter;
|
|
34
|
+
exports.default = require_sqlite_afs.SQLiteAFS;
|
|
33
35
|
exports.getVirtualPathType = require_path_router.getVirtualPathType;
|
|
34
36
|
exports.isVirtualPath = require_path_router.isVirtualPath;
|
|
35
37
|
exports.matchPath = require_path_router.matchPath;
|
package/dist/index.d.cts
CHANGED
|
@@ -12,4 +12,4 @@ import { RouteAction, RouteData, RouteMatch, RouteParams } from "./router/types.
|
|
|
12
12
|
import { buildPath, createPathRouter, getVirtualPathType, isVirtualPath, matchPath } from "./router/path-router.cjs";
|
|
13
13
|
import { SchemaIntrospector } from "./schema/introspector.cjs";
|
|
14
14
|
import { SQLiteAFS } from "./sqlite-afs.cjs";
|
|
15
|
-
export { type ActionContext, type ActionDefinition, type ActionHandler, type ActionResult, ActionsRegistry, type BuildEntryOptions, CRUDOperations, type ColumnInfo, type FTSConfig, FTSSearch, type FTSTableConfig, type ForeignKeyInfo, type IndexInfo, type PragmaForeignKeyRow, type PragmaIndexListRow, type PragmaTableInfoRow, type RouteAction, type RouteData, type RouteMatch, type RouteParams, SQLiteAFS, type SQLiteAFSConfig, type SQLiteAFSOptions, type SchemaGeneratorContext, SchemaIntrospector, SchemaService, type SchemaServiceOptions, type TableSchema, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
|
15
|
+
export { type ActionContext, type ActionDefinition, type ActionHandler, type ActionResult, ActionsRegistry, type BuildEntryOptions, CRUDOperations, type ColumnInfo, type FTSConfig, FTSSearch, type FTSTableConfig, type ForeignKeyInfo, type IndexInfo, type PragmaForeignKeyRow, type PragmaIndexListRow, type PragmaTableInfoRow, type RouteAction, type RouteData, type RouteMatch, type RouteParams, SQLiteAFS, type SQLiteAFSConfig, type SQLiteAFSOptions, type SchemaGeneratorContext, SchemaIntrospector, SchemaService, type SchemaServiceOptions, type TableSchema, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, SQLiteAFS as default, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
package/dist/index.d.mts
CHANGED
|
@@ -12,4 +12,4 @@ import { RouteAction, RouteData, RouteMatch, RouteParams } from "./router/types.
|
|
|
12
12
|
import { buildPath, createPathRouter, getVirtualPathType, isVirtualPath, matchPath } from "./router/path-router.mjs";
|
|
13
13
|
import { SchemaIntrospector } from "./schema/introspector.mjs";
|
|
14
14
|
import { SQLiteAFS } from "./sqlite-afs.mjs";
|
|
15
|
-
export { type ActionContext, type ActionDefinition, type ActionHandler, type ActionResult, ActionsRegistry, type BuildEntryOptions, CRUDOperations, type ColumnInfo, type FTSConfig, FTSSearch, type FTSTableConfig, type ForeignKeyInfo, type IndexInfo, type PragmaForeignKeyRow, type PragmaIndexListRow, type PragmaTableInfoRow, type RouteAction, type RouteData, type RouteMatch, type RouteParams, SQLiteAFS, type SQLiteAFSConfig, type SQLiteAFSOptions, type SchemaGeneratorContext, SchemaIntrospector, SchemaService, type SchemaServiceOptions, type TableSchema, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
|
15
|
+
export { type ActionContext, type ActionDefinition, type ActionHandler, type ActionResult, ActionsRegistry, type BuildEntryOptions, CRUDOperations, type ColumnInfo, type FTSConfig, FTSSearch, type FTSTableConfig, type ForeignKeyInfo, type IndexInfo, type PragmaForeignKeyRow, type PragmaIndexListRow, type PragmaTableInfoRow, type RouteAction, type RouteData, type RouteMatch, type RouteParams, SQLiteAFS, type SQLiteAFSConfig, type SQLiteAFSOptions, type SchemaGeneratorContext, SchemaIntrospector, SchemaService, type SchemaServiceOptions, type TableSchema, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, SQLiteAFS as default, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -10,4 +10,4 @@ import { SchemaIntrospector } from "./schema/introspector.mjs";
|
|
|
10
10
|
import { SchemaService } from "./schema/service.mjs";
|
|
11
11
|
import { SQLiteAFS } from "./sqlite-afs.mjs";
|
|
12
12
|
|
|
13
|
-
export { ActionsRegistry, CRUDOperations, FTSSearch, SQLiteAFS, SchemaIntrospector, SchemaService, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
|
13
|
+
export { ActionsRegistry, CRUDOperations, FTSSearch, SQLiteAFS, SchemaIntrospector, SchemaService, buildActionsListEntry, buildDelete, buildGetLastRowId, buildInsert, buildMetaEntry, buildPath, buildRowEntry, buildSearchEntry, buildSelectAll, buildSelectByPK, buildTableEntry, buildUpdate, createFTSConfig, createPathRouter, SQLiteAFS as default, getVirtualPathType, isVirtualPath, matchPath, registerBuiltInActions, sqliteAFSConfigSchema };
|
package/dist/node/builder.cjs
CHANGED
|
@@ -11,7 +11,8 @@ function buildRowEntry(table, schema, row, options) {
|
|
|
11
11
|
id: `${table}:${pk}`,
|
|
12
12
|
path: `${basePath}/${table}/${pk}`,
|
|
13
13
|
content: row,
|
|
14
|
-
|
|
14
|
+
meta: {
|
|
15
|
+
kind: "sqlite:row",
|
|
15
16
|
table,
|
|
16
17
|
primaryKey: pkColumn,
|
|
17
18
|
primaryKeyValue: pk
|
|
@@ -27,12 +28,13 @@ function buildTableEntry(table, schema, options) {
|
|
|
27
28
|
return {
|
|
28
29
|
id: table,
|
|
29
30
|
path: `${options?.basePath ?? ""}/${table}`,
|
|
30
|
-
|
|
31
|
+
meta: {
|
|
32
|
+
kind: "sqlite:table",
|
|
31
33
|
description: `Table: ${table} (${schema.columns.length} columns)`,
|
|
32
34
|
table,
|
|
33
35
|
columnCount: schema.columns.length,
|
|
34
36
|
primaryKey: schema.primaryKey,
|
|
35
|
-
childrenCount: options?.rowCount
|
|
37
|
+
childrenCount: options?.rowCount || -1
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
}
|
|
@@ -55,7 +57,7 @@ function buildMetaEntry(table, schema, pk, row, options) {
|
|
|
55
57
|
foreignKeys: schema.foreignKeys.filter((fk) => Object.keys(row).includes(fk.from)),
|
|
56
58
|
rowid: row.rowid
|
|
57
59
|
},
|
|
58
|
-
|
|
60
|
+
meta: {
|
|
59
61
|
table,
|
|
60
62
|
type: "meta"
|
|
61
63
|
}
|
|
@@ -70,7 +72,7 @@ function buildActionsListEntry(table, pk, actions, options) {
|
|
|
70
72
|
id: `${table}:${pk}:.actions:${action.name}`,
|
|
71
73
|
path: `${basePath}/${table}/${pk}/.actions/${action.name}`,
|
|
72
74
|
summary: action.name,
|
|
73
|
-
|
|
75
|
+
meta: {
|
|
74
76
|
kind: "afs:executable",
|
|
75
77
|
kinds: ["afs:executable", "afs:node"],
|
|
76
78
|
name: action.name,
|
|
@@ -88,7 +90,7 @@ function buildTableActionsListEntry(table, actions, options) {
|
|
|
88
90
|
id: `${table}:.actions:${action.name}`,
|
|
89
91
|
path: `${basePath}/${table}/.actions/${action.name}`,
|
|
90
92
|
summary: action.name,
|
|
91
|
-
|
|
93
|
+
meta: {
|
|
92
94
|
kind: "afs:executable",
|
|
93
95
|
kinds: ["afs:executable", "afs:node"],
|
|
94
96
|
name: action.name,
|
|
@@ -106,7 +108,7 @@ function buildRootActionsListEntry(actions, options) {
|
|
|
106
108
|
id: `:actions:${action.name}`,
|
|
107
109
|
path: `${basePath}/.actions/${action.name}`,
|
|
108
110
|
summary: action.name,
|
|
109
|
-
|
|
111
|
+
meta: {
|
|
110
112
|
kind: "afs:executable",
|
|
111
113
|
kinds: ["afs:executable", "afs:node"],
|
|
112
114
|
name: action.name,
|
|
@@ -131,7 +133,8 @@ function buildRootEntry(schemas, options) {
|
|
|
131
133
|
return {
|
|
132
134
|
id: "root",
|
|
133
135
|
path: basePath === "" ? "/" : basePath,
|
|
134
|
-
|
|
136
|
+
meta: {
|
|
137
|
+
kind: "sqlite:database",
|
|
135
138
|
description: "SQLite database root",
|
|
136
139
|
childrenCount: schemas.size,
|
|
137
140
|
tableCount: schemas.size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.cts","names":[],"sources":["../../src/node/builder.ts"],"mappings":";;;;;;AAMA;UAAiB,iBAAA;;EAEf,QAAA;AAAA;AAMF;;;AAAA,iBAAgB,aAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;;;
|
|
1
|
+
{"version":3,"file":"builder.d.cts","names":[],"sources":["../../src/node/builder.ts"],"mappings":";;;;;;AAMA;UAAiB,iBAAA;;EAEf,QAAA;AAAA;AAMF;;;AAAA,iBAAgB,aAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;;;iBAuBa,eAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,OAAA,GAAU,iBAAA;EAAsB,QAAA;AAAA,IAC/B,QAAA;;;;iBAoBa,cAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,EAAA,UACA,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;AA9BH;;UAkFiB,oBAAA;EACf,IAAA;EACA,WAAA;EACA,WAAA,GAAc,MAAA;AAAA;;;;iBAMA,qBAAA,CACd,KAAA,UACA,EAAA,UACA,OAAA,EAAS,oBAAA,IACT,OAAA,GAAU,iBAAA,GACT,QAAA;;;;iBAmEa,gBAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,WACA,OAAA,GAAU,iBAAA,GACT,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.mts","names":[],"sources":["../../src/node/builder.ts"],"mappings":";;;;;;AAMA;UAAiB,iBAAA;;EAEf,QAAA;AAAA;AAMF;;;AAAA,iBAAgB,aAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;;;
|
|
1
|
+
{"version":3,"file":"builder.d.mts","names":[],"sources":["../../src/node/builder.ts"],"mappings":";;;;;;AAMA;UAAiB,iBAAA;;EAEf,QAAA;AAAA;AAMF;;;AAAA,iBAAgB,aAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;;;iBAuBa,eAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,OAAA,GAAU,iBAAA;EAAsB,QAAA;AAAA,IAC/B,QAAA;;;;iBAoBa,cAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,EAAA,UACA,GAAA,EAAK,MAAA,mBACL,OAAA,GAAU,iBAAA,GACT,QAAA;;AA9BH;;UAkFiB,oBAAA;EACf,IAAA;EACA,WAAA;EACA,WAAA,GAAc,MAAA;AAAA;;;;iBAMA,qBAAA,CACd,KAAA,UACA,EAAA,UACA,OAAA,EAAS,oBAAA,IACT,OAAA,GAAU,iBAAA,GACT,QAAA;;;;iBAmEa,gBAAA,CACd,KAAA,UACA,MAAA,EAAQ,WAAA,EACR,GAAA,EAAK,MAAA,mBACL,OAAA,WACA,OAAA,GAAU,iBAAA,GACT,QAAA"}
|
package/dist/node/builder.mjs
CHANGED
|
@@ -10,7 +10,8 @@ function buildRowEntry(table, schema, row, options) {
|
|
|
10
10
|
id: `${table}:${pk}`,
|
|
11
11
|
path: `${basePath}/${table}/${pk}`,
|
|
12
12
|
content: row,
|
|
13
|
-
|
|
13
|
+
meta: {
|
|
14
|
+
kind: "sqlite:row",
|
|
14
15
|
table,
|
|
15
16
|
primaryKey: pkColumn,
|
|
16
17
|
primaryKeyValue: pk
|
|
@@ -26,12 +27,13 @@ function buildTableEntry(table, schema, options) {
|
|
|
26
27
|
return {
|
|
27
28
|
id: table,
|
|
28
29
|
path: `${options?.basePath ?? ""}/${table}`,
|
|
29
|
-
|
|
30
|
+
meta: {
|
|
31
|
+
kind: "sqlite:table",
|
|
30
32
|
description: `Table: ${table} (${schema.columns.length} columns)`,
|
|
31
33
|
table,
|
|
32
34
|
columnCount: schema.columns.length,
|
|
33
35
|
primaryKey: schema.primaryKey,
|
|
34
|
-
childrenCount: options?.rowCount
|
|
36
|
+
childrenCount: options?.rowCount || -1
|
|
35
37
|
}
|
|
36
38
|
};
|
|
37
39
|
}
|
|
@@ -54,7 +56,7 @@ function buildMetaEntry(table, schema, pk, row, options) {
|
|
|
54
56
|
foreignKeys: schema.foreignKeys.filter((fk) => Object.keys(row).includes(fk.from)),
|
|
55
57
|
rowid: row.rowid
|
|
56
58
|
},
|
|
57
|
-
|
|
59
|
+
meta: {
|
|
58
60
|
table,
|
|
59
61
|
type: "meta"
|
|
60
62
|
}
|
|
@@ -69,7 +71,7 @@ function buildActionsListEntry(table, pk, actions, options) {
|
|
|
69
71
|
id: `${table}:${pk}:.actions:${action.name}`,
|
|
70
72
|
path: `${basePath}/${table}/${pk}/.actions/${action.name}`,
|
|
71
73
|
summary: action.name,
|
|
72
|
-
|
|
74
|
+
meta: {
|
|
73
75
|
kind: "afs:executable",
|
|
74
76
|
kinds: ["afs:executable", "afs:node"],
|
|
75
77
|
name: action.name,
|
|
@@ -87,7 +89,7 @@ function buildTableActionsListEntry(table, actions, options) {
|
|
|
87
89
|
id: `${table}:.actions:${action.name}`,
|
|
88
90
|
path: `${basePath}/${table}/.actions/${action.name}`,
|
|
89
91
|
summary: action.name,
|
|
90
|
-
|
|
92
|
+
meta: {
|
|
91
93
|
kind: "afs:executable",
|
|
92
94
|
kinds: ["afs:executable", "afs:node"],
|
|
93
95
|
name: action.name,
|
|
@@ -105,7 +107,7 @@ function buildRootActionsListEntry(actions, options) {
|
|
|
105
107
|
id: `:actions:${action.name}`,
|
|
106
108
|
path: `${basePath}/.actions/${action.name}`,
|
|
107
109
|
summary: action.name,
|
|
108
|
-
|
|
110
|
+
meta: {
|
|
109
111
|
kind: "afs:executable",
|
|
110
112
|
kinds: ["afs:executable", "afs:node"],
|
|
111
113
|
name: action.name,
|
|
@@ -130,7 +132,8 @@ function buildRootEntry(schemas, options) {
|
|
|
130
132
|
return {
|
|
131
133
|
id: "root",
|
|
132
134
|
path: basePath === "" ? "/" : basePath,
|
|
133
|
-
|
|
135
|
+
meta: {
|
|
136
|
+
kind: "sqlite:database",
|
|
134
137
|
description: "SQLite database root",
|
|
135
138
|
childrenCount: schemas.size,
|
|
136
139
|
tableCount: schemas.size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.mjs","names":[],"sources":["../../src/node/builder.ts"],"sourcesContent":["import type { AFSEntry } from \"@aigne/afs\";\nimport type { TableSchema } from \"../schema/types.js\";\n\n/**\n * Options for building an AFSEntry\n */\nexport interface BuildEntryOptions {\n /** Base path prefix (e.g., empty string or module mount path) */\n basePath?: string;\n}\n\n/**\n * Builds an AFSEntry from a database row\n */\nexport function buildRowEntry(\n table: string,\n schema: TableSchema,\n row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const pkColumn = schema.primaryKey[0] ?? \"rowid\";\n const pk = String(row[pkColumn] ?? row.rowid);\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}`,\n path: `${basePath}/${table}/${pk}`,\n content: row,\n metadata: {\n table,\n primaryKey: pkColumn,\n primaryKeyValue: pk,\n },\n createdAt: parseDate(row.created_at ?? row.createdAt),\n updatedAt: parseDate(row.updated_at ?? row.updatedAt),\n };\n}\n\n/**\n * Builds an AFSEntry for a table listing\n */\nexport function buildTableEntry(\n table: string,\n schema: TableSchema,\n options?: BuildEntryOptions & { rowCount?: number },\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: table,\n path: `${basePath}/${table}`,\n metadata: {\n description: `Table: ${table} (${schema.columns.length} columns)`,\n table,\n columnCount: schema.columns.length,\n primaryKey: schema.primaryKey,\n childrenCount: options?.rowCount,\n },\n };\n}\n\n/**\n * Builds an AFSEntry for row metadata (using @meta suffix)\n */\nexport function buildMetaEntry(\n table: string,\n schema: TableSchema,\n pk: string,\n row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}:@meta`,\n path: `${basePath}/${table}/${pk}/@meta`,\n content: {\n table,\n primaryKey: schema.primaryKey[0] ?? \"rowid\",\n primaryKeyValue: pk,\n schema: {\n columns: schema.columns.map((c) => c.name),\n types: Object.fromEntries(schema.columns.map((c) => [c.name, c.type])),\n },\n foreignKeys: schema.foreignKeys.filter((fk) => Object.keys(row).includes(fk.from)),\n rowid: row.rowid,\n },\n metadata: {\n table,\n type: \"meta\",\n },\n };\n}\n\n/**\n * Builds an AFSEntry for row metadata (using .meta suffix - conformance standard)\n */\nexport function buildRowDotMetaEntry(\n table: string,\n schema: TableSchema,\n pk: string,\n _row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}:.meta`,\n path: `${basePath}/${table}/${pk}/.meta`,\n metadata: {\n table,\n primaryKey: schema.primaryKey[0] ?? \"rowid\",\n primaryKeyValue: pk,\n columnCount: schema.columns.length,\n columns: schema.columns.map((c) => c.name),\n },\n };\n}\n\n/**\n * Action definition with optional schema\n */\nexport interface ActionDefinitionInfo {\n name: string;\n description?: string;\n inputSchema?: Record<string, unknown>;\n}\n\n/**\n * Builds AFSEntry for row-level actions list\n */\nexport function buildActionsListEntry(\n table: string,\n pk: string,\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `${table}:${pk}:.actions:${action.name}`,\n path: `${basePath}/${table}/${pk}/.actions/${action.name}`,\n summary: action.name,\n metadata: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action on ${table}:${pk}`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds AFSEntry for table-level actions list\n */\nexport function buildTableActionsListEntry(\n table: string,\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `${table}:.actions:${action.name}`,\n path: `${basePath}/${table}/.actions/${action.name}`,\n summary: action.name,\n metadata: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action on table ${table}`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds AFSEntry for root-level actions list\n */\nexport function buildRootActionsListEntry(\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `:actions:${action.name}`,\n path: `${basePath}/.actions/${action.name}`,\n summary: action.name,\n metadata: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds a search result entry with highlights\n */\nexport function buildSearchEntry(\n table: string,\n schema: TableSchema,\n row: Record<string, unknown>,\n snippet?: string,\n options?: BuildEntryOptions,\n): AFSEntry {\n const entry = buildRowEntry(table, schema, row, options);\n\n if (snippet) {\n entry.summary = snippet;\n }\n\n return entry;\n}\n\n/**\n * Builds an AFSEntry for the root (database)\n */\nexport function buildRootEntry(\n schemas: Map<string, TableSchema>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: \"root\",\n path: basePath === \"\" ? \"/\" : basePath,\n metadata: {\n description: \"SQLite database root\",\n childrenCount: schemas.size,\n tableCount: schemas.size,\n },\n };\n}\n\n/**\n * Builds an AFSEntry for root metadata\n */\nexport function buildRootMetaEntry(\n schemas: Map<string, TableSchema>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: \"root:meta\",\n path: `${basePath}/.meta`,\n metadata: {\n description: \"SQLite database metadata\",\n tableCount: schemas.size,\n tables: Array.from(schemas.keys()),\n },\n };\n}\n\n/**\n * Builds an AFSEntry for table metadata (directory-level, not row-level)\n */\nexport function buildTableMetaEntry(\n table: string,\n schema: TableSchema,\n options?: BuildEntryOptions & { rowCount?: number },\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:meta`,\n path: `${basePath}/${table}/.meta`,\n metadata: {\n description: `Table metadata for: ${table}`,\n table,\n columnCount: schema.columns.length,\n primaryKey: schema.primaryKey,\n columns: schema.columns.map((c) => c.name),\n rowCount: options?.rowCount,\n },\n };\n}\n\n/**\n * Parses a date from various formats\n */\nfunction parseDate(value: unknown): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n if (typeof value === \"string\") return new Date(value);\n if (typeof value === \"number\") return new Date(value);\n return undefined;\n}\n"],"mappings":";;;;AAcA,SAAgB,cACd,OACA,QACA,KACA,SACU;CACV,MAAM,WAAW,OAAO,WAAW,MAAM;CACzC,MAAM,KAAK,OAAO,IAAI,aAAa,IAAI,MAAM;CAC7C,MAAM,WAAW,SAAS,YAAY;AAEtC,QAAO;EACL,IAAI,GAAG,MAAM,GAAG;EAChB,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG;EAC9B,SAAS;EACT,UAAU;GACR;GACA,YAAY;GACZ,iBAAiB;GAClB;EACD,WAAW,UAAU,IAAI,cAAc,IAAI,UAAU;EACrD,WAAW,UAAU,IAAI,cAAc,IAAI,UAAU;EACtD;;;;;AAMH,SAAgB,gBACd,OACA,QACA,SACU;AAGV,QAAO;EACL,IAAI;EACJ,MAAM,GAJS,SAAS,YAAY,GAIlB,GAAG;EACrB,UAAU;GACR,aAAa,UAAU,MAAM,IAAI,OAAO,QAAQ,OAAO;GACvD;GACA,aAAa,OAAO,QAAQ;GAC5B,YAAY,OAAO;GACnB,eAAe,SAAS;GACzB;EACF;;;;;AAMH,SAAgB,eACd,OACA,QACA,IACA,KACA,SACU;CACV,MAAM,WAAW,SAAS,YAAY;AAEtC,QAAO;EACL,IAAI,GAAG,MAAM,GAAG,GAAG;EACnB,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,GAAG;EACjC,SAAS;GACP;GACA,YAAY,OAAO,WAAW,MAAM;GACpC,iBAAiB;GACjB,QAAQ;IACN,SAAS,OAAO,QAAQ,KAAK,MAAM,EAAE,KAAK;IAC1C,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACvE;GAC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;AAML,SAAgB,iBACd,OACA,QACA,KACA,SACA,SACU;CACV,MAAM,QAAQ,cAAc,OAAO,QAAQ,KAAK,QAAQ;AAExD,KAAI,QACF,OAAM,UAAU;AAGlB,QAAO;;;;;AAMT,SAAgB,eACd,SACA,SACU;CACV,MAAM,WAAW,SAAS,YAAY;AAEtC,QAAO;EACL,IAAI;EACJ,MAAM,aAAa,KAAK,MAAM;EAC9B,UAAU;GACR,aAAa;GACb,eAAe,QAAQ;GACvB,YAAY,QAAQ;GACrB;EACF;;;;;AAkDH,SAAS,UAAU,OAAkC;AACnD,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,iBAAiB,KAAM,QAAO;AAClC,KAAI,OAAO,UAAU,SAAU,QAAO,IAAI,KAAK,MAAM;AACrD,KAAI,OAAO,UAAU,SAAU,QAAO,IAAI,KAAK,MAAM"}
|
|
1
|
+
{"version":3,"file":"builder.mjs","names":[],"sources":["../../src/node/builder.ts"],"sourcesContent":["import type { AFSEntry } from \"@aigne/afs\";\nimport type { TableSchema } from \"../schema/types.js\";\n\n/**\n * Options for building an AFSEntry\n */\nexport interface BuildEntryOptions {\n /** Base path prefix (e.g., empty string or module mount path) */\n basePath?: string;\n}\n\n/**\n * Builds an AFSEntry from a database row\n */\nexport function buildRowEntry(\n table: string,\n schema: TableSchema,\n row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const pkColumn = schema.primaryKey[0] ?? \"rowid\";\n const pk = String(row[pkColumn] ?? row.rowid);\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}`,\n path: `${basePath}/${table}/${pk}`,\n content: row,\n meta: {\n kind: \"sqlite:row\",\n table,\n primaryKey: pkColumn,\n primaryKeyValue: pk,\n },\n createdAt: parseDate(row.created_at ?? row.createdAt),\n updatedAt: parseDate(row.updated_at ?? row.updatedAt),\n };\n}\n\n/**\n * Builds an AFSEntry for a table listing\n */\nexport function buildTableEntry(\n table: string,\n schema: TableSchema,\n options?: BuildEntryOptions & { rowCount?: number },\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: table,\n path: `${basePath}/${table}`,\n meta: {\n kind: \"sqlite:table\",\n description: `Table: ${table} (${schema.columns.length} columns)`,\n table,\n columnCount: schema.columns.length,\n primaryKey: schema.primaryKey,\n childrenCount: options?.rowCount || -1,\n },\n };\n}\n\n/**\n * Builds an AFSEntry for row metadata (using @meta suffix)\n */\nexport function buildMetaEntry(\n table: string,\n schema: TableSchema,\n pk: string,\n row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}:@meta`,\n path: `${basePath}/${table}/${pk}/@meta`,\n content: {\n table,\n primaryKey: schema.primaryKey[0] ?? \"rowid\",\n primaryKeyValue: pk,\n schema: {\n columns: schema.columns.map((c) => c.name),\n types: Object.fromEntries(schema.columns.map((c) => [c.name, c.type])),\n },\n foreignKeys: schema.foreignKeys.filter((fk) => Object.keys(row).includes(fk.from)),\n rowid: row.rowid,\n },\n meta: {\n table,\n type: \"meta\",\n },\n };\n}\n\n/**\n * Builds an AFSEntry for row metadata (using .meta suffix - conformance standard)\n */\nexport function buildRowDotMetaEntry(\n table: string,\n schema: TableSchema,\n pk: string,\n _row: Record<string, unknown>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:${pk}:.meta`,\n path: `${basePath}/${table}/${pk}/.meta`,\n meta: {\n table,\n primaryKey: schema.primaryKey[0] ?? \"rowid\",\n primaryKeyValue: pk,\n columnCount: schema.columns.length,\n columns: schema.columns.map((c) => c.name),\n },\n };\n}\n\n/**\n * Action definition with optional schema\n */\nexport interface ActionDefinitionInfo {\n name: string;\n description?: string;\n inputSchema?: Record<string, unknown>;\n}\n\n/**\n * Builds AFSEntry for row-level actions list\n */\nexport function buildActionsListEntry(\n table: string,\n pk: string,\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `${table}:${pk}:.actions:${action.name}`,\n path: `${basePath}/${table}/${pk}/.actions/${action.name}`,\n summary: action.name,\n meta: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action on ${table}:${pk}`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds AFSEntry for table-level actions list\n */\nexport function buildTableActionsListEntry(\n table: string,\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `${table}:.actions:${action.name}`,\n path: `${basePath}/${table}/.actions/${action.name}`,\n summary: action.name,\n meta: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action on table ${table}`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds AFSEntry for root-level actions list\n */\nexport function buildRootActionsListEntry(\n actions: ActionDefinitionInfo[],\n options?: BuildEntryOptions,\n): AFSEntry[] {\n const basePath = options?.basePath ?? \"\";\n\n return actions.map((action) => ({\n id: `:actions:${action.name}`,\n path: `${basePath}/.actions/${action.name}`,\n summary: action.name,\n meta: {\n kind: \"afs:executable\",\n kinds: [\"afs:executable\", \"afs:node\"],\n name: action.name,\n description: action.description ?? `Execute ${action.name} action`,\n inputSchema: action.inputSchema,\n },\n }));\n}\n\n/**\n * Builds a search result entry with highlights\n */\nexport function buildSearchEntry(\n table: string,\n schema: TableSchema,\n row: Record<string, unknown>,\n snippet?: string,\n options?: BuildEntryOptions,\n): AFSEntry {\n const entry = buildRowEntry(table, schema, row, options);\n\n if (snippet) {\n entry.summary = snippet;\n }\n\n return entry;\n}\n\n/**\n * Builds an AFSEntry for the root (database)\n */\nexport function buildRootEntry(\n schemas: Map<string, TableSchema>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: \"root\",\n path: basePath === \"\" ? \"/\" : basePath,\n meta: {\n kind: \"sqlite:database\",\n description: \"SQLite database root\",\n childrenCount: schemas.size,\n tableCount: schemas.size,\n },\n };\n}\n\n/**\n * Builds an AFSEntry for root metadata\n */\nexport function buildRootMetaEntry(\n schemas: Map<string, TableSchema>,\n options?: BuildEntryOptions,\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: \"root:meta\",\n path: `${basePath}/.meta`,\n meta: {\n description: \"SQLite database metadata\",\n tableCount: schemas.size,\n tables: Array.from(schemas.keys()),\n },\n };\n}\n\n/**\n * Builds an AFSEntry for table metadata (directory-level, not row-level)\n */\nexport function buildTableMetaEntry(\n table: string,\n schema: TableSchema,\n options?: BuildEntryOptions & { rowCount?: number },\n): AFSEntry {\n const basePath = options?.basePath ?? \"\";\n\n return {\n id: `${table}:meta`,\n path: `${basePath}/${table}/.meta`,\n meta: {\n description: `Table metadata for: ${table}`,\n table,\n columnCount: schema.columns.length,\n primaryKey: schema.primaryKey,\n columns: schema.columns.map((c) => c.name),\n rowCount: options?.rowCount,\n },\n };\n}\n\n/**\n * Parses a date from various formats\n */\nfunction parseDate(value: unknown): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n if (typeof value === \"string\") return new Date(value);\n if (typeof value === \"number\") return new Date(value);\n return undefined;\n}\n"],"mappings":";;;;AAcA,SAAgB,cACd,OACA,QACA,KACA,SACU;CACV,MAAM,WAAW,OAAO,WAAW,MAAM;CACzC,MAAM,KAAK,OAAO,IAAI,aAAa,IAAI,MAAM;CAC7C,MAAM,WAAW,SAAS,YAAY;AAEtC,QAAO;EACL,IAAI,GAAG,MAAM,GAAG;EAChB,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG;EAC9B,SAAS;EACT,MAAM;GACJ,MAAM;GACN;GACA,YAAY;GACZ,iBAAiB;GAClB;EACD,WAAW,UAAU,IAAI,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U,SAAU,QAAO,IAAI,KAAK,MAAM"}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Builds a SELECT query string for a single row by primary key
|
|
5
5
|
*/
|
|
6
6
|
function buildSelectByPK(tableName, schema, pk) {
|
|
7
|
-
return `SELECT * FROM "${tableName}" WHERE "${schema.primaryKey[0] ?? "rowid"}" = '${escapeSQLString(pk)}'`;
|
|
7
|
+
return `SELECT rowid, * FROM "${tableName}" WHERE "${schema.primaryKey[0] ?? "rowid"}" = '${escapeSQLString(pk)}'`;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Builds a SELECT query string for listing rows with optional limit and offset
|
|
11
11
|
*/
|
|
12
12
|
function buildSelectAll(tableName, options) {
|
|
13
|
-
let query = `SELECT * FROM "${tableName}"`;
|
|
13
|
+
let query = `SELECT rowid, * FROM "${tableName}"`;
|
|
14
14
|
if (options?.orderBy?.length) {
|
|
15
15
|
const orderClauses = options.orderBy.map(([col, dir]) => `"${col}" ${dir.toUpperCase()}`);
|
|
16
16
|
query += ` ORDER BY ${orderClauses.join(", ")}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.cts","names":[],"sources":["../../src/operations/query-builder.ts"],"mappings":";;;;;AAKA;iBAAgB,eAAA,CAAgB,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;;
|
|
1
|
+
{"version":3,"file":"query-builder.d.cts","names":[],"sources":["../../src/operations/query-builder.ts"],"mappings":";;;;;AAKA;iBAAgB,eAAA,CAAgB,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;;iBASxD,cAAA,CACd,SAAA,UACA,OAAA;EACE,KAAA;EACA,MAAA;EACA,OAAA;AAAA;AALJ;;;AAAA,iBA8BgB,WAAA,CACd,SAAA,UACA,MAAA,EAAQ,WAAA,EACR,OAAA,EAAS,MAAA;;;;iBAmBK,WAAA,CACd,SAAA,UACA,MAAA,EAAQ,WAAA,EACR,EAAA,UACA,OAAA,EAAS,MAAA;;;;iBAsBK,WAAA,CAAY,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;AA1BpE;iBAoEgB,iBAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.mts","names":[],"sources":["../../src/operations/query-builder.ts"],"mappings":";;;;;AAKA;iBAAgB,eAAA,CAAgB,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;;
|
|
1
|
+
{"version":3,"file":"query-builder.d.mts","names":[],"sources":["../../src/operations/query-builder.ts"],"mappings":";;;;;AAKA;iBAAgB,eAAA,CAAgB,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;;iBASxD,cAAA,CACd,SAAA,UACA,OAAA;EACE,KAAA;EACA,MAAA;EACA,OAAA;AAAA;AALJ;;;AAAA,iBA8BgB,WAAA,CACd,SAAA,UACA,MAAA,EAAQ,WAAA,EACR,OAAA,EAAS,MAAA;;;;iBAmBK,WAAA,CACd,SAAA,UACA,MAAA,EAAQ,WAAA,EACR,EAAA,UACA,OAAA,EAAS,MAAA;;;;iBAsBK,WAAA,CAAY,SAAA,UAAmB,MAAA,EAAQ,WAAA,EAAa,EAAA;;;AA1BpE;iBAoEgB,iBAAA,CAAA"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Builds a SELECT query string for a single row by primary key
|
|
4
4
|
*/
|
|
5
5
|
function buildSelectByPK(tableName, schema, pk) {
|
|
6
|
-
return `SELECT * FROM "${tableName}" WHERE "${schema.primaryKey[0] ?? "rowid"}" = '${escapeSQLString(pk)}'`;
|
|
6
|
+
return `SELECT rowid, * FROM "${tableName}" WHERE "${schema.primaryKey[0] ?? "rowid"}" = '${escapeSQLString(pk)}'`;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Builds a SELECT query string for listing rows with optional limit and offset
|
|
10
10
|
*/
|
|
11
11
|
function buildSelectAll(tableName, options) {
|
|
12
|
-
let query = `SELECT * FROM "${tableName}"`;
|
|
12
|
+
let query = `SELECT rowid, * FROM "${tableName}"`;
|
|
13
13
|
if (options?.orderBy?.length) {
|
|
14
14
|
const orderClauses = options.orderBy.map(([col, dir]) => `"${col}" ${dir.toUpperCase()}`);
|
|
15
15
|
query += ` ORDER BY ${orderClauses.join(", ")}`;
|