From bcda3fdba943ec4da8b0a1c50907a1341981164c Mon Sep 17 00:00:00 2001 From: Stefano Verna Date: Mon, 29 Jun 2026 12:45:35 +0000 Subject: [PATCH 1/2] Add poster_time to file/gallery field value types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CMA returns (and accepts) a `poster_time` metadata key on file and gallery field values for video assets — the float second into the video used to generate the thumbnail. The hand-written field value types didn't include it, so it was missing from `FileFieldValue`, `FileFieldValueInRequest`, and (via re-export) the gallery equivalents. - Add `poster_time` to `FileFieldValue` (`number | null`) and `FileFieldValueInRequest` (`number | null`, optional). - Require `poster_time` in the `isFileFieldValue` response type guard, matching the existing `focal_point` check. - Surface `poster_time` in `inspectItem` for file and gallery items. Gallery types derive from the file types, so they pick this up for free. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/cma-client/__tests__/inspectItem.test.ts | 2 ++ packages/cma-client/src/fieldTypes/file.ts | 8 ++++++-- packages/cma-client/src/utilities/inspectItem.ts | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/cma-client/__tests__/inspectItem.test.ts b/packages/cma-client/__tests__/inspectItem.test.ts index b332d6b6..d2d3c746 100644 --- a/packages/cma-client/__tests__/inspectItem.test.ts +++ b/packages/cma-client/__tests__/inspectItem.test.ts @@ -398,6 +398,7 @@ describe('inspectItem', () => { title: 'English file title', custom_data: {}, focal_point: null, + poster_time: null, }, it: { upload_id: 'italian-file-id', @@ -405,6 +406,7 @@ describe('inspectItem', () => { title: 'Titolo file italiano', custom_data: { locale: 'it' }, focal_point: { x: 0.6, y: 0.4 }, + poster_time: null, }, }, diff --git a/packages/cma-client/src/fieldTypes/file.ts b/packages/cma-client/src/fieldTypes/file.ts index 6336708d..e35d73e5 100644 --- a/packages/cma-client/src/fieldTypes/file.ts +++ b/packages/cma-client/src/fieldTypes/file.ts @@ -17,13 +17,14 @@ import type { RequiredAltTitleValidator } from './validators/required_alt_title. * which contain file uploads with optional metadata like alt text, title, custom data, and focal points. * * The challenge we're solving: - * - DatoCMS File fields can have optional metadata fields (alt, title, custom_data, focal_point) + * - DatoCMS File fields can have optional metadata fields (alt, title, custom_data, focal_point, poster_time) * - For API requests, all these fields are optional and can be omitted * - For API responses, DatoCMS provides default values for missing fields: * - alt: null * - title: null * - custom_data: {} * - focal_point: null + * - poster_time: null * - This creates a need for different type variants for the same conceptual data structure * * This module provides separate types for: @@ -52,6 +53,7 @@ export type FileFieldValue = { x: number; y: number; } | null; + poster_time: number | null; } | null; /** @@ -75,6 +77,7 @@ export type FileFieldValueInRequest = { x: number; y: number; } | null; + poster_time?: number | null; } | null; /** @@ -95,7 +98,8 @@ export function isFileFieldValue(value: unknown): value is FileFieldValue { 'alt' in value && 'title' in value && 'custom_data' in value && - 'focal_point' in value + 'focal_point' in value && + 'poster_time' in value ); } diff --git a/packages/cma-client/src/utilities/inspectItem.ts b/packages/cma-client/src/utilities/inspectItem.ts index b4db4a26..8d51cacc 100644 --- a/packages/cma-client/src/utilities/inspectItem.ts +++ b/packages/cma-client/src/utilities/inspectItem.ts @@ -387,6 +387,10 @@ function fileInspectionTreeNodes( nodes.push({ label: `focal_point: x=${x}% y=${y}%` }); } + if (typeof value.poster_time === 'number') { + nodes.push({ label: `poster_time: ${value.poster_time}s` }); + } + return nodes; } @@ -432,6 +436,10 @@ function galleryInspectionTreeNodes( nodes.push({ label: `focal_point: x=${x}% y=${y}%` }); } + if (typeof item.poster_time === 'number') { + nodes.push({ label: `poster_time: ${item.poster_time}s` }); + } + return { label: `[${index}]`, nodes: nodes, From 56e77cbff1dd2d9b4935bb2e34c8356bd779347b Mon Sep 17 00:00:00 2001 From: Stefano Verna Date: Mon, 29 Jun 2026 14:53:14 +0200 Subject: [PATCH 2/2] Update schema --- packages/cma-client/src/generated/ApiTypes.ts | 2 +- packages/cma-client/src/generated/RawApiTypes.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cma-client/src/generated/ApiTypes.ts b/packages/cma-client/src/generated/ApiTypes.ts index 739c76c1..0f0f100a 100644 --- a/packages/cma-client/src/generated/ApiTypes.ts +++ b/packages/cma-client/src/generated/ApiTypes.ts @@ -7892,7 +7892,7 @@ export type ItemValidateExistingSchema< > = { id?: ItemIdentity; type?: ItemType1; - item_type: ItemTypeData; + item_type?: ItemTypeData; creator?: | AccountData | AccessTokenData diff --git a/packages/cma-client/src/generated/RawApiTypes.ts b/packages/cma-client/src/generated/RawApiTypes.ts index 40448255..3d15662e 100644 --- a/packages/cma-client/src/generated/RawApiTypes.ts +++ b/packages/cma-client/src/generated/RawApiTypes.ts @@ -7599,11 +7599,11 @@ export type ItemValidateExistingSchema< * The JSON data associated to the record */ attributes: ToItemAttributesInRequest; - relationships: { + relationships?: { /** * The record's model */ - item_type: { + item_type?: { data: ItemTypeData; }; /**