@aws-amplify/api 4.0.33-unstable.9 → 4.0.34-cloud-logging.8
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.
- package/CHANGELOG.md +17 -35
- package/dist/aws-amplify-api.js +262 -218
- package/dist/aws-amplify-api.js.map +1 -1
- package/dist/aws-amplify-api.min.js +3 -3
- package/dist/aws-amplify-api.min.js.map +1 -1
- package/package.json +4 -4
package/dist/aws-amplify-api.js
CHANGED
|
@@ -10245,17 +10245,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
10245
10245
|
|
|
10246
10246
|
"use strict";
|
|
10247
10247
|
__webpack_require__.r(__webpack_exports__);
|
|
10248
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return GRAPHQL_AUTH_MODE; });
|
|
10249
10248
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GraphQLAuthError", function() { return GraphQLAuthError; });
|
|
10250
|
-
var
|
|
10249
|
+
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/auth */ "@aws-amplify/auth");
|
|
10250
|
+
/* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__);
|
|
10251
|
+
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GRAPHQL_AUTH_MODE", function() { return _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"]; });
|
|
10252
|
+
|
|
10251
10253
|
|
|
10252
|
-
(function (GRAPHQL_AUTH_MODE) {
|
|
10253
|
-
GRAPHQL_AUTH_MODE["API_KEY"] = "API_KEY";
|
|
10254
|
-
GRAPHQL_AUTH_MODE["AWS_IAM"] = "AWS_IAM";
|
|
10255
|
-
GRAPHQL_AUTH_MODE["OPENID_CONNECT"] = "OPENID_CONNECT";
|
|
10256
|
-
GRAPHQL_AUTH_MODE["AMAZON_COGNITO_USER_POOLS"] = "AMAZON_COGNITO_USER_POOLS";
|
|
10257
|
-
GRAPHQL_AUTH_MODE["AWS_LAMBDA"] = "AWS_LAMBDA";
|
|
10258
|
-
})(GRAPHQL_AUTH_MODE || (GRAPHQL_AUTH_MODE = {}));
|
|
10259
10254
|
|
|
10260
10255
|
var GraphQLAuthError;
|
|
10261
10256
|
|
|
@@ -11713,6 +11708,9 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
11713
11708
|
|
|
11714
11709
|
|
|
11715
11710
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('AWSAppSyncProvider');
|
|
11711
|
+
/**
|
|
11712
|
+
* @deprecated Unused, all usecases have migrated to AWSAppSyncRealtimeProvider
|
|
11713
|
+
*/
|
|
11716
11714
|
|
|
11717
11715
|
var AWSAppSyncProvider =
|
|
11718
11716
|
/** @class */
|
|
@@ -12436,9 +12434,9 @@ function (_super) {
|
|
|
12436
12434
|
AWSAppSyncRealTimeProvider.prototype.subscribe = function (_topics, options) {
|
|
12437
12435
|
var _this = this;
|
|
12438
12436
|
|
|
12439
|
-
var appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint;
|
|
12437
|
+
var appSyncGraphqlEndpoint = options === null || options === void 0 ? void 0 : options.appSyncGraphqlEndpoint;
|
|
12440
12438
|
return new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (observer) {
|
|
12441
|
-
if (!appSyncGraphqlEndpoint) {
|
|
12439
|
+
if (!options || !appSyncGraphqlEndpoint) {
|
|
12442
12440
|
observer.error({
|
|
12443
12441
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscribe only available for AWS AppSync endpoint"))]
|
|
12444
12442
|
});
|
|
@@ -12531,19 +12529,22 @@ function (_super) {
|
|
|
12531
12529
|
var options = _a.options,
|
|
12532
12530
|
observer = _a.observer,
|
|
12533
12531
|
subscriptionId = _a.subscriptionId;
|
|
12532
|
+
|
|
12533
|
+
var _b, _c;
|
|
12534
|
+
|
|
12534
12535
|
return __awaiter(this, void 0, void 0, function () {
|
|
12535
|
-
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region,
|
|
12536
|
+
var appSyncGraphqlEndpoint, authenticationType, query, variables, apiKey, region, _d, graphql_headers, _e, additionalHeaders, subscriptionState, data, dataString, headerObj, _f, _g, subscriptionMessage, stringToAWSRealTime, err_2, message, subscriptionFailedCallback_1, _h, subscriptionFailedCallback, subscriptionReadyCallback;
|
|
12536
12537
|
|
|
12537
|
-
var
|
|
12538
|
+
var _j;
|
|
12538
12539
|
|
|
12539
12540
|
var _this = this;
|
|
12540
12541
|
|
|
12541
|
-
return __generator(this, function (
|
|
12542
|
-
switch (
|
|
12542
|
+
return __generator(this, function (_k) {
|
|
12543
|
+
switch (_k.label) {
|
|
12543
12544
|
case 0:
|
|
12544
|
-
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region,
|
|
12545
|
+
appSyncGraphqlEndpoint = options.appSyncGraphqlEndpoint, authenticationType = options.authenticationType, query = options.query, variables = options.variables, apiKey = options.apiKey, region = options.region, _d = options.graphql_headers, graphql_headers = _d === void 0 ? function () {
|
|
12545
12546
|
return {};
|
|
12546
|
-
} :
|
|
12547
|
+
} : _d, _e = options.additionalHeaders, additionalHeaders = _e === void 0 ? {} : _e;
|
|
12547
12548
|
subscriptionState = SUBSCRIPTION_STATUS.PENDING;
|
|
12548
12549
|
data = {
|
|
12549
12550
|
query: query,
|
|
@@ -12552,13 +12553,13 @@ function (_super) {
|
|
|
12552
12553
|
|
|
12553
12554
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
12554
12555
|
observer: observer,
|
|
12555
|
-
query: query,
|
|
12556
|
-
variables: variables,
|
|
12556
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
12557
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
12557
12558
|
subscriptionState: subscriptionState,
|
|
12558
|
-
startAckTimeoutId:
|
|
12559
|
+
startAckTimeoutId: undefined
|
|
12559
12560
|
});
|
|
12560
12561
|
dataString = JSON.stringify(data);
|
|
12561
|
-
|
|
12562
|
+
_f = [{}];
|
|
12562
12563
|
return [4
|
|
12563
12564
|
/*yield*/
|
|
12564
12565
|
, this._awsRealTimeHeaderBasedAuth({
|
|
@@ -12572,13 +12573,13 @@ function (_super) {
|
|
|
12572
12573
|
})];
|
|
12573
12574
|
|
|
12574
12575
|
case 1:
|
|
12575
|
-
|
|
12576
|
+
_g = [__assign.apply(void 0, _f.concat([_k.sent()]))];
|
|
12576
12577
|
return [4
|
|
12577
12578
|
/*yield*/
|
|
12578
12579
|
, graphql_headers()];
|
|
12579
12580
|
|
|
12580
12581
|
case 2:
|
|
12581
|
-
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0,
|
|
12582
|
+
headerObj = __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _g.concat([_k.sent()])), additionalHeaders]), (_j = {}, _j[_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["USER_AGENT_HEADER"]] = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Constants"].userAgent, _j)]);
|
|
12582
12583
|
subscriptionMessage = {
|
|
12583
12584
|
id: subscriptionId,
|
|
12584
12585
|
payload: {
|
|
@@ -12590,10 +12591,10 @@ function (_super) {
|
|
|
12590
12591
|
type: MESSAGE_TYPES.GQL_START
|
|
12591
12592
|
};
|
|
12592
12593
|
stringToAWSRealTime = JSON.stringify(subscriptionMessage);
|
|
12593
|
-
|
|
12594
|
+
_k.label = 3;
|
|
12594
12595
|
|
|
12595
12596
|
case 3:
|
|
12596
|
-
|
|
12597
|
+
_k.trys.push([3, 5,, 6]);
|
|
12597
12598
|
|
|
12598
12599
|
return [4
|
|
12599
12600
|
/*yield*/
|
|
@@ -12606,18 +12607,18 @@ function (_super) {
|
|
|
12606
12607
|
})];
|
|
12607
12608
|
|
|
12608
12609
|
case 4:
|
|
12609
|
-
|
|
12610
|
+
_k.sent();
|
|
12610
12611
|
|
|
12611
12612
|
return [3
|
|
12612
12613
|
/*break*/
|
|
12613
12614
|
, 6];
|
|
12614
12615
|
|
|
12615
12616
|
case 5:
|
|
12616
|
-
err_2 =
|
|
12617
|
+
err_2 = _k.sent();
|
|
12617
12618
|
logger.debug({
|
|
12618
12619
|
err: err_2
|
|
12619
12620
|
});
|
|
12620
|
-
|
|
12621
|
+
message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
|
|
12621
12622
|
observer.error({
|
|
12622
12623
|
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
|
|
12623
12624
|
});
|
|
@@ -12633,13 +12634,13 @@ function (_super) {
|
|
|
12633
12634
|
];
|
|
12634
12635
|
|
|
12635
12636
|
case 6:
|
|
12636
|
-
|
|
12637
|
+
_h = (_c = this.subscriptionObserverMap.get(subscriptionId)) !== null && _c !== void 0 ? _c : {}, subscriptionFailedCallback = _h.subscriptionFailedCallback, subscriptionReadyCallback = _h.subscriptionReadyCallback; // This must be done before sending the message in order to be listening immediately
|
|
12637
12638
|
|
|
12638
12639
|
this.subscriptionObserverMap.set(subscriptionId, {
|
|
12639
12640
|
observer: observer,
|
|
12640
12641
|
subscriptionState: subscriptionState,
|
|
12641
|
-
|
|
12642
|
-
|
|
12642
|
+
query: query !== null && query !== void 0 ? query : '',
|
|
12643
|
+
variables: variables !== null && variables !== void 0 ? variables : {},
|
|
12643
12644
|
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
12644
12645
|
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
12645
12646
|
startAckTimeoutId: setTimeout(function () {
|
|
@@ -12662,32 +12663,35 @@ function (_super) {
|
|
|
12662
12663
|
|
|
12663
12664
|
AWSAppSyncRealTimeProvider.prototype._waitForSubscriptionToBeConnected = function (subscriptionId) {
|
|
12664
12665
|
return __awaiter(this, void 0, void 0, function () {
|
|
12665
|
-
var subscriptionState;
|
|
12666
|
+
var subscriptionObserver, subscriptionState;
|
|
12666
12667
|
|
|
12667
12668
|
var _this = this;
|
|
12668
12669
|
|
|
12669
12670
|
return __generator(this, function (_a) {
|
|
12670
|
-
|
|
12671
|
+
subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
12671
12672
|
|
|
12672
|
-
if (
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12673
|
+
if (subscriptionObserver) {
|
|
12674
|
+
subscriptionState = subscriptionObserver.subscriptionState; // This in case unsubscribe is invoked before sending start subscription message
|
|
12675
|
+
|
|
12676
|
+
if (subscriptionState === SUBSCRIPTION_STATUS.PENDING) {
|
|
12677
|
+
return [2
|
|
12678
|
+
/*return*/
|
|
12679
|
+
, new Promise(function (res, rej) {
|
|
12680
|
+
var observer = subscriptionObserver.observer,
|
|
12681
|
+
subscriptionState = subscriptionObserver.subscriptionState,
|
|
12682
|
+
variables = subscriptionObserver.variables,
|
|
12683
|
+
query = subscriptionObserver.query;
|
|
12684
|
+
|
|
12685
|
+
_this.subscriptionObserverMap.set(subscriptionId, {
|
|
12686
|
+
observer: observer,
|
|
12687
|
+
subscriptionState: subscriptionState,
|
|
12688
|
+
variables: variables,
|
|
12689
|
+
query: query,
|
|
12690
|
+
subscriptionReadyCallback: res,
|
|
12691
|
+
subscriptionFailedCallback: rej
|
|
12692
|
+
});
|
|
12693
|
+
})];
|
|
12694
|
+
}
|
|
12691
12695
|
}
|
|
12692
12696
|
|
|
12693
12697
|
return [2
|
|
@@ -12738,19 +12742,23 @@ function (_super) {
|
|
|
12738
12742
|
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
12739
12743
|
} else {
|
|
12740
12744
|
logger.debug('closing WebSocket...');
|
|
12741
|
-
clearTimeout(this.keepAliveTimeoutId);
|
|
12745
|
+
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
12742
12746
|
var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
|
|
12743
12747
|
|
|
12744
|
-
tempSocket.onclose =
|
|
12745
|
-
tempSocket.onerror =
|
|
12748
|
+
tempSocket.onclose = null;
|
|
12749
|
+
tempSocket.onerror = null;
|
|
12746
12750
|
tempSocket.close(1000);
|
|
12747
|
-
this.awsRealTimeSocket =
|
|
12751
|
+
this.awsRealTimeSocket = undefined;
|
|
12748
12752
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
12749
12753
|
}
|
|
12750
12754
|
};
|
|
12751
12755
|
|
|
12752
12756
|
AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
|
|
12753
|
-
|
|
12757
|
+
if (message.data && message.data === '{"type":"ka"}') {
|
|
12758
|
+
logger.verbose("subscription message from AWS AppSync RealTime: " + message.data);
|
|
12759
|
+
} else {
|
|
12760
|
+
logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
|
|
12761
|
+
}
|
|
12754
12762
|
|
|
12755
12763
|
var _a = JSON.parse(message.data),
|
|
12756
12764
|
_b = _a.id,
|
|
@@ -12769,12 +12777,21 @@ function (_super) {
|
|
|
12769
12777
|
subscriptionReadyCallback = _c.subscriptionReadyCallback,
|
|
12770
12778
|
subscriptionFailedCallback = _c.subscriptionFailedCallback;
|
|
12771
12779
|
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12780
|
+
if (!id && !observer && !query && Object.keys(variables).length === 0) {
|
|
12781
|
+
logger.verbose({
|
|
12782
|
+
id: id,
|
|
12783
|
+
observer: observer,
|
|
12784
|
+
query: query,
|
|
12785
|
+
variables: variables
|
|
12786
|
+
});
|
|
12787
|
+
} else {
|
|
12788
|
+
logger.debug({
|
|
12789
|
+
id: id,
|
|
12790
|
+
observer: observer,
|
|
12791
|
+
query: query,
|
|
12792
|
+
variables: variables
|
|
12793
|
+
});
|
|
12794
|
+
}
|
|
12778
12795
|
|
|
12779
12796
|
if (type === MESSAGE_TYPES.GQL_DATA && payload && payload.data) {
|
|
12780
12797
|
if (observer) {
|
|
@@ -12796,50 +12813,57 @@ function (_super) {
|
|
|
12796
12813
|
subscriptionReadyCallback();
|
|
12797
12814
|
}
|
|
12798
12815
|
|
|
12799
|
-
clearTimeout(startAckTimeoutId);
|
|
12816
|
+
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
12800
12817
|
dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].SUBSCRIPTION_ACK, {
|
|
12801
12818
|
query: query,
|
|
12802
12819
|
variables: variables
|
|
12803
12820
|
}, 'Connection established for subscription');
|
|
12804
12821
|
var subscriptionState = SUBSCRIPTION_STATUS.CONNECTED;
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12822
|
+
|
|
12823
|
+
if (observer) {
|
|
12824
|
+
this.subscriptionObserverMap.set(id, {
|
|
12825
|
+
observer: observer,
|
|
12826
|
+
query: query,
|
|
12827
|
+
variables: variables,
|
|
12828
|
+
startAckTimeoutId: undefined,
|
|
12829
|
+
subscriptionState: subscriptionState,
|
|
12830
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
12831
|
+
subscriptionFailedCallback: subscriptionFailedCallback
|
|
12832
|
+
});
|
|
12833
|
+
} // TODO: emit event on hub but it requires to store the id first
|
|
12834
|
+
|
|
12814
12835
|
|
|
12815
12836
|
return;
|
|
12816
12837
|
}
|
|
12817
12838
|
|
|
12818
12839
|
if (type === MESSAGE_TYPES.GQL_CONNECTION_KEEP_ALIVE) {
|
|
12819
|
-
clearTimeout(this.keepAliveTimeoutId);
|
|
12840
|
+
if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
|
|
12820
12841
|
this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
|
|
12821
12842
|
return;
|
|
12822
12843
|
}
|
|
12823
12844
|
|
|
12824
12845
|
if (type === MESSAGE_TYPES.GQL_ERROR) {
|
|
12825
12846
|
var subscriptionState = SUBSCRIPTION_STATUS.FAILED;
|
|
12826
|
-
this.subscriptionObserverMap.set(id, {
|
|
12827
|
-
observer: observer,
|
|
12828
|
-
query: query,
|
|
12829
|
-
variables: variables,
|
|
12830
|
-
startAckTimeoutId: startAckTimeoutId,
|
|
12831
|
-
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
12832
|
-
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
12833
|
-
subscriptionState: subscriptionState
|
|
12834
|
-
});
|
|
12835
|
-
observer.error({
|
|
12836
|
-
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
12837
|
-
});
|
|
12838
|
-
clearTimeout(startAckTimeoutId);
|
|
12839
|
-
observer.complete();
|
|
12840
12847
|
|
|
12841
|
-
if (
|
|
12842
|
-
|
|
12848
|
+
if (observer) {
|
|
12849
|
+
this.subscriptionObserverMap.set(id, {
|
|
12850
|
+
observer: observer,
|
|
12851
|
+
query: query,
|
|
12852
|
+
variables: variables,
|
|
12853
|
+
startAckTimeoutId: startAckTimeoutId,
|
|
12854
|
+
subscriptionReadyCallback: subscriptionReadyCallback,
|
|
12855
|
+
subscriptionFailedCallback: subscriptionFailedCallback,
|
|
12856
|
+
subscriptionState: subscriptionState
|
|
12857
|
+
});
|
|
12858
|
+
observer.error({
|
|
12859
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + JSON.stringify(payload)))]
|
|
12860
|
+
});
|
|
12861
|
+
if (startAckTimeoutId) clearTimeout(startAckTimeoutId);
|
|
12862
|
+
observer.complete();
|
|
12863
|
+
|
|
12864
|
+
if (typeof subscriptionFailedCallback === 'function') {
|
|
12865
|
+
subscriptionFailedCallback();
|
|
12866
|
+
}
|
|
12843
12867
|
}
|
|
12844
12868
|
}
|
|
12845
12869
|
};
|
|
@@ -12865,37 +12889,40 @@ function (_super) {
|
|
|
12865
12889
|
};
|
|
12866
12890
|
|
|
12867
12891
|
AWSAppSyncRealTimeProvider.prototype._timeoutStartSubscriptionAck = function (subscriptionId) {
|
|
12868
|
-
var
|
|
12869
|
-
observer = _a.observer,
|
|
12870
|
-
query = _a.query,
|
|
12871
|
-
variables = _a.variables;
|
|
12892
|
+
var subscriptionObserver = this.subscriptionObserverMap.get(subscriptionId);
|
|
12872
12893
|
|
|
12873
|
-
if (
|
|
12874
|
-
|
|
12875
|
-
|
|
12894
|
+
if (subscriptionObserver) {
|
|
12895
|
+
var observer = subscriptionObserver.observer,
|
|
12896
|
+
query = subscriptionObserver.query,
|
|
12897
|
+
variables = subscriptionObserver.variables;
|
|
12876
12898
|
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
variables: variables,
|
|
12881
|
-
subscriptionState: SUBSCRIPTION_STATUS.FAILED
|
|
12882
|
-
});
|
|
12899
|
+
if (!observer) {
|
|
12900
|
+
return;
|
|
12901
|
+
}
|
|
12883
12902
|
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
}); // Cleanup will be automatically executed
|
|
12903
|
+
this.subscriptionObserverMap.set(subscriptionId, {
|
|
12904
|
+
observer: observer,
|
|
12905
|
+
query: query,
|
|
12906
|
+
variables: variables,
|
|
12907
|
+
subscriptionState: SUBSCRIPTION_STATUS.FAILED
|
|
12908
|
+
});
|
|
12891
12909
|
|
|
12892
|
-
observer.
|
|
12893
|
-
|
|
12910
|
+
if (observer && !observer.closed) {
|
|
12911
|
+
observer.error({
|
|
12912
|
+
errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"]("Subscription timeout " + JSON.stringify({
|
|
12913
|
+
query: query,
|
|
12914
|
+
variables: variables
|
|
12915
|
+
})))]
|
|
12916
|
+
}); // Cleanup will be automatically executed
|
|
12894
12917
|
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12918
|
+
observer.complete();
|
|
12919
|
+
}
|
|
12920
|
+
|
|
12921
|
+
logger.debug('timeoutStartSubscription', JSON.stringify({
|
|
12922
|
+
query: query,
|
|
12923
|
+
variables: variables
|
|
12924
|
+
}));
|
|
12925
|
+
}
|
|
12899
12926
|
};
|
|
12900
12927
|
|
|
12901
12928
|
AWSAppSyncRealTimeProvider.prototype._initializeWebSocketConnection = function (_a) {
|
|
@@ -12949,7 +12976,7 @@ function (_super) {
|
|
|
12949
12976
|
headerString = _b.apply(_a, [_c.sent()]);
|
|
12950
12977
|
headerQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(headerString).toString('base64');
|
|
12951
12978
|
payloadQs = buffer__WEBPACK_IMPORTED_MODULE_4__["Buffer"].from(payloadString).toString('base64');
|
|
12952
|
-
discoverableEndpoint = appSyncGraphqlEndpoint;
|
|
12979
|
+
discoverableEndpoint = appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '';
|
|
12953
12980
|
|
|
12954
12981
|
if (this.isCustomDomain(discoverableEndpoint)) {
|
|
12955
12982
|
discoverableEndpoint = discoverableEndpoint.concat(customDomainPath);
|
|
@@ -12962,9 +12989,7 @@ function (_super) {
|
|
|
12962
12989
|
awsRealTimeUrl = discoverableEndpoint + "?header=" + headerQs + "&payload=" + payloadQs;
|
|
12963
12990
|
return [4
|
|
12964
12991
|
/*yield*/
|
|
12965
|
-
, this._initializeRetryableHandshake(
|
|
12966
|
-
awsRealTimeUrl: awsRealTimeUrl
|
|
12967
|
-
})];
|
|
12992
|
+
, this._initializeRetryableHandshake(awsRealTimeUrl)];
|
|
12968
12993
|
|
|
12969
12994
|
case 3:
|
|
12970
12995
|
_c.sent();
|
|
@@ -12992,7 +13017,7 @@ function (_super) {
|
|
|
12992
13017
|
this.awsRealTimeSocket.close(3001);
|
|
12993
13018
|
}
|
|
12994
13019
|
|
|
12995
|
-
this.awsRealTimeSocket =
|
|
13020
|
+
this.awsRealTimeSocket = undefined;
|
|
12996
13021
|
this.socketStatus = SOCKET_STATUS.CLOSED;
|
|
12997
13022
|
return [3
|
|
12998
13023
|
/*break*/
|
|
@@ -13008,21 +13033,18 @@ function (_super) {
|
|
|
13008
13033
|
});
|
|
13009
13034
|
};
|
|
13010
13035
|
|
|
13011
|
-
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (
|
|
13012
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
13036
|
+
AWSAppSyncRealTimeProvider.prototype._initializeRetryableHandshake = function (awsRealTimeUrl) {
|
|
13013
13037
|
return __awaiter(this, void 0, void 0, function () {
|
|
13014
|
-
return __generator(this, function (
|
|
13015
|
-
switch (
|
|
13038
|
+
return __generator(this, function (_a) {
|
|
13039
|
+
switch (_a.label) {
|
|
13016
13040
|
case 0:
|
|
13017
13041
|
logger.debug("Initializaling retryable Handshake");
|
|
13018
13042
|
return [4
|
|
13019
13043
|
/*yield*/
|
|
13020
|
-
, Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [
|
|
13021
|
-
awsRealTimeUrl: awsRealTimeUrl
|
|
13022
|
-
}], MAX_DELAY_MS)];
|
|
13044
|
+
, Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["jitteredExponentialRetry"])(this._initializeHandshake.bind(this), [awsRealTimeUrl], MAX_DELAY_MS)];
|
|
13023
13045
|
|
|
13024
13046
|
case 1:
|
|
13025
|
-
|
|
13047
|
+
_a.sent();
|
|
13026
13048
|
|
|
13027
13049
|
return [2
|
|
13028
13050
|
/*return*/
|
|
@@ -13032,10 +13054,9 @@ function (_super) {
|
|
|
13032
13054
|
});
|
|
13033
13055
|
};
|
|
13034
13056
|
|
|
13035
|
-
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (
|
|
13036
|
-
var awsRealTimeUrl = _a.awsRealTimeUrl;
|
|
13057
|
+
AWSAppSyncRealTimeProvider.prototype._initializeHandshake = function (awsRealTimeUrl) {
|
|
13037
13058
|
return __awaiter(this, void 0, void 0, function () {
|
|
13038
|
-
var err_4, errorType, errorCode;
|
|
13059
|
+
var err_4, _a, errorType, errorCode;
|
|
13039
13060
|
|
|
13040
13061
|
var _this = this;
|
|
13041
13062
|
|
|
@@ -13077,77 +13098,82 @@ function (_super) {
|
|
|
13077
13098
|
/*yield*/
|
|
13078
13099
|
, function () {
|
|
13079
13100
|
return new Promise(function (res, rej) {
|
|
13080
|
-
|
|
13101
|
+
if (_this.awsRealTimeSocket) {
|
|
13102
|
+
var ackOk_1 = false;
|
|
13081
13103
|
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13104
|
+
_this.awsRealTimeSocket.onerror = function (error) {
|
|
13105
|
+
logger.debug("WebSocket error " + JSON.stringify(error));
|
|
13106
|
+
};
|
|
13085
13107
|
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13108
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
13109
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
13110
|
+
rej(new Error(JSON.stringify(event)));
|
|
13111
|
+
};
|
|
13090
13112
|
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13113
|
+
_this.awsRealTimeSocket.onmessage = function (message) {
|
|
13114
|
+
logger.debug("subscription message from AWS AppSyncRealTime: " + message.data + " ");
|
|
13115
|
+
var data = JSON.parse(message.data);
|
|
13116
|
+
var type = data.type,
|
|
13117
|
+
_a = data.payload,
|
|
13118
|
+
_b = (_a === void 0 ? {} : _a).connectionTimeoutMs,
|
|
13119
|
+
connectionTimeoutMs = _b === void 0 ? DEFAULT_KEEP_ALIVE_TIMEOUT : _b;
|
|
13098
13120
|
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
_this.keepAliveTimeout = connectionTimeoutMs;
|
|
13102
|
-
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
13121
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ACK) {
|
|
13122
|
+
ackOk_1 = true;
|
|
13103
13123
|
|
|
13104
|
-
|
|
13105
|
-
|
|
13124
|
+
if (_this.awsRealTimeSocket) {
|
|
13125
|
+
_this.keepAliveTimeout = connectionTimeoutMs;
|
|
13126
|
+
_this.awsRealTimeSocket.onmessage = _this._handleIncomingSubscriptionMessage.bind(_this);
|
|
13106
13127
|
|
|
13107
|
-
|
|
13108
|
-
|
|
13128
|
+
_this.awsRealTimeSocket.onerror = function (err) {
|
|
13129
|
+
logger.debug(err);
|
|
13109
13130
|
|
|
13110
|
-
|
|
13111
|
-
|
|
13131
|
+
_this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
13132
|
+
};
|
|
13112
13133
|
|
|
13113
|
-
|
|
13114
|
-
|
|
13134
|
+
_this.awsRealTimeSocket.onclose = function (event) {
|
|
13135
|
+
logger.debug("WebSocket closed " + event.reason);
|
|
13115
13136
|
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13137
|
+
_this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_CLOSED);
|
|
13138
|
+
};
|
|
13139
|
+
}
|
|
13119
13140
|
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
_e = __read(_d === void 0 ? [] : _d, 1),
|
|
13124
|
-
_f = _e[0],
|
|
13125
|
-
_g = _f === void 0 ? {} : _f,
|
|
13126
|
-
_h = _g.errorType,
|
|
13127
|
-
errorType = _h === void 0 ? '' : _h,
|
|
13128
|
-
_j = _g.errorCode,
|
|
13129
|
-
errorCode = _j === void 0 ? 0 : _j;
|
|
13130
|
-
|
|
13131
|
-
rej({
|
|
13132
|
-
errorType: errorType,
|
|
13133
|
-
errorCode: errorCode
|
|
13134
|
-
});
|
|
13135
|
-
}
|
|
13136
|
-
};
|
|
13141
|
+
res('Cool, connected to AWS AppSyncRealTime');
|
|
13142
|
+
return;
|
|
13143
|
+
}
|
|
13137
13144
|
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13145
|
+
if (type === MESSAGE_TYPES.GQL_CONNECTION_ERROR) {
|
|
13146
|
+
var _c = data.payload,
|
|
13147
|
+
_d = (_c === void 0 ? {} : _c).errors,
|
|
13148
|
+
_e = __read(_d === void 0 ? [] : _d, 1),
|
|
13149
|
+
_f = _e[0],
|
|
13150
|
+
_g = _f === void 0 ? {} : _f,
|
|
13151
|
+
_h = _g.errorType,
|
|
13152
|
+
errorType = _h === void 0 ? '' : _h,
|
|
13153
|
+
_j = _g.errorCode,
|
|
13154
|
+
errorCode = _j === void 0 ? 0 : _j;
|
|
13155
|
+
|
|
13156
|
+
rej({
|
|
13157
|
+
errorType: errorType,
|
|
13158
|
+
errorCode: errorCode
|
|
13159
|
+
});
|
|
13160
|
+
}
|
|
13161
|
+
};
|
|
13141
13162
|
|
|
13142
|
-
|
|
13163
|
+
var gqlInit = {
|
|
13164
|
+
type: MESSAGE_TYPES.GQL_CONNECTION_INIT
|
|
13165
|
+
};
|
|
13143
13166
|
|
|
13144
|
-
|
|
13167
|
+
_this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
|
|
13168
|
+
|
|
13169
|
+
setTimeout(checkAckOk.bind(_this, ackOk_1), CONNECTION_INIT_TIMEOUT);
|
|
13170
|
+
}
|
|
13171
|
+
|
|
13172
|
+
function checkAckOk(ackOk) {
|
|
13145
13173
|
if (!ackOk) {
|
|
13146
13174
|
rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + CONNECTION_INIT_TIMEOUT + " ms"));
|
|
13147
13175
|
}
|
|
13148
13176
|
}
|
|
13149
|
-
|
|
13150
|
-
setTimeout(checkAckOk.bind(_this), CONNECTION_INIT_TIMEOUT);
|
|
13151
13177
|
});
|
|
13152
13178
|
}()];
|
|
13153
13179
|
|
|
@@ -13161,7 +13187,7 @@ function (_super) {
|
|
|
13161
13187
|
|
|
13162
13188
|
case 4:
|
|
13163
13189
|
err_4 = _b.sent();
|
|
13164
|
-
errorType =
|
|
13190
|
+
_a = err_4, errorType = _a.errorType, errorCode = _a.errorCode;
|
|
13165
13191
|
|
|
13166
13192
|
if (NON_RETRYABLE_CODES.includes(errorCode)) {
|
|
13167
13193
|
throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["NonRetryableError"](errorType);
|
|
@@ -13204,16 +13230,17 @@ function (_super) {
|
|
|
13204
13230
|
AMAZON_COGNITO_USER_POOLS: this._awsRealTimeCUPHeader.bind(this),
|
|
13205
13231
|
AWS_LAMBDA: this._customAuthHeader
|
|
13206
13232
|
};
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
}
|
|
13233
|
+
if (!(!authenticationType || !headerHandler[authenticationType])) return [3
|
|
13234
|
+
/*break*/
|
|
13235
|
+
, 1];
|
|
13236
|
+
logger.debug("Authentication type " + authenticationType + " not supported");
|
|
13237
|
+
return [2
|
|
13238
|
+
/*return*/
|
|
13239
|
+
, ''];
|
|
13215
13240
|
|
|
13216
|
-
|
|
13241
|
+
case 1:
|
|
13242
|
+
handler = headerHandler[authenticationType];
|
|
13243
|
+
host = url__WEBPACK_IMPORTED_MODULE_2__["parse"](appSyncGraphqlEndpoint !== null && appSyncGraphqlEndpoint !== void 0 ? appSyncGraphqlEndpoint : '').host;
|
|
13217
13244
|
return [4
|
|
13218
13245
|
/*yield*/
|
|
13219
13246
|
, handler({
|
|
@@ -13226,7 +13253,7 @@ function (_super) {
|
|
|
13226
13253
|
additionalHeaders: additionalHeaders
|
|
13227
13254
|
})];
|
|
13228
13255
|
|
|
13229
|
-
case
|
|
13256
|
+
case 2:
|
|
13230
13257
|
result = _b.sent();
|
|
13231
13258
|
return [2
|
|
13232
13259
|
/*return*/
|
|
@@ -13358,10 +13385,14 @@ function (_super) {
|
|
|
13358
13385
|
return [4
|
|
13359
13386
|
/*yield*/
|
|
13360
13387
|
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Credentials"].get().then(function (credentials) {
|
|
13388
|
+
var _a = credentials,
|
|
13389
|
+
secretAccessKey = _a.secretAccessKey,
|
|
13390
|
+
accessKeyId = _a.accessKeyId,
|
|
13391
|
+
sessionToken = _a.sessionToken;
|
|
13361
13392
|
return {
|
|
13362
|
-
secret_key:
|
|
13363
|
-
access_key:
|
|
13364
|
-
session_token:
|
|
13393
|
+
secret_key: secretAccessKey,
|
|
13394
|
+
access_key: accessKeyId,
|
|
13395
|
+
session_token: sessionToken
|
|
13365
13396
|
};
|
|
13366
13397
|
})];
|
|
13367
13398
|
|
|
@@ -13386,7 +13417,7 @@ function (_super) {
|
|
|
13386
13417
|
var host = _a.host,
|
|
13387
13418
|
additionalHeaders = _a.additionalHeaders;
|
|
13388
13419
|
|
|
13389
|
-
if (!additionalHeaders
|
|
13420
|
+
if (!additionalHeaders || !additionalHeaders['Authorization']) {
|
|
13390
13421
|
throw new Error('No auth token specified');
|
|
13391
13422
|
}
|
|
13392
13423
|
|
|
@@ -13623,8 +13654,12 @@ var AWSIoTProvider =
|
|
|
13623
13654
|
function (_super) {
|
|
13624
13655
|
__extends(AWSIoTProvider, _super);
|
|
13625
13656
|
|
|
13626
|
-
function AWSIoTProvider() {
|
|
13627
|
-
|
|
13657
|
+
function AWSIoTProvider(options) {
|
|
13658
|
+
if (options === void 0) {
|
|
13659
|
+
options = {};
|
|
13660
|
+
}
|
|
13661
|
+
|
|
13662
|
+
return _super.call(this, options) || this;
|
|
13628
13663
|
}
|
|
13629
13664
|
|
|
13630
13665
|
Object.defineProperty(AWSIoTProvider.prototype, "region", {
|
|
@@ -13954,21 +13989,27 @@ function () {
|
|
|
13954
13989
|
|
|
13955
13990
|
ClientsQueue.prototype.get = function (clientId, clientFactory) {
|
|
13956
13991
|
return __awaiter(this, void 0, void 0, function () {
|
|
13957
|
-
var
|
|
13992
|
+
var cachedPromise, newPromise;
|
|
13958
13993
|
return __generator(this, function (_a) {
|
|
13959
|
-
|
|
13994
|
+
cachedPromise = this.promises.get(clientId);
|
|
13995
|
+
|
|
13996
|
+
if (cachedPromise) {
|
|
13997
|
+
return [2
|
|
13998
|
+
/*return*/
|
|
13999
|
+
, cachedPromise];
|
|
14000
|
+
}
|
|
13960
14001
|
|
|
13961
|
-
if (
|
|
14002
|
+
if (clientFactory) {
|
|
14003
|
+
newPromise = clientFactory(clientId);
|
|
14004
|
+
this.promises.set(clientId, newPromise);
|
|
13962
14005
|
return [2
|
|
13963
14006
|
/*return*/
|
|
13964
|
-
,
|
|
14007
|
+
, newPromise];
|
|
13965
14008
|
}
|
|
13966
14009
|
|
|
13967
|
-
promise = clientFactory(clientId);
|
|
13968
|
-
this.promises.set(clientId, promise);
|
|
13969
14010
|
return [2
|
|
13970
14011
|
/*return*/
|
|
13971
|
-
,
|
|
14012
|
+
, undefined];
|
|
13972
14013
|
});
|
|
13973
14014
|
});
|
|
13974
14015
|
};
|
|
@@ -14060,6 +14101,10 @@ function (_super) {
|
|
|
14060
14101
|
}, args), null, 2));
|
|
14061
14102
|
var topicsToDelete_1 = [];
|
|
14062
14103
|
|
|
14104
|
+
if (!clientId) {
|
|
14105
|
+
return;
|
|
14106
|
+
}
|
|
14107
|
+
|
|
14063
14108
|
var clientIdObservers = this._clientIdObservers.get(clientId);
|
|
14064
14109
|
|
|
14065
14110
|
if (!clientIdObservers) {
|
|
@@ -14178,9 +14223,7 @@ function (_super) {
|
|
|
14178
14223
|
case 0:
|
|
14179
14224
|
return [4
|
|
14180
14225
|
/*yield*/
|
|
14181
|
-
, this.clientsQueue.get(clientId
|
|
14182
|
-
return null;
|
|
14183
|
-
})];
|
|
14226
|
+
, this.clientsQueue.get(clientId)];
|
|
14184
14227
|
|
|
14185
14228
|
case 1:
|
|
14186
14229
|
client = _a.sent();
|
|
@@ -14359,13 +14402,14 @@ function (_super) {
|
|
|
14359
14402
|
})();
|
|
14360
14403
|
|
|
14361
14404
|
return function () {
|
|
14405
|
+
var _a, _b;
|
|
14406
|
+
|
|
14362
14407
|
logger.debug('Unsubscribing from topic(s)', targetTopics.join(','));
|
|
14363
14408
|
|
|
14364
14409
|
if (client) {
|
|
14365
|
-
_this._clientIdObservers.get(clientId)["delete"](observer); // No more observers per client => client not needed anymore
|
|
14410
|
+
(_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
|
|
14366
14411
|
|
|
14367
|
-
|
|
14368
|
-
if (_this._clientIdObservers.get(clientId).size === 0) {
|
|
14412
|
+
if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
|
|
14369
14413
|
_this.disconnect(clientId);
|
|
14370
14414
|
|
|
14371
14415
|
_this._clientIdObservers["delete"](clientId);
|
|
@@ -14700,7 +14744,7 @@ function () {
|
|
|
14700
14744
|
* @param {PubSubOptions} options - Configuration object for PubSub
|
|
14701
14745
|
*/
|
|
14702
14746
|
function PubSubClass(options) {
|
|
14703
|
-
this._options = options;
|
|
14747
|
+
this._options = options !== null && options !== void 0 ? options : {};
|
|
14704
14748
|
logger.debug('PubSub Options', this._options);
|
|
14705
14749
|
this._pluggables = [];
|
|
14706
14750
|
this.subscribe = this.subscribe.bind(this);
|
|
@@ -14889,7 +14933,7 @@ function () {
|
|
|
14889
14933
|
}();
|
|
14890
14934
|
|
|
14891
14935
|
|
|
14892
|
-
var PubSub = new PubSubClass(
|
|
14936
|
+
var PubSub = new PubSubClass();
|
|
14893
14937
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
|
|
14894
14938
|
|
|
14895
14939
|
/***/ }),
|