MapComplete/src/UI/Studio/configMeta.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-06-16 02:36:11 +02:00
import { JsonSchema, JsonSchemaType } from "./jsonSchema"
export interface ConfigMeta {
path: string[]
type: JsonSchemaType | JsonSchema[]
/**
* All fields are lowercase, as they should be case-insensitive
*/
2023-06-16 02:36:11 +02:00
hints: {
group?: string
typehint?: string
typehelper?: string
/**
* If multiple subcategories can be chosen
*/
types?: string
2023-06-16 02:36:11 +02:00
question?: string
iftrue?: string
iffalse?: string
2023-06-16 02:36:11 +02:00
ifunset?: string
inline?: string
default?: string
typesdefault?: string
suggestions?: []
title?: string
multianswer?: "true" | string
2023-06-16 02:36:11 +02:00
}
required: boolean
description: string
}
2023-09-15 01:16:33 +02:00
export class ConfigMetaUtils {
static isTranslation(configMeta: ConfigMeta) {
/* {
"$ref": "#/definitions/Record<string,string>"
},
{
"type": "string"
}*/
if (!configMeta.type) {
return false
}
if (Array.isArray(configMeta.type)) {
return configMeta.type.some((t) => t["$ref"] === "#/definitions/Record<string,string>")
} else {
return configMeta.type["$ref"] === "#/definitions/Record<string,string>"
}
}
}