@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,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,8 @@
1
+ import { AmplifyErrorMap } from '@aws-amplify/core/internals/utils';
2
+ export declare enum APIValidationErrorCode {
3
+ NoAppId = "NoAppId",
4
+ NoCredentials = "NoCredentials",
5
+ NoRegion = "NoRegion",
6
+ NoDefaultAuthMode = "NoDefaultAuthMode"
7
+ }
8
+ export declare const validationErrorMap: AmplifyErrorMap<APIValidationErrorCode>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var _a;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var APIValidationErrorCode;
7
+ (function (APIValidationErrorCode) {
8
+ APIValidationErrorCode["NoAppId"] = "NoAppId";
9
+ APIValidationErrorCode["NoCredentials"] = "NoCredentials";
10
+ APIValidationErrorCode["NoRegion"] = "NoRegion";
11
+ APIValidationErrorCode["NoDefaultAuthMode"] = "NoDefaultAuthMode";
12
+ })(APIValidationErrorCode = exports.APIValidationErrorCode || (exports.APIValidationErrorCode = {}));
13
+ exports.validationErrorMap = (_a = {},
14
+ _a[APIValidationErrorCode.NoAppId] = {
15
+ message: 'Missing application id.',
16
+ },
17
+ _a[APIValidationErrorCode.NoCredentials] = {
18
+ message: 'Credentials should not be empty.',
19
+ },
20
+ _a[APIValidationErrorCode.NoRegion] = {
21
+ message: 'Missing region.',
22
+ },
23
+ _a[APIValidationErrorCode.NoDefaultAuthMode] = {
24
+ message: 'Missing default auth mode',
25
+ },
26
+ _a);
@@ -0,0 +1,2 @@
1
+ export { resolveConfig } from './resolveConfig';
2
+ export { resolveCredentials } from './resolveCredentials';
@@ -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 resolveCredentials_1 = require("./resolveCredentials");
8
+ exports.resolveCredentials = resolveCredentials_1.resolveCredentials;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const resolveConfig: () => {
5
+ endpoint: string;
6
+ region: string;
7
+ defaultAuthMode: import("@aws-amplify/core/lib-esm/singleton/API/types").GraphQLAuthMode;
8
+ };
@@ -0,0 +1,17 @@
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 core_1 = require("@aws-amplify/core");
6
+ var errors_1 = require("./errors");
7
+ /**
8
+ * @internal
9
+ */
10
+ exports.resolveConfig = function () {
11
+ var _a, _b;
12
+ var _c = (_b = (_a = core_1.Amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.AppSync) !== null && _b !== void 0 ? _b : {}, region = _c.region, defaultAuthMode = _c.defaultAuthMode, endpoint = _c.endpoint;
13
+ errors_1.assertValidationError(!!endpoint, errors_1.APIValidationErrorCode.NoAppId);
14
+ errors_1.assertValidationError(!!region, errors_1.APIValidationErrorCode.NoRegion);
15
+ errors_1.assertValidationError(!!defaultAuthMode, errors_1.APIValidationErrorCode.NoDefaultAuthMode);
16
+ return { endpoint: endpoint, region: region, defaultAuthMode: defaultAuthMode };
17
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const resolveCredentials: () => Promise<{
5
+ credentials: {
6
+ accessKeyId: string;
7
+ secretAccessKey: string;
8
+ sessionToken?: string;
9
+ expiration?: Date;
10
+ };
11
+ identityId: string;
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
+ var tslib_1 = require("tslib");
6
+ var core_1 = require("@aws-amplify/core");
7
+ var errors_1 = require("./errors");
8
+ /**
9
+ * @internal
10
+ */
11
+ exports.resolveCredentials = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
12
+ var _a, credentials, identityId;
13
+ return tslib_1.__generator(this, function (_b) {
14
+ switch (_b.label) {
15
+ case 0: return [4 /*yield*/, core_1.fetchAuthSession()];
16
+ case 1:
17
+ _a = _b.sent(), credentials = _a.credentials, identityId = _a.identityId;
18
+ errors_1.assertValidationError(!!credentials, errors_1.APIValidationErrorCode.NoCredentials);
19
+ return [2 /*return*/, { credentials: credentials, identityId: identityId }];
20
+ }
21
+ });
22
+ }); };
@@ -1,7 +1,4 @@
1
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';
5
2
  import { InternalGraphQLAPIClass } from './internals';
6
3
  export var graphqlOperation = function (query, variables, authToken) {
7
4
  if (variables === void 0) { variables = {}; }
@@ -36,5 +33,3 @@ var GraphQLAPIClass = /** @class */ (function (_super) {
36
33
  }(InternalGraphQLAPIClass));
37
34
  export { GraphQLAPIClass };
38
35
  export var GraphQLAPI = new GraphQLAPIClass(null);
39
- Amplify.register(GraphQLAPI);
40
- //# sourceMappingURL=GraphQLAPI.js.map
@@ -0,0 +1,67 @@
1
+ import Observable from 'zen-observable-ts';
2
+ import { PubSubContentObserver } from '../../types/PubSub';
3
+ import { SUBSCRIPTION_STATUS } from '../constants';
4
+ import { GraphQLAuthMode } from '@aws-amplify/core/lib-esm/singleton/API/types';
5
+ import { CustomUserAgentDetails } from '@aws-amplify/core/internals/utils';
6
+ import { DocumentType } from '@aws-amplify/api-rest';
7
+ export declare type ObserverQuery = {
8
+ observer: PubSubContentObserver;
9
+ query: string;
10
+ variables: Record<string, DocumentType>;
11
+ subscriptionState: SUBSCRIPTION_STATUS;
12
+ subscriptionReadyCallback?: Function;
13
+ subscriptionFailedCallback?: Function;
14
+ startAckTimeoutId?: ReturnType<typeof setTimeout>;
15
+ };
16
+ export interface AWSAppSyncRealTimeProviderOptions {
17
+ appSyncGraphqlEndpoint?: string;
18
+ authenticationType?: GraphQLAuthMode;
19
+ query?: string;
20
+ variables?: Record<string, DocumentType>;
21
+ apiKey?: string;
22
+ region?: string;
23
+ graphql_headers?: () => {} | (() => Promise<{}>);
24
+ additionalHeaders?: {
25
+ [key: string]: string;
26
+ };
27
+ }
28
+ export declare class AWSAppSyncRealTimeProvider {
29
+ private awsRealTimeSocket?;
30
+ private socketStatus;
31
+ private keepAliveTimeoutId?;
32
+ private keepAliveTimeout;
33
+ private keepAliveAlertTimeoutId?;
34
+ private subscriptionObserverMap;
35
+ private promiseArray;
36
+ private connectionState;
37
+ private readonly connectionStateMonitor;
38
+ private readonly reconnectionMonitor;
39
+ private connectionStateMonitorSubscription;
40
+ constructor(options?: AWSAppSyncRealTimeProviderOptions);
41
+ /**
42
+ * Mark the socket closed and release all active listeners
43
+ */
44
+ close(): void;
45
+ getNewWebSocket(url: string, protocol: string): WebSocket;
46
+ getProviderName(): string;
47
+ private isCustomDomain;
48
+ subscribe(options?: AWSAppSyncRealTimeProviderOptions, customUserAgentDetails?: CustomUserAgentDetails): Observable<Record<string, unknown>>;
49
+ private _startSubscriptionWithAWSAppSyncRealTime;
50
+ private _logStartSubscriptionError;
51
+ private _waitForSubscriptionToBeConnected;
52
+ private _sendUnsubscriptionMessage;
53
+ private _removeSubscriptionObserver;
54
+ private _closeSocketIfRequired;
55
+ private _handleIncomingSubscriptionMessage;
56
+ private _errorDisconnect;
57
+ private _timeoutStartSubscriptionAck;
58
+ private _initializeWebSocketConnection;
59
+ private _initializeRetryableHandshake;
60
+ private _initializeHandshake;
61
+ private _awsRealTimeHeaderBasedAuth;
62
+ private _awsRealTimeCUPHeader;
63
+ private _awsRealTimeOPENIDHeader;
64
+ private _awsRealTimeApiKeyHeader;
65
+ private _awsRealTimeIAMHeader;
66
+ private _customAuthHeader;
67
+ }