@trayio/cdk-cli 4.76.0 → 4.77.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.76.0 linux-x64 node-v18.20.7
22
+ @trayio/cdk-cli/4.77.0 linux-x64 node-v18.20.7
23
23
  $ tray-cdk --help [COMMAND]
24
24
  USAGE
25
25
  $ tray-cdk COMMAND
@@ -40,6 +40,7 @@ USAGE
40
40
  * [`tray-cdk deployment create`](#tray-cdk-deployment-create)
41
41
  * [`tray-cdk deployment get [CONNECTORNAME] [CONNECTORVERSION] [UUID]`](#tray-cdk-deployment-get-connectorname-connectorversion-uuid)
42
42
  * [`tray-cdk help [COMMAND]`](#tray-cdk-help-command)
43
+ * [`tray-cdk namespace get ORGID`](#tray-cdk-namespace-get-orgid)
43
44
  * [`tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-add-connectorname-connectorversion)
44
45
  * [`tray-cdk permissions list [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-list-connectorname-connectorversion)
45
46
  * [`tray-cdk plugins`](#tray-cdk-plugins)
@@ -256,6 +257,31 @@ DESCRIPTION
256
257
 
257
258
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
258
259
 
260
+ ## `tray-cdk namespace get ORGID`
261
+
262
+ Retrieves the connector namespace for your organization, if one exists
263
+
264
+ ```
265
+ USAGE
266
+ $ tray-cdk namespace get ORGID [--us] [--eu] [--ap]
267
+
268
+ ARGUMENTS
269
+ ORGID The ID of the organization you want to retrieve the namespace for
270
+
271
+ FLAGS
272
+ --ap Use the Tray APAC region
273
+ --eu Use the Tray EU region
274
+ --us Use the Tray US region
275
+
276
+ DESCRIPTION
277
+ Retrieves the connector namespace for your organization, if one exists
278
+
279
+ EXAMPLES
280
+ $ tray-cdk namespace get some-org-id
281
+
282
+ $ tray-cdk namespace get some-org-id --us
283
+ ```
284
+
259
285
  ## `tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION]`
260
286
 
261
287
  Share your connector version with other users in your organization
@@ -0,0 +1,16 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Get extends Command {
3
+ static description: string;
4
+ static args: {
5
+ orgId: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ us: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ eu: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ ap: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ static examples: string[];
13
+ private regionHandler;
14
+ run(): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/namespace/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AASvD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACvC,MAAM,CAAC,WAAW,SACwD;IAE1E,MAAM,CAAC,IAAI;;MAOT;IAEF,MAAM,CAAC,KAAK;;;;MAEV;IAEF,MAAM,CAAC,QAAQ,WAGb;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEI,GAAG;CA6CT"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
5
+ const ConnectorNamespaceHttpClient_1 = require("@trayio/tray-client/connector/namespace/ConnectorNamespaceHttpClient");
6
+ const region_1 = require("../../utils/region");
7
+ const colorizeString_1 = require("../../utils/colorizeString");
8
+ const check_env_1 = require("../../utils/check-env");
9
+ class Get extends core_1.Command {
10
+ static description = 'Retrieves the connector namespace for your organization, if one exists';
11
+ static args = {
12
+ orgId: core_1.Args.string({
13
+ name: 'Organization ID',
14
+ required: true,
15
+ description: 'The ID of the organization you want to retrieve the namespace for',
16
+ }),
17
+ };
18
+ static flags = {
19
+ ...region_1.regionFlags,
20
+ };
21
+ static examples = [
22
+ `<%= config.bin %> <%= command.id %> some-org-id`,
23
+ `<%= config.bin %> <%= command.id %> some-org-id --us`,
24
+ ];
25
+ regionHandler = new region_1.RegionHandler(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
26
+ async run() {
27
+ (0, check_env_1.checkTokenEnv)();
28
+ const { args, flags } = await this.parse(Get);
29
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
30
+ const input = {
31
+ organizationId: args.orgId,
32
+ token: TRAY_API_TOKEN,
33
+ };
34
+ core_1.ux.action.start(`Fetching namespace...`);
35
+ const response = await this.regionHandler.invoke(flags).get(input);
36
+ core_1.ux.action.stop();
37
+ if (response.isSuccess) {
38
+ this.log((0, colorizeString_1.success)(`Organization: ${(0, colorizeString_1.info)(args.orgId)}\nNamespace: ${(0, colorizeString_1.info)(response.value.namespace)}`));
39
+ }
40
+ if (response.isFailure) {
41
+ if (response.error.message.includes('Could not find namespace')) {
42
+ this.log((0, colorizeString_1.error)(`Namespace could not be found for organization: ${(0, colorizeString_1.info)(args.orgId)}`));
43
+ }
44
+ else {
45
+ this.log((0, colorizeString_1.error)(`There was an error retrieving the namespace, please try again or contact support`));
46
+ this.log(response.error.message);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ exports.default = Get;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.unit.test.d.ts","sourceRoot":"","sources":["../../../src/commands/namespace/get.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const stdout_stderr_1 = require("stdout-stderr");
7
+ const ConnectorNamespaceHttpClient_1 = require("@trayio/tray-client/connector/namespace/ConnectorNamespaceHttpClient");
8
+ const get_1 = __importDefault(require("./get"));
9
+ jest.mock('@trayio/tray-client/connector/namespace/ConnectorNamespaceHttpClient', () => ({
10
+ ConnectorNamespaceHttpClient: jest.fn(),
11
+ }));
12
+ describe('GetNamespace', () => {
13
+ let success = true;
14
+ let failure = false;
15
+ let notFound = false;
16
+ const orgId = 'some-org-id';
17
+ const namespace = 'some-namespace';
18
+ beforeEach(() => {
19
+ success = true;
20
+ failure = false;
21
+ notFound = false;
22
+ ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient.mockImplementation(() => ({
23
+ get: jest.fn().mockReturnValue({
24
+ isSuccess: success,
25
+ ...(success && {
26
+ value: {
27
+ namespace,
28
+ },
29
+ }),
30
+ isFailure: failure,
31
+ ...(failure && {
32
+ error: {
33
+ message: notFound
34
+ ? 'Could not find namespace'
35
+ : 'There was an error retrieving the namespace',
36
+ },
37
+ }),
38
+ }),
39
+ }));
40
+ });
41
+ afterAll(() => {
42
+ jest.clearAllMocks();
43
+ });
44
+ it('should log success message when namespace is retrieved', async () => {
45
+ stdout_stderr_1.stdout.start();
46
+ await get_1.default.run([orgId]);
47
+ stdout_stderr_1.stdout.stop();
48
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`Organization: ${orgId}\nNamespace: ${namespace}`));
49
+ });
50
+ it('should log error message when namespace retrieval fails', async () => {
51
+ success = false;
52
+ failure = true;
53
+ stdout_stderr_1.stdout.start();
54
+ await get_1.default.run([orgId]);
55
+ stdout_stderr_1.stdout.stop();
56
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('There was an error retrieving the namespace, please try again or contact support'));
57
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('There was an error retrieving the namespace'));
58
+ });
59
+ it('should log error message when namespace could not be found', async () => {
60
+ success = false;
61
+ failure = true;
62
+ notFound = true;
63
+ stdout_stderr_1.stdout.start();
64
+ await get_1.default.run([orgId]);
65
+ stdout_stderr_1.stdout.stop();
66
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`Namespace could not be found for organization: ${orgId}`));
67
+ });
68
+ it('should set baseUrl based on region flag', async () => {
69
+ await get_1.default.run([orgId]);
70
+ expect(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient).toHaveBeenCalledWith({
71
+ baseUrl: 'https://api.tray.io',
72
+ }, expect.anything());
73
+ await get_1.default.run([orgId, '--us']);
74
+ expect(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient).toHaveBeenCalledWith({
75
+ baseUrl: 'https://api.tray.io',
76
+ }, expect.anything());
77
+ await get_1.default.run([orgId, '--eu']);
78
+ expect(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient).toHaveBeenCalledWith({
79
+ baseUrl: 'https://api.eu1.tray.io',
80
+ }, expect.anything());
81
+ await get_1.default.run([orgId, '--ap']);
82
+ expect(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient).toHaveBeenCalledWith({
83
+ baseUrl: 'https://api.ap1.tray.io',
84
+ }, expect.anything());
85
+ });
86
+ });
@@ -428,7 +428,57 @@
428
428
  "permissions",
429
429
  "list.js"
430
430
  ]
431
+ },
432
+ "namespace:get": {
433
+ "aliases": [],
434
+ "args": {
435
+ "orgId": {
436
+ "description": "The ID of the organization you want to retrieve the namespace for",
437
+ "name": "orgId",
438
+ "required": true
439
+ }
440
+ },
441
+ "description": "Retrieves the connector namespace for your organization, if one exists",
442
+ "examples": [
443
+ "<%= config.bin %> <%= command.id %> some-org-id",
444
+ "<%= config.bin %> <%= command.id %> some-org-id --us"
445
+ ],
446
+ "flags": {
447
+ "us": {
448
+ "description": "Use the Tray US region",
449
+ "name": "us",
450
+ "allowNo": false,
451
+ "type": "boolean"
452
+ },
453
+ "eu": {
454
+ "description": "Use the Tray EU region",
455
+ "name": "eu",
456
+ "allowNo": false,
457
+ "type": "boolean"
458
+ },
459
+ "ap": {
460
+ "description": "Use the Tray APAC region",
461
+ "name": "ap",
462
+ "allowNo": false,
463
+ "type": "boolean"
464
+ }
465
+ },
466
+ "hasDynamicHelp": false,
467
+ "hiddenAliases": [],
468
+ "id": "namespace:get",
469
+ "pluginAlias": "@trayio/cdk-cli",
470
+ "pluginName": "@trayio/cdk-cli",
471
+ "pluginType": "core",
472
+ "strict": true,
473
+ "enableJsonFlag": false,
474
+ "isESM": false,
475
+ "relativePath": [
476
+ "dist",
477
+ "commands",
478
+ "namespace",
479
+ "get.js"
480
+ ]
431
481
  }
432
482
  },
433
- "version": "4.76.0"
483
+ "version": "4.77.0"
434
484
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "4.76.0",
3
+ "version": "4.77.0",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -22,12 +22,12 @@
22
22
  "@oclif/plugin-version": "2.0.11",
23
23
  "@oclif/plugin-warn-if-update-available": "^3.1.4",
24
24
  "@oclif/test": "3.1.12",
25
- "@trayio/axios": "4.76.0",
26
- "@trayio/cdk-build": "4.76.0",
27
- "@trayio/commons": "4.76.0",
28
- "@trayio/generator": "4.76.0",
29
- "@trayio/tray-client": "4.76.0",
30
- "@trayio/tray-openapi": "4.76.0",
25
+ "@trayio/axios": "4.77.0",
26
+ "@trayio/cdk-build": "4.77.0",
27
+ "@trayio/commons": "4.77.0",
28
+ "@trayio/generator": "4.77.0",
29
+ "@trayio/tray-client": "4.77.0",
30
+ "@trayio/tray-openapi": "4.77.0",
31
31
  "chalk": "4.1.2",
32
32
  "inquirer": "8.2.6"
33
33
  },