altair-graphql-core 6.3.1 → 6.4.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 (44) hide show
  1. package/build/authorization/authorization-provider.d.ts +11 -0
  2. package/build/authorization/authorization-provider.js +9 -0
  3. package/build/authorization/providers/api-key.d.ts +10 -0
  4. package/build/authorization/providers/api-key.js +11 -0
  5. package/build/authorization/providers/api-key.spec.d.ts +2 -0
  6. package/build/authorization/providers/api-key.spec.js +19 -0
  7. package/build/authorization/providers/basic.d.ts +10 -0
  8. package/build/authorization/providers/basic.js +16 -0
  9. package/build/authorization/providers/basic.spec.d.ts +2 -0
  10. package/build/authorization/providers/basic.spec.js +31 -0
  11. package/build/authorization/providers/bearer.d.ts +9 -0
  12. package/build/authorization/providers/bearer.js +11 -0
  13. package/build/authorization/providers/bearer.spec.d.ts +2 -0
  14. package/build/authorization/providers/bearer.spec.js +18 -0
  15. package/build/cjs/authorization/authorization-provider.d.ts +11 -0
  16. package/build/cjs/authorization/authorization-provider.js +13 -0
  17. package/build/cjs/authorization/providers/api-key.d.ts +10 -0
  18. package/build/cjs/authorization/providers/api-key.js +14 -0
  19. package/build/cjs/authorization/providers/api-key.spec.d.ts +2 -0
  20. package/build/cjs/authorization/providers/api-key.spec.js +24 -0
  21. package/build/cjs/authorization/providers/basic.d.ts +10 -0
  22. package/build/cjs/authorization/providers/basic.js +42 -0
  23. package/build/cjs/authorization/providers/basic.spec.d.ts +2 -0
  24. package/build/cjs/authorization/providers/basic.spec.js +36 -0
  25. package/build/cjs/authorization/providers/bearer.d.ts +9 -0
  26. package/build/cjs/authorization/providers/bearer.js +14 -0
  27. package/build/cjs/authorization/providers/bearer.spec.d.ts +2 -0
  28. package/build/cjs/authorization/providers/bearer.spec.js +23 -0
  29. package/build/cjs/config.js +1 -2
  30. package/build/cjs/subscriptions/providers/graphql-ws.js +4 -3
  31. package/build/cjs/subscriptions/subscription-provider.d.ts +2 -2
  32. package/build/cjs/theme/theme.js +14 -0
  33. package/build/cjs/types/state/authorization.interface.d.ts +19 -0
  34. package/build/cjs/types/state/authorization.interface.js +12 -0
  35. package/build/cjs/types/state/per-window.interfaces.d.ts +2 -0
  36. package/build/config.js +1 -2
  37. package/build/subscriptions/providers/graphql-ws.js +4 -3
  38. package/build/subscriptions/subscription-provider.d.ts +2 -2
  39. package/build/theme/theme.js +14 -0
  40. package/build/types/state/authorization.interface.d.ts +19 -0
  41. package/build/types/state/authorization.interface.js +9 -0
  42. package/build/types/state/per-window.interfaces.d.ts +2 -0
  43. package/jest.config.js +6 -0
  44. package/package.json +13 -3
@@ -0,0 +1,11 @@
1
+ import { AuthorizationResult } from '../types/state/authorization.interface';
2
+ export interface AuthorizationProviderExecuteOptions<T = unknown> {
3
+ data: T;
4
+ }
5
+ export declare abstract class AuthorizationProvider<T = unknown> {
6
+ private hydrator;
7
+ constructor(hydrator: (data: string) => string);
8
+ hydrate(data: string): string;
9
+ abstract execute(options: AuthorizationProviderExecuteOptions<T>): Promise<AuthorizationResult>;
10
+ }
11
+ //# sourceMappingURL=authorization-provider.d.ts.map
@@ -0,0 +1,9 @@
1
+ export class AuthorizationProvider {
2
+ constructor(hydrator) {
3
+ this.hydrator = hydrator;
4
+ }
5
+ hydrate(data) {
6
+ return this.hydrator(data);
7
+ }
8
+ }
9
+ //# sourceMappingURL=authorization-provider.js.map
@@ -0,0 +1,10 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface ApiKeyAuthorizationProviderData {
4
+ key: string;
5
+ value: string;
6
+ }
7
+ export default class ApiKeyAuthorizationProvider extends AuthorizationProvider<ApiKeyAuthorizationProviderData> {
8
+ execute(options: AuthorizationProviderExecuteOptions<ApiKeyAuthorizationProviderData>): Promise<AuthorizationResult>;
9
+ }
10
+ //# sourceMappingURL=api-key.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { AuthorizationProvider, } from '../authorization-provider';
2
+ export default class ApiKeyAuthorizationProvider extends AuthorizationProvider {
3
+ async execute(options) {
4
+ return {
5
+ headers: {
6
+ [options.data.key]: options.data.value,
7
+ },
8
+ };
9
+ }
10
+ }
11
+ //# sourceMappingURL=api-key.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api-key.spec.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import ApiKeyAuthorizationProvider from './api-key';
3
+ describe('basic', () => {
4
+ it('should return basic auth header', async () => {
5
+ const authProvider = new ApiKeyAuthorizationProvider((x) => x);
6
+ const res = await authProvider.execute({
7
+ data: {
8
+ key: 'X-API-Key',
9
+ value: 'api_1a2s3d4f5g6h7j8k9l0',
10
+ },
11
+ });
12
+ expect(res).toEqual({
13
+ headers: {
14
+ 'X-API-Key': 'api_1a2s3d4f5g6h7j8k9l0',
15
+ },
16
+ });
17
+ });
18
+ });
19
+ //# sourceMappingURL=api-key.spec.js.map
@@ -0,0 +1,10 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface BasicAuthorizationProviderData {
4
+ username: string;
5
+ password: string;
6
+ }
7
+ export default class BasicAuthorizationProvider extends AuthorizationProvider<BasicAuthorizationProviderData> {
8
+ execute(options: AuthorizationProviderExecuteOptions<BasicAuthorizationProviderData>): Promise<AuthorizationResult>;
9
+ }
10
+ //# sourceMappingURL=basic.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { AuthorizationProvider, } from '../authorization-provider';
2
+ export default class BasicAuthorizationProvider extends AuthorizationProvider {
3
+ async execute(options) {
4
+ if (!options.data.username || !options.data.password) {
5
+ return {
6
+ headers: {},
7
+ };
8
+ }
9
+ return {
10
+ headers: {
11
+ Authorization: `Basic ${(await import('abab')).btoa(`${options.data.username}:${options.data.password}`)}`,
12
+ },
13
+ };
14
+ }
15
+ }
16
+ //# sourceMappingURL=basic.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=basic.spec.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import BasicAuthorizationProvider from './basic';
3
+ describe('basic', () => {
4
+ it('should return basic auth header', async () => {
5
+ const authProvider = new BasicAuthorizationProvider((x) => x);
6
+ const res = await authProvider.execute({
7
+ data: {
8
+ username: 'username',
9
+ password: 'password',
10
+ },
11
+ });
12
+ expect(res).toEqual({
13
+ headers: {
14
+ Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
15
+ },
16
+ });
17
+ });
18
+ it('should not return headers if username or password is missing', async () => {
19
+ const authProvider = new BasicAuthorizationProvider((x) => x);
20
+ const res = await authProvider.execute({
21
+ data: {
22
+ username: '',
23
+ password: '',
24
+ },
25
+ });
26
+ expect(res).toEqual({
27
+ headers: {},
28
+ });
29
+ });
30
+ });
31
+ //# sourceMappingURL=basic.spec.js.map
@@ -0,0 +1,9 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface BearerAuthorizationProviderData {
4
+ token: string;
5
+ }
6
+ export default class BearerAuthorizationProvider extends AuthorizationProvider<BearerAuthorizationProviderData> {
7
+ execute(options: AuthorizationProviderExecuteOptions<BearerAuthorizationProviderData>): Promise<AuthorizationResult>;
8
+ }
9
+ //# sourceMappingURL=bearer.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { AuthorizationProvider, } from '../authorization-provider';
2
+ export default class BearerAuthorizationProvider extends AuthorizationProvider {
3
+ async execute(options) {
4
+ return {
5
+ headers: {
6
+ Authorization: `Bearer ${options.data.token}`,
7
+ },
8
+ };
9
+ }
10
+ }
11
+ //# sourceMappingURL=bearer.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bearer.spec.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { describe, expect, it } from '@jest/globals';
2
+ import BearerAuthorizationProvider from './bearer';
3
+ describe('basic', () => {
4
+ it('should return basic auth header', async () => {
5
+ const authProvider = new BearerAuthorizationProvider((x) => x);
6
+ const res = await authProvider.execute({
7
+ data: {
8
+ token: 'tk_1a2s3d4f5g6h7j8k9l0',
9
+ },
10
+ });
11
+ expect(res).toEqual({
12
+ headers: {
13
+ Authorization: 'Bearer tk_1a2s3d4f5g6h7j8k9l0',
14
+ },
15
+ });
16
+ });
17
+ });
18
+ //# sourceMappingURL=bearer.spec.js.map
@@ -0,0 +1,11 @@
1
+ import { AuthorizationResult } from '../types/state/authorization.interface';
2
+ export interface AuthorizationProviderExecuteOptions<T = unknown> {
3
+ data: T;
4
+ }
5
+ export declare abstract class AuthorizationProvider<T = unknown> {
6
+ private hydrator;
7
+ constructor(hydrator: (data: string) => string);
8
+ hydrate(data: string): string;
9
+ abstract execute(options: AuthorizationProviderExecuteOptions<T>): Promise<AuthorizationResult>;
10
+ }
11
+ //# sourceMappingURL=authorization-provider.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorizationProvider = void 0;
4
+ class AuthorizationProvider {
5
+ constructor(hydrator) {
6
+ this.hydrator = hydrator;
7
+ }
8
+ hydrate(data) {
9
+ return this.hydrator(data);
10
+ }
11
+ }
12
+ exports.AuthorizationProvider = AuthorizationProvider;
13
+ //# sourceMappingURL=authorization-provider.js.map
@@ -0,0 +1,10 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface ApiKeyAuthorizationProviderData {
4
+ key: string;
5
+ value: string;
6
+ }
7
+ export default class ApiKeyAuthorizationProvider extends AuthorizationProvider<ApiKeyAuthorizationProviderData> {
8
+ execute(options: AuthorizationProviderExecuteOptions<ApiKeyAuthorizationProviderData>): Promise<AuthorizationResult>;
9
+ }
10
+ //# sourceMappingURL=api-key.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const authorization_provider_1 = require("../authorization-provider");
4
+ class ApiKeyAuthorizationProvider extends authorization_provider_1.AuthorizationProvider {
5
+ async execute(options) {
6
+ return {
7
+ headers: {
8
+ [options.data.key]: options.data.value,
9
+ },
10
+ };
11
+ }
12
+ }
13
+ exports.default = ApiKeyAuthorizationProvider;
14
+ //# sourceMappingURL=api-key.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api-key.spec.d.ts.map
@@ -0,0 +1,24 @@
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
+ const globals_1 = require("@jest/globals");
7
+ const api_key_1 = __importDefault(require("./api-key"));
8
+ (0, globals_1.describe)('basic', () => {
9
+ (0, globals_1.it)('should return basic auth header', async () => {
10
+ const authProvider = new api_key_1.default((x) => x);
11
+ const res = await authProvider.execute({
12
+ data: {
13
+ key: 'X-API-Key',
14
+ value: 'api_1a2s3d4f5g6h7j8k9l0',
15
+ },
16
+ });
17
+ (0, globals_1.expect)(res).toEqual({
18
+ headers: {
19
+ 'X-API-Key': 'api_1a2s3d4f5g6h7j8k9l0',
20
+ },
21
+ });
22
+ });
23
+ });
24
+ //# sourceMappingURL=api-key.spec.js.map
@@ -0,0 +1,10 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface BasicAuthorizationProviderData {
4
+ username: string;
5
+ password: string;
6
+ }
7
+ export default class BasicAuthorizationProvider extends AuthorizationProvider<BasicAuthorizationProviderData> {
8
+ execute(options: AuthorizationProviderExecuteOptions<BasicAuthorizationProviderData>): Promise<AuthorizationResult>;
9
+ }
10
+ //# sourceMappingURL=basic.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const authorization_provider_1 = require("../authorization-provider");
27
+ class BasicAuthorizationProvider extends authorization_provider_1.AuthorizationProvider {
28
+ async execute(options) {
29
+ if (!options.data.username || !options.data.password) {
30
+ return {
31
+ headers: {},
32
+ };
33
+ }
34
+ return {
35
+ headers: {
36
+ Authorization: `Basic ${(await Promise.resolve().then(() => __importStar(require('abab')))).btoa(`${options.data.username}:${options.data.password}`)}`,
37
+ },
38
+ };
39
+ }
40
+ }
41
+ exports.default = BasicAuthorizationProvider;
42
+ //# sourceMappingURL=basic.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=basic.spec.d.ts.map
@@ -0,0 +1,36 @@
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
+ const globals_1 = require("@jest/globals");
7
+ const basic_1 = __importDefault(require("./basic"));
8
+ (0, globals_1.describe)('basic', () => {
9
+ (0, globals_1.it)('should return basic auth header', async () => {
10
+ const authProvider = new basic_1.default((x) => x);
11
+ const res = await authProvider.execute({
12
+ data: {
13
+ username: 'username',
14
+ password: 'password',
15
+ },
16
+ });
17
+ (0, globals_1.expect)(res).toEqual({
18
+ headers: {
19
+ Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=',
20
+ },
21
+ });
22
+ });
23
+ (0, globals_1.it)('should not return headers if username or password is missing', async () => {
24
+ const authProvider = new basic_1.default((x) => x);
25
+ const res = await authProvider.execute({
26
+ data: {
27
+ username: '',
28
+ password: '',
29
+ },
30
+ });
31
+ (0, globals_1.expect)(res).toEqual({
32
+ headers: {},
33
+ });
34
+ });
35
+ });
36
+ //# sourceMappingURL=basic.spec.js.map
@@ -0,0 +1,9 @@
1
+ import { AuthorizationResult } from '../../types/state/authorization.interface';
2
+ import { AuthorizationProvider, AuthorizationProviderExecuteOptions } from '../authorization-provider';
3
+ export interface BearerAuthorizationProviderData {
4
+ token: string;
5
+ }
6
+ export default class BearerAuthorizationProvider extends AuthorizationProvider<BearerAuthorizationProviderData> {
7
+ execute(options: AuthorizationProviderExecuteOptions<BearerAuthorizationProviderData>): Promise<AuthorizationResult>;
8
+ }
9
+ //# sourceMappingURL=bearer.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const authorization_provider_1 = require("../authorization-provider");
4
+ class BearerAuthorizationProvider extends authorization_provider_1.AuthorizationProvider {
5
+ async execute(options) {
6
+ return {
7
+ headers: {
8
+ Authorization: `Bearer ${options.data.token}`,
9
+ },
10
+ };
11
+ }
12
+ }
13
+ exports.default = BearerAuthorizationProvider;
14
+ //# sourceMappingURL=bearer.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bearer.spec.d.ts.map
@@ -0,0 +1,23 @@
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
+ const globals_1 = require("@jest/globals");
7
+ const bearer_1 = __importDefault(require("./bearer"));
8
+ (0, globals_1.describe)('basic', () => {
9
+ (0, globals_1.it)('should return basic auth header', async () => {
10
+ const authProvider = new bearer_1.default((x) => x);
11
+ const res = await authProvider.execute({
12
+ data: {
13
+ token: 'tk_1a2s3d4f5g6h7j8k9l0',
14
+ },
15
+ });
16
+ (0, globals_1.expect)(res).toEqual({
17
+ headers: {
18
+ Authorization: 'Bearer tk_1a2s3d4f5g6h7j8k9l0',
19
+ },
20
+ });
21
+ });
22
+ });
23
+ //# sourceMappingURL=bearer.spec.js.map
@@ -86,8 +86,7 @@ class AltairConfig {
86
86
  instanceStorageNamespace ||
87
87
  'altair_';
88
88
  this.initialData.settings = initialSettings;
89
- this.initialData.initialSubscriptionsProvider =
90
- initialSubscriptionsProvider;
89
+ this.initialData.initialSubscriptionsProvider = initialSubscriptionsProvider;
91
90
  this.initialData.initialSubscriptionsPayload = initialSubscriptionsPayload;
92
91
  this.initialData.initialHttpMethod = initialHttpMethod;
93
92
  this.initialData.preserveState = preserveState;
@@ -10,14 +10,14 @@ class GraphQLWsSubscriptionProvider extends subscription_provider_1.Subscription
10
10
  url: this.subscriptionUrl,
11
11
  connectionParams: this.connectionParams,
12
12
  lazy: false,
13
- onNonLazyError: (err) => {
13
+ onNonLazyError: err => {
14
14
  this.extraOptions?.onConnected?.(err, undefined);
15
15
  },
16
16
  on: {
17
17
  connected: () => {
18
18
  this.extraOptions?.onConnected?.(undefined, undefined);
19
19
  },
20
- error: (err) => {
20
+ error: err => {
21
21
  this.extraOptions?.onConnected?.(err, undefined);
22
22
  },
23
23
  },
@@ -28,7 +28,7 @@ class GraphQLWsSubscriptionProvider extends subscription_provider_1.Subscription
28
28
  if (!this.client) {
29
29
  throw new Error('Could not create subscription client!');
30
30
  }
31
- return new rxjs_1.Observable((subscriber) => {
31
+ return new rxjs_1.Observable(subscriber => {
32
32
  this.cleanup = this.client.subscribe({
33
33
  query: options.query,
34
34
  variables: options.variables,
@@ -49,6 +49,7 @@ class GraphQLWsSubscriptionProvider extends subscription_provider_1.Subscription
49
49
  this.client = undefined;
50
50
  }
51
51
  catch (err) {
52
+ // eslint-disable-next-line no-console
52
53
  console.error(err);
53
54
  }
54
55
  }
@@ -1,7 +1,7 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { IDictionary } from '../types/shared';
3
3
  export interface SubscriptionProviderExtraOptions {
4
- onConnected?: (error: any, data: any) => void;
4
+ onConnected?: (error: unknown, data: unknown) => void;
5
5
  headers?: IDictionary<string>;
6
6
  }
7
7
  export interface SubscriptionProviderExecuteOptions {
@@ -15,7 +15,7 @@ export declare abstract class SubscriptionProvider {
15
15
  protected connectionParams: IDictionary;
16
16
  protected extraOptions?: SubscriptionProviderExtraOptions | undefined;
17
17
  constructor(subscriptionUrl: string, connectionParams: IDictionary, extraOptions?: SubscriptionProviderExtraOptions | undefined);
18
- abstract execute(options: SubscriptionProviderExecuteOptions): Observable<any>;
18
+ abstract execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
19
19
  abstract close(): void;
20
20
  }
21
21
  //# sourceMappingURL=subscription-provider.d.ts.map
@@ -6,6 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createTheme = exports.mergeThemes = exports.hexToRgbStr = exports.foundations = void 0;
7
7
  const deepmerge_1 = __importDefault(require("deepmerge"));
8
8
  const color_name_1 = __importDefault(require("color-name"));
9
+ /*
10
+ Some theming ideas:
11
+ #1a1c24 - A deep charcoal gray with a subtle blue undertone.
12
+ #181a1f - A very dark gray with a cool, slightly bluish tint.
13
+ #212529 - A dark cool gray with a hint of blue.
14
+ #232931 - A rich, deep blue-gray shade that pairs well with greens.
15
+ #2d2f33 - A slightly lighter dark gray with a subtle blue cast.
16
+
17
+ If the background color is #1a1c24 (deep charcoal gray), you could use #2d3138 for borders.
18
+ For a #181a1f (very dark gray) background, consider #262a2e for borders.
19
+ With a #212529 (dark cool gray) background, #343a40 would make a good border color.
20
+ If you choose #232931 (rich blue-gray) as the background, #3a4149 would be a suitable border shade.
21
+ For a #2d2f33 (slightly lighter dark gray) background, #404448 could work well for borders.
22
+ */
9
23
  exports.foundations = {
10
24
  easing: 'ease',
11
25
  colors: {
@@ -0,0 +1,19 @@
1
+ import { IDictionary } from '../shared';
2
+ export declare const AUTHORIZATION_TYPES: {
3
+ readonly NONE: "none";
4
+ readonly BASIC: "basic";
5
+ readonly BEARER: "bearer";
6
+ readonly API_KEY: "api-key";
7
+ };
8
+ export declare const AUTHORIZATION_TYPE_LIST: ("none" | "basic" | "bearer" | "api-key")[];
9
+ export declare const DEFAULT_AUTHORIZATION_TYPE: "none";
10
+ export type AuthorizationTypes = typeof AUTHORIZATION_TYPES[keyof typeof AUTHORIZATION_TYPES];
11
+ export interface AuthorizationResult {
12
+ headers: IDictionary<string>;
13
+ }
14
+ export interface AuthorizationState {
15
+ type: AuthorizationTypes;
16
+ data: unknown;
17
+ result: AuthorizationResult;
18
+ }
19
+ //# sourceMappingURL=authorization.interface.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_AUTHORIZATION_TYPE = exports.AUTHORIZATION_TYPE_LIST = exports.AUTHORIZATION_TYPES = void 0;
4
+ exports.AUTHORIZATION_TYPES = {
5
+ NONE: 'none',
6
+ BASIC: 'basic',
7
+ BEARER: 'bearer',
8
+ API_KEY: 'api-key',
9
+ };
10
+ exports.AUTHORIZATION_TYPE_LIST = Object.values(exports.AUTHORIZATION_TYPES);
11
+ exports.DEFAULT_AUTHORIZATION_TYPE = exports.AUTHORIZATION_TYPES.NONE;
12
+ //# sourceMappingURL=authorization.interface.js.map
@@ -1,3 +1,4 @@
1
+ import { AuthorizationState } from './authorization.interface';
1
2
  import { DialogState } from './dialog.interfaces';
2
3
  import { DocsState } from './docs.interfaces';
3
4
  import { GQLSchemaState } from './gql-schema.interfaces';
@@ -12,6 +13,7 @@ import { VariableState } from './variable.interfaces';
12
13
  export interface PerWindowState {
13
14
  layout: LayoutState;
14
15
  query: QueryState;
16
+ authorization: AuthorizationState;
15
17
  headers: HeaderState;
16
18
  variables: VariableState;
17
19
  dialogs: DialogState;
package/build/config.js CHANGED
@@ -80,8 +80,7 @@ export class AltairConfig {
80
80
  instanceStorageNamespace ||
81
81
  'altair_';
82
82
  this.initialData.settings = initialSettings;
83
- this.initialData.initialSubscriptionsProvider =
84
- initialSubscriptionsProvider;
83
+ this.initialData.initialSubscriptionsProvider = initialSubscriptionsProvider;
85
84
  this.initialData.initialSubscriptionsPayload = initialSubscriptionsPayload;
86
85
  this.initialData.initialHttpMethod = initialHttpMethod;
87
86
  this.initialData.preserveState = preserveState;
@@ -7,14 +7,14 @@ export class GraphQLWsSubscriptionProvider extends SubscriptionProvider {
7
7
  url: this.subscriptionUrl,
8
8
  connectionParams: this.connectionParams,
9
9
  lazy: false,
10
- onNonLazyError: (err) => {
10
+ onNonLazyError: err => {
11
11
  this.extraOptions?.onConnected?.(err, undefined);
12
12
  },
13
13
  on: {
14
14
  connected: () => {
15
15
  this.extraOptions?.onConnected?.(undefined, undefined);
16
16
  },
17
- error: (err) => {
17
+ error: err => {
18
18
  this.extraOptions?.onConnected?.(err, undefined);
19
19
  },
20
20
  },
@@ -25,7 +25,7 @@ export class GraphQLWsSubscriptionProvider extends SubscriptionProvider {
25
25
  if (!this.client) {
26
26
  throw new Error('Could not create subscription client!');
27
27
  }
28
- return new Observable((subscriber) => {
28
+ return new Observable(subscriber => {
29
29
  this.cleanup = this.client.subscribe({
30
30
  query: options.query,
31
31
  variables: options.variables,
@@ -46,6 +46,7 @@ export class GraphQLWsSubscriptionProvider extends SubscriptionProvider {
46
46
  this.client = undefined;
47
47
  }
48
48
  catch (err) {
49
+ // eslint-disable-next-line no-console
49
50
  console.error(err);
50
51
  }
51
52
  }
@@ -1,7 +1,7 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { IDictionary } from '../types/shared';
3
3
  export interface SubscriptionProviderExtraOptions {
4
- onConnected?: (error: any, data: any) => void;
4
+ onConnected?: (error: unknown, data: unknown) => void;
5
5
  headers?: IDictionary<string>;
6
6
  }
7
7
  export interface SubscriptionProviderExecuteOptions {
@@ -15,7 +15,7 @@ export declare abstract class SubscriptionProvider {
15
15
  protected connectionParams: IDictionary;
16
16
  protected extraOptions?: SubscriptionProviderExtraOptions | undefined;
17
17
  constructor(subscriptionUrl: string, connectionParams: IDictionary, extraOptions?: SubscriptionProviderExtraOptions | undefined);
18
- abstract execute(options: SubscriptionProviderExecuteOptions): Observable<any>;
18
+ abstract execute(options: SubscriptionProviderExecuteOptions): Observable<unknown>;
19
19
  abstract close(): void;
20
20
  }
21
21
  //# sourceMappingURL=subscription-provider.d.ts.map
@@ -1,5 +1,19 @@
1
1
  import deepmerge from 'deepmerge';
2
2
  import colors from 'color-name';
3
+ /*
4
+ Some theming ideas:
5
+ #1a1c24 - A deep charcoal gray with a subtle blue undertone.
6
+ #181a1f - A very dark gray with a cool, slightly bluish tint.
7
+ #212529 - A dark cool gray with a hint of blue.
8
+ #232931 - A rich, deep blue-gray shade that pairs well with greens.
9
+ #2d2f33 - A slightly lighter dark gray with a subtle blue cast.
10
+
11
+ If the background color is #1a1c24 (deep charcoal gray), you could use #2d3138 for borders.
12
+ For a #181a1f (very dark gray) background, consider #262a2e for borders.
13
+ With a #212529 (dark cool gray) background, #343a40 would make a good border color.
14
+ If you choose #232931 (rich blue-gray) as the background, #3a4149 would be a suitable border shade.
15
+ For a #2d2f33 (slightly lighter dark gray) background, #404448 could work well for borders.
16
+ */
3
17
  export const foundations = {
4
18
  easing: 'ease',
5
19
  colors: {
@@ -0,0 +1,19 @@
1
+ import { IDictionary } from '../shared';
2
+ export declare const AUTHORIZATION_TYPES: {
3
+ readonly NONE: "none";
4
+ readonly BASIC: "basic";
5
+ readonly BEARER: "bearer";
6
+ readonly API_KEY: "api-key";
7
+ };
8
+ export declare const AUTHORIZATION_TYPE_LIST: ("none" | "basic" | "bearer" | "api-key")[];
9
+ export declare const DEFAULT_AUTHORIZATION_TYPE: "none";
10
+ export type AuthorizationTypes = typeof AUTHORIZATION_TYPES[keyof typeof AUTHORIZATION_TYPES];
11
+ export interface AuthorizationResult {
12
+ headers: IDictionary<string>;
13
+ }
14
+ export interface AuthorizationState {
15
+ type: AuthorizationTypes;
16
+ data: unknown;
17
+ result: AuthorizationResult;
18
+ }
19
+ //# sourceMappingURL=authorization.interface.d.ts.map
@@ -0,0 +1,9 @@
1
+ export const AUTHORIZATION_TYPES = {
2
+ NONE: 'none',
3
+ BASIC: 'basic',
4
+ BEARER: 'bearer',
5
+ API_KEY: 'api-key',
6
+ };
7
+ export const AUTHORIZATION_TYPE_LIST = Object.values(AUTHORIZATION_TYPES);
8
+ export const DEFAULT_AUTHORIZATION_TYPE = AUTHORIZATION_TYPES.NONE;
9
+ //# sourceMappingURL=authorization.interface.js.map
@@ -1,3 +1,4 @@
1
+ import { AuthorizationState } from './authorization.interface';
1
2
  import { DialogState } from './dialog.interfaces';
2
3
  import { DocsState } from './docs.interfaces';
3
4
  import { GQLSchemaState } from './gql-schema.interfaces';
@@ -12,6 +13,7 @@ import { VariableState } from './variable.interfaces';
12
13
  export interface PerWindowState {
13
14
  layout: LayoutState;
14
15
  query: QueryState;
16
+ authorization: AuthorizationState;
15
17
  headers: HeaderState;
16
18
  variables: VariableState;
17
19
  dialogs: DialogState;
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testRegex: '.*\\.spec\\.ts$',
5
+ testEnvironment: 'node',
6
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "altair-graphql-core",
3
3
  "description": "Several of the core logic for altair graphql client",
4
- "version": "6.3.1",
4
+ "version": "6.4.0",
5
5
  "author": "Samuel Imolorhe <altair@sirmuel.design> (https://sirmuel.design)",
6
6
  "bugs": "https://github.com/altair-graphql/altair/issues",
7
7
  "dependencies": {
@@ -25,12 +25,22 @@
25
25
  "uuid": "9.0.1"
26
26
  },
27
27
  "devDependencies": {
28
+ "@jest/globals": "^29.7.0",
28
29
  "@types/actioncable": "^5.2.5",
30
+ "@types/jest": "^29.5.12",
29
31
  "@types/node": "^14.14.41",
30
32
  "@types/uuid": "^9.0.5",
33
+ "@typescript-eslint/eslint-plugin": "^7.4.0",
34
+ "@typescript-eslint/parser": "^7.4.0",
31
35
  "ajv": "^8.11.2",
32
36
  "ajv-cli": "5.0.0",
37
+ "eslint": "^8.57.0",
38
+ "eslint-config-prettier": "^9.1.0",
39
+ "eslint-plugin-prettier": "^5.1.3",
40
+ "jest": "^29.7.0",
41
+ "prettier": "^3.2.5",
33
42
  "react": "17.0.2",
43
+ "ts-jest": "^29.1.2",
34
44
  "ts-node": "9.1.1",
35
45
  "typescript": "5.2.2",
36
46
  "typescript-json-schema": "0.50.1"
@@ -53,8 +63,8 @@
53
63
  "scripts": {
54
64
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
55
65
  "prepare": "npm run build",
56
- "test": "echo \"Error: no test specified\" && exit 0"
66
+ "test": "jest"
57
67
  },
58
68
  "types": "./build/index.d.ts",
59
- "gitHead": "fcd5b52374bc2b296068270500d8b04ad16be721"
69
+ "gitHead": "4a30079d23fc1c545fe64465f7f7262f66bf0e5e"
60
70
  }