@contrail/cli 3.6.0-alpha-8-alpha.7830b8a → 3.6.0-alpha-8-alpha.302405c
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 +9 -8
- package/dist/commands/entities/create.spec.js +5 -5
- package/dist/commands/entities/get.js +5 -5
- package/dist/commands/entities/update.js +2 -2
- package/dist/helpers/entities/items.spec.js +1 -1
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +2 -2
- package/dist/helpers/propertySpecifications/propertyValues.spec.js +21 -21
- package/oclif.manifest.json +8 -8
- package/package.json +1 -1
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-8-alpha.
|
|
20
|
+
@contrail/cli/3.6.0-alpha-8-alpha.302405c linux-x64 node-v24.22.2
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -656,9 +656,10 @@ FLAGS
|
|
|
656
656
|
-l, --logLevel=<option> The Log Level
|
|
657
657
|
<options: error|warn|info|debug>
|
|
658
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
|
|
659
|
+
-p, --propertySlugs=<value> Comma-separated list of property slugs to include in the output. Only some entity
|
|
660
|
+
types support this; the rest return full records.
|
|
660
661
|
-r, --relations=<value> Comma-separated list of relations to include in the output
|
|
661
|
-
-s, --skip=<value> Number of entities to skip
|
|
662
|
+
-s, --skip=<value> Number of entities to skip
|
|
662
663
|
-t, --take=<value> Number of entities to fetch in a single request (default is 100)
|
|
663
664
|
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
664
665
|
<options: 1|2>
|
|
@@ -675,11 +676,11 @@ EXAMPLES
|
|
|
675
676
|
|
|
676
677
|
$ contrail entities get color -- id=123
|
|
677
678
|
|
|
678
|
-
$ contrail entities get loader-
|
|
679
|
+
$ contrail entities get loader-process -- createdOn=2025-09-15..2025-09-16
|
|
679
680
|
|
|
680
|
-
$ contrail entities get
|
|
681
|
+
$ contrail entities get item -- updatedOn=2025-09-15T04:00:00Z..
|
|
681
682
|
|
|
682
|
-
$ contrail entities get
|
|
683
|
+
$ contrail entities get color -- createdOn=..2025-09-16T23:59:59Z
|
|
683
684
|
```
|
|
684
685
|
|
|
685
686
|
## `contrail entities update ENTITYNAME [IDS]`
|
|
@@ -714,9 +715,9 @@ DESCRIPTION
|
|
|
714
715
|
EXAMPLES
|
|
715
716
|
$ contrail entities update color 123 -- name=obsidian hex=000000
|
|
716
717
|
|
|
717
|
-
$ contrail entities update item id1 id2 id3 --
|
|
718
|
+
$ contrail entities update item id1 id2 id3 -- colorName=obsidian # apply the same change to several entities
|
|
718
719
|
|
|
719
|
-
$ contrail entities update color 123 --
|
|
720
|
+
$ contrail entities update color 123 -- federatedId= name='""' # Unset federatedId, set name to empty string
|
|
720
721
|
```
|
|
721
722
|
|
|
722
723
|
## `contrail feature-flags export`
|
|
@@ -532,19 +532,19 @@ describe('pickRandomPropertyValues', () => {
|
|
|
532
532
|
propertyType: types_1.PropertyType.UserList,
|
|
533
533
|
propertyLevel: types_1.PropertyLevel.ALL,
|
|
534
534
|
};
|
|
535
|
-
it('
|
|
535
|
+
it('should generate only the properties matching the given roles', () => {
|
|
536
536
|
const type = typeWith([familyOnly, optionOnly]);
|
|
537
537
|
const family = (0, create_1.pickRandomPropertyValues)(type, caches[0], caches[1], ['family']);
|
|
538
538
|
const option = (0, create_1.pickRandomPropertyValues)(type, caches[0], caches[1], ['option']);
|
|
539
539
|
expect(Object.keys(family)).toEqual(['familyText']);
|
|
540
540
|
expect(Object.keys(option)).toEqual(['optionText']);
|
|
541
541
|
});
|
|
542
|
-
it('
|
|
542
|
+
it('should skip properties the caller already supplied', () => {
|
|
543
543
|
const type = typeWith([familyOnly, optionOnly]);
|
|
544
544
|
const result = (0, create_1.pickRandomPropertyValues)(type, caches[0], caches[1], undefined, new Set(['familyText']));
|
|
545
545
|
expect(Object.keys(result)).toEqual(['optionText']);
|
|
546
546
|
});
|
|
547
|
-
it('
|
|
547
|
+
it('should not fail on an unsupported property type when its value was supplied', () => {
|
|
548
548
|
const type = typeWith([unsupported]);
|
|
549
549
|
expect(() => (0, create_1.pickRandomPropertyValues)(type, caches[0], caches[1])).toThrow('Cannot handle property type: userList');
|
|
550
550
|
expect((0, create_1.pickRandomPropertyValues)(type, caches[0], caches[1], undefined, new Set(['users']))).toEqual({});
|
|
@@ -553,7 +553,7 @@ describe('pickRandomPropertyValues', () => {
|
|
|
553
553
|
describe('MultiSelect generation', () => {
|
|
554
554
|
const caches = [new Map(), new Map()];
|
|
555
555
|
const options = ['na', 'active', 'big', 'classic', 'custom', 'pro'].map((value) => ({ value }));
|
|
556
|
-
it('
|
|
556
|
+
it('should pick a real subset rather than every option', () => {
|
|
557
557
|
const property = {
|
|
558
558
|
slug: 'tags',
|
|
559
559
|
propertyType: types_1.PropertyType.MultiSelect,
|
|
@@ -565,7 +565,7 @@ describe('MultiSelect generation', () => {
|
|
|
565
565
|
expect(Math.min(...counts)).toBeGreaterThan(0);
|
|
566
566
|
expect(counts.size).toBeGreaterThan(1);
|
|
567
567
|
});
|
|
568
|
-
it('
|
|
568
|
+
it('should not reorder the option list it was given', () => {
|
|
569
569
|
const property = {
|
|
570
570
|
slug: 'tags',
|
|
571
571
|
propertyType: types_1.PropertyType.MultiSelect,
|
|
@@ -21,9 +21,9 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
21
21
|
'contrail entities get color 123',
|
|
22
22
|
'contrail entities get color id1 id2 id3',
|
|
23
23
|
'contrail entities get color -- id=123',
|
|
24
|
-
'contrail entities get loader-
|
|
25
|
-
'contrail entities get
|
|
26
|
-
'contrail entities get
|
|
24
|
+
'contrail entities get loader-process -- createdOn=2025-09-15..2025-09-16',
|
|
25
|
+
'contrail entities get item -- updatedOn=2025-09-15T04:00:00Z..',
|
|
26
|
+
'contrail entities get color -- createdOn=..2025-09-16T23:59:59Z',
|
|
27
27
|
];
|
|
28
28
|
static flags = {
|
|
29
29
|
...basecommand_1.BaseCommand.baseFlags,
|
|
@@ -34,7 +34,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
34
34
|
}),
|
|
35
35
|
propertySlugs: core_1.Flags.string({
|
|
36
36
|
char: 'p',
|
|
37
|
-
description: 'Comma-separated list of property slugs to include in the output',
|
|
37
|
+
description: 'Comma-separated list of property slugs to include in the output. Only some entity types support this; the rest return full records.',
|
|
38
38
|
required: false,
|
|
39
39
|
}),
|
|
40
40
|
paginated: core_1.Flags.boolean({
|
|
@@ -45,7 +45,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
45
45
|
}),
|
|
46
46
|
skip: core_1.Flags.integer({
|
|
47
47
|
char: 's',
|
|
48
|
-
description: 'Number of entities to skip
|
|
48
|
+
description: 'Number of entities to skip',
|
|
49
49
|
required: false,
|
|
50
50
|
}),
|
|
51
51
|
skipHydrateRelationships: core_1.Flags.boolean({
|
|
@@ -16,8 +16,8 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
16
16
|
static description = 'Update an entity';
|
|
17
17
|
static examples = [
|
|
18
18
|
'contrail entities update color 123 -- name=obsidian hex=000000',
|
|
19
|
-
'contrail entities update item id1 id2 id3 --
|
|
20
|
-
'contrail entities update color 123 --
|
|
19
|
+
'contrail entities update item id1 id2 id3 -- colorName=obsidian # apply the same change to several entities',
|
|
20
|
+
'contrail entities update color 123 -- federatedId= name=\'""\' # Unset federatedId, set name to empty string',
|
|
21
21
|
];
|
|
22
22
|
static flags = {
|
|
23
23
|
...basecommand_1.BaseCommand.baseFlags,
|
|
@@ -8,7 +8,7 @@ jest.mock('@contrail/sdk', () => ({
|
|
|
8
8
|
}));
|
|
9
9
|
describe('getManyItems', () => {
|
|
10
10
|
beforeEach(() => jest.clearAllMocks());
|
|
11
|
-
it('
|
|
11
|
+
it('should stop on the last page rather than refetching the first', async () => {
|
|
12
12
|
mockGet.mockImplementation(async ({ nextPageKey }) => nextPageKey === 'page-2'
|
|
13
13
|
? { results: [{ id: 'b' }], nextPageKey: undefined }
|
|
14
14
|
: { results: [{ id: 'a' }], nextPageKey: 'page-2' });
|
|
@@ -372,7 +372,7 @@ describe('edge cases and limitations', () => {
|
|
|
372
372
|
});
|
|
373
373
|
});
|
|
374
374
|
describe('values containing ..', () => {
|
|
375
|
-
it('
|
|
375
|
+
it('should keep them literal, since date ranges resolve in get criteria', () => {
|
|
376
376
|
const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)([
|
|
377
377
|
'description=Loading...',
|
|
378
378
|
'notes=2025-01-01..2025-12-31',
|
|
@@ -380,7 +380,7 @@ describe('values containing ..', () => {
|
|
|
380
380
|
expect(result.get('description')).toBe('Loading...');
|
|
381
381
|
expect(result.get('notes')).toBe('2025-01-01..2025-12-31');
|
|
382
382
|
});
|
|
383
|
-
it('
|
|
383
|
+
it('should not discard them during partitioning', () => {
|
|
384
384
|
expect((0, propertySpecifications_1.isValidPropertySpecification)('description=Loading...')).toBe(true);
|
|
385
385
|
expect((0, propertySpecifications_1.isValidPropertySpecification)('createdOn=2025-13-50..2025-13-51')).toBe(true);
|
|
386
386
|
});
|
|
@@ -34,10 +34,10 @@ describe('castValueToPropertyType array coercion', () => {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
describe('getPropertySlug', () => {
|
|
37
|
-
it('
|
|
37
|
+
it('should suffix Id for an object reference', () => {
|
|
38
38
|
expect((0, propertyValues_1.getPropertySlug)({ slug: 'fabric', propertyType: types_1.PropertyType.ObjectReference })).toBe('fabricId');
|
|
39
39
|
});
|
|
40
|
-
it('
|
|
40
|
+
it('should leave every other property type alone', () => {
|
|
41
41
|
expect((0, propertyValues_1.getPropertySlug)({ slug: 'name', propertyType: types_1.PropertyType.String })).toBe('name');
|
|
42
42
|
});
|
|
43
43
|
});
|
|
@@ -47,62 +47,62 @@ describe('castValuesToPropertyTypes', () => {
|
|
|
47
47
|
{ slug: 'rank', propertyType: types_1.PropertyType.Number },
|
|
48
48
|
{ slug: 'fabric', propertyType: types_1.PropertyType.ObjectReference },
|
|
49
49
|
];
|
|
50
|
-
it('
|
|
50
|
+
it('should cast each value using its property type', () => {
|
|
51
51
|
const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([
|
|
52
52
|
['isArchived', 'false'],
|
|
53
53
|
['rank', '3'],
|
|
54
54
|
]), typeProperties);
|
|
55
55
|
expect(result).toEqual({ isArchived: false, rank: 3 });
|
|
56
56
|
});
|
|
57
|
-
it('
|
|
57
|
+
it('should match an object reference by its suffixed slug', () => {
|
|
58
58
|
const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([['fabricId', 'abc']]), typeProperties);
|
|
59
59
|
expect(result).toEqual({ fabricId: 'abc' });
|
|
60
60
|
});
|
|
61
|
-
it('
|
|
61
|
+
it('should write a slug the type does not define through as a string', () => {
|
|
62
62
|
const result = (0, propertyValues_1.castValuesToPropertyTypes)(new Map([['unknown', 'false']]), typeProperties);
|
|
63
63
|
expect(result).toEqual({ unknown: 'false' });
|
|
64
64
|
});
|
|
65
|
-
it('
|
|
65
|
+
it('should treat a missing type as defining no properties', () => {
|
|
66
66
|
expect((0, propertyValues_1.castValuesToPropertyTypes)(new Map([['isArchived', 'true']]))).toEqual({
|
|
67
67
|
isArchived: 'true',
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
describe('inferAndCastValue', () => {
|
|
72
|
-
it('
|
|
72
|
+
it('should coerce a number only when it survives the round trip', () => {
|
|
73
73
|
expect((0, propertyValues_1.inferAndCastValue)('3650')).toBe(3650);
|
|
74
74
|
expect((0, propertyValues_1.inferAndCastValue)('12.5')).toBe(12.5);
|
|
75
75
|
expect((0, propertyValues_1.inferAndCastValue)('0')).toBe(0);
|
|
76
76
|
});
|
|
77
|
-
it('
|
|
77
|
+
it('should keep numeric-looking strings that would not round trip', () => {
|
|
78
78
|
// hex=000000 appears in the create examples, and parseFloat would make it 0
|
|
79
79
|
expect((0, propertyValues_1.inferAndCastValue)('000000')).toBe('000000');
|
|
80
80
|
expect((0, propertyValues_1.inferAndCastValue)('007')).toBe('007');
|
|
81
81
|
expect((0, propertyValues_1.inferAndCastValue)('12.50')).toBe('12.50');
|
|
82
82
|
expect((0, propertyValues_1.inferAndCastValue)('1e5')).toBe('1e5');
|
|
83
83
|
});
|
|
84
|
-
it('
|
|
84
|
+
it('should coerce exact booleans only', () => {
|
|
85
85
|
expect((0, propertyValues_1.inferAndCastValue)('true')).toBe(true);
|
|
86
86
|
expect((0, propertyValues_1.inferAndCastValue)('false')).toBe(false);
|
|
87
87
|
expect((0, propertyValues_1.inferAndCastValue)('True')).toBe('True');
|
|
88
88
|
});
|
|
89
|
-
it('
|
|
89
|
+
it('should coerce ISO dates', () => {
|
|
90
90
|
expect((0, propertyValues_1.inferAndCastValue)('2025-09-15')).toBe('2025-09-15T00:00:00.000Z');
|
|
91
91
|
expect((0, propertyValues_1.inferAndCastValue)('not-a-date')).toBe('not-a-date');
|
|
92
92
|
});
|
|
93
|
-
it('
|
|
93
|
+
it('should map over arrays and leave non-strings alone', () => {
|
|
94
94
|
expect((0, propertyValues_1.inferAndCastValue)(['1', 'x'])).toEqual([1, 'x']);
|
|
95
95
|
expect((0, propertyValues_1.inferAndCastValue)(7)).toBe(7);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
describe('buildPropertyTypeMap', () => {
|
|
99
|
-
it('
|
|
99
|
+
it('should give the first type precedence for a conflicting slug', () => {
|
|
100
100
|
const first = [{ slug: 'matchingProperty2', propertyType: types_1.PropertyType.Number }];
|
|
101
101
|
const second = [{ slug: 'matchingProperty2', propertyType: types_1.PropertyType.String }];
|
|
102
102
|
expect((0, propertyValues_1.buildPropertyTypeMap)([first, second]).get('matchingProperty2')).toBe(types_1.PropertyType.Number);
|
|
103
103
|
expect((0, propertyValues_1.buildPropertyTypeMap)([second, first]).get('matchingProperty2')).toBe(types_1.PropertyType.String);
|
|
104
104
|
});
|
|
105
|
-
it('
|
|
105
|
+
it('should tolerate a type that could not be resolved', () => {
|
|
106
106
|
expect((0, propertyValues_1.buildPropertyTypeMap)([undefined]).size).toBe(0);
|
|
107
107
|
});
|
|
108
108
|
});
|
|
@@ -112,27 +112,27 @@ describe('castCriteriaValues', () => {
|
|
|
112
112
|
{ slug: 'optionSequence', propertyType: types_1.PropertyType.Sequence },
|
|
113
113
|
{ slug: 'hex', propertyType: types_1.PropertyType.String },
|
|
114
114
|
];
|
|
115
|
-
it('
|
|
115
|
+
it('should cast a defined slug from its property type', () => {
|
|
116
116
|
expect((0, propertyValues_1.castCriteriaValues)(new Map([['isArchived', 'false']]), [typeProperties])).toEqual({
|
|
117
117
|
isArchived: false,
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
|
-
it('
|
|
120
|
+
it('should cast the whole numeric family, not just Number', () => {
|
|
121
121
|
expect((0, propertyValues_1.castCriteriaValues)(new Map([['optionSequence', '3650']]), [typeProperties])).toEqual({
|
|
122
122
|
optionSequence: 3650,
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
|
-
it('
|
|
125
|
+
it('should leave a defined string property alone', () => {
|
|
126
126
|
expect((0, propertyValues_1.castCriteriaValues)(new Map([['hex', '000000']]), [typeProperties])).toEqual({
|
|
127
127
|
hex: '000000',
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
|
-
it('
|
|
130
|
+
it('should fall back to the value shape for an undefined slug', () => {
|
|
131
131
|
expect((0, propertyValues_1.castCriteriaValues)(new Map([['unknown', 'true']]), [typeProperties])).toEqual({
|
|
132
132
|
unknown: true,
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
|
-
it('never
|
|
135
|
+
it('should never coerce id or ids', () => {
|
|
136
136
|
expect((0, propertyValues_1.castCriteriaValues)(new Map([
|
|
137
137
|
['id', '12345'],
|
|
138
138
|
['ids', ['1', '2']],
|
|
@@ -140,17 +140,17 @@ describe('castCriteriaValues', () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
describe('castValuesToPropertyTypes never guesses', () => {
|
|
143
|
-
it('
|
|
143
|
+
it('should write an undefined slug through unchanged', () => {
|
|
144
144
|
expect((0, propertyValues_1.castValuesToPropertyTypes)(new Map([['unknown', 'true']]), [])).toEqual({
|
|
145
145
|
unknown: 'true',
|
|
146
146
|
});
|
|
147
147
|
});
|
|
148
148
|
});
|
|
149
149
|
describe('Date casting', () => {
|
|
150
|
-
it('
|
|
150
|
+
it('should name the slug and value for an unparseable date', () => {
|
|
151
151
|
expect(() => (0, propertyValues_1.castValueToPropertyType)('garbage', types_1.PropertyType.Date, 'createdOn')).toThrow('Invalid date value for createdOn: garbage');
|
|
152
152
|
});
|
|
153
|
-
it('still
|
|
153
|
+
it('should still convert a parseable date', () => {
|
|
154
154
|
expect((0, propertyValues_1.castValueToPropertyType)('2025-09-15', types_1.PropertyType.Date, 'createdOn')).toBe('2025-09-15T00:00:00.000Z');
|
|
155
155
|
});
|
|
156
156
|
});
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.6.0-alpha-8-alpha.
|
|
2
|
+
"version": "3.6.0-alpha-8-alpha.302405c",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -903,9 +903,9 @@
|
|
|
903
903
|
"contrail entities get color 123",
|
|
904
904
|
"contrail entities get color id1 id2 id3",
|
|
905
905
|
"contrail entities get color -- id=123",
|
|
906
|
-
"contrail entities get loader-
|
|
907
|
-
"contrail entities get
|
|
908
|
-
"contrail entities get
|
|
906
|
+
"contrail entities get loader-process -- createdOn=2025-09-15..2025-09-16",
|
|
907
|
+
"contrail entities get item -- updatedOn=2025-09-15T04:00:00Z..",
|
|
908
|
+
"contrail entities get color -- createdOn=..2025-09-16T23:59:59Z"
|
|
909
909
|
],
|
|
910
910
|
"flags": {
|
|
911
911
|
"logLevel": {
|
|
@@ -947,7 +947,7 @@
|
|
|
947
947
|
"name": "propertySlugs",
|
|
948
948
|
"type": "option",
|
|
949
949
|
"char": "p",
|
|
950
|
-
"description": "Comma-separated list of property slugs to include in the output",
|
|
950
|
+
"description": "Comma-separated list of property slugs to include in the output. Only some entity types support this; the rest return full records.",
|
|
951
951
|
"required": false,
|
|
952
952
|
"multiple": false
|
|
953
953
|
},
|
|
@@ -963,7 +963,7 @@
|
|
|
963
963
|
"name": "skip",
|
|
964
964
|
"type": "option",
|
|
965
965
|
"char": "s",
|
|
966
|
-
"description": "Number of entities to skip
|
|
966
|
+
"description": "Number of entities to skip",
|
|
967
967
|
"required": false,
|
|
968
968
|
"multiple": false
|
|
969
969
|
},
|
|
@@ -1033,8 +1033,8 @@
|
|
|
1033
1033
|
"aliases": [],
|
|
1034
1034
|
"examples": [
|
|
1035
1035
|
"contrail entities update color 123 -- name=obsidian hex=000000",
|
|
1036
|
-
"contrail entities update item id1 id2 id3 --
|
|
1037
|
-
"contrail entities update color 123 --
|
|
1036
|
+
"contrail entities update item id1 id2 id3 -- colorName=obsidian # apply the same change to several entities",
|
|
1037
|
+
"contrail entities update color 123 -- federatedId= name='\"\"' # Unset federatedId, set name to empty string"
|
|
1038
1038
|
],
|
|
1039
1039
|
"flags": {
|
|
1040
1040
|
"logLevel": {
|