/** Which catalog/role facet a consumer projects (D581). */ export type RoleCatalogProjection = "member_permissions" | "tenant_roles"; /** * Structural subset of @nodii/replica-consumer's `ReplicationEvent` — the fields * a role-catalog projection reads. A real `ReplicationEvent` (which has these + * more) is assignable to this, so `toRow` written against `RoleCatalogEvent` * accepts the live event verbatim. */ export interface RoleCatalogEvent { event_id: string; topic: string; aggregate_kind: string; aggregate_id: string; entity_version: number; payload: Record; } /** * Row UPSERTed into the consumer's replica table. Mirrors * @nodii/replica-consumer's `ReplicaRow`: the LWW version column is mandatory. */ export type RoleCatalogRow = Record & { source_entity_version: number; }; /** Input to defineRoleCatalogConsumer. */ export interface RoleCatalogConsumerSpec { /** Consuming service (e.g. `nodii-crm-service`). */ serviceName: string; /** Which facet this consumer projects (D581). */ projection: RoleCatalogProjection; /** Destination replica table. */ replicaTable: string; /** Primary-key columns of the replica table. */ primaryKey: string[]; /** Redis-Streams source stream (e.g. `tenant.user_membership`). */ sourceStream: string; /** Subscribed topics (e.g. `tenant.user_membership.updated.v1`). Non-empty. */ topics: string[]; /** Projection: event → replica row. */ toRow: (event: RoleCatalogEvent) => RoleCatalogRow | Promise; /** Accepted aggregate kinds. Defaults per projection when omitted. */ aggregateKinds?: string[]; /** Whether rows are tenant-scoped (drives db-rls downstream). Default true — * role/permission/seat projections are per-tenant. */ isPerTenantData?: boolean; } /** Resolved spec — field names mirror @nodii/replica-consumer's `ReplicaSpec`. */ export interface ResolvedRoleCatalogConsumerSpec { serviceName: string; projection: RoleCatalogProjection; replicaTable: string; primaryKey: string[]; sourceStream: string; topics: string[]; /** Resolved O(1) membership set of `topics`. */ topicSet: Set; toRow: (event: RoleCatalogEvent) => RoleCatalogRow | Promise; aggregateKinds: string[]; isPerTenantData: boolean; } /** * Validate + freeze a role-catalog consumer spec. Fail-loud on any malformed * field (mirrors @nodii/replica-consumer's `defineReplica`). Returns a resolved * spec ready to hand to `startReplicaConsumer`. */ export declare function defineRoleCatalogConsumer(spec: RoleCatalogConsumerSpec): ResolvedRoleCatalogConsumerSpec; //# sourceMappingURL=consumer.d.ts.map