@anyformat/sdk 1.10.0 → 1.12.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/dist/index.d.cts CHANGED
@@ -319,6 +319,72 @@ interface TDataShape {
319
319
  type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
320
320
  type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
321
321
 
322
+ /**
323
+ * AccuracyCoverageV3
324
+ *
325
+ * Which fields have ground truth to grade against.
326
+ */
327
+ type AccuracyCoverageV3 = {
328
+ /**
329
+ * Graded Persistent Ids
330
+ *
331
+ * Fields graded on at least one document.
332
+ */
333
+ graded_persistent_ids: Array<string>;
334
+ /**
335
+ * Ungraded Persistent Ids
336
+ *
337
+ * Fields graded on no document.
338
+ */
339
+ ungraded_persistent_ids: Array<string>;
340
+ };
341
+ /**
342
+ * AccuracyV3
343
+ *
344
+ * An accuracy breakdown: totals, per field, per document and per dataset tag.
345
+ *
346
+ * Accuracy is `matched / (matched + mismatched)`; `ungraded` values are left
347
+ * out of it.
348
+ */
349
+ type AccuracyV3 = {
350
+ /**
351
+ * By Dataset Tag
352
+ *
353
+ * Counts per dataset tag, ordered by tag name.
354
+ */
355
+ by_dataset_tag: Array<DatasetTagAccuracyV3>;
356
+ /**
357
+ * By Document Packet
358
+ *
359
+ * Counts per document.
360
+ */
361
+ by_document_packet: Array<DocumentPacketAccuracyV3>;
362
+ /**
363
+ * By Field
364
+ *
365
+ * Counts per field.
366
+ */
367
+ by_field: Array<FieldAccuracyV3>;
368
+ coverage: AccuracyCoverageV3;
369
+ /**
370
+ * Matched
371
+ *
372
+ * Values that matched ground truth.
373
+ */
374
+ matched: number;
375
+ /**
376
+ * Mismatched
377
+ *
378
+ * Values that did not match ground truth.
379
+ */
380
+ mismatched: number;
381
+ /**
382
+ * Ungraded
383
+ *
384
+ * Values with no ground truth to grade against.
385
+ */
386
+ ungraded: number;
387
+ };
322
388
  /**
323
389
  * AllOfCheck
324
390
  *
@@ -681,6 +747,59 @@ type ConsolidationCandidate = {
681
747
  */
682
748
  value_unit?: string | null;
683
749
  };
750
+ /**
751
+ * DatasetTagAccuracyV3
752
+ *
753
+ * Grading counts for the documents carrying one dataset tag.
754
+ *
755
+ * A document counts under every tag it carries, so the rows do not add up to
756
+ * the totals.
757
+ */
758
+ type DatasetTagAccuracyV3 = {
759
+ /**
760
+ * Dataset Tag Id
761
+ *
762
+ * The dataset tag's id (hyphenated UUID).
763
+ */
764
+ dataset_tag_id: string;
765
+ /**
766
+ * Matched
767
+ *
768
+ * Values that matched ground truth.
769
+ */
770
+ matched: number;
771
+ /**
772
+ * Mismatched
773
+ *
774
+ * Values that did not match ground truth.
775
+ */
776
+ mismatched: number;
777
+ };
778
+ /**
779
+ * DatasetTagV3
780
+ *
781
+ * One of a workflow's dataset tags.
782
+ */
783
+ type DatasetTagV3 = {
784
+ /**
785
+ * Created At
786
+ *
787
+ * Timestamp when the tag was created (ISO 8601).
788
+ */
789
+ created_at?: string | null;
790
+ /**
791
+ * Id
792
+ *
793
+ * The dataset tag's id (hyphenated UUID); pass it in `dataset_tag_ids` to launch an eval on the documents carrying it.
794
+ */
795
+ id: string;
796
+ /**
797
+ * Name
798
+ *
799
+ * The tag's name, unique within the workflow.
800
+ */
801
+ name: string;
802
+ };
684
803
  /**
685
804
  * DatasetUploadFileV3
686
805
  *
@@ -853,6 +972,67 @@ type Detection = {
853
972
  */
854
973
  type: string;
855
974
  };
975
+ /**
976
+ * DocumentPacketAccuracyV3
977
+ *
978
+ * Grading counts for one dataset document.
979
+ */
980
+ type DocumentPacketAccuracyV3 = {
981
+ /**
982
+ * Document Packet Id
983
+ *
984
+ * The dataset copy's document packet id (hyphenated UUID), not the id of the production packet it was added from.
985
+ */
986
+ document_packet_id: string;
987
+ /**
988
+ * Failed Persistent Ids
989
+ *
990
+ * `persistent_id` of every field with at least one mismatched value.
991
+ */
992
+ failed_persistent_ids: Array<string>;
993
+ /**
994
+ * File Count
995
+ *
996
+ * Number of files in the document packet.
997
+ */
998
+ file_count: number;
999
+ /**
1000
+ * First File Name
1001
+ *
1002
+ * Name of the document's first file.
1003
+ */
1004
+ first_file_name: string;
1005
+ /**
1006
+ * Has Extraction
1007
+ *
1008
+ * `false` when the eval produced no extraction for this document.
1009
+ */
1010
+ has_extraction: boolean;
1011
+ /**
1012
+ * Matched
1013
+ *
1014
+ * Values that matched ground truth.
1015
+ */
1016
+ matched: number;
1017
+ /**
1018
+ * Mismatched
1019
+ *
1020
+ * Values that did not match ground truth.
1021
+ */
1022
+ mismatched: number;
1023
+ /**
1024
+ * Name
1025
+ *
1026
+ * The document packet's own name. Absent when it has none.
1027
+ */
1028
+ name?: string | null;
1029
+ /**
1030
+ * Ungraded
1031
+ *
1032
+ * Values with no ground truth to grade against.
1033
+ */
1034
+ ungraded: number;
1035
+ };
856
1036
  /**
857
1037
  * DocumentPacketDetailV3
858
1038
  *
@@ -1152,6 +1332,167 @@ type EnumOption = {
1152
1332
  */
1153
1333
  name: string;
1154
1334
  };
1335
+ /**
1336
+ * EvalDetailV3
1337
+ *
1338
+ * One eval's frozen headline — the poll target for a launched run.
1339
+ *
1340
+ * ``id`` here is the same identifier the launch returned as ``eval_id``. The
1341
+ * headline fields (``accuracy``, ``matched``, ``mismatched``, ``ungraded``)
1342
+ * are ``null`` while ``status`` is ``in_progress``; ``accuracy`` stays ``null``
1343
+ * on a ``processed`` eval whose graded denominator is 0.
1344
+ */
1345
+ type EvalDetailV3 = {
1346
+ /**
1347
+ * Accuracy
1348
+ *
1349
+ * Headline accuracy in [0, 1]; `null` while `in_progress` and on a `processed` eval with a 0 graded denominator.
1350
+ */
1351
+ accuracy?: number | null;
1352
+ /**
1353
+ * Created At
1354
+ *
1355
+ * Timestamp when the eval was created (ISO 8601).
1356
+ */
1357
+ created_at?: string | null;
1358
+ /**
1359
+ * Dataset Tag Ids
1360
+ *
1361
+ * Dataset tags the eval was launched on, as sent at launch. Absent on an eval of the whole dataset.
1362
+ */
1363
+ dataset_tag_ids?: Array<string>;
1364
+ /**
1365
+ * Failed Count
1366
+ *
1367
+ * Number of dataset documents that failed to enqueue for this run.
1368
+ */
1369
+ failed_count: number;
1370
+ /**
1371
+ * File Count
1372
+ *
1373
+ * Number of dataset documents in the eval's realized cohort.
1374
+ */
1375
+ file_count: number;
1376
+ /**
1377
+ * Id
1378
+ *
1379
+ * Unique identifier of the eval (hyphenated UUID); equals the launch's `eval_id`.
1380
+ */
1381
+ id: string;
1382
+ /**
1383
+ * Matched
1384
+ *
1385
+ * Values that matched ground truth; `null` while `in_progress`.
1386
+ */
1387
+ matched?: number | null;
1388
+ /**
1389
+ * Mismatched
1390
+ *
1391
+ * Values that did not match ground truth; `null` while `in_progress`.
1392
+ */
1393
+ mismatched?: number | null;
1394
+ /**
1395
+ * Run Number
1396
+ *
1397
+ * Per-workflow run counter (#1, #2, …) for this eval.
1398
+ */
1399
+ run_number: number;
1400
+ /**
1401
+ * Grading status. Non-terminal: `in_progress`. Terminal: `processed`, `error`.
1402
+ */
1403
+ status: EvalStatus;
1404
+ /**
1405
+ * Ungraded
1406
+ *
1407
+ * Values with no ground truth to grade against; `null` while `in_progress`.
1408
+ */
1409
+ ungraded?: number | null;
1410
+ /**
1411
+ * Untagged
1412
+ *
1413
+ * `true` when the eval also ran the untagged documents. Absent otherwise.
1414
+ */
1415
+ untagged?: boolean;
1416
+ /**
1417
+ * Version Id
1418
+ *
1419
+ * Workflow version the eval scored.
1420
+ */
1421
+ version_id: string;
1422
+ };
1423
+ /**
1424
+ * EvalDocumentPacketFieldsV3
1425
+ *
1426
+ * Extracted against expected values for one document of an eval.
1427
+ */
1428
+ type EvalDocumentPacketFieldsV3 = {
1429
+ /**
1430
+ * Document Packet Id
1431
+ *
1432
+ * The dataset copy's document packet id (hyphenated UUID), not the id of the production packet it was added from.
1433
+ */
1434
+ document_packet_id: string;
1435
+ /**
1436
+ * Fields
1437
+ *
1438
+ * One entry per graded field.
1439
+ */
1440
+ fields: Array<FieldValuesV3>;
1441
+ /**
1442
+ * First File Name
1443
+ *
1444
+ * Name of the document's first file.
1445
+ */
1446
+ first_file_name: string;
1447
+ /**
1448
+ * Has Extraction
1449
+ *
1450
+ * `false` when the eval produced no extraction for this document.
1451
+ */
1452
+ has_extraction: boolean;
1453
+ };
1454
+ /**
1455
+ * EvalLaunchedV3
1456
+ *
1457
+ * 202 response: the eval was created and its cohort enqueued.
1458
+ *
1459
+ * Exposes counts, never the internal extraction/file ids. Read the eval by
1460
+ * ``eval_id`` for the per-document breakdown (including which documents
1461
+ * failed to enqueue).
1462
+ */
1463
+ type EvalLaunchedV3 = {
1464
+ /**
1465
+ * Enqueued Count
1466
+ *
1467
+ * Number of dataset documents whose extraction was enqueued for this run.
1468
+ */
1469
+ enqueued_count: number;
1470
+ /**
1471
+ * Eval Id
1472
+ *
1473
+ * Unique identifier of the new eval (hyphenated UUID); the poll handle.
1474
+ */
1475
+ eval_id: string;
1476
+ /**
1477
+ * Failed Count
1478
+ *
1479
+ * Number of dataset documents that failed to enqueue. Read the eval for the failed document ids.
1480
+ */
1481
+ failed_count: number;
1482
+ /**
1483
+ * Run Number
1484
+ *
1485
+ * Per-workflow run counter (#1, #2, …) for this eval.
1486
+ */
1487
+ run_number: number;
1488
+ };
1489
+ /**
1490
+ * EvalStatus
1491
+ *
1492
+ * Grading lifecycle of an eval. Non-terminal: ``in_progress`` (the headline
1493
+ * fields are null). Terminal: ``processed`` (graded) and ``error``.
1494
+ */
1495
+ type EvalStatus = 'in_progress' | 'processed' | 'error';
1155
1496
  /**
1156
1497
  * Evidence
1157
1498
  *
@@ -1310,6 +1651,62 @@ type ExtractionSchema = {
1310
1651
  */
1311
1652
  fields: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField | ObjectField>;
1312
1653
  };
1654
+ /**
1655
+ * FieldAccuracyV3
1656
+ *
1657
+ * Grading counts for one field across the graded documents.
1658
+ */
1659
+ type FieldAccuracyV3 = {
1660
+ /**
1661
+ * Matched
1662
+ *
1663
+ * Values of this field that matched ground truth.
1664
+ */
1665
+ matched: number;
1666
+ /**
1667
+ * Mismatched
1668
+ *
1669
+ * Values of this field that did not match ground truth.
1670
+ */
1671
+ mismatched: number;
1672
+ /**
1673
+ * Persistent Id
1674
+ *
1675
+ * The field's `persistent_id` in the workflow schema.
1676
+ */
1677
+ persistent_id: string;
1678
+ /**
1679
+ * Ungraded
1680
+ *
1681
+ * Values of this field with no ground truth to grade against.
1682
+ */
1683
+ ungraded: number;
1684
+ };
1685
+ /**
1686
+ * FieldValuesV3
1687
+ *
1688
+ * One field's extracted value beside its ground truth.
1689
+ */
1690
+ type FieldValuesV3 = {
1691
+ /**
1692
+ * Expected
1693
+ *
1694
+ * The ground-truth value, in the same shape.
1695
+ */
1696
+ expected?: unknown;
1697
+ /**
1698
+ * Extracted
1699
+ *
1700
+ * The value the eval extracted. A scalar for a scalar field; for a field inside a list or object, one value per row, in row order.
1701
+ */
1702
+ extracted?: unknown;
1703
+ /**
1704
+ * Persistent Id
1705
+ *
1706
+ * The field's `persistent_id` in the workflow schema.
1707
+ */
1708
+ persistent_id: string;
1709
+ };
1313
1710
  /**
1314
1711
  * FilePages
1315
1712
  *
@@ -2495,6 +2892,35 @@ type WorkflowSummaryV3 = {
2495
2892
  */
2496
2893
  updated_at?: string | null;
2497
2894
  };
2895
+ /**
2896
+ * WorkflowVersionSummaryV3
2897
+ *
2898
+ * One entry in a workflow's version history.
2899
+ *
2900
+ * Versions are read-only: they exist for comparison and audit, and runs
2901
+ * always use the latest version. Pass ``version_id`` as
2902
+ * ``GET /v3/workflows/{workflow_id}/?version=`` to read that version's graph.
2903
+ */
2904
+ type WorkflowVersionSummaryV3 = {
2905
+ /**
2906
+ * Created At
2907
+ *
2908
+ * Timestamp when the version was created (ISO 8601).
2909
+ */
2910
+ created_at?: string | null;
2911
+ /**
2912
+ * Version
2913
+ *
2914
+ * Display number, `major.minor.patch`.
2915
+ */
2916
+ version: string;
2917
+ /**
2918
+ * Version Id
2919
+ *
2920
+ * Identifier of the version; pass it as `?version=` on `GET /v3/workflows/{workflow_id}/`.
2921
+ */
2922
+ version_id: string;
2923
+ };
2498
2924
  /**
2499
2925
  * _FieldOperand
2500
2926
  */
@@ -2903,6 +3329,13 @@ interface ListOptions {
2903
3329
  /** Opaque token from a previous page's `nextCursor`. */
2904
3330
  cursor?: string;
2905
3331
  }
3332
+ /** Narrows an eval to a tagged subset; omit both for the whole dataset. */
3333
+ interface DatasetTagFilter {
3334
+ /** Documents carrying at least one of these dataset tags. */
3335
+ datasetTagIds?: string[];
3336
+ /** Documents with no dataset tag; with `datasetTagIds`, their union. */
3337
+ untagged?: boolean;
3338
+ }
2906
3339
  interface IterOptions {
2907
3340
  /** Page size the auto-pager fetches per underlying request, capped at 100 by the API. */
2908
3341
  limit?: number;
@@ -2920,8 +3353,13 @@ declare class Anyformat {
2920
3353
  constructor(opts: AnyformatOptions);
2921
3354
  workflow(name: string, description?: string): WorkflowBuilder;
2922
3355
  listWorkflows(opts?: ListOptions): Promise<Page<Workflow>>;
2923
- /** Retrieve a workflow with its complete typed graph inline (round-trippable into `updateWorkflow`). */
2924
- getWorkflow(workflowId: string): Promise<WorkflowDetailV3>;
3356
+ /**
3357
+ * Retrieve a workflow with its complete typed graph inline (round-trippable into `updateWorkflow`).
3358
+ * Pass a `version_id` as `version` to read that version instead of the current one.
3359
+ */
3360
+ getWorkflow(workflowId: string, opts?: {
3361
+ version?: string;
3362
+ }): Promise<WorkflowDetailV3>;
2925
3363
  /**
2926
3364
  * Replace a workflow's typed graph (atomic). Accepts the shape `getWorkflow`
2927
3365
  * returns — echo each field's `persistent_id` unchanged (including across
@@ -2951,6 +3389,10 @@ declare class Anyformat {
2951
3389
  iterDocumentPackets(workflowId: string, opts?: IterOptions): AsyncIterableIterator<DocumentPacketSummaryV3>;
2952
3390
  /** Every run of a workflow, following `nextCursor` across pages. Lazy. */
2953
3391
  iterRuns(workflowId: string, opts?: IterOptions): AsyncIterableIterator<RunSummaryV3>;
3392
+ /** A workflow's versions, newest first; item 0 of the first page is the current version. */
3393
+ listWorkflowVersions(workflowId: string, opts?: ListOptions): Promise<Page<WorkflowVersionSummaryV3>>;
3394
+ /** Every version of a workflow, newest first, following `nextCursor` across pages. Lazy. */
3395
+ iterWorkflowVersions(workflowId: string, opts?: IterOptions): AsyncIterableIterator<WorkflowVersionSummaryV3>;
2954
3396
  /** Retrieve one run: lifecycle status plus results inline once `processed`. */
2955
3397
  getRun(runId: string): Promise<RunDetailV3>;
2956
3398
  /**
@@ -2975,6 +3417,25 @@ declare class Anyformat {
2975
3417
  * or `null` while it is still queued or in progress.
2976
3418
  */
2977
3419
  getParseMarkdown(runId: string): Promise<string | null>;
3420
+ /** A workflow's dataset tags, ordered by name; a tag's `id` is what `datasetTagIds` takes. */
3421
+ listDatasetTags(workflowId: string): Promise<DatasetTagV3[]>;
3422
+ /**
3423
+ * Launch an eval: extract every dataset document on a version and grade it
3424
+ * against ground truth. Billed per document. Omit `versionId` for the current
3425
+ * version. `idempotencyKey` makes a retry return the original eval instead of
3426
+ * launching a second one. `datasetTagIds: []` without `untagged: true` throws.
3427
+ */
3428
+ launchEval(workflowId: string, opts?: DatasetTagFilter & {
3429
+ versionId?: string;
3430
+ idempotencyKey?: string;
3431
+ }): Promise<EvalLaunchedV3>;
3432
+ /** One eval's headline; poll it until `status` leaves `in_progress`. */
3433
+ getEval(workflowId: string, evalId: string): Promise<EvalDetailV3>;
3434
+ listEvals(workflowId: string, opts?: ListOptions): Promise<Page<EvalDetailV3>>;
3435
+ /** An eval's accuracy per field, per document and per dataset tag; partial while it runs. */
3436
+ getEvalAccuracy(workflowId: string, evalId: string): Promise<AccuracyV3>;
3437
+ /** One eval document's extracted values beside its ground truth. The id is the dataset copy's. */
3438
+ getEvalDocumentPacketFields(workflowId: string, evalId: string, documentPacketId: string): Promise<EvalDocumentPacketFieldsV3>;
2978
3439
  }
2979
3440
 
2980
3441
  declare class AnyformatError extends Error {
@@ -3054,4 +3515,4 @@ declare class ExtractionCancelledError extends RunFailedError {
3054
3515
  declare class WorkflowBuilderError extends AnyformatError {
3055
3516
  }
3056
3517
 
3057
- export { APIError, type AllOfCheck, type AnyOfCheck, Anyformat, AnyformatError, type AnyformatOptions, type ArithmeticCheck, BadRequestError, type Block, type BooleanField, type Branch, type ClassifyCategory, type ComparisonCheck, type DatasetDocument, DatasetUpload, type DatasetUploadFileV3, type DatasetUploadOptions, type DatasetUploadResponseV3, type DateCheck, type DateField, type DatetimeField, type DocumentPacketDetailV3, type DocumentPacketFileV3, type DocumentPacketStatus, type DocumentPacketSummaryV3, type Edge, type EnumField, type EnumOption, type ExpressionCheck, type ExtractedField, type ExtractedRows, type Extraction, ExtractionCancelledError, ExtractionFailedError, type ExtractionSchema, type Field, type FloatField, ForbiddenError, InsufficientScopeError, type IntegerField, type IterOptions, type JsonValue, type ListOptions, type MultiSelectField, type NestedField, NotFoundError, type ObjectField, type OneOfCheck, type Page, type ParseResult, ParseView, PaymentRequiredError, type RangeCheck, RateLimitedError, type RegexCheck, type RequiredCheck, Result, type ResultsResponseV3, Run, type RunDetailV3, RunFailedError, type RunStatus, type RunSummaryV3, type RunTriggerOptions, SDKTimeoutError, type ScalarOrList, Schema, ServerError, type SplitPartition, type SplitResult, type SplitterRule, type StringField, TermsAcceptanceRequiredError, UnauthorizedError, Upload, type UploadFromUrlsOptions, type UploadOptions, type ValidationItem, type ValidationRule, type WaitOptions, Workflow, WorkflowBuilder, WorkflowBuilderError, type WorkflowCreateRequest, type WorkflowDefinition, type WorkflowDetailV3, WorkflowNameConflictError, type WorkflowSummaryV3 };
3518
+ export { APIError, type AccuracyCoverageV3, type AccuracyV3, type AllOfCheck, type AnyOfCheck, Anyformat, AnyformatError, type AnyformatOptions, type ArithmeticCheck, BadRequestError, type Block, type BooleanField, type Branch, type ClassifyCategory, type ComparisonCheck, type DatasetDocument, type DatasetTagAccuracyV3, type DatasetTagFilter, type DatasetTagV3, DatasetUpload, type DatasetUploadFileV3, type DatasetUploadOptions, type DatasetUploadResponseV3, type DateCheck, type DateField, type DatetimeField, type DocumentPacketAccuracyV3, type DocumentPacketDetailV3, type DocumentPacketFileV3, type DocumentPacketStatus, type DocumentPacketSummaryV3, type Edge, type EnumField, type EnumOption, type EvalDetailV3, type EvalDocumentPacketFieldsV3, type EvalLaunchedV3, type ExpressionCheck, type ExtractedField, type ExtractedRows, type Extraction, ExtractionCancelledError, ExtractionFailedError, type ExtractionSchema, type Field, type FieldAccuracyV3, type FieldValuesV3, type FloatField, ForbiddenError, InsufficientScopeError, type IntegerField, type IterOptions, type JsonValue, type ListOptions, type MultiSelectField, type NestedField, NotFoundError, type ObjectField, type OneOfCheck, type Page, type ParseResult, ParseView, PaymentRequiredError, type RangeCheck, RateLimitedError, type RegexCheck, type RequiredCheck, Result, type ResultsResponseV3, Run, type RunDetailV3, RunFailedError, type RunStatus, type RunSummaryV3, type RunTriggerOptions, SDKTimeoutError, type ScalarOrList, Schema, ServerError, type SplitPartition, type SplitResult, type SplitterRule, type StringField, TermsAcceptanceRequiredError, UnauthorizedError, Upload, type UploadFromUrlsOptions, type UploadOptions, type ValidationItem, type ValidationRule, type WaitOptions, Workflow, WorkflowBuilder, WorkflowBuilderError, type WorkflowCreateRequest, type WorkflowDefinition, type WorkflowDetailV3, WorkflowNameConflictError, type WorkflowSummaryV3, type WorkflowVersionSummaryV3 };