zerobucket 0.6.1 → 0.8.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.
@@ -77,8 +77,30 @@ interface SqliteDatabaseLike {
77
77
  };
78
78
  exec(sql: string): unknown;
79
79
  }
80
- /** What `connection` accepts: a `pg` client for the Postgres backend, a `better-sqlite3` Database for SQLite. */
81
- type Connection = Queryable | SqliteDatabaseLike;
80
+ /**
81
+ * A `mysql2/promise` connection (or pool connection): both `query()` and `execute()` resolve to
82
+ * `[rowsOrResultHeader, fields]`. Pass one as `connection` to make a call part of YOUR MySQL/MariaDB
83
+ * transaction. Declared structurally so consumers do not need `mysql2` installed to type-check.
84
+ */
85
+ interface MysqlQueryable {
86
+ query(sql: string, values?: any): Promise<[any, any]>;
87
+ execute(sql: string, values?: any): Promise<[any, any]>;
88
+ }
89
+ /** The slice of a `mysql2/promise` pool connection that the MySQL backend uses. */
90
+ interface MysqlPoolConnectionLike extends MysqlQueryable {
91
+ beginTransaction(): Promise<void>;
92
+ commit(): Promise<void>;
93
+ rollback(): Promise<void>;
94
+ release(): void;
95
+ destroy(): void;
96
+ }
97
+ /** The slice of a `mysql2/promise` Pool that the MySQL backend uses (bring your own via `pool`). */
98
+ interface MysqlPoolLike {
99
+ getConnection(): Promise<MysqlPoolConnectionLike>;
100
+ end(): Promise<void>;
101
+ }
102
+ /** What `connection` accepts: a `pg` client for Postgres, a `better-sqlite3` Database for SQLite, a `mysql2/promise` connection for MySQL/MariaDB. */
103
+ type Connection = Queryable | SqliteDatabaseLike | MysqlQueryable;
82
104
  /** The row shape a storage backend persists (after validation and checksumming). */
83
105
  interface PreparedRow {
84
106
  data: Buffer;
@@ -314,7 +336,17 @@ interface ZeroBucketOptions<C = unknown> {
314
336
  * package's SQLiteBackend, so both can share one `.db` file.
315
337
  */
316
338
  sqlite?: string;
317
- /** Advanced: inject a custom StorageBackend instead of building one from `connectionString` / `pool` / `sqlite`. */
339
+ /**
340
+ * Use MySQL or MariaDB instead of PostgreSQL: `mysql://user:password@host:3306/database`
341
+ * (`mariadb://` works too). Needs `npm install mysql2`. Same schema as the Python package's
342
+ * MySQLBackend, so both can share one database. Classic mode only for now (`dedup` is not
343
+ * available for MySQL yet). `maxRetries`, `retryBaseDelayMs`, `poolMaxSize`, `poolTimeoutMs`,
344
+ * `autoMigrate`, `objectStorage` and `onOperation` apply to it too.
345
+ */
346
+ mysql?: string;
347
+ /** Bring your own `mysql2/promise` Pool for MySQL/MariaDB. It is NOT closed by close(). */
348
+ mysqlPool?: MysqlPoolLike;
349
+ /** Advanced: inject a custom StorageBackend instead of building one from `connectionString` / `pool` / `sqlite` / `mysql`. */
318
350
  backend?: StorageBackend;
319
351
  /** Max accepted size in bytes. Default 8 MiB. */
320
352
  maxBytes?: number;
@@ -470,4 +502,4 @@ declare function readInput(image: ImageInput, filename: string | undefined, maxB
470
502
  filename: string | undefined;
471
503
  }>;
472
504
 
473
- export { type BatchDeleteResult as B, type CallOptions as C, DEFAULT_MAX_BYTES as D, type GetOptions as G, type ImageListOptions as I, type OperationEvent as O, type PreparedRow as P, type Queryable as Q, type StorageBackend as S, type ValidatedContent as V, type WritableLike as W, ZeroBucket as Z, type ObjectStorageLike as a, type StoredRecord as b, type StoredRecordMetadata as c, type StreamOptions$1 as d, type StorageInfo as e, type ImageListEntry as f, type ContentValidator as g, type BatchGetResult as h, type BatchPutResult as i, type BeforeGetHook as j, type BeforePutHook as k, type Connection as l, type Image as m, type ImageInput as n, type ImageMetadata as o, ObjectStorage as p, type ObjectStorageOptions as q, type OptimizationResult as r, type OptimizeOptions as s, type PutManyOptions as t, type PutOptions as u, type SqliteDatabaseLike as v, type StreamOptions as w, type ZeroBucketOptions as x, optimizeImage as y, readInput as z };
505
+ export { optimizeImage as A, type BatchDeleteResult as B, type CallOptions as C, DEFAULT_MAX_BYTES as D, readInput as E, type GetOptions as G, type ImageListOptions as I, type MysqlPoolLike as M, type OperationEvent as O, type PreparedRow as P, type Queryable as Q, type StorageBackend as S, type ValidatedContent as V, type WritableLike as W, ZeroBucket as Z, type ObjectStorageLike as a, type StoredRecord as b, type StoredRecordMetadata as c, type StreamOptions$1 as d, type StorageInfo as e, type ImageListEntry as f, type ContentValidator as g, type BatchGetResult as h, type BatchPutResult as i, type BeforeGetHook as j, type BeforePutHook as k, type Connection as l, type Image as m, type ImageInput as n, type ImageMetadata as o, type MysqlPoolConnectionLike as p, type MysqlQueryable as q, ObjectStorage as r, type ObjectStorageOptions as s, type OptimizationResult as t, type OptimizeOptions as u, type PutManyOptions as v, type PutOptions as w, type SqliteDatabaseLike as x, type StreamOptions as y, type ZeroBucketOptions as z };
@@ -77,8 +77,30 @@ interface SqliteDatabaseLike {
77
77
  };
78
78
  exec(sql: string): unknown;
79
79
  }
80
- /** What `connection` accepts: a `pg` client for the Postgres backend, a `better-sqlite3` Database for SQLite. */
81
- type Connection = Queryable | SqliteDatabaseLike;
80
+ /**
81
+ * A `mysql2/promise` connection (or pool connection): both `query()` and `execute()` resolve to
82
+ * `[rowsOrResultHeader, fields]`. Pass one as `connection` to make a call part of YOUR MySQL/MariaDB
83
+ * transaction. Declared structurally so consumers do not need `mysql2` installed to type-check.
84
+ */
85
+ interface MysqlQueryable {
86
+ query(sql: string, values?: any): Promise<[any, any]>;
87
+ execute(sql: string, values?: any): Promise<[any, any]>;
88
+ }
89
+ /** The slice of a `mysql2/promise` pool connection that the MySQL backend uses. */
90
+ interface MysqlPoolConnectionLike extends MysqlQueryable {
91
+ beginTransaction(): Promise<void>;
92
+ commit(): Promise<void>;
93
+ rollback(): Promise<void>;
94
+ release(): void;
95
+ destroy(): void;
96
+ }
97
+ /** The slice of a `mysql2/promise` Pool that the MySQL backend uses (bring your own via `pool`). */
98
+ interface MysqlPoolLike {
99
+ getConnection(): Promise<MysqlPoolConnectionLike>;
100
+ end(): Promise<void>;
101
+ }
102
+ /** What `connection` accepts: a `pg` client for Postgres, a `better-sqlite3` Database for SQLite, a `mysql2/promise` connection for MySQL/MariaDB. */
103
+ type Connection = Queryable | SqliteDatabaseLike | MysqlQueryable;
82
104
  /** The row shape a storage backend persists (after validation and checksumming). */
83
105
  interface PreparedRow {
84
106
  data: Buffer;
@@ -314,7 +336,17 @@ interface ZeroBucketOptions<C = unknown> {
314
336
  * package's SQLiteBackend, so both can share one `.db` file.
315
337
  */
316
338
  sqlite?: string;
317
- /** Advanced: inject a custom StorageBackend instead of building one from `connectionString` / `pool` / `sqlite`. */
339
+ /**
340
+ * Use MySQL or MariaDB instead of PostgreSQL: `mysql://user:password@host:3306/database`
341
+ * (`mariadb://` works too). Needs `npm install mysql2`. Same schema as the Python package's
342
+ * MySQLBackend, so both can share one database. Classic mode only for now (`dedup` is not
343
+ * available for MySQL yet). `maxRetries`, `retryBaseDelayMs`, `poolMaxSize`, `poolTimeoutMs`,
344
+ * `autoMigrate`, `objectStorage` and `onOperation` apply to it too.
345
+ */
346
+ mysql?: string;
347
+ /** Bring your own `mysql2/promise` Pool for MySQL/MariaDB. It is NOT closed by close(). */
348
+ mysqlPool?: MysqlPoolLike;
349
+ /** Advanced: inject a custom StorageBackend instead of building one from `connectionString` / `pool` / `sqlite` / `mysql`. */
318
350
  backend?: StorageBackend;
319
351
  /** Max accepted size in bytes. Default 8 MiB. */
320
352
  maxBytes?: number;
@@ -470,4 +502,4 @@ declare function readInput(image: ImageInput, filename: string | undefined, maxB
470
502
  filename: string | undefined;
471
503
  }>;
472
504
 
473
- export { type BatchDeleteResult as B, type CallOptions as C, DEFAULT_MAX_BYTES as D, type GetOptions as G, type ImageListOptions as I, type OperationEvent as O, type PreparedRow as P, type Queryable as Q, type StorageBackend as S, type ValidatedContent as V, type WritableLike as W, ZeroBucket as Z, type ObjectStorageLike as a, type StoredRecord as b, type StoredRecordMetadata as c, type StreamOptions$1 as d, type StorageInfo as e, type ImageListEntry as f, type ContentValidator as g, type BatchGetResult as h, type BatchPutResult as i, type BeforeGetHook as j, type BeforePutHook as k, type Connection as l, type Image as m, type ImageInput as n, type ImageMetadata as o, ObjectStorage as p, type ObjectStorageOptions as q, type OptimizationResult as r, type OptimizeOptions as s, type PutManyOptions as t, type PutOptions as u, type SqliteDatabaseLike as v, type StreamOptions as w, type ZeroBucketOptions as x, optimizeImage as y, readInput as z };
505
+ export { optimizeImage as A, type BatchDeleteResult as B, type CallOptions as C, DEFAULT_MAX_BYTES as D, readInput as E, type GetOptions as G, type ImageListOptions as I, type MysqlPoolLike as M, type OperationEvent as O, type PreparedRow as P, type Queryable as Q, type StorageBackend as S, type ValidatedContent as V, type WritableLike as W, ZeroBucket as Z, type ObjectStorageLike as a, type StoredRecord as b, type StoredRecordMetadata as c, type StreamOptions$1 as d, type StorageInfo as e, type ImageListEntry as f, type ContentValidator as g, type BatchGetResult as h, type BatchPutResult as i, type BeforeGetHook as j, type BeforePutHook as k, type Connection as l, type Image as m, type ImageInput as n, type ImageMetadata as o, type MysqlPoolConnectionLike as p, type MysqlQueryable as q, ObjectStorage as r, type ObjectStorageOptions as s, type OptimizationResult as t, type OptimizeOptions as u, type PutManyOptions as v, type PutOptions as w, type SqliteDatabaseLike as x, type StreamOptions as y, type ZeroBucketOptions as z };
package/dist/http.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Z as ZeroBucket } from './client-C7xs1dlr.cjs';
2
+ import { Z as ZeroBucket } from './client-XQ22b1l3.cjs';
3
3
  import 'pg';
4
4
 
5
5
  /**
package/dist/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { Z as ZeroBucket } from './client-C7xs1dlr.js';
2
+ import { Z as ZeroBucket } from './client-XQ22b1l3.js';
3
3
  import 'pg';
4
4
 
5
5
  /**