@retab/node 1.0.98 → 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 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +4 -0
- 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 +81 -34
- 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 +1 -128
- 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 +3 -64
- 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 +7 -1
- package/dist/api/jobs/client.d.ts +11 -9
- package/dist/api/jobs/client.d.ts.map +1 -1
- package/dist/api/jobs/client.js +7 -11
- 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 +451 -22
- package/dist/api/schemas/client.d.ts +3 -0
- package/dist/api/schemas/client.d.ts.map +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 +73 -1
- package/dist/api/workflows/client.d.ts.map +1 -1
- package/dist/api/workflows/client.js +121 -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 +111 -112
- 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 +61 -13
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +78 -4
- package/dist/generated_types.d.ts +7751 -2718
- package/dist/generated_types.d.ts.map +1 -1
- package/dist/generated_types.js +709 -68
- 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 +614 -109
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +70 -14
- package/package.json +1 -1
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import { CompositionClient, RequestOptions } from "../../../../client.js";
|
|
2
|
-
import { StepOutputResponse, WorkflowRunStep } from "../../../../types.js";
|
|
2
|
+
import { StepOutputResponse, StepOutputsBatchResponse, WorkflowRunStep, WorkflowRun } from "../../../../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Workflow Run Steps API client for accessing step-level outputs.
|
|
5
5
|
*
|
|
6
|
-
* Usage: `client.workflows.runs.steps.get(runId, nodeId)` or `client.workflows.runs.steps.
|
|
6
|
+
* Usage: `client.workflows.runs.steps.get(runId, nodeId)` or `client.workflows.runs.steps.getMany(runId, nodeIds)`
|
|
7
7
|
*/
|
|
8
8
|
export default class APIWorkflowRunSteps extends CompositionClient {
|
|
9
9
|
constructor(client: CompositionClient);
|
|
10
10
|
/**
|
|
11
|
-
* Get
|
|
12
|
-
*
|
|
13
|
-
* @param runId - The ID of the workflow run
|
|
14
|
-
* @param nodeId - The ID of the node/step to get output for
|
|
15
|
-
* @param options - Optional request options
|
|
16
|
-
* @returns The step output with handle outputs and inputs
|
|
11
|
+
* Get step status and handle data for a specific step in a workflow run.
|
|
17
12
|
*
|
|
18
13
|
* @example
|
|
19
14
|
* ```typescript
|
|
20
15
|
* const step = await client.workflows.runs.steps.get("run_abc123", "extract-node-1");
|
|
21
|
-
*
|
|
16
|
+
* const data = step.handle_outputs?.["output-json-0"]?.data;
|
|
22
17
|
* ```
|
|
23
18
|
*/
|
|
24
19
|
get(runId: string, nodeId: string, options?: RequestOptions): Promise<StepOutputResponse>;
|
|
25
20
|
/**
|
|
26
21
|
* List all persisted step documents for a workflow run.
|
|
27
22
|
*
|
|
28
|
-
* @param runId - The ID of the workflow run
|
|
29
|
-
* @param options - Optional request options
|
|
30
|
-
* @returns All step documents for the run
|
|
31
|
-
*
|
|
32
23
|
* @example
|
|
33
24
|
* ```typescript
|
|
34
25
|
* const steps = await client.workflows.runs.steps.list("run_abc123");
|
|
@@ -38,5 +29,36 @@ export default class APIWorkflowRunSteps extends CompositionClient {
|
|
|
38
29
|
* ```
|
|
39
30
|
*/
|
|
40
31
|
list(runId: string, options?: RequestOptions): Promise<WorkflowRunStep[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Batch-get step outputs for multiple nodes in a single request.
|
|
34
|
+
*
|
|
35
|
+
* @param runId - The workflow run ID
|
|
36
|
+
* @param nodeIds - List of node IDs to fetch outputs for
|
|
37
|
+
* @returns Step outputs keyed by node ID
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const batch = await client.workflows.runs.steps.getMany("run_abc123", ["extract-1", "classifier-1"]);
|
|
42
|
+
* console.log(batch.outputs["extract-1"]?.handle_outputs);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
getMany(runId: string, nodeIds: string[], options?: RequestOptions): Promise<StepOutputsBatchResponse>;
|
|
46
|
+
get_many(runId: string, nodeIds: string[], options?: RequestOptions): Promise<StepOutputsBatchResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Fetch outputs for all steps in a workflow run in one call.
|
|
49
|
+
*
|
|
50
|
+
* Internally fetches the run to discover step node IDs, then batch-fetches all outputs.
|
|
51
|
+
*
|
|
52
|
+
* @param runId - The workflow run ID
|
|
53
|
+
* @returns Step outputs keyed by node ID
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const allOutputs = await client.workflows.runs.steps.getAll("run_abc123");
|
|
58
|
+
* console.log(allOutputs.outputs["extract-1"]?.handle_outputs);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
getAll(run: WorkflowRun | string, options?: RequestOptions): Promise<StepOutputsBatchResponse>;
|
|
62
|
+
get_all(run: WorkflowRun | string, options?: RequestOptions): Promise<StepOutputsBatchResponse>;
|
|
41
63
|
}
|
|
42
64
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/api/workflows/runs/steps/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EACH,kBAAkB,EAElB,eAAe,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/api/workflows/runs/steps/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EACH,kBAAkB,EAElB,wBAAwB,EAExB,eAAe,EAEf,WAAW,EAEd,MAAM,sBAAsB,CAAC;AAG9B;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,iBAAiB;gBAClD,MAAM,EAAE,iBAAiB;IAIrC;;;;;;;;OAQG;IACG,GAAG,CACL,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,kBAAkB,CAAC;IAS9B;;;;;;;;;;OAUG;IACG,IAAI,CACN,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,eAAe,EAAE,CAAC;IAS7B;;;;;;;;;;;;OAYG;IACG,OAAO,CACT,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,wBAAwB,CAAC;IAU9B,QAAQ,CACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,wBAAwB,CAAC;IAIpC;;;;;;;;;;;;;OAaG;IACG,MAAM,CACR,GAAG,EAAE,WAAW,GAAG,MAAM,EACzB,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,wBAAwB,CAAC;IAkB9B,OAAO,CACT,GAAG,EAAE,WAAW,GAAG,MAAM,EACzB,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,wBAAwB,CAAC;CAGvC"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { CompositionClient } from "../../../../client.js";
|
|
2
|
-
import { ZStepOutputResponse, ZWorkflowRunStep, } from "../../../../types.js";
|
|
2
|
+
import { ZStepOutputResponse, ZStepOutputsBatchResponse, ZWorkflowRunStep, ZWorkflowRun, } from "../../../../types.js";
|
|
3
3
|
import * as z from "zod";
|
|
4
4
|
/**
|
|
5
5
|
* Workflow Run Steps API client for accessing step-level outputs.
|
|
6
6
|
*
|
|
7
|
-
* Usage: `client.workflows.runs.steps.get(runId, nodeId)` or `client.workflows.runs.steps.
|
|
7
|
+
* Usage: `client.workflows.runs.steps.get(runId, nodeId)` or `client.workflows.runs.steps.getMany(runId, nodeIds)`
|
|
8
8
|
*/
|
|
9
9
|
export default class APIWorkflowRunSteps extends CompositionClient {
|
|
10
10
|
constructor(client) {
|
|
11
11
|
super(client);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Get
|
|
15
|
-
*
|
|
16
|
-
* @param runId - The ID of the workflow run
|
|
17
|
-
* @param nodeId - The ID of the node/step to get output for
|
|
18
|
-
* @param options - Optional request options
|
|
19
|
-
* @returns The step output with handle outputs and inputs
|
|
14
|
+
* Get step status and handle data for a specific step in a workflow run.
|
|
20
15
|
*
|
|
21
16
|
* @example
|
|
22
17
|
* ```typescript
|
|
23
18
|
* const step = await client.workflows.runs.steps.get("run_abc123", "extract-node-1");
|
|
24
|
-
*
|
|
19
|
+
* const data = step.handle_outputs?.["output-json-0"]?.data;
|
|
25
20
|
* ```
|
|
26
21
|
*/
|
|
27
22
|
async get(runId, nodeId, options) {
|
|
@@ -35,10 +30,6 @@ export default class APIWorkflowRunSteps extends CompositionClient {
|
|
|
35
30
|
/**
|
|
36
31
|
* List all persisted step documents for a workflow run.
|
|
37
32
|
*
|
|
38
|
-
* @param runId - The ID of the workflow run
|
|
39
|
-
* @param options - Optional request options
|
|
40
|
-
* @returns All step documents for the run
|
|
41
|
-
*
|
|
42
33
|
* @example
|
|
43
34
|
* ```typescript
|
|
44
35
|
* const steps = await client.workflows.runs.steps.list("run_abc123");
|
|
@@ -55,4 +46,61 @@ export default class APIWorkflowRunSteps extends CompositionClient {
|
|
|
55
46
|
headers: options?.headers,
|
|
56
47
|
});
|
|
57
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Batch-get step outputs for multiple nodes in a single request.
|
|
51
|
+
*
|
|
52
|
+
* @param runId - The workflow run ID
|
|
53
|
+
* @param nodeIds - List of node IDs to fetch outputs for
|
|
54
|
+
* @returns Step outputs keyed by node ID
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const batch = await client.workflows.runs.steps.getMany("run_abc123", ["extract-1", "classifier-1"]);
|
|
59
|
+
* console.log(batch.outputs["extract-1"]?.handle_outputs);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
async getMany(runId, nodeIds, options) {
|
|
63
|
+
return this._fetchJson(ZStepOutputsBatchResponse, {
|
|
64
|
+
url: `/workflows/runs/${runId}/steps/batch`,
|
|
65
|
+
method: "POST",
|
|
66
|
+
body: { node_ids: nodeIds, ...(options?.body || {}) },
|
|
67
|
+
params: options?.params,
|
|
68
|
+
headers: options?.headers,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async get_many(runId, nodeIds, options) {
|
|
72
|
+
return this.getMany(runId, nodeIds, options);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fetch outputs for all steps in a workflow run in one call.
|
|
76
|
+
*
|
|
77
|
+
* Internally fetches the run to discover step node IDs, then batch-fetches all outputs.
|
|
78
|
+
*
|
|
79
|
+
* @param runId - The workflow run ID
|
|
80
|
+
* @returns Step outputs keyed by node ID
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const allOutputs = await client.workflows.runs.steps.getAll("run_abc123");
|
|
85
|
+
* console.log(allOutputs.outputs["extract-1"]?.handle_outputs);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
async getAll(run, options) {
|
|
89
|
+
const workflowRun = typeof run === "string"
|
|
90
|
+
? await this._fetchJson(ZWorkflowRun, {
|
|
91
|
+
url: `/workflows/runs/${run}`,
|
|
92
|
+
method: "GET",
|
|
93
|
+
params: options?.params,
|
|
94
|
+
headers: options?.headers,
|
|
95
|
+
})
|
|
96
|
+
: run;
|
|
97
|
+
const nodeIds = workflowRun.steps.map((s) => s.node_id);
|
|
98
|
+
if (nodeIds.length === 0) {
|
|
99
|
+
return { outputs: {} };
|
|
100
|
+
}
|
|
101
|
+
return this.getMany(workflowRun.id, nodeIds, options);
|
|
102
|
+
}
|
|
103
|
+
async get_all(run, options) {
|
|
104
|
+
return this.getAll(run, options);
|
|
105
|
+
}
|
|
58
106
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type FetchParams = {
|
|
|
5
5
|
params?: Record<string, any>;
|
|
6
6
|
headers?: Record<string, any>;
|
|
7
7
|
bodyMime?: "application/json" | "multipart/form-data";
|
|
8
|
-
body?: Record<string, any
|
|
8
|
+
body?: Record<string, any> | unknown[];
|
|
9
9
|
auth?: string[];
|
|
10
10
|
};
|
|
11
11
|
export declare class AbstractClient {
|
|
@@ -18,6 +18,8 @@ export declare class CompositionClient extends AbstractClient {
|
|
|
18
18
|
protected _client: AbstractClient;
|
|
19
19
|
constructor(client: AbstractClient);
|
|
20
20
|
protected _fetch(params: FetchParams): Promise<Response>;
|
|
21
|
+
private _installPrepareMethods;
|
|
22
|
+
protected _capturePreparedRequest(methodName: string, args: unknown[]): Promise<FetchParams>;
|
|
21
23
|
}
|
|
22
24
|
export declare class APIError extends Error {
|
|
23
25
|
status: number;
|
|
@@ -50,7 +52,7 @@ export declare class FetcherClient extends AbstractClient {
|
|
|
50
52
|
params?: Record<string, any>;
|
|
51
53
|
headers?: Record<string, any>;
|
|
52
54
|
bodyMime?: "application/json" | "multipart/form-data";
|
|
53
|
-
body?: Record<string, any
|
|
55
|
+
body?: Record<string, any> | unknown[];
|
|
54
56
|
}): Promise<Response>;
|
|
55
57
|
/**
|
|
56
58
|
* Verify the signature of a webhook event.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,kBAAkB,GAAG,qBAAqB,CAAC;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"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"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import * as crypto from "crypto";
|
|
3
|
+
const PYTHON_PUBLIC_PREPARE_METHODS = {
|
|
4
|
+
APIModels: ["list"],
|
|
5
|
+
APISchemas: ["generate"],
|
|
6
|
+
APIExtractions: ["list", "download", "update", "get", "sources", "delete"],
|
|
7
|
+
APIFiles: ["upload", "list", "get", "get_download_link"],
|
|
8
|
+
APIProjects: ["create", "get", "list", "delete", "publish", "extract", "split"],
|
|
9
|
+
ProjectDatasets: ["create", "get", "list", "update", "delete", "duplicate", "add_document", "get_document", "list_documents", "update_document", "delete_document"],
|
|
10
|
+
ProjectIterations: ["create", "get", "list", "update_draft", "delete", "finalize", "get_schema", "process_documents", "get_document", "list_documents", "update_document", "delete_document", "get_metrics"],
|
|
11
|
+
APIWorkflows: ["get", "list", "create", "update", "delete", "publish", "duplicate", "get_entities"],
|
|
12
|
+
APIWorkflowBlocks: ["list", "get", "create", "create_batch", "update", "delete"],
|
|
13
|
+
APIWorkflowEdges: ["list", "get", "create", "create_batch", "delete", "delete_all"],
|
|
14
|
+
APIWorkflowRuns: ["create", "get", "list", "delete", "cancel", "restart", "resume"],
|
|
15
|
+
APIWorkflowRunSteps: ["get", "list", "get_many"],
|
|
16
|
+
APIEvalsExtract: ["process", "process_stream"],
|
|
17
|
+
APIEvalsSplit: ["process"],
|
|
18
|
+
APIEvalsClassify: ["process"],
|
|
19
|
+
};
|
|
3
20
|
async function* streamResponse(schema, response) {
|
|
4
21
|
let body = "";
|
|
5
22
|
let depth = 0;
|
|
@@ -57,7 +74,7 @@ export class AbstractClient {
|
|
|
57
74
|
if (!bodyType) {
|
|
58
75
|
return;
|
|
59
76
|
}
|
|
60
|
-
if (response.headers.get("Content-Type")
|
|
77
|
+
if (!response.headers.get("Content-Type")?.startsWith("application/json"))
|
|
61
78
|
throw new APIError(response.status, "Response is not JSON");
|
|
62
79
|
return bodyType.parseAsync(await response.json());
|
|
63
80
|
}
|
|
@@ -66,7 +83,7 @@ export class AbstractClient {
|
|
|
66
83
|
if (!response.ok) {
|
|
67
84
|
throw new APIError(response.status, await response.text());
|
|
68
85
|
}
|
|
69
|
-
if (response.headers.get("Content-Type")
|
|
86
|
+
if (!response.headers.get("Content-Type")?.startsWith("application/stream+json"))
|
|
70
87
|
throw new APIError(response.status, "Response is not stream JSON");
|
|
71
88
|
return streamResponse(schema, response);
|
|
72
89
|
}
|
|
@@ -75,10 +92,66 @@ export class CompositionClient extends AbstractClient {
|
|
|
75
92
|
constructor(client) {
|
|
76
93
|
super();
|
|
77
94
|
this._client = client;
|
|
95
|
+
this._installPrepareMethods();
|
|
78
96
|
}
|
|
79
97
|
_fetch(params) {
|
|
80
98
|
return this._client["_fetch"](params);
|
|
81
99
|
}
|
|
100
|
+
_installPrepareMethods() {
|
|
101
|
+
const allowedMethods = PYTHON_PUBLIC_PREPARE_METHODS[this.constructor.name] ?? [];
|
|
102
|
+
if (allowedMethods.length === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const methodName of allowedMethods) {
|
|
106
|
+
const method = this[methodName];
|
|
107
|
+
const prepareMethodName = `prepare_${methodName}`;
|
|
108
|
+
if (typeof method !== "function" || prepareMethodName in this) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
Object.defineProperty(this, prepareMethodName, {
|
|
112
|
+
configurable: true,
|
|
113
|
+
enumerable: false,
|
|
114
|
+
writable: false,
|
|
115
|
+
value: (...args) => this._capturePreparedRequest(methodName, args),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async _capturePreparedRequest(methodName, args) {
|
|
120
|
+
let capturedRequest;
|
|
121
|
+
const self = this;
|
|
122
|
+
const originalFetch = self._fetch;
|
|
123
|
+
const originalFetchJson = self._fetchJson;
|
|
124
|
+
const originalFetchStream = self._fetchStream;
|
|
125
|
+
self._fetch = async (params) => {
|
|
126
|
+
capturedRequest = params;
|
|
127
|
+
return new Response("{}", {
|
|
128
|
+
status: 200,
|
|
129
|
+
headers: {
|
|
130
|
+
"Content-Type": "application/json",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
self._fetchJson = async (...fetchArgs) => {
|
|
135
|
+
capturedRequest = (fetchArgs.length === 2 ? fetchArgs[1] : fetchArgs[0]);
|
|
136
|
+
return {};
|
|
137
|
+
};
|
|
138
|
+
self._fetchStream = async (...fetchArgs) => {
|
|
139
|
+
capturedRequest = fetchArgs[1];
|
|
140
|
+
return (async function* emptyStream() { })();
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
await self[methodName](...args);
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
self._fetch = originalFetch;
|
|
147
|
+
self._fetchJson = originalFetchJson;
|
|
148
|
+
self._fetchStream = originalFetchStream;
|
|
149
|
+
}
|
|
150
|
+
if (!capturedRequest) {
|
|
151
|
+
throw new Error(`Unable to capture prepared request for ${methodName}`);
|
|
152
|
+
}
|
|
153
|
+
return capturedRequest;
|
|
154
|
+
}
|
|
82
155
|
}
|
|
83
156
|
export class APIError extends Error {
|
|
84
157
|
constructor(status, info) {
|
|
@@ -124,8 +197,9 @@ export class FetcherClient extends AbstractClient {
|
|
|
124
197
|
if (params.method !== "GET") {
|
|
125
198
|
if (params.bodyMime === "multipart/form-data") {
|
|
126
199
|
let formData = new FormData();
|
|
127
|
-
|
|
128
|
-
|
|
200
|
+
const multipartBody = (params.body || {});
|
|
201
|
+
for (const key of Object.keys(multipartBody)) {
|
|
202
|
+
let value = multipartBody[key];
|
|
129
203
|
if (Array.isArray(value)) {
|
|
130
204
|
for (const item of value) {
|
|
131
205
|
formData.append(key, item);
|