diff --git a/cli/windmill-utils-internal/package.json b/cli/windmill-utils-internal/package.json index 72ec2220e8..ff4418f79b 100644 --- a/cli/windmill-utils-internal/package.json +++ b/cli/windmill-utils-internal/package.json @@ -1,6 +1,6 @@ { "name": "windmill-utils-internal", - "version": "1.3.0", + "version": "1.3.1", "description": "Internal utility functions for Windmill", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -21,4 +21,4 @@ "files": [ "dist/**/*" ] -} +} \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/config/index.ts b/cli/windmill-utils-internal/src/config/index.ts index f3ae42b3c8..e23ba6ca86 100644 --- a/cli/windmill-utils-internal/src/config/index.ts +++ b/cli/windmill-utils-internal/src/config/index.ts @@ -1 +1 @@ -export * from "./config.ts"; \ No newline at end of file +export * from "./config"; \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/index.ts b/cli/windmill-utils-internal/src/index.ts index 635893e2d1..da314a7c5a 100644 --- a/cli/windmill-utils-internal/src/index.ts +++ b/cli/windmill-utils-internal/src/index.ts @@ -8,8 +8,8 @@ * - Cross-platform path constants */ -export * from "./inline-scripts.ts"; -export * from "./path-utils.ts"; -export * from "./parse.ts"; -export * from "./config.ts"; -export { SEP, DELIMITER } from "./constants.ts"; \ No newline at end of file +export * from "./inline-scripts"; +export * from "./path-utils"; +export * from "./parse"; +export * from "./config"; +export { SEP, DELIMITER } from "./constants"; \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/inline-scripts/extractor.ts b/cli/windmill-utils-internal/src/inline-scripts/extractor.ts index be2d33c0de..b64e7ca789 100644 --- a/cli/windmill-utils-internal/src/inline-scripts/extractor.ts +++ b/cli/windmill-utils-internal/src/inline-scripts/extractor.ts @@ -1,5 +1,5 @@ -import { newPathAssigner } from "../path-utils/path-assigner.ts"; -import { FlowModule } from "../gen/types.gen.ts"; +import { newPathAssigner } from "../path-utils/path-assigner"; +import { FlowModule } from "../gen/types.gen"; /** * Represents an inline script extracted from a flow module diff --git a/cli/windmill-utils-internal/src/inline-scripts/index.ts b/cli/windmill-utils-internal/src/inline-scripts/index.ts index bb3c917dbb..eace8d3e4f 100644 --- a/cli/windmill-utils-internal/src/inline-scripts/index.ts +++ b/cli/windmill-utils-internal/src/inline-scripts/index.ts @@ -1,2 +1,2 @@ -export * from "./replacer.ts"; -export * from "./extractor.ts"; \ No newline at end of file +export * from "./replacer"; +export * from "./extractor"; \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/inline-scripts/replacer.ts b/cli/windmill-utils-internal/src/inline-scripts/replacer.ts index 9ec25e9f65..be349785c7 100644 --- a/cli/windmill-utils-internal/src/inline-scripts/replacer.ts +++ b/cli/windmill-utils-internal/src/inline-scripts/replacer.ts @@ -1,4 +1,4 @@ -import { FlowModule } from "../gen/types.gen.ts"; +import { FlowModule } from "../gen/types.gen"; /** * Replaces inline script references with actual file content from the filesystem. diff --git a/cli/windmill-utils-internal/src/parse/index.ts b/cli/windmill-utils-internal/src/parse/index.ts index 41d09ed00d..fc26ce611a 100644 --- a/cli/windmill-utils-internal/src/parse/index.ts +++ b/cli/windmill-utils-internal/src/parse/index.ts @@ -1 +1 @@ -export * from "./parse-schema.ts"; \ No newline at end of file +export * from "./parse-schema"; \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/parse/parse-schema.ts b/cli/windmill-utils-internal/src/parse/parse-schema.ts index a6417a1c01..9cd4a596b4 100644 --- a/cli/windmill-utils-internal/src/parse/parse-schema.ts +++ b/cli/windmill-utils-internal/src/parse/parse-schema.ts @@ -1,7 +1,7 @@ /** * Type alias for enum values - can be an array of strings or undefined */ -export type EnumType = string[] | undefined; +export type EnumType = string[] | { label: string; value: string }[] | undefined; /** * Represents a property in a JSON schema with various validation and display options @@ -17,7 +17,7 @@ export interface SchemaProperty { items?: { type?: "string" | "number" | "bytes" | "object" | "resource"; contentEncoding?: "base64"; - enum?: string[]; + enum?: EnumType; resourceType?: string; properties?: { [name: string]: SchemaProperty }; }; @@ -54,22 +54,22 @@ export function argSigToJsonSchemaType( | string | { resource: string | null } | { - list: - | (string | { name?: string; props?: { key: string; typ: any }[] }) - | { str: any } - | { object: { name?: string; props?: { key: string; typ: any }[] } } - | null; - } + list: + | (string | { name?: string; props?: { key: string; typ: any }[] }) + | { str: any } + | { object: { name?: string; props?: { key: string; typ: any }[] } } + | null; + } | { dynselect: string } | { dynmultiselect: string } | { str: string[] | null } | { object: { name?: string; props?: { key: string; typ: any }[] } } | { - oneof: { - label: string; - properties: { key: string; typ: any }[]; - }[]; - }, + oneof: { + label: string; + properties: { key: string; typ: any }[]; + }[]; + }, oldS: SchemaProperty ): void { const newS: SchemaProperty = { type: "" }; diff --git a/cli/windmill-utils-internal/src/path-utils/index.ts b/cli/windmill-utils-internal/src/path-utils/index.ts index 6f5c8d68be..ef23185664 100644 --- a/cli/windmill-utils-internal/src/path-utils/index.ts +++ b/cli/windmill-utils-internal/src/path-utils/index.ts @@ -1 +1 @@ -export * from "./path-assigner.ts"; \ No newline at end of file +export * from "./path-assigner"; \ No newline at end of file diff --git a/cli/windmill-utils-internal/src/path-utils/path-assigner.ts b/cli/windmill-utils-internal/src/path-utils/path-assigner.ts index d1a79a3a32..9020974214 100644 --- a/cli/windmill-utils-internal/src/path-utils/path-assigner.ts +++ b/cli/windmill-utils-internal/src/path-utils/path-assigner.ts @@ -1,4 +1,4 @@ -import { RawScript } from "../gen/types.gen.ts"; +import { RawScript } from "../gen/types.gen"; const INLINE_SCRIPT_PREFIX = "inline_script"; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 53e732f293..4659c8bc51 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -86,7 +86,7 @@ "windmill-parser-wasm-ts": "1.538.0", "windmill-parser-wasm-yaml": "1.510.1", "windmill-sql-datatype-parser-wasm": "1.512.0", - "windmill-utils-internal": "^1.3.0", + "windmill-utils-internal": "^1.3.1", "xterm": "^5.3.0", "xterm-readline": "^1.1.2", "y-monaco": "^0.1.4", @@ -13542,9 +13542,9 @@ "integrity": "sha512-uHNL8F72/Tf96xF3hOHnPDjkEyqXw7fNjcPJiUhth9sTQkcwUIoJMOdwm8/cs+j9kKVRJ4tgNYMHEBLylazp6g==" }, "node_modules/windmill-utils-internal": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/windmill-utils-internal/-/windmill-utils-internal-1.3.0.tgz", - "integrity": "sha512-UH7G+NVODkhm4o3BbjaOrSE2Qu+J6ro7+vpsIs+GvjDZM4ogSN7aJfnQNHW7Ke0VY74BKZVClTKROe/N6I5Reg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/windmill-utils-internal/-/windmill-utils-internal-1.3.1.tgz", + "integrity": "sha512-afRGUDcvaUfGu7FA6DD0xWECQiKnXADs0N4WyQQ+OvaloxZ4oQzdEpLnVab/m3T02hhs29ru4Ilrdxu3ozyT5Q==", "license": "Apache 2.0" }, "node_modules/word-wrap": { diff --git a/frontend/package.json b/frontend/package.json index 0fb2dc9c01..be97c6b950 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -151,7 +151,7 @@ "windmill-parser-wasm-ts": "1.538.0", "windmill-parser-wasm-yaml": "1.510.1", "windmill-sql-datatype-parser-wasm": "1.512.0", - "windmill-utils-internal": "^1.3.0", + "windmill-utils-internal": "^1.3.1", "xterm": "^5.3.0", "xterm-readline": "^1.1.2", "y-monaco": "^0.1.4", diff --git a/frontend/src/lib/common.ts b/frontend/src/lib/common.ts index b96af76d03..7ea1de146e 100644 --- a/frontend/src/lib/common.ts +++ b/frontend/src/lib/common.ts @@ -15,7 +15,7 @@ export interface PropertyDisplayInfo { propertiesNumber: number } -export type EnumType = string[] | undefined +export type EnumType = string[] | { value: string; label: string }[] | undefined export interface SchemaProperty { type: string | undefined diff --git a/frontend/src/lib/components/ArgEnum.svelte b/frontend/src/lib/components/ArgEnum.svelte index d87d34ea33..3b616b95f3 100644 --- a/frontend/src/lib/components/ArgEnum.svelte +++ b/frontend/src/lib/components/ArgEnum.svelte @@ -30,11 +30,19 @@ let customItems: string[] = $state([]) let items = $derived.by(() => { - const l = [...(enum_ ? enum_ : []), ...customItems].map((item) => ({ - value: item, - label: enumLabels?.[item] ?? item - })) - if (create && filterText && l.every((i) => i.value !== filterText)) { + const l = [...(enum_ ? enum_ : []), ...customItems] + .map((item) => { + if (typeof item === 'string') { + return { + value: item, + label: enumLabels?.[item] ?? item + } + } else if (typeof item === 'object') { + return item + } + }) + .filter((i) => i != undefined) + if (create && filterText && l.every((i) => i?.value !== filterText)) { l.push({ value: filterText, label: `Add new: ${filterText}` }) } return l diff --git a/frontend/src/lib/components/ArgInput.svelte b/frontend/src/lib/components/ArgInput.svelte index 6df54a8054..843281774f 100644 --- a/frontend/src/lib/components/ArgInput.svelte +++ b/frontend/src/lib/components/ArgInput.svelte @@ -248,7 +248,12 @@ if (inputCat === 'string') { nvalue = nullable ? null : '' } else if (inputCat == 'enum' && required) { - nvalue = enum_?.[0] + let firstV = enum_?.[0] + if (typeof firstV === 'string') { + nvalue = firstV + } else if (firstV && typeof firstV === 'object') { + nvalue = firstV.value + } } else if (inputCat == 'boolean') { nvalue = false } else if (inputCat == 'list') { diff --git a/frontend/src/lib/components/StringTypeNarrowing.svelte b/frontend/src/lib/components/StringTypeNarrowing.svelte index 5fa15f090a..51dad18154 100644 --- a/frontend/src/lib/components/StringTypeNarrowing.svelte +++ b/frontend/src/lib/components/StringTypeNarrowing.svelte @@ -98,12 +98,12 @@ } let choice = `choice ${enum_?.length ? enum_?.length + 1 : 1}` - enum_ = enum_ ? enum_.concat(choice) : [choice] + enum_ = enum_ ? (enum_.concat(choice) as EnumType) : [choice] } function remove(item: string) { - enum_ = (enum_ || []).filter((el) => el !== item) - if (enum_.length == 0) { + enum_ = (enum_ || []).filter((el) => el !== item) as EnumType + if (enum_?.length == 0) { enum_ = undefined } @@ -230,34 +230,49 @@