@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.
Files changed (69) hide show
  1. package/README.md +10 -28
  2. package/dist/api/types.d.ts +0 -5
  3. package/dist/api/types.js +1 -36
  4. package/dist/commands/projects/export.d.ts +1 -0
  5. package/dist/commands/projects/export.js +19 -5
  6. package/dist/commands/types/getAll.js +0 -18
  7. package/dist/commands/types/loadAll.js +0 -2
  8. package/dist/commands/types/mergeTypeProperties.js +0 -5
  9. package/dist/commands/types/uploadOptionSetHierarchies.js +0 -117
  10. package/dist/commands/types/uploadOptionSets.js +1 -1
  11. package/dist/commands/types/uploadRuleSets.js +2 -85
  12. package/dist/commands/types/uploadTypeOverrides.js +10 -2
  13. package/dist/commands/types/uploadTypePolicies.js +2 -86
  14. package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
  15. package/dist/commands/types/uploadTypePropertyPolicies.js +3 -139
  16. package/dist/helpers/projects/helpers.d.ts +2 -1
  17. package/dist/helpers/projects/helpers.js +37 -2
  18. package/dist/helpers/projects/post-processor.d.ts +131 -0
  19. package/dist/helpers/projects/post-processor.js +519 -0
  20. package/dist/helpers/types/type-uploader.js +1 -1
  21. package/dist/interfaces.d.ts +0 -25
  22. package/dist/templates/typescript/tsup.config.ts +0 -0
  23. package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
  24. package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
  25. package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
  26. package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
  27. package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
  28. package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
  29. package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
  30. package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
  31. package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
  32. package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
  33. package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
  34. package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
  35. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
  36. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
  37. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
  38. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
  39. package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
  40. package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
  41. package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
  42. package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
  43. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
  44. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
  45. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
  46. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
  47. package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
  48. package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
  49. package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
  50. package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
  51. package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
  52. package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
  53. package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
  54. package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
  55. package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
  56. package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
  57. package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
  58. package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
  59. package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
  60. package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
  61. package/node_modules/@contrail/org-config-migration/package.json +1 -1
  62. package/oclif.manifest.json +11 -55
  63. package/package.json +2 -2
  64. package/dist/commands/types/uploadUsageInfo.d.ts +0 -15
  65. package/dist/commands/types/uploadUsageInfo.js +0 -180
  66. package/dist/commands/types/uploadUsageInfo.spec.d.ts +0 -1
  67. package/dist/commands/types/uploadUsageInfo.spec.js +0 -249
  68. package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
  69. package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
@@ -1,41 +1,41 @@
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
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.uploadUsers = void 0;
27
- const sdk_1 = require("@contrail/sdk");
28
- const p_limit_1 = __importDefault(require("p-limit"));
29
- const limit = (0, p_limit_1.default)(5);
30
- function uploadUsers(users, entitiesInstance = new sdk_1.Entities()) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- yield Promise.all(users.map((user) => limit(() => __awaiter(this, void 0, void 0, function* () {
33
- const { email } = user, rest = __rest(user, ["email"]);
34
- yield entitiesInstance.create({
35
- entityName: 'user-org',
36
- object: Object.assign({ userEmail: email }, rest),
37
- });
38
- }))));
39
- });
40
- }
41
- exports.uploadUsers = uploadUsers;
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
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.uploadUsers = void 0;
27
+ const sdk_1 = require("@contrail/sdk");
28
+ const p_limit_1 = __importDefault(require("p-limit"));
29
+ const limit = (0, p_limit_1.default)(5);
30
+ function uploadUsers(users, entitiesInstance = new sdk_1.Entities()) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ yield Promise.all(users.map((user) => limit(() => __awaiter(this, void 0, void 0, function* () {
33
+ const { email } = user, rest = __rest(user, ["email"]);
34
+ yield entitiesInstance.create({
35
+ entityName: 'user-org',
36
+ object: Object.assign({ userEmail: email }, rest),
37
+ });
38
+ }))));
39
+ });
40
+ }
41
+ exports.uploadUsers = uploadUsers;
@@ -1,2 +1,2 @@
1
- export * from './export';
2
- export * from './import';
1
+ export * from './export';
2
+ export * from './import';
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./export"), exports);
18
- __exportStar(require("./import"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./export"), exports);
18
+ __exportStar(require("./import"), exports);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/org-config-migration",
3
- "version": "1.1.13",
3
+ "version": "1.2.0",
4
4
  "description": "A collection of utilities that helps with importing and exporting of types, users, groups, and workflows.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.2",
2
+ "version": "3.5.3-alpha.317fe63",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -1241,14 +1241,15 @@
1241
1241
  },
1242
1242
  "projects:export": {
1243
1243
  "id": "projects:export",
1244
- "description": "Export a project.",
1244
+ "description": "Export a project with optional post-processing.",
1245
1245
  "strict": true,
1246
1246
  "pluginName": "@contrail/cli",
1247
1247
  "pluginAlias": "@contrail/cli",
1248
1248
  "pluginType": "core",
1249
1249
  "aliases": [],
1250
1250
  "examples": [
1251
- "$ contrail project export <PROJECT_NAME>\n"
1251
+ "$ contrail project export <PROJECT_NAME>",
1252
+ "$ contrail project export <PROJECT_NAME> --process"
1252
1253
  ],
1253
1254
  "flags": {
1254
1255
  "logLevel": {
@@ -1277,12 +1278,18 @@
1277
1278
  "false"
1278
1279
  ],
1279
1280
  "default": "true"
1281
+ },
1282
+ "process": {
1283
+ "name": "process",
1284
+ "type": "boolean",
1285
+ "description": "Enable post-processing of exported project data",
1286
+ "allowNo": false
1280
1287
  }
1281
1288
  },
1282
1289
  "args": {
1283
1290
  "projectName": {
1284
1291
  "name": "projectName",
1285
- "description": "",
1292
+ "description": "Name or identifier of the project to export",
1286
1293
  "required": true
1287
1294
  }
1288
1295
  }
@@ -2520,57 +2527,6 @@
2520
2527
  },
2521
2528
  "args": {}
2522
2529
  },
2523
- "types:uploadUsageInfo": {
2524
- "id": "types:uploadUsageInfo",
2525
- "description": "Upload extracted usage info",
2526
- "strict": true,
2527
- "pluginName": "@contrail/cli",
2528
- "pluginAlias": "@contrail/cli",
2529
- "pluginType": "core",
2530
- "aliases": [],
2531
- "examples": [
2532
- "$ contrail types uploadUsageInfo\n"
2533
- ],
2534
- "flags": {
2535
- "logLevel": {
2536
- "name": "logLevel",
2537
- "type": "option",
2538
- "char": "l",
2539
- "description": "The Log Level",
2540
- "required": false,
2541
- "multiple": false,
2542
- "options": [
2543
- "error",
2544
- "warn",
2545
- "info",
2546
- "debug"
2547
- ]
2548
- },
2549
- "alwaysConfirmEnv": {
2550
- "name": "alwaysConfirmEnv",
2551
- "type": "option",
2552
- "char": "e",
2553
- "description": "The Environment variables",
2554
- "required": false,
2555
- "multiple": false,
2556
- "options": [
2557
- "true",
2558
- "false"
2559
- ],
2560
- "default": "true"
2561
- },
2562
- "dir": {
2563
- "name": "dir",
2564
- "type": "option",
2565
- "char": "d",
2566
- "description": "The directory from which to export the usage info data. Defaults to the current directory. The usage info data will be loaded from $dir/usage-info.yml",
2567
- "required": false,
2568
- "multiple": false,
2569
- "default": "."
2570
- }
2571
- },
2572
- "args": {}
2573
- },
2574
2530
  "users:export": {
2575
2531
  "id": "users:export",
2576
2532
  "description": "Export all users in the org.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/cli",
3
- "version": "3.5.2",
3
+ "version": "3.5.3-alpha.317fe63",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@contrail/entity-types": "^1.6.1",
34
34
  "@contrail/loader": "^2.0.9",
35
- "@contrail/org-config-migration": "^1.1.13",
35
+ "@contrail/org-config-migration": "^1.2.0",
36
36
  "@contrail/sdk": "^1.5.13",
37
37
  "@contrail/types": "^3.1.5",
38
38
  "@contrail/util": "^1.2.0",
@@ -1,15 +0,0 @@
1
- import { BaseCommand } from '../../basecommand';
2
- import { PersistReducedUsageInfo } from '../../interfaces';
3
- export default class UploadUsageInfo extends BaseCommand {
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
- };
11
- run(): Promise<void>;
12
- }
13
- export declare function uploadUsageInfo(dir: string): Promise<void>;
14
- export declare const persistReducedUsageInfoFields: readonly ["typeId", "typePropertyId", "editable", "used", "formulaFunction", "validationFunction", "numberFormat", "defaultValue", "label", "required", "searchable", "isUniqueProperty", "isUniquePropertyInFamily", "copyBehavior", "copyDefault", "propertyLevel", "isArchived", "isFederationProperty", "carryOverBehavior", "carryOverDefault"];
15
- export declare function transformReducedUsageInfoToTypeIdsFromPath(reducedUsageInfo: any, types: any): PersistReducedUsageInfo | undefined;
@@ -1,180 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformReducedUsageInfoToTypeIdsFromPath = exports.persistReducedUsageInfoFields = exports.uploadUsageInfo = void 0;
4
- const tslib_1 = require("tslib");
5
- const sdk_1 = require("@contrail/sdk");
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const login_1 = require("../../auth/login");
8
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
- const path = tslib_1.__importStar(require("path"));
10
- const core_1 = require("@oclif/core");
11
- const type_extractor_1 = require("../../helpers/types/type-extractor");
12
- const basecommand_1 = require("../../basecommand");
13
- const logger_1 = tslib_1.__importDefault(require("../../logger"));
14
- const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
15
- class UploadUsageInfo extends basecommand_1.BaseCommand {
16
- static description = 'Upload extracted usage info';
17
- static examples = [
18
- `$ contrail types uploadUsageInfo
19
- `,
20
- ];
21
- static flags = {
22
- ...basecommand_1.BaseCommand.baseFlags,
23
- dir: core_1.Flags.string({
24
- char: 'd',
25
- description: 'The directory from which to export the usage info data. Defaults to the current directory. The usage info data will be loaded from $dir/usage-info.yml',
26
- required: false,
27
- default: '.',
28
- }),
29
- };
30
- async run() {
31
- await uploadUsageInfo(this.flags.dir);
32
- }
33
- }
34
- exports.default = UploadUsageInfo;
35
- async function uploadUsageInfo(dir) {
36
- try {
37
- await (0, login_1.authUser)();
38
- logger_1.default.info(`${chalk_1.default.yellow.bold('USAGE INFO')} Uploading`);
39
- const reducedUsageInfo = await loadUsageInfo(dir);
40
- await uploadUsageInfoObjects(reducedUsageInfo);
41
- logger_1.default.info(`${chalk_1.default.yellow.bold('USAGE INFO')} Uploaded`);
42
- }
43
- catch (e) {
44
- logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Usage Info Upload Failed . ${e}`);
45
- return;
46
- }
47
- logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Usage Info Upload Complete.`);
48
- }
49
- exports.uploadUsageInfo = uploadUsageInfo;
50
- function loadUsageInfo(dir) {
51
- try {
52
- const doc = js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, 'usage-info.yml'), 'utf8'));
53
- return doc;
54
- }
55
- catch (e) {
56
- throw new Error(`ERROR PARSING YAML: ${e}`);
57
- }
58
- }
59
- async function uploadUsageInfoObjects(loadedUsageInfo) {
60
- const typesWithProperties = await (0, type_extractor_1.getTypes)();
61
- const currentUsageInfo = await new sdk_1.Entities().get({
62
- entityName: 'type-property-usage-info',
63
- });
64
- const currentUsageInfosHashes = {};
65
- for (const currentUI of currentUsageInfo) {
66
- const foundType = typesWithProperties.find((t) => t.id === currentUI.typeId);
67
- const typeProperties = foundType?.typeProperties || [];
68
- const foundTypeProperty = typeProperties.find((tp) => tp.id === currentUI.typePropertyId);
69
- if (!foundType || !foundTypeProperty) {
70
- logger_1.default.info(`skipping unhashable, invalid usage info: ${JSON.stringify(currentUI, null, 2)}`);
71
- continue;
72
- }
73
- const hash = `${foundType.typePath}|${foundTypeProperty.slug}`;
74
- currentUsageInfosHashes[hash] = currentUI;
75
- }
76
- const reducedUsageInfoHashes = {};
77
- for (const loadedUI of loadedUsageInfo) {
78
- const hash = `${loadedUI.typePath}|${loadedUI.typePropertySlug}`;
79
- reducedUsageInfoHashes[hash] = loadedUI;
80
- }
81
- logger_1.default.debug(`current usage info: ${JSON.stringify(currentUsageInfo)}`);
82
- logger_1.default.debug(`loaded usage info: ${JSON.stringify(loadedUsageInfo)}`);
83
- for (const loadedUI of loadedUsageInfo) {
84
- try {
85
- const found = currentUsageInfosHashes[`${loadedUI.typePath}|${loadedUI.typePropertySlug}`];
86
- const transformedUI = transformReducedUsageInfoToTypeIdsFromPath(loadedUI, typesWithProperties);
87
- if (!transformedUI) {
88
- continue;
89
- }
90
- if (!found) {
91
- logger_1.default.debug(`Creating: ${JSON.stringify(transformedUI)}`);
92
- await new sdk_1.Entities().create({
93
- entityName: 'type-property-usage-info',
94
- object: transformedUI,
95
- });
96
- }
97
- else {
98
- logger_1.default.info(`Updating: ${JSON.stringify(transformedUI)}`);
99
- await new sdk_1.Entities().update({
100
- entityName: 'type-property-usage-info',
101
- id: found.id,
102
- object: transformedUI,
103
- });
104
- }
105
- }
106
- catch (err) {
107
- logger_1.default.error(`Error Uploading usage info: ${err}`);
108
- }
109
- }
110
- for (const [hash, currentUI] of Object.entries(currentUsageInfosHashes)) {
111
- try {
112
- const found = reducedUsageInfoHashes[hash];
113
- if (!found) {
114
- logger_1.default.debug(`Creating: ${hash}`);
115
- await new sdk_1.Entities().delete({
116
- entityName: 'type-property-usage-info',
117
- id: currentUI['id'],
118
- });
119
- }
120
- }
121
- catch (err) {
122
- logger_1.default.error(`Error Deleting usage info: ${err}`);
123
- }
124
- }
125
- }
126
- //This should contain the property keys in PersistReducedUsageInfo in interfaces.ts
127
- //except for typePath and typePropertySlug which are used for transformation but not persisted to the database.
128
- // If you add a new property to PersistReducedUsageInfo, you need to add it to this array to be persisted to the database.
129
- exports.persistReducedUsageInfoFields = [
130
- // 'typePath',
131
- // 'typePropertySlug',
132
- 'typeId',
133
- 'typePropertyId',
134
- 'editable',
135
- 'used',
136
- 'formulaFunction',
137
- 'validationFunction',
138
- 'numberFormat',
139
- 'defaultValue',
140
- 'label',
141
- 'required',
142
- 'searchable',
143
- 'isUniqueProperty',
144
- 'isUniquePropertyInFamily',
145
- 'copyBehavior',
146
- 'copyDefault',
147
- 'propertyLevel',
148
- 'isArchived',
149
- 'isFederationProperty',
150
- 'carryOverBehavior',
151
- 'carryOverDefault',
152
- ];
153
- // transforms the reduced Usage Info from name slugs to ids
154
- function transformReducedUsageInfoToTypeIdsFromPath(reducedUsageInfo, types) {
155
- const foundType = types.find((t) => t.typePath === reducedUsageInfo.typePath);
156
- if (!foundType) {
157
- logger_1.default.error(`Could not find type with typePath ${reducedUsageInfo.typePath} while transforming ${reducedUsageInfo.typePropertySlug}`);
158
- return undefined;
159
- }
160
- const foundTypeProperty = foundType.typeProperties?.find((tp) => tp.slug === reducedUsageInfo.typePropertySlug);
161
- if (!foundTypeProperty) {
162
- logger_1.default.error(`Could not find type property with slug ${reducedUsageInfo.typePropertySlug} while transforming ${JSON.stringify(reducedUsageInfo)}`);
163
- return undefined;
164
- }
165
- // Create a new object with only the properties that are in the persistReducedUsageInfoFields array
166
- // If there is a compile error on the code below, it means you added a new property to PersistReducedUsageInfo
167
- // interface in interfaces.ts but forgot to add it to the persistReducedUsageInfoFields array above,
168
- // It needs to be added to be persisted to the database.
169
- const persistedUsageInfo = {
170
- typeId: foundType.id,
171
- typePropertyId: foundTypeProperty.id,
172
- };
173
- for (const key of Object.keys(reducedUsageInfo)) {
174
- if (exports.persistReducedUsageInfoFields.includes(key)) {
175
- persistedUsageInfo[key] = reducedUsageInfo[key];
176
- }
177
- }
178
- return persistedUsageInfo;
179
- }
180
- exports.transformReducedUsageInfoToTypeIdsFromPath = transformReducedUsageInfoToTypeIdsFromPath;
@@ -1 +0,0 @@
1
- export {};