@platforma-sdk/workflow-tengo 2.1.0 → 2.2.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.
- package/dist/tengo/lib/exec.lib.tengo +94 -4
- package/dist/tengo/lib/pframes.util.lib.tengo +6 -0
- package/dist/tengo/lib/smart.lib.tengo +68 -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 +4 -4
|
@@ -69,6 +69,7 @@ builder := func() {
|
|
|
69
69
|
assetInfos := {}
|
|
70
70
|
assetDescriptors := {}
|
|
71
71
|
assetRules := {}
|
|
72
|
+
assetCache := {}
|
|
72
73
|
|
|
73
74
|
stdout := "stdout.txt"
|
|
74
75
|
stderr := "stderr.txt"
|
|
@@ -184,7 +185,7 @@ builder := func() {
|
|
|
184
185
|
},
|
|
185
186
|
|
|
186
187
|
/**
|
|
187
|
-
*
|
|
188
|
+
* Use cacheMillis, cacheSeconds, cacheMinutes, cacheHours and cacheDays to not make hidden mistakes in cache time ranges.
|
|
188
189
|
* Sets the cache time.
|
|
189
190
|
*
|
|
190
191
|
* @param time: duration - the cache time from 'times' library.
|
|
@@ -275,10 +276,18 @@ builder := func() {
|
|
|
275
276
|
* @param pathsInArchive: string[] - paths inside the archive to be extracted into destinationDir.
|
|
276
277
|
* Empty array means 'unpack full archive'.
|
|
277
278
|
*/
|
|
278
|
-
addAsset: func(asset, destinationDir, pathsInArchive) {
|
|
279
|
+
addAsset: func(asset, destinationDir, ...pathsInArchive) {
|
|
280
|
+
if (len(pathsInArchive) == 1 && is_array(pathsInArchive[0])) {
|
|
281
|
+
// support [<paths>] single argument
|
|
282
|
+
pathsInArchive = pathsInArchive[0]
|
|
283
|
+
}
|
|
284
|
+
if len(pathsInArchive) == 0 {
|
|
285
|
+
// default for 'no paths' is to extract all
|
|
286
|
+
pathsInArchive = []
|
|
287
|
+
}
|
|
288
|
+
|
|
279
289
|
ll.assert(assets.isAssetInfo(asset),
|
|
280
290
|
"exec.builder.addAsset: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
281
|
-
|
|
282
291
|
validation.assertJsonSchema(destinationDir, "string", "exec.builder.addAsset: <destinationDir> is not a string. It must be a path inside working directory")
|
|
283
292
|
validation.assertJsonSchema(pathsInArchive, ["string"], "exec.builder.addAsset: <pathsInArchive> must contain list of strings with paths inside archive")
|
|
284
293
|
|
|
@@ -300,6 +309,86 @@ builder := func() {
|
|
|
300
309
|
return self
|
|
301
310
|
},
|
|
302
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
|
|
314
|
+
* This allows to customize cache time on per-asset basis
|
|
315
|
+
*/
|
|
316
|
+
cacheAssetMillis: func (asset, millis) {
|
|
317
|
+
ll.assert(assets.isAssetInfo(asset),
|
|
318
|
+
"exec.builder.cacheAssetMillis: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
319
|
+
ll.assert(is_int(millis),
|
|
320
|
+
"exec.builder.cacheAssetMillis: asset cache time must be a number of milliseconds.")
|
|
321
|
+
|
|
322
|
+
assetIdKey := ll.idToString(asset._id)
|
|
323
|
+
assetCache[assetIdKey] = millis * times.millisecond
|
|
324
|
+
|
|
325
|
+
return self
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
|
|
330
|
+
* This allows to customize cache time on per-asset basis
|
|
331
|
+
*/
|
|
332
|
+
cacheAssetSeconds: func (asset, seconds) {
|
|
333
|
+
ll.assert(assets.isAssetInfo(asset),
|
|
334
|
+
"exec.builder.cacheAssetSeconds: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
335
|
+
ll.assert(is_int(seconds),
|
|
336
|
+
"exec.builder.cacheAssetSeconds: asset cache time must be a number of seconds.")
|
|
337
|
+
|
|
338
|
+
assetIdKey := ll.idToString(asset._id)
|
|
339
|
+
assetCache[assetIdKey] = seconds * times.second
|
|
340
|
+
|
|
341
|
+
return self
|
|
342
|
+
},
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
|
|
346
|
+
* This allows to customize cache time on per-asset basis
|
|
347
|
+
*/
|
|
348
|
+
cacheAssetMinutes: func (asset, minutes) {
|
|
349
|
+
ll.assert(assets.isAssetInfo(asset),
|
|
350
|
+
"exec.builder.cacheAssetMinutes: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
351
|
+
ll.assert(is_int(minutes),
|
|
352
|
+
"exec.builder.cacheAssetMinutes: asset cache time must be a number of minutes.")
|
|
353
|
+
|
|
354
|
+
assetIdKey := ll.idToString(asset._id)
|
|
355
|
+
assetCache[assetIdKey] = minutes * times.minute
|
|
356
|
+
|
|
357
|
+
return self
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
|
|
362
|
+
* This allows to customize cache time on per-asset basis
|
|
363
|
+
*/
|
|
364
|
+
cacheAssetHours: func (asset, hours) {
|
|
365
|
+
ll.assert(assets.isAssetInfo(asset),
|
|
366
|
+
"exec.builder.cacheAssetHours: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
367
|
+
ll.assert(is_int(hours),
|
|
368
|
+
"exec.builder.cacheAssetHours: asset cache time must be a number of hours.")
|
|
369
|
+
|
|
370
|
+
assetIdKey := ll.idToString(asset._id)
|
|
371
|
+
assetCache[assetIdKey] = hours * times.hour
|
|
372
|
+
|
|
373
|
+
return self
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Set custom cache time for given asset. By default, cache time of 1 day is applied to all assets.
|
|
378
|
+
* This allows to customize cache time on per-asset basis
|
|
379
|
+
*/
|
|
380
|
+
cacheAssetDays: func (asset, days) {
|
|
381
|
+
ll.assert(assets.isAssetInfo(asset),
|
|
382
|
+
"exec.builder.cacheAssetHours: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
|
|
383
|
+
ll.assert(is_int(days),
|
|
384
|
+
"exec.builder.cacheAssetHours: asset cache time must be a number of days.")
|
|
385
|
+
|
|
386
|
+
assetIdKey := ll.idToString(asset._id)
|
|
387
|
+
assetCache[assetIdKey] = days * 24 * times.hour
|
|
388
|
+
|
|
389
|
+
return self
|
|
390
|
+
},
|
|
391
|
+
|
|
303
392
|
/**
|
|
304
393
|
* Adds a file to the working directory
|
|
305
394
|
*
|
|
@@ -515,7 +604,8 @@ builder := func() {
|
|
|
515
604
|
wdProcessors: wdProcessors,
|
|
516
605
|
assets: smart.createMapResource(assetInfos),
|
|
517
606
|
assetDescriptors: assetDescriptors,
|
|
518
|
-
assetRules: assetRules
|
|
607
|
+
assetRules: assetRules,
|
|
608
|
+
assetCache: assetCache
|
|
519
609
|
}
|
|
520
610
|
|
|
521
611
|
if !is_undefined(soft) {
|
|
@@ -141,6 +141,12 @@ PFCONV_IMPORT_CFG_SCHEMA := {
|
|
|
141
141
|
// Single ASCII character to be used as separator;
|
|
142
142
|
// default: ',' for .csv, '\t' for .tsv
|
|
143
143
|
`separator,omitempty`: `string`,
|
|
144
|
+
// Single ASCII character, if XSV row begins with this character - the row would be skipped;
|
|
145
|
+
// default: error is thrown if comment lines are found in document
|
|
146
|
+
`commentLinePrefix,omitempty`: `string`,
|
|
147
|
+
// Should empty lines be skipped;
|
|
148
|
+
// default: false
|
|
149
|
+
`skipEmptyLines,omitempty`: `bool`,
|
|
144
150
|
// Resolve duplicates by adding sequential suffixes to column labels;
|
|
145
151
|
// default: true
|
|
146
152
|
`allowColumnLabelDuplicates,omitempty`: `bool`,
|
|
@@ -7,6 +7,7 @@ ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
|
7
7
|
oop := import("@platforma-sdk/workflow-tengo:oop")
|
|
8
8
|
maps := import("@platforma-sdk/workflow-tengo:maps")
|
|
9
9
|
json := import("json")
|
|
10
|
+
times := import("times")
|
|
10
11
|
constants := import("@platforma-sdk/workflow-tengo:constants")
|
|
11
12
|
|
|
12
13
|
//////////////// definitions ////////////////
|
|
@@ -621,6 +622,73 @@ field = func(f) {
|
|
|
621
622
|
return self.info().Error != 0
|
|
622
623
|
},
|
|
623
624
|
|
|
625
|
+
/**
|
|
626
|
+
* Use cacheMillis, cacheSeconds, cacheMinutes, cacheHours and cacheDays to not make hidden mistakes in cache time ranges.
|
|
627
|
+
* Sets the cache time.
|
|
628
|
+
*
|
|
629
|
+
* @param time: duration - the cache time from 'times' library.
|
|
630
|
+
*/
|
|
631
|
+
setCache: func(time) {
|
|
632
|
+
ll.assert(is_int(time) && time >= times.millisecond,
|
|
633
|
+
"smart.field.setCache: cache time must be an integer >= millisecond. Did you forget to import a standard tengo library 'times'?")
|
|
634
|
+
|
|
635
|
+
tx.cacheSetToField(self.id, time)
|
|
636
|
+
return self
|
|
637
|
+
},
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Sets the cache time in milliseconds.
|
|
641
|
+
*
|
|
642
|
+
* @param millis: number
|
|
643
|
+
*/
|
|
644
|
+
setCacheMillis: func(millis) {
|
|
645
|
+
ll.assert(is_int(millis),
|
|
646
|
+
"smart.field.setCacheMillis: cache time must be a number of milliseconds")
|
|
647
|
+
return self.setCache(millis * times.millisecond)
|
|
648
|
+
},
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Sets the cache time in seconds.
|
|
652
|
+
*
|
|
653
|
+
* @param seconds: number
|
|
654
|
+
*/
|
|
655
|
+
setCacheSeconds: func(seconds) {
|
|
656
|
+
ll.assert(is_int(seconds),
|
|
657
|
+
"smart.field.setCacheSeconds: cache time must be a number of seconds")
|
|
658
|
+
return self.setCache(seconds * times.second)
|
|
659
|
+
},
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Sets the cache time in minutes.
|
|
663
|
+
*
|
|
664
|
+
* @param minutes: number
|
|
665
|
+
*/
|
|
666
|
+
setCacheMinutes: func(minutes) {
|
|
667
|
+
ll.assert(is_int(minutes),
|
|
668
|
+
"smart.field.setCacheMinutes: cache time must be a number of minutes")
|
|
669
|
+
return self.setCache(minutes * times.minute)
|
|
670
|
+
},
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Sets the cache time in hours.
|
|
674
|
+
*
|
|
675
|
+
* @param hours: number
|
|
676
|
+
*/
|
|
677
|
+
setCacheHours: func(hours) {
|
|
678
|
+
ll.assert(is_int(hours), "smart.field.setCacheHours: cache time must be a number of hours")
|
|
679
|
+
return self.setCache(hours * times.hour)
|
|
680
|
+
},
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Sets the cache time in days
|
|
684
|
+
*
|
|
685
|
+
* @param days: number
|
|
686
|
+
*/
|
|
687
|
+
setCacheDays: func(days) {
|
|
688
|
+
ll.assert(is_int(days), "smart.field.setCacheDays: cache time must be a number of days")
|
|
689
|
+
return self.setCache(days * 24 * times.hour)
|
|
690
|
+
},
|
|
691
|
+
|
|
624
692
|
/**
|
|
625
693
|
* Returns a smart.Resource object from the resolved field value
|
|
626
694
|
*/
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
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": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Tengo SDK library",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"./dist/**/*"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@milaboratories/software-pframes-conv": "2.0.
|
|
20
|
-
"@platforma-open/milaboratories.software-small-binaries": "^1.14.
|
|
19
|
+
"@milaboratories/software-pframes-conv": "2.0.4",
|
|
20
|
+
"@platforma-open/milaboratories.software-small-binaries": "^1.14.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@platforma-sdk/tengo-builder": "^1.
|
|
23
|
+
"@platforma-sdk/tengo-builder": "^1.17.3"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"type-check": "pl-tengo check",
|