Implemented new campaign/session stable inputs and corresponding input source references
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
All checks were successful
ci/woodpecker/tag/release Pipeline was successful
This commit is contained in:
@@ -13,6 +13,10 @@ import (
|
||||
const (
|
||||
SourceBoundsSession = "narratio.bounds.session"
|
||||
|
||||
SourceInputPlayers = "narratio.input.players"
|
||||
SourceInputParty = "narratio.input.party"
|
||||
SourceInputGlossary = "narratio.input.glossary"
|
||||
|
||||
configuredSourcePrefix = "narratio.artifact."
|
||||
previousConfiguredSrcPrefix = "narratio.previous_session.artifact."
|
||||
)
|
||||
@@ -31,6 +35,7 @@ const (
|
||||
SourceKindBuiltIn SourceKind = "built_in"
|
||||
SourceKindConfiguredArtifact SourceKind = "configured_artifact"
|
||||
SourceKindPreviousArtifact SourceKind = "previous_session_configured_artifact"
|
||||
SourceKindStableInput SourceKind = "stable_input"
|
||||
)
|
||||
|
||||
// Source describes one normalized artifact source identifier.
|
||||
@@ -118,6 +123,11 @@ func DescribeScriptoriumInputSource(source string) (ScriptoriumInputSourceDescri
|
||||
if trimmed == "" {
|
||||
return ScriptoriumInputSourceDescriptor{}, ErrUnsupportedScriptoriumInputSource
|
||||
}
|
||||
if IsStableInputSource(trimmed) {
|
||||
return ScriptoriumInputSourceDescriptor{
|
||||
Source: Source{ID: trimmed, Kind: SourceKindStableInput},
|
||||
}, nil
|
||||
}
|
||||
if strings.HasPrefix(trimmed, "narratio.previous_session.artifact") {
|
||||
descriptor, err := DescribePreviousSessionSource(trimmed)
|
||||
if err != nil {
|
||||
@@ -140,6 +150,17 @@ func DescribeScriptoriumInputSource(source string) (ScriptoriumInputSourceDescri
|
||||
return ScriptoriumInputSourceDescriptor{Source: classified}, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
// DescribePreviousSessionSource validates a canonical previous-session source id
|
||||
// and returns both previous and configured-source vocabulary descriptors.
|
||||
func DescribePreviousSessionSource(source string) (PreviousSessionSourceDescriptor, error) {
|
||||
|
||||
@@ -112,6 +112,9 @@ func TestDescribeScriptoriumInputSource(t *testing.T) {
|
||||
}{
|
||||
{name: "built in", source: "narratio.transcript.final_trimmed", wantKind: SourceKindBuiltIn},
|
||||
{name: "built in markdown", source: "narratio.transcript.final_markdown", wantKind: SourceKindBuiltIn},
|
||||
{name: "prepared players input", source: "narratio.input.players", wantKind: SourceKindStableInput},
|
||||
{name: "prepared party input", source: "narratio.input.party", wantKind: SourceKindStableInput},
|
||||
{name: "prepared glossary input", source: "narratio.input.glossary", wantKind: SourceKindStableInput},
|
||||
{name: "configured", source: "narratio.artifact.session_recap", wantKind: SourceKindConfiguredArtifact, wantKey: "session_recap"},
|
||||
{name: "previous", source: "narratio.previous_session.artifact.session_recap", wantKind: SourceKindPreviousArtifact, wantKey: "session_recap", wantPrev: true},
|
||||
{name: "invalid previous", source: "narratio.previous_session.artifact.", wantErr: ErrInvalidPreviousSessionSource},
|
||||
|
||||
Reference in New Issue
Block a user