@morlay/session-rdb 0.1.4 → 0.1.6
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 +4 -7
- package/dist/artifact.d.mts +2 -1
- package/dist/{src-BmogreEz.mjs → deletion-ODZFcbZm.mjs} +134 -90
- package/dist/deletion.d.mts +1 -1
- package/dist/deletion.mjs +1 -1
- package/dist/export.d.mts +1 -1
- package/dist/gc.d.mts +1 -1
- package/dist/import.d.mts +2 -2
- package/dist/import.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/log-C0q5svm7.d.mts +594 -0
- package/dist/{sqlite-YCr2-Fov.mjs → sqlite-DjOnMRh2.mjs} +73 -2
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +1 -2
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +95 -14669
- package/dist/usage.d.mts +1 -1
- package/drizzle/postgres/20261008103001_v3_schedule_tasks/migration.sql +11 -0
- package/drizzle/sqlite/20261008103000_v3_schedule_tasks/migration.sql +14 -0
- package/package.json +60 -42
- package/src/branch.ts +1 -1
- package/src/entities/v3/index.ts +4 -0
- package/src/entities/v3/schedule-tasks.ts +16 -0
- package/src/index.ts +2 -1
- package/src/schema.ts +2 -0
- package/src/sqlite.ts +5 -2
- package/src/storage-takeover/repository.ts +61 -0
- package/src/storage-takeover/storage-backend.ts +120 -42
- package/src/storage-takeover/types.ts +9 -0
- package/dist/dist-DHer1cql.mjs +0 -1531
- package/dist/invariant.d.mts +0 -6
- package/dist/invariant.mjs +0 -8
- package/dist/log-DYyxRh7j.d.mts +0 -6078
- package/dist/rolldown-runtime-EAsCxrDo.mjs +0 -14
- package/src/invariant.ts +0 -13
- package/dist/{branch-aiXPmnKC.mjs → branch-DbFW3rJX.mjs} +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { COUNTED_EVENT_TYPES, addActivityTotals, addTokenTotals, addTotals, emptyTotals, localDayKey } from "./usage.mjs";
|
|
2
2
|
import { _ as sessionConflictRow, b as titleOfEventData, v as sessionInsertRow } from "./log-DYxdjJ-l.mjs";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
3
|
import { SESSION_FORMAT_VERSION, SessionId, SessionLogOffset, SessionSeq } from "@deepseek-ai/dsh-session";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
5
|
import { and, desc, eq, gte, inArray, isNotNull, lt, notInArray, sql } from "drizzle-orm";
|
|
6
6
|
import { check, index, integer, sqliteTable, text, unique } from "drizzle-orm/sqlite-core";
|
|
7
7
|
import { bigint, check as check$1, index as index$1, integer as integer$1, pgSchema, pgTable, serial, text as text$1, unique as unique$1 } from "drizzle-orm/pg-core";
|
|
@@ -412,6 +412,32 @@ const workspaceState = {
|
|
|
412
412
|
checks: { ck_workspace_state_singleton: { expression: "f_singleton = 1" } }
|
|
413
413
|
};
|
|
414
414
|
//#endregion
|
|
415
|
+
//#region src/entities/v3/schedule-tasks.ts
|
|
416
|
+
const scheduleTasks = {
|
|
417
|
+
name: "t_schedule_tasks",
|
|
418
|
+
columns: {
|
|
419
|
+
f_id: {
|
|
420
|
+
type: "text",
|
|
421
|
+
primaryKey: true
|
|
422
|
+
},
|
|
423
|
+
f_session_id: {
|
|
424
|
+
type: "text",
|
|
425
|
+
notNull: true
|
|
426
|
+
},
|
|
427
|
+
f_status: {
|
|
428
|
+
type: "text",
|
|
429
|
+
notNull: true
|
|
430
|
+
},
|
|
431
|
+
f_record: {
|
|
432
|
+
type: "text",
|
|
433
|
+
notNull: true
|
|
434
|
+
},
|
|
435
|
+
f_last_delivery: { type: "text" },
|
|
436
|
+
f_delivery_history: { type: "text" }
|
|
437
|
+
},
|
|
438
|
+
indexes: { idx_schedule_tasks_session_id: { columns: ["f_session_id"] } }
|
|
439
|
+
};
|
|
440
|
+
//#endregion
|
|
415
441
|
//#region src/entities/v3/session-projcache-rows.ts
|
|
416
442
|
const sessionProjcacheRows = {
|
|
417
443
|
name: "t_session_projcache_row",
|
|
@@ -625,6 +651,7 @@ const sqliteTableDefs = [
|
|
|
625
651
|
workspaces,
|
|
626
652
|
workspaceSessions,
|
|
627
653
|
workspaceState,
|
|
654
|
+
scheduleTasks,
|
|
628
655
|
sessionProjcacheRows,
|
|
629
656
|
eventUsage,
|
|
630
657
|
sessionUsage,
|
|
@@ -640,6 +667,7 @@ const postgresTableDefs = [
|
|
|
640
667
|
workspaces,
|
|
641
668
|
workspaceSessions,
|
|
642
669
|
workspaceState,
|
|
670
|
+
scheduleTasks,
|
|
643
671
|
sessionProjcacheRows,
|
|
644
672
|
eventUsage,
|
|
645
673
|
sessionUsage,
|
|
@@ -661,6 +689,7 @@ const tStorageUnits = sqliteTables["t_storage_units"];
|
|
|
661
689
|
const tWorkspaces = sqliteTables["t_workspaces"];
|
|
662
690
|
const tWorkspaceSessions = sqliteTables["t_workspace_sessions"];
|
|
663
691
|
const tWorkspaceState = sqliteTables["t_workspace_state"];
|
|
692
|
+
const tScheduleTasks = sqliteTables["t_schedule_tasks"];
|
|
664
693
|
const tSessionProjcacheRows = sqliteTables["t_session_projcache_row"];
|
|
665
694
|
const tEventUsage = sqliteTables["t_event_usage"];
|
|
666
695
|
const tSessionUsage = sqliteTables["t_session_usage"];
|
|
@@ -860,6 +889,25 @@ function pendingMutationOf(row) {
|
|
|
860
889
|
workspaceId: row.fPendingWorkspaceId ?? ""
|
|
861
890
|
};
|
|
862
891
|
}
|
|
892
|
+
function taskFromRow(row) {
|
|
893
|
+
return {
|
|
894
|
+
sessionId: row.fSessionId,
|
|
895
|
+
record: JSON.parse(row.fRecord),
|
|
896
|
+
status: row.fStatus === "inactive" ? "inactive" : "active",
|
|
897
|
+
...row.fLastDelivery === null ? {} : { lastDelivery: JSON.parse(row.fLastDelivery) },
|
|
898
|
+
...row.fDeliveryHistory === null ? {} : { deliveryHistory: JSON.parse(row.fDeliveryHistory) }
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
function rowFromTask(id, task) {
|
|
902
|
+
return {
|
|
903
|
+
fId: id,
|
|
904
|
+
fSessionId: task.sessionId,
|
|
905
|
+
fStatus: task.status === "inactive" ? "inactive" : "active",
|
|
906
|
+
fRecord: JSON.stringify(task.record),
|
|
907
|
+
fLastDelivery: task.lastDelivery === void 0 ? null : JSON.stringify(task.lastDelivery),
|
|
908
|
+
fDeliveryHistory: task.deliveryHistory === void 0 ? null : JSON.stringify(task.deliveryHistory)
|
|
909
|
+
};
|
|
910
|
+
}
|
|
863
911
|
function createStorageRepository(host) {
|
|
864
912
|
const tables = host.tables;
|
|
865
913
|
const tUnits = tables["t_storage_units"];
|
|
@@ -867,6 +915,7 @@ function createStorageRepository(host) {
|
|
|
867
915
|
const tWorkspaces = tables["t_workspaces"];
|
|
868
916
|
const tWorkspaceSessions = tables["t_workspace_sessions"];
|
|
869
917
|
const tWorkspaceState = tables["t_workspace_state"];
|
|
918
|
+
const tScheduleTasks = tables["t_schedule_tasks"];
|
|
870
919
|
const tProjcacheRows = tables["t_session_projcache_row"];
|
|
871
920
|
const sessionIdentity = {
|
|
872
921
|
fSessionId: tSessions.fSessionId,
|
|
@@ -1001,6 +1050,27 @@ function createStorageRepository(host) {
|
|
|
1001
1050
|
}));
|
|
1002
1051
|
});
|
|
1003
1052
|
},
|
|
1053
|
+
async listScheduleTasks() {
|
|
1054
|
+
return (await allRows((await dbx()).select().from(tScheduleTasks))).map((row) => ({
|
|
1055
|
+
id: row.fId,
|
|
1056
|
+
task: taskFromRow(row)
|
|
1057
|
+
}));
|
|
1058
|
+
},
|
|
1059
|
+
async putScheduleTask(id, task) {
|
|
1060
|
+
await host.writeAtomically(async () => {
|
|
1061
|
+
const db = await dbx();
|
|
1062
|
+
const values = rowFromTask(id, task);
|
|
1063
|
+
await runQuery(db.insert(tScheduleTasks).values(values).onConflictDoUpdate({
|
|
1064
|
+
target: tScheduleTasks.fId,
|
|
1065
|
+
set: values
|
|
1066
|
+
}));
|
|
1067
|
+
});
|
|
1068
|
+
},
|
|
1069
|
+
async deleteScheduleTask(id) {
|
|
1070
|
+
await host.writeAtomically(async () => {
|
|
1071
|
+
await runQuery((await dbx()).delete(tScheduleTasks).where(eq(tScheduleTasks.fId, id)));
|
|
1072
|
+
});
|
|
1073
|
+
},
|
|
1004
1074
|
async loadProjcache() {
|
|
1005
1075
|
const db = await dbx();
|
|
1006
1076
|
const rows = await allRows(db.select().from(tProjcacheRows));
|
|
@@ -1304,6 +1374,7 @@ var SqliteBackend = class SqliteBackend {
|
|
|
1304
1374
|
t_workspaces: tWorkspaces,
|
|
1305
1375
|
t_workspace_sessions: tWorkspaceSessions,
|
|
1306
1376
|
t_workspace_state: tWorkspaceState,
|
|
1377
|
+
t_schedule_tasks: tScheduleTasks,
|
|
1307
1378
|
t_session_projcache_row: tSessionProjcacheRows
|
|
1308
1379
|
}
|
|
1309
1380
|
});
|
|
@@ -1703,4 +1774,4 @@ var SqliteBackend = class SqliteBackend {
|
|
|
1703
1774
|
}
|
|
1704
1775
|
};
|
|
1705
1776
|
//#endregion
|
|
1706
|
-
export {
|
|
1777
|
+
export { tWorkspaces as C, WriteGuard as E, tWorkspaceState as S, toPostgresSchema as T, tSessionProjcacheRows as _, EVENT_ENCODING as a, tStorageUnits as b, eventDimensions as c, tEvents as d, tPersistenceState as f, tSessionEvents as g, tSessionCounts as h, DEFAULT_BUSY_TIMEOUT_MS as i, eventKind as l, tSchemaMeta as m, openDatabase as n, SCHEMA_VERSION as o, tScheduleTasks as p, createStorageRepository as r, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID as s, SqliteBackend as t, tEventUsage as u, tSessionUsage as v, postgresTableDefs as w, tWorkspaceSessions as x, tSessions as y };
|
package/dist/storage.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as SessionRow, At as
|
|
1
|
+
import { A as SessionRow, At as tWorkspaces, Ct as tSessionEvents, D as SessionCountBucket, Dt as tStorageUnits, E as EventRow, Et as tSessions, F as UsageAggregate, O as SessionListRowsPage, Ot as tWorkspaceSessions, Rt as StorageRepository, St as tSessionCounts, T as BackendTx, Tt as tSessionUsage, _t as tEventUsage, bt as tScheduleTasks, ct as DEFAULT_BUSY_TIMEOUT_MS, dt as EventRole, ft as JournalMode, gt as eventKind, ht as eventDimensions, j as SessionUsageBucket, jt as WriteGuard, k as SessionListRowsQuery, kt as tWorkspaceState, lt as EVENT_ENCODING, mt as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, pt as SCHEMA_VERSION, ut as EventKind, vt as tEvents, w as Backend, wt as tSessionProjcacheRows, xt as tSchemaMeta, yt as tPersistenceState } from "./log-C0q5svm7.mjs";
|
|
2
2
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
3
3
|
import { DatabaseSync } from "node:sqlite";
|
|
4
4
|
//#region src/sqlite.d.ts
|
|
@@ -56,4 +56,4 @@ export declare class SqliteBackend implements Backend {
|
|
|
56
56
|
private eventRows;
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
|
-
export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, EventKind, EventRole, type EventRow, JournalMode, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, type SessionRow, WriteGuard, eventDimensions, eventKind, tEventUsage, tEvents, tPersistenceState, tSchemaMeta, tSessionCounts, tSessionEvents, tSessionProjcacheRows, tSessionUsage, tSessions, tStorageUnits, tWorkspaceSessions, tWorkspaceState, tWorkspaces };
|
|
59
|
+
export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, EventKind, EventRole, type EventRow, JournalMode, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, type SessionRow, WriteGuard, eventDimensions, eventKind, tEventUsage, tEvents, tPersistenceState, tScheduleTasks, tSchemaMeta, tSessionCounts, tSessionEvents, tSessionProjcacheRows, tSessionUsage, tSessions, tStorageUnits, tWorkspaceSessions, tWorkspaceState, tWorkspaces };
|
package/dist/storage.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { DEFAULT_BUSY_TIMEOUT_MS, EVENT_ENCODING, SCHEMA_VERSION, SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, SqliteBackend, WriteGuard, eventDimensions, eventKind, openDatabase, tEventUsage, tEvents, tPersistenceState, tSchemaMeta, tSessionCounts, tSessionEvents, tSessionProjcacheRows, tSessionUsage, tSessions, tStorageUnits, tWorkspaceSessions, tWorkspaceState, tWorkspaces };
|
|
1
|
+
export { i as DEFAULT_BUSY_TIMEOUT_MS, a as EVENT_ENCODING, o as SCHEMA_VERSION, s as SESSION_PERSISTENCE_SQLITE_APPLICATION_ID, t as SqliteBackend, E as WriteGuard, c as eventDimensions, l as eventKind, n as openDatabase, u as tEventUsage, d as tEvents, f as tPersistenceState, p as tScheduleTasks, m as tSchemaMeta, h as tSessionCounts, g as tSessionEvents, _ as tSessionProjcacheRows, v as tSessionUsage, y as tSessions, b as tStorageUnits, x as tWorkspaceSessions, S as tWorkspaceState, C as tWorkspaces } from "./sqlite-DjOnMRh2.mjs";
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { at as truncateLiveSession } from "./log-
|
|
2
|
-
import { SessionPersistence } from "@deepseek-ai/dsh-session-persistence";
|
|
1
|
+
import { at as truncateLiveSession } from "./log-C0q5svm7.mjs";
|
|
3
2
|
import { Session, SessionEvent, SessionHeader, SessionId } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { SessionPersistence } from "@deepseek-ai/dsh-session-persistence";
|
|
4
4
|
import { Context, Fiber } from "@deepseek-ai/cordis";
|
|
5
5
|
//#region src/testing/contract.d.ts
|
|
6
6
|
interface ContractBackendInstance {
|