From 3a6f7e9dc55aa8a70a0c7aa86ae95412bcd8a3e2 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 26 Nov 2021 23:04:15 +0100 Subject: [PATCH] Add types for backend response --- types/PEP440.d.ts | 14 ++++++++++++++ types/flaschengeist.d.ts | 9 +++++++++ types/index.d.ts | 1 + types/plugin.d.ts | 15 +-------------- 4 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 types/PEP440.d.ts diff --git a/types/PEP440.d.ts b/types/PEP440.d.ts new file mode 100644 index 0000000..f5c0a18 --- /dev/null +++ b/types/PEP440.d.ts @@ -0,0 +1,14 @@ +/* This is some sort of PEP440 subset */ +type Join = T extends [] + ? '' + : T extends [string | number | boolean | bigint] + ? `${T[0]}` + : T extends [string | number | boolean | bigint, ...infer U] + ? `${T[0]}${D}${Join}` + : string; +type BaseVersion = Join<[number, number], '.'> | Join<[number, number, number], '.'>; +type PreRelease = Join<[['a' | 'b' | 'rc'], number], '.'>; +type PRVersion = BaseVersion | `${BaseVersion}${PreRelease}`; + +/** A PEP440 subset used to describe backend module versions */ +declare type PEP440Version = PRVersion | `${PRVersion}.dev${number}`; \ No newline at end of file diff --git a/types/flaschengeist.d.ts b/types/flaschengeist.d.ts index 9230e64..4133763 100644 --- a/types/flaschengeist.d.ts +++ b/types/flaschengeist.d.ts @@ -1,8 +1,17 @@ +/// /** * Types used for communicating with the API */ declare namespace FG { + interface BackendPlugin { + permissions: string[]; + version: PEP440Version; + } + interface Backend { + plugins: {[key: string]: BackendPlugin}; + version: PEP440Version; + } interface Notification { id: number; plugin: string; diff --git a/types/index.d.ts b/types/index.d.ts index b9624c7..b79cf34 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,4 @@ /// +/// export * from './plugin'; diff --git a/types/plugin.d.ts b/types/plugin.d.ts index ec54211..e66a8f1 100644 --- a/types/plugin.d.ts +++ b/types/plugin.d.ts @@ -1,3 +1,4 @@ +/// import type { RouteLocationRaw, RouteRecordRaw, RouteRecordName } from 'vue-router'; import type { Component } from '@vue/runtime-core'; @@ -6,20 +7,6 @@ import type { Component } from '@vue/runtime-core'; * + Additional types for plugin interaction with the core */ -/* This is some sort of PEP440 subset */ -type Join = T extends [] - ? '' - : T extends [string | number | boolean | bigint] - ? `${T[0]}` - : T extends [string | number | boolean | bigint, ...infer U] - ? `${T[0]}${D}${Join}` - : string; -type BaseVersion = Join<[number, number], '.'> | Join<[number, number, number], '.'>; -type PreRelease = Join<[['a' | 'b' | 'rc'], number], '.'>; -type PRVersion = BaseVersion | `${BaseVersion}${PreRelease}`; -/** A PEP440 subset used to describe backend module versions */ -export type PEP440Version = PRVersion | `${PRVersion}.dev${number}`; - export namespace FG_Plugin { /** * Interface defining a Flaschengeist plugin