Skip to content

Registry

Registry provides type information for a set of registered types.

new Registry(pbdbValue?): Registry

Db = ...

Registry

copy(): Registry

Registry


ensureNativeTypes(…descriptors): void

ensureNativeTypes registers explicit TypeScript object descriptions, skipping any type name which is already registered with an identical description.

Registering a different description of an already registered type name remains a conflict. This is the registration a library performs, where the same type may legitimately be described again by a second copy of that library.

…NativeObjectDescriptor[]

void


enumTypes(): DescEnum[]

enumTypes returns every registered protobuf enum descriptor.

DescEnum[]


enumValue(enumName): Val

EnumValue returns the numeric value of the given enum value name.

string

Val

TypeRegistry.enumValue


enumValueOf(typeName, value): Val

enumValueOf creates an enum value from its signed number or declared symbolic name.

string

string | bigint

Val


extend(incoming): Registry

extend returns an independent registry containing this registry’s registrations plus those of incoming. Neither input registry is modified, so an extended registry never observes a later registration made against the registry it grew from.

extend adds the incoming registrations through the same registration methods a caller uses, so a duplicate registration is accepted or rejected exactly as it would be on a single registry. A native type is the one exception: registering one twice is always a conflict on a single registry, but two registries which describe it identically are combined rather than rejected.

A protobuf file already registered under the same file name keeps the registration it already has, so two different definitions of one file name are combined as the first of the two.

Registry

Registry


findEnumType(typeName): DescEnum | undefined

findEnumType resolves a registered protobuf enum descriptor by fully qualified type name.

string

DescEnum | undefined


findEnumValue(enumName): Val | undefined

FindEnumValue resolves a declared enum value by name, or undefined when the name is not one.

Callers that probe a name they expect to miss use this rather than enumValue. Err extends the built-in Error, so constructing one captures a stack trace: fabricating an error per missed lookup dominated checking a qualified selection.

string

Val | undefined


findFieldType(messageType, fieldName): FieldType | undefined

FindFieldType returns the field type for a checked type value.

string

string

FieldType | undefined

TypeRegistry.findFieldType


findIdent(identName): Val | undefined

FindIdent takes a qualified identifier name and returns a Value if one exists.

string

Val | undefined

TypeRegistry.findIdent


findStructFieldNames(structType): string[] | undefined

string

string[] | undefined

Provider.findStructFieldNames


findStructFieldType(structType, fieldName): ProviderFieldType | undefined

string

string

ProviderFieldType | undefined

Provider.findStructFieldType


findStructType(structType): Type | undefined

string

Type | undefined

Provider.findStructType


findType(typeName): Type | undefined

FindType looks up the Type given a qualified typeName. Returns false if not found.

string

Type | undefined

TypeRegistry.findType


jsonFieldNames(): boolean

boolean


nativeToValue(value): Val

NativeToValue converts the input value to a CEL ref.Val.

unknown

Val

TypeRegistry.nativeToValue


newValue(structType, fields): Val

string

Record<string, Val>

Val

Provider.newValue


registerDescriptor(fileDesc): void

RegisterDescriptor registers a protocol buffer file descriptor.

DescFile

void

TypeRegistry.registerDescriptor


registerMessage(message, schema?): void

RegisterMessage registers a protocol buffer message and its dependencies.

Message

DescMessage

void

TypeRegistry.registerMessage


registerNativeTypes(…descriptors): void

registerNativeTypes registers explicit TypeScript object descriptions with the provider.

…NativeObjectDescriptor[]

void


registerType(…types): void

RegisterType registers a type value with the provider.

…RefType[]

void

TypeRegistry.registerType


strongEnumsEnabled(): boolean

strongEnumsEnabled reports whether protobuf enums retain their declared runtime types.

boolean


value(typeName, fields): Val

Value creates a new type value from a qualified name and map of field name to value.

string

Record<string, Val>

Val

TypeRegistry.value


withJSONFieldNames(enabled): void

boolean

void


withStrongEnums(enabled): void

withStrongEnums selects whether protobuf enums retain their declared runtime types.

boolean

void