@uniformdev/transformer 1.1.20 → 1.1.21
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.js +43 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +42 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -199,6 +199,14 @@ declare class ComponentService {
|
|
|
199
199
|
}>;
|
|
200
200
|
saveComponent(filePath: string, component: ComponentDefinition): Promise<void>;
|
|
201
201
|
private sortComponentArrays;
|
|
202
|
+
sortParametersByGroup<T extends {
|
|
203
|
+
id: string;
|
|
204
|
+
type: string;
|
|
205
|
+
typeConfig?: {
|
|
206
|
+
childrenParams?: string[];
|
|
207
|
+
[key: string]: unknown;
|
|
208
|
+
};
|
|
209
|
+
}>(parameters: T[]): T[];
|
|
202
210
|
findParameter(component: ComponentDefinition, parameterName: string, options?: FindOptions$1): Parameter | undefined;
|
|
203
211
|
isGroupParameter(parameter: Parameter): boolean;
|
|
204
212
|
resolveGroupParameters(component: ComponentDefinition, groupParameter: Parameter, options?: FindOptions$1): Parameter[];
|
package/dist/index.js
CHANGED
|
@@ -185,19 +185,51 @@ var ComponentService = class {
|
|
|
185
185
|
sortComponentArrays(component) {
|
|
186
186
|
const result = { ...component };
|
|
187
187
|
if (result.parameters) {
|
|
188
|
-
result.parameters =
|
|
188
|
+
result.parameters = this.sortParametersByGroup(result.parameters);
|
|
189
189
|
}
|
|
190
190
|
if (result.slots) {
|
|
191
|
-
result.slots = [...result.slots].sort((a, b) => a.id.localeCompare(b.id)).map((slot) => {
|
|
191
|
+
result.slots = [...result.slots].sort((a, b) => a.id.localeCompare(b.id, void 0, { sensitivity: "base" })).map((slot) => {
|
|
192
192
|
if (slot.allowedComponents) {
|
|
193
|
-
return { ...slot, allowedComponents: [...slot.allowedComponents].sort((a, b) => a.localeCompare(b)) };
|
|
193
|
+
return { ...slot, allowedComponents: [...slot.allowedComponents].sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" })) };
|
|
194
194
|
}
|
|
195
195
|
return slot;
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
const variants = result.variants;
|
|
199
199
|
if (Array.isArray(variants)) {
|
|
200
|
-
result.variants = [...variants].sort((a, b) => a.id.localeCompare(b.id));
|
|
200
|
+
result.variants = [...variants].sort((a, b) => a.id.localeCompare(b.id, void 0, { sensitivity: "base" }));
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
sortParametersByGroup(parameters) {
|
|
205
|
+
const compare = (a, b) => a.localeCompare(b, void 0, { sensitivity: "base" });
|
|
206
|
+
const groups = [];
|
|
207
|
+
const childToGroup = /* @__PURE__ */ new Set();
|
|
208
|
+
for (const param of parameters) {
|
|
209
|
+
if (param.type === "group") {
|
|
210
|
+
groups.push(param);
|
|
211
|
+
if (param.typeConfig?.childrenParams) {
|
|
212
|
+
param.typeConfig.childrenParams = [...param.typeConfig.childrenParams].sort(compare);
|
|
213
|
+
}
|
|
214
|
+
for (const childId of param.typeConfig?.childrenParams ?? []) {
|
|
215
|
+
childToGroup.add(childId.toLowerCase());
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const ungrouped = parameters.filter(
|
|
220
|
+
(p) => p.type !== "group" && !childToGroup.has(p.id.toLowerCase())
|
|
221
|
+
);
|
|
222
|
+
const sortedGroups = [...groups].sort((a, b) => compare(a.id, b.id));
|
|
223
|
+
const result = [];
|
|
224
|
+
result.push(...[...ungrouped].sort((a, b) => compare(a.id, b.id)));
|
|
225
|
+
for (const group of sortedGroups) {
|
|
226
|
+
result.push(group);
|
|
227
|
+
for (const childId of group.typeConfig?.childrenParams ?? []) {
|
|
228
|
+
const child = parameters.find((p) => p.id.toLowerCase() === childId.toLowerCase());
|
|
229
|
+
if (child) {
|
|
230
|
+
result.push(child);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
201
233
|
}
|
|
202
234
|
return result;
|
|
203
235
|
}
|
|
@@ -746,6 +778,12 @@ var CompositionConverterService = class {
|
|
|
746
778
|
}
|
|
747
779
|
}
|
|
748
780
|
}
|
|
781
|
+
for (const contentType of contentTypeMap.values()) {
|
|
782
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
783
|
+
}
|
|
784
|
+
for (const contentType of flattenContentTypeMap.values()) {
|
|
785
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
786
|
+
}
|
|
749
787
|
for (const [typeName, contentType] of contentTypeMap) {
|
|
750
788
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
751
789
|
const fieldCount = contentType.fields.filter((f) => f.type !== "contentReference").length;
|