1 | export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
|
2 |
|
3 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4 | // SPDX-License-Identifier: Apache-2.0
|
5 | const MAX_DELAY_MS = 5000;
|
6 | const NON_RETRYABLE_CODES = [400, 401, 403];
|
7 | const CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
|
8 | var MESSAGE_TYPES;
|
9 | (function (MESSAGE_TYPES) {
|
10 | /**
|
11 | * Client -> Server message.
|
12 | * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
|
13 | */
|
14 | MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
|
15 | /**
|
16 | * Server -> Client message
|
17 | * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
|
18 | */
|
19 | MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
|
20 | /**
|
21 | * Server -> Client message.
|
22 | * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
|
23 | */
|
24 | MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
|
25 | /**
|
26 | * Client -> Server message.
|
27 | * This message type is for register subscriptions with AWS AppSync RealTime
|
28 | */
|
29 | MESSAGE_TYPES["GQL_START"] = "start";
|
30 | /**
|
31 | * Server -> Client message.
|
32 | * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
|
33 | */
|
34 | MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
|
35 | /**
|
36 | * Server -> Client message.
|
37 | * This message type is for subscription message from AWS AppSync RealTime
|
38 | */
|
39 | MESSAGE_TYPES["GQL_DATA"] = "data";
|
40 | /**
|
41 | * Server -> Client message.
|
42 | * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
|
43 | */
|
44 | MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
|
45 | /**
|
46 | * Client -> Server message.
|
47 | * This message type is for unregister subscriptions with AWS AppSync RealTime
|
48 | */
|
49 | MESSAGE_TYPES["GQL_STOP"] = "stop";
|
50 | /**
|
51 | * Server -> Client message.
|
52 | * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
|
53 | */
|
54 | MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
|
55 | /**
|
56 | * Server -> Client message.
|
57 | * This message type is for sending error messages from AWS AppSync RealTime to the client
|
58 | */
|
59 | MESSAGE_TYPES["GQL_ERROR"] = "error";
|
60 | })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
|
61 | var SUBSCRIPTION_STATUS;
|
62 | (function (SUBSCRIPTION_STATUS) {
|
63 | SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
|
64 | SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
|
65 | SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
|
66 | })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
|
67 | var SOCKET_STATUS;
|
68 | (function (SOCKET_STATUS) {
|
69 | SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
|
70 | SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
|
71 | SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
|
72 | })(SOCKET_STATUS || (SOCKET_STATUS = {}));
|
73 | const AWS_APPSYNC_REALTIME_HEADERS = {
|
74 | accept: 'application/json, text/javascript',
|
75 | 'content-encoding': 'amz-1.0',
|
76 | 'content-type': 'application/json; charset=UTF-8',
|
77 | };
|
78 | /**
|
79 | * Time in milleseconds to wait for GQL_CONNECTION_INIT message
|
80 | */
|
81 | const CONNECTION_INIT_TIMEOUT = 15000;
|
82 | /**
|
83 | * Time in milleseconds to wait for GQL_START_ACK message
|
84 | */
|
85 | const START_ACK_TIMEOUT = 15000;
|
86 | /**
|
87 | * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
|
88 | */
|
89 | const DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
|
90 | /**
|
91 | * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
|
92 | */
|
93 | const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
|
94 | /**
|
95 | * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
|
96 | */
|
97 | const RECONNECT_DELAY = 5 * 1000;
|
98 | /**
|
99 | * Default interval time in milleseconds between when reconnect is re-attempted
|
100 | */
|
101 | const RECONNECT_INTERVAL = 60 * 1000;
|
102 |
|
103 | export { AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, CONNECTION_STATE_CHANGE, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, MAX_DELAY_MS, MESSAGE_TYPES, NON_RETRYABLE_CODES, RECONNECT_DELAY, RECONNECT_INTERVAL, SOCKET_STATUS, START_ACK_TIMEOUT, SUBSCRIPTION_STATUS };
|
104 | //# sourceMappingURL=constants.mjs.map
|