@contrail/cli 3.5.1-alpha.fd40e6d → 3.5.2-alpha.39ff2c1

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 CHANGED
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
17
17
  $ contrail COMMAND
18
18
  running command...
19
19
  $ contrail (--version)
20
- @contrail/cli/3.5.1-alpha.fd40e6d linux-x64 node-v24.14.1
20
+ @contrail/cli/3.5.2-alpha.39ff2c1 linux-x64 node-v24.14.1
21
21
  $ contrail --help [COMMAND]
22
22
  USAGE
23
23
  $ contrail COMMAND
@@ -86,7 +86,6 @@ To get instructions on how to set up autocomplete for your shell, run `contrail
86
86
  * [`contrail types uploadTypePolicies`](#contrail-types-uploadtypepolicies)
87
87
  * [`contrail types uploadTypePropertyPolicies`](#contrail-types-uploadtypepropertypolicies)
88
88
  * [`contrail types uploadTypes`](#contrail-types-uploadtypes)
89
- * [`contrail types uploadUsageInfo`](#contrail-types-uploadusageinfo)
90
89
  * [`contrail users export`](#contrail-users-export)
91
90
  * [`contrail users import USERSFILE`](#contrail-users-import-usersfile)
92
91
  * [`contrail webhooks create`](#contrail-webhooks-create)
@@ -1403,29 +1402,6 @@ EXAMPLES
1403
1402
  $ contrail types uploadTypes
1404
1403
  ```
1405
1404
 
1406
- ## `contrail types uploadUsageInfo`
1407
-
1408
- [DEPRECATED] Upload extracted usage info. Use uploadTypeOverrides instead.
1409
-
1410
- ```
1411
- USAGE
1412
- $ contrail types uploadUsageInfo [-l error|warn|info|debug] [-e true|false] [-d <value>]
1413
-
1414
- FLAGS
1415
- -d, --dir=<value> [default: .] The directory from which to export the usage info data. Defaults to the
1416
- current directory. The usage info data will be loaded from $dir/usage-info.yml
1417
- -e, --alwaysConfirmEnv=<option> [default: true] The Environment variables
1418
- <options: true|false>
1419
- -l, --logLevel=<option> The Log Level
1420
- <options: error|warn|info|debug>
1421
-
1422
- DESCRIPTION
1423
- [DEPRECATED] Upload extracted usage info. Use uploadTypeOverrides instead.
1424
-
1425
- EXAMPLES
1426
- $ contrail types uploadUsageInfo
1427
- ```
1428
-
1429
1405
  ## `contrail users export`
1430
1406
 
1431
1407
  Export all users in the org.
@@ -370,31 +370,6 @@ 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'>;
398
373
  export declare enum PropertyType {
399
374
  Text = "text",
400
375
  String = "string",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.5.1-alpha.fd40e6d",
2
+ "version": "3.5.2-alpha.39ff2c1",
3
3
  "commands": {
4
4
  "app:create": {
5
5
  "id": "app:create",
@@ -2520,60 +2520,6 @@
2520
2520
  },
2521
2521
  "args": {}
2522
2522
  },
2523
- "types:uploadUsageInfo": {
2524
- "id": "types:uploadUsageInfo",
2525
- "description": "[DEPRECATED] Upload extracted usage info. Use uploadTypeOverrides instead.",
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
- "deprecationOptions": {
2535
- "message": "uploadUsageInfo is deprecated. Usage info is now managed as type overrides. Use `contrail types uploadTypeOverrides` instead."
2536
- },
2537
- "flags": {
2538
- "logLevel": {
2539
- "name": "logLevel",
2540
- "type": "option",
2541
- "char": "l",
2542
- "description": "The Log Level",
2543
- "required": false,
2544
- "multiple": false,
2545
- "options": [
2546
- "error",
2547
- "warn",
2548
- "info",
2549
- "debug"
2550
- ]
2551
- },
2552
- "alwaysConfirmEnv": {
2553
- "name": "alwaysConfirmEnv",
2554
- "type": "option",
2555
- "char": "e",
2556
- "description": "The Environment variables",
2557
- "required": false,
2558
- "multiple": false,
2559
- "options": [
2560
- "true",
2561
- "false"
2562
- ],
2563
- "default": "true"
2564
- },
2565
- "dir": {
2566
- "name": "dir",
2567
- "type": "option",
2568
- "char": "d",
2569
- "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",
2570
- "required": false,
2571
- "multiple": false,
2572
- "default": "."
2573
- }
2574
- },
2575
- "args": {}
2576
- },
2577
2523
  "users:export": {
2578
2524
  "id": "users:export",
2579
2525
  "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.1-alpha.fd40e6d",
3
+ "version": "3.5.2-alpha.39ff2c1",
4
4
  "description": "VibeIQ's Contrail Platform CLI.",
5
5
  "bin": {
6
6
  "contrail-cli": "./bin/run",
@@ -1,18 +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 deprecationOptions: {
6
- message: string;
7
- };
8
- static examples: string[];
9
- static flags: {
10
- dir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
- alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
- logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
- };
14
- run(): Promise<void>;
15
- }
16
- export declare function uploadUsageInfo(dir: string): Promise<void>;
17
- 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"];
18
- export declare function transformReducedUsageInfoToTypeIdsFromPath(reducedUsageInfo: any, types: any): PersistReducedUsageInfo | undefined;
@@ -1,183 +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 = '[DEPRECATED] Upload extracted usage info. Use uploadTypeOverrides instead.';
17
- static deprecationOptions = {
18
- message: 'uploadUsageInfo is deprecated. Usage info is now managed as type overrides. Use `contrail types uploadTypeOverrides` instead.',
19
- };
20
- static examples = [
21
- `$ contrail types uploadUsageInfo
22
- `,
23
- ];
24
- static flags = {
25
- ...basecommand_1.BaseCommand.baseFlags,
26
- dir: core_1.Flags.string({
27
- char: 'd',
28
- 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',
29
- required: false,
30
- default: '.',
31
- }),
32
- };
33
- async run() {
34
- await uploadUsageInfo(this.flags.dir);
35
- }
36
- }
37
- exports.default = UploadUsageInfo;
38
- async function uploadUsageInfo(dir) {
39
- try {
40
- await (0, login_1.authUser)();
41
- logger_1.default.info(`${chalk_1.default.yellow.bold('USAGE INFO')} Uploading`);
42
- const reducedUsageInfo = await loadUsageInfo(dir);
43
- await uploadUsageInfoObjects(reducedUsageInfo);
44
- logger_1.default.info(`${chalk_1.default.yellow.bold('USAGE INFO')} Uploaded`);
45
- }
46
- catch (e) {
47
- logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Usage Info Upload Failed . ${e}`);
48
- return;
49
- }
50
- logger_1.default.info(`${chalk_1.default.green.bold('COMPLETE')} Usage Info Upload Complete.`);
51
- }
52
- exports.uploadUsageInfo = uploadUsageInfo;
53
- function loadUsageInfo(dir) {
54
- try {
55
- const doc = js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, 'usage-info.yml'), 'utf8'));
56
- return doc;
57
- }
58
- catch (e) {
59
- throw new Error(`ERROR PARSING YAML: ${e}`);
60
- }
61
- }
62
- async function uploadUsageInfoObjects(loadedUsageInfo) {
63
- const typesWithProperties = await (0, type_extractor_1.getTypes)();
64
- const currentUsageInfo = await new sdk_1.Entities().get({
65
- entityName: 'type-property-usage-info',
66
- });
67
- const currentUsageInfosHashes = {};
68
- for (const currentUI of currentUsageInfo) {
69
- const foundType = typesWithProperties.find((t) => t.id === currentUI.typeId);
70
- const typeProperties = foundType?.typeProperties || [];
71
- const foundTypeProperty = typeProperties.find((tp) => tp.id === currentUI.typePropertyId);
72
- if (!foundType || !foundTypeProperty) {
73
- logger_1.default.info(`skipping unhashable, invalid usage info: ${JSON.stringify(currentUI, null, 2)}`);
74
- continue;
75
- }
76
- const hash = `${foundType.typePath}|${foundTypeProperty.slug}`;
77
- currentUsageInfosHashes[hash] = currentUI;
78
- }
79
- const reducedUsageInfoHashes = {};
80
- for (const loadedUI of loadedUsageInfo) {
81
- const hash = `${loadedUI.typePath}|${loadedUI.typePropertySlug}`;
82
- reducedUsageInfoHashes[hash] = loadedUI;
83
- }
84
- logger_1.default.debug(`current usage info: ${JSON.stringify(currentUsageInfo)}`);
85
- logger_1.default.debug(`loaded usage info: ${JSON.stringify(loadedUsageInfo)}`);
86
- for (const loadedUI of loadedUsageInfo) {
87
- try {
88
- const found = currentUsageInfosHashes[`${loadedUI.typePath}|${loadedUI.typePropertySlug}`];
89
- const transformedUI = transformReducedUsageInfoToTypeIdsFromPath(loadedUI, typesWithProperties);
90
- if (!transformedUI) {
91
- continue;
92
- }
93
- if (!found) {
94
- logger_1.default.debug(`Creating: ${JSON.stringify(transformedUI)}`);
95
- await new sdk_1.Entities().create({
96
- entityName: 'type-property-usage-info',
97
- object: transformedUI,
98
- });
99
- }
100
- else {
101
- logger_1.default.info(`Updating: ${JSON.stringify(transformedUI)}`);
102
- await new sdk_1.Entities().update({
103
- entityName: 'type-property-usage-info',
104
- id: found.id,
105
- object: transformedUI,
106
- });
107
- }
108
- }
109
- catch (err) {
110
- logger_1.default.error(`Error Uploading usage info: ${err}`);
111
- }
112
- }
113
- for (const [hash, currentUI] of Object.entries(currentUsageInfosHashes)) {
114
- try {
115
- const found = reducedUsageInfoHashes[hash];
116
- if (!found) {
117
- logger_1.default.debug(`Creating: ${hash}`);
118
- await new sdk_1.Entities().delete({
119
- entityName: 'type-property-usage-info',
120
- id: currentUI['id'],
121
- });
122
- }
123
- }
124
- catch (err) {
125
- logger_1.default.error(`Error Deleting usage info: ${err}`);
126
- }
127
- }
128
- }
129
- //This should contain the property keys in PersistReducedUsageInfo in interfaces.ts
130
- //except for typePath and typePropertySlug which are used for transformation but not persisted to the database.
131
- // If you add a new property to PersistReducedUsageInfo, you need to add it to this array to be persisted to the database.
132
- exports.persistReducedUsageInfoFields = [
133
- // 'typePath',
134
- // 'typePropertySlug',
135
- 'typeId',
136
- 'typePropertyId',
137
- 'editable',
138
- 'used',
139
- 'formulaFunction',
140
- 'validationFunction',
141
- 'numberFormat',
142
- 'defaultValue',
143
- 'label',
144
- 'required',
145
- 'searchable',
146
- 'isUniqueProperty',
147
- 'isUniquePropertyInFamily',
148
- 'copyBehavior',
149
- 'copyDefault',
150
- 'propertyLevel',
151
- 'isArchived',
152
- 'isFederationProperty',
153
- 'carryOverBehavior',
154
- 'carryOverDefault',
155
- ];
156
- // transforms the reduced Usage Info from name slugs to ids
157
- function transformReducedUsageInfoToTypeIdsFromPath(reducedUsageInfo, types) {
158
- const foundType = types.find((t) => t.typePath === reducedUsageInfo.typePath);
159
- if (!foundType) {
160
- logger_1.default.error(`Could not find type with typePath ${reducedUsageInfo.typePath} while transforming ${reducedUsageInfo.typePropertySlug}`);
161
- return undefined;
162
- }
163
- const foundTypeProperty = foundType.typeProperties?.find((tp) => tp.slug === reducedUsageInfo.typePropertySlug);
164
- if (!foundTypeProperty) {
165
- logger_1.default.error(`Could not find type property with slug ${reducedUsageInfo.typePropertySlug} while transforming ${JSON.stringify(reducedUsageInfo)}`);
166
- return undefined;
167
- }
168
- // Create a new object with only the properties that are in the persistReducedUsageInfoFields array
169
- // If there is a compile error on the code below, it means you added a new property to PersistReducedUsageInfo
170
- // interface in interfaces.ts but forgot to add it to the persistReducedUsageInfoFields array above,
171
- // It needs to be added to be persisted to the database.
172
- const persistedUsageInfo = {
173
- typeId: foundType.id,
174
- typePropertyId: foundTypeProperty.id,
175
- };
176
- for (const key of Object.keys(reducedUsageInfo)) {
177
- if (exports.persistReducedUsageInfoFields.includes(key)) {
178
- persistedUsageInfo[key] = reducedUsageInfo[key];
179
- }
180
- }
181
- return persistedUsageInfo;
182
- }
183
- exports.transformReducedUsageInfoToTypeIdsFromPath = transformReducedUsageInfoToTypeIdsFromPath;
@@ -1 +0,0 @@
1
- export {};
@@ -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
- });