@contrail/cli 3.5.3-alpha.73bd011 → 3.5.3-alpha.915cfe5
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 +11 -5
- package/dist/commands/workflow-templates/export.d.ts +3 -1
- package/dist/commands/workflow-templates/export.js +99 -28
- package/dist/helpers/workflow-templates/helper.d.ts +1 -0
- package/dist/helpers/workflow-templates/helper.js +27 -6
- 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 +15 -5
- package/package.json +2 -2
- 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
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReducedOptionSets = void 0;
|
|
4
|
-
function getReducedOptionSets(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map((optionSet) => {
|
|
7
|
-
var _a, _b;
|
|
8
|
-
return {
|
|
9
|
-
name: optionSet.name,
|
|
10
|
-
slug: optionSet.slug,
|
|
11
|
-
isArchived: optionSet.isArchived,
|
|
12
|
-
optionSet: (_a = optionSet.optionSet) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
13
|
-
var _a;
|
|
14
|
-
return Object.assign(Object.assign({}, x), { disabled: typeof x.disabled === 'string' ? x.disabled === 'true' : Boolean((_a = x.disabled) !== null && _a !== void 0 ? _a : false) });
|
|
15
|
-
}),
|
|
16
|
-
disabled: typeof optionSet.disabled === 'string' ? optionSet.disabled === 'true' : Boolean((_b = optionSet.disabled) !== null && _b !== void 0 ? _b : false),
|
|
17
|
-
};
|
|
18
|
-
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
19
|
-
}
|
|
20
|
-
exports.getReducedOptionSets = getReducedOptionSets;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedOptionSets = void 0;
|
|
4
|
+
function getReducedOptionSets(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map((optionSet) => {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return {
|
|
9
|
+
name: optionSet.name,
|
|
10
|
+
slug: optionSet.slug,
|
|
11
|
+
isArchived: optionSet.isArchived,
|
|
12
|
+
optionSet: (_a = optionSet.optionSet) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
13
|
+
var _a;
|
|
14
|
+
return Object.assign(Object.assign({}, x), { disabled: typeof x.disabled === 'string' ? x.disabled === 'true' : Boolean((_a = x.disabled) !== null && _a !== void 0 ? _a : false) });
|
|
15
|
+
}),
|
|
16
|
+
disabled: typeof optionSet.disabled === 'string' ? optionSet.disabled === 'true' : Boolean((_b = optionSet.disabled) !== null && _b !== void 0 ? _b : false),
|
|
17
|
+
};
|
|
18
|
+
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
19
|
+
}
|
|
20
|
+
exports.getReducedOptionSets = getReducedOptionSets;
|
package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from '../interfaces';
|
|
2
|
-
export declare function getReducedOptionSetHierarchies(data: DataHolder): any[];
|
|
3
|
-
export declare function getReducedOptionSetHierarchyLinks(data: DataHolder): any[];
|
|
1
|
+
import { DataHolder } from '../interfaces';
|
|
2
|
+
export declare function getReducedOptionSetHierarchies(data: DataHolder): any[];
|
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function getReducedOptionSetHierarchies(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
7
|
-
const hierarchyBySlug = x.hierarchy.map((optionSetId) => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.slug; });
|
|
8
|
-
return {
|
|
9
|
-
hierarchy: hierarchyBySlug,
|
|
10
|
-
options: x.options,
|
|
11
|
-
name: x.name,
|
|
12
|
-
identifier: x.identifier,
|
|
13
|
-
};
|
|
14
|
-
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
15
|
-
}
|
|
16
|
-
exports.getReducedOptionSetHierarchies = getReducedOptionSetHierarchies;
|
|
17
|
-
function getReducedOptionSetHierarchyLinks(data) {
|
|
18
|
-
var _a;
|
|
19
|
-
return (_a = data.optionSetHierarchyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
21
|
-
const osh = (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.find((y) => y.id === x.optionSetHierarchyId);
|
|
22
|
-
if (!osh) {
|
|
23
|
-
console.log(`OSH Link: could not find option set hierarchy ${x.optionSetHierarchyId} skipping...`);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const type = (_b = data.types) === null || _b === void 0 ? void 0 : _b.find((y) => y.id === x.typeId);
|
|
27
|
-
if (!type) {
|
|
28
|
-
console.log(`OSH Link: could not find type ${x.typeId} skipping...`);
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const typePropertySlugs = [];
|
|
32
|
-
for (const tpId of x.hierarchyTypePropertyIds) {
|
|
33
|
-
const typePropertySlug = (_d = (_c = type.typeProperties) === null || _c === void 0 ? void 0 : _c.find((y) => y.id === tpId)) === null || _d === void 0 ? void 0 : _d.slug;
|
|
34
|
-
if (!typePropertySlug) {
|
|
35
|
-
console.log(`OSH Link: could not find type property ${tpId} skipping...`);
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
typePropertySlugs.push(typePropertySlug);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
optionSetHierarchyIdentifier: osh.identifier,
|
|
42
|
-
typeSlug: type.slug,
|
|
43
|
-
typePropertySlugs,
|
|
44
|
-
};
|
|
45
|
-
}).filter((x) => !!x).sort((one, two) => (one.typeSlug < two.typeSlug ? -1 : 1));
|
|
46
|
-
}
|
|
47
|
-
exports.getReducedOptionSetHierarchyLinks = getReducedOptionSetHierarchyLinks;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedOptionSetHierarchies = void 0;
|
|
4
|
+
function getReducedOptionSetHierarchies(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
7
|
+
const hierarchyBySlug = x.hierarchy.map((optionSetId) => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.slug; });
|
|
8
|
+
return {
|
|
9
|
+
hierarchy: hierarchyBySlug,
|
|
10
|
+
options: x.options,
|
|
11
|
+
name: x.name,
|
|
12
|
+
identifier: x.identifier,
|
|
13
|
+
};
|
|
14
|
+
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
15
|
+
}
|
|
16
|
+
exports.getReducedOptionSetHierarchies = getReducedOptionSetHierarchies;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from '../interfaces';
|
|
2
|
-
export declare function getReducedOverrides(data: DataHolder): any[];
|
|
1
|
+
import { DataHolder } from '../interfaces';
|
|
2
|
+
export declare function getReducedOverrides(data: DataHolder): any[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReducedOverrides = void 0;
|
|
4
|
-
function getReducedOverrides(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typeOverrides) !== null && _a !== void 0 ? _a : [];
|
|
7
|
-
}
|
|
8
|
-
exports.getReducedOverrides = getReducedOverrides;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedOverrides = void 0;
|
|
4
|
+
function getReducedOverrides(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typeOverrides) !== null && _a !== void 0 ? _a : [];
|
|
7
|
+
}
|
|
8
|
+
exports.getReducedOverrides = getReducedOverrides;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from '../interfaces';
|
|
2
|
-
export declare function getReducedRuleSets(data: DataHolder): any[];
|
|
3
|
-
export declare function getReducedRuleSetLinks(data: DataHolder): any[];
|
|
1
|
+
import { DataHolder } from '../interfaces';
|
|
2
|
+
export declare function getReducedRuleSets(data: DataHolder): any[];
|
|
@@ -1,39 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function getReducedRuleSets(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
7
|
-
return {
|
|
8
|
-
ruleSet: x.ruleSet,
|
|
9
|
-
name: x.name,
|
|
10
|
-
identifier: x.identifier,
|
|
11
|
-
};
|
|
12
|
-
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
13
|
-
}
|
|
14
|
-
exports.getReducedRuleSets = getReducedRuleSets;
|
|
15
|
-
function getReducedRuleSetLinks(data) {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
const reducedRuleSetLinks = [];
|
|
18
|
-
if (!(data === null || data === void 0 ? void 0 : data.ruleSetLinks.length)) {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
for (const ruleSetLink of data.ruleSetLinks) {
|
|
22
|
-
const ruleSet = (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === ruleSetLink.typeRuleSetId);
|
|
23
|
-
const type = (_b = data === null || data === void 0 ? void 0 : data.types) === null || _b === void 0 ? void 0 : _b.find((x) => x.id === ruleSetLink.typeId);
|
|
24
|
-
if (!ruleSet || !type) {
|
|
25
|
-
console.log(`Skipping bad rule set link ${ruleSetLink.id}`);
|
|
26
|
-
}
|
|
27
|
-
reducedRuleSetLinks.push({
|
|
28
|
-
ruleSet: ruleSet.identifier,
|
|
29
|
-
type: type.slug,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return reducedRuleSetLinks.sort((one, two) => {
|
|
33
|
-
if (one.type === two.type) {
|
|
34
|
-
return one.ruleSet > two.ruleSet ? -1 : 1;
|
|
35
|
-
}
|
|
36
|
-
return one.type > two.type ? -1 : 1;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
exports.getReducedRuleSetLinks = getReducedRuleSetLinks;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedRuleSets = void 0;
|
|
4
|
+
function getReducedRuleSets(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
7
|
+
return {
|
|
8
|
+
ruleSet: x.ruleSet,
|
|
9
|
+
name: x.name,
|
|
10
|
+
identifier: x.identifier,
|
|
11
|
+
};
|
|
12
|
+
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
13
|
+
}
|
|
14
|
+
exports.getReducedRuleSets = getReducedRuleSets;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from '../interfaces';
|
|
2
|
-
export declare function getReducedTypePolicies(data: DataHolder): any[];
|
|
3
|
-
export declare function getReducedTypePolicyLinks(data: DataHolder): any[];
|
|
1
|
+
import { DataHolder } from '../interfaces';
|
|
2
|
+
export declare function getReducedTypePolicies(data: DataHolder): any[];
|
|
@@ -1,56 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function getReducedTypePolicies(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
function reducePrincipal(statement) {
|
|
7
|
-
var _a, _b, _c, _d;
|
|
8
|
-
if (!(statement === null || statement === void 0 ? void 0 : statement.principal)) {
|
|
9
|
-
return statement;
|
|
10
|
-
}
|
|
11
|
-
const [type, id] = statement.principal.split(':');
|
|
12
|
-
if (!type || !id) {
|
|
13
|
-
return statement;
|
|
14
|
-
}
|
|
15
|
-
if (type === 'group') {
|
|
16
|
-
const groupName = (_b = (_a = data.groups) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === id)) === null || _b === void 0 ? void 0 : _b.name;
|
|
17
|
-
if (!groupName) {
|
|
18
|
-
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
19
|
-
return statement;
|
|
20
|
-
}
|
|
21
|
-
statement.principal = `group:${groupName}`;
|
|
22
|
-
}
|
|
23
|
-
else if (type === 'user') {
|
|
24
|
-
const userEmail = (_d = (_c = data.orgUsers) === null || _c === void 0 ? void 0 : _c.find((x) => x.user.id === id)) === null || _d === void 0 ? void 0 : _d.email;
|
|
25
|
-
if (!userEmail) {
|
|
26
|
-
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
27
|
-
return statement;
|
|
28
|
-
}
|
|
29
|
-
statement.principal = `user:${userEmail}`;
|
|
30
|
-
}
|
|
31
|
-
return statement;
|
|
32
|
-
}
|
|
33
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
34
|
-
return {
|
|
35
|
-
label: x.label,
|
|
36
|
-
identifier: x.identifier,
|
|
37
|
-
policy: {
|
|
38
|
-
version: x.policy.version,
|
|
39
|
-
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
43
|
-
}
|
|
44
|
-
exports.getReducedTypePolicies = getReducedTypePolicies;
|
|
45
|
-
function getReducedTypePolicyLinks(data) {
|
|
46
|
-
var _a;
|
|
47
|
-
const types = data === null || data === void 0 ? void 0 : data.types;
|
|
48
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePolicyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
49
|
-
var _a, _b, _c;
|
|
50
|
-
return {
|
|
51
|
-
typeSlug: (_a = types.find((y) => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
|
|
52
|
-
typePolicyIdentifier: (_c = (_b = data.typePolicies) === null || _b === void 0 ? void 0 : _b.find((y) => y.id === x.typePolicyId)) === null || _c === void 0 ? void 0 : _c.identifier,
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
exports.getReducedTypePolicyLinks = getReducedTypePolicyLinks;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedTypePolicies = void 0;
|
|
4
|
+
function getReducedTypePolicies(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
function reducePrincipal(statement) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
if (!(statement === null || statement === void 0 ? void 0 : statement.principal)) {
|
|
9
|
+
return statement;
|
|
10
|
+
}
|
|
11
|
+
const [type, id] = statement.principal.split(':');
|
|
12
|
+
if (!type || !id) {
|
|
13
|
+
return statement;
|
|
14
|
+
}
|
|
15
|
+
if (type === 'group') {
|
|
16
|
+
const groupName = (_b = (_a = data.groups) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === id)) === null || _b === void 0 ? void 0 : _b.name;
|
|
17
|
+
if (!groupName) {
|
|
18
|
+
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
19
|
+
return statement;
|
|
20
|
+
}
|
|
21
|
+
statement.principal = `group:${groupName}`;
|
|
22
|
+
}
|
|
23
|
+
else if (type === 'user') {
|
|
24
|
+
const userEmail = (_d = (_c = data.orgUsers) === null || _c === void 0 ? void 0 : _c.find((x) => x.user.id === id)) === null || _d === void 0 ? void 0 : _d.email;
|
|
25
|
+
if (!userEmail) {
|
|
26
|
+
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
27
|
+
return statement;
|
|
28
|
+
}
|
|
29
|
+
statement.principal = `user:${userEmail}`;
|
|
30
|
+
}
|
|
31
|
+
return statement;
|
|
32
|
+
}
|
|
33
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
34
|
+
return {
|
|
35
|
+
label: x.label,
|
|
36
|
+
identifier: x.identifier,
|
|
37
|
+
policy: {
|
|
38
|
+
version: x.policy.version,
|
|
39
|
+
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
43
|
+
}
|
|
44
|
+
exports.getReducedTypePolicies = getReducedTypePolicies;
|
package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from '../interfaces';
|
|
2
|
-
export declare function getReducedTypePropertyPolicies(data: DataHolder): any[];
|
|
3
|
-
export declare function getReducedTypePropertyPolicyLinks(data: DataHolder): any[];
|
|
1
|
+
import { DataHolder } from '../interfaces';
|
|
2
|
+
export declare function getReducedTypePropertyPolicies(data: DataHolder): any[];
|
|
@@ -1,71 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function getReducedTypePropertyPolicies(data) {
|
|
5
|
-
var _a;
|
|
6
|
-
function reducePrincipal(statement) {
|
|
7
|
-
var _a, _b, _c, _d;
|
|
8
|
-
if (!(statement === null || statement === void 0 ? void 0 : statement.principal)) {
|
|
9
|
-
return statement;
|
|
10
|
-
}
|
|
11
|
-
const [type, id] = statement.principal.split(':');
|
|
12
|
-
if (!type || !id) {
|
|
13
|
-
return statement;
|
|
14
|
-
}
|
|
15
|
-
if (type === 'group') {
|
|
16
|
-
const groupName = (_b = (_a = data.groups) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === id)) === null || _b === void 0 ? void 0 : _b.name;
|
|
17
|
-
if (!groupName) {
|
|
18
|
-
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
19
|
-
return statement;
|
|
20
|
-
}
|
|
21
|
-
statement.principal = `group:${groupName}`;
|
|
22
|
-
}
|
|
23
|
-
else if (type === 'user') {
|
|
24
|
-
const userEmail = (_d = (_c = data.orgUsers) === null || _c === void 0 ? void 0 : _c.find((x) => x.user.id === id)) === null || _d === void 0 ? void 0 : _d.email;
|
|
25
|
-
if (!userEmail) {
|
|
26
|
-
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
27
|
-
return statement;
|
|
28
|
-
}
|
|
29
|
-
statement.principal = `user:${userEmail}`;
|
|
30
|
-
}
|
|
31
|
-
return statement;
|
|
32
|
-
}
|
|
33
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
34
|
-
return {
|
|
35
|
-
label: x.label,
|
|
36
|
-
identifier: x.identifier,
|
|
37
|
-
policy: {
|
|
38
|
-
version: x.policy.version,
|
|
39
|
-
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
43
|
-
}
|
|
44
|
-
exports.getReducedTypePropertyPolicies = getReducedTypePropertyPolicies;
|
|
45
|
-
function getReducedTypePropertyPolicyLinks(data) {
|
|
46
|
-
var _a, _b;
|
|
47
|
-
const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map((x) => x.typeProperties).reduce((x, y) => x.concat(y));
|
|
48
|
-
const typePropertyIdToTypeSlugMap = data.types.reduce((map, obj) => {
|
|
49
|
-
for (const tp of obj.typeProperties) {
|
|
50
|
-
map[tp.id] = obj.slug;
|
|
51
|
-
}
|
|
52
|
-
return map;
|
|
53
|
-
}, {});
|
|
54
|
-
return (_b = data === null || data === void 0 ? void 0 : data.typePropertyPolicyLinks) === null || _b === void 0 ? void 0 : _b.map((x) => {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
const typeSlug = typePropertyIdToTypeSlugMap[x.typePropertyId];
|
|
57
|
-
const typePropertySlug = (_a = typeProperties.find((y) => y.id === x.typePropertyId)) === null || _a === void 0 ? void 0 : _a.slug;
|
|
58
|
-
const typePropertyPolicyIdentifier = (_b = data.typePropertyPolicies.find((y) => y.id === x.typePropertyPolicyId)) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
59
|
-
if (!typeSlug || !typePropertySlug || !typePropertyPolicyIdentifier) {
|
|
60
|
-
console.log(`typeSlug: ${typeSlug} typePropertySlug: ${typePropertySlug}, typePropertyPolicyIdentifier: ${typePropertyPolicyIdentifier} `);
|
|
61
|
-
console.log(`Could not reduce bad type property policy link... skipping ${JSON.stringify(x, null, 2)}`);
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
typeSlug,
|
|
66
|
-
typePropertySlug,
|
|
67
|
-
typePropertyPolicyIdentifier,
|
|
68
|
-
};
|
|
69
|
-
}).filter((x) => !!x);
|
|
70
|
-
}
|
|
71
|
-
exports.getReducedTypePropertyPolicyLinks = getReducedTypePropertyPolicyLinks;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReducedTypePropertyPolicies = void 0;
|
|
4
|
+
function getReducedTypePropertyPolicies(data) {
|
|
5
|
+
var _a;
|
|
6
|
+
function reducePrincipal(statement) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
if (!(statement === null || statement === void 0 ? void 0 : statement.principal)) {
|
|
9
|
+
return statement;
|
|
10
|
+
}
|
|
11
|
+
const [type, id] = statement.principal.split(':');
|
|
12
|
+
if (!type || !id) {
|
|
13
|
+
return statement;
|
|
14
|
+
}
|
|
15
|
+
if (type === 'group') {
|
|
16
|
+
const groupName = (_b = (_a = data.groups) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === id)) === null || _b === void 0 ? void 0 : _b.name;
|
|
17
|
+
if (!groupName) {
|
|
18
|
+
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
19
|
+
return statement;
|
|
20
|
+
}
|
|
21
|
+
statement.principal = `group:${groupName}`;
|
|
22
|
+
}
|
|
23
|
+
else if (type === 'user') {
|
|
24
|
+
const userEmail = (_d = (_c = data.orgUsers) === null || _c === void 0 ? void 0 : _c.find((x) => x.user.id === id)) === null || _d === void 0 ? void 0 : _d.email;
|
|
25
|
+
if (!userEmail) {
|
|
26
|
+
console.log(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
27
|
+
return statement;
|
|
28
|
+
}
|
|
29
|
+
statement.principal = `user:${userEmail}`;
|
|
30
|
+
}
|
|
31
|
+
return statement;
|
|
32
|
+
}
|
|
33
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
34
|
+
return {
|
|
35
|
+
label: x.label,
|
|
36
|
+
identifier: x.identifier,
|
|
37
|
+
policy: {
|
|
38
|
+
version: x.policy.version,
|
|
39
|
+
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
43
|
+
}
|
|
44
|
+
exports.getReducedTypePropertyPolicies = getReducedTypePropertyPolicies;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DataHolder } from './../interfaces';
|
|
2
|
-
export declare function getReducedTypes(dataHolder: DataHolder): Promise<any[]>;
|
|
1
|
+
import { DataHolder } from './../interfaces';
|
|
2
|
+
export declare function getReducedTypes(dataHolder: DataHolder): Promise<any[]>;
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getReducedTypes = void 0;
|
|
13
|
-
function getReducedTypes(dataHolder) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
console.log(`Found types: ${dataHolder.types.length}`);
|
|
16
|
-
let reducedTypes = [];
|
|
17
|
-
const optionSetSlugById = {};
|
|
18
|
-
const userLists = dataHolder === null || dataHolder === void 0 ? void 0 : dataHolder.userList;
|
|
19
|
-
for (const optionSet of dataHolder.optionSets) {
|
|
20
|
-
optionSetSlugById[optionSet.id] = optionSet.slug;
|
|
21
|
-
}
|
|
22
|
-
console.log(`option set and their ids: ${JSON.stringify(optionSetSlugById, null, 2)}`);
|
|
23
|
-
for (const type of dataHolder.types) {
|
|
24
|
-
const reducedTypeProperties = [];
|
|
25
|
-
for (const typeProperty of type.typeProperties) {
|
|
26
|
-
if (typeProperty.inherited) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
let userListName = '';
|
|
30
|
-
if (typeProperty.typePropertyUserListId) {
|
|
31
|
-
const userData = userLists.find((s) => s.id === typeProperty.typePropertyUserListId);
|
|
32
|
-
if (userData) {
|
|
33
|
-
userListName = userData.name;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const reducedTypeProperty = {
|
|
37
|
-
slug: typeProperty.slug,
|
|
38
|
-
id: typeProperty.id,
|
|
39
|
-
isArchived: typeProperty.isArchived,
|
|
40
|
-
propertyType: typeProperty.propertyType,
|
|
41
|
-
label: typeProperty.label,
|
|
42
|
-
editable: typeProperty.editable,
|
|
43
|
-
searchable: typeProperty.searchable,
|
|
44
|
-
core: typeProperty.core,
|
|
45
|
-
typePropertyOptionSetSlug: optionSetSlugById[typeProperty.typePropertyOptionSetId],
|
|
46
|
-
formula: typeProperty.formula,
|
|
47
|
-
referencedTypePath: typeProperty.referencedTypePath,
|
|
48
|
-
referencedTypeRootSlug: typeProperty.referencedTypeRootSlug,
|
|
49
|
-
typePropertyUserListId: typeProperty.typePropertyUserListId,
|
|
50
|
-
typePropertyUserListName: userListName,
|
|
51
|
-
referencedTypeRole: typeProperty.referencedTypeRole,
|
|
52
|
-
defaultValue: typeProperty.defaultValue,
|
|
53
|
-
propertyLevel: typeProperty.propertyLevel,
|
|
54
|
-
carryOverBehavior: typeProperty.carryOverBehavior,
|
|
55
|
-
carryOverDefault: typeProperty.carryOverDefault,
|
|
56
|
-
isUniqueProperty: typeProperty.isUniqueProperty,
|
|
57
|
-
isUniquePropertyInFamily: typeProperty.isUniquePropertyInFamily,
|
|
58
|
-
inherited: typeProperty.inherited,
|
|
59
|
-
formulaFunction: typeProperty.formulaFunction,
|
|
60
|
-
validationFunction: typeProperty.validationFunction,
|
|
61
|
-
numberFormat: typeProperty.numberFormat,
|
|
62
|
-
sequenceSeedValue: typeProperty.sequenceSeedValue,
|
|
63
|
-
copyBehavior: typeProperty.copyBehavior,
|
|
64
|
-
};
|
|
65
|
-
reducedTypeProperties.push(reducedTypeProperty);
|
|
66
|
-
}
|
|
67
|
-
const reducedType = {
|
|
68
|
-
typePath: type.typePath,
|
|
69
|
-
slug: type.slug,
|
|
70
|
-
label: type.label,
|
|
71
|
-
isArchived: type.isArchived,
|
|
72
|
-
typeProperties: reducedTypeProperties
|
|
73
|
-
.map((x) => {
|
|
74
|
-
delete x['id'];
|
|
75
|
-
return Object.assign({}, x);
|
|
76
|
-
})
|
|
77
|
-
.sort((one, two) => (one.slug < two.slug ? -1 : 1)),
|
|
78
|
-
};
|
|
79
|
-
reducedTypes.push(reducedType);
|
|
80
|
-
}
|
|
81
|
-
reducedTypes = reducedTypes.sort((one, two) => (one.typePath < two.typePath ? -1 : 1));
|
|
82
|
-
return reducedTypes;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
exports.getReducedTypes = getReducedTypes;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getReducedTypes = void 0;
|
|
13
|
+
function getReducedTypes(dataHolder) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
console.log(`Found types: ${dataHolder.types.length}`);
|
|
16
|
+
let reducedTypes = [];
|
|
17
|
+
const optionSetSlugById = {};
|
|
18
|
+
const userLists = dataHolder === null || dataHolder === void 0 ? void 0 : dataHolder.userList;
|
|
19
|
+
for (const optionSet of dataHolder.optionSets) {
|
|
20
|
+
optionSetSlugById[optionSet.id] = optionSet.slug;
|
|
21
|
+
}
|
|
22
|
+
console.log(`option set and their ids: ${JSON.stringify(optionSetSlugById, null, 2)}`);
|
|
23
|
+
for (const type of dataHolder.types) {
|
|
24
|
+
const reducedTypeProperties = [];
|
|
25
|
+
for (const typeProperty of type.typeProperties) {
|
|
26
|
+
if (typeProperty.inherited) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
let userListName = '';
|
|
30
|
+
if (typeProperty.typePropertyUserListId) {
|
|
31
|
+
const userData = userLists.find((s) => s.id === typeProperty.typePropertyUserListId);
|
|
32
|
+
if (userData) {
|
|
33
|
+
userListName = userData.name;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const reducedTypeProperty = {
|
|
37
|
+
slug: typeProperty.slug,
|
|
38
|
+
id: typeProperty.id,
|
|
39
|
+
isArchived: typeProperty.isArchived,
|
|
40
|
+
propertyType: typeProperty.propertyType,
|
|
41
|
+
label: typeProperty.label,
|
|
42
|
+
editable: typeProperty.editable,
|
|
43
|
+
searchable: typeProperty.searchable,
|
|
44
|
+
core: typeProperty.core,
|
|
45
|
+
typePropertyOptionSetSlug: optionSetSlugById[typeProperty.typePropertyOptionSetId],
|
|
46
|
+
formula: typeProperty.formula,
|
|
47
|
+
referencedTypePath: typeProperty.referencedTypePath,
|
|
48
|
+
referencedTypeRootSlug: typeProperty.referencedTypeRootSlug,
|
|
49
|
+
typePropertyUserListId: typeProperty.typePropertyUserListId,
|
|
50
|
+
typePropertyUserListName: userListName,
|
|
51
|
+
referencedTypeRole: typeProperty.referencedTypeRole,
|
|
52
|
+
defaultValue: typeProperty.defaultValue,
|
|
53
|
+
propertyLevel: typeProperty.propertyLevel,
|
|
54
|
+
carryOverBehavior: typeProperty.carryOverBehavior,
|
|
55
|
+
carryOverDefault: typeProperty.carryOverDefault,
|
|
56
|
+
isUniqueProperty: typeProperty.isUniqueProperty,
|
|
57
|
+
isUniquePropertyInFamily: typeProperty.isUniquePropertyInFamily,
|
|
58
|
+
inherited: typeProperty.inherited,
|
|
59
|
+
formulaFunction: typeProperty.formulaFunction,
|
|
60
|
+
validationFunction: typeProperty.validationFunction,
|
|
61
|
+
numberFormat: typeProperty.numberFormat,
|
|
62
|
+
sequenceSeedValue: typeProperty.sequenceSeedValue,
|
|
63
|
+
copyBehavior: typeProperty.copyBehavior,
|
|
64
|
+
};
|
|
65
|
+
reducedTypeProperties.push(reducedTypeProperty);
|
|
66
|
+
}
|
|
67
|
+
const reducedType = {
|
|
68
|
+
typePath: type.typePath,
|
|
69
|
+
slug: type.slug,
|
|
70
|
+
label: type.label,
|
|
71
|
+
isArchived: type.isArchived,
|
|
72
|
+
typeProperties: reducedTypeProperties
|
|
73
|
+
.map((x) => {
|
|
74
|
+
delete x['id'];
|
|
75
|
+
return Object.assign({}, x);
|
|
76
|
+
})
|
|
77
|
+
.sort((one, two) => (one.slug < two.slug ? -1 : 1)),
|
|
78
|
+
};
|
|
79
|
+
reducedTypes.push(reducedType);
|
|
80
|
+
}
|
|
81
|
+
reducedTypes = reducedTypes.sort((one, two) => (one.typePath < two.typePath ? -1 : 1));
|
|
82
|
+
return reducedTypes;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
exports.getReducedTypes = getReducedTypes;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ReducedDataHolder } from '../interfaces';
|
|
2
|
-
export declare function importReducedData(reducedData: ReducedDataHolder, skipPolicies?: boolean): Promise<void>;
|
|
1
|
+
import { ReducedDataHolder } from '../interfaces';
|
|
2
|
+
export declare function importReducedData(reducedData: ReducedDataHolder, skipPolicies?: boolean): Promise<void>;
|