@nestm/storage 0.1.0-alpha.3 → 0.1.0-alpha.5

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +200 -3
  3. package/dist/artifacts/artifact-storage.d.ts +161 -0
  4. package/dist/artifacts/artifact-storage.d.ts.map +1 -0
  5. package/dist/artifacts/artifact-storage.js +452 -0
  6. package/dist/artifacts/artifact-storage.js.map +1 -0
  7. package/dist/artifacts/crypto/codec.d.ts +44 -0
  8. package/dist/artifacts/crypto/codec.d.ts.map +1 -0
  9. package/dist/artifacts/crypto/codec.js +273 -0
  10. package/dist/artifacts/crypto/codec.js.map +1 -0
  11. package/dist/artifacts/crypto/context.d.ts +48 -0
  12. package/dist/artifacts/crypto/context.d.ts.map +1 -0
  13. package/dist/artifacts/crypto/context.js +37 -0
  14. package/dist/artifacts/crypto/context.js.map +1 -0
  15. package/dist/artifacts/crypto/dek-cache.d.ts +38 -0
  16. package/dist/artifacts/crypto/dek-cache.d.ts.map +1 -0
  17. package/dist/artifacts/crypto/dek-cache.js +137 -0
  18. package/dist/artifacts/crypto/dek-cache.js.map +1 -0
  19. package/dist/artifacts/crypto/index.d.ts +25 -0
  20. package/dist/artifacts/crypto/index.d.ts.map +1 -0
  21. package/dist/artifacts/crypto/index.js +29 -0
  22. package/dist/artifacts/crypto/index.js.map +1 -0
  23. package/dist/artifacts/crypto/key-provider.d.ts +44 -0
  24. package/dist/artifacts/crypto/key-provider.d.ts.map +1 -0
  25. package/dist/artifacts/crypto/key-provider.js +36 -0
  26. package/dist/artifacts/crypto/key-provider.js.map +1 -0
  27. package/dist/artifacts/crypto/kms-provider.d.ts +16 -0
  28. package/dist/artifacts/crypto/kms-provider.d.ts.map +1 -0
  29. package/dist/artifacts/crypto/kms-provider.js +90 -0
  30. package/dist/artifacts/crypto/kms-provider.js.map +1 -0
  31. package/dist/artifacts/crypto/local-provider.d.ts +17 -0
  32. package/dist/artifacts/crypto/local-provider.d.ts.map +1 -0
  33. package/dist/artifacts/crypto/local-provider.js +58 -0
  34. package/dist/artifacts/crypto/local-provider.js.map +1 -0
  35. package/dist/artifacts/env-config.d.ts +15 -0
  36. package/dist/artifacts/env-config.d.ts.map +1 -0
  37. package/dist/artifacts/env-config.js +95 -0
  38. package/dist/artifacts/env-config.js.map +1 -0
  39. package/dist/artifacts/index.d.ts +6 -0
  40. package/dist/artifacts/index.d.ts.map +1 -0
  41. package/dist/artifacts/index.js +6 -0
  42. package/dist/artifacts/index.js.map +1 -0
  43. package/dist/artifacts/nest/index.d.ts +29 -0
  44. package/dist/artifacts/nest/index.d.ts.map +1 -0
  45. package/dist/artifacts/nest/index.js +129 -0
  46. package/dist/artifacts/nest/index.js.map +1 -0
  47. package/dist/artifacts/object-store.d.ts +27 -0
  48. package/dist/artifacts/object-store.d.ts.map +1 -0
  49. package/dist/artifacts/object-store.js +198 -0
  50. package/dist/artifacts/object-store.js.map +1 -0
  51. package/dist/artifacts/storage-driver.d.ts +48 -0
  52. package/dist/artifacts/storage-driver.d.ts.map +1 -0
  53. package/dist/artifacts/storage-driver.js +89 -0
  54. package/dist/artifacts/storage-driver.js.map +1 -0
  55. package/dist/files-sdk/files-sdk.driver.d.ts +18 -18
  56. package/dist/files-sdk/files-sdk.driver.d.ts.map +1 -1
  57. package/dist/files-sdk/fs/index.d.ts +21 -0
  58. package/dist/files-sdk/fs/index.d.ts.map +1 -0
  59. package/dist/files-sdk/fs/index.js +20 -0
  60. package/dist/files-sdk/fs/index.js.map +1 -0
  61. package/dist/files-sdk/provider/index.d.ts +54 -0
  62. package/dist/files-sdk/provider/index.d.ts.map +1 -0
  63. package/dist/files-sdk/provider/index.js +80 -0
  64. package/dist/files-sdk/provider/index.js.map +1 -0
  65. package/dist/files-sdk/s3/index.d.ts +13 -2
  66. package/dist/files-sdk/s3/index.d.ts.map +1 -1
  67. package/dist/files-sdk/s3/index.js +19 -8
  68. package/dist/files-sdk/s3/index.js.map +1 -1
  69. package/dist/gateway/storage-gateway-fastify-parser.d.ts.map +1 -1
  70. package/dist/gateway/storage-gateway-fastify-parser.js.map +1 -1
  71. package/dist/gateway/storage-gateway.controller.d.ts.map +1 -1
  72. package/dist/gateway/storage-gateway.controller.js.map +1 -1
  73. package/dist/gateway/storage-gateway.guard.d.ts.map +1 -1
  74. package/dist/gateway/storage-gateway.guard.js.map +1 -1
  75. package/dist/gateway/storage-gateway.module.d.ts.map +1 -1
  76. package/dist/gateway/storage-gateway.module.js.map +1 -1
  77. package/dist/gateway/storage-gateway.types.d.ts +10 -10
  78. package/dist/gateway/storage-gateway.types.d.ts.map +1 -1
  79. package/dist/inject-storage.decorator.js.map +1 -1
  80. package/dist/storage-upload-control.d.ts.map +1 -1
  81. package/dist/storage.client.d.ts.map +1 -1
  82. package/dist/storage.client.js.map +1 -1
  83. package/dist/storage.error.d.ts +10 -10
  84. package/dist/storage.error.d.ts.map +1 -1
  85. package/dist/storage.error.js.map +1 -1
  86. package/dist/storage.module.d.ts.map +1 -1
  87. package/dist/storage.module.js.map +1 -1
  88. package/dist/storage.service.d.ts.map +1 -1
  89. package/dist/storage.service.js.map +1 -1
  90. package/dist/storage.tokens.js.map +1 -1
  91. package/dist/testing/index.js.map +1 -1
  92. package/package.json +34 -10
@@ -0,0 +1,21 @@
1
+ import { type FsAdapter, type FsAdapterOptions } from 'files-sdk/fs';
2
+ import { type FilesSdkDriverOptions, type FilesSdkStorageDriver } from '../files-sdk.driver.js';
3
+ export interface FsStorageDriverOptions extends Omit<FilesSdkDriverOptions<FsAdapter>, 'adapter'> {
4
+ adapter: FsAdapterOptions;
5
+ }
6
+ /**
7
+ * Creates the files-sdk filesystem driver from the storage package's own
8
+ * dependency context. The adapter reaches only `node:fs`, so this entry point
9
+ * adds no native SDK to the install — unlike every object-store provider, it is
10
+ * always available.
11
+ *
12
+ * The adapter keeps a `<key>.meta.json` sidecar beside each body to carry the
13
+ * content type, ETag, and custom metadata that a filesystem has nowhere else to
14
+ * put. Sidecars never surface as keys: `list` and `search` skip them, and
15
+ * uploading a key that ends in `.meta.json` fails closed rather than colliding
16
+ * with one.
17
+ */
18
+ export declare function createFsStorageDriver(options: FsStorageDriverOptions): FilesSdkStorageDriver<FsAdapter>;
19
+ export { fs, mapFsError } from 'files-sdk/fs';
20
+ export type { FsAdapter, FsAdapterOptions } from 'files-sdk/fs';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files-sdk/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,qBAAqB,CAAC,SAAS,CAAC,EAChC,SAAS,CACV;IACC,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAAC,SAAS,CAAC,CAGlC;AAED,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { fs } from 'files-sdk/fs';
2
+ import { createFilesSdkDriver, } from '../files-sdk.driver.js';
3
+ /**
4
+ * Creates the files-sdk filesystem driver from the storage package's own
5
+ * dependency context. The adapter reaches only `node:fs`, so this entry point
6
+ * adds no native SDK to the install — unlike every object-store provider, it is
7
+ * always available.
8
+ *
9
+ * The adapter keeps a `<key>.meta.json` sidecar beside each body to carry the
10
+ * content type, ETag, and custom metadata that a filesystem has nowhere else to
11
+ * put. Sidecars never surface as keys: `list` and `search` skip them, and
12
+ * uploading a key that ends in `.meta.json` fails closed rather than colliding
13
+ * with one.
14
+ */
15
+ export function createFsStorageDriver(options) {
16
+ const { adapter: adapterOptions, ...filesOptions } = options;
17
+ return createFilesSdkDriver({ ...filesOptions, adapter: fs(adapterOptions) });
18
+ }
19
+ export { fs, mapFsError } from 'files-sdk/fs';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/files-sdk/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAyC,MAAM,cAAc,CAAC;AAEzE,OAAO,EACL,oBAAoB,GAGrB,MAAM,wBAAwB,CAAC;AAShC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA+B;IAE/B,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;IAC7D,OAAO,oBAAoB,CAAC,EAAE,GAAG,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { fs, type FsAdapter, type FsAdapterOptions } from 'files-sdk/fs';\n\nimport {\n createFilesSdkDriver,\n type FilesSdkDriverOptions,\n type FilesSdkStorageDriver,\n} from '../files-sdk.driver.js';\n\nexport interface FsStorageDriverOptions extends Omit<\n FilesSdkDriverOptions<FsAdapter>,\n 'adapter'\n> {\n adapter: FsAdapterOptions;\n}\n\n/**\n * Creates the files-sdk filesystem driver from the storage package's own\n * dependency context. The adapter reaches only `node:fs`, so this entry point\n * adds no native SDK to the install — unlike every object-store provider, it is\n * always available.\n *\n * The adapter keeps a `<key>.meta.json` sidecar beside each body to carry the\n * content type, ETag, and custom metadata that a filesystem has nowhere else to\n * put. Sidecars never surface as keys: `list` and `search` skip them, and\n * uploading a key that ends in `.meta.json` fails closed rather than colliding\n * with one.\n */\nexport function createFsStorageDriver(\n options: FsStorageDriverOptions,\n): FilesSdkStorageDriver<FsAdapter> {\n const { adapter: adapterOptions, ...filesOptions } = options;\n return createFilesSdkDriver({ ...filesOptions, adapter: fs(adapterOptions) });\n}\n\nexport { fs, mapFsError } from 'files-sdk/fs';\nexport type { FsAdapter, FsAdapterOptions } from 'files-sdk/fs';\n"]}
@@ -0,0 +1,54 @@
1
+ import type { Adapter } from 'files-sdk';
2
+ import { type LoadFilesOptions } from 'files-sdk/loader';
3
+ import { type EnvVar, type Provider, type ProviderSlug } from 'files-sdk/providers';
4
+ import { type FilesSdkDriverOptions, type FilesSdkStorageDriver } from '../files-sdk.driver.js';
5
+ /** Slug of a storage provider this package can build a driver for. */
6
+ export type StorageProviderName = ProviderSlug;
7
+ /**
8
+ * Flat, provider-specific settings — `bucket` and `region` for an object store,
9
+ * `root` for the filesystem, `accountName` and `container` for Azure, and so
10
+ * on. Every provider reads what it needs and ignores the rest, so one config
11
+ * shape serves a deployment that switches providers by name.
12
+ *
13
+ * Credentials may be omitted for any provider whose SDK resolves its own chain
14
+ * (an IAM role, Application Default Credentials, a shared profile).
15
+ */
16
+ export type StorageProviderConfig = Omit<LoadFilesOptions, 'provider'>;
17
+ export interface ProviderStorageDriverOptions extends Omit<FilesSdkDriverOptions<Adapter>, 'adapter'> {
18
+ /** Which provider to build. Validate untrusted input with {@link isStorageProvider}. */
19
+ provider: StorageProviderName;
20
+ config?: StorageProviderConfig;
21
+ }
22
+ /**
23
+ * Builds a {@link FilesSdkStorageDriver} for a provider named at runtime,
24
+ * importing that provider's adapter — and only that one — on demand. A
25
+ * deployment selects its store with a string (`'s3'`, `'gcs'`, `'azure'`,
26
+ * `'r2'`, `'fs'`, …) and installs one native SDK, instead of the application
27
+ * hard-coding a driver per backend.
28
+ *
29
+ * The `s3` slug additionally gets the conditional-promotion and signed-policy
30
+ * capabilities {@link createS3StorageDriver} attaches; every other provider
31
+ * exposes exactly what its adapter declares. Import
32
+ * `@nestm/storage/files-sdk/s3` directly when the provider is known at build
33
+ * time and the extra indirection buys nothing.
34
+ *
35
+ * @throws StorageError `INVALID_ARGUMENT` for an unknown slug, and whatever the
36
+ * adapter reports (mapped) when required config or credentials are missing.
37
+ */
38
+ export declare function createProviderStorageDriver(options: ProviderStorageDriverOptions): Promise<FilesSdkStorageDriver>;
39
+ /** Narrows an untrusted string — an env var, a config file — to a known slug. */
40
+ export declare function isStorageProvider(value: string): value is StorageProviderName;
41
+ /** Every provider that can be named, sorted by slug. */
42
+ export declare function listStorageProviders(): readonly Provider[];
43
+ /** One provider's display name, description, native SDKs, and env contract. */
44
+ export declare function getStorageProvider(slug: string): Provider | undefined;
45
+ /**
46
+ * Every environment variable a provider reads, flattened across required, all
47
+ * credential modes, and optional. Useful for validating a deployment's config
48
+ * before the first upload rather than at it.
49
+ */
50
+ export declare function listStorageProviderEnvVars(slug: string): EnvVar[];
51
+ /** The subset of {@link listStorageProviderEnvVars} that carries secrets. */
52
+ export declare function listStorageProviderSecretEnvVars(slug: string): EnvVar[];
53
+ export type { EnvVar as StorageProviderEnvVar, Provider as StorageProviderInfo, } from 'files-sdk/providers';
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files-sdk/provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AAEvE,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CACxD,qBAAqB,CAAC,OAAO,CAAC,EAC9B,SAAS,CACV;IACC,wFAAwF;IACxF,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,qBAAqB,CAAC,CAWhC;AAoCD,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,mBAAmB,CAE7E;AAED,wDAAwD;AACxD,wBAAgB,oBAAoB,IAAI,SAAS,QAAQ,EAAE,CAE1D;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAErE;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjE;AAED,6EAA6E;AAC7E,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvE;AAED,YAAY,EACV,MAAM,IAAI,qBAAqB,EAC/B,QAAQ,IAAI,mBAAmB,GAChC,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,80 @@
1
+ import { loadFiles } from 'files-sdk/loader';
2
+ import { PROVIDER_NAMES, getProvider, getSecretEnvVars, listEnvVars, } from 'files-sdk/providers';
3
+ import { StorageError, StorageErrorCode } from '../../storage.error.js';
4
+ import { createFilesSdkDriver, mapFilesSdkError, } from '../files-sdk.driver.js';
5
+ /**
6
+ * Builds a {@link FilesSdkStorageDriver} for a provider named at runtime,
7
+ * importing that provider's adapter — and only that one — on demand. A
8
+ * deployment selects its store with a string (`'s3'`, `'gcs'`, `'azure'`,
9
+ * `'r2'`, `'fs'`, …) and installs one native SDK, instead of the application
10
+ * hard-coding a driver per backend.
11
+ *
12
+ * The `s3` slug additionally gets the conditional-promotion and signed-policy
13
+ * capabilities {@link createS3StorageDriver} attaches; every other provider
14
+ * exposes exactly what its adapter declares. Import
15
+ * `@nestm/storage/files-sdk/s3` directly when the provider is known at build
16
+ * time and the extra indirection buys nothing.
17
+ *
18
+ * @throws StorageError `INVALID_ARGUMENT` for an unknown slug, and whatever the
19
+ * adapter reports (mapped) when required config or credentials are missing.
20
+ */
21
+ export async function createProviderStorageDriver(options) {
22
+ const { provider, config, ...filesOptions } = options;
23
+ if (!isStorageProvider(provider)) {
24
+ throw unknownProvider(provider);
25
+ }
26
+ // `loadFiles` owns the slug → adapter mapping and keeps the import lazy; the
27
+ // client it returns is discarded so the caller's own driver options (prefix,
28
+ // hooks, plugins, readonly, retries) apply to the instance the bridge builds.
29
+ const adapter = await resolveAdapter(provider, config);
30
+ return createFilesSdkDriver({ ...filesOptions, adapter });
31
+ }
32
+ async function resolveAdapter(provider, config) {
33
+ let resolved;
34
+ try {
35
+ resolved = await loadFiles({ ...config, provider });
36
+ }
37
+ catch (error) {
38
+ throw mapFilesSdkError(error);
39
+ }
40
+ const { adapter } = resolved.files;
41
+ if (provider !== 's3') {
42
+ return adapter;
43
+ }
44
+ // Built by `s3(...)`, so its `raw` is an S3Client and the promotion path
45
+ // holds. The S3-compatible wrappers keep only what they declare themselves.
46
+ const { withS3Capabilities } = await import('../s3/index.js');
47
+ return withS3Capabilities(adapter, {
48
+ ...(config?.publicBaseUrl !== undefined && {
49
+ publicBaseUrl: config.publicBaseUrl,
50
+ }),
51
+ });
52
+ }
53
+ function unknownProvider(provider) {
54
+ return new StorageError(`Unknown storage provider: ${JSON.stringify(provider)}. Known providers: ${PROVIDER_NAMES.join(', ')}.`, { code: StorageErrorCode.INVALID_ARGUMENT, permanent: true });
55
+ }
56
+ /** Narrows an untrusted string — an env var, a config file — to a known slug. */
57
+ export function isStorageProvider(value) {
58
+ return getProvider(value) !== undefined;
59
+ }
60
+ /** Every provider that can be named, sorted by slug. */
61
+ export function listStorageProviders() {
62
+ return PROVIDER_NAMES.flatMap((slug) => getProvider(slug) ?? []);
63
+ }
64
+ /** One provider's display name, description, native SDKs, and env contract. */
65
+ export function getStorageProvider(slug) {
66
+ return getProvider(slug);
67
+ }
68
+ /**
69
+ * Every environment variable a provider reads, flattened across required, all
70
+ * credential modes, and optional. Useful for validating a deployment's config
71
+ * before the first upload rather than at it.
72
+ */
73
+ export function listStorageProviderEnvVars(slug) {
74
+ return listEnvVars(slug);
75
+ }
76
+ /** The subset of {@link listStorageProviderEnvVars} that carries secrets. */
77
+ export function listStorageProviderSecretEnvVars(slug) {
78
+ return getSecretEnvVars(slug);
79
+ }
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/files-sdk/provider/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAyB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,GAIZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAyBhC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAqC;IAErC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;IACtD,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,MAAM,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,6EAA6E;IAC7E,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,QAAQ,EA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,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gCAAgC,CAAC,IAAY;IAC3D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import type { Adapter } from 'files-sdk';\nimport { loadFiles, type LoadFilesOptions } from 'files-sdk/loader';\nimport {\n PROVIDER_NAMES,\n getProvider,\n getSecretEnvVars,\n listEnvVars,\n type EnvVar,\n type Provider,\n type ProviderSlug,\n} from 'files-sdk/providers';\n\nimport { StorageError, StorageErrorCode } from '../../storage.error.js';\nimport {\n createFilesSdkDriver,\n mapFilesSdkError,\n type FilesSdkDriverOptions,\n type FilesSdkStorageDriver,\n} from '../files-sdk.driver.js';\n\n/** Slug of a storage provider this package can build a driver for. */\nexport type StorageProviderName = ProviderSlug;\n\n/**\n * Flat, provider-specific settings — `bucket` and `region` for an object store,\n * `root` for the filesystem, `accountName` and `container` for Azure, and so\n * on. Every provider reads what it needs and ignores the rest, so one config\n * shape serves a deployment that switches providers by name.\n *\n * Credentials may be omitted for any provider whose SDK resolves its own chain\n * (an IAM role, Application Default Credentials, a shared profile).\n */\nexport type StorageProviderConfig = Omit<LoadFilesOptions, 'provider'>;\n\nexport interface ProviderStorageDriverOptions extends Omit<\n FilesSdkDriverOptions<Adapter>,\n 'adapter'\n> {\n /** Which provider to build. Validate untrusted input with {@link isStorageProvider}. */\n provider: StorageProviderName;\n config?: StorageProviderConfig;\n}\n\n/**\n * Builds a {@link FilesSdkStorageDriver} for a provider named at runtime,\n * importing that provider's adapter — and only that one — on demand. A\n * deployment selects its store with a string (`'s3'`, `'gcs'`, `'azure'`,\n * `'r2'`, `'fs'`, …) and installs one native SDK, instead of the application\n * hard-coding a driver per backend.\n *\n * The `s3` slug additionally gets the conditional-promotion and signed-policy\n * capabilities {@link createS3StorageDriver} attaches; every other provider\n * exposes exactly what its adapter declares. Import\n * `@nestm/storage/files-sdk/s3` directly when the provider is known at build\n * time and the extra indirection buys nothing.\n *\n * @throws StorageError `INVALID_ARGUMENT` for an unknown slug, and whatever the\n * adapter reports (mapped) when required config or credentials are missing.\n */\nexport async function createProviderStorageDriver(\n options: ProviderStorageDriverOptions,\n): Promise<FilesSdkStorageDriver> {\n const { provider, config, ...filesOptions } = options;\n if (!isStorageProvider(provider)) {\n throw unknownProvider(provider);\n }\n\n // `loadFiles` owns the slug → adapter mapping and keeps the import lazy; the\n // client it returns is discarded so the caller's own driver options (prefix,\n // hooks, plugins, readonly, retries) apply to the instance the bridge builds.\n const adapter = await resolveAdapter(provider, config);\n return createFilesSdkDriver({ ...filesOptions, adapter });\n}\n\nasync function resolveAdapter(\n provider: StorageProviderName,\n config: StorageProviderConfig | undefined,\n): Promise<Adapter> {\n let resolved;\n try {\n resolved = await loadFiles({ ...config, provider });\n } catch (error) {\n throw mapFilesSdkError(error);\n }\n const { adapter } = resolved.files;\n if (provider !== 's3') {\n return adapter;\n }\n // Built by `s3(...)`, so its `raw` is an S3Client and the promotion path\n // holds. The S3-compatible wrappers keep only what they declare themselves.\n const { withS3Capabilities } = await import('../s3/index.js');\n return withS3Capabilities(\n adapter as Parameters<typeof withS3Capabilities>[0],\n {\n ...(config?.publicBaseUrl !== undefined && {\n publicBaseUrl: config.publicBaseUrl,\n }),\n },\n );\n}\n\nfunction unknownProvider(provider: string): StorageError {\n return new StorageError(\n `Unknown storage provider: ${JSON.stringify(provider)}. Known providers: ${PROVIDER_NAMES.join(', ')}.`,\n { code: StorageErrorCode.INVALID_ARGUMENT, permanent: true },\n );\n}\n\n/** Narrows an untrusted string — an env var, a config file — to a known slug. */\nexport function isStorageProvider(value: string): value is StorageProviderName {\n return getProvider(value) !== undefined;\n}\n\n/** Every provider that can be named, sorted by slug. */\nexport function listStorageProviders(): readonly Provider[] {\n return PROVIDER_NAMES.flatMap((slug) => getProvider(slug) ?? []);\n}\n\n/** One provider's display name, description, native SDKs, and env contract. */\nexport function getStorageProvider(slug: string): Provider | undefined {\n return getProvider(slug);\n}\n\n/**\n * Every environment variable a provider reads, flattened across required, all\n * credential modes, and optional. Useful for validating a deployment's config\n * before the first upload rather than at it.\n */\nexport function listStorageProviderEnvVars(slug: string): EnvVar[] {\n return listEnvVars(slug);\n}\n\n/** The subset of {@link listStorageProviderEnvVars} that carries secrets. */\nexport function listStorageProviderSecretEnvVars(slug: string): EnvVar[] {\n return getSecretEnvVars(slug);\n}\n\nexport type {\n EnvVar as StorageProviderEnvVar,\n Provider as StorageProviderInfo,\n} from 'files-sdk/providers';\n"]}
@@ -3,12 +3,23 @@ import { type FilesSdkConditionalCopyAdapter, type FilesSdkDriverOptions, type F
3
3
  export interface S3StorageDriverOptions extends Omit<FilesSdkDriverOptions<S3Adapter>, 'adapter'> {
4
4
  adapter: S3AdapterOptions;
5
5
  }
6
- type EnhancedS3Adapter = S3Adapter & FilesSdkConditionalCopyAdapter & FilesSdkSignedDownloadPolicyAdapter & FilesSdkSignedUploadPolicyAdapter;
6
+ export type S3StorageAdapter = S3Adapter & FilesSdkConditionalCopyAdapter & FilesSdkSignedDownloadPolicyAdapter & FilesSdkSignedUploadPolicyAdapter;
7
+ /**
8
+ * Adds the S3-only capabilities to an adapter already built by `s3(...)`: an
9
+ * ETag/version-conditional server-side promotion, and the signed upload and
10
+ * download policies the bridge advertises through `capabilities`.
11
+ *
12
+ * Exported so the provider factory can apply them to the adapter `loadFiles`
13
+ * resolved for the `s3` slug instead of re-deriving {@link S3AdapterOptions}
14
+ * from flat provider config. It expects an adapter whose `raw` is an `S3Client`
15
+ * — pass one built by `s3(...)`, not an S3-compatible wrapper.
16
+ */
17
+ export declare function withS3Capabilities(base: S3Adapter, options?: Pick<S3AdapterOptions, 'publicBaseUrl'>): S3StorageAdapter;
7
18
  /**
8
19
  * Creates the files-sdk S3 driver from the storage package's own dependency
9
20
  * context and adds an ETag/version-conditional server-side promotion.
10
21
  */
11
- export declare function createS3StorageDriver(options: S3StorageDriverOptions): FilesSdkStorageDriver<EnhancedS3Adapter>;
22
+ export declare function createS3StorageDriver(options: S3StorageDriverOptions): FilesSdkStorageDriver<S3StorageAdapter>;
12
23
  export { mapS3Error, s3 } from 'files-sdk/s3';
13
24
  export type { S3Adapter, S3AdapterOptions, S3Sdk } from 'files-sdk/s3';
14
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files-sdk/s3/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,EAC1B,KAAK,iCAAiC,EACtC,KAAK,mCAAmC,EACxC,KAAK,qBAAqB,EAE3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,qBAAqB,CAAC,SAAS,CAAC,EAChC,SAAS,CACV;IACC,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,KAAK,iBAAiB,GAAG,SAAS,GAChC,8BAA8B,GAC9B,mCAAmC,GACnC,iCAAiC,CAAC;AA6DpC;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAAC,iBAAiB,CAAC,CAyE1C;AAED,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/files-sdk/s3/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,qBAAqB,EAC1B,KAAK,iCAAiC,EACtC,KAAK,mCAAmC,EACxC,KAAK,qBAAqB,EAE3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAClD,qBAAqB,CAAC,SAAS,CAAC,EAChC,SAAS,CACV;IACC,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,MAAM,gBAAgB,GAAG,SAAS,GACtC,8BAA8B,GAC9B,mCAAmC,GACnC,iCAAiC,CAAC;AA6DpC;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAM,GACpD,gBAAgB,CAkElB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAAC,gBAAgB,CAAC,CAMzC;AAED,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC"}
@@ -43,13 +43,17 @@ async function waitForRetry(milliseconds, signal) {
43
43
  });
44
44
  }
45
45
  /**
46
- * Creates the files-sdk S3 driver from the storage package's own dependency
47
- * context and adds an ETag/version-conditional server-side promotion.
46
+ * Adds the S3-only capabilities to an adapter already built by `s3(...)`: an
47
+ * ETag/version-conditional server-side promotion, and the signed upload and
48
+ * download policies the bridge advertises through `capabilities`.
49
+ *
50
+ * Exported so the provider factory can apply them to the adapter `loadFiles`
51
+ * resolved for the `s3` slug instead of re-deriving {@link S3AdapterOptions}
52
+ * from flat provider config. It expects an adapter whose `raw` is an `S3Client`
53
+ * — pass one built by `s3(...)`, not an S3-compatible wrapper.
48
54
  */
49
- export function createS3StorageDriver(options) {
50
- const { adapter: adapterOptions, ...filesOptions } = options;
51
- const base = s3(adapterOptions);
52
- const adapter = Object.assign(base, {
55
+ export function withS3Capabilities(base, options = {}) {
56
+ return Object.assign(base, {
53
57
  conditionalCopy: Object.freeze({
54
58
  etag: true,
55
59
  supported: true,
@@ -60,7 +64,7 @@ export function createS3StorageDriver(options) {
60
64
  sizeRange: true,
61
65
  }),
62
66
  signedDownloadPolicy: Object.freeze({
63
- expiresIn: adapterOptions.publicBaseUrl === undefined,
67
+ expiresIn: options.publicBaseUrl === undefined,
64
68
  }),
65
69
  async promote(sourceKey, destinationKey, promotion) {
66
70
  const retries = maxRetries(promotion);
@@ -99,9 +103,16 @@ export function createS3StorageDriver(options) {
99
103
  }
100
104
  },
101
105
  });
106
+ }
107
+ /**
108
+ * Creates the files-sdk S3 driver from the storage package's own dependency
109
+ * context and adds an ETag/version-conditional server-side promotion.
110
+ */
111
+ export function createS3StorageDriver(options) {
112
+ const { adapter: adapterOptions, ...filesOptions } = options;
102
113
  return createFilesSdkDriver({
103
114
  ...filesOptions,
104
- adapter,
115
+ adapter: withS3Capabilities(s3(adapterOptions), adapterOptions),
105
116
  });
106
117
  }
107
118
  export { mapS3Error, s3 } from 'files-sdk/s3';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/files-sdk/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,UAAU,EACV,EAAE,GAGH,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,oBAAoB,EAMpB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAchC,SAAS,UAAU,CACjB,MAAc,EACd,GAAW,EACX,OAA2B;IAE3B,MAAM,MAAM,GAAG,GAAG,k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CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;oBACzC,MAAM,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;KAGgC,CAAC,CAAC;IAErC,OAAO,oBAAoB,CAAC;QAC1B,GAAG,YAAY;QACf,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { CopyObjectCommand } from '@aws-sdk/client-s3';\nimport {\n mapS3Error,\n s3,\n type S3Adapter,\n type S3AdapterOptions,\n} from 'files-sdk/s3';\n\nimport type { StoragePromotionOptions } from '../../storage.types.js';\nimport {\n createFilesSdkDriver,\n type FilesSdkConditionalCopyAdapter,\n type FilesSdkDriverOptions,\n type FilesSdkSignedUploadPolicyAdapter,\n type FilesSdkSignedDownloadPolicyAdapter,\n type FilesSdkStorageDriver,\n mapFilesSdkError,\n} from '../files-sdk.driver.js';\n\nexport interface S3StorageDriverOptions extends Omit<\n FilesSdkDriverOptions<S3Adapter>,\n 'adapter'\n> {\n adapter: S3AdapterOptions;\n}\n\ntype EnhancedS3Adapter = S3Adapter &\n FilesSdkConditionalCopyAdapter &\n FilesSdkSignedDownloadPolicyAdapter &\n FilesSdkSignedUploadPolicyAdapter;\n\nfunction copySource(\n bucket: string,\n key: string,\n version: string | undefined,\n): string {\n const source = `${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`;\n return version === undefined\n ? source\n : `${source}?versionId=${encodeURIComponent(version)}`;\n}\n\nfunction operationSignal(\n options: StoragePromotionOptions,\n): AbortSignal | undefined {\n const timeoutSignal =\n options.timeout === undefined || options.timeout <= 0\n ? undefined\n : AbortSignal.timeout(options.timeout);\n if (options.signal === undefined) {\n return timeoutSignal;\n }\n return timeoutSignal === undefined\n ? options.signal\n : AbortSignal.any([options.signal, timeoutSignal]);\n}\n\nfunction maxRetries(options: StoragePromotionOptions): number {\n const configured =\n typeof options.retries === 'number'\n ? options.retries\n : options.retries?.max;\n return Math.max(0, Math.floor(configured ?? 0));\n}\n\nasync function waitForRetry(\n milliseconds: number,\n signal: AbortSignal | undefined,\n): Promise<void> {\n if (signal?.aborted === true) {\n throw signal.reason;\n }\n await new Promise<void>((resolve, reject) => {\n const cleanup = (): void => signal?.removeEventListener('abort', abort);\n const timer = setTimeout(\n () => {\n cleanup();\n resolve();\n },\n Math.max(0, milliseconds),\n );\n const abort = (): void => {\n clearTimeout(timer);\n cleanup();\n reject(signal?.reason);\n };\n signal?.addEventListener('abort', abort, { once: true });\n });\n}\n\n/**\n * Creates the files-sdk S3 driver from the storage package's own dependency\n * context and adds an ETag/version-conditional server-side promotion.\n */\nexport function createS3StorageDriver(\n options: S3StorageDriverOptions,\n): FilesSdkStorageDriver<EnhancedS3Adapter> {\n const { adapter: adapterOptions, ...filesOptions } = options;\n const base = s3(adapterOptions);\n const adapter: EnhancedS3Adapter = Object.assign(base, {\n conditionalCopy: Object.freeze({\n etag: true,\n supported: true,\n version: true,\n }),\n signedUploadPolicy: Object.freeze({\n contentType: true,\n sizeRange: true,\n }),\n signedDownloadPolicy: Object.freeze({\n expiresIn: adapterOptions.publicBaseUrl === undefined,\n }),\n async promote(\n sourceKey: string,\n destinationKey: string,\n promotion: StoragePromotionOptions,\n ): Promise<void> {\n const retries = maxRetries(promotion);\n for (let attempt = 0; ; attempt += 1) {\n const signal = operationSignal(promotion);\n try {\n await base.raw.send(\n new CopyObjectCommand({\n Bucket: base.bucket,\n CopySource: copySource(\n base.bucket,\n sourceKey,\n promotion.sourceVersion,\n ),\n ...(promotion.sourceEtag !== undefined && {\n CopySourceIfMatch: promotion.sourceEtag,\n }),\n Key: destinationKey,\n }),\n signal === undefined ? undefined : { abortSignal: signal },\n );\n return;\n } catch (error) {\n const mapped = mapS3Error(error);\n if (\n attempt >= retries ||\n mapped.code !== 'Provider' ||\n mapped.aborted ||\n mapped.permanent ||\n signal?.aborted === true\n ) {\n throw mapped;\n }\n const storageError = mapFilesSdkError(mapped);\n const delay =\n typeof promotion.retries === 'object' &&\n promotion.retries.backoff !== undefined\n ? promotion.retries.backoff({\n attempt: attempt + 1,\n error: storageError,\n })\n : Math.min(1000, 100 * 2 ** attempt);\n await waitForRetry(delay, promotion.signal);\n }\n }\n },\n } satisfies FilesSdkConditionalCopyAdapter &\n FilesSdkSignedDownloadPolicyAdapter &\n FilesSdkSignedUploadPolicyAdapter);\n\n return createFilesSdkDriver({\n ...filesOptions,\n adapter,\n });\n}\n\nexport { mapS3Error, s3 } from 'files-sdk/s3';\nexport type { S3Adapter, S3AdapterOptions, S3Sdk } from 'files-sdk/s3';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/files-sdk/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,UAAU,EACV,EAAE,GAGH,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,oBAAoB,EAMpB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAchC,SAAS,UAAU,CACjB,MAAc,EACd,GAAW,EACX,OAA2B;IAE3B,MAAM,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1E,OAAO,OAAO,KAAK,SAAS;QAC1B,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,GAAG,MAAM,cAAc,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,eAAe,CACtB,OAAgC;IAEhC,MAAM,aAAa,GACjB,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC;QACnD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,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AAM,cAAc,CAAC","sourcesContent":["import { CopyObjectCommand } from '@aws-sdk/client-s3';\nimport {\n mapS3Error,\n s3,\n type S3Adapter,\n type S3AdapterOptions,\n} from 'files-sdk/s3';\n\nimport type { StoragePromotionOptions } from '../../storage.types.js';\nimport {\n createFilesSdkDriver,\n type FilesSdkConditionalCopyAdapter,\n type FilesSdkDriverOptions,\n type FilesSdkSignedUploadPolicyAdapter,\n type FilesSdkSignedDownloadPolicyAdapter,\n type FilesSdkStorageDriver,\n mapFilesSdkError,\n} from '../files-sdk.driver.js';\n\nexport interface S3StorageDriverOptions extends Omit<\n FilesSdkDriverOptions<S3Adapter>,\n 'adapter'\n> {\n adapter: S3AdapterOptions;\n}\n\nexport type S3StorageAdapter = S3Adapter &\n FilesSdkConditionalCopyAdapter &\n FilesSdkSignedDownloadPolicyAdapter &\n FilesSdkSignedUploadPolicyAdapter;\n\nfunction copySource(\n bucket: string,\n key: string,\n version: string | undefined,\n): string {\n const source = `${encodeURIComponent(bucket)}/${encodeURIComponent(key)}`;\n return version === undefined\n ? source\n : `${source}?versionId=${encodeURIComponent(version)}`;\n}\n\nfunction operationSignal(\n options: StoragePromotionOptions,\n): AbortSignal | undefined {\n const timeoutSignal =\n options.timeout === undefined || options.timeout <= 0\n ? undefined\n : AbortSignal.timeout(options.timeout);\n if (options.signal === undefined) {\n return timeoutSignal;\n }\n return timeoutSignal === undefined\n ? options.signal\n : AbortSignal.any([options.signal, timeoutSignal]);\n}\n\nfunction maxRetries(options: StoragePromotionOptions): number {\n const configured =\n typeof options.retries === 'number'\n ? options.retries\n : options.retries?.max;\n return Math.max(0, Math.floor(configured ?? 0));\n}\n\nasync function waitForRetry(\n milliseconds: number,\n signal: AbortSignal | undefined,\n): Promise<void> {\n if (signal?.aborted === true) {\n throw signal.reason;\n }\n await new Promise<void>((resolve, reject) => {\n const cleanup = (): void => signal?.removeEventListener('abort', abort);\n const timer = setTimeout(\n () => {\n cleanup();\n resolve();\n },\n Math.max(0, milliseconds),\n );\n const abort = (): void => {\n clearTimeout(timer);\n cleanup();\n reject(signal?.reason);\n };\n signal?.addEventListener('abort', abort, { once: true });\n });\n}\n\n/**\n * Adds the S3-only capabilities to an adapter already built by `s3(...)`: an\n * ETag/version-conditional server-side promotion, and the signed upload and\n * download policies the bridge advertises through `capabilities`.\n *\n * Exported so the provider factory can apply them to the adapter `loadFiles`\n * resolved for the `s3` slug instead of re-deriving {@link S3AdapterOptions}\n * from flat provider config. It expects an adapter whose `raw` is an `S3Client`\n * pass one built by `s3(...)`, not an S3-compatible wrapper.\n */\nexport function withS3Capabilities(\n base: S3Adapter,\n options: Pick<S3AdapterOptions, 'publicBaseUrl'> = {},\n): S3StorageAdapter {\n return Object.assign(base, {\n conditionalCopy: Object.freeze({\n etag: true,\n supported: true,\n version: true,\n }),\n signedUploadPolicy: Object.freeze({\n contentType: true,\n sizeRange: true,\n }),\n signedDownloadPolicy: Object.freeze({\n expiresIn: options.publicBaseUrl === undefined,\n }),\n async promote(\n sourceKey: string,\n destinationKey: string,\n promotion: StoragePromotionOptions,\n ): Promise<void> {\n const retries = maxRetries(promotion);\n for (let attempt = 0; ; attempt += 1) {\n const signal = operationSignal(promotion);\n try {\n await base.raw.send(\n new CopyObjectCommand({\n Bucket: base.bucket,\n CopySource: copySource(\n base.bucket,\n sourceKey,\n promotion.sourceVersion,\n ),\n ...(promotion.sourceEtag !== undefined && {\n CopySourceIfMatch: promotion.sourceEtag,\n }),\n Key: destinationKey,\n }),\n signal === undefined ? undefined : { abortSignal: signal },\n );\n return;\n } catch (error) {\n const mapped = mapS3Error(error);\n if (\n attempt >= retries ||\n mapped.code !== 'Provider' ||\n mapped.aborted ||\n mapped.permanent ||\n signal?.aborted === true\n ) {\n throw mapped;\n }\n const storageError = mapFilesSdkError(mapped);\n const delay =\n typeof promotion.retries === 'object' &&\n promotion.retries.backoff !== undefined\n ? promotion.retries.backoff({\n attempt: attempt + 1,\n error: storageError,\n })\n : Math.min(1000, 100 * 2 ** attempt);\n await waitForRetry(delay, promotion.signal);\n }\n }\n },\n } satisfies FilesSdkConditionalCopyAdapter &\n FilesSdkSignedDownloadPolicyAdapter &\n FilesSdkSignedUploadPolicyAdapter);\n}\n\n/**\n * Creates the files-sdk S3 driver from the storage package's own dependency\n * context and adds an ETag/version-conditional server-side promotion.\n */\nexport function createS3StorageDriver(\n options: S3StorageDriverOptions,\n): FilesSdkStorageDriver<S3StorageAdapter> {\n const { adapter: adapterOptions, ...filesOptions } = options;\n return createFilesSdkDriver({\n ...filesOptions,\n adapter: withS3Capabilities(s3(adapterOptions), adapterOptions),\n });\n}\n\nexport { mapS3Error, s3 } from 'files-sdk/s3';\nexport type { S3Adapter, S3AdapterOptions, S3Sdk } from 'files-sdk/s3';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-gateway-fastify-parser.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway-fastify-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB/C,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAqBzE,qBACa,2BAA4B,YAAW,YAAY;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,eAAe;IAEzD,YAAY,IAAI,IAAI;CAyBrB"}
1
+ {"version":3,"file":"storage-gateway-fastify-parser.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway-fastify-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB/C,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAqBzE,qBACa,2BAA4B,YAAW,YAAY;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW;IAAxC,YAA6B,WAAW,EAAE,eAAe,EAAI;IAE7D,YAAY,IAAI,IAAI,CAwBnB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-gateway-fastify-parser.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway-fastify-parser.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,6BAA6B,GAE9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB/C,MAAM,CAAC,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAEzE,SAAS,oBAAoB;IAC3B,OAAO,IAAI,6BAA6B,CACtC,kDAAkD,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,KAAuC,CAAC;IAC1D,OAAO,CACL,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU;QACpD,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU,CACrD,CAAC;AACJ,CAAC;AAGM,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACT;IAA7B,YAA6B,WAA4B;QAA5B,gBAAW,GAAX,WAAW,CAAiB;IAAG,CAAC;IAE7D,YAAY;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAC5D,IACE,CAAC,uBAAuB,CAAC,QAAQ,CAAC;YAClC,QAAQ,CAAC,oBAAoB,CAAC,0BAA0B,CAAC,EACzD,CAAC;YACD,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,oBAAoB,CAC3B,0BAA0B,EAC1B,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACzB,MAAM,aAAa,GAAG,OAA+B,CAAC;YACtD,IACE,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,CAClC,6BAA6B,CAC9B,KAAK,IAAI,EACV,CAAC;gBACD,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtB,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA5BY,2BAA2B;IADvC,UAAU,EAAE;qCAE+B,eAAe;GAD9C,2BAA2B,CA4BvC","sourcesContent":["import {\n Injectable,\n UnsupportedMediaTypeException,\n type OnModuleInit,\n} from '@nestjs/common';\nimport { HttpAdapterHost } from '@nestjs/core';\nimport type { Readable } from 'node:stream';\n\ninterface FastifyParserInstance {\n hasContentTypeParser(contentType: string): boolean;\n addContentTypeParser(\n contentType: string,\n parser: (\n request: unknown,\n payload: Readable,\n done: (error: Error | null, body?: unknown) => void,\n ) => void,\n ): void;\n}\n\ninterface FastifyParserRequest {\n routeOptions?: {\n config?: Record<string, unknown>;\n };\n}\n\nexport const FASTIFY_STORAGE_UPLOAD_CONFIG = 'nestmStorageGatewayUpload';\n\nfunction unsupportedMediaType(): Error {\n return new UnsupportedMediaTypeException(\n 'Unsupported Media Type: application/octet-stream',\n );\n}\n\nfunction isFastifyParserInstance(\n value: unknown,\n): value is FastifyParserInstance {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const candidate = value as Partial<FastifyParserInstance>;\n return (\n typeof candidate.addContentTypeParser === 'function' &&\n typeof candidate.hasContentTypeParser === 'function'\n );\n}\n\n@Injectable()\nexport class StorageGatewayFastifyParser implements OnModuleInit {\n constructor(private readonly adapterHost: HttpAdapterHost) {}\n\n onModuleInit(): void {\n const instance = this.adapterHost.httpAdapter.getInstance();\n if (\n !isFastifyParserInstance(instance) ||\n instance.hasContentTypeParser('application/octet-stream')\n ) {\n return;\n }\n\n instance.addContentTypeParser(\n 'application/octet-stream',\n (request, payload, done) => {\n const parserRequest = request as FastifyParserRequest;\n if (\n parserRequest.routeOptions?.config?.[\n FASTIFY_STORAGE_UPLOAD_CONFIG\n ] !== true\n ) {\n done(unsupportedMediaType());\n return;\n }\n done(null, payload);\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"storage-gateway-fastify-parser.js","sourceRoot":"","sources":["../../src/gateway/storage-gateway-fastify-parser.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,6BAA6B,GAE9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqB/C,MAAM,CAAC,MAAM,6BAA6B,GAAG,2BAA2B,CAAC;AAEzE,SAAS,oBAAoB;IAC3B,OAAO,IAAI,6BAA6B,CACtC,kDAAkD,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,KAAuC,CAAC;IAC1D,OAAO,CACL,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU;QACpD,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU,CACrD,CAAC;AACJ,CAAC;AAGM,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IACT,WAAW;IAAxC,YAA6B,WAA4B;2BAA5B,WAAW;IAAoB,CAAC;IAE7D,YAAY;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;QAC5D,IACE,CAAC,uBAAuB,CAAC,QAAQ,CAAC;YAClC,QAAQ,CAAC,oBAAoB,CAAC,0BAA0B,CAAC,EACzD,CAAC;YACD,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,oBAAoB,CAC3B,0BAA0B,EAC1B,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YACzB,MAAM,aAAa,GAAG,OAA+B,CAAC;YACtD,IACE,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,CAClC,6BAA6B,CAC9B,KAAK,IAAI,EACV,CAAC;gBACD,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtB,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AA5BY,2BAA2B;IADvC,UAAU,EAAE;qCAE+B,eAAe;GAD9C,2BAA2B,CA4BvC","sourcesContent":["import {\n Injectable,\n UnsupportedMediaTypeException,\n type OnModuleInit,\n} from '@nestjs/common';\nimport { HttpAdapterHost } from '@nestjs/core';\nimport type { Readable } from 'node:stream';\n\ninterface FastifyParserInstance {\n hasContentTypeParser(contentType: string): boolean;\n addContentTypeParser(\n contentType: string,\n parser: (\n request: unknown,\n payload: Readable,\n done: (error: Error | null, body?: unknown) => void,\n ) => void,\n ): void;\n}\n\ninterface FastifyParserRequest {\n routeOptions?: {\n config?: Record<string, unknown>;\n };\n}\n\nexport const FASTIFY_STORAGE_UPLOAD_CONFIG = 'nestmStorageGatewayUpload';\n\nfunction unsupportedMediaType(): Error {\n return new UnsupportedMediaTypeException(\n 'Unsupported Media Type: application/octet-stream',\n );\n}\n\nfunction isFastifyParserInstance(\n value: unknown,\n): value is FastifyParserInstance {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n const candidate = value as Partial<FastifyParserInstance>;\n return (\n typeof candidate.addContentTypeParser === 'function' &&\n typeof candidate.hasContentTypeParser === 'function'\n );\n}\n\n@Injectable()\nexport class StorageGatewayFastifyParser implements OnModuleInit {\n constructor(private readonly adapterHost: HttpAdapterHost) {}\n\n onModuleInit(): void {\n const instance = this.adapterHost.httpAdapter.getInstance();\n if (\n !isFastifyParserInstance(instance) ||\n instance.hasContentTypeParser('application/octet-stream')\n ) {\n return;\n }\n\n instance.addContentTypeParser(\n 'application/octet-stream',\n (request, payload, done) => {\n const parserRequest = request as FastifyParserRequest;\n if (\n parserRequest.routeOptions?.config?.[\n FASTIFY_STORAGE_UPLOAD_CONFIG\n ] !== true\n ) {\n done(unsupportedMediaType());\n return;\n }\n done(null, payload);\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"storage-gateway.controller.d.ts","sourceRoot":"","sources":["../../src/gateway/storage-gateway.controller.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAcvD,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAG7B,MAAM,4BAA4B,CAAC;AAEpC,UAAU,gBAAgB,CAAC,MAAM;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAoWD,qBAEa,wBAAwB;;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAJT,OAAO,EAAE,cAAc,EAEvB,OAAO,EAAE,6BAA6B,EAEtC,SAAS,EAAE,uBAAuB;IAI/C,QAAQ,CACE,GAAG,EAAE,MAAM,GAAG,SAAS,EACrB,KAAK,EAAE,MAAM,GAAG,SAAS,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAChC,QAAQ,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC9C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,GACvB,OAAO,CAAC,IAAI,CAAC;IAuHV,MAAM,CACI,GAAG,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,GACtB,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IA8D/B,IAAI,CACM,GAAG,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,GACvB,OAAO,CAAC,IAAI,CAAC;IAoBV,MAAM,CACI,GAAG,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,OAAO,GAC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