From 75ad86cf8d9e3235eb99287d26af206ba28dbc16 Mon Sep 17 00:00:00 2001 From: Arnav Reddy Andem Date: Tue, 21 Jul 2026 16:48:11 +0530 Subject: [PATCH 1/2] feat: add pre_extraction_item_counts to EventData for sync duration estimation Add ItemInputType enum ('main'/'users') and ItemTypeCount interface, and an optional pre_extraction_item_counts field on EventData so ADaaS snap-ins can report per-record-type counts on the metadata-done event. The field is optional and passes through emit unchanged, so existing snap-ins are unaffected. ASFND-360 Co-Authored-By: Claude Opus 4.8 (1M context) --- REFERENCE.md | 31 +++++++++++++++++++ .../worker-adapter.emit.test.ts | 31 +++++++++++++++++++ src/types/extraction.ts | 19 ++++++++++++ src/types/index.ts | 2 ++ 4 files changed, 83 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index b949a3b4..33c0ab79 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -466,6 +466,37 @@ Defines the structure of event data that is sent from the external extractor to Optional. A **string** representing the stats file artifact ID. +- _pre_extraction_item_counts_ + + Optional. An array of **ItemTypeCount** objects reporting per-record-type counts collected during the metadata phase. Used for sync duration estimation. + +### `ItemInputType` enum + +Defines which sync duration estimation input a counted record type feeds into. + +#### Values + +- `MAIN` = `'main'` +- `USERS` = `'users'` + +### `ItemTypeCount` interface + +Represents a per-record-type count reported during the metadata phase, used for sync duration estimation. + +#### Properties + +- _record_type_ + + Required. A **string** identifying the external record type being counted. + +- _count_ + + Required. A **number** with the count of records of this type. + +- _model_input_type_ + + Required. An **ItemInputType** value indicating which estimation input this record type feeds into. + ### `EventType` enum Defines the different types of events that can be sent to the external extractor from ADaaS. The external extractor uses these events to know what to do next in the extraction process. diff --git a/src/multithreading/worker-adapter/worker-adapter.emit.test.ts b/src/multithreading/worker-adapter/worker-adapter.emit.test.ts index 2da61f73..6812c369 100644 --- a/src/multithreading/worker-adapter/worker-adapter.emit.test.ts +++ b/src/multithreading/worker-adapter/worker-adapter.emit.test.ts @@ -8,6 +8,7 @@ import { Artifact, EventType, ExtractorEventType, + ItemInputType, LoaderEventType, } from '../../types'; import { ActionType, LoaderReport } from '../../types/loading'; @@ -240,6 +241,36 @@ describe(`${WorkerAdapter.name}.emit`, () => { expect(callData).not.toHaveProperty('processed_files'); }); + it('should include pre_extraction_item_counts passed on the metadata-done event', async () => { + // Arrange + const { emit: mockEmit } = require('../../common/control-protocol'); + adapter['adapterState'].postState = jest.fn().mockResolvedValue(undefined); + adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined); + + // Act + await adapter.emit(ExtractorEventType.MetadataExtractionDone, { + pre_extraction_item_counts: [ + { + record_type: 'tickets', + count: 0, + model_input_type: ItemInputType.MAIN, + }, + { + record_type: 'customers', + count: 1200, + model_input_type: ItemInputType.USERS, + }, + ], + }); + + // Assert + const callData = mockEmit.mock.calls[0][0].data; + expect(callData.pre_extraction_item_counts).toEqual([ + { record_type: 'tickets', count: 0, model_input_type: 'main' }, + { record_type: 'customers', count: 1200, model_input_type: 'users' }, + ]); + }); + it('should include artifacts for all ExtractorEventType values', async () => { // Arrange const { emit: mockEmit } = require('../../common/control-protocol'); diff --git a/src/types/extraction.ts b/src/types/extraction.ts index 859dff8f..c5ab4e2d 100644 --- a/src/types/extraction.ts +++ b/src/types/extraction.ts @@ -387,6 +387,23 @@ export interface ConnectionData { key_type: string; } +/** + * ItemInputType is the sync-duration-estimation model input a counted record type feeds into. + */ +export enum ItemInputType { + MAIN = 'main', + USERS = 'users', +} + +/** + * ItemTypeCount is a per-record-type count reported during the metadata phase, used for sync-duration estimation. + */ +export interface ItemTypeCount { + record_type: string; + count: number; + model_input_type: ItemInputType; +} + /** * EventData is an interface that defines the structure of the event data that is sent from the external extractor to ADaaS. */ @@ -412,6 +429,8 @@ export interface EventData { reports?: LoaderReport[]; processed_files?: string[]; stats_file?: string; + // Optional per-record-type counts reported on the metadata-done event, used for sync-duration estimation. + pre_extraction_item_counts?: ItemTypeCount[]; } /** diff --git a/src/types/index.ts b/src/types/index.ts index f49ef309..26d48405 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -30,6 +30,8 @@ export { ExtractorEvent, ExtractorEventType, InitialSyncScope, + ItemInputType, + ItemTypeCount, ProcessAttachmentReturnType, TimeUnit, TimeValue, From 338684a24d51ce135e64b507a6c4dfb8f99e7af4 Mon Sep 17 00:00:00 2001 From: svc-devrev-sdk Date: Mon, 10 Aug 2026 07:26:32 +0000 Subject: [PATCH 2/2] chore: release v1.20.2-beta.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 300ee9a9..6f0798a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devrev/ts-adaas", - "version": "1.20.1", + "version": "1.20.2-beta.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devrev/ts-adaas", - "version": "1.20.1", + "version": "1.20.2-beta.0", "license": "ISC", "dependencies": { "@devrev/typescript-sdk": "^1.1.78", diff --git a/package.json b/package.json index 8d03e228..7a5767f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devrev/ts-adaas", - "version": "1.20.1", + "version": "1.20.2-beta.0", "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.", "type": "commonjs", "main": "./dist/index.js",