@docmana/sdk 0.3.4 → 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 (48) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +123 -211
  3. package/dist/api/execution-result.d.ts +3 -0
  4. package/dist/api/execution-status.d.ts +6 -0
  5. package/dist/api/run-flow.d.ts +6 -0
  6. package/dist/cli.mjs +225 -250
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/client.d.ts +21 -0
  9. package/dist/config.d.ts +21 -0
  10. package/dist/errors.d.ts +55 -0
  11. package/dist/files/resolve-input.d.ts +11 -0
  12. package/dist/http/http-client.d.ts +26 -0
  13. package/dist/index.d.ts +4 -335
  14. package/dist/index.js +167 -291
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +167 -291
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/models/docmana-api-document-execution-result.model.d.ts +9 -0
  19. package/dist/models/docmana-api-document-request.model.d.ts +15 -0
  20. package/dist/models/docmana-api-execution-result.model.d.ts +24 -0
  21. package/dist/models/docmana-api-node-result.model.d.ts +28 -0
  22. package/dist/models/docmana-classification-result.model.d.ts +3 -0
  23. package/dist/models/docmana-conclusion-result.model.d.ts +3 -0
  24. package/dist/models/docmana-cross-validation-result.model.d.ts +3 -0
  25. package/dist/models/docmana-document-mapping.model.d.ts +4 -0
  26. package/dist/models/docmana-document-result.model.d.ts +11 -0
  27. package/dist/models/docmana-execution-result.model.d.ts +15 -0
  28. package/dist/models/docmana-extraction-result.model.d.ts +3 -0
  29. package/dist/models/docmana-metadata-extraction-result.model.d.ts +3 -0
  30. package/dist/models/docmana-node-result.model.d.ts +7 -0
  31. package/dist/models/docmana-score-node-result.model.d.ts +5 -0
  32. package/dist/models/docmana-validation-result.model.d.ts +3 -0
  33. package/dist/models/document-content.model.d.ts +4 -0
  34. package/dist/models/execution-progress.model.d.ts +4 -0
  35. package/dist/models/execution-status.enum.d.ts +1 -0
  36. package/dist/models/flow-configs.model.d.ts +16 -0
  37. package/dist/models/flow-edge.model.d.ts +4 -0
  38. package/dist/models/flow-node-type.enum.d.ts +1 -0
  39. package/dist/models/flow-node.model.d.ts +33 -0
  40. package/dist/models/flow.model.d.ts +11 -0
  41. package/dist/models/index.d.ts +26 -0
  42. package/dist/models/node-translation-result.model.d.ts +7 -0
  43. package/dist/models/physical-document.model.d.ts +9 -0
  44. package/dist/models/virtual-document.model.d.ts +10 -0
  45. package/dist/polling/poll.d.ts +15 -0
  46. package/dist/types.d.ts +76 -0
  47. package/package.json +17 -14
  48. package/dist/index.d.cts +0 -335
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docmana/sdk",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Official Docmana SDK — run document-analysis flows with a single call.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  }
19
19
  },
20
20
  "bin": {
21
- "docmana": "./dist/cli.mjs"
21
+ "docmana": "dist/cli.mjs"
22
22
  },
23
23
  "files": [
24
24
  "dist",
@@ -27,10 +27,11 @@
27
27
  "CHANGELOG.md"
28
28
  ],
29
29
  "publishConfig": {
30
+ "registry": "https://registry.npmjs.org/",
30
31
  "access": "public"
31
32
  },
32
33
  "dependencies": {
33
- "commander": "^14.0.3"
34
+ "commander": "^15.0.0"
34
35
  },
35
36
  "scripts": {
36
37
  "build": "tsup",
@@ -48,17 +49,19 @@
48
49
  "prepublishOnly": "npm run check && npm run build"
49
50
  },
50
51
  "devDependencies": {
51
- "@types/node": "^22.0.0",
52
- "@typescript-eslint/eslint-plugin": "^8.0.0",
53
- "@typescript-eslint/parser": "^8.0.0",
54
- "@vitest/coverage-v8": "^2.0.0",
55
- "eslint": "^9.0.0",
56
- "prettier": "^3.0.0",
57
- "tsup": "^8.0.0",
58
- "typescript": "^5.6.0",
59
- "typescript-eslint": "^8.60.1",
60
- "undici": "^7.24.4",
61
- "vitest": "^2.0.0",
52
+ "@eslint/js": "^10.0.1",
53
+ "@types/node": "^25.9.3",
54
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
55
+ "@typescript-eslint/parser": "^8.61.0",
56
+ "@vitest/coverage-v8": "^4.1.8",
57
+ "eslint": "^10.5.0",
58
+ "prettier": "^3.8.4",
59
+ "tsup": "^8.5.1",
60
+ "tsx": "^4.22.4",
61
+ "typescript": "^6.0.3",
62
+ "typescript-eslint": "^8.61.0",
63
+ "undici": "^8.4.1",
64
+ "vitest": "^4.1.8",
62
65
  "yalc": "^1.0.0-pre.53"
63
66
  }
64
67
  }
package/dist/index.d.cts DELETED
@@ -1,335 +0,0 @@
1
- interface DocmanaDocumentMapping {
2
- name: string;
3
- reference: string;
4
- }
5
-
6
- interface DocmanaNodeResult {
7
- status: string;
8
- errors?: string[];
9
- /** Human-readable rationale (language-specific). Returned for every node. */
10
- feedback?: string;
11
- data?: Record<string, unknown>;
12
- }
13
-
14
- interface DocmanaScoreNodeResult extends DocmanaNodeResult {
15
- /** Numeric confidence (0..100), identical across languages (not translated). */
16
- score?: number;
17
- }
18
-
19
- interface DocmanaClassificationResult extends DocmanaScoreNodeResult {
20
- }
21
-
22
- interface DocmanaMetadataExtractionResult extends DocmanaNodeResult {
23
- }
24
-
25
- interface DocmanaExtractionResult extends DocmanaNodeResult {
26
- }
27
-
28
- interface DocmanaValidationResult extends DocmanaScoreNodeResult {
29
- }
30
-
31
- interface DocmanaDocumentResult {
32
- status: string;
33
- classifications?: Record<string, DocmanaClassificationResult>;
34
- metadataExtraction?: DocmanaMetadataExtractionResult;
35
- extractions?: Record<string, DocmanaExtractionResult>;
36
- validations?: Record<string, DocmanaValidationResult>;
37
- }
38
-
39
- interface DocmanaCrossValidationResult extends DocmanaScoreNodeResult {
40
- }
41
-
42
- interface DocmanaConclusionResult extends DocmanaScoreNodeResult {
43
- }
44
-
45
- interface DocmanaExecutionResult {
46
- status: string;
47
- executionId: string;
48
- errors?: string[];
49
- documents: {
50
- mappings: DocmanaDocumentMapping[];
51
- [docKey: string]: DocmanaDocumentResult | DocmanaDocumentMapping[];
52
- };
53
- crossValidations?: Record<string, DocmanaCrossValidationResult>;
54
- conclusions?: Record<string, DocmanaConclusionResult>;
55
- }
56
-
57
- type ExecutionStatus = "Pending" | "Running" | "Incompleted" | "Completed" | "Failed";
58
-
59
- interface DocmanaConfig {
60
- clientId: string;
61
- clientSecret: string;
62
- apiBaseUrl?: string;
63
- tokenEndpoint?: string;
64
- scope?: string;
65
- timeoutMs?: number;
66
- pollIntervalMs?: number;
67
- fetch?: typeof fetch;
68
- headers?: Record<string, string>;
69
- tokenCache?: TokenCache;
70
- }
71
- interface TokenCacheEntry {
72
- accessToken: string;
73
- expiresAt: number;
74
- clientId: string;
75
- tokenEndpoint: string;
76
- scope: string;
77
- }
78
- interface TokenCache {
79
- read(): Promise<TokenCacheEntry | null>;
80
- write(entry: TokenCacheEntry): Promise<void>;
81
- clear(): Promise<void>;
82
- }
83
- interface PathFileInput {
84
- path: string;
85
- }
86
- type FileInput = string | PathFileInput | Uint8Array | NodeJS.ReadableStream;
87
- interface RunFlowInput {
88
- file?: FileInput;
89
- files?: FileInput[];
90
- fileName?: string;
91
- signal?: AbortSignal;
92
- timeoutMs?: number;
93
- pollIntervalMs?: number;
94
- once?: boolean;
95
- language?: string;
96
- context?: Record<string, unknown>;
97
- }
98
-
99
- declare class Docmana {
100
- private readonly config;
101
- private readonly http;
102
- constructor(config: DocmanaConfig);
103
- runFlowAsync(flowId: string, input: RunFlowInput): Promise<{
104
- executionResultId: string;
105
- fileIds: string[];
106
- }>;
107
- getStatus(executionResultId: string, signal?: AbortSignal): Promise<{
108
- status: ExecutionStatus | string;
109
- }>;
110
- getResult(executionResultId: string, signal?: AbortSignal, language?: string): Promise<DocmanaExecutionResult>;
111
- runFlow(flowId: string, input: RunFlowInput): Promise<DocmanaExecutionResult>;
112
- }
113
-
114
- declare class DocmanaError extends Error {
115
- readonly status?: number;
116
- readonly requestId?: string;
117
- readonly code: string;
118
- constructor(message: string, opts?: {
119
- status?: number;
120
- requestId?: string;
121
- code?: string;
122
- });
123
- }
124
- declare class DocmanaAuthError extends DocmanaError {
125
- constructor(message: string, opts?: {
126
- status?: number;
127
- requestId?: string;
128
- });
129
- }
130
- declare class DocmanaPermissionError extends DocmanaError {
131
- constructor(message: string, opts?: {
132
- status?: number;
133
- requestId?: string;
134
- });
135
- }
136
- declare class DocmanaNotFoundError extends DocmanaError {
137
- constructor(message: string, opts?: {
138
- status?: number;
139
- requestId?: string;
140
- });
141
- }
142
- declare class DocmanaRequestError extends DocmanaError {
143
- constructor(message: string, opts?: {
144
- status?: number;
145
- requestId?: string;
146
- });
147
- }
148
- declare class DocmanaExecutionError extends DocmanaError {
149
- readonly errors: unknown[];
150
- readonly result?: DocmanaExecutionResult;
151
- constructor(message: string, errors?: unknown[], result?: DocmanaExecutionResult);
152
- }
153
- declare class DocmanaTimeoutError extends DocmanaError {
154
- constructor(message: string);
155
- }
156
- declare class DocmanaAbortError extends DocmanaError {
157
- constructor(message: string);
158
- }
159
-
160
- interface PhysicalDocument {
161
- physical_document_name: string;
162
- physical_document_id: string;
163
- physical_document_path?: string;
164
- page_from: number;
165
- page_to: number;
166
- physical_document_url?: string;
167
- metadata?: Record<string, unknown>;
168
- }
169
-
170
- interface DocumentContent {
171
- coordinates_unit?: string;
172
- pages?: Array<Array<Record<string, unknown>>>;
173
- }
174
-
175
- interface VirtualDocument {
176
- source: PhysicalDocument;
177
- virtual_document_name: string;
178
- virtual_document_id: string;
179
- is_translated: boolean;
180
- document_types?: string[];
181
- content?: DocumentContent;
182
- }
183
-
184
- type FlowNodeType = "Start" | "Finish" | "DataMapping" | "Classification" | "Extraction" | "Validation" | "CrossValidation" | "MetadataExtraction";
185
-
186
- interface FlowConfigs {
187
- description?: string | null;
188
- useIntelligentSplitting: boolean;
189
- useSplittingAsContextOnly: boolean;
190
- useDetectAndClassifyPII: boolean;
191
- enableChatFeature: boolean;
192
- defaultLanguage?: string | null;
193
- additionalLanguages?: string[] | null;
194
- enableDocumentPersistenceForViewing: boolean;
195
- preClassificationAggregatorPrompt?: string | null;
196
- preClassificationSummarizerPrompt?: string | null;
197
- enforceSingleClassificationPerDocument?: boolean | null;
198
- useFraudDetection: boolean;
199
- fraudDetectionThreshold: number;
200
- useMetadataExtraction: boolean;
201
- }
202
-
203
- interface FlowNodePromptMessage {
204
- role: string;
205
- content: string;
206
- type?: string | null;
207
- }
208
- interface FlowNodePromptOutputStructure {
209
- output_structure: Record<string, {
210
- type: string;
211
- description?: string | null;
212
- items?: Record<string, unknown> | null;
213
- properties?: Record<string, unknown> | null;
214
- context?: string | null;
215
- }>;
216
- }
217
- interface FlowNode {
218
- node_id: string;
219
- label: string;
220
- unique_name?: string | null;
221
- type: FlowNodeType;
222
- has_single_document_type: boolean;
223
- prompt_id?: string | null;
224
- commit?: string | null;
225
- target_language?: string | null;
226
- mock_results?: Record<string, unknown> | null;
227
- enabled?: boolean;
228
- model?: string | null;
229
- classification_priority?: number;
230
- prompt_messages?: {
231
- messages: FlowNodePromptMessage[];
232
- } | null;
233
- prompt_output_structure?: FlowNodePromptOutputStructure | null;
234
- }
235
-
236
- interface FlowEdge {
237
- source: string;
238
- target: string;
239
- }
240
-
241
- interface Flow {
242
- flow_id: string;
243
- name: string;
244
- version: number;
245
- configs: FlowConfigs;
246
- nodes: FlowNode[];
247
- edges: FlowEdge[];
248
- }
249
-
250
- interface NodeTranslationResult {
251
- status?: string;
252
- running_time?: number | null;
253
- feedback?: string | null;
254
- score?: number | null;
255
- [key: string]: unknown;
256
- }
257
-
258
- interface ExecutionProgress {
259
- status: string;
260
- errors?: string[];
261
- }
262
-
263
- interface DocmanaApiDocumentRequest {
264
- name: string;
265
- file_extension: string;
266
- sas_url: string;
267
- blob_name: string;
268
- uuid_file: string;
269
- physical_document_id?: string | null;
270
- doc_key: string | null;
271
- status?: string | null;
272
- error_message?: string | null;
273
- message?: string | null;
274
- message_code?: string | null;
275
- metadata?: Record<string, unknown> | null;
276
- is_temporary_upload?: boolean;
277
- }
278
-
279
- interface DocmanaApiNodeResult {
280
- node_id?: string;
281
- node_name?: string | null;
282
- node_type?: string | null;
283
- feature_name?: string | null;
284
- running_time?: number | null;
285
- status?: string;
286
- score?: number | null;
287
- feedback?: string | null;
288
- translations?: Record<string, NodeTranslationResult> | null;
289
- tokens?: number | null;
290
- input_tokens?: number | null;
291
- output_tokens?: number | null;
292
- errors?: string[];
293
- mana?: number | null;
294
- model?: string | null;
295
- tool_calls?: Record<string, unknown>[] | null;
296
- prompt_id?: string | null;
297
- prompt?: string | null;
298
- prompt_name?: string | null;
299
- label?: string | null;
300
- scoreDescription?: string | null;
301
- score_description?: string | null;
302
- result?: unknown;
303
- documentType?: string | null;
304
- [key: string]: unknown;
305
- }
306
-
307
- interface DocmanaApiDocumentExecutionResult {
308
- document?: DocmanaApiDocumentRequest;
309
- node_results?: DocmanaApiNodeResult[];
310
- status?: string;
311
- error?: string | null;
312
- [key: string]: unknown;
313
- }
314
-
315
- interface DocmanaApiExecutionResult {
316
- status: ExecutionStatus | string;
317
- error?: string;
318
- errors?: string[];
319
- document_requests?: DocmanaApiDocumentRequest[];
320
- flow?: Flow | null;
321
- results?: DocmanaApiDocumentExecutionResult[];
322
- restructured_documents?: VirtualDocument[];
323
- execution_id?: string;
324
- total_running_time?: number;
325
- total_running_time_node?: number;
326
- total_tokens?: number;
327
- total_input_tokens?: number;
328
- total_output_tokens?: number;
329
- total_documents?: number;
330
- total_pages?: number;
331
- event_timestamp?: string;
332
- [key: string]: unknown;
333
- }
334
-
335
- export { Docmana, DocmanaAbortError, type DocmanaApiDocumentExecutionResult, type DocmanaApiDocumentRequest, type DocmanaApiExecutionResult, type DocmanaApiNodeResult, DocmanaAuthError, type DocmanaClassificationResult, type DocmanaConclusionResult, type DocmanaConfig, type DocmanaCrossValidationResult, type DocmanaDocumentMapping, type DocmanaDocumentResult, DocmanaError, DocmanaExecutionError, type DocmanaExecutionResult, type DocmanaExtractionResult, type DocmanaMetadataExtractionResult, type DocmanaNodeResult, DocmanaNotFoundError, DocmanaPermissionError, DocmanaRequestError, type DocmanaScoreNodeResult, DocmanaTimeoutError, type DocmanaValidationResult, type DocumentContent, type ExecutionProgress, type ExecutionStatus, type FileInput, type Flow, type FlowConfigs, type FlowEdge, type FlowNode, type FlowNodeType, type NodeTranslationResult, type PhysicalDocument, type RunFlowInput, type VirtualDocument };