@contrail/cli 3.6.0-alpha-8-alpha.d785367 → 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 +7 -7
- package/dist/commands/entities/get.d.ts +1 -1
- package/dist/commands/entities/get.js +10 -15
- package/oclif.manifest.json +4 -4
- package/package.json +1 -1
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.
|
|
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
|
|
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
|
|
638
|
+
## `contrail entities get ENTITYNAME [IDS]`
|
|
639
639
|
|
|
640
640
|
Get an entity
|
|
641
641
|
|
|
642
642
|
```
|
|
643
643
|
USAGE
|
|
644
|
-
$ contrail entities get
|
|
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
|
-
|
|
649
|
-
IDS
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
description: 'The
|
|
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 {
|
|
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(
|
|
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
|
|
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
|
|
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(
|
|
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,
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.6.0-alpha-8-alpha.
|
|
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
|
-
"
|
|
1015
|
-
"name": "
|
|
1016
|
-
"description": "The
|
|
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": {
|