From 05cc1a3d7bf35241d03ab8d19dba5c8c2bdafc33 Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 2 Apr 2026 16:17:19 +0530 Subject: [PATCH 1/2] refactor: update client import and variable naming in market-app.utils.ts --- api/src/utils/market-app.utils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/utils/market-app.utils.ts b/api/src/utils/market-app.utils.ts index 8a5fbe699..470aba4db 100644 --- a/api/src/utils/market-app.utils.ts +++ b/api/src/utils/market-app.utils.ts @@ -1,4 +1,4 @@ -import contentstack from '@contentstack/marketplace-sdk'; +import {client} from '@contentstack/marketplace-sdk'; import { DEVURLS } from '../constants/index.js'; @@ -6,8 +6,8 @@ import { DEVURLS } from '../constants/index.js'; export const getAllApps = async ({ organizationUid, authtoken, region }: any) => { try { - const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA }); - const data = await client.marketplace(organizationUid).findAllApps(); + const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA }); + const data = await contentstackclient.marketplace(organizationUid).findAllApps(); return data?.items; } catch (err) { console.info("🚀 ~ getAllApps ~ err:", err) @@ -16,8 +16,8 @@ export const getAllApps = async ({ organizationUid, authtoken, region }: any) => export const getAppManifestAndAppConfig = async ({ organizationUid, authtoken, region, manifestUid }: any) => { try { - const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA }); - const data = await client.marketplace(organizationUid).app(manifestUid).fetch(); + const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA }); + const data = await contentstackclient.marketplace(organizationUid).app(manifestUid).fetch(); return data; } catch (err: any) { console.info("🚀 ~ getAppManifestAndAppConfig ~ err:", err) From 08e818abbeb674c20368ce2aa6e8408f7a77f54d Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 2 Apr 2026 16:22:18 +0530 Subject: [PATCH 2/2] refactor: simplify client import and update usage in market-app.utils.test.ts --- api/tests/unit/utils/market-app.utils.test.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/api/tests/unit/utils/market-app.utils.test.ts b/api/tests/unit/utils/market-app.utils.test.ts index 646a30064..50306667f 100644 --- a/api/tests/unit/utils/market-app.utils.test.ts +++ b/api/tests/unit/utils/market-app.utils.test.ts @@ -5,9 +5,7 @@ const mockClient = { }; vi.mock('@contentstack/marketplace-sdk', () => ({ - default: { - client: vi.fn(() => mockClient), - }, + client: vi.fn(() => mockClient), })); vi.mock('../../../src/constants/index.js', () => ({ @@ -17,7 +15,7 @@ vi.mock('../../../src/constants/index.js', () => ({ }, })); -import contentstack from '@contentstack/marketplace-sdk'; +import { client as marketplaceClient } from '@contentstack/marketplace-sdk'; import { getAllApps, getAppManifestAndAppConfig, @@ -48,7 +46,7 @@ describe('market-app.utils', () => { }); expect(result).toEqual(mockItems); - expect(contentstack.client).toHaveBeenCalledWith({ + expect(marketplaceClient).toHaveBeenCalledWith({ authtoken: 'token-xyz', host: 'developerhub-api.contentstack.com', }); @@ -66,7 +64,7 @@ describe('market-app.utils', () => { region: 'EU', }); - expect(contentstack.client).toHaveBeenCalledWith({ + expect(marketplaceClient).toHaveBeenCalledWith({ authtoken: 'token', host: 'eu-developerhub-api.contentstack.com', });