import { EntityOperationType, RelationshipOperationType, BulkOperationType } from './persister-operation-types'; import { EntityAdditionalProperties } from './entity'; import { RelationshipAdditionalProperties } from './relationship'; import { RelationshipDirection, TargetEntityProperties, TargetFilterKey } from './mapper'; import { PersistedObjectSourceName } from './persisted-object'; import { IntegrationJobStatus } from './integration'; export declare type PersisterPayloadSourceName = PersistedObjectSourceName; export interface SourceInfoAdditionalProperties { /** * The persister will automatically copy properties from * `relationshipAdditionalProperties` into relationships * during the synchronization process. */ relationshipAdditionalProperties?: RelationshipAdditionalProperties; /** * The persister will automatically copy properties from * `entityAdditionalProperties` into entities * during the synchronization process. */ entityAdditionalProperties?: EntityAdditionalProperties; } export interface IntegrationSourceInfo extends SourceInfoAdditionalProperties { source: 'integration-managed' | 'integration-external'; /** * The non-unique `IntegrationInstance.name` provided by a user when they * configure an integration instance. The value will be transferred to entity * `_integrationName`. */ integrationName: string; /** * The unique `IntegrationDefinition.integrationType` used to identify data * created by the integration. The value will be transferred to entity * `_integrationType`. */ integrationType: string; /** * The `IntegrationDefinition.integrationClass` used to classify data created * by the integration. The value will be transferred to entity * `_integrationClass`. */ integrationClass: string[]; integrationInstanceId: string; integrationDefinitionId: string; } export interface PowerupSourceInfo extends SourceInfoAdditionalProperties { source: 'powerup-managed'; powerupName: string; } export interface ApiSourceInfo extends SourceInfoAdditionalProperties { source: 'api'; scope?: string; } export interface SystemInternalSourceInfo extends SourceInfoAdditionalProperties { source: 'system-internal'; scope?: string; } export declare type SourceInfoWithScope = ApiSourceInfo | SystemInternalSourceInfo; export interface SystemSourceInfo extends SourceInfoAdditionalProperties { source: 'system-mapper' | 'system-persister'; } export declare type SampleDataSourceInfo = SourceInfoAdditionalProperties & { source: 'sample-data'; scope?: string; }; export declare type SourceInfo = IntegrationSourceInfo | PowerupSourceInfo | ApiSourceInfo | SystemInternalSourceInfo | SourceInfoWithScope | SystemSourceInfo | SampleDataSourceInfo; /** * The source of the incoming payload. * * NOTE: This enum needs to stay synchronized with `PersisterPayloadSourceName` */ export declare enum PersisterPayloadSource { /** * from the system persister (for example, used when putting more * granular "delete relationship" operations on to work queue when * deleting entity) * * NOTE: Value needs to start with "system-" since we use this * for the `isSystemSource(source)` function. */ SYSTEM_PERSISTER = "system-persister", /** * from the system mapper * * NOTE: Value needs to start with "system-" since we use this * for the `isSystemSource(source)` function. */ SYSTEM_MAPPER = "system-mapper", /** * From an internal system that is not the mapper. For example, * `jupiter-integration-jupiterone`. * * NOTE: Value needs to start with "system-" since we use this * for the `isSystemSource(source)` function. */ SYSTEM_INTERNAL = "system-internal", /** * from a managed integration * * NOTE: Value needs to start with "integration-" since we use this * for the `isIntegrationSource(source)` function. */ INTEGRATION_MANAGED = "integration-managed", /** * from an external integration (a integration not managed by JupiterOne) * * NOTE: Value needs to start with "integration-" since we use this * for the `isIntegrationSource(source)` function. */ INTEGRATION_EXTERNAL = "integration-external", /** * from the public-facing API */ API = "api", /** * from managed powerups * * NOTE: Value needs to start with "powerup-" since we use this * for the `isPowerupSource(source)` function. */ POWERUP_MANAGED = "powerup-managed", /** * from sample data (graph objects generated from the sample-data project) * * NOTE: graph objects that are pulled with this source will maintain their * original source values. */ SAMPLE_DATA = "sample-data" } export declare namespace PersisterPayloadSource { function isSystemSource(source: PersisterPayloadSourceName): boolean; function isIntegrationSource(source: PersisterPayloadSourceName): boolean; function isPowerupSource(source: PersisterPayloadSourceName): boolean; function isAPISource(source: PersisterPayloadSourceName): boolean; } /** * `DeleteIntegrationOperation` is a bulk operation that is used * to handle bulk deleting entities and relationships when an * integration is deleted. */ export interface DeleteIntegrationOperation { type: BulkOperationType.DELETE_INTEGRATION; integrationInstanceId: string; timestamp: number; } export interface EndJobOperation { type: BulkOperationType.END_JOB; timestamp: number; integrationJobId: string; status: IntegrationJobStatus.COMPLETED | IntegrationJobStatus.FAILED; } /** * `BulkOperation` type is used by operations that perform bulk operations. */ export declare type BulkOperation = DeleteIntegrationOperation | EndJobOperation; export interface CreateEntityOperation { type: EntityOperationType.CREATE_ENTITY; entityKey: string; entityType: string; entityClass?: string | string[]; rawDataTempUris?: string[]; rawDataHashes?: string; timestamp: number; properties?: EntityAdditionalProperties; } export interface UpdateEntityOperation { type: EntityOperationType.UPDATE_ENTITY; entityId: string; entityKey?: string; entitySource?: string; entityType?: string; entityClass?: string | string[]; entityPowerupName?: string; entityScope?: string; rawDataTempUris?: string[]; rawDataHashes?: string; timestamp: number; properties?: EntityAdditionalProperties; onlyAlertPropertiesChanged?: boolean; } export interface DeleteEntityOperation { type: EntityOperationType.DELETE_ENTITY; entityId: string; timestamp: number; hardDelete?: boolean; integrationDeleted?: boolean; } export interface FinalizeDeleteEntityOperation { type: EntityOperationType.FINALIZE_DELETE_ENTITY; entityId: string; timestamp: number; integrationDeleted: boolean; purgingOldData: boolean; } export interface RemapEntityOperation { type: EntityOperationType.REMAP_ENTITY; entityId: string; timestamp: number; } /** * The `EntityOperation` type is a union of all operations related * to entities. */ export declare type EntityOperation = CreateEntityOperation | UpdateEntityOperation | DeleteEntityOperation | FinalizeDeleteEntityOperation | RemapEntityOperation; export interface CreateRelationshipOperation { type: RelationshipOperationType.CREATE_RELATIONSHIP; relationshipKey: string; relationshipType: string; relationshipClass?: string; timestamp: number; properties?: RelationshipAdditionalProperties; /** * The unique key of the "from" entity in the scope of a integration * instance. * * `fromEntityKey` is required if source of operation is a integration * and it should be undefined if source is not a integration. */ fromEntityKey?: string; /** * The unique key of the "to" entity in the scope of a integration * instance. * * `toEntityKey` is required if source of operation is a integration * and it should be undefined if source is not a integration. */ toEntityKey?: string; /** * NOTE: The `fromEntityId` is only allowed if source of operation is not * a integration (e.g. "system-mapper"). Integrations must use `fromEntityKey`. */ fromEntityId?: string; /** * NOTE: The `toEntityId` is only allowed if source of operation is not * a integration (e.g. "system-mapper"). Integrations must use `toEntityKey`. */ toEntityId?: string; } export interface CreateMappedRelationshipOperation { type: RelationshipOperationType.CREATE_MAPPED_RELATIONSHIP; mappingKey?: string; relationshipKey?: string; relationshipType: string; relationshipClass?: string; timestamp: number; relationshipProperties?: RelationshipAdditionalProperties; /** * The unique ID of the "source" entity in the scope of an account */ sourceEntityId?: string; /** * The unique key of the "source" entity in the scope of a integration * instance or Powerup. */ sourceEntityKey?: string; /** * Relationship direction. * `FORWARD` is from source to target. * `REVERSE` is from target to source. */ relationshipDirection: RelationshipDirection; /** * The keys that we can use to try to find the target entity. * * Example `targetFilterKeys`: * ```javascript * [['_class','cidr']] * ``` */ targetFilterKeys: TargetFilterKey[]; /** * The properties that this mapping will contribute to the * target mapped entity. If the target entity needs to be * created then it will have these properties. If the target * entity already exists then these properties will be merged * into the existing target entity. */ targetEntity: TargetEntityProperties; /** * Should we skip creating the target entity if it doesn't exist? * The default for `skipTargetCreation` is `false` which means that, * by default, the target will automatically be created if it doesn't * exist. */ skipTargetCreation?: boolean; } export interface UpdateRelationshipOperation { type: RelationshipOperationType.UPDATE_RELATIONSHIP; relationshipId: string; relationshipKey?: string; relationshipSource?: string; relationshipType?: string; relationshipClass?: string; relationshipPowerupName?: string; relationshipScope?: string; timestamp: number; properties?: RelationshipAdditionalProperties; } export interface DeleteRelationshipOperation { type: RelationshipOperationType.DELETE_RELATIONSHIP; timestamp: number; relationshipId: string; hardDelete?: boolean; integrationDeleted?: boolean; purgingOldData?: boolean; } /** * The `RelationshipOperation` type is a union of all operations related * to relationships. */ export declare type RelationshipOperation = CreateRelationshipOperation | CreateMappedRelationshipOperation | UpdateRelationshipOperation | DeleteRelationshipOperation; /** * The `PersisterPayload` type is describes the data schema that is used to * send updates from a integration or mapper to the persister. */ export interface PersisterPayload { /** * The source of the payload * ("system-mapper", "api", "integration-managed", etc.) */ source: PersisterPayloadSourceName; /** * Each payload contains operations for a single account * so we need to use the `accountId`. The `accountId` should * also be used as the partition key when sending this payload * via the persister's incoming Kinesis stream. */ accountId: string; /** * The `entityOperations` property contains all of the entity * operations associated with this payload. * * NOTE: The persister handles all entity operations * before handling relationship operations. */ entityOperations: EntityOperation[]; /** * The `relationshipOperations` property contains all of the relationship * operations associated with this payload. * * NOTE: The persister handles all entity operations * before handling relationship operations. */ relationshipOperations: RelationshipOperation[]; /** * Bulk operations are operations that affect entities and relationships. * Example bulk operations are "delete_account" and "delete_integration". */ bulkOperations?: BulkOperation[]; } /** * The `PersisterPayloadFromIntegration` type describes the data schema for * messages sent from a integration to the persister. * When getting updates from a integration, we assume that all operations * are scoped to a single integration instance and account. */ export declare type PersisterPayloadFromIntegration = PersisterPayload & IntegrationSourceInfo; /** * The `PersisterPayloadFromIntegration` type describes the data schema for * messages sent from a system service to the persister. * System services have the ability to create entities/relationships * that are not associated with a integration instance. Relationships * created by the system can also span entities that were created from * different integrations. */ export declare type PersisterPayloadFromSystem = PersisterPayload & SystemSourceInfo; /** * The `PersisterPayloadFromPowerup` type describes the data schema for * messages sent from a system service to the persister. * System services have the ability to create entities/relationships * that are not associated with a integration instance. Relationships * created by the system can also span entities that were created from * different integrations. */ export declare type PersisterPayloadFromPowerup = PersisterPayload & PowerupSourceInfo; /** * The `PersisterPayloadFromApi` type describes the data schema for * messages sent from the jupiter-integration-service to the persister. * Messages sent from the jupiter-integration-service (api) are currently * limited to be bulk delete operations, that delete all assets related to * a given integrationInstanceId. */ export declare type PersisterPayloadFromApi = PersisterPayload & ApiSourceInfo; /** * The `PersisterPayloadFromSystemInternal` type describes the data schema for * messages sent from the internal system sources (e.g. `jupiter-integration-jupiterone`) * to the persister. */ export declare type PersisterPayloadFromSystemInternal = PersisterPayload & SystemInternalSourceInfo;