@reduck-ai/sdk 1.1.21 → 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 +105 -202
- package/dist/client.d.ts +11 -20
- package/dist/client.js +19 -107
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/client.gen.js +216 -0
- package/dist/generated/client/index.d.ts +10 -0
- package/dist/generated/client/index.js +6 -0
- package/dist/generated/client/types.gen.d.ts +120 -0
- package/dist/generated/client/types.gen.js +2 -0
- package/dist/generated/client/utils.gen.d.ts +37 -0
- package/dist/generated/client/utils.gen.js +228 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/client.gen.js +3 -0
- package/dist/generated/core/auth.gen.d.ts +25 -0
- package/dist/generated/core/auth.gen.js +14 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/bodySerializer.gen.js +57 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/params.gen.js +109 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/pathSerializer.gen.js +106 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/queryKeySerializer.gen.js +92 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/serverSentEvents.gen.js +132 -0
- package/dist/generated/core/types.gen.d.ts +83 -0
- package/dist/generated/core/types.gen.js +2 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/core/utils.gen.js +87 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/index.js +3 -0
- package/dist/generated/sdk.gen.d.ts +471 -0
- package/dist/generated/sdk.gen.js +862 -0
- package/dist/generated/types.gen.d.ts +5489 -0
- package/dist/generated/types.gen.js +56 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +4 -4
- package/openapi.json +16668 -0
- package/package.json +23 -25
- package/dist/build-env.generated.d.ts +0 -3
- package/dist/build-env.generated.js +0 -4
- package/dist/device.d.ts +0 -3
- package/dist/device.js +0 -7
- package/dist/errors.d.ts +0 -9
- package/dist/errors.js +0 -21
- package/dist/method.d.ts +0 -3
- package/dist/method.js +0 -23
- package/dist/run.d.ts +0 -12
- package/dist/run.js +0 -73
- package/dist/schemas.d.ts +0 -597
- package/dist/schemas.js +0 -106
- package/dist/session.d.ts +0 -3
- package/dist/session.js +0 -14
- package/dist/site.d.ts +0 -3
- package/dist/site.js +0 -21
- package/dist/types.d.ts +0 -43
- package/dist/types.js +0 -8
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reduck-ai/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "TypeScript SDK for Reduck
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "TypeScript SDK for the Reduck API: manage your browser scripts, devices and runs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Reduck AI <contact@reduck.ai> (https://reduck.ai)",
|
|
7
|
-
"homepage": "https://reduck
|
|
7
|
+
"homepage": "https://github.com/reduck-ai/reduck-sdk#readme",
|
|
8
|
+
"bugs": "https://github.com/reduck-ai/reduck-sdk/issues",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/reduck-ai/reduck-sdk.git"
|
|
12
|
+
},
|
|
8
13
|
"keywords": [
|
|
9
14
|
"reduck",
|
|
10
15
|
"browser-automation",
|
|
@@ -12,19 +17,20 @@
|
|
|
12
17
|
"ai",
|
|
13
18
|
"rpa"
|
|
14
19
|
],
|
|
15
|
-
"funding": "https://reduck.ai",
|
|
16
20
|
"sideEffects": false,
|
|
17
21
|
"type": "module",
|
|
18
22
|
"main": "./dist/index.js",
|
|
19
23
|
"types": "./dist/index.d.ts",
|
|
20
24
|
"exports": {
|
|
21
25
|
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
22
27
|
"import": "./dist/index.js",
|
|
23
|
-
"
|
|
28
|
+
"default": "./dist/index.js"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
27
32
|
"dist/",
|
|
33
|
+
"openapi.json",
|
|
28
34
|
"README.md"
|
|
29
35
|
],
|
|
30
36
|
"engines": {
|
|
@@ -33,26 +39,18 @@
|
|
|
33
39
|
"publishConfig": {
|
|
34
40
|
"access": "public"
|
|
35
41
|
},
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
42
|
+
"packageManager": "pnpm@11.28.8",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"generate": "openapi-ts",
|
|
45
|
+
"update-spec": "node scripts/update-spec.mjs",
|
|
46
|
+
"build": "rm -rf dist && pnpm generate && tsc -p tsconfig.build.json",
|
|
47
|
+
"check": "pnpm generate && tsc --noEmit",
|
|
48
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
49
|
+
"smoke": "node test/smoke.mjs"
|
|
39
50
|
},
|
|
40
51
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"repository": {
|
|
45
|
-
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/conception-ai/conception-clean-for-real.git"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"generate-env": "node ../scripts/generate-build-env.mjs ./src/build-env.generated.ts",
|
|
50
|
-
"prebuild": "pnpm generate-env",
|
|
51
|
-
"build": "pnpm exec tsc",
|
|
52
|
-
"build:production": "REDUCK_BUILD_ENV=production pnpm build",
|
|
53
|
-
"build:staging": "REDUCK_BUILD_ENV=staging pnpm build",
|
|
54
|
-
"precheck": "pnpm generate-env",
|
|
55
|
-
"check": "pnpm exec tsc --noEmit",
|
|
56
|
-
"dev": "pnpm exec tsc --watch"
|
|
52
|
+
"@hey-api/openapi-ts": "0.99.0",
|
|
53
|
+
"@types/node": "22.20.5",
|
|
54
|
+
"typescript": "6.0.3"
|
|
57
55
|
}
|
|
58
|
-
}
|
|
56
|
+
}
|
package/dist/device.d.ts
DELETED
package/dist/device.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ReduckError } from "./errors.js";
|
|
2
|
-
export async function fetchDevices(appBaseUrl, headers) {
|
|
3
|
-
const res = await fetch(`${appBaseUrl}/api/devices`, { headers });
|
|
4
|
-
if (!res.ok)
|
|
5
|
-
throw ReduckError.fromResponse("GET /api/devices", res.status);
|
|
6
|
-
return (await res.json());
|
|
7
|
-
}
|
package/dist/errors.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class ReduckError extends Error {
|
|
2
|
-
readonly code: string;
|
|
3
|
-
readonly status?: number;
|
|
4
|
-
constructor(message: string, opts?: {
|
|
5
|
-
code?: string;
|
|
6
|
-
status?: number;
|
|
7
|
-
});
|
|
8
|
-
static fromResponse(endpoint: string, status: number, detail?: string): ReduckError;
|
|
9
|
-
}
|
package/dist/errors.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const STATUS_MESSAGES = {
|
|
2
|
-
401: "Not authenticated. Run `reduck login` or provide --api-key.",
|
|
3
|
-
403: "Access denied.",
|
|
4
|
-
404: "Resource not found.",
|
|
5
|
-
429: "Rate limited. Try again later.",
|
|
6
|
-
};
|
|
7
|
-
export class ReduckError extends Error {
|
|
8
|
-
code;
|
|
9
|
-
status;
|
|
10
|
-
constructor(message, opts = {}) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "ReduckError";
|
|
13
|
-
this.code = opts.code ?? "INTERNAL_ERROR";
|
|
14
|
-
this.status = opts.status;
|
|
15
|
-
}
|
|
16
|
-
static fromResponse(endpoint, status, detail) {
|
|
17
|
-
const hint = STATUS_MESSAGES[status] ?? `HTTP ${status}`;
|
|
18
|
-
const message = detail ? `${endpoint}: ${hint} — ${detail}` : `${endpoint}: ${hint}`;
|
|
19
|
-
return new ReduckError(message, { code: "HTTP_ERROR", status });
|
|
20
|
-
}
|
|
21
|
-
}
|
package/dist/method.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ListMethodsOptions, Method, MethodsPage } from "./types.js";
|
|
2
|
-
export declare function fetchMethods(appBaseUrl: string, headers: Record<string, string>, options?: ListMethodsOptions): Promise<MethodsPage>;
|
|
3
|
-
export declare function fetchMethod(appBaseUrl: string, headers: Record<string, string>, host: string, slug: string): Promise<Method>;
|
package/dist/method.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ReduckError } from "./errors.js";
|
|
2
|
-
export async function fetchMethods(appBaseUrl, headers, options = {}) {
|
|
3
|
-
const params = new URLSearchParams();
|
|
4
|
-
if (options.q)
|
|
5
|
-
params.set("q", options.q);
|
|
6
|
-
if (options.host)
|
|
7
|
-
params.set("host", options.host);
|
|
8
|
-
if (options.page !== undefined)
|
|
9
|
-
params.set("page", String(options.page));
|
|
10
|
-
if (options.pageSize !== undefined)
|
|
11
|
-
params.set("pageSize", String(options.pageSize));
|
|
12
|
-
const qs = params.toString();
|
|
13
|
-
const res = await fetch(`${appBaseUrl}/api/methods${qs ? `?${qs}` : ""}`, { headers });
|
|
14
|
-
if (!res.ok)
|
|
15
|
-
throw ReduckError.fromResponse("GET /api/methods", res.status);
|
|
16
|
-
return (await res.json());
|
|
17
|
-
}
|
|
18
|
-
export async function fetchMethod(appBaseUrl, headers, host, slug) {
|
|
19
|
-
const res = await fetch(`${appBaseUrl}/api/methods/${encodeURIComponent(host)}/${encodeURIComponent(slug)}`, { headers });
|
|
20
|
-
if (!res.ok)
|
|
21
|
-
throw ReduckError.fromResponse(`GET /api/methods/${host}/${slug}`, res.status);
|
|
22
|
-
return (await res.json());
|
|
23
|
-
}
|
package/dist/run.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RunEvent, RunRequestedEvent } from "./types.js";
|
|
2
|
-
export declare class Run implements AsyncIterable<RunEvent> {
|
|
3
|
-
private readonly _requestedPromise;
|
|
4
|
-
private readonly _wsBase;
|
|
5
|
-
private readonly _headers;
|
|
6
|
-
private _ws;
|
|
7
|
-
constructor(requestedPromise: Promise<RunRequestedEvent>, wsBase: string, headers: Record<string, string>);
|
|
8
|
-
get id(): Promise<string>;
|
|
9
|
-
[Symbol.asyncIterator](): AsyncGenerator<RunEvent>;
|
|
10
|
-
private _stream;
|
|
11
|
-
cancel(): Promise<void>;
|
|
12
|
-
}
|
package/dist/run.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import WebSocket from "ws";
|
|
2
|
-
import { ReduckError } from "./errors.js";
|
|
3
|
-
export class Run {
|
|
4
|
-
_requestedPromise;
|
|
5
|
-
_wsBase;
|
|
6
|
-
_headers;
|
|
7
|
-
_ws = null;
|
|
8
|
-
constructor(requestedPromise, wsBase, headers) {
|
|
9
|
-
this._requestedPromise = requestedPromise;
|
|
10
|
-
this._wsBase = wsBase;
|
|
11
|
-
this._headers = headers;
|
|
12
|
-
}
|
|
13
|
-
get id() {
|
|
14
|
-
return this._requestedPromise.then((e) => e.run_id);
|
|
15
|
-
}
|
|
16
|
-
[Symbol.asyncIterator]() {
|
|
17
|
-
return this._stream();
|
|
18
|
-
}
|
|
19
|
-
async *_stream() {
|
|
20
|
-
const requested = await this._requestedPromise;
|
|
21
|
-
yield requested;
|
|
22
|
-
const runId = requested.run_id;
|
|
23
|
-
const wsUrl = `${this._wsBase}/run/${runId}/events`;
|
|
24
|
-
const ws = new WebSocket(wsUrl, { headers: this._headers });
|
|
25
|
-
this._ws = ws;
|
|
26
|
-
const queue = [];
|
|
27
|
-
let resolve = null;
|
|
28
|
-
let done = false;
|
|
29
|
-
let error = null;
|
|
30
|
-
ws.on("message", (data) => {
|
|
31
|
-
const event = JSON.parse(data.toString());
|
|
32
|
-
queue.push(event);
|
|
33
|
-
resolve?.();
|
|
34
|
-
});
|
|
35
|
-
ws.on("error", (err) => {
|
|
36
|
-
error = new ReduckError(err.message, { code: "CONNECTION_LOST" });
|
|
37
|
-
done = true;
|
|
38
|
-
resolve?.();
|
|
39
|
-
});
|
|
40
|
-
ws.on("close", () => {
|
|
41
|
-
done = true;
|
|
42
|
-
resolve?.();
|
|
43
|
-
});
|
|
44
|
-
await new Promise((r) => ws.once("open", r));
|
|
45
|
-
while (true) {
|
|
46
|
-
while (queue.length > 0) {
|
|
47
|
-
const event = queue.shift();
|
|
48
|
-
yield event;
|
|
49
|
-
if (event.type === "done" || event.type === "failure" || event.type === "cancel") {
|
|
50
|
-
ws.close();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (done) {
|
|
55
|
-
if (error)
|
|
56
|
-
throw error;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
await new Promise((r) => { resolve = r; });
|
|
60
|
-
resolve = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
async cancel() {
|
|
64
|
-
const runId = (await this._requestedPromise).run_id;
|
|
65
|
-
const baseUrl = this._wsBase
|
|
66
|
-
.replace("wss://", "https://")
|
|
67
|
-
.replace("ws://", "http://");
|
|
68
|
-
await fetch(`${baseUrl}/run/${runId}/cancel`, {
|
|
69
|
-
method: "POST",
|
|
70
|
-
headers: this._headers,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|