@uniformdev/transformer 1.1.11 → 1.1.12
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 +46 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +45 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3696,6 +3696,9 @@ var CompositionConverterService = class {
|
|
|
3696
3696
|
value: instances.map((inst) => inst.determinisiticId)
|
|
3697
3697
|
};
|
|
3698
3698
|
}
|
|
3699
|
+
if (flattenComponentIds.length > 0) {
|
|
3700
|
+
this.transformContentReferences(entry);
|
|
3701
|
+
}
|
|
3699
3702
|
const entryFilePath = this.fileSystem.joinPath(entriesDirFull, `${compositionId}.json`);
|
|
3700
3703
|
this.logger.action(
|
|
3701
3704
|
whatIf,
|
|
@@ -3818,13 +3821,29 @@ var CompositionConverterService = class {
|
|
|
3818
3821
|
// --- Entry Generation ---
|
|
3819
3822
|
generateEntryFromComposition(composition) {
|
|
3820
3823
|
const comp = composition.composition;
|
|
3824
|
+
const compositionSpecificKeys = /* @__PURE__ */ new Set(["_id", "_name", "type", "parameters", "slots", "_overrides"]);
|
|
3825
|
+
const extraRootProps = {};
|
|
3826
|
+
for (const [key, value] of Object.entries(comp)) {
|
|
3827
|
+
if (!compositionSpecificKeys.has(key) && value != null) {
|
|
3828
|
+
extraRootProps[key] = value;
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3831
|
+
const wrapperKeys = /* @__PURE__ */ new Set(["composition"]);
|
|
3832
|
+
const extraWrapperProps = {};
|
|
3833
|
+
for (const [key, value] of Object.entries(composition)) {
|
|
3834
|
+
if (!wrapperKeys.has(key) && value != null) {
|
|
3835
|
+
extraWrapperProps[key] = value;
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3821
3838
|
return {
|
|
3822
3839
|
entry: {
|
|
3823
3840
|
_id: comp._id,
|
|
3824
3841
|
_name: comp._name ?? comp._id,
|
|
3825
3842
|
type: comp.type,
|
|
3826
|
-
fields: { ...comp.parameters ?? {} }
|
|
3827
|
-
|
|
3843
|
+
fields: { ...comp.parameters ?? {} },
|
|
3844
|
+
...extraRootProps
|
|
3845
|
+
},
|
|
3846
|
+
...extraWrapperProps
|
|
3828
3847
|
};
|
|
3829
3848
|
}
|
|
3830
3849
|
generateEntryFromFlattenedInstance(inst) {
|
|
@@ -3878,6 +3897,30 @@ var CompositionConverterService = class {
|
|
|
3878
3897
|
}
|
|
3879
3898
|
}
|
|
3880
3899
|
}
|
|
3900
|
+
// --- Content Reference Transformation ---
|
|
3901
|
+
transformContentReferences(entry) {
|
|
3902
|
+
const dataResources = {};
|
|
3903
|
+
for (const [fieldName, field] of Object.entries(entry.entry.fields)) {
|
|
3904
|
+
if (field.type === "contentReference" && Array.isArray(field.value)) {
|
|
3905
|
+
const entryIds = field.value;
|
|
3906
|
+
const resourceKey = `ref-${entry.entry._id}-${fieldName}`;
|
|
3907
|
+
field.value = `\${#jptr:/${resourceKey}/entries}`;
|
|
3908
|
+
dataResources[resourceKey] = {
|
|
3909
|
+
type: "uniformContentInternalReference",
|
|
3910
|
+
variables: {
|
|
3911
|
+
locale: "${locale}",
|
|
3912
|
+
entryIds: entryIds.join(",")
|
|
3913
|
+
}
|
|
3914
|
+
};
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
if (Object.keys(dataResources).length > 0) {
|
|
3918
|
+
entry.entry._dataResources = {
|
|
3919
|
+
...entry.entry._dataResources ?? {},
|
|
3920
|
+
...dataResources
|
|
3921
|
+
};
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3881
3924
|
// --- Utilities ---
|
|
3882
3925
|
compareTypes(type1, type2, strict) {
|
|
3883
3926
|
if (strict) {
|
|
@@ -4010,7 +4053,7 @@ function createConvertCompositionsToEntriesCommand() {
|
|
|
4010
4053
|
// package.json
|
|
4011
4054
|
var package_default = {
|
|
4012
4055
|
name: "@uniformdev/transformer",
|
|
4013
|
-
version: "1.1.
|
|
4056
|
+
version: "1.1.12",
|
|
4014
4057
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
4015
4058
|
type: "module",
|
|
4016
4059
|
bin: {
|