Skip to content

Commit

Permalink
feat: add typings and interfaces for Overlay Specification v1.0.0
Browse files Browse the repository at this point in the history
related #1246
  • Loading branch information
jeremyfiel committed Oct 17, 2024
1 parent 6522bc0 commit f401f1e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/core/src/types/overlay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { type NodeType, NormalizedScalarSchema, listOf } from '.';

Check failure on line 1 in packages/core/src/types/overlay.ts

View workflow job for this annotation

GitHub Actions / code-style-check

Import "NormalizedScalarSchema" is only used as types

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<string, NodeType | NormalizedScalarSchema> = {
Root,
Info,
Extends,
Actions,
Action,
};
19 changes: 19 additions & 0 deletions packages/core/src/typings/overlay.ts
Original file line number Diff line number Diff line change
@@ -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+(-.+)?$/;

0 comments on commit f401f1e

Please sign in to comment.