@nestm/storage 0.1.0-alpha.2 → 0.1.0-alpha.3
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/CHANGELOG.md +15 -0
- package/README.md +111 -13
- package/SECURITY.md +23 -0
- package/dist/files-sdk/files-sdk.driver.d.ts +36 -7
- package/dist/files-sdk/files-sdk.driver.d.ts.map +1 -1
- package/dist/files-sdk/files-sdk.driver.js +141 -20
- package/dist/files-sdk/files-sdk.driver.js.map +1 -1
- package/dist/files-sdk/index.d.ts +1 -1
- package/dist/files-sdk/index.d.ts.map +1 -1
- package/dist/files-sdk/index.js.map +1 -1
- package/dist/files-sdk/s3/index.d.ts +14 -0
- package/dist/files-sdk/s3/index.d.ts.map +1 -0
- package/dist/files-sdk/s3/index.js +108 -0
- package/dist/files-sdk/s3/index.js.map +1 -0
- package/dist/gateway/index.d.ts +1 -1
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/storage-gateway.controller.d.ts +12 -11
- package/dist/gateway/storage-gateway.controller.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.controller.js +209 -65
- package/dist/gateway/storage-gateway.controller.js.map +1 -1
- package/dist/gateway/storage-gateway.module.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.module.js +60 -1
- package/dist/gateway/storage-gateway.module.js.map +1 -1
- package/dist/gateway/storage-gateway.tokens.d.ts +1 -0
- package/dist/gateway/storage-gateway.tokens.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.tokens.js +1 -0
- package/dist/gateway/storage-gateway.tokens.js.map +1 -1
- package/dist/gateway/storage-gateway.types.d.ts +43 -0
- package/dist/gateway/storage-gateway.types.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.types.js.map +1 -1
- package/dist/storage.client.d.ts +8 -1
- package/dist/storage.client.d.ts.map +1 -1
- package/dist/storage.client.js +40 -0
- package/dist/storage.client.js.map +1 -1
- package/dist/storage.driver.d.ts +6 -1
- package/dist/storage.driver.d.ts.map +1 -1
- package/dist/storage.driver.js.map +1 -1
- package/dist/storage.error.d.ts +3 -0
- package/dist/storage.error.d.ts.map +1 -1
- package/dist/storage.error.js +33 -1
- package/dist/storage.error.js.map +1 -1
- package/dist/storage.types.d.ts +39 -1
- package/dist/storage.types.d.ts.map +1 -1
- package/dist/storage.types.js.map +1 -1
- package/package.json +25 -1
package/dist/storage.client.js
CHANGED
|
@@ -151,6 +151,7 @@ export class StorageClient {
|
|
|
151
151
|
head: (options) => this.head(key, options),
|
|
152
152
|
key,
|
|
153
153
|
moveTo: (destinationKey, options) => this.move(key, destinationKey, options),
|
|
154
|
+
promoteTo: (destinationKey, options) => this.promote(key, destinationKey, options),
|
|
154
155
|
signDownload: (options) => this.signDownload(key, options),
|
|
155
156
|
signUpload: (options) => this.signUpload(key, options),
|
|
156
157
|
bytes: (options) => this.downloadBytes(key, options),
|
|
@@ -223,6 +224,45 @@ export class StorageClient {
|
|
|
223
224
|
to: destinationKey,
|
|
224
225
|
}, () => this.#driver.move(sourceKey, destinationKey, options));
|
|
225
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Conditionally copies a staged object to a final key. This operation does
|
|
229
|
+
* not delete the source; delete it after the application commit succeeds.
|
|
230
|
+
*/
|
|
231
|
+
promote(sourceKey, destinationKey, options) {
|
|
232
|
+
assertKey(sourceKey, 'source key');
|
|
233
|
+
assertKey(destinationKey, 'destination key');
|
|
234
|
+
const sourceEtag = options.sourceEtag;
|
|
235
|
+
const sourceVersion = options.sourceVersion;
|
|
236
|
+
if (sourceEtag !== undefined && sourceEtag.length === 0) {
|
|
237
|
+
invalidArgument('sourceEtag must be a non-empty string.');
|
|
238
|
+
}
|
|
239
|
+
if (sourceVersion !== undefined && sourceVersion.length === 0) {
|
|
240
|
+
invalidArgument('sourceVersion must be a non-empty string.');
|
|
241
|
+
}
|
|
242
|
+
if (sourceEtag === undefined && sourceVersion === undefined) {
|
|
243
|
+
invalidArgument('promote requires sourceEtag, sourceVersion, or both.');
|
|
244
|
+
}
|
|
245
|
+
const capability = this.#driver.capabilities.conditionalCopy;
|
|
246
|
+
const promote = this.#driver.promote;
|
|
247
|
+
if (capability?.supported !== true ||
|
|
248
|
+
promote === undefined ||
|
|
249
|
+
(sourceEtag !== undefined && !capability.etag) ||
|
|
250
|
+
(sourceVersion !== undefined && !capability.version)) {
|
|
251
|
+
throw new StorageError(`Store "${this.name}" does not support the requested conditional promotion.`, {
|
|
252
|
+
code: StorageErrorCode.NOT_SUPPORTED,
|
|
253
|
+
key: sourceKey,
|
|
254
|
+
operation: 'promote',
|
|
255
|
+
permanent: true,
|
|
256
|
+
store: this.name,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
return this.#execute({
|
|
260
|
+
from: sourceKey,
|
|
261
|
+
operation: 'promote',
|
|
262
|
+
store: this.name,
|
|
263
|
+
to: destinationKey,
|
|
264
|
+
}, () => promote.call(this.#driver, sourceKey, destinationKey, options));
|
|
265
|
+
}
|
|
226
266
|
list(options) {
|
|
227
267
|
assertListOptions(options);
|
|
228
268
|
return this.#execute({ operation: 'list', store: this.name }, () => this.#driver.list(options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.client.js","sourceRoot":"","sources":["../src/storage.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AA8B5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAKrD,SAAS,SAAS,CAAC,GAAW,EAAE,KAAK,GAAG,KAAK;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,YAAY,CAAC,GAAG,KAAK,8BAA8B,EAAE;YAC7D,I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AC;YACH,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC9C,CAAC;gBAAC,MAAM,CAAC;oBACP,uCAAuC;gBACzC,CAAC;YACH,CAAC;YACD,MAAM,UAAU,CAAC;QACnB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { settleMany } from './internal/settle-many.js';\nimport {\n StorageError,\n StorageErrorCode,\n normalizeStorageError,\n} from './storage.error.js';\nimport type { StorageDriver } from './storage.driver.js';\nimport type {\n StorageBody,\n StorageBufferedDownloadOptions,\n StorageBulkOptions,\n StorageCapabilities,\n StorageDeleteManyResult,\n StorageDownloadManyResult,\n StorageDownloadOptions,\n StorageExistsManyResult,\n StorageHeadManyResult,\n StorageListOptions,\n StorageListResult,\n StorageObject,\n StorageObjectMetadata,\n StorageOperationContext,\n StorageOperationOptions,\n StoragePlugin,\n StorageSearchOptions,\n StorageSignedDownloadOptions,\n StorageSignedUpload,\n StorageSignedUploadOptions,\n StorageUploadManyItem,\n StorageUploadManyOptions,\n StorageUploadManyResult,\n StorageUploadOptions,\n StorageUploadResult,\n} from './storage.types.js';\n\nexport const DEFAULT_BUFFER_LIMIT = 10 * 1024 * 1024;\n\ntype BulkOperationOptions = StorageBulkOptions & StorageOperationOptions;\ntype DownloadManyOptions = StorageBulkOptions & StorageDownloadOptions;\n\nfunction assertKey(key: string, label = 'key'): void {\n if (typeof key !== 'string' || key.length === 0) {\n throw new StorageError(`${label} must be a non-empty string.`, {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n });\n }\n}\n\nfunction invalidArgument(message: string): never {\n throw new StorageError(message, {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n });\n}\n\nfunction assertPositiveSafeInteger(\n value: number | undefined,\n label: string,\n): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {\n invalidArgument(`${label} must be a positive safe integer.`);\n }\n}\n\nfunction assertDownloadOptions(options?: StorageDownloadOptions): void {\n const range = options?.range;\n if (range === undefined) {\n return;\n }\n if (!Number.isSafeInteger(range.start) || range.start < 0) {\n invalidArgument('range.start must be a non-negative safe integer.');\n }\n if (\n range.end !== undefined &&\n (!Number.isSafeInteger(range.end) || range.end < range.start)\n ) {\n invalidArgument(\n 'range.end must be a safe integer greater than or equal to range.start.',\n );\n }\n}\n\nfunction assertListOptions(options?: StorageListOptions): void {\n if (options?.delimiter !== undefined && options.delimiter.length === 0) {\n invalidArgument('delimiter must be a non-empty string.');\n }\n assertPositiveSafeInteger(options?.limit, 'limit');\n}\n\nfunction assertSearchOptions(options?: StorageSearchOptions): void {\n assertPositiveSafeInteger(options?.limit, 'limit');\n assertPositiveSafeInteger(options?.maxResults, 'maxResults');\n}\n\nfunction assertSignedUploadOptions(options: StorageSignedUploadOptions): void {\n assertPositiveSafeInteger(options.expiresIn, 'expiresIn');\n assertPositiveSafeInteger(options.maxSize, 'maxSize');\n if (\n options.minSize !== undefined &&\n (!Number.isSafeInteger(options.minSize) || options.minSize < 0)\n ) {\n invalidArgument('minSize must be a non-negative safe integer.');\n }\n if (\n options.minSize !== undefined &&\n options.maxSize !== undefined &&\n options.minSize > options.maxSize\n ) {\n invalidArgument('minSize cannot be greater than maxSize.');\n }\n}\n\nfunction operationOptions(\n options?: BulkOperationOptions,\n): StorageOperationOptions | undefined {\n if (options === undefined) {\n return undefined;\n }\n return {\n ...(options.retries !== undefined && { retries: options.retries }),\n ...(options.signal !== undefined && { signal: options.signal }),\n ...(options.timeout !== undefined && { timeout: options.timeout }),\n };\n}\n\nfunction downloadOptions(\n options?: DownloadManyOptions,\n): StorageDownloadOptions | undefined {\n if (options === undefined) {\n return undefined;\n }\n return {\n ...operationOptions(options),\n ...(options.range !== undefined && { range: options.range }),\n };\n}\n\nasync function collectBody(\n object: StorageObject,\n maxBytes: number,\n): Promise<Uint8Array> {\n if (maxBytes !== Infinity && (!Number.isFinite(maxBytes) || maxBytes < 0)) {\n await object.body.cancel().catch(() => undefined);\n throw new StorageError(\n 'maxBytes must be a non-negative finite number or Infinity.',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n key: object.key,\n permanent: true,\n },\n );\n }\n\n if (maxBytes !== Infinity && object.size > maxBytes) {\n await object.body.cancel().catch(() => undefined);\n throw new StorageError(\n `Object \"${object.key}\" is ${object.size} bytes, exceeding the ${maxBytes}-byte buffer limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: object.key,\n permanent: true,\n },\n );\n }\n\n const chunks: Uint8Array[] = [];\n let total = 0;\n const reader = object.body.getReader();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n total += value.byteLength;\n if (maxBytes !== Infinity && total > maxBytes) {\n await reader.cancel().catch(() => undefined);\n throw new StorageError(\n `Object \"${object.key}\" exceeded the ${maxBytes}-byte buffer limit while downloading.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: object.key,\n permanent: true,\n },\n );\n }\n chunks.push(value);\n }\n } finally {\n reader.releaseLock();\n }\n\n const bytes = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n}\n\nexport interface StorageFileHandle {\n readonly key: string;\n upload(\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult>;\n download(options?: StorageDownloadOptions): Promise<StorageObject>;\n bytes(options?: StorageBufferedDownloadOptions): Promise<Uint8Array>;\n text(options?: StorageBufferedDownloadOptions): Promise<string>;\n head(options?: StorageOperationOptions): Promise<StorageObjectMetadata>;\n exists(options?: StorageOperationOptions): Promise<boolean>;\n delete(options?: StorageOperationOptions): Promise<void>;\n signDownload(options?: StorageSignedDownloadOptions): Promise<string>;\n signUpload(options: StorageSignedUploadOptions): Promise<StorageSignedUpload>;\n copyTo(\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n moveTo(\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n}\n\nexport class StorageClient {\n readonly #driver: StorageDriver;\n readonly #plugins: readonly StoragePlugin[];\n #closed = false;\n\n constructor(\n readonly name: string,\n driver: StorageDriver,\n plugins: readonly StoragePlugin[] = [],\n ) {\n assertKey(name, 'store name');\n this.#driver = driver;\n this.#plugins = [...plugins];\n }\n\n get driverName(): string {\n return this.#driver.name;\n }\n\n get capabilities(): Readonly<StorageCapabilities> {\n return this.#driver.capabilities;\n }\n\n file(key: string): StorageFileHandle {\n assertKey(key);\n return {\n copyTo: (destinationKey, options) =>\n this.copy(key, destinationKey, options),\n delete: (options) => this.delete(key, options),\n download: (options) => this.downloadStream(key, options),\n exists: (options) => this.exists(key, options),\n head: (options) => this.head(key, options),\n key,\n moveTo: (destinationKey, options) =>\n this.move(key, destinationKey, options),\n signDownload: (options) => this.signDownload(key, options),\n signUpload: (options) => this.signUpload(key, options),\n bytes: (options) => this.downloadBytes(key, options),\n text: (options) => this.downloadText(key, options),\n upload: (body, options) => this.upload(key, body, options),\n };\n }\n\n upload(\n key: string,\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult> {\n assertKey(key);\n return this.#execute({ key, operation: 'upload', store: this.name }, () =>\n this.#driver.upload(key, body, options),\n );\n }\n\n downloadStream(\n key: string,\n options?: StorageDownloadOptions,\n ): Promise<StorageObject> {\n assertKey(key);\n assertDownloadOptions(options);\n return this.#execute({ key, operation: 'download', store: this.name }, () =>\n this.#driver.download(key, options),\n );\n }\n\n async downloadBytes(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<Uint8Array> {\n const { maxBytes = DEFAULT_BUFFER_LIMIT, ...download } = options ?? {};\n const object = await this.downloadStream(key, download);\n return collectBody(object, maxBytes);\n }\n\n async downloadText(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<string> {\n return new TextDecoder().decode(await this.downloadBytes(key, options));\n }\n\n async downloadJson<Result = unknown>(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<Result> {\n const text = await this.downloadText(key, options);\n try {\n return JSON.parse(text) as Result;\n } catch (error) {\n throw new StorageError(`Object \"${key}\" does not contain valid JSON.`, {\n cause: error,\n code: StorageErrorCode.INVALID_ARGUMENT,\n key,\n operation: 'download',\n permanent: true,\n store: this.name,\n });\n }\n }\n\n head(\n key: string,\n options?: StorageOperationOptions,\n ): Promise<StorageObjectMetadata> {\n assertKey(key);\n return this.#execute({ key, operation: 'head', store: this.name }, () =>\n this.#driver.head(key, options),\n );\n }\n\n exists(key: string, options?: StorageOperationOptions): Promise<boolean> {\n assertKey(key);\n return this.#execute({ key, operation: 'exists', store: this.name }, () =>\n this.#driver.exists(key, options),\n );\n }\n\n delete(key: string, options?: StorageOperationOptions): Promise<void> {\n assertKey(key);\n return this.#execute({ key, operation: 'delete', store: this.name }, () =>\n this.#driver.delete(key, options),\n );\n }\n\n copy(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void> {\n assertKey(sourceKey, 'source key');\n assertKey(destinationKey, 'destination key');\n return this.#execute(\n {\n from: sourceKey,\n operation: 'copy',\n store: this.name,\n to: destinationKey,\n },\n () => this.#driver.copy(sourceKey, destinationKey, options),\n );\n }\n\n move(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void> {\n assertKey(sourceKey, 'source key');\n assertKey(destinationKey, 'destination key');\n return this.#execute(\n {\n from: sourceKey,\n operation: 'move',\n store: this.name,\n to: destinationKey,\n },\n () => this.#driver.move(sourceKey, destinationKey, options),\n );\n }\n\n list(options?: StorageListOptions): Promise<StorageListResult> {\n assertListOptions(options);\n return this.#execute({ operation: 'list', store: this.name }, () =>\n this.#driver.list(options),\n );\n }\n\n async *listAll(\n options?: StorageListOptions,\n ): AsyncGenerator<StorageObjectMetadata, void> {\n const { delimiter: _delimiter, ...walkOptions } = options ?? {};\n void _delimiter;\n let cursor = walkOptions.cursor;\n const seen = new Set<string>();\n\n do {\n const page = await this.list({\n ...walkOptions,\n ...(cursor !== undefined && { cursor }),\n });\n yield* page.items;\n cursor = page.cursor;\n if (cursor !== undefined) {\n if (seen.has(cursor)) {\n throw new StorageError(\n `Store \"${this.name}\" returned a repeated pagination cursor.`,\n {\n code: StorageErrorCode.PROVIDER,\n operation: 'list',\n permanent: true,\n store: this.name,\n },\n );\n }\n seen.add(cursor);\n }\n } while (cursor !== undefined);\n }\n\n search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncIterable<StorageObjectMetadata> {\n assertSearchOptions(options);\n return this.#search(pattern, options);\n }\n\n async *#search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncGenerator<StorageObjectMetadata, void> {\n const context: StorageOperationContext = {\n operation: 'search',\n store: this.name,\n };\n try {\n for (const plugin of this.#plugins) {\n await plugin.beforeOperation?.(context);\n }\n for await (const object of this.#driver.search(pattern, options)) {\n yield object;\n }\n for (const plugin of this.#plugins) {\n await plugin.afterOperation?.(context, undefined);\n }\n } catch (error) {\n const normalized = normalizeStorageError(error, {\n operation: 'search',\n store: this.name,\n });\n for (const plugin of this.#plugins) {\n try {\n await plugin.onError?.(context, normalized);\n } catch {\n // Preserve the original storage error.\n }\n }\n throw normalized;\n }\n }\n\n signDownload(\n key: string,\n options?: StorageSignedDownloadOptions,\n ): Promise<string> {\n assertKey(key);\n return this.#execute(\n { key, operation: 'signDownload', store: this.name },\n () => this.#driver.signDownload(key, options),\n );\n }\n\n signUpload(\n key: string,\n options: StorageSignedUploadOptions,\n ): Promise<StorageSignedUpload> {\n assertKey(key);\n assertSignedUploadOptions(options);\n return this.#execute(\n { key, operation: 'signUpload', store: this.name },\n () => this.#driver.signUpload(key, options),\n );\n }\n\n async uploadMany(\n items: readonly StorageUploadManyItem[],\n options?: StorageUploadManyOptions,\n ): Promise<StorageUploadManyResult> {\n const settled = await settleMany(\n items,\n (item) => item.key,\n (item) =>\n this.upload(item.key, item.body, {\n ...operationOptions(options),\n ...(item.cacheControl !== undefined && {\n cacheControl: item.cacheControl,\n }),\n ...(item.contentType !== undefined && {\n contentType: item.contentType,\n }),\n ...(item.metadata !== undefined && { metadata: item.metadata }),\n ...(item.multipart !== undefined && {\n multipart: item.multipart,\n }),\n ...(options?.onProgress !== undefined && {\n onProgress: (progress) =>\n options.onProgress?.({ ...progress, key: item.key }),\n }),\n }),\n options,\n );\n\n return {\n uploaded: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async downloadMany(\n keys: readonly string[],\n options?: DownloadManyOptions,\n ): Promise<StorageDownloadManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n (key) => this.downloadStream(key, downloadOptions(options)),\n options,\n );\n return {\n downloaded: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async headMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageHeadManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n (key) => this.head(key, operationOptions(options)),\n options,\n );\n return {\n objects: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async existsMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageExistsManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n async (key) => ({ exists: await this.exists(key, options), key }),\n options,\n );\n const existing: string[] = [];\n const missing: string[] = [];\n for (const result of settled.results) {\n (result.exists ? existing : missing).push(result.key);\n }\n return {\n existing,\n missing,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async deleteMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageDeleteManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n async (key) => {\n await this.delete(key, operationOptions(options));\n return key;\n },\n options,\n );\n return {\n deleted: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async onApplicationShutdown(): Promise<void> {\n if (this.#closed) {\n return;\n }\n this.#closed = true;\n await this.#driver.close?.();\n }\n\n async #execute<Result>(\n context: StorageOperationContext,\n operation: () => Promise<Result>,\n ): Promise<Result> {\n try {\n for (const plugin of this.#plugins) {\n await plugin.beforeOperation?.(context);\n }\n const result = await operation();\n for (const plugin of this.#plugins) {\n await plugin.afterOperation?.(context, result);\n }\n return result;\n } catch (error) {\n const normalized = normalizeStorageError(error, {\n ...(context.key !== undefined && { key: context.key }),\n operation: context.operation,\n store: this.name,\n });\n for (const plugin of this.#plugins) {\n try {\n await plugin.onError?.(context, normalized);\n } catch {\n // Preserve the original storage error.\n }\n }\n throw normalized;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.client.js","sourceRoot":"","sources":["../src/storage.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AA+B5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAKrD,SAAS,SAAS,CAAC,GAAW,EAAE,KAAK,GAAG,KAAK;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,YAAY,CAAC,GAAG,KAAK,8BAA8B,EAAE;YAC7D,IAAI,EAAE,gBAAgB,CAAC,gBAAgB;YACvC,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,gBAAgB,CAAC,gBAAgB;QACvC,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,yBAAyB,CAChC,KAAyB,EACzB,KAAa;IAEb,IAAI,KAA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AE,OAAO,CAAC,SAAS;gBAC5B,KAAK,EAAE,IAAI,CAAC,IAAI;aACjB,CAAC,CAAC;YACH,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;gBAC9C,CAAC;gBAAC,MAAM,CAAC;oBACP,uCAAuC;gBACzC,CAAC;YACH,CAAC;YACD,MAAM,UAAU,CAAC;QACnB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { settleMany } from './internal/settle-many.js';\nimport {\n StorageError,\n StorageErrorCode,\n normalizeStorageError,\n} from './storage.error.js';\nimport type { StorageDriver } from './storage.driver.js';\nimport type {\n StorageBody,\n StorageBufferedDownloadOptions,\n StorageBulkOptions,\n StorageCapabilities,\n StorageDeleteManyResult,\n StorageDownloadManyResult,\n StorageDownloadOptions,\n StorageExistsManyResult,\n StorageHeadManyResult,\n StorageListOptions,\n StorageListResult,\n StorageObject,\n StorageObjectMetadata,\n StorageOperationContext,\n StorageOperationOptions,\n StoragePlugin,\n StoragePromotionOptions,\n StorageSearchOptions,\n StorageSignedDownloadOptions,\n StorageSignedUpload,\n StorageSignedUploadOptions,\n StorageUploadManyItem,\n StorageUploadManyOptions,\n StorageUploadManyResult,\n StorageUploadOptions,\n StorageUploadResult,\n} from './storage.types.js';\n\nexport const DEFAULT_BUFFER_LIMIT = 10 * 1024 * 1024;\n\ntype BulkOperationOptions = StorageBulkOptions & StorageOperationOptions;\ntype DownloadManyOptions = StorageBulkOptions & StorageDownloadOptions;\n\nfunction assertKey(key: string, label = 'key'): void {\n if (typeof key !== 'string' || key.length === 0) {\n throw new StorageError(`${label} must be a non-empty string.`, {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n });\n }\n}\n\nfunction invalidArgument(message: string): never {\n throw new StorageError(message, {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n });\n}\n\nfunction assertPositiveSafeInteger(\n value: number | undefined,\n label: string,\n): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {\n invalidArgument(`${label} must be a positive safe integer.`);\n }\n}\n\nfunction assertDownloadOptions(options?: StorageDownloadOptions): void {\n const range = options?.range;\n if (range === undefined) {\n return;\n }\n if (!Number.isSafeInteger(range.start) || range.start < 0) {\n invalidArgument('range.start must be a non-negative safe integer.');\n }\n if (\n range.end !== undefined &&\n (!Number.isSafeInteger(range.end) || range.end < range.start)\n ) {\n invalidArgument(\n 'range.end must be a safe integer greater than or equal to range.start.',\n );\n }\n}\n\nfunction assertListOptions(options?: StorageListOptions): void {\n if (options?.delimiter !== undefined && options.delimiter.length === 0) {\n invalidArgument('delimiter must be a non-empty string.');\n }\n assertPositiveSafeInteger(options?.limit, 'limit');\n}\n\nfunction assertSearchOptions(options?: StorageSearchOptions): void {\n assertPositiveSafeInteger(options?.limit, 'limit');\n assertPositiveSafeInteger(options?.maxResults, 'maxResults');\n}\n\nfunction assertSignedUploadOptions(options: StorageSignedUploadOptions): void {\n assertPositiveSafeInteger(options.expiresIn, 'expiresIn');\n assertPositiveSafeInteger(options.maxSize, 'maxSize');\n if (\n options.minSize !== undefined &&\n (!Number.isSafeInteger(options.minSize) || options.minSize < 0)\n ) {\n invalidArgument('minSize must be a non-negative safe integer.');\n }\n if (\n options.minSize !== undefined &&\n options.maxSize !== undefined &&\n options.minSize > options.maxSize\n ) {\n invalidArgument('minSize cannot be greater than maxSize.');\n }\n}\n\nfunction operationOptions(\n options?: BulkOperationOptions,\n): StorageOperationOptions | undefined {\n if (options === undefined) {\n return undefined;\n }\n return {\n ...(options.retries !== undefined && { retries: options.retries }),\n ...(options.signal !== undefined && { signal: options.signal }),\n ...(options.timeout !== undefined && { timeout: options.timeout }),\n };\n}\n\nfunction downloadOptions(\n options?: DownloadManyOptions,\n): StorageDownloadOptions | undefined {\n if (options === undefined) {\n return undefined;\n }\n return {\n ...operationOptions(options),\n ...(options.range !== undefined && { range: options.range }),\n };\n}\n\nasync function collectBody(\n object: StorageObject,\n maxBytes: number,\n): Promise<Uint8Array> {\n if (maxBytes !== Infinity && (!Number.isFinite(maxBytes) || maxBytes < 0)) {\n await object.body.cancel().catch(() => undefined);\n throw new StorageError(\n 'maxBytes must be a non-negative finite number or Infinity.',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n key: object.key,\n permanent: true,\n },\n );\n }\n\n if (maxBytes !== Infinity && object.size > maxBytes) {\n await object.body.cancel().catch(() => undefined);\n throw new StorageError(\n `Object \"${object.key}\" is ${object.size} bytes, exceeding the ${maxBytes}-byte buffer limit.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: object.key,\n permanent: true,\n },\n );\n }\n\n const chunks: Uint8Array[] = [];\n let total = 0;\n const reader = object.body.getReader();\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n total += value.byteLength;\n if (maxBytes !== Infinity && total > maxBytes) {\n await reader.cancel().catch(() => undefined);\n throw new StorageError(\n `Object \"${object.key}\" exceeded the ${maxBytes}-byte buffer limit while downloading.`,\n {\n code: StorageErrorCode.LIMIT_EXCEEDED,\n key: object.key,\n permanent: true,\n },\n );\n }\n chunks.push(value);\n }\n } finally {\n reader.releaseLock();\n }\n\n const bytes = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n}\n\nexport interface StorageFileHandle {\n readonly key: string;\n upload(\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult>;\n download(options?: StorageDownloadOptions): Promise<StorageObject>;\n bytes(options?: StorageBufferedDownloadOptions): Promise<Uint8Array>;\n text(options?: StorageBufferedDownloadOptions): Promise<string>;\n head(options?: StorageOperationOptions): Promise<StorageObjectMetadata>;\n exists(options?: StorageOperationOptions): Promise<boolean>;\n delete(options?: StorageOperationOptions): Promise<void>;\n signDownload(options?: StorageSignedDownloadOptions): Promise<string>;\n signUpload(options: StorageSignedUploadOptions): Promise<StorageSignedUpload>;\n copyTo(\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n moveTo(\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n /** Conditionally copies this staged object and deliberately retains it. */\n promoteTo(\n destinationKey: string,\n options: StoragePromotionOptions,\n ): Promise<void>;\n}\n\nexport class StorageClient {\n readonly #driver: StorageDriver;\n readonly #plugins: readonly StoragePlugin[];\n #closed = false;\n\n constructor(\n readonly name: string,\n driver: StorageDriver,\n plugins: readonly StoragePlugin[] = [],\n ) {\n assertKey(name, 'store name');\n this.#driver = driver;\n this.#plugins = [...plugins];\n }\n\n get driverName(): string {\n return this.#driver.name;\n }\n\n get capabilities(): Readonly<StorageCapabilities> {\n return this.#driver.capabilities;\n }\n\n file(key: string): StorageFileHandle {\n assertKey(key);\n return {\n copyTo: (destinationKey, options) =>\n this.copy(key, destinationKey, options),\n delete: (options) => this.delete(key, options),\n download: (options) => this.downloadStream(key, options),\n exists: (options) => this.exists(key, options),\n head: (options) => this.head(key, options),\n key,\n moveTo: (destinationKey, options) =>\n this.move(key, destinationKey, options),\n promoteTo: (destinationKey, options) =>\n this.promote(key, destinationKey, options),\n signDownload: (options) => this.signDownload(key, options),\n signUpload: (options) => this.signUpload(key, options),\n bytes: (options) => this.downloadBytes(key, options),\n text: (options) => this.downloadText(key, options),\n upload: (body, options) => this.upload(key, body, options),\n };\n }\n\n upload(\n key: string,\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult> {\n assertKey(key);\n return this.#execute({ key, operation: 'upload', store: this.name }, () =>\n this.#driver.upload(key, body, options),\n );\n }\n\n downloadStream(\n key: string,\n options?: StorageDownloadOptions,\n ): Promise<StorageObject> {\n assertKey(key);\n assertDownloadOptions(options);\n return this.#execute({ key, operation: 'download', store: this.name }, () =>\n this.#driver.download(key, options),\n );\n }\n\n async downloadBytes(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<Uint8Array> {\n const { maxBytes = DEFAULT_BUFFER_LIMIT, ...download } = options ?? {};\n const object = await this.downloadStream(key, download);\n return collectBody(object, maxBytes);\n }\n\n async downloadText(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<string> {\n return new TextDecoder().decode(await this.downloadBytes(key, options));\n }\n\n async downloadJson<Result = unknown>(\n key: string,\n options?: StorageBufferedDownloadOptions,\n ): Promise<Result> {\n const text = await this.downloadText(key, options);\n try {\n return JSON.parse(text) as Result;\n } catch (error) {\n throw new StorageError(`Object \"${key}\" does not contain valid JSON.`, {\n cause: error,\n code: StorageErrorCode.INVALID_ARGUMENT,\n key,\n operation: 'download',\n permanent: true,\n store: this.name,\n });\n }\n }\n\n head(\n key: string,\n options?: StorageOperationOptions,\n ): Promise<StorageObjectMetadata> {\n assertKey(key);\n return this.#execute({ key, operation: 'head', store: this.name }, () =>\n this.#driver.head(key, options),\n );\n }\n\n exists(key: string, options?: StorageOperationOptions): Promise<boolean> {\n assertKey(key);\n return this.#execute({ key, operation: 'exists', store: this.name }, () =>\n this.#driver.exists(key, options),\n );\n }\n\n delete(key: string, options?: StorageOperationOptions): Promise<void> {\n assertKey(key);\n return this.#execute({ key, operation: 'delete', store: this.name }, () =>\n this.#driver.delete(key, options),\n );\n }\n\n copy(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void> {\n assertKey(sourceKey, 'source key');\n assertKey(destinationKey, 'destination key');\n return this.#execute(\n {\n from: sourceKey,\n operation: 'copy',\n store: this.name,\n to: destinationKey,\n },\n () => this.#driver.copy(sourceKey, destinationKey, options),\n );\n }\n\n move(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void> {\n assertKey(sourceKey, 'source key');\n assertKey(destinationKey, 'destination key');\n return this.#execute(\n {\n from: sourceKey,\n operation: 'move',\n store: this.name,\n to: destinationKey,\n },\n () => this.#driver.move(sourceKey, destinationKey, options),\n );\n }\n\n /**\n * Conditionally copies a staged object to a final key. This operation does\n * not delete the source; delete it after the application commit succeeds.\n */\n promote(\n sourceKey: string,\n destinationKey: string,\n options: StoragePromotionOptions,\n ): Promise<void> {\n assertKey(sourceKey, 'source key');\n assertKey(destinationKey, 'destination key');\n const sourceEtag = options.sourceEtag;\n const sourceVersion = options.sourceVersion;\n if (sourceEtag !== undefined && sourceEtag.length === 0) {\n invalidArgument('sourceEtag must be a non-empty string.');\n }\n if (sourceVersion !== undefined && sourceVersion.length === 0) {\n invalidArgument('sourceVersion must be a non-empty string.');\n }\n if (sourceEtag === undefined && sourceVersion === undefined) {\n invalidArgument('promote requires sourceEtag, sourceVersion, or both.');\n }\n\n const capability = this.#driver.capabilities.conditionalCopy;\n const promote = this.#driver.promote;\n if (\n capability?.supported !== true ||\n promote === undefined ||\n (sourceEtag !== undefined && !capability.etag) ||\n (sourceVersion !== undefined && !capability.version)\n ) {\n throw new StorageError(\n `Store \"${this.name}\" does not support the requested conditional promotion.`,\n {\n code: StorageErrorCode.NOT_SUPPORTED,\n key: sourceKey,\n operation: 'promote',\n permanent: true,\n store: this.name,\n },\n );\n }\n\n return this.#execute(\n {\n from: sourceKey,\n operation: 'promote',\n store: this.name,\n to: destinationKey,\n },\n () => promote.call(this.#driver, sourceKey, destinationKey, options),\n );\n }\n\n list(options?: StorageListOptions): Promise<StorageListResult> {\n assertListOptions(options);\n return this.#execute({ operation: 'list', store: this.name }, () =>\n this.#driver.list(options),\n );\n }\n\n async *listAll(\n options?: StorageListOptions,\n ): AsyncGenerator<StorageObjectMetadata, void> {\n const { delimiter: _delimiter, ...walkOptions } = options ?? {};\n void _delimiter;\n let cursor = walkOptions.cursor;\n const seen = new Set<string>();\n\n do {\n const page = await this.list({\n ...walkOptions,\n ...(cursor !== undefined && { cursor }),\n });\n yield* page.items;\n cursor = page.cursor;\n if (cursor !== undefined) {\n if (seen.has(cursor)) {\n throw new StorageError(\n `Store \"${this.name}\" returned a repeated pagination cursor.`,\n {\n code: StorageErrorCode.PROVIDER,\n operation: 'list',\n permanent: true,\n store: this.name,\n },\n );\n }\n seen.add(cursor);\n }\n } while (cursor !== undefined);\n }\n\n search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncIterable<StorageObjectMetadata> {\n assertSearchOptions(options);\n return this.#search(pattern, options);\n }\n\n async *#search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncGenerator<StorageObjectMetadata, void> {\n const context: StorageOperationContext = {\n operation: 'search',\n store: this.name,\n };\n try {\n for (const plugin of this.#plugins) {\n await plugin.beforeOperation?.(context);\n }\n for await (const object of this.#driver.search(pattern, options)) {\n yield object;\n }\n for (const plugin of this.#plugins) {\n await plugin.afterOperation?.(context, undefined);\n }\n } catch (error) {\n const normalized = normalizeStorageError(error, {\n operation: 'search',\n store: this.name,\n });\n for (const plugin of this.#plugins) {\n try {\n await plugin.onError?.(context, normalized);\n } catch {\n // Preserve the original storage error.\n }\n }\n throw normalized;\n }\n }\n\n signDownload(\n key: string,\n options?: StorageSignedDownloadOptions,\n ): Promise<string> {\n assertKey(key);\n return this.#execute(\n { key, operation: 'signDownload', store: this.name },\n () => this.#driver.signDownload(key, options),\n );\n }\n\n signUpload(\n key: string,\n options: StorageSignedUploadOptions,\n ): Promise<StorageSignedUpload> {\n assertKey(key);\n assertSignedUploadOptions(options);\n return this.#execute(\n { key, operation: 'signUpload', store: this.name },\n () => this.#driver.signUpload(key, options),\n );\n }\n\n async uploadMany(\n items: readonly StorageUploadManyItem[],\n options?: StorageUploadManyOptions,\n ): Promise<StorageUploadManyResult> {\n const settled = await settleMany(\n items,\n (item) => item.key,\n (item) =>\n this.upload(item.key, item.body, {\n ...operationOptions(options),\n ...(item.cacheControl !== undefined && {\n cacheControl: item.cacheControl,\n }),\n ...(item.contentType !== undefined && {\n contentType: item.contentType,\n }),\n ...(item.metadata !== undefined && { metadata: item.metadata }),\n ...(item.multipart !== undefined && {\n multipart: item.multipart,\n }),\n ...(options?.onProgress !== undefined && {\n onProgress: (progress) =>\n options.onProgress?.({ ...progress, key: item.key }),\n }),\n }),\n options,\n );\n\n return {\n uploaded: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async downloadMany(\n keys: readonly string[],\n options?: DownloadManyOptions,\n ): Promise<StorageDownloadManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n (key) => this.downloadStream(key, downloadOptions(options)),\n options,\n );\n return {\n downloaded: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async headMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageHeadManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n (key) => this.head(key, operationOptions(options)),\n options,\n );\n return {\n objects: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async existsMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageExistsManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n async (key) => ({ exists: await this.exists(key, options), key }),\n options,\n );\n const existing: string[] = [];\n const missing: string[] = [];\n for (const result of settled.results) {\n (result.exists ? existing : missing).push(result.key);\n }\n return {\n existing,\n missing,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async deleteMany(\n keys: readonly string[],\n options?: BulkOperationOptions,\n ): Promise<StorageDeleteManyResult> {\n const settled = await settleMany(\n keys,\n (key) => key,\n async (key) => {\n await this.delete(key, operationOptions(options));\n return key;\n },\n options,\n );\n return {\n deleted: settled.results,\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async onApplicationShutdown(): Promise<void> {\n if (this.#closed) {\n return;\n }\n this.#closed = true;\n await this.#driver.close?.();\n }\n\n async #execute<Result>(\n context: StorageOperationContext,\n operation: () => Promise<Result>,\n ): Promise<Result> {\n try {\n for (const plugin of this.#plugins) {\n await plugin.beforeOperation?.(context);\n }\n const result = await operation();\n for (const plugin of this.#plugins) {\n await plugin.afterOperation?.(context, result);\n }\n return result;\n } catch (error) {\n const normalized = normalizeStorageError(error, {\n ...(context.key !== undefined && { key: context.key }),\n operation: context.operation,\n store: this.name,\n });\n for (const plugin of this.#plugins) {\n try {\n await plugin.onError?.(context, normalized);\n } catch {\n // Preserve the original storage error.\n }\n }\n throw normalized;\n }\n }\n}\n"]}
|
package/dist/storage.driver.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StorageBody, StorageCapabilities, StorageDownloadOptions, StorageListOptions, StorageListResult, StorageObject, StorageObjectMetadata, StorageOperationOptions, StorageSearchOptions, StorageSignedDownloadOptions, StorageSignedUpload, StorageSignedUploadOptions, StorageUploadOptions, StorageUploadResult } from './storage.types.js';
|
|
1
|
+
import type { StorageBody, StorageCapabilities, StorageDownloadOptions, StorageListOptions, StorageListResult, StorageObject, StorageObjectMetadata, StorageOperationOptions, StoragePromotionOptions, StorageSearchOptions, StorageSignedDownloadOptions, StorageSignedUpload, StorageSignedUploadOptions, StorageUploadOptions, StorageUploadResult } from './storage.types.js';
|
|
2
2
|
export interface StorageDriver {
|
|
3
3
|
readonly name: string;
|
|
4
4
|
readonly capabilities: StorageCapabilities;
|
|
@@ -9,6 +9,11 @@ export interface StorageDriver {
|
|
|
9
9
|
delete(key: string, options?: StorageOperationOptions): Promise<void>;
|
|
10
10
|
copy(sourceKey: string, destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
11
11
|
move(sourceKey: string, destinationKey: string, options?: StorageOperationOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Conditionally copies a staged object to its final key. The source remains
|
|
14
|
+
* in place so applications can delete it only after their metadata commit.
|
|
15
|
+
*/
|
|
16
|
+
promote?(sourceKey: string, destinationKey: string, options: StoragePromotionOptions): Promise<void>;
|
|
12
17
|
list(options?: StorageListOptions): Promise<StorageListResult>;
|
|
13
18
|
search(pattern: string | RegExp, options?: StorageSearchOptions): AsyncIterable<StorageObjectMetadata>;
|
|
14
19
|
signDownload(key: string, options?: StorageSignedDownloadOptions): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.driver.d.ts","sourceRoot":"","sources":["../src/storage.driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,4BAA4B,EAC5B,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAE3C,MAAM,CACJ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW,EACjB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B,IAAI,CACF,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,cAAc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
|
|
1
|
-
{"version":3,"file":"storage.driver.js","sourceRoot":"","sources":["../src/storage.driver.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n StorageBody,\n StorageCapabilities,\n StorageDownloadOptions,\n StorageListOptions,\n StorageListResult,\n StorageObject,\n StorageObjectMetadata,\n StorageOperationOptions,\n StorageSearchOptions,\n StorageSignedDownloadOptions,\n StorageSignedUpload,\n StorageSignedUploadOptions,\n StorageUploadOptions,\n StorageUploadResult,\n} from './storage.types.js';\n\nexport interface StorageDriver {\n readonly name: string;\n readonly capabilities: StorageCapabilities;\n\n upload(\n key: string,\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult>;\n download(\n key: string,\n options?: StorageDownloadOptions,\n ): Promise<StorageObject>;\n head(\n key: string,\n options?: StorageOperationOptions,\n ): Promise<StorageObjectMetadata>;\n exists(key: string, options?: StorageOperationOptions): Promise<boolean>;\n delete(key: string, options?: StorageOperationOptions): Promise<void>;\n copy(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n move(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n list(options?: StorageListOptions): Promise<StorageListResult>;\n search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncIterable<StorageObjectMetadata>;\n signDownload(\n key: string,\n options?: StorageSignedDownloadOptions,\n ): Promise<string>;\n signUpload(\n key: string,\n options: StorageSignedUploadOptions,\n ): Promise<StorageSignedUpload>;\n close?(): void | Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.driver.js","sourceRoot":"","sources":["../src/storage.driver.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n StorageBody,\n StorageCapabilities,\n StorageDownloadOptions,\n StorageListOptions,\n StorageListResult,\n StorageObject,\n StorageObjectMetadata,\n StorageOperationOptions,\n StoragePromotionOptions,\n StorageSearchOptions,\n StorageSignedDownloadOptions,\n StorageSignedUpload,\n StorageSignedUploadOptions,\n StorageUploadOptions,\n StorageUploadResult,\n} from './storage.types.js';\n\nexport interface StorageDriver {\n readonly name: string;\n readonly capabilities: StorageCapabilities;\n\n upload(\n key: string,\n body: StorageBody,\n options?: StorageUploadOptions,\n ): Promise<StorageUploadResult>;\n download(\n key: string,\n options?: StorageDownloadOptions,\n ): Promise<StorageObject>;\n head(\n key: string,\n options?: StorageOperationOptions,\n ): Promise<StorageObjectMetadata>;\n exists(key: string, options?: StorageOperationOptions): Promise<boolean>;\n delete(key: string, options?: StorageOperationOptions): Promise<void>;\n copy(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n move(\n sourceKey: string,\n destinationKey: string,\n options?: StorageOperationOptions,\n ): Promise<void>;\n /**\n * Conditionally copies a staged object to its final key. The source remains\n * in place so applications can delete it only after their metadata commit.\n */\n promote?(\n sourceKey: string,\n destinationKey: string,\n options: StoragePromotionOptions,\n ): Promise<void>;\n list(options?: StorageListOptions): Promise<StorageListResult>;\n search(\n pattern: string | RegExp,\n options?: StorageSearchOptions,\n ): AsyncIterable<StorageObjectMetadata>;\n signDownload(\n key: string,\n options?: StorageSignedDownloadOptions,\n ): Promise<string>;\n signUpload(\n key: string,\n options: StorageSignedUploadOptions,\n ): Promise<StorageSignedUpload>;\n close?(): void | Promise<void>;\n}\n"]}
|
package/dist/storage.error.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const StorageErrorCode: {
|
|
|
11
11
|
readonly PROVIDER: "PROVIDER";
|
|
12
12
|
};
|
|
13
13
|
export type StorageErrorCode = (typeof StorageErrorCode)[keyof typeof StorageErrorCode];
|
|
14
|
+
declare const STORAGE_ERROR_BRAND: unique symbol;
|
|
14
15
|
export interface StorageErrorOptions {
|
|
15
16
|
code: StorageErrorCode;
|
|
16
17
|
store?: string;
|
|
@@ -22,6 +23,7 @@ export interface StorageErrorOptions {
|
|
|
22
23
|
cause?: unknown;
|
|
23
24
|
}
|
|
24
25
|
export declare class StorageError extends Error {
|
|
26
|
+
readonly [STORAGE_ERROR_BRAND]: true;
|
|
25
27
|
readonly code: StorageErrorCode;
|
|
26
28
|
readonly store: string | undefined;
|
|
27
29
|
readonly operation: string | undefined;
|
|
@@ -36,4 +38,5 @@ export declare function isStorageError(error: unknown): error is StorageError;
|
|
|
36
38
|
export declare function normalizeStorageError(error: unknown, options?: Omit<StorageErrorOptions, 'code' | 'cause'> & {
|
|
37
39
|
code?: StorageErrorCode;
|
|
38
40
|
}): StorageError;
|
|
41
|
+
export {};
|
|
39
42
|
//# sourceMappingURL=storage.error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.error.d.ts","sourceRoot":"","sources":["../src/storage.error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;CAWnB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAA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;gBAEtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB;CAkB1D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAoCpE;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACrD,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACpB,GACL,YAAY,CAYd"}
|
package/dist/storage.error.js
CHANGED
|
@@ -10,6 +10,10 @@ export const StorageErrorCode = {
|
|
|
10
10
|
LIMIT_EXCEEDED: 'LIMIT_EXCEEDED',
|
|
11
11
|
PROVIDER: 'PROVIDER',
|
|
12
12
|
};
|
|
13
|
+
const STORAGE_ERROR_BRAND = Symbol.for('@nestm/storage/StorageError');
|
|
14
|
+
function isStorageErrorCode(value) {
|
|
15
|
+
return Object.values(StorageErrorCode).includes(value);
|
|
16
|
+
}
|
|
13
17
|
export class StorageError extends Error {
|
|
14
18
|
code;
|
|
15
19
|
store;
|
|
@@ -21,6 +25,12 @@ export class StorageError extends Error {
|
|
|
21
25
|
cause;
|
|
22
26
|
constructor(message, options) {
|
|
23
27
|
super(message, { cause: options.cause });
|
|
28
|
+
Object.defineProperty(this, STORAGE_ERROR_BRAND, {
|
|
29
|
+
configurable: false,
|
|
30
|
+
enumerable: false,
|
|
31
|
+
value: true,
|
|
32
|
+
writable: false,
|
|
33
|
+
});
|
|
24
34
|
this.name = 'StorageError';
|
|
25
35
|
this.code = options.code;
|
|
26
36
|
this.store = options.store;
|
|
@@ -33,7 +43,29 @@ export class StorageError extends Error {
|
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
export function isStorageError(error) {
|
|
36
|
-
|
|
46
|
+
if (error instanceof StorageError) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (!(error instanceof Error) || error.name !== 'StorageError') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const candidate = error;
|
|
54
|
+
const hasCompatibleBrand = candidate[STORAGE_ERROR_BRAND] === true ||
|
|
55
|
+
candidate[STORAGE_ERROR_BRAND] === undefined;
|
|
56
|
+
return (hasCompatibleBrand &&
|
|
57
|
+
isStorageErrorCode(candidate.code) &&
|
|
58
|
+
typeof candidate.aborted === 'boolean' &&
|
|
59
|
+
typeof candidate.timedOut === 'boolean' &&
|
|
60
|
+
typeof candidate.permanent === 'boolean' &&
|
|
61
|
+
(candidate.store === undefined || typeof candidate.store === 'string') &&
|
|
62
|
+
(candidate.operation === undefined ||
|
|
63
|
+
typeof candidate.operation === 'string') &&
|
|
64
|
+
(candidate.key === undefined || typeof candidate.key === 'string'));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
37
69
|
}
|
|
38
70
|
export function normalizeStorageError(error, options = {}) {
|
|
39
71
|
if (isStorageError(error)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.error.js","sourceRoot":"","sources":["../src/storage.error.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,gBAAgB;IAChC,QAAQ,EAAE,UAAU;CACZ,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.error.js","sourceRoot":"","sources":["../src/storage.error.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW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C1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEvE,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE;QAC/B,GAAG,OAAO;QACV,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,gBAAgB,CAAC,QAAQ;KAChD,CAAC,CAAC;AACL,CAAC","sourcesContent":["export const StorageErrorCode = {\n NOT_FOUND: 'NOT_FOUND',\n UNAUTHORIZED: 'UNAUTHORIZED',\n CONFLICT: 'CONFLICT',\n READ_ONLY: 'READ_ONLY',\n INVALID_ARGUMENT: 'INVALID_ARGUMENT',\n NOT_SUPPORTED: 'NOT_SUPPORTED',\n ABORTED: 'ABORTED',\n TIMEOUT: 'TIMEOUT',\n LIMIT_EXCEEDED: 'LIMIT_EXCEEDED',\n PROVIDER: 'PROVIDER',\n} as const;\n\nexport type StorageErrorCode =\n (typeof StorageErrorCode)[keyof typeof StorageErrorCode];\n\nconst STORAGE_ERROR_BRAND = Symbol.for('@nestm/storage/StorageError');\n\nfunction isStorageErrorCode(value: unknown): value is StorageErrorCode {\n return Object.values(StorageErrorCode).includes(value as StorageErrorCode);\n}\n\nexport interface StorageErrorOptions {\n code: StorageErrorCode;\n store?: string;\n operation?: string;\n key?: string;\n aborted?: boolean;\n timedOut?: boolean;\n permanent?: boolean;\n cause?: unknown;\n}\n\nexport class StorageError extends Error {\n declare readonly [STORAGE_ERROR_BRAND]: true;\n readonly code: StorageErrorCode;\n readonly store: string | undefined;\n readonly operation: string | undefined;\n readonly key: string | undefined;\n readonly aborted: boolean;\n readonly timedOut: boolean;\n readonly permanent: boolean;\n override readonly cause?: unknown;\n\n constructor(message: string, options: StorageErrorOptions) {\n super(message, { cause: options.cause });\n Object.defineProperty(this, STORAGE_ERROR_BRAND, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n });\n this.name = 'StorageError';\n this.code = options.code;\n this.store = options.store;\n this.operation = options.operation;\n this.key = options.key;\n this.aborted = options.aborted === true;\n this.timedOut = options.timedOut === true;\n this.permanent = options.permanent === true;\n this.cause = options.cause;\n }\n}\n\nexport function isStorageError(error: unknown): error is StorageError {\n if (error instanceof StorageError) {\n return true;\n }\n if (!(error instanceof Error) || error.name !== 'StorageError') {\n return false;\n }\n\n try {\n const candidate = error as Error & {\n readonly [STORAGE_ERROR_BRAND]?: unknown;\n readonly aborted?: unknown;\n readonly code?: unknown;\n readonly key?: unknown;\n readonly operation?: unknown;\n readonly permanent?: unknown;\n readonly store?: unknown;\n readonly timedOut?: unknown;\n };\n const hasCompatibleBrand =\n candidate[STORAGE_ERROR_BRAND] === true ||\n candidate[STORAGE_ERROR_BRAND] === undefined;\n return (\n hasCompatibleBrand &&\n isStorageErrorCode(candidate.code) &&\n typeof candidate.aborted === 'boolean' &&\n typeof candidate.timedOut === 'boolean' &&\n typeof candidate.permanent === 'boolean' &&\n (candidate.store === undefined || typeof candidate.store === 'string') &&\n (candidate.operation === undefined ||\n typeof candidate.operation === 'string') &&\n (candidate.key === undefined || typeof candidate.key === 'string')\n );\n } catch {\n return false;\n }\n}\n\nexport function normalizeStorageError(\n error: unknown,\n options: Omit<StorageErrorOptions, 'code' | 'cause'> & {\n code?: StorageErrorCode;\n } = {},\n): StorageError {\n if (isStorageError(error)) {\n return error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n\n return new StorageError(message, {\n ...options,\n cause: error,\n code: options.code ?? StorageErrorCode.PROVIDER,\n });\n}\n"]}
|
package/dist/storage.types.d.ts
CHANGED
|
@@ -15,6 +15,16 @@ export interface StorageOperationOptions {
|
|
|
15
15
|
timeout?: number;
|
|
16
16
|
retries?: StorageRetryOptions;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Preconditions for promoting a staged object to its final key. At least one
|
|
20
|
+
* source identity must be supplied; unsupported identities fail closed.
|
|
21
|
+
*/
|
|
22
|
+
export interface StoragePromotionOptions extends StorageOperationOptions {
|
|
23
|
+
/** Copy only the source object whose provider ETag exactly matches. */
|
|
24
|
+
sourceEtag?: string;
|
|
25
|
+
/** Copy this immutable provider version of the source object. */
|
|
26
|
+
sourceVersion?: string;
|
|
27
|
+
}
|
|
18
28
|
export interface StorageMultipartOptions {
|
|
19
29
|
partSize?: number;
|
|
20
30
|
concurrency?: number;
|
|
@@ -106,6 +116,21 @@ export interface StorageSignedUrlCapability {
|
|
|
106
116
|
supported: boolean;
|
|
107
117
|
maxExpiresIn?: number;
|
|
108
118
|
}
|
|
119
|
+
export interface StorageConditionalCopyCapability {
|
|
120
|
+
supported: boolean;
|
|
121
|
+
etag: boolean;
|
|
122
|
+
version: boolean;
|
|
123
|
+
}
|
|
124
|
+
export interface StorageSignedUploadPolicyCapability {
|
|
125
|
+
/** The signed request fixes the exact declared content type. */
|
|
126
|
+
contentType: boolean;
|
|
127
|
+
/** The signed request enforces the requested min/max byte range. */
|
|
128
|
+
sizeRange: boolean;
|
|
129
|
+
}
|
|
130
|
+
export interface StorageSignedDownloadPolicyCapability {
|
|
131
|
+
/** Every generated URL honors the requested expiry. */
|
|
132
|
+
expiresIn: boolean;
|
|
133
|
+
}
|
|
109
134
|
export interface StorageCapabilities {
|
|
110
135
|
rangeRead: boolean;
|
|
111
136
|
/** True when the provider reports native byte-level upload progress. */
|
|
@@ -115,12 +140,25 @@ export interface StorageCapabilities {
|
|
|
115
140
|
cacheControl: boolean;
|
|
116
141
|
resumableUpload: boolean;
|
|
117
142
|
serverSideCopy: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Conditional server-side copy used to promote an already verified staged
|
|
145
|
+
* object without a validation/copy race. Absent means unsupported for
|
|
146
|
+
* compatibility with drivers built against earlier package versions.
|
|
147
|
+
*/
|
|
148
|
+
conditionalCopy?: StorageConditionalCopyCapability;
|
|
118
149
|
signedDownload: StorageSignedUrlCapability;
|
|
150
|
+
/** Expiry guarantees enforced by the provider adapter. */
|
|
151
|
+
signedDownloadPolicy?: StorageSignedDownloadPolicyCapability;
|
|
119
152
|
/**
|
|
120
153
|
* Some providers decide support from credentials or requested constraints,
|
|
121
154
|
* so direct-upload support can only be known when the call is attempted.
|
|
122
155
|
*/
|
|
123
156
|
signedUpload: boolean | 'runtime';
|
|
157
|
+
/**
|
|
158
|
+
* Constraints cryptographically/provider-policy enforced by direct upload.
|
|
159
|
+
* Absent means callers must not assume request options are enforced.
|
|
160
|
+
*/
|
|
161
|
+
signedUploadPolicy?: StorageSignedUploadPolicyCapability;
|
|
124
162
|
}
|
|
125
163
|
export interface StorageBulkOptions {
|
|
126
164
|
concurrency?: number;
|
|
@@ -164,7 +202,7 @@ export interface StorageDeleteManyResult {
|
|
|
164
202
|
deleted: string[];
|
|
165
203
|
errors?: StorageBulkError[];
|
|
166
204
|
}
|
|
167
|
-
export type StorageOperationName = 'upload' | 'download' | 'head' | 'exists' | 'delete' | 'copy' | 'move' | 'list' | 'search' | 'signDownload' | 'signUpload';
|
|
205
|
+
export type StorageOperationName = 'upload' | 'download' | 'head' | 'exists' | 'delete' | 'copy' | 'move' | 'promote' | 'list' | 'search' | 'signDownload' | 'signUpload';
|
|
168
206
|
export interface StorageOperationContext {
|
|
169
207
|
store: string;
|
|
170
208
|
operation: StorageOperationName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.types.d.ts","sourceRoot":"","sources":["../src/storage.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,MAAM,WAAW,GACnB,IAAI,GACJ,IAAI,GACJ,cAAc,CAAC,UAAU,CAAC,GAC1B,QAAQ,GACR,WAAW,GACX,eAAe,GACf,UAA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IACZ,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.types.js","sourceRoot":"","sources":["../src/storage.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\n\nimport type { StorageError } from './storage.error.js';\nimport type { StorageUploadControl } from './storage-upload-control.js';\n\nexport type StorageBody =\n | Blob\n | File\n | ReadableStream<Uint8Array>\n | Readable\n | ArrayBuffer\n | ArrayBufferView\n | Uint8Array\n | string;\n\nexport interface StorageRetryContext {\n attempt: number;\n error: StorageError;\n}\n\nexport type StorageRetryOptions =\n | number\n | {\n max: number;\n backoff?: (context: StorageRetryContext) => number;\n };\n\nexport interface StorageOperationOptions {\n signal?: AbortSignal;\n timeout?: number;\n retries?: StorageRetryOptions;\n}\n\nexport interface StorageMultipartOptions {\n partSize?: number;\n concurrency?: number;\n}\n\nexport interface StorageUploadProgress {\n loaded: number;\n total?: number;\n}\n\nexport interface StorageUploadOptions extends StorageOperationOptions {\n contentType?: string;\n cacheControl?: string;\n metadata?: Record<string, string>;\n onProgress?: (progress: StorageUploadProgress) => void;\n multipart?: boolean | StorageMultipartOptions;\n control?: StorageUploadControl;\n}\n\nexport interface StorageUploadResult {\n key: string;\n size: number;\n contentType: string;\n etag?: string;\n lastModified?: Date;\n}\n\nexport interface StorageObjectMetadata {\n key: string;\n name: string;\n size: number;\n contentType: string;\n etag?: string;\n lastModified?: Date;\n metadata?: Record<string, string>;\n}\n\nexport interface StorageObject extends StorageObjectMetadata {\n body: ReadableStream<Uint8Array>;\n}\n\nexport interface StorageByteRange {\n start: number;\n end?: number;\n}\n\nexport interface StorageDownloadOptions extends StorageOperationOptions {\n range?: StorageByteRange;\n}\n\nexport interface StorageBufferedDownloadOptions extends StorageDownloadOptions {\n /**\n * Maximum number of bytes buffered in memory. Defaults to 10 MiB.\n * Pass `Infinity` only when the caller has independently bounded the object.\n */\n maxBytes?: number;\n}\n\nexport interface StorageListOptions extends StorageOperationOptions {\n prefix?: string;\n cursor?: string;\n limit?: number;\n delimiter?: string;\n}\n\nexport interface StorageListResult {\n items: StorageObjectMetadata[];\n prefixes?: string[];\n cursor?: string;\n}\n\nexport type StorageSearchMatch = 'glob' | 'regex' | 'substring' | 'exact';\n\nexport interface StorageSearchOptions extends StorageOperationOptions {\n prefix?: string;\n limit?: number;\n maxResults?: number;\n match?: StorageSearchMatch;\n caseInsensitive?: boolean;\n}\n\nexport interface StorageSignedDownloadOptions extends StorageOperationOptions {\n expiresIn?: number;\n responseContentDisposition?: string;\n}\n\nexport interface StorageSignedUploadOptions extends StorageOperationOptions {\n expiresIn: number;\n contentType?: string;\n maxSize?: number;\n minSize?: number;\n}\n\nexport type StorageSignedUpload =\n | {\n method: 'PUT';\n url: string;\n headers?: Record<string, string>;\n }\n | {\n method: 'POST';\n url: string;\n fields: Record<string, string>;\n };\n\nexport interface StorageSignedUrlCapability {\n supported: boolean;\n maxExpiresIn?: number;\n}\n\nexport interface StorageCapabilities {\n rangeRead: boolean;\n /** True when the provider reports native byte-level upload progress. */\n nativeUploadProgress: boolean;\n delimiter: boolean;\n metadata: boolean;\n cacheControl: boolean;\n resumableUpload: boolean;\n serverSideCopy: boolean;\n signedDownload: StorageSignedUrlCapability;\n /**\n * Some providers decide support from credentials or requested constraints,\n * so direct-upload support can only be known when the call is attempted.\n */\n signedUpload: boolean | 'runtime';\n}\n\nexport interface StorageBulkOptions {\n concurrency?: number;\n stopOnError?: boolean;\n}\n\nexport interface StorageBulkError {\n key: string;\n error: StorageError;\n}\n\nexport interface StorageUploadManyItem {\n key: string;\n body: StorageBody;\n contentType?: string;\n cacheControl?: string;\n metadata?: Record<string, string>;\n multipart?: boolean | StorageMultipartOptions;\n}\n\nexport interface StorageUploadManyOptions\n extends StorageBulkOptions, StorageOperationOptions {\n onProgress?: (progress: StorageUploadProgress & { key: string }) => void;\n}\n\nexport interface StorageUploadManyResult {\n uploaded: StorageUploadResult[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageDownloadManyResult {\n downloaded: StorageObject[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageHeadManyResult {\n objects: StorageObjectMetadata[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageExistsManyResult {\n existing: string[];\n missing: string[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageDeleteManyResult {\n deleted: string[];\n errors?: StorageBulkError[];\n}\n\nexport type StorageOperationName =\n | 'upload'\n | 'download'\n | 'head'\n | 'exists'\n | 'delete'\n | 'copy'\n | 'move'\n | 'list'\n | 'search'\n | 'signDownload'\n | 'signUpload';\n\nexport interface StorageOperationContext {\n store: string;\n operation: StorageOperationName;\n key?: string;\n from?: string;\n to?: string;\n}\n\nexport interface StoragePlugin {\n name?: string;\n /**\n * Runs before the driver and may reject an operation, for example to enforce\n * policy. Hooks run in registration order.\n */\n beforeOperation?: (context: StorageOperationContext) => void | Promise<void>;\n /**\n * Observes a successful operation. Throwing turns the call into a failure,\n * which is useful for mandatory audit sinks.\n *\n * For streaming downloads, success means the provider returned a stream.\n * Later consumption failures are normalized for the stream consumer but do\n * not re-enter plugin hooks.\n */\n afterOperation?: (\n context: StorageOperationContext,\n result: unknown,\n ) => void | Promise<void>;\n /**\n * Best-effort error observation. Hook failures never replace the original\n * storage error.\n */\n onError?: (\n context: StorageOperationContext,\n error: StorageError,\n ) => void | Promise<void>;\n}\n\nexport interface StorageTransferProgress {\n done: number;\n total: number;\n key: string;\n status: 'transferred' | 'skipped';\n}\n\nexport interface StorageTransferOptions extends StorageBulkOptions {\n from: string;\n to: string;\n prefix?: string;\n transformKey?: (key: string) => string;\n overwrite?: boolean;\n limit?: number;\n signal?: AbortSignal;\n onProgress?: (progress: StorageTransferProgress) => void;\n}\n\nexport interface StorageTransferResult {\n transferred: string[];\n skipped?: string[];\n errors?: StorageBulkError[];\n}\n\nexport type StorageSyncCompare =\n | 'etag'\n | 'size'\n | ((\n source: StorageObjectMetadata,\n destination: StorageObjectMetadata,\n ) => boolean);\n\nexport interface StorageSyncProgress {\n done: number;\n total: number;\n key: string;\n status: 'uploaded' | 'skipped' | 'deleted';\n}\n\nexport interface StorageSyncOptions extends StorageBulkOptions {\n from: string;\n to: string;\n prefix?: string;\n destinationPrefix?: string;\n transformKey?: (key: string) => string;\n prune?: boolean;\n compare?: StorageSyncCompare;\n dryRun?: boolean;\n limit?: number;\n signal?: AbortSignal;\n onProgress?: (progress: StorageSyncProgress) => void;\n}\n\nexport interface StorageSyncResult {\n uploaded: string[];\n skipped: string[];\n deleted?: string[];\n errors?: StorageBulkError[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.types.js","sourceRoot":"","sources":["../src/storage.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\n\nimport type { StorageError } from './storage.error.js';\nimport type { StorageUploadControl } from './storage-upload-control.js';\n\nexport type StorageBody =\n | Blob\n | File\n | ReadableStream<Uint8Array>\n | Readable\n | ArrayBuffer\n | ArrayBufferView\n | Uint8Array\n | string;\n\nexport interface StorageRetryContext {\n attempt: number;\n error: StorageError;\n}\n\nexport type StorageRetryOptions =\n | number\n | {\n max: number;\n backoff?: (context: StorageRetryContext) => number;\n };\n\nexport interface StorageOperationOptions {\n signal?: AbortSignal;\n timeout?: number;\n retries?: StorageRetryOptions;\n}\n\n/**\n * Preconditions for promoting a staged object to its final key. At least one\n * source identity must be supplied; unsupported identities fail closed.\n */\nexport interface StoragePromotionOptions extends StorageOperationOptions {\n /** Copy only the source object whose provider ETag exactly matches. */\n sourceEtag?: string;\n /** Copy this immutable provider version of the source object. */\n sourceVersion?: string;\n}\n\nexport interface StorageMultipartOptions {\n partSize?: number;\n concurrency?: number;\n}\n\nexport interface StorageUploadProgress {\n loaded: number;\n total?: number;\n}\n\nexport interface StorageUploadOptions extends StorageOperationOptions {\n contentType?: string;\n cacheControl?: string;\n metadata?: Record<string, string>;\n onProgress?: (progress: StorageUploadProgress) => void;\n multipart?: boolean | StorageMultipartOptions;\n control?: StorageUploadControl;\n}\n\nexport interface StorageUploadResult {\n key: string;\n size: number;\n contentType: string;\n etag?: string;\n lastModified?: Date;\n}\n\nexport interface StorageObjectMetadata {\n key: string;\n name: string;\n size: number;\n contentType: string;\n etag?: string;\n lastModified?: Date;\n metadata?: Record<string, string>;\n}\n\nexport interface StorageObject extends StorageObjectMetadata {\n body: ReadableStream<Uint8Array>;\n}\n\nexport interface StorageByteRange {\n start: number;\n end?: number;\n}\n\nexport interface StorageDownloadOptions extends StorageOperationOptions {\n range?: StorageByteRange;\n}\n\nexport interface StorageBufferedDownloadOptions extends StorageDownloadOptions {\n /**\n * Maximum number of bytes buffered in memory. Defaults to 10 MiB.\n * Pass `Infinity` only when the caller has independently bounded the object.\n */\n maxBytes?: number;\n}\n\nexport interface StorageListOptions extends StorageOperationOptions {\n prefix?: string;\n cursor?: string;\n limit?: number;\n delimiter?: string;\n}\n\nexport interface StorageListResult {\n items: StorageObjectMetadata[];\n prefixes?: string[];\n cursor?: string;\n}\n\nexport type StorageSearchMatch = 'glob' | 'regex' | 'substring' | 'exact';\n\nexport interface StorageSearchOptions extends StorageOperationOptions {\n prefix?: string;\n limit?: number;\n maxResults?: number;\n match?: StorageSearchMatch;\n caseInsensitive?: boolean;\n}\n\nexport interface StorageSignedDownloadOptions extends StorageOperationOptions {\n expiresIn?: number;\n responseContentDisposition?: string;\n}\n\nexport interface StorageSignedUploadOptions extends StorageOperationOptions {\n expiresIn: number;\n contentType?: string;\n maxSize?: number;\n minSize?: number;\n}\n\nexport type StorageSignedUpload =\n | {\n method: 'PUT';\n url: string;\n headers?: Record<string, string>;\n }\n | {\n method: 'POST';\n url: string;\n fields: Record<string, string>;\n };\n\nexport interface StorageSignedUrlCapability {\n supported: boolean;\n maxExpiresIn?: number;\n}\n\nexport interface StorageConditionalCopyCapability {\n supported: boolean;\n etag: boolean;\n version: boolean;\n}\n\nexport interface StorageSignedUploadPolicyCapability {\n /** The signed request fixes the exact declared content type. */\n contentType: boolean;\n /** The signed request enforces the requested min/max byte range. */\n sizeRange: boolean;\n}\n\nexport interface StorageSignedDownloadPolicyCapability {\n /** Every generated URL honors the requested expiry. */\n expiresIn: boolean;\n}\n\nexport interface StorageCapabilities {\n rangeRead: boolean;\n /** True when the provider reports native byte-level upload progress. */\n nativeUploadProgress: boolean;\n delimiter: boolean;\n metadata: boolean;\n cacheControl: boolean;\n resumableUpload: boolean;\n serverSideCopy: boolean;\n /**\n * Conditional server-side copy used to promote an already verified staged\n * object without a validation/copy race. Absent means unsupported for\n * compatibility with drivers built against earlier package versions.\n */\n conditionalCopy?: StorageConditionalCopyCapability;\n signedDownload: StorageSignedUrlCapability;\n /** Expiry guarantees enforced by the provider adapter. */\n signedDownloadPolicy?: StorageSignedDownloadPolicyCapability;\n /**\n * Some providers decide support from credentials or requested constraints,\n * so direct-upload support can only be known when the call is attempted.\n */\n signedUpload: boolean | 'runtime';\n /**\n * Constraints cryptographically/provider-policy enforced by direct upload.\n * Absent means callers must not assume request options are enforced.\n */\n signedUploadPolicy?: StorageSignedUploadPolicyCapability;\n}\n\nexport interface StorageBulkOptions {\n concurrency?: number;\n stopOnError?: boolean;\n}\n\nexport interface StorageBulkError {\n key: string;\n error: StorageError;\n}\n\nexport interface StorageUploadManyItem {\n key: string;\n body: StorageBody;\n contentType?: string;\n cacheControl?: string;\n metadata?: Record<string, string>;\n multipart?: boolean | StorageMultipartOptions;\n}\n\nexport interface StorageUploadManyOptions\n extends StorageBulkOptions, StorageOperationOptions {\n onProgress?: (progress: StorageUploadProgress & { key: string }) => void;\n}\n\nexport interface StorageUploadManyResult {\n uploaded: StorageUploadResult[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageDownloadManyResult {\n downloaded: StorageObject[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageHeadManyResult {\n objects: StorageObjectMetadata[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageExistsManyResult {\n existing: string[];\n missing: string[];\n errors?: StorageBulkError[];\n}\n\nexport interface StorageDeleteManyResult {\n deleted: string[];\n errors?: StorageBulkError[];\n}\n\nexport type StorageOperationName =\n | 'upload'\n | 'download'\n | 'head'\n | 'exists'\n | 'delete'\n | 'copy'\n | 'move'\n | 'promote'\n | 'list'\n | 'search'\n | 'signDownload'\n | 'signUpload';\n\nexport interface StorageOperationContext {\n store: string;\n operation: StorageOperationName;\n key?: string;\n from?: string;\n to?: string;\n}\n\nexport interface StoragePlugin {\n name?: string;\n /**\n * Runs before the driver and may reject an operation, for example to enforce\n * policy. Hooks run in registration order.\n */\n beforeOperation?: (context: StorageOperationContext) => void | Promise<void>;\n /**\n * Observes a successful operation. Throwing turns the call into a failure,\n * which is useful for mandatory audit sinks.\n *\n * For streaming downloads, success means the provider returned a stream.\n * Later consumption failures are normalized for the stream consumer but do\n * not re-enter plugin hooks.\n */\n afterOperation?: (\n context: StorageOperationContext,\n result: unknown,\n ) => void | Promise<void>;\n /**\n * Best-effort error observation. Hook failures never replace the original\n * storage error.\n */\n onError?: (\n context: StorageOperationContext,\n error: StorageError,\n ) => void | Promise<void>;\n}\n\nexport interface StorageTransferProgress {\n done: number;\n total: number;\n key: string;\n status: 'transferred' | 'skipped';\n}\n\nexport interface StorageTransferOptions extends StorageBulkOptions {\n from: string;\n to: string;\n prefix?: string;\n transformKey?: (key: string) => string;\n overwrite?: boolean;\n limit?: number;\n signal?: AbortSignal;\n onProgress?: (progress: StorageTransferProgress) => void;\n}\n\nexport interface StorageTransferResult {\n transferred: string[];\n skipped?: string[];\n errors?: StorageBulkError[];\n}\n\nexport type StorageSyncCompare =\n | 'etag'\n | 'size'\n | ((\n source: StorageObjectMetadata,\n destination: StorageObjectMetadata,\n ) => boolean);\n\nexport interface StorageSyncProgress {\n done: number;\n total: number;\n key: string;\n status: 'uploaded' | 'skipped' | 'deleted';\n}\n\nexport interface StorageSyncOptions extends StorageBulkOptions {\n from: string;\n to: string;\n prefix?: string;\n destinationPrefix?: string;\n transformKey?: (key: string) => string;\n prune?: boolean;\n compare?: StorageSyncCompare;\n dryRun?: boolean;\n limit?: number;\n signal?: AbortSignal;\n onProgress?: (progress: StorageSyncProgress) => void;\n}\n\nexport interface StorageSyncResult {\n uploaded: string[];\n skipped: string[];\n deleted?: string[];\n errors?: StorageBulkError[];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestm/storage",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "Framework-neutral storage clients with NestJS 12 integration, named stores, streaming I/O, and an optional guarded HTTP gateway.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Kauan Guesser",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"types": "./dist/files-sdk/index.d.ts",
|
|
28
28
|
"import": "./dist/files-sdk/index.js"
|
|
29
29
|
},
|
|
30
|
+
"./files-sdk/s3": {
|
|
31
|
+
"types": "./dist/files-sdk/s3/index.d.ts",
|
|
32
|
+
"import": "./dist/files-sdk/s3/index.js"
|
|
33
|
+
},
|
|
30
34
|
"./gateway": {
|
|
31
35
|
"types": "./dist/gateway/index.d.ts",
|
|
32
36
|
"import": "./dist/gateway/index.js"
|
|
@@ -69,12 +73,28 @@
|
|
|
69
73
|
"files-sdk": "2.2.2"
|
|
70
74
|
},
|
|
71
75
|
"peerDependencies": {
|
|
76
|
+
"@aws-sdk/client-s3": "^3.700.0",
|
|
77
|
+
"@aws-sdk/lib-storage": "^3.700.0",
|
|
78
|
+
"@aws-sdk/s3-presigned-post": "^3.700.0",
|
|
79
|
+
"@aws-sdk/s3-request-presigner": "^3.700.0",
|
|
72
80
|
"@nestjs/common": "^12.0.0-alpha.5",
|
|
73
81
|
"@nestjs/core": "^12.0.0-alpha.5",
|
|
74
82
|
"reflect-metadata": "^0.2.2",
|
|
75
83
|
"rxjs": "^7.8.1"
|
|
76
84
|
},
|
|
77
85
|
"peerDependenciesMeta": {
|
|
86
|
+
"@aws-sdk/client-s3": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
89
|
+
"@aws-sdk/lib-storage": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"@aws-sdk/s3-presigned-post": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"@aws-sdk/s3-request-presigner": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
78
98
|
"@nestjs/common": {
|
|
79
99
|
"optional": true
|
|
80
100
|
},
|
|
@@ -89,6 +109,10 @@
|
|
|
89
109
|
}
|
|
90
110
|
},
|
|
91
111
|
"devDependencies": {
|
|
112
|
+
"@aws-sdk/client-s3": "3.1101.0",
|
|
113
|
+
"@aws-sdk/lib-storage": "3.1101.0",
|
|
114
|
+
"@aws-sdk/s3-presigned-post": "3.1101.0",
|
|
115
|
+
"@aws-sdk/s3-request-presigner": "3.1101.0",
|
|
92
116
|
"@changesets/cli": "2.31.1",
|
|
93
117
|
"@nestjs/common": "12.0.0-alpha.5",
|
|
94
118
|
"@nestjs/core": "12.0.0-alpha.5",
|