@trayio/cdk-cli 4.77.0 → 4.79.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.77.0 linux-x64 node-v18.20.7
22
+ @trayio/cdk-cli/4.79.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 create ORGID NAMESPACE`](#tray-cdk-namespace-create-orgid-namespace)
43
44
  * [`tray-cdk namespace get ORGID`](#tray-cdk-namespace-get-orgid)
44
45
  * [`tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-add-connectorname-connectorversion)
45
46
  * [`tray-cdk permissions list [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-list-connectorname-connectorversion)
@@ -257,6 +258,32 @@ DESCRIPTION
257
258
 
258
259
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
259
260
 
261
+ ## `tray-cdk namespace create ORGID NAMESPACE`
262
+
263
+ Creates a new connector namespace for your organization
264
+
265
+ ```
266
+ USAGE
267
+ $ tray-cdk namespace create ORGID NAMESPACE [--us] [--eu] [--ap]
268
+
269
+ ARGUMENTS
270
+ ORGID The ID of the organization for which to create the namespace
271
+ NAMESPACE The name of the namespace to create
272
+
273
+ FLAGS
274
+ --ap Use the Tray APAC region
275
+ --eu Use the Tray EU region
276
+ --us Use the Tray US region
277
+
278
+ DESCRIPTION
279
+ Creates a new connector namespace for your organization
280
+
281
+ EXAMPLES
282
+ $ tray-cdk namespace create org-id namespace
283
+
284
+ $ tray-cdk namespace create org-id namespace --us
285
+ ```
286
+
260
287
  ## `tray-cdk namespace get ORGID`
261
288
 
262
289
  Retrieves the connector namespace for your organization, if one exists
@@ -0,0 +1,17 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Create extends Command {
3
+ static description: string;
4
+ static args: {
5
+ orgId: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ namespace: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ us: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ eu: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ ap: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ static examples: string[];
14
+ private regionHandler;
15
+ run(): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/namespace/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAQvD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IAC1C,MAAM,CAAC,WAAW,SACyC;IAE3D,MAAM,CAAC,IAAI;;;MAYT;IAEF,MAAM,CAAC,KAAK;;;;MAEV;IAEF,MAAM,CAAC,QAAQ,WAGb;IAEF,OAAO,CAAC,aAAa,CAGnB;IAEI,GAAG;CAgDT"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const ConnectorNamespaceHttpClient_1 = require("@trayio/tray-client/connector/namespace/ConnectorNamespaceHttpClient");
5
+ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
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 Create extends core_1.Command {
10
+ static description = 'Creates a new connector namespace for your organization';
11
+ static args = {
12
+ orgId: core_1.Args.string({
13
+ name: 'Organization ID',
14
+ required: true,
15
+ description: 'The ID of the organization for which to create the namespace',
16
+ }),
17
+ namespace: core_1.Args.string({
18
+ name: 'Namespace',
19
+ required: true,
20
+ description: 'The name of the namespace to create',
21
+ }),
22
+ };
23
+ static flags = {
24
+ ...region_1.regionFlags,
25
+ };
26
+ static examples = [
27
+ `<%= config.bin %> <%= command.id %> org-id namespace`,
28
+ `<%= config.bin %> <%= command.id %> org-id namespace --us`,
29
+ ];
30
+ regionHandler = new region_1.RegionHandler(ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient, new AxiosHttpClient_1.AxiosHttpClient());
31
+ async run() {
32
+ const { args, flags } = await this.parse(Create);
33
+ const { orgId, namespace } = args;
34
+ (0, check_env_1.checkTokenEnv)();
35
+ const input = {
36
+ organizationId: orgId,
37
+ namespace,
38
+ token: process.env.TRAY_API_TOKEN,
39
+ };
40
+ core_1.ux.action.start(`Creating namespace...`);
41
+ const response = await this.regionHandler.invoke(flags).create(input);
42
+ core_1.ux.action.stop();
43
+ if (response.isSuccess) {
44
+ this.log((0, colorizeString_1.success)(`Namespace Added!\nOrganization: ${(0, colorizeString_1.info)(orgId)}\nNamespace: ${(0, colorizeString_1.info)(namespace)}`));
45
+ }
46
+ if (response.isFailure) {
47
+ if (response.error.message.includes('is already associated with a namespace')) {
48
+ this.log((0, colorizeString_1.error)(`A namespace already exists for organization '${orgId}', use the 'get' command to retrieve it.\n${(0, colorizeString_1.info)('If you would like to update your namespace, please contact Tray support.')}`));
49
+ }
50
+ else {
51
+ this.log((0, colorizeString_1.error)(`Failed to create namespace: ${response.error.message}`));
52
+ }
53
+ }
54
+ }
55
+ }
56
+ exports.default = Create;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=create.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.unit.test.d.ts","sourceRoot":"","sources":["../../../src/commands/namespace/create.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,66 @@
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 create_1 = __importDefault(require("./create"));
9
+ jest.mock('@trayio/tray-client/connector/namespace/ConnectorNamespaceHttpClient', () => ({
10
+ ConnectorNamespaceHttpClient: jest.fn(),
11
+ }));
12
+ describe('CreateNamespace', () => {
13
+ let success = true;
14
+ let failure = false;
15
+ let namespaceExists = false;
16
+ const orgId = 'some-org-id';
17
+ const namespace = 'some-namespace';
18
+ beforeEach(() => {
19
+ success = true;
20
+ failure = false;
21
+ ConnectorNamespaceHttpClient_1.ConnectorNamespaceHttpClient.mockImplementation(() => ({
22
+ create: jest.fn().mockReturnValue({
23
+ isSuccess: success,
24
+ ...(success && {
25
+ value: {
26
+ namespace,
27
+ },
28
+ }),
29
+ isFailure: failure,
30
+ ...(failure && {
31
+ error: {
32
+ message: namespaceExists
33
+ ? 'Organization org-id is already associated with a namespace: namespace'
34
+ : 'There was an error creating the namespace',
35
+ },
36
+ }),
37
+ }),
38
+ }));
39
+ });
40
+ afterAll(() => {
41
+ jest.clearAllMocks();
42
+ });
43
+ it('should log success message when namespace is created', async () => {
44
+ stdout_stderr_1.stdout.start();
45
+ await create_1.default.run([orgId, namespace]);
46
+ stdout_stderr_1.stdout.stop();
47
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`Namespace Added!\nOrganization: ${orgId}\nNamespace: ${namespace}`));
48
+ });
49
+ it('should log error message when namespace creation fails', async () => {
50
+ success = false;
51
+ failure = true;
52
+ stdout_stderr_1.stdout.start();
53
+ await create_1.default.run([orgId, namespace]);
54
+ stdout_stderr_1.stdout.stop();
55
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Failed to create namespace: There was an error creating the namespace'));
56
+ });
57
+ it('should log error message when namespace already exists', async () => {
58
+ success = false;
59
+ failure = true;
60
+ namespaceExists = true;
61
+ stdout_stderr_1.stdout.start();
62
+ await create_1.default.run([orgId, namespace]);
63
+ stdout_stderr_1.stdout.stop();
64
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining(`A namespace already exists for organization '${orgId}', use the 'get' command to retrieve it.\nIf you would like to update your namespace, please contact Tray support.`));
65
+ });
66
+ });
@@ -303,41 +303,76 @@
303
303
  "get.js"
304
304
  ]
305
305
  },
306
- "permissions:add": {
306
+ "namespace:create": {
307
307
  "aliases": [],
308
308
  "args": {
309
- "connectorName": {
310
- "description": "The name of the connector",
311
- "name": "connectorName",
312
- "required": false
309
+ "orgId": {
310
+ "description": "The ID of the organization for which to create the namespace",
311
+ "name": "orgId",
312
+ "required": true
313
313
  },
314
- "connectorVersion": {
315
- "description": "The version of the connector",
316
- "name": "connectorVersion",
317
- "required": false
314
+ "namespace": {
315
+ "description": "The name of the namespace to create",
316
+ "name": "namespace",
317
+ "required": true
318
318
  }
319
319
  },
320
- "description": "Share your connector version with other users in your organization",
320
+ "description": "Creates a new connector namespace for your organization",
321
321
  "examples": [
322
- "<%= config.bin %> <%= command.id %>",
323
- "<%= config.bin %> <%= command.id %> my-connector",
324
- "<%= config.bin %> <%= command.id %> my-connector 1.0",
325
- "<%= config.bin %> <%= command.id %> my-connector 1.0 --email=\"my.email@domain.com, your.email@domain.com\"",
326
- "<%= config.bin %> <%= command.id %> my-connector 1.0 -e=\"my.email@domain.com, your.email@domain.com\""
322
+ "<%= config.bin %> <%= command.id %> org-id namespace",
323
+ "<%= config.bin %> <%= command.id %> org-id namespace --us"
327
324
  ],
328
325
  "flags": {
329
- "email": {
330
- "aliases": [
331
- "emails",
332
- "email"
333
- ],
334
- "char": "e",
335
- "description": "Share with users by providing a list of emails",
336
- "name": "email",
337
- "hasDynamicHelp": false,
338
- "multiple": false,
339
- "type": "option"
326
+ "us": {
327
+ "description": "Use the Tray US region",
328
+ "name": "us",
329
+ "allowNo": false,
330
+ "type": "boolean"
340
331
  },
332
+ "eu": {
333
+ "description": "Use the Tray EU region",
334
+ "name": "eu",
335
+ "allowNo": false,
336
+ "type": "boolean"
337
+ },
338
+ "ap": {
339
+ "description": "Use the Tray APAC region",
340
+ "name": "ap",
341
+ "allowNo": false,
342
+ "type": "boolean"
343
+ }
344
+ },
345
+ "hasDynamicHelp": false,
346
+ "hiddenAliases": [],
347
+ "id": "namespace:create",
348
+ "pluginAlias": "@trayio/cdk-cli",
349
+ "pluginName": "@trayio/cdk-cli",
350
+ "pluginType": "core",
351
+ "strict": true,
352
+ "enableJsonFlag": false,
353
+ "isESM": false,
354
+ "relativePath": [
355
+ "dist",
356
+ "commands",
357
+ "namespace",
358
+ "create.js"
359
+ ]
360
+ },
361
+ "namespace:get": {
362
+ "aliases": [],
363
+ "args": {
364
+ "orgId": {
365
+ "description": "The ID of the organization you want to retrieve the namespace for",
366
+ "name": "orgId",
367
+ "required": true
368
+ }
369
+ },
370
+ "description": "Retrieves the connector namespace for your organization, if one exists",
371
+ "examples": [
372
+ "<%= config.bin %> <%= command.id %> some-org-id",
373
+ "<%= config.bin %> <%= command.id %> some-org-id --us"
374
+ ],
375
+ "flags": {
341
376
  "us": {
342
377
  "description": "Use the Tray US region",
343
378
  "name": "us",
@@ -359,7 +394,7 @@
359
394
  },
360
395
  "hasDynamicHelp": false,
361
396
  "hiddenAliases": [],
362
- "id": "permissions:add",
397
+ "id": "namespace:get",
363
398
  "pluginAlias": "@trayio/cdk-cli",
364
399
  "pluginName": "@trayio/cdk-cli",
365
400
  "pluginType": "core",
@@ -369,11 +404,11 @@
369
404
  "relativePath": [
370
405
  "dist",
371
406
  "commands",
372
- "permissions",
373
- "add.js"
407
+ "namespace",
408
+ "get.js"
374
409
  ]
375
410
  },
376
- "permissions:list": {
411
+ "permissions:add": {
377
412
  "aliases": [],
378
413
  "args": {
379
414
  "connectorName": {
@@ -387,13 +422,27 @@
387
422
  "required": false
388
423
  }
389
424
  },
390
- "description": "Retrieves a list of emails that have access to a connector",
425
+ "description": "Share your connector version with other users in your organization",
391
426
  "examples": [
392
427
  "<%= config.bin %> <%= command.id %>",
393
428
  "<%= config.bin %> <%= command.id %> my-connector",
394
- "<%= config.bin %> <%= command.id %> my-connector 1.0"
429
+ "<%= config.bin %> <%= command.id %> my-connector 1.0",
430
+ "<%= config.bin %> <%= command.id %> my-connector 1.0 --email=\"my.email@domain.com, your.email@domain.com\"",
431
+ "<%= config.bin %> <%= command.id %> my-connector 1.0 -e=\"my.email@domain.com, your.email@domain.com\""
395
432
  ],
396
433
  "flags": {
434
+ "email": {
435
+ "aliases": [
436
+ "emails",
437
+ "email"
438
+ ],
439
+ "char": "e",
440
+ "description": "Share with users by providing a list of emails",
441
+ "name": "email",
442
+ "hasDynamicHelp": false,
443
+ "multiple": false,
444
+ "type": "option"
445
+ },
397
446
  "us": {
398
447
  "description": "Use the Tray US region",
399
448
  "name": "us",
@@ -415,7 +464,7 @@
415
464
  },
416
465
  "hasDynamicHelp": false,
417
466
  "hiddenAliases": [],
418
- "id": "permissions:list",
467
+ "id": "permissions:add",
419
468
  "pluginAlias": "@trayio/cdk-cli",
420
469
  "pluginName": "@trayio/cdk-cli",
421
470
  "pluginType": "core",
@@ -426,22 +475,28 @@
426
475
  "dist",
427
476
  "commands",
428
477
  "permissions",
429
- "list.js"
478
+ "add.js"
430
479
  ]
431
480
  },
432
- "namespace:get": {
481
+ "permissions:list": {
433
482
  "aliases": [],
434
483
  "args": {
435
- "orgId": {
436
- "description": "The ID of the organization you want to retrieve the namespace for",
437
- "name": "orgId",
438
- "required": true
484
+ "connectorName": {
485
+ "description": "The name of the connector",
486
+ "name": "connectorName",
487
+ "required": false
488
+ },
489
+ "connectorVersion": {
490
+ "description": "The version of the connector",
491
+ "name": "connectorVersion",
492
+ "required": false
439
493
  }
440
494
  },
441
- "description": "Retrieves the connector namespace for your organization, if one exists",
495
+ "description": "Retrieves a list of emails that have access to a connector",
442
496
  "examples": [
443
- "<%= config.bin %> <%= command.id %> some-org-id",
444
- "<%= config.bin %> <%= command.id %> some-org-id --us"
497
+ "<%= config.bin %> <%= command.id %>",
498
+ "<%= config.bin %> <%= command.id %> my-connector",
499
+ "<%= config.bin %> <%= command.id %> my-connector 1.0"
445
500
  ],
446
501
  "flags": {
447
502
  "us": {
@@ -465,7 +520,7 @@
465
520
  },
466
521
  "hasDynamicHelp": false,
467
522
  "hiddenAliases": [],
468
- "id": "namespace:get",
523
+ "id": "permissions:list",
469
524
  "pluginAlias": "@trayio/cdk-cli",
470
525
  "pluginName": "@trayio/cdk-cli",
471
526
  "pluginType": "core",
@@ -475,10 +530,10 @@
475
530
  "relativePath": [
476
531
  "dist",
477
532
  "commands",
478
- "namespace",
479
- "get.js"
533
+ "permissions",
534
+ "list.js"
480
535
  ]
481
536
  }
482
537
  },
483
- "version": "4.77.0"
538
+ "version": "4.79.0"
484
539
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "4.77.0",
3
+ "version": "4.79.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.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",
25
+ "@trayio/axios": "4.79.0",
26
+ "@trayio/cdk-build": "4.79.0",
27
+ "@trayio/commons": "4.79.0",
28
+ "@trayio/generator": "4.79.0",
29
+ "@trayio/tray-client": "4.79.0",
30
+ "@trayio/tray-openapi": "4.79.0",
31
31
  "chalk": "4.1.2",
32
32
  "inquirer": "8.2.6"
33
33
  },