@c-time/frelio-data-json-generator 3.7.1 → 3.8.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/index.js CHANGED
@@ -745,7 +745,10 @@ function inferLegacyType(field) {
745
745
  return field;
746
746
  }
747
747
  function applyTransformField(field, content, currentData, defaultTimezone) {
748
- const sourceValue = resolveSourceExpression(field.source, content, currentData);
748
+ let sourceValue = resolveSourceExpression(field.source, content, currentData);
749
+ if (field.fallbackSource !== void 0 && isEmptySourceValue(sourceValue)) {
750
+ sourceValue = resolveSourceExpression(field.fallbackSource, content, currentData);
751
+ }
749
752
  return formatValue(sourceValue, field.type, {
750
753
  format: field.format,
751
754
  timezone: field.timezone ?? defaultTimezone,
@@ -755,6 +758,10 @@ function applyTransformField(field, content, currentData, defaultTimezone) {
755
758
  defaultValue: field.defaultValue
756
759
  });
757
760
  }
761
+ function isEmptySourceValue(value) {
762
+ if (value === void 0 || value === null) return true;
763
+ return typeof value === "string" && value.trim() === "";
764
+ }
758
765
  function resolveSourceExpression(source, content, currentData) {
759
766
  const singleVarMatch = source.match(/^\{\$this\.([^}]+)\}$/);
760
767
  if (singleVarMatch) {