@lark-apaas/nestjs-capability 0.1.5-alpha.13 → 0.1.5-alpha.14
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/index.cjs +27 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +27 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -907,17 +907,7 @@ var CapabilityService = class _CapabilityService {
|
|
|
907
907
|
duration_ms: durationMs,
|
|
908
908
|
output: stringifyForLog(result)
|
|
909
909
|
});
|
|
910
|
-
|
|
911
|
-
const manifest = this.pluginLoaderService.getManifest(config.pluginKey);
|
|
912
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
913
|
-
version: manifest?.version ?? "",
|
|
914
|
-
success: String(true),
|
|
915
|
-
duration: String(durationMs),
|
|
916
|
-
is_stream: String(isStream),
|
|
917
|
-
caller_type: String(callerType),
|
|
918
|
-
status_code: "0"
|
|
919
|
-
}).catch(() => {
|
|
920
|
-
});
|
|
910
|
+
this.reportCallEvent(config.pluginKey, true, durationMs, isStream, contextOverride);
|
|
921
911
|
return result;
|
|
922
912
|
} catch (error) {
|
|
923
913
|
const durationMs = Date.now() - startTime;
|
|
@@ -926,18 +916,8 @@ var CapabilityService = class _CapabilityService {
|
|
|
926
916
|
duration_ms: durationMs,
|
|
927
917
|
error: error instanceof Error ? error.message : String(error)
|
|
928
918
|
});
|
|
929
|
-
const callerType = contextOverride?.caller ?? (contextOverride?.isDebug ? "debug" : "server");
|
|
930
919
|
const errorCode = String(error?.code ?? "EXECUTION_ERROR");
|
|
931
|
-
|
|
932
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
933
|
-
version: manifest?.version ?? "",
|
|
934
|
-
success: String(false),
|
|
935
|
-
duration: String(durationMs),
|
|
936
|
-
is_stream: String(isStream),
|
|
937
|
-
caller_type: String(callerType),
|
|
938
|
-
status_code: errorCode
|
|
939
|
-
}).catch(() => {
|
|
940
|
-
});
|
|
920
|
+
this.reportCallEvent(config.pluginKey, false, durationMs, isStream, contextOverride, errorCode);
|
|
941
921
|
throw error;
|
|
942
922
|
}
|
|
943
923
|
}
|
|
@@ -983,17 +963,7 @@ var CapabilityService = class _CapabilityService {
|
|
|
983
963
|
duration_ms: durationMs,
|
|
984
964
|
output: stringifyForLog(aggregatedResult)
|
|
985
965
|
});
|
|
986
|
-
|
|
987
|
-
const manifest = this.pluginLoaderService.getManifest(config.pluginKey);
|
|
988
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
989
|
-
version: manifest?.version ?? "",
|
|
990
|
-
success: String(true),
|
|
991
|
-
duration: String(durationMs),
|
|
992
|
-
is_stream: String(isStream),
|
|
993
|
-
caller_type: String(callerType),
|
|
994
|
-
status_code: "0"
|
|
995
|
-
}).catch(() => {
|
|
996
|
-
});
|
|
966
|
+
this.reportCallEvent(config.pluginKey, true, durationMs, isStream, contextOverride);
|
|
997
967
|
} catch (error) {
|
|
998
968
|
const durationMs = Date.now() - startTime;
|
|
999
969
|
this.logger.error("Capability (stream) execution failed", {
|
|
@@ -1001,18 +971,8 @@ var CapabilityService = class _CapabilityService {
|
|
|
1001
971
|
duration_ms: durationMs,
|
|
1002
972
|
error: error instanceof Error ? error.message : String(error)
|
|
1003
973
|
});
|
|
1004
|
-
const callerType = contextOverride?.caller ?? (contextOverride?.isDebug ? "debug" : "server");
|
|
1005
974
|
const errorCode = String(error?.code ?? "EXECUTION_ERROR");
|
|
1006
|
-
|
|
1007
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
1008
|
-
version: manifest?.version ?? "",
|
|
1009
|
-
success: String(false),
|
|
1010
|
-
duration: String(durationMs),
|
|
1011
|
-
is_stream: String(true),
|
|
1012
|
-
caller_type: String(callerType),
|
|
1013
|
-
status_code: errorCode
|
|
1014
|
-
}).catch(() => {
|
|
1015
|
-
});
|
|
975
|
+
this.reportCallEvent(config.pluginKey, false, durationMs, true, contextOverride, errorCode);
|
|
1016
976
|
throw error;
|
|
1017
977
|
}
|
|
1018
978
|
}
|
|
@@ -1048,6 +1008,8 @@ var CapabilityService = class _CapabilityService {
|
|
|
1048
1008
|
yield event;
|
|
1049
1009
|
} else if (event.type === "done") {
|
|
1050
1010
|
const aggregatedResult2 = pluginInstance.aggregate ? pluginInstance.aggregate(actionName, chunks) : chunks;
|
|
1011
|
+
const durationMs = Date.now() - startTime;
|
|
1012
|
+
this.reportCallEvent(config.pluginKey, true, durationMs, isStream, contextOverride);
|
|
1051
1013
|
yield {
|
|
1052
1014
|
type: "done",
|
|
1053
1015
|
metadata: {
|
|
@@ -1077,33 +1039,23 @@ var CapabilityService = class _CapabilityService {
|
|
|
1077
1039
|
};
|
|
1078
1040
|
}
|
|
1079
1041
|
const aggregatedResult2 = pluginInstance.aggregate ? pluginInstance.aggregate(actionName, chunks) : chunks;
|
|
1042
|
+
const durationMs = Date.now() - startTime;
|
|
1043
|
+
this.reportCallEvent(config.pluginKey, true, durationMs, isStream, contextOverride);
|
|
1080
1044
|
yield {
|
|
1081
1045
|
type: "done",
|
|
1082
1046
|
metadata: {
|
|
1083
1047
|
chunks: chunks.length,
|
|
1084
|
-
duration:
|
|
1048
|
+
duration: durationMs,
|
|
1085
1049
|
aggregated: aggregatedResult2
|
|
1086
1050
|
}
|
|
1087
1051
|
};
|
|
1088
1052
|
}
|
|
1089
|
-
const durationMs = Date.now() - startTime;
|
|
1090
1053
|
const aggregatedResult = pluginInstance.aggregate ? pluginInstance.aggregate(actionName, chunks) : chunks;
|
|
1091
1054
|
this.logger.log("Capability (streamWithEvents) executed successfully", {
|
|
1092
1055
|
...loggerContext,
|
|
1093
|
-
duration_ms:
|
|
1056
|
+
duration_ms: Date.now() - startTime,
|
|
1094
1057
|
output: stringifyForLog(aggregatedResult)
|
|
1095
1058
|
});
|
|
1096
|
-
const callerType = contextOverride?.caller ?? (contextOverride?.isDebug ? "debug" : "server");
|
|
1097
|
-
const manifest = this.pluginLoaderService.getManifest(config.pluginKey);
|
|
1098
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
1099
|
-
version: manifest?.version ?? "",
|
|
1100
|
-
success: String(true),
|
|
1101
|
-
duration: String(durationMs),
|
|
1102
|
-
is_stream: String(isStream),
|
|
1103
|
-
caller_type: String(callerType),
|
|
1104
|
-
status_code: "0"
|
|
1105
|
-
}).catch(() => {
|
|
1106
|
-
});
|
|
1107
1059
|
} catch (error) {
|
|
1108
1060
|
const durationMs = Date.now() - startTime;
|
|
1109
1061
|
this.logger.error("Capability (streamWithEvents) execution failed", {
|
|
@@ -1111,18 +1063,8 @@ var CapabilityService = class _CapabilityService {
|
|
|
1111
1063
|
duration_ms: durationMs,
|
|
1112
1064
|
error: error instanceof Error ? error.message : String(error)
|
|
1113
1065
|
});
|
|
1114
|
-
const callerType = contextOverride?.caller ?? (contextOverride?.isDebug ? "debug" : "server");
|
|
1115
1066
|
const errorCode = String(error?.code ?? "EXECUTION_ERROR");
|
|
1116
|
-
|
|
1117
|
-
this.telemetryService.reportCall(config.pluginKey, {
|
|
1118
|
-
version: manifest?.version ?? "",
|
|
1119
|
-
success: String(false),
|
|
1120
|
-
duration: String(durationMs),
|
|
1121
|
-
is_stream: String(true),
|
|
1122
|
-
caller_type: String(callerType),
|
|
1123
|
-
status_code: errorCode
|
|
1124
|
-
}).catch(() => {
|
|
1125
|
-
});
|
|
1067
|
+
this.reportCallEvent(config.pluginKey, false, durationMs, true, contextOverride, errorCode);
|
|
1126
1068
|
yield {
|
|
1127
1069
|
type: "error",
|
|
1128
1070
|
error: this.extractErrorInfo(error)
|
|
@@ -1130,6 +1072,22 @@ var CapabilityService = class _CapabilityService {
|
|
|
1130
1072
|
}
|
|
1131
1073
|
}
|
|
1132
1074
|
/**
|
|
1075
|
+
* 上报调用事件(fire-and-forget)
|
|
1076
|
+
*/
|
|
1077
|
+
reportCallEvent(pluginKey, success, durationMs, isStream, contextOverride, statusCode = "0") {
|
|
1078
|
+
const callerType = contextOverride?.caller ?? (contextOverride?.isDebug ? "debug" : "server");
|
|
1079
|
+
const manifest = this.pluginLoaderService.getManifest(pluginKey);
|
|
1080
|
+
this.telemetryService.reportCall(pluginKey, {
|
|
1081
|
+
version: manifest?.version ?? "",
|
|
1082
|
+
success: String(success),
|
|
1083
|
+
duration: String(durationMs),
|
|
1084
|
+
is_stream: String(isStream),
|
|
1085
|
+
caller_type: String(callerType),
|
|
1086
|
+
status_code: statusCode
|
|
1087
|
+
}).catch(() => {
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1133
1091
|
* 从错误对象提取错误信息
|
|
1134
1092
|
* 支持 PluginError 和 RateLimitError
|
|
1135
1093
|
*/
|