@contrail/cli 3.6.0-alpha-8-alpha.d785367 → 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.d785367 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
@@ -53,7 +53,7 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
53
53
  * [`contrail config use [NAME]`](#contrail-config-use-name)
54
54
  * [`contrail entities create TYPEPATH`](#contrail-entities-create-typepath)
55
55
  * [`contrail entities delete ENTITYNAME [IDS]`](#contrail-entities-delete-entityname-ids)
56
- * [`contrail entities get TYPEPATH [IDS]`](#contrail-entities-get-typepath-ids)
56
+ * [`contrail entities get ENTITYNAME [IDS]`](#contrail-entities-get-entityname-ids)
57
57
  * [`contrail entities update ENTITYNAME [IDS]`](#contrail-entities-update-entityname-ids)
58
58
  * [`contrail feature-flags export`](#contrail-feature-flags-export)
59
59
  * [`contrail feature-flags import`](#contrail-feature-flags-import)
@@ -635,18 +635,18 @@ EXAMPLES
635
635
  $ contrail entities delete item -i ids.json
636
636
  ```
637
637
 
638
- ## `contrail entities get TYPEPATH [IDS]`
638
+ ## `contrail entities get ENTITYNAME [IDS]`
639
639
 
640
640
  Get an entity
641
641
 
642
642
  ```
643
643
  USAGE
644
- $ contrail entities get TYPEPATH [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>] [-P]
645
- [-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
644
+ $ contrail entities get ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>]
645
+ [-P] [-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
646
646
 
647
647
  ARGUMENTS
648
- TYPEPATH The type path of the entities to fetch (e.g. color, custom-entity:franchise)
649
- IDS One or more entity ids; shorthand for the id/ids criteria
648
+ ENTITYNAME The name of the entity type to fetch (type paths are not supported)
649
+ IDS One or more entity ids; shorthand for the id/ids criteria
650
650
 
651
651
  FLAGS
652
652
  -P, --paginated If true, fetches all entities in a paginated manner
@@ -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
@@ -16,7 +16,7 @@ export default class GetEntity extends BaseCommand {
16
16
  logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
17
  };
18
18
  static args: {
19
- typePath: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
19
+ entityName: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
20
20
  ids: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
21
21
  };
22
22
  static strict: boolean;
@@ -7,7 +7,6 @@ const basecommand_1 = require("../../basecommand");
7
7
  const sdk_1 = require("@contrail/sdk");
8
8
  const login_1 = require("../../auth/login");
9
9
  const common_1 = require("../../common");
10
- const types_1 = require("../../api/types");
11
10
  const dateRanges_1 = require("../../helpers/propertySpecifications/dateRanges");
12
11
  const propertySpecifications_1 = require("../../helpers/propertySpecifications/propertySpecifications");
13
12
  const batchFetch_1 = require("../../helpers/entities/batchFetch");
@@ -74,8 +73,8 @@ class GetEntity extends basecommand_1.BaseCommand {
74
73
  }),
75
74
  };
76
75
  static args = {
77
- typePath: core_1.Args.string({
78
- description: 'The type path of the entities to fetch (e.g. color, custom-entity:franchise)',
76
+ entityName: core_1.Args.string({
77
+ description: 'The name of the entity type to fetch (type paths are not supported)',
79
78
  required: true,
80
79
  }),
81
80
  ids: core_1.Args.string({
@@ -91,7 +90,10 @@ class GetEntity extends basecommand_1.BaseCommand {
91
90
  async run() {
92
91
  await (0, login_1.authUser)();
93
92
  const { args, flags, argv } = await this.parse(GetEntity);
94
- const { typePath } = args;
93
+ const { entityName } = args;
94
+ if (entityName.includes(':')) {
95
+ this.error(`get takes an entity name, not a type path. Use: contrail entities get ${entityName.split(':')[0]} [ID...]`);
96
+ }
95
97
  const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, suffix, apiVersion, take, } = flags;
96
98
  SHOULD_USE_PAGINATED_FIND = shouldUsePaginatedFind;
97
99
  MAX_NUMBER_OF_ENTITIES_TO_FETCH = take;
@@ -126,10 +128,9 @@ class GetEntity extends basecommand_1.BaseCommand {
126
128
  .filter(Boolean)
127
129
  : [];
128
130
  try {
129
- // TODO: Refactor this so it's easier to read. It was partially vibe-coded and Adam
130
- // 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.
131
132
  if (SHOULD_USE_PAGINATED_FIND) {
132
- const stream = streamPaginatedFind(typePath, {
133
+ const stream = streamPaginatedFind(entityName, {
133
134
  criteria: convertPropertySpecIntoCriteria(propertySpecBySlug),
134
135
  skipHydrateRelationships,
135
136
  skip,
@@ -152,7 +153,7 @@ class GetEntity extends basecommand_1.BaseCommand {
152
153
  console.error(`Output saved to ${outputFile}`);
153
154
  }
154
155
  else {
155
- const response = await getEntityByTypePath(typePath, propertySpecBySlug, {
156
+ const response = await getEntitiesByName(entityName, propertySpecBySlug, {
156
157
  skipHydrateRelationships,
157
158
  relations,
158
159
  propertySlugs: propertySlugsArray,
@@ -182,14 +183,10 @@ class GetEntity extends basecommand_1.BaseCommand {
182
183
  }
183
184
  }
184
185
  exports.default = GetEntity;
185
- async function getEntityByTypePath(typePath, propertySpec, options = {}) {
186
+ async function getEntitiesByName(entityName, propertySpec, options = {}) {
186
187
  const { propertySlugs, relations, skipHydrateRelationships, skip, suffix, apiVersion, take } = options;
187
188
  const id = propertySpec?.get('id')?.toString() || undefined;
188
189
  const criteria = convertPropertySpecIntoCriteria(propertySpec || new Map());
189
- const { root: entityName } = (0, types_1.parseTypePath)(typePath);
190
- if (entityName === 'custom-entity' && !id) {
191
- criteria.typePath = typePath;
192
- }
193
190
  return find(entityName, {
194
191
  id,
195
192
  // a missing id returns null (no retries); the command turns it into a clean not-found error
@@ -239,16 +236,13 @@ async function find(entityName, options = {}) {
239
236
  return client.get(payload);
240
237
  }
241
238
  }
242
- async function* streamPaginatedFind(typePath, options = {}) {
239
+ async function* streamPaginatedFind(entityName, options = {}) {
243
240
  const client = new sdk_1.Entities();
244
241
  let nextPageKey = undefined;
245
242
  let count = 0;
246
- const { root: entityName } = (0, types_1.parseTypePath)(typePath);
247
- const criteria = entityName === 'custom-entity' ? { ...options.criteria, typePath } : options.criteria;
248
243
  while (true) {
249
244
  const opts = {
250
245
  ...options,
251
- criteria,
252
246
  entityName,
253
247
  // paginated reads require the V2 response shape unless overridden
254
248
  apiVersion: options.apiVersion ?? sdk_1.API_VERSION.V2,
@@ -273,9 +267,3 @@ async function* streamPaginatedFind(typePath, options = {}) {
273
267
  return;
274
268
  }
275
269
  }
276
- // Useful for troubleshooting
277
- function logMemoryUsage(entityCount) {
278
- const used = process.memoryUsage();
279
- const toMB = (bytes) => (bytes / 1024 / 1024).toFixed(2);
280
- console.error(`[${entityCount} entities] Memory Usage → RSS: ${toMB(used.rss)} MB | Heap: ${toMB(used.heapUsed)} MB / ${toMB(used.heapTotal)} MB`);
281
- }
@@ -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.d785367",
2
+ "version": "3.6.0-alpha-8-alpha.85a73d5",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -1011,9 +1011,9 @@
1011
1011
  }
1012
1012
  },
1013
1013
  "args": {
1014
- "typePath": {
1015
- "name": "typePath",
1016
- "description": "The type path of the entities to fetch (e.g. color, custom-entity:franchise)",
1014
+ "entityName": {
1015
+ "name": "entityName",
1016
+ "description": "The name of the entity type to fetch (type paths are not supported)",
1017
1017
  "required": true
1018
1018
  },
1019
1019
  "ids": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.6.0-alpha-8-alpha.d785367",
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",