@contrail/cli 3.6.0-alpha-8-alpha.330b1f6 → 3.6.0-alpha-8-alpha.82b70ea

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.330b1f6 linux-x64 node-v24.22.1
20
+ @contrail/cli/3.6.0-alpha-8-alpha.82b70ea 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
@@ -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;
@@ -129,7 +131,7 @@ class GetEntity extends basecommand_1.BaseCommand {
129
131
  // TODO: Refactor this so it's easier to read. It was partially vibe-coded and Adam
130
132
  // thinks it is hard to read. Consider breaking it into smaller functions.
131
133
  if (SHOULD_USE_PAGINATED_FIND) {
132
- const stream = streamPaginatedFind(typePath, {
134
+ const stream = streamPaginatedFind(entityName, {
133
135
  criteria: convertPropertySpecIntoCriteria(propertySpecBySlug),
134
136
  skipHydrateRelationships,
135
137
  skip,
@@ -152,7 +154,7 @@ class GetEntity extends basecommand_1.BaseCommand {
152
154
  console.error(`Output saved to ${outputFile}`);
153
155
  }
154
156
  else {
155
- const response = await getEntityByTypePath(typePath, propertySpecBySlug, {
157
+ const response = await getEntitiesByName(entityName, propertySpecBySlug, {
156
158
  skipHydrateRelationships,
157
159
  relations,
158
160
  propertySlugs: propertySlugsArray,
@@ -182,14 +184,10 @@ class GetEntity extends basecommand_1.BaseCommand {
182
184
  }
183
185
  }
184
186
  exports.default = GetEntity;
185
- async function getEntityByTypePath(typePath, propertySpec, options = {}) {
187
+ async function getEntitiesByName(entityName, propertySpec, options = {}) {
186
188
  const { propertySlugs, relations, skipHydrateRelationships, skip, suffix, apiVersion, take } = options;
187
189
  const id = propertySpec?.get('id')?.toString() || undefined;
188
190
  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
191
  return find(entityName, {
194
192
  id,
195
193
  // a missing id returns null (no retries); the command turns it into a clean not-found error
@@ -239,16 +237,13 @@ async function find(entityName, options = {}) {
239
237
  return client.get(payload);
240
238
  }
241
239
  }
242
- async function* streamPaginatedFind(typePath, options = {}) {
240
+ async function* streamPaginatedFind(entityName, options = {}) {
243
241
  const client = new sdk_1.Entities();
244
242
  let nextPageKey = undefined;
245
243
  let count = 0;
246
- const { root: entityName } = (0, types_1.parseTypePath)(typePath);
247
- const criteria = entityName === 'custom-entity' ? { ...options.criteria, typePath } : options.criteria;
248
244
  while (true) {
249
245
  const opts = {
250
246
  ...options,
251
- criteria,
252
247
  entityName,
253
248
  // paginated reads require the V2 response shape unless overridden
254
249
  apiVersion: options.apiVersion ?? sdk_1.API_VERSION.V2,
@@ -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)([]);
@@ -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),
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.6.0-alpha-8-alpha.330b1f6",
2
+ "version": "3.6.0-alpha-8-alpha.82b70ea",
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.330b1f6",
3
+ "version": "3.6.0-alpha-8-alpha.82b70ea",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",