windmill-utils-internal 1.3.2 → 1.3.3

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.
Files changed (82) hide show
  1. package/dist/cjs/config/config.js +231 -0
  2. package/dist/cjs/config/index.js +17 -0
  3. package/dist/cjs/constants.js +44 -0
  4. package/dist/cjs/gen/core/ApiError.js +20 -0
  5. package/dist/cjs/gen/core/ApiRequestOptions.js +2 -0
  6. package/dist/cjs/gen/core/ApiResult.js +2 -0
  7. package/dist/cjs/gen/core/CancelablePromise.js +100 -0
  8. package/dist/cjs/gen/core/OpenAPI.js +39 -0
  9. package/dist/cjs/gen/core/request.js +323 -0
  10. package/dist/cjs/gen/index.js +27 -0
  11. package/dist/{gen → cjs/gen}/services.gen.d.ts +336 -15
  12. package/dist/cjs/gen/services.gen.js +13143 -0
  13. package/dist/{gen → cjs/gen}/types.gen.d.ts +728 -41
  14. package/dist/cjs/gen/types.gen.js +3 -0
  15. package/dist/cjs/index.js +33 -0
  16. package/dist/cjs/inline-scripts/extractor.js +112 -0
  17. package/dist/cjs/inline-scripts/index.js +18 -0
  18. package/dist/cjs/inline-scripts/replacer.js +88 -0
  19. package/dist/cjs/parse/index.js +17 -0
  20. package/dist/cjs/parse/parse-schema.js +253 -0
  21. package/dist/cjs/path-utils/index.js +17 -0
  22. package/dist/cjs/path-utils/path-assigner.js +164 -0
  23. package/dist/esm/config/config.d.ts +11 -0
  24. package/dist/esm/config/index.js +1 -0
  25. package/dist/esm/constants.d.ts +16 -0
  26. package/dist/esm/gen/core/ApiError.d.ts +10 -0
  27. package/dist/esm/gen/core/ApiRequestOptions.d.ts +14 -0
  28. package/dist/esm/gen/core/ApiResult.d.ts +7 -0
  29. package/dist/esm/gen/core/CancelablePromise.d.ts +26 -0
  30. package/dist/esm/gen/core/OpenAPI.d.ts +27 -0
  31. package/dist/{gen → esm/gen}/core/OpenAPI.js +1 -1
  32. package/dist/esm/gen/core/request.d.ts +29 -0
  33. package/dist/esm/gen/index.d.ts +5 -0
  34. package/dist/esm/gen/services.gen.d.ts +6137 -0
  35. package/dist/{gen → esm/gen}/services.gen.js +664 -30
  36. package/dist/esm/gen/types.gen.d.ts +10613 -0
  37. package/dist/esm/index.js +14 -0
  38. package/dist/esm/inline-scripts/extractor.d.ts +41 -0
  39. package/dist/{inline-scripts → esm/inline-scripts}/extractor.js +34 -12
  40. package/dist/esm/inline-scripts/index.js +2 -0
  41. package/dist/esm/inline-scripts/replacer.d.ts +16 -0
  42. package/dist/esm/inline-scripts/replacer.js +85 -0
  43. package/dist/esm/parse/index.js +1 -0
  44. package/dist/esm/parse/parse-schema.d.ts +98 -0
  45. package/dist/esm/path-utils/index.js +1 -0
  46. package/dist/esm/path-utils/path-assigner.d.ts +58 -0
  47. package/package.json +14 -4
  48. package/dist/inline-scripts/replacer.js +0 -93
  49. /package/dist/{config → cjs/config}/config.d.ts +0 -0
  50. /package/dist/{config → cjs/config}/index.d.ts +0 -0
  51. /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
  52. /package/dist/{gen → cjs/gen}/core/ApiError.d.ts +0 -0
  53. /package/dist/{gen → cjs/gen}/core/ApiRequestOptions.d.ts +0 -0
  54. /package/dist/{gen → cjs/gen}/core/ApiResult.d.ts +0 -0
  55. /package/dist/{gen → cjs/gen}/core/CancelablePromise.d.ts +0 -0
  56. /package/dist/{gen → cjs/gen}/core/OpenAPI.d.ts +0 -0
  57. /package/dist/{gen → cjs/gen}/core/request.d.ts +0 -0
  58. /package/dist/{gen → cjs/gen}/index.d.ts +0 -0
  59. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  60. /package/dist/{inline-scripts → cjs/inline-scripts}/extractor.d.ts +0 -0
  61. /package/dist/{inline-scripts → cjs/inline-scripts}/index.d.ts +0 -0
  62. /package/dist/{inline-scripts → cjs/inline-scripts}/replacer.d.ts +0 -0
  63. /package/dist/{parse → cjs/parse}/index.d.ts +0 -0
  64. /package/dist/{parse → cjs/parse}/parse-schema.d.ts +0 -0
  65. /package/dist/{path-utils → cjs/path-utils}/index.d.ts +0 -0
  66. /package/dist/{path-utils → cjs/path-utils}/path-assigner.d.ts +0 -0
  67. /package/dist/{config → esm/config}/config.js +0 -0
  68. /package/dist/{config/index.js → esm/config/index.d.ts} +0 -0
  69. /package/dist/{constants.js → esm/constants.js} +0 -0
  70. /package/dist/{gen → esm/gen}/core/ApiError.js +0 -0
  71. /package/dist/{gen → esm/gen}/core/ApiRequestOptions.js +0 -0
  72. /package/dist/{gen → esm/gen}/core/ApiResult.js +0 -0
  73. /package/dist/{gen → esm/gen}/core/CancelablePromise.js +0 -0
  74. /package/dist/{gen → esm/gen}/core/request.js +0 -0
  75. /package/dist/{gen → esm/gen}/index.js +0 -0
  76. /package/dist/{gen → esm/gen}/types.gen.js +0 -0
  77. /package/dist/{index.js → esm/index.d.ts} +0 -0
  78. /package/dist/{inline-scripts/index.js → esm/inline-scripts/index.d.ts} +0 -0
  79. /package/dist/{parse/index.js → esm/parse/index.d.ts} +0 -0
  80. /package/dist/{parse → esm/parse}/parse-schema.js +0 -0
  81. /package/dist/{path-utils/index.js → esm/path-utils/index.d.ts} +0 -0
  82. /package/dist/{path-utils → esm/path-utils}/path-assigner.js +0 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Main entry point for windmill-utils-internal package
4
+ *
5
+ * This module provides utilities for handling Windmill flows, scripts, and schemas:
6
+ * - Inline script extraction and replacement
7
+ * - Path utilities for different programming languages
8
+ * - Schema parsing and conversion utilities
9
+ * - Cross-platform path constants
10
+ */
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; } });
@@ -0,0 +1,112 @@
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");
6
+ function extractRawscriptInline(id, summary, rawscript, mapping, separator, assigner) {
7
+ const [basePath, ext] = assigner.assignPath(summary ?? id, rawscript.language);
8
+ const path = mapping[id] ?? basePath + ext;
9
+ const content = rawscript.content;
10
+ const r = [{ path: path, content: content }];
11
+ rawscript.content = "!inline " + path.replaceAll(separator, "/");
12
+ const lock = rawscript.lock;
13
+ if (lock && lock != "") {
14
+ const lockPath = basePath + "lock";
15
+ rawscript.lock = "!inline " + lockPath.replaceAll(separator, "/");
16
+ r.push({ path: lockPath, content: lock });
17
+ }
18
+ return r;
19
+ }
20
+ /**
21
+ * Extracts inline scripts from flow modules, converting them to separate files
22
+ * and replacing the original content with file references.
23
+ *
24
+ * @param modules - Array of flow modules to process
25
+ * @param mapping - Optional mapping of module IDs to custom file paths
26
+ * @param separator - Path separator to use
27
+ * @param defaultTs - Default TypeScript runtime to use ("bun" or "deno")
28
+ * @param pathAssigner - Optional path assigner to reuse (for nested calls)
29
+ * @param options - Optional configuration options
30
+ * @returns Array of inline scripts with their paths and content
31
+ */
32
+ function extractInlineScripts(modules, mapping = {}, separator = "/", defaultTs, pathAssigner, options) {
33
+ // Create pathAssigner only if not provided (top-level call), but reuse it for nested calls
34
+ const assigner = pathAssigner ?? (0, path_assigner_1.newPathAssigner)(defaultTs ?? "bun", { skipInlineScriptSuffix: options?.skipInlineScriptSuffix });
35
+ return modules.flatMap((m) => {
36
+ if (m.value.type == "rawscript") {
37
+ return extractRawscriptInline(m.id, m.summary, m.value, mapping, separator, assigner);
38
+ }
39
+ else if (m.value.type == "forloopflow") {
40
+ return extractInlineScripts(m.value.modules, mapping, separator, defaultTs, assigner);
41
+ }
42
+ else if (m.value.type == "branchall") {
43
+ return m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs, assigner));
44
+ }
45
+ else if (m.value.type == "whileloopflow") {
46
+ return extractInlineScripts(m.value.modules, mapping, separator, defaultTs, assigner);
47
+ }
48
+ else if (m.value.type == "branchone") {
49
+ return [
50
+ ...m.value.branches.flatMap((b) => extractInlineScripts(b.modules, mapping, separator, defaultTs, assigner)),
51
+ ...extractInlineScripts(m.value.default, mapping, separator, defaultTs, assigner),
52
+ ];
53
+ }
54
+ else if (m.value.type == "aiagent") {
55
+ return (m.value.tools ?? []).flatMap((tool) => {
56
+ const toolValue = tool.value;
57
+ // Only process flowmodule tools with rawscript type
58
+ if (!toolValue || toolValue.tool_type !== 'flowmodule' || toolValue.type !== 'rawscript') {
59
+ return [];
60
+ }
61
+ return extractRawscriptInline(tool.id, tool.summary, toolValue, mapping, separator, assigner);
62
+ });
63
+ }
64
+ else {
65
+ return [];
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Extracts the current mapping of module IDs to file paths from flow modules
71
+ * by analyzing existing inline script references.
72
+ *
73
+ * @param modules - Array of flow modules to analyze (can be undefined)
74
+ * @param mapping - Existing mapping to extend (defaults to empty object)
75
+ * @returns Record mapping module IDs to their corresponding file paths
76
+ */
77
+ function extractCurrentMapping(modules, mapping = {}) {
78
+ if (!modules || !Array.isArray(modules)) {
79
+ return mapping;
80
+ }
81
+ modules.forEach((m) => {
82
+ if (!m?.value?.type) {
83
+ return;
84
+ }
85
+ if (m.value.type === "rawscript") {
86
+ if (m.value.content && m.value.content.startsWith("!inline ")) {
87
+ mapping[m.id] = m.value.content.trim().split(" ")[1];
88
+ }
89
+ }
90
+ else if (m.value.type === "forloopflow" ||
91
+ m.value.type === "whileloopflow") {
92
+ extractCurrentMapping(m.value.modules, mapping);
93
+ }
94
+ else if (m.value.type === "branchall") {
95
+ m.value.branches.forEach((b) => extractCurrentMapping(b.modules, mapping));
96
+ }
97
+ else if (m.value.type === "branchone") {
98
+ m.value.branches.forEach((b) => extractCurrentMapping(b.modules, mapping));
99
+ extractCurrentMapping(m.value.default, mapping);
100
+ }
101
+ else if (m.value.type === "aiagent") {
102
+ (m.value.tools ?? []).forEach((tool) => {
103
+ const toolValue = tool.value;
104
+ if (!toolValue || toolValue.tool_type !== 'flowmodule' || toolValue.type !== 'rawscript' || !toolValue.content || !toolValue.content.startsWith("!inline")) {
105
+ return;
106
+ }
107
+ mapping[tool.id] = toolValue.content.trim().split(" ")[1];
108
+ });
109
+ }
110
+ });
111
+ return mapping;
112
+ }
@@ -0,0 +1,18 @@
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);
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceInlineScripts = replaceInlineScripts;
4
+ async function replaceRawscriptInline(id, rawscript, fileReader, logger, separator, removeLocks) {
5
+ if (!rawscript.content || !rawscript.content.startsWith("!inline")) {
6
+ return;
7
+ }
8
+ const path = rawscript.content.split(" ")[1];
9
+ const pathSuffix = path.split(".").slice(1).join(".");
10
+ const newPath = id + "." + pathSuffix;
11
+ try {
12
+ rawscript.content = await fileReader(path);
13
+ }
14
+ catch {
15
+ logger.error(`Script file ${path} not found`);
16
+ try {
17
+ rawscript.content = await fileReader(newPath);
18
+ }
19
+ catch {
20
+ logger.error(`Script file ${newPath} not found`);
21
+ }
22
+ }
23
+ const lock = rawscript.lock;
24
+ if (removeLocks && removeLocks.includes(path)) {
25
+ rawscript.lock = undefined;
26
+ }
27
+ else if (lock &&
28
+ typeof lock === "string" &&
29
+ lock.trimStart().startsWith("!inline ")) {
30
+ const lockPath = lock.split(" ")[1];
31
+ try {
32
+ rawscript.lock = await fileReader(lockPath.replaceAll("/", separator));
33
+ }
34
+ catch {
35
+ logger.error(`Lock file ${lockPath} not found, treating as empty`);
36
+ rawscript.lock = "";
37
+ }
38
+ }
39
+ }
40
+ /**
41
+ * Replaces inline script references with actual file content from the filesystem.
42
+ * This function recursively processes all flow modules and their nested structures.
43
+ *
44
+ * @param modules - Array of flow modules to process
45
+ * @param fileReader - Function to read file content (typically fs.readFile or similar)
46
+ * @param logger - Optional logger object with info and error methods
47
+ * @param localPath - Base path for resolving relative file paths
48
+ * @param removeLocks - Optional array of paths for which to remove lock files
49
+ * @returns Promise that resolves when all inline scripts have been replaced
50
+ */
51
+ async function replaceInlineScripts(modules, fileReader, logger = {
52
+ info: () => { },
53
+ error: () => { },
54
+ }, localPath, separator = "/", removeLocks) {
55
+ await Promise.all(modules.map(async (module) => {
56
+ if (!module.value) {
57
+ throw new Error(`Module value is undefined for module ${module.id}`);
58
+ }
59
+ if (module.value.type === "rawscript") {
60
+ await replaceRawscriptInline(module.id, module.value, fileReader, logger, separator, removeLocks);
61
+ }
62
+ else if (module.value.type === "forloopflow" || module.value.type === "whileloopflow") {
63
+ await replaceInlineScripts(module.value.modules, fileReader, logger, localPath, separator, removeLocks);
64
+ }
65
+ else if (module.value.type === "branchall") {
66
+ await Promise.all(module.value.branches.map(async (branch) => {
67
+ await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
68
+ }));
69
+ }
70
+ else if (module.value.type === "branchone") {
71
+ await Promise.all(module.value.branches.map(async (branch) => {
72
+ await replaceInlineScripts(branch.modules, fileReader, logger, localPath, separator, removeLocks);
73
+ }));
74
+ await replaceInlineScripts(module.value.default, fileReader, logger, localPath, separator, removeLocks);
75
+ }
76
+ else if (module.value.type === "aiagent") {
77
+ await Promise.all((module.value.tools ?? []).map(async (tool) => {
78
+ const toolValue = tool.value;
79
+ if (!toolValue ||
80
+ toolValue.tool_type !== "flowmodule" ||
81
+ toolValue.type !== "rawscript") {
82
+ return;
83
+ }
84
+ await replaceRawscriptInline(tool.id, toolValue, fileReader, logger, separator, removeLocks);
85
+ }));
86
+ }
87
+ }));
88
+ }
@@ -0,0 +1,17 @@
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);
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.argSigToJsonSchemaType = argSigToJsonSchemaType;
4
+ const ITEMS_PRESERVED_FIELDS = [
5
+ "properties",
6
+ "required",
7
+ "additionalProperties",
8
+ "enum",
9
+ "resourceType",
10
+ "contentEncoding",
11
+ "description",
12
+ ];
13
+ /**
14
+ * Converts argument signature types to JSON schema properties.
15
+ * This function handles various Windmill-specific types and converts them
16
+ * to standard JSON schema format while preserving existing property metadata.
17
+ *
18
+ * @param t - The argument signature type definition (can be string or complex object types)
19
+ * @param oldS - Existing schema property to update with new type information
20
+ */
21
+ function argSigToJsonSchemaType(t, oldS) {
22
+ const newS = { type: "" };
23
+ if (t === "int") {
24
+ newS.type = "integer";
25
+ }
26
+ else if (t === "float") {
27
+ newS.type = "number";
28
+ }
29
+ else if (t === "bool") {
30
+ newS.type = "boolean";
31
+ }
32
+ else if (t === "email") {
33
+ newS.type = "string";
34
+ newS.format = "email";
35
+ }
36
+ else if (t === "sql") {
37
+ newS.type = "string";
38
+ newS.format = "sql";
39
+ }
40
+ else if (t === "yaml") {
41
+ newS.type = "string";
42
+ newS.format = "yaml";
43
+ }
44
+ else if (t === "bytes") {
45
+ newS.type = "string";
46
+ newS.contentEncoding = "base64";
47
+ newS.originalType = "bytes";
48
+ }
49
+ else if (t === "datetime") {
50
+ newS.type = "string";
51
+ newS.format = "date-time";
52
+ }
53
+ else if (typeof t !== "string" && "oneof" in t) {
54
+ newS.type = "object";
55
+ if (t.oneof) {
56
+ newS.oneOf = t.oneof.map((obj) => {
57
+ const oldObjS = oldS.oneOf?.find((o) => o?.title === obj.label) ?? undefined;
58
+ const properties = {};
59
+ for (const prop of obj.properties) {
60
+ if (oldObjS?.properties && prop.key in oldObjS?.properties) {
61
+ properties[prop.key] = oldObjS?.properties[prop.key];
62
+ }
63
+ else {
64
+ properties[prop.key] = { description: "", type: "" };
65
+ }
66
+ argSigToJsonSchemaType(prop.typ, properties[prop.key]);
67
+ }
68
+ return {
69
+ type: "object",
70
+ title: obj.label,
71
+ properties,
72
+ order: oldObjS?.order ?? undefined,
73
+ };
74
+ });
75
+ }
76
+ }
77
+ else if (typeof t !== "string" && `object` in t) {
78
+ newS.type = "object";
79
+ if (t.object.name) {
80
+ newS.format = `resource-${t.object.name}`;
81
+ }
82
+ if (t.object.props) {
83
+ const properties = {};
84
+ for (const prop of t.object.props) {
85
+ if (oldS.properties && prop.key in oldS.properties) {
86
+ properties[prop.key] = oldS.properties[prop.key];
87
+ }
88
+ else {
89
+ properties[prop.key] = { description: "", type: "" };
90
+ }
91
+ argSigToJsonSchemaType(prop.typ, properties[prop.key]);
92
+ }
93
+ newS.properties = properties;
94
+ }
95
+ }
96
+ else if (typeof t !== "string" && `str` in t) {
97
+ newS.type = "string";
98
+ if (t.str) {
99
+ newS.originalType = "enum";
100
+ newS.enum = t.str;
101
+ }
102
+ else if (oldS.originalType == "string" && oldS.enum) {
103
+ newS.originalType = "string";
104
+ newS.enum = oldS.enum;
105
+ }
106
+ else {
107
+ newS.originalType = "string";
108
+ newS.enum = undefined;
109
+ }
110
+ }
111
+ else if (typeof t !== "string" && `resource` in t) {
112
+ newS.type = "object";
113
+ newS.format = `resource-${t.resource}`;
114
+ }
115
+ else if (typeof t !== "string" && `dynselect` in t) {
116
+ newS.type = "object";
117
+ newS.format = `dynselect-${t.dynselect}`;
118
+ }
119
+ else if (typeof t !== "string" && `dynmultiselect` in t) {
120
+ newS.type = "object";
121
+ newS.format = `dynmultiselect-${t.dynmultiselect}`;
122
+ }
123
+ else if (typeof t !== "string" && `list` in t) {
124
+ newS.type = "array";
125
+ if (t.list === "int" || t.list === "float") {
126
+ newS.items = { type: "number" };
127
+ newS.originalType = "number[]";
128
+ }
129
+ else if (t.list === "bytes") {
130
+ newS.items = { type: "string", contentEncoding: "base64" };
131
+ newS.originalType = "bytes[]";
132
+ }
133
+ else if (t.list &&
134
+ typeof t.list == "object" &&
135
+ "str" in t.list &&
136
+ t.list.str) {
137
+ newS.items = { type: "string", enum: t.list.str };
138
+ newS.originalType = "enum[]";
139
+ }
140
+ else if (t.list == "string" ||
141
+ (t.list && typeof t.list == "object" && "str" in t.list)) {
142
+ newS.items = { type: "string", enum: oldS.items?.enum };
143
+ newS.originalType = "string[]";
144
+ }
145
+ else if (t.list &&
146
+ typeof t.list == "object" &&
147
+ "resource" in t.list &&
148
+ t.list.resource) {
149
+ newS.items = {
150
+ type: "resource",
151
+ resourceType: t.list.resource,
152
+ };
153
+ newS.originalType = "resource[]";
154
+ }
155
+ else if (t.list &&
156
+ typeof t.list == "object" &&
157
+ "object" in t.list &&
158
+ t.list.object) {
159
+ if (t.list.object.name) {
160
+ newS.format = `resource-${t.list.object.name}`;
161
+ }
162
+ if (t.list.object.props && t.list.object.props.length > 0) {
163
+ const properties = {};
164
+ for (const prop of t.list.object.props) {
165
+ properties[prop.key] = { description: "", type: "" };
166
+ argSigToJsonSchemaType(prop.typ, properties[prop.key]);
167
+ }
168
+ newS.items = { type: "object", properties: properties };
169
+ }
170
+ else {
171
+ // Preserve ALL user-defined fields when parser cannot infer structure
172
+ newS.items = { type: oldS.items?.type || "object" };
173
+ if (oldS.items && typeof oldS.items === "object") {
174
+ ITEMS_PRESERVED_FIELDS.forEach((field) => {
175
+ if (oldS.items && oldS.items[field] !== undefined) {
176
+ newS.items[field] = oldS.items[field];
177
+ }
178
+ });
179
+ }
180
+ }
181
+ newS.originalType = "record[]";
182
+ }
183
+ else {
184
+ // Preserve ALL user-defined fields for untyped lists (same as record[] branch)
185
+ newS.items = { type: oldS.items?.type || "object" };
186
+ if (oldS.items && typeof oldS.items === "object") {
187
+ ITEMS_PRESERVED_FIELDS.forEach((field) => {
188
+ if (oldS.items && oldS.items[field] !== undefined) {
189
+ newS.items[field] = oldS.items[field];
190
+ }
191
+ });
192
+ }
193
+ newS.originalType = "object[]";
194
+ }
195
+ }
196
+ else {
197
+ // Preserve existing type when inference fails, default to "object" for undefined/null
198
+ newS.type = oldS.type ?? "object";
199
+ }
200
+ const preservedFields = [
201
+ "description",
202
+ "pattern",
203
+ "min",
204
+ "max",
205
+ "currency",
206
+ "currencyLocale",
207
+ "multiselect",
208
+ "customErrorMessage",
209
+ "required",
210
+ "showExpr",
211
+ "password",
212
+ "order",
213
+ "dateFormat",
214
+ "title",
215
+ "placeholder",
216
+ ];
217
+ preservedFields.forEach((field) => {
218
+ // @ts-ignore
219
+ if (oldS[field] !== undefined) {
220
+ // @ts-ignore
221
+ newS[field] = oldS[field];
222
+ }
223
+ });
224
+ if (oldS.type != newS.type) {
225
+ for (const prop of Object.getOwnPropertyNames(newS)) {
226
+ if (prop != "description") {
227
+ // @ts-ignore
228
+ delete oldS[prop];
229
+ }
230
+ }
231
+ }
232
+ else if ((oldS.format == "date" || oldS.format === "date-time") &&
233
+ newS.format == "string") {
234
+ newS.format = oldS.format;
235
+ }
236
+ else if (newS.format == "date-time" && oldS.format == "date") {
237
+ newS.format = "date";
238
+ }
239
+ else if (newS.format == "date" || newS.format == "date-time") {
240
+ newS.format = oldS.format;
241
+ }
242
+ else if (oldS.items?.type != newS.items?.type) {
243
+ delete oldS.items;
244
+ }
245
+ else if (oldS.type == "string" && oldS.format != undefined) {
246
+ newS.format = oldS.format;
247
+ }
248
+ if ((oldS.type != newS.type || newS.type != "string") &&
249
+ newS.format == undefined) {
250
+ oldS.format = undefined;
251
+ }
252
+ Object.assign(oldS, newS);
253
+ }
@@ -0,0 +1,17 @@
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);