@c-time/frelio-data-json-generator 2.0.0 → 2.1.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.js +16 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -699,10 +699,12 @@ async function applyCustomFields(data, customFields, content, context) {
|
|
|
699
699
|
return data;
|
|
700
700
|
}
|
|
701
701
|
const result = { ...data };
|
|
702
|
-
for (const
|
|
703
|
-
|
|
702
|
+
for (const rawField of customFields) {
|
|
703
|
+
const field = inferLegacyType(rawField);
|
|
704
|
+
const loose = field;
|
|
705
|
+
if (!loose.type) {
|
|
704
706
|
throw new Error(
|
|
705
|
-
`CustomField "${
|
|
707
|
+
`CustomField "${loose.field ?? "(unknown)"}" is missing required "type" field.`
|
|
706
708
|
);
|
|
707
709
|
}
|
|
708
710
|
if (field.type === "constant") {
|
|
@@ -717,6 +719,17 @@ async function applyCustomFields(data, customFields, content, context) {
|
|
|
717
719
|
}
|
|
718
720
|
return result;
|
|
719
721
|
}
|
|
722
|
+
function inferLegacyType(field) {
|
|
723
|
+
const loose = field;
|
|
724
|
+
if (loose.type) return field;
|
|
725
|
+
if (typeof loose.source === "string") {
|
|
726
|
+
return { ...field, type: "string" };
|
|
727
|
+
}
|
|
728
|
+
if (loose.value !== void 0) {
|
|
729
|
+
return { ...field, type: "constant" };
|
|
730
|
+
}
|
|
731
|
+
return field;
|
|
732
|
+
}
|
|
720
733
|
function applyTransformField(field, content, currentData, defaultTimezone) {
|
|
721
734
|
const sourceValue = resolveSourceExpression(field.source, content, currentData);
|
|
722
735
|
return formatValue(sourceValue, field.type, {
|