@platforma-sdk/workflow-tengo 3.0.1 → 3.0.3

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" | "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";
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" | "pframes.export-pframe-for-ui";
3
3
  declare const Templates: Record<TplName, TemplateFromFile>;
4
4
  export { Templates };
package/dist/index.js CHANGED
@@ -18,5 +18,6 @@ module.exports = { Templates: {
18
18
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
19
19
  'pframes.xsv-import-map': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.xsv-import-map.plj.gz') },
20
20
  'pframes.process-pcolumn-data': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.process-pcolumn-data.plj.gz') },
21
- 'pframes.export-pframe': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe.plj.gz') }
21
+ 'pframes.export-pframe': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe.plj.gz') },
22
+ 'pframes.export-pframe-for-ui': { type: 'from-file', path: require.resolve('./tengo/tpl/pframes.export-pframe-for-ui.plj.gz') }
22
23
  }};
package/dist/index.mjs CHANGED
@@ -19,5 +19,6 @@ export const Templates = {
19
19
  'pframes.xsv-import-if-not-null': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-if-not-null.plj.gz') },
20
20
  'pframes.xsv-import-map': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.xsv-import-map.plj.gz') },
21
21
  'pframes.process-pcolumn-data': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.process-pcolumn-data.plj.gz') },
22
- 'pframes.export-pframe': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe.plj.gz') }
22
+ 'pframes.export-pframe': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe.plj.gz') },
23
+ 'pframes.export-pframe-for-ui': { type: 'from-file', path: resolve(import.meta.dirname, './tengo/tpl/pframes.export-pframe-for-ui.plj.gz') }
23
24
  };
@@ -0,0 +1,132 @@
1
+ ll := import("@platforma-sdk/workflow-tengo:ll")
2
+ file := import("@platforma-sdk/workflow-tengo:file")
3
+ text := import("text")
4
+ smart := import("@platforma-sdk/workflow-tengo:smart")
5
+ render := import("@platforma-sdk/workflow-tengo:render")
6
+ assets := import("@platforma-sdk/workflow-tengo:assets")
7
+ pframes := import("@platforma-sdk/workflow-tengo:pframes")
8
+ constants := import("@platforma-sdk/workflow-tengo:constants")
9
+ validation := import("@platforma-sdk/workflow-tengo:validation")
10
+
11
+ eMulTpl := assets.importTemplate("@platforma-sdk/workflow-tengo:pframes.export-multiple-pcolumns")
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ exportPFrame := func(pfResource, skipHideDataFromUI) {
21
+
22
+
23
+
24
+ fields := pfResource.inputs()
25
+
26
+
27
+ if pfResource.checkResourceType(constants.RTYPE_CONTEXT) {
28
+ newFields := {}
29
+ for rawFieldName, fieldValue in fields {
30
+ if text.has_prefix(rawFieldName, "values/") {
31
+ fieldName := rawFieldName[7:]
32
+ newFields[fieldName] = fieldValue
33
+ } else if rawFieldName == "id" || rawFieldName == "parent" {
34
+
35
+ continue
36
+ } else {
37
+ ll.panic("Unexpected context field: %v", rawFieldName)
38
+ }
39
+ }
40
+
41
+ fields = newFields
42
+ }
43
+
44
+
45
+
46
+
47
+ columns := {}
48
+
49
+ getOrCreateColumn := func(name) {
50
+ c := columns[name]
51
+ if is_undefined(c) {
52
+ c = {}
53
+ columns[name] = c
54
+ }
55
+ return c
56
+ }
57
+
58
+ for fieldName, fieldValue in fields {
59
+ if text.has_suffix(fieldName, ".spec") {
60
+ if !(fieldValue.getValue().checkResourceType(constants.RTYPE_JSON) || fieldValue.getValue().checkResourceType(constants.RTYPE_OBJECT_SPEC)) {
61
+ ll.panic("Unexpected spec value type: %v", fieldValue.getValue().info().Type)
62
+ }
63
+ col := getOrCreateColumn(fieldName[:len(fieldName) - 5])
64
+ col.spec = fieldValue.getValue().getDataAsJson()
65
+ col.specRaw = fieldValue
66
+ } else if text.has_suffix(fieldName, ".data") {
67
+ col := getOrCreateColumn(fieldName[:len(fieldName) - 5])
68
+ col.data = fieldValue
69
+ } else {
70
+ ll.panic("Unexpected field name: %v", fieldName)
71
+ }
72
+ }
73
+
74
+ validation.assertType(columns, {any: {
75
+ "spec,?": "any",
76
+ "specRaw,?": validation.reference,
77
+ "data,?": validation.reference
78
+ }})
79
+
80
+
81
+
82
+
83
+ result := pframes.pFrameBuilder()
84
+
85
+
86
+ eMulTplInput := smart.mapBuilder()
87
+
88
+ eMulTplRender := render.createEphemeral(eMulTpl, { data: eMulTplInput })
89
+
90
+ for colName, col in columns {
91
+ if is_undefined(col.data) {
92
+ result.add(colName, col.specRaw, undefined)
93
+ continue
94
+ }
95
+
96
+ shouldHideDataFromUI := skipHideDataFromUI && !is_undefined(col.spec) && col.spec.annotations["pl7.app/hideDataFromUi"] == "true"
97
+ if shouldHideDataFromUI {
98
+
99
+ result.add(colName, col.specRaw, undefined)
100
+ continue
101
+ }
102
+
103
+ if is_undefined(col.spec) || (
104
+ col.spec.kind == "PColumn" && (
105
+ is_undefined(col.spec.valueType) ||
106
+ col.spec.valueType == "file" || col.spec.valueType == "blob" ||
107
+ col.spec.valueType == "File" || col.spec.valueType == "Blob" ||
108
+ col.spec.valueType == "Int" || col.spec.valueType == "Long" ||
109
+ col.spec.valueType == "Float" || col.spec.valueType == "Double" ||
110
+ col.spec.valueType == "String" || col.spec.valueType == "Bytes")) {
111
+
112
+ result.add(colName, col.specRaw, eMulTplRender.output(colName))
113
+ eMulTplInput.add(colName, col.data)
114
+ continue
115
+ }
116
+
117
+ if col.spec.kind == "File" {
118
+ result.add(colName, col.specRaw, file.exportFile(col.data))
119
+ continue
120
+ }
121
+
122
+ result.add(colName, col.specRaw, col.data)
123
+ }
124
+
125
+ eMulTplInput.build()
126
+
127
+ return result.build()
128
+ }
129
+
130
+ export {
131
+ exportPFrame: exportPFrame
132
+ }
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": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -16,11 +16,11 @@
16
16
  "./dist/**/*"
17
17
  ],
18
18
  "dependencies": {
19
- "@milaboratories/software-pframes-conv": "2.1.19",
19
+ "@milaboratories/software-pframes-conv": "2.1.20",
20
20
  "@platforma-open/milaboratories.software-small-binaries": "^1.15.19"
21
21
  },
22
22
  "devDependencies": {
23
- "@platforma-sdk/tengo-builder": "^2.0.0"
23
+ "@platforma-sdk/tengo-builder": "^2.0.1"
24
24
  },
25
25
  "scripts": {
26
26
  "type-check": "pl-tengo check",