forked from tangled.org/core
this repo has no description
1package models 2 3import ( 4 "fmt" 5 "regexp" 6 7 "tangled.sh/tangled.sh/core/api/tangled" 8 9 "github.com/bluesky-social/indigo/atproto/syntax" 10) 11 12var ( 13 re = regexp.MustCompile(`[^a-zA-Z0-9_.-]`) 14) 15 16type PipelineId struct { 17 Knot string 18 Rkey string 19} 20 21func (p *PipelineId) AtUri() syntax.ATURI { 22 return syntax.ATURI(fmt.Sprintf("at://did:web:%s/%s/%s", p.Knot, tangled.PipelineNSID, p.Rkey)) 23} 24 25type WorkflowId struct { 26 PipelineId 27 Name string 28} 29 30func (wid WorkflowId) String() string { 31 return fmt.Sprintf("%s-%s-%s", normalize(wid.Knot), wid.Rkey, normalize(wid.Name)) 32} 33 34func normalize(name string) string { 35 normalized := re.ReplaceAllString(name, "-") 36 return normalized 37}