From 76fb579bc33dfa16d45332a3c10403d4d48ccb5f Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 10:52:40 +0530 Subject: [PATCH 1/6] fix: allow siteID and token to be passed in Functions v2 and Edge Functions --- src/store_factory.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/store_factory.ts b/src/store_factory.ts index 420cfc2..77784f5 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -70,6 +70,23 @@ export const getStore: { if (typeof input?.name === 'string') { const { name } = input + + if (typeof input?.siteID === 'string' && typeof input.token === 'string') { + const { siteID, token } = input + const clientOptions = getClientOptions(input, { + siteID, + token + }) + + if (!siteID || !token) { + throw new MissingBlobsEnvironmentError(['siteID', 'token']) + } + + const client = new Client(clientOptions) + + return new Store({ client, name }) + } + const clientOptions = getClientOptions(input) if (!name) { From 67a13bf14782907a465f2dab4a08ab61dcc93ce7 Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 11:42:40 +0530 Subject: [PATCH 2/6] fix: lint errors --- src/store_factory.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/store_factory.ts b/src/store_factory.ts index 77784f5..5a909bc 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -68,25 +68,21 @@ export const getStore: { return new Store({ client, name: input }) } - if (typeof input?.name === 'string') { - const { name } = input - - if (typeof input?.siteID === 'string' && typeof input.token === 'string') { + if (typeof input?.name === 'string' && typeof input?.siteID === 'string' && typeof input?.token === 'string') { const { siteID, token } = input - const clientOptions = getClientOptions(input, { - siteID, - token - }) + const clientOptions = getClientOptions(input, { siteID, token }) - if (!siteID || !token) { - throw new MissingBlobsEnvironmentError(['siteID', 'token']) + if (!name || !siteID || !token) { + throw new MissingBlobsEnvironmentError(['name', 'siteID', 'token']) } const client = new Client(clientOptions) return new Store({ client, name }) } - + + if (typeof input?.name === 'string') { + const { name } = input const clientOptions = getClientOptions(input) if (!name) { From e2dbd22267fe50f54a38609ab83074dd015dab23 Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 11:50:44 +0530 Subject: [PATCH 3/6] fix: lint errors --- src/store_factory.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/store_factory.ts b/src/store_factory.ts index 5a909bc..fc54ac0 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -69,18 +69,18 @@ export const getStore: { } if (typeof input?.name === 'string' && typeof input?.siteID === 'string' && typeof input?.token === 'string') { - const { siteID, token } = input - const clientOptions = getClientOptions(input, { siteID, token }) + const { name, siteID, token } = input + const clientOptions = getClientOptions(input, { siteID, token }) - if (!name || !siteID || !token) { - throw new MissingBlobsEnvironmentError(['name', 'siteID', 'token']) - } - - const client = new Client(clientOptions) - - return new Store({ client, name }) + if (!name || !siteID || !token) { + throw new MissingBlobsEnvironmentError(['name', 'siteID', 'token']) } + const client = new Client(clientOptions) + + return new Store({ client, name }) + } + if (typeof input?.name === 'string') { const { name } = input const clientOptions = getClientOptions(input) From 29c552834f39d1af3ebd6f9e41ef8f4aee636d3d Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 11:51:19 +0530 Subject: [PATCH 4/6] chore: remove extra spaces --- src/store_factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store_factory.ts b/src/store_factory.ts index fc54ac0..2e93a27 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -82,7 +82,7 @@ export const getStore: { } if (typeof input?.name === 'string') { - const { name } = input + const { name } = input const clientOptions = getClientOptions(input) if (!name) { From 165686a38cb730aa3bbcf50d6c970d0220e160c6 Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 11:54:28 +0530 Subject: [PATCH 5/6] chore: fix prettier --- src/store_factory.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/store_factory.ts b/src/store_factory.ts index 2e93a27..6c97298 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -80,9 +80,10 @@ export const getStore: { return new Store({ client, name }) } - + if (typeof input?.name === 'string') { const { name } = input + const clientOptions = getClientOptions(input) if (!name) { From de49b81f34a773c940e6d61dbae8f6ee4bf2fde2 Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Sun, 23 Feb 2025 11:55:00 +0530 Subject: [PATCH 6/6] chore: remvoe extra line break --- src/store_factory.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store_factory.ts b/src/store_factory.ts index 6c97298..5f51e5b 100644 --- a/src/store_factory.ts +++ b/src/store_factory.ts @@ -83,7 +83,6 @@ export const getStore: { if (typeof input?.name === 'string') { const { name } = input - const clientOptions = getClientOptions(input) if (!name) {