j5schema

package
v0.0.0-...-9c8294d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](val T) *T

func WalkSchemaFields

func WalkSchemaFields(root RootSchema, asClient bool, callback WalkCallback) error

Types

type AnyField

type AnyField struct {
	OnlyDefined bool
	Types       []protoreflect.FullName
	// contains filtered or unexported fields
}

func (*AnyField) AsContainer

func (s *AnyField) AsContainer() (Container, bool)

func (*AnyField) FullName

func (f *AnyField) FullName() string

func (*AnyField) Mutable

func (s *AnyField) Mutable() bool

func (*AnyField) ParentContext

func (f *AnyField) ParentContext() (ContainerSchema, string)

func (*AnyField) ToJ5Field

func (s *AnyField) ToJ5Field() *schema_j5pb.Field

func (*AnyField) TypeName

func (s *AnyField) TypeName() string

type ArrayField

type ArrayField struct {
	Schema FieldSchema
	Rules  *schema_j5pb.ArrayField_Rules
	Ext    *schema_j5pb.ArrayField_Ext
	// contains filtered or unexported fields
}

func (*ArrayField) AsContainer

func (s *ArrayField) AsContainer() (Container, bool)

func (*ArrayField) FullName

func (f *ArrayField) FullName() string

func (*ArrayField) Mutable

func (s *ArrayField) Mutable() bool

func (*ArrayField) ParentContext

func (f *ArrayField) ParentContext() (ContainerSchema, string)

func (*ArrayField) ToJ5Field

func (s *ArrayField) ToJ5Field() *schema_j5pb.Field

func (*ArrayField) TypeName

func (s *ArrayField) TypeName() string

type Container

type Container interface {
	PropertyField(name string) FieldSchema
	WalkToProperty(name ...string) (FieldSchema, error)
}

type ContainerSchema

type ContainerSchema interface {
	FullName() string
}

type EnumField

type EnumField struct {
	Ref       *RefSchema
	Rules     *schema_j5pb.EnumField_Rules
	ListRules *list_j5pb.EnumRules
	Ext       *schema_j5pb.EnumField_Ext
	// contains filtered or unexported fields
}

func (*EnumField) AsContainer

func (s *EnumField) AsContainer() (Container, bool)

func (*EnumField) FullName

func (f *EnumField) FullName() string

func (*EnumField) Mutable

func (s *EnumField) Mutable() bool

func (*EnumField) ParentContext

func (f *EnumField) ParentContext() (ContainerSchema, string)

func (*EnumField) Schema

func (s *EnumField) Schema() *EnumSchema

func (*EnumField) ToJ5Field

func (s *EnumField) ToJ5Field() *schema_j5pb.Field

func (*EnumField) TypeName

func (s *EnumField) TypeName() string

type EnumOption

type EnumOption struct {
	Info map[string]string
	// contains filtered or unexported fields
}

func (*EnumOption) Description

func (eo *EnumOption) Description() string

func (*EnumOption) Name

func (eo *EnumOption) Name() string

func (*EnumOption) Number

func (eo *EnumOption) Number() int32

func (*EnumOption) ToJ5EnumValue

func (eo *EnumOption) ToJ5EnumValue() *schema_j5pb.Enum_Option

type EnumSchema

type EnumSchema struct {
	NamePrefix string
	Options    []*EnumOption //schema_j5pb.Enum_Value

	InfoFields []*schema_j5pb.Enum_OptionInfoField
	// contains filtered or unexported fields
}

func (*EnumSchema) AsRef

func (s *EnumSchema) AsRef() *RefSchema

func (*EnumSchema) Description

func (s *EnumSchema) Description() string

func (*EnumSchema) FullName

func (s *EnumSchema) FullName() string

func (*EnumSchema) Name

func (s *EnumSchema) Name() string

func (*EnumSchema) OptionByName

func (s *EnumSchema) OptionByName(name string) *EnumOption

func (*EnumSchema) OptionByNumber

func (s *EnumSchema) OptionByNumber(num int32) *EnumOption

func (*EnumSchema) OptionsList

func (s *EnumSchema) OptionsList() []string

func (*EnumSchema) Package

func (s *EnumSchema) Package() *Package

func (*EnumSchema) PackageName

func (s *EnumSchema) PackageName() string

func (*EnumSchema) ToJ5ClientRoot

func (s *EnumSchema) ToJ5ClientRoot() *schema_j5pb.RootSchema

func (*EnumSchema) ToJ5Root

func (s *EnumSchema) ToJ5Root() *schema_j5pb.RootSchema

type FieldSchema

type FieldSchema interface {
	ToJ5Field() *schema_j5pb.Field

	TypeName() string

	ParentContext() (ContainerSchema, string)
	FullName() string

	// Mutable determines how reflection can access the Field
	// true for ObjectField and OneofField
	// false for ScalarField, EnumField
	// true for ArrayField and MapField
	// false for AnyField special case
	Mutable() bool

	AsContainer() (Container, bool)
}

type MapField

type MapField struct {
	Schema FieldSchema
	Rules  *schema_j5pb.MapField_Rules
	Ext    *schema_j5pb.MapField_Ext
	// contains filtered or unexported fields
}

func (*MapField) AsContainer

func (s *MapField) AsContainer() (Container, bool)

func (*MapField) FullName

func (f *MapField) FullName() string

func (*MapField) Mutable

func (s *MapField) Mutable() bool

func (*MapField) ParentContext

func (f *MapField) ParentContext() (ContainerSchema, string)

func (*MapField) ToJ5Field

func (s *MapField) ToJ5Field() *schema_j5pb.Field

func (*MapField) TypeName

func (s *MapField) TypeName() string

type ObjectField

type ObjectField struct {
	Ref     *RefSchema
	Flatten bool
	Rules   *schema_j5pb.ObjectField_Rules
	Ext     *schema_j5pb.ObjectField_Ext
	// contains filtered or unexported fields
}

func (*ObjectField) AsContainer

func (s *ObjectField) AsContainer() (Container, bool)

func (*ObjectField) FullName

func (f *ObjectField) FullName() string

func (*ObjectField) Mutable

func (s *ObjectField) Mutable() bool

func (*ObjectField) ParentContext

func (f *ObjectField) ParentContext() (ContainerSchema, string)

func (*ObjectField) Schema

func (s *ObjectField) Schema() *ObjectSchema

func (*ObjectField) ToJ5Field

func (s *ObjectField) ToJ5Field() *schema_j5pb.Field

func (*ObjectField) TypeName

func (s *ObjectField) TypeName() string

type ObjectProperty

type ObjectProperty struct {
	Parent RootSchema
	Schema FieldSchema

	ProtoField []protoreflect.FieldNumber

	JSONName string

	Required           bool
	ReadOnly           bool
	WriteOnly          bool
	ExplicitlyOptional bool

	Description string
}

func (*ObjectProperty) FullName

func (prop *ObjectProperty) FullName() string

func (*ObjectProperty) ToJ5Proto

func (prop *ObjectProperty) ToJ5Proto() *schema_j5pb.ObjectProperty

type ObjectSchema

type ObjectSchema struct {
	Entity     *schema_j5pb.EntityObject
	AnyMember  []string
	Properties PropertySet
	// contains filtered or unexported fields
}

func (*ObjectSchema) AsRef

func (s *ObjectSchema) AsRef() *RefSchema

func (*ObjectSchema) ClientProperties

func (s *ObjectSchema) ClientProperties() []*ObjectProperty

func (*ObjectSchema) Clone

func (s *ObjectSchema) Clone() *ObjectSchema

func (*ObjectSchema) Description

func (s *ObjectSchema) Description() string

func (*ObjectSchema) FullName

func (s *ObjectSchema) FullName() string

func (*ObjectSchema) Name

func (s *ObjectSchema) Name() string

func (*ObjectSchema) Package

func (s *ObjectSchema) Package() *Package

func (*ObjectSchema) PackageName

func (s *ObjectSchema) PackageName() string

func (*ObjectSchema) ToJ5ClientObject

func (s *ObjectSchema) ToJ5ClientObject() *schema_j5pb.Object

func (*ObjectSchema) ToJ5ClientRoot

func (s *ObjectSchema) ToJ5ClientRoot() *schema_j5pb.RootSchema

func (*ObjectSchema) ToJ5Object

func (s *ObjectSchema) ToJ5Object() *schema_j5pb.Object

func (*ObjectSchema) ToJ5Root

func (s *ObjectSchema) ToJ5Root() *schema_j5pb.RootSchema

type OneofField

type OneofField struct {
	Ref       *RefSchema
	Rules     *schema_j5pb.OneofField_Rules
	ListRules *list_j5pb.OneofRules
	Ext       *schema_j5pb.OneofField_Ext
	// contains filtered or unexported fields
}

func (*OneofField) AsContainer

func (s *OneofField) AsContainer() (Container, bool)

func (*OneofField) FullName

func (f *OneofField) FullName() string

func (*OneofField) Mutable

func (s *OneofField) Mutable() bool

func (*OneofField) ParentContext

func (f *OneofField) ParentContext() (ContainerSchema, string)

func (*OneofField) Schema

func (s *OneofField) Schema() *OneofSchema

func (*OneofField) ToJ5Field

func (s *OneofField) ToJ5Field() *schema_j5pb.Field

func (*OneofField) TypeName

func (s *OneofField) TypeName() string

type OneofSchema

type OneofSchema struct {
	Properties PropertySet
	// contains filtered or unexported fields
}

func (*OneofSchema) AsRef

func (s *OneofSchema) AsRef() *RefSchema

func (*OneofSchema) ClientProperties

func (s *OneofSchema) ClientProperties() []*ObjectProperty

func (*OneofSchema) Description

func (s *OneofSchema) Description() string

func (*OneofSchema) FullName

func (s *OneofSchema) FullName() string

func (*OneofSchema) Name

func (s *OneofSchema) Name() string

func (*OneofSchema) Package

func (s *OneofSchema) Package() *Package

func (*OneofSchema) PackageName

func (s *OneofSchema) PackageName() string

func (*OneofSchema) ToJ5ClientRoot

func (s *OneofSchema) ToJ5ClientRoot() *schema_j5pb.RootSchema

func (*OneofSchema) ToJ5Root

func (s *OneofSchema) ToJ5Root() *schema_j5pb.RootSchema

type Package

type Package struct {
	Name       string
	Schemas    map[string]*RefSchema
	PackageSet RootSet
}

type PropertySet

type PropertySet []*ObjectProperty

func (PropertySet) ByJSONName

func (ps PropertySet) ByJSONName(name string) *ObjectProperty

func (PropertySet) PropertyField

func (ps PropertySet) PropertyField(name string) FieldSchema

func (PropertySet) WalkToProperty

func (ps PropertySet) WalkToProperty(name ...string) (FieldSchema, error)

type RefSchema

type RefSchema struct {
	Package *Package
	Schema  string
	To      RootSchema
}

func (*RefSchema) FullName

func (s *RefSchema) FullName() string

type RootSchema

type RootSchema interface {
	AsRef() *RefSchema
	FullName() string
	Name() string
	PackageName() string
	Package() *Package
	ToJ5Root() *schema_j5pb.RootSchema
	ToJ5ClientRoot() *schema_j5pb.RootSchema
	Description() string
}

type RootSet

type RootSet interface {
	// contains filtered or unexported methods
}

type ScalarSchema

type ScalarSchema struct {

	// subset of the available schema types, everything excluding ref, oneof
	// wrapper, array, object, map
	Proto *schema_j5pb.Field

	Kind              protoreflect.Kind
	WellKnownTypeName protoreflect.FullName
	// contains filtered or unexported fields
}

func (*ScalarSchema) AsContainer

func (s *ScalarSchema) AsContainer() (Container, bool)

func (*ScalarSchema) FullName

func (f *ScalarSchema) FullName() string

func (*ScalarSchema) Mutable

func (s *ScalarSchema) Mutable() bool

func (*ScalarSchema) ParentContext

func (f *ScalarSchema) ParentContext() (ContainerSchema, string)

func (*ScalarSchema) ToJ5Field

func (s *ScalarSchema) ToJ5Field() *schema_j5pb.Field

func (*ScalarSchema) TypeName

func (s *ScalarSchema) TypeName() string

type SchemaCache

type SchemaCache struct {
	// contains filtered or unexported fields
}

SchemaCache acts like PackageSet, but builds schemas on demand from reflection.

func NewSchemaCache

func NewSchemaCache() *SchemaCache

func (*SchemaCache) Schema

Schema returns the J5 schema for the given message descriptor.

type SchemaSet

type SchemaSet struct {
	Packages map[string]*Package
}

func PackageSetFromSourceAPI

func PackageSetFromSourceAPI(packages []*source_j5pb.Package) (*SchemaSet, error)

func SchemaSetFromFiles

func SchemaSetFromFiles(descFiles *protoregistry.Files, include func(protoreflect.FileDescriptor) bool) (*SchemaSet, error)

func (*SchemaSet) AnonymousObjectFromSchema

func (ps *SchemaSet) AnonymousObjectFromSchema(packageName string, schema *schema_j5pb.Object) (*ObjectSchema, error)

AnonymousObjectFromSchema converts the schema object but does not add it to the package set. This is used for dynamic request and reply entities.

func (*SchemaSet) Package

func (ps *SchemaSet) Package(name string) *Package

func (*SchemaSet) SchemaByName

func (ss *SchemaSet) SchemaByName(packageName, name string) (RootSchema, error)

type WalkCallback

type WalkCallback func(schema WalkProperty) error

type WalkProperty

type WalkProperty struct {
	*ObjectProperty
	Path []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL