@dokus/client 0.1.0-alpha.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/LICENSE +36 -0
- package/README.md +114 -0
- package/dist/browser-denied.d.ts +8 -0
- package/dist/browser-denied.js +12 -0
- package/dist/chunk-RJGJ7P2Y.js +73 -0
- package/dist/errors-Ce8Vc6yb.d.ts +45 -0
- package/dist/index.d.ts +211 -0
- package/dist/index.js +1424 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Dokus SDK Pre-Release Evaluation License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dokus. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Subject to the restrictions below, Dokus grants you a limited, revocable,
|
|
6
|
+
non-exclusive, non-transferable, non-sublicensable license to install and use
|
|
7
|
+
this pre-release SDK solely to evaluate Dokus and to develop and test
|
|
8
|
+
integrations that communicate with Dokus services using credentials you are
|
|
9
|
+
authorized to use.
|
|
10
|
+
|
|
11
|
+
You may not:
|
|
12
|
+
|
|
13
|
+
1. use the SDK in production or provide it as part of a production service;
|
|
14
|
+
2. copy, publish, redistribute, sublicense, sell, rent, lease, or otherwise
|
|
15
|
+
make the SDK available to another party;
|
|
16
|
+
3. modify the SDK, create derivative works from it, or reverse engineer,
|
|
17
|
+
decompile, or disassemble it, except to the limited extent applicable law
|
|
18
|
+
expressly prohibits this restriction;
|
|
19
|
+
4. use the SDK or information derived from it to create or improve a product
|
|
20
|
+
or service that competes with Dokus; or
|
|
21
|
+
5. remove or alter proprietary notices.
|
|
22
|
+
|
|
23
|
+
Dokus and its licensors retain all ownership and intellectual-property rights
|
|
24
|
+
in the SDK. No rights are granted except those stated expressly in this
|
|
25
|
+
license. Access to Dokus services remains subject to the applicable service
|
|
26
|
+
terms and may be suspended or terminated independently of this license.
|
|
27
|
+
|
|
28
|
+
This license terminates automatically if you breach it or when Dokus replaces
|
|
29
|
+
this pre-release license for the SDK version you use. On termination, you must
|
|
30
|
+
stop using and delete the SDK.
|
|
31
|
+
|
|
32
|
+
THE SDK IS PRE-RELEASE SOFTWARE PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT
|
|
33
|
+
WARRANTIES OR CONDITIONS OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY LAW,
|
|
34
|
+
DOKUS WILL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL,
|
|
35
|
+
OR EXEMPLARY DAMAGES, OR FOR LOSS OF DATA, PROFITS, REVENUE, OR BUSINESS,
|
|
36
|
+
ARISING FROM OR RELATED TO THE SDK.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# `@dokus/client`
|
|
2
|
+
|
|
3
|
+
Server-only, typed HTTP access to Dokus document rendering, runs, outputs, and
|
|
4
|
+
workflow generation. Use `@dokus/contracts` to author semantic render intent,
|
|
5
|
+
then send that inert contract inline with the render request.
|
|
6
|
+
|
|
7
|
+
This alpha is evaluation software under the included restrictive license. It
|
|
8
|
+
is ESM-only and requires Node.js 22.12 or newer.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install @dokus/client@alpha
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createDokusClient } from "@dokus/client";
|
|
16
|
+
import {
|
|
17
|
+
JSON_SCHEMA_DRAFT_2020_12,
|
|
18
|
+
defineRenderContract,
|
|
19
|
+
input,
|
|
20
|
+
values,
|
|
21
|
+
} from "@dokus/contracts";
|
|
22
|
+
|
|
23
|
+
const dokus = createDokusClient({
|
|
24
|
+
apiKey: process.env.DOKUS_API_KEY!,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const contract = defineRenderContract({
|
|
28
|
+
inputSchema: {
|
|
29
|
+
$schema: JSON_SCHEMA_DRAFT_2020_12,
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: { customerName: { type: "string" } },
|
|
32
|
+
required: ["customerName"],
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
rules: [values({ "customer.name": input("customerName") })],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const started = await dokus.documents.render(
|
|
39
|
+
{
|
|
40
|
+
documentId: "019e744b-8ed8-7dab-a72a-a894043f2f37",
|
|
41
|
+
versionId: "019e744d-fd08-7c8f-b292-434a214e660b",
|
|
42
|
+
contract,
|
|
43
|
+
data: { customerName: "Ada Lovelace" },
|
|
44
|
+
generatePdf: true,
|
|
45
|
+
mode: "async",
|
|
46
|
+
},
|
|
47
|
+
{ idempotencyKey: "render-quarterly-report-2026-q3" },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const run = await dokus.runs.wait(started.runId);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The inline contract path is the real no-download scripting path: the server
|
|
54
|
+
loads the exact selected document version, resolves aliases and placeholder
|
|
55
|
+
keys, compiles the contract to a fingerprint-bound render plan, and renders it.
|
|
56
|
+
Callers do not download or modify a DKSD package.
|
|
57
|
+
|
|
58
|
+
`@dokus/dksd` provides pure authoring artifacts and transaction types, but the
|
|
59
|
+
public API does not yet mount persistence or mutation endpoints for document
|
|
60
|
+
definitions, snapshots, snapshot packages, or transactions. Accordingly,
|
|
61
|
+
`@dokus/client` does not expose decorative methods for those operations. It
|
|
62
|
+
also has no persisted-contract resource; submit contracts inline to
|
|
63
|
+
`documents.render`.
|
|
64
|
+
|
|
65
|
+
The client never reads credentials from the environment. The example reads the
|
|
66
|
+
environment in application code and passes the value into a closure explicitly.
|
|
67
|
+
Do not import this package in a browser or web worker; conditional exports and a
|
|
68
|
+
runtime check reject those environments.
|
|
69
|
+
|
|
70
|
+
## Resources
|
|
71
|
+
|
|
72
|
+
- `documents.render` accepts data, exact version selection, either `planId` or
|
|
73
|
+
an inline contract, sync/async mode, PDF/DOCX output choices, and output
|
|
74
|
+
expiry.
|
|
75
|
+
- `runs.get`, `outputs`, `outputDownload`, `rotatePreviewLink`,
|
|
76
|
+
`revokePreviewLink`, `delete`, and `wait` operate on mounted run/output routes.
|
|
77
|
+
- `workflows.generate`, `generateSync`, `generateAll`, and `documentRuns`
|
|
78
|
+
expose the currently mounted workflow operations. Workflow generation does
|
|
79
|
+
not accept plan or contract selectors.
|
|
80
|
+
|
|
81
|
+
`documents.render` calls `POST /api/documents/:documentId/run`. `planId` and an
|
|
82
|
+
inline `contract: DokusRenderContractV1` are mutually exclusive. Select a
|
|
83
|
+
version with either `version: "latest" | "draft"` or an exact `versionId`, not
|
|
84
|
+
both.
|
|
85
|
+
|
|
86
|
+
The default `mode: "sync"` returns `DokusDocumentRenderCompleted`: the canonical
|
|
87
|
+
run result plus `documentId`, `documentVersionId`, and the selected `planId`.
|
|
88
|
+
Explicit `mode: "async"` returns `DokusDocumentRenderStarted` with the pending
|
|
89
|
+
run identity; pass its `runId` to `runs.wait`.
|
|
90
|
+
|
|
91
|
+
All public option and input records must be plain or null-prototype data
|
|
92
|
+
objects. Unknown, inherited, accessor, non-enumerable, and symbol-keyed fields
|
|
93
|
+
are rejected before any request is sent. JSON request values are cloned from
|
|
94
|
+
descriptors without invoking getters and must be strict JSON: no `undefined`,
|
|
95
|
+
functions, symbols, bigint, non-finite numbers, cycles, sparse/decorated arrays,
|
|
96
|
+
or class instances. Requests are bounded to 32 nesting levels, 100,000 nodes,
|
|
97
|
+
and 1 MiB of UTF-8 JSON.
|
|
98
|
+
|
|
99
|
+
State-changing calls require an `idempotencyKey` of 8-128 safe opaque
|
|
100
|
+
characters as a stable operation identifier. The currently mounted public
|
|
101
|
+
routes do not promise durable replay or deduplication, so the client never
|
|
102
|
+
automatically retries POST, PUT, or DELETE. Treat an ambiguous write failure as
|
|
103
|
+
non-retryable until application code has reconciled the operation's state.
|
|
104
|
+
Only GET requests are retried on transient network errors and HTTP 408, 429,
|
|
105
|
+
502, 503, or 504. `Retry-After` is honored within the configured delay cap.
|
|
106
|
+
|
|
107
|
+
Every request has a deadline, composes with an application `AbortSignal`, sends
|
|
108
|
+
an `x-request-id`, rejects redirects, bounds response reads, and maps failures
|
|
109
|
+
to the exported `DokusError` hierarchy. Errors do not retain request headers or
|
|
110
|
+
request bodies, and API-key values are redacted from server messages/details.
|
|
111
|
+
|
|
112
|
+
JSON routes use `{ "success": true, "data": ... }`. Errors use
|
|
113
|
+
`{ "success": false, "error": { "code", "message", "details"? } }` and should
|
|
114
|
+
return `x-request-id`; throttling/transient responses may return `Retry-After`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { D as DokusAbortError, a as DokusApiError, i as DokusApiErrorCode, b as DokusConnectionError, c as DokusError, j as DokusKnownApiErrorCode, d as DokusProtocolError, e as DokusResponseTooLargeError, f as DokusTimeoutError, g as DokusValidationError, h as DokusWaitTimeoutError } from './errors-Ce8Vc6yb.js';
|
|
2
|
+
|
|
3
|
+
declare const DOKUS_API_BASE_URL = "https://api.dokus.pro";
|
|
4
|
+
declare function createDokusClient(_options: {
|
|
5
|
+
readonly apiKey: string;
|
|
6
|
+
}): never;
|
|
7
|
+
|
|
8
|
+
export { DOKUS_API_BASE_URL, createDokusClient };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DokusValidationError } from './chunk-RJGJ7P2Y.js';
|
|
2
|
+
export { DokusAbortError, DokusApiError, DokusConnectionError, DokusError, DokusProtocolError, DokusResponseTooLargeError, DokusTimeoutError, DokusValidationError, DokusWaitTimeoutError } from './chunk-RJGJ7P2Y.js';
|
|
3
|
+
|
|
4
|
+
// src/browser-denied.ts
|
|
5
|
+
var DOKUS_API_BASE_URL = "https://api.dokus.pro";
|
|
6
|
+
function createDokusClient(_options) {
|
|
7
|
+
throw new DokusValidationError(
|
|
8
|
+
"@dokus/client is server-only; keep Dokus API keys out of browsers and web workers."
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { DOKUS_API_BASE_URL, createDokusClient };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var DokusError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "DokusError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var DokusValidationError = class extends DokusError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "DokusValidationError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var DokusConnectionError = class extends DokusError {
|
|
15
|
+
constructor(requestId) {
|
|
16
|
+
super("The Dokus API could not be reached.");
|
|
17
|
+
this.requestId = requestId;
|
|
18
|
+
this.name = "DokusConnectionError";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var DokusAbortError = class extends DokusError {
|
|
22
|
+
constructor(requestId) {
|
|
23
|
+
super("The Dokus API request was aborted.");
|
|
24
|
+
this.requestId = requestId;
|
|
25
|
+
this.name = "DokusAbortError";
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var DokusTimeoutError = class extends DokusError {
|
|
29
|
+
constructor(timeoutMs, requestId) {
|
|
30
|
+
super(`The Dokus API request timed out after ${timeoutMs}ms.`);
|
|
31
|
+
this.timeoutMs = timeoutMs;
|
|
32
|
+
this.requestId = requestId;
|
|
33
|
+
this.name = "DokusTimeoutError";
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var DokusProtocolError = class extends DokusError {
|
|
37
|
+
constructor(requestId) {
|
|
38
|
+
super("The Dokus API returned an invalid response.");
|
|
39
|
+
this.requestId = requestId;
|
|
40
|
+
this.name = "DokusProtocolError";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var DokusResponseTooLargeError = class extends DokusError {
|
|
44
|
+
constructor(limitBytes, requestId) {
|
|
45
|
+
super(`The Dokus API response exceeded the ${limitBytes}-byte limit.`);
|
|
46
|
+
this.limitBytes = limitBytes;
|
|
47
|
+
this.requestId = requestId;
|
|
48
|
+
this.name = "DokusResponseTooLargeError";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var DokusApiError = class extends DokusError {
|
|
52
|
+
constructor(message, status, requestId, code, details, retryAfterMs) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.status = status;
|
|
55
|
+
this.requestId = requestId;
|
|
56
|
+
this.code = code;
|
|
57
|
+
this.details = details;
|
|
58
|
+
this.retryAfterMs = retryAfterMs;
|
|
59
|
+
this.name = "DokusApiError";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var DokusWaitTimeoutError = class extends DokusError {
|
|
63
|
+
constructor(timeoutMs, lastStatus) {
|
|
64
|
+
super(
|
|
65
|
+
`Run polling timed out after ${timeoutMs}ms with status "${lastStatus}".`
|
|
66
|
+
);
|
|
67
|
+
this.timeoutMs = timeoutMs;
|
|
68
|
+
this.lastStatus = lastStatus;
|
|
69
|
+
this.name = "DokusWaitTimeoutError";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { DokusAbortError, DokusApiError, DokusConnectionError, DokusError, DokusProtocolError, DokusResponseTooLargeError, DokusTimeoutError, DokusValidationError, DokusWaitTimeoutError };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
type DokusKnownApiErrorCode = "VALIDATION_ERROR" | "NOT_FOUND" | "UNAUTHORIZED" | "FORBIDDEN" | "CONFLICT" | "ACTIVE_RUN_CONFLICT" | "VERSION_NOT_FOUND" | "UNSUPPORTED_GENERATION_FORMAT" | "SYNC_SIZE_EXCEEDED" | "OUTPUT_NOT_READY" | "NO_ROOT_DOCUMENTS" | "INVALID_DOCUMENT_SELECTION" | "GENERATION_START_FAILED" | "RATE_LIMIT_EXCEEDED";
|
|
2
|
+
type DokusApiErrorCode = DokusKnownApiErrorCode | (string & {});
|
|
3
|
+
declare class DokusError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
declare class DokusValidationError extends DokusError {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
declare class DokusConnectionError extends DokusError {
|
|
10
|
+
readonly requestId: string;
|
|
11
|
+
constructor(requestId: string);
|
|
12
|
+
}
|
|
13
|
+
declare class DokusAbortError extends DokusError {
|
|
14
|
+
readonly requestId?: string | undefined;
|
|
15
|
+
constructor(requestId?: string | undefined);
|
|
16
|
+
}
|
|
17
|
+
declare class DokusTimeoutError extends DokusError {
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
readonly requestId: string;
|
|
20
|
+
constructor(timeoutMs: number, requestId: string);
|
|
21
|
+
}
|
|
22
|
+
declare class DokusProtocolError extends DokusError {
|
|
23
|
+
readonly requestId: string;
|
|
24
|
+
constructor(requestId: string);
|
|
25
|
+
}
|
|
26
|
+
declare class DokusResponseTooLargeError extends DokusError {
|
|
27
|
+
readonly limitBytes: number;
|
|
28
|
+
readonly requestId: string;
|
|
29
|
+
constructor(limitBytes: number, requestId: string);
|
|
30
|
+
}
|
|
31
|
+
declare class DokusApiError extends DokusError {
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly requestId: string;
|
|
34
|
+
readonly code?: DokusApiErrorCode | undefined;
|
|
35
|
+
readonly details?: unknown | undefined;
|
|
36
|
+
readonly retryAfterMs?: number | undefined;
|
|
37
|
+
constructor(message: string, status: number, requestId: string, code?: DokusApiErrorCode | undefined, details?: unknown | undefined, retryAfterMs?: number | undefined);
|
|
38
|
+
}
|
|
39
|
+
declare class DokusWaitTimeoutError extends DokusError {
|
|
40
|
+
readonly timeoutMs: number;
|
|
41
|
+
readonly lastStatus: string;
|
|
42
|
+
constructor(timeoutMs: number, lastStatus: string);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { DokusAbortError as D, DokusApiError as a, DokusConnectionError as b, DokusError as c, DokusProtocolError as d, DokusResponseTooLargeError as e, DokusTimeoutError as f, DokusValidationError as g, DokusWaitTimeoutError as h, type DokusApiErrorCode as i, type DokusKnownApiErrorCode as j };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { DokusRenderContractV1, JsonObject } from '@dokus/contracts';
|
|
2
|
+
export { D as DokusAbortError, a as DokusApiError, i as DokusApiErrorCode, b as DokusConnectionError, c as DokusError, j as DokusKnownApiErrorCode, d as DokusProtocolError, e as DokusResponseTooLargeError, f as DokusTimeoutError, g as DokusValidationError, h as DokusWaitTimeoutError } from './errors-Ce8Vc6yb.js';
|
|
3
|
+
|
|
4
|
+
interface DokusRetryOptions {
|
|
5
|
+
/** Total attempts, including the first request. Defaults to 3; maximum 10. */
|
|
6
|
+
readonly maxAttempts?: number;
|
|
7
|
+
/** Maximum delay between attempts. Defaults to 30 seconds. */
|
|
8
|
+
readonly maxDelayMs?: number;
|
|
9
|
+
}
|
|
10
|
+
interface DokusClientOptions {
|
|
11
|
+
/** API key captured by the server-only client closure. */
|
|
12
|
+
readonly apiKey: string;
|
|
13
|
+
/** Dokus API origin. Defaults to https://api.dokus.pro. */
|
|
14
|
+
readonly baseUrl?: string;
|
|
15
|
+
/** Explicit fetch implementation, primarily for testing or custom Node dispatch. */
|
|
16
|
+
readonly fetch?: typeof fetch;
|
|
17
|
+
/** Default whole-request deadline. Defaults to 30 seconds. */
|
|
18
|
+
readonly timeoutMs?: number;
|
|
19
|
+
/** Retry GET requests; false disables retries. Writes are never retried. */
|
|
20
|
+
readonly retry?: false | DokusRetryOptions;
|
|
21
|
+
}
|
|
22
|
+
interface DokusRequestOptions {
|
|
23
|
+
readonly signal?: AbortSignal;
|
|
24
|
+
/** Override the client's request deadline for this call. */
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
/** Optional caller request ID; otherwise the client generates a UUID. */
|
|
27
|
+
readonly requestId?: string;
|
|
28
|
+
}
|
|
29
|
+
interface DokusWriteOptions extends DokusRequestOptions {
|
|
30
|
+
/** Stable operation identifier sent to the API; it does not imply durable replay. */
|
|
31
|
+
readonly idempotencyKey: string;
|
|
32
|
+
}
|
|
33
|
+
type DokusRunStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
34
|
+
type DokusOutputStatus = "pending" | "processing" | "completed" | "failed" | "skipped";
|
|
35
|
+
type DokusOutputFileType = "docx" | "xlsx" | "pdf";
|
|
36
|
+
interface DokusPreviewLinkMeta {
|
|
37
|
+
readonly status: "issued" | "revoked";
|
|
38
|
+
readonly createdAt: string;
|
|
39
|
+
readonly rotatedAt: string | null;
|
|
40
|
+
readonly allowDownload: boolean;
|
|
41
|
+
readonly expiresAt: string | null;
|
|
42
|
+
}
|
|
43
|
+
interface DokusRunOutput {
|
|
44
|
+
readonly id: number;
|
|
45
|
+
readonly fileType: DokusOutputFileType;
|
|
46
|
+
readonly outputFileName: string;
|
|
47
|
+
readonly status: DokusOutputStatus;
|
|
48
|
+
readonly error: string | null;
|
|
49
|
+
readonly size: number | null;
|
|
50
|
+
readonly pages: number | null;
|
|
51
|
+
readonly completedAt: string | null;
|
|
52
|
+
readonly downloadUrl: string | null;
|
|
53
|
+
/** Issue-once URL; `runs.wait` retains the first value observed while polling. */
|
|
54
|
+
readonly previewUrl: string | null;
|
|
55
|
+
readonly previewLink: DokusPreviewLinkMeta | null;
|
|
56
|
+
}
|
|
57
|
+
interface DokusRunResult {
|
|
58
|
+
readonly runId: string;
|
|
59
|
+
readonly workflowId: string;
|
|
60
|
+
readonly mode: "sync" | "async";
|
|
61
|
+
readonly status: DokusRunStatus;
|
|
62
|
+
readonly startedAt: string | null;
|
|
63
|
+
readonly completedAt: string | null;
|
|
64
|
+
readonly error: string | null;
|
|
65
|
+
readonly createdAt: string;
|
|
66
|
+
readonly outputs: readonly DokusRunOutput[];
|
|
67
|
+
}
|
|
68
|
+
interface DokusDocumentRenderCompleted extends DokusRunResult {
|
|
69
|
+
readonly documentId: string;
|
|
70
|
+
readonly documentVersionId: string;
|
|
71
|
+
readonly planId: string | null;
|
|
72
|
+
readonly mode: "sync";
|
|
73
|
+
}
|
|
74
|
+
interface DokusDocumentRenderStarted {
|
|
75
|
+
readonly documentId: string;
|
|
76
|
+
readonly documentVersionId: string;
|
|
77
|
+
readonly planId: string | null;
|
|
78
|
+
readonly runId: string;
|
|
79
|
+
readonly workflowId: string;
|
|
80
|
+
readonly status: "pending";
|
|
81
|
+
}
|
|
82
|
+
interface DokusRunOutputs {
|
|
83
|
+
readonly runId: string;
|
|
84
|
+
readonly outputs: readonly DokusRunOutput[];
|
|
85
|
+
}
|
|
86
|
+
interface DokusOutputDownload {
|
|
87
|
+
readonly url: string;
|
|
88
|
+
readonly expiresAt: string;
|
|
89
|
+
}
|
|
90
|
+
interface DokusPreviewLinkRotated {
|
|
91
|
+
readonly previewUrl: string;
|
|
92
|
+
readonly previewLink: DokusPreviewLinkMeta;
|
|
93
|
+
}
|
|
94
|
+
interface DokusGenerateStarted {
|
|
95
|
+
readonly runId: string;
|
|
96
|
+
readonly temporalWorkflowId: string;
|
|
97
|
+
readonly status: "started" | "already_running";
|
|
98
|
+
}
|
|
99
|
+
interface DokusGenerateAllEntry {
|
|
100
|
+
readonly documentId: string;
|
|
101
|
+
readonly runId?: string;
|
|
102
|
+
readonly temporalWorkflowId?: string;
|
|
103
|
+
readonly status: "started" | "already_running" | "failed";
|
|
104
|
+
readonly error?: string;
|
|
105
|
+
}
|
|
106
|
+
interface DokusDocumentRunSummary {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly workflowId: string;
|
|
109
|
+
readonly status: DokusRunStatus;
|
|
110
|
+
readonly startedAt: string | null;
|
|
111
|
+
readonly completedAt: string | null;
|
|
112
|
+
readonly error: string | null;
|
|
113
|
+
readonly triggeredByType: string;
|
|
114
|
+
readonly triggeredById: string | null;
|
|
115
|
+
readonly createdAt: string;
|
|
116
|
+
readonly outputCount: number;
|
|
117
|
+
}
|
|
118
|
+
interface DokusVersionSelection {
|
|
119
|
+
readonly version?: "latest" | "draft";
|
|
120
|
+
readonly versionId?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface DokusRenderDocumentInput extends DokusVersionSelection {
|
|
124
|
+
readonly documentId: string;
|
|
125
|
+
readonly planId?: string;
|
|
126
|
+
readonly contract?: DokusRenderContractV1;
|
|
127
|
+
readonly data?: JsonObject;
|
|
128
|
+
readonly generatePdf?: boolean;
|
|
129
|
+
readonly generateDocx?: boolean;
|
|
130
|
+
readonly expireAt?: number | Date | null;
|
|
131
|
+
readonly mode?: "sync" | "async";
|
|
132
|
+
}
|
|
133
|
+
type SyncRenderInput = DokusRenderDocumentInput & {
|
|
134
|
+
readonly mode?: "sync";
|
|
135
|
+
};
|
|
136
|
+
type AsyncRenderInput = DokusRenderDocumentInput & {
|
|
137
|
+
readonly mode: "async";
|
|
138
|
+
};
|
|
139
|
+
interface DokusDocuments {
|
|
140
|
+
/** Existing execution route: POST /api/documents/:documentId/run. */
|
|
141
|
+
render(input: AsyncRenderInput, options: DokusWriteOptions): Promise<DokusDocumentRenderStarted>;
|
|
142
|
+
render(input: SyncRenderInput, options: DokusWriteOptions): Promise<DokusDocumentRenderCompleted>;
|
|
143
|
+
render(input: DokusRenderDocumentInput, options: DokusWriteOptions): Promise<DokusDocumentRenderCompleted | DokusDocumentRenderStarted>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface DokusRunGetOptions extends DokusRequestOptions {
|
|
147
|
+
readonly expireAt?: number | Date | null;
|
|
148
|
+
}
|
|
149
|
+
interface DokusRunWaitOptions {
|
|
150
|
+
readonly expireAt?: number | Date | null;
|
|
151
|
+
readonly signal?: AbortSignal;
|
|
152
|
+
readonly requestId?: string;
|
|
153
|
+
/** Poll interval. Defaults to 2 seconds. */
|
|
154
|
+
readonly intervalMs?: number;
|
|
155
|
+
/** Overall polling deadline. Defaults to 2 minutes. */
|
|
156
|
+
readonly timeoutMs?: number;
|
|
157
|
+
/** Deadline for each individual polling request. */
|
|
158
|
+
readonly requestTimeoutMs?: number;
|
|
159
|
+
}
|
|
160
|
+
interface DokusRotatePreviewOptions extends DokusWriteOptions {
|
|
161
|
+
readonly allowDownload?: boolean;
|
|
162
|
+
readonly expiresIn?: {
|
|
163
|
+
readonly days: number;
|
|
164
|
+
} | null;
|
|
165
|
+
}
|
|
166
|
+
interface DokusRuns {
|
|
167
|
+
get(runId: string, options?: DokusRunGetOptions): Promise<DokusRunResult>;
|
|
168
|
+
outputs(runId: string, options?: DokusRequestOptions): Promise<DokusRunOutputs>;
|
|
169
|
+
outputDownload(runId: string, outputId: number, options?: DokusRequestOptions): Promise<DokusOutputDownload>;
|
|
170
|
+
rotatePreviewLink(runId: string, outputId: number, options: DokusRotatePreviewOptions): Promise<DokusPreviewLinkRotated>;
|
|
171
|
+
revokePreviewLink(runId: string, outputId: number, options: DokusWriteOptions): Promise<void>;
|
|
172
|
+
delete(runId: string, options: DokusWriteOptions): Promise<void>;
|
|
173
|
+
wait(runId: string, options?: DokusRunWaitOptions): Promise<DokusRunResult>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface DokusGenerateInput {
|
|
177
|
+
readonly documentId: string;
|
|
178
|
+
readonly data?: JsonObject;
|
|
179
|
+
readonly versionId?: string;
|
|
180
|
+
readonly versionSpec?: "latest" | "draft";
|
|
181
|
+
readonly outputFileNameOverride?: string;
|
|
182
|
+
readonly generatePdf?: boolean;
|
|
183
|
+
readonly generateDocx?: boolean;
|
|
184
|
+
}
|
|
185
|
+
interface DokusGenerateAllInput {
|
|
186
|
+
readonly data?: JsonObject;
|
|
187
|
+
readonly versionSpec?: "latest" | "draft";
|
|
188
|
+
readonly generatePdf?: boolean;
|
|
189
|
+
readonly generateDocx?: boolean;
|
|
190
|
+
readonly documentIds?: readonly string[];
|
|
191
|
+
}
|
|
192
|
+
interface DokusWorkflows {
|
|
193
|
+
generate(workflowId: string, input: DokusGenerateInput, options: DokusWriteOptions): Promise<DokusGenerateStarted>;
|
|
194
|
+
generateSync(workflowId: string, input: DokusGenerateInput, options: DokusWriteOptions): Promise<DokusRunResult>;
|
|
195
|
+
generateAll(workflowId: string, input: DokusGenerateAllInput | undefined, options: DokusWriteOptions): Promise<readonly DokusGenerateAllEntry[]>;
|
|
196
|
+
documentRuns(workflowId: string, documentId: string, options?: DokusRequestOptions & {
|
|
197
|
+
readonly limit?: number;
|
|
198
|
+
}): Promise<readonly DokusDocumentRunSummary[]>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
declare const DOKUS_API_BASE_URL = "https://api.dokus.pro";
|
|
202
|
+
|
|
203
|
+
interface DokusClient {
|
|
204
|
+
readonly documents: DokusDocuments;
|
|
205
|
+
readonly runs: DokusRuns;
|
|
206
|
+
readonly workflows: DokusWorkflows;
|
|
207
|
+
}
|
|
208
|
+
/** Create one server-only, API-key-authenticated Dokus client. */
|
|
209
|
+
declare function createDokusClient(options: DokusClientOptions): DokusClient;
|
|
210
|
+
|
|
211
|
+
export { DOKUS_API_BASE_URL, type DokusClient, type DokusClientOptions, type DokusDocumentRenderCompleted, type DokusDocumentRenderStarted, type DokusDocumentRunSummary, type DokusDocuments, type DokusGenerateAllEntry, type DokusGenerateAllInput, type DokusGenerateInput, type DokusGenerateStarted, type DokusOutputDownload, type DokusOutputFileType, type DokusOutputStatus, type DokusPreviewLinkMeta, type DokusPreviewLinkRotated, type DokusRenderDocumentInput, type DokusRequestOptions, type DokusRetryOptions, type DokusRotatePreviewOptions, type DokusRunGetOptions, type DokusRunOutput, type DokusRunOutputs, type DokusRunResult, type DokusRunStatus, type DokusRunWaitOptions, type DokusRuns, type DokusVersionSelection, type DokusWorkflows, type DokusWriteOptions, createDokusClient };
|