// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.12.4 // protoc v5.28.3 // source: events_constraints.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import type { CallContext, CallOptions } from "nice-grpc-common"; import { Empty } from "./google/protobuf/empty"; export const protobufPackage = "Cratis.Chronicle.Contracts.Events.Constraints"; export enum ConstraintType { Unknown = 0, Unique = 1, UniqueEventType = 2, Schema = 3, StreamClosed = 4, UNRECOGNIZED = -1, } export function constraintTypeFromJSON(object: any): ConstraintType { switch (object) { case 0: case "Unknown": return ConstraintType.Unknown; case 1: case "Unique": return ConstraintType.Unique; case 2: case "UniqueEventType": return ConstraintType.UniqueEventType; case 3: case "Schema": return ConstraintType.Schema; case 4: case "StreamClosed": return ConstraintType.StreamClosed; case -1: case "UNRECOGNIZED": default: return ConstraintType.UNRECOGNIZED; } } export function constraintTypeToJSON(object: ConstraintType): string { switch (object) { case ConstraintType.Unknown: return "Unknown"; case ConstraintType.Unique: return "Unique"; case ConstraintType.UniqueEventType: return "UniqueEventType"; case ConstraintType.Schema: return "Schema"; case ConstraintType.StreamClosed: return "StreamClosed"; case ConstraintType.UNRECOGNIZED: default: return "UNRECOGNIZED"; } } export interface Constraint { Name: string; Type: ConstraintType; RemovedWith: string[]; Definition: OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition | undefined; Scope: ConstraintScope | undefined; } export interface ConstraintScope { EventSourceType: string; EventStreamType: string; EventStreamId: string; } export interface OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { Value0: UniqueConstraintDefinition | undefined; Value1: UniqueEventTypeConstraintDefinition | undefined; } export interface RegisterConstraintsRequest { EventStore: string; Constraints: Constraint[]; } export interface UniqueConstraintDefinition { EventDefinitions: UniqueConstraintEventDefinition[]; IgnoreCasing: boolean; } export interface UniqueConstraintEventDefinition { EventTypeId: string; Properties: string[]; } export interface UniqueEventTypeConstraintDefinition { EventTypeIds: string[]; } function createBaseConstraint(): Constraint { return { Name: "", Type: 0, RemovedWith: [], Definition: undefined, Scope: undefined }; } export const Constraint: MessageFns = { encode(message: Constraint, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.Name !== "") { writer.uint32(10).string(message.Name); } if (message.Type !== 0) { writer.uint32(16).int32(message.Type); } for (const v of message.RemovedWith) { writer.uint32(26).string(v!); } if (message.Definition !== undefined) { OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.encode( message.Definition, writer.uint32(34).fork(), ).join(); } if (message.Scope !== undefined) { ConstraintScope.encode(message.Scope, writer.uint32(42).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): Constraint { 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 = createBaseConstraint(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Name = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.Type = reader.int32() as any; continue; } case 3: { if (tag !== 26) { break; } message.RemovedWith.push(reader.string()); continue; } case 4: { if (tag !== 34) { break; } message.Definition = OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.decode( reader, reader.uint32(), ); continue; } case 5: { if (tag !== 42) { break; } message.Scope = ConstraintScope.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): Constraint { return { Name: isSet(object.Name) ? globalThis.String(object.Name) : "", Type: isSet(object.Type) ? constraintTypeFromJSON(object.Type) : 0, RemovedWith: globalThis.Array.isArray(object?.RemovedWith) ? object.RemovedWith.map((e: any) => globalThis.String(e)) : [], Definition: isSet(object.Definition) ? OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.fromJSON(object.Definition) : undefined, Scope: isSet(object.Scope) ? ConstraintScope.fromJSON(object.Scope) : undefined, }; }, toJSON(message: Constraint): unknown { const obj: any = {}; if (message.Name !== "") { obj.Name = message.Name; } if (message.Type !== 0) { obj.Type = constraintTypeToJSON(message.Type); } if (message.RemovedWith?.length) { obj.RemovedWith = message.RemovedWith; } if (message.Definition !== undefined) { obj.Definition = OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.toJSON(message.Definition); } if (message.Scope !== undefined) { obj.Scope = ConstraintScope.toJSON(message.Scope); } return obj; }, create(base?: DeepPartial): Constraint { return Constraint.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): Constraint { const message = createBaseConstraint(); message.Name = object.Name ?? ""; message.Type = object.Type ?? 0; message.RemovedWith = object.RemovedWith?.map((e) => e) || []; message.Definition = (object.Definition !== undefined && object.Definition !== null) ? OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.fromPartial(object.Definition) : undefined; message.Scope = (object.Scope !== undefined && object.Scope !== null) ? ConstraintScope.fromPartial(object.Scope) : undefined; return message; }, }; function createBaseConstraintScope(): ConstraintScope { return { EventSourceType: "", EventStreamType: "", EventStreamId: "" }; } export const ConstraintScope: MessageFns = { encode(message: ConstraintScope, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventSourceType !== "") { writer.uint32(10).string(message.EventSourceType); } if (message.EventStreamType !== "") { writer.uint32(18).string(message.EventStreamType); } if (message.EventStreamId !== "") { writer.uint32(26).string(message.EventStreamId); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): ConstraintScope { 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 = createBaseConstraintScope(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventSourceType = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.EventStreamType = reader.string(); continue; } case 3: { if (tag !== 26) { break; } message.EventStreamId = 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): ConstraintScope { return { EventSourceType: isSet(object.EventSourceType) ? globalThis.String(object.EventSourceType) : "", EventStreamType: isSet(object.EventStreamType) ? globalThis.String(object.EventStreamType) : "", EventStreamId: isSet(object.EventStreamId) ? globalThis.String(object.EventStreamId) : "", }; }, toJSON(message: ConstraintScope): unknown { const obj: any = {}; if (message.EventSourceType !== "") { obj.EventSourceType = message.EventSourceType; } if (message.EventStreamType !== "") { obj.EventStreamType = message.EventStreamType; } if (message.EventStreamId !== "") { obj.EventStreamId = message.EventStreamId; } return obj; }, create(base?: DeepPartial): ConstraintScope { return ConstraintScope.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): ConstraintScope { const message = createBaseConstraintScope(); message.EventSourceType = object.EventSourceType ?? ""; message.EventStreamType = object.EventStreamType ?? ""; message.EventStreamId = object.EventStreamId ?? ""; return message; }, }; function createBaseOneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition(): OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { return { Value0: undefined, Value1: undefined }; } export const OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition: MessageFns< OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition > = { encode( message: OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition, writer: BinaryWriter = new BinaryWriter(), ): BinaryWriter { if (message.Value0 !== undefined) { UniqueConstraintDefinition.encode(message.Value0, writer.uint32(10).fork()).join(); } if (message.Value1 !== undefined) { UniqueEventTypeConstraintDefinition.encode(message.Value1, writer.uint32(18).fork()).join(); } return writer; }, decode( input: BinaryReader | Uint8Array, length?: number, ): OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { 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 = createBaseOneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.Value0 = UniqueConstraintDefinition.decode(reader, reader.uint32()); continue; } case 2: { if (tag !== 18) { break; } message.Value1 = UniqueEventTypeConstraintDefinition.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): OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { return { Value0: isSet(object.Value0) ? UniqueConstraintDefinition.fromJSON(object.Value0) : undefined, Value1: isSet(object.Value1) ? UniqueEventTypeConstraintDefinition.fromJSON(object.Value1) : undefined, }; }, toJSON(message: OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition): unknown { const obj: any = {}; if (message.Value0 !== undefined) { obj.Value0 = UniqueConstraintDefinition.toJSON(message.Value0); } if (message.Value1 !== undefined) { obj.Value1 = UniqueEventTypeConstraintDefinition.toJSON(message.Value1); } return obj; }, create( base?: DeepPartial, ): OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { return OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition.fromPartial(base ?? {}); }, fromPartial( object: DeepPartial, ): OneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition { const message = createBaseOneOfUniqueConstraintDefinitionUniqueEventTypeConstraintDefinition(); message.Value0 = (object.Value0 !== undefined && object.Value0 !== null) ? UniqueConstraintDefinition.fromPartial(object.Value0) : undefined; message.Value1 = (object.Value1 !== undefined && object.Value1 !== null) ? UniqueEventTypeConstraintDefinition.fromPartial(object.Value1) : undefined; return message; }, }; function createBaseRegisterConstraintsRequest(): RegisterConstraintsRequest { return { EventStore: "", Constraints: [] }; } export const RegisterConstraintsRequest: MessageFns = { encode(message: RegisterConstraintsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventStore !== "") { writer.uint32(10).string(message.EventStore); } for (const v of message.Constraints) { Constraint.encode(v!, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): RegisterConstraintsRequest { 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 = createBaseRegisterConstraintsRequest(); 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.Constraints.push(Constraint.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): RegisterConstraintsRequest { return { EventStore: isSet(object.EventStore) ? globalThis.String(object.EventStore) : "", Constraints: globalThis.Array.isArray(object?.Constraints) ? object.Constraints.map((e: any) => Constraint.fromJSON(e)) : [], }; }, toJSON(message: RegisterConstraintsRequest): unknown { const obj: any = {}; if (message.EventStore !== "") { obj.EventStore = message.EventStore; } if (message.Constraints?.length) { obj.Constraints = message.Constraints.map((e) => Constraint.toJSON(e)); } return obj; }, create(base?: DeepPartial): RegisterConstraintsRequest { return RegisterConstraintsRequest.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): RegisterConstraintsRequest { const message = createBaseRegisterConstraintsRequest(); message.EventStore = object.EventStore ?? ""; message.Constraints = object.Constraints?.map((e) => Constraint.fromPartial(e)) || []; return message; }, }; function createBaseUniqueConstraintDefinition(): UniqueConstraintDefinition { return { EventDefinitions: [], IgnoreCasing: false }; } export const UniqueConstraintDefinition: MessageFns = { encode(message: UniqueConstraintDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.EventDefinitions) { UniqueConstraintEventDefinition.encode(v!, writer.uint32(10).fork()).join(); } if (message.IgnoreCasing !== false) { writer.uint32(16).bool(message.IgnoreCasing); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): UniqueConstraintDefinition { 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 = createBaseUniqueConstraintDefinition(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventDefinitions.push(UniqueConstraintEventDefinition.decode(reader, reader.uint32())); continue; } case 2: { if (tag !== 16) { break; } message.IgnoreCasing = 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): UniqueConstraintDefinition { return { EventDefinitions: globalThis.Array.isArray(object?.EventDefinitions) ? object.EventDefinitions.map((e: any) => UniqueConstraintEventDefinition.fromJSON(e)) : [], IgnoreCasing: isSet(object.IgnoreCasing) ? globalThis.Boolean(object.IgnoreCasing) : false, }; }, toJSON(message: UniqueConstraintDefinition): unknown { const obj: any = {}; if (message.EventDefinitions?.length) { obj.EventDefinitions = message.EventDefinitions.map((e) => UniqueConstraintEventDefinition.toJSON(e)); } if (message.IgnoreCasing !== false) { obj.IgnoreCasing = message.IgnoreCasing; } return obj; }, create(base?: DeepPartial): UniqueConstraintDefinition { return UniqueConstraintDefinition.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): UniqueConstraintDefinition { const message = createBaseUniqueConstraintDefinition(); message.EventDefinitions = object.EventDefinitions?.map((e) => UniqueConstraintEventDefinition.fromPartial(e)) || []; message.IgnoreCasing = object.IgnoreCasing ?? false; return message; }, }; function createBaseUniqueConstraintEventDefinition(): UniqueConstraintEventDefinition { return { EventTypeId: "", Properties: [] }; } export const UniqueConstraintEventDefinition: MessageFns = { encode(message: UniqueConstraintEventDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.EventTypeId !== "") { writer.uint32(10).string(message.EventTypeId); } for (const v of message.Properties) { writer.uint32(18).string(v!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): UniqueConstraintEventDefinition { 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 = createBaseUniqueConstraintEventDefinition(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.EventTypeId = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.Properties.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): UniqueConstraintEventDefinition { return { EventTypeId: isSet(object.EventTypeId) ? globalThis.String(object.EventTypeId) : "", Properties: globalThis.Array.isArray(object?.Properties) ? object.Properties.map((e: any) => globalThis.String(e)) : [], }; }, toJSON(message: UniqueConstraintEventDefinition): unknown { const obj: any = {}; if (message.EventTypeId !== "") { obj.EventTypeId = message.EventTypeId; } if (message.Properties?.length) { obj.Properties = message.Properties; } return obj; }, create(base?: DeepPartial): UniqueConstraintEventDefinition { return UniqueConstraintEventDefinition.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): UniqueConstraintEventDefinition { const message = createBaseUniqueConstraintEventDefinition(); message.EventTypeId = object.EventTypeId ?? ""; message.Properties = object.Properties?.map((e) => e) || []; return message; }, }; function createBaseUniqueEventTypeConstraintDefinition(): UniqueEventTypeConstraintDefinition { return { EventTypeIds: [] }; } export const UniqueEventTypeConstraintDefinition: MessageFns = { encode(message: UniqueEventTypeConstraintDefinition, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.EventTypeIds) { writer.uint32(18).string(v!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): UniqueEventTypeConstraintDefinition { 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 = createBaseUniqueEventTypeConstraintDefinition(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 2: { if (tag !== 18) { break; } message.EventTypeIds.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): UniqueEventTypeConstraintDefinition { return { EventTypeIds: globalThis.Array.isArray(object?.EventTypeIds) ? object.EventTypeIds.map((e: any) => globalThis.String(e)) : [], }; }, toJSON(message: UniqueEventTypeConstraintDefinition): unknown { const obj: any = {}; if (message.EventTypeIds?.length) { obj.EventTypeIds = message.EventTypeIds; } return obj; }, create(base?: DeepPartial): UniqueEventTypeConstraintDefinition { return UniqueEventTypeConstraintDefinition.fromPartial(base ?? {}); }, fromPartial(object: DeepPartial): UniqueEventTypeConstraintDefinition { const message = createBaseUniqueEventTypeConstraintDefinition(); message.EventTypeIds = object.EventTypeIds?.map((e) => e) || []; return message; }, }; export type ConstraintsDefinition = typeof ConstraintsDefinition; export const ConstraintsDefinition = { name: "Constraints", fullName: "Cratis.Chronicle.Contracts.Events.Constraints.Constraints", methods: { register: { name: "Register", requestType: RegisterConstraintsRequest as typeof RegisterConstraintsRequest, requestStream: false, responseType: Empty as typeof Empty, responseStream: false, options: {}, }, }, } as const; export interface ConstraintsServiceImplementation { register(request: RegisterConstraintsRequest, context: CallContext & CallContextExt): Promise>; } export interface ConstraintsClient { register(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; }