@contrail/cli 3.6.0-alpha-8-alpha.f16d816 → 3.6.0-alpha-8-alpha.694fd70
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.d.ts +0 -1
- package/dist/commands/entities/create.js +4 -8
- package/dist/commands/entities/create.spec.js +0 -4
- package/dist/commands/entities/delete.d.ts +0 -1
- package/dist/commands/entities/delete.js +2 -5
- package/dist/commands/entities/get.d.ts +0 -1
- package/dist/commands/entities/get.js +1 -4
- package/dist/commands/entities/update.d.ts +0 -1
- package/dist/commands/entities/update.js +1 -4
- package/dist/helpers/entities/assortment-items.d.ts +2 -4
- package/dist/helpers/entities/assortment-items.js +1 -4
- 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.694fd70 linux-x64 node-v24.21.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -23,7 +23,6 @@ export default class CreateEntity extends BaseCommand {
|
|
|
23
23
|
path: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
24
24
|
};
|
|
25
25
|
static strict: boolean;
|
|
26
|
-
init(): Promise<void>;
|
|
27
26
|
run(): Promise<void>;
|
|
28
27
|
}
|
|
29
28
|
export type CreateSummary = {
|
|
@@ -218,11 +218,8 @@ class CreateEntity extends basecommand_1.BaseCommand {
|
|
|
218
218
|
}),
|
|
219
219
|
};
|
|
220
220
|
static strict = false;
|
|
221
|
-
async init() {
|
|
222
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
223
|
-
await super.init();
|
|
224
|
-
}
|
|
225
221
|
async run() {
|
|
222
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
226
223
|
await (0, login_1.authUser)();
|
|
227
224
|
const { flags, argv, args } = await this.parse(CreateEntity);
|
|
228
225
|
const { count, dryRun: isDryRun, inputFile: inputFilename, outputFile: outputFilename, generateValues: shouldGenerateMissingValues, readableIds: shouldUseReadableIds, skipHydrateRelationships, suffix, apiVersion, } = flags;
|
|
@@ -374,6 +371,8 @@ function createEntityWithPopulatedValues(type, typeReferencesCache, objectRefere
|
|
|
374
371
|
// Handle property specifications
|
|
375
372
|
for (const [propertySlug, specifiedValue] of propertySpecificationBySlug.entries()) {
|
|
376
373
|
const correspondingProperty = type.typeProperties.find((prop) => getPropertySlug(prop) === propertySlug);
|
|
374
|
+
// slug= means unset; on create there is nothing to unset, so skip it.
|
|
375
|
+
// slug='""' is the empty string and is written like any other value.
|
|
377
376
|
if (specifiedValue === undefined) {
|
|
378
377
|
continue;
|
|
379
378
|
}
|
|
@@ -524,9 +523,6 @@ function generateRandomDateString() {
|
|
|
524
523
|
return new Date().toISOString();
|
|
525
524
|
}
|
|
526
525
|
function castValueToPropertyType(value, propertyType) {
|
|
527
|
-
if (Array.isArray(value) && propertyType !== types_1.PropertyType.MultiSelect) {
|
|
528
|
-
return value.map((element) => castValueToPropertyType(element, propertyType));
|
|
529
|
-
}
|
|
530
526
|
switch (propertyType) {
|
|
531
527
|
case types_1.PropertyType.Boolean:
|
|
532
528
|
return value.toString().toLowerCase() === 'true';
|
|
@@ -559,7 +555,7 @@ async function createEntity(entityName, entity, routing = {}) {
|
|
|
559
555
|
const skipHydrateRelationships = SHOULD_SKIP_HYDRATE_RELATIONSHIPS;
|
|
560
556
|
const { suffix, apiVersion } = routing;
|
|
561
557
|
if (entityName === 'assortment-item' && !suffix)
|
|
562
|
-
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships
|
|
558
|
+
return (0, entities_1.createAssortmentItem)(entity, { skipHydrateRelationships }); // special case
|
|
563
559
|
const response = await client.create({
|
|
564
560
|
entityName,
|
|
565
561
|
object: entity,
|
|
@@ -532,10 +532,6 @@ describe('castValueToPropertyType array coercion', () => {
|
|
|
532
532
|
expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('slug=option slug=family'));
|
|
533
533
|
consoleError.mockRestore();
|
|
534
534
|
});
|
|
535
|
-
it('should cast each element of a repeated-key array on scalar property types', () => {
|
|
536
|
-
expect((0, create_1.castValueToPropertyType)(['1', '2'], types_1.PropertyType.Number)).toEqual([1, 2]);
|
|
537
|
-
expect((0, create_1.castValueToPropertyType)(['true', 'false'], types_1.PropertyType.Boolean)).toEqual([true, false]);
|
|
538
|
-
});
|
|
539
535
|
it('should keep commas literal on string properties without warning', () => {
|
|
540
536
|
const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
541
537
|
expect((0, create_1.castValueToPropertyType)('my,name', types_1.PropertyType.String)).toBe('my,name');
|
|
@@ -51,11 +51,8 @@ class DeleteEntity extends basecommand_1.BaseCommand {
|
|
|
51
51
|
}),
|
|
52
52
|
};
|
|
53
53
|
static strict = false;
|
|
54
|
-
async init() {
|
|
55
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
56
|
-
await super.init();
|
|
57
|
-
}
|
|
58
54
|
async run() {
|
|
55
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
59
56
|
await (0, login_1.authUser)();
|
|
60
57
|
const { args, flags, argv } = await this.parse(DeleteEntity);
|
|
61
58
|
const { entityName } = args;
|
|
@@ -117,7 +114,7 @@ async function deleteEntityByIds(entityName, ids, routing = {}) {
|
|
|
117
114
|
}
|
|
118
115
|
deletedIds.push(id);
|
|
119
116
|
}, (error) => {
|
|
120
|
-
if (error.message
|
|
117
|
+
if (error.message.includes('not found')) {
|
|
121
118
|
notFoundIds.push(id);
|
|
122
119
|
}
|
|
123
120
|
else {
|
|
@@ -83,11 +83,8 @@ class GetEntity extends basecommand_1.BaseCommand {
|
|
|
83
83
|
}),
|
|
84
84
|
};
|
|
85
85
|
static strict = false;
|
|
86
|
-
async init() {
|
|
87
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
88
|
-
await super.init();
|
|
89
|
-
}
|
|
90
86
|
async run() {
|
|
87
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
91
88
|
await (0, login_1.authUser)();
|
|
92
89
|
const { args, flags, argv } = await this.parse(GetEntity);
|
|
93
90
|
const { typePath } = args;
|
|
@@ -16,7 +16,6 @@ export default class UpdateEntity extends BaseCommand {
|
|
|
16
16
|
ids: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
17
17
|
};
|
|
18
18
|
static strict: boolean;
|
|
19
|
-
init(): Promise<void>;
|
|
20
19
|
run(): Promise<void>;
|
|
21
20
|
}
|
|
22
21
|
export type UpdateSummary = {
|
|
@@ -57,11 +57,8 @@ class UpdateEntity extends basecommand_1.BaseCommand {
|
|
|
57
57
|
}),
|
|
58
58
|
};
|
|
59
59
|
static strict = false;
|
|
60
|
-
async init() {
|
|
61
|
-
(0, common_1.routeConsoleLogToStderr)();
|
|
62
|
-
await super.init();
|
|
63
|
-
}
|
|
64
60
|
async run() {
|
|
61
|
+
(0, common_1.routeConsoleLogToStderr)();
|
|
65
62
|
await (0, login_1.authUser)();
|
|
66
63
|
const { args, argv } = await this.parse(UpdateEntity);
|
|
67
64
|
const { entityName } = args;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
|
-
import { API_VERSION } from '@contrail/sdk';
|
|
3
2
|
export declare function throwIfInvalidAssortmentId(assortmentId: string): Promise<void>;
|
|
4
3
|
export declare function createAssortmentItem(assortmentItem: {
|
|
5
4
|
assortmentId: string;
|
|
6
5
|
itemId: string;
|
|
7
6
|
[key: string]: any;
|
|
8
|
-
},
|
|
9
|
-
skipHydrateRelationships
|
|
10
|
-
apiVersion?: API_VERSION;
|
|
7
|
+
}, { skipHydrateRelationships }?: {
|
|
8
|
+
skipHydrateRelationships: boolean;
|
|
11
9
|
}): Promise<any>;
|
|
12
10
|
export declare function findItemsNotInAssortment(assortmentId: string, count?: number): Promise<Item[]>;
|
|
@@ -15,17 +15,15 @@ async function doesAssortmentExistById(id) {
|
|
|
15
15
|
const assortment = await client.get({ entityName: 'assortment', id });
|
|
16
16
|
return !!assortment;
|
|
17
17
|
}
|
|
18
|
-
async function createAssortmentItem(assortmentItem,
|
|
18
|
+
async function createAssortmentItem(assortmentItem, { skipHydrateRelationships } = { skipHydrateRelationships: false }) {
|
|
19
19
|
const client = new sdk_1.Entities();
|
|
20
20
|
const { assortmentId, itemId } = assortmentItem;
|
|
21
|
-
const { skipHydrateRelationships = false, apiVersion } = options;
|
|
22
21
|
// add item to assortment
|
|
23
22
|
await client.create({
|
|
24
23
|
entityName: 'assortment',
|
|
25
24
|
id: assortmentId,
|
|
26
25
|
relation: 'items',
|
|
27
26
|
object: { itemIds: [itemId] },
|
|
28
|
-
apiVersion,
|
|
29
27
|
});
|
|
30
28
|
// Update assortment item with properties
|
|
31
29
|
const updated = await client.update({
|
|
@@ -33,7 +31,6 @@ async function createAssortmentItem(assortmentItem, options = {}) {
|
|
|
33
31
|
id: `${assortmentId}:${itemId}`,
|
|
34
32
|
object: assortmentItem,
|
|
35
33
|
skipHydrateRelationships,
|
|
36
|
-
apiVersion,
|
|
37
34
|
});
|
|
38
35
|
return updated;
|
|
39
36
|
}
|
package/oclif.manifest.json
CHANGED