import { EndJobOperation, EntityOperation, IntegrationDefinition, IntegrationInstance, PersisterPayloadFromIntegration, RelationshipOperation } from './../jupiter-types'; import { IntegrationLogger } from '../integration/types'; import { EntityFromIntegration, IntegrationRelationship, PersisterBackend, PersisterOperations, PersisterOperationsResult, RawDataUploader } from './types'; export declare type PersisterClientConfig = { logger: IntegrationLogger; definition: IntegrationDefinition; instance: IntegrationInstance; accountId: string; timestamp: number; persisterBackend: PersisterBackend; rawDataUploader: RawDataUploader; }; /** * Provides an interface to the J1 persister subsystem, which is responsible for * executing `PersisterOperations` against the graph. */ export interface PersisterClient { /** * Calculate persister operations based on differences between the existing * graph entities and new data from the provider. * * This will enqueue `_rawData` for upload, remove it from the entities and * add the collection of `_rawDataTempUris` to which the uploads are * delivered. There is a pqueue used for the uploads so that this operation * does no I/O itself. `publishEntityOperations` will block to wait for the * uploads to complete before it will send operations to the persister, to * ensure that the persister is able to process valid `_rawDataTempUris`. * * @param oldEntities entities with properties currently stored in the graph * @param newEntities entities with properties and `_rawData` from the * provider */ processEntities: (options: { oldEntities: T[]; newEntities: T[]; patch?: boolean; eventProperties?: string[]; }) => EntityOperation[]; /** * Calculate persister operations based on differences between the existing * graph relationships and new data from the provider. * * @param oldRelationships relationships with properties currently stored in * the graph * @param newRelationships relationships with properties from the provider */ processRelationships: (options: { oldRelationships: T[]; newRelationships: T[]; patch?: boolean; eventProperties?: string[]; }) => RelationshipOperation[]; /** * Publish entity and relationship operations. Entity operations are published * first, then relationship operations so that entities are processed by the * persister before relationships. * * Some integrations will produce entities and relationships. This convenience * API makes that easy. Consider using other `publish*` functions when that * will make code clearer. * * Enqueued entity `_rawData` uploads will be waited upon, then operations * delivered to the persister, so that when the persister receives the * operations, the data will be found in the `_rawDataTempUris`. */ publishPersisterOperations: (...operations: PersisterOperations[]) => Promise; /** * Publish relationship operations. It is important to * `publishEntityOperations` before sending relationships that reference those * entities. * * @param operations `RelationshipOperation[]` */ publishRelationshipOperations: (operations: RelationshipOperation[]) => Promise; /** * Publish entity operations. * * Enqueued entity `_rawData` uploads will be waited upon, then operations * delivered to the persister, so that when the persister receives the * operations, the data will be found in the `_rawDataTempUris`. * * @param operations `EntityOperation[]` */ publishEntityOperations: (operations: EntityOperation[]) => Promise; /** * Publish an operation marking the end of the job. */ publishEndJob: (integrationJobId: string, status: EndJobOperation['status']) => Promise; } export declare class StandardPersisterClient implements PersisterClient { readonly config: PersisterClientConfig; readonly persisterPayloadBase: PersisterPayloadFromIntegration; readonly persisterBackend: PersisterBackend; readonly rawDataUploader: RawDataUploader; constructor(config: PersisterClientConfig); processEntities({ oldEntities, newEntities, patch, eventProperties, }: { oldEntities: T[]; newEntities: T[]; patch?: boolean; eventProperties?: string[]; }): EntityOperation[]; processRelationships({ oldRelationships, newRelationships, patch, eventProperties, }: { oldRelationships: T[]; newRelationships: T[]; patch?: boolean; eventProperties?: string[]; }): RelationshipOperation[]; publishPersisterOperations(...operations: PersisterOperations[]): Promise; publishRelationshipOperations(operations: RelationshipOperation[]): Promise; publishEntityOperations(operations: EntityOperation[]): Promise; publishEndJob(integrationJobId: string, status: EndJobOperation['status']): Promise; private buildPersisterPayloadForEntityOperations; private buildPersisterPayloadForRelationshipOperations; private publishPayload; } export declare function serializePayload(payload: PersisterPayloadFromIntegration): Record;