From 89398cd05210e0a5204f392f01521925d9f79767 Mon Sep 17 00:00:00 2001 From: Edoardo Sandon Date: Thu, 26 Sep 2024 13:28:11 +0200 Subject: [PATCH 1/3] feat: update the shape of Asset field type --- .../storyblokProvidedPropertyTypes.ts | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/utils/typescript/storyblokProvidedPropertyTypes.ts b/src/utils/typescript/storyblokProvidedPropertyTypes.ts index e480bec..fccce8a 100644 --- a/src/utils/typescript/storyblokProvidedPropertyTypes.ts +++ b/src/utils/typescript/storyblokProvidedPropertyTypes.ts @@ -4,27 +4,65 @@ export const getAssetJSONSchema = (title: string): JSONSchema => ({ $id: "#/asset", title, type: "object", - required: ["id", "filename", "name"], + required: ["id", "fieldtype", "filename", "name", "title", "focus", "alt"], properties: { alt: { - type: "string", + type: ["string", "null"], }, copyright: { + type: ["string", "null"], + }, + fieldtype: { type: "string", + enum: ["asset"], }, id: { type: "number", }, filename: { - type: "string", + type: ["string", "null"], }, name: { type: "string", }, title: { - type: "string", + type: ["string", "null"], }, focus: { + type: ["string", "null"], + }, + meta_data: { + type: "object", + }, + source: { + type: ["string", "null"], + }, + is_external_url: { + type: "boolean", + }, + is_private: { + type: "boolean", + }, + src: { + type: "string", + }, + updated_at: { + type: "string", + }, + // Cloudinary integration keys + width: { + type: ["number", "null"], + }, + height: { + type: ["number", "null"], + }, + aspect_ratio: { + type: ["number", "null"], + }, + public_id: { + type: ["string", "null"], + }, + content_type: { type: "string", }, }, From 4ec6d514039587ec812e85026ce4366cf3a9de4f Mon Sep 17 00:00:00 2001 From: Edoardo Sandon Date: Thu, 26 Sep 2024 13:30:27 +0200 Subject: [PATCH 2/3] feat: update the shape of Multiasset field type --- .../storyblokProvidedPropertyTypes.ts | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/utils/typescript/storyblokProvidedPropertyTypes.ts b/src/utils/typescript/storyblokProvidedPropertyTypes.ts index fccce8a..176e27f 100644 --- a/src/utils/typescript/storyblokProvidedPropertyTypes.ts +++ b/src/utils/typescript/storyblokProvidedPropertyTypes.ts @@ -74,24 +74,65 @@ export const getMultiassetJSONSchema = (title: string): JSONSchema => ({ type: "array", items: { type: "object", - required: ["id", "filename", "name"], + required: ["id", "fieldtype", "filename", "name", "title", "focus", "alt"], properties: { alt: { - type: "string", + type: ["string", "null"], }, copyright: { + type: ["string", "null"], + }, + fieldtype: { type: "string", + enum: ["asset"], }, id: { type: "number", }, filename: { - type: "string", + type: ["string", "null"], }, name: { type: "string", }, title: { + type: ["string", "null"], + }, + focus: { + type: ["string", "null"], + }, + meta_data: { + type: "object", + }, + source: { + type: ["string", "null"], + }, + is_external_url: { + type: "boolean", + }, + is_private: { + type: "boolean", + }, + src: { + type: "string", + }, + updated_at: { + type: "string", + }, + // Cloudinary integration keys + width: { + type: ["number", "null"], + }, + height: { + type: ["number", "null"], + }, + aspect_ratio: { + type: ["number", "null"], + }, + public_id: { + type: ["string", "null"], + }, + content_type: { type: "string", }, }, From 7562c037d2ad84b0c0a925f88908bc5b7fcf637b Mon Sep 17 00:00:00 2001 From: Edoardo Sandon Date: Thu, 26 Sep 2024 16:23:49 +0200 Subject: [PATCH 3/3] feat: update Multilink type --- .../storyblokProvidedPropertyTypes.ts | 81 ++++++++++++++----- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/src/utils/typescript/storyblokProvidedPropertyTypes.ts b/src/utils/typescript/storyblokProvidedPropertyTypes.ts index 176e27f..21f5b13 100644 --- a/src/utils/typescript/storyblokProvidedPropertyTypes.ts +++ b/src/utils/typescript/storyblokProvidedPropertyTypes.ts @@ -139,29 +139,43 @@ export const getMultiassetJSONSchema = (title: string): JSONSchema => ({ }, }); +// TODO: find a reliable way to share props among different Link Types to increase maintainability +// Currently not possible because of JSONSchema4 complaining +const multilinkSharedRequiredProps = ["fieldtype", "id", "url", "cached_url", "linktype"]; + export const getMultilinkJSONSchema = (title: string): JSONSchema => ({ $id: "#/multilink", title, oneOf: [ { type: "object", + required: multilinkSharedRequiredProps, properties: { - id: { + // Shared props + fieldtype: { type: "string", + enum: ["multilink"], }, - cached_url: { + id: { type: "string" }, + url: { type: "string" }, + cached_url: { type: "string" }, + target: { type: "string", enum: ["_blank", "_self"] }, + // Custom props + anchor: { type: "string", }, - anchor: { + rel: { type: "string", }, - linktype: { + title: { + type: "string", + }, + prep: { type: "string", - enum: ["story"], }, - target: { + linktype: { type: "string", - enum: ["_self", "_blank"], + enum: ["story"], }, story: { type: "object", @@ -248,29 +262,44 @@ export const getMultilinkJSONSchema = (title: string): JSONSchema => ({ }, { type: "object", + required: multilinkSharedRequiredProps, properties: { - url: { + // Shared props + fieldtype: { type: "string", + enum: ["multilink"], }, - cached_url: { - type: "string", - }, - anchor: { + id: { type: "string" }, + url: { type: "string" }, + cached_url: { type: "string" }, + target: { type: "string", enum: ["_blank", "_self"] }, + // Custom props + linktype: { type: "string", + enum: ["url"], }, - linktype: { + rel: { type: "string", - enum: ["asset", "url"], }, - target: { + title: { type: "string", - enum: ["_self", "_blank"], }, }, }, { type: "object", + required: multilinkSharedRequiredProps, properties: { + // Shared props + fieldtype: { + type: "string", + enum: ["multilink"], + }, + id: { type: "string" }, + url: { type: "string" }, + cached_url: { type: "string" }, + target: { type: "string", enum: ["_blank", "_self"] }, + // Custom props email: { type: "string", }, @@ -278,9 +307,25 @@ export const getMultilinkJSONSchema = (title: string): JSONSchema => ({ type: "string", enum: ["email"], }, - target: { + }, + }, + { + type: "object", + required: multilinkSharedRequiredProps, + properties: { + // Shared props + fieldtype: { + type: "string", + enum: ["multilink"], + }, + id: { type: "string" }, + url: { type: "string" }, + cached_url: { type: "string" }, + target: { type: "string", enum: ["_blank", "_self"] }, + // Custom props + linktype: { type: "string", - enum: ["_self", "_blank"], + enum: ["asset"], }, }, },