skedyul 1.5.0 → 1.5.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.
- package/README.md +157 -240
- package/dist/cli/index.js +181 -172
- package/dist/config/index.d.ts +0 -1
- package/dist/config/loader.js +208 -0
- package/dist/config/loader.mjs +184 -0
- package/dist/esm/index.mjs +39 -203
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -200
- package/package.json +7 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
var __esm = (fn, res) => function __init() {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/config/transpileConfigMetadata.ts
|
|
18
|
+
var transpileConfigMetadata_exports = {};
|
|
19
|
+
__export(transpileConfigMetadata_exports, {
|
|
20
|
+
transpileConfigMetadata: () => transpileConfigMetadata
|
|
21
|
+
});
|
|
22
|
+
import * as fs from "fs";
|
|
23
|
+
import * as path from "path";
|
|
24
|
+
function prepareConfigSource(content) {
|
|
25
|
+
return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
|
|
26
|
+
}
|
|
27
|
+
function isJsonImport(importPath) {
|
|
28
|
+
return importPath.endsWith(".json");
|
|
29
|
+
}
|
|
30
|
+
async function transpileConfigMetadata(configPath) {
|
|
31
|
+
const esbuild = await import("esbuild");
|
|
32
|
+
const absolutePath = path.resolve(configPath);
|
|
33
|
+
const configDir = path.dirname(absolutePath);
|
|
34
|
+
const configBasename = path.basename(absolutePath);
|
|
35
|
+
const result = await esbuild.build({
|
|
36
|
+
absWorkingDir: configDir,
|
|
37
|
+
entryPoints: [absolutePath],
|
|
38
|
+
bundle: true,
|
|
39
|
+
format: "cjs",
|
|
40
|
+
platform: "node",
|
|
41
|
+
target: "node22",
|
|
42
|
+
write: false,
|
|
43
|
+
logLevel: "silent",
|
|
44
|
+
plugins: [
|
|
45
|
+
{
|
|
46
|
+
name: "prepare-config-entry",
|
|
47
|
+
setup(build) {
|
|
48
|
+
build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
|
|
49
|
+
contents: prepareConfigSource(fs.readFileSync(absolutePath, "utf-8")),
|
|
50
|
+
loader: "ts"
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "skedyul-shim",
|
|
56
|
+
setup(build) {
|
|
57
|
+
build.onResolve({ filter: /^skedyul$/ }, () => ({
|
|
58
|
+
path: "skedyul-shim",
|
|
59
|
+
namespace: SKEDYUL_SHIM_NAMESPACE
|
|
60
|
+
}));
|
|
61
|
+
build.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
|
|
62
|
+
contents: [
|
|
63
|
+
"function defineConfig(config) { return config; }",
|
|
64
|
+
"module.exports = { defineConfig };"
|
|
65
|
+
].join("\n"),
|
|
66
|
+
loader: "js"
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "metadata-stub-imports",
|
|
72
|
+
setup(build) {
|
|
73
|
+
build.onResolve({ filter: /^\.{1,2}\// }, (args) => {
|
|
74
|
+
if (isJsonImport(args.path)) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
path: args.path,
|
|
79
|
+
namespace: METADATA_STUB_NAMESPACE
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
build.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
|
|
83
|
+
contents: "module.exports = {};\n",
|
|
84
|
+
loader: "js"
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
if (result.errors.length > 0) {
|
|
91
|
+
throw new Error(result.errors.map((error) => error.text).join("\n"));
|
|
92
|
+
}
|
|
93
|
+
if (result.outputFiles.length === 0) {
|
|
94
|
+
throw new Error("Config transpile produced no output");
|
|
95
|
+
}
|
|
96
|
+
return result.outputFiles[0].text;
|
|
97
|
+
}
|
|
98
|
+
var SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
|
|
99
|
+
var init_transpileConfigMetadata = __esm({
|
|
100
|
+
"src/config/transpileConfigMetadata.ts"() {
|
|
101
|
+
"use strict";
|
|
102
|
+
SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
|
|
103
|
+
METADATA_STUB_NAMESPACE = "metadata-stub";
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// src/config/loader.ts
|
|
108
|
+
import * as fs2 from "fs";
|
|
109
|
+
import * as path2 from "path";
|
|
110
|
+
import * as os from "os";
|
|
111
|
+
var CONFIG_FILE_NAMES = [
|
|
112
|
+
"skedyul.config.ts",
|
|
113
|
+
"skedyul.config.js",
|
|
114
|
+
"skedyul.config.mjs",
|
|
115
|
+
"skedyul.config.cjs"
|
|
116
|
+
];
|
|
117
|
+
async function loadConfig(configPath) {
|
|
118
|
+
const absolutePath = path2.resolve(configPath);
|
|
119
|
+
if (!fs2.existsSync(absolutePath)) {
|
|
120
|
+
throw new Error(`Config file not found: ${absolutePath}`);
|
|
121
|
+
}
|
|
122
|
+
const isTypeScript = absolutePath.endsWith(".ts");
|
|
123
|
+
try {
|
|
124
|
+
if (isTypeScript) {
|
|
125
|
+
try {
|
|
126
|
+
const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
|
|
127
|
+
const transpiled = await transpileConfigMetadata2(absolutePath);
|
|
128
|
+
const tempFile = path2.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
|
|
129
|
+
fs2.writeFileSync(tempFile, transpiled);
|
|
130
|
+
try {
|
|
131
|
+
const module2 = __require(tempFile);
|
|
132
|
+
const config2 = module2.default || module2;
|
|
133
|
+
if (!config2 || typeof config2 !== "object") {
|
|
134
|
+
throw new Error("Config file must export a configuration object");
|
|
135
|
+
}
|
|
136
|
+
if (!config2.name || typeof config2.name !== "string") {
|
|
137
|
+
throw new Error('Config must have a "name" property');
|
|
138
|
+
}
|
|
139
|
+
return config2;
|
|
140
|
+
} finally {
|
|
141
|
+
try {
|
|
142
|
+
fs2.unlinkSync(tempFile);
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch (transpileError) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const module = await import(
|
|
153
|
+
/* webpackIgnore: true */
|
|
154
|
+
absolutePath
|
|
155
|
+
);
|
|
156
|
+
const config = module.default || module;
|
|
157
|
+
if (!config || typeof config !== "object") {
|
|
158
|
+
throw new Error("Config file must export a configuration object");
|
|
159
|
+
}
|
|
160
|
+
if (!config.name || typeof config.name !== "string") {
|
|
161
|
+
throw new Error('Config must have a "name" property');
|
|
162
|
+
}
|
|
163
|
+
return config;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
throw new Error(
|
|
166
|
+
`Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function validateConfig(config) {
|
|
171
|
+
const errors = [];
|
|
172
|
+
if (!config.name) {
|
|
173
|
+
errors.push("Missing required field: name");
|
|
174
|
+
}
|
|
175
|
+
if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
|
|
176
|
+
errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
|
|
177
|
+
}
|
|
178
|
+
return { valid: errors.length === 0, errors };
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
CONFIG_FILE_NAMES,
|
|
182
|
+
loadConfig,
|
|
183
|
+
validateConfig
|
|
184
|
+
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
2
|
|
|
9
3
|
// src/index.ts
|
|
10
4
|
import { z as z15 } from "zod/v4";
|
|
@@ -2025,13 +2019,13 @@ function mergeRuntimeEnv() {
|
|
|
2025
2019
|
|
|
2026
2020
|
// src/server/utils/http.ts
|
|
2027
2021
|
function readRawRequestBody(req) {
|
|
2028
|
-
return new Promise((
|
|
2022
|
+
return new Promise((resolve3, reject) => {
|
|
2029
2023
|
let body = "";
|
|
2030
2024
|
req.on("data", (chunk) => {
|
|
2031
2025
|
body += chunk.toString();
|
|
2032
2026
|
});
|
|
2033
2027
|
req.on("end", () => {
|
|
2034
|
-
|
|
2028
|
+
resolve3(body);
|
|
2035
2029
|
});
|
|
2036
2030
|
req.on("error", reject);
|
|
2037
2031
|
});
|
|
@@ -3844,7 +3838,7 @@ function printStartupLog(config, tools, port) {
|
|
|
3844
3838
|
|
|
3845
3839
|
// src/server/route-handlers/adapters.ts
|
|
3846
3840
|
function fromLambdaEvent(event2) {
|
|
3847
|
-
const
|
|
3841
|
+
const path5 = event2.path || event2.rawPath || "/";
|
|
3848
3842
|
const method = event2.httpMethod || event2.requestContext?.http?.method || "POST";
|
|
3849
3843
|
const forwardedProto = event2.headers?.["x-forwarded-proto"] ?? event2.headers?.["X-Forwarded-Proto"];
|
|
3850
3844
|
const protocol = forwardedProto ?? "https";
|
|
@@ -3852,9 +3846,9 @@ function fromLambdaEvent(event2) {
|
|
|
3852
3846
|
const queryString = event2.queryStringParameters ? "?" + new URLSearchParams(
|
|
3853
3847
|
event2.queryStringParameters
|
|
3854
3848
|
).toString() : "";
|
|
3855
|
-
const url = `${protocol}://${host}${
|
|
3849
|
+
const url = `${protocol}://${host}${path5}${queryString}`;
|
|
3856
3850
|
return {
|
|
3857
|
-
path:
|
|
3851
|
+
path: path5,
|
|
3858
3852
|
method,
|
|
3859
3853
|
headers: event2.headers,
|
|
3860
3854
|
query: event2.queryStringParameters ?? {},
|
|
@@ -4404,7 +4398,7 @@ async function handleOAuthCallback(parsedBody, hooks) {
|
|
|
4404
4398
|
}
|
|
4405
4399
|
|
|
4406
4400
|
// src/server/handlers/webhook-handler.ts
|
|
4407
|
-
function parseWebhookRequest(parsedBody, method, url,
|
|
4401
|
+
function parseWebhookRequest(parsedBody, method, url, path5, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
|
|
4408
4402
|
const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
|
|
4409
4403
|
if (isEnvelope) {
|
|
4410
4404
|
const envelope = parsedBody;
|
|
@@ -4458,7 +4452,7 @@ function parseWebhookRequest(parsedBody, method, url, path7, headers, query, raw
|
|
|
4458
4452
|
const webhookRequest = {
|
|
4459
4453
|
method,
|
|
4460
4454
|
url,
|
|
4461
|
-
path:
|
|
4455
|
+
path: path5,
|
|
4462
4456
|
headers,
|
|
4463
4457
|
query,
|
|
4464
4458
|
body: parsedBody,
|
|
@@ -4907,9 +4901,9 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4907
4901
|
}
|
|
4908
4902
|
const perCallTimeoutMs = deadline ? Math.min(deadline, 25e3) : 25e3;
|
|
4909
4903
|
const executeWithTimeout = async (call2, timeoutMs) => {
|
|
4910
|
-
return new Promise(async (
|
|
4904
|
+
return new Promise(async (resolve3) => {
|
|
4911
4905
|
const timeoutHandle = setTimeout(() => {
|
|
4912
|
-
|
|
4906
|
+
resolve3({
|
|
4913
4907
|
id: call2.id,
|
|
4914
4908
|
success: false,
|
|
4915
4909
|
error: "Timeout",
|
|
@@ -4922,7 +4916,7 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4922
4916
|
const found = findToolInRegistry(ctx.registry, toolName);
|
|
4923
4917
|
if (!found) {
|
|
4924
4918
|
clearTimeout(timeoutHandle);
|
|
4925
|
-
|
|
4919
|
+
resolve3({
|
|
4926
4920
|
id: call2.id,
|
|
4927
4921
|
success: false,
|
|
4928
4922
|
error: `Tool "${toolName}" not found`
|
|
@@ -4940,13 +4934,13 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4940
4934
|
clearTimeout(timeoutHandle);
|
|
4941
4935
|
const isFailure2 = "success" in toolResult && toolResult.success === false || "error" in toolResult && toolResult.error != null;
|
|
4942
4936
|
if (isFailure2) {
|
|
4943
|
-
|
|
4937
|
+
resolve3({
|
|
4944
4938
|
id: call2.id,
|
|
4945
4939
|
success: false,
|
|
4946
4940
|
error: "error" in toolResult && toolResult.error ? typeof toolResult.error === "string" ? toolResult.error : JSON.stringify(toolResult.error) : "Tool execution failed"
|
|
4947
4941
|
});
|
|
4948
4942
|
} else {
|
|
4949
|
-
|
|
4943
|
+
resolve3({
|
|
4950
4944
|
id: call2.id,
|
|
4951
4945
|
success: true,
|
|
4952
4946
|
result: "output" in toolResult ? toolResult.output : toolResult
|
|
@@ -4954,7 +4948,7 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4954
4948
|
}
|
|
4955
4949
|
} catch (err) {
|
|
4956
4950
|
clearTimeout(timeoutHandle);
|
|
4957
|
-
|
|
4951
|
+
resolve3({
|
|
4958
4952
|
id: call2.id,
|
|
4959
4953
|
success: false,
|
|
4960
4954
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -5140,21 +5134,21 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
|
|
|
5140
5134
|
return {
|
|
5141
5135
|
async listen(listenPort) {
|
|
5142
5136
|
const finalPort = listenPort ?? port;
|
|
5143
|
-
return new Promise((
|
|
5137
|
+
return new Promise((resolve3, reject) => {
|
|
5144
5138
|
httpServer.listen(finalPort, () => {
|
|
5145
5139
|
printStartupLog(config, tools, finalPort);
|
|
5146
|
-
|
|
5140
|
+
resolve3();
|
|
5147
5141
|
});
|
|
5148
5142
|
httpServer.once("error", reject);
|
|
5149
5143
|
});
|
|
5150
5144
|
},
|
|
5151
5145
|
async close() {
|
|
5152
|
-
return new Promise((
|
|
5146
|
+
return new Promise((resolve3, reject) => {
|
|
5153
5147
|
const closable = httpServer;
|
|
5154
5148
|
closable.closeAllConnections?.();
|
|
5155
5149
|
httpServer.close((err) => {
|
|
5156
5150
|
if (err) reject(err);
|
|
5157
|
-
else
|
|
5151
|
+
else resolve3();
|
|
5158
5152
|
});
|
|
5159
5153
|
});
|
|
5160
5154
|
},
|
|
@@ -5509,169 +5503,14 @@ function defineNavigation(navigation) {
|
|
|
5509
5503
|
return navigation;
|
|
5510
5504
|
}
|
|
5511
5505
|
|
|
5512
|
-
// src/config/loader.ts
|
|
5513
|
-
import * as fs4 from "fs";
|
|
5514
|
-
import * as path4 from "path";
|
|
5515
|
-
import * as os from "os";
|
|
5516
|
-
|
|
5517
|
-
// src/config/transpileConfigMetadata.ts
|
|
5518
|
-
import * as esbuild from "esbuild";
|
|
5506
|
+
// src/config/schema-loader.ts
|
|
5519
5507
|
import * as fs3 from "fs";
|
|
5520
5508
|
import * as path3 from "path";
|
|
5521
|
-
|
|
5522
|
-
var METADATA_STUB_NAMESPACE = "metadata-stub";
|
|
5523
|
-
function prepareConfigSource(content) {
|
|
5524
|
-
return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
|
|
5525
|
-
}
|
|
5526
|
-
function isJsonImport(importPath) {
|
|
5527
|
-
return importPath.endsWith(".json");
|
|
5528
|
-
}
|
|
5529
|
-
async function transpileConfigMetadata(configPath) {
|
|
5530
|
-
const absolutePath = path3.resolve(configPath);
|
|
5531
|
-
const configDir = path3.dirname(absolutePath);
|
|
5532
|
-
const configBasename = path3.basename(absolutePath);
|
|
5533
|
-
const result = await esbuild.build({
|
|
5534
|
-
absWorkingDir: configDir,
|
|
5535
|
-
entryPoints: [absolutePath],
|
|
5536
|
-
bundle: true,
|
|
5537
|
-
format: "cjs",
|
|
5538
|
-
platform: "node",
|
|
5539
|
-
target: "node22",
|
|
5540
|
-
write: false,
|
|
5541
|
-
logLevel: "silent",
|
|
5542
|
-
plugins: [
|
|
5543
|
-
{
|
|
5544
|
-
name: "prepare-config-entry",
|
|
5545
|
-
setup(build2) {
|
|
5546
|
-
build2.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
|
|
5547
|
-
contents: prepareConfigSource(fs3.readFileSync(absolutePath, "utf-8")),
|
|
5548
|
-
loader: "ts"
|
|
5549
|
-
}));
|
|
5550
|
-
}
|
|
5551
|
-
},
|
|
5552
|
-
{
|
|
5553
|
-
name: "skedyul-shim",
|
|
5554
|
-
setup(build2) {
|
|
5555
|
-
build2.onResolve({ filter: /^skedyul$/ }, () => ({
|
|
5556
|
-
path: "skedyul-shim",
|
|
5557
|
-
namespace: SKEDYUL_SHIM_NAMESPACE
|
|
5558
|
-
}));
|
|
5559
|
-
build2.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
|
|
5560
|
-
contents: [
|
|
5561
|
-
"function defineConfig(config) { return config; }",
|
|
5562
|
-
"module.exports = { defineConfig };"
|
|
5563
|
-
].join("\n"),
|
|
5564
|
-
loader: "js"
|
|
5565
|
-
}));
|
|
5566
|
-
}
|
|
5567
|
-
},
|
|
5568
|
-
{
|
|
5569
|
-
name: "metadata-stub-imports",
|
|
5570
|
-
setup(build2) {
|
|
5571
|
-
build2.onResolve({ filter: /^\.{1,2}\// }, (args) => {
|
|
5572
|
-
if (isJsonImport(args.path)) {
|
|
5573
|
-
return void 0;
|
|
5574
|
-
}
|
|
5575
|
-
return {
|
|
5576
|
-
path: args.path,
|
|
5577
|
-
namespace: METADATA_STUB_NAMESPACE
|
|
5578
|
-
};
|
|
5579
|
-
});
|
|
5580
|
-
build2.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
|
|
5581
|
-
contents: "module.exports = {};\n",
|
|
5582
|
-
loader: "js"
|
|
5583
|
-
}));
|
|
5584
|
-
}
|
|
5585
|
-
}
|
|
5586
|
-
]
|
|
5587
|
-
});
|
|
5588
|
-
if (result.errors.length > 0) {
|
|
5589
|
-
throw new Error(result.errors.map((error) => error.text).join("\n"));
|
|
5590
|
-
}
|
|
5591
|
-
if (result.outputFiles.length === 0) {
|
|
5592
|
-
throw new Error("Config transpile produced no output");
|
|
5593
|
-
}
|
|
5594
|
-
return result.outputFiles[0].text;
|
|
5595
|
-
}
|
|
5596
|
-
|
|
5597
|
-
// src/config/loader.ts
|
|
5598
|
-
var CONFIG_FILE_NAMES = [
|
|
5599
|
-
"skedyul.config.ts",
|
|
5600
|
-
"skedyul.config.js",
|
|
5601
|
-
"skedyul.config.mjs",
|
|
5602
|
-
"skedyul.config.cjs"
|
|
5603
|
-
];
|
|
5604
|
-
async function loadConfig(configPath) {
|
|
5605
|
-
const absolutePath = path4.resolve(configPath);
|
|
5606
|
-
if (!fs4.existsSync(absolutePath)) {
|
|
5607
|
-
throw new Error(`Config file not found: ${absolutePath}`);
|
|
5608
|
-
}
|
|
5609
|
-
const isTypeScript = absolutePath.endsWith(".ts");
|
|
5610
|
-
try {
|
|
5611
|
-
if (isTypeScript) {
|
|
5612
|
-
try {
|
|
5613
|
-
const transpiled = await transpileConfigMetadata(absolutePath);
|
|
5614
|
-
const tempFile = path4.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
|
|
5615
|
-
fs4.writeFileSync(tempFile, transpiled);
|
|
5616
|
-
try {
|
|
5617
|
-
const module2 = __require(tempFile);
|
|
5618
|
-
const config2 = module2.default || module2;
|
|
5619
|
-
if (!config2 || typeof config2 !== "object") {
|
|
5620
|
-
throw new Error("Config file must export a configuration object");
|
|
5621
|
-
}
|
|
5622
|
-
if (!config2.name || typeof config2.name !== "string") {
|
|
5623
|
-
throw new Error('Config must have a "name" property');
|
|
5624
|
-
}
|
|
5625
|
-
return config2;
|
|
5626
|
-
} finally {
|
|
5627
|
-
try {
|
|
5628
|
-
fs4.unlinkSync(tempFile);
|
|
5629
|
-
} catch {
|
|
5630
|
-
}
|
|
5631
|
-
}
|
|
5632
|
-
} catch (transpileError) {
|
|
5633
|
-
throw new Error(
|
|
5634
|
-
`Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
|
|
5635
|
-
);
|
|
5636
|
-
}
|
|
5637
|
-
}
|
|
5638
|
-
const module = await import(
|
|
5639
|
-
/* webpackIgnore: true */
|
|
5640
|
-
absolutePath
|
|
5641
|
-
);
|
|
5642
|
-
const config = module.default || module;
|
|
5643
|
-
if (!config || typeof config !== "object") {
|
|
5644
|
-
throw new Error("Config file must export a configuration object");
|
|
5645
|
-
}
|
|
5646
|
-
if (!config.name || typeof config.name !== "string") {
|
|
5647
|
-
throw new Error('Config must have a "name" property');
|
|
5648
|
-
}
|
|
5649
|
-
return config;
|
|
5650
|
-
} catch (error) {
|
|
5651
|
-
throw new Error(
|
|
5652
|
-
`Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
5653
|
-
);
|
|
5654
|
-
}
|
|
5655
|
-
}
|
|
5656
|
-
function validateConfig(config) {
|
|
5657
|
-
const errors = [];
|
|
5658
|
-
if (!config.name) {
|
|
5659
|
-
errors.push("Missing required field: name");
|
|
5660
|
-
}
|
|
5661
|
-
if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
|
|
5662
|
-
errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
|
|
5663
|
-
}
|
|
5664
|
-
return { valid: errors.length === 0, errors };
|
|
5665
|
-
}
|
|
5666
|
-
|
|
5667
|
-
// src/config/schema-loader.ts
|
|
5668
|
-
import * as fs5 from "fs";
|
|
5669
|
-
import * as path5 from "path";
|
|
5670
|
-
import * as os2 from "os";
|
|
5509
|
+
import * as os from "os";
|
|
5671
5510
|
|
|
5672
5511
|
// src/config/resolver.ts
|
|
5673
|
-
import * as
|
|
5674
|
-
import * as
|
|
5512
|
+
import * as fs4 from "fs";
|
|
5513
|
+
import * as path4 from "path";
|
|
5675
5514
|
|
|
5676
5515
|
// src/config/utils.ts
|
|
5677
5516
|
function getAllEnvKeys(config) {
|
|
@@ -5774,7 +5613,7 @@ function getApiToken() {
|
|
|
5774
5613
|
const config = getConfig();
|
|
5775
5614
|
return config.apiToken || process.env.SKEDYUL_API_TOKEN || "";
|
|
5776
5615
|
}
|
|
5777
|
-
async function callRateLimitApi(
|
|
5616
|
+
async function callRateLimitApi(path5, body) {
|
|
5778
5617
|
const baseUrl = getApiBaseUrl();
|
|
5779
5618
|
const token2 = getApiToken();
|
|
5780
5619
|
if (!baseUrl || !token2) {
|
|
@@ -5782,7 +5621,7 @@ async function callRateLimitApi(path7, body) {
|
|
|
5782
5621
|
"SKEDYUL_API_URL and SKEDYUL_API_TOKEN are required for platform queue coordination"
|
|
5783
5622
|
);
|
|
5784
5623
|
}
|
|
5785
|
-
const response = await fetch(`${baseUrl}/api/internal/ratelimit/${
|
|
5624
|
+
const response = await fetch(`${baseUrl}/api/internal/ratelimit/${path5}`, {
|
|
5786
5625
|
method: "POST",
|
|
5787
5626
|
headers: {
|
|
5788
5627
|
Authorization: `Bearer ${token2}`,
|
|
@@ -5792,11 +5631,11 @@ async function callRateLimitApi(path7, body) {
|
|
|
5792
5631
|
});
|
|
5793
5632
|
const payload = await response.json().catch(() => null);
|
|
5794
5633
|
if (!response.ok || payload?.success === false) {
|
|
5795
|
-
const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${
|
|
5634
|
+
const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${path5} failed with status ${response.status}`;
|
|
5796
5635
|
throw new RateLimitBackendError(message, response.status);
|
|
5797
5636
|
}
|
|
5798
5637
|
if (!payload?.data) {
|
|
5799
|
-
throw new RateLimitBackendError(`Queue coordination API ${
|
|
5638
|
+
throw new RateLimitBackendError(`Queue coordination API ${path5} returned empty data`);
|
|
5800
5639
|
}
|
|
5801
5640
|
return payload.data;
|
|
5802
5641
|
}
|
|
@@ -5923,9 +5762,9 @@ var MemoryRateLimitBackend = class {
|
|
|
5923
5762
|
if (canAcquire(state, limits)) {
|
|
5924
5763
|
return this.grant(state, queueKey, limits);
|
|
5925
5764
|
}
|
|
5926
|
-
return new Promise((
|
|
5765
|
+
return new Promise((resolve3, reject) => {
|
|
5927
5766
|
const waiter = {
|
|
5928
|
-
resolve:
|
|
5767
|
+
resolve: resolve3,
|
|
5929
5768
|
reject,
|
|
5930
5769
|
timer: null,
|
|
5931
5770
|
limits
|
|
@@ -5954,7 +5793,7 @@ var MemoryRateLimitBackend = class {
|
|
|
5954
5793
|
if (waiter.timer) {
|
|
5955
5794
|
clearTimeout(waiter.timer);
|
|
5956
5795
|
}
|
|
5957
|
-
|
|
5796
|
+
resolve3(this.grant(state, queueKey, limits));
|
|
5958
5797
|
return;
|
|
5959
5798
|
}
|
|
5960
5799
|
setTimeout(retry, Math.max(getMinTime(limits), 10));
|
|
@@ -6075,7 +5914,7 @@ function defaultShouldRetry(error, _attempt) {
|
|
|
6075
5914
|
return false;
|
|
6076
5915
|
}
|
|
6077
5916
|
function sleep(ms) {
|
|
6078
|
-
return new Promise((
|
|
5917
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
6079
5918
|
}
|
|
6080
5919
|
|
|
6081
5920
|
// src/ratelimit/queued-fetch.ts
|
|
@@ -6355,16 +6194,16 @@ function evaluateTemplate(template, context) {
|
|
|
6355
6194
|
const templateRegex = /\{\{\s*([^}]+)\s*\}\}/g;
|
|
6356
6195
|
const singleMatch = template.match(/^\{\{\s*([^}]+)\s*\}\}$/);
|
|
6357
6196
|
if (singleMatch) {
|
|
6358
|
-
const
|
|
6359
|
-
return resolvePath(context,
|
|
6197
|
+
const path5 = singleMatch[1].trim();
|
|
6198
|
+
return resolvePath(context, path5);
|
|
6360
6199
|
}
|
|
6361
|
-
return template.replace(templateRegex, (_,
|
|
6362
|
-
const value = resolvePath(context,
|
|
6200
|
+
return template.replace(templateRegex, (_, path5) => {
|
|
6201
|
+
const value = resolvePath(context, path5.trim());
|
|
6363
6202
|
return value === void 0 || value === null ? "" : String(value);
|
|
6364
6203
|
});
|
|
6365
6204
|
}
|
|
6366
|
-
function resolvePath(obj,
|
|
6367
|
-
const parts =
|
|
6205
|
+
function resolvePath(obj, path5) {
|
|
6206
|
+
const parts = path5.split(".");
|
|
6368
6207
|
let current = obj;
|
|
6369
6208
|
for (const part of parts) {
|
|
6370
6209
|
if (current === null || current === void 0) {
|
|
@@ -6385,14 +6224,14 @@ function evaluateCondition(condition, context) {
|
|
|
6385
6224
|
const expression = match[1].trim();
|
|
6386
6225
|
const eqMatch = expression.match(/^(.+?)\s*==\s*['"](.+)['"]$/);
|
|
6387
6226
|
if (eqMatch) {
|
|
6388
|
-
const [,
|
|
6389
|
-
const actualValue = resolvePath(context,
|
|
6227
|
+
const [, path5, expectedValue] = eqMatch;
|
|
6228
|
+
const actualValue = resolvePath(context, path5.trim());
|
|
6390
6229
|
return actualValue === expectedValue;
|
|
6391
6230
|
}
|
|
6392
6231
|
const neqMatch = expression.match(/^(.+?)\s*!=\s*['"](.+)['"]$/);
|
|
6393
6232
|
if (neqMatch) {
|
|
6394
|
-
const [,
|
|
6395
|
-
const actualValue = resolvePath(context,
|
|
6233
|
+
const [, path5, expectedValue] = neqMatch;
|
|
6234
|
+
const actualValue = resolvePath(context, path5.trim());
|
|
6396
6235
|
return actualValue !== expectedValue;
|
|
6397
6236
|
}
|
|
6398
6237
|
const value = resolvePath(context, expression);
|
|
@@ -7634,7 +7473,6 @@ export {
|
|
|
7634
7473
|
AuthenticationError,
|
|
7635
7474
|
BaseEventPayloadSchema,
|
|
7636
7475
|
BreadcrumbItemSchema,
|
|
7637
|
-
CONFIG_FILE_NAMES,
|
|
7638
7476
|
CRMCardinalitySchema,
|
|
7639
7477
|
CRMContextSchema2 as CRMContextSchema,
|
|
7640
7478
|
CRMDataSchema,
|
|
@@ -7900,7 +7738,6 @@ export {
|
|
|
7900
7738
|
isTimeInPolicy,
|
|
7901
7739
|
isTimeInWindowSlot2 as isTimeInWindowSlot,
|
|
7902
7740
|
isWorkflowDependency,
|
|
7903
|
-
loadConfig,
|
|
7904
7741
|
matchesTrigger,
|
|
7905
7742
|
parseCRMSchema,
|
|
7906
7743
|
queuedFetch,
|
|
@@ -7918,7 +7755,6 @@ export {
|
|
|
7918
7755
|
server,
|
|
7919
7756
|
token,
|
|
7920
7757
|
validateCRMSchema,
|
|
7921
|
-
validateConfig,
|
|
7922
7758
|
validateSkillYAML,
|
|
7923
7759
|
validateWorkflowYAML,
|
|
7924
7760
|
webhook,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare const _default: {
|
|
|
14
14
|
z: typeof z;
|
|
15
15
|
};
|
|
16
16
|
export default _default;
|
|
17
|
-
export { defineConfig, defineModel, defineChannel, definePage, defineWorkflow, defineAgent, defineEnv, defineNavigation,
|
|
17
|
+
export { defineConfig, defineModel, defineChannel, definePage, defineWorkflow, defineAgent, defineEnv, defineNavigation, getAllEnvKeys, getRequiredInstallEnvKeys, } from './config';
|
|
18
18
|
export { queuedFetch, requeue, resolveQueue, createQueueHandle, queuedFetchResponse, registerQueueConfig, runWithRateLimitExecutionContext, getRateLimitExecutionContext, defaultShouldRetry, QueueContextError, QueueNotFoundError, QueuedFetchExhaustedError, RequeueOutsideContextError, RateLimitBackendError, RateLimitExceededError, } from './ratelimit';
|
|
19
19
|
export type { QueueInput, QueueSelector, Lease, QueueLimits, ResolvedQueue, RateLimitExecutionContext, RateLimitBackend, QueueScope, QueueConfig, SerializableQueueConfig, QueueRegistry, } from './ratelimit';
|
|
20
20
|
export { defineSchema, validateCRMSchema, parseCRMSchema, safeParseCRMSchema, } from './schemas';
|