@contrail/cli 3.6.0-alpha-8-alpha.418c5f6 → 3.6.0-alpha-8-alpha.d785367

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.418c5f6 linux-x64 node-v24.22.1
20
+ @contrail/cli/3.6.0-alpha-8-alpha.d785367 linux-x64 node-v24.22.1
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -28,8 +28,6 @@ const SLUGS_THAT_MUST_BE_SPECIFIED_BY_TYPE_PATH = {
28
28
  'assortment-item': ['assortmentId'],
29
29
  'user-org': ['role'],
30
30
  };
31
- // Candidate items are excluded against a single parent, so one command generates for one
32
- // parent. Mixed input would hand later rows candidates never checked against their own parent.
33
31
  function throwIfParentsAreMixed(entities, parentSlug, parentLabel) {
34
32
  const parentIds = new Set(entities.map((entity) => entity[parentSlug]));
35
33
  if (parentIds.size > 1) {
@@ -360,7 +358,6 @@ async function buildEntitiesToCreate(entityTypePath, entities, propertySpecifica
360
358
  return populatedEntities;
361
359
  }
362
360
  function createEntityWithPopulatedValues(type, typeReferencesCache, objectReferencesCache, propertySpecificationBySlug, inputRow) {
363
- // the row wins over the command line, matching the spread order at the call site
364
361
  const rolesValue = inputRow?.roles ?? propertySpecificationBySlug?.get('roles');
365
362
  const roles = rolesValue === undefined ? undefined : [].concat(rolesValue);
366
363
  const suppliedSlugs = collectSuppliedSlugs(propertySpecificationBySlug, inputRow);
@@ -419,7 +416,6 @@ function pickRandomPropertyValues(type, objectReferencesCache, typeReferencesCac
419
416
  // Validate property level
420
417
  if (roles?.length && roles.every((r) => !doesPropertyLevelMatchRole(property.propertyLevel, r)))
421
418
  continue;
422
- // the caller pinned this value, so do not generate (or fail) on its behalf
423
419
  if (suppliedSlugs?.has(getPropertySlug(property)))
424
420
  continue;
425
421
  // Generate random value
@@ -207,8 +207,6 @@ async function getEntityByTypePath(typePath, propertySpec, options = {}) {
207
207
  function convertPropertySpecIntoCriteria(propertySpec) {
208
208
  const criteria = {};
209
209
  propertySpec.forEach((value, slug) => {
210
- // date ranges are a query concept, so they resolve here rather than in the shared
211
- // parser that create and update also use
212
210
  criteria[slug] = (0, dateRanges_1.isDateRangeValue)(value)
213
211
  ? (0, dateRanges_1.convertDateRangeToJSURL)((0, dateRanges_1.parseDateRange)(value))
214
212
  : value;
@@ -246,8 +244,6 @@ async function* streamPaginatedFind(typePath, options = {}) {
246
244
  let nextPageKey = undefined;
247
245
  let count = 0;
248
246
  const { root: entityName } = (0, types_1.parseTypePath)(typePath);
249
- // a custom entity collection holds every subtype, so the paginated read needs the
250
- // same type-path filter the single-shot read applies
251
247
  const criteria = entityName === 'custom-entity' ? { ...options.criteria, typePath } : options.criteria;
252
248
  while (true) {
253
249
  const opts = {
@@ -23,10 +23,9 @@ describe('entities command grammar: entities <verb> <typePath> [ID...]', () => {
23
23
  expect(ids).toEqual(['id1', 'id2']);
24
24
  expect(specs).toEqual(['name=jet', 'status=archived']);
25
25
  });
26
- it('should not classify malformed specs as ids', () => {
27
- const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(['=value']);
28
- expect(ids).toEqual([]);
29
- expect(specs).toEqual([]);
26
+ it('should reject malformed specs rather than discard them', () => {
27
+ expect(() => (0, propertySpecifications_1.partitionIdsAndSpecs)(['=value'])).toThrow('Invalid property specification');
28
+ expect(() => (0, propertySpecifications_1.partitionIdsAndSpecs)(['id1', '=value'])).toThrow('=value');
30
29
  });
31
30
  it('should handle empty input', () => {
32
31
  const { ids, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)([]);
@@ -89,8 +89,7 @@ class UpdateEntity extends basecommand_1.BaseCommand {
89
89
  const skipped = entitiesToUpdate.filter(({ id }) => !id).length;
90
90
  const entitiesWithId = entitiesToUpdate.filter(({ id }) => id);
91
91
  // will be applied to all entities
92
- // slug= parses to undefined, and JSON.stringify drops undefined keys, so an unset
93
- // has to travel as an explicit null for the server to clear the property
92
+ // JSON.stringify drops undefined keys, so an unset has to travel as an explicit null
94
93
  const fixedValues = Object.fromEntries([...propertySpec.entries()].map(([slug, value]) => [slug, value ?? null]));
95
94
  async function updateEntity(entity) {
96
95
  const newEntityState = { ...entity, ...fixedValues };
@@ -33,7 +33,7 @@ async function getManyItems(maxCount = 10000) {
33
33
  }
34
34
  items.push(...response.results);
35
35
  if (!nextPageKey) {
36
- break; // last page; without this the next request refetches page one
36
+ break; // an absent cursor restarts pagination from page one
37
37
  }
38
38
  if (items.length >= maxCount) {
39
39
  console.warn(`Reached maximum item limit of ${maxCount}. Some items may not be included.`);
@@ -9,7 +9,6 @@ jest.mock('@contrail/sdk', () => ({
9
9
  describe('getManyItems', () => {
10
10
  beforeEach(() => jest.clearAllMocks());
11
11
  it('stops on the last page rather than refetching the first', async () => {
12
- // the final page carries results but no cursor, which previously restarted pagination
13
12
  mockGet.mockImplementation(async ({ nextPageKey }) => nextPageKey === 'page-2'
14
13
  ? { results: [{ id: 'b' }], nextPageKey: undefined }
15
14
  : { results: [{ id: 'a' }], nextPageKey: 'page-2' });
@@ -80,6 +80,12 @@ exports.parsePropertySpecificationsIntoMap = parsePropertySpecificationsIntoMap;
80
80
  * property specifications.
81
81
  */
82
82
  function partitionIdsAndSpecs(tokens) {
83
+ // a token carrying '=' is neither an id nor a usable spec, so dropping it would
84
+ // silently discard a filter the caller asked for
85
+ const malformed = tokens.filter((token) => token.includes('=') && !isValidPropertySpecification(token));
86
+ if (malformed.length > 0) {
87
+ throw new Error(`Invalid property specification: ${malformed.join(' ')}. Expected slug=value.`);
88
+ }
83
89
  return {
84
90
  ids: tokens.filter((token) => !token.includes('=')),
85
91
  specs: tokens.filter(isValidPropertySpecification),
@@ -371,3 +371,17 @@ describe('edge cases and limitations', () => {
371
371
  });
372
372
  });
373
373
  });
374
+ describe('values containing ..', () => {
375
+ it('keeps them literal, since date ranges resolve in get criteria', () => {
376
+ const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)([
377
+ 'description=Loading...',
378
+ 'notes=2025-01-01..2025-12-31',
379
+ ]);
380
+ expect(result.get('description')).toBe('Loading...');
381
+ expect(result.get('notes')).toBe('2025-01-01..2025-12-31');
382
+ });
383
+ it('does not discard them during partitioning', () => {
384
+ expect((0, propertySpecifications_1.isValidPropertySpecification)('description=Loading...')).toBe(true);
385
+ expect((0, propertySpecifications_1.isValidPropertySpecification)('createdOn=2025-13-50..2025-13-51')).toBe(true);
386
+ });
387
+ });
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.418c5f6",
2
+ "version": "3.6.0-alpha-8-alpha.d785367",
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.418c5f6",
3
+ "version": "3.6.0-alpha-8-alpha.d785367",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",