Skip to content

Commit

Permalink
Improved image typings (plone#6064)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnicolli authored Jun 1, 2024
1 parent 57c97e7 commit a2f8d59
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/types/news/6064.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved image typings @pnicolli
6 changes: 3 additions & 3 deletions packages/types/src/content/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export type RelatedItem = {
'@type': string;
UID: string;
description: string;
image_field: unknown;
image_scales: unknown;
image_field: string;
image_scales: Record<string, Image> | null;
review_state: string;
title: string;
};
Expand All @@ -46,7 +46,7 @@ export type ImageScale = {
width: number;
};

export type PreviewImage = {
export type Image = {
'content-type': string;
download: string;
filename: string;
Expand Down
12 changes: 4 additions & 8 deletions packages/types/src/content/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
Expanders,
ContainedItem,
PreviewImage,
RelatedItem,
} from './common';
import type { Expanders, ContainedItem, Image, RelatedItem } from './common';

export interface Content {
'@components': Expanders;
Expand Down Expand Up @@ -33,6 +28,7 @@ export interface Content {
expires: string | null;
id: string;
is_folderish: boolean;
image?: Image | null;
items: ContainedItem[];
items_total: number;
language: unknown;
Expand Down Expand Up @@ -68,7 +64,7 @@ export interface Content {
title: string;
};
preview_caption: string | null;
preview_image: PreviewImage;
preview_image?: Image | null;
previous_item: {
'@id': string;
'@type': string;
Expand All @@ -81,7 +77,7 @@ export interface Content {
subjects: [];
table_of_contents: boolean | null;
title: string;
type_tile: string | null;
type_title: string | null;
version: number | null;
versioning_enabled: boolean | null;
working_copy: unknown;
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/services/common.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PreviewImage } from '../content/common';
import type { Image } from '../content/common';

export interface Brain {
'@id': string;
Expand Down Expand Up @@ -33,7 +33,7 @@ export interface Brain {
head_title: string | null; // TODO is this correct?
id: string;
image_field: string; // TODO could this be more specific?
image_scales: Record<string, PreviewImage> | null; // TODO could this be more specific?
image_scales: Record<string, Image> | null; // TODO could this be more specific?
in_response_to: string | null; // TODO is this correct?
is_folderish: boolean;
last_comment_date: string | null;
Expand Down

0 comments on commit a2f8d59

Please sign in to comment.