@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.
- package/README.md +11 -13
- package/dist/artifact.d.mts +6 -16
- package/dist/artifact.mjs +3 -3
- package/dist/{import-B-tf5vQn.mjs → import-CKrzjXVB.mjs} +73 -83
- package/dist/import.d.mts +2 -3
- package/dist/import.mjs +2 -2
- package/dist/index-CgGDHQSK.d.mts +225 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +694 -169
- package/dist/log-DTJsxMud.mjs +314 -0
- package/dist/{schema-CFXZURX7.d.mts → schema-COK7-wRV.d.mts} +3 -15
- package/dist/sqlite-DCy4VTD8.mjs +698 -0
- package/dist/storage.d.mts +2 -7
- package/dist/storage.mjs +2 -3
- package/dist/testing.d.mts +30 -1
- package/dist/testing.mjs +676 -1991
- package/drizzle/postgres/20260908072805_v2_initial/migration.sql +58 -0
- package/drizzle/postgres/20260908072805_v2_initial/snapshot.json +686 -0
- package/drizzle/postgres/20260908072806_v3_drop_original_seq/migration.sql +1 -0
- package/drizzle/postgres/20260908072806_v3_drop_original_seq/snapshot.json +673 -0
- package/drizzle/sqlite/20260908072751_v2_initial/migration.sql +53 -0
- package/drizzle/sqlite/20260908072751_v2_initial/snapshot.json +492 -0
- package/drizzle/sqlite/20260908072752_v3_drop_original_seq/migration.sql +6 -0
- package/drizzle/sqlite/20260908072752_v3_drop_original_seq/snapshot.json +513 -0
- package/package.json +17 -12
- package/src/adapters/index.ts +10 -2
- package/src/adapters/to-postgres.ts +19 -15
- package/src/adapters/to-sqlite.ts +20 -14
- package/src/{entities → adapters}/types.ts +7 -8
- package/src/backend.ts +0 -7
- package/src/branch.ts +29 -110
- package/src/drizzle/postgres-v2.ts +11 -0
- package/src/drizzle/postgres-v3.ts +11 -0
- package/src/drizzle/sqlite-v2.ts +10 -0
- package/src/drizzle/sqlite-v3.ts +11 -0
- package/src/entities/index.ts +2 -30
- package/src/entities/v2/index.ts +20 -0
- package/src/entities/v2/session-events.ts +11 -0
- package/src/entities/v3/events.ts +27 -0
- package/src/entities/v3/index.ts +27 -0
- package/src/entities/v3/persistence-state.ts +10 -0
- package/src/entities/v3/schema-meta.ts +9 -0
- package/src/entities/v3/session-events.ts +26 -0
- package/src/entities/v3/sessions.ts +20 -0
- package/src/import.ts +65 -57
- package/src/index.ts +868 -223
- package/src/invariant.ts +0 -2
- package/src/legacy.ts +67 -0
- package/src/log.ts +41 -81
- package/src/postgres.ts +75 -93
- package/src/schema.ts +3 -14
- package/src/sqlite.ts +59 -46
- package/src/testing/contract.ts +460 -375
- package/src/testing/coordinator-contract.ts +108 -1374
- package/src/testing.ts +1 -6
- package/dist/index-uUvn6gYp.d.mts +0 -111
- package/dist/schema-BfPVmr1X.mjs +0 -875
- package/dist/sqlite-BUWnS0so.mjs +0 -356
- package/src/adapters/ddl.ts +0 -77
- package/src/entities/events.ts +0 -27
- package/src/entities/persistence-state.ts +0 -10
- package/src/entities/schema-meta.ts +0 -9
- package/src/entities/session-events.ts +0 -29
- package/src/entities/sessions.ts +0 -20
- package/src/migrate.ts +0 -137
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "7",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "73c73ac0-f96e-4579-8784-04343de1a0d7",
|
|
5
|
+
"prevIds": ["fb2bcab4-68a8-41b5-8493-804915c1ab54"],
|
|
6
|
+
"ddl": [
|
|
7
|
+
{
|
|
8
|
+
"name": "t_events",
|
|
9
|
+
"entityType": "tables"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "t_persistence_state",
|
|
13
|
+
"entityType": "tables"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "t_schema_meta",
|
|
17
|
+
"entityType": "tables"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "t_session_events",
|
|
21
|
+
"entityType": "tables"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "t_sessions",
|
|
25
|
+
"entityType": "tables"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "integer",
|
|
29
|
+
"notNull": false,
|
|
30
|
+
"autoincrement": true,
|
|
31
|
+
"default": null,
|
|
32
|
+
"generated": null,
|
|
33
|
+
"name": "f_id",
|
|
34
|
+
"entityType": "columns",
|
|
35
|
+
"table": "t_events"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "text",
|
|
39
|
+
"notNull": true,
|
|
40
|
+
"autoincrement": false,
|
|
41
|
+
"default": null,
|
|
42
|
+
"generated": null,
|
|
43
|
+
"name": "f_event_id",
|
|
44
|
+
"entityType": "columns",
|
|
45
|
+
"table": "t_events"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "text",
|
|
49
|
+
"notNull": true,
|
|
50
|
+
"autoincrement": false,
|
|
51
|
+
"default": "''",
|
|
52
|
+
"generated": null,
|
|
53
|
+
"name": "f_parent_id",
|
|
54
|
+
"entityType": "columns",
|
|
55
|
+
"table": "t_events"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "text",
|
|
59
|
+
"notNull": true,
|
|
60
|
+
"autoincrement": false,
|
|
61
|
+
"default": "''",
|
|
62
|
+
"generated": null,
|
|
63
|
+
"name": "f_type",
|
|
64
|
+
"entityType": "columns",
|
|
65
|
+
"table": "t_events"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "text",
|
|
69
|
+
"notNull": true,
|
|
70
|
+
"autoincrement": false,
|
|
71
|
+
"default": "''",
|
|
72
|
+
"generated": null,
|
|
73
|
+
"name": "f_kind",
|
|
74
|
+
"entityType": "columns",
|
|
75
|
+
"table": "t_events"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "text",
|
|
79
|
+
"notNull": true,
|
|
80
|
+
"autoincrement": false,
|
|
81
|
+
"default": "''",
|
|
82
|
+
"generated": null,
|
|
83
|
+
"name": "f_role",
|
|
84
|
+
"entityType": "columns",
|
|
85
|
+
"table": "t_events"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "text",
|
|
89
|
+
"notNull": true,
|
|
90
|
+
"autoincrement": false,
|
|
91
|
+
"default": "''",
|
|
92
|
+
"generated": null,
|
|
93
|
+
"name": "f_name",
|
|
94
|
+
"entityType": "columns",
|
|
95
|
+
"table": "t_events"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "text",
|
|
99
|
+
"notNull": true,
|
|
100
|
+
"autoincrement": false,
|
|
101
|
+
"default": "''",
|
|
102
|
+
"generated": null,
|
|
103
|
+
"name": "f_action_id",
|
|
104
|
+
"entityType": "columns",
|
|
105
|
+
"table": "t_events"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": "text",
|
|
109
|
+
"notNull": true,
|
|
110
|
+
"autoincrement": false,
|
|
111
|
+
"default": "''",
|
|
112
|
+
"generated": null,
|
|
113
|
+
"name": "f_encoding",
|
|
114
|
+
"entityType": "columns",
|
|
115
|
+
"table": "t_events"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "text",
|
|
119
|
+
"notNull": true,
|
|
120
|
+
"autoincrement": false,
|
|
121
|
+
"default": null,
|
|
122
|
+
"generated": null,
|
|
123
|
+
"name": "f_data",
|
|
124
|
+
"entityType": "columns",
|
|
125
|
+
"table": "t_events"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"type": "integer",
|
|
129
|
+
"notNull": true,
|
|
130
|
+
"autoincrement": false,
|
|
131
|
+
"default": "0",
|
|
132
|
+
"generated": null,
|
|
133
|
+
"name": "f_created_at",
|
|
134
|
+
"entityType": "columns",
|
|
135
|
+
"table": "t_events"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "integer",
|
|
139
|
+
"notNull": false,
|
|
140
|
+
"autoincrement": false,
|
|
141
|
+
"default": null,
|
|
142
|
+
"generated": null,
|
|
143
|
+
"name": "f_singleton",
|
|
144
|
+
"entityType": "columns",
|
|
145
|
+
"table": "t_persistence_state"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "text",
|
|
149
|
+
"notNull": true,
|
|
150
|
+
"autoincrement": false,
|
|
151
|
+
"default": null,
|
|
152
|
+
"generated": null,
|
|
153
|
+
"name": "f_store_id",
|
|
154
|
+
"entityType": "columns",
|
|
155
|
+
"table": "t_persistence_state"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "text",
|
|
159
|
+
"notNull": false,
|
|
160
|
+
"autoincrement": false,
|
|
161
|
+
"default": null,
|
|
162
|
+
"generated": null,
|
|
163
|
+
"name": "f_key",
|
|
164
|
+
"entityType": "columns",
|
|
165
|
+
"table": "t_schema_meta"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "text",
|
|
169
|
+
"notNull": true,
|
|
170
|
+
"autoincrement": false,
|
|
171
|
+
"default": null,
|
|
172
|
+
"generated": null,
|
|
173
|
+
"name": "f_value",
|
|
174
|
+
"entityType": "columns",
|
|
175
|
+
"table": "t_schema_meta"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"type": "integer",
|
|
179
|
+
"notNull": false,
|
|
180
|
+
"autoincrement": true,
|
|
181
|
+
"default": null,
|
|
182
|
+
"generated": null,
|
|
183
|
+
"name": "f_id",
|
|
184
|
+
"entityType": "columns",
|
|
185
|
+
"table": "t_session_events"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "text",
|
|
189
|
+
"notNull": true,
|
|
190
|
+
"autoincrement": false,
|
|
191
|
+
"default": null,
|
|
192
|
+
"generated": null,
|
|
193
|
+
"name": "f_session_id",
|
|
194
|
+
"entityType": "columns",
|
|
195
|
+
"table": "t_session_events"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "text",
|
|
199
|
+
"notNull": true,
|
|
200
|
+
"autoincrement": false,
|
|
201
|
+
"default": null,
|
|
202
|
+
"generated": null,
|
|
203
|
+
"name": "f_event_id",
|
|
204
|
+
"entityType": "columns",
|
|
205
|
+
"table": "t_session_events"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"type": "integer",
|
|
209
|
+
"notNull": true,
|
|
210
|
+
"autoincrement": false,
|
|
211
|
+
"default": null,
|
|
212
|
+
"generated": null,
|
|
213
|
+
"name": "f_sequence",
|
|
214
|
+
"entityType": "columns",
|
|
215
|
+
"table": "t_session_events"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"type": "text",
|
|
219
|
+
"notNull": false,
|
|
220
|
+
"autoincrement": false,
|
|
221
|
+
"default": null,
|
|
222
|
+
"generated": null,
|
|
223
|
+
"name": "f_surface_op",
|
|
224
|
+
"entityType": "columns",
|
|
225
|
+
"table": "t_session_events"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"type": "integer",
|
|
229
|
+
"notNull": false,
|
|
230
|
+
"autoincrement": true,
|
|
231
|
+
"default": null,
|
|
232
|
+
"generated": null,
|
|
233
|
+
"name": "f_id",
|
|
234
|
+
"entityType": "columns",
|
|
235
|
+
"table": "t_sessions"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "text",
|
|
239
|
+
"notNull": true,
|
|
240
|
+
"autoincrement": false,
|
|
241
|
+
"default": null,
|
|
242
|
+
"generated": null,
|
|
243
|
+
"name": "f_session_id",
|
|
244
|
+
"entityType": "columns",
|
|
245
|
+
"table": "t_sessions"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"type": "text",
|
|
249
|
+
"notNull": true,
|
|
250
|
+
"autoincrement": false,
|
|
251
|
+
"default": "''",
|
|
252
|
+
"generated": null,
|
|
253
|
+
"name": "f_head_event_id",
|
|
254
|
+
"entityType": "columns",
|
|
255
|
+
"table": "t_sessions"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"type": "integer",
|
|
259
|
+
"notNull": true,
|
|
260
|
+
"autoincrement": false,
|
|
261
|
+
"default": "-1",
|
|
262
|
+
"generated": null,
|
|
263
|
+
"name": "f_head_sequence",
|
|
264
|
+
"entityType": "columns",
|
|
265
|
+
"table": "t_sessions"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"type": "integer",
|
|
269
|
+
"notNull": true,
|
|
270
|
+
"autoincrement": false,
|
|
271
|
+
"default": null,
|
|
272
|
+
"generated": null,
|
|
273
|
+
"name": "f_version",
|
|
274
|
+
"entityType": "columns",
|
|
275
|
+
"table": "t_sessions"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"type": "integer",
|
|
279
|
+
"notNull": true,
|
|
280
|
+
"autoincrement": false,
|
|
281
|
+
"default": null,
|
|
282
|
+
"generated": null,
|
|
283
|
+
"name": "f_created_at",
|
|
284
|
+
"entityType": "columns",
|
|
285
|
+
"table": "t_sessions"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"type": "text",
|
|
289
|
+
"notNull": false,
|
|
290
|
+
"autoincrement": false,
|
|
291
|
+
"default": null,
|
|
292
|
+
"generated": null,
|
|
293
|
+
"name": "f_cwd",
|
|
294
|
+
"entityType": "columns",
|
|
295
|
+
"table": "t_sessions"
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"type": "text",
|
|
299
|
+
"notNull": false,
|
|
300
|
+
"autoincrement": false,
|
|
301
|
+
"default": null,
|
|
302
|
+
"generated": null,
|
|
303
|
+
"name": "f_parent_session",
|
|
304
|
+
"entityType": "columns",
|
|
305
|
+
"table": "t_sessions"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"type": "integer",
|
|
309
|
+
"notNull": false,
|
|
310
|
+
"autoincrement": false,
|
|
311
|
+
"default": null,
|
|
312
|
+
"generated": null,
|
|
313
|
+
"name": "f_seed_length",
|
|
314
|
+
"entityType": "columns",
|
|
315
|
+
"table": "t_sessions"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"type": "text",
|
|
319
|
+
"notNull": false,
|
|
320
|
+
"autoincrement": false,
|
|
321
|
+
"default": null,
|
|
322
|
+
"generated": null,
|
|
323
|
+
"name": "f_origin",
|
|
324
|
+
"entityType": "columns",
|
|
325
|
+
"table": "t_sessions"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"type": "integer",
|
|
329
|
+
"notNull": false,
|
|
330
|
+
"autoincrement": false,
|
|
331
|
+
"default": null,
|
|
332
|
+
"generated": null,
|
|
333
|
+
"name": "f_delegation_depth",
|
|
334
|
+
"entityType": "columns",
|
|
335
|
+
"table": "t_sessions"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"type": "text",
|
|
339
|
+
"notNull": true,
|
|
340
|
+
"autoincrement": false,
|
|
341
|
+
"default": null,
|
|
342
|
+
"generated": null,
|
|
343
|
+
"name": "f_incarnation",
|
|
344
|
+
"entityType": "columns",
|
|
345
|
+
"table": "t_sessions"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
"type": "integer",
|
|
349
|
+
"notNull": true,
|
|
350
|
+
"autoincrement": false,
|
|
351
|
+
"default": null,
|
|
352
|
+
"generated": null,
|
|
353
|
+
"name": "f_revision",
|
|
354
|
+
"entityType": "columns",
|
|
355
|
+
"table": "t_sessions"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"columns": ["f_session_id"],
|
|
359
|
+
"tableTo": "t_sessions",
|
|
360
|
+
"columnsTo": ["f_session_id"],
|
|
361
|
+
"onUpdate": "NO ACTION",
|
|
362
|
+
"onDelete": "CASCADE",
|
|
363
|
+
"nameExplicit": false,
|
|
364
|
+
"name": "fk_t_session_events_f_session_id_t_sessions_f_session_id_fk",
|
|
365
|
+
"entityType": "fks",
|
|
366
|
+
"table": "t_session_events"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"columns": ["f_event_id"],
|
|
370
|
+
"tableTo": "t_events",
|
|
371
|
+
"columnsTo": ["f_event_id"],
|
|
372
|
+
"onUpdate": "NO ACTION",
|
|
373
|
+
"onDelete": "CASCADE",
|
|
374
|
+
"nameExplicit": false,
|
|
375
|
+
"name": "fk_t_session_events_f_event_id_t_events_f_event_id_fk",
|
|
376
|
+
"entityType": "fks",
|
|
377
|
+
"table": "t_session_events"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
"columns": ["f_id"],
|
|
381
|
+
"nameExplicit": false,
|
|
382
|
+
"name": "t_events_pk",
|
|
383
|
+
"table": "t_events",
|
|
384
|
+
"entityType": "pks"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"columns": ["f_singleton"],
|
|
388
|
+
"nameExplicit": false,
|
|
389
|
+
"name": "t_persistence_state_pk",
|
|
390
|
+
"table": "t_persistence_state",
|
|
391
|
+
"entityType": "pks"
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"columns": ["f_key"],
|
|
395
|
+
"nameExplicit": false,
|
|
396
|
+
"name": "t_schema_meta_pk",
|
|
397
|
+
"table": "t_schema_meta",
|
|
398
|
+
"entityType": "pks"
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"columns": ["f_id"],
|
|
402
|
+
"nameExplicit": false,
|
|
403
|
+
"name": "t_session_events_pk",
|
|
404
|
+
"table": "t_session_events",
|
|
405
|
+
"entityType": "pks"
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"columns": ["f_id"],
|
|
409
|
+
"nameExplicit": false,
|
|
410
|
+
"name": "t_sessions_pk",
|
|
411
|
+
"table": "t_sessions",
|
|
412
|
+
"entityType": "pks"
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"columns": [
|
|
416
|
+
{
|
|
417
|
+
"value": "f_kind",
|
|
418
|
+
"isExpression": false
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
"isUnique": false,
|
|
422
|
+
"where": null,
|
|
423
|
+
"origin": "manual",
|
|
424
|
+
"name": "idx_events_kind",
|
|
425
|
+
"entityType": "indexes",
|
|
426
|
+
"table": "t_events"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"columns": [
|
|
430
|
+
{
|
|
431
|
+
"value": "f_role",
|
|
432
|
+
"isExpression": false
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
"isUnique": false,
|
|
436
|
+
"where": null,
|
|
437
|
+
"origin": "manual",
|
|
438
|
+
"name": "idx_events_role",
|
|
439
|
+
"entityType": "indexes",
|
|
440
|
+
"table": "t_events"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"columns": [
|
|
444
|
+
{
|
|
445
|
+
"value": "f_name",
|
|
446
|
+
"isExpression": false
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
"isUnique": false,
|
|
450
|
+
"where": null,
|
|
451
|
+
"origin": "manual",
|
|
452
|
+
"name": "idx_events_name",
|
|
453
|
+
"entityType": "indexes",
|
|
454
|
+
"table": "t_events"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"columns": [
|
|
458
|
+
{
|
|
459
|
+
"value": "f_action_id",
|
|
460
|
+
"isExpression": false
|
|
461
|
+
}
|
|
462
|
+
],
|
|
463
|
+
"isUnique": false,
|
|
464
|
+
"where": null,
|
|
465
|
+
"origin": "manual",
|
|
466
|
+
"name": "idx_events_action_id",
|
|
467
|
+
"entityType": "indexes",
|
|
468
|
+
"table": "t_events"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"columns": [
|
|
472
|
+
{
|
|
473
|
+
"value": "f_event_id",
|
|
474
|
+
"isExpression": false
|
|
475
|
+
}
|
|
476
|
+
],
|
|
477
|
+
"isUnique": false,
|
|
478
|
+
"where": null,
|
|
479
|
+
"origin": "manual",
|
|
480
|
+
"name": "idx_session_events_event_id",
|
|
481
|
+
"entityType": "indexes",
|
|
482
|
+
"table": "t_session_events"
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"columns": ["f_session_id", "f_sequence"],
|
|
486
|
+
"nameExplicit": true,
|
|
487
|
+
"name": "uq_session_events_session_sequence",
|
|
488
|
+
"entityType": "uniques",
|
|
489
|
+
"table": "t_session_events"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"columns": ["f_event_id"],
|
|
493
|
+
"nameExplicit": false,
|
|
494
|
+
"name": "t_events_f_event_id_unique",
|
|
495
|
+
"entityType": "uniques",
|
|
496
|
+
"table": "t_events"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"columns": ["f_session_id"],
|
|
500
|
+
"nameExplicit": false,
|
|
501
|
+
"name": "t_sessions_f_session_id_unique",
|
|
502
|
+
"entityType": "uniques",
|
|
503
|
+
"table": "t_sessions"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"value": "f_singleton = 1",
|
|
507
|
+
"name": "ck_persistence_state_singleton",
|
|
508
|
+
"entityType": "checks",
|
|
509
|
+
"table": "t_persistence_state"
|
|
510
|
+
}
|
|
511
|
+
],
|
|
512
|
+
"renames": []
|
|
513
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/session-rdb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16-alpha.0",
|
|
4
4
|
"description": "RDB durable session backend for DeepSeek Harness: implements both session-persistence and session-branch (rewind / retry / fork) providers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"branch",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
21
|
"src",
|
|
22
|
+
"drizzle",
|
|
22
23
|
"cordis.patch.yml",
|
|
23
24
|
"!**/__tests__"
|
|
24
25
|
],
|
|
@@ -34,24 +35,27 @@
|
|
|
34
35
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@morlay/session-branch": "^0.0.
|
|
38
|
+
"@morlay/session-branch": "^0.0.4-alpha.0",
|
|
38
39
|
"drizzle-orm": "^1.0.0-rc.5-ab785fc",
|
|
39
40
|
"fflate": "^0.8.2",
|
|
40
41
|
"pg": "^8.23.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.
|
|
44
|
-
"@deepseek-ai/dsh-token-meter": "^0.1.
|
|
45
|
-
"@types/pg": "^8.23.1"
|
|
44
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.3-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.3-alpha.2",
|
|
46
|
+
"@types/pg": "^8.23.1",
|
|
47
|
+
"drizzle-kit": "1.0.0-rc.5-ab785fc"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
50
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
49
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-llm": "^0.1.
|
|
51
|
-
"@deepseek-ai/dsh-scope": "^0.1.
|
|
52
|
-
"@deepseek-ai/dsh-session": "^0.1.
|
|
53
|
-
"@deepseek-ai/dsh-session-
|
|
54
|
-
"@deepseek-ai/dsh-
|
|
51
|
+
"@deepseek-ai/dsh-invariants": "^0.1.3-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-llm": "^0.1.3-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-scope": "^0.1.3-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-session": "^0.1.3-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-session-format": "^0.1.3-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-session-format-catalog": "^0.1.3-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-session-persistence": "^0.1.3-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-settings": "^0.1.3-alpha.2",
|
|
55
59
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
56
60
|
},
|
|
57
61
|
"dsh": {
|
|
@@ -73,6 +77,7 @@
|
|
|
73
77
|
"vitest": "4.1.11"
|
|
74
78
|
},
|
|
75
79
|
"scripts": {
|
|
76
|
-
"build": "pnpm exec tsdown"
|
|
80
|
+
"build": "pnpm exec tsdown",
|
|
81
|
+
"db:generate": "drizzle-kit generate --config drizzle.config.ts && drizzle-kit generate --config drizzle.pg.config.ts"
|
|
77
82
|
}
|
|
78
83
|
}
|
package/src/adapters/index.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export { toSqliteSchema } from "./to-sqlite.ts";
|
|
2
2
|
export { toPostgresSchema } from "./to-postgres.ts";
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export type {
|
|
4
|
+
ColumnDef,
|
|
5
|
+
TableDef,
|
|
6
|
+
CheckDef,
|
|
7
|
+
UniqueDef,
|
|
8
|
+
IndexDef,
|
|
9
|
+
ColumnTypeName,
|
|
10
|
+
DeleteAction,
|
|
11
|
+
} from "./types.ts";
|
|
12
|
+
export { toProperty } from "./types.ts";
|
|
@@ -13,27 +13,29 @@ import {
|
|
|
13
13
|
type AnyPgColumnBuilder,
|
|
14
14
|
type AnyPgTable,
|
|
15
15
|
} from "drizzle-orm/pg-core";
|
|
16
|
-
import { toProperty, type ColumnDef, type TableDef } from "
|
|
16
|
+
import { toProperty, type ColumnDef, type TableDef } from "./types.ts";
|
|
17
17
|
|
|
18
18
|
type TableRegistry = Record<string, AnyPgTable>;
|
|
19
19
|
|
|
20
|
-
function buildColumn(c: ColumnDef, tables: TableRegistry): AnyPgColumnBuilder {
|
|
20
|
+
function buildColumn(name: string, c: ColumnDef, tables: TableRegistry): AnyPgColumnBuilder {
|
|
21
21
|
// 具体 builder 类型与 AnyPgColumnBuilder 在方法层面不兼容,构建阶段用宽松类型。
|
|
22
22
|
let col: any;
|
|
23
23
|
switch (c.type) {
|
|
24
|
-
case "text":
|
|
25
|
-
|
|
24
|
+
case "text": {
|
|
25
|
+
const built = text(name);
|
|
26
|
+
col = c.primaryKey ? built.primaryKey() : built;
|
|
26
27
|
break;
|
|
28
|
+
}
|
|
27
29
|
case "serial":
|
|
28
|
-
col = serial(
|
|
30
|
+
col = serial(name).primaryKey();
|
|
29
31
|
break;
|
|
30
32
|
case "integer": {
|
|
31
|
-
const built = integer(
|
|
33
|
+
const built = integer(name);
|
|
32
34
|
col = c.primaryKey ? built.primaryKey() : built;
|
|
33
35
|
break;
|
|
34
36
|
}
|
|
35
37
|
case "bigint": {
|
|
36
|
-
const built = bigint(
|
|
38
|
+
const built = bigint(name, { mode: "number" });
|
|
37
39
|
col = c.primaryKey ? built.primaryKey() : built;
|
|
38
40
|
break;
|
|
39
41
|
}
|
|
@@ -61,20 +63,22 @@ export function toPostgresSchema(
|
|
|
61
63
|
const table = schemaName === "public" ? pgTable : pgSchema(schemaName).table;
|
|
62
64
|
for (const def of defs) {
|
|
63
65
|
const columns: Record<string, AnyPgColumnBuilder> = {};
|
|
64
|
-
for (const c of def.columns)
|
|
66
|
+
for (const [name, c] of Object.entries(def.columns)) {
|
|
67
|
+
columns[toProperty(name)] = buildColumn(name, c, tables);
|
|
68
|
+
}
|
|
65
69
|
const extra = (self: Record<string, unknown>) => [
|
|
66
|
-
...(def.checks ??
|
|
67
|
-
...(def.uniques ??
|
|
68
|
-
unique(
|
|
69
|
-
...(u.columns.map((
|
|
70
|
+
...Object.entries(def.checks ?? {}).map(([name, c]) => pgCheck(name, sql.raw(c.expression))),
|
|
71
|
+
...Object.entries(def.uniques ?? {}).map(([name, u]) =>
|
|
72
|
+
unique(name).on(
|
|
73
|
+
...(u.columns.map((n) => self[toProperty(n)] as AnyPgColumn) as [
|
|
70
74
|
AnyPgColumn,
|
|
71
75
|
...AnyPgColumn[],
|
|
72
76
|
]),
|
|
73
77
|
),
|
|
74
78
|
),
|
|
75
|
-
...(def.indexes ??
|
|
76
|
-
index(
|
|
77
|
-
...(i.columns.map((
|
|
79
|
+
...Object.entries(def.indexes ?? {}).map(([name, i]) =>
|
|
80
|
+
index(name).on(
|
|
81
|
+
...(i.columns.map((n) => self[toProperty(n)] as AnyPgColumn) as [
|
|
78
82
|
AnyPgColumn,
|
|
79
83
|
...AnyPgColumn[],
|
|
80
84
|
]),
|