@contrail/cli 3.6.0-alpha-8-alpha.8cae9b1 → 3.6.0-alpha-8-alpha.7d24daa
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 +14 -4
- package/dist/commands/entities/create.d.ts +1 -0
- package/dist/commands/entities/create.js +16 -7
- package/dist/commands/entities/delete.d.ts +1 -0
- package/dist/commands/entities/delete.js +10 -6
- package/dist/commands/entities/get.d.ts +1 -0
- package/dist/commands/entities/get.js +13 -4
- package/dist/commands/entities/grammar.spec.js +6 -0
- package/dist/commands/entities/update.d.ts +1 -0
- package/dist/commands/entities/update.js +12 -4
- package/oclif.manifest.json +29 -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.7d24daa 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]
|
|
551
|
+
<value>] [-g] [-r] [-S] [--suffix <value>]
|
|
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
|
+
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
572
|
+
/<entities>/synchronous)
|
|
571
573
|
|
|
572
574
|
DESCRIPTION
|
|
573
575
|
Create entities
|
|
@@ -598,7 +600,8 @@ Delete entities by id
|
|
|
598
600
|
|
|
599
601
|
```
|
|
600
602
|
USAGE
|
|
601
|
-
$ contrail entities delete ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-d] [-i <value>]
|
|
603
|
+
$ contrail entities delete ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-d] [-i <value>] [--suffix
|
|
604
|
+
<value>]
|
|
602
605
|
|
|
603
606
|
ARGUMENTS
|
|
604
607
|
ENTITYNAME The name of the entity type to delete
|
|
@@ -612,6 +615,8 @@ FLAGS
|
|
|
612
615
|
entity in the file.
|
|
613
616
|
-l, --logLevel=<option> The Log Level
|
|
614
617
|
<options: error|warn|info|debug>
|
|
618
|
+
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
619
|
+
/<entities>/synchronous)
|
|
615
620
|
|
|
616
621
|
DESCRIPTION
|
|
617
622
|
Delete entities by id
|
|
@@ -631,7 +636,7 @@ Get an entity
|
|
|
631
636
|
```
|
|
632
637
|
USAGE
|
|
633
638
|
$ contrail entities get TYPEPATH [IDS] [-l error|warn|info|debug] [-e true|false] [-o <value>] [-p <value>] [-P]
|
|
634
|
-
[-s <value>] [-S] [-t <value>] [-r <value>]
|
|
639
|
+
[-s <value>] [-S] [-t <value>] [-r <value>] [--suffix <value>]
|
|
635
640
|
|
|
636
641
|
ARGUMENTS
|
|
637
642
|
TYPEPATH The name of the entity type to fetch
|
|
@@ -649,6 +654,8 @@ FLAGS
|
|
|
649
654
|
-r, --relations=<value> Comma-separated list of relations to include in the output
|
|
650
655
|
-s, --skip=<value> Number of entities to skip (used with paginated fetch)
|
|
651
656
|
-t, --take=<value> Number of entities to fetch in a single request (default is 100)
|
|
657
|
+
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
658
|
+
/<entities>/synchronous)
|
|
652
659
|
|
|
653
660
|
DESCRIPTION
|
|
654
661
|
Get an entity
|
|
@@ -674,6 +681,7 @@ Update an entity
|
|
|
674
681
|
```
|
|
675
682
|
USAGE
|
|
676
683
|
$ contrail entities update ENTITYNAME [IDS] [-l error|warn|info|debug] [-e true|false] [-S] [-d] [-i <value>] [-F]
|
|
684
|
+
[--suffix <value>]
|
|
677
685
|
|
|
678
686
|
ARGUMENTS
|
|
679
687
|
ENTITYNAME The name of the entity type to update
|
|
@@ -688,6 +696,8 @@ FLAGS
|
|
|
688
696
|
-i, --inputFile=<value> File containing properties to update the entity (optional)
|
|
689
697
|
-l, --logLevel=<option> The Log Level
|
|
690
698
|
<options: error|warn|info|debug>
|
|
699
|
+
--suffix=<value> Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets
|
|
700
|
+
/<entities>/synchronous)
|
|
691
701
|
|
|
692
702
|
DESCRIPTION
|
|
693
703
|
Update an entity
|
|
@@ -14,6 +14,7 @@ export default class CreateEntity extends BaseCommand {
|
|
|
14
14
|
generateValues: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
15
15
|
readableIds: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
16
16
|
skipHydrateRelationships: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
17
18
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
19
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
19
20
|
};
|
|
@@ -200,6 +200,10 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
200
200
|
required: false,
|
|
201
201
|
default: false,
|
|
202
202
|
}),
|
|
203
|
+
suffix: core_1.Flags.string({
|
|
204
|
+
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
205
|
+
required: false,
|
|
206
|
+
}),
|
|
203
207
|
};
|
|
204
208
|
static args = {
|
|
205
209
|
path: core_1.Args.string({
|
|
@@ -213,7 +217,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
213
217
|
(0, common_1.routeConsoleLogToStderr)();
|
|
214
218
|
await (0, login_1.authUser)();
|
|
215
219
|
const { flags, argv, args } = await this.parse(CreateEntity);
|
|
216
|
-
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, } = flags;
|
|
220
|
+
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, } = flags;
|
|
217
221
|
const { path: entityTypePath } = args;
|
|
218
222
|
// Global flags is a little hacky, but it was easier
|
|
219
223
|
// and it doesn't see *that* bad because they are only valid
|
|
@@ -259,7 +263,7 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
259
263
|
}
|
|
260
264
|
try {
|
|
261
265
|
const entitiesToCreate = await buildEntitiesToCreate(entityTypePath, partialEntities, propertySpecBySlug);
|
|
262
|
-
const summary = await createEntities(entityName, entitiesToCreate);
|
|
266
|
+
const summary = await createEntities(entityName, entitiesToCreate, suffix);
|
|
263
267
|
if (outputFilename) {
|
|
264
268
|
fs_1.default.writeFileSync(outputFilename, JSON.stringify(summary, null, 2));
|
|
265
269
|
console.error(`Output saved to ${outputFilename}`);
|
|
@@ -294,13 +298,13 @@ function summarizeSettledCreates(inputs, settled) {
|
|
|
294
298
|
return { created, failed };
|
|
295
299
|
}
|
|
296
300
|
exports.summarizeSettledCreates = summarizeSettledCreates;
|
|
297
|
-
async function createEntities(entityName, entities) {
|
|
301
|
+
async function createEntities(entityName, entities, suffix) {
|
|
298
302
|
if (IS_DRY_RUN) {
|
|
299
303
|
console.error(`Dry run mode: not creating entities, but simulating creation for ${entityName}`);
|
|
300
304
|
return { created: entities, failed: [] };
|
|
301
305
|
}
|
|
302
306
|
const limit = (0, p_limit_1.default)(20);
|
|
303
|
-
const settled = await Promise.allSettled(entities.map(async (e) => limit(() => createEntity(entityName, e))));
|
|
307
|
+
const settled = await Promise.allSettled(entities.map(async (e) => limit(() => createEntity(entityName, e, suffix))));
|
|
304
308
|
return summarizeSettledCreates(entities, settled);
|
|
305
309
|
}
|
|
306
310
|
async function buildEntitiesToCreate(entityTypePath, entities, propertySpecificationBySlug) {
|
|
@@ -540,12 +544,17 @@ function castValueToPropertyType(value, propertyType) {
|
|
|
540
544
|
}
|
|
541
545
|
}
|
|
542
546
|
exports.castValueToPropertyType = castValueToPropertyType;
|
|
543
|
-
async function createEntity(entityName, entity) {
|
|
547
|
+
async function createEntity(entityName, entity, suffix) {
|
|
544
548
|
const client = new sdk_1.Entities();
|
|
545
549
|
const skipHydrateRelationships = SHOULD_SKIP_HYDRATE_RELATIONSHIPS;
|
|
546
|
-
if (entityName === 'assortment-item')
|
|
550
|
+
if (entityName === 'assortment-item' && !suffix)
|
|
547
551
|
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships }); // special case
|
|
548
|
-
const response = await client.create({
|
|
552
|
+
const response = await client.create({
|
|
553
|
+
entityName,
|
|
554
|
+
object: entity,
|
|
555
|
+
skipHydrateRelationships,
|
|
556
|
+
suffix,
|
|
557
|
+
});
|
|
549
558
|
return response;
|
|
550
559
|
}
|
|
551
560
|
function getReferencedObjectPaths(type) {
|
|
@@ -5,6 +5,7 @@ export default class DeleteEntity extends BaseCommand {
|
|
|
5
5
|
static flags: {
|
|
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
|
+
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
};
|
|
@@ -30,6 +30,10 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
30
30
|
required: false,
|
|
31
31
|
multiple: false,
|
|
32
32
|
}),
|
|
33
|
+
suffix: core_1.Flags.string({
|
|
34
|
+
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
35
|
+
required: false,
|
|
36
|
+
}),
|
|
33
37
|
};
|
|
34
38
|
static args = {
|
|
35
39
|
entityName: core_1.Args.string({
|
|
@@ -47,7 +51,7 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
47
51
|
await (0, login_1.authUser)();
|
|
48
52
|
const { args, flags, argv } = await this.parse(DeleteEntity);
|
|
49
53
|
const { entityName } = args;
|
|
50
|
-
const { inputFile: inputFilename } = flags;
|
|
54
|
+
const { inputFile: inputFilename, suffix } = flags;
|
|
51
55
|
if (flags.dryRun) {
|
|
52
56
|
IS_DRY_RUN = true;
|
|
53
57
|
console.error('Running in dry run mode. No entities will be deleted.');
|
|
@@ -71,7 +75,7 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
71
75
|
}
|
|
72
76
|
const ids = rowsWithId ? rowsWithId.map((item) => item.id) : positionalIds;
|
|
73
77
|
try {
|
|
74
|
-
const response = await deleteEntityByIds(entityName, ids);
|
|
78
|
+
const response = await deleteEntityByIds(entityName, ids, suffix);
|
|
75
79
|
if (IS_DRY_RUN) {
|
|
76
80
|
console.error('simulated deletion of entities:');
|
|
77
81
|
}
|
|
@@ -90,12 +94,12 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
exports.default = DeleteEntity;
|
|
93
|
-
async function deleteEntityByIds(entityName, ids) {
|
|
97
|
+
async function deleteEntityByIds(entityName, ids, suffix) {
|
|
94
98
|
const idsDeleted = new Set();
|
|
95
99
|
const idsNotFound = new Set();
|
|
96
100
|
const idsErrored = new Set();
|
|
97
101
|
const limit = (0, p_limit_1.default)(10);
|
|
98
|
-
const deletePromises = ids.map((id) => limit(() => deleteEntityById(entityName, id).then((entity) => {
|
|
102
|
+
const deletePromises = ids.map((id) => limit(() => deleteEntityById(entityName, id, suffix).then((entity) => {
|
|
99
103
|
if (!entity) {
|
|
100
104
|
idsNotFound.add(id);
|
|
101
105
|
return null;
|
|
@@ -118,12 +122,12 @@ async function deleteEntityByIds(entityName, ids) {
|
|
|
118
122
|
idsErrored: Array.from(idsErrored),
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
|
-
async function deleteEntityById(entityName, id) {
|
|
125
|
+
async function deleteEntityById(entityName, id, suffix) {
|
|
122
126
|
const client = new sdk_1.Entities();
|
|
123
127
|
if (IS_DRY_RUN) {
|
|
124
128
|
return client.get({ entityName, id, ignore404: true }).catch(throwIfNot404);
|
|
125
129
|
}
|
|
126
|
-
return client.delete({ entityName, id, ignore404: true }).catch(throwIfNot404);
|
|
130
|
+
return client.delete({ entityName, id, ignore404: true, suffix }).catch(throwIfNot404);
|
|
127
131
|
}
|
|
128
132
|
function throwIfNot404(e) {
|
|
129
133
|
const { statusCode } = parseSDKErrorMessage(e);
|
|
@@ -10,6 +10,7 @@ export default class GetEntity extends BaseCommand {
|
|
|
10
10
|
skipHydrateRelationships: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
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
|
+
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
14
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
15
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
16
|
};
|
|
@@ -62,6 +62,10 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
62
62
|
description: 'Comma-separated list of relations to include in the output',
|
|
63
63
|
required: false,
|
|
64
64
|
}),
|
|
65
|
+
suffix: core_1.Flags.string({
|
|
66
|
+
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
67
|
+
required: false,
|
|
68
|
+
}),
|
|
65
69
|
};
|
|
66
70
|
static args = {
|
|
67
71
|
typePath: core_1.Args.string({
|
|
@@ -79,7 +83,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
79
83
|
await (0, login_1.authUser)();
|
|
80
84
|
const { args, flags, argv } = await this.parse(GetEntity);
|
|
81
85
|
const { typePath } = args;
|
|
82
|
-
const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, take, } = flags;
|
|
86
|
+
const { outputFile, paginated: shouldUsePaginatedFind, propertySlugs, relations: relationString, skip, skipHydrateRelationships, suffix, take, } = flags;
|
|
83
87
|
SHOULD_USE_PAGINATED_FIND = shouldUsePaginatedFind;
|
|
84
88
|
MAX_NUMBER_OF_ENTITIES_TO_FETCH = take;
|
|
85
89
|
if (MAX_NUMBER_OF_ENTITIES_TO_FETCH)
|
|
@@ -120,6 +124,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
120
124
|
criteria: convertPropertySpecIntoCriteria(propertySpecBySlug),
|
|
121
125
|
skipHydrateRelationships,
|
|
122
126
|
skip,
|
|
127
|
+
suffix,
|
|
123
128
|
relations,
|
|
124
129
|
propertySlugs: propertySlugsArray,
|
|
125
130
|
});
|
|
@@ -142,6 +147,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
142
147
|
relations,
|
|
143
148
|
propertySlugs: propertySlugsArray,
|
|
144
149
|
skip,
|
|
150
|
+
suffix,
|
|
145
151
|
take,
|
|
146
152
|
});
|
|
147
153
|
if (outputFile) {
|
|
@@ -160,7 +166,7 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
160
166
|
}
|
|
161
167
|
exports.default = GetEntity;
|
|
162
168
|
async function getEntityByTypePath(typePath, propertySpec, options = {}) {
|
|
163
|
-
const { propertySlugs, relations, skipHydrateRelationships, skip, take } = options;
|
|
169
|
+
const { propertySlugs, relations, skipHydrateRelationships, skip, suffix, take } = options;
|
|
164
170
|
const id = propertySpec?.get('id')?.toString() || undefined;
|
|
165
171
|
const criteria = convertPropertySpecIntoCriteria(propertySpec || new Map());
|
|
166
172
|
const { root: entityName } = (0, types_1.parseTypePath)(typePath);
|
|
@@ -174,6 +180,7 @@ async function getEntityByTypePath(typePath, propertySpec, options = {}) {
|
|
|
174
180
|
propertySlugs,
|
|
175
181
|
criteria,
|
|
176
182
|
skip,
|
|
183
|
+
suffix,
|
|
177
184
|
take,
|
|
178
185
|
});
|
|
179
186
|
}
|
|
@@ -186,19 +193,21 @@ function convertPropertySpecIntoCriteria(propertySpec) {
|
|
|
186
193
|
}
|
|
187
194
|
async function find(entityName, options = {}) {
|
|
188
195
|
const client = new sdk_1.Entities();
|
|
189
|
-
const { criteria, id, propertySlugs, skipHydrateRelationships, relations, skip, take } = options;
|
|
196
|
+
const { criteria, id, propertySlugs, skipHydrateRelationships, relations, skip, suffix, take } = options;
|
|
190
197
|
const queryOptions = {
|
|
191
198
|
entityName,
|
|
192
199
|
skipHydrateRelationships,
|
|
193
200
|
relations,
|
|
194
201
|
skip,
|
|
202
|
+
suffix,
|
|
195
203
|
take,
|
|
196
204
|
};
|
|
197
205
|
if (propertySlugs && propertySlugs.length > 0) {
|
|
198
206
|
queryOptions.customParams = { propertySlugs: propertySlugs.join(',') };
|
|
199
207
|
}
|
|
200
208
|
const payload = id ? { id, ...queryOptions } : { criteria, ...queryOptions };
|
|
201
|
-
|
|
209
|
+
// a suffix names a specific sub-route, so it always goes through the plain client
|
|
210
|
+
if ((0, batchFetch_1.canBatchFetchEntity)(entityName) && !suffix) {
|
|
202
211
|
return (0, batchFetch_1.batchFetch)(entityName, payload);
|
|
203
212
|
}
|
|
204
213
|
else {
|
|
@@ -65,5 +65,11 @@ describe('entities command grammar: entities <verb> <typePath> [ID...]', () => {
|
|
|
65
65
|
it('should keep -s for --skip on get', () => {
|
|
66
66
|
expect(get_1.default.flags.skip.char).toBe('s');
|
|
67
67
|
});
|
|
68
|
+
it('should expose --suffix on every verb to reach entity sub-routes', () => {
|
|
69
|
+
expect(create_1.default.flags.suffix).toBeDefined();
|
|
70
|
+
expect(get_1.default.flags.suffix).toBeDefined();
|
|
71
|
+
expect(update_1.default.flags.suffix).toBeDefined();
|
|
72
|
+
expect(delete_1.default.flags.suffix).toBeDefined();
|
|
73
|
+
});
|
|
68
74
|
});
|
|
69
75
|
});
|
|
@@ -7,6 +7,7 @@ export default class UpdateEntity extends BaseCommand {
|
|
|
7
7
|
dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
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
|
+
suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
13
|
};
|
|
@@ -41,6 +41,10 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
41
41
|
description: 'Force update without validation. Internal use only',
|
|
42
42
|
required: false,
|
|
43
43
|
}),
|
|
44
|
+
suffix: core_1.Flags.string({
|
|
45
|
+
description: 'Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)',
|
|
46
|
+
required: false,
|
|
47
|
+
}),
|
|
44
48
|
};
|
|
45
49
|
static args = {
|
|
46
50
|
entityName: core_1.Args.string({
|
|
@@ -58,7 +62,7 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
58
62
|
await (0, login_1.authUser)();
|
|
59
63
|
const { args, argv } = await this.parse(UpdateEntity);
|
|
60
64
|
const { entityName } = args;
|
|
61
|
-
const { dryRun: isDryRun, inputFile: inputFilename, skipHydrateRelationships, force, } = this.flags;
|
|
65
|
+
const { dryRun: isDryRun, inputFile: inputFilename, skipHydrateRelationships, suffix, force, } = this.flags;
|
|
62
66
|
const { ids: positionalIds, specs } = (0, propertySpecifications_1.partitionIdsAndSpecs)(argv.slice(1));
|
|
63
67
|
const propertySpec = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
|
|
64
68
|
if (propertySpec.has('id') || propertySpec.has('ids')) {
|
|
@@ -88,7 +92,11 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
88
92
|
const id = entity.id;
|
|
89
93
|
return isDryRun
|
|
90
94
|
? mockUpdateById(entityName, id, newEntityState, { skipHydrateRelationships })
|
|
91
|
-
: updateEntityById(entityName, id, newEntityState, {
|
|
95
|
+
: updateEntityById(entityName, id, newEntityState, {
|
|
96
|
+
skipHydrateRelationships,
|
|
97
|
+
suffix,
|
|
98
|
+
force,
|
|
99
|
+
});
|
|
92
100
|
}
|
|
93
101
|
try {
|
|
94
102
|
const limit = (0, p_limit_1.default)(20);
|
|
@@ -130,8 +138,8 @@ function summarizeSettledUpdates(inputs, settled, skipped) {
|
|
|
130
138
|
exports.summarizeSettledUpdates = summarizeSettledUpdates;
|
|
131
139
|
async function updateEntityById(entityName, id, changes, options = {}) {
|
|
132
140
|
const client = new sdk_1.Entities();
|
|
133
|
-
const { skipHydrateRelationships, force } = options;
|
|
134
|
-
return client.update({ entityName, id, object: changes, skipHydrateRelationships });
|
|
141
|
+
const { skipHydrateRelationships, suffix, force } = options;
|
|
142
|
+
return client.update({ entityName, id, object: changes, skipHydrateRelationships, suffix });
|
|
135
143
|
}
|
|
136
144
|
async function mockUpdateById(entityName, id, changes, options = {}) {
|
|
137
145
|
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.7d24daa",
|
|
3
3
|
"commands": {
|
|
4
4
|
"app:create": {
|
|
5
5
|
"id": "app:create",
|
|
@@ -775,6 +775,13 @@
|
|
|
775
775
|
"description": "If true, does not hydrate relationships for the created entities",
|
|
776
776
|
"required": false,
|
|
777
777
|
"allowNo": false
|
|
778
|
+
},
|
|
779
|
+
"suffix": {
|
|
780
|
+
"name": "suffix",
|
|
781
|
+
"type": "option",
|
|
782
|
+
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
783
|
+
"required": false,
|
|
784
|
+
"multiple": false
|
|
778
785
|
}
|
|
779
786
|
},
|
|
780
787
|
"args": {
|
|
@@ -841,6 +848,13 @@
|
|
|
841
848
|
"description": "A file with a JSON array of objects; only each object's id is used. Deletes every entity in the file.",
|
|
842
849
|
"required": false,
|
|
843
850
|
"multiple": false
|
|
851
|
+
},
|
|
852
|
+
"suffix": {
|
|
853
|
+
"name": "suffix",
|
|
854
|
+
"type": "option",
|
|
855
|
+
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
856
|
+
"required": false,
|
|
857
|
+
"multiple": false
|
|
844
858
|
}
|
|
845
859
|
},
|
|
846
860
|
"args": {
|
|
@@ -955,6 +969,13 @@
|
|
|
955
969
|
"description": "Comma-separated list of relations to include in the output",
|
|
956
970
|
"required": false,
|
|
957
971
|
"multiple": false
|
|
972
|
+
},
|
|
973
|
+
"suffix": {
|
|
974
|
+
"name": "suffix",
|
|
975
|
+
"type": "option",
|
|
976
|
+
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
977
|
+
"required": false,
|
|
978
|
+
"multiple": false
|
|
958
979
|
}
|
|
959
980
|
},
|
|
960
981
|
"args": {
|
|
@@ -1042,6 +1063,13 @@
|
|
|
1042
1063
|
"description": "Force update without validation. Internal use only",
|
|
1043
1064
|
"required": false,
|
|
1044
1065
|
"allowNo": false
|
|
1066
|
+
},
|
|
1067
|
+
"suffix": {
|
|
1068
|
+
"name": "suffix",
|
|
1069
|
+
"type": "option",
|
|
1070
|
+
"description": "Append a sub-route to the entity endpoint (e.g. --suffix=synchronous targets /<entities>/synchronous)",
|
|
1071
|
+
"required": false,
|
|
1072
|
+
"multiple": false
|
|
1045
1073
|
}
|
|
1046
1074
|
},
|
|
1047
1075
|
"args": {
|