@quereus/store 4.4.1 → 4.6.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 (104) hide show
  1. package/README.md +538 -491
  2. package/dist/src/common/encoding.d.ts +4 -3
  3. package/dist/src/common/encoding.d.ts.map +1 -1
  4. package/dist/src/common/encoding.js +17 -13
  5. package/dist/src/common/encoding.js.map +1 -1
  6. package/dist/src/common/events.d.ts +5 -1
  7. package/dist/src/common/events.d.ts.map +1 -1
  8. package/dist/src/common/events.js.map +1 -1
  9. package/dist/src/common/implicit-unique-index.d.ts +80 -0
  10. package/dist/src/common/implicit-unique-index.d.ts.map +1 -0
  11. package/dist/src/common/implicit-unique-index.js +148 -0
  12. package/dist/src/common/implicit-unique-index.js.map +1 -0
  13. package/dist/src/common/index.d.ts +7 -3
  14. package/dist/src/common/index.d.ts.map +1 -1
  15. package/dist/src/common/index.js +5 -2
  16. package/dist/src/common/index.js.map +1 -1
  17. package/dist/src/common/json-key.d.ts +2 -2
  18. package/dist/src/common/json-key.js +2 -2
  19. package/dist/src/common/key-builder.d.ts +40 -20
  20. package/dist/src/common/key-builder.d.ts.map +1 -1
  21. package/dist/src/common/key-builder.js +31 -23
  22. package/dist/src/common/key-builder.js.map +1 -1
  23. package/dist/src/common/kv-store.d.ts +10 -0
  24. package/dist/src/common/kv-store.d.ts.map +1 -1
  25. package/dist/src/common/pk-key-resolution.d.ts +275 -0
  26. package/dist/src/common/pk-key-resolution.d.ts.map +1 -0
  27. package/dist/src/common/pk-key-resolution.js +389 -0
  28. package/dist/src/common/pk-key-resolution.js.map +1 -0
  29. package/dist/src/common/store-module-access-plan.d.ts +32 -0
  30. package/dist/src/common/store-module-access-plan.d.ts.map +1 -0
  31. package/dist/src/common/store-module-access-plan.js +424 -0
  32. package/dist/src/common/store-module-access-plan.js.map +1 -0
  33. package/dist/src/common/store-module-alter-column.d.ts +23 -0
  34. package/dist/src/common/store-module-alter-column.d.ts.map +1 -0
  35. package/dist/src/common/store-module-alter-column.js +393 -0
  36. package/dist/src/common/store-module-alter-column.js.map +1 -0
  37. package/dist/src/common/store-module-alter.d.ts +55 -0
  38. package/dist/src/common/store-module-alter.d.ts.map +1 -0
  39. package/dist/src/common/store-module-alter.js +519 -0
  40. package/dist/src/common/store-module-alter.js.map +1 -0
  41. package/dist/src/common/store-module-base.d.ts +268 -0
  42. package/dist/src/common/store-module-base.d.ts.map +1 -0
  43. package/dist/src/common/store-module-base.js +362 -0
  44. package/dist/src/common/store-module-base.js.map +1 -0
  45. package/dist/src/common/store-module-catalog.d.ts +269 -0
  46. package/dist/src/common/store-module-catalog.d.ts.map +1 -0
  47. package/dist/src/common/store-module-catalog.js +462 -0
  48. package/dist/src/common/store-module-catalog.js.map +1 -0
  49. package/dist/src/common/store-module-index-build.d.ts +88 -0
  50. package/dist/src/common/store-module-index-build.d.ts.map +1 -0
  51. package/dist/src/common/store-module-index-build.js +280 -0
  52. package/dist/src/common/store-module-index-build.js.map +1 -0
  53. package/dist/src/common/store-module-index.d.ts +116 -0
  54. package/dist/src/common/store-module-index.d.ts.map +1 -0
  55. package/dist/src/common/store-module-index.js +373 -0
  56. package/dist/src/common/store-module-index.js.map +1 -0
  57. package/dist/src/common/store-module-rename.d.ts +49 -0
  58. package/dist/src/common/store-module-rename.d.ts.map +1 -0
  59. package/dist/src/common/store-module-rename.js +244 -0
  60. package/dist/src/common/store-module-rename.js.map +1 -0
  61. package/dist/src/common/store-module-schema-rewrite.d.ts +57 -0
  62. package/dist/src/common/store-module-schema-rewrite.d.ts.map +1 -0
  63. package/dist/src/common/store-module-schema-rewrite.js +140 -0
  64. package/dist/src/common/store-module-schema-rewrite.js.map +1 -0
  65. package/dist/src/common/store-module-schema-sync.d.ts +232 -0
  66. package/dist/src/common/store-module-schema-sync.d.ts.map +1 -0
  67. package/dist/src/common/store-module-schema-sync.js +529 -0
  68. package/dist/src/common/store-module-schema-sync.js.map +1 -0
  69. package/dist/src/common/store-module.d.ts +43 -909
  70. package/dist/src/common/store-module.d.ts.map +1 -1
  71. package/dist/src/common/store-module.js +184 -3194
  72. package/dist/src/common/store-module.js.map +1 -1
  73. package/dist/src/common/store-table-base.d.ts +523 -0
  74. package/dist/src/common/store-table-base.d.ts.map +1 -0
  75. package/dist/src/common/store-table-base.js +878 -0
  76. package/dist/src/common/store-table-base.js.map +1 -0
  77. package/dist/src/common/store-table-constraints.d.ts +237 -0
  78. package/dist/src/common/store-table-constraints.d.ts.map +1 -0
  79. package/dist/src/common/store-table-constraints.js +624 -0
  80. package/dist/src/common/store-table-constraints.js.map +1 -0
  81. package/dist/src/common/store-table-scan.d.ts +415 -0
  82. package/dist/src/common/store-table-scan.d.ts.map +1 -0
  83. package/dist/src/common/store-table-scan.js +821 -0
  84. package/dist/src/common/store-table-scan.js.map +1 -0
  85. package/dist/src/common/store-table.d.ts +71 -1044
  86. package/dist/src/common/store-table.d.ts.map +1 -1
  87. package/dist/src/common/store-table.js +130 -2131
  88. package/dist/src/common/store-table.js.map +1 -1
  89. package/dist/src/testing/index.d.ts +12 -0
  90. package/dist/src/testing/index.d.ts.map +1 -0
  91. package/dist/src/testing/index.js +12 -0
  92. package/dist/src/testing/index.js.map +1 -0
  93. package/dist/src/testing/kv-assert.d.ts +19 -0
  94. package/dist/src/testing/kv-assert.d.ts.map +1 -0
  95. package/dist/src/testing/kv-assert.js +25 -0
  96. package/dist/src/testing/kv-assert.js.map +1 -0
  97. package/dist/src/testing/kv-conformance.d.ts.map +1 -1
  98. package/dist/src/testing/kv-conformance.js +1 -15
  99. package/dist/src/testing/kv-conformance.js.map +1 -1
  100. package/dist/src/testing/kv-provider-conformance.d.ts +54 -0
  101. package/dist/src/testing/kv-provider-conformance.d.ts.map +1 -0
  102. package/dist/src/testing/kv-provider-conformance.js +183 -0
  103. package/dist/src/testing/kv-provider-conformance.js.map +1 -0
  104. package/package.json +9 -9
@@ -81,25 +81,38 @@ export declare function buildStatsKey(schemaName: string, tableName: string): Ui
81
81
  * semantic-ordering member ('PT1H' / 'PT60M') land on one key.
82
82
  */
83
83
  export declare function buildDataKey(pkValues: SqlValue[], options?: EncodeOptions, directions?: ReadonlyArray<boolean>, collations?: ReadonlyArray<string | undefined>, transforms?: ReadonlyArray<KeyValueTransform | undefined>): Uint8Array;
84
+ /**
85
+ * One half of a secondary-index key — the index-column prefix or the PK suffix.
86
+ * Each half carries its own per-column DESC `directions`, key `collations`
87
+ * (overriding `options.collation`; see {@link encodeCompositeKey}), and
88
+ * {@link KeyValueTransform}s, positionally aligned with `values`.
89
+ */
90
+ export interface IndexKeyHalf {
91
+ values: SqlValue[];
92
+ directions?: ReadonlyArray<boolean>;
93
+ collations?: ReadonlyArray<string | undefined>;
94
+ transforms?: ReadonlyArray<KeyValueTransform | undefined>;
95
+ }
84
96
  /**
85
97
  * Build a secondary index key.
86
98
  * Format: {encoded_index_cols}{encoded_pk}
87
99
  *
88
100
  * The index columns come first for range scans, followed by PK for uniqueness.
89
- * `indexDirections` and `pkDirections` independently control DESC bit-inversion
90
- * for each half so ordered index scans honor per-column direction.
101
+ * The two halves are symmetric {@link IndexKeyHalf}s:
91
102
  *
92
- * `pkCollations[i]`, when defined, encodes the PK-suffix column i under its own
93
- * key collation (overriding `options.collation`). The PK suffix MUST be encoded
94
- * with the same per-column collations as the data key (see `buildDataKey`), so
95
- * index maintenance (delete-then-insert on UPDATE/DELETE) addresses the same
96
- * bytes the data store keys by. Index columns keep `options.collation`.
97
- *
98
- * `indexTransforms` / `pkTransforms` canonicalize each half's values before
99
- * encoding (see {@link KeyValueTransform}); the PK-suffix transforms MUST match
100
- * the data key's for the same reason as the collations above.
103
+ * - `index.collations` encodes each index column under its own key collation
104
+ * (`resolveIndexKeyCollations` — the index column's COLLATE, else the table
105
+ * column's declared collation, else BINARY), so the stored bytes agree with the
106
+ * collation everything that COMPARES those values uses (`matchesFilters`, the
107
+ * planner's cover analysis, UNIQUE enforcement).
108
+ * - `pk.collations` MUST be the same per-column collations as the data key (see
109
+ * `buildDataKey` / `resolvePkKeyCollations`), so index maintenance
110
+ * (delete-then-insert on UPDATE/DELETE) addresses the same bytes the data store
111
+ * keys by.
112
+ * - Each half's `transforms` canonicalize its values before encoding; the PK
113
+ * suffix's MUST match the data key's for the same reason as its collations.
101
114
  */
102
- export declare function buildIndexKey(indexValues: SqlValue[], pkValues: SqlValue[], options?: EncodeOptions, indexDirections?: ReadonlyArray<boolean>, pkDirections?: ReadonlyArray<boolean>, pkCollations?: ReadonlyArray<string | undefined>, indexTransforms?: ReadonlyArray<KeyValueTransform | undefined>, pkTransforms?: ReadonlyArray<KeyValueTransform | undefined>): Uint8Array;
115
+ export declare function buildIndexKey(index: IndexKeyHalf, pk: IndexKeyHalf, options?: EncodeOptions): Uint8Array;
103
116
  /**
104
117
  * Build a catalog key for DDL storage.
105
118
  * Format: {schema}.{table}
@@ -201,6 +214,12 @@ export declare function buildFullScanBounds(): {
201
214
  * `directions[i] === true` flips bytes of prefix component i to match DESC
202
215
  * encoding in the stored index keys.
203
216
  *
217
+ * `collations[i]`, when defined, encodes prefix component i under its own key
218
+ * collation (overriding `options.collation`) — MUST be the same per-column index
219
+ * key collations `buildIndexKey`'s index half was written under
220
+ * (`resolveIndexKeyCollations`), or the bounds address different bytes than the
221
+ * stored entries. Same parameter order as {@link buildPkPrefixBounds}.
222
+ *
204
223
  * `lt` is omitted when the encoded prefix is all-0xff bytes (e.g. a single
205
224
  * leading DESC NULL, whose type byte inverts to 0xff) — no finite exclusive
206
225
  * upper bound exists, so the scan runs to the end of the store.
@@ -211,15 +230,16 @@ export declare function buildFullScanBounds(): {
211
230
  * with a 0xff type byte) — the same trap {@link buildFullScanBounds} documents
212
231
  * for data stores.
213
232
  *
214
- * NOTE: both `StoreTable` callers (`analyzeIndexAccess`, `buildIndexRangeBounds`)
215
- * pass NO `transforms` — sound only because both decline a semantic-ordering
216
- * column before they get here (the EQ-prefix loop breaks on `hasSemanticOrdering`;
217
- * the range arm is gated on `keyOrderMatchesCollation`). If backlog
218
- * `feat-reopen-timespan-store-seeks` re-opens either arm, thread the column's
219
- * transforms through first or the bounds will address raw-value bytes while the
220
- * index holds transformed ones.
233
+ * NOTE: all three `StoreTable` callers (`analyzeIndexAccess`, `buildIndexRangeBounds`,
234
+ * `scanMultiSeek`) pass NO `transforms` — sound only because each declines a
235
+ * semantic-ordering column before it gets here (the EQ-prefix loop breaks on
236
+ * `hasSemanticOrdering`; the range arm is gated on `keyOrderMatchesCollation`; the
237
+ * multi-seek throws INTERNAL, its plan having already been declined by
238
+ * `tryIndexAccessPlan` (store-module-access-plan.ts)). If backlog `feat-reopen-timespan-store-seeks`
239
+ * re-opens any arm, thread the column's transforms through first or the bounds will
240
+ * address raw-value bytes while the index holds transformed ones.
221
241
  */
222
- export declare function buildIndexPrefixBounds(prefixValues: SqlValue[], options?: EncodeOptions, directions?: ReadonlyArray<boolean>, transforms?: ReadonlyArray<KeyValueTransform | undefined>): {
242
+ export declare function buildIndexPrefixBounds(prefixValues: SqlValue[], options?: EncodeOptions, directions?: ReadonlyArray<boolean>, collations?: ReadonlyArray<string | undefined>, transforms?: ReadonlyArray<KeyValueTransform | undefined>): {
223
243
  gte: Uint8Array;
224
244
  lt?: Uint8Array;
225
245
  };
@@ -1 +1 @@
1
- {"version":3,"file":"key-builder.d.ts","sourceRoot":"","sources":["../../../src/common/key-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAiD,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAK1H;;GAEG;AACH,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,mCAAmC;AACnC,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAgB5C;;;;;;;;;;;;;;;;;;GAkBG;AASH,wBAAgB,kBAAkB,CAAC,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AAE,MAAM,EAClB,SAAS,EAAE,MAAM,GACf,UAAU,CAEZ;AAED,kDAAkD;AAClD,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAChB;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAErB;AAED,qDAAqD;AACrD,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,QAAQ,EAAE,EACzB,OAAO,CAAC,EAAE,aAAa,GACrB;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,EAAE,CAAC,EAAE,UAAU,CAAA;CAAE,CAEtC;AAED,8CAA8C;AAC9C,wBAAgB,YAAY,CAC3B,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,EACpC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GACf,UAAU,CAEZ;AAED,qDAAqD;AACrD,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,EACpC,UAAU,CAAC,EAAE,MAAM,GACjB;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,UAAU,CAAA;CAAE,CAErC"}
@@ -121,22 +121,23 @@ export function buildDataKey(pkValues, options, directions, collations, transfor
121
121
  * Format: {encoded_index_cols}{encoded_pk}
122
122
  *
123
123
  * The index columns come first for range scans, followed by PK for uniqueness.
124
- * `indexDirections` and `pkDirections` independently control DESC bit-inversion
125
- * for each half so ordered index scans honor per-column direction.
124
+ * The two halves are symmetric {@link IndexKeyHalf}s:
126
125
  *
127
- * `pkCollations[i]`, when defined, encodes the PK-suffix column i under its own
128
- * key collation (overriding `options.collation`). The PK suffix MUST be encoded
129
- * with the same per-column collations as the data key (see `buildDataKey`), so
130
- * index maintenance (delete-then-insert on UPDATE/DELETE) addresses the same
131
- * bytes the data store keys by. Index columns keep `options.collation`.
132
- *
133
- * `indexTransforms` / `pkTransforms` canonicalize each half's values before
134
- * encoding (see {@link KeyValueTransform}); the PK-suffix transforms MUST match
135
- * the data key's for the same reason as the collations above.
126
+ * - `index.collations` encodes each index column under its own key collation
127
+ * (`resolveIndexKeyCollations` — the index column's COLLATE, else the table
128
+ * column's declared collation, else BINARY), so the stored bytes agree with the
129
+ * collation everything that COMPARES those values uses (`matchesFilters`, the
130
+ * planner's cover analysis, UNIQUE enforcement).
131
+ * - `pk.collations` MUST be the same per-column collations as the data key (see
132
+ * `buildDataKey` / `resolvePkKeyCollations`), so index maintenance
133
+ * (delete-then-insert on UPDATE/DELETE) addresses the same bytes the data store
134
+ * keys by.
135
+ * - Each half's `transforms` canonicalize its values before encoding; the PK
136
+ * suffix's MUST match the data key's for the same reason as its collations.
136
137
  */
137
- export function buildIndexKey(indexValues, pkValues, options, indexDirections, pkDirections, pkCollations, indexTransforms, pkTransforms) {
138
- const indexEncoded = encodeCompositeKey(indexValues, options, indexDirections, undefined, indexTransforms);
139
- const pkEncoded = encodeCompositeKey(pkValues, options, pkDirections, pkCollations, pkTransforms);
138
+ export function buildIndexKey(index, pk, options) {
139
+ const indexEncoded = encodeCompositeKey(index.values, options, index.directions, index.collations, index.transforms);
140
+ const pkEncoded = encodeCompositeKey(pk.values, options, pk.directions, pk.collations, pk.transforms);
140
141
  return concatBytes(indexEncoded, pkEncoded);
141
142
  }
142
143
  /**
@@ -295,6 +296,12 @@ export function buildFullScanBounds() {
295
296
  * `directions[i] === true` flips bytes of prefix component i to match DESC
296
297
  * encoding in the stored index keys.
297
298
  *
299
+ * `collations[i]`, when defined, encodes prefix component i under its own key
300
+ * collation (overriding `options.collation`) — MUST be the same per-column index
301
+ * key collations `buildIndexKey`'s index half was written under
302
+ * (`resolveIndexKeyCollations`), or the bounds address different bytes than the
303
+ * stored entries. Same parameter order as {@link buildPkPrefixBounds}.
304
+ *
298
305
  * `lt` is omitted when the encoded prefix is all-0xff bytes (e.g. a single
299
306
  * leading DESC NULL, whose type byte inverts to 0xff) — no finite exclusive
300
307
  * upper bound exists, so the scan runs to the end of the store.
@@ -305,19 +312,20 @@ export function buildFullScanBounds() {
305
312
  * with a 0xff type byte) — the same trap {@link buildFullScanBounds} documents
306
313
  * for data stores.
307
314
  *
308
- * NOTE: both `StoreTable` callers (`analyzeIndexAccess`, `buildIndexRangeBounds`)
309
- * pass NO `transforms` — sound only because both decline a semantic-ordering
310
- * column before they get here (the EQ-prefix loop breaks on `hasSemanticOrdering`;
311
- * the range arm is gated on `keyOrderMatchesCollation`). If backlog
312
- * `feat-reopen-timespan-store-seeks` re-opens either arm, thread the column's
313
- * transforms through first or the bounds will address raw-value bytes while the
314
- * index holds transformed ones.
315
+ * NOTE: all three `StoreTable` callers (`analyzeIndexAccess`, `buildIndexRangeBounds`,
316
+ * `scanMultiSeek`) pass NO `transforms` — sound only because each declines a
317
+ * semantic-ordering column before it gets here (the EQ-prefix loop breaks on
318
+ * `hasSemanticOrdering`; the range arm is gated on `keyOrderMatchesCollation`; the
319
+ * multi-seek throws INTERNAL, its plan having already been declined by
320
+ * `tryIndexAccessPlan` (store-module-access-plan.ts)). If backlog `feat-reopen-timespan-store-seeks`
321
+ * re-opens any arm, thread the column's transforms through first or the bounds will
322
+ * address raw-value bytes while the index holds transformed ones.
315
323
  */
316
- export function buildIndexPrefixBounds(prefixValues, options, directions, transforms) {
324
+ export function buildIndexPrefixBounds(prefixValues, options, directions, collations, transforms) {
317
325
  if (prefixValues.length === 0) {
318
326
  return buildFullScanBounds();
319
327
  }
320
- const prefixEncoded = encodeCompositeKey(prefixValues, options, directions, undefined, transforms);
328
+ const prefixEncoded = encodeCompositeKey(prefixValues, options, directions, collations, transforms);
321
329
  return {
322
330
  gte: prefixEncoded,
323
331
  lt: incrementLastByte(prefixEncoded),
@@ -1 +1 @@
1
- {"version":3,"file":"key-builder.js","sourceRoot":"","sources":["../../../src/common/key-builder.ts"],"names":[],"mappings":"AAAA;;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e,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,mBAAmB,CAClC,SAAoC,EACpC,UAAmB;IAEnB,OAAO,sBAAsB,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC"}
@@ -90,6 +90,16 @@ export interface WriteBatch {
90
90
  * so for one (store, key) pair the later op wins. The coordinator replays its
91
91
  * pending ops into one atomic batch without collapsing duplicates, so a
92
92
  * transaction that writes then deletes the same row depends on this.
93
+ *
94
+ * SINGLE USE: a batch is spent once `write()` resolves — queue one commit's ops, write
95
+ * once, drop it (what the coordinator does). Reuse after `write()` is deliberately
96
+ * unspecified and backends differ: LevelDB's chained batch is closed by `write()` and
97
+ * throws on any later call, while IndexedDB's merely resets its op list and keeps working.
98
+ *
99
+ * NOTE: there is also no dispose — a batch that is built and then abandoned without
100
+ * `write()` (only reachable today if queueing throws MISUSE, i.e. a programming error)
101
+ * leaks whatever the backend holds until GC. If an abandoned-batch path ever becomes
102
+ * ordinary, give this interface a `close()` and make both behaviors conformance-tested.
93
103
  */
94
104
  export interface AtomicBatch {
95
105
  /** Queue a put against the given store. */
@@ -1 +1 @@
1
- {"version":3,"file":"kv-store.d.ts","sourceRoot":"","sources":["../../../src/common/kv-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,gEAAgE;IAChE,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,2BAA2B;IAC3B,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,wDAAwD;IACxD,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,GAAG,EAAE,UAAU,C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ExG;;;;;;;;;;;;;;;;;OAiBG;IACH,iBAAiB,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvH;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,IAAI,WAAW,GAAG,SAAS,CAAC;CAC7C"}
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Resolution of the physical KEY properties of a table's primary-key and
3
+ * secondary-index columns: the per-column key collation, the key-identity value
4
+ * transform for semantic-ordering types, and the order-safety predicates that
5
+ * decide whether a byte window may stand in for a comparator range.
6
+ *
7
+ * Shared by the store table (data-key + index-maintenance encoding) and
8
+ * `StoreModule` (index rebuild, access planning) so key encoding can never drift
9
+ * between the two.
10
+ */
11
+ import { type LogicalType, type Database, type ColumnSchema, type TableSchema, type TableIndexSchema, type SqlValue } from '@quereus/quereus';
12
+ import { type KeyValueTransform } from './encoding.js';
13
+ /**
14
+ * Resolve the per-column KEY collation for each primary-key column.
15
+ *
16
+ * The store encodes PRIMARY KEY uniqueness/ordering PHYSICALLY in the key bytes, so each
17
+ * text-capable PK column's key must be encoded under the collation the engine actually
18
+ * COMPARES that column under. Returns one entry per PK member, in `pkDef` order:
19
+ * - collation-aware member (`text`, `any` — the types whose `compare` applies the
20
+ * collation it is handed, `LogicalType.collationAware`) → its declared `collation`
21
+ * (normalized upper-case), or `fallback` (the table key collation K) when the
22
+ * column carries none.
23
+ * - text-capable but collation-blind member — `json` and the temporal types
24
+ * (`date` / `time` / `datetime` / `timespan`) → hard-coded `'BINARY'`: those
25
+ * types' `compare` is not the generic storage-class + collation comparison (the
26
+ * temporals ignore the argument; JSON ranks structurally), and their empty
27
+ * `supportedCollations` list keeps a non-BINARY column COLLATE out at DDL time.
28
+ * - never-text member → `undefined`: collation is meaningless for
29
+ * integer/real/blob keys (they encode type-natively), so the encoder ignores
30
+ * it and the data/index key bytes are identical regardless.
31
+ *
32
+ * Note that `undefined` does NOT mean "encode type-natively" to `encodeValue` — it means
33
+ * "fall back to `options.collation`", the table key collation K. Only a never-text column
34
+ * may be left `undefined`, because only it never reaches the collation branch.
35
+ *
36
+ * Every name returned here is encoded through the key-normalizer resolver carried
37
+ * in `EncodeOptions.normalizers` (`db.getKeyNormalizerResolver()`), so a collation
38
+ * registered or overridden with `db.registerCollation` produces key bytes that agree
39
+ * with the comparator the store's UNIQUE enforcement uses. A collation that cannot
40
+ * key — unregistered, or registered with a comparator but no normalizer — is rejected
41
+ * at DDL time by `StoreTableBase.validateKeyCollations`, so no encode call ever has
42
+ * to fall back. Shared by `StoreTable` (data-key + index-maintenance) and
43
+ * the index rebuild `buildIndexEntries` (store-module-index-build.ts) so the PK suffix
44
+ * encoding can never drift between the two.
45
+ */
46
+ export declare function resolvePkKeyCollations(pkDef: ReadonlyArray<{
47
+ index: number;
48
+ }>, columns: ReadonlyArray<ColumnSchema>, fallback: string): (string | undefined)[];
49
+ /**
50
+ * Per-column KEY collation for a secondary index's OWN columns (the index half of
51
+ * `buildIndexKey`), positionally aligned with `index.columns` — the index twin of
52
+ * {@link resolvePkKeyCollations}. Same three-way branch, delegated to the engine's
53
+ * `pkKeyCollationName`:
54
+ * - never-text column (`integer`, `real`, `blob`) → `undefined`: encoded
55
+ * type-natively, collation is moot.
56
+ * - text-capable but collation-blind (`json`, the temporal types) → hard-coded
57
+ * `'BINARY'` — those types' `compare` is not the generic collation comparison.
58
+ * - collation-aware (`text`, `any`) → the index column's own COLLATE, else the
59
+ * table column's declared collation, else `'BINARY'`.
60
+ *
61
+ * The fallback is `BINARY`, NOT the table key collation K — deliberately asymmetric
62
+ * with {@link resolvePkKeyCollations}, whose fallback IS K. For a PK member the
63
+ * asymmetry is illusory: `reconcilePkCollations` (store-module-schema-rewrite.ts)
64
+ * rewrites an undecorated text PK column's declared collation to K at CREATE time, so
65
+ * for a PK member K *is* the declared collation. No such rewrite exists for non-PK
66
+ * columns — an undecorated `text` column genuinely compares under BINARY (in the
67
+ * engine's operators and in the store's `matchesFilters` residual alike), so BINARY is
68
+ * what its index bytes must encode under, or the stored order/equality disagrees with
69
+ * every comparison made against it.
70
+ */
71
+ export declare function resolveIndexKeyCollations(index: TableIndexSchema, columns: ReadonlyArray<ColumnSchema>): (string | undefined)[];
72
+ /**
73
+ * The store's per-type key VALUE TRANSFORM for a semantic-ordering logical type, or
74
+ * `undefined` when raw values already key faithfully.
75
+ *
76
+ * The contract is TWO-sided — identity AND order. `StoreTable` implements no
77
+ * `comparePrimaryKey`, so the isolation layer merges overlay against underlying with
78
+ * its own fallback comparator (the PK type's `compare` via `createTypedComparator`)
79
+ * and needs this table's key BYTE order to agree with it; and byte equality must be
80
+ * exactly the type's equality, or two spellings of one value land on two keys.
81
+ *
82
+ * - JSON → the store-local structural encoder ({@link jsonStructuralKey}): a
83
+ * `Uint8Array` whose memcmp order reproduces the type's structural `compare`
84
+ * (canonical-text bytes are identity-faithful but sort `[10]` before `[2]`,
85
+ * which broke overlay shadowing — see json-key.ts).
86
+ * - Everything else → the engine's {@link semanticKeyTransform} (the type's
87
+ * `groupKey`). Today that is TIMESPAN: total seconds against the same reference
88
+ * date as `TIMESPAN.compare`, so 'PT1H' and 'PT60M' collide on one key AND byte
89
+ * order is elapsed-time order.
90
+ *
91
+ * JSON deliberately gets NO engine `groupKey` — `groupKey` also drives GROUP BY /
92
+ * `IN` / hash-join identity, where canonical-text identity is already correct and a
93
+ * `Uint8Array` key would be a behaviour change for no benefit. Hence this
94
+ * store-local seam. A semantic-ordering type with NEITHER a `groupKey` nor an entry
95
+ * here cannot key a persisted structure soundly; `StoreTable` rejects it at DDL time
96
+ * (see `validateSemanticKeyTransforms`).
97
+ *
98
+ * This is the PHYSICAL KEY BYTES resolver — it feeds `buildIndexKey` / `buildDataKey`
99
+ * and its output is memcmp-ordered and persisted. {@link storeDedupeKeyTransform} is
100
+ * its build/validate-time twin: same job, but for the transient UNIQUE dedupe
101
+ * signature, which is free to leave a comparable value for `serializeKey`'s collation
102
+ * normalizer instead of committing to structural bytes.
103
+ */
104
+ export declare function storeSemanticKeyTransform(type: LogicalType | undefined): KeyValueTransform | undefined;
105
+ /**
106
+ * The build/validate-time twin of {@link storeSemanticKeyTransform}, for the UNIQUE
107
+ * dedupe SIGNATURE rather than physical key bytes (`buildIndexEntries`'s in-pass
108
+ * `seen` check and `assertNoDuplicateRows`, both in store-module-index-build.ts).
109
+ *
110
+ * The signature is a `serializeKey` call over the (possibly transformed) values, and
111
+ * `serializeKey` applies a column's collation NORMALIZER only to a raw `string` value
112
+ * — a transform that returns a `Uint8Array` (as {@link storeSemanticKeyTransform} does
113
+ * for JSON, via {@link jsonStructuralKey}) is tagged as an opaque byte array instead,
114
+ * and the normalizer never runs. For JSON that would silently drop the index
115
+ * COLLATE on exactly the case `JSON_TYPE.compare` treats as text (a string-scalar
116
+ * pair) and let a build-time UNIQUE index admit rows a write-time insert would then
117
+ * reject (bug-store-index-build-dedupe-skips-collation) — so this resolver special-
118
+ * cases JSON: a string scalar is left AS a string, so `serializeKey`'s normalizer
119
+ * still runs; every other JSON value (object, array, number, boolean, or null) falls
120
+ * back to the structural bytes, matching `JSON_TYPE.compare`'s non-text ranking.
121
+ *
122
+ * Every other semantic-ordering type (TIMESPAN today) is unaffected: its `compare`
123
+ * ignores the collation it is handed, and its `groupKey` transform already collides
124
+ * every equal-identity spelling onto one value on both the build and write paths, so
125
+ * this resolver defers to {@link storeSemanticKeyTransform} unchanged.
126
+ */
127
+ export declare function storeDedupeKeyTransform(type: LogicalType | undefined): KeyValueTransform | undefined;
128
+ /**
129
+ * Resolve the per-column key value transform for each primary-key column —
130
+ * {@link storeSemanticKeyTransform} of the member's logical type. One entry per PK
131
+ * member in `pkDef` order; `undefined` for every type whose raw value already keys
132
+ * faithfully. The companion of {@link resolvePkKeyCollations}: every call site that
133
+ * threads the collations MUST thread these too, or key identity/order drifts
134
+ * between the write path and the rebuild/lookup path.
135
+ */
136
+ export declare function resolvePkKeyTransforms(pkDef: ReadonlyArray<{
137
+ index: number;
138
+ }>, columns: ReadonlyArray<ColumnSchema>): (KeyValueTransform | undefined)[];
139
+ /**
140
+ * Per-column key value transforms for a secondary index's OWN columns (the
141
+ * index half of `buildIndexKey`), positionally aligned with `index.columns`.
142
+ * Same rule as {@link resolvePkKeyTransforms}: a semantic-ordering member
143
+ * canonicalizes through {@link storeSemanticKeyTransform}, everything else
144
+ * encodes raw.
145
+ */
146
+ export declare function resolveIndexKeyTransforms(index: TableIndexSchema, columns: ReadonlyArray<ColumnSchema>): (KeyValueTransform | undefined)[];
147
+ /**
148
+ * Per-column {@link storeDedupeKeyTransform} for an arbitrary column-index list —
149
+ * the UNIQUE dedupe-signature counterpart of {@link resolveIndexKeyTransforms},
150
+ * shared by both build/validate-time dedupe sites (`buildIndexEntries`' in-pass
151
+ * `seen` check over an index's columns, `assertNoDuplicateRows` over a constraint's)
152
+ * so the two cannot drift onto different transforms.
153
+ */
154
+ export declare function resolveDedupeKeyTransforms(colIndices: ReadonlyArray<number>, columns: ReadonlyArray<ColumnSchema>): (KeyValueTransform | undefined)[];
155
+ /**
156
+ * Per-PK-column typed equality comparator for semantic-ordering members, `undefined`
157
+ * elsewhere. Backs `StoreTableConstraints.keysEqual`: two PK arrays naming the same
158
+ * physical key under {@link resolvePkKeyTransforms} ('PT1H' / 'PT60M') must also
159
+ * answer "same row" here, or self-PK exclusion in the UNIQUE checks false-conflicts
160
+ * a row against its own differently-spelled image.
161
+ */
162
+ export declare function resolvePkSemanticEquality(pkDef: ReadonlyArray<{
163
+ index: number;
164
+ }>, columns: ReadonlyArray<ColumnSchema>): (((a: SqlValue, b: SqlValue) => number) | undefined)[];
165
+ /**
166
+ * True when `col` can produce a TEXT value at runtime, and so when its physical
167
+ * key bytes are produced by a collation normalizer rather than a type-native
168
+ * encoding. The `ColumnSchema`-shaped wrapper over the engine's
169
+ * {@link logicalTypeCanHoldText}; both collation-safety guards over the store's
170
+ * secondary indexes — the write-side `StoreTableConstraints.indexSeekHonorsEnforcementCollation`
171
+ * and the read-side {@link keyOrderMatchesCollation} — exempt a never-text column from their
172
+ * key-vs-comparison collation test, so a false "non-text" answer is a silent wrong-result
173
+ * (a seek under the wrong collation, with the residual dropped).
174
+ */
175
+ export declare function columnCanHoldText(col: ColumnSchema | undefined): boolean;
176
+ /**
177
+ * True when a byte window — or a byte-order advertisement — over `column` is SOUND.
178
+ *
179
+ * The store physically orders rows by memcmp of each column's key bytes, which for a
180
+ * text-capable column are produced by `keyCollation`'s normalizer. A range seek (and the
181
+ * `providesOrdering` / `monotonicOn` advertisement) equates that byte order with the order
182
+ * `compareCollation`'s comparator defines. Two things must hold for that equation:
183
+ *
184
+ * - **Same collation on both sides** (`compareCollation === keyCollation`). A `keyCollation`
185
+ * merely COARSER than `compareCollation` is not enough: it would need the key normalizer
186
+ * to be monotone with respect to the OTHER collation's order. It generally is not, even
187
+ * for built-ins: with `keyCollation = NOCASE` and `compareCollation = BINARY`,
188
+ * 'K' (U+212A KELVIN SIGN) is `> 'z'` under BINARY, yet its key bytes are
189
+ * `toLowerCase('K') = 'k'`, which sorts BEFORE 'z' — the row falls outside a `> 'z'`
190
+ * window and is silently dropped.
191
+ * - **The normalizer preserves order** (`db._isCollationOrderPreserving`). `registerCollation`
192
+ * promises only that a normalizer partitions strings the way the comparator calls them
193
+ * equal; a custom pair may agree on equality and disagree on order.
194
+ *
195
+ * A never-text column is exempt: its key bytes are type-native and collation-independent.
196
+ *
197
+ * Returning `false` costs an optimization (the caller full-scans and lets the
198
+ * collation-aware `matchesFilters` residual decide); returning `true` wrongly is a silent
199
+ * wrong-result. Shared by `StoreTable`'s read arms and `StoreModule`'s access planner so the
200
+ * "mark handled" and "build a window" decisions can never disagree.
201
+ *
202
+ * The PK caller ({@link pkOrderPreservingPrefixLength}) can genuinely pass two DIFFERENT
203
+ * collations, because {@link resolvePkKeyCollations} still falls back to the table key
204
+ * collation K for an undecorated text PK member. The secondary-index caller
205
+ * ({@link indexLeadingRangeIsOrderSafe}) usually passes the same name on both sides — index
206
+ * key bytes encode under the index column's own effective collation, which is what the scan
207
+ * residual re-compares under — so for a `text` or `any` column it reduces to the
208
+ * `orderPreserving` assertion alone. The one index shape where the two sides still differ is
209
+ * a collation-blind column (`json`, the temporal types) under an index column carrying an
210
+ * explicit non-BINARY COLLATE (index DDL does not type-gate the way column DDL does): its
211
+ * key bytes are hard-`BINARY` while its residual compares under the declared name, and this
212
+ * predicate correctly declines it.
213
+ */
214
+ export declare function keyOrderMatchesCollation(db: Database, column: ColumnSchema | undefined, keyCollation: string, compareCollation: string): boolean;
215
+ /**
216
+ * True when an EQUALITY/prefix byte window over the leading `prefixLength` columns of
217
+ * secondary `index` is EXACTLY the qualifying set — the condition under which the access
218
+ * planner may claim the equality filters handled and drop the residual Filter.
219
+ *
220
+ * `keyCollations` is {@link resolveIndexKeyCollations}' output for `index` (the scan passes
221
+ * its memoized copy, the access planner resolves one on the spot): the collation each
222
+ * position's key bytes are ACTUALLY encoded under. The window equals the qualifying set iff
223
+ * that agrees, per position, with {@link indexResidualCollation}.
224
+ *
225
+ * For a `text` or `any` column the two agree by construction — both resolve to the index
226
+ * `COLLATE` else the declared collation else BINARY — so those admit, including the
227
+ * `text` column of a table whose key collation K is something else entirely, and an
228
+ * `x any collate nocase` index column (whose window is now genuinely the NOCASE-equal
229
+ * set — ANY's `compare` honors the collation, so key bytes, residual, and enforcement
230
+ * all agree). The shape that does NOT agree is a collation-blind column (`json`, the
231
+ * temporal types) under an index column carrying an explicit non-BINARY COLLATE:
232
+ * `pkKeyCollationName` keys those hard-`BINARY` while the residual still compares under
233
+ * the declared name, so the window would be byte-equal only and miss rows the residual
234
+ * admits — declined. Never-text columns are exempt — their key bytes are type-native.
235
+ */
236
+ export declare function indexPrefixSeekIsCollationExact(columns: ReadonlyArray<ColumnSchema>, index: TableIndexSchema, keyCollations: ReadonlyArray<string | undefined>, prefixLength: number): boolean;
237
+ /**
238
+ * True when a byte RANGE window over the LEADING column of secondary `index` is SOUND.
239
+ *
240
+ * Strictly stronger than {@link indexPrefixSeekIsCollationExact} at position 0: the same
241
+ * key-vs-residual collation agreement, PLUS the collation's `orderPreserving` assertion,
242
+ * because a range window also equates memcmp of the key bytes with the residual
243
+ * comparator's ORDER. Both halves are {@link keyOrderMatchesCollation}, which also declines
244
+ * a semantic-ordering column outright.
245
+ *
246
+ * THE shared predicate for the two decision sites: `tryIndexAccessPlan`
247
+ * (store-module-access-plan.ts) marks the range filters handled only when it holds, and
248
+ * `StoreTableScan.analyzeIndexAccess` builds a window only when it holds. They must agree —
249
+ * a plan that claims a filter the scan then declines to window loses the residual Filter and
250
+ * returns the whole table — so they call this rather than each restating it.
251
+ */
252
+ export declare function indexLeadingRangeIsOrderSafe(db: Database, columns: ReadonlyArray<ColumnSchema>, index: TableIndexSchema, keyCollations: ReadonlyArray<string | undefined>): boolean;
253
+ /**
254
+ * How many LEADING primary-key members have key bytes whose memcmp order matches their
255
+ * declared collation's comparator order, per {@link keyOrderMatchesCollation}.
256
+ *
257
+ * `pkKeyCollations` is {@link resolvePkKeyCollations}' output for this table; an `undefined`
258
+ * entry belongs to a never-text member, which {@link keyOrderMatchesCollation} exempts
259
+ * outright — `tableKeyCollation` is passed only so the exempt branch has a name to ignore.
260
+ * The comparison collation is the column's declared one, which `reconcilePkCollations` has
261
+ * already aligned with the key collation for every *textual* PK member.
262
+ *
263
+ * What the advertisement is measured against is the order the planner's `Sort` would have
264
+ * produced. For most members Sort orders under the operand's COLLATION, so a collation match
265
+ * is the question; for a member whose logical type carries SEMANTIC ordering (TIMESPAN, JSON
266
+ * — see docs/types.md "Semantic ordering") Sort now ranks by `logicalType.compare`, which no
267
+ * text-byte encoding reproduces, and {@link keyOrderMatchesCollation} closes the gate for
268
+ * such members outright (the memory backend's typed BTree order is the canonical order under
269
+ * that ruling; the store declines rather than advertising a divergent byte order).
270
+ *
271
+ * `0` ⇒ even the leading member is unsafe: no range seek, no PK-order advertisement.
272
+ * A prefix shorter than the PK truncates the ordering advertisement rather than voiding it.
273
+ */
274
+ export declare function pkOrderPreservingPrefixLength(db: Database, schema: TableSchema, pkKeyCollations: ReadonlyArray<string | undefined>, tableKeyCollation: string): number;
275
+ //# sourceMappingURL=pk-key-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pk-key-resolution.d.ts","sourceRoot":"","sources":["../../../src/common/pk-key-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAON,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,aAAa,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EACvC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,QAAQ,EAAE,MAAM,GACd,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAUxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,GAClC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAcxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAQtG;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAGpG;AAaD;;;;;;;GAO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