@vectorx/functions-framework 1.0.0 → 1.0.1
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.
|
@@ -12,9 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.openGwRequestMiddleware = openGwRequestMiddleware;
|
|
13
13
|
const error_1 = require("../error");
|
|
14
14
|
const unified_responder_1 = require("../unified-responder");
|
|
15
|
-
function openGwRequestMiddleware(agentId) {
|
|
15
|
+
function openGwRequestMiddleware(agentId, options) {
|
|
16
16
|
return (ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if ((options === null || options === void 0 ? void 0 : options.mode) === "fun") {
|
|
18
|
+
yield next();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
17
21
|
if (process.env.OPEN_PLATFORM_STAGE === "production") {
|
|
22
|
+
if (!agentId) {
|
|
23
|
+
return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newSysErr)("agentId is required in agent mode"), 500);
|
|
24
|
+
}
|
|
18
25
|
const openId = ctx.headers["open-id"];
|
|
19
26
|
if (!openId) {
|
|
20
27
|
return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)("open-id is required"), 401);
|
package/lib/server.js
CHANGED
|
@@ -73,7 +73,8 @@ function createServer(options, router, projectConfig) {
|
|
|
73
73
|
return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)(err), 400);
|
|
74
74
|
},
|
|
75
75
|
}));
|
|
76
|
-
|
|
76
|
+
const openGwAgentId = options.mode === "fun" ? undefined : projectConfig.agentId;
|
|
77
|
+
app.use((0, middlewares_1.openGwRequestMiddleware)(openGwAgentId, { mode: options.mode }));
|
|
77
78
|
app.use((0, middlewares_1.functionRouteMiddleware)(router, projectConfig));
|
|
78
79
|
const httpServer = http_1.default.createServer(app.callback());
|
|
79
80
|
return httpServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorx/functions-framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "VectorX Functions Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"node": ">=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vectorx/ai-types": "1.0.
|
|
29
|
-
"@vectorx/endpoints": "1.0.
|
|
28
|
+
"@vectorx/ai-types": "1.0.1",
|
|
29
|
+
"@vectorx/endpoints": "1.0.1",
|
|
30
30
|
"async_hooks": "^1.0.0",
|
|
31
31
|
"chalk": "4",
|
|
32
32
|
"commander": "^12.1.0",
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Context, Next } from "koa";
|
|
2
|
-
export
|
|
2
|
+
export type OpenGwRequestMiddlewareOptions = {
|
|
3
|
+
mode?: "agent" | "fun";
|
|
4
|
+
};
|
|
5
|
+
export declare function openGwRequestMiddleware(agentId?: string, options?: OpenGwRequestMiddlewareOptions): (ctx: Context, next: Next) => Promise<void>;
|