rename things and add new value spec types

This commit is contained in:
Matt Hill
2023-04-20 12:40:05 -06:00
parent e279711f8e
commit ce1c383944
11 changed files with 269 additions and 145 deletions

View File

@@ -1,7 +1,6 @@
import camelCase from "lodash/camelCase";
import * as fs from "fs";
import { string } from "ts-matches";
import { unionSelectKey } from "../lib/config/configTypes";
export async function writeConvertedFile(
file: string,
@@ -65,7 +64,7 @@ export default async function makeFileContent(
2,
)})`;
}
return `Value.string(${JSON.stringify(
return `Value.text(${JSON.stringify(
{
name: value.name || null,
default: value.default || null,
@@ -74,8 +73,11 @@ export default async function makeFileContent(
required: !(value.nullable || false),
masked: value.masked || false,
placeholder: value.placeholder || null,
pattern: value.pattern || null,
patternDescription: value["pattern-description"] || null,
patterns: value.pattern ?
[{ regex: value.pattern, description: value["pattern-description"] }] :
[],
minLength: null,
maxLength: null,
},
null,
2,
@@ -89,8 +91,10 @@ export default async function makeFileContent(
description: value.description || null,
warning: value.warning || null,
required: !(value.nullable || false),
range: value.range || null,
integral: value.integral || false,
min: null,
max: null,
step: null,
integer: value.integral || false,
units: value.units || null,
placeholder: value.placeholder || null,
},
@@ -99,7 +103,7 @@ export default async function makeFileContent(
)})`;
}
case "boolean": {
return `Value.boolean(${JSON.stringify(
return `Value.toggle(${JSON.stringify(
{
name: value.name || null,
default: value.default || false,
@@ -172,12 +176,11 @@ export default async function makeFileContent(
function convertList(value: any) {
switch (value.subtype) {
case "string": {
return `List.${
value?.spec?.textarea === true ? "textarea" : "string"
}(${JSON.stringify(
return `List.text(${JSON.stringify(
{
name: value.name || null,
range: value.range || null,
minLength: null,
maxLength: null,
default: value.default || null,
description: value.description || null,
warning: value.warning || null,
@@ -187,15 +190,19 @@ export default async function makeFileContent(
)}, ${JSON.stringify({
masked: value?.spec?.masked || false,
placeholder: value?.spec?.placeholder || null,
pattern: value?.spec?.pattern || null,
patternDescription: value?.spec?.["pattern-description"] || null,
patterns: value?.spec?.pattern ?
[{ regex: value.spec.pattern, description: value?.spec?.["pattern-description"] }] :
[],
minLength: null,
maxLength: null,
})})`;
}
case "number": {
return `List.number(${JSON.stringify(
{
name: value.name || null,
range: value.range || null,
minLength: null,
maxLength: null,
default: value.default || null,
description: value.description || null,
warning: value.warning || null,
@@ -203,8 +210,9 @@ export default async function makeFileContent(
null,
2,
)}, ${JSON.stringify({
range: value?.spec?.range || null,
integral: value?.spec?.integral || false,
integer: value?.spec?.integral || false,
min: null,
max: null,
units: value?.spec?.units || null,
placeholder: value?.spec?.placeholder || null,
})})`;
@@ -225,7 +233,8 @@ export default async function makeFileContent(
return `Value.multiselect(${JSON.stringify(
{
name: value.name || null,
range: value.range || null,
minLength: null,
maxLength: null,
default: value.default || null,
description: value.description || null,
warning: value.warning || null,
@@ -242,7 +251,8 @@ export default async function makeFileContent(
);
return `List.obj({
name: ${JSON.stringify(value.name || null)},
range: ${JSON.stringify(value.range || null)},
minLength: ${JSON.stringify(null)},
maxLength: ${JSON.stringify(null)},
default: ${JSON.stringify(value.default || null)},
description: ${JSON.stringify(value.description || null)},
warning: ${JSON.stringify(value.warning || null)},
@@ -284,7 +294,8 @@ export default async function makeFileContent(
);
return `List.obj({
name:${JSON.stringify(value.name || null)},
range:${JSON.stringify(value.range || null)},
minLength:${JSON.stringify(null)},
maxLength:${JSON.stringify(null)},
default: [],
description: ${JSON.stringify(value.description || null)},
warning: ${JSON.stringify(value.warning || null)},