@noy-db/hub 0.2.0-pre.30 → 0.2.0-pre.31

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 (143) hide show
  1. package/dist/adapter/index.d.ts +9 -0
  2. package/dist/adapter/index.js +14 -0
  3. package/dist/attestation/index.d.ts +1 -1
  4. package/dist/attestation/index.js +3 -3
  5. package/dist/blobs/index.d.ts +3 -3
  6. package/dist/bundle/index.d.ts +3 -3
  7. package/dist/bundle/index.js +1 -1
  8. package/dist/{chunk-Y6YUWZTS.js → chunk-L5HHBOMS.js} +2 -2
  9. package/dist/{chunk-BVKLJBJJ.js → chunk-W5NVNJDX.js} +2 -1
  10. package/dist/{chunk-BVKLJBJJ.js.map → chunk-W5NVNJDX.js.map} +1 -1
  11. package/dist/consent/index.d.ts +2 -2
  12. package/dist/{decrypt-partition-Mhjh6nnG.d.ts → decrypt-partition-CXS5KopB.d.ts} +1 -1
  13. package/dist/derivations/index.d.ts +3 -3
  14. package/dist/{dev-unlock-DJ3IhgY9.d.ts → dev-unlock-CnHTTVea.d.ts} +1 -1
  15. package/dist/guards/index.d.ts +3 -3
  16. package/dist/{hash-DLwkYf1d.d.ts → hash-oc5paYl0.d.ts} +1 -1
  17. package/dist/history/index.d.ts +3 -3
  18. package/dist/i18n/index.d.ts +2 -2
  19. package/dist/{index-CMRIx_zx.d.ts → index-BmhGztUi.d.ts} +1 -1
  20. package/dist/index.d.ts +11 -11
  21. package/dist/index.js +2 -2
  22. package/dist/kernel/index.d.ts +2 -2
  23. package/dist/materialized-views/index.d.ts +3 -3
  24. package/dist/{mime-magic-CacDBwYp.d.ts → mime-magic-JeLKHRng.d.ts} +1 -1
  25. package/dist/{noydb-5MIBD77B.js → noydb-NAU2DTFP.js} +2 -2
  26. package/dist/noydb-NAU2DTFP.js.map +1 -0
  27. package/dist/overlay-views/index.d.ts +3 -3
  28. package/dist/periods/index.d.ts +2 -2
  29. package/dist/session/index.d.ts +3 -3
  30. package/dist/shadow/index.d.ts +2 -2
  31. package/dist/snapshots/index.d.ts +2 -2
  32. package/dist/store/index.d.ts +2 -2
  33. package/dist/sync/index.d.ts +1 -1
  34. package/dist/team/index.d.ts +2 -2
  35. package/dist/{transition-guard-J04-jime.d.ts → transition-guard-Dy3NioQr.d.ts} +1 -1
  36. package/dist/tx/index.d.ts +2 -2
  37. package/dist/{with-materialized-view-DNfzC5lH.d.ts → with-materialized-view-DIVeez0W.d.ts} +1 -1
  38. package/dist/{with-overlayed-view-qk3lbhOd.d.ts → with-overlayed-view-DVZrc5Hb.d.ts} +1 -1
  39. package/dist/{with-rollup-Dd3_ZG4b.d.ts → with-rollup-CbU-O4wP.d.ts} +1 -1
  40. package/package.json +62 -221
  41. package/dist/aggregate/index.cjs +0 -1144
  42. package/dist/aggregate/index.cjs.map +0 -1
  43. package/dist/aggregate/index.d.cts +0 -39
  44. package/dist/attestation/index.cjs +0 -305
  45. package/dist/attestation/index.cjs.map +0 -1
  46. package/dist/attestation/index.d.cts +0 -54
  47. package/dist/blobs/index.cjs +0 -1967
  48. package/dist/blobs/index.cjs.map +0 -1
  49. package/dist/blobs/index.d.cts +0 -48
  50. package/dist/bundle/index.cjs +0 -41045
  51. package/dist/bundle/index.cjs.map +0 -1
  52. package/dist/bundle/index.d.cts +0 -187
  53. package/dist/consent/index.cjs +0 -204
  54. package/dist/consent/index.cjs.map +0 -1
  55. package/dist/consent/index.d.cts +0 -27
  56. package/dist/crdt/index.cjs +0 -152
  57. package/dist/crdt/index.cjs.map +0 -1
  58. package/dist/crdt/index.d.cts +0 -30
  59. package/dist/decrypt-partition-C0iDpbSd.d.cts +0 -558
  60. package/dist/derivations/index.cjs +0 -469
  61. package/dist/derivations/index.cjs.map +0 -1
  62. package/dist/derivations/index.d.cts +0 -74
  63. package/dist/dev-unlock-0Z6yxfS7.d.cts +0 -263
  64. package/dist/discriminant-BN9REW3o.d.cts +0 -60
  65. package/dist/errors-BAWO5Z5a.d.cts +0 -1500
  66. package/dist/forget/index.cjs +0 -43
  67. package/dist/forget/index.cjs.map +0 -1
  68. package/dist/forget/index.d.cts +0 -1
  69. package/dist/guards/index.cjs +0 -455
  70. package/dist/guards/index.cjs.map +0 -1
  71. package/dist/guards/index.d.cts +0 -39
  72. package/dist/hash-Db8ncXGr.d.cts +0 -63
  73. package/dist/history/index.cjs +0 -1245
  74. package/dist/history/index.cjs.map +0 -1
  75. package/dist/history/index.d.cts +0 -65
  76. package/dist/i18n/index.cjs +0 -1280
  77. package/dist/i18n/index.cjs.map +0 -1
  78. package/dist/i18n/index.d.cts +0 -41
  79. package/dist/index-BMmajblo.d.cts +0 -362
  80. package/dist/index-C1SC1EPe.d.cts +0 -1325
  81. package/dist/index-xJEPkvMb.d.cts +0 -93
  82. package/dist/index.cjs +0 -48100
  83. package/dist/index.cjs.map +0 -1
  84. package/dist/index.d.cts +0 -1050
  85. package/dist/indexing/index.cjs +0 -803
  86. package/dist/indexing/index.cjs.map +0 -1
  87. package/dist/indexing/index.d.cts +0 -36
  88. package/dist/kernel/index.cjs +0 -751
  89. package/dist/kernel/index.cjs.map +0 -1
  90. package/dist/kernel/index.d.cts +0 -11
  91. package/dist/lazy-builder-eYZzLEL1.d.cts +0 -304
  92. package/dist/materialized-views/index.cjs +0 -1518
  93. package/dist/materialized-views/index.cjs.map +0 -1
  94. package/dist/materialized-views/index.d.cts +0 -187
  95. package/dist/mime-magic-sdMzsfVK.d.cts +0 -103
  96. package/dist/overlay-views/index.cjs +0 -399
  97. package/dist/overlay-views/index.cjs.map +0 -1
  98. package/dist/overlay-views/index.d.cts +0 -102
  99. package/dist/periods/index.cjs +0 -1041
  100. package/dist/periods/index.cjs.map +0 -1
  101. package/dist/periods/index.d.cts +0 -24
  102. package/dist/predicate-BmhBSPCH.d.cts +0 -267
  103. package/dist/query/index.cjs +0 -3480
  104. package/dist/query/index.cjs.map +0 -1
  105. package/dist/query/index.d.cts +0 -4
  106. package/dist/sealed-record/index.cjs +0 -139
  107. package/dist/sealed-record/index.cjs.map +0 -1
  108. package/dist/sealed-record/index.d.cts +0 -123
  109. package/dist/session/index.cjs +0 -495
  110. package/dist/session/index.cjs.map +0 -1
  111. package/dist/session/index.d.cts +0 -48
  112. package/dist/shadow/index.cjs +0 -133
  113. package/dist/shadow/index.cjs.map +0 -1
  114. package/dist/shadow/index.d.cts +0 -19
  115. package/dist/snapshots/index.cjs +0 -937
  116. package/dist/snapshots/index.cjs.map +0 -1
  117. package/dist/snapshots/index.d.cts +0 -30
  118. package/dist/store/index.cjs +0 -1091
  119. package/dist/store/index.cjs.map +0 -1
  120. package/dist/store/index.d.cts +0 -501
  121. package/dist/strategy-BSxFXGzb.d.cts +0 -110
  122. package/dist/strategy-mJExw4LQ.d.cts +0 -1069
  123. package/dist/sync/index.cjs +0 -1062
  124. package/dist/sync/index.cjs.map +0 -1
  125. package/dist/sync/index.d.cts +0 -45
  126. package/dist/team/index.cjs +0 -2805
  127. package/dist/team/index.cjs.map +0 -1
  128. package/dist/team/index.d.cts +0 -120
  129. package/dist/transition-guard-tWZIsaXe.d.cts +0 -165
  130. package/dist/tx/index.cjs +0 -614
  131. package/dist/tx/index.cjs.map +0 -1
  132. package/dist/tx/index.d.cts +0 -39
  133. package/dist/types-CdVfiQgt.d.cts +0 -15275
  134. package/dist/ulid-DRH25k3y.d.cts +0 -66
  135. package/dist/util/index.cjs +0 -237
  136. package/dist/util/index.cjs.map +0 -1
  137. package/dist/util/index.d.cts +0 -79
  138. package/dist/with-materialized-view-DfgPcvi9.d.cts +0 -27
  139. package/dist/with-overlayed-view-Cvfkx1lg.d.cts +0 -13
  140. package/dist/with-rollup-nIxo7h9z.d.cts +0 -47
  141. /package/dist/{noydb-5MIBD77B.js.map → adapter/index.js.map} +0 -0
  142. /package/dist/{chunk-Y6YUWZTS.js.map → chunk-L5HHBOMS.js.map} +0 -0
  143. /package/dist/{types-DHn9lEP0.d.ts → index-DHn9lEP0.d.ts} +0 -0
@@ -1,24 +0,0 @@
1
- import { ab as PeriodsStrategy } from '../types-CdVfiQgt.cjs';
2
- export { ac as CarryForwardContext, ad as ClosePeriodOptions, ae as OpenPeriodOptions, af as PERIODS_COLLECTION, ag as PeriodRecord, ah as ReadOnlyCollection, ai as appendPeriodLedgerEntry, aj as assertTsWritable, ak as chainAnchor, al as loadPeriods, am as validatePeriodName } from '../types-CdVfiQgt.cjs';
3
- import '../lazy-builder-eYZzLEL1.cjs';
4
- import '../predicate-BmhBSPCH.cjs';
5
- import '../strategy-mJExw4LQ.cjs';
6
- import '../errors-BAWO5Z5a.cjs';
7
- import '../strategy-BSxFXGzb.cjs';
8
- import '../index-BMmajblo.cjs';
9
- import '../index-C1SC1EPe.cjs';
10
- import '@noy-db/attestation';
11
-
12
- /**
13
- * Active periods strategy factory. Only reachable through the
14
- * `@noy-db/hub/periods` subpath.
15
- */
16
-
17
- /**
18
- * Build the default periods strategy. Pass into
19
- * `createNoydb({ periodsStrategy: withPeriods() })` to enable
20
- * `vault.closePeriod()` / `vault.openPeriod()` / write-guards.
21
- */
22
- declare function withPeriods(): PeriodsStrategy;
23
-
24
- export { PeriodsStrategy, withPeriods };
@@ -1,267 +0,0 @@
1
- /**
2
- * Secondary indexes for the query DSL.
3
- *
4
- * ships **in-memory hash indexes**:
5
- * - Built during `Collection.ensureHydrated()` from the decrypted cache
6
- * - Maintained incrementally on `put` and `delete`
7
- * - Consulted by the query executor for `==` and `in` operators on
8
- * indexed fields, falling back to a linear scan otherwise
9
- * - Live entirely in memory — no adapter writes for the index itself
10
- *
11
- * Persistent encrypted index blobs (the spec's "store as a separate
12
- * AES-256-GCM blob" note) are deferred to a follow-up issue. The reasons
13
- * are documented in the PR body — short version: at the target
14
- * scale of 1K–50K records, building the index during hydrate is free,
15
- * so persistence buys nothing measurable.
16
- */
17
- /**
18
- * Index declaration accepted by `Collection`'s constructor.
19
- *
20
- * Accepts:
21
- * - `string` — a single-field hash index (`'clientId'`)
22
- * - `{ fields: [...] }` or `readonly string[]` — a composite index
23
- * over an ordered field tuple. Only lazy-mode
24
- * collections consume composite declarations today; eager mode
25
- * silently treats a composite as equivalent to declaring each
26
- * component field as its own single-field index.
27
- *
28
- * Additive variants (unique constraints, partial indexes) will land as
29
- * further union members without breaking existing declarations.
30
- */
31
- type IndexDef = string | {
32
- readonly fields: readonly string[];
33
- readonly unique?: boolean;
34
- } | readonly string[];
35
- /**
36
- * Internal representation of a built hash index.
37
- *
38
- * Maps stringified field values to the set of record ids whose value
39
- * for that field matches. Stringification keeps the index simple and
40
- * works uniformly for primitives (`'open'`, `'42'`, `'true'`).
41
- *
42
- * Records whose indexed field is `undefined` or `null` are NOT inserted
43
- * — `query().where('field', '==', undefined)` falls back to a linear
44
- * scan, which is the conservative behavior.
45
- */
46
- interface HashIndex {
47
- readonly field: string;
48
- readonly buckets: Map<string, Set<string>>;
49
- }
50
- /**
51
- * Container for all indexes on a single collection.
52
- *
53
- * Methods are pure with respect to the in-memory `buckets` Map — they
54
- * never touch the adapter or the keyring. The Collection class owns
55
- * lifecycle (build on hydrate, maintain on put/delete).
56
- */
57
- declare class CollectionIndexes {
58
- private readonly indexes;
59
- /**
60
- * Declare an index. Subsequent record additions are tracked under it.
61
- * Calling this twice for the same field is a no-op (idempotent).
62
- */
63
- declare(field: string): void;
64
- /** True if the given field has a declared index. */
65
- has(field: string): boolean;
66
- /** All declared field names, in declaration order. */
67
- fields(): string[];
68
- /**
69
- * Build all declared indexes from a snapshot of records.
70
- * Called once per hydration. O(N × indexes.size).
71
- */
72
- build<T>(records: ReadonlyArray<{
73
- id: string;
74
- record: T;
75
- }>): void;
76
- /**
77
- * Insert or update a single record across all indexes.
78
- * Called by `Collection.put()` after the encrypted write succeeds.
79
- *
80
- * If `previousRecord` is provided, the record is removed from any old
81
- * buckets first — this is the update path. Pass `null` for fresh adds.
82
- */
83
- upsert<T>(id: string, newRecord: T, previousRecord: T | null): void;
84
- /**
85
- * Remove a record from all indexes. Called by `Collection.delete()`
86
- * (and as the first half of `upsert` for the update path).
87
- */
88
- remove<T>(id: string, record: T): void;
89
- /** Drop all index data. Called when the collection is invalidated. */
90
- clear(): void;
91
- /**
92
- * Equality lookup: return the set of record ids whose `field` matches
93
- * the given value. Returns `null` if no index covers the field — the
94
- * caller should fall back to a linear scan.
95
- *
96
- * The returned Set is a reference to the index's internal storage —
97
- * callers must NOT mutate it.
98
- */
99
- lookupEqual(field: string, value: unknown): ReadonlySet<string> | null;
100
- /**
101
- * Set lookup: return the union of record ids whose `field` matches any
102
- * of the given values. Returns `null` if no index covers the field.
103
- */
104
- lookupIn(field: string, values: readonly unknown[]): ReadonlySet<string> | null;
105
- }
106
-
107
- /**
108
- * Money-aware `where()` comparison (#336).
109
- *
110
- * Query clauses evaluate against RAW stored records — money decode
111
- * happens on output only (#322) — so a money field's stored form is a
112
- * scaled-integer digit string (`'1000000'`) while the caller naturally
113
- * writes the operand in major units (`10000`, `'10000.00'`). Without a
114
- * rewrite the comparison is silently wrong by the scale factor, and a
115
- * string-vs-number comparison is excluded by `isComparable` anyway.
116
- *
117
- * Two halves:
118
- *
119
- * - {@link moneyFieldClause} runs at QUERY BUILD time: it quantizes the
120
- * caller's major-unit operand into stored scaled-int space via the
121
- * same `parseToScaledInt` path as writes, so a malformed operand
122
- * throws at `.where()` — not silently filters everything out.
123
- * - {@link evaluateMoneyClause} runs per record and compares
124
- * `BigInt`-exact in scaled space (exact past 2^53, like the rest of
125
- * the money subsystem).
126
- *
127
- * Currency semantics (multi mode): an operand carries one currency —
128
- * explicit via `{ amount, currency }`, or the descriptor's sole allowed
129
- * currency for a bare amount. A record in a DIFFERENT currency has no
130
- * defined order against the operand: it matches `!=` and nothing else.
131
- */
132
-
133
- /** One quantized operand value: scaled digit string + its currency. */
134
- interface MoneyOperandEntry {
135
- readonly scaled: string;
136
- readonly currency: string;
137
- }
138
- /**
139
- * The money payload attached to a {@link FieldClause} over a declared
140
- * money field. `entries` holds one element for comparison ops, two for
141
- * `between` (lo, hi — same currency), N for `in`.
142
- */
143
- interface MoneyWhereOperand {
144
- readonly mode: 'fixed' | 'multi';
145
- readonly entries: ReadonlyArray<MoneyOperandEntry>;
146
- }
147
-
148
- /**
149
- * Operator implementations for the query DSL.
150
- *
151
- * All predicates run client-side, AFTER decryption — they never see ciphertext.
152
- * The only dependency is the money clause evaluator (#336) — still
153
- * tree-shakeable through it.
154
- */
155
-
156
- /** Comparison operators supported by the where() builder. */
157
- type Operator = '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'contains' | 'startsWith' | 'between';
158
- /**
159
- * A single field comparison clause inside a query plan.
160
- * Plans are JSON-serializable, so this type uses primitives only.
161
- */
162
- interface FieldClause {
163
- readonly type: 'field';
164
- readonly field: string;
165
- readonly op: Operator;
166
- readonly value: unknown;
167
- /**
168
- * Present when `field` is a declared money field (#336): the operand
169
- * quantized into stored scaled-int space at query BUILD time, so the
170
- * per-record comparison is BigInt-exact against the raw stored value.
171
- * Built by `moneyFieldClause` — `Query.where()` attaches it when the
172
- * source declares the field in `moneyFields`.
173
- */
174
- readonly money?: MoneyWhereOperand;
175
- }
176
- /**
177
- * A user-supplied predicate function escape hatch. Not serializable.
178
- *
179
- * The predicate accepts `unknown` at the type level so the surrounding
180
- * Clause type can stay non-parametric — this keeps Collection<T> covariant
181
- * in T at the public API surface. Builder methods cast user predicates
182
- * (typed `(record: T) => boolean`) into this shape on the way in.
183
- */
184
- interface FilterClause {
185
- readonly type: 'filter';
186
- readonly fn: (record: unknown) => boolean;
187
- }
188
- /**
189
- * A declared deterministic predicate reference. The query
190
- * builder produces this via `.wherePredicate(name, ctx?)` when a
191
- * Query has been augmented with a predicates map (typically by the
192
- * materialized-view registry — see MV v2 spec § Function-based
193
- * source-row predicates).
194
- *
195
- * `predicateHash` is the consumer-supplied stable hash for the
196
- * function body; `ctxHash` is the canonical-JSON SHA-256 of `ctx`.
197
- * Both fold into the MV's `queryHash` so a function or ctx change
198
- * forces refresh on next visit.
199
- *
200
- * `fn` is resolved at builder time from the predicates map and
201
- * embedded directly — so `evaluateClause` can fire it without a
202
- * runtime lookup.
203
- */
204
- interface WherePredicateClause {
205
- readonly type: 'wherePredicate';
206
- readonly name: string;
207
- readonly ctx: unknown;
208
- readonly predicateHash: string;
209
- readonly ctxHash: string;
210
- readonly fn: (record: unknown, ctx?: unknown) => boolean;
211
- }
212
- /** A logical group of clauses combined by AND or OR. */
213
- interface GroupClause {
214
- readonly type: 'group';
215
- readonly op: 'and' | 'or';
216
- readonly clauses: readonly Clause[];
217
- }
218
- /**
219
- * Cartesian-product expansion clause. Appended to `QueryPlan.clauses`
220
- * by `Query.crossJoin()`. Processed in declaration order by
221
- * `executeClausePipeline` — NOT by `evaluateClause` (which is a
222
- * per-record predicate and throws on this type).
223
- */
224
- interface CrossJoinClause {
225
- readonly type: 'crossJoin';
226
- /** Target collection name to cross-join against. */
227
- readonly target: string;
228
- /** Alias under which the right-side record is exposed on each result row. */
229
- readonly as: string;
230
- /**
231
- * Lateral filter callback. `undefined` → full cartesian product.
232
- * Two call shapes:
233
- * - Subset: `(left) => TTarget[]` — returns the right rows for this left row
234
- * - Predicate: `(left) => (right) => boolean` — executor materializes then filters
235
- */
236
- readonly on?: (left: unknown) => unknown[] | ((right: unknown) => boolean);
237
- /** When `on:` was supplied as `{ predicate: name }`, the name is stored here for queryHash. */
238
- readonly onPredicateName?: string;
239
- /** Per-clause row ceiling override. `undefined` → `DEFAULT_CROSS_JOIN_MAX_ROWS`. */
240
- readonly maxRows?: number;
241
- }
242
- type Clause = FieldClause | FilterClause | WherePredicateClause | GroupClause | CrossJoinClause;
243
- /**
244
- * Read a possibly nested field path like "address.city" from a record.
245
- * Returns undefined if any segment is missing.
246
- */
247
- declare function readPath(record: unknown, path: string): unknown;
248
- /**
249
- * Evaluate a single field clause against a record.
250
- * Returns false on type mismatches rather than throwing — query results
251
- * exclude non-matching records by definition.
252
- */
253
- declare function evaluateFieldClause(record: unknown, clause: FieldClause): boolean;
254
- /**
255
- * Evaluate any clause (field / filter / group) against a record.
256
- * The recursion depth is bounded by the user's query expression — no risk of
257
- * blowing the stack on a 50K-record collection.
258
- *
259
- * `fnRecord`, when provided, is the view handed to USER CALLBACK clauses
260
- * (`filter` / `wherePredicate`) instead of `record` — the executor passes
261
- * the money-decoded view there (#335) so user code never sees the stored
262
- * scaled-int form, while field clauses keep evaluating against the raw
263
- * record (their money operands are pre-quantized to that space, #336).
264
- */
265
- declare function evaluateClause(record: unknown, clause: Clause, fnRecord?: unknown): boolean;
266
-
267
- export { CollectionIndexes as C, type FieldClause as F, type GroupClause as G, type HashIndex as H, type IndexDef as I, type Operator as O, type Clause as a, type FilterClause as b, evaluateFieldClause as c, type CrossJoinClause as d, evaluateClause as e, readPath as r };