@contrail/cli 3.5.2 → 3.5.3-alpha.0e9434c

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 (67) hide show
  1. package/README.md +11 -29
  2. package/dist/api/types.d.ts +0 -5
  3. package/dist/api/types.js +1 -36
  4. package/dist/commands/types/getAll.js +0 -18
  5. package/dist/commands/types/loadAll.js +0 -2
  6. package/dist/commands/types/mergeTypeProperties.js +0 -5
  7. package/dist/commands/types/uploadOptionSetHierarchies.js +0 -117
  8. package/dist/commands/types/uploadOptionSets.js +1 -1
  9. package/dist/commands/types/uploadRuleSets.js +2 -85
  10. package/dist/commands/types/uploadTypeOverrides.js +10 -2
  11. package/dist/commands/types/uploadTypePolicies.js +2 -86
  12. package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
  13. package/dist/commands/types/uploadTypePropertyPolicies.js +3 -139
  14. package/dist/commands/workflow-templates/export.d.ts +3 -1
  15. package/dist/commands/workflow-templates/export.js +105 -28
  16. package/dist/helpers/types/type-uploader.js +1 -1
  17. package/dist/helpers/workflow-templates/helper.d.ts +1 -0
  18. package/dist/helpers/workflow-templates/helper.js +27 -6
  19. package/dist/interfaces.d.ts +0 -25
  20. package/dist/templates/typescript/tsup.config.ts +0 -0
  21. package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
  22. package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
  23. package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
  24. package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
  25. package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
  26. package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
  27. package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
  28. package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
  29. package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
  30. package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
  31. package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
  32. package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
  33. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
  34. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
  35. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
  36. package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
  37. package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
  38. package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
  39. package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
  40. package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
  41. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
  42. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
  43. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
  44. package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
  45. package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
  46. package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
  47. package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
  48. package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
  49. package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
  50. package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
  51. package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
  52. package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
  53. package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
  54. package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
  55. package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
  56. package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
  57. package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
  58. package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
  59. package/node_modules/@contrail/org-config-migration/package.json +1 -1
  60. package/oclif.manifest.json +15 -56
  61. package/package.json +2 -2
  62. package/dist/commands/types/uploadUsageInfo.d.ts +0 -15
  63. package/dist/commands/types/uploadUsageInfo.js +0 -180
  64. package/dist/commands/types/uploadUsageInfo.spec.d.ts +0 -1
  65. package/dist/commands/types/uploadUsageInfo.spec.js +0 -249
  66. package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
  67. package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
@@ -1,249 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const uploadUsageInfo_1 = require("./uploadUsageInfo");
5
- const logger_1 = tslib_1.__importDefault(require("../../logger"));
6
- // Mock the logger
7
- jest.mock('../../logger', () => ({
8
- error: jest.fn(),
9
- info: jest.fn(),
10
- debug: jest.fn(),
11
- }));
12
- describe('transformReducedUsageInfoToTypeIdsFromPath', () => {
13
- const mockTypes = [
14
- {
15
- id: 'type-123',
16
- typePath: 'product/clothing',
17
- typeProperties: [
18
- {
19
- id: 'prop-456',
20
- slug: 'color',
21
- },
22
- {
23
- id: 'prop-789',
24
- slug: 'size',
25
- },
26
- ],
27
- },
28
- {
29
- id: 'type-abc',
30
- typePath: 'product/electronics',
31
- typeProperties: [
32
- {
33
- id: 'prop-def',
34
- slug: 'brand',
35
- },
36
- ],
37
- },
38
- ];
39
- beforeEach(() => {
40
- jest.clearAllMocks();
41
- });
42
- it('should successfully transform a valid reducedUsageInfo object', () => {
43
- const reducedUsageInfo = {
44
- typePath: 'product/clothing',
45
- typePropertySlug: 'color',
46
- editable: true,
47
- used: true,
48
- label: 'Color',
49
- extraProperty: 'should be removed',
50
- };
51
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
52
- expect(result).toBeDefined();
53
- expect(result.typeId).toBe('type-123');
54
- expect(result.typePropertyId).toBe('prop-456');
55
- expect(result.extraProperty).toBeUndefined();
56
- expect(result.editable).toBe(true);
57
- expect(result.used).toBe(true);
58
- expect(result.label).toBe('Color');
59
- // Verify original object is not mutated
60
- expect(reducedUsageInfo.typeId).toBeUndefined();
61
- expect(reducedUsageInfo.typePropertyId).toBeUndefined();
62
- });
63
- it('should return undefined when type is not found', () => {
64
- const reducedUsageInfo = {
65
- typePath: 'product/nonexistent',
66
- typePropertySlug: 'color',
67
- editable: true,
68
- };
69
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
70
- expect(result).toBeUndefined();
71
- expect(logger_1.default.error).toHaveBeenCalledWith(expect.stringContaining('Could not find type with typePath product/nonexistent'));
72
- // Verify original object is not mutated
73
- expect(reducedUsageInfo.typeId).toBeUndefined();
74
- expect(reducedUsageInfo.typePropertyId).toBeUndefined();
75
- });
76
- it('should return undefined when type property is not found', () => {
77
- const reducedUsageInfo = {
78
- typePath: 'product/clothing',
79
- typePropertySlug: 'nonexistent-property',
80
- editable: true,
81
- };
82
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
83
- expect(result).toBeUndefined();
84
- expect(logger_1.default.error).toHaveBeenCalledWith(expect.stringContaining('Could not find type property with slug nonexistent-property'));
85
- // Verify original object is not mutated
86
- expect(reducedUsageInfo.typeId).toBeUndefined();
87
- expect(reducedUsageInfo.typePropertyId).toBeUndefined();
88
- });
89
- it('should exclude properties not in persistReducedUsageInfoFields', () => {
90
- const reducedUsageInfo = {
91
- typePath: 'product/clothing',
92
- typePropertySlug: 'color',
93
- editable: true,
94
- used: false,
95
- formulaFunction: 'someFormula',
96
- extraField1: 'value1',
97
- extraField2: 'value2',
98
- randomProperty: 123,
99
- };
100
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
101
- expect(result).toBeDefined();
102
- expect(result.extraField1).toBeUndefined();
103
- expect(result.extraField2).toBeUndefined();
104
- expect(result.randomProperty).toBeUndefined();
105
- expect(result.editable).toBeDefined();
106
- expect(result.used).toBeDefined();
107
- expect(result.formulaFunction).toBeDefined();
108
- });
109
- it('should preserve all valid persistReducedUsageInfoFields', () => {
110
- const reducedUsageInfo = {
111
- typePath: 'product/electronics',
112
- typePropertySlug: 'brand',
113
- editable: true,
114
- used: true,
115
- formulaFunction: 'formula',
116
- validationFunction: 'validation',
117
- numberFormat: '0.00',
118
- defaultValue: 'default',
119
- label: 'Brand',
120
- required: true,
121
- searchable: true,
122
- isUniqueProperty: false,
123
- isUniquePropertyInFamily: false,
124
- copyBehavior: 'copy',
125
- copyDefault: true,
126
- propertyLevel: 'instance',
127
- isArchived: false,
128
- shouldBeRemoved: 'extra',
129
- isFederationProperty: false,
130
- carryOverBehavior: 'carry',
131
- carryOverDefault: 'default',
132
- };
133
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
134
- expect(result).toBeDefined();
135
- expect(result.typeId).toBe('type-abc');
136
- expect(result.typePropertyId).toBe('prop-def');
137
- expect(result.shouldBeRemoved).toBeUndefined();
138
- // Verify all valid fields are preserved
139
- uploadUsageInfo_1.persistReducedUsageInfoFields.forEach((field) => {
140
- expect(result[field]).toBeDefined();
141
- });
142
- });
143
- it('should return undefined for empty types array', () => {
144
- const reducedUsageInfo = {
145
- typePath: 'product/clothing',
146
- typePropertySlug: 'color',
147
- editable: true,
148
- };
149
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, []);
150
- expect(result).toBeUndefined();
151
- expect(logger_1.default.error).toHaveBeenCalled();
152
- });
153
- it('should return undefined for type with empty typeProperties array', () => {
154
- const typesWithEmptyProps = [
155
- {
156
- id: 'type-123',
157
- typePath: 'product/clothing',
158
- typeProperties: [],
159
- },
160
- ];
161
- const reducedUsageInfo = {
162
- typePath: 'product/clothing',
163
- typePropertySlug: 'color',
164
- editable: true,
165
- };
166
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, typesWithEmptyProps);
167
- expect(result).toBeUndefined();
168
- expect(logger_1.default.error).toHaveBeenCalledWith(expect.stringContaining('Could not find type property with slug color'));
169
- });
170
- it('should not mutate the original object', () => {
171
- const reducedUsageInfo = {
172
- typePath: 'product/clothing',
173
- typePropertySlug: 'size',
174
- editable: false,
175
- extraProp: 'remove',
176
- };
177
- const originalRef = reducedUsageInfo;
178
- const result = (0, uploadUsageInfo_1.transformReducedUsageInfoToTypeIdsFromPath)(reducedUsageInfo, mockTypes);
179
- // Verify the original object is not mutated
180
- expect(reducedUsageInfo).toBe(originalRef);
181
- expect(reducedUsageInfo.typeId).toBeUndefined();
182
- expect(reducedUsageInfo.typePropertyId).toBeUndefined();
183
- expect(reducedUsageInfo.extraProp).toBe('remove');
184
- // Verify result is a new object with correct data
185
- expect(result).toBeDefined();
186
- expect(result.typeId).toBe('type-123');
187
- expect(result.typePropertyId).toBe('prop-789');
188
- expect(result.extraProp).toBeUndefined();
189
- });
190
- });
191
- describe('persistReducedUsageInfoFields validation', () => {
192
- it('should contain all properties from PersistReducedUsageInfo interface', () => {
193
- // Create a sample object with all required properties from PersistReducedUsageInfo
194
- // This will fail at compile time if we're missing any properties
195
- const samplePersistReducedUsageInfo = {
196
- typeId: 'type-123',
197
- typePropertyId: 'prop-456',
198
- editable: true,
199
- used: true,
200
- formulaFunction: 'formula',
201
- validationFunction: 'validation',
202
- numberFormat: '0.00',
203
- defaultValue: 'default',
204
- label: 'Label',
205
- required: true,
206
- searchable: true,
207
- isUniqueProperty: false,
208
- isUniquePropertyInFamily: false,
209
- copyBehavior: 'copy',
210
- copyDefault: 'default',
211
- propertyLevel: 'instance',
212
- isArchived: false,
213
- isFederationProperty: false,
214
- carryOverBehavior: 'carry',
215
- carryOverDefault: 'default',
216
- };
217
- // Get all keys from the sample object
218
- const allKeys = Object.keys(samplePersistReducedUsageInfo);
219
- // Verify that every key exists in persistReducedUsageInfoFields
220
- const missingKeys = [];
221
- allKeys.forEach((key) => {
222
- if (!uploadUsageInfo_1.persistReducedUsageInfoFields.includes(key)) {
223
- missingKeys.push(key);
224
- }
225
- });
226
- // This test will fail if any keys are missing
227
- expect(missingKeys).toEqual([]);
228
- expect(missingKeys.length).toBe(0);
229
- });
230
- it('should contain only valid properties from PersistReducedUsageInfo interface', () => {
231
- // Verify no extra keys that don't exist in the interface
232
- // This is more of a documentation test - TypeScript already enforces this at compile time
233
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
234
- const samplePersistReducedUsageInfo = {
235
- typeId: 'type-123',
236
- typePropertyId: 'prop-456',
237
- editable: true,
238
- used: true,
239
- isArchived: false,
240
- };
241
- // Every field in the array should be a valid key
242
- uploadUsageInfo_1.persistReducedUsageInfoFields.forEach((field) => {
243
- // TypeScript ensures this at compile time, but we can document it in tests
244
- expect(typeof field).toBe('string');
245
- // Also verify the field could exist in the sample
246
- expect(field).toBeTruthy();
247
- });
248
- });
249
- });
@@ -1,2 +0,0 @@
1
- import { DataHolder } from '../interfaces';
2
- export declare function getReducedUsageInfo(data: DataHolder): any[];
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReducedUsageInfo = void 0;
4
- function getReducedUsageInfo(data) {
5
- var _a, _b;
6
- if (!(data === null || data === void 0 ? void 0 : data.usageInfo) || !(data === null || data === void 0 ? void 0 : data.types)) {
7
- return [];
8
- }
9
- const typeProperties = ((_a = data.types) !== null && _a !== void 0 ? _a : []).flatMap((type) => { var _a; return (_a = type.typeProperties) !== null && _a !== void 0 ? _a : []; });
10
- return (_b = data === null || data === void 0 ? void 0 : data.usageInfo) === null || _b === void 0 ? void 0 : _b.map((x) => {
11
- const type = data.types.find((y) => y.id === x.typeId);
12
- const typeProperty = typeProperties.find((y) => y.id === x.typePropertyId);
13
- const typePropertySlug = typeProperty === null || typeProperty === void 0 ? void 0 : typeProperty.slug;
14
- return {
15
- used: x.used,
16
- editable: x.editable,
17
- formulaFunction: x.formulaFunction,
18
- validationFunction: x.validationFunction,
19
- numberFormat: x.numberFormat,
20
- defaultValue: x.defaultValue,
21
- label: x.label,
22
- typeSlug: type === null || type === void 0 ? void 0 : type.slug,
23
- typePath: type === null || type === void 0 ? void 0 : type.typePath,
24
- typePropertySlug,
25
- required: x.required,
26
- searchable: x.searchable,
27
- isUniqueProperty: x.isUniqueProperty,
28
- isUniquePropertyInFamily: x.isUniquePropertyInFamily,
29
- copyBehavior: x.copyBehavior,
30
- copyDefault: x.copyDefault,
31
- propertyLevel: x.propertyLevel,
32
- isArchived: x.isArchived,
33
- isFederationProperty: x.isFederationProperty,
34
- carryOverBehavior: x.carryOverBehavior,
35
- carryOverDefault: x.carryOverDefault,
36
- };
37
- }).sort((one, two) => (one.typePath < two.typePath ? -1 : 1));
38
- }
39
- exports.getReducedUsageInfo = getReducedUsageInfo;