kubemq-js
Version:
KubeMQ SDK for Node.js — gRPC-based messaging client for Events, Queues, Commands, and Queries
1,505 lines (1,496 loc) • 352 kB
JavaScript
'use strict';
var crypto = require('crypto');
var grpc = require('@grpc/grpc-js');
var pb_1 = require('google-protobuf');
var events = require('events');
var promises = require('fs/promises');
var path = require('path');
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
var pb_1__namespace = /*#__PURE__*/_interopNamespace(pb_1);
// src/errors.ts
var ErrorCode = {
/** The initial connection or a reconnection attempt timed out. */
ConnectionTimeout: "CONNECTION_TIMEOUT",
/** Authentication credentials were rejected by the server. */
AuthFailed: "AUTH_FAILED",
/** A message or request failed input validation before being sent. */
ValidationFailed: "VALIDATION_FAILED",
/** The server is temporarily unavailable (transient). */
Unavailable: "UNAVAILABLE",
/** An operation exceeded its deadline. */
Timeout: "TIMEOUT",
/** The server throttled the request due to rate limiting. */
Throttled: "THROTTLED",
/** The requested channel or resource does not exist. */
NotFound: "NOT_FOUND",
/** The authenticated identity lacks permission for this operation. */
PermissionDenied: "PERMISSION_DENIED",
/** An unrecoverable internal error. */
Fatal: "FATAL",
/** The operation was cancelled via `AbortSignal`. */
Cancelled: "CANCELLED",
/** The reconnect buffer is full and cannot accept more messages. */
BufferFull: "BUFFER_FULL",
/** A streaming connection broke mid-flight. */
StreamBroken: "STREAM_BROKEN",
/** The client has been closed; no further operations are allowed. */
ClientClosed: "CLIENT_CLOSED",
/** The requested feature is not implemented in this SDK version. */
NotImplemented: "NOT_IMPLEMENTED",
/** A client configuration value is invalid. */
ConfigurationError: "CONFIGURATION_ERROR",
/** The transport connection is not in a ready state. */
ConnectionNotReady: "CONNECTION_NOT_READY",
/** All retry attempts have been exhausted. */
RetryExhausted: "RETRY_EXHAUSTED"
};
var ErrorCategory = {
/** A temporary failure that may self-resolve (e.g. network blip). */
Transient: "Transient",
/** An operation exceeded its deadline. */
Timeout: "Timeout",
/** The server is rate-limiting the client. */
Throttling: "Throttling",
/** Credentials are invalid or expired. */
Authentication: "Authentication",
/** The identity lacks required permissions. */
Authorization: "Authorization",
/** Input did not pass validation rules. */
Validation: "Validation",
/** The target resource was not found. */
NotFound: "NotFound",
/** Unrecoverable failure. */
Fatal: "Fatal",
/** The operation was explicitly cancelled. */
Cancellation: "Cancellation",
/** The system is applying backpressure (buffer full). */
Backpressure: "Backpressure",
/** A configuration parameter is invalid. */
Configuration: "Configuration"
};
var KUBEMQ_ERROR_SYMBOL = /* @__PURE__ */ Symbol.for("kubemq.error");
var KubeMQError = class _KubeMQError extends Error {
/**
* Cross-version instanceof check via well-known symbol.
* Only used on the base class — subclass discrimination uses the
* standard prototype chain (preserved by Object.setPrototypeOf).
*/
static [Symbol.hasInstance](instance) {
if (typeof instance !== "object" || instance === null || !instance[KUBEMQ_ERROR_SYMBOL]) {
return false;
}
if (this === _KubeMQError) return true;
return Function.prototype[Symbol.hasInstance].call(this, instance);
}
name;
code;
operation;
channel;
isRetryable;
requestId;
statusCode;
serverAddress;
timestamp;
category;
suggestion;
constructor(options) {
super(options.message, { cause: options.cause });
this.name = "KubeMQError";
this.code = options.code ?? ErrorCode.Fatal;
this.operation = options.operation;
this.channel = options.channel;
this.isRetryable = options.isRetryable ?? false;
this.requestId = options.requestId ?? crypto.randomUUID();
this.statusCode = options.statusCode;
this.serverAddress = options.serverAddress;
this.timestamp = /* @__PURE__ */ new Date();
this.category = ErrorCategory.Fatal;
this.suggestion = options.suggestion;
Object.setPrototypeOf(this, new.target.prototype);
Object.defineProperty(this, KUBEMQ_ERROR_SYMBOL, { value: true });
}
toJSON() {
return {
name: this.name,
code: this.code,
category: this.category,
message: this.message,
operation: this.operation,
channel: this.channel,
isRetryable: this.isRetryable,
requestId: this.requestId,
statusCode: this.statusCode,
serverAddress: this.serverAddress,
timestamp: this.timestamp.toISOString(),
suggestion: this.suggestion,
cause: this.cause instanceof Error ? this.cause.message : void 0
};
}
toSanitizedString() {
const parts = [
`${this.operation} failed`,
this.channel ? `on channel "${this.channel}"` : void 0,
`: ${this.message}`
].filter(Boolean).join(" ");
const lines = [parts];
if (this.suggestion) {
lines.push(` Suggestion: ${this.suggestion}`);
}
return lines.join("\n");
}
};
var ConnectionError = class extends KubeMQError {
category = ErrorCategory.Transient;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ConnectionTimeout,
isRetryable: options.isRetryable ?? true
});
this.name = "ConnectionError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var AuthenticationError = class extends KubeMQError {
category = ErrorCategory.Authentication;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.AuthFailed,
isRetryable: false
});
this.name = "AuthenticationError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var AuthorizationError = class extends KubeMQError {
category = ErrorCategory.Authorization;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.PermissionDenied,
isRetryable: false
});
this.name = "AuthorizationError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var KubeMQTimeoutError = class extends KubeMQError {
category = ErrorCategory.Timeout;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Timeout,
isRetryable: options.isRetryable ?? true
});
this.name = "KubeMQTimeoutError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var ValidationError = class extends KubeMQError {
category = ErrorCategory.Validation;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ValidationFailed,
isRetryable: false
});
this.name = "ValidationError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var TransientError = class extends KubeMQError {
category = ErrorCategory.Transient;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Unavailable,
isRetryable: options.isRetryable ?? true
});
this.name = "TransientError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var ThrottlingError = class extends KubeMQError {
category = ErrorCategory.Throttling;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Throttled,
isRetryable: options.isRetryable ?? true
});
this.name = "ThrottlingError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var NotFoundError = class extends KubeMQError {
category = ErrorCategory.NotFound;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.NotFound,
isRetryable: false
});
this.name = "NotFoundError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var FatalError = class extends KubeMQError {
category = ErrorCategory.Fatal;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Fatal,
isRetryable: options.isRetryable ?? false
});
this.name = "FatalError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var CancellationError = class extends KubeMQError {
category = ErrorCategory.Cancellation;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Cancelled,
isRetryable: false
});
this.name = "CancellationError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var BufferFullError = class extends KubeMQError {
category = ErrorCategory.Backpressure;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.BufferFull,
isRetryable: false
});
this.name = "BufferFullError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var StreamBrokenError = class extends KubeMQError {
category = ErrorCategory.Transient;
unacknowledgedMessageIds;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.StreamBroken,
isRetryable: options.isRetryable ?? true
});
this.name = "StreamBrokenError";
this.unacknowledgedMessageIds = options.unacknowledgedMessageIds;
Object.setPrototypeOf(this, new.target.prototype);
}
};
var ClientClosedError = class extends KubeMQError {
category = ErrorCategory.Fatal;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ClientClosed,
isRetryable: false
});
this.name = "ClientClosedError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var ConnectionNotReadyError = class extends ConnectionError {
category = ErrorCategory.Transient;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ConnectionNotReady,
isRetryable: options.isRetryable ?? false
});
this.name = "ConnectionNotReadyError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var ConfigurationError = class extends KubeMQError {
category = ErrorCategory.Configuration;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ConfigurationError,
isRetryable: false
});
this.name = "ConfigurationError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var RetryExhaustedError = class extends KubeMQError {
attempts;
maxRetries;
totalDuration;
lastError;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.RetryExhausted,
isRetryable: false
});
this.name = "RetryExhaustedError";
this.attempts = options.attempts;
this.maxRetries = options.maxRetries ?? options.attempts;
this.totalDuration = options.totalDuration;
this.lastError = options.lastError;
Object.setPrototypeOf(this, new.target.prototype);
}
toSanitizedString() {
const base = super.toSanitizedString();
return `${base}
Retries exhausted: ${String(this.attempts)}/${String(this.maxRetries)} attempts over ${String(this.totalDuration)}ms`;
}
};
var NotImplementedError = class extends KubeMQError {
category = ErrorCategory.Fatal;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.NotImplemented,
isRetryable: false
});
this.name = "NotImplementedError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var PartialFailureError = class extends KubeMQError {
failures;
constructor(options) {
super(options);
this.name = "PartialFailureError";
this.failures = options.failures;
Object.setPrototypeOf(this, new.target.prototype);
}
};
var HandlerError = class extends KubeMQError {
category = ErrorCategory.Fatal;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.Fatal,
isRetryable: options.isRetryable ?? false
});
this.name = "HandlerError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var SenderDisconnectedError = class extends TransientError {
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.StreamBroken,
isRetryable: options.isRetryable ?? true
});
this.name = "SenderDisconnectedError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
var SenderClosedError = class extends KubeMQError {
category = ErrorCategory.Fatal;
constructor(options) {
super({
...options,
code: options.code ?? ErrorCode.ClientClosed,
isRetryable: options.isRetryable ?? false
});
this.name = "SenderClosedError";
Object.setPrototypeOf(this, new.target.prototype);
}
};
// src/internal/utils/encoding.ts
var encoder = new TextEncoder();
var decoder = new TextDecoder("utf-8", { fatal: true });
function stringToBytes(str) {
return encoder.encode(str);
}
function bytesToString(bytes) {
return decoder.decode(bytes);
}
function toBytes(input) {
if (typeof input === "string") {
return encoder.encode(input);
}
return input;
}
function toBuffer(data) {
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
}
// src/internal/utils/body.ts
function normalizeBody(body) {
if (typeof body === "string") {
return stringToBytes(body);
}
if (Buffer.isBuffer(body)) {
return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
}
return body;
}
function bodyToString(body) {
return bytesToString(body);
}
// src/internal/validation/message-validator.ts
function fail(message, operation, channel, suggestion) {
throw new ValidationError({
code: ErrorCode.ValidationFailed,
message,
operation,
channel,
isRetryable: false,
suggestion
});
}
function requireNonEmptyChannel(channel, operation) {
if (typeof channel !== "string" || channel.trim().length === 0) {
fail(
"Channel name is required and must not be empty",
operation,
void 0,
"Provide a non-empty channel name, e.g., 'my-events'"
);
}
}
function requireBody(msg, operation) {
const hasBody = msg.body !== void 0 && msg.body !== null && (typeof msg.body === "string" ? msg.body.length > 0 : msg.body.length > 0);
const hasMetadata = typeof msg.metadata === "string" && msg.metadata.trim().length > 0;
const hasTags = msg.tags !== void 0 && Object.keys(msg.tags).length > 0;
if (!hasBody && !hasMetadata && !hasTags) {
fail(
"Message must have at least one of: body, metadata, or tags",
operation,
msg.channel,
"Provide a body (string or Uint8Array), metadata string, or tags"
);
}
}
function requirePositive(value, field, operation) {
if (value !== void 0 && value <= 0) {
fail(`${field} must be a positive number, got ${String(value)}`, operation);
}
}
function requireNonNegative(value, field, operation) {
if (value !== void 0 && value < 0) {
fail(`${field} must be non-negative, got ${String(value)}`, operation);
}
}
function validateChannelFormat(channel, allowWildcards, operation) {
if (!allowWildcards && /[*>]/.test(channel)) {
fail(
"Channel name cannot contain wildcards (* or >)",
operation,
channel,
"Wildcards are only allowed for Events subscribe"
);
}
if (/\s/.test(channel)) {
fail(
"Channel name cannot contain whitespace",
operation,
channel,
"Remove whitespace from channel name"
);
}
if (channel.endsWith(".")) {
fail(
'Channel name cannot end with "."',
operation,
channel,
"Remove trailing dot from channel name"
);
}
}
function validateEventMessage(msg, operation) {
requireNonEmptyChannel(msg.channel, operation);
validateChannelFormat(msg.channel, false, operation);
requireBody(msg, operation);
}
function validateEventStoreMessage(msg, operation) {
requireNonEmptyChannel(msg.channel, operation);
validateChannelFormat(msg.channel, false, operation);
requireBody(msg, operation);
}
function validateQueueMessage(msg, operation) {
requireNonEmptyChannel(msg.channel, operation);
validateChannelFormat(msg.channel, false, operation);
requireBody(msg, operation);
if (msg.policy) {
requireNonNegative(msg.policy.delaySeconds, "policy.delaySeconds", operation);
requireNonNegative(msg.policy.expirationSeconds, "policy.expirationSeconds", operation);
requireNonNegative(msg.policy.maxReceiveCount, "policy.maxReceiveCount", operation);
if (msg.policy.maxReceiveCount !== void 0 && msg.policy.maxReceiveCount > 0) {
if (!msg.policy.maxReceiveQueue || msg.policy.maxReceiveQueue.trim().length === 0) {
fail(
"policy.maxReceiveQueue is required when policy.maxReceiveCount > 0",
operation,
msg.channel,
"Provide a dead-letter queue name for rejected messages"
);
}
}
}
}
function validateCommandMessage(msg, operation) {
requireNonEmptyChannel(msg.channel, operation);
validateChannelFormat(msg.channel, false, operation);
requireBody(msg, operation);
if (msg.timeoutInSeconds <= 0) {
fail(
"Command message requires a positive timeoutInSeconds",
operation,
msg.channel,
"Set timeoutInSeconds to the maximum time (in seconds) to wait for a response"
);
}
}
function validateQueryMessage(msg, operation) {
requireNonEmptyChannel(msg.channel, operation);
validateChannelFormat(msg.channel, false, operation);
requireBody(msg, operation);
if (msg.timeoutInSeconds <= 0) {
fail(
"Query message requires a positive timeoutInSeconds",
operation,
msg.channel,
"Set timeoutInSeconds to the maximum time (in seconds) to wait for a response"
);
}
if (msg.cacheKey && (!msg.cacheTtlInSeconds || msg.cacheTtlInSeconds <= 0)) {
fail(
"cacheTtlInSeconds is required and must be > 0 when cacheKey is set",
operation,
msg.channel,
"Set cacheTtlInSeconds to a positive number of seconds"
);
}
if (msg.cacheTtlInSeconds !== void 0) {
requirePositive(msg.cacheTtlInSeconds, "cacheTtlInSeconds", operation);
}
}
function validateQueuePollRequest(req, operation) {
requireNonEmptyChannel(req.channel, operation);
requirePositive(req.waitTimeoutSeconds, "waitTimeoutSeconds", operation);
if (req.maxMessages !== void 0) {
requirePositive(req.maxMessages, "maxMessages", operation);
}
if (req.maxMessages !== void 0 && req.maxMessages > 1024) {
fail("maxMessages must be <= 1024", operation, req.channel);
}
if (req.waitTimeoutSeconds > 3600) {
fail("waitTimeoutSeconds must be <= 3600", operation, req.channel);
}
}
function validateSubscription(sub, operation, allowWildcards = false) {
requireNonEmptyChannel(sub.channel, operation);
validateChannelFormat(sub.channel, allowWildcards, operation);
}
function validateEventStoreSubscription(sub, operation) {
requireNonEmptyChannel(sub.channel, operation);
if (/[*>]/.test(sub.channel)) {
fail(
"EventsStore subscriptions do not support wildcard channels",
operation,
sub.channel,
"Use Events subscribe for wildcard patterns"
);
}
if (sub.startFrom == null) {
fail(
"EventStore subscription requires a startFrom value",
operation,
sub.channel,
"Set startFrom to one of the EventStoreStartPosition values (e.g., EventStoreStartPosition.StartFromNew)"
);
}
if (sub.startFrom === 4 /* StartAtSequence */) {
if (sub.startValue === void 0 || sub.startValue <= 0) {
fail(
"EventStore subscription with StartAtSequence requires a positive startValue (sequence number)",
operation,
sub.channel
);
}
}
if (sub.startFrom === 5 /* StartAtTime */) {
if (sub.startValue === void 0 || sub.startValue <= 0) {
fail(
"EventStore subscription with StartAtTime requires a positive startValue (Unix timestamp in seconds)",
operation,
sub.channel
);
}
}
if (sub.startFrom === 6 /* StartAtTimeDelta */) {
if (sub.startValue === void 0 || sub.startValue <= 0) {
fail(
"EventStore subscription with StartAtTimeDelta requires a positive startValue (seconds from now)",
operation,
sub.channel
);
}
}
}
function validateResponseMessage(resp, operation) {
if (!resp.id || resp.id.trim().length === 0) {
fail("Response id (RequestID) is required", operation);
}
if (!resp.replyChannel || resp.replyChannel.trim().length === 0) {
fail("Response replyChannel is required", operation);
}
}
// src/messages/events-store.ts
var EventStoreStartPosition = /* @__PURE__ */ ((EventStoreStartPosition2) => {
EventStoreStartPosition2[EventStoreStartPosition2["StartFromNew"] = 1] = "StartFromNew";
EventStoreStartPosition2[EventStoreStartPosition2["StartFromFirst"] = 2] = "StartFromFirst";
EventStoreStartPosition2[EventStoreStartPosition2["StartFromLast"] = 3] = "StartFromLast";
EventStoreStartPosition2[EventStoreStartPosition2["StartAtSequence"] = 4] = "StartAtSequence";
EventStoreStartPosition2[EventStoreStartPosition2["StartAtTime"] = 5] = "StartAtTime";
EventStoreStartPosition2[EventStoreStartPosition2["StartAtTimeDelta"] = 6] = "StartAtTimeDelta";
return EventStoreStartPosition2;
})(EventStoreStartPosition || {});
function createEventStoreMessage(opts) {
validateEventStoreMessage(opts, "createEventStoreMessage");
const msg = {
channel: opts.channel,
body: opts.body !== void 0 ? normalizeBody(opts.body) : void 0,
metadata: opts.metadata ?? "",
tags: opts.tags ?? {},
id: opts.id ?? crypto.randomUUID(),
clientId: opts.clientId
};
return Object.freeze(msg);
}
// src/internal/transport/connection-state.ts
var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
ConnectionState2["IDLE"] = "IDLE";
ConnectionState2["CONNECTING"] = "CONNECTING";
ConnectionState2["READY"] = "READY";
ConnectionState2["RECONNECTING"] = "RECONNECTING";
ConnectionState2["CLOSED"] = "CLOSED";
return ConnectionState2;
})(ConnectionState || {});
var VALID_TRANSITIONS = /* @__PURE__ */ new Map([
["IDLE" /* IDLE */, /* @__PURE__ */ new Set(["CONNECTING" /* CONNECTING */, "CLOSED" /* CLOSED */])],
[
"CONNECTING" /* CONNECTING */,
/* @__PURE__ */ new Set(["READY" /* READY */, "RECONNECTING" /* RECONNECTING */, "CLOSED" /* CLOSED */])
],
["READY" /* READY */, /* @__PURE__ */ new Set(["RECONNECTING" /* RECONNECTING */, "CLOSED" /* CLOSED */])],
[
"RECONNECTING" /* RECONNECTING */,
/* @__PURE__ */ new Set(["RECONNECTING" /* RECONNECTING */, "READY" /* READY */, "CLOSED" /* CLOSED */])
],
["CLOSED" /* CLOSED */, /* @__PURE__ */ new Set()]
]);
function isValidTransition(from, to) {
return VALID_TRANSITIONS.get(from)?.has(to) ?? false;
}
var kubemq;
((kubemq2) => {
((StreamRequestType2) => {
StreamRequestType2[StreamRequestType2["StreamRequestTypeUnknown"] = 0] = "StreamRequestTypeUnknown";
StreamRequestType2[StreamRequestType2["ReceiveMessage"] = 1] = "ReceiveMessage";
StreamRequestType2[StreamRequestType2["AckMessage"] = 2] = "AckMessage";
StreamRequestType2[StreamRequestType2["RejectMessage"] = 3] = "RejectMessage";
StreamRequestType2[StreamRequestType2["ModifyVisibility"] = 4] = "ModifyVisibility";
StreamRequestType2[StreamRequestType2["ResendMessage"] = 5] = "ResendMessage";
StreamRequestType2[StreamRequestType2["SendModifiedMessage"] = 6] = "SendModifiedMessage";
})(kubemq2.StreamRequestType || (kubemq2.StreamRequestType = {}));
((QueuesDownstreamRequestType2) => {
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["PollRequestTypeUnknown"] = 0] = "PollRequestTypeUnknown";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["Get"] = 1] = "Get";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["AckAll"] = 2] = "AckAll";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["AckRange"] = 3] = "AckRange";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["NAckAll"] = 4] = "NAckAll";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["NAckRange"] = 5] = "NAckRange";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["ReQueueAll"] = 6] = "ReQueueAll";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["ReQueueRange"] = 7] = "ReQueueRange";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["ActiveOffsets"] = 8] = "ActiveOffsets";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["TransactionStatus"] = 9] = "TransactionStatus";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["CloseByClient"] = 10] = "CloseByClient";
QueuesDownstreamRequestType2[QueuesDownstreamRequestType2["CloseByServer"] = 11] = "CloseByServer";
})(kubemq2.QueuesDownstreamRequestType || (kubemq2.QueuesDownstreamRequestType = {}));
class PingResult extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("Host" in data && data.Host != void 0) {
this.Host = data.Host;
}
if ("Version" in data && data.Version != void 0) {
this.Version = data.Version;
}
if ("ServerStartTime" in data && data.ServerStartTime != void 0) {
this.ServerStartTime = data.ServerStartTime;
}
if ("ServerUpTimeSeconds" in data && data.ServerUpTimeSeconds != void 0) {
this.ServerUpTimeSeconds = data.ServerUpTimeSeconds;
}
}
}
get Host() {
return pb_1__namespace.Message.getFieldWithDefault(this, 1, "");
}
set Host(value) {
pb_1__namespace.Message.setField(this, 1, value);
}
get Version() {
return pb_1__namespace.Message.getFieldWithDefault(this, 2, "");
}
set Version(value) {
pb_1__namespace.Message.setField(this, 2, value);
}
get ServerStartTime() {
return pb_1__namespace.Message.getFieldWithDefault(this, 3, 0);
}
set ServerStartTime(value) {
pb_1__namespace.Message.setField(this, 3, value);
}
get ServerUpTimeSeconds() {
return pb_1__namespace.Message.getFieldWithDefault(this, 4, 0);
}
set ServerUpTimeSeconds(value) {
pb_1__namespace.Message.setField(this, 4, value);
}
static fromObject(data) {
const message = new PingResult({});
if (data.Host != null) {
message.Host = data.Host;
}
if (data.Version != null) {
message.Version = data.Version;
}
if (data.ServerStartTime != null) {
message.ServerStartTime = data.ServerStartTime;
}
if (data.ServerUpTimeSeconds != null) {
message.ServerUpTimeSeconds = data.ServerUpTimeSeconds;
}
return message;
}
toObject() {
const data = {};
if (this.Host != null) {
data.Host = this.Host;
}
if (this.Version != null) {
data.Version = this.Version;
}
if (this.ServerStartTime != null) {
data.ServerStartTime = this.ServerStartTime;
}
if (this.ServerUpTimeSeconds != null) {
data.ServerUpTimeSeconds = this.ServerUpTimeSeconds;
}
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (this.Host.length) writer.writeString(1, this.Host);
if (this.Version.length) writer.writeString(2, this.Version);
if (this.ServerStartTime != 0) writer.writeInt64(3, this.ServerStartTime);
if (this.ServerUpTimeSeconds != 0) writer.writeInt64(4, this.ServerUpTimeSeconds);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new PingResult();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.Host = reader.readString();
break;
case 2:
message.Version = reader.readString();
break;
case 3:
message.ServerStartTime = reader.readInt64();
break;
case 4:
message.ServerUpTimeSeconds = reader.readInt64();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary() {
return this.serialize();
}
static deserializeBinary(bytes) {
return PingResult.deserialize(bytes);
}
}
kubemq2.PingResult = PingResult;
class Empty extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
}
static fromObject(data) {
const message = new Empty({});
return message;
}
toObject() {
const data = {};
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new Empty();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
default:
reader.skipField();
}
}
return message;
}
serializeBinary() {
return this.serialize();
}
static deserializeBinary(bytes) {
return Empty.deserialize(bytes);
}
}
kubemq2.Empty = Empty;
class Result extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("EventID" in data && data.EventID != void 0) {
this.EventID = data.EventID;
}
if ("Sent" in data && data.Sent != void 0) {
this.Sent = data.Sent;
}
if ("Error" in data && data.Error != void 0) {
this.Error = data.Error;
}
}
}
get EventID() {
return pb_1__namespace.Message.getFieldWithDefault(this, 1, "");
}
set EventID(value) {
pb_1__namespace.Message.setField(this, 1, value);
}
get Sent() {
return pb_1__namespace.Message.getFieldWithDefault(this, 2, false);
}
set Sent(value) {
pb_1__namespace.Message.setField(this, 2, value);
}
get Error() {
return pb_1__namespace.Message.getFieldWithDefault(this, 3, "");
}
set Error(value) {
pb_1__namespace.Message.setField(this, 3, value);
}
static fromObject(data) {
const message = new Result({});
if (data.EventID != null) {
message.EventID = data.EventID;
}
if (data.Sent != null) {
message.Sent = data.Sent;
}
if (data.Error != null) {
message.Error = data.Error;
}
return message;
}
toObject() {
const data = {};
if (this.EventID != null) {
data.EventID = this.EventID;
}
if (this.Sent != null) {
data.Sent = this.Sent;
}
if (this.Error != null) {
data.Error = this.Error;
}
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (this.EventID.length) writer.writeString(1, this.EventID);
if (this.Sent != false) writer.writeBool(2, this.Sent);
if (this.Error.length) writer.writeString(3, this.Error);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new Result();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.EventID = reader.readString();
break;
case 2:
message.Sent = reader.readBool();
break;
case 3:
message.Error = reader.readString();
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary() {
return this.serialize();
}
static deserializeBinary(bytes) {
return Result.deserialize(bytes);
}
}
kubemq2.Result = Result;
class Event extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("EventID" in data && data.EventID != void 0) {
this.EventID = data.EventID;
}
if ("ClientID" in data && data.ClientID != void 0) {
this.ClientID = data.ClientID;
}
if ("Channel" in data && data.Channel != void 0) {
this.Channel = data.Channel;
}
if ("Metadata" in data && data.Metadata != void 0) {
this.Metadata = data.Metadata;
}
if ("Body" in data && data.Body != void 0) {
this.Body = data.Body;
}
if ("Store" in data && data.Store != void 0) {
this.Store = data.Store;
}
if ("Tags" in data && data.Tags != void 0) {
this.Tags = data.Tags;
}
}
if (!this.Tags) this.Tags = /* @__PURE__ */ new Map();
}
get EventID() {
return pb_1__namespace.Message.getFieldWithDefault(this, 1, "");
}
set EventID(value) {
pb_1__namespace.Message.setField(this, 1, value);
}
get ClientID() {
return pb_1__namespace.Message.getFieldWithDefault(this, 2, "");
}
set ClientID(value) {
pb_1__namespace.Message.setField(this, 2, value);
}
get Channel() {
return pb_1__namespace.Message.getFieldWithDefault(this, 3, "");
}
set Channel(value) {
pb_1__namespace.Message.setField(this, 3, value);
}
get Metadata() {
return pb_1__namespace.Message.getFieldWithDefault(this, 4, "");
}
set Metadata(value) {
pb_1__namespace.Message.setField(this, 4, value);
}
get Body() {
return pb_1__namespace.Message.getFieldWithDefault(this, 5, new Uint8Array(0));
}
set Body(value) {
pb_1__namespace.Message.setField(this, 5, value);
}
get Store() {
return pb_1__namespace.Message.getFieldWithDefault(this, 6, false);
}
set Store(value) {
pb_1__namespace.Message.setField(this, 6, value);
}
get Tags() {
return pb_1__namespace.Message.getField(this, 7);
}
set Tags(value) {
pb_1__namespace.Message.setField(this, 7, value);
}
static fromObject(data) {
const message = new Event({});
if (data.EventID != null) {
message.EventID = data.EventID;
}
if (data.ClientID != null) {
message.ClientID = data.ClientID;
}
if (data.Channel != null) {
message.Channel = data.Channel;
}
if (data.Metadata != null) {
message.Metadata = data.Metadata;
}
if (data.Body != null) {
message.Body = data.Body;
}
if (data.Store != null) {
message.Store = data.Store;
}
if (typeof data.Tags == "object") {
message.Tags = new Map(Object.entries(data.Tags));
}
return message;
}
toObject() {
const data = {};
if (this.EventID != null) {
data.EventID = this.EventID;
}
if (this.ClientID != null) {
data.ClientID = this.ClientID;
}
if (this.Channel != null) {
data.Channel = this.Channel;
}
if (this.Metadata != null) {
data.Metadata = this.Metadata;
}
if (this.Body != null) {
data.Body = this.Body;
}
if (this.Store != null) {
data.Store = this.Store;
}
if (this.Tags != null) {
data.Tags = Object.fromEntries(this.Tags);
}
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (this.EventID.length) writer.writeString(1, this.EventID);
if (this.ClientID.length) writer.writeString(2, this.ClientID);
if (this.Channel.length) writer.writeString(3, this.Channel);
if (this.Metadata.length) writer.writeString(4, this.Metadata);
if (this.Body.length) writer.writeBytes(5, this.Body);
if (this.Store != false) writer.writeBool(6, this.Store);
for (const [key, value] of this.Tags) {
writer.writeMessage(7, this.Tags, () => {
writer.writeString(1, key);
writer.writeString(2, value);
});
}
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new Event();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.EventID = reader.readString();
break;
case 2:
message.ClientID = reader.readString();
break;
case 3:
message.Channel = reader.readString();
break;
case 4:
message.Metadata = reader.readString();
break;
case 5:
message.Body = reader.readBytes();
break;
case 6:
message.Store = reader.readBool();
break;
case 7:
reader.readMessage(
message,
() => pb_1__namespace.Map.deserializeBinary(
message.Tags,
reader,
reader.readString,
reader.readString
)
);
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary() {
return this.serialize();
}
static deserializeBinary(bytes) {
return Event.deserialize(bytes);
}
}
kubemq2.Event = Event;
class EventReceive extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("EventID" in data && data.EventID != void 0) {
this.EventID = data.EventID;
}
if ("Channel" in data && data.Channel != void 0) {
this.Channel = data.Channel;
}
if ("Metadata" in data && data.Metadata != void 0) {
this.Metadata = data.Metadata;
}
if ("Body" in data && data.Body != void 0) {
this.Body = data.Body;
}
if ("Timestamp" in data && data.Timestamp != void 0) {
this.Timestamp = data.Timestamp;
}
if ("Sequence" in data && data.Sequence != void 0) {
this.Sequence = data.Sequence;
}
if ("Tags" in data && data.Tags != void 0) {
this.Tags = data.Tags;
}
}
if (!this.Tags) this.Tags = /* @__PURE__ */ new Map();
}
get EventID() {
return pb_1__namespace.Message.getFieldWithDefault(this, 1, "");
}
set EventID(value) {
pb_1__namespace.Message.setField(this, 1, value);
}
get Channel() {
return pb_1__namespace.Message.getFieldWithDefault(this, 2, "");
}
set Channel(value) {
pb_1__namespace.Message.setField(this, 2, value);
}
get Metadata() {
return pb_1__namespace.Message.getFieldWithDefault(this, 3, "");
}
set Metadata(value) {
pb_1__namespace.Message.setField(this, 3, value);
}
get Body() {
return pb_1__namespace.Message.getFieldWithDefault(this, 4, new Uint8Array(0));
}
set Body(value) {
pb_1__namespace.Message.setField(this, 4, value);
}
get Timestamp() {
return pb_1__namespace.Message.getFieldWithDefault(this, 5, 0);
}
set Timestamp(value) {
pb_1__namespace.Message.setField(this, 5, value);
}
get Sequence() {
return pb_1__namespace.Message.getFieldWithDefault(this, 6, 0);
}
set Sequence(value) {
pb_1__namespace.Message.setField(this, 6, value);
}
get Tags() {
return pb_1__namespace.Message.getField(this, 7);
}
set Tags(value) {
pb_1__namespace.Message.setField(this, 7, value);
}
static fromObject(data) {
const message = new EventReceive({});
if (data.EventID != null) {
message.EventID = data.EventID;
}
if (data.Channel != null) {
message.Channel = data.Channel;
}
if (data.Metadata != null) {
message.Metadata = data.Metadata;
}
if (data.Body != null) {
message.Body = data.Body;
}
if (data.Timestamp != null) {
message.Timestamp = data.Timestamp;
}
if (data.Sequence != null) {
message.Sequence = data.Sequence;
}
if (typeof data.Tags == "object") {
message.Tags = new Map(Object.entries(data.Tags));
}
return message;
}
toObject() {
const data = {};
if (this.EventID != null) {
data.EventID = this.EventID;
}
if (this.Channel != null) {
data.Channel = this.Channel;
}
if (this.Metadata != null) {
data.Metadata = this.Metadata;
}
if (this.Body != null) {
data.Body = this.Body;
}
if (this.Timestamp != null) {
data.Timestamp = this.Timestamp;
}
if (this.Sequence != null) {
data.Sequence = this.Sequence;
}
if (this.Tags != null) {
data.Tags = Object.fromEntries(this.Tags);
}
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (this.EventID.length) writer.writeString(1, this.EventID);
if (this.Channel.length) writer.writeString(2, this.Channel);
if (this.Metadata.length) writer.writeString(3, this.Metadata);
if (this.Body.length) writer.writeBytes(4, this.Body);
if (this.Timestamp != 0) writer.writeInt64(5, this.Timestamp);
if (this.Sequence != 0) writer.writeUint64(6, this.Sequence);
for (const [key, value] of this.Tags) {
writer.writeMessage(7, this.Tags, () => {
writer.writeString(1, key);
writer.writeString(2, value);
});
}
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new EventReceive();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.EventID = reader.readString();
break;
case 2:
message.Channel = reader.readString();
break;
case 3:
message.Metadata = reader.readString();
break;
case 4:
message.Body = reader.readBytes();
break;
case 5:
message.Timestamp = reader.readInt64();
break;
case 6:
message.Sequence = reader.readUint64();
break;
case 7:
reader.readMessage(
message,
() => pb_1__namespace.Map.deserializeBinary(
message.Tags,
reader,
reader.readString,
reader.readString
)
);
break;
default:
reader.skipField();
}
}
return message;
}
serializeBinary() {
return this.serialize();
}
static deserializeBinary(bytes) {
return EventReceive.deserialize(bytes);
}
}
kubemq2.EventReceive = EventReceive;
class Subscribe extends pb_1__namespace.Message {
#one_of_decls = [];
constructor(data) {
super();
pb_1__namespace.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("SubscribeTypeData" in data && data.SubscribeTypeData != void 0) {
this.SubscribeTypeData = data.SubscribeTypeData;
}
if ("ClientID" in data && data.ClientID != void 0) {
this.ClientID = data.ClientID;
}
if ("Channel" in data && data.Channel != void 0) {
this.Channel = data.Channel;
}
if ("Group" in data && data.Group != void 0) {
this.Group = data.Group;
}
if ("EventsStoreTypeData" in data && data.EventsStoreTypeData != void 0) {
this.EventsStoreTypeData = data.EventsStoreTypeData;
}
if ("EventsStoreTypeValue" in data && data.EventsStoreTypeValue != void 0) {
this.EventsStoreTypeValue = data.EventsStoreTypeValue;
}
}
}
get SubscribeTypeData() {
return pb_1__namespace.Message.getFieldWithDefault(
this,
1,
Subscribe.SubscribeType.SubscribeTypeUndefined
);
}
set SubscribeTypeData(value) {
pb_1__namespace.Message.setField(this, 1, value);
}
get ClientID() {
return pb_1__namespace.Message.getFieldWithDefault(this, 2, "");
}
set ClientID(value) {
pb_1__namespace.Message.setField(this, 2, value);
}
get Channel() {
return pb_1__namespace.Message.getFieldWithDefault(this, 3, "");
}
set Channel(value) {
pb_1__namespace.Message.setField(this, 3, value);
}
get Group() {
return pb_1__namespace.Message.getFieldWithDefault(this, 4, "");
}
set Group(value) {
pb_1__namespace.Message.setField(this, 4, value);
}
get EventsStoreTypeData() {
return pb_1__namespace.Message.getFieldWithDefault(
this,
5,
Subscribe.EventsStoreType.EventsStoreTypeUndefined
);
}
set EventsStoreTypeData(value) {
pb_1__namespace.Message.setField(this, 5, value);
}
get EventsStoreTypeValue() {
return pb_1__namespace.Message.getFieldWithDefault(this, 6, 0);
}
set EventsStoreTypeValue(value) {
pb_1__namespace.Message.setField(this, 6, value);
}
static fromObject(data) {
const message = new Subscribe({});
if (data.SubscribeTypeData != null) {
message.SubscribeTypeData = data.SubscribeTypeData;
}
if (data.ClientID != null) {
message.ClientID = data.ClientID;
}
if (data.Channel != null) {
message.Channel = data.Channel;
}
if (data.Group != null) {
message.Group = data.Group;
}
if (data.EventsStoreTypeData != null) {
message.EventsStoreTypeData = data.EventsStoreTypeData;
}
if (data.EventsStoreTypeValue != null) {
message.EventsStoreTypeValue = data.EventsStoreTypeValue;
}
return message;
}
toObject() {
const data = {};
if (this.SubscribeTypeData != null) {
data.SubscribeTypeData = this.SubscribeTypeData;
}
if (this.ClientID != null) {
data.ClientID = this.ClientID;
}
if (this.Channel != null) {
data.Channel = this.Channel;
}
if (this.Group != null) {
data.Group = this.Group;
}
if (this.EventsStoreTypeData != null) {
data.EventsStoreTypeData = this.EventsStoreTypeData;
}
if (this.EventsStoreTypeValue != null) {
data.EventsStoreTypeValue = this.EventsStoreTypeValue;
}
return data;
}
serialize(w) {
const writer = w || new pb_1__namespace.BinaryWriter();
if (this.SubscribeTypeData != Subscribe.SubscribeType.SubscribeTypeUndefined)
writer.writeEnum(1, this.SubscribeTypeData);
if (this.ClientID.length) writer.writeString(2, this.ClientID);
if (this.Channel.length) writer.writeString(3, this.Channel);
if (this.Group.length) writer.writeString(4, this.Group);
if (this.EventsStoreTypeData != Subscribe.EventsStoreType.EventsStoreTypeUndefined)
writer.writeEnum(5, this.EventsStoreTypeData);
if (this.EventsStoreTypeValue != 0) writer.writeInt64(6, this.EventsStoreTypeValue);
if (!w) return writer.getResultBuffer();
}
static deserialize(bytes) {
const reader = bytes instanceof pb_1__namespace.BinaryReader ? bytes : new pb_1__namespace.BinaryReader(bytes), message = new Subscribe();
while (reader.nextField()) {
if (reader.isEndGroup()) break;
switch (reader.getFieldNumber()) {
case 1:
message.SubscribeTypeData = reader.readEnum();
break;
case 2:
message.ClientID = reader.readString();
break;
case 3:
message.Channel = reader.readString();
break;
case 4:
message.Group = reader.readString();
break;
case 5:
message.EventsStoreTypeData