@docmana/sdk 0.15.1 → 0.16.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 +7 -0
- package/dist/api/execution-result.d.ts +1 -1
- package/dist/api/execution-status.d.ts +1 -1
- package/dist/api/organization-documents.d.ts +3 -2
- package/dist/cli.mjs +39 -19
- package/dist/cli.mjs.map +1 -1
- package/dist/client.d.ts +5 -4
- package/dist/index.js +39 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
- Scope organization document access to a specific organization: `listOrganizationDocuments`
|
|
5
|
+
now accepts an `organization` option and `downloadOrganizationDocument(s)` an optional
|
|
6
|
+
`organization` argument, both forwarded as the `?organization=` query param (relayed to
|
|
7
|
+
docmana-api as `X-Selected-Organization`). Without it, consumer-edge reads the caller's
|
|
8
|
+
default organization depot, which leaks another org's documents to callers scoping by site.
|
|
9
|
+
|
|
3
10
|
## 0.15.0
|
|
4
11
|
- Expose `rejectionCode`, `rejectionMessage`, `documentTypeProximity`, and
|
|
5
12
|
`documentContentNature` as optional system fields on node results instead of
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HttpClient } from "../http/http-client.js";
|
|
2
2
|
import type { DocmanaExecutionResult } from "../types.js";
|
|
3
|
-
export declare function getResult(http: HttpClient, executionResultId: string, signal?: AbortSignal, language?: string): Promise<DocmanaExecutionResult>;
|
|
3
|
+
export declare function getResult(http: HttpClient, executionResultId: string, signal?: AbortSignal, language?: string, organization?: string): Promise<DocmanaExecutionResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from "../http/http-client.js";
|
|
2
2
|
import type { ExecutionStatus } from "../types.js";
|
|
3
|
-
export declare function getStatus(http: HttpClient, executionResultId: string, signal?: AbortSignal): Promise<{
|
|
3
|
+
export declare function getStatus(http: HttpClient, executionResultId: string, signal?: AbortSignal, organization?: string): Promise<{
|
|
4
4
|
status: ExecutionStatus | string;
|
|
5
5
|
pollAfterMs?: number;
|
|
6
6
|
}>;
|
|
@@ -2,6 +2,7 @@ import type { HttpClient } from "../http/http-client.js";
|
|
|
2
2
|
import type { DownloadedOrganizationDocument, OrganizationDocumentsPayload } from "../types.js";
|
|
3
3
|
export declare function listOrganizationDocuments(http: HttpClient, options?: {
|
|
4
4
|
prefix?: string;
|
|
5
|
+
organization?: string;
|
|
5
6
|
}): Promise<OrganizationDocumentsPayload>;
|
|
6
|
-
export declare function downloadOrganizationDocument(http: HttpClient, path: string): Promise<DownloadedOrganizationDocument>;
|
|
7
|
-
export declare function downloadOrganizationDocuments(http: HttpClient, paths: string[]): Promise<DownloadedOrganizationDocument[]>;
|
|
7
|
+
export declare function downloadOrganizationDocument(http: HttpClient, path: string, organization?: string): Promise<DownloadedOrganizationDocument>;
|
|
8
|
+
export declare function downloadOrganizationDocuments(http: HttpClient, paths: string[], organization?: string): Promise<DownloadedOrganizationDocument[]>;
|
package/dist/cli.mjs
CHANGED
|
@@ -298,8 +298,11 @@ function isTerminalStatus(status) {
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
// src/sdk/api/execution-status.ts
|
|
301
|
-
async function getStatus(http, executionResultId, signal) {
|
|
302
|
-
const res = await http.requestRaw("GET", `/executions/${executionResultId}/status`, {
|
|
301
|
+
async function getStatus(http, executionResultId, signal, organization) {
|
|
302
|
+
const res = await http.requestRaw("GET", `/executions/${executionResultId}/status`, {
|
|
303
|
+
query: organization ? { organization } : void 0,
|
|
304
|
+
signal
|
|
305
|
+
});
|
|
303
306
|
const text = await res.text();
|
|
304
307
|
const body = text ? JSON.parse(text) : { status: "" };
|
|
305
308
|
const normalizedBody = { ...body, status: normalizeStatus(body.status) };
|
|
@@ -320,9 +323,12 @@ function parsePositiveInt(value) {
|
|
|
320
323
|
}
|
|
321
324
|
|
|
322
325
|
// src/sdk/api/execution-result.ts
|
|
323
|
-
async function getResult(http, executionResultId, signal, language) {
|
|
326
|
+
async function getResult(http, executionResultId, signal, language, organization) {
|
|
327
|
+
const query = {};
|
|
328
|
+
if (language) query.language = language;
|
|
329
|
+
if (organization) query.organization = organization;
|
|
324
330
|
return http.requestJson("GET", `/executions/${executionResultId}/result`, {
|
|
325
|
-
query:
|
|
331
|
+
query: Object.keys(query).length > 0 ? query : void 0,
|
|
326
332
|
signal
|
|
327
333
|
});
|
|
328
334
|
}
|
|
@@ -394,8 +400,11 @@ async function getFlowDefinition(http, flowId, organization) {
|
|
|
394
400
|
|
|
395
401
|
// src/sdk/api/organization-documents.ts
|
|
396
402
|
async function listOrganizationDocuments(http, options = {}) {
|
|
403
|
+
const query = {};
|
|
404
|
+
if (options.prefix) query.prefix = options.prefix;
|
|
405
|
+
if (options.organization) query.organization = options.organization;
|
|
397
406
|
const result = await http.requestJson("GET", "/organization-documents", {
|
|
398
|
-
query:
|
|
407
|
+
query: Object.keys(query).length ? query : void 0
|
|
399
408
|
});
|
|
400
409
|
const value = result && typeof result === "object" ? result : {};
|
|
401
410
|
return {
|
|
@@ -403,9 +412,11 @@ async function listOrganizationDocuments(http, options = {}) {
|
|
|
403
412
|
documents: Array.isArray(value.documents) ? value.documents.map(toOrganizationDocument).filter(isOrganizationDocument) : []
|
|
404
413
|
};
|
|
405
414
|
}
|
|
406
|
-
async function downloadOrganizationDocument(http, path) {
|
|
415
|
+
async function downloadOrganizationDocument(http, path, organization) {
|
|
416
|
+
const query = { path };
|
|
417
|
+
if (organization) query.organization = organization;
|
|
407
418
|
const result = await http.requestBytes("GET", "/organization-documents/download", {
|
|
408
|
-
query
|
|
419
|
+
query
|
|
409
420
|
});
|
|
410
421
|
return {
|
|
411
422
|
bytes: result.bytes,
|
|
@@ -413,8 +424,8 @@ async function downloadOrganizationDocument(http, path) {
|
|
|
413
424
|
contentType: result.headers.get("content-type") || void 0
|
|
414
425
|
};
|
|
415
426
|
}
|
|
416
|
-
async function downloadOrganizationDocuments(http, paths) {
|
|
417
|
-
return Promise.all(paths.map((path) => downloadOrganizationDocument(http, path)));
|
|
427
|
+
async function downloadOrganizationDocuments(http, paths, organization) {
|
|
428
|
+
return Promise.all(paths.map((path) => downloadOrganizationDocument(http, path, organization)));
|
|
418
429
|
}
|
|
419
430
|
function toOrganizationDocument(document) {
|
|
420
431
|
const value = document && typeof document === "object" ? document : {};
|
|
@@ -524,11 +535,11 @@ var Docmana = class {
|
|
|
524
535
|
params.organization
|
|
525
536
|
);
|
|
526
537
|
}
|
|
527
|
-
async getStatus(executionResultId, signal) {
|
|
528
|
-
return getStatus(this.http, executionResultId, signal);
|
|
538
|
+
async getStatus(executionResultId, signal, organization) {
|
|
539
|
+
return getStatus(this.http, executionResultId, signal, organization);
|
|
529
540
|
}
|
|
530
|
-
async getResult(executionResultId, signal, language) {
|
|
531
|
-
return getResult(this.http, executionResultId, signal, language);
|
|
541
|
+
async getResult(executionResultId, signal, language, organization) {
|
|
542
|
+
return getResult(this.http, executionResultId, signal, language, organization);
|
|
532
543
|
}
|
|
533
544
|
async runFlow(flowId, params, options = {}) {
|
|
534
545
|
const { executionResultId } = await this.runFlowAsync(flowId, params, {
|
|
@@ -540,7 +551,11 @@ var Docmana = class {
|
|
|
540
551
|
check: async () => {
|
|
541
552
|
attempt += 1;
|
|
542
553
|
try {
|
|
543
|
-
const statusResult = await this.getStatus(
|
|
554
|
+
const statusResult = await this.getStatus(
|
|
555
|
+
executionResultId,
|
|
556
|
+
options.signal,
|
|
557
|
+
params.organization
|
|
558
|
+
);
|
|
544
559
|
const status = statusResult.status;
|
|
545
560
|
const nextPollAfterMs = this.isTerminalStatus(status) ? void 0 : statusResult.pollAfterMs;
|
|
546
561
|
options.onPoll?.({
|
|
@@ -568,7 +583,12 @@ var Docmana = class {
|
|
|
568
583
|
timeoutMs: options.timeoutMs ?? this.config.timeoutMs,
|
|
569
584
|
signal: options.signal
|
|
570
585
|
});
|
|
571
|
-
const result = await this.getResult(
|
|
586
|
+
const result = await this.getResult(
|
|
587
|
+
executionResultId,
|
|
588
|
+
options.signal,
|
|
589
|
+
params.language,
|
|
590
|
+
params.organization
|
|
591
|
+
);
|
|
572
592
|
if (isFailedStatus(result.status)) {
|
|
573
593
|
throw new DocmanaExecutionError(
|
|
574
594
|
`Flow ${flowId} execution failed`,
|
|
@@ -593,11 +613,11 @@ var Docmana = class {
|
|
|
593
613
|
async listOrganizationDocuments(options = {}) {
|
|
594
614
|
return listOrganizationDocuments(this.http, options);
|
|
595
615
|
}
|
|
596
|
-
async downloadOrganizationDocument(path) {
|
|
597
|
-
return downloadOrganizationDocument(this.http, path);
|
|
616
|
+
async downloadOrganizationDocument(path, organization) {
|
|
617
|
+
return downloadOrganizationDocument(this.http, path, organization);
|
|
598
618
|
}
|
|
599
|
-
async downloadOrganizationDocuments(paths) {
|
|
600
|
-
return downloadOrganizationDocuments(this.http, paths);
|
|
619
|
+
async downloadOrganizationDocuments(paths, organization) {
|
|
620
|
+
return downloadOrganizationDocuments(this.http, paths, organization);
|
|
601
621
|
}
|
|
602
622
|
isTerminalStatus(status) {
|
|
603
623
|
return isTerminalStatus(status);
|