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.
Files changed (62) hide show
  1. package/build/config.d.ts +42 -30
  2. package/build/config.js +11 -11
  3. package/build/index.d.ts +1 -0
  4. package/build/index.js +1 -1
  5. package/build/plugin/base.d.ts +1 -0
  6. package/build/plugin/base.js +3 -4
  7. package/build/plugin/context/context.interface.d.ts +1 -0
  8. package/build/plugin/event/event.interfaces.d.ts +1 -0
  9. package/build/plugin/panel.d.ts +1 -0
  10. package/build/plugin/panel.js +6 -7
  11. package/build/plugin/plugin.interfaces.d.ts +1 -0
  12. package/build/plugin/plugin.interfaces.js +4 -11
  13. package/build/plugin/ui-action.d.ts +1 -0
  14. package/build/plugin/ui-action.js +6 -7
  15. package/build/subscriptions/index.d.ts +1 -0
  16. package/build/subscriptions/providers/action-cable.d.ts +1 -0
  17. package/build/subscriptions/providers/action-cable.js +14 -34
  18. package/build/subscriptions/providers/app-sync.d.ts +3 -1
  19. package/build/subscriptions/providers/app-sync.js +29 -59
  20. package/build/subscriptions/providers/graphql-ws.d.ts +1 -0
  21. package/build/subscriptions/providers/graphql-ws.js +21 -56
  22. package/build/subscriptions/providers/ws.d.ts +1 -0
  23. package/build/subscriptions/providers/ws.js +19 -52
  24. package/build/subscriptions/subscription-provider.d.ts +1 -0
  25. package/build/subscriptions/subscription-provider.js +3 -4
  26. package/build/theme/defaults/dark.d.ts +1 -0
  27. package/build/theme/defaults/dark.js +2 -2
  28. package/build/theme/defaults/dracula.d.ts +1 -0
  29. package/build/theme/defaults/dracula.js +1 -1
  30. package/build/theme/defaults/light.d.ts +1 -0
  31. package/build/theme/defaults/light.js +1 -1
  32. package/build/theme/index.d.ts +4 -0
  33. package/build/theme/index.js +3 -3
  34. package/build/theme/theme.d.ts +3 -0
  35. package/build/theme/theme.js +42 -28
  36. package/build/types/shared.d.ts +1 -0
  37. package/build/types/state/collection.interfaces.d.ts +12 -3
  38. package/build/types/state/dialog.interfaces.d.ts +1 -0
  39. package/build/types/state/docs.interfaces.d.ts +1 -0
  40. package/build/types/state/donation.interfaces.d.ts +1 -0
  41. package/build/types/state/environments.interfaces.d.ts +1 -0
  42. package/build/types/state/gql-schema.interfaces.d.ts +1 -0
  43. package/build/types/state/header.interfaces.d.ts +1 -0
  44. package/build/types/state/history.interfaces.d.ts +1 -0
  45. package/build/types/state/layout.interfaces.d.ts +1 -0
  46. package/build/types/state/local.interfaces.d.ts +1 -0
  47. package/build/types/state/per-window.interfaces.d.ts +1 -0
  48. package/build/types/state/postrequest.interfaces.d.ts +1 -0
  49. package/build/types/state/prerequest.interfaces.d.ts +1 -0
  50. package/build/types/state/query.interfaces.d.ts +3 -1
  51. package/build/types/state/settings.interfaces.d.ts +9 -0
  52. package/build/types/state/settings.interfaces.js +2 -2
  53. package/build/types/state/state.interfaces.d.ts +1 -0
  54. package/build/types/state/stream.interfaces.d.ts +1 -0
  55. package/build/types/state/variable.interfaces.d.ts +1 -0
  56. package/build/types/state/window.interfaces.d.ts +3 -0
  57. package/build/types/state/windows-meta.interfaces.d.ts +1 -0
  58. package/build/utils/is_electron.d.ts +1 -0
  59. package/build/utils/logger.d.ts +1 -0
  60. package/build/utils/logger.js +9 -9
  61. package/package.json +4 -3
  62. 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 AltairConfigOptions {
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
- * URL to set as the subscription endpoint
13
- */
16
+ * URL to set as the subscription endpoint
17
+ */
14
18
  subscriptionsEndpoint?: string;
15
19
  /**
16
- * Initial query to be added
17
- */
20
+ * Initial query to be added
21
+ */
18
22
  initialQuery?: string;
19
23
  /**
20
- * Initial variables to be added
21
- */
24
+ * Initial variables to be added
25
+ */
22
26
  initialVariables?: string;
23
27
  /**
24
- * Initial pre-request script to be added
25
- */
28
+ * Initial pre-request script to be added
29
+ */
26
30
  initialPreRequestScript?: string;
27
31
  /**
28
- * Initial post-request script to be added
29
- */
32
+ * Initial post-request script to be added
33
+ */
30
34
  initialPostRequestScript?: string;
31
35
  /**
32
- * Initial headers object to be added
33
- * @example
34
- * {
35
- * 'X-GraphQL-Token': 'asd7-237s-2bdk-nsdk4'
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
- * HTTP method to use for making requests
94
+ * List of options for windows to be loaded
85
95
  */
86
- initialHttpMethod?: HttpVerb;
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
- var subscriptions_1 = require("./subscriptions");
8
- var is_electron_1 = __importDefault(require("./utils/is_electron"));
9
- var isTranslateMode = window.__ALTAIR_TRANSLATE__;
10
- var AltairConfig = /** @class */ (function () {
11
- function AltairConfig(_a) {
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
- return AltairConfig;
78
- }());
78
+ }
79
79
  exports.AltairConfig = AltairConfig;
80
- var config = new AltairConfig();
81
- exports.setAltairConfig = function (_config) {
80
+ let config = new AltairConfig();
81
+ exports.setAltairConfig = (_config) => {
82
82
  config = _config;
83
83
  };
84
- exports.getAltairConfig = function () {
84
+ exports.getAltairConfig = () => {
85
85
  return config;
86
86
  };
87
87
  window.getAltairConfig = exports.getAltairConfig;
package/build/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import { PluginBase, PluginConstructor } from './plugin/base';
2
2
  export declare const registerPluginClass: <T extends PluginBase>(pluginClassName: string, pluginClass: PluginConstructor<T>) => void;
3
+ //# sourceMappingURL=index.d.ts.map
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 = function (pluginClassName, pluginClass) {
4
+ exports.registerPluginClass = (pluginClassName, pluginClass) => {
5
5
  window['AltairGraphQL'].plugins[pluginClassName] = pluginClass;
6
6
  };
@@ -8,3 +8,4 @@ export declare abstract class PluginBase {
8
8
  export interface PluginConstructor<T extends PluginBase = PluginBase> {
9
9
  new (): T;
10
10
  }
11
+ //# sourceMappingURL=base.d.ts.map
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PluginBase = void 0;
4
- var PluginBase = /** @class */ (function () {
5
- function PluginBase(ctx) {
4
+ class PluginBase {
5
+ constructor(ctx) {
6
6
  this.ctx = ctx;
7
7
  }
8
- return PluginBase;
9
- }());
8
+ }
10
9
  exports.PluginBase = PluginBase;
@@ -75,3 +75,4 @@ export interface PluginContext {
75
75
  export interface PluginContextGenerator {
76
76
  createContext(pluginName: string, plugin: AltairPlugin): PluginContext;
77
77
  }
78
+ //# sourceMappingURL=context.interface.d.ts.map
@@ -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
@@ -15,3 +15,4 @@ export declare class AltairPanel {
15
15
  constructor(title: string, element: HTMLElement, location: AltairPanelLocation);
16
16
  destroy(): void;
17
17
  }
18
+ //# sourceMappingURL=panel.d.ts.map
@@ -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
- var uuid_1 = require("uuid");
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
- var AltairPanel = /** @class */ (function () {
15
- function AltairPanel(title, element, location) {
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
- AltairPanel.prototype.destroy = function () {
22
+ destroy() {
23
23
  this.element = null;
24
- };
25
- return AltairPanel;
26
- }());
24
+ }
25
+ }
27
26
  exports.AltairPanel = AltairPanel;
@@ -47,3 +47,4 @@ export interface AltairPlugin {
47
47
  manifest: PluginManifest;
48
48
  }
49
49
  export declare const createPlugin: (name: string, manifest: PluginManifest) => AltairPlugin;
50
+ //# sourceMappingURL=plugin.interfaces.d.ts.map
@@ -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 = function (name, manifest) {
24
+ exports.createPlugin = (name, manifest) => {
32
25
  return {
33
- name: name,
34
- manifest: 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(__spreadArrays((manifest.capabilities || []), ['query:read', 'query:write']))),
31
+ capabilities: Array.from(new Set([...(manifest.capabilities || []), ...['query:read', 'query:write']])),
39
32
  };
40
33
  };
@@ -9,3 +9,4 @@ export declare class AltairUiAction {
9
9
  constructor(title: string, location: AltairUiActionLocation, callback: () => void);
10
10
  execute(): void;
11
11
  }
12
+ //# sourceMappingURL=ui-action.d.ts.map
@@ -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
- var uuid_1 = require("uuid");
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
- var AltairUiAction = /** @class */ (function () {
10
- function AltairUiAction(title, location, callback) {
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
- AltairUiAction.prototype.execute = function () {
16
+ execute() {
17
17
  this.callback();
18
- };
19
- return AltairUiAction;
20
- }());
18
+ }
19
+ }
21
20
  exports.AltairUiAction = AltairUiAction;
@@ -15,3 +15,4 @@ export interface SubscriptionProviderData {
15
15
  getProviderClass: () => Promise<SubscriptionProviderConstructor>;
16
16
  copyTag?: string;
17
17
  }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -6,3 +6,4 @@ export declare class ActionCableSubscriptionProvider extends SubscriptionProvide
6
6
  execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
7
7
  close(): void;
8
8
  }
9
+ //# sourceMappingURL=action-cable.d.ts.map
@@ -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
- var subscription_provider_1 = require("../subscription-provider");
21
- var rxjs_1 = require("rxjs");
22
- var actioncable_1 = __importDefault(require("actioncable"));
23
- var ActionCableSubscriptionProvider = /** @class */ (function (_super) {
24
- __extends(ActionCableSubscriptionProvider, _super);
25
- function ActionCableSubscriptionProvider() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- ActionCableSubscriptionProvider.prototype.execute = function (options) {
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
- ActionCableSubscriptionProvider.prototype.close = function () {
51
- var _a;
52
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
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?: any;
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
- var subscription_provider_1 = require("../subscription-provider");
18
- var rxjs_1 = require("rxjs");
19
- var aws_appsync_auth_link_1 = require("aws-appsync-auth-link");
20
- var aws_appsync_subscription_link_1 = require("aws-appsync-subscription-link");
21
- var core_1 = require("@apollo/client/core");
22
- var graphql_1 = require("graphql");
23
- var AppSyncSubscriptionProvider = /** @class */ (function (_super) {
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
- AppSyncSubscriptionProvider.prototype.execute = function (options) {
39
- var _this = this;
40
- var url = this.connectionParams.aws_appsync_graphqlEndpoint;
41
- var region = this.connectionParams.aws_appsync_region;
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
- var link = core_1.ApolloLink.from([
48
- aws_appsync_auth_link_1.createAuthLink({ url: url, region: region, auth: auth }),
49
- aws_appsync_subscription_link_1.createSubscriptionHandshakeLink({ url: url, region: region, auth: auth }),
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
- var client = new core_1.ApolloClient({
52
- link: link,
33
+ const client = new core_1.ApolloClient({
34
+ link,
53
35
  cache: new core_1.InMemoryCache()
54
36
  });
55
- var subscription = client.subscribe({
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(function (subscriber) {
60
- _this.subscription = subscription.subscribe({
61
- next: function () {
62
- var args = [];
63
- for (var _i = 0; _i < arguments.length; _i++) {
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
- AppSyncSubscriptionProvider.prototype.close = function () {
80
- var _a;
81
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
82
- };
83
- return AppSyncSubscriptionProvider;
84
- }(subscription_provider_1.SubscriptionProvider));
48
+ }
49
+ close() {
50
+ if (this.subscription?.closed) {
51
+ this.subscription?.unsubscribe();
52
+ }
53
+ }
54
+ }
85
55
  exports.AppSyncSubscriptionProvider = AppSyncSubscriptionProvider;
@@ -7,3 +7,4 @@ export declare class GraphQLWsSubscriptionProvider extends SubscriptionProvider
7
7
  execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
8
8
  close(): void;
9
9
  }
10
+ //# sourceMappingURL=graphql-ws.d.ts.map
@@ -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
- var subscription_provider_1 = require("../subscription-provider");
18
- var rxjs_1 = require("rxjs");
19
- var graphql_ws_1 = require("graphql-ws");
20
- var GraphQLWsSubscriptionProvider = /** @class */ (function (_super) {
21
- __extends(GraphQLWsSubscriptionProvider, _super);
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: function () {
32
- var _a, _b;
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: function (err) {
36
- var _a, _b;
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
- GraphQLWsSubscriptionProvider.prototype.execute = function (options) {
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(function (subscriber) {
49
- return _this.client.subscribe({
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: function () {
55
- var args = [];
56
- for (var _i = 0; _i < arguments.length; _i++) {
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
- GraphQLWsSubscriptionProvider.prototype.close = function () {
73
- var _a;
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
- return GraphQLWsSubscriptionProvider;
78
- }(subscription_provider_1.SubscriptionProvider));
42
+ }
43
+ }
79
44
  exports.GraphQLWsSubscriptionProvider = GraphQLWsSubscriptionProvider;
@@ -7,3 +7,4 @@ export declare class WebsocketSubscriptionProvider extends SubscriptionProvider
7
7
  execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
8
8
  close(): void;
9
9
  }
10
+ //# sourceMappingURL=ws.d.ts.map