@contrail/cli 3.6.0-alpha-8-alpha.82b70ea → 3.6.0-alpha-8-alpha.85a73d5

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.82b70ea linux-x64 node-v24.22.1
20
+ @contrail/cli/3.6.0-alpha-8-alpha.85a73d5 linux-x64 node-v24.22.1
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -360,7 +360,9 @@ async function buildEntitiesToCreate(entityTypePath, entities, propertySpecifica
360
360
  function createEntityWithPopulatedValues(type, typeReferencesCache, objectReferencesCache, propertySpecificationBySlug, inputRow) {
361
361
  const rolesValue = inputRow?.roles ?? propertySpecificationBySlug?.get('roles');
362
362
  const roles = rolesValue === undefined ? undefined : [].concat(rolesValue);
363
- const suppliedSlugs = collectSuppliedSlugs(propertySpecificationBySlug, inputRow);
363
+ const suppliedSlugs = new Set([...(propertySpecificationBySlug?.entries() ?? []), ...Object.entries(inputRow ?? {})]
364
+ .filter(([, value]) => value !== undefined)
365
+ .map(([slug]) => slug));
364
366
  const entity = SHOULD_GENERATE_MISSING_VALUES
365
367
  ? pickRandomPropertyValues(type, objectReferencesCache, typeReferencesCache, roles, suppliedSlugs)
366
368
  : {};
@@ -400,15 +402,6 @@ function createEntityWithPopulatedValues(type, typeReferencesCache, objectRefere
400
402
  }
401
403
  return entity;
402
404
  }
403
- function collectSuppliedSlugs(propertySpecificationBySlug, inputRow) {
404
- const fromCommandLine = [...(propertySpecificationBySlug?.entries() ?? [])]
405
- .filter(([, value]) => value !== undefined)
406
- .map(([slug]) => slug);
407
- const fromRow = Object.entries(inputRow ?? {})
408
- .filter(([, value]) => value !== undefined)
409
- .map(([slug]) => slug);
410
- return new Set([...fromCommandLine, ...fromRow]);
411
- }
412
405
  function pickRandomPropertyValues(type, objectReferencesCache, typeReferencesCache, roles, suppliedSlugs) {
413
406
  const entity = {};
414
407
  // Get values for properties
@@ -128,8 +128,7 @@ class GetEntity extends basecommand_1.BaseCommand {
128
128
  .filter(Boolean)
129
129
  : [];
130
130
  try {
131
- // TODO: Refactor this so it's easier to read. It was partially vibe-coded and Adam
132
- // thinks it is hard to read. Consider breaking it into smaller functions.
131
+ // TODO: break the paginated and single-shot branches into their own functions.
133
132
  if (SHOULD_USE_PAGINATED_FIND) {
134
133
  const stream = streamPaginatedFind(entityName, {
135
134
  criteria: convertPropertySpecIntoCriteria(propertySpecBySlug),
@@ -268,9 +267,3 @@ async function* streamPaginatedFind(entityName, options = {}) {
268
267
  return;
269
268
  }
270
269
  }
271
- // Useful for troubleshooting
272
- function logMemoryUsage(entityCount) {
273
- const used = process.memoryUsage();
274
- const toMB = (bytes) => (bytes / 1024 / 1024).toFixed(2);
275
- console.error(`[${entityCount} entities] Memory Usage → RSS: ${toMB(used.rss)} MB | Heap: ${toMB(used.heapUsed)} MB / ${toMB(used.heapTotal)} MB`);
276
- }
@@ -1,8 +1,6 @@
1
1
  import { Item } from '@contrail/entity-types';
2
2
  export type SparseItem = Pick<Item, 'id' | 'itemFamilyId' | 'roles' | 'name'>;
3
- export declare function getAllItemsUsingCacheFallback(): Promise<SparseItem[]>;
4
3
  export declare function getManyItems(maxCount?: number): Promise<SparseItem[]>;
5
4
  export declare function getItemFamilies(count: number): Promise<SparseItem[] | undefined>;
6
- export declare function getFamilyName(item: SparseItem): Promise<string[] | undefined>;
7
5
  export declare const Roles: readonly ["option", "family"];
8
6
  export type Role = (typeof Roles)[number];
@@ -1,35 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Roles = exports.getFamilyName = exports.getItemFamilies = exports.getManyItems = exports.getAllItemsUsingCacheFallback = void 0;
3
+ exports.Roles = exports.getItemFamilies = exports.getManyItems = void 0;
4
4
  const sdk_1 = require("@contrail/sdk");
5
- const ITEMS_CACHE_BY_ID = new Map();
6
- async function getAllItemsUsingCacheFallback() {
7
- if (ITEMS_CACHE_BY_ID.size > 0) {
8
- return Array.from(ITEMS_CACHE_BY_ID.values());
9
- }
10
- const items = await getManyItems();
11
- items.forEach((item) => {
12
- ITEMS_CACHE_BY_ID.set(item.id, item);
13
- });
14
- return items;
15
- }
16
- exports.getAllItemsUsingCacheFallback = getAllItemsUsingCacheFallback;
17
5
  async function getManyItems(maxCount = 10000) {
18
6
  const client = new sdk_1.Entities();
19
- // paginate to get all items
20
- // Note: This will only return the first 100 assortments by default.
21
7
  const items = [];
22
8
  let nextPageKey = undefined;
23
9
  while (true) {
24
10
  const response = await client.get({
25
11
  entityName: 'item',
26
12
  apiVersion: sdk_1.API_VERSION.V2,
27
- // customParams: { propertySlugs: 'id,familyId,roles,name' }, // not compatible with V2 for some reason
28
13
  nextPageKey,
29
14
  });
30
15
  nextPageKey = response.nextPageKey;
31
16
  if (response.results.length === 0) {
32
- break; // No more assortments to fetch
17
+ break;
33
18
  }
34
19
  items.push(...response.results);
35
20
  if (!nextPageKey) {
@@ -37,7 +22,7 @@ async function getManyItems(maxCount = 10000) {
37
22
  }
38
23
  if (items.length >= maxCount) {
39
24
  console.warn(`Reached maximum item limit of ${maxCount}. Some items may not be included.`);
40
- break; // Stop if we reach the maximum limit
25
+ break;
41
26
  }
42
27
  }
43
28
  return items;
@@ -47,23 +32,6 @@ async function getItemFamilies(count) {
47
32
  return getItems({ roles: ['family'] }, count);
48
33
  }
49
34
  exports.getItemFamilies = getItemFamilies;
50
- async function getFamilyName(item) {
51
- if (!item.roles.includes('option')) {
52
- return undefined;
53
- }
54
- if (!item.itemFamilyId) {
55
- return undefined;
56
- }
57
- await ensureItemCacheIsPopulated();
58
- const family = ITEMS_CACHE_BY_ID.get(item.itemFamilyId);
59
- return family ? [family.name] : ['placeholder']; // placeholder if family not found
60
- }
61
- exports.getFamilyName = getFamilyName;
62
- async function ensureItemCacheIsPopulated() {
63
- if (ITEMS_CACHE_BY_ID.size === 0) {
64
- await getAllItemsUsingCacheFallback();
65
- }
66
- }
67
35
  exports.Roles = ['option', 'family'];
68
36
  async function getItems(criteria, count = 100) {
69
37
  const client = new sdk_1.Entities();
@@ -78,7 +46,7 @@ async function getItems(criteria, count = 100) {
78
46
  });
79
47
  nextPageKey = response.nextPageKey;
80
48
  if (response.results.length === 0) {
81
- break; // No more items to fetch
49
+ break;
82
50
  }
83
51
  const numItemsCanBeAdded = count - items.length;
84
52
  const itemsToAdd = response.results.slice(0, numItemsCanBeAdded);
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Date Range Parsing Utilities
3
3
  *
4
- * Handles parsing date range syntax like:
5
- * - createdOn=2025-09-15..2025-09-16 (date range)
6
- * - createdOn=2025-09-15T04:00:00Z..2025-09-16T03:59:59Z (timestamp range)
7
- * - createdOn=2025-09-15.. (from date onwards)
8
- * - createdOn=..2025-09-16 (until date)
4
+ * Resolves the date range syntax used in get criteria values:
5
+ * - 2025-09-15..2025-09-16 (date range)
6
+ * - 2025-09-15T04:00:00Z..2025-09-16T03:59:59Z (timestamp range)
7
+ * - 2025-09-15.. (from date onwards)
8
+ * - ..2025-09-16 (until date)
9
9
  */
10
10
  export type DateRange = {
11
11
  start?: Date;
@@ -2,11 +2,11 @@
2
2
  /**
3
3
  * Date Range Parsing Utilities
4
4
  *
5
- * Handles parsing date range syntax like:
6
- * - createdOn=2025-09-15..2025-09-16 (date range)
7
- * - createdOn=2025-09-15T04:00:00Z..2025-09-16T03:59:59Z (timestamp range)
8
- * - createdOn=2025-09-15.. (from date onwards)
9
- * - createdOn=..2025-09-16 (until date)
5
+ * Resolves the date range syntax used in get criteria values:
6
+ * - 2025-09-15..2025-09-16 (date range)
7
+ * - 2025-09-15T04:00:00Z..2025-09-16T03:59:59Z (timestamp range)
8
+ * - 2025-09-15.. (from date onwards)
9
+ * - ..2025-09-16 (until date)
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.convertDateRangeToJSURL = exports.parseDate = exports.parseDateRange = exports.isDateRangeValue = void 0;
@@ -19,7 +19,6 @@
19
19
  * contrail entities get color -- id=123
20
20
  * contrail entities update color 123 -- name=obsidian hex=000000
21
21
  * contrail entities update color 123 -- description= notes='""'
22
- * contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16 (ranges resolve in get)
23
22
  */
24
23
  export type PropertySpecification = {
25
24
  slug: string;
@@ -20,7 +20,6 @@
20
20
  * contrail entities get color -- id=123
21
21
  * contrail entities update color 123 -- name=obsidian hex=000000
22
22
  * contrail entities update color 123 -- description= notes='""'
23
- * contrail entities get loader-processes -- createdOn=2025-09-15..2025-09-16 (ranges resolve in get)
24
23
  */
25
24
  Object.defineProperty(exports, "__esModule", { value: true });
26
25
  exports.isValidPropertySpecification = exports.partitionIdsAndSpecs = exports.parsePropertySpecificationsIntoMap = exports.parsePropertySpecification = void 0;
@@ -80,8 +79,7 @@ exports.parsePropertySpecificationsIntoMap = parsePropertySpecificationsIntoMap;
80
79
  * property specifications.
81
80
  */
82
81
  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
82
+ // a token carrying '=' belongs to neither bucket below, so it would vanish silently
85
83
  const malformed = tokens.filter((token) => token.includes('=') && !isValidPropertySpecification(token));
86
84
  if (malformed.length > 0) {
87
85
  throw new Error(`Invalid property specification: ${malformed.join(' ')}. Expected slug=value.`);
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.82b70ea",
2
+ "version": "3.6.0-alpha-8-alpha.85a73d5",
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.82b70ea",
3
+ "version": "3.6.0-alpha-8-alpha.85a73d5",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",