zerobucket 0.7.0 → 0.8.1

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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as StorageBackend, O as OperationEvent, a as ObjectStorageLike, P as PreparedRow, C as CallOptions, b as StoredRecord, c as StoredRecordMetadata, d as StreamOptions, e as StorageInfo, I as ImageListOptions, f as ImageListEntry, M as MysqlPoolLike, g as ContentValidator, V as ValidatedContent } from './client-XQ22b1l3.cjs';
2
- export { B as BatchDeleteResult, h as BatchGetResult, i as BatchPutResult, j as BeforeGetHook, k as BeforePutHook, l as Connection, D as DEFAULT_MAX_BYTES, G as GetOptions, m as Image, n as ImageInput, o as ImageMetadata, p as MysqlPoolConnectionLike, q as MysqlQueryable, r as ObjectStorage, s as ObjectStorageOptions, t as OptimizationResult, u as OptimizeOptions, v as PutManyOptions, w as PutOptions, Q as Queryable, x as SqliteDatabaseLike, y as StreamOptions, W as WritableLike, Z as ZeroBucket, z as ZeroBucketOptions, A as optimizeImage, E as readInput } from './client-XQ22b1l3.cjs';
1
+ import { S as StorageBackend, O as OperationEvent, a as ObjectStorageLike, P as PreparedRow, C as CallOptions, b as StoredRecord, c as StoredRecordMetadata, d as StreamOptions, e as StorageInfo, I as ImageListOptions, f as ImageListEntry, M as MigrateToDedupOptions, g as MigrateToDedupResult, h as MysqlPoolLike, i as ContentValidator, V as ValidatedContent } from './client-l4jPIFJI.cjs';
2
+ export { B as BatchDeleteResult, j as BatchGetResult, k as BatchPutResult, l as BeforeGetHook, m as BeforePutHook, n as Connection, D as DEFAULT_MAX_BYTES, G as GetOptions, o as Image, p as ImageInput, q as ImageMetadata, r as MysqlPoolConnectionLike, s as MysqlQueryable, t as ObjectStorage, u as ObjectStorageOptions, v as OptimizationResult, w as OptimizeOptions, x as PutManyOptions, y as PutOptions, Q as Queryable, z as SqliteDatabaseLike, A as StreamOptions, W as WritableLike, Z as ZeroBucket, E as ZeroBucketOptions, F as optimizeImage, H as readInput } from './client-l4jPIFJI.cjs';
3
3
  import { Pool } from 'pg';
4
4
 
5
5
  /**
@@ -158,18 +158,13 @@ declare class PostgresBackend implements StorageBackend {
158
158
  * dedup instance's tables, preserving every id (external references keep working) and
159
159
  * deduplicating identical content on the way. The classic table is never modified.
160
160
  *
161
- * Differences from the Python version, all deliberate: rows are copied in small batches (bounded
162
- * memory instead of loading the whole table); re-running is safe (already-migrated ids are
163
- * skipped and reported, not an error); and classic rows already tiered to object storage are
164
- * refused up front with a clear message (their bytes are not in the database to copy).
161
+ * Rows are copied in small batches (bounded memory instead of loading the whole table);
162
+ * re-running is safe (already-migrated ids are skipped and reported, not an error). Classic rows
163
+ * already tiered to object storage are refused up front with a clear message (their bytes are
164
+ * not in the database to copy) unless `skipTiered: true`, which skips and counts them instead.
165
165
  * Still all-or-nothing: one transaction.
166
166
  */
167
- migrateClassicToDedup(): Promise<{
168
- imagesMigrated: number;
169
- distinctBlobsCreated: number;
170
- duplicateReferencesFound: number;
171
- alreadyMigrated: number;
172
- }>;
167
+ migrateClassicToDedup(opts?: MigrateToDedupOptions): Promise<MigrateToDedupResult>;
173
168
  private hydrate;
174
169
  /**
175
170
  * Remove tiered objects AFTER their rows are gone. Ordering is deliberate:
@@ -295,7 +290,11 @@ interface MySQLBackendOptions {
295
290
  onOperation?: (event: OperationEvent) => void;
296
291
  /** Enables transparent reads of tiered rows and `tierToObjectStorage()`. */
297
292
  objectStorage?: ObjectStorageLike;
298
- /** Not available for MySQL yet; passing `true` throws. */
293
+ /**
294
+ * Content-addressed storage: identical bytes are stored once and shared by every image that has them
295
+ * (reference counted). Same tables as the Python package's dedup mode. Cannot be combined with
296
+ * `objectStorage` (a blob may be shared by many images).
297
+ */
299
298
  dedup?: boolean;
300
299
  }
301
300
  declare class MySQLBackend implements StorageBackend {
@@ -308,6 +307,8 @@ declare class MySQLBackend implements StorageBackend {
308
307
  private readonly retryBaseDelayMs;
309
308
  private readonly poolTimeoutMs;
310
309
  private readonly autoMigrate;
310
+ private readonly dedup;
311
+ private readonly sql;
311
312
  constructor(opts: MySQLBackendOptions);
312
313
  ready(): Promise<void>;
313
314
  private init;
@@ -317,6 +318,8 @@ declare class MySQLBackend implements StorageBackend {
317
318
  * re-running is a no-op.
318
319
  */
319
320
  private migrate;
321
+ /** Dedup tables, created only if missing (same no-needless-DDL rule as the classic table). */
322
+ private migrateDedup;
320
323
  close(): Promise<void>;
321
324
  private emit;
322
325
  /** Wait for a pool slot, but never longer than poolTimeoutMs. */
@@ -351,6 +354,17 @@ declare class MySQLBackend implements StorageBackend {
351
354
  delete(id: string, { connection }?: CallOptions): Promise<boolean>;
352
355
  deleteMany(ids: string[], { connection }?: CallOptions): Promise<string[]>;
353
356
  exists(id: string, { connection }?: CallOptions): Promise<boolean>;
357
+ /** Storage statistics, or null if the tables do not exist yet (nothing is created). */
358
+ getInfo(): Promise<StorageInfo | null>;
359
+ /** Ids matching the filters: oldest first, or a random sample. Used by the CLI's verify and tier. */
360
+ listImages(o?: ImageListOptions): Promise<ImageListEntry[]>;
361
+ /**
362
+ * Lock the ref row, delete it, then decrement its blob (the UPDATE takes the blob row lock, so two
363
+ * deletes of different refs to one blob serialize instead of racing) and remove the blob once nothing
364
+ * references it. All in one transaction: a failure can never leave a ref without its count or the reverse.
365
+ */
366
+ private deleteDedup;
367
+ private deleteManyDedup;
354
368
  private hydrate;
355
369
  /**
356
370
  * Remove tiered objects AFTER their rows are gone: once the row is deleted the image is correctly
@@ -415,4 +429,4 @@ declare class PDFValidator implements ContentValidator {
415
429
  }): ValidatedContent;
416
430
  }
417
431
 
418
- export { AccessDeniedError, CallOptions, ContentValidationError, ContentValidator, CorruptedImageError, DEFAULT_MAX_PIXELS, DEFAULT_STREAM_CHUNK_SIZE, ImageNotFoundError, ImageTooLargeError, ImageValidationError, MySQLBackend, type MySQLBackendOptions, MysqlPoolLike, ObjectStorageLike, OperationEvent, PDFValidator, PostgresBackend, type PostgresBackendOptions, PreparedRow, SQLiteBackend, type SQLiteBackendOptions, SUPPORTED_FORMATS, StorageBackend, StorageError, StoredRecord, StoredRecordMetadata, UnsupportedFormatError, ValidatedContent, type ValidatedImage, ZeroBucketError, validateImage };
432
+ export { AccessDeniedError, CallOptions, ContentValidationError, ContentValidator, CorruptedImageError, DEFAULT_MAX_PIXELS, DEFAULT_STREAM_CHUNK_SIZE, ImageNotFoundError, ImageTooLargeError, ImageValidationError, MigrateToDedupOptions, MigrateToDedupResult, MySQLBackend, type MySQLBackendOptions, MysqlPoolLike, ObjectStorageLike, OperationEvent, PDFValidator, PostgresBackend, type PostgresBackendOptions, PreparedRow, SQLiteBackend, type SQLiteBackendOptions, SUPPORTED_FORMATS, StorageBackend, StorageError, StoredRecord, StoredRecordMetadata, UnsupportedFormatError, ValidatedContent, type ValidatedImage, ZeroBucketError, validateImage };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as StorageBackend, O as OperationEvent, a as ObjectStorageLike, P as PreparedRow, C as CallOptions, b as StoredRecord, c as StoredRecordMetadata, d as StreamOptions, e as StorageInfo, I as ImageListOptions, f as ImageListEntry, M as MysqlPoolLike, g as ContentValidator, V as ValidatedContent } from './client-XQ22b1l3.js';
2
- export { B as BatchDeleteResult, h as BatchGetResult, i as BatchPutResult, j as BeforeGetHook, k as BeforePutHook, l as Connection, D as DEFAULT_MAX_BYTES, G as GetOptions, m as Image, n as ImageInput, o as ImageMetadata, p as MysqlPoolConnectionLike, q as MysqlQueryable, r as ObjectStorage, s as ObjectStorageOptions, t as OptimizationResult, u as OptimizeOptions, v as PutManyOptions, w as PutOptions, Q as Queryable, x as SqliteDatabaseLike, y as StreamOptions, W as WritableLike, Z as ZeroBucket, z as ZeroBucketOptions, A as optimizeImage, E as readInput } from './client-XQ22b1l3.js';
1
+ import { S as StorageBackend, O as OperationEvent, a as ObjectStorageLike, P as PreparedRow, C as CallOptions, b as StoredRecord, c as StoredRecordMetadata, d as StreamOptions, e as StorageInfo, I as ImageListOptions, f as ImageListEntry, M as MigrateToDedupOptions, g as MigrateToDedupResult, h as MysqlPoolLike, i as ContentValidator, V as ValidatedContent } from './client-l4jPIFJI.js';
2
+ export { B as BatchDeleteResult, j as BatchGetResult, k as BatchPutResult, l as BeforeGetHook, m as BeforePutHook, n as Connection, D as DEFAULT_MAX_BYTES, G as GetOptions, o as Image, p as ImageInput, q as ImageMetadata, r as MysqlPoolConnectionLike, s as MysqlQueryable, t as ObjectStorage, u as ObjectStorageOptions, v as OptimizationResult, w as OptimizeOptions, x as PutManyOptions, y as PutOptions, Q as Queryable, z as SqliteDatabaseLike, A as StreamOptions, W as WritableLike, Z as ZeroBucket, E as ZeroBucketOptions, F as optimizeImage, H as readInput } from './client-l4jPIFJI.js';
3
3
  import { Pool } from 'pg';
4
4
 
5
5
  /**
@@ -158,18 +158,13 @@ declare class PostgresBackend implements StorageBackend {
158
158
  * dedup instance's tables, preserving every id (external references keep working) and
159
159
  * deduplicating identical content on the way. The classic table is never modified.
160
160
  *
161
- * Differences from the Python version, all deliberate: rows are copied in small batches (bounded
162
- * memory instead of loading the whole table); re-running is safe (already-migrated ids are
163
- * skipped and reported, not an error); and classic rows already tiered to object storage are
164
- * refused up front with a clear message (their bytes are not in the database to copy).
161
+ * Rows are copied in small batches (bounded memory instead of loading the whole table);
162
+ * re-running is safe (already-migrated ids are skipped and reported, not an error). Classic rows
163
+ * already tiered to object storage are refused up front with a clear message (their bytes are
164
+ * not in the database to copy) unless `skipTiered: true`, which skips and counts them instead.
165
165
  * Still all-or-nothing: one transaction.
166
166
  */
167
- migrateClassicToDedup(): Promise<{
168
- imagesMigrated: number;
169
- distinctBlobsCreated: number;
170
- duplicateReferencesFound: number;
171
- alreadyMigrated: number;
172
- }>;
167
+ migrateClassicToDedup(opts?: MigrateToDedupOptions): Promise<MigrateToDedupResult>;
173
168
  private hydrate;
174
169
  /**
175
170
  * Remove tiered objects AFTER their rows are gone. Ordering is deliberate:
@@ -295,7 +290,11 @@ interface MySQLBackendOptions {
295
290
  onOperation?: (event: OperationEvent) => void;
296
291
  /** Enables transparent reads of tiered rows and `tierToObjectStorage()`. */
297
292
  objectStorage?: ObjectStorageLike;
298
- /** Not available for MySQL yet; passing `true` throws. */
293
+ /**
294
+ * Content-addressed storage: identical bytes are stored once and shared by every image that has them
295
+ * (reference counted). Same tables as the Python package's dedup mode. Cannot be combined with
296
+ * `objectStorage` (a blob may be shared by many images).
297
+ */
299
298
  dedup?: boolean;
300
299
  }
301
300
  declare class MySQLBackend implements StorageBackend {
@@ -308,6 +307,8 @@ declare class MySQLBackend implements StorageBackend {
308
307
  private readonly retryBaseDelayMs;
309
308
  private readonly poolTimeoutMs;
310
309
  private readonly autoMigrate;
310
+ private readonly dedup;
311
+ private readonly sql;
311
312
  constructor(opts: MySQLBackendOptions);
312
313
  ready(): Promise<void>;
313
314
  private init;
@@ -317,6 +318,8 @@ declare class MySQLBackend implements StorageBackend {
317
318
  * re-running is a no-op.
318
319
  */
319
320
  private migrate;
321
+ /** Dedup tables, created only if missing (same no-needless-DDL rule as the classic table). */
322
+ private migrateDedup;
320
323
  close(): Promise<void>;
321
324
  private emit;
322
325
  /** Wait for a pool slot, but never longer than poolTimeoutMs. */
@@ -351,6 +354,17 @@ declare class MySQLBackend implements StorageBackend {
351
354
  delete(id: string, { connection }?: CallOptions): Promise<boolean>;
352
355
  deleteMany(ids: string[], { connection }?: CallOptions): Promise<string[]>;
353
356
  exists(id: string, { connection }?: CallOptions): Promise<boolean>;
357
+ /** Storage statistics, or null if the tables do not exist yet (nothing is created). */
358
+ getInfo(): Promise<StorageInfo | null>;
359
+ /** Ids matching the filters: oldest first, or a random sample. Used by the CLI's verify and tier. */
360
+ listImages(o?: ImageListOptions): Promise<ImageListEntry[]>;
361
+ /**
362
+ * Lock the ref row, delete it, then decrement its blob (the UPDATE takes the blob row lock, so two
363
+ * deletes of different refs to one blob serialize instead of racing) and remove the blob once nothing
364
+ * references it. All in one transaction: a failure can never leave a ref without its count or the reverse.
365
+ */
366
+ private deleteDedup;
367
+ private deleteManyDedup;
354
368
  private hydrate;
355
369
  /**
356
370
  * Remove tiered objects AFTER their rows are gone: once the row is deleted the image is correctly
@@ -415,4 +429,4 @@ declare class PDFValidator implements ContentValidator {
415
429
  }): ValidatedContent;
416
430
  }
417
431
 
418
- export { AccessDeniedError, CallOptions, ContentValidationError, ContentValidator, CorruptedImageError, DEFAULT_MAX_PIXELS, DEFAULT_STREAM_CHUNK_SIZE, ImageNotFoundError, ImageTooLargeError, ImageValidationError, MySQLBackend, type MySQLBackendOptions, MysqlPoolLike, ObjectStorageLike, OperationEvent, PDFValidator, PostgresBackend, type PostgresBackendOptions, PreparedRow, SQLiteBackend, type SQLiteBackendOptions, SUPPORTED_FORMATS, StorageBackend, StorageError, StoredRecord, StoredRecordMetadata, UnsupportedFormatError, ValidatedContent, type ValidatedImage, ZeroBucketError, validateImage };
432
+ export { AccessDeniedError, CallOptions, ContentValidationError, ContentValidator, CorruptedImageError, DEFAULT_MAX_PIXELS, DEFAULT_STREAM_CHUNK_SIZE, ImageNotFoundError, ImageTooLargeError, ImageValidationError, MigrateToDedupOptions, MigrateToDedupResult, MySQLBackend, type MySQLBackendOptions, MysqlPoolLike, ObjectStorageLike, OperationEvent, PDFValidator, PostgresBackend, type PostgresBackendOptions, PreparedRow, SQLiteBackend, type SQLiteBackendOptions, SUPPORTED_FORMATS, StorageBackend, StorageError, StoredRecord, StoredRecordMetadata, UnsupportedFormatError, ValidatedContent, type ValidatedImage, ZeroBucketError, validateImage };