diff --git a/packages/core/src/types/overlay.ts b/packages/core/src/types/overlay.ts new file mode 100644 index 000000000..26decac9f --- /dev/null +++ b/packages/core/src/types/overlay.ts @@ -0,0 +1,46 @@ +import { type NodeType, NormalizedScalarSchema, listOf } from '.'; + +const Root: NodeType = { + properties: { + overlay: { type: 'string' }, + info: 'Info', + extends: { type: 'string' }, + actions: listOf('action'), + }, + required: ['overlay', 'info', 'actions'], + extensionsPrefix: 'x-', +}; + +const Info: NodeType = { + properties: { + title: { type: 'string' }, + version: { type: 'string' }, + }, + required: ['title', 'version'], + extensionsPrefix: 'x-', +}; + +const Extends: NormalizedScalarSchema = { + type: 'string', + resolvable: true, +}; + +const Actions: NodeType = listOf('Action'); +const Action: NodeType = { + properties: { + target: { type: 'string' }, + description: { type: 'string' }, + update: {}, // any + remove: { type: 'boolean' }, + }, + required: ['target'], + extensionsPrefix: 'x-', +}; + +export const OverlayTypes: Record = { + Root, + Info, + Extends, + Actions, + Action, +}; diff --git a/packages/core/src/typings/overlay.ts b/packages/core/src/typings/overlay.ts new file mode 100644 index 000000000..908480b18 --- /dev/null +++ b/packages/core/src/typings/overlay.ts @@ -0,0 +1,19 @@ +export interface InfoObject { + title: string; + version: string; +} + +export interface ActionObject { + target: string; + description?: string; + update?: any; + remove?: boolean; +} +export interface OverlayDefinition { + overlay: '1.0.0'; + info: InfoObject; + extends?: string; + actions: ActionObject[]; +} + +export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;