diff --git a/cli/.gitignore b/cli/.gitignore index 74d3e102f59ba..e6c9bd265535a 100644 --- a/cli/.gitignore +++ b/cli/.gitignore @@ -1,3 +1,4 @@ npm/ gen/ -node_modules/ \ No newline at end of file +node_modules/ +windmill-utils-internal/.npmrc \ No newline at end of file diff --git a/cli/windmill-utils-internal/package-lock.json b/cli/windmill-utils-internal/package-lock.json index db260b02dc22f..ddf3437925324 100644 --- a/cli/windmill-utils-internal/package-lock.json +++ b/cli/windmill-utils-internal/package-lock.json @@ -1,12 +1,12 @@ { "name": "windmill-utils-internal", - "version": "1.3.0", + "version": "1.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "windmill-utils-internal", - "version": "1.3.0", + "version": "1.3.2", "license": "Apache 2.0", "devDependencies": { "@types/node": "^24.2.0", diff --git a/cli/windmill-utils-internal/package.json b/cli/windmill-utils-internal/package.json index ff4418f79bac1..20f20a4c9a235 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.1", + "version": "1.3.2", "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/parse/parse-schema.ts b/cli/windmill-utils-internal/src/parse/parse-schema.ts index 9cd4a596b45bb..bb2e2078af7a1 100644 --- a/cli/windmill-utils-internal/src/parse/parse-schema.ts +++ b/cli/windmill-utils-internal/src/parse/parse-schema.ts @@ -1,7 +1,10 @@ /** * Type alias for enum values - can be an array of strings or undefined */ -export type EnumType = string[] | { label: string; value: string }[] | undefined; +export type EnumType = + | string[] + | { label: string; value: string }[] + | undefined; /** * Represents a property in a JSON schema with various validation and display options @@ -40,6 +43,16 @@ export interface SchemaProperty { originalType?: string; } +const ITEMS_PRESERVED_FIELDS = [ + "properties", + "required", + "additionalProperties", + "enum", + "resourceType", + "contentEncoding", + "description", +] as (keyof SchemaProperty["items"])[]; + /** * Converts argument signature types to JSON schema properties. * This function handles various Windmill-specific types and converts them @@ -54,22 +67,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: "" }; @@ -206,15 +219,34 @@ export function argSigToJsonSchemaType( } newS.items = { type: "object", properties: properties }; } else { - newS.items = { type: "object" }; + // Preserve ALL user-defined fields when parser cannot infer structure + newS.items = { type: oldS.items?.type || "object" }; + + if (oldS.items && typeof oldS.items === "object") { + ITEMS_PRESERVED_FIELDS.forEach((field) => { + if (oldS.items && oldS.items[field] !== undefined) { + newS.items![field] = oldS.items[field]; + } + }); + } } newS.originalType = "record[]"; } else { - newS.items = { type: "object" }; + // Preserve ALL user-defined fields for untyped lists (same as record[] branch) + newS.items = { type: oldS.items?.type || "object" }; + + if (oldS.items && typeof oldS.items === "object") { + ITEMS_PRESERVED_FIELDS.forEach((field) => { + if (oldS.items && oldS.items[field] !== undefined) { + newS.items![field] = oldS.items[field]; + } + }); + } newS.originalType = "object[]"; } } else { - newS.type = "object"; + // Preserve existing type when inference fails, default to "object" for undefined/null + newS.type = oldS.type ?? "object"; } const preservedFields = [ diff --git a/cli/windmill-utils-internal/tsconfig.json b/cli/windmill-utils-internal/tsconfig.json index 38f18728f4474..35814c1f7a2e8 100644 --- a/cli/windmill-utils-internal/tsconfig.json +++ b/cli/windmill-utils-internal/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "ES2022", - "module": "commonjs", + "module": "ES2022", "lib": ["ES2022"], "declaration": true, "outDir": "./dist", @@ -11,7 +11,7 @@ "noUnusedParameters": false, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "baseUrl": "./", "esModuleInterop": true, "experimentalDecorators": true, @@ -19,11 +19,6 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "dist" - ] -} \ No newline at end of file + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/frontend/package-lock.json b/frontend/package-lock.json index bb77f1b2a681c..3b56a7fc1a218 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -86,7 +86,7 @@ "windmill-parser-wasm-ts": "1.593.0", "windmill-parser-wasm-yaml": "1.593.0", "windmill-sql-datatype-parser-wasm": "1.512.0", - "windmill-utils-internal": "^1.3.1", + "windmill-utils-internal": "^1.3.2", "xterm": "^5.3.0", "xterm-readline": "^1.1.2", "y-monaco": "^0.1.4", @@ -15893,9 +15893,9 @@ "integrity": "sha512-uHNL8F72/Tf96xF3hOHnPDjkEyqXw7fNjcPJiUhth9sTQkcwUIoJMOdwm8/cs+j9kKVRJ4tgNYMHEBLylazp6g==" }, "node_modules/windmill-utils-internal": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/windmill-utils-internal/-/windmill-utils-internal-1.3.1.tgz", - "integrity": "sha512-afRGUDcvaUfGu7FA6DD0xWECQiKnXADs0N4WyQQ+OvaloxZ4oQzdEpLnVab/m3T02hhs29ru4Ilrdxu3ozyT5Q==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/windmill-utils-internal/-/windmill-utils-internal-1.3.2.tgz", + "integrity": "sha512-sLE7sfmN3vBwPReqKorBrusnn83Qnm8vVFqh/7+kz8mf98ojMVDMgBginjlh9KBtVfWu9NhyjGS+WXRcnWalzA==", "license": "Apache 2.0" }, "node_modules/word-wrap": { diff --git a/frontend/package.json b/frontend/package.json index ece9c3ada4970..593a348b8e3ba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -158,7 +158,7 @@ "windmill-parser-wasm-ts": "1.593.0", "windmill-parser-wasm-yaml": "1.593.0", "windmill-sql-datatype-parser-wasm": "1.512.0", - "windmill-utils-internal": "^1.3.1", + "windmill-utils-internal": "^1.3.2", "xterm": "^5.3.0", "xterm-readline": "^1.1.2", "y-monaco": "^0.1.4",