@the-open-engine/zeroshot 6.45.0 → 6.46.0

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.
@@ -231,8 +231,9 @@ class Connection {
231
231
  entry.reject(new errors_js_1.ClusterProtocolError('response has neither result nor error', 'INVALID_RESPONSE'));
232
232
  return;
233
233
  }
234
+ let validatedResult;
234
235
  try {
235
- (0, validators_js_1.assertMethodResult)(entry.method, frame.result);
236
+ validatedResult = (0, validators_js_1.assertMethodResult)(entry.method, frame.result);
236
237
  }
237
238
  catch (error) {
238
239
  if (entry.subscriptionKind && (0, frames_js_1.isRecord)(frame.result) && typeof frame.result.subscriptionId === 'string') {
@@ -243,10 +244,10 @@ class Connection {
243
244
  return;
244
245
  }
245
246
  if (!entry.subscriptionKind) {
246
- entry.resolve(frame.result);
247
+ entry.resolve(validatedResult);
247
248
  return;
248
249
  }
249
- const result = frame.result;
250
+ const result = validatedResult;
250
251
  const registration = {
251
252
  id: result.subscriptionId, kind: entry.subscriptionKind,
252
253
  queue: new queue_js_1.BoundedQueue(), overflowed: false, cancelSent: false,
@@ -292,8 +293,9 @@ class Connection {
292
293
  const registration = this.#subscriptions.get(subscriptionId);
293
294
  if (!registration)
294
295
  return;
296
+ const routedFrame = (0, validators_js_1.normalizeInboundSubscriptionFrame)(registration.kind, method, frame);
295
297
  const terminal = method === 'subscription/closed';
296
- const outcome = registration.queue.push(frame, bytes);
298
+ const outcome = registration.queue.push(routedFrame, bytes);
297
299
  if (outcome === 'overflow') {
298
300
  registration.overflowed = true;
299
301
  this.unregisterSubscription(subscriptionId, registration);
@@ -3,7 +3,7 @@ import { ClusterConfigError, ClusterInternalError, ClusterProtocolError, Cluster
3
3
  import { boundedFrameText, isRecord } from './frames.mjs';
4
4
  import { BoundedQueue } from './queue.mjs';
5
5
  import { addSocketListener } from './socket.mjs';
6
- import { assertDefinition, assertMethodResult } from './validators.mjs';
6
+ import { assertDefinition, assertMethodResult, normalizeInboundSubscriptionFrame } from './validators.mjs';
7
7
  import { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, deferred, } from './connection-state.mjs';
8
8
  export { CONNECTION_TRANSITIONS, PROTOCOL_DIAGNOSTIC_CAPACITY, } from './connection-state.mjs';
9
9
  export class Connection {
@@ -226,8 +226,9 @@ export class Connection {
226
226
  entry.reject(new ClusterProtocolError('response has neither result nor error', 'INVALID_RESPONSE'));
227
227
  return;
228
228
  }
229
+ let validatedResult;
229
230
  try {
230
- assertMethodResult(entry.method, frame.result);
231
+ validatedResult = assertMethodResult(entry.method, frame.result);
231
232
  }
232
233
  catch (error) {
233
234
  if (entry.subscriptionKind && isRecord(frame.result) && typeof frame.result.subscriptionId === 'string') {
@@ -238,10 +239,10 @@ export class Connection {
238
239
  return;
239
240
  }
240
241
  if (!entry.subscriptionKind) {
241
- entry.resolve(frame.result);
242
+ entry.resolve(validatedResult);
242
243
  return;
243
244
  }
244
- const result = frame.result;
245
+ const result = validatedResult;
245
246
  const registration = {
246
247
  id: result.subscriptionId, kind: entry.subscriptionKind,
247
248
  queue: new BoundedQueue(), overflowed: false, cancelSent: false,
@@ -287,8 +288,9 @@ export class Connection {
287
288
  const registration = this.#subscriptions.get(subscriptionId);
288
289
  if (!registration)
289
290
  return;
291
+ const routedFrame = normalizeInboundSubscriptionFrame(registration.kind, method, frame);
290
292
  const terminal = method === 'subscription/closed';
291
- const outcome = registration.queue.push(frame, bytes);
293
+ const outcome = registration.queue.push(routedFrame, bytes);
292
294
  if (outcome === 'overflow') {
293
295
  registration.overflowed = true;
294
296
  this.unregisterSubscription(subscriptionId, registration);