From 7d83ab36b7ecaa3b965aa59348cb04975b35d17b Mon Sep 17 00:00:00 2001 From: Rohin Bhargava Date: Sun, 12 Jan 2025 18:41:41 -0500 Subject: [PATCH] looser s3 init constraints for local bundle --- packages/fdr-sdk/src/api-definition/s3Loader.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/fdr-sdk/src/api-definition/s3Loader.ts b/packages/fdr-sdk/src/api-definition/s3Loader.ts index 189d7ea4da..aa912e19a1 100644 --- a/packages/fdr-sdk/src/api-definition/s3Loader.ts +++ b/packages/fdr-sdk/src/api-definition/s3Loader.ts @@ -4,8 +4,9 @@ import { FdrAPI } from "../client"; import { LatestApiDefinition } from "./latest"; export class S3Loader { - private s3Client: S3Client; - private bucketName: string; + private s3Client: S3Client | undefined; + private bucketName: string | undefined; + constructor() { if ( process.env.AWS_ACCESS_KEY_ID != null && @@ -21,14 +22,16 @@ export class S3Loader { }, }); this.bucketName = process.env.AWS_S3_BUCKET_NAME; - } else { - throw new Error("Missing S3 API definitions configuration in env vars"); } } async loadApiDefinition( apiDefinitionOrKey: LatestApiDefinition ): Promise { + if (this.s3Client == null) { + throw new Error("S3 client not initialized"); + } + let resolvedApi: FdrAPI.api.latest.ApiDefinition; if (typeof apiDefinitionOrKey === "string") { const command = new GetObjectCommand({