@morlay/session-rdb 0.0.14 → 0.0.16-alpha.0

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.
Files changed (65) hide show
  1. package/README.md +11 -13
  2. package/dist/artifact.d.mts +6 -16
  3. package/dist/artifact.mjs +3 -3
  4. package/dist/{import-B-tf5vQn.mjs → import-CKrzjXVB.mjs} +73 -83
  5. package/dist/import.d.mts +2 -3
  6. package/dist/import.mjs +2 -2
  7. package/dist/index-CgGDHQSK.d.mts +225 -0
  8. package/dist/index.d.mts +3 -3
  9. package/dist/index.mjs +694 -169
  10. package/dist/log-DTJsxMud.mjs +314 -0
  11. package/dist/{schema-CFXZURX7.d.mts → schema-COK7-wRV.d.mts} +3 -15
  12. package/dist/sqlite-DCy4VTD8.mjs +698 -0
  13. package/dist/storage.d.mts +2 -7
  14. package/dist/storage.mjs +2 -3
  15. package/dist/testing.d.mts +30 -1
  16. package/dist/testing.mjs +676 -1991
  17. package/drizzle/postgres/20260908072805_v2_initial/migration.sql +58 -0
  18. package/drizzle/postgres/20260908072805_v2_initial/snapshot.json +686 -0
  19. package/drizzle/postgres/20260908072806_v3_drop_original_seq/migration.sql +1 -0
  20. package/drizzle/postgres/20260908072806_v3_drop_original_seq/snapshot.json +673 -0
  21. package/drizzle/sqlite/20260908072751_v2_initial/migration.sql +53 -0
  22. package/drizzle/sqlite/20260908072751_v2_initial/snapshot.json +492 -0
  23. package/drizzle/sqlite/20260908072752_v3_drop_original_seq/migration.sql +6 -0
  24. package/drizzle/sqlite/20260908072752_v3_drop_original_seq/snapshot.json +513 -0
  25. package/package.json +17 -12
  26. package/src/adapters/index.ts +10 -2
  27. package/src/adapters/to-postgres.ts +19 -15
  28. package/src/adapters/to-sqlite.ts +20 -14
  29. package/src/{entities → adapters}/types.ts +7 -8
  30. package/src/backend.ts +0 -7
  31. package/src/branch.ts +29 -110
  32. package/src/drizzle/postgres-v2.ts +11 -0
  33. package/src/drizzle/postgres-v3.ts +11 -0
  34. package/src/drizzle/sqlite-v2.ts +10 -0
  35. package/src/drizzle/sqlite-v3.ts +11 -0
  36. package/src/entities/index.ts +2 -30
  37. package/src/entities/v2/index.ts +20 -0
  38. package/src/entities/v2/session-events.ts +11 -0
  39. package/src/entities/v3/events.ts +27 -0
  40. package/src/entities/v3/index.ts +27 -0
  41. package/src/entities/v3/persistence-state.ts +10 -0
  42. package/src/entities/v3/schema-meta.ts +9 -0
  43. package/src/entities/v3/session-events.ts +26 -0
  44. package/src/entities/v3/sessions.ts +20 -0
  45. package/src/import.ts +65 -57
  46. package/src/index.ts +868 -223
  47. package/src/invariant.ts +0 -2
  48. package/src/legacy.ts +67 -0
  49. package/src/log.ts +41 -81
  50. package/src/postgres.ts +75 -93
  51. package/src/schema.ts +3 -14
  52. package/src/sqlite.ts +59 -46
  53. package/src/testing/contract.ts +460 -375
  54. package/src/testing/coordinator-contract.ts +108 -1374
  55. package/src/testing.ts +1 -6
  56. package/dist/index-uUvn6gYp.d.mts +0 -111
  57. package/dist/schema-BfPVmr1X.mjs +0 -875
  58. package/dist/sqlite-BUWnS0so.mjs +0 -356
  59. package/src/adapters/ddl.ts +0 -77
  60. package/src/entities/events.ts +0 -27
  61. package/src/entities/persistence-state.ts +0 -10
  62. package/src/entities/schema-meta.ts +0 -9
  63. package/src/entities/session-events.ts +0 -29
  64. package/src/entities/sessions.ts +0 -20
  65. package/src/migrate.ts +0 -137
@@ -0,0 +1,58 @@
1
+ CREATE TABLE "t_events" (
2
+ "f_id" serial PRIMARY KEY,
3
+ "f_event_id" text NOT NULL UNIQUE,
4
+ "f_parent_id" text DEFAULT '' NOT NULL,
5
+ "f_type" text DEFAULT '' NOT NULL,
6
+ "f_kind" text DEFAULT '' NOT NULL,
7
+ "f_role" text DEFAULT '' NOT NULL,
8
+ "f_name" text DEFAULT '' NOT NULL,
9
+ "f_action_id" text DEFAULT '' NOT NULL,
10
+ "f_encoding" text DEFAULT '' NOT NULL,
11
+ "f_data" text NOT NULL,
12
+ "f_created_at" bigint DEFAULT 0 NOT NULL
13
+ );
14
+ --> statement-breakpoint
15
+ CREATE TABLE "t_persistence_state" (
16
+ "f_singleton" integer PRIMARY KEY,
17
+ "f_store_id" text NOT NULL,
18
+ CONSTRAINT "ck_persistence_state_singleton" CHECK (f_singleton = 1)
19
+ );
20
+ --> statement-breakpoint
21
+ CREATE TABLE "t_schema_meta" (
22
+ "f_key" text PRIMARY KEY,
23
+ "f_value" text NOT NULL
24
+ );
25
+ --> statement-breakpoint
26
+ CREATE TABLE "t_session_events" (
27
+ "f_id" serial PRIMARY KEY,
28
+ "f_session_id" text NOT NULL,
29
+ "f_event_id" text NOT NULL,
30
+ "f_sequence" integer NOT NULL,
31
+ "f_surface_op" text,
32
+ "f_original_seq" integer NOT NULL,
33
+ CONSTRAINT "uq_session_events_session_sequence" UNIQUE("f_session_id","f_sequence")
34
+ );
35
+ --> statement-breakpoint
36
+ CREATE TABLE "t_sessions" (
37
+ "f_id" serial PRIMARY KEY,
38
+ "f_session_id" text NOT NULL UNIQUE,
39
+ "f_head_event_id" text DEFAULT '' NOT NULL,
40
+ "f_head_sequence" integer DEFAULT -1 NOT NULL,
41
+ "f_version" integer NOT NULL,
42
+ "f_created_at" bigint NOT NULL,
43
+ "f_cwd" text,
44
+ "f_parent_session" text,
45
+ "f_seed_length" integer,
46
+ "f_origin" text,
47
+ "f_delegation_depth" integer,
48
+ "f_incarnation" text NOT NULL,
49
+ "f_revision" integer NOT NULL
50
+ );
51
+ --> statement-breakpoint
52
+ CREATE INDEX "idx_events_kind" ON "t_events" ("f_kind");--> statement-breakpoint
53
+ CREATE INDEX "idx_events_role" ON "t_events" ("f_role");--> statement-breakpoint
54
+ CREATE INDEX "idx_events_name" ON "t_events" ("f_name");--> statement-breakpoint
55
+ CREATE INDEX "idx_events_action_id" ON "t_events" ("f_action_id");--> statement-breakpoint
56
+ CREATE INDEX "idx_session_events_event_id" ON "t_session_events" ("f_event_id");--> statement-breakpoint
57
+ ALTER TABLE "t_session_events" ADD CONSTRAINT "t_session_events_f_session_id_t_sessions_f_session_id_fkey" FOREIGN KEY ("f_session_id") REFERENCES "t_sessions"("f_session_id") ON DELETE CASCADE;--> statement-breakpoint
58
+ ALTER TABLE "t_session_events" ADD CONSTRAINT "t_session_events_f_event_id_t_events_f_event_id_fkey" FOREIGN KEY ("f_event_id") REFERENCES "t_events"("f_event_id") ON DELETE CASCADE;