@famgia/omnify-core 0.0.160 → 0.0.163
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.cjs +73 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2250,7 +2250,8 @@ var VALID_PIVOT_FIELD_TYPES = [
|
|
|
2250
2250
|
"Date",
|
|
2251
2251
|
"Time",
|
|
2252
2252
|
"Timestamp",
|
|
2253
|
-
"Json"
|
|
2253
|
+
"Json",
|
|
2254
|
+
"Enum"
|
|
2254
2255
|
];
|
|
2255
2256
|
var ASSOCIATION_FIELDS = [
|
|
2256
2257
|
"relation",
|
|
@@ -2536,6 +2537,77 @@ var AssociationType = {
|
|
|
2536
2537
|
`Supported types: ${VALID_PIVOT_FIELD_TYPES.join(", ")}`
|
|
2537
2538
|
)
|
|
2538
2539
|
);
|
|
2540
|
+
} else if (fieldType === "Enum") {
|
|
2541
|
+
const { enum: enumValues } = fieldDef;
|
|
2542
|
+
if (enumValues === void 0) {
|
|
2543
|
+
errors.push(
|
|
2544
|
+
validationError(
|
|
2545
|
+
`Pivot field '${fieldName}' in '${propertyName}' of type 'Enum' requires 'enum' field`,
|
|
2546
|
+
buildLocation6(filePath),
|
|
2547
|
+
`Example: ${fieldName}: { type: "Enum", enum: [value1, value2] }`
|
|
2548
|
+
)
|
|
2549
|
+
);
|
|
2550
|
+
} else if (!Array.isArray(enumValues)) {
|
|
2551
|
+
errors.push(
|
|
2552
|
+
validationError(
|
|
2553
|
+
`Pivot field '${fieldName}' in '${propertyName}' enum field must be an array`,
|
|
2554
|
+
buildLocation6(filePath),
|
|
2555
|
+
'enum: [value1, value2] or enum: [{ value: "v1", label: "Label 1" }]'
|
|
2556
|
+
)
|
|
2557
|
+
);
|
|
2558
|
+
} else if (enumValues.length === 0) {
|
|
2559
|
+
errors.push(
|
|
2560
|
+
validationError(
|
|
2561
|
+
`Pivot field '${fieldName}' in '${propertyName}' enum field cannot be empty`,
|
|
2562
|
+
buildLocation6(filePath),
|
|
2563
|
+
"Add at least one enum value"
|
|
2564
|
+
)
|
|
2565
|
+
);
|
|
2566
|
+
} else {
|
|
2567
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2568
|
+
for (const value of enumValues) {
|
|
2569
|
+
if (typeof value === "string") {
|
|
2570
|
+
if (seen.has(value)) {
|
|
2571
|
+
errors.push(
|
|
2572
|
+
validationError(
|
|
2573
|
+
`Pivot field '${fieldName}' in '${propertyName}' has duplicate enum value '${value}'`,
|
|
2574
|
+
buildLocation6(filePath)
|
|
2575
|
+
)
|
|
2576
|
+
);
|
|
2577
|
+
} else {
|
|
2578
|
+
seen.add(value);
|
|
2579
|
+
}
|
|
2580
|
+
} else if (typeof value === "object" && value !== null && "value" in value) {
|
|
2581
|
+
const objValue = value.value;
|
|
2582
|
+
if (typeof objValue !== "string") {
|
|
2583
|
+
errors.push(
|
|
2584
|
+
validationError(
|
|
2585
|
+
`Pivot field '${fieldName}' in '${propertyName}' enum value.value must be a string`,
|
|
2586
|
+
buildLocation6(filePath),
|
|
2587
|
+
'Use format: { value: "string", label: "Display Label" }'
|
|
2588
|
+
)
|
|
2589
|
+
);
|
|
2590
|
+
} else if (seen.has(objValue)) {
|
|
2591
|
+
errors.push(
|
|
2592
|
+
validationError(
|
|
2593
|
+
`Pivot field '${fieldName}' in '${propertyName}' has duplicate enum value '${objValue}'`,
|
|
2594
|
+
buildLocation6(filePath)
|
|
2595
|
+
)
|
|
2596
|
+
);
|
|
2597
|
+
} else {
|
|
2598
|
+
seen.add(objValue);
|
|
2599
|
+
}
|
|
2600
|
+
} else {
|
|
2601
|
+
errors.push(
|
|
2602
|
+
validationError(
|
|
2603
|
+
`Pivot field '${fieldName}' in '${propertyName}' enum values must be strings or objects with 'value' field`,
|
|
2604
|
+
buildLocation6(filePath),
|
|
2605
|
+
'Use: "value" or { value: "value", label: "Label" }'
|
|
2606
|
+
)
|
|
2607
|
+
);
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2539
2611
|
}
|
|
2540
2612
|
}
|
|
2541
2613
|
}
|