altair-graphql-core 8.2.8 → 8.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.
- package/.turbo/turbo-bootstrap.log +2 -2
- package/build/ai/constants.d.ts +1 -1
- package/build/ai/constants.js +1 -1
- package/build/authorization/providers/basic.js +1 -1
- package/build/cjs/ai/constants.d.ts +1 -1
- package/build/cjs/ai/constants.js +1 -1
- package/build/cjs/authorization/providers/basic.js +1 -24
- package/build/cjs/config/index.d.ts +1 -1
- package/build/cjs/config/index.js +8 -6
- package/build/cjs/oauth2/helpers.spec.js +1 -1
- package/build/cjs/script/context.js +18 -7
- package/build/cjs/script/evaluator-client-engine.d.ts +2 -2
- package/build/cjs/script/evaluator-client-engine.js +0 -1
- package/build/cjs/script/types.d.ts +13 -11
- package/build/cjs/types/state/collection.interfaces.d.ts +9 -0
- package/build/cjs/types/state/docs.interfaces.d.ts +5 -1
- package/build/cjs/types/state/environments.interfaces.d.ts +28 -0
- package/build/cjs/types/state/environments.interfaces.js +15 -0
- package/build/cjs/types/state/local.interfaces.d.ts +17 -0
- package/build/cjs/types/state/query.interfaces.d.ts +1 -0
- package/build/cjs/types/state/workspace.interface.d.ts +2 -2
- package/build/config/index.d.ts +1 -1
- package/build/config/index.js +8 -6
- package/build/oauth2/helpers.spec.js +1 -1
- package/build/script/context.js +1 -0
- package/build/script/evaluator-client-engine.d.ts +2 -2
- package/build/script/evaluator-client-engine.js +0 -1
- package/build/script/types.d.ts +13 -11
- package/build/types/state/collection.interfaces.d.ts +9 -0
- package/build/types/state/docs.interfaces.d.ts +5 -1
- package/build/types/state/environments.interfaces.d.ts +28 -0
- package/build/types/state/environments.interfaces.js +14 -1
- package/build/types/state/local.interfaces.d.ts +17 -0
- package/build/types/state/query.interfaces.d.ts +1 -0
- package/build/types/state/workspace.interface.d.ts +2 -2
- package/jest.config.js +1 -0
- package/package.json +3 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> altair-graphql-core@8.
|
|
2
|
+
> altair-graphql-core@8.4.0 bootstrap /home/runner/work/altair/altair/packages/altair-core
|
|
3
3
|
> pnpm build
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> altair-graphql-core@8.
|
|
6
|
+
> altair-graphql-core@8.4.0 build /home/runner/work/altair/altair/packages/altair-core
|
|
7
7
|
> node ./scripts/build.js
|
|
8
8
|
|
|
9
9
|
Generating types for partial-settings ...
|
package/build/ai/constants.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare const maxGraphqlQueryTokens = 1000;
|
|
|
8
8
|
export declare const maxGraphqlQueryChars: number;
|
|
9
9
|
export declare const maxGraphqlVariablesTokens = 150;
|
|
10
10
|
export declare const maxGraphqlVariablesChars: number;
|
|
11
|
-
export declare const responseMaxTokens =
|
|
11
|
+
export declare const responseMaxTokens = 2500;
|
|
12
12
|
//# sourceMappingURL=constants.d.ts.map
|
package/build/ai/constants.js
CHANGED
|
@@ -10,5 +10,5 @@ export const maxGraphqlQueryTokens = 1000;
|
|
|
10
10
|
export const maxGraphqlQueryChars = maxGraphqlQueryTokens * avgCharsPerToken;
|
|
11
11
|
export const maxGraphqlVariablesTokens = 150;
|
|
12
12
|
export const maxGraphqlVariablesChars = maxGraphqlVariablesTokens * avgCharsPerToken;
|
|
13
|
-
export const responseMaxTokens =
|
|
13
|
+
export const responseMaxTokens = 2500;
|
|
14
14
|
//# sourceMappingURL=constants.js.map
|
|
@@ -8,7 +8,7 @@ export default class BasicAuthorizationProvider extends AuthorizationProvider {
|
|
|
8
8
|
}
|
|
9
9
|
return {
|
|
10
10
|
headers: {
|
|
11
|
-
Authorization: `Basic ${
|
|
11
|
+
Authorization: `Basic ${btoa(`${this.hydrate(options.data.username)}:${this.hydrate(options.data.password)}`)}`,
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -8,5 +8,5 @@ export declare const maxGraphqlQueryTokens = 1000;
|
|
|
8
8
|
export declare const maxGraphqlQueryChars: number;
|
|
9
9
|
export declare const maxGraphqlVariablesTokens = 150;
|
|
10
10
|
export declare const maxGraphqlVariablesChars: number;
|
|
11
|
-
export declare const responseMaxTokens =
|
|
11
|
+
export declare const responseMaxTokens = 2500;
|
|
12
12
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -13,5 +13,5 @@ exports.maxGraphqlQueryTokens = 1000;
|
|
|
13
13
|
exports.maxGraphqlQueryChars = exports.maxGraphqlQueryTokens * avgCharsPerToken;
|
|
14
14
|
exports.maxGraphqlVariablesTokens = 150;
|
|
15
15
|
exports.maxGraphqlVariablesChars = exports.maxGraphqlVariablesTokens * avgCharsPerToken;
|
|
16
|
-
exports.responseMaxTokens =
|
|
16
|
+
exports.responseMaxTokens = 2500;
|
|
17
17
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,27 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
const authorization_provider_1 = require("../authorization-provider");
|
|
27
4
|
class BasicAuthorizationProvider extends authorization_provider_1.AuthorizationProvider {
|
|
@@ -33,7 +10,7 @@ class BasicAuthorizationProvider extends authorization_provider_1.AuthorizationP
|
|
|
33
10
|
}
|
|
34
11
|
return {
|
|
35
12
|
headers: {
|
|
36
|
-
Authorization: `Basic ${
|
|
13
|
+
Authorization: `Basic ${btoa(`${this.hydrate(options.data.username)}:${this.hydrate(options.data.password)}`)}`,
|
|
37
14
|
},
|
|
38
15
|
};
|
|
39
16
|
}
|
|
@@ -66,7 +66,7 @@ export declare class AltairConfig {
|
|
|
66
66
|
initialAuthorization: AltairConfigOptions["initialAuthorization"];
|
|
67
67
|
};
|
|
68
68
|
constructor({ endpointURL, subscriptionsEndpoint, subscriptionsProtocol, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, persistedSettings, initialRequestHandlerId, initialRequestHandlerAdditionalParams, initialSubscriptionRequestHandlerId, initialSubscriptionsPayload, initialHttpMethod, preserveState, initialWindows, disableAccount, initialAuthorization, cspNonce, }?: AltairConfigOptions);
|
|
69
|
-
private
|
|
69
|
+
private getPossibleLocalSandBoxRoot;
|
|
70
70
|
private getLocalSandBoxUrl;
|
|
71
71
|
getUrlConfig(environment?: ConfigEnvironment): UrlConfig;
|
|
72
72
|
getUrlConfigWithLocal(environment?: ConfigEnvironment): Promise<UrlConfig>;
|
|
@@ -116,7 +116,7 @@ class AltairConfig {
|
|
|
116
116
|
this.initialData.disableAccount = disableAccount;
|
|
117
117
|
this.initialData.initialAuthorization = initialAuthorization;
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
getPossibleLocalSandBoxRoot() {
|
|
120
120
|
if (crx_1.isExtension) {
|
|
121
121
|
// we only support mv3 extensions now
|
|
122
122
|
// and mv3 extensions doesn't allow using iframe
|
|
@@ -132,20 +132,22 @@ class AltairConfig {
|
|
|
132
132
|
parseUrl(document.baseURI)?.origin === window.location.origin) {
|
|
133
133
|
// add iframe-sandbox path to base url
|
|
134
134
|
if (document.baseURI.endsWith('/')) {
|
|
135
|
-
return new URL(document.baseURI + 'iframe-sandbox
|
|
135
|
+
return new URL(document.baseURI + 'iframe-sandbox');
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
138
|
// remove the last part of the url
|
|
139
139
|
return new URL(document.baseURI.slice(0, document.baseURI.lastIndexOf('/') + 1) +
|
|
140
|
-
'iframe-sandbox
|
|
140
|
+
'iframe-sandbox');
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
async getLocalSandBoxUrl() {
|
|
145
145
|
if (typeof this.localSandboxUrl === 'undefined') {
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
146
|
+
const localSandboxRoot = this.getPossibleLocalSandBoxRoot()?.href ?? '';
|
|
147
|
+
if (localSandboxRoot) {
|
|
148
|
+
this.localSandboxUrl = localSandboxRoot + '/index.html';
|
|
149
|
+
const localSandboxTestUrl = localSandboxRoot + '/sandbox.png';
|
|
150
|
+
const res = await fetch(localSandboxTestUrl);
|
|
149
151
|
if (res.ok) {
|
|
150
152
|
this.useLocalSandboxUrl = true;
|
|
151
153
|
}
|
|
@@ -22,7 +22,7 @@ const helpers_1 = require("./helpers");
|
|
|
22
22
|
});
|
|
23
23
|
(0, globals_1.describe)('base64UrlEncode', () => {
|
|
24
24
|
(0, globals_1.it)('should encode a string to base64url', () => {
|
|
25
|
-
const out = (0, helpers_1.base64UrlEncode)(new TextEncoder().encode('hello world'));
|
|
25
|
+
const out = (0, helpers_1.base64UrlEncode)(new TextEncoder().encode('hello world').buffer);
|
|
26
26
|
(0, globals_1.expect)(out).toBe('aGVsbG8gd29ybGQ');
|
|
27
27
|
});
|
|
28
28
|
});
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.getGlobalContext = exports.importModuleHelper = exports.buildContextResponse = exports.ModuleImports = void 0;
|
|
27
37
|
const types_1 = require("./types");
|
|
@@ -107,6 +117,7 @@ const getGlobalContext = (data, handlers) => {
|
|
|
107
117
|
log: (d) => {
|
|
108
118
|
data.requestScriptLogs = data.requestScriptLogs ?? [];
|
|
109
119
|
data.requestScriptLogs.push({
|
|
120
|
+
id: crypto.randomUUID(),
|
|
110
121
|
time: Date.now(),
|
|
111
122
|
text: JSON.stringify(d, null, 2),
|
|
112
123
|
source: 'Request script',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ScriptContextData, ScriptEvaluatorClientFactory, ScriptEventHandlers,
|
|
1
|
+
import { ScriptContextData, ScriptEvaluatorClientFactory, ScriptEventHandlers, ScriptTransformResult } from './types';
|
|
2
2
|
export declare class ScriptEvaluatorClientEngine {
|
|
3
3
|
private engineFactory;
|
|
4
4
|
private timeout;
|
|
5
5
|
private client?;
|
|
6
6
|
constructor(engineFactory: ScriptEvaluatorClientFactory, timeout?: number);
|
|
7
7
|
private getClient;
|
|
8
|
-
executeScript(script: string, data: ScriptContextData, userAvailableHandlers: ScriptEventHandlers): Promise<
|
|
8
|
+
executeScript(script: string, data: ScriptContextData, userAvailableHandlers: ScriptEventHandlers): Promise<ScriptTransformResult>;
|
|
9
9
|
private killClient;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=evaluator-client-engine.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDictionary } from '../types/shared';
|
|
1
|
+
import { IDictionary, TODO } from '../types/shared';
|
|
2
2
|
import { IEnvironment } from '../types/state/environments.interfaces';
|
|
3
3
|
import { HeaderState } from '../types/state/header.interfaces';
|
|
4
4
|
import { LogLine } from '../types/state/query.interfaces';
|
|
@@ -23,7 +23,7 @@ export interface ScriptContextHelpers {
|
|
|
23
23
|
setEnvironment: (key: string, value: unknown, activeEnvironment?: boolean) => void;
|
|
24
24
|
getCookie: (key: string) => string;
|
|
25
25
|
setCookie: (key: string, value: string) => void;
|
|
26
|
-
request: (arg1: string, arg2: string, arg3:
|
|
26
|
+
request: (arg1: string, arg2: string, arg3: TODO) => Promise<ArrayBuffer | null>;
|
|
27
27
|
}
|
|
28
28
|
export interface ScriptContextStorage {
|
|
29
29
|
get: (key: string) => Promise<unknown>;
|
|
@@ -58,11 +58,13 @@ export interface GlobalHelperContext {
|
|
|
58
58
|
log: (d: unknown) => void;
|
|
59
59
|
response?: ScriptContextResponse;
|
|
60
60
|
}
|
|
61
|
-
export interface
|
|
61
|
+
export interface ScriptTransformResult {
|
|
62
62
|
requestScriptLogs: LogLine[];
|
|
63
|
-
additionalHeaders: HeaderState;
|
|
64
63
|
environment?: IEnvironment;
|
|
65
64
|
}
|
|
65
|
+
export interface FullTransformResult extends ScriptTransformResult {
|
|
66
|
+
combinedHeaders: HeaderState;
|
|
67
|
+
}
|
|
66
68
|
export type SameSite = 'Lax' | 'None' | 'Strict';
|
|
67
69
|
export interface CookieOptions {
|
|
68
70
|
expires?: number | Date;
|
|
@@ -85,7 +87,7 @@ export interface ModuleImportsMap {
|
|
|
85
87
|
export interface ScriptEventHandlers {
|
|
86
88
|
alert: (msg: string) => Promise<void>;
|
|
87
89
|
log: (d: unknown) => Promise<void>;
|
|
88
|
-
request: (arg1: string, arg2: string, arg3:
|
|
90
|
+
request: (arg1: string, arg2: string, arg3: TODO) => Promise<TODO>;
|
|
89
91
|
setCookie: (key: string, value: string, options?: CookieOptions) => Promise<void>;
|
|
90
92
|
getStorageItem: (key: string) => Promise<unknown>;
|
|
91
93
|
setStorageItem: (key: string, value: unknown) => Promise<void>;
|
|
@@ -104,7 +106,7 @@ export interface ScriptEventDataPayload<T extends ScriptEvent> {
|
|
|
104
106
|
}
|
|
105
107
|
export interface ScriptEventResponsePayload {
|
|
106
108
|
id: string;
|
|
107
|
-
response:
|
|
109
|
+
response: TODO;
|
|
108
110
|
}
|
|
109
111
|
export interface ScriptEventErrorPayload {
|
|
110
112
|
id: string;
|
|
@@ -116,22 +118,22 @@ export type ScriptEventData<T extends ScriptEvent> = T extends ScriptEvent ? {
|
|
|
116
118
|
} : never;
|
|
117
119
|
export interface ScriptWorkerMessageData {
|
|
118
120
|
type: string;
|
|
119
|
-
payload:
|
|
121
|
+
payload: TODO;
|
|
120
122
|
}
|
|
121
123
|
export interface ScriptEvaluatorClientFactory {
|
|
122
124
|
create: () => Promise<ScriptEvaluatorClient>;
|
|
123
125
|
}
|
|
124
126
|
export declare abstract class ScriptEvaluatorClient {
|
|
125
127
|
abstract subscribe<T extends ScriptEvent>(type: T, handler: (type: T, e: ScriptEventData<T>) => void): void;
|
|
126
|
-
abstract send(type: string, payload:
|
|
127
|
-
abstract onError(handler: (err:
|
|
128
|
+
abstract send(type: string, payload: TODO): void;
|
|
129
|
+
abstract onError(handler: (err: TODO) => void): void;
|
|
128
130
|
abstract destroy(): void;
|
|
129
131
|
sendResponse<T extends ScriptEvent>(type: T, payload: ScriptEventResponsePayload): void;
|
|
130
132
|
sendError<T extends ScriptEvent>(type: T, payload: ScriptEventErrorPayload): void;
|
|
131
133
|
}
|
|
132
134
|
export declare abstract class ScriptEvaluatorWorker {
|
|
133
135
|
abstract onMessage(handler: (e: ScriptWorkerMessageData) => void): void;
|
|
134
|
-
abstract send(type: string, payload:
|
|
135
|
-
abstract onError(handler: (err:
|
|
136
|
+
abstract send(type: string, payload: TODO): void;
|
|
137
|
+
abstract onError(handler: (err: TODO) => void): void;
|
|
136
138
|
}
|
|
137
139
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { BaseDocument, BaseOwnableDocument } from '../shared';
|
|
|
2
2
|
import { PostrequestState } from './postrequest.interfaces';
|
|
3
3
|
import { PrerequestState } from './prerequest.interfaces';
|
|
4
4
|
import { ExportWindowState } from './window.interfaces';
|
|
5
|
+
import { HeaderState } from './header.interfaces';
|
|
5
6
|
export type SortByOptions = 'a-z' | 'z-a' | 'newest' | 'oldest' | 'none';
|
|
6
7
|
export type EntityStorageType = 'local' | 'api';
|
|
7
8
|
export interface CollectionState {
|
|
@@ -25,6 +26,14 @@ export interface IQueryCollection extends BaseDocument {
|
|
|
25
26
|
description?: string;
|
|
26
27
|
preRequest?: PrerequestState;
|
|
27
28
|
postRequest?: PostrequestState;
|
|
29
|
+
/**
|
|
30
|
+
* Headers to be inherited by all queries in this collection
|
|
31
|
+
*/
|
|
32
|
+
headers?: HeaderState;
|
|
33
|
+
/**
|
|
34
|
+
* Environment variables to be inherited by all queries in this collection
|
|
35
|
+
*/
|
|
36
|
+
environmentVariables?: Record<string, unknown>;
|
|
28
37
|
/**
|
|
29
38
|
* path of the collection in the collection tree
|
|
30
39
|
* e.g. '/123/456'
|
|
@@ -7,13 +7,17 @@ export interface FieldDocView {
|
|
|
7
7
|
name: string;
|
|
8
8
|
parentType: string;
|
|
9
9
|
}
|
|
10
|
+
export interface DirectiveDocView {
|
|
11
|
+
view: 'directive';
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
10
14
|
export interface RootDocView {
|
|
11
15
|
view: 'root';
|
|
12
16
|
}
|
|
13
17
|
export interface SearchDocView {
|
|
14
18
|
view: 'search';
|
|
15
19
|
}
|
|
16
|
-
export type DocView = TypeDocView | FieldDocView | RootDocView | SearchDocView;
|
|
20
|
+
export type DocView = TypeDocView | FieldDocView | DirectiveDocView | RootDocView | SearchDocView;
|
|
17
21
|
export interface DocsState {
|
|
18
22
|
showDocs: boolean;
|
|
19
23
|
isLoading: boolean;
|
|
@@ -36,4 +36,32 @@ export interface IEnvironment extends IDictionary {
|
|
|
36
36
|
headers?: IDictionary<string>;
|
|
37
37
|
accentColor?: string;
|
|
38
38
|
}
|
|
39
|
+
export declare const ENVIRONMENT_VARIABLE_SOURCE_TYPE: {
|
|
40
|
+
/**
|
|
41
|
+
* Base environment
|
|
42
|
+
*/
|
|
43
|
+
readonly BASE_ENVIRONMENT: "base";
|
|
44
|
+
/**
|
|
45
|
+
* Sub environment
|
|
46
|
+
*/
|
|
47
|
+
readonly SUB_ENVIRONMENT: "sub";
|
|
48
|
+
/**
|
|
49
|
+
* Collection environment
|
|
50
|
+
*/
|
|
51
|
+
readonly COLLECTION: "collection";
|
|
52
|
+
};
|
|
53
|
+
export type EnvironmentVariableSourceType = (typeof ENVIRONMENT_VARIABLE_SOURCE_TYPE)[keyof typeof ENVIRONMENT_VARIABLE_SOURCE_TYPE];
|
|
54
|
+
export interface EnvironmentVariableData {
|
|
55
|
+
key: string;
|
|
56
|
+
value: unknown;
|
|
57
|
+
/**
|
|
58
|
+
* The source type of the environment variable
|
|
59
|
+
*/
|
|
60
|
+
sourceType: EnvironmentVariableSourceType;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the source, for display purposes
|
|
63
|
+
*/
|
|
64
|
+
sourceName: string;
|
|
65
|
+
}
|
|
66
|
+
export type EnvironmentVariables = Record<string, EnvironmentVariableData>;
|
|
39
67
|
//# sourceMappingURL=environments.interfaces.d.ts.map
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENVIRONMENT_VARIABLE_SOURCE_TYPE = void 0;
|
|
4
|
+
exports.ENVIRONMENT_VARIABLE_SOURCE_TYPE = {
|
|
5
|
+
/**
|
|
6
|
+
* Base environment
|
|
7
|
+
*/
|
|
8
|
+
BASE_ENVIRONMENT: 'base',
|
|
9
|
+
/**
|
|
10
|
+
* Sub environment
|
|
11
|
+
*/
|
|
12
|
+
SUB_ENVIRONMENT: 'sub',
|
|
13
|
+
/**
|
|
14
|
+
* Collection environment
|
|
15
|
+
*/
|
|
16
|
+
COLLECTION: 'collection',
|
|
17
|
+
};
|
|
3
18
|
//# sourceMappingURL=environments.interfaces.js.map
|
|
@@ -24,10 +24,27 @@ export interface V3PluginStateEntry {
|
|
|
24
24
|
engine: PluginParentEngine;
|
|
25
25
|
isActive?: boolean;
|
|
26
26
|
}
|
|
27
|
+
export interface LoadingRequestStateEntry {
|
|
28
|
+
name: string;
|
|
29
|
+
id: string;
|
|
30
|
+
state: 'done' | 'error' | 'active' | 'pending';
|
|
31
|
+
source: 'collection' | 'window';
|
|
32
|
+
sourceId: string;
|
|
33
|
+
type: 'pre-request' | 'post-request' | 'query' | 'auth';
|
|
34
|
+
}
|
|
35
|
+
export interface TemporaryWindowStateEntry {
|
|
36
|
+
windowId: string;
|
|
37
|
+
loadingRequestState: LoadingRequestStateEntry[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* State for local (session) data.
|
|
41
|
+
* This would contain arbitrary global data that should be stored in memory and not persisted
|
|
42
|
+
*/
|
|
27
43
|
export interface LocalState {
|
|
28
44
|
closedWindows: PerWindowState[];
|
|
29
45
|
installedPlugins: IDictionary<V1PluginStateEntry | V3PluginStateEntry>;
|
|
30
46
|
panels: AltairPanel[];
|
|
31
47
|
uiActions: AltairUiAction[];
|
|
48
|
+
temporaryWindowStates: IDictionary<TemporaryWindowStateEntry>;
|
|
32
49
|
}
|
|
33
50
|
//# sourceMappingURL=local.interfaces.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ValueObject } from '../../utils/value-object';
|
|
2
2
|
export declare const WORKSPACES: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
LOCAL: string;
|
|
4
|
+
REMOTE: string;
|
|
5
5
|
};
|
|
6
6
|
export declare class WorkspaceId extends ValueObject<string> {
|
|
7
7
|
constructor(props?: string);
|
package/build/config/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export declare class AltairConfig {
|
|
|
66
66
|
initialAuthorization: AltairConfigOptions["initialAuthorization"];
|
|
67
67
|
};
|
|
68
68
|
constructor({ endpointURL, subscriptionsEndpoint, subscriptionsProtocol, initialQuery, initialHeaders, initialEnvironments, initialVariables, initialPreRequestScript, initialPostRequestScript, instanceStorageNamespace, initialSettings, persistedSettings, initialRequestHandlerId, initialRequestHandlerAdditionalParams, initialSubscriptionRequestHandlerId, initialSubscriptionsPayload, initialHttpMethod, preserveState, initialWindows, disableAccount, initialAuthorization, cspNonce, }?: AltairConfigOptions);
|
|
69
|
-
private
|
|
69
|
+
private getPossibleLocalSandBoxRoot;
|
|
70
70
|
private getLocalSandBoxUrl;
|
|
71
71
|
getUrlConfig(environment?: ConfigEnvironment): UrlConfig;
|
|
72
72
|
getUrlConfigWithLocal(environment?: ConfigEnvironment): Promise<UrlConfig>;
|
package/build/config/index.js
CHANGED
|
@@ -110,7 +110,7 @@ export class AltairConfig {
|
|
|
110
110
|
this.initialData.disableAccount = disableAccount;
|
|
111
111
|
this.initialData.initialAuthorization = initialAuthorization;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
getPossibleLocalSandBoxRoot() {
|
|
114
114
|
if (isExtension) {
|
|
115
115
|
// we only support mv3 extensions now
|
|
116
116
|
// and mv3 extensions doesn't allow using iframe
|
|
@@ -126,20 +126,22 @@ export class AltairConfig {
|
|
|
126
126
|
parseUrl(document.baseURI)?.origin === window.location.origin) {
|
|
127
127
|
// add iframe-sandbox path to base url
|
|
128
128
|
if (document.baseURI.endsWith('/')) {
|
|
129
|
-
return new URL(document.baseURI + 'iframe-sandbox
|
|
129
|
+
return new URL(document.baseURI + 'iframe-sandbox');
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
132
132
|
// remove the last part of the url
|
|
133
133
|
return new URL(document.baseURI.slice(0, document.baseURI.lastIndexOf('/') + 1) +
|
|
134
|
-
'iframe-sandbox
|
|
134
|
+
'iframe-sandbox');
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
async getLocalSandBoxUrl() {
|
|
139
139
|
if (typeof this.localSandboxUrl === 'undefined') {
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
|
|
140
|
+
const localSandboxRoot = this.getPossibleLocalSandBoxRoot()?.href ?? '';
|
|
141
|
+
if (localSandboxRoot) {
|
|
142
|
+
this.localSandboxUrl = localSandboxRoot + '/index.html';
|
|
143
|
+
const localSandboxTestUrl = localSandboxRoot + '/sandbox.png';
|
|
144
|
+
const res = await fetch(localSandboxTestUrl);
|
|
143
145
|
if (res.ok) {
|
|
144
146
|
this.useLocalSandboxUrl = true;
|
|
145
147
|
}
|
|
@@ -20,7 +20,7 @@ describe('oauth2 helpers', () => {
|
|
|
20
20
|
});
|
|
21
21
|
describe('base64UrlEncode', () => {
|
|
22
22
|
it('should encode a string to base64url', () => {
|
|
23
|
-
const out = base64UrlEncode(new TextEncoder().encode('hello world'));
|
|
23
|
+
const out = base64UrlEncode(new TextEncoder().encode('hello world').buffer);
|
|
24
24
|
expect(out).toBe('aGVsbG8gd29ybGQ');
|
|
25
25
|
});
|
|
26
26
|
});
|
package/build/script/context.js
CHANGED
|
@@ -79,6 +79,7 @@ export const getGlobalContext = (data, handlers) => {
|
|
|
79
79
|
log: (d) => {
|
|
80
80
|
data.requestScriptLogs = data.requestScriptLogs ?? [];
|
|
81
81
|
data.requestScriptLogs.push({
|
|
82
|
+
id: crypto.randomUUID(),
|
|
82
83
|
time: Date.now(),
|
|
83
84
|
text: JSON.stringify(d, null, 2),
|
|
84
85
|
source: 'Request script',
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ScriptContextData, ScriptEvaluatorClientFactory, ScriptEventHandlers,
|
|
1
|
+
import { ScriptContextData, ScriptEvaluatorClientFactory, ScriptEventHandlers, ScriptTransformResult } from './types';
|
|
2
2
|
export declare class ScriptEvaluatorClientEngine {
|
|
3
3
|
private engineFactory;
|
|
4
4
|
private timeout;
|
|
5
5
|
private client?;
|
|
6
6
|
constructor(engineFactory: ScriptEvaluatorClientFactory, timeout?: number);
|
|
7
7
|
private getClient;
|
|
8
|
-
executeScript(script: string, data: ScriptContextData, userAvailableHandlers: ScriptEventHandlers): Promise<
|
|
8
|
+
executeScript(script: string, data: ScriptContextData, userAvailableHandlers: ScriptEventHandlers): Promise<ScriptTransformResult>;
|
|
9
9
|
private killClient;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=evaluator-client-engine.d.ts.map
|
package/build/script/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDictionary } from '../types/shared';
|
|
1
|
+
import { IDictionary, TODO } from '../types/shared';
|
|
2
2
|
import { IEnvironment } from '../types/state/environments.interfaces';
|
|
3
3
|
import { HeaderState } from '../types/state/header.interfaces';
|
|
4
4
|
import { LogLine } from '../types/state/query.interfaces';
|
|
@@ -23,7 +23,7 @@ export interface ScriptContextHelpers {
|
|
|
23
23
|
setEnvironment: (key: string, value: unknown, activeEnvironment?: boolean) => void;
|
|
24
24
|
getCookie: (key: string) => string;
|
|
25
25
|
setCookie: (key: string, value: string) => void;
|
|
26
|
-
request: (arg1: string, arg2: string, arg3:
|
|
26
|
+
request: (arg1: string, arg2: string, arg3: TODO) => Promise<ArrayBuffer | null>;
|
|
27
27
|
}
|
|
28
28
|
export interface ScriptContextStorage {
|
|
29
29
|
get: (key: string) => Promise<unknown>;
|
|
@@ -58,11 +58,13 @@ export interface GlobalHelperContext {
|
|
|
58
58
|
log: (d: unknown) => void;
|
|
59
59
|
response?: ScriptContextResponse;
|
|
60
60
|
}
|
|
61
|
-
export interface
|
|
61
|
+
export interface ScriptTransformResult {
|
|
62
62
|
requestScriptLogs: LogLine[];
|
|
63
|
-
additionalHeaders: HeaderState;
|
|
64
63
|
environment?: IEnvironment;
|
|
65
64
|
}
|
|
65
|
+
export interface FullTransformResult extends ScriptTransformResult {
|
|
66
|
+
combinedHeaders: HeaderState;
|
|
67
|
+
}
|
|
66
68
|
export type SameSite = 'Lax' | 'None' | 'Strict';
|
|
67
69
|
export interface CookieOptions {
|
|
68
70
|
expires?: number | Date;
|
|
@@ -85,7 +87,7 @@ export interface ModuleImportsMap {
|
|
|
85
87
|
export interface ScriptEventHandlers {
|
|
86
88
|
alert: (msg: string) => Promise<void>;
|
|
87
89
|
log: (d: unknown) => Promise<void>;
|
|
88
|
-
request: (arg1: string, arg2: string, arg3:
|
|
90
|
+
request: (arg1: string, arg2: string, arg3: TODO) => Promise<TODO>;
|
|
89
91
|
setCookie: (key: string, value: string, options?: CookieOptions) => Promise<void>;
|
|
90
92
|
getStorageItem: (key: string) => Promise<unknown>;
|
|
91
93
|
setStorageItem: (key: string, value: unknown) => Promise<void>;
|
|
@@ -104,7 +106,7 @@ export interface ScriptEventDataPayload<T extends ScriptEvent> {
|
|
|
104
106
|
}
|
|
105
107
|
export interface ScriptEventResponsePayload {
|
|
106
108
|
id: string;
|
|
107
|
-
response:
|
|
109
|
+
response: TODO;
|
|
108
110
|
}
|
|
109
111
|
export interface ScriptEventErrorPayload {
|
|
110
112
|
id: string;
|
|
@@ -116,22 +118,22 @@ export type ScriptEventData<T extends ScriptEvent> = T extends ScriptEvent ? {
|
|
|
116
118
|
} : never;
|
|
117
119
|
export interface ScriptWorkerMessageData {
|
|
118
120
|
type: string;
|
|
119
|
-
payload:
|
|
121
|
+
payload: TODO;
|
|
120
122
|
}
|
|
121
123
|
export interface ScriptEvaluatorClientFactory {
|
|
122
124
|
create: () => Promise<ScriptEvaluatorClient>;
|
|
123
125
|
}
|
|
124
126
|
export declare abstract class ScriptEvaluatorClient {
|
|
125
127
|
abstract subscribe<T extends ScriptEvent>(type: T, handler: (type: T, e: ScriptEventData<T>) => void): void;
|
|
126
|
-
abstract send(type: string, payload:
|
|
127
|
-
abstract onError(handler: (err:
|
|
128
|
+
abstract send(type: string, payload: TODO): void;
|
|
129
|
+
abstract onError(handler: (err: TODO) => void): void;
|
|
128
130
|
abstract destroy(): void;
|
|
129
131
|
sendResponse<T extends ScriptEvent>(type: T, payload: ScriptEventResponsePayload): void;
|
|
130
132
|
sendError<T extends ScriptEvent>(type: T, payload: ScriptEventErrorPayload): void;
|
|
131
133
|
}
|
|
132
134
|
export declare abstract class ScriptEvaluatorWorker {
|
|
133
135
|
abstract onMessage(handler: (e: ScriptWorkerMessageData) => void): void;
|
|
134
|
-
abstract send(type: string, payload:
|
|
135
|
-
abstract onError(handler: (err:
|
|
136
|
+
abstract send(type: string, payload: TODO): void;
|
|
137
|
+
abstract onError(handler: (err: TODO) => void): void;
|
|
136
138
|
}
|
|
137
139
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -2,6 +2,7 @@ import { BaseDocument, BaseOwnableDocument } from '../shared';
|
|
|
2
2
|
import { PostrequestState } from './postrequest.interfaces';
|
|
3
3
|
import { PrerequestState } from './prerequest.interfaces';
|
|
4
4
|
import { ExportWindowState } from './window.interfaces';
|
|
5
|
+
import { HeaderState } from './header.interfaces';
|
|
5
6
|
export type SortByOptions = 'a-z' | 'z-a' | 'newest' | 'oldest' | 'none';
|
|
6
7
|
export type EntityStorageType = 'local' | 'api';
|
|
7
8
|
export interface CollectionState {
|
|
@@ -25,6 +26,14 @@ export interface IQueryCollection extends BaseDocument {
|
|
|
25
26
|
description?: string;
|
|
26
27
|
preRequest?: PrerequestState;
|
|
27
28
|
postRequest?: PostrequestState;
|
|
29
|
+
/**
|
|
30
|
+
* Headers to be inherited by all queries in this collection
|
|
31
|
+
*/
|
|
32
|
+
headers?: HeaderState;
|
|
33
|
+
/**
|
|
34
|
+
* Environment variables to be inherited by all queries in this collection
|
|
35
|
+
*/
|
|
36
|
+
environmentVariables?: Record<string, unknown>;
|
|
28
37
|
/**
|
|
29
38
|
* path of the collection in the collection tree
|
|
30
39
|
* e.g. '/123/456'
|
|
@@ -7,13 +7,17 @@ export interface FieldDocView {
|
|
|
7
7
|
name: string;
|
|
8
8
|
parentType: string;
|
|
9
9
|
}
|
|
10
|
+
export interface DirectiveDocView {
|
|
11
|
+
view: 'directive';
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
10
14
|
export interface RootDocView {
|
|
11
15
|
view: 'root';
|
|
12
16
|
}
|
|
13
17
|
export interface SearchDocView {
|
|
14
18
|
view: 'search';
|
|
15
19
|
}
|
|
16
|
-
export type DocView = TypeDocView | FieldDocView | RootDocView | SearchDocView;
|
|
20
|
+
export type DocView = TypeDocView | FieldDocView | DirectiveDocView | RootDocView | SearchDocView;
|
|
17
21
|
export interface DocsState {
|
|
18
22
|
showDocs: boolean;
|
|
19
23
|
isLoading: boolean;
|
|
@@ -36,4 +36,32 @@ export interface IEnvironment extends IDictionary {
|
|
|
36
36
|
headers?: IDictionary<string>;
|
|
37
37
|
accentColor?: string;
|
|
38
38
|
}
|
|
39
|
+
export declare const ENVIRONMENT_VARIABLE_SOURCE_TYPE: {
|
|
40
|
+
/**
|
|
41
|
+
* Base environment
|
|
42
|
+
*/
|
|
43
|
+
readonly BASE_ENVIRONMENT: "base";
|
|
44
|
+
/**
|
|
45
|
+
* Sub environment
|
|
46
|
+
*/
|
|
47
|
+
readonly SUB_ENVIRONMENT: "sub";
|
|
48
|
+
/**
|
|
49
|
+
* Collection environment
|
|
50
|
+
*/
|
|
51
|
+
readonly COLLECTION: "collection";
|
|
52
|
+
};
|
|
53
|
+
export type EnvironmentVariableSourceType = (typeof ENVIRONMENT_VARIABLE_SOURCE_TYPE)[keyof typeof ENVIRONMENT_VARIABLE_SOURCE_TYPE];
|
|
54
|
+
export interface EnvironmentVariableData {
|
|
55
|
+
key: string;
|
|
56
|
+
value: unknown;
|
|
57
|
+
/**
|
|
58
|
+
* The source type of the environment variable
|
|
59
|
+
*/
|
|
60
|
+
sourceType: EnvironmentVariableSourceType;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the source, for display purposes
|
|
63
|
+
*/
|
|
64
|
+
sourceName: string;
|
|
65
|
+
}
|
|
66
|
+
export type EnvironmentVariables = Record<string, EnvironmentVariableData>;
|
|
39
67
|
//# sourceMappingURL=environments.interfaces.d.ts.map
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export const ENVIRONMENT_VARIABLE_SOURCE_TYPE = {
|
|
2
|
+
/**
|
|
3
|
+
* Base environment
|
|
4
|
+
*/
|
|
5
|
+
BASE_ENVIRONMENT: 'base',
|
|
6
|
+
/**
|
|
7
|
+
* Sub environment
|
|
8
|
+
*/
|
|
9
|
+
SUB_ENVIRONMENT: 'sub',
|
|
10
|
+
/**
|
|
11
|
+
* Collection environment
|
|
12
|
+
*/
|
|
13
|
+
COLLECTION: 'collection',
|
|
14
|
+
};
|
|
2
15
|
//# sourceMappingURL=environments.interfaces.js.map
|
|
@@ -24,10 +24,27 @@ export interface V3PluginStateEntry {
|
|
|
24
24
|
engine: PluginParentEngine;
|
|
25
25
|
isActive?: boolean;
|
|
26
26
|
}
|
|
27
|
+
export interface LoadingRequestStateEntry {
|
|
28
|
+
name: string;
|
|
29
|
+
id: string;
|
|
30
|
+
state: 'done' | 'error' | 'active' | 'pending';
|
|
31
|
+
source: 'collection' | 'window';
|
|
32
|
+
sourceId: string;
|
|
33
|
+
type: 'pre-request' | 'post-request' | 'query' | 'auth';
|
|
34
|
+
}
|
|
35
|
+
export interface TemporaryWindowStateEntry {
|
|
36
|
+
windowId: string;
|
|
37
|
+
loadingRequestState: LoadingRequestStateEntry[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* State for local (session) data.
|
|
41
|
+
* This would contain arbitrary global data that should be stored in memory and not persisted
|
|
42
|
+
*/
|
|
27
43
|
export interface LocalState {
|
|
28
44
|
closedWindows: PerWindowState[];
|
|
29
45
|
installedPlugins: IDictionary<V1PluginStateEntry | V3PluginStateEntry>;
|
|
30
46
|
panels: AltairPanel[];
|
|
31
47
|
uiActions: AltairUiAction[];
|
|
48
|
+
temporaryWindowStates: IDictionary<TemporaryWindowStateEntry>;
|
|
32
49
|
}
|
|
33
50
|
//# sourceMappingURL=local.interfaces.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ValueObject } from '../../utils/value-object';
|
|
2
2
|
export declare const WORKSPACES: {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
LOCAL: string;
|
|
4
|
+
REMOTE: string;
|
|
5
5
|
};
|
|
6
6
|
export declare class WorkspaceId extends ValueObject<string> {
|
|
7
7
|
constructor(props?: string);
|
package/jest.config.js
CHANGED
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": "8.
|
|
4
|
+
"version": "8.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": {
|
|
@@ -54,13 +54,14 @@
|
|
|
54
54
|
"eslint-config-prettier": "^9.1.0",
|
|
55
55
|
"eslint-plugin-prettier": "^5.1.3",
|
|
56
56
|
"jest": "^29.7.0",
|
|
57
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
57
58
|
"msw": "^2.3.1",
|
|
58
59
|
"prettier": "^3.2.5",
|
|
59
60
|
"react": "17.0.2",
|
|
60
61
|
"shx": "^0.3.4",
|
|
61
62
|
"ts-jest": "^29.1.2",
|
|
62
63
|
"ts-node": "9.1.1",
|
|
63
|
-
"typescript": "^5.
|
|
64
|
+
"typescript": "^5.8.0",
|
|
64
65
|
"typescript-json-schema": "0.50.1",
|
|
65
66
|
"undici": "^6.19.1"
|
|
66
67
|
},
|