aws-appsync-subscription-link 3.1.2 → 3.2.0-alpha.da776601
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 +11 -0
- package/__tests__/link/realtime-subscription-handshake-link-test.ts +559 -489
- package/jest.config.js +5 -1
- package/lib/index.js +5 -4
- package/lib/non-terminating-http-link.d.ts +2 -2
- package/lib/non-terminating-http-link.js +6 -5
- package/lib/non-terminating-link.d.ts +3 -3
- package/lib/non-terminating-link.js +7 -4
- package/lib/observable-compat.d.ts +1 -0
- package/lib/observable-compat.js +19 -0
- package/lib/realtime-subscription-handshake-link.d.ts +2 -2
- package/lib/realtime-subscription-handshake-link.js +43 -38
- package/lib/subscription-handshake-link.d.ts +1 -1
- package/lib/subscription-handshake-link.js +14 -13
- package/lib/types/index.d.ts +4 -4
- package/lib/types/index.js +1 -0
- package/lib/utils/apollo-compat.d.ts +4 -0
- package/lib/utils/apollo-compat.js +31 -0
- package/lib/utils/index.js +2 -1
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.js +11 -9
- package/lib/utils/retry.js +9 -5
- package/package.json +7 -5
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isApolloClientV4 = exports.Observable = void 0;
|
|
4
|
+
var core_1 = require("@apollo/client/core");
|
|
5
|
+
// Runtime detection of Apollo Client version
|
|
6
|
+
function detectApolloClientVersion() {
|
|
7
|
+
try {
|
|
8
|
+
// Try to access Apollo Client package.json to get version
|
|
9
|
+
var apolloClient = require('@apollo/client/package.json');
|
|
10
|
+
var version = apolloClient.version;
|
|
11
|
+
var majorVersion = parseInt(version.split('.')[0], 10);
|
|
12
|
+
return majorVersion;
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
// Fallback to checking if RxJS Observable is available
|
|
16
|
+
try {
|
|
17
|
+
require('rxjs');
|
|
18
|
+
return 4; // Assume v4 if RxJS is present
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
return 3; // Assume v3 if RxJS is not present
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Export a compatible Observable that works with both versions
|
|
26
|
+
exports.Observable = core_1.Observable;
|
|
27
|
+
// Utility function to check if we're running with Apollo Client v4
|
|
28
|
+
function isApolloClientV4() {
|
|
29
|
+
return detectApolloClientVersion() >= 4;
|
|
30
|
+
}
|
|
31
|
+
exports.isApolloClientV4 = isApolloClientV4;
|
package/lib/utils/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rootLogger = void 0;
|
|
3
4
|
/*!
|
|
4
5
|
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
6
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
7
|
*/
|
|
7
8
|
var logger_1 = require("./logger");
|
|
8
|
-
exports
|
|
9
|
+
Object.defineProperty(exports, "rootLogger", { enumerable: true, get: function () { return logger_1.default; } });
|
package/lib/utils/logger.d.ts
CHANGED
package/lib/utils/logger.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
10
|
};
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
var debug_1 = require("debug");
|
|
11
|
-
var debugLogger = debug_1.default('aws-appsync');
|
|
13
|
+
var debugLogger = (0, debug_1.default)('aws-appsync');
|
|
12
14
|
var extend = function (category) {
|
|
13
15
|
if (category === void 0) { category = ''; }
|
|
14
|
-
var newCategory = category ?
|
|
15
|
-
var result = debug_1.default(newCategory);
|
|
16
|
+
var newCategory = category ? __spreadArray(__spreadArray([], this.namespace.split(':'), true), [category], false).join(':') : this.namespace;
|
|
17
|
+
var result = (0, debug_1.default)(newCategory);
|
|
16
18
|
result.extend = extend.bind(result);
|
|
17
19
|
return result;
|
|
18
20
|
};
|
package/lib/utils/retry.js
CHANGED
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -27,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
27
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
30
|
function step(op) {
|
|
29
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
31
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
35
|
switch (op[0]) {
|
|
@@ -49,6 +51,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.jitteredExponentialRetry = exports.retry = exports.NonRetryableError = void 0;
|
|
52
55
|
var index_1 = require("./index");
|
|
53
56
|
var logger = index_1.rootLogger.extend("retry");
|
|
54
57
|
var MAX_DELAY_MS = 5000;
|
|
@@ -81,7 +84,7 @@ function retry(functionToRetry, args, delayFn, attempt) {
|
|
|
81
84
|
return __generator(this, function (_a) {
|
|
82
85
|
switch (_a.label) {
|
|
83
86
|
case 0:
|
|
84
|
-
logger("Attempt #"
|
|
87
|
+
logger("Attempt #".concat(attempt, " for this vars: ").concat(JSON.stringify(args)));
|
|
85
88
|
_a.label = 1;
|
|
86
89
|
case 1:
|
|
87
90
|
_a.trys.push([1, 3, , 8]);
|
|
@@ -91,7 +94,7 @@ function retry(functionToRetry, args, delayFn, attempt) {
|
|
|
91
94
|
return [3 /*break*/, 8];
|
|
92
95
|
case 3:
|
|
93
96
|
err_1 = _a.sent();
|
|
94
|
-
logger("error "
|
|
97
|
+
logger("error ".concat(err_1));
|
|
95
98
|
if (isNonRetryableError(err_1)) {
|
|
96
99
|
logger("non retryable error");
|
|
97
100
|
throw err_1;
|
|
@@ -124,7 +127,8 @@ function jitteredBackoff(maxDelayMs) {
|
|
|
124
127
|
* @private
|
|
125
128
|
* Internal use of Subscription link
|
|
126
129
|
*/
|
|
127
|
-
|
|
130
|
+
var jitteredExponentialRetry = function (functionToRetry, args, maxDelayMs) {
|
|
128
131
|
if (maxDelayMs === void 0) { maxDelayMs = MAX_DELAY_MS; }
|
|
129
132
|
return retry(functionToRetry, args, jitteredBackoff(maxDelayMs));
|
|
130
133
|
};
|
|
134
|
+
exports.jitteredExponentialRetry = jitteredExponentialRetry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-appsync-subscription-link",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-alpha.da776601",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "AWS Mobile AppSync SDK for JavaScript",
|
|
@@ -19,16 +19,18 @@
|
|
|
19
19
|
"test-watch": "jest --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"aws-appsync-auth-link": "^3.0.
|
|
22
|
+
"aws-appsync-auth-link": "^3.1.0-alpha.da776601",
|
|
23
23
|
"debug": "2.6.9",
|
|
24
24
|
"url": "^0.11.0",
|
|
25
25
|
"zen-observable-ts": "^1.2.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@apollo/client": "^
|
|
29
|
-
"@redux-offline/redux-offline": "2.5.2-native.0"
|
|
28
|
+
"@apollo/client": "^4.0.0",
|
|
29
|
+
"@redux-offline/redux-offline": "2.5.2-native.0",
|
|
30
|
+
"rxjs": "^7.0.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"@apollo/client": "
|
|
33
|
+
"@apollo/client": "4.x",
|
|
34
|
+
"rxjs": "^7.0.0"
|
|
33
35
|
}
|
|
34
36
|
}
|