@aws-amplify/api-graphql 4.7.4-websocket-event.29583bc.0 → 4.7.4

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.
@@ -255,11 +255,6 @@ export abstract class AWSWebSocketProvider {
255
255
 
256
256
  return new Promise((resolve, reject) => {
257
257
  if (this.awsRealTimeSocket) {
258
- const timeoutId = setTimeout(() => {
259
- cleanup();
260
- reject(new Error('Publish operation timed out'));
261
- }, 30000); // 30 seconds timeout
262
-
263
258
  const publishListener = (event: MessageEvent) => {
264
259
  const data = JSON.parse(event.data);
265
260
  if (data.id === subscriptionId && data.type === 'publish_success') {
@@ -268,47 +263,22 @@ export abstract class AWSWebSocketProvider {
268
263
  'message',
269
264
  publishListener,
270
265
  );
271
- cleanup();
266
+
272
267
  resolve();
273
268
  }
274
269
 
275
270
  if (data.erroredEvents && data.erroredEvents.length > 0) {
276
271
  // TODO: handle errors
277
- const errors = data.erroredEvents.map(
278
- (errorEvent: any) => errorEvent.error,
279
- );
280
- cleanup();
281
- reject(new Error(`Publish errors: ${errors.join(', ')}`));
282
272
  }
283
273
  };
284
-
285
- const errorListener = (error: Event) => {
286
- cleanup();
287
- reject(new Error(`WebSocket error: ${error}`));
288
- };
289
-
290
- const closeListener = () => {
291
- cleanup();
292
- reject(new Error('WebSocket is closed'));
293
- };
294
-
295
- const cleanup = () => {
296
- clearTimeout(timeoutId);
297
- this.awsRealTimeSocket?.removeEventListener(
298
- 'message',
299
- publishListener,
300
- );
301
- this.awsRealTimeSocket?.removeEventListener('error', errorListener);
302
- this.awsRealTimeSocket?.removeEventListener('close', closeListener);
303
- };
304
-
305
274
  this.awsRealTimeSocket.addEventListener('message', publishListener);
306
- this.awsRealTimeSocket.addEventListener('error', errorListener);
307
- this.awsRealTimeSocket.addEventListener('close', closeListener);
275
+ this.awsRealTimeSocket.addEventListener('close', () => {
276
+ reject(new Error('WebSocket is closed'));
277
+ });
278
+ //
279
+ // this.awsRealTimeSocket.addEventListener('error', publishListener);
308
280
 
309
281
  this.awsRealTimeSocket.send(serializedSubscriptionMessage);
310
- } else {
311
- reject(new Error('WebSocket is not connected'));
312
282
  }
313
283
  });
314
284
  }
@@ -70,7 +70,7 @@ async function connect(
70
70
  };
71
71
 
72
72
  // WS publish is not enabled in the service yet. It will be a follow up feature
73
- const pub = async (
73
+ const _pub = async (
74
74
  event: DocumentType,
75
75
  pubOptions?: EventsOptions,
76
76
  ): Promise<any> => {
@@ -94,7 +94,7 @@ async function connect(
94
94
  return {
95
95
  subscribe: sub,
96
96
  close,
97
- publish: pub,
97
+ // publish: pub,
98
98
  };
99
99
  }
100
100
 
@@ -3,7 +3,6 @@
3
3
 
4
4
  import { Subscription } from 'rxjs';
5
5
  import type { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
6
- import { DocumentType } from '@aws-amplify/core/internals/utils';
7
6
 
8
7
  export interface SubscriptionObserver<T> {
9
8
  next(value: T): void;
@@ -52,15 +51,6 @@ export interface EventsChannel {
52
51
  *
53
52
  */
54
53
  close(): void;
55
- /**
56
- *
57
- * @param event
58
- * @param pubOptions
59
- *
60
- * @example
61
- * await channel.publish({ some: "data" });
62
- */
63
- publish(event: DocumentType, pubOptions?: EventsOptions): Promise<any>;
64
54
  }
65
55
 
66
56
  export type ResolvedGraphQLAuthModes = Exclude<GraphQLAuthMode, 'identityPool'>;
@@ -47,7 +47,7 @@ export const configure = () => {
47
47
  };
48
48
 
49
49
  /**
50
- * Event API expects an array of JSON strings
50
+ * Event API expects and array of JSON strings
51
51
  *
52
52
  * @param events - JSON-serializable value or an array of values
53
53
  * @returns array of JSON strings