mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 00:04:10 +00:00
fix: fix format not being preserved in script editor + currency bind failure
This commit is contained in:
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "windmill-utils-internal",
|
||||
"version": "1.1.0",
|
||||
"version": "1.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "windmill-utils-internal",
|
||||
"version": "1.1.0",
|
||||
"version": "1.3.0",
|
||||
"license": "Apache 2.0",
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.2.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "windmill-utils-internal",
|
||||
"version": "1.1.0",
|
||||
"version": "1.3.0",
|
||||
"description": "Internal utility functions for Windmill",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from "./config.ts";
|
||||
export * from "./config";
|
||||
@@ -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";
|
||||
export * from "./inline-scripts";
|
||||
export * from "./path-utils";
|
||||
export * from "./parse";
|
||||
export * from "./config";
|
||||
export { SEP, DELIMITER } from "./constants";
|
||||
@@ -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
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./replacer.ts";
|
||||
export * from "./extractor.ts";
|
||||
export * from "./replacer";
|
||||
export * from "./extractor";
|
||||
@@ -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.
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from "./parse-schema.ts";
|
||||
export * from "./parse-schema";
|
||||
@@ -1,248 +1,276 @@
|
||||
/**
|
||||
* Type alias for enum values - can be an array of strings or undefined
|
||||
*/
|
||||
export type EnumType = string[] | undefined
|
||||
export type EnumType = string[] | undefined;
|
||||
|
||||
/**
|
||||
* Represents a property in a JSON schema with various validation and display options
|
||||
*/
|
||||
export interface SchemaProperty {
|
||||
type: string | undefined
|
||||
description?: string
|
||||
pattern?: string
|
||||
default?: any
|
||||
enum?: EnumType
|
||||
contentEncoding?: 'base64' | 'binary'
|
||||
format?: string
|
||||
items?: {
|
||||
type?: 'string' | 'number' | 'bytes' | 'object' | 'resource'
|
||||
contentEncoding?: 'base64'
|
||||
enum?: string[]
|
||||
resourceType?: string
|
||||
properties?: { [name: string]: SchemaProperty }
|
||||
}
|
||||
min?: number
|
||||
max?: number
|
||||
currency?: string
|
||||
currencyLocale?: string
|
||||
multiselect?: boolean
|
||||
customErrorMessage?: string
|
||||
properties?: { [name: string]: SchemaProperty }
|
||||
required?: string[]
|
||||
showExpr?: string
|
||||
password?: boolean
|
||||
order?: string[]
|
||||
nullable?: boolean
|
||||
dateFormat?: string
|
||||
title?: string
|
||||
placeholder?: string
|
||||
oneOf?: SchemaProperty[]
|
||||
originalType?: string
|
||||
type: string | undefined;
|
||||
description?: string;
|
||||
pattern?: string;
|
||||
default?: any;
|
||||
enum?: EnumType;
|
||||
contentEncoding?: "base64" | "binary";
|
||||
format?: string;
|
||||
items?: {
|
||||
type?: "string" | "number" | "bytes" | "object" | "resource";
|
||||
contentEncoding?: "base64";
|
||||
enum?: string[];
|
||||
resourceType?: string;
|
||||
properties?: { [name: string]: SchemaProperty };
|
||||
};
|
||||
min?: number;
|
||||
max?: number;
|
||||
currency?: string;
|
||||
currencyLocale?: string;
|
||||
multiselect?: boolean;
|
||||
customErrorMessage?: string;
|
||||
properties?: { [name: string]: SchemaProperty };
|
||||
required?: string[];
|
||||
showExpr?: string;
|
||||
password?: boolean;
|
||||
order?: string[];
|
||||
nullable?: boolean;
|
||||
dateFormat?: string;
|
||||
title?: string;
|
||||
placeholder?: string;
|
||||
oneOf?: SchemaProperty[];
|
||||
originalType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts argument signature types to JSON schema properties.
|
||||
* This function handles various Windmill-specific types and converts them
|
||||
* to standard JSON schema format while preserving existing property metadata.
|
||||
*
|
||||
*
|
||||
* @param t - The argument signature type definition (can be string or complex object types)
|
||||
* @param oldS - Existing schema property to update with new type information
|
||||
*/
|
||||
|
||||
export function argSigToJsonSchemaType(
|
||||
t:
|
||||
| string
|
||||
| { resource: string | 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 }[]
|
||||
}[]
|
||||
},
|
||||
oldS: SchemaProperty
|
||||
t:
|
||||
| string
|
||||
| { resource: string | 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 }[];
|
||||
}[];
|
||||
},
|
||||
oldS: SchemaProperty
|
||||
): void {
|
||||
const newS: SchemaProperty = { type: '' }
|
||||
if (t === 'int') {
|
||||
newS.type = 'integer'
|
||||
} else if (t === 'float') {
|
||||
newS.type = 'number'
|
||||
} else if (t === 'bool') {
|
||||
newS.type = 'boolean'
|
||||
} else if (t === 'email') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'email'
|
||||
} else if (t === 'sql') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'sql'
|
||||
} else if (t === 'yaml') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'yaml'
|
||||
} else if (t === 'bytes') {
|
||||
newS.type = 'string'
|
||||
newS.contentEncoding = 'base64'
|
||||
newS.originalType = 'bytes'
|
||||
} else if (t === 'datetime') {
|
||||
newS.type = 'string'
|
||||
newS.format = 'date-time'
|
||||
} else if (typeof t !== 'string' && 'oneof' in t) {
|
||||
newS.type = 'object'
|
||||
if (t.oneof) {
|
||||
newS.oneOf = t.oneof.map((obj) => {
|
||||
const oldObjS = oldS.oneOf?.find((o) => o?.title === obj.label) ?? undefined
|
||||
const properties: Record<string, any> = {}
|
||||
for (const prop of obj.properties) {
|
||||
if (oldObjS?.properties && prop.key in oldObjS?.properties) {
|
||||
properties[prop.key] = oldObjS?.properties[prop.key]
|
||||
} else {
|
||||
properties[prop.key] = { description: '', type: '' }
|
||||
}
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key])
|
||||
}
|
||||
return {
|
||||
type: 'object',
|
||||
title: obj.label,
|
||||
properties,
|
||||
order: oldObjS?.order ?? undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (typeof t !== 'string' && `object` in t) {
|
||||
newS.type = 'object'
|
||||
if (t.object.name) {
|
||||
newS.format = `resource-${t.object.name}`
|
||||
}
|
||||
if (t.object.props) {
|
||||
const properties: Record<string, any> = {}
|
||||
for (const prop of t.object.props) {
|
||||
if (oldS.properties && prop.key in oldS.properties) {
|
||||
properties[prop.key] = oldS.properties[prop.key]
|
||||
} else {
|
||||
properties[prop.key] = { description: '', type: '' }
|
||||
}
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key])
|
||||
}
|
||||
newS.properties = properties
|
||||
}
|
||||
} else if (typeof t !== 'string' && `str` in t) {
|
||||
newS.type = 'string'
|
||||
if (t.str) {
|
||||
newS.originalType = 'enum'
|
||||
newS.enum = t.str
|
||||
} else if (oldS.originalType == 'string' && oldS.enum) {
|
||||
newS.originalType = 'string'
|
||||
newS.enum = oldS.enum
|
||||
} else {
|
||||
newS.originalType = 'string'
|
||||
newS.enum = undefined
|
||||
}
|
||||
} else if (typeof t !== 'string' && `resource` in t) {
|
||||
newS.type = 'object'
|
||||
newS.format = `resource-${t.resource}`
|
||||
} else if (typeof t !== 'string' && `dynselect` in t) {
|
||||
newS.type = 'object'
|
||||
newS.format = `dynselect-${t.dynselect}`
|
||||
} else if (typeof t !== 'string' && `dynmultiselect` in t) {
|
||||
newS.type = 'object'
|
||||
newS.format = `dynmultiselect-${t.dynmultiselect}`
|
||||
}
|
||||
else if (typeof t !== 'string' && `list` in t) {
|
||||
newS.type = 'array'
|
||||
if (t.list === 'int' || t.list === 'float') {
|
||||
newS.items = { type: 'number' }
|
||||
newS.originalType = 'number[]'
|
||||
} else if (t.list === 'bytes') {
|
||||
newS.items = { type: 'string', contentEncoding: 'base64' }
|
||||
newS.originalType = 'bytes[]'
|
||||
} else if (t.list && typeof t.list == 'object' && 'str' in t.list && t.list.str) {
|
||||
newS.items = { type: 'string', enum: t.list.str }
|
||||
newS.originalType = 'enum[]'
|
||||
} else if (t.list == 'string' || (t.list && typeof t.list == 'object' && 'str' in t.list)) {
|
||||
newS.items = { type: 'string', enum: oldS.items?.enum }
|
||||
newS.originalType = 'string[]'
|
||||
} else if (t.list && typeof t.list == 'object' && 'resource' in t.list && t.list.resource) {
|
||||
newS.items = {
|
||||
type: 'resource',
|
||||
resourceType: t.list.resource as string
|
||||
}
|
||||
newS.originalType = 'resource[]'
|
||||
} else if (t.list && typeof t.list == 'object' && 'object' in t.list && t.list.object) {
|
||||
if (t.list.object.name) {
|
||||
newS.format = `resource-${t.list.object.name}`
|
||||
}
|
||||
if (t.list.object.props && t.list.object.props.length > 0) {
|
||||
const properties: Record<string, any> = {}
|
||||
for (const prop of t.list.object.props) {
|
||||
properties[prop.key] = { description: '', type: '' }
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key])
|
||||
}
|
||||
newS.items = { type: 'object', properties: properties }
|
||||
} else {
|
||||
newS.items = { type: 'object' }
|
||||
}
|
||||
newS.originalType = 'record[]'
|
||||
} else {
|
||||
newS.items = { type: 'object' }
|
||||
newS.originalType = 'object[]'
|
||||
}
|
||||
} else {
|
||||
newS.type = 'object'
|
||||
}
|
||||
const newS: SchemaProperty = { type: "" };
|
||||
if (t === "int") {
|
||||
newS.type = "integer";
|
||||
} else if (t === "float") {
|
||||
newS.type = "number";
|
||||
} else if (t === "bool") {
|
||||
newS.type = "boolean";
|
||||
} else if (t === "email") {
|
||||
newS.type = "string";
|
||||
newS.format = "email";
|
||||
} else if (t === "sql") {
|
||||
newS.type = "string";
|
||||
newS.format = "sql";
|
||||
} else if (t === "yaml") {
|
||||
newS.type = "string";
|
||||
newS.format = "yaml";
|
||||
} else if (t === "bytes") {
|
||||
newS.type = "string";
|
||||
newS.contentEncoding = "base64";
|
||||
newS.originalType = "bytes";
|
||||
} else if (t === "datetime") {
|
||||
newS.type = "string";
|
||||
newS.format = "date-time";
|
||||
} else if (typeof t !== "string" && "oneof" in t) {
|
||||
newS.type = "object";
|
||||
if (t.oneof) {
|
||||
newS.oneOf = t.oneof.map((obj) => {
|
||||
const oldObjS =
|
||||
oldS.oneOf?.find((o) => o?.title === obj.label) ?? undefined;
|
||||
const properties: Record<string, any> = {};
|
||||
for (const prop of obj.properties) {
|
||||
if (oldObjS?.properties && prop.key in oldObjS?.properties) {
|
||||
properties[prop.key] = oldObjS?.properties[prop.key];
|
||||
} else {
|
||||
properties[prop.key] = { description: "", type: "" };
|
||||
}
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
||||
}
|
||||
return {
|
||||
type: "object",
|
||||
title: obj.label,
|
||||
properties,
|
||||
order: oldObjS?.order ?? undefined,
|
||||
};
|
||||
});
|
||||
}
|
||||
} else if (typeof t !== "string" && `object` in t) {
|
||||
newS.type = "object";
|
||||
if (t.object.name) {
|
||||
newS.format = `resource-${t.object.name}`;
|
||||
}
|
||||
if (t.object.props) {
|
||||
const properties: Record<string, any> = {};
|
||||
for (const prop of t.object.props) {
|
||||
if (oldS.properties && prop.key in oldS.properties) {
|
||||
properties[prop.key] = oldS.properties[prop.key];
|
||||
} else {
|
||||
properties[prop.key] = { description: "", type: "" };
|
||||
}
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
||||
}
|
||||
newS.properties = properties;
|
||||
}
|
||||
} else if (typeof t !== "string" && `str` in t) {
|
||||
newS.type = "string";
|
||||
if (t.str) {
|
||||
newS.originalType = "enum";
|
||||
newS.enum = t.str;
|
||||
} else if (oldS.originalType == "string" && oldS.enum) {
|
||||
newS.originalType = "string";
|
||||
newS.enum = oldS.enum;
|
||||
} else {
|
||||
newS.originalType = "string";
|
||||
newS.enum = undefined;
|
||||
}
|
||||
} else if (typeof t !== "string" && `resource` in t) {
|
||||
newS.type = "object";
|
||||
newS.format = `resource-${t.resource}`;
|
||||
} else if (typeof t !== "string" && `dynselect` in t) {
|
||||
newS.type = "object";
|
||||
newS.format = `dynselect-${t.dynselect}`;
|
||||
} else if (typeof t !== "string" && `dynmultiselect` in t) {
|
||||
newS.type = "object";
|
||||
newS.format = `dynmultiselect-${t.dynmultiselect}`;
|
||||
} else if (typeof t !== "string" && `list` in t) {
|
||||
newS.type = "array";
|
||||
if (t.list === "int" || t.list === "float") {
|
||||
newS.items = { type: "number" };
|
||||
newS.originalType = "number[]";
|
||||
} else if (t.list === "bytes") {
|
||||
newS.items = { type: "string", contentEncoding: "base64" };
|
||||
newS.originalType = "bytes[]";
|
||||
} else if (
|
||||
t.list &&
|
||||
typeof t.list == "object" &&
|
||||
"str" in t.list &&
|
||||
t.list.str
|
||||
) {
|
||||
newS.items = { type: "string", enum: t.list.str };
|
||||
newS.originalType = "enum[]";
|
||||
} else if (
|
||||
t.list == "string" ||
|
||||
(t.list && typeof t.list == "object" && "str" in t.list)
|
||||
) {
|
||||
newS.items = { type: "string", enum: oldS.items?.enum };
|
||||
newS.originalType = "string[]";
|
||||
} else if (
|
||||
t.list &&
|
||||
typeof t.list == "object" &&
|
||||
"resource" in t.list &&
|
||||
t.list.resource
|
||||
) {
|
||||
newS.items = {
|
||||
type: "resource",
|
||||
resourceType: t.list.resource as string,
|
||||
};
|
||||
newS.originalType = "resource[]";
|
||||
} else if (
|
||||
t.list &&
|
||||
typeof t.list == "object" &&
|
||||
"object" in t.list &&
|
||||
t.list.object
|
||||
) {
|
||||
if (t.list.object.name) {
|
||||
newS.format = `resource-${t.list.object.name}`;
|
||||
}
|
||||
if (t.list.object.props && t.list.object.props.length > 0) {
|
||||
const properties: Record<string, any> = {};
|
||||
for (const prop of t.list.object.props) {
|
||||
properties[prop.key] = { description: "", type: "" };
|
||||
argSigToJsonSchemaType(prop.typ, properties[prop.key]);
|
||||
}
|
||||
newS.items = { type: "object", properties: properties };
|
||||
} else {
|
||||
newS.items = { type: "object" };
|
||||
}
|
||||
newS.originalType = "record[]";
|
||||
} else {
|
||||
newS.items = { type: "object" };
|
||||
newS.originalType = "object[]";
|
||||
}
|
||||
} else {
|
||||
newS.type = "object";
|
||||
}
|
||||
|
||||
const preservedFields = [
|
||||
'description',
|
||||
'pattern',
|
||||
'min',
|
||||
'max',
|
||||
'currency',
|
||||
'currencyLocale',
|
||||
'multiselect',
|
||||
'customErrorMessage',
|
||||
'required',
|
||||
'showExpr',
|
||||
'password',
|
||||
'order',
|
||||
'dateFormat',
|
||||
'title',
|
||||
'placeholder'
|
||||
]
|
||||
const preservedFields = [
|
||||
"description",
|
||||
"pattern",
|
||||
"min",
|
||||
"max",
|
||||
"currency",
|
||||
"currencyLocale",
|
||||
"multiselect",
|
||||
"customErrorMessage",
|
||||
"required",
|
||||
"showExpr",
|
||||
"password",
|
||||
"order",
|
||||
"dateFormat",
|
||||
"title",
|
||||
"placeholder",
|
||||
];
|
||||
|
||||
preservedFields.forEach((field) => {
|
||||
// @ts-ignore
|
||||
if (oldS[field] !== undefined) {
|
||||
// @ts-ignore
|
||||
newS[field] = oldS[field]
|
||||
}
|
||||
})
|
||||
preservedFields.forEach((field) => {
|
||||
// @ts-ignore
|
||||
if (oldS[field] !== undefined) {
|
||||
// @ts-ignore
|
||||
newS[field] = oldS[field];
|
||||
}
|
||||
});
|
||||
|
||||
if (oldS.type != newS.type) {
|
||||
for (const prop of Object.getOwnPropertyNames(newS)) {
|
||||
if (prop != 'description') {
|
||||
// @ts-ignore
|
||||
delete oldS[prop]
|
||||
}
|
||||
}
|
||||
} else if ((oldS.format == 'date' || oldS.format === 'date-time') && newS.format == 'string') {
|
||||
newS.format = oldS.format
|
||||
} else if (newS.format == 'date-time' && oldS.format == 'date') {
|
||||
newS.format = 'date'
|
||||
} else if (oldS.items?.type != newS.items?.type) {
|
||||
delete oldS.items
|
||||
}
|
||||
if (oldS.type != newS.type) {
|
||||
for (const prop of Object.getOwnPropertyNames(newS)) {
|
||||
if (prop != "description") {
|
||||
// @ts-ignore
|
||||
delete oldS[prop];
|
||||
}
|
||||
}
|
||||
} else if (
|
||||
(oldS.format == "date" || oldS.format === "date-time") &&
|
||||
newS.format == "string"
|
||||
) {
|
||||
newS.format = oldS.format;
|
||||
} else if (newS.format == "date-time" && oldS.format == "date") {
|
||||
newS.format = "date";
|
||||
} else if (newS.format == "date" || newS.format == "date-time") {
|
||||
newS.format = oldS.format;
|
||||
} else if (oldS.items?.type != newS.items?.type) {
|
||||
delete oldS.items;
|
||||
} else if (oldS.type == "string" && oldS.format != undefined) {
|
||||
newS.format = oldS.format;
|
||||
}
|
||||
|
||||
if (oldS.format && !newS.format) {
|
||||
oldS.format = undefined
|
||||
}
|
||||
if (
|
||||
(oldS.type != newS.type || newS.type != "string") &&
|
||||
newS.format == undefined
|
||||
) {
|
||||
oldS.format = undefined;
|
||||
}
|
||||
|
||||
Object.assign(oldS, newS)
|
||||
|
||||
}
|
||||
Object.assign(oldS, newS);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from "./path-assigner.ts";
|
||||
export * from "./path-assigner";
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RawScript } from "../gen/types.gen.ts";
|
||||
import { RawScript } from "../gen/types.gen";
|
||||
|
||||
const INLINE_SCRIPT_PREFIX = "inline_script";
|
||||
|
||||
|
||||
Generated
+4
-4
@@ -87,7 +87,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.1.0",
|
||||
"windmill-utils-internal": "^1.3.0",
|
||||
"xterm": "^5.3.0",
|
||||
"xterm-readline": "^1.1.2",
|
||||
"y-monaco": "^0.1.4",
|
||||
@@ -12935,9 +12935,9 @@
|
||||
"integrity": "sha512-uHNL8F72/Tf96xF3hOHnPDjkEyqXw7fNjcPJiUhth9sTQkcwUIoJMOdwm8/cs+j9kKVRJ4tgNYMHEBLylazp6g=="
|
||||
},
|
||||
"node_modules/windmill-utils-internal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/windmill-utils-internal/-/windmill-utils-internal-1.1.0.tgz",
|
||||
"integrity": "sha512-Vzm+lNTYR+75hSefDKgjBafNN5OGhhjkdsSElOeS8L1QcgB21DEdLtBmF7mXUGe147deFu36raq/LQzOZ7jqoQ==",
|
||||
"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==",
|
||||
"license": "Apache 2.0"
|
||||
},
|
||||
"node_modules/word-wrap": {
|
||||
|
||||
@@ -154,7 +154,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.1.0",
|
||||
"windmill-utils-internal": "^1.3.0",
|
||||
"xterm": "^5.3.0",
|
||||
"xterm-readline": "^1.1.2",
|
||||
"y-monaco": "^0.1.4",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import type { EnumType } from '$lib/common'
|
||||
import { computeKind } from '$lib/utils'
|
||||
import Label from './Label.svelte'
|
||||
@@ -82,18 +80,18 @@
|
||||
['Pattern', 'pattern']
|
||||
]
|
||||
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
format =
|
||||
kind == 'resource' ? (resource != undefined ? `resource-${resource}` : 'resource') : format
|
||||
})
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
pattern = patternStr == '' ? undefined : patternStr
|
||||
})
|
||||
run(() => {
|
||||
$effect(() => {
|
||||
contentEncoding = kind == 'base64' ? 'base64' : undefined
|
||||
})
|
||||
|
||||
run(() => {
|
||||
$effect.pre(() => {
|
||||
if (format == 'email') {
|
||||
pattern = '^[\\w-+.]+@([\\w-]+\\.)+[\\w-]{2,63}$'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import DarkModeObserver from '$lib/components/DarkModeObserver.svelte'
|
||||
import { untrack } from 'svelte'
|
||||
import { onMount, untrack } from 'svelte'
|
||||
|
||||
/* Forked from MIT LICENSE
|
||||
https://raw.githubusercontent.com/Canutin/svelte-currency-input/main/src/lib/CurrencyInput.svelte
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
|
||||
let {
|
||||
value = $bindable(DEFAULT_VALUE),
|
||||
value = $bindable(),
|
||||
locale = DEFAULT_LOCALE,
|
||||
currency = DEFAULT_CURRENCY,
|
||||
name = DEFAULT_NAME,
|
||||
@@ -58,6 +58,12 @@
|
||||
style = ''
|
||||
}: Props = $props()
|
||||
|
||||
onMount(() => {
|
||||
if (value == undefined) {
|
||||
value = DEFAULT_VALUE
|
||||
}
|
||||
})
|
||||
|
||||
// Formats value as: e.g. $1,523.00 | -$1,523.00
|
||||
const formatCurrency = (
|
||||
value: number,
|
||||
@@ -120,7 +126,7 @@
|
||||
inputTarget = event.target as HTMLInputElement
|
||||
|
||||
// Reverse the value when minus is pressed
|
||||
if (isNegativeAllowed && event.key === '-') value = value * -1
|
||||
if (isNegativeAllowed && event.key === '-') value = (value ?? DEFAULT_VALUE) * -1
|
||||
}
|
||||
|
||||
// Remove all characters that arent: numbers, commas, periods (or minus signs if `isNegativeAllowed`)
|
||||
@@ -160,7 +166,7 @@
|
||||
const previousFormattedValueLength = formattedValue.length
|
||||
|
||||
// Apply formatting to input
|
||||
formattedValue = formatCurrency(value, fractionDigits, 0)
|
||||
formattedValue = formatCurrency(value ?? DEFAULT_VALUE, fractionDigits, 0)
|
||||
|
||||
// Update `value` after formatting
|
||||
setUnformattedValue()
|
||||
@@ -180,7 +186,7 @@
|
||||
let formattedPlaceholder =
|
||||
placeholder !== null ? formatCurrency(placeholder, fractionDigits, fractionDigits) : ''
|
||||
let isZero = $derived(value === 0)
|
||||
let isNegative = $derived(value < 0)
|
||||
let isNegative = $derived((value ?? DEFAULT_VALUE) < 0)
|
||||
$effect(() => {
|
||||
value
|
||||
untrack(() => {
|
||||
|
||||
@@ -249,7 +249,7 @@ export async function inferArgs(
|
||||
} else if (language == 'ruby') {
|
||||
await initWasmRuby()
|
||||
inferedSchema = JSON.parse(parse_ruby(code))
|
||||
// for related places search: ADD_NEW_LANG
|
||||
// for related places search: ADD_NEW_LANG
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user