import { NeptuneClient } from './../../platform-sdk-neptune'; import { EntityAssignable, EntityOperation, PersistedObjectAssignable, PersisterPayloadFromIntegration, RelationshipAssignable, RelationshipDirection, RelationshipOperation, TargetEntityProperties, TargetFilterKey } from './../../jupiter-types'; import { IntegrationLogger } from '../../integration/types'; /** * Delivers a set of PersisterOperations to a Persister. */ export interface PersisterBackend { publishPayload: (payload: PersisterPayloadFromIntegration) => Promise; } export interface PersisterBackendFactory { (neptuneClient: NeptuneClient, logger: IntegrationLogger): PersisterBackend; } /** * A collection of entity and relationship operations used to build a * PersisterPayload. */ export declare type PersisterOperations = [EntityOperation[], RelationshipOperation[]]; /** * Represents the counts of operations produced to synchronize provider data * with J1. */ export interface PersisterOperationsResult { created: number; updated: number; deleted: number; } /** * This interface only includes `_id` and it is not intended to be used * outside this file but we have to export "intermediate" types. */ export interface Identifiable { /** * Id that the persister assigns to an entity/relationship that is stable * across multiple versions. * * The `_id` field is optional so that is possible to initialize a * `PersistedObject` without an `_id` before sending it to the persister * to be saved to the database. */ readonly _id?: string; } /** * Properties used to track raw data associated with entities. */ export interface RawDataTracking { /** * Maintains references to a collection of raw data uploads accumulated during * the construction of an entity. * * This data will not be included in any operations delivered to the persister. * Each input is placed in a queue by the `RawDataUploader` for upload to * temporary storage and the associated storage URI is added to * `_rawDataTempUris`. */ _rawData?: RawUploadJobInput[]; /** * Raw data temporary storage URIs produced during the registration of uploads * accumulated in `_rawData`. * * These URIs will be included in operations delivered to the persister. The * persister will move the data to permanent storage. * */ _rawDataTempUris?: string[]; _rawDataHashes?: string; } /** * Provides a service for uploading raw data obtained from an integration data * provider source, in order to facilitate certain features of J1 which provide * visibility into what is ingested over time. */ export interface RawDataUploader { /** * Adds an upload job to the queue, returning the location the data will be * stored. Use `onUploadJobsCompleted()` to await completion of all enqueued * upload jobs. */ addUploadJob: (rawInput: RawUploadJobInput) => string; /** * Returns a Promise that resolves when all enqueued upload jobs have * completed. */ onUploadJobsCompleted: () => Promise; } /** * `RawDataUploader` upload job input. */ export declare type RawUploadJobInput = { /** * A name that identifies the payload when there are multiple data sources * used to build an entity. * * This name is part of a permanent key associated with the data. It must be * unique within the context of the entity. `'default'` is an acceptable value * when there is only one data payload, though it is recommended to use names * that are more meaningful when there is more than one. * * For example, consider an AWS IAM Role entity, where the role has an * embedded policy obtained through a separate API call: * * ``` * [ * { name: 'role', ... }, * { name: 'policy', ... } * ] * ``` */ name: string; /** * Any type of data representing the source content used to build an entity. */ rawData: any; }; /** * An entity managed by an integration. */ export declare type EntityFromIntegration = Identifiable & PersistedObjectAssignable & EntityAssignable & RawDataTracking; export interface RelationshipToFromEntity { /** * The key of the entity that the edge is directed from. */ _fromEntityKey: string; /** * The key of the entity that the edge is directed toward. */ _toEntityKey: string; } /** * A relationship between two entities, created by an integration. * * Integrations create instances of `RelationshipFromIntegration` or * `MappedRelationshipFromIntegration`. */ export declare type IntegrationRelationship = Identifiable & PersistedObjectAssignable & RelationshipAssignable; /** * A relationship between two entities known to be managed by the integration. * See also `MappedRelationshipFromIntegration`. */ export declare type RelationshipFromIntegration = IntegrationRelationship & RelationshipToFromEntity; /** * A relationship between an entity managed by the integration, and an entity * that may be managed by a different integration or may not be known to any * integration. */ export interface MappedRelationshipFromIntegration extends IntegrationRelationship { /** * Metadata providing properties for finding or creating the other side of the * relationship. * * The `_mapping` indicates the desire to have the downstream mapper create a * relationship to entities that already exist, or when no matching entities * are found, the mapper will create one using the `targetEntity` properties. * When the mapper owns the target entity, because it created it for one * integration or another, it will update the entity with properties known by * this integration. */ _mapping: RelationshipMapping; } /** * Metadata assigned to a `MappedRelationshipFromIntegration._mapping`. */ export interface RelationshipMapping { /** * The relationship direction, `source - FORWARD -> target` or * `source <- REVERSE - target`. */ relationshipDirection: RelationshipDirection; /** * The `_key` value of the entity managed by the integration, to which * relationships will be created. * * "Source" implies that the graph vertex will have an outgoing edge. However, * that is not necessarily the case. See `relationshipDirection`. */ sourceEntityKey: string; /** * Identifies properties in the `targetEntity` that are used to locate the * entites to connect to the `sourceEntityKey`. For example, if you know that * you want to build a relationship to user entities with a known email, this * can be expressed by: * * ```js * { * targetFilterKeys: [['_class', 'email']], * targetEntity: { * _class: 'User', * email: 'person@example.com', * firstName: 'Person', * lastName: 'Example' * } * } */ targetFilterKeys: TargetFilterKey[]; /** * Properties of the target entity known to the integration building the * relationship. * * The property values of the `targetFilterKeys` are used to find the target * entities. When the mapper manages the target entity (it created the entity, * no other integration owns it), it will update the entity to store these * properties. This allows a number of integrations to contribute data to * "fill out" knowledge of the entity. */ targetEntity: TargetEntityProperties; /** * By default, an entity will be created by the mapper when no matching * entities are found. * * When a relationship is not meaningful unless target entities already exist, * `skipTargetCreation: true` will inform the mapper that the entity should * not be created. */ skipTargetCreation?: boolean; }