@nubitio/hydra 0.9.5 → 0.9.6
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 +8 -5
- package/dist/index.d.cts +9 -5
- package/dist/index.d.mts +9 -5
- package/dist/index.mjs +8 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -300,9 +300,11 @@ function deriveApiUrl(entrypointPropertyId) {
|
|
|
300
300
|
/**
|
|
301
301
|
* True when `raw` is the Hydra collection-range wrapper — an array whose
|
|
302
302
|
* entries carry the target class under `owl:equivalentClass.owl:allValuesFrom`.
|
|
303
|
-
*
|
|
304
|
-
* properties
|
|
305
|
-
*
|
|
303
|
+
* Some API Platform configurations emit this shape for `ManyToMany`/`OneToMany`
|
|
304
|
+
* properties instead of the plain string `range` + `@type: "Link"` combination
|
|
305
|
+
* (see the `isCollection` field on `HydraFieldSchema` for the other signal) —
|
|
306
|
+
* this function only recognises the array-wrapper variant. A to-one relation's
|
|
307
|
+
* `range` is always a plain string or a single IRI object, never an array.
|
|
306
308
|
*/
|
|
307
309
|
function isCollectionRange(raw) {
|
|
308
310
|
return Array.isArray(raw);
|
|
@@ -439,14 +441,15 @@ function parseHydraDoc(doc, entrypointHrefs) {
|
|
|
439
441
|
const readable = sp.readable !== false;
|
|
440
442
|
const writeable = sp.writeable !== false;
|
|
441
443
|
if (!readable) continue;
|
|
444
|
+
const propertyType = sp.property?.["@type"] ?? "rdf:Property";
|
|
442
445
|
fields.push({
|
|
443
446
|
name: technicalName(sp),
|
|
444
447
|
range: normalizeRange(sp.property?.range),
|
|
445
|
-
propertyType
|
|
448
|
+
propertyType,
|
|
446
449
|
required: sp.required ?? false,
|
|
447
450
|
readable,
|
|
448
451
|
writeable,
|
|
449
|
-
isCollection: isCollectionRange(sp.property?.range),
|
|
452
|
+
isCollection: isCollectionRange(sp.property?.range) || propertyType === "Link",
|
|
450
453
|
"hydra:title": sp["title"] ?? sp["hydra:title"] ?? void 0,
|
|
451
454
|
crudHints: sp["x-crud"],
|
|
452
455
|
enumOptions: Array.isArray(sp["enum"]) ? sp["enum"] : void 0
|
package/dist/index.d.cts
CHANGED
|
@@ -265,11 +265,15 @@ interface HydraFieldSchema {
|
|
|
265
265
|
enumOptions?: Array<string | number>;
|
|
266
266
|
/**
|
|
267
267
|
* True when the property is a to-many relation (Doctrine ManyToMany /
|
|
268
|
-
* OneToMany) rather than a single reference.
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
268
|
+
* OneToMany) rather than a single reference. Two independent Hydra signals
|
|
269
|
+
* feed this, checked with OR since different API Platform configurations
|
|
270
|
+
* emit different ones: the collection-range array wrapper (see
|
|
271
|
+
* {@link isCollectionRange}), or `propertyType === 'Link'` — confirmed
|
|
272
|
+
* empirically to be exactly the to-many properties in at least one real
|
|
273
|
+
* deployment, where `range` alone is an unchanged plain string identical to
|
|
274
|
+
* a to-one relation's and carries no cardinality information at all. Rule 8
|
|
275
|
+
* in {@link mapHydraSchemaToFields} uses this to render a multi-select
|
|
276
|
+
* control instead of a single picker.
|
|
273
277
|
*/
|
|
274
278
|
isCollection?: boolean;
|
|
275
279
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -265,11 +265,15 @@ interface HydraFieldSchema {
|
|
|
265
265
|
enumOptions?: Array<string | number>;
|
|
266
266
|
/**
|
|
267
267
|
* True when the property is a to-many relation (Doctrine ManyToMany /
|
|
268
|
-
* OneToMany) rather than a single reference.
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
268
|
+
* OneToMany) rather than a single reference. Two independent Hydra signals
|
|
269
|
+
* feed this, checked with OR since different API Platform configurations
|
|
270
|
+
* emit different ones: the collection-range array wrapper (see
|
|
271
|
+
* {@link isCollectionRange}), or `propertyType === 'Link'` — confirmed
|
|
272
|
+
* empirically to be exactly the to-many properties in at least one real
|
|
273
|
+
* deployment, where `range` alone is an unchanged plain string identical to
|
|
274
|
+
* a to-one relation's and carries no cardinality information at all. Rule 8
|
|
275
|
+
* in {@link mapHydraSchemaToFields} uses this to render a multi-select
|
|
276
|
+
* control instead of a single picker.
|
|
273
277
|
*/
|
|
274
278
|
isCollection?: boolean;
|
|
275
279
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -276,9 +276,11 @@ function deriveApiUrl(entrypointPropertyId) {
|
|
|
276
276
|
/**
|
|
277
277
|
* True when `raw` is the Hydra collection-range wrapper — an array whose
|
|
278
278
|
* entries carry the target class under `owl:equivalentClass.owl:allValuesFrom`.
|
|
279
|
-
*
|
|
280
|
-
* properties
|
|
281
|
-
*
|
|
279
|
+
* Some API Platform configurations emit this shape for `ManyToMany`/`OneToMany`
|
|
280
|
+
* properties instead of the plain string `range` + `@type: "Link"` combination
|
|
281
|
+
* (see the `isCollection` field on `HydraFieldSchema` for the other signal) —
|
|
282
|
+
* this function only recognises the array-wrapper variant. A to-one relation's
|
|
283
|
+
* `range` is always a plain string or a single IRI object, never an array.
|
|
282
284
|
*/
|
|
283
285
|
function isCollectionRange(raw) {
|
|
284
286
|
return Array.isArray(raw);
|
|
@@ -415,14 +417,15 @@ function parseHydraDoc(doc, entrypointHrefs) {
|
|
|
415
417
|
const readable = sp.readable !== false;
|
|
416
418
|
const writeable = sp.writeable !== false;
|
|
417
419
|
if (!readable) continue;
|
|
420
|
+
const propertyType = sp.property?.["@type"] ?? "rdf:Property";
|
|
418
421
|
fields.push({
|
|
419
422
|
name: technicalName(sp),
|
|
420
423
|
range: normalizeRange(sp.property?.range),
|
|
421
|
-
propertyType
|
|
424
|
+
propertyType,
|
|
422
425
|
required: sp.required ?? false,
|
|
423
426
|
readable,
|
|
424
427
|
writeable,
|
|
425
|
-
isCollection: isCollectionRange(sp.property?.range),
|
|
428
|
+
isCollection: isCollectionRange(sp.property?.range) || propertyType === "Link",
|
|
426
429
|
"hydra:title": sp["title"] ?? sp["hydra:title"] ?? void 0,
|
|
427
430
|
crudHints: sp["x-crud"],
|
|
428
431
|
enumOptions: Array.isArray(sp["enum"]) ? sp["enum"] : void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubitio/hydra",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
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.6",
|
|
54
|
+
"@nubitio/crud": "^0.9.6"
|
|
55
55
|
}
|
|
56
56
|
}
|