refactor: shared YAML types via tf-tools/lib (yaml-generator + resource-generator)

TOOLS/lib/types.go — canonical ServiceSpec, ParamSpec, OperationSpec, OutputParam.
Both generators use type aliases, one source of truth for YAML contract.
docs-generator stays as-is (will be replaced by LLM-based generator).
This commit is contained in:
“Naeel”
2026-07-06 09:40:59 +04:00
parent 53d03004de
commit b56e634796
8 changed files with 137 additions and 131 deletions
+1 -3
View File
@@ -1,5 +1,3 @@
module lib
module tf-tools/lib
go 1.24
require gopkg.in/yaml.v3 v3.0.1
+19 -20
View File
@@ -1,4 +1,3 @@
package lib
// Package lib — общие типы YAML-контракта для всех генераторов.
//
// Это КАНОНИЧЕСКОЕ определение YAML-спеков. Все генераторы используют эти типы.
@@ -52,25 +51,25 @@ type OperationSpec struct {
// Поля без тега — специфичны для конкретного генератора (заполняются при обработке).
type ParamSpec struct {
// === YAML-контракт (канонические поля) ===
ID int `yaml:"id"`
Code string `yaml:"code"`
DataType string `yaml:"data_type,omitempty"`
Type string `yaml:"type,omitempty"`
Required bool `yaml:"required"`
Default interface{} `yaml:"default,omitempty"`
ValueList []string `yaml:"value_list,omitempty"`
RefSvcID *int `yaml:"ref_svc_id,omitempty"`
Func string `yaml:"func,omitempty"`
Regex string `yaml:"regex,omitempty"`
Unique string `yaml:"unique_scope,omitempty"`
MaxLength *int `yaml:"maxlength,omitempty"`
MinLength *int `yaml:"minlength,omitempty"`
MaxValue interface{} `yaml:"maxvalue,omitempty"`
MinValue interface{} `yaml:"minvalue,omitempty"`
Descr string `yaml:"descr,omitempty"`
Man string `yaml:"man,omitempty"`
Sort *int `yaml:"sort,omitempty"`
DependsOn interface{} `yaml:"depends_on,omitempty"`
ID int `yaml:"id"`
Code string `yaml:"code"`
DataType string `yaml:"data_type,omitempty"`
Type string `yaml:"type,omitempty"`
Required bool `yaml:"required"`
Default interface{} `yaml:"default,omitempty"`
ValueList []string `yaml:"value_list,omitempty"`
RefSvcID *int `yaml:"ref_svc_id,omitempty"`
Func string `yaml:"func,omitempty"`
Regex string `yaml:"regex,omitempty"`
UniqueScope string `yaml:"unique_scope,omitempty"`
MaxLength *int `yaml:"maxlength,omitempty"`
MinLength *int `yaml:"minlength,omitempty"`
MaxValue interface{} `yaml:"maxvalue,omitempty"`
MinValue interface{} `yaml:"minvalue,omitempty"`
Descr string `yaml:"descr,omitempty"`
Man string `yaml:"man,omitempty"`
Sort *int `yaml:"sort,omitempty"`
DependsOn interface{} `yaml:"depends_on,omitempty"`
// === Генератор-специфичные поля (не сериализуются в YAML) ===
IsModifiable *bool `yaml:"is_modifiable,omitempty"`