altair-graphql-core 4.0.11 → 4.3.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/build/config.d.ts +42 -30
- package/build/config.js +11 -11
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -1
- package/build/plugin/base.d.ts +1 -0
- package/build/plugin/base.js +3 -4
- package/build/plugin/context/context.interface.d.ts +1 -0
- package/build/plugin/event/event.interfaces.d.ts +1 -0
- package/build/plugin/panel.d.ts +1 -0
- package/build/plugin/panel.js +6 -7
- package/build/plugin/plugin.interfaces.d.ts +1 -0
- package/build/plugin/plugin.interfaces.js +4 -11
- package/build/plugin/ui-action.d.ts +1 -0
- package/build/plugin/ui-action.js +6 -7
- package/build/subscriptions/index.d.ts +1 -0
- package/build/subscriptions/providers/action-cable.d.ts +1 -0
- package/build/subscriptions/providers/action-cable.js +14 -34
- package/build/subscriptions/providers/app-sync.d.ts +3 -1
- package/build/subscriptions/providers/app-sync.js +29 -59
- package/build/subscriptions/providers/graphql-ws.d.ts +1 -0
- package/build/subscriptions/providers/graphql-ws.js +21 -56
- package/build/subscriptions/providers/ws.d.ts +1 -0
- package/build/subscriptions/providers/ws.js +19 -52
- package/build/subscriptions/subscription-provider.d.ts +1 -0
- package/build/subscriptions/subscription-provider.js +3 -4
- package/build/theme/defaults/dark.d.ts +1 -0
- package/build/theme/defaults/dark.js +2 -2
- package/build/theme/defaults/dracula.d.ts +1 -0
- package/build/theme/defaults/dracula.js +1 -1
- package/build/theme/defaults/light.d.ts +1 -0
- package/build/theme/defaults/light.js +1 -1
- package/build/theme/index.d.ts +4 -0
- package/build/theme/index.js +3 -3
- package/build/theme/theme.d.ts +3 -0
- package/build/theme/theme.js +42 -28
- package/build/types/shared.d.ts +1 -0
- package/build/types/state/collection.interfaces.d.ts +12 -3
- package/build/types/state/dialog.interfaces.d.ts +1 -0
- package/build/types/state/docs.interfaces.d.ts +1 -0
- package/build/types/state/donation.interfaces.d.ts +1 -0
- package/build/types/state/environments.interfaces.d.ts +1 -0
- package/build/types/state/gql-schema.interfaces.d.ts +1 -0
- package/build/types/state/header.interfaces.d.ts +1 -0
- package/build/types/state/history.interfaces.d.ts +1 -0
- package/build/types/state/layout.interfaces.d.ts +1 -0
- package/build/types/state/local.interfaces.d.ts +1 -0
- package/build/types/state/per-window.interfaces.d.ts +1 -0
- package/build/types/state/postrequest.interfaces.d.ts +1 -0
- package/build/types/state/prerequest.interfaces.d.ts +1 -0
- package/build/types/state/query.interfaces.d.ts +3 -1
- package/build/types/state/settings.interfaces.d.ts +9 -0
- package/build/types/state/settings.interfaces.js +2 -2
- package/build/types/state/state.interfaces.d.ts +1 -0
- package/build/types/state/stream.interfaces.d.ts +1 -0
- package/build/types/state/variable.interfaces.d.ts +1 -0
- package/build/types/state/window.interfaces.d.ts +3 -0
- package/build/types/state/windows-meta.interfaces.d.ts +1 -0
- package/build/utils/is_electron.d.ts +1 -0
- package/build/utils/logger.d.ts +1 -0
- package/build/utils/logger.js +9 -9
- package/package.json +4 -3
- package/tsconfig.json +2 -1
package/build/config.d.ts
CHANGED
|
@@ -3,39 +3,59 @@ import { IDictionary } from './types/shared';
|
|
|
3
3
|
import { IInitialEnvironments } from './types/state/environments.interfaces';
|
|
4
4
|
import { HttpVerb } from './types/state/query.interfaces';
|
|
5
5
|
import { SettingsState } from './types/state/settings.interfaces';
|
|
6
|
-
export interface
|
|
6
|
+
export interface AltairWindowOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Initial name of the window
|
|
9
|
+
*/
|
|
10
|
+
initialName?: string;
|
|
7
11
|
/**
|
|
8
12
|
* URL to set as the server endpoint
|
|
9
13
|
*/
|
|
10
14
|
endpointURL?: string;
|
|
11
15
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
* URL to set as the subscription endpoint
|
|
17
|
+
*/
|
|
14
18
|
subscriptionsEndpoint?: string;
|
|
15
19
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
* Initial query to be added
|
|
21
|
+
*/
|
|
18
22
|
initialQuery?: string;
|
|
19
23
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
* Initial variables to be added
|
|
25
|
+
*/
|
|
22
26
|
initialVariables?: string;
|
|
23
27
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
* Initial pre-request script to be added
|
|
29
|
+
*/
|
|
26
30
|
initialPreRequestScript?: string;
|
|
27
31
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
* Initial post-request script to be added
|
|
33
|
+
*/
|
|
30
34
|
initialPostRequestScript?: string;
|
|
31
35
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
* Initial headers object to be added
|
|
37
|
+
* @example
|
|
38
|
+
* {
|
|
39
|
+
* 'X-GraphQL-Token': 'asd7-237s-2bdk-nsdk4'
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
38
42
|
initialHeaders?: IDictionary;
|
|
43
|
+
/**
|
|
44
|
+
* Initial subscriptions provider
|
|
45
|
+
*
|
|
46
|
+
* @default "websocket"
|
|
47
|
+
*/
|
|
48
|
+
initialSubscriptionsProvider?: SubscriptionProviderIds;
|
|
49
|
+
/**
|
|
50
|
+
* Initial subscriptions connection params
|
|
51
|
+
*/
|
|
52
|
+
initialSubscriptionsPayload?: IDictionary;
|
|
53
|
+
/**
|
|
54
|
+
* HTTP method to use for making requests
|
|
55
|
+
*/
|
|
56
|
+
initialHttpMethod?: HttpVerb;
|
|
57
|
+
}
|
|
58
|
+
export interface AltairConfigOptions extends AltairWindowOptions {
|
|
39
59
|
/**
|
|
40
60
|
* Initial Environments to be added
|
|
41
61
|
* @example
|
|
@@ -64,16 +84,6 @@ export interface AltairConfigOptions {
|
|
|
64
84
|
* Initial app settings to use
|
|
65
85
|
*/
|
|
66
86
|
initialSettings?: Partial<SettingsState>;
|
|
67
|
-
/**
|
|
68
|
-
* Initial subscriptions provider
|
|
69
|
-
*
|
|
70
|
-
* @default "websocket"
|
|
71
|
-
*/
|
|
72
|
-
initialSubscriptionsProvider?: SubscriptionProviderIds;
|
|
73
|
-
/**
|
|
74
|
-
* Initial subscriptions connection params
|
|
75
|
-
*/
|
|
76
|
-
initialSubscriptionsPayload?: IDictionary;
|
|
77
87
|
/**
|
|
78
88
|
* Indicates if the state should be preserved for subsequent app loads
|
|
79
89
|
*
|
|
@@ -81,9 +91,9 @@ export interface AltairConfigOptions {
|
|
|
81
91
|
*/
|
|
82
92
|
preserveState?: boolean;
|
|
83
93
|
/**
|
|
84
|
-
*
|
|
94
|
+
* List of options for windows to be loaded
|
|
85
95
|
*/
|
|
86
|
-
|
|
96
|
+
initialWindows?: AltairWindowOptions[];
|
|
87
97
|
}
|
|
88
98
|
export declare class AltairConfig {
|
|
89
99
|
donation: {
|
|
@@ -133,8 +143,10 @@ export declare class AltairConfig {
|
|
|
133
143
|
initialSubscriptionsPayload: IDictionary<any>;
|
|
134
144
|
initialHttpMethod: "POST" | "GET" | "PUT" | "DELETE";
|
|
135
145
|
preserveState: boolean;
|
|
146
|
+
windows: AltairWindowOptions[];
|
|
136
147
|
};
|
|
137
|
-
constructor({ endpointURL, subscriptionsEndpoint, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, initialSubscriptionsProvider, initialSubscriptionsPayload, initialHttpMethod, preserveState, }?: AltairConfigOptions);
|
|
148
|
+
constructor({ endpointURL, subscriptionsEndpoint, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, initialSubscriptionsProvider, initialSubscriptionsPayload, initialHttpMethod, preserveState, initialWindows, }?: AltairConfigOptions);
|
|
138
149
|
}
|
|
139
150
|
export declare const setAltairConfig: (_config: AltairConfig) => void;
|
|
140
151
|
export declare const getAltairConfig: () => AltairConfig;
|
|
152
|
+
//# sourceMappingURL=config.d.ts.map
|
package/build/config.js
CHANGED
|
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAltairConfig = exports.setAltairConfig = exports.AltairConfig = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _b = _a === void 0 ? {} : _a, endpointURL = _b.endpointURL, subscriptionsEndpoint = _b.subscriptionsEndpoint, initialQuery = _b.initialQuery, initialHeaders = _b.initialHeaders, initialEnvironments = _b.initialEnvironments, initialVariables = _b.initialVariables, initialPreRequestScript = _b.initialPreRequestScript, _c = _b.initialPostRequestScript, initialPostRequestScript = _c === void 0 ? '' : _c, instanceStorageNamespace = _b.instanceStorageNamespace, initialSettings = _b.initialSettings, _d = _b.initialSubscriptionsProvider, initialSubscriptionsProvider = _d === void 0 ? subscriptions_1.WEBSOCKET_PROVIDER_ID : _d, _e = _b.initialSubscriptionsPayload, initialSubscriptionsPayload = _e === void 0 ? {} : _e, _f = _b.initialHttpMethod, initialHttpMethod = _f === void 0 ? 'POST' : _f, _g = _b.preserveState, preserveState = _g === void 0 ? true : _g;
|
|
7
|
+
const subscriptions_1 = require("./subscriptions");
|
|
8
|
+
const is_electron_1 = __importDefault(require("./utils/is_electron"));
|
|
9
|
+
const isTranslateMode = window.__ALTAIR_TRANSLATE__;
|
|
10
|
+
class AltairConfig {
|
|
11
|
+
constructor({ endpointURL, subscriptionsEndpoint, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript = '', instanceStorageNamespace, initialSettings, initialSubscriptionsProvider = subscriptions_1.WEBSOCKET_PROVIDER_ID, initialSubscriptionsPayload = {}, initialHttpMethod = 'POST', preserveState = true, initialWindows = [], } = {}) {
|
|
13
12
|
this.donation = {
|
|
14
13
|
url: 'https://opencollective.com/altair/donate',
|
|
15
14
|
action_count_threshold: 50
|
|
@@ -58,6 +57,7 @@ var AltairConfig = /** @class */ (function () {
|
|
|
58
57
|
initialSubscriptionsPayload: {},
|
|
59
58
|
initialHttpMethod: 'POST',
|
|
60
59
|
preserveState: true,
|
|
60
|
+
windows: [],
|
|
61
61
|
};
|
|
62
62
|
this.initialData.url = window.__ALTAIR_ENDPOINT_URL__ || endpointURL || '';
|
|
63
63
|
this.initialData.subscriptionsEndpoint = window.__ALTAIR_SUBSCRIPTIONS_ENDPOINT__ || subscriptionsEndpoint || '';
|
|
@@ -73,15 +73,15 @@ var AltairConfig = /** @class */ (function () {
|
|
|
73
73
|
this.initialData.initialSubscriptionsPayload = initialSubscriptionsPayload;
|
|
74
74
|
this.initialData.initialHttpMethod = initialHttpMethod;
|
|
75
75
|
this.initialData.preserveState = preserveState;
|
|
76
|
+
this.initialData.windows = initialWindows;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
}());
|
|
78
|
+
}
|
|
79
79
|
exports.AltairConfig = AltairConfig;
|
|
80
|
-
|
|
81
|
-
exports.setAltairConfig =
|
|
80
|
+
let config = new AltairConfig();
|
|
81
|
+
exports.setAltairConfig = (_config) => {
|
|
82
82
|
config = _config;
|
|
83
83
|
};
|
|
84
|
-
exports.getAltairConfig =
|
|
84
|
+
exports.getAltairConfig = () => {
|
|
85
85
|
return config;
|
|
86
86
|
};
|
|
87
87
|
window.getAltairConfig = exports.getAltairConfig;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerPluginClass = void 0;
|
|
4
|
-
exports.registerPluginClass =
|
|
4
|
+
exports.registerPluginClass = (pluginClassName, pluginClass) => {
|
|
5
5
|
window['AltairGraphQL'].plugins[pluginClassName] = pluginClass;
|
|
6
6
|
};
|
package/build/plugin/base.d.ts
CHANGED
package/build/plugin/base.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PluginBase = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class PluginBase {
|
|
5
|
+
constructor(ctx) {
|
|
6
6
|
this.ctx = ctx;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
}());
|
|
8
|
+
}
|
|
10
9
|
exports.PluginBase = PluginBase;
|
|
@@ -27,3 +27,4 @@ export interface PluginEventPayloadMap {
|
|
|
27
27
|
}
|
|
28
28
|
export declare type PluginEvent = keyof PluginEventPayloadMap;
|
|
29
29
|
export declare type PluginEventCallback<T extends PluginEvent> = (payload: PluginEventPayloadMap[T]) => void;
|
|
30
|
+
//# sourceMappingURL=event.interfaces.d.ts.map
|
package/build/plugin/panel.d.ts
CHANGED
package/build/plugin/panel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AltairPanel = exports.AltairPanelLocation = void 0;
|
|
4
|
-
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
var AltairPanelLocation;
|
|
6
6
|
(function (AltairPanelLocation) {
|
|
7
7
|
AltairPanelLocation["HEADER"] = "header";
|
|
@@ -11,17 +11,16 @@ var AltairPanelLocation;
|
|
|
11
11
|
/**
|
|
12
12
|
* Used for dynamic panel elements. Can also be used for angular components in the future.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
class AltairPanel {
|
|
15
|
+
constructor(title, element, location) {
|
|
16
16
|
this.title = title;
|
|
17
17
|
this.element = element;
|
|
18
18
|
this.location = location;
|
|
19
19
|
this.id = uuid_1.v4();
|
|
20
20
|
this.isActive = false;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
destroy() {
|
|
23
23
|
this.element = null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
27
26
|
exports.AltairPanel = AltairPanel;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
3
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
4
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
5
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
6
|
-
r[k] = a[j];
|
|
7
|
-
return r;
|
|
8
|
-
};
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.createPlugin = exports.PluginType = exports.PluginSource = void 0;
|
|
11
4
|
/**
|
|
@@ -28,13 +21,13 @@ var PluginType;
|
|
|
28
21
|
PluginType["SIDEBAR"] = "sidebar";
|
|
29
22
|
PluginType["ACTION_BUTTON"] = "action_button";
|
|
30
23
|
})(PluginType = exports.PluginType || (exports.PluginType = {}));
|
|
31
|
-
exports.createPlugin =
|
|
24
|
+
exports.createPlugin = (name, manifest) => {
|
|
32
25
|
return {
|
|
33
|
-
name
|
|
34
|
-
manifest
|
|
26
|
+
name,
|
|
27
|
+
manifest,
|
|
35
28
|
type: manifest.type,
|
|
36
29
|
display_name: manifest.display_name || name,
|
|
37
30
|
plugin_class: manifest.plugin_class,
|
|
38
|
-
capabilities: Array.from(new Set(
|
|
31
|
+
capabilities: Array.from(new Set([...(manifest.capabilities || []), ...['query:read', 'query:write']])),
|
|
39
32
|
};
|
|
40
33
|
};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AltairUiAction = exports.AltairUiActionLocation = void 0;
|
|
4
|
-
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
5
|
var AltairUiActionLocation;
|
|
6
6
|
(function (AltairUiActionLocation) {
|
|
7
7
|
AltairUiActionLocation["RESULT_PANE"] = "result_pane";
|
|
8
8
|
})(AltairUiActionLocation = exports.AltairUiActionLocation || (exports.AltairUiActionLocation = {}));
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
class AltairUiAction {
|
|
10
|
+
constructor(title, location, callback) {
|
|
11
11
|
this.title = title;
|
|
12
12
|
this.location = location;
|
|
13
13
|
this.callback = callback;
|
|
14
14
|
this.id = uuid_1.v4();
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
execute() {
|
|
17
17
|
this.callback();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
21
20
|
exports.AltairUiAction = AltairUiAction;
|
|
@@ -1,36 +1,18 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, 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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
4
|
};
|
|
18
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
6
|
exports.ActionCableSubscriptionProvider = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _this = this;
|
|
30
|
-
var cable = actioncable_1.default.createConsumer(this.subscriptionUrl);
|
|
31
|
-
return new rxjs_1.Observable(function (subscriber) {
|
|
32
|
-
_this.subscription = cable.subscriptions.create(Object.assign({}, {
|
|
33
|
-
channel: _this.connectionParams.channel || 'GraphqlChannel',
|
|
7
|
+
const subscription_provider_1 = require("../subscription-provider");
|
|
8
|
+
const rxjs_1 = require("rxjs");
|
|
9
|
+
const actioncable_1 = __importDefault(require("actioncable"));
|
|
10
|
+
class ActionCableSubscriptionProvider extends subscription_provider_1.SubscriptionProvider {
|
|
11
|
+
execute(options) {
|
|
12
|
+
const cable = actioncable_1.default.createConsumer(this.subscriptionUrl);
|
|
13
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
14
|
+
this.subscription = cable.subscriptions.create(Object.assign({}, {
|
|
15
|
+
channel: this.connectionParams.channel || 'GraphqlChannel',
|
|
34
16
|
channelId: Math.round(Date.now() + Math.random() * 100000).toString(16),
|
|
35
17
|
}, {}), {
|
|
36
18
|
connected: function () {
|
|
@@ -46,11 +28,9 @@ var ActionCableSubscriptionProvider = /** @class */ (function (_super) {
|
|
|
46
28
|
}
|
|
47
29
|
});
|
|
48
30
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return ActionCableSubscriptionProvider;
|
|
55
|
-
}(subscription_provider_1.SubscriptionProvider));
|
|
31
|
+
}
|
|
32
|
+
close() {
|
|
33
|
+
this.subscription?.unsubscribe();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
56
36
|
exports.ActionCableSubscriptionProvider = ActionCableSubscriptionProvider;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="zen-observable" />
|
|
1
2
|
import { SubscriptionProvider, SubscriptionProviderExecuteOptions } from '../subscription-provider';
|
|
2
3
|
import { Observable } from 'rxjs';
|
|
3
4
|
export declare class AppSyncSubscriptionProvider extends SubscriptionProvider {
|
|
4
|
-
subscription?:
|
|
5
|
+
subscription?: ZenObservable.Subscription;
|
|
5
6
|
/**
|
|
6
7
|
{
|
|
7
8
|
"aws_project_region": "us-west-2",
|
|
@@ -15,3 +16,4 @@ export declare class AppSyncSubscriptionProvider extends SubscriptionProvider {
|
|
|
15
16
|
execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
|
|
16
17
|
close(): void;
|
|
17
18
|
}
|
|
19
|
+
//# sourceMappingURL=app-sync.d.ts.map
|
|
@@ -1,30 +1,13 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.AppSyncSubscriptionProvider = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
__extends(AppSyncSubscriptionProvider, _super);
|
|
25
|
-
function AppSyncSubscriptionProvider() {
|
|
26
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
}
|
|
4
|
+
const subscription_provider_1 = require("../subscription-provider");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const aws_appsync_auth_link_1 = require("aws-appsync-auth-link");
|
|
7
|
+
const aws_appsync_subscription_link_1 = require("aws-appsync-subscription-link");
|
|
8
|
+
const core_1 = require("@apollo/client/core");
|
|
9
|
+
const graphql_1 = require("graphql");
|
|
10
|
+
class AppSyncSubscriptionProvider extends subscription_provider_1.SubscriptionProvider {
|
|
28
11
|
/**
|
|
29
12
|
{
|
|
30
13
|
"aws_project_region": "us-west-2",
|
|
@@ -35,51 +18,38 @@ var AppSyncSubscriptionProvider = /** @class */ (function (_super) {
|
|
|
35
18
|
"aws_appsync_jwtToken" "..."
|
|
36
19
|
}
|
|
37
20
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var auth = {
|
|
21
|
+
execute(options) {
|
|
22
|
+
const url = this.connectionParams.aws_appsync_graphqlEndpoint;
|
|
23
|
+
const region = this.connectionParams.aws_appsync_region;
|
|
24
|
+
const auth = {
|
|
43
25
|
type: this.connectionParams.aws_appsync_authenticationType,
|
|
44
26
|
apiKey: this.connectionParams.aws_appsync_apiKey,
|
|
45
27
|
jwtToken: this.connectionParams.aws_appsync_jwtToken,
|
|
46
28
|
};
|
|
47
|
-
|
|
48
|
-
aws_appsync_auth_link_1.createAuthLink({ url
|
|
49
|
-
aws_appsync_subscription_link_1.createSubscriptionHandshakeLink({ url
|
|
29
|
+
const link = core_1.ApolloLink.from([
|
|
30
|
+
aws_appsync_auth_link_1.createAuthLink({ url, region, auth }),
|
|
31
|
+
aws_appsync_subscription_link_1.createSubscriptionHandshakeLink({ url, region, auth }),
|
|
50
32
|
]);
|
|
51
|
-
|
|
52
|
-
link
|
|
33
|
+
const client = new core_1.ApolloClient({
|
|
34
|
+
link,
|
|
53
35
|
cache: new core_1.InMemoryCache()
|
|
54
36
|
});
|
|
55
|
-
|
|
37
|
+
const subscription = client.subscribe({
|
|
56
38
|
query: graphql_1.parse(options.query),
|
|
57
39
|
variables: options.variables
|
|
58
40
|
});
|
|
59
|
-
return new rxjs_1.Observable(
|
|
60
|
-
|
|
61
|
-
next:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
args[_i] = arguments[_i];
|
|
65
|
-
}
|
|
66
|
-
return subscriber.next.apply(subscriber, args);
|
|
67
|
-
},
|
|
68
|
-
error: function () {
|
|
69
|
-
var args = [];
|
|
70
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
71
|
-
args[_i] = arguments[_i];
|
|
72
|
-
}
|
|
73
|
-
return subscriber.error.apply(subscriber, args);
|
|
74
|
-
},
|
|
75
|
-
complete: function () { return subscriber.complete(); },
|
|
41
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
42
|
+
this.subscription = subscription.subscribe({
|
|
43
|
+
next: (...args) => subscriber.next(...args),
|
|
44
|
+
error: (...args) => subscriber.error(...args),
|
|
45
|
+
complete: () => subscriber.complete(),
|
|
76
46
|
});
|
|
77
47
|
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
48
|
+
}
|
|
49
|
+
close() {
|
|
50
|
+
if (this.subscription?.closed) {
|
|
51
|
+
this.subscription?.unsubscribe();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
85
55
|
exports.AppSyncSubscriptionProvider = AppSyncSubscriptionProvider;
|
|
@@ -1,79 +1,44 @@
|
|
|
1
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 (Object.prototype.hasOwnProperty.call(b, 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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.GraphQLWsSubscriptionProvider = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function GraphQLWsSubscriptionProvider() {
|
|
23
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
-
}
|
|
25
|
-
GraphQLWsSubscriptionProvider.prototype.createClient = function () {
|
|
26
|
-
var _this = this;
|
|
4
|
+
const subscription_provider_1 = require("../subscription-provider");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const graphql_ws_1 = require("graphql-ws");
|
|
7
|
+
class GraphQLWsSubscriptionProvider extends subscription_provider_1.SubscriptionProvider {
|
|
8
|
+
createClient() {
|
|
27
9
|
this.client = graphql_ws_1.createClient({
|
|
28
10
|
url: this.subscriptionUrl,
|
|
29
11
|
connectionParams: this.connectionParams,
|
|
30
12
|
on: {
|
|
31
|
-
connected:
|
|
32
|
-
|
|
33
|
-
(_b = (_a = _this.extraOptions) === null || _a === void 0 ? void 0 : _a.onConnected) === null || _b === void 0 ? void 0 : _b.call(_a, undefined, undefined);
|
|
13
|
+
connected: () => {
|
|
14
|
+
this.extraOptions?.onConnected?.(undefined, undefined);
|
|
34
15
|
},
|
|
35
|
-
error:
|
|
36
|
-
|
|
37
|
-
(_b = (_a = _this.extraOptions) === null || _a === void 0 ? void 0 : _a.onConnected) === null || _b === void 0 ? void 0 : _b.call(_a, err, undefined);
|
|
16
|
+
error: (err) => {
|
|
17
|
+
this.extraOptions?.onConnected?.(err, undefined);
|
|
38
18
|
}
|
|
39
19
|
}
|
|
40
20
|
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var _this = this;
|
|
21
|
+
}
|
|
22
|
+
execute(options) {
|
|
44
23
|
this.createClient();
|
|
45
24
|
if (!this.client) {
|
|
46
25
|
throw new Error('Could not create subscription client!');
|
|
47
26
|
}
|
|
48
|
-
return new rxjs_1.Observable(
|
|
49
|
-
return
|
|
27
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
28
|
+
return this.client.subscribe({
|
|
50
29
|
query: options.query,
|
|
51
30
|
variables: options.variables,
|
|
52
31
|
operationName: options.operationName,
|
|
53
32
|
}, {
|
|
54
|
-
next:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
args[_i] = arguments[_i];
|
|
58
|
-
}
|
|
59
|
-
return subscriber.next.apply(subscriber, args);
|
|
60
|
-
},
|
|
61
|
-
error: function () {
|
|
62
|
-
var args = [];
|
|
63
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
64
|
-
args[_i] = arguments[_i];
|
|
65
|
-
}
|
|
66
|
-
return subscriber.error.apply(subscriber, args);
|
|
67
|
-
},
|
|
68
|
-
complete: function () { return subscriber.complete(); },
|
|
33
|
+
next: (...args) => subscriber.next(...args),
|
|
34
|
+
error: (...args) => subscriber.error(...args),
|
|
35
|
+
complete: () => subscriber.complete(),
|
|
69
36
|
});
|
|
70
37
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(_a = this.client) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
this.client?.dispose();
|
|
75
41
|
this.client = undefined;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
}(subscription_provider_1.SubscriptionProvider));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
79
44
|
exports.GraphQLWsSubscriptionProvider = GraphQLWsSubscriptionProvider;
|