@contrail/cli 3.6.0-alpha-8-alpha.694fd70 → 3.6.0-alpha.693d785

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 (163) hide show
  1. package/README.md +45 -151
  2. package/dist/api/feature-flags.d.ts +3 -0
  3. package/dist/api/feature-flags.js +29 -0
  4. package/dist/api/types.d.ts +0 -35
  5. package/dist/api/types.js +1 -49
  6. package/dist/api/users.d.ts +1 -0
  7. package/dist/api/users.js +10 -1
  8. package/dist/auth/login.d.ts +4 -0
  9. package/dist/auth/login.js +167 -93
  10. package/dist/auth/login.spec.js +305 -0
  11. package/dist/auth/sso.d.ts +36 -0
  12. package/dist/auth/sso.js +168 -0
  13. package/dist/auth/sso.spec.js +138 -0
  14. package/dist/basecommand.d.ts +1 -3
  15. package/dist/basecommand.js +2 -2
  16. package/dist/commands/app/getApiKey.js +2 -2
  17. package/dist/commands/config/set.js +1 -1
  18. package/dist/commands/feature-flags/export.d.ts +19 -0
  19. package/dist/commands/feature-flags/export.js +66 -0
  20. package/dist/commands/feature-flags/export.spec.js +109 -0
  21. package/dist/commands/feature-flags/import.d.ts +42 -0
  22. package/dist/commands/feature-flags/import.js +191 -0
  23. package/dist/commands/feature-flags/import.spec.js +194 -0
  24. package/dist/commands/instance/export.d.ts +9 -0
  25. package/dist/commands/instance/export.js +18 -3
  26. package/dist/commands/instance/export.spec.js +32 -0
  27. package/dist/commands/instance/import.d.ts +3 -0
  28. package/dist/commands/instance/import.js +5 -0
  29. package/dist/commands/instance/import.spec.js +4 -0
  30. package/dist/commands/login.d.ts +12 -0
  31. package/dist/commands/login.js +25 -0
  32. package/dist/common.d.ts +1 -3
  33. package/dist/common.js +1 -13
  34. package/dist/helpers/config/config.d.ts +5 -4
  35. package/dist/helpers/config/config.js +10 -12
  36. package/dist/helpers/file-helpers.d.ts +0 -1
  37. package/dist/helpers/file-helpers.js +1 -18
  38. package/dist/logger.js +1 -4
  39. package/node_modules/@contrail/entity-compare/package.json +3 -6
  40. package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
  41. package/node_modules/@contrail/loader/lib/constants.d.ts +8 -0
  42. package/node_modules/@contrail/loader/lib/constants.js +9 -1
  43. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +4 -0
  44. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +57 -0
  45. package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +492 -34
  46. package/node_modules/@contrail/loader/lib/pipeline/validate.js +2 -52
  47. package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +0 -85
  48. package/node_modules/@contrail/loader/package.json +2 -2
  49. package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +4 -1
  50. package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
  51. package/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -3
  52. package/node_modules/@contrail/sdk/lib/config/config.js +7 -13
  53. package/node_modules/@contrail/sdk/lib/core/request.js +2 -6
  54. package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -2
  55. package/node_modules/@contrail/sdk/lib/entities/entities.client.js +1 -3
  56. package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -1
  57. package/node_modules/@contrail/sdk/package.json +1 -1
  58. package/oclif.manifest.json +75 -365
  59. package/package.json +15 -5
  60. package/dist/commands/entities/create.d.ts +0 -48
  61. package/dist/commands/entities/create.js +0 -639
  62. package/dist/commands/entities/create.spec.js +0 -541
  63. package/dist/commands/entities/delete.d.ts +0 -19
  64. package/dist/commands/entities/delete.js +0 -134
  65. package/dist/commands/entities/get.d.ts +0 -24
  66. package/dist/commands/entities/get.js +0 -273
  67. package/dist/commands/entities/grammar.spec.js +0 -80
  68. package/dist/commands/entities/output.spec.js +0 -72
  69. package/dist/commands/entities/update.d.ts +0 -31
  70. package/dist/commands/entities/update.js +0 -157
  71. package/dist/helpers/entities/assortment-items.d.ts +0 -10
  72. package/dist/helpers/entities/assortment-items.js +0 -84
  73. package/dist/helpers/entities/batchFetch.d.ts +0 -8
  74. package/dist/helpers/entities/batchFetch.js +0 -49
  75. package/dist/helpers/entities/index.d.ts +0 -3
  76. package/dist/helpers/entities/index.js +0 -6
  77. package/dist/helpers/entities/items.d.ts +0 -10
  78. package/dist/helpers/entities/items.js +0 -102
  79. package/dist/helpers/entities/project-items.d.ts +0 -3
  80. package/dist/helpers/entities/project-items.js +0 -65
  81. package/dist/helpers/propertySpecifications/dateRanges.d.ts +0 -38
  82. package/dist/helpers/propertySpecifications/dateRanges.js +0 -89
  83. package/dist/helpers/propertySpecifications/dateRanges.spec.js +0 -95
  84. package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +0 -40
  85. package/dist/helpers/propertySpecifications/propertySpecifications.js +0 -109
  86. package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +0 -1
  87. package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +0 -373
  88. package/dist/logger.spec.d.ts +0 -1
  89. package/dist/logger.spec.js +0 -12
  90. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/pull_request_template.md +0 -31
  91. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/check-code-formatting.yml +0 -34
  92. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/empty.yml +0 -10
  93. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/generate-sdk-docs.yml +0 -32
  94. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +0 -117
  95. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.github/workflows/sdk-lib.yml +0 -27
  96. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/.prettierrc.yaml +0 -2
  97. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/README.md +0 -72
  98. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/home-hero.svg +0 -11
  99. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.d.ts +0 -9
  100. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/assets.js +0 -54
  101. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.d.ts +0 -1
  102. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/assets/index.js +0 -17
  103. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.d.ts +0 -10
  104. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/auth.js +0 -6
  105. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.d.ts +0 -2
  106. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/index.js +0 -18
  107. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.d.ts +0 -10
  108. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/auth/login.js +0 -209
  109. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.d.ts +0 -48
  110. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/config.js +0 -42
  111. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.d.ts +0 -1
  112. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/config/index.js +0 -17
  113. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.d.ts +0 -12
  114. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/content.js +0 -70
  115. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.d.ts +0 -1
  116. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/content/index.js +0 -17
  117. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.d.ts +0 -1
  118. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/index.js +0 -17
  119. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.d.ts +0 -15
  120. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/core/request.js +0 -241
  121. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +0 -101
  122. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entities.client.js +0 -306
  123. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.d.ts +0 -9
  124. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference-expander.js +0 -86
  125. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.d.ts +0 -6
  126. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity-reference.js +0 -19
  127. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.d.ts +0 -5
  128. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +0 -59
  129. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.d.ts +0 -3
  130. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/entities/index.js +0 -19
  131. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.d.ts +0 -3
  132. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/file-type-helper.js +0 -24
  133. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.d.ts +0 -19
  134. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/files.js +0 -151
  135. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.d.ts +0 -1
  136. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/files/index.js +0 -17
  137. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.d.ts +0 -10
  138. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/index.js +0 -26
  139. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.d.ts +0 -1
  140. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/index.js +0 -17
  141. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.d.ts +0 -16
  142. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/notifications/notifications-dispatcher.js +0 -37
  143. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.d.ts +0 -1
  144. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/index.js +0 -17
  145. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.d.ts +0 -12
  146. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies-cache.js +0 -55
  147. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.d.ts +0 -9
  148. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/policies/policies.client.js +0 -74
  149. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.d.ts +0 -2
  150. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/index.js +0 -18
  151. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.d.ts +0 -18
  152. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/sub-types-helper.js +0 -98
  153. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.d.ts +0 -19
  154. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types-cache.js +0 -73
  155. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.d.ts +0 -42
  156. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/lib/types/types.client.js +0 -217
  157. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/package.json +0 -64
  158. package/node_modules/@contrail/org-config-migration/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
  159. package/node_modules/@contrail/sdk/scripts/replicate-bug.js +0 -69
  160. /package/dist/{commands/entities/create.spec.d.ts → auth/sso.spec.d.ts} +0 -0
  161. /package/dist/commands/{entities/grammar.spec.d.ts → feature-flags/export.spec.d.ts} +0 -0
  162. /package/dist/commands/{entities/output.spec.d.ts → feature-flags/import.spec.d.ts} +0 -0
  163. /package/dist/{helpers/propertySpecifications/dateRanges.spec.d.ts → commands/instance/export.spec.d.ts} +0 -0
@@ -1,541 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const types_1 = require("@contrail/types");
4
- const create_1 = require("./create");
5
- const propertySpecifications_1 = require("../../helpers/propertySpecifications/propertySpecifications");
6
- describe('doesPropertyLevelMatchRole', () => {
7
- it('should return true for exact matches', () => {
8
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OPTION, 'option')).toBe(true);
9
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.FAMILY, 'family')).toBe(true);
10
- });
11
- it('should return false when propertyLevel does not match role', () => {
12
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OPTION, 'family')).toBe(false);
13
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.FAMILY, 'option')).toBe(false);
14
- });
15
- it('should return true for ALL property level with any role', () => {
16
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.ALL, 'option')).toBe(true);
17
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.ALL, 'family')).toBe(true);
18
- });
19
- it('should return true for OVERRIDABLE property level with any role', () => {
20
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OVERRIDABLE, 'option')).toBe(true);
21
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OVERRIDABLE, 'family')).toBe(true);
22
- });
23
- });
24
- describe('Entity Creation E2E Happy Path', () => {
25
- describe('pickRandomValueForProperty', () => {
26
- const mockObjectReferencesCache = new Map();
27
- const mockTypeReferencesCache = new Map();
28
- it('should generate random string values for String property type', () => {
29
- const property = {
30
- slug: 'name',
31
- propertyType: types_1.PropertyType.String,
32
- propertyLevel: types_1.PropertyLevel.ALL,
33
- };
34
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
35
- expect(typeof result).toBe('string');
36
- expect(result.length).toBeGreaterThan(0);
37
- });
38
- it('should generate random boolean values for Boolean property type', () => {
39
- const property = {
40
- slug: 'isActive',
41
- propertyType: types_1.PropertyType.Boolean,
42
- propertyLevel: types_1.PropertyLevel.ALL,
43
- };
44
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
45
- expect(typeof result).toBe('boolean');
46
- });
47
- it('should generate random number values for Number property type', () => {
48
- const property = {
49
- slug: 'quantity',
50
- propertyType: types_1.PropertyType.Number,
51
- propertyLevel: types_1.PropertyLevel.ALL,
52
- };
53
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
54
- expect(typeof result).toBe('number');
55
- });
56
- it('should generate random date string for Date property type', () => {
57
- const property = {
58
- slug: 'createdAt',
59
- propertyType: types_1.PropertyType.Date,
60
- propertyLevel: types_1.PropertyLevel.ALL,
61
- };
62
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
63
- expect(typeof result).toBe('string');
64
- expect(new Date(result).toString()).not.toBe('Invalid Date');
65
- });
66
- it('should pick random option for SingleSelect property type', () => {
67
- const options = [
68
- { value: 'red', display: 'Red' },
69
- { value: 'blue', display: 'Blue' },
70
- { value: 'green', display: 'Green' },
71
- ];
72
- const property = {
73
- slug: 'color',
74
- propertyType: types_1.PropertyType.SingleSelect,
75
- propertyLevel: types_1.PropertyLevel.ALL,
76
- options,
77
- };
78
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
79
- expect(options.some((option) => option.value === result)).toBe(true);
80
- });
81
- it('should pick random options for MultiSelect property type', () => {
82
- const options = [
83
- { value: 'feature1', display: 'Feature 1' },
84
- { value: 'feature2', display: 'Feature 2' },
85
- { value: 'feature3', display: 'Feature 3' },
86
- ];
87
- const property = {
88
- slug: 'features',
89
- propertyType: types_1.PropertyType.MultiSelect,
90
- propertyLevel: types_1.PropertyLevel.ALL,
91
- options,
92
- };
93
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
94
- expect(Array.isArray(result)).toBe(true);
95
- expect(result.length).toBeGreaterThan(0);
96
- result.forEach((value) => {
97
- expect(options.some((option) => option.value === value)).toBe(true);
98
- });
99
- });
100
- it('should return object reference ID for ObjectReference property type', () => {
101
- const mockEntity = { id: 'test-id-123', name: 'Test Entity' };
102
- const objectCache = new Map([['test-id-123', mockEntity]]);
103
- mockObjectReferencesCache.set('custom-entity:test', objectCache);
104
- const property = {
105
- slug: 'parentId',
106
- propertyType: types_1.PropertyType.ObjectReference,
107
- propertyLevel: types_1.PropertyLevel.ALL,
108
- referencedTypePath: 'custom-entity:test',
109
- };
110
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
111
- expect(result).toBe('test-id-123');
112
- });
113
- it('should return type reference ID for TypeReference property type', () => {
114
- const mockType = { id: 'type-id-456', typePath: 'custom-entity:category' };
115
- mockTypeReferencesCache.set('custom-entity:category', mockType);
116
- const property = {
117
- slug: 'categoryType',
118
- propertyType: types_1.PropertyType.TypeReference,
119
- propertyLevel: types_1.PropertyLevel.ALL,
120
- referencedTypePath: 'custom-entity:category',
121
- };
122
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
123
- expect(result).toBe('type-id-456');
124
- });
125
- });
126
- describe('buildObjectReferenceCache', () => {
127
- it('should build a cache from entities with IDs', () => {
128
- const entities = [
129
- { id: 'entity-1', name: 'First Entity', type: 'test' },
130
- { id: 'entity-2', name: 'Second Entity', type: 'test' },
131
- { id: 'entity-3', name: 'Third Entity', type: 'test' },
132
- ];
133
- const cache = (0, create_1.buildObjectReferenceCache)(entities);
134
- expect(cache.size).toBe(3);
135
- expect(cache.get('entity-1')).toEqual(entities[0]);
136
- expect(cache.get('entity-2')).toEqual(entities[1]);
137
- expect(cache.get('entity-3')).toEqual(entities[2]);
138
- });
139
- });
140
- describe('getReferencedObjectPaths', () => {
141
- it('should extract object reference paths from type properties', () => {
142
- const mockType = {
143
- id: 'test-type',
144
- typePath: 'item',
145
- typeProperties: [
146
- {
147
- slug: 'name',
148
- propertyType: types_1.PropertyType.String,
149
- propertyLevel: types_1.PropertyLevel.ALL,
150
- },
151
- {
152
- slug: 'categoryId',
153
- propertyType: types_1.PropertyType.ObjectReference,
154
- propertyLevel: types_1.PropertyLevel.ALL,
155
- referencedTypePath: 'custom-entity:category',
156
- },
157
- {
158
- slug: 'supplierId',
159
- propertyType: types_1.PropertyType.ObjectReference,
160
- propertyLevel: types_1.PropertyLevel.ALL,
161
- referencedTypePath: 'custom-entity:supplier',
162
- },
163
- {
164
- slug: 'description',
165
- propertyType: types_1.PropertyType.Text,
166
- propertyLevel: types_1.PropertyLevel.ALL,
167
- },
168
- ],
169
- };
170
- const referencedPaths = (0, create_1.getReferencedObjectPaths)(mockType);
171
- expect(referencedPaths).toEqual(['custom-entity:category', 'custom-entity:supplier']);
172
- });
173
- it('should return empty array when no object references exist', () => {
174
- const mockType = {
175
- id: 'test-type',
176
- typePath: 'item',
177
- typeProperties: [
178
- {
179
- slug: 'name',
180
- propertyType: types_1.PropertyType.String,
181
- propertyLevel: types_1.PropertyLevel.ALL,
182
- },
183
- {
184
- slug: 'isActive',
185
- propertyType: types_1.PropertyType.Boolean,
186
- propertyLevel: types_1.PropertyLevel.ALL,
187
- },
188
- ],
189
- };
190
- expect((0, create_1.getReferencedObjectPaths)(mockType)).toEqual([]);
191
- });
192
- });
193
- describe('Integration: Complete entity creation flow', () => {
194
- it('should create a complete entity with all property types populated', () => {
195
- // Mock a comprehensive type with various property types
196
- const mockType = {
197
- id: 'comprehensive-type',
198
- typePath: 'item',
199
- typeProperties: [
200
- {
201
- slug: 'name',
202
- propertyType: types_1.PropertyType.String,
203
- propertyLevel: types_1.PropertyLevel.ALL,
204
- },
205
- {
206
- slug: 'isActive',
207
- propertyType: types_1.PropertyType.Boolean,
208
- propertyLevel: types_1.PropertyLevel.ALL,
209
- },
210
- {
211
- slug: 'quantity',
212
- propertyType: types_1.PropertyType.Number,
213
- propertyLevel: types_1.PropertyLevel.ALL,
214
- },
215
- {
216
- slug: 'color',
217
- propertyType: types_1.PropertyType.SingleSelect,
218
- propertyLevel: types_1.PropertyLevel.ALL,
219
- options: [
220
- { value: 'red', display: 'Red' },
221
- { value: 'blue', display: 'Blue' },
222
- { value: 'green', display: 'Green' },
223
- ],
224
- },
225
- {
226
- slug: 'features',
227
- propertyType: types_1.PropertyType.MultiSelect,
228
- propertyLevel: types_1.PropertyLevel.ALL,
229
- options: [
230
- { value: 'waterproof', display: 'Waterproof' },
231
- { value: 'durable', display: 'Durable' },
232
- { value: 'lightweight', display: 'Lightweight' },
233
- ],
234
- },
235
- ],
236
- };
237
- // Create mock caches
238
- const objectReferencesCache = new Map();
239
- const typeReferencesCache = new Map();
240
- // Generate random values for each property
241
- const generatedEntity = {};
242
- for (const property of mockType.typeProperties) {
243
- const value = (0, create_1.pickRandomValueForProperty)(property, objectReferencesCache, typeReferencesCache);
244
- generatedEntity[property.slug] = value;
245
- }
246
- // Verify all properties are populated with correct types
247
- expect(typeof generatedEntity.name).toBe('string');
248
- expect(generatedEntity.name.length).toBeGreaterThan(0);
249
- expect(typeof generatedEntity.isActive).toBe('boolean');
250
- expect(typeof generatedEntity.quantity).toBe('number');
251
- expect(generatedEntity.quantity).toBeGreaterThanOrEqual(0);
252
- expect(['red', 'blue', 'green']).toContain(generatedEntity.color);
253
- expect(Array.isArray(generatedEntity.features)).toBe(true);
254
- expect(generatedEntity.features.length).toBeGreaterThan(0);
255
- generatedEntity.features.forEach((feature) => {
256
- expect(['waterproof', 'durable', 'lightweight']).toContain(feature);
257
- });
258
- });
259
- });
260
- describe('Property Specifications Integration', () => {
261
- describe('parsePropertySpecificationsIntoMap', () => {
262
- it('should parse simple property specifications', () => {
263
- const specs = [
264
- 'name=Test Item',
265
- 'quantity=10',
266
- 'isActive=true',
267
- ];
268
- const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
269
- expect(result.get('name')).toBe('Test Item');
270
- expect(result.get('quantity')).toBe('10');
271
- expect(result.get('isActive')).toBe('true');
272
- });
273
- it('should build roles arrays from repeated keys', () => {
274
- const specs = ['roles=option', 'roles=family', 'name=Test'];
275
- const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
276
- expect(result.get('roles')).toEqual(['option', 'family']);
277
- expect(result.get('name')).toBe('Test');
278
- });
279
- it('should handle complex values with spaces and special characters', () => {
280
- const specs = [
281
- 'description=This is a long description with spaces',
282
- 'hex=#FF0000',
283
- ];
284
- const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(specs);
285
- expect(result.get('description')).toBe('This is a long description with spaces');
286
- expect(result.get('hex')).toBe('#FF0000');
287
- });
288
- it('should throw error for invalid specifications', () => {
289
- expect(() => (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(['invalid-spec'])).toThrow('Invalid property specification: invalid-spec');
290
- expect(() => (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(['=value'])).toThrow('Invalid property specification: =value');
291
- const result = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)(['key=']);
292
- expect(result.get('key')).toBeUndefined();
293
- expect(result.size).toBe(1);
294
- });
295
- });
296
- describe('isValidPropertySpecification', () => {
297
- it('should validate correct property specifications', () => {
298
- expect((0, propertySpecifications_1.isValidPropertySpecification)('name=value')).toBe(true);
299
- expect((0, propertySpecifications_1.isValidPropertySpecification)('id=123')).toBe(true);
300
- expect((0, propertySpecifications_1.isValidPropertySpecification)('description=Long description with spaces')).toBe(true);
301
- expect((0, propertySpecifications_1.isValidPropertySpecification)('roles=option,family')).toBe(true);
302
- expect((0, propertySpecifications_1.isValidPropertySpecification)('key=')).toBe(true);
303
- });
304
- it('should reject most invalid property specifications', () => {
305
- expect((0, propertySpecifications_1.isValidPropertySpecification)('invalid')).toBe(false);
306
- expect((0, propertySpecifications_1.isValidPropertySpecification)('=')).toBe(false);
307
- expect((0, propertySpecifications_1.isValidPropertySpecification)('=value')).toBe(false);
308
- expect((0, propertySpecifications_1.isValidPropertySpecification)('')).toBe(false);
309
- });
310
- });
311
- describe('Property specifications with entity creation', () => {
312
- it('should apply property specifications to override random values', () => {
313
- const propertySpecs = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)([
314
- 'name=Custom Name',
315
- 'quantity=42',
316
- 'isActive=true',
317
- ]);
318
- // Simulate the property specification override logic
319
- const entity = {};
320
- // First generate random values (simulated)
321
- entity.name = 'random-name';
322
- entity.quantity = 99;
323
- entity.isActive = false;
324
- // Then apply property specifications
325
- for (const [slug, value] of propertySpecs.entries()) {
326
- entity[slug] = value;
327
- }
328
- expect(entity.name).toBe('Custom Name');
329
- expect(entity.quantity).toBe('42'); // Note: type casting would happen in real implementation
330
- expect(entity.isActive).toBe('true'); // Note: type casting would happen in real implementation
331
- });
332
- it('should handle roles property specification for filtering properties', () => {
333
- const propertySpecs = (0, propertySpecifications_1.parsePropertySpecificationsIntoMap)([
334
- 'roles=option',
335
- ]);
336
- const roles = [].concat(propertySpecs.get('roles'));
337
- // Test that property level matching works with specified roles
338
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OPTION, roles[0])).toBe(true);
339
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.FAMILY, roles[0])).toBe(false);
340
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.ALL, roles[0])).toBe(true);
341
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OVERRIDABLE, roles[0])).toBe(true);
342
- });
343
- });
344
- });
345
- describe('Error Handling and Edge Cases', () => {
346
- describe('pickRandomValueForProperty error scenarios', () => {
347
- const mockObjectReferencesCache = new Map();
348
- const mockTypeReferencesCache = new Map();
349
- it('should throw error for SingleSelect without options', () => {
350
- const property = {
351
- slug: 'color',
352
- propertyType: types_1.PropertyType.SingleSelect,
353
- propertyLevel: types_1.PropertyLevel.ALL,
354
- // Missing options property
355
- };
356
- expect(() => (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache)).toThrow('Option set is required for SingleSelect property');
357
- });
358
- it('should throw error for MultiSelect without options', () => {
359
- const property = {
360
- slug: 'features',
361
- propertyType: types_1.PropertyType.MultiSelect,
362
- propertyLevel: types_1.PropertyLevel.ALL,
363
- // Missing options property
364
- };
365
- expect(() => (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache)).toThrow('Option set is required for MultiSelect property');
366
- });
367
- it('should throw error for ObjectReference with missing cache', () => {
368
- const property = {
369
- slug: 'categoryId',
370
- propertyType: types_1.PropertyType.ObjectReference,
371
- propertyLevel: types_1.PropertyLevel.ALL,
372
- referencedTypePath: 'custom-entity:nonexistent',
373
- };
374
- expect(() => (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache)).toThrow('No object references found for referencedTypePath: custom-entity:nonexistent');
375
- });
376
- it('should throw error for ObjectReference with empty cache', () => {
377
- const emptyCache = new Map();
378
- emptyCache.set('custom-entity:empty', new Map());
379
- const property = {
380
- slug: 'categoryId',
381
- propertyType: types_1.PropertyType.ObjectReference,
382
- propertyLevel: types_1.PropertyLevel.ALL,
383
- referencedTypePath: 'custom-entity:empty',
384
- };
385
- expect(() => (0, create_1.pickRandomValueForProperty)(property, emptyCache, mockTypeReferencesCache)).toThrow('No object references found for referencedTypePath: custom-entity:empty');
386
- });
387
- it('should throw error for TypeReference with missing type', () => {
388
- const property = {
389
- slug: 'categoryType',
390
- propertyType: types_1.PropertyType.TypeReference,
391
- propertyLevel: types_1.PropertyLevel.ALL,
392
- referencedTypePath: 'custom-entity:nonexistent',
393
- };
394
- expect(() => (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache)).toThrow('Referenced type not found for path: custom-entity:nonexistent');
395
- });
396
- it('should throw error for unsupported property type', () => {
397
- const property = {
398
- slug: 'unsupported',
399
- propertyType: 'UnsupportedType',
400
- propertyLevel: types_1.PropertyLevel.ALL,
401
- };
402
- expect(() => (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache)).toThrow('Cannot handle property type: UnsupportedType');
403
- });
404
- it('should handle Formula property type gracefully', () => {
405
- const property = {
406
- slug: 'calculatedValue',
407
- propertyType: types_1.PropertyType.Formula,
408
- propertyLevel: types_1.PropertyLevel.ALL,
409
- };
410
- const result = (0, create_1.pickRandomValueForProperty)(property, mockObjectReferencesCache, mockTypeReferencesCache);
411
- expect(result).toBeUndefined();
412
- });
413
- });
414
- describe('Cache building edge cases', () => {
415
- it('should handle empty entities array', () => {
416
- const cache = (0, create_1.buildObjectReferenceCache)([]);
417
- expect(cache.size).toBe(0);
418
- });
419
- it('should handle entities without IDs gracefully', () => {
420
- const entitiesWithoutIds = [
421
- { name: 'Entity 1' },
422
- { id: 'entity-2', name: 'Entity 2' },
423
- undefined, // Undefined entity
424
- ].filter(Boolean); // Remove undefined
425
- const cache = (0, create_1.buildObjectReferenceCache)(entitiesWithoutIds);
426
- expect(cache.size).toBe(1); // Only the valid entity with ID
427
- expect(cache.get('entity-2')).toEqual({ id: 'entity-2', name: 'Entity 2' });
428
- });
429
- it('should handle duplicate entity IDs', () => {
430
- const entitiesWithDuplicates = [
431
- { id: 'duplicate-id', name: 'First Entity' },
432
- { id: 'duplicate-id', name: 'Second Entity' },
433
- { id: 'unique-id', name: 'Unique Entity' },
434
- ];
435
- const cache = (0, create_1.buildObjectReferenceCache)(entitiesWithDuplicates);
436
- expect(cache.size).toBe(2);
437
- // Should keep the first occurrence
438
- expect(cache.get('duplicate-id')).toEqual({ id: 'duplicate-id', name: 'First Entity' });
439
- expect(cache.get('unique-id')).toEqual({ id: 'unique-id', name: 'Unique Entity' });
440
- });
441
- });
442
- describe('Reference path extraction edge cases', () => {
443
- it('should handle type with no properties', () => {
444
- const typeWithNoProperties = {
445
- id: 'empty-type',
446
- typePath: 'item',
447
- typeProperties: [],
448
- };
449
- const referencedPaths = (0, create_1.getReferencedObjectPaths)(typeWithNoProperties);
450
- expect(referencedPaths).toEqual([]);
451
- });
452
- it('should handle type with undefined typeProperties', () => {
453
- const typeWithUndefinedProperties = {
454
- id: 'undefined-props-type',
455
- typePath: 'item',
456
- typeProperties: undefined,
457
- };
458
- const referencedPaths = (0, create_1.getReferencedObjectPaths)(typeWithUndefinedProperties);
459
- expect(referencedPaths).toEqual([]);
460
- });
461
- it('should filter out non-ObjectReference properties correctly', () => {
462
- const mixedType = {
463
- id: 'mixed-type',
464
- typePath: 'item',
465
- typeProperties: [
466
- {
467
- slug: 'name',
468
- propertyType: types_1.PropertyType.String,
469
- propertyLevel: types_1.PropertyLevel.ALL,
470
- },
471
- {
472
- slug: 'categoryId',
473
- propertyType: types_1.PropertyType.ObjectReference,
474
- propertyLevel: types_1.PropertyLevel.ALL,
475
- referencedTypePath: 'custom-entity:category',
476
- },
477
- {
478
- slug: 'isActive',
479
- propertyType: types_1.PropertyType.Boolean,
480
- propertyLevel: types_1.PropertyLevel.ALL,
481
- },
482
- {
483
- slug: 'supplierId',
484
- propertyType: types_1.PropertyType.ObjectReference,
485
- propertyLevel: types_1.PropertyLevel.ALL,
486
- referencedTypePath: 'custom-entity:supplier',
487
- },
488
- {
489
- slug: 'typeRef',
490
- propertyType: types_1.PropertyType.TypeReference,
491
- propertyLevel: types_1.PropertyLevel.ALL,
492
- referencedTypePath: 'custom-entity:type',
493
- },
494
- ],
495
- };
496
- const referencedPaths = (0, create_1.getReferencedObjectPaths)(mixedType);
497
- expect(referencedPaths).toEqual(['custom-entity:category', 'custom-entity:supplier']);
498
- expect(referencedPaths).not.toContain('custom-entity:type'); // TypeReference should not be included
499
- });
500
- });
501
- describe('Property level and role matching edge cases', () => {
502
- it('should handle valid roles correctly', () => {
503
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OPTION, 'option')).toBe(true);
504
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.FAMILY, 'family')).toBe(true);
505
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.ALL, 'option')).toBe(true);
506
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.ALL, 'family')).toBe(true);
507
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OVERRIDABLE, 'option')).toBe(true);
508
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OVERRIDABLE, 'family')).toBe(true);
509
- });
510
- it('should reject mismatched property levels and roles', () => {
511
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.OPTION, 'family')).toBe(false);
512
- expect((0, create_1.doesPropertyLevelMatchRole)(types_1.PropertyLevel.FAMILY, 'option')).toBe(false);
513
- });
514
- });
515
- });
516
- });
517
- describe('castValueToPropertyType array coercion', () => {
518
- it('should coerce a single value on a multi-value property to a one-element array', () => {
519
- expect((0, create_1.castValueToPropertyType)('option', types_1.PropertyType.MultiSelect)).toEqual(['option']);
520
- });
521
- it('should pass arrays through on multi-value properties', () => {
522
- expect((0, create_1.castValueToPropertyType)(['option', 'family'], types_1.PropertyType.MultiSelect)).toEqual([
523
- 'option',
524
- 'family',
525
- ]);
526
- });
527
- it('should keep a comma value literal on a multi-value property and warn with the repeated-key form', () => {
528
- const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
529
- expect((0, create_1.castValueToPropertyType)('option,family', types_1.PropertyType.MultiSelect)).toEqual([
530
- 'option,family',
531
- ]);
532
- expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('slug=option slug=family'));
533
- consoleError.mockRestore();
534
- });
535
- it('should keep commas literal on string properties without warning', () => {
536
- const consoleError = jest.spyOn(console, 'error').mockImplementation(() => undefined);
537
- expect((0, create_1.castValueToPropertyType)('my,name', types_1.PropertyType.String)).toBe('my,name');
538
- expect(consoleError).not.toHaveBeenCalled();
539
- consoleError.mockRestore();
540
- });
541
- });
@@ -1,19 +0,0 @@
1
- import { BaseCommand } from '../../basecommand';
2
- export default class DeleteEntity extends BaseCommand {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {
6
- dryRun: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
- inputFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- suffix: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- apiVersion: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
- alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
- logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
- };
13
- static args: {
14
- entityName: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
15
- ids: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
16
- };
17
- static strict: boolean;
18
- run(): Promise<void>;
19
- }