Complete native session acquisition and initialization
This commit is contained in:
@@ -77,20 +77,16 @@ func documentOptionalResource(resolution *configkit.Resolution, path configkit.P
|
||||
}
|
||||
|
||||
func campaignDefinition(invocationDir string, sources map[string]string, expected string) configkit.Definition[CampaignDocument] {
|
||||
presence := make(map[string]configkit.FieldInfo)
|
||||
return configkit.Definition[CampaignDocument]{Resolve: func(cfg *CampaignDocument, resolution *configkit.Resolution) error {
|
||||
narratio := configkit.Keys("narratio")
|
||||
documentResource(resolution, narratio.Key("session_template_file"), &cfg.Narratio.SessionTemplateFile, invocationDir, sources)
|
||||
inputs := narratio.Key("inputs")
|
||||
documentResource(resolution, inputs.Key("speakers_file"), &cfg.Narratio.Inputs.SpeakersFile, invocationDir, sources)
|
||||
documentOptionalResource(resolution, inputs.Key("glossary_file"), &cfg.Narratio.Inputs.GlossaryFile, invocationDir, sources)
|
||||
if party, ok := cfg.References["party"].(string); ok {
|
||||
documentResource(resolution, configkit.Keys("references", "party"), &party, invocationDir, sources)
|
||||
cfg.References["party"] = party
|
||||
}
|
||||
for _, name := range []string{"schema_version", "id", "name", "description", "setting", "system", "references"} {
|
||||
if info, ok := resolution.EntryInfo(configkit.Keys(name)); ok {
|
||||
presence[name] = info
|
||||
if references, ok := cfg.Extensions["references"].(map[string]any); ok {
|
||||
if party, ok := references["party"].(string); ok {
|
||||
documentResource(resolution, configkit.Keys("references", "party"), &party, invocationDir, sources)
|
||||
references["party"] = party
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -99,21 +95,8 @@ func campaignDefinition(invocationDir string, sources map[string]string, expecte
|
||||
for key, value := range cfg.Extensions {
|
||||
shared[key] = value
|
||||
}
|
||||
for _, field := range []struct {
|
||||
name string
|
||||
value any
|
||||
}{
|
||||
{"schema_version", cfg.SchemaVersion}, {"id", cfg.ID}, {"name", cfg.Name}, {"description", cfg.Description},
|
||||
{"setting", cfg.Setting}, {"system", cfg.System}, {"references", cfg.References},
|
||||
} {
|
||||
if info, ok := presence[field.name]; ok && info.Explicit {
|
||||
if info.Null {
|
||||
shared[field.name] = nil
|
||||
} else {
|
||||
shared[field.name] = field.value
|
||||
}
|
||||
}
|
||||
}
|
||||
shared["schema_version"] = cfg.SchemaVersion
|
||||
shared["id"] = cfg.ID
|
||||
if err := domaininput.ValidateCampaign(shared); err != nil {
|
||||
v.Error(configkit.Keys(), err.Error())
|
||||
}
|
||||
@@ -241,14 +224,16 @@ func campaignDomain(doc CampaignDocument) *CampaignConfig {
|
||||
SpeakersFile: doc.Narratio.Inputs.SpeakersFile, GlossaryFile: doc.Narratio.Inputs.GlossaryFile,
|
||||
Glossary: doc.Narratio.Inputs.Glossary, Autocorrect: doc.Narratio.Inputs.Autocorrect,
|
||||
}}
|
||||
if value, ok := doc.Setting.(string); ok {
|
||||
if value, ok := doc.Extensions["setting"].(string); ok {
|
||||
cfg.Inputs.Setting = &value
|
||||
}
|
||||
if value, ok := doc.System.(string); ok {
|
||||
if value, ok := doc.Extensions["system"].(string); ok {
|
||||
cfg.Inputs.System = &value
|
||||
}
|
||||
if value, ok := doc.References["party"].(string); ok {
|
||||
cfg.Inputs.PartyFile = value
|
||||
if references, ok := doc.Extensions["references"].(map[string]any); ok {
|
||||
if value, ok := references["party"].(string); ok {
|
||||
cfg.Inputs.PartyFile = value
|
||||
}
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user