@nubitio/hydra 0.3.1 → 0.4.1
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 +12 -0
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +13 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -624,6 +624,18 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
624
624
|
fields.push(field);
|
|
625
625
|
continue;
|
|
626
626
|
}
|
|
627
|
+
const formatHint = fieldSchema.crudHints?.format;
|
|
628
|
+
if (formatHint === "image" || formatHint === "file") {
|
|
629
|
+
const apiBase = schema.apiUrl.slice(0, schema.apiUrl.lastIndexOf("/") + 1);
|
|
630
|
+
const field = {
|
|
631
|
+
...(formatHint === "image" ? (0, _nubitio_crud.imageField)(apiBase) : (0, _nubitio_crud.fileField)(apiBase)).name(name).label(label).required(required).build(),
|
|
632
|
+
filterable: false,
|
|
633
|
+
sortable: false
|
|
634
|
+
};
|
|
635
|
+
applyCrudHints(field, fieldSchema.crudHints);
|
|
636
|
+
fields.push(field);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
627
639
|
if (fieldSchema.crudHints?.format === "currency" && (tag === "text" || tag === "integer" || tag === "decimal")) {
|
|
628
640
|
const field = {
|
|
629
641
|
...(0, _nubitio_crud.currencyField)().name(name).label(label).required(required).build(),
|
package/dist/index.d.cts
CHANGED
|
@@ -73,8 +73,12 @@ interface CrudHints {
|
|
|
73
73
|
order?: number;
|
|
74
74
|
/** Column width in pixels or as a CSS string. */
|
|
75
75
|
width?: number;
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Render hint. 'currency' maps decimals to a money control; 'image'/'file'
|
|
78
|
+
* map media relations (nubitio/admin-bundle Media or compatible) to instant
|
|
79
|
+
* upload controls that submit the media IRI.
|
|
80
|
+
*/
|
|
81
|
+
format?: 'currency' | 'image' | 'file';
|
|
78
82
|
}
|
|
79
83
|
interface HydraSupportedProperty {
|
|
80
84
|
'@type': 'SupportedProperty';
|
package/dist/index.d.mts
CHANGED
|
@@ -73,8 +73,12 @@ interface CrudHints {
|
|
|
73
73
|
order?: number;
|
|
74
74
|
/** Column width in pixels or as a CSS string. */
|
|
75
75
|
width?: number;
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Render hint. 'currency' maps decimals to a money control; 'image'/'file'
|
|
78
|
+
* map media relations (nubitio/admin-bundle Media or compatible) to instant
|
|
79
|
+
* upload controls that submit the media IRI.
|
|
80
|
+
*/
|
|
81
|
+
format?: 'currency' | 'image' | 'file';
|
|
78
82
|
}
|
|
79
83
|
interface HydraSupportedProperty {
|
|
80
84
|
'@type': 'SupportedProperty';
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCoreHttpClient, useCoreConfig, useCoreHttpClient } from "@nubitio/core";
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
import { ResourceSchemaProvider, ResourceStoreProvider, currencyField, datetimeField, entityField, enumField, noneField, numberField, switchField, textField } from "@nubitio/crud";
|
|
3
|
+
import { ResourceSchemaProvider, ResourceStoreProvider, currencyField, datetimeField, entityField, enumField, fileField, imageField, noneField, numberField, switchField, textField } from "@nubitio/crud";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { useQuery } from "@tanstack/react-query";
|
|
6
6
|
//#region packages/hydra/HydraRemoteDataSource.ts
|
|
@@ -600,6 +600,18 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
|
|
|
600
600
|
fields.push(field);
|
|
601
601
|
continue;
|
|
602
602
|
}
|
|
603
|
+
const formatHint = fieldSchema.crudHints?.format;
|
|
604
|
+
if (formatHint === "image" || formatHint === "file") {
|
|
605
|
+
const apiBase = schema.apiUrl.slice(0, schema.apiUrl.lastIndexOf("/") + 1);
|
|
606
|
+
const field = {
|
|
607
|
+
...(formatHint === "image" ? imageField(apiBase) : fileField(apiBase)).name(name).label(label).required(required).build(),
|
|
608
|
+
filterable: false,
|
|
609
|
+
sortable: false
|
|
610
|
+
};
|
|
611
|
+
applyCrudHints(field, fieldSchema.crudHints);
|
|
612
|
+
fields.push(field);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
603
615
|
if (fieldSchema.crudHints?.format === "currency" && (tag === "text" || tag === "integer" || tag === "decimal")) {
|
|
604
616
|
const field = {
|
|
605
617
|
...currencyField().name(name).label(label).required(required).build(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/hydra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
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": "^19.0.0",
|
|
51
51
|
"react-dom": "^19.0.0",
|
|
52
52
|
"react-i18next": "^14.0.0",
|
|
53
|
-
"@nubitio/core": "^0.
|
|
54
|
-
"@nubitio/crud": "^0.
|
|
53
|
+
"@nubitio/core": "^0.4.1",
|
|
54
|
+
"@nubitio/crud": "^0.4.1"
|
|
55
55
|
}
|
|
56
56
|
}
|