@contrail/cli 3.6.0-alpha-8-alpha.7d24daa → 3.6.0-alpha-8-alpha.d292a3d
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 +13 -5
- package/dist/commands/entities/create.d.ts +1 -0
- package/dist/commands/entities/create.js +15 -5
- package/dist/commands/entities/delete.d.ts +1 -0
- package/dist/commands/entities/delete.js +17 -6
- package/dist/commands/entities/get.d.ts +1 -0
- package/dist/commands/entities/get.js +14 -4
- package/dist/commands/entities/grammar.spec.js +5 -0
- package/dist/commands/entities/update.d.ts +1 -0
- package/dist/commands/entities/update.js +16 -3
- package/oclif.manifest.json +45 -1
- 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.d292a3d linux-x64 node-v24.21.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -548,7 +548,7 @@ Create entities
|
|
|
548
548
|
```
|
|
549
549
|
USAGE
|
|
550
550
|
$ contrail entities create PATH [-l error|warn|info|debug] [-e true|false] [-n <value>] [-d] [-i <value>] [-o
|
|
551
|
-
<value>] [-g] [-r] [-S] [--suffix <value>]
|
|
551
|
+
<value>] [-g] [-r] [-S] [--suffix <value>] [--apiVersion 1|2]
|
|
552
552
|
|
|
553
553
|
ARGUMENTS
|
|
554
554
|
PATH Path of the entity type to create
|
|
@@ -568,6 +568,8 @@ FLAGS
|
|
|
568
568
|
-n, --count=<value> Number of random entities to create
|
|
569
569
|
-o, --outputFile=<value> File to save the output (optional)
|
|
570
570
|
-r, --readableIds If true, uses readable IDs for the created entities
|
|
571
|
+
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
572
|
+
<options: 1|2>
|
|
571
573
|
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
572
574
|
/<entities>/synchronous)
|
|
573
575
|
|
|
@@ -601,7 +603,7 @@ Delete entities by id
|
|
|
601
603
|
```
|
|
602
604
|
USAGE
|
|
603
605
|
$ contrail entities delete ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-d] [-i <value>] [--suffix
|
|
604
|
-
<value>]
|
|
606
|
+
<value>] [--apiVersion 1|2]
|
|
605
607
|
|
|
606
608
|
ARGUMENTS
|
|
607
609
|
ENTITYNAME The name of the entity type to delete
|
|
@@ -615,6 +617,8 @@ FLAGS
|
|
|
615
617
|
entity in the file.
|
|
616
618
|
-l, --logLevel=<option> The Log Level
|
|
617
619
|
<options: error|warn|info|debug>
|
|
620
|
+
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
621
|
+
<options: 1|2>
|
|
618
622
|
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
619
623
|
/<entities>/synchronous)
|
|
620
624
|
|
|
@@ -636,7 +640,7 @@ Get an entity
|
|
|
636
640
|
```
|
|
637
641
|
USAGE
|
|
638
642
|
$ contrail entities get TYPEPATH [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>] [-P]
|
|
639
|
-
[-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>]
|
|
643
|
+
[-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>] [--apiVersion 1|2]
|
|
640
644
|
|
|
641
645
|
ARGUMENTS
|
|
642
646
|
TYPEPATH The name of the entity type to fetch
|
|
@@ -654,6 +658,8 @@ FLAGS
|
|
|
654
658
|
-r, --relations=<value> Comma-separated list of relations to include in the output
|
|
655
659
|
-s, --skip=<value> Number of entities to skip (used with paginated fetch)
|
|
656
660
|
-t, --take=<value> Number of entities to fetch in a single request (default is 100)
|
|
661
|
+
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
662
|
+
<options: 1|2>
|
|
657
663
|
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
658
664
|
/<entities>/synchronous)
|
|
659
665
|
|
|
@@ -681,7 +687,7 @@ Update an entity
|
|
|
681
687
|
```
|
|
682
688
|
USAGE
|
|
683
689
|
$ contrail entities update ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-S] [-d] [-i <value>] [-F]
|
|
684
|
-
[--suffix <value>]
|
|
690
|
+
[--suffix <value>] [--apiVersion 1|2]
|
|
685
691
|
|
|
686
692
|
ARGUMENTS
|
|
687
693
|
ENTITYNAME The name of the entity type to update
|
|
@@ -696,6 +702,8 @@ FLAGS
|
|
|
696
702
|
-i, --inputFile=<value> File containing properties to update the entity (optional)
|
|
697
703
|
-l, --logLevel=<option> The Log Level
|
|
698
704
|
<options: error|warn|info|debug>
|
|
705
|
+
--apiVersion=<option> Api-Version header to send; selects the V1 or V2 variant of the endpoint
|
|
706
|
+
<options: 1|2>
|
|
699
707
|
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
700
708
|
/<entities>/synchronous)
|
|
701
709
|
|
|
@@ -15,6 +15,7 @@ export default class CreateEntity extends BaseCommand {
|
|
|
15
15
|
readableIds: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
skipHydrateRelationships: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
17
|
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
|
+
apiVersion: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
19
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
20
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
20
21
|
};
|
|
@@ -204,6 +204,11 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
204
204
|
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
205
205
|
required: false,
|
|
206
206
|
}),
|
|
207
|
+
apiVersion: core_1.Flags.string({
|
|
208
|
+
description: 'Api-Version header to send; selects the V1 or V2 variant of the endpoint',
|
|
209
|
+
options: ['1', '2'],
|
|
210
|
+
required: false,
|
|
211
|
+
}),
|
|
207
212
|
};
|
|
208
213
|
static args = {
|
|
209
214
|
path: core_1.Args.string({
|
|
@@ -217,7 +222,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
217
222
|
(0, common_1.routeConsoleLogToStderr)();
|
|
218
223
|
await (0, login_1.authUser)();
|
|
219
224
|
const { flags, argv, args } = await this.parse(CreateEntity);
|
|
220
|
-
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, } = flags;
|
|
225
|
+
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, apiVersion, } = flags;
|
|
221
226
|
const { path: entityTypePath } = args;
|
|
222
227
|
// Global flags is a little hacky, but it was easier
|
|
223
228
|
// and it doesn't see *that* bad because they are only valid
|
|
@@ -263,7 +268,10 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
263
268
|
}
|
|
264
269
|
try {
|
|
265
270
|
const entitiesToCreate = await buildEntitiesToCreate(entityTypePath, partialEntities, propertySpecBySlug);
|
|
266
|
-
const summary = await createEntities(entityName, entitiesToCreate,
|
|
271
|
+
const summary = await createEntities(entityName, entitiesToCreate, {
|
|
272
|
+
suffix,
|
|
273
|
+
apiVersion: apiVersion,
|
|
274
|
+
});
|
|
267
275
|
if (outputFilename) {
|
|
268
276
|
fs_1.default.writeFileSync(outputFilename, JSON.stringify(summary, null, 2));
|
|
269
277
|
console.error(`Output saved to ${outputFilename}`);
|
|
@@ -298,13 +306,13 @@ function summarizeSettledCreates(inputs, settled) {
|
|
|
298
306
|
return { created, failed };
|
|
299
307
|
}
|
|
300
308
|
exports.summarizeSettledCreates = summarizeSettledCreates;
|
|
301
|
-
async function createEntities(entityName, entities,
|
|
309
|
+
async function createEntities(entityName, entities, routing = {}) {
|
|
302
310
|
if (IS_DRY_RUN) {
|
|
303
311
|
console.error(`Dry run mode: not creating entities, but simulating creation for ${entityName}`);
|
|
304
312
|
return { created: entities, failed: [] };
|
|
305
313
|
}
|
|
306
314
|
const limit = (0, p_limit_1.default)(20);
|
|
307
|
-
const settled = await Promise.allSettled(entities.map(async (e) => limit(() => createEntity(entityName, e,
|
|
315
|
+
const settled = await Promise.allSettled(entities.map(async (e) => limit(() => createEntity(entityName, e, routing))));
|
|
308
316
|
return summarizeSettledCreates(entities, settled);
|
|
309
317
|
}
|
|
310
318
|
async function buildEntitiesToCreate(entityTypePath, entities, propertySpecificationBySlug) {
|
|
@@ -544,9 +552,10 @@ function castValueToPropertyType(value, propertyType) {
|
|
|
544
552
|
}
|
|
545
553
|
}
|
|
546
554
|
exports.castValueToPropertyType = castValueToPropertyType;
|
|
547
|
-
async function createEntity(entityName, entity,
|
|
555
|
+
async function createEntity(entityName, entity, routing = {}) {
|
|
548
556
|
const client = new sdk_1.Entities();
|
|
549
557
|
const skipHydrateRelationships = SHOULD_SKIP_HYDRATE_RELATIONSHIPS;
|
|
558
|
+
const { suffix, apiVersion } = routing;
|
|
550
559
|
if (entityName === 'assortment-item' && !suffix)
|
|
551
560
|
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships }); // special case
|
|
552
561
|
const response = await client.create({
|
|
@@ -554,6 +563,7 @@ async function createEntity(entityName, entity, suffix) {
|
|
|
554
563
|
object: entity,
|
|
555
564
|
skipHydrateRelationships,
|
|
556
565
|
suffix,
|
|
566
|
+
apiVersion,
|
|
557
567
|
});
|
|
558
568
|
return response;
|
|
559
569
|
}
|
|
@@ -6,6 +6,7 @@ export default class DeleteEntity extends BaseCommand {
|
|
|
6
6
|
dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
7
|
inputFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
apiVersion: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
};
|
|
@@ -34,6 +34,11 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
34
34
|
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
35
35
|
required: false,
|
|
36
36
|
}),
|
|
37
|
+
apiVersion: core_1.Flags.string({
|
|
38
|
+
description: 'Api-Version header to send; selects the V1 or V2 variant of the endpoint',
|
|
39
|
+
options: ['1', '2'],
|
|
40
|
+
required: false,
|
|
41
|
+
}),
|
|
37
42
|
};
|
|
38
43
|
static args = {
|
|
39
44
|
entityName: core_1.Args.string({
|
|
@@ -51,7 +56,7 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
51
56
|
await (0, login_1.authUser)();
|
|
52
57
|
const { args, flags, argv } = await this.parse(DeleteEntity);
|
|
53
58
|
const { entityName } = args;
|
|
54
|
-
const { inputFile: inputFilename, suffix } = flags;
|
|
59
|
+
const { inputFile: inputFilename, suffix, apiVersion } = flags;
|
|
55
60
|
if (flags.dryRun) {
|
|
56
61
|
IS_DRY_RUN = true;
|
|
57
62
|
console.error('Running in dry run mode. No entities will be deleted.');
|
|
@@ -75,7 +80,10 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
75
80
|
}
|
|
76
81
|
const ids = rowsWithId ? rowsWithId.map((item) => item.id) : positionalIds;
|
|
77
82
|
try {
|
|
78
|
-
const response = await deleteEntityByIds(entityName, ids,
|
|
83
|
+
const response = await deleteEntityByIds(entityName, ids, {
|
|
84
|
+
suffix,
|
|
85
|
+
apiVersion: apiVersion,
|
|
86
|
+
});
|
|
79
87
|
if (IS_DRY_RUN) {
|
|
80
88
|
console.error('simulated deletion of entities:');
|
|
81
89
|
}
|
|
@@ -94,12 +102,12 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
exports.default = DeleteEntity;
|
|
97
|
-
async function deleteEntityByIds(entityName, ids,
|
|
105
|
+
async function deleteEntityByIds(entityName, ids, routing = {}) {
|
|
98
106
|
const idsDeleted = new Set();
|
|
99
107
|
const idsNotFound = new Set();
|
|
100
108
|
const idsErrored = new Set();
|
|
101
109
|
const limit = (0, p_limit_1.default)(10);
|
|
102
|
-
const deletePromises = ids.map((id) => limit(() => deleteEntityById(entityName, id,
|
|
110
|
+
const deletePromises = ids.map((id) => limit(() => deleteEntityById(entityName, id, routing).then((entity) => {
|
|
103
111
|
if (!entity) {
|
|
104
112
|
idsNotFound.add(id);
|
|
105
113
|
return null;
|
|
@@ -122,12 +130,15 @@ async function deleteEntityByIds(entityName, ids, suffix) {
|
|
|
122
130
|
idsErrored: Array.from(idsErrored),
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
async function deleteEntityById(entityName, id,
|
|
133
|
+
async function deleteEntityById(entityName, id, routing = {}) {
|
|
126
134
|
const client = new sdk_1.Entities();
|
|
127
135
|
if (IS_DRY_RUN) {
|
|
128
136
|
return client.get({ entityName, id, ignore404: true }).catch(throwIfNot404);
|
|
129
137
|
}
|
|
130
|
-
|
|
138
|
+
const { suffix, apiVersion } = routing;
|
|
139
|
+
return client
|
|
140
|
+
.delete({ entityName, id, ignore404: true, suffix, apiVersion })
|
|
141
|
+
.catch(throwIfNot404);
|
|
131
142
|
}
|
|
132
143
|
function throwIfNot404(e) {
|
|
133
144
|
const { statusCode } = parseSDKErrorMessage(e);
|
|
@@ -11,6 +11,7 @@ export default class GetEntity extends BaseCommand {
|
|
|
11
11
|
take: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
12
|
relations: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
13
|
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
apiVersion: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
15
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
16
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
16
17
|
};
|
|
@@ -66,6 +66,11 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
66
66
|
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
67
67
|
required: false,
|
|
68
68
|
}),
|
|
69
|
+
apiVersion: core_1.Flags.string({
|
|
70
|
+
description: 'Api-Version header to send; selects the V1 or V2 variant of the endpoint',
|
|
71
|
+
options: ['1', '2'],
|
|
72
|
+
required: false,
|
|
73
|
+
}),
|
|
69
74
|
};
|
|
70
75
|
static args = {
|
|
71
76
|
typePath: core_1.Args.string({
|
|
@@ -83,7 +88,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
83
88
|
await (0, login_1.authUser)();
|
|
84
89
|
const { args, flags, argv } = await this.parse(GetEntity);
|
|
85
90
|
const { typePath } = args;
|
|
86
|
-
const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, suffix, take, } = flags;
|
|
91
|
+
const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, suffix, apiVersion, take, } = flags;
|
|
87
92
|
SHOULD_USE_PAGINATED_FIND = shouldUsePaginatedFind;
|
|
88
93
|
MAX_NUMBER_OF_ENTITIES_TO_FETCH = take;
|
|
89
94
|
if (MAX_NUMBER_OF_ENTITIES_TO_FETCH)
|
|
@@ -125,6 +130,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
125
130
|
skipHydrateRelationships,
|
|
126
131
|
skip,
|
|
127
132
|
suffix,
|
|
133
|
+
apiVersion: apiVersion,
|
|
128
134
|
relations,
|
|
129
135
|
propertySlugs: propertySlugsArray,
|
|
130
136
|
});
|
|
@@ -148,6 +154,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
148
154
|
propertySlugs: propertySlugsArray,
|
|
149
155
|
skip,
|
|
150
156
|
suffix,
|
|
157
|
+
apiVersion: apiVersion,
|
|
151
158
|
take,
|
|
152
159
|
});
|
|
153
160
|
if (outputFile) {
|
|
@@ -166,7 +173,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
166
173
|
}
|
|
167
174
|
exports.default = GetEntity;
|
|
168
175
|
async function getEntityByTypePath(typePath, propertySpec, options = {}) {
|
|
169
|
-
const { propertySlugs, relations, skipHydrateRelationships, skip, suffix, take } = options;
|
|
176
|
+
const { propertySlugs, relations, skipHydrateRelationships, skip, suffix, apiVersion, take } = options;
|
|
170
177
|
const id = propertySpec?.get('id')?.toString() || undefined;
|
|
171
178
|
const criteria = convertPropertySpecIntoCriteria(propertySpec || new Map());
|
|
172
179
|
const { root: entityName } = (0, types_1.parseTypePath)(typePath);
|
|
@@ -181,6 +188,7 @@ async function getEntityByTypePath(typePath, propertySpec, options = {}) {
|
|
|
181
188
|
criteria,
|
|
182
189
|
skip,
|
|
183
190
|
suffix,
|
|
191
|
+
apiVersion,
|
|
184
192
|
take,
|
|
185
193
|
});
|
|
186
194
|
}
|
|
@@ -193,13 +201,14 @@ function convertPropertySpecIntoCriteria(propertySpec) {
|
|
|
193
201
|
}
|
|
194
202
|
async function find(entityName, options = {}) {
|
|
195
203
|
const client = new sdk_1.Entities();
|
|
196
|
-
const { criteria, id, propertySlugs, skipHydrateRelationships, relations, skip, suffix, take } = options;
|
|
204
|
+
const { criteria, id, propertySlugs, skipHydrateRelationships, relations, skip, suffix, apiVersion, take, } = options;
|
|
197
205
|
const queryOptions = {
|
|
198
206
|
entityName,
|
|
199
207
|
skipHydrateRelationships,
|
|
200
208
|
relations,
|
|
201
209
|
skip,
|
|
202
210
|
suffix,
|
|
211
|
+
apiVersion,
|
|
203
212
|
take,
|
|
204
213
|
};
|
|
205
214
|
if (propertySlugs && propertySlugs.length > 0) {
|
|
@@ -223,7 +232,8 @@ async function* streamPaginatedFind(typePath, options = {}) {
|
|
|
223
232
|
const opts = {
|
|
224
233
|
...options,
|
|
225
234
|
entityName,
|
|
226
|
-
|
|
235
|
+
// paginated reads require the V2 response shape unless overridden
|
|
236
|
+
apiVersion: options.apiVersion ?? sdk_1.API_VERSION.V2,
|
|
227
237
|
nextPageKey,
|
|
228
238
|
};
|
|
229
239
|
if (options.propertySlugs?.length > 0) {
|
|
@@ -71,5 +71,10 @@ describe('entities command grammar: entities <verb> <typePath> [ID...]', () => {
|
|
|
71
71
|
expect(update_1.default.flags.suffix).toBeDefined();
|
|
72
72
|
expect(delete_1.default.flags.suffix).toBeDefined();
|
|
73
73
|
});
|
|
74
|
+
it('should expose --apiVersion on every verb, constrained to 1 or 2', () => {
|
|
75
|
+
for (const command of [create_1.default, get_1.default, update_1.default, delete_1.default]) {
|
|
76
|
+
expect(command.flags.apiVersion.options).toEqual(['1', '2']);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
74
79
|
});
|
|
75
80
|
});
|
|
@@ -8,6 +8,7 @@ export default class UpdateEntity extends BaseCommand {
|
|
|
8
8
|
inputFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
9
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
|
+
apiVersion: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
13
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
14
|
};
|
|
@@ -45,6 +45,11 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
45
45
|
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
46
46
|
required: false,
|
|
47
47
|
}),
|
|
48
|
+
apiVersion: core_1.Flags.string({
|
|
49
|
+
description: 'Api-Version header to send; selects the V1 or V2 variant of the endpoint',
|
|
50
|
+
options: ['1', '2'],
|
|
51
|
+
required: false,
|
|
52
|
+
}),
|
|
48
53
|
};
|
|
49
54
|
static args = {
|
|
50
55
|
entityName: core_1.Args.string({
|
|
@@ -62,7 +67,7 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
62
67
|
await (0, login_1.authUser)();
|
|
63
68
|
const { args, argv } = await this.parse(UpdateEntity);
|
|
64
69
|
const { entityName } = args;
|
|
65
|
-
const { dryRun: isDryRun, inputFile: inputFilename, skipHydrateRelationships, suffix, force, } = this.flags;
|
|
70
|
+
const { dryRun: isDryRun, inputFile: inputFilename, skipHydrateRelationships, suffix, apiVersion, force, } = this.flags;
|
|
66
71
|
const { ids: positionalIds, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(argv.slice(1));
|
|
67
72
|
const propertySpec = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
68
73
|
if (propertySpec.has('id') || propertySpec.has('ids')) {
|
|
@@ -95,6 +100,7 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
95
100
|
: updateEntityById(entityName, id, newEntityState, {
|
|
96
101
|
skipHydrateRelationships,
|
|
97
102
|
suffix,
|
|
103
|
+
apiVersion: apiVersion,
|
|
98
104
|
force,
|
|
99
105
|
});
|
|
100
106
|
}
|
|
@@ -138,8 +144,15 @@ function summarizeSettledUpdates(inputs, settled, skipped) {
|
|
|
138
144
|
exports.summarizeSettledUpdates = summarizeSettledUpdates;
|
|
139
145
|
async function updateEntityById(entityName, id, changes, options = {}) {
|
|
140
146
|
const client = new sdk_1.Entities();
|
|
141
|
-
const { skipHydrateRelationships, suffix, force } = options;
|
|
142
|
-
return client.update({
|
|
147
|
+
const { skipHydrateRelationships, suffix, apiVersion, force } = options;
|
|
148
|
+
return client.update({
|
|
149
|
+
entityName,
|
|
150
|
+
id,
|
|
151
|
+
object: changes,
|
|
152
|
+
skipHydrateRelationships,
|
|
153
|
+
suffix,
|
|
154
|
+
apiVersion,
|
|
155
|
+
});
|
|
143
156
|
}
|
|
144
157
|
async function mockUpdateById(entityName, id, changes, options = {}) {
|
|
145
158
|
const client = new sdk_1.Entities();
|
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.d292a3d",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -782,6 +782,17 @@
|
|
|
782
782
|
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
783
783
|
"required": false,
|
|
784
784
|
"multiple": false
|
|
785
|
+
},
|
|
786
|
+
"apiVersion": {
|
|
787
|
+
"name": "apiVersion",
|
|
788
|
+
"type": "option",
|
|
789
|
+
"description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
|
|
790
|
+
"required": false,
|
|
791
|
+
"multiple": false,
|
|
792
|
+
"options": [
|
|
793
|
+
"1",
|
|
794
|
+
"2"
|
|
795
|
+
]
|
|
785
796
|
}
|
|
786
797
|
},
|
|
787
798
|
"args": {
|
|
@@ -855,6 +866,17 @@
|
|
|
855
866
|
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
856
867
|
"required": false,
|
|
857
868
|
"multiple": false
|
|
869
|
+
},
|
|
870
|
+
"apiVersion": {
|
|
871
|
+
"name": "apiVersion",
|
|
872
|
+
"type": "option",
|
|
873
|
+
"description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
|
|
874
|
+
"required": false,
|
|
875
|
+
"multiple": false,
|
|
876
|
+
"options": [
|
|
877
|
+
"1",
|
|
878
|
+
"2"
|
|
879
|
+
]
|
|
858
880
|
}
|
|
859
881
|
},
|
|
860
882
|
"args": {
|
|
@@ -976,6 +998,17 @@
|
|
|
976
998
|
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
977
999
|
"required": false,
|
|
978
1000
|
"multiple": false
|
|
1001
|
+
},
|
|
1002
|
+
"apiVersion": {
|
|
1003
|
+
"name": "apiVersion",
|
|
1004
|
+
"type": "option",
|
|
1005
|
+
"description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
|
|
1006
|
+
"required": false,
|
|
1007
|
+
"multiple": false,
|
|
1008
|
+
"options": [
|
|
1009
|
+
"1",
|
|
1010
|
+
"2"
|
|
1011
|
+
]
|
|
979
1012
|
}
|
|
980
1013
|
},
|
|
981
1014
|
"args": {
|
|
@@ -1070,6 +1103,17 @@
|
|
|
1070
1103
|
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
1071
1104
|
"required": false,
|
|
1072
1105
|
"multiple": false
|
|
1106
|
+
},
|
|
1107
|
+
"apiVersion": {
|
|
1108
|
+
"name": "apiVersion",
|
|
1109
|
+
"type": "option",
|
|
1110
|
+
"description": "Api-Version header to send; selects the V1 or V2 variant of the endpoint",
|
|
1111
|
+
"required": false,
|
|
1112
|
+
"multiple": false,
|
|
1113
|
+
"options": [
|
|
1114
|
+
"1",
|
|
1115
|
+
"2"
|
|
1116
|
+
]
|
|
1073
1117
|
}
|
|
1074
1118
|
},
|
|
1075
1119
|
"args": {
|