keiro-dsl-0.17.0.0: test/fixtures/mapped-nominal-leaf.keiro
language keiro-dsl 6
context mapped-nominal-leaf
id TemplateId prefix=template
id ClaimId prefix=claim using {
haskell package=example-core module=Example.Domain type=ClaimId
binding = "Example.Bindings.claimIdBinding"
binding-version = "1"
canonical-type = "example.ClaimId.v1"
fixtures = "Example.Bindings.claimIdFixtures"
}
mapped nominal AccountNumber : Text {
haskell package=example-core module=Example.Domain type=AccountNumber
binding = "Example.Bindings.accountNumberBinding"
binding-version = "1"
canonical-type = "example.AccountNumber.v1"
fixtures = "Example.Bindings.accountNumberFixtures"
}
mapped structural record TemplateState {
haskell package=example-core module=Example.Model type=TemplateState
binding = "Example.Bindings.templateStateBinding"
binding-version = "1"
canonical-type = "example.TemplateState.v1"
fixtures = "Example.Bindings.templateStateFixtures"
wire object constructor=TemplateState unknown-fields=reject {
templateId as "templateId" : TemplateId required
holder as "holder" : Optional ClaimId optional on-missing=null
account as "account" : AccountNumber required
history as "history" : List (Optional TemplateId) required
byKey as "byKey" : Map ClaimId required
}
}
mapped structural union TemplateRef {
haskell package=example-core module=Example.Model type=TemplateRef
binding = "Example.Bindings.templateRefBinding"
binding-version = "1"
canonical-type = "example.TemplateRef.v1"
fixtures = "Example.Bindings.templateRefFixtures"
wire tagged-object tag="tag" contents="contents" unknown-fields=reject {
ById as "by_id" : TemplateId
ByClaim as "by_claim" : ClaimId
ByAccount as "by_account" : AccountNumber
Unknown as "unknown"
}
}
aggregate Template
regs
states Empty Stored!
command RecordTemplate { state:TemplateState reference:TemplateRef }
event TemplateRecorded = fields(RecordTemplate)
Empty -- RecordTemplate -->
emit TemplateRecorded
goto Stored
wire kind=ctorName fields=camelCase schemaVersion=1
workqueue template_work {
queue logical = "template.work"
derive physical = "template_work"
dlq = "template_work_dlq"
table = "pgmq.q_template_work"
payload TemplateWork {
templateId -> "template_id" : Optional TemplateId
}
retry maxRetries = 3 delay = 1s dlq = on
disposition {
storeFailure -> retry 1s
commandRejected -> deadLetter
decodeFailure -> deadLetter
onCodecReject -> deadLetter
}
}
target template_table {
schema = "public"
table = "templates"
reset = clear
}
rebuild-group template_rebuild {
targets = [ template_table ]
order = [ template_table ]
}
projection-owner template_writer {
source = all
delivery = subscription
group = template_rebuild
targets = [ template_table ]
order = 10
subscription = "template-writer"
dedup = "template-writer-v1"
checkpoint-on-missing = from-beginning
replay = explicit
}
readmodel template_lookup {
columns {}
query input = TemplateState
query result = List TemplateId
version = 1
shape = "fnv1a:3c07a19c552c3547"
freshness = wait-for-head entire-log
group = template_rebuild
targets = [ template_table ]
}