@platforma-sdk/workflow-tengo 2.15.16 → 2.16.0

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  declare type TemplateFromFile = { readonly type: "from-file"; readonly path: string; };
2
- declare type TplName = "ll.get-field" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "exec.R.create-renv" | "exec.python.install-deps" | "pframes.export-multiple-pcolumns" | "exec.python.create-venv" | "exec.monetization_to_json" | "exec.exec" | "exec.monetization_info" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "pframes.process-pcolumn-data" | "pframes.export-pframe";
2
+ declare type TplName = "ll.get-field" | "workflow.query-anchored" | "pframes.export-single-pcolumn" | "pframes.import-dir" | "pframes.remove-nulls" | "waiter.waiter" | "workdir.save" | "workflow.build-ctx" | "exec.R.create-renv" | "exec.python.install-deps" | "pframes.export-multiple-pcolumns" | "exec.python.create-venv" | "exec.monetization_to_json" | "exec.exec" | "exec.monetization_info" | "pframes.xsv-export-pframe" | "pframes.xsv-import-if-not-null" | "pframes.xsv-import-map" | "pframes.process-pcolumn-data" | "pframes.export-pframe";
3
3
  declare const Templates: Record<TplName, TemplateFromFile>;
4
4
  export { Templates };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = { Templates: {
2
2
  'll.get-field': { type: 'from-file', path: require.resolve('./tengo/tpl/ll.get-field.plj.gz') },
3
+ 'workflow.query-anchored': { type: 'from-file', path: require.resolve('./tengo/tpl/workflow.query-anchored.plj.gz') },
3
4
  'pframes.export-single-pcolumn': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-single-pcolumn.plj.gz') },
4
5
  'pframes.import-dir': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.import-dir.plj.gz') },
5
6
  'pframes.remove-nulls': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.remove-nulls.plj.gz') },
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { resolve } from 'node:path';
2
2
  export const Templates = {
3
3
  'll.get-field': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/ll.get-field.plj.gz') },
4
+ 'workflow.query-anchored': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/workflow.query-anchored.plj.gz') },
4
5
  'pframes.export-single-pcolumn': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-single-pcolumn.plj.gz') },
5
6
  'pframes.import-dir': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.import-dir.plj.gz') },
6
7
  'pframes.remove-nulls': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.remove-nulls.plj.gz') },
@@ -1,8 +1,14 @@
1
1
  ll := import("@platforma-sdk/workflow-tengo:ll")
2
2
  smart := import("@platforma-sdk/workflow-tengo:smart")
3
+ maps := import("@platforma-sdk/workflow-tengo:maps")
3
4
  constants := import("@platforma-sdk/workflow-tengo:constants")
4
5
  json := import("json")
6
+ assets := import("@platforma-sdk/workflow-tengo:assets")
7
+ render := import("@platforma-sdk/workflow-tengo:render")
8
+ validation := import("@platforma-sdk/workflow-tengo:validation")
9
+ model := import("@platforma-sdk/workflow-tengo:workflow.model")
5
10
 
11
+ queryAnchoredTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:workflow.query-anchored")
6
12
 
7
13
  _CONTEXT_FIELD_NAME := "ctx"
8
14
 
@@ -28,6 +34,76 @@ _DEFAULT_OPTIONS := {
28
34
 
29
35
  errIfMissing: false
30
36
  }
37
+
38
+
39
+ _QUERY_MAP_SCHEMA := {
40
+ `__options__,closed`: true,
41
+ `any`: ["or",
42
+ model.AP_COLUMN_SELECTOR_SCHEMA,
43
+ {
44
+ `__options__,closed`: true,
45
+ `query`: model.AP_COLUMN_SELECTOR_SCHEMA,
46
+ `specOnly`: `bool`
47
+ }
48
+ ]
49
+ }
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
31
107
 
32
108
 
33
109
 
@@ -199,8 +275,133 @@ resolve := func(ref, ctx, ...options) {
199
275
  return create(spec, ctx, ops)
200
276
  }
201
277
 
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+ anchoredQuery := func(ctx, anchors, queryMap) {
301
+
302
+ validation.assertType(queryMap, _QUERY_MAP_SCHEMA, "invalid query map schema")
303
+
304
+
305
+ resolvedAnchors := {}
306
+ for anchorId, anchorValue in anchors {
307
+ opts := { spec: true, data: true }
308
+
309
+ ref := anchorValue
310
+ if !is_undefined(anchorValue.ref) {
311
+ ref = anchorValue.ref
312
+ if anchorValue.specOnly {
313
+ opts.data = false
314
+ }
315
+ }
316
+
317
+ resolvedAnchors[anchorId] = resolve(ref, ctx, opts)
318
+ }
319
+
320
+
321
+ processedQueryMap := {}
322
+ for queryId, aQuery in queryMap {
323
+ query := aQuery
324
+ fetchData := true
325
+
326
+ if !is_undefined(aQuery.query) {
327
+ query = aQuery.query
328
+ if aQuery.specOnly {
329
+ fetchData = false
330
+ }
331
+ }
332
+
333
+ processedQueryMap[queryId] = {
334
+ query: query,
335
+ fetchData: fetchData
336
+ }
337
+ }
338
+
339
+
340
+ queryResult := render.createEphemeral(queryAnchoredTpl, {
341
+ ctx: ctx,
342
+ anchorSpecs: smart.createMapResource(maps.mapValues(resolvedAnchors, func(v) { return v.inputs().spec })),
343
+ queryMap: processedQueryMap
344
+ })
345
+
346
+
347
+ self := undefined
348
+ self = ll.toStrict({
349
+
350
+
351
+
352
+
353
+
354
+ getAnchor: func(anchorId) {
355
+ anchor := resolvedAnchors[anchorId]
356
+ if is_undefined(anchor) {
357
+ ll.panic("unknown anchor ID: " + anchorId)
358
+ }
359
+ return anchor
360
+ },
361
+
362
+
363
+
364
+
365
+
366
+
367
+ getResult: func(queryId) {
368
+ return queryResult.output("result/" + queryId)
369
+ },
370
+
371
+
372
+
373
+
374
+
375
+
376
+ getResultSpec: func(queryId) {
377
+ return self.getResult(queryId).getFutureInputField("spec")
378
+ },
379
+
380
+
381
+
382
+
383
+
384
+
385
+ getResultData: func(queryId) {
386
+ return self.getResult(queryId).getFutureInputField("data")
387
+ },
388
+
389
+
390
+
391
+
392
+
393
+
394
+ getResultRef: func(queryId) {
395
+ return self.getResult(queryId).getFutureInputField("ref")
396
+ }
397
+ })
398
+
399
+ return self
400
+ }
401
+
202
402
  export ll.toStrict({
203
403
  create: create,
204
404
  resolve: resolve,
205
- resultUnmarshaller: resultUnmarshaller
405
+ resultUnmarshaller: resultUnmarshaller,
406
+ anchoredQuery: anchoredQuery
206
407
  })
@@ -191,6 +191,18 @@ _buildOutputs := func(results) {
191
191
 
192
192
 
193
193
 
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+
194
206
  query := func(spec, ...options) {
195
207
  return bquery.create(spec, _parentContext(), options...)
196
208
  }
@@ -201,6 +213,16 @@ query := func(spec, ...options) {
201
213
 
202
214
 
203
215
 
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
204
226
  resolve := func(ref, ...options) {
205
227
  r := bquery.resolve(ref, _parentContext(), options...)
206
228
 
@@ -212,6 +234,30 @@ resolve := func(ref, ...options) {
212
234
 
213
235
 
214
236
 
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ anchoredQuery := func(anchors, queryMap) {
257
+ return bquery.anchoredQuery(_parentContext(), anchors, queryMap)
258
+ }
259
+
260
+
215
261
  _preRunTpl := undefined
216
262
 
217
263
  _prepare := func(cb) {
@@ -234,7 +280,7 @@ _prepare := func(cb) {
234
280
 
235
281
  prepare := func(cb) {
236
282
  if !_isProduction() {
237
- return
283
+ return
238
284
  }
239
285
  _prepare(cb)
240
286
  }
@@ -247,7 +293,7 @@ prepare := func(cb) {
247
293
 
248
294
  preparePreRun := func(cb) {
249
295
  if !_isStaging() {
250
- return
296
+ return
251
297
  }
252
298
  _prepare(cb)
253
299
  }
@@ -309,6 +355,7 @@ body := func(bodyFn) {
309
355
  export ll.toStrict({
310
356
  query: query,
311
357
  resolve: resolve,
358
+ anchoredQuery: anchoredQuery,
312
359
  prepare: prepare,
313
360
  body: body,
314
361
  setPreRun: setPreRun,
@@ -0,0 +1,71 @@
1
+ ll := import("@platforma-sdk/workflow-tengo:ll")
2
+
3
+
4
+ AXIS_SELECTOR_SCHEMA := {
5
+ `__options__,closed`: true,
6
+ `type,?`: ["or", "string", ["string"]],
7
+ `name,?`: `string`,
8
+ `domain,?`: { any: `string` }
9
+ }
10
+
11
+
12
+ ANCHOR_AXIS_REF_BY_IDX_SCHEMA := {
13
+ `__options__,closed`: true,
14
+ `anchor`: `string`,
15
+ `idx`: `number`
16
+ }
17
+
18
+ ANCHOR_AXIS_REF_BY_NAME_SCHEMA := {
19
+ `__options__,closed`: true,
20
+ `anchor`: `string`,
21
+ `name`: `string`
22
+ }
23
+
24
+ ANCHOR_AXIS_REF_BY_MATCHER_SCHEMA := {
25
+ `__options__,closed`: true,
26
+ `anchor`: `string`,
27
+ `id`: AXIS_SELECTOR_SCHEMA
28
+ }
29
+
30
+
31
+ A_AXIS_SELECTOR_SCHEMA := ["or",
32
+ AXIS_SELECTOR_SCHEMA,
33
+ ANCHOR_AXIS_REF_BY_IDX_SCHEMA,
34
+ ANCHOR_AXIS_REF_BY_NAME_SCHEMA,
35
+ ANCHOR_AXIS_REF_BY_MATCHER_SCHEMA
36
+ ]
37
+
38
+
39
+ A_DOMAIN_SCHEMA := ["or",
40
+ "string",
41
+ {
42
+ `__options__,closed`: true,
43
+ `anchor`: `string`
44
+ }
45
+ ]
46
+
47
+
48
+ AP_COLUMN_SELECTOR_SCHEMA := {
49
+ `__options__,closed`: true,
50
+ `name,?`: `string`,
51
+ `namePattern,?`: `string`,
52
+ `type,?`: ["or", "string", ["string"]],
53
+ `domainAnchor,?`: `string`,
54
+ `domain,?`: { any: A_DOMAIN_SCHEMA },
55
+ `axes,?`: [A_AXIS_SELECTOR_SCHEMA],
56
+ `partialAxesMatch,?`: `boolean`,
57
+ `annotations,?`: { any: `string` },
58
+ `annotationPatterns,?`: { any: `string` },
59
+ `matchStrategy,?`: `string,regex=expectSingle|expectMultiple|takeFirst`
60
+ }
61
+
62
+ export ll.toStrict({
63
+ AP_COLUMN_SELECTOR_SCHEMA: AP_COLUMN_SELECTOR_SCHEMA,
64
+ AXIS_SELECTOR_SCHEMA: AXIS_SELECTOR_SCHEMA,
65
+ ANCHOR_AXIS_REF_BY_IDX_SCHEMA: ANCHOR_AXIS_REF_BY_IDX_SCHEMA,
66
+ ANCHOR_AXIS_REF_BY_NAME_SCHEMA: ANCHOR_AXIS_REF_BY_NAME_SCHEMA,
67
+ ANCHOR_AXIS_REF_BY_MATCHER_SCHEMA: ANCHOR_AXIS_REF_BY_MATCHER_SCHEMA,
68
+ A_AXIS_SELECTOR_SCHEMA: A_AXIS_SELECTOR_SCHEMA,
69
+ A_DOMAIN_SCHEMA: A_DOMAIN_SCHEMA
70
+ })
71
+
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.15.16",
3
+ "version": "2.16.0",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",