Add Notarius reference configuration vocabulary
This commit is contained in:
@@ -13,9 +13,10 @@ import (
|
||||
const (
|
||||
SourceBoundsSession = "narratio.bounds.session"
|
||||
|
||||
SourceInputPlayers = "narratio.input.players"
|
||||
SourceInputParty = "narratio.input.party"
|
||||
SourceInputGlossary = "narratio.input.glossary"
|
||||
SourceInputPlayers = "narratio.input.players"
|
||||
SourceInputParty = "narratio.input.party"
|
||||
SourceInputGlossary = "narratio.input.glossary"
|
||||
SourceInputSpellCatalog = "narratio.input.spell_catalog"
|
||||
|
||||
configuredSourcePrefix = "narratio.artifact."
|
||||
extractionSourcePrefix = "narratio.extraction."
|
||||
@@ -52,9 +53,18 @@ type Source struct {
|
||||
// ScriptoriumInputSourceDescriptor describes one validated Scriptorium input source.
|
||||
type ScriptoriumInputSourceDescriptor struct {
|
||||
Source Source
|
||||
PreparedInput *PreparedInputSourceDescriptor
|
||||
PreviousSession *PreviousSessionSourceDescriptor
|
||||
}
|
||||
|
||||
// PreparedInputSourceDescriptor describes a prepared stable input's source,
|
||||
// manifest kind, and canonical staged filename.
|
||||
type PreparedInputSourceDescriptor struct {
|
||||
SourceID string
|
||||
ManifestKind string
|
||||
Filename string
|
||||
}
|
||||
|
||||
// PreviousSessionSourceDescriptor describes one canonical previous-session input source.
|
||||
type PreviousSessionSourceDescriptor struct {
|
||||
SourceID string
|
||||
@@ -158,9 +168,10 @@ func DescribeScriptoriumInputSource(source string) (ScriptoriumInputSourceDescri
|
||||
if trimmed == "" {
|
||||
return ScriptoriumInputSourceDescriptor{}, ErrUnsupportedScriptoriumInputSource
|
||||
}
|
||||
if IsStableInputSource(trimmed) {
|
||||
if prepared, ok := DescribePreparedInputSource(trimmed); ok {
|
||||
return ScriptoriumInputSourceDescriptor{
|
||||
Source: Source{ID: trimmed, Kind: SourceKindStableInput},
|
||||
Source: Source{ID: prepared.SourceID, Kind: SourceKindStableInput},
|
||||
PreparedInput: &prepared,
|
||||
}, nil
|
||||
}
|
||||
if strings.HasPrefix(trimmed, "narratio.previous_session.artifact") {
|
||||
@@ -188,12 +199,38 @@ func DescribeScriptoriumInputSource(source string) (ScriptoriumInputSourceDescri
|
||||
// IsStableInputSource reports whether source is a prepared stable input source
|
||||
// available only to Scriptorium input resolution.
|
||||
func IsStableInputSource(source string) bool {
|
||||
switch strings.TrimSpace(source) {
|
||||
case SourceInputPlayers, SourceInputParty, SourceInputGlossary:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
_, ok := DescribePreparedInputSource(source)
|
||||
return ok
|
||||
}
|
||||
|
||||
var preparedInputSources = map[string]PreparedInputSourceDescriptor{
|
||||
SourceInputPlayers: {
|
||||
SourceID: SourceInputPlayers,
|
||||
ManifestKind: "players",
|
||||
Filename: "players.yml",
|
||||
},
|
||||
SourceInputParty: {
|
||||
SourceID: SourceInputParty,
|
||||
ManifestKind: "party",
|
||||
Filename: "party.yml",
|
||||
},
|
||||
SourceInputGlossary: {
|
||||
SourceID: SourceInputGlossary,
|
||||
ManifestKind: "glossary",
|
||||
Filename: "glossary.yml",
|
||||
},
|
||||
SourceInputSpellCatalog: {
|
||||
SourceID: SourceInputSpellCatalog,
|
||||
ManifestKind: "spell_catalog",
|
||||
Filename: "spell_catalog.json",
|
||||
},
|
||||
}
|
||||
|
||||
// DescribePreparedInputSource returns the canonical descriptor for a prepared
|
||||
// stable input source.
|
||||
func DescribePreparedInputSource(source string) (PreparedInputSourceDescriptor, bool) {
|
||||
descriptor, ok := preparedInputSources[strings.TrimSpace(source)]
|
||||
return descriptor, ok
|
||||
}
|
||||
|
||||
// DescribePreviousSessionSource validates a canonical previous-session source id
|
||||
|
||||
Reference in New Issue
Block a user