// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.12.4 // protoc v5.28.3 // source: observation_reducers.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import type { CallContext, CallOptions } from "nice-grpc-common"; import { Guid } from "./protobuf-net/bcl"; export const protobufPackage = "Cratis.Chronicle.Contracts.Observation.Reducers"; export enum EventObservationState { EVENT_OBSERVATION_STATE_None = 0, Initial = 1, Replay = 2, UNRECOGNIZED = -1, } export function eventObservationStateFromJSON(object: any): EventObservationState { switch (object) { case 0: case "EVENT_OBSERVATION_STATE_None": return EventObservationState.EVENT_OBSERVATION_STATE_None; case 1: case "Initial": return EventObservationState.Initial; case 2: case "Replay": return EventObservationState.Replay; case -1: case "UNRECOGNIZED": default: return EventObservationState.UNRECOGNIZED; } } export function eventObservationStateToJSON(object: EventObservationState): string { switch (object) { case EventObservationState.EVENT_OBSERVATION_STATE_None: return "EVENT_OBSERVATION_STATE_None"; case EventObservationState.Initial: return "Initial"; case EventObservationState.Replay: return "Replay"; case EventObservationState.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } export enum ObservationState { OBSERVATION_STATE_None = 0, Success = 1, Failed = 2, UNRECOGNIZED = -1, } export function observationStateFromJSON(object: any): ObservationState { switch (object) { case 0: case "OBSERVATION_STATE_None": return ObservationState.OBSERVATION_STATE_None; case 1: case "Success": return ObservationState.Success; case 2: case "Failed": return ObservationState.Failed; case -1: case "UNRECOGNIZED": default: return ObservationState.UNRECOGNIZED; } } export function observationStateToJSON(object: ObservationState): string { switch (object) { case ObservationState.OBSERVATION_STATE_None: return "OBSERVATION_STATE_None"; case ObservationState.Success: return "Success"; case ObservationState.Failed: return "Failed"; case ObservationState.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } export enum ReplayState { REPLAY_STATE_None = 0, BeginReplay = 1, EndReplay = 2, BeginReplayPartition = 3, EndReplayPartition = 4, UNRECOGNIZED = -1, } export function replayStateFromJSON(object: any): ReplayState { switch (object) { case 0: case "REPLAY_STATE_None": return ReplayState.REPLAY_STATE_None; case 1: case "BeginReplay": return ReplayState.BeginReplay; case 2: case "EndReplay": return ReplayState.EndReplay; case 3: case "BeginReplayPartition": return ReplayState.BeginReplayPartition; case 4: case "EndReplayPartition": return ReplayState.EndReplayPartition; case -1: case "UNRECOGNIZED": default: return ReplayState.UNRECOGNIZED; } } export function replayStateToJSON(object: ReplayState): string { switch (object) { case ReplayState.REPLAY_STATE_None: return "REPLAY_STATE_None"; case ReplayState.BeginReplay: return "BeginReplay"; case ReplayState.EndReplay: return "EndReplay"; case ReplayState.BeginReplayPartition: return "BeginReplayPartition"; case ReplayState.EndReplayPartition: return "EndReplayPartition"; case ReplayState.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } export interface AppendedEvent { Context: EventContext | undefined; Content: string; OriginalContent: string; Revisions: EventRevision[]; GenerationalContent: { [key: number]: string }; } export interface AppendedEvent_GenerationalContentEntry { key: number; value: string; } export interface Causation { Occurred: SerializableDateTimeOffset | undefined; Type: string; Properties: { [key: string]: string }; } export interface Causation_PropertiesEntry { key: string; value: string; } export interface EventContext { EventType: EventType | undefined; EventSourceType: string; EventSourceId: string; SequenceNumber: bigint; EventStreamType: string; EventStreamId: string; Occurred: SerializableDateTimeOffset | undefined; EventStore: string; Namespace: string; /** default value could not be applied: 00000000-0000-0000-0000-000000000000 */ CorrelationId: Guid | undefined; Causation: Causation[]; CausedBy: Identity | undefined; ObservationState: EventObservationState; Tags: string[]; Hash: string; Subject: string; } export interface EventRevision { Generation: number; CorrelationId: string; CausedBy: Identity | undefined; Occurred: SerializableDateTimeOffset | undefined; Content: string; } export interface EventType { Id: string; Generation: number; Tombstone: boolean; } export interface EventTypeWithKeyExpression { EventType: EventType | undefined; Key: string; } export interface Identity { Subject: string; Name: string; UserName: string; OnBehalfOf: Identity | undefined; } export interface ObserverFilters { FilterTags: string[]; EventSourceType: string; /** default value could not be applied: All */ EventStreamType: string; } export interface OneOfRegisterReducerReducerResult { Value0: RegisterReducer | undefined; Value1: ReducerResult | undefined; } export interface ReduceOperationMessage { Partition: string; InitialState: string; Events: AppendedEvent[]; ReplayState: ReplayState; } export interface ReducerDefinition { ReducerId: string; EventSequenceId: string; EventTypes: EventTypeWithKeyExpression[]; ReadModel: string; IsActive: boolean; Tags: string[]; Filters: ObserverFilters | undefined; Hash: string; } export interface ReducerMessage { Content: OneOfRegisterReducerReducerResult | undefined; } export interface ReducerResult { Partition: string; State: ObservationState; LastSuccessfulObservation: bigint; ExceptionMessages: string[]; ExceptionStackTrace: string; ReadModelState: string; } export interface RegisterReducer { ConnectionId: string; EventStore: string; Namespace: string; Reducer: ReducerDefinition | undefined; } /** Represents a DateTimeOffset value as an ISO 8601 string (e.g., "2024-01-15T12:30:00.0000000+02:00"). */ export interface SerializableDateTimeOffset { Value: string; } function createBaseAppendedEvent(): AppendedEvent { return { Context: undefined, Content: "", OriginalContent: "", Revisions: [], GenerationalContent: {} }; } export const AppendedEvent: MessageFns = { encode(message: AppendedEvent, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Context !== undefined) { EventContext.encode(message.Context, writer.uint32(10).fork()).join(); } if (message.Content !== "") { writer.uint32(18).string(message.Content); } if (message.OriginalContent !== "") { writer.uint32(26).string(message.OriginalContent); } for (const v of message.Revisions) { EventRevision.encode(v!, writer.uint32(34).fork()).join(); } globalThis.Object.entries(message.GenerationalContent).forEach(([key, value]: [string, string]) => { AppendedEvent_GenerationalContentEntry.encode({ key: key as any, value }, writer.uint32(42).fork()).join(); }); return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): AppendedEvent { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAppendedEvent(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Context = EventContext.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.Content = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.OriginalContent = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.Revisions.push(EventRevision.decode(reader, reader.uint32())); continue; } case 5: { if (tag !== 42) { break; } const entry5 = AppendedEvent_GenerationalContentEntry.decode(reader, reader.uint32()); if (entry5.value !== undefined) { message.GenerationalContent[entry5.key] = entry5.value; } continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): AppendedEvent { return { Context: isSet(object.Context) ? EventContext.fromJSON(object.Context) : undefined, Content: isSet(object.Content) ? globalThis.String(object.Content) : "", OriginalContent: isSet(object.OriginalContent) ? globalThis.String(object.OriginalContent) : "", Revisions: globalThis.Array.isArray(object?.Revisions) ? object.Revisions.map((e: any) => EventRevision.fromJSON(e)) : [], GenerationalContent: isObject(object.GenerationalContent) ? (globalThis.Object.entries(object.GenerationalContent) as [string, any][]).reduce( (acc: { [key: number]: string }, [key, value]: [string, any]) => { globalThis.Object.defineProperty(acc, globalThis.Number(key), { value: globalThis.String(value), enumerable: true, configurable: true, writable: true, }); return acc; }, {}, ) : {}, }; }, toJSON(message: AppendedEvent): unknown { const obj: any = {}; if (message.Context !== undefined) { obj.Context = EventContext.toJSON(message.Context); } if (message.Content !== "") { obj.Content = message.Content; } if (message.OriginalContent !== "") { obj.OriginalContent = message.OriginalContent; } if (message.Revisions?.length) { obj.Revisions = message.Revisions.map((e) => EventRevision.toJSON(e)); } if (message.GenerationalContent) { const entries = globalThis.Object.entries(message.GenerationalContent) as [string, string][]; if (entries.length > 0) { obj.GenerationalContent = {}; entries.forEach(([k, v]) => { obj.GenerationalContent[k] = v; }); } } return obj; }, create(base?: DeepPartial): AppendedEvent { return AppendedEvent.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): AppendedEvent { const message = createBaseAppendedEvent(); message.Context = (object.Context !== undefined && object.Context !== null) ? EventContext.fromPartial(object.Context) : undefined; message.Content = object.Content ?? ""; message.OriginalContent = object.OriginalContent ?? ""; message.Revisions = object.Revisions?.map((e) => EventRevision.fromPartial(e)) || []; message.GenerationalContent = (globalThis.Object.entries(object.GenerationalContent ?? {}) as [string, string][]) .reduce((acc: { [key: number]: string }, [key, value]: [string, string]) => { if (value !== undefined) { acc[globalThis.Number(key)] = globalThis.String(value); } return acc; }, {}); return message; }, }; function createBaseAppendedEvent_GenerationalContentEntry(): AppendedEvent_GenerationalContentEntry { return { key: 0, value: "" }; } export const AppendedEvent_GenerationalContentEntry: MessageFns = { encode(message: AppendedEvent_GenerationalContentEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.key !== 0) { writer.uint32(8).int32(message.key); } if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): AppendedEvent_GenerationalContentEntry { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseAppendedEvent_GenerationalContentEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.key = reader.int32(); continue; } case 2: { if (tag !== 18) { break; } message.value = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): AppendedEvent_GenerationalContentEntry { return { key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? globalThis.String(object.value) : "", }; }, toJSON(message: AppendedEvent_GenerationalContentEntry): unknown { const obj: any = {}; if (message.key !== 0) { obj.key = Math.round(message.key); } if (message.value !== "") { obj.value = message.value; } return obj; }, create(base?: DeepPartial): AppendedEvent_GenerationalContentEntry { return AppendedEvent_GenerationalContentEntry.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): AppendedEvent_GenerationalContentEntry { const message = createBaseAppendedEvent_GenerationalContentEntry(); message.key = object.key ?? 0; message.value = object.value ?? ""; return message; }, }; function createBaseCausation(): Causation { return { Occurred: undefined, Type: "", Properties: {} }; } export const Causation: MessageFns = { encode(message: Causation, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Occurred !== undefined) { SerializableDateTimeOffset.encode(message.Occurred, writer.uint32(10).fork()).join(); } if (message.Type !== "") { writer.uint32(18).string(message.Type); } globalThis.Object.entries(message.Properties).forEach(([key, value]: [string, string]) => { Causation_PropertiesEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).join(); }); return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Causation { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCausation(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Occurred = SerializableDateTimeOffset.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.Type = reader.string(); continue; } case 3: { if (tag !== 26) { break; } const entry3 = Causation_PropertiesEntry.decode(reader, reader.uint32()); if (entry3.value !== undefined) { message.Properties[entry3.key] = entry3.value; } continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): Causation { return { Occurred: isSet(object.Occurred) ? SerializableDateTimeOffset.fromJSON(object.Occurred) : undefined, Type: isSet(object.Type) ? globalThis.String(object.Type) : "", Properties: isObject(object.Properties) ? (globalThis.Object.entries(object.Properties) as [string, any][]).reduce( (acc: { [key: string]: string }, [key, value]: [string, any]) => { globalThis.Object.defineProperty(acc, key, { value: globalThis.String(value), enumerable: true, configurable: true, writable: true, }); return acc; }, {}, ) : {}, }; }, toJSON(message: Causation): unknown { const obj: any = {}; if (message.Occurred !== undefined) { obj.Occurred = SerializableDateTimeOffset.toJSON(message.Occurred); } if (message.Type !== "") { obj.Type = message.Type; } if (message.Properties) { const entries = globalThis.Object.entries(message.Properties) as [string, string][]; if (entries.length > 0) { obj.Properties = {}; entries.forEach(([k, v]) => { obj.Properties[k] = v; }); } } return obj; }, create(base?: DeepPartial): Causation { return Causation.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Causation { const message = createBaseCausation(); message.Occurred = (object.Occurred !== undefined && object.Occurred !== null) ? SerializableDateTimeOffset.fromPartial(object.Occurred) : undefined; message.Type = object.Type ?? ""; message.Properties = (globalThis.Object.entries(object.Properties ?? {}) as [string, string][]).reduce( (acc: { [key: string]: string }, [key, value]: [string, string]) => { if (value !== undefined) { acc[key] = globalThis.String(value); } return acc; }, {}, ); return message; }, }; function createBaseCausation_PropertiesEntry(): Causation_PropertiesEntry { return { key: "", value: "" }; } export const Causation_PropertiesEntry: MessageFns = { encode(message: Causation_PropertiesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Causation_PropertiesEntry { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseCausation_PropertiesEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.key = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.value = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): Causation_PropertiesEntry { return { key: isSet(object.key) ? globalThis.String(object.key) : "", value: isSet(object.value) ? globalThis.String(object.value) : "", }; }, toJSON(message: Causation_PropertiesEntry): unknown { const obj: any = {}; if (message.key !== "") { obj.key = message.key; } if (message.value !== "") { obj.value = message.value; } return obj; }, create(base?: DeepPartial): Causation_PropertiesEntry { return Causation_PropertiesEntry.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Causation_PropertiesEntry { const message = createBaseCausation_PropertiesEntry(); message.key = object.key ?? ""; message.value = object.value ?? ""; return message; }, }; function createBaseEventContext(): EventContext { return { EventType: undefined, EventSourceType: "", EventSourceId: "", SequenceNumber: 0n, EventStreamType: "", EventStreamId: "", Occurred: undefined, EventStore: "", Namespace: "", CorrelationId: undefined, Causation: [], CausedBy: undefined, ObservationState: 0, Tags: [], Hash: "", Subject: "", }; } export const EventContext: MessageFns = { encode(message: EventContext, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventType !== undefined) { EventType.encode(message.EventType, writer.uint32(10).fork()).join(); } if (message.EventSourceType !== "") { writer.uint32(18).string(message.EventSourceType); } if (message.EventSourceId !== "") { writer.uint32(26).string(message.EventSourceId); } if (message.SequenceNumber !== 0n) { if (BigInt.asUintN(64, message.SequenceNumber) !== message.SequenceNumber) { throw new globalThis.Error("value provided for field message.SequenceNumber of type uint64 too large"); } writer.uint32(32).uint64(message.SequenceNumber); } if (message.EventStreamType !== "") { writer.uint32(42).string(message.EventStreamType); } if (message.EventStreamId !== "") { writer.uint32(50).string(message.EventStreamId); } if (message.Occurred !== undefined) { SerializableDateTimeOffset.encode(message.Occurred, writer.uint32(58).fork()).join(); } if (message.EventStore !== "") { writer.uint32(66).string(message.EventStore); } if (message.Namespace !== "") { writer.uint32(74).string(message.Namespace); } if (message.CorrelationId !== undefined) { Guid.encode(message.CorrelationId, writer.uint32(82).fork()).join(); } for (const v of message.Causation) { Causation.encode(v!, writer.uint32(90).fork()).join(); } if (message.CausedBy !== undefined) { Identity.encode(message.CausedBy, writer.uint32(98).fork()).join(); } if (message.ObservationState !== 0) { writer.uint32(104).int32(message.ObservationState); } for (const v of message.Tags) { writer.uint32(114).string(v!); } if (message.Hash !== "") { writer.uint32(122).string(message.Hash); } if (message.Subject !== "") { writer.uint32(130).string(message.Subject); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventContext { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEventContext(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventType = EventType.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.EventSourceType = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.EventSourceId = reader.string(); continue; } case 4: { if (tag !== 32) { break; } message.SequenceNumber = reader.uint64() as bigint; continue; } case 5: { if (tag !== 42) { break; } message.EventStreamType = reader.string(); continue; } case 6: { if (tag !== 50) { break; } message.EventStreamId = reader.string(); continue; } case 7: { if (tag !== 58) { break; } message.Occurred = SerializableDateTimeOffset.decode(reader, reader.uint32()); continue; } case 8: { if (tag !== 66) { break; } message.EventStore = reader.string(); continue; } case 9: { if (tag !== 74) { break; } message.Namespace = reader.string(); continue; } case 10: { if (tag !== 82) { break; } message.CorrelationId = Guid.decode(reader, reader.uint32()); continue; } case 11: { if (tag !== 90) { break; } message.Causation.push(Causation.decode(reader, reader.uint32())); continue; } case 12: { if (tag !== 98) { break; } message.CausedBy = Identity.decode(reader, reader.uint32()); continue; } case 13: { if (tag !== 104) { break; } message.ObservationState = reader.int32() as any; continue; } case 14: { if (tag !== 114) { break; } message.Tags.push(reader.string()); continue; } case 15: { if (tag !== 122) { break; } message.Hash = reader.string(); continue; } case 16: { if (tag !== 130) { break; } message.Subject = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): EventContext { return { EventType: isSet(object.EventType) ? EventType.fromJSON(object.EventType) : undefined, EventSourceType: isSet(object.EventSourceType) ? globalThis.String(object.EventSourceType) : "", EventSourceId: isSet(object.EventSourceId) ? globalThis.String(object.EventSourceId) : "", SequenceNumber: isSet(object.SequenceNumber) ? BigInt(object.SequenceNumber) : 0n, EventStreamType: isSet(object.EventStreamType) ? globalThis.String(object.EventStreamType) : "", EventStreamId: isSet(object.EventStreamId) ? globalThis.String(object.EventStreamId) : "", Occurred: isSet(object.Occurred) ? SerializableDateTimeOffset.fromJSON(object.Occurred) : undefined, EventStore: isSet(object.EventStore) ? globalThis.String(object.EventStore) : "", Namespace: isSet(object.Namespace) ? globalThis.String(object.Namespace) : "", CorrelationId: isSet(object.CorrelationId) ? Guid.fromJSON(object.CorrelationId) : undefined, Causation: globalThis.Array.isArray(object?.Causation) ? object.Causation.map((e: any) => Causation.fromJSON(e)) : [], CausedBy: isSet(object.CausedBy) ? Identity.fromJSON(object.CausedBy) : undefined, ObservationState: isSet(object.ObservationState) ? eventObservationStateFromJSON(object.ObservationState) : 0, Tags: globalThis.Array.isArray(object?.Tags) ? object.Tags.map((e: any) => globalThis.String(e)) : [], Hash: isSet(object.Hash) ? globalThis.String(object.Hash) : "", Subject: isSet(object.Subject) ? globalThis.String(object.Subject) : "", }; }, toJSON(message: EventContext): unknown { const obj: any = {}; if (message.EventType !== undefined) { obj.EventType = EventType.toJSON(message.EventType); } if (message.EventSourceType !== "") { obj.EventSourceType = message.EventSourceType; } if (message.EventSourceId !== "") { obj.EventSourceId = message.EventSourceId; } if (message.SequenceNumber !== 0n) { obj.SequenceNumber = message.SequenceNumber.toString(); } if (message.EventStreamType !== "") { obj.EventStreamType = message.EventStreamType; } if (message.EventStreamId !== "") { obj.EventStreamId = message.EventStreamId; } if (message.Occurred !== undefined) { obj.Occurred = SerializableDateTimeOffset.toJSON(message.Occurred); } if (message.EventStore !== "") { obj.EventStore = message.EventStore; } if (message.Namespace !== "") { obj.Namespace = message.Namespace; } if (message.CorrelationId !== undefined) { obj.CorrelationId = Guid.toJSON(message.CorrelationId); } if (message.Causation?.length) { obj.Causation = message.Causation.map((e) => Causation.toJSON(e)); } if (message.CausedBy !== undefined) { obj.CausedBy = Identity.toJSON(message.CausedBy); } if (message.ObservationState !== 0) { obj.ObservationState = eventObservationStateToJSON(message.ObservationState); } if (message.Tags?.length) { obj.Tags = message.Tags; } if (message.Hash !== "") { obj.Hash = message.Hash; } if (message.Subject !== "") { obj.Subject = message.Subject; } return obj; }, create(base?: DeepPartial): EventContext { return EventContext.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventContext { const message = createBaseEventContext(); message.EventType = (object.EventType !== undefined && object.EventType !== null) ? EventType.fromPartial(object.EventType) : undefined; message.EventSourceType = object.EventSourceType ?? ""; message.EventSourceId = object.EventSourceId ?? ""; message.SequenceNumber = (object.SequenceNumber !== undefined && object.SequenceNumber !== null) ? BigInt(object.SequenceNumber) : 0n; message.EventStreamType = object.EventStreamType ?? ""; message.EventStreamId = object.EventStreamId ?? ""; message.Occurred = (object.Occurred !== undefined && object.Occurred !== null) ? SerializableDateTimeOffset.fromPartial(object.Occurred) : undefined; message.EventStore = object.EventStore ?? ""; message.Namespace = object.Namespace ?? ""; message.CorrelationId = (object.CorrelationId !== undefined && object.CorrelationId !== null) ? Guid.fromPartial(object.CorrelationId) : undefined; message.Causation = object.Causation?.map((e) => Causation.fromPartial(e)) || []; message.CausedBy = (object.CausedBy !== undefined && object.CausedBy !== null) ? Identity.fromPartial(object.CausedBy) : undefined; message.ObservationState = object.ObservationState ?? 0; message.Tags = object.Tags?.map((e) => e) || []; message.Hash = object.Hash ?? ""; message.Subject = object.Subject ?? ""; return message; }, }; function createBaseEventRevision(): EventRevision { return { Generation: 0, CorrelationId: "", CausedBy: undefined, Occurred: undefined, Content: "" }; } export const EventRevision: MessageFns = { encode(message: EventRevision, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Generation !== 0) { writer.uint32(8).uint32(message.Generation); } if (message.CorrelationId !== "") { writer.uint32(18).string(message.CorrelationId); } if (message.CausedBy !== undefined) { Identity.encode(message.CausedBy, writer.uint32(26).fork()).join(); } if (message.Occurred !== undefined) { SerializableDateTimeOffset.encode(message.Occurred, writer.uint32(34).fork()).join(); } if (message.Content !== "") { writer.uint32(42).string(message.Content); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventRevision { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEventRevision(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.Generation = reader.uint32(); continue; } case 2: { if (tag !== 18) { break; } message.CorrelationId = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.CausedBy = Identity.decode(reader, reader.uint32()); continue; } case 4: { if (tag !== 34) { break; } message.Occurred = SerializableDateTimeOffset.decode(reader, reader.uint32()); continue; } case 5: { if (tag !== 42) { break; } message.Content = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): EventRevision { return { Generation: isSet(object.Generation) ? globalThis.Number(object.Generation) : 0, CorrelationId: isSet(object.CorrelationId) ? globalThis.String(object.CorrelationId) : "", CausedBy: isSet(object.CausedBy) ? Identity.fromJSON(object.CausedBy) : undefined, Occurred: isSet(object.Occurred) ? SerializableDateTimeOffset.fromJSON(object.Occurred) : undefined, Content: isSet(object.Content) ? globalThis.String(object.Content) : "", }; }, toJSON(message: EventRevision): unknown { const obj: any = {}; if (message.Generation !== 0) { obj.Generation = Math.round(message.Generation); } if (message.CorrelationId !== "") { obj.CorrelationId = message.CorrelationId; } if (message.CausedBy !== undefined) { obj.CausedBy = Identity.toJSON(message.CausedBy); } if (message.Occurred !== undefined) { obj.Occurred = SerializableDateTimeOffset.toJSON(message.Occurred); } if (message.Content !== "") { obj.Content = message.Content; } return obj; }, create(base?: DeepPartial): EventRevision { return EventRevision.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventRevision { const message = createBaseEventRevision(); message.Generation = object.Generation ?? 0; message.CorrelationId = object.CorrelationId ?? ""; message.CausedBy = (object.CausedBy !== undefined && object.CausedBy !== null) ? Identity.fromPartial(object.CausedBy) : undefined; message.Occurred = (object.Occurred !== undefined && object.Occurred !== null) ? SerializableDateTimeOffset.fromPartial(object.Occurred) : undefined; message.Content = object.Content ?? ""; return message; }, }; function createBaseEventType(): EventType { return { Id: "", Generation: 0, Tombstone: false }; } export const EventType: MessageFns = { encode(message: EventType, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Id !== "") { writer.uint32(10).string(message.Id); } if (message.Generation !== 0) { writer.uint32(16).uint32(message.Generation); } if (message.Tombstone !== false) { writer.uint32(24).bool(message.Tombstone); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventType { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEventType(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Id = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.Generation = reader.uint32(); continue; } case 3: { if (tag !== 24) { break; } message.Tombstone = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): EventType { return { Id: isSet(object.Id) ? globalThis.String(object.Id) : "", Generation: isSet(object.Generation) ? globalThis.Number(object.Generation) : 0, Tombstone: isSet(object.Tombstone) ? globalThis.Boolean(object.Tombstone) : false, }; }, toJSON(message: EventType): unknown { const obj: any = {}; if (message.Id !== "") { obj.Id = message.Id; } if (message.Generation !== 0) { obj.Generation = Math.round(message.Generation); } if (message.Tombstone !== false) { obj.Tombstone = message.Tombstone; } return obj; }, create(base?: DeepPartial): EventType { return EventType.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventType { const message = createBaseEventType(); message.Id = object.Id ?? ""; message.Generation = object.Generation ?? 0; message.Tombstone = object.Tombstone ?? false; return message; }, }; function createBaseEventTypeWithKeyExpression(): EventTypeWithKeyExpression { return { EventType: undefined, Key: "" }; } export const EventTypeWithKeyExpression: MessageFns = { encode(message: EventTypeWithKeyExpression, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventType !== undefined) { EventType.encode(message.EventType, writer.uint32(10).fork()).join(); } if (message.Key !== "") { writer.uint32(18).string(message.Key); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventTypeWithKeyExpression { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseEventTypeWithKeyExpression(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventType = EventType.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.Key = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): EventTypeWithKeyExpression { return { EventType: isSet(object.EventType) ? EventType.fromJSON(object.EventType) : undefined, Key: isSet(object.Key) ? globalThis.String(object.Key) : "", }; }, toJSON(message: EventTypeWithKeyExpression): unknown { const obj: any = {}; if (message.EventType !== undefined) { obj.EventType = EventType.toJSON(message.EventType); } if (message.Key !== "") { obj.Key = message.Key; } return obj; }, create(base?: DeepPartial): EventTypeWithKeyExpression { return EventTypeWithKeyExpression.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventTypeWithKeyExpression { const message = createBaseEventTypeWithKeyExpression(); message.EventType = (object.EventType !== undefined && object.EventType !== null) ? EventType.fromPartial(object.EventType) : undefined; message.Key = object.Key ?? ""; return message; }, }; function createBaseIdentity(): Identity { return { Subject: "", Name: "", UserName: "", OnBehalfOf: undefined }; } export const Identity: MessageFns = { encode(message: Identity, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Subject !== "") { writer.uint32(10).string(message.Subject); } if (message.Name !== "") { writer.uint32(18).string(message.Name); } if (message.UserName !== "") { writer.uint32(26).string(message.UserName); } if (message.OnBehalfOf !== undefined) { Identity.encode(message.OnBehalfOf, writer.uint32(34).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Identity { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseIdentity(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Subject = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.Name = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.UserName = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.OnBehalfOf = Identity.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): Identity { return { Subject: isSet(object.Subject) ? globalThis.String(object.Subject) : "", Name: isSet(object.Name) ? globalThis.String(object.Name) : "", UserName: isSet(object.UserName) ? globalThis.String(object.UserName) : "", OnBehalfOf: isSet(object.OnBehalfOf) ? Identity.fromJSON(object.OnBehalfOf) : undefined, }; }, toJSON(message: Identity): unknown { const obj: any = {}; if (message.Subject !== "") { obj.Subject = message.Subject; } if (message.Name !== "") { obj.Name = message.Name; } if (message.UserName !== "") { obj.UserName = message.UserName; } if (message.OnBehalfOf !== undefined) { obj.OnBehalfOf = Identity.toJSON(message.OnBehalfOf); } return obj; }, create(base?: DeepPartial): Identity { return Identity.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Identity { const message = createBaseIdentity(); message.Subject = object.Subject ?? ""; message.Name = object.Name ?? ""; message.UserName = object.UserName ?? ""; message.OnBehalfOf = (object.OnBehalfOf !== undefined && object.OnBehalfOf !== null) ? Identity.fromPartial(object.OnBehalfOf) : undefined; return message; }, }; function createBaseObserverFilters(): ObserverFilters { return { FilterTags: [], EventSourceType: "", EventStreamType: "" }; } export const ObserverFilters: MessageFns = { encode(message: ObserverFilters, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.FilterTags) { writer.uint32(10).string(v!); } if (message.EventSourceType !== "") { writer.uint32(18).string(message.EventSourceType); } if (message.EventStreamType !== "") { writer.uint32(26).string(message.EventStreamType); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ObserverFilters { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseObserverFilters(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.FilterTags.push(reader.string()); continue; } case 2: { if (tag !== 18) { break; } message.EventSourceType = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.EventStreamType = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): ObserverFilters { return { FilterTags: globalThis.Array.isArray(object?.FilterTags) ? object.FilterTags.map((e: any) => globalThis.String(e)) : [], EventSourceType: isSet(object.EventSourceType) ? globalThis.String(object.EventSourceType) : "", EventStreamType: isSet(object.EventStreamType) ? globalThis.String(object.EventStreamType) : "", }; }, toJSON(message: ObserverFilters): unknown { const obj: any = {}; if (message.FilterTags?.length) { obj.FilterTags = message.FilterTags; } if (message.EventSourceType !== "") { obj.EventSourceType = message.EventSourceType; } if (message.EventStreamType !== "") { obj.EventStreamType = message.EventStreamType; } return obj; }, create(base?: DeepPartial): ObserverFilters { return ObserverFilters.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ObserverFilters { const message = createBaseObserverFilters(); message.FilterTags = object.FilterTags?.map((e) => e) || []; message.EventSourceType = object.EventSourceType ?? ""; message.EventStreamType = object.EventStreamType ?? ""; return message; }, }; function createBaseOneOfRegisterReducerReducerResult(): OneOfRegisterReducerReducerResult { return { Value0: undefined, Value1: undefined }; } export const OneOfRegisterReducerReducerResult: MessageFns = { encode(message: OneOfRegisterReducerReducerResult, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Value0 !== undefined) { RegisterReducer.encode(message.Value0, writer.uint32(10).fork()).join(); } if (message.Value1 !== undefined) { ReducerResult.encode(message.Value1, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): OneOfRegisterReducerReducerResult { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseOneOfRegisterReducerReducerResult(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Value0 = RegisterReducer.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.Value1 = ReducerResult.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): OneOfRegisterReducerReducerResult { return { Value0: isSet(object.Value0) ? RegisterReducer.fromJSON(object.Value0) : undefined, Value1: isSet(object.Value1) ? ReducerResult.fromJSON(object.Value1) : undefined, }; }, toJSON(message: OneOfRegisterReducerReducerResult): unknown { const obj: any = {}; if (message.Value0 !== undefined) { obj.Value0 = RegisterReducer.toJSON(message.Value0); } if (message.Value1 !== undefined) { obj.Value1 = ReducerResult.toJSON(message.Value1); } return obj; }, create(base?: DeepPartial): OneOfRegisterReducerReducerResult { return OneOfRegisterReducerReducerResult.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): OneOfRegisterReducerReducerResult { const message = createBaseOneOfRegisterReducerReducerResult(); message.Value0 = (object.Value0 !== undefined && object.Value0 !== null) ? RegisterReducer.fromPartial(object.Value0) : undefined; message.Value1 = (object.Value1 !== undefined && object.Value1 !== null) ? ReducerResult.fromPartial(object.Value1) : undefined; return message; }, }; function createBaseReduceOperationMessage(): ReduceOperationMessage { return { Partition: "", InitialState: "", Events: [], ReplayState: 0 }; } export const ReduceOperationMessage: MessageFns = { encode(message: ReduceOperationMessage, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Partition !== "") { writer.uint32(10).string(message.Partition); } if (message.InitialState !== "") { writer.uint32(18).string(message.InitialState); } for (const v of message.Events) { AppendedEvent.encode(v!, writer.uint32(26).fork()).join(); } if (message.ReplayState !== 0) { writer.uint32(32).int32(message.ReplayState); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ReduceOperationMessage { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseReduceOperationMessage(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Partition = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.InitialState = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.Events.push(AppendedEvent.decode(reader, reader.uint32())); continue; } case 4: { if (tag !== 32) { break; } message.ReplayState = reader.int32() as any; continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): ReduceOperationMessage { return { Partition: isSet(object.Partition) ? globalThis.String(object.Partition) : "", InitialState: isSet(object.InitialState) ? globalThis.String(object.InitialState) : "", Events: globalThis.Array.isArray(object?.Events) ? object.Events.map((e: any) => AppendedEvent.fromJSON(e)) : [], ReplayState: isSet(object.ReplayState) ? replayStateFromJSON(object.ReplayState) : 0, }; }, toJSON(message: ReduceOperationMessage): unknown { const obj: any = {}; if (message.Partition !== "") { obj.Partition = message.Partition; } if (message.InitialState !== "") { obj.InitialState = message.InitialState; } if (message.Events?.length) { obj.Events = message.Events.map((e) => AppendedEvent.toJSON(e)); } if (message.ReplayState !== 0) { obj.ReplayState = replayStateToJSON(message.ReplayState); } return obj; }, create(base?: DeepPartial): ReduceOperationMessage { return ReduceOperationMessage.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ReduceOperationMessage { const message = createBaseReduceOperationMessage(); message.Partition = object.Partition ?? ""; message.InitialState = object.InitialState ?? ""; message.Events = object.Events?.map((e) => AppendedEvent.fromPartial(e)) || []; message.ReplayState = object.ReplayState ?? 0; return message; }, }; function createBaseReducerDefinition(): ReducerDefinition { return { ReducerId: "", EventSequenceId: "", EventTypes: [], ReadModel: "", IsActive: false, Tags: [], Filters: undefined, Hash: "", }; } export const ReducerDefinition: MessageFns = { encode(message: ReducerDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.ReducerId !== "") { writer.uint32(10).string(message.ReducerId); } if (message.EventSequenceId !== "") { writer.uint32(18).string(message.EventSequenceId); } for (const v of message.EventTypes) { EventTypeWithKeyExpression.encode(v!, writer.uint32(26).fork()).join(); } if (message.ReadModel !== "") { writer.uint32(34).string(message.ReadModel); } if (message.IsActive !== false) { writer.uint32(40).bool(message.IsActive); } for (const v of message.Tags) { writer.uint32(58).string(v!); } if (message.Filters !== undefined) { ObserverFilters.encode(message.Filters, writer.uint32(66).fork()).join(); } if (message.Hash !== "") { writer.uint32(74).string(message.Hash); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ReducerDefinition { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseReducerDefinition(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.ReducerId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.EventSequenceId = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.EventTypes.push(EventTypeWithKeyExpression.decode(reader, reader.uint32())); continue; } case 4: { if (tag !== 34) { break; } message.ReadModel = reader.string(); continue; } case 5: { if (tag !== 40) { break; } message.IsActive = reader.bool(); continue; } case 7: { if (tag !== 58) { break; } message.Tags.push(reader.string()); continue; } case 8: { if (tag !== 66) { break; } message.Filters = ObserverFilters.decode(reader, reader.uint32()); continue; } case 9: { if (tag !== 74) { break; } message.Hash = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): ReducerDefinition { return { ReducerId: isSet(object.ReducerId) ? globalThis.String(object.ReducerId) : "", EventSequenceId: isSet(object.EventSequenceId) ? globalThis.String(object.EventSequenceId) : "", EventTypes: globalThis.Array.isArray(object?.EventTypes) ? object.EventTypes.map((e: any) => EventTypeWithKeyExpression.fromJSON(e)) : [], ReadModel: isSet(object.ReadModel) ? globalThis.String(object.ReadModel) : "", IsActive: isSet(object.IsActive) ? globalThis.Boolean(object.IsActive) : false, Tags: globalThis.Array.isArray(object?.Tags) ? object.Tags.map((e: any) => globalThis.String(e)) : [], Filters: isSet(object.Filters) ? ObserverFilters.fromJSON(object.Filters) : undefined, Hash: isSet(object.Hash) ? globalThis.String(object.Hash) : "", }; }, toJSON(message: ReducerDefinition): unknown { const obj: any = {}; if (message.ReducerId !== "") { obj.ReducerId = message.ReducerId; } if (message.EventSequenceId !== "") { obj.EventSequenceId = message.EventSequenceId; } if (message.EventTypes?.length) { obj.EventTypes = message.EventTypes.map((e) => EventTypeWithKeyExpression.toJSON(e)); } if (message.ReadModel !== "") { obj.ReadModel = message.ReadModel; } if (message.IsActive !== false) { obj.IsActive = message.IsActive; } if (message.Tags?.length) { obj.Tags = message.Tags; } if (message.Filters !== undefined) { obj.Filters = ObserverFilters.toJSON(message.Filters); } if (message.Hash !== "") { obj.Hash = message.Hash; } return obj; }, create(base?: DeepPartial): ReducerDefinition { return ReducerDefinition.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ReducerDefinition { const message = createBaseReducerDefinition(); message.ReducerId = object.ReducerId ?? ""; message.EventSequenceId = object.EventSequenceId ?? ""; message.EventTypes = object.EventTypes?.map((e) => EventTypeWithKeyExpression.fromPartial(e)) || []; message.ReadModel = object.ReadModel ?? ""; message.IsActive = object.IsActive ?? false; message.Tags = object.Tags?.map((e) => e) || []; message.Filters = (object.Filters !== undefined && object.Filters !== null) ? ObserverFilters.fromPartial(object.Filters) : undefined; message.Hash = object.Hash ?? ""; return message; }, }; function createBaseReducerMessage(): ReducerMessage { return { Content: undefined }; } export const ReducerMessage: MessageFns = { encode(message: ReducerMessage, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Content !== undefined) { OneOfRegisterReducerReducerResult.encode(message.Content, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ReducerMessage { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseReducerMessage(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Content = OneOfRegisterReducerReducerResult.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): ReducerMessage { return { Content: isSet(object.Content) ? OneOfRegisterReducerReducerResult.fromJSON(object.Content) : undefined }; }, toJSON(message: ReducerMessage): unknown { const obj: any = {}; if (message.Content !== undefined) { obj.Content = OneOfRegisterReducerReducerResult.toJSON(message.Content); } return obj; }, create(base?: DeepPartial): ReducerMessage { return ReducerMessage.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ReducerMessage { const message = createBaseReducerMessage(); message.Content = (object.Content !== undefined && object.Content !== null) ? OneOfRegisterReducerReducerResult.fromPartial(object.Content) : undefined; return message; }, }; function createBaseReducerResult(): ReducerResult { return { Partition: "", State: 0, LastSuccessfulObservation: 0n, ExceptionMessages: [], ExceptionStackTrace: "", ReadModelState: "", }; } export const ReducerResult: MessageFns = { encode(message: ReducerResult, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Partition !== "") { writer.uint32(10).string(message.Partition); } if (message.State !== 0) { writer.uint32(16).int32(message.State); } if (message.LastSuccessfulObservation !== 0n) { if (BigInt.asUintN(64, message.LastSuccessfulObservation) !== message.LastSuccessfulObservation) { throw new globalThis.Error( "value provided for field message.LastSuccessfulObservation of type uint64 too large", ); } writer.uint32(24).uint64(message.LastSuccessfulObservation); } for (const v of message.ExceptionMessages) { writer.uint32(34).string(v!); } if (message.ExceptionStackTrace !== "") { writer.uint32(42).string(message.ExceptionStackTrace); } if (message.ReadModelState !== "") { writer.uint32(50).string(message.ReadModelState); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ReducerResult { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseReducerResult(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Partition = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.State = reader.int32() as any; continue; } case 3: { if (tag !== 24) { break; } message.LastSuccessfulObservation = reader.uint64() as bigint; continue; } case 4: { if (tag !== 34) { break; } message.ExceptionMessages.push(reader.string()); continue; } case 5: { if (tag !== 42) { break; } message.ExceptionStackTrace = reader.string(); continue; } case 6: { if (tag !== 50) { break; } message.ReadModelState = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): ReducerResult { return { Partition: isSet(object.Partition) ? globalThis.String(object.Partition) : "", State: isSet(object.State) ? observationStateFromJSON(object.State) : 0, LastSuccessfulObservation: isSet(object.LastSuccessfulObservation) ? BigInt(object.LastSuccessfulObservation) : 0n, ExceptionMessages: globalThis.Array.isArray(object?.ExceptionMessages) ? object.ExceptionMessages.map((e: any) => globalThis.String(e)) : [], ExceptionStackTrace: isSet(object.ExceptionStackTrace) ? globalThis.String(object.ExceptionStackTrace) : "", ReadModelState: isSet(object.ReadModelState) ? globalThis.String(object.ReadModelState) : "", }; }, toJSON(message: ReducerResult): unknown { const obj: any = {}; if (message.Partition !== "") { obj.Partition = message.Partition; } if (message.State !== 0) { obj.State = observationStateToJSON(message.State); } if (message.LastSuccessfulObservation !== 0n) { obj.LastSuccessfulObservation = message.LastSuccessfulObservation.toString(); } if (message.ExceptionMessages?.length) { obj.ExceptionMessages = message.ExceptionMessages; } if (message.ExceptionStackTrace !== "") { obj.ExceptionStackTrace = message.ExceptionStackTrace; } if (message.ReadModelState !== "") { obj.ReadModelState = message.ReadModelState; } return obj; }, create(base?: DeepPartial): ReducerResult { return ReducerResult.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ReducerResult { const message = createBaseReducerResult(); message.Partition = object.Partition ?? ""; message.State = object.State ?? 0; message.LastSuccessfulObservation = (object.LastSuccessfulObservation !== undefined && object.LastSuccessfulObservation !== null) ? BigInt(object.LastSuccessfulObservation) : 0n; message.ExceptionMessages = object.ExceptionMessages?.map((e) => e) || []; message.ExceptionStackTrace = object.ExceptionStackTrace ?? ""; message.ReadModelState = object.ReadModelState ?? ""; return message; }, }; function createBaseRegisterReducer(): RegisterReducer { return { ConnectionId: "", EventStore: "", Namespace: "", Reducer: undefined }; } export const RegisterReducer: MessageFns = { encode(message: RegisterReducer, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.ConnectionId !== "") { writer.uint32(10).string(message.ConnectionId); } if (message.EventStore !== "") { writer.uint32(18).string(message.EventStore); } if (message.Namespace !== "") { writer.uint32(26).string(message.Namespace); } if (message.Reducer !== undefined) { ReducerDefinition.encode(message.Reducer, writer.uint32(34).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): RegisterReducer { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseRegisterReducer(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.ConnectionId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.EventStore = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.Namespace = reader.string(); continue; } case 4: { if (tag !== 34) { break; } message.Reducer = ReducerDefinition.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): RegisterReducer { return { ConnectionId: isSet(object.ConnectionId) ? globalThis.String(object.ConnectionId) : "", EventStore: isSet(object.EventStore) ? globalThis.String(object.EventStore) : "", Namespace: isSet(object.Namespace) ? globalThis.String(object.Namespace) : "", Reducer: isSet(object.Reducer) ? ReducerDefinition.fromJSON(object.Reducer) : undefined, }; }, toJSON(message: RegisterReducer): unknown { const obj: any = {}; if (message.ConnectionId !== "") { obj.ConnectionId = message.ConnectionId; } if (message.EventStore !== "") { obj.EventStore = message.EventStore; } if (message.Namespace !== "") { obj.Namespace = message.Namespace; } if (message.Reducer !== undefined) { obj.Reducer = ReducerDefinition.toJSON(message.Reducer); } return obj; }, create(base?: DeepPartial): RegisterReducer { return RegisterReducer.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): RegisterReducer { const message = createBaseRegisterReducer(); message.ConnectionId = object.ConnectionId ?? ""; message.EventStore = object.EventStore ?? ""; message.Namespace = object.Namespace ?? ""; message.Reducer = (object.Reducer !== undefined && object.Reducer !== null) ? ReducerDefinition.fromPartial(object.Reducer) : undefined; return message; }, }; function createBaseSerializableDateTimeOffset(): SerializableDateTimeOffset { return { Value: "" }; } export const SerializableDateTimeOffset: MessageFns = { encode(message: SerializableDateTimeOffset, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Value !== "") { writer.uint32(10).string(message.Value); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): SerializableDateTimeOffset { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0; if (previousRecursionDepth >= 100) { throw new globalThis.Error("protobuf decode recursion limit exceeded"); } (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1; try { const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSerializableDateTimeOffset(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Value = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): SerializableDateTimeOffset { return { Value: isSet(object.Value) ? globalThis.String(object.Value) : "" }; }, toJSON(message: SerializableDateTimeOffset): unknown { const obj: any = {}; if (message.Value !== "") { obj.Value = message.Value; } return obj; }, create(base?: DeepPartial): SerializableDateTimeOffset { return SerializableDateTimeOffset.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): SerializableDateTimeOffset { const message = createBaseSerializableDateTimeOffset(); message.Value = object.Value ?? ""; return message; }, }; export type ReducersDefinition = typeof ReducersDefinition; export const ReducersDefinition = { name: "Reducers", fullName: "Cratis.Chronicle.Contracts.Observation.Reducers.Reducers", methods: { observe: { name: "Observe", requestType: ReducerMessage as typeof ReducerMessage, requestStream: true, responseType: ReduceOperationMessage as typeof ReduceOperationMessage, responseStream: true, options: {}, }, }, } as const; export interface ReducersServiceImplementation { observe( request: AsyncIterable, context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; } export interface ReducersClient { observe( request: AsyncIterable>, options?: CallOptions & CallOptionsExt, ): AsyncIterable; } type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined; export type DeepPartial = T extends bigint ? string | number | bigint : T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function isObject(value: any): boolean { return typeof value === "object" && value !== null; } function isSet(value: any): boolean { return value !== null && value !== undefined; } export type ServerStreamingMethodResult = { [Symbol.asyncIterator](): AsyncIterator }; export interface MessageFns { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create(base?: DeepPartial): T; fromPartial(object: DeepPartial): T; }