@platforma-sdk/workflow-tengo 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ ll := import("@platforma-sdk/workflow-tengo:ll")
2
2
  text := import("text")
3
3
  slices := import("@platforma-sdk/workflow-tengo:slices")
4
4
  validation := import("@platforma-sdk/workflow-tengo:validation")
5
+ regexp := import("@platforma-sdk/workflow-tengo:regexp")
5
6
 
6
7
 
7
8
 
@@ -116,7 +117,9 @@ getExtension := func(path, ...sep) {
116
117
  sep = _sepOrDefault(sep...)
117
118
 
118
119
  nPoints := 1
119
- if text.re_match(`\.(gz|xz|bzip|zstd)$`, path) {
120
+
121
+ archiveRegexp := regexp.compile(`\.(gz|xz|bzip|zstd)$`)
122
+ if archiveRegexp.match(path) {
120
123
  nPoints = 2
121
124
  }
122
125
 
@@ -0,0 +1,36 @@
1
+
2
+
3
+ ll := import("@platforma-sdk/workflow-tengo:ll")
4
+ text := import("text")
5
+
6
+
7
+ compiledCache := {}
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ compile := func(pattern) {
17
+
18
+ if !is_undefined(compiledCache[pattern]) {
19
+ return compiledCache[pattern]
20
+ }
21
+
22
+
23
+ compiled := text.re_compile(pattern)
24
+ if is_error(compiled) {
25
+ ll.panic("Error compiling regexp: %v", compiled)
26
+ }
27
+
28
+
29
+ compiledCache[pattern] = compiled
30
+
31
+ return compiled
32
+ }
33
+
34
+ export ll.toStrict({
35
+ compile: compile
36
+ })
@@ -6,6 +6,7 @@
6
6
  tx := import("tx")
7
7
  ll := import("@platforma-sdk/workflow-tengo:ll")
8
8
  text := import("text")
9
+ regexp := import("@platforma-sdk/workflow-tengo:regexp")
9
10
 
10
11
  createContext := func() {
11
12
  return {
@@ -72,7 +73,7 @@ awaitOneState := func(field, path, state) {
72
73
  return true
73
74
  }
74
75
  } else {
75
- regex := text.re_compile(step.match)
76
+ regex := regexp.compile(step.match)
76
77
  if is_error(regex) {
77
78
  ll.panic("Error parsing regex %v: %v", step.match, regex)
78
79
  }
@@ -4,6 +4,7 @@ text := import("text")
4
4
  maps := import("@platforma-sdk/workflow-tengo:maps")
5
5
  enum := import("enum")
6
6
  smart := import("@platforma-sdk/workflow-tengo:smart")
7
+ regexp := import("@platforma-sdk/workflow-tengo:regexp")
7
8
 
8
9
  json := import("json")
9
10
 
@@ -89,13 +90,13 @@ _validateTypes := func(js, tags, keyPath, ...stack) {
89
90
  return success
90
91
  }
91
92
 
92
- if k == "alphanumeric" && ((is_string(js) && text.re_match("^[[:alnum:]]*$", js)) || is_int(js)) {
93
+ if k == "alphanumeric" && ((is_string(js) && regexp.compile("^[[:alnum:]]*$").match(js)) || is_int(js)) {
93
94
  return success
94
95
  }
95
96
 
96
97
  if k == "string" && is_string(js) {
97
98
  regex := tags.tags["regex"]
98
- if !is_undefined(regex) && !text.re_match(regex, js) {
99
+ if !is_undefined(regex) && !regexp.compile(regex).match(js) {
99
100
  return fail(keyPath, "value %q does not conform regex %q", js, regex)
100
101
  }
101
102
 
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",