@platforma-sdk/workflow-tengo 2.9.6 → 2.9.8

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