|
5 | 5 | // TypeScript Version: ^3.8.3 |
6 | 6 |
|
7 | 7 | import { Task } from "../task"; |
| 8 | +import { Batch } from "../batch"; |
8 | 9 |
|
9 | 10 | export type Config = { |
10 | 11 | host: string; |
@@ -578,6 +579,8 @@ export type EnqueuedTaskObject = { |
578 | 579 |
|
579 | 580 | export type TaskObject = Omit<EnqueuedTaskObject, "taskUid"> & { |
580 | 581 | uid: number; |
| 582 | + /** The UID of the batch that the task belongs to (`null` for enqueued tasks) */ |
| 583 | + batchUid: number | null; |
581 | 584 | details: { |
582 | 585 | // Number of documents sent |
583 | 586 | receivedDocuments?: number; |
@@ -659,6 +662,83 @@ export type WaitOptions = { |
659 | 662 | intervalMs?: number; |
660 | 663 | }; |
661 | 664 |
|
| 665 | +/* |
| 666 | + ** BATCHES |
| 667 | + */ |
| 668 | + |
| 669 | +/** |
| 670 | + * Represents a batch operation object containing information about tasks |
| 671 | + * processing |
| 672 | + */ |
| 673 | +export type BatchObject = { |
| 674 | + /** Unique identifier for the batch */ |
| 675 | + uid: number; |
| 676 | + |
| 677 | + /** Details about document processing */ |
| 678 | + details: { |
| 679 | + /** Number of documents received in the batch */ |
| 680 | + receivedDocuments?: number; |
| 681 | + /** Number of documents successfully indexed */ |
| 682 | + indexedDocuments?: number; |
| 683 | + /** Number of documents deleted in the batch */ |
| 684 | + deletedDocuments?: number; |
| 685 | + }; |
| 686 | + |
| 687 | + /** Progress indicator (currently always null) */ |
| 688 | + progress: null; |
| 689 | + |
| 690 | + /** Statistics about tasks within the batch */ |
| 691 | + stats: { |
| 692 | + /** Total number of tasks in the batch */ |
| 693 | + totalNbTasks: number; |
| 694 | + /** Count of tasks in each status */ |
| 695 | + status: { |
| 696 | + /** Number of successfully completed tasks */ |
| 697 | + succeeded: number; |
| 698 | + /** Number of failed tasks */ |
| 699 | + failed: number; |
| 700 | + /** Number of canceled tasks */ |
| 701 | + canceled: number; |
| 702 | + /** Number of tasks currently processing */ |
| 703 | + processing: number; |
| 704 | + /** Number of tasks waiting to be processed */ |
| 705 | + enqueued: number; |
| 706 | + }; |
| 707 | + /** Count of tasks by type */ |
| 708 | + types: Record<TaskTypes, number>; |
| 709 | + /** Count of tasks by index UID */ |
| 710 | + indexUids: Record<string, number>; |
| 711 | + }; |
| 712 | + |
| 713 | + /** Timestamp when the batch started processing (rfc3339 format) */ |
| 714 | + startedAt: string; |
| 715 | + /** Timestamp when the batch finished processing (rfc3339 format) */ |
| 716 | + finishedAt: string; |
| 717 | + /** Duration of batch processing */ |
| 718 | + duration: string; |
| 719 | +}; |
| 720 | + |
| 721 | +export type BatchesQuery = { |
| 722 | + /** The batch should contain the specified task UIDs */ |
| 723 | + uids?: number[]; |
| 724 | + batchUids?: number[]; |
| 725 | + types?: TaskTypes[]; |
| 726 | + statuses?: TaskStatus[]; |
| 727 | + indexUids?: string[]; |
| 728 | + canceledBy?: number[]; |
| 729 | + beforeEnqueuedAt?: Date; |
| 730 | + afterEnqueuedAt?: Date; |
| 731 | + beforeStartedAt?: Date; |
| 732 | + afterStartedAt?: Date; |
| 733 | + beforeFinishedAt?: Date; |
| 734 | + afterFinishedAt?: Date; |
| 735 | + limit?: number; |
| 736 | + from?: number; |
| 737 | +}; |
| 738 | + |
| 739 | +export type BatchesResults = CursorResults<Batch>; |
| 740 | +export type BatchesResultsObject = CursorResults<BatchObject>; |
| 741 | + |
662 | 742 | /* |
663 | 743 | *** HEALTH |
664 | 744 | */ |
|
0 commit comments