@aws-amplify/api-graphql 4.0.1-console-preview.4b7d177.0 → 4.0.1-console-preview.deaebd5.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.
@@ -1,8 +1,7 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { PubSubContentObserver } from '../../types/PubSub';
3
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';
4
+ import { CustomUserAgentDetails, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
6
5
  import { DocumentType } from '@aws-amplify/api-rest';
7
6
  export declare type ObserverQuery = {
8
7
  observer: PubSubContentObserver;
@@ -59,7 +58,6 @@ export declare class AWSAppSyncRealTimeProvider {
59
58
  private _initializeRetryableHandshake;
60
59
  private _initializeHandshake;
61
60
  private _awsRealTimeHeaderBasedAuth;
62
- private _awsRealTimeCUPHeader;
63
61
  private _awsRealTimeOPENIDHeader;
64
62
  private _awsRealTimeApiKeyHeader;
65
63
  private _awsRealTimeIAMHeader;
@@ -85,7 +85,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
85
85
  };
86
86
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (options, customUserAgentDetails) {
87
87
  var _this = this;
88
- var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, region = options.region, query = options.query, variables = options.variables, authenticationType = options.authenticationType;
88
+ var _a = options || {}, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, region = _a.region, query = _a.query, variables = _a.variables, authenticationType = _a.authenticationType, additionalHeaders = _a.additionalHeaders;
89
89
  return new rxjs_1.Observable(function (observer) {
90
90
  if (!options || !appSyncGraphqlEndpoint) {
91
91
  observer.error({
@@ -108,6 +108,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
108
108
  region: region,
109
109
  authenticationType: authenticationType,
110
110
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
111
+ additionalHeaders: additionalHeaders,
111
112
  },
112
113
  observer: observer,
113
114
  subscriptionId: subscriptionId_1,
@@ -697,7 +698,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
697
698
  case 1:
698
699
  handler = headerHandler[authenticationType.type];
699
700
  host = url.parse(appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
700
- logger.debug("Authenticating with " + authenticationType);
701
+ logger.debug("Authenticating with " + JSON.stringify(authenticationType));
701
702
  apiKey = void 0;
702
703
  if (authenticationType.type === 'apiKey') {
703
704
  apiKey = authenticationType.apiKey;
@@ -718,34 +719,18 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
718
719
  });
719
720
  });
720
721
  };
721
- AWSAppSyncRealTimeProvider.prototype._awsRealTimeCUPHeader = function (_a) {
722
- var host = _a.host;
723
- return tslib_1.__awaiter(this, void 0, void 0, function () {
724
- var session;
725
- return tslib_1.__generator(this, function (_b) {
726
- switch (_b.label) {
727
- case 0: return [4 /*yield*/, core_1.fetchAuthSession()];
728
- case 1:
729
- session = _b.sent();
730
- return [2 /*return*/, {
731
- Authorization: session.tokens.accessToken.toString(),
732
- host: host,
733
- }];
734
- }
735
- });
736
- });
737
- };
738
722
  AWSAppSyncRealTimeProvider.prototype._awsRealTimeOPENIDHeader = function (_a) {
739
723
  var host = _a.host;
724
+ var _b, _c;
740
725
  return tslib_1.__awaiter(this, void 0, void 0, function () {
741
726
  var session;
742
- return tslib_1.__generator(this, function (_b) {
743
- switch (_b.label) {
727
+ return tslib_1.__generator(this, function (_d) {
728
+ switch (_d.label) {
744
729
  case 0: return [4 /*yield*/, core_1.fetchAuthSession()];
745
730
  case 1:
746
- session = _b.sent();
731
+ session = _d.sent();
747
732
  return [2 /*return*/, {
748
- Authorization: session.tokens.accessToken.toString(),
733
+ Authorization: (_c = (_b = session === null || session === void 0 ? void 0 : session.tokens) === null || _b === void 0 ? void 0 : _b.accessToken) === null || _c === void 0 ? void 0 : _c.toString(),
749
734
  host: host,
750
735
  }];
751
736
  }
@@ -804,7 +789,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
804
789
  };
805
790
  AWSAppSyncRealTimeProvider.prototype._customAuthHeader = function (_a) {
806
791
  var host = _a.host, additionalHeaders = _a.additionalHeaders;
807
- if (!additionalHeaders || !additionalHeaders['Authorization']) {
792
+ if (!(additionalHeaders === null || additionalHeaders === void 0 ? void 0 : additionalHeaders['Authorization'])) {
808
793
  throw new Error('No auth token specified');
809
794
  }
810
795
  return {
@@ -17,6 +17,7 @@ export declare class InternalGraphQLAPIClass {
17
17
  private _options;
18
18
  private appSyncRealTime;
19
19
  Cache: import("@aws-amplify/core/lib-esm/Cache/types").ICache;
20
+ private _api;
20
21
  /**
21
22
  * Initialize GraphQL API with AWS configuration
22
23
  * @param {Object} options - Configuration object for API
@@ -29,6 +29,7 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
29
29
  */
30
30
  function InternalGraphQLAPIClass(options) {
31
31
  this.Cache = core_1.Cache;
32
+ this._api = { post: api_rest_1.post };
32
33
  this._options = options;
33
34
  logger.debug('API Options', this._options);
34
35
  }
@@ -198,7 +199,7 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
198
199
  _j.label = 7;
199
200
  case 7:
200
201
  _j.trys.push([7, 9, , 10]);
201
- return [4 /*yield*/, api_rest_1.post(endpoint, {
202
+ return [4 /*yield*/, this._api.post(endpoint, {
202
203
  headers: headers,
203
204
  body: body,
204
205
  region: region,
@@ -1130,8 +1130,8 @@
1130
1130
  "signature": "e02f9f6928bd974cc18803419ecc30e12dc39fb3c4383eaa897bf8d868135ef1"
1131
1131
  },
1132
1132
  "../../core/lib-esm/Hub/types/AuthTypes.d.ts": {
1133
- "version": "b8e5ba29dd7f2369f52d2b2ea829e168399e177879cae7fce6ad10e4f50975f3",
1134
- "signature": "b8e5ba29dd7f2369f52d2b2ea829e168399e177879cae7fce6ad10e4f50975f3"
1133
+ "version": "a04a1debf29ca7be5a11859eca422ede0355a7ffac49027843c21a1566aacc2a",
1134
+ "signature": "a04a1debf29ca7be5a11859eca422ede0355a7ffac49027843c21a1566aacc2a"
1135
1135
  },
1136
1136
  "../../core/lib-esm/Hub/types/HubTypes.d.ts": {
1137
1137
  "version": "9a23afdd036a23560984aeeec5dbdfc3ddd3e50bd8ca87929fca3d0a13292148",
@@ -1166,8 +1166,8 @@
1166
1166
  "signature": "92395e3e6898e201a167d96559042af069933f1a96662305bdc01fda3627bfbf"
1167
1167
  },
1168
1168
  "../../core/lib-esm/libraryUtils.d.ts": {
1169
- "version": "0f0269450c924ed45441071963c5bcb05c19b8cb4179e1e1af10ac6f3b82c53c",
1170
- "signature": "0f0269450c924ed45441071963c5bcb05c19b8cb4179e1e1af10ac6f3b82c53c"
1169
+ "version": "6c64a38ac2b21b0e6505c5de98394c334e6c3cde067e206ad8df44fb29474fd6",
1170
+ "signature": "6c64a38ac2b21b0e6505c5de98394c334e6c3cde067e206ad8df44fb29474fd6"
1171
1171
  },
1172
1172
  "../src/types/PubSub.ts": {
1173
1173
  "version": "70ac482472a54d226119a9a20fbb3f3baa04e9e305526ab90559626561206a64",
@@ -1366,8 +1366,8 @@
1366
1366
  "signature": "a21e6b4bebe10b7e0ad199954dff9c5b9813e6552585fd5a944a691d5d0250ed"
1367
1367
  },
1368
1368
  "../../core/lib-esm/I18n/index.d.ts": {
1369
- "version": "39943a1a0b759d46ee9383ef7a3e228b705c05e7ec131677bbcae4b130ed5aba",
1370
- "signature": "39943a1a0b759d46ee9383ef7a3e228b705c05e7ec131677bbcae4b130ed5aba"
1369
+ "version": "3cdc09269c30f50499132846639d826e03fb74007685505c5f0ce9691f627f75",
1370
+ "signature": "3cdc09269c30f50499132846639d826e03fb74007685505c5f0ce9691f627f75"
1371
1371
  },
1372
1372
  "../../core/lib-esm/index.d.ts": {
1373
1373
  "version": "961b863ef850a0b1d97c21a273560ee4434a313849b41f4dc9505804f9a6108c",
@@ -1394,12 +1394,12 @@
1394
1394
  "signature": "b0afc2803af9e818fad28464e4e62ee1b255d282f8f19ba8a2459b7bab4d789e"
1395
1395
  },
1396
1396
  "../src/Providers/AWSAppSyncRealTimeProvider/index.ts": {
1397
- "version": "bdf3278d057e57afeadef186e7e3c29eb13984bfef25d6103c529b34ab1e7233",
1398
- "signature": "1ca983fc0bd67090f0a821be987a560152b74428b00d1e32d6a1ba687a3036db"
1397
+ "version": "f8705479ea9a4e277dec482c8db14962f1ec78b281ddb806a265ac515e99906c",
1398
+ "signature": "06482fe555f7555e160c985b684718636c0ca7b00893c317e5b8058df388b490"
1399
1399
  },
1400
1400
  "../src/internals/InternalGraphQLAPI.ts": {
1401
- "version": "db89d8ef6882a3bf3877f5f1ab2a5dd1c0e4263c815260a362661c8dfec49cb7",
1402
- "signature": "4321d78cf978abcc5646ba30c694ba92707a891b79697f77ab7d451d0d14db7e"
1401
+ "version": "93686822478e203cb6dad02d8432b98f04fc7e3c875d3a9eb6059b31919b9720",
1402
+ "signature": "186c82c1cbd4eb233c4fde8e8f264511fbba3187e270c384c570343dee075ee4"
1403
1403
  },
1404
1404
  "../src/internals/v6.ts": {
1405
1405
  "version": "49f318f6c79f74c78ad69e2b9bc41d3c61503c0ddb0acbd59480de34ca229adf",
@@ -1435,7 +1435,7 @@
1435
1435
  },
1436
1436
  "../src/utils/resolveConfig.ts": {
1437
1437
  "version": "0fb2071d51a0132ad718f803dc493064d8f784be4d8e1a0b52a43404ea738c64",
1438
- "signature": "79c87fb1bbcb52ffc89fc563eaf1a55a0a345a7067ff2130c6a80372c029df2b"
1438
+ "signature": "d478965a8e7c9f4b505cc28b821b30f42bc71e21d70b14c354a13f8b89278b55"
1439
1439
  },
1440
1440
  "../src/utils/resolveCredentials.ts": {
1441
1441
  "version": "22c610d9879b27de3f79333284f54ce4f330b35e930837627cdfc0d276bf8a57",
@@ -3570,7 +3570,6 @@
3570
3570
  "../src/Providers/constants.ts",
3571
3571
  "../src/utils/ConnectionStateMonitor.ts",
3572
3572
  "../src/utils/ReconnectionMonitor.ts",
3573
- "../../core/lib-esm/singleton/API/types.d.ts",
3574
3573
  "../../core/lib-esm/libraryUtils.d.ts",
3575
3574
  "../../api-rest/lib-esm/index.d.ts",
3576
3575
  "../../../node_modules/@types/node/index.d.ts"
@@ -3852,7 +3851,6 @@
3852
3851
  "../src/types/PubSub.ts",
3853
3852
  "../../api-rest/lib-esm/index.d.ts",
3854
3853
  "../src/Providers/constants.ts",
3855
- "../../core/lib-esm/singleton/API/types.d.ts",
3856
3854
  "../../core/lib-esm/libraryUtils.d.ts"
3857
3855
  ],
3858
3856
  "../src/types/index.ts": [
@@ -4613,7 +4611,7 @@
4613
4611
  "../src/utils/resolveCredentials.ts"
4614
4612
  ],
4615
4613
  "../src/utils/resolveConfig.ts": [
4616
- "../../core/lib-esm/singleton/API/types.d.ts"
4614
+ "../../core/lib-esm/libraryUtils.d.ts"
4617
4615
  ],
4618
4616
  "../src/utils/errors/assertValidationError.ts": [
4619
4617
  "../src/utils/errors/validation.ts"
@@ -4,5 +4,5 @@
4
4
  export declare const resolveConfig: () => {
5
5
  endpoint: string;
6
6
  region: string;
7
- defaultAuthMode: import("@aws-amplify/core/lib-esm/singleton/API/types").GraphQLAuthMode;
7
+ defaultAuthMode: import("@aws-amplify/core/lib-esm/libraryUtils").GraphQLAuthMode;
8
8
  };
@@ -1,8 +1,7 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { PubSubContentObserver } from '../../types/PubSub';
3
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';
4
+ import { CustomUserAgentDetails, GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
6
5
  import { DocumentType } from '@aws-amplify/api-rest';
7
6
  export declare type ObserverQuery = {
8
7
  observer: PubSubContentObserver;
@@ -59,7 +58,6 @@ export declare class AWSAppSyncRealTimeProvider {
59
58
  private _initializeRetryableHandshake;
60
59
  private _initializeHandshake;
61
60
  private _awsRealTimeHeaderBasedAuth;
62
- private _awsRealTimeCUPHeader;
63
61
  private _awsRealTimeOPENIDHeader;
64
62
  private _awsRealTimeApiKeyHeader;
65
63
  private _awsRealTimeIAMHeader;
@@ -83,7 +83,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
83
83
  };
84
84
  AWSAppSyncRealTimeProvider.prototype.subscribe = function (options, customUserAgentDetails) {
85
85
  var _this = this;
86
- var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, region = options.region, query = options.query, variables = options.variables, authenticationType = options.authenticationType;
86
+ var _a = options || {}, appSyncGraphqlEndpoint = _a.appSyncGraphqlEndpoint, region = _a.region, query = _a.query, variables = _a.variables, authenticationType = _a.authenticationType, additionalHeaders = _a.additionalHeaders;
87
87
  return new Observable(function (observer) {
88
88
  if (!options || !appSyncGraphqlEndpoint) {
89
89
  observer.error({
@@ -106,6 +106,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
106
106
  region: region,
107
107
  authenticationType: authenticationType,
108
108
  appSyncGraphqlEndpoint: appSyncGraphqlEndpoint,
109
+ additionalHeaders: additionalHeaders,
109
110
  },
110
111
  observer: observer,
111
112
  subscriptionId: subscriptionId_1,
@@ -695,7 +696,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
695
696
  case 1:
696
697
  handler = headerHandler[authenticationType.type];
697
698
  host = url.parse(appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
698
- logger.debug("Authenticating with " + authenticationType);
699
+ logger.debug("Authenticating with " + JSON.stringify(authenticationType));
699
700
  apiKey = void 0;
700
701
  if (authenticationType.type === 'apiKey') {
701
702
  apiKey = authenticationType.apiKey;
@@ -716,34 +717,18 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
716
717
  });
717
718
  });
718
719
  };
719
- AWSAppSyncRealTimeProvider.prototype._awsRealTimeCUPHeader = function (_a) {
720
- var host = _a.host;
721
- return __awaiter(this, void 0, void 0, function () {
722
- var session;
723
- return __generator(this, function (_b) {
724
- switch (_b.label) {
725
- case 0: return [4 /*yield*/, fetchAuthSession()];
726
- case 1:
727
- session = _b.sent();
728
- return [2 /*return*/, {
729
- Authorization: session.tokens.accessToken.toString(),
730
- host: host,
731
- }];
732
- }
733
- });
734
- });
735
- };
736
720
  AWSAppSyncRealTimeProvider.prototype._awsRealTimeOPENIDHeader = function (_a) {
737
721
  var host = _a.host;
722
+ var _b, _c;
738
723
  return __awaiter(this, void 0, void 0, function () {
739
724
  var session;
740
- return __generator(this, function (_b) {
741
- switch (_b.label) {
725
+ return __generator(this, function (_d) {
726
+ switch (_d.label) {
742
727
  case 0: return [4 /*yield*/, fetchAuthSession()];
743
728
  case 1:
744
- session = _b.sent();
729
+ session = _d.sent();
745
730
  return [2 /*return*/, {
746
- Authorization: session.tokens.accessToken.toString(),
731
+ Authorization: (_c = (_b = session === null || session === void 0 ? void 0 : session.tokens) === null || _b === void 0 ? void 0 : _b.accessToken) === null || _c === void 0 ? void 0 : _c.toString(),
747
732
  host: host,
748
733
  }];
749
734
  }
@@ -802,7 +787,7 @@ var AWSAppSyncRealTimeProvider = /** @class */ (function () {
802
787
  };
803
788
  AWSAppSyncRealTimeProvider.prototype._customAuthHeader = function (_a) {
804
789
  var host = _a.host, additionalHeaders = _a.additionalHeaders;
805
- if (!additionalHeaders || !additionalHeaders['Authorization']) {
790
+ if (!(additionalHeaders === null || additionalHeaders === void 0 ? void 0 : additionalHeaders['Authorization'])) {
806
791
  throw new Error('No auth token specified');
807
792
  }
808
793
  return {
@@ -17,6 +17,7 @@ export declare class InternalGraphQLAPIClass {
17
17
  private _options;
18
18
  private appSyncRealTime;
19
19
  Cache: import("@aws-amplify/core/lib-esm/Cache/types").ICache;
20
+ private _api;
20
21
  /**
21
22
  * Initialize GraphQL API with AWS configuration
22
23
  * @param {Object} options - Configuration object for API
@@ -27,6 +27,7 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
27
27
  */
28
28
  function InternalGraphQLAPIClass(options) {
29
29
  this.Cache = Cache;
30
+ this._api = { post: post };
30
31
  this._options = options;
31
32
  logger.debug('API Options', this._options);
32
33
  }
@@ -196,7 +197,7 @@ var InternalGraphQLAPIClass = /** @class */ (function () {
196
197
  _j.label = 7;
197
198
  case 7:
198
199
  _j.trys.push([7, 9, , 10]);
199
- return [4 /*yield*/, post(endpoint, {
200
+ return [4 /*yield*/, this._api.post(endpoint, {
200
201
  headers: headers,
201
202
  body: body,
202
203
  region: region,
@@ -1130,8 +1130,8 @@
1130
1130
  "signature": "e02f9f6928bd974cc18803419ecc30e12dc39fb3c4383eaa897bf8d868135ef1"
1131
1131
  },
1132
1132
  "../../core/lib-esm/Hub/types/AuthTypes.d.ts": {
1133
- "version": "b8e5ba29dd7f2369f52d2b2ea829e168399e177879cae7fce6ad10e4f50975f3",
1134
- "signature": "b8e5ba29dd7f2369f52d2b2ea829e168399e177879cae7fce6ad10e4f50975f3"
1133
+ "version": "a04a1debf29ca7be5a11859eca422ede0355a7ffac49027843c21a1566aacc2a",
1134
+ "signature": "a04a1debf29ca7be5a11859eca422ede0355a7ffac49027843c21a1566aacc2a"
1135
1135
  },
1136
1136
  "../../core/lib-esm/Hub/types/HubTypes.d.ts": {
1137
1137
  "version": "9a23afdd036a23560984aeeec5dbdfc3ddd3e50bd8ca87929fca3d0a13292148",
@@ -1166,8 +1166,8 @@
1166
1166
  "signature": "92395e3e6898e201a167d96559042af069933f1a96662305bdc01fda3627bfbf"
1167
1167
  },
1168
1168
  "../../core/lib-esm/libraryUtils.d.ts": {
1169
- "version": "0f0269450c924ed45441071963c5bcb05c19b8cb4179e1e1af10ac6f3b82c53c",
1170
- "signature": "0f0269450c924ed45441071963c5bcb05c19b8cb4179e1e1af10ac6f3b82c53c"
1169
+ "version": "6c64a38ac2b21b0e6505c5de98394c334e6c3cde067e206ad8df44fb29474fd6",
1170
+ "signature": "6c64a38ac2b21b0e6505c5de98394c334e6c3cde067e206ad8df44fb29474fd6"
1171
1171
  },
1172
1172
  "../src/types/PubSub.ts": {
1173
1173
  "version": "70ac482472a54d226119a9a20fbb3f3baa04e9e305526ab90559626561206a64",
@@ -1366,8 +1366,8 @@
1366
1366
  "signature": "a21e6b4bebe10b7e0ad199954dff9c5b9813e6552585fd5a944a691d5d0250ed"
1367
1367
  },
1368
1368
  "../../core/lib-esm/I18n/index.d.ts": {
1369
- "version": "39943a1a0b759d46ee9383ef7a3e228b705c05e7ec131677bbcae4b130ed5aba",
1370
- "signature": "39943a1a0b759d46ee9383ef7a3e228b705c05e7ec131677bbcae4b130ed5aba"
1369
+ "version": "3cdc09269c30f50499132846639d826e03fb74007685505c5f0ce9691f627f75",
1370
+ "signature": "3cdc09269c30f50499132846639d826e03fb74007685505c5f0ce9691f627f75"
1371
1371
  },
1372
1372
  "../../core/lib-esm/index.d.ts": {
1373
1373
  "version": "961b863ef850a0b1d97c21a273560ee4434a313849b41f4dc9505804f9a6108c",
@@ -1394,12 +1394,12 @@
1394
1394
  "signature": "b0afc2803af9e818fad28464e4e62ee1b255d282f8f19ba8a2459b7bab4d789e"
1395
1395
  },
1396
1396
  "../src/Providers/AWSAppSyncRealTimeProvider/index.ts": {
1397
- "version": "bdf3278d057e57afeadef186e7e3c29eb13984bfef25d6103c529b34ab1e7233",
1398
- "signature": "1ca983fc0bd67090f0a821be987a560152b74428b00d1e32d6a1ba687a3036db"
1397
+ "version": "f8705479ea9a4e277dec482c8db14962f1ec78b281ddb806a265ac515e99906c",
1398
+ "signature": "06482fe555f7555e160c985b684718636c0ca7b00893c317e5b8058df388b490"
1399
1399
  },
1400
1400
  "../src/internals/InternalGraphQLAPI.ts": {
1401
- "version": "db89d8ef6882a3bf3877f5f1ab2a5dd1c0e4263c815260a362661c8dfec49cb7",
1402
- "signature": "4321d78cf978abcc5646ba30c694ba92707a891b79697f77ab7d451d0d14db7e"
1401
+ "version": "93686822478e203cb6dad02d8432b98f04fc7e3c875d3a9eb6059b31919b9720",
1402
+ "signature": "186c82c1cbd4eb233c4fde8e8f264511fbba3187e270c384c570343dee075ee4"
1403
1403
  },
1404
1404
  "../src/internals/v6.ts": {
1405
1405
  "version": "49f318f6c79f74c78ad69e2b9bc41d3c61503c0ddb0acbd59480de34ca229adf",
@@ -1435,7 +1435,7 @@
1435
1435
  },
1436
1436
  "../src/utils/resolveConfig.ts": {
1437
1437
  "version": "0fb2071d51a0132ad718f803dc493064d8f784be4d8e1a0b52a43404ea738c64",
1438
- "signature": "79c87fb1bbcb52ffc89fc563eaf1a55a0a345a7067ff2130c6a80372c029df2b"
1438
+ "signature": "d478965a8e7c9f4b505cc28b821b30f42bc71e21d70b14c354a13f8b89278b55"
1439
1439
  },
1440
1440
  "../src/utils/resolveCredentials.ts": {
1441
1441
  "version": "22c610d9879b27de3f79333284f54ce4f330b35e930837627cdfc0d276bf8a57",
@@ -3570,7 +3570,6 @@
3570
3570
  "../src/Providers/constants.ts",
3571
3571
  "../src/utils/ConnectionStateMonitor.ts",
3572
3572
  "../src/utils/ReconnectionMonitor.ts",
3573
- "../../core/lib-esm/singleton/API/types.d.ts",
3574
3573
  "../../core/lib-esm/libraryUtils.d.ts",
3575
3574
  "../../api-rest/lib-esm/index.d.ts",
3576
3575
  "../../../node_modules/@types/node/index.d.ts"
@@ -3852,7 +3851,6 @@
3852
3851
  "../src/types/PubSub.ts",
3853
3852
  "../../api-rest/lib-esm/index.d.ts",
3854
3853
  "../src/Providers/constants.ts",
3855
- "../../core/lib-esm/singleton/API/types.d.ts",
3856
3854
  "../../core/lib-esm/libraryUtils.d.ts"
3857
3855
  ],
3858
3856
  "../src/types/index.ts": [
@@ -4613,7 +4611,7 @@
4613
4611
  "../src/utils/resolveCredentials.ts"
4614
4612
  ],
4615
4613
  "../src/utils/resolveConfig.ts": [
4616
- "../../core/lib-esm/singleton/API/types.d.ts"
4614
+ "../../core/lib-esm/libraryUtils.d.ts"
4617
4615
  ],
4618
4616
  "../src/utils/errors/assertValidationError.ts": [
4619
4617
  "../src/utils/errors/validation.ts"
@@ -4,5 +4,5 @@
4
4
  export declare const resolveConfig: () => {
5
5
  endpoint: string;
6
6
  region: string;
7
- defaultAuthMode: import("@aws-amplify/core/lib-esm/singleton/API/types").GraphQLAuthMode;
7
+ defaultAuthMode: import("@aws-amplify/core/lib-esm/libraryUtils").GraphQLAuthMode;
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/api-graphql",
3
- "version": "4.0.1-console-preview.4b7d177.0+4b7d177",
3
+ "version": "4.0.1-console-preview.deaebd5.0+deaebd5",
4
4
  "description": "Api-graphql category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -47,9 +47,9 @@
47
47
  "internals"
48
48
  ],
49
49
  "dependencies": {
50
- "@aws-amplify/api-rest": "4.0.1-console-preview.4b7d177.0+4b7d177",
51
- "@aws-amplify/auth": "6.0.1-console-preview.4b7d177.0+4b7d177",
52
- "@aws-amplify/core": "6.0.1-console-preview.4b7d177.0+4b7d177",
50
+ "@aws-amplify/api-rest": "4.0.1-console-preview.deaebd5.0+deaebd5",
51
+ "@aws-amplify/auth": "6.0.1-console-preview.deaebd5.0+deaebd5",
52
+ "@aws-amplify/core": "6.0.1-console-preview.deaebd5.0+deaebd5",
53
53
  "@aws-sdk/types": "3.387.0",
54
54
  "graphql": "15.8.0",
55
55
  "rxjs": "^7.8.1",
@@ -67,7 +67,9 @@
67
67
  "jest": {
68
68
  "globals": {
69
69
  "ts-jest": {
70
- "diagnostics": false,
70
+ "diagnostics": {
71
+ "pathRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$"
72
+ },
71
73
  "tsConfig": {
72
74
  "lib": [
73
75
  "es5",
@@ -77,7 +79,10 @@
77
79
  "es2017.object"
78
80
  ],
79
81
  "allowJs": true,
80
- "noEmitOnError": false
82
+ "noEmitOnError": false,
83
+ "types": [
84
+ "@types/jest"
85
+ ]
81
86
  }
82
87
  }
83
88
  },
@@ -85,6 +90,11 @@
85
90
  "^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
86
91
  },
87
92
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
93
+ "testPathIgnorePatterns": [
94
+ "<rootDir>/__tests__/helpers.ts",
95
+ "<rootDir>/__tests__/fixtures/",
96
+ "<rootDir>/__tests__/utils/"
97
+ ],
88
98
  "moduleFileExtensions": [
89
99
  "ts",
90
100
  "tsx",
@@ -103,11 +113,12 @@
103
113
  }
104
114
  },
105
115
  "coveragePathIgnorePatterns": [
106
- "/node_modules/",
107
- "dist",
108
- "lib",
109
- "lib-esm"
116
+ "<rootDir>/node_modules/",
117
+ "<rootDir>/dist",
118
+ "<rootDir>/lib",
119
+ "<rootDir>/lib-esm",
120
+ "<rootDir>/__tests__"
110
121
  ]
111
122
  },
112
- "gitHead": "4b7d177e4da0aad2f1e1dd76c8c788f77f3114a2"
123
+ "gitHead": "deaebd5a938733ff2b25aaec39c042843ef2289c"
113
124
  }
@@ -38,7 +38,6 @@ import {
38
38
  ReconnectEvent,
39
39
  ReconnectionMonitor,
40
40
  } from '../../utils/ReconnectionMonitor';
41
- import { GraphQLAuthMode } from '@aws-amplify/core/lib-esm/singleton/API/types';
42
41
 
43
42
  import {
44
43
  CustomUserAgentDetails,
@@ -48,6 +47,7 @@ import {
48
47
  getAmplifyUserAgent,
49
48
  isNonRetryableError,
50
49
  jitteredExponentialRetry,
50
+ GraphQLAuthMode,
51
51
  } from '@aws-amplify/core/internals/utils';
52
52
  import { DocumentType } from '@aws-amplify/api-rest';
53
53
 
@@ -196,7 +196,8 @@ export class AWSAppSyncRealTimeProvider {
196
196
  query,
197
197
  variables,
198
198
  authenticationType,
199
- } = options;
199
+ additionalHeaders,
200
+ } = options || {};
200
201
 
201
202
  return new Observable(observer => {
202
203
  if (!options || !appSyncGraphqlEndpoint) {
@@ -225,6 +226,7 @@ export class AWSAppSyncRealTimeProvider {
225
226
  region,
226
227
  authenticationType,
227
228
  appSyncGraphqlEndpoint,
229
+ additionalHeaders,
228
230
  },
229
231
  observer,
230
232
  subscriptionId,
@@ -294,7 +296,7 @@ export class AWSAppSyncRealTimeProvider {
294
296
  options: AWSAppSyncRealTimeProviderOptions;
295
297
  observer: PubSubContentObserver;
296
298
  subscriptionId: string;
297
- customUserAgentDetails: CustomUserAgentDetails;
299
+ customUserAgentDetails: CustomUserAgentDetails | undefined;
298
300
  }) {
299
301
  const {
300
302
  appSyncGraphqlEndpoint,
@@ -899,7 +901,7 @@ export class AWSAppSyncRealTimeProvider {
899
901
 
900
902
  const { host } = url.parse(appSyncGraphqlEndpoint ?? '');
901
903
 
902
- logger.debug(`Authenticating with ${authenticationType}`);
904
+ logger.debug(`Authenticating with ${JSON.stringify(authenticationType)}`);
903
905
  let apiKey;
904
906
  if (authenticationType.type === 'apiKey') {
905
907
  apiKey = authenticationType.apiKey;
@@ -918,21 +920,13 @@ export class AWSAppSyncRealTimeProvider {
918
920
  }
919
921
  }
920
922
 
921
- private async _awsRealTimeCUPHeader({ host }: AWSAppSyncRealTimeAuthInput) {
922
- const session = await fetchAuthSession();
923
- return {
924
- Authorization: session.tokens.accessToken.toString(),
925
- host,
926
- };
927
- }
928
-
929
923
  private async _awsRealTimeOPENIDHeader({
930
924
  host,
931
925
  }: AWSAppSyncRealTimeAuthInput) {
932
926
  const session = await fetchAuthSession();
933
927
 
934
928
  return {
935
- Authorization: session.tokens.accessToken.toString(),
929
+ Authorization: session?.tokens?.accessToken?.toString(),
936
930
  host,
937
931
  };
938
932
  }
@@ -991,7 +985,7 @@ export class AWSAppSyncRealTimeProvider {
991
985
  host,
992
986
  additionalHeaders,
993
987
  }: AWSAppSyncRealTimeAuthInput) {
994
- if (!additionalHeaders || !additionalHeaders['Authorization']) {
988
+ if (!additionalHeaders?.['Authorization']) {
995
989
  throw new Error('No auth token specified');
996
990
  }
997
991
 
@@ -49,6 +49,7 @@ export class InternalGraphQLAPIClass {
49
49
  private appSyncRealTime: AWSAppSyncRealTimeProvider | null;
50
50
 
51
51
  Cache = Cache;
52
+ private _api = { post };
52
53
 
53
54
  /**
54
55
  * Initialize GraphQL API with AWS configuration
@@ -241,7 +242,7 @@ export class InternalGraphQLAPIClass {
241
242
 
242
243
  let response;
243
244
  try {
244
- response = await post(endpoint, {
245
+ response = await this._api.post(endpoint, {
245
246
  headers,
246
247
  body,
247
248
  region,