Skip to content
Open
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
1,189 changes: 650 additions & 539 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions packages/contentstack-config/src/commands/config/set/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
studio: _flags.string({
description: 'Custom host to set for Studio API',
}),
'asset-management': _flags.string({
description: 'Custom host to set for Asset Management API',
}),
};
static examples = [
'$ csdx config:set:region',
Expand All @@ -61,6 +64,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --personalize <custom_personalize_url>',
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --launch <custom_launch_url>',
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --studio <custom_studio_url>',
'$ csdx config:set:region --cma <custom_cma_host_url> --cda <custom_cda_host_url> --ui-host <custom_ui_host_url> --name "India" --asset-management <asset_management_url>',
'$ csdx config:set:region --cda <custom_cda_host_url> --cma <custom_cma_host_url> --ui-host <custom_ui_host_url> --name "India" --developer-hub <custom_developer_hub_url> --launch <custom_launch_url> --personalize <custom_personalize_url> --studio <custom_studio_url>',
];

Expand All @@ -78,6 +82,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
let personalizeUrl = regionSetFlags['personalize'];
let launchHubUrl = regionSetFlags['launch'];
let composableStudioUrl = regionSetFlags['studio'];
let assetManagementUrl = regionSetFlags['asset-management'];
let selectedRegion = args.region;
if (!(cda && cma && uiHost && name) && !selectedRegion) {
selectedRegion = await interactive.askRegions();
Expand Down Expand Up @@ -108,6 +113,11 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
if (!composableStudioUrl) {
composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
}
if (!assetManagementUrl) {
// Use UI host as base and append /am/api
const baseUrl = uiHost.replace(/\/$/, ''); // Remove trailing slash if present
assetManagementUrl = `${baseUrl}/am/api`;
}
Comment on lines +116 to +120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @naman-contentstack can we move this conversion of baseUrl to assetManagementurl into transformUrl.
Can we use CMA api to transform it into AM api?
cc: @aman19K

let customRegion: Region = {
cda,
cma,
Expand All @@ -117,6 +127,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
personalizeUrl,
launchHubUrl,
composableStudioUrl,
assetManagementUrl,
};
customRegion = regionHandler.setCustomRegion(customRegion);
await authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
Expand All @@ -128,6 +139,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
cliux.success(`Asset Management URL: ${customRegion.assetManagementUrl}`);
} catch (error) {
handleAndLogError(error, { ...this.contextDetails, module: 'config-set-region' });
}
Expand All @@ -146,6 +158,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
cliux.success(`Personalize URL: ${regionDetails.personalizeUrl}`);
cliux.success(`Launch URL: ${regionDetails.launchHubUrl}`);
cliux.success(`Studio URL: ${regionDetails.composableStudioUrl}`);
cliux.success(`Asset Management URL: ${regionDetails.assetManagementUrl}`);
} else {
cliux.error(`Invalid region specified.`);
}
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-config/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface Region {
personalizeUrl: string;
launchHubUrl: string;
composableStudioUrl: string;
assetManagementUrl?: string;
}

export interface Limit {
Expand Down
2 changes: 2 additions & 0 deletions packages/contentstack-config/src/utils/region-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function getRegionObject(regionKey: string): Region {
launchHubUrl: endpoints.launch,
personalizeUrl: endpoints.personalizeManagement,
composableStudioUrl: endpoints.composableStudio,
assetManagementUrl: endpoints.assetManagement || (endpoints.application ? `${endpoints.application.replace(/\/$/, '')}/am/api` : undefined),
};
} catch (error) {
return null;
Expand Down Expand Up @@ -166,6 +167,7 @@ class UserConfig {
personalizeUrl: regionObject['personalizeUrl'],
launchHubUrl: regionObject['launchHubUrl'],
composableStudioUrl: regionObject['composableStudioUrl'],
assetManagementUrl: regionObject['assetManagementUrl'],
};

return sanitizedRegion;
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@contentstack/cli-cm-import": "~2.0.0-beta.6",
"@contentstack/cli-command": "~1.7.2",
"@contentstack/cli-utilities": "~1.17.2",
"@contentstack/management": "~1.27.3",
"@contentstack/management": "~1.27.5",
"inquirer": "8.2.7",
"mkdirp": "^1.0.4",
"tar": "^7.5.4",
Expand All @@ -21,7 +21,7 @@
"@types/node": "^14.18.63",
"@types/tar": "^6.1.13",
"@types/tmp": "^0.2.6",
"axios": "^1.8.2",
"axios": "^1.13.5",
"eslint": "^8.57.1",
"eslint-config-oclif": "^6.0.62",
"eslint-config-oclif-typescript": "^3.1.14",
Expand Down
8 changes: 4 additions & 4 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
"@contentstack/cli-cm-seed": "~2.0.0-beta.6",
"@contentstack/cli-command": "~1.7.2",
"@contentstack/cli-config": "~1.19.0",
"@contentstack/cli-launch": "^1.9.2",
"@contentstack/cli-launch": "^1.9.6",
"@contentstack/cli-migration": "~2.0.0-beta.3",
"@contentstack/cli-utilities": "~1.17.2",
"@contentstack/cli-variants": "~2.0.0-beta.4",
"@contentstack/management": "~1.27.3",
"@contentstack/management": "~1.27.5",
"@contentstack/utils": "~1.7.0",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"@oclif/plugin-help": "^6.2.37",
"@oclif/plugin-not-found": "^3.2.53",
"@oclif/plugin-plugins": "^5.4.54",
"chalk": "^4.1.2",
Expand Down Expand Up @@ -167,4 +167,4 @@
}
},
"repository": "https://github.com/contentstack/cli"
}
}
Loading
Loading