import { PrimitiveType } from '../jsonTypeResolution/TypeResolver'; import type { ExifData } from 'exif'; interface SquizImageData { width: number; height: number; url: string; mimeType: string; byteSize: number; sha1Hash: string; aspectRatio: string; // Enforced validation of something like /\d+:\d+/ } interface SquizImageShape { name: string; alt?: string; caption?: string; exif?: ExifData; imageVariations: { original: SquizImageData; small?: SquizImageData[]; medium?: SquizImageData[]; large?: SquizImageData[]; aspectRatios?: SquizImageData[]; }; } export const SquizImageType = PrimitiveType({ title: 'SquizImage', type: 'object', properties: { name: { type: 'string', }, alt: { type: 'string', }, caption: { type: 'string', }, exif: { type: 'object', properties: { image: { type: 'object', }, thumbnail: { type: 'object', }, exif: { type: 'object', }, gps: { type: 'object', }, interoperability: { type: 'object', }, makernote: { type: 'object', }, }, required: ['image', 'thumbnail', 'exif', 'gps', 'interoperability', 'makernote'], }, imageVariations: { type: 'object', properties: { original: { $ref: '#/definitions/SquizImageData' }, small: { type: 'array', items: { $ref: '#/definitions/SquizImageData', }, }, medium: { type: 'array', items: { $ref: '#/definitions/SquizImageData', }, }, large: { type: 'array', items: { $ref: '#/definitions/SquizImageData', }, }, aspectRatios: { type: 'array', items: { $ref: '#/definitions/SquizImageData', }, }, }, required: ['original'], }, }, required: ['name', 'imageVariations'], definitions: { SquizImageData: { type: 'object', properties: { width: { type: 'number', }, height: { type: 'number', }, url: { type: 'string', }, mimeType: { type: 'string', }, byteSize: { type: 'number', }, sha1Hash: { type: 'string', }, aspectRatio: { type: 'string', }, }, required: ['width', 'height', 'url', 'mimeType', 'byteSize', 'sha1Hash', 'aspectRatio'], }, }, }); export type SquizImageType = typeof SquizImageType;