@platforma-sdk/workflow-tengo 2.9.5 → 2.9.7
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
|
@@ -6,201 +6,201 @@ json := import("json")
|
|
|
6
6
|
|
|
7
7
|
_CONTEXT_FIELD_NAME := "ctx"
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// options scheme for query
|
|
10
10
|
_OPTIONS_SCHEME := {
|
|
11
|
-
"spec,?": `bool`,
|
|
12
|
-
"data,?": `bool`,
|
|
13
|
-
"single,?": `bool`,
|
|
14
|
-
"first,?": `bool`,
|
|
15
|
-
"errIfMissing,?": `bool`
|
|
11
|
+
"spec,?": `bool`,
|
|
12
|
+
"data,?": `bool`,
|
|
13
|
+
"single,?": `bool`,
|
|
14
|
+
"first,?": `bool`,
|
|
15
|
+
"errIfMissing,?": `bool`
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// default query options
|
|
19
19
|
_DEFAULT_OPTIONS := {
|
|
20
|
-
|
|
21
|
-
spec: true,
|
|
22
|
-
|
|
23
|
-
data: true,
|
|
24
|
-
|
|
25
|
-
single: false,
|
|
26
|
-
|
|
27
|
-
first: false,
|
|
28
|
-
|
|
29
|
-
errIfMissing: false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
/** Return specs in the results */
|
|
21
|
+
spec: true,
|
|
22
|
+
/** Return data in the results */
|
|
23
|
+
data: true,
|
|
24
|
+
/** Asserts that the resulting list has one element and returns it */
|
|
25
|
+
single: false,
|
|
26
|
+
/** Returns first available result of the query */
|
|
27
|
+
first: false,
|
|
28
|
+
/** Throw error if no results found */
|
|
29
|
+
errIfMissing: false
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Query results pool.
|
|
34
|
+
*
|
|
35
|
+
* @param spec: query spec
|
|
36
|
+
* @param ctx: results pool (context) to query
|
|
37
|
+
* @param options: an options map
|
|
38
|
+
* @return result: a list of {ref: spec: data:} objects (data will be absent if not requested)
|
|
39
|
+
*/
|
|
40
40
|
create := func(spec, ctx, ...options) {
|
|
41
41
|
|
|
42
|
+
// @TODO validate spec
|
|
42
43
|
|
|
44
|
+
ops := copy(_DEFAULT_OPTIONS)
|
|
45
|
+
if len(options) > 0 {
|
|
46
|
+
ll.assert(len(options) == 1, "expected map, got array: ", options)
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
if len(options) > 0 {
|
|
46
|
-
ll.assert(len(options) == 1, "expected map, got array: ", options)
|
|
48
|
+
// @TODO validate options
|
|
47
49
|
|
|
50
|
+
// override defaults
|
|
51
|
+
for k, v in options[0] {
|
|
52
|
+
ops[k] = v
|
|
53
|
+
}
|
|
54
|
+
}
|
|
48
55
|
|
|
56
|
+
query := json.encode({
|
|
57
|
+
query: spec,
|
|
58
|
+
setErrorIfMissing: ops.errIfMissing
|
|
59
|
+
})
|
|
49
60
|
|
|
61
|
+
builder := undefined
|
|
62
|
+
if ops.first {
|
|
63
|
+
builder = smart.ephemeralBuilder(constants.RTYPE_BRESOLVE_FIRST, query)
|
|
64
|
+
} else {
|
|
65
|
+
// return all query results
|
|
66
|
+
builder = smart.ephemeralBuilder(constants.RTYPE_BRESOLVE_CHOICE, query)
|
|
67
|
+
}
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
69
|
+
builder.createInputField(_CONTEXT_FIELD_NAME).set(ctx)
|
|
70
|
+
resolve := builder.lockInputsAndBuild()
|
|
55
71
|
|
|
56
|
-
query := json.encode({
|
|
57
|
-
query: spec,
|
|
58
|
-
setErrorIfMissing: ops.errIfMissing
|
|
59
|
-
})
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
if ops.first {
|
|
63
|
-
builder = smart.ephemeralBuilder(constants.RTYPE_BRESOLVE_FIRST, query)
|
|
64
|
-
} else {
|
|
73
|
+
// create a special type to store query results
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
}
|
|
75
|
+
rb := smart.structBuilder(constants.RTYPE_QUERY_RESULT)
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
// save options
|
|
78
|
+
rb.createInputField("ops").setJson(ops)
|
|
71
79
|
|
|
80
|
+
if ops.spec {
|
|
81
|
+
rb.createInputField("spec").set(resolve.getFutureOutputField("spec"))
|
|
82
|
+
}
|
|
72
83
|
|
|
84
|
+
// pass data only if needed, otherwise we are not waiting for data to complete
|
|
85
|
+
if ops.data {
|
|
86
|
+
rb.createInputField("data").set(resolve.getFutureOutputField("data"))
|
|
87
|
+
}
|
|
73
88
|
|
|
89
|
+
// the data structure differs in this case; the single ref, data and spec are stored
|
|
90
|
+
// directly as result fields
|
|
91
|
+
if ops.first {
|
|
92
|
+
rb.createInputField("ref").set(resolve.getFutureOutputField("address"))
|
|
93
|
+
}
|
|
74
94
|
|
|
75
|
-
rb
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
rb.createInputField("ops").setJson(ops)
|
|
79
|
-
|
|
80
|
-
if ops.spec {
|
|
81
|
-
rb.createInputField("spec").set(resolve.getFutureOutputField("spec"))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if ops.data {
|
|
86
|
-
rb.createInputField("data").set(resolve.getFutureOutputField("data"))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if ops.first {
|
|
92
|
-
rb.createInputField("ref").set(resolve.getFutureOutputField("address"))
|
|
95
|
+
return rb.lockAndBuild()
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Inputs preprocessor used to convert query result into array of {ref: spec: data:} objects
|
|
100
|
+
*/
|
|
101
101
|
resultUnmarshaller := func() {
|
|
102
|
-
return {
|
|
103
|
-
canParse: func(r) {
|
|
104
|
-
return smart.isResource(r) && r.info().Type.Name == constants.RTYPE_QUERY_RESULT.Name
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
parse: func(resource, parser) {
|
|
108
|
-
|
|
109
|
-
ops := resource.get("ops").getDataAsJson()
|
|
110
|
-
|
|
111
|
-
if ops.first {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
isNR := func(r) {
|
|
116
|
-
return r.info().Type.Name == constants.RTYPE_BRESOLVE_NO_RESULT.Name
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if isNR(resource.get("ref")) {
|
|
120
|
-
return undefined
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
result := {
|
|
124
|
-
ref: resource.get("ref").getDataAsJson(),
|
|
125
|
-
spec: resource.get("spec").getDataAsJson()
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if resource.hasInputField("data") {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if isNR(resource.get("data")) {
|
|
133
|
-
result.data = undefined
|
|
134
|
-
} else {
|
|
135
|
-
result.data = parser(resource.get("data"))
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return ll.toStrict(result)
|
|
140
|
-
} else {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
spec := resource.get("spec").inputs()
|
|
144
|
-
data := undefined
|
|
145
|
-
if resource.hasInputField("data") {
|
|
146
|
-
data = resource.get("data").inputs()
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
result := []
|
|
150
|
-
for ref, s in spec {
|
|
151
|
-
r := {
|
|
152
|
-
ref: json.decode(ref),
|
|
153
|
-
spec: s.getValueAsJson()
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if !is_undefined(data) {
|
|
158
|
-
r.data = parser(data[ref].getValue())
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
result = append(result, ll.toStrict(r))
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if ops.single {
|
|
165
|
-
ll.assert(len(result) == 1, "expected single element, got ", len(result))
|
|
166
|
-
|
|
167
|
-
result = result[0]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return result
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
102
|
+
return {
|
|
103
|
+
canParse: func(r) {
|
|
104
|
+
return smart.isResource(r) && r.info().Type.Name == constants.RTYPE_QUERY_RESULT.Name
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
parse: func(resource, parser) {
|
|
108
|
+
|
|
109
|
+
ops := resource.get("ops").getDataAsJson()
|
|
110
|
+
|
|
111
|
+
if ops.first {
|
|
112
|
+
// special case, single element
|
|
113
|
+
|
|
114
|
+
// is no result
|
|
115
|
+
isNR := func(r) {
|
|
116
|
+
return r.info().Type.Name == constants.RTYPE_BRESOLVE_NO_RESULT.Name
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if isNR(resource.get("ref")) {
|
|
120
|
+
return undefined
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
result := {
|
|
124
|
+
ref: resource.get("ref").getDataAsJson(),
|
|
125
|
+
spec: resource.get("spec").getDataAsJson()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// only if the data is there
|
|
129
|
+
if resource.hasInputField("data") {
|
|
130
|
+
|
|
131
|
+
// even if spec is present, the data may be still not available
|
|
132
|
+
if isNR(resource.get("data")) {
|
|
133
|
+
result.data = undefined
|
|
134
|
+
} else {
|
|
135
|
+
result.data = parser(resource.get("data"))
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return ll.toStrict(result)
|
|
140
|
+
} else {
|
|
141
|
+
// format list of results
|
|
142
|
+
|
|
143
|
+
spec := resource.get("spec").inputs()
|
|
144
|
+
data := undefined
|
|
145
|
+
if resource.hasInputField("data") {
|
|
146
|
+
data = resource.get("data").inputs()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
result := []
|
|
150
|
+
for ref, s in spec {
|
|
151
|
+
r := {
|
|
152
|
+
ref: json.decode(ref),
|
|
153
|
+
spec: s.getValueAsJson()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// only if the data is there
|
|
157
|
+
if !is_undefined(data) {
|
|
158
|
+
r.data = parser(data[ref].getValue())
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
result = append(result, ll.toStrict(r))
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if ops.single {
|
|
165
|
+
ll.assert(len(result) == 1, "expected single element, got ", len(result))
|
|
166
|
+
|
|
167
|
+
result = result[0]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return result
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Query results pool to find spec & data for a given ref.
|
|
178
|
+
*
|
|
179
|
+
* @param ref: a ref object ({blockId: name:})
|
|
180
|
+
* @param ctx: results pool (context) to query
|
|
181
|
+
* @return result: a {ref: spec: data:} object
|
|
182
|
+
*/
|
|
183
183
|
resolve := func(ref, ctx, ...options) {
|
|
184
184
|
|
|
185
|
-
spec := {
|
|
186
|
-
type: "Direct",
|
|
187
|
-
block_id: ref.blockId, // @TODO use consistent naming in pl
|
|
188
|
-
output_name: ref.name // @TODO use consistent naming in pl
|
|
189
|
-
}
|
|
185
|
+
spec := {
|
|
186
|
+
type: "Direct",
|
|
187
|
+
block_id: ref.blockId, // @TODO use consistent naming in pl
|
|
188
|
+
output_name: ref.name // @TODO use consistent naming in pl
|
|
189
|
+
}
|
|
190
190
|
|
|
191
|
-
ops := {}
|
|
191
|
+
ops := {}
|
|
192
192
|
|
|
193
|
-
if len(options) > 0 {
|
|
194
|
-
ops = options[0]
|
|
195
|
-
}
|
|
193
|
+
if len(options) > 0 {
|
|
194
|
+
ops = options[0]
|
|
195
|
+
}
|
|
196
196
|
|
|
197
|
-
ops.first = true
|
|
197
|
+
ops.first = true
|
|
198
198
|
|
|
199
|
-
return create(spec, ctx, ops)
|
|
199
|
+
return create(spec, ctx, ops)
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
export ll.toStrict({
|
|
203
|
-
create: create,
|
|
204
|
-
resolve: resolve,
|
|
205
|
-
resultUnmarshaller: resultUnmarshaller
|
|
203
|
+
create: create,
|
|
204
|
+
resolve: resolve,
|
|
205
|
+
resultUnmarshaller: resultUnmarshaller
|
|
206
206
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** Library to work with context resources */
|
|
2
2
|
|
|
3
3
|
ll := import("@platforma-sdk/workflow-tengo:ll")
|
|
4
4
|
smart := import("@platforma-sdk/workflow-tengo:smart")
|
|
@@ -9,48 +9,48 @@ _BLOCK_ID_FIELD := "id"
|
|
|
9
9
|
_PARENT_CTX_FIELD := "parent"
|
|
10
10
|
_EXPORTS_OUTPUT_PREFIX := "values/"
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Create a new context builder
|
|
14
|
+
*
|
|
15
|
+
* @param block block (smart.Resource)
|
|
16
|
+
* @param parentContext parent context (smart.Resource)
|
|
17
|
+
*/
|
|
18
18
|
builder := func(block, parentContext) {
|
|
19
19
|
|
|
20
|
-
super := smart.ephemeralBuilder(constants.RTYPE_CONTEXT)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
super.createInputField(_BLOCK_ID_FIELD).setRefOrJson(block)
|
|
20
|
+
super := smart.ephemeralBuilder(constants.RTYPE_CONTEXT)
|
|
24
21
|
|
|
22
|
+
// set blockId associated with this context
|
|
23
|
+
super.createInputField(_BLOCK_ID_FIELD).setRefOrJson(block)
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
// set parent context
|
|
26
|
+
super.createInputField(_PARENT_CTX_FIELD).set(parentContext)
|
|
27
27
|
|
|
28
|
-
self := undefined
|
|
29
|
-
self = ll.toStrict(oop.inherit(super, {
|
|
28
|
+
self := undefined
|
|
29
|
+
self = ll.toStrict(oop.inherit(super, {
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Add export to the context
|
|
33
|
+
*
|
|
34
|
+
* @param name string name of the export field
|
|
35
|
+
* @param value resource/field value
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
add: func(name, value) {
|
|
39
|
+
field := super.createInputField(_EXPORTS_OUTPUT_PREFIX + name)
|
|
31
40
|
|
|
41
|
+
field.setRefOrJson(value)
|
|
32
42
|
|
|
43
|
+
return self
|
|
44
|
+
},
|
|
33
45
|
|
|
46
|
+
build: func() {
|
|
47
|
+
return super.lockAndBuild()
|
|
48
|
+
}
|
|
49
|
+
}))
|
|
34
50
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
add: func(name, value) {
|
|
39
|
-
field := super.createInputField(_EXPORTS_OUTPUT_PREFIX + name)
|
|
40
|
-
|
|
41
|
-
field.setRefOrJson(value)
|
|
42
|
-
|
|
43
|
-
return self
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
build: func() {
|
|
47
|
-
return super.lockAndBuild()
|
|
48
|
-
}
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
return self
|
|
51
|
+
return self
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export ll.toStrict({
|
|
55
|
-
builder: builder
|
|
55
|
+
builder: builder
|
|
56
56
|
})
|