@platforma-sdk/workflow-tengo 2.8.4 → 2.8.5
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.
- package/dist/tengo/lib/assets.lib.tengo +6 -0
- package/dist/tengo/lib/constants.lib.tengo +3 -0
- package/dist/tengo/lib/exec.R.lib.tengo +8 -0
- package/dist/tengo/lib/exec.internal.lib.tengo +12 -0
- package/dist/tengo/lib/exec.lib.tengo +67 -0
- package/dist/tengo/lib/exec.package.lib.tengo +9 -0
- package/dist/tengo/lib/exec.python.internal.lib.tengo +1 -0
- package/dist/tengo/lib/exec.python.lib.tengo +8 -0
- package/dist/tengo/lib/exec.runcmd.lib.tengo +19 -0
- package/dist/tengo/lib/exec.runenv.lib.tengo +4 -0
- package/dist/tengo/lib/exec.stream.lib.tengo +4 -0
- package/dist/tengo/lib/file.internal.lib.tengo +7 -0
- package/dist/tengo/lib/file.lib.tengo +3 -0
- package/dist/tengo/lib/ll.lib.tengo +24 -0
- package/dist/tengo/lib/maps.lib.tengo +8 -0
- package/dist/tengo/lib/objects.lib.tengo +2 -0
- package/dist/tengo/lib/oop.lib.tengo +3 -0
- package/dist/tengo/lib/path.lib.tengo +9 -0
- package/dist/tengo/lib/pframes.constants.lib.tengo +3 -0
- package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +5 -0
- package/dist/tengo/lib/pframes.lib.tengo +5 -0
- package/dist/tengo/lib/pframes.ll.lib.tengo +2 -0
- package/dist/tengo/lib/pframes.pcolumn.lib.tengo +4 -0
- package/dist/tengo/lib/pframes.spec.lib.tengo +26 -0
- package/dist/tengo/lib/pframes.util.lib.tengo +134 -0
- package/dist/tengo/lib/pframes.xsv.lib.tengo +12 -0
- package/dist/tengo/lib/render.lib.tengo +10 -0
- package/dist/tengo/lib/sets.lib.tengo +7 -0
- package/dist/tengo/lib/slices.lib.tengo +11 -0
- package/dist/tengo/lib/smart.lib.tengo +113 -0
- package/dist/tengo/lib/test.lib.tengo +32 -0
- package/dist/tengo/lib/tpl.lib.tengo +68 -0
- package/dist/tengo/lib/tpl.state-await.lib.tengo +14 -0
- package/dist/tengo/lib/tpl.util.lib.tengo +5 -0
- package/dist/tengo/lib/validation.lib.tengo +44 -0
- package/dist/tengo/lib/workdir.lib.tengo +22 -0
- package/dist/tengo/lib/workdir.proc.lib.tengo +18 -0
- package/dist/tengo/lib/workdir.save.lib.tengo +17 -0
- package/dist/tengo/lib/workflow.bobject.lib.tengo +5 -0
- package/dist/tengo/lib/workflow.bquery.lib.tengo +25 -0
- package/dist/tengo/lib/workflow.constants.lib.tengo +1 -0
- package/dist/tengo/lib/workflow.context.lib.tengo +5 -0
- package/dist/tengo/lib/workflow.lib.tengo +39 -0
- package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
- package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
- package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
- package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
- package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
- package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
- package/package.json +1 -1
|
@@ -8,6 +8,9 @@ smart := import("@platforma-sdk/workflow-tengo:smart")
|
|
|
8
8
|
json := import("json")
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
11
14
|
_formatKeyPath := func(current, format, key) {
|
|
12
15
|
if current == "" {
|
|
13
16
|
if !is_string(key) {
|
|
@@ -22,6 +25,7 @@ return fmt.sprintf(format, current, key)
|
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
|
|
28
|
+
|
|
25
29
|
success := { result: true }
|
|
26
30
|
|
|
27
31
|
|
|
@@ -30,6 +34,7 @@ success := { result: true }
|
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
|
|
37
|
+
|
|
33
38
|
fail := func(keyPath, msg, ...args) {
|
|
34
39
|
return {
|
|
35
40
|
result: false,
|
|
@@ -45,6 +50,7 @@ return r.result == true
|
|
|
45
50
|
|
|
46
51
|
|
|
47
52
|
|
|
53
|
+
|
|
48
54
|
isFail := func(r) {
|
|
49
55
|
return r.result == false
|
|
50
56
|
}
|
|
@@ -56,6 +62,7 @@ return r.result == false
|
|
|
56
62
|
|
|
57
63
|
|
|
58
64
|
|
|
65
|
+
|
|
59
66
|
check := func(condition, keyPath, msg, ...args) {
|
|
60
67
|
if condition {
|
|
61
68
|
return success
|
|
@@ -71,6 +78,10 @@ return fail(keyPath, msg, args...)
|
|
|
71
78
|
|
|
72
79
|
|
|
73
80
|
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
74
85
|
_validateTypes := func(js, tags, keyPath, ...stack) {
|
|
75
86
|
k := tags.key
|
|
76
87
|
|
|
@@ -119,6 +130,7 @@ return fail(keyPath, "js %q is not one of a type: %s", js, tags.key)
|
|
|
119
130
|
|
|
120
131
|
|
|
121
132
|
|
|
133
|
+
|
|
122
134
|
_parseTags := func(rule) {
|
|
123
135
|
tagsKV := text.split(rule, ",")
|
|
124
136
|
key := tagsKV[0]
|
|
@@ -148,6 +160,7 @@ tags: tags
|
|
|
148
160
|
|
|
149
161
|
|
|
150
162
|
|
|
163
|
+
|
|
151
164
|
_validateJson := func(js, schema, keyPath, ...stack) {
|
|
152
165
|
if is_undefined(schema) {
|
|
153
166
|
if len(stack) == 0 {
|
|
@@ -157,6 +170,8 @@ return fail(keyPath, "key is not defined by schema, but exists in the JSON")
|
|
|
157
170
|
return fail(keyPath, "key is not defined by schema, but exists in the JSON. Validated item: %#v", stack[0])
|
|
158
171
|
}
|
|
159
172
|
|
|
173
|
+
|
|
174
|
+
|
|
160
175
|
if is_string(schema) {
|
|
161
176
|
if schema == "any" {
|
|
162
177
|
return success
|
|
@@ -166,10 +181,16 @@ tags := _parseTags(schema)
|
|
|
166
181
|
return _validateTypes(js, tags, keyPath, stack...)
|
|
167
182
|
}
|
|
168
183
|
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
169
187
|
if is_callable(schema) {
|
|
170
188
|
return schema(js, keyPath, stack)
|
|
171
189
|
}
|
|
172
190
|
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
173
194
|
if is_array(schema) && len(schema) > 0 && schema[0] == "or" {
|
|
174
195
|
for i, elem in schema[1:] {
|
|
175
196
|
r := _validateJson(js, elem, keyPath, stack...)
|
|
@@ -181,6 +202,9 @@ return r
|
|
|
181
202
|
return fail(keyPath, "js %q does not fit any of the following rules: %q", js, schema)
|
|
182
203
|
}
|
|
183
204
|
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
184
208
|
if is_array(schema) {
|
|
185
209
|
if !is_array(js) {
|
|
186
210
|
return fail(keyPath, "js %q must be array", js)
|
|
@@ -197,12 +221,19 @@ return r
|
|
|
197
221
|
return success
|
|
198
222
|
}
|
|
199
223
|
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
200
228
|
if !ll.isMap(js) {
|
|
201
229
|
return fail(keyPath, "js %#v must be map", js)
|
|
202
230
|
}
|
|
203
231
|
|
|
232
|
+
|
|
204
233
|
schemaTags := {}
|
|
234
|
+
|
|
205
235
|
schemaRules := {}
|
|
236
|
+
|
|
206
237
|
jsFull := {}
|
|
207
238
|
|
|
208
239
|
for k, v in schema {
|
|
@@ -212,6 +243,7 @@ schemaRules[p.key] = v
|
|
|
212
243
|
jsFull[p.key] = undefined
|
|
213
244
|
}
|
|
214
245
|
|
|
246
|
+
|
|
215
247
|
any := schemaTags["any"]
|
|
216
248
|
if !is_undefined(any) {
|
|
217
249
|
if is_undefined(jsFull["any"]) { // in case actual object has field named "any"
|
|
@@ -230,6 +262,7 @@ delete(jsFull, "__options__")
|
|
|
230
262
|
}
|
|
231
263
|
}
|
|
232
264
|
|
|
265
|
+
|
|
233
266
|
for k, v in js {
|
|
234
267
|
jsFull[k] = v
|
|
235
268
|
}
|
|
@@ -251,6 +284,7 @@ return r
|
|
|
251
284
|
continue
|
|
252
285
|
}
|
|
253
286
|
|
|
287
|
+
|
|
254
288
|
key := schemaTags[_key]
|
|
255
289
|
|
|
256
290
|
if is_undefined(key) {
|
|
@@ -290,6 +324,7 @@ return success
|
|
|
290
324
|
|
|
291
325
|
|
|
292
326
|
|
|
327
|
+
|
|
293
328
|
checkJson := func(js, schema) {
|
|
294
329
|
return _validateJson(js, schema, "")
|
|
295
330
|
}
|
|
@@ -300,6 +335,7 @@ return _validateJson(js, schema, "")
|
|
|
300
335
|
|
|
301
336
|
|
|
302
337
|
|
|
338
|
+
|
|
303
339
|
isValid := func(js, schema) {
|
|
304
340
|
return _validateJson(js, schema, "").result
|
|
305
341
|
}
|
|
@@ -310,6 +346,7 @@ return _validateJson(js, schema, "").result
|
|
|
310
346
|
|
|
311
347
|
|
|
312
348
|
|
|
349
|
+
|
|
313
350
|
assertJsonSchema := func(js, schema, ...failMsg) {
|
|
314
351
|
r := _validateJson(js, schema, "")
|
|
315
352
|
|
|
@@ -328,6 +365,10 @@ ll.panic("%s: %s", msg, r.message)
|
|
|
328
365
|
|
|
329
366
|
|
|
330
367
|
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
331
372
|
resource := func(...args) {
|
|
332
373
|
|
|
333
374
|
ops := {}
|
|
@@ -368,6 +409,7 @@ return checker
|
|
|
368
409
|
|
|
369
410
|
|
|
370
411
|
|
|
412
|
+
|
|
371
413
|
resourceType := func(rt) {
|
|
372
414
|
return func(elem, keyPath, stack) {
|
|
373
415
|
return check(smart.isResource(elem) && elem.info().Type.Name == rt.Name, keyPath, "the element " + elem + " must be a resource")
|
|
@@ -379,12 +421,14 @@ return check(smart.isResource(elem) && elem.info().Type.Name == rt.Name, keyPath
|
|
|
379
421
|
|
|
380
422
|
|
|
381
423
|
|
|
424
|
+
|
|
382
425
|
reference := func(elem, keyPath, stack) {
|
|
383
426
|
return check(smart.isReference(elem), keyPath, "the element " + elem + " must be a resource or a field")
|
|
384
427
|
}
|
|
385
428
|
|
|
386
429
|
|
|
387
430
|
|
|
431
|
+
|
|
388
432
|
refSchema := {
|
|
389
433
|
blockId: `string`,
|
|
390
434
|
name: `string`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
json := import("json")
|
|
5
6
|
|
|
6
7
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
@@ -57,6 +58,7 @@ extractRules: extractRules
|
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
|
|
61
|
+
|
|
60
62
|
_getValueFillRule := func(filePath) {
|
|
61
63
|
return {
|
|
62
64
|
type: "value",
|
|
@@ -72,6 +74,7 @@ valueKey: filePath
|
|
|
72
74
|
|
|
73
75
|
|
|
74
76
|
|
|
77
|
+
|
|
75
78
|
_getDirFillRule := func(dir) {
|
|
76
79
|
return {
|
|
77
80
|
type: "dir",
|
|
@@ -85,6 +88,7 @@ pathKey: ""
|
|
|
85
88
|
|
|
86
89
|
|
|
87
90
|
|
|
91
|
+
|
|
88
92
|
_fill := func(workdir) {
|
|
89
93
|
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
90
94
|
|
|
@@ -120,6 +124,7 @@ sets.add(dirs, newDirs...)
|
|
|
120
124
|
|
|
121
125
|
|
|
122
126
|
|
|
127
|
+
|
|
123
128
|
addFromZip: func(zipResource, destinationDir, pathsInArchive) {
|
|
124
129
|
validation.assertJsonSchema(zipResource, validation.reference, "workdir.builder.addFromZip: <zipResource> is not smart.reference")
|
|
125
130
|
validation.assertJsonSchema(destinationDir, "string", "workdir.builder.addFromZip: <destinationDir> is not a string. It must be a path inside working directory")
|
|
@@ -156,6 +161,7 @@ return self
|
|
|
156
161
|
|
|
157
162
|
|
|
158
163
|
|
|
164
|
+
|
|
159
165
|
addFile: func(fileName, fileResource) {
|
|
160
166
|
validation.assertJsonSchema(fileName, "string")
|
|
161
167
|
validation.assertJsonSchema(fileResource, validation.reference)
|
|
@@ -171,6 +177,7 @@ return self
|
|
|
171
177
|
|
|
172
178
|
|
|
173
179
|
|
|
180
|
+
|
|
174
181
|
addFiles: func(fileMap) {
|
|
175
182
|
enum.each(fileMap, self.addFile)
|
|
176
183
|
return self
|
|
@@ -181,6 +188,7 @@ return self
|
|
|
181
188
|
|
|
182
189
|
|
|
183
190
|
|
|
191
|
+
|
|
184
192
|
writeFile: func(fileName, contentRef) {
|
|
185
193
|
validation.assertJsonSchema(fileName, "string")
|
|
186
194
|
values[fileName] = contentRef
|
|
@@ -193,6 +201,7 @@ return self
|
|
|
193
201
|
|
|
194
202
|
|
|
195
203
|
|
|
204
|
+
|
|
196
205
|
writeFiles: func(contentRefMap) {
|
|
197
206
|
enum.each(contentRefMap, self.writeFile)
|
|
198
207
|
return self
|
|
@@ -202,6 +211,7 @@ return self
|
|
|
202
211
|
|
|
203
212
|
|
|
204
213
|
|
|
214
|
+
|
|
205
215
|
mkDir: func(dir) {
|
|
206
216
|
sets.add(dirs, path.getBasenameDirs(dir))
|
|
207
217
|
return self
|
|
@@ -211,6 +221,7 @@ return self
|
|
|
211
221
|
|
|
212
222
|
|
|
213
223
|
|
|
224
|
+
|
|
214
225
|
build: func() {
|
|
215
226
|
rules := []
|
|
216
227
|
for dir, _ in dirs {
|
|
@@ -249,6 +260,7 @@ return self
|
|
|
249
260
|
|
|
250
261
|
|
|
251
262
|
|
|
263
|
+
|
|
252
264
|
builder := func() {
|
|
253
265
|
return _fill(create())
|
|
254
266
|
}
|
|
@@ -258,12 +270,17 @@ return _fill(create())
|
|
|
258
270
|
|
|
259
271
|
|
|
260
272
|
|
|
273
|
+
|
|
261
274
|
save := func(workdir) {
|
|
262
275
|
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
263
276
|
|
|
277
|
+
|
|
264
278
|
files := {}
|
|
279
|
+
|
|
265
280
|
filesContent := {}
|
|
281
|
+
|
|
266
282
|
fileSets := {}
|
|
283
|
+
|
|
267
284
|
fileSetsContent := {}
|
|
268
285
|
|
|
269
286
|
self := undefined
|
|
@@ -272,6 +289,7 @@ self = ll.toStrict({
|
|
|
272
289
|
|
|
273
290
|
|
|
274
291
|
|
|
292
|
+
|
|
275
293
|
saveFile: func(fileName) {
|
|
276
294
|
validation.assertJsonSchema(fileName, "string")
|
|
277
295
|
sets.add(files, fileName)
|
|
@@ -282,6 +300,7 @@ return self
|
|
|
282
300
|
|
|
283
301
|
|
|
284
302
|
|
|
303
|
+
|
|
285
304
|
saveFileContent: func(fileName) {
|
|
286
305
|
validation.assertJsonSchema(fileName, "string")
|
|
287
306
|
sets.add(filesContent, fileName)
|
|
@@ -293,6 +312,7 @@ return self
|
|
|
293
312
|
|
|
294
313
|
|
|
295
314
|
|
|
315
|
+
|
|
296
316
|
saveFileSet: func(name, regex) {
|
|
297
317
|
validation.assertJsonSchema(regex, "string")
|
|
298
318
|
ll.assert(is_undefined(fileSets[name]), "file set with name '", name, "' is already in added")
|
|
@@ -305,6 +325,7 @@ return self
|
|
|
305
325
|
|
|
306
326
|
|
|
307
327
|
|
|
328
|
+
|
|
308
329
|
saveFileSetContent: func(name, regex) {
|
|
309
330
|
validation.assertJsonSchema(regex, "string")
|
|
310
331
|
ll.assert(is_undefined(fileSetsContent[name]), "file set content with name '", name, "' is already in added")
|
|
@@ -316,6 +337,7 @@ return self
|
|
|
316
337
|
|
|
317
338
|
|
|
318
339
|
|
|
340
|
+
|
|
319
341
|
build: func() {
|
|
320
342
|
|
|
321
343
|
tpl := assets.importTemplate("@platforma-sdk/workflow-tengo:workdir.save")
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
2
3
|
tpl := import("@platforma-sdk/workflow-tengo:tpl")
|
|
3
4
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
4
5
|
wdSave := import("@platforma-sdk/workflow-tengo:workdir.save")
|
|
5
6
|
|
|
7
|
+
|
|
6
8
|
tpl.defineOutputs(["result", "workdir"])
|
|
7
9
|
|
|
8
10
|
proc := func() {
|
|
@@ -13,6 +15,7 @@ self = {
|
|
|
13
15
|
_wdBefore: undefined,
|
|
14
16
|
|
|
15
17
|
|
|
18
|
+
|
|
16
19
|
wdBefore: func() {
|
|
17
20
|
if is_undefined(self._wdBefore) {
|
|
18
21
|
self._wdBefore = tpl.inputs().workdir
|
|
@@ -23,6 +26,7 @@ return self._wdBefore
|
|
|
23
26
|
_filesInWd: undefined,
|
|
24
27
|
|
|
25
28
|
|
|
29
|
+
|
|
26
30
|
filesInWd: func() {
|
|
27
31
|
if is_undefined(self._filesInWd) {
|
|
28
32
|
self._filesInWd = self.wdBefore().getDataAsJson().files
|
|
@@ -34,14 +38,20 @@ return self._filesInWd
|
|
|
34
38
|
_wdAfterReadFiles: undefined,
|
|
35
39
|
|
|
36
40
|
|
|
41
|
+
|
|
37
42
|
wdAfterReadFiles: func() {
|
|
38
43
|
if is_undefined(self._wdAfterReadFiles) {
|
|
39
44
|
|
|
40
45
|
if !is_undefined(tpl.inputs().wdAfterReadFiles) {
|
|
41
46
|
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
42
51
|
self._wdAfterReadFiles = tpl.inputs().wdAfterReadFiles
|
|
43
52
|
} else {
|
|
44
53
|
|
|
54
|
+
|
|
45
55
|
self._wdAfterReadFiles = self.wdBefore()
|
|
46
56
|
}
|
|
47
57
|
}
|
|
@@ -55,9 +65,11 @@ return self._wdAfterReadFiles
|
|
|
55
65
|
|
|
56
66
|
|
|
57
67
|
|
|
68
|
+
|
|
58
69
|
readFiles: func(cb) {
|
|
59
70
|
tpl.prepare(func(inputs){
|
|
60
71
|
inputs.files = self.filesInWd()
|
|
72
|
+
|
|
61
73
|
files := cb(inputs)
|
|
62
74
|
|
|
63
75
|
wdBuilder := wdSave.builder(self.wdBefore())
|
|
@@ -66,6 +78,7 @@ wdBuilder.saveFileContent(fName)
|
|
|
66
78
|
}
|
|
67
79
|
wd := wdBuilder.build()
|
|
68
80
|
|
|
81
|
+
|
|
69
82
|
preps := {}
|
|
70
83
|
for key, fName in files {
|
|
71
84
|
preps[key] = wd.getSavedFileContent(fName)
|
|
@@ -80,6 +93,7 @@ return preps
|
|
|
80
93
|
_wdFinalBuilder: undefined,
|
|
81
94
|
|
|
82
95
|
|
|
96
|
+
|
|
83
97
|
wdFinalBuilder: func() {
|
|
84
98
|
if is_undefined(self._wdFinalBuilder) {
|
|
85
99
|
self._wdFinalBuilder = wdSave.builder(self.wdAfterReadFiles())
|
|
@@ -91,6 +105,7 @@ return self._wdFinalBuilder
|
|
|
91
105
|
|
|
92
106
|
|
|
93
107
|
|
|
108
|
+
|
|
94
109
|
saveFile: func(fName) {
|
|
95
110
|
self.wdFinalBuilder().saveFile(fName)
|
|
96
111
|
return self.wdFinalBuilder().getSavedFile(fName)
|
|
@@ -100,6 +115,7 @@ return self.wdFinalBuilder().getSavedFile(fName)
|
|
|
100
115
|
|
|
101
116
|
|
|
102
117
|
|
|
118
|
+
|
|
103
119
|
saveFileContent: func(fName) {
|
|
104
120
|
self.wdFinalBuilder().saveFileContent(fName)
|
|
105
121
|
return self.wdFinalBuilder().getSavedFileContent(fName)
|
|
@@ -112,6 +128,7 @@ return self.wdFinalBuilder().getSavedFileContent(fName)
|
|
|
112
128
|
|
|
113
129
|
|
|
114
130
|
|
|
131
|
+
|
|
115
132
|
body: func(cb) {
|
|
116
133
|
tpl.body(func(inputs) {
|
|
117
134
|
|
|
@@ -130,6 +147,7 @@ workdir: wd.getWorkdirAfter()
|
|
|
130
147
|
return ll.toStrict(self)
|
|
131
148
|
}
|
|
132
149
|
|
|
150
|
+
|
|
133
151
|
instance := proc()
|
|
134
152
|
|
|
135
153
|
export ll.toStrict({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
2
3
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
3
4
|
oop := import("@platforma-sdk/workflow-tengo:oop")
|
|
4
5
|
json := import("json")
|
|
@@ -19,6 +20,7 @@ _PROGRESS_FIELD := "progress"
|
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
|
|
22
24
|
getFileSaveRule := func(fileName) {
|
|
23
25
|
return {
|
|
24
26
|
blobKey: fileName,
|
|
@@ -32,6 +34,7 @@ filePath: fileName
|
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
|
|
37
|
+
|
|
35
38
|
getContentSaveRule := func(fileName) {
|
|
36
39
|
return {
|
|
37
40
|
blobKey: fileName,
|
|
@@ -42,12 +45,16 @@ contentPath: fileName
|
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
|
|
48
|
+
|
|
45
49
|
builder := func(wdBefore) {
|
|
46
50
|
|
|
47
51
|
super := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_SAVE)
|
|
52
|
+
|
|
48
53
|
super.getField(_WORKDIR_IN_FIELD).set(wdBefore)
|
|
49
54
|
|
|
55
|
+
|
|
50
56
|
fRules := {}
|
|
57
|
+
|
|
51
58
|
cRules := {}
|
|
52
59
|
|
|
53
60
|
self := undefined
|
|
@@ -58,6 +65,7 @@ self = ll.toStrict(oop.inherit(super, {
|
|
|
58
65
|
|
|
59
66
|
|
|
60
67
|
|
|
68
|
+
|
|
61
69
|
saveFile: func(fName) {
|
|
62
70
|
fRules = sets.add(fRules, fName)
|
|
63
71
|
return self
|
|
@@ -68,6 +76,7 @@ return self
|
|
|
68
76
|
|
|
69
77
|
|
|
70
78
|
|
|
79
|
+
|
|
71
80
|
saveFileContent: func(fName) {
|
|
72
81
|
cRules = sets.add(cRules, fName)
|
|
73
82
|
return self
|
|
@@ -75,42 +84,49 @@ return self
|
|
|
75
84
|
|
|
76
85
|
|
|
77
86
|
|
|
87
|
+
|
|
78
88
|
getSavedFiles: func() {
|
|
79
89
|
return self.getField(_SAVED_FILES_FIELD)
|
|
80
90
|
},
|
|
81
91
|
|
|
82
92
|
|
|
83
93
|
|
|
94
|
+
|
|
84
95
|
getSavedFilesContent: func() {
|
|
85
96
|
return self.getField(_SAVED_CONTENT_FIELD)
|
|
86
97
|
},
|
|
87
98
|
|
|
88
99
|
|
|
89
100
|
|
|
101
|
+
|
|
90
102
|
getWorkdirAfter: func() {
|
|
91
103
|
return self.getField(_WORKDIR_AFTER_FIELD)
|
|
92
104
|
},
|
|
93
105
|
|
|
94
106
|
|
|
95
107
|
|
|
108
|
+
|
|
96
109
|
getProgress: func() {
|
|
97
110
|
return self.getField(_PROGRESS_FIELD)
|
|
98
111
|
},
|
|
99
112
|
|
|
100
113
|
|
|
101
114
|
|
|
115
|
+
|
|
102
116
|
getSavedFile: func(fName) {
|
|
103
117
|
return self.getSavedFiles().getFutureInputField(fName)
|
|
104
118
|
},
|
|
105
119
|
|
|
106
120
|
|
|
107
121
|
|
|
122
|
+
|
|
108
123
|
getSavedFileContent: func(fName) {
|
|
109
124
|
return self.getSavedFilesContent().getFutureInputField(fName)
|
|
110
125
|
},
|
|
111
126
|
|
|
112
127
|
|
|
113
128
|
|
|
129
|
+
|
|
114
130
|
build: func() {
|
|
115
131
|
rules := []
|
|
116
132
|
for fName, _ in fRules {
|
|
@@ -129,6 +145,7 @@ json.encode(rules)
|
|
|
129
145
|
|
|
130
146
|
resource := super.lockAndBuild()
|
|
131
147
|
|
|
148
|
+
|
|
132
149
|
return self
|
|
133
150
|
}
|
|
134
151
|
}))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
5
6
|
constants := import("@platforma-sdk/workflow-tengo:constants")
|
|
6
7
|
json := import("json")
|
|
@@ -8,6 +9,7 @@ smart := import("@platforma-sdk/workflow-tengo:smart")
|
|
|
8
9
|
validation := import("@platforma-sdk/workflow-tengo:validation")
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
_pObjectSpecSchema := {
|
|
12
14
|
"__options__,closed": "",
|
|
13
15
|
|
|
@@ -34,10 +36,13 @@ _pObjectSpecSchema := {
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
|
|
39
|
+
|
|
37
40
|
createSpec := func(spec) {
|
|
38
41
|
ll.assert(ll.isMap(spec), "expected map got %v", spec)
|
|
39
42
|
|
|
40
43
|
|
|
44
|
+
|
|
45
|
+
|
|
41
46
|
return smart.createValueResource(constants.RTYPE_BOBJECT_SPEC, json.encode(spec))
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -6,6 +6,7 @@ json := import("json")
|
|
|
6
6
|
|
|
7
7
|
_CONTEXT_FIELD_NAME := "ctx"
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
_OPTIONS_SCHEME := {
|
|
10
11
|
"spec,?": `bool`,
|
|
11
12
|
"data,?": `bool`,
|
|
@@ -14,11 +15,17 @@ _OPTIONS_SCHEME := {
|
|
|
14
15
|
"errIfMissing,?": `bool`
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
|
|
17
19
|
_DEFAULT_OPTIONS := {
|
|
20
|
+
|
|
18
21
|
spec: true,
|
|
22
|
+
|
|
19
23
|
data: true,
|
|
24
|
+
|
|
20
25
|
single: false,
|
|
26
|
+
|
|
21
27
|
first: false,
|
|
28
|
+
|
|
22
29
|
errIfMissing: false
|
|
23
30
|
}
|
|
24
31
|
|
|
@@ -29,14 +36,18 @@ errIfMissing: false
|
|
|
29
36
|
|
|
30
37
|
|
|
31
38
|
|
|
39
|
+
|
|
32
40
|
create := func(spec, ctx, ...options) {
|
|
33
41
|
|
|
34
42
|
|
|
43
|
+
|
|
35
44
|
ops := copy(_DEFAULT_OPTIONS)
|
|
36
45
|
if len(options) > 0 {
|
|
37
46
|
ll.assert(len(options) == 1, "expected map, got array: ", options)
|
|
38
47
|
|
|
39
48
|
|
|
49
|
+
|
|
50
|
+
|
|
40
51
|
for k, v in options[0] {
|
|
41
52
|
ops[k] = v
|
|
42
53
|
}
|
|
@@ -51,6 +62,7 @@ builder := undefined
|
|
|
51
62
|
if ops.first {
|
|
52
63
|
builder = smart.ephemeralBuilder(constants.RTYPE_BRESOLVE_FIRST, query)
|
|
53
64
|
} else {
|
|
65
|
+
|
|
54
66
|
builder = smart.ephemeralBuilder(constants.RTYPE_BRESOLVE_CHOICE, query)
|
|
55
67
|
}
|
|
56
68
|
|
|
@@ -59,18 +71,23 @@ resolve := builder.lockInputsAndBuild()
|
|
|
59
71
|
|
|
60
72
|
|
|
61
73
|
|
|
74
|
+
|
|
62
75
|
rb := smart.structBuilder(constants.RTYPE_QUERY_RESULT)
|
|
63
76
|
|
|
77
|
+
|
|
64
78
|
rb.createInputField("ops").setJson(ops)
|
|
65
79
|
|
|
66
80
|
if ops.spec {
|
|
67
81
|
rb.createInputField("spec").set(resolve.getFutureOutputField("spec"))
|
|
68
82
|
}
|
|
69
83
|
|
|
84
|
+
|
|
70
85
|
if ops.data {
|
|
71
86
|
rb.createInputField("data").set(resolve.getFutureOutputField("data"))
|
|
72
87
|
}
|
|
73
88
|
|
|
89
|
+
|
|
90
|
+
|
|
74
91
|
if ops.first {
|
|
75
92
|
rb.createInputField("ref").set(resolve.getFutureOutputField("address"))
|
|
76
93
|
}
|
|
@@ -80,6 +97,7 @@ return rb.lockAndBuild()
|
|
|
80
97
|
|
|
81
98
|
|
|
82
99
|
|
|
100
|
+
|
|
83
101
|
resultUnmarshaller := func() {
|
|
84
102
|
return {
|
|
85
103
|
canParse: func(r) {
|
|
@@ -92,6 +110,8 @@ ops := resource.get("ops").getDataAsJson()
|
|
|
92
110
|
|
|
93
111
|
if ops.first {
|
|
94
112
|
|
|
113
|
+
|
|
114
|
+
|
|
95
115
|
isNR := func(r) {
|
|
96
116
|
return r.info().Type.Name == constants.RTYPE_BRESOLVE_NO_RESULT.Name
|
|
97
117
|
}
|
|
@@ -105,8 +125,10 @@ ref: resource.get("ref").getDataAsJson(),
|
|
|
105
125
|
spec: resource.get("spec").getDataAsJson()
|
|
106
126
|
}
|
|
107
127
|
|
|
128
|
+
|
|
108
129
|
if resource.hasInputField("data") {
|
|
109
130
|
|
|
131
|
+
|
|
110
132
|
if isNR(resource.get("data")) {
|
|
111
133
|
result.data = undefined
|
|
112
134
|
} else {
|
|
@@ -117,6 +139,7 @@ result.data = parser(resource.get("data"))
|
|
|
117
139
|
return ll.toStrict(result)
|
|
118
140
|
} else {
|
|
119
141
|
|
|
142
|
+
|
|
120
143
|
spec := resource.get("spec").inputs()
|
|
121
144
|
data := undefined
|
|
122
145
|
if resource.hasInputField("data") {
|
|
@@ -130,6 +153,7 @@ ref: json.decode(ref),
|
|
|
130
153
|
spec: s.getValueAsJson()
|
|
131
154
|
}
|
|
132
155
|
|
|
156
|
+
|
|
133
157
|
if !is_undefined(data) {
|
|
134
158
|
r.data = parser(data[ref].getValue())
|
|
135
159
|
}
|
|
@@ -155,6 +179,7 @@ return result
|
|
|
155
179
|
|
|
156
180
|
|
|
157
181
|
|
|
182
|
+
|
|
158
183
|
resolve := func(ref, ctx, ...options) {
|
|
159
184
|
|
|
160
185
|
spec := {
|