windmill-utils-internal 1.3.0 → 1.3.2

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.
@@ -1,3 +1,2 @@
1
- "use strict";
2
1
  // This file is auto-generated by @hey-api/openapi-ts
3
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ export {};
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * @fileoverview Main entry point for windmill-utils-internal package
4
3
  *
@@ -8,26 +7,8 @@
8
7
  * - Schema parsing and conversion utilities
9
8
  * - Cross-platform path constants
10
9
  */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.DELIMITER = exports.SEP = void 0;
27
- __exportStar(require("./inline-scripts"), exports);
28
- __exportStar(require("./path-utils"), exports);
29
- __exportStar(require("./parse"), exports);
30
- __exportStar(require("./config"), exports);
31
- var constants_1 = require("./constants");
32
- Object.defineProperty(exports, "SEP", { enumerable: true, get: function () { return constants_1.SEP; } });
33
- Object.defineProperty(exports, "DELIMITER", { enumerable: true, get: function () { return constants_1.DELIMITER; } });
10
+ export * from "./inline-scripts";
11
+ export * from "./path-utils";
12
+ export * from "./parse";
13
+ export * from "./config";
14
+ export { SEP, DELIMITER } from "./constants";
@@ -1,3 +1,4 @@
1
+ import { PathAssigner } from "../path-utils/path-assigner";
1
2
  import { FlowModule } from "../gen/types.gen";
2
3
  /**
3
4
  * Represents an inline script extracted from a flow module
@@ -8,16 +9,26 @@ interface InlineScript {
8
9
  /** The actual script content */
9
10
  content: string;
10
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
+ }
11
19
  /**
12
20
  * Extracts inline scripts from flow modules, converting them to separate files
13
21
  * and replacing the original content with file references.
14
22
  *
15
23
  * @param modules - Array of flow modules to process
16
24
  * @param mapping - Optional mapping of module IDs to custom file paths
25
+ * @param separator - Path separator to use
17
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
18
29
  * @returns Array of inline scripts with their paths and content
19
30
  */
20
- export declare function extractInlineScripts(modules: FlowModule[], mapping?: Record<string, string>, separator?: string, defaultTs?: "bun" | "deno"): InlineScript[];
31
+ export declare function extractInlineScripts(modules: FlowModule[], mapping?: Record<string, string>, separator?: string, defaultTs?: "bun" | "deno", pathAssigner?: PathAssigner, options?: ExtractInlineScriptsOptions): InlineScript[];
21
32
  /**
22
33
  * Extracts the current mapping of module IDs to file paths from flow modules
23
34
  * by analyzing existing inline script references.
@@ -1,23 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractInlineScripts = extractInlineScripts;
4
- exports.extractCurrentMapping = extractCurrentMapping;
5
- const path_assigner_1 = require("../path-utils/path-assigner");
1
+ import { newPathAssigner } from "../path-utils/path-assigner";
6
2
  /**
7
3
  * Extracts inline scripts from flow modules, converting them to separate files
8
4
  * and replacing the original content with file references.
9
5
  *
10
6
  * @param modules - Array of flow modules to process
11
7
  * @param mapping - Optional mapping of module IDs to custom file paths
8
+ * @param separator - Path separator to use
12
9
  * @param defaultTs - Default TypeScript runtime to use ("bun" or "deno")
10
+ * @param pathAssigner - Optional path assigner to reuse (for nested calls)
11
+ * @param options - Optional configuration options
13
12
  * @returns Array of inline scripts with their paths and content
14
13
  */
15
- function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs) {
16
- const pathAssigner = (0, path_assigner_1.newPathAssigner)(defaultTs ?? "bun");
14
+ export function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs, pathAssigner, options) {
15
+ // Create pathAssigner only if not provided (top-level call), but reuse it for nested calls
16
+ const assigner = pathAssigner ?? newPathAssigner(defaultTs ?? "bun", { skipInlineScriptSuffix: options?.skipInlineScriptSuffix });
17
17
  return modules.flatMap((m) => {
18
18
  if (m.value.type == "rawscript") {
19
- let basePath, ext;
20
- [basePath, ext] = pathAssigner.assignPath(m.summary, m.value.language);
19
+ const [basePath, ext] = assigner.assignPath(m.summary, m.value.language);
21
20
  const path = mapping[m.id] ?? basePath + ext;
22
21
  const content = m.value.content;
23
22
  const r = [{ path: path, content: content }];
@@ -31,18 +30,18 @@ function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs)
31
30
  return r;
32
31
  }
33
32
  else if (m.value.type == "forloopflow") {
34
- return extractInlineScripts(m.value.modules, mapping, separator, defaultTs);
33
+ return extractInlineScripts(m.value.modules, mapping, separator, defaultTs, assigner);
35
34
  }
36
35
  else if (m.value.type == "branchall") {
37
- return m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs));
36
+ return m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs, assigner));
38
37
  }
39
38
  else if (m.value.type == "whileloopflow") {
40
- return extractInlineScripts(m.value.modules, mapping, separator, defaultTs);
39
+ return extractInlineScripts(m.value.modules, mapping, separator, defaultTs, assigner);
41
40
  }
42
41
  else if (m.value.type == "branchone") {
43
42
  return [
44
- ...m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs)),
45
- ...extractInlineScripts(m.value.default, mapping, separator, defaultTs),
43
+ ...m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs, assigner)),
44
+ ...extractInlineScripts(m.value.default, mapping, separator, defaultTs, assigner),
46
45
  ];
47
46
  }
48
47
  else {
@@ -58,7 +57,7 @@ function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs)
58
57
  * @param mapping - Existing mapping to extend (defaults to empty object)
59
58
  * @returns Record mapping module IDs to their corresponding file paths
60
59
  */
61
- function extractCurrentMapping(modules, mapping = {}) {
60
+ export function extractCurrentMapping(modules, mapping = {}) {
62
61
  if (!modules || !Array.isArray(modules)) {
63
62
  return mapping;
64
63
  }
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./replacer"), exports);
18
- __exportStar(require("./extractor"), exports);
1
+ export * from "./replacer";
2
+ export * from "./extractor";
@@ -13,4 +13,4 @@ import { FlowModule } from "../gen/types.gen";
13
13
  export declare function replaceInlineScripts(modules: FlowModule[], fileReader: (path: string) => Promise<string>, logger: {
14
14
  info: (message: string) => void;
15
15
  error: (message: string) => void;
16
- } | undefined, localPath: string, separator?: string, removeLocks?: string[], renamer?: (path: string, newPath: string) => void, deleter?: (path: string) => void): Promise<void>;
16
+ } | undefined, localPath: string, separator?: string, removeLocks?: string[]): Promise<void>;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceInlineScripts = replaceInlineScripts;
4
1
  /**
5
2
  * Replaces inline script references with actual file content from the filesystem.
6
3
  * This function recursively processes all flow modules and their nested structures.
@@ -12,17 +9,17 @@ exports.replaceInlineScripts = replaceInlineScripts;
12
9
  * @param removeLocks - Optional array of paths for which to remove lock files
13
10
  * @returns Promise that resolves when all inline scripts have been replaced
14
11
  */
15
- async function replaceInlineScripts(modules, fileReader, logger = {
12
+ export async function replaceInlineScripts(modules, fileReader, logger = {
16
13
  info: () => { },
17
14
  error: () => { },
18
- }, localPath, separator = "/", removeLocks, renamer, deleter) {
15
+ }, localPath, separator = "/", removeLocks) {
19
16
  await Promise.all(modules.map(async (module) => {
20
17
  if (!module.value) {
21
18
  throw new Error(`Module value is undefined for module ${module.id}`);
22
19
  }
23
20
  if (module.value.type === "rawscript" && module.value.content && module.value.content.startsWith("!inline")) {
24
21
  const path = module.value.content.split(" ")[1];
25
- const pathPrefix = path.split(".")[0];
22
+ // const pathPrefix = path.split(".")[0];
26
23
  const pathSuffix = path.split(".").slice(1).join(".");
27
24
  // new path is the module id with the same suffix
28
25
  const newPath = module.id + "." + pathSuffix;
@@ -73,7 +70,8 @@ async function replaceInlineScripts(modules, fileReader, logger = {
73
70
  module.value.lock = await fileReader(path.replaceAll("/", separator));
74
71
  }
75
72
  catch {
76
- logger.error(`Lock file ${path} not found`);
73
+ logger.error(`Lock file ${path} not found, treating as empty`);
74
+ module.value.lock = "";
77
75
  }
78
76
  }
79
77
  }
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./parse-schema"), exports);
1
+ export * from "./parse-schema";
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * Type alias for enum values - can be an array of strings or undefined
3
3
  */
4
- export type EnumType = string[] | undefined;
4
+ export type EnumType = string[] | {
5
+ label: string;
6
+ value: string;
7
+ }[] | undefined;
5
8
  /**
6
9
  * Represents a property in a JSON schema with various validation and display options
7
10
  */
@@ -16,7 +19,7 @@ export interface SchemaProperty {
16
19
  items?: {
17
20
  type?: "string" | "number" | "bytes" | "object" | "resource";
18
21
  contentEncoding?: "base64";
19
- enum?: string[];
22
+ enum?: EnumType;
20
23
  resourceType?: string;
21
24
  properties?: {
22
25
  [name: string]: SchemaProperty;
@@ -1,6 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.argSigToJsonSchemaType = argSigToJsonSchemaType;
1
+ const ITEMS_PRESERVED_FIELDS = [
2
+ "properties",
3
+ "required",
4
+ "additionalProperties",
5
+ "enum",
6
+ "resourceType",
7
+ "contentEncoding",
8
+ "description",
9
+ ];
4
10
  /**
5
11
  * Converts argument signature types to JSON schema properties.
6
12
  * This function handles various Windmill-specific types and converts them
@@ -9,7 +15,7 @@ exports.argSigToJsonSchemaType = argSigToJsonSchemaType;
9
15
  * @param t - The argument signature type definition (can be string or complex object types)
10
16
  * @param oldS - Existing schema property to update with new type information
11
17
  */
12
- function argSigToJsonSchemaType(t, oldS) {
18
+ export function argSigToJsonSchemaType(t, oldS) {
13
19
  const newS = { type: "" };
14
20
  if (t === "int") {
15
21
  newS.type = "integer";
@@ -159,17 +165,34 @@ function argSigToJsonSchemaType(t, oldS) {
159
165
  newS.items = { type: "object", properties: properties };
160
166
  }
161
167
  else {
162
- newS.items = { type: "object" };
168
+ // Preserve ALL user-defined fields when parser cannot infer structure
169
+ newS.items = { type: oldS.items?.type || "object" };
170
+ if (oldS.items && typeof oldS.items === "object") {
171
+ ITEMS_PRESERVED_FIELDS.forEach((field) => {
172
+ if (oldS.items && oldS.items[field] !== undefined) {
173
+ newS.items[field] = oldS.items[field];
174
+ }
175
+ });
176
+ }
163
177
  }
164
178
  newS.originalType = "record[]";
165
179
  }
166
180
  else {
167
- newS.items = { type: "object" };
181
+ // Preserve ALL user-defined fields for untyped lists (same as record[] branch)
182
+ newS.items = { type: oldS.items?.type || "object" };
183
+ if (oldS.items && typeof oldS.items === "object") {
184
+ ITEMS_PRESERVED_FIELDS.forEach((field) => {
185
+ if (oldS.items && oldS.items[field] !== undefined) {
186
+ newS.items[field] = oldS.items[field];
187
+ }
188
+ });
189
+ }
168
190
  newS.originalType = "object[]";
169
191
  }
170
192
  }
171
193
  else {
172
- newS.type = "object";
194
+ // Preserve existing type when inference fails, default to "object" for undefined/null
195
+ newS.type = oldS.type ?? "object";
173
196
  }
174
197
  const preservedFields = [
175
198
  "description",
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./path-assigner"), exports);
1
+ export * from "./path-assigner";
@@ -16,13 +16,43 @@ export declare const LANGUAGE_EXTENSIONS: Record<SupportedLanguage, string>;
16
16
  * @returns File extension string (without the dot)
17
17
  */
18
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;
19
32
  export interface PathAssigner {
20
33
  assignPath(summary: string | undefined, language: SupportedLanguage): [string, string];
21
34
  }
35
+ export interface PathAssignerOptions {
36
+ defaultTs: "bun" | "deno";
37
+ /** When true, skip the .inline_script. suffix in file names */
38
+ skipInlineScriptSuffix?: boolean;
39
+ }
22
40
  /**
23
41
  * Creates a new path assigner for inline scripts.
24
42
  *
25
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")
26
56
  * @returns Path assigner function
27
57
  */
28
- export declare function newPathAssigner(defaultTs: "bun" | "deno"): PathAssigner;
58
+ export declare function newRawAppPathAssigner(defaultTs: "bun" | "deno"): PathAssigner;
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LANGUAGE_EXTENSIONS = void 0;
4
- exports.getLanguageExtension = getLanguageExtension;
5
- exports.newPathAssigner = newPathAssigner;
6
1
  const INLINE_SCRIPT_PREFIX = "inline_script";
7
2
  /**
8
3
  * Mapping of supported languages to their file extensions
9
4
  */
10
- exports.LANGUAGE_EXTENSIONS = {
5
+ export const LANGUAGE_EXTENSIONS = {
11
6
  python3: "py",
12
7
  bun: "bun.ts",
13
8
  deno: "deno.ts",
@@ -41,19 +36,74 @@ exports.LANGUAGE_EXTENSIONS = {
41
36
  * @param defaultTs - Default TypeScript runtime ("bun" or "deno")
42
37
  * @returns File extension string (without the dot)
43
38
  */
44
- function getLanguageExtension(language, defaultTs = "bun") {
39
+ export function getLanguageExtension(language, defaultTs = "bun") {
45
40
  if (language === defaultTs || language === "bunnative") {
46
41
  return "ts";
47
42
  }
48
- return exports.LANGUAGE_EXTENSIONS[language] || "no_ext";
43
+ return LANGUAGE_EXTENSIONS[language] || "no_ext";
44
+ }
45
+ /**
46
+ * Reverse mapping from file extensions to languages.
47
+ * Used when deriving language from file extension.
48
+ */
49
+ export const EXTENSION_TO_LANGUAGE = {
50
+ "py": "python3",
51
+ "bun.ts": "bun",
52
+ "deno.ts": "deno",
53
+ "go": "go",
54
+ "sh": "bash",
55
+ "ps1": "powershell",
56
+ "pg.sql": "postgresql",
57
+ "my.sql": "mysql",
58
+ "bq.sql": "bigquery",
59
+ "odb.sql": "oracledb",
60
+ "sf.sql": "snowflake",
61
+ "ms.sql": "mssql",
62
+ "gql": "graphql",
63
+ "native.ts": "nativets",
64
+ "frontend.js": "frontend",
65
+ "php": "php",
66
+ "rs": "rust",
67
+ "cs": "csharp",
68
+ "nu": "nu",
69
+ "playbook.yml": "ansible",
70
+ "java": "java",
71
+ "duckdb.sql": "duckdb",
72
+ // Plain .ts defaults to bun (will be overridden by defaultTs setting)
73
+ "ts": "bun",
74
+ };
75
+ /**
76
+ * Gets the language from a file extension.
77
+ *
78
+ * @param ext - File extension (e.g., "py", "ts", "bun.ts")
79
+ * @param defaultTs - Default TypeScript runtime for plain .ts files
80
+ * @returns The language, or undefined if not recognized
81
+ */
82
+ export function getLanguageFromExtension(ext, defaultTs = "bun") {
83
+ // Check for compound extensions first (e.g., "bun.ts", "pg.sql")
84
+ const lang = EXTENSION_TO_LANGUAGE[ext];
85
+ if (lang) {
86
+ // For plain .ts, return the default TypeScript runtime
87
+ if (ext === "ts") {
88
+ return defaultTs;
89
+ }
90
+ return lang;
91
+ }
92
+ return undefined;
49
93
  }
50
94
  /**
51
95
  * Creates a new path assigner for inline scripts.
52
96
  *
53
97
  * @param defaultTs - Default TypeScript runtime ("bun" or "deno")
98
+ * @param options - Optional configuration (can pass options object instead of defaultTs)
54
99
  * @returns Path assigner function
55
100
  */
56
- function newPathAssigner(defaultTs) {
101
+ export function newPathAssigner(defaultTs, options) {
102
+ // Handle both old signature (defaultTs string) and new signature (options object)
103
+ const resolvedOptions = typeof defaultTs === "object"
104
+ ? defaultTs
105
+ : { defaultTs, skipInlineScriptSuffix: options?.skipInlineScriptSuffix };
106
+ const { defaultTs: tsRuntime, skipInlineScriptSuffix } = resolvedOptions;
57
107
  let counter = 0;
58
108
  const seen_names = new Set();
59
109
  function assignPath(summary, language) {
@@ -69,8 +119,39 @@ function newPathAssigner(defaultTs) {
69
119
  name = `${original_name}_${counter}`;
70
120
  }
71
121
  seen_names.add(name);
122
+ const ext = getLanguageExtension(language, tsRuntime);
123
+ // When skipInlineScriptSuffix is true, don't add .inline_script. to the path
124
+ const suffix = skipInlineScriptSuffix ? "." : ".inline_script.";
125
+ return [`${name}${suffix}`, ext];
126
+ }
127
+ return { assignPath };
128
+ }
129
+ /**
130
+ * Creates a new path assigner for raw app runnables.
131
+ * Unlike newPathAssigner, this does NOT add ".inline_script." prefix since
132
+ * everything in raw_app/backend/ is already known to be for inline scripts.
133
+ *
134
+ * @param defaultTs - Default TypeScript runtime ("bun" or "deno")
135
+ * @returns Path assigner function
136
+ */
137
+ export function newRawAppPathAssigner(defaultTs) {
138
+ let counter = 0;
139
+ const seen_names = new Set();
140
+ function assignPath(summary, language) {
141
+ let name;
142
+ name = summary?.toLowerCase()?.replaceAll(" ", "_") ?? "";
143
+ let original_name = name;
144
+ if (name == "") {
145
+ original_name = "runnable";
146
+ name = `runnable_0`;
147
+ }
148
+ while (seen_names.has(name)) {
149
+ counter++;
150
+ name = `${original_name}_${counter}`;
151
+ }
152
+ seen_names.add(name);
72
153
  const ext = getLanguageExtension(language, defaultTs);
73
- return [`${name}.inline_script.`, ext];
154
+ return [`${name}.`, ext];
74
155
  }
75
156
  return { assignPath };
76
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-utils-internal",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Internal utility functions for Windmill",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",