@nubitio/hydra 0.3.0 → 0.4.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.cjs CHANGED
@@ -624,6 +624,27 @@ 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
+ }
639
+ if (fieldSchema.crudHints?.format === "currency" && (tag === "text" || tag === "integer" || tag === "decimal")) {
640
+ const field = {
641
+ ...(0, _nubitio_crud.currencyField)().name(name).label(label).required(required).build(),
642
+ filterable
643
+ };
644
+ applyCrudHints(field, fieldSchema.crudHints);
645
+ fields.push(field);
646
+ continue;
647
+ }
627
648
  if (tag === "boolean") {
628
649
  const field = {
629
650
  ...(0, _nubitio_crud.switchField)().name(name).label(label).required(required).build(),
@@ -653,7 +674,7 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
653
674
  }
654
675
  if (tag === "decimal") {
655
676
  const field = {
656
- ...(fieldSchema.crudHints?.format === "currency" ? (0, _nubitio_crud.currencyField)() : (0, _nubitio_crud.numberField)()).name(name).label(label).required(required).build(),
677
+ ...(0, _nubitio_crud.numberField)().name(name).label(label).required(required).build(),
657
678
  filterable
658
679
  };
659
680
  applyCrudHints(field, fieldSchema.crudHints);
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
- /** Render hint for scalar fields. 'currency' maps decimals to a currency control. */
77
- format?: 'currency';
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
- /** Render hint for scalar fields. 'currency' maps decimals to a currency control. */
77
- format?: 'currency';
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,27 @@ 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
+ }
615
+ if (fieldSchema.crudHints?.format === "currency" && (tag === "text" || tag === "integer" || tag === "decimal")) {
616
+ const field = {
617
+ ...currencyField().name(name).label(label).required(required).build(),
618
+ filterable
619
+ };
620
+ applyCrudHints(field, fieldSchema.crudHints);
621
+ fields.push(field);
622
+ continue;
623
+ }
603
624
  if (tag === "boolean") {
604
625
  const field = {
605
626
  ...switchField().name(name).label(label).required(required).build(),
@@ -629,7 +650,7 @@ function mapHydraSchemaToFields(schema, urlLookup, schemaLookup) {
629
650
  }
630
651
  if (tag === "decimal") {
631
652
  const field = {
632
- ...(fieldSchema.crudHints?.format === "currency" ? currencyField() : numberField()).name(name).label(label).required(required).build(),
653
+ ...numberField().name(name).label(label).required(required).build(),
633
654
  filterable
634
655
  };
635
656
  applyCrudHints(field, fieldSchema.crudHints);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/hydra",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
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.3.0",
54
- "@nubitio/crud": "^0.3.0"
53
+ "@nubitio/core": "^0.4.0",
54
+ "@nubitio/crud": "^0.4.0"
55
55
  }
56
56
  }