@platforma-sdk/workflow-tengo 3.0.0 → 3.0.2

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.
Files changed (30) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2 -1
  3. package/dist/index.mjs +2 -1
  4. package/dist/tengo/lib/path.lib.tengo +4 -1
  5. package/dist/tengo/lib/pframes.export-pframe.lib.tengo +132 -0
  6. package/dist/tengo/lib/regexp.lib.tengo +36 -0
  7. package/dist/tengo/lib/tpl.state-await.lib.tengo +2 -1
  8. package/dist/tengo/lib/validation.lib.tengo +3 -2
  9. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  10. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  11. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  12. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  13. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  14. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  15. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  16. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  17. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  18. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  19. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  20. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  21. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  22. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  26. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  27. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  28. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  29. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  30. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
2
- declare type TplName = "ll.get-field" | "workflow.query-anchored" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "exec.R.create-renv" | "exec.python.install-deps" | "pframes.export-multiple-pcolumns" | "exec.python.create-venv" | "exec.monetization_to_json" | "exec.exec" | "exec.monetization_info" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "pframes.process-pcolumn-data" | "pframes.export-pframe";
2
+ declare type TplName = "ll.get-field" | "workflow.query-anchored" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "exec.R.create-renv" | "exec.python.install-deps" | "pframes.export-multiple-pcolumns" | "exec.python.create-venv" | "exec.monetization_to_json" | "exec.exec" | "exec.monetization_info" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "pframes.process-pcolumn-data" | "pframes.export-pframe" | "pframes.export-pframe-for-ui";
3
3
  declare const Templates: Record<TplName, TemplateFromFile>;
4
4
  export { Templates };
package/dist/index.js CHANGED
@@ -18,5 +18,6 @@ module.exports = { Templates: {
18
18
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
19
19
  'pframes.xsv-import-map': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-map.plj.gz') },
20
20
  'pframes.process-pcolumn-data': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.process-pcolumn-data.plj.gz') },
21
- 'pframes.export-pframe': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe.plj.gz') }
21
+ 'pframes.export-pframe': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe.plj.gz') },
22
+ 'pframes.export-pframe-for-ui': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe-for-ui.plj.gz') }
22
23
  }};
package/dist/index.mjs CHANGED
@@ -19,5 +19,6 @@ export const Templates = {
19
19
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
20
20
  'pframes.xsv-import-map': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-map.plj.gz') },
21
21
  'pframes.process-pcolumn-data': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.process-pcolumn-data.plj.gz') },
22
- 'pframes.export-pframe': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe.plj.gz') }
22
+ 'pframes.export-pframe': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe.plj.gz') },
23
+ 'pframes.export-pframe-for-ui': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe-for-ui.plj.gz') }
23
24
  };
@@ -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,132 @@
1
+ ll := import("@platforma-sdk/workflow-tengo:ll")
2
+ file := import("@platforma-sdk/workflow-tengo:file")
3
+ text := import("text")
4
+ smart := import("@platforma-sdk/workflow-tengo:smart")
5
+ render := import("@platforma-sdk/workflow-tengo:render")
6
+ assets := import("@platforma-sdk/workflow-tengo:assets")
7
+ pframes := import("@platforma-sdk/workflow-tengo:pframes")
8
+ constants := import("@platforma-sdk/workflow-tengo:constants")
9
+ validation := import("@platforma-sdk/workflow-tengo:validation")
10
+
11
+ eMulTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.export-multiple-pcolumns")
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ exportPFrame := func(pfResource, skipHideDataFromUI) {
21
+
22
+
23
+
24
+ fields := pfResource.inputs()
25
+
26
+
27
+ if pfResource.checkResourceType(constants.RTYPE_CONTEXT) {
28
+ newFields := {}
29
+ for rawFieldName, fieldValue in fields {
30
+ if text.has_prefix(rawFieldName, "values/") {
31
+ fieldName := rawFieldName[7:]
32
+ newFields[fieldName] = fieldValue
33
+ } else if rawFieldName == "id" || rawFieldName == "parent" {
34
+
35
+ continue
36
+ } else {
37
+ ll.panic("Unexpected context field: %v", rawFieldName)
38
+ }
39
+ }
40
+
41
+ fields = newFields
42
+ }
43
+
44
+
45
+
46
+
47
+ columns := {}
48
+
49
+ getOrCreateColumn := func(name) {
50
+ c := columns[name]
51
+ if is_undefined(c) {
52
+ c = {}
53
+ columns[name] = c
54
+ }
55
+ return c
56
+ }
57
+
58
+ for fieldName, fieldValue in fields {
59
+ if text.has_suffix(fieldName, ".spec") {
60
+ if !(fieldValue.getValue().checkResourceType(constants.RTYPE_JSON) || fieldValue.getValue().checkResourceType(constants.RTYPE_OBJECT_SPEC)) {
61
+ ll.panic("Unexpected spec value type: %v", fieldValue.getValue().info().Type)
62
+ }
63
+ col := getOrCreateColumn(fieldName[:len(fieldName) - 5])
64
+ col.spec = fieldValue.getValue().getDataAsJson()
65
+ col.specRaw = fieldValue
66
+ } else if text.has_suffix(fieldName, ".data") {
67
+ col := getOrCreateColumn(fieldName[:len(fieldName) - 5])
68
+ col.data = fieldValue
69
+ } else {
70
+ ll.panic("Unexpected field name: %v", fieldName)
71
+ }
72
+ }
73
+
74
+ validation.assertType(columns, {any: {
75
+ "spec,?": "any",
76
+ "specRaw,?": validation.reference,
77
+ "data,?": validation.reference
78
+ }})
79
+
80
+
81
+
82
+
83
+ result := pframes.pFrameBuilder()
84
+
85
+
86
+ eMulTplInput := smart.mapBuilder()
87
+
88
+ eMulTplRender := render.createEphemeral(eMulTpl, { data: eMulTplInput })
89
+
90
+ for colName, col in columns {
91
+ if is_undefined(col.data) {
92
+ result.add(colName, col.specRaw, undefined)
93
+ continue
94
+ }
95
+
96
+ shouldHideDataFromUI := skipHideDataFromUI && !is_undefined(col.spec) && col.spec.annotations["pl7.app/hideDataFromUi"] == "true"
97
+ if shouldHideDataFromUI {
98
+
99
+ result.add(colName, col.specRaw, undefined)
100
+ continue
101
+ }
102
+
103
+ if is_undefined(col.spec) || (
104
+ col.spec.kind == "PColumn" && (
105
+ is_undefined(col.spec.valueType) ||
106
+ col.spec.valueType == "file" || col.spec.valueType == "blob" ||
107
+ col.spec.valueType == "File" || col.spec.valueType == "Blob" ||
108
+ col.spec.valueType == "Int" || col.spec.valueType == "Long" ||
109
+ col.spec.valueType == "Float" || col.spec.valueType == "Double" ||
110
+ col.spec.valueType == "String" || col.spec.valueType == "Bytes")) {
111
+
112
+ result.add(colName, col.specRaw, eMulTplRender.output(colName))
113
+ eMulTplInput.add(colName, col.data)
114
+ continue
115
+ }
116
+
117
+ if col.spec.kind == "File" {
118
+ result.add(colName, col.specRaw, file.exportFile(col.data))
119
+ continue
120
+ }
121
+
122
+ result.add(colName, col.specRaw, col.data)
123
+ }
124
+
125
+ eMulTplInput.build()
126
+
127
+ return result.build()
128
+ }
129
+
130
+ export {
131
+ exportPFrame: exportPFrame
132
+ }
@@ -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.2",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "@platforma-open/milaboratories.software-small-binaries": "^1.15.19"
21
21
  },
22
22
  "devDependencies": {
23
- "@platforma-sdk/tengo-builder": "^2.0.0"
23
+ "@platforma-sdk/tengo-builder": "^2.0.1"
24
24
  },
25
25
  "scripts": {
26
26
  "type-check": "pl-tengo check",