@docmana/sdk 0.9.0 → 0.10.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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.0
4
+ - Add an optional `organization` to flow selection, emitted as a
5
+ `?organization=<org>` query param on the request to
6
+ `docmana-consumer-edge-api`. Purely additive — existing calls are unchanged.
7
+ - `listFlows({ organization })`, `getFlowMetadata(flowId, { organization })`,
8
+ and `getFlowDefinition(flowId, { organization })` accept the option.
9
+ - `RunFlowParams` (and therefore `runFlow` / `runFlowAsync`) gains
10
+ `organization`, threaded onto the `execute-async` request URL.
11
+ - Expose `organization` on `FlowListItem`: when the consumer-edge tags a flow
12
+ with its organization, `listFlows()` now carries it through on each item.
13
+
3
14
  ## 0.8.1
4
15
  - Rename the multipart wire fields sent to `docmana-consumer-edge-api` from
5
16
  `json_context` / `callback_url` to `jsonContext` / `callbackUrl`, matching the
@@ -1,3 +1,3 @@
1
1
  import type { HttpClient } from "../http/http-client.js";
2
2
  import type { FlowDefinition } from "../types.js";
3
- export declare function getFlowDefinition(http: HttpClient, flowId: string): Promise<FlowDefinition>;
3
+ export declare function getFlowDefinition(http: HttpClient, flowId: string, organization?: string): Promise<FlowDefinition>;
@@ -1,3 +1,3 @@
1
1
  import type { HttpClient } from "../http/http-client.js";
2
2
  import type { FlowMetadata } from "../types.js";
3
- export declare function getFlowMetadata(http: HttpClient, flowId: string): Promise<FlowMetadata>;
3
+ export declare function getFlowMetadata(http: HttpClient, flowId: string, organization?: string): Promise<FlowMetadata>;
@@ -1,3 +1,3 @@
1
1
  import type { HttpClient } from "../http/http-client.js";
2
2
  import type { FlowListItem } from "../types.js";
3
- export declare function listFlows(http: HttpClient): Promise<FlowListItem[]>;
3
+ export declare function listFlows(http: HttpClient, organization?: string): Promise<FlowListItem[]>;
@@ -1,6 +1,6 @@
1
1
  import type { ResolvedPart } from "../files/resolve-input.js";
2
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<{
3
+ export declare function runFlow(http: HttpClient, flowId: string, parts: ResolvedPart[], signal?: AbortSignal, useDraftVersion?: boolean, context?: Record<string, unknown>, callbackUrl?: string, language?: string, organization?: string): Promise<{
4
4
  executionResultId: string;
5
5
  fileIds: string[];
6
6
  }>;
package/dist/cli.mjs CHANGED
@@ -265,7 +265,7 @@ async function resolveInputs(input) {
265
265
  }
266
266
 
267
267
  // src/sdk/api/run-flow.ts
268
- async function runFlow(http, flowId, parts, signal, useDraftVersion = false, context, callbackUrl, language) {
268
+ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, context, callbackUrl, language, organization) {
269
269
  const form = new FormData();
270
270
  for (const part of parts) {
271
271
  form.append("files", new File([part.data], part.filename, { type: part.contentType }));
@@ -274,9 +274,10 @@ async function runFlow(http, flowId, parts, signal, useDraftVersion = false, con
274
274
  if (callbackUrl !== void 0) form.append("callbackUrl", callbackUrl);
275
275
  if (language !== void 0) form.append("language", language);
276
276
  if (useDraftVersion) form.append("useDraftVersion", "true");
277
+ const path = `/flows/${flowId}/execute-async`;
277
278
  return http.requestJson(
278
279
  "POST",
279
- `/flows/${flowId}/execute-async`,
280
+ organization ? `${path}?organization=${encodeURIComponent(organization)}` : path,
280
281
  { body: form, signal }
281
282
  );
282
283
  }
@@ -304,17 +305,22 @@ async function getResult(http, executionResultId, signal, language) {
304
305
  }
305
306
 
306
307
  // src/sdk/api/list-flows.ts
307
- async function listFlows(http) {
308
- const flows = await http.requestJson("GET", "/flows");
308
+ async function listFlows(http, organization) {
309
+ const path = organization ? `/flows?organization=${encodeURIComponent(organization)}` : "/flows";
310
+ const flows = await http.requestJson("GET", path);
309
311
  return Array.isArray(flows) ? flows.map(toFlowListItem) : [];
310
312
  }
311
313
  function toFlowListItem(flow) {
312
314
  const value = flow && typeof flow === "object" ? flow : {};
313
- return {
315
+ const item = {
314
316
  id: toStringValue(value.id),
315
317
  name: toStringValue(value.name),
316
318
  state: toStateValue(value.state)
317
319
  };
320
+ if (typeof value.organization === "string") {
321
+ item.organization = value.organization;
322
+ }
323
+ return item;
318
324
  }
319
325
  function toStringValue(value) {
320
326
  return typeof value === "string" ? value : "";
@@ -346,13 +352,21 @@ function toStringValue2(value) {
346
352
  }
347
353
 
348
354
  // src/sdk/api/flow-metadata.ts
349
- async function getFlowMetadata(http, flowId) {
350
- return http.requestJson("GET", `/flows/${encodeURIComponent(flowId)}/metadata`);
355
+ async function getFlowMetadata(http, flowId, organization) {
356
+ const path = `/flows/${encodeURIComponent(flowId)}/metadata`;
357
+ return http.requestJson(
358
+ "GET",
359
+ organization ? `${path}?organization=${encodeURIComponent(organization)}` : path
360
+ );
351
361
  }
352
362
 
353
363
  // src/sdk/api/flow-definition.ts
354
- async function getFlowDefinition(http, flowId) {
355
- return http.requestJson("GET", `/flows/${encodeURIComponent(flowId)}/definition`);
364
+ async function getFlowDefinition(http, flowId, organization) {
365
+ const path = `/flows/${encodeURIComponent(flowId)}/definition`;
366
+ return http.requestJson(
367
+ "GET",
368
+ organization ? `${path}?organization=${encodeURIComponent(organization)}` : path
369
+ );
356
370
  }
357
371
 
358
372
  // src/sdk/api/organization-documents.ts
@@ -484,7 +498,8 @@ var Docmana = class {
484
498
  params.useDraftVersion ?? false,
485
499
  params.context,
486
500
  params.callbackUrl,
487
- params.language
501
+ params.language,
502
+ params.organization
488
503
  );
489
504
  }
490
505
  async getStatus(executionResultId, signal) {
@@ -541,17 +556,17 @@ var Docmana = class {
541
556
  }
542
557
  return result;
543
558
  }
544
- async listFlows() {
545
- return listFlows(this.http);
559
+ async listFlows(options = {}) {
560
+ return listFlows(this.http, options.organization);
546
561
  }
547
562
  async listOrganizations() {
548
563
  return listOrganizations(this.http);
549
564
  }
550
- async getFlowMetadata(flowId) {
551
- return getFlowMetadata(this.http, flowId);
565
+ async getFlowMetadata(flowId, options = {}) {
566
+ return getFlowMetadata(this.http, flowId, options.organization);
552
567
  }
553
- async getFlowDefinition(flowId) {
554
- return getFlowDefinition(this.http, flowId);
568
+ async getFlowDefinition(flowId, options = {}) {
569
+ return getFlowDefinition(this.http, flowId, options.organization);
555
570
  }
556
571
  async listOrganizationDocuments(options = {}) {
557
572
  return listOrganizationDocuments(this.http, options);