@contrail/cli 3.6.0-alpha-8-alpha.2ba81bf → 3.6.0-alpha-8-alpha.2ad94f7

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.2ba81bf linux-x64 node-v24.22.1
20
+ @contrail/cli/3.6.0-alpha-8-alpha.2ad94f7 linux-x64 node-v24.22.1
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -41,7 +41,7 @@ export type WithId = {
41
41
  export type ObjectReferenceCache = Map<string, WithId>;
42
42
  type ObjectReferenceCachesByTypePath = Map<string, ObjectReferenceCache>;
43
43
  export declare function pickRandomValueForProperty(property: ExtendedTypeProperty, objectReferencesCache: ObjectReferenceCachesByTypePath, typeReferencesCache: TypeReferencesCacheByPath): number | string | string[] | boolean | null;
44
- export declare function castValueToPropertyType(value: string | number | string[] | number[], propertyType: PropertyType): any;
44
+ export declare function castValueToPropertyType(value: string | number | string[] | number[], propertyType: PropertyType, propertySlug: string): any;
45
45
  export declare function getReferencedObjectPaths(type: TypeWithProperties): ColonDelimited[];
46
46
  export declare function buildObjectReferenceCache(entities: any[]): ObjectReferenceCache;
47
47
  export declare function selectRandomObject(cache: ObjectReferenceCache): WithId;
@@ -377,7 +377,7 @@ function createEntityWithPopulatedValues(type, typeReferencesCache, objectRefere
377
377
  if (specifiedValue === undefined) {
378
378
  continue;
379
379
  }
380
- entity[propertySlug] = castValueToPropertyType(specifiedValue, correspondingProperty?.propertyType || types_1.PropertyType.String);
380
+ entity[propertySlug] = castValueToPropertyType(specifiedValue, correspondingProperty?.propertyType || types_1.PropertyType.String, propertySlug);
381
381
  }
382
382
  // Give Readbable IDs if specified
383
383
  if (SHOULD_USE_READABLE_IDS) {
@@ -523,9 +523,9 @@ function generateRandomReadableString() {
523
523
  function generateRandomDateString() {
524
524
  return new Date().toISOString();
525
525
  }
526
- function castValueToPropertyType(value, propertyType) {
526
+ function castValueToPropertyType(value, propertyType, propertySlug) {
527
527
  if (Array.isArray(value) && propertyType !== types_1.PropertyType.MultiSelect) {
528
- return value.map((element) => castValueToPropertyType(element, propertyType));
528
+ return value.map((element) => castValueToPropertyType(element, propertyType, propertySlug));
529
529
  }
530
530
  switch (propertyType) {
531
531
  case types_1.PropertyType.Boolean:
@@ -544,9 +544,9 @@ function castValueToPropertyType(value, propertyType) {
544
544
  }
545
545
  // the old comma syntax parses as one literal value; warn instead of guessing at a split
546
546
  if (typeof value === 'string' && value.includes(',')) {
547
- console.error(`Value "${value}" for a multi-value property contains a comma and is treated as one literal value. To pass several values, repeat the key: slug=${value
547
+ console.error(`${propertySlug} value "${value}" contains a comma and is treated as one literal value. To pass several values, repeat the key: ${propertySlug}=${value
548
548
  .split(',')
549
- .join(' slug=')}`);
549
+ .join(` ${propertySlug}=`)}`);
550
550
  }
551
551
  return [value];
552
552
  default:
@@ -516,29 +516,29 @@ describe('Entity Creation E2E Happy Path', () => {
516
516
  });
517
517
  describe('castValueToPropertyType array coercion', () => {
518
518
  it('should coerce a single value on a multi-value property to a one-element array', () => {
519
- expect((0, create_1.castValueToPropertyType)('option', types_1.PropertyType.MultiSelect)).toEqual(['option']);
519
+ expect((0, create_1.castValueToPropertyType)('option', types_1.PropertyType.MultiSelect, 'colors')).toEqual(['option']);
520
520
  });
521
521
  it('should pass arrays through on multi-value properties', () => {
522
- expect((0, create_1.castValueToPropertyType)(['option', 'family'], types_1.PropertyType.MultiSelect)).toEqual([
522
+ expect((0, create_1.castValueToPropertyType)(['option', 'family'], types_1.PropertyType.MultiSelect, 'colors')).toEqual([
523
523
  'option',
524
524
  'family',
525
525
  ]);
526
526
  });
527
527
  it('should keep a comma value literal on a multi-value property and warn with the repeated-key form', () => {
528
528
  const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
529
- expect((0, create_1.castValueToPropertyType)('option,family', types_1.PropertyType.MultiSelect)).toEqual([
529
+ expect((0, create_1.castValueToPropertyType)('option,family', types_1.PropertyType.MultiSelect, 'colors')).toEqual([
530
530
  'option,family',
531
531
  ]);
532
- expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('slug=option slug=family'));
532
+ expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('colors=option colors=family'));
533
533
  consoleError.mockRestore();
534
534
  });
535
535
  it('should cast each element of a repeated-key array on scalar property types', () => {
536
- expect((0, create_1.castValueToPropertyType)(['1', '2'], types_1.PropertyType.Number)).toEqual([1, 2]);
537
- expect((0, create_1.castValueToPropertyType)(['true', 'false'], types_1.PropertyType.Boolean)).toEqual([true, false]);
536
+ expect((0, create_1.castValueToPropertyType)(['1', '2'], types_1.PropertyType.Number, 'rank')).toEqual([1, 2]);
537
+ expect((0, create_1.castValueToPropertyType)(['true', 'false'], types_1.PropertyType.Boolean, 'isActive')).toEqual([true, false]);
538
538
  });
539
539
  it('should keep commas literal on string properties without warning', () => {
540
540
  const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
541
- expect((0, create_1.castValueToPropertyType)('my,name', types_1.PropertyType.String)).toBe('my,name');
541
+ expect((0, create_1.castValueToPropertyType)('my,name', types_1.PropertyType.String, 'name')).toBe('my,name');
542
542
  expect(consoleError).not.toHaveBeenCalled();
543
543
  consoleError.mockRestore();
544
544
  });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.2ba81bf",
2
+ "version": "3.6.0-alpha-8-alpha.2ad94f7",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.6.0-alpha-8-alpha.2ba81bf",
3
+ "version": "3.6.0-alpha-8-alpha.2ad94f7",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",