Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
npm/
gen/
node_modules/
node_modules/
windmill-utils-internal/.npmrc
4 changes: 2 additions & 2 deletions cli/windmill-utils-internal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/windmill-utils-internal/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -21,4 +21,4 @@
"files": [
"dist/**/*"
]
}
}
62 changes: 47 additions & 15 deletions cli/windmill-utils-internal/src/parse/parse-schema.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -40,6 +43,16 @@ export interface SchemaProperty {
originalType?: string;
}

const ITEMS_PRESERVED_FIELDS = [
"properties",
"required",
"additionalProperties",
"enum",
"resourceType",
"contentEncoding",
"description",
] as (keyof SchemaProperty["items"])[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ITEMS_PRESERVED_FIELDS array includes "additionalProperties", "required", and "description" which are not defined in the SchemaProperty["items"] interface (lines 20-26). While this works at runtime, it creates a type inconsistency.

Consider updating the items interface to include these fields:

Suggested change
] as (keyof SchemaProperty["items"])[];
] as (keyof SchemaProperty["items"])[];
// Note: Consider adding required?, additionalProperties?, and description?
// to the items interface above for complete type safety

Alternatively, update the interface definition around line 20:

items?: {
  type?: "string" | "number" | "bytes" | "object" | "resource";
  contentEncoding?: "base64";
  enum?: EnumType;
  resourceType?: string;
  properties?: { [name: string]: SchemaProperty };
  required?: string[];
  additionalProperties?: boolean;
  description?: string;
};


/**
* Converts argument signature types to JSON schema properties.
* This function handles various Windmill-specific types and converts them
Expand All @@ -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: "" };
Expand Down Expand Up @@ -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 = [
Expand Down
15 changes: 5 additions & 10 deletions cli/windmill-utils-internal/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"module": "ES2022",
"lib": ["ES2022"],
"declaration": true,
"outDir": "./dist",
Expand All @@ -11,19 +11,14 @@
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"baseUrl": "./",
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading