@platforma-sdk/workflow-tengo 4.0.1 → 4.0.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.
- package/dist/tengo/lib/maps.lib.tengo +16 -0
- package/dist/tengo/lib/pframes.bundle.lib.tengo +107 -59
- package/dist/tengo/lib/pframes.xsv-import-file.lib.tengo +8 -0
- package/dist/tengo/lib/strings.lib.tengo +26 -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.monetization_info.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/ll.get-field.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.export-pframe-for-ui.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.process-pcolumn-data.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.remove-nulls.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.slice-data.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-import-if-not-null.plj.gz +0 -0
- package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
- package/dist/tengo/tpl/waiter.waiter.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/dist/tengo/tpl/workflow.query-anchored.plj.gz +0 -0
- package/package.json +1 -1
|
@@ -20,6 +20,21 @@ getKeys := func(map) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
getValues := func(map) {
|
|
26
|
+
keys := getKeys(map)
|
|
27
|
+
res := []
|
|
28
|
+
for _, k in keys {
|
|
29
|
+
res = append(res, map[k])
|
|
30
|
+
}
|
|
31
|
+
return res
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
23
38
|
containsKey := func(map, key) {
|
|
24
39
|
for k, _ in map {
|
|
25
40
|
if key == k {
|
|
@@ -221,5 +236,6 @@ export ll.toStrict({
|
|
|
221
236
|
filterKeys : filterKeys,
|
|
222
237
|
filterKeysValues : filterKeysValues,
|
|
223
238
|
getKeys: getKeys,
|
|
239
|
+
getValues: getValues,
|
|
224
240
|
containsKey: containsKey
|
|
225
241
|
})
|
|
@@ -11,6 +11,7 @@ ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
|
11
11
|
xsv := import("@platforma-sdk/workflow-tengo:pframes.xsv")
|
|
12
12
|
assets := import("@platforma-sdk/workflow-tengo:assets")
|
|
13
13
|
render := import("@platforma-sdk/workflow-tengo:render")
|
|
14
|
+
strings := import("@platforma-sdk/workflow-tengo:strings")
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
@@ -167,11 +168,7 @@ createBuilder := func(ctx) {
|
|
|
167
168
|
return self
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
nameCleanPattern := text.re_compile("[-_,.:; \\[\\]}{\"\\\\/:]+")
|
|
171
171
|
|
|
172
|
-
cleanColumnName := func(name) {
|
|
173
|
-
return nameCleanPattern.replace(name, "_")
|
|
174
|
-
}
|
|
175
172
|
|
|
176
173
|
|
|
177
174
|
|
|
@@ -179,9 +176,43 @@ cleanColumnName := func(name) {
|
|
|
179
176
|
|
|
180
177
|
|
|
181
178
|
|
|
179
|
+
pColumnBundleUnmarshaller := func() {
|
|
182
180
|
|
|
181
|
+
processColumnId := func(id) {
|
|
182
|
+
columnKey := undefined
|
|
183
|
+
columnAxisFilters := undefined
|
|
184
|
+
serializedId := undefined
|
|
185
|
+
|
|
186
|
+
if is_string(id) {
|
|
187
|
+
serializedId = id
|
|
188
|
+
decodedId := json.decode(id)
|
|
189
|
+
|
|
190
|
+
if is_map(decodedId) && !is_undefined(decodedId.source) && !is_undefined(decodedId.axisFilters) {
|
|
191
|
+
columnKey = canonical.encode(decodedId.source)
|
|
192
|
+
columnAxisFilters = decodedId.axisFilters
|
|
193
|
+
} else {
|
|
194
|
+
columnKey = id
|
|
195
|
+
}
|
|
196
|
+
} else if is_map(id) {
|
|
197
|
+
if !is_undefined(id.source) && !is_undefined(id.axisFilters) {
|
|
198
|
+
columnKey = canonical.encode(id.source)
|
|
199
|
+
columnAxisFilters = id.axisFilters
|
|
200
|
+
serializedId = canonical.encode(id)
|
|
201
|
+
} else {
|
|
202
|
+
columnKey = canonical.encode(id)
|
|
203
|
+
serializedId = columnKey
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
ll.panic("Invalid column ID type. Expected string or object.")
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
columnKey: columnKey,
|
|
211
|
+
axisFilters: columnAxisFilters,
|
|
212
|
+
canonicalId: serializedId
|
|
213
|
+
}
|
|
214
|
+
}
|
|
183
215
|
|
|
184
|
-
pColumnBundleUnmarshaller := func() {
|
|
185
216
|
return {
|
|
186
217
|
canParse: func(resource) {
|
|
187
218
|
return smart.isResource(resource) &&
|
|
@@ -235,6 +266,33 @@ pColumnBundleUnmarshaller := func() {
|
|
|
235
266
|
|
|
236
267
|
|
|
237
268
|
|
|
269
|
+
getSpec: func(id) {
|
|
270
|
+
processedId := processColumnId(id)
|
|
271
|
+
columnKey := processedId.columnKey
|
|
272
|
+
columnAxisFilters := processedId.axisFilters // Filters from FilteredPColumnId
|
|
273
|
+
|
|
274
|
+
if is_undefined(pool[columnKey]) {
|
|
275
|
+
ll.panic("Column not found in bundle: " + columnKey)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
baseSpec := pool[columnKey].spec
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
if !is_undefined(columnAxisFilters) && len(columnAxisFilters) > 0 {
|
|
282
|
+
prepared := pSpec.prepareAxisFilters(columnAxisFilters, baseSpec)
|
|
283
|
+
return prepared.columnSpec
|
|
284
|
+
} else {
|
|
285
|
+
|
|
286
|
+
return baseSpec
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
238
296
|
setAxisHeader: func(matcher, header) {
|
|
239
297
|
if is_string(matcher) {
|
|
240
298
|
matcher = { name: matcher, domain: {} }
|
|
@@ -253,14 +311,35 @@ pColumnBundleUnmarshaller := func() {
|
|
|
253
311
|
requests := []
|
|
254
312
|
addedColumns := {}
|
|
255
313
|
|
|
314
|
+
distiller := undefined
|
|
315
|
+
|
|
316
|
+
getSpecDistiller := func() {
|
|
317
|
+
if is_undefined(distiller) {
|
|
318
|
+
columnsToDistill := []
|
|
319
|
+
for request in requests {
|
|
320
|
+
col := pool[request.key]
|
|
321
|
+
columnsToDistill = append(columnsToDistill, col.spec)
|
|
322
|
+
}
|
|
323
|
+
distiller = pSpec.createSpecDistiller(columnsToDistill)
|
|
324
|
+
}
|
|
325
|
+
return distiller
|
|
326
|
+
}
|
|
327
|
+
|
|
256
328
|
findAxisHeaderOverride := func(spec) {
|
|
257
329
|
for _, override in localAxisHeaderOverrides {
|
|
258
330
|
matcher := override[0]
|
|
259
331
|
|
|
260
332
|
if matcher.name == spec.name {
|
|
333
|
+
specDistiller := getSpecDistiller()
|
|
334
|
+
discriminativeDomains := specDistiller.getDiscriminativeDomainsSet(spec.name)
|
|
335
|
+
|
|
261
336
|
domainsMatch := true
|
|
262
337
|
|
|
263
338
|
for domainKey, domainValue in matcher.domain {
|
|
339
|
+
if is_undefined(discriminativeDomains[domainKey]) {
|
|
340
|
+
continue
|
|
341
|
+
}
|
|
342
|
+
|
|
264
343
|
if is_undefined(spec.domain) ||
|
|
265
344
|
is_undefined(spec.domain[domainKey]) ||
|
|
266
345
|
spec.domain[domainKey] != domainValue {
|
|
@@ -277,20 +356,6 @@ pColumnBundleUnmarshaller := func() {
|
|
|
277
356
|
return undefined
|
|
278
357
|
}
|
|
279
358
|
|
|
280
|
-
distiller := undefined
|
|
281
|
-
|
|
282
|
-
getSpecDistiller := func() {
|
|
283
|
-
if is_undefined(distiller) {
|
|
284
|
-
columnsToDistill := []
|
|
285
|
-
for request in requests {
|
|
286
|
-
col := pool[request.key]
|
|
287
|
-
columnsToDistill = append(columnsToDistill, col.spec)
|
|
288
|
-
}
|
|
289
|
-
distiller = pSpec.createSpecDistiller(columnsToDistill)
|
|
290
|
-
}
|
|
291
|
-
return distiller
|
|
292
|
-
}
|
|
293
|
-
|
|
294
359
|
generateLabelForAxis := func(spec) {
|
|
295
360
|
name := spec.name
|
|
296
361
|
label := undefined
|
|
@@ -302,7 +367,7 @@ pColumnBundleUnmarshaller := func() {
|
|
|
302
367
|
discriminativeDomains := specDistiller.getDiscriminativeDomains(name)
|
|
303
368
|
|
|
304
369
|
if len(discriminativeDomains) == 0 {
|
|
305
|
-
label =
|
|
370
|
+
label = strings.substituteSpecialCharacters(name)
|
|
306
371
|
} else {
|
|
307
372
|
ll.panic("Cannot deduce header for %s in axis. Discriminative domains: %s. Please provide a header override.",
|
|
308
373
|
name, discriminativeDomains)
|
|
@@ -318,39 +383,16 @@ pColumnBundleUnmarshaller := func() {
|
|
|
318
383
|
}
|
|
319
384
|
|
|
320
385
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
if is_string(id) {
|
|
327
|
-
serializedId = id
|
|
328
|
-
decodedId := json.decode(id)
|
|
329
|
-
|
|
330
|
-
if is_map(decodedId) && !is_undefined(decodedId.source) && !is_undefined(decodedId.axisFilters) {
|
|
331
|
-
columnKey = canonical.encode(decodedId.source)
|
|
332
|
-
columnAxisFilters = decodedId.axisFilters
|
|
333
|
-
} else {
|
|
334
|
-
columnKey = id
|
|
386
|
+
findRequestByItem := func(item) {
|
|
387
|
+
serializedId := processColumnId(item).canonicalId
|
|
388
|
+
for _, request in requests {
|
|
389
|
+
if request.canonicalId == serializedId {
|
|
390
|
+
return request
|
|
335
391
|
}
|
|
336
|
-
} else if is_map(id) {
|
|
337
|
-
if !is_undefined(id.source) && !is_undefined(id.axisFilters) {
|
|
338
|
-
columnKey = canonical.encode(id.source)
|
|
339
|
-
columnAxisFilters = id.axisFilters
|
|
340
|
-
serializedId = canonical.encode(id)
|
|
341
|
-
} else {
|
|
342
|
-
columnKey = canonical.encode(id)
|
|
343
|
-
serializedId = columnKey
|
|
344
|
-
}
|
|
345
|
-
} else {
|
|
346
|
-
ll.panic("Invalid column ID type. Expected string or object.")
|
|
347
392
|
}
|
|
348
393
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
axisFilters: columnAxisFilters,
|
|
352
|
-
canonicalId: serializedId
|
|
353
|
-
}
|
|
394
|
+
ll.panic("Column not found in the table: %s. Make sure to call add() first.",
|
|
395
|
+
serializedId)
|
|
354
396
|
}
|
|
355
397
|
|
|
356
398
|
tableBuilder := undefined
|
|
@@ -420,7 +462,7 @@ pColumnBundleUnmarshaller := func() {
|
|
|
420
462
|
|
|
421
463
|
addedColumns[request.canonicalId] = true
|
|
422
464
|
|
|
423
|
-
request.safeId =
|
|
465
|
+
request.safeId = strings.substituteSpecialCharacters(request.canonicalId)
|
|
424
466
|
|
|
425
467
|
if !is_undefined(request.headerOverride) {
|
|
426
468
|
request.header = request.headerOverride
|
|
@@ -519,16 +561,22 @@ pColumnBundleUnmarshaller := func() {
|
|
|
519
561
|
return generateLabelForAxis(item)
|
|
520
562
|
}
|
|
521
563
|
|
|
522
|
-
serializedId := processColumnId(item).canonicalId
|
|
523
564
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
565
|
+
request := findRequestByItem(item)
|
|
566
|
+
return request.header
|
|
567
|
+
},
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
getSpec: func(item) {
|
|
529
577
|
|
|
530
|
-
|
|
531
|
-
|
|
578
|
+
request := findRequestByItem(item)
|
|
579
|
+
return request.columnSpec
|
|
532
580
|
}
|
|
533
581
|
}
|
|
534
582
|
|
|
@@ -57,6 +57,14 @@ importFile := func(xsvFile, xsvType, spec, ...ops) {
|
|
|
57
57
|
|
|
58
58
|
validation.assertType(spec, util.PFCONV_IMPORT_CFG_SCHEMA)
|
|
59
59
|
|
|
60
|
+
|
|
61
|
+
ll.assert(
|
|
62
|
+
spec.partitionKeyLength == undefined || spec.partitionKeyLength < len(spec.axes),
|
|
63
|
+
"partitionKeyLength (%d) must be strictly less than the number of axes (%d)",
|
|
64
|
+
spec.partitionKeyLength,
|
|
65
|
+
len(spec.axes)
|
|
66
|
+
)
|
|
67
|
+
|
|
60
68
|
xsvFileName := "file." + xsvType
|
|
61
69
|
|
|
62
70
|
ops := renderOps({ dataOnly: false, splitDataAndSpec: false }, ops...)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
2
|
+
text := import("text")
|
|
3
|
+
|
|
4
|
+
specialCharactersPattern := text.re_compile("[-_,.:; +()!<>\\[\\]}{\"\\\\/:$%^#@*&]+")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
substituteSpecialCharacters := func(name, ...replacementVarargs) {
|
|
16
|
+
ll.assert(len(replacementVarargs) <= 1, "substituteSpecialCharacters: expects at most one optional replacement argument")
|
|
17
|
+
replacement := "_"
|
|
18
|
+
if len(replacementVarargs) == 1 {
|
|
19
|
+
replacement = replacementVarargs[0]
|
|
20
|
+
}
|
|
21
|
+
return specialCharactersPattern.replace(name, replacement)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export ll.toStrict({
|
|
25
|
+
substituteSpecialCharacters: substituteSpecialCharacters
|
|
26
|
+
})
|
|
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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|