@noy-db/hub 0.1.0-pre.10

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 (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -0
  3. package/dist/aggregate/index.cjs +476 -0
  4. package/dist/aggregate/index.cjs.map +1 -0
  5. package/dist/aggregate/index.d.cts +38 -0
  6. package/dist/aggregate/index.d.ts +38 -0
  7. package/dist/aggregate/index.js +53 -0
  8. package/dist/aggregate/index.js.map +1 -0
  9. package/dist/blobs/index.cjs +1480 -0
  10. package/dist/blobs/index.cjs.map +1 -0
  11. package/dist/blobs/index.d.cts +45 -0
  12. package/dist/blobs/index.d.ts +45 -0
  13. package/dist/blobs/index.js +48 -0
  14. package/dist/blobs/index.js.map +1 -0
  15. package/dist/bundle/index.cjs +496 -0
  16. package/dist/bundle/index.cjs.map +1 -0
  17. package/dist/bundle/index.d.cts +7 -0
  18. package/dist/bundle/index.d.ts +7 -0
  19. package/dist/bundle/index.js +51 -0
  20. package/dist/bundle/index.js.map +1 -0
  21. package/dist/chunk-2QR2PQTT.js +217 -0
  22. package/dist/chunk-2QR2PQTT.js.map +1 -0
  23. package/dist/chunk-72UIIX3E.js +1109 -0
  24. package/dist/chunk-72UIIX3E.js.map +1 -0
  25. package/dist/chunk-A4NFZKRW.js +722 -0
  26. package/dist/chunk-A4NFZKRW.js.map +1 -0
  27. package/dist/chunk-AOYCZP2H.js +793 -0
  28. package/dist/chunk-AOYCZP2H.js.map +1 -0
  29. package/dist/chunk-CIMZBAZB.js +72 -0
  30. package/dist/chunk-CIMZBAZB.js.map +1 -0
  31. package/dist/chunk-E3AGCGJ4.js +160 -0
  32. package/dist/chunk-E3AGCGJ4.js.map +1 -0
  33. package/dist/chunk-EKX3YVCI.js +97 -0
  34. package/dist/chunk-EKX3YVCI.js.map +1 -0
  35. package/dist/chunk-EMIGCR7X.js +39 -0
  36. package/dist/chunk-EMIGCR7X.js.map +1 -0
  37. package/dist/chunk-EMMRIE3C.js +72 -0
  38. package/dist/chunk-EMMRIE3C.js.map +1 -0
  39. package/dist/chunk-EUNIORPU.js +680 -0
  40. package/dist/chunk-EUNIORPU.js.map +1 -0
  41. package/dist/chunk-FZU343FL.js +32 -0
  42. package/dist/chunk-FZU343FL.js.map +1 -0
  43. package/dist/chunk-GHGXG53C.js +795 -0
  44. package/dist/chunk-GHGXG53C.js.map +1 -0
  45. package/dist/chunk-GKA4BGJN.js +79 -0
  46. package/dist/chunk-GKA4BGJN.js.map +1 -0
  47. package/dist/chunk-HG2OWBLX.js +430 -0
  48. package/dist/chunk-HG2OWBLX.js.map +1 -0
  49. package/dist/chunk-IGAROPKM.js +34 -0
  50. package/dist/chunk-IGAROPKM.js.map +1 -0
  51. package/dist/chunk-J66GRPNH.js +111 -0
  52. package/dist/chunk-J66GRPNH.js.map +1 -0
  53. package/dist/chunk-LVMMDXFT.js +275 -0
  54. package/dist/chunk-LVMMDXFT.js.map +1 -0
  55. package/dist/chunk-M5INGEFC.js +84 -0
  56. package/dist/chunk-M5INGEFC.js.map +1 -0
  57. package/dist/chunk-NBYQNDXA.js +557 -0
  58. package/dist/chunk-NBYQNDXA.js.map +1 -0
  59. package/dist/chunk-NPC4LFV5.js +132 -0
  60. package/dist/chunk-NPC4LFV5.js.map +1 -0
  61. package/dist/chunk-NSWHB5VQ.js +1285 -0
  62. package/dist/chunk-NSWHB5VQ.js.map +1 -0
  63. package/dist/chunk-OLM4LA6K.js +392 -0
  64. package/dist/chunk-OLM4LA6K.js.map +1 -0
  65. package/dist/chunk-UAFBZWFB.js +155 -0
  66. package/dist/chunk-UAFBZWFB.js.map +1 -0
  67. package/dist/chunk-UF3BUNQZ.js +1 -0
  68. package/dist/chunk-UF3BUNQZ.js.map +1 -0
  69. package/dist/chunk-UMMAVAYW.js +17 -0
  70. package/dist/chunk-UMMAVAYW.js.map +1 -0
  71. package/dist/chunk-UPY7WLBH.js +381 -0
  72. package/dist/chunk-UPY7WLBH.js.map +1 -0
  73. package/dist/chunk-W63BWEJH.js +311 -0
  74. package/dist/chunk-W63BWEJH.js.map +1 -0
  75. package/dist/chunk-WIGI5OJK.js +90 -0
  76. package/dist/chunk-WIGI5OJK.js.map +1 -0
  77. package/dist/chunk-XNL2TKKR.js +490 -0
  78. package/dist/chunk-XNL2TKKR.js.map +1 -0
  79. package/dist/chunk-XWNUJPIS.js +367 -0
  80. package/dist/chunk-XWNUJPIS.js.map +1 -0
  81. package/dist/chunk-YWKJZZGV.js +715 -0
  82. package/dist/chunk-YWKJZZGV.js.map +1 -0
  83. package/dist/consent/index.cjs +204 -0
  84. package/dist/consent/index.cjs.map +1 -0
  85. package/dist/consent/index.d.cts +24 -0
  86. package/dist/consent/index.d.ts +24 -0
  87. package/dist/consent/index.js +23 -0
  88. package/dist/consent/index.js.map +1 -0
  89. package/dist/crdt/index.cjs +152 -0
  90. package/dist/crdt/index.cjs.map +1 -0
  91. package/dist/crdt/index.d.cts +30 -0
  92. package/dist/crdt/index.d.ts +30 -0
  93. package/dist/crdt/index.js +24 -0
  94. package/dist/crdt/index.js.map +1 -0
  95. package/dist/crypto-6PNIHP7W.js +44 -0
  96. package/dist/crypto-6PNIHP7W.js.map +1 -0
  97. package/dist/delegation-WVIVMF73.js +17 -0
  98. package/dist/delegation-WVIVMF73.js.map +1 -0
  99. package/dist/dev-unlock-D4xB0_gs.d.cts +263 -0
  100. package/dist/dev-unlock-Dz8GEbd3.d.ts +263 -0
  101. package/dist/hash--EflSV65.d.cts +63 -0
  102. package/dist/hash-CRdXYnv3.d.ts +63 -0
  103. package/dist/history/index.cjs +1215 -0
  104. package/dist/history/index.cjs.map +1 -0
  105. package/dist/history/index.d.cts +62 -0
  106. package/dist/history/index.d.ts +62 -0
  107. package/dist/history/index.js +79 -0
  108. package/dist/history/index.js.map +1 -0
  109. package/dist/i18n/index.cjs +840 -0
  110. package/dist/i18n/index.cjs.map +1 -0
  111. package/dist/i18n/index.d.cts +38 -0
  112. package/dist/i18n/index.d.ts +38 -0
  113. package/dist/i18n/index.js +68 -0
  114. package/dist/i18n/index.js.map +1 -0
  115. package/dist/index-CD1VnONm.d.cts +415 -0
  116. package/dist/index-CLRxPs-W.d.cts +1960 -0
  117. package/dist/index-CUi9wfss.d.ts +415 -0
  118. package/dist/index-DtV93TMP.d.ts +1960 -0
  119. package/dist/index.cjs +17387 -0
  120. package/dist/index.cjs.map +1 -0
  121. package/dist/index.d.cts +565 -0
  122. package/dist/index.d.ts +565 -0
  123. package/dist/index.js +7525 -0
  124. package/dist/index.js.map +1 -0
  125. package/dist/indexing/index.cjs +736 -0
  126. package/dist/indexing/index.cjs.map +1 -0
  127. package/dist/indexing/index.d.cts +36 -0
  128. package/dist/indexing/index.d.ts +36 -0
  129. package/dist/indexing/index.js +77 -0
  130. package/dist/indexing/index.js.map +1 -0
  131. package/dist/lazy-builder-BwEoBQZ9.d.ts +304 -0
  132. package/dist/lazy-builder-CZVLKh0Z.d.cts +304 -0
  133. package/dist/ledger-HBBH2NPZ.js +33 -0
  134. package/dist/ledger-HBBH2NPZ.js.map +1 -0
  135. package/dist/mime-magic-CBBSOkjm.d.cts +50 -0
  136. package/dist/mime-magic-CBBSOkjm.d.ts +50 -0
  137. package/dist/periods/index.cjs +1035 -0
  138. package/dist/periods/index.cjs.map +1 -0
  139. package/dist/periods/index.d.cts +21 -0
  140. package/dist/periods/index.d.ts +21 -0
  141. package/dist/periods/index.js +25 -0
  142. package/dist/periods/index.js.map +1 -0
  143. package/dist/predicate-SBHmi6D0.d.cts +161 -0
  144. package/dist/predicate-SBHmi6D0.d.ts +161 -0
  145. package/dist/public-envelope-TLQA6REO.js +31 -0
  146. package/dist/public-envelope-TLQA6REO.js.map +1 -0
  147. package/dist/query/index.cjs +1999 -0
  148. package/dist/query/index.cjs.map +1 -0
  149. package/dist/query/index.d.cts +3 -0
  150. package/dist/query/index.d.ts +3 -0
  151. package/dist/query/index.js +73 -0
  152. package/dist/query/index.js.map +1 -0
  153. package/dist/session/index.cjs +495 -0
  154. package/dist/session/index.cjs.map +1 -0
  155. package/dist/session/index.d.cts +45 -0
  156. package/dist/session/index.d.ts +45 -0
  157. package/dist/session/index.js +51 -0
  158. package/dist/session/index.js.map +1 -0
  159. package/dist/shadow/index.cjs +133 -0
  160. package/dist/shadow/index.cjs.map +1 -0
  161. package/dist/shadow/index.d.cts +16 -0
  162. package/dist/shadow/index.d.ts +16 -0
  163. package/dist/shadow/index.js +20 -0
  164. package/dist/shadow/index.js.map +1 -0
  165. package/dist/store/index.cjs +1083 -0
  166. package/dist/store/index.cjs.map +1 -0
  167. package/dist/store/index.d.cts +491 -0
  168. package/dist/store/index.d.ts +491 -0
  169. package/dist/store/index.js +37 -0
  170. package/dist/store/index.js.map +1 -0
  171. package/dist/strategy-BSxFXGzb.d.cts +110 -0
  172. package/dist/strategy-BSxFXGzb.d.ts +110 -0
  173. package/dist/strategy-D-SrOLCl.d.cts +548 -0
  174. package/dist/strategy-D-SrOLCl.d.ts +548 -0
  175. package/dist/sync/index.cjs +1062 -0
  176. package/dist/sync/index.cjs.map +1 -0
  177. package/dist/sync/index.d.cts +42 -0
  178. package/dist/sync/index.d.ts +42 -0
  179. package/dist/sync/index.js +28 -0
  180. package/dist/sync/index.js.map +1 -0
  181. package/dist/team/index.cjs +2606 -0
  182. package/dist/team/index.cjs.map +1 -0
  183. package/dist/team/index.d.cts +117 -0
  184. package/dist/team/index.d.ts +117 -0
  185. package/dist/team/index.js +106 -0
  186. package/dist/team/index.js.map +1 -0
  187. package/dist/tx/index.cjs +212 -0
  188. package/dist/tx/index.cjs.map +1 -0
  189. package/dist/tx/index.d.cts +20 -0
  190. package/dist/tx/index.d.ts +20 -0
  191. package/dist/tx/index.js +20 -0
  192. package/dist/tx/index.js.map +1 -0
  193. package/dist/types-DSFLtbKg.d.ts +9702 -0
  194. package/dist/types-zwwMOqkg.d.cts +9702 -0
  195. package/dist/ulid-COREQ2RQ.js +9 -0
  196. package/dist/ulid-COREQ2RQ.js.map +1 -0
  197. package/dist/util/index.cjs +230 -0
  198. package/dist/util/index.cjs.map +1 -0
  199. package/dist/util/index.d.cts +77 -0
  200. package/dist/util/index.d.ts +77 -0
  201. package/dist/util/index.js +190 -0
  202. package/dist/util/index.js.map +1 -0
  203. package/package.json +244 -0
@@ -0,0 +1,557 @@
1
+ // src/errors.ts
2
+ var NoydbError = class extends Error {
3
+ /** Machine-readable error code. Stable across library versions. */
4
+ code;
5
+ constructor(code, message) {
6
+ super(message);
7
+ this.name = "NoydbError";
8
+ this.code = code;
9
+ }
10
+ };
11
+ var DecryptionError = class extends NoydbError {
12
+ constructor(message = "Decryption failed") {
13
+ super("DECRYPTION_FAILED", message);
14
+ this.name = "DecryptionError";
15
+ }
16
+ };
17
+ var TamperedError = class extends NoydbError {
18
+ constructor(message = "Data integrity check failed \u2014 record may have been tampered with") {
19
+ super("TAMPERED", message);
20
+ this.name = "TamperedError";
21
+ }
22
+ };
23
+ var InvalidKeyError = class extends NoydbError {
24
+ constructor(message = "Invalid key \u2014 wrong passphrase or corrupted keyring") {
25
+ super("INVALID_KEY", message);
26
+ this.name = "InvalidKeyError";
27
+ }
28
+ };
29
+ var KeyringCorruptError = class extends NoydbError {
30
+ failedCollections;
31
+ intactCount;
32
+ constructor(opts) {
33
+ super(
34
+ "KEYRING_CORRUPT",
35
+ opts.message ?? `Keyring has ${opts.failedCollections.length} corrupted wrapped DEK(s) (${opts.failedCollections.join(", ")}); ${opts.intactCount} other DEK(s) unwrapped successfully \u2014 the passphrase is correct, the entries are damaged. Do NOT use onInvalidKey: 'reset' here \u2014 that would destroy the intact DEKs.`
36
+ );
37
+ this.name = "KeyringCorruptError";
38
+ this.failedCollections = opts.failedCollections;
39
+ this.intactCount = opts.intactCount;
40
+ }
41
+ };
42
+ var NoAccessError = class extends NoydbError {
43
+ constructor(message = "No access \u2014 user does not have a key for this collection") {
44
+ super("NO_ACCESS", message);
45
+ this.name = "NoAccessError";
46
+ }
47
+ };
48
+ var ReadOnlyError = class extends NoydbError {
49
+ constructor(message = "Read-only \u2014 user has ro permission on this collection") {
50
+ super("READ_ONLY", message);
51
+ this.name = "ReadOnlyError";
52
+ }
53
+ };
54
+ var ReadOnlyAtInstantError = class extends NoydbError {
55
+ constructor(operation, timestamp) {
56
+ super(
57
+ "READ_ONLY_AT_INSTANT",
58
+ `Cannot ${operation}() on a vault view anchored at ${timestamp} \u2014 time-machine views are read-only`
59
+ );
60
+ this.name = "ReadOnlyAtInstantError";
61
+ }
62
+ };
63
+ var ReadOnlyFrameError = class extends NoydbError {
64
+ constructor(operation) {
65
+ super(
66
+ "READ_ONLY_FRAME",
67
+ `Cannot ${operation}() on a vault frame \u2014 frames are read-only presentations of the current vault`
68
+ );
69
+ this.name = "ReadOnlyFrameError";
70
+ }
71
+ };
72
+ var PermissionDeniedError = class extends NoydbError {
73
+ constructor(message = "Permission denied \u2014 insufficient role for this operation") {
74
+ super("PERMISSION_DENIED", message);
75
+ this.name = "PermissionDeniedError";
76
+ }
77
+ };
78
+ var ExportCapabilityError = class extends NoydbError {
79
+ tier;
80
+ format;
81
+ userId;
82
+ constructor(opts) {
83
+ const msg = opts.message ?? (opts.tier === "plaintext" ? `Export capability denied \u2014 keyring "${opts.userId}" is not granted plaintext-export capability for format "${opts.format ?? "<unknown>"}". Ask a vault owner or admin to grant it via vault.grant({ exportCapability: { plaintext: ['${opts.format ?? "<format>"}'] } }).` : `Export capability denied \u2014 keyring "${opts.userId}" is not granted encrypted-bundle export capability. Ask a vault owner or admin to grant it via vault.grant({ exportCapability: { bundle: true } }).`);
84
+ super("EXPORT_CAPABILITY", msg);
85
+ this.name = "ExportCapabilityError";
86
+ this.tier = opts.tier;
87
+ this.userId = opts.userId;
88
+ if (opts.format !== void 0) this.format = opts.format;
89
+ }
90
+ };
91
+ var KeyringExpiredError = class extends NoydbError {
92
+ userId;
93
+ expiresAt;
94
+ constructor(opts) {
95
+ super(
96
+ "KEYRING_EXPIRED",
97
+ `Keyring "${opts.userId}" expired at ${opts.expiresAt}. The slot refuses to unlock past its expiry timestamp.`
98
+ );
99
+ this.name = "KeyringExpiredError";
100
+ this.userId = opts.userId;
101
+ this.expiresAt = opts.expiresAt;
102
+ }
103
+ };
104
+ var ImportCapabilityError = class extends NoydbError {
105
+ tier;
106
+ format;
107
+ userId;
108
+ constructor(opts) {
109
+ const msg = opts.message ?? (opts.tier === "plaintext" ? `Import capability denied \u2014 keyring "${opts.userId}" is not granted plaintext-import capability for format "${opts.format ?? "<unknown>"}". Ask a vault owner or admin to grant it via vault.grant({ importCapability: { plaintext: ['${opts.format ?? "<format>"}'] } }).` : `Import capability denied \u2014 keyring "${opts.userId}" is not granted encrypted-bundle import capability. Ask a vault owner or admin to grant it via vault.grant({ importCapability: { bundle: true } }).`);
110
+ super("IMPORT_CAPABILITY", msg);
111
+ this.name = "ImportCapabilityError";
112
+ this.tier = opts.tier;
113
+ this.userId = opts.userId;
114
+ if (opts.format !== void 0) this.format = opts.format;
115
+ }
116
+ };
117
+ var StoreCapabilityError = class extends NoydbError {
118
+ /** The store method/capability that was missing. */
119
+ capability;
120
+ constructor(capability, callerApi, storeName) {
121
+ super(
122
+ "STORE_CAPABILITY",
123
+ `${callerApi} requires the optional store capability "${capability}" but the active store${storeName ? ` (${storeName})` : ""} does not implement it. Use a store that supports "${capability}" (store-memory, store-file) or pass an explicit vault list to bypass enumeration.`
124
+ );
125
+ this.name = "StoreCapabilityError";
126
+ this.capability = capability;
127
+ }
128
+ };
129
+ var PrivilegeEscalationError = class extends NoydbError {
130
+ offendingCollection;
131
+ constructor(offendingCollection, message) {
132
+ super(
133
+ "PRIVILEGE_ESCALATION",
134
+ message ?? `Privilege escalation: grantor has no DEK for collection "${offendingCollection}" and cannot grant access to it.`
135
+ );
136
+ this.name = "PrivilegeEscalationError";
137
+ this.offendingCollection = offendingCollection;
138
+ }
139
+ };
140
+ var PeriodClosedError = class extends NoydbError {
141
+ periodName;
142
+ endDate;
143
+ recordTs;
144
+ constructor(periodName, endDate, recordTs) {
145
+ super(
146
+ "PERIOD_CLOSED",
147
+ `Cannot modify record (last written ${recordTs}) \u2014 sealed by closed period "${periodName}" (endDate: ${endDate}). Post a compensating entry in a new period instead.`
148
+ );
149
+ this.name = "PeriodClosedError";
150
+ this.periodName = periodName;
151
+ this.endDate = endDate;
152
+ this.recordTs = recordTs;
153
+ }
154
+ };
155
+ var TierNotGrantedError = class extends NoydbError {
156
+ tier;
157
+ collection;
158
+ constructor(collection, tier) {
159
+ super(
160
+ "TIER_NOT_GRANTED",
161
+ `User has no DEK for tier ${tier} in collection "${collection}"`
162
+ );
163
+ this.name = "TierNotGrantedError";
164
+ this.collection = collection;
165
+ this.tier = tier;
166
+ }
167
+ };
168
+ var ElevationExpiredError = class extends NoydbError {
169
+ tier;
170
+ expiresAt;
171
+ constructor(opts) {
172
+ super(
173
+ "ELEVATION_EXPIRED",
174
+ `Elevation to tier ${opts.tier} expired at ${new Date(opts.expiresAt).toISOString()}`
175
+ );
176
+ this.name = "ElevationExpiredError";
177
+ this.tier = opts.tier;
178
+ this.expiresAt = opts.expiresAt;
179
+ }
180
+ };
181
+ var AlreadyElevatedError = class extends NoydbError {
182
+ activeTier;
183
+ constructor(activeTier) {
184
+ super(
185
+ "ALREADY_ELEVATED",
186
+ `Vault is already elevated to tier ${activeTier}; release the existing handle first`
187
+ );
188
+ this.name = "AlreadyElevatedError";
189
+ this.activeTier = activeTier;
190
+ }
191
+ };
192
+ var TierDemoteDeniedError = class extends NoydbError {
193
+ constructor(id, tier) {
194
+ super(
195
+ "TIER_DEMOTE_DENIED",
196
+ `Only the original elevator or an owner can demote record "${id}" from tier ${tier}`
197
+ );
198
+ this.name = "TierDemoteDeniedError";
199
+ }
200
+ };
201
+ var DelegationTargetMissingError = class extends NoydbError {
202
+ toUser;
203
+ constructor(toUser) {
204
+ super(
205
+ "DELEGATION_TARGET_MISSING",
206
+ `Delegation target user "${toUser}" has no keyring in this vault`
207
+ );
208
+ this.name = "DelegationTargetMissingError";
209
+ this.toUser = toUser;
210
+ }
211
+ };
212
+ var ConflictError = class extends NoydbError {
213
+ /** The actual stored version at the time of conflict. */
214
+ version;
215
+ constructor(version, message = "Version conflict") {
216
+ super("CONFLICT", message);
217
+ this.name = "ConflictError";
218
+ this.version = version;
219
+ }
220
+ };
221
+ var LedgerContentionError = class extends NoydbError {
222
+ attempts;
223
+ constructor(attempts) {
224
+ super(
225
+ "LEDGER_CONTENTION",
226
+ `LedgerStore.append: failed to claim a chain slot after ${attempts} optimistic-CAS retries`
227
+ );
228
+ this.name = "LedgerContentionError";
229
+ this.attempts = attempts;
230
+ }
231
+ };
232
+ var BundleVersionConflictError = class extends NoydbError {
233
+ /** The bundle handle of the newer remote version that rejected the push. */
234
+ remoteVersion;
235
+ constructor(remoteVersion, message = "Bundle version conflict \u2014 remote has been updated") {
236
+ super("BUNDLE_VERSION_CONFLICT", message);
237
+ this.name = "BundleVersionConflictError";
238
+ this.remoteVersion = remoteVersion;
239
+ }
240
+ };
241
+ var NetworkError = class extends NoydbError {
242
+ constructor(message = "Network error") {
243
+ super("NETWORK_ERROR", message);
244
+ this.name = "NetworkError";
245
+ }
246
+ };
247
+ var NotFoundError = class extends NoydbError {
248
+ constructor(message = "Record not found") {
249
+ super("NOT_FOUND", message);
250
+ this.name = "NotFoundError";
251
+ }
252
+ };
253
+ var ValidationError = class extends NoydbError {
254
+ constructor(message = "Validation error") {
255
+ super("VALIDATION_ERROR", message);
256
+ this.name = "ValidationError";
257
+ }
258
+ };
259
+ var SchemaValidationError = class extends NoydbError {
260
+ issues;
261
+ direction;
262
+ constructor(message, issues, direction) {
263
+ super("SCHEMA_VALIDATION_FAILED", message);
264
+ this.name = "SchemaValidationError";
265
+ this.issues = issues;
266
+ this.direction = direction;
267
+ }
268
+ };
269
+ var GroupCardinalityError = class extends NoydbError {
270
+ /** The field being grouped on. */
271
+ field;
272
+ /** Observed number of distinct groups at the moment the cap tripped. */
273
+ cardinality;
274
+ /** The cap that was exceeded. */
275
+ maxGroups;
276
+ constructor(field, cardinality, maxGroups) {
277
+ super(
278
+ "GROUP_CARDINALITY",
279
+ `.groupBy("${field}") produced ${cardinality} distinct groups, exceeding the ${maxGroups}-group ceiling. This is almost always a query mistake \u2014 grouping on a high-uniqueness field like "id" or "createdAt" produces one bucket per record. Narrow the query with .where() before grouping, or group on a lower-cardinality field (status, category, clientId). If you genuinely need high-cardinality grouping, file an issue with your use case.`
280
+ );
281
+ this.name = "GroupCardinalityError";
282
+ this.field = field;
283
+ this.cardinality = cardinality;
284
+ this.maxGroups = maxGroups;
285
+ }
286
+ };
287
+ var IndexRequiredError = class extends NoydbError {
288
+ collection;
289
+ touchedFields;
290
+ missingFields;
291
+ constructor(args) {
292
+ super(
293
+ "INDEX_REQUIRED",
294
+ `Collection "${args.collection}": query references unindexed fields in lazy mode (missing: ${args.missingFields.join(", ")}). Declare an index on each field, or use collection.scan() for non-indexed iteration.`
295
+ );
296
+ this.name = "IndexRequiredError";
297
+ this.collection = args.collection;
298
+ this.touchedFields = [...args.touchedFields];
299
+ this.missingFields = [...args.missingFields];
300
+ }
301
+ };
302
+ var IndexWriteFailureError = class extends NoydbError {
303
+ recordId;
304
+ field;
305
+ op;
306
+ cause;
307
+ constructor(args) {
308
+ super(
309
+ "INDEX_WRITE_FAILURE",
310
+ `Index side-car ${args.op} failed for field "${args.field}" on record "${args.recordId}"`
311
+ );
312
+ this.name = "IndexWriteFailureError";
313
+ this.recordId = args.recordId;
314
+ this.field = args.field;
315
+ this.op = args.op;
316
+ this.cause = args.cause;
317
+ }
318
+ };
319
+ var BundleIntegrityError = class extends NoydbError {
320
+ constructor(message) {
321
+ super("BUNDLE_INTEGRITY", `.noydb bundle integrity check failed: ${message}`);
322
+ this.name = "BundleIntegrityError";
323
+ }
324
+ };
325
+ var ReservedCollectionNameError = class extends NoydbError {
326
+ /** The rejected collection name. */
327
+ collectionName;
328
+ constructor(collectionName) {
329
+ super(
330
+ "RESERVED_COLLECTION_NAME",
331
+ `"${collectionName}" is a reserved collection name. Use vault.dictionary("${collectionName.replace(/^_dict_/, "")}") to access dictionary collections.`
332
+ );
333
+ this.name = "ReservedCollectionNameError";
334
+ this.collectionName = collectionName;
335
+ }
336
+ };
337
+ var DictKeyMissingError = class extends NoydbError {
338
+ /** The dictionary name. */
339
+ dictionaryName;
340
+ /** The key that was not found. */
341
+ key;
342
+ constructor(dictionaryName, key) {
343
+ super(
344
+ "DICT_KEY_MISSING",
345
+ `Dictionary "${dictionaryName}" has no entry for key "${key}".`
346
+ );
347
+ this.name = "DictKeyMissingError";
348
+ this.dictionaryName = dictionaryName;
349
+ this.key = key;
350
+ }
351
+ };
352
+ var DictKeyInUseError = class extends NoydbError {
353
+ /** The dictionary name. */
354
+ dictionaryName;
355
+ /** The key that is still referenced. */
356
+ key;
357
+ /** Name of the first collection found to reference this key. */
358
+ usedBy;
359
+ /** Number of records in `usedBy` that reference this key. */
360
+ count;
361
+ constructor(dictionaryName, key, usedBy, count) {
362
+ super(
363
+ "DICT_KEY_IN_USE",
364
+ `Cannot delete key "${key}" from dictionary "${dictionaryName}": ${count} record(s) in "${usedBy}" still reference it. Use dictionary.rename("${key}", newKey) to rewrite references first.`
365
+ );
366
+ this.name = "DictKeyInUseError";
367
+ this.dictionaryName = dictionaryName;
368
+ this.key = key;
369
+ this.usedBy = usedBy;
370
+ this.count = count;
371
+ }
372
+ };
373
+ var MissingTranslationError = class extends NoydbError {
374
+ /** The field name whose translation(s) are missing. */
375
+ field;
376
+ /** Locale codes that were required but absent. */
377
+ missing;
378
+ constructor(field, missing, message) {
379
+ super(
380
+ "MISSING_TRANSLATION",
381
+ message ?? `Field "${field}": missing required translation(s): ${missing.join(", ")}.`
382
+ );
383
+ this.name = "MissingTranslationError";
384
+ this.field = field;
385
+ this.missing = missing;
386
+ }
387
+ };
388
+ var LocaleNotSpecifiedError = class extends NoydbError {
389
+ /** The field name that required a locale. */
390
+ field;
391
+ constructor(field, message) {
392
+ super(
393
+ "LOCALE_NOT_SPECIFIED",
394
+ message ?? `Cannot read i18nText field "${field}" without a locale. Pass { locale } to get()/list()/query() or set a default via openVault(name, { locale }).`
395
+ );
396
+ this.name = "LocaleNotSpecifiedError";
397
+ this.field = field;
398
+ }
399
+ };
400
+ var TranslatorNotConfiguredError = class extends NoydbError {
401
+ /** The field that requested auto-translation. */
402
+ field;
403
+ /** The collection the put was targeting. */
404
+ collection;
405
+ constructor(field, collection) {
406
+ super(
407
+ "TRANSLATOR_NOT_CONFIGURED",
408
+ `Field "${field}" in collection "${collection}" has autoTranslate: true, but no plaintextTranslator was configured on createNoydb(). Either configure a plaintextTranslator or remove autoTranslate from the schema.`
409
+ );
410
+ this.name = "TranslatorNotConfiguredError";
411
+ this.field = field;
412
+ this.collection = collection;
413
+ }
414
+ };
415
+ var BackupLedgerError = class extends NoydbError {
416
+ /** First-broken-entry index, if known. */
417
+ divergedAt;
418
+ constructor(message, divergedAt) {
419
+ super("BACKUP_LEDGER", message);
420
+ this.name = "BackupLedgerError";
421
+ if (divergedAt !== void 0) this.divergedAt = divergedAt;
422
+ }
423
+ };
424
+ var BackupCorruptedError = class extends NoydbError {
425
+ /** The (collection, id) pair whose envelope failed the hash check. */
426
+ collection;
427
+ id;
428
+ constructor(collection, id, message) {
429
+ super("BACKUP_CORRUPTED", message);
430
+ this.name = "BackupCorruptedError";
431
+ this.collection = collection;
432
+ this.id = id;
433
+ }
434
+ };
435
+ var SessionExpiredError = class extends NoydbError {
436
+ sessionId;
437
+ constructor(sessionId) {
438
+ super("SESSION_EXPIRED", `Session "${sessionId}" has expired. Re-unlock to continue.`);
439
+ this.name = "SessionExpiredError";
440
+ this.sessionId = sessionId;
441
+ }
442
+ };
443
+ var SessionNotFoundError = class extends NoydbError {
444
+ sessionId;
445
+ constructor(sessionId) {
446
+ super("SESSION_NOT_FOUND", `Session key for "${sessionId}" not found. The session may have been revoked or the page reloaded.`);
447
+ this.name = "SessionNotFoundError";
448
+ this.sessionId = sessionId;
449
+ }
450
+ };
451
+ var SessionPolicyError = class extends NoydbError {
452
+ operation;
453
+ constructor(operation, message) {
454
+ super(
455
+ "SESSION_POLICY",
456
+ message ?? `Operation "${operation}" requires re-authentication per the active session policy.`
457
+ );
458
+ this.name = "SessionPolicyError";
459
+ this.operation = operation;
460
+ }
461
+ };
462
+ var JoinTooLargeError = class extends NoydbError {
463
+ leftRows;
464
+ rightRows;
465
+ maxRows;
466
+ side;
467
+ constructor(opts) {
468
+ super("JOIN_TOO_LARGE", opts.message);
469
+ this.name = "JoinTooLargeError";
470
+ this.leftRows = opts.leftRows;
471
+ this.rightRows = opts.rightRows;
472
+ this.maxRows = opts.maxRows;
473
+ this.side = opts.side;
474
+ }
475
+ };
476
+ var DanglingReferenceError = class extends NoydbError {
477
+ field;
478
+ target;
479
+ refId;
480
+ constructor(opts) {
481
+ super("DANGLING_REFERENCE", opts.message);
482
+ this.name = "DanglingReferenceError";
483
+ this.field = opts.field;
484
+ this.target = opts.target;
485
+ this.refId = opts.refId;
486
+ }
487
+ };
488
+ var FilenameSanitizationError = class extends NoydbError {
489
+ constructor(message) {
490
+ super("FILENAME_SANITIZATION", message);
491
+ this.name = "FilenameSanitizationError";
492
+ }
493
+ };
494
+ var PathEscapeError = class extends NoydbError {
495
+ attempted;
496
+ targetDir;
497
+ constructor(opts) {
498
+ super(
499
+ "PATH_ESCAPE",
500
+ `Sanitized filename "${opts.attempted}" resolves outside target dir "${opts.targetDir}"`
501
+ );
502
+ this.name = "PathEscapeError";
503
+ this.attempted = opts.attempted;
504
+ this.targetDir = opts.targetDir;
505
+ }
506
+ };
507
+
508
+ export {
509
+ NoydbError,
510
+ DecryptionError,
511
+ TamperedError,
512
+ InvalidKeyError,
513
+ KeyringCorruptError,
514
+ NoAccessError,
515
+ ReadOnlyError,
516
+ ReadOnlyAtInstantError,
517
+ ReadOnlyFrameError,
518
+ PermissionDeniedError,
519
+ ExportCapabilityError,
520
+ KeyringExpiredError,
521
+ ImportCapabilityError,
522
+ StoreCapabilityError,
523
+ PrivilegeEscalationError,
524
+ PeriodClosedError,
525
+ TierNotGrantedError,
526
+ ElevationExpiredError,
527
+ AlreadyElevatedError,
528
+ TierDemoteDeniedError,
529
+ DelegationTargetMissingError,
530
+ ConflictError,
531
+ LedgerContentionError,
532
+ BundleVersionConflictError,
533
+ NetworkError,
534
+ NotFoundError,
535
+ ValidationError,
536
+ SchemaValidationError,
537
+ GroupCardinalityError,
538
+ IndexRequiredError,
539
+ IndexWriteFailureError,
540
+ BundleIntegrityError,
541
+ ReservedCollectionNameError,
542
+ DictKeyMissingError,
543
+ DictKeyInUseError,
544
+ MissingTranslationError,
545
+ LocaleNotSpecifiedError,
546
+ TranslatorNotConfiguredError,
547
+ BackupLedgerError,
548
+ BackupCorruptedError,
549
+ SessionExpiredError,
550
+ SessionNotFoundError,
551
+ SessionPolicyError,
552
+ JoinTooLargeError,
553
+ DanglingReferenceError,
554
+ FilenameSanitizationError,
555
+ PathEscapeError
556
+ };
557
+ //# sourceMappingURL=chunk-NBYQNDXA.js.map