@contrail/cli 3.6.0-alpha-8-alpha.c321203 → 3.6.0-alpha-8-alpha.7ff28fb
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/helpers/entities/assortment-items.d.ts +0 -1
- package/dist/helpers/entities/assortment-items.js +1 -12
- package/dist/helpers/entities/items.d.ts +0 -2
- package/dist/helpers/entities/items.js +1 -18
- package/dist/helpers/entities/project-items.d.ts +0 -1
- package/dist/helpers/entities/project-items.js +1 -22
- 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.7ff28fb linux-x64 node-v24.22.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
2
|
import { API_VERSION } from '@contrail/sdk';
|
|
3
|
-
export declare function throwIfInvalidAssortmentId(assortmentId: string): Promise<void>;
|
|
4
3
|
export declare function createAssortmentItem(assortmentItem: {
|
|
5
4
|
assortmentId: string;
|
|
6
5
|
itemId: string;
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findItemsNotInAssortment = exports.createAssortmentItem =
|
|
3
|
+
exports.findItemsNotInAssortment = exports.createAssortmentItem = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
const batchFetch_1 = require("./batchFetch");
|
|
6
6
|
const items_1 = require("./items");
|
|
7
|
-
async function throwIfInvalidAssortmentId(assortmentId) {
|
|
8
|
-
if (!(await doesAssortmentExistById(assortmentId))) {
|
|
9
|
-
throw new Error(`Assortment with ID ${assortmentId} does not exist`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.throwIfInvalidAssortmentId = throwIfInvalidAssortmentId;
|
|
13
|
-
async function doesAssortmentExistById(id) {
|
|
14
|
-
const client = new sdk_1.Entities();
|
|
15
|
-
const assortment = await client.get({ entityName: 'assortment', id });
|
|
16
|
-
return !!assortment;
|
|
17
|
-
}
|
|
18
7
|
async function createAssortmentItem(assortmentItem, options = {}) {
|
|
19
8
|
const client = new sdk_1.Entities();
|
|
20
9
|
const { assortmentId, itemId } = assortmentItem;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Item } from '@contrail/entity-types';
|
|
2
|
-
export declare function throwIfInvalidItemId(itemId: string): Promise<void>;
|
|
3
2
|
export type SparseItem = Pick<Item, 'id' | 'itemFamilyId' | 'roles' | 'name'>;
|
|
4
3
|
export declare function getAllItemsUsingCacheFallback(): Promise<SparseItem[]>;
|
|
5
4
|
export declare function getManyItems(maxCount?: number): Promise<SparseItem[]>;
|
|
@@ -7,4 +6,3 @@ export declare function getItemFamilies(count: number): Promise<SparseItem[] | u
|
|
|
7
6
|
export declare function getFamilyName(item: SparseItem): Promise<string[] | undefined>;
|
|
8
7
|
export declare const Roles: readonly ["option", "family"];
|
|
9
8
|
export type Role = (typeof Roles)[number];
|
|
10
|
-
export declare function throwIfInvalidItemLevel(role: string): asserts role is Role;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Roles = exports.getFamilyName = exports.getItemFamilies = exports.getManyItems = exports.getAllItemsUsingCacheFallback = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
|
-
async function throwIfInvalidItemId(itemId) {
|
|
6
|
-
if (!(await doesItemExistById(itemId))) {
|
|
7
|
-
throw new Error(`Item with ID ${itemId} does not exist`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.throwIfInvalidItemId = throwIfInvalidItemId;
|
|
11
|
-
async function doesItemExistById(id) {
|
|
12
|
-
const client = new sdk_1.Entities();
|
|
13
|
-
const item = await client.get({ entityName: 'item', id });
|
|
14
|
-
return !!item;
|
|
15
|
-
}
|
|
16
5
|
const ITEMS_CACHE_BY_ID = new Map();
|
|
17
6
|
async function getAllItemsUsingCacheFallback() {
|
|
18
7
|
if (ITEMS_CACHE_BY_ID.size > 0) {
|
|
@@ -73,12 +62,6 @@ async function ensureItemCacheIsPopulated() {
|
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
exports.Roles = ['option', 'family'];
|
|
76
|
-
function throwIfInvalidItemLevel(role) {
|
|
77
|
-
if (!exports.Roles.includes(role)) {
|
|
78
|
-
throw new Error(`Invalid role: ${role}. Valid roles are: ${exports.Roles.join(', ')}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.throwIfInvalidItemLevel = throwIfInvalidItemLevel;
|
|
82
65
|
async function getItems(criteria, count = 100) {
|
|
83
66
|
const client = new sdk_1.Entities();
|
|
84
67
|
const items = [];
|
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findItemsNotInProject =
|
|
4
|
-
const sdk_1 = require("@contrail/sdk");
|
|
3
|
+
exports.findItemsNotInProject = void 0;
|
|
5
4
|
const batchFetch_1 = require("./batchFetch");
|
|
6
5
|
const items_1 = require("./items");
|
|
7
6
|
const PROJECT_ITEMS_CACHE_BY_PROJECT_ID = new Map();
|
|
8
7
|
const PROJECT_ITEMS_CACHE_BY_ITEM_ID = new Map();
|
|
9
|
-
async function throwIfInvalidProjectId(projectId) {
|
|
10
|
-
if (!(await doesProjectExistById(projectId))) {
|
|
11
|
-
throw new Error(`Project with ID ${projectId} does not exist`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.throwIfInvalidProjectId = throwIfInvalidProjectId;
|
|
15
|
-
async function doesProjectExistById(id) {
|
|
16
|
-
const client = new sdk_1.Entities();
|
|
17
|
-
const project = await client
|
|
18
|
-
.get({
|
|
19
|
-
entityName: 'project',
|
|
20
|
-
id,
|
|
21
|
-
customParams: { propertySlugs: 'id' },
|
|
22
|
-
})
|
|
23
|
-
.catch((e) => {
|
|
24
|
-
console.error(e);
|
|
25
|
-
return null; // Return null if project does not exist
|
|
26
|
-
});
|
|
27
|
-
return !!project;
|
|
28
|
-
}
|
|
29
8
|
async function cacheProjectItemsByProjectId(projectId) {
|
|
30
9
|
if (PROJECT_ITEMS_CACHE_BY_PROJECT_ID.has(projectId)) {
|
|
31
10
|
return; // Already cached
|
package/oclif.manifest.json
CHANGED