@vertexvis/plm-cli 0.1.3
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 +373 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/lib/commands/configure.d.ts +30 -0
- package/lib/commands/configure.js +162 -0
- package/lib/commands/set-overwrite.d.ts +13 -0
- package/lib/commands/set-overwrite.js +75 -0
- package/lib/commands/view-part-jobs.d.ts +13 -0
- package/lib/commands/view-part-jobs.js +58 -0
- package/lib/commands/view-part-structure.d.ts +13 -0
- package/lib/commands/view-part-structure.js +53 -0
- package/lib/commands/view-part.d.ts +13 -0
- package/lib/commands/view-part.js +83 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/lib/lib/args.d.ts +11 -0
- package/lib/lib/args.js +20 -0
- package/lib/lib/base.d.ts +7 -0
- package/lib/lib/base.js +13 -0
- package/lib/lib/config.d.ts +15 -0
- package/lib/lib/config.js +59 -0
- package/lib/lib/plm-api/find-registered-part-revision.d.ts +6 -0
- package/lib/lib/plm-api/find-registered-part-revision.js +24 -0
- package/lib/lib/plm-api/get-registered-part-revision-jobs.d.ts +3 -0
- package/lib/lib/plm-api/get-registered-part-revision-jobs.js +25 -0
- package/lib/lib/plm-api/index.d.ts +4 -0
- package/lib/lib/plm-api/index.js +7 -0
- package/lib/lib/plm-api/plm-api.d.ts +9 -0
- package/lib/lib/plm-api/plm-api.js +14 -0
- package/lib/lib/plm-api/set-overwrite-policy.d.ts +7 -0
- package/lib/lib/plm-api/set-overwrite-policy.js +24 -0
- package/lib/lib/prompt.d.ts +2 -0
- package/lib/lib/prompt.js +19 -0
- package/lib/lib/tree/tree-node.d.ts +64 -0
- package/lib/lib/tree/tree-node.js +150 -0
- package/lib/lib/vertex-api/client.d.ts +2 -0
- package/lib/lib/vertex-api/client.js +26 -0
- package/lib/lib/vertex-api/get-part-revision-instance-tree.d.ts +10 -0
- package/lib/lib/vertex-api/get-part-revision-instance-tree.js +97 -0
- package/lib/lib/vertex-api/index.d.ts +2 -0
- package/lib/lib/vertex-api/index.js +5 -0
- package/oclif.manifest.json +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const args_1 = require("../lib/args");
|
|
5
|
+
const base_1 = (0, tslib_1.__importDefault)(require("../lib/base"));
|
|
6
|
+
const plm_api_1 = require("../lib/plm-api");
|
|
7
|
+
class ViewPartJobs extends base_1.default {
|
|
8
|
+
async run() {
|
|
9
|
+
const { args } = this.parse(ViewPartJobs);
|
|
10
|
+
const ids = (0, args_1.parsePlmIds)({
|
|
11
|
+
plmPartId: args.plmPartId,
|
|
12
|
+
plmRevisionId: args.plmRevisionId,
|
|
13
|
+
plmIterationId: args.plmIterationId,
|
|
14
|
+
});
|
|
15
|
+
console.log(`Looking for registered part revision jobs with IDs:\n${JSON.stringify(ids, null, 2)}`);
|
|
16
|
+
const registeredPart = await (0, plm_api_1.findRegisteredPartRevision)({
|
|
17
|
+
partId: ids.plmPartId,
|
|
18
|
+
partRevisionId: ids.plmRevisionId,
|
|
19
|
+
iterationId: ids.plmIterationId,
|
|
20
|
+
});
|
|
21
|
+
if (registeredPart === null) {
|
|
22
|
+
console.log('Part revision not found in PLM.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log('Found registered part revision in PLM:');
|
|
26
|
+
console.log(JSON.stringify(registeredPart, null, 2));
|
|
27
|
+
const registeredPartRevisionJobs = await (0, plm_api_1.getRegisteredPartRevisionJobs)({
|
|
28
|
+
id: registeredPart.id,
|
|
29
|
+
});
|
|
30
|
+
if (registeredPartRevisionJobs === null) {
|
|
31
|
+
console.log('No jobs found for the registered part revision.');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log('Registered Part Revision Jobs:');
|
|
35
|
+
console.log(JSON.stringify(registeredPartRevisionJobs, null, 2));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = ViewPartJobs;
|
|
40
|
+
ViewPartJobs.description = 'View PLM kernel jobs for a given part revision';
|
|
41
|
+
ViewPartJobs.args = [
|
|
42
|
+
{
|
|
43
|
+
name: 'plmPartId',
|
|
44
|
+
required: true,
|
|
45
|
+
description: 'PLM part ID (string)',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'plmRevisionId',
|
|
49
|
+
required: true,
|
|
50
|
+
description: 'PLM revision ID (string)',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'plmIterationId',
|
|
54
|
+
required: false,
|
|
55
|
+
description: 'PLM iteration ID (string, optional)',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
ViewPartJobs.flags = Object.assign({}, base_1.default.flags);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseCommand from '../lib/base';
|
|
2
|
+
export default class ViewPartStructure extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
name: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
description: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const args_1 = require("../lib/args");
|
|
5
|
+
const base_1 = (0, tslib_1.__importDefault)(require("../lib/base"));
|
|
6
|
+
const plm_api_1 = require("../lib/plm-api");
|
|
7
|
+
const vertex_api_1 = require("../lib/vertex-api");
|
|
8
|
+
class ViewPartStructure extends base_1.default {
|
|
9
|
+
async run() {
|
|
10
|
+
const { args } = this.parse(ViewPartStructure);
|
|
11
|
+
const ids = (0, args_1.parsePlmIds)({
|
|
12
|
+
plmPartId: args.plmPartId,
|
|
13
|
+
plmRevisionId: args.plmRevisionId,
|
|
14
|
+
plmIterationId: args.plmIterationId,
|
|
15
|
+
});
|
|
16
|
+
console.log(`Looking for part revision with IDs:\n${JSON.stringify(ids, null, 2)}`);
|
|
17
|
+
const registeredPart = await (0, plm_api_1.findRegisteredPartRevision)({
|
|
18
|
+
partId: ids.plmPartId,
|
|
19
|
+
partRevisionId: ids.plmRevisionId,
|
|
20
|
+
iterationId: ids.plmIterationId,
|
|
21
|
+
});
|
|
22
|
+
if (registeredPart === null) {
|
|
23
|
+
console.log('Part revision not found in PLM.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
console.log('Found registered part revision in PLM:');
|
|
27
|
+
console.log(JSON.stringify(registeredPart, null, 2));
|
|
28
|
+
console.log('Fetching part revision structure data from the platform...');
|
|
29
|
+
const partStructure = await (0, vertex_api_1.fetchPartRevisionInstanceTree)(registeredPart.vertexPartRevisionId);
|
|
30
|
+
console.log(`Part Revision Instance Tree [${partStructure.size} node${partStructure.size === 1 ? '' : 's'}]:`);
|
|
31
|
+
console.log(partStructure.dump());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = ViewPartStructure;
|
|
35
|
+
ViewPartStructure.description = 'View structure for a given part revision';
|
|
36
|
+
ViewPartStructure.args = [
|
|
37
|
+
{
|
|
38
|
+
name: 'plmPartId',
|
|
39
|
+
required: true,
|
|
40
|
+
description: 'PLM part ID (string)',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'plmRevisionId',
|
|
44
|
+
required: true,
|
|
45
|
+
description: 'PLM revision ID (string)',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'plmIterationId',
|
|
49
|
+
required: false,
|
|
50
|
+
description: 'PLM iteration ID (string, optional)',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
ViewPartStructure.flags = Object.assign({}, base_1.default.flags);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseCommand from '../lib/base';
|
|
2
|
+
export default class ViewPart extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
name: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
description: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const args_1 = require("../lib/args");
|
|
5
|
+
const base_1 = (0, tslib_1.__importDefault)(require("../lib/base"));
|
|
6
|
+
const plm_api_1 = require("../lib/plm-api");
|
|
7
|
+
const vertex_api_1 = require("../lib/vertex-api");
|
|
8
|
+
class ViewPart extends base_1.default {
|
|
9
|
+
async run() {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
const { args } = this.parse(ViewPart);
|
|
12
|
+
const ids = (0, args_1.parsePlmIds)({
|
|
13
|
+
plmPartId: args.plmPartId,
|
|
14
|
+
plmRevisionId: args.plmRevisionId,
|
|
15
|
+
plmIterationId: args.plmIterationId,
|
|
16
|
+
});
|
|
17
|
+
console.log(`Looking for part revision with IDs:\n${JSON.stringify(ids, null, 2)}`);
|
|
18
|
+
const registeredPart = await (0, plm_api_1.findRegisteredPartRevision)({
|
|
19
|
+
partId: ids.plmPartId,
|
|
20
|
+
partRevisionId: ids.plmRevisionId,
|
|
21
|
+
iterationId: ids.plmIterationId,
|
|
22
|
+
});
|
|
23
|
+
const client = await (0, vertex_api_1.getClient)();
|
|
24
|
+
if (registeredPart === null) {
|
|
25
|
+
console.log('Part revision not found in PLM Integration Service.');
|
|
26
|
+
console.log('Checking Vertex Platform for any matching part revisions...');
|
|
27
|
+
const platformPart = await client.parts.getParts({
|
|
28
|
+
filterSuppliedId: ids.plmPartId,
|
|
29
|
+
});
|
|
30
|
+
if (((_a = platformPart.data) === null || _a === void 0 ? void 0 : _a.data.length) > 0) {
|
|
31
|
+
const partId = platformPart.data.data[0].id;
|
|
32
|
+
const partRevs = await client.partRevisions.getPartRevisions({
|
|
33
|
+
id: partId,
|
|
34
|
+
filterSuppliedId: ids.plmRevisionId,
|
|
35
|
+
});
|
|
36
|
+
if (((_b = partRevs.data) === null || _b === void 0 ? void 0 : _b.data.length) > 0) {
|
|
37
|
+
console.log('Found matching part revision(s) in Vertex Platform:');
|
|
38
|
+
console.log(JSON.stringify(partRevs.data.data, null, 2));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log('Part exists in Vertex Platform, but no revisions match the given revision ID.');
|
|
42
|
+
console.log('Part details:');
|
|
43
|
+
console.log(JSON.stringify(platformPart.data.data[0], null, 2));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log('Found registered part revision in PLM Integration Service:');
|
|
49
|
+
console.log(JSON.stringify(registeredPart, null, 2));
|
|
50
|
+
const platformPartRev = await client.partRevisions.getPartRevision({
|
|
51
|
+
id: registeredPart.vertexPartRevisionId,
|
|
52
|
+
fieldsPartRevision: 'metadata',
|
|
53
|
+
});
|
|
54
|
+
if ((_c = platformPartRev.data) === null || _c === void 0 ? void 0 : _c.data) {
|
|
55
|
+
console.log('Corresponding Part Revision in Vertex Platform:');
|
|
56
|
+
console.log(JSON.stringify(platformPartRev.data.data, null, 2));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
console.log('Corresponding Part Revision not found in Vertex Platform.');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = ViewPart;
|
|
65
|
+
ViewPart.description = 'Find a registered part revision';
|
|
66
|
+
ViewPart.args = [
|
|
67
|
+
{
|
|
68
|
+
name: 'plmPartId',
|
|
69
|
+
required: true,
|
|
70
|
+
description: 'PLM part ID (string)',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'plmRevisionId',
|
|
74
|
+
required: true,
|
|
75
|
+
description: 'PLM revision ID (string)',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'plmIterationId',
|
|
79
|
+
required: false,
|
|
80
|
+
description: 'PLM iteration ID (string, optional)',
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
ViewPart.flags = Object.assign({}, base_1.default.flags);
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/command';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface PlmIds {
|
|
2
|
+
plmPartId: string;
|
|
3
|
+
plmRevisionId: string;
|
|
4
|
+
plmIterationId?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function requireNonEmpty(value: unknown, name: string): string;
|
|
7
|
+
export declare function parsePlmIds(opts: {
|
|
8
|
+
plmPartId: unknown;
|
|
9
|
+
plmRevisionId: unknown;
|
|
10
|
+
plmIterationId?: unknown;
|
|
11
|
+
}): PlmIds;
|
package/lib/lib/args.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsePlmIds = exports.requireNonEmpty = void 0;
|
|
4
|
+
function requireNonEmpty(value, name) {
|
|
5
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
6
|
+
throw new Error(`${name} must be a non-empty string`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
exports.requireNonEmpty = requireNonEmpty;
|
|
11
|
+
function parsePlmIds(opts) {
|
|
12
|
+
const plmPartId = requireNonEmpty(opts.plmPartId, 'plm-part-id');
|
|
13
|
+
const plmRevisionId = requireNonEmpty(opts.plmRevisionId, 'plm-revision-id');
|
|
14
|
+
const plmIterationIdRaw = opts.plmIterationId;
|
|
15
|
+
const plmIterationId = typeof plmIterationIdRaw === 'string' && plmIterationIdRaw.trim().length > 0
|
|
16
|
+
? plmIterationIdRaw
|
|
17
|
+
: undefined;
|
|
18
|
+
return { plmPartId, plmRevisionId, plmIterationId };
|
|
19
|
+
}
|
|
20
|
+
exports.parsePlmIds = parsePlmIds;
|
package/lib/lib/base.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
class BaseCommand extends command_1.Command {
|
|
6
|
+
async init() {
|
|
7
|
+
await (0, config_1.loadConfigToEnv)();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = BaseCommand;
|
|
11
|
+
BaseCommand.flags = {
|
|
12
|
+
help: command_1.flags.help({ char: 'h' }),
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type VertexConfig = Partial<{
|
|
2
|
+
VERTEX_CLIENT_ID: string;
|
|
3
|
+
VERTEX_CLIENT_SECRET: string;
|
|
4
|
+
VERTEX_API_HOST: string;
|
|
5
|
+
VERTEX_PLM_HOST: string;
|
|
6
|
+
VERTEX_PLM_API_KEY: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function getConfigPath(): string;
|
|
9
|
+
export declare function readConfig(): Promise<VertexConfig>;
|
|
10
|
+
export declare function writeConfig(config: VertexConfig): Promise<void>;
|
|
11
|
+
export declare function deleteConfigFile(): Promise<void>;
|
|
12
|
+
export declare function loadConfigToEnv(): Promise<VertexConfig>;
|
|
13
|
+
export declare function redactConfig(cfg: VertexConfig): VertexConfig;
|
|
14
|
+
export declare const CONFIG_KEYS: readonly ["VERTEX_CLIENT_ID", "VERTEX_CLIENT_SECRET", "VERTEX_API_HOST", "VERTEX_PLM_HOST", "VERTEX_PLM_API_KEY"];
|
|
15
|
+
export declare type ConfigKey = (typeof CONFIG_KEYS)[number];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_KEYS = exports.redactConfig = exports.loadConfigToEnv = exports.deleteConfigFile = exports.writeConfig = exports.readConfig = exports.getConfigPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_os_1 = (0, tslib_1.__importDefault)(require("node:os"));
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const CONFIG_DIR = (0, node_path_1.join)(node_os_1.default.homedir(), '.vertex-plm');
|
|
9
|
+
const CONFIG_FILE = (0, node_path_1.join)(CONFIG_DIR, 'config.json');
|
|
10
|
+
function getConfigPath() {
|
|
11
|
+
return CONFIG_FILE;
|
|
12
|
+
}
|
|
13
|
+
exports.getConfigPath = getConfigPath;
|
|
14
|
+
async function readConfig() {
|
|
15
|
+
try {
|
|
16
|
+
const raw = await (0, promises_1.readFile)(CONFIG_FILE, 'utf8');
|
|
17
|
+
const parsed = JSON.parse(raw);
|
|
18
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.readConfig = readConfig;
|
|
25
|
+
async function writeConfig(config) {
|
|
26
|
+
await (0, promises_1.mkdir)(CONFIG_DIR, { recursive: true });
|
|
27
|
+
await (0, promises_1.writeFile)(CONFIG_FILE, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
28
|
+
}
|
|
29
|
+
exports.writeConfig = writeConfig;
|
|
30
|
+
async function deleteConfigFile() {
|
|
31
|
+
// rm with force avoids throwing if file doesn't exist
|
|
32
|
+
await (0, promises_1.rm)(CONFIG_FILE, { force: true });
|
|
33
|
+
}
|
|
34
|
+
exports.deleteConfigFile = deleteConfigFile;
|
|
35
|
+
async function loadConfigToEnv() {
|
|
36
|
+
const cfg = await readConfig();
|
|
37
|
+
for (const [k, v] of Object.entries(cfg)) {
|
|
38
|
+
if (typeof v !== 'string' || v.trim() === '')
|
|
39
|
+
continue;
|
|
40
|
+
if (process.env[k] === null ||
|
|
41
|
+
process.env[k] === undefined ||
|
|
42
|
+
process.env[k] === '') {
|
|
43
|
+
process.env[k] = v;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return cfg;
|
|
47
|
+
}
|
|
48
|
+
exports.loadConfigToEnv = loadConfigToEnv;
|
|
49
|
+
function redactConfig(cfg) {
|
|
50
|
+
return Object.assign(Object.assign(Object.assign({}, cfg), (cfg.VERTEX_CLIENT_SECRET ? { VERTEX_CLIENT_SECRET: '********' } : {})), (cfg.VERTEX_PLM_API_KEY ? { VERTEX_PLM_API_KEY: '********' } : {}));
|
|
51
|
+
}
|
|
52
|
+
exports.redactConfig = redactConfig;
|
|
53
|
+
exports.CONFIG_KEYS = [
|
|
54
|
+
'VERTEX_CLIENT_ID',
|
|
55
|
+
'VERTEX_CLIENT_SECRET',
|
|
56
|
+
'VERTEX_API_HOST',
|
|
57
|
+
'VERTEX_PLM_HOST',
|
|
58
|
+
'VERTEX_PLM_API_KEY',
|
|
59
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRegisteredPartRevision = void 0;
|
|
4
|
+
const plm_api_1 = require("./plm-api");
|
|
5
|
+
async function findRegisteredPartRevision({ partId, partRevisionId, iterationId, }) {
|
|
6
|
+
// Implementation to find the part revision in the PLM system
|
|
7
|
+
// console.log(`Finding part revision in PLM for Part ID: ${partId}, Part Revision ID: ${partRevisionId}, Iteration ID: ${iterationId}`);
|
|
8
|
+
const VERTEX_PLM_HOST = process.env.VERTEX_PLM_HOST;
|
|
9
|
+
if (!VERTEX_PLM_HOST) {
|
|
10
|
+
throw new Error('VERTEX_PLM_HOST is not set in configuration or environment variables');
|
|
11
|
+
}
|
|
12
|
+
const requestOptions = {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: (0, plm_api_1.getPlmHeaders)(),
|
|
15
|
+
};
|
|
16
|
+
const response = await fetch(`${VERTEX_PLM_HOST}/registered-part-revisions?plmRevisionId=${partRevisionId}${partId ? `&plmPartId=${partId}` : ''}${iterationId ? `&plmIterationId=${iterationId}` : ''}`, requestOptions);
|
|
17
|
+
const result = await response.json();
|
|
18
|
+
if (result.items && result.items.length > 0) {
|
|
19
|
+
return result.items[0];
|
|
20
|
+
}
|
|
21
|
+
// console.log(`Registered part revision not found in PLM. [Part: ${partId}, Revision: ${partRevisionId}, Iteration: ${iterationId}]`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
exports.findRegisteredPartRevision = findRegisteredPartRevision;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegisteredPartRevisionJobs = void 0;
|
|
4
|
+
const plm_api_1 = require("./plm-api");
|
|
5
|
+
async function getRegisteredPartRevisionJobs({ id, }) {
|
|
6
|
+
// Implementation to find jobs for the part revision in the PLM kernel
|
|
7
|
+
var _a;
|
|
8
|
+
const VERTEX_PLM_HOST = process.env.VERTEX_PLM_HOST;
|
|
9
|
+
if (!VERTEX_PLM_HOST) {
|
|
10
|
+
throw new Error('VERTEX_PLM_HOST is not set in configuration or environment variables');
|
|
11
|
+
}
|
|
12
|
+
const requestOptions = {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: (0, plm_api_1.getPlmHeaders)(),
|
|
15
|
+
};
|
|
16
|
+
const response = await fetch(`${VERTEX_PLM_HOST}/registered-part-revisions/${id}/jobs`, requestOptions);
|
|
17
|
+
try {
|
|
18
|
+
const result = await response.json();
|
|
19
|
+
return (_a = result.items) !== null && _a !== void 0 ? _a : null;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.getRegisteredPartRevisionJobs = getRegisteredPartRevisionJobs;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./find-registered-part-revision"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./get-registered-part-revision-jobs"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./plm-api"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./set-overwrite-policy"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlmHeaders = void 0;
|
|
4
|
+
function getPlmHeaders() {
|
|
5
|
+
const VERTEX_PLM_API_KEY = process.env.VERTEX_PLM_API_KEY;
|
|
6
|
+
if (!VERTEX_PLM_API_KEY) {
|
|
7
|
+
throw new Error('VERTEX_PLM_API_KEY is not set in configuration or environment variables');
|
|
8
|
+
}
|
|
9
|
+
const headers = new Headers();
|
|
10
|
+
headers.append('Accept', 'application/json');
|
|
11
|
+
headers.append('x-api-key', VERTEX_PLM_API_KEY);
|
|
12
|
+
return headers;
|
|
13
|
+
}
|
|
14
|
+
exports.getPlmHeaders = getPlmHeaders;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementation to set a registered part revision in the PLM kernel to be overwritten
|
|
3
|
+
* @returns {Promise<void>} Resolves when the policy has been set.
|
|
4
|
+
*/
|
|
5
|
+
export declare function setOverwritePolicy({ registeredPartRevisionId, }: {
|
|
6
|
+
registeredPartRevisionId: string;
|
|
7
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setOverwritePolicy = void 0;
|
|
4
|
+
const plm_api_1 = require("./plm-api");
|
|
5
|
+
/**
|
|
6
|
+
* Implementation to set a registered part revision in the PLM kernel to be overwritten
|
|
7
|
+
* @returns {Promise<void>} Resolves when the policy has been set.
|
|
8
|
+
*/
|
|
9
|
+
async function setOverwritePolicy({ registeredPartRevisionId, }) {
|
|
10
|
+
const VERTEX_PLM_HOST = process.env.VERTEX_PLM_HOST;
|
|
11
|
+
if (!VERTEX_PLM_HOST) {
|
|
12
|
+
throw new Error('VERTEX_PLM_HOST is not set in configuration or environment variables');
|
|
13
|
+
}
|
|
14
|
+
const requestOptions = {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
headers: (0, plm_api_1.getPlmHeaders)(),
|
|
17
|
+
body: JSON.stringify({ revisionId: registeredPartRevisionId }),
|
|
18
|
+
};
|
|
19
|
+
const response = await fetch(`${VERTEX_PLM_HOST}/policies`, requestOptions);
|
|
20
|
+
if (response.status !== 201) {
|
|
21
|
+
throw new Error(`Failed to set registered part revision to overwrite. Status: ${response.status}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.setOverwritePolicy = setOverwritePolicy;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptSecret = exports.promptText = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cli_ux_1 = (0, tslib_1.__importDefault)(require("cli-ux"));
|
|
6
|
+
async function promptText(label, current) {
|
|
7
|
+
const suffix = current ? ` (current: ${current})` : '';
|
|
8
|
+
const ans = await cli_ux_1.default.prompt(`${label}${suffix}`);
|
|
9
|
+
const v = String(ans !== null && ans !== void 0 ? ans : '').trim();
|
|
10
|
+
return v.length > 0 ? v : undefined;
|
|
11
|
+
}
|
|
12
|
+
exports.promptText = promptText;
|
|
13
|
+
async function promptSecret(label, hasCurrent) {
|
|
14
|
+
const suffix = hasCurrent ? ' (current: ********)' : '';
|
|
15
|
+
const ans = await cli_ux_1.default.prompt(`${label}${suffix}`, { type: 'hide' });
|
|
16
|
+
const v = String(ans !== null && ans !== void 0 ? ans : '').trim();
|
|
17
|
+
return v.length > 0 ? v : undefined;
|
|
18
|
+
}
|
|
19
|
+
exports.promptSecret = promptSecret;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple tree node class that can be used to create a tree structure.
|
|
3
|
+
* Each node can have multiple children and a single parent.
|
|
4
|
+
* The class provides methods to traverse the tree, check properties of nodes,
|
|
5
|
+
* and manipulate the tree structure.
|
|
6
|
+
*
|
|
7
|
+
* @template T The type of the data stored in the node.
|
|
8
|
+
* @class TreeNode
|
|
9
|
+
*/
|
|
10
|
+
export declare class TreeNode<T> implements Iterable<TreeNode<T>> {
|
|
11
|
+
parent: TreeNode<T> | null;
|
|
12
|
+
children: TreeNode<T>[];
|
|
13
|
+
data: T | null;
|
|
14
|
+
constructor(data?: T | null, parent?: TreeNode<T>);
|
|
15
|
+
/** Pre-order traversal generator
|
|
16
|
+
* @param {TreeNode<U>} node - The node to start traversal from.
|
|
17
|
+
* @returns {Generator<TreeNode<U>>} A generator yielding nodes in pre-order.
|
|
18
|
+
*/
|
|
19
|
+
static preorder<U>(node: TreeNode<U>): Generator<TreeNode<U>>;
|
|
20
|
+
/** Total number of nodes in this subtree (includes this node) */
|
|
21
|
+
get size(): number;
|
|
22
|
+
isRoot(): boolean;
|
|
23
|
+
isLeaf(): boolean;
|
|
24
|
+
hasChildren(): boolean;
|
|
25
|
+
hasSiblings(): boolean;
|
|
26
|
+
isEmpty(): boolean;
|
|
27
|
+
/** Distance from this node up to the root (root.depth === 0) */
|
|
28
|
+
get depth(): number;
|
|
29
|
+
/** Number of direct children */
|
|
30
|
+
get numChildren(): number;
|
|
31
|
+
/** Number of siblings (including this node) */
|
|
32
|
+
get numSiblings(): number;
|
|
33
|
+
/** Allow `for (const n of someNode) { … }`
|
|
34
|
+
* @returns {Iterator<TreeNode<T>>} An iterator over nodes in pre-order.
|
|
35
|
+
*/
|
|
36
|
+
[Symbol.iterator](): Iterator<TreeNode<T>>;
|
|
37
|
+
/** True if any node in this subtree holds `obj` (by `===`)
|
|
38
|
+
* @param {T} obj - The object to search for.
|
|
39
|
+
* @returns {boolean} True if found, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
contains(obj: T): boolean;
|
|
42
|
+
/** Remove all descendants (but not this node itself)
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
/** Grab the data payload in pre-order as a flat array
|
|
47
|
+
* @returns {(T | null)[]} Array of data values in pre-order.
|
|
48
|
+
*/
|
|
49
|
+
toArray(): (T | null)[];
|
|
50
|
+
/** Returns a string representation of this node
|
|
51
|
+
* @returns {string} String representation of the node.
|
|
52
|
+
*/
|
|
53
|
+
toString({ node, data, }?: {
|
|
54
|
+
node?: (node: TreeNode<T>) => string;
|
|
55
|
+
data?: (data: T | null) => string;
|
|
56
|
+
}): string;
|
|
57
|
+
/** Human-readable dump with ASCII-tree lines
|
|
58
|
+
* @returns {string} A multi-line string representation of the tree.
|
|
59
|
+
*/
|
|
60
|
+
dump({ node, data, }?: {
|
|
61
|
+
node?: (node: TreeNode<T>) => string;
|
|
62
|
+
data?: (data: T | null) => string;
|
|
63
|
+
}): string;
|
|
64
|
+
}
|