@platforma-sdk/workflow-tengo 1.4.0 → 1.4.1

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.
@@ -121,14 +121,16 @@ isReference := func(f) {
121
121
  * Gets future field by given field name and field type.
122
122
  *
123
123
  * @param from: reference - whether a resource or a field we get a field from.
124
- * @param name: field name
124
+ * @param name: string - field name
125
125
  * @param fieldType: field type: input, output
126
+ * @param isEph: bool - resolve in ephemeral or pure mode
127
+ *
126
128
  * @return field: smart field
127
129
  */
128
- _getFutureField := func(from, name, fieldType) {
130
+ _getFutureField := func(from, name, fieldType, isEph) {
129
131
  ll.assert(isReference(from), "'from' must be either a resource or a field, got: %#v", from)
130
132
 
131
- futureField := tx.createFutureFieldID(fieldType, name)
133
+ futureField := tx.createFutureFieldID(fieldType, name, !isEph)
132
134
  f := field(futureField.ResourceFID)
133
135
  f.set(from)
134
136
 
@@ -427,40 +429,53 @@ resource = func(r) {
427
429
  /**
428
430
  * Get future field given field name and field type.
429
431
  *
430
- * @param name: field name
431
- * @param fieldType: field type: input, output
432
- * @return field: smart field
432
+ * @param name: string - field name
433
+ * @param fieldType: field type - input, output
434
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
435
+ * to pass deduplication before resolution.
436
+ *
437
+ * @return field: smart.field
433
438
  */
434
- getFutureField: func(name, fieldType) {
435
- return _getFutureField(strictSelf, name, fieldType)
439
+ getFutureField: func(name, fieldType, ...eph) {
440
+ isEph := true
441
+ if len(eph) > 0 {
442
+ isEph = eph[0]
443
+ }
444
+ return _getFutureField(strictSelf, name, fieldType, isEph)
436
445
  },
437
446
 
438
447
  /**
439
448
  * Get future input field given field name or a path
440
449
  *
441
- * @param nameOrPath field name or an array representing a path to be traversed
442
- * @return field: smart field
450
+ * @param nameOrPath: string|string[] - field name or an array representing a path to be traversed
451
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
452
+ * to pass deduplication before resolution.
453
+ *
454
+ * @return field: smart.field
443
455
  */
444
- getFutureInputField: func(nameOrPath) {
456
+ getFutureInputField: func(nameOrPath, ...eph) {
445
457
  if is_array(nameOrPath) {
446
458
  current := strictSelf
447
459
  for name in nameOrPath {
448
- current = current.getFutureField(name, "input")
460
+ current = current.getFutureField(name, "input", eph...)
449
461
  }
450
462
  return current
451
463
  } else {
452
- return self.getFutureField(nameOrPath, "input")
464
+ return self.getFutureField(nameOrPath, "input", eph...)
453
465
  }
454
466
  },
455
467
 
456
468
  /**
457
469
  * Get future output field given field name
458
470
  *
459
- * @param name field name
460
- * @return field: smart field
471
+ * @param name: string - field name
472
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
473
+ * to pass deduplication before resolution.
474
+ *
475
+ * @return field: smart.field
461
476
  */
462
- getFutureOutputField: func(name) {
463
- return self.getFutureField(name, "output")
477
+ getFutureOutputField: func(name, ...eph) {
478
+ return self.getFutureField(name, "output", eph...)
464
479
  },
465
480
 
466
481
  /**
@@ -687,40 +702,53 @@ field = func(f) {
687
702
  /**
688
703
  * Get future field given field name and field type.
689
704
  *
690
- * @param name: field name
705
+ * @param name: string - field name
691
706
  * @param fieldType: field type: input, output
692
- * @return field: smart field
707
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
708
+ * to pass deduplication before resolution.
709
+ *
710
+ * @return field: smart.field
693
711
  */
694
- getFutureField: func(name, fieldType) {
695
- return _getFutureField(strictSelf, name, fieldType)
712
+ getFutureField: func(name, fieldType, ...eph) {
713
+ isEph := true
714
+ if len(eph) > 0 {
715
+ isEph = eph[0]
716
+ }
717
+ return _getFutureField(strictSelf, name, fieldType, isEph)
696
718
  },
697
719
 
698
720
  /**
699
721
  * Get future input field given field name or a path
700
722
  *
701
- * @param nameOrPath field name or an array representing a path to be traversed
723
+ * @param nameOrPath: string|string[] - field name or an array representing a path to be traversed
724
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
725
+ * to pass deduplication before resolution.
726
+ *
702
727
  * @return field: smart field
703
728
  */
704
- getFutureInputField: func(nameOrPath) {
729
+ getFutureInputField: func(nameOrPath, ...eph) {
705
730
  if is_array(nameOrPath) {
706
731
  current := strictSelf
707
732
  for name in nameOrPath {
708
- current = current.getFutureField(name, "input")
733
+ current = current.getFutureField(name, "input", eph...)
709
734
  }
710
735
  return current
711
736
  } else {
712
- return self.getFutureField(nameOrPath, "input")
737
+ return self.getFutureField(nameOrPath, "input", eph...)
713
738
  }
714
739
  },
715
740
 
716
741
  /**
717
742
  * Get future output field given field name
718
743
  *
719
- * @param name field name
744
+ * @param name: string - field name
745
+ * @param eph: bool (optional) - when false, the operation becomes pure function, waiting for resource
746
+ * to pass deduplication before resolution.
747
+ *
720
748
  * @return field: smart field
721
749
  */
722
- getFutureOutputField: func(name) {
723
- return self.getFutureField(name, "output")
750
+ getFutureOutputField: func(name, ...eph) {
751
+ return self.getFutureField(name, "output", eph...)
724
752
  }
725
753
  }
726
754
 
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",