first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHttpRequestMethods,
|
||||
IHttpRequestOptions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { IAirtopResponse } from './types';
|
||||
import { BASE_URL, N8N_VERSION } from '../constants';
|
||||
|
||||
const defaultHeaders = {
|
||||
'Content-Type': 'application/json',
|
||||
'x-airtop-sdk-environment': 'n8n',
|
||||
'x-airtop-sdk-version': N8N_VERSION,
|
||||
};
|
||||
|
||||
export async function apiRequest<T extends IAirtopResponse = IAirtopResponse>(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<T> {
|
||||
const options: IHttpRequestOptions = {
|
||||
headers: defaultHeaders,
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
url: endpoint.startsWith('http') ? endpoint : `${BASE_URL}${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
return await this.helpers.httpRequestWithAuthentication.call<
|
||||
IExecuteFunctions | ILoadOptionsFunctions,
|
||||
[string, IHttpRequestOptions],
|
||||
Promise<T>
|
||||
>(this, 'airtopApi', options);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
export interface IAirtopSessionResponse extends IDataObject {
|
||||
data: {
|
||||
id: string;
|
||||
status: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IAirtopResponse extends IDataObject {
|
||||
sessionId?: string;
|
||||
windowId?: string;
|
||||
data?: IDataObject & {
|
||||
windowId?: string;
|
||||
modelResponse?: string;
|
||||
files?: IDataObject[];
|
||||
};
|
||||
meta?: IDataObject & {
|
||||
status?: string;
|
||||
screenshots?: Array<{ dataUrl: string }>;
|
||||
};
|
||||
errors?: IDataObject[];
|
||||
warnings?: IDataObject[];
|
||||
output?: IDataObject;
|
||||
}
|
||||
|
||||
export interface IAirtopResponseWithFiles extends IAirtopResponse {
|
||||
data: {
|
||||
files: IDataObject[];
|
||||
fileName?: string;
|
||||
status?: string;
|
||||
downloadUrl?: string;
|
||||
pagination: {
|
||||
hasMore: boolean;
|
||||
};
|
||||
sessionIds?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IAirtopInteractionRequest extends IDataObject {
|
||||
text?: string;
|
||||
waitForNavigation?: boolean;
|
||||
elementDescription?: string;
|
||||
pressEnterKey?: boolean;
|
||||
// scroll parameters
|
||||
scrollToElement?: string;
|
||||
scrollWithin?: string;
|
||||
scrollToEdge?: {
|
||||
xAxis?: string;
|
||||
yAxis?: string;
|
||||
};
|
||||
scrollBy?: {
|
||||
xAxis?: string;
|
||||
yAxis?: string;
|
||||
};
|
||||
// configuration
|
||||
configuration: {
|
||||
visualAnalysis?: {
|
||||
scope: string;
|
||||
};
|
||||
waitForNavigationConfig?: {
|
||||
waitUntil: string;
|
||||
};
|
||||
clickType?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IAirtopFileInputRequest extends IDataObject {
|
||||
fileId: string;
|
||||
windowId: string;
|
||||
sessionId: string;
|
||||
elementDescription?: string;
|
||||
includeHiddenElements?: boolean;
|
||||
}
|
||||
|
||||
export interface IAirtopNodeExecutionData extends INodeExecutionData {
|
||||
json: IAirtopResponse;
|
||||
}
|
||||
|
||||
export interface IAirtopServerEvent {
|
||||
event: string;
|
||||
eventData: {
|
||||
error?: string;
|
||||
};
|
||||
fileId?: string;
|
||||
status?: string;
|
||||
downloadUrl?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user