@docmana/sdk 0.3.5 → 0.4.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.
Files changed (47) hide show
  1. package/README.md +115 -247
  2. package/dist/api/execution-result.d.ts +3 -0
  3. package/dist/api/execution-status.d.ts +6 -0
  4. package/dist/api/run-flow.d.ts +6 -0
  5. package/dist/cli.mjs +217 -257
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/client.d.ts +21 -0
  8. package/dist/config.d.ts +21 -0
  9. package/dist/errors.d.ts +55 -0
  10. package/dist/files/resolve-input.d.ts +11 -0
  11. package/dist/http/http-client.d.ts +26 -0
  12. package/dist/index.d.ts +4 -349
  13. package/dist/index.js +159 -298
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +159 -298
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/models/docmana-api-document-execution-result.model.d.ts +9 -0
  18. package/dist/models/docmana-api-document-request.model.d.ts +15 -0
  19. package/dist/models/docmana-api-execution-result.model.d.ts +24 -0
  20. package/dist/models/docmana-api-node-result.model.d.ts +28 -0
  21. package/dist/models/docmana-classification-result.model.d.ts +3 -0
  22. package/dist/models/docmana-conclusion-result.model.d.ts +3 -0
  23. package/dist/models/docmana-cross-validation-result.model.d.ts +3 -0
  24. package/dist/models/docmana-document-mapping.model.d.ts +4 -0
  25. package/dist/models/docmana-document-result.model.d.ts +11 -0
  26. package/dist/models/docmana-execution-result.model.d.ts +15 -0
  27. package/dist/models/docmana-extraction-result.model.d.ts +3 -0
  28. package/dist/models/docmana-metadata-extraction-result.model.d.ts +3 -0
  29. package/dist/models/docmana-node-result.model.d.ts +7 -0
  30. package/dist/models/docmana-score-node-result.model.d.ts +5 -0
  31. package/dist/models/docmana-validation-result.model.d.ts +3 -0
  32. package/dist/models/document-content.model.d.ts +4 -0
  33. package/dist/models/execution-progress.model.d.ts +4 -0
  34. package/dist/models/execution-status.enum.d.ts +1 -0
  35. package/dist/models/flow-configs.model.d.ts +16 -0
  36. package/dist/models/flow-edge.model.d.ts +4 -0
  37. package/dist/models/flow-node-type.enum.d.ts +1 -0
  38. package/dist/models/flow-node.model.d.ts +33 -0
  39. package/dist/models/flow.model.d.ts +11 -0
  40. package/dist/models/index.d.ts +26 -0
  41. package/dist/models/node-translation-result.model.d.ts +7 -0
  42. package/dist/models/physical-document.model.d.ts +9 -0
  43. package/dist/models/virtual-document.model.d.ts +10 -0
  44. package/dist/polling/poll.d.ts +15 -0
  45. package/dist/types.d.ts +76 -0
  46. package/package.json +17 -14
  47. package/dist/index.d.cts +0 -349
package/README.md CHANGED
@@ -1,12 +1,9 @@
1
1
  # @docmana/sdk
2
2
 
3
- Official Docmana SDK run document-analysis flows with a single call.
3
+ Official Docmana SDK for calling `docmana-consumer-edge-api`.
4
4
 
5
- Docmana's HTTP API requires four steps to analyze a document: upload the file, start a flow run, poll for status, then fetch the result. This SDK collapses all four into one call. Authentication, token caching, and polling are handled for you.
6
-
7
- ```ts
8
- const result = await docmana.runFlow("<flow-id>", { file: "./contract.pdf" });
9
- ```
5
+ The SDK sends documents to Consumer, starts an async flow, polls Consumer for
6
+ status, and returns the mapped Consumer execution DTO.
10
7
 
11
8
  ## Installation
12
9
 
@@ -22,103 +19,92 @@ Requires Node.js 20+.
22
19
  import { Docmana } from "@docmana/sdk";
23
20
 
24
21
  const docmana = new Docmana({
25
- clientId: process.env.DOCMANA_CLIENT_ID!,
26
- clientSecret: process.env.DOCMANA_CLIENT_SECRET!,
22
+ apiBaseUrl: process.env.DOCMANA_API_URL!,
23
+ accessToken: process.env.DOCMANA_ACCESS_TOKEN!,
27
24
  });
28
25
 
29
- const result = await docmana.runFlow("<flow-id>", { file: "./contract.pdf" });
26
+ const result = await docmana.runFlow("<flow-id>", {
27
+ file: "./contract.pdf",
28
+ context: { contract: { destination: "Canada" } },
29
+ useDraftVersion: true,
30
+ });
30
31
 
31
- console.log(result.status, result.results);
32
+ console.log(result.status, result.executionId);
32
33
  ```
33
34
 
34
- The package ships both ESM and CommonJS builds. In a CommonJS project:
35
+ ## Authentication
35
36
 
36
- ```js
37
- const { Docmana } = require("@docmana/sdk");
37
+ The public SDK is Bearer-only. It does not acquire OAuth tokens and it never
38
+ calls `docmana-api` directly. Provide either a static `accessToken` or a
39
+ `getAccessToken` provider:
38
40
 
41
+ ```ts
39
42
  const docmana = new Docmana({
40
- clientId: process.env.DOCMANA_CLIENT_ID,
41
- clientSecret: process.env.DOCMANA_CLIENT_SECRET,
43
+ apiBaseUrl: "https://consumer.example.com/v1",
44
+ getAccessToken: async ({ forceRefresh } = {}) => {
45
+ return forceRefresh ? refreshTokenSomehow() : currentToken();
46
+ },
42
47
  });
43
-
44
- const result = await docmana.runFlow("<flow-id>", { file: "./contract.pdf" });
45
48
  ```
46
49
 
47
- ## Authentication
48
-
49
- The SDK authenticates with OAuth2 `client_credentials` against the Docmana CIAM tenant. Docmana provisions a `client_id` and `client_secret` for you during onboarding pass them to the constructor. The SDK acquires the bearer token on the first request, then caches and refreshes it automatically in memory. You never handle tokens directly.
50
+ If Consumer returns `401` and `getAccessToken` is configured, the SDK calls
51
+ `getAccessToken({ forceRefresh: true })` once and retries the request. With a
52
+ static `accessToken`, `401` is returned as an auth error without retry.
50
53
 
51
54
  ## Configuration
52
55
 
53
- The constructor takes a single `DocmanaConfig` object.
54
-
55
- | Field | Type | Required | Default | Description |
56
- | ---------------- | -------------- | -------- | ----------------------------------------- | ------------------------------------------------------------ |
57
- | `clientId` | `string` | Yes | | OAuth2 client ID provisioned by Docmana at onboarding. |
58
- | `clientSecret` | `string` | Yes | — | OAuth2 client secret provisioned by Docmana at onboarding. |
59
- | `apiBaseUrl` | `string` | No | `https://api.docmana.ai` | Base URL of the Docmana API. |
60
- | `tokenEndpoint` | `string` | No | Docmana CIAM `oauth2/v2.0/token` endpoint | OAuth2 token endpoint used to acquire the bearer token. |
61
- | `scope` | `string` | No | `api://d781e6ba-…/.default` | OAuth2 scope requested for the token. |
62
- | `timeoutMs` | `number` | No | `300000` (5 min) | Maximum time `runFlow` will poll before throwing a timeout. |
63
- | `pollIntervalMs` | `number` | No | `2000` (2 s) | Delay between status polls in `runFlow`. |
64
- | `fetch` | `typeof fetch` | No | global `fetch` | Custom `fetch` implementation (e.g. for proxies or testing). |
56
+ | Field | Type | Required | Description |
57
+ | ------------------- | --------------------------------------------------------------------- | -------- | ------------------------------------------------------------ |
58
+ | `apiBaseUrl` | `string` | Yes | Base URL of Consumer API, including version when applicable. |
59
+ | `accessToken` | `string` | One of | Static Bearer token sent to Consumer. |
60
+ | `getAccessToken` | `(options?: { forceRefresh?: boolean }) => string \| Promise<string>` | One of | Token provider for renewable Bearer tokens. |
61
+ | `timeoutMs` | `number` | No | Maximum polling time for `runFlow`. Default: 5 minutes. |
62
+ | `pollIntervalMs` | `number` | No | Fallback minimum delay between status polls. Default: 2s. |
63
+ | `pollMaxIntervalMs` | `number` | No | Fallback maximum polling delay. Default: 10s. |
64
+ | `fetch` | `typeof fetch` | No | Custom fetch implementation. |
65
+ | `headers` | `Record<string, string>` | No | Extra headers sent on every Consumer request. |
65
66
 
66
- Most integrations only set `clientId` and `clientSecret`. The other fields exist for non-production environments or advanced networking needs.
67
+ `apiBaseUrl` is required so a migrated SDK cannot accidentally call
68
+ `https://api.docmana.ai`.
67
69
 
68
70
  ## Inputs
69
71
 
70
- `runFlow(flowId, input)` (and the lower-level `runFlowAsync`) accept a `RunFlowInput`:
71
-
72
- | Field | Type | Description |
73
- | ---------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- |
74
- | `file` | `string \| { path: string } \| Buffer \| NodeJS.ReadableStream` | A single document. A string or `{ path }` is treated as a file path. |
75
- | `files` | `(string \| { path: string } \| Buffer \| NodeJS.ReadableStream)[]` | Multiple documents for a multi-document flow. |
76
- | `fileName` | `string` | Required when passing a `Buffer` or stream with no derivable name. |
77
- | `signal` | `AbortSignal` | Cancels the in-flight run. |
78
- | `timeoutMs` | `number` | Overrides the configured polling timeout for this call. |
79
- | `pollIntervalMs` | `number` | Overrides the configured poll interval for this call. |
80
-
81
- Provide either `file` or `files`.
82
-
83
- A file path:
84
-
85
- ```ts
86
- await docmana.runFlow("<flow-id>", { file: "./contract.pdf" });
87
- ```
88
-
89
- A `Buffer` (or stream) — supply `fileName` so Docmana can infer the document type:
90
-
91
- ```ts
92
- import { readFile } from "node:fs/promises";
93
-
94
- const buffer = await readFile("./contract.pdf");
95
- await docmana.runFlow("<flow-id>", { file: buffer, fileName: "contract.pdf" });
96
- ```
97
-
98
- Multiple documents:
99
-
100
- ```ts
101
- await docmana.runFlow("<flow-id>", {
102
- files: ["./statement.pdf", "./id-card.png"],
103
- });
104
- ```
105
-
106
- Path objects are also supported, which is useful when your caller already models uploads as
107
- objects:
108
-
109
- ```ts
110
- await docmana.runFlow("<flow-id>", {
111
- files: [{ path: "./contract.pdf" }],
112
- });
113
- ```
114
-
115
- ## Lower-level methods
116
-
117
- `runFlow` is the recommended entry point. If you need to manage polling yourself — for example to surface progress in your own job queue — the underlying steps are exposed:
118
-
119
- - `runFlowAsync(flowId, input)` → `{ executionResultId, fileIds }` — uploads the file(s) and starts the flow without waiting; `fileIds` are the uploaded document UUIDs.
120
- - `getStatus(executionResultId)` → `{ status }` — current execution status (`"Pending" | "Running" | "Completed" | "Failed"`).
121
- - `getResult(executionResultId)` → `ExecutionResult` — the result payload once the flow has finished.
72
+ `runFlow(flowId, input)` and `runFlowAsync(flowId, input)` accept:
73
+
74
+ | Field | Type | Description |
75
+ | ------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------- |
76
+ | `file` | `string \| { path: string } \| Buffer \| NodeJS.ReadableStream` | A single document. A string or `{ path }` is treated as a file path. |
77
+ | `files` | `(string \| { path: string } \| Buffer \| NodeJS.ReadableStream)[]` | Multiple documents for a multi-document flow. |
78
+ | `fileName` | `string` | Required when passing a `Buffer` or stream with no derivable name. |
79
+ | `context` | `Record<string, unknown>` | Business context serialized as multipart `json_context`. |
80
+ | `language` | `string` | Optional result language passed to Consumer. |
81
+ | `useDraftVersion` | `boolean` | Runs the current draft flow version. |
82
+ | `signal` | `AbortSignal` | Cancels the in-flight request/polling. |
83
+ | `timeoutMs` | `number` | Overrides configured polling timeout for this call. |
84
+ | `pollIntervalMs` | `number` | Overrides configured fallback minimum polling interval. |
85
+ | `pollMaxIntervalMs` | `number` | Overrides configured fallback maximum polling interval. |
86
+ | `onPoll` | `(event) => void` | Called after each status poll. |
87
+ | `onRateLimit` | `(event) => void` | Called when polling receives `429`; includes `retryAfterMs`. |
88
+
89
+ `once` was removed. Use `useDraftVersion`.
90
+
91
+ ## Methods
92
+
93
+ - `runFlowAsync(flowId, input)` posts multipart files to
94
+ `POST /v1/flows/:flowId/execute-async` and returns
95
+ `{ executionResultId, fileIds }`.
96
+ - `getStatus(executionResultId)` calls
97
+ `GET /v1/executions/:executionResultId/status`.
98
+ - `getResult(executionResultId, signal?, language?)` calls
99
+ `GET /v1/executions/:executionResultId/result`.
100
+ - `runFlow(flowId, input)` starts async execution, polls status, fetches the
101
+ result, respects `X-Poll-After` and `429 Retry-After` while polling, and throws
102
+ `DocmanaExecutionError` if the result status is `Failed`.
103
+
104
+ Consumer is the polling authority. When `GET /status` returns `X-Poll-After`,
105
+ the SDK waits that many milliseconds before the next status call. If the header
106
+ is absent, the SDK falls back to capped exponential full jitter between
107
+ `pollIntervalMs` and `pollMaxIntervalMs`. `Retry-After` on `429` always wins.
122
108
 
123
109
  ```ts
124
110
  const { executionResultId } = await docmana.runFlowAsync("<flow-id>", {
@@ -131,221 +117,103 @@ while (status !== "Completed" && status !== "Failed") {
131
117
  ({ status } = await docmana.getStatus(executionResultId));
132
118
  }
133
119
 
134
- const result = await docmana.getResult(executionResultId);
135
- console.log(result.status, result.results);
120
+ const result = await docmana.getResult(executionResultId, undefined, "fr");
136
121
  ```
137
122
 
138
- Unlike `runFlow`, `getResult` does not throw on a failed execution — inspect `result.status` and `result.errors` yourself.
139
-
140
123
  ## Webhook callbacks
141
124
 
142
- When you don't want to poll, use `runFlowWithCallback`. It starts the flow with a `callbackUrl` and returns immediately — docmana-api POSTs a completion notification to that URL when the run finishes, so your server never polls.
143
-
144
- - `runFlowWithCallback(flowId, input)` → `{ executionResultId, fileIds }` — uploads the file(s) and starts the flow with the callback registered. It does **not** poll and does **not** fetch the result.
145
-
146
- `input` is a `RunFlowWithCallbackInput`:
147
-
148
- | Field | Type | Required | Description |
149
- | ------------- | ------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------- |
150
- | `callbackUrl` | `string` | Yes | URL docmana-api POSTs the completion notification to (wire: `callback_url`). |
151
- | `file` | `string \| { path: string } \| Buffer \| NodeJS.ReadableStream` | — | A single document. |
152
- | `files` | `(string \| { path: string } \| Buffer \| NodeJS.ReadableStream)[]` | — | Multiple documents for a multi-document flow. |
153
- | `fileName` | `string` | — | Required when passing a `Buffer`/stream with no derivable name. |
154
- | `once` | `boolean` | — | Use the ad-hoc `run_once_flow` endpoint instead of `run_flow`. |
155
- | `context` | `Record<string, unknown>` | — | Business `json_context` passed through to the flow. |
156
- | `signal` | `AbortSignal` | — | Cancels the upload/start. |
157
-
158
- `callbackUrl` lives only on this input — `RunFlowInput` (used by `runFlow`/`runFlowAsync`) has no callback field, so a polling run never registers one.
159
-
160
- The notification payload docmana-api sends is a small JSON object, e.g.:
161
-
162
- ```json
163
- {
164
- "execution_id": "faad872c-…",
165
- "status": "Success",
166
- "timestamp": "2026-06-08T21:45:28.415402+00:00",
167
- "flow_id": "f87bb991-…"
168
- }
169
- ```
170
-
171
- It is a notification only — it does not carry the result. On receipt, fetch and map the full result with `getResult`:
125
+ `runFlowWithCallback` uses the same Consumer async endpoint with `callback_url`.
126
+ It returns immediately and does not poll.
172
127
 
173
128
  ```ts
174
129
  const { executionResultId } = await docmana.runFlowWithCallback("<flow-id>", {
175
130
  file: "./contract.pdf",
176
131
  callbackUrl: "https://your-service.example.com/webhooks/docmana/executions",
132
+ language: "fr",
177
133
  });
178
-
179
- // …later, in your webhook handler, keyed by the notification's execution_id:
180
- const result = await docmana.getResult(execution_id);
181
- console.log(result.status, result.results);
182
134
  ```
183
135
 
184
- ## CLI
185
-
186
- The package also installs a `docmana` command for simple terminal usage:
136
+ Consumer posts the mapped result DTO to your callback URL when the execution is
137
+ finished. Keep `executionResultId` if you also want to poll as a fallback.
187
138
 
188
- ```bash
189
- docmana flow run "<flow-id>" --files "./contract.pdf" --organisation "<organisation-id>"
190
- ```
139
+ ## CLI
191
140
 
192
- You can create a local config file interactively:
141
+ The CLI can still acquire and cache a token through OAuth:
193
142
 
194
143
  ```bash
195
144
  docmana config init
145
+ docmana login
196
146
  ```
197
147
 
198
- This writes `docmana.config.json` in the current directory. The file can include Docmana URLs,
199
- scope, organisation, client id, and client secret, so it is ignored by Git.
148
+ `docmana login` reads `clientId`, `clientSecret`, `tokenEndpoint`, and `scope`
149
+ from flags, environment variables, or `docmana.config.json`, then stores the
150
+ access token in `docmana.token.json`.
200
151
 
201
- Use a custom config path when needed:
202
-
203
- ```bash
204
- docmana config init --config ./docmana.dev.config.json
205
- docmana flow run "<flow-id>" --files "./contract.pdf" --config ./docmana.dev.config.json
206
- ```
152
+ `docmana flow run` always passes a Bearer token to the SDK. It resolves the token
153
+ in this order:
207
154
 
208
- `flow run` automatically loads `./docmana.config.json` when present. Credentials and connection
209
- settings can also be read from the environment:
155
+ 1. `--access-token`
156
+ 2. `DOCMANA_ACCESS_TOKEN`
157
+ 3. valid `docmana.token.json`
158
+ 4. OAuth refresh using CLI/config credentials
210
159
 
211
160
  ```bash
212
- DOCMANA_CLIENT_ID="<client-id>"
213
- DOCMANA_CLIENT_SECRET="<client-secret>"
214
- DOCMANA_ORGANISATION="<organisation-id>"
215
- DOCMANA_API_URL="https://api.docmana.ai"
216
- DOCMANA_TOKEN_URL="<token-endpoint>"
217
- DOCMANA_SCOPE="<oauth-scope>"
218
-
219
- docmana flow run "<flow-id>" --files "./contract.pdf,./annexe.pdf"
161
+ DOCMANA_API_URL="https://consumer.example.com/v1"
162
+ docmana flow run "<flow-id>" --files "./contract.pdf"
220
163
  ```
221
164
 
222
- You can override config or environment values with flags:
165
+ You can also run without the cache:
223
166
 
224
167
  ```bash
225
168
  docmana flow run "<flow-id>" \
226
- --files "./contract.pdf" \
227
- --client-id "<client-id>" \
228
- --client-secret "<client-secret>" \
229
- --organisation "<organisation-id>" \
230
- --api-url "https://api.docmana.ai" \
231
- --token-url "<token-endpoint>" \
232
- --scope "<oauth-scope>"
233
- ```
234
-
235
- The CLI caches OAuth2 access tokens in `docmana.token.json` by default, so repeated commands do
236
- not request a new token until the cached token expires. The cache file is ignored by Git. Use a
237
- custom token cache path when needed:
238
-
239
- ```bash
240
- docmana login
241
- docmana flow run "<flow-id>" --files "./contract.pdf" --token-cache ./docmana.dev.token.json
242
- ```
243
-
244
- `docmana login` loads the same config, environment variables, and auth flags as `flow run`, then
245
- ensures a valid token is cached. It does not print the token.
246
-
247
- By default, the CLI prints a human-readable summary with a preview of the results. Use `--json`
248
- to print the complete result payload to stdout:
249
-
250
- ```bash
251
- docmana flow run "<flow-id>" --files "./contract.pdf" --organisation "<organisation-id>" --json
169
+ --api-url "https://consumer.example.com/v1" \
170
+ --access-token "$DOCMANA_ACCESS_TOKEN" \
171
+ --files "./contract.pdf,./annexe.pdf" \
172
+ --draft \
173
+ --json
252
174
  ```
253
175
 
254
- `--files` is a simple comma-separated list. Paths containing commas are not supported.
176
+ Use `--draft` to run the current draft flow version.
255
177
 
256
- To build the local checkout and expose the `docmana` command on your machine:
257
-
258
- ```bash
259
- npm run cli:link
260
- ```
261
-
262
- Then run:
263
-
264
- ```bash
265
- docmana flow run "<flow-id>" --files "./contract.pdf" --organisation "<organisation-id>"
266
- ```
178
+ The CLI no longer sends `X-Selected-Organization`; Consumer derives identity
179
+ from the Bearer token.
267
180
 
268
181
  ## Error handling
269
182
 
270
- Every error thrown by the SDK extends `DocmanaError`, which carries `.status` (HTTP status, when applicable), `.code`, and an optional `.requestId`.
271
-
272
- | Error | Thrown when |
273
- | ------------------------ | ------------------------------------------------------------------------------- |
274
- | `DocmanaRequestError` | `400` — bad request (e.g. calling for a result before the flow has finished). |
275
- | `DocmanaAuthError` | `401` — bad credentials, wrong scope, or an expired/rejected token. |
276
- | `DocmanaPermissionError` | `403` — the client is missing the `access_m2m_apps` role. |
277
- | `DocmanaNotFoundError` | `404` — the flow or endpoint was not found. |
278
- | `DocmanaExecutionError` | The flow finished with status `"Failed"`. Carries the flow errors in `.errors`. |
279
- | `DocmanaTimeoutError` | Polling exceeded `timeoutMs` before the flow reached a terminal state. |
280
- | `DocmanaAbortError` | The provided `AbortSignal` fired. |
183
+ Every SDK error extends `DocmanaError`, which carries `.status`, `.code`, and an
184
+ optional `.requestId` when available.
281
185
 
282
- ```ts
283
- import {
284
- Docmana,
285
- DocmanaAuthError,
286
- DocmanaExecutionError,
287
- DocmanaTimeoutError,
288
- } from "@docmana/sdk";
289
-
290
- try {
291
- const result = await docmana.runFlow("<flow-id>", { file: "./contract.pdf" });
292
- console.log(result.results);
293
- } catch (err) {
294
- if (err instanceof DocmanaAuthError) {
295
- // Check client_id / client_secret / scope.
296
- } else if (err instanceof DocmanaExecutionError) {
297
- console.error("Flow failed:", err.errors);
298
- } else if (err instanceof DocmanaTimeoutError) {
299
- // Retry, or raise timeoutMs.
300
- } else {
301
- throw err;
302
- }
303
- }
304
- ```
305
-
306
- ## Security
307
-
308
- Treat `clientSecret` as a credential with full access to your Docmana account.
309
-
310
- - Store `clientId` and `clientSecret` in a secrets manager (Azure Key Vault, AWS Secrets Manager, etc.).
311
- - Never commit them to source control, and never expose them in a browser or frontend bundle — this SDK is server-side only.
312
- - Never log them.
313
-
314
- The SDK keeps the bearer token in memory only. It is never written to disk.
315
-
316
- ## Requirements
317
-
318
- - Node.js 20 or later.
319
- - ESM and CommonJS are both supported.
186
+ | Error | Thrown when |
187
+ | ------------------------ | -------------------------------------------------------------------------- |
188
+ | `DocmanaRequestError` | `400` bad request. |
189
+ | `DocmanaAuthError` | `401` rejected or expired Bearer token. |
190
+ | `DocmanaPermissionError` | `403` missing permission. |
191
+ | `DocmanaNotFoundError` | `404` flow or execution not found. |
192
+ | `DocmanaExecutionError` | The flow finished with status `"Failed"`. Carries `.errors` and `.result`. |
193
+ | `DocmanaTimeoutError` | Polling exceeded `timeoutMs`. |
194
+ | `DocmanaAbortError` | The provided `AbortSignal` fired. |
320
195
 
321
196
  ## Local development with yalc
322
197
 
323
- To test changes to this SDK inside a consuming project without publishing to npm, use [yalc](https://github.com/wclr/yalc).
324
-
325
- In **this library**:
198
+ In this library:
326
199
 
327
200
  ```bash
328
201
  npm run dev
329
202
  ```
330
203
 
331
- This runs `tsup` in watch mode. After every rebuild it runs `yalc push`, propagating the freshly built package to every project that has linked it.
332
-
333
- In the **consuming project** (once):
204
+ In the consuming project:
334
205
 
335
206
  ```bash
336
207
  yalc add @docmana/sdk
337
208
  npm install
338
209
  ```
339
210
 
340
- From then on, each change you save here is rebuilt and pushed automatically — the consumer picks it up without reinstalling. To stop using the local copy and restore the registry version:
211
+ For a one-shot publish to the local yalc store:
341
212
 
342
213
  ```bash
343
- yalc remove @docmana/sdk
344
- npm install
214
+ npm run yalc:publish
345
215
  ```
346
216
 
347
- For a single one-shot publish to the local yalc store (no watch), use `npm run yalc:publish`.
348
-
349
217
  ## License
350
218
 
351
219
  MIT
@@ -0,0 +1,3 @@
1
+ import type { HttpClient } from "../http/http-client.js";
2
+ import type { DocmanaExecutionResult } from "../types.js";
3
+ export declare function getResult(http: HttpClient, executionResultId: string, signal?: AbortSignal, language?: string): Promise<DocmanaExecutionResult>;
@@ -0,0 +1,6 @@
1
+ import type { HttpClient } from "../http/http-client.js";
2
+ import type { ExecutionStatus } from "../types.js";
3
+ export declare function getStatus(http: HttpClient, executionResultId: string, signal?: AbortSignal): Promise<{
4
+ status: ExecutionStatus | string;
5
+ pollAfterMs?: number;
6
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { ResolvedPart } from "../files/resolve-input.js";
2
+ import type { HttpClient } from "../http/http-client.js";
3
+ export declare function runFlow(http: HttpClient, flowId: string, parts: ResolvedPart[], signal?: AbortSignal, useDraftVersion?: boolean, context?: Record<string, unknown>, callbackUrl?: string, language?: string): Promise<{
4
+ executionResultId: string;
5
+ fileIds: string[];
6
+ }>;