@contrail/cli 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/types/uploadUsageInfo.d.ts +3 -0
- package/dist/commands/types/uploadUsageInfo.js +64 -57
- package/dist/commands/types/uploadUsageInfo.spec.d.ts +1 -0
- package/dist/commands/types/uploadUsageInfo.spec.js +249 -0
- package/dist/interfaces.d.ts +25 -0
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseCommand } from '../../basecommand';
|
|
2
|
+
import { PersistReducedUsageInfo } from '../../interfaces';
|
|
2
3
|
export default class UploadUsageInfo extends BaseCommand {
|
|
3
4
|
static description: string;
|
|
4
5
|
static examples: string[];
|
|
@@ -10,3 +11,5 @@ export default class UploadUsageInfo extends BaseCommand {
|
|
|
10
11
|
run(): Promise<void>;
|
|
11
12
|
}
|
|
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadUsageInfo = void 0;
|
|
3
|
+
exports.transformReducedUsageInfoToTypeIdsFromPath = exports.persistReducedUsageInfoFields = exports.uploadUsageInfo = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_1 = require("@contrail/sdk");
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
@@ -58,80 +58,48 @@ function loadUsageInfo(dir) {
|
|
|
58
58
|
}
|
|
59
59
|
async function uploadUsageInfoObjects(loadedUsageInfo) {
|
|
60
60
|
const typesWithProperties = await (0, type_extractor_1.getTypes)();
|
|
61
|
-
const typeProperties = typesWithProperties
|
|
62
|
-
.filter((t) => !!t.typeProperties)
|
|
63
|
-
.map((t) => t.typeProperties)
|
|
64
|
-
.reduce((a, b) => a.concat(b));
|
|
65
61
|
const currentUsageInfo = await new sdk_1.Entities().get({
|
|
66
62
|
entityName: 'type-property-usage-info',
|
|
67
63
|
});
|
|
68
64
|
const currentUsageInfosHashes = {};
|
|
69
65
|
for (const currentUI of currentUsageInfo) {
|
|
70
66
|
const foundType = typesWithProperties.find((t) => t.id === currentUI.typeId);
|
|
67
|
+
const typeProperties = foundType?.typeProperties || [];
|
|
71
68
|
const foundTypeProperty = typeProperties.find((tp) => tp.id === currentUI.typePropertyId);
|
|
72
69
|
if (!foundType || !foundTypeProperty) {
|
|
73
70
|
logger_1.default.info(`skipping unhashable, invalid usage info: ${JSON.stringify(currentUI, null, 2)}`);
|
|
74
71
|
continue;
|
|
75
72
|
}
|
|
76
|
-
const hash = `${foundType.
|
|
73
|
+
const hash = `${foundType.typePath}|${foundTypeProperty.slug}`;
|
|
77
74
|
currentUsageInfosHashes[hash] = currentUI;
|
|
78
75
|
}
|
|
79
76
|
const reducedUsageInfoHashes = {};
|
|
80
77
|
for (const loadedUI of loadedUsageInfo) {
|
|
81
|
-
const hash = `${loadedUI.
|
|
78
|
+
const hash = `${loadedUI.typePath}|${loadedUI.typePropertySlug}`;
|
|
82
79
|
reducedUsageInfoHashes[hash] = loadedUI;
|
|
83
80
|
}
|
|
84
|
-
logger_1.default.debug(`current usage info: ${currentUsageInfo}`);
|
|
85
|
-
logger_1.default.debug(
|
|
81
|
+
logger_1.default.debug(`current usage info: ${JSON.stringify(currentUsageInfo)}`);
|
|
82
|
+
logger_1.default.debug(`loaded usage info: ${JSON.stringify(loadedUsageInfo)}`);
|
|
86
83
|
for (const loadedUI of loadedUsageInfo) {
|
|
87
84
|
try {
|
|
88
|
-
const found = currentUsageInfosHashes[`${loadedUI.
|
|
85
|
+
const found = currentUsageInfosHashes[`${loadedUI.typePath}|${loadedUI.typePropertySlug}`];
|
|
86
|
+
const transformedUI = transformReducedUsageInfoToTypeIdsFromPath(loadedUI, typesWithProperties);
|
|
87
|
+
if (!transformedUI) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
89
90
|
if (!found) {
|
|
90
|
-
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
logger_1.default.debug(`Creating: ${loadedUI}`);
|
|
91
|
+
logger_1.default.debug(`Creating: ${JSON.stringify(transformedUI)}`);
|
|
94
92
|
await new sdk_1.Entities().create({
|
|
95
93
|
entityName: 'type-property-usage-info',
|
|
96
|
-
object:
|
|
97
|
-
typePropertyId: loadedUI.typePropertyId,
|
|
98
|
-
typeId: loadedUI.typeId,
|
|
99
|
-
editable: loadedUI.editable,
|
|
100
|
-
used: loadedUI.used,
|
|
101
|
-
formulaFunction: loadedUI.formulaFunction,
|
|
102
|
-
validationFunction: loadedUI.validationFunction,
|
|
103
|
-
numberFormat: loadedUI.numberFormat,
|
|
104
|
-
defaultValue: loadedUI.defaultValue,
|
|
105
|
-
label: loadedUI.label,
|
|
106
|
-
isArchived: loadedUI.isArchived,
|
|
107
|
-
},
|
|
94
|
+
object: transformedUI,
|
|
108
95
|
});
|
|
109
96
|
}
|
|
110
97
|
else {
|
|
111
|
-
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
logger_1.default.info(`Updating: ${loadedUI}`);
|
|
98
|
+
logger_1.default.info(`Updating: ${JSON.stringify(transformedUI)}`);
|
|
115
99
|
await new sdk_1.Entities().update({
|
|
116
100
|
entityName: 'type-property-usage-info',
|
|
117
101
|
id: found.id,
|
|
118
|
-
object:
|
|
119
|
-
editable: loadedUI?.editable,
|
|
120
|
-
used: loadedUI?.used,
|
|
121
|
-
formulaFunction: loadedUI?.formulaFunction,
|
|
122
|
-
validationFunction: loadedUI?.validationFunction,
|
|
123
|
-
numberFormat: loadedUI?.numberFormat,
|
|
124
|
-
defaultValue: loadedUI?.defaultValue,
|
|
125
|
-
label: loadedUI?.label,
|
|
126
|
-
required: loadedUI?.required,
|
|
127
|
-
searchable: loadedUI?.searchable,
|
|
128
|
-
isUniqueProperty: loadedUI?.isUniqueProperty,
|
|
129
|
-
isUniquePropertyInFamily: loadedUI?.isUniquePropertyInFamily,
|
|
130
|
-
copyBehavior: loadedUI?.copyBehavior,
|
|
131
|
-
copyDefault: loadedUI?.copyDefault,
|
|
132
|
-
propertyLevel: loadedUI?.propertyLevel,
|
|
133
|
-
isArchived: loadedUI?.isArchived,
|
|
134
|
-
},
|
|
102
|
+
object: transformedUI,
|
|
135
103
|
});
|
|
136
104
|
}
|
|
137
105
|
}
|
|
@@ -155,19 +123,58 @@ async function uploadUsageInfoObjects(loadedUsageInfo) {
|
|
|
155
123
|
}
|
|
156
124
|
}
|
|
157
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
|
+
];
|
|
158
153
|
// transforms the reduced Usage Info from name slugs to ids
|
|
159
|
-
function
|
|
160
|
-
const foundType = types.find((t) => t.
|
|
154
|
+
function transformReducedUsageInfoToTypeIdsFromPath(reducedUsageInfo, types) {
|
|
155
|
+
const foundType = types.find((t) => t.typePath === reducedUsageInfo.typePath);
|
|
161
156
|
if (!foundType) {
|
|
162
|
-
logger_1.default.error(`Could not find type with
|
|
163
|
-
return
|
|
157
|
+
logger_1.default.error(`Could not find type with typePath ${reducedUsageInfo.typePath} while transforming ${reducedUsageInfo.typePropertySlug}`);
|
|
158
|
+
return undefined;
|
|
164
159
|
}
|
|
165
|
-
|
|
166
|
-
const foundTypeProperty = typeProperties.find((tp) => tp.slug === reducedUsageInfo.typePropertySlug);
|
|
160
|
+
const foundTypeProperty = foundType.typeProperties?.find((tp) => tp.slug === reducedUsageInfo.typePropertySlug);
|
|
167
161
|
if (!foundTypeProperty) {
|
|
168
|
-
logger_1.default.error(`Could not find type property with slug ${reducedUsageInfo.typePropertySlug} while transforming ${reducedUsageInfo}`);
|
|
169
|
-
return
|
|
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
|
+
}
|
|
170
177
|
}
|
|
171
|
-
|
|
172
|
-
return true;
|
|
178
|
+
return persistedUsageInfo;
|
|
173
179
|
}
|
|
180
|
+
exports.transformReducedUsageInfoToTypeIdsFromPath = transformReducedUsageInfoToTypeIdsFromPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
});
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -370,6 +370,31 @@ export interface ReducedOptionSet {
|
|
|
370
370
|
isArchived: boolean;
|
|
371
371
|
optionSet: any[];
|
|
372
372
|
}
|
|
373
|
+
export interface ReducedUsageInfo {
|
|
374
|
+
typeId: string;
|
|
375
|
+
typePropertyId: string;
|
|
376
|
+
typePath: string;
|
|
377
|
+
typePropertySlug: string;
|
|
378
|
+
editable: boolean;
|
|
379
|
+
used: boolean;
|
|
380
|
+
formulaFunction?: string;
|
|
381
|
+
validationFunction?: string;
|
|
382
|
+
numberFormat?: any;
|
|
383
|
+
defaultValue?: string;
|
|
384
|
+
label?: string;
|
|
385
|
+
required?: boolean;
|
|
386
|
+
searchable?: boolean;
|
|
387
|
+
isUniqueProperty?: boolean;
|
|
388
|
+
isUniquePropertyInFamily?: boolean;
|
|
389
|
+
copyBehavior?: string;
|
|
390
|
+
copyDefault?: string;
|
|
391
|
+
propertyLevel?: string;
|
|
392
|
+
isArchived: boolean;
|
|
393
|
+
isFederationProperty?: boolean;
|
|
394
|
+
carryOverBehavior?: string;
|
|
395
|
+
carryOverDefault?: string;
|
|
396
|
+
}
|
|
397
|
+
export type PersistReducedUsageInfo = Omit<ReducedUsageInfo, 'typePath' | 'typePropertySlug'>;
|
|
373
398
|
export declare enum PropertyType {
|
|
374
399
|
Text = "text",
|
|
375
400
|
String = "string",
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contrail-cli": "./bin/run",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"/oclif.manifest.json"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@contrail/entity-types": "^1.
|
|
26
|
-
"@contrail/org-config-migration": "^1.1.
|
|
27
|
-
"@contrail/sdk": "^1.
|
|
28
|
-
"@contrail/types": "^3.
|
|
29
|
-
"@contrail/util": "^1.
|
|
25
|
+
"@contrail/entity-types": "^1.6.0",
|
|
26
|
+
"@contrail/org-config-migration": "^1.1.13",
|
|
27
|
+
"@contrail/sdk": "^1.5.5",
|
|
28
|
+
"@contrail/types": "^3.1.5",
|
|
29
|
+
"@contrail/util": "^1.2.0",
|
|
30
30
|
"@oclif/core": "^2",
|
|
31
31
|
"@oclif/plugin-autocomplete": "^2.1.4",
|
|
32
32
|
"@oclif/plugin-help": "^5",
|