@uniformdev/transformer 1.0.0
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/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +2399 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +320 -0
- package/dist/index.js +1116 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
interface Parameter {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
typeConfig?: {
|
|
6
|
+
childrenParams?: string[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
interface SlotDefinition {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
allowedComponents?: string[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface ComponentDefinition {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
parameters?: Parameter[];
|
|
21
|
+
slots?: SlotDefinition[];
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ParameterValue {
|
|
26
|
+
type: string;
|
|
27
|
+
value?: unknown;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
interface ComponentInstance {
|
|
31
|
+
type: string;
|
|
32
|
+
_id?: string;
|
|
33
|
+
parameters?: Record<string, ParameterValue>;
|
|
34
|
+
slots?: Record<string, ComponentInstance[]>;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
interface CompositionOverrides {
|
|
38
|
+
parameters?: Record<string, ParameterValue>;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
interface CompositionRoot {
|
|
42
|
+
_id: string;
|
|
43
|
+
type: string;
|
|
44
|
+
parameters?: Record<string, ParameterValue>;
|
|
45
|
+
_overrides?: Record<string, CompositionOverrides>;
|
|
46
|
+
slots?: Record<string, ComponentInstance[]>;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface Composition {
|
|
50
|
+
composition: CompositionRoot;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface GlobalOptions {
|
|
55
|
+
rootDir: string;
|
|
56
|
+
whatIf?: boolean;
|
|
57
|
+
strict?: boolean;
|
|
58
|
+
compositionsDir: string;
|
|
59
|
+
componentsDir: string;
|
|
60
|
+
contentTypesDir: string;
|
|
61
|
+
assetsDir: string;
|
|
62
|
+
categoriesDir: string;
|
|
63
|
+
componentPatternsDir: string;
|
|
64
|
+
compositionPatternsDir: string;
|
|
65
|
+
dataTypesDir: string;
|
|
66
|
+
entriesDir: string;
|
|
67
|
+
filesDir: string;
|
|
68
|
+
previewUrlsDir: string;
|
|
69
|
+
previewViewportsDir: string;
|
|
70
|
+
projectMapDefinitionsDir: string;
|
|
71
|
+
projectMapNodesDir: string;
|
|
72
|
+
quirksDir: string;
|
|
73
|
+
}
|
|
74
|
+
interface PropagateRootComponentPropertyOptions extends GlobalOptions {
|
|
75
|
+
compositionType: string;
|
|
76
|
+
property: string;
|
|
77
|
+
targetComponentType: string;
|
|
78
|
+
targetGroup: string;
|
|
79
|
+
deleteSourceParameter?: boolean;
|
|
80
|
+
}
|
|
81
|
+
interface CompositionPatternCandidatesOptions extends GlobalOptions {
|
|
82
|
+
minGroupSize: number;
|
|
83
|
+
depth: number;
|
|
84
|
+
threshold: number;
|
|
85
|
+
format: 'text' | 'json';
|
|
86
|
+
brief?: boolean;
|
|
87
|
+
}
|
|
88
|
+
interface UnpackSerializationOptions extends GlobalOptions {
|
|
89
|
+
sourceDir?: string;
|
|
90
|
+
file?: string;
|
|
91
|
+
outputDir?: string;
|
|
92
|
+
format: 'yaml' | 'json';
|
|
93
|
+
}
|
|
94
|
+
interface PackSerializationOptions extends GlobalOptions {
|
|
95
|
+
sourceDir?: string;
|
|
96
|
+
file?: string;
|
|
97
|
+
outputDir?: string;
|
|
98
|
+
keepFragments?: boolean;
|
|
99
|
+
format: 'yaml' | 'json';
|
|
100
|
+
}
|
|
101
|
+
interface RenameComponentOptions extends GlobalOptions {
|
|
102
|
+
componentType: string;
|
|
103
|
+
newComponentType: string;
|
|
104
|
+
newComponentName?: string;
|
|
105
|
+
}
|
|
106
|
+
interface RenameSlotOptions extends GlobalOptions {
|
|
107
|
+
componentType: string;
|
|
108
|
+
slotId: string;
|
|
109
|
+
newSlotId: string;
|
|
110
|
+
newSlotName?: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare class TransformError extends Error {
|
|
114
|
+
constructor(message: string);
|
|
115
|
+
}
|
|
116
|
+
declare class ComponentNotFoundError extends TransformError {
|
|
117
|
+
constructor(componentType: string, path?: string);
|
|
118
|
+
}
|
|
119
|
+
declare class PropertyNotFoundError extends TransformError {
|
|
120
|
+
constructor(propertyName: string, componentType: string);
|
|
121
|
+
}
|
|
122
|
+
declare class InvalidYamlError extends TransformError {
|
|
123
|
+
constructor(filePath: string, details?: string);
|
|
124
|
+
}
|
|
125
|
+
declare class FileNotFoundError extends TransformError {
|
|
126
|
+
constructor(filePath: string);
|
|
127
|
+
}
|
|
128
|
+
declare class DuplicateIdError extends TransformError {
|
|
129
|
+
constructor(id: string, arrayProperty: string, filePath: string);
|
|
130
|
+
}
|
|
131
|
+
declare class ComponentAlreadyExistsError extends TransformError {
|
|
132
|
+
constructor(componentType: string, path?: string);
|
|
133
|
+
}
|
|
134
|
+
declare class SlotNotFoundError extends TransformError {
|
|
135
|
+
constructor(slotId: string, componentType: string);
|
|
136
|
+
}
|
|
137
|
+
declare class SlotAlreadyExistsError extends TransformError {
|
|
138
|
+
constructor(slotId: string, componentType: string);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare class FileSystemService {
|
|
142
|
+
private isJsonFile;
|
|
143
|
+
readFile<T>(filePath: string): Promise<T>;
|
|
144
|
+
writeFile<T>(filePath: string, data: T): Promise<void>;
|
|
145
|
+
readYamlFile<T>(filePath: string): Promise<T>;
|
|
146
|
+
writeYamlFile<T>(filePath: string, data: T): Promise<void>;
|
|
147
|
+
findFiles(directory: string, pattern: string): Promise<string[]>;
|
|
148
|
+
fileExists(filePath: string): Promise<boolean>;
|
|
149
|
+
resolvePath(...segments: string[]): string;
|
|
150
|
+
joinPath(...segments: string[]): string;
|
|
151
|
+
getBasename(filePath: string, ext?: string): string;
|
|
152
|
+
renameFile(oldPath: string, newPath: string): Promise<void>;
|
|
153
|
+
deleteFile(filePath: string): void;
|
|
154
|
+
getExtension(filePath: string): string;
|
|
155
|
+
getDirname(filePath: string): string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface FindOptions$1 {
|
|
159
|
+
strict?: boolean;
|
|
160
|
+
}
|
|
161
|
+
declare class ComponentService {
|
|
162
|
+
private fileSystem;
|
|
163
|
+
constructor(fileSystem: FileSystemService);
|
|
164
|
+
private compareIds;
|
|
165
|
+
loadComponent(componentsDir: string, componentType: string, options?: FindOptions$1): Promise<{
|
|
166
|
+
component: ComponentDefinition;
|
|
167
|
+
filePath: string;
|
|
168
|
+
}>;
|
|
169
|
+
saveComponent(filePath: string, component: ComponentDefinition): Promise<void>;
|
|
170
|
+
findParameter(component: ComponentDefinition, parameterName: string, options?: FindOptions$1): Parameter | undefined;
|
|
171
|
+
isGroupParameter(parameter: Parameter): boolean;
|
|
172
|
+
resolveGroupParameters(component: ComponentDefinition, groupParameter: Parameter, options?: FindOptions$1): Parameter[];
|
|
173
|
+
resolveProperties(component: ComponentDefinition, propertyNames: string[], options?: FindOptions$1): {
|
|
174
|
+
parameters: Parameter[];
|
|
175
|
+
notFound: string[];
|
|
176
|
+
};
|
|
177
|
+
addParameterToComponent(component: ComponentDefinition, parameter: Parameter, options?: FindOptions$1): ComponentDefinition;
|
|
178
|
+
ensureGroupExists(component: ComponentDefinition, groupId: string, groupName?: string, options?: FindOptions$1): ComponentDefinition;
|
|
179
|
+
addParameterToGroup(component: ComponentDefinition, groupId: string, parameterId: string, options?: FindOptions$1): ComponentDefinition;
|
|
180
|
+
removeParameter(component: ComponentDefinition, parameterId: string, options?: FindOptions$1): ComponentDefinition;
|
|
181
|
+
removeEmptyGroups(component: ComponentDefinition): ComponentDefinition;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface FindOptions {
|
|
185
|
+
strict?: boolean;
|
|
186
|
+
}
|
|
187
|
+
interface FoundComponentInstance {
|
|
188
|
+
instance: ComponentInstance;
|
|
189
|
+
instanceId: string;
|
|
190
|
+
path: string[];
|
|
191
|
+
}
|
|
192
|
+
declare class CompositionService {
|
|
193
|
+
private fileSystem;
|
|
194
|
+
constructor(fileSystem: FileSystemService);
|
|
195
|
+
private compareTypes;
|
|
196
|
+
loadComposition(filePath: string): Promise<Composition>;
|
|
197
|
+
saveComposition(filePath: string, composition: Composition): Promise<void>;
|
|
198
|
+
findCompositionsByType(compositionsDir: string, compositionType: string, options?: FindOptions): Promise<{
|
|
199
|
+
composition: Composition;
|
|
200
|
+
filePath: string;
|
|
201
|
+
}[]>;
|
|
202
|
+
findComponentInstances(composition: Composition, componentType: string, options?: FindOptions): FoundComponentInstance[];
|
|
203
|
+
private searchSlots;
|
|
204
|
+
getRootOverrides(composition: Composition): Record<string, ParameterValue>;
|
|
205
|
+
getInstanceOverrides(composition: Composition, instanceId: string): Record<string, ParameterValue>;
|
|
206
|
+
setInstanceOverride(composition: Composition, instanceId: string, parameterId: string, value: ParameterValue): Composition;
|
|
207
|
+
setInstanceOverrides(composition: Composition, instanceId: string, parameters: Record<string, ParameterValue>): Composition;
|
|
208
|
+
/**
|
|
209
|
+
* Sets parameters directly on a component instance (preferred approach).
|
|
210
|
+
* This modifies the instance object in-place.
|
|
211
|
+
*/
|
|
212
|
+
setInstanceParameters(instance: ComponentInstance, parameters: Record<string, ParameterValue>): void;
|
|
213
|
+
/**
|
|
214
|
+
* Deletes parameters from root overrides.
|
|
215
|
+
* Returns true if any parameters were deleted.
|
|
216
|
+
*/
|
|
217
|
+
deleteRootOverrides(composition: Composition, parameterIds: string[], options?: FindOptions): boolean;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare class Logger {
|
|
221
|
+
info(message: string): void;
|
|
222
|
+
success(message: string): void;
|
|
223
|
+
error(message: string): void;
|
|
224
|
+
warn(message: string): void;
|
|
225
|
+
action(whatIf: boolean, actionType: string, message: string): void;
|
|
226
|
+
detail(message: string): void;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface PropagateOptions {
|
|
230
|
+
rootDir: string;
|
|
231
|
+
componentsDir: string;
|
|
232
|
+
compositionsDir: string;
|
|
233
|
+
compositionType: string;
|
|
234
|
+
property: string;
|
|
235
|
+
targetComponentType: string;
|
|
236
|
+
targetGroup: string;
|
|
237
|
+
whatIf: boolean;
|
|
238
|
+
strict: boolean;
|
|
239
|
+
deleteSourceParameter: boolean;
|
|
240
|
+
}
|
|
241
|
+
interface PropagateResult {
|
|
242
|
+
modifiedComponents: number;
|
|
243
|
+
modifiedCompositions: number;
|
|
244
|
+
propagatedInstances: number;
|
|
245
|
+
}
|
|
246
|
+
declare class PropertyPropagatorService {
|
|
247
|
+
private fileSystem;
|
|
248
|
+
private componentService;
|
|
249
|
+
private compositionService;
|
|
250
|
+
private logger;
|
|
251
|
+
constructor(fileSystem: FileSystemService, componentService: ComponentService, compositionService: CompositionService, logger: Logger);
|
|
252
|
+
propagate(options: PropagateOptions): Promise<PropagateResult>;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
interface RenameSlotInternalOptions {
|
|
256
|
+
rootDir: string;
|
|
257
|
+
componentsDir: string;
|
|
258
|
+
compositionsDir: string;
|
|
259
|
+
compositionPatternsDir: string;
|
|
260
|
+
componentPatternsDir: string;
|
|
261
|
+
componentType: string;
|
|
262
|
+
slotId: string;
|
|
263
|
+
newSlotId: string;
|
|
264
|
+
newSlotName?: string;
|
|
265
|
+
whatIf: boolean;
|
|
266
|
+
strict: boolean;
|
|
267
|
+
}
|
|
268
|
+
interface RenameSlotResult {
|
|
269
|
+
componentDefinitionUpdated: boolean;
|
|
270
|
+
compositionsModified: number;
|
|
271
|
+
compositionPatternsModified: number;
|
|
272
|
+
componentPatternsModified: number;
|
|
273
|
+
instancesRenamed: number;
|
|
274
|
+
}
|
|
275
|
+
declare class SlotRenamerService {
|
|
276
|
+
private fileSystem;
|
|
277
|
+
private componentService;
|
|
278
|
+
private logger;
|
|
279
|
+
constructor(fileSystem: FileSystemService, componentService: ComponentService, logger: Logger);
|
|
280
|
+
private compareIds;
|
|
281
|
+
rename(options: RenameSlotInternalOptions): Promise<RenameSlotResult>;
|
|
282
|
+
private renameSlotInDirectory;
|
|
283
|
+
private renameSlotInTree;
|
|
284
|
+
private renameSlotKey;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
interface RenameComponentInternalOptions {
|
|
288
|
+
rootDir: string;
|
|
289
|
+
componentsDir: string;
|
|
290
|
+
compositionsDir: string;
|
|
291
|
+
compositionPatternsDir: string;
|
|
292
|
+
componentPatternsDir: string;
|
|
293
|
+
componentType: string;
|
|
294
|
+
newComponentType: string;
|
|
295
|
+
newComponentName?: string;
|
|
296
|
+
whatIf: boolean;
|
|
297
|
+
strict: boolean;
|
|
298
|
+
}
|
|
299
|
+
interface RenameComponentResult {
|
|
300
|
+
componentRenamed: boolean;
|
|
301
|
+
fileRenamed: boolean;
|
|
302
|
+
allowedComponentsUpdated: number;
|
|
303
|
+
compositionsModified: number;
|
|
304
|
+
compositionPatternsModified: number;
|
|
305
|
+
componentPatternsModified: number;
|
|
306
|
+
instancesRenamed: number;
|
|
307
|
+
}
|
|
308
|
+
declare class ComponentRenamerService {
|
|
309
|
+
private fileSystem;
|
|
310
|
+
private componentService;
|
|
311
|
+
private logger;
|
|
312
|
+
constructor(fileSystem: FileSystemService, componentService: ComponentService, logger: Logger);
|
|
313
|
+
private compareIds;
|
|
314
|
+
rename(options: RenameComponentInternalOptions): Promise<RenameComponentResult>;
|
|
315
|
+
private updateAllowedComponents;
|
|
316
|
+
private renameTypeInDirectory;
|
|
317
|
+
private renameTypeInTree;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export { ComponentAlreadyExistsError, type ComponentDefinition, type ComponentInstance, ComponentNotFoundError, ComponentRenamerService, ComponentService, type Composition, type CompositionOverrides, type CompositionPatternCandidatesOptions, type CompositionRoot, CompositionService, DuplicateIdError, FileNotFoundError, FileSystemService, type GlobalOptions, InvalidYamlError, Logger, type PackSerializationOptions, type Parameter, type ParameterValue, type PropagateRootComponentPropertyOptions, PropertyNotFoundError, PropertyPropagatorService, type RenameComponentOptions, type RenameSlotOptions, SlotAlreadyExistsError, type SlotDefinition, SlotNotFoundError, SlotRenamerService, TransformError, type UnpackSerializationOptions };
|