diff --git a/docs/api/appending-events.md b/docs/api/appending-events.md index e70451c9..ff1ae122 100644 --- a/docs/api/appending-events.md +++ b/docs/api/appending-events.md @@ -195,4 +195,64 @@ const credentials = { await client.appendToStream("some-stream", event, { credentials, }); +``` + +## Append to multiple streams + +::: note +This feature is only available in KurrentDB 25.1 and later. +::: + +You can append events to multiple streams in a single atomic operation. Either all streams are updated, or the entire operation fails. + +::: warning +Currently, metadata must be valid JSON. Binary metadata will not be supported in +this version. This limitation ensures compatibility with KurrentDB's metadata +handling and will be removed in the next major release. +::: + +```ts +import { jsonEvent } from "@kurrent/kurrentdb-client"; +import { v4 as uuid } from "uuid"; + +const metadata = { + timestamp: new Date().toISOString(), + source: "OrderProcessingSystem", + version: 1.0 +}; + +const requests = [ + { + streamName: "order-stream-1", + expectedState: "any", + events: [ + jsonEvent({ + id: uuid(), + type: "OrderCreated", + data: { + orderId: "12345", + amount: 99.99 + }, + metadata + }) + ] + }, + { + streamName: "inventory-stream-1", + expectedState: "any", + events: [ + jsonEvent({ + id: uuid(), + type: "ItemReserved", + data: { + itemId: "ABC123", + quantity: 2 + }, + metadata + }) + ] + } +]; + +await client.multiStreamAppend(requests); ``` \ No newline at end of file diff --git a/docs/api/persistent-subscriptions.md b/docs/api/persistent-subscriptions.md index 5d3ce6e2..cf1bbe2f 100644 --- a/docs/api/persistent-subscriptions.md +++ b/docs/api/persistent-subscriptions.md @@ -203,6 +203,27 @@ The main aim of this strategy is to decrease the likelihood of concurrency and ordering issues while maintaining load balancing. This is **not a guarantee**, and you should handle the usual ordering and concurrency issues. +### PinnedByCorrelation + +The PinnedByCorrelation strategy is a consumer strategy available for persistent subscriptions +It ensures that events with the same correlation id are consistently delivered to the same +consumer within a subscription group. + +:::note +This strategy requires database version 21.10.1 or later. You can only create a persistent subscription +with this strategy. To change the strategy, you must delete the existing subscription and create a +new one with the desired settings. +::: + +## Updating a subscription group + +You can edit the settings of an existing subscription group while it is running, +you don't need to delete and recreate it to change settings. When you update the +subscription group, it resets itself internally, dropping the connections and +having them reconnect. You must have admin permissions to update a persistent +subscription group. + + ## Updating a subscription group You can edit the settings of an existing subscription group while it is running, diff --git a/package.json b/package.json index 81208ca9..d864bea8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "devDependencies": { "@tsconfig/node18": "^18.2.4", "@types/node": "18.19.76", + "@types/semver": "^7.7.0", "@typescript-eslint/eslint-plugin": "^8.10.0", "@typescript-eslint/parser": "^8.10.0", "cross-env": "^7.0.3", @@ -31,7 +32,7 @@ "eslint-plugin-tsdoc": "^0.2.17", "nx": "20.1.3", "prettier": "^2.8.8", - "semver": "^7.6.3", + "semver": "^7.7.2", "typescript": "^5.6.3" } } diff --git a/packages/db-client/generated/errors_grpc_pb.js b/packages/db-client/generated/errors_grpc_pb.js new file mode 100644 index 00000000..97b3a246 --- /dev/null +++ b/packages/db-client/generated/errors_grpc_pb.js @@ -0,0 +1 @@ +// GENERATED CODE -- NO SERVICES IN PROTO \ No newline at end of file diff --git a/packages/db-client/generated/errors_pb.d.ts b/packages/db-client/generated/errors_pb.d.ts new file mode 100644 index 00000000..37090aef --- /dev/null +++ b/packages/db-client/generated/errors_pb.d.ts @@ -0,0 +1,199 @@ +// package: kurrentdb.protocol.v2.streams.errors +// file: kurrentdb/protocols/v2/streams/errors.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as kurrentdb_protocols_v2_rpc_pb from "../../../../kurrentdb/protocols/v2/rpc_pb"; + +export class StreamNotFoundErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamNotFoundErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamNotFoundErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamNotFoundErrorDetails): StreamNotFoundErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamNotFoundErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamNotFoundErrorDetails; + static deserializeBinaryFromReader(message: StreamNotFoundErrorDetails, reader: jspb.BinaryReader): StreamNotFoundErrorDetails; +} + +export namespace StreamNotFoundErrorDetails { + export type AsObject = { + stream: string, + } +} + +export class StreamAlreadyExistsErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamAlreadyExistsErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamAlreadyExistsErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamAlreadyExistsErrorDetails): StreamAlreadyExistsErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamAlreadyExistsErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamAlreadyExistsErrorDetails; + static deserializeBinaryFromReader(message: StreamAlreadyExistsErrorDetails, reader: jspb.BinaryReader): StreamAlreadyExistsErrorDetails; +} + +export namespace StreamAlreadyExistsErrorDetails { + export type AsObject = { + stream: string, + } +} + +export class StreamDeletedErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamDeletedErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamDeletedErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamDeletedErrorDetails): StreamDeletedErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamDeletedErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamDeletedErrorDetails; + static deserializeBinaryFromReader(message: StreamDeletedErrorDetails, reader: jspb.BinaryReader): StreamDeletedErrorDetails; +} + +export namespace StreamDeletedErrorDetails { + export type AsObject = { + stream: string, + } +} + +export class StreamTombstonedErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamTombstonedErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamTombstonedErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamTombstonedErrorDetails): StreamTombstonedErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamTombstonedErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamTombstonedErrorDetails; + static deserializeBinaryFromReader(message: StreamTombstonedErrorDetails, reader: jspb.BinaryReader): StreamTombstonedErrorDetails; +} + +export namespace StreamTombstonedErrorDetails { + export type AsObject = { + stream: string, + } +} + +export class StreamRevisionConflictErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamRevisionConflictErrorDetails; + getExpectedRevision(): string; + setExpectedRevision(value: string): StreamRevisionConflictErrorDetails; + getActualRevision(): string; + setActualRevision(value: string): StreamRevisionConflictErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamRevisionConflictErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamRevisionConflictErrorDetails): StreamRevisionConflictErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamRevisionConflictErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamRevisionConflictErrorDetails; + static deserializeBinaryFromReader(message: StreamRevisionConflictErrorDetails, reader: jspb.BinaryReader): StreamRevisionConflictErrorDetails; +} + +export namespace StreamRevisionConflictErrorDetails { + export type AsObject = { + stream: string, + expectedRevision: string, + actualRevision: string, + } +} + +export class AppendRecordSizeExceededErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): AppendRecordSizeExceededErrorDetails; + getRecordId(): string; + setRecordId(value: string): AppendRecordSizeExceededErrorDetails; + getSize(): number; + setSize(value: number): AppendRecordSizeExceededErrorDetails; + getMaxSize(): number; + setMaxSize(value: number): AppendRecordSizeExceededErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendRecordSizeExceededErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: AppendRecordSizeExceededErrorDetails): AppendRecordSizeExceededErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendRecordSizeExceededErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendRecordSizeExceededErrorDetails; + static deserializeBinaryFromReader(message: AppendRecordSizeExceededErrorDetails, reader: jspb.BinaryReader): AppendRecordSizeExceededErrorDetails; +} + +export namespace AppendRecordSizeExceededErrorDetails { + export type AsObject = { + stream: string, + recordId: string, + size: number, + maxSize: number, + } +} + +export class AppendTransactionSizeExceededErrorDetails extends jspb.Message { + getSize(): number; + setSize(value: number): AppendTransactionSizeExceededErrorDetails; + getMaxSize(): number; + setMaxSize(value: number): AppendTransactionSizeExceededErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendTransactionSizeExceededErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: AppendTransactionSizeExceededErrorDetails): AppendTransactionSizeExceededErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendTransactionSizeExceededErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendTransactionSizeExceededErrorDetails; + static deserializeBinaryFromReader(message: AppendTransactionSizeExceededErrorDetails, reader: jspb.BinaryReader): AppendTransactionSizeExceededErrorDetails; +} + +export namespace AppendTransactionSizeExceededErrorDetails { + export type AsObject = { + size: number, + maxSize: number, + } +} + +export class StreamAlreadyInAppendSessionErrorDetails extends jspb.Message { + getStream(): string; + setStream(value: string): StreamAlreadyInAppendSessionErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): StreamAlreadyInAppendSessionErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: StreamAlreadyInAppendSessionErrorDetails): StreamAlreadyInAppendSessionErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: StreamAlreadyInAppendSessionErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): StreamAlreadyInAppendSessionErrorDetails; + static deserializeBinaryFromReader(message: StreamAlreadyInAppendSessionErrorDetails, reader: jspb.BinaryReader): StreamAlreadyInAppendSessionErrorDetails; +} + +export namespace StreamAlreadyInAppendSessionErrorDetails { + export type AsObject = { + stream: string, + } +} + +export enum StreamsError { + STREAMS_ERROR_UNSPECIFIED = 0, + STREAMS_ERROR_STREAM_NOT_FOUND = 1, + STREAMS_ERROR_STREAM_ALREADY_EXISTS = 2, + STREAMS_ERROR_STREAM_DELETED = 3, + STREAMS_ERROR_STREAM_TOMBSTONED = 4, + STREAMS_ERROR_STREAM_REVISION_CONFLICT = 5, + STREAMS_ERROR_APPEND_RECORD_SIZE_EXCEEDED = 6, + STREAMS_ERROR_APPEND_TRANSACTION_SIZE_EXCEEDED = 7, + STREAMS_ERROR_STREAM_ALREADY_IN_APPEND_SESSION = 8, + STREAMS_ERROR_APPEND_SESSION_NO_REQUESTS = 9, +} diff --git a/packages/db-client/generated/errors_pb.js b/packages/db-client/generated/errors_pb.js new file mode 100644 index 00000000..3895c096 --- /dev/null +++ b/packages/db-client/generated/errors_pb.js @@ -0,0 +1,1439 @@ +// source: kurrentdb/protocols/v2/streams/errors.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { + if (this) { return this; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + if (typeof self !== 'undefined') { return self; } + return Function('return this')(); +}.call(null)); + +var kurrentdb_protocols_v2_rpc_pb = require('../../../../kurrentdb/protocols/v2/rpc_pb.js'); +goog.object.extend(proto, kurrentdb_protocols_v2_rpc_pb); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.errors.StreamsError', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.displayName = 'proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamNotFoundErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyExistsErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamDeletedErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamTombstonedErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, ""), + expectedRevision: jspb.Message.getFieldWithDefault(msg, 2, "0"), + actualRevision: jspb.Message.getFieldWithDefault(msg, 3, "0") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setExpectedRevision(value); + break; + case 3: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setActualRevision(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getExpectedRevision(); + if (parseInt(f, 10) !== 0) { + writer.writeSint64String( + 2, + f + ); + } + f = message.getActualRevision(); + if (parseInt(f, 10) !== 0) { + writer.writeSint64String( + 3, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional sint64 expected_revision = 2; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.getExpectedRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.setExpectedRevision = function(value) { + return jspb.Message.setProto3StringIntField(this, 2, value); +}; + + +/** + * optional sint64 actual_revision = 3; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.getActualRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamRevisionConflictErrorDetails.prototype.setActualRevision = function(value) { + return jspb.Message.setProto3StringIntField(this, 3, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, ""), + recordId: jspb.Message.getFieldWithDefault(msg, 2, ""), + size: jspb.Message.getFieldWithDefault(msg, 3, 0), + maxSize: jspb.Message.getFieldWithDefault(msg, 4, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setRecordId(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt32()); + msg.setSize(value); + break; + case 4: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMaxSize(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getRecordId(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getSize(); + if (f !== 0) { + writer.writeInt32( + 3, + f + ); + } + f = message.getMaxSize(); + if (f !== 0) { + writer.writeInt32( + 4, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string record_id = 2; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.getRecordId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.setRecordId = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional int32 size = 3; + * @return {number} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.getSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.setSize = function(value) { + return jspb.Message.setProto3IntField(this, 3, value); +}; + + +/** + * optional int32 max_size = 4; + * @return {number} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.getMaxSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendRecordSizeExceededErrorDetails.prototype.setMaxSize = function(value) { + return jspb.Message.setProto3IntField(this, 4, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + size: jspb.Message.getFieldWithDefault(msg, 1, 0), + maxSize: jspb.Message.getFieldWithDefault(msg, 2, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setSize(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setMaxSize(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getSize(); + if (f !== 0) { + writer.writeInt32( + 1, + f + ); + } + f = message.getMaxSize(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * optional int32 size = 1; + * @return {number} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.getSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.setSize = function(value) { + return jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional int32 max_size = 2; + * @return {number} + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.getMaxSize = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.AppendTransactionSizeExceededErrorDetails.prototype.setMaxSize = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails; + return proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails} returns this + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamAlreadyInAppendSessionErrorDetails.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * @enum {number} + */ +proto.kurrentdb.protocol.v2.streams.errors.StreamsError = { + STREAMS_ERROR_UNSPECIFIED: 0, + STREAMS_ERROR_STREAM_NOT_FOUND: 1, + STREAMS_ERROR_STREAM_ALREADY_EXISTS: 2, + STREAMS_ERROR_STREAM_DELETED: 3, + STREAMS_ERROR_STREAM_TOMBSTONED: 4, + STREAMS_ERROR_STREAM_REVISION_CONFLICT: 5, + STREAMS_ERROR_APPEND_RECORD_SIZE_EXCEEDED: 6, + STREAMS_ERROR_APPEND_TRANSACTION_SIZE_EXCEEDED: 7, + STREAMS_ERROR_STREAM_ALREADY_IN_APPEND_SESSION: 8, + STREAMS_ERROR_APPEND_SESSION_NO_REQUESTS: 9 +}; + +goog.object.extend(exports, proto.kurrentdb.protocol.v2.streams.errors); diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/errors_grpc_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/errors_grpc_pb.js new file mode 100644 index 00000000..97b3a246 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/errors_grpc_pb.js @@ -0,0 +1 @@ +// GENERATED CODE -- NO SERVICES IN PROTO \ No newline at end of file diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.d.ts b/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.d.ts new file mode 100644 index 00000000..213ca642 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.d.ts @@ -0,0 +1,105 @@ +// package: kurrent.rpc +// file: kurrentdb/protocols/v2/errors.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as kurrentdb_protocols_v2_rpc_pb from "../../../kurrentdb/protocols/v2/rpc_pb"; + +export class AccessDeniedErrorDetails extends jspb.Message { + getOperation(): string; + setOperation(value: string): AccessDeniedErrorDetails; + + hasUsername(): boolean; + clearUsername(): void; + getUsername(): string | undefined; + setUsername(value: string): AccessDeniedErrorDetails; + + hasPermission(): boolean; + clearPermission(): void; + getPermission(): string | undefined; + setPermission(value: string): AccessDeniedErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AccessDeniedErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: AccessDeniedErrorDetails): AccessDeniedErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AccessDeniedErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AccessDeniedErrorDetails; + static deserializeBinaryFromReader(message: AccessDeniedErrorDetails, reader: jspb.BinaryReader): AccessDeniedErrorDetails; +} + +export namespace AccessDeniedErrorDetails { + export type AsObject = { + operation: string, + username?: string, + permission?: string, + } +} + +export class NotLeaderNodeErrorDetails extends jspb.Message { + + hasCurrentLeader(): boolean; + clearCurrentLeader(): void; + getCurrentLeader(): NotLeaderNodeErrorDetails.NodeInfo | undefined; + setCurrentLeader(value?: NotLeaderNodeErrorDetails.NodeInfo): NotLeaderNodeErrorDetails; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): NotLeaderNodeErrorDetails.AsObject; + static toObject(includeInstance: boolean, msg: NotLeaderNodeErrorDetails): NotLeaderNodeErrorDetails.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: NotLeaderNodeErrorDetails, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): NotLeaderNodeErrorDetails; + static deserializeBinaryFromReader(message: NotLeaderNodeErrorDetails, reader: jspb.BinaryReader): NotLeaderNodeErrorDetails; +} + +export namespace NotLeaderNodeErrorDetails { + export type AsObject = { + currentLeader?: NotLeaderNodeErrorDetails.NodeInfo.AsObject, + } + + + export class NodeInfo extends jspb.Message { + getHost(): string; + setHost(value: string): NodeInfo; + getPort(): number; + setPort(value: number): NodeInfo; + + hasNodeId(): boolean; + clearNodeId(): void; + getNodeId(): string | undefined; + setNodeId(value: string): NodeInfo; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): NodeInfo.AsObject; + static toObject(includeInstance: boolean, msg: NodeInfo): NodeInfo.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: NodeInfo, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): NodeInfo; + static deserializeBinaryFromReader(message: NodeInfo, reader: jspb.BinaryReader): NodeInfo; + } + + export namespace NodeInfo { + export type AsObject = { + host: string, + port: number, + nodeId?: string, + } + } + +} + +export enum ServerError { + UNSPECIFIED = 0, + SERVER_ERROR_ACCESS_DENIED = 1, + SERVER_ERROR_BAD_REQUEST = 2, + SERVER_ERROR_NOT_LEADER_NODE = 5, + SERVER_ERROR_OPERATION_TIMEOUT = 6, + SERVER_ERROR_SERVER_NOT_READY = 7, + SERVER_ERROR_SERVER_OVERLOADED = 8, + SERVER_ERROR_SERVER_MALFUNCTION = 9, +} diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.js new file mode 100644 index 00000000..3010c72c --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/errors_pb.js @@ -0,0 +1,692 @@ +// source: kurrentdb/protocols/v2/errors.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { + if (this) { return this; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + if (typeof self !== 'undefined') { return self; } + return Function('return this')(); +}.call(null)); + +var kurrentdb_protocols_v2_rpc_pb = require('../../../kurrentdb/protocols/v2/rpc_pb.js'); +goog.object.extend(proto, kurrentdb_protocols_v2_rpc_pb); +goog.exportSymbol('proto.kurrent.rpc.AccessDeniedErrorDetails', null, global); +goog.exportSymbol('proto.kurrent.rpc.NotLeaderNodeErrorDetails', null, global); +goog.exportSymbol('proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo', null, global); +goog.exportSymbol('proto.kurrent.rpc.ServerError', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrent.rpc.AccessDeniedErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrent.rpc.AccessDeniedErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrent.rpc.AccessDeniedErrorDetails.displayName = 'proto.kurrent.rpc.AccessDeniedErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrent.rpc.NotLeaderNodeErrorDetails, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrent.rpc.NotLeaderNodeErrorDetails.displayName = 'proto.kurrent.rpc.NotLeaderNodeErrorDetails'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.displayName = 'proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrent.rpc.AccessDeniedErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrent.rpc.AccessDeniedErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + operation: jspb.Message.getFieldWithDefault(msg, 1, ""), + username: jspb.Message.getFieldWithDefault(msg, 2, ""), + permission: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrent.rpc.AccessDeniedErrorDetails; + return proto.kurrent.rpc.AccessDeniedErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrent.rpc.AccessDeniedErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setOperation(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setUsername(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setPermission(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrent.rpc.AccessDeniedErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrent.rpc.AccessDeniedErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getOperation(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional string operation = 1; + * @return {string} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.getOperation = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} returns this + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.setOperation = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional string username = 2; + * @return {string} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.getUsername = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} returns this + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.setUsername = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} returns this + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.clearUsername = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.hasUsername = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string permission = 3; + * @return {string} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.getPermission = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} returns this + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.setPermission = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrent.rpc.AccessDeniedErrorDetails} returns this + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.clearPermission = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrent.rpc.AccessDeniedErrorDetails.prototype.hasPermission = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.toObject = function(opt_includeInstance) { + return proto.kurrent.rpc.NotLeaderNodeErrorDetails.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.toObject = function(includeInstance, msg) { + var f, obj = { + currentLeader: (f = msg.getCurrentLeader()) && proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrent.rpc.NotLeaderNodeErrorDetails; + return proto.kurrent.rpc.NotLeaderNodeErrorDetails.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo; + reader.readMessage(value,proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.deserializeBinaryFromReader); + msg.setCurrentLeader(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrent.rpc.NotLeaderNodeErrorDetails.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCurrentLeader(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.serializeBinaryToWriter + ); + } +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.toObject = function(opt_includeInstance) { + return proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.toObject = function(includeInstance, msg) { + var f, obj = { + host: jspb.Message.getFieldWithDefault(msg, 1, ""), + port: jspb.Message.getFieldWithDefault(msg, 2, 0), + nodeId: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo; + return proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setHost(value); + break; + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setPort(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setNodeId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getHost(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getPort(); + if (f !== 0) { + writer.writeInt32( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional string host = 1; + * @return {string} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.getHost = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} returns this + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.setHost = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional int32 port = 2; + * @return {number} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.getPort = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} returns this + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.setPort = function(value) { + return jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * optional string node_id = 3; + * @return {string} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.getNodeId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} returns this + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.setNodeId = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} returns this + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.clearNodeId = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo.prototype.hasNodeId = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional NodeInfo current_leader = 1; + * @return {?proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.getCurrentLeader = function() { + return /** @type{?proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo} */ ( + jspb.Message.getWrapperField(this, proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo, 1)); +}; + + +/** + * @param {?proto.kurrent.rpc.NotLeaderNodeErrorDetails.NodeInfo|undefined} value + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} returns this +*/ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.setCurrentLeader = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.kurrent.rpc.NotLeaderNodeErrorDetails} returns this + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.clearCurrentLeader = function() { + return this.setCurrentLeader(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrent.rpc.NotLeaderNodeErrorDetails.prototype.hasCurrentLeader = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * @enum {number} + */ +proto.kurrent.rpc.ServerError = { + UNSPECIFIED: 0, + SERVER_ERROR_ACCESS_DENIED: 1, + SERVER_ERROR_BAD_REQUEST: 2, + SERVER_ERROR_NOT_LEADER_NODE: 5, + SERVER_ERROR_OPERATION_TIMEOUT: 6, + SERVER_ERROR_SERVER_NOT_READY: 7, + SERVER_ERROR_SERVER_OVERLOADED: 8, + SERVER_ERROR_SERVER_MALFUNCTION: 9 +}; + +goog.object.extend(exports, proto.kurrent.rpc); diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/rpc_grpc_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_grpc_pb.js new file mode 100644 index 00000000..97b3a246 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_grpc_pb.js @@ -0,0 +1 @@ +// GENERATED CODE -- NO SERVICES IN PROTO \ No newline at end of file diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.d.ts b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.d.ts new file mode 100644 index 00000000..c4be25da --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.d.ts @@ -0,0 +1,34 @@ +// package: kurrent.rpc +// file: kurrentdb/protocols/v2/rpc.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_descriptor_pb from "google-protobuf/google/protobuf/descriptor_pb"; +import * as kurrentdb_protocols_v1_code_pb from "../../../kurrentdb/protocols/v1/code_pb"; + +export class ErrorMetadata extends jspb.Message { + getStatusCode(): kurrentdb_protocols_v1_code_pb.Code; + setStatusCode(value: kurrentdb_protocols_v1_code_pb.Code): ErrorMetadata; + getHasDetails(): boolean; + setHasDetails(value: boolean): ErrorMetadata; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): ErrorMetadata.AsObject; + static toObject(includeInstance: boolean, msg: ErrorMetadata): ErrorMetadata.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: ErrorMetadata, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): ErrorMetadata; + static deserializeBinaryFromReader(message: ErrorMetadata, reader: jspb.BinaryReader): ErrorMetadata; +} + +export namespace ErrorMetadata { + export type AsObject = { + statusCode: kurrentdb_protocols_v1_code_pb.Code, + hasDetails: boolean, + } +} + +export const error: jspb.ExtensionFieldInfo; diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.js new file mode 100644 index 00000000..95a1ae10 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/rpc_pb.js @@ -0,0 +1,236 @@ +// source: kurrentdb/protocols/v2/rpc.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { + if (this) { return this; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + if (typeof self !== 'undefined') { return self; } + return Function('return this')(); +}.call(null)); + +var google_protobuf_descriptor_pb = require('google-protobuf/google/protobuf/descriptor_pb.js'); +goog.object.extend(proto, google_protobuf_descriptor_pb); +var kurrentdb_protocols_v1_code_pb = require('../../../kurrentdb/protocols/v1/code_pb.js'); +goog.object.extend(proto, kurrentdb_protocols_v1_code_pb); +goog.exportSymbol('proto.kurrent.rpc.ErrorMetadata', null, global); +goog.exportSymbol('proto.kurrent.rpc.error', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrent.rpc.ErrorMetadata = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrent.rpc.ErrorMetadata, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrent.rpc.ErrorMetadata.displayName = 'proto.kurrent.rpc.ErrorMetadata'; +} + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrent.rpc.ErrorMetadata.prototype.toObject = function(opt_includeInstance) { + return proto.kurrent.rpc.ErrorMetadata.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrent.rpc.ErrorMetadata} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.ErrorMetadata.toObject = function(includeInstance, msg) { + var f, obj = { + statusCode: jspb.Message.getFieldWithDefault(msg, 1, 0), + hasDetails: jspb.Message.getBooleanFieldWithDefault(msg, 2, false) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrent.rpc.ErrorMetadata} + */ +proto.kurrent.rpc.ErrorMetadata.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrent.rpc.ErrorMetadata; + return proto.kurrent.rpc.ErrorMetadata.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrent.rpc.ErrorMetadata} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrent.rpc.ErrorMetadata} + */ +proto.kurrent.rpc.ErrorMetadata.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.google.rpc.Code} */ (reader.readEnum()); + msg.setStatusCode(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setHasDetails(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrent.rpc.ErrorMetadata.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrent.rpc.ErrorMetadata.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrent.rpc.ErrorMetadata} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrent.rpc.ErrorMetadata.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStatusCode(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getHasDetails(); + if (f) { + writer.writeBool( + 2, + f + ); + } +}; + + +/** + * optional google.rpc.Code status_code = 1; + * @return {!proto.google.rpc.Code} + */ +proto.kurrent.rpc.ErrorMetadata.prototype.getStatusCode = function() { + return /** @type {!proto.google.rpc.Code} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.google.rpc.Code} value + * @return {!proto.kurrent.rpc.ErrorMetadata} returns this + */ +proto.kurrent.rpc.ErrorMetadata.prototype.setStatusCode = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional bool has_details = 2; + * @return {boolean} + */ +proto.kurrent.rpc.ErrorMetadata.prototype.getHasDetails = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.kurrent.rpc.ErrorMetadata} returns this + */ +proto.kurrent.rpc.ErrorMetadata.prototype.setHasDetails = function(value) { + return jspb.Message.setProto3BooleanField(this, 2, value); +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `error`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.kurrent.rpc.error = new jspb.ExtensionFieldInfo( + 50000, + {error: 0}, + proto.kurrent.rpc.ErrorMetadata, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.kurrent.rpc.ErrorMetadata.toObject), + 0); + +google_protobuf_descriptor_pb.EnumValueOptions.extensionsBinary[50000] = new jspb.ExtensionFieldBinaryInfo( + proto.kurrent.rpc.error, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.kurrent.rpc.ErrorMetadata.serializeBinaryToWriter, + proto.kurrent.rpc.ErrorMetadata.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +google_protobuf_descriptor_pb.EnumValueOptions.extensions[50000] = proto.kurrent.rpc.error; + +goog.object.extend(exports, proto.kurrent.rpc); diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.d.ts b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.d.ts new file mode 100644 index 00000000..b3411cff --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.d.ts @@ -0,0 +1,44 @@ +// package: kurrentdb.protocol.v2.streams +// file: kurrentdb/protocols/v2/streams/streams.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as grpc from "@grpc/grpc-js"; +import * as kurrentdb_protocols_v2_streams_streams_pb from "../../../../kurrentdb/protocols/v2/streams/streams_pb"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +interface IStreamsServiceService extends grpc.ServiceDefinition { + appendSession: IStreamsServiceService_IAppendSession; +} + +interface IStreamsServiceService_IAppendSession extends grpc.MethodDefinition { + path: "/kurrentdb.protocol.v2.streams.StreamsService/AppendSession"; + requestStream: true; + responseStream: false; + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +export const StreamsServiceService: IStreamsServiceService; + +export interface IStreamsServiceServer extends grpc.UntypedServiceImplementation { + appendSession: grpc.handleClientStreamingCall; +} + +export interface IStreamsServiceClient { + appendSession(callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + appendSession(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + appendSession(options: Partial, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + appendSession(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; +} + +export class StreamsServiceClient extends grpc.Client implements IStreamsServiceClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); + public appendSession(callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + public appendSession(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + public appendSession(options: Partial, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; + public appendSession(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse) => void): grpc.ClientWritableStream; +} diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.js new file mode 100644 index 00000000..78eb9a23 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_grpc_pb.js @@ -0,0 +1,69 @@ +// GENERATED CODE -- DO NOT EDIT! + +// Original file comments: +// ****************************************************************************************** +// This protocol is UNSTABLE in the sense of being subject to change. +// ****************************************************************************************** +// +'use strict'; +var grpc = require('@grpc/grpc-js'); +var kurrentdb_protocols_v2_streams_streams_pb = require('../../../../kurrentdb/protocols/v2/streams/streams_pb.js'); +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); + +function serialize_kurrentdb_protocol_v2_streams_AppendRequest(arg) { + if (!(arg instanceof kurrentdb_protocols_v2_streams_streams_pb.AppendRequest)) { + throw new Error('Expected argument of type kurrentdb.protocol.v2.streams.AppendRequest'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_kurrentdb_protocol_v2_streams_AppendRequest(buffer_arg) { + return kurrentdb_protocols_v2_streams_streams_pb.AppendRequest.deserializeBinary(new Uint8Array(buffer_arg)); +} + +function serialize_kurrentdb_protocol_v2_streams_AppendSessionResponse(arg) { + if (!(arg instanceof kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse)) { + throw new Error('Expected argument of type kurrentdb.protocol.v2.streams.AppendSessionResponse'); + } + return Buffer.from(arg.serializeBinary()); +} + +function deserialize_kurrentdb_protocol_v2_streams_AppendSessionResponse(buffer_arg) { + return kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse.deserializeBinary(new Uint8Array(buffer_arg)); +} + + +var StreamsServiceService = exports.StreamsServiceService = { + // Appends records to multiple streams atomically within a single transaction. +// +// This is a client-streaming RPC where the client sends multiple AppendRequest messages +// (one per stream) and receives a single AppendSessionResponse upon commit. +// +// Guarantees: +// - Atomicity: All writes succeed or all fail together +// - Optimistic Concurrency: Expected revisions are validated for all streams before commit +// - Ordering: Records within each stream maintain send order +// +// Current Limitations: +// - Each stream can only appear once per session (no multiple appends to same stream) +// +// Example flow: +// 1. Client opens stream +// 2. Client sends AppendRequest for stream "orders" with 3 records +// 3. Client sends AppendRequest for stream "inventory" with 2 records +// 4. Client completes the stream +// 5. Server validates, commits, returns AppendSessionResponse with positions +appendSession: { + path: '/kurrentdb.protocol.v2.streams.StreamsService/AppendSession', + requestStream: true, + responseStream: false, + requestType: kurrentdb_protocols_v2_streams_streams_pb.AppendRequest, + responseType: kurrentdb_protocols_v2_streams_streams_pb.AppendSessionResponse, + requestSerialize: serialize_kurrentdb_protocol_v2_streams_AppendRequest, + requestDeserialize: deserialize_kurrentdb_protocol_v2_streams_AppendRequest, + responseSerialize: serialize_kurrentdb_protocol_v2_streams_AppendSessionResponse, + responseDeserialize: deserialize_kurrentdb_protocol_v2_streams_AppendSessionResponse, + }, +}; + +exports.StreamsServiceClient = grpc.makeGenericClientConstructor(StreamsServiceService, 'StreamsService'); diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.d.ts b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.d.ts new file mode 100644 index 00000000..85e1b96a --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.d.ts @@ -0,0 +1,176 @@ +// package: kurrentdb.protocol.v2.streams +// file: kurrentdb/protocols/v2/streams/streams.proto + +/* tslint:disable */ +/* eslint-disable */ + +import * as jspb from "google-protobuf"; +import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb"; + +export class AppendRequest extends jspb.Message { + getStream(): string; + setStream(value: string): AppendRequest; + clearRecordsList(): void; + getRecordsList(): Array; + setRecordsList(value: Array): AppendRequest; + addRecords(value?: AppendRecord, index?: number): AppendRecord; + + hasExpectedRevision(): boolean; + clearExpectedRevision(): void; + getExpectedRevision(): string | undefined; + setExpectedRevision(value: string): AppendRequest; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendRequest.AsObject; + static toObject(includeInstance: boolean, msg: AppendRequest): AppendRequest.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendRequest, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendRequest; + static deserializeBinaryFromReader(message: AppendRequest, reader: jspb.BinaryReader): AppendRequest; +} + +export namespace AppendRequest { + export type AsObject = { + stream: string, + recordsList: Array, + expectedRevision?: string, + } +} + +export class AppendResponse extends jspb.Message { + getStream(): string; + setStream(value: string): AppendResponse; + getStreamRevision(): string; + setStreamRevision(value: string): AppendResponse; + + hasPosition(): boolean; + clearPosition(): void; + getPosition(): string | undefined; + setPosition(value: string): AppendResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendResponse.AsObject; + static toObject(includeInstance: boolean, msg: AppendResponse): AppendResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendResponse; + static deserializeBinaryFromReader(message: AppendResponse, reader: jspb.BinaryReader): AppendResponse; +} + +export namespace AppendResponse { + export type AsObject = { + stream: string, + streamRevision: string, + position?: string, + } +} + +export class AppendSessionResponse extends jspb.Message { + clearOutputList(): void; + getOutputList(): Array; + setOutputList(value: Array): AppendSessionResponse; + addOutput(value?: AppendResponse, index?: number): AppendResponse; + getPosition(): string; + setPosition(value: string): AppendSessionResponse; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendSessionResponse.AsObject; + static toObject(includeInstance: boolean, msg: AppendSessionResponse): AppendSessionResponse.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendSessionResponse, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendSessionResponse; + static deserializeBinaryFromReader(message: AppendSessionResponse, reader: jspb.BinaryReader): AppendSessionResponse; +} + +export namespace AppendSessionResponse { + export type AsObject = { + outputList: Array, + position: string, + } +} + +export class SchemaInfo extends jspb.Message { + getFormat(): SchemaFormat; + setFormat(value: SchemaFormat): SchemaInfo; + getName(): string; + setName(value: string): SchemaInfo; + + hasId(): boolean; + clearId(): void; + getId(): string | undefined; + setId(value: string): SchemaInfo; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): SchemaInfo.AsObject; + static toObject(includeInstance: boolean, msg: SchemaInfo): SchemaInfo.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: SchemaInfo, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): SchemaInfo; + static deserializeBinaryFromReader(message: SchemaInfo, reader: jspb.BinaryReader): SchemaInfo; +} + +export namespace SchemaInfo { + export type AsObject = { + format: SchemaFormat, + name: string, + id?: string, + } +} + +export class AppendRecord extends jspb.Message { + + hasRecordId(): boolean; + clearRecordId(): void; + getRecordId(): string | undefined; + setRecordId(value: string): AppendRecord; + + getPropertiesMap(): jspb.Map; + clearPropertiesMap(): void; + + hasSchema(): boolean; + clearSchema(): void; + getSchema(): SchemaInfo | undefined; + setSchema(value?: SchemaInfo): AppendRecord; + getData(): Uint8Array | string; + getData_asU8(): Uint8Array; + getData_asB64(): string; + setData(value: Uint8Array | string): AppendRecord; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AppendRecord.AsObject; + static toObject(includeInstance: boolean, msg: AppendRecord): AppendRecord.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + static serializeBinaryToWriter(message: AppendRecord, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AppendRecord; + static deserializeBinaryFromReader(message: AppendRecord, reader: jspb.BinaryReader): AppendRecord; +} + +export namespace AppendRecord { + export type AsObject = { + recordId?: string, + + propertiesMap: Array<[string, google_protobuf_struct_pb.Value.AsObject]>, + schema?: SchemaInfo.AsObject, + data: Uint8Array | string, + } +} + +export enum SchemaFormat { + SCHEMA_FORMAT_UNSPECIFIED = 0, + SCHEMA_FORMAT_JSON = 1, + SCHEMA_FORMAT_PROTOBUF = 2, + SCHEMA_FORMAT_AVRO = 3, + SCHEMA_FORMAT_BYTES = 4, +} + +export enum ExpectedRevisionConstants { + EXPECTED_REVISION_CONSTANTS_SINGLE_EVENT = 0, + EXPECTED_REVISION_CONSTANTS_NO_STREAM = -1, + EXPECTED_REVISION_CONSTANTS_ANY = -2, + EXPECTED_REVISION_CONSTANTS_EXISTS = -4, +} diff --git a/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.js b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.js new file mode 100644 index 00000000..7aef0d25 --- /dev/null +++ b/packages/db-client/generated/kurrentdb/protocols/v2/streams/streams_pb.js @@ -0,0 +1,1289 @@ +// source: kurrentdb/protocols/v2/streams/streams.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +var jspb = require('google-protobuf'); +var goog = jspb; +var global = (function() { + if (this) { return this; } + if (typeof window !== 'undefined') { return window; } + if (typeof global !== 'undefined') { return global; } + if (typeof self !== 'undefined') { return self; } + return Function('return this')(); +}.call(null)); + +var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js'); +goog.object.extend(proto, google_protobuf_struct_pb); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.AppendRecord', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.AppendRequest', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.AppendResponse', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.AppendSessionResponse', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.ExpectedRevisionConstants', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.SchemaFormat', null, global); +goog.exportSymbol('proto.kurrentdb.protocol.v2.streams.SchemaInfo', null, global); +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.kurrentdb.protocol.v2.streams.AppendRequest.repeatedFields_, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.AppendRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.AppendRequest.displayName = 'proto.kurrentdb.protocol.v2.streams.AppendRequest'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.AppendResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.AppendResponse.displayName = 'proto.kurrentdb.protocol.v2.streams.AppendResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.repeatedFields_, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.AppendSessionResponse, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.displayName = 'proto.kurrentdb.protocol.v2.streams.AppendSessionResponse'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.SchemaInfo, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.SchemaInfo.displayName = 'proto.kurrentdb.protocol.v2.streams.SchemaInfo'; +} +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.kurrentdb.protocol.v2.streams.AppendRecord, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.kurrentdb.protocol.v2.streams.AppendRecord.displayName = 'proto.kurrentdb.protocol.v2.streams.AppendRecord'; +} + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.AppendRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRequest} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, ""), + recordsList: jspb.Message.toObjectList(msg.getRecordsList(), + proto.kurrentdb.protocol.v2.streams.AppendRecord.toObject, includeInstance), + expectedRevision: jspb.Message.getFieldWithDefault(msg, 3, "0") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.AppendRequest; + return proto.kurrentdb.protocol.v2.streams.AppendRequest.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRequest} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + case 2: + var value = new proto.kurrentdb.protocol.v2.streams.AppendRecord; + reader.readMessage(value,proto.kurrentdb.protocol.v2.streams.AppendRecord.deserializeBinaryFromReader); + msg.addRecords(value); + break; + case 3: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setExpectedRevision(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.AppendRequest.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRequest} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getRecordsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.kurrentdb.protocol.v2.streams.AppendRecord.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeSint64String( + 3, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * repeated AppendRecord records = 2; + * @return {!Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.getRecordsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.kurrentdb.protocol.v2.streams.AppendRecord, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} returns this +*/ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.setRecordsList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 2, value); +}; + + +/** + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRecord=} opt_value + * @param {number=} opt_index + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.addRecords = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.kurrentdb.protocol.v2.streams.AppendRecord, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.clearRecordsList = function() { + return this.setRecordsList([]); +}; + + +/** + * optional sint64 expected_revision = 3; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.getExpectedRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.setExpectedRevision = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRequest} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.clearExpectedRevision = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrentdb.protocol.v2.streams.AppendRequest.prototype.hasExpectedRevision = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.AppendResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.AppendResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.toObject = function(includeInstance, msg) { + var f, obj = { + stream: jspb.Message.getFieldWithDefault(msg, 1, ""), + streamRevision: jspb.Message.getFieldWithDefault(msg, 2, "0"), + position: jspb.Message.getFieldWithDefault(msg, 3, "0") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.AppendResponse; + return proto.kurrentdb.protocol.v2.streams.AppendResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStream(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setStreamRevision(value); + break; + case 3: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setPosition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.AppendResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getStream(); + if (f.length > 0) { + writer.writeString( + 1, + f + ); + } + f = message.getStreamRevision(); + if (parseInt(f, 10) !== 0) { + writer.writeSint64String( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeSint64String( + 3, + f + ); + } +}; + + +/** + * optional string stream = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.getStream = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.setStream = function(value) { + return jspb.Message.setProto3StringField(this, 1, value); +}; + + +/** + * optional sint64 stream_revision = 2; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.getStreamRevision = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.setStreamRevision = function(value) { + return jspb.Message.setProto3StringIntField(this, 2, value); +}; + + +/** + * optional sint64 position = 3; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.getPosition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.setPosition = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.clearPosition = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrentdb.protocol.v2.streams.AppendResponse.prototype.hasPosition = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.repeatedFields_ = [1]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.toObject = function(includeInstance, msg) { + var f, obj = { + outputList: jspb.Message.toObjectList(msg.getOutputList(), + proto.kurrentdb.protocol.v2.streams.AppendResponse.toObject, includeInstance), + position: jspb.Message.getFieldWithDefault(msg, 2, "0") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.AppendSessionResponse; + return proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.kurrentdb.protocol.v2.streams.AppendResponse; + reader.readMessage(value,proto.kurrentdb.protocol.v2.streams.AppendResponse.deserializeBinaryFromReader); + msg.addOutput(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setPosition(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getOutputList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 1, + f, + proto.kurrentdb.protocol.v2.streams.AppendResponse.serializeBinaryToWriter + ); + } + f = message.getPosition(); + if (parseInt(f, 10) !== 0) { + writer.writeSint64String( + 2, + f + ); + } +}; + + +/** + * repeated AppendResponse output = 1; + * @return {!Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.getOutputList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.kurrentdb.protocol.v2.streams.AppendResponse, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} returns this +*/ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.setOutputList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.kurrentdb.protocol.v2.streams.AppendResponse=} opt_value + * @param {number=} opt_index + * @return {!proto.kurrentdb.protocol.v2.streams.AppendResponse} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.addOutput = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.kurrentdb.protocol.v2.streams.AppendResponse, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.clearOutputList = function() { + return this.setOutputList([]); +}; + + +/** + * optional sint64 position = 2; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.getPosition = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendSessionResponse} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendSessionResponse.prototype.setPosition = function(value) { + return jspb.Message.setProto3StringIntField(this, 2, value); +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.SchemaInfo.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.toObject = function(includeInstance, msg) { + var f, obj = { + format: jspb.Message.getFieldWithDefault(msg, 1, 0), + name: jspb.Message.getFieldWithDefault(msg, 2, ""), + id: jspb.Message.getFieldWithDefault(msg, 3, "") + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.SchemaInfo; + return proto.kurrentdb.protocol.v2.streams.SchemaInfo.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.kurrentdb.protocol.v2.streams.SchemaFormat} */ (reader.readEnum()); + msg.setFormat(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setName(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.SchemaInfo.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getFormat(); + if (f !== 0.0) { + writer.writeEnum( + 1, + f + ); + } + f = message.getName(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } +}; + + +/** + * optional SchemaFormat format = 1; + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaFormat} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.getFormat = function() { + return /** @type {!proto.kurrentdb.protocol.v2.streams.SchemaFormat} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {!proto.kurrentdb.protocol.v2.streams.SchemaFormat} value + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} returns this + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.setFormat = function(value) { + return jspb.Message.setProto3EnumField(this, 1, value); +}; + + +/** + * optional string name = 2; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} returns this + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.setName = function(value) { + return jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string id = 3; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} returns this + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.setId = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrentdb.protocol.v2.streams.SchemaInfo} returns this + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.clearId = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrentdb.protocol.v2.streams.SchemaInfo.prototype.hasId = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.toObject = function(opt_includeInstance) { + return proto.kurrentdb.protocol.v2.streams.AppendRecord.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRecord} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.toObject = function(includeInstance, msg) { + var f, obj = { + recordId: jspb.Message.getFieldWithDefault(msg, 1, ""), + propertiesMap: (f = msg.getPropertiesMap()) ? f.toObject(includeInstance, proto.google.protobuf.Value.toObject) : [], + schema: (f = msg.getSchema()) && proto.kurrentdb.protocol.v2.streams.SchemaInfo.toObject(includeInstance, f), + data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.kurrentdb.protocol.v2.streams.AppendRecord; + return proto.kurrentdb.protocol.v2.streams.AppendRecord.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRecord} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setRecordId(value); + break; + case 2: + var value = msg.getPropertiesMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.google.protobuf.Value.deserializeBinaryFromReader, "", new proto.google.protobuf.Value()); + }); + break; + case 3: + var value = new proto.kurrentdb.protocol.v2.streams.SchemaInfo; + reader.readMessage(value,proto.kurrentdb.protocol.v2.streams.SchemaInfo.deserializeBinaryFromReader); + msg.setSchema(value); + break; + case 4: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.kurrentdb.protocol.v2.streams.AppendRecord.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.kurrentdb.protocol.v2.streams.AppendRecord} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getPropertiesMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.google.protobuf.Value.serializeBinaryToWriter); + } + f = message.getSchema(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.kurrentdb.protocol.v2.streams.SchemaInfo.serializeBinaryToWriter + ); + } + f = message.getData_asU8(); + if (f.length > 0) { + writer.writeBytes( + 4, + f + ); + } +}; + + +/** + * optional string record_id = 1; + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getRecordId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.setRecordId = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.clearRecordId = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.hasRecordId = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * map properties = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getPropertiesMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + proto.google.protobuf.Value)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.clearPropertiesMap = function() { + this.getPropertiesMap().clear(); + return this;}; + + +/** + * optional SchemaInfo schema = 3; + * @return {?proto.kurrentdb.protocol.v2.streams.SchemaInfo} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getSchema = function() { + return /** @type{?proto.kurrentdb.protocol.v2.streams.SchemaInfo} */ ( + jspb.Message.getWrapperField(this, proto.kurrentdb.protocol.v2.streams.SchemaInfo, 3)); +}; + + +/** + * @param {?proto.kurrentdb.protocol.v2.streams.SchemaInfo|undefined} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this +*/ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.setSchema = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.clearSchema = function() { + return this.setSchema(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.hasSchema = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional bytes data = 4; + * @return {!(string|Uint8Array)} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * optional bytes data = 4; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 4; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.kurrentdb.protocol.v2.streams.AppendRecord} returns this + */ +proto.kurrentdb.protocol.v2.streams.AppendRecord.prototype.setData = function(value) { + return jspb.Message.setProto3BytesField(this, 4, value); +}; + + +/** + * @enum {number} + */ +proto.kurrentdb.protocol.v2.streams.SchemaFormat = { + SCHEMA_FORMAT_UNSPECIFIED: 0, + SCHEMA_FORMAT_JSON: 1, + SCHEMA_FORMAT_PROTOBUF: 2, + SCHEMA_FORMAT_AVRO: 3, + SCHEMA_FORMAT_BYTES: 4 +}; + +/** + * @enum {number} + */ +proto.kurrentdb.protocol.v2.streams.ExpectedRevisionConstants = { + EXPECTED_REVISION_CONSTANTS_SINGLE_EVENT: 0, + EXPECTED_REVISION_CONSTANTS_NO_STREAM: -1, + EXPECTED_REVISION_CONSTANTS_ANY: -2, + EXPECTED_REVISION_CONSTANTS_EXISTS: -4 +}; + +goog.object.extend(exports, proto.kurrentdb.protocol.v2.streams); diff --git a/packages/db-client/package.json b/packages/db-client/package.json index d12a4b3a..21093e00 100644 --- a/packages/db-client/package.json +++ b/packages/db-client/package.json @@ -52,9 +52,11 @@ "@types/node": "^22.10.2", "debug": "^4.4.0", "google-protobuf": "^3.21.4", + "semver": "^7.7.2", "uuid": "11.0.3" }, "devDependencies": { + "@types/semver": "^7.7.0", "@types/uuid": "^10.0.0", "grpc-tools": "^1.12.4", "grpc_tools_node_protoc_ts": "^5.3.3", diff --git a/packages/db-client/protos/kurrentdb/protocols/v2/errors.proto b/packages/db-client/protos/kurrentdb/protocols/v2/errors.proto new file mode 100644 index 00000000..981ad47e --- /dev/null +++ b/packages/db-client/protos/kurrentdb/protocols/v2/errors.proto @@ -0,0 +1,152 @@ +// ****************************************************************************************** +// This protocol is UNSTABLE in the sense of being subject to change. +// ****************************************************************************************** + +syntax = "proto3"; + +package kurrent.rpc; + +option csharp_namespace = "KurrentDB.Protocol.V2.Common.Errors"; + +import "kurrentdb/protocols/v2/rpc.proto"; + +// The canonical server error codes for the Kurrent Platform gRPC APIs. +// These errors represent common failure modes across all Kurrent services. +enum ServerError { + // Default value. This value is not used. + // An error code MUST always be set to a non-zero value. + // If an error code is not explicitly set, it MUST be treated as + // an internal server error (INTERNAL). + UNSPECIFIED = 0; + + // Authentication or authorization failure. + // The client lacks valid credentials or sufficient permissions to perform the requested operation. + // + // Common causes: + // - Missing or invalid authentication tokens + // - Insufficient permissions for the operation + // - Expired credentials + // + // Client action: Check credentials, verify permissions, and re-authenticate if necessary. + // Not retriable without fixing the underlying authorization issue. + SERVER_ERROR_ACCESS_DENIED = 1 [(kurrent.rpc.error) = { + status_code: PERMISSION_DENIED, + has_details: true + }]; + + // The request is malformed or contains invalid data. + // The server cannot process the request due to client error. + // + // Common causes: + // - Invalid field values (e.g., empty required fields, out-of-range numbers) + // - Malformed data formats + // - Validation failures + // + // Client action: Fix the request data and retry. + // Not retriable without modifying the request. + SERVER_ERROR_BAD_REQUEST = 2 [(kurrent.rpc.error) = { + status_code: INVALID_ARGUMENT, + has_details: true + }]; + + // The server is not the cluster leader and cannot process write operations. + // In a clustered deployment, only the leader node can accept write operations. + // + // Common causes: + // - Client connected to a follower node + // - Leader election in progress + // - Network partition + // + // Client action: Redirect the request to the leader node indicated in the error details. + // Retriable after redirecting to the correct leader node. + SERVER_ERROR_NOT_LEADER_NODE = 5 [(kurrent.rpc.error) = { + status_code: FAILED_PRECONDITION, + has_details: true + }]; + + // The operation did not complete within the configured timeout period. + // + // Common causes: + // - Slow disk I/O during writes + // - Cluster consensus delays + // - Network latency + // - Heavy server load + // + // Client action: Retry with exponential backoff. Consider increasing timeout values. + // Retriable - the operation may succeed on retry. + SERVER_ERROR_OPERATION_TIMEOUT = 6 [(kurrent.rpc.error) = { + status_code: DEADLINE_EXCEEDED + }]; + + // The server is starting up or shutting down and cannot process requests. + // + // Common causes: + // - Server is initializing (loading indexes, recovering state) + // - Server is performing graceful shutdown + // - Server is performing maintenance operations + // + // Client action: Retry with exponential backoff. Wait for server to become ready. + // Retriable - the server will become available after initialization completes. + SERVER_ERROR_SERVER_NOT_READY = 7 [(kurrent.rpc.error) = { + status_code: UNAVAILABLE + }]; + + // The server is temporarily overloaded and cannot accept more requests. + // This is a backpressure mechanism to prevent server overload. + // + // Common causes: + // - Too many concurrent requests + // - Resource exhaustion (CPU, memory, disk I/O) + // - Rate limiting triggered + // + // Client action: Retry with exponential backoff. Reduce request rate. + // Retriable - the server may accept requests after load decreases. + SERVER_ERROR_SERVER_OVERLOADED = 8 [(kurrent.rpc.error) = { + status_code: UNAVAILABLE + }]; + + // An internal server error occurred. + // This indicates a bug or unexpected condition in the server. + // + // Common causes: + // - Unhandled exceptions + // - Assertion failures + // - Corrupted internal state + // - Programming errors + // + // Client action: Report to server administrators with request details. + // May be retriable, but likely indicates a server-side issue requiring investigation. + SERVER_ERROR_SERVER_MALFUNCTION = 9 [(kurrent.rpc.error) = { + status_code: INTERNAL + }]; +} + +// Details for ACCESS_DENIED errors. +message AccessDeniedErrorDetails { + // The friendly name of the operation that was denied. + string operation = 1; + + // The username of the user who was denied access. + optional string username = 2; + + // The permission that was required for this operation. + optional string permission = 3; +} + +// Details for NOT_LEADER_NODE errors. +message NotLeaderNodeErrorDetails { + // Information about the current cluster leader node. + NodeInfo current_leader = 1; + + // Information about a cluster node. + message NodeInfo { + // The hostname or IP address of the node. + string host = 1; + + // The gRPC port of the node. + int32 port = 2; + + // The unique instance ID of the node. + optional string node_id = 3; + } +} \ No newline at end of file diff --git a/packages/db-client/protos/kurrentdb/protocols/v2/rpc.proto b/packages/db-client/protos/kurrentdb/protocols/v2/rpc.proto new file mode 100644 index 00000000..c06de032 --- /dev/null +++ b/packages/db-client/protos/kurrentdb/protocols/v2/rpc.proto @@ -0,0 +1,74 @@ +// ****************************************************************************************** +// This protocol is UNSTABLE in the sense of being subject to change. +// ****************************************************************************************** + +syntax = "proto3"; + +package kurrent.rpc; + +option csharp_namespace = "Kurrent.Rpc"; + +import "google/protobuf/descriptor.proto"; +import "kurrentdb/protocols/v1/code.proto"; + +// ErrorMetadata provides actionable information for error enum values to enable automated +// code generation, documentation, and consistent error handling across the Kurrent platform. +// +// It was modeled to support a single details type per error code to simplify code generation and +// validation. If multiple detail types are needed for a single error code, consider defining +// separate error codes for each detail type. Or, use a union type (oneof) in the detail message +// to encapsulate multiple detail variants within a single detail message. +// +// More however DebugInfo and RetryInfo can and should be added to any error regardless of +// this setting, when applicable. +// +// This annotation is applied to enum values using the google.protobuf.EnumValueOptions +// extension mechanism. It enables: +// - Automatic gRPC status code mapping +// - Code generation for error handling utilities +// - Documentation generation +// - Type-safe error detail validation +// +// Usage Example: +// enum StreamErrorCode { +// REVISION_CONFLICT = 5 [(kurrent.rpc.error) = { +// status_code: FAILED_PRECONDITION, +// has_details: true +// }]; +// } +// +// See individual field documentation for conventions and defaults. +message ErrorMetadata { + // Maps the error to a standard gRPC status code for transport-level compatibility. + // This field is REQUIRED for every error annotation. + // + // Use standard gRPC status codes from `google.rpc.code`. + // + // Code generators use this to: + // - Map errors to gRPC status codes automatically + // - Generate HTTP status code mappings + // - Create transport-agnostic error handling + google.rpc.Code status_code = 1; + + // Indicates whether this error supports rich, typed detail messages. + // Defaults to false (simple message string only). + // The message type name must be derived from the enum name by convention. + // Mask: {EnumValue}ErrorDetails, {EnumValue}Error, {EnumValue} + // + // Examples: + // ACCESS_DENIED -> "AccessDeniedErrorDetails", "AccessDeniedError" or "AccessDenied" + // SERVER_NOT_READY -> "ServerNotReadyErrorDetails", "ServerNotReadyError" or "ServerNotReady" + // + // Code generators use the message type name to: + // - Validate that the detail message matches the expected type + // - Generate type-safe error handling code + // - Create accurate documentation + bool has_details = 2; +} + +// Extend EnumValueOptions to include error information for enum values +extend google.protobuf.EnumValueOptions { + // Provides additional information about error conditions for automated + // code generation and documentation. + optional ErrorMetadata error = 50000; +} \ No newline at end of file diff --git a/packages/db-client/protos/kurrentdb/protocols/v2/streams/errors.proto b/packages/db-client/protos/kurrentdb/protocols/v2/streams/errors.proto new file mode 100644 index 00000000..853371c6 --- /dev/null +++ b/packages/db-client/protos/kurrentdb/protocols/v2/streams/errors.proto @@ -0,0 +1,213 @@ +// ****************************************************************************************** +// This protocol is UNSTABLE in the sense of being subject to change. +// ****************************************************************************************** + +syntax = "proto3"; + +package kurrentdb.protocol.v2.streams.errors; + +option csharp_namespace = "KurrentDB.Protocol.V2.Streams.Errors"; + +import "kurrentdb/protocols/v2/rpc.proto"; + +// Error codes specific to the Streams API. +// These errors represent failure modes when working with streams of records. +enum StreamsError { + // Default value. This value is not used. + // An error code MUST always be set to a non-zero value. + // If an error code is not explicitly set, it MUST be treated as + // an internal server error (INTERNAL). + STREAMS_ERROR_UNSPECIFIED = 0; + + // The requested stream does not exist in the database. + // + // Common causes: + // - Stream name typo or incorrect stream identifier + // - Stream was never created (no events appended yet) + // - Stream was deleted and not yet recreated + // + // Client action: Verify the stream name is correct. Create the stream by appending to it. + // Recoverable by creating the stream first (append with NO_STREAM expected revision). + STREAMS_ERROR_STREAM_NOT_FOUND = 1 [(kurrent.rpc.error) = { + status_code: NOT_FOUND, + has_details: true, + }]; + + // The stream already exists when an operation expected it not to exist. + // + // Common causes: + // - Attempting to create a stream that already has events + // - Using NO_STREAM expected revision on an existing stream + // - Race condition with concurrent stream creation + // + // Client action: Use the existing stream or use a different expected revision. + // Recoverable by adjusting the expected revision or using the existing stream. + STREAMS_ERROR_STREAM_ALREADY_EXISTS = 2 [(kurrent.rpc.error) = { + status_code: ALREADY_EXISTS, + has_details: true + }]; + + // The stream has been soft deleted. + // Soft-deleted streams are hidden from stream lists but can be restored by appending to them. + // + // Common causes: + // - Stream was explicitly soft-deleted via delete operation + // - Attempting to read from a soft-deleted stream + // + // Client action: Restore the stream by appending new events, or accept that the stream is deleted. + // Recoverable by appending to the stream to restore it. + STREAMS_ERROR_STREAM_DELETED = 3 [(kurrent.rpc.error) = { + status_code: FAILED_PRECONDITION, + has_details: true + }]; + + // The stream has been tombstoned (permanently deleted). + // Tombstoned streams cannot be restored and will never accept new events. + // + // Common causes: + // - Stream was explicitly tombstoned via tombstone operation + // - Administrative deletion of sensitive data + // - Attempting to write to or read from a tombstoned stream + // + // Client action: Stream is permanently removed. Create a new stream with a different name if needed. + // Not recoverable - the stream cannot be restored. + STREAMS_ERROR_STREAM_TOMBSTONED = 4 [(kurrent.rpc.error) = { + status_code: FAILED_PRECONDITION, + has_details: true + }]; + + // The expected revision does not match the actual stream revision. + // This is an optimistic concurrency control failure. + // + // Common causes: + // - Another client modified the stream concurrently + // - Client has stale state about the stream revision + // - Race condition in distributed system + // + // Client action: Fetch the current stream revision and retry with the correct expected revision. + // Recoverable by reading the current state and retrying with proper optimistic concurrency control. + STREAMS_ERROR_STREAM_REVISION_CONFLICT = 5 [(kurrent.rpc.error) = { + status_code: FAILED_PRECONDITION, + has_details: true + }]; + + // A single record being appended exceeds the maximum allowed size. + // + // Common causes: + // - Record payload is too large (exceeds server's max record size configuration) + // - Excessive metadata in properties + // - Large binary data without chunking + // + // Client action: Reduce record size, split large payloads across multiple records, or increase server limits. + // Recoverable by reducing record size or adjusting server configuration. + STREAMS_ERROR_APPEND_RECORD_SIZE_EXCEEDED = 6 [(kurrent.rpc.error) = { + status_code: INVALID_ARGUMENT, + has_details: true + }]; + + // The total size of all records in a single append session exceeds the maximum allowed transaction size. + // + // Common causes: + // - Too many records in a single append session + // - Combined payload size exceeds server's max transaction size + // - Attempting to write very large batches + // + // Client action: Split the append into multiple smaller transactions. + // Recoverable by reducing the number of records per append session. + STREAMS_ERROR_APPEND_TRANSACTION_SIZE_EXCEEDED = 7 [(kurrent.rpc.error) = { + status_code: ABORTED, + has_details: true + }]; + + // The same stream appears multiple times in a single append session. + // This is currently not supported to prevent complexity with expected revisions and ordering. + // + // Common causes: + // - Accidentally appending to the same stream twice in one session + // - Application logic error in batch operations + // + // Client action: Remove duplicate streams from the append session or split into multiple sessions. + // Recoverable by restructuring the append session to reference each stream only once. + STREAMS_ERROR_STREAM_ALREADY_IN_APPEND_SESSION = 8 [(kurrent.rpc.error) = { + status_code: ABORTED, + has_details: true + }]; + + // An append session was started but no append requests were sent before completing the stream. + // + // Common causes: + // - Client completed the stream without sending any AppendRequest messages + // - Application logic error + // + // Client action: Ensure at least one AppendRequest is sent before completing the stream. + // Recoverable by properly implementing the append session protocol. + STREAMS_ERROR_APPEND_SESSION_NO_REQUESTS = 9 [(kurrent.rpc.error) = { + status_code: FAILED_PRECONDITION + }]; +} + +// Details for STREAM_NOT_FOUND errors. +message StreamNotFoundErrorDetails { + // The name of the stream that was not found. + string stream = 1; +} + +// Details for STREAM_ALREADY_EXISTS errors. +message StreamAlreadyExistsErrorDetails { + // The name of the stream that already exists. + string stream = 1; +} + +// Details for STREAM_DELETED errors. +message StreamDeletedErrorDetails { + // The name of the stream that was deleted. + string stream = 1; +} + +// Details for STREAM_TOMBSTONED errors. +message StreamTombstonedErrorDetails { + // The name of the stream that was tombstoned. + string stream = 1; +} + +// Details for STREAM_REVISION_CONFLICT errors. +message StreamRevisionConflictErrorDetails { + // The name of the stream that had a revision conflict. + string stream = 1; + + // The expected revision that was provided in the append request. + sint64 expected_revision = 2 [jstype = JS_STRING]; + + // The actual current revision of the stream. + sint64 actual_revision = 3 [jstype = JS_STRING]; +} + +// Details for APPEND_RECORD_SIZE_EXCEEDED errors. +message AppendRecordSizeExceededErrorDetails { + // The name of the stream where the append was attempted. + string stream = 1; + + // The identifier of the record that exceeded the size limit. + string record_id = 2; + + // The actual size of the record in bytes. + int32 size = 3; + + // The maximum allowed size of a single record in bytes. + int32 max_size = 4; +} + +// Details for APPEND_TRANSACTION_SIZE_EXCEEDED errors. +message AppendTransactionSizeExceededErrorDetails { + // The actual size of the transaction in bytes. + int32 size = 1; + + // The maximum allowed size of an append transaction in bytes. + int32 max_size = 2; +} + +// Details for STREAM_ALREADY_IN_APPEND_SESSION errors. +message StreamAlreadyInAppendSessionErrorDetails { + // The name of the stream that appears multiple times. + string stream = 1; +} \ No newline at end of file diff --git a/packages/db-client/protos/kurrentdb/protocols/v2/streams/streams.proto b/packages/db-client/protos/kurrentdb/protocols/v2/streams/streams.proto new file mode 100644 index 00000000..46a0e742 --- /dev/null +++ b/packages/db-client/protos/kurrentdb/protocols/v2/streams/streams.proto @@ -0,0 +1,155 @@ +// ****************************************************************************************** +// This protocol is UNSTABLE in the sense of being subject to change. +// ****************************************************************************************** + +syntax = "proto3"; + +package kurrentdb.protocol.v2.streams; + +option csharp_namespace = "KurrentDB.Protocol.V2.Streams"; + +import "google/protobuf/struct.proto"; + +service StreamsService { + // Appends records to multiple streams atomically within a single transaction. + // + // This is a client-streaming RPC where the client sends multiple AppendRequest messages + // (one per stream) and receives a single AppendSessionResponse upon commit. + // + // Guarantees: + // - Atomicity: All writes succeed or all fail together + // - Optimistic Concurrency: Expected revisions are validated for all streams before commit + // - Ordering: Records within each stream maintain send order + // + // Current Limitations: + // - Each stream can only appear once per session (no multiple appends to same stream) + // + // Example flow: + // 1. Client opens stream + // 2. Client sends AppendRequest for stream "orders" with 3 records + // 3. Client sends AppendRequest for stream "inventory" with 2 records + // 4. Client completes the stream + // 5. Server validates, commits, returns AppendSessionResponse with positions + rpc AppendSession(stream AppendRequest) returns (AppendSessionResponse); +} + +// Represents the input for appending records to a specific stream. +message AppendRequest { + // The stream to append records to. + string stream = 1; + + // The records to append to the stream. + repeated AppendRecord records = 2; + + // The expected revision for optimistic concurrency control. + // Can be either: + // - A specific revision number (0, 1, 2, ...) - the stream must be at exactly this revision + // - An ExpectedRevisionConstants value (-4, -2, -1) for special semantics + // + // If omitted, defaults to EXPECTED_REVISION_CONSTANTS_ANY (-2). + optional sint64 expected_revision = 3 [jstype = JS_STRING]; +} + +// Represents the outcome of an append operation. +message AppendResponse { + // The stream to which records were appended. + string stream = 1; + + // The actual/current revision of the stream after the append. + // This is the revision number of the last record written to this stream. + sint64 stream_revision = 2 [jstype = JS_STRING]; + + // The position of the last appended record in the global log. + optional sint64 position = 3 [jstype = JS_STRING]; +} + +message AppendSessionResponse { + // The results of each append request in the session. + repeated AppendResponse output = 1; + + // The global commit position of the last appended record in the session. + sint64 position = 2 [jstype = JS_STRING]; +} + +// Represents the data format of the schema. +enum SchemaFormat { + // Default value, should not be used. + SCHEMA_FORMAT_UNSPECIFIED = 0; + SCHEMA_FORMAT_JSON = 1; + SCHEMA_FORMAT_PROTOBUF = 2; + SCHEMA_FORMAT_AVRO = 3; + SCHEMA_FORMAT_BYTES = 4; +} + +// Schema information for record validation and interpretation. +message SchemaInfo { + // The format of the data payload. + // Determines how the bytes in AppendRecord.data should be interpreted. + SchemaFormat format = 1; + + // The schema name (replaces the legacy "event type" concept). + // Identifies what kind of data this record contains. + // + // Common naming formats: + // - Kebab-case: "order-placed", "customer-registered" + // - URN format: "urn:kurrentdb:events:order-placed:v1" + // - Dotted namespace: "Teams.Player.V1", "Orders.OrderPlaced.V2" + // - Reverse domain: "com.acme.orders.placed" + string name = 2; + + // The identifier of the specific version of the schema that the record payload + // conforms to. This should match a registered schema version in the system. + // Not necessary when not enforcing schema validation. + optional string id = 3; +} + +// Record to be appended to a stream. +message AppendRecord { + // Unique identifier for this record (must be a valid UUID/GUID). + // If not provided, the server will generate a new one. + optional string record_id = 1; + + // A collection of properties providing additional information about the + // record. Can contain user-defined or system propreties. + // System keys will be prefixed with "$" (e.g., "$timestamp"). + // User-defined keys MUST NOT start with "$". + // + // Common examples: + // User metadata: + // - "user-id": "12345" + // - "tenant": "acme-corp" + // - "source": "mobile-app" + // + // System metadata (with $ prefix): + // - "$trace-id": "4bf92f3577b34da6a3ce929d0e0e4736" // OpenTelemetry trace ID + // - "$span-id": "00f067aa0ba902b7" // OpenTelemetry span ID + // - "$timestamp": "2025-01-15T10:30:00.000Z" // ISO 8601 timestamp + map properties = 2; + + // Schema information for this record. + SchemaInfo schema = 3; + + // The record payload as raw bytes. + // The format specified in SchemaInfo determines how to interpret these bytes. + bytes data = 4; +} + +// Constants for expected revision validation in optimistic concurrency control. +// These can be used in the expected_revision field, or you can specify an actual revision number. +enum ExpectedRevisionConstants { + // The stream must have exactly one event at revision 0. + // Used for scenarios requiring strict single-event semantics. + EXPECTED_REVISION_CONSTANTS_SINGLE_EVENT = 0; + + // The stream must not exist yet (first write to the stream). + // Fails if the stream already has events. + EXPECTED_REVISION_CONSTANTS_NO_STREAM = -1; + + // Accept any current state of the stream (no optimistic concurrency check). + // The write will succeed regardless of the stream's current revision. + EXPECTED_REVISION_CONSTANTS_ANY = -2; + + // The stream must exist (have at least one record). + // Fails if the stream doesn't exist yet. + EXPECTED_REVISION_CONSTANTS_EXISTS = -4; +} \ No newline at end of file diff --git a/packages/db-client/src/constants.ts b/packages/db-client/src/constants.ts index 3c1a0607..e69d0f75 100644 --- a/packages/db-client/src/constants.ts +++ b/packages/db-client/src/constants.ts @@ -21,6 +21,7 @@ export const READ_ONLY_REPLICA = "read_only_replica"; export const DISPATCH_TO_SINGLE = "DispatchToSingle"; export const ROUND_ROBIN = "RoundRobin"; export const PINNED = "Pinned"; +export const PINNED_BY_CORRELATION = "PinnedByCorrelation"; // persistent action export const PARK = "park"; diff --git a/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToAll.ts b/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToAll.ts index 518bd11e..c80cf5ba 100644 --- a/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToAll.ts +++ b/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToAll.ts @@ -1,14 +1,22 @@ -import { Empty } from "../../generated/shared_pb"; -import { CreateReq } from "../../generated/persistent_pb"; +import { Empty } from "../../generated/kurrentdb/protocols/v1/shared_pb"; +import { CreateReq } from "../../generated/kurrentdb/protocols/v1/persistentsubscriptions_pb"; +import semver from "semver"; import { PersistentSubscriptionsClient, PersistentSubscriptionsService, -} from "../../generated/persistent_grpc_pb"; +} from "../../generated/kurrentdb/protocols/v1/persistentsubscriptions_grpc_pb"; import type { BaseOptions, Filter } from "../types"; import { debug, convertToCommandError, UnsupportedError } from "../utils"; import { Client } from "../Client"; -import { END, EVENT_TYPE, START, STREAM_NAME } from "../constants"; +import { + END, + EVENT_TYPE, + PINNED_BY_CORRELATION, + ROUND_ROBIN, + START, + STREAM_NAME, +} from "../constants"; import { settingsToGRPC } from "./utils/settingsToGRPC"; import type { PersistentSubscriptionToAllSettings } from "./utils/persistentSubscriptionSettings"; @@ -44,16 +52,24 @@ Client.prototype.createPersistentSubscriptionToAll = async function ( this: Client, groupName: string, settings: PersistentSubscriptionToAllSettings, - { - filter, - - ...baseOptions - }: CreatePersistentSubscriptionToAllOptions = {} + { filter, ...baseOptions }: CreatePersistentSubscriptionToAllOptions = {} ): Promise { - if (!(await this.supports(PersistentSubscriptionsService.create, "all"))) { + const { serverVersion, supports } = await this.capabilities; + + if (!supports(PersistentSubscriptionsService.create, "all")) { throw new UnsupportedError("createPersistentSubscriptionToAll", "21.10"); } + if ( + semver.lt(serverVersion, "21.10.1") && + settings.consumerStrategyName === PINNED_BY_CORRELATION + ) { + console.warn( + `Consumer strategy "${PINNED_BY_CORRELATION}" requires server version ${serverVersion} or higher. "${ROUND_ROBIN}" will be used instead.` + ); + settings.consumerStrategyName = ROUND_ROBIN; + } + const req = new CreateReq(); const options = new CreateReq.Options(); const allOptions = new CreateReq.AllOptions(); diff --git a/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToStream.ts b/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToStream.ts index a709ca07..1113e932 100644 --- a/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToStream.ts +++ b/packages/db-client/src/persistentSubscription/createPersistentSubscriptionToStream.ts @@ -4,7 +4,8 @@ import { PersistentSubscriptionsClient } from "../../generated/persistent_grpc_p import type { BaseOptions } from "../types"; import { debug, convertToCommandError, createStreamIdentifier } from "../utils"; import { Client } from "../Client"; -import { END, START } from "../constants"; +import { END, PINNED_BY_CORRELATION, ROUND_ROBIN, START } from "../constants"; +import semver from "semver"; import { settingsToGRPC } from "./utils/settingsToGRPC"; import type { PersistentSubscriptionToStreamSettings } from "./utils/persistentSubscriptionSettings"; @@ -37,6 +38,18 @@ Client.prototype.createPersistentSubscriptionToStream = async function ( settings: PersistentSubscriptionToStreamSettings, baseOptions: BaseOptions = {} ): Promise { + const { serverVersion } = await this.capabilities; + + if ( + semver.lt(serverVersion, "21.10.1") && + settings.consumerStrategyName === PINNED_BY_CORRELATION + ) { + console.warn( + `Consumer strategy "${PINNED_BY_CORRELATION}" requires server version ${serverVersion} or higher. "${ROUND_ROBIN}" will be used instead.` + ); + settings.consumerStrategyName = ROUND_ROBIN; + } + const req = new CreateReq(); const options = new CreateReq.Options(); const identifier = createStreamIdentifier(streamName); diff --git a/packages/db-client/src/persistentSubscription/utils/settingsToGRPC.ts b/packages/db-client/src/persistentSubscription/utils/settingsToGRPC.ts index 50dfaa80..2b8b1235 100644 --- a/packages/db-client/src/persistentSubscription/utils/settingsToGRPC.ts +++ b/packages/db-client/src/persistentSubscription/utils/settingsToGRPC.ts @@ -1,8 +1,12 @@ -import { CreateReq, UpdateReq } from "../../../generated/persistent_pb"; +import { + CreateReq, + UpdateReq, +} from "../../../generated/kurrentdb/protocols/v1/persistentsubscriptions_pb"; import { DISPATCH_TO_SINGLE, PINNED, + PINNED_BY_CORRELATION, ROUND_ROBIN, UNBOUNDED, } from "../../constants"; @@ -62,6 +66,14 @@ export const settingsToGRPC = ( ); break; } + case PINNED_BY_CORRELATION: { + if (reqSettings instanceof CreateReq.Settings) { + reqSettings.setConsumerStrategy(settings.consumerStrategyName); + break; + } else { + throw new Error("'PinnedByCorrelation' is not supported for updates."); + } + } default: { console.warn( `Unknown consumerStrategyName ${settings.consumerStrategyName}.` diff --git a/packages/db-client/src/streams/appendToStream/index.ts b/packages/db-client/src/streams/appendToStream/index.ts index 772423e3..097b5189 100644 --- a/packages/db-client/src/streams/appendToStream/index.ts +++ b/packages/db-client/src/streams/appendToStream/index.ts @@ -1,5 +1,5 @@ -import { StreamsService } from "../../../generated/streams_grpc_pb"; - +import { StreamsService } from "../../../generated/kurrentdb/protocols/v1/streams_grpc_pb"; +import { StreamsServiceService } from "../../../generated/kurrentdb/protocols/v2/streams/streams_grpc_pb"; import { Client } from "../../Client"; import { ANY } from "../../constants"; import type { @@ -8,10 +8,14 @@ import type { AppendStreamState, EventData, EventType, + MultiAppendResult, + AppendStreamRequest, } from "../../types"; +import { UnsupportedError } from "../../utils"; import { append } from "./append"; import { batchAppend } from "./batchAppend"; +import { multiStreamAppend } from "./multiStreamAppend"; export interface AppendToStreamOptions extends BaseOptions { /** @@ -39,6 +43,10 @@ declare module "../../Client" { events: EventData | EventData[], options?: AppendToStreamOptions ): Promise; + + multiStreamAppend( + requests: AppendStreamRequest[] + ): Promise; } } @@ -73,3 +81,13 @@ Client.prototype.appendToStream = async function < ...baseOptions, }); }; + +Client.prototype.multiStreamAppend = async function ( + this: Client, + requests: AppendStreamRequest[] +): Promise { + if (!(await this.supports(StreamsServiceService.appendSession))) { + throw new UnsupportedError("multiStreamAppend", "25.1"); + } + return multiStreamAppend.call(this, requests); +}; diff --git a/packages/db-client/src/streams/appendToStream/multiStreamAppend.ts b/packages/db-client/src/streams/appendToStream/multiStreamAppend.ts new file mode 100644 index 00000000..e8403cfe --- /dev/null +++ b/packages/db-client/src/streams/appendToStream/multiStreamAppend.ts @@ -0,0 +1,127 @@ +import { + MultiAppendResult, + AppendResponse, + AppendStreamRequest, +} from "../../types"; +import type { Client } from "../../Client"; +import grpc from "../../../generated/kurrentdb/protocols/v2/streams/streams_grpc_pb"; +import protobuf, { + SchemaInfo, +} from "../../../generated/kurrentdb/protocols/v2/streams/streams_pb"; +import { + backpressuredWrite, + convertToCommandError, + convertToSchemaDataFormat as convertToSchemaFormat, + mapToValueMap, +} from "../../utils"; + +export const multiStreamAppend = async function ( + this: Client, + requests: AppendStreamRequest[] +): Promise { + if ( + requests.some((request) => + request.events.some( + (event) => event.metadata && event.metadata.constructor === Uint8Array + ) + ) + ) + throw new Error( + "multiStreamAppend requires all event metadata to be in JSON format." + ); + + return this.execute( + grpc.StreamsServiceClient, + "multiStreamAppend", + (client) => + new Promise(async (resolve, reject) => { + const sink = client.appendSession( + ...this.callArguments({ + requiresLeader: false, + }), + (error, response) => { + if (error != null) { + return reject(convertToCommandError(error)); + } + + const successes: AppendResponse[] = []; + for (const success of response.getOutputList()) { + successes.push({ + streamName: success.getStream(), + revision: BigInt(success.getStreamRevision()), + }); + } + + return resolve({ + position: BigInt(response.getPosition()), + responses: successes, + }); + } + ); + + sink.on("error", (err) => reject(err)); + + for (const request of requests) { + const message = new protobuf.AppendRequest(); + message.setStream(request.streamName); + + switch (request.expectedState) { + case "any": { + message.setExpectedRevision((-2).toString(10)); + break; + } + case "no_stream": { + message.setExpectedRevision((-1).toString(10)); + break; + } + case "stream_exists": { + message.setExpectedRevision((-4).toString(10)); + break; + } + default: { + message.setExpectedRevision(request.expectedState.toString(10)); + break; + } + } + + for (const event of request.events) { + const record = new protobuf.AppendRecord(); + record.setRecordId(event.id); + + const schemaInfo = new SchemaInfo(); + schemaInfo.setFormat(convertToSchemaFormat(event.contentType)); + schemaInfo.setName(event.type); + record.setSchema(schemaInfo); + + if (event.metadata) { + const metadataMap = mapToValueMap( + event.metadata as Record + ); + for (const [key, value] of metadataMap) { + record.getPropertiesMap().set(key, value); + } + } + + switch (event.contentType) { + case "application/json": { + const data = JSON.stringify(event.data); + record.setData(Buffer.from(data, "utf8").toString("base64")); + break; + } + + case "application/octet-stream": { + record.setData(event.data); + break; + } + } + + message.addRecords(record); + } + + await backpressuredWrite(sink, message); + } + + sink.end(); + }) + ); +}; diff --git a/packages/db-client/src/types/index.ts b/packages/db-client/src/types/index.ts index 6047d43f..3b55113a 100644 --- a/packages/db-client/src/types/index.ts +++ b/packages/db-client/src/types/index.ts @@ -5,7 +5,7 @@ import type { ChannelCredentials, } from "@grpc/grpc-js"; -import { MemberInfo as GrpcMemberInfo } from "../../generated/gossip_pb"; +import { MemberInfo as GrpcMemberInfo } from "../../generated/kurrentdb/protocols/v1/gossip_pb"; import VNodeState = GrpcMemberInfo.VNodeState; import type { @@ -14,6 +14,7 @@ import type { EventType, PersistentSubscriptionToAllResolvedEvent, PersistentSubscriptionToStreamResolvedEvent, + EventData, } from "./events"; import type * as constants from "../constants"; @@ -97,7 +98,7 @@ export type Direction = typeof constants.FORWARDS | typeof constants.BACKWARDS; export interface AppendResult { /** - * If the append was successful. Only relevent if `throwOnAppendFailure` is set to false. + * If the append was successful. Only relevant if `throwOnAppendFailure` is set to false. */ success: boolean; /** @@ -246,7 +247,8 @@ export interface DeleteResult { export type ConsumerStrategy = | typeof constants.DISPATCH_TO_SINGLE | typeof constants.ROUND_ROBIN - | typeof constants.PINNED; + | typeof constants.PINNED + | typeof constants.PINNED_BY_CORRELATION; export type PersistentAction = | typeof constants.PARK @@ -527,6 +529,45 @@ export interface FellBehind { position?: Position; } +export interface AppendStreamRequest< + KnownEventType extends EventType = EventType +> { + streamName: string; + events: EventData[]; + expectedState: AppendStreamState; +} + +export interface AppendResponse { + streamName: string; + revision: bigint; +} + +export interface BaseAppendErrorDetails { + type: string; +} + +export type AppendErrorDetails = + | ({ type: "unknown" } & BaseAppendErrorDetails) + | ({ type: "access_denied"; reason: string } & BaseAppendErrorDetails) + | ({ type: "stream_deleted" } & BaseAppendErrorDetails) + | ({ + type: "wrong_expected_revision"; + revision: bigint; + } & BaseAppendErrorDetails) + | ({ + type: "transaction_max_size_exceeded"; + maxSize: number; + } & BaseAppendErrorDetails); + +export const UnknownErrorDetails: AppendErrorDetails = { + type: "unknown", +} as const; + +export type MultiAppendResult = { + position: bigint; + responses: AppendResponse[]; +}; + // Other listeners that are only supported in catch-up subscriptions export interface CatchupSubscription { addListener(event: "caughtUp", listener: (info: CaughtUp) => void): this; diff --git a/packages/db-client/src/utils/CommandError.ts b/packages/db-client/src/utils/CommandError.ts index 7b503947..1dbee04c 100644 --- a/packages/db-client/src/utils/CommandError.ts +++ b/packages/db-client/src/utils/CommandError.ts @@ -3,10 +3,17 @@ /* istanbul ignore file */ import { status as StatusCode, ServiceError, Metadata } from "@grpc/grpc-js"; -import { isClientCancellationError } from "."; +import { getGrpcStatusDetails, isClientCancellationError } from "."; -import type { WrongExpectedVersion } from "../../generated/shared_pb"; +import { WrongExpectedVersion } from "../../generated/kurrentdb/protocols/v1/shared_pb"; import type { CurrentStreamState, EndPoint, AppendStreamState } from "../types"; +import { + AppendTransactionSizeExceededErrorDetails, + StreamRevisionConflictErrorDetails, + StreamTombstonedErrorDetails, + StreamNotFoundErrorDetails, + AppendRecordSizeExceededErrorDetails, +} from "../../generated/kurrentdb/protocols/v2/streams/errors_pb"; export enum ErrorType { TIMEOUT = "timeout", @@ -22,9 +29,12 @@ export enum ErrorType { INVALID_ARGUMENT = "invalid-argument", INVALID_TRANSACTION = "invalid-transaction", STREAM_DELETED = "stream-deleted", + STREAM_TOMBSTONED = "stream-tombstoned", SCAVENGE_NOT_FOUND = "scavenge-not-found", WRONG_EXPECTED_VERSION = "wrong-expected-version", MAXIMUM_APPEND_SIZE_EXCEEDED = "maximum-append-size-exceeded", + TRANSACTION_MAX_SIZE_EXCEEDED = "transaction-max-size-exceeded", + APPEND_RECORD_SIZE_EXCEEDED = "append-record-size-exceeded", MISSING_REQUIRED_METADATA_PROPERTY = "missing-required-metadata-property", PERSISTENT_SUBSCRIPTION_FAILED = "persistent-subscription-failed", @@ -203,6 +213,35 @@ export class WrongExpectedVersionError extends CommandErrorBase { }); }; + static fromRevisionConflict = ( + details: StreamRevisionConflictErrorDetails.AsObject + ) => { + let expected: AppendStreamState; + switch (details.expectedRevision) { + case "-1": + expected = "no_stream"; + break; + case "-4": + expected = "stream_exists"; + break; + case "-2": + expected = "any"; + break; + default: + expected = BigInt(details.expectedRevision); + break; + } + + return new WrongExpectedVersionError(undefined, { + current: + details.actualRevision === "-1" + ? "no_stream" + : BigInt(details.actualRevision), + expected, + streamName: details.stream, + }); + }; + constructor(error: ServiceError); constructor(error: undefined, versions: WrongExpectedVersionDetails); constructor(error?: ServiceError, versions?: WrongExpectedVersionDetails) { @@ -249,6 +288,55 @@ export class MaxAppendSizeExceededError extends CommandErrorBase { } } +export class AppendRecordSizeExceededError extends CommandErrorBase { + public type: ErrorType.APPEND_RECORD_SIZE_EXCEEDED = + ErrorType.APPEND_RECORD_SIZE_EXCEEDED; + public stream: string; + public recordId: string; + public size: number; + public maxSize: number; + + constructor( + error: ServiceError, + details: AppendRecordSizeExceededErrorDetails.AsObject + ) { + super(error); + this.stream = details.stream; + this.recordId = details.recordId; + this.size = details.size; + this.maxSize = details.maxSize; + } +} + +export class StreamTombstonedError extends CommandErrorBase { + public type: ErrorType.STREAM_TOMBSTONED = ErrorType.STREAM_TOMBSTONED; + public stream: string; + + constructor( + error: ServiceError, + details: StreamTombstonedErrorDetails.AsObject + ) { + super(error); + this.stream = details.stream; + } +} + +export class TransactionMaxSizeExceededError extends CommandErrorBase { + public type: ErrorType.TRANSACTION_MAX_SIZE_EXCEEDED = + ErrorType.TRANSACTION_MAX_SIZE_EXCEEDED; + public size: number; + public maxSize: number; + + constructor( + error: ServiceError, + details: AppendTransactionSizeExceededErrorDetails.AsObject + ) { + super(error); + this.size = details.size; + this.maxSize = details.maxSize; + } +} + export class RequiredMetadataPropertyMissingError extends CommandErrorBase { public type: ErrorType.MISSING_REQUIRED_METADATA_PROPERTY = ErrorType.MISSING_REQUIRED_METADATA_PROPERTY; @@ -415,9 +503,12 @@ export type CommandError = | InvalidArgumentError | InvalidTransactionError | StreamDeletedError + | StreamTombstonedError | ScavengeNotFoundError | WrongExpectedVersionError | MaxAppendSizeExceededError + | AppendRecordSizeExceededError + | TransactionMaxSizeExceededError | RequiredMetadataPropertyMissingError | PersistentSubscriptionFailedError | PersistentSubscriptionDoesNotExistError @@ -476,20 +567,82 @@ export const convertToCommandError = (error: Error): CommandError | Error => { } switch (error.code) { - case StatusCode.ABORTED: + case StatusCode.ABORTED: { + const details = getGrpcStatusDetails(error); + if (!details) break; + + const { typeUrl, value } = details; + + if (typeUrl.endsWith("AppendTransactionSizeExceededErrorDetails")) { + return new TransactionMaxSizeExceededError( + error, + AppendTransactionSizeExceededErrorDetails.deserializeBinary( + value + ).toObject() + ); + } + return new TimeoutError(error); + } case StatusCode.DEADLINE_EXCEEDED: return new DeadlineExceededError(error); case StatusCode.UNAVAILABLE: return new UnavailableError(error); case StatusCode.UNAUTHENTICATED: return new AccessDeniedError(error); - case StatusCode.NOT_FOUND: + case StatusCode.NOT_FOUND: { + const details = getGrpcStatusDetails(error); + if (details && details.typeUrl.endsWith("StreamNotFoundErrorDetails")) { + const stream = StreamNotFoundErrorDetails.deserializeBinary( + details.value + ).toObject().stream; + return new StreamNotFoundError(error, stream); + } + return new NotFoundError(error); + } case StatusCode.CANCELLED: { if (isClientCancellationError(error)) break; return new CancelledError(error); } + case StatusCode.FAILED_PRECONDITION: { + const details = getGrpcStatusDetails(error); + if (!details) break; + + if (details.typeUrl.endsWith("StreamRevisionConflictErrorDetails")) { + return WrongExpectedVersionError.fromRevisionConflict( + StreamRevisionConflictErrorDetails.deserializeBinary( + details.value + ).toObject() + ); + } else if (details.typeUrl.endsWith("StreamTombstonedErrorDetails")) { + return new StreamTombstonedError( + error, + StreamTombstonedErrorDetails.deserializeBinary( + details.value + ).toObject() + ); + } + + break; + } + case StatusCode.INVALID_ARGUMENT: { + const details = getGrpcStatusDetails(error); + + if ( + details && + details.typeUrl.endsWith("AppendRecordSizeExceededErrorDetails") + ) { + return new AppendRecordSizeExceededError( + error, + AppendRecordSizeExceededErrorDetails.deserializeBinary( + details.value + ).toObject() + ); + } + + break; + } } // This is a temporary workaround for a bug in Node.js. Must be removed when the bug is fixed. diff --git a/packages/db-client/src/utils/getGrpcStatusDetails.ts b/packages/db-client/src/utils/getGrpcStatusDetails.ts new file mode 100644 index 00000000..649a81af --- /dev/null +++ b/packages/db-client/src/utils/getGrpcStatusDetails.ts @@ -0,0 +1,19 @@ +import { ServiceError } from "@grpc/grpc-js"; +import { Status } from "../../generated/kurrentdb/protocols/v1/status_pb"; + +export const getGrpcStatusDetails = ( + error: ServiceError +): { value: Uint8Array; typeUrl: string } | undefined => { + const statusBuffer = error.metadata.get("grpc-status-details-bin")?.[0]; + if (!statusBuffer || typeof statusBuffer === "string") { + return undefined; + } + + const status = Status.deserializeBinary(new Uint8Array(statusBuffer)); + const details = status.getDetails(); + + const value = details?.getValue_asU8() ?? new Uint8Array(); + const typeUrl = details?.getTypeUrl() ?? ""; + + return { value, typeUrl }; +}; diff --git a/packages/db-client/src/utils/index.ts b/packages/db-client/src/utils/index.ts index a3dcc46e..9b3d1a6b 100644 --- a/packages/db-client/src/utils/index.ts +++ b/packages/db-client/src/utils/index.ts @@ -7,3 +7,6 @@ export * from "./grpcStreamIdentifier"; export * from "./grpcUUID"; export * from "./utilityTypes"; export * from "./isClientCancellationError"; +export * from "./mapToValue"; +export * from "./schema"; +export * from "./getGrpcStatusDetails"; diff --git a/packages/db-client/src/utils/mapToValue.ts b/packages/db-client/src/utils/mapToValue.ts new file mode 100644 index 00000000..c7754f6a --- /dev/null +++ b/packages/db-client/src/utils/mapToValue.ts @@ -0,0 +1,54 @@ +import { NullValue, Value } from "google-protobuf/google/protobuf/struct_pb"; + +export const mapToValue = (source: unknown): Value => { + const value = new Value(); + + if (source === null || source === undefined) { + value.setNullValue(NullValue.NULL_VALUE); + return value; + } + + switch (typeof source) { + case "string": + value.setStringValue(source); + break; + + case "boolean": + value.setBoolValue(source); + break; + + case "number": + value.setNumberValue(source); + break; + + case "object": + if (source instanceof Date) { + value.setStringValue(source.toISOString()); + } else if (source instanceof Uint8Array) { + value.setStringValue(Buffer.from(source).toString("base64")); + } else if (Buffer.isBuffer(source)) { + value.setStringValue(source.toString("base64")); + } else { + value.setStringValue(JSON.stringify(source)); + } + break; + + default: + value.setStringValue(String(source)); + break; + } + + return value; +}; + +export const mapToValueMap = ( + obj: Record +): Map => { + const map = new Map(); + + for (const [key, value] of Object.entries(obj)) { + map.set(key, mapToValue(value)); + } + + return map; +}; diff --git a/packages/db-client/src/utils/schema.ts b/packages/db-client/src/utils/schema.ts new file mode 100644 index 00000000..052982c6 --- /dev/null +++ b/packages/db-client/src/utils/schema.ts @@ -0,0 +1,19 @@ +import { SchemaFormat } from "../../generated/kurrentdb/protocols/v2/streams/streams_pb"; + +/** + * Converts a content type to a SchemaDataFormat. + * @param format - The content type to convert. + * @returns The corresponding SchemaDataFormat. + */ +export const convertToSchemaDataFormat = ( + format: "application/json" | "application/octet-stream" +): SchemaFormat => { + switch (format) { + case "application/json": + return SchemaFormat.SCHEMA_FORMAT_JSON; + case "application/octet-stream": + return SchemaFormat.SCHEMA_FORMAT_BYTES; + default: + throw new Error(`Unsupported data format: ${format}`); + } +}; diff --git a/packages/opentelemetry/src/attributes.ts b/packages/opentelemetry/src/attributes.ts index 65ae659f..a335a80a 100644 --- a/packages/opentelemetry/src/attributes.ts +++ b/packages/opentelemetry/src/attributes.ts @@ -12,6 +12,7 @@ export const KurrentAttributes = { SERVER_PORT: `${server}.port`, STREAM_APPEND: `${streams}.append`, + STREAM_MULTI_APPEND: `${streams}.multi-append`, STREAM_SUBSCRIBE: `${streams}.subscribe`, KURRENT_DB_STREAM: `${kurrentdb}.stream`, diff --git a/packages/opentelemetry/src/instrumentation.ts b/packages/opentelemetry/src/instrumentation.ts index 276a5c1e..9443c92d 100644 --- a/packages/opentelemetry/src/instrumentation.ts +++ b/packages/opentelemetry/src/instrumentation.ts @@ -8,6 +8,7 @@ import { Span, SpanKind, SpanStatusCode, + TimeInput, trace, TraceFlags, Tracer, @@ -24,6 +25,7 @@ import type { EventData, EventType, JSONEventType, + MultiAppendResult, ResolvedEvent, SubscribeToAllOptions, SubscribeToPersistentSubscriptionToAllOptions, @@ -38,6 +40,7 @@ import type { Subscription } from "@kurrent/kurrentdb-client/src/streams/utils/S import { INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION } from "./version"; import type { AppendToStreamParams, + MultiStreamAppendParams, PersistentSubscribeParameters, SubscribeParameters, } from "./types"; @@ -67,6 +70,11 @@ export class Instrumentation extends InstrumentationBase { "appendToStream", this._patchAppendToStream() ); + this.wrap( + moduleExports.KurrentDBClient.prototype, + "multiStreamAppend", + this._patchMultiStreamAppend() + ); this.wrap( moduleExports.KurrentDBClient.prototype, "subscribeToStream", @@ -106,6 +114,10 @@ export class Instrumentation extends InstrumentationBase { this._diag.debug("un-patching"); this._unwrap(moduleExports.KurrentDBClient.prototype, "appendToStream"); + this._unwrap( + moduleExports.KurrentDBClient.prototype, + "multiStreamAppend" + ); this._unwrap( moduleExports.KurrentDBClient.prototype, "subscribeToStream" @@ -196,6 +208,67 @@ export class Instrumentation extends InstrumentationBase { }; } + private _patchMultiStreamAppend(): ( + original: Function, + operation: keyof kurrentdb.KurrentDBClient + ) => (...args: MultiStreamAppendParams) => Promise { + const instrumentation = this; + const tracer = instrumentation.tracer; + + return function multiStreamAppend( + original: Function, + operation: keyof kurrentdb.KurrentDBClient + ) { + return async function ( + this: kurrentdb.KurrentDBClient, + ...args: MultiStreamAppendParams + ): Promise { + const [requests] = [...args]; + + const uri = await this.resolveUri(); + const { hostname, port } = Instrumentation.getServerAddress(uri); + + const requestStartTime: TimeInput = Date.now(); + + const span = tracer.startSpan(KurrentAttributes.STREAM_MULTI_APPEND, { + kind: SpanKind.CLIENT, + startTime: requestStartTime, + attributes: { + [KurrentAttributes.SERVER_ADDRESS]: hostname, + [KurrentAttributes.SERVER_PORT]: port, + [KurrentAttributes.DATABASE_SYSTEM]: INSTRUMENTATION_NAME, + [KurrentAttributes.DATABASE_OPERATION]: operation, + }, + }); + + requests.forEach((request) => { + const traceId = span.spanContext().traceId; + const spanId = span.spanContext().spanId; + + request.events.forEach((event) => { + const metadata = (event.metadata = event.metadata || {}); + if (isJSONEventData(event) && typeof metadata === "object") { + event.metadata = { + ...metadata, + [TRACE_ID]: traceId, + [SPAN_ID]: spanId, + }; + } + }); + }); + + try { + return await original.apply(this, [requests]); + } catch (error) { + Instrumentation.handleError(error, span); + throw error; + } finally { + span.end(); + } + }; + }; + } + static applySubscriptionInstrumentation( spanName: string, subscription: diff --git a/packages/opentelemetry/src/types.ts b/packages/opentelemetry/src/types.ts index bff83aa6..eee21684 100644 --- a/packages/opentelemetry/src/types.ts +++ b/packages/opentelemetry/src/types.ts @@ -23,3 +23,7 @@ export type PersistentSubscribeParameters = export type AppendToStreamParams = Parameters< kdb.KurrentDBClient["appendToStream"] >; + +export type MultiStreamAppendParams = Parameters< + kdb.KurrentDBClient["multiStreamAppend"] +>; diff --git a/packages/test/package.json b/packages/test/package.json index 4aa4df2f..565e7d58 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -37,6 +37,7 @@ "@opentelemetry/api": "^1.9.0", "@opentelemetry/exporter-trace-otlp-grpc": "^0.51.1", "@opentelemetry/instrumentation": "^0.56.0", + "@opentelemetry/resources": "^2.0.1", "@opentelemetry/sdk-trace-node": "^1.30.0", "@opentelemetry/semantic-conventions": "^1.28.0", "@types/debug": "^4.1.12", diff --git a/packages/test/src/connection/reconnect/no-reconnection.test.ts b/packages/test/src/connection/reconnect/no-reconnection.test.ts index dd8c7ae8..04bb9c25 100644 --- a/packages/test/src/connection/reconnect/no-reconnection.test.ts +++ b/packages/test/src/connection/reconnect/no-reconnection.test.ts @@ -54,7 +54,7 @@ describe("reconnect", () => { await cluster.down(); }); - test("no reconnection for TimeoutError", async () => { + test.skip("no reconnection for TimeoutError", async () => { const timeoutNode = createTestNode() .setOption("EVENTSTORE_COMMIT_TIMEOUT_MS", 1) .setOption("EVENTSTORE_PREPARE_TIMEOUT_MS", 1); diff --git a/packages/test/src/opentelemetry/instrumentation.test.ts b/packages/test/src/opentelemetry/instrumentation.test.ts index 83a73c24..5e4fe3cc 100644 --- a/packages/test/src/opentelemetry/instrumentation.test.ts +++ b/packages/test/src/opentelemetry/instrumentation.test.ts @@ -1,3 +1,5 @@ +/** @jest-environment ./src/utils/enableVersionCheck.ts */ + import { createTestNode, Defer, delay, jsonTestEvents } from "@test-utils"; import { NodeTracerProvider, diff --git a/packages/test/src/persistentSubscription/createPersistentSubscriptionToAll.test.ts b/packages/test/src/persistentSubscription/createPersistentSubscriptionToAll.test.ts index 4b08ee77..1ea3941b 100644 --- a/packages/test/src/persistentSubscription/createPersistentSubscriptionToAll.test.ts +++ b/packages/test/src/persistentSubscription/createPersistentSubscriptionToAll.test.ts @@ -14,6 +14,10 @@ import { persistentSubscriptionToAllSettingsFromDefaults, START, UnsupportedError, + PINNED_BY_CORRELATION, + ROUND_ROBIN, + PINNED, + DISPATCH_TO_SINGLE, } from "@kurrent/kurrentdb-client"; describe("createPersistentSubscriptionToAll", () => { @@ -87,6 +91,31 @@ describe("createPersistentSubscriptionToAll", () => { ).resolves.toBeUndefined(); }); + test.each([ + PINNED_BY_CORRELATION, + PINNED, + ROUND_ROBIN, + DISPATCH_TO_SINGLE, + ])("consumer strategy: %s", async (strategy) => { + const GROUP_NAME = `group_name_valid_consumer_strategy_${strategy.toLowerCase()}`; + await expect( + client.createPersistentSubscriptionToAll( + GROUP_NAME, + persistentSubscriptionToAllSettingsFromDefaults({ + consumerStrategyName: strategy, + }) + ) + ).resolves.toBeUndefined(); + + let persistentSubscription = + await client.getPersistentSubscriptionToAllInfo(GROUP_NAME); + + expect(persistentSubscription.groupName).toBe(GROUP_NAME); + expect(persistentSubscription.settings.consumerStrategyName).toBe( + strategy + ); + }); + test("with a filter", async () => { const GROUP_NAME = "group_name_with_filter"; await expect( diff --git a/packages/test/src/persistentSubscription/createPersistentSubscriptionToStream.test.ts b/packages/test/src/persistentSubscription/createPersistentSubscriptionToStream.test.ts index 2c70ff7f..55891326 100644 --- a/packages/test/src/persistentSubscription/createPersistentSubscriptionToStream.test.ts +++ b/packages/test/src/persistentSubscription/createPersistentSubscriptionToStream.test.ts @@ -1,9 +1,13 @@ import { createTestNode } from "@test-utils"; import { + DISPATCH_TO_SINGLE, KurrentDBClient, PersistentSubscriptionExistsError, persistentSubscriptionToStreamSettingsFromDefaults, + PINNED, + PINNED_BY_CORRELATION, + ROUND_ROBIN, START, } from "@kurrent/kurrentdb-client"; @@ -61,6 +65,34 @@ describe("createPersistentSubscriptionToStream", () => { ) ).resolves.toBeUndefined(); }); + + test.each([PINNED_BY_CORRELATION, PINNED, ROUND_ROBIN, DISPATCH_TO_SINGLE])( + "consumer strategy: %s", + async (strategy) => { + const STREAM_NAME = `stream_name_from_revision_${strategy.toLowerCase()}`; + const GROUP_NAME = `group_name_valid_consumer_strategy_${strategy.toLowerCase()}`; + await expect( + client.createPersistentSubscriptionToStream( + STREAM_NAME, + GROUP_NAME, + persistentSubscriptionToStreamSettingsFromDefaults({ + consumerStrategyName: strategy, + }) + ) + ).resolves.toBeUndefined(); + + let persistentSubscription = + await client.getPersistentSubscriptionToStreamInfo( + STREAM_NAME, + GROUP_NAME + ); + + expect(persistentSubscription.eventSource).toBe(STREAM_NAME); + expect(persistentSubscription.settings.consumerStrategyName).toBe( + strategy + ); + } + ); }); test("should throw an error if subscription exists", async () => { diff --git a/packages/test/src/samples/opentelemetry.ts b/packages/test/src/samples/opentelemetry.ts index d270fde9..abdf4542 100644 --- a/packages/test/src/samples/opentelemetry.ts +++ b/packages/test/src/samples/opentelemetry.ts @@ -1,4 +1,10 @@ -// region import-required-packages +/** @jest-environment ./src/utils/enableVersionCheck.ts */ + +/** + * Download and start aspire dashboard from https://aspiredashboard.com/ + * You can also use Jaeger or any other OpenTelemetry compatible dashboard. + */ + import { InMemorySpanExporter, NodeTracerProvider, @@ -8,15 +14,41 @@ import { import { registerInstrumentations } from "@opentelemetry/instrumentation"; import { KurrentDBInstrumentation } from "@kurrent/opentelemetry"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc"; -import {} from "@opentelemetry/sdk-trace-node"; -// endregion import-required-packages -import { createTestNode } from "@test-utils"; -import { KurrentDBClient } from "@kurrent/kurrentdb-client"; +import { resourceFromAttributes } from "@opentelemetry/resources"; +import { + ATTR_EXCEPTION_STACKTRACE, + ATTR_EXCEPTION_TYPE, + ATTR_SERVICE_NAME, + ATTR_SERVICE_VERSION, +} from "@opentelemetry/semantic-conventions"; +import { + createTestNode, + Defer, + matchServerVersion, + optionalDescribe, +} from "@test-utils"; -import * as esdb from "@kurrent/kurrentdb-client"; +import * as kurrentdb from "@kurrent/kurrentdb-client"; +import { KurrentAttributes } from "@kurrent/opentelemetry/src/attributes"; +import { v4 } from "uuid"; +import { multiStreamAppend } from "@kurrent/kurrentdb-client/src/streams/appendToStream/multiStreamAppend"; +import { WrongExpectedVersionError } from "@kurrent/kurrentdb-client"; -// region register-instrumentation -const provider = new NodeTracerProvider(); +const memoryExporter = new InMemorySpanExporter(); +const otlpExporter = new OTLPTraceExporter({ url: "http://localhost:4317" }); // change this to your OTLP receiver address +const consoleExporter = new ConsoleSpanExporter(); + +const provider = new NodeTracerProvider({ + resource: resourceFromAttributes({ + [ATTR_SERVICE_NAME]: "kurrentdb", + [ATTR_SERVICE_VERSION]: "1.0.0", + }), + spanProcessors: [ + new SimpleSpanProcessor(memoryExporter), + // new SimpleSpanProcessor(consoleExporter), + new SimpleSpanProcessor(otlpExporter), + ], +}); const instrumentation = new KurrentDBInstrumentation(); @@ -24,30 +56,22 @@ registerInstrumentations({ instrumentations: [instrumentation], tracerProvider: provider, }); -// endregion register-instrumentation instrumentation.disable(); +const getSpans = (name: string) => { + return memoryExporter.getFinishedSpans().filter((span) => span.name === name); +}; + describe("[sample] opentelemetry", () => { const node = createTestNode(); - let client!: KurrentDBClient; - - // region setup-exporter - const memoryExporter = new InMemorySpanExporter(); - const otlpExporter = new OTLPTraceExporter({ url: "http://localhost:4317" }); // change this to your OTLP receiver address - const consoleExporter = new ConsoleSpanExporter(); - - provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); - provider.addSpanProcessor(new SimpleSpanProcessor(consoleExporter)); - provider.addSpanProcessor(new SimpleSpanProcessor(otlpExporter)); - // endregion setup-exporter + const moduleName = "@kurrent/opentelemetry"; // @ts-expect-error the moduleExports property is private. This is needed to make the test work with auto-mocking - instrumentation._modules[0].moduleExports = esdb; + instrumentation._modules[0].moduleExports = kurrentdb; beforeAll(async () => { await node.up(); - client = KurrentDBClient.connectionString(node.connectionString()); }); beforeAll(async () => { @@ -64,33 +88,173 @@ describe("[sample] opentelemetry", () => { memoryExporter.reset(); }); - test("tracing", async () => { - // region setup-client-for-tracing - const { KurrentDBClient, jsonEvent } = await import( - "@kurrent/kurrentdb-client" - ); - - const client = KurrentDBClient.connectionString(node.connectionString()); - // endregion setup-client-for-tracing - - const response = await client.appendToStream( - "some-stream", - jsonEvent({ - type: "OrderPlaced", - data: { - orderId: "1337", - orderValue: 123.45, - }, - }), - { - streamState: "any", - } - ); + optionalDescribe(matchServerVersion`>=25.0`)("multistream append", () => { + test("append then subscribe", async () => { + // Arrange + const defer = new Defer(); + + const { KurrentDBClient, jsonEvent } = await import( + "@kurrent/kurrentdb-client" + ); + + const handleError = jest.fn((error) => { + defer.reject(error); + }); + const handleClose = jest.fn(); + const handleEvent = jest.fn((event: kurrentdb.ResolvedEvent) => { + expect(event).toBeDefined(); + }); + const handleCaughtUp = jest.fn(async () => { + try { + expect(handleEvent).toHaveBeenCalledTimes(3); + await subscription.unsubscribe(); + } catch (error) { + defer.reject(error); + } + }); + const handleEnd = jest.fn(defer.resolve); + const handleConfirmation = jest.fn(); + + const client = KurrentDBClient.connectionString(node.connectionString()); + + const firstOrderReq: kurrentdb.AppendStreamRequest = { + streamName: `order-${v4()}`, + events: [ + jsonEvent({ + type: "OrderPlaced", + data: { id: v4() }, + }), + jsonEvent({ + type: "PaymentProcessed", + data: { id: v4() }, + }), + ], + expectedState: kurrentdb.ANY, + }; + + const secondOrderReq: kurrentdb.AppendStreamRequest = { + streamName: `order-${v4()}`, + events: [ + jsonEvent({ + type: "OrderPlaced", + data: { customerId: "cust-456" }, + }), + ], + expectedState: kurrentdb.ANY, + }; + + // Act + const appendResponse = await client.multiStreamAppend([ + firstOrderReq, + secondOrderReq, + ]); + + expect(appendResponse.position).toBeGreaterThan(BigInt(0)); + expect(appendResponse.responses).toHaveLength(2); - expect(response).toBeDefined(); + const subscription = client + .subscribeToAll({ + filter: kurrentdb.streamNameFilter({ + prefixes: ["order-"], + }), + }) + .on("error", handleError) + .on("data", handleEvent) + .on("close", handleClose) + .on("confirmation", handleConfirmation) + .on("caughtUp", handleCaughtUp) + .on("end", handleEnd); - const memorySpans = memoryExporter.getFinishedSpans(); + await defer.promise; - expect(memorySpans.length).toBe(1); + // Assert + expect(handleError).not.toHaveBeenCalled(); + expect(handleConfirmation).toHaveBeenCalledTimes(1); + expect(handleEvent).toHaveBeenCalledTimes(3); + expect(handleCaughtUp).toHaveBeenCalled(); + + const appendSpans = getSpans(KurrentAttributes.STREAM_MULTI_APPEND); + const subscribeSpans = getSpans(KurrentAttributes.STREAM_SUBSCRIBE); + + expect(appendSpans).toHaveLength(1); + expect(subscribeSpans).toHaveLength(3); + + expect(subscribeSpans[0].parentSpanId).toBe( + appendSpans[0].spanContext().spanId + ); + expect(subscribeSpans[1].parentSpanId).toBe( + appendSpans[0].spanContext().spanId + ); + + expect(appendSpans[0].attributes).toMatchObject({ + [KurrentAttributes.SERVER_ADDRESS]: node.endpoints[0].address, + [KurrentAttributes.SERVER_PORT]: node.endpoints[0].port.toString(), + [KurrentAttributes.DATABASE_SYSTEM]: moduleName, + [KurrentAttributes.DATABASE_OPERATION]: multiStreamAppend.name, + }); + }); + + test("append with failures", async () => { + // Arrange + const defer = new Defer(); + + const { KurrentDBClient, jsonEvent } = await import( + "@kurrent/kurrentdb-client" + ); + + const client = KurrentDBClient.connectionString(node.connectionString()); + + const firstOrderReq: kurrentdb.AppendStreamRequest = { + streamName: `order-${v4()}`, + events: [ + jsonEvent({ + type: "OrderPlaced", + data: { id: v4() }, + }), + jsonEvent({ + type: "PaymentProcessed", + data: { id: v4() }, + }), + ], + expectedState: kurrentdb.ANY, + }; + + const secondOrderReq: kurrentdb.AppendStreamRequest = { + streamName: `order-${v4()}`, + events: [ + jsonEvent({ + type: "OrderPlaced", + data: { customerId: "cust-456" }, + }), + ], + expectedState: kurrentdb.STREAM_EXISTS, + }; + + try { + await client.multiStreamAppend([firstOrderReq, secondOrderReq]); + } catch (error) { + const spans = memoryExporter.getFinishedSpans(); + expect(spans.length).toBe(1); + + const failedSpan = spans[0]; + + const failedEvents = failedSpan.events; + + expect(failedEvents.length).toBe(1); + + const failedEvent = failedEvents[0]; + + expect(error).toBeInstanceOf(WrongExpectedVersionError); + expect(failedEvent).toEqual( + expect.objectContaining({ + name: "exception", + attributes: { + [ATTR_EXCEPTION_TYPE]: "Error", + [ATTR_EXCEPTION_STACKTRACE]: error.stack, + }, + }) + ); + } + }); }); }); diff --git a/packages/test/src/streams/appendToStream-errors.test.ts b/packages/test/src/streams/appendToStream-errors.test.ts index 55b726cd..a78057f1 100644 --- a/packages/test/src/streams/appendToStream-errors.test.ts +++ b/packages/test/src/streams/appendToStream-errors.test.ts @@ -121,7 +121,7 @@ describe("appendToStream - errors", () => { } }); - optionalTest(supported)("MaximumAppendSizeExceeded", async () => { + optionalTest(supported).skip("MaximumAppendSizeExceeded", async () => { const STREAM_NAME = `${prefix}_i_am_too_many`; try { diff --git a/packages/test/src/streams/multiAppendStream.test.ts b/packages/test/src/streams/multiAppendStream.test.ts new file mode 100644 index 00000000..ead2a850 --- /dev/null +++ b/packages/test/src/streams/multiAppendStream.test.ts @@ -0,0 +1,176 @@ +/** @jest-environment ./src/utils/enableVersionCheck.ts */ + +import { + binaryTestEvents, + collect, + createTestNode, + jsonTestEvents, + matchServerVersion, + optionalDescribe, +} from "@test-utils"; + +import { + KurrentDBClient, + ANY, + UnsupportedError, + AppendStreamRequest, + STREAM_EXISTS, + WrongExpectedVersionError, + StreamTombstonedError, +} from "@kurrent/kurrentdb-client"; + +import { v4 } from "uuid"; + +describe("multiAppend", () => { + const supported = matchServerVersion`>=25.0`; + const node = createTestNode(); + let client!: KurrentDBClient; + + beforeAll(async () => { + await node.up(); + client = KurrentDBClient.connectionString(node.connectionString()); + }); + + afterAll(async () => { + await node.down(); + }); + + test("json events", async () => { + const STREAM_NAME = v4().toString(); + + const requests: AppendStreamRequest[] = []; + + requests.push({ + streamName: STREAM_NAME, + events: binaryTestEvents(), + expectedState: ANY, + }); + + try { + await client.multiStreamAppend(requests); + } catch (error) { + expect(error).toBeInstanceOf(Error); + expect(error.message).toBe( + "multiStreamAppend requires server version 25.1 or higher." + ); + } + }); + + optionalDescribe(supported)("Supported (>=25.1)", () => { + test("json events", async () => { + const STREAM_NAME_1 = v4().toString(); + const STREAM_NAME_2 = v4().toString(); + const expectedMetadata = { + timestamp: new Date().toISOString(), + int: 1, + float: 1.1, + string: "test", + }; + + const requests: AppendStreamRequest[] = []; + + requests.push({ + streamName: STREAM_NAME_1, + events: jsonTestEvents(4, "test", expectedMetadata), + expectedState: ANY, + }); + + requests.push({ + streamName: STREAM_NAME_2, + events: jsonTestEvents(4, "test", expectedMetadata), + expectedState: ANY, + }); + + const result = await client.multiStreamAppend(requests); + expect(result).toBeDefined(); + expect(result.position).toBeGreaterThanOrEqual(BigInt(0)); + expect(result.responses).toBeDefined(); + expect(result.responses.length).toBe(2); + + const stream1Events = await collect(client.readStream(STREAM_NAME_1)); + const stream2Events = await collect(client.readStream(STREAM_NAME_2)); + + expect(stream1Events.length).toBe(4); + expect(stream2Events.length).toBe(4); + + for (const { event } of [...stream1Events, ...stream2Events]) { + expect(event).toBeDefined(); + expect(event?.metadata).toEqual( + expect.objectContaining({ + "$schema.format": "Json", + "$schema.name": "test", + ...expectedMetadata, + }) + ); + } + }); + }); + + optionalDescribe(supported)("Supported (>=25.1)", () => { + test("stream deleted", async () => { + const STREAM_NAME = v4().toString(); + + await client.tombstoneStream(STREAM_NAME); + + const requests: AppendStreamRequest[] = []; + + requests.push({ + streamName: STREAM_NAME, + events: jsonTestEvents(), + expectedState: STREAM_EXISTS, + }); + + try { + await client.multiStreamAppend(requests); + } catch (error) { + expect(error).toBeInstanceOf(StreamTombstonedError); + } + }); + }); + + optionalDescribe(supported)("Supported (>=25.1)", () => { + test("stream revision conflict", async () => { + const STREAM_NAME = v4().toString(); + + const requests: AppendStreamRequest[] = []; + + requests.push({ + streamName: STREAM_NAME, + events: jsonTestEvents(), + expectedState: STREAM_EXISTS, + }); + + try { + await client.multiStreamAppend(requests); + } catch (error) { + expect(error).toBeInstanceOf(WrongExpectedVersionError); + } + }); + }); + + optionalDescribe(!supported)("not supported (<25.0)", () => { + test("throw unsupported error", async () => { + const STREAM_NAME_1 = v4().toString(); + const STREAM_NAME_2 = v4().toString(); + const requests: AppendStreamRequest[] = []; + + requests.push({ + streamName: STREAM_NAME_1, + events: jsonTestEvents(), + expectedState: ANY, + }); + + requests.push({ + streamName: STREAM_NAME_2, + events: jsonTestEvents(), + expectedState: ANY, + }); + + try { + await client.multiStreamAppend(requests); + } catch (error) { + expect(error).toBeInstanceOf(UnsupportedError); + } + }); + }); +}); diff --git a/packages/test/src/utils/dockerImages.ts b/packages/test/src/utils/dockerImages.ts index e08854f1..f266a366 100644 --- a/packages/test/src/utils/dockerImages.ts +++ b/packages/test/src/utils/dockerImages.ts @@ -1,7 +1,7 @@ const kdbImage = ((): string => { const image = process.env.KURRENT_IMAGE ?? - "docker.kurrent.io/eventstore/eventstoredb-ee:lts"; + "docker.cloudsmith.io/eventstore/kurrent-staging/kurrentdb:ci"; return image; })(); diff --git a/packages/test/src/utils/testEvents.ts b/packages/test/src/utils/testEvents.ts index d06772b8..92f545a4 100644 --- a/packages/test/src/utils/testEvents.ts +++ b/packages/test/src/utils/testEvents.ts @@ -5,7 +5,11 @@ export interface TestEventData { index: number; } -export const jsonTestEvents = (count = 4, type = "test"): EventData[] => +export const jsonTestEvents = ( + count = 4, + type = "test", + metadata?: Record +): EventData[] => Array.from({ length: count }, (_, i) => jsonEvent({ type, @@ -13,6 +17,7 @@ export const jsonTestEvents = (count = 4, type = "test"): EventData[] => message: "test", index: i, }, + ...(metadata && { metadata }), }) ); diff --git a/yarn.lock b/yarn.lock index 957a2750..9c913868 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1130,12 +1130,14 @@ __metadata: "@types/debug": "npm:^4.1.12" "@types/google-protobuf": "npm:^3.15.12" "@types/node": "npm:^22.10.2" + "@types/semver": "npm:^7.7.0" "@types/uuid": "npm:^10.0.0" debug: "npm:^4.4.0" google-protobuf: "npm:^3.21.4" grpc-tools: "npm:^1.12.4" grpc_tools_node_protoc_ts: "npm:^5.3.3" nx: "npm:20.1.3" + semver: "npm:^7.7.2" shx: "npm:^0.3.4" uuid: "npm:11.0.3" languageName: unknown @@ -1394,6 +1396,17 @@ __metadata: languageName: node linkType: hard +"@opentelemetry/core@npm:2.0.1": + version: 2.0.1 + resolution: "@opentelemetry/core@npm:2.0.1" + dependencies: + "@opentelemetry/semantic-conventions": "npm:^1.29.0" + peerDependencies: + "@opentelemetry/api": ">=1.0.0 <1.10.0" + checksum: 10c0/d587b1289559757d80da98039f9f57612f84f72ec608cd665dc467c7c6c5ce3a987dfcc2c63b521c7c86ce984a2552b3ead15a0dc458de1cf6bde5cdfe4ca9d8 + languageName: node + linkType: hard + "@opentelemetry/exporter-trace-otlp-grpc@npm:^0.51.1": version: 0.51.1 resolution: "@opentelemetry/exporter-trace-otlp-grpc@npm:0.51.1" @@ -1513,6 +1526,18 @@ __metadata: languageName: node linkType: hard +"@opentelemetry/resources@npm:^2.0.1": + version: 2.0.1 + resolution: "@opentelemetry/resources@npm:2.0.1" + dependencies: + "@opentelemetry/core": "npm:2.0.1" + "@opentelemetry/semantic-conventions": "npm:^1.29.0" + peerDependencies: + "@opentelemetry/api": ">=1.3.0 <1.10.0" + checksum: 10c0/96532b7553b26607a7a892d72f6b03ad12bd542dc23c95135a8ae40362da9c883c21a4cff3d2296d9e0e9bd899a5977e325ed52d83142621a8ffe81d08d99341 + languageName: node + linkType: hard + "@opentelemetry/sdk-logs@npm:0.51.1": version: 0.51.1 resolution: "@opentelemetry/sdk-logs@npm:0.51.1" @@ -1602,6 +1627,13 @@ __metadata: languageName: node linkType: hard +"@opentelemetry/semantic-conventions@npm:^1.29.0": + version: 1.36.0 + resolution: "@opentelemetry/semantic-conventions@npm:1.36.0" + checksum: 10c0/edc8a6fe3ec4fc0c67ba3a92b86fb3dcc78fe1eb4f19838d8013c3232b9868540a034dd25cfe0afdd5eae752c5f0e9f42272ff46da144a2d5b35c644478e1c62 + languageName: node + linkType: hard + "@pkgjs/parseargs@npm:^0.11.0": version: 0.11.0 resolution: "@pkgjs/parseargs@npm:0.11.0" @@ -1939,6 +1971,13 @@ __metadata: languageName: node linkType: hard +"@types/semver@npm:^7.7.0": + version: 7.7.0 + resolution: "@types/semver@npm:7.7.0" + checksum: 10c0/6b5f65f647474338abbd6ee91a6bbab434662ddb8fe39464edcbcfc96484d388baad9eb506dff217b6fc1727a88894930eb1f308617161ac0f376fe06be4e1ee + languageName: node + linkType: hard + "@types/shimmer@npm:^1.2.0": version: 1.2.0 resolution: "@types/shimmer@npm:1.2.0" @@ -7169,6 +7208,7 @@ __metadata: dependencies: "@tsconfig/node18": "npm:^18.2.4" "@types/node": "npm:18.19.76" + "@types/semver": "npm:^7.7.0" "@typescript-eslint/eslint-plugin": "npm:^8.10.0" "@typescript-eslint/parser": "npm:^8.10.0" cross-env: "npm:^7.0.3" @@ -7176,7 +7216,7 @@ __metadata: eslint-plugin-tsdoc: "npm:^0.2.17" nx: "npm:20.1.3" prettier: "npm:^2.8.8" - semver: "npm:^7.6.3" + semver: "npm:^7.7.2" typescript: "npm:^5.6.3" languageName: unknown linkType: soft @@ -9577,6 +9617,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.7.2": + version: 7.7.2 + resolution: "semver@npm:7.7.2" + bin: + semver: bin/semver.js + checksum: 10c0/aca305edfbf2383c22571cb7714f48cadc7ac95371b4b52362fb8eeffdfbc0de0669368b82b2b15978f8848f01d7114da65697e56cd8c37b0dab8c58e543f9ea + languageName: node + linkType: hard + "set-blocking@npm:^2.0.0": version: 2.0.0 resolution: "set-blocking@npm:2.0.0" @@ -10365,6 +10414,7 @@ __metadata: "@opentelemetry/api": "npm:^1.9.0" "@opentelemetry/exporter-trace-otlp-grpc": "npm:^0.51.1" "@opentelemetry/instrumentation": "npm:^0.56.0" + "@opentelemetry/resources": "npm:^2.0.1" "@opentelemetry/sdk-trace-node": "npm:^1.30.0" "@opentelemetry/semantic-conventions": "npm:^1.28.0" "@types/debug": "npm:^4.1.12"