mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
Trying code editor (#1173)
Implement hidden dev service packaging tools. Co-authored-by: Drew Ansbacher <drew.ansbacher@spiredigital.com> Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
export interface ConfigSpec { [key: string]: ValueSpec }
|
||||
export interface ConfigSpec {
|
||||
[key: string]: ValueSpec
|
||||
}
|
||||
|
||||
export type ValueType = 'string' | 'number' | 'boolean' | 'enum' | 'list' | 'object' | 'pointer' | 'union'
|
||||
export type ValueType =
|
||||
| 'string'
|
||||
| 'number'
|
||||
| 'boolean'
|
||||
| 'enum'
|
||||
| 'list'
|
||||
| 'object'
|
||||
| 'pointer'
|
||||
| 'union'
|
||||
export type ValueSpec = ValueSpecOf<ValueType>
|
||||
|
||||
// core spec types. These types provide the metadata for performing validations
|
||||
export type ValueSpecOf<T extends ValueType> =
|
||||
T extends 'string' ? ValueSpecString :
|
||||
T extends 'number' ? ValueSpecNumber :
|
||||
T extends 'boolean' ? ValueSpecBoolean :
|
||||
T extends 'enum' ? ValueSpecEnum :
|
||||
T extends 'list' ? ValueSpecList :
|
||||
T extends 'object' ? ValueSpecObject :
|
||||
T extends 'pointer' ? ValueSpecPointer :
|
||||
T extends 'union' ? ValueSpecUnion :
|
||||
never
|
||||
export type ValueSpecOf<T extends ValueType> = T extends 'string'
|
||||
? ValueSpecString
|
||||
: T extends 'number'
|
||||
? ValueSpecNumber
|
||||
: T extends 'boolean'
|
||||
? ValueSpecBoolean
|
||||
: T extends 'enum'
|
||||
? ValueSpecEnum
|
||||
: T extends 'list'
|
||||
? ValueSpecList
|
||||
: T extends 'object'
|
||||
? ValueSpecObject
|
||||
: T extends 'pointer'
|
||||
? ValueSpecPointer
|
||||
: T extends 'union'
|
||||
? ValueSpecUnion
|
||||
: never
|
||||
|
||||
export interface ValueSpecString extends ListValueSpecString, WithStandalone {
|
||||
type: 'string'
|
||||
@@ -62,20 +79,30 @@ export interface WithStandalone {
|
||||
}
|
||||
|
||||
// no lists of booleans, lists, pointers
|
||||
export type ListValueSpecType = 'string' | 'number' | 'enum' | 'object' | 'union'
|
||||
export type ListValueSpecType =
|
||||
| 'string'
|
||||
| 'number'
|
||||
| 'enum'
|
||||
| 'object'
|
||||
| 'union'
|
||||
|
||||
// represents a spec for the values of a list
|
||||
export type ListValueSpecOf<T extends ListValueSpecType> =
|
||||
T extends 'string' ? ListValueSpecString :
|
||||
T extends 'number' ? ListValueSpecNumber :
|
||||
T extends 'enum' ? ListValueSpecEnum :
|
||||
T extends 'object' ? ListValueSpecObject :
|
||||
T extends 'union' ? ListValueSpecUnion :
|
||||
never
|
||||
export type ListValueSpecOf<T extends ListValueSpecType> = T extends 'string'
|
||||
? ListValueSpecString
|
||||
: T extends 'number'
|
||||
? ListValueSpecNumber
|
||||
: T extends 'enum'
|
||||
? ListValueSpecEnum
|
||||
: T extends 'object'
|
||||
? ListValueSpecObject
|
||||
: T extends 'union'
|
||||
? ListValueSpecUnion
|
||||
: never
|
||||
|
||||
// represents a spec for a list
|
||||
export type ValueSpecList = ValueSpecListOf<ListValueSpecType>
|
||||
export interface ValueSpecListOf<T extends ListValueSpecType> extends WithStandalone {
|
||||
export interface ValueSpecListOf<T extends ListValueSpecType>
|
||||
extends WithStandalone {
|
||||
type: 'list'
|
||||
subtype: T
|
||||
spec: ListValueSpecOf<T>
|
||||
@@ -84,7 +111,10 @@ export interface ValueSpecListOf<T extends ListValueSpecType> extends WithStanda
|
||||
}
|
||||
|
||||
// sometimes the type checker needs just a little bit of help
|
||||
export function isValueSpecListOf<S extends ListValueSpecType> (t: ValueSpecList, s: S): t is ValueSpecListOf<S> {
|
||||
export function isValueSpecListOf<S extends ListValueSpecType>(
|
||||
t: ValueSpecList,
|
||||
s: S,
|
||||
): t is ValueSpecListOf<S> {
|
||||
return t.subtype === s
|
||||
}
|
||||
|
||||
@@ -105,7 +135,6 @@ export interface ListValueSpecNumber {
|
||||
|
||||
export interface ListValueSpecEnum {
|
||||
values: string[]
|
||||
'values-set'?: Set<string>
|
||||
'value-names': { [value: string]: string }
|
||||
}
|
||||
|
||||
@@ -129,9 +158,10 @@ export interface UnionTagSpec {
|
||||
id: string // The name of the field containing one of the union variants
|
||||
name: string
|
||||
description?: string
|
||||
'variant-names': { // the name of each variant
|
||||
'variant-names': {
|
||||
// the name of each variant
|
||||
[variant: string]: string
|
||||
}
|
||||
}
|
||||
|
||||
export type DefaultString = string | { charset: string, len: number }
|
||||
export type DefaultString = string | { charset: string; len: number }
|
||||
|
||||
Reference in New Issue
Block a user