@cloudbitmaps/s3 0.19.1 → 0.20.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.
@@ -59,8 +59,7 @@ export interface S3RegistryDriverOptions {
59
59
  readonly readTimeoutMs?: number;
60
60
  /**
61
61
  * Whether a delete removes a row for good, by a `DeleteObject` sent with `If-Match: <the ETag it read>`, rather than
62
- * leaving a tombstone. Only a row born with an incarnation id is removed; a row a release before 0.12 wrote is
63
- * always tombstoned.
62
+ * leaving a tombstone.
64
63
  *
65
64
  * Defaults to `true` when the host the client resolves is an AWS S3 host (`*.amazonaws.com`, `*.amazonaws.com.cn`: the
66
65
  * FIPS, dual-stack, access-point and VPC interface forms included), where `If-Match` on `DeleteObject` is documented
package/dist/storage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BlobSink, GenKey, IStorageDriver, SegmentRef, StorageCaps } from '@cloudbitmaps/core/driver-kit';
1
+ import type { BlobSink, GenKey, IStorageDriver, SegmentRef, StorageCaps, StorageDeleteOptions, TailRead } from '@cloudbitmaps/core/driver-kit';
2
2
  import { type S3Client } from '@aws-sdk/client-s3';
3
3
  import type { SocketAdvisory } from './socket-advisory.js';
4
4
  /** What the throttle backoff waits on. */
@@ -38,6 +38,15 @@ export interface S3StorageDriverOptions {
38
38
  readonly sockets?: SocketAdvisory;
39
39
  /** What the backoff before re-sending a throttled commit waits on; real time when absent. */
40
40
  readonly clock?: Sleeper;
41
+ /**
42
+ * Whether a delete given `ifVersion` is sent with `If-Match`, so it removes the object only while it is the one that
43
+ * ETag names. Defaults as the registry's option does: on when the host the client resolves is an AWS S3 host and the
44
+ * SDK sends the header, resolved on the first such delete (until then `capabilities()` reads `false`), and off for any
45
+ * other host, and for a client that cannot be resolved then (no region), whose deletes stay unconditional. Set it for
46
+ * an S3-compatible store only once you know the store applies `If-Match` on a delete. A `true` never overrides an SDK
47
+ * that does not send the header.
48
+ */
49
+ readonly conditionalDelete?: boolean;
41
50
  }
42
51
  export declare class S3StorageDriver implements IStorageDriver {
43
52
  private readonly client;
@@ -48,26 +57,33 @@ export declare class S3StorageDriver implements IStorageDriver {
48
57
  private readonly readTimeoutMs;
49
58
  private readonly clock;
50
59
  private readonly sockets;
60
+ private readonly explicitConditionalDelete;
61
+ private probed;
62
+ private facts;
51
63
  constructor(options: S3StorageDriverOptions);
52
64
  capabilities(): StorageCaps;
65
+ /** Ask the client once where its requests go and whether it sends `If-Match` on a delete; it sends nothing. */
66
+ private settle;
53
67
  putImmutable(key: GenKey, write: (sink: BlobSink) => Promise<void>): Promise<{
54
68
  size: number;
55
69
  sha256: string;
56
70
  }>;
57
71
  getRange(key: GenKey, offset: number, length: number): Promise<Uint8Array>;
58
- getTail(key: GenKey, maxBytes: number): Promise<{
59
- bytes: Uint8Array;
60
- size: number;
61
- }>;
72
+ getTail(key: GenKey, maxBytes: number): Promise<TailRead>;
62
73
  private badRead;
63
- /** The object's size from a `HeadObject`, or `undefined` when the response does not carry one. */
64
- private headSize;
74
+ /**
75
+ * The object's size and ETag from a `HeadObject`, each `undefined` when the response does not carry it. A missing
76
+ * object throws {@link NotFoundError}.
77
+ */
78
+ private head;
65
79
  /**
66
80
  * One read request under the read timeout, its failures mapped to the driver vocabulary. The timeout's own
67
81
  * `TransientError` is raised outside the mapping, so it reaches the caller as it is.
68
82
  */
69
83
  private read;
70
- delete(key: GenKey): Promise<void>;
84
+ delete(key: GenKey, options?: StorageDeleteOptions): Promise<void>;
85
+ /** Whether an object is under the key, from one `HeadObject`. A read that fails in any other way throws. */
86
+ private exists;
71
87
  list(ref: SegmentRef): AsyncIterable<GenKey>;
72
88
  /** Map S3 read errors to the driver vocabulary; pass everything else through {@link mapError}. */
73
89
  private mapReadError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbitmaps/s3",
3
- "version": "0.19.1",
3
+ "version": "0.20.0",
4
4
  "description": "S3 and S3-compatible storage (R2, MinIO, Ceph, Wasabi, B2) for CloudBitmaps",
5
5
  "keywords": [
6
6
  "cloudbitmaps",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@aws-sdk/client-s3": ">=3.700.0 <4",
56
- "@cloudbitmaps/core": "^0.19.1"
56
+ "@cloudbitmaps/core": "^0.20.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^22.0.0",