@platforma-sdk/workflow-tengo 2.8.1 → 2.8.2

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 (59) hide show
  1. package/dist/tengo/lib/assets.lib.tengo +76 -82
  2. package/dist/tengo/lib/constants.lib.tengo +28 -31
  3. package/dist/tengo/lib/exec.R.internal.lib.tengo +14 -14
  4. package/dist/tengo/lib/exec.R.lib.tengo +158 -167
  5. package/dist/tengo/lib/exec.internal.lib.tengo +222 -234
  6. package/dist/tengo/lib/exec.lib.tengo +647 -714
  7. package/dist/tengo/lib/exec.package.lib.tengo +229 -238
  8. package/dist/tengo/lib/exec.python.internal.lib.tengo +5 -6
  9. package/dist/tengo/lib/exec.python.lib.tengo +138 -146
  10. package/dist/tengo/lib/exec.runcmd.lib.tengo +234 -253
  11. package/dist/tengo/lib/exec.runenv.lib.tengo +88 -92
  12. package/dist/tengo/lib/exec.stream.lib.tengo +36 -40
  13. package/dist/tengo/lib/file.internal.lib.tengo +70 -77
  14. package/dist/tengo/lib/file.lib.tengo +54 -57
  15. package/dist/tengo/lib/ll.lib.tengo +217 -241
  16. package/dist/tengo/lib/maps.lib.tengo +98 -106
  17. package/dist/tengo/lib/objects.lib.tengo +11 -13
  18. package/dist/tengo/lib/oop.lib.tengo +16 -19
  19. package/dist/tengo/lib/path.lib.tengo +116 -125
  20. package/dist/tengo/lib/pframes.constants.lib.tengo +25 -28
  21. package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +28 -33
  22. package/dist/tengo/lib/pframes.lib.tengo +38 -43
  23. package/dist/tengo/lib/pframes.ll.lib.tengo +70 -73
  24. package/dist/tengo/lib/pframes.pcolumn.lib.tengo +45 -51
  25. package/dist/tengo/lib/pframes.spec.lib.tengo +70 -96
  26. package/dist/tengo/lib/pframes.util.lib.tengo +154 -289
  27. package/dist/tengo/lib/pframes.xsv.lib.tengo +260 -273
  28. package/dist/tengo/lib/render.lib.tengo +65 -76
  29. package/dist/tengo/lib/sets.lib.tengo +61 -68
  30. package/dist/tengo/lib/slices.lib.tengo +169 -180
  31. package/dist/tengo/lib/smart.lib.tengo +956 -1069
  32. package/dist/tengo/lib/test.lib.tengo +129 -161
  33. package/dist/tengo/lib/tpl.lib.tengo +448 -516
  34. package/dist/tengo/lib/tpl.state-await.lib.tengo +226 -241
  35. package/dist/tengo/lib/tpl.util.lib.tengo +4 -9
  36. package/dist/tengo/lib/validation.lib.tengo +334 -379
  37. package/dist/tengo/lib/workdir.lib.tengo +309 -332
  38. package/dist/tengo/lib/workdir.proc.lib.tengo +126 -144
  39. package/dist/tengo/lib/workdir.save.lib.tengo +113 -130
  40. package/dist/tengo/lib/workflow.bobject.lib.tengo +21 -26
  41. package/dist/tengo/lib/workflow.bquery.lib.tengo +140 -166
  42. package/dist/tengo/lib/workflow.constants.lib.tengo +1 -2
  43. package/dist/tengo/lib/workflow.context.lib.tengo +27 -32
  44. package/dist/tengo/lib/workflow.lib.tengo +167 -207
  45. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  46. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  47. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  48. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  49. package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
  50. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  51. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  52. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  53. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  54. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
  55. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  56. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  57. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  58. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  59. package/package.json +5 -5
@@ -1,6 +1,5 @@
1
- /**
2
- * A library for working with platforma packages
3
- */
1
+
2
+
4
3
 
5
4
  ll := import("@platforma-sdk/workflow-tengo:ll")
6
5
  smart := import("@platforma-sdk/workflow-tengo:smart")
@@ -11,43 +10,43 @@ validation := import("@platforma-sdk/workflow-tengo:validation")
11
10
  json := import("json")
12
11
 
13
12
  runEnvDescriptorScheme := {
14
- registry: "string",
15
- package: "string",
16
- type: "string",
17
- binDir: "string"
13
+ registry: "string",
14
+ package: "string",
15
+ type: "string",
16
+ binDir: "string"
18
17
  }
19
18
 
20
19
  binaryDescriptorScheme := {
21
- registry: "string",
22
- package: "string",
23
- cmd: ["string"],
24
- runEnv: runEnvDescriptorScheme
20
+ registry: "string",
21
+ package: "string",
22
+ cmd: ["string"],
23
+ runEnv: runEnvDescriptorScheme
25
24
  }
26
25
 
27
26
  assetDescriptorScheme := {
28
- registry: "string",
29
- package: "string",
30
- url: "string"
27
+ registry: "string",
28
+ package: "string",
29
+ url: "string"
31
30
  }
32
31
 
33
32
  localDescriptorScheme := {
34
- hash: "string",
35
- path: "string",
36
- cmd: ["string"],
37
- runEnv: runEnvDescriptorScheme
33
+ hash: "string",
34
+ path: "string",
35
+ cmd: ["string"],
36
+ runEnv: runEnvDescriptorScheme
38
37
  }
39
38
 
40
39
  descriptorScheme := {
41
- "isDev,?": "bool",
42
- "binary,?": binaryDescriptorScheme,
43
- "asset,?": assetDescriptorScheme,
44
- "local,?": localDescriptorScheme
40
+ "isDev,?": "bool",
41
+ "binary,?": binaryDescriptorScheme,
42
+ "asset,?": assetDescriptorScheme,
43
+ "local,?": localDescriptorScheme
45
44
  }
46
45
 
47
46
  softwareInfoScheme := {
48
- "name": "string",
49
- "version": "string",
50
- "descriptor": descriptorScheme
47
+ "name": "string",
48
+ "version": "string",
49
+ "descriptor": descriptorScheme
51
50
  }
52
51
 
53
52
  META_KEY_DESCRIPTOR := "ctl/runner/package/descriptor"
@@ -58,24 +57,23 @@ _INPUT_REGISTRY := "registry"
58
57
  _OUTPUT_ARCHIVE := "archive"
59
58
 
60
59
  get := func(registryName, pkgName) {
61
- res := smart.structBuilder(_RTYPE_PACKAGE_GET)
62
-
63
- res.getField(_INPUT_REGISTRY).setRefOrJson(registryName)
64
- res.getField(_INPUT_PACKAGE_NAME).setRefOrJson(pkgName)
65
-
66
- self := undefined
67
- self = oop.inherit(res, {
68
- /**
69
- * Reference to the software package archive downloaded by 'get'
70
- *
71
- * @return archive: field - output field, where info on downloaded archive will appear
72
- */
73
- archive: func() {
74
- return res.outputs()[_OUTPUT_ARCHIVE]
75
- }
76
- })
77
-
78
- return self
60
+ res := smart.structBuilder(_RTYPE_PACKAGE_GET)
61
+
62
+ res.getField(_INPUT_REGISTRY).setRefOrJson(registryName)
63
+ res.getField(_INPUT_PACKAGE_NAME).setRefOrJson(pkgName)
64
+
65
+ self := undefined
66
+ self = oop.inherit(res, {
67
+
68
+
69
+
70
+
71
+ archive: func() {
72
+ return res.outputs()[_OUTPUT_ARCHIVE]
73
+ }
74
+ })
75
+
76
+ return self
79
77
  }
80
78
 
81
79
  _RTYPE_PACKAGE_INSTALL := { Name: "PackageInstall", Version: "1" }
@@ -83,63 +81,61 @@ _INPUT_ARCHIVE := "archive"
83
81
  _OUTPUT_PACKAGE := "package"
84
82
 
85
83
  install := func(archive) {
86
- ll.assert(smart.isReference(archive),
87
- "package.install: <archive> must be reference to package archive. It is usually obtained from package.get().archive")
88
-
89
- res := smart.structBuilder(_RTYPE_PACKAGE_INSTALL)
90
-
91
- res.getField(_INPUT_ARCHIVE).set(archive)
92
-
93
- self := undefined
94
- self = oop.inherit(res, {
95
- /**
96
- * Reference to installed package
97
- *
98
- * @return package: smart.field - output field, where installed package will appear
99
- */
100
- package: func() {
101
- return res.getField(_OUTPUT_PACKAGE)
102
- }
103
- })
104
-
105
- return self
84
+ ll.assert(smart.isReference(archive),
85
+ "package.install: <archive> must be reference to package archive. It is usually obtained from package.get().archive")
86
+
87
+ res := smart.structBuilder(_RTYPE_PACKAGE_INSTALL)
88
+
89
+ res.getField(_INPUT_ARCHIVE).set(archive)
90
+
91
+ self := undefined
92
+ self = oop.inherit(res, {
93
+
94
+
95
+
96
+
97
+ package: func() {
98
+ return res.getField(_OUTPUT_PACKAGE)
99
+ }
100
+ })
101
+
102
+ return self
106
103
  }
107
104
 
108
105
  _RTYPE_PACKAGE_USE := { Name: "PackageUse", Version: "1" }
109
106
  _INPUT_PACKAGE_USE_SETTINGS := "settings"
110
107
 
111
108
  _useSettingsSchema := {
112
- hash: ["or", "bytes", "string"],
113
- path: "string",
114
- descriptor: "any",
115
- origin: {
116
- registry: "string",
117
- url: "string",
118
- packageName: "string"
119
- }
109
+ hash: ["or", "bytes", "string"],
110
+ path: "string",
111
+ descriptor: "any",
112
+ origin: {
113
+ registry: "string",
114
+ url: "string",
115
+ packageName: "string"
116
+ }
120
117
  }
121
118
 
122
119
  use := func(settings) {
123
- res := smart.structBuilder(_RTYPE_PACKAGE_USE)
124
-
125
- validation.assertJsonSchema(settings, _useSettingsSchema, "package.use(<settings>): settings have invalid format")
126
- settingsRes := smart.createJsonResource(settings)
127
-
128
- res.getField(_INPUT_PACKAGE_USE_SETTINGS).set(settingsRes)
129
-
130
- self := undefined
131
- self = oop.inherit(res, {
132
- /**
133
- * Reference to installed package
134
- *
135
- * @return package: field - output field, where installed package will appear
136
- */
137
- package: func() {
138
- return res.outputs()[_OUTPUT_PACKAGE]
139
- }
140
- })
141
-
142
- return self
120
+ res := smart.structBuilder(_RTYPE_PACKAGE_USE)
121
+
122
+ validation.assertJsonSchema(settings, _useSettingsSchema, "package.use(<settings>): settings have invalid format")
123
+ settingsRes := smart.createJsonResource(settings)
124
+
125
+ res.getField(_INPUT_PACKAGE_USE_SETTINGS).set(settingsRes)
126
+
127
+ self := undefined
128
+ self = oop.inherit(res, {
129
+
130
+
131
+
132
+
133
+ package: func() {
134
+ return res.outputs()[_OUTPUT_PACKAGE]
135
+ }
136
+ })
137
+
138
+ return self
143
139
  }
144
140
 
145
141
  _RTYPE_PACKAGE_PUT_ASSET := { Name: "PackagePutAssetsToWD", Version: "1" }
@@ -147,162 +143,157 @@ _INPUT_PACKAGE := "package"
147
143
  _INPUT_WD_IN := "workdirIn"
148
144
  _OUTPUT_WD_OUT := "workdirOut"
149
145
 
150
- /**
151
- * Load static files from software package into working directory or value resources.
152
- *
153
- * @param pkg: package - installed package (usually from package.install(<archive>))
154
- *
155
- * @return loader: pkgFileLoader - builder that provides requested files and content after load() call
156
- */
146
+
147
+
148
+
149
+
150
+
151
+
157
152
  pkgFileLoader := func(pkg) {
158
- ll.assert(smart.isReference(pkg),
159
- "package.pkgFileLoader: <pkg> must be reference to installed package. It is usually obtained from package.install().package")
160
-
161
- filePaths := []
162
- fileContentPaths := []
163
-
164
- self := undefined
165
-
166
- self = {
167
- saveFile: func(path) {
168
- validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFile: <path> must be string")
169
- filePaths = append(filePaths, path)
170
-
171
- return self
172
- },
173
-
174
- saveFiles: func(paths) {
175
- validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFiles: <paths> must be array of strings")
176
- for p in paths {
177
- self.saveFile(p)
178
- }
179
-
180
- return self
181
- },
182
-
183
- saveFileContent: func(path) {
184
- validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFileContent: <path> must be string")
185
- fileContentPaths = append(fileContentPaths, path)
186
- return self
187
- },
188
-
189
- saveFilesContent: func(paths) {
190
- validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFilesContent: <paths> must be array of strings")
191
- for p in paths {
192
- self.saveFileContent(p)
193
- }
194
-
195
- return self
196
- },
197
-
198
- load: func() {
199
- wd := workdir.create()
200
-
201
- allPaths := sets.fromSlice(filePaths)
202
- allPaths = sets.add(allPaths, fileContentPaths...)
203
-
204
- res := smart.ephemeralBuilder(_RTYPE_PACKAGE_PUT_ASSET, json.encode({
205
- paths: sets.toSlice(allPaths)
206
- }))
207
-
208
- res.getField(_INPUT_PACKAGE).set(pkg)
209
- res.getField(_INPUT_WD_IN).set(wd)
210
-
211
- wdAfter := res.getField(_OUTPUT_WD_OUT)
212
-
213
- wdSaveBuilder := workdir.save(wdAfter)
214
- for p in filePaths {
215
- wdSaveBuilder.saveFile(p)
216
- }
217
- for p in fileContentPaths {
218
- wdSaveBuilder.saveFileContent(p)
219
- }
220
- wdSave := wdSaveBuilder.build()
221
-
222
- return {
223
- files: wdSave.files,
224
- filesContent: wdSave.filesContent,
225
- progress: wdSave.progress,
226
-
227
- /**
228
- * Retrieves selected asset file by its path (use saveFile() to provide asset as file)
229
- *
230
- * @param fileName: string
231
- * @return file: smart.field - a reference to the file resource.
232
- */
233
- getFile: func(fileName) {
234
- return wdSave.files.getFutureInputField(fileName)
235
- },
236
-
237
- /**
238
- * Retrieves selected asset data by its path (use saveFileContent() to provide asset's data)
239
- *
240
- * @param fileName: string
241
- * @return file: smart.field - a reference to the file resource.
242
- */
243
- getFileContent: func(fileName) {
244
- return wdSave.filesContent.getFutureInputField(fileName)
245
- }
246
- }
247
- }
248
- }
249
-
250
- return ll.toStrict(self)
153
+ ll.assert(smart.isReference(pkg),
154
+ "package.pkgFileLoader: <pkg> must be reference to installed package. It is usually obtained from package.install().package")
155
+
156
+ filePaths := []
157
+ fileContentPaths := []
158
+
159
+ self := undefined
160
+
161
+ self = {
162
+ saveFile: func(path) {
163
+ validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFile: <path> must be string")
164
+ filePaths = append(filePaths, path)
165
+
166
+ return self
167
+ },
168
+
169
+ saveFiles: func(paths) {
170
+ validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFiles: <paths> must be array of strings")
171
+ for p in paths {
172
+ self.saveFile(p)
173
+ }
174
+
175
+ return self
176
+ },
177
+
178
+ saveFileContent: func(path) {
179
+ validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFileContent: <path> must be string")
180
+ fileContentPaths = append(fileContentPaths, path)
181
+ return self
182
+ },
183
+
184
+ saveFilesContent: func(paths) {
185
+ validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFilesContent: <paths> must be array of strings")
186
+ for p in paths {
187
+ self.saveFileContent(p)
251
188
  }
252
189
 
253
- /**
254
- * Load single asset by its path inside package, providing it as file.
255
- *
256
- * @param pkg: package - installed package (usually from package.install(<archive>))
257
- * @param assetPath: string - path to asset inside package <pkg>
258
- *
259
- * @return file: singleAsset - object with reference to the file resource and progress report
260
- */
190
+ return self
191
+ },
192
+
193
+ load: func() {
194
+ wd := workdir.create()
195
+
196
+ allPaths := sets.fromSlice(filePaths)
197
+ allPaths = sets.add(allPaths, fileContentPaths...)
198
+
199
+ res := smart.ephemeralBuilder(_RTYPE_PACKAGE_PUT_ASSET, json.encode({
200
+ paths: sets.toSlice(allPaths)
201
+ }))
202
+
203
+ res.getField(_INPUT_PACKAGE).set(pkg)
204
+ res.getField(_INPUT_WD_IN).set(wd)
205
+
206
+ wdAfter := res.getField(_OUTPUT_WD_OUT)
207
+
208
+ wdSaveBuilder := workdir.save(wdAfter)
209
+ for p in filePaths {
210
+ wdSaveBuilder.saveFile(p)
211
+ }
212
+ for p in fileContentPaths {
213
+ wdSaveBuilder.saveFileContent(p)
214
+ }
215
+ wdSave := wdSaveBuilder.build()
216
+
217
+ return {
218
+ files: wdSave.files,
219
+ filesContent: wdSave.filesContent,
220
+ progress: wdSave.progress,
221
+
222
+
223
+
224
+
225
+
226
+
227
+ getFile: func(fileName) {
228
+ return wdSave.files.getFutureInputField(fileName)
229
+ },
230
+
231
+
232
+
233
+
234
+
235
+
236
+ getFileContent: func(fileName) {
237
+ return wdSave.filesContent.getFutureInputField(fileName)
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ return ll.toStrict(self)
244
+ }
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
261
253
  loadPackageFile := func(pkg, assetPath) {
262
- assets := pkgFileLoader(pkg).
263
- saveFile(assetPath).
264
- load()
265
-
266
- return {
267
- file: assets.getFile(assetPath),
268
- progress: assets.progress
269
- }
254
+ assets := pkgFileLoader(pkg).
255
+ saveFile(assetPath).
256
+ load()
257
+
258
+ return {
259
+ file: assets.getFile(assetPath),
260
+ progress: assets.progress
261
+ }
270
262
  }
271
263
 
272
- /**
273
- * Load single asset by its path inside package, providing its raw content.
274
- *
275
- * @param pkg: package - installed package (usually from package.install(<archive>))
276
- * @param assetPath: string - path to asset inside package <pkg>
277
- *
278
- * @return content: singleAsset - object with reference to the asset content resource and progress report
279
- */
264
+
265
+
266
+
267
+
268
+
269
+
270
+
280
271
  loadPackageFileContent := func(pkg, assetPath) {
281
- assets := pkgFileLoader(pkg).
282
- saveFileContent(assetPath).
283
- load()
284
-
285
- return {
286
- content: assets.getFileContent(assetPath),
287
- progress: assets.progress
288
- }
272
+ assets := pkgFileLoader(pkg).
273
+ saveFileContent(assetPath).
274
+ load()
275
+
276
+ return {
277
+ content: assets.getFileContent(assetPath),
278
+ progress: assets.progress
279
+ }
289
280
  }
290
281
 
291
282
 
292
283
  export ll.toStrict({
293
- softwareInfoScheme : softwareInfoScheme,
294
- descriptorScheme : descriptorScheme,
295
- assetDescriptorScheme : assetDescriptorScheme,
296
- binaryDescriptorScheme : binaryDescriptorScheme,
297
- localDescriptorScheme : localDescriptorScheme,
298
- runEnvDescriptorScheme : runEnvDescriptorScheme,
299
-
300
- META_KEY_DESCRIPTOR : META_KEY_DESCRIPTOR,
301
-
302
- get : get,
303
- install : install,
304
- use : use,
305
- pkgFileLoader : pkgFileLoader,
306
- loadPackageFile : loadPackageFile,
307
- loadPackageFileContent : loadPackageFileContent
284
+ softwareInfoScheme : softwareInfoScheme,
285
+ descriptorScheme : descriptorScheme,
286
+ assetDescriptorScheme : assetDescriptorScheme,
287
+ binaryDescriptorScheme : binaryDescriptorScheme,
288
+ localDescriptorScheme : localDescriptorScheme,
289
+ runEnvDescriptorScheme : runEnvDescriptorScheme,
290
+
291
+ META_KEY_DESCRIPTOR : META_KEY_DESCRIPTOR,
292
+
293
+ get : get,
294
+ install : install,
295
+ use : use,
296
+ pkgFileLoader : pkgFileLoader,
297
+ loadPackageFile : loadPackageFile,
298
+ loadPackageFileContent : loadPackageFileContent
308
299
  })
@@ -3,14 +3,13 @@ validation := import("@platforma-sdk/workflow-tengo:validation")
3
3
  pkg := import("@platforma-sdk/workflow-tengo:exec.package")
4
4
 
5
5
  pythonVenvInputSchema := {
6
- toolset: "string",
7
- dependencies: {"any": validation.reference},
8
- // software: validation.reference,
6
+ toolset: "string",
7
+ dependencies: {"any": validation.reference},
9
8
 
10
- pythonDescriptor: pkg.runEnvDescriptorScheme,
11
- python: validation.reference
9
+ pythonDescriptor: pkg.runEnvDescriptorScheme,
10
+ python: validation.reference
12
11
  }
13
12
 
14
13
  export ll.toStrict({
15
- pythonVenvInputSchema : pythonVenvInputSchema
14
+ pythonVenvInputSchema : pythonVenvInputSchema
16
15
  })