@aws-amplify/api-graphql 4.0.1-console-preview.3d7f188.0 → 4.0.1-mjs-test.20ead30.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.
Files changed (156) hide show
  1. package/dist/cjs/GraphQLAPI.js +52 -0
  2. package/dist/cjs/GraphQLAPI.js.map +1 -0
  3. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js +693 -0
  4. package/dist/cjs/Providers/AWSAppSyncRealTimeProvider/index.js.map +1 -0
  5. package/{lib → dist/cjs}/Providers/constants.js +8 -8
  6. package/dist/cjs/Providers/constants.js.map +1 -0
  7. package/dist/cjs/index.js +15 -0
  8. package/dist/cjs/index.js.map +1 -0
  9. package/dist/cjs/internals/InternalGraphQLAPI.js +274 -0
  10. package/dist/cjs/internals/InternalGraphQLAPI.js.map +1 -0
  11. package/dist/cjs/internals/index.js +14 -0
  12. package/dist/cjs/internals/index.js.map +1 -0
  13. package/{lib → dist/cjs}/internals/v6.js +7 -4
  14. package/dist/cjs/internals/v6.js.map +1 -0
  15. package/{lib → dist/cjs}/types/PubSub.js +6 -6
  16. package/dist/cjs/types/PubSub.js.map +1 -0
  17. package/{lib → dist/cjs}/types/index.js +7 -5
  18. package/dist/cjs/types/index.js.map +1 -0
  19. package/dist/cjs/utils/ConnectionStateMonitor.js +134 -0
  20. package/dist/cjs/utils/ConnectionStateMonitor.js.map +1 -0
  21. package/dist/cjs/utils/ReachabilityMonitor/index.js +10 -0
  22. package/dist/cjs/utils/ReachabilityMonitor/index.js.map +1 -0
  23. package/dist/cjs/utils/ReachabilityMonitor/index.native.js +12 -0
  24. package/dist/cjs/utils/ReachabilityMonitor/index.native.js.map +1 -0
  25. package/{lib → dist/cjs}/utils/ReconnectionMonitor.js +24 -25
  26. package/dist/cjs/utils/ReconnectionMonitor.js.map +1 -0
  27. package/dist/cjs/utils/errors/APIError.js +21 -0
  28. package/dist/cjs/utils/errors/APIError.js.map +1 -0
  29. package/dist/cjs/utils/errors/assertValidationError.js +19 -0
  30. package/dist/cjs/utils/errors/assertValidationError.js.map +1 -0
  31. package/dist/cjs/utils/errors/index.js +14 -0
  32. package/dist/cjs/utils/errors/index.js.map +1 -0
  33. package/{lib → dist/cjs}/utils/errors/validation.js +9 -7
  34. package/dist/cjs/utils/errors/validation.js.map +1 -0
  35. package/dist/cjs/utils/index.js +11 -0
  36. package/dist/cjs/utils/index.js.map +1 -0
  37. package/dist/cjs/utils/resolveConfig.js +26 -0
  38. package/dist/cjs/utils/resolveConfig.js.map +1 -0
  39. package/dist/cjs/utils/resolveLibraryOptions.js +16 -0
  40. package/dist/cjs/utils/resolveLibraryOptions.js.map +1 -0
  41. package/{lib-esm → dist/esm}/GraphQLAPI.d.ts +2 -2
  42. package/dist/esm/GraphQLAPI.mjs +50 -0
  43. package/dist/esm/GraphQLAPI.mjs.map +1 -0
  44. package/{lib → dist/esm}/Providers/AWSAppSyncRealTimeProvider/index.d.ts +1 -1
  45. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs +691 -0
  46. package/dist/esm/Providers/AWSAppSyncRealTimeProvider/index.mjs.map +1 -0
  47. package/{lib-esm/Providers/constants.js → dist/esm/Providers/constants.mjs} +18 -14
  48. package/dist/esm/Providers/constants.mjs.map +1 -0
  49. package/dist/esm/index.mjs +5 -0
  50. package/dist/esm/index.mjs.map +1 -0
  51. package/{lib → dist/esm}/internals/InternalGraphQLAPI.d.ts +2 -2
  52. package/dist/esm/internals/InternalGraphQLAPI.mjs +272 -0
  53. package/dist/esm/internals/InternalGraphQLAPI.mjs.map +1 -0
  54. package/dist/esm/internals/index.mjs +3 -0
  55. package/dist/esm/internals/index.mjs.map +1 -0
  56. package/{lib-esm/internals/v6.js → dist/esm/internals/v6.mjs} +10 -6
  57. package/dist/esm/internals/v6.mjs.map +1 -0
  58. package/{lib → dist/esm}/types/PubSub.d.ts +2 -2
  59. package/{lib-esm/types/PubSub.js → dist/esm/types/PubSub.mjs} +5 -2
  60. package/dist/esm/types/PubSub.mjs.map +1 -0
  61. package/{lib-esm → dist/esm}/types/index.d.ts +45 -25
  62. package/{lib-esm/types/index.js → dist/esm/types/index.mjs} +7 -3
  63. package/dist/esm/types/index.mjs.map +1 -0
  64. package/{lib-esm → dist/esm}/utils/ConnectionStateMonitor.d.ts +3 -3
  65. package/{lib-esm/utils/ConnectionStateMonitor.js → dist/esm/utils/ConnectionStateMonitor.mjs} +56 -66
  66. package/dist/esm/utils/ConnectionStateMonitor.mjs.map +1 -0
  67. package/dist/esm/utils/ReachabilityMonitor/index.d.ts +1 -0
  68. package/{lib-esm/utils/ReachabilityMonitor/index.js → dist/esm/utils/ReachabilityMonitor/index.mjs} +6 -2
  69. package/dist/esm/utils/ReachabilityMonitor/index.mjs.map +1 -0
  70. package/dist/esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  71. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs +9 -0
  72. package/dist/esm/utils/ReachabilityMonitor/index.native.mjs.map +1 -0
  73. package/{lib-esm/utils/ReconnectionMonitor.js → dist/esm/utils/ReconnectionMonitor.mjs} +25 -26
  74. package/dist/esm/utils/ReconnectionMonitor.mjs.map +1 -0
  75. package/dist/esm/utils/errors/APIError.mjs +19 -0
  76. package/dist/esm/utils/errors/APIError.mjs.map +1 -0
  77. package/dist/esm/utils/errors/assertValidationError.mjs +17 -0
  78. package/dist/esm/utils/errors/assertValidationError.mjs.map +1 -0
  79. package/dist/esm/utils/errors/index.mjs +4 -0
  80. package/dist/esm/utils/errors/index.mjs.map +1 -0
  81. package/{lib-esm/utils/errors/validation.js → dist/esm/utils/errors/validation.mjs} +9 -7
  82. package/dist/esm/utils/errors/validation.mjs.map +1 -0
  83. package/dist/esm/utils/index.mjs +3 -0
  84. package/dist/esm/utils/index.mjs.map +1 -0
  85. package/{lib → dist/esm}/utils/resolveConfig.d.ts +1 -1
  86. package/dist/esm/utils/resolveConfig.mjs +26 -0
  87. package/dist/esm/utils/resolveConfig.mjs.map +1 -0
  88. package/{lib-esm → dist/esm}/utils/resolveLibraryOptions.d.ts +2 -2
  89. package/dist/esm/utils/resolveLibraryOptions.mjs +13 -0
  90. package/dist/esm/utils/resolveLibraryOptions.mjs.map +1 -0
  91. package/internals/package.json +4 -4
  92. package/package.json +48 -26
  93. package/src/GraphQLAPI.ts +2 -2
  94. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +3 -3
  95. package/src/internals/InternalGraphQLAPI.ts +35 -10
  96. package/src/types/index.ts +51 -9
  97. package/lib/GraphQLAPI.d.ts +0 -38
  98. package/lib/GraphQLAPI.js +0 -57
  99. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +0 -806
  100. package/lib/Providers/constants.d.ts +0 -95
  101. package/lib/index.d.ts +0 -3
  102. package/lib/index.js +0 -12
  103. package/lib/internals/InternalGraphQLAPI.js +0 -316
  104. package/lib/internals/index.d.ts +0 -2
  105. package/lib/internals/index.js +0 -11
  106. package/lib/internals/v6.d.ts +0 -101
  107. package/lib/tsconfig.tsbuildinfo +0 -6619
  108. package/lib/types/index.d.ts +0 -289
  109. package/lib/utils/ConnectionStateMonitor.d.ts +0 -41
  110. package/lib/utils/ConnectionStateMonitor.js +0 -144
  111. package/lib/utils/ReachabilityMonitor/index.d.ts +0 -1
  112. package/lib/utils/ReachabilityMonitor/index.js +0 -6
  113. package/lib/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  114. package/lib/utils/ReachabilityMonitor/index.native.js +0 -10
  115. package/lib/utils/ReconnectionMonitor.d.ts +0 -29
  116. package/lib/utils/errors/APIError.d.ts +0 -7
  117. package/lib/utils/errors/APIError.js +0 -22
  118. package/lib/utils/errors/assertValidationError.d.ts +0 -5
  119. package/lib/utils/errors/assertValidationError.js +0 -16
  120. package/lib/utils/errors/index.d.ts +0 -3
  121. package/lib/utils/errors/index.js +0 -11
  122. package/lib/utils/errors/validation.d.ts +0 -7
  123. package/lib/utils/index.d.ts +0 -2
  124. package/lib/utils/index.js +0 -8
  125. package/lib/utils/resolveConfig.js +0 -23
  126. package/lib/utils/resolveLibraryOptions.d.ts +0 -11
  127. package/lib/utils/resolveLibraryOptions.js +0 -13
  128. package/lib-esm/GraphQLAPI.js +0 -55
  129. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +0 -64
  130. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +0 -804
  131. package/lib-esm/index.js +0 -5
  132. package/lib-esm/internals/InternalGraphQLAPI.d.ts +0 -58
  133. package/lib-esm/internals/InternalGraphQLAPI.js +0 -314
  134. package/lib-esm/internals/index.js +0 -4
  135. package/lib-esm/tsconfig.tsbuildinfo +0 -6619
  136. package/lib-esm/types/PubSub.d.ts +0 -27
  137. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +0 -1
  138. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +0 -1
  139. package/lib-esm/utils/ReachabilityMonitor/index.native.js +0 -7
  140. package/lib-esm/utils/errors/APIError.js +0 -20
  141. package/lib-esm/utils/errors/assertValidationError.js +0 -13
  142. package/lib-esm/utils/errors/index.js +0 -5
  143. package/lib-esm/utils/index.js +0 -4
  144. package/lib-esm/utils/resolveConfig.d.ts +0 -12
  145. package/lib-esm/utils/resolveConfig.js +0 -21
  146. package/lib-esm/utils/resolveLibraryOptions.js +0 -11
  147. /package/{lib-esm → dist/esm}/Providers/constants.d.ts +0 -0
  148. /package/{lib-esm → dist/esm}/index.d.ts +0 -0
  149. /package/{lib-esm → dist/esm}/internals/index.d.ts +0 -0
  150. /package/{lib-esm → dist/esm}/internals/v6.d.ts +0 -0
  151. /package/{lib-esm → dist/esm}/utils/ReconnectionMonitor.d.ts +0 -0
  152. /package/{lib-esm → dist/esm}/utils/errors/APIError.d.ts +0 -0
  153. /package/{lib-esm → dist/esm}/utils/errors/assertValidationError.d.ts +0 -0
  154. /package/{lib-esm → dist/esm}/utils/errors/index.d.ts +0 -0
  155. /package/{lib-esm → dist/esm}/utils/errors/validation.d.ts +0 -0
  156. /package/{lib-esm → dist/esm}/utils/index.d.ts +0 -0
@@ -1,15 +1,14 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var CONTROL_MSG;
4
+ exports.ConnectionState = exports.CONTROL_MSG = void 0;
4
5
  (function (CONTROL_MSG) {
5
6
  CONTROL_MSG["CONNECTION_CLOSED"] = "Connection closed";
6
7
  CONTROL_MSG["CONNECTION_FAILED"] = "Connection failed";
7
8
  CONTROL_MSG["REALTIME_SUBSCRIPTION_INIT_ERROR"] = "AppSync Realtime subscription init error";
8
9
  CONTROL_MSG["SUBSCRIPTION_ACK"] = "Subscription ack";
9
10
  CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
10
- })(CONTROL_MSG = exports.CONTROL_MSG || (exports.CONTROL_MSG = {}));
11
- /** @enum {string} */
12
- var ConnectionState;
11
+ })(exports.CONTROL_MSG || (exports.CONTROL_MSG = {}));
13
12
  (function (ConnectionState) {
14
13
  /*
15
14
  * The connection is alive and healthy
@@ -43,4 +42,5 @@ var ConnectionState;
43
42
  * The connection is alive, but a keep alive message has been missed
44
43
  */
45
44
  ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
46
- })(ConnectionState = exports.ConnectionState || (exports.ConnectionState = {}));
45
+ })(exports.ConnectionState || (exports.ConnectionState = {}));
46
+ //# sourceMappingURL=PubSub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PubSub.js","sources":["../../../src/types/PubSub.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar CONTROL_MSG;\n(function (CONTROL_MSG) {\n CONTROL_MSG[\"CONNECTION_CLOSED\"] = \"Connection closed\";\n CONTROL_MSG[\"CONNECTION_FAILED\"] = \"Connection failed\";\n CONTROL_MSG[\"REALTIME_SUBSCRIPTION_INIT_ERROR\"] = \"AppSync Realtime subscription init error\";\n CONTROL_MSG[\"SUBSCRIPTION_ACK\"] = \"Subscription ack\";\n CONTROL_MSG[\"TIMEOUT_DISCONNECT\"] = \"Timeout disconnect\";\n})(CONTROL_MSG = exports.CONTROL_MSG || (exports.CONTROL_MSG = {}));\n/** @enum {string} */\nvar ConnectionState;\n(function (ConnectionState) {\n /*\n * The connection is alive and healthy\n */\n ConnectionState[\"Connected\"] = \"Connected\";\n /*\n * The connection is alive, but the connection is offline\n */\n ConnectionState[\"ConnectedPendingNetwork\"] = \"ConnectedPendingNetwork\";\n /*\n * The connection has been disconnected while in use\n */\n ConnectionState[\"ConnectionDisrupted\"] = \"ConnectionDisrupted\";\n /*\n * The connection has been disconnected and the network is offline\n */\n ConnectionState[\"ConnectionDisruptedPendingNetwork\"] = \"ConnectionDisruptedPendingNetwork\";\n /*\n * The connection is in the process of connecting\n */\n ConnectionState[\"Connecting\"] = \"Connecting\";\n /*\n * The connection is not in use and is being disconnected\n */\n ConnectionState[\"ConnectedPendingDisconnect\"] = \"ConnectedPendingDisconnect\";\n /*\n * The connection is not in use and has been disconnected\n */\n ConnectionState[\"Disconnected\"] = \"Disconnected\";\n /*\n * The connection is alive, but a keep alive message has been missed\n */\n ConnectionState[\"ConnectedPendingKeepAlive\"] = \"ConnectedPendingKeepAlive\";\n})(ConnectionState = exports.ConnectionState || (exports.ConnectionState = {}));\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AAEvD,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAC3D,IAAI,WAAW,CAAC,kCAAkC,CAAC,GAAG,0CAA0C,CAAC;AACjG,IAAI,WAAW,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACzD,IAAI,WAAW,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;AAC7D,CAAC,EAAgB,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,CAAC,CAAC;AAGpE,CAAC,UAAU,eAAe,EAAE;AAC5B;AACA;AACA;AACA,IAAI,eAAe,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC;AAC/C;AACA;AACA;AACA,IAAI,eAAe,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AAC3E;AACA;AACA;AACA,IAAI,eAAe,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AACnE;AACA;AACA;AACA,IAAI,eAAe,CAAC,mCAAmC,CAAC,GAAG,mCAAmC,CAAC;AAC/F;AACA;AACA;AACA,IAAI,eAAe,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AACjD;AACA;AACA;AACA,IAAI,eAAe,CAAC,4BAA4B,CAAC,GAAG,4BAA4B,CAAC;AACjF;AACA;AACA;AACA,IAAI,eAAe,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACrD;AACA;AACA;AACA,IAAI,eAAe,CAAC,2BAA2B,CAAC,GAAG,2BAA2B,CAAC;AAC/E,CAAC,EAAoB,OAAO,CAAC,eAAe,KAAK,OAAO,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC;;"}
@@ -1,14 +1,16 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;
3
5
  var PubSub_1 = require("./PubSub");
4
- exports.CONTROL_MSG = PubSub_1.CONTROL_MSG;
5
- exports.ConnectionState = PubSub_1.ConnectionState;
6
- var GraphQLAuthError;
6
+ Object.defineProperty(exports, "CONTROL_MSG", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });
7
+ Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });
7
8
  (function (GraphQLAuthError) {
8
9
  GraphQLAuthError["NO_API_KEY"] = "No api-key configured";
9
10
  GraphQLAuthError["NO_CURRENT_USER"] = "No current user";
10
11
  GraphQLAuthError["NO_CREDENTIALS"] = "No credentials";
11
12
  GraphQLAuthError["NO_FEDERATED_JWT"] = "No federated jwt";
12
13
  GraphQLAuthError["NO_AUTH_TOKEN"] = "No auth token specified";
13
- })(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));
14
+ })(exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));
14
15
  exports.__amplify = Symbol('amplify');
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/types/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.__amplify = exports.GraphQLAuthError = exports.ConnectionState = exports.CONTROL_MSG = void 0;\nvar PubSub_1 = require(\"./PubSub\");\nObject.defineProperty(exports, \"CONTROL_MSG\", { enumerable: true, get: function () { return PubSub_1.CONTROL_MSG; } });\nObject.defineProperty(exports, \"ConnectionState\", { enumerable: true, get: function () { return PubSub_1.ConnectionState; } });\nvar GraphQLAuthError;\n(function (GraphQLAuthError) {\n GraphQLAuthError[\"NO_API_KEY\"] = \"No api-key configured\";\n GraphQLAuthError[\"NO_CURRENT_USER\"] = \"No current user\";\n GraphQLAuthError[\"NO_CREDENTIALS\"] = \"No credentials\";\n GraphQLAuthError[\"NO_FEDERATED_JWT\"] = \"No federated jwt\";\n GraphQLAuthError[\"NO_AUTH_TOKEN\"] = \"No auth token specified\";\n})(GraphQLAuthError = exports.GraphQLAuthError || (exports.GraphQLAuthError = {}));\nexports.__amplify = Symbol('amplify');\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC;AACtG,IAAI,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACnC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;AACvH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC;AAE/H,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,uBAAuB,CAAC;AAC7D,IAAI,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC5D,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AAC1D,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AAC9D,IAAI,gBAAgB,CAAC,eAAe,CAAC,GAAG,yBAAyB,CAAC;AAClE,CAAC,EAAqB,OAAO,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,CAAC;AACnF,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;;"}
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConnectionStateMonitor = exports.CONNECTION_CHANGE = void 0;
7
+ const rxjs_1 = require("rxjs");
8
+ const PubSub_1 = require("../types/PubSub");
9
+ const ReachabilityMonitor_1 = require("./ReachabilityMonitor");
10
+ exports.CONNECTION_CHANGE = {
11
+ KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },
12
+ KEEP_ALIVE: { keepAliveState: 'healthy' },
13
+ CONNECTION_ESTABLISHED: { connectionState: 'connected' },
14
+ CONNECTION_FAILED: {
15
+ intendedConnectionState: 'disconnected',
16
+ connectionState: 'disconnected',
17
+ },
18
+ CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },
19
+ OPENING_CONNECTION: {
20
+ intendedConnectionState: 'connected',
21
+ connectionState: 'connecting',
22
+ },
23
+ CLOSED: { connectionState: 'disconnected' },
24
+ ONLINE: { networkState: 'connected' },
25
+ OFFLINE: { networkState: 'disconnected' },
26
+ };
27
+ class ConnectionStateMonitor {
28
+ constructor() {
29
+ this._networkMonitoringSubscription = undefined;
30
+ this._linkedConnectionState = {
31
+ networkState: 'connected',
32
+ connectionState: 'disconnected',
33
+ intendedConnectionState: 'disconnected',
34
+ keepAliveState: 'healthy',
35
+ };
36
+ // Attempt to update the state with the current actual network state
37
+ this._initialNetworkStateSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {
38
+ this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
39
+ this._initialNetworkStateSubscription?.unsubscribe();
40
+ });
41
+ this._linkedConnectionStateObservable =
42
+ new rxjs_1.Observable(connectionStateObserver => {
43
+ connectionStateObserver.next(this._linkedConnectionState);
44
+ this._linkedConnectionStateObserver = connectionStateObserver;
45
+ });
46
+ }
47
+ /**
48
+ * Turn network state monitoring on if it isn't on already
49
+ */
50
+ enableNetworkMonitoring() {
51
+ // If no initial network state was discovered, stop trying
52
+ this._initialNetworkStateSubscription?.unsubscribe();
53
+ // Maintain the network state based on the reachability monitor
54
+ if (this._networkMonitoringSubscription === undefined) {
55
+ this._networkMonitoringSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {
56
+ this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);
57
+ });
58
+ }
59
+ }
60
+ /**
61
+ * Turn network state monitoring off if it isn't off already
62
+ */
63
+ disableNetworkMonitoring() {
64
+ this._networkMonitoringSubscription?.unsubscribe();
65
+ this._networkMonitoringSubscription = undefined;
66
+ }
67
+ /**
68
+ * Get the observable that allows us to monitor the connection state
69
+ *
70
+ * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
71
+ */
72
+ get connectionStateObservable() {
73
+ let previous;
74
+ // The linked state aggregates state changes to any of the network, connection,
75
+ // intendedConnection and keepAliveHealth. Some states will change these independent
76
+ // states without changing the overall connection state.
77
+ // After translating from linked states to ConnectionState, then remove any duplicates
78
+ return this._linkedConnectionStateObservable
79
+ .pipe((0, rxjs_1.map)(value => {
80
+ return this.connectionStatesTranslator(value);
81
+ }))
82
+ .pipe((0, rxjs_1.filter)(current => {
83
+ const toInclude = current !== previous;
84
+ previous = current;
85
+ return toInclude;
86
+ }));
87
+ }
88
+ /*
89
+ * Updates local connection state and emits the full state to the observer.
90
+ */
91
+ record(statusUpdates) {
92
+ // Maintain the network monitor
93
+ if (statusUpdates.intendedConnectionState === 'connected') {
94
+ this.enableNetworkMonitoring();
95
+ }
96
+ else if (statusUpdates.intendedConnectionState === 'disconnected') {
97
+ this.disableNetworkMonitoring();
98
+ }
99
+ // Maintain the socket state
100
+ const newSocketStatus = {
101
+ ...this._linkedConnectionState,
102
+ ...statusUpdates,
103
+ };
104
+ this._linkedConnectionState = { ...newSocketStatus };
105
+ this._linkedConnectionStateObserver?.next(this._linkedConnectionState);
106
+ }
107
+ /*
108
+ * Translate the ConnectionState structure into a specific ConnectionState string literal union
109
+ */
110
+ connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {
111
+ if (connectionState === 'connected' && networkState === 'disconnected')
112
+ return PubSub_1.ConnectionState.ConnectedPendingNetwork;
113
+ if (connectionState === 'connected' &&
114
+ intendedConnectionState === 'disconnected')
115
+ return PubSub_1.ConnectionState.ConnectedPendingDisconnect;
116
+ if (connectionState === 'disconnected' &&
117
+ intendedConnectionState === 'connected' &&
118
+ networkState === 'disconnected')
119
+ return PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork;
120
+ if (connectionState === 'disconnected' &&
121
+ intendedConnectionState === 'connected')
122
+ return PubSub_1.ConnectionState.ConnectionDisrupted;
123
+ if (connectionState === 'connected' && keepAliveState === 'unhealthy')
124
+ return PubSub_1.ConnectionState.ConnectedPendingKeepAlive;
125
+ // All remaining states directly correspond to the connection state
126
+ if (connectionState === 'connecting')
127
+ return PubSub_1.ConnectionState.Connecting;
128
+ if (connectionState === 'disconnected')
129
+ return PubSub_1.ConnectionState.Disconnected;
130
+ return PubSub_1.ConnectionState.Connected;
131
+ }
132
+ }
133
+ exports.ConnectionStateMonitor = ConnectionStateMonitor;
134
+ //# sourceMappingURL=ConnectionStateMonitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionStateMonitor.js","sources":["../../../src/utils/ConnectionStateMonitor.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ConnectionStateMonitor = exports.CONNECTION_CHANGE = void 0;\nconst rxjs_1 = require(\"rxjs\");\nconst PubSub_1 = require(\"../types/PubSub\");\nconst ReachabilityMonitor_1 = require(\"./ReachabilityMonitor\");\nexports.CONNECTION_CHANGE = {\n KEEP_ALIVE_MISSED: { keepAliveState: 'unhealthy' },\n KEEP_ALIVE: { keepAliveState: 'healthy' },\n CONNECTION_ESTABLISHED: { connectionState: 'connected' },\n CONNECTION_FAILED: {\n intendedConnectionState: 'disconnected',\n connectionState: 'disconnected',\n },\n CLOSING_CONNECTION: { intendedConnectionState: 'disconnected' },\n OPENING_CONNECTION: {\n intendedConnectionState: 'connected',\n connectionState: 'connecting',\n },\n CLOSED: { connectionState: 'disconnected' },\n ONLINE: { networkState: 'connected' },\n OFFLINE: { networkState: 'disconnected' },\n};\nclass ConnectionStateMonitor {\n constructor() {\n this._networkMonitoringSubscription = undefined;\n this._linkedConnectionState = {\n networkState: 'connected',\n connectionState: 'disconnected',\n intendedConnectionState: 'disconnected',\n keepAliveState: 'healthy',\n };\n // Attempt to update the state with the current actual network state\n this._initialNetworkStateSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {\n this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);\n this._initialNetworkStateSubscription?.unsubscribe();\n });\n this._linkedConnectionStateObservable =\n new rxjs_1.Observable(connectionStateObserver => {\n connectionStateObserver.next(this._linkedConnectionState);\n this._linkedConnectionStateObserver = connectionStateObserver;\n });\n }\n /**\n * Turn network state monitoring on if it isn't on already\n */\n enableNetworkMonitoring() {\n // If no initial network state was discovered, stop trying\n this._initialNetworkStateSubscription?.unsubscribe();\n // Maintain the network state based on the reachability monitor\n if (this._networkMonitoringSubscription === undefined) {\n this._networkMonitoringSubscription = (0, ReachabilityMonitor_1.ReachabilityMonitor)().subscribe(({ online }) => {\n this.record(online ? exports.CONNECTION_CHANGE.ONLINE : exports.CONNECTION_CHANGE.OFFLINE);\n });\n }\n }\n /**\n * Turn network state monitoring off if it isn't off already\n */\n disableNetworkMonitoring() {\n this._networkMonitoringSubscription?.unsubscribe();\n this._networkMonitoringSubscription = undefined;\n }\n /**\n * Get the observable that allows us to monitor the connection state\n *\n * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates\n */\n get connectionStateObservable() {\n let previous;\n // The linked state aggregates state changes to any of the network, connection,\n // intendedConnection and keepAliveHealth. Some states will change these independent\n // states without changing the overall connection state.\n // After translating from linked states to ConnectionState, then remove any duplicates\n return this._linkedConnectionStateObservable\n .pipe((0, rxjs_1.map)(value => {\n return this.connectionStatesTranslator(value);\n }))\n .pipe((0, rxjs_1.filter)(current => {\n const toInclude = current !== previous;\n previous = current;\n return toInclude;\n }));\n }\n /*\n * Updates local connection state and emits the full state to the observer.\n */\n record(statusUpdates) {\n // Maintain the network monitor\n if (statusUpdates.intendedConnectionState === 'connected') {\n this.enableNetworkMonitoring();\n }\n else if (statusUpdates.intendedConnectionState === 'disconnected') {\n this.disableNetworkMonitoring();\n }\n // Maintain the socket state\n const newSocketStatus = {\n ...this._linkedConnectionState,\n ...statusUpdates,\n };\n this._linkedConnectionState = { ...newSocketStatus };\n this._linkedConnectionStateObserver?.next(this._linkedConnectionState);\n }\n /*\n * Translate the ConnectionState structure into a specific ConnectionState string literal union\n */\n connectionStatesTranslator({ connectionState, networkState, intendedConnectionState, keepAliveState, }) {\n if (connectionState === 'connected' && networkState === 'disconnected')\n return PubSub_1.ConnectionState.ConnectedPendingNetwork;\n if (connectionState === 'connected' &&\n intendedConnectionState === 'disconnected')\n return PubSub_1.ConnectionState.ConnectedPendingDisconnect;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected' &&\n networkState === 'disconnected')\n return PubSub_1.ConnectionState.ConnectionDisruptedPendingNetwork;\n if (connectionState === 'disconnected' &&\n intendedConnectionState === 'connected')\n return PubSub_1.ConnectionState.ConnectionDisrupted;\n if (connectionState === 'connected' && keepAliveState === 'unhealthy')\n return PubSub_1.ConnectionState.ConnectedPendingKeepAlive;\n // All remaining states directly correspond to the connection state\n if (connectionState === 'connecting')\n return PubSub_1.ConnectionState.Connecting;\n if (connectionState === 'disconnected')\n return PubSub_1.ConnectionState.Disconnected;\n return PubSub_1.ConnectionState.Connected;\n }\n}\nexports.ConnectionStateMonitor = ConnectionStateMonitor;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EA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AK,cAAc;AAC9E,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,uBAAuB,CAAC;AACpE,QAAQ,IAAI,eAAe,KAAK,WAAW;AAC3C,YAAY,uBAAuB,KAAK,cAAc;AACtD,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,0BAA0B,CAAC;AACvE,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,YAAY,KAAK,cAAc;AAC3C,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,iCAAiC,CAAC;AAC9E,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,uBAAuB,KAAK,WAAW;AACnD,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC;AAChE,QAAQ,IAAI,eAAe,KAAK,WAAW,IAAI,cAAc,KAAK,WAAW;AAC7E,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,yBAAyB,CAAC;AACtE;AACA,QAAQ,IAAI,eAAe,KAAK,YAAY;AAC5C,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC;AACvD,QAAQ,IAAI,eAAe,KAAK,cAAc;AAC9C,YAAY,OAAO,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC;AACzD,QAAQ,OAAO,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC;AAClD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,sBAAsB,GAAG,sBAAsB;;"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ReachabilityMonitor = void 0;
5
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6
+ // SPDX-License-Identifier: Apache-2.0
7
+ const utils_1 = require("@aws-amplify/core/internals/utils");
8
+ const ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor();
9
+ exports.ReachabilityMonitor = ReachabilityMonitor;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/utils/ReachabilityMonitor/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReachabilityMonitor = void 0;\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor();\nexports.ReachabilityMonitor = ReachabilityMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AACrC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,mBAAmB,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,cAAc,EAAE,CAAC;AAC9E,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ReachabilityMonitor = void 0;
5
+ const tslib_1 = require("tslib");
6
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ // SPDX-License-Identifier: Apache-2.0
8
+ const utils_1 = require("@aws-amplify/core/internals/utils");
9
+ const netinfo_1 = tslib_1.__importDefault(require("@react-native-community/netinfo"));
10
+ const ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor(netinfo_1.default);
11
+ exports.ReachabilityMonitor = ReachabilityMonitor;
12
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sources":["../../../../src/utils/ReachabilityMonitor/index.native.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReachabilityMonitor = void 0;\nconst tslib_1 = require(\"tslib\");\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\nconst netinfo_1 = tslib_1.__importDefault(require(\"@react-native-community/netinfo\"));\nconst ReachabilityMonitor = () => new utils_1.Reachability().networkMonitor(netinfo_1.default);\nexports.ReachabilityMonitor = ReachabilityMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AACrC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjC;AACA;AACA,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC,CAAC;AACtF,MAAM,mBAAmB,GAAG,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC/F,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
@@ -1,6 +1,8 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var constants_1 = require("../Providers/constants");
4
+ exports.ReconnectionMonitor = exports.ReconnectEvent = void 0;
5
+ const constants_1 = require("../Providers/constants");
4
6
  var ReconnectEvent;
5
7
  (function (ReconnectEvent) {
6
8
  ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
@@ -12,31 +14,30 @@ var ReconnectEvent;
12
14
  * Attempting to reconnect only once creates unrecoverable states when the network state isn't
13
15
  * supported by the browser, so this keeps retrying every minute until halted.
14
16
  */
15
- var ReconnectionMonitor = /** @class */ (function () {
16
- function ReconnectionMonitor() {
17
+ class ReconnectionMonitor {
18
+ constructor() {
17
19
  this.reconnectObservers = [];
18
20
  }
19
21
  /**
20
22
  * Add reconnect observer to the list of observers to alert on reconnect
21
23
  */
22
- ReconnectionMonitor.prototype.addObserver = function (reconnectObserver) {
24
+ addObserver(reconnectObserver) {
23
25
  this.reconnectObservers.push(reconnectObserver);
24
- };
26
+ }
25
27
  /**
26
28
  * Given a reconnect event, start the appropriate behavior
27
29
  */
28
- ReconnectionMonitor.prototype.record = function (event) {
29
- var _this = this;
30
+ record(event) {
30
31
  if (event === ReconnectEvent.START_RECONNECT) {
31
32
  // If the reconnection hasn't been started
32
33
  if (this.reconnectSetTimeoutId === undefined &&
33
34
  this.reconnectIntervalId === undefined) {
34
- this.reconnectSetTimeoutId = setTimeout(function () {
35
+ this.reconnectSetTimeoutId = setTimeout(() => {
35
36
  // Reconnect now
36
- _this._triggerReconnect();
37
+ this._triggerReconnect();
37
38
  // Retry reconnect every periodically until it works
38
- _this.reconnectIntervalId = setInterval(function () {
39
- _this._triggerReconnect();
39
+ this.reconnectIntervalId = setInterval(() => {
40
+ this._triggerReconnect();
40
41
  }, constants_1.RECONNECT_INTERVAL);
41
42
  }, constants_1.RECONNECT_DELAY);
42
43
  }
@@ -51,22 +52,20 @@ var ReconnectionMonitor = /** @class */ (function () {
51
52
  this.reconnectSetTimeoutId = undefined;
52
53
  }
53
54
  }
54
- };
55
+ }
55
56
  /**
56
57
  * Complete all reconnect observers
57
58
  */
58
- ReconnectionMonitor.prototype.close = function () {
59
- this.reconnectObservers.forEach(function (reconnectObserver) {
60
- var _a;
61
- (_a = reconnectObserver.complete) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
59
+ close() {
60
+ this.reconnectObservers.forEach(reconnectObserver => {
61
+ reconnectObserver.complete?.();
62
62
  });
63
- };
64
- ReconnectionMonitor.prototype._triggerReconnect = function () {
65
- this.reconnectObservers.forEach(function (reconnectObserver) {
66
- var _a;
67
- (_a = reconnectObserver.next) === null || _a === void 0 ? void 0 : _a.call(reconnectObserver);
63
+ }
64
+ _triggerReconnect() {
65
+ this.reconnectObservers.forEach(reconnectObserver => {
66
+ reconnectObserver.next?.();
68
67
  });
69
- };
70
- return ReconnectionMonitor;
71
- }());
68
+ }
69
+ }
72
70
  exports.ReconnectionMonitor = ReconnectionMonitor;
71
+ //# sourceMappingURL=ReconnectionMonitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReconnectionMonitor.js","sources":["../../../src/utils/ReconnectionMonitor.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ReconnectionMonitor = exports.ReconnectEvent = void 0;\nconst constants_1 = require(\"../Providers/constants\");\nvar ReconnectEvent;\n(function (ReconnectEvent) {\n ReconnectEvent[\"START_RECONNECT\"] = \"START_RECONNECT\";\n ReconnectEvent[\"HALT_RECONNECT\"] = \"HALT_RECONNECT\";\n})(ReconnectEvent = exports.ReconnectEvent || (exports.ReconnectEvent = {}));\n/**\n * Captures the reconnect event logic used to determine when to reconnect to PubSub providers.\n * Reconnnect attempts are delayed by 5 seconds to let the interface settle.\n * Attempting to reconnect only once creates unrecoverable states when the network state isn't\n * supported by the browser, so this keeps retrying every minute until halted.\n */\nclass ReconnectionMonitor {\n constructor() {\n this.reconnectObservers = [];\n }\n /**\n * Add reconnect observer to the list of observers to alert on reconnect\n */\n addObserver(reconnectObserver) {\n this.reconnectObservers.push(reconnectObserver);\n }\n /**\n * Given a reconnect event, start the appropriate behavior\n */\n record(event) {\n if (event === ReconnectEvent.START_RECONNECT) {\n // If the reconnection hasn't been started\n if (this.reconnectSetTimeoutId === undefined &&\n this.reconnectIntervalId === undefined) {\n this.reconnectSetTimeoutId = setTimeout(() => {\n // Reconnect now\n this._triggerReconnect();\n // Retry reconnect every periodically until it works\n this.reconnectIntervalId = setInterval(() => {\n this._triggerReconnect();\n }, constants_1.RECONNECT_INTERVAL);\n }, constants_1.RECONNECT_DELAY);\n }\n }\n if (event === ReconnectEvent.HALT_RECONNECT) {\n if (this.reconnectIntervalId) {\n clearInterval(this.reconnectIntervalId);\n this.reconnectIntervalId = undefined;\n }\n if (this.reconnectSetTimeoutId) {\n clearTimeout(this.reconnectSetTimeoutId);\n this.reconnectSetTimeoutId = undefined;\n }\n }\n }\n /**\n * Complete all reconnect observers\n */\n close() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.complete?.();\n });\n }\n _triggerReconnect() {\n this.reconnectObservers.forEach(reconnectObserver => {\n reconnectObserver.next?.();\n });\n }\n}\nexports.ReconnectionMonitor = ReconnectionMonitor;\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACtD,IAAI,cAAc,CAAC;AACnB,CAAC,UAAU,cAAc,EAAE;AAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,iBAAiB,CAAC;AAC1D,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC;AACxD,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,KAAK,OAAO,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,mBAAmB,CAAC;AAC1B,IAAI,WAAW,GAAG;AAClB,QAAQ,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;AACrC,KAAK;AACL;AACA;AACA;AACA,IAAI,WAAW,CAAC,iBAAiB,EAAE;AACnC,QAAQ,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACxD,KAAK;AACL;AACA;AACA;AACA,IAAI,MAAM,CAAC,KA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AiB,CAAC,IAAI,IAAI,CAAC;AACvC,SAAS,CAAC,CAAC;AACX,KAAK;AACL,CAAC;AACD,OAAO,CAAC,mBAAmB,GAAG,mBAAmB;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.APIError = void 0;
7
+ const utils_1 = require("@aws-amplify/core/internals/utils");
8
+ /**
9
+ * @internal
10
+ */
11
+ class APIError extends utils_1.AmplifyError {
12
+ constructor(params) {
13
+ super(params);
14
+ // Hack for making the custom error class work when transpiled to es5
15
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
16
+ this.constructor = APIError;
17
+ Object.setPrototypeOf(this, APIError.prototype);
18
+ }
19
+ }
20
+ exports.APIError = APIError;
21
+ //# sourceMappingURL=APIError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"APIError.js","sources":["../../../../src/utils/errors/APIError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.APIError = void 0;\nconst utils_1 = require(\"@aws-amplify/core/internals/utils\");\n/**\n * @internal\n */\nclass APIError extends utils_1.AmplifyError {\n constructor(params) {\n super(params);\n // Hack for making the custom error class work when transpiled to es5\n // TODO: Delete the following 2 lines after we change the build target to >= es2015\n this.constructor = APIError;\n Object.setPrototypeOf(this, APIError.prototype);\n }\n}\nexports.APIError = APIError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;AAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAC7D;AACA;AACA;AACA,MAAM,QAAQ,SAAS,OAAO,CAAC,YAAY,CAAC;AAC5C,IAAI,WAAW,CAAC,MAAM,EAAE;AACxB,QAAQ,KAAK,CAAC,MAAM,CAAC,CAAC;AACtB;AACA;AACA,QAAQ,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;AACpC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxD,KAAK;AACL,CAAC;AACD,OAAO,CAAC,QAAQ,GAAG,QAAQ;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.assertValidationError = void 0;
7
+ const APIError_1 = require("./APIError");
8
+ const validation_1 = require("./validation");
9
+ /**
10
+ * @internal
11
+ */
12
+ function assertValidationError(assertion, name) {
13
+ const { message, recoverySuggestion } = validation_1.validationErrorMap[name];
14
+ if (!assertion) {
15
+ throw new APIError_1.APIError({ name, message, recoverySuggestion });
16
+ }
17
+ }
18
+ exports.assertValidationError = assertValidationError;
19
+ //# sourceMappingURL=assertValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertValidationError.js","sources":["../../../../src/utils/errors/assertValidationError.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.assertValidationError = void 0;\nconst APIError_1 = require(\"./APIError\");\nconst validation_1 = require(\"./validation\");\n/**\n * @internal\n */\nfunction assertValidationError(assertion, name) {\n const { message, recoverySuggestion } = validation_1.validationErrorMap[name];\n if (!assertion) {\n throw new APIError_1.APIError({ name, message, recoverySuggestion });\n }\n}\nexports.assertValidationError = assertValidationError;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AACvC,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACzC,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC7C;AACA;AACA;AACA,SAAS,qBAAqB,CAAC,SAAS,EAAE,IAAI,EAAE;AAChD,IAAI,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClF,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC7E,KAAK;AACL,CAAC;AACD,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.APIError = void 0;
7
+ var APIError_1 = require("./APIError");
8
+ Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return APIError_1.APIError; } });
9
+ var assertValidationError_1 = require("./assertValidationError");
10
+ Object.defineProperty(exports, "assertValidationError", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });
11
+ var validation_1 = require("./validation");
12
+ Object.defineProperty(exports, "APIValidationErrorCode", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });
13
+ Object.defineProperty(exports, "validationErrorMap", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/utils/errors/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.APIValidationErrorCode = exports.assertValidationError = exports.APIError = void 0;\nvar APIError_1 = require(\"./APIError\");\nObject.defineProperty(exports, \"APIError\", { enumerable: true, get: function () { return APIError_1.APIError; } });\nvar assertValidationError_1 = require(\"./assertValidationError\");\nObject.defineProperty(exports, \"assertValidationError\", { enumerable: true, get: function () { return assertValidationError_1.assertValidationError; } });\nvar validation_1 = require(\"./validation\");\nObject.defineProperty(exports, \"APIValidationErrorCode\", { enumerable: true, get: function () { return validation_1.APIValidationErrorCode; } });\nObject.defineProperty(exports, \"validationErrorMap\", { enumerable: true, get: function () { return validation_1.validationErrorMap; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;AACxH,IAAI,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;AACnH,IAAI,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACjE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1J,IAAI,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAC3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,wBAAwB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,sBAAsB,CAAC,EAAE,EAAE,CAAC,CAAC;AACjJ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,YAAY,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -1,26 +1,28 @@
1
- "use strict";
1
+ 'use strict';
2
+
2
3
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
4
  // SPDX-License-Identifier: Apache-2.0
4
- var _a;
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validationErrorMap = exports.APIValidationErrorCode = void 0;
6
7
  var APIValidationErrorCode;
7
8
  (function (APIValidationErrorCode) {
8
9
  APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
9
10
  APIValidationErrorCode["NoRegion"] = "NoRegion";
10
11
  APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
11
12
  })(APIValidationErrorCode = exports.APIValidationErrorCode || (exports.APIValidationErrorCode = {}));
12
- exports.validationErrorMap = (_a = {},
13
- _a[APIValidationErrorCode.NoAuthSession] = {
13
+ exports.validationErrorMap = {
14
+ [APIValidationErrorCode.NoAuthSession]: {
14
15
  message: 'Auth session should not be empty.',
15
16
  },
16
17
  // TODO: re-enable when working in all test environments:
17
18
  // [APIValidationErrorCode.NoEndpoint]: {
18
19
  // message: 'Missing endpoint',
19
20
  // },
20
- _a[APIValidationErrorCode.NoRegion] = {
21
+ [APIValidationErrorCode.NoRegion]: {
21
22
  message: 'Missing region.',
22
23
  },
23
- _a[APIValidationErrorCode.NoCustomEndpoint] = {
24
+ [APIValidationErrorCode.NoCustomEndpoint]: {
24
25
  message: 'Custom endpoint region is present without custom endpoint.',
25
26
  },
26
- _a);
27
+ };
28
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sources":["../../../../src/utils/errors/validation.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.validationErrorMap = exports.APIValidationErrorCode = void 0;\nvar APIValidationErrorCode;\n(function (APIValidationErrorCode) {\n APIValidationErrorCode[\"NoAuthSession\"] = \"NoAuthSession\";\n APIValidationErrorCode[\"NoRegion\"] = \"NoRegion\";\n APIValidationErrorCode[\"NoCustomEndpoint\"] = \"NoCustomEndpoint\";\n})(APIValidationErrorCode = exports.APIValidationErrorCode || (exports.APIValidationErrorCode = {}));\nexports.validationErrorMap = {\n [APIValidationErrorCode.NoAuthSession]: {\n message: 'Auth session should not be empty.',\n },\n // TODO: re-enable when working in all test environments:\n // [APIValidationErrorCode.NoEndpoint]: {\n // \tmessage: 'Missing endpoint',\n // },\n [APIValidationErrorCode.NoRegion]: {\n message: 'Missing region.',\n },\n [APIValidationErrorCode.NoCustomEndpoint]: {\n message: 'Custom endpoint region is present without custom endpoint.',\n },\n};\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,sBAAsB,GAAG,KAAK,CAAC,CAAC;AACrE,IAAI,sBAAsB,CAAC;AAC3B,CAAC,UAAU,sBAAsB,EAAE;AACnC,IAAI,sBAAsB,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AAC9D,IAAI,sBAAsB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACpD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAAC;AACpE,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,KAAK,OAAO,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC,CAAC;AACrG,OAAO,CAAC,kBAAkB,GAAG;AAC7B,IAAI,CAAC,sBAAsB,CAAC,aAAa,GAAG;AAC5C,QAAQ,OAAO,EAAE,mCAAmC;AACpD,KAAK;AACL;AACA;AACA;AACA;AACA,IAAI,CAAC,sBAAsB,CAAC,QAAQ,GAAG;AACvC,QAAQ,OAAO,EAAE,iBAAiB;AAClC,KAAK;AACL,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,GAAG;AAC/C,QAAQ,OAAO,EAAE,4DAA4D;AAC7E,KAAK;AACL,CAAC;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveLibraryOptions = exports.resolveConfig = void 0;
7
+ var resolveConfig_1 = require("./resolveConfig");
8
+ Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });
9
+ var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
10
+ Object.defineProperty(exports, "resolveLibraryOptions", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/utils/index.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLibraryOptions = exports.resolveConfig = void 0;\nvar resolveConfig_1 = require(\"./resolveConfig\");\nObject.defineProperty(exports, \"resolveConfig\", { enumerable: true, get: function () { return resolveConfig_1.resolveConfig; } });\nvar resolveLibraryOptions_1 = require(\"./resolveLibraryOptions\");\nObject.defineProperty(exports, \"resolveLibraryOptions\", { enumerable: true, get: function () { return resolveLibraryOptions_1.resolveLibraryOptions; } });\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/D,IAAI,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,eAAe,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;AAClI,IAAI,uBAAuB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACjE,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC;;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveConfig = void 0;
7
+ const errors_1 = require("./errors");
8
+ /**
9
+ * @internal
10
+ */
11
+ const resolveConfig = (amplify) => {
12
+ const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};
13
+ // TODO: re-enable when working in all test environments:
14
+ // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
15
+ (0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
16
+ return {
17
+ apiKey,
18
+ customEndpoint,
19
+ customEndpointRegion,
20
+ defaultAuthMode,
21
+ endpoint,
22
+ region,
23
+ };
24
+ };
25
+ exports.resolveConfig = resolveConfig;
26
+ //# sourceMappingURL=resolveConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveConfig.js","sources":["../../../src/utils/resolveConfig.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveConfig = void 0;\nconst errors_1 = require(\"./errors\");\n/**\n * @internal\n */\nconst resolveConfig = (amplify) => {\n const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};\n // TODO: re-enable when working in all test environments:\n // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);\n (0, errors_1.assertValidationError)(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);\n return {\n apiKey,\n customEndpoint,\n customEndpointRegion,\n defaultAuthMode,\n endpoint,\n region,\n };\n};\nexports.resolveConfig = resolveConfig;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AACrC;AACA;AACA;AACA,MAAM,aAAa,GAAG,CAAC,OAAO,KAAK;AACnC,IAAI,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAC;AACxI;AACA;AACA,IAAI,IAAI,QAAQ,CAAC,qBAAqB,EAAE,EAAE,CAAC,cAAc,IAAI,oBAAoB,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;AACtI,IAAI,OAAO;AACX,QAAQ,MAAM;AACd,QAAQ,cAAc;AACtB,QAAQ,oBAAoB;AAC5B,QAAQ,eAAe;AACvB,QAAQ,QAAQ;AAChB,QAAQ,MAAM;AACd,KAAK,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,aAAa,GAAG,aAAa;;"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveLibraryOptions = void 0;
7
+ /**
8
+ * @internal
9
+ */
10
+ const resolveLibraryOptions = (amplify) => {
11
+ const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
12
+ const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
13
+ return { headers, withCredentials };
14
+ };
15
+ exports.resolveLibraryOptions = resolveLibraryOptions;
16
+ //# sourceMappingURL=resolveLibraryOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveLibraryOptions.js","sources":["../../../src/utils/resolveLibraryOptions.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveLibraryOptions = void 0;\n/**\n * @internal\n */\nconst resolveLibraryOptions = (amplify) => {\n const headers = amplify.libraryOptions?.API?.GraphQL?.headers;\n const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;\n return { headers, withCredentials };\n};\nexports.resolveLibraryOptions = resolveLibraryOptions;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,qBAAqB,GAAG,KAAK,CAAC,CAAC;AACvC;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,CAAC,OAAO,KAAK;AAC3C,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC;AAClE,IAAI,MAAM,eAAe,GAAG,OAAO,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,CAAC;AAClF,IAAI,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AACxC,CAAC,CAAC;AACF,OAAO,CAAC,qBAAqB,GAAG,qBAAqB;;"}
@@ -2,7 +2,7 @@ import { AmplifyClassV6 } from '@aws-amplify/core';
2
2
  import { GraphQLOptions, GraphQLResult } from './types';
3
3
  import { InternalGraphQLAPIClass } from './internals';
4
4
  import { Observable } from 'rxjs';
5
- export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
5
+ export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
6
6
  query: any;
7
7
  variables: {};
8
8
  authToken: string | undefined;
@@ -19,7 +19,7 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
19
19
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
20
20
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
21
21
  */
22
- graphql<T = any>(amplify: AmplifyClassV6, options: GraphQLOptions, additionalHeaders?: {
22
+ graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: {
23
23
  [key: string]: string;
24
24
  }): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
25
25
  /**