skedyul 0.3.12 → 0.3.13
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/.build-stamp +1 -1
- package/dist/server/serverless.js +58 -0
- package/package.json +1 -1
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1771646139683
|
|
@@ -422,6 +422,64 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
|
|
|
422
422
|
}, headers);
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
+
// Handle /provision endpoint for provision handlers
|
|
426
|
+
if (path === '/provision' && method === 'POST') {
|
|
427
|
+
if (!config.hooks?.provision) {
|
|
428
|
+
return (0, utils_1.createResponse)(404, { error: 'Provision handler not configured' }, headers);
|
|
429
|
+
}
|
|
430
|
+
let provisionBody;
|
|
431
|
+
try {
|
|
432
|
+
provisionBody = event.body ? JSON.parse(event.body) : {};
|
|
433
|
+
}
|
|
434
|
+
catch {
|
|
435
|
+
return (0, utils_1.createResponse)(400, { error: { code: -32700, message: 'Parse error' } }, headers);
|
|
436
|
+
}
|
|
437
|
+
if (!provisionBody.context?.app) {
|
|
438
|
+
return (0, utils_1.createResponse)(400, { error: { code: -32602, message: 'Missing context (app required)' } }, headers);
|
|
439
|
+
}
|
|
440
|
+
// SECURITY: Merge process.env (baked-in secrets) with request env (API token).
|
|
441
|
+
// This ensures secrets like MAILGUN_API_KEY come from the container,
|
|
442
|
+
// while runtime values like SKEDYUL_API_TOKEN come from the request.
|
|
443
|
+
const mergedEnv = {};
|
|
444
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
445
|
+
if (value !== undefined) {
|
|
446
|
+
mergedEnv[key] = value;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
// Request env overrides process.env (e.g., for SKEDYUL_API_TOKEN)
|
|
450
|
+
Object.assign(mergedEnv, provisionBody.env ?? {});
|
|
451
|
+
const provisionContext = {
|
|
452
|
+
env: mergedEnv,
|
|
453
|
+
app: provisionBody.context.app,
|
|
454
|
+
invocation: provisionBody.invocation,
|
|
455
|
+
log: (0, logger_1.createContextLogger)(),
|
|
456
|
+
};
|
|
457
|
+
// Build request-scoped config for SDK access
|
|
458
|
+
const provisionRequestConfig = {
|
|
459
|
+
baseUrl: mergedEnv.SKEDYUL_API_URL ?? '',
|
|
460
|
+
apiToken: mergedEnv.SKEDYUL_API_TOKEN ?? '',
|
|
461
|
+
};
|
|
462
|
+
try {
|
|
463
|
+
const provisionHook = config.hooks.provision;
|
|
464
|
+
const provisionHandler = typeof provisionHook === 'function'
|
|
465
|
+
? provisionHook
|
|
466
|
+
: provisionHook.handler;
|
|
467
|
+
const result = await (0, context_logger_1.runWithLogContext)({ invocation: provisionBody.invocation }, async () => {
|
|
468
|
+
return await (0, client_1.runWithConfig)(provisionRequestConfig, async () => {
|
|
469
|
+
return await provisionHandler(provisionContext);
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
return (0, utils_1.createResponse)(200, result, headers);
|
|
473
|
+
}
|
|
474
|
+
catch (err) {
|
|
475
|
+
return (0, utils_1.createResponse)(500, {
|
|
476
|
+
error: {
|
|
477
|
+
code: -32603,
|
|
478
|
+
message: err instanceof Error ? err.message : String(err ?? ''),
|
|
479
|
+
},
|
|
480
|
+
}, headers);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
425
483
|
// Handle /oauth_callback endpoint for OAuth callbacks (called by platform route)
|
|
426
484
|
if (path === '/oauth_callback' && method === 'POST') {
|
|
427
485
|
if (!config.hooks?.oauth_callback) {
|