@contrail/cli 3.6.0-alpha-8-alpha.5396d7b → 3.6.0-alpha-8-alpha.c321203
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 +1 -1
- package/dist/commands/entities/create.js +0 -28
- package/oclif.manifest.json +1 -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.c321203 linux-x64 node-v24.22.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -22,24 +22,6 @@ let SHOULD_SKIP_HYDRATE_RELATIONSHIPS = false;
|
|
|
22
22
|
let SHOULD_GENERATE_MISSING_VALUES = false;
|
|
23
23
|
let NUM_ENTITIES_TO_CREATE = 1; // Default to creating one entity if not specified
|
|
24
24
|
const getNumEntitiesToCreate = () => NUM_ENTITIES_TO_CREATE; // method to get the latest number in case this changes later
|
|
25
|
-
const baseValidationMap = {
|
|
26
|
-
assortmentId: async (_slug, assortmentId) => (0, entities_1.throwIfInvalidAssortmentId)(assortmentId),
|
|
27
|
-
itemId: async (_slug, itemId) => (0, entities_1.throwIfInvalidItemId)(itemId),
|
|
28
|
-
projectId: async (_slug, projectId) => (0, entities_1.throwIfInvalidProjectId)(projectId),
|
|
29
|
-
};
|
|
30
|
-
const throwIfInvalidPropertyLevelFn = async (_slug, maybeRoles) => [].concat(maybeRoles).forEach((maybeRole) => (0, entities_1.throwIfInvalidItemLevel)(maybeRole));
|
|
31
|
-
const throwIfInvalidUserOrgRoleFn = async (_slug, maybeRole) => {
|
|
32
|
-
if (maybeRole !== 'MEMBER' && maybeRole !== 'ADMIN') {
|
|
33
|
-
throw new Error(`${maybeRole} is not a valid User Org Role`); // TODO: get these roles from a shared library
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const SLUG_VALIDATION_BY_ROOT_MAP = {
|
|
37
|
-
item: { ...baseValidationMap, roles: throwIfInvalidPropertyLevelFn },
|
|
38
|
-
'project-item': { ...baseValidationMap, roles: throwIfInvalidPropertyLevelFn },
|
|
39
|
-
'assortment-item': baseValidationMap,
|
|
40
|
-
'user-org': baseValidationMap,
|
|
41
|
-
'custom-entity': { ...baseValidationMap, role: throwIfInvalidUserOrgRoleFn },
|
|
42
|
-
};
|
|
43
25
|
const SLUGS_THAT_MUST_BE_SPECIFIED_BY_TYPE_PATH = {
|
|
44
26
|
item: ['roles'],
|
|
45
27
|
'project-item': ['projectId'],
|
|
@@ -333,8 +315,6 @@ async function buildEntitiesToCreate(entityTypePath, entities, propertySpecifica
|
|
|
333
315
|
...createEntityWithPopulatedValues(type, typesCache, objectReferencesCache, propertySpecificationBySlug),
|
|
334
316
|
...entity,
|
|
335
317
|
}));
|
|
336
|
-
const limit = (0, p_limit_1.default)(30);
|
|
337
|
-
await Promise.all(populatedEntities.map(async () => limit(() => throwIfEntityIsInvalid)));
|
|
338
318
|
// Skip system value generation unless -g flag is set (generateValues mode)
|
|
339
319
|
if (!SHOULD_GENERATE_MISSING_VALUES) {
|
|
340
320
|
console.error('Using only specified properties. Use --generate-values to auto-generate missing values.');
|
|
@@ -428,14 +408,6 @@ function pickRandomPropertyValues(type, objectReferencesCache, typeReferencesCac
|
|
|
428
408
|
}
|
|
429
409
|
return entity;
|
|
430
410
|
}
|
|
431
|
-
async function throwIfEntityIsInvalid(typeRoot, entity) {
|
|
432
|
-
const propertySlugs = Object.keys(entity);
|
|
433
|
-
const validationMap = SLUG_VALIDATION_BY_ROOT_MAP[typeRoot] || {};
|
|
434
|
-
const promises = propertySlugs
|
|
435
|
-
.filter((slug) => validationMap[slug])
|
|
436
|
-
.map((slug) => validationMap[slug](slug, entity[slug]));
|
|
437
|
-
await Promise.all(promises);
|
|
438
|
-
}
|
|
439
411
|
function pickRandomValueForProperty(property, objectReferencesCache, typeReferencesCache) {
|
|
440
412
|
const getRandomObjectReference = (referencedTypePath) => {
|
|
441
413
|
if (!objectReferencesCache.has(referencedTypePath)) {
|
package/oclif.manifest.json
CHANGED