@platforma-sdk/workflow-tengo 4.2.1 → 4.2.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 (34) hide show
  1. package/dist/tengo/lib/pframes.bundle.lib.tengo +2 -1
  2. package/dist/tengo/lib/smart.lib.tengo +15 -0
  3. package/dist/tengo/lib/tpl.base.lib.tengo +57 -4
  4. package/dist/tengo/lib/workflow.bquery.lib.tengo +22 -16
  5. package/dist/tengo/lib/workflow.lib.tengo +1 -0
  6. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  7. package/dist/tengo/tpl/check_network.download_blob_from_storage.plj.gz +0 -0
  8. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  9. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  10. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  11. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  12. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  13. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  14. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  15. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  16. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  17. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  18. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  19. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  20. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  21. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  22. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  26. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  27. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  28. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  29. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  30. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  31. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  32. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  33. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  34. package/package.json +1 -1
@@ -232,8 +232,9 @@ createBuilder := func(ctx) {
232
232
  bundle := smart.mapBuilder(pConstants.RTYPE_P_COLUMN_BUNDLE)
233
233
 
234
234
  for refKey, ref in refs {
235
- if is_string(ref) {
235
+ if is_string(ref) { // ref is anchor id
236
236
  bundle.addRef(refKey, resolveResult.getAnchor(ref))
237
+ bundle.addRef(ref, resolveResult.getAnchor(ref))
237
238
  } else {
238
239
  bundle.addRef(refKey, bquery.resolve(ref, ctx))
239
240
  }
@@ -632,6 +632,21 @@ resource = func(r) {
632
632
 
633
633
 
634
634
 
635
+ getFieldOrResource: func(name) {
636
+ field := self.getField(name)
637
+ if field.isSet() {
638
+ return field.getValue()
639
+ } else {
640
+ return field
641
+ }
642
+ },
643
+
644
+
645
+
646
+
647
+
648
+
649
+
635
650
 
636
651
  kvGet: func(key) {
637
652
  return tx.resourceKeyValueGet(self.id, key)
@@ -67,6 +67,29 @@ _unmarshal := func(resource, preprocessors) {
67
67
  }
68
68
  }
69
69
 
70
+ AWAIT_TEMPLATES := {
71
+ "BQueryResultSingle": [
72
+ ["ref", "ResourceReady"],
73
+ ["spec", "ResourceReady"]
74
+ ],
75
+ "BQueryResultMulti": [
76
+ ["spec", "ResourceReady"],
77
+ ["data", "InputsLocked"]
78
+ ],
79
+ "BQueryResultMultiNoData": [
80
+ ["spec", "ResourceReady"]
81
+ ],
82
+ "PColumnBundle": [
83
+ [{ wildcard: "*" }, "ref", "ResourceReady"],
84
+ [{ wildcard: "*" }, "spec", "ResourceReady"]
85
+ ],
86
+ "PColumnBundleWithPartitions": [
87
+ [{ wildcard: "*" }, "ref", "ResourceReady"],
88
+ [{ wildcard: "*" }, "spec", "ResourceReady"],
89
+ [{ wildcard: "*" }, "data", "InputsLocked"]
90
+ ]
91
+ }
92
+
70
93
 
71
94
 
72
95
 
@@ -208,6 +231,15 @@ tpl := func(ops) {
208
231
 
209
232
 
210
233
 
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
211
243
 
212
244
 
213
245
 
@@ -248,6 +280,15 @@ tpl := func(ops) {
248
280
 
249
281
 
250
282
 
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
251
292
 
252
293
 
253
294
 
@@ -264,10 +305,22 @@ tpl := func(ops) {
264
305
  }
265
306
  path := pathAndState[:len(pathAndState) - 1]
266
307
  state := pathAndState[len(pathAndState) - 1]
267
- _stateRequests = append(_stateRequests, {
268
- path: path,
269
- state: state
270
- })
308
+ template := AWAIT_TEMPLATES[state]
309
+ if is_undefined(template) {
310
+ _stateRequests = append(_stateRequests, {
311
+ path: path,
312
+ state: state
313
+ })
314
+ } else {
315
+ for tPathAndState in template {
316
+ tPath := tPathAndState[:len(tPathAndState) - 1]
317
+ tState := tPathAndState[len(tPathAndState) - 1]
318
+ _stateRequests = append(_stateRequests, {
319
+ path: append(copy(path), tPath...),
320
+ state: tState
321
+ })
322
+ }
323
+ }
271
324
  },
272
325
 
273
326
 
@@ -184,6 +184,19 @@ resultUnmarshaller := func() {
184
184
 
185
185
  ops := resource.get("ops").getDataAsJson()
186
186
 
187
+
188
+
189
+
190
+
191
+ getData := func(res, fieldName) {
192
+ field := res.getField(fieldName)
193
+ if field.isSet() {
194
+ return parser(field.getValue())
195
+ } else {
196
+ return field
197
+ }
198
+ }
199
+
187
200
  if ops.first {
188
201
 
189
202
 
@@ -201,41 +214,34 @@ resultUnmarshaller := func() {
201
214
  spec: resource.get("spec").getDataAsJson()
202
215
  }
203
216
 
204
-
205
217
  if resource.hasInputField("data") {
206
-
207
-
208
- if isNR(resource.get("data")) {
209
- result.data = undefined
210
- } else {
211
- result.data = parser(resource.get("data"))
212
- }
218
+ result.data = getData(resource, "data")
213
219
  }
214
220
 
215
221
  return ll.toStrict(result)
216
222
  } else {
217
223
 
218
224
 
219
- spec := resource.get("spec").inputs()
220
- data := undefined
225
+ specs := resource.get("spec").inputs() // map of specs
226
+ datas := undefined
221
227
  if resource.hasInputField("data") {
222
- data = resource.get("data").inputs()
228
+ datas = resource.get("data") // map of datas
223
229
  }
224
230
 
225
231
  result := []
226
- for ref, s in spec {
227
- r := {
232
+ maps.forEach(specs, func(ref, s) {
233
+ r := {
228
234
  ref: json.decode(ref),
229
235
  spec: s.getValueAsJson()
230
236
  }
231
237
 
232
238
 
233
- if !is_undefined(data) {
234
- r.data = parser(data[ref].getValue())
239
+ if !is_undefined(datas) {
240
+ r.data = getData(datas, ref)
235
241
  }
236
242
 
237
243
  result = append(result, ll.toStrict(r))
238
- }
244
+ })
239
245
 
240
246
  if ops.single {
241
247
  ll.assert(len(result) == 1, "expected single element, got ", len(result))
@@ -408,6 +408,7 @@ export ll.toStrict({
408
408
  body: body,
409
409
  setPreRun: setPreRun,
410
410
  blockId: blockId,
411
+ getBlockId: getBlockId,
411
412
  validateArgs: validateArgs,
412
413
  createPBundleBuilder: createPBundleBuilder
413
414
  })
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": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",