-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor workflow APIs: support workflow builder based on Go template.
- Loading branch information
1 parent
73d7a22
commit d8b9f9d
Showing
21 changed files
with
295 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2024 Jelly Terra | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
// that can be found in the LICENSE file and https://mozilla.org/MPL/2.0/. | ||
|
||
package common | ||
|
||
var V1Arithmetic = map[string]any{ | ||
"add": func(aInt, bInt int) int { return aInt + bInt }, | ||
"sub": func(aInt, bInt int) int { return aInt - bInt }, | ||
"mul": func(aInt, bInt int) int { return aInt * bInt }, | ||
"div": func(aInt, bInt int) int { return aInt / bInt }, | ||
"mod": func(aInt, bInt int) int { return aInt % bInt }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2024 Jelly Terra | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
// that can be found in the LICENSE file and https://mozilla.org/MPL/2.0/. | ||
|
||
package common | ||
|
||
import "errors" | ||
|
||
type Slice struct { | ||
Raw []any | ||
} | ||
|
||
func (s *Slice) Len() int { return len(s.Raw) } | ||
func (s *Slice) Index(i int) any { return s.Raw[i] } | ||
func (s *Slice) Slice(start, end int) *Slice { return &Slice{s.Raw[start:end]} } | ||
func (s *Slice) Push(e ...any) (_ Void) { s.Raw = append(s.Raw, e...); return } | ||
func (s *Slice) StringSlice() []string { | ||
slice := make([]string, len(s.Raw)) | ||
for i, e := range s.Raw { | ||
slice[i], _ = e.(string) | ||
} | ||
return slice | ||
} | ||
|
||
type Map struct { | ||
Raw map[string]any | ||
} | ||
|
||
type Void string | ||
|
||
func (m *Map) Set(key string, value any) (_ Void) { m.Raw[key] = value; return } | ||
func (m *Map) Get(key string) any { return m.Raw[key] } | ||
func (m *Map) Has(key string) bool { return m.Raw[key] != nil } | ||
func (m *Map) Delete(key string) (_ Void) { delete(m.Raw, key); return } | ||
|
||
var V1Builtin = map[string]any{ | ||
"panic": func(v string) (_ Void) { panic(errors.New(v)); return }, | ||
|
||
"Any": func(v any) any { return v }, | ||
"Int": func(v any) int { return v.(int) }, | ||
"Str": func(v any) string { return v.(string) }, | ||
|
||
"makeSlice": func() *Slice { return new(Slice) }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 Jelly Terra | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
// that can be found in the LICENSE file and https://mozilla.org/MPL/2.0/. | ||
|
||
package common | ||
|
||
import ( | ||
. "path" | ||
) | ||
|
||
type V1Path struct{} | ||
|
||
func (V1Path) Base(path string) string { return Base(path) } | ||
|
||
func (V1Path) Clean(path string) string { return Clean(path) } | ||
|
||
func (V1Path) Dir(path string) string { return Dir(path) } | ||
|
||
func (V1Path) Ext(path string) string { return Ext(path) } | ||
|
||
func (V1Path) IsAbs(path string) bool { return IsAbs(path) } | ||
|
||
func (V1Path) Join(paths ...string) string { return Join(paths...) } | ||
|
||
func (V1Path) Match(pattern, name string) (matched bool, valid bool) { | ||
matched, err := Match(pattern, name) | ||
if err != nil { | ||
return false, false | ||
} | ||
|
||
return matched, true | ||
} | ||
|
||
func (V1Path) Split(path string) (dir, file string) { return Split(path) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2024 Jelly Terra | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0 | ||
// that can be found in the LICENSE file and https://mozilla.org/MPL/2.0/. | ||
|
||
package common | ||
|
||
import "strings" | ||
|
||
type V1Strings struct{} | ||
|
||
func (V1Strings) Contains(s, substr string) bool { return strings.Contains(s, substr) } | ||
func (V1Strings) ContainsAny(s, chars string) bool { return strings.Contains(s, chars) } | ||
func (V1Strings) ContainsRune(s string, r rune) bool { return strings.ContainsRune(s, r) } | ||
|
||
func (V1Strings) Count(s, substr string) int { return strings.Count(s, substr) } | ||
|
||
func (V1Strings) HasPrefix(str, prefix string) bool { return strings.HasPrefix(str, prefix) } | ||
func (V1Strings) HasSuffix(str, suffix string) bool { return strings.HasSuffix(str, suffix) } | ||
|
||
func (V1Strings) Index(s, substr string) int { return strings.Index(s, substr) } | ||
func (V1Strings) IndexAny(s, chars string) int { return strings.IndexAny(s, chars) } | ||
func (V1Strings) IndexByte(s string, c byte) int { return strings.IndexByte(s, c) } | ||
func (V1Strings) IndexRune(s string, r rune) int { return strings.IndexRune(s, r) } | ||
|
||
func (V1Strings) Join(sep string, elems ...string) string { return strings.Join(elems, sep) } | ||
|
||
func (V1Strings) LastIndex(s, substr string) int { return strings.LastIndex(s, substr) } | ||
func (V1Strings) LastIndexAny(s, chars string) int { return strings.LastIndexAny(s, chars) } | ||
func (V1Strings) LastIndexByte(s string, c byte) int { return strings.LastIndexByte(s, c) } | ||
|
||
func (V1Strings) Repeat(s string, count int) string { return strings.Repeat(s, count) } | ||
|
||
func (V1Strings) Replace(s, old, new string, n int) string { return strings.Replace(s, old, new, n) } | ||
func (V1Strings) ReplaceAll(s, old, new string) string { return strings.ReplaceAll(s, old, new) } | ||
|
||
func (V1Strings) Split(s, substr string) []string { return strings.Split(s, substr) } | ||
func (V1Strings) SplitAfter(s, substr string) []string { return strings.SplitAfter(s, substr) } | ||
func (V1Strings) SplitAfterN(s, substr string, n int) []string { | ||
return strings.SplitAfterN(s, substr, n) | ||
} | ||
func (V1Strings) SplitN(s, substr string, n int) []string { return strings.SplitN(s, substr, n) } | ||
|
||
func (V1Strings) ToLower(s string) string { return strings.ToLower(s) } | ||
func (V1Strings) ToTitle(s string) string { return strings.ToTitle(s) } | ||
func (V1Strings) ToUpper(s string) string { return strings.ToUpper(s) } | ||
func (V1Strings) ToValidUTF8(s, replacement string) string { | ||
return strings.ToValidUTF8(s, replacement) | ||
} | ||
|
||
func (V1Strings) Trim(s, cutset string) string { return strings.Trim(s, cutset) } | ||
func (V1Strings) TrimLeft(s, cutset string) string { return strings.TrimLeft(s, cutset) } | ||
func (V1Strings) TrimPrefix(str, prefix string) string { return strings.TrimPrefix(str, prefix) } | ||
func (V1Strings) TrimRight(s, cutset string) string { return strings.TrimRight(s, cutset) } | ||
func (V1Strings) TrimSpace(s string) string { return strings.TrimSpace(s) } | ||
func (V1Strings) TrimSuffix(str, suffix string) string { return strings.TrimSuffix(str, suffix) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.