simplex-ts 1.1.12 → 2.0.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/README.md +163 -56
- package/dist/SimplexClient.d.ts +13 -0
- package/dist/SimplexClient.d.ts.map +1 -0
- package/dist/SimplexClient.js +31 -0
- package/dist/SimplexClient.js.map +1 -0
- package/dist/client/HttpClient.d.ts +33 -0
- package/dist/client/HttpClient.d.ts.map +1 -0
- package/dist/client/HttpClient.js +149 -0
- package/dist/client/HttpClient.js.map +1 -0
- package/dist/errors/index.d.ts +22 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +55 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +4 -43
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -399
- package/dist/index.js.map +1 -1
- package/dist/resources/Agent.d.ts +13 -0
- package/dist/resources/Agent.d.ts.map +1 -0
- package/dist/resources/Agent.js +53 -0
- package/dist/resources/Agent.js.map +1 -0
- package/dist/resources/Workflow.d.ts +38 -0
- package/dist/resources/Workflow.d.ts.map +1 -0
- package/dist/resources/Workflow.js +124 -0
- package/dist/resources/Workflow.js.map +1 -0
- package/dist/types/index.d.ts +80 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +22 -26
- package/dist/index.d.mts +0 -43
- package/dist/index.mjs +0 -366
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,81 +1,188 @@
|
|
|
1
|
-
# Simplex TypeScript
|
|
1
|
+
# Simplex TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official TypeScript SDK for the Simplex API.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Content extraction (text, images, bounding boxes)
|
|
11
|
-
- File upload and download capabilities
|
|
12
|
-
- TypeScript support with type definitions
|
|
13
|
-
- Built with modern tooling (ESM + CommonJS output)
|
|
7
|
+
```bash
|
|
8
|
+
npm install simplex-typescript-sdk
|
|
9
|
+
```
|
|
14
10
|
|
|
15
|
-
##
|
|
11
|
+
## Quick Start
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
```typescript
|
|
14
|
+
import { SimplexClient } from 'simplex-typescript-sdk';
|
|
15
|
+
|
|
16
|
+
const client = new SimplexClient({
|
|
17
|
+
apiKey: 'YOUR_API_KEY_HERE'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Run a workflow
|
|
21
|
+
const result = await client.workflows.run('workflow-id', {
|
|
22
|
+
variables: {
|
|
23
|
+
username: 'john_doe',
|
|
24
|
+
product_id: '12345'
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log('Session ID:', result.session_id);
|
|
20
29
|
```
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const client = new SimplexClient({
|
|
35
|
+
apiKey: 'YOUR_API_KEY_HERE',
|
|
36
|
+
baseURL: 'https://api.simplex.sh', // Optional
|
|
37
|
+
timeout: 30000, // Optional: Request timeout in ms
|
|
38
|
+
maxRetries: 3, // Optional: Number of retries
|
|
39
|
+
retryDelay: 1000 // Optional: Delay between retries in ms
|
|
40
|
+
});
|
|
25
41
|
```
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
## API Methods
|
|
44
|
+
|
|
45
|
+
### Workflows
|
|
46
|
+
|
|
47
|
+
#### Run a workflow
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const result = await client.workflows.run('workflow-id', {
|
|
51
|
+
variables: { key: 'value' },
|
|
52
|
+
metadata: 'optional-metadata',
|
|
53
|
+
webhookUrl: 'https://your-webhook.com'
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Run with variables only
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
const result = await client.workflows.runWithVariables('workflow-id', {
|
|
61
|
+
key: 'value'
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Create a workflow session
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const session = await client.workflows.createWorkflowSession(
|
|
69
|
+
'my-workflow-name',
|
|
70
|
+
'https://example.com',
|
|
71
|
+
{
|
|
72
|
+
sessionData: { key: 'value' },
|
|
73
|
+
proxies: false
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
console.log('Session ID:', session.session_id);
|
|
78
|
+
console.log('Livestream URL:', session.livestream_url);
|
|
30
79
|
```
|
|
31
80
|
|
|
32
|
-
|
|
81
|
+
### Agents
|
|
82
|
+
|
|
83
|
+
#### Run an agent task
|
|
84
|
+
|
|
85
|
+
Execute a specific task using the agentic endpoint:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const result = await client.agents.agentic(
|
|
89
|
+
'Find and click the login button',
|
|
90
|
+
'session-id',
|
|
91
|
+
{
|
|
92
|
+
maxSteps: 10,
|
|
93
|
+
actionsToExclude: ['scroll', 'wait'],
|
|
94
|
+
variables: { username: 'user@example.com' }
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
console.log('Task succeeded:', result.succeeded);
|
|
99
|
+
console.log('Result:', result.result);
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Run a named agent
|
|
103
|
+
|
|
104
|
+
Run a pre-configured agent by name:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const result = await client.agents.run(
|
|
108
|
+
'my-agent-name',
|
|
109
|
+
'session-id',
|
|
110
|
+
{
|
|
111
|
+
key1: 'value1',
|
|
112
|
+
key2: 'value2'
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
console.log('Agent succeeded:', result.succeeded);
|
|
117
|
+
console.log('Session ID:', result.session_id);
|
|
118
|
+
console.log('Result:', result.result);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Error Handling
|
|
122
|
+
|
|
123
|
+
The SDK provides typed error classes for different error scenarios:
|
|
33
124
|
|
|
34
125
|
```typescript
|
|
35
|
-
import {
|
|
126
|
+
import {
|
|
127
|
+
SimplexClient,
|
|
128
|
+
WorkflowError,
|
|
129
|
+
ValidationError,
|
|
130
|
+
AuthenticationError,
|
|
131
|
+
RateLimitError,
|
|
132
|
+
NetworkError
|
|
133
|
+
} from 'simplex-typescript-sdk';
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const result = await client.workflows.run('workflow-id');
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof WorkflowError) {
|
|
139
|
+
console.error('Workflow failed:', error.message);
|
|
140
|
+
} else if (error instanceof ValidationError) {
|
|
141
|
+
console.error('Invalid request:', error.message);
|
|
142
|
+
} else if (error instanceof AuthenticationError) {
|
|
143
|
+
console.error('Authentication failed:', error.message);
|
|
144
|
+
} else if (error instanceof RateLimitError) {
|
|
145
|
+
console.error('Rate limited. Retry after:', error.retryAfter);
|
|
146
|
+
} else if (error instanceof NetworkError) {
|
|
147
|
+
console.error('Network error:', error.message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Examples
|
|
153
|
+
|
|
154
|
+
The SDK includes several example files to demonstrate different use cases:
|
|
36
155
|
|
|
37
|
-
|
|
38
|
-
|
|
156
|
+
- **`examples/basic-usage.ts`** - Basic workflow execution and status checking
|
|
157
|
+
- **`examples/agent-usage.ts`** - Using the agentic endpoints for task execution
|
|
158
|
+
- **`examples/agent-workflow.ts`** - Creating a workflow with sequential agent tasks
|
|
159
|
+
- **`examples/agent-workflow-advanced.ts`** - Advanced workflow patterns with error handling
|
|
160
|
+
|
|
161
|
+
Run examples with:
|
|
162
|
+
```bash
|
|
163
|
+
npx tsx examples/basic-usage.ts
|
|
164
|
+
npx tsx examples/agent-workflow.ts
|
|
165
|
+
```
|
|
39
166
|
|
|
40
|
-
|
|
41
|
-
const [sessionId, livestreamUrl] = await simplex.createSession();
|
|
167
|
+
## Development
|
|
42
168
|
|
|
43
|
-
|
|
44
|
-
await simplex.goto('example.com');
|
|
169
|
+
### Build the SDK
|
|
45
170
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
await simplex.pressEnter();
|
|
171
|
+
```bash
|
|
172
|
+
npm run build
|
|
173
|
+
```
|
|
50
174
|
|
|
51
|
-
|
|
52
|
-
const text = await simplex.extractText('Welcome message');
|
|
53
|
-
console.log(text);
|
|
175
|
+
### Watch mode
|
|
54
176
|
|
|
55
|
-
|
|
56
|
-
|
|
177
|
+
```bash
|
|
178
|
+
npm run dev
|
|
57
179
|
```
|
|
58
180
|
|
|
59
|
-
###
|
|
60
|
-
|
|
61
|
-
- `createSession()` - Start a new browser session
|
|
62
|
-
- `goto(url)` - Navigate to a URL
|
|
63
|
-
- `click(elementDescription)` - Click an element
|
|
64
|
-
- `type(text)` - Type text
|
|
65
|
-
- `pressEnter()` - Press Enter key
|
|
66
|
-
- `pressTab()` - Press Tab key
|
|
67
|
-
- `deleteText()` - Delete text
|
|
68
|
-
- `extractBbox(elementDescription)` - Get element bounding box
|
|
69
|
-
- `extractText(elementDescription)` - Extract text from element
|
|
70
|
-
- `extractImage(elementDescription)` - Extract image from element
|
|
71
|
-
- `scroll(pixels)` - Scroll page
|
|
72
|
-
- `wait(milliseconds)` - Wait for specified duration
|
|
73
|
-
- `clickAndUpload(elementDescription, file)` - Click and upload file
|
|
74
|
-
- `clickAndDownload(elementDescription)` - Click and download file
|
|
75
|
-
- `exists(elementDescription)` - Check if element exists
|
|
76
|
-
- `enqueueActions(action_array)` - Experimental, ask in Slack if you're using this!
|
|
77
|
-
- `closeSession()` - Close the browser session
|
|
181
|
+
### Clean build files
|
|
78
182
|
|
|
183
|
+
```bash
|
|
184
|
+
npm run clean
|
|
185
|
+
```
|
|
79
186
|
|
|
80
187
|
## License
|
|
81
188
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Workflow } from './resources/Workflow';
|
|
2
|
+
import { Agent } from './resources/Agent';
|
|
3
|
+
import { SimplexClientOptions } from './types';
|
|
4
|
+
export declare class SimplexClient {
|
|
5
|
+
private httpClient;
|
|
6
|
+
workflows: Workflow;
|
|
7
|
+
agents: Agent;
|
|
8
|
+
constructor(options: SimplexClientOptions);
|
|
9
|
+
updateApiKey(apiKey: string): void;
|
|
10
|
+
setCustomHeader(key: string, value: string): void;
|
|
11
|
+
removeCustomHeader(key: string): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=SimplexClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimplexClient.d.ts","sourceRoot":"","sources":["../src/SimplexClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAa;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC;gBAET,OAAO,EAAE,oBAAoB;IAezC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIlC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAIjD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAGtC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimplexClient = void 0;
|
|
4
|
+
const HttpClient_1 = require("./client/HttpClient");
|
|
5
|
+
const Workflow_1 = require("./resources/Workflow");
|
|
6
|
+
const Agent_1 = require("./resources/Agent");
|
|
7
|
+
class SimplexClient {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
const baseURL = options.baseURL || 'https://api.simplex.sh';
|
|
10
|
+
this.httpClient = new HttpClient_1.HttpClient({
|
|
11
|
+
baseURL,
|
|
12
|
+
apiKey: options.apiKey,
|
|
13
|
+
timeout: options.timeout,
|
|
14
|
+
retryAttempts: options.maxRetries,
|
|
15
|
+
retryDelay: options.retryDelay,
|
|
16
|
+
});
|
|
17
|
+
this.workflows = new Workflow_1.Workflow(this.httpClient);
|
|
18
|
+
this.agents = new Agent_1.Agent(this.httpClient);
|
|
19
|
+
}
|
|
20
|
+
updateApiKey(apiKey) {
|
|
21
|
+
this.httpClient.updateApiKey(apiKey);
|
|
22
|
+
}
|
|
23
|
+
setCustomHeader(key, value) {
|
|
24
|
+
this.httpClient.setHeader(key, value);
|
|
25
|
+
}
|
|
26
|
+
removeCustomHeader(key) {
|
|
27
|
+
this.httpClient.removeHeader(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SimplexClient = SimplexClient;
|
|
31
|
+
//# sourceMappingURL=SimplexClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimplexClient.js","sourceRoot":"","sources":["../src/SimplexClient.ts"],"names":[],"mappings":";;;AAAA,oDAAiD;AACjD,mDAAgD;AAChD,6CAA0C;AAG1C,MAAa,aAAa;IAKxB,YAAY,OAA6B;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,wBAAwB,CAAC;QAE5D,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC;YAC/B,OAAO;YACP,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,aAAa,EAAE,OAAO,CAAC,UAAU;YACjC,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,aAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,YAAY,CAAC,MAAc;QACzB,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,eAAe,CAAC,GAAW,EAAE,KAAa;QACxC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,kBAAkB,CAAC,GAAW;QAC5B,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACF;AA/BD,sCA+BC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
export interface HttpClientConfig {
|
|
3
|
+
baseURL: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
retryAttempts?: number;
|
|
8
|
+
retryDelay?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface RequestOptions extends Omit<AxiosRequestConfig, 'baseURL'> {
|
|
11
|
+
retries?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class HttpClient {
|
|
14
|
+
private client;
|
|
15
|
+
private config;
|
|
16
|
+
constructor(config: HttpClientConfig);
|
|
17
|
+
private setupInterceptors;
|
|
18
|
+
private shouldRetry;
|
|
19
|
+
private delay;
|
|
20
|
+
private handleError;
|
|
21
|
+
private extractErrorMessage;
|
|
22
|
+
private extractRetryAfter;
|
|
23
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
24
|
+
post<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
25
|
+
postJSON<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
26
|
+
put<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
27
|
+
patch<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
28
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
29
|
+
setHeader(key: string, value: string): void;
|
|
30
|
+
removeHeader(key: string): void;
|
|
31
|
+
updateApiKey(apiKey: string): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=HttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/client/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAc,EAAiB,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAG5F,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAA6B;gBAE/B,MAAM,EAAE,gBAAgB;IAsBpC,OAAO,CAAC,iBAAiB;IA2BzB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,iBAAiB;IASnB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAK1D,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAsBvE,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAW3E,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAKxE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAKnE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI3C,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI/B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGnC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
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.HttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
class HttpClient {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = {
|
|
12
|
+
timeout: 30000,
|
|
13
|
+
headers: {},
|
|
14
|
+
retryAttempts: 3,
|
|
15
|
+
retryDelay: 1000,
|
|
16
|
+
...config,
|
|
17
|
+
};
|
|
18
|
+
this.client = axios_1.default.create({
|
|
19
|
+
baseURL: this.config.baseURL,
|
|
20
|
+
timeout: this.config.timeout,
|
|
21
|
+
headers: {
|
|
22
|
+
'X-API-Key': this.config.apiKey,
|
|
23
|
+
'User-Agent': 'Simplex-TypeScript-SDK/1.0.0',
|
|
24
|
+
...this.config.headers,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
this.setupInterceptors();
|
|
28
|
+
}
|
|
29
|
+
setupInterceptors() {
|
|
30
|
+
this.client.interceptors.request.use((config) => {
|
|
31
|
+
return config;
|
|
32
|
+
}, (error) => {
|
|
33
|
+
return Promise.reject(this.handleError(error));
|
|
34
|
+
});
|
|
35
|
+
this.client.interceptors.response.use((response) => response, async (error) => {
|
|
36
|
+
const config = error.config;
|
|
37
|
+
const retries = config.retries ?? this.config.retryAttempts;
|
|
38
|
+
if (this.shouldRetry(error) && retries > 0) {
|
|
39
|
+
config.retries = retries - 1;
|
|
40
|
+
await this.delay(this.config.retryDelay);
|
|
41
|
+
return this.client.request(config);
|
|
42
|
+
}
|
|
43
|
+
return Promise.reject(this.handleError(error));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
shouldRetry(error) {
|
|
47
|
+
if (!error.response) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const status = error.response.status;
|
|
51
|
+
return status === 429 || status === 503 || status >= 500;
|
|
52
|
+
}
|
|
53
|
+
delay(ms) {
|
|
54
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
55
|
+
}
|
|
56
|
+
handleError(error) {
|
|
57
|
+
if (!error.response) {
|
|
58
|
+
return new errors_1.NetworkError(error.message);
|
|
59
|
+
}
|
|
60
|
+
const status = error.response.status;
|
|
61
|
+
const message = this.extractErrorMessage(error.response);
|
|
62
|
+
switch (status) {
|
|
63
|
+
case 400:
|
|
64
|
+
return new errors_1.ValidationError(message, error.response.data);
|
|
65
|
+
case 401:
|
|
66
|
+
case 403:
|
|
67
|
+
return new errors_1.AuthenticationError(message);
|
|
68
|
+
case 429:
|
|
69
|
+
return new errors_1.RateLimitError(message, this.extractRetryAfter(error.response));
|
|
70
|
+
default:
|
|
71
|
+
return new errors_1.SimplexError(message, status, error.response.data);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
extractErrorMessage(response) {
|
|
75
|
+
const data = response.data;
|
|
76
|
+
if (typeof data === 'string') {
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
79
|
+
if (data && typeof data === 'object') {
|
|
80
|
+
return data.message || data.error || 'An error occurred';
|
|
81
|
+
}
|
|
82
|
+
return 'An error occurred';
|
|
83
|
+
}
|
|
84
|
+
extractRetryAfter(response) {
|
|
85
|
+
const retryAfter = response.headers['retry-after'];
|
|
86
|
+
if (retryAfter) {
|
|
87
|
+
const parsed = parseInt(retryAfter, 10);
|
|
88
|
+
return isNaN(parsed) ? undefined : parsed;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
async get(path, options) {
|
|
93
|
+
const response = await this.client.get(path, options);
|
|
94
|
+
return response.data;
|
|
95
|
+
}
|
|
96
|
+
async post(path, data, options) {
|
|
97
|
+
// Convert to form data
|
|
98
|
+
const formData = new URLSearchParams();
|
|
99
|
+
if (data) {
|
|
100
|
+
Object.keys(data).forEach(key => {
|
|
101
|
+
const value = data[key];
|
|
102
|
+
if (value !== undefined && value !== null) {
|
|
103
|
+
formData.append(key, typeof value === 'object' ? JSON.stringify(value) : value);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const response = await this.client.post(path, formData, {
|
|
108
|
+
...options,
|
|
109
|
+
headers: {
|
|
110
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
111
|
+
...options?.headers,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
return response.data;
|
|
115
|
+
}
|
|
116
|
+
async postJSON(path, data, options) {
|
|
117
|
+
const response = await this.client.post(path, data, {
|
|
118
|
+
...options,
|
|
119
|
+
headers: {
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
...options?.headers,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
return response.data;
|
|
125
|
+
}
|
|
126
|
+
async put(path, data, options) {
|
|
127
|
+
const response = await this.client.put(path, data, options);
|
|
128
|
+
return response.data;
|
|
129
|
+
}
|
|
130
|
+
async patch(path, data, options) {
|
|
131
|
+
const response = await this.client.patch(path, data, options);
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
async delete(path, options) {
|
|
135
|
+
const response = await this.client.delete(path, options);
|
|
136
|
+
return response.data;
|
|
137
|
+
}
|
|
138
|
+
setHeader(key, value) {
|
|
139
|
+
this.client.defaults.headers.common[key] = value;
|
|
140
|
+
}
|
|
141
|
+
removeHeader(key) {
|
|
142
|
+
delete this.client.defaults.headers.common[key];
|
|
143
|
+
}
|
|
144
|
+
updateApiKey(apiKey) {
|
|
145
|
+
this.setHeader('X-API-Key', apiKey);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.HttpClient = HttpClient;
|
|
149
|
+
//# sourceMappingURL=HttpClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/client/HttpClient.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4F;AAC5F,sCAA6G;AAe7G,MAAa,UAAU;IAIrB,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,CAAC;YAChB,UAAU,EAAE,IAAI;YAChB,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,IAAI,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AY,EAAE,OAAwB;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAI,IAAI,EAAE,OAAO,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,KAAa;QAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnD,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,YAAY,CAAC,MAAc;QACzB,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AA3KD,gCA2KC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class SimplexError extends Error {
|
|
2
|
+
readonly statusCode?: number;
|
|
3
|
+
readonly data?: any;
|
|
4
|
+
constructor(message: string, statusCode?: number, data?: any);
|
|
5
|
+
}
|
|
6
|
+
export declare class NetworkError extends SimplexError {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class ValidationError extends SimplexError {
|
|
10
|
+
constructor(message: string, data?: any);
|
|
11
|
+
}
|
|
12
|
+
export declare class AuthenticationError extends SimplexError {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class RateLimitError extends SimplexError {
|
|
16
|
+
readonly retryAfter?: number;
|
|
17
|
+
constructor(message: string, retryAfter?: number);
|
|
18
|
+
}
|
|
19
|
+
export declare class WorkflowError extends SimplexError {
|
|
20
|
+
constructor(message: string, workflowId?: string, sessionId?: string);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,IAAI,CAAC,EAAE,GAAG,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAO7D;AAED,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAKxC;AAED,qBAAa,mBAAoB,SAAQ,YAAY;gBACvC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAMjD;AAED,qBAAa,aAAc,SAAQ,YAAY;gBACjC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAKrE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkflowError = exports.RateLimitError = exports.AuthenticationError = exports.ValidationError = exports.NetworkError = exports.SimplexError = void 0;
|
|
4
|
+
class SimplexError extends Error {
|
|
5
|
+
constructor(message, statusCode, data) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'SimplexError';
|
|
8
|
+
this.statusCode = statusCode;
|
|
9
|
+
this.data = data;
|
|
10
|
+
Object.setPrototypeOf(this, SimplexError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SimplexError = SimplexError;
|
|
14
|
+
class NetworkError extends SimplexError {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(`Network error: ${message}`);
|
|
17
|
+
this.name = 'NetworkError';
|
|
18
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.NetworkError = NetworkError;
|
|
22
|
+
class ValidationError extends SimplexError {
|
|
23
|
+
constructor(message, data) {
|
|
24
|
+
super(message, 400, data);
|
|
25
|
+
this.name = 'ValidationError';
|
|
26
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ValidationError = ValidationError;
|
|
30
|
+
class AuthenticationError extends SimplexError {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message, 401);
|
|
33
|
+
this.name = 'AuthenticationError';
|
|
34
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.AuthenticationError = AuthenticationError;
|
|
38
|
+
class RateLimitError extends SimplexError {
|
|
39
|
+
constructor(message, retryAfter) {
|
|
40
|
+
super(message, 429);
|
|
41
|
+
this.name = 'RateLimitError';
|
|
42
|
+
this.retryAfter = retryAfter;
|
|
43
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.RateLimitError = RateLimitError;
|
|
47
|
+
class WorkflowError extends SimplexError {
|
|
48
|
+
constructor(message, workflowId, sessionId) {
|
|
49
|
+
super(message, 500, { workflowId, sessionId });
|
|
50
|
+
this.name = 'WorkflowError';
|
|
51
|
+
Object.setPrototypeOf(this, WorkflowError.prototype);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.WorkflowError = WorkflowError;
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IAIrC,YAAY,OA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C,UAAU,GAAG,UAAU,CAAC;QAC7B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACF;AATD,wCASC;AAED,MAAa,aAAc,SAAQ,YAAY;IAC7C,YAAY,OAAe,EAAE,UAAmB,EAAE,SAAkB;QAClE,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAND,sCAMC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
declare function greet(name: string): string;
|
|
7
|
-
interface SessionData {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
declare class Simplex {
|
|
11
|
-
private apiKey;
|
|
12
|
-
private sessionId;
|
|
13
|
-
private connectUrl;
|
|
14
|
-
constructor(apiKey: string);
|
|
15
|
-
private makeRequest;
|
|
16
|
-
createSession(showInConsole?: boolean, proxies?: boolean, workflowName?: string, sessionData?: SessionData | string): Promise<[string, string]>;
|
|
17
|
-
goto(url: string, cdpUrl?: string): Promise<void>;
|
|
18
|
-
click(elementDescription: string, dropdownOptions?: boolean, cdpUrl?: string): Promise<string>;
|
|
19
|
-
hover(elementDescription: string, cdpUrl?: string): Promise<void>;
|
|
20
|
-
scrollToElement(elementDescription: string, cdpUrl?: string): Promise<void>;
|
|
21
|
-
getNetworkResponse(url: string, cdpUrl?: string): Promise<string>;
|
|
22
|
-
type(text: string, cdpUrl?: string): Promise<void>;
|
|
23
|
-
pressEnter(cdpUrl?: string): Promise<void>;
|
|
24
|
-
pressTab(cdpUrl?: string): Promise<void>;
|
|
25
|
-
deleteText(cdpUrl?: string): Promise<void>;
|
|
26
|
-
extractBbox(elementDescription: string, cdpUrl?: string): Promise<any>;
|
|
27
|
-
extractText(elementDescription: string, cdpUrl?: string): Promise<string>;
|
|
28
|
-
scroll(pixels: number, cdpUrl?: string): Promise<void>;
|
|
29
|
-
wait(milliseconds: number, cdpUrl?: string): Promise<void>;
|
|
30
|
-
clickAndUpload(elementDescription: string, filePathOrCallable: string | (() => Blob)): Promise<void>;
|
|
31
|
-
clickAndDownload(elementDescription: string): Promise<[string, string]>;
|
|
32
|
-
exists(elementDescription: string, cdpUrl?: string, maxSteps?: number): Promise<[boolean, string]>;
|
|
33
|
-
getPageURL(cdpUrl?: string): Promise<string>;
|
|
34
|
-
captureLoginSession(cdpUrl?: string): Promise<string>;
|
|
35
|
-
closeSession(): Promise<void>;
|
|
36
|
-
captchaExists(): Promise<boolean>;
|
|
37
|
-
waitForCaptcha(): Promise<boolean>;
|
|
38
|
-
setDialogSettings(accept: boolean): Promise<void>;
|
|
39
|
-
getDialogMessage(): Promise<string | undefined>;
|
|
40
|
-
enqueueActions(actions: any[]): Promise<void>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { Simplex, greet };
|
|
1
|
+
export { SimplexClient } from './SimplexClient';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export { SimplexError, NetworkError, ValidationError, AuthenticationError, RateLimitError, WorkflowError, } from './errors';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,UAAU,CAAC"}
|