feat: import
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -22,6 +22,8 @@ import type {
|
||||
EntityDeltaResponse,
|
||||
EntityMoveRequest,
|
||||
EntityMoveResponse,
|
||||
EntityImportRequest,
|
||||
EntityImportResponse,
|
||||
EntityInterface,
|
||||
} from '../types/entity';
|
||||
import { useIntegrationStore } from '@KTXC/stores/integrationStore';
|
||||
@@ -139,6 +141,28 @@ export const entityService = {
|
||||
return await transceivePost<EntityMoveRequest, EntityMoveResponse>('entity.move', request);
|
||||
},
|
||||
|
||||
/**
|
||||
* Import vCards into a collection, streaming progress as it arrives.
|
||||
*
|
||||
* @param request - import request (target collection, raw data, options)
|
||||
* @param onObject - called synchronously for each per-contact result frame
|
||||
* @param onDiscovered - called once with the discovered total (progress denominator)
|
||||
*
|
||||
* @returns Promise resolving to { total } (objects processed) when the stream completes
|
||||
*/
|
||||
async import(
|
||||
request: EntityImportRequest,
|
||||
onObject: (object: EntityImportResponse) => void,
|
||||
onDiscovered: (expected: number) => void,
|
||||
): Promise<{ total: number }> {
|
||||
return await transceiveStream<EntityImportRequest, EntityImportResponse>(
|
||||
'entity.import',
|
||||
request,
|
||||
onObject,
|
||||
{ onStart: (expected) => { if (expected !== undefined) onDiscovered(expected); } },
|
||||
);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default entityService;
|
||||
|
||||
Reference in New Issue
Block a user