@aws-amplify/api-graphql 3.4.11 → 4.0.1-console-preview.047a1dd.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 (114) hide show
  1. package/README.md +3 -0
  2. package/lib/GraphQLAPI.js +0 -5
  3. package/lib/Providers/AWSAppSyncRealTimeProvider/index.d.ts +67 -0
  4. package/lib/Providers/AWSAppSyncRealTimeProvider/index.js +817 -0
  5. package/lib/Providers/constants.d.ts +95 -0
  6. package/lib/Providers/constants.js +103 -0
  7. package/lib/index.d.ts +0 -3
  8. package/lib/index.js +3 -9
  9. package/lib/internals/InternalGraphQLAPI.d.ts +4 -40
  10. package/lib/internals/InternalGraphQLAPI.js +89 -243
  11. package/lib/internals/index.d.ts +1 -0
  12. package/lib/internals/index.js +2 -1
  13. package/lib/internals/v6.d.ts +89 -0
  14. package/lib/internals/v6.js +99 -0
  15. package/lib/tsconfig.tsbuildinfo +5790 -0
  16. package/lib/types/PubSub.d.ts +27 -0
  17. package/lib/types/PubSub.js +46 -0
  18. package/lib/types/index.d.ts +184 -4
  19. package/lib/types/index.js +0 -3
  20. package/lib/utils/ConnectionStateMonitor.d.ts +41 -0
  21. package/lib/utils/ConnectionStateMonitor.js +143 -0
  22. package/lib/utils/ReachabilityMonitor/index.d.ts +3 -0
  23. package/lib/utils/ReachabilityMonitor/index.js +6 -0
  24. package/lib/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  25. package/lib/utils/ReachabilityMonitor/index.native.js +10 -0
  26. package/lib/utils/ReconnectionMonitor.d.ts +29 -0
  27. package/lib/utils/ReconnectionMonitor.js +72 -0
  28. package/lib/utils/errors/APIError.d.ts +7 -0
  29. package/lib/utils/errors/APIError.js +22 -0
  30. package/lib/utils/errors/assertValidationError.d.ts +5 -0
  31. package/lib/utils/errors/assertValidationError.js +16 -0
  32. package/lib/utils/errors/index.d.ts +3 -0
  33. package/lib/utils/errors/index.js +11 -0
  34. package/lib/utils/errors/validation.d.ts +8 -0
  35. package/lib/utils/errors/validation.js +26 -0
  36. package/lib/utils/index.d.ts +2 -0
  37. package/lib/utils/index.js +8 -0
  38. package/lib/utils/resolveConfig.d.ts +8 -0
  39. package/lib/utils/resolveConfig.js +17 -0
  40. package/lib/utils/resolveCredentials.d.ts +12 -0
  41. package/lib/utils/resolveCredentials.js +22 -0
  42. package/lib-esm/GraphQLAPI.js +0 -5
  43. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.d.ts +67 -0
  44. package/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js +815 -0
  45. package/lib-esm/Providers/constants.d.ts +95 -0
  46. package/lib-esm/Providers/constants.js +100 -0
  47. package/lib-esm/index.d.ts +0 -3
  48. package/lib-esm/index.js +0 -4
  49. package/lib-esm/internals/InternalGraphQLAPI.d.ts +4 -40
  50. package/lib-esm/internals/InternalGraphQLAPI.js +90 -244
  51. package/lib-esm/internals/index.d.ts +1 -0
  52. package/lib-esm/internals/index.js +1 -1
  53. package/lib-esm/internals/v6.d.ts +89 -0
  54. package/lib-esm/internals/v6.js +96 -0
  55. package/lib-esm/tsconfig.tsbuildinfo +5790 -0
  56. package/lib-esm/types/PubSub.d.ts +27 -0
  57. package/lib-esm/types/PubSub.js +44 -0
  58. package/lib-esm/types/index.d.ts +184 -4
  59. package/lib-esm/types/index.js +0 -3
  60. package/lib-esm/utils/ConnectionStateMonitor.d.ts +41 -0
  61. package/lib-esm/utils/ConnectionStateMonitor.js +141 -0
  62. package/lib-esm/utils/ReachabilityMonitor/index.d.ts +3 -0
  63. package/lib-esm/utils/ReachabilityMonitor/index.js +4 -0
  64. package/lib-esm/utils/ReachabilityMonitor/index.native.d.ts +3 -0
  65. package/lib-esm/utils/ReachabilityMonitor/index.native.js +7 -0
  66. package/lib-esm/utils/ReconnectionMonitor.d.ts +29 -0
  67. package/lib-esm/utils/ReconnectionMonitor.js +70 -0
  68. package/lib-esm/utils/errors/APIError.d.ts +7 -0
  69. package/lib-esm/utils/errors/APIError.js +20 -0
  70. package/lib-esm/utils/errors/assertValidationError.d.ts +5 -0
  71. package/lib-esm/utils/errors/assertValidationError.js +13 -0
  72. package/lib-esm/utils/errors/index.d.ts +3 -0
  73. package/lib-esm/utils/errors/index.js +5 -0
  74. package/lib-esm/utils/errors/validation.d.ts +8 -0
  75. package/lib-esm/utils/errors/validation.js +24 -0
  76. package/lib-esm/utils/index.d.ts +2 -0
  77. package/lib-esm/utils/index.js +4 -0
  78. package/lib-esm/utils/resolveConfig.d.ts +8 -0
  79. package/lib-esm/utils/resolveConfig.js +15 -0
  80. package/lib-esm/utils/resolveCredentials.d.ts +12 -0
  81. package/lib-esm/utils/resolveCredentials.js +20 -0
  82. package/package.json +114 -114
  83. package/src/GraphQLAPI.ts +0 -2
  84. package/src/Providers/AWSAppSyncRealTimeProvider/index.ts +1003 -0
  85. package/src/Providers/constants.ts +110 -0
  86. package/src/index.ts +0 -3
  87. package/src/internals/InternalGraphQLAPI.ts +62 -221
  88. package/src/internals/index.ts +2 -0
  89. package/src/internals/v6.ts +106 -0
  90. package/src/types/PubSub.ts +58 -0
  91. package/src/types/index.ts +234 -7
  92. package/src/utils/ConnectionStateMonitor.ts +195 -0
  93. package/src/utils/ReachabilityMonitor/index.native.ts +7 -0
  94. package/src/utils/ReachabilityMonitor/index.ts +4 -0
  95. package/src/utils/ReconnectionMonitor.ts +76 -0
  96. package/src/utils/errors/APIError.ts +18 -0
  97. package/src/utils/errors/assertValidationError.ts +19 -0
  98. package/src/utils/errors/index.ts +6 -0
  99. package/src/utils/errors/validation.ts +26 -0
  100. package/src/utils/index.ts +5 -0
  101. package/src/utils/resolveConfig.ts +20 -0
  102. package/src/utils/resolveCredentials.ts +14 -0
  103. package/lib/.tsbuildinfo +0 -3
  104. package/lib/GraphQLAPI.js.map +0 -1
  105. package/lib/index.js.map +0 -1
  106. package/lib/internals/InternalGraphQLAPI.js.map +0 -1
  107. package/lib/internals/index.js.map +0 -1
  108. package/lib/types/index.js.map +0 -1
  109. package/lib-esm/.tsbuildinfo +0 -3
  110. package/lib-esm/GraphQLAPI.js.map +0 -1
  111. package/lib-esm/index.js.map +0 -1
  112. package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
  113. package/lib-esm/internals/index.js.map +0 -1
  114. package/lib-esm/types/index.js.map +0 -1
@@ -0,0 +1,95 @@
1
+ export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
2
+ export declare const MAX_DELAY_MS = 5000;
3
+ export declare const NON_RETRYABLE_CODES: number[];
4
+ export declare const CONNECTION_STATE_CHANGE = "ConnectionStateChange";
5
+ export declare enum MESSAGE_TYPES {
6
+ /**
7
+ * Client -> Server message.
8
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
9
+ */
10
+ GQL_CONNECTION_INIT = "connection_init",
11
+ /**
12
+ * Server -> Client message
13
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
14
+ */
15
+ GQL_CONNECTION_ERROR = "connection_error",
16
+ /**
17
+ * Server -> Client message.
18
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
19
+ */
20
+ GQL_CONNECTION_ACK = "connection_ack",
21
+ /**
22
+ * Client -> Server message.
23
+ * This message type is for register subscriptions with AWS AppSync RealTime
24
+ */
25
+ GQL_START = "start",
26
+ /**
27
+ * Server -> Client message.
28
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
29
+ */
30
+ GQL_START_ACK = "start_ack",
31
+ /**
32
+ * Server -> Client message.
33
+ * This message type is for subscription message from AWS AppSync RealTime
34
+ */
35
+ GQL_DATA = "data",
36
+ /**
37
+ * Server -> Client message.
38
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
39
+ */
40
+ GQL_CONNECTION_KEEP_ALIVE = "ka",
41
+ /**
42
+ * Client -> Server message.
43
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
44
+ */
45
+ GQL_STOP = "stop",
46
+ /**
47
+ * Server -> Client message.
48
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
49
+ */
50
+ GQL_COMPLETE = "complete",
51
+ /**
52
+ * Server -> Client message.
53
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
54
+ */
55
+ GQL_ERROR = "error"
56
+ }
57
+ export declare enum SUBSCRIPTION_STATUS {
58
+ PENDING = 0,
59
+ CONNECTED = 1,
60
+ FAILED = 2
61
+ }
62
+ export declare enum SOCKET_STATUS {
63
+ CLOSED = 0,
64
+ READY = 1,
65
+ CONNECTING = 2
66
+ }
67
+ export declare const AWS_APPSYNC_REALTIME_HEADERS: {
68
+ accept: string;
69
+ 'content-encoding': string;
70
+ 'content-type': string;
71
+ };
72
+ /**
73
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
74
+ */
75
+ export declare const CONNECTION_INIT_TIMEOUT = 15000;
76
+ /**
77
+ * Time in milleseconds to wait for GQL_START_ACK message
78
+ */
79
+ export declare const START_ACK_TIMEOUT = 15000;
80
+ /**
81
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
82
+ */
83
+ export declare const DEFAULT_KEEP_ALIVE_TIMEOUT: number;
84
+ /**
85
+ * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
86
+ */
87
+ export declare const DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT: number;
88
+ /**
89
+ * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
90
+ */
91
+ export declare const RECONNECT_DELAY: number;
92
+ /**
93
+ * Default interval time in milleseconds between when reconnect is re-attempted
94
+ */
95
+ export declare const RECONNECT_INTERVAL: number;
@@ -0,0 +1,100 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { AMPLIFY_SYMBOL } from '@aws-amplify/core/internals/utils';
4
+ export var MAX_DELAY_MS = 5000;
5
+ export var NON_RETRYABLE_CODES = [400, 401, 403];
6
+ export var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
7
+ export var MESSAGE_TYPES;
8
+ (function (MESSAGE_TYPES) {
9
+ /**
10
+ * Client -> Server message.
11
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
12
+ */
13
+ MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
14
+ /**
15
+ * Server -> Client message
16
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
17
+ */
18
+ MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
19
+ /**
20
+ * Server -> Client message.
21
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
22
+ */
23
+ MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
24
+ /**
25
+ * Client -> Server message.
26
+ * This message type is for register subscriptions with AWS AppSync RealTime
27
+ */
28
+ MESSAGE_TYPES["GQL_START"] = "start";
29
+ /**
30
+ * Server -> Client message.
31
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
32
+ */
33
+ MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
34
+ /**
35
+ * Server -> Client message.
36
+ * This message type is for subscription message from AWS AppSync RealTime
37
+ */
38
+ MESSAGE_TYPES["GQL_DATA"] = "data";
39
+ /**
40
+ * Server -> Client message.
41
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
42
+ */
43
+ MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
44
+ /**
45
+ * Client -> Server message.
46
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
47
+ */
48
+ MESSAGE_TYPES["GQL_STOP"] = "stop";
49
+ /**
50
+ * Server -> Client message.
51
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
52
+ */
53
+ MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
54
+ /**
55
+ * Server -> Client message.
56
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
57
+ */
58
+ MESSAGE_TYPES["GQL_ERROR"] = "error";
59
+ })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
60
+ export var SUBSCRIPTION_STATUS;
61
+ (function (SUBSCRIPTION_STATUS) {
62
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
63
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
64
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
65
+ })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
66
+ export var SOCKET_STATUS;
67
+ (function (SOCKET_STATUS) {
68
+ SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
69
+ SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
70
+ SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
71
+ })(SOCKET_STATUS || (SOCKET_STATUS = {}));
72
+ export var AWS_APPSYNC_REALTIME_HEADERS = {
73
+ accept: 'application/json, text/javascript',
74
+ 'content-encoding': 'amz-1.0',
75
+ 'content-type': 'application/json; charset=UTF-8',
76
+ };
77
+ /**
78
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
79
+ */
80
+ export var CONNECTION_INIT_TIMEOUT = 15000;
81
+ /**
82
+ * Time in milleseconds to wait for GQL_START_ACK message
83
+ */
84
+ export var START_ACK_TIMEOUT = 15000;
85
+ /**
86
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
87
+ */
88
+ export var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
89
+ /**
90
+ * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
91
+ */
92
+ export var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
93
+ /**
94
+ * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
95
+ */
96
+ export var RECONNECT_DELAY = 5 * 1000;
97
+ /**
98
+ * Default interval time in milleseconds between when reconnect is re-attempted
99
+ */
100
+ export var RECONNECT_INTERVAL = 60 * 1000;
@@ -1,5 +1,2 @@
1
- import { GraphQLAPI } from './GraphQLAPI';
2
- export { GraphQLResult, GraphQLAuthError, GRAPHQL_AUTH_MODE } from './types';
3
1
  export { GraphQLAPI, GraphQLAPIClass, graphqlOperation } from './GraphQLAPI';
4
2
  export * from './types';
5
- export default GraphQLAPI;
package/lib-esm/index.js CHANGED
@@ -1,8 +1,4 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { GraphQLAPI } from './GraphQLAPI';
4
- export { GraphQLAuthError, GRAPHQL_AUTH_MODE } from './types';
5
3
  export { GraphQLAPI, GraphQLAPIClass, graphqlOperation } from './GraphQLAPI';
6
4
  export * from './types';
7
- export default GraphQLAPI;
8
- //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import { OperationTypeNode } from 'graphql';
2
2
  import Observable from 'zen-observable-ts';
3
- import { CustomUserAgentDetails } from '@aws-amplify/core';
4
- import { GraphQLOptions, GraphQLResult, GraphQLOperation } from '../types';
3
+ import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
4
+ import { GraphQLResult, GraphQLOperation, GraphQLOptions } from '../types';
5
5
  export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
6
6
  query: any;
7
7
  variables: {};
@@ -15,27 +15,14 @@ export declare class InternalGraphQLAPIClass {
15
15
  * @private
16
16
  */
17
17
  private _options;
18
- private _api;
19
- Auth: import("@aws-amplify/auth/lib-esm/Auth").AuthClass;
20
- Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
21
- Credentials: import("@aws-amplify/core").CredentialsClass;
18
+ private appSyncRealTime;
19
+ Cache: import("@aws-amplify/core/lib-esm/Cache/types").ICache;
22
20
  /**
23
21
  * Initialize GraphQL API with AWS configuration
24
22
  * @param {Object} options - Configuration object for API
25
23
  */
26
24
  constructor(options: any);
27
25
  getModuleName(): string;
28
- /**
29
- * Configure API
30
- * @param {Object} config - Configuration of the API
31
- * @return {Object} - The current configuration
32
- */
33
- configure(options: any): any;
34
- /**
35
- * Create an instance of API for the library
36
- * @return - A promise of true if Success
37
- */
38
- createInstance(): true | Promise<never>;
39
26
  private _headerBasedAuth;
40
27
  /**
41
28
  * to get the operation type
@@ -53,29 +40,6 @@ export declare class InternalGraphQLAPIClass {
53
40
  [key: string]: string;
54
41
  }, customUserAgentDetails?: CustomUserAgentDetails): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
55
42
  private _graphql;
56
- createInstanceIfNotCreated(): Promise<void>;
57
- /**
58
- * Checks to see if an error thrown is from an api request cancellation
59
- * @param {any} error - Any error
60
- * @return {boolean} - A boolean indicating if the error was from an api request cancellation
61
- */
62
- isCancel(error: any): any;
63
- /**
64
- * Cancels an inflight request. Only applicable for graphql queries and mutations
65
- * @param {any} request - request to cancel
66
- * @return {boolean} - A boolean indicating if the request was cancelled
67
- */
68
- cancel(request: Promise<any>, message?: string): any;
69
- /**
70
- * Check if the request has a corresponding cancel token in the WeakMap.
71
- * @params request - The request promise
72
- * @return if the request has a corresponding cancel token.
73
- */
74
- hasCancelToken(request: Promise<any>): any;
75
43
  private _graphqlSubscribe;
76
- /**
77
- * @private
78
- */
79
- _ensureCredentials(): any;
80
44
  }
81
45
  export declare const InternalGraphQLAPI: InternalGraphQLAPIClass;