@uniformdev/transformer 1.1.10 → 1.1.11
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 +66 -48
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +65 -47
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1705,6 +1705,8 @@ var CompositionConverterService = class {
|
|
|
1705
1705
|
contentTypeMap.set(rootType, contentType);
|
|
1706
1706
|
}
|
|
1707
1707
|
const flattenContentTypeMap = /* @__PURE__ */ new Map();
|
|
1708
|
+
const missingFlattenTypes = [];
|
|
1709
|
+
const foundMissingFlattenTypes = /* @__PURE__ */ new Set();
|
|
1708
1710
|
for (const flattenType of flattenComponentIds) {
|
|
1709
1711
|
const isRootType = [...rootComponentTypes].some(
|
|
1710
1712
|
(rt) => this.compareTypes(rt, flattenType, strict)
|
|
@@ -1722,57 +1724,13 @@ var CompositionConverterService = class {
|
|
|
1722
1724
|
flattenContentTypeMap.set(flattenType, contentType);
|
|
1723
1725
|
} catch (error) {
|
|
1724
1726
|
if (error instanceof ComponentNotFoundError) {
|
|
1725
|
-
|
|
1727
|
+
this.logger.info(`Flatten component type not found: ${flattenType}`);
|
|
1728
|
+
missingFlattenTypes.push(flattenType);
|
|
1729
|
+
continue;
|
|
1726
1730
|
}
|
|
1727
1731
|
throw error;
|
|
1728
1732
|
}
|
|
1729
1733
|
}
|
|
1730
|
-
if (flattenComponentIds.length > 0) {
|
|
1731
|
-
for (const contentType of contentTypeMap.values()) {
|
|
1732
|
-
for (const flattenType of flattenComponentIds) {
|
|
1733
|
-
if (this.compareTypes(flattenType, contentType.id, strict)) {
|
|
1734
|
-
continue;
|
|
1735
|
-
}
|
|
1736
|
-
contentType.fields.push({
|
|
1737
|
-
id: flattenType,
|
|
1738
|
-
name: flattenType,
|
|
1739
|
-
type: "contentReference",
|
|
1740
|
-
typeConfig: {
|
|
1741
|
-
isMulti: true,
|
|
1742
|
-
allowedContentTypes: [flattenType]
|
|
1743
|
-
},
|
|
1744
|
-
localizable: false
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
for (const [typeName, contentType] of contentTypeMap) {
|
|
1750
|
-
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1751
|
-
const fieldCount = contentType.fields.filter((f) => f.type !== "contentReference").length;
|
|
1752
|
-
const refCount = contentType.fields.filter((f) => f.type === "contentReference").length;
|
|
1753
|
-
const refInfo = refCount > 0 ? ` + ${refCount} reference(s)` : "";
|
|
1754
|
-
this.logger.action(
|
|
1755
|
-
whatIf,
|
|
1756
|
-
"WRITE",
|
|
1757
|
-
`${contentTypesDir}/${typeName}.json (${fieldCount} fields${refInfo})`
|
|
1758
|
-
);
|
|
1759
|
-
if (!whatIf) {
|
|
1760
|
-
await this.fileSystem.writeFile(filePath, contentType);
|
|
1761
|
-
}
|
|
1762
|
-
contentTypesWritten++;
|
|
1763
|
-
}
|
|
1764
|
-
for (const [typeName, contentType] of flattenContentTypeMap) {
|
|
1765
|
-
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1766
|
-
this.logger.action(
|
|
1767
|
-
whatIf,
|
|
1768
|
-
"WRITE",
|
|
1769
|
-
`${contentTypesDir}/${typeName}.json (${contentType.fields.length} fields)`
|
|
1770
|
-
);
|
|
1771
|
-
if (!whatIf) {
|
|
1772
|
-
await this.fileSystem.writeFile(filePath, contentType);
|
|
1773
|
-
}
|
|
1774
|
-
contentTypesWritten++;
|
|
1775
|
-
}
|
|
1776
1734
|
for (const { composition } of compositionResults) {
|
|
1777
1735
|
const comp = composition.composition;
|
|
1778
1736
|
const compositionId = comp._id;
|
|
@@ -1797,6 +1755,9 @@ var CompositionConverterService = class {
|
|
|
1797
1755
|
);
|
|
1798
1756
|
if (instances.length > 0) {
|
|
1799
1757
|
flattenedByType.set(flattenType, instances);
|
|
1758
|
+
if (missingFlattenTypes.includes(flattenType)) {
|
|
1759
|
+
foundMissingFlattenTypes.add(flattenType);
|
|
1760
|
+
}
|
|
1800
1761
|
}
|
|
1801
1762
|
}
|
|
1802
1763
|
}
|
|
@@ -1835,6 +1796,63 @@ var CompositionConverterService = class {
|
|
|
1835
1796
|
}
|
|
1836
1797
|
}
|
|
1837
1798
|
}
|
|
1799
|
+
if (flattenComponentIds.length > 0) {
|
|
1800
|
+
for (const contentType of contentTypeMap.values()) {
|
|
1801
|
+
for (const flattenType of flattenComponentIds) {
|
|
1802
|
+
if (this.compareTypes(flattenType, contentType.id, strict)) {
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
if (missingFlattenTypes.includes(flattenType) && !foundMissingFlattenTypes.has(flattenType)) {
|
|
1806
|
+
continue;
|
|
1807
|
+
}
|
|
1808
|
+
contentType.fields.push({
|
|
1809
|
+
id: flattenType,
|
|
1810
|
+
name: flattenType,
|
|
1811
|
+
type: "contentReference",
|
|
1812
|
+
typeConfig: {
|
|
1813
|
+
isMulti: true,
|
|
1814
|
+
allowedContentTypes: [flattenType]
|
|
1815
|
+
},
|
|
1816
|
+
localizable: false
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
for (const [typeName, contentType] of contentTypeMap) {
|
|
1822
|
+
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1823
|
+
const fieldCount = contentType.fields.filter((f) => f.type !== "contentReference").length;
|
|
1824
|
+
const refCount = contentType.fields.filter((f) => f.type === "contentReference").length;
|
|
1825
|
+
const refInfo = refCount > 0 ? ` + ${refCount} reference(s)` : "";
|
|
1826
|
+
this.logger.action(
|
|
1827
|
+
whatIf,
|
|
1828
|
+
"WRITE",
|
|
1829
|
+
`${contentTypesDir}/${typeName}.json (${fieldCount} fields${refInfo})`
|
|
1830
|
+
);
|
|
1831
|
+
if (!whatIf) {
|
|
1832
|
+
await this.fileSystem.writeFile(filePath, contentType);
|
|
1833
|
+
}
|
|
1834
|
+
contentTypesWritten++;
|
|
1835
|
+
}
|
|
1836
|
+
for (const [typeName, contentType] of flattenContentTypeMap) {
|
|
1837
|
+
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1838
|
+
this.logger.action(
|
|
1839
|
+
whatIf,
|
|
1840
|
+
"WRITE",
|
|
1841
|
+
`${contentTypesDir}/${typeName}.json (${contentType.fields.length} fields)`
|
|
1842
|
+
);
|
|
1843
|
+
if (!whatIf) {
|
|
1844
|
+
await this.fileSystem.writeFile(filePath, contentType);
|
|
1845
|
+
}
|
|
1846
|
+
contentTypesWritten++;
|
|
1847
|
+
}
|
|
1848
|
+
const neverFoundMissingTypes = missingFlattenTypes.filter(
|
|
1849
|
+
(type) => !foundMissingFlattenTypes.has(type)
|
|
1850
|
+
);
|
|
1851
|
+
if (neverFoundMissingTypes.length > 0) {
|
|
1852
|
+
this.logger.warn(
|
|
1853
|
+
`Flatten component type(s) not found in any composition: ${neverFoundMissingTypes.join(", ")}`
|
|
1854
|
+
);
|
|
1855
|
+
}
|
|
1838
1856
|
return { contentTypesWritten, entriesFromCompositions, entriesFromFlattened };
|
|
1839
1857
|
}
|
|
1840
1858
|
// --- Content Type Generation ---
|