Open MartinDavi opened 7 months ago
And description should it be an object ?
{ format: "basic_html", processed: "<p>Test description</p>" value: "<p>Test description</p>" }
Running into this with the Document media types. Note that DrupalNode
and DrupalParagraph
are have number
as the type for the drupal_internal__*id
, but DrupalMedia
and DrupalFile
have those as string. We are seeing them come through as number
in our system.
export interface DrupalNode extends JsonApiResourceWithPath {
drupal_internal__nid: number;
drupal_internal__vid: number;
changed: string;
created: string;
title: string;
default_langcode: boolean;
sticky: boolean;
}
export interface DrupalParagraph extends JsonApiResource {
drupal_internal__id: number;
drupal_internal__revision_id: number;
}
export interface DrupalBlock extends JsonApiResource {
info: string;
}
export interface DrupalMedia extends JsonApiResource {
drupal_internal__mid: string;
drupal_internal__vid: string;
changed: string;
created: string;
name: string;
}
export interface DrupalFile extends JsonApiResource {
drupal_internal__fid: string;
changed: string;
created: string;
filename: string;
uri: {
value: string;
url: string;
};
filesize: number;
filemime: string;
resourceIdObjMeta?: DrupalFileMeta;
}
export interface DrupalFileMeta {
alt?: string;
title?: string;
width: number;
height: number;
}
A second issue is that the types for DrupalFIleMeta
(via resourceIdObjMeta
) are specific to images, but document files returned via JSON:API have a different resourceIdObjMeta
surfaced.
images:
"image": {
"data": {
"type": "file--file",
"id": "e638fd17-9090-442b-a724-5113133b4d0f",
"meta": {
"alt": null,
"title": null,
"width": 456,
"height": 304,
"drupal_internal__target_id": 1
}
},
documents:
"field_document": {
"data": {
"type": "file--file",
"id": "b17bc9dd-a7ce-469a-9b9f-5550de367cea",
"meta": {
"display": true,
"description": "",
"drupal_internal__target_id": 10
}
},
Package containing the bug
next-drupal (NPM package)
Describe the bug
Hey, in types.ts we have:
But when I fetch terms from the jsonapi,
drupal_internal__tid
is a number. Same if it's a node id or what have you.This just caused a tricky bug where I was trying to compare a string with a number which of course wasn't working.
I'm on 1.6.0.