Skip to content

Commit f3fa60f

Browse files
author
naman-contentstack
committed
feat: AM2.0 suppport in config module
1 parent 305cc62 commit f3fa60f

7 files changed

Lines changed: 1181 additions & 1079 deletions

File tree

package-lock.json

Lines changed: 650 additions & 539 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-config/src/commands/config/set/region.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
4646
studio: _flags.string({
4747
description: 'Custom host to set for Studio API',
4848
}),
49+
'asset-management': _flags.string({
50+
description: 'Custom host to set for Asset Management API',
51+
}),
4952
};
5053
static examples = [
5154
'$ csdx config:set:region',
@@ -61,6 +64,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
6164
'$ 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>',
6265
'$ 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>',
6366
'$ 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>',
67+
'$ 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>',
6468
'$ 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>',
6569
];
6670

@@ -78,6 +82,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
7882
let personalizeUrl = regionSetFlags['personalize'];
7983
let launchHubUrl = regionSetFlags['launch'];
8084
let composableStudioUrl = regionSetFlags['studio'];
85+
let assetManagementUrl = regionSetFlags['asset-management'];
8186
let selectedRegion = args.region;
8287
if (!(cda && cma && uiHost && name) && !selectedRegion) {
8388
selectedRegion = await interactive.askRegions();
@@ -108,6 +113,11 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
108113
if (!composableStudioUrl) {
109114
composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
110115
}
116+
if (!assetManagementUrl) {
117+
// Use UI host as base and append /am/api
118+
const baseUrl = uiHost.replace(/\/$/, ''); // Remove trailing slash if present
119+
assetManagementUrl = `${baseUrl}/am/api`;
120+
}
111121
let customRegion: Region = {
112122
cda,
113123
cma,
@@ -117,6 +127,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
117127
personalizeUrl,
118128
launchHubUrl,
119129
composableStudioUrl,
130+
assetManagementUrl,
120131
};
121132
customRegion = regionHandler.setCustomRegion(customRegion);
122133
await authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
@@ -128,6 +139,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
128139
cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
129140
cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
130141
cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
142+
cliux.success(`Asset Management URL: ${customRegion.assetManagementUrl}`);
131143
} catch (error) {
132144
handleAndLogError(error, { ...this.contextDetails, module: 'config-set-region' });
133145
}
@@ -146,6 +158,7 @@ export default class RegionSetCommand extends BaseCommand<typeof RegionSetComman
146158
cliux.success(`Personalize URL: ${regionDetails.personalizeUrl}`);
147159
cliux.success(`Launch URL: ${regionDetails.launchHubUrl}`);
148160
cliux.success(`Studio URL: ${regionDetails.composableStudioUrl}`);
161+
cliux.success(`Asset Management URL: ${regionDetails.assetManagementUrl}`);
149162
} else {
150163
cliux.error(`Invalid region specified.`);
151164
}

packages/contentstack-config/src/interfaces/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface Region {
1919
personalizeUrl: string;
2020
launchHubUrl: string;
2121
composableStudioUrl: string;
22+
assetManagementUrl?: string;
2223
}
2324

2425
export interface Limit {

packages/contentstack-config/src/utils/region-handler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function getRegionObject(regionKey: string): Region {
4040
launchHubUrl: endpoints.launch,
4141
personalizeUrl: endpoints.personalizeManagement,
4242
composableStudioUrl: endpoints.composableStudio,
43+
assetManagementUrl: endpoints.assetManagement || (endpoints.application ? `${endpoints.application.replace(/\/$/, '')}/am/api` : undefined),
4344
};
4445
} catch (error) {
4546
return null;
@@ -166,6 +167,7 @@ class UserConfig {
166167
personalizeUrl: regionObject['personalizeUrl'],
167168
launchHubUrl: regionObject['launchHubUrl'],
168169
composableStudioUrl: regionObject['composableStudioUrl'],
170+
assetManagementUrl: regionObject['assetManagementUrl'],
169171
};
170172

171173
return sanitizedRegion;

packages/contentstack-seed/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@contentstack/cli-cm-import": "~2.0.0-beta.6",
99
"@contentstack/cli-command": "~1.7.2",
1010
"@contentstack/cli-utilities": "~1.17.2",
11-
"@contentstack/management": "~1.27.3",
11+
"@contentstack/management": "~1.27.5",
1212
"inquirer": "8.2.7",
1313
"mkdirp": "^1.0.4",
1414
"tar": "^7.5.4",
@@ -21,7 +21,7 @@
2121
"@types/node": "^14.18.63",
2222
"@types/tar": "^6.1.13",
2323
"@types/tmp": "^0.2.6",
24-
"axios": "^1.8.2",
24+
"axios": "^1.13.5",
2525
"eslint": "^8.57.1",
2626
"eslint-config-oclif": "^6.0.62",
2727
"eslint-config-oclif-typescript": "^3.1.14",

packages/contentstack/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
"@contentstack/cli-cm-seed": "~2.0.0-beta.6",
3636
"@contentstack/cli-command": "~1.7.2",
3737
"@contentstack/cli-config": "~1.19.0",
38-
"@contentstack/cli-launch": "^1.9.2",
38+
"@contentstack/cli-launch": "^1.9.6",
3939
"@contentstack/cli-migration": "~2.0.0-beta.3",
4040
"@contentstack/cli-utilities": "~1.17.2",
4141
"@contentstack/cli-variants": "~2.0.0-beta.4",
42-
"@contentstack/management": "~1.27.3",
42+
"@contentstack/management": "~1.27.5",
4343
"@contentstack/utils": "~1.7.0",
4444
"@oclif/core": "^4.3.0",
45-
"@oclif/plugin-help": "^6.2.28",
45+
"@oclif/plugin-help": "^6.2.37",
4646
"@oclif/plugin-not-found": "^3.2.53",
4747
"@oclif/plugin-plugins": "^5.4.54",
4848
"chalk": "^4.1.2",
@@ -167,4 +167,4 @@
167167
}
168168
},
169169
"repository": "https://github.com/contentstack/cli"
170-
}
170+
}

0 commit comments

Comments
 (0)