@nestm/storage 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +29 -0
- package/README.md +86 -3
- package/dist/files-sdk/files-sdk.driver.d.ts +18 -18
- package/dist/files-sdk/files-sdk.driver.d.ts.map +1 -1
- package/dist/files-sdk/fs/index.d.ts +21 -0
- package/dist/files-sdk/fs/index.d.ts.map +1 -0
- package/dist/files-sdk/fs/index.js +20 -0
- package/dist/files-sdk/fs/index.js.map +1 -0
- package/dist/files-sdk/provider/index.d.ts +54 -0
- package/dist/files-sdk/provider/index.d.ts.map +1 -0
- package/dist/files-sdk/provider/index.js +80 -0
- package/dist/files-sdk/provider/index.js.map +1 -0
- package/dist/files-sdk/s3/index.d.ts +13 -2
- package/dist/files-sdk/s3/index.d.ts.map +1 -1
- package/dist/files-sdk/s3/index.js +19 -8
- package/dist/files-sdk/s3/index.js.map +1 -1
- package/dist/gateway/storage-gateway-fastify-parser.d.ts.map +1 -1
- package/dist/gateway/storage-gateway-fastify-parser.js.map +1 -1
- package/dist/gateway/storage-gateway.controller.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.controller.js.map +1 -1
- package/dist/gateway/storage-gateway.guard.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.guard.js.map +1 -1
- package/dist/gateway/storage-gateway.module.d.ts.map +1 -1
- package/dist/gateway/storage-gateway.module.js.map +1 -1
- package/dist/gateway/storage-gateway.types.d.ts +10 -10
- package/dist/gateway/storage-gateway.types.d.ts.map +1 -1
- package/dist/inject-storage.decorator.js.map +1 -1
- package/dist/storage-upload-control.d.ts.map +1 -1
- package/dist/storage.client.d.ts.map +1 -1
- package/dist/storage.client.js.map +1 -1
- package/dist/storage.error.d.ts +10 -10
- package/dist/storage.error.d.ts.map +1 -1
- package/dist/storage.error.js.map +1 -1
- package/dist/storage.module.d.ts.map +1 -1
- package/dist/storage.module.js.map +1 -1
- package/dist/storage.service.d.ts.map +1 -1
- package/dist/storage.service.js.map +1 -1
- package/dist/storage.tokens.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +18 -10
|
@@ -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;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,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC;QACxE,eAAe,CAAC,GAAG,KAAK,mCAAmC,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAgC;IAC7D,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;IAC7B,IAAI,K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zC,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"]}
|
|
1
|
+
{"version":3,"file":"storage.client.js","sourceRoot":"","sources":["../src/storage.client.ts"],"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AI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAgC,EAChC,SAAgC;QAEhC,IAAI,CAAC;YACH,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnC,MAAM,MAAM,CAAC,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC;YAC1C,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;YACjC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnC,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACjD,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,EAAE;gBAC9C,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;gBACtD,SAAS,EAAE,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.error.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export declare const StorageErrorCode: {
|
|
2
|
-
readonly NOT_FOUND:
|
|
3
|
-
readonly UNAUTHORIZED:
|
|
4
|
-
readonly CONFLICT:
|
|
5
|
-
readonly READ_ONLY:
|
|
6
|
-
readonly INVALID_ARGUMENT:
|
|
7
|
-
readonly NOT_SUPPORTED:
|
|
8
|
-
readonly ABORTED:
|
|
9
|
-
readonly TIMEOUT:
|
|
10
|
-
readonly LIMIT_EXCEEDED:
|
|
11
|
-
readonly PROVIDER:
|
|
2
|
+
readonly NOT_FOUND: 'NOT_FOUND';
|
|
3
|
+
readonly UNAUTHORIZED: 'UNAUTHORIZED';
|
|
4
|
+
readonly CONFLICT: 'CONFLICT';
|
|
5
|
+
readonly READ_ONLY: 'READ_ONLY';
|
|
6
|
+
readonly INVALID_ARGUMENT: 'INVALID_ARGUMENT';
|
|
7
|
+
readonly NOT_SUPPORTED: 'NOT_SUPPORTED';
|
|
8
|
+
readonly ABORTED: 'ABORTED';
|
|
9
|
+
readonly TIMEOUT: 'TIMEOUT';
|
|
10
|
+
readonly LIMIT_EXCEEDED: 'LIMIT_EXCEEDED';
|
|
11
|
+
readonly PROVIDER: 'PROVIDER';
|
|
12
12
|
};
|
|
13
13
|
export type StorageErrorCode = (typeof StorageErrorCode)[keyof typeof StorageErrorCode];
|
|
14
14
|
declare const STORAGE_ERROR_BRAND: unique symbol;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.error.d.ts","sourceRoot":"","sources":["../src/storage.error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"storage.error.d.ts","sourceRoot":"","sources":["../src/storage.error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;aAC3B,SAAS,EAAE,WAAW;aACtB,YAAY,EAAE,cAAc;aAC5B,QAAQ,EAAE,UAAU;aACpB,SAAS,EAAE,WAAW;aACtB,gBAAgB,EAAE,kBAAkB;aACpC,aAAa,EAAE,eAAe;aAC9B,OAAO,EAAE,SAAS;aAClB,OAAO,EAAE,SAAS;aAClB,cAAc,EAAE,gBAAgB;aAChC,QAAQ,EAAE,UAAU;CACZ,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE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C,SAAS,KAAK,QAAQ,CAAC;YAC1C,CAAC,SAAS,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,CACnE,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAc,EACd,OAAO,GAEH,EAAE;IAEN,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.module.d.ts","sourceRoot":"","sources":["../src/storage.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAInB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAEV,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAsBrC,qBACa,oBAAoB;CAAG;AAmNpC,qBACa,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa;
|
|
1
|
+
{"version":3,"file":"storage.module.d.ts","sourceRoot":"","sources":["../src/storage.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAInB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAEV,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EAErB,MAAM,6BAA6B,CAAC;AAsBrC,qBACa,oBAAoB;CAAG;AAmNpC,qBACa,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAY3D;IAED,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,yBAAyB,GAAG,aAAa,CAarE;IAED,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,CAU/D;IAED,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,0BAA0B,GAAG,aAAa,CAUzE;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.module.js","sourceRoot":"","sources":["../src/storage.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EACL,MAAM,GAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE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AAC,UAAU,CAAC,OAA8B;QAC9C,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC9D,OAAO,iBAAiB,CACtB,oBAAoB,EACpB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,OAAmC;QACxD,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,OAAO,kBAAkB,CACvB,oBAAoB,EACpB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,aAAa;IADzB,MAAM,CAAC,EAAE,CAAC;GACE,aAAa,CAqDzB","sourcesContent":["import {\n Module,\n type DynamicModule,\n type FactoryProvider,\n type ModuleMetadata,\n type Provider,\n} from '@nestjs/common';\n\nimport { StorageClient } from './storage.client.js';\nimport type { StorageDriver } from './storage.driver.js';\nimport type {\n StorageAsyncStoreDefinition,\n StorageFeatureAsyncOptions,\n StorageFeatureOptions,\n StorageModuleAsyncOptions,\n StorageModuleOptions,\n StorageStoreDefinition,\n} from './storage-module.options.js';\nimport { StorageService } from './storage.service.js';\nimport {\n DEFAULT_STORAGE_NAME,\n STORAGE_DEFAULT_NAME,\n getStorageToken,\n normalizeStorageName,\n} from './storage.tokens.js';\nimport type { StoragePlugin } from './storage.types.js';\n\ninterface PreparedStore {\n name: string;\n driver: StorageDriver;\n plugins: readonly StoragePlugin[];\n}\n\ninterface PreparedAsyncStore {\n name: string;\n definition: StorageAsyncStoreDefinition;\n plugins: readonly StoragePlugin[];\n}\n\n@Module({})\nexport class StorageFeatureModule {}\n\nfunction assertStores(names: readonly string[]): void {\n if (names.length === 0) {\n throw new TypeError('At least one storage store must be configured.');\n }\n const duplicates = names.filter(\n (name, index) => names.indexOf(name) !== index,\n );\n if (duplicates.length > 0) {\n throw new TypeError(\n `Duplicate storage store names: ${[...new Set(duplicates)].join(', ')}.`,\n );\n }\n}\n\nfunction resolveDefaultName(\n names: readonly string[],\n requested?: string,\n): string | null {\n if (requested !== undefined) {\n const normalized = normalizeStorageName(requested);\n if (!names.includes(normalized)) {\n throw new TypeError(\n `Default storage store \"${normalized}\" is not present in this registration.`,\n );\n }\n return normalized;\n }\n if (names.length === 1) {\n return names[0] ?? null;\n }\n return names.includes(DEFAULT_STORAGE_NAME) ? DEFAULT_STORAGE_NAME : null;\n}\n\nfunction prepareStores(\n stores: readonly StorageStoreDefinition[],\n plugins: readonly StoragePlugin[] = [],\n): PreparedStore[] {\n const prepared = stores.map((store) => ({\n driver: store.driver,\n name: normalizeStorageName(store.name),\n plugins: [...plugins, ...(store.plugins ?? [])],\n }));\n assertStores(prepared.map((store) => store.name));\n return prepared;\n}\n\nfunction prepareAsyncStores(\n stores: readonly StorageAsyncStoreDefinition[],\n plugins: readonly StoragePlugin[] = [],\n): PreparedAsyncStore[] {\n const prepared = stores.map((definition) => ({\n definition,\n name: normalizeStorageName(definition.name),\n plugins: [...plugins, ...(definition.plugins ?? [])],\n }));\n assertStores(prepared.map((store) => store.name));\n return prepared;\n}\n\nfunction uniqueImports(\n root: ModuleMetadata['imports'] = [],\n stores: readonly PreparedAsyncStore[] = [],\n): NonNullable<ModuleMetadata['imports']> {\n return [\n ...new Set([\n ...root,\n ...stores.flatMap((store) => store.definition.imports ?? []),\n ]),\n ];\n}\n\nfunction serviceProvider(\n defaultName: string | null,\n names: readonly string[],\n): Provider[] {\n const storeTokens = names.map((name) => getStorageToken(name));\n return [\n { provide: STORAGE_DEFAULT_NAME, useValue: defaultName },\n {\n provide: StorageService,\n inject: [STORAGE_DEFAULT_NAME, ...storeTokens],\n useFactory: (\n configuredDefault: string | null,\n ...clients: StorageClient[]\n ): StorageService => {\n return new StorageService(\n new Map(names.map((name, index) => [name, clients[index]!])),\n configuredDefault,\n );\n },\n },\n ];\n}\n\nfunction syncDynamicModule(\n module: typeof StorageModule | typeof StorageFeatureModule,\n stores: readonly PreparedStore[],\n defaultName: string | null,\n global: boolean,\n includeService: boolean,\n imports: ModuleMetadata['imports'] = [],\n): DynamicModule {\n const clientProviders: Provider[] = stores.map((store) => ({\n provide: getStorageToken(store.name),\n useFactory: () =>\n new StorageClient(store.name, store.driver, store.plugins),\n }));\n const storeTokens = stores.map((store) => getStorageToken(store.name));\n const names = stores.map((store) => store.name);\n\n return {\n module,\n global,\n imports: uniqueImports(imports),\n providers: [\n ...clientProviders,\n ...(includeService ? serviceProvider(defaultName, names) : []),\n ],\n exports: [...storeTokens, ...(includeService ? [StorageService] : [])],\n };\n}\n\nfunction asyncClientProvider(store: PreparedAsyncStore): {\n client: FactoryProvider;\n extra?: Provider;\n} {\n const token = getStorageToken(store.name);\n const definition = store.definition;\n\n if (definition.useFactory !== undefined) {\n const factory = definition.useFactory as unknown as (\n ...dependencies: unknown[]\n ) => StorageDriver | Promise<StorageDriver>;\n return {\n client: {\n provide: token,\n inject: definition.inject ?? [],\n useFactory: async (...dependencies: unknown[]) =>\n new StorageClient(\n store.name,\n await factory(...dependencies),\n store.plugins,\n ),\n },\n };\n }\n\n if (definition.useClass !== undefined) {\n return {\n client: {\n provide: token,\n inject: [definition.useClass],\n useFactory: async (factory) =>\n new StorageClient(\n store.name,\n await factory.createStorageDriver(store.name),\n store.plugins,\n ),\n },\n extra: definition.useClass,\n };\n }\n\n return {\n client: {\n provide: token,\n inject: [definition.useExisting],\n useFactory: async (factory) =>\n new StorageClient(\n store.name,\n await factory.createStorageDriver(store.name),\n store.plugins,\n ),\n },\n };\n}\n\nfunction asyncDynamicModule(\n module: typeof StorageModule | typeof StorageFeatureModule,\n stores: readonly PreparedAsyncStore[],\n defaultName: string | null,\n global: boolean,\n includeService: boolean,\n imports: ModuleMetadata['imports'] = [],\n): DynamicModule {\n const clients = stores.map(asyncClientProvider);\n const extras = clients\n .map(({ extra }) => extra)\n .filter((provider): provider is Provider => provider !== undefined);\n const storeTokens = stores.map((store) => getStorageToken(store.name));\n\n return {\n module,\n global,\n imports: uniqueImports(imports, stores),\n providers: [\n ...new Set(extras),\n ...clients.map(({ client }) => client),\n ...(includeService\n ? serviceProvider(\n defaultName,\n stores.map((store) => store.name),\n )\n : []),\n ],\n exports: [...storeTokens, ...(includeService ? [StorageService] : [])],\n };\n}\n\n@Module({})\nexport class StorageModule {\n static forRoot(options: StorageModuleOptions): DynamicModule {\n const stores = prepareStores(options.stores, options.plugins);\n return syncDynamicModule(\n StorageModule,\n stores,\n resolveDefaultName(\n stores.map((store) => store.name),\n options.default,\n ),\n options.isGlobal === true,\n true,\n );\n }\n\n static forRootAsync(options: StorageModuleAsyncOptions): DynamicModule {\n const stores = prepareAsyncStores(options.stores, options.plugins);\n return asyncDynamicModule(\n StorageModule,\n stores,\n resolveDefaultName(\n stores.map((store) => store.name),\n options.default,\n ),\n options.isGlobal === true,\n true,\n options.imports,\n );\n }\n\n static forFeature(options: StorageFeatureOptions): DynamicModule {\n const stores = prepareStores(options.stores, options.plugins);\n return syncDynamicModule(\n StorageFeatureModule,\n stores,\n null,\n false,\n false,\n options.imports,\n );\n }\n\n static forFeatureAsync(options: StorageFeatureAsyncOptions): DynamicModule {\n const stores = prepareAsyncStores(options.stores, options.plugins);\n return asyncDynamicModule(\n StorageFeatureModule,\n stores,\n null,\n false,\n false,\n options.imports,\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.module.js","sourceRoot":"","sources":["../src/storage.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EACL,MAAM,GAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,GACrB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AAC;QAC9D,OAAO,iBAAiB,CACtB,oBAAoB,EACpB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,OAAmC;QACxD,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,OAAO,kBAAkB,CACvB,oBAAoB,EACpB,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,aAAa;IADzB,MAAM,CAAC,EAAE,CAAC;GACE,aAAa,CAqDzB","sourcesContent":["import {\n Module,\n type DynamicModule,\n type FactoryProvider,\n type ModuleMetadata,\n type Provider,\n} from '@nestjs/common';\n\nimport { StorageClient } from './storage.client.js';\nimport type { StorageDriver } from './storage.driver.js';\nimport type {\n StorageAsyncStoreDefinition,\n StorageFeatureAsyncOptions,\n StorageFeatureOptions,\n StorageModuleAsyncOptions,\n StorageModuleOptions,\n StorageStoreDefinition,\n} from './storage-module.options.js';\nimport { StorageService } from './storage.service.js';\nimport {\n DEFAULT_STORAGE_NAME,\n STORAGE_DEFAULT_NAME,\n getStorageToken,\n normalizeStorageName,\n} from './storage.tokens.js';\nimport type { StoragePlugin } from './storage.types.js';\n\ninterface PreparedStore {\n name: string;\n driver: StorageDriver;\n plugins: readonly StoragePlugin[];\n}\n\ninterface PreparedAsyncStore {\n name: string;\n definition: StorageAsyncStoreDefinition;\n plugins: readonly StoragePlugin[];\n}\n\n@Module({})\nexport class StorageFeatureModule {}\n\nfunction assertStores(names: readonly string[]): void {\n if (names.length === 0) {\n throw new TypeError('At least one storage store must be configured.');\n }\n const duplicates = names.filter(\n (name, index) => names.indexOf(name) !== index,\n );\n if (duplicates.length > 0) {\n throw new TypeError(\n `Duplicate storage store names: ${[...new Set(duplicates)].join(', ')}.`,\n );\n }\n}\n\nfunction resolveDefaultName(\n names: readonly string[],\n requested?: string,\n): string | null {\n if (requested !== undefined) {\n const normalized = normalizeStorageName(requested);\n if (!names.includes(normalized)) {\n throw new TypeError(\n `Default storage store \"${normalized}\" is not present in this registration.`,\n );\n }\n return normalized;\n }\n if (names.length === 1) {\n return names[0] ?? null;\n }\n return names.includes(DEFAULT_STORAGE_NAME) ? DEFAULT_STORAGE_NAME : null;\n}\n\nfunction prepareStores(\n stores: readonly StorageStoreDefinition[],\n plugins: readonly StoragePlugin[] = [],\n): PreparedStore[] {\n const prepared = stores.map((store) => ({\n driver: store.driver,\n name: normalizeStorageName(store.name),\n plugins: [...plugins, ...(store.plugins ?? [])],\n }));\n assertStores(prepared.map((store) => store.name));\n return prepared;\n}\n\nfunction prepareAsyncStores(\n stores: readonly StorageAsyncStoreDefinition[],\n plugins: readonly StoragePlugin[] = [],\n): PreparedAsyncStore[] {\n const prepared = stores.map((definition) => ({\n definition,\n name: normalizeStorageName(definition.name),\n plugins: [...plugins, ...(definition.plugins ?? [])],\n }));\n assertStores(prepared.map((store) => store.name));\n return prepared;\n}\n\nfunction uniqueImports(\n root: ModuleMetadata['imports'] = [],\n stores: readonly PreparedAsyncStore[] = [],\n): NonNullable<ModuleMetadata['imports']> {\n return [\n ...new Set([\n ...root,\n ...stores.flatMap((store) => store.definition.imports ?? []),\n ]),\n ];\n}\n\nfunction serviceProvider(\n defaultName: string | null,\n names: readonly string[],\n): Provider[] {\n const storeTokens = names.map((name) => getStorageToken(name));\n return [\n { provide: STORAGE_DEFAULT_NAME, useValue: defaultName },\n {\n provide: StorageService,\n inject: [STORAGE_DEFAULT_NAME, ...storeTokens],\n useFactory: (\n configuredDefault: string | null,\n ...clients: StorageClient[]\n ): StorageService => {\n return new StorageService(\n new Map(names.map((name, index) => [name, clients[index]!])),\n configuredDefault,\n );\n },\n },\n ];\n}\n\nfunction syncDynamicModule(\n module: typeof StorageModule | typeof StorageFeatureModule,\n stores: readonly PreparedStore[],\n defaultName: string | null,\n global: boolean,\n includeService: boolean,\n imports: ModuleMetadata['imports'] = [],\n): DynamicModule {\n const clientProviders: Provider[] = stores.map((store) => ({\n provide: getStorageToken(store.name),\n useFactory: () =>\n new StorageClient(store.name, store.driver, store.plugins),\n }));\n const storeTokens = stores.map((store) => getStorageToken(store.name));\n const names = stores.map((store) => store.name);\n\n return {\n module,\n global,\n imports: uniqueImports(imports),\n providers: [\n ...clientProviders,\n ...(includeService ? serviceProvider(defaultName, names) : []),\n ],\n exports: [...storeTokens, ...(includeService ? [StorageService] : [])],\n };\n}\n\nfunction asyncClientProvider(store: PreparedAsyncStore): {\n client: FactoryProvider;\n extra?: Provider;\n} {\n const token = getStorageToken(store.name);\n const definition = store.definition;\n\n if (definition.useFactory !== undefined) {\n const factory = definition.useFactory as unknown as (\n ...dependencies: unknown[]\n ) => StorageDriver | Promise<StorageDriver>;\n return {\n client: {\n provide: token,\n inject: definition.inject ?? [],\n useFactory: async (...dependencies: unknown[]) =>\n new StorageClient(\n store.name,\n await factory(...dependencies),\n store.plugins,\n ),\n },\n };\n }\n\n if (definition.useClass !== undefined) {\n return {\n client: {\n provide: token,\n inject: [definition.useClass],\n useFactory: async (factory) =>\n new StorageClient(\n store.name,\n await factory.createStorageDriver(store.name),\n store.plugins,\n ),\n },\n extra: definition.useClass,\n };\n }\n\n return {\n client: {\n provide: token,\n inject: [definition.useExisting],\n useFactory: async (factory) =>\n new StorageClient(\n store.name,\n await factory.createStorageDriver(store.name),\n store.plugins,\n ),\n },\n };\n}\n\nfunction asyncDynamicModule(\n module: typeof StorageModule | typeof StorageFeatureModule,\n stores: readonly PreparedAsyncStore[],\n defaultName: string | null,\n global: boolean,\n includeService: boolean,\n imports: ModuleMetadata['imports'] = [],\n): DynamicModule {\n const clients = stores.map(asyncClientProvider);\n const extras = clients\n .map(({ extra }) => extra)\n .filter((provider): provider is Provider => provider !== undefined);\n const storeTokens = stores.map((store) => getStorageToken(store.name));\n\n return {\n module,\n global,\n imports: uniqueImports(imports, stores),\n providers: [\n ...new Set(extras),\n ...clients.map(({ client }) => client),\n ...(includeService\n ? serviceProvider(\n defaultName,\n stores.map((store) => store.name),\n )\n : []),\n ],\n exports: [...storeTokens, ...(includeService ? [StorageService] : [])],\n };\n}\n\n@Module({})\nexport class StorageModule {\n static forRoot(options: StorageModuleOptions): DynamicModule {\n const stores = prepareStores(options.stores, options.plugins);\n return syncDynamicModule(\n StorageModule,\n stores,\n resolveDefaultName(\n stores.map((store) => store.name),\n options.default,\n ),\n options.isGlobal === true,\n true,\n );\n }\n\n static forRootAsync(options: StorageModuleAsyncOptions): DynamicModule {\n const stores = prepareAsyncStores(options.stores, options.plugins);\n return asyncDynamicModule(\n StorageModule,\n stores,\n resolveDefaultName(\n stores.map((store) => store.name),\n options.default,\n ),\n options.isGlobal === true,\n true,\n options.imports,\n );\n }\n\n static forFeature(options: StorageFeatureOptions): DynamicModule {\n const stores = prepareStores(options.stores, options.plugins);\n return syncDynamicModule(\n StorageFeatureModule,\n stores,\n null,\n false,\n false,\n options.imports,\n );\n }\n\n static forFeatureAsync(options: StorageFeatureAsyncOptions): DynamicModule {\n const stores = prepareAsyncStores(options.stores, options.plugins);\n return asyncDynamicModule(\n StorageFeatureModule,\n stores,\n null,\n false,\n false,\n options.imports,\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.service.d.ts","sourceRoot":"","sources":["../src/storage.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAIV,kBAAkB,EAElB,iBAAiB,EACjB,sBAAsB,EAEtB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAuD5B,qBAAa,cAAc;;IAKvB,OAAO,CAAC,QAAQ,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"storage.service.d.ts","sourceRoot":"","sources":["../src/storage.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,a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OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE;gBAC5D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI;oBACvC,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC;gBACF,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC/D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI;oBACvC,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC;aACH,CAAC,CAAC;YACH,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;YAC/B,YAAY,GAAG,YAAY,CAAC,MAAM,IAAI,EAAE,CAAC;YACzC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC;QACpD,OAAO;YACL,QAAQ;YACR,OAAO,EAAE,WAAW;YACpB,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YAChD,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;SACrC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { settleMany } from './internal/settle-many.js';\nimport { StorageClient } from './storage.client.js';\nimport { StorageError, StorageErrorCode } from './storage.error.js';\nimport { normalizeStorageName } from './storage.tokens.js';\nimport type {\n StorageBulkError,\n StorageObjectMetadata,\n StorageSyncCompare,\n StorageSyncOptions,\n StorageSyncProgress,\n StorageSyncResult,\n StorageTransferOptions,\n StorageTransferProgress,\n StorageTransferResult,\n} from './storage.types.js';\n\nconst identity = (key: string): string => key;\n\nfunction assertDifferentStores(from: string, to: string): void {\n if (from === to) {\n throw new StorageError(\n 'Cross-store transfer and sync require different source and destination stores.',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n store: from,\n },\n );\n }\n}\n\nfunction unchanged(\n source: StorageObjectMetadata,\n destination: StorageObjectMetadata,\n compare: StorageSyncCompare,\n): boolean {\n if (typeof compare === 'function') {\n return compare(source, destination);\n }\n if (compare === 'size') {\n return source.size === destination.size;\n }\n return (\n source.size === destination.size &&\n source.etag !== undefined &&\n destination.etag !== undefined &&\n source.etag === destination.etag\n );\n}\n\nasync function walk(\n client: StorageClient,\n options: {\n prefix?: string;\n limit?: number;\n signal?: AbortSignal;\n },\n): Promise<StorageObjectMetadata[]> {\n const objects: StorageObjectMetadata[] = [];\n for await (const object of client.listAll({\n ...(options.limit !== undefined && { limit: options.limit }),\n ...(options.prefix !== undefined && { prefix: options.prefix }),\n ...(options.signal !== undefined && { signal: options.signal }),\n })) {\n objects.push(object);\n }\n return objects;\n}\n\nexport class StorageService {\n readonly #clients: ReadonlyMap<string, StorageClient>;\n\n constructor(\n clients: ReadonlyMap<string, StorageClient>,\n private readonly defaultName: string | null,\n ) {\n this.#clients = new Map(clients);\n }\n\n get names(): readonly string[] {\n return [...this.#clients.keys()].sort();\n }\n\n use(name?: string): StorageClient {\n const resolved =\n name === undefined ? this.defaultName : normalizeStorageName(name);\n\n if (resolved === null) {\n throw new StorageError(\n 'No default storage store is configured; call storage.use(name).',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n },\n );\n }\n\n const client = this.#clients.get(resolved);\n if (client === undefined) {\n const available = this.names;\n throw new StorageError(\n available.length === 0\n ? `Storage store \"${resolved}\" is not registered.`\n : `Storage store \"${resolved}\" is not registered. Available stores: ${available.join(', ')}.`,\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n store: resolved,\n },\n );\n }\n return client;\n }\n\n async transfer(\n options: StorageTransferOptions,\n ): Promise<StorageTransferResult> {\n const fromName = normalizeStorageName(options.from);\n const toName = normalizeStorageName(options.to);\n assertDifferentStores(fromName, toName);\n const source = this.use(fromName);\n const destination = this.use(toName);\n const transformKey = options.transformKey ?? identity;\n const overwrite = options.overwrite ?? true;\n const objects = await walk(source, options);\n const total = objects.length;\n let done = 0;\n const skipped = new Set<string>();\n\n const report = (\n key: string,\n status: StorageTransferProgress['status'],\n ): void => {\n done += 1;\n options.onProgress?.({ done, key, status, total });\n };\n\n const settled = await settleMany(\n objects,\n (object) => object.key,\n async (object) => {\n const destinationKey = transformKey(object.key);\n if (\n !overwrite &&\n (await destination.exists(destinationKey, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n }))\n ) {\n skipped.add(object.key);\n report(object.key, 'skipped');\n return object.key;\n }\n\n const downloaded = await source.downloadStream(object.key, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n try {\n await destination.upload(destinationKey, downloaded.body, {\n contentType: downloaded.contentType,\n ...(downloaded.metadata !== undefined && {\n metadata: downloaded.metadata,\n }),\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n } catch (error) {\n if (!downloaded.body.locked) {\n await downloaded.body.cancel().catch(() => undefined);\n }\n throw error;\n }\n report(object.key, 'transferred');\n return object.key;\n },\n options,\n );\n\n const transferred: string[] = [];\n const skippedKeys: string[] = [];\n for (const key of settled.results) {\n (skipped.has(key) ? skippedKeys : transferred).push(key);\n }\n\n return {\n transferred,\n ...(skippedKeys.length > 0 && { skipped: skippedKeys }),\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async sync(options: StorageSyncOptions): Promise<StorageSyncResult> {\n const fromName = normalizeStorageName(options.from);\n const toName = normalizeStorageName(options.to);\n assertDifferentStores(fromName, toName);\n const source = this.use(fromName);\n const destination = this.use(toName);\n const transformKey = options.transformKey ?? identity;\n const compare = options.compare ?? 'etag';\n const sourceObjects = await walk(source, options);\n const destinationObjects = await walk(destination, {\n ...(options.destinationPrefix !== undefined\n ? { prefix: options.destinationPrefix }\n : options.prefix !== undefined\n ? { prefix: options.prefix }\n : {}),\n ...(options.limit !== undefined && { limit: options.limit }),\n ...(options.signal !== undefined && { signal: options.signal }),\n });\n const destinationIndex = new Map(\n destinationObjects.map((object) => [object.key, object]),\n );\n const desiredDestinationKeys = new Set(\n sourceObjects.map((object) => transformKey(object.key)),\n );\n const deleteKeys =\n (options.prune ?? false)\n ? destinationObjects\n .map((object) => object.key)\n .filter((key) => !desiredDestinationKeys.has(key))\n : [];\n\n const plannedUploads: string[] = [];\n const plannedSkips: string[] = [];\n for (const object of sourceObjects) {\n const existing = destinationIndex.get(transformKey(object.key));\n (existing && unchanged(object, existing, compare)\n ? plannedSkips\n : plannedUploads\n ).push(object.key);\n }\n\n if (options.dryRun) {\n return {\n uploaded: plannedUploads,\n skipped: plannedSkips,\n ...(options.prune && { deleted: deleteKeys }),\n };\n }\n\n const total =\n sourceObjects.length + (options.prune ? deleteKeys.length : 0);\n let done = 0;\n const report = (\n key: string,\n status: StorageSyncProgress['status'],\n ): void => {\n done += 1;\n options.onProgress?.({ done, key, status, total });\n };\n const skipped = new Set<string>();\n\n const settled = await settleMany(\n sourceObjects,\n (object) => object.key,\n async (object) => {\n const destinationKey = transformKey(object.key);\n const existing = destinationIndex.get(destinationKey);\n if (existing && unchanged(object, existing, compare)) {\n skipped.add(object.key);\n report(object.key, 'skipped');\n return object.key;\n }\n const downloaded = await source.downloadStream(object.key, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n try {\n await destination.upload(destinationKey, downloaded.body, {\n contentType: downloaded.contentType,\n ...(downloaded.metadata !== undefined && {\n metadata: downloaded.metadata,\n }),\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n } catch (error) {\n if (!downloaded.body.locked) {\n await downloaded.body.cancel().catch(() => undefined);\n }\n throw error;\n }\n report(object.key, 'uploaded');\n return object.key;\n },\n options,\n );\n\n const uploaded: string[] = [];\n const skippedKeys: string[] = [];\n for (const key of settled.results) {\n (skipped.has(key) ? skippedKeys : uploaded).push(key);\n }\n\n let deleted: string[] | undefined;\n let deleteErrors: StorageBulkError[] = [];\n const canPrune =\n options.prune && !(options.stopOnError && settled.errors.length > 0);\n if (canPrune) {\n const deleteResult = await destination.deleteMany(deleteKeys, {\n ...(options.concurrency !== undefined && {\n concurrency: options.concurrency,\n }),\n ...(options.signal !== undefined && { signal: options.signal }),\n ...(options.stopOnError !== undefined && {\n stopOnError: options.stopOnError,\n }),\n });\n deleted = deleteResult.deleted;\n deleteErrors = deleteResult.errors ?? [];\n for (const key of deleted) {\n report(key, 'deleted');\n }\n }\n\n const errors = [...settled.errors, ...deleteErrors];\n return {\n uploaded,\n skipped: skippedKeys,\n ...(options.prune && { deleted: deleted ?? [] }),\n ...(errors.length > 0 && { errors }),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage.service.js","sourceRoot":"","sources":["../src/storage.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAa3D,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC;AAE9C,SAAS,qBAAqB,CAAC,IAAY,EAAE,EAAU;IACrD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,YAAY,CACpB,gFAAgF,EAChF;YACE,IAAI,EAAE,gBAAgB,CAAC,gBAAgB;YACvC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI;SACZ,CACF,CAAC;IACJ,CAAC;AACH,CAA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OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvE,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE;gBAC5D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI;oBACvC,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC;gBACF,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC/D,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI;oBACvC,WAAW,EAAE,OAAO,CAAC,WAAW;iBACjC,CAAC;aACH,CAAC,CAAC;YACH,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;YAC/B,YAAY,GAAG,YAAY,CAAC,MAAM,IAAI,EAAE,CAAC;YACzC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC;QACpD,OAAO;YACL,QAAQ;YACR,OAAO,EAAE,WAAW;YACpB,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;YAChD,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;SACrC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { settleMany } from './internal/settle-many.js';\nimport { StorageClient } from './storage.client.js';\nimport { StorageError, StorageErrorCode } from './storage.error.js';\nimport { normalizeStorageName } from './storage.tokens.js';\nimport type {\n StorageBulkError,\n StorageObjectMetadata,\n StorageSyncCompare,\n StorageSyncOptions,\n StorageSyncProgress,\n StorageSyncResult,\n StorageTransferOptions,\n StorageTransferProgress,\n StorageTransferResult,\n} from './storage.types.js';\n\nconst identity = (key: string): string => key;\n\nfunction assertDifferentStores(from: string, to: string): void {\n if (from === to) {\n throw new StorageError(\n 'Cross-store transfer and sync require different source and destination stores.',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n store: from,\n },\n );\n }\n}\n\nfunction unchanged(\n source: StorageObjectMetadata,\n destination: StorageObjectMetadata,\n compare: StorageSyncCompare,\n): boolean {\n if (typeof compare === 'function') {\n return compare(source, destination);\n }\n if (compare === 'size') {\n return source.size === destination.size;\n }\n return (\n source.size === destination.size &&\n source.etag !== undefined &&\n destination.etag !== undefined &&\n source.etag === destination.etag\n );\n}\n\nasync function walk(\n client: StorageClient,\n options: {\n prefix?: string;\n limit?: number;\n signal?: AbortSignal;\n },\n): Promise<StorageObjectMetadata[]> {\n const objects: StorageObjectMetadata[] = [];\n for await (const object of client.listAll({\n ...(options.limit !== undefined && { limit: options.limit }),\n ...(options.prefix !== undefined && { prefix: options.prefix }),\n ...(options.signal !== undefined && { signal: options.signal }),\n })) {\n objects.push(object);\n }\n return objects;\n}\n\nexport class StorageService {\n readonly #clients: ReadonlyMap<string, StorageClient>;\n\n constructor(\n clients: ReadonlyMap<string, StorageClient>,\n private readonly defaultName: string | null,\n ) {\n this.#clients = new Map(clients);\n }\n\n get names(): readonly string[] {\n return [...this.#clients.keys()].sort();\n }\n\n use(name?: string): StorageClient {\n const resolved =\n name === undefined ? this.defaultName : normalizeStorageName(name);\n\n if (resolved === null) {\n throw new StorageError(\n 'No default storage store is configured; call storage.use(name).',\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n },\n );\n }\n\n const client = this.#clients.get(resolved);\n if (client === undefined) {\n const available = this.names;\n throw new StorageError(\n available.length === 0\n ? `Storage store \"${resolved}\" is not registered.`\n : `Storage store \"${resolved}\" is not registered. Available stores: ${available.join(', ')}.`,\n {\n code: StorageErrorCode.INVALID_ARGUMENT,\n permanent: true,\n store: resolved,\n },\n );\n }\n return client;\n }\n\n async transfer(\n options: StorageTransferOptions,\n ): Promise<StorageTransferResult> {\n const fromName = normalizeStorageName(options.from);\n const toName = normalizeStorageName(options.to);\n assertDifferentStores(fromName, toName);\n const source = this.use(fromName);\n const destination = this.use(toName);\n const transformKey = options.transformKey ?? identity;\n const overwrite = options.overwrite ?? true;\n const objects = await walk(source, options);\n const total = objects.length;\n let done = 0;\n const skipped = new Set<string>();\n\n const report = (\n key: string,\n status: StorageTransferProgress['status'],\n ): void => {\n done += 1;\n options.onProgress?.({ done, key, status, total });\n };\n\n const settled = await settleMany(\n objects,\n (object) => object.key,\n async (object) => {\n const destinationKey = transformKey(object.key);\n if (\n !overwrite &&\n (await destination.exists(destinationKey, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n }))\n ) {\n skipped.add(object.key);\n report(object.key, 'skipped');\n return object.key;\n }\n\n const downloaded = await source.downloadStream(object.key, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n try {\n await destination.upload(destinationKey, downloaded.body, {\n contentType: downloaded.contentType,\n ...(downloaded.metadata !== undefined && {\n metadata: downloaded.metadata,\n }),\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n } catch (error) {\n if (!downloaded.body.locked) {\n await downloaded.body.cancel().catch(() => undefined);\n }\n throw error;\n }\n report(object.key, 'transferred');\n return object.key;\n },\n options,\n );\n\n const transferred: string[] = [];\n const skippedKeys: string[] = [];\n for (const key of settled.results) {\n (skipped.has(key) ? skippedKeys : transferred).push(key);\n }\n\n return {\n transferred,\n ...(skippedKeys.length > 0 && { skipped: skippedKeys }),\n ...(settled.errors.length > 0 && { errors: settled.errors }),\n };\n }\n\n async sync(options: StorageSyncOptions): Promise<StorageSyncResult> {\n const fromName = normalizeStorageName(options.from);\n const toName = normalizeStorageName(options.to);\n assertDifferentStores(fromName, toName);\n const source = this.use(fromName);\n const destination = this.use(toName);\n const transformKey = options.transformKey ?? identity;\n const compare = options.compare ?? 'etag';\n const sourceObjects = await walk(source, options);\n const destinationObjects = await walk(destination, {\n ...(options.destinationPrefix !== undefined\n ? { prefix: options.destinationPrefix }\n : options.prefix !== undefined\n ? { prefix: options.prefix }\n : {}),\n ...(options.limit !== undefined && { limit: options.limit }),\n ...(options.signal !== undefined && { signal: options.signal }),\n });\n const destinationIndex = new Map(\n destinationObjects.map((object) => [object.key, object]),\n );\n const desiredDestinationKeys = new Set(\n sourceObjects.map((object) => transformKey(object.key)),\n );\n const deleteKeys =\n (options.prune ?? false)\n ? destinationObjects\n .map((object) => object.key)\n .filter((key) => !desiredDestinationKeys.has(key))\n : [];\n\n const plannedUploads: string[] = [];\n const plannedSkips: string[] = [];\n for (const object of sourceObjects) {\n const existing = destinationIndex.get(transformKey(object.key));\n (existing && unchanged(object, existing, compare)\n ? plannedSkips\n : plannedUploads\n ).push(object.key);\n }\n\n if (options.dryRun) {\n return {\n uploaded: plannedUploads,\n skipped: plannedSkips,\n ...(options.prune && { deleted: deleteKeys }),\n };\n }\n\n const total =\n sourceObjects.length + (options.prune ? deleteKeys.length : 0);\n let done = 0;\n const report = (\n key: string,\n status: StorageSyncProgress['status'],\n ): void => {\n done += 1;\n options.onProgress?.({ done, key, status, total });\n };\n const skipped = new Set<string>();\n\n const settled = await settleMany(\n sourceObjects,\n (object) => object.key,\n async (object) => {\n const destinationKey = transformKey(object.key);\n const existing = destinationIndex.get(destinationKey);\n if (existing && unchanged(object, existing, compare)) {\n skipped.add(object.key);\n report(object.key, 'skipped');\n return object.key;\n }\n const downloaded = await source.downloadStream(object.key, {\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n try {\n await destination.upload(destinationKey, downloaded.body, {\n contentType: downloaded.contentType,\n ...(downloaded.metadata !== undefined && {\n metadata: downloaded.metadata,\n }),\n ...(options.signal !== undefined && {\n signal: options.signal,\n }),\n });\n } catch (error) {\n if (!downloaded.body.locked) {\n await downloaded.body.cancel().catch(() => undefined);\n }\n throw error;\n }\n report(object.key, 'uploaded');\n return object.key;\n },\n options,\n );\n\n const uploaded: string[] = [];\n const skippedKeys: string[] = [];\n for (const key of settled.results) {\n (skipped.has(key) ? skippedKeys : uploaded).push(key);\n }\n\n let deleted: string[] | undefined;\n let deleteErrors: StorageBulkError[] = [];\n const canPrune =\n options.prune && !(options.stopOnError && settled.errors.length > 0);\n if (canPrune) {\n const deleteResult = await destination.deleteMany(deleteKeys, {\n ...(options.concurrency !== undefined && {\n concurrency: options.concurrency,\n }),\n ...(options.signal !== undefined && { signal: options.signal }),\n ...(options.stopOnError !== undefined && {\n stopOnError: options.stopOnError,\n }),\n });\n deleted = deleteResult.deleted;\n deleteErrors = deleteResult.errors ?? [];\n for (const key of deleted) {\n report(key, 'deleted');\n }\n }\n\n const errors = [...settled.errors, ...deleteErrors];\n return {\n uploaded,\n skipped: skippedKeys,\n ...(options.prune && { deleted: deleted ?? [] }),\n ...(errors.length > 0 && { errors }),\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.tokens.js","sourceRoot":"","sources":["../src/storage.tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,
|
|
1
|
+
{"version":3,"file":"storage.tokens.js","sourceRoot":"","sources":["../src/storage.tokens.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC;AAE9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE9E,MAAM,UAAU,oBAAoB,CAClC,IAAI,GAAW,oBAAoB;IAEnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;QAC1E,MAAM,IAAI,SAAS,CACjB,uFAAuF,CACxF,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAI,GAAW,oBAAoB;IACjE,OAAO,MAAM,CAAC,GAAG,CAAC,wBAAwB,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC","sourcesContent":["export const DEFAULT_STORAGE_NAME = 'default';\n\nexport const STORAGE_DEFAULT_NAME = Symbol.for('@nestm/storage/default-name');\n\nexport function normalizeStorageName(\n name: string = DEFAULT_STORAGE_NAME,\n): string {\n if (typeof name !== 'string' || name.length === 0 || name.trim() !== name) {\n throw new TypeError(\n 'Storage store names must be non-empty strings without leading or trailing whitespace.',\n );\n }\n return name;\n}\n\nexport function getStorageToken(name: string = DEFAULT_STORAGE_NAME): symbol {\n return Symbol.for(`@nestm/storage/store/${normalizeStorageName(name)}`);\n}\n\nexport const STORAGE = getStorageToken();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,GAErB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,MAAM,GAGP,MAAM,kBAAkB,CAAC;AAS1B,MAAM,UAAU,yBAAyB,CACvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,GAErB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,MAAM,GAGP,MAAM,kBAAkB,CAAC;AAS1B,MAAM,UAAU,yBAAyB,CACvC,OAAO,GAA+B,EAAE;IAExC,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;IAC7C,OAAO,oBAAoB,CAAC;QAC1B,GAAG,YAAY;QACf,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;KACzB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { StorageDriver } from '../storage.driver.js';\nimport {\n createFilesSdkDriver,\n type FilesSdkDriverOptions,\n} from '../files-sdk/files-sdk.driver.js';\nimport {\n memory,\n type MemoryAdapter,\n type MemoryAdapterOptions,\n} from 'files-sdk/memory';\n\nexport interface MemoryStorageDriverOptions extends Omit<\n FilesSdkDriverOptions<MemoryAdapter>,\n 'adapter'\n> {\n adapter?: MemoryAdapterOptions;\n}\n\nexport function createMemoryStorageDriver(\n options: MemoryStorageDriverOptions = {},\n): StorageDriver {\n const { adapter, ...filesOptions } = options;\n return createFilesSdkDriver({\n ...filesOptions,\n adapter: memory(adapter),\n });\n}\n\nexport type { MemoryAdapterOptions, MemorySeed } from 'files-sdk/memory';\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.4",
|
|
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,14 @@
|
|
|
27
27
|
"types": "./dist/files-sdk/index.d.ts",
|
|
28
28
|
"import": "./dist/files-sdk/index.js"
|
|
29
29
|
},
|
|
30
|
+
"./files-sdk/fs": {
|
|
31
|
+
"types": "./dist/files-sdk/fs/index.d.ts",
|
|
32
|
+
"import": "./dist/files-sdk/fs/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./files-sdk/provider": {
|
|
35
|
+
"types": "./dist/files-sdk/provider/index.d.ts",
|
|
36
|
+
"import": "./dist/files-sdk/provider/index.js"
|
|
37
|
+
},
|
|
30
38
|
"./files-sdk/s3": {
|
|
31
39
|
"types": "./dist/files-sdk/s3/index.d.ts",
|
|
32
40
|
"import": "./dist/files-sdk/s3/index.js"
|
|
@@ -70,7 +78,7 @@
|
|
|
70
78
|
"nestm"
|
|
71
79
|
],
|
|
72
80
|
"dependencies": {
|
|
73
|
-
"files-sdk": "2.2.
|
|
81
|
+
"files-sdk": "2.2.3"
|
|
74
82
|
},
|
|
75
83
|
"peerDependencies": {
|
|
76
84
|
"@aws-sdk/client-s3": "^3.700.0",
|
|
@@ -109,10 +117,10 @@
|
|
|
109
117
|
}
|
|
110
118
|
},
|
|
111
119
|
"devDependencies": {
|
|
112
|
-
"@aws-sdk/client-s3": "3.
|
|
113
|
-
"@aws-sdk/lib-storage": "3.
|
|
114
|
-
"@aws-sdk/s3-presigned-post": "3.
|
|
115
|
-
"@aws-sdk/s3-request-presigner": "3.
|
|
120
|
+
"@aws-sdk/client-s3": "3.1103.0",
|
|
121
|
+
"@aws-sdk/lib-storage": "3.1103.0",
|
|
122
|
+
"@aws-sdk/s3-presigned-post": "3.1103.0",
|
|
123
|
+
"@aws-sdk/s3-request-presigner": "3.1103.0",
|
|
116
124
|
"@changesets/cli": "2.31.1",
|
|
117
125
|
"@nestjs/common": "12.0.0-alpha.5",
|
|
118
126
|
"@nestjs/core": "12.0.0-alpha.5",
|
|
@@ -122,14 +130,14 @@
|
|
|
122
130
|
"@types/node": "26.1.2",
|
|
123
131
|
"@types/supertest": "7.2.1",
|
|
124
132
|
"@vitest/coverage-v8": "4.1.10",
|
|
125
|
-
"fastify": "5.
|
|
126
|
-
"oxlint": "1.
|
|
133
|
+
"fastify": "5.11.2",
|
|
134
|
+
"oxlint": "1.77.0",
|
|
127
135
|
"prettier": "3.9.6",
|
|
128
|
-
"publint": "0.3.
|
|
136
|
+
"publint": "0.3.23",
|
|
129
137
|
"reflect-metadata": "0.2.2",
|
|
130
138
|
"rxjs": "7.8.2",
|
|
131
139
|
"supertest": "7.2.2",
|
|
132
|
-
"typescript": "
|
|
140
|
+
"typescript": "7.0.2",
|
|
133
141
|
"vitest": "4.1.10"
|
|
134
142
|
},
|
|
135
143
|
"scripts": {
|