@platforma-sdk/workflow-tengo 2.8.0 → 2.8.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 (59) hide show
  1. package/dist/tengo/lib/assets.lib.tengo +76 -82
  2. package/dist/tengo/lib/constants.lib.tengo +28 -31
  3. package/dist/tengo/lib/exec.R.internal.lib.tengo +14 -14
  4. package/dist/tengo/lib/exec.R.lib.tengo +158 -167
  5. package/dist/tengo/lib/exec.internal.lib.tengo +222 -234
  6. package/dist/tengo/lib/exec.lib.tengo +647 -714
  7. package/dist/tengo/lib/exec.package.lib.tengo +229 -238
  8. package/dist/tengo/lib/exec.python.internal.lib.tengo +5 -6
  9. package/dist/tengo/lib/exec.python.lib.tengo +138 -146
  10. package/dist/tengo/lib/exec.runcmd.lib.tengo +234 -253
  11. package/dist/tengo/lib/exec.runenv.lib.tengo +88 -92
  12. package/dist/tengo/lib/exec.stream.lib.tengo +36 -40
  13. package/dist/tengo/lib/file.internal.lib.tengo +70 -77
  14. package/dist/tengo/lib/file.lib.tengo +54 -57
  15. package/dist/tengo/lib/ll.lib.tengo +217 -241
  16. package/dist/tengo/lib/maps.lib.tengo +98 -106
  17. package/dist/tengo/lib/objects.lib.tengo +11 -13
  18. package/dist/tengo/lib/oop.lib.tengo +16 -19
  19. package/dist/tengo/lib/path.lib.tengo +116 -125
  20. package/dist/tengo/lib/pframes.constants.lib.tengo +25 -28
  21. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +28 -33
  22. package/dist/tengo/lib/pframes.lib.tengo +38 -43
  23. package/dist/tengo/lib/pframes.ll.lib.tengo +70 -73
  24. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +45 -51
  25. package/dist/tengo/lib/pframes.spec.lib.tengo +70 -96
  26. package/dist/tengo/lib/pframes.util.lib.tengo +154 -289
  27. package/dist/tengo/lib/pframes.xsv.lib.tengo +260 -273
  28. package/dist/tengo/lib/render.lib.tengo +65 -76
  29. package/dist/tengo/lib/sets.lib.tengo +61 -68
  30. package/dist/tengo/lib/slices.lib.tengo +169 -180
  31. package/dist/tengo/lib/smart.lib.tengo +956 -1069
  32. package/dist/tengo/lib/test.lib.tengo +129 -161
  33. package/dist/tengo/lib/tpl.lib.tengo +448 -516
  34. package/dist/tengo/lib/tpl.state-await.lib.tengo +226 -241
  35. package/dist/tengo/lib/tpl.util.lib.tengo +4 -9
  36. package/dist/tengo/lib/validation.lib.tengo +334 -379
  37. package/dist/tengo/lib/workdir.lib.tengo +309 -332
  38. package/dist/tengo/lib/workdir.proc.lib.tengo +126 -144
  39. package/dist/tengo/lib/workdir.save.lib.tengo +113 -130
  40. package/dist/tengo/lib/workflow.bobject.lib.tengo +21 -26
  41. package/dist/tengo/lib/workflow.bquery.lib.tengo +140 -166
  42. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -2
  43. package/dist/tengo/lib/workflow.context.lib.tengo +27 -32
  44. package/dist/tengo/lib/workflow.lib.tengo +167 -207
  45. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  46. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  47. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  48. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  49. package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
  50. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  51. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  52. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  53. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  54. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
  55. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  56. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  57. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  58. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  59. package/package.json +5 -5
@@ -1,4 +1,3 @@
1
- /* Low level pl API */
2
1
 
3
2
  plapi := import("plapi")
4
3
  json := import("json")
@@ -6,311 +5,288 @@ fmt := import("fmt")
6
5
  log := import("log")
7
6
  text := import("text")
8
7
 
9
- /**
10
- * Provides current API version available at runtime
11
- */
8
+
9
+
12
10
  apiVersion := func() {
13
- return 0 // stub code. Real API checker will appear here.
11
+ return 0 // stub code. Real API checker will appear here.
14
12
  }
15
13
 
16
- /**
17
- * Prints message to the pl log
18
- */
14
+
15
+
19
16
  print := func(txt, ...args) {
20
- plapi.print(txt, args...)
17
+ plapi.print(txt, args...)
21
18
  }
22
19
 
23
- /**
24
- * Panics in a template, prints the error and
25
- * stops the execution of the template.
26
- * After that, the controller will set errors to outputs.
27
- */
20
+
21
+
22
+
23
+
28
24
  panic := func(msg, ...args) {
29
- txt := fmt.sprintf(msg, args...)
30
- plapi.print(txt)
25
+ txt := fmt.sprintf(msg, args...)
26
+ plapi.print(txt)
31
27
 
32
- // next statement actually terminates the execution
33
- plapi.setTemplateError(txt)
28
+ plapi.setTemplateError(txt)
34
29
  }
35
30
 
36
- /**
37
- * Asserts a given condition and panics if it is not met
38
- */
31
+
32
+
39
33
  assert := func(condition, msg, ...args) {
40
- if !condition {
41
- panic("assertion error: condition failed: "+msg, args...)
42
- }
34
+ if !condition {
35
+ panic("assertion error: condition failed: "+msg, args...)
36
+ }
43
37
  }
44
38
 
45
- /**
46
- * Checks whether the given object is a strict map
47
- *
48
- * @param obj any
49
- * @return strict: bool - whether obj is a 'strict' map
50
- */
39
+
40
+
41
+
42
+
43
+
51
44
  isStrict := func(obj) {
52
- return plapi.isStrictMap(obj)
45
+ return plapi.isStrictMap(obj)
53
46
  }
54
47
 
55
- /**
56
- * Checks whether the given object is a map, a strict map or an immutable map.
57
- *
58
- * @param obj any
59
- * @return bool whether obj is any kind of map object (map/immutable map/strict map)
60
- */
48
+
49
+
50
+
51
+
52
+
61
53
  isMap := func(obj) {
62
- return is_map(obj) || is_immutable_map(obj) || isStrict(obj)
54
+ return is_map(obj) || is_immutable_map(obj) || isStrict(obj)
63
55
  }
64
56
 
65
- /**
66
- * Converts 'strict' map into a normal one
67
- *
68
- * @param r: map|strictMap (will panic if not)
69
- *
70
- * @return map: std map
71
- */
57
+
58
+
59
+
60
+
61
+
62
+
72
63
  fromStrict := func(r) {
73
- if is_map(r) {
74
- return r
75
- }
64
+ if is_map(r) {
65
+ return r
66
+ }
76
67
 
77
- if !isStrict(r) {
78
- panic("not a map", r)
79
- }
68
+ if !isStrict(r) {
69
+ panic("not a map", r)
70
+ }
80
71
 
81
- return plapi.strictToMap(r)
72
+ return plapi.strictToMap(r)
82
73
  }
83
74
 
84
- /**
85
- * Safe way to check if method exists in a builtin module or a library
86
- *
87
- * @param module: module - builtin module or tengo library
88
- * @param methodName: string - name of a method to be checked
89
- *
90
- * @return bool - true when method exists, false otherwise
91
- */
75
+
76
+
77
+
78
+
79
+
80
+
81
+
92
82
  methodExists := func(module, methodName) {
93
- if isStrict(module) {
94
- if !is_callable(plapi.mapHasKey) {
95
- module = fromStrict(module)
83
+ if isStrict(module) {
84
+ if !is_callable(plapi.mapHasKey) {
85
+ module = fromStrict(module)
96
86
 
97
- } else {
98
- if !plapi.mapHasKey(module, methodName) {
99
- return false
100
- }
101
- }
102
- }
87
+ } else {
88
+ if !plapi.mapHasKey(module, methodName) {
89
+ return false
90
+ }
91
+ }
92
+ }
103
93
 
104
- method := module[methodName]
94
+ method := module[methodName]
105
95
 
106
- if is_undefined(method) {
107
- return false
108
- }
96
+ if is_undefined(method) {
97
+ return false
98
+ }
109
99
 
110
- return is_callable(method)
100
+ return is_callable(method)
111
101
  }
112
102
 
113
- /**
114
- * If input is a strict map, converts it to a normal one, otherwise returns the object as is
115
- *
116
- * @param r: any object (possible strict map)
117
- * @return map: tengo object
118
- */
103
+
104
+
105
+
106
+
107
+
119
108
  ensureNonStrict := func(r) {
120
- if isStrict(r) {
121
- return fromStrict(r)
122
- }
123
-
124
- return r
125
- }
126
-
127
- /**
128
- * Converts map into a 'strict' map, which will panic on
129
- * access to non-existing elements.
130
- *
131
- * @param m: map|strictMap
132
- * @param recursive: boolean - convert also all child maps
133
- *
134
- * @return strict: strictMap
135
- */
109
+ if isStrict(r) {
110
+ return fromStrict(r)
111
+ }
112
+
113
+ return r
114
+ }
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
136
124
  toStrict := func(v, ...recursive) {
137
- if len(recursive) > 0 && recursive[0] {
138
- if isMap(v) {
139
- for k, vv in v {
140
- v[k] = toStrict(vv)
141
- }
142
- } else if is_array(v) {
143
- for i, vv in v {
144
- if isMap(vv) {
145
- v[i] = toStrict(vv)
146
- }
147
- }
148
- }
149
-
150
- if !isMap(v) {
151
- return v // for recursive transformation, accept the top-level value to be of any type (i.e. array of maps)
152
- }
153
- }
154
-
155
- if isStrict(v) {
156
- return v
157
- }
158
-
159
- if(!isMap(v)) {
160
- panic("toStrict(<v>): <v> is not a map", v)
161
- }
162
- return plapi.mapToStrict(v)
163
- }
164
-
165
- /**
166
- * Creates a field Id struct from given resource id and field name
167
- */
125
+ if len(recursive) > 0 && recursive[0] {
126
+ if isMap(v) {
127
+ for k, vv in v {
128
+ v[k] = toStrict(vv)
129
+ }
130
+ } else if is_array(v) {
131
+ for i, vv in v {
132
+ if isMap(vv) {
133
+ v[i] = toStrict(vv)
134
+ }
135
+ }
136
+ }
137
+
138
+ if !isMap(v) {
139
+ return v // for recursive transformation, accept the top-level value to be of any type (i.e. array of maps)
140
+ }
141
+ }
142
+
143
+ if isStrict(v) {
144
+ return v
145
+ }
146
+
147
+ if(!isMap(v)) {
148
+ panic("toStrict(<v>): <v> is not a map", v)
149
+ }
150
+ return plapi.mapToStrict(v)
151
+ }
152
+
153
+
154
+
168
155
  fieldId := func(resourceId, fieldName) {
169
- return plapi.newFieldID(resourceId, fieldName)
156
+ return plapi.newFieldID(resourceId, fieldName)
170
157
  }
171
158
 
172
- /**
173
- * Checks if <val> can be used as field ID
174
- */
159
+
160
+
175
161
  isFieldId := func(val) {
176
- if !isStrict(val) {
177
- return false
178
- }
179
- v := fromStrict(val)
180
- return v["ResourceID"] != undefined && v["Name"] != undefined
162
+ if !isStrict(val) {
163
+ return false
181
164
  }
165
+ v := fromStrict(val)
166
+ return v["ResourceID"] != undefined && v["Name"] != undefined
167
+ }
168
+
169
+
182
170
 
183
- /**
184
- * Converts reference ID (resource ID or field ID) to stable string representation, suitable for use as map keys
185
- */
186
171
  idToString := func(referenceID) {
187
- if isFieldId(referenceID) {
188
- return fmt.sprintf("0x%X/%s", referenceID.ResourceID, referenceID.Name)
189
- }
190
- if is_int(referenceID) {
191
- return fmt.sprintf("0x%X", referenceID)
192
- }
193
- panic("ll.idToString: <referenceID> cannot be used as resource or field ID")
194
- }
195
-
196
- /**
197
- * Returns current template renderer
198
- */
172
+ if isFieldId(referenceID) {
173
+ return fmt.sprintf("0x%X/%s", referenceID.ResourceID, referenceID.Name)
174
+ }
175
+ if is_int(referenceID) {
176
+ return fmt.sprintf("0x%X", referenceID)
177
+ }
178
+ panic("ll.idToString: <referenceID> cannot be used as resource or field ID")
179
+ }
180
+
181
+
182
+
199
183
  getCurrentTemplateRenderer := func() {
200
- return plapi.getTemplate()
184
+ return plapi.getTemplate()
201
185
  }
202
186
 
203
- /**
204
- * @return isInit: bool - true when current template is initializing (executed for the first time)
205
- */
187
+
188
+
206
189
  isInitializing := func() {
207
- return plapi.isInit
190
+ return plapi.isInit
208
191
  }
209
192
 
210
- /**
211
- * Get the list of executors available in current Platforma installation.
212
- *
213
- * @return executors: []string - list of executors, say ['executor', 'docker', ...]
214
- */
193
+
194
+
195
+
196
+
215
197
  getExecutorsList := func() {
216
- return plapi.getExecutors()
198
+ return plapi.getExecutors()
217
199
  }
218
200
 
219
- /**
220
- * Joins path elements into a single path.
221
- *
222
- * @param elems: ...string - any number of elements.
223
- */
201
+
202
+
203
+
204
+
224
205
  filepathJoin := func(...elems) {
225
- return plapi.filepathJoin(elems...)
206
+ return plapi.filepathJoin(elems...)
226
207
  }
227
208
 
228
- /**
229
- * Like filepathJoin, joins elements to a single path,
230
- * but can be used safely in regexps.
231
- *
232
- * @param elems: ...string - any number of elements.
233
- */
209
+
210
+
211
+
212
+
213
+
234
214
  filepathRegexpJoin := func(...elems) {
235
- escapedSeparator := plapi.regexpQuoteMeta(plapi.osSeparator)
236
- return text.join(elems, escapedSeparator)
215
+ escapedSeparator := plapi.regexpQuoteMeta(plapi.osSeparator)
216
+ return text.join(elems, escapedSeparator)
237
217
  }
238
218
 
239
- /**
240
- * Joins elements of the filepath and canonizes it, i.e.
241
- * semantically resolves ../ and ./ and changes slash
242
- * to a pathSeparator.
243
- *
244
- * @param elems: ...string - any number of elements.
245
- */
219
+
220
+
221
+
222
+
223
+
224
+
246
225
  filepathCanonize := func(...elem) {
247
- return plapi.filepathCanonize(elem...)
226
+ return plapi.filepathCanonize(elem...)
248
227
  }
249
228
 
250
- /**
251
- * Returns a path separator. "/" on Unix-like systems, "\\" on Windows.
252
- *
253
- * @return separator: string
254
- */
229
+
230
+
231
+
232
+
255
233
  pathSeparator := plapi.osSeparator
256
234
 
257
- /**
258
- * Parses URL and returns a structure containing separe parts of the URL.
259
- *
260
- * The general form represented is:
261
- *
262
- * [scheme:][//[userinfo@]host][/]path[?query][#fragment]
263
- *
264
- * URLs that do not start with a slash after the scheme are interpreted as:
265
- *
266
- * scheme:opaque[?query][#fragment]
267
- *
268
- * Returns the floowing structure:
269
- *
270
- * {
271
- * Scheme: string,
272
- * Host: string,
273
- * Port: number,
274
- * Path: string,
275
- * RawPath: string,
276
- * Query: string
277
- * }
278
- *
279
- * @param url: string with the url
280
- * @return url structure: (see above)
281
- */
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
282
259
  parseUrl := func(url) {
283
- return plapi.urlParse(url)
260
+ return plapi.urlParse(url)
284
261
  }
285
262
 
286
- /**
287
- * Returns current execution context, which cab be used is a simple kv-store associated with the renderer instance.
288
- */
263
+
264
+
289
265
  getCtx := func() {
290
- return plapi.getCtx()
266
+ return plapi.getCtx()
291
267
  }
292
268
 
293
269
  export toStrict({
294
- apiVersion: apiVersion,
295
- print: print,
296
- panic: panic,
297
- assert: assert,
298
- methodExists: methodExists,
299
- isStrict: isStrict,
300
- isMap: isMap,
301
- fromStrict: fromStrict,
302
- ensureNonStrict: ensureNonStrict,
303
- toStrict: toStrict,
304
- fieldId: fieldId,
305
- isFieldId: isFieldId,
306
- idToString: idToString,
307
- getCurrentTemplateRenderer: getCurrentTemplateRenderer,
308
- isInitializing: isInitializing,
309
- getExecutorsList: getExecutorsList,
310
- filepathJoin: filepathJoin,
311
- filepathRegexpJoin: filepathRegexpJoin,
312
- pathSeparator: pathSeparator,
313
- filepathCanonize: filepathCanonize,
314
- parseUrl: parseUrl,
315
- getCtx: getCtx
270
+ apiVersion: apiVersion,
271
+ print: print,
272
+ panic: panic,
273
+ assert: assert,
274
+ methodExists: methodExists,
275
+ isStrict: isStrict,
276
+ isMap: isMap,
277
+ fromStrict: fromStrict,
278
+ ensureNonStrict: ensureNonStrict,
279
+ toStrict: toStrict,
280
+ fieldId: fieldId,
281
+ isFieldId: isFieldId,
282
+ idToString: idToString,
283
+ getCurrentTemplateRenderer: getCurrentTemplateRenderer,
284
+ isInitializing: isInitializing,
285
+ getExecutorsList: getExecutorsList,
286
+ filepathJoin: filepathJoin,
287
+ filepathRegexpJoin: filepathRegexpJoin,
288
+ pathSeparator: pathSeparator,
289
+ filepathCanonize: filepathCanonize,
290
+ parseUrl: parseUrl,
291
+ getCtx: getCtx
316
292
  })