@superblocksteam/util 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-types.d.ts +9 -0
- package/dist/data-types.js +31 -0
- package/dist/generate-component-types.d.ts +2 -1
- package/dist/generate-component-types.js +7 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/resource-configs.d.ts +0 -1
- package/dist/resource-configs.js +1 -16
- package/dist/types.d.ts +13 -6
- package/dist/validation.js +21 -10
- package/package.json +1 -1
- package/src/data-types.ts +39 -0
- package/src/generate-component-types.ts +10 -9
- package/src/index.ts +1 -1
- package/src/resource-configs.ts +0 -19
- package/src/types.ts +29 -6
- package/src/validation.ts +21 -10
- package/dist/input-types.d.ts +0 -9
- package/dist/input-types.js +0 -26
- package/src/input-types.ts +0 -34
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const supportedDataTypes: readonly ["string", "number", "boolean", "any"];
|
|
2
|
+
export type DataType = (typeof supportedDataTypes)[number];
|
|
3
|
+
interface TypeInfo {
|
|
4
|
+
tsType: string;
|
|
5
|
+
prompt: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const dataTypeDefinions: Record<DataType, TypeInfo>;
|
|
8
|
+
export declare function isValidDataType(input: string): input is DataType;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidDataType = exports.dataTypeDefinions = exports.supportedDataTypes = void 0;
|
|
4
|
+
exports.supportedDataTypes = [
|
|
5
|
+
"string",
|
|
6
|
+
"number",
|
|
7
|
+
"boolean",
|
|
8
|
+
"any",
|
|
9
|
+
];
|
|
10
|
+
exports.dataTypeDefinions = {
|
|
11
|
+
string: {
|
|
12
|
+
tsType: "string",
|
|
13
|
+
prompt: "string",
|
|
14
|
+
},
|
|
15
|
+
number: {
|
|
16
|
+
tsType: "number",
|
|
17
|
+
prompt: "number",
|
|
18
|
+
},
|
|
19
|
+
boolean: {
|
|
20
|
+
tsType: "boolean",
|
|
21
|
+
prompt: "boolean",
|
|
22
|
+
},
|
|
23
|
+
any: {
|
|
24
|
+
tsType: "any",
|
|
25
|
+
prompt: "any (raw js expression)",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
function isValidDataType(input) {
|
|
29
|
+
return Object.prototype.hasOwnProperty.call(exports.dataTypeDefinions, input);
|
|
30
|
+
}
|
|
31
|
+
exports.isValidDataType = isValidDataType;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ComponentConfig } from "./types";
|
|
2
|
+
export declare function generateComponentTypesFile(config: ComponentConfig): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateComponentTypesFile = void 0;
|
|
4
|
-
const
|
|
4
|
+
const data_types_1 = require("./data-types");
|
|
5
5
|
const indent = (str, spaces) => {
|
|
6
6
|
const spacesString = " ".repeat(spaces);
|
|
7
7
|
return str
|
|
@@ -10,21 +10,21 @@ const indent = (str, spaces) => {
|
|
|
10
10
|
.join("\n");
|
|
11
11
|
};
|
|
12
12
|
function renderInputTypeAsTS(name, type, trailingChars, indentSpaces) {
|
|
13
|
-
return indent(`${name}: ${
|
|
13
|
+
return indent(`${name}: ${data_types_1.dataTypeDefinions[type].tsType}${trailingChars}`, indentSpaces);
|
|
14
14
|
}
|
|
15
15
|
function generateComponentTypesFile(config) {
|
|
16
16
|
var _a, _b;
|
|
17
|
-
const
|
|
18
|
-
const eventHandlers = (_b = config.
|
|
17
|
+
const properties = (_a = config.properties) !== null && _a !== void 0 ? _a : [];
|
|
18
|
+
const eventHandlers = (_b = config.events) !== null && _b !== void 0 ? _b : [];
|
|
19
19
|
return `// WARNING: This file is automatically generated and managed by Superblocks CLI and should not be edited manually.
|
|
20
20
|
// Use the \`superblocks components watch\` command to regenerate this file from its source in config.ts
|
|
21
21
|
|
|
22
|
-
// All
|
|
22
|
+
// All properties of your component are defined here.
|
|
23
23
|
// These are the properties which are surfaced in the Superblocks properties panel
|
|
24
24
|
// and can be referenced throughout your Superblocks Application
|
|
25
25
|
export interface Props {
|
|
26
|
-
${
|
|
27
|
-
.map((v) => renderInputTypeAsTS(v.path, v.
|
|
26
|
+
${properties
|
|
27
|
+
.map((v) => renderInputTypeAsTS(v.path, v.dataType, ";", 2) + "\n")
|
|
28
28
|
.join("")}}
|
|
29
29
|
|
|
30
30
|
export interface EventTriggers {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,5 +6,5 @@ tslib_1.__exportStar(require("./component-configs"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./file-uploader"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./login"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./resource-configs"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./
|
|
9
|
+
tslib_1.__exportStar(require("./data-types"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -28,7 +28,6 @@ export type SuperblocksConfig = SuperblocksMonorepoConfig | SuperblocksApplicati
|
|
|
28
28
|
* @param checkParentDir Whether to recursively check the parent directory for a Superblocks config file
|
|
29
29
|
*/
|
|
30
30
|
export declare function getSuperblocksMonorepoConfigJson(checkParentDir?: boolean, pathPrefix?: string): Promise<[SuperblocksMonorepoConfig, string]>;
|
|
31
|
-
export declare function updatedMonorepoConfig(version: string): Promise<void>;
|
|
32
31
|
export declare function getSuperblocksApplicationConfigJson(): Promise<SuperblocksApplicationConfig>;
|
|
33
32
|
export declare function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig>;
|
|
34
33
|
export declare function getSuperblocksResourceConfigIfExists(): Promise<SuperblocksResourceConfig | undefined>;
|
package/dist/resource-configs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigJson = exports.
|
|
3
|
+
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
6
6
|
const constants_1 = require("./constants");
|
|
@@ -35,21 +35,6 @@ async function getSuperblocksMonorepoConfigJson(checkParentDir = false, pathPref
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.getSuperblocksMonorepoConfigJson = getSuperblocksMonorepoConfigJson;
|
|
38
|
-
async function updatedMonorepoConfig(version) {
|
|
39
|
-
try {
|
|
40
|
-
const [previousConfig, configPath] = await getSuperblocksMonorepoConfigJson(true);
|
|
41
|
-
if (previousConfig.metadata.cliVersion !== version) {
|
|
42
|
-
const newConfig = JSON.parse(JSON.stringify(previousConfig));
|
|
43
|
-
newConfig.metadata.cliVersion = version;
|
|
44
|
-
// update superblocks.json file
|
|
45
|
-
await fs.writeFile(configPath, JSON.stringify(updatedMonorepoConfig, null, 2));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// This might fail for a brand-new project folder, which is deliberately ignored
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.updatedMonorepoConfig = updatedMonorepoConfig;
|
|
53
38
|
async function getSuperblocksApplicationConfigJson() {
|
|
54
39
|
let superblocksConfig;
|
|
55
40
|
try {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type UUID } from "node:crypto";
|
|
3
|
-
import { type
|
|
4
|
-
|
|
3
|
+
import { type DataType } from "./data-types";
|
|
4
|
+
interface PropertiesPanelDisplay {
|
|
5
|
+
controlType: "text" | "js-expr" | "switch";
|
|
5
6
|
label: string;
|
|
6
|
-
path: string;
|
|
7
|
-
inputType: InputType;
|
|
8
7
|
placeholder?: string;
|
|
8
|
+
exampleData?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Property {
|
|
11
|
+
path: string;
|
|
12
|
+
dataType: DataType;
|
|
13
|
+
propertiesPanelDisplay?: PropertiesPanelDisplay;
|
|
14
|
+
description?: string;
|
|
9
15
|
}
|
|
10
16
|
export interface ComponentConfig {
|
|
11
17
|
id: UUID;
|
|
12
18
|
name: string;
|
|
13
19
|
displayName: string;
|
|
14
20
|
componentPath: string;
|
|
15
|
-
|
|
21
|
+
properties: Property[];
|
|
16
22
|
/**
|
|
17
23
|
* Example: [{
|
|
18
24
|
* label: "On Click",
|
|
19
25
|
* path: "onClick",
|
|
20
26
|
* }]
|
|
21
27
|
*/
|
|
22
|
-
|
|
28
|
+
events: Array<{
|
|
23
29
|
label: string;
|
|
24
30
|
path: string;
|
|
25
31
|
}>;
|
|
26
32
|
}
|
|
33
|
+
export {};
|
package/dist/validation.js
CHANGED
|
@@ -12,13 +12,13 @@ const componentSchema = {
|
|
|
12
12
|
name: { type: "string" },
|
|
13
13
|
displayName: { type: "string" },
|
|
14
14
|
componentPath: { type: "string" },
|
|
15
|
-
|
|
15
|
+
properties: {
|
|
16
16
|
type: "array",
|
|
17
17
|
items: {
|
|
18
|
-
$ref: "#/definitions/
|
|
18
|
+
$ref: "#/definitions/Property",
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
events: {
|
|
22
22
|
type: "array",
|
|
23
23
|
items: {
|
|
24
24
|
$ref: "#/definitions/EventHandler",
|
|
@@ -30,21 +30,32 @@ const componentSchema = {
|
|
|
30
30
|
"name",
|
|
31
31
|
"displayName",
|
|
32
32
|
"componentPath",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"properties",
|
|
34
|
+
"events",
|
|
35
35
|
],
|
|
36
36
|
additionalProperties: false,
|
|
37
37
|
definitions: {
|
|
38
|
-
|
|
38
|
+
Property: {
|
|
39
39
|
properties: {
|
|
40
|
-
label: { type: "string" },
|
|
41
40
|
path: { type: "string" },
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
dataType: { enum: ["number", "boolean", "string", "any"] },
|
|
42
|
+
propertiesPanelDisplay: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
label: { type: "string" },
|
|
46
|
+
controlType: { enum: ["text", "js-expr", "switch"] },
|
|
47
|
+
defaultValue: { type: "string" },
|
|
48
|
+
placeholder: { type: "string" },
|
|
49
|
+
exampleData: { type: "string" },
|
|
50
|
+
},
|
|
51
|
+
required: ["controlType", "label"],
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
},
|
|
54
|
+
description: { type: "string" },
|
|
44
55
|
},
|
|
45
56
|
type: "object",
|
|
46
57
|
additionalProperties: false,
|
|
47
|
-
required: ["
|
|
58
|
+
required: ["path", "dataType"],
|
|
48
59
|
},
|
|
49
60
|
EventHandler: {
|
|
50
61
|
properties: {
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const supportedDataTypes = [
|
|
2
|
+
"string",
|
|
3
|
+
"number",
|
|
4
|
+
"boolean",
|
|
5
|
+
"any",
|
|
6
|
+
] as const;
|
|
7
|
+
|
|
8
|
+
export type DataType = (typeof supportedDataTypes)[number];
|
|
9
|
+
|
|
10
|
+
interface TypeInfo {
|
|
11
|
+
tsType: string;
|
|
12
|
+
prompt: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const dataTypeDefinions: Record<DataType, TypeInfo> = {
|
|
16
|
+
string: {
|
|
17
|
+
tsType: "string",
|
|
18
|
+
prompt: "string",
|
|
19
|
+
},
|
|
20
|
+
number: {
|
|
21
|
+
tsType: "number",
|
|
22
|
+
prompt: "number",
|
|
23
|
+
},
|
|
24
|
+
boolean: {
|
|
25
|
+
tsType: "boolean",
|
|
26
|
+
prompt: "boolean",
|
|
27
|
+
},
|
|
28
|
+
any: {
|
|
29
|
+
tsType: "any",
|
|
30
|
+
prompt: "any (raw js expression)",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function isValidDataType(input: string): input is DataType {
|
|
35
|
+
return Object.prototype.hasOwnProperty.call(
|
|
36
|
+
dataTypeDefinions,
|
|
37
|
+
input as DataType
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dataTypeDefinions, type DataType } from "./data-types";
|
|
2
|
+
import { ComponentConfig } from "./types";
|
|
2
3
|
|
|
3
4
|
const indent = (str: string, spaces: number) => {
|
|
4
5
|
const spacesString = " ".repeat(spaces);
|
|
@@ -11,28 +12,28 @@ const indent = (str: string, spaces: number) => {
|
|
|
11
12
|
|
|
12
13
|
function renderInputTypeAsTS(
|
|
13
14
|
name: string,
|
|
14
|
-
type:
|
|
15
|
+
type: DataType,
|
|
15
16
|
trailingChars: string,
|
|
16
17
|
indentSpaces: number
|
|
17
18
|
) {
|
|
18
19
|
return indent(
|
|
19
|
-
`${name}: ${
|
|
20
|
+
`${name}: ${dataTypeDefinions[type].tsType}${trailingChars}`,
|
|
20
21
|
indentSpaces
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export function generateComponentTypesFile(config:
|
|
25
|
-
const
|
|
26
|
-
const eventHandlers = config.
|
|
25
|
+
export function generateComponentTypesFile(config: ComponentConfig) {
|
|
26
|
+
const properties = config.properties ?? [];
|
|
27
|
+
const eventHandlers = config.events ?? [];
|
|
27
28
|
return `// WARNING: This file is automatically generated and managed by Superblocks CLI and should not be edited manually.
|
|
28
29
|
// Use the \`superblocks components watch\` command to regenerate this file from its source in config.ts
|
|
29
30
|
|
|
30
|
-
// All
|
|
31
|
+
// All properties of your component are defined here.
|
|
31
32
|
// These are the properties which are surfaced in the Superblocks properties panel
|
|
32
33
|
// and can be referenced throughout your Superblocks Application
|
|
33
34
|
export interface Props {
|
|
34
|
-
${
|
|
35
|
-
.map((v
|
|
35
|
+
${properties
|
|
36
|
+
.map((v) => renderInputTypeAsTS(v.path, v.dataType, ";", 2) + "\n")
|
|
36
37
|
.join("")}}
|
|
37
38
|
|
|
38
39
|
export interface EventTriggers {
|
package/src/index.ts
CHANGED
package/src/resource-configs.ts
CHANGED
|
@@ -75,25 +75,6 @@ export async function getSuperblocksMonorepoConfigJson(
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
export async function updatedMonorepoConfig(version: string) {
|
|
79
|
-
try {
|
|
80
|
-
const [previousConfig, configPath] = await getSuperblocksMonorepoConfigJson(
|
|
81
|
-
true
|
|
82
|
-
);
|
|
83
|
-
if (previousConfig.metadata.cliVersion !== version) {
|
|
84
|
-
const newConfig = JSON.parse(JSON.stringify(previousConfig));
|
|
85
|
-
newConfig.metadata.cliVersion = version;
|
|
86
|
-
// update superblocks.json file
|
|
87
|
-
await fs.writeFile(
|
|
88
|
-
configPath,
|
|
89
|
-
JSON.stringify(updatedMonorepoConfig, null, 2)
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
// This might fail for a brand-new project folder, which is deliberately ignored
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
78
|
export async function getSuperblocksApplicationConfigJson(): Promise<SuperblocksApplicationConfig> {
|
|
98
79
|
let superblocksConfig;
|
|
99
80
|
try {
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import { type UUID } from "node:crypto";
|
|
2
|
-
import { type
|
|
2
|
+
import { type DataType } from "./data-types";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface PropertiesPanelDisplay {
|
|
5
|
+
// Determines what form item type is shown in the Superblocks properties panel.
|
|
6
|
+
controlType: "text" | "js-expr" | "switch";
|
|
7
|
+
|
|
8
|
+
// Determines form item label in the Superblocks properties panel.
|
|
5
9
|
label: string;
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
|
|
11
|
+
// Placeholder text appears as gray text in the properties panel. This only applies
|
|
12
|
+
// to text-like inputs.
|
|
8
13
|
placeholder?: string;
|
|
14
|
+
|
|
15
|
+
// This shows up in the popover as a user types into the properties panel.
|
|
16
|
+
// This is a documentation field that helps users understand what type of data is accepted
|
|
17
|
+
// by this property.
|
|
18
|
+
exampleData?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Property {
|
|
22
|
+
path: string;
|
|
23
|
+
dataType: DataType;
|
|
24
|
+
|
|
25
|
+
// The presence of this object determines whether or not this property
|
|
26
|
+
// shows up in the Superblocks properties panel.
|
|
27
|
+
propertiesPanelDisplay?: PropertiesPanelDisplay;
|
|
28
|
+
|
|
29
|
+
// A description of this property. This is used in the Superblocks properties panel
|
|
30
|
+
// as well as in the custom component's autocomplete.
|
|
31
|
+
description?: string;
|
|
9
32
|
}
|
|
10
33
|
|
|
11
34
|
export interface ComponentConfig {
|
|
@@ -20,7 +43,7 @@ export interface ComponentConfig {
|
|
|
20
43
|
// Example: "components/myComponent/component.tsx"
|
|
21
44
|
componentPath: string;
|
|
22
45
|
|
|
23
|
-
|
|
46
|
+
properties: Property[];
|
|
24
47
|
|
|
25
48
|
/**
|
|
26
49
|
* Example: [{
|
|
@@ -28,7 +51,7 @@ export interface ComponentConfig {
|
|
|
28
51
|
* path: "onClick",
|
|
29
52
|
* }]
|
|
30
53
|
*/
|
|
31
|
-
|
|
54
|
+
events: Array<{
|
|
32
55
|
label: string;
|
|
33
56
|
path: string;
|
|
34
57
|
}>;
|
package/src/validation.ts
CHANGED
|
@@ -10,13 +10,13 @@ const componentSchema: Schema = {
|
|
|
10
10
|
name: { type: "string" },
|
|
11
11
|
displayName: { type: "string" },
|
|
12
12
|
componentPath: { type: "string" },
|
|
13
|
-
|
|
13
|
+
properties: {
|
|
14
14
|
type: "array",
|
|
15
15
|
items: {
|
|
16
|
-
$ref: "#/definitions/
|
|
16
|
+
$ref: "#/definitions/Property",
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
events: {
|
|
20
20
|
type: "array",
|
|
21
21
|
items: {
|
|
22
22
|
$ref: "#/definitions/EventHandler",
|
|
@@ -28,21 +28,32 @@ const componentSchema: Schema = {
|
|
|
28
28
|
"name",
|
|
29
29
|
"displayName",
|
|
30
30
|
"componentPath",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"properties",
|
|
32
|
+
"events",
|
|
33
33
|
],
|
|
34
34
|
additionalProperties: false,
|
|
35
35
|
definitions: {
|
|
36
|
-
|
|
36
|
+
Property: {
|
|
37
37
|
properties: {
|
|
38
|
-
label: { type: "string" },
|
|
39
38
|
path: { type: "string" },
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
dataType: { enum: ["number", "boolean", "string", "any"] },
|
|
40
|
+
propertiesPanelDisplay: {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
label: { type: "string" },
|
|
44
|
+
controlType: { enum: ["text", "js-expr", "switch"] },
|
|
45
|
+
defaultValue: { type: "string" },
|
|
46
|
+
placeholder: { type: "string" },
|
|
47
|
+
exampleData: { type: "string" },
|
|
48
|
+
},
|
|
49
|
+
required: ["controlType", "label"],
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
},
|
|
52
|
+
description: { type: "string" },
|
|
42
53
|
},
|
|
43
54
|
type: "object",
|
|
44
55
|
additionalProperties: false,
|
|
45
|
-
required: ["
|
|
56
|
+
required: ["path", "dataType"],
|
|
46
57
|
},
|
|
47
58
|
EventHandler: {
|
|
48
59
|
properties: {
|
package/dist/input-types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const supportedInputTypes: readonly ["text", "number", "boolean", "js"];
|
|
2
|
-
export type InputType = (typeof supportedInputTypes)[number];
|
|
3
|
-
interface TypeInfo {
|
|
4
|
-
tsType: string;
|
|
5
|
-
prompt: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const inputTypeDefinions: Record<InputType, TypeInfo>;
|
|
8
|
-
export declare function isValidInputType(input: string): input is InputType;
|
|
9
|
-
export {};
|
package/dist/input-types.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidInputType = exports.inputTypeDefinions = exports.supportedInputTypes = void 0;
|
|
4
|
-
exports.supportedInputTypes = ["text", "number", "boolean", "js"];
|
|
5
|
-
exports.inputTypeDefinions = {
|
|
6
|
-
text: {
|
|
7
|
-
tsType: "string",
|
|
8
|
-
prompt: "text",
|
|
9
|
-
},
|
|
10
|
-
number: {
|
|
11
|
-
tsType: "number",
|
|
12
|
-
prompt: "number",
|
|
13
|
-
},
|
|
14
|
-
boolean: {
|
|
15
|
-
tsType: "boolean",
|
|
16
|
-
prompt: "boolean",
|
|
17
|
-
},
|
|
18
|
-
js: {
|
|
19
|
-
tsType: "any",
|
|
20
|
-
prompt: "any (raw js expression)",
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
function isValidInputType(input) {
|
|
24
|
-
return Object.prototype.hasOwnProperty.call(exports.inputTypeDefinions, input);
|
|
25
|
-
}
|
|
26
|
-
exports.isValidInputType = isValidInputType;
|
package/src/input-types.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const supportedInputTypes = ["text", "number", "boolean", "js"] as const;
|
|
2
|
-
|
|
3
|
-
export type InputType = (typeof supportedInputTypes)[number];
|
|
4
|
-
|
|
5
|
-
interface TypeInfo {
|
|
6
|
-
tsType: string;
|
|
7
|
-
prompt: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const inputTypeDefinions: Record<InputType, TypeInfo> = {
|
|
11
|
-
text: {
|
|
12
|
-
tsType: "string",
|
|
13
|
-
prompt: "text",
|
|
14
|
-
},
|
|
15
|
-
number: {
|
|
16
|
-
tsType: "number",
|
|
17
|
-
prompt: "number",
|
|
18
|
-
},
|
|
19
|
-
boolean: {
|
|
20
|
-
tsType: "boolean",
|
|
21
|
-
prompt: "boolean",
|
|
22
|
-
},
|
|
23
|
-
js: {
|
|
24
|
-
tsType: "any",
|
|
25
|
-
prompt: "any (raw js expression)",
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export function isValidInputType(input: string): input is InputType {
|
|
30
|
-
return Object.prototype.hasOwnProperty.call(
|
|
31
|
-
inputTypeDefinions,
|
|
32
|
-
input as InputType
|
|
33
|
-
);
|
|
34
|
-
}
|