@noy-db/hub 0.4.0-pre.3 → 0.4.0-pre.4

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 (31) hide show
  1. package/dist/cargo/index.js +2 -2
  2. package/dist/{chunk-GU5AYA2Q.js → chunk-4X6DJZHY.js} +2 -2
  3. package/dist/{chunk-N4A3DCBT.js → chunk-5KI3REO3.js} +2 -2
  4. package/dist/{chunk-OWLPX2GI.js → chunk-BLB7P7LS.js} +2 -2
  5. package/dist/{chunk-J6U4BOKP.js → chunk-JW3XCZA2.js} +9 -9
  6. package/dist/{chunk-UBF7HTOR.js → chunk-QUIG6BZT.js} +15 -15
  7. package/dist/{chunk-UBF7HTOR.js.map → chunk-QUIG6BZT.js.map} +1 -1
  8. package/dist/{chunk-SN75YVM5.js → chunk-U73LHVPF.js} +15 -15
  9. package/dist/{chunk-SN75YVM5.js.map → chunk-U73LHVPF.js.map} +1 -1
  10. package/dist/{chunk-LUH2MPEF.js → chunk-W7TCXZWU.js} +423 -467
  11. package/dist/chunk-W7TCXZWU.js.map +1 -0
  12. package/dist/{collection-facade-ENLTJZBT.js → collection-facade-CMZGQ6IS.js} +2 -2
  13. package/dist/index.js +7 -7
  14. package/dist/kernel/collection-config.d.ts +11 -69
  15. package/dist/kernel/collection.d.ts +10 -21
  16. package/dist/kernel/noydb.d.ts +11 -12
  17. package/dist/kernel/vault.d.ts +21 -68
  18. package/dist/{noydb-KUX2TJMX.js → noydb-N5IW6OFZ.js} +7 -7
  19. package/dist/port/with/archive-strategy.d.ts +31 -0
  20. package/dist/port/with/strategies.d.ts +134 -0
  21. package/dist/query/index.js +1 -1
  22. package/dist/team/index.js +1 -1
  23. package/dist/tiers/index.js +1 -1
  24. package/package.json +3 -3
  25. package/dist/chunk-LUH2MPEF.js.map +0 -1
  26. /package/dist/{chunk-GU5AYA2Q.js.map → chunk-4X6DJZHY.js.map} +0 -0
  27. /package/dist/{chunk-N4A3DCBT.js.map → chunk-5KI3REO3.js.map} +0 -0
  28. /package/dist/{chunk-OWLPX2GI.js.map → chunk-BLB7P7LS.js.map} +0 -0
  29. /package/dist/{chunk-J6U4BOKP.js.map → chunk-JW3XCZA2.js.map} +0 -0
  30. /package/dist/{collection-facade-ENLTJZBT.js.map → collection-facade-CMZGQ6IS.js.map} +0 -0
  31. /package/dist/{noydb-KUX2TJMX.js.map → noydb-N5IW6OFZ.js.map} +0 -0
@@ -0,0 +1,134 @@
1
+ /**
2
+ * The strategy bag (#838) — one resolved, immutable record of every opt-in
3
+ * service, built once in `createNoydb` and carried by reference down the
4
+ * spine: `Noydb` → `Vault` → `Collection`.
5
+ *
6
+ * ## Why this exists
7
+ *
8
+ * Threading one service through the spine used to cost ~10 mechanical edits
9
+ * with no logic in any of them: a field on `NoydbOptions`, a conditional
10
+ * spread at the `new Vault(` site, a field declaration + constructor
11
+ * parameter + constructor assignment on `Vault`, a forwarding spread into
12
+ * the collection options, a field + `?? NO_*` default in
13
+ * `collection-config.ts`, and a field + assignment on `Collection`. Nothing
14
+ * checked that a new service reached every layer, which is exactly how #834
15
+ * happened — one of three copies of the Vault option block had silently
16
+ * dropped six strategies, and a vault reached that way threw
17
+ * `*NotEnabledError` for services the caller had actually configured.
18
+ *
19
+ * Here the layers hold ONE field. Adding a service is a row in
20
+ * {@link StrategyBag} plus a row in {@link STRATEGY_DEFAULTS} — both in this
21
+ * file, and omitting either is a compile error rather than a bug that only
22
+ * shows up through one construction path.
23
+ *
24
+ * ## Every key always resolves
25
+ *
26
+ * There is no `undefined` in the bag. An un-opted-in service resolves to its
27
+ * `NO_*` stub, which is the tree-shake seam: the stubs are deliberately tiny
28
+ * modules on the `/with` port that the spine may import statically, while the
29
+ * real implementation arrives only when the consumer imports the service's
30
+ * subpath. Holding a stub costs a few hundred bytes; it does not pull the
31
+ * machinery in.
32
+ *
33
+ * Two services needed adjusting to fit that rule, both recorded here because
34
+ * the reasons are not obvious:
35
+ *
36
+ * - `archive` had no stub at all and was held as `ArchiveStrategy |
37
+ * undefined` behind a hand-rolled null gate. {@link NO_ARCHIVE} now stands
38
+ * in and throws on `.store` access — see `port/with/archive-strategy.ts`.
39
+ * - `lazy`'s floor is {@link IMPLICIT_LAZY}, not a no-op: an un-opted-in
40
+ * collection still gets a working LRU, it just warns. So its default row
41
+ * is a real strategy, which is why this table maps keys to defaults rather
42
+ * than assuming a `NO_*` naming convention.
43
+ *
44
+ * `coordinationStrategy` is deliberately NOT in the bag. It is a
45
+ * `CoordinationProvider`, not a service strategy — it has no `with*()`
46
+ * factory, no `NO_*` stub, and is resolved asynchronously from the store
47
+ * (`createDefaultCoordinationProvider`) rather than passed through. The
48
+ * completeness assertion at the bottom of this file excludes it by name so
49
+ * that the exclusion is explicit and survives future edits.
50
+ *
51
+ * @internal
52
+ */
53
+ import type { NoydbOptions } from '../../kernel/types.js';
54
+ import { type AggregateStrategy } from '../../with-lookup/aggregate/strategy.js';
55
+ import { type AttestationStrategy } from '../../with-audit/attestation/strategy.js';
56
+ import { type BlobStrategy } from './blob-strategy.js';
57
+ import { type BrokerStrategy } from './broker-strategy.js';
58
+ import { type CargoStrategy } from '../../with-cargo/strategy.js';
59
+ import { type ClassifiedStrategy } from './classified-strategy.js';
60
+ import { type ConsentStrategy } from '../../with-audit/consent/strategy.js';
61
+ import { type CrdtStrategy } from '../../with-commit/crdt/strategy.js';
62
+ import { type CustodyStrategy } from '../../with-party/custody/strategy.js';
63
+ import { type ForgetStrategy } from '../../with-audit/forget/strategy.js';
64
+ import { type HistoryStrategy } from '../../with-commit/history/strategy.js';
65
+ import { type I18nStrategy } from './i18n-strategy.js';
66
+ import { type IndexStrategy } from '../../with-lookup/indexing/strategy.js';
67
+ import { type PeriodsStrategy } from '../../with-audit/periods/strategy.js';
68
+ import { type PortabilityStrategy } from '../../with-audit/portability/strategy.js';
69
+ import { type SealedRecordStrategy } from '../../with-audit/sealed-record/strategy.js';
70
+ import { type SearchStrategy } from '../../with-lookup/search/strategy.js';
71
+ import { type SequenceStrategy } from '../../with-commit/sequence/strategy.js';
72
+ import { type SessionStrategy } from '../../with-party/session/strategy.js';
73
+ import { type ShadowStrategy } from '../../with-fork/shadow/strategy.js';
74
+ import { type SnapshotStrategy } from '../../with-fork/snapshots/strategy.js';
75
+ import { type SyncStrategy } from '../../with-party/team/sync-strategy.js';
76
+ import { type TeamStrategy } from './team-strategy.js';
77
+ import { type TiersStrategy } from '../../with-audit/tiers/strategy.js';
78
+ import { type TxStrategy } from '../../with-commit/tx/strategy.js';
79
+ import { type LazyStrategy } from './lazy-strategy.js';
80
+ import type { ArchiveStrategy } from '../../with-fork/archive/index.js';
81
+ /**
82
+ * Every opt-in service, resolved. One field per service, never `undefined`.
83
+ *
84
+ * Keys drop the `Strategy` suffix the `createNoydb` option carries, so
85
+ * `searchStrategy: withSearch()` reads back as `strategies.search`. The
86
+ * completeness assertion below pins that correspondence.
87
+ */
88
+ export interface StrategyBag {
89
+ readonly aggregate: AggregateStrategy;
90
+ readonly archive: ArchiveStrategy;
91
+ readonly attestation: AttestationStrategy;
92
+ readonly blob: BlobStrategy;
93
+ readonly broker: BrokerStrategy;
94
+ readonly cargo: CargoStrategy;
95
+ readonly classified: ClassifiedStrategy;
96
+ readonly consent: ConsentStrategy;
97
+ readonly crdt: CrdtStrategy;
98
+ readonly custody: CustodyStrategy;
99
+ readonly forget: ForgetStrategy;
100
+ readonly history: HistoryStrategy;
101
+ readonly i18n: I18nStrategy;
102
+ readonly index: IndexStrategy;
103
+ readonly lazy: LazyStrategy;
104
+ readonly periods: PeriodsStrategy;
105
+ readonly portability: PortabilityStrategy;
106
+ readonly sealedRecord: SealedRecordStrategy;
107
+ readonly search: SearchStrategy;
108
+ readonly sequence: SequenceStrategy;
109
+ readonly session: SessionStrategy;
110
+ readonly shadow: ShadowStrategy;
111
+ readonly snapshot: SnapshotStrategy;
112
+ readonly sync: SyncStrategy;
113
+ readonly team: TeamStrategy;
114
+ readonly tiers: TiersStrategy;
115
+ readonly tx: TxStrategy;
116
+ }
117
+ /** The name of every service in the bag. */
118
+ export type StrategyKey = keyof StrategyBag;
119
+ /**
120
+ * The un-opted-in floor: what each service resolves to when the caller passed
121
+ * no `with*()` factory. Annotating this `StrategyBag` is what makes a missing
122
+ * row a compile error.
123
+ */
124
+ export declare const STRATEGY_DEFAULTS: StrategyBag;
125
+ /**
126
+ * Build the bag from user options. Called ONCE, in `createNoydb` — every
127
+ * layer below shares the resulting reference.
128
+ *
129
+ * The two casts are the price of mapping `blob` ↔ `blobStrategy` in a loop
130
+ * instead of writing 27 hand-copied lines; the correspondence they assume is
131
+ * proven at compile time by the assertion below, so a typo cannot survive a
132
+ * build.
133
+ */
134
+ export declare function resolveStrategies(options: NoydbOptions): StrategyBag;
@@ -4,7 +4,7 @@ import {
4
4
  ScanBuilder,
5
5
  buildLiveQuery,
6
6
  executePlan
7
- } from "../chunk-GU5AYA2Q.js";
7
+ } from "../chunk-4X6DJZHY.js";
8
8
  import {
9
9
  DEFAULT_JOIN_MAX_ROWS,
10
10
  applyJoins,
@@ -23,7 +23,7 @@ import {
23
23
  unwrapMagicLinkGrant,
24
24
  updateAuthenticator,
25
25
  writeMagicLinkGrant
26
- } from "../chunk-UBF7HTOR.js";
26
+ } from "../chunk-QUIG6BZT.js";
27
27
  import {
28
28
  SYNC_CREDENTIALS_COLLECTION,
29
29
  buildRecipientKeyringFile,
@@ -11,7 +11,7 @@ import {
11
11
  putAtTier,
12
12
  syncDerivedOutputs,
13
13
  withTiers
14
- } from "../chunk-N4A3DCBT.js";
14
+ } from "../chunk-5KI3REO3.js";
15
15
  import "../chunk-MSO2C3KG.js";
16
16
  import "../chunk-PEY6ZTCF.js";
17
17
  import "../chunk-QXPOEAKR.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noy-db/hub",
3
- "version": "0.4.0-pre.3",
3
+ "version": "0.4.0-pre.4",
4
4
  "description": "Zero-knowledge, offline-first, encrypted document store — core library with AES-256-GCM, PBKDF2, multi-user keyring, and sync engine",
5
5
  "license": "MIT",
6
6
  "author": "vLannaAi <vicio@lanna.ai>",
@@ -192,14 +192,14 @@
192
192
  "node": ">=22.0.0"
193
193
  },
194
194
  "dependencies": {
195
- "@noy-db/attestation": "0.4.0-pre.3"
195
+ "@noy-db/attestation": "0.4.0-pre.4"
196
196
  },
197
197
  "devDependencies": {
198
198
  "@types/node": "^22.0.0",
199
199
  "esbuild": "^0.25.0",
200
200
  "zod": "^4.0.0",
201
201
  "zod-to-json-schema": "^3.25.2",
202
- "@noy-db/on-shamir": "0.4.0-pre.3"
202
+ "@noy-db/on-shamir": "0.4.0-pre.4"
203
203
  },
204
204
  "peerDependencies": {
205
205
  "zod-to-json-schema": "^3.25.0"