diff --git a/lib/config/builder/index.test.ts b/lib/config/builder/index.test.ts
index a3862ce..1c17282 100644
--- a/lib/config/builder/index.test.ts
+++ b/lib/config/builder/index.test.ts
@@ -24,7 +24,6 @@ describe("builder tests", () => {
placeholder: null,
pattern: null,
patternDescription: null,
- textarea: null,
}),
}).build();
expect(JSON.stringify(bitcoinPropertiesBuilt)).toEqual(
@@ -39,8 +38,7 @@ describe("builder tests", () => {
"masked": true,
"placeholder": null,
"pattern": null,
- "patternDescription": null,
- "textarea": null
+ "patternDescription": null
}}`
.replaceAll("\n", " ")
.replaceAll(/\s{2,}/g, "")
diff --git a/lib/config/builder/list.ts b/lib/config/builder/list.ts
index fd986a1..eea866a 100644
--- a/lib/config/builder/list.ts
+++ b/lib/config/builder/list.ts
@@ -38,7 +38,6 @@ export class List extends IBuilder {
placeholder: string | null;
pattern: string | null;
patternDescription: string | null;
- textarea: boolean | null;
};
}
>(a: A) {
diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts
index ad4629e..4c41efc 100644
--- a/lib/config/builder/value.ts
+++ b/lib/config/builder/value.ts
@@ -8,6 +8,7 @@ import {
ValueSpecList,
ValueSpecNumber,
ValueSpecString,
+ ValueSpecTextarea,
} from "../config-types";
import { guardAll } from "../../util";
@@ -66,7 +67,6 @@ export class Value extends IBuilder {
placeholder: string | null;
pattern: string | null;
patternDescription: string | null;
- textarea: boolean | null;
}
>(a: A) {
return new Value({
@@ -74,6 +74,20 @@ export class Value extends IBuilder {
...a,
} as ValueSpecString);
}
+ static textarea<
+ A extends {
+ name: string;
+ description: string | null;
+ warning: string | null;
+ nullable: boolean;
+ placeholder: string | null;
+ }
+ >(a: A) {
+ return new Value({
+ type: "textarea" as const,
+ ...a,
+ } as ValueSpecTextarea);
+ }
static number<
A extends {
name: string;
diff --git a/lib/config/config-types.ts b/lib/config/config-types.ts
index ae1011d..c4b530a 100644
--- a/lib/config/config-types.ts
+++ b/lib/config/config-types.ts
@@ -2,6 +2,7 @@ export type InputSpec = Record;
export type ValueType =
| "string"
+ | "textarea"
| "number"
| "boolean"
| "select"
@@ -16,6 +17,8 @@ export type ValueSpec = ValueSpecOf;
export type ValueSpecOf = T extends "string"
? ValueSpecString
: T extends "number"
+ ? ValueSpecTextarea
+ : T extends "textarea"
? ValueSpecNumber
: T extends "boolean"
? ValueSpecBoolean
@@ -37,7 +40,12 @@ export interface ValueSpecString extends ListValueSpecString, WithStandalone {
type: "string";
default: null | DefaultString;
nullable: boolean;
- textarea: null | boolean;
+}
+
+export interface ValueSpecTextarea extends WithStandalone {
+ type: "textarea";
+ placeholder: null | string;
+ nullable: boolean;
}
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
diff --git a/lib/test/makeOutput.ts b/lib/test/makeOutput.ts
index f3fc061..756ff56 100644
--- a/lib/test/makeOutput.ts
+++ b/lib/test/makeOutput.ts
@@ -76,6 +76,18 @@ writeConvertedFile(
copyable: true,
masked: true,
},
+ bio: {
+ type: "string",
+ nullable: false,
+ name: "Username",
+ description: "The username for connecting to Bitcoin over RPC.",
+ default: "bitcoin",
+ masked: true,
+ pattern: "^[a-zA-Z0-9_]+$",
+ "pattern-description":
+ "Must be alphanumeric (can contain underscore).",
+ textarea: true,
+ },
advanced: {
type: "object",
name: "Advanced",
diff --git a/lib/util/propertiesMatcher.ts b/lib/util/propertiesMatcher.ts
index c84b09b..97bfb7c 100644
--- a/lib/util/propertiesMatcher.ts
+++ b/lib/util/propertiesMatcher.ts
@@ -11,6 +11,7 @@ const { string, some, object, dictionary, unknown, number, literals, boolean } =
type TypeBoolean = "boolean";
type TypeString = "string";
+type TypeTextarea = "textarea";
type TypeNumber = "number";
type TypeObject = "object";
type TypeList = "list";
@@ -33,6 +34,10 @@ type GuardNumber =
type GuardString =
A extends { type: TypeString } ? GuardDefaultNullable :
unknown
+// prettier-ignore
+type GuardTextarea =
+ A extends { type: TypeTextarea } ? GuardDefaultNullable :
+ unknown
// prettier-ignore
type GuardBoolean =
@@ -76,6 +81,7 @@ type GuardUnion =
type _ = T;
export type GuardAll = GuardNumber &
GuardString &
+ GuardTextarea &
GuardBoolean &
GuardObject &
GuardList &
@@ -232,6 +238,9 @@ export function guardAll(
case "string":
return defaultNullable(string, value) as any;
+ case "textarea":
+ return defaultNullable(string, value) as any;
+
case "number":
return defaultNullable(
withIntegral(withRange(value), value),
@@ -267,6 +276,7 @@ export function guardAll(
) as any;
}
return unknown as any;
+
case "multiselect":
if (matchValues.test(value)) {
const rangeValidate =
@@ -282,6 +292,7 @@ export function guardAll(
) as any;
}
return unknown as any;
+
case "union":
if (matchUnion.test(value)) {
return some(
diff --git a/scripts/oldSpecToBuilder.ts b/scripts/oldSpecToBuilder.ts
index 603e04d..a67ae88 100644
--- a/scripts/oldSpecToBuilder.ts
+++ b/scripts/oldSpecToBuilder.ts
@@ -52,6 +52,19 @@ export default async function makeFileContent(
function convertValueSpec(value: any): string {
switch (value.type) {
case "string": {
+ if (value.textarea) {
+ return `Value.textarea(${JSON.stringify(
+ {
+ name: value.name || null,
+ description: value.description || null,
+ warning: value.warning || null,
+ nullable: value.nullable || false,
+ placeholder: value.placeholder || null,
+ },
+ null,
+ 2
+ )})`;
+ }
return `Value.string(${JSON.stringify(
{
name: value.name || null,
@@ -63,7 +76,6 @@ export default async function makeFileContent(
placeholder: value.placeholder || null,
pattern: value.pattern || null,
patternDescription: value["pattern-description"] || null,
- textarea: value.textarea || null,
},
null,
2