Expose sequence identity registrations through the facade
This commit is contained in:
40
lifecycle.go
40
lifecycle.go
@@ -15,15 +15,11 @@ type Definition[T any] struct {
|
||||
Validate func(*T, *Validation)
|
||||
Version *VersionRule
|
||||
Secret func(Path) bool
|
||||
// SequenceCompositions registers mapping paths whose sequence contributions
|
||||
// strictly append distinct records by the selected literal identity field.
|
||||
// Invalid or conflicting registrations fail option validation. Repeated input
|
||||
// identities fail strict composition after source and helper processing. The
|
||||
// field also supplies identity for parent lookup when surviving records at
|
||||
// that path use record-inheritance directives.
|
||||
// Registration paths are copied when a load begins; definitions are read-only
|
||||
// after being shared.
|
||||
SequenceCompositions []SequenceComposition
|
||||
// SequenceIdentities declares the scalar fields used to combine records and
|
||||
// resolve record inheritance at selected sequence destinations. Registration
|
||||
// errors are reported before source acquisition. These constraints do not yet
|
||||
// validate identities introduced by defaults, CLI overrides, or callbacks.
|
||||
SequenceIdentities []SequenceIdentity
|
||||
}
|
||||
|
||||
// PlacementMode selects how an input mapping is placed at its Destination.
|
||||
@@ -38,20 +34,6 @@ const (
|
||||
PlacementModeSequenceItem
|
||||
)
|
||||
|
||||
// SequenceComposition registers a sequence path for strict identity-based
|
||||
// composition. Path is copied at load start; IdentityField is one literal key,
|
||||
// including the empty string. Invalid or conflicting registrations fail option
|
||||
// validation.
|
||||
type SequenceComposition struct {
|
||||
// Path selects a literal mapping path; registration paths are copied at load
|
||||
// start. Invalid paths fail option validation; the root path is harmless.
|
||||
Path Path
|
||||
// IdentityField is one literal mapping key and may be empty. Records must
|
||||
// contain a string at this key; malformed records fail strict composition.
|
||||
// The field also identifies parents for record inheritance at this path.
|
||||
IdentityField string
|
||||
}
|
||||
|
||||
// SourceVersionMode controls schema-version declarations across one complete
|
||||
// load. The zero value preserves the existing main-only effective-path check
|
||||
// and its protected-path behavior. Enabled modes check participating documents
|
||||
@@ -360,14 +342,12 @@ func toEngineFilesystemContext(context *FilesystemContext) *engine.FilesystemCon
|
||||
|
||||
func toEngineDefinition[T any](definition Definition[T]) engine.Definition[T] {
|
||||
result := engine.Definition[T]{Defaults: definition.Defaults}
|
||||
if definition.SequenceCompositions != nil {
|
||||
paths := make([]engine.Path, len(definition.SequenceCompositions))
|
||||
identityFields := make([]string, len(definition.SequenceCompositions))
|
||||
for index, registration := range definition.SequenceCompositions {
|
||||
paths[index] = toEnginePath(registration.Path.clone())
|
||||
identityFields[index] = registration.IdentityField
|
||||
if definition.SequenceIdentities != nil {
|
||||
registrations := make([]engine.SequenceIdentityRegistrationInput, len(definition.SequenceIdentities))
|
||||
for index, identity := range definition.SequenceIdentities {
|
||||
registrations[index] = toEngineSequenceIdentity(identity)
|
||||
}
|
||||
result = engine.DefinitionWithSequenceRegistrations(result, paths, identityFields)
|
||||
result = engine.DefinitionWithSequenceIdentityRegistrations(result, registrations)
|
||||
}
|
||||
if definition.Resolve != nil {
|
||||
result.Resolve = func(configuration *T, resolution *engine.Resolution) error {
|
||||
|
||||
Reference in New Issue
Block a user