@aws-amplify/api-graphql 3.4.12-api-v6-models.b3abc9b.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 (118) 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 -1
  13. package/lib/internals/index.js +2 -1
  14. package/lib/internals/v6.d.ts +14 -2
  15. package/lib/internals/v6.js +21 -3
  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 +119 -12
  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 -1
  54. package/lib-esm/internals/index.js +1 -2
  55. package/lib-esm/internals/v6.d.ts +14 -2
  56. package/lib-esm/internals/v6.js +18 -2
  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 +119 -12
  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 -118
  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 +1 -1
  91. package/src/internals/v6.ts +34 -2
  92. package/src/types/PubSub.ts +56 -0
  93. package/src/types/index.ts +175 -15
  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/internals/v6.js.map +0 -1
  111. package/lib/types/index.js.map +0 -1
  112. package/lib-esm/.tsbuildinfo +0 -3
  113. package/lib-esm/GraphQLAPI.js.map +0 -1
  114. package/lib-esm/index.js.map +0 -1
  115. package/lib-esm/internals/InternalGraphQLAPI.js.map +0 -1
  116. package/lib-esm/internals/index.js.map +0 -1
  117. package/lib-esm/internals/v6.js.map +0 -1
  118. 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,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ var utils_1 = require("@aws-amplify/core/internals/utils");
6
+ exports.AMPLIFY_SYMBOL = utils_1.AMPLIFY_SYMBOL;
7
+ exports.MAX_DELAY_MS = 5000;
8
+ exports.NON_RETRYABLE_CODES = [400, 401, 403];
9
+ exports.CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
10
+ var MESSAGE_TYPES;
11
+ (function (MESSAGE_TYPES) {
12
+ /**
13
+ * Client -> Server message.
14
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
15
+ */
16
+ MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
17
+ /**
18
+ * Server -> Client message
19
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
20
+ */
21
+ MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
22
+ /**
23
+ * Server -> Client message.
24
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
25
+ */
26
+ MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
27
+ /**
28
+ * Client -> Server message.
29
+ * This message type is for register subscriptions with AWS AppSync RealTime
30
+ */
31
+ MESSAGE_TYPES["GQL_START"] = "start";
32
+ /**
33
+ * Server -> Client message.
34
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
35
+ */
36
+ MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
37
+ /**
38
+ * Server -> Client message.
39
+ * This message type is for subscription message from AWS AppSync RealTime
40
+ */
41
+ MESSAGE_TYPES["GQL_DATA"] = "data";
42
+ /**
43
+ * Server -> Client message.
44
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
45
+ */
46
+ MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
47
+ /**
48
+ * Client -> Server message.
49
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
50
+ */
51
+ MESSAGE_TYPES["GQL_STOP"] = "stop";
52
+ /**
53
+ * Server -> Client message.
54
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
55
+ */
56
+ MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
57
+ /**
58
+ * Server -> Client message.
59
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
60
+ */
61
+ MESSAGE_TYPES["GQL_ERROR"] = "error";
62
+ })(MESSAGE_TYPES = exports.MESSAGE_TYPES || (exports.MESSAGE_TYPES = {}));
63
+ var SUBSCRIPTION_STATUS;
64
+ (function (SUBSCRIPTION_STATUS) {
65
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
66
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
67
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
68
+ })(SUBSCRIPTION_STATUS = exports.SUBSCRIPTION_STATUS || (exports.SUBSCRIPTION_STATUS = {}));
69
+ var SOCKET_STATUS;
70
+ (function (SOCKET_STATUS) {
71
+ SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
72
+ SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
73
+ SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
74
+ })(SOCKET_STATUS = exports.SOCKET_STATUS || (exports.SOCKET_STATUS = {}));
75
+ exports.AWS_APPSYNC_REALTIME_HEADERS = {
76
+ accept: 'application/json, text/javascript',
77
+ 'content-encoding': 'amz-1.0',
78
+ 'content-type': 'application/json; charset=UTF-8',
79
+ };
80
+ /**
81
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
82
+ */
83
+ exports.CONNECTION_INIT_TIMEOUT = 15000;
84
+ /**
85
+ * Time in milleseconds to wait for GQL_START_ACK message
86
+ */
87
+ exports.START_ACK_TIMEOUT = 15000;
88
+ /**
89
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
90
+ */
91
+ exports.DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
92
+ /**
93
+ * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
94
+ */
95
+ exports.DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
96
+ /**
97
+ * Default delay time in milleseconds between when reconnect is triggered vs when it is attempted
98
+ */
99
+ exports.RECONNECT_DELAY = 5 * 1000;
100
+ /**
101
+ * Default interval time in milleseconds between when reconnect is re-attempted
102
+ */
103
+ exports.RECONNECT_INTERVAL = 60 * 1000;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,3 @@
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;
3
+ export { CONNECTION_STATE_CHANGE } from './Providers/constants';
package/lib/index.js CHANGED
@@ -2,15 +2,11 @@
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- var tslib_1 = require("tslib");
5
+ const tslib_1 = require("tslib");
6
6
  var GraphQLAPI_1 = require("./GraphQLAPI");
7
- var types_1 = require("./types");
8
- exports.GraphQLAuthError = types_1.GraphQLAuthError;
9
- exports.GRAPHQL_AUTH_MODE = types_1.GRAPHQL_AUTH_MODE;
10
- var GraphQLAPI_2 = require("./GraphQLAPI");
11
- exports.GraphQLAPI = GraphQLAPI_2.GraphQLAPI;
12
- exports.GraphQLAPIClass = GraphQLAPI_2.GraphQLAPIClass;
13
- exports.graphqlOperation = GraphQLAPI_2.graphqlOperation;
7
+ exports.GraphQLAPI = GraphQLAPI_1.GraphQLAPI;
8
+ exports.GraphQLAPIClass = GraphQLAPI_1.GraphQLAPIClass;
9
+ exports.graphqlOperation = GraphQLAPI_1.graphqlOperation;
14
10
  tslib_1.__exportStar(require("./types"), exports);
15
- exports.default = GraphQLAPI_1.GraphQLAPI;
16
- //# sourceMappingURL=index.js.map
11
+ var constants_1 = require("./Providers/constants");
12
+ exports.CONNECTION_STATE_CHANGE = constants_1.CONNECTION_STATE_CHANGE;
@@ -1,11 +1,12 @@
1
1
  import { OperationTypeNode } from 'graphql';
2
- import Observable from 'zen-observable-ts';
3
- import { CustomUserAgentDetails } from '@aws-amplify/core';
4
- import { GraphQLOptions, GraphQLResult, GraphQLOperation } from '../types';
5
- export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string) => {
2
+ import { Observable } from 'rxjs';
3
+ import { AmplifyClassV6 } from '@aws-amplify/core';
4
+ import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
5
+ import { GraphQLResult, GraphQLOperation, GraphQLOptions } from '../types';
6
+ export declare const graphqlOperation: (query: any, variables?: {}, authToken?: string | undefined) => {
6
7
  query: any;
7
8
  variables: {};
8
- authToken: string;
9
+ authToken: string | undefined;
9
10
  };
10
11
  /**
11
12
  * Export Cloud Logic APIs
@@ -15,27 +16,14 @@ export declare class InternalGraphQLAPIClass {
15
16
  * @private
16
17
  */
17
18
  private _options;
19
+ private appSyncRealTime;
18
20
  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;
22
21
  /**
23
22
  * Initialize GraphQL API with AWS configuration
24
23
  * @param {Object} options - Configuration object for API
25
24
  */
26
25
  constructor(options: any);
27
26
  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
27
  private _headerBasedAuth;
40
28
  /**
41
29
  * to get the operation type
@@ -49,33 +37,22 @@ export declare class InternalGraphQLAPIClass {
49
37
  * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
50
38
  * @returns An Observable if the query is a subscription query, else a promise of the graphql result.
51
39
  */
52
- graphql<T = any>({ query: paramQuery, variables, authMode, authToken }: GraphQLOptions, additionalHeaders?: {
40
+ graphql<T = any>(amplify: AmplifyClassV6 | ((fn: (amplify: any) => Promise<any>) => Promise<AmplifyClassV6>), { query: paramQuery, variables, authMode, authToken }: GraphQLOptions, additionalHeaders?: {
53
41
  [key: string]: string;
54
42
  }, customUserAgentDetails?: CustomUserAgentDetails): Observable<GraphQLResult<T>> | Promise<GraphQLResult<T>>;
55
43
  private _graphql;
56
- createInstanceIfNotCreated(): Promise<void>;
57
44
  /**
58
45
  * Checks to see if an error thrown is from an api request cancellation
59
46
  * @param {any} error - Any error
60
47
  * @return {boolean} - A boolean indicating if the error was from an api request cancellation
61
48
  */
62
- isCancel(error: any): any;
49
+ isCancelError(error: any): boolean;
63
50
  /**
64
51
  * Cancels an inflight request. Only applicable for graphql queries and mutations
65
52
  * @param {any} request - request to cancel
66
- * @return {boolean} - A boolean indicating if the request was cancelled
53
+ * @returns - A boolean indicating if the request was cancelled
67
54
  */
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;
55
+ cancel(request: Promise<any>, message?: string): boolean;
75
56
  private _graphqlSubscribe;
76
- /**
77
- * @private
78
- */
79
- _ensureCredentials(): any;
80
57
  }
81
58
  export declare const InternalGraphQLAPI: InternalGraphQLAPIClass;