@authzed/authzed-js-node
Version:
authzed js client for nodejs
861 lines (860 loc) • 235 kB
JavaScript
import { WireType } from "@protobuf-ts/runtime";
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
import { reflectionMergePartial } from "@protobuf-ts/runtime";
import { MESSAGE_TYPE } from "@protobuf-ts/runtime";
import { MessageType } from "@protobuf-ts/runtime";
import { FieldDescriptorProto_Type } from "../../google/protobuf/descriptor.js";
import { Timestamp } from "../../google/protobuf/timestamp.js";
import { Duration } from "../../google/protobuf/duration.js";
/**
* Specifies how FieldConstraints.ignore behaves. See the documentation for
* FieldConstraints.required for definitions of "populated" and "nullable".
*
* @generated from protobuf enum buf.validate.Ignore
*/
export var Ignore;
(function (Ignore) {
/**
* Validation is only skipped if it's an unpopulated nullable fields.
*
* ```proto
* syntax="proto3";
*
* message Request {
* // The uri rule applies to any value, including the empty string.
* string foo = 1 [
* (buf.validate.field).string.uri = true
* ];
*
* // The uri rule only applies if the field is set, including if it's
* // set to the empty string.
* optional string bar = 2 [
* (buf.validate.field).string.uri = true
* ];
*
* // The min_items rule always applies, even if the list is empty.
* repeated string baz = 3 [
* (buf.validate.field).repeated.min_items = 3
* ];
*
* // The custom CEL rule applies only if the field is set, including if
* // it's the "zero" value of that message.
* SomeMessage quux = 4 [
* (buf.validate.field).cel = {/* ... *\/}
* ];
* }
* ```
*
* @generated from protobuf enum value: IGNORE_UNSPECIFIED = 0;
*/
Ignore[Ignore["UNSPECIFIED"] = 0] = "UNSPECIFIED";
/**
* Validation is skipped if the field is unpopulated. This rule is redundant
* if the field is already nullable.
*
* ```proto
* syntax="proto3
*
* message Request {
* // The uri rule applies only if the value is not the empty string.
* string foo = 1 [
* (buf.validate.field).string.uri = true,
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
* ];
*
* // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this
* // case: the uri rule only applies if the field is set, including if
* // it's set to the empty string.
* optional string bar = 2 [
* (buf.validate.field).string.uri = true,
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
* ];
*
* // The min_items rule only applies if the list has at least one item.
* repeated string baz = 3 [
* (buf.validate.field).repeated.min_items = 3,
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
* ];
*
* // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this
* // case: the custom CEL rule applies only if the field is set, including
* // if it's the "zero" value of that message.
* SomeMessage quux = 4 [
* (buf.validate.field).cel = {/* ... *\/},
* (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED
* ];
* }
* ```
*
* @generated from protobuf enum value: IGNORE_IF_UNPOPULATED = 1;
*/
Ignore[Ignore["IF_UNPOPULATED"] = 1] = "IF_UNPOPULATED";
/**
* Validation is skipped if the field is unpopulated or if it is a nullable
* field populated with its default value. This is typically the zero or
* empty value, but proto2 scalars support custom defaults. For messages, the
* default is a non-null message with all its fields unpopulated.
*
* ```proto
* syntax="proto3
*
* message Request {
* // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in
* // this case; the uri rule applies only if the value is not the empty
* // string.
* string foo = 1 [
* (buf.validate.field).string.uri = true,
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
* ];
*
* // The uri rule only applies if the field is set to a value other than
* // the empty string.
* optional string bar = 2 [
* (buf.validate.field).string.uri = true,
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
* ];
*
* // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in
* // this case; the min_items rule only applies if the list has at least
* // one item.
* repeated string baz = 3 [
* (buf.validate.field).repeated.min_items = 3,
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
* ];
*
* // The custom CEL rule only applies if the field is set to a value other
* // than an empty message (i.e., fields are unpopulated).
* SomeMessage quux = 4 [
* (buf.validate.field).cel = {/* ... *\/},
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
* ];
* }
* ```
*
* This rule is affected by proto2 custom default values:
*
* ```proto
* syntax="proto2";
*
* message Request {
* // The gt rule only applies if the field is set and it's value is not
* the default (i.e., not -42). The rule even applies if the field is set
* to zero since the default value differs.
* optional int32 value = 1 [
* default = -42,
* (buf.validate.field).int32.gt = 0,
* (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE
* ];
* }
*
* @generated from protobuf enum value: IGNORE_IF_DEFAULT_VALUE = 2;
*/
Ignore[Ignore["IF_DEFAULT_VALUE"] = 2] = "IF_DEFAULT_VALUE";
/**
* The validation rules of this field will be skipped and not evaluated. This
* is useful for situations that necessitate turning off the rules of a field
* containing a message that may not make sense in the current context, or to
* temporarily disable constraints during development.
*
* ```proto
* message MyMessage {
* // The field's rules will always be ignored, including any validation's
* // on value's fields.
* MyOtherMessage value = 1 [
* (buf.validate.field).ignore = IGNORE_ALWAYS];
* }
* ```
*
* @generated from protobuf enum value: IGNORE_ALWAYS = 3;
*/
Ignore[Ignore["ALWAYS"] = 3] = "ALWAYS";
})(Ignore || (Ignore = {}));
/**
* WellKnownRegex contain some well-known patterns.
*
* @generated from protobuf enum buf.validate.KnownRegex
*/
export var KnownRegex;
(function (KnownRegex) {
/**
* @generated from protobuf enum value: KNOWN_REGEX_UNSPECIFIED = 0;
*/
KnownRegex[KnownRegex["UNSPECIFIED"] = 0] = "UNSPECIFIED";
/**
* HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2).
*
* @generated from protobuf enum value: KNOWN_REGEX_HTTP_HEADER_NAME = 1;
*/
KnownRegex[KnownRegex["HTTP_HEADER_NAME"] = 1] = "HTTP_HEADER_NAME";
/**
* HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4).
*
* @generated from protobuf enum value: KNOWN_REGEX_HTTP_HEADER_VALUE = 2;
*/
KnownRegex[KnownRegex["HTTP_HEADER_VALUE"] = 2] = "HTTP_HEADER_VALUE";
})(KnownRegex || (KnownRegex = {}));
// @generated message type with reflection information, may provide speed optimized methods
class Constraint$Type extends MessageType {
constructor() {
super("buf.validate.Constraint", [
{ no: 1, name: "id", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "message", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "expression", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ }
]);
}
create(value) {
const message = {};
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* optional string id */ 1:
message.id = reader.string();
break;
case /* optional string message */ 2:
message.message = reader.string();
break;
case /* optional string expression */ 3:
message.expression = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* optional string id = 1; */
if (message.id !== undefined)
writer.tag(1, WireType.LengthDelimited).string(message.id);
/* optional string message = 2; */
if (message.message !== undefined)
writer.tag(2, WireType.LengthDelimited).string(message.message);
/* optional string expression = 3; */
if (message.expression !== undefined)
writer.tag(3, WireType.LengthDelimited).string(message.expression);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.Constraint
*/
export const Constraint = new Constraint$Type();
// @generated message type with reflection information, may provide speed optimized methods
class MessageConstraints$Type extends MessageType {
constructor() {
super("buf.validate.MessageConstraints", [
{ no: 1, name: "disabled", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ },
{ no: 3, name: "cel", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Constraint }
]);
}
create(value) {
const message = { cel: [] };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* optional bool disabled */ 1:
message.disabled = reader.bool();
break;
case /* repeated buf.validate.Constraint cel */ 3:
message.cel.push(Constraint.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* optional bool disabled = 1; */
if (message.disabled !== undefined)
writer.tag(1, WireType.Varint).bool(message.disabled);
/* repeated buf.validate.Constraint cel = 3; */
for (let i = 0; i < message.cel.length; i++)
Constraint.internalBinaryWrite(message.cel[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.MessageConstraints
*/
export const MessageConstraints = new MessageConstraints$Type();
// @generated message type with reflection information, may provide speed optimized methods
class OneofConstraints$Type extends MessageType {
constructor() {
super("buf.validate.OneofConstraints", [
{ no: 1, name: "required", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ }
]);
}
create(value) {
const message = {};
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* optional bool required */ 1:
message.required = reader.bool();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* optional bool required = 1; */
if (message.required !== undefined)
writer.tag(1, WireType.Varint).bool(message.required);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.OneofConstraints
*/
export const OneofConstraints = new OneofConstraints$Type();
// @generated message type with reflection information, may provide speed optimized methods
class FieldConstraints$Type extends MessageType {
constructor() {
super("buf.validate.FieldConstraints", [
{ no: 23, name: "cel", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Constraint },
{ no: 25, name: "required", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/ },
{ no: 27, name: "ignore", kind: "enum", opt: true, T: () => ["buf.validate.Ignore", Ignore, "IGNORE_"] },
{ no: 1, name: "float", kind: "message", oneof: "type", T: () => FloatRules },
{ no: 2, name: "double", kind: "message", oneof: "type", T: () => DoubleRules },
{ no: 3, name: "int32", kind: "message", oneof: "type", T: () => Int32Rules },
{ no: 4, name: "int64", kind: "message", oneof: "type", T: () => Int64Rules },
{ no: 5, name: "uint32", kind: "message", oneof: "type", T: () => UInt32Rules },
{ no: 6, name: "uint64", kind: "message", oneof: "type", T: () => UInt64Rules },
{ no: 7, name: "sint32", kind: "message", oneof: "type", T: () => SInt32Rules },
{ no: 8, name: "sint64", kind: "message", oneof: "type", T: () => SInt64Rules },
{ no: 9, name: "fixed32", kind: "message", oneof: "type", T: () => Fixed32Rules },
{ no: 10, name: "fixed64", kind: "message", oneof: "type", T: () => Fixed64Rules },
{ no: 11, name: "sfixed32", kind: "message", oneof: "type", T: () => SFixed32Rules },
{ no: 12, name: "sfixed64", kind: "message", oneof: "type", T: () => SFixed64Rules },
{ no: 13, name: "bool", kind: "message", oneof: "type", T: () => BoolRules },
{ no: 14, name: "string", kind: "message", oneof: "type", T: () => StringRules },
{ no: 15, name: "bytes", kind: "message", oneof: "type", T: () => BytesRules },
{ no: 16, name: "enum", kind: "message", oneof: "type", T: () => EnumRules },
{ no: 18, name: "repeated", kind: "message", oneof: "type", T: () => RepeatedRules },
{ no: 19, name: "map", kind: "message", oneof: "type", T: () => MapRules },
{ no: 20, name: "any", kind: "message", oneof: "type", T: () => AnyRules },
{ no: 21, name: "duration", kind: "message", oneof: "type", T: () => DurationRules },
{ no: 22, name: "timestamp", kind: "message", oneof: "type", T: () => TimestampRules }
]);
}
create(value) {
const message = { cel: [], type: { oneofKind: undefined } };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated buf.validate.Constraint cel */ 23:
message.cel.push(Constraint.internalBinaryRead(reader, reader.uint32(), options));
break;
case /* optional bool required */ 25:
message.required = reader.bool();
break;
case /* optional buf.validate.Ignore ignore */ 27:
message.ignore = reader.int32();
break;
case /* buf.validate.FloatRules float */ 1:
message.type = {
oneofKind: "float",
float: FloatRules.internalBinaryRead(reader, reader.uint32(), options, message.type.float)
};
break;
case /* buf.validate.DoubleRules double */ 2:
message.type = {
oneofKind: "double",
double: DoubleRules.internalBinaryRead(reader, reader.uint32(), options, message.type.double)
};
break;
case /* buf.validate.Int32Rules int32 */ 3:
message.type = {
oneofKind: "int32",
int32: Int32Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.int32)
};
break;
case /* buf.validate.Int64Rules int64 */ 4:
message.type = {
oneofKind: "int64",
int64: Int64Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.int64)
};
break;
case /* buf.validate.UInt32Rules uint32 */ 5:
message.type = {
oneofKind: "uint32",
uint32: UInt32Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.uint32)
};
break;
case /* buf.validate.UInt64Rules uint64 */ 6:
message.type = {
oneofKind: "uint64",
uint64: UInt64Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.uint64)
};
break;
case /* buf.validate.SInt32Rules sint32 */ 7:
message.type = {
oneofKind: "sint32",
sint32: SInt32Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.sint32)
};
break;
case /* buf.validate.SInt64Rules sint64 */ 8:
message.type = {
oneofKind: "sint64",
sint64: SInt64Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.sint64)
};
break;
case /* buf.validate.Fixed32Rules fixed32 */ 9:
message.type = {
oneofKind: "fixed32",
fixed32: Fixed32Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.fixed32)
};
break;
case /* buf.validate.Fixed64Rules fixed64 */ 10:
message.type = {
oneofKind: "fixed64",
fixed64: Fixed64Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.fixed64)
};
break;
case /* buf.validate.SFixed32Rules sfixed32 */ 11:
message.type = {
oneofKind: "sfixed32",
sfixed32: SFixed32Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.sfixed32)
};
break;
case /* buf.validate.SFixed64Rules sfixed64 */ 12:
message.type = {
oneofKind: "sfixed64",
sfixed64: SFixed64Rules.internalBinaryRead(reader, reader.uint32(), options, message.type.sfixed64)
};
break;
case /* buf.validate.BoolRules bool */ 13:
message.type = {
oneofKind: "bool",
bool: BoolRules.internalBinaryRead(reader, reader.uint32(), options, message.type.bool)
};
break;
case /* buf.validate.StringRules string */ 14:
message.type = {
oneofKind: "string",
string: StringRules.internalBinaryRead(reader, reader.uint32(), options, message.type.string)
};
break;
case /* buf.validate.BytesRules bytes */ 15:
message.type = {
oneofKind: "bytes",
bytes: BytesRules.internalBinaryRead(reader, reader.uint32(), options, message.type.bytes)
};
break;
case /* buf.validate.EnumRules enum */ 16:
message.type = {
oneofKind: "enum",
enum: EnumRules.internalBinaryRead(reader, reader.uint32(), options, message.type.enum)
};
break;
case /* buf.validate.RepeatedRules repeated */ 18:
message.type = {
oneofKind: "repeated",
repeated: RepeatedRules.internalBinaryRead(reader, reader.uint32(), options, message.type.repeated)
};
break;
case /* buf.validate.MapRules map */ 19:
message.type = {
oneofKind: "map",
map: MapRules.internalBinaryRead(reader, reader.uint32(), options, message.type.map)
};
break;
case /* buf.validate.AnyRules any */ 20:
message.type = {
oneofKind: "any",
any: AnyRules.internalBinaryRead(reader, reader.uint32(), options, message.type.any)
};
break;
case /* buf.validate.DurationRules duration */ 21:
message.type = {
oneofKind: "duration",
duration: DurationRules.internalBinaryRead(reader, reader.uint32(), options, message.type.duration)
};
break;
case /* buf.validate.TimestampRules timestamp */ 22:
message.type = {
oneofKind: "timestamp",
timestamp: TimestampRules.internalBinaryRead(reader, reader.uint32(), options, message.type.timestamp)
};
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* repeated buf.validate.Constraint cel = 23; */
for (let i = 0; i < message.cel.length; i++)
Constraint.internalBinaryWrite(message.cel[i], writer.tag(23, WireType.LengthDelimited).fork(), options).join();
/* optional bool required = 25; */
if (message.required !== undefined)
writer.tag(25, WireType.Varint).bool(message.required);
/* optional buf.validate.Ignore ignore = 27; */
if (message.ignore !== undefined)
writer.tag(27, WireType.Varint).int32(message.ignore);
/* buf.validate.FloatRules float = 1; */
if (message.type.oneofKind === "float")
FloatRules.internalBinaryWrite(message.type.float, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.DoubleRules double = 2; */
if (message.type.oneofKind === "double")
DoubleRules.internalBinaryWrite(message.type.double, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.Int32Rules int32 = 3; */
if (message.type.oneofKind === "int32")
Int32Rules.internalBinaryWrite(message.type.int32, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.Int64Rules int64 = 4; */
if (message.type.oneofKind === "int64")
Int64Rules.internalBinaryWrite(message.type.int64, writer.tag(4, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.UInt32Rules uint32 = 5; */
if (message.type.oneofKind === "uint32")
UInt32Rules.internalBinaryWrite(message.type.uint32, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.UInt64Rules uint64 = 6; */
if (message.type.oneofKind === "uint64")
UInt64Rules.internalBinaryWrite(message.type.uint64, writer.tag(6, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.SInt32Rules sint32 = 7; */
if (message.type.oneofKind === "sint32")
SInt32Rules.internalBinaryWrite(message.type.sint32, writer.tag(7, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.SInt64Rules sint64 = 8; */
if (message.type.oneofKind === "sint64")
SInt64Rules.internalBinaryWrite(message.type.sint64, writer.tag(8, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.Fixed32Rules fixed32 = 9; */
if (message.type.oneofKind === "fixed32")
Fixed32Rules.internalBinaryWrite(message.type.fixed32, writer.tag(9, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.Fixed64Rules fixed64 = 10; */
if (message.type.oneofKind === "fixed64")
Fixed64Rules.internalBinaryWrite(message.type.fixed64, writer.tag(10, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.SFixed32Rules sfixed32 = 11; */
if (message.type.oneofKind === "sfixed32")
SFixed32Rules.internalBinaryWrite(message.type.sfixed32, writer.tag(11, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.SFixed64Rules sfixed64 = 12; */
if (message.type.oneofKind === "sfixed64")
SFixed64Rules.internalBinaryWrite(message.type.sfixed64, writer.tag(12, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.BoolRules bool = 13; */
if (message.type.oneofKind === "bool")
BoolRules.internalBinaryWrite(message.type.bool, writer.tag(13, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.StringRules string = 14; */
if (message.type.oneofKind === "string")
StringRules.internalBinaryWrite(message.type.string, writer.tag(14, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.BytesRules bytes = 15; */
if (message.type.oneofKind === "bytes")
BytesRules.internalBinaryWrite(message.type.bytes, writer.tag(15, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.EnumRules enum = 16; */
if (message.type.oneofKind === "enum")
EnumRules.internalBinaryWrite(message.type.enum, writer.tag(16, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.RepeatedRules repeated = 18; */
if (message.type.oneofKind === "repeated")
RepeatedRules.internalBinaryWrite(message.type.repeated, writer.tag(18, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.MapRules map = 19; */
if (message.type.oneofKind === "map")
MapRules.internalBinaryWrite(message.type.map, writer.tag(19, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.AnyRules any = 20; */
if (message.type.oneofKind === "any")
AnyRules.internalBinaryWrite(message.type.any, writer.tag(20, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.DurationRules duration = 21; */
if (message.type.oneofKind === "duration")
DurationRules.internalBinaryWrite(message.type.duration, writer.tag(21, WireType.LengthDelimited).fork(), options).join();
/* buf.validate.TimestampRules timestamp = 22; */
if (message.type.oneofKind === "timestamp")
TimestampRules.internalBinaryWrite(message.type.timestamp, writer.tag(22, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.FieldConstraints
*/
export const FieldConstraints = new FieldConstraints$Type();
// @generated message type with reflection information, may provide speed optimized methods
class PredefinedConstraints$Type extends MessageType {
constructor() {
super("buf.validate.PredefinedConstraints", [
{ no: 1, name: "cel", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => Constraint }
]);
}
create(value) {
const message = { cel: [] };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* repeated buf.validate.Constraint cel */ 1:
message.cel.push(Constraint.internalBinaryRead(reader, reader.uint32(), options));
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* repeated buf.validate.Constraint cel = 1; */
for (let i = 0; i < message.cel.length; i++)
Constraint.internalBinaryWrite(message.cel[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.PredefinedConstraints
*/
export const PredefinedConstraints = new PredefinedConstraints$Type();
// @generated message type with reflection information, may provide speed optimized methods
class FloatRules$Type extends MessageType {
constructor() {
super("buf.validate.FloatRules", [
{ no: 1, name: "const", kind: "scalar", opt: true, T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.const", expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" }] } } },
{ no: 2, name: "lt", kind: "scalar", oneof: "lessThan", T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.lt", expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)? 'value must be less than %s'.format([rules.lt]) : ''" }] } } },
{ no: 3, name: "lte", kind: "scalar", oneof: "lessThan", T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.lte", expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)? 'value must be less than or equal to %s'.format([rules.lte]) : ''" }] } } },
{ no: 4, name: "gt", kind: "scalar", oneof: "greaterThan", T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.gt", expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)? 'value must be greater than %s'.format([rules.gt]) : ''" }, { id: "float.gt_lt", expression: "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, { id: "float.gt_lt_exclusive", expression: "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, { id: "float.gt_lte", expression: "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, { id: "float.gt_lte_exclusive", expression: "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }] } } },
{ no: 5, name: "gte", kind: "scalar", oneof: "greaterThan", T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.gte", expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" }, { id: "float.gte_lt", expression: "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, { id: "float.gte_lt_exclusive", expression: "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, { id: "float.gte_lte", expression: "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, { id: "float.gte_lte_exclusive", expression: "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }] } } },
{ no: 6, name: "in", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.in", expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" }] } } },
{ no: 7, name: "not_in", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.not_in", expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" }] } } },
{ no: 8, name: "finite", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/, options: { "buf.validate.predefined": { cel: [{ id: "float.finite", expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" }] } } },
{ no: 9, name: "example", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 2 /*ScalarType.FLOAT*/, options: { "buf.validate.predefined": { cel: [{ id: "float.example", expression: "true" }] } } }
]);
}
create(value) {
const message = { lessThan: { oneofKind: undefined }, greaterThan: { oneofKind: undefined }, in: [], notIn: [], example: [] };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* optional float const */ 1:
message.const = reader.float();
break;
case /* float lt */ 2:
message.lessThan = {
oneofKind: "lt",
lt: reader.float()
};
break;
case /* float lte */ 3:
message.lessThan = {
oneofKind: "lte",
lte: reader.float()
};
break;
case /* float gt */ 4:
message.greaterThan = {
oneofKind: "gt",
gt: reader.float()
};
break;
case /* float gte */ 5:
message.greaterThan = {
oneofKind: "gte",
gte: reader.float()
};
break;
case /* repeated float in */ 6:
if (wireType === WireType.LengthDelimited)
for (let e = reader.int32() + reader.pos; reader.pos < e;)
message.in.push(reader.float());
else
message.in.push(reader.float());
break;
case /* repeated float not_in */ 7:
if (wireType === WireType.LengthDelimited)
for (let e = reader.int32() + reader.pos; reader.pos < e;)
message.notIn.push(reader.float());
else
message.notIn.push(reader.float());
break;
case /* optional bool finite */ 8:
message.finite = reader.bool();
break;
case /* repeated float example */ 9:
if (wireType === WireType.LengthDelimited)
for (let e = reader.int32() + reader.pos; reader.pos < e;)
message.example.push(reader.float());
else
message.example.push(reader.float());
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
}
internalBinaryWrite(message, writer, options) {
/* optional float const = 1; */
if (message.const !== undefined)
writer.tag(1, WireType.Bit32).float(message.const);
/* float lt = 2; */
if (message.lessThan.oneofKind === "lt")
writer.tag(2, WireType.Bit32).float(message.lessThan.lt);
/* float lte = 3; */
if (message.lessThan.oneofKind === "lte")
writer.tag(3, WireType.Bit32).float(message.lessThan.lte);
/* float gt = 4; */
if (message.greaterThan.oneofKind === "gt")
writer.tag(4, WireType.Bit32).float(message.greaterThan.gt);
/* float gte = 5; */
if (message.greaterThan.oneofKind === "gte")
writer.tag(5, WireType.Bit32).float(message.greaterThan.gte);
/* repeated float in = 6; */
for (let i = 0; i < message.in.length; i++)
writer.tag(6, WireType.Bit32).float(message.in[i]);
/* repeated float not_in = 7; */
for (let i = 0; i < message.notIn.length; i++)
writer.tag(7, WireType.Bit32).float(message.notIn[i]);
/* optional bool finite = 8; */
if (message.finite !== undefined)
writer.tag(8, WireType.Varint).bool(message.finite);
/* repeated float example = 9; */
for (let i = 0; i < message.example.length; i++)
writer.tag(9, WireType.Bit32).float(message.example[i]);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
}
}
/**
* @generated MessageType for protobuf message buf.validate.FloatRules
*/
export const FloatRules = new FloatRules$Type();
// @generated message type with reflection information, may provide speed optimized methods
class DoubleRules$Type extends MessageType {
constructor() {
super("buf.validate.DoubleRules", [
{ no: 1, name: "const", kind: "scalar", opt: true, T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.const", expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" }] } } },
{ no: 2, name: "lt", kind: "scalar", oneof: "lessThan", T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.lt", expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)? 'value must be less than %s'.format([rules.lt]) : ''" }] } } },
{ no: 3, name: "lte", kind: "scalar", oneof: "lessThan", T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.lte", expression: "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)? 'value must be less than or equal to %s'.format([rules.lte]) : ''" }] } } },
{ no: 4, name: "gt", kind: "scalar", oneof: "greaterThan", T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.gt", expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)? 'value must be greater than %s'.format([rules.gt]) : ''" }, { id: "double.gt_lt", expression: "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" }, { id: "double.gt_lt_exclusive", expression: "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" }, { id: "double.gt_lte", expression: "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }, { id: "double.gt_lte_exclusive", expression: "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" }] } } },
{ no: 5, name: "gte", kind: "scalar", oneof: "greaterThan", T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.gte", expression: "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" }, { id: "double.gte_lt", expression: "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" }, { id: "double.gte_lt_exclusive", expression: "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" }, { id: "double.gte_lte", expression: "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }, { id: "double.gte_lte_exclusive", expression: "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" }] } } },
{ no: 6, name: "in", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.in", expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" }] } } },
{ no: 7, name: "not_in", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.not_in", expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" }] } } },
{ no: 8, name: "finite", kind: "scalar", opt: true, T: 8 /*ScalarType.BOOL*/, options: { "buf.validate.predefined": { cel: [{ id: "double.finite", expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" }] } } },
{ no: 9, name: "example", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 1 /*ScalarType.DOUBLE*/, options: { "buf.validate.predefined": { cel: [{ id: "double.example", expression: "true" }] } } }
]);
}
create(value) {
const message = { lessThan: { oneofKind: undefined }, greaterThan: { oneofKind: undefined }, in: [], notIn: [], example: [] };
globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
reflectionMergePartial(this, message, value);
return message;
}
internalBinaryRead(reader, length, options, target) {
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
case /* optional double const */ 1:
message.const = reader.double();
break;
case /* double lt */ 2:
message.lessThan = {
oneofKind: "lt",
lt: reader.double()
};
break;
case /* double lte */ 3:
message.lessThan = {
oneofKind: "lte",
lte: reader.double()
};
break;
case /* double gt */ 4:
message.greaterThan = {
oneofKind: "gt",
gt: reader.double()
};
break;
case /* double gte */ 5:
message.greaterThan = {
oneofKind: "gte",
gte: reader.double()
};
break;
case /* repeated double in */ 6:
if (wireType === WireType.LengthDelimited)
for (let e = reader.int32() + reader.pos; reader.pos < e;)
message.in.push(reader.double());