@noy-db/hub 0.1.0-pre.3
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.
- package/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/aggregate/index.cjs +476 -0
- package/dist/aggregate/index.cjs.map +1 -0
- package/dist/aggregate/index.d.cts +38 -0
- package/dist/aggregate/index.d.ts +38 -0
- package/dist/aggregate/index.js +53 -0
- package/dist/aggregate/index.js.map +1 -0
- package/dist/blobs/index.cjs +1480 -0
- package/dist/blobs/index.cjs.map +1 -0
- package/dist/blobs/index.d.cts +45 -0
- package/dist/blobs/index.d.ts +45 -0
- package/dist/blobs/index.js +48 -0
- package/dist/blobs/index.js.map +1 -0
- package/dist/bundle/index.cjs +436 -0
- package/dist/bundle/index.cjs.map +1 -0
- package/dist/bundle/index.d.cts +7 -0
- package/dist/bundle/index.d.ts +7 -0
- package/dist/bundle/index.js +40 -0
- package/dist/bundle/index.js.map +1 -0
- package/dist/chunk-2QR2PQTT.js +217 -0
- package/dist/chunk-2QR2PQTT.js.map +1 -0
- package/dist/chunk-4OWFYIDQ.js +79 -0
- package/dist/chunk-4OWFYIDQ.js.map +1 -0
- package/dist/chunk-5AATM2M2.js +90 -0
- package/dist/chunk-5AATM2M2.js.map +1 -0
- package/dist/chunk-ACLDOTNQ.js +543 -0
- package/dist/chunk-ACLDOTNQ.js.map +1 -0
- package/dist/chunk-BTDCBVJW.js +160 -0
- package/dist/chunk-BTDCBVJW.js.map +1 -0
- package/dist/chunk-CIMZBAZB.js +72 -0
- package/dist/chunk-CIMZBAZB.js.map +1 -0
- package/dist/chunk-E445ICYI.js +365 -0
- package/dist/chunk-E445ICYI.js.map +1 -0
- package/dist/chunk-EXQRC2L4.js +722 -0
- package/dist/chunk-EXQRC2L4.js.map +1 -0
- package/dist/chunk-FZU343FL.js +32 -0
- package/dist/chunk-FZU343FL.js.map +1 -0
- package/dist/chunk-GJILMRPO.js +354 -0
- package/dist/chunk-GJILMRPO.js.map +1 -0
- package/dist/chunk-GOUT6DND.js +1285 -0
- package/dist/chunk-GOUT6DND.js.map +1 -0
- package/dist/chunk-J66GRPNH.js +111 -0
- package/dist/chunk-J66GRPNH.js.map +1 -0
- package/dist/chunk-M2F2JAWB.js +464 -0
- package/dist/chunk-M2F2JAWB.js.map +1 -0
- package/dist/chunk-M5INGEFC.js +84 -0
- package/dist/chunk-M5INGEFC.js.map +1 -0
- package/dist/chunk-M62XNWRA.js +72 -0
- package/dist/chunk-M62XNWRA.js.map +1 -0
- package/dist/chunk-MR4424N3.js +275 -0
- package/dist/chunk-MR4424N3.js.map +1 -0
- package/dist/chunk-NPC4LFV5.js +132 -0
- package/dist/chunk-NPC4LFV5.js.map +1 -0
- package/dist/chunk-NXFEYLVG.js +311 -0
- package/dist/chunk-NXFEYLVG.js.map +1 -0
- package/dist/chunk-R36SIKES.js +79 -0
- package/dist/chunk-R36SIKES.js.map +1 -0
- package/dist/chunk-TDR6T5CJ.js +381 -0
- package/dist/chunk-TDR6T5CJ.js.map +1 -0
- package/dist/chunk-UF3BUNQZ.js +1 -0
- package/dist/chunk-UF3BUNQZ.js.map +1 -0
- package/dist/chunk-UQFSPSWG.js +1109 -0
- package/dist/chunk-UQFSPSWG.js.map +1 -0
- package/dist/chunk-USKYUS74.js +793 -0
- package/dist/chunk-USKYUS74.js.map +1 -0
- package/dist/chunk-XCL3WP6J.js +121 -0
- package/dist/chunk-XCL3WP6J.js.map +1 -0
- package/dist/chunk-XHFOENR2.js +680 -0
- package/dist/chunk-XHFOENR2.js.map +1 -0
- package/dist/chunk-ZFKD4QMV.js +430 -0
- package/dist/chunk-ZFKD4QMV.js.map +1 -0
- package/dist/chunk-ZLMV3TUA.js +490 -0
- package/dist/chunk-ZLMV3TUA.js.map +1 -0
- package/dist/chunk-ZRG4V3F5.js +17 -0
- package/dist/chunk-ZRG4V3F5.js.map +1 -0
- package/dist/consent/index.cjs +204 -0
- package/dist/consent/index.cjs.map +1 -0
- package/dist/consent/index.d.cts +24 -0
- package/dist/consent/index.d.ts +24 -0
- package/dist/consent/index.js +23 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/crdt/index.cjs +152 -0
- package/dist/crdt/index.cjs.map +1 -0
- package/dist/crdt/index.d.cts +30 -0
- package/dist/crdt/index.d.ts +30 -0
- package/dist/crdt/index.js +24 -0
- package/dist/crdt/index.js.map +1 -0
- package/dist/crypto-IVKU7YTT.js +44 -0
- package/dist/crypto-IVKU7YTT.js.map +1 -0
- package/dist/delegation-XDJCBTI2.js +16 -0
- package/dist/delegation-XDJCBTI2.js.map +1 -0
- package/dist/dev-unlock-CeXic1xC.d.cts +263 -0
- package/dist/dev-unlock-KrKkcqD3.d.ts +263 -0
- package/dist/hash-9KO1BGxh.d.cts +63 -0
- package/dist/hash-ChfJjRjQ.d.ts +63 -0
- package/dist/history/index.cjs +1215 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +62 -0
- package/dist/history/index.d.ts +62 -0
- package/dist/history/index.js +79 -0
- package/dist/history/index.js.map +1 -0
- package/dist/i18n/index.cjs +746 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +38 -0
- package/dist/i18n/index.d.ts +38 -0
- package/dist/i18n/index.js +55 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-BRHBCmLt.d.ts +1940 -0
- package/dist/index-C8kQtmOk.d.ts +380 -0
- package/dist/index-DN-J-5wT.d.cts +1940 -0
- package/dist/index-DhjMjz7L.d.cts +380 -0
- package/dist/index.cjs +14756 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +6085 -0
- package/dist/index.js.map +1 -0
- package/dist/indexing/index.cjs +736 -0
- package/dist/indexing/index.cjs.map +1 -0
- package/dist/indexing/index.d.cts +36 -0
- package/dist/indexing/index.d.ts +36 -0
- package/dist/indexing/index.js +77 -0
- package/dist/indexing/index.js.map +1 -0
- package/dist/lazy-builder-BwEoBQZ9.d.ts +304 -0
- package/dist/lazy-builder-CZVLKh0Z.d.cts +304 -0
- package/dist/ledger-2NX4L7PN.js +33 -0
- package/dist/ledger-2NX4L7PN.js.map +1 -0
- package/dist/mime-magic-CBBSOkjm.d.cts +50 -0
- package/dist/mime-magic-CBBSOkjm.d.ts +50 -0
- package/dist/periods/index.cjs +1035 -0
- package/dist/periods/index.cjs.map +1 -0
- package/dist/periods/index.d.cts +21 -0
- package/dist/periods/index.d.ts +21 -0
- package/dist/periods/index.js +25 -0
- package/dist/periods/index.js.map +1 -0
- package/dist/predicate-SBHmi6D0.d.cts +161 -0
- package/dist/predicate-SBHmi6D0.d.ts +161 -0
- package/dist/query/index.cjs +1957 -0
- package/dist/query/index.cjs.map +1 -0
- package/dist/query/index.d.cts +3 -0
- package/dist/query/index.d.ts +3 -0
- package/dist/query/index.js +62 -0
- package/dist/query/index.js.map +1 -0
- package/dist/session/index.cjs +487 -0
- package/dist/session/index.cjs.map +1 -0
- package/dist/session/index.d.cts +45 -0
- package/dist/session/index.d.ts +45 -0
- package/dist/session/index.js +44 -0
- package/dist/session/index.js.map +1 -0
- package/dist/shadow/index.cjs +133 -0
- package/dist/shadow/index.cjs.map +1 -0
- package/dist/shadow/index.d.cts +16 -0
- package/dist/shadow/index.d.ts +16 -0
- package/dist/shadow/index.js +20 -0
- package/dist/shadow/index.js.map +1 -0
- package/dist/store/index.cjs +1069 -0
- package/dist/store/index.cjs.map +1 -0
- package/dist/store/index.d.cts +491 -0
- package/dist/store/index.d.ts +491 -0
- package/dist/store/index.js +34 -0
- package/dist/store/index.js.map +1 -0
- package/dist/strategy-BSxFXGzb.d.cts +110 -0
- package/dist/strategy-BSxFXGzb.d.ts +110 -0
- package/dist/strategy-D-SrOLCl.d.cts +548 -0
- package/dist/strategy-D-SrOLCl.d.ts +548 -0
- package/dist/sync/index.cjs +1062 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +42 -0
- package/dist/sync/index.d.ts +42 -0
- package/dist/sync/index.js +28 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/team/index.cjs +1233 -0
- package/dist/team/index.cjs.map +1 -0
- package/dist/team/index.d.cts +117 -0
- package/dist/team/index.d.ts +117 -0
- package/dist/team/index.js +39 -0
- package/dist/team/index.js.map +1 -0
- package/dist/tx/index.cjs +212 -0
- package/dist/tx/index.cjs.map +1 -0
- package/dist/tx/index.d.cts +20 -0
- package/dist/tx/index.d.ts +20 -0
- package/dist/tx/index.js +20 -0
- package/dist/tx/index.js.map +1 -0
- package/dist/types-BZpCZB8N.d.ts +7526 -0
- package/dist/types-Bfs0qr5F.d.cts +7526 -0
- package/dist/ulid-COREQ2RQ.js +9 -0
- package/dist/ulid-COREQ2RQ.js.map +1 -0
- package/dist/util/index.cjs +230 -0
- package/dist/util/index.cjs.map +1 -0
- package/dist/util/index.d.cts +77 -0
- package/dist/util/index.d.ts +77 -0
- package/dist/util/index.js +190 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +244 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { ar as UnlockedKeyring, aR as Vault, aA as DiffEntry } from './types-Bfs0qr5F.cjs';
|
|
2
|
+
export { aS as AccessibleVault, ax as AppendInput, p as BLOB_CHUNKS_COLLECTION, q as BLOB_COLLECTION, t as BLOB_INDEX_COLLECTION, u as BLOB_SLOTS_PREFIX, w as BLOB_VERSIONS_PREFIX, aT as BUNDLE_STORE_POLICY, A as BlobObject, C as BlobPutOptions, E as BlobResponseOptions, F as BlobSet, aU as BundleRecipient, _ as CONSENT_AUDIT_COLLECTION, aV as CacheOptions, aW as CacheStats, aX as ChangeEvent, ay as ChangeType, a7 as ClosePeriodOptions, aY as Collection, aZ as CollectionChangeEvent, a_ as CollectionConflictResolver, ai as CollectionFrame, az as CollectionInstant, a$ as Conflict, b0 as ConflictPolicy, b1 as ConflictStrategy, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, b2 as CrossTierAccessEvent, L as DEFAULT_CHUNK_SIZE, b3 as DELEGATIONS_COLLECTION, D as DICT_COLLECTION_PREFIX, b4 as DelegationToken, b5 as DeleteManyResult, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, b6 as DirtyEntry, b7 as ELEVATION_AUDIT_COLLECTION, b8 as ElevatedHandle, av as EncryptedEnvelope, b9 as ExportCapability, ba as ExportChunk, bb as ExportFormat, bc as ExportStreamOptions, bd as GhostRecord, be as GrantOptions, bf as HistoryConfig, bg as HistoryEntry, au as HistoryOptions, e as I18nTextDescriptor, f as I18nTextOptions, bh as INDEXED_STORE_POLICY, bi as ImportCapability, bj as InferOutput, bk as IssueDelegationOptions, bl as IssueMagicLinkGrantOptions, aB as JsonPatch, aC as JsonPatchOp, bm as KeyringFile, aD as LedgerEntry, aE as LedgerStore, bn as ListAccessibleVaultsOptions, bo as ListPageResult, bp as LocaleReadOptions, bq as Lru, br as LruOptions, bs as LruStats, bt as MAGIC_LINK_CONTENT_INFO_PREFIX, bu as MAGIC_LINK_GRANTS_COLLECTION, bv as MAGIC_LINK_KEK_INFO_PREFIX, bw as MagicLinkGrantPayload, bx as MagicLinkGrantRecord, by as NOYDB_BACKUP_VERSION, bz as NOYDB_FORMAT_VERSION, bA as NOYDB_KEYRING_VERSION, bB as NOYDB_SYNC_VERSION, bC as Noydb, bD as NoydbBundleStore, bE as NoydbEventMap, bF as NoydbOptions, at as NoydbStore, a8 as OpenPeriodOptions, a9 as PERIODS_COLLECTION, aa as PeriodRecord, bG as Permission, bH as Permissions, bI as PlaintextTranslatorContext, bJ as PlaintextTranslatorFn, P as PolicyEnforcer, bK as PresenceHandle, bL as PresencePeer, aw as PruneOptions, bM as PullMode, bN as PullOptions, bO as PullPolicy, bP as PullResult, bQ as PushMode, bR as PushOptions, bS as PushPolicy, bT as PushResult, bU as PutManyItemOptions, bV as PutManyOptions, bW as PutManyResult, bX as QueryAcrossOptions, bY as QueryAcrossResult, bZ as ReAuthOperation, b_ as RevokeOptions, aq as Role, b$ as SessionPolicy, U as SlotInfo, V as SlotRecord, c0 as StandardSchemaV1, c1 as StandardSchemaV1Issue, c2 as StandardSchemaV1SyncResult, c3 as StoreAuth, c4 as StoreAuthKind, c5 as StoreCapabilities, c6 as SyncEngine, c7 as SyncMetadata, c8 as SyncPolicy, c9 as SyncScheduler, ca as SyncSchedulerStatus, cb as SyncStatus, cc as SyncTarget, cd as SyncTargetRole, ce as SyncTransaction, cf as SyncTransactionResult, cg as TierMode, ch as TranslatorAuditEntry, al as TxCollection, am as TxContext, ci as TxOp, an as TxVault, cj as UserInfo, ck as VaultBackup, aF as VaultEngine, aj as VaultFrame, aG as VaultInstant, cl as VaultSnapshot, aH as VerifyResult, W as VersionRecord, g as applyI18nLocale, aI as applyPatch, cm as buildRecipientKeyringFile, aJ as canonicalJson, aK as computePatch, n as createEnforcer, cn as createNoydb, co as createStore, cp as deriveMagicLinkContentKey, h as dictCollectionName, i as dictKey, aL as diff, cq as evaluateExportCapability, cr as evaluateImportCapability, aM as formatDiff, cs as hasExportCapability, ct as hasImportCapability, aN as hashEntry, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, cu as isMagicLinkGrantExpired, cv as issueDelegation, cw as listMagicLinkGrants, cx as loadActiveDelegations, cy as magicLinkGrantRecordId, aO as paddedIndex, aP as parseIndex, cz as readMagicLinkGrantRecord, r as resolveI18nText, cA as revokeDelegation, cB as revokeMagicLinkGrant, ao as runTransaction, aQ as sha256Hex, cC as unwrapMagicLinkGrant, v as validateI18nTextValue, cD as validateSchemaInput, cE as validateSchemaOutput, o as validateSessionPolicy, cF as writeMagicLinkGrant } from './types-Bfs0qr5F.cjs';
|
|
3
|
+
export { d as detectMagic, a as detectMimeType, i as isPreCompressed } from './mime-magic-CBBSOkjm.cjs';
|
|
4
|
+
export { AgeRoute, BlobLifecyclePolicy, BlobStoreRoute, CircuitBreakerOptions, HealthCheckOptions, LogLevel, LoggingOptions, MetricsOptions, OverrideOptions, OverrideTarget, RetryOptions, RouteStatus, RouteStoreOptions, RoutedNoydbStore, StoreCacheOptions, StoreMiddleware, StoreOperation, SuspendOptions, WrapBundleStoreOptions, WrappedBundleNoydbStore, createBundleStore, routeStore, withCache, withCircuitBreaker, withHealthCheck, withLogging, withMetrics, withRetry, wrapBundleStore, wrapStore } from './store/index.cjs';
|
|
5
|
+
export { A as AlreadyElevatedError, B as BackupCorruptedError, a as BackupLedgerError, b as BundleIntegrityError, c as BundleVersionConflictError, C as ConflictError, D as DEFAULT_JOIN_MAX_ROWS, d as DanglingReferenceError, e as DecryptionError, f as DelegationTargetMissingError, g as DictKeyInUseError, h as DictKeyMissingError, E as ElevationExpiredError, i as ExportCapabilityError, F as FilenameSanitizationError, G as GroupCardinalityError, I as ImportCapabilityError, j as IndexRequiredError, k as IndexWriteFailureError, l as InvalidKeyError, J as JoinContext, m as JoinLeg, n as JoinStrategy, o as JoinTooLargeError, p as JoinableSource, K as KeyringExpiredError, L as LedgerContentionError, q as LiveQuery, r as LiveUpstream, s as LocaleNotSpecifiedError, M as MissingTranslationError, N as NetworkError, t as NoAccessError, u as NotFoundError, v as NoydbError, O as OrderBy, P as PathEscapeError, w as PeriodClosedError, x as PermissionDeniedError, y as PrivilegeEscalationError, Q as Query, z as QueryPlan, H as QuerySource, R as ReadOnlyAtInstantError, S as ReadOnlyError, T as ReadOnlyFrameError, U as RefDescriptor, V as RefIntegrityError, W as RefMode, X as RefRegistry, Y as RefScopeError, Z as RefViolation, _ as ReservedCollectionNameError, $ as ScanBuilder, a0 as ScanPageProvider, a1 as SchemaValidationError, a2 as SessionExpiredError, a3 as SessionNotFoundError, a4 as SessionPolicyError, a5 as StoreCapabilityError, a6 as TamperedError, a7 as TierDemoteDeniedError, a8 as TierNotGrantedError, a9 as TranslatorNotConfiguredError, aa as ValidationError, ab as applyJoins, ac as buildLiveQuery, ad as executePlan, ae as ref, af as resetJoinWarnings } from './index-DN-J-5wT.cjs';
|
|
6
|
+
export { C as CompressionAlgo, N as NOYDB_BUNDLE_FORMAT_VERSION, a as NOYDB_BUNDLE_MAGIC, b as NOYDB_BUNDLE_PREFIX_BYTES, c as NoydbBundleHeader, d as NoydbBundleReadResult, W as WriteNoydbBundleOptions, g as generateULID, h as hasNoydbBundleMagic, i as isULID, r as readNoydbBundle, e as readNoydbBundleHeader, f as resetBrotliSupportCache, w as writeNoydbBundle } from './index-DhjMjz7L.cjs';
|
|
7
|
+
export { a as CrdtMode, b as CrdtState, L as LwwMapState, R as RgaState, Y as YjsState, m as mergeCrdtStates, r as resolveCrdtSnapshot } from './strategy-BSxFXGzb.cjs';
|
|
8
|
+
export { SYNC_CREDENTIALS_COLLECTION, SyncCredential, credentialStatus, deleteCredential, getCredential, listCredentials, putCredential } from './team/index.cjs';
|
|
9
|
+
export { C as CreateSessionOptions, a as CreateSessionResult, D as DevUnlockOptions, S as SessionToken, b as activeSessionCount, c as clearDevUnlock, d as createSession, e as enableDevUnlock, i as isDevUnlockActive, f as isSessionAlive, l as loadDevUnlock, r as resolveSession, g as revokeAllSessions, h as revokeSession } from './dev-unlock-CeXic1xC.cjs';
|
|
10
|
+
export { a as Clause, C as CollectionIndexes, F as FieldClause, b as FilterClause, G as GroupClause, H as HashIndex, I as IndexDef, O as Operator, e as evaluateClause, c as evaluateFieldClause, r as readPath } from './predicate-SBHmi6D0.cjs';
|
|
11
|
+
export { a as AggregateResult, b as AggregateSpec, c as Aggregation, d as AggregationUpstream, G as GROUPBY_MAX_CARDINALITY, e as GROUPBY_WARN_CARDINALITY, f as GroupedAggregation, g as GroupedQuery, h as GroupedRow, L as LiveAggregation, R as Reducer, i as ReducerOptions, j as avg, l as count, m as groupAndReduce, n as max, o as min, r as reduceRecords, s as sum } from './strategy-D-SrOLCl.cjs';
|
|
12
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from './hash-9KO1BGxh.cjs';
|
|
13
|
+
import './lazy-builder-CZVLKh0Z.cjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cache policy helpers — parse human-friendly byte budgets into raw numbers.
|
|
17
|
+
*
|
|
18
|
+
* Accepted shapes (case-insensitive on suffix):
|
|
19
|
+
* number — interpreted as raw bytes
|
|
20
|
+
* '1024' — string of digits, raw bytes
|
|
21
|
+
* '50KB' — kilobytes (×1024)
|
|
22
|
+
* '50MB' — megabytes (×1024²)
|
|
23
|
+
* '1GB' — gigabytes (×1024³)
|
|
24
|
+
*
|
|
25
|
+
* Decimals are accepted (`'1.5GB'` → 1610612736 bytes).
|
|
26
|
+
*
|
|
27
|
+
* Anything else throws — better to fail loud at construction time than
|
|
28
|
+
* to silently treat a typo as 0 bytes (which would evict everything).
|
|
29
|
+
*/
|
|
30
|
+
/** Parse a byte budget into a positive integer number of bytes. */
|
|
31
|
+
declare function parseBytes(input: number | string): number;
|
|
32
|
+
/**
|
|
33
|
+
* Estimate the in-memory byte size of a decrypted record.
|
|
34
|
+
*
|
|
35
|
+
* Uses `JSON.stringify().length` as a stand-in for actual heap usage.
|
|
36
|
+
* It's a deliberate approximation: real V8 heap size includes pointer
|
|
37
|
+
* overhead, hidden classes, and string interning that we can't measure
|
|
38
|
+
* from JavaScript. The JSON length is a stable, monotonic proxy that
|
|
39
|
+
* costs O(record size) per insert — fine when records are typically
|
|
40
|
+
* < 1 KB and the cache eviction is the slow path anyway.
|
|
41
|
+
*
|
|
42
|
+
* Returns `0` (and the caller must treat it as 1 for accounting) if
|
|
43
|
+
* stringification throws on circular references; this is documented
|
|
44
|
+
* but in practice records always come from JSON-decoded envelopes.
|
|
45
|
+
*/
|
|
46
|
+
declare function estimateRecordBytes(record: unknown): number;
|
|
47
|
+
|
|
48
|
+
interface EncryptResult {
|
|
49
|
+
iv: string;
|
|
50
|
+
data: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Encrypt raw bytes with AES-256-GCM using a fresh random IV.
|
|
54
|
+
* Used by the attachment store so binary blobs avoid double base64 encoding
|
|
55
|
+
* (the existing `encrypt()` function calls `TextEncoder` on a string — here
|
|
56
|
+
* we pass the `Uint8Array` directly to `subtle.encrypt`).
|
|
57
|
+
*/
|
|
58
|
+
declare function encryptBytes(data: Uint8Array, dek: CryptoKey): Promise<EncryptResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Decrypt AES-256-GCM ciphertext back to raw bytes.
|
|
61
|
+
* Counterpart to `encryptBytes`. Throws `TamperedError` on auth-tag failure.
|
|
62
|
+
*/
|
|
63
|
+
declare function decryptBytes(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<Uint8Array>;
|
|
64
|
+
/**
|
|
65
|
+
* Derive an AES-256-GCM presence key from a collection DEK using HKDF-SHA256.
|
|
66
|
+
*
|
|
67
|
+
* The presence key is domain-separated from the data DEK by the fixed salt
|
|
68
|
+
* `'noydb-presence'` and the `info` = collection name. This means:
|
|
69
|
+
* - The adapter never sees the presence key.
|
|
70
|
+
* - Presence payloads rotate automatically when the collection DEK is rotated.
|
|
71
|
+
* - Revoked users cannot derive the new presence key after a DEK rotation.
|
|
72
|
+
*
|
|
73
|
+
* @param dek The collection's AES-256-GCM DEK (extractable).
|
|
74
|
+
* @param collectionName Used as the HKDF `info` parameter for domain separation.
|
|
75
|
+
* @returns A non-extractable AES-256-GCM key suitable for presence payload encryption.
|
|
76
|
+
*/
|
|
77
|
+
declare function derivePresenceKey(dek: CryptoKey, collectionName: string): Promise<CryptoKey>;
|
|
78
|
+
/**
|
|
79
|
+
* Encrypt a plaintext string with AES-256-GCM and a deterministic,
|
|
80
|
+
* HKDF-derived IV.
|
|
81
|
+
*
|
|
82
|
+
* The same `{ dek, context, plaintext }` triple always produces the
|
|
83
|
+
* same `{ iv, data }` — call this twice and you can string-compare the
|
|
84
|
+
* ciphertexts to check equality of the inputs without decrypting them.
|
|
85
|
+
*
|
|
86
|
+
* @param context Domain-separation string — by convention
|
|
87
|
+
* `'<collection>/<field>'`. Different contexts encrypt
|
|
88
|
+
* the same plaintext to different ciphertexts, so
|
|
89
|
+
* `email` in collection `users` does not collide with
|
|
90
|
+
* `email` in collection `customers`.
|
|
91
|
+
*/
|
|
92
|
+
declare function encryptDeterministic(plaintext: string, dek: CryptoKey, context: string): Promise<EncryptResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Counterpart to {@link encryptDeterministic}. The IV is stored
|
|
95
|
+
* alongside the ciphertext (exactly like the randomized path), so
|
|
96
|
+
* decrypt uses the stored IV and verifies the GCM auth tag — a tampered
|
|
97
|
+
* ciphertext throws `TamperedError` just like randomized AES-GCM.
|
|
98
|
+
*/
|
|
99
|
+
declare function decryptDeterministic(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<string>;
|
|
100
|
+
declare function bufferToBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
101
|
+
declare function base64ToBuffer(base64: string): Uint8Array<ArrayBuffer>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Hierarchical access — tier-aware keyring helpers.
|
|
105
|
+
*
|
|
106
|
+
* The keyring's existing `deks: Map<string, CryptoKey>` is keyed by
|
|
107
|
+
* collection name. extends the key space:
|
|
108
|
+
*
|
|
109
|
+
* `'invoices'` — tier-0 DEK (unchanged from v0.x)
|
|
110
|
+
* `'invoices#1'` — tier-1 DEK
|
|
111
|
+
* `'invoices#2'` — tier-2 DEK
|
|
112
|
+
*
|
|
113
|
+
* Tier 0 keeps the bare collection name so any keyring written
|
|
114
|
+
* before tiers existed loads without migration. Tiers ≥ 1 use `#N`
|
|
115
|
+
* suffixes that
|
|
116
|
+
* would be invalid as user-supplied collection names (see
|
|
117
|
+
* `ReservedCollectionNameError` — `#` is reserved).
|
|
118
|
+
*
|
|
119
|
+
* @module
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/** Canonical DEK key for a given collection + tier. Tier 0 → bare name. */
|
|
123
|
+
declare function dekKey(collection: string, tier: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the user's effective clearance for a given collection: the
|
|
126
|
+
* maximum tier for which their keyring holds a DEK. Falls back to 0
|
|
127
|
+
* when the user has only the tier-0 DEK (or none — the getDEK caller
|
|
128
|
+
* will raise separately).
|
|
129
|
+
*/
|
|
130
|
+
declare function effectiveClearance(keyring: UnlockedKeyring, collection: string): number;
|
|
131
|
+
/**
|
|
132
|
+
* Assert the caller is cleared for the requested tier. Owners and
|
|
133
|
+
* admins always pass (they can mint any new tier DEK on demand);
|
|
134
|
+
* other roles must already hold the tier DEK — via a prior grant or
|
|
135
|
+
* an active delegation — otherwise this throws `TierNotGrantedError`.
|
|
136
|
+
*
|
|
137
|
+
* This gate runs BEFORE `getDEK()` on the mutation path so a
|
|
138
|
+
* non-cleared operator never has the opportunity to silently
|
|
139
|
+
* auto-create a tier DEK they shouldn't have.
|
|
140
|
+
*/
|
|
141
|
+
declare function assertTierAccess(keyring: UnlockedKeyring, collection: string, tier: number): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Vault-level diff orchestrator.
|
|
145
|
+
*
|
|
146
|
+
* Compares a live `Vault`'s plaintext state against a candidate state
|
|
147
|
+
* (another vault, a plain `{ collection: records[] }` map, or a vault
|
|
148
|
+
* dump JSON) and returns a structured `VaultDiff` plan listing the
|
|
149
|
+
* records that would be added, modified, or deleted to bring the live
|
|
150
|
+
* vault into the candidate's shape.
|
|
151
|
+
*
|
|
152
|
+
* Builds on two existing record-level helpers:
|
|
153
|
+
*
|
|
154
|
+
* 1. `diff(a, b)` from `./history/diff.ts` — emits dot-pathed
|
|
155
|
+
* `DiffEntry[]` with `type: 'added' | 'removed' | 'changed'` for
|
|
156
|
+
* each changed field of two records. Used here for the
|
|
157
|
+
* `fieldDiffs` of every `modified` entry, and (with empty result)
|
|
158
|
+
* as the default deep-equal check.
|
|
159
|
+
*
|
|
160
|
+
* 2. `Vault.exportStream()` from `./vault.ts` — the canonical
|
|
161
|
+
* decrypt-and-stream-records iterator. Used to walk both sides
|
|
162
|
+
* when the candidate is itself a `Vault`. ACL-scoped: collections
|
|
163
|
+
* the caller can't read silently drop out, the same way every
|
|
164
|
+
* other plaintext-emitting export pipeline filters them.
|
|
165
|
+
*
|
|
166
|
+
* The new orchestration is the **vault-level** enumeration: bucket
|
|
167
|
+
* each record id into added (only in candidate), deleted (only in
|
|
168
|
+
* vault), or modified (in both with field changes); leave the
|
|
169
|
+
* field-level granularity to the existing `diff()`.
|
|
170
|
+
*
|
|
171
|
+
* Use cases:
|
|
172
|
+
*
|
|
173
|
+
* - Import preview (`@noy-db/as-*` `fromString` returns a plan
|
|
174
|
+
* whose body is a `VaultDiff`).
|
|
175
|
+
* - Backup verification ("does this `.noydb` bundle from yesterday
|
|
176
|
+
* match the current vault?").
|
|
177
|
+
* - Two-vault reconciliation ("what's different between Office A
|
|
178
|
+
* and Office B before we sync?").
|
|
179
|
+
* - Test assertions (golden-file testing with one-liner
|
|
180
|
+
* `expect(plan.summary).toEqual(...)`).
|
|
181
|
+
*
|
|
182
|
+
* @module
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/** Per-record entry shape — added and deleted records carry only the record value. */
|
|
186
|
+
interface VaultDiffEntry<T = unknown> {
|
|
187
|
+
readonly collection: string;
|
|
188
|
+
readonly id: string;
|
|
189
|
+
readonly record: T;
|
|
190
|
+
}
|
|
191
|
+
/** Modified records carry both halves of the diff plus the field-level breakdown. */
|
|
192
|
+
interface VaultDiffModifiedEntry<T = unknown> extends VaultDiffEntry<T> {
|
|
193
|
+
/** The record as it stands in the live vault. */
|
|
194
|
+
readonly before: T;
|
|
195
|
+
/** Top-level keys whose values differ between `before` and `record`. */
|
|
196
|
+
readonly fieldsChanged: readonly string[];
|
|
197
|
+
/**
|
|
198
|
+
* Field-level diff entries from `diff(before, record)`. Reuses the
|
|
199
|
+
* existing per-record diff helper so consumers can render git-style
|
|
200
|
+
* `path: from → to` rows without re-walking the records.
|
|
201
|
+
*/
|
|
202
|
+
readonly fieldDiffs: readonly DiffEntry[];
|
|
203
|
+
}
|
|
204
|
+
interface VaultDiff<T = unknown> {
|
|
205
|
+
readonly added: readonly VaultDiffEntry<T>[];
|
|
206
|
+
readonly modified: readonly VaultDiffModifiedEntry<T>[];
|
|
207
|
+
readonly deleted: readonly VaultDiffEntry<T>[];
|
|
208
|
+
/** Only populated when `options.includeUnchanged: true`. */
|
|
209
|
+
readonly unchanged: readonly VaultDiffEntry<T>[] | undefined;
|
|
210
|
+
readonly summary: {
|
|
211
|
+
readonly add: number;
|
|
212
|
+
readonly modify: number;
|
|
213
|
+
readonly delete: number;
|
|
214
|
+
readonly total: number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Format the diff as a human-readable string.
|
|
218
|
+
*
|
|
219
|
+
* - `'count'` — one line, just the numbers (`12 added · 3 modified · 0 deleted`)
|
|
220
|
+
* - `'one-line'` — count plus a single overview line
|
|
221
|
+
* - `'full'` — count + one row per added/modified/deleted record (default)
|
|
222
|
+
*/
|
|
223
|
+
format(opts?: {
|
|
224
|
+
detail?: 'count' | 'one-line' | 'full';
|
|
225
|
+
}): string;
|
|
226
|
+
}
|
|
227
|
+
interface DiffOptions {
|
|
228
|
+
/** Restrict the diff to a subset of collections. */
|
|
229
|
+
readonly collections?: readonly string[];
|
|
230
|
+
/** Field on each record that carries its id. Defaults to `'id'`. */
|
|
231
|
+
readonly idKey?: string;
|
|
232
|
+
/** Override the default deep-equal check for "modified vs unchanged". */
|
|
233
|
+
readonly compareFn?: (a: unknown, b: unknown) => boolean;
|
|
234
|
+
/** If true, include unchanged records in the diff (off by default to save memory). */
|
|
235
|
+
readonly includeUnchanged?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Candidate state to diff the vault against:
|
|
239
|
+
*
|
|
240
|
+
* - A `Vault` instance — both sides are walked via `exportStream()`.
|
|
241
|
+
* - A `Record<collection, records[]>` map — same shape `as-json.toObject()`
|
|
242
|
+
* produces. Useful for diffing parsed file content against the live vault.
|
|
243
|
+
* - A `VaultDump` (output of `vault.dump()`) — a JSON string carrying the
|
|
244
|
+
* full vault state. Parsed and reduced to the map shape above.
|
|
245
|
+
*/
|
|
246
|
+
type DiffCandidate<T = unknown> = Vault | Record<string, readonly T[]> | string;
|
|
247
|
+
/**
|
|
248
|
+
* Compute the diff between a live vault and a candidate state.
|
|
249
|
+
*
|
|
250
|
+
* Returns a fully buffered `VaultDiff` — no streaming. Memory cost is
|
|
251
|
+
* O(n + m) in the row count of vault + candidate. For documented
|
|
252
|
+
* 1K-50K-record vaults this is fine; a streaming variant lands as a
|
|
253
|
+
* follow-up if a > 100K-record consumer arrives.
|
|
254
|
+
*/
|
|
255
|
+
declare function diffVault<T = unknown>(vault: Vault, candidate: DiffCandidate<T>, options?: DiffOptions): Promise<VaultDiff<T>>;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Validate passphrase strength.
|
|
259
|
+
* Checks length and basic entropy heuristics.
|
|
260
|
+
* Throws ValidationError if too weak.
|
|
261
|
+
*/
|
|
262
|
+
declare function validatePassphrase(passphrase: string): void;
|
|
263
|
+
/**
|
|
264
|
+
* Estimate passphrase entropy in bits.
|
|
265
|
+
* Uses character class analysis (not dictionary-based).
|
|
266
|
+
*/
|
|
267
|
+
declare function estimateEntropy(passphrase: string): number;
|
|
268
|
+
|
|
269
|
+
export { type DiffCandidate, DiffEntry, type DiffOptions, UnlockedKeyring, Vault, type VaultDiff, type VaultDiffEntry, type VaultDiffModifiedEntry, assertTierAccess, base64ToBuffer, bufferToBase64, decryptBytes, decryptDeterministic, dekKey, derivePresenceKey, diffVault, effectiveClearance, encryptBytes, encryptDeterministic, estimateEntropy, estimateRecordBytes, parseBytes, validatePassphrase };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { ar as UnlockedKeyring, aR as Vault, aA as DiffEntry } from './types-BZpCZB8N.js';
|
|
2
|
+
export { aS as AccessibleVault, ax as AppendInput, p as BLOB_CHUNKS_COLLECTION, q as BLOB_COLLECTION, t as BLOB_INDEX_COLLECTION, u as BLOB_SLOTS_PREFIX, w as BLOB_VERSIONS_PREFIX, aT as BUNDLE_STORE_POLICY, A as BlobObject, C as BlobPutOptions, E as BlobResponseOptions, F as BlobSet, aU as BundleRecipient, _ as CONSENT_AUDIT_COLLECTION, aV as CacheOptions, aW as CacheStats, aX as ChangeEvent, ay as ChangeType, a7 as ClosePeriodOptions, aY as Collection, aZ as CollectionChangeEvent, a_ as CollectionConflictResolver, ai as CollectionFrame, az as CollectionInstant, a$ as Conflict, b0 as ConflictPolicy, b1 as ConflictStrategy, $ as ConsentAuditEntry, a0 as ConsentAuditFilter, a1 as ConsentContext, a2 as ConsentOp, b2 as CrossTierAccessEvent, L as DEFAULT_CHUNK_SIZE, b3 as DELEGATIONS_COLLECTION, D as DICT_COLLECTION_PREFIX, b4 as DelegationToken, b5 as DeleteManyResult, a as DictEntry, b as DictKeyDescriptor, c as DictionaryHandle, d as DictionaryOptions, b6 as DirtyEntry, b7 as ELEVATION_AUDIT_COLLECTION, b8 as ElevatedHandle, av as EncryptedEnvelope, b9 as ExportCapability, ba as ExportChunk, bb as ExportFormat, bc as ExportStreamOptions, bd as GhostRecord, be as GrantOptions, bf as HistoryConfig, bg as HistoryEntry, au as HistoryOptions, e as I18nTextDescriptor, f as I18nTextOptions, bh as INDEXED_STORE_POLICY, bi as ImportCapability, bj as InferOutput, bk as IssueDelegationOptions, bl as IssueMagicLinkGrantOptions, aB as JsonPatch, aC as JsonPatchOp, bm as KeyringFile, aD as LedgerEntry, aE as LedgerStore, bn as ListAccessibleVaultsOptions, bo as ListPageResult, bp as LocaleReadOptions, bq as Lru, br as LruOptions, bs as LruStats, bt as MAGIC_LINK_CONTENT_INFO_PREFIX, bu as MAGIC_LINK_GRANTS_COLLECTION, bv as MAGIC_LINK_KEK_INFO_PREFIX, bw as MagicLinkGrantPayload, bx as MagicLinkGrantRecord, by as NOYDB_BACKUP_VERSION, bz as NOYDB_FORMAT_VERSION, bA as NOYDB_KEYRING_VERSION, bB as NOYDB_SYNC_VERSION, bC as Noydb, bD as NoydbBundleStore, bE as NoydbEventMap, bF as NoydbOptions, at as NoydbStore, a8 as OpenPeriodOptions, a9 as PERIODS_COLLECTION, aa as PeriodRecord, bG as Permission, bH as Permissions, bI as PlaintextTranslatorContext, bJ as PlaintextTranslatorFn, P as PolicyEnforcer, bK as PresenceHandle, bL as PresencePeer, aw as PruneOptions, bM as PullMode, bN as PullOptions, bO as PullPolicy, bP as PullResult, bQ as PushMode, bR as PushOptions, bS as PushPolicy, bT as PushResult, bU as PutManyItemOptions, bV as PutManyOptions, bW as PutManyResult, bX as QueryAcrossOptions, bY as QueryAcrossResult, bZ as ReAuthOperation, b_ as RevokeOptions, aq as Role, b$ as SessionPolicy, U as SlotInfo, V as SlotRecord, c0 as StandardSchemaV1, c1 as StandardSchemaV1Issue, c2 as StandardSchemaV1SyncResult, c3 as StoreAuth, c4 as StoreAuthKind, c5 as StoreCapabilities, c6 as SyncEngine, c7 as SyncMetadata, c8 as SyncPolicy, c9 as SyncScheduler, ca as SyncSchedulerStatus, cb as SyncStatus, cc as SyncTarget, cd as SyncTargetRole, ce as SyncTransaction, cf as SyncTransactionResult, cg as TierMode, ch as TranslatorAuditEntry, al as TxCollection, am as TxContext, ci as TxOp, an as TxVault, cj as UserInfo, ck as VaultBackup, aF as VaultEngine, aj as VaultFrame, aG as VaultInstant, cl as VaultSnapshot, aH as VerifyResult, W as VersionRecord, g as applyI18nLocale, aI as applyPatch, cm as buildRecipientKeyringFile, aJ as canonicalJson, aK as computePatch, n as createEnforcer, cn as createNoydb, co as createStore, cp as deriveMagicLinkContentKey, h as dictCollectionName, i as dictKey, aL as diff, cq as evaluateExportCapability, cr as evaluateImportCapability, aM as formatDiff, cs as hasExportCapability, ct as hasImportCapability, aN as hashEntry, j as i18nText, k as isDictCollectionName, l as isDictKeyDescriptor, m as isI18nTextDescriptor, cu as isMagicLinkGrantExpired, cv as issueDelegation, cw as listMagicLinkGrants, cx as loadActiveDelegations, cy as magicLinkGrantRecordId, aO as paddedIndex, aP as parseIndex, cz as readMagicLinkGrantRecord, r as resolveI18nText, cA as revokeDelegation, cB as revokeMagicLinkGrant, ao as runTransaction, aQ as sha256Hex, cC as unwrapMagicLinkGrant, v as validateI18nTextValue, cD as validateSchemaInput, cE as validateSchemaOutput, o as validateSessionPolicy, cF as writeMagicLinkGrant } from './types-BZpCZB8N.js';
|
|
3
|
+
export { d as detectMagic, a as detectMimeType, i as isPreCompressed } from './mime-magic-CBBSOkjm.js';
|
|
4
|
+
export { AgeRoute, BlobLifecyclePolicy, BlobStoreRoute, CircuitBreakerOptions, HealthCheckOptions, LogLevel, LoggingOptions, MetricsOptions, OverrideOptions, OverrideTarget, RetryOptions, RouteStatus, RouteStoreOptions, RoutedNoydbStore, StoreCacheOptions, StoreMiddleware, StoreOperation, SuspendOptions, WrapBundleStoreOptions, WrappedBundleNoydbStore, createBundleStore, routeStore, withCache, withCircuitBreaker, withHealthCheck, withLogging, withMetrics, withRetry, wrapBundleStore, wrapStore } from './store/index.js';
|
|
5
|
+
export { A as AlreadyElevatedError, B as BackupCorruptedError, a as BackupLedgerError, b as BundleIntegrityError, c as BundleVersionConflictError, C as ConflictError, D as DEFAULT_JOIN_MAX_ROWS, d as DanglingReferenceError, e as DecryptionError, f as DelegationTargetMissingError, g as DictKeyInUseError, h as DictKeyMissingError, E as ElevationExpiredError, i as ExportCapabilityError, F as FilenameSanitizationError, G as GroupCardinalityError, I as ImportCapabilityError, j as IndexRequiredError, k as IndexWriteFailureError, l as InvalidKeyError, J as JoinContext, m as JoinLeg, n as JoinStrategy, o as JoinTooLargeError, p as JoinableSource, K as KeyringExpiredError, L as LedgerContentionError, q as LiveQuery, r as LiveUpstream, s as LocaleNotSpecifiedError, M as MissingTranslationError, N as NetworkError, t as NoAccessError, u as NotFoundError, v as NoydbError, O as OrderBy, P as PathEscapeError, w as PeriodClosedError, x as PermissionDeniedError, y as PrivilegeEscalationError, Q as Query, z as QueryPlan, H as QuerySource, R as ReadOnlyAtInstantError, S as ReadOnlyError, T as ReadOnlyFrameError, U as RefDescriptor, V as RefIntegrityError, W as RefMode, X as RefRegistry, Y as RefScopeError, Z as RefViolation, _ as ReservedCollectionNameError, $ as ScanBuilder, a0 as ScanPageProvider, a1 as SchemaValidationError, a2 as SessionExpiredError, a3 as SessionNotFoundError, a4 as SessionPolicyError, a5 as StoreCapabilityError, a6 as TamperedError, a7 as TierDemoteDeniedError, a8 as TierNotGrantedError, a9 as TranslatorNotConfiguredError, aa as ValidationError, ab as applyJoins, ac as buildLiveQuery, ad as executePlan, ae as ref, af as resetJoinWarnings } from './index-BRHBCmLt.js';
|
|
6
|
+
export { C as CompressionAlgo, N as NOYDB_BUNDLE_FORMAT_VERSION, a as NOYDB_BUNDLE_MAGIC, b as NOYDB_BUNDLE_PREFIX_BYTES, c as NoydbBundleHeader, d as NoydbBundleReadResult, W as WriteNoydbBundleOptions, g as generateULID, h as hasNoydbBundleMagic, i as isULID, r as readNoydbBundle, e as readNoydbBundleHeader, f as resetBrotliSupportCache, w as writeNoydbBundle } from './index-C8kQtmOk.js';
|
|
7
|
+
export { a as CrdtMode, b as CrdtState, L as LwwMapState, R as RgaState, Y as YjsState, m as mergeCrdtStates, r as resolveCrdtSnapshot } from './strategy-BSxFXGzb.js';
|
|
8
|
+
export { SYNC_CREDENTIALS_COLLECTION, SyncCredential, credentialStatus, deleteCredential, getCredential, listCredentials, putCredential } from './team/index.js';
|
|
9
|
+
export { C as CreateSessionOptions, a as CreateSessionResult, D as DevUnlockOptions, S as SessionToken, b as activeSessionCount, c as clearDevUnlock, d as createSession, e as enableDevUnlock, i as isDevUnlockActive, f as isSessionAlive, l as loadDevUnlock, r as resolveSession, g as revokeAllSessions, h as revokeSession } from './dev-unlock-KrKkcqD3.js';
|
|
10
|
+
export { a as Clause, C as CollectionIndexes, F as FieldClause, b as FilterClause, G as GroupClause, H as HashIndex, I as IndexDef, O as Operator, e as evaluateClause, c as evaluateFieldClause, r as readPath } from './predicate-SBHmi6D0.js';
|
|
11
|
+
export { a as AggregateResult, b as AggregateSpec, c as Aggregation, d as AggregationUpstream, G as GROUPBY_MAX_CARDINALITY, e as GROUPBY_WARN_CARDINALITY, f as GroupedAggregation, g as GroupedQuery, h as GroupedRow, L as LiveAggregation, R as Reducer, i as ReducerOptions, j as avg, l as count, m as groupAndReduce, n as max, o as min, r as reduceRecords, s as sum } from './strategy-D-SrOLCl.js';
|
|
12
|
+
export { L as LEDGER_COLLECTION, a as LEDGER_DELTAS_COLLECTION, e as envelopePayloadHash } from './hash-ChfJjRjQ.js';
|
|
13
|
+
import './lazy-builder-BwEoBQZ9.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Cache policy helpers — parse human-friendly byte budgets into raw numbers.
|
|
17
|
+
*
|
|
18
|
+
* Accepted shapes (case-insensitive on suffix):
|
|
19
|
+
* number — interpreted as raw bytes
|
|
20
|
+
* '1024' — string of digits, raw bytes
|
|
21
|
+
* '50KB' — kilobytes (×1024)
|
|
22
|
+
* '50MB' — megabytes (×1024²)
|
|
23
|
+
* '1GB' — gigabytes (×1024³)
|
|
24
|
+
*
|
|
25
|
+
* Decimals are accepted (`'1.5GB'` → 1610612736 bytes).
|
|
26
|
+
*
|
|
27
|
+
* Anything else throws — better to fail loud at construction time than
|
|
28
|
+
* to silently treat a typo as 0 bytes (which would evict everything).
|
|
29
|
+
*/
|
|
30
|
+
/** Parse a byte budget into a positive integer number of bytes. */
|
|
31
|
+
declare function parseBytes(input: number | string): number;
|
|
32
|
+
/**
|
|
33
|
+
* Estimate the in-memory byte size of a decrypted record.
|
|
34
|
+
*
|
|
35
|
+
* Uses `JSON.stringify().length` as a stand-in for actual heap usage.
|
|
36
|
+
* It's a deliberate approximation: real V8 heap size includes pointer
|
|
37
|
+
* overhead, hidden classes, and string interning that we can't measure
|
|
38
|
+
* from JavaScript. The JSON length is a stable, monotonic proxy that
|
|
39
|
+
* costs O(record size) per insert — fine when records are typically
|
|
40
|
+
* < 1 KB and the cache eviction is the slow path anyway.
|
|
41
|
+
*
|
|
42
|
+
* Returns `0` (and the caller must treat it as 1 for accounting) if
|
|
43
|
+
* stringification throws on circular references; this is documented
|
|
44
|
+
* but in practice records always come from JSON-decoded envelopes.
|
|
45
|
+
*/
|
|
46
|
+
declare function estimateRecordBytes(record: unknown): number;
|
|
47
|
+
|
|
48
|
+
interface EncryptResult {
|
|
49
|
+
iv: string;
|
|
50
|
+
data: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Encrypt raw bytes with AES-256-GCM using a fresh random IV.
|
|
54
|
+
* Used by the attachment store so binary blobs avoid double base64 encoding
|
|
55
|
+
* (the existing `encrypt()` function calls `TextEncoder` on a string — here
|
|
56
|
+
* we pass the `Uint8Array` directly to `subtle.encrypt`).
|
|
57
|
+
*/
|
|
58
|
+
declare function encryptBytes(data: Uint8Array, dek: CryptoKey): Promise<EncryptResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Decrypt AES-256-GCM ciphertext back to raw bytes.
|
|
61
|
+
* Counterpart to `encryptBytes`. Throws `TamperedError` on auth-tag failure.
|
|
62
|
+
*/
|
|
63
|
+
declare function decryptBytes(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<Uint8Array>;
|
|
64
|
+
/**
|
|
65
|
+
* Derive an AES-256-GCM presence key from a collection DEK using HKDF-SHA256.
|
|
66
|
+
*
|
|
67
|
+
* The presence key is domain-separated from the data DEK by the fixed salt
|
|
68
|
+
* `'noydb-presence'` and the `info` = collection name. This means:
|
|
69
|
+
* - The adapter never sees the presence key.
|
|
70
|
+
* - Presence payloads rotate automatically when the collection DEK is rotated.
|
|
71
|
+
* - Revoked users cannot derive the new presence key after a DEK rotation.
|
|
72
|
+
*
|
|
73
|
+
* @param dek The collection's AES-256-GCM DEK (extractable).
|
|
74
|
+
* @param collectionName Used as the HKDF `info` parameter for domain separation.
|
|
75
|
+
* @returns A non-extractable AES-256-GCM key suitable for presence payload encryption.
|
|
76
|
+
*/
|
|
77
|
+
declare function derivePresenceKey(dek: CryptoKey, collectionName: string): Promise<CryptoKey>;
|
|
78
|
+
/**
|
|
79
|
+
* Encrypt a plaintext string with AES-256-GCM and a deterministic,
|
|
80
|
+
* HKDF-derived IV.
|
|
81
|
+
*
|
|
82
|
+
* The same `{ dek, context, plaintext }` triple always produces the
|
|
83
|
+
* same `{ iv, data }` — call this twice and you can string-compare the
|
|
84
|
+
* ciphertexts to check equality of the inputs without decrypting them.
|
|
85
|
+
*
|
|
86
|
+
* @param context Domain-separation string — by convention
|
|
87
|
+
* `'<collection>/<field>'`. Different contexts encrypt
|
|
88
|
+
* the same plaintext to different ciphertexts, so
|
|
89
|
+
* `email` in collection `users` does not collide with
|
|
90
|
+
* `email` in collection `customers`.
|
|
91
|
+
*/
|
|
92
|
+
declare function encryptDeterministic(plaintext: string, dek: CryptoKey, context: string): Promise<EncryptResult>;
|
|
93
|
+
/**
|
|
94
|
+
* Counterpart to {@link encryptDeterministic}. The IV is stored
|
|
95
|
+
* alongside the ciphertext (exactly like the randomized path), so
|
|
96
|
+
* decrypt uses the stored IV and verifies the GCM auth tag — a tampered
|
|
97
|
+
* ciphertext throws `TamperedError` just like randomized AES-GCM.
|
|
98
|
+
*/
|
|
99
|
+
declare function decryptDeterministic(ivBase64: string, dataBase64: string, dek: CryptoKey): Promise<string>;
|
|
100
|
+
declare function bufferToBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
101
|
+
declare function base64ToBuffer(base64: string): Uint8Array<ArrayBuffer>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Hierarchical access — tier-aware keyring helpers.
|
|
105
|
+
*
|
|
106
|
+
* The keyring's existing `deks: Map<string, CryptoKey>` is keyed by
|
|
107
|
+
* collection name. extends the key space:
|
|
108
|
+
*
|
|
109
|
+
* `'invoices'` — tier-0 DEK (unchanged from v0.x)
|
|
110
|
+
* `'invoices#1'` — tier-1 DEK
|
|
111
|
+
* `'invoices#2'` — tier-2 DEK
|
|
112
|
+
*
|
|
113
|
+
* Tier 0 keeps the bare collection name so any keyring written
|
|
114
|
+
* before tiers existed loads without migration. Tiers ≥ 1 use `#N`
|
|
115
|
+
* suffixes that
|
|
116
|
+
* would be invalid as user-supplied collection names (see
|
|
117
|
+
* `ReservedCollectionNameError` — `#` is reserved).
|
|
118
|
+
*
|
|
119
|
+
* @module
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/** Canonical DEK key for a given collection + tier. Tier 0 → bare name. */
|
|
123
|
+
declare function dekKey(collection: string, tier: number): string;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the user's effective clearance for a given collection: the
|
|
126
|
+
* maximum tier for which their keyring holds a DEK. Falls back to 0
|
|
127
|
+
* when the user has only the tier-0 DEK (or none — the getDEK caller
|
|
128
|
+
* will raise separately).
|
|
129
|
+
*/
|
|
130
|
+
declare function effectiveClearance(keyring: UnlockedKeyring, collection: string): number;
|
|
131
|
+
/**
|
|
132
|
+
* Assert the caller is cleared for the requested tier. Owners and
|
|
133
|
+
* admins always pass (they can mint any new tier DEK on demand);
|
|
134
|
+
* other roles must already hold the tier DEK — via a prior grant or
|
|
135
|
+
* an active delegation — otherwise this throws `TierNotGrantedError`.
|
|
136
|
+
*
|
|
137
|
+
* This gate runs BEFORE `getDEK()` on the mutation path so a
|
|
138
|
+
* non-cleared operator never has the opportunity to silently
|
|
139
|
+
* auto-create a tier DEK they shouldn't have.
|
|
140
|
+
*/
|
|
141
|
+
declare function assertTierAccess(keyring: UnlockedKeyring, collection: string, tier: number): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Vault-level diff orchestrator.
|
|
145
|
+
*
|
|
146
|
+
* Compares a live `Vault`'s plaintext state against a candidate state
|
|
147
|
+
* (another vault, a plain `{ collection: records[] }` map, or a vault
|
|
148
|
+
* dump JSON) and returns a structured `VaultDiff` plan listing the
|
|
149
|
+
* records that would be added, modified, or deleted to bring the live
|
|
150
|
+
* vault into the candidate's shape.
|
|
151
|
+
*
|
|
152
|
+
* Builds on two existing record-level helpers:
|
|
153
|
+
*
|
|
154
|
+
* 1. `diff(a, b)` from `./history/diff.ts` — emits dot-pathed
|
|
155
|
+
* `DiffEntry[]` with `type: 'added' | 'removed' | 'changed'` for
|
|
156
|
+
* each changed field of two records. Used here for the
|
|
157
|
+
* `fieldDiffs` of every `modified` entry, and (with empty result)
|
|
158
|
+
* as the default deep-equal check.
|
|
159
|
+
*
|
|
160
|
+
* 2. `Vault.exportStream()` from `./vault.ts` — the canonical
|
|
161
|
+
* decrypt-and-stream-records iterator. Used to walk both sides
|
|
162
|
+
* when the candidate is itself a `Vault`. ACL-scoped: collections
|
|
163
|
+
* the caller can't read silently drop out, the same way every
|
|
164
|
+
* other plaintext-emitting export pipeline filters them.
|
|
165
|
+
*
|
|
166
|
+
* The new orchestration is the **vault-level** enumeration: bucket
|
|
167
|
+
* each record id into added (only in candidate), deleted (only in
|
|
168
|
+
* vault), or modified (in both with field changes); leave the
|
|
169
|
+
* field-level granularity to the existing `diff()`.
|
|
170
|
+
*
|
|
171
|
+
* Use cases:
|
|
172
|
+
*
|
|
173
|
+
* - Import preview (`@noy-db/as-*` `fromString` returns a plan
|
|
174
|
+
* whose body is a `VaultDiff`).
|
|
175
|
+
* - Backup verification ("does this `.noydb` bundle from yesterday
|
|
176
|
+
* match the current vault?").
|
|
177
|
+
* - Two-vault reconciliation ("what's different between Office A
|
|
178
|
+
* and Office B before we sync?").
|
|
179
|
+
* - Test assertions (golden-file testing with one-liner
|
|
180
|
+
* `expect(plan.summary).toEqual(...)`).
|
|
181
|
+
*
|
|
182
|
+
* @module
|
|
183
|
+
*/
|
|
184
|
+
|
|
185
|
+
/** Per-record entry shape — added and deleted records carry only the record value. */
|
|
186
|
+
interface VaultDiffEntry<T = unknown> {
|
|
187
|
+
readonly collection: string;
|
|
188
|
+
readonly id: string;
|
|
189
|
+
readonly record: T;
|
|
190
|
+
}
|
|
191
|
+
/** Modified records carry both halves of the diff plus the field-level breakdown. */
|
|
192
|
+
interface VaultDiffModifiedEntry<T = unknown> extends VaultDiffEntry<T> {
|
|
193
|
+
/** The record as it stands in the live vault. */
|
|
194
|
+
readonly before: T;
|
|
195
|
+
/** Top-level keys whose values differ between `before` and `record`. */
|
|
196
|
+
readonly fieldsChanged: readonly string[];
|
|
197
|
+
/**
|
|
198
|
+
* Field-level diff entries from `diff(before, record)`. Reuses the
|
|
199
|
+
* existing per-record diff helper so consumers can render git-style
|
|
200
|
+
* `path: from → to` rows without re-walking the records.
|
|
201
|
+
*/
|
|
202
|
+
readonly fieldDiffs: readonly DiffEntry[];
|
|
203
|
+
}
|
|
204
|
+
interface VaultDiff<T = unknown> {
|
|
205
|
+
readonly added: readonly VaultDiffEntry<T>[];
|
|
206
|
+
readonly modified: readonly VaultDiffModifiedEntry<T>[];
|
|
207
|
+
readonly deleted: readonly VaultDiffEntry<T>[];
|
|
208
|
+
/** Only populated when `options.includeUnchanged: true`. */
|
|
209
|
+
readonly unchanged: readonly VaultDiffEntry<T>[] | undefined;
|
|
210
|
+
readonly summary: {
|
|
211
|
+
readonly add: number;
|
|
212
|
+
readonly modify: number;
|
|
213
|
+
readonly delete: number;
|
|
214
|
+
readonly total: number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Format the diff as a human-readable string.
|
|
218
|
+
*
|
|
219
|
+
* - `'count'` — one line, just the numbers (`12 added · 3 modified · 0 deleted`)
|
|
220
|
+
* - `'one-line'` — count plus a single overview line
|
|
221
|
+
* - `'full'` — count + one row per added/modified/deleted record (default)
|
|
222
|
+
*/
|
|
223
|
+
format(opts?: {
|
|
224
|
+
detail?: 'count' | 'one-line' | 'full';
|
|
225
|
+
}): string;
|
|
226
|
+
}
|
|
227
|
+
interface DiffOptions {
|
|
228
|
+
/** Restrict the diff to a subset of collections. */
|
|
229
|
+
readonly collections?: readonly string[];
|
|
230
|
+
/** Field on each record that carries its id. Defaults to `'id'`. */
|
|
231
|
+
readonly idKey?: string;
|
|
232
|
+
/** Override the default deep-equal check for "modified vs unchanged". */
|
|
233
|
+
readonly compareFn?: (a: unknown, b: unknown) => boolean;
|
|
234
|
+
/** If true, include unchanged records in the diff (off by default to save memory). */
|
|
235
|
+
readonly includeUnchanged?: boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Candidate state to diff the vault against:
|
|
239
|
+
*
|
|
240
|
+
* - A `Vault` instance — both sides are walked via `exportStream()`.
|
|
241
|
+
* - A `Record<collection, records[]>` map — same shape `as-json.toObject()`
|
|
242
|
+
* produces. Useful for diffing parsed file content against the live vault.
|
|
243
|
+
* - A `VaultDump` (output of `vault.dump()`) — a JSON string carrying the
|
|
244
|
+
* full vault state. Parsed and reduced to the map shape above.
|
|
245
|
+
*/
|
|
246
|
+
type DiffCandidate<T = unknown> = Vault | Record<string, readonly T[]> | string;
|
|
247
|
+
/**
|
|
248
|
+
* Compute the diff between a live vault and a candidate state.
|
|
249
|
+
*
|
|
250
|
+
* Returns a fully buffered `VaultDiff` — no streaming. Memory cost is
|
|
251
|
+
* O(n + m) in the row count of vault + candidate. For documented
|
|
252
|
+
* 1K-50K-record vaults this is fine; a streaming variant lands as a
|
|
253
|
+
* follow-up if a > 100K-record consumer arrives.
|
|
254
|
+
*/
|
|
255
|
+
declare function diffVault<T = unknown>(vault: Vault, candidate: DiffCandidate<T>, options?: DiffOptions): Promise<VaultDiff<T>>;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Validate passphrase strength.
|
|
259
|
+
* Checks length and basic entropy heuristics.
|
|
260
|
+
* Throws ValidationError if too weak.
|
|
261
|
+
*/
|
|
262
|
+
declare function validatePassphrase(passphrase: string): void;
|
|
263
|
+
/**
|
|
264
|
+
* Estimate passphrase entropy in bits.
|
|
265
|
+
* Uses character class analysis (not dictionary-based).
|
|
266
|
+
*/
|
|
267
|
+
declare function estimateEntropy(passphrase: string): number;
|
|
268
|
+
|
|
269
|
+
export { type DiffCandidate, DiffEntry, type DiffOptions, UnlockedKeyring, Vault, type VaultDiff, type VaultDiffEntry, type VaultDiffModifiedEntry, assertTierAccess, base64ToBuffer, bufferToBase64, decryptBytes, decryptDeterministic, dekKey, derivePresenceKey, diffVault, effectiveClearance, encryptBytes, encryptDeterministic, estimateEntropy, estimateRecordBytes, parseBytes, validatePassphrase };
|