@jarenjs/db 0.84.3 → 0.85.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.
@@ -227,10 +227,167 @@
227
227
  },
228
228
  "generated": {
229
229
  "type": "boolean"
230
+ },
231
+ "type": {
232
+ "enum": [
233
+ "INTEGER",
234
+ "REAL",
235
+ "TEXT",
236
+ "BLOB",
237
+ "NUMERIC"
238
+ ]
239
+ },
240
+ "defaultValue": {
241
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
242
+ "anyOf": [
243
+ {
244
+ "type": [
245
+ "string",
246
+ "number",
247
+ "null"
248
+ ]
249
+ },
250
+ {
251
+ "type": "object",
252
+ "required": [
253
+ "$sql"
254
+ ],
255
+ "properties": {
256
+ "$sql": {
257
+ "enum": [
258
+ "column",
259
+ "value",
260
+ "binary",
261
+ "not",
262
+ "in",
263
+ "call",
264
+ "cast",
265
+ "collate",
266
+ "case",
267
+ "scalar",
268
+ "exists"
269
+ ]
270
+ }
271
+ }
272
+ }
273
+ ]
274
+ },
275
+ "collation": {
276
+ "enum": [
277
+ "BINARY",
278
+ "NOCASE",
279
+ "RTRIM"
280
+ ]
281
+ },
282
+ "identity": {
283
+ "enum": [
284
+ "rowid",
285
+ "autoincrement"
286
+ ]
287
+ },
288
+ "check": {
289
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
290
+ "anyOf": [
291
+ {
292
+ "type": [
293
+ "string",
294
+ "number",
295
+ "null"
296
+ ]
297
+ },
298
+ {
299
+ "type": "object",
300
+ "required": [
301
+ "$sql"
302
+ ],
303
+ "properties": {
304
+ "$sql": {
305
+ "enum": [
306
+ "column",
307
+ "value",
308
+ "binary",
309
+ "not",
310
+ "in",
311
+ "call",
312
+ "cast",
313
+ "collate",
314
+ "case",
315
+ "scalar",
316
+ "exists"
317
+ ]
318
+ }
319
+ }
320
+ }
321
+ ]
322
+ },
323
+ "generatedExpression": {
324
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
325
+ "anyOf": [
326
+ {
327
+ "type": [
328
+ "string",
329
+ "number",
330
+ "null"
331
+ ]
332
+ },
333
+ {
334
+ "type": "object",
335
+ "required": [
336
+ "$sql"
337
+ ],
338
+ "properties": {
339
+ "$sql": {
340
+ "enum": [
341
+ "column",
342
+ "value",
343
+ "binary",
344
+ "not",
345
+ "in",
346
+ "call",
347
+ "cast",
348
+ "collate",
349
+ "case",
350
+ "scalar",
351
+ "exists"
352
+ ]
353
+ }
354
+ }
355
+ }
356
+ ]
357
+ },
358
+ "stored": {
359
+ "type": "boolean"
230
360
  }
231
361
  },
232
362
  "additionalProperties": false
233
363
  }
364
+ },
365
+ "constraints": {
366
+ "type": "array",
367
+ "items": {
368
+ "type": "object"
369
+ },
370
+ "description": "Structural SQLite declarations validated by planTable."
371
+ },
372
+ "indexes": {
373
+ "type": "array",
374
+ "items": {
375
+ "type": "object"
376
+ },
377
+ "description": "Structural SQLite declarations validated by planTable."
378
+ },
379
+ "triggers": {
380
+ "type": "array",
381
+ "items": {
382
+ "type": "object"
383
+ },
384
+ "description": "Structural SQLite declarations validated by planTable."
385
+ },
386
+ "strict": {
387
+ "type": "boolean"
388
+ },
389
+ "withoutRowid": {
390
+ "type": "boolean"
234
391
  }
235
392
  },
236
393
  "additionalProperties": false
@@ -227,10 +227,167 @@
227
227
  },
228
228
  "generated": {
229
229
  "type": "boolean"
230
+ },
231
+ "type": {
232
+ "enum": [
233
+ "INTEGER",
234
+ "REAL",
235
+ "TEXT",
236
+ "BLOB",
237
+ "NUMERIC"
238
+ ]
239
+ },
240
+ "defaultValue": {
241
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
242
+ "anyOf": [
243
+ {
244
+ "type": [
245
+ "string",
246
+ "number",
247
+ "null"
248
+ ]
249
+ },
250
+ {
251
+ "type": "object",
252
+ "required": [
253
+ "$sql"
254
+ ],
255
+ "properties": {
256
+ "$sql": {
257
+ "enum": [
258
+ "column",
259
+ "value",
260
+ "binary",
261
+ "not",
262
+ "in",
263
+ "call",
264
+ "cast",
265
+ "collate",
266
+ "case",
267
+ "scalar",
268
+ "exists"
269
+ ]
270
+ }
271
+ }
272
+ }
273
+ ]
274
+ },
275
+ "collation": {
276
+ "enum": [
277
+ "BINARY",
278
+ "NOCASE",
279
+ "RTRIM"
280
+ ]
281
+ },
282
+ "identity": {
283
+ "enum": [
284
+ "rowid",
285
+ "autoincrement"
286
+ ]
287
+ },
288
+ "check": {
289
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
290
+ "anyOf": [
291
+ {
292
+ "type": [
293
+ "string",
294
+ "number",
295
+ "null"
296
+ ]
297
+ },
298
+ {
299
+ "type": "object",
300
+ "required": [
301
+ "$sql"
302
+ ],
303
+ "properties": {
304
+ "$sql": {
305
+ "enum": [
306
+ "column",
307
+ "value",
308
+ "binary",
309
+ "not",
310
+ "in",
311
+ "call",
312
+ "cast",
313
+ "collate",
314
+ "case",
315
+ "scalar",
316
+ "exists"
317
+ ]
318
+ }
319
+ }
320
+ }
321
+ ]
322
+ },
323
+ "generatedExpression": {
324
+ "description": "A literal SQLite value or closed structural $sql expression; planTable validates its operator and contextual semantics.",
325
+ "anyOf": [
326
+ {
327
+ "type": [
328
+ "string",
329
+ "number",
330
+ "null"
331
+ ]
332
+ },
333
+ {
334
+ "type": "object",
335
+ "required": [
336
+ "$sql"
337
+ ],
338
+ "properties": {
339
+ "$sql": {
340
+ "enum": [
341
+ "column",
342
+ "value",
343
+ "binary",
344
+ "not",
345
+ "in",
346
+ "call",
347
+ "cast",
348
+ "collate",
349
+ "case",
350
+ "scalar",
351
+ "exists"
352
+ ]
353
+ }
354
+ }
355
+ }
356
+ ]
357
+ },
358
+ "stored": {
359
+ "type": "boolean"
230
360
  }
231
361
  },
232
362
  "additionalProperties": false
233
363
  }
364
+ },
365
+ "constraints": {
366
+ "type": "array",
367
+ "items": {
368
+ "type": "object"
369
+ },
370
+ "description": "Structural SQLite declarations validated by planTable."
371
+ },
372
+ "indexes": {
373
+ "type": "array",
374
+ "items": {
375
+ "type": "object"
376
+ },
377
+ "description": "Structural SQLite declarations validated by planTable."
378
+ },
379
+ "triggers": {
380
+ "type": "array",
381
+ "items": {
382
+ "type": "object"
383
+ },
384
+ "description": "Structural SQLite declarations validated by planTable."
385
+ },
386
+ "strict": {
387
+ "type": "boolean"
388
+ },
389
+ "withoutRowid": {
390
+ "type": "boolean"
234
391
  }
235
392
  },
236
393
  "additionalProperties": false
package/src/capture.js CHANGED
@@ -1,4 +1,6 @@
1
1
  //@ts-check
2
+ import { CHANGES_TABLE, CHANGES_STATE_TABLE } from './engine-metadata.js';
3
+ export { CHANGES_TABLE, CHANGES_STATE_TABLE };
2
4
  /**
3
5
  * @file Change capture (D13): committed writes become an observable,
4
6
  * ordered stream of RFC 6902 patches — derived from SQLite's own
@@ -37,13 +39,13 @@ import { chain, attempt } from './driver.js';
37
39
  import { createCursor, drainPage, utf8Length, PAGE_LIMIT_DEFAULT } from './cursor.js';
38
40
 
39
41
  /** The persisted change log (LIVE-FORMAT §5). */
40
- export const CHANGES_TABLE = '_jaren_changes';
42
+
41
43
  /**
42
44
  * The log's durable state: one row holding the highest sequence ever
43
45
  * allocated for this file, so the high watermark survives a log that
44
46
  * retention or maintenance has emptied (LIVE-FORMAT §5).
45
47
  */
46
- export const CHANGES_STATE_TABLE = '_jaren_changes_state';
48
+
47
49
  export const DEFAULT_RETENTION = 1000;
48
50
 
49
51
  /** A driver failure met by the change reader, classified — never raw. */
package/src/ddl.js CHANGED
@@ -20,6 +20,7 @@ import { DbCompileError } from './errors.js';
20
20
  import { chain } from './driver.js';
21
21
  import { BBOX_COMPONENTS, BBOX_INDEX_ORDER, derivedMappingFor } from './derive.js';
22
22
  import { expressionSql, expressionStem, expressionFunctions } from './expression.js';
23
+ import { planTable } from './dialects/sqlite-schema.js';
23
24
 
24
25
  /** The fixed physical column names of the 0.1 mapping. */
25
26
  export const KEY_COLUMN = 'key';
@@ -903,9 +904,13 @@ export function verifyShape(connection, plan, collection, docPath) {
903
904
  * columnNames: Set<string> }}
904
905
  */
905
906
  export function planEntity(name, entityMapping, entities, dialect) {
906
- if (entityMapping.document === false) return { table: entityMapping.table,
907
- physical: { ...entityMapping, triggers: dialect.invariantTriggers?.(entityMapping, entities, dialect) ?? [] }, createSql: [], expected: { columns: [], indexes: [] },
908
- columnNames: new Set(entityMapping.columns.map((c) => c.physical)) };
907
+ if (entityMapping.document === false) {
908
+ const declared = entityMapping.ddl && dialect.name === 'sqlite' ? planTable(entityMapping.ddl) : null;
909
+ return { table: entityMapping.table,
910
+ physical: { ...entityMapping, triggers: dialect.invariantTriggers?.(entityMapping, entities, dialect) ?? [] },
911
+ createSql: declared?.createSql ?? [], expected: declared?.expected ?? { columns: [], indexes: [] },
912
+ columnNames: new Set(entityMapping.columns.map((c) => c.physical)) };
913
+ }
909
914
  const storageType = (storage) => dialect.typeFor(storage, 'generated');
910
915
  const keyType = (entityName) => {
911
916
  const target = entities.entities[entityName];