@reduck-ai/sdk 1.1.20 → 1.1.21

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/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Device, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage, type Site } from "./types.js";
1
+ import { type Device, type ListMethodsOptions, type ListSitesOptions, type Method, type MethodsPage, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage, type Site, type SitesPage } from "./types.js";
2
2
  import { Run } from "./run.js";
3
3
  export declare class ReduckClient {
4
4
  private readonly _runnerBaseUrl;
@@ -9,8 +9,10 @@ export declare class ReduckClient {
9
9
  listDevices(): Promise<Device[]>;
10
10
  listRuns(page?: number): Promise<RunsPage>;
11
11
  getRun(runId: string): Promise<RunRecord>;
12
- searchSites(query: string): Promise<Site[]>;
12
+ listSites(options?: ListSitesOptions): Promise<SitesPage>;
13
13
  getSite(host: string): Promise<Site>;
14
+ listMethods(options?: ListMethodsOptions): Promise<MethodsPage>;
15
+ getMethod(host: string, slug: string): Promise<Method>;
14
16
  interrupt(runId: string): Promise<void>;
15
17
  private _createRun;
16
18
  private _mount;
package/dist/client.js CHANGED
@@ -6,8 +6,8 @@ import { authHeader } from "./types.js";
6
6
  import { Run } from "./run.js";
7
7
  import { fetchDevices } from "./device.js";
8
8
  import { fetchRun, fetchRuns } from "./session.js";
9
- import { fetchSearchSites } from "./search.js";
10
- import { fetchGetSite } from "./get.js";
9
+ import { fetchSite, fetchSites } from "./site.js";
10
+ import { fetchMethod, fetchMethods } from "./method.js";
11
11
  import { RUNNER_URL, APP_URL } from "./build-env.generated.js";
12
12
  export class ReduckClient {
13
13
  _runnerBaseUrl;
@@ -36,11 +36,17 @@ export class ReduckClient {
36
36
  async getRun(runId) {
37
37
  return fetchRun(this._appBaseUrl, this._headers, runId);
38
38
  }
39
- async searchSites(query) {
40
- return fetchSearchSites(this._runnerBaseUrl, this._headers, query);
39
+ async listSites(options = {}) {
40
+ return fetchSites(this._appBaseUrl, this._headers, options);
41
41
  }
42
42
  async getSite(host) {
43
- return fetchGetSite(this._runnerBaseUrl, this._headers, host);
43
+ return fetchSite(this._appBaseUrl, this._headers, host);
44
+ }
45
+ async listMethods(options = {}) {
46
+ return fetchMethods(this._appBaseUrl, this._headers, options);
47
+ }
48
+ async getMethod(host, slug) {
49
+ return fetchMethod(this._appBaseUrl, this._headers, host, slug);
44
50
  }
45
51
  async interrupt(runId) {
46
52
  await fetch(`${this._runnerBaseUrl}/run/${runId}/cancel`, {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { ReduckClient } from "./client.js";
2
2
  export { ReduckError } from "./errors.js";
3
3
  export { Run } from "./run.js";
4
- export type { Device, Method, RunEvent, RunResult, RunOptions, RunRecord, RunsPage, ReduckClientOptions, Site } from "./types.js";
4
+ export type { Device, ListMethodsOptions, ListSitesOptions, Method, MethodsPage, PaginationParameters, ReduckClientOptions, RunEvent, RunOptions, RunRecord, RunResult, RunsPage, Site, SitesPage, } from "./types.js";
5
5
  export * as schemas from "./schemas.js";
@@ -0,0 +1,3 @@
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 ADDED
@@ -0,0 +1,23 @@
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/schemas.d.ts CHANGED
@@ -523,7 +523,40 @@ export declare const MethodSchema: z.ZodObject<{
523
523
  export declare const SiteSchema: z.ZodObject<{
524
524
  host: z.ZodString;
525
525
  notes: z.ZodDefault<z.ZodString>;
526
- methods: z.ZodArray<z.ZodObject<{
526
+ }, "strip", z.ZodTypeAny, {
527
+ host: string;
528
+ notes: string;
529
+ }, {
530
+ host: string;
531
+ notes?: string | undefined;
532
+ }>;
533
+ export declare const SitesPageSchema: z.ZodObject<{
534
+ data: z.ZodArray<z.ZodObject<{
535
+ host: z.ZodString;
536
+ notes: z.ZodDefault<z.ZodString>;
537
+ }, "strip", z.ZodTypeAny, {
538
+ host: string;
539
+ notes: string;
540
+ }, {
541
+ host: string;
542
+ notes?: string | undefined;
543
+ }>, "many">;
544
+ hasNextPage: z.ZodBoolean;
545
+ }, "strip", z.ZodTypeAny, {
546
+ data: {
547
+ host: string;
548
+ notes: string;
549
+ }[];
550
+ hasNextPage: boolean;
551
+ }, {
552
+ data: {
553
+ host: string;
554
+ notes?: string | undefined;
555
+ }[];
556
+ hasNextPage: boolean;
557
+ }>;
558
+ export declare const MethodsPageSchema: z.ZodObject<{
559
+ data: z.ZodArray<z.ZodObject<{
527
560
  host: z.ZodString;
528
561
  method_slug: z.ZodString;
529
562
  description: z.ZodString;
@@ -542,24 +575,23 @@ export declare const SiteSchema: z.ZodObject<{
542
575
  method_slug: string;
543
576
  description: string;
544
577
  }>, "many">;
578
+ hasNextPage: z.ZodBoolean;
545
579
  }, "strip", z.ZodTypeAny, {
546
- host: string;
547
- notes: string;
548
- methods: {
580
+ data: {
549
581
  output_schema: Record<string, unknown> | null;
550
582
  args: Record<string, unknown>;
551
583
  host: string;
552
584
  method_slug: string;
553
585
  description: string;
554
586
  }[];
587
+ hasNextPage: boolean;
555
588
  }, {
556
- host: string;
557
- methods: {
589
+ data: {
558
590
  output_schema: Record<string, unknown> | null;
559
591
  args: Record<string, unknown>;
560
592
  host: string;
561
593
  method_slug: string;
562
594
  description: string;
563
595
  }[];
564
- notes?: string | undefined;
596
+ hasNextPage: boolean;
565
597
  }>;
package/dist/schemas.js CHANGED
@@ -95,5 +95,12 @@ export const MethodSchema = z.object({
95
95
  export const SiteSchema = z.object({
96
96
  host: z.string(),
97
97
  notes: z.string().default(""),
98
- methods: z.array(MethodSchema),
98
+ });
99
+ export const SitesPageSchema = z.object({
100
+ data: z.array(SiteSchema),
101
+ hasNextPage: z.boolean(),
102
+ });
103
+ export const MethodsPageSchema = z.object({
104
+ data: z.array(MethodSchema),
105
+ hasNextPage: z.boolean(),
99
106
  });
package/dist/site.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { ListSitesOptions, Site, SitesPage } from "./types.js";
2
+ export declare function fetchSites(appBaseUrl: string, headers: Record<string, string>, options?: ListSitesOptions): Promise<SitesPage>;
3
+ export declare function fetchSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
package/dist/site.js ADDED
@@ -0,0 +1,21 @@
1
+ import { ReduckError } from "./errors.js";
2
+ export async function fetchSites(appBaseUrl, headers, options = {}) {
3
+ const params = new URLSearchParams();
4
+ if (options.q)
5
+ params.set("q", options.q);
6
+ if (options.page !== undefined)
7
+ params.set("page", String(options.page));
8
+ if (options.pageSize !== undefined)
9
+ params.set("pageSize", String(options.pageSize));
10
+ const qs = params.toString();
11
+ const res = await fetch(`${appBaseUrl}/api/sites${qs ? `?${qs}` : ""}`, { headers });
12
+ if (!res.ok)
13
+ throw ReduckError.fromResponse("GET /api/sites", res.status);
14
+ return (await res.json());
15
+ }
16
+ export async function fetchSite(appBaseUrl, headers, host) {
17
+ const res = await fetch(`${appBaseUrl}/api/sites/${encodeURIComponent(host)}`, { headers });
18
+ if (!res.ok)
19
+ throw ReduckError.fromResponse(`GET /api/sites/${host}`, res.status);
20
+ return (await res.json());
21
+ }
package/dist/types.d.ts CHANGED
@@ -6,7 +6,20 @@ export type RunResult = z.infer<typeof S.RunResultSchema>;
6
6
  export type RunRecord = z.infer<typeof S.RunRecordSchema>;
7
7
  export type RunsPage = z.infer<typeof S.RunsPageSchema>;
8
8
  export type Method = z.infer<typeof S.MethodSchema>;
9
+ export type MethodsPage = z.infer<typeof S.MethodsPageSchema>;
9
10
  export type Site = z.infer<typeof S.SiteSchema>;
11
+ export type SitesPage = z.infer<typeof S.SitesPageSchema>;
12
+ export interface PaginationParameters {
13
+ page?: number;
14
+ pageSize?: number;
15
+ }
16
+ export interface ListSitesOptions extends PaginationParameters {
17
+ q?: string;
18
+ }
19
+ export interface ListMethodsOptions extends PaginationParameters {
20
+ q?: string;
21
+ host?: string;
22
+ }
10
23
  export type RunRequestedEvent = Extract<RunEvent, {
11
24
  type: "run_requested";
12
25
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reduck-ai/sdk",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "TypeScript SDK for Reduck — run browser automations programmatically.",
5
5
  "license": "MIT",
6
6
  "author": "Reduck AI <contact@reduck.ai> (https://reduck.ai)",
package/dist/get.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Site } from "./types.js";
2
- export declare function fetchGetSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
package/dist/get.js DELETED
@@ -1,8 +0,0 @@
1
- export async function fetchGetSite(appBaseUrl, headers, host) {
2
- const res = await fetch(`${appBaseUrl}/sites/${encodeURIComponent(host)}`, { headers });
3
- if (res.status === 404)
4
- throw new Error(`Site not found: ${host}`);
5
- if (!res.ok)
6
- throw new Error(`Get site failed (HTTP ${res.status})`);
7
- return res.json();
8
- }
package/dist/search.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Site } from "./types.js";
2
- export declare function fetchSearchSites(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Site[]>;
package/dist/search.js DELETED
@@ -1,7 +0,0 @@
1
- export async function fetchSearchSites(appBaseUrl, headers, query) {
2
- const url = `${appBaseUrl}/sites?q=${encodeURIComponent(query)}`;
3
- const res = await fetch(url, { headers });
4
- if (!res.ok)
5
- throw new Error(`Search sites failed (HTTP ${res.status})`);
6
- return res.json();
7
- }