aws-appsync-subscription-link 3.1.3 → 4.0.0-next.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.
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "aws-appsync-subscription-link",
3
- "version": "3.1.3",
3
+ "version": "4.0.0-next.0",
4
4
  "main": "lib/index.js",
5
+ "module": "lib/index.mjs",
6
+ "types": "lib/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./lib/index.d.ts",
10
+ "import": "./lib/index.mjs",
11
+ "require": "./lib/index.js"
12
+ }
13
+ },
5
14
  "license": "Apache-2.0",
6
15
  "description": "AWS Mobile AppSync SDK for JavaScript",
7
16
  "author": {
@@ -14,21 +23,27 @@
14
23
  "url": "https://github.com/awslabs/aws-mobile-appsync-sdk-js.git"
15
24
  },
16
25
  "scripts": {
17
- "prepare": "tsc && cp -r src/vendor lib/vendor",
26
+ "build": "tsup",
27
+ "prepare": "npm run build",
28
+ "clean": "rm -rf lib",
18
29
  "test": "jest --coverage --coverageReporters=text",
19
30
  "test-watch": "jest --watch"
20
31
  },
21
32
  "dependencies": {
22
- "aws-appsync-auth-link": "^3.0.7",
33
+ "aws-appsync-auth-link": "^4.0.0-next.0",
23
34
  "debug": "2.6.9",
24
35
  "url": "^0.11.0",
36
+ "uuid": "^8.3.2",
25
37
  "zen-observable-ts": "^1.2.5"
26
38
  },
27
39
  "devDependencies": {
28
- "@apollo/client": "^3.2.0",
29
- "@redux-offline/redux-offline": "2.5.2-native.0"
40
+ "@apollo/client": "^4.0.0",
41
+ "@redux-offline/redux-offline": "2.5.2-native.0",
42
+ "@types/uuid": "^8.3.4",
43
+ "rxjs": "^7.0.0"
30
44
  },
31
45
  "peerDependencies": {
32
- "@apollo/client": "3.x"
46
+ "@apollo/client": "4.x",
47
+ "rxjs": "^7.0.0"
33
48
  }
34
49
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["cjs", "esm"],
6
+ dts: true,
7
+ clean: true,
8
+ outDir: "lib",
9
+ external: [
10
+ "@apollo/client",
11
+ "@redux-offline/redux-offline",
12
+ "aws-appsync-auth-link",
13
+ "debug",
14
+ "rxjs",
15
+ "url",
16
+ "zen-observable-ts",
17
+ ],
18
+ onSuccess: "cp -r src/vendor lib/vendor",
19
+ });
@@ -1,9 +0,0 @@
1
- /*!
2
- * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { HttpOptions } from '@apollo/client/link/http';
6
- import { NonTerminatingLink } from './non-terminating-link';
7
- export declare class NonTerminatingHttpLink extends NonTerminatingLink {
8
- constructor(contextKey: string, options: HttpOptions);
9
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- /*!
17
- * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
- * SPDX-License-Identifier: Apache-2.0
19
- */
20
- var http_1 = require("@apollo/client/link/http");
21
- var non_terminating_link_1 = require("./non-terminating-link");
22
- var NonTerminatingHttpLink = /** @class */ (function (_super) {
23
- __extends(NonTerminatingHttpLink, _super);
24
- function NonTerminatingHttpLink(contextKey, options) {
25
- var _this = this;
26
- var link = http_1.createHttpLink(options);
27
- _this = _super.call(this, contextKey, { link: link }) || this;
28
- return _this;
29
- }
30
- return NonTerminatingHttpLink;
31
- }(non_terminating_link_1.NonTerminatingLink));
32
- exports.NonTerminatingHttpLink = NonTerminatingHttpLink;
@@ -1,15 +0,0 @@
1
- /*!
2
- * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { ApolloLink } from '@apollo/client/core';
6
- import type { NextLink, FetchResult } from '@apollo/client/core';
7
- import type { Observable } from 'zen-observable-ts';
8
- export declare class NonTerminatingLink extends ApolloLink {
9
- private contextKey;
10
- private link;
11
- constructor(contextKey: string, { link }: {
12
- link: ApolloLink;
13
- });
14
- request(operation: any, forward?: NextLink): Observable<FetchResult>;
15
- }
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
- return new (P || (P = Promise))(function (resolve, reject) {
29
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
- step((generator = generator.apply(thisArg, _arguments || [])).next());
33
- });
34
- };
35
- var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
- function verb(n) { return function (v) { return step([n, v]); }; }
39
- function step(op) {
40
- if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
42
- 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;
43
- if (y = 0, t) op = [op[0] & 2, t.value];
44
- switch (op[0]) {
45
- case 0: case 1: t = op; break;
46
- case 4: _.label++; return { value: op[1], done: false };
47
- case 5: _.label++; y = op[1]; op = [0]; continue;
48
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
- default:
50
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
- if (t[2]) _.ops.pop();
55
- _.trys.pop(); continue;
56
- }
57
- op = body.call(thisArg, _);
58
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
- }
61
- };
62
- Object.defineProperty(exports, "__esModule", { value: true });
63
- /*!
64
- * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
65
- * SPDX-License-Identifier: Apache-2.0
66
- */
67
- var core_1 = require("@apollo/client/core");
68
- var context_1 = require("@apollo/client/link/context");
69
- var NonTerminatingLink = /** @class */ (function (_super) {
70
- __extends(NonTerminatingLink, _super);
71
- function NonTerminatingLink(contextKey, _a) {
72
- var link = _a.link;
73
- var _this = _super.call(this) || this;
74
- _this.contextKey = contextKey;
75
- _this.link = link;
76
- return _this;
77
- }
78
- NonTerminatingLink.prototype.request = function (operation, forward) {
79
- var _this = this;
80
- return (context_1.setContext(function (_request, prevContext) { return __awaiter(_this, void 0, void 0, function () {
81
- var result;
82
- var _a;
83
- var _this = this;
84
- return __generator(this, function (_b) {
85
- switch (_b.label) {
86
- case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
87
- _this.link.request(operation).subscribe({
88
- next: resolve,
89
- error: reject,
90
- });
91
- })];
92
- case 1:
93
- result = _b.sent();
94
- return [2 /*return*/, __assign(__assign({}, prevContext), (_a = {}, _a[this.contextKey] = result, _a))];
95
- }
96
- });
97
- }); })).request(operation, forward);
98
- };
99
- return NonTerminatingLink;
100
- }(core_1.ApolloLink));
101
- exports.NonTerminatingLink = NonTerminatingLink;
@@ -1,37 +0,0 @@
1
- /*!
2
- * Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
- import { ApolloLink, Observable, Operation, FetchResult } from "@apollo/client/core";
6
- import { AppSyncRealTimeSubscriptionConfig } from "./types";
7
- export declare const CONTROL_EVENTS_KEY = "@@controlEvents";
8
- export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
9
- private url;
10
- private region;
11
- private auth;
12
- private awsRealTimeSocket;
13
- private socketStatus;
14
- private keepAliveTimeoutId;
15
- private keepAliveTimeout?;
16
- private subscriptionObserverMap;
17
- private promiseArray;
18
- constructor({ url: theUrl, region: theRegion, auth: theAuth, keepAliveTimeoutMs }: AppSyncRealTimeSubscriptionConfig);
19
- private isCustomDomain;
20
- request(operation: Operation): Observable<FetchResult<Record<string, any>, Record<string, any>, Record<string, any>>>;
21
- private _verifySubscriptionAlreadyStarted;
22
- private _sendUnsubscriptionMessage;
23
- private _removeSubscriptionObserver;
24
- private _closeSocketIfRequired;
25
- private _startSubscriptionWithAWSAppSyncRealTime;
26
- private _initializeWebSocketConnection;
27
- private _awsRealTimeHeaderBasedAuth;
28
- private _awsRealTimeAuthorizationHeader;
29
- private _awsRealTimeApiKeyHeader;
30
- private _awsRealTimeIAMHeader;
31
- private _initializeRetryableHandshake;
32
- private _initializeHandshake;
33
- private _handleIncomingSubscriptionMessage;
34
- private _errorDisconnect;
35
- private _timeoutStartSubscriptionAck;
36
- static createWebSocket(awsRealTimeUrl: string, protocol: string): WebSocket;
37
- }