@platforma-sdk/workflow-tengo 2.14.0 → 2.15.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.
Files changed (80) hide show
  1. package/README.md +17 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -1
  4. package/dist/index.mjs +3 -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 +13 -13
  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,13 +1,13 @@
1
1
  ll := import("@platforma-sdk/workflow-tengo:ll")
2
2
  enum := import("enum")
3
3
 
4
- /**
5
- * Returns length of the collection even if it's nil.
6
- * It's a one of rare differences of Tengo and Go.
7
- *
8
- * @param slice: []any | undefined - a slice
9
- * @return: length: int
10
- */
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
11
  length := func(slice) {
12
12
  if is_undefined(slice) {
13
13
  return 0
@@ -15,16 +15,16 @@ length := func(slice) {
15
15
  return len(slice)
16
16
  }
17
17
 
18
- /**
19
- * Returns a slice of the array, but you can give negative from and to,
20
- * in which case it slices from the end like in Python.
21
- * Example: slice([1, 2, 3], 0, -1) == [1, 2]
22
- *
23
- * @param array: []any - a slice
24
- * @param from: number - an index we starts from
25
- * @param to: number - an index the slice will end
26
- * @return slice: []any - a sliced array.
27
- */
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
28
  slice := func(array, from, to) {
29
29
  len := length(array)
30
30
  if from < 0 {
@@ -37,14 +37,14 @@ slice := func(array, from, to) {
37
37
  return array[from:to]
38
38
  }
39
39
 
40
- /**
41
- * Appends slices safely even some of them are nil.
42
- * It's one of rare differences of Tengo and Go.
43
- *
44
- * @param slice: []any - a slice
45
- * @param toAppend: ...any - elements we'll append to the slice
46
- * @return new slice: []any - the same slice but with appended elements.
47
- */
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
48
  safeAppend := func(slice, ...toAppend) {
49
49
  if is_undefined(slice) {
50
50
  slice = []
@@ -56,13 +56,13 @@ safeAppend := func(slice, ...toAppend) {
56
56
  return append(slice, toAppend...)
57
57
  }
58
58
 
59
- /**
60
- * Returns an index of an element in the slice or -1 if it wasn't found.
61
- *
62
- * @param silce: []any
63
- * @param element: any
64
- * @return index: int - index of the element or -1
65
- */
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
66
  findElement := func(slice, element) {
67
67
  for i, elem in slice {
68
68
  if elem == element {
@@ -73,35 +73,35 @@ findElement := func(slice, element) {
73
73
  return -1
74
74
  }
75
75
 
76
- /**
77
- * Returns a boolean of whether an element is in a slice.
78
- *
79
- * @param slice: []any
80
- * @param element: any - an element the function searches for.
81
- * @return found: bool
82
- */
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
83
  hasElement := func(slice, element) {
84
84
  return findElement(slice, element) != -1
85
85
  }
86
86
 
87
- /**
88
- * Removes an element from the slice
89
- *
90
- * @param slice: []any
91
- * @param i: int - an index of the element to remove.
92
- * @return nothing
93
- */
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
94
  removeElement := func(slice, i) {
95
95
  return safeAppend(slice[:i], slice[i+1:]...)
96
96
  }
97
97
 
98
- /**
99
- * Returns a new slice with elements for which a predicate returned true.
100
- *
101
- * @param slice: []any
102
- * @param predicateFn: func(elem): bool - a function that gets an element and returns a truthy or falsy value.
103
- * @return new slice: []any - a slice with matched elements.
104
- */
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
105
  filter := func(slice, predicateFn) {
106
106
  newS := []
107
107
  for _, elem in slice {
@@ -113,13 +113,13 @@ filter := func(slice, predicateFn) {
113
113
  return newS
114
114
  }
115
115
 
116
- /**
117
- * Transforms each element of the slice to a new one and returns a new slice
118
- *
119
- * @param slice: []any
120
- * @param fn: func(elem): new elem - a function that gets an element and returns a transformed element.
121
- * @return new slice: []any - a new slice with transformed elements.
122
- */
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
123
  map := func(slice, fn) {
124
124
  newS := []
125
125
  for _, elem in slice {
@@ -129,16 +129,16 @@ map := func(slice, fn) {
129
129
  return newS
130
130
  }
131
131
 
132
- /**
133
- * Returns the result of applying fn to the first 2 items in the slice, then
134
- * applying fn to that result and the 3rd item, etc.
135
- * If coll has only 1 item, it is returned and fn is not called.
136
- *
137
- * @param slice: []any
138
- * @param fn: func(any, element): new result.
139
- * a function that gets a result got so far and an element and returns a new result.
140
- * @return final result: any - the final result
141
- */
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
142
  reduce := func(slice, fn, ...init) {
143
143
  result := undefined
144
144
  for i, elem in slice {
@@ -152,7 +152,7 @@ reduce := func(slice, fn, ...init) {
152
152
  return result
153
153
  }
154
154
 
155
- /** Returns true if the function applied to every element returns true. */
155
+
156
156
  every := func(slice, fn) {
157
157
  for _, elem in slice {
158
158
  if !fn(elem) {
@@ -162,11 +162,11 @@ every := func(slice, fn) {
162
162
  return true
163
163
  }
164
164
 
165
- //
166
- // Simple quick-sort implementations:
167
- // - with user-provided ordering
168
- // - and with native sorting
169
- //
165
+
166
+
167
+
168
+
169
+
170
170
 
171
171
  _quickSortFn := func(arr, left, right, less) {
172
172
  if is_undefined(arr) || len(arr) <= 1 || left < 0 || left >= len(arr) || right < 0 || right >= len(arr) || left >= right {
@@ -210,65 +210,65 @@ _quickSort := func(arr, left, right) {
210
210
  return arr
211
211
  }
212
212
 
213
- /**
214
- * Sorts slice in-place, using native ordering.
215
- *
216
- * @param s: []any - a slice of elements of any comparable type
217
- * @return s: []any the same slice after sorting
218
- *
219
- */
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
220
  quickSortInPlace := func(s) {
221
221
  _quickSort(s, 0, len(s)-1)
222
222
  return s
223
223
  }
224
224
 
225
- /**
226
- * Copy the slice and returtn sorted slice according to native ordering.
227
- *
228
- * @param s: []any - a slice of elements of any comparable type
229
- * @return s: []any sorted slice
230
- *
231
- */
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
232
  quickSort := func(s) {
233
233
  s = copy(s)
234
234
  _quickSort(s, 0, len(s)-1)
235
235
  return s
236
236
  }
237
237
 
238
- /**
239
- * Sorts slice in-place, using provided ordering function.
240
- *
241
- * @param s: []any - a slice of elements of any comparable type
242
- * @param less: func(a, b): boolean - define ordering, must return true, if a < b
243
- * @return s: []any the same slice after sorting
244
- */
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
245
  quickSortInPlaceFn := func(s, less) {
246
246
  _quickSortFn(s, 0, len(s)-1, less)
247
247
  return s
248
248
  }
249
249
 
250
- /**
251
- * Copy the slice and returtn sorted slice according to using provided ordering function.
252
- *
253
- * @param s: []any - a slice of elements of any comparable type
254
- * @param less: func(a, b): boolean - define ordering, must return true, if a < b
255
- * @return s: []any sorted slice
256
- *
257
- */
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
258
  quickSortFn := func(s, less) {
259
259
  s = copy(s)
260
260
  _quickSortFn(s, 0, len(s)-1, less)
261
261
  return s
262
262
  }
263
263
 
264
- /**
265
- * Creates a copy of a slice and sorts it using a stable bubble sort.
266
- *
267
- * @param notSortedSlice: []any - a slice of elements of any type.
268
- * @param fn: func(elem): int - a function that transforms an element to a key.
269
- * @return sorted slice: []any
270
- *
271
- */
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
272
  sortByFn := func(notSortedSlice, fn) {
273
273
  s := copy(notSortedSlice)
274
274
 
@@ -285,24 +285,24 @@ sortByFn := func(notSortedSlice, fn) {
285
285
  return s
286
286
  }
287
287
 
288
- /**
289
- * Creates a slice from a set of elements
290
- *
291
- * @param set: map[element]any - a set
292
- * @return slice: []element - a slice of elements from the set, sorted by an element.
293
- */
288
+
289
+
290
+
291
+
292
+
293
+
294
294
  fromSet := func(set) {
295
295
  slice := enum.map(set, func(k, _) { return k })
296
296
  return sortByFn(slice, func(elem) { return elem })
297
297
  }
298
298
 
299
- /**
300
- * Normalizes a slice by ensuring it is never undefined.
301
- * Returns an empty slice if input is undefined, otherwise returns the input slice unchanged.
302
- *
303
- * @param s: any[]|undefined - Input slice that may be undefined
304
- * @returns any[] - Normalized slice, never undefined
305
- */
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
306
  normalize := func(s) {
307
307
  if is_undefined(s) {
308
308
  return []