// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.15.3 // protoc v5.28.3 // source: statistics.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.Statistics"; export enum ValidationResultSeverity { Unknown = 0, Information = 1, Warning = 2, Error = 3, UNRECOGNIZED = -1, } export function validationResultSeverityFromJSON(object: any): ValidationResultSeverity { switch (object) { case 0: case "Unknown": return ValidationResultSeverity.Unknown; case 1: case "Information": return ValidationResultSeverity.Information; case 2: case "Warning": return ValidationResultSeverity.Warning; case 3: case "Error": return ValidationResultSeverity.Error; case -1: case "UNRECOGNIZED": default: return ValidationResultSeverity.UNRECOGNIZED; } } export function validationResultSeverityToJSON(object: ValidationResultSeverity): string { switch (object) { case ValidationResultSeverity.Unknown: return "Unknown"; case ValidationResultSeverity.Information: return "Information"; case ValidationResultSeverity.Warning: return "Warning"; case ValidationResultSeverity.Error: return "Error"; case ValidationResultSeverity.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } export interface EventStatisticsResponse { TotalEvents: bigint; EventTypes: number; Namespaces: number; PerEventType: EventTypeCount[]; } export interface EventTypeCount { EventType: string; Count: bigint; } export interface QueryResultEventStatisticsResponse { /** default value could not be applied: 00000000-0000-0000-0000-000000000000 */ CorrelationId: Guid | undefined; IsAuthorized: boolean; ValidationResults: ValidationResult[]; ExceptionMessages: string[]; ExceptionStackTrace: string; Data: EventStatisticsResponse | undefined; } export interface StatisticsForEventStoreRequest { EventStore: string; } export interface StatisticsForNamespaceRequest { EventStore: string; Namespace: string; } export interface ValidationResult { /** default value could not be applied: Error */ Severity: ValidationResultSeverity; Message: string; Members: string[]; } function createBaseEventStatisticsResponse(): EventStatisticsResponse { return { TotalEvents: 0n, EventTypes: 0, Namespaces: 0, PerEventType: [] }; } export const EventStatisticsResponse: MessageFns = { encode(message: EventStatisticsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.TotalEvents !== 0n) { if (BigInt.asIntN(64, message.TotalEvents) !== message.TotalEvents) { throw new globalThis.Error("value provided for field message.TotalEvents of type int64 too large"); } writer.uint32(8).int64(message.TotalEvents); } if (message.EventTypes !== 0) { writer.uint32(16).int32(message.EventTypes); } if (message.Namespaces !== 0) { writer.uint32(24).int32(message.Namespaces); } for (const v of message.PerEventType) { EventTypeCount.encode(v!, writer.uint32(34).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventStatisticsResponse { 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 = createBaseEventStatisticsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.TotalEvents = reader.int64() as bigint; continue; } case 2: { if (tag !== 16) { break; } message.EventTypes = reader.int32(); continue; } case 3: { if (tag !== 24) { break; } message.Namespaces = reader.int32(); continue; } case 4: { if (tag !== 34) { break; } message.PerEventType.push(EventTypeCount.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): EventStatisticsResponse { return { TotalEvents: isSet(object.TotalEvents) ? BigInt(object.TotalEvents) : 0n, EventTypes: isSet(object.EventTypes) ? globalThis.Number(object.EventTypes) : 0, Namespaces: isSet(object.Namespaces) ? globalThis.Number(object.Namespaces) : 0, PerEventType: globalThis.Array.isArray(object?.PerEventType) ? object.PerEventType.map((e: any) => EventTypeCount.fromJSON(e)) : [], }; }, toJSON(message: EventStatisticsResponse): unknown { const obj: any = {}; if (message.TotalEvents !== 0n) { obj.TotalEvents = message.TotalEvents.toString(); } if (message.EventTypes !== 0) { obj.EventTypes = Math.round(message.EventTypes); } if (message.Namespaces !== 0) { obj.Namespaces = Math.round(message.Namespaces); } if (message.PerEventType?.length) { obj.PerEventType = message.PerEventType.map((e) => EventTypeCount.toJSON(e)); } return obj; }, create(base?: DeepPartial): EventStatisticsResponse { return EventStatisticsResponse.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventStatisticsResponse { const message = createBaseEventStatisticsResponse(); message.TotalEvents = (object.TotalEvents !== undefined && object.TotalEvents !== null) ? BigInt(object.TotalEvents) : 0n; message.EventTypes = object.EventTypes ?? 0; message.Namespaces = object.Namespaces ?? 0; message.PerEventType = object.PerEventType?.map((e) => EventTypeCount.fromPartial(e)) || []; return message; }, }; function createBaseEventTypeCount(): EventTypeCount { return { EventType: "", Count: 0n }; } export const EventTypeCount: MessageFns = { encode(message: EventTypeCount, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventType !== "") { writer.uint32(10).string(message.EventType); } if (message.Count !== 0n) { if (BigInt.asIntN(64, message.Count) !== message.Count) { throw new globalThis.Error("value provided for field message.Count of type int64 too large"); } writer.uint32(16).int64(message.Count); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): EventTypeCount { 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 = createBaseEventTypeCount(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventType = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.Count = reader.int64() as bigint; continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; } finally { (reader as any).__tsProtoDecodeDepth = previousRecursionDepth; } }, fromJSON(object: any): EventTypeCount { return { EventType: isSet(object.EventType) ? globalThis.String(object.EventType) : "", Count: isSet(object.Count) ? BigInt(object.Count) : 0n, }; }, toJSON(message: EventTypeCount): unknown { const obj: any = {}; if (message.EventType !== "") { obj.EventType = message.EventType; } if (message.Count !== 0n) { obj.Count = message.Count.toString(); } return obj; }, create(base?: DeepPartial): EventTypeCount { return EventTypeCount.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): EventTypeCount { const message = createBaseEventTypeCount(); message.EventType = object.EventType ?? ""; message.Count = (object.Count !== undefined && object.Count !== null) ? BigInt(object.Count) : 0n; return message; }, }; function createBaseQueryResultEventStatisticsResponse(): QueryResultEventStatisticsResponse { return { CorrelationId: undefined, IsAuthorized: false, ValidationResults: [], ExceptionMessages: [], ExceptionStackTrace: "", Data: undefined, }; } export const QueryResultEventStatisticsResponse: MessageFns = { encode(message: QueryResultEventStatisticsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.CorrelationId !== undefined) { Guid.encode(message.CorrelationId, writer.uint32(10).fork()).join(); } if (message.IsAuthorized !== false) { writer.uint32(16).bool(message.IsAuthorized); } for (const v of message.ValidationResults) { ValidationResult.encode(v!, writer.uint32(26).fork()).join(); } for (const v of message.ExceptionMessages) { writer.uint32(34).string(v!); } if (message.ExceptionStackTrace !== "") { writer.uint32(42).string(message.ExceptionStackTrace); } if (message.Data !== undefined) { EventStatisticsResponse.encode(message.Data, writer.uint32(50).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): QueryResultEventStatisticsResponse { 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 = createBaseQueryResultEventStatisticsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.CorrelationId = Guid.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 16) { break; } message.IsAuthorized = reader.bool(); continue; } case 3: { if (tag !== 26) { break; } message.ValidationResults.push(ValidationResult.decode(reader, reader.uint32())); 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.Data = EventStatisticsResponse.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): QueryResultEventStatisticsResponse { return { CorrelationId: isSet(object.CorrelationId) ? Guid.fromJSON(object.CorrelationId) : undefined, IsAuthorized: isSet(object.IsAuthorized) ? globalThis.Boolean(object.IsAuthorized) : false, ValidationResults: globalThis.Array.isArray(object?.ValidationResults) ? object.ValidationResults.map((e: any) => ValidationResult.fromJSON(e)) : [], ExceptionMessages: globalThis.Array.isArray(object?.ExceptionMessages) ? object.ExceptionMessages.map((e: any) => globalThis.String(e)) : [], ExceptionStackTrace: isSet(object.ExceptionStackTrace) ? globalThis.String(object.ExceptionStackTrace) : "", Data: isSet(object.Data) ? EventStatisticsResponse.fromJSON(object.Data) : undefined, }; }, toJSON(message: QueryResultEventStatisticsResponse): unknown { const obj: any = {}; if (message.CorrelationId !== undefined) { obj.CorrelationId = Guid.toJSON(message.CorrelationId); } if (message.IsAuthorized !== false) { obj.IsAuthorized = message.IsAuthorized; } if (message.ValidationResults?.length) { obj.ValidationResults = message.ValidationResults.map((e) => ValidationResult.toJSON(e)); } if (message.ExceptionMessages?.length) { obj.ExceptionMessages = message.ExceptionMessages; } if (message.ExceptionStackTrace !== "") { obj.ExceptionStackTrace = message.ExceptionStackTrace; } if (message.Data !== undefined) { obj.Data = EventStatisticsResponse.toJSON(message.Data); } return obj; }, create(base?: DeepPartial): QueryResultEventStatisticsResponse { return QueryResultEventStatisticsResponse.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): QueryResultEventStatisticsResponse { const message = createBaseQueryResultEventStatisticsResponse(); message.CorrelationId = (object.CorrelationId !== undefined && object.CorrelationId !== null) ? Guid.fromPartial(object.CorrelationId) : undefined; message.IsAuthorized = object.IsAuthorized ?? false; message.ValidationResults = object.ValidationResults?.map((e) => ValidationResult.fromPartial(e)) || []; message.ExceptionMessages = object.ExceptionMessages?.map((e) => e) || []; message.ExceptionStackTrace = object.ExceptionStackTrace ?? ""; message.Data = (object.Data !== undefined && object.Data !== null) ? EventStatisticsResponse.fromPartial(object.Data) : undefined; return message; }, }; function createBaseStatisticsForEventStoreRequest(): StatisticsForEventStoreRequest { return { EventStore: "" }; } export const StatisticsForEventStoreRequest: MessageFns = { encode(message: StatisticsForEventStoreRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventStore !== "") { writer.uint32(10).string(message.EventStore); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): StatisticsForEventStoreRequest { 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 = createBaseStatisticsForEventStoreRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventStore = 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): StatisticsForEventStoreRequest { return { EventStore: isSet(object.EventStore) ? globalThis.String(object.EventStore) : "" }; }, toJSON(message: StatisticsForEventStoreRequest): unknown { const obj: any = {}; if (message.EventStore !== "") { obj.EventStore = message.EventStore; } return obj; }, create(base?: DeepPartial): StatisticsForEventStoreRequest { return StatisticsForEventStoreRequest.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): StatisticsForEventStoreRequest { const message = createBaseStatisticsForEventStoreRequest(); message.EventStore = object.EventStore ?? ""; return message; }, }; function createBaseStatisticsForNamespaceRequest(): StatisticsForNamespaceRequest { return { EventStore: "", Namespace: "" }; } export const StatisticsForNamespaceRequest: MessageFns = { encode(message: StatisticsForNamespaceRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventStore !== "") { writer.uint32(10).string(message.EventStore); } if (message.Namespace !== "") { writer.uint32(18).string(message.Namespace); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): StatisticsForNamespaceRequest { 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 = createBaseStatisticsForNamespaceRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventStore = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.Namespace = 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): StatisticsForNamespaceRequest { return { EventStore: isSet(object.EventStore) ? globalThis.String(object.EventStore) : "", Namespace: isSet(object.Namespace) ? globalThis.String(object.Namespace) : "", }; }, toJSON(message: StatisticsForNamespaceRequest): unknown { const obj: any = {}; if (message.EventStore !== "") { obj.EventStore = message.EventStore; } if (message.Namespace !== "") { obj.Namespace = message.Namespace; } return obj; }, create(base?: DeepPartial): StatisticsForNamespaceRequest { return StatisticsForNamespaceRequest.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): StatisticsForNamespaceRequest { const message = createBaseStatisticsForNamespaceRequest(); message.EventStore = object.EventStore ?? ""; message.Namespace = object.Namespace ?? ""; return message; }, }; function createBaseValidationResult(): ValidationResult { return { Severity: 0, Message: "", Members: [] }; } export const ValidationResult: MessageFns = { encode(message: ValidationResult, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Severity !== 0) { writer.uint32(8).int32(message.Severity); } if (message.Message !== "") { writer.uint32(18).string(message.Message); } for (const v of message.Members) { writer.uint32(26).string(v!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ValidationResult { 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 = createBaseValidationResult(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.Severity = reader.int32() as any; continue; } case 2: { if (tag !== 18) { break; } message.Message = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.Members.push(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): ValidationResult { return { Severity: isSet(object.Severity) ? validationResultSeverityFromJSON(object.Severity) : 0, Message: isSet(object.Message) ? globalThis.String(object.Message) : "", Members: globalThis.Array.isArray(object?.Members) ? object.Members.map((e: any) => globalThis.String(e)) : [], }; }, toJSON(message: ValidationResult): unknown { const obj: any = {}; if (message.Severity !== 0) { obj.Severity = validationResultSeverityToJSON(message.Severity); } if (message.Message !== "") { obj.Message = message.Message; } if (message.Members?.length) { obj.Members = message.Members; } return obj; }, create(base?: DeepPartial): ValidationResult { return ValidationResult.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ValidationResult { const message = createBaseValidationResult(); message.Severity = object.Severity ?? 0; message.Message = object.Message ?? ""; message.Members = object.Members?.map((e) => e) || []; return message; }, }; export type StatisticsDefinition = typeof StatisticsDefinition; export const StatisticsDefinition = { name: "Statistics", fullName: "Cratis.Chronicle.Contracts.Statistics.Statistics", methods: { statisticsForEventStore: { name: "StatisticsForEventStore", requestType: StatisticsForEventStoreRequest as typeof StatisticsForEventStoreRequest, requestStream: false, responseType: QueryResultEventStatisticsResponse as typeof QueryResultEventStatisticsResponse, responseStream: false, options: {}, }, statisticsForNamespace: { name: "StatisticsForNamespace", requestType: StatisticsForNamespaceRequest as typeof StatisticsForNamespaceRequest, requestStream: false, responseType: QueryResultEventStatisticsResponse as typeof QueryResultEventStatisticsResponse, responseStream: false, options: {}, }, }, } as const; export interface StatisticsServiceImplementation { statisticsForEventStore( request: StatisticsForEventStoreRequest, context: CallContext & CallContextExt, ): Promise>; statisticsForNamespace( request: StatisticsForNamespaceRequest, context: CallContext & CallContextExt, ): Promise>; } export interface StatisticsClient { statisticsForEventStore( request: DeepPartial, options?: CallOptions & CallOptionsExt, ): Promise; statisticsForNamespace( request: DeepPartial, options?: CallOptions & CallOptionsExt, ): Promise; } 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 isSet(value: any): boolean { return value !== null && value !== undefined; } 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; }