import type { AuditEventId, AuditEventIdEncoded } from '../ids/index.js'; import type { ObjectEmpty, POJO } from '../types.js'; import type { nodeConnectionInboundMetricPath, nodeConnectionReverseTopicPath, nodeConnectionOutboundMetricPath, nodeConnectionForwardTopicPath, discoveryVertexQueuedTopicPath, discoveryVertexProcessedTopicPath, discoveryVertexFailedTopicPath, discoveryVertexCulledTopicPath, discoveryVertexCancelledTopicPath, discoveryCheckRediscoveryTopicPath, nodeConnectionMetricPath, topicPaths, metricPaths } from './utils.js'; import type { VertexEventError, VertexEventIdentifier } from '../discovery/types.js'; type IsSubpath = U extends readonly [...T, ...infer _] ? true : false; type InferTypeFromSubpath = IsSubpath extends true ? E : never; type InferAuditEventFromSubpath

= InferTypeFromSubpath; /** * Represents a capture of an event. */ type AuditEventBase = { id: AuditEventId; path: P; data: T; }; /** * Represents a capture of an event. */ type AuditEvent = TopicSubPathToAuditEvent; /** * Represents a capture of an event stored in the database. */ type AuditEventDB = AuditEventToAuditEventDB; /** * Represents a capture of an event for transmission over network. */ type AuditEventSerialized = AuditEventToAuditEventSerialized; type AuditEventToAuditEventDB = Omit; type AuditEventToAuditEventSerialized = Omit & { id: AuditEventIdEncoded; }; /** * Equivalent to `Array` but restricted to the available paths in `topicPaths`. */ type TopicPath = (typeof topicPaths)[number]; type TopicSubPath = (T extends readonly [...infer Head, infer Tail] ? [...Head, Tail] | TopicSubPath : []) | TopicPath; type TopicSubPathToAuditEvent = InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath | InferAuditEventFromSubpath; type AuditEventNodeConnectionBase = AuditEventBase<{ remoteNodeId: string; remoteHost: string; remotePort: number; }>; type AuditEventNodeConnection = AuditEventNodeConnectionReverse | AuditEventNodeConnectionForward; type AuditEventNodeConnectionReverse = AuditEventNodeConnectionBase & AuditEventBase<{ type: 'reverse'; }, typeof nodeConnectionReverseTopicPath>; type AuditEventNodeConnectionForward = AuditEventNodeConnectionBase & AuditEventBase<{ type: 'forward'; }, typeof nodeConnectionForwardTopicPath>; type AuditEventDiscovery = AuditEventDiscoveryVertex | AuditEventDiscoveryCheckRediscovery; type AuditEventDiscoveryVertex = AuditEventDiscoveryVertexQueued | AuditEventDiscoveryVertexProcessed | AuditEventDiscoveryVertexFailed | AuditEventDiscoveryVertexCulled | AuditEventDiscoveryVertexCancelled; type AuditEventDiscoveryVertexQueued = AuditEventBase; type AuditEventDiscoveryVertexProcessed = AuditEventBase; type AuditEventDiscoveryVertexFailed = AuditEventBase; type AuditEventDiscoveryVertexCulled = AuditEventBase; type AuditEventDiscoveryVertexCancelled = AuditEventBase; type AuditEventDiscoveryCheckRediscovery = AuditEventBase; type TopicPathTreeNode = Record; type MetricPath = (typeof metricPaths)[number]; type MetricPathToAuditMetric = T extends typeof nodeConnectionMetricPath | typeof nodeConnectionInboundMetricPath | typeof nodeConnectionOutboundMetricPath ? AuditMetricNodeConnection : never; type AuditMetric = AuditMetricNodeConnection; /** * Represents a capture of an event. */ type AuditMetricBase = { data: T; }; type AuditMetricNodeConnection = AuditMetricBase<{ total: number; averagePerMinute: number; averagePerHour: number; averagePerDay: number; }>; export type { IsSubpath, InferTypeFromSubpath, InferAuditEventFromSubpath, AuditEventBase, AuditEvent, AuditEventDB, AuditEventToAuditEventDB, AuditEventSerialized, AuditEventToAuditEventSerialized, TopicPath, TopicSubPathToAuditEvent, TopicSubPath, AuditEventNodeConnectionBase, AuditEventNodeConnection, AuditEventNodeConnectionReverse, AuditEventNodeConnectionForward, AuditEventDiscovery, AuditEventDiscoveryVertex, AuditEventDiscoveryVertexQueued, AuditEventDiscoveryVertexProcessed, AuditEventDiscoveryVertexFailed, AuditEventDiscoveryVertexCulled, AuditEventDiscoveryVertexCancelled, AuditEventDiscoveryCheckRediscovery, TopicPathTreeNode, MetricPath, MetricPathToAuditMetric, AuditMetric, AuditMetricBase, AuditMetricNodeConnection, };