@contentstack/cli-config 1.20.5 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version)
21
- @contentstack/cli-config/1.20.5 linux-x64 node-v22.23.0
21
+ @contentstack/cli-config/1.21.1 linux-x64 node-v22.23.1
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -316,8 +316,8 @@ USAGE
316
316
  $ csdx config:set:ea-header [--header-alias <value>] [--header <value>]
317
317
 
318
318
  FLAGS
319
- --header=<value> (optional) Provide the Early Access header alias name.
320
- --header-alias=<value> (optional) Provide the Early Access header value.
319
+ --header=<value> (optional) Provide the Early Access header value.
320
+ --header-alias=<value> (optional) Provide a name (alias) for this Early Access header.
321
321
 
322
322
  DESCRIPTION
323
323
  Set Early Access header
@@ -340,8 +340,8 @@ USAGE
340
340
  $ csdx config:set:early-access-header [--header-alias <value>] [--header <value>]
341
341
 
342
342
  FLAGS
343
- --header=<value> (optional) Provide the Early Access header alias name.
344
- --header-alias=<value> (optional) Provide the Early Access header value.
343
+ --header=<value> (optional) Provide the Early Access header value.
344
+ --header-alias=<value> (optional) Provide a name (alias) for this Early Access header.
345
345
 
346
346
  DESCRIPTION
347
347
  Set Early Access header
@@ -457,7 +457,7 @@ Set region for CLI
457
457
  ```
458
458
  USAGE
459
459
  $ csdx config:set:region [REGION] [-d <value> -m <value> --ui-host <value> -n <value>] [--developer-hub <value>]
460
- [--personalize <value>] [--launch <value>] [--studio <value>]
460
+ [--personalize <value>] [--launch <value>] [--studio <value>] [--auth-api <value>]
461
461
 
462
462
  ARGUMENTS
463
463
  [REGION] Name for the region
@@ -468,6 +468,7 @@ FLAGS
468
468
  -m, --cma=<value> Custom host to set for content management API, , if this flag is added then cda, ui-host
469
469
  and name flags are required
470
470
  -n, --name=<value> Name for the region, if this flag is added then cda, cma and ui-host flags are required
471
+ --auth-api=<value> Custom host to set for Auth API
471
472
  --developer-hub=<value> Custom host to set for Developer hub API
472
473
  --launch=<value> Custom host to set for Launch API
473
474
  --personalize=<value> Custom host to set for Personalize API
@@ -26,8 +26,8 @@ exports.default = SetEarlyAccessHeaderCommand;
26
26
  SetEarlyAccessHeaderCommand.description = 'Set Early Access header';
27
27
  SetEarlyAccessHeaderCommand.aliases = ['config:set:ea-header'];
28
28
  SetEarlyAccessHeaderCommand.flags = {
29
- 'header-alias': cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header value.' }),
30
- header: cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header alias name.' }),
29
+ 'header-alias': cli_utilities_1.flags.string({ description: '(optional) Provide a name (alias) for this Early Access header.' }),
30
+ header: cli_utilities_1.flags.string({ description: '(optional) Provide the Early Access header value.' }),
31
31
  };
32
32
  SetEarlyAccessHeaderCommand.examples = [
33
33
  '$ <%= config.bin %> <%= command.id %>',
@@ -5,6 +5,7 @@ const utils_1 = require("../../../utils");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  class RegionSetCommand extends base_command_1.BaseCommand {
7
7
  async run() {
8
+ var _a;
8
9
  const { args, flags: regionSetFlags } = await this.parse(RegionSetCommand);
9
10
  let cda = regionSetFlags.cda;
10
11
  let cma = regionSetFlags.cma;
@@ -14,6 +15,7 @@ class RegionSetCommand extends base_command_1.BaseCommand {
14
15
  let personalizeUrl = regionSetFlags['personalize'];
15
16
  let launchHubUrl = regionSetFlags['launch'];
16
17
  let composableStudioUrl = regionSetFlags['studio'];
18
+ let authUrl = regionSetFlags['auth-api'];
17
19
  let selectedRegion = args.region;
18
20
  if (!(cda && cma && uiHost && name) && !selectedRegion) {
19
21
  selectedRegion = await utils_1.interactive.askRegions();
@@ -43,6 +45,9 @@ class RegionSetCommand extends base_command_1.BaseCommand {
43
45
  if (!composableStudioUrl) {
44
46
  composableStudioUrl = this.transformUrl(cma, 'composable-studio-api');
45
47
  }
48
+ if (!authUrl) {
49
+ authUrl = this.transformUrl(cma, 'auth-api');
50
+ }
46
51
  let customRegion = {
47
52
  cda,
48
53
  cma,
@@ -52,6 +57,16 @@ class RegionSetCommand extends base_command_1.BaseCommand {
52
57
  personalizeUrl,
53
58
  launchHubUrl,
54
59
  composableStudioUrl,
60
+ endpoints: {
61
+ contentManagement: cma,
62
+ contentDelivery: cda,
63
+ application: uiHost,
64
+ developerHub: developerHubUrl,
65
+ launch: launchHubUrl,
66
+ personalizeManagement: personalizeUrl,
67
+ composableStudio: composableStudioUrl,
68
+ auth: authUrl,
69
+ },
55
70
  };
56
71
  customRegion = utils_1.regionHandler.setCustomRegion(customRegion);
57
72
  await cli_utilities_1.authHandler.setConfigData('logout'); //Todo: Handle this logout flow well through logout command call
@@ -63,6 +78,7 @@ class RegionSetCommand extends base_command_1.BaseCommand {
63
78
  cli_utilities_1.cliux.success(`Personalize URL: ${customRegion.personalizeUrl}`);
64
79
  cli_utilities_1.cliux.success(`Launch URL: ${customRegion.launchHubUrl}`);
65
80
  cli_utilities_1.cliux.success(`Studio URL: ${customRegion.composableStudioUrl}`);
81
+ cli_utilities_1.cliux.success(`Auth API URL: ${(_a = customRegion.endpoints) === null || _a === void 0 ? void 0 : _a.auth}`);
66
82
  }
67
83
  catch (error) {
68
84
  (0, cli_utilities_1.handleAndLogError)(error, Object.assign(Object.assign({}, this.contextDetails), { module: 'config-set-region' }));
@@ -130,6 +146,9 @@ RegionSetCommand.flags = {
130
146
  studio: cli_utilities_1.flags.string({
131
147
  description: 'Custom host to set for Studio API',
132
148
  }),
149
+ 'auth-api': cli_utilities_1.flags.string({
150
+ description: 'Custom host to set for Auth API',
151
+ }),
133
152
  };
134
153
  RegionSetCommand.examples = [
135
154
  '$ csdx config:set:region',
@@ -17,6 +17,7 @@ export interface Region {
17
17
  personalizeUrl: string;
18
18
  launchHubUrl: string;
19
19
  composableStudioUrl: string;
20
+ endpoints?: Record<string, string>;
20
21
  }
21
22
  export interface Limit {
22
23
  value: number;
@@ -38,16 +38,7 @@ declare class UserConfig {
38
38
  * @param { object } regionObject JSON object needs to be sanitized
39
39
  * @returns { object } JSON object with only valid keys for region
40
40
  */
41
- sanitizeRegionObject(regionObject: any): {
42
- cma: any;
43
- cda: any;
44
- uiHost: any;
45
- name: any;
46
- developerHubUrl: any;
47
- personalizeUrl: any;
48
- launchHubUrl: any;
49
- composableStudioUrl: any;
50
- };
41
+ sanitizeRegionObject(regionObject: any): import("@contentstack/cli-utilities").CanonicalRegion;
51
42
  }
52
43
  export { regions };
53
44
  declare const _default: UserConfig;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.regions = void 0;
4
4
  const cli_utilities_1 = require("@contentstack/cli-utilities");
5
- const utils_1 = require("@contentstack/utils");
6
5
  function validURL(str) {
7
6
  const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol (http or https)
8
7
  '([a-zA-Z0-9.-]+|' + // domain name
@@ -20,44 +19,18 @@ function validURL(str) {
20
19
  * @returns {object} Region object with all necessary URLs
21
20
  */
22
21
  function getRegionObject(regionKey) {
23
- try {
24
- // getContentstackEndpoint handles all aliases defined in regions.json
25
- const endpoints = (0, utils_1.getContentstackEndpoint)(regionKey);
26
- if (typeof endpoints === 'string') {
27
- throw new Error('Invalid endpoint response');
28
- }
29
- return {
30
- name: regionKey,
31
- cma: endpoints.contentManagement,
32
- cda: endpoints.contentDelivery,
33
- uiHost: endpoints.application,
34
- developerHubUrl: endpoints.developerHub,
35
- launchHubUrl: endpoints.launch,
36
- personalizeUrl: endpoints.personalizeManagement,
37
- composableStudioUrl: endpoints.composableStudio,
38
- };
39
- }
40
- catch (_a) {
22
+ // resolveCanonicalEndpoints handles all aliases defined in regions.json
23
+ const endpoints = (0, cli_utilities_1.resolveCanonicalEndpoints)(regionKey);
24
+ if (!endpoints)
41
25
  return null;
42
- }
26
+ return (0, cli_utilities_1.buildRegionFromEndpoints)(regionKey, endpoints);
43
27
  }
44
28
  /**
45
29
  * Get all available regions dynamically
46
30
  * This creates a regions object similar to the old hardcoded one but using @contentstack/utils
47
31
  */
48
32
  function getAvailableRegions() {
49
- const regionKeys = [
50
- 'NA',
51
- 'AWS-NA',
52
- 'EU',
53
- 'AWS-EU',
54
- 'AU',
55
- 'AWS-AU',
56
- 'AZURE-NA',
57
- 'AZURE-EU',
58
- 'GCP-NA',
59
- 'GCP-EU',
60
- ];
33
+ const regionKeys = ['NA', 'AWS-NA', 'EU', 'AWS-EU', 'AU', 'AWS-AU', 'AZURE-NA', 'AZURE-EU', 'GCP-NA', 'GCP-EU'];
61
34
  const regions = {};
62
35
  for (const key of regionKeys) {
63
36
  const regionObj = getRegionObject(key);
@@ -142,17 +115,22 @@ class UserConfig {
142
115
  * @returns { object } JSON object with only valid keys for region
143
116
  */
144
117
  sanitizeRegionObject(regionObject) {
145
- const sanitizedRegion = {
146
- cma: regionObject.cma,
147
- cda: regionObject.cda,
148
- uiHost: regionObject.uiHost,
149
- name: regionObject.name,
150
- developerHubUrl: regionObject['developerHubUrl'],
151
- personalizeUrl: regionObject['personalizeUrl'],
152
- launchHubUrl: regionObject['launchHubUrl'],
153
- composableStudioUrl: regionObject['composableStudioUrl'],
118
+ var _a;
119
+ // endpoints is the single source of truth — every friendly field (cma, cda, ...,
120
+ // authUrl) is derived from it below via buildRegionFromEndpoints, same as named
121
+ // regions. Falls back to synthesizing endpoints from the individual raw fields
122
+ // when the caller didn't supply one directly.
123
+ const endpoints = (_a = regionObject['endpoints']) !== null && _a !== void 0 ? _a : {
124
+ contentManagement: regionObject.cma,
125
+ contentDelivery: regionObject.cda,
126
+ application: regionObject.uiHost,
127
+ developerHub: regionObject['developerHubUrl'],
128
+ launch: regionObject['launchHubUrl'],
129
+ personalizeManagement: regionObject['personalizeUrl'],
130
+ composableStudio: regionObject['composableStudioUrl'],
131
+ auth: regionObject['authUrl'],
154
132
  };
155
- return sanitizedRegion;
133
+ return (0, cli_utilities_1.buildRegionFromEndpoints)(regionObject.name, endpoints);
156
134
  }
157
135
  }
158
136
  exports.default = new UserConfig();
@@ -199,14 +199,14 @@
199
199
  ],
200
200
  "flags": {
201
201
  "header-alias": {
202
- "description": "(optional) Provide the Early Access header value.",
202
+ "description": "(optional) Provide a name (alias) for this Early Access header.",
203
203
  "name": "header-alias",
204
204
  "hasDynamicHelp": false,
205
205
  "multiple": false,
206
206
  "type": "option"
207
207
  },
208
208
  "header": {
209
- "description": "(optional) Provide the Early Access header alias name.",
209
+ "description": "(optional) Provide the Early Access header value.",
210
210
  "name": "header",
211
211
  "hasDynamicHelp": false,
212
212
  "multiple": false,
@@ -509,6 +509,13 @@
509
509
  "hasDynamicHelp": false,
510
510
  "multiple": false,
511
511
  "type": "option"
512
+ },
513
+ "auth-api": {
514
+ "description": "Custom host to set for Auth API",
515
+ "name": "auth-api",
516
+ "hasDynamicHelp": false,
517
+ "multiple": false,
518
+ "type": "option"
512
519
  }
513
520
  },
514
521
  "hasDynamicHelp": false,
@@ -667,5 +674,5 @@
667
674
  ]
668
675
  }
669
676
  },
670
- "version": "1.20.5"
677
+ "version": "1.21.1"
671
678
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-config",
3
3
  "description": "Contentstack CLI plugin for configuration",
4
- "version": "1.20.5",
4
+ "version": "1.21.1",
5
5
  "author": "Contentstack",
6
6
  "scripts": {
7
7
  "build": "pnpm compile && oclif manifest && oclif readme",
@@ -14,8 +14,8 @@
14
14
  "lint": "eslint src/**/*.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@contentstack/cli-command": "~1.8.4",
18
- "@contentstack/cli-utilities": "~1.18.5",
17
+ "@contentstack/cli-command": "~1.8.5",
18
+ "@contentstack/cli-utilities": "~1.19.1",
19
19
  "@contentstack/utils": "~1.9.1",
20
20
  "@oclif/core": "^4.11.4"
21
21
  },
@@ -91,4 +91,4 @@
91
91
  }
92
92
  },
93
93
  "repository": "contentstack/cli"
94
- }
94
+ }