@cloudbitmaps/core 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +8 -4
  2. package/dist/chunk-7GT632UF.js +641 -0
  3. package/dist/chunk-7GT632UF.js.map +7 -0
  4. package/dist/chunk-CGILDXGP.js +73 -0
  5. package/dist/chunk-CGILDXGP.js.map +7 -0
  6. package/dist/chunk-GKHERVVQ.js +121 -0
  7. package/dist/chunk-GKHERVVQ.js.map +7 -0
  8. package/dist/{chunk-OSU7W2Y3.js → chunk-MVUD4R72.js} +200 -756
  9. package/dist/chunk-MVUD4R72.js.map +7 -0
  10. package/dist/core/audit.d.ts +53 -15
  11. package/dist/core/bit-route.d.ts +2 -0
  12. package/dist/core/blob.d.ts +4 -0
  13. package/dist/core/budget.d.ts +8 -3
  14. package/dist/core/check.d.ts +49 -0
  15. package/dist/core/combine-many.d.ts +11 -0
  16. package/dist/core/consistency.d.ts +11 -2
  17. package/dist/core/cooperative.d.ts +7 -0
  18. package/dist/core/crbm-storage-source.d.ts +7 -4
  19. package/dist/core/crypto.d.ts +5 -0
  20. package/dist/core/discover.d.ts +5 -3
  21. package/dist/core/engine.d.ts +4 -4
  22. package/dist/core/erase-id.d.ts +35 -12
  23. package/dist/core/erasure.d.ts +61 -27
  24. package/dist/core/errors.d.ts +30 -0
  25. package/dist/core/leases.d.ts +2 -0
  26. package/dist/core/load-input.d.ts +48 -0
  27. package/dist/core/load.d.ts +23 -2
  28. package/dist/core/metrics.d.ts +21 -0
  29. package/dist/core/pinned-storage-source.d.ts +27 -8
  30. package/dist/core/pointer-id.d.ts +9 -0
  31. package/dist/core/ports.d.ts +100 -7
  32. package/dist/core/preflight.d.ts +80 -0
  33. package/dist/core/retention-sweep.d.ts +60 -15
  34. package/dist/core/retention.d.ts +17 -6
  35. package/dist/core/retry.d.ts +1 -2
  36. package/dist/core/rollback.d.ts +22 -12
  37. package/dist/core/validate.d.ts +33 -2
  38. package/dist/driver-kit.d.ts +3 -3
  39. package/dist/driver-kit.js +61 -20
  40. package/dist/driver-kit.js.map +2 -2
  41. package/dist/drivers/_shared/object-registry.d.ts +24 -1
  42. package/dist/drivers/_shared/options.d.ts +15 -7
  43. package/dist/drivers/backends.d.ts +17 -2
  44. package/dist/drivers/crypto.d.ts +17 -2
  45. package/dist/export/index.d.ts +16 -2
  46. package/dist/index.d.ts +10 -9
  47. package/dist/index.js +1743 -1701
  48. package/dist/index.js.map +4 -4
  49. package/dist/node.d.ts +14 -0
  50. package/dist/node.js +1064 -0
  51. package/dist/node.js.map +7 -0
  52. package/package.json +11 -2
  53. package/dist/chunk-OSU7W2Y3.js.map +0 -7
@@ -3,7 +3,8 @@ import type { Aead, AeadSealed, IKeystore, WrappedDek } from '../core/crypto.js'
3
3
  * never stored. Nonce-reuse safety: the random-96-bit birthday bound is ~q²/2⁹⁷, negligible below ~2³² seals
4
4
  * under one key. A per-segment DEK is **reused across all generations** (every load and rewrite encrypts under it), so
5
5
  * seal count is cumulative over the segment's life — a segment approaching ~2³² lifetime chunk-seals should be
6
- * re-seeded (a fresh segment ⇒ fresh DEK). Far beyond any realistic workload; noted for completeness. */
6
+ * re-seeded (a fresh segment ⇒ fresh DEK). A segment at the 65,536-chunk maximum reaches it after about 65,500 loads
7
+ * or rewrites (230 days at one every 5 minutes): load into a fresh segment, or load less often, before then. */
7
8
  export declare class NodeAead implements Aead {
8
9
  private readonly key;
9
10
  constructor(key: Uint8Array);
@@ -14,11 +15,18 @@ export declare class NodeAead implements Aead {
14
15
  * Options for {@link InProcessKeystore}. `keys` maps a `keyId` → its 32-byte KEK; `activeKeyId` names the KEK
15
16
  * new DEKs are wrapped under; an optional `recoveryKeyId` additionally wraps each new DEK under a second
16
17
  * (e.g. offline) KEK, so losing the active KEK isn't fatal. Rotating the active KEK needs no data
17
- * re-encryption: add the new KEK, point `activeKeyId` at it, keep the old one to unwrap existing segments.
18
+ * re-encryption: add the new KEK, point `activeKeyId` at it, keep the old one to unwrap existing segments. An option
19
+ * it does not take, such as a misspelt `recoveryKeyId`, throws `ValidationError`.
18
20
  */
19
21
  export interface InProcessKeystoreOptions {
22
+ /** Each key-encryption key (KEK) by its id: 32 bytes each, at least one. */
20
23
  readonly keys: Readonly<Record<string, Uint8Array>>;
24
+ /** The id of the KEK new data keys are wrapped under. It must be in `keys`. */
21
25
  readonly activeKeyId: string;
26
+ /**
27
+ * The id of a second KEK each new data key is also wrapped under, such as an offline one. Absent for none, and the
28
+ * same id as `activeKeyId` means none too; it must be in `keys` when given.
29
+ */
22
30
  readonly recoveryKeyId?: string;
23
31
  }
24
32
  /**
@@ -29,6 +37,13 @@ export declare class InProcessKeystore implements IKeystore {
29
37
  private readonly keys;
30
38
  private readonly activeKeyId;
31
39
  private readonly recoveryKeyId;
40
+ /**
41
+ * Builds a keystore from `options`; throws `ValidationError` for no options object, an option it does not take
42
+ * (a misspelt `recoveryKeyId` would otherwise leave no recovery wrapping), a `keys` that is not an object, an
43
+ * `activeKeyId` or `recoveryKeyId` that is not a string, no keys, a key given as text rather than a
44
+ * `Uint8Array`, a key that is not 32 bytes, or an `activeKeyId` or `recoveryKeyId` that is not in `keys`. A
45
+ * `recoveryKeyId` equal to `activeKeyId` means no recovery key.
46
+ */
32
47
  constructor(options: InProcessKeystoreOptions);
33
48
  createDek(): Promise<{
34
49
  wrapped: WrappedDek[];
@@ -16,8 +16,10 @@ export interface ExportWriter {
16
16
  }
17
17
  /** A destination the export writes each segment to. `ext` is `.roaring` or `.ndjson`. */
18
18
  export interface ExportSink {
19
+ /** Opens the writer for one segment. `ext` is `.roaring` or `.ndjson`, by the export's format. */
19
20
  open(ref: SegmentRef, ext: string): Promise<ExportWriter> | ExportWriter;
20
21
  }
22
+ /** Options of an export: the format, the namespace to scope it to, and the ndjson batch size. */
21
23
  export interface ExportOptions {
22
24
  /** Output format; defaults to `'roaring'`. */
23
25
  readonly format?: ExportFormat;
@@ -28,7 +30,9 @@ export interface ExportOptions {
28
30
  }
29
31
  /** Per-segment result recorded in the {@link ExportManifest}. */
30
32
  export interface ExportedSegment {
33
+ /** The segment's name. */
31
34
  readonly segment: string;
35
+ /** The segment's namespace, or `undefined` for the default one. */
32
36
  readonly namespace?: string;
33
37
  /** Ids written (the segment's effective cardinality at export time). */
34
38
  readonly count: number;
@@ -40,27 +44,37 @@ export interface ExportedSegment {
40
44
  * single corrupt/undecryptable segment never blocks the rest of the dump.
41
45
  */
42
46
  export interface ExportFailure {
47
+ /** The name of the segment that could not be exported. */
43
48
  readonly segment: string;
49
+ /** That segment's namespace, or `undefined` for the default one. */
44
50
  readonly namespace?: string;
45
51
  /** Why it failed (an error message) — e.g. a corrupt storage object, or an encrypted segment with no keystore. */
46
52
  readonly error: string;
47
53
  }
48
54
  /**
49
- * A registered segment the export did not read, and why. `'destroyed'` is a tombstone: the segment was crypto-shredded
50
- * or dropped, so it resolves no generation and has nothing to export.
55
+ * A registered segment the export did not read, and why. `'destroyed'` is a tombstone: the segment was
56
+ * crypto-shredded,
57
+ * destroyed in the clear or dropped, so it resolves no generation and has nothing to export.
51
58
  */
52
59
  export interface ExportSkipped {
60
+ /** The name of the segment that was skipped. */
53
61
  readonly segment: string;
62
+ /** That segment's namespace, or `undefined` for the default one. */
54
63
  readonly namespace?: string;
64
+ /** Why it was skipped: `'destroyed'`, a tombstone. */
55
65
  readonly reason: 'destroyed';
56
66
  }
57
67
  /** What `CloudRoaring.exportSegments` produced — a self-describing summary the CLI persists as `manifest.json`. */
58
68
  export interface ExportManifest {
59
69
  /** Schema version of this manifest shape (currently `1`) — insurance for evolving the format post-1.0. */
60
70
  readonly version: number;
71
+ /** The format the segments were written in. */
61
72
  readonly format: ExportFormat;
73
+ /** How many segments were exported. */
62
74
  readonly totalSegments: number;
75
+ /** How many ids were written, over all segments. */
63
76
  readonly totalIds: number;
77
+ /** One entry for each segment exported. */
64
78
  readonly segments: readonly ExportedSegment[];
65
79
  /**
66
80
  * Segments that could not be read (empty when everything succeeded). Its presence in the manifest is the point:
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  /**
2
2
  * `@cloudbitmaps/core` — the codec-agnostic cloud engine behind the @cloudbitmaps family.
3
3
  *
4
- * Everything here is **independent of any bitmap codec**: the read engine, the SDK-free storage backends, the `.crbm`
4
+ * Everything here is **independent of any bitmap codec**: the read engine, the `.crbm`
5
5
  * format, the loaded store's write path (`loadSegment`: write, guard, publish, collect), encryption/crypto-shred, the registry,
6
6
  * the budget/consistency/eject machinery. Bitmaps are only ever constructed and combined through the
7
7
  * {@link CodecInterface} seam, so a *flavor* package (`@cloudbitmaps/roaring` today) supplies the codec and a
8
8
  * facade on top.
9
9
  *
10
10
  * **This entry is internal.** It is the engine `@cloudbitmaps/roaring` and the storage-driver packages import, and it is
11
- * outside the stability promise: it can change in any minor release, and a change to it gets no CHANGELOG Breaking
11
+ * outside the stability promise: it can change in any release, and a change to it gets no CHANGELOG Breaking
12
12
  * entry. Install `@cloudbitmaps/roaring` and a driver; `@cloudbitmaps/roaring` re-exports, by name, what an application
13
13
  * uses. The public entry of this package is `@cloudbitmaps/core/driver-kit`, the contract for writing a driver.
14
- * Within a minor, this entry changes only additively: a removal or a changed signature waits for the next minor.
14
+ *
15
+ * The drivers that need a Node builtin (the in-memory and local-filesystem backends, the in-process cipher and
16
+ * keystore) are exported by `@cloudbitmaps/core/node`, so nothing this entry reaches imports a `node:*` builtin.
15
17
  *
16
18
  * Nothing in here may import a flavor package — the dependency arrow is one-way (flavor → core), so core stays
17
19
  * publishable on its own and every codec reuses one driver set with zero duplication.
@@ -26,11 +28,10 @@ export { splitId } from './core/bit-route.js';
26
28
  export { mapWithConcurrency } from './core/concurrency.js';
27
29
  export { resolveBudget, resolvePerOpBudget, checkBudget, collectWithinBudget } from './core/budget.js';
28
30
  export { segmentExists, listSegments } from './core/discover.js';
31
+ export { refuseUnknownRefKeys } from './core/validate.js';
29
32
  export type { SegmentInfo } from './core/discover.js';
30
33
  export { segmentKey } from './core/keys.js';
31
34
  export { isStorageBackend } from './core/ports.js';
32
- export { LocalFsStorage, MemoryStorage } from './drivers/backends.js';
33
- export type { LocalFsStorageOptions, MemoryStorageOptions } from './drivers/backends.js';
34
35
  export { CrbmStorageChunkSource } from './core/crbm-storage-source.js';
35
36
  export type { CrbmStorageChunkSourceOptions, PinLease, PinnedObject, } from './core/crbm-storage-source.js';
36
37
  export { LEASE_SKEW_MS, MAX_LEASE_MS, MAX_LEASES_PER_SEGMENT, releaseLease, takeLease, } from './core/leases.js';
@@ -45,21 +46,21 @@ export type { LoadInput, PortableBitmap } from './core/load-input.js';
45
46
  export { decodeSerialized } from './core/load-input.js';
46
47
  export { listGenerations, rollbackSegment } from './core/rollback.js';
47
48
  export type { GenerationListDeps, GenerationEntry, RollbackResult } from './core/rollback.js';
48
- export { eraseIdFromSegment } from './core/erase-id.js';
49
- export type { EraseIdDeps, EraseIdResult } from './core/erase-id.js';
49
+ export { eraseIdFromSegment, findIdUnderTombstone } from './core/erase-id.js';
50
+ export type { EraseIdDeps, EraseIdResult, SearchDeps } from './core/erase-id.js';
50
51
  export type { CodecInterface, CodecBitmap, EncodedChunk } from './core/codec.js';
51
52
  export type { Clock, Entropy, Rng } from './core/determinism.js';
52
53
  export type { SegmentRef, GenerationMetadata } from './core/ports.js';
53
54
  export { CloudRoaringError, ValidationError, WriteConflictError, IntegrityError, NotFoundError, UnsupportedError, CapabilityError, TransientError, KeyUnavailableError, BudgetExceededError, LeaseExpiredError, LeaseLimitError, StaleOperandError, errorKind, } from './core/errors.js';
54
55
  export type { CrbmCrypto } from './core/crypto.js';
55
56
  export { aadFor } from './core/crypto.js';
56
- export { NodeAead, InProcessKeystore } from './drivers/crypto.js';
57
- export type { InProcessKeystoreOptions } from './drivers/crypto.js';
58
57
  export { destroySegment, dropSegment, eraseNamespace } from './core/erasure.js';
59
58
  export type { DropDeps, DropResult, EraseDeps, DestroyResult } from './core/erasure.js';
60
59
  export { setSegmentRetention, clearSegmentRetention, getSegmentRetention, readRetentionPolicy, MIN_EXPIRES_AT_MS, } from './core/retention.js';
61
60
  export type { RetentionPolicy, RetentionDeps, SetRetentionResult } from './core/retention.js';
62
61
  export { retireExpired } from './core/retention-sweep.js';
62
+ export { runPreflight } from './core/preflight.js';
63
+ export type { PreflightCheck, PreflightDeps, PreflightResult } from './core/preflight.js';
63
64
  export { excludingReservedRows } from './core/registry-scan.js';
64
65
  export type { RetireExpiredOptions, RetireExpiredResult, RetireEntry, } from './core/retention-sweep.js';
65
66
  export { DEFAULT_BUDGET } from './core/budget.js';