@platforma-sdk/workflow-tengo 2.14.0 → 2.15.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 (80) hide show
  1. package/README.md +17 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -1
  4. package/dist/index.mjs +3 -1
  5. package/dist/tengo/lib/assets.lib.tengo +28 -28
  6. package/dist/tengo/lib/assets.swinfo.lib.tengo +24 -24
  7. package/dist/tengo/lib/constants.lib.tengo +6 -3
  8. package/dist/tengo/lib/exec.R.internal.lib.tengo +2 -2
  9. package/dist/tengo/lib/exec.R.lib.tengo +41 -41
  10. package/dist/tengo/lib/exec.descriptor.lib.tengo +3 -3
  11. package/dist/tengo/lib/exec.internal.lib.tengo +41 -41
  12. package/dist/tengo/lib/exec.lib.tengo +289 -289
  13. package/dist/tengo/lib/exec.limits.lib.tengo +49 -49
  14. package/dist/tengo/lib/exec.monetization.lib.tengo +1 -1
  15. package/dist/tengo/lib/exec.monetization_internal.lib.tengo +38 -38
  16. package/dist/tengo/lib/exec.package.lib.tengo +53 -53
  17. package/dist/tengo/lib/exec.python.internal.lib.tengo +1 -1
  18. package/dist/tengo/lib/exec.python.lib.tengo +37 -37
  19. package/dist/tengo/lib/exec.runcmd.lib.tengo +138 -138
  20. package/dist/tengo/lib/exec.runenv.lib.tengo +18 -18
  21. package/dist/tengo/lib/exec.stream.lib.tengo +25 -25
  22. package/dist/tengo/lib/feats.lib.tengo +3 -3
  23. package/dist/tengo/lib/file.internal.lib.tengo +31 -31
  24. package/dist/tengo/lib/file.lib.tengo +29 -29
  25. package/dist/tengo/lib/ll.get-future-field-default.lib.tengo +137 -0
  26. package/dist/tengo/lib/ll.lib.tengo +129 -129
  27. package/dist/tengo/lib/maps.lib.tengo +38 -38
  28. package/dist/tengo/lib/objects.lib.tengo +6 -6
  29. package/dist/tengo/lib/oop.lib.tengo +11 -11
  30. package/dist/tengo/lib/path.lib.tengo +60 -60
  31. package/dist/tengo/lib/pframes.builder.lib.tengo +3 -3
  32. package/dist/tengo/lib/pframes.constants.lib.tengo +20 -20
  33. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +5 -5
  34. package/dist/tengo/lib/pframes.lib.tengo +206 -198
  35. package/dist/tengo/lib/pframes.ll.lib.tengo +59 -59
  36. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +18 -18
  37. package/dist/tengo/lib/pframes.remove-nulls.lib.tengo +36 -0
  38. package/dist/tengo/lib/pframes.spec.lib.tengo +83 -83
  39. package/dist/tengo/lib/pframes.util.lib.tengo +176 -176
  40. package/dist/tengo/lib/pframes.xsv-import-file.lib.tengo +160 -0
  41. package/dist/tengo/lib/pframes.xsv.lib.tengo +84 -167
  42. package/dist/tengo/lib/render.lib.tengo +100 -45
  43. package/dist/tengo/lib/sets.lib.tengo +44 -44
  44. package/dist/tengo/lib/slices.lib.tengo +126 -126
  45. package/dist/tengo/lib/smart.lib.tengo +654 -507
  46. package/dist/tengo/lib/test.lib.tengo +120 -120
  47. package/dist/tengo/lib/tpl.lib.tengo +206 -170
  48. package/dist/tengo/lib/tpl.state-await.lib.tengo +17 -17
  49. package/dist/tengo/lib/tpl.util.lib.tengo +5 -5
  50. package/dist/tengo/lib/units.lib.tengo +2 -2
  51. package/dist/tengo/lib/validation.lib.tengo +130 -130
  52. package/dist/tengo/lib/waiter.lib.tengo +13 -13
  53. package/dist/tengo/lib/workdir.lib.tengo +126 -126
  54. package/dist/tengo/lib/workdir.proc.lib.tengo +47 -47
  55. package/dist/tengo/lib/workdir.save.lib.tengo +53 -53
  56. package/dist/tengo/lib/workflow.bobject.lib.tengo +11 -11
  57. package/dist/tengo/lib/workflow.bquery.lib.tengo +40 -40
  58. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -1
  59. package/dist/tengo/lib/workflow.context.lib.tengo +16 -16
  60. package/dist/tengo/lib/workflow.lib.tengo +76 -76
  61. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  62. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  63. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  64. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  65. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  66. package/dist/tengo/tpl/ll.get-field.plj.gz +0 -0
  67. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  68. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  69. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  70. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  71. package/dist/tengo/tpl/pframes.process-pcolumn-data.plj.gz +0 -0
  72. package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
  73. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  74. package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
  75. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  76. package/dist/tengo/tpl/waiter.waiter.plj.gz +0 -0
  77. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  78. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  79. package/package.json +2 -2
  80. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
@@ -1,6 +1,6 @@
1
- /*
2
- * Library provides development kit for workflows
3
- */
1
+
2
+
3
+
4
4
 
5
5
  tx := import("tx")
6
6
  ll := import("@platforma-sdk/workflow-tengo:ll")
@@ -17,30 +17,30 @@ bobject := import("@platforma-sdk/workflow-tengo:workflow.bobject")
17
17
  bquery := import("@platforma-sdk/workflow-tengo:workflow.bquery")
18
18
 
19
19
 
20
- // instance of this
20
+
21
21
  self := import("@platforma-sdk/workflow-tengo:tpl")
22
22
 
23
- // renderer's output field storing a map with the results
23
+
24
24
  _RESULTS_FIELD_NAME := "result"
25
25
 
26
- // renderer's inputs map field with the context resource
26
+
27
27
  _INPUT_CONTEXT_FIELD_NAME := "context"
28
28
 
29
- // renderer's output field with the context resource
29
+
30
30
  _OUTPUT_CONTEXT_FIELD_NAME := "context"
31
31
 
32
- // a field name prefix used in the renderer's inputs map fields
33
- // that store prepared resources (aka requested in the 'prepare()' method)
32
+
33
+
34
34
  _PREPARED_INPUTS_PREFIX := "prepared/"
35
35
 
36
36
 
37
- // define outputs as we know them
38
- // this is important to unlock 'prepare' functionality
39
- // as workflow is an eph template
37
+
38
+
39
+
40
40
  self.defineOutputs([_RESULTS_FIELD_NAME, _OUTPUT_CONTEXT_FIELD_NAME])
41
41
 
42
42
  _isProduction := func() {
43
- // using low level api to avoid unnecessary unmarshalling etc
43
+
44
44
  return self.rawInputs().isProduction.getValueAsJson() == true
45
45
  }
46
46
 
@@ -48,28 +48,28 @@ _isStaging := func() {
48
48
  return !_isProduction()
49
49
  }
50
50
 
51
- // register standard inputs preprocessors [now added by default for all templates]
52
- // self.registerUnmarshaller(bquery.resultUnmarshaller())
51
+
52
+
53
53
 
54
54
  _args := undefined
55
55
 
56
- /**
57
- * Block arguments map
58
- */
56
+
57
+
58
+
59
59
  args := func() {
60
60
  if is_undefined(_args) {
61
- // template inputs
61
+
62
62
  inputs := self.inputs()
63
63
 
64
- // original args from inputs
64
+
65
65
  _args = inputs.args
66
66
  if is_undefined(_args) || smart.isReference(_args) {
67
67
  ll.panic("Unexpected args type: %v", _args)
68
68
  }
69
69
 
70
- // add all prepared 'extra' inputs to the args
70
+
71
71
  for k, v in inputs {
72
- // those extra inputs are prefixed
72
+
73
73
  if text.has_prefix(k, _PREPARED_INPUTS_PREFIX) {
74
74
 
75
75
  name := text.trim_prefix(k, _PREPARED_INPUTS_PREFIX)
@@ -85,9 +85,9 @@ args := func() {
85
85
 
86
86
  _blockId := undefined
87
87
 
88
- /**
89
- * Id of this block
90
- */
88
+
89
+
90
+
91
91
  blockId := func() {
92
92
  if _blockId == undefined {
93
93
  _blockId = self.inputs().blockId
@@ -99,9 +99,9 @@ blockId := func() {
99
99
 
100
100
  __parentContext := undefined
101
101
 
102
- /**
103
- * Parent context
104
- */
102
+
103
+
104
+
105
105
  _parentContext := func() {
106
106
  if __parentContext == undefined {
107
107
  __parentContext = self.inputs()[_INPUT_CONTEXT_FIELD_NAME]
@@ -112,9 +112,9 @@ _parentContext := func() {
112
112
  return __parentContext
113
113
  }
114
114
 
115
- /**
116
- * Utility function to build final template outputs given block results
117
- */
115
+
116
+
117
+
118
118
  _buildOutputs := func(results) {
119
119
  ll.assert(ll.isMap(results), "expected to see map result from body function")
120
120
  ll.assert(
@@ -128,30 +128,30 @@ _buildOutputs := func(results) {
128
128
  ll.assert(ll.isMap(results.outputs), "expected a map in outputs returned from workflow.body")
129
129
  ll.assert(ll.isMap(results.exports), "expected a map in exports returned from workflow.body")
130
130
 
131
- // block outputs
131
+
132
132
  o := results.outputs
133
- // block exports
133
+
134
134
  e := results.exports
135
135
 
136
- // create results map
136
+
137
137
  resBuilder := smart.mapBuilder()
138
138
  for name, value in o {
139
139
  ll.assert(!is_undefined(value), "value is undefined for output ", name)
140
140
  resBuilder.add(name, value)
141
141
  }
142
142
 
143
- // data to pass to ctx builder template
143
+
144
144
  eData := {}
145
145
  eData[constants.NO_PREFIX_EXPORT] = {}
146
146
 
147
147
  for name, value in e {
148
- // pass resource to flatten in ctx builder
148
+
149
149
  if smart.isReference(value) {
150
150
  eData[name] = value
151
151
  continue
152
152
  }
153
153
 
154
- // check that value has spec and data
154
+
155
155
  ll.assert(
156
156
  sets.fromSlice(["spec", "data"]) == sets.fromMapKeys(value),
157
157
  "expected spec and data export structure"
@@ -167,7 +167,7 @@ _buildOutputs := func(results) {
167
167
  eData[constants.NO_PREFIX_EXPORT][name + ".data"] = value.data
168
168
  }
169
169
 
170
- // create ctx and save exports
170
+
171
171
  ctxBuilder := render.createEphemeral(
172
172
  assets.importTemplate("@platforma-sdk/workflow-tengo:workflow.build-ctx"),
173
173
  {
@@ -177,7 +177,7 @@ _buildOutputs := func(results) {
177
177
  }
178
178
  )
179
179
 
180
- // final template outputs
180
+
181
181
  tplOutputs := {}
182
182
  tplOutputs[_RESULTS_FIELD_NAME] = resBuilder.build()
183
183
  tplOutputs[_OUTPUT_CONTEXT_FIELD_NAME] = ctxBuilder.output("ctx")
@@ -185,22 +185,22 @@ _buildOutputs := func(results) {
185
185
  return tplOutputs
186
186
  }
187
187
 
188
- /**
189
- * Query results pool.
190
- *
191
- * @param spec: query spec
192
- * @return result: an array of {ref: spec: data:} objects (data will be absent if not requested)
193
- */
188
+
189
+
190
+
191
+
192
+
193
+
194
194
  query := func(spec, ...options) {
195
195
  return bquery.create(spec, _parentContext(), options...)
196
196
  }
197
197
 
198
- /**
199
- * Query results pool to find spec & data for a given ref.
200
- *
201
- * @param ref: a ref object ({blockId: name:})
202
- * @return result: a {ref: spec: data:} object
203
- */
198
+
199
+
200
+
201
+
202
+
203
+
204
204
  resolve := func(ref, ...options) {
205
205
  r := bquery.resolve(ref, _parentContext(), options...)
206
206
 
@@ -211,14 +211,14 @@ resolve := func(ref, ...options) {
211
211
  }
212
212
 
213
213
 
214
- // template for prerun
214
+
215
215
  _preRunTpl := undefined
216
216
 
217
217
  _prepare := func(cb) {
218
218
  self.prepare(func(_){
219
219
  raw := cb(args())
220
220
  prefixed := {}
221
- // mark prepared inputs
221
+
222
222
  for k, v in raw {
223
223
  prefixed[_PREPARED_INPUTS_PREFIX + k] = v
224
224
  }
@@ -226,12 +226,12 @@ _prepare := func(cb) {
226
226
  })
227
227
  }
228
228
 
229
- /**
230
- * Prepare additional resources for the workflow body. The body function of the workflow will be executed only when the references will be
231
- * returned by the prepare method will ve resolved into a ready resources. The resulting resources will be passed as an input to the body function.
232
- *
233
- * @param cb: a callback function returning a map of references to be resolved
234
- */
229
+
230
+
231
+
232
+
233
+
234
+
235
235
  prepare := func(cb) {
236
236
  if !_isProduction() {
237
237
  return
@@ -239,12 +239,12 @@ prepare := func(cb) {
239
239
  _prepare(cb)
240
240
  }
241
241
 
242
- /**
243
- * Prepare additional resources for the workflow body in pre-run. The body function of the workflow will be executed only when the references will be
244
- * returned by the prepare method will ve resolved into a ready resources. The resulting resources will be passed as an input to the body function.
245
- *
246
- * @param cb: a callback function returning a map of references to be resolved
247
- */
242
+
243
+
244
+
245
+
246
+
247
+
248
248
  preparePreRun := func(cb) {
249
249
  if !_isStaging() {
250
250
  return
@@ -252,9 +252,9 @@ preparePreRun := func(cb) {
252
252
  _prepare(cb)
253
253
  }
254
254
 
255
- /**
256
- * Defines a pre run entry point for a current workflow
257
- */
255
+
256
+
257
+
258
258
  setPreRun := func(tplId) {
259
259
  ll.assert(is_undefined(_preRunTpl), "pre run template is already set")
260
260
 
@@ -262,18 +262,18 @@ setPreRun := func(tplId) {
262
262
  _preRunTpl = tplId
263
263
  }
264
264
 
265
- /**
266
- * Validate that arguments fulfil the desired schema
267
- */
265
+
266
+
267
+
268
268
  validateArgs := func(argsSchema) {
269
269
  self.validateInputs({
270
270
  args: argsSchema
271
271
  })
272
272
  }
273
273
 
274
- /**
275
- * Defines main entry point for current workflow
276
- */
274
+
275
+
276
+
277
277
  body := func(bodyFn) {
278
278
 
279
279
  if _isProduction() {
@@ -288,13 +288,13 @@ body := func(bodyFn) {
288
288
 
289
289
  } else if !is_undefined(_preRunTpl) {
290
290
 
291
- // staging; render pre-run template
291
+
292
292
 
293
293
  self.delegate(_preRunTpl, { isProduction: true }, [_RESULTS_FIELD_NAME, _OUTPUT_CONTEXT_FIELD_NAME])
294
294
 
295
295
  } else {
296
296
 
297
- // staging; pre-run template not specified; noop
297
+
298
298
 
299
299
  self.body(func(_) {
300
300
  return _buildOutputs({
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": "2.14.0",
3
+ "version": "2.15.0",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "@platforma-open/milaboratories.software-small-binaries": "^1.15.13"
21
21
  },
22
22
  "devDependencies": {
23
- "@platforma-sdk/tengo-builder": "^1.18.0"
23
+ "@platforma-sdk/tengo-builder": "^1.19.0"
24
24
  },
25
25
  "scripts": {
26
26
  "type-check": "pl-tengo check",