diff --git a/SPEC.md b/SPEC.md index f172113..878cbc7 100644 --- a/SPEC.md +++ b/SPEC.md @@ -300,6 +300,7 @@ type StoryBlock = | Definition | InfoBox | InfoPair + | AudioPlayer ``` `StoryBlock` nodes are things that can be inserted into an article body. @@ -859,9 +860,59 @@ interface InfoPair extends Parent { } ``` +### AudioPlayer +```ts +type AudioPlayer = AudioPlayerV1 | AudioPlayerV2 | AudioPlayerV3 +/** + * @sparkGenerateStoryblock true + * @support deprecated + */ +interface AudioPlayerV1 extends Node { + type: "audio-player" + version: 1 + title: string + audioUrl: string +} +/** + * @sparkGenerateStoryblock true + * @sparkInsert true + * @support supported + */ +interface AudioPlayerV2 extends Node { + type: "audio-player" + version: 2 + title: string + audioId: string + external audio: AudioSet +} +/** + * @sparkGenerateStoryblock true + * @support prerelease + */ +interface AudioPlayerV3 extends Node { + type: "audio-player" + version: 3 + title: string + audioId: string + transcriptionId: string + external audio: AudioSet + external transcription: Transcription +} +``` +```ts +/** + * Demo placeholders so the AudioPlayer versioning example compiles. + */ +interface AudioSet extends Node { + url: string +} +interface Transcription extends Node { + text: string +} +``` diff --git a/build.bash b/build.bash index f8e3fe3..4a7327d 100755 --- a/build.bash +++ b/build.bash @@ -1,8 +1,8 @@ #!/bin/bash node tools/maketypes content-tree.ts tsc -d content-tree.ts -typescript-json-schema --noExtraProps --required content-tree.ts ContentTree.full.Root > schemas/content-tree.schema.json -typescript-json-schema --noExtraProps --required content-tree.ts ContentTree.transit.Root > schemas/transit-tree.schema.json -typescript-json-schema --noExtraProps --required content-tree.ts ContentTree.transit.Body > schemas/body-tree.schema.json +typescript-json-schema --validationKeywords support sparkGenerateStoryblock --noExtraProps --required content-tree.ts ContentTree.full.Root > schemas/content-tree.schema.json +typescript-json-schema --validationKeywords support sparkGenerateStoryblock --noExtraProps --required content-tree.ts ContentTree.transit.Root > schemas/transit-tree.schema.json +typescript-json-schema --validationKeywords support sparkGenerateStoryblock --noExtraProps --required content-tree.ts ContentTree.transit.Body > schemas/body-tree.schema.json rm content-tree.ts rm content-tree.js diff --git a/content-tree.d.ts b/content-tree.d.ts index 9e3c4b1..f9944ef 100644 --- a/content-tree.d.ts +++ b/content-tree.d.ts @@ -76,7 +76,7 @@ export declare namespace ContentTree { type: "blockquote"; children: (Paragraph | Phrasing)[]; } - type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair; + type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | AudioPlayer; interface Pullquote extends Node { type: "pullquote"; text: string; @@ -366,6 +366,51 @@ export declare namespace ContentTree { title?: string; children: [Card, Card]; } + type AudioPlayer = AudioPlayerV1 | AudioPlayerV2 | AudioPlayerV3; + /** + * @sparkGenerateStoryblock true + * @support deprecated + */ + interface AudioPlayerV1 extends Node { + type: "audio-player"; + version: 1; + title: string; + audioUrl: string; + } + /** + * @sparkGenerateStoryblock true + * @sparkInsert true + * @support supported + */ + interface AudioPlayerV2 extends Node { + type: "audio-player"; + version: 2; + title: string; + audioId: string; + audio: AudioSet; + } + /** + * @sparkGenerateStoryblock true + * @support prerelease + */ + interface AudioPlayerV3 extends Node { + type: "audio-player"; + version: 3; + title: string; + audioId: string; + transcriptionId: string; + audio: AudioSet; + transcription: Transcription; + } + /** + * Demo placeholders so the AudioPlayer versioning example compiles. + */ + interface AudioSet extends Node { + url: string; + } + interface Transcription extends Node { + text: string; + } namespace full { type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width"; interface Node { @@ -444,7 +489,7 @@ export declare namespace ContentTree { type: "blockquote"; children: (Paragraph | Phrasing)[]; } - type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair; + type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | AudioPlayer; interface Pullquote extends Node { type: "pullquote"; text: string; @@ -734,6 +779,51 @@ export declare namespace ContentTree { title?: string; children: [Card, Card]; } + type AudioPlayer = AudioPlayerV1 | AudioPlayerV2 | AudioPlayerV3; + /** + * @sparkGenerateStoryblock true + * @support deprecated + */ + interface AudioPlayerV1 extends Node { + type: "audio-player"; + version: 1; + title: string; + audioUrl: string; + } + /** + * @sparkGenerateStoryblock true + * @sparkInsert true + * @support supported + */ + interface AudioPlayerV2 extends Node { + type: "audio-player"; + version: 2; + title: string; + audioId: string; + audio: AudioSet; + } + /** + * @sparkGenerateStoryblock true + * @support prerelease + */ + interface AudioPlayerV3 extends Node { + type: "audio-player"; + version: 3; + title: string; + audioId: string; + transcriptionId: string; + audio: AudioSet; + transcription: Transcription; + } + /** + * Demo placeholders so the AudioPlayer versioning example compiles. + */ + interface AudioSet extends Node { + url: string; + } + interface Transcription extends Node { + text: string; + } } namespace transit { type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width"; @@ -813,7 +903,7 @@ export declare namespace ContentTree { type: "blockquote"; children: (Paragraph | Phrasing)[]; } - type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair; + type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | AudioPlayer; interface Pullquote extends Node { type: "pullquote"; text: string; @@ -1088,6 +1178,48 @@ export declare namespace ContentTree { title?: string; children: [Card, Card]; } + type AudioPlayer = AudioPlayerV1 | AudioPlayerV2 | AudioPlayerV3; + /** + * @sparkGenerateStoryblock true + * @support deprecated + */ + interface AudioPlayerV1 extends Node { + type: "audio-player"; + version: 1; + title: string; + audioUrl: string; + } + /** + * @sparkGenerateStoryblock true + * @sparkInsert true + * @support supported + */ + interface AudioPlayerV2 extends Node { + type: "audio-player"; + version: 2; + title: string; + audioId: string; + } + /** + * @sparkGenerateStoryblock true + * @support prerelease + */ + interface AudioPlayerV3 extends Node { + type: "audio-player"; + version: 3; + title: string; + audioId: string; + transcriptionId: string; + } + /** + * Demo placeholders so the AudioPlayer versioning example compiles. + */ + interface AudioSet extends Node { + url: string; + } + interface Transcription extends Node { + text: string; + } } namespace loose { type LayoutWidth = "auto" | "in-line" | "inset-left" | "inset-right" | "full-bleed" | "full-grid" | "mid-grid" | "full-width"; @@ -1167,7 +1299,7 @@ export declare namespace ContentTree { type: "blockquote"; children: (Paragraph | Phrasing)[]; } - type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair; + type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair | AudioPlayer; interface Pullquote extends Node { type: "pullquote"; text: string; @@ -1457,5 +1589,50 @@ export declare namespace ContentTree { title?: string; children: [Card, Card]; } + type AudioPlayer = AudioPlayerV1 | AudioPlayerV2 | AudioPlayerV3; + /** + * @sparkGenerateStoryblock true + * @support deprecated + */ + interface AudioPlayerV1 extends Node { + type: "audio-player"; + version: 1; + title: string; + audioUrl: string; + } + /** + * @sparkGenerateStoryblock true + * @sparkInsert true + * @support supported + */ + interface AudioPlayerV2 extends Node { + type: "audio-player"; + version: 2; + title: string; + audioId: string; + audio?: AudioSet; + } + /** + * @sparkGenerateStoryblock true + * @support prerelease + */ + interface AudioPlayerV3 extends Node { + type: "audio-player"; + version: 3; + title: string; + audioId: string; + transcriptionId: string; + audio?: AudioSet; + transcription?: Transcription; + } + /** + * Demo placeholders so the AudioPlayer versioning example compiles. + */ + interface AudioSet extends Node { + url: string; + } + interface Transcription extends Node { + text: string; + } } } diff --git a/schemas/body-tree.schema.json b/schemas/body-tree.schema.json index c4c67ba..2a5c2d0 100644 --- a/schemas/body-tree.schema.json +++ b/schemas/body-tree.schema.json @@ -2,6 +2,97 @@ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "definitions": { + "ContentTree.transit.AudioPlayerV1": { + "additionalProperties": false, + "properties": { + "audioUrl": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 1, + "type": "number" + } + }, + "required": [ + "audioUrl", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "deprecated", + "type": "object" + }, + "ContentTree.transit.AudioPlayerV2": { + "additionalProperties": false, + "properties": { + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 2, + "type": "number" + } + }, + "required": [ + "audioId", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "supported", + "type": "object" + }, + "ContentTree.transit.AudioPlayerV3": { + "additionalProperties": false, + "properties": { + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "transcriptionId": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 3, + "type": "number" + } + }, + "required": [ + "audioId", + "title", + "transcriptionId", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "prerelease", + "type": "object" + }, "ContentTree.transit.BigNumber": { "additionalProperties": false, "properties": { @@ -146,6 +237,15 @@ }, { "$ref": "#/definitions/ContentTree.transit.InfoPair" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV1" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV2" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV3" } ] }, diff --git a/schemas/content-tree.schema.json b/schemas/content-tree.schema.json index b9d165c..17cc477 100644 --- a/schemas/content-tree.schema.json +++ b/schemas/content-tree.schema.json @@ -2,6 +2,127 @@ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "definitions": { + "ContentTree.full.AudioPlayerV1": { + "additionalProperties": false, + "properties": { + "audioUrl": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 1, + "type": "number" + } + }, + "required": [ + "audioUrl", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "deprecated", + "type": "object" + }, + "ContentTree.full.AudioPlayerV2": { + "additionalProperties": false, + "properties": { + "audio": { + "$ref": "#/definitions/ContentTree.full.AudioSet" + }, + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 2, + "type": "number" + } + }, + "required": [ + "audio", + "audioId", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "supported", + "type": "object" + }, + "ContentTree.full.AudioPlayerV3": { + "additionalProperties": false, + "properties": { + "audio": { + "$ref": "#/definitions/ContentTree.full.AudioSet" + }, + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "transcription": { + "$ref": "#/definitions/ContentTree.full.Transcription" + }, + "transcriptionId": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 3, + "type": "number" + } + }, + "required": [ + "audio", + "audioId", + "title", + "transcription", + "transcriptionId", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "prerelease", + "type": "object" + }, + "ContentTree.full.AudioSet": { + "additionalProperties": false, + "description": "Demo placeholders so the AudioPlayer versioning example compiles.", + "properties": { + "data": {}, + "type": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "required": [ + "type", + "url" + ], + "type": "object" + }, "ContentTree.full.BigNumber": { "additionalProperties": false, "properties": { @@ -171,6 +292,15 @@ }, { "$ref": "#/definitions/ContentTree.full.InfoPair" + }, + { + "$ref": "#/definitions/ContentTree.full.AudioPlayerV1" + }, + { + "$ref": "#/definitions/ContentTree.full.AudioPlayerV2" + }, + { + "$ref": "#/definitions/ContentTree.full.AudioPlayerV3" } ] }, @@ -2223,6 +2353,23 @@ ], "type": "object" }, + "ContentTree.full.Transcription": { + "additionalProperties": false, + "properties": { + "data": {}, + "text": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "text", + "type" + ], + "type": "object" + }, "ContentTree.full.Tweet": { "additionalProperties": false, "properties": { diff --git a/schemas/transit-tree.schema.json b/schemas/transit-tree.schema.json index 114cc59..d8e80d3 100644 --- a/schemas/transit-tree.schema.json +++ b/schemas/transit-tree.schema.json @@ -2,6 +2,97 @@ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "definitions": { + "ContentTree.transit.AudioPlayerV1": { + "additionalProperties": false, + "properties": { + "audioUrl": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 1, + "type": "number" + } + }, + "required": [ + "audioUrl", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "deprecated", + "type": "object" + }, + "ContentTree.transit.AudioPlayerV2": { + "additionalProperties": false, + "properties": { + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 2, + "type": "number" + } + }, + "required": [ + "audioId", + "title", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "supported", + "type": "object" + }, + "ContentTree.transit.AudioPlayerV3": { + "additionalProperties": false, + "properties": { + "audioId": { + "type": "string" + }, + "data": {}, + "title": { + "type": "string" + }, + "transcriptionId": { + "type": "string" + }, + "type": { + "const": "audio-player", + "type": "string" + }, + "version": { + "const": 3, + "type": "number" + } + }, + "required": [ + "audioId", + "title", + "transcriptionId", + "type", + "version" + ], + "sparkGenerateStoryblock": true, + "support": "prerelease", + "type": "object" + }, "ContentTree.transit.BigNumber": { "additionalProperties": false, "properties": { @@ -171,6 +262,15 @@ }, { "$ref": "#/definitions/ContentTree.transit.InfoPair" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV1" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV2" + }, + { + "$ref": "#/definitions/ContentTree.transit.AudioPlayerV3" } ] },