@artinet/sdk 0.6.8 → 0.6.9
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/storage/sqlite.d.ts +1 -1
- package/dist/storage/sqlite.js +15 -24
- package/package.json +1 -1
package/dist/storage/sqlite.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { A2A } from "../types/index.js";
|
|
6
6
|
import { Tasks } from "../services/a2a/managers.js";
|
|
7
|
-
import { BaseSQLiteDatabase } from
|
|
7
|
+
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
8
8
|
export declare const TABLE_NAME = "artinet_tasks";
|
|
9
9
|
export declare const createTaskTable: (db: BaseSQLiteDatabase<`sync` | `async`, any, TaskTable>) => Promise<void>;
|
|
10
10
|
export declare const TaskTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
package/dist/storage/sqlite.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { Tasks } from "../services/a2a/managers.js";
|
|
6
|
-
import { eq, like, or
|
|
7
|
-
import { sqliteTable, text } from
|
|
6
|
+
import { eq, like, or /*Table, TableConfig*/ } from 'drizzle-orm';
|
|
7
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core';
|
|
8
8
|
import { logger } from "../config/index.js";
|
|
9
|
-
export const TABLE_NAME =
|
|
9
|
+
export const TABLE_NAME = 'artinet_tasks';
|
|
10
10
|
const CREATE_TASKS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS ${TABLE_NAME}\
|
|
11
11
|
(id TEXT PRIMARY KEY, contextId TEXT NOT NULL,\
|
|
12
12
|
kind TEXT NOT NULL, status TEXT NOT NULL,\
|
|
@@ -20,20 +20,11 @@ export const createTaskTable = async (db) => {
|
|
|
20
20
|
export const TaskTable = sqliteTable(TABLE_NAME, {
|
|
21
21
|
id: text().primaryKey(),
|
|
22
22
|
contextId: text().notNull(),
|
|
23
|
-
kind: text(
|
|
24
|
-
status: text(
|
|
25
|
-
history: text(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.default([]),
|
|
29
|
-
artifacts: text("artifacts", { mode: "json" })
|
|
30
|
-
.$type()
|
|
31
|
-
.notNull()
|
|
32
|
-
.default([]),
|
|
33
|
-
metadata: text("metadata", { mode: "json" })
|
|
34
|
-
.$type()
|
|
35
|
-
.notNull()
|
|
36
|
-
.default({}),
|
|
23
|
+
kind: text('kind').$type().notNull(),
|
|
24
|
+
status: text('status', { mode: 'json' }).$type().notNull(),
|
|
25
|
+
history: text('history', { mode: 'json' }).$type().notNull().default([]),
|
|
26
|
+
artifacts: text('artifacts', { mode: 'json' }).$type().notNull().default([]),
|
|
27
|
+
metadata: text('metadata', { mode: 'json' }).$type().notNull().default({}),
|
|
37
28
|
});
|
|
38
29
|
export class SQLiteStore extends Tasks {
|
|
39
30
|
db;
|
|
@@ -47,11 +38,7 @@ export class SQLiteStore extends Tasks {
|
|
|
47
38
|
if (task) {
|
|
48
39
|
return task;
|
|
49
40
|
}
|
|
50
|
-
task = await this.db
|
|
51
|
-
.select()
|
|
52
|
-
.from(TaskTable)
|
|
53
|
-
.where(eq(TaskTable.id, id))
|
|
54
|
-
.get();
|
|
41
|
+
task = await this.db.select().from(TaskTable).where(eq(TaskTable.id, id)).get();
|
|
55
42
|
if (task) {
|
|
56
43
|
await super.set(id, task);
|
|
57
44
|
}
|
|
@@ -62,12 +49,16 @@ export class SQLiteStore extends Tasks {
|
|
|
62
49
|
return;
|
|
63
50
|
}
|
|
64
51
|
if (id !== data.id) {
|
|
65
|
-
logger.warn(
|
|
66
|
-
throw new Error(
|
|
52
|
+
logger.warn('SQLiteStore', `Task ID mismatch: ${id} !== ${data.id}`);
|
|
53
|
+
throw new Error('Task ID mismatch');
|
|
67
54
|
}
|
|
68
55
|
await this.db
|
|
69
56
|
.insert(TaskTable)
|
|
70
57
|
.values({ ...data, id })
|
|
58
|
+
.onConflictDoUpdate({
|
|
59
|
+
target: [TaskTable.id],
|
|
60
|
+
set: { ...data },
|
|
61
|
+
})
|
|
71
62
|
.execute();
|
|
72
63
|
await super.set(id, data);
|
|
73
64
|
}
|