altair-graphql-core 4.0.10
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/LICENSE +21 -0
- package/README.md +1 -0
- package/build/config.d.ts +140 -0
- package/build/config.js +87 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +6 -0
- package/build/plugin/base.d.ts +10 -0
- package/build/plugin/base.js +10 -0
- package/build/plugin/context/context.interface.d.ts +77 -0
- package/build/plugin/context/context.interface.js +2 -0
- package/build/plugin/event/event.interfaces.d.ts +29 -0
- package/build/plugin/event/event.interfaces.js +3 -0
- package/build/plugin/panel.d.ts +17 -0
- package/build/plugin/panel.js +27 -0
- package/build/plugin/plugin.interfaces.d.ts +49 -0
- package/build/plugin/plugin.interfaces.js +40 -0
- package/build/plugin/ui-action.d.ts +11 -0
- package/build/plugin/ui-action.js +21 -0
- package/build/subscriptions/index.d.ts +17 -0
- package/build/subscriptions/index.js +13 -0
- package/build/subscriptions/providers/action-cable.d.ts +8 -0
- package/build/subscriptions/providers/action-cable.js +56 -0
- package/build/subscriptions/providers/app-sync.d.ts +17 -0
- package/build/subscriptions/providers/app-sync.js +85 -0
- package/build/subscriptions/providers/graphql-ws.d.ts +9 -0
- package/build/subscriptions/providers/graphql-ws.js +79 -0
- package/build/subscriptions/providers/ws.d.ts +9 -0
- package/build/subscriptions/providers/ws.js +71 -0
- package/build/subscriptions/subscription-provider.d.ts +19 -0
- package/build/subscriptions/subscription-provider.js +12 -0
- package/build/theme/defaults/dark.d.ts +3 -0
- package/build/theme/defaults/dark.js +33 -0
- package/build/theme/defaults/dracula.d.ts +3 -0
- package/build/theme/defaults/dracula.js +28 -0
- package/build/theme/defaults/light.d.ts +3 -0
- package/build/theme/defaults/light.js +4 -0
- package/build/theme/index.d.ts +187 -0
- package/build/theme/index.js +23 -0
- package/build/theme/theme.d.ts +102 -0
- package/build/theme/theme.js +124 -0
- package/build/types/shared.d.ts +5 -0
- package/build/types/shared.js +2 -0
- package/build/types/state/collection.interfaces.d.ts +25 -0
- package/build/types/state/collection.interfaces.js +2 -0
- package/build/types/state/dialog.interfaces.d.ts +8 -0
- package/build/types/state/dialog.interfaces.js +2 -0
- package/build/types/state/docs.interfaces.d.ts +19 -0
- package/build/types/state/docs.interfaces.js +2 -0
- package/build/types/state/donation.interfaces.d.ts +3 -0
- package/build/types/state/donation.interfaces.js +2 -0
- package/build/types/state/environments.interfaces.d.ts +21 -0
- package/build/types/state/environments.interfaces.js +3 -0
- package/build/types/state/gql-schema.interfaces.d.ts +8 -0
- package/build/types/state/gql-schema.interfaces.js +2 -0
- package/build/types/state/header.interfaces.d.ts +6 -0
- package/build/types/state/header.interfaces.js +2 -0
- package/build/types/state/history.interfaces.d.ts +6 -0
- package/build/types/state/history.interfaces.js +2 -0
- package/build/types/state/layout.interfaces.d.ts +7 -0
- package/build/types/state/layout.interfaces.js +2 -0
- package/build/types/state/local.interfaces.d.ts +18 -0
- package/build/types/state/local.interfaces.js +2 -0
- package/build/types/state/per-window.interfaces.d.ts +25 -0
- package/build/types/state/per-window.interfaces.js +2 -0
- package/build/types/state/postrequest.interfaces.d.ts +4 -0
- package/build/types/state/postrequest.interfaces.js +2 -0
- package/build/types/state/prerequest.interfaces.d.ts +4 -0
- package/build/types/state/prerequest.interfaces.js +2 -0
- package/build/types/state/query.interfaces.d.ts +41 -0
- package/build/types/state/query.interfaces.js +4 -0
- package/build/types/state/settings.interfaces.d.ts +80 -0
- package/build/types/state/settings.interfaces.js +4 -0
- package/build/types/state/state.interfaces.d.ts +16 -0
- package/build/types/state/state.interfaces.js +2 -0
- package/build/types/state/stream.interfaces.d.ts +7 -0
- package/build/types/state/stream.interfaces.js +2 -0
- package/build/types/state/variable.interfaces.d.ts +10 -0
- package/build/types/state/variable.interfaces.js +2 -0
- package/build/types/state/window.interfaces.d.ts +35 -0
- package/build/types/state/window.interfaces.js +2 -0
- package/build/types/state/windows-meta.interfaces.d.ts +9 -0
- package/build/types/state/windows-meta.interfaces.js +2 -0
- package/build/utils/is_electron.d.ts +2 -0
- package/build/utils/is_electron.js +3 -0
- package/build/utils/logger.d.ts +5 -0
- package/build/utils/logger.js +45 -0
- package/package.json +64 -0
- package/tsconfig.json +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [year] [fullname]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# altair-graphql-core
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { SubscriptionProviderIds } from './subscriptions';
|
|
2
|
+
import { IDictionary } from './types/shared';
|
|
3
|
+
import { IInitialEnvironments } from './types/state/environments.interfaces';
|
|
4
|
+
import { HttpVerb } from './types/state/query.interfaces';
|
|
5
|
+
import { SettingsState } from './types/state/settings.interfaces';
|
|
6
|
+
export interface AltairConfigOptions {
|
|
7
|
+
/**
|
|
8
|
+
* URL to set as the server endpoint
|
|
9
|
+
*/
|
|
10
|
+
endpointURL?: string;
|
|
11
|
+
/**
|
|
12
|
+
* URL to set as the subscription endpoint
|
|
13
|
+
*/
|
|
14
|
+
subscriptionsEndpoint?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Initial query to be added
|
|
17
|
+
*/
|
|
18
|
+
initialQuery?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Initial variables to be added
|
|
21
|
+
*/
|
|
22
|
+
initialVariables?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Initial pre-request script to be added
|
|
25
|
+
*/
|
|
26
|
+
initialPreRequestScript?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Initial post-request script to be added
|
|
29
|
+
*/
|
|
30
|
+
initialPostRequestScript?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Initial headers object to be added
|
|
33
|
+
* @example
|
|
34
|
+
* {
|
|
35
|
+
* 'X-GraphQL-Token': 'asd7-237s-2bdk-nsdk4'
|
|
36
|
+
* }
|
|
37
|
+
*/
|
|
38
|
+
initialHeaders?: IDictionary;
|
|
39
|
+
/**
|
|
40
|
+
* Initial Environments to be added
|
|
41
|
+
* @example
|
|
42
|
+
* {
|
|
43
|
+
* base: {
|
|
44
|
+
* title: 'Environment',
|
|
45
|
+
* variables: {}
|
|
46
|
+
* },
|
|
47
|
+
* subEnvironments: [
|
|
48
|
+
* {
|
|
49
|
+
* title: 'sub-1',
|
|
50
|
+
* variables: {}
|
|
51
|
+
* }
|
|
52
|
+
* ]
|
|
53
|
+
* }
|
|
54
|
+
*/
|
|
55
|
+
initialEnvironments?: IInitialEnvironments;
|
|
56
|
+
/**
|
|
57
|
+
* Namespace for storing the data for the altair instance.
|
|
58
|
+
* Use this when you have multiple altair instances running on the same domain.
|
|
59
|
+
* @example
|
|
60
|
+
* instanceStorageNamespace: 'altair_dev_'
|
|
61
|
+
*/
|
|
62
|
+
instanceStorageNamespace?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Initial app settings to use
|
|
65
|
+
*/
|
|
66
|
+
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
|
+
/**
|
|
78
|
+
* Indicates if the state should be preserved for subsequent app loads
|
|
79
|
+
*
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
preserveState?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* HTTP method to use for making requests
|
|
85
|
+
*/
|
|
86
|
+
initialHttpMethod?: HttpVerb;
|
|
87
|
+
}
|
|
88
|
+
export declare class AltairConfig {
|
|
89
|
+
donation: {
|
|
90
|
+
url: string;
|
|
91
|
+
action_count_threshold: number;
|
|
92
|
+
};
|
|
93
|
+
ga: string;
|
|
94
|
+
add_query_depth_limit: number;
|
|
95
|
+
tab_size: number;
|
|
96
|
+
max_windows: number;
|
|
97
|
+
default_language: string;
|
|
98
|
+
languages: {
|
|
99
|
+
'en-US': string;
|
|
100
|
+
'fr-FR': string;
|
|
101
|
+
'es-ES': string;
|
|
102
|
+
'cs-CZ': string;
|
|
103
|
+
'de-DE': string;
|
|
104
|
+
'pt-BR': string;
|
|
105
|
+
'ru-RU': string;
|
|
106
|
+
'uk-UA': string;
|
|
107
|
+
'zh-CN': string;
|
|
108
|
+
'ja-JP': string;
|
|
109
|
+
'sr-SP': string;
|
|
110
|
+
'it-IT': string;
|
|
111
|
+
'pl-PL': string;
|
|
112
|
+
'ko-KR': string;
|
|
113
|
+
'ro-RO': string;
|
|
114
|
+
'vi-VN': string;
|
|
115
|
+
};
|
|
116
|
+
query_history_depth: number;
|
|
117
|
+
defaultTheme: string;
|
|
118
|
+
themes: string[];
|
|
119
|
+
isTranslateMode: any;
|
|
120
|
+
isWebApp: any;
|
|
121
|
+
initialData: {
|
|
122
|
+
url: string;
|
|
123
|
+
subscriptionsEndpoint: string;
|
|
124
|
+
query: string;
|
|
125
|
+
variables: string;
|
|
126
|
+
headers: IDictionary<any>;
|
|
127
|
+
environments: IInitialEnvironments;
|
|
128
|
+
preRequestScript: string;
|
|
129
|
+
postRequestScript: string;
|
|
130
|
+
instanceStorageNamespace: string;
|
|
131
|
+
settings: Partial<SettingsState>;
|
|
132
|
+
initialSubscriptionsProvider: SubscriptionProviderIds;
|
|
133
|
+
initialSubscriptionsPayload: IDictionary<any>;
|
|
134
|
+
initialHttpMethod: "POST" | "GET" | "PUT" | "DELETE";
|
|
135
|
+
preserveState: boolean;
|
|
136
|
+
};
|
|
137
|
+
constructor({ endpointURL, subscriptionsEndpoint, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, initialSubscriptionsProvider, initialSubscriptionsPayload, initialHttpMethod, preserveState, }?: AltairConfigOptions);
|
|
138
|
+
}
|
|
139
|
+
export declare const setAltairConfig: (_config: AltairConfig) => void;
|
|
140
|
+
export declare const getAltairConfig: () => AltairConfig;
|
package/build/config.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
13
|
+
this.donation = {
|
|
14
|
+
url: 'https://opencollective.com/altair/donate',
|
|
15
|
+
action_count_threshold: 50
|
|
16
|
+
};
|
|
17
|
+
this.ga = 'UA-41432833-6';
|
|
18
|
+
this.add_query_depth_limit = 3;
|
|
19
|
+
this.tab_size = 2;
|
|
20
|
+
this.max_windows = is_electron_1.default ? 50 : 15;
|
|
21
|
+
this.default_language = isTranslateMode ? 'ach-UG' : 'en-US';
|
|
22
|
+
this.languages = {
|
|
23
|
+
'en-US': 'English',
|
|
24
|
+
'fr-FR': 'French',
|
|
25
|
+
'es-ES': 'Español',
|
|
26
|
+
'cs-CZ': 'Czech',
|
|
27
|
+
'de-DE': 'German',
|
|
28
|
+
'pt-BR': 'Brazilian',
|
|
29
|
+
'ru-RU': 'Russian',
|
|
30
|
+
'uk-UA': 'Ukrainian',
|
|
31
|
+
'zh-CN': 'Chinese Simplified',
|
|
32
|
+
'ja-JP': 'Japanese',
|
|
33
|
+
'sr-SP': 'Serbian',
|
|
34
|
+
'it-IT': 'Italian',
|
|
35
|
+
'pl-PL': 'Polish',
|
|
36
|
+
'ko-KR': 'Korean',
|
|
37
|
+
'ro-RO': 'Romanian',
|
|
38
|
+
'vi-VN': 'Vietnamese',
|
|
39
|
+
};
|
|
40
|
+
this.query_history_depth = is_electron_1.default ? 100 : 15;
|
|
41
|
+
this.defaultTheme = 'system';
|
|
42
|
+
this.themes = ['light', 'dark', 'dracula', 'system'];
|
|
43
|
+
this.isTranslateMode = isTranslateMode;
|
|
44
|
+
this.isWebApp = window.__ALTAIR_WEB_APP__;
|
|
45
|
+
this.initialData = {
|
|
46
|
+
url: '',
|
|
47
|
+
subscriptionsEndpoint: '',
|
|
48
|
+
query: '',
|
|
49
|
+
variables: '',
|
|
50
|
+
// Force type of header, since initial value inference is wrong
|
|
51
|
+
headers: null,
|
|
52
|
+
environments: {},
|
|
53
|
+
preRequestScript: '',
|
|
54
|
+
postRequestScript: '',
|
|
55
|
+
instanceStorageNamespace: 'altair_',
|
|
56
|
+
settings: undefined,
|
|
57
|
+
initialSubscriptionsProvider: undefined,
|
|
58
|
+
initialSubscriptionsPayload: {},
|
|
59
|
+
initialHttpMethod: 'POST',
|
|
60
|
+
preserveState: true,
|
|
61
|
+
};
|
|
62
|
+
this.initialData.url = window.__ALTAIR_ENDPOINT_URL__ || endpointURL || '';
|
|
63
|
+
this.initialData.subscriptionsEndpoint = window.__ALTAIR_SUBSCRIPTIONS_ENDPOINT__ || subscriptionsEndpoint || '';
|
|
64
|
+
this.initialData.query = window.__ALTAIR_INITIAL_QUERY__ || initialQuery || '';
|
|
65
|
+
this.initialData.variables = window.__ALTAIR_INITIAL_VARIABLES__ || initialVariables || '';
|
|
66
|
+
this.initialData.headers = window.__ALTAIR_INITIAL_HEADERS__ || initialHeaders || '';
|
|
67
|
+
this.initialData.environments = initialEnvironments || {};
|
|
68
|
+
this.initialData.preRequestScript = window.__ALTAIR_INITIAL_PRE_REQUEST_SCRIPT__ || initialPreRequestScript || '';
|
|
69
|
+
this.initialData.postRequestScript = initialPostRequestScript;
|
|
70
|
+
this.initialData.instanceStorageNamespace = window.__ALTAIR_INSTANCE_STORAGE_NAMESPACE__ || instanceStorageNamespace || 'altair_';
|
|
71
|
+
this.initialData.settings = initialSettings;
|
|
72
|
+
this.initialData.initialSubscriptionsProvider = initialSubscriptionsProvider;
|
|
73
|
+
this.initialData.initialSubscriptionsPayload = initialSubscriptionsPayload;
|
|
74
|
+
this.initialData.initialHttpMethod = initialHttpMethod;
|
|
75
|
+
this.initialData.preserveState = preserveState;
|
|
76
|
+
}
|
|
77
|
+
return AltairConfig;
|
|
78
|
+
}());
|
|
79
|
+
exports.AltairConfig = AltairConfig;
|
|
80
|
+
var config = new AltairConfig();
|
|
81
|
+
exports.setAltairConfig = function (_config) {
|
|
82
|
+
config = _config;
|
|
83
|
+
};
|
|
84
|
+
exports.getAltairConfig = function () {
|
|
85
|
+
return config;
|
|
86
|
+
};
|
|
87
|
+
window.getAltairConfig = exports.getAltairConfig;
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluginContext } from './context/context.interface';
|
|
2
|
+
export declare abstract class PluginBase {
|
|
3
|
+
protected ctx: PluginContext;
|
|
4
|
+
constructor(ctx: PluginContext);
|
|
5
|
+
abstract initialize(ctx: PluginContext): void;
|
|
6
|
+
abstract destroy(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginConstructor<T extends PluginBase = PluginBase> {
|
|
9
|
+
new (): T;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginBase = void 0;
|
|
4
|
+
var PluginBase = /** @class */ (function () {
|
|
5
|
+
function PluginBase(ctx) {
|
|
6
|
+
this.ctx = ctx;
|
|
7
|
+
}
|
|
8
|
+
return PluginBase;
|
|
9
|
+
}());
|
|
10
|
+
exports.PluginBase = PluginBase;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SubscriptionProviderData } from '../../subscriptions';
|
|
2
|
+
import { ICustomTheme } from '../../theme';
|
|
3
|
+
import { ExportWindowState } from '../../types/state/window.interfaces';
|
|
4
|
+
import { PluginEvent, PluginEventCallback } from '../event/event.interfaces';
|
|
5
|
+
import { AltairPanel, AltairPanelLocation } from '../panel';
|
|
6
|
+
import { AltairPlugin } from '../plugin.interfaces';
|
|
7
|
+
import { AltairUiAction, AltairUiActionLocation } from '../ui-action';
|
|
8
|
+
export interface CreatePanelOptions {
|
|
9
|
+
title?: string;
|
|
10
|
+
location?: AltairPanelLocation;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateActionOptions {
|
|
13
|
+
title: string;
|
|
14
|
+
location?: AltairUiActionLocation;
|
|
15
|
+
execute: (data: PluginWindowState) => void;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginWindowState extends ExportWindowState {
|
|
18
|
+
windowId: string;
|
|
19
|
+
sdl: string;
|
|
20
|
+
queryResult: string;
|
|
21
|
+
requestStartTime: number;
|
|
22
|
+
requestEndTime: number;
|
|
23
|
+
responseTime: number;
|
|
24
|
+
responseStatus: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PluginContext {
|
|
27
|
+
app: {
|
|
28
|
+
/**
|
|
29
|
+
* Returns an allowed set of data from the state visible to plugins
|
|
30
|
+
*
|
|
31
|
+
* Since it is a method, the state can be generated when called.
|
|
32
|
+
* So we can ensure uniqueness of the state, as well as avoid passing values by references.
|
|
33
|
+
*/
|
|
34
|
+
getWindowState(windowId: string): Promise<PluginWindowState>;
|
|
35
|
+
getCurrentWindowState(): Promise<PluginWindowState>;
|
|
36
|
+
/**
|
|
37
|
+
* panel has two locations: sidebar, header
|
|
38
|
+
*
|
|
39
|
+
* Each call creates a new panel. Instead, plugin should create panel only once (@initialize)
|
|
40
|
+
* Panel can be destroyed when the plugin is unused.
|
|
41
|
+
*
|
|
42
|
+
* returns panel instance (includes destroy() method)
|
|
43
|
+
*/
|
|
44
|
+
createPanel(element: HTMLElement, options?: CreatePanelOptions): AltairPanel;
|
|
45
|
+
destroyPanel(panel: AltairPanel): void;
|
|
46
|
+
/**
|
|
47
|
+
* action has 1 location for now: resultpane
|
|
48
|
+
*
|
|
49
|
+
* Each call creates a new action. Instead, plugins should create action once, when needed
|
|
50
|
+
* Action can be destroyed when the plugin decides to.
|
|
51
|
+
*
|
|
52
|
+
* returns action instance (includes destroy() method)
|
|
53
|
+
*/
|
|
54
|
+
createAction(options: CreateActionOptions): AltairUiAction;
|
|
55
|
+
destroyAction(uiAction: AltairUiAction): void;
|
|
56
|
+
isElectron(): boolean;
|
|
57
|
+
createWindow(data: ExportWindowState): void;
|
|
58
|
+
setQuery(windowId: string, query: string): void;
|
|
59
|
+
setVariables(windowId: string, variables: string): void;
|
|
60
|
+
setEndpoint(windowId: string, url: string): void;
|
|
61
|
+
addSubscriptionProvider(providerData: SubscriptionProviderData): void;
|
|
62
|
+
executeCommand(): void;
|
|
63
|
+
};
|
|
64
|
+
events: {
|
|
65
|
+
on<E extends PluginEvent>(event: E, callback: PluginEventCallback<E>): {
|
|
66
|
+
unsubscribe: () => void;
|
|
67
|
+
};
|
|
68
|
+
off(): void;
|
|
69
|
+
};
|
|
70
|
+
theme: {
|
|
71
|
+
add(name: string, theme: ICustomTheme): void;
|
|
72
|
+
enable(name: string, darkMode?: boolean): Promise<void>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface PluginContextGenerator {
|
|
76
|
+
createContext(pluginName: string, plugin: AltairPlugin): PluginContext;
|
|
77
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface PluginEventPayloadMap {
|
|
2
|
+
'app-ready': boolean;
|
|
3
|
+
'current-window.change': {
|
|
4
|
+
windowId: string;
|
|
5
|
+
};
|
|
6
|
+
'query.change': {
|
|
7
|
+
windowId: string;
|
|
8
|
+
data: string;
|
|
9
|
+
};
|
|
10
|
+
'query-result.change': {
|
|
11
|
+
windowId: string;
|
|
12
|
+
data: any;
|
|
13
|
+
};
|
|
14
|
+
'query-result-meta.change': {
|
|
15
|
+
windowId: string;
|
|
16
|
+
data: {
|
|
17
|
+
requestStartTime: number;
|
|
18
|
+
requestEndTime: number;
|
|
19
|
+
responseTime: number;
|
|
20
|
+
responseStatus: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
'sdl.change': {
|
|
24
|
+
windowId: string;
|
|
25
|
+
data: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare type PluginEvent = keyof PluginEventPayloadMap;
|
|
29
|
+
export declare type PluginEventCallback<T extends PluginEvent> = (payload: PluginEventPayloadMap[T]) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum AltairPanelLocation {
|
|
2
|
+
HEADER = "header",
|
|
3
|
+
SIDEBAR = "sidebar",
|
|
4
|
+
RESULT_PANE_BOTTOM = "result_pane_bottom"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Used for dynamic panel elements. Can also be used for angular components in the future.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AltairPanel {
|
|
10
|
+
title: string;
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
location: AltairPanelLocation;
|
|
13
|
+
id: string;
|
|
14
|
+
isActive: boolean;
|
|
15
|
+
constructor(title: string, element: HTMLElement, location: AltairPanelLocation);
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AltairPanel = exports.AltairPanelLocation = void 0;
|
|
4
|
+
var uuid_1 = require("uuid");
|
|
5
|
+
var AltairPanelLocation;
|
|
6
|
+
(function (AltairPanelLocation) {
|
|
7
|
+
AltairPanelLocation["HEADER"] = "header";
|
|
8
|
+
AltairPanelLocation["SIDEBAR"] = "sidebar";
|
|
9
|
+
AltairPanelLocation["RESULT_PANE_BOTTOM"] = "result_pane_bottom";
|
|
10
|
+
})(AltairPanelLocation = exports.AltairPanelLocation || (exports.AltairPanelLocation = {}));
|
|
11
|
+
/**
|
|
12
|
+
* Used for dynamic panel elements. Can also be used for angular components in the future.
|
|
13
|
+
*/
|
|
14
|
+
var AltairPanel = /** @class */ (function () {
|
|
15
|
+
function AltairPanel(title, element, location) {
|
|
16
|
+
this.title = title;
|
|
17
|
+
this.element = element;
|
|
18
|
+
this.location = location;
|
|
19
|
+
this.id = uuid_1.v4();
|
|
20
|
+
this.isActive = false;
|
|
21
|
+
}
|
|
22
|
+
AltairPanel.prototype.destroy = function () {
|
|
23
|
+
this.element = null;
|
|
24
|
+
};
|
|
25
|
+
return AltairPanel;
|
|
26
|
+
}());
|
|
27
|
+
exports.AltairPanel = AltairPanel;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the repository of the plugin.
|
|
3
|
+
* Used to know where to get the plugin from.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum PluginSource {
|
|
6
|
+
NPM = "npm",
|
|
7
|
+
GITHUB = "github",
|
|
8
|
+
URL = "url"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Specifies the type of the plugin.
|
|
12
|
+
* Determines how the plugin would interact with Altair.
|
|
13
|
+
*/
|
|
14
|
+
export declare enum PluginType {
|
|
15
|
+
HEADER = "header",
|
|
16
|
+
SIDEBAR = "sidebar",
|
|
17
|
+
ACTION_BUTTON = "action_button"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the capabilities (functionalities) available to the plugin.
|
|
21
|
+
* In the future, this would be used to request the necessary permissions from the user.
|
|
22
|
+
*/
|
|
23
|
+
export declare type PluginCapabilities = 'query:read' | 'query:write' | 'header:read' | 'header:write' | 'environment:read' | 'environment:write';
|
|
24
|
+
/**
|
|
25
|
+
* Plugin Manifest Structure
|
|
26
|
+
*/
|
|
27
|
+
export interface PluginManifest {
|
|
28
|
+
manifest_version: number;
|
|
29
|
+
name: string;
|
|
30
|
+
display_name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
description: string;
|
|
33
|
+
author_email?: string;
|
|
34
|
+
author?: string;
|
|
35
|
+
type?: PluginType;
|
|
36
|
+
plugin_class?: string;
|
|
37
|
+
scripts: string[];
|
|
38
|
+
styles?: string[];
|
|
39
|
+
capabilities?: PluginCapabilities[];
|
|
40
|
+
}
|
|
41
|
+
export interface AltairPlugin {
|
|
42
|
+
name: string;
|
|
43
|
+
display_name: string;
|
|
44
|
+
capabilities: PluginCapabilities[];
|
|
45
|
+
type?: PluginType;
|
|
46
|
+
plugin_class?: string;
|
|
47
|
+
manifest: PluginManifest;
|
|
48
|
+
}
|
|
49
|
+
export declare const createPlugin: (name: string, manifest: PluginManifest) => AltairPlugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createPlugin = exports.PluginType = exports.PluginSource = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Defines the repository of the plugin.
|
|
13
|
+
* Used to know where to get the plugin from.
|
|
14
|
+
*/
|
|
15
|
+
var PluginSource;
|
|
16
|
+
(function (PluginSource) {
|
|
17
|
+
PluginSource["NPM"] = "npm";
|
|
18
|
+
PluginSource["GITHUB"] = "github";
|
|
19
|
+
PluginSource["URL"] = "url";
|
|
20
|
+
})(PluginSource = exports.PluginSource || (exports.PluginSource = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Specifies the type of the plugin.
|
|
23
|
+
* Determines how the plugin would interact with Altair.
|
|
24
|
+
*/
|
|
25
|
+
var PluginType;
|
|
26
|
+
(function (PluginType) {
|
|
27
|
+
PluginType["HEADER"] = "header";
|
|
28
|
+
PluginType["SIDEBAR"] = "sidebar";
|
|
29
|
+
PluginType["ACTION_BUTTON"] = "action_button";
|
|
30
|
+
})(PluginType = exports.PluginType || (exports.PluginType = {}));
|
|
31
|
+
exports.createPlugin = function (name, manifest) {
|
|
32
|
+
return {
|
|
33
|
+
name: name,
|
|
34
|
+
manifest: manifest,
|
|
35
|
+
type: manifest.type,
|
|
36
|
+
display_name: manifest.display_name || name,
|
|
37
|
+
plugin_class: manifest.plugin_class,
|
|
38
|
+
capabilities: Array.from(new Set(__spreadArrays((manifest.capabilities || []), ['query:read', 'query:write']))),
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare enum AltairUiActionLocation {
|
|
2
|
+
RESULT_PANE = "result_pane"
|
|
3
|
+
}
|
|
4
|
+
export declare class AltairUiAction {
|
|
5
|
+
title: string;
|
|
6
|
+
location: AltairUiActionLocation;
|
|
7
|
+
callback: () => void;
|
|
8
|
+
id: string;
|
|
9
|
+
constructor(title: string, location: AltairUiActionLocation, callback: () => void);
|
|
10
|
+
execute(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AltairUiAction = exports.AltairUiActionLocation = void 0;
|
|
4
|
+
var uuid_1 = require("uuid");
|
|
5
|
+
var AltairUiActionLocation;
|
|
6
|
+
(function (AltairUiActionLocation) {
|
|
7
|
+
AltairUiActionLocation["RESULT_PANE"] = "result_pane";
|
|
8
|
+
})(AltairUiActionLocation = exports.AltairUiActionLocation || (exports.AltairUiActionLocation = {}));
|
|
9
|
+
var AltairUiAction = /** @class */ (function () {
|
|
10
|
+
function AltairUiAction(title, location, callback) {
|
|
11
|
+
this.title = title;
|
|
12
|
+
this.location = location;
|
|
13
|
+
this.callback = callback;
|
|
14
|
+
this.id = uuid_1.v4();
|
|
15
|
+
}
|
|
16
|
+
AltairUiAction.prototype.execute = function () {
|
|
17
|
+
this.callback();
|
|
18
|
+
};
|
|
19
|
+
return AltairUiAction;
|
|
20
|
+
}());
|
|
21
|
+
exports.AltairUiAction = AltairUiAction;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SubscriptionProviderConstructor } from './subscription-provider';
|
|
2
|
+
export declare const WEBSOCKET_PROVIDER_ID = "websocket";
|
|
3
|
+
export declare const GRAPHQL_WS_PROVIDER_ID = "graphql-ws";
|
|
4
|
+
export declare const APP_SYNC_PROVIDER_ID = "app-sync";
|
|
5
|
+
export declare const ACTION_CABLE_PROVIDER_ID = "action-cable";
|
|
6
|
+
export declare const SUBSCRIPTION_PROVIDER_IDS: {
|
|
7
|
+
readonly WEBSOCKET: "websocket";
|
|
8
|
+
readonly GRAPHQL_WS: "graphql-ws";
|
|
9
|
+
readonly APP_SYNC: "app-sync";
|
|
10
|
+
readonly ACTION_CABLE: "action-cable";
|
|
11
|
+
};
|
|
12
|
+
export declare type SubscriptionProviderIds = typeof SUBSCRIPTION_PROVIDER_IDS[keyof typeof SUBSCRIPTION_PROVIDER_IDS];
|
|
13
|
+
export interface SubscriptionProviderData {
|
|
14
|
+
id: string;
|
|
15
|
+
getProviderClass: () => Promise<SubscriptionProviderConstructor>;
|
|
16
|
+
copyTag?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUBSCRIPTION_PROVIDER_IDS = exports.ACTION_CABLE_PROVIDER_ID = exports.APP_SYNC_PROVIDER_ID = exports.GRAPHQL_WS_PROVIDER_ID = exports.WEBSOCKET_PROVIDER_ID = void 0;
|
|
4
|
+
exports.WEBSOCKET_PROVIDER_ID = 'websocket';
|
|
5
|
+
exports.GRAPHQL_WS_PROVIDER_ID = 'graphql-ws';
|
|
6
|
+
exports.APP_SYNC_PROVIDER_ID = 'app-sync';
|
|
7
|
+
exports.ACTION_CABLE_PROVIDER_ID = 'action-cable';
|
|
8
|
+
exports.SUBSCRIPTION_PROVIDER_IDS = {
|
|
9
|
+
WEBSOCKET: exports.WEBSOCKET_PROVIDER_ID,
|
|
10
|
+
GRAPHQL_WS: exports.GRAPHQL_WS_PROVIDER_ID,
|
|
11
|
+
APP_SYNC: exports.APP_SYNC_PROVIDER_ID,
|
|
12
|
+
ACTION_CABLE: exports.ACTION_CABLE_PROVIDER_ID
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SubscriptionProvider, SubscriptionProviderExecuteOptions } from '../subscription-provider';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export declare class ActionCableSubscriptionProvider extends SubscriptionProvider {
|
|
4
|
+
subscription?: any;
|
|
5
|
+
channel?: string;
|
|
6
|
+
execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|