From 1ffc126898bf7bce22c0160bdd47631adef12a6e Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Wed, 5 Jun 2024 15:54:28 +0530 Subject: [PATCH 1/2] feat: :recycle: removed old api calls and added new marketplace sdk calls --- src/base-command.ts | 2 ++ src/commands/app/create.ts | 4 ++-- src/util/common-utils.ts | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base-command.ts b/src/base-command.ts index 6ab435e..4b7d655 100644 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -14,6 +14,7 @@ import { cliux, isAuthenticated, } from "@contentstack/cli-utilities"; +import { ContentstackClient as MarketplaceContentstackClient } from "@contentstack/marketplace-sdk"; import config from "./config"; import { ConfigType, LogFn } from "./types"; @@ -39,6 +40,7 @@ export abstract class BaseCommand extends Command { }; protected managementSdk!: ContentstackClient; protected managementAppSdk!: ContentstackClient; + protected marketplaceAppSdk!: MarketplaceContentstackClient; protected flags!: Flags; protected args!: Args; diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index 38471b0..eca0ba8 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -266,8 +266,8 @@ export default class Create extends BaseCommand { appName: this.sharedConfig.appName, }) ); - await this.managementAppSdk - .organization(this.sharedConfig.org) + await this.marketplaceAppSdk + .marketplace(this.sharedConfig.org) .app() .create(this.appData as AppData) .then((response) => { diff --git a/src/util/common-utils.ts b/src/util/common-utils.ts index 6a843e2..6ad5f15 100644 --- a/src/util/common-utils.ts +++ b/src/util/common-utils.ts @@ -1,4 +1,5 @@ import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities"; +import { ContentstackClient as MarketplaceContentstackClient } from "@contentstack/marketplace-sdk"; import { AppLocation, Extension, LogFn } from "../types"; import { cliux, Stack } from "@contentstack/cli-utilities"; import { apiRequestHandler } from "./api-request-handler"; @@ -7,6 +8,10 @@ export type CommonOptions = { log: LogFn; managementSdk: ContentstackClient; }; +export type MarketPlaceOptions = { + log: LogFn; + marketplaceSdk: MarketplaceContentstackClient; +}; async function getOrganizations( options: CommonOptions, From bd7e2cf6f7abcc03c0cf5ead3c5248c22ceadf59 Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Wed, 5 Jun 2024 17:12:34 +0530 Subject: [PATCH 2/2] fix: used marketplace client from cli-utilities for initialization --- src/base-command.ts | 14 ++++++++++++-- src/util/common-utils.ts | 5 ++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/base-command.ts b/src/base-command.ts index 4b7d655..1cb1f74 100644 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -13,8 +13,10 @@ import { InquirePayload, cliux, isAuthenticated, + ContentstackMarketplaceClient, + marketplaceSDKInitiator, + marketplaceSDKClient, } from "@contentstack/cli-utilities"; -import { ContentstackClient as MarketplaceContentstackClient } from "@contentstack/marketplace-sdk"; import config from "./config"; import { ConfigType, LogFn } from "./types"; @@ -40,7 +42,7 @@ export abstract class BaseCommand extends Command { }; protected managementSdk!: ContentstackClient; protected managementAppSdk!: ContentstackClient; - protected marketplaceAppSdk!: MarketplaceContentstackClient; + protected marketplaceAppSdk!: ContentstackMarketplaceClient; protected flags!: Flags; protected args!: Args; @@ -74,6 +76,7 @@ export abstract class BaseCommand extends Command { this.developerHubBaseUrl = this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl(); await this.initCmaSDK(); + await this.initMarketplaceSDK(); // Init logger const logger = new Logger(this.sharedConfig); @@ -128,6 +131,13 @@ export abstract class BaseCommand extends Command { host: this.developerHubBaseUrl, }); } + + async initMarketplaceSDK() { + marketplaceSDKInitiator.init(this.context); + this.marketplaceAppSdk = await marketplaceSDKClient({ + host: this.developerHubBaseUrl, + }); + } /** * @method getValPrompt diff --git a/src/util/common-utils.ts b/src/util/common-utils.ts index 6ad5f15..1731094 100644 --- a/src/util/common-utils.ts +++ b/src/util/common-utils.ts @@ -1,5 +1,4 @@ -import { ContentstackClient, FlagInput } from "@contentstack/cli-utilities"; -import { ContentstackClient as MarketplaceContentstackClient } from "@contentstack/marketplace-sdk"; +import { ContentstackClient, FlagInput, ContentstackMarketplaceClient } from "@contentstack/cli-utilities"; import { AppLocation, Extension, LogFn } from "../types"; import { cliux, Stack } from "@contentstack/cli-utilities"; import { apiRequestHandler } from "./api-request-handler"; @@ -10,7 +9,7 @@ export type CommonOptions = { }; export type MarketPlaceOptions = { log: LogFn; - marketplaceSdk: MarketplaceContentstackClient; + marketplaceSdk: ContentstackMarketplaceClient; }; async function getOrganizations(