@platforma-sdk/workflow-tengo 2.13.6 → 2.15.0

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 (80) hide show
  1. package/README.md +17 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +4 -1
  4. package/dist/index.mjs +4 -1
  5. package/dist/tengo/lib/assets.lib.tengo +28 -28
  6. package/dist/tengo/lib/assets.swinfo.lib.tengo +24 -24
  7. package/dist/tengo/lib/constants.lib.tengo +6 -3
  8. package/dist/tengo/lib/exec.R.internal.lib.tengo +2 -2
  9. package/dist/tengo/lib/exec.R.lib.tengo +41 -41
  10. package/dist/tengo/lib/exec.descriptor.lib.tengo +3 -3
  11. package/dist/tengo/lib/exec.internal.lib.tengo +41 -41
  12. package/dist/tengo/lib/exec.lib.tengo +289 -289
  13. package/dist/tengo/lib/exec.limits.lib.tengo +49 -49
  14. package/dist/tengo/lib/exec.monetization.lib.tengo +1 -1
  15. package/dist/tengo/lib/exec.monetization_internal.lib.tengo +38 -38
  16. package/dist/tengo/lib/exec.package.lib.tengo +53 -53
  17. package/dist/tengo/lib/exec.python.internal.lib.tengo +1 -1
  18. package/dist/tengo/lib/exec.python.lib.tengo +37 -37
  19. package/dist/tengo/lib/exec.runcmd.lib.tengo +138 -138
  20. package/dist/tengo/lib/exec.runenv.lib.tengo +18 -18
  21. package/dist/tengo/lib/exec.stream.lib.tengo +25 -25
  22. package/dist/tengo/lib/feats.lib.tengo +3 -3
  23. package/dist/tengo/lib/file.internal.lib.tengo +31 -31
  24. package/dist/tengo/lib/file.lib.tengo +29 -29
  25. package/dist/tengo/lib/ll.get-future-field-default.lib.tengo +137 -0
  26. package/dist/tengo/lib/ll.lib.tengo +129 -129
  27. package/dist/tengo/lib/maps.lib.tengo +38 -38
  28. package/dist/tengo/lib/objects.lib.tengo +6 -6
  29. package/dist/tengo/lib/oop.lib.tengo +11 -11
  30. package/dist/tengo/lib/path.lib.tengo +60 -60
  31. package/dist/tengo/lib/pframes.builder.lib.tengo +3 -3
  32. package/dist/tengo/lib/pframes.constants.lib.tengo +20 -20
  33. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +5 -5
  34. package/dist/tengo/lib/pframes.lib.tengo +206 -198
  35. package/dist/tengo/lib/pframes.ll.lib.tengo +59 -59
  36. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +18 -18
  37. package/dist/tengo/lib/pframes.remove-nulls.lib.tengo +36 -0
  38. package/dist/tengo/lib/pframes.spec.lib.tengo +83 -83
  39. package/dist/tengo/lib/pframes.util.lib.tengo +176 -176
  40. package/dist/tengo/lib/pframes.xsv-import-file.lib.tengo +160 -0
  41. package/dist/tengo/lib/pframes.xsv.lib.tengo +84 -167
  42. package/dist/tengo/lib/render.lib.tengo +100 -45
  43. package/dist/tengo/lib/sets.lib.tengo +44 -44
  44. package/dist/tengo/lib/slices.lib.tengo +126 -126
  45. package/dist/tengo/lib/smart.lib.tengo +654 -507
  46. package/dist/tengo/lib/test.lib.tengo +120 -120
  47. package/dist/tengo/lib/tpl.lib.tengo +206 -170
  48. package/dist/tengo/lib/tpl.state-await.lib.tengo +17 -17
  49. package/dist/tengo/lib/tpl.util.lib.tengo +5 -5
  50. package/dist/tengo/lib/units.lib.tengo +2 -2
  51. package/dist/tengo/lib/validation.lib.tengo +130 -130
  52. package/dist/tengo/lib/waiter.lib.tengo +59 -0
  53. package/dist/tengo/lib/workdir.lib.tengo +126 -126
  54. package/dist/tengo/lib/workdir.proc.lib.tengo +47 -47
  55. package/dist/tengo/lib/workdir.save.lib.tengo +53 -53
  56. package/dist/tengo/lib/workflow.bobject.lib.tengo +11 -11
  57. package/dist/tengo/lib/workflow.bquery.lib.tengo +40 -40
  58. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -1
  59. package/dist/tengo/lib/workflow.context.lib.tengo +16 -16
  60. package/dist/tengo/lib/workflow.lib.tengo +76 -76
  61. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  62. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  63. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  64. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  65. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  66. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  67. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  68. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  69. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  70. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  71. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  72. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  73. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  74. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  75. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  76. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  77. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  78. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  79. package/package.json +2 -2
  80. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
@@ -1,12 +1,12 @@
1
1
  ll := import("@platforma-sdk/workflow-tengo:ll")
2
2
  slices := import("@platforma-sdk/workflow-tengo:slices")
3
3
 
4
- /**
5
- * Returns a slice of keys of the map.
6
- *
7
- * @param map map[string]any - map to extract keys from
8
- * @return result: string[] - a slice of keys.
9
- */
4
+
5
+
6
+
7
+
8
+
9
+
10
10
  getKeys := func(map) {
11
11
  res := []
12
12
  for k, _ in map {
@@ -16,10 +16,10 @@ getKeys := func(map) {
16
16
  return slices.quickSort(res)
17
17
  }
18
18
 
19
- /**
20
- * Returns true if map contains specified key.
21
- * Note: fallback implementation is O(N). You can remove it after 05.2025
22
- */
19
+
20
+
21
+
22
+
23
23
  containsKey := func(map, key) {
24
24
  for k, _ in map {
25
25
  if key == k {
@@ -30,7 +30,7 @@ containsKey := func(map, key) {
30
30
  return false
31
31
  }
32
32
 
33
- // Load effective version of map key checker if it exists in controller's API
33
+
34
34
  plapi := import("plapi")
35
35
  if ll.methodExists(plapi, "mapHasKey") {
36
36
  containsKey = func(map, key) {
@@ -38,13 +38,13 @@ if ll.methodExists(plapi, "mapHasKey") {
38
38
  }
39
39
  }
40
40
 
41
- /**
42
- * Transforms all keys of the map with a function and returns a new map with these keys.
43
- *
44
- * @param map: map[key]any
45
- * @param fnK: func(key): newKey - a function that gets a key and returns a new key.
46
- * @return new map: map[newKey]any - a transformed map
47
- */
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
48
  mapKeys := func(map, fnK) {
49
49
  newM := {}
50
50
  for k, v in map {
@@ -54,7 +54,7 @@ mapKeys := func(map, fnK) {
54
54
  return newM
55
55
  }
56
56
 
57
- // Map values
57
+
58
58
  mapValues := func(map, fnV) {
59
59
  newM := {}
60
60
  for k, v in map {
@@ -64,7 +64,7 @@ mapValues := func(map, fnV) {
64
64
  return newM
65
65
  }
66
66
 
67
- // Map keys and values
67
+
68
68
  map := func(map, fn) {
69
69
  newM := {}
70
70
  for k, v in map {
@@ -98,16 +98,16 @@ filterKeysValues := func(map, predicateFnK, predicateFnV) {
98
98
  return filter(map, func(k, v) { return predicateFnK(k) && predicateFnV(v) })
99
99
  }
100
100
 
101
- /**
102
- * Returns a deep copy of a map or an array.
103
- * Optionally removes keys having undefined value.
104
- *
105
- * @param obj - object to be cloned
106
- * @param ops - additional options
107
- * {
108
- * removeUndefs: boolean
109
- * }
110
- */
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
111
  clone := func(obj, ...ops) {
112
112
  removeUndefs := false
113
113
  if len(ops) == 1 {
@@ -141,10 +141,10 @@ clone := func(obj, ...ops) {
141
141
  return obj
142
142
  }
143
143
 
144
- /**
145
- * Do shallow merge of arbitrary number of maps.
146
- * Add {... key: undefined ...} to remove the "key" from the map collected from maps before.
147
- */
144
+
145
+
146
+
147
+
148
148
  merge := func(...maps) {
149
149
  res := {}
150
150
  for map in maps {
@@ -159,10 +159,10 @@ merge := func(...maps) {
159
159
  return res
160
160
  }
161
161
 
162
- /**
163
- * Do deep merge of arbitrary number of maps.
164
- * Add {... key: undefined ...} to remove the "key" from the map collected from maps before.
165
- */
162
+
163
+
164
+
165
+
166
166
  deepMerge := undefined
167
167
  deepMerge = func(...maps) {
168
168
  res := {}
@@ -1,12 +1,12 @@
1
- /**
2
- * Utilities for working with objects
3
- */
1
+
2
+
3
+
4
4
 
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
 
7
- /**
8
- * Deletes entries with undefined values from object
9
- */
7
+
8
+
9
+
10
10
  deleteUndefined := func(obj) {
11
11
  for k, v in obj {
12
12
  if is_undefined(v) {
@@ -1,20 +1,20 @@
1
- /**
2
- * Utility functions for working with objects.
3
- */
1
+
2
+
3
+
4
4
 
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
 
7
- /**
8
- * Inherit all methods and properties of a super object
9
- *
10
- * @param super a parent from which we get all methods
11
- * @param self an object in which we set all super methods
12
- * @return self
13
- */
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
14
  inherit := func(super, self) {
15
15
  self["super"] = super
16
16
 
17
- // inherit super methods
17
+
18
18
  for k, v in super {
19
19
  if self[k] == undefined {
20
20
  self[k] = v
@@ -3,53 +3,53 @@ text := import("text")
3
3
  slices := import("@platforma-sdk/workflow-tengo:slices")
4
4
  validation := import("@platforma-sdk/workflow-tengo:validation")
5
5
 
6
- /**
7
- * Joins path elements into a single path.
8
- *
9
- * @param elems: ...string - any number of elements.
10
- */
6
+
7
+
8
+
9
+
10
+
11
11
  join := func(...elems) {
12
12
  validation.assertType(elems, ["string"])
13
13
  return ll.filepathJoin(elems...)
14
14
  }
15
15
 
16
- /**
17
- * Like join, joins elements to a single path,
18
- * but can be used safely in regexps.
19
- *
20
- * @param elems: ...string - any number of elements.
21
- */
16
+
17
+
18
+
19
+
20
+
21
+
22
22
  regexpJoin := func(...elems) {
23
23
  validation.assertType(elems, ["string"])
24
24
  return ll.filepathRegexpJoin(elems...)
25
25
  }
26
26
 
27
- /**
28
- * Joins elements of the filepath and canonizes it, i.e.
29
- * semantically resolves ../ and ./ and changes slash
30
- * to a pathSeparator.
31
- *
32
- * @param elems: ...string - any number of elements.
33
- */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
34
  canonize := func(...elems) {
35
35
  validation.assertType(elems, ["string"])
36
36
  return ll.filepathCanonize(elems...)
37
37
  }
38
38
 
39
- /**
40
- * Returns a path separator. "/" on Unix-like systems, "\\" on Windows.
41
- *
42
- * @return separator: string
43
- */
39
+
40
+
41
+
42
+
43
+
44
44
  separator := ll.pathSeparator
45
45
 
46
- /**
47
- * Trims a beginning of the file path following by a path separator.
48
- *
49
- * @param path: string - a file path
50
- * @param prefix: string - the beginning of the file path
51
- * @return trimmed path: string - a path without the beginning and a path separator.
52
- */
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
53
  trimPrefix := func(path, prefix) {
54
54
  validation.assertType([path, prefix], ["string"])
55
55
  return text.trim_prefix(path, prefix+separator)
@@ -65,29 +65,29 @@ _sepOrDefault := func(...sep) {
65
65
  return sep[0]
66
66
  }
67
67
 
68
- /**
69
- * Splits a path to path components.
70
- * If it was a file name, the last component will be this name.
71
- *
72
- * @param path: string - the path
73
- * @param sep: string - an optional path separator.
74
- * @return components: []string - all directories and a file name at the end.
75
- */
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
76
  split := func(path, ...sep) {
77
77
  sep = _sepOrDefault(sep...)
78
78
 
79
79
  return text.split(path, sep)
80
80
  }
81
81
 
82
- /**
83
- * Gets all directories with their ancestors from the root.
84
- * For example, for dir1/dir2/dir3/abc.txt it gives:
85
- * ["dir1", "dir1/dir2", "dir1/dir2/dir3", "dir1/dir2/dir3/abc.txt"]
86
- *
87
- * @param path: string - the path
88
- * @param separator: string - an optional separator.
89
- * @return components: []string - all directories and a file name at the end from their root.
90
- */
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
91
  getBasenameDirs := func(path, ...sep) {
92
92
  validation.assertType(path, "string")
93
93
  sep = _sepOrDefault(sep...)
@@ -102,14 +102,14 @@ getBasenameDirs := func(path, ...sep) {
102
102
  return dirTails
103
103
  }
104
104
 
105
- /**
106
- * Gets an extension to the last "." symbol,
107
- * or, if the name contains ".gz" or any other archive suffix,
108
- * then till the next from the last "." symbol.
109
- *
110
- * @param path: string - a path
111
- * @return extension: string - the extension without the leading "."
112
- */
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
113
  getExtension := func(path, ...sep) {
114
114
  validation.assertType(path, "string")
115
115
  ext := ""
@@ -137,11 +137,11 @@ getExtension := func(path, ...sep) {
137
137
  return ext
138
138
  }
139
139
 
140
- /**
141
- * Checks if the path is correct.
142
- *
143
- * @param path: string - a path
144
- */
140
+
141
+
142
+
143
+
144
+
145
145
  assertIsValid := func(path) {
146
146
  validation.assertType(path, "string")
147
147
  if text.contains(path, "/") {
@@ -4,9 +4,9 @@ smart := import("@platforma-sdk/workflow-tengo:smart")
4
4
  pConstants := import("@platforma-sdk/workflow-tengo:pframes.constants")
5
5
 
6
6
 
7
- /**
8
- * Creates a builder for p-frame resource.
9
- */
7
+
8
+
9
+
10
10
  pFrameBuilder := func() {
11
11
  r := smart.structBuilder(pConstants.RTYPE_P_FRAME)
12
12
 
@@ -1,32 +1,32 @@
1
- /**
2
- * Contain field names and other constant used in PFrames
3
- * libraries and templates.
4
- */
1
+
2
+
3
+
4
+
5
5
 
6
6
  ll := import("@platforma-sdk/workflow-tengo:ll")
7
7
 
8
- /**
9
- * Name of the field under which the iteration value like in "map" and "aggregate" is passed
10
- * to the iteration body template.
11
- */
8
+
9
+
10
+
11
+
12
12
  VALUE_FIELD_NAME := "__value__"
13
13
 
14
- /**
15
- * Name of the field under which the iteration key like in "map" and "aggregate" is passed
16
- * to the iteration body template.
17
- */
14
+
15
+
16
+
17
+
18
18
  KEY_FIELD_NAME := "__key__"
19
19
 
20
- /**
21
- * Name of the field under which the aggregation axes specification is passed
22
- * to the iteration body template.
23
- */
20
+
21
+
22
+
23
+
24
24
  AGGREGATION_AXES_SPEC_FIELD_NAME := "__aggregation_axes_spec__"
25
25
 
26
- /**
27
- * Name of the field under which the aggregation axes names are passed
28
- * to the iteration body template.
29
- */
26
+
27
+
28
+
29
+
30
30
  AGGREGATION_AXES_NAMES_FIELD_NAME := "__aggregation_axes_names__"
31
31
 
32
32
  RTYPE_P_FRAME := { Name: "PFrame", Version: "1" }
@@ -5,15 +5,15 @@ file := import("@platforma-sdk/workflow-tengo:file")
5
5
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
6
  assets := import("@platforma-sdk/workflow-tengo:assets")
7
7
 
8
- // reference to the template doing nested super-partitioned export
8
+
9
9
  nestedTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.export-single-pcolumn")
10
10
 
11
- /** Implements core export logic for export-single-pcolumn and export-multiple-pcolumns templates */
11
+
12
12
  exportPColumnData := func(data) {
13
13
  if data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP_PARTITIONED) ||
14
14
  data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_JSON_SUPER_PARTITIONED) ||
15
15
  data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_BINARY_SUPER_PARTITIONED) {
16
- // super-partitioned data
16
+
17
17
 
18
18
  newData := smart.structBuilder(data.info().Type, data.info().Data)
19
19
  for key, partData in data.inputs() {
@@ -24,7 +24,7 @@ exportPColumnData := func(data) {
24
24
  } else if data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_RESOURCE_MAP) ||
25
25
  data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_JSON_PARTITIONED) ||
26
26
  data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_BINARY_PARTITIONED) {
27
- // data directly referencing blob objects
27
+
28
28
 
29
29
  newData := smart.structBuilder(data.info().Type, data.info().Data)
30
30
  for key, partData in data.inputs() {
@@ -33,7 +33,7 @@ exportPColumnData := func(data) {
33
33
  return newData.lockAndBuild()
34
34
 
35
35
  } else if data.checkResourceType(pConstants.RTYPE_P_COLUMN_DATA_JSON) {
36
- // data embeds all information and needs no special exporting procedure
36
+
37
37
 
38
38
  return data
39
39