@platforma-sdk/workflow-tengo 4.10.0 → 4.11.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 (38) hide show
  1. package/dist/tengo/lib/pt.expression.lib.tengo +48 -19
  2. package/dist/tengo/lib/pt.lib.tengo +25 -1
  3. package/dist/tengo/tpl/anonymize.deanonymize.plj.gz +0 -0
  4. package/dist/tengo/tpl/anonymize.impl.plj.gz +0 -0
  5. package/dist/tengo/tpl/check_network.create_workdir_from_storage.plj.gz +0 -0
  6. package/dist/tengo/tpl/check_network.download_blob.plj.gz +0 -0
  7. package/dist/tengo/tpl/check_network.run_hello_world.plj.gz +0 -0
  8. package/dist/tengo/tpl/check_network.run_hello_world_py.plj.gz +0 -0
  9. package/dist/tengo/tpl/check_network.upload_blob.plj.gz +0 -0
  10. package/dist/tengo/tpl/check_network.upload_template.plj.gz +0 -0
  11. package/dist/tengo/tpl/check_network.workdir_type_name_extractor.plj.gz +0 -0
  12. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  13. package/dist/tengo/tpl/exec.delayed-compute-allocation.impl.plj.gz +0 -0
  14. package/dist/tengo/tpl/exec.exec-impl.plj.gz +0 -0
  15. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  16. package/dist/tengo/tpl/exec.load-software.impl.plj.gz +0 -0
  17. package/dist/tengo/tpl/exec.monetization_info.plj.gz +0 -0
  18. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  19. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  20. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  21. package/dist/tengo/tpl/exec.python.venv-bin-path.plj.gz +0 -0
  22. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.export-pframe-for-ui.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  26. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  27. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  28. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  29. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  30. package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
  31. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  32. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  33. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  34. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  35. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  36. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  37. package/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
  38. package/package.json +2 -2
@@ -318,32 +318,37 @@ _newExpression = func(expression, currentAlias) {
318
318
 
319
319
 
320
320
 
321
- strSlice: func(start, ...lengthArgs) { // Primary method with optional length via varargs
322
- ll.assert(is_int(start), "start must be an integer")
323
- ll.assert(len(lengthArgs) <= 1, "strSlice expects at most one optional length argument.")
324
-
325
- exprDetails := {type: "substring", value: expression, start: start}
326
- if len(lengthArgs) == 1 {
327
- lengthVal := lengthArgs[0]
328
- ll.assert(is_int(lengthVal), "length, if provided, must be an integer")
329
- exprDetails.length = lengthVal
330
- }
331
-
332
- return _newExpression(exprDetails, undefined)
333
- },
334
-
335
321
 
336
322
 
337
323
 
338
324
 
325
+ strSlice: func(start, ...args) {
326
+ ll.assert(len(args) <= 1, "strSlice expects at most one additional argument.")
339
327
 
328
+ expr := {
329
+ type: "substring",
330
+ value: expression,
331
+ start: _mapToSingleExpressionStruct(start, "col")
332
+ }
340
333
 
341
- strSliceEnd: func(start, endIdx) { // Method with end index
342
- ll.assert(is_int(start), "start must be an integer")
343
- ll.assert(is_int(endIdx), "endIdx must be an integer")
334
+ if len(args) > 0 {
335
+ arg := args[0]
336
+ if is_map(arg) {
337
+ if arg.length != undefined && arg.end != undefined {
338
+ ll.panic("strSlice cannot have both 'length' and 'end' options.")
339
+ }
340
+ if !is_undefined(arg.length) {
341
+ expr.length = _mapToSingleExpressionStruct(arg.length, "col")
342
+ }
343
+ if !is_undefined(arg.end) {
344
+ expr.end = _mapToSingleExpressionStruct(arg.end, "col")
345
+ }
346
+ } else {
347
+ expr.length = _mapToSingleExpressionStruct(arg, "col")
348
+ }
349
+ }
344
350
 
345
- exprDetails := {type: "substring", value: expression, start: start, end: endIdx}
346
- return _newExpression(exprDetails, undefined)
351
+ return _newExpression(expr, undefined)
347
352
  },
348
353
 
349
354
 
@@ -391,6 +396,23 @@ _newExpression = func(expression, currentAlias) {
391
396
 
392
397
 
393
398
 
399
+ strReplaceAll: func(pattern, replacement, ...options) {
400
+ opts := {}
401
+ if len(options) > 0 {
402
+ opts = options[0]
403
+ }
404
+ opts.replaceAll = true
405
+ return self.strReplace(pattern, replacement, opts)
406
+ },
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
394
416
  strDistance: func(string2, metric, returnSimilarity) {
395
417
  ll.assert(_isExpression(string2), "string2 must be an expression object")
396
418
  ll.assert(is_string(metric), "metric must be a string")
@@ -571,6 +593,13 @@ _newExpression = func(expression, currentAlias) {
571
593
  partitionBy: [],
572
594
  descending: descendingVal
573
595
  }, undefined, undefined)
596
+ },
597
+
598
+
599
+
600
+
601
+ toString: func() {
602
+ return self.cast("string")
574
603
  }
575
604
  })
576
605
  return self
@@ -436,6 +436,29 @@ _newDataFrame = func(parentWorkflow, dfName) {
436
436
  return cols
437
437
  }
438
438
 
439
+ _mapExprsToStepColsAllowingStrings := func(exprs, methodName) {
440
+ ll.assert(len(exprs) > 0, methodName + " requires at least one expression argument.")
441
+ cols := []
442
+ for expr in exprs {
443
+ if is_string(expr) {
444
+
445
+ colExpr := exp.col(expr)
446
+ cols = append(cols, {
447
+ name: colExpr.getAlias(),
448
+ expression: colExpr.getExpression()
449
+ })
450
+ } else if exp._isExpression(expr) {
451
+ cols = append(cols, {
452
+ name: expr.getAlias(),
453
+ expression: expr.getExpression()
454
+ })
455
+ } else {
456
+ ll.panic("Invalid argument to " + methodName + ": Expected an expression object or string column name, got %v", expr)
457
+ }
458
+ }
459
+ return cols
460
+ }
461
+
439
462
  _addSaveStep := func(outputFile, ...options) {
440
463
  opts := {}
441
464
  if len(options) > 0 {
@@ -525,8 +548,9 @@ _newDataFrame = func(parentWorkflow, dfName) {
525
548
 
526
549
 
527
550
 
551
+
528
552
  select: func(...expressions) {
529
- stepCols := _mapExprsToStepCols(expressions, "select")
553
+ stepCols := _mapExprsToStepColsAllowingStrings(expressions, "select")
530
554
  outputDfName := parentWorkflow._newAnonymousDataFrameId()
531
555
  parentWorkflow.addRawStep({
532
556
  type: "select",
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.10.0",
3
+ "version": "4.11.0",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@milaboratories/software-pframes-conv": "2.2.2",
20
20
  "@platforma-open/milaboratories.software-small-binaries": "^1.15.21",
21
- "@platforma-open/milaboratories.software-ptabler": "1.6.0"
21
+ "@platforma-open/milaboratories.software-ptabler": "1.7.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@platforma-sdk/tengo-builder": "^2.1.12"