@nubitio/hydra 0.9.2 → 0.9.4
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 +18 -1
- package/dist/index.mjs +18 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -721,7 +721,25 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
721
721
|
const hydraTitle = fieldSchema["hydra:title"];
|
|
722
722
|
const label = hydraTitle && hydraTitle.trim() !== "" && hydraTitle !== name ? hydraTitle : toLabel(name);
|
|
723
723
|
const filterable = filterableProperties.size === 0 ? true : filterableProperties.has(name);
|
|
724
|
+
const tag = resolveRangeTag(range, propertyType);
|
|
724
725
|
if (!writeable) {
|
|
726
|
+
if (tag === "entity" || propertyType === "Link") {
|
|
727
|
+
const resourceClass = range ? range.replace("#", "") : "";
|
|
728
|
+
const relatedSchema = resourceClass ? schemaLookup?.(resourceClass) : void 0;
|
|
729
|
+
const relatedTextField = resolveEntityTextField(relatedSchema, resolveEntityValueField(relatedSchema), fieldSchema.crudHints?.textField);
|
|
730
|
+
const field = {
|
|
731
|
+
...(0, _nubitio_crud.noneField)().name(name).label(label).required(required).formatter((cell) => {
|
|
732
|
+
const value = cell.value;
|
|
733
|
+
if (value == null) return "";
|
|
734
|
+
if (typeof value !== "object") return String(value);
|
|
735
|
+
return String(value[relatedTextField] ?? "");
|
|
736
|
+
}).build(),
|
|
737
|
+
filterable
|
|
738
|
+
};
|
|
739
|
+
stampMappingReason(field, "rule-3 display-only entity-ref", applyCrudHints(field, fieldSchema.crudHints));
|
|
740
|
+
fields.push(field);
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
725
743
|
const field = {
|
|
726
744
|
...(fieldSchema.crudHints?.format === "currency" ? (0, _nubitio_crud.currencyField)().readonly(true) : (0, _nubitio_crud.noneField)()).name(name).label(label).required(required).build(),
|
|
727
745
|
filterable
|
|
@@ -730,7 +748,6 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
730
748
|
fields.push(field);
|
|
731
749
|
continue;
|
|
732
750
|
}
|
|
733
|
-
const tag = resolveRangeTag(range, propertyType);
|
|
734
751
|
const enumOptions = fieldSchema.enumOptions;
|
|
735
752
|
if (enumOptions && enumOptions.length > 0 && (tag === "text" || tag === "integer" || tag === "decimal")) {
|
|
736
753
|
const field = {
|
package/dist/index.mjs
CHANGED
|
@@ -697,7 +697,25 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
697
697
|
const hydraTitle = fieldSchema["hydra:title"];
|
|
698
698
|
const label = hydraTitle && hydraTitle.trim() !== "" && hydraTitle !== name ? hydraTitle : toLabel(name);
|
|
699
699
|
const filterable = filterableProperties.size === 0 ? true : filterableProperties.has(name);
|
|
700
|
+
const tag = resolveRangeTag(range, propertyType);
|
|
700
701
|
if (!writeable) {
|
|
702
|
+
if (tag === "entity" || propertyType === "Link") {
|
|
703
|
+
const resourceClass = range ? range.replace("#", "") : "";
|
|
704
|
+
const relatedSchema = resourceClass ? schemaLookup?.(resourceClass) : void 0;
|
|
705
|
+
const relatedTextField = resolveEntityTextField(relatedSchema, resolveEntityValueField(relatedSchema), fieldSchema.crudHints?.textField);
|
|
706
|
+
const field = {
|
|
707
|
+
...noneField().name(name).label(label).required(required).formatter((cell) => {
|
|
708
|
+
const value = cell.value;
|
|
709
|
+
if (value == null) return "";
|
|
710
|
+
if (typeof value !== "object") return String(value);
|
|
711
|
+
return String(value[relatedTextField] ?? "");
|
|
712
|
+
}).build(),
|
|
713
|
+
filterable
|
|
714
|
+
};
|
|
715
|
+
stampMappingReason(field, "rule-3 display-only entity-ref", applyCrudHints(field, fieldSchema.crudHints));
|
|
716
|
+
fields.push(field);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
701
719
|
const field = {
|
|
702
720
|
...(fieldSchema.crudHints?.format === "currency" ? currencyField().readonly(true) : noneField()).name(name).label(label).required(required).build(),
|
|
703
721
|
filterable
|
|
@@ -706,7 +724,6 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
706
724
|
fields.push(field);
|
|
707
725
|
continue;
|
|
708
726
|
}
|
|
709
|
-
const tag = resolveRangeTag(range, propertyType);
|
|
710
727
|
const enumOptions = fieldSchema.enumOptions;
|
|
711
728
|
if (enumOptions && enumOptions.length > 0 && (tag === "text" || tag === "integer" || tag === "decimal")) {
|
|
712
729
|
const field = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/hydra",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Hydra / OpenAPI adapter for @nubitio/crud — automatic schema discovery and data source from API Platform docs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react": "^18.2.0 || ^19.0.0",
|
|
51
51
|
"react-dom": "^18.2.0 || ^19.0.0",
|
|
52
52
|
"react-i18next": "^14.0.0",
|
|
53
|
-
"@nubitio/core": "^0.9.
|
|
54
|
-
"@nubitio/crud": "^0.9.
|
|
53
|
+
"@nubitio/core": "^0.9.4",
|
|
54
|
+
"@nubitio/crud": "^0.9.4"
|
|
55
55
|
}
|
|
56
56
|
}
|