@goplus123/core-api 1.1.5 → 1.1.7

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 CHANGED
@@ -1071,24 +1071,47 @@ var WsClient = (_class5 = class {
1071
1071
  return value;
1072
1072
  }
1073
1073
  }
1074
- /**
1075
- * 发送消息
1076
- * @param functionName 业务方法名
1077
- * @param service 服务名
1078
- * @param payload 业务参数
1079
- */
1080
- send(functionName, service, payload) {
1074
+ createWireMessage(functionName, service, payload) {
1081
1075
  const requestId = _nullishCoalesce(_optionalChain([payload, 'optionalAccess', _109 => _109.requestId]), () => ( this.requestId));
1082
1076
  const message = JSON.stringify({
1083
1077
  functionName,
1084
1078
  data: {
1085
- ...payload,
1079
+ ...payload && typeof payload === "object" ? payload : {},
1086
1080
  ...this.headerConfig,
1087
1081
  uuid: this.options.protocols,
1088
1082
  requestId
1089
1083
  },
1090
1084
  service
1091
1085
  });
1086
+ return { requestId, message };
1087
+ }
1088
+ sendNow(functionName, service, payload) {
1089
+ const { requestId, message } = this.createWireMessage(functionName, service, payload);
1090
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
1091
+ this.log("[ws:send][blocked]", {
1092
+ service,
1093
+ functionName,
1094
+ requestId,
1095
+ data: this.maskLogValue(payload)
1096
+ });
1097
+ throw new WsTransportError({ type: "disconnected", requestId, functionName });
1098
+ }
1099
+ this.log("[ws:send]", {
1100
+ service,
1101
+ functionName,
1102
+ requestId,
1103
+ data: this.maskLogValue(payload)
1104
+ });
1105
+ this.ws.send(message);
1106
+ }
1107
+ /**
1108
+ * 发送消息
1109
+ * @param functionName 业务方法名
1110
+ * @param service 服务名
1111
+ * @param payload 业务参数
1112
+ */
1113
+ send(functionName, service, payload) {
1114
+ const { requestId, message } = this.createWireMessage(functionName, service, payload);
1092
1115
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
1093
1116
  this.log("[ws:send][queued]", {
1094
1117
  service,
@@ -1146,7 +1169,7 @@ var WsClient = (_class5 = class {
1146
1169
  timer
1147
1170
  });
1148
1171
  try {
1149
- this.send(functionName, service, { ..._nullishCoalesce(payload, () => ( {})), requestId });
1172
+ this.sendNow(functionName, service, { ..._nullishCoalesce(payload, () => ( {})), requestId });
1150
1173
  } catch (e) {
1151
1174
  this.pendingRequests.delete(requestId);
1152
1175
  if (timer) clearTimeout(timer);
@@ -1190,7 +1213,7 @@ var WsClient = (_class5 = class {
1190
1213
  }, options.timeout);
1191
1214
  }
1192
1215
  try {
1193
- this.send(functionName, service, { ..._nullishCoalesce(payload, () => ( {})), requestId });
1216
+ this.sendNow(functionName, service, { ..._nullishCoalesce(payload, () => ( {})), requestId });
1194
1217
  } catch (e) {
1195
1218
  if (timer) clearTimeout(timer);
1196
1219
  off();
@@ -2638,7 +2661,7 @@ function buildEndpointRegistry(apiMap) {
2638
2661
  async function ensureEndpointRegistry() {
2639
2662
  if (endpointRegistryReady) return;
2640
2663
  if (endpointRegistryBuildPromise) return endpointRegistryBuildPromise;
2641
- endpointRegistryBuildPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./spec-HWWEQVB6.cjs"))).then((mod) => buildEndpointRegistry(mod.apiMap)).catch((err) => {
2664
+ endpointRegistryBuildPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./spec-WKJMH322.cjs"))).then((mod) => buildEndpointRegistry(mod.apiMap)).catch((err) => {
2642
2665
  endpointRegistryReady = false;
2643
2666
  throw err;
2644
2667
  }).finally(() => {
@@ -3288,7 +3311,7 @@ function initSDK(config) {
3288
3311
  setGrpcAdapterClient(sdk.client);
3289
3312
  setUnifiedClient(sdk.client);
3290
3313
  if (_optionalChain([config, 'access', _298 => _298.grpc, 'optionalAccess', _299 => _299.baseUrl])) {
3291
- const legacyPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./legacy-CO3UUF6P.cjs"))).then((m) => m.createLegacyServices(api.grpc));
3314
+ const legacyPromise = Promise.resolve().then(() => _interopRequireWildcard(require("./legacy-LOUPMLZX.cjs"))).then((m) => m.createLegacyServices(api.grpc));
3292
3315
  const loadLegacy = () => legacyPromise;
3293
3316
  sdk.auth = createLazyObject(
3294
3317
  () => loadLegacy().then((m) => m.auth)