@contrail/cli 3.6.0-alpha-8-alpha.85a73d5 → 3.6.0-alpha.5ecc188
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 +136 -56
- package/dist/auth/login.spec.js +117 -3
- package/dist/auth/sign-in-error.d.ts +7 -0
- package/dist/auth/sign-in-error.js +24 -0
- package/dist/auth/sign-in-error.spec.js +22 -0
- package/dist/auth/sso.d.ts +38 -0
- package/dist/auth/sso.js +184 -0
- package/dist/auth/sso.spec.js +191 -0
- package/dist/basecommand.d.ts +3 -0
- package/dist/basecommand.js +10 -3
- 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.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/sign-in-error.spec.d.ts} +0 -0
- /package/dist/{commands/entities/grammar.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.5ecc188 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
|
+
shouldOpenBrowser: 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,36 @@
|
|
|
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");
|
|
11
|
+
const sign_in_error_1 = require("./sign-in-error");
|
|
9
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
13
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
11
|
-
const common_1 = require("../common");
|
|
12
14
|
const DEFAULT_API_GATEWAY = config_1.ENVIRONMENTS.prod;
|
|
13
15
|
const COGNITO_CONFIGS = {
|
|
14
|
-
dev: {
|
|
15
|
-
|
|
16
|
+
dev: {
|
|
17
|
+
userPoolId: 'us-east-1_e2cA0nJWu',
|
|
18
|
+
clientId: '209s9c62o165cqab0fu5ihjtu9',
|
|
19
|
+
sso: {
|
|
20
|
+
domain: 'https://dev-vibeiq.auth.us-east-1.amazoncognito.com',
|
|
21
|
+
clientId: '7qlu7d55oog9dv0kd3k30kjr2v',
|
|
22
|
+
pastedCodeCallbackUrl: 'https://login.dev.vibeiq.com/cli',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
prod: {
|
|
26
|
+
userPoolId: 'us-east-1_qIaNZdUfm',
|
|
27
|
+
clientId: '7knkt34gfacbgd0ghnuspefdfg',
|
|
28
|
+
sso: {
|
|
29
|
+
domain: 'https://prod-vibeiq.auth.us-east-1.amazoncognito.com',
|
|
30
|
+
clientId: 'PROD_CLI_CLIENT_ID',
|
|
31
|
+
pastedCodeCallbackUrl: 'https://login.vibeiq.com/cli',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
16
34
|
};
|
|
17
35
|
async function authUser() {
|
|
18
36
|
logger_1.default.debug('authorizing user...');
|
|
@@ -37,7 +55,7 @@ async function authUser() {
|
|
|
37
55
|
};
|
|
38
56
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
39
57
|
try {
|
|
40
|
-
return await signInWithStoredTokens();
|
|
58
|
+
return await signInWithStoredTokens(config.signInMethod ?? 'password');
|
|
41
59
|
}
|
|
42
60
|
catch (e) {
|
|
43
61
|
logger_1.default.debug(`stored tokens rejected: ${e?.message}`);
|
|
@@ -48,13 +66,90 @@ async function authUser() {
|
|
|
48
66
|
logger_1.default.info('Token expired. Requesting auth credentials...');
|
|
49
67
|
}
|
|
50
68
|
}
|
|
51
|
-
return await
|
|
69
|
+
return await signIn({ shouldOpenBrowser: true });
|
|
52
70
|
}
|
|
53
71
|
exports.authUser = authUser;
|
|
72
|
+
async function signIn(options) {
|
|
73
|
+
const config = await (0, config_1.getConfig)();
|
|
74
|
+
const apiGateway = getApiGateway(config);
|
|
75
|
+
const environment = getSignInEnvironment(apiGateway);
|
|
76
|
+
const email = process.env.CONTRAIL_CLI_EMAIL || (await promptForEmail());
|
|
77
|
+
const params = {
|
|
78
|
+
email,
|
|
79
|
+
orgSlug: await getOrgSlug(config),
|
|
80
|
+
apiGateway,
|
|
81
|
+
environment,
|
|
82
|
+
};
|
|
83
|
+
if (process.env.CONTRAIL_CLI_PASSWORD) {
|
|
84
|
+
return authenticateWithUsernamePassword(params);
|
|
85
|
+
}
|
|
86
|
+
const domainCheck = await (0, sso_1.fetchSsoDomainCheck)(email, apiGateway);
|
|
87
|
+
if (domainCheck.kind === 'cognito') {
|
|
88
|
+
return signInWithSso(params, domainCheck.identityProvider, options);
|
|
89
|
+
}
|
|
90
|
+
if (domainCheck.kind === 'legacy') {
|
|
91
|
+
console.log('The CLI does not support your SSO provider yet. Sign in with your VibeIQ password, or set CONTRAIL_CLI_API_KEY.');
|
|
92
|
+
}
|
|
93
|
+
return authenticateWithUsernamePassword(params);
|
|
94
|
+
}
|
|
95
|
+
exports.signIn = signIn;
|
|
96
|
+
function getSignInEnvironment(apiGateway) {
|
|
97
|
+
const environment = (0, config_1.findEnvironmentName)(apiGateway);
|
|
98
|
+
if (!environment) {
|
|
99
|
+
throw new sign_in_error_1.SignInError('ENVIRONMENT_NOT_CONFIGURED', 'Sign-in works only for dev and prod. Use CONTRAIL_CLI_API_KEY for other environments.', { apiGateway });
|
|
100
|
+
}
|
|
101
|
+
return environment;
|
|
102
|
+
}
|
|
103
|
+
async function promptForEmail() {
|
|
104
|
+
const answers = await inquirer_1.default.prompt([
|
|
105
|
+
{ type: 'input', name: 'email', validate: (val) => !!val, message: 'Email' },
|
|
106
|
+
]);
|
|
107
|
+
return answers.email;
|
|
108
|
+
}
|
|
109
|
+
async function signInWithSso(params, identityProvider, options) {
|
|
110
|
+
const ssoClient = COGNITO_CONFIGS[params.environment].sso;
|
|
111
|
+
const signInAttempt = (0, sso_1.createSignInAttempt)();
|
|
112
|
+
const usesLoopback = options.shouldOpenBrowser && (0, sso_1.canOpenBrowser)();
|
|
113
|
+
const redirectUri = usesLoopback ? sso_1.LOOPBACK_CALLBACK_URL : ssoClient.pastedCodeCallbackUrl;
|
|
114
|
+
const authorizeUrl = (0, sso_1.buildAuthorizeUrl)(ssoClient, identityProvider, redirectUri, signInAttempt);
|
|
115
|
+
let code;
|
|
116
|
+
if (usesLoopback) {
|
|
117
|
+
const loopbackListener = await (0, sso_1.listenForLoopbackCode)(signInAttempt.state);
|
|
118
|
+
console.log(`Opening your browser to sign in. If it does not open, visit:\n${authorizeUrl}`);
|
|
119
|
+
try {
|
|
120
|
+
await (0, sso_1.openBrowser)(authorizeUrl);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (error?.code !== 'ENOENT') {
|
|
124
|
+
loopbackListener.stop();
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
console.log('Could not find a browser to open. Open the URL above to sign in.');
|
|
128
|
+
}
|
|
129
|
+
code = await loopbackListener.code;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.log(`Open this URL in any browser to sign in:\n${authorizeUrl}`);
|
|
133
|
+
const answers = await inquirer_1.default.prompt([
|
|
134
|
+
{ type: 'input', name: 'signInCode', validate: (val) => !!val, message: 'Sign-in code' },
|
|
135
|
+
]);
|
|
136
|
+
code = (0, sso_1.parsePastedSignInCode)(answers.signInCode, signInAttempt.state);
|
|
137
|
+
}
|
|
138
|
+
const tokens = await (0, sso_1.exchangeCodeForTokens)(ssoClient, code, redirectUri, signInAttempt.verifier);
|
|
139
|
+
sdk_1.Auth.config = {
|
|
140
|
+
apiUserToken: tokens.accessToken,
|
|
141
|
+
apiRefreshToken: tokens.refreshToken,
|
|
142
|
+
apiGateway: params.apiGateway,
|
|
143
|
+
orgSlug: params.orgSlug,
|
|
144
|
+
};
|
|
145
|
+
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
146
|
+
await (0, sdk_1.getCurrentUser)();
|
|
147
|
+
return returnAndStoreConfig(sdk_1.Auth.config, 'sso');
|
|
148
|
+
}
|
|
54
149
|
async function getOrgSlug(config) {
|
|
55
150
|
const orgSlug = config?.orgSlug || process.env.CONTRAIL_CLI_ORG_SLUG;
|
|
56
151
|
if (!orgSlug) {
|
|
57
|
-
const answers = await
|
|
152
|
+
const answers = await inquirer_1.default.prompt([
|
|
58
153
|
{
|
|
59
154
|
type: 'input',
|
|
60
155
|
name: 'orgSlug',
|
|
@@ -76,43 +171,11 @@ async function authenticateWithApiKey(config, apiKey, orgSlug) {
|
|
|
76
171
|
};
|
|
77
172
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
78
173
|
await (0, sdk_1.getCurrentUser)();
|
|
79
|
-
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
174
|
+
return returnAndStoreConfig(sdk_1.Auth.config, 'apiKey');
|
|
80
175
|
}
|
|
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
|
-
}
|
|
176
|
+
async function authenticateWithUsernamePassword(params) {
|
|
177
|
+
const cognitoConfig = COGNITO_CONFIGS[params.environment];
|
|
178
|
+
const password = process.env.CONTRAIL_CLI_PASSWORD || (await promptForPassword());
|
|
116
179
|
const poolData = {
|
|
117
180
|
UserPoolId: cognitoConfig.userPoolId,
|
|
118
181
|
ClientId: cognitoConfig.clientId,
|
|
@@ -120,7 +183,7 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
120
183
|
const userPool = new amazon_cognito_identity_js_1.CognitoUserPool(poolData);
|
|
121
184
|
const authData = {
|
|
122
185
|
Username: params.email,
|
|
123
|
-
Password:
|
|
186
|
+
Password: password,
|
|
124
187
|
};
|
|
125
188
|
const authDetails = new amazon_cognito_identity_js_1.AuthenticationDetails(authData);
|
|
126
189
|
const userData = {
|
|
@@ -140,7 +203,7 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
140
203
|
},
|
|
141
204
|
onFailure: (err) => {
|
|
142
205
|
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`));
|
|
206
|
+
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
207
|
return;
|
|
145
208
|
}
|
|
146
209
|
reject(err);
|
|
@@ -148,6 +211,12 @@ async function authenticateWithUsernamePassword(config) {
|
|
|
148
211
|
});
|
|
149
212
|
});
|
|
150
213
|
}
|
|
214
|
+
async function promptForPassword() {
|
|
215
|
+
const answers = await inquirer_1.default.prompt([
|
|
216
|
+
{ type: 'password', name: 'password', validate: (val) => !!val, message: 'Password' },
|
|
217
|
+
]);
|
|
218
|
+
return answers.password;
|
|
219
|
+
}
|
|
151
220
|
async function setAuthContext(user, params) {
|
|
152
221
|
const apiGateway = params.apiGateway;
|
|
153
222
|
const { vibeAccessToken, vibeRefreshToken } = await getVibeAccessTokenFromCognitoAccessToken(user.idToken.jwtToken, apiGateway, params.environment);
|
|
@@ -160,9 +229,9 @@ async function setAuthContext(user, params) {
|
|
|
160
229
|
};
|
|
161
230
|
// SET SDK CONFIG
|
|
162
231
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
163
|
-
return refreshCurrentUserOrg();
|
|
232
|
+
return refreshCurrentUserOrg('password');
|
|
164
233
|
}
|
|
165
|
-
async function signInWithStoredTokens() {
|
|
234
|
+
async function signInWithStoredTokens(signInMethod) {
|
|
166
235
|
try {
|
|
167
236
|
await (0, sdk_1.getCurrentUser)();
|
|
168
237
|
}
|
|
@@ -171,24 +240,35 @@ async function signInWithStoredTokens() {
|
|
|
171
240
|
throw e;
|
|
172
241
|
}
|
|
173
242
|
logger_1.default.debug('access token rejected, refreshing it...');
|
|
174
|
-
await refreshAccessToken();
|
|
243
|
+
await refreshAccessToken(signInMethod);
|
|
175
244
|
await (0, sdk_1.getCurrentUser)();
|
|
176
245
|
}
|
|
177
|
-
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
246
|
+
return returnAndStoreConfig(sdk_1.Auth.config, signInMethod);
|
|
178
247
|
}
|
|
179
|
-
async function refreshCurrentUserOrg() {
|
|
248
|
+
async function refreshCurrentUserOrg(signInMethod) {
|
|
180
249
|
logger_1.default.debug('refreshing current user org...');
|
|
181
250
|
await (0, sdk_1.getCurrentUser)();
|
|
182
251
|
// TODO: To uncomment when telemetry backend is developed.
|
|
183
252
|
// const current_Version = getVersionFromPackageJson();
|
|
184
253
|
// await checkTelemetry(current_Version);
|
|
185
|
-
return returnAndStoreConfig(sdk_1.Auth.config);
|
|
254
|
+
return returnAndStoreConfig(sdk_1.Auth.config, signInMethod);
|
|
186
255
|
}
|
|
187
|
-
async function refreshAccessToken() {
|
|
188
|
-
const
|
|
189
|
-
sdk_1.Auth.config = { ...sdk_1.Auth.config, apiUserToken:
|
|
256
|
+
async function refreshAccessToken(signInMethod) {
|
|
257
|
+
const newAccessToken = await fetchRefreshedAccessTokenForSignInMethod(signInMethod);
|
|
258
|
+
sdk_1.Auth.config = { ...sdk_1.Auth.config, apiUserToken: newAccessToken };
|
|
190
259
|
(0, sdk_1.setConfig)(sdk_1.Auth.config);
|
|
191
260
|
}
|
|
261
|
+
async function fetchRefreshedAccessTokenForSignInMethod(signInMethod) {
|
|
262
|
+
const { apiRefreshToken, apiGateway } = sdk_1.Auth.config;
|
|
263
|
+
if (signInMethod === 'sso') {
|
|
264
|
+
const ssoClient = COGNITO_CONFIGS[getSignInEnvironment(apiGateway)].sso;
|
|
265
|
+
return (0, sso_1.refreshSsoAccessToken)(ssoClient, apiRefreshToken);
|
|
266
|
+
}
|
|
267
|
+
if (signInMethod === 'apiKey') {
|
|
268
|
+
throw new sign_in_error_1.SignInError('API_KEY_CANNOT_REFRESH', 'An API key cannot be refreshed. Set a new one.');
|
|
269
|
+
}
|
|
270
|
+
return requestRefreshedAccessToken(apiRefreshToken, apiGateway);
|
|
271
|
+
}
|
|
192
272
|
function getApiGateway(config) {
|
|
193
273
|
return config?.apiGateway ?? DEFAULT_API_GATEWAY;
|
|
194
274
|
}
|
|
@@ -238,9 +318,9 @@ function getVersionFromPackageJson() {
|
|
|
238
318
|
return packageJson.version;
|
|
239
319
|
}
|
|
240
320
|
exports.getVersionFromPackageJson = getVersionFromPackageJson;
|
|
241
|
-
async function returnAndStoreConfig(config) {
|
|
321
|
+
async function returnAndStoreConfig(config, signInMethod) {
|
|
242
322
|
const configCopy = Object.assign({}, config);
|
|
243
|
-
await (0, config_1.storeConfig)(configCopy);
|
|
323
|
+
await (0, config_1.storeConfig)({ ...configCopy, signInMethod });
|
|
244
324
|
return configCopy;
|
|
245
325
|
}
|
|
246
326
|
function isNetworkConnectionError(e) {
|