@fastly/compute-js-static-publish 8.0.0-beta.4 → 8.0.0-beta.6
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/build/cli/cli/commands/manage/publish-content.d.ts.map +1 -1
- package/build/cli/cli/commands/manage/publish-content.js +8 -6
- package/build/cli/cli/commands/scaffold/index.js +3 -3
- package/build/cli/cli/util/variants.d.ts +1 -1
- package/build/cli/cli/util/variants.d.ts.map +1 -1
- package/build/cli/cli/util/variants.js +7 -3
- package/build/cli/models/config/s3-storage-config.d.ts +1 -0
- package/build/cli/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/cli/models/config/s3-storage-config.js +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts +1 -0
- package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/cli/models/config/static-publish-rc.js +3 -1
- package/build/server/models/config/s3-storage-config.d.ts +1 -0
- package/build/server/models/config/s3-storage-config.d.ts.map +1 -1
- package/build/server/models/config/s3-storage-config.js +1 -0
- package/build/server/models/config/static-publish-rc.d.ts +1 -0
- package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
- package/build/server/models/config/static-publish-rc.js +3 -1
- package/build/server/server/storage/s3-storage-provider.d.ts +6 -1
- package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
- package/build/server/server/storage/s3-storage-provider.js +9 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AA4GA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"publish-content.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/manage/publish-content.ts"],"names":[],"mappings":"AA4GA,wBAAsB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,iBA0ehD"}
|
|
@@ -314,22 +314,24 @@ export async function action(actionArgs) {
|
|
|
314
314
|
const variantFilePath = path.resolve(storageContentDir, variantFilename);
|
|
315
315
|
let variantMetadata = variantMetadatas.get(variant);
|
|
316
316
|
if (variantMetadata != null) {
|
|
317
|
-
|
|
317
|
+
if (verbose) {
|
|
318
|
+
console.log(` 🏃♂️ Asset "${variantKey}" is identical to an item we already know about, reusing existing copy.`);
|
|
319
|
+
}
|
|
318
320
|
}
|
|
319
321
|
else {
|
|
320
322
|
if (!overwriteExisting) {
|
|
321
323
|
const assetVariantMetadata = await storageProvider.getExistingAssetVariant(variantKey);
|
|
322
324
|
if (assetVariantMetadata != null) {
|
|
323
|
-
|
|
325
|
+
if (verbose) {
|
|
326
|
+
console.log(` ・ Asset found in storage with key "${variantKey}".`);
|
|
327
|
+
}
|
|
324
328
|
// And we already know its hash and size.
|
|
325
329
|
variantMetadata = Object.assign(assetVariantMetadata, { existsInKvStore: true });
|
|
326
330
|
}
|
|
327
331
|
}
|
|
328
332
|
if (variantMetadata == null) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
console.log(` ・ Prepping asset for storage with key "${variantKey}".`);
|
|
332
|
-
}
|
|
333
|
+
console.log(` ↦ Prepping new asset for storage: "${variantKey}"`);
|
|
334
|
+
await ensureVariantFileExists(variantFilePath, variant, file, verbose);
|
|
333
335
|
let contentEncoding, hash, size;
|
|
334
336
|
if (variant === 'original') {
|
|
335
337
|
contentEncoding = undefined;
|
|
@@ -662,7 +662,7 @@ export async function action(actionArgs) {
|
|
|
662
662
|
packageJsonScripts['fastly:publish'] = 'npx @fastly/compute-js-static-publish publish-content';
|
|
663
663
|
}
|
|
664
664
|
else if (storageMode === 's3') {
|
|
665
|
-
packageJsonScripts['publish'] = 'npx @fastly/compute-js-static-publish publish-content
|
|
665
|
+
packageJsonScripts['s3:publish'] = 'npx @fastly/compute-js-static-publish publish-content';
|
|
666
666
|
}
|
|
667
667
|
resourceFiles['package.json'] = JSON.stringify({
|
|
668
668
|
name,
|
|
@@ -908,11 +908,11 @@ To publish your content to your S3-compatible bucket
|
|
|
908
908
|
|
|
909
909
|
Using an AWS profile set with "aws configure", type:
|
|
910
910
|
cd ${COMPUTE_JS_DIR}
|
|
911
|
-
AWS_PROFILE=xxxx npm run publish
|
|
911
|
+
AWS_PROFILE=xxxx npm run s3:publish
|
|
912
912
|
|
|
913
913
|
Using AWS IAM credentials, type:
|
|
914
914
|
cd ${COMPUTE_JS_DIR}
|
|
915
|
-
AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx npm run publish
|
|
915
|
+
AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx npm run s3:publish
|
|
916
916
|
|
|
917
917
|
To run your Compute application locally
|
|
918
918
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ContentCompressionTypes } from '../../models/compression/index.js';
|
|
2
2
|
export type Variants = 'original' | ContentCompressionTypes;
|
|
3
|
-
export declare function ensureVariantFileExists(variantFilePath: string, variant: Variants, file: string): Promise<void>;
|
|
3
|
+
export declare function ensureVariantFileExists(variantFilePath: string, variant: Variants, file: string, verbose: boolean): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=variants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/variants.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAIjF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,uBAAuB,CAAC;AAE5D,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/cli/util/variants.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAIjF,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,uBAAuB,CAAC;AAE5D,wBAAsB,uBAAuB,CAC3C,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,iBA6BjB"}
|
|
@@ -5,19 +5,23 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import { algs } from '../compression/index.js';
|
|
7
7
|
import { rootRelative } from './files.js';
|
|
8
|
-
export async function ensureVariantFileExists(variantFilePath, variant, file) {
|
|
8
|
+
export async function ensureVariantFileExists(variantFilePath, variant, file, verbose) {
|
|
9
9
|
// Compress/prepare the asset if it doesn't already exist
|
|
10
10
|
// We disregard chunked copies of the file and only check for the existence
|
|
11
11
|
// of the main copy of the file at this point.
|
|
12
12
|
if (!fs.existsSync(variantFilePath)) {
|
|
13
13
|
if (variant === 'original') {
|
|
14
14
|
fs.cpSync(file, variantFilePath);
|
|
15
|
-
|
|
15
|
+
if (verbose) {
|
|
16
|
+
console.log(` 📄→📄 Copied file '${rootRelative(file)}' to '${rootRelative(variantFilePath)}'.`);
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
19
|
else {
|
|
18
20
|
const compressTo = algs[variant];
|
|
19
21
|
await compressTo(file, variantFilePath);
|
|
20
|
-
|
|
22
|
+
if (verbose) {
|
|
23
|
+
console.log(` 📄→🗄️ Compressed file '${rootRelative(file)}' to '${rootRelative(variantFilePath)}' [${variant}].`);
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
// However, if we did just create the file,
|
|
23
27
|
// we delete any chunked copies that may exist as they can be out of date.
|
|
@@ -3,6 +3,7 @@ export type S3StorageConfig = {
|
|
|
3
3
|
region: string;
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
|
+
fastlyBackendName?: string;
|
|
6
7
|
};
|
|
7
8
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
8
9
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAOpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-publish-rc.d.ts","sourceRoot":"","sources":["../../../../src/models/config/static-publish-rc.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG;IAGhC,SAAS,EAAE,MAAM,CAAC;IAGlB,qBAAqB,EAAE,MAAM,CAAC;IAK9B,yBAAyB,EAAE,MAAM,CAAC;CACnC,CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB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Q,CAAC,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAChC,6BAA6B,GAAG,mBAAmB,CAAC;AAEtD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,sBAAsB,CAyB7E;AAED,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,6BAA6B,CAChC;AAED,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,sBAAsB,CACzB"}
|
|
@@ -30,7 +30,9 @@ export function isS3StorageConfigRc(rc) {
|
|
|
30
30
|
if ('region' in rc.s3 && typeof rc.s3.region === 'string' &&
|
|
31
31
|
'bucket' in rc.s3 && typeof rc.s3.bucket === 'string' && (!('endpoint' in rc.s3) ||
|
|
32
32
|
rc.s3.endpoint === undefined ||
|
|
33
|
-
typeof rc.s3.endpoint === 'string'))
|
|
33
|
+
typeof rc.s3.endpoint === 'string') && (!('fastlyBackendName' in rc.s3) ||
|
|
34
|
+
rc.s3.fastlyBackendName === undefined ||
|
|
35
|
+
typeof rc.s3.fastlyBackendName === 'string')) {
|
|
34
36
|
return true;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -3,6 +3,7 @@ export type S3StorageConfig = {
|
|
|
3
3
|
region: string;
|
|
4
4
|
bucket: string;
|
|
5
5
|
endpoint?: string;
|
|
6
|
+
fastlyBackendName?: string;
|
|
6
7
|
};
|
|
7
8
|
export declare function getS3StorageConfigFromRc(rc: StaticPublishS3Storage): S3StorageConfig;
|
|
8
9
|
//# sourceMappingURL=s3-storage-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"s3-storage-config.d.ts","sourceRoot":"","sources":["../../../../src/models/config/s3-storage-config.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAOpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-publish-rc.d.ts","sourceRoot":"","sources":["../../../../src/models/config/static-publish-rc.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG;IAGhC,SAAS,EAAE,MAAM,CAAC;IAGlB,qBAAqB,EAAE,MAAM,CAAC;IAK9B,yBAAyB,EAAE,MAAM,CAAC;CACnC,CAAC;AAGF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,WAAW,EAAE,UAAU,CAAC;IACxB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAGF,MAAM,MAAM,2BAA2B,GACnC,8BAA8B,GAC9B,iCAAiC,CACpC;AAGD,MAAM,MAAM,oBAAoB,GAC9B,2BAA2B,GAAG,mBAAmB,CAAC;AAEpD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,oBAAoB,CAqBzE;AAGD,MA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B,CAyB7E;AAED,MAAM,MAAM,2BAA2B,GACnC,2BAA2B,GAC3B,6BAA6B,CAChC;AAED,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,sBAAsB,CACzB"}
|
|
@@ -30,7 +30,9 @@ export function isS3StorageConfigRc(rc) {
|
|
|
30
30
|
if ('region' in rc.s3 && typeof rc.s3.region === 'string' &&
|
|
31
31
|
'bucket' in rc.s3 && typeof rc.s3.bucket === 'string' && (!('endpoint' in rc.s3) ||
|
|
32
32
|
rc.s3.endpoint === undefined ||
|
|
33
|
-
typeof rc.s3.endpoint === 'string'))
|
|
33
|
+
typeof rc.s3.endpoint === 'string') && (!('fastlyBackendName' in rc.s3) ||
|
|
34
|
+
rc.s3.fastlyBackendName === undefined ||
|
|
35
|
+
typeof rc.s3.fastlyBackendName === 'string')) {
|
|
34
36
|
return true;
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -14,11 +14,16 @@ export declare function buildAwsCredentialsFromSecretStore(): Promise<{
|
|
|
14
14
|
secretAccessKey: string;
|
|
15
15
|
}>;
|
|
16
16
|
export declare function setAwsCredentialsBuilder(awsCredentialsBuilder: AwsCredentialsBuilder): void;
|
|
17
|
+
export type S3StorageProviderParams = {
|
|
18
|
+
s3Endpoint?: string;
|
|
19
|
+
s3FastlyBackendName?: string;
|
|
20
|
+
};
|
|
17
21
|
export declare class S3StorageProvider implements StorageProvider {
|
|
18
|
-
constructor(s3Region: string, s3Bucket: string,
|
|
22
|
+
constructor(s3Region: string, s3Bucket: string, params?: S3StorageProviderParams);
|
|
19
23
|
private readonly s3Region;
|
|
20
24
|
private readonly s3Bucket;
|
|
21
25
|
private readonly s3Endpoint?;
|
|
26
|
+
private readonly s3FastlyBackendName?;
|
|
22
27
|
private s3Client?;
|
|
23
28
|
getS3Client(): Promise<S3Client>;
|
|
24
29
|
getEntry(key: string): Promise<StorageEntry | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAErF,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"s3-storage-provider.d.ts","sourceRoot":"","sources":["../../../../src/server/storage/s3-storage-provider.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;AAErF,eAAO,MAAM,kBAAkB,EAAE,sBAahC,CAAC;AAMF,wBAAgB,+BAA+B,CAAC,eAAe,EAAE,MAAM,QAEtE;AAED,wBAAgB,kCAAkC,CAAC,cAAc,EAAE,MAAM,QAExE;AAED,wBAAgB,sCAAsC,CAAC,cAAc,EAAE,MAAM,QAE5E;AAED,wBAAsB,kCAAkC;;;GAuBvD;AAGD,wBAAgB,wBAAwB,CAAC,qBAAqB,EAAE,qBAAqB,QAEpF;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,qBAAa,iBAAkB,YAAW,eAAe;gBAErD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,uBAAuB;IAQlC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAS;IAE9C,OAAO,CAAC,QAAQ,CAAC,CAAW;IACtB,WAAW;IAsBX,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CA4B1D"}
|
|
@@ -13,7 +13,10 @@ export const buildStoreProvider = (config) => {
|
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
const s3StorageConfig = getS3StorageConfigFromRc(config);
|
|
16
|
-
return new S3StorageProvider(s3StorageConfig.region, s3StorageConfig.bucket,
|
|
16
|
+
return new S3StorageProvider(s3StorageConfig.region, s3StorageConfig.bucket, {
|
|
17
|
+
s3Endpoint: s3StorageConfig.endpoint,
|
|
18
|
+
s3FastlyBackendName: s3StorageConfig.fastlyBackendName,
|
|
19
|
+
});
|
|
17
20
|
};
|
|
18
21
|
let _secretStoreForAwsCredentials = 'AWS_CREDENTIALS';
|
|
19
22
|
let _secretStoreKeyForAwsAccessKeyId = 'AWS_ACCESS_KEY_ID';
|
|
@@ -55,16 +58,18 @@ export function setAwsCredentialsBuilder(awsCredentialsBuilder) {
|
|
|
55
58
|
_awsCredentialsBuilder = awsCredentialsBuilder;
|
|
56
59
|
}
|
|
57
60
|
export class S3StorageProvider {
|
|
58
|
-
constructor(s3Region, s3Bucket,
|
|
61
|
+
constructor(s3Region, s3Bucket, params) {
|
|
59
62
|
this.s3Region = s3Region;
|
|
60
63
|
this.s3Bucket = s3Bucket;
|
|
61
|
-
this.s3Endpoint = s3Endpoint;
|
|
64
|
+
this.s3Endpoint = params?.s3Endpoint;
|
|
65
|
+
this.s3FastlyBackendName = params?.s3FastlyBackendName;
|
|
62
66
|
}
|
|
63
67
|
async getS3Client() {
|
|
64
68
|
if (this.s3Client != null) {
|
|
65
69
|
return this.s3Client;
|
|
66
70
|
}
|
|
67
71
|
const awsCredentials = await _awsCredentialsBuilder();
|
|
72
|
+
const s3FastlyBackendName = this.s3FastlyBackendName ?? "aws";
|
|
68
73
|
this.s3Client = new S3Client({
|
|
69
74
|
region: this.s3Region,
|
|
70
75
|
endpoint: this.s3Endpoint,
|
|
@@ -75,7 +80,7 @@ export class S3StorageProvider {
|
|
|
75
80
|
},
|
|
76
81
|
maxAttempts: 1,
|
|
77
82
|
requestHandler: new FetchHttpHandler({
|
|
78
|
-
requestInit() { return { backend:
|
|
83
|
+
requestInit() { return { backend: s3FastlyBackendName }; }
|
|
79
84
|
}),
|
|
80
85
|
});
|
|
81
86
|
return this.s3Client;
|