@platforma-sdk/workflow-tengo 2.15.2 → 2.15.4

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" | "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" | "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
@@ -12,6 +12,7 @@ module.exports = { Templates: {
12
12
  'exec.python.create-venv': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.python.create-venv.plj.gz') },
13
13
  'exec.monetization_to_json': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.monetization_to_json.plj.gz') },
14
14
  'exec.exec': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.exec.plj.gz') },
15
+ 'exec.monetization_info': { type: 'from-file', path: require.resolve('./tengo/tpl/exec.monetization_info.plj.gz') },
15
16
  'pframes.xsv-export-pframe': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-export-pframe.plj.gz') },
16
17
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
17
18
  'pframes.xsv-import-map': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-map.plj.gz') },
package/dist/index.mjs CHANGED
@@ -13,6 +13,7 @@ export const Templates = {
13
13
  'exec.python.create-venv': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.python.create-venv.plj.gz') },
14
14
  'exec.monetization_to_json': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.monetization_to_json.plj.gz') },
15
15
  'exec.exec': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.exec.plj.gz') },
16
+ 'exec.monetization_info': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/exec.monetization_info.plj.gz') },
16
17
  'pframes.xsv-export-pframe': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-export-pframe.plj.gz') },
17
18
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
18
19
  'pframes.xsv-import-map': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-map.plj.gz') },
@@ -490,8 +490,8 @@ builder := func() {
490
490
  return self
491
491
  },
492
492
 
493
- setMnzDryRun: func() {
494
- monetization.setDryRun(mnz, true)
493
+ setMnzUrl: func(url) {
494
+ monetization.setUrl(mnz, url)
495
495
  return self
496
496
  },
497
497
 
@@ -2,22 +2,35 @@
2
2
 
3
3
  ll := import("@platforma-sdk/workflow-tengo:ll")
4
4
  monetization := import("@platforma-sdk/workflow-tengo:exec.monetization_internal")
5
- workdir := import("@platforma-sdk/workflow-tengo:workdir")
5
+ assets := import("@platforma-sdk/workflow-tengo:assets")
6
+ render := import("@platforma-sdk/workflow-tengo:render")
6
7
  path := import("@platforma-sdk/workflow-tengo:path")
7
- constants := import("@platforma-sdk/workflow-tengo:exec.constants")
8
8
  smart := import("@platforma-sdk/workflow-tengo:smart")
9
9
  validation := import("@platforma-sdk/workflow-tengo:validation")
10
10
 
11
+
12
+
13
+
14
+
15
+
16
+
17
+
11
18
  builder := func(productKey) {
12
19
  mnz := monetization.init()
13
20
  monetization.enable(mnz, productKey)
14
21
  monetization.setDryRun(mnz, true)
15
22
 
23
+ date := undefined
16
24
  filesToAdd := {}
17
25
  filesToWrite := {}
18
26
 
19
27
  self := undefined
20
28
  self = ll.toStrict({
29
+ setDate: func(newDate) {
30
+ date = newDate
31
+ return self
32
+ },
33
+
21
34
  addFile: func(fileName, file, params) {
22
35
  ll.assert(is_string(fileName), "monetization.builder().addFile: fileName must be a string")
23
36
  ll.assert(smart.isReference(file), "monetization.builder().addFile: file must be a reference")
@@ -42,15 +55,29 @@ builder := func(productKey) {
42
55
  return self
43
56
  },
44
57
 
58
+ setUrl: func(url) {
59
+ monetization.setUrl(mnz, url)
60
+ return self
61
+ },
62
+
45
63
  build: func() {
46
- wd := workdir.builder().
47
- addFiles(filesToAdd).
48
- writeFiles(filesToWrite).
49
- build()
64
+ ll.assert(!is_undefined(date), "monetization.builder().build: date must be set")
65
+
66
+
67
+
68
+
50
69
 
51
- result := monetization.run(mnz, wd, constants.UI_TASKS_QUEUE)
70
+ result := render.create(
71
+ assets.importTemplate("@platforma-sdk/workflow-tengo:exec.monetization_info"),
72
+ {
73
+ date: date, // solely for deduplication
74
+ monetization: monetization.toJson(mnz),
75
+ filesToAdd: filesToAdd,
76
+ filesToWrite: filesToWrite
77
+ }
78
+ )
52
79
 
53
- return result
80
+ return result.output("info")
54
81
  }
55
82
  })
56
83
 
@@ -31,7 +31,7 @@ mnzClientStdoutSchema := ["or",
31
31
  spentRuns: "number",
32
32
  runsToSpend: "number",
33
33
  willRemainAfterRun: "number",
34
- subscription: {
34
+ "subscription,?": {
35
35
  availableRuns: "number",
36
36
  startsAt: "string",
37
37
  expiresAt: "string"
@@ -53,7 +53,10 @@ init := func() {
53
53
  isDryRun: false,
54
54
 
55
55
 
56
- fileParams: {}
56
+ fileParams: {},
57
+
58
+
59
+ url: undefined
57
60
  })
58
61
  }
59
62
 
@@ -66,7 +69,8 @@ schema := {
66
69
  "enabled": "bool",
67
70
  "productKey": "string",
68
71
  "isDryRun": "bool",
69
- "fileParams": {"any": fileParamsSchema}
72
+ "fileParams": {"any": fileParamsSchema},
73
+ "url,?": "string"
70
74
  }
71
75
 
72
76
 
@@ -110,19 +114,6 @@ enable := func(mnz, productKey) {
110
114
  mnz.productKey = productKey
111
115
  }
112
116
 
113
- setDryRun := func(mnz, isDryRun) {
114
- ll.assert(mnz.enabled,
115
- "monetization.setDryRun(): monetization must be explicitly enabled by enableMnz(productKey) function")
116
-
117
- ll.assert(is_bool(isDryRun),
118
- "monetization.setDryRun(): isDryRun must be boolean, got %v", isDryRun)
119
-
120
- validation.assertType(mnz, schema,
121
- "monetization.setDryRun(): mnz object does not fit schema")
122
-
123
- mnz.isDryRun = isDryRun
124
- }
125
-
126
117
 
127
118
  shouldRun := func(mnz) {
128
119
  if mnz.enabled {
@@ -159,6 +150,32 @@ addFileParams := func(mnz, fileName, params) {
159
150
  mnz.fileParams[fileName] = params
160
151
  }
161
152
 
153
+ setDryRun := func(mnz, isDryRun) {
154
+ ll.assert(mnz.enabled,
155
+ "monetization.setDryRun(): monetization must be explicitly enabled by enableMnz(productKey) function")
156
+
157
+ ll.assert(is_bool(isDryRun),
158
+ "monetization.setDryRun(): isDryRun must be boolean, got %v", isDryRun)
159
+
160
+ validation.assertType(mnz, schema,
161
+ "monetization.setDryRun(): mnz object does not fit schema")
162
+
163
+ mnz.isDryRun = isDryRun
164
+ }
165
+
166
+ setUrl := func(mnz, url) {
167
+ ll.assert(mnz.enabled,
168
+ "monetization.setUrl(): monetization must be explicitly enabled by enableMnz(productKey) function")
169
+
170
+ ll.assert(is_string(url),
171
+ "monetization.setUrl(): url must be string, got %v", url)
172
+
173
+ validation.assertType(mnz, schema,
174
+ "monetization.setUrl(): mnz object does not fit schema")
175
+
176
+ mnz.url = url
177
+ }
178
+
162
179
 
163
180
 
164
181
 
@@ -191,6 +208,9 @@ run := func(mnz, wd, queue) {
191
208
  if mnz.isDryRun {
192
209
  builder.arg("-dry-run")
193
210
  }
211
+ if mnz.url {
212
+ builder.arg(mnz.isDryRun ? "-dry-run-url" : "-url").arg(mnz.url)
213
+ }
194
214
  builder.arg("-productKey").arg(mnz.productKey)
195
215
 
196
216
 
@@ -447,14 +447,13 @@ processColumn := func(input, bodyTpl, outputs, ...opts) {
447
447
 
448
448
 
449
449
 
450
- allOutputsFrame: func(...xsvNameSeparator) {
450
+
451
+ addAllOutputsToBuilder: func(builder, ...separator) {
451
452
  sep := "."
452
- if len(xsvNameSeparator) > 0 {
453
- sep = xsvNameSeparator[0]
453
+ if len(separator) > 0 {
454
+ sep = separator[0]
454
455
  }
455
456
 
456
- builder := builder.pFrameBuilder()
457
-
458
457
  for name, output in outputsMap {
459
458
  if output.type == "Xsv" {
460
459
 
@@ -475,6 +474,18 @@ processColumn := func(input, bodyTpl, outputs, ...opts) {
475
474
  }
476
475
  }
477
476
 
477
+ return builder
478
+ },
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+ allOutputsFrame: func(...xsvNameSeparator) {
487
+ builder := builder.pFrameBuilder()
488
+ self.addAllOutputsToBuilder(builder, xsvNameSeparator...)
478
489
  return builder.build()
479
490
  },
480
491
 
@@ -525,7 +536,29 @@ processColumn := func(input, bodyTpl, outputs, ...opts) {
525
536
  columns = append(columns, columnName)
526
537
  }
527
538
  return slices.quickSort(columns)
539
+ },
540
+
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+ addXsvOutputToBuilder: func(builder, outputName, prefix) {
550
+ for columnName in self.listXsvColumns(outputName) {
551
+ builder.add(
552
+ prefix + columnName,
553
+ self.outputSpec(outputName, columnName),
554
+ self.outputData(outputName, columnName)
555
+ )
556
+ }
557
+
558
+ return builder
528
559
  }
560
+
561
+
529
562
  })
530
563
 
531
564
  return self
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.2",
3
+ "version": "2.15.4",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "@platforma-open/milaboratories.software-small-binaries": "^1.15.13"
21
21
  },
22
22
  "devDependencies": {
23
- "@platforma-sdk/tengo-builder": "^1.19.1"
23
+ "@platforma-sdk/tengo-builder": "^1.19.2"
24
24
  },
25
25
  "scripts": {
26
26
  "type-check": "pl-tengo check",