@platforma-sdk/workflow-tengo 2.9.6 → 2.9.8
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 +52 -52
- package/dist/tengo/lib/assets.swinfo.lib.tengo +45 -45
- package/dist/tengo/lib/constants.lib.tengo +32 -32
- package/dist/tengo/lib/exec.R.internal.lib.tengo +29 -29
- package/dist/tengo/lib/exec.R.lib.tengo +166 -166
- package/dist/tengo/lib/exec.constants.lib.tengo +4 -4
- package/dist/tengo/lib/exec.descriptor.lib.tengo +31 -31
- package/dist/tengo/lib/exec.internal.lib.tengo +297 -297
- package/dist/tengo/lib/exec.lib.tengo +815 -815
- package/dist/tengo/lib/exec.monetization.lib.tengo +130 -130
- package/dist/tengo/lib/exec.package.lib.tengo +212 -212
- package/dist/tengo/lib/exec.python.internal.lib.tengo +6 -6
- package/dist/tengo/lib/exec.python.lib.tengo +146 -146
- package/dist/tengo/lib/exec.runcmd.lib.tengo +371 -371
- package/dist/tengo/lib/exec.runenv.lib.tengo +92 -92
- package/dist/tengo/lib/exec.stream.lib.tengo +40 -40
- package/dist/tengo/lib/file.internal.lib.tengo +77 -77
- package/dist/tengo/lib/file.lib.tengo +57 -57
- package/dist/tengo/lib/ll.lib.tengo +244 -244
- package/dist/tengo/lib/maps.lib.tengo +152 -152
- package/dist/tengo/lib/objects.lib.tengo +13 -13
- package/dist/tengo/lib/oop.lib.tengo +19 -19
- package/dist/tengo/lib/path.lib.tengo +125 -125
- package/dist/tengo/lib/pframes.constants.lib.tengo +28 -28
- package/dist/tengo/lib/pframes.export-pcolumn.lib.tengo +33 -33
- package/dist/tengo/lib/pframes.lib.tengo +43 -43
- package/dist/tengo/lib/pframes.ll.lib.tengo +72 -72
- package/dist/tengo/lib/pframes.pcolumn.lib.tengo +49 -49
- package/dist/tengo/lib/pframes.spec.lib.tengo +96 -96
- package/dist/tengo/lib/pframes.util.lib.tengo +288 -288
- package/dist/tengo/lib/pframes.xsv.lib.tengo +272 -272
- package/dist/tengo/lib/render.lib.tengo +75 -75
- package/dist/tengo/lib/sets.lib.tengo +68 -68
- package/dist/tengo/lib/slices.lib.tengo +258 -155
- package/dist/tengo/lib/smart.lib.tengo +1069 -1069
- package/dist/tengo/lib/test.lib.tengo +161 -161
- package/dist/tengo/lib/tpl.lib.tengo +515 -515
- package/dist/tengo/lib/tpl.state-await.lib.tengo +240 -240
- package/dist/tengo/lib/tpl.util.lib.tengo +9 -9
- package/dist/tengo/lib/validation.lib.tengo +378 -378
- package/dist/tengo/lib/workdir.lib.tengo +331 -331
- package/dist/tengo/lib/workdir.proc.lib.tengo +144 -144
- package/dist/tengo/lib/workdir.save.lib.tengo +130 -130
- package/dist/tengo/lib/workflow.bobject.lib.tengo +26 -26
- package/dist/tengo/lib/workflow.bquery.lib.tengo +165 -165
- package/dist/tengo/lib/workflow.constants.lib.tengo +2 -2
- package/dist/tengo/lib/workflow.context.lib.tengo +32 -32
- package/dist/tengo/lib/workflow.lib.tengo +206 -206
- 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.monetization_to_json.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 +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Gives an interface for working with workdirs.
|
|
3
|
+
*/
|
|
4
4
|
|
|
5
5
|
json := import("json")
|
|
6
6
|
|
|
@@ -17,356 +17,356 @@ validation := import("@platforma-sdk/workflow-tengo:validation")
|
|
|
17
17
|
render := import("@platforma-sdk/workflow-tengo:render")
|
|
18
18
|
|
|
19
19
|
create := func() {
|
|
20
|
-
wd := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_CREATE).lockAndBuild()
|
|
21
|
-
return wd.getField("workdir")
|
|
20
|
+
wd := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_CREATE).lockAndBuild()
|
|
21
|
+
return wd.getField("workdir")
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
_getFileFillRule := func(filePath, extension) {
|
|
25
|
-
return {
|
|
26
|
-
type: "file",
|
|
27
|
-
path: filePath,
|
|
28
|
-
permissions: 0o600,
|
|
29
|
-
pathKey: filePath,
|
|
30
|
-
blobKey: filePath,
|
|
31
|
-
copyOptional: false,
|
|
32
|
-
fileExtension: extension
|
|
33
|
-
}
|
|
25
|
+
return {
|
|
26
|
+
type: "file",
|
|
27
|
+
path: filePath,
|
|
28
|
+
permissions: 0o600,
|
|
29
|
+
pathKey: filePath,
|
|
30
|
+
blobKey: filePath,
|
|
31
|
+
copyOptional: false,
|
|
32
|
+
fileExtension: extension
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
_getArchiveFillRule := func(dstDir, whatToExtract, archiveBlobKey) {
|
|
37
|
-
extractRules := []
|
|
38
|
-
for f in whatToExtract {
|
|
39
|
-
extractRules = append(extractRules, {
|
|
40
|
-
srcPath: f,
|
|
41
|
-
dstPath: f,
|
|
42
|
-
filePerms: 0o600,
|
|
43
|
-
dirPerms: 0o700
|
|
44
|
-
})
|
|
37
|
+
extractRules := []
|
|
38
|
+
for f in whatToExtract {
|
|
39
|
+
extractRules = append(extractRules, {
|
|
40
|
+
srcPath: f,
|
|
41
|
+
dstPath: f,
|
|
42
|
+
filePerms: 0o600,
|
|
43
|
+
dirPerms: 0o700
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
type: "archive",
|
|
49
|
+
path: dstDir,
|
|
50
|
+
blobKey: archiveBlobKey,
|
|
51
|
+
archiveType: "zip",
|
|
52
|
+
extractRules: extractRules
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Generates a value fill rule for a given file path.
|
|
58
|
+
*
|
|
59
|
+
* @param filePath: string - the path of the file.
|
|
60
|
+
* @return rule: map - the value fill rule.
|
|
61
|
+
*/
|
|
62
62
|
_getValueFillRule := func(filePath) {
|
|
63
|
-
return {
|
|
64
|
-
type: "value",
|
|
65
|
-
path: filePath,
|
|
66
|
-
permissions: 0o600,
|
|
67
|
-
pathKey: filePath,
|
|
68
|
-
valueKey: filePath
|
|
63
|
+
return {
|
|
64
|
+
type: "value",
|
|
65
|
+
path: filePath,
|
|
66
|
+
permissions: 0o600,
|
|
67
|
+
pathKey: filePath,
|
|
68
|
+
valueKey: filePath
|
|
69
|
+
}
|
|
69
70
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Generates a directory fill rule for a given directory.
|
|
74
|
+
*
|
|
75
|
+
* @param dir: string - the path of the directory.
|
|
76
|
+
* @return rule: map - the directory fill rule.
|
|
77
|
+
*/
|
|
78
78
|
_getDirFillRule := func(dir) {
|
|
79
|
-
return {
|
|
80
|
-
type: "dir",
|
|
81
|
-
path: dir,
|
|
82
|
-
permissions: 0o700,
|
|
83
|
-
pathKey: ""
|
|
79
|
+
return {
|
|
80
|
+
type: "dir",
|
|
81
|
+
path: dir,
|
|
82
|
+
permissions: 0o700,
|
|
83
|
+
pathKey: ""
|
|
84
|
+
}
|
|
84
85
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Fills a workdir with files, values, and directories.
|
|
89
|
+
*
|
|
90
|
+
* @param workdir: reference - a reference to the workdir to fill.
|
|
91
|
+
* @return self: builder - a builder that adds files and directories to the workdir. */
|
|
92
92
|
_fill := func(workdir) {
|
|
93
|
-
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
94
|
-
|
|
95
|
-
wd := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_FILL)
|
|
96
|
-
wd.getField("workdirIn").set(workdir)
|
|
97
|
-
|
|
98
|
-
blobs := {}
|
|
99
|
-
files := {}
|
|
100
|
-
zipExtractions := {}
|
|
101
|
-
values := {}
|
|
102
|
-
dirs := {}
|
|
103
|
-
|
|
104
|
-
self := undefined
|
|
105
|
-
self = ll.toStrict(oop.inherit(wd, {
|
|
106
|
-
_getAllDirs: func(fileName) {
|
|
107
|
-
dirsWithFileName := path.getBasenameDirs(fileName)
|
|
108
|
-
return slices.slice(dirsWithFileName, 0, -1)
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
_addDirs: func(fileName) {
|
|
112
|
-
newDirs := self._getAllDirs(fileName)
|
|
113
|
-
sets.add(dirs, newDirs...)
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
addFromZip: func(zipResource, destinationDir, pathsInArchive) {
|
|
129
|
-
validation.assertJsonSchema(zipResource, validation.reference, "workdir.builder.addFromZip: <zipResource> is not smart.reference")
|
|
130
|
-
validation.assertJsonSchema(destinationDir, "string", "workdir.builder.addFromZip: <destinationDir> is not a string. It must be a path inside working directory")
|
|
131
|
-
|
|
132
|
-
if (is_undefined(pathsInArchive)) {
|
|
133
|
-
pathsInArchive = []
|
|
134
|
-
}
|
|
135
|
-
validation.assertJsonSchema(pathsInArchive, ["string"], "workdir.builder.addFromZip: <pathsInArchive> must contain list of strings with paths inside archive")
|
|
136
|
-
|
|
137
|
-
blobKey := ll.idToString(zipResource.id)
|
|
138
|
-
|
|
139
|
-
if is_undefined(blobs[blobKey]) {
|
|
140
|
-
blobs[blobKey] = zipResource
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if is_undefined(zipExtractions[blobKey]) {
|
|
144
|
-
zipExtractions[blobKey] = {}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if is_undefined(zipExtractions[blobKey][destinationDir]) || len(pathsInArchive) == 0 {
|
|
148
|
-
zipExtractions[blobKey][destinationDir] = pathsInArchive
|
|
149
|
-
return self
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (len(pathsInArchive) > 0) {
|
|
153
|
-
zipExtractions[blobKey][destinationDir] = append(zipExtractions[blobKey][destinationDir], pathsInArchive...)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return self
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
addFile: func(fileName, fileResource) {
|
|
166
|
-
validation.assertJsonSchema(fileName, "string")
|
|
167
|
-
validation.assertJsonSchema(fileResource, validation.reference)
|
|
168
|
-
|
|
169
|
-
files[fileName] = fileResource
|
|
170
|
-
blobs[fileName] = fileResource
|
|
171
|
-
self._addDirs(fileName)
|
|
172
|
-
|
|
173
|
-
return self
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
addFiles: func(fileMap) {
|
|
182
|
-
enum.each(fileMap, self.addFile)
|
|
183
|
-
return self
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
writeFile: func(fileName, contentRef) {
|
|
193
|
-
validation.assertJsonSchema(fileName, "string")
|
|
194
|
-
values[fileName] = contentRef
|
|
195
|
-
self._addDirs(fileName)
|
|
196
|
-
|
|
197
|
-
return self
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
writeFiles: func(contentRefMap) {
|
|
206
|
-
enum.each(contentRefMap, self.writeFile)
|
|
207
|
-
return self
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
mkDir: func(dir) {
|
|
216
|
-
sets.add(dirs, path.getBasenameDirs(dir))
|
|
217
|
-
return self
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
build: func() {
|
|
226
|
-
rules := []
|
|
227
|
-
for dir, _ in dirs {
|
|
228
|
-
rules = append(rules, _getDirFillRule(dir))
|
|
229
|
-
}
|
|
230
|
-
for fileName, _ in files {
|
|
231
|
-
rules = append(rules, _getFileFillRule(fileName, path.getExtension(fileName)))
|
|
93
|
+
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
94
|
+
|
|
95
|
+
wd := smart.ephemeralBuilder(constants.RTYPE_WORKDIR_FILL)
|
|
96
|
+
wd.getField("workdirIn").set(workdir)
|
|
97
|
+
|
|
98
|
+
blobs := {}
|
|
99
|
+
files := {}
|
|
100
|
+
zipExtractions := {}
|
|
101
|
+
values := {}
|
|
102
|
+
dirs := {}
|
|
103
|
+
|
|
104
|
+
self := undefined
|
|
105
|
+
self = ll.toStrict(oop.inherit(wd, {
|
|
106
|
+
_getAllDirs: func(fileName) {
|
|
107
|
+
dirsWithFileName := path.getBasenameDirs(fileName)
|
|
108
|
+
return slices.slice(dirsWithFileName, 0, -1)
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
_addDirs: func(fileName) {
|
|
112
|
+
newDirs := self._getAllDirs(fileName)
|
|
113
|
+
sets.add(dirs, newDirs...)
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Adds files from given zip archive into working directory.
|
|
118
|
+
*
|
|
119
|
+
* @param zipResource: smart.reference - reference to zip archive to be extracted.
|
|
120
|
+
* @param destinationDir: string - path inside working directory for files to be extracted from archive.
|
|
121
|
+
* Consider it as 'cd' before extraction. It makes all extracted files to be
|
|
122
|
+
* stored inside this directory.
|
|
123
|
+
* @param pathsInArchive: string[] - paths inside the archive to be extracted into destinationDir.
|
|
124
|
+
* Empty array means 'unpack full archive'.
|
|
125
|
+
* Full file paths are preserved during extraction: the file 'a/b/file.txt' would
|
|
126
|
+
* be extracted into '<destinationDir>/a/b/file.txt', NOT '<destinationDir>/file.txt',
|
|
127
|
+
*/
|
|
128
|
+
addFromZip: func(zipResource, destinationDir, pathsInArchive) {
|
|
129
|
+
validation.assertJsonSchema(zipResource, validation.reference, "workdir.builder.addFromZip: <zipResource> is not smart.reference")
|
|
130
|
+
validation.assertJsonSchema(destinationDir, "string", "workdir.builder.addFromZip: <destinationDir> is not a string. It must be a path inside working directory")
|
|
131
|
+
|
|
132
|
+
if (is_undefined(pathsInArchive)) {
|
|
133
|
+
pathsInArchive = []
|
|
134
|
+
}
|
|
135
|
+
validation.assertJsonSchema(pathsInArchive, ["string"], "workdir.builder.addFromZip: <pathsInArchive> must contain list of strings with paths inside archive")
|
|
136
|
+
|
|
137
|
+
blobKey := ll.idToString(zipResource.id)
|
|
138
|
+
|
|
139
|
+
if is_undefined(blobs[blobKey]) {
|
|
140
|
+
blobs[blobKey] = zipResource
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if is_undefined(zipExtractions[blobKey]) {
|
|
144
|
+
zipExtractions[blobKey] = {}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if is_undefined(zipExtractions[blobKey][destinationDir]) || len(pathsInArchive) == 0 {
|
|
148
|
+
zipExtractions[blobKey][destinationDir] = pathsInArchive
|
|
149
|
+
return self
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (len(pathsInArchive) > 0) {
|
|
153
|
+
zipExtractions[blobKey][destinationDir] = append(zipExtractions[blobKey][destinationDir], pathsInArchive...)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return self
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Adds a file to the workdir.
|
|
161
|
+
*
|
|
162
|
+
* @param fileName: string - the name of the file.
|
|
163
|
+
* @param fileResource: reference - the file to add.
|
|
164
|
+
*/
|
|
165
|
+
addFile: func(fileName, fileResource) {
|
|
166
|
+
validation.assertJsonSchema(fileName, "string")
|
|
167
|
+
validation.assertJsonSchema(fileResource, validation.reference)
|
|
168
|
+
|
|
169
|
+
files[fileName] = fileResource
|
|
170
|
+
blobs[fileName] = fileResource
|
|
171
|
+
self._addDirs(fileName)
|
|
172
|
+
|
|
173
|
+
return self
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Adds multiple files to the workdir.
|
|
178
|
+
*
|
|
179
|
+
* @param fileMap: map[string]reference - a map of files.
|
|
180
|
+
*/
|
|
181
|
+
addFiles: func(fileMap) {
|
|
182
|
+
enum.each(fileMap, self.addFile)
|
|
183
|
+
return self
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Adds a file with a content to the workdir.
|
|
188
|
+
*
|
|
189
|
+
* @param fileName: string - the name of the file.
|
|
190
|
+
* @param contentRef: reference|any - the content as a reference to add or the content itself.
|
|
191
|
+
*/
|
|
192
|
+
writeFile: func(fileName, contentRef) {
|
|
193
|
+
validation.assertJsonSchema(fileName, "string")
|
|
194
|
+
values[fileName] = contentRef
|
|
195
|
+
self._addDirs(fileName)
|
|
196
|
+
|
|
197
|
+
return self
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Adds multiple files with contents to the workdir.
|
|
202
|
+
*
|
|
203
|
+
* @param contentMap: map[string]any|reference - a map of references to a content or to a content itself.
|
|
204
|
+
*/
|
|
205
|
+
writeFiles: func(contentRefMap) {
|
|
206
|
+
enum.each(contentRefMap, self.writeFile)
|
|
207
|
+
return self
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Creates a possibly nested directory in the workdir.
|
|
212
|
+
*
|
|
213
|
+
* @param dir: string - the path of the directory.
|
|
214
|
+
*/
|
|
215
|
+
mkDir: func(dir) {
|
|
216
|
+
sets.add(dirs, path.getBasenameDirs(dir))
|
|
217
|
+
return self
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Builds the filled workdir.
|
|
222
|
+
*
|
|
223
|
+
* @return wd: reference - a reference to the filled workdir.
|
|
224
|
+
*/
|
|
225
|
+
build: func() {
|
|
226
|
+
rules := []
|
|
227
|
+
for dir, _ in dirs {
|
|
228
|
+
rules = append(rules, _getDirFillRule(dir))
|
|
229
|
+
}
|
|
230
|
+
for fileName, _ in files {
|
|
231
|
+
rules = append(rules, _getFileFillRule(fileName, path.getExtension(fileName)))
|
|
232
|
+
}
|
|
233
|
+
for fileName, _ in values {
|
|
234
|
+
rules = append(rules, _getValueFillRule(fileName))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
for blobKey, directories in zipExtractions {
|
|
238
|
+
for dstDir, whatToExtract in directories {
|
|
239
|
+
rules = append(rules, _getArchiveFillRule(dstDir, whatToExtract, blobKey))
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
rulesRes := smart.createValueResource(
|
|
244
|
+
constants.RTYPE_WORKDIR_FILL_RULES,
|
|
245
|
+
json.encode(rules)
|
|
246
|
+
)
|
|
247
|
+
self.getField("rules").set(rulesRes)
|
|
248
|
+
|
|
249
|
+
self.getField("dataIn").set(smart.createBinaryMapResource(values))
|
|
250
|
+
self.getField("blobsIn").set(smart.createBlobMapResource(blobs))
|
|
251
|
+
|
|
252
|
+
return self.lockAndBuild().outputs().workdirOut
|
|
253
|
+
}
|
|
254
|
+
}))
|
|
255
|
+
|
|
256
|
+
return self
|
|
232
257
|
}
|
|
233
|
-
for fileName, _ in values {
|
|
234
|
-
rules = append(rules, _getValueFillRule(fileName))
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
for blobKey, directories in zipExtractions {
|
|
238
|
-
for dstDir, whatToExtract in directories {
|
|
239
|
-
rules = append(rules, _getArchiveFillRule(dstDir, whatToExtract, blobKey))
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
rulesRes := smart.createValueResource(
|
|
244
|
-
constants.RTYPE_WORKDIR_FILL_RULES,
|
|
245
|
-
json.encode(rules)
|
|
246
|
-
)
|
|
247
|
-
self.getField("rules").set(rulesRes)
|
|
248
|
-
|
|
249
|
-
self.getField("dataIn").set(smart.createBinaryMapResource(values))
|
|
250
|
-
self.getField("blobsIn").set(smart.createBlobMapResource(blobs))
|
|
251
|
-
|
|
252
|
-
return self.lockAndBuild().outputs().workdirOut
|
|
253
|
-
}
|
|
254
|
-
}))
|
|
255
|
-
|
|
256
|
-
return self
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Creates and fills a workdir with files, contents, and directories. See _fill for futher documentation.
|
|
261
|
+
*
|
|
262
|
+
* @return self: builder - a builder that adds files and directories to the workdir.
|
|
263
|
+
*/
|
|
264
264
|
builder := func() {
|
|
265
|
-
return _fill(create())
|
|
265
|
+
return _fill(create())
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Saves a workdir.
|
|
270
|
+
*
|
|
271
|
+
* @param workdir: reference - a reference to the workdir to save.
|
|
272
|
+
* @return self: builder - the builder that helps adding save rules to the save workdir.
|
|
273
|
+
*/
|
|
274
274
|
save := func(workdir) {
|
|
275
|
-
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
files := {}
|
|
279
|
-
|
|
280
|
-
filesContent := {}
|
|
281
|
-
|
|
282
|
-
fileSets := {}
|
|
283
|
-
|
|
284
|
-
fileSetsContent := {}
|
|
285
|
-
|
|
286
|
-
self := undefined
|
|
287
|
-
self = ll.toStrict({
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
saveFile: func(fileName) {
|
|
294
|
-
validation.assertJsonSchema(fileName, "string")
|
|
295
|
-
sets.add(files, fileName)
|
|
296
|
-
return self
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
saveFileContent: func(fileName) {
|
|
305
|
-
validation.assertJsonSchema(fileName, "string")
|
|
306
|
-
sets.add(filesContent, fileName)
|
|
307
|
-
return self
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
saveFileSet: func(name, regex) {
|
|
317
|
-
validation.assertJsonSchema(regex, "string")
|
|
318
|
-
ll.assert(is_undefined(fileSets[name]), "file set with name '", name, "' is already in added")
|
|
319
|
-
fileSets[name] = regex
|
|
320
|
-
return self
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
saveFileSetContent: func(name, regex) {
|
|
330
|
-
validation.assertJsonSchema(regex, "string")
|
|
331
|
-
ll.assert(is_undefined(fileSetsContent[name]), "file set content with name '", name, "' is already in added")
|
|
332
|
-
sets.add(fileSetsContent, regex)
|
|
333
|
-
return self
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
build: func() {
|
|
342
|
-
|
|
343
|
-
tpl := assets.importTemplate("@platforma-sdk/workflow-tengo:workdir.save")
|
|
344
|
-
inputs := {
|
|
345
|
-
workdir: workdir,
|
|
346
|
-
files: files,
|
|
347
|
-
filesContent: filesContent,
|
|
348
|
-
fileSets: fileSets,
|
|
349
|
-
fileSetsContent: fileSetsContent
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
wds := render.createEphemeral(tpl, inputs)
|
|
353
|
-
|
|
354
|
-
return ll.toStrict({
|
|
355
|
-
files: wds.output("files"),
|
|
356
|
-
filesContent: wds.output("filesContent"),
|
|
357
|
-
fileSets : wds.output("fileSets"),
|
|
358
|
-
fileSetsContent : wds.output("fileSetsContent"),
|
|
359
|
-
workdir: wds.output("workdir"),
|
|
360
|
-
progress: wds.output("progress")
|
|
361
|
-
})
|
|
362
|
-
}
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
return self
|
|
275
|
+
ll.assert(smart.isReference(workdir), "workdir must be a reference to a resource or field")
|
|
276
|
+
|
|
277
|
+
// files to save
|
|
278
|
+
files := {}
|
|
279
|
+
// files to save their content
|
|
280
|
+
filesContent := {}
|
|
281
|
+
// file sets to save by regex
|
|
282
|
+
fileSets := {}
|
|
283
|
+
// file sets to save their content by regex
|
|
284
|
+
fileSetsContent := {}
|
|
285
|
+
|
|
286
|
+
self := undefined
|
|
287
|
+
self = ll.toStrict({
|
|
288
|
+
/**
|
|
289
|
+
* Saves a file from the workdir.
|
|
290
|
+
*
|
|
291
|
+
* @param fileName: string - the name of the file.
|
|
292
|
+
*/
|
|
293
|
+
saveFile: func(fileName) {
|
|
294
|
+
validation.assertJsonSchema(fileName, "string")
|
|
295
|
+
sets.add(files, fileName)
|
|
296
|
+
return self
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Saves a file to a value resource from the workdir.
|
|
301
|
+
*
|
|
302
|
+
* @param fileName: string - the name of the file.
|
|
303
|
+
*/
|
|
304
|
+
saveFileContent: func(fileName) {
|
|
305
|
+
validation.assertJsonSchema(fileName, "string")
|
|
306
|
+
sets.add(filesContent, fileName)
|
|
307
|
+
return self
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Save files which names satisfy given regex rule
|
|
312
|
+
*
|
|
313
|
+
* @param name: string - a name to refer this file set in the outputs
|
|
314
|
+
* @param regex: string - regex
|
|
315
|
+
*/
|
|
316
|
+
saveFileSet: func(name, regex) {
|
|
317
|
+
validation.assertJsonSchema(regex, "string")
|
|
318
|
+
ll.assert(is_undefined(fileSets[name]), "file set with name '", name, "' is already in added")
|
|
319
|
+
fileSets[name] = regex
|
|
320
|
+
return self
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Save files content which names satisfy given regex rule
|
|
325
|
+
*
|
|
326
|
+
* @param name: string - a name to refer this file set in the outputs
|
|
327
|
+
* @param regex: string - regex
|
|
328
|
+
*/
|
|
329
|
+
saveFileSetContent: func(name, regex) {
|
|
330
|
+
validation.assertJsonSchema(regex, "string")
|
|
331
|
+
ll.assert(is_undefined(fileSetsContent[name]), "file set content with name '", name, "' is already in added")
|
|
332
|
+
sets.add(fileSetsContent, regex)
|
|
333
|
+
return self
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Builds the saved workdir.
|
|
338
|
+
*
|
|
339
|
+
* @return wd: reference - the saved workdir with additional fields.
|
|
340
|
+
*/
|
|
341
|
+
build: func() {
|
|
342
|
+
|
|
343
|
+
tpl := assets.importTemplate("@platforma-sdk/workflow-tengo:workdir.save")
|
|
344
|
+
inputs := {
|
|
345
|
+
workdir: workdir,
|
|
346
|
+
files: files,
|
|
347
|
+
filesContent: filesContent,
|
|
348
|
+
fileSets: fileSets,
|
|
349
|
+
fileSetsContent: fileSetsContent
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
wds := render.createEphemeral(tpl, inputs)
|
|
353
|
+
|
|
354
|
+
return ll.toStrict({
|
|
355
|
+
files: wds.output("files"),
|
|
356
|
+
filesContent: wds.output("filesContent"),
|
|
357
|
+
fileSets : wds.output("fileSets"),
|
|
358
|
+
fileSetsContent : wds.output("fileSetsContent"),
|
|
359
|
+
workdir: wds.output("workdir"),
|
|
360
|
+
progress: wds.output("progress")
|
|
361
|
+
})
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
return self
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
export ll.toStrict({
|
|
369
|
-
builder: builder,
|
|
370
|
-
create: create,
|
|
371
|
-
save: save
|
|
369
|
+
builder: builder,
|
|
370
|
+
create: create,
|
|
371
|
+
save: save
|
|
372
372
|
})
|