@@ -67,46 +67,60 @@ type IntegrationBase struct {
6767 attachmentJSONSchema []byte
6868}
6969
70+ // IntegrationBaseOptions holds the options for creating a new IntegrationBase
71+ type IntegrationBaseOptions struct {
72+ ID string
73+ Name string
74+ Version string
75+ Description string
76+ Kinds []string
77+ Schema * InputSchema
78+ }
79+
7080// NewIntegrationBase helper to create a new IntegrationBase
71- func NewIntegrationBase (id , name , version , description string , kinds [] string , schema * InputSchema ) (* IntegrationBase , error ) {
81+ func NewIntegrationBase (opts * IntegrationBaseOptions ) (* IntegrationBase , error ) {
7282 var (
7383 registrationJSONSchema , attachmentJSONSchema []byte
7484 err error
7585 )
7686
87+ if opts == nil {
88+ return nil , fmt .Errorf ("options are required" )
89+ }
90+
7791 // Validate basic metadata
78- if id == "" {
92+ if opts . ID == "" {
7993 return nil , fmt .Errorf ("id is required" )
8094 }
8195
82- if version == "" {
96+ if opts . Version == "" {
8397 return nil , fmt .Errorf ("version is required" )
8498 }
8599
86- if len (kinds ) == 0 {
100+ if len (opts . Kinds ) == 0 {
87101 return nil , fmt .Errorf ("kinds is required" )
88102 }
89103
90- if schema == nil {
104+ if opts . Schema == nil {
91105 return nil , fmt .Errorf ("input schema is required" )
92106 }
93107
94108 // Generate JSON schemas
95- registrationJSONSchema , err = GenerateJSONSchema (schema .Registration )
109+ registrationJSONSchema , err = GenerateJSONSchema (opts . Schema .Registration )
96110 if err != nil {
97111 return nil , fmt .Errorf ("failed to generate registration JSON schema: %w" , err )
98112 }
99113
100- attachmentJSONSchema , err = GenerateJSONSchema (schema .Attachment )
114+ attachmentJSONSchema , err = GenerateJSONSchema (opts . Schema .Attachment )
101115 if err != nil {
102116 return nil , fmt .Errorf ("failed to generate attachment JSON schema: %w" , err )
103117 }
104118 return & IntegrationBase {
105- ID : id ,
106- Name : name ,
107- Version : version ,
108- Description : description ,
109- Kinds : kinds ,
119+ ID : opts . ID ,
120+ Name : opts . Name ,
121+ Version : opts . Version ,
122+ Description : opts . Description ,
123+ Kinds : opts . Kinds ,
110124 registrationJSONSchema : registrationJSONSchema ,
111125 attachmentJSONSchema : attachmentJSONSchema ,
112126 }, nil
0 commit comments