@platforma-sdk/workflow-tengo 4.2.3 → 4.3.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 (30) hide show
  1. package/dist/tengo/lib/pframes.bundle.lib.tengo +126 -20
  2. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  3. package/dist/tengo/tpl/check_network.download_blob_from_storage.plj.gz +0 -0
  4. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  5. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  6. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  7. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  8. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  9. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  10. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  11. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  12. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  13. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  14. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  15. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  16. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  17. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  18. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  19. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  20. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  21. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  22. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  26. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  27. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  28. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  29. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  30. package/package.json +1 -1
@@ -52,6 +52,14 @@ strings := import("@platforma-sdk/workflow-tengo:strings")
52
52
 
53
53
 
54
54
 
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
55
63
 
56
64
 
57
65
 
@@ -75,8 +83,8 @@ createBuilder := func(ctx) {
75
83
  ignoreMissingDomains: false
76
84
  }
77
85
 
78
- addSingleInner := func(id, ...queryKey) {
79
- ll.assert(len(queryKey) <= 1, "addSingle accepts at most one optional queryKey argument")
86
+ addSingleInner := func(id, ...ops) {
87
+ ll.assert(len(ops) <= 2, "addSingle accepts at most two optional arguments")
80
88
 
81
89
  decodedId := undefined
82
90
  if is_string(id) {
@@ -87,8 +95,31 @@ createBuilder := func(ctx) {
87
95
  ll.panic("Invalid column ID type. Expected string or object.")
88
96
  }
89
97
 
98
+ queryKey := undefined
99
+ if len(ops) > 0 {
100
+ if !is_string(ops[0]) {
101
+ ll.panic("Invalid queryKey type. Expected single string option, got ", ops[0])
102
+ }
103
+ queryKey = ops[0]
104
+ }
105
+
106
+ if len(ops) == 2 {
107
+ if !is_map(ops[1]) {
108
+ ll.panic("Invalid options type. Expected map got ", ops[1])
109
+ }
110
+ if !is_undefined(ops[1].overrides) {
111
+
112
+ decodedId = maps.deepMerge(decodedId, ops[1].overrides)
113
+ }
114
+ }
115
+
116
+ queryOpts := undefined
117
+ if len(ops) > 1 {
118
+ queryOpts = ops[1]
119
+ }
120
+
90
121
  isFiltered := is_map(decodedId) && !is_undefined(decodedId.source) && !is_undefined(decodedId.axisFilters)
91
- if isFiltered && len(queryKey) > 0 {
122
+ if isFiltered && !is_undefined(queryKey) {
92
123
  ll.panic("FilteredPColumnId cannot be used with a queryKey.")
93
124
  }
94
125
 
@@ -104,24 +135,55 @@ createBuilder := func(ctx) {
104
135
  }
105
136
 
106
137
  keyToUse := defaultKey
107
- if len(queryKey) == 1 {
108
- keyToUse = queryKey[0]
138
+ if !is_undefined(queryKey) {
139
+ keyToUse = queryKey
109
140
  }
110
141
 
111
142
  queries[keyToUse] = valueToStore
112
143
  }
113
144
 
114
- addMultiInner := func(query, ...queryKey) {
115
- ll.assert(len(queryKey) <= 1, "addMulti accepts at most one optional queryKey argument")
145
+ addMultiInner := func(query, ...ops) {
146
+ ll.assert(len(ops) <= 2, "addMulti accepts at most two optional arguments")
147
+
148
+ decodedQuery := undefined
149
+ if is_string(query) {
150
+ decodedQuery = json.decode(query)
151
+ } else if is_map(query) {
152
+ decodedQuery = query
153
+ } else {
154
+ ll.panic("Invalid query type. Expected string or object.")
155
+ }
156
+
157
+ queryKey := undefined
158
+ if len(ops) > 0 {
159
+ if !is_string(ops[0]) {
160
+ ll.panic("Invalid queryKey type. Expected single string option, got ", ops[0])
161
+ }
162
+ queryKey = ops[0]
163
+ }
164
+
165
+ if len(ops) == 2 {
166
+ if !is_map(ops[1]) {
167
+ ll.panic("Invalid options type. Expected map got ", ops[1])
168
+ }
169
+ if !is_undefined(ops[1].overrides) {
170
+
171
+
172
+ decodedQuery = maps.deepMerge(decodedQuery, ops[1].overrides)
173
+ }
174
+ }
116
175
 
176
+
177
+ decodedQuery.matchStrategy = "expectMultiple"
178
+
117
179
  keyToUse := undefined
118
- if len(queryKey) == 1 {
119
- keyToUse = queryKey[0]
180
+ if !is_undefined(queryKey) {
181
+ keyToUse = queryKey
120
182
  } else {
121
183
  keyToUse = canonical.encode(query)
122
184
  }
123
185
 
124
- queries[keyToUse] = query
186
+ queries[keyToUse] = decodedQuery
125
187
  }
126
188
 
127
189
  self := undefined
@@ -314,9 +376,24 @@ pColumnBundleUnmarshaller := func() {
314
376
 
315
377
  result := bResultUnmarshaller.parse(value.getValue(), parser)
316
378
 
317
- pool[resultKey] = {
318
- spec: result.spec,
319
- data: result.data
379
+ if is_array(result) {
380
+ arr := []
381
+ for i, r in result {
382
+ k := resultKey + string(i)
383
+ el := {
384
+ key: k,
385
+ spec: r.spec,
386
+ data: r.data
387
+ }
388
+ pool[k] = el
389
+ arr = append(arr, el)
390
+ }
391
+ pool[resultKey] = arr
392
+ } else {
393
+ pool[resultKey] = {
394
+ spec: result.spec,
395
+ data: result.data
396
+ }
320
397
  }
321
398
  }
322
399
 
@@ -325,6 +402,19 @@ pColumnBundleUnmarshaller := func() {
325
402
 
326
403
  axisHeaderOverrides := []
327
404
 
405
+ get := func(resultKey) {
406
+ if !is_string(resultKey) {
407
+ resultKey = canonical.encode(resultKey)
408
+ }
409
+
410
+ result := pool[resultKey]
411
+ if is_undefined(result) {
412
+ ll.panic("Column not found: %v. Pool: %v", resultKey, maps.getKeys(pool))
413
+ }
414
+
415
+ return result
416
+ }
417
+
328
418
  bundle := undefined
329
419
  bundle = ll.toStrict({
330
420
 
@@ -332,15 +422,26 @@ pColumnBundleUnmarshaller := func() {
332
422
 
333
423
 
334
424
 
335
- getColumn: func(resultKey) {
336
- if !is_string(resultKey) {
337
- resultKey = canonical.encode(resultKey)
425
+
426
+ getColumns: func(resultKey) {
427
+ result := get(resultKey)
428
+ if !is_array(result) {
429
+ ll.panic("Expected a multi-column result, got a single column: %v. User getColumn() instead.", resultKey)
338
430
  }
431
+ return result
432
+ },
433
+
339
434
 
340
- if is_undefined(pool[resultKey]) {
341
- ll.panic("Column not found: " + resultKey)
435
+
436
+
437
+
438
+
439
+ getColumn: func(resultKey) {
440
+ result := get(resultKey)
441
+ if is_array(result) {
442
+ ll.panic("Cannot get a single column from a multi-column result: %v. Use getColumns() instead.", resultKey)
342
443
  }
343
- return pool[resultKey]
444
+ return result
344
445
  },
345
446
 
346
447
 
@@ -358,7 +459,12 @@ pColumnBundleUnmarshaller := func() {
358
459
  ll.panic("Column not found in bundle: " + columnKey)
359
460
  }
360
461
 
361
- baseSpec := pool[columnKey].spec
462
+ result := pool[columnKey]
463
+ if is_array(result) {
464
+ ll.panic("Cannot get a single column from a multi-column result: " + columnKey + ". Use get() instead.")
465
+ }
466
+
467
+ baseSpec := result.spec
362
468
 
363
469
 
364
470
  if !is_undefined(columnAxisFilters) && len(columnAxisFilters) > 0 {
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.3",
3
+ "version": "4.3.0",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",