@vectorx/functions-framework 0.0.0-beta-20251112071515 → 0.0.0-beta-20251225064112
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/lib/framework.js +0 -1
- package/lib/function-wrapper.js +0 -3
- package/lib/middlewares/middle-apm-injection.js +1 -0
- package/lib/middlewares/middle-context-injection.js +1 -0
- package/lib/request.js +4 -0
- package/lib/server.js +0 -36
- package/lib/utils/apm.js +1 -1
- package/package.json +2 -2
- package/types/function-loader.d.ts +1 -0
package/lib/framework.js
CHANGED
|
@@ -75,7 +75,6 @@ class AgentServerFramework {
|
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
const { functionsConfigFile } = this.options;
|
|
77
77
|
let cloudFunctionConfig;
|
|
78
|
-
console.log("==== process.env.OPEN_PLATFORM_STAGE ====", process.env.OPEN_PLATFORM_STAGE);
|
|
79
78
|
if (!process.env.OPEN_PLATFORM_STAGE) {
|
|
80
79
|
process.stdout.write(chalk_1.default.yellow(`未设置 OPEN_PLATFORM_STAGE 环境变量,使用默认值: development\n`));
|
|
81
80
|
process.env.OPEN_PLATFORM_STAGE = "development";
|
package/lib/function-wrapper.js
CHANGED
|
@@ -140,7 +140,6 @@ const wrapEventFunction = (execute, projectConfig) => {
|
|
|
140
140
|
result = yield execute(event, context);
|
|
141
141
|
}
|
|
142
142
|
catch (e) {
|
|
143
|
-
console.log("============>>>>>>>>>> function wrapper error ", e);
|
|
144
143
|
ctx.state.error = e;
|
|
145
144
|
if (hasSwitchSSEMode) {
|
|
146
145
|
const sse = (_a = ctx.sse) === null || _a === void 0 ? void 0 : _a.call(ctx);
|
|
@@ -150,9 +149,7 @@ const wrapEventFunction = (execute, projectConfig) => {
|
|
|
150
149
|
data: e.message,
|
|
151
150
|
comment: "uncaught-exception-from-user-code",
|
|
152
151
|
};
|
|
153
|
-
console.log("============>>>>>>>>>> errorEvent ", errorEvent);
|
|
154
152
|
sse.emit("error", errorEvent);
|
|
155
|
-
console.log("============>>>>>>>>>> sse.end(errorEvent) ");
|
|
156
153
|
sse.end(errorEvent);
|
|
157
154
|
}
|
|
158
155
|
}
|
|
@@ -25,6 +25,7 @@ function apmMiddleware() {
|
|
|
25
25
|
kit_agent_desc: agentInfo.desc,
|
|
26
26
|
kit_agent_id: agentInfo.agentId,
|
|
27
27
|
kit_agent_version: agentInfo.version,
|
|
28
|
+
kit_agent_name: agentInfo.name,
|
|
28
29
|
context_artifactVersion: kitInfo.agentRuntimeVersion,
|
|
29
30
|
kit_agent_runtime_version: kitInfo.agentRuntimeVersion,
|
|
30
31
|
kit_function_framework_version: kitInfo.functionsFrameworkVersion,
|
package/lib/request.js
CHANGED
|
@@ -112,6 +112,10 @@ class Request {
|
|
|
112
112
|
const requestOptions = Object.assign(Object.assign({ method,
|
|
113
113
|
headers }, (payload !== undefined && { body: payload })), { credentials: withCredentials ? "include" : "same-origin", signal });
|
|
114
114
|
try {
|
|
115
|
+
console.log("===== request =====", {
|
|
116
|
+
realUrl,
|
|
117
|
+
requestOptions,
|
|
118
|
+
});
|
|
115
119
|
const response = yield (0, node_fetch_1.default)(realUrl, requestOptions), result = {
|
|
116
120
|
header: {},
|
|
117
121
|
statusCode: response.status,
|
package/lib/server.js
CHANGED
|
@@ -36,19 +36,6 @@ function createServer(options, router, projectConfig) {
|
|
|
36
36
|
const app = new koa_1.default();
|
|
37
37
|
app.use(corsMiddleware());
|
|
38
38
|
app.use((0, middlewares_1.logsQueryMiddleware)());
|
|
39
|
-
app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
try {
|
|
41
|
-
const h = ctx.request.headers || {};
|
|
42
|
-
console.log("[REQ-IN]", ctx.method, ctx.url, {
|
|
43
|
-
"content-type": h["content-type"],
|
|
44
|
-
"content-length": h["content-length"],
|
|
45
|
-
"transfer-encoding": h["transfer-encoding"],
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (e) {
|
|
49
|
-
}
|
|
50
|
-
yield next();
|
|
51
|
-
}));
|
|
52
39
|
app.use((0, middlewares_1.contextInjectionMiddleware)(options, projectConfig));
|
|
53
40
|
app.use((0, middlewares_1.eventIdMiddleware)());
|
|
54
41
|
app.use((0, middlewares_1.apmMiddleware)());
|
|
@@ -85,29 +72,6 @@ function createServer(options, router, projectConfig) {
|
|
|
85
72
|
return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)(err), 400);
|
|
86
73
|
},
|
|
87
74
|
}));
|
|
88
|
-
app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
try {
|
|
91
|
-
const fields = ((_a = ctx.request) === null || _a === void 0 ? void 0 : _a.body) ? Object.keys(ctx.request.body) : [];
|
|
92
|
-
const files = (_b = ctx.request) === null || _b === void 0 ? void 0 : _b.files;
|
|
93
|
-
console.log("[REQ-PARSED] Body", JSON.stringify(ctx.request.body, null, 2));
|
|
94
|
-
console.log("[REQ-PARSED] files", JSON.stringify(ctx.request.files, null, 2));
|
|
95
|
-
}
|
|
96
|
-
catch (_) { }
|
|
97
|
-
yield next();
|
|
98
|
-
}));
|
|
99
|
-
app.use((ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
if (!(ctx.request.files || ctx.request.body || ctx.state.isTimeout)) {
|
|
101
|
-
try {
|
|
102
|
-
console.log("==== ctx.request.files ====", ctx.request.files);
|
|
103
|
-
console.log("==== ctx.request.body ====", ctx.request.body);
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
return (0, unified_responder_1.sendResponse)(ctx, undefined, (0, error_1.newBadRequestErr)(err), 400);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
yield next();
|
|
110
|
-
}));
|
|
111
75
|
app.use((0, middlewares_1.openGwRequestMiddleware)(projectConfig.agentId));
|
|
112
76
|
app.use((0, middlewares_1.functionRouteMiddleware)(router, projectConfig));
|
|
113
77
|
const httpServer = http_1.default.createServer(app.callback());
|
package/lib/utils/apm.js
CHANGED
|
@@ -54,7 +54,7 @@ class ApmReporter {
|
|
|
54
54
|
context_appVersion: "unknown",
|
|
55
55
|
context_osVersion: os.release(),
|
|
56
56
|
context_userAgent: `Node/${process.version} ${os.platform()}/${os.release()} (${os.arch()})`,
|
|
57
|
-
context_artifactName: "
|
|
57
|
+
context_artifactName: "miniprogram",
|
|
58
58
|
context_deviceModel: "",
|
|
59
59
|
context_matchedPath: "",
|
|
60
60
|
context_deviceId: (0, machineId_1.machineIdSync)(true),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorx/functions-framework",
|
|
3
|
-
"version": "0.0.0-beta-
|
|
3
|
+
"version": "0.0.0-beta-20251225064112",
|
|
4
4
|
"description": "VectorX Functions Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"node": ">=18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vectorx/ai-types": "0.0.0-beta-
|
|
28
|
+
"@vectorx/ai-types": "0.0.0-beta-20251225064112",
|
|
29
29
|
"async_hooks": "^1.0.0",
|
|
30
30
|
"chalk": "4",
|
|
31
31
|
"commander": "^12.1.0",
|