@retab/node 1.0.96 → 1.0.99
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 +39 -42
- package/dist/api/client.d.ts +4 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -2
- package/dist/api/documents/client.d.ts +17 -11
- package/dist/api/documents/client.d.ts.map +1 -1
- package/dist/api/documents/client.js +85 -38
- package/dist/api/edit/agent/client.js +1 -1
- package/dist/api/edit/client.d.ts +1 -1
- package/dist/api/edit/client.js +1 -1
- package/dist/api/edit/templates/client.d.ts +1 -75
- package/dist/api/edit/templates/client.d.ts.map +1 -1
- package/dist/api/edit/templates/client.js +3 -130
- package/dist/api/evals/classify/client.d.ts +20 -0
- package/dist/api/evals/classify/client.d.ts.map +1 -0
- package/dist/api/evals/classify/client.js +25 -0
- package/dist/api/evals/client.d.ts +11 -0
- package/dist/api/evals/client.d.ts.map +1 -0
- package/dist/api/evals/client.js +12 -0
- package/dist/api/evals/extract/client.d.ts +287 -0
- package/dist/api/evals/extract/client.d.ts.map +1 -0
- package/dist/api/evals/extract/client.js +56 -0
- package/dist/api/evals/helpers.d.ts +30 -0
- package/dist/api/evals/helpers.d.ts.map +1 -0
- package/dist/api/evals/helpers.js +46 -0
- package/dist/api/evals/schemas.d.ts +6522 -0
- package/dist/api/evals/schemas.d.ts.map +1 -0
- package/dist/api/evals/schemas.js +219 -0
- package/dist/api/evals/split/client.d.ts +105 -0
- package/dist/api/evals/split/client.d.ts.map +1 -0
- package/dist/api/evals/split/client.js +28 -0
- package/dist/api/extractions/client.d.ts +3 -43
- package/dist/api/extractions/client.d.ts.map +1 -1
- package/dist/api/extractions/client.js +6 -67
- package/dist/api/files/client.d.ts +9 -1
- package/dist/api/files/client.d.ts.map +1 -1
- package/dist/api/files/client.js +11 -5
- package/dist/api/jobs/client.d.ts +12 -10
- package/dist/api/jobs/client.d.ts.map +1 -1
- package/dist/api/jobs/client.js +13 -17
- package/dist/api/models/client.d.ts +3 -10
- package/dist/api/models/client.d.ts.map +1 -1
- package/dist/api/models/client.js +9 -8
- package/dist/api/projects/client.d.ts +1640 -4
- package/dist/api/projects/client.d.ts.map +1 -1
- package/dist/api/projects/client.js +457 -28
- package/dist/api/schemas/client.d.ts +3 -0
- package/dist/api/schemas/client.d.ts.map +1 -1
- package/dist/api/schemas/client.js +1 -1
- package/dist/api/workflows/blocks/client.d.ts +67 -0
- package/dist/api/workflows/blocks/client.d.ts.map +1 -0
- package/dist/api/workflows/blocks/client.js +132 -0
- package/dist/api/workflows/client.d.ts +90 -2
- package/dist/api/workflows/client.d.ts.map +1 -1
- package/dist/api/workflows/client.js +153 -1
- package/dist/api/workflows/edges/client.d.ts +66 -0
- package/dist/api/workflows/edges/client.d.ts.map +1 -0
- package/dist/api/workflows/edges/client.js +120 -0
- package/dist/api/workflows/runs/client.d.ts +57 -113
- package/dist/api/workflows/runs/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/client.js +118 -119
- package/dist/api/workflows/runs/steps/client.d.ts +35 -13
- package/dist/api/workflows/runs/steps/client.d.ts.map +1 -1
- package/dist/api/workflows/runs/steps/client.js +63 -15
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +79 -5
- package/dist/generated_types.d.ts +7778 -2745
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +711 -70
- package/dist/mime.d.ts.map +1 -1
- package/dist/mime.js +11 -1
- package/dist/schema_types.d.ts +2 -2
- package/dist/schema_types.d.ts.map +1 -1
- package/dist/schema_types.js +2 -2
- package/dist/types.d.ts +655 -109
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +84 -14
- package/package.json +1 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { CompositionClient } from "../../../client.js";
|
|
3
|
+
import { ZWorkflowBlock, } from "../../../types.js";
|
|
4
|
+
function serializeBlockCreateRequest(request) {
|
|
5
|
+
const legacyRequest = request;
|
|
6
|
+
return {
|
|
7
|
+
id: request.id,
|
|
8
|
+
type: request.type,
|
|
9
|
+
label: request.label ?? "",
|
|
10
|
+
position_x: "positionX" in request ? (request.positionX ?? 0) : (legacyRequest.position_x ?? 0),
|
|
11
|
+
position_y: "positionY" in request ? (request.positionY ?? 0) : (legacyRequest.position_y ?? 0),
|
|
12
|
+
width: request.width,
|
|
13
|
+
height: request.height,
|
|
14
|
+
config: request.config,
|
|
15
|
+
subflow_id: "subflowId" in request ? request.subflowId : legacyRequest.subflow_id,
|
|
16
|
+
parent_id: "parentId" in request ? request.parentId : legacyRequest.parent_id,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function serializeBlockUpdateRequest(request) {
|
|
20
|
+
return {
|
|
21
|
+
label: request.label,
|
|
22
|
+
position_x: request.positionX,
|
|
23
|
+
position_y: request.positionY,
|
|
24
|
+
width: request.width,
|
|
25
|
+
height: request.height,
|
|
26
|
+
config: request.config,
|
|
27
|
+
subflow_id: request.subflowId,
|
|
28
|
+
parent_id: request.parentId,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Workflow Blocks API client for managing blocks (nodes) in a workflow graph.
|
|
33
|
+
*
|
|
34
|
+
* Usage: `client.workflows.blocks.list(workflowId)`
|
|
35
|
+
*/
|
|
36
|
+
export default class APIWorkflowBlocks extends CompositionClient {
|
|
37
|
+
constructor(client) {
|
|
38
|
+
super(client);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* List all blocks for a workflow.
|
|
42
|
+
*
|
|
43
|
+
* @param workflowId - The workflow ID
|
|
44
|
+
* @param subflowId - Optional: filter by subflow ID
|
|
45
|
+
*/
|
|
46
|
+
async list(workflowId, { subflowId } = {}, options) {
|
|
47
|
+
const params = Object.fromEntries(Object.entries({
|
|
48
|
+
subflow_id: subflowId,
|
|
49
|
+
...(options?.params || {}),
|
|
50
|
+
}).filter(([_, v]) => v !== undefined));
|
|
51
|
+
return this._fetchJson(z.array(ZWorkflowBlock), {
|
|
52
|
+
url: `/workflows/${workflowId}/blocks`,
|
|
53
|
+
method: "GET",
|
|
54
|
+
params,
|
|
55
|
+
headers: options?.headers,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get a single block by ID.
|
|
60
|
+
*/
|
|
61
|
+
async get(workflowId, blockId, options) {
|
|
62
|
+
return this._fetchJson(ZWorkflowBlock, {
|
|
63
|
+
url: `/workflows/${workflowId}/blocks/${blockId}`,
|
|
64
|
+
method: "GET",
|
|
65
|
+
params: options?.params,
|
|
66
|
+
headers: options?.headers,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a new block in a workflow.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const block = await client.workflows.blocks.create("wf_abc123", {
|
|
75
|
+
* id: "extract-1",
|
|
76
|
+
* type: "extract",
|
|
77
|
+
* label: "Extract Invoice Data",
|
|
78
|
+
* config: { json_schema: { ... } },
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async create(workflowId, request, options) {
|
|
83
|
+
return this._fetchJson(ZWorkflowBlock, {
|
|
84
|
+
url: `/workflows/${workflowId}/blocks`,
|
|
85
|
+
method: "POST",
|
|
86
|
+
body: { ...serializeBlockCreateRequest(request), ...(options?.body || {}) },
|
|
87
|
+
params: options?.params,
|
|
88
|
+
headers: options?.headers,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create multiple blocks in a single request.
|
|
93
|
+
*
|
|
94
|
+
* @param workflowId - The workflow ID
|
|
95
|
+
* @param blocks - Array of block definitions (each with at least `id` and `type`)
|
|
96
|
+
*/
|
|
97
|
+
async createBatch(workflowId, blocks, options) {
|
|
98
|
+
return this._fetchJson(z.array(ZWorkflowBlock), {
|
|
99
|
+
url: `/workflows/${workflowId}/blocks/batch`,
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: blocks.map((block) => serializeBlockCreateRequest(block)),
|
|
102
|
+
params: options?.params,
|
|
103
|
+
headers: options?.headers,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async create_batch(workflowId, blocks, options) {
|
|
107
|
+
return this.createBatch(workflowId, blocks, options);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Update a block with partial data. Only provided fields are updated.
|
|
111
|
+
*/
|
|
112
|
+
async update(workflowId, blockId, request, options) {
|
|
113
|
+
return this._fetchJson(ZWorkflowBlock, {
|
|
114
|
+
url: `/workflows/${workflowId}/blocks/${blockId}`,
|
|
115
|
+
method: "PATCH",
|
|
116
|
+
body: { ...serializeBlockUpdateRequest(request), ...(options?.body || {}) },
|
|
117
|
+
params: options?.params,
|
|
118
|
+
headers: options?.headers,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Delete a block and any edges connected to it.
|
|
123
|
+
*/
|
|
124
|
+
async delete(workflowId, blockId, options) {
|
|
125
|
+
return this._fetchJson({
|
|
126
|
+
url: `/workflows/${workflowId}/blocks/${blockId}`,
|
|
127
|
+
method: "DELETE",
|
|
128
|
+
params: options?.params,
|
|
129
|
+
headers: options?.headers,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -1,13 +1,101 @@
|
|
|
1
|
-
import { CompositionClient } from "../../client.js";
|
|
1
|
+
import { CompositionClient, RequestOptions } from "../../client.js";
|
|
2
|
+
import { PaginatedList, Workflow, WorkflowWithEntities } from "../../types.js";
|
|
2
3
|
import APIWorkflowRuns from "./runs/client.js";
|
|
4
|
+
import APIWorkflowBlocks from "./blocks/client.js";
|
|
5
|
+
import APIWorkflowEdges from "./edges/client.js";
|
|
3
6
|
/**
|
|
4
7
|
* Workflows API client for workflow operations.
|
|
5
8
|
*
|
|
6
9
|
* Sub-clients:
|
|
7
|
-
* - runs: Workflow run operations
|
|
10
|
+
* - runs: Workflow run operations
|
|
11
|
+
* - blocks: Workflow block CRUD
|
|
12
|
+
* - edges: Workflow edge CRUD
|
|
8
13
|
*/
|
|
9
14
|
export default class APIWorkflows extends CompositionClient {
|
|
10
15
|
runs: APIWorkflowRuns;
|
|
16
|
+
blocks: APIWorkflowBlocks;
|
|
17
|
+
edges: APIWorkflowEdges;
|
|
11
18
|
constructor(client: CompositionClient);
|
|
19
|
+
/**
|
|
20
|
+
* Get a workflow by ID.
|
|
21
|
+
*/
|
|
22
|
+
get(workflowId: string, options?: RequestOptions): Promise<Workflow>;
|
|
23
|
+
/**
|
|
24
|
+
* List workflows with pagination.
|
|
25
|
+
*/
|
|
26
|
+
list({ before, after, limit, order, sortBy, fields, }?: {
|
|
27
|
+
before?: string;
|
|
28
|
+
after?: string;
|
|
29
|
+
limit?: number;
|
|
30
|
+
order?: "asc" | "desc";
|
|
31
|
+
sortBy?: string;
|
|
32
|
+
fields?: string;
|
|
33
|
+
}, options?: RequestOptions): Promise<PaginatedList>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new workflow.
|
|
36
|
+
*
|
|
37
|
+
* @param name - Workflow name (default: "Untitled Workflow")
|
|
38
|
+
* @param description - Workflow description (default: "")
|
|
39
|
+
* @returns The created workflow (unpublished, with a default start node)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const wf = await client.workflows.create({ name: "Invoice Extractor" });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
create({ name, description, }?: {
|
|
47
|
+
name?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
}, options?: RequestOptions): Promise<Workflow>;
|
|
50
|
+
/**
|
|
51
|
+
* Update a workflow's metadata.
|
|
52
|
+
*
|
|
53
|
+
* @param workflowId - The workflow ID
|
|
54
|
+
* @param fields - Fields to update (only provided fields are changed)
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const wf = await client.workflows.update("wf_abc123", { name: "New Name" });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
update(workflowId: string, { name, description, emailSendersWhitelist, emailDomainsWhitelist, }: {
|
|
62
|
+
name?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
emailSendersWhitelist?: string[];
|
|
65
|
+
emailDomainsWhitelist?: string[];
|
|
66
|
+
}, options?: RequestOptions): Promise<Workflow>;
|
|
67
|
+
/**
|
|
68
|
+
* Delete a workflow and all its associated entities (blocks, edges, snapshots).
|
|
69
|
+
*/
|
|
70
|
+
delete(workflowId: string, options?: RequestOptions): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Publish a workflow's current draft as a new version.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const wf = await client.workflows.publish("wf_abc123", { description: "v1" });
|
|
77
|
+
* console.log(wf.published_snapshot_id);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
publish(workflowId: string, { description }?: {
|
|
81
|
+
description?: string;
|
|
82
|
+
}, options?: RequestOptions): Promise<Workflow>;
|
|
83
|
+
/**
|
|
84
|
+
* Duplicate a workflow with all its blocks and edges.
|
|
85
|
+
*
|
|
86
|
+
* @returns The new duplicated workflow (unpublished)
|
|
87
|
+
*/
|
|
88
|
+
duplicate(workflowId: string, options?: RequestOptions): Promise<Workflow>;
|
|
89
|
+
/**
|
|
90
|
+
* Get a workflow with all its entities (blocks, edges, subflows).
|
|
91
|
+
*
|
|
92
|
+
* Use the returned `blocks` array to discover start nodes:
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const entities = await client.workflows.getEntities("wf_abc123");
|
|
95
|
+
* const startNodes = entities.blocks.filter(b => b.type === "start");
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
getEntities(workflowId: string, options?: RequestOptions): Promise<WorkflowWithEntities>;
|
|
99
|
+
get_entities(workflowId: string, options?: RequestOptions): Promise<WorkflowWithEntities>;
|
|
12
100
|
}
|
|
13
101
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/workflows/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/workflows/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,oBAAoB,EAAoD,MAAM,gBAAgB,CAAC;AACjI,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,gBAAgB,MAAM,mBAAmB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,iBAAiB;IAChD,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;gBAEnB,MAAM,EAAE,iBAAiB;IAOrC;;OAEG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAS1E;;OAEG;IACG,IAAI,CACN,EACI,MAAM,EACN,KAAK,EACL,KAAU,EACV,KAAc,EACd,MAAM,EACN,MAAM,GACT,GAAE;QACC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QACvB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACd,EACN,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,aAAa,CAAC;IAqBzB;;;;;;;;;;;OAWG;IACG,MAAM,CACR,EACI,IAA0B,EAC1B,WAAgB,GACnB,GAAE;QACC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACnB,EACN,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,QAAQ,CAAC;IAUpB;;;;;;;;;;OAUG;IACG,MAAM,CACR,UAAU,EAAE,MAAM,EAClB,EACI,IAAI,EACJ,WAAW,EACX,qBAAqB,EACrB,qBAAqB,GACxB,EAAE;QACC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;QACjC,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;KACpC,EACD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,QAAQ,CAAC;IAiBpB;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IASzE;;;;;;;;OAQG;IACG,OAAO,CACT,UAAU,EAAE,MAAM,EAClB,EAAE,WAAgB,EAAE,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,EACnD,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,QAAQ,CAAC;IAUpB;;;;OAIG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUhF;;;;;;;;OAQG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IASxF,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAGlG"}
|
|
@@ -1,14 +1,166 @@
|
|
|
1
1
|
import { CompositionClient } from "../../client.js";
|
|
2
|
+
import { ZPaginatedList, ZWorkflow, ZWorkflowWithEntities } from "../../types.js";
|
|
2
3
|
import APIWorkflowRuns from "./runs/client.js";
|
|
4
|
+
import APIWorkflowBlocks from "./blocks/client.js";
|
|
5
|
+
import APIWorkflowEdges from "./edges/client.js";
|
|
3
6
|
/**
|
|
4
7
|
* Workflows API client for workflow operations.
|
|
5
8
|
*
|
|
6
9
|
* Sub-clients:
|
|
7
|
-
* - runs: Workflow run operations
|
|
10
|
+
* - runs: Workflow run operations
|
|
11
|
+
* - blocks: Workflow block CRUD
|
|
12
|
+
* - edges: Workflow edge CRUD
|
|
8
13
|
*/
|
|
9
14
|
export default class APIWorkflows extends CompositionClient {
|
|
10
15
|
constructor(client) {
|
|
11
16
|
super(client);
|
|
12
17
|
this.runs = new APIWorkflowRuns(this);
|
|
18
|
+
this.blocks = new APIWorkflowBlocks(this);
|
|
19
|
+
this.edges = new APIWorkflowEdges(this);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a workflow by ID.
|
|
23
|
+
*/
|
|
24
|
+
async get(workflowId, options) {
|
|
25
|
+
return this._fetchJson(ZWorkflow, {
|
|
26
|
+
url: `/workflows/${workflowId}`,
|
|
27
|
+
method: "GET",
|
|
28
|
+
params: options?.params,
|
|
29
|
+
headers: options?.headers,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List workflows with pagination.
|
|
34
|
+
*/
|
|
35
|
+
async list({ before, after, limit = 10, order = "desc", sortBy, fields, } = {}, options) {
|
|
36
|
+
const params = Object.fromEntries(Object.entries({
|
|
37
|
+
before,
|
|
38
|
+
after,
|
|
39
|
+
limit,
|
|
40
|
+
order,
|
|
41
|
+
sort_by: sortBy,
|
|
42
|
+
fields,
|
|
43
|
+
...(options?.params || {}),
|
|
44
|
+
}).filter(([_, value]) => value !== undefined));
|
|
45
|
+
return this._fetchJson(ZPaginatedList, {
|
|
46
|
+
url: "/workflows",
|
|
47
|
+
method: "GET",
|
|
48
|
+
params,
|
|
49
|
+
headers: options?.headers,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a new workflow.
|
|
54
|
+
*
|
|
55
|
+
* @param name - Workflow name (default: "Untitled Workflow")
|
|
56
|
+
* @param description - Workflow description (default: "")
|
|
57
|
+
* @returns The created workflow (unpublished, with a default start node)
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const wf = await client.workflows.create({ name: "Invoice Extractor" });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
async create({ name = "Untitled Workflow", description = "", } = {}, options) {
|
|
65
|
+
return this._fetchJson(ZWorkflow, {
|
|
66
|
+
url: "/workflows",
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: { name, description, ...(options?.body || {}) },
|
|
69
|
+
params: options?.params,
|
|
70
|
+
headers: options?.headers,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Update a workflow's metadata.
|
|
75
|
+
*
|
|
76
|
+
* @param workflowId - The workflow ID
|
|
77
|
+
* @param fields - Fields to update (only provided fields are changed)
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const wf = await client.workflows.update("wf_abc123", { name: "New Name" });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
async update(workflowId, { name, description, emailSendersWhitelist, emailDomainsWhitelist, }, options) {
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
const body = {};
|
|
87
|
+
if (name !== undefined)
|
|
88
|
+
body.name = name;
|
|
89
|
+
if (description !== undefined)
|
|
90
|
+
body.description = description;
|
|
91
|
+
if (emailSendersWhitelist !== undefined)
|
|
92
|
+
body.email_senders_whitelist = emailSendersWhitelist;
|
|
93
|
+
if (emailDomainsWhitelist !== undefined)
|
|
94
|
+
body.email_domains_whitelist = emailDomainsWhitelist;
|
|
95
|
+
return this._fetchJson(ZWorkflow, {
|
|
96
|
+
url: `/workflows/${workflowId}`,
|
|
97
|
+
method: "PATCH",
|
|
98
|
+
body: { ...body, ...(options?.body || {}) },
|
|
99
|
+
params: options?.params,
|
|
100
|
+
headers: options?.headers,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a workflow and all its associated entities (blocks, edges, snapshots).
|
|
105
|
+
*/
|
|
106
|
+
async delete(workflowId, options) {
|
|
107
|
+
return this._fetchJson({
|
|
108
|
+
url: `/workflows/${workflowId}`,
|
|
109
|
+
method: "DELETE",
|
|
110
|
+
params: options?.params,
|
|
111
|
+
headers: options?.headers,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Publish a workflow's current draft as a new version.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const wf = await client.workflows.publish("wf_abc123", { description: "v1" });
|
|
120
|
+
* console.log(wf.published_snapshot_id);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
async publish(workflowId, { description = "" } = {}, options) {
|
|
124
|
+
return this._fetchJson(ZWorkflow, {
|
|
125
|
+
url: `/workflows/${workflowId}/publish`,
|
|
126
|
+
method: "POST",
|
|
127
|
+
body: { description, ...(options?.body || {}) },
|
|
128
|
+
params: options?.params,
|
|
129
|
+
headers: options?.headers,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Duplicate a workflow with all its blocks and edges.
|
|
134
|
+
*
|
|
135
|
+
* @returns The new duplicated workflow (unpublished)
|
|
136
|
+
*/
|
|
137
|
+
async duplicate(workflowId, options) {
|
|
138
|
+
return this._fetchJson(ZWorkflow, {
|
|
139
|
+
url: `/workflows/${workflowId}/duplicate`,
|
|
140
|
+
method: "POST",
|
|
141
|
+
body: { ...(options?.body || {}) },
|
|
142
|
+
params: options?.params,
|
|
143
|
+
headers: options?.headers,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get a workflow with all its entities (blocks, edges, subflows).
|
|
148
|
+
*
|
|
149
|
+
* Use the returned `blocks` array to discover start nodes:
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const entities = await client.workflows.getEntities("wf_abc123");
|
|
152
|
+
* const startNodes = entities.blocks.filter(b => b.type === "start");
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
async getEntities(workflowId, options) {
|
|
156
|
+
return this._fetchJson(ZWorkflowWithEntities, {
|
|
157
|
+
url: `/workflows/${workflowId}/entities`,
|
|
158
|
+
method: "GET",
|
|
159
|
+
params: options?.params,
|
|
160
|
+
headers: options?.headers,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
async get_entities(workflowId, options) {
|
|
164
|
+
return this.getEntities(workflowId, options);
|
|
13
165
|
}
|
|
14
166
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CompositionClient, RequestOptions } from "../../../client.js";
|
|
2
|
+
import { WorkflowEdge, WorkflowEdgeCreateRequest } from "../../../types.js";
|
|
3
|
+
type LegacyWorkflowEdgeCreateRequest = {
|
|
4
|
+
id: string;
|
|
5
|
+
source_block: string;
|
|
6
|
+
target_block: string;
|
|
7
|
+
source_handle?: string;
|
|
8
|
+
target_handle?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Workflow Edges API client for managing connections between blocks.
|
|
12
|
+
*
|
|
13
|
+
* Usage: `client.workflows.edges.list(workflowId)`
|
|
14
|
+
*/
|
|
15
|
+
export default class APIWorkflowEdges extends CompositionClient {
|
|
16
|
+
constructor(client: CompositionClient);
|
|
17
|
+
/**
|
|
18
|
+
* List all edges for a workflow.
|
|
19
|
+
*
|
|
20
|
+
* @param workflowId - The workflow ID
|
|
21
|
+
* @param sourceBlock - Optional: filter by source block ID
|
|
22
|
+
* @param targetBlock - Optional: filter by target block ID
|
|
23
|
+
*/
|
|
24
|
+
list(workflowId: string, { sourceBlock, targetBlock }?: {
|
|
25
|
+
sourceBlock?: string;
|
|
26
|
+
targetBlock?: string;
|
|
27
|
+
}, options?: RequestOptions): Promise<WorkflowEdge[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a single edge by ID.
|
|
30
|
+
*/
|
|
31
|
+
get(workflowId: string, edgeId: string, options?: RequestOptions): Promise<WorkflowEdge>;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new edge connecting two blocks.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const edge = await client.workflows.edges.create("wf_abc123", {
|
|
38
|
+
* id: "edge-1",
|
|
39
|
+
* sourceBlock: "start-1",
|
|
40
|
+
* targetBlock: "extract-1",
|
|
41
|
+
* sourceHandle: "output-file-0",
|
|
42
|
+
* targetHandle: "input-file-0",
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
create(workflowId: string, request: WorkflowEdgeCreateRequest, options?: RequestOptions): Promise<WorkflowEdge>;
|
|
47
|
+
/**
|
|
48
|
+
* Create multiple edges in a single request.
|
|
49
|
+
*
|
|
50
|
+
* @param workflowId - The workflow ID
|
|
51
|
+
* @param edges - Array of edge definitions
|
|
52
|
+
*/
|
|
53
|
+
createBatch(workflowId: string, edges: Array<WorkflowEdgeCreateRequest | LegacyWorkflowEdgeCreateRequest>, options?: RequestOptions): Promise<WorkflowEdge[]>;
|
|
54
|
+
create_batch(workflowId: string, edges: Array<WorkflowEdgeCreateRequest | LegacyWorkflowEdgeCreateRequest>, options?: RequestOptions): Promise<WorkflowEdge[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Delete an edge.
|
|
57
|
+
*/
|
|
58
|
+
delete(workflowId: string, edgeId: string, options?: RequestOptions): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Delete all edges for a workflow.
|
|
61
|
+
*/
|
|
62
|
+
deleteAll(workflowId: string, options?: RequestOptions): Promise<void>;
|
|
63
|
+
delete_all(workflowId: string, options?: RequestOptions): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/workflows/edges/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAiB,MAAM,mBAAmB,CAAC;AAE3F,KAAK,+BAA+B,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAeF;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,iBAAiB;gBAC/C,MAAM,EAAE,iBAAiB;IAIrC;;;;;;OAMG;IACG,IAAI,CACN,UAAU,EAAE,MAAM,EAClB,EAAE,WAAW,EAAE,WAAW,EAAE,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,EACjF,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,EAAE,CAAC;IAiB1B;;OAEG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAS9F;;;;;;;;;;;;;OAaG;IACG,MAAM,CACR,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,yBAAyB,EAClC,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,CAAC;IAUxB;;;;;OAKG;IACG,WAAW,CACb,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,KAAK,CAAC,yBAAyB,GAAG,+BAA+B,CAAC,EACzE,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,EAAE,CAAC;IAUpB,YAAY,CACd,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,KAAK,CAAC,yBAAyB,GAAG,+BAA+B,CAAC,EACzE,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,YAAY,EAAE,CAAC;IAI1B;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IASzF;;OAEG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAStE,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAGhF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { CompositionClient } from "../../../client.js";
|
|
3
|
+
import { ZWorkflowEdge } from "../../../types.js";
|
|
4
|
+
function serializeEdgeCreateRequest(request) {
|
|
5
|
+
const legacyRequest = request;
|
|
6
|
+
return {
|
|
7
|
+
id: request.id,
|
|
8
|
+
source_block: "sourceBlock" in request ? request.sourceBlock : legacyRequest.source_block,
|
|
9
|
+
target_block: "targetBlock" in request ? request.targetBlock : legacyRequest.target_block,
|
|
10
|
+
source_handle: "sourceHandle" in request ? request.sourceHandle : legacyRequest.source_handle,
|
|
11
|
+
target_handle: "targetHandle" in request ? request.targetHandle : legacyRequest.target_handle,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Workflow Edges API client for managing connections between blocks.
|
|
16
|
+
*
|
|
17
|
+
* Usage: `client.workflows.edges.list(workflowId)`
|
|
18
|
+
*/
|
|
19
|
+
export default class APIWorkflowEdges extends CompositionClient {
|
|
20
|
+
constructor(client) {
|
|
21
|
+
super(client);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* List all edges for a workflow.
|
|
25
|
+
*
|
|
26
|
+
* @param workflowId - The workflow ID
|
|
27
|
+
* @param sourceBlock - Optional: filter by source block ID
|
|
28
|
+
* @param targetBlock - Optional: filter by target block ID
|
|
29
|
+
*/
|
|
30
|
+
async list(workflowId, { sourceBlock, targetBlock } = {}, options) {
|
|
31
|
+
const params = Object.fromEntries(Object.entries({
|
|
32
|
+
source_block: sourceBlock,
|
|
33
|
+
target_block: targetBlock,
|
|
34
|
+
...(options?.params || {}),
|
|
35
|
+
}).filter(([_, v]) => v !== undefined));
|
|
36
|
+
return this._fetchJson(z.array(ZWorkflowEdge), {
|
|
37
|
+
url: `/workflows/${workflowId}/edges`,
|
|
38
|
+
method: "GET",
|
|
39
|
+
params,
|
|
40
|
+
headers: options?.headers,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get a single edge by ID.
|
|
45
|
+
*/
|
|
46
|
+
async get(workflowId, edgeId, options) {
|
|
47
|
+
return this._fetchJson(ZWorkflowEdge, {
|
|
48
|
+
url: `/workflows/${workflowId}/edges/${edgeId}`,
|
|
49
|
+
method: "GET",
|
|
50
|
+
params: options?.params,
|
|
51
|
+
headers: options?.headers,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a new edge connecting two blocks.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const edge = await client.workflows.edges.create("wf_abc123", {
|
|
60
|
+
* id: "edge-1",
|
|
61
|
+
* sourceBlock: "start-1",
|
|
62
|
+
* targetBlock: "extract-1",
|
|
63
|
+
* sourceHandle: "output-file-0",
|
|
64
|
+
* targetHandle: "input-file-0",
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
async create(workflowId, request, options) {
|
|
69
|
+
return this._fetchJson(ZWorkflowEdge, {
|
|
70
|
+
url: `/workflows/${workflowId}/edges`,
|
|
71
|
+
method: "POST",
|
|
72
|
+
body: { ...serializeEdgeCreateRequest(request), ...(options?.body || {}) },
|
|
73
|
+
params: options?.params,
|
|
74
|
+
headers: options?.headers,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create multiple edges in a single request.
|
|
79
|
+
*
|
|
80
|
+
* @param workflowId - The workflow ID
|
|
81
|
+
* @param edges - Array of edge definitions
|
|
82
|
+
*/
|
|
83
|
+
async createBatch(workflowId, edges, options) {
|
|
84
|
+
return this._fetchJson(z.array(ZWorkflowEdge), {
|
|
85
|
+
url: `/workflows/${workflowId}/edges/batch`,
|
|
86
|
+
method: "POST",
|
|
87
|
+
body: edges.map((edge) => serializeEdgeCreateRequest(edge)),
|
|
88
|
+
params: options?.params,
|
|
89
|
+
headers: options?.headers,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async create_batch(workflowId, edges, options) {
|
|
93
|
+
return this.createBatch(workflowId, edges, options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Delete an edge.
|
|
97
|
+
*/
|
|
98
|
+
async delete(workflowId, edgeId, options) {
|
|
99
|
+
return this._fetchJson({
|
|
100
|
+
url: `/workflows/${workflowId}/edges/${edgeId}`,
|
|
101
|
+
method: "DELETE",
|
|
102
|
+
params: options?.params,
|
|
103
|
+
headers: options?.headers,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Delete all edges for a workflow.
|
|
108
|
+
*/
|
|
109
|
+
async deleteAll(workflowId, options) {
|
|
110
|
+
return this._fetchJson({
|
|
111
|
+
url: `/workflows/${workflowId}/edges`,
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
params: options?.params,
|
|
114
|
+
headers: options?.headers,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async delete_all(workflowId, options) {
|
|
118
|
+
return this.deleteAll(workflowId, options);
|
|
119
|
+
}
|
|
120
|
+
}
|