windmill-utils-internal 1.3.2 → 1.3.4
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/cjs/config/config.js +231 -0
- package/dist/cjs/config/index.js +17 -0
- package/dist/cjs/constants.js +44 -0
- package/dist/cjs/gen/core/ApiError.js +20 -0
- package/dist/cjs/gen/core/ApiRequestOptions.js +2 -0
- package/dist/cjs/gen/core/ApiResult.js +2 -0
- package/dist/cjs/gen/core/CancelablePromise.js +100 -0
- package/dist/cjs/gen/core/OpenAPI.js +39 -0
- package/dist/cjs/gen/core/request.js +323 -0
- package/dist/cjs/gen/index.js +27 -0
- package/dist/{gen → cjs/gen}/services.gen.d.ts +362 -52
- package/dist/cjs/gen/services.gen.js +13121 -0
- package/dist/{gen → cjs/gen}/types.gen.d.ts +1882 -172
- package/dist/cjs/gen/types.gen.js +3 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/inline-scripts/extractor.js +112 -0
- package/dist/cjs/inline-scripts/index.js +18 -0
- package/dist/cjs/inline-scripts/replacer.js +88 -0
- package/dist/cjs/parse/index.js +17 -0
- package/dist/cjs/parse/parse-schema.js +257 -0
- package/dist/cjs/path-utils/index.js +17 -0
- package/dist/cjs/path-utils/path-assigner.js +166 -0
- package/dist/esm/config/config.d.ts +11 -0
- package/dist/esm/config/index.js +1 -0
- package/dist/esm/constants.d.ts +16 -0
- package/dist/esm/gen/core/ApiError.d.ts +10 -0
- package/dist/esm/gen/core/ApiRequestOptions.d.ts +14 -0
- package/dist/esm/gen/core/ApiResult.d.ts +7 -0
- package/dist/esm/gen/core/CancelablePromise.d.ts +26 -0
- package/dist/esm/gen/core/OpenAPI.d.ts +27 -0
- package/dist/{gen → esm/gen}/core/OpenAPI.js +1 -1
- package/dist/esm/gen/core/request.d.ts +29 -0
- package/dist/esm/gen/index.d.ts +5 -0
- package/dist/esm/gen/services.gen.d.ts +6126 -0
- package/dist/{gen → esm/gen}/services.gen.js +744 -131
- package/dist/esm/gen/types.gen.d.ts +11636 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/inline-scripts/extractor.d.ts +41 -0
- package/dist/{inline-scripts → esm/inline-scripts}/extractor.js +34 -12
- package/dist/esm/inline-scripts/index.js +2 -0
- package/dist/esm/inline-scripts/replacer.d.ts +16 -0
- package/dist/esm/inline-scripts/replacer.js +85 -0
- package/dist/esm/parse/index.js +1 -0
- package/dist/esm/parse/parse-schema.d.ts +98 -0
- package/dist/{parse → esm/parse}/parse-schema.js +4 -0
- package/dist/esm/path-utils/index.js +1 -0
- package/dist/esm/path-utils/path-assigner.d.ts +58 -0
- package/dist/{path-utils → esm/path-utils}/path-assigner.js +2 -0
- package/package.json +14 -4
- package/dist/inline-scripts/replacer.js +0 -93
- /package/dist/{config → cjs/config}/config.d.ts +0 -0
- /package/dist/{config → cjs/config}/index.d.ts +0 -0
- /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
- /package/dist/{gen → cjs/gen}/core/ApiError.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/core/ApiRequestOptions.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/core/ApiResult.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/core/CancelablePromise.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/core/OpenAPI.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/core/request.d.ts +0 -0
- /package/dist/{gen → cjs/gen}/index.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{inline-scripts → cjs/inline-scripts}/extractor.d.ts +0 -0
- /package/dist/{inline-scripts → cjs/inline-scripts}/index.d.ts +0 -0
- /package/dist/{inline-scripts → cjs/inline-scripts}/replacer.d.ts +0 -0
- /package/dist/{parse → cjs/parse}/index.d.ts +0 -0
- /package/dist/{parse → cjs/parse}/parse-schema.d.ts +0 -0
- /package/dist/{path-utils → cjs/path-utils}/index.d.ts +0 -0
- /package/dist/{path-utils → cjs/path-utils}/path-assigner.d.ts +0 -0
- /package/dist/{config → esm/config}/config.js +0 -0
- /package/dist/{config/index.js → esm/config/index.d.ts} +0 -0
- /package/dist/{constants.js → esm/constants.js} +0 -0
- /package/dist/{gen → esm/gen}/core/ApiError.js +0 -0
- /package/dist/{gen → esm/gen}/core/ApiRequestOptions.js +0 -0
- /package/dist/{gen → esm/gen}/core/ApiResult.js +0 -0
- /package/dist/{gen → esm/gen}/core/CancelablePromise.js +0 -0
- /package/dist/{gen → esm/gen}/core/request.js +0 -0
- /package/dist/{gen → esm/gen}/index.js +0 -0
- /package/dist/{gen → esm/gen}/types.gen.js +0 -0
- /package/dist/{index.js → esm/index.d.ts} +0 -0
- /package/dist/{inline-scripts/index.js → esm/inline-scripts/index.d.ts} +0 -0
- /package/dist/{parse/index.js → esm/parse/index.d.ts} +0 -0
- /package/dist/{path-utils/index.js → esm/path-utils/index.d.ts} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for windmill-utils-internal package
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities for handling Windmill flows, scripts, and schemas:
|
|
5
|
+
* - Inline script extraction and replacement
|
|
6
|
+
* - Path utilities for different programming languages
|
|
7
|
+
* - Schema parsing and conversion utilities
|
|
8
|
+
* - Cross-platform path constants
|
|
9
|
+
*/
|
|
10
|
+
export * from "./inline-scripts";
|
|
11
|
+
export * from "./path-utils";
|
|
12
|
+
export * from "./parse";
|
|
13
|
+
export * from "./config";
|
|
14
|
+
export { SEP, DELIMITER } from "./constants";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PathAssigner } from "../path-utils/path-assigner";
|
|
2
|
+
import { FlowModule } from "../gen/types.gen";
|
|
3
|
+
/**
|
|
4
|
+
* Represents an inline script extracted from a flow module
|
|
5
|
+
*/
|
|
6
|
+
interface InlineScript {
|
|
7
|
+
/** File path where the script content should be written */
|
|
8
|
+
path: string;
|
|
9
|
+
/** The actual script content */
|
|
10
|
+
content: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for extractInlineScripts function
|
|
14
|
+
*/
|
|
15
|
+
export interface ExtractInlineScriptsOptions {
|
|
16
|
+
/** When true, skip the .inline_script. suffix in file names */
|
|
17
|
+
skipInlineScriptSuffix?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Extracts inline scripts from flow modules, converting them to separate files
|
|
21
|
+
* and replacing the original content with file references.
|
|
22
|
+
*
|
|
23
|
+
* @param modules - Array of flow modules to process
|
|
24
|
+
* @param mapping - Optional mapping of module IDs to custom file paths
|
|
25
|
+
* @param separator - Path separator to use
|
|
26
|
+
* @param defaultTs - Default TypeScript runtime to use ("bun" or "deno")
|
|
27
|
+
* @param pathAssigner - Optional path assigner to reuse (for nested calls)
|
|
28
|
+
* @param options - Optional configuration options
|
|
29
|
+
* @returns Array of inline scripts with their paths and content
|
|
30
|
+
*/
|
|
31
|
+
export declare function extractInlineScripts(modules: FlowModule[], mapping?: Record<string, string>, separator?: string, defaultTs?: "bun" | "deno", pathAssigner?: PathAssigner, options?: ExtractInlineScriptsOptions): InlineScript[];
|
|
32
|
+
/**
|
|
33
|
+
* Extracts the current mapping of module IDs to file paths from flow modules
|
|
34
|
+
* by analyzing existing inline script references.
|
|
35
|
+
*
|
|
36
|
+
* @param modules - Array of flow modules to analyze (can be undefined)
|
|
37
|
+
* @param mapping - Existing mapping to extend (defaults to empty object)
|
|
38
|
+
* @returns Record mapping module IDs to their corresponding file paths
|
|
39
|
+
*/
|
|
40
|
+
export declare function extractCurrentMapping(modules: FlowModule[] | undefined, mapping?: Record<string, string>): Record<string, string>;
|
|
41
|
+
export {};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { newPathAssigner } from "../path-utils/path-assigner";
|
|
2
|
+
function extractRawscriptInline(id, summary, rawscript, mapping, separator, assigner) {
|
|
3
|
+
const [basePath, ext] = assigner.assignPath(summary ?? id, rawscript.language);
|
|
4
|
+
const path = mapping[id] ?? basePath + ext;
|
|
5
|
+
const content = rawscript.content;
|
|
6
|
+
const r = [{ path: path, content: content }];
|
|
7
|
+
rawscript.content = "!inline " + path.replaceAll(separator, "/");
|
|
8
|
+
const lock = rawscript.lock;
|
|
9
|
+
if (lock && lock != "") {
|
|
10
|
+
const lockPath = basePath + "lock";
|
|
11
|
+
rawscript.lock = "!inline " + lockPath.replaceAll(separator, "/");
|
|
12
|
+
r.push({ path: lockPath, content: lock });
|
|
13
|
+
}
|
|
14
|
+
return r;
|
|
15
|
+
}
|
|
2
16
|
/**
|
|
3
17
|
* Extracts inline scripts from flow modules, converting them to separate files
|
|
4
18
|
* and replacing the original content with file references.
|
|
@@ -16,18 +30,7 @@ export function extractInlineScripts(modules, mapping = {}, separator = "/", def
|
|
|
16
30
|
const assigner = pathAssigner ?? newPathAssigner(defaultTs ?? "bun", { skipInlineScriptSuffix: options?.skipInlineScriptSuffix });
|
|
17
31
|
return modules.flatMap((m) => {
|
|
18
32
|
if (m.value.type == "rawscript") {
|
|
19
|
-
|
|
20
|
-
const path = mapping[m.id] ?? basePath + ext;
|
|
21
|
-
const content = m.value.content;
|
|
22
|
-
const r = [{ path: path, content: content }];
|
|
23
|
-
m.value.content = "!inline " + path.replaceAll(separator, "/");
|
|
24
|
-
const lock = m.value.lock;
|
|
25
|
-
if (lock && lock != "") {
|
|
26
|
-
const lockPath = basePath + "lock";
|
|
27
|
-
m.value.lock = "!inline " + lockPath.replaceAll(separator, "/");
|
|
28
|
-
r.push({ path: lockPath, content: lock });
|
|
29
|
-
}
|
|
30
|
-
return r;
|
|
33
|
+
return extractRawscriptInline(m.id, m.summary, m.value, mapping, separator, assigner);
|
|
31
34
|
}
|
|
32
35
|
else if (m.value.type == "forloopflow") {
|
|
33
36
|
return extractInlineScripts(m.value.modules, mapping, separator, defaultTs, assigner);
|
|
@@ -44,6 +47,16 @@ export function extractInlineScripts(modules, mapping = {}, separator = "/", def
|
|
|
44
47
|
...extractInlineScripts(m.value.default, mapping, separator, defaultTs, assigner),
|
|
45
48
|
];
|
|
46
49
|
}
|
|
50
|
+
else if (m.value.type == "aiagent") {
|
|
51
|
+
return (m.value.tools ?? []).flatMap((tool) => {
|
|
52
|
+
const toolValue = tool.value;
|
|
53
|
+
// Only process flowmodule tools with rawscript type
|
|
54
|
+
if (!toolValue || toolValue.tool_type !== 'flowmodule' || toolValue.type !== 'rawscript') {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
return extractRawscriptInline(tool.id, tool.summary, toolValue, mapping, separator, assigner);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
47
60
|
else {
|
|
48
61
|
return [];
|
|
49
62
|
}
|
|
@@ -81,6 +94,15 @@ export function extractCurrentMapping(modules, mapping = {}) {
|
|
|
81
94
|
m.value.branches.forEach((b) => extractCurrentMapping(b.modules, mapping));
|
|
82
95
|
extractCurrentMapping(m.value.default, mapping);
|
|
83
96
|
}
|
|
97
|
+
else if (m.value.type === "aiagent") {
|
|
98
|
+
(m.value.tools ?? []).forEach((tool) => {
|
|
99
|
+
const toolValue = tool.value;
|
|
100
|
+
if (!toolValue || toolValue.tool_type !== 'flowmodule' || toolValue.type !== 'rawscript' || !toolValue.content || !toolValue.content.startsWith("!inline")) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
mapping[tool.id] = toolValue.content.trim().split(" ")[1];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
84
106
|
});
|
|
85
107
|
return mapping;
|
|
86
108
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FlowModule } from "../gen/types.gen";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces inline script references with actual file content from the filesystem.
|
|
4
|
+
* This function recursively processes all flow modules and their nested structures.
|
|
5
|
+
*
|
|
6
|
+
* @param modules - Array of flow modules to process
|
|
7
|
+
* @param fileReader - Function to read file content (typically fs.readFile or similar)
|
|
8
|
+
* @param logger - Optional logger object with info and error methods
|
|
9
|
+
* @param localPath - Base path for resolving relative file paths
|
|
10
|
+
* @param removeLocks - Optional array of paths for which to remove lock files
|
|
11
|
+
* @returns Promise that resolves when all inline scripts have been replaced
|
|
12
|
+
*/
|
|
13
|
+
export declare function replaceInlineScripts(modules: FlowModule[], fileReader: (path: string) => Promise<string>, logger: {
|
|
14
|
+
info: (message: string) => void;
|
|
15
|
+
error: (message: string) => void;
|
|
16
|
+
} | undefined, localPath: string, separator?: string, removeLocks?: string[]): Promise<void>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
async function replaceRawscriptInline(id, rawscript, fileReader, logger, separator, removeLocks) {
|
|
2
|
+
if (!rawscript.content || !rawscript.content.startsWith("!inline")) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
const path = rawscript.content.split(" ")[1];
|
|
6
|
+
const pathSuffix = path.split(".").slice(1).join(".");
|
|
7
|
+
const newPath = id + "." + pathSuffix;
|
|
8
|
+
try {
|
|
9
|
+
rawscript.content = await fileReader(path);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
logger.error(`Script file ${path} not found`);
|
|
13
|
+
try {
|
|
14
|
+
rawscript.content = await fileReader(newPath);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
logger.error(`Script file ${newPath} not found`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const lock = rawscript.lock;
|
|
21
|
+
if (removeLocks && removeLocks.includes(path)) {
|
|
22
|
+
rawscript.lock = undefined;
|
|
23
|
+
}
|
|
24
|
+
else if (lock &&
|
|
25
|
+
typeof lock === "string" &&
|
|
26
|
+
lock.trimStart().startsWith("!inline ")) {
|
|
27
|
+
const lockPath = lock.split(" ")[1];
|
|
28
|
+
try {
|
|
29
|
+
rawscript.lock = await fileReader(lockPath.replaceAll("/", separator));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
logger.error(`Lock file ${lockPath} not found, treating as empty`);
|
|
33
|
+
rawscript.lock = "";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Replaces inline script references with actual file content from the filesystem.
|
|
39
|
+
* This function recursively processes all flow modules and their nested structures.
|
|
40
|
+
*
|
|
41
|
+
* @param modules - Array of flow modules to process
|
|
42
|
+
* @param fileReader - Function to read file content (typically fs.readFile or similar)
|
|
43
|
+
* @param logger - Optional logger object with info and error methods
|
|
44
|
+
* @param localPath - Base path for resolving relative file paths
|
|
45
|
+
* @param removeLocks - Optional array of paths for which to remove lock files
|
|
46
|
+
* @returns Promise that resolves when all inline scripts have been replaced
|
|
47
|
+
*/
|
|
48
|
+
export async function replaceInlineScripts(modules, fileReader, logger = {
|
|
49
|
+
info: () => { },
|
|
50
|
+
error: () => { },
|
|
51
|
+
}, localPath, separator = "/", removeLocks) {
|
|
52
|
+
await Promise.all(modules.map(async (module) => {
|
|
53
|
+
if (!module.value) {
|
|
54
|
+
throw new Error(`Module value is undefined for module ${module.id}`);
|
|
55
|
+
}
|
|
56
|
+
if (module.value.type === "rawscript") {
|
|
57
|
+
await replaceRawscriptInline(module.id, module.value, fileReader, logger, separator, removeLocks);
|
|
58
|
+
}
|
|
59
|
+
else if (module.value.type === "forloopflow" || module.value.type === "whileloopflow") {
|
|
60
|
+
await replaceInlineScripts(module.value.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
61
|
+
}
|
|
62
|
+
else if (module.value.type === "branchall") {
|
|
63
|
+
await Promise.all(module.value.branches.map(async (branch) => {
|
|
64
|
+
await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
else if (module.value.type === "branchone") {
|
|
68
|
+
await Promise.all(module.value.branches.map(async (branch) => {
|
|
69
|
+
await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
70
|
+
}));
|
|
71
|
+
await replaceInlineScripts(module.value.default, fileReader, logger, localPath, separator, removeLocks);
|
|
72
|
+
}
|
|
73
|
+
else if (module.value.type === "aiagent") {
|
|
74
|
+
await Promise.all((module.value.tools ?? []).map(async (tool) => {
|
|
75
|
+
const toolValue = tool.value;
|
|
76
|
+
if (!toolValue ||
|
|
77
|
+
toolValue.tool_type !== "flowmodule" ||
|
|
78
|
+
toolValue.type !== "rawscript") {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await replaceRawscriptInline(tool.id, toolValue, fileReader, logger, separator, removeLocks);
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./parse-schema";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type alias for enum values - can be an array of strings or undefined
|
|
3
|
+
*/
|
|
4
|
+
export type EnumType = string[] | {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[] | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Represents a property in a JSON schema with various validation and display options
|
|
10
|
+
*/
|
|
11
|
+
export interface SchemaProperty {
|
|
12
|
+
type: string | undefined;
|
|
13
|
+
description?: string;
|
|
14
|
+
pattern?: string;
|
|
15
|
+
default?: any;
|
|
16
|
+
enum?: EnumType;
|
|
17
|
+
contentEncoding?: "base64" | "binary";
|
|
18
|
+
format?: string;
|
|
19
|
+
items?: {
|
|
20
|
+
type?: "string" | "number" | "bytes" | "object" | "resource";
|
|
21
|
+
contentEncoding?: "base64";
|
|
22
|
+
enum?: EnumType;
|
|
23
|
+
resourceType?: string;
|
|
24
|
+
properties?: {
|
|
25
|
+
[name: string]: SchemaProperty;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
currency?: string;
|
|
31
|
+
currencyLocale?: string;
|
|
32
|
+
multiselect?: boolean;
|
|
33
|
+
customErrorMessage?: string;
|
|
34
|
+
properties?: {
|
|
35
|
+
[name: string]: SchemaProperty;
|
|
36
|
+
};
|
|
37
|
+
required?: string[];
|
|
38
|
+
showExpr?: string;
|
|
39
|
+
password?: boolean;
|
|
40
|
+
order?: string[];
|
|
41
|
+
nullable?: boolean;
|
|
42
|
+
dateFormat?: string;
|
|
43
|
+
title?: string;
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
oneOf?: SchemaProperty[];
|
|
46
|
+
originalType?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Converts argument signature types to JSON schema properties.
|
|
50
|
+
* This function handles various Windmill-specific types and converts them
|
|
51
|
+
* to standard JSON schema format while preserving existing property metadata.
|
|
52
|
+
*
|
|
53
|
+
* @param t - The argument signature type definition (can be string or complex object types)
|
|
54
|
+
* @param oldS - Existing schema property to update with new type information
|
|
55
|
+
*/
|
|
56
|
+
export declare function argSigToJsonSchemaType(t: string | {
|
|
57
|
+
resource: string | null;
|
|
58
|
+
} | {
|
|
59
|
+
list: (string | {
|
|
60
|
+
name?: string;
|
|
61
|
+
props?: {
|
|
62
|
+
key: string;
|
|
63
|
+
typ: any;
|
|
64
|
+
}[];
|
|
65
|
+
}) | {
|
|
66
|
+
str: any;
|
|
67
|
+
} | {
|
|
68
|
+
object: {
|
|
69
|
+
name?: string;
|
|
70
|
+
props?: {
|
|
71
|
+
key: string;
|
|
72
|
+
typ: any;
|
|
73
|
+
}[];
|
|
74
|
+
};
|
|
75
|
+
} | null;
|
|
76
|
+
} | {
|
|
77
|
+
dynselect: string;
|
|
78
|
+
} | {
|
|
79
|
+
dynmultiselect: string;
|
|
80
|
+
} | {
|
|
81
|
+
str: string[] | null;
|
|
82
|
+
} | {
|
|
83
|
+
object: {
|
|
84
|
+
name?: string;
|
|
85
|
+
props?: {
|
|
86
|
+
key: string;
|
|
87
|
+
typ: any;
|
|
88
|
+
}[];
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
oneof: {
|
|
92
|
+
label: string;
|
|
93
|
+
properties: {
|
|
94
|
+
key: string;
|
|
95
|
+
typ: any;
|
|
96
|
+
}[];
|
|
97
|
+
}[];
|
|
98
|
+
}, oldS: SchemaProperty): void;
|
|
@@ -47,6 +47,10 @@ export function argSigToJsonSchemaType(t, oldS) {
|
|
|
47
47
|
newS.type = "string";
|
|
48
48
|
newS.format = "date-time";
|
|
49
49
|
}
|
|
50
|
+
else if (t === "date") {
|
|
51
|
+
newS.type = "string";
|
|
52
|
+
newS.format = "date";
|
|
53
|
+
}
|
|
50
54
|
else if (typeof t !== "string" && "oneof" in t) {
|
|
51
55
|
newS.type = "object";
|
|
52
56
|
if (t.oneof) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./path-assigner";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RawScript } from "../gen/types.gen";
|
|
2
|
+
/**
|
|
3
|
+
* Union type of all supported programming languages in Windmill
|
|
4
|
+
*/
|
|
5
|
+
export type SupportedLanguage = RawScript["language"] | "frontend" | "bunnative" | "oracledb" | "rust" | "csharp" | "nu" | "ansible" | "java" | "duckdb";
|
|
6
|
+
/**
|
|
7
|
+
* Mapping of supported languages to their file extensions
|
|
8
|
+
*/
|
|
9
|
+
export declare const LANGUAGE_EXTENSIONS: Record<SupportedLanguage, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the appropriate file extension for a given programming language.
|
|
12
|
+
* Handles special cases for TypeScript variants based on the default runtime.
|
|
13
|
+
*
|
|
14
|
+
* @param language - The programming language to get extension for
|
|
15
|
+
* @param defaultTs - Default TypeScript runtime ("bun" or "deno")
|
|
16
|
+
* @returns File extension string (without the dot)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getLanguageExtension(language: SupportedLanguage, defaultTs?: "bun" | "deno"): string;
|
|
19
|
+
/**
|
|
20
|
+
* Reverse mapping from file extensions to languages.
|
|
21
|
+
* Used when deriving language from file extension.
|
|
22
|
+
*/
|
|
23
|
+
export declare const EXTENSION_TO_LANGUAGE: Record<string, SupportedLanguage>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the language from a file extension.
|
|
26
|
+
*
|
|
27
|
+
* @param ext - File extension (e.g., "py", "ts", "bun.ts")
|
|
28
|
+
* @param defaultTs - Default TypeScript runtime for plain .ts files
|
|
29
|
+
* @returns The language, or undefined if not recognized
|
|
30
|
+
*/
|
|
31
|
+
export declare function getLanguageFromExtension(ext: string, defaultTs?: "bun" | "deno"): SupportedLanguage | undefined;
|
|
32
|
+
export interface PathAssigner {
|
|
33
|
+
assignPath(summary: string | undefined, language: SupportedLanguage): [string, string];
|
|
34
|
+
}
|
|
35
|
+
export interface PathAssignerOptions {
|
|
36
|
+
defaultTs: "bun" | "deno";
|
|
37
|
+
/** When true, skip the .inline_script. suffix in file names */
|
|
38
|
+
skipInlineScriptSuffix?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new path assigner for inline scripts.
|
|
42
|
+
*
|
|
43
|
+
* @param defaultTs - Default TypeScript runtime ("bun" or "deno")
|
|
44
|
+
* @param options - Optional configuration (can pass options object instead of defaultTs)
|
|
45
|
+
* @returns Path assigner function
|
|
46
|
+
*/
|
|
47
|
+
export declare function newPathAssigner(defaultTs: "bun" | "deno" | PathAssignerOptions, options?: {
|
|
48
|
+
skipInlineScriptSuffix?: boolean;
|
|
49
|
+
}): PathAssigner;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new path assigner for raw app runnables.
|
|
52
|
+
* Unlike newPathAssigner, this does NOT add ".inline_script." prefix since
|
|
53
|
+
* everything in raw_app/backend/ is already known to be for inline scripts.
|
|
54
|
+
*
|
|
55
|
+
* @param defaultTs - Default TypeScript runtime ("bun" or "deno")
|
|
56
|
+
* @returns Path assigner function
|
|
57
|
+
*/
|
|
58
|
+
export declare function newRawAppPathAssigner(defaultTs: "bun" | "deno"): PathAssigner;
|
|
@@ -26,6 +26,7 @@ export const LANGUAGE_EXTENSIONS = {
|
|
|
26
26
|
java: "java",
|
|
27
27
|
duckdb: "duckdb.sql",
|
|
28
28
|
bunnative: "ts",
|
|
29
|
+
ruby: "rb",
|
|
29
30
|
// for related places search: ADD_NEW_LANG
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
@@ -69,6 +70,7 @@ export const EXTENSION_TO_LANGUAGE = {
|
|
|
69
70
|
"playbook.yml": "ansible",
|
|
70
71
|
"java": "java",
|
|
71
72
|
"duckdb.sql": "duckdb",
|
|
73
|
+
"rb": "ruby",
|
|
72
74
|
// Plain .ts defaults to bun (will be overridden by defaultTs setting)
|
|
73
75
|
"ts": "bun",
|
|
74
76
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-utils-internal",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Internal utility functions for Windmill",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/cjs/index.js",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"types": "./dist/esm/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"scripts": {
|
|
8
16
|
"dev": "./gen_wm_client.sh && ./remove-ts-ext.sh",
|
|
9
|
-
"build": "
|
|
17
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
18
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
19
|
+
"build": "./gen_wm_client.sh && ./remove-ts-ext.sh && npm run build:cjs && npm run build:esm",
|
|
10
20
|
"prepublishOnly": "npm run build"
|
|
11
21
|
},
|
|
12
22
|
"keywords": [
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replaces inline script references with actual file content from the filesystem.
|
|
3
|
-
* This function recursively processes all flow modules and their nested structures.
|
|
4
|
-
*
|
|
5
|
-
* @param modules - Array of flow modules to process
|
|
6
|
-
* @param fileReader - Function to read file content (typically fs.readFile or similar)
|
|
7
|
-
* @param logger - Optional logger object with info and error methods
|
|
8
|
-
* @param localPath - Base path for resolving relative file paths
|
|
9
|
-
* @param removeLocks - Optional array of paths for which to remove lock files
|
|
10
|
-
* @returns Promise that resolves when all inline scripts have been replaced
|
|
11
|
-
*/
|
|
12
|
-
export async function replaceInlineScripts(modules, fileReader, logger = {
|
|
13
|
-
info: () => { },
|
|
14
|
-
error: () => { },
|
|
15
|
-
}, localPath, separator = "/", removeLocks) {
|
|
16
|
-
await Promise.all(modules.map(async (module) => {
|
|
17
|
-
if (!module.value) {
|
|
18
|
-
throw new Error(`Module value is undefined for module ${module.id}`);
|
|
19
|
-
}
|
|
20
|
-
if (module.value.type === "rawscript" && module.value.content && module.value.content.startsWith("!inline")) {
|
|
21
|
-
const path = module.value.content.split(" ")[1];
|
|
22
|
-
// const pathPrefix = path.split(".")[0];
|
|
23
|
-
const pathSuffix = path.split(".").slice(1).join(".");
|
|
24
|
-
// new path is the module id with the same suffix
|
|
25
|
-
const newPath = module.id + "." + pathSuffix;
|
|
26
|
-
try {
|
|
27
|
-
module.value.content = await fileReader(path);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
logger.error(`Script file ${path} not found`);
|
|
31
|
-
// try new path
|
|
32
|
-
try {
|
|
33
|
-
module.value.content = await fileReader(newPath);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
logger.error(`Script file ${newPath} not found`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// rename the file if the prefix is different from the module id (fix old naming)
|
|
40
|
-
// if (pathPrefix != module.id && renamer) {
|
|
41
|
-
// logger.info(`Renaming ${path} to ${module.id}.${pathSuffix}`);
|
|
42
|
-
// try {
|
|
43
|
-
// renamer(localPath + path, localPath + module.id + "." + pathSuffix);
|
|
44
|
-
// } catch {
|
|
45
|
-
// logger.info(`Failed to rename ${path} to ${module.id}.${pathSuffix}`);
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
const lock = module.value.lock;
|
|
49
|
-
if (removeLocks && removeLocks.includes(path)) {
|
|
50
|
-
module.value.lock = undefined;
|
|
51
|
-
// delete the file if the prefix is different from the module id (fix old naming)
|
|
52
|
-
// if (lock && lock != "") {
|
|
53
|
-
// const path = lock.split(" ")[1];
|
|
54
|
-
// const pathPrefix = path.split(".")[0];
|
|
55
|
-
// if (pathPrefix != module.id && deleter) {
|
|
56
|
-
// logger.info(`Deleting ${path}`);
|
|
57
|
-
// try {
|
|
58
|
-
// deleter(localPath + path);
|
|
59
|
-
// } catch {
|
|
60
|
-
// logger.error(`Failed to delete ${path}`);
|
|
61
|
-
// }
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
}
|
|
65
|
-
else if (lock &&
|
|
66
|
-
typeof lock == "string" &&
|
|
67
|
-
lock.trimStart().startsWith("!inline ")) {
|
|
68
|
-
const path = lock.split(" ")[1];
|
|
69
|
-
try {
|
|
70
|
-
module.value.lock = await fileReader(path.replaceAll("/", separator));
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
logger.error(`Lock file ${path} not found, treating as empty`);
|
|
74
|
-
module.value.lock = "";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (module.value.type === "forloopflow" || module.value.type === "whileloopflow") {
|
|
79
|
-
await replaceInlineScripts(module.value.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
80
|
-
}
|
|
81
|
-
else if (module.value.type === "branchall") {
|
|
82
|
-
await Promise.all(module.value.branches.map(async (branch) => {
|
|
83
|
-
await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
else if (module.value.type === "branchone") {
|
|
87
|
-
await Promise.all(module.value.branches.map(async (branch) => {
|
|
88
|
-
await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
|
|
89
|
-
}));
|
|
90
|
-
await replaceInlineScripts(module.value.default, fileReader, logger, localPath, separator, removeLocks);
|
|
91
|
-
}
|
|
92
|
-
}));
|
|
93
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|