refactor(schema)!: rename ObjectType -> StateObjectType (#21691)

Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
This commit is contained in:
Aaron Craelius
2024-09-16 08:17:52 +00:00
committed by GitHub
co-authored by cool-developer
parent 397ff0bd22
commit ae40e809b9
33 changed files with 247 additions and 247 deletions
+11 -11
View File
@@ -57,13 +57,13 @@ func (s ModuleSchema) Validate() error {
}
// ValidateObjectUpdate validates that the update conforms to the module schema.
func (s ModuleSchema) ValidateObjectUpdate(update ObjectUpdate) error {
func (s ModuleSchema) ValidateObjectUpdate(update StateObjectUpdate) error {
typ, ok := s.types[update.TypeName]
if !ok {
return fmt.Errorf("object type %q not found in module schema", update.TypeName)
}
objTyp, ok := typ.(ObjectType)
objTyp, ok := typ.(StateObjectType)
if !ok {
return fmt.Errorf("type %q is not an object type", update.TypeName)
}
@@ -91,14 +91,14 @@ func (s ModuleSchema) LookupEnumType(name string) (t EnumType, found bool) {
}
// LookupObjectType is a convenience method that looks up an ObjectType by name.
func (s ModuleSchema) LookupObjectType(name string) (t ObjectType, found bool) {
func (s ModuleSchema) LookupStateObjectType(name string) (t StateObjectType, found bool) {
typ, found := s.LookupType(name)
if !found {
return ObjectType{}, false
return StateObjectType{}, false
}
t, ok := typ.(ObjectType)
t, ok := typ.(StateObjectType)
if !ok {
return ObjectType{}, false
return StateObjectType{}, false
}
return t, true
}
@@ -119,9 +119,9 @@ func (s ModuleSchema) AllTypes(f func(Type) bool) {
}
// ObjectTypes iterators over all the object types in the schema in alphabetical order.
func (s ModuleSchema) ObjectTypes(f func(ObjectType) bool) {
func (s ModuleSchema) StateObjectTypes(f func(StateObjectType) bool) {
s.AllTypes(func(t Type) bool {
objTyp, ok := t.(ObjectType)
objTyp, ok := t.(StateObjectType)
if ok {
return f(objTyp)
}
@@ -141,8 +141,8 @@ func (s ModuleSchema) EnumTypes(f func(EnumType) bool) {
}
type moduleSchemaJson struct {
ObjectTypes []ObjectType `json:"object_types"`
EnumTypes []EnumType `json:"enum_types"`
ObjectTypes []StateObjectType `json:"object_types"`
EnumTypes []EnumType `json:"enum_types"`
}
// MarshalJSON implements the json.Marshaler interface for ModuleSchema.
@@ -151,7 +151,7 @@ type moduleSchemaJson struct {
func (s ModuleSchema) MarshalJSON() ([]byte, error) {
asJson := moduleSchemaJson{}
s.ObjectTypes(func(objType ObjectType) bool {
s.StateObjectTypes(func(objType StateObjectType) bool {
asJson.ObjectTypes = append(asJson.ObjectTypes, objType)
return true
})