@trayio/cdk-cli 4.11.1-unstable → 4.12.0

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
@@ -19,7 +19,7 @@ $ npm install -g @trayio/cdk-cli
19
19
  $ tray-cdk COMMAND
20
20
  running command...
21
21
  $ tray-cdk (--version|-v)
22
- @trayio/cdk-cli/4.11.1-unstable linux-x64 node-v18.20.2
22
+ @trayio/cdk-cli/4.12.0 linux-x64 node-v18.20.2
23
23
  $ tray-cdk --help [COMMAND]
24
24
  USAGE
25
25
  $ tray-cdk COMMAND
@@ -178,7 +178,12 @@ Creates a new deployment for a connector project
178
178
 
179
179
  ```
180
180
  USAGE
181
- $ tray-cdk deployment create
181
+ $ tray-cdk deployment create [--us] [--eu] [--ap]
182
+
183
+ FLAGS
184
+ --ap Use the Tray APAC region
185
+ --eu Use the Tray EU region
186
+ --us Use the Tray US region
182
187
 
183
188
  DESCRIPTION
184
189
  Creates a new deployment for a connector project
@@ -190,7 +195,7 @@ Retrieves the status of a connector deployment
190
195
 
191
196
  ```
192
197
  USAGE
193
- $ tray-cdk deployment get [CONNECTORNAME] [CONNECTORVERSION] [UUID] [-t]
198
+ $ tray-cdk deployment get [CONNECTORNAME] [CONNECTORVERSION] [UUID] [-t] [--us] [--eu] [--ap]
194
199
 
195
200
  ARGUMENTS
196
201
  CONNECTORNAME The name of the connector
@@ -199,6 +204,9 @@ ARGUMENTS
199
204
 
200
205
  FLAGS
201
206
  -t, --tail Enables the command to run until the deployment is complete with either a success or failure.
207
+ --ap Use the Tray APAC region
208
+ --eu Use the Tray EU region
209
+ --us Use the Tray US region
202
210
 
203
211
  DESCRIPTION
204
212
  Retrieves the status of a connector deployment
@@ -249,7 +257,7 @@ Share your connector version with other users in your organization
249
257
 
250
258
  ```
251
259
  USAGE
252
- $ tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION] [-e <value>]
260
+ $ tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION] [-e <value>] [--us] [--eu] [--ap]
253
261
 
254
262
  ARGUMENTS
255
263
  CONNECTORNAME The name of the connector
@@ -257,6 +265,9 @@ ARGUMENTS
257
265
 
258
266
  FLAGS
259
267
  -e, --email=<value> Share with users by providing a list of emails
268
+ --ap Use the Tray APAC region
269
+ --eu Use the Tray EU region
270
+ --us Use the Tray US region
260
271
 
261
272
  DESCRIPTION
262
273
  Share your connector version with other users in your organization
@@ -279,12 +290,17 @@ Retrieves a list of emails that have access to a connector
279
290
 
280
291
  ```
281
292
  USAGE
282
- $ tray-cdk permissions list [CONNECTORNAME] [CONNECTORVERSION]
293
+ $ tray-cdk permissions list [CONNECTORNAME] [CONNECTORVERSION] [--us] [--eu] [--ap]
283
294
 
284
295
  ARGUMENTS
285
296
  CONNECTORNAME The name of the connector
286
297
  CONNECTORVERSION The version of the connector
287
298
 
299
+ FLAGS
300
+ --ap Use the Tray APAC region
301
+ --eu Use the Tray EU region
302
+ --us Use the Tray US region
303
+
288
304
  DESCRIPTION
289
305
  Retrieves a list of emails that have access to a connector
290
306
 
@@ -2,7 +2,12 @@ import { Command } from '@oclif/core';
2
2
  export default class Create extends Command {
3
3
  static description: string;
4
4
  static args: {};
5
- private connectorDeployment;
5
+ static flags: {
6
+ us: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ eu: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ ap: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ };
10
+ private regionHandler;
6
11
  run(): Promise<void>;
7
12
  }
8
13
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAW1C,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IAC1C,MAAM,CAAC,WAAW,SAAsD;IAExE,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CA6DT"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IAC1C,MAAM,CAAC,WAAW,SAAsD;IAExE,MAAM,CAAC,IAAI,KAAM;IAEjB,MAAM,CAAC,KAAK;;;;MAEV;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEI,GAAG;CAiET"}
@@ -31,6 +31,7 @@ const pathLib = __importStar(require("path"));
31
31
  const fse = __importStar(require("fs-extra"));
32
32
  const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
33
33
  const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
34
+ const region_1 = require("../../utils/region");
34
35
  const test_1 = __importDefault(require("../connector/test"));
35
36
  const build_1 = __importDefault(require("../connector/build"));
36
37
  const colorizeString_1 = require("../../utils/colorizeString");
@@ -38,11 +39,13 @@ const check_env_1 = require("../../utils/check-env");
38
39
  class Create extends core_1.Command {
39
40
  static description = 'Creates a new deployment for a connector project';
40
41
  static args = {};
41
- connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
42
- baseUrl: process.env.TRAY_API_URL,
43
- }, new AxiosHttpClient_1.AxiosHttpClient());
42
+ static flags = {
43
+ ...region_1.regionFlags,
44
+ };
45
+ regionHandler = new region_1.RegionHandler(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
44
46
  async run() {
45
- (0, check_env_1.checkEnv)();
47
+ (0, check_env_1.checkTokenEnv)();
48
+ const { flags } = await this.parse(Create);
46
49
  await test_1.default.run([]);
47
50
  await build_1.default.run([]);
48
51
  const currentDirectory = process.cwd();
@@ -61,7 +64,9 @@ class Create extends core_1.Command {
61
64
  token: TRAY_API_TOKEN,
62
65
  };
63
66
  core_1.ux.action.start('Creating Connector Deployment');
64
- const response = await this.connectorDeployment.deployFromSourceCode(input);
67
+ const response = await this.regionHandler
68
+ .invoke(flags)
69
+ .deployFromSourceCode(input);
65
70
  if (response.isSuccess) {
66
71
  const { id } = response.value;
67
72
  if (response.value.repeatDeployment === true) {
@@ -88,4 +88,23 @@ describe('Create', () => {
88
88
  expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
89
89
  expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('There was an error creating the deployment.'));
90
90
  });
91
+ it('should set baseUrl based on region flag', async () => {
92
+ jest.mock('@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient');
93
+ await create_1.default.run([]);
94
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
95
+ baseUrl: 'https://api.tray.io',
96
+ }, expect.anything());
97
+ await create_1.default.run(['--us']);
98
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
99
+ baseUrl: 'https://api.tray.io',
100
+ }, expect.anything());
101
+ await create_1.default.run(['--eu']);
102
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
103
+ baseUrl: 'https://api.eu1.tray.io',
104
+ }, expect.anything());
105
+ await create_1.default.run(['--ap']);
106
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
107
+ baseUrl: 'https://api.ap1.tray.io',
108
+ }, expect.anything());
109
+ });
91
110
  });
@@ -2,15 +2,18 @@ import { Command } from '@oclif/core';
2
2
  export default class Get extends Command {
3
3
  static description: string;
4
4
  static args: {
5
- connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
- connectorVersion: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
- uuid: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
+ connectorName: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
6
+ connectorVersion: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
7
+ uuid: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
8
8
  };
9
9
  static flags: {
10
- tail: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ us: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
11
+ eu: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
12
+ ap: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
13
+ tail: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
11
14
  };
12
15
  static examples: string[];
13
- private connectorDeployment;
16
+ private regionHandler;
14
17
  private generateConnectorDeploymentId;
15
18
  private pollConnectorDeploymentStatus;
16
19
  private getLocalConnectorInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAcvD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAAoD;IAEtE,MAAM,CAAC,IAAI;;;;MAiBT;IAEF,MAAM,CAAC,KAAK;;MAMV;IAEF,MAAM,CAAC,QAAQ,WAUb;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEF,OAAO,CAAC,6BAA6B,CAGmC;IAExE,OAAO,CAAC,6BAA6B,CA8BnC;IAEF,OAAO,CAAC,qBAAqB,CAe3B;IAEI,GAAG;CAsFT"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAiBvD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SAAoD;IAEtE,MAAM,CAAC,IAAI;;;;MAiBT;IAEF,MAAM,CAAC,KAAK;;;;;MAOV;IAEF,MAAM,CAAC,QAAQ,WAUb;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEF,OAAO,CAAC,6BAA6B,CAGmC;IAExE,OAAO,CAAC,6BAA6B,CAgCnC;IAEF,OAAO,CAAC,qBAAqB,CAe3B;IAEI,GAAG;CAuFT"}
@@ -30,6 +30,7 @@ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
30
30
  const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
31
31
  const ConnectorDeploymentApi_1 = require("@trayio/tray-api/connector/deployment/ConnectorDeploymentApi");
32
32
  const uuid_1 = require("uuid");
33
+ const region_1 = require("../../utils/region");
33
34
  const colorizeString_1 = require("../../utils/colorizeString");
34
35
  const check_env_1 = require("../../utils/check-env");
35
36
  class Get extends core_1.Command {
@@ -56,6 +57,7 @@ class Get extends core_1.Command {
56
57
  char: 't',
57
58
  description: 'Enables the command to run until the deployment is complete with either a success or failure.',
58
59
  }),
60
+ ...region_1.regionFlags,
59
61
  };
60
62
  static examples = [
61
63
  `<%= config.bin %> <%= command.id %>`,
@@ -68,24 +70,22 @@ class Get extends core_1.Command {
68
70
  `<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 --tail`,
69
71
  `<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 -t`,
70
72
  ];
71
- connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
72
- baseUrl: process.env.TRAY_API_URL,
73
- }, new AxiosHttpClient_1.AxiosHttpClient());
73
+ regionHandler = new region_1.RegionHandler(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
74
74
  generateConnectorDeploymentId = (connectorName, connectorVersion) => (0, uuid_1.v5)(`${connectorName}-${connectorVersion}`, uuid_1.v5.URL);
75
- pollConnectorDeploymentStatus = async (connectorName, connectorVersion, id, token) => {
75
+ pollConnectorDeploymentStatus = async (connectorName, connectorVersion, id, token, flags) => {
76
76
  const input = {
77
77
  connectorName,
78
78
  connectorVersion,
79
79
  id,
80
80
  token,
81
81
  };
82
- const response = await this.connectorDeployment.get(input);
82
+ const response = await this.regionHandler.invoke(flags).get(input);
83
83
  if (response.isSuccess &&
84
84
  response.value.deploymentStatus === ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying) {
85
85
  await new Promise((resolve) => {
86
86
  setTimeout(resolve, 5000);
87
87
  });
88
- return this.pollConnectorDeploymentStatus(connectorName, connectorVersion, id, token);
88
+ return this.pollConnectorDeploymentStatus(connectorName, connectorVersion, id, token, flags);
89
89
  }
90
90
  return response;
91
91
  };
@@ -104,7 +104,7 @@ class Get extends core_1.Command {
104
104
  }
105
105
  };
106
106
  async run() {
107
- (0, check_env_1.checkEnv)();
107
+ (0, check_env_1.checkTokenEnv)();
108
108
  const { args, flags } = await this.parse(Get);
109
109
  const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
110
110
  if (!args.connectorName || !args.connectorVersion) {
@@ -124,11 +124,11 @@ class Get extends core_1.Command {
124
124
  let response;
125
125
  if (flags.tail) {
126
126
  core_1.ux.action.start(`Checking the connector deployment status with tailing`);
127
- response = await this.pollConnectorDeploymentStatus(input.connectorName, input.connectorVersion, input.id, input.token);
127
+ response = await this.pollConnectorDeploymentStatus(input.connectorName, input.connectorVersion, input.id, input.token, flags);
128
128
  }
129
129
  else {
130
130
  core_1.ux.action.start(`Checking the connector deployment status`);
131
- response = await this.connectorDeployment.get(input);
131
+ response = await this.regionHandler.invoke(flags).get(input);
132
132
  }
133
133
  core_1.ux.action.stop();
134
134
  if (response.isSuccess) {
@@ -107,4 +107,23 @@ describe('GetDeploymentStatus', () => {
107
107
  expect(uxStartSpy.mock.calls[1][0]).toEqual('Checking the connector deployment status');
108
108
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
109
109
  });
110
+ it('should set baseUrl based on region flag', async () => {
111
+ jest.mock('@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient');
112
+ await get_1.default.run([]);
113
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
114
+ baseUrl: 'https://api.tray.io',
115
+ }, expect.anything());
116
+ await get_1.default.run(['--us']);
117
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
118
+ baseUrl: 'https://api.tray.io',
119
+ }, expect.anything());
120
+ await get_1.default.run(['--eu']);
121
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
122
+ baseUrl: 'https://api.eu1.tray.io',
123
+ }, expect.anything());
124
+ await get_1.default.run(['--ap']);
125
+ expect(ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient).toHaveBeenCalledWith({
126
+ baseUrl: 'https://api.ap1.tray.io',
127
+ }, expect.anything());
128
+ });
110
129
  });
@@ -3,13 +3,16 @@ export default class Add extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static args: {
6
- connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
- connectorVersion: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ connectorName: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
7
+ connectorVersion: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
8
8
  };
9
9
  static flags: {
10
- email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ us: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
11
+ eu: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
12
+ ap: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
13
+ email: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
14
  };
12
- private connectorPermissions;
15
+ private regionHandler;
13
16
  run(): Promise<void>;
14
17
  private handleShareByEmail;
15
18
  private handleShareByWorkspace;
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/commands/permissions/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAa,MAAM,aAAa,CAAC;AAWvD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAQb;IAEF,MAAM,CAAC,IAAI;;;MAWT;IAEF,MAAM,CAAC,KAAK;;MAYV;IAEF,OAAO,CAAC,oBAAoB,CAK1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YA4EnB,kBAAkB;YA+BlB,sBAAsB;IAoCpC,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,eAAe;CAGvB"}
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/commands/permissions/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAa,MAAM,aAAa,CAAC;AAevD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAQb;IAEF,MAAM,CAAC,IAAI;;;MAWT;IAEF,MAAM,CAAC,KAAK;;;;;MAaV;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAgFnB,kBAAkB;YAkClB,sBAAsB;IAuCpC,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,eAAe;CAGvB"}
@@ -7,6 +7,8 @@ const core_1 = require("@oclif/core");
7
7
  const inquirer_1 = __importDefault(require("inquirer"));
8
8
  const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
9
9
  const ConnectorPermissionsHttpClient_1 = require("@trayio/tray-client/connector/permissions/ConnectorPermissionsHttpClient");
10
+ const region_1 = require("../../utils/region");
11
+ const check_env_1 = require("../../utils/check-env");
10
12
  const colorizeString_1 = require("../../utils/colorizeString");
11
13
  /*
12
14
  * Note: the workspaces feature is commented due to security concerns
@@ -41,6 +43,7 @@ class Add extends core_1.Command {
41
43
  aliases: ['emails', 'email'],
42
44
  description: 'Share with users by providing a list of emails',
43
45
  }),
46
+ ...region_1.regionFlags,
44
47
  // workspaces: Flags.string({
45
48
  // char: 'w',
46
49
  // aliases: ['workspaces', 'workspace'],
@@ -48,10 +51,9 @@ class Add extends core_1.Command {
48
51
  // 'Share with the emails of users in a workspace by providing a list of workspace IDs',
49
52
  // }),
50
53
  };
51
- connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
52
- baseUrl: process.env.TRAY_API_URL,
53
- }, new AxiosHttpClient_1.AxiosHttpClient());
54
+ regionHandler = new region_1.RegionHandler(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
54
55
  async run() {
56
+ (0, check_env_1.checkTokenEnv)();
55
57
  const { args, flags } = await this.parse(Add);
56
58
  const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
57
59
  const promptRes = await inquirer_1.default.prompt([
@@ -103,20 +105,21 @@ class Add extends core_1.Command {
103
105
  // error('Please provide either emails or workspace IDs, not both')
104
106
  // );
105
107
  if (emails) {
106
- this.handleShareByEmail(connectorName, connectorVersion, TRAY_API_TOKEN, emails);
108
+ this.handleShareByEmail(connectorName, connectorVersion, TRAY_API_TOKEN, emails, flags);
107
109
  // } else if (workspaceIds && !emails) {
108
110
  // this.handleShareByWorkspace(
109
111
  // connectorName,
110
112
  // connectorVersion,
111
113
  // TRAY_API_TOKEN,
112
- // workspaceIds
114
+ // workspaceIds,
115
+ // flags
113
116
  // );
114
117
  }
115
118
  else {
116
119
  this.log((0, colorizeString_1.error)('Please provide at least 1 email.'));
117
120
  }
118
121
  }
119
- async handleShareByEmail(connectorName, connectorVersion, token, emails) {
122
+ async handleShareByEmail(connectorName, connectorVersion, token, emails, flags) {
120
123
  core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails`);
121
124
  const input = {
122
125
  connectorName,
@@ -124,7 +127,9 @@ class Add extends core_1.Command {
124
127
  emails: this.splitList(emails),
125
128
  token,
126
129
  };
127
- const response = await this.connectorPermissions.shareWithEmails(input);
130
+ const response = await this.regionHandler
131
+ .invoke(flags)
132
+ .shareWithEmails(input);
128
133
  core_1.ux.action.stop();
129
134
  if (response.isSuccess) {
130
135
  this.log((0, colorizeString_1.success)(response.value.message));
@@ -134,7 +139,7 @@ class Add extends core_1.Command {
134
139
  this.log(response.error.message);
135
140
  }
136
141
  }
137
- async handleShareByWorkspace(connectorName, connectorVersion, token, workspaceIds) {
142
+ async handleShareByWorkspace(connectorName, connectorVersion, token, workspaceIds, flags) {
138
143
  core_1.ux.action.start(`Sharing ${connectorName} ${connectorVersion} with emails assigned to the given workspaces`);
139
144
  const input = {
140
145
  connectorName,
@@ -142,7 +147,9 @@ class Add extends core_1.Command {
142
147
  workspaceIds: this.splitList(workspaceIds),
143
148
  token,
144
149
  };
145
- const response = await this.connectorPermissions.shareWithWorkspaces(input);
150
+ const response = await this.regionHandler
151
+ .invoke(flags)
152
+ .shareWithWorkspaces(input);
146
153
  core_1.ux.action.stop();
147
154
  if (response.isSuccess) {
148
155
  this.log((0, colorizeString_1.success)(response.value.success.message));
@@ -78,6 +78,39 @@ describe('Share', () => {
78
78
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Share By Email Failed, please try again or contact support'));
79
79
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`The connector (Left(some-connector-name~1.1)) was not found or you don't have permission to access it`));
80
80
  });
81
+ it('should set baseUrl based on region flag', async () => {
82
+ await add_1.default.run([connectorName, connectorVersion, `--emails='${emails}'`]);
83
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
84
+ baseUrl: 'https://api.tray.io',
85
+ }, expect.anything());
86
+ await add_1.default.run([
87
+ connectorName,
88
+ connectorVersion,
89
+ `--emails='${emails}'`,
90
+ '--us',
91
+ ]);
92
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
93
+ baseUrl: 'https://api.tray.io',
94
+ }, expect.anything());
95
+ await add_1.default.run([
96
+ connectorName,
97
+ connectorVersion,
98
+ `--emails='${emails}'`,
99
+ '--eu',
100
+ ]);
101
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
102
+ baseUrl: 'https://api.eu1.tray.io',
103
+ }, expect.anything());
104
+ await add_1.default.run([
105
+ connectorName,
106
+ connectorVersion,
107
+ `--emails='${emails}'`,
108
+ '--ap',
109
+ ]);
110
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
111
+ baseUrl: 'https://api.ap1.tray.io',
112
+ }, expect.anything());
113
+ });
81
114
  // it('should log success message when connector is shared by workspaces and warn of empty workspaces', async () => {
82
115
  // success = true;
83
116
  // stdout.start();
@@ -6,8 +6,12 @@ export default class PermissionsList extends Command {
6
6
  connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
7
  connectorVersion: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
8
8
  };
9
- static flags: {};
10
- private connectorPermissions;
9
+ static flags: {
10
+ us: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ eu: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ ap: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ private regionHandler;
11
15
  run(): Promise<void>;
12
16
  }
13
17
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/permissions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAa,MAAM,aAAa,CAAC;AAOvD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAC4C;IAG9D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,IAAI;;;MAWT;IAEF,MAAM,CAAC,KAAK,KAYV;IAEF,OAAO,CAAC,oBAAoB,CAK1B;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoDjC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/permissions/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAa,MAAM,aAAa,CAAC;AASvD,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAC4C;IAG9D,MAAM,CAAC,QAAQ,WAIb;IAEF,MAAM,CAAC,IAAI;;;MAWT;IAEF,MAAM,CAAC,KAAK;;;;MAaV;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsDjC"}
@@ -9,6 +9,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
9
9
  const ConnectorPermissionsHttpClient_1 = require("@trayio/tray-client/connector/permissions/ConnectorPermissionsHttpClient");
10
10
  const check_env_1 = require("../../utils/check-env");
11
11
  const colorizeString_1 = require("../../utils/colorizeString");
12
+ const region_1 = require("../../utils/region");
12
13
  class PermissionsList extends core_1.Command {
13
14
  static description = 'Retrieves a list of emails that have access to a connector';
14
15
  // 'Retrieves a list of emails and workspaces that have access to a connector';
@@ -30,23 +31,22 @@ class PermissionsList extends core_1.Command {
30
31
  }),
31
32
  };
32
33
  static flags = {
33
- // email: Flags.string({
34
- // char: 'e',
35
- // aliases: ['emails', 'email'],
36
- // description: 'Retrieve a list of emails that have access to a connector',
37
- // }),
38
- // workspaces: Flags.string({
39
- // char: 'w',
40
- // aliases: ['workspaces', 'workspace'],
41
- // description:
42
- // 'Retrieve a list of workspace IDs that have access to a connector',
43
- // }),
34
+ ...region_1.regionFlags,
35
+ // email: Flags.string({
36
+ // char: 'e',
37
+ // aliases: ['emails', 'email'],
38
+ // description: 'Retrieve a list of emails that have access to a connector',
39
+ // }),
40
+ // workspaces: Flags.string({
41
+ // char: 'w',
42
+ // aliases: ['workspaces', 'workspace'],
43
+ // description:
44
+ // 'Retrieve a list of workspace IDs that have access to a connector',
45
+ // }),
44
46
  };
45
- connectorPermissions = new ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient({
46
- baseUrl: process.env.TRAY_API_URL,
47
- }, new AxiosHttpClient_1.AxiosHttpClient());
47
+ regionHandler = new region_1.RegionHandler(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
48
48
  async run() {
49
- (0, check_env_1.checkEnv)();
49
+ (0, check_env_1.checkTokenEnv)();
50
50
  const { args, flags } = await this.parse(PermissionsList);
51
51
  const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
52
52
  const promptRes = await inquirer_1.default.prompt([
@@ -76,7 +76,9 @@ class PermissionsList extends core_1.Command {
76
76
  token: TRAY_API_TOKEN,
77
77
  };
78
78
  core_1.ux.action.start(`Checking the connector deployment status`);
79
- const response = await this.connectorPermissions.listSharedEmails(input);
79
+ const response = await this.regionHandler
80
+ .invoke(flags)
81
+ .listSharedEmails(input);
80
82
  core_1.ux.action.stop();
81
83
  if (response.isSuccess) {
82
84
  this.log((0, colorizeString_1.success)(`Success! These are the emails that have access to ${input.connectorName}:`));
@@ -51,4 +51,22 @@ describe('PermissionsList', () => {
51
51
  stdout_stderr_1.stdout.stop();
52
52
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`There was an error when listing connector permissions.`));
53
53
  });
54
+ it('should set baseUrl based on region flag', async () => {
55
+ await list_1.default.run([connectorName, connectorVersion]);
56
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
57
+ baseUrl: 'https://api.tray.io',
58
+ }, expect.anything());
59
+ await list_1.default.run([connectorName, connectorVersion, '--us']);
60
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
61
+ baseUrl: 'https://api.tray.io',
62
+ }, expect.anything());
63
+ await list_1.default.run([connectorName, connectorVersion, '--eu']);
64
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
65
+ baseUrl: 'https://api.eu1.tray.io',
66
+ }, expect.anything());
67
+ await list_1.default.run([connectorName, connectorVersion, '--ap']);
68
+ expect(ConnectorPermissionsHttpClient_1.ConnectorPermissionsHttpClient).toHaveBeenCalledWith({
69
+ baseUrl: 'https://api.ap1.tray.io',
70
+ }, expect.anything());
71
+ });
54
72
  });
@@ -1,2 +1,3 @@
1
- export declare const checkEnv: () => void;
1
+ export declare const checkTokenEnv: () => void;
2
+ export declare const checkApiUrlEnv: () => void;
2
3
  //# sourceMappingURL=check-env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-env.d.ts","sourceRoot":"","sources":["../../src/utils/check-env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,YAIpB,CAAC"}
1
+ {"version":3,"file":"check-env.d.ts","sourceRoot":"","sources":["../../src/utils/check-env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAGzB,CAAC;AAEF,eAAO,MAAM,cAAc,YAG1B,CAAC"}
@@ -1,27 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkEnv = void 0;
4
- const checkEnv = () => {
5
- checkMissingEnv();
6
- isApiUrlValid();
3
+ exports.checkApiUrlEnv = exports.checkTokenEnv = void 0;
4
+ const checkTokenEnv = () => {
5
+ checkMissingTokenEnv();
7
6
  isValidApiToken();
8
7
  };
9
- exports.checkEnv = checkEnv;
10
- const checkMissingEnv = () => {
11
- if (!process.env.TRAY_API_URL) {
12
- throw new Error('required env TRAY_API_URL is not set');
13
- }
8
+ exports.checkTokenEnv = checkTokenEnv;
9
+ const checkApiUrlEnv = () => {
10
+ checkMissingApiUrlEnv();
11
+ isApiUrlValid();
12
+ };
13
+ exports.checkApiUrlEnv = checkApiUrlEnv;
14
+ const checkMissingTokenEnv = () => {
14
15
  if (!process.env.TRAY_API_TOKEN) {
15
16
  throw new Error('required env TRAY_API_TOKEN is not set');
16
17
  }
17
18
  };
18
- const isApiUrlValid = () => {
19
- const apiUrl = process.env.TRAY_API_URL;
20
- const validApiUrlRegex = /^https:\/\/api\.(?:ap1\.|eu1\.|staging\.)?tray\.io$/;
21
- if (!validApiUrlRegex.test(apiUrl)) {
22
- throw new Error(`TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io`);
23
- }
24
- };
25
19
  const isValidApiToken = () => {
26
20
  let apiToken = process.env.TRAY_API_TOKEN;
27
21
  if (apiToken.includes('Bearer ') || apiToken.includes('bearer ')) {
@@ -33,3 +27,15 @@ const isValidApiToken = () => {
33
27
  throw new Error(`TRAY_API_TOKEN is in a invalid format.`);
34
28
  }
35
29
  };
30
+ const checkMissingApiUrlEnv = () => {
31
+ if (!process.env.TRAY_API_URL) {
32
+ throw new Error('required env TRAY_API_URL is not set, or use the --us, --eu, or --ap region flags');
33
+ }
34
+ };
35
+ const isApiUrlValid = () => {
36
+ const apiUrl = process.env.TRAY_API_URL;
37
+ const validApiUrlRegex = /^https:\/\/api\.(?:ap1\.|eu1\.|staging\.)?tray\.io$/;
38
+ if (!validApiUrlRegex.test(apiUrl)) {
39
+ throw new Error(`TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io. Or use the --us, --eu, or --ap region flags`);
40
+ }
41
+ };
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const check_env_1 = require("./check-env");
4
- describe('checkEnv', () => {
5
- const subject = check_env_1.checkEnv;
4
+ describe('checkTokenEnv', () => {
5
+ const subject = check_env_1.checkTokenEnv;
6
6
  const { env } = process;
7
7
  afterEach(() => {
8
8
  process.env = env;
9
9
  });
10
- it('should throw an error if TRAY_API_URL is not set', () => {
11
- process.env = { TRAY_API_URL: undefined };
12
- expect(() => subject()).toThrowError('required env TRAY_API_URL is not set');
13
- });
14
10
  it('should throw an error if TRAY_API_TOKEN is not set', () => {
15
11
  process.env = {
16
12
  TRAY_API_URL: 'https://api.tray.io',
@@ -18,13 +14,6 @@ describe('checkEnv', () => {
18
14
  };
19
15
  expect(() => subject()).toThrowError('required env TRAY_API_TOKEN is not set');
20
16
  });
21
- it('should throw an error if TRAY_API_URL is invalid', () => {
22
- process.env = {
23
- TRAY_API_URL: 'https://api.tray.io/invalid',
24
- TRAY_API_TOKEN: 'random',
25
- };
26
- expect(() => subject()).toThrowError('TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io');
27
- });
28
17
  it('should remove bearer prefix if TRAY_API_TOKEN contains Bearer prefix', () => {
29
18
  process.env = {
30
19
  TRAY_API_URL: 'https://api.tray.io',
@@ -40,11 +29,34 @@ describe('checkEnv', () => {
40
29
  };
41
30
  expect(() => subject()).toThrowError('TRAY_API_TOKEN is in a invalid format.');
42
31
  });
43
- it('should not throw an error if TRAY_API_URL and TRAY_API_TOKEN are valid', () => {
32
+ it('should not throw an error if TRAY_API_TOKEN is valid', () => {
44
33
  process.env = {
45
- TRAY_API_URL: 'https://api.tray.io',
46
34
  TRAY_API_TOKEN: '1234567890123456789012345678901234567890123456789012345678901234',
47
35
  };
48
36
  expect(() => subject()).not.toThrowError();
49
37
  });
50
38
  });
39
+ describe('checkApiUrlEnv', () => {
40
+ const subject = check_env_1.checkApiUrlEnv;
41
+ const { env } = process;
42
+ afterEach(() => {
43
+ process.env = env;
44
+ });
45
+ it('should throw an error if TRAY_API_URL is not set', () => {
46
+ process.env = { TRAY_API_URL: undefined };
47
+ expect(() => subject()).toThrowError('required env TRAY_API_URL is not set');
48
+ });
49
+ it('should throw an error if TRAY_API_URL is invalid', () => {
50
+ process.env = {
51
+ TRAY_API_URL: 'https://api.tray.io/invalid',
52
+ TRAY_API_TOKEN: 'random',
53
+ };
54
+ expect(() => subject()).toThrowError('TRAY_API_URL is invalid. It should be one of the following: https://api.tray.io, https://api.ap1.tray.io, https://api.eu1.tray.io');
55
+ });
56
+ it('should not throw an error if TRAY_API_URL is valid', () => {
57
+ process.env = {
58
+ TRAY_API_URL: 'https://api.tray.io',
59
+ };
60
+ expect(() => subject()).not.toThrowError();
61
+ });
62
+ });
@@ -0,0 +1,20 @@
1
+ import { ParserInput } from '@oclif/core/lib/interfaces/parser';
2
+ import { HttpClient } from '@trayio/commons/src/http/HttpClient';
3
+ import { HttpConfig } from '@trayio/tray-client/src/base/BaseClient';
4
+ export declare const getBaseUrl: (flags: ParserInput['flags']) => string;
5
+ export declare const regionFlags: {
6
+ us: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
7
+ eu: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
8
+ ap: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
9
+ };
10
+ interface HttpImplementation<T> {
11
+ new (httpConfig: HttpConfig, httpClient: HttpClient): T;
12
+ }
13
+ export declare class RegionHandler<T> {
14
+ private readonly HttpImplementation;
15
+ private readonly httpClient;
16
+ constructor(HttpImplementation: HttpImplementation<T>, httpClient: HttpClient);
17
+ invoke(flags: ParserInput['flags']): T;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=region.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region.d.ts","sourceRoot":"","sources":["../../src/utils/region.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAGrE,eAAO,MAAM,UAAU,UAAW,WAAW,CAAC,OAAO,CAAC,KAAG,MAYxD,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAUvB,CAAC;AAEF,UAAU,kBAAkB,CAAC,CAAC;IAC7B,KAAK,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,CAAC;CACxD;AAED,qBAAa,aAAa,CAAC,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,EACzC,UAAU,EAAE,UAAU;IAGjC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC;CAIzC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegionHandler = exports.regionFlags = exports.getBaseUrl = void 0;
4
+ const core_1 = require("@oclif/core");
5
+ const check_env_1 = require("./check-env");
6
+ const getBaseUrl = (flags) => {
7
+ if (flags.us) {
8
+ return 'https://api.tray.io';
9
+ }
10
+ if (flags.eu) {
11
+ return 'https://api.eu1.tray.io';
12
+ }
13
+ if (flags.ap) {
14
+ return 'https://api.ap1.tray.io';
15
+ }
16
+ (0, check_env_1.checkApiUrlEnv)();
17
+ return process.env.TRAY_API_URL;
18
+ };
19
+ exports.getBaseUrl = getBaseUrl;
20
+ exports.regionFlags = {
21
+ us: core_1.Flags.boolean({
22
+ description: 'Use the Tray US region',
23
+ }),
24
+ eu: core_1.Flags.boolean({
25
+ description: 'Use the Tray EU region',
26
+ }),
27
+ ap: core_1.Flags.boolean({
28
+ description: 'Use the Tray APAC region',
29
+ }),
30
+ };
31
+ class RegionHandler {
32
+ HttpImplementation;
33
+ httpClient;
34
+ constructor(HttpImplementation, httpClient) {
35
+ this.HttpImplementation = HttpImplementation;
36
+ this.httpClient = httpClient;
37
+ }
38
+ invoke(flags) {
39
+ const baseUrl = (0, exports.getBaseUrl)(flags);
40
+ return new this.HttpImplementation({ baseUrl }, this.httpClient);
41
+ }
42
+ }
43
+ exports.RegionHandler = RegionHandler;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=region.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"region.unit.test.d.ts","sourceRoot":"","sources":["../../src/utils/region.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
4
+ const region_1 = require("./region");
5
+ class HttpImplementationStub {
6
+ httpConfig;
7
+ httpClient;
8
+ constructor(httpConfig, httpClient) {
9
+ this.httpConfig = httpConfig;
10
+ this.httpClient = httpClient;
11
+ }
12
+ get() {
13
+ return this.httpConfig.baseUrl;
14
+ }
15
+ }
16
+ describe('RegionHandler', () => {
17
+ it('should use TRAY_API_URL env var when passed no flag', () => {
18
+ process.env = {
19
+ TRAY_API_URL: 'https://api.tray.io',
20
+ };
21
+ const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
22
+ const result = regionHandler.invoke({}).get();
23
+ expect(result).toEqual('https://api.tray.io');
24
+ });
25
+ it('should throw an error when passed no flag and TRAY_API_URL env var is not set', () => {
26
+ process.env = {
27
+ TRAY_API_URL: '',
28
+ };
29
+ const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
30
+ expect(() => regionHandler.invoke({}).get()).toThrowError('required env TRAY_API_URL is not set, or use the --us, --eu, or --ap region flags');
31
+ });
32
+ it('should use US baseUrl when passed us flag', () => {
33
+ const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
34
+ const flags = { us: true };
35
+ const result = regionHandler.invoke(flags).get();
36
+ expect(result).toEqual('https://api.tray.io');
37
+ });
38
+ it('should use EU baseUrl when passed eu flag', () => {
39
+ const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
40
+ const flags = { eu: true };
41
+ const result = regionHandler.invoke(flags).get();
42
+ expect(result).toEqual('https://api.eu1.tray.io');
43
+ });
44
+ it('should use AP baseUrl when passed ap flag', () => {
45
+ const regionHandler = new region_1.RegionHandler(HttpImplementationStub, new AxiosHttpClient_1.AxiosHttpClient());
46
+ const flags = { ap: true };
47
+ const result = regionHandler.invoke(flags).get();
48
+ expect(result).toEqual('https://api.ap1.tray.io');
49
+ });
50
+ });
@@ -180,7 +180,26 @@
180
180
  "aliases": [],
181
181
  "args": {},
182
182
  "description": "Creates a new deployment for a connector project",
183
- "flags": {},
183
+ "flags": {
184
+ "us": {
185
+ "description": "Use the Tray US region",
186
+ "name": "us",
187
+ "allowNo": false,
188
+ "type": "boolean"
189
+ },
190
+ "eu": {
191
+ "description": "Use the Tray EU region",
192
+ "name": "eu",
193
+ "allowNo": false,
194
+ "type": "boolean"
195
+ },
196
+ "ap": {
197
+ "description": "Use the Tray APAC region",
198
+ "name": "ap",
199
+ "allowNo": false,
200
+ "type": "boolean"
201
+ }
202
+ },
184
203
  "hasDynamicHelp": false,
185
204
  "hiddenAliases": [],
186
205
  "id": "deployment:create",
@@ -235,6 +254,24 @@
235
254
  "name": "tail",
236
255
  "allowNo": false,
237
256
  "type": "boolean"
257
+ },
258
+ "us": {
259
+ "description": "Use the Tray US region",
260
+ "name": "us",
261
+ "allowNo": false,
262
+ "type": "boolean"
263
+ },
264
+ "eu": {
265
+ "description": "Use the Tray EU region",
266
+ "name": "eu",
267
+ "allowNo": false,
268
+ "type": "boolean"
269
+ },
270
+ "ap": {
271
+ "description": "Use the Tray APAC region",
272
+ "name": "ap",
273
+ "allowNo": false,
274
+ "type": "boolean"
238
275
  }
239
276
  },
240
277
  "hasDynamicHelp": false,
@@ -287,6 +324,24 @@
287
324
  "hasDynamicHelp": false,
288
325
  "multiple": false,
289
326
  "type": "option"
327
+ },
328
+ "us": {
329
+ "description": "Use the Tray US region",
330
+ "name": "us",
331
+ "allowNo": false,
332
+ "type": "boolean"
333
+ },
334
+ "eu": {
335
+ "description": "Use the Tray EU region",
336
+ "name": "eu",
337
+ "allowNo": false,
338
+ "type": "boolean"
339
+ },
340
+ "ap": {
341
+ "description": "Use the Tray APAC region",
342
+ "name": "ap",
343
+ "allowNo": false,
344
+ "type": "boolean"
290
345
  }
291
346
  },
292
347
  "hasDynamicHelp": false,
@@ -325,7 +380,26 @@
325
380
  "<%= config.bin %> <%= command.id %> my-connector",
326
381
  "<%= config.bin %> <%= command.id %> my-connector 1.0"
327
382
  ],
328
- "flags": {},
383
+ "flags": {
384
+ "us": {
385
+ "description": "Use the Tray US region",
386
+ "name": "us",
387
+ "allowNo": false,
388
+ "type": "boolean"
389
+ },
390
+ "eu": {
391
+ "description": "Use the Tray EU region",
392
+ "name": "eu",
393
+ "allowNo": false,
394
+ "type": "boolean"
395
+ },
396
+ "ap": {
397
+ "description": "Use the Tray APAC region",
398
+ "name": "ap",
399
+ "allowNo": false,
400
+ "type": "boolean"
401
+ }
402
+ },
329
403
  "hasDynamicHelp": false,
330
404
  "hiddenAliases": [],
331
405
  "id": "permissions:list",
@@ -343,5 +417,5 @@
343
417
  ]
344
418
  }
345
419
  },
346
- "version": "4.11.1-unstable"
420
+ "version": "4.12.0"
347
421
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "4.11.1-unstable",
3
+ "version": "4.12.0",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -20,12 +20,12 @@
20
20
  "@oclif/plugin-plugins": "^5",
21
21
  "@oclif/plugin-version": "2.0.11",
22
22
  "@oclif/test": "3.1.12",
23
- "@trayio/axios": "4.11.1-unstable",
24
- "@trayio/cdk-build": "4.11.1-unstable",
25
- "@trayio/commons": "4.11.1-unstable",
26
- "@trayio/generator": "4.11.1-unstable",
27
- "@trayio/tray-client": "4.11.1-unstable",
28
- "@trayio/tray-openapi": "4.11.1-unstable",
23
+ "@trayio/axios": "4.12.0",
24
+ "@trayio/cdk-build": "4.12.0",
25
+ "@trayio/commons": "4.12.0",
26
+ "@trayio/generator": "4.12.0",
27
+ "@trayio/tray-client": "4.12.0",
28
+ "@trayio/tray-openapi": "4.12.0",
29
29
  "chalk": "4.1.2",
30
30
  "inquirer": "8.2.6"
31
31
  },