@contrail/cli 3.5.2 → 3.5.3-alpha.317fe63
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 +10 -28
- package/dist/api/types.d.ts +0 -5
- package/dist/api/types.js +1 -36
- package/dist/commands/projects/export.d.ts +1 -0
- package/dist/commands/projects/export.js +19 -5
- package/dist/commands/types/getAll.js +0 -18
- package/dist/commands/types/loadAll.js +0 -2
- package/dist/commands/types/mergeTypeProperties.js +0 -5
- package/dist/commands/types/uploadOptionSetHierarchies.js +0 -117
- package/dist/commands/types/uploadOptionSets.js +1 -1
- package/dist/commands/types/uploadRuleSets.js +2 -85
- package/dist/commands/types/uploadTypeOverrides.js +10 -2
- package/dist/commands/types/uploadTypePolicies.js +2 -86
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
- package/dist/commands/types/uploadTypePropertyPolicies.js +3 -139
- package/dist/helpers/projects/helpers.d.ts +2 -1
- package/dist/helpers/projects/helpers.js +37 -2
- package/dist/helpers/projects/post-processor.d.ts +131 -0
- package/dist/helpers/projects/post-processor.js +519 -0
- package/dist/helpers/types/type-uploader.js +1 -1
- package/dist/interfaces.d.ts +0 -25
- package/dist/templates/typescript/tsup.config.ts +0 -0
- package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
- package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
- package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
- package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
- package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
- package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
- package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
- package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
- package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
- package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
- package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
- package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
- package/node_modules/@contrail/org-config-migration/package.json +1 -1
- package/oclif.manifest.json +11 -55
- package/package.json +2 -2
- package/dist/commands/types/uploadUsageInfo.d.ts +0 -15
- package/dist/commands/types/uploadUsageInfo.js +0 -180
- package/dist/commands/types/uploadUsageInfo.spec.d.ts +0 -1
- package/dist/commands/types/uploadUsageInfo.spec.js +0 -249
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
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.5.
|
|
20
|
+
@contrail/cli/3.5.3-alpha.317fe63 linux-x64 node-v24.19.0
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
|
@@ -86,7 +86,6 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
|
|
|
86
86
|
* [`contrail types uploadTypePolicies`](#contrail-types-uploadtypepolicies)
|
|
87
87
|
* [`contrail types uploadTypePropertyPolicies`](#contrail-types-uploadtypepropertypolicies)
|
|
88
88
|
* [`contrail types uploadTypes`](#contrail-types-uploadtypes)
|
|
89
|
-
* [`contrail types uploadUsageInfo`](#contrail-types-uploadusageinfo)
|
|
90
89
|
* [`contrail users export`](#contrail-users-export)
|
|
91
90
|
* [`contrail users import USERSFILE`](#contrail-users-import-usersfile)
|
|
92
91
|
* [`contrail webhooks create`](#contrail-webhooks-create)
|
|
@@ -780,23 +779,29 @@ EXAMPLES
|
|
|
780
779
|
|
|
781
780
|
## `contrail projects export PROJECTNAME`
|
|
782
781
|
|
|
783
|
-
Export a project.
|
|
782
|
+
Export a project with optional post-processing.
|
|
784
783
|
|
|
785
784
|
```
|
|
786
785
|
USAGE
|
|
787
|
-
$ contrail projects export PROJECTNAME [-l error|warn|info|debug] [-e true|false]
|
|
786
|
+
$ contrail projects export PROJECTNAME [-l error|warn|info|debug] [-e true|false] [--process]
|
|
787
|
+
|
|
788
|
+
ARGUMENTS
|
|
789
|
+
PROJECTNAME Name or identifier of the project to export
|
|
788
790
|
|
|
789
791
|
FLAGS
|
|
790
792
|
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
791
793
|
<options: true|false>
|
|
792
794
|
-l, --logLevel=<option> The Log Level
|
|
793
795
|
<options: error|warn|info|debug>
|
|
796
|
+
--process Enable post-processing of exported project data
|
|
794
797
|
|
|
795
798
|
DESCRIPTION
|
|
796
|
-
Export a project.
|
|
799
|
+
Export a project with optional post-processing.
|
|
797
800
|
|
|
798
801
|
EXAMPLES
|
|
799
802
|
$ contrail project export <PROJECT_NAME>
|
|
803
|
+
|
|
804
|
+
$ contrail project export <PROJECT_NAME> --process
|
|
800
805
|
```
|
|
801
806
|
|
|
802
807
|
## `contrail projects list`
|
|
@@ -1403,29 +1408,6 @@ EXAMPLES
|
|
|
1403
1408
|
$ contrail types uploadTypes
|
|
1404
1409
|
```
|
|
1405
1410
|
|
|
1406
|
-
## `contrail types uploadUsageInfo`
|
|
1407
|
-
|
|
1408
|
-
Upload extracted usage info
|
|
1409
|
-
|
|
1410
|
-
```
|
|
1411
|
-
USAGE
|
|
1412
|
-
$ contrail types uploadUsageInfo [-l error|warn|info|debug] [-e true|false] [-d <value>]
|
|
1413
|
-
|
|
1414
|
-
FLAGS
|
|
1415
|
-
-d, --dir=<value> [default: .] The directory from which to export the usage info data. Defaults to the
|
|
1416
|
-
current directory. The usage info data will be loaded from $dir/usage-info.yml
|
|
1417
|
-
-e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
|
|
1418
|
-
<options: true|false>
|
|
1419
|
-
-l, --logLevel=<option> The Log Level
|
|
1420
|
-
<options: error|warn|info|debug>
|
|
1421
|
-
|
|
1422
|
-
DESCRIPTION
|
|
1423
|
-
Upload extracted usage info
|
|
1424
|
-
|
|
1425
|
-
EXAMPLES
|
|
1426
|
-
$ contrail types uploadUsageInfo
|
|
1427
|
-
```
|
|
1428
|
-
|
|
1429
1411
|
## `contrail users export`
|
|
1430
1412
|
|
|
1431
1413
|
Export all users in the org.
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
export declare function getOptionSets(): Promise<any[]>;
|
|
2
2
|
export declare function getUserLists(): Promise<any[]>;
|
|
3
3
|
export declare function getOptionSetHierarchies(): Promise<any[]>;
|
|
4
|
-
export declare function getOptionSetHierarchyLinks(): Promise<any[]>;
|
|
5
4
|
export declare function getRuleSets(): Promise<any[]>;
|
|
6
|
-
export declare function getRuleSetLinks(): Promise<any[]>;
|
|
7
|
-
export declare function getUsageInfo(): Promise<any[]>;
|
|
8
5
|
export declare function getTypePropertyPolicies(): Promise<any[]>;
|
|
9
|
-
export declare function getTypePropertyPolicyLinks(): Promise<any[]>;
|
|
10
6
|
export declare function getTypePolicies(): Promise<any[]>;
|
|
11
7
|
export declare function getTypeOverrideCopies(): Promise<any[]>;
|
|
12
8
|
export declare function uploadTypeOverrideObjects(reducedOverrides: any): Promise<void>;
|
|
13
|
-
export declare function getTypePolicyLinks(): Promise<any[]>;
|
package/dist/api/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.uploadTypeOverrideObjects = exports.getTypeOverrideCopies = exports.getTypePolicies = exports.getTypePropertyPolicies = exports.getRuleSets = exports.getOptionSetHierarchies = exports.getUserLists = exports.getOptionSets = void 0;
|
|
4
4
|
const sdk_1 = require("@contrail/sdk");
|
|
5
5
|
async function getOptionSets() {
|
|
6
6
|
return await new sdk_1.Entities().get({
|
|
@@ -21,13 +21,6 @@ async function getOptionSetHierarchies() {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
exports.getOptionSetHierarchies = getOptionSetHierarchies;
|
|
24
|
-
async function getOptionSetHierarchyLinks() {
|
|
25
|
-
const entitiesClient = new sdk_1.Entities();
|
|
26
|
-
return await entitiesClient.get({
|
|
27
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
exports.getOptionSetHierarchyLinks = getOptionSetHierarchyLinks;
|
|
31
24
|
async function getRuleSets() {
|
|
32
25
|
const entitiesClient = new sdk_1.Entities();
|
|
33
26
|
return await entitiesClient.get({
|
|
@@ -35,20 +28,6 @@ async function getRuleSets() {
|
|
|
35
28
|
});
|
|
36
29
|
}
|
|
37
30
|
exports.getRuleSets = getRuleSets;
|
|
38
|
-
async function getRuleSetLinks() {
|
|
39
|
-
const entitiesClient = new sdk_1.Entities();
|
|
40
|
-
return await entitiesClient.get({
|
|
41
|
-
entityName: 'type-rule-set-link',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
exports.getRuleSetLinks = getRuleSetLinks;
|
|
45
|
-
async function getUsageInfo() {
|
|
46
|
-
const entitiesClient = new sdk_1.Entities();
|
|
47
|
-
return await entitiesClient.get({
|
|
48
|
-
entityName: 'type-property-usage-info',
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
exports.getUsageInfo = getUsageInfo;
|
|
52
31
|
async function getTypePropertyPolicies() {
|
|
53
32
|
const entitiesClient = new sdk_1.Entities();
|
|
54
33
|
return await entitiesClient.get({
|
|
@@ -56,13 +35,6 @@ async function getTypePropertyPolicies() {
|
|
|
56
35
|
});
|
|
57
36
|
}
|
|
58
37
|
exports.getTypePropertyPolicies = getTypePropertyPolicies;
|
|
59
|
-
async function getTypePropertyPolicyLinks() {
|
|
60
|
-
const entitiesClient = new sdk_1.Entities();
|
|
61
|
-
return await entitiesClient.get({
|
|
62
|
-
entityName: 'type-property-policy-link',
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.getTypePropertyPolicyLinks = getTypePropertyPolicyLinks;
|
|
66
38
|
async function getTypePolicies() {
|
|
67
39
|
const entitiesClient = new sdk_1.Entities();
|
|
68
40
|
return await entitiesClient.get({
|
|
@@ -86,10 +58,3 @@ async function uploadTypeOverrideObjects(reducedOverrides) {
|
|
|
86
58
|
});
|
|
87
59
|
}
|
|
88
60
|
exports.uploadTypeOverrideObjects = uploadTypeOverrideObjects;
|
|
89
|
-
async function getTypePolicyLinks() {
|
|
90
|
-
const entitiesClient = new sdk_1.Entities();
|
|
91
|
-
return await entitiesClient.get({
|
|
92
|
-
entityName: 'type-policy-link',
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
exports.getTypePolicyLinks = getTypePolicyLinks;
|
|
@@ -3,6 +3,7 @@ export default class ExportProjects extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
process: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -7,23 +7,37 @@ const login_1 = require("../../auth/login");
|
|
|
7
7
|
const helpers_1 = require("../../helpers/projects/helpers");
|
|
8
8
|
const basecommand_1 = require("../../basecommand");
|
|
9
9
|
class ExportProjects extends basecommand_1.BaseCommand {
|
|
10
|
-
static description = 'Export a project.';
|
|
10
|
+
static description = 'Export a project with optional post-processing.';
|
|
11
11
|
static examples = [
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
'$ contrail project export <PROJECT_NAME>',
|
|
13
|
+
'$ contrail project export <PROJECT_NAME> --process',
|
|
14
14
|
];
|
|
15
15
|
static flags = {
|
|
16
16
|
...basecommand_1.BaseCommand.baseFlags,
|
|
17
|
+
process: core_1.Flags.boolean({
|
|
18
|
+
description: 'Enable post-processing of exported project data',
|
|
19
|
+
default: false,
|
|
20
|
+
}),
|
|
17
21
|
};
|
|
18
22
|
static args = {
|
|
19
|
-
projectName: core_1.Args.string({
|
|
23
|
+
projectName: core_1.Args.string({
|
|
24
|
+
description: 'Name or identifier of the project to export',
|
|
25
|
+
required: true,
|
|
26
|
+
}),
|
|
20
27
|
};
|
|
21
28
|
async run() {
|
|
22
29
|
try {
|
|
23
30
|
await (0, login_1.authUser)();
|
|
24
31
|
this.log(`${chalk_1.default.blue.bold('START')} Exporting Project.`);
|
|
32
|
+
const processingOptions = {
|
|
33
|
+
removeBackings: true,
|
|
34
|
+
fixMissingIdentifiers: true,
|
|
35
|
+
cleanProperties: true,
|
|
36
|
+
analyzeOnly: false,
|
|
37
|
+
verbose: false,
|
|
38
|
+
};
|
|
25
39
|
this.log(`${chalk_1.default.yellow.bold('PROJECT')} Exporting`);
|
|
26
|
-
await (0, helpers_1.exportProject)(this.args.projectName);
|
|
40
|
+
await (0, helpers_1.exportProject)(this.args.projectName, this.flags.process ? processingOptions : null);
|
|
27
41
|
this.log(`${chalk_1.default.yellow.bold('PROJECT')} Exported`);
|
|
28
42
|
}
|
|
29
43
|
catch (e) {
|
|
@@ -54,14 +54,9 @@ async function getAll(outDir, overwrite) {
|
|
|
54
54
|
types: await (0, type_extractor_1.getTypes)(),
|
|
55
55
|
optionSets: await (0, types_1.getOptionSets)(),
|
|
56
56
|
optionSetHierarchies: await (0, types_1.getOptionSetHierarchies)(),
|
|
57
|
-
optionSetHierarchyLinks: await (0, types_1.getOptionSetHierarchyLinks)(),
|
|
58
57
|
ruleSets: await (0, types_1.getRuleSets)(),
|
|
59
|
-
ruleSetLinks: await (0, types_1.getRuleSetLinks)(),
|
|
60
|
-
usageInfo: await (0, types_1.getUsageInfo)(),
|
|
61
58
|
typePropertyPolicies: await (0, types_1.getTypePropertyPolicies)(),
|
|
62
|
-
typePropertyPolicyLinks: await (0, types_1.getTypePropertyPolicyLinks)(),
|
|
63
59
|
typePolicies: await (0, types_1.getTypePolicies)(),
|
|
64
|
-
typePolicyLinks: await (0, types_1.getTypePolicyLinks)(),
|
|
65
60
|
typeOverrides: await (0, types_1.getTypeOverrideCopies)(),
|
|
66
61
|
orgUsers: await (0, users_1.getUserOrgs)(),
|
|
67
62
|
groups: await (0, users_1.getGroups)(),
|
|
@@ -125,31 +120,18 @@ async function saveData(reducedData, dir, overwrite) {
|
|
|
125
120
|
split: true,
|
|
126
121
|
fileLabel: 'identifier',
|
|
127
122
|
},
|
|
128
|
-
reducedOptionSetHierarchyLinks: {
|
|
129
|
-
filename: 'type-option-set-hierarchy-links',
|
|
130
|
-
split: false,
|
|
131
|
-
fileLabel: '',
|
|
132
|
-
},
|
|
133
123
|
reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
|
|
134
|
-
reducedRuleSetLinks: { filename: 'rule-set-links', split: false, fileLabel: '' },
|
|
135
|
-
reducedUsageInfo: { filename: 'usage-info', split: false, fileLabel: '' },
|
|
136
124
|
reducedTypePropertyPolicies: {
|
|
137
125
|
filename: 'type-property-policies',
|
|
138
126
|
split: true,
|
|
139
127
|
fileLabel: 'label',
|
|
140
128
|
},
|
|
141
|
-
reducedTypePropertyPolicyLinks: {
|
|
142
|
-
filename: 'type-property-policy-links',
|
|
143
|
-
split: false,
|
|
144
|
-
fileLabel: '',
|
|
145
|
-
},
|
|
146
129
|
reducedOverrides: {
|
|
147
130
|
filename: 'type-overrides',
|
|
148
131
|
split: false,
|
|
149
132
|
fileLabel: '',
|
|
150
133
|
},
|
|
151
134
|
reducedTypePolicies: { filename: 'type-policies', split: true, fileLabel: 'label' },
|
|
152
|
-
reducedTypePolicyLinks: { filename: 'type-policy-links', split: false, fileLabel: '' },
|
|
153
135
|
};
|
|
154
136
|
for (const [key, folder] of Object.entries(propertyToFolderMap)) {
|
|
155
137
|
const CURRENT_DIR = process.cwd();
|
|
@@ -7,7 +7,6 @@ const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
|
7
7
|
const login_1 = require("../../auth/login");
|
|
8
8
|
const uploadOptionSets_1 = require("./uploadOptionSets");
|
|
9
9
|
const uploadOptionSetHierarchies_1 = require("./uploadOptionSetHierarchies");
|
|
10
|
-
const uploadUsageInfo_1 = require("./uploadUsageInfo");
|
|
11
10
|
const uploadRuleSets_1 = require("./uploadRuleSets");
|
|
12
11
|
const uploadTypePropertyPolicies_1 = require("./uploadTypePropertyPolicies");
|
|
13
12
|
const type_uploader_1 = require("../../helpers/types/type-uploader");
|
|
@@ -41,7 +40,6 @@ async function loadAll(dir, skipPolicies = false) {
|
|
|
41
40
|
await (0, uploadOptionSets_1.uploadOptionSets)(dir);
|
|
42
41
|
await (0, type_uploader_1.uploadTypes)(dir);
|
|
43
42
|
await (0, uploadOptionSetHierarchies_1.uploadOptionSetHierarchies)(dir);
|
|
44
|
-
await (0, uploadUsageInfo_1.uploadUsageInfo)(dir);
|
|
45
43
|
await (0, uploadRuleSets_1.uploadRuleSets)(dir);
|
|
46
44
|
if (!skipPolicies) {
|
|
47
45
|
await (0, uploadTypePropertyPolicies_1.uploadTypePropertyPolicies)(dir);
|
|
@@ -62,14 +62,9 @@ async function mergeTypeProperties(fileLocation, typePaths) {
|
|
|
62
62
|
types: await (0, type_extractor_1.getTypes)(),
|
|
63
63
|
optionSets: await (0, types_2.getOptionSets)(),
|
|
64
64
|
optionSetHierarchies: [],
|
|
65
|
-
optionSetHierarchyLinks: [],
|
|
66
65
|
ruleSets: [],
|
|
67
|
-
ruleSetLinks: [],
|
|
68
|
-
usageInfo: [],
|
|
69
66
|
typePropertyPolicies: [],
|
|
70
|
-
typePropertyPolicyLinks: [],
|
|
71
67
|
typePolicies: [],
|
|
72
|
-
typePolicyLinks: [],
|
|
73
68
|
};
|
|
74
69
|
const reducedData = await (0, types_1.getAllReducedTypes)(data);
|
|
75
70
|
for (const typePath of typePaths) {
|
|
@@ -8,7 +8,6 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
8
8
|
const login_1 = require("../../auth/login");
|
|
9
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
|
-
const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
12
11
|
const basecommand_1 = require("../../basecommand");
|
|
13
12
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
14
13
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
@@ -38,8 +37,6 @@ async function uploadOptionSetHierarchies(dir) {
|
|
|
38
37
|
logger_1.default.info(`${chalk_1.default.yellow.bold('OPTION SET HIERARCHIES')} Uploading`);
|
|
39
38
|
const optionSetHierarchies = await loadOptionSetHierarchies(dir);
|
|
40
39
|
await uploadOSH(optionSetHierarchies);
|
|
41
|
-
const optionSetHierarchyLinks = await loadOptionSetHierarchyLinks(dir);
|
|
42
|
-
await uploadOSHLinks(optionSetHierarchyLinks);
|
|
43
40
|
logger_1.default.info(`${chalk_1.default.yellow.bold('OPTION SET HIERARCHIES')} Uploaded`);
|
|
44
41
|
}
|
|
45
42
|
catch (e) {
|
|
@@ -63,14 +60,6 @@ function loadOptionSetHierarchies(fromDir) {
|
|
|
63
60
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
function loadOptionSetHierarchyLinks(fromDir) {
|
|
67
|
-
try {
|
|
68
|
-
return js_yaml_1.default.load(fs_1.default.readFileSync(path.join(fromDir, 'type-option-set-hierarchy-links.yml'), 'utf8'));
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
63
|
async function uploadOSH(loadedOSHs) {
|
|
75
64
|
const optionSets = await new sdk_1.Entities().get({
|
|
76
65
|
entityName: 'type-property-option-set',
|
|
@@ -150,109 +139,3 @@ function transformOSHNameToID(hierarchy, optionSets) {
|
|
|
150
139
|
}
|
|
151
140
|
return true;
|
|
152
141
|
}
|
|
153
|
-
async function uploadOSHLinks(reducedOSHLinks) {
|
|
154
|
-
const typesWithProperties = await (0, type_extractor_1.getTypes)();
|
|
155
|
-
const typeProperties = [];
|
|
156
|
-
typesWithProperties.forEach((type) => {
|
|
157
|
-
if (type.typeProperties) {
|
|
158
|
-
for (const tp of type.typeProperties) {
|
|
159
|
-
tp.typeId = type.id;
|
|
160
|
-
tp.typeSlug = type.slug;
|
|
161
|
-
typeProperties.push(tp);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
const currentOSHs = await new sdk_1.Entities().get({
|
|
166
|
-
entityName: 'option-set-hierarchy',
|
|
167
|
-
});
|
|
168
|
-
const currentOSHLinks = await new sdk_1.Entities().get({
|
|
169
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
170
|
-
});
|
|
171
|
-
const currentOSHLinkHashes = {};
|
|
172
|
-
for (const currentLink of currentOSHLinks) {
|
|
173
|
-
const foundType = typesWithProperties.find((x) => x.id === currentLink.typeId);
|
|
174
|
-
const foundOSH = currentOSHs.find((osh) => osh.id === currentLink.optionSetHierarchyId);
|
|
175
|
-
const foundTPSlugs = typeProperties
|
|
176
|
-
.filter((x) => currentLink?.hierarchyTypePropertyIds?.includes(x.id))
|
|
177
|
-
.map((x) => x.slug);
|
|
178
|
-
if (!foundType ||
|
|
179
|
-
!foundOSH ||
|
|
180
|
-
foundTPSlugs.length !== currentLink.hierarchyTypePropertyIds.length) {
|
|
181
|
-
logger_1.default.info(`skipping unhashable, invalid type option set hierarchy link: ${JSON.stringify(currentLink, null, 2)}`);
|
|
182
|
-
}
|
|
183
|
-
// don't mutate original array
|
|
184
|
-
const sortedFoundTPSlugs = [...foundTPSlugs].sort();
|
|
185
|
-
const hash = `${foundType.slug}|${foundOSH.name}|${sortedFoundTPSlugs.join('|')}`;
|
|
186
|
-
currentOSHLinkHashes[hash] = currentLink;
|
|
187
|
-
}
|
|
188
|
-
const reducedLinksByHashes = {};
|
|
189
|
-
for (const loadedLink of reducedOSHLinks) {
|
|
190
|
-
// don't mutate original array
|
|
191
|
-
const sortedTPSlugs = [...loadedLink.typePropertySlugs].sort();
|
|
192
|
-
const hash = `${loadedLink.typeSlug}|${loadedLink.optionSetHierarchyIdentifier}|${sortedTPSlugs.join('|')}}`;
|
|
193
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
194
|
-
}
|
|
195
|
-
for (const loadedLink of reducedOSHLinks) {
|
|
196
|
-
try {
|
|
197
|
-
// don't mutate original array
|
|
198
|
-
const sortedTPSlugs = [...loadedLink.typePropertySlugs].sort();
|
|
199
|
-
const found = currentOSHLinkHashes[`${loadedLink.typeSlug}|${loadedLink.optionSetHierarchyIdentifier}|${sortedTPSlugs.join('|')}`];
|
|
200
|
-
if (!found) {
|
|
201
|
-
if (!transformReducedLink(loadedLink, typesWithProperties, currentOSHs)) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
logger_1.default.debug(`Creating: ${JSON.stringify(loadedLink, null, 2)}`);
|
|
205
|
-
await new sdk_1.Entities().create({
|
|
206
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
207
|
-
object: {
|
|
208
|
-
hierarchyTypePropertyIds: loadedLink.hierarchyTypePropertyIds,
|
|
209
|
-
optionSetHierarchyId: loadedLink.optionSetHierarchyId,
|
|
210
|
-
typeId: loadedLink.typeId,
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
logger_1.default.error(`Error uploading type option set hierarchy links: ${err}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
for (const [currentLinkHash, currentLink] of Object.entries(currentOSHLinkHashes)) {
|
|
220
|
-
try {
|
|
221
|
-
const found = reducedLinksByHashes[currentLinkHash];
|
|
222
|
-
if (!found) {
|
|
223
|
-
logger_1.default.debug(`Deleting: ${JSON.stringify(currentLinkHash)}`);
|
|
224
|
-
await new sdk_1.Entities().delete({
|
|
225
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
226
|
-
id: currentLink['id'],
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (err) {
|
|
231
|
-
logger_1.default.error(`Error Deleting rule set link: ${err}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function transformReducedLink(OSHLink, typesWithProperties, OSHs) {
|
|
236
|
-
logger_1.default.debug(`OSHLink before transform: ${JSON.stringify(OSHLink, null, 2)}`);
|
|
237
|
-
const foundType = typesWithProperties.find((x) => x.slug === OSHLink.typeSlug);
|
|
238
|
-
if (!foundType) {
|
|
239
|
-
logger_1.default.error(`OSH Links: Could not find type with slug ${OSHLink.typeSlug}`);
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
OSHLink.typeId = foundType.id;
|
|
243
|
-
const foundTPs = foundType?.typeProperties?.filter((x) => OSHLink.typePropertySlugs.includes(x.slug)) ?? [];
|
|
244
|
-
if (foundTPs.length !== OSHLink.typePropertySlugs.length) {
|
|
245
|
-
logger_1.default.error(`OSH Links: Could not find all type properties with slugs ${OSHLink.typePropertySlugs}`);
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
logger_1.default.debug(`foundTPs: ${JSON.stringify(foundTPs)}`);
|
|
249
|
-
OSHLink.hierarchyTypePropertyIds = foundTPs.map((x) => x.id);
|
|
250
|
-
const foundOSH = OSHs.find((x) => x.identifier === OSHLink.optionSetHierarchyIdentifier);
|
|
251
|
-
if (!foundOSH) {
|
|
252
|
-
logger_1.default.error(`OSH Links: Could not find option set hierarchy with identifier ${OSHLink.optionSetHierarchyIdentifier}`);
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
OSHLink.optionSetHierarchyId = foundOSH.id;
|
|
256
|
-
logger_1.default.debug(`OSHLink after transform: ${JSON.stringify(OSHLink, null, 2)}`);
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
@@ -129,7 +129,7 @@ async function uploadOS(dir) {
|
|
|
129
129
|
}
|
|
130
130
|
function validateOptionSets(optionSets) {
|
|
131
131
|
optionSets.forEach((optionSet) => {
|
|
132
|
-
optionSet.optionSet
|
|
132
|
+
optionSet.optionSet?.forEach((option) => {
|
|
133
133
|
validateOption(option, optionSet.slug);
|
|
134
134
|
});
|
|
135
135
|
});
|
|
@@ -35,9 +35,8 @@ async function uploadRuleSets(dir) {
|
|
|
35
35
|
try {
|
|
36
36
|
await (0, login_1.authUser)();
|
|
37
37
|
logger_1.default.info(`${chalk_1.default.yellow.bold('RULE SET')} Uploading`);
|
|
38
|
-
const
|
|
38
|
+
const reducedRuleSets = await loadReducedRuleSets(dir);
|
|
39
39
|
await uploadRuleSetObjects(reducedRuleSets);
|
|
40
|
-
await uploadRuleSetLinkObjects(reducedRuleSetLinks);
|
|
41
40
|
logger_1.default.info(`${chalk_1.default.yellow.bold('RULE SET')} Uploaded`);
|
|
42
41
|
}
|
|
43
42
|
catch (e) {
|
|
@@ -49,15 +48,13 @@ async function uploadRuleSets(dir) {
|
|
|
49
48
|
exports.uploadRuleSets = uploadRuleSets;
|
|
50
49
|
function loadReducedRuleSets(fromDir) {
|
|
51
50
|
const ruleSets = [];
|
|
52
|
-
let ruleSetLinks = [];
|
|
53
51
|
const dir = path.join(fromDir, 'rule-sets');
|
|
54
52
|
try {
|
|
55
53
|
const files = fs_1.default.readdirSync(dir);
|
|
56
54
|
for (const file of files) {
|
|
57
55
|
ruleSets.push(js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
return [ruleSets, ruleSetLinks];
|
|
57
|
+
return ruleSets;
|
|
61
58
|
}
|
|
62
59
|
catch (e) {
|
|
63
60
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -116,83 +113,3 @@ async function uploadRuleSetObjects(reducedRuleSets) {
|
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
|
-
async function uploadRuleSetLinkObjects(loadedRuleSetLinks) {
|
|
120
|
-
const types = await new sdk_1.Entities().get({
|
|
121
|
-
entityName: 'type',
|
|
122
|
-
});
|
|
123
|
-
const currentRuleSets = await new sdk_1.Entities().get({
|
|
124
|
-
entityName: 'type-rule-set',
|
|
125
|
-
});
|
|
126
|
-
const currentRuleSetLinks = await new sdk_1.Entities().get({
|
|
127
|
-
entityName: 'type-rule-set-link',
|
|
128
|
-
});
|
|
129
|
-
const currentLinksHashes = {};
|
|
130
|
-
for (const currentLink of currentRuleSetLinks) {
|
|
131
|
-
const foundType = types.find((t) => t.id === currentLink.typeId);
|
|
132
|
-
const foundRuleSet = currentRuleSets.find((rs) => rs.id === currentLink.typeRuleSetId);
|
|
133
|
-
const hash = `${foundType.slug}|${foundRuleSet.name}`;
|
|
134
|
-
currentLinksHashes[hash] = currentLink;
|
|
135
|
-
}
|
|
136
|
-
const reducedLinksByHashes = {};
|
|
137
|
-
for (const loadedLink of loadedRuleSetLinks) {
|
|
138
|
-
const hash = `${loadedLink.type}|${loadedLink.ruleSet}`;
|
|
139
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
140
|
-
}
|
|
141
|
-
for (const loadedRuleSetLink of loadedRuleSetLinks) {
|
|
142
|
-
try {
|
|
143
|
-
const found = currentLinksHashes[`${loadedRuleSetLink.type}|${loadedRuleSetLink.ruleSet}`];
|
|
144
|
-
if (!found) {
|
|
145
|
-
if (!transformReducedLink(loadedRuleSetLink, types, currentRuleSets)) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
logger_1.default.info(`Creating: ${JSON.stringify(loadedRuleSetLink, null, 2)}`);
|
|
149
|
-
await new sdk_1.Entities().create({
|
|
150
|
-
entityName: 'type-rule-set-link',
|
|
151
|
-
object: {
|
|
152
|
-
typeRuleSetId: loadedRuleSetLink.ruleSet,
|
|
153
|
-
typeId: loadedRuleSetLink.type,
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
if (!transformReducedLink(loadedRuleSetLink, types, currentRuleSets)) {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
logger_1.default.info(`skipping updating existing rule set link: ${loadedRuleSetLink}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
logger_1.default.error(`Error Uploading rule set links: ${err}`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (const [currentLinkHash, currentLink] of Object.entries(currentLinksHashes)) {
|
|
169
|
-
try {
|
|
170
|
-
const found = reducedLinksByHashes[currentLinkHash];
|
|
171
|
-
if (!found) {
|
|
172
|
-
logger_1.default.info(`Deleting: ${currentLinkHash}`);
|
|
173
|
-
await new sdk_1.Entities().delete({
|
|
174
|
-
entityName: 'type-rule-set-link',
|
|
175
|
-
id: currentLink['id'],
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
logger_1.default.error(`Error Deleting rule set link: ${err}`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function transformReducedLink(ruleSetLink, types, ruleSets) {
|
|
185
|
-
const foundType = types.find((t) => t.slug === ruleSetLink.type);
|
|
186
|
-
if (!foundType) {
|
|
187
|
-
logger_1.default.error(`Could not find type with name ${ruleSetLink.type}`);
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
ruleSetLink.type = foundType.id;
|
|
191
|
-
const foundRuleSet = ruleSets.find((rs) => rs.identifier === ruleSetLink.ruleSet);
|
|
192
|
-
if (!foundRuleSet) {
|
|
193
|
-
logger_1.default.error(`Could not find rule set with name ${foundType.ruleSet}`);
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
ruleSetLink.ruleSet = foundRuleSet.id;
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
@@ -34,8 +34,12 @@ exports.default = UploadTypeOverrides;
|
|
|
34
34
|
async function uploadTypeOverrides(dir) {
|
|
35
35
|
try {
|
|
36
36
|
await (0, login_1.authUser)();
|
|
37
|
-
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploading`);
|
|
38
37
|
const reducedOverrides = readTypeOverridesFromFile(dir);
|
|
38
|
+
if (!reducedOverrides || reducedOverrides.length === 0) {
|
|
39
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} No overrides found in type-overrides.yml — skipping upload to avoid wiping org overrides`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploading`);
|
|
39
43
|
await (0, types_1.uploadTypeOverrideObjects)(reducedOverrides);
|
|
40
44
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploaded`);
|
|
41
45
|
}
|
|
@@ -47,8 +51,12 @@ async function uploadTypeOverrides(dir) {
|
|
|
47
51
|
}
|
|
48
52
|
exports.uploadTypeOverrides = uploadTypeOverrides;
|
|
49
53
|
function readTypeOverridesFromFile(fromDir) {
|
|
54
|
+
const filePath = path.join(fromDir, 'type-overrides.yml');
|
|
55
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
50
58
|
try {
|
|
51
|
-
return js_yaml_1.default.load(fs_1.default.readFileSync(
|
|
59
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(filePath, 'utf8'));
|
|
52
60
|
}
|
|
53
61
|
catch (e) {
|
|
54
62
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|