@contrail/cli 3.6.0-alpha-8-alpha.e2d1830 → 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 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.e2d1830 linux-x64 node-v24.22.2
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 (used with paginated fetch)
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-processes -- createdOn=2025-09-15..2025-09-16
679
+ $ contrail entities get loader-process -- createdOn=2025-09-15..2025-09-16
679
680
 
680
- $ contrail entities get orders -- updatedAt=2025-09-15T04:00:00Z..
681
+ $ contrail entities get item -- updatedOn=2025-09-15T04:00:00Z..
681
682
 
682
- $ contrail entities get events -- timestamp=..2025-09-16T23:59:59Z
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 -- status=archived # apply the same change to several entities
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 -- description= notes='""' # Unset description, set notes to empty string
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('generates only the properties matching the given roles', () => {
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('skips properties the caller already supplied', () => {
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('does not fail on an unsupported property type when its value was supplied', () => {
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('picks a real subset rather than every option', () => {
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('does not reorder the option list it was given', () => {
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,
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const fs_1 = tslib_1.__importDefault(require("fs"));
5
5
  const core_1 = require("@oclif/core");
6
- const types_1 = require("../../api/types");
6
+ const types_1 = require("@contrail/types");
7
+ const types_2 = require("../../api/types");
7
8
  const propertyValues_1 = require("../../helpers/propertySpecifications/propertyValues");
8
9
  const basecommand_1 = require("../../basecommand");
9
10
  const sdk_1 = require("@contrail/sdk");
@@ -20,9 +21,9 @@ class GetEntity extends basecommand_1.BaseCommand {
20
21
  'contrail entities get color 123',
21
22
  'contrail entities get color id1 id2 id3',
22
23
  'contrail entities get color -- id=123',
23
- 'contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16',
24
- 'contrail entities get orders -- updatedAt=2025-09-15T04:00:00Z..',
25
- 'contrail entities get events -- timestamp=..2025-09-16T23:59:59Z',
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',
26
27
  ];
27
28
  static flags = {
28
29
  ...basecommand_1.BaseCommand.baseFlags,
@@ -33,7 +34,7 @@ class GetEntity extends basecommand_1.BaseCommand {
33
34
  }),
34
35
  propertySlugs: core_1.Flags.string({
35
36
  char: 'p',
36
- 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.',
37
38
  required: false,
38
39
  }),
39
40
  paginated: core_1.Flags.boolean({
@@ -44,7 +45,7 @@ class GetEntity extends basecommand_1.BaseCommand {
44
45
  }),
45
46
  skip: core_1.Flags.integer({
46
47
  char: 's',
47
- description: 'Number of entities to skip (used with paginated fetch)',
48
+ description: 'Number of entities to skip',
48
49
  required: false,
49
50
  }),
50
51
  skipHydrateRelationships: core_1.Flags.boolean({
@@ -205,10 +206,14 @@ async function getEntitiesByName(entityName, propertySpec, typePropertySets, opt
205
206
  });
206
207
  }
207
208
  function convertPropertySpecIntoCriteria(propertySpec, typePropertySets = []) {
209
+ const propertyTypeBySlug = (0, propertyValues_1.buildPropertyTypeMap)(typePropertySets);
208
210
  const ranges = new Map();
209
211
  const values = new Map();
210
212
  propertySpec.forEach((value, slug) => {
211
- ((0, dateRanges_1.isDateRangeValue)(value) ? ranges : values).set(slug, value);
213
+ const looksLikeRange = typeof value === 'string' && value.includes('..');
214
+ const isDateProperty = propertyTypeBySlug.get(slug) === types_1.PropertyType.Date;
215
+ const isRange = looksLikeRange && (isDateProperty || (0, dateRanges_1.isDateRangeValue)(value));
216
+ (isRange ? ranges : values).set(slug, value);
212
217
  });
213
218
  const criteria = (0, propertyValues_1.castCriteriaValues)(values, typePropertySets);
214
219
  ranges.forEach((value, slug) => {
@@ -224,7 +229,7 @@ function convertPropertySpecIntoCriteria(propertySpec, typePropertySets = []) {
224
229
  async function resolveQueryTypes(entityName, propertySpec) {
225
230
  const specified = propertySpec.get('typePath');
226
231
  const paths = specified === undefined ? [entityName] : [specified].flat().map(String);
227
- const types = await Promise.all(paths.map((path) => (0, types_1.getTypeByPath)(path).catch(() => {
232
+ const types = await Promise.all(paths.map((path) => (0, types_2.getTypeByPath)(path).catch(() => {
228
233
  console.error(`Could not resolve type ${path}; criteria on it are read as written.`);
229
234
  return undefined;
230
235
  })));
@@ -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 -- status=archived # apply the same change to several entities',
20
- 'contrail entities update color 123 -- description= notes=\'""\' # Unset description, set notes to empty string',
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('stops on the last page rather than refetching the first', async () => {
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('keeps them literal, since date ranges resolve in get criteria', () => {
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('does not discard them during partitioning', () => {
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
  });
@@ -37,7 +37,11 @@ function castValueToPropertyType(value, propertyType, propertySlug) {
37
37
  }
38
38
  return numValue;
39
39
  case types_1.PropertyType.Date:
40
- return new Date(value.toString()).toISOString();
40
+ const date = new Date(value.toString());
41
+ if (isNaN(date.getTime())) {
42
+ throw new Error(`Invalid date value for ${propertySlug}: ${value}`);
43
+ }
44
+ return date.toISOString();
41
45
  case types_1.PropertyType.MultiSelect:
42
46
  if (Array.isArray(value)) {
43
47
  return value;
@@ -34,10 +34,10 @@ describe('castValueToPropertyType array coercion', () => {
34
34
  });
35
35
  });
36
36
  describe('getPropertySlug', () => {
37
- it('suffixes Id for an object reference', () => {
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('leaves every other property type alone', () => {
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('casts each value using its property type', () => {
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('matches an object reference by its suffixed slug', () => {
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('writes a slug the type does not define through as a string', () => {
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('treats a missing type as defining no properties', () => {
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('coerces a number only when it survives the round trip', () => {
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('keeps numeric-looking strings that would not round trip', () => {
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('coerces exact booleans only', () => {
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('coerces ISO dates', () => {
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('maps over arrays and leaves non-strings alone', () => {
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('gives the first type precedence for a conflicting slug', () => {
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('tolerates a type that could not be resolved', () => {
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('casts a defined slug from its property type', () => {
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('casts the whole numeric family, not just Number', () => {
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('leaves a defined string property alone', () => {
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('falls back to the value shape for an undefined slug', () => {
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 coerces id or ids', () => {
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,9 +140,17 @@ describe('castCriteriaValues', () => {
140
140
  });
141
141
  });
142
142
  describe('castValuesToPropertyTypes never guesses', () => {
143
- it('writes an undefined slug through unchanged', () => {
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
+ describe('Date casting', () => {
150
+ it('should name the slug and value for an unparseable date', () => {
151
+ expect(() => (0, propertyValues_1.castValueToPropertyType)('garbage', types_1.PropertyType.Date, 'createdOn')).toThrow('Invalid date value for createdOn: garbage');
152
+ });
153
+ it('should still convert a parseable date', () => {
154
+ expect((0, propertyValues_1.castValueToPropertyType)('2025-09-15', types_1.PropertyType.Date, 'createdOn')).toBe('2025-09-15T00:00:00.000Z');
155
+ });
156
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.e2d1830",
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-processes -- createdOn=2025-09-15..2025-09-16",
907
- "contrail entities get orders -- updatedAt=2025-09-15T04:00:00Z..",
908
- "contrail entities get events -- timestamp=..2025-09-16T23:59:59Z"
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 (used with paginated fetch)",
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 -- status=archived # apply the same change to several entities",
1037
- "contrail entities update color 123 -- description= notes='\"\"' # Unset description, set notes to empty string"
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": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.6.0-alpha-8-alpha.e2d1830",
3
+ "version": "3.6.0-alpha-8-alpha.302405c",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",