@contrail/cli 3.6.0-alpha-8-alpha.85a73d5 → 3.6.0-alpha.a5acc88
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 +26 -181
- package/dist/api/types.d.ts +0 -35
- package/dist/api/types.js +1 -49
- package/dist/auth/login.d.ts +4 -0
- package/dist/auth/login.js +115 -52
- package/dist/auth/login.spec.js +100 -0
- package/dist/auth/sso.d.ts +36 -0
- package/dist/auth/sso.js +174 -0
- package/dist/auth/sso.spec.js +148 -0
- package/dist/basecommand.js +2 -2
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/login.d.ts +12 -0
- package/dist/commands/login.js +25 -0
- package/dist/common.d.ts +1 -4
- package/dist/common.js +1 -18
- package/dist/helpers/config/config.d.ts +3 -3
- package/dist/helpers/config/config.js +3 -3
- package/dist/helpers/file-helpers.d.ts +0 -1
- package/dist/helpers/file-helpers.js +3 -20
- package/dist/logger.js +1 -4
- package/node_modules/@contrail/entity-compare/package.json +3 -6
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
- package/node_modules/@contrail/loader/lib/constants.js +9 -1
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +4 -1
- package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
- package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
- package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
- package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
- package/node_modules/@contrail/sdk/lib/index.d.ts +0 -1
- package/node_modules/@contrail/sdk/lib/index.js +0 -1
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/oclif.manifest.json +50 -449
- package/package.json +12 -5
- package/dist/commands/entities/create.d.ts +0 -50
- package/dist/commands/entities/create.js +0 -633
- package/dist/commands/entities/create.spec.js +0 -583
- package/dist/commands/entities/delete.d.ts +0 -20
- package/dist/commands/entities/delete.js +0 -140
- package/dist/commands/entities/get.d.ts +0 -25
- package/dist/commands/entities/get.js +0 -269
- package/dist/commands/entities/grammar.spec.d.ts +0 -1
- package/dist/commands/entities/grammar.spec.js +0 -79
- package/dist/commands/entities/output.spec.d.ts +0 -1
- package/dist/commands/entities/output.spec.js +0 -72
- package/dist/commands/entities/update.d.ts +0 -32
- package/dist/commands/entities/update.js +0 -161
- package/dist/helpers/entities/assortment-items.d.ts +0 -11
- package/dist/helpers/entities/assortment-items.js +0 -76
- package/dist/helpers/entities/batchFetch.d.ts +0 -8
- package/dist/helpers/entities/batchFetch.js +0 -49
- package/dist/helpers/entities/index.d.ts +0 -3
- package/dist/helpers/entities/index.js +0 -6
- package/dist/helpers/entities/items.d.ts +0 -6
- package/dist/helpers/entities/items.js +0 -56
- package/dist/helpers/entities/items.spec.d.ts +0 -1
- package/dist/helpers/entities/items.spec.js +0 -19
- package/dist/helpers/entities/project-items.d.ts +0 -2
- package/dist/helpers/entities/project-items.js +0 -44
- package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -34
- package/dist/helpers/propertySpecifications/dateRanges.js +0 -83
- package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +0 -1
- package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -91
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -39
- package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -102
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -387
- package/dist/logger.spec.d.ts +0 -1
- package/dist/logger.spec.js +0 -12
- package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +0 -34
- package/node_modules/@contrail/sdk/lib/image-search/image-search.js +0 -42
- package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +0 -1
- package/node_modules/@contrail/sdk/lib/image-search/index.js +0 -17
- package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
- /package/dist/{commands/entities/create.spec.d.ts → auth/sso.spec.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.6.0-alpha
|
|
20
|
+
@contrail/cli/3.6.0-alpha.a5acc88 linux-x64 node-v24.22.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -51,10 +51,6 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
51
51
|
* [`contrail config list`](#contrail-config-list)
|
|
52
52
|
* [`contrail config set`](#contrail-config-set)
|
|
53
53
|
* [`contrail config use [NAME]`](#contrail-config-use-name)
|
|
54
|
-
* [`contrail entities create TYPEPATH`](#contrail-entities-create-typepath)
|
|
55
|
-
* [`contrail entities delete ENTITYNAME [IDS]`](#contrail-entities-delete-entityname-ids)
|
|
56
|
-
* [`contrail entities get ENTITYNAME [IDS]`](#contrail-entities-get-entityname-ids)
|
|
57
|
-
* [`contrail entities update ENTITYNAME [IDS]`](#contrail-entities-update-entityname-ids)
|
|
58
54
|
* [`contrail feature-flags export`](#contrail-feature-flags-export)
|
|
59
55
|
* [`contrail feature-flags import`](#contrail-feature-flags-import)
|
|
60
56
|
* [`contrail file upload FILELOCATION CONTENTTYPE`](#contrail-file-upload-filelocation-contenttype)
|
|
@@ -67,6 +63,7 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
67
63
|
* [`contrail load custom-entity DATAFILE CONFIGFILE`](#contrail-load-custom-entity-datafile-configfile)
|
|
68
64
|
* [`contrail load line-sheet DATAFILE CONFIGFILE`](#contrail-load-line-sheet-datafile-configfile)
|
|
69
65
|
* [`contrail load upload-and-load INCOMINGFILE CONFIGFILENAME`](#contrail-load-upload-and-load-incomingfile-configfilename)
|
|
66
|
+
* [`contrail login`](#contrail-login)
|
|
70
67
|
* [`contrail org-config export`](#contrail-org-config-export)
|
|
71
68
|
* [`contrail org-config import`](#contrail-org-config-import)
|
|
72
69
|
* [`contrail projects export PROJECTNAME`](#contrail-projects-export-projectname)
|
|
@@ -543,182 +540,6 @@ EXAMPLES
|
|
|
543
540
|
$ contrail config use demo-org
|
|
544
541
|
```
|
|
545
542
|
|
|
546
|
-
## `contrail entities create TYPEPATH`
|
|
547
|
-
|
|
548
|
-
Create entities
|
|
549
|
-
|
|
550
|
-
```
|
|
551
|
-
USAGE
|
|
552
|
-
$ contrail entities create TYPEPATH [-l error|warn|info|debug] [-e true|false] [-n <value>] [-d] [-i <value>] [-o
|
|
553
|
-
<value>] [-g] [-r] [-S] [--suffix <value>] [--apiVersion 1|2]
|
|
554
|
-
|
|
555
|
-
ARGUMENTS
|
|
556
|
-
TYPEPATH The type path of the entity to create (e.g. color, custom-entity:franchise)
|
|
557
|
-
|
|
558
|
-
FLAGS
|
|
559
|
-
-S, --skipHydrateRelationships If true, does not hydrate relationships for the created entities
|
|
560
|
-
-d, --dryRun If true, does not create the entity but simulates the creation
|
|
561
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
562
|
-
<options: true|false>
|
|
563
|
-
-g, --generateValues If true, generates random values for properties that are not specified. By default,
|
|
564
|
-
only specified properties are used.
|
|
565
|
-
-i, --inputFile=<value> A file with a JSON array of objects where each object is one entity to create. Cannot
|
|
566
|
-
be used with --count. Unless --generateValues is specified, only the properties in
|
|
567
|
-
the file will be used.
|
|
568
|
-
-l, --logLevel=<option> The Log Level
|
|
569
|
-
<options: error|warn|info|debug>
|
|
570
|
-
-n, --count=<value> Number of random entities to create
|
|
571
|
-
-o, --outputFile=<value> File to save the output (optional)
|
|
572
|
-
-r, --readableIds If true, uses readable IDs for the created entities
|
|
573
|
-
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
574
|
-
<options: 1|2>
|
|
575
|
-
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
576
|
-
/<entities>/synchronous)
|
|
577
|
-
|
|
578
|
-
DESCRIPTION
|
|
579
|
-
Create entities
|
|
580
|
-
|
|
581
|
-
EXAMPLES
|
|
582
|
-
$ contrail entities create color -g -n=10 # creates 10 random colors
|
|
583
|
-
|
|
584
|
-
$ contrail entities create color -- name="Electric Blue" green=1 red=2 blue=3 # creates one color with specified properties only
|
|
585
|
-
|
|
586
|
-
$ contrail entities create custom-entities:franchise
|
|
587
|
-
|
|
588
|
-
$ contrail entities create project-item -n=1 -- projectId=abc # creates 10 project items within project ABC
|
|
589
|
-
|
|
590
|
-
$ contrail entities create color -g -r # creates a random color with a human readable ID
|
|
591
|
-
|
|
592
|
-
$ contrail entities create color -d -- name=test # simulates the creation of a color without actually creating it
|
|
593
|
-
|
|
594
|
-
$ contrail entities create custom-entity:franchise -s # creates an entity and the response does not contain hydrating relationships
|
|
595
|
-
|
|
596
|
-
$ contrail entities create color -g -- name=Electric Blue # creates a color with the name specified and other properties auto-generated
|
|
597
|
-
|
|
598
|
-
$ contrail entities create color -o /tmp/colors.json -- name=Blue green=1 red=2 blue=3 # creates a color and saves the output to /tmp/colors.json
|
|
599
|
-
```
|
|
600
|
-
|
|
601
|
-
## `contrail entities delete ENTITYNAME [IDS]`
|
|
602
|
-
|
|
603
|
-
Delete entities by id
|
|
604
|
-
|
|
605
|
-
```
|
|
606
|
-
USAGE
|
|
607
|
-
$ contrail entities delete ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-d] [-i <value>] [--suffix
|
|
608
|
-
<value>] [--apiVersion 1|2]
|
|
609
|
-
|
|
610
|
-
ARGUMENTS
|
|
611
|
-
ENTITYNAME The name of the entity type to delete (type paths are not supported)
|
|
612
|
-
IDS One or more entity ids to delete
|
|
613
|
-
|
|
614
|
-
FLAGS
|
|
615
|
-
-d, --dryRun If true, does not delete the entities but simulates the deletion
|
|
616
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
617
|
-
<options: true|false>
|
|
618
|
-
-i, --inputFile=<value> A file with a JSON array of objects; only each object's id is used. Deletes every
|
|
619
|
-
entity in the file.
|
|
620
|
-
-l, --logLevel=<option> The Log Level
|
|
621
|
-
<options: error|warn|info|debug>
|
|
622
|
-
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
623
|
-
<options: 1|2>
|
|
624
|
-
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
625
|
-
/<entities>/synchronous)
|
|
626
|
-
|
|
627
|
-
DESCRIPTION
|
|
628
|
-
Delete entities by id
|
|
629
|
-
|
|
630
|
-
EXAMPLES
|
|
631
|
-
$ contrail entities delete color 123
|
|
632
|
-
|
|
633
|
-
$ contrail entities delete color id1 id2 id3
|
|
634
|
-
|
|
635
|
-
$ contrail entities delete item -i ids.json
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
## `contrail entities get ENTITYNAME [IDS]`
|
|
639
|
-
|
|
640
|
-
Get an entity
|
|
641
|
-
|
|
642
|
-
```
|
|
643
|
-
USAGE
|
|
644
|
-
$ contrail entities get ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>]
|
|
645
|
-
[-P] [-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
|
|
646
|
-
|
|
647
|
-
ARGUMENTS
|
|
648
|
-
ENTITYNAME The name of the entity type to fetch (type paths are not supported)
|
|
649
|
-
IDS One or more entity ids; shorthand for the id/ids criteria
|
|
650
|
-
|
|
651
|
-
FLAGS
|
|
652
|
-
-P, --paginated If true, fetches all entities in a paginated manner
|
|
653
|
-
-S, --skipHydrateRelationships Skip hydrating relationships when fetching the entity
|
|
654
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
655
|
-
<options: true|false>
|
|
656
|
-
-l, --logLevel=<option> The Log Level
|
|
657
|
-
<options: error|warn|info|debug>
|
|
658
|
-
-o, --outputFile=<value> File to save the output (optional)
|
|
659
|
-
-p, --propertySlugs=<value> Comma-separated list of property slugs to include in the output
|
|
660
|
-
-r, --relations=<value> Comma-separated list of relations to include in the output
|
|
661
|
-
-s, --skip=<value> Number of entities to skip (used with paginated fetch)
|
|
662
|
-
-t, --take=<value> Number of entities to fetch in a single request (default is 100)
|
|
663
|
-
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
664
|
-
<options: 1|2>
|
|
665
|
-
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
666
|
-
/<entities>/synchronous)
|
|
667
|
-
|
|
668
|
-
DESCRIPTION
|
|
669
|
-
Get an entity
|
|
670
|
-
|
|
671
|
-
EXAMPLES
|
|
672
|
-
$ contrail entities get color 123
|
|
673
|
-
|
|
674
|
-
$ contrail entities get color id1 id2 id3
|
|
675
|
-
|
|
676
|
-
$ contrail entities get color -- id=123
|
|
677
|
-
|
|
678
|
-
$ contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16
|
|
679
|
-
|
|
680
|
-
$ contrail entities get orders -- updatedAt=2025-09-15T04:00:00Z..
|
|
681
|
-
|
|
682
|
-
$ contrail entities get events -- timestamp=..2025-09-16T23:59:59Z
|
|
683
|
-
```
|
|
684
|
-
|
|
685
|
-
## `contrail entities update ENTITYNAME [IDS]`
|
|
686
|
-
|
|
687
|
-
Update an entity
|
|
688
|
-
|
|
689
|
-
```
|
|
690
|
-
USAGE
|
|
691
|
-
$ contrail entities update ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-S] [-d] [-i <value>]
|
|
692
|
-
[--suffix <value>] [--apiVersion 1|2]
|
|
693
|
-
|
|
694
|
-
ARGUMENTS
|
|
695
|
-
ENTITYNAME The name of the entity type to update (type paths are not supported)
|
|
696
|
-
IDS One or more entity ids to update
|
|
697
|
-
|
|
698
|
-
FLAGS
|
|
699
|
-
-S, --skipHydrateRelationships Skip hydrating relationships when updating the entity
|
|
700
|
-
-d, --dryRun If true, does not update the entities but simulates the update
|
|
701
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
702
|
-
<options: true|false>
|
|
703
|
-
-i, --inputFile=<value> A file with a JSON array of {id, ...} objects; each object is one entity to update.
|
|
704
|
-
-l, --logLevel=<option> The Log Level
|
|
705
|
-
<options: error|warn|info|debug>
|
|
706
|
-
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
707
|
-
<options: 1|2>
|
|
708
|
-
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
709
|
-
/<entities>/synchronous)
|
|
710
|
-
|
|
711
|
-
DESCRIPTION
|
|
712
|
-
Update an entity
|
|
713
|
-
|
|
714
|
-
EXAMPLES
|
|
715
|
-
$ contrail entities update color 123 -- name=obsidian hex=000000
|
|
716
|
-
|
|
717
|
-
$ contrail entities update item id1 id2 id3 -- status=archived # apply the same change to several entities
|
|
718
|
-
|
|
719
|
-
$ contrail entities update color 123 -- description= notes='""' # Unset description, set notes to empty string
|
|
720
|
-
```
|
|
721
|
-
|
|
722
543
|
## `contrail feature-flags export`
|
|
723
544
|
|
|
724
545
|
Export the enabled feature flags for your Org
|
|
@@ -1008,6 +829,30 @@ EXAMPLES
|
|
|
1008
829
|
$ contrail load-processor upload-and-load <File Path> <Config Path>
|
|
1009
830
|
```
|
|
1010
831
|
|
|
832
|
+
## `contrail login`
|
|
833
|
+
|
|
834
|
+
Sign in to VibeIQ with SSO or your email and password
|
|
835
|
+
|
|
836
|
+
```
|
|
837
|
+
USAGE
|
|
838
|
+
$ contrail login [-l error|warn|info|debug] [-e true|false] [--browser]
|
|
839
|
+
|
|
840
|
+
FLAGS
|
|
841
|
+
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
842
|
+
<options: true|false>
|
|
843
|
+
-l, --logLevel=<option> The Log Level
|
|
844
|
+
<options: error|warn|info|debug>
|
|
845
|
+
--[no-]browser Open a browser for SSO. Use --no-browser to paste a sign-in code instead.
|
|
846
|
+
|
|
847
|
+
DESCRIPTION
|
|
848
|
+
Sign in to VibeIQ with SSO or your email and password
|
|
849
|
+
|
|
850
|
+
EXAMPLES
|
|
851
|
+
$ contrail login
|
|
852
|
+
|
|
853
|
+
$ contrail login --no-browser
|
|
854
|
+
```
|
|
855
|
+
|
|
1011
856
|
## `contrail org-config export`
|
|
1012
857
|
|
|
1013
858
|
Export the org config for your Org
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { TypeProperty as SDKTypeProperty } from '@contrail/types';
|
|
2
|
-
import { PropertyLevel, PropertyType, Type } from '@contrail/types';
|
|
3
1
|
export declare function getOptionSets(): Promise<any[]>;
|
|
4
2
|
export declare function getUserLists(): Promise<any[]>;
|
|
5
3
|
export declare function getOptionSetHierarchies(): Promise<any[]>;
|
|
@@ -8,36 +6,3 @@ export declare function getTypePropertyPolicies(): Promise<any[]>;
|
|
|
8
6
|
export declare function getTypePolicies(): Promise<any[]>;
|
|
9
7
|
export declare function getTypeOverrideCopies(): Promise<any[]>;
|
|
10
8
|
export declare function uploadTypeOverrideObjects(reducedOverrides: any): Promise<void>;
|
|
11
|
-
type ColonDelimitedHelper<S extends string> = S extends `${infer Head}:${infer Tail}` ? `${Head}:${ColonDelimitedHelper<Tail>}` : S;
|
|
12
|
-
export type ColonDelimited = ColonDelimitedHelper<string>;
|
|
13
|
-
export type TypeWithProperties = Type & {
|
|
14
|
-
typeProperties: TypeProperty[];
|
|
15
|
-
};
|
|
16
|
-
export interface Option {
|
|
17
|
-
value: string;
|
|
18
|
-
display: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface TypeProperty extends SDKTypeProperty {
|
|
22
|
-
propertyType?: PropertyType;
|
|
23
|
-
referencedTypePath?: string;
|
|
24
|
-
referencedTypeRootSlug?: string;
|
|
25
|
-
propertyLevel?: PropertyLevel;
|
|
26
|
-
}
|
|
27
|
-
export interface TypePropertyOptionSet {
|
|
28
|
-
id?: string;
|
|
29
|
-
orgId?: string;
|
|
30
|
-
name: string;
|
|
31
|
-
slug: string;
|
|
32
|
-
optionSet: Option[];
|
|
33
|
-
isArchived?: boolean;
|
|
34
|
-
}
|
|
35
|
-
export type TypeReferencesCacheByPath = Map<string, TypeWithProperties>;
|
|
36
|
-
export declare function getTypeByPath(path: ColonDelimited): Promise<TypeWithProperties>;
|
|
37
|
-
export declare function buildLocalTypesCache(paths: ColonDelimited[]): Promise<TypeReferencesCacheByPath>;
|
|
38
|
-
export declare function parseTypePath(path: ColonDelimited): {
|
|
39
|
-
root: string;
|
|
40
|
-
path: string;
|
|
41
|
-
};
|
|
42
|
-
export declare function getReferencedTypePaths(type: TypeWithProperties): ColonDelimited[];
|
|
43
|
-
export {};
|
package/dist/api/types.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.uploadTypeOverrideObjects = exports.getTypeOverrideCopies = exports.getTypePolicies = exports.getTypePropertyPolicies = exports.getRuleSets = exports.getOptionSetHierarchies = exports.getUserLists = exports.getOptionSets = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
|
-
const types_1 = require("@contrail/types");
|
|
6
5
|
async function getOptionSets() {
|
|
7
6
|
return await new sdk_1.Entities().get({
|
|
8
7
|
entityName: 'type-property-option-set',
|
|
@@ -59,50 +58,3 @@ async function uploadTypeOverrideObjects(reducedOverrides) {
|
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
exports.uploadTypeOverrideObjects = uploadTypeOverrideObjects;
|
|
62
|
-
const TYPES_CACHE_BY_PATH = new Map();
|
|
63
|
-
async function fetchTypeByPath(path) {
|
|
64
|
-
const { root } = parseTypePath(path);
|
|
65
|
-
const client = new sdk_1.Entities();
|
|
66
|
-
const type = await client.get({
|
|
67
|
-
entityName: 'type',
|
|
68
|
-
suffix: `roots/${root}/path/${path}`,
|
|
69
|
-
relations: ['typeProperties'],
|
|
70
|
-
});
|
|
71
|
-
return type;
|
|
72
|
-
}
|
|
73
|
-
async function getTypeByPath(path) {
|
|
74
|
-
if (TYPES_CACHE_BY_PATH.has(path)) {
|
|
75
|
-
return TYPES_CACHE_BY_PATH.get(path);
|
|
76
|
-
}
|
|
77
|
-
const type = await fetchTypeByPath(path);
|
|
78
|
-
TYPES_CACHE_BY_PATH.set(path, type);
|
|
79
|
-
return type;
|
|
80
|
-
}
|
|
81
|
-
exports.getTypeByPath = getTypeByPath;
|
|
82
|
-
async function buildLocalTypesCache(paths) {
|
|
83
|
-
const types = await Promise.all(paths.map((path) => getTypeByPath(path)));
|
|
84
|
-
const newCache = types.reduce((acc, type) => {
|
|
85
|
-
if (!type)
|
|
86
|
-
return acc;
|
|
87
|
-
acc.set(type.typePath, type);
|
|
88
|
-
return acc;
|
|
89
|
-
}, new Map());
|
|
90
|
-
return newCache;
|
|
91
|
-
}
|
|
92
|
-
exports.buildLocalTypesCache = buildLocalTypesCache;
|
|
93
|
-
function parseTypePath(path) {
|
|
94
|
-
const parts = path.split(':').filter(Boolean);
|
|
95
|
-
if (parts.length === 0) {
|
|
96
|
-
throw new Error('Path cannot be empty');
|
|
97
|
-
}
|
|
98
|
-
const root = parts[0];
|
|
99
|
-
return { root, path };
|
|
100
|
-
}
|
|
101
|
-
exports.parseTypePath = parseTypePath;
|
|
102
|
-
function getReferencedTypePaths(type) {
|
|
103
|
-
const properties = type.typeProperties || [];
|
|
104
|
-
return properties
|
|
105
|
-
.filter((prop) => prop.propertyType === types_1.PropertyType.TypeReference)
|
|
106
|
-
.map(({ referencedTypePath }) => referencedTypePath);
|
|
107
|
-
}
|
|
108
|
-
exports.getReferencedTypePaths = getReferencedTypePaths;
|
package/dist/auth/login.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { AuthContext } from '@contrail/sdk';
|
|
2
|
+
export interface SignInOptions {
|
|
3
|
+
openBrowser: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare function authUser(): Promise<AuthContext>;
|
|
6
|
+
export declare function signIn(options: SignInOptions): Promise<AuthContext>;
|
|
3
7
|
export declare function getVersionFromPackageJson(): string;
|
package/dist/auth/login.js
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getVersionFromPackageJson = exports.authUser = void 0;
|
|
3
|
+
exports.getVersionFromPackageJson = exports.signIn = exports.authUser = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
7
|
const sdk_1 = require("@contrail/sdk");
|
|
7
8
|
const config_1 = require("../helpers/config/config");
|
|
8
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
10
|
+
const sso_1 = require("./sso");
|
|
9
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
12
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
11
|
-
const common_1 = require("../common");
|
|
12
13
|
const DEFAULT_API_GATEWAY = config_1.ENVIRONMENTS.prod;
|
|
13
14
|
const COGNITO_CONFIGS = {
|
|
14
|
-
dev: {
|
|
15
|
-
|
|
15
|
+
dev: {
|
|
16
|
+
userPoolId: 'us-east-1_e2cA0nJWu',
|
|
17
|
+
clientId: '209s9c62o165cqab0fu5ihjtu9',
|
|
18
|
+
sso: {
|
|
19
|
+
domain: 'https://dev-vibeiq.auth.us-east-1.amazoncognito.com',
|
|
20
|
+
clientId: '37m7g73hfetr5ab4o5b2ocv1j9',
|
|
21
|
+
pastedCodeCallbackUrl: 'https://login.dev.vibeiq.com/cli',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
prod: {
|
|
25
|
+
userPoolId: 'us-east-1_qIaNZdUfm',
|
|
26
|
+
clientId: '7knkt34gfacbgd0ghnuspefdfg',
|
|
27
|
+
sso: {
|
|
28
|
+
domain: 'https://prod-vibeiq.auth.us-east-1.amazoncognito.com',
|
|
29
|
+
clientId: 'PROD_CLI_CLIENT_ID',
|
|
30
|
+
pastedCodeCallbackUrl: 'https://login.vibeiq.com/cli',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
16
33
|
};
|
|
17
34
|
async function authUser() {
|
|
18
35
|
logger_1.default.debug('authorizing user...');
|
|
@@ -37,7 +54,7 @@ async function authUser() {
|
|
|
37
54
|
};
|
|
38
55
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
39
56
|
try {
|
|
40
|
-
return await signInWithStoredTokens();
|
|
57
|
+
return await signInWithStoredTokens(config.signInMethod ?? 'password');
|
|
41
58
|
}
|
|
42
59
|
catch (e) {
|
|
43
60
|
logger_1.default.debug(`stored tokens rejected: ${e?.message}`);
|
|
@@ -48,13 +65,77 @@ async function authUser() {
|
|
|
48
65
|
logger_1.default.info('Token expired. Requesting auth credentials...');
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
|
-
return await
|
|
68
|
+
return await signIn({ openBrowser: true });
|
|
52
69
|
}
|
|
53
70
|
exports.authUser = authUser;
|
|
71
|
+
async function signIn(options) {
|
|
72
|
+
const config = await (0, config_1.getConfig)();
|
|
73
|
+
const apiGateway = getApiGateway(config);
|
|
74
|
+
const environment = (0, config_1.findEnvironmentName)(apiGateway);
|
|
75
|
+
if (!environment) {
|
|
76
|
+
throw new Error(`No Cognito user pool is known for ${apiGateway}. Sign-in works for ${Object.keys(COGNITO_CONFIGS).join(' and ')}; use CONTRAIL_CLI_API_KEY for other environments.`);
|
|
77
|
+
}
|
|
78
|
+
const email = process.env.CONTRAIL_CLI_EMAIL || (await promptForEmail());
|
|
79
|
+
const params = {
|
|
80
|
+
email,
|
|
81
|
+
orgSlug: await getOrgSlug(config),
|
|
82
|
+
apiGateway,
|
|
83
|
+
environment,
|
|
84
|
+
};
|
|
85
|
+
if (process.env.CONTRAIL_CLI_PASSWORD) {
|
|
86
|
+
return authenticateWithUsernamePassword(params);
|
|
87
|
+
}
|
|
88
|
+
const domainCheck = await (0, sso_1.fetchSsoDomainCheck)(email, apiGateway);
|
|
89
|
+
if (domainCheck.kind === 'cognito') {
|
|
90
|
+
return signInWithSso(params, domainCheck.identityProvider, options);
|
|
91
|
+
}
|
|
92
|
+
if (domainCheck.kind === 'legacy') {
|
|
93
|
+
console.log('The CLI does not support your SSO provider yet. Sign in with your VibeIQ password, or set CONTRAIL_CLI_API_KEY.');
|
|
94
|
+
}
|
|
95
|
+
return authenticateWithUsernamePassword(params);
|
|
96
|
+
}
|
|
97
|
+
exports.signIn = signIn;
|
|
98
|
+
async function promptForEmail() {
|
|
99
|
+
const answers = await inquirer_1.default.prompt([
|
|
100
|
+
{ type: 'input', name: 'email', validate: (val) => !!val, message: 'Email' },
|
|
101
|
+
]);
|
|
102
|
+
return answers.email;
|
|
103
|
+
}
|
|
104
|
+
async function signInWithSso(params, identityProvider, options) {
|
|
105
|
+
const ssoClient = COGNITO_CONFIGS[params.environment].sso;
|
|
106
|
+
const pkce = (0, sso_1.createPkceChallenge)();
|
|
107
|
+
const usesLoopback = options.openBrowser && (0, sso_1.canOpenBrowser)();
|
|
108
|
+
const redirectUri = usesLoopback ? sso_1.LOOPBACK_CALLBACK_URL : ssoClient.pastedCodeCallbackUrl;
|
|
109
|
+
const authorizeUrl = (0, sso_1.buildAuthorizeUrl)(ssoClient, identityProvider, redirectUri, pkce);
|
|
110
|
+
let code;
|
|
111
|
+
if (usesLoopback) {
|
|
112
|
+
const loopbackListener = await (0, sso_1.listenForLoopbackCode)(pkce.state);
|
|
113
|
+
console.log(`Opening your browser to sign in. If it does not open, visit:\n${authorizeUrl}`);
|
|
114
|
+
await (0, sso_1.openBrowser)(authorizeUrl).catch(() => console.log('Could not open a browser. Open the URL above to sign in.'));
|
|
115
|
+
code = await loopbackListener.code;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.log(`Open this URL in any browser to sign in:\n${authorizeUrl}`);
|
|
119
|
+
const answers = await inquirer_1.default.prompt([
|
|
120
|
+
{ type: 'input', name: 'signInCode', validate: (val) => !!val, message: 'Sign-in code' },
|
|
121
|
+
]);
|
|
122
|
+
code = (0, sso_1.parsePastedSignInCode)(answers.signInCode, pkce.state);
|
|
123
|
+
}
|
|
124
|
+
const tokens = await (0, sso_1.exchangeCodeForTokens)(ssoClient, code, redirectUri, pkce.verifier);
|
|
125
|
+
sdk_1.Auth.config = {
|
|
126
|
+
apiUserToken: tokens.accessToken,
|
|
127
|
+
apiRefreshToken: tokens.refreshToken,
|
|
128
|
+
apiGateway: params.apiGateway,
|
|
129
|
+
orgSlug: params.orgSlug,
|
|
130
|
+
};
|
|
131
|
+
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
132
|
+
await (0, sdk_1.getCurrentUser)();
|
|
133
|
+
return returnAndStoreConfig(sdk_1.Auth.config, 'sso');
|
|
134
|
+
}
|
|
54
135
|
async function getOrgSlug(config) {
|
|
55
136
|
const orgSlug = config?.orgSlug || process.env.CONTRAIL_CLI_ORG_SLUG;
|
|
56
137
|
if (!orgSlug) {
|
|
57
|
-
const answers = await
|
|
138
|
+
const answers = await inquirer_1.default.prompt([
|
|
58
139
|
{
|
|
59
140
|
type: 'input',
|
|
60
141
|
name: 'orgSlug',
|
|
@@ -78,41 +159,9 @@ async function authenticateWithApiKey(config, apiKey, orgSlug) {
|
|
|
78
159
|
await (0, sdk_1.getCurrentUser)();
|
|
79
160
|
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
80
161
|
}
|
|
81
|
-
async function authenticateWithUsernamePassword(
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
if (!environment) {
|
|
85
|
-
throw new Error(`No Cognito user pool is known for ${apiGateway}. Email and password sign-in works for ${Object.keys(COGNITO_CONFIGS).join(' and ')}; use CONTRAIL_CLI_API_KEY for other environments.`);
|
|
86
|
-
}
|
|
87
|
-
const cognitoConfig = COGNITO_CONFIGS[environment];
|
|
88
|
-
const questions = [];
|
|
89
|
-
if (!process.env.CONTRAIL_CLI_EMAIL) {
|
|
90
|
-
questions.push({
|
|
91
|
-
type: 'input',
|
|
92
|
-
name: 'email',
|
|
93
|
-
validate: (val) => !!val,
|
|
94
|
-
message: 'Email',
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (!process.env.CONTRAIL_CLI_PASSWORD) {
|
|
98
|
-
questions.push({
|
|
99
|
-
type: 'password',
|
|
100
|
-
name: 'password',
|
|
101
|
-
validate: (val) => !!val,
|
|
102
|
-
message: 'Password',
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
const answers = await (0, common_1.promptOnStderr)(questions);
|
|
106
|
-
const params = {
|
|
107
|
-
email: process.env.CONTRAIL_CLI_EMAIL || answers.email,
|
|
108
|
-
password: process.env.CONTRAIL_CLI_PASSWORD || answers.password,
|
|
109
|
-
orgSlug: await getOrgSlug(config),
|
|
110
|
-
apiGateway,
|
|
111
|
-
environment,
|
|
112
|
-
};
|
|
113
|
-
if (!params.email || !params.password) {
|
|
114
|
-
throw new Error('Email and Password required');
|
|
115
|
-
}
|
|
162
|
+
async function authenticateWithUsernamePassword(params) {
|
|
163
|
+
const cognitoConfig = COGNITO_CONFIGS[params.environment];
|
|
164
|
+
const password = process.env.CONTRAIL_CLI_PASSWORD || (await promptForPassword());
|
|
116
165
|
const poolData = {
|
|
117
166
|
UserPoolId: cognitoConfig.userPoolId,
|
|
118
167
|
ClientId: cognitoConfig.clientId,
|
|
@@ -120,7 +169,7 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
120
169
|
const userPool = new amazon_cognito_identity_js_1.CognitoUserPool(poolData);
|
|
121
170
|
const authData = {
|
|
122
171
|
Username: params.email,
|
|
123
|
-
Password:
|
|
172
|
+
Password: password,
|
|
124
173
|
};
|
|
125
174
|
const authDetails = new amazon_cognito_identity_js_1.AuthenticationDetails(authData);
|
|
126
175
|
const userData = {
|
|
@@ -140,7 +189,7 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
140
189
|
},
|
|
141
190
|
onFailure: (err) => {
|
|
142
191
|
if (err?.code === 'ResourceNotFoundException') {
|
|
143
|
-
reject(new Error(`This version of the CLI has outdated ${environment} sign-in settings (${err.message}). Update the CLI: npm i -g @contrail/cli`));
|
|
192
|
+
reject(new Error(`This version of the CLI has outdated ${params.environment} sign-in settings (${err.message}). Update the CLI: npm i -g @contrail/cli`));
|
|
144
193
|
return;
|
|
145
194
|
}
|
|
146
195
|
reject(err);
|
|
@@ -148,6 +197,12 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
148
197
|
});
|
|
149
198
|
});
|
|
150
199
|
}
|
|
200
|
+
async function promptForPassword() {
|
|
201
|
+
const answers = await inquirer_1.default.prompt([
|
|
202
|
+
{ type: 'password', name: 'password', validate: (val) => !!val, message: 'Password' },
|
|
203
|
+
]);
|
|
204
|
+
return answers.password;
|
|
205
|
+
}
|
|
151
206
|
async function setAuthContext(user, params) {
|
|
152
207
|
const apiGateway = params.apiGateway;
|
|
153
208
|
const { vibeAccessToken, vibeRefreshToken } = await getVibeAccessTokenFromCognitoAccessToken(user.idToken.jwtToken, apiGateway, params.environment);
|
|
@@ -162,7 +217,7 @@ async function setAuthContext(user, params) {
|
|
|
162
217
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
163
218
|
return refreshCurrentUserOrg();
|
|
164
219
|
}
|
|
165
|
-
async function signInWithStoredTokens() {
|
|
220
|
+
async function signInWithStoredTokens(signInMethod) {
|
|
166
221
|
try {
|
|
167
222
|
await (0, sdk_1.getCurrentUser)();
|
|
168
223
|
}
|
|
@@ -171,7 +226,7 @@ async function signInWithStoredTokens() {
|
|
|
171
226
|
throw e;
|
|
172
227
|
}
|
|
173
228
|
logger_1.default.debug('access token rejected, refreshing it...');
|
|
174
|
-
await refreshAccessToken();
|
|
229
|
+
await refreshAccessToken(signInMethod);
|
|
175
230
|
await (0, sdk_1.getCurrentUser)();
|
|
176
231
|
}
|
|
177
232
|
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
@@ -182,13 +237,21 @@ async function refreshCurrentUserOrg() {
|
|
|
182
237
|
// TODO: To uncomment when telemetry backend is developed.
|
|
183
238
|
// const current_Version = getVersionFromPackageJson();
|
|
184
239
|
// await checkTelemetry(current_Version);
|
|
185
|
-
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
240
|
+
return returnAndStoreConfig(sdk_1.Auth.config, 'password');
|
|
186
241
|
}
|
|
187
|
-
async function refreshAccessToken() {
|
|
188
|
-
const
|
|
189
|
-
sdk_1.Auth.config = { ...sdk_1.Auth.config, apiUserToken:
|
|
242
|
+
async function refreshAccessToken(signInMethod) {
|
|
243
|
+
const newAccessToken = await fetchRefreshedAccessTokenForSignInMethod(signInMethod);
|
|
244
|
+
sdk_1.Auth.config = { ...sdk_1.Auth.config, apiUserToken: newAccessToken };
|
|
190
245
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
191
246
|
}
|
|
247
|
+
async function fetchRefreshedAccessTokenForSignInMethod(signInMethod) {
|
|
248
|
+
const { apiRefreshToken, apiGateway } = sdk_1.Auth.config;
|
|
249
|
+
if (signInMethod === 'sso') {
|
|
250
|
+
const ssoClient = COGNITO_CONFIGS[(0, config_1.findEnvironmentName)(apiGateway)].sso;
|
|
251
|
+
return (0, sso_1.refreshSsoAccessToken)(ssoClient, apiRefreshToken);
|
|
252
|
+
}
|
|
253
|
+
return requestRefreshedAccessToken(apiRefreshToken, apiGateway);
|
|
254
|
+
}
|
|
192
255
|
function getApiGateway(config) {
|
|
193
256
|
return config?.apiGateway ?? DEFAULT_API_GATEWAY;
|
|
194
257
|
}
|
|
@@ -238,9 +301,9 @@ function getVersionFromPackageJson() {
|
|
|
238
301
|
return packageJson.version;
|
|
239
302
|
}
|
|
240
303
|
exports.getVersionFromPackageJson = getVersionFromPackageJson;
|
|
241
|
-
async function returnAndStoreConfig(config) {
|
|
304
|
+
async function returnAndStoreConfig(config, signInMethod) {
|
|
242
305
|
const configCopy = Object.assign({}, config);
|
|
243
|
-
await (0, config_1.storeConfig)(configCopy);
|
|
306
|
+
await (0, config_1.storeConfig)(signInMethod ? { ...configCopy, signInMethod } : configCopy);
|
|
244
307
|
return configCopy;
|
|
245
308
|
}
|
|
246
309
|
function isNetworkConnectionError(e) {
|