@aws-amplify/api-graphql 3.4.12-unstable.7762f1a.0 → 4.0.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 (116) hide show
  1. package/README.md +3 -0
  2. package/lib/GraphQLAPI.d.ts +17 -4
  3. package/lib/GraphQLAPI.js +33 -27
  4. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
  5. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +690 -0
  6. package/lib/Providers/constants.d.ts +95 -0
  7. package/lib/Providers/constants.js +103 -0
  8. package/lib/index.d.ts +1 -3
  9. package/lib/index.js +6 -10
  10. package/lib/internals/InternalGraphQLAPI.d.ts +11 -34
  11. package/lib/internals/InternalGraphQLAPI.js +219 -345
  12. package/lib/internals/index.d.ts +1 -0
  13. package/lib/internals/index.js +4 -1
  14. package/lib/internals/v6.d.ts +101 -0
  15. package/lib/internals/v6.js +118 -0
  16. package/lib/tsconfig.tsbuildinfo +6813 -0
  17. package/lib/types/PubSub.d.ts +27 -0
  18. package/lib/types/PubSub.js +46 -0
  19. package/lib/types/index.d.ts +281 -5
  20. package/lib/types/index.js +4 -3
  21. package/lib/utils/ConnectionStateMonitor.d.ts +41 -0
  22. package/lib/utils/ConnectionStateMonitor.js +131 -0
  23. package/lib/utils/ReachabilityMonitor/index.d.ts +1 -0
  24. package/lib/utils/ReachabilityMonitor/index.js +6 -0
  25. package/lib/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  26. package/lib/utils/ReachabilityMonitor/index.native.js +8 -0
  27. package/lib/utils/ReconnectionMonitor.d.ts +29 -0
  28. package/lib/utils/ReconnectionMonitor.js +68 -0
  29. package/lib/utils/errors/APIError.d.ts +7 -0
  30. package/lib/utils/errors/APIError.js +18 -0
  31. package/lib/utils/errors/assertValidationError.d.ts +5 -0
  32. package/lib/utils/errors/assertValidationError.js +16 -0
  33. package/lib/utils/errors/index.d.ts +3 -0
  34. package/lib/utils/errors/index.js +11 -0
  35. package/lib/utils/errors/validation.d.ts +7 -0
  36. package/lib/utils/errors/validation.js +25 -0
  37. package/lib/utils/index.d.ts +2 -0
  38. package/lib/utils/index.js +8 -0
  39. package/lib/utils/resolveConfig.d.ts +12 -0
  40. package/lib/utils/resolveConfig.js +22 -0
  41. package/lib/utils/resolveLibraryOptions.d.ts +11 -0
  42. package/lib/utils/resolveLibraryOptions.js +12 -0
  43. package/lib-esm/GraphQLAPI.d.ts +17 -4
  44. package/lib-esm/GraphQLAPI.js +33 -28
  45. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +64 -0
  46. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +687 -0
  47. package/lib-esm/Providers/constants.d.ts +95 -0
  48. package/lib-esm/Providers/constants.js +100 -0
  49. package/lib-esm/index.d.ts +1 -3
  50. package/lib-esm/index.js +1 -4
  51. package/lib-esm/internals/InternalGraphQLAPI.d.ts +11 -34
  52. package/lib-esm/internals/InternalGraphQLAPI.js +218 -345
  53. package/lib-esm/internals/index.d.ts +1 -0
  54. package/lib-esm/internals/index.js +1 -1
  55. package/lib-esm/internals/v6.d.ts +101 -0
  56. package/lib-esm/internals/v6.js +113 -0
  57. package/lib-esm/tsconfig.tsbuildinfo +6813 -0
  58. package/lib-esm/types/PubSub.d.ts +27 -0
  59. package/lib-esm/types/PubSub.js +44 -0
  60. package/lib-esm/types/index.d.ts +281 -5
  61. package/lib-esm/types/index.js +2 -3
  62. package/lib-esm/utils/ConnectionStateMonitor.d.ts +41 -0
  63. package/lib-esm/utils/ConnectionStateMonitor.js +128 -0
  64. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +1 -0
  65. package/lib-esm/utils/ReachabilityMonitor/index.js +4 -0
  66. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +1 -0
  67. package/lib-esm/utils/ReachabilityMonitor/index.native.js +5 -0
  68. package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
  69. package/lib-esm/utils/ReconnectionMonitor.js +65 -0
  70. package/lib-esm/utils/errors/APIError.d.ts +7 -0
  71. package/lib-esm/utils/errors/APIError.js +15 -0
  72. package/lib-esm/utils/errors/assertValidationError.d.ts +5 -0
  73. package/lib-esm/utils/errors/assertValidationError.js +13 -0
  74. package/lib-esm/utils/errors/index.d.ts +3 -0
  75. package/lib-esm/utils/errors/index.js +5 -0
  76. package/lib-esm/utils/errors/validation.d.ts +7 -0
  77. package/lib-esm/utils/errors/validation.js +23 -0
  78. package/lib-esm/utils/index.d.ts +2 -0
  79. package/lib-esm/utils/index.js +4 -0
  80. package/lib-esm/utils/resolveConfig.d.ts +12 -0
  81. package/lib-esm/utils/resolveConfig.js +20 -0
  82. package/lib-esm/utils/resolveLibraryOptions.d.ts +11 -0
  83. package/lib-esm/utils/resolveLibraryOptions.js +10 -0
  84. package/package.json +122 -114
  85. package/src/GraphQLAPI.ts +26 -4
  86. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +998 -0
  87. package/src/Providers/constants.ts +110 -0
  88. package/src/index.ts +2 -3
  89. package/src/internals/InternalGraphQLAPI.ts +181 -218
  90. package/src/internals/index.ts +2 -0
  91. package/src/internals/v6.ts +138 -0
  92. package/src/types/PubSub.ts +56 -0
  93. package/src/types/index.ts +378 -8
  94. package/src/utils/ConnectionStateMonitor.ts +199 -0
  95. package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
  96. package/src/utils/ReachabilityMonitor/index.ts +4 -0
  97. package/src/utils/ReconnectionMonitor.ts +76 -0
  98. package/src/utils/errors/APIError.ts +21 -0
  99. package/src/utils/errors/assertValidationError.ts +19 -0
  100. package/src/utils/errors/index.ts +6 -0
  101. package/src/utils/errors/validation.ts +26 -0
  102. package/src/utils/index.ts +5 -0
  103. package/src/utils/resolveConfig.ts +35 -0
  104. package/src/utils/resolveLibraryOptions.ts +13 -0
  105. package/lib/.tsbuildinfo +0 -3
  106. package/lib/GraphQLAPI.js.map +0 -1
  107. package/lib/index.js.map +0 -1
  108. package/lib/internals/InternalGraphQLAPI.js.map +0 -1
  109. package/lib/internals/index.js.map +0 -1
  110. package/lib/types/index.js.map +0 -1
  111. package/lib-esm/.tsbuildinfo +0 -3
  112. package/lib-esm/GraphQLAPI.js.map +0 -1
  113. package/lib-esm/index.js.map +0 -1
  114. package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
  115. package/lib-esm/internals/index.js.map +0 -1
  116. package/lib-esm/types/index.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../Providers/constants");
4
+ var ReconnectEvent;
5
+ (function (ReconnectEvent) {
6
+ ReconnectEvent["START_RECONNECT"] = "START_RECONNECT";
7
+ ReconnectEvent["HALT_RECONNECT"] = "HALT_RECONNECT";
8
+ })(ReconnectEvent = exports.ReconnectEvent || (exports.ReconnectEvent = {}));
9
+ /**
10
+ * Captures the reconnect event logic used to determine when to reconnect to PubSub providers.
11
+ * Reconnnect attempts are delayed by 5 seconds to let the interface settle.
12
+ * Attempting to reconnect only once creates unrecoverable states when the network state isn't
13
+ * supported by the browser, so this keeps retrying every minute until halted.
14
+ */
15
+ class ReconnectionMonitor {
16
+ constructor() {
17
+ this.reconnectObservers = [];
18
+ }
19
+ /**
20
+ * Add reconnect observer to the list of observers to alert on reconnect
21
+ */
22
+ addObserver(reconnectObserver) {
23
+ this.reconnectObservers.push(reconnectObserver);
24
+ }
25
+ /**
26
+ * Given a reconnect event, start the appropriate behavior
27
+ */
28
+ record(event) {
29
+ if (event === ReconnectEvent.START_RECONNECT) {
30
+ // If the reconnection hasn't been started
31
+ if (this.reconnectSetTimeoutId === undefined &&
32
+ this.reconnectIntervalId === undefined) {
33
+ this.reconnectSetTimeoutId = setTimeout(() => {
34
+ // Reconnect now
35
+ this._triggerReconnect();
36
+ // Retry reconnect every periodically until it works
37
+ this.reconnectIntervalId = setInterval(() => {
38
+ this._triggerReconnect();
39
+ }, constants_1.RECONNECT_INTERVAL);
40
+ }, constants_1.RECONNECT_DELAY);
41
+ }
42
+ }
43
+ if (event === ReconnectEvent.HALT_RECONNECT) {
44
+ if (this.reconnectIntervalId) {
45
+ clearInterval(this.reconnectIntervalId);
46
+ this.reconnectIntervalId = undefined;
47
+ }
48
+ if (this.reconnectSetTimeoutId) {
49
+ clearTimeout(this.reconnectSetTimeoutId);
50
+ this.reconnectSetTimeoutId = undefined;
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Complete all reconnect observers
56
+ */
57
+ close() {
58
+ this.reconnectObservers.forEach(reconnectObserver => {
59
+ reconnectObserver.complete?.();
60
+ });
61
+ }
62
+ _triggerReconnect() {
63
+ this.reconnectObservers.forEach(reconnectObserver => {
64
+ reconnectObserver.next?.();
65
+ });
66
+ }
67
+ }
68
+ exports.ReconnectionMonitor = ReconnectionMonitor;
@@ -0,0 +1,7 @@
1
+ import { AmplifyError, AmplifyErrorParams } from '@aws-amplify/core/internals/utils';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare class APIError extends AmplifyError {
6
+ constructor(params: AmplifyErrorParams);
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const utils_1 = require("@aws-amplify/core/internals/utils");
6
+ /**
7
+ * @internal
8
+ */
9
+ class APIError extends utils_1.AmplifyError {
10
+ constructor(params) {
11
+ super(params);
12
+ // Hack for making the custom error class work when transpiled to es5
13
+ // TODO: Delete the following 2 lines after we change the build target to >= es2015
14
+ this.constructor = APIError;
15
+ Object.setPrototypeOf(this, APIError.prototype);
16
+ }
17
+ }
18
+ exports.APIError = APIError;
@@ -0,0 +1,5 @@
1
+ import { APIValidationErrorCode } from './validation';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function assertValidationError(assertion: boolean, name: APIValidationErrorCode): asserts assertion;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const APIError_1 = require("./APIError");
6
+ const validation_1 = require("./validation");
7
+ /**
8
+ * @internal
9
+ */
10
+ function assertValidationError(assertion, name) {
11
+ const { message, recoverySuggestion } = validation_1.validationErrorMap[name];
12
+ if (!assertion) {
13
+ throw new APIError_1.APIError({ name, message, recoverySuggestion });
14
+ }
15
+ }
16
+ exports.assertValidationError = assertValidationError;
@@ -0,0 +1,3 @@
1
+ export { APIError } from './APIError';
2
+ export { assertValidationError } from './assertValidationError';
3
+ export { APIValidationErrorCode, validationErrorMap } from './validation';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ var APIError_1 = require("./APIError");
6
+ exports.APIError = APIError_1.APIError;
7
+ var assertValidationError_1 = require("./assertValidationError");
8
+ exports.assertValidationError = assertValidationError_1.assertValidationError;
9
+ var validation_1 = require("./validation");
10
+ exports.APIValidationErrorCode = validation_1.APIValidationErrorCode;
11
+ exports.validationErrorMap = validation_1.validationErrorMap;
@@ -0,0 +1,7 @@
1
+ import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
2
+ export declare enum APIValidationErrorCode {
3
+ NoAuthSession = "NoAuthSession",
4
+ NoRegion = "NoRegion",
5
+ NoCustomEndpoint = "NoCustomEndpoint"
6
+ }
7
+ export declare const validationErrorMap: AmplifyErrorMap<APIValidationErrorCode>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ var APIValidationErrorCode;
6
+ (function (APIValidationErrorCode) {
7
+ APIValidationErrorCode["NoAuthSession"] = "NoAuthSession";
8
+ APIValidationErrorCode["NoRegion"] = "NoRegion";
9
+ APIValidationErrorCode["NoCustomEndpoint"] = "NoCustomEndpoint";
10
+ })(APIValidationErrorCode = exports.APIValidationErrorCode || (exports.APIValidationErrorCode = {}));
11
+ exports.validationErrorMap = {
12
+ [APIValidationErrorCode.NoAuthSession]: {
13
+ message: 'Auth session should not be empty.',
14
+ },
15
+ // TODO: re-enable when working in all test environments:
16
+ // [APIValidationErrorCode.NoEndpoint]: {
17
+ // message: 'Missing endpoint',
18
+ // },
19
+ [APIValidationErrorCode.NoRegion]: {
20
+ message: 'Missing region.',
21
+ },
22
+ [APIValidationErrorCode.NoCustomEndpoint]: {
23
+ message: 'Custom endpoint region is present without custom endpoint.',
24
+ },
25
+ };
@@ -0,0 +1,2 @@
1
+ export { resolveConfig } from './resolveConfig';
2
+ export { resolveLibraryOptions } from './resolveLibraryOptions';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ var resolveConfig_1 = require("./resolveConfig");
6
+ exports.resolveConfig = resolveConfig_1.resolveConfig;
7
+ var resolveLibraryOptions_1 = require("./resolveLibraryOptions");
8
+ exports.resolveLibraryOptions = resolveLibraryOptions_1.resolveLibraryOptions;
@@ -0,0 +1,12 @@
1
+ import { AmplifyClassV6 } from '@aws-amplify/core';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const resolveConfig: (amplify: AmplifyClassV6) => {
6
+ apiKey: string | undefined;
7
+ customEndpoint: string | undefined;
8
+ customEndpointRegion: string | undefined;
9
+ defaultAuthMode: "apiKey" | "oidc" | "userPool" | "iam" | "lambda" | "none" | undefined;
10
+ endpoint: string | undefined;
11
+ region: string | undefined;
12
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const errors_1 = require("./errors");
6
+ /**
7
+ * @internal
8
+ */
9
+ exports.resolveConfig = (amplify) => {
10
+ const { apiKey, customEndpoint, customEndpointRegion, defaultAuthMode, endpoint, region, } = amplify.getConfig().API?.GraphQL ?? {};
11
+ // TODO: re-enable when working in all test environments:
12
+ // assertValidationError(!!endpoint, APIValidationErrorCode.NoEndpoint);
13
+ errors_1.assertValidationError(!(!customEndpoint && customEndpointRegion), errors_1.APIValidationErrorCode.NoCustomEndpoint);
14
+ return {
15
+ apiKey,
16
+ customEndpoint,
17
+ customEndpointRegion,
18
+ defaultAuthMode,
19
+ endpoint,
20
+ region,
21
+ };
22
+ };
@@ -0,0 +1,11 @@
1
+ import { AmplifyClassV6 } from '@aws-amplify/core';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const resolveLibraryOptions: (amplify: AmplifyClassV6) => {
6
+ headers: ((options: {
7
+ query: string;
8
+ variables?: Record<string, import("@aws-amplify/core/lib-esm/libraryUtils").DocumentType> | undefined;
9
+ }) => Promise<Record<string, string>>) | undefined;
10
+ withCredentials: boolean | undefined;
11
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ /**
6
+ * @internal
7
+ */
8
+ exports.resolveLibraryOptions = (amplify) => {
9
+ const headers = amplify.libraryOptions?.API?.GraphQL?.headers;
10
+ const withCredentials = amplify.libraryOptions?.API?.GraphQL?.withCredentials;
11
+ return { headers, withCredentials };
12
+ };
@@ -1,10 +1,11 @@
1
+ import { AmplifyClassV6 } from '@aws-amplify/core';
1
2
  import { GraphQLOptions, GraphQLResult } from './types';
2
3
  import { InternalGraphQLAPIClass } from './internals';
3
- import Observable from 'zen-observable-ts';
4
- export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
4
+ import { Observable } from 'rxjs';
5
+ export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
5
6
  query: any;
6
7
  variables: {};
7
- authToken: string;
8
+ authToken: string | undefined;
8
9
  };
9
10
  /**
10
11
  * Export Cloud Logic APIs
@@ -18,8 +19,20 @@ export declare class GraphQLAPIClass extends InternalGraphQLAPIClass {
18
19
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
19
20
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
20
21
  */
21
- graphql<T = any>(options: GraphQLOptions, additionalHeaders?: {
22
+ graphql<T = any>(amplify: AmplifyClassV6 | (() => Promise<AmplifyClassV6>), options: GraphQLOptions, additionalHeaders?: {
22
23
  [key: string]: string;
23
24
  }): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
25
+ /**
26
+ * Checks to see if an error thrown is from an api request cancellation
27
+ * @param error - Any error
28
+ * @returns A boolean indicating if the error was from an api request cancellation
29
+ */
30
+ isCancelError(error: any): boolean;
31
+ /**
32
+ * Cancels an inflight request. Only applicable for graphql queries and mutations
33
+ * @param {any} request - request to cancel
34
+ * @returns A boolean indicating if the request was cancelled
35
+ */
36
+ cancel(request: Promise<any>, message?: string): boolean;
24
37
  }
25
38
  export declare const GraphQLAPI: GraphQLAPIClass;
@@ -1,27 +1,17 @@
1
- import { __extends } from "tslib";
2
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { Amplify } from '@aws-amplify/core';
1
+ import { Category, ApiAction } from '@aws-amplify/core/internals/utils';
5
2
  import { InternalGraphQLAPIClass } from './internals';
6
- export var graphqlOperation = function (query, variables, authToken) {
7
- if (variables === void 0) { variables = {}; }
8
- return ({
9
- query: query,
10
- variables: variables,
11
- authToken: authToken,
12
- });
13
- };
3
+ export const graphqlOperation = (query, variables = {}, authToken) => ({
4
+ query,
5
+ variables,
6
+ authToken,
7
+ });
14
8
  /**
15
9
  * Export Cloud Logic APIs
16
10
  */
17
- var GraphQLAPIClass = /** @class */ (function (_super) {
18
- __extends(GraphQLAPIClass, _super);
19
- function GraphQLAPIClass() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- GraphQLAPIClass.prototype.getModuleName = function () {
11
+ export class GraphQLAPIClass extends InternalGraphQLAPIClass {
12
+ getModuleName() {
23
13
  return 'GraphQLAPI';
24
- };
14
+ }
25
15
  /**
26
16
  * Executes a GraphQL operation
27
17
  *
@@ -29,12 +19,27 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
29
19
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
30
20
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
31
21
  */
32
- GraphQLAPIClass.prototype.graphql = function (options, additionalHeaders) {
33
- return _super.prototype.graphql.call(this, options, additionalHeaders);
34
- };
35
- return GraphQLAPIClass;
36
- }(InternalGraphQLAPIClass));
37
- export { GraphQLAPIClass };
38
- export var GraphQLAPI = new GraphQLAPIClass(null);
39
- Amplify.register(GraphQLAPI);
40
- //# sourceMappingURL=GraphQLAPI.js.map
22
+ graphql(amplify, options, additionalHeaders) {
23
+ return super.graphql(amplify, options, additionalHeaders, {
24
+ category: Category.API,
25
+ action: ApiAction.GraphQl,
26
+ });
27
+ }
28
+ /**
29
+ * Checks to see if an error thrown is from an api request cancellation
30
+ * @param error - Any error
31
+ * @returns A boolean indicating if the error was from an api request cancellation
32
+ */
33
+ isCancelError(error) {
34
+ return super.isCancelError(error);
35
+ }
36
+ /**
37
+ * Cancels an inflight request. Only applicable for graphql queries and mutations
38
+ * @param {any} request - request to cancel
39
+ * @returns A boolean indicating if the request was cancelled
40
+ */
41
+ cancel(request, message) {
42
+ return super.cancel(request, message);
43
+ }
44
+ }
45
+ export const GraphQLAPI = new GraphQLAPIClass(null);
@@ -0,0 +1,64 @@
1
+ import { Observable } from 'rxjs';
2
+ import { GraphQLAuthMode, CustomUserAgentDetails, DocumentType } from '@aws-amplify/core/internals/utils';
3
+ import { PubSubContentObserver } from '../../types/PubSub';
4
+ import { SUBSCRIPTION_STATUS } from '../constants';
5
+ export declare type ObserverQuery = {
6
+ observer: PubSubContentObserver;
7
+ query: string;
8
+ variables: Record<string, DocumentType>;
9
+ subscriptionState: SUBSCRIPTION_STATUS;
10
+ subscriptionReadyCallback?: Function;
11
+ subscriptionFailedCallback?: Function;
12
+ startAckTimeoutId?: ReturnType<typeof setTimeout>;
13
+ };
14
+ export interface AWSAppSyncRealTimeProviderOptions {
15
+ appSyncGraphqlEndpoint?: string;
16
+ authenticationType?: GraphQLAuthMode;
17
+ query?: string;
18
+ variables?: Record<string, DocumentType>;
19
+ apiKey?: string;
20
+ region?: string;
21
+ graphql_headers?: () => {} | (() => Promise<{}>);
22
+ additionalHeaders?: {
23
+ [key: string]: string;
24
+ };
25
+ }
26
+ export declare class AWSAppSyncRealTimeProvider {
27
+ private awsRealTimeSocket?;
28
+ private socketStatus;
29
+ private keepAliveTimeoutId?;
30
+ private keepAliveTimeout;
31
+ private keepAliveAlertTimeoutId?;
32
+ private subscriptionObserverMap;
33
+ private promiseArray;
34
+ private connectionState;
35
+ private readonly connectionStateMonitor;
36
+ private readonly reconnectionMonitor;
37
+ private connectionStateMonitorSubscription;
38
+ constructor(options?: AWSAppSyncRealTimeProviderOptions);
39
+ /**
40
+ * Mark the socket closed and release all active listeners
41
+ */
42
+ close(): void;
43
+ getNewWebSocket(url: string, protocol: string): WebSocket;
44
+ getProviderName(): string;
45
+ private isCustomDomain;
46
+ subscribe(options?: AWSAppSyncRealTimeProviderOptions, customUserAgentDetails?: CustomUserAgentDetails): Observable<Record<string, unknown>>;
47
+ private _startSubscriptionWithAWSAppSyncRealTime;
48
+ private _logStartSubscriptionError;
49
+ private _waitForSubscriptionToBeConnected;
50
+ private _sendUnsubscriptionMessage;
51
+ private _removeSubscriptionObserver;
52
+ private _closeSocketIfRequired;
53
+ private _handleIncomingSubscriptionMessage;
54
+ private _errorDisconnect;
55
+ private _timeoutStartSubscriptionAck;
56
+ private _initializeWebSocketConnection;
57
+ private _initializeRetryableHandshake;
58
+ private _initializeHandshake;
59
+ private _awsRealTimeHeaderBasedAuth;
60
+ private _awsAuthTokenHeader;
61
+ private _awsRealTimeApiKeyHeader;
62
+ private _awsRealTimeIAMHeader;
63
+ private _customAuthHeader;
64
+ }