@cloudbitmaps/core 0.1.0-rc.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.
- package/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +22 -0
- package/dist/azure/index.cjs +368 -0
- package/dist/azure/index.cjs.map +1 -0
- package/dist/azure/index.d.cts +48 -0
- package/dist/azure/index.d.ts +48 -0
- package/dist/azure/index.js +304 -0
- package/dist/azure/index.js.map +1 -0
- package/dist/cassandra/index.cjs +265 -0
- package/dist/cassandra/index.cjs.map +1 -0
- package/dist/cassandra/index.d.cts +52 -0
- package/dist/cassandra/index.d.ts +52 -0
- package/dist/cassandra/index.js +204 -0
- package/dist/cassandra/index.js.map +1 -0
- package/dist/chunk-2YDULGXS.js +203 -0
- package/dist/chunk-2YDULGXS.js.map +1 -0
- package/dist/chunk-7LMLYSVJ.js +43 -0
- package/dist/chunk-7LMLYSVJ.js.map +1 -0
- package/dist/chunk-AS6ODRLT.js +6 -0
- package/dist/chunk-AS6ODRLT.js.map +1 -0
- package/dist/chunk-NUIDEEFZ.js +91 -0
- package/dist/chunk-NUIDEEFZ.js.map +1 -0
- package/dist/chunk-SNJVZ227.js +35 -0
- package/dist/chunk-SNJVZ227.js.map +1 -0
- package/dist/dynamodb/index.cjs +731 -0
- package/dist/dynamodb/index.cjs.map +1 -0
- package/dist/dynamodb/index.d.cts +106 -0
- package/dist/dynamodb/index.d.ts +106 -0
- package/dist/dynamodb/index.js +460 -0
- package/dist/dynamodb/index.js.map +1 -0
- package/dist/gcs/index.cjs +343 -0
- package/dist/gcs/index.cjs.map +1 -0
- package/dist/gcs/index.d.cts +46 -0
- package/dist/gcs/index.d.ts +46 -0
- package/dist/gcs/index.js +279 -0
- package/dist/gcs/index.js.map +1 -0
- package/dist/index.cjs +4031 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1945 -0
- package/dist/index.d.ts +1945 -0
- package/dist/index.js +3642 -0
- package/dist/index.js.map +1 -0
- package/dist/mongodb/index.cjs +260 -0
- package/dist/mongodb/index.cjs.map +1 -0
- package/dist/mongodb/index.d.cts +45 -0
- package/dist/mongodb/index.d.ts +45 -0
- package/dist/mongodb/index.js +199 -0
- package/dist/mongodb/index.js.map +1 -0
- package/dist/mysql/index.cjs +281 -0
- package/dist/mysql/index.cjs.map +1 -0
- package/dist/mysql/index.d.cts +56 -0
- package/dist/mysql/index.d.ts +56 -0
- package/dist/mysql/index.js +211 -0
- package/dist/mysql/index.js.map +1 -0
- package/dist/ports-D3BrJ6ax.d.cts +357 -0
- package/dist/ports-D3BrJ6ax.d.ts +357 -0
- package/dist/postgres/index.cjs +273 -0
- package/dist/postgres/index.cjs.map +1 -0
- package/dist/postgres/index.d.cts +54 -0
- package/dist/postgres/index.d.ts +54 -0
- package/dist/postgres/index.js +203 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/redis/index.cjs +257 -0
- package/dist/redis/index.cjs.map +1 -0
- package/dist/redis/index.d.cts +42 -0
- package/dist/redis/index.d.ts +42 -0
- package/dist/redis/index.js +197 -0
- package/dist/redis/index.js.map +1 -0
- package/dist/s3/index.cjs +891 -0
- package/dist/s3/index.cjs.map +1 -0
- package/dist/s3/index.d.cts +112 -0
- package/dist/s3/index.d.ts +112 -0
- package/dist/s3/index.js +555 -0
- package/dist/s3/index.js.map +1 -0
- package/package.json +172 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/drivers/s3/keys.ts","../../src/drivers/s3/s3-errors.ts","../../src/drivers/s3/cold.ts","../../src/drivers/s3/registry.ts"],"names":["res","ListObjectsV2Command","GetObjectCommand","PutObjectCommand"],"mappings":";;;;;;;;AAcA,IAAM,MAAA,GAAS,OAAA;AACf,IAAM,eAAA,GAAkB,MAAA;AAGxB,SAAS,WAAW,MAAA,EAAoC;AACtD,EAAA,IAAI,MAAA,KAAW,QAAW,OAAO,EAAA;AACjC,EAAA,MAAM,OAAA,GAAU,MAAA,CAA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* Pure string logic with no SDK dependency, so it's unit-testable without S3/MinIO. Mirrors the LocalFs\n * layout (`<namespace>/segments/<segment>.<gen>.crbm`) under an optional caller prefix, and re-validates\n * names at the boundary (defense in depth, even though the engine already validates — S2). The default\n * (absent) namespace maps to `_default`, which can't collide with a real namespace (the grammar forbids a\n * leading underscore).\n */\nimport { ValidationError } from '@/core/errors';\nimport { validateSegmentRef } from '@/core/validate';\nimport type { GenKey, SegmentRef } from '@/core/ports';\nimport { DEFAULT_NAMESPACE, namespacePart } from '../_shared/keys';\n\nconst SUFFIX = '.crbm';\nconst REGISTRY_SUFFIX = '.reg';\n\n/** Normalize an optional caller prefix to either `''` or `trimmed/` (no leading/trailing slashes). */\nfunction prefixPart(prefix: string | undefined): string {\n if (prefix === undefined) return '';\n const trimmed = prefix.replace(/^\\/+|\\/+$/g, '');\n return trimmed === '' ? '' : `${trimmed}/`;\n}\n\n/**\n * Validate the caller-supplied key prefix (trusted config, but make it a real containment boundary):\n * reject control characters and `.`/`..` path segments so a prefix can't traverse out of its intended space.\n * Returns it unchanged (the key builders normalize slashes). Shared by the S3 cold + registry drivers.\n */\nexport function normalizeS3Prefix(prefix: string | undefined): string | undefined {\n if (prefix === undefined) return undefined;\n for (const ch of prefix) {\n if (ch.charCodeAt(0) < 0x20) {\n throw new ValidationError('prefix must not contain control characters');\n }\n }\n for (const segment of prefix.split('/')) {\n if (segment === '.' || segment === '..') {\n throw new ValidationError(\n `prefix must not contain \".\" or \"..\" path segments: ${JSON.stringify(prefix)}`,\n );\n }\n }\n return prefix;\n}\n\n/**\n * The S3 key prefix shared by all of a segment's generations: `<prefix><ns>/segments/<segment>.`. Used\n * both as the `ListObjectsV2` prefix and as the string stripped by {@link parseGenerationFromKey}.\n */\nexport function segmentObjectPrefix(prefix: string | undefined, ref: SegmentRef): string {\n validateSegmentRef(ref);\n return `${prefixPart(prefix)}${namespacePart(ref.namespace)}/segments/${ref.segment}.`;\n}\n\n/** The full S3 key of one `.crbm` generation: `<segmentPrefix><gen>.crbm`. */\nexport function coldObjectKey(prefix: string | undefined, key: GenKey): string {\n if (!Number.isInteger(key.generation) || key.generation < 0) {\n throw new ValidationError(`generation must be a non-negative integer; got ${key.generation}`);\n }\n return `${segmentObjectPrefix(prefix, key)}${key.generation}${SUFFIX}`;\n}\n\n// ─── Registry keys ({@link S3RegistryDriver}) ───────────────────────────────────────────────────────────\n// Registry objects live under a **registry-first** prefix (`<prefix>registry/<ns>/<segment>.reg`) — separate\n// from the namespace-first cold layout — so discovery is a single `ListObjectsV2` over `registry/` (all\n// namespaces) or `registry/<ns>/` (one), never entangled with the `.crbm` payload objects.\n\n/** The S3 key prefix under which every registry object lives: `<prefix>registry/`. */\nexport function registryPrefix(prefix: string | undefined): string {\n return `${prefixPart(prefix)}registry/`;\n}\n\n/** The full S3 key of one segment's registry object: `<prefix>registry/<ns>/<segment>.reg`. */\nexport function registryObjectKey(prefix: string | undefined, ref: SegmentRef): string {\n validateSegmentRef(ref);\n return `${registryPrefix(prefix)}${namespacePart(ref.namespace)}/${ref.segment}${REGISTRY_SUFFIX}`;\n}\n\n/** The `ListObjectsV2` prefix for discovery: registry-wide, or scoped to one namespace. */\nexport function registryListPrefix(prefix: string | undefined, namespace?: string): string {\n const base = registryPrefix(prefix);\n return namespace === undefined ? base : `${base}${namespacePart(namespace)}/`;\n}\n\n/**\n * Parse a `<prefix>registry/<ns>/<segment>.reg` key back to its {@link SegmentRef}, or `null` if it doesn't\n * match (a stray/foreign object under the prefix, or one whose parsed ref fails the name grammar). `_default`\n * maps back to the absent namespace; a segment name can't contain `/`, so the split is unambiguous.\n */\nexport function parseRegistryKey(prefix: string | undefined, objectKey: string): SegmentRef | null {\n const base = registryPrefix(prefix);\n if (!objectKey.startsWith(base) || !objectKey.endsWith(REGISTRY_SUFFIX)) return null;\n const rest = objectKey.slice(base.length, objectKey.length - REGISTRY_SUFFIX.length);\n const slash = rest.indexOf('/');\n if (slash < 0) return null;\n const nsPart = rest.slice(0, slash);\n const segment = rest.slice(slash + 1);\n if (segment.length === 0 || segment.includes('/')) return null;\n const namespace = nsPart === DEFAULT_NAMESPACE ? undefined : nsPart;\n const ref: SegmentRef = { segment, namespace };\n try {\n validateSegmentRef(ref); // reject a hostile/foreign key that isn't a valid ref\n } catch {\n return null;\n }\n return ref;\n}\n\n/**\n * Parse a generation number out of a full object key, given its segment prefix, or `null` if it doesn't\n * match. Canonical decimal only — no leading zeros (so `…s.07.crbm` can't alias `…s.7.crbm`) and within\n * safe-integer range. This also rejects a *different* segment whose name merely shares the prefix (e.g. a\n * key for segment `s.x` won't parse under segment `s`'s prefix, since its middle isn't all digits).\n */\nexport function parseGenerationFromKey(segmentPrefix: string, objectKey: string): number | null {\n if (!objectKey.startsWith(segmentPrefix) || !objectKey.endsWith(SUFFIX)) return null;\n const middle = objectKey.slice(segmentPrefix.length, objectKey.length - SUFFIX.length);\n if (!/^(0|[1-9]\\d*)$/.test(middle)) return null;\n const generation = Number(middle);\n return Number.isSafeInteger(generation) ? generation : null;\n}\n","/**\n * Pure helpers for classifying S3 SDK errors + parsing response headers (Phase 3c; transient class 4b).\n *\n * Kept SDK-free and side-effect-free (they only read structural shapes — `err.name`,\n * `$metadata.httpStatusCode`, a `Content-Range` string) so the subtle S3-specific translation logic is\n * unit-testable without a live MinIO/S3 or even the AWS SDK. Shared AWS shapes come from `_shared/aws-errors`.\n */\nimport {\n errorName,\n httpStatus,\n isNetworkOrTimeout,\n isSdkRetryable,\n isServerSide,\n} from '../_shared/aws-errors';\n\n/** A conditional `If-None-Match: *` PUT lost the write-once race (the object already existed). */\nexport function isPreconditionFailed(err: unknown): boolean {\n return errorName(err) === 'PreconditionFailed' || httpStatus(err) === 412;\n}\n\n/**\n * A conditional write (`If-None-Match: *` / `If-Match: <etag>`) lost the race — **either** outcome S3 uses:\n * the precondition evaluated false (`412 PreconditionFailed`), **or** S3 rejected concurrent conditional\n * writes to the same key to prevent a lost update (`409 ConditionalRequestConflict`, which AWS documents and\n * asks you to retry). Both mean \"you lost; re-read and retry\" — so both must map to `WriteConflictError` and\n * route through the caller's OCC path, never a blind transient retry (which would just replay a doomed PUT).\n */\nexport function isConditionalConflict(err: unknown): boolean {\n return (\n isPreconditionFailed(err) ||\n errorName(err) === 'ConditionalRequestConflict' ||\n httpStatus(err) === 409\n );\n}\n\n/** The object / generation does not exist (GetObject → `NoSuchKey`, HeadObject → `NotFound`; both 404). */\nexport function isNotFound(err: unknown): boolean {\n const name = errorName(err);\n return name === 'NoSuchKey' || name === 'NotFound' || httpStatus(err) === 404;\n}\n\n/** A range request started past EOF (HTTP 416). */\nexport function isInvalidRange(err: unknown): boolean {\n return errorName(err) === 'InvalidRange' || httpStatus(err) === 416;\n}\n\n/**\n * A transient S3 fault that is safe to retry: throttling (`SlowDown` / 503), any 5xx, a dropped/timed-out\n * connection, or anything the SDK itself marks retryable. Excludes the deterministic outcomes above\n * (412/404/416) — those are caller-meaningful and must never be retried/reclassified.\n */\nexport function isTransient(err: unknown): boolean {\n // A conditional-write conflict (412/409) is caller-meaningful OCC, not a blind-retryable transient.\n if (isConditionalConflict(err) || isNotFound(err) || isInvalidRange(err)) return false;\n return (\n errorName(err) === 'SlowDown' ||\n isServerSide(err) ||\n isNetworkOrTimeout(err) ||\n isSdkRetryable(err)\n );\n}\n\n/**\n * Parse the total object size out of a `Content-Range: bytes <start>-<end>/<total>` header, or `undefined`\n * if absent/unparseable/unsafe. The total is the part after the final `/`.\n */\nexport function totalFromContentRange(contentRange: string | undefined): number | undefined {\n if (contentRange === undefined) return undefined;\n const match = /\\/(\\d+)\\s*$/.exec(contentRange);\n if (match === null) return undefined;\n const total = Number(match[1]);\n return Number.isSafeInteger(total) ? total : undefined;\n}\n","/**\n * `S3ColdDriver` — an {@link IColdDriver} over S3-compatible object storage (Phase 3c).\n *\n * Works with AWS S3 and any compatible backend (MinIO, etc.) via the official `@aws-sdk/client-s3`, which\n * is an **optional peer dependency** — only consumers of `cloud-roaring/s3` install it. The client is\n * **injected** (dependency injection): the driver owns no credential/region/endpoint logic, so it's thin,\n * testable against MinIO (point a client at its endpoint), and reuses the caller's existing client.\n *\n * Generations are write-once immutable objects: a conditional `PutObject` with `If-None-Match: *` makes the\n * publish atomic — a second write to the same key fails with `WriteConflictError`, never a silent overwrite\n * (C13), the cloud analogue of the LocalFs atomic `link`. **This requires a backend that honors\n * `If-None-Match: *`** (AWS S3 — GA Aug 2024; recent MinIO): a backend that silently ignored the\n * precondition would break write-once immutability. **Writes stream (Phase 4f):** the object is uploaded in\n * constant memory — a small object is a single conditional `PutObject`; a large one is a **multipart upload**\n * (parts flushed as the codec writes, freed as they go) finished with a conditional `CompleteMultipartUpload`,\n * so the daemon's footprint stays ~one part regardless of segment size, up to the advertised `maxObjectBytes`\n * (default `partBytes × 10,000` — S3's per-upload part limit). Drivers may use `node:crypto`; only `core/`\n * is bound by the determinism lint.\n */\nimport { createHash, type Hash } from 'node:crypto';\nimport {\n AbortMultipartUploadCommand,\n CompleteMultipartUploadCommand,\n CreateMultipartUploadCommand,\n DeleteObjectCommand,\n GetObjectCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n PutObjectCommand,\n UploadPartCommand,\n type S3Client,\n} from '@aws-sdk/client-s3';\nimport type { BlobSink } from '@/core/blob';\nimport {\n NotFoundError,\n TransientError,\n ValidationError,\n WriteConflictError,\n isNotFoundError,\n isValidationError,\n isWriteConflictError,\n} from '@/core/errors';\nimport type { ColdCaps, GenKey, IColdDriver, SegmentRef } from '@/core/ports';\nimport {\n coldObjectKey,\n normalizeS3Prefix,\n parseGenerationFromKey,\n segmentObjectPrefix,\n} from './keys';\nimport {\n isConditionalConflict,\n isInvalidRange,\n isNotFound,\n isTransient,\n totalFromContentRange,\n} from './s3-errors';\n\n/** Part size for multipart uploads. ≥ the S3 5 MiB minimum; an object that fits in one part uses a single\n * conditional PUT instead (no multipart overhead, strongest write-once). Peak write memory ≈ one part. */\nconst S3_PART_BYTES = 8 * 1024 * 1024;\n/** S3 hard limit: a multipart upload has at most 10,000 parts. This × the part size is the real object ceiling. */\nconst S3_MAX_PARTS = 10_000;\n\nexport interface S3ColdDriverOptions {\n /** A constructed S3 client (point its `endpoint` at MinIO for local/integration use). */\n readonly client: S3Client;\n /** Target bucket (must already exist). */\n readonly bucket: string;\n /** Optional key prefix under which all objects live (e.g. `cloudroaring/`). */\n readonly prefix?: string;\n /**\n * Largest object this driver will write/advertise. Default = `partBytes × 10,000` (≈ 80 GiB at the default\n * 8 MiB part) — the honest ceiling reachable within S3's 10,000-part limit. Set it higher and `partBytes`\n * auto-grows so 10,000 parts still cover it (raising peak write memory to ~one part); up to the 5 TiB S3 max.\n */\n readonly maxObjectBytes?: number;\n /** Multipart part size in bytes (default 8 MiB; clamped to the S3 5 MiB minimum). Tunes peak write memory. */\n readonly partBytes?: number;\n}\n\nexport class S3ColdDriver implements IColdDriver {\n private readonly client: S3Client;\n private readonly bucket: string;\n private readonly prefix: string | undefined;\n private readonly maxObjectBytes: number;\n private readonly partBytes: number;\n\n constructor(options: S3ColdDriverOptions) {\n this.client = options.client;\n this.bucket = options.bucket;\n this.prefix = normalizeS3Prefix(options.prefix);\n const requestedPart = Math.max(options.partBytes ?? S3_PART_BYTES, 5 * 1024 * 1024);\n // Default the object cap to what the requested part size can actually cover within S3's 10,000-part limit;\n // if a larger cap is requested, grow the part size to keep it reachable (so the advertised cap is honest).\n this.maxObjectBytes = options.maxObjectBytes ?? requestedPart * S3_MAX_PARTS;\n this.partBytes = Math.max(requestedPart, Math.ceil(this.maxObjectBytes / S3_MAX_PARTS));\n }\n\n capabilities(): ColdCaps {\n return { rangeRead: true, maxObjectBytes: this.maxObjectBytes, conditionalPut: true };\n }\n\n async putImmutable(\n key: GenKey,\n write: (sink: BlobSink) => Promise<void>,\n ): Promise<{ size: number; sha256: string }> {\n const objectKey = coldObjectKey(this.prefix, key); // validates ref + generation\n const sink = new S3MultipartSink(\n this.client,\n this.bucket,\n objectKey,\n this.partBytes,\n this.maxObjectBytes,\n );\n try {\n await write(sink);\n return await sink.finish();\n } catch (err) {\n await sink.abort(); // best-effort cleanup of any in-flight multipart upload\n // A lost conditional-write race — the precondition failed (412) or S3 rejected concurrent conditional\n // writes to the key (409) — is the write-once conflict, never a silent overwrite.\n if (isConditionalConflict(err)) {\n throw new WriteConflictError(\n `generation already exists (write-once): ${key.segment}.${key.generation}`,\n );\n }\n if (isValidationError(err) || isWriteConflictError(err) || isNotFoundError(err)) {\n throw err;\n }\n throw this.mapError(err);\n }\n }\n\n async getRange(key: GenKey, offset: number, length: number): Promise<Uint8Array> {\n if (!Number.isInteger(offset) || !Number.isInteger(length) || offset < 0 || length < 0) {\n throw new ValidationError(`invalid range offset=${offset} length=${length}`);\n }\n const objectKey = coldObjectKey(this.prefix, key);\n if (length === 0) return new Uint8Array(0);\n try {\n const res = await this.client.send(\n new GetObjectCommand({\n Bucket: this.bucket,\n Key: objectKey,\n Range: `bytes=${offset}-${offset + length - 1}`,\n }),\n );\n const bytes = await collect(res.Body);\n // A short read means the range ran past EOF — treat as out-of-bounds, never a partial result.\n if (bytes.length !== length) {\n throw new ValidationError(\n `range [${offset}, ${offset + length}) out of bounds (got ${bytes.length}B)`,\n );\n }\n return bytes;\n } catch (err) {\n throw this.mapReadError(err, key);\n }\n }\n\n async getTail(key: GenKey, maxBytes: number): Promise<{ bytes: Uint8Array; size: number }> {\n const objectKey = coldObjectKey(this.prefix, key);\n if (maxBytes <= 0) {\n // No tail bytes wanted — just resolve the size via a HEAD.\n try {\n const head = await this.client.send(\n new HeadObjectCommand({ Bucket: this.bucket, Key: objectKey }),\n );\n return { bytes: new Uint8Array(0), size: head.ContentLength ?? 0 };\n } catch (err) {\n throw this.mapReadError(err, key);\n }\n }\n try {\n const res = await this.client.send(\n new GetObjectCommand({ Bucket: this.bucket, Key: objectKey, Range: `bytes=-${maxBytes}` }),\n );\n const bytes = await collect(res.Body);\n let size = totalFromContentRange(res.ContentRange);\n if (size === undefined) {\n // A spec-compliant backend omits Content-Range only on a 200 (whole object), where bytes.length\n // IS the size. If the body is exactly maxBytes we can't rule out a clamped partial from a\n // non-compliant backend — confirm the true size with a HEAD rather than trust a possibly-short read.\n if (bytes.length === maxBytes) {\n const head = await this.client.send(\n new HeadObjectCommand({ Bucket: this.bucket, Key: objectKey }),\n );\n size = head.ContentLength ?? bytes.length;\n } else {\n size = bytes.length;\n }\n }\n return { bytes, size };\n } catch (err) {\n throw this.mapReadError(err, key);\n }\n }\n\n async delete(key: GenKey): Promise<void> {\n // Idempotent: S3 DeleteObject succeeds even if the key is absent (GC may race / retry).\n try {\n await this.client.send(\n new DeleteObjectCommand({ Bucket: this.bucket, Key: coldObjectKey(this.prefix, key) }),\n );\n } catch (err) {\n throw this.mapError(err);\n }\n }\n\n async *list(ref: SegmentRef): AsyncIterable<GenKey> {\n const prefix = segmentObjectPrefix(this.prefix, ref); // validates ref\n let token: string | undefined;\n do {\n let res;\n try {\n res = await this.client.send(\n new ListObjectsV2Command({\n Bucket: this.bucket,\n Prefix: prefix,\n ContinuationToken: token,\n }),\n );\n } catch (err) {\n throw this.mapError(err);\n }\n for (const obj of res.Contents ?? []) {\n if (obj.Key === undefined) continue;\n const generation = parseGenerationFromKey(prefix, obj.Key);\n if (generation !== null) {\n yield { namespace: ref.namespace, segment: ref.segment, generation };\n }\n }\n token = res.IsTruncated === true ? res.NextContinuationToken : undefined;\n } while (token !== undefined);\n }\n\n /** Map S3 read errors to the driver vocabulary; pass everything else through {@link mapError}. */\n private mapReadError(err: unknown, key: GenKey): unknown {\n if (isValidationError(err)) return err;\n if (isNotFound(err)) {\n return new NotFoundError(`no such generation: ${key.segment}.${key.generation}`);\n }\n // A fully out-of-range request (start past EOF) — the BlobReader contract treats range errors as\n // ValidationError, never a short/empty read.\n if (isInvalidRange(err)) {\n return new ValidationError(`range out of bounds for ${key.segment}.${key.generation}`);\n }\n return this.mapError(err);\n }\n\n /**\n * Reclassify a transient S3 fault (throttle/5xx/dropped connection) as a retryable {@link TransientError}\n * so the retry decorator can ride it out; everything else propagates unchanged. The final fallback at every\n * `client.send` site, so callers and the decorator only ever see typed errors.\n */\n private mapError(err: unknown): unknown {\n if (isTransient(err)) {\n return new TransientError(\n `transient S3 fault: ${(err as { name?: string } | null)?.name ?? 'unknown'}`,\n { cause: err },\n );\n }\n return err;\n }\n}\n\n/** Concatenate a list of byte chunks of known total length into one buffer. */\nfunction concatBytes(parts: readonly Uint8Array[], total: number): Uint8Array {\n const out = new Uint8Array(total);\n let offset = 0;\n for (const p of parts) {\n out.set(p, offset);\n offset += p.length;\n }\n return out;\n}\n\n/**\n * Streaming {@link BlobSink} that uploads one S3 object in **constant memory** (Phase 4f). It buffers at most\n * one part: as the codec writes, full parts are flushed via `UploadPart` and freed. A small object that never\n * reaches one part is committed as a single conditional `PutObject`; a larger one is finished with a\n * conditional `CompleteMultipartUpload` — **both enforce write-once** via `If-None-Match: *`. SHA-256 is hashed\n * incrementally. On any error the caller invokes {@link abort} to clean up the in-flight multipart upload.\n */\nclass S3MultipartSink implements BlobSink {\n private readonly hash: Hash = createHash('sha256');\n private readonly pending: Uint8Array[] = [];\n private pendingLen = 0;\n private total = 0;\n private uploadId: string | undefined;\n private partNumber = 0;\n private readonly parts: { ETag: string | undefined; PartNumber: number }[] = [];\n\n constructor(\n private readonly client: S3Client,\n private readonly bucket: string,\n private readonly objectKey: string,\n private readonly partBytes: number,\n private readonly maxObjectBytes: number,\n ) {}\n\n async write(bytes: Uint8Array): Promise<void> {\n if (bytes.length === 0) return;\n this.total += bytes.length;\n if (this.total > this.maxObjectBytes) {\n // Fail fast + typed, rather than a late opaque S3 error (and abort the in-flight upload via the caller).\n throw new ValidationError(`object exceeds maxObjectBytes ${this.maxObjectBytes}`);\n }\n this.hash.update(bytes);\n this.pending.push(bytes);\n this.pendingLen += bytes.length;\n if (this.pendingLen >= this.partBytes) await this.flushPart();\n }\n\n /** Upload the buffered bytes (≥ one part) as a single part, freeing them. Starts the upload on first call. */\n private async flushPart(): Promise<void> {\n if (this.uploadId === undefined) {\n const res = await this.client.send(\n new CreateMultipartUploadCommand({ Bucket: this.bucket, Key: this.objectKey }),\n );\n if (res.UploadId === undefined) {\n throw new TransientError('S3 CreateMultipartUpload returned no UploadId');\n }\n this.uploadId = res.UploadId;\n }\n const body = concatBytes(this.pending, this.pendingLen);\n this.pending.length = 0;\n this.pendingLen = 0;\n this.partNumber += 1;\n if (this.partNumber > S3_MAX_PARTS) {\n // Unreachable for valid input (the maxObjectBytes byte-cap, sized to ≤ S3_MAX_PARTS parts, fires first) —\n // a typed guard so the S3 hard limit is never a raw 400.\n throw new ValidationError(`multipart upload exceeded the S3 ${S3_MAX_PARTS}-part limit`);\n }\n const res = await this.client.send(\n new UploadPartCommand({\n Bucket: this.bucket,\n Key: this.objectKey,\n UploadId: this.uploadId,\n PartNumber: this.partNumber,\n Body: body,\n }),\n );\n this.parts.push({ ETag: res.ETag, PartNumber: this.partNumber });\n }\n\n /** Commit the object: a single conditional PUT if it fit in one part, else complete the multipart upload. */\n async finish(): Promise<{ size: number; sha256: string }> {\n const sha256 = this.hash.digest('hex');\n if (this.uploadId === undefined) {\n await this.client.send(\n new PutObjectCommand({\n Bucket: this.bucket,\n Key: this.objectKey,\n Body: concatBytes(this.pending, this.pendingLen),\n IfNoneMatch: '*', // write-once\n }),\n );\n return { size: this.total, sha256 };\n }\n if (this.pendingLen > 0) await this.flushPart(); // the final part may be < partBytes (allowed)\n await this.client.send(\n new CompleteMultipartUploadCommand({\n Bucket: this.bucket,\n Key: this.objectKey,\n UploadId: this.uploadId,\n MultipartUpload: { Parts: this.parts },\n IfNoneMatch: '*', // write-once: fail if the object already exists\n }),\n );\n this.uploadId = undefined; // completed — nothing left to abort\n return { size: this.total, sha256 };\n }\n\n /** Best-effort cleanup of an in-flight multipart upload after an error (a leaked MPU is reaped by a bucket\n * lifecycle rule; never a correctness issue). No-op if nothing was started or it already completed. */\n async abort(): Promise<void> {\n if (this.uploadId === undefined) return;\n const id = this.uploadId;\n this.uploadId = undefined;\n try {\n await this.client.send(\n new AbortMultipartUploadCommand({ Bucket: this.bucket, Key: this.objectKey, UploadId: id }),\n );\n } catch {\n // swallow — best-effort\n }\n }\n}\n\n/**\n * Collect an S3 response body into a `Uint8Array`. `transformToByteArray` is added at runtime to the SDK's\n * Node stream by `@aws-sdk`'s sdk-stream-mixin, so the structural cast is sound on Node.\n */\nasync function collect(body: GetObjectCommandBody): Promise<Uint8Array> {\n if (body === undefined) {\n throw new NotFoundError('S3 GetObject returned an empty body');\n }\n return body.transformToByteArray();\n}\n\n/** The S3 `GetObject` Body type, narrowed to the part we use (`transformToByteArray`). */\ntype GetObjectCommandBody = { transformToByteArray(): Promise<Uint8Array> } | undefined;\n","/**\n * `S3RegistryDriver` — an {@link IRegistryDriver} over S3-compatible object storage (Phase 7).\n *\n * Lets a **read-mostly deployment run on S3 alone** — cold `.crbm` generations + the registry in one bucket,\n * no DynamoDB. One tiny JSON object per segment at `<prefix>registry/<ns>/<segment>.reg` holding the\n * `{ deleted, record }` envelope (the same shape LocalFs persists). The OCC token is a monotonic counter,\n * advanced on every mutation and even across a `delete` (which **tombstones** rather than removes the object)\n * so a deleted-then-recreated row never re-issues an old token (ABA-safe) — identical semantics to the\n * LocalFs + DynamoDB registries, so it passes the same conformance suite.\n *\n * **The atomic swap is offloaded to S3's conditional writes** (GA Nov 2024): `create` uses `If-None-Match: *`\n * (write-once, or `If-Match` over a tombstone), and `compareAndSwap`/`delete` use `If-Match: <etag>` so a\n * concurrent writer between our read and our PUT loses with a `412` → {@link WriteConflictError}. No in-process\n * lock is needed (unlike LocalFs) — the ETag precondition fences writers *across processes*. Reads are\n * strongly consistent (S3, since 2020), satisfying the registry's `strongRead` contract. The client is\n * **injected**, exactly like {@link S3ColdDriver}.\n *\n * **Deployment requirements** (a backend/policy that violates these silently corrupts the registry):\n * - The backend **must honor `If-Match`** (AWS S3; recent MinIO). One that returns ETags but ignores the\n * precondition degrades compare-and-swap to last-write-wins → lost `currentGen` swaps. Verified against real\n * S3 semantics by the MinIO integration lane.\n * - The IAM principal needs **`s3:ListBucket`** on the bucket. Without it, `GetObject` on a missing key returns\n * `403` (not `404`), so the \"absent segment → `null`\" contract (and `create`'s bootstrap read) breaks — and\n * `list()` needs it regardless.\n * - **Do not apply an S3 lifecycle-expiration rule to the `registry/` prefix.** `delete` tombstones (keeps the\n * object with an advanced counter) for ABA-safety; expiring a tombstone would let a recreate reset the token\n * to 0 and re-issue a stale one.\n */\nimport {\n GetObjectCommand,\n ListObjectsV2Command,\n PutObjectCommand,\n type S3Client,\n} from '@aws-sdk/client-s3';\nimport {\n IntegrityError,\n TransientError,\n ValidationError,\n WriteConflictError,\n isWriteConflictError,\n} from '@/core/errors';\nimport type {\n IRegistryDriver,\n NewRegistryRecord,\n RegCaps,\n RegistryPatch,\n RegistryRecord,\n SegmentRef,\n Token,\n} from '@/core/ports';\nimport {\n applyRegistryPatch,\n parseRegistryEnvelope,\n recordFromNew,\n registryCounterOf,\n serializeRegistryEnvelope,\n validateNewRegistryRecord,\n validateRegistryPatch,\n type RegistryEnvelope,\n} from '../_shared/registry';\nimport { normalizeS3Prefix, parseRegistryKey, registryListPrefix, registryObjectKey } from './keys';\nimport { isConditionalConflict, isNotFound, isTransient } from './s3-errors';\nimport { mapWithConcurrency } from '@/core/concurrency';\n\n/** Defensive cap on a single registry object read from storage, before allocation (rows are tiny; ~1 KB). */\nconst MAX_ROW_BYTES = 1 * 1024 * 1024;\n/** Bounded retry for `delete`'s read→tombstone under cross-process contention (converges; then fails typed). */\nconst MAX_DELETE_ATTEMPTS = 8;\n/** In-flight `readRow` GETs per `list()` page — turns the serial N+1 into one LIST + bounded parallel GETs. */\nconst LIST_READ_CONCURRENCY = 16;\n\n/** A conditional-write precondition: exactly one of write-once (`If-None-Match: *`) or CAS (`If-Match: etag`). */\ntype PutCondition = { readonly ifNoneMatch: '*' } | { readonly ifMatch: string };\n\nexport interface S3RegistryDriverOptions {\n /** A constructed S3 client (point its `endpoint` at MinIO for local/integration use). */\n readonly client: S3Client;\n /** Target bucket (must already exist). */\n readonly bucket: string;\n /** Optional key prefix under which all registry objects live (e.g. `cloudroaring/`). */\n readonly prefix?: string;\n /** Injected clock for `createdAt`/`updatedAt`; defaults to `Date.now`. */\n readonly now?: () => number;\n}\n\nexport class S3RegistryDriver implements IRegistryDriver {\n private readonly client: S3Client;\n private readonly bucket: string;\n private readonly prefix: string | undefined;\n private readonly now: () => number;\n\n constructor(options: S3RegistryDriverOptions) {\n this.client = options.client;\n this.bucket = options.bucket;\n this.prefix = normalizeS3Prefix(options.prefix);\n this.now = options.now ?? ((): number => Date.now());\n }\n\n capabilities(): RegCaps {\n return { strongRead: true };\n }\n\n async get(ref: SegmentRef): Promise<RegistryRecord | null> {\n const current = await this.readRow(registryObjectKey(this.prefix, ref));\n return current && !current.env.deleted ? current.env.record : null;\n }\n\n async create(ref: SegmentRef, record: NewRegistryRecord): Promise<{ token: Token }> {\n validateNewRegistryRecord(record);\n const key = registryObjectKey(this.prefix, ref);\n const current = await this.readRow(key);\n if (current !== null && !current.env.deleted) {\n throw new WriteConflictError(`registry row already exists for segment ${ref.segment}`);\n }\n // Advance across a tombstone so a recreate never re-issues an old token (ABA-safe).\n const token = String(current ? registryCounterOf(current.env.record) + 1 : 0);\n const env: RegistryEnvelope = {\n deleted: false,\n record: recordFromNew(ref, record, this.now(), token),\n };\n // Write-once when truly absent; overwrite the tombstone under its ETag when recreating. Either way a\n // concurrent create loses with a 412 → WriteConflictError.\n await this.putRow(key, env, current ? { ifMatch: current.etag } : { ifNoneMatch: '*' });\n return { token };\n }\n\n async compareAndSwap(\n ref: SegmentRef,\n expected: Token,\n patch: RegistryPatch,\n ): Promise<{ token: Token }> {\n validateRegistryPatch(patch);\n const key = registryObjectKey(this.prefix, ref);\n const current = await this.readRow(key);\n if (current === null || current.env.deleted || current.env.record.token !== expected) {\n throw new WriteConflictError(`OCC token mismatch for registry row ${ref.segment}`);\n }\n const token = String(registryCounterOf(current.env.record) + 1);\n const env: RegistryEnvelope = {\n deleted: false,\n record: applyRegistryPatch(current.env.record, patch, this.now(), token),\n };\n // If-Match on the ETag we read fences a concurrent writer between our read and this PUT (412 → conflict).\n await this.putRow(key, env, { ifMatch: current.etag });\n return { token };\n }\n\n async *list(namespace?: string): AsyncIterable<RegistryRecord> {\n const prefix = registryListPrefix(this.prefix, namespace);\n let token: string | undefined;\n do {\n let res;\n try {\n res = await this.client.send(\n new ListObjectsV2Command({\n Bucket: this.bucket,\n Prefix: prefix,\n ContinuationToken: token,\n }),\n );\n } catch (err) {\n throw this.mapError(err);\n }\n // Registry keys in this page (skipping stray/foreign objects). `readRow` is one GET each — a serial\n // await-in-loop made `list()` O(N) sequential round-trips (the N+1). Fan them out with a bounded pool:\n // one LIST + up to `LIST_READ_CONCURRENCY` parallel GETs per page, order-preserving so the yielded\n // stream stays deterministic.\n const keys = (res.Contents ?? [])\n .map((obj) => obj.Key)\n .filter((k): k is string => k !== undefined && parseRegistryKey(this.prefix, k) !== null);\n const rows = await mapWithConcurrency(keys, LIST_READ_CONCURRENCY, (key) =>\n this.readRow(key),\n );\n for (const current of rows) {\n if (current && !current.env.deleted) yield current.env.record;\n }\n token = res.IsTruncated === true ? res.NextContinuationToken : undefined;\n } while (token !== undefined);\n }\n\n async delete(ref: SegmentRef): Promise<void> {\n const key = registryObjectKey(this.prefix, ref);\n // Tombstone (advance the counter) rather than remove the object — keeps the token monotonic for\n // ABA-safety. Retry the read→tombstone on a cross-process race (a concurrent write bumps the ETag → 412);\n // it converges, then fails typed rather than silently leaving the row live.\n for (let attempt = 0; attempt < MAX_DELETE_ATTEMPTS; attempt++) {\n const current = await this.readRow(key);\n if (current === null || current.env.deleted) return; // idempotent — already gone\n const token = String(registryCounterOf(current.env.record) + 1);\n const env: RegistryEnvelope = {\n deleted: true,\n record: { ...current.env.record, token, updatedAt: this.now() },\n };\n try {\n await this.putRow(key, env, { ifMatch: current.etag });\n return;\n } catch (err) {\n if (isWriteConflictError(err)) continue; // raced — re-read and re-tombstone\n throw err;\n }\n }\n throw new WriteConflictError(\n `registry delete: contention tombstoning \"${ref.segment}\" — retry`,\n );\n }\n\n /** GET + parse a registry object, returning its envelope + ETag (for a later If-Match), or null if absent. */\n private async readRow(\n objectKey: string,\n ): Promise<{ env: RegistryEnvelope; etag: string } | null> {\n let res;\n try {\n res = await this.client.send(new GetObjectCommand({ Bucket: this.bucket, Key: objectKey }));\n } catch (err) {\n if (isNotFound(err)) return null;\n throw this.mapError(err);\n }\n if ((res.ContentLength ?? 0) > MAX_ROW_BYTES) {\n throw new IntegrityError(\n `registry object ${res.ContentLength}B exceeds cap ${MAX_ROW_BYTES}B`,\n );\n }\n if (res.Body === undefined) {\n throw new IntegrityError(`registry object has an empty body: ${objectKey}`);\n }\n const bytes = await (\n res.Body as { transformToByteArray(): Promise<Uint8Array> }\n ).transformToByteArray();\n if (bytes.length > MAX_ROW_BYTES) {\n throw new IntegrityError(`registry object ${bytes.length}B exceeds cap ${MAX_ROW_BYTES}B`);\n }\n const env = parseRegistryEnvelope(Buffer.from(bytes).toString('utf8'), objectKey);\n if (res.ETag === undefined || res.ETag.length === 0) {\n // The ETag is the OCC fence for CAS; a backend that omits it can't be used safely as a registry.\n throw new IntegrityError(\n `registry object has no ETag (needed for compare-and-swap): ${objectKey}`,\n );\n }\n return { env, etag: res.ETag };\n }\n\n /** Conditional PUT of an envelope; maps a `412` precondition failure to {@link WriteConflictError}. */\n private async putRow(\n objectKey: string,\n env: RegistryEnvelope,\n cond: PutCondition,\n ): Promise<void> {\n const Body = Buffer.from(serializeRegistryEnvelope(env), 'utf8');\n if (Body.length > MAX_ROW_BYTES) {\n // Belt-and-braces: the governance/DEK fields are already capped by validate*, so this can't fire for\n // valid input — but never write a row that would later be unreadable.\n throw new ValidationError(`registry object ${Body.length}B exceeds cap ${MAX_ROW_BYTES}B`);\n }\n try {\n await this.client.send(\n new PutObjectCommand({\n Bucket: this.bucket,\n Key: objectKey,\n Body,\n ContentType: 'application/json',\n IfNoneMatch: 'ifNoneMatch' in cond ? cond.ifNoneMatch : undefined,\n IfMatch: 'ifMatch' in cond ? cond.ifMatch : undefined,\n }),\n );\n } catch (err) {\n // A lost conditional-write race (412 precondition, or 409 concurrent-conflict) is an OCC conflict.\n if (isConditionalConflict(err)) {\n throw new WriteConflictError(`registry OCC conflict for ${objectKey}`);\n }\n throw this.mapError(err);\n }\n }\n\n /** Reclassify a transient S3 fault as a retryable {@link TransientError}; pass everything else through. */\n private mapError(err: unknown): unknown {\n if (isTransient(err)) {\n return new TransientError(\n `transient S3 fault: ${(err as { name?: string } | null)?.name ?? 'unknown'}`,\n { cause: err },\n );\n }\n return err;\n }\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudbitmaps/core",
|
|
3
|
+
"version": "0.1.0-rc.0",
|
|
4
|
+
"description": "The codec-agnostic cloud engine behind the @cloudbitmaps family: tiered storage (RAM → warm KV → cold object store), chunk-skipping intersection, the .crbm format, crash-safe compaction, encryption-at-rest, and every storage driver.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"roaring",
|
|
7
|
+
"bitmap",
|
|
8
|
+
"roaring-bitmap",
|
|
9
|
+
"roaring-bitmaps",
|
|
10
|
+
"croaring",
|
|
11
|
+
"bitset",
|
|
12
|
+
"compressed-bitmap",
|
|
13
|
+
"lambda",
|
|
14
|
+
"nodejs",
|
|
15
|
+
"typescript",
|
|
16
|
+
"set",
|
|
17
|
+
"set-intersection",
|
|
18
|
+
"s3",
|
|
19
|
+
"dynamodb",
|
|
20
|
+
"gcs",
|
|
21
|
+
"azure",
|
|
22
|
+
"postgres",
|
|
23
|
+
"redis",
|
|
24
|
+
"mongodb",
|
|
25
|
+
"cassandra",
|
|
26
|
+
"mysql",
|
|
27
|
+
"mariadb",
|
|
28
|
+
"serverless",
|
|
29
|
+
"tiered-storage",
|
|
30
|
+
"scale-to-zero",
|
|
31
|
+
"segmentation",
|
|
32
|
+
"audience",
|
|
33
|
+
"cloud"
|
|
34
|
+
],
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"author": "Sharvil Kadam",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/cloudbitmaps/cloudbitmaps.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/cloudbitmaps/cloudbitmaps#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/cloudbitmaps/cloudbitmaps/issues"
|
|
44
|
+
},
|
|
45
|
+
"type": "module",
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": false,
|
|
50
|
+
"main": "./dist/index.cjs",
|
|
51
|
+
"module": "./dist/index.js",
|
|
52
|
+
"types": "./dist/index.d.ts",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"import": "./dist/index.js",
|
|
57
|
+
"require": "./dist/index.cjs"
|
|
58
|
+
},
|
|
59
|
+
"./s3": {
|
|
60
|
+
"types": "./dist/s3/index.d.ts",
|
|
61
|
+
"import": "./dist/s3/index.js",
|
|
62
|
+
"require": "./dist/s3/index.cjs"
|
|
63
|
+
},
|
|
64
|
+
"./dynamodb": {
|
|
65
|
+
"types": "./dist/dynamodb/index.d.ts",
|
|
66
|
+
"import": "./dist/dynamodb/index.js",
|
|
67
|
+
"require": "./dist/dynamodb/index.cjs"
|
|
68
|
+
},
|
|
69
|
+
"./gcs": {
|
|
70
|
+
"types": "./dist/gcs/index.d.ts",
|
|
71
|
+
"import": "./dist/gcs/index.js",
|
|
72
|
+
"require": "./dist/gcs/index.cjs"
|
|
73
|
+
},
|
|
74
|
+
"./azure": {
|
|
75
|
+
"types": "./dist/azure/index.d.ts",
|
|
76
|
+
"import": "./dist/azure/index.js",
|
|
77
|
+
"require": "./dist/azure/index.cjs"
|
|
78
|
+
},
|
|
79
|
+
"./postgres": {
|
|
80
|
+
"types": "./dist/postgres/index.d.ts",
|
|
81
|
+
"import": "./dist/postgres/index.js",
|
|
82
|
+
"require": "./dist/postgres/index.cjs"
|
|
83
|
+
},
|
|
84
|
+
"./redis": {
|
|
85
|
+
"types": "./dist/redis/index.d.ts",
|
|
86
|
+
"import": "./dist/redis/index.js",
|
|
87
|
+
"require": "./dist/redis/index.cjs"
|
|
88
|
+
},
|
|
89
|
+
"./mongodb": {
|
|
90
|
+
"types": "./dist/mongodb/index.d.ts",
|
|
91
|
+
"import": "./dist/mongodb/index.js",
|
|
92
|
+
"require": "./dist/mongodb/index.cjs"
|
|
93
|
+
},
|
|
94
|
+
"./cassandra": {
|
|
95
|
+
"types": "./dist/cassandra/index.d.ts",
|
|
96
|
+
"import": "./dist/cassandra/index.js",
|
|
97
|
+
"require": "./dist/cassandra/index.cjs"
|
|
98
|
+
},
|
|
99
|
+
"./mysql": {
|
|
100
|
+
"types": "./dist/mysql/index.d.ts",
|
|
101
|
+
"import": "./dist/mysql/index.js",
|
|
102
|
+
"require": "./dist/mysql/index.cjs"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"files": [
|
|
106
|
+
"dist",
|
|
107
|
+
"README.md",
|
|
108
|
+
"LICENSE",
|
|
109
|
+
"NOTICE"
|
|
110
|
+
],
|
|
111
|
+
"publishConfig": {
|
|
112
|
+
"access": "public"
|
|
113
|
+
},
|
|
114
|
+
"peerDependencies": {
|
|
115
|
+
"@aws-sdk/client-dynamodb": "^3",
|
|
116
|
+
"@aws-sdk/client-s3": "^3",
|
|
117
|
+
"@azure/storage-blob": "^12",
|
|
118
|
+
"@google-cloud/storage": "^7",
|
|
119
|
+
"cassandra-driver": "^4",
|
|
120
|
+
"ioredis": "^5",
|
|
121
|
+
"mongodb": "^6",
|
|
122
|
+
"mysql2": "^3",
|
|
123
|
+
"pg": "^8"
|
|
124
|
+
},
|
|
125
|
+
"peerDependenciesMeta": {
|
|
126
|
+
"@aws-sdk/client-dynamodb": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
129
|
+
"@aws-sdk/client-s3": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"@azure/storage-blob": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"@google-cloud/storage": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"cassandra-driver": {
|
|
139
|
+
"optional": true
|
|
140
|
+
},
|
|
141
|
+
"ioredis": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
144
|
+
"mongodb": {
|
|
145
|
+
"optional": true
|
|
146
|
+
},
|
|
147
|
+
"mysql2": {
|
|
148
|
+
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"pg": {
|
|
151
|
+
"optional": true
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"devDependencies": {
|
|
155
|
+
"@aws-sdk/client-dynamodb": "^3.1075.0",
|
|
156
|
+
"@aws-sdk/client-s3": "^3.1075.0",
|
|
157
|
+
"@azure/storage-blob": "^12",
|
|
158
|
+
"@google-cloud/storage": "^7.0.0",
|
|
159
|
+
"cassandra-driver": "^4",
|
|
160
|
+
"ioredis": "^5",
|
|
161
|
+
"mongodb": "^6",
|
|
162
|
+
"mysql2": "^3.23.1",
|
|
163
|
+
"pg": "^8",
|
|
164
|
+
"@types/pg": "^8",
|
|
165
|
+
"@types/node": "^22.0.0",
|
|
166
|
+
"tsup": "^8.0.0",
|
|
167
|
+
"typescript": "^5.5.0"
|
|
168
|
+
},
|
|
169
|
+
"scripts": {
|
|
170
|
+
"build": "tsup"
|
|
171
|
+
}
|
|
172
|
+
}
|