Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/src/utils/market-app.utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import contentstack from '@contentstack/marketplace-sdk';
import {client} from '@contentstack/marketplace-sdk';
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)
Expand All @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions api/tests/unit/utils/market-app.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand All @@ -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,
Expand Down Expand Up @@ -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',
});
Expand All @@ -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',
});
Expand Down
Loading