@things-factory/integration-base 6.1.100 → 6.1.101

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.
Files changed (31) hide show
  1. package/dist-server/engine/task/http-get.js +4 -7
  2. package/dist-server/engine/task/http-get.js.map +1 -1
  3. package/dist-server/engine/task/http-post.js +1 -0
  4. package/dist-server/engine/task/http-post.js.map +1 -1
  5. package/dist-server/engine/task/log.js +23 -9
  6. package/dist-server/engine/task/log.js.map +1 -1
  7. package/dist-server/tsconfig.tsbuildinfo +1 -1
  8. package/helps/integration/concept/template-literal.ja.md +31 -0
  9. package/helps/integration/concept/template-literal.ko.md +31 -0
  10. package/helps/integration/concept/template-literal.md +31 -0
  11. package/helps/integration/concept/template-literal.zh.md +31 -0
  12. package/helps/integration/task/book-up-scenario.md +5 -2
  13. package/helps/integration/task/http-get.ja.md +31 -0
  14. package/helps/integration/task/http-get.ko.md +28 -0
  15. package/helps/integration/task/http-get.md +28 -0
  16. package/helps/integration/task/http-get.ms.md +28 -0
  17. package/helps/integration/task/http-get.zh.md +28 -0
  18. package/helps/integration/task/http-post.ja.md +35 -0
  19. package/helps/integration/task/http-post.ko.md +34 -0
  20. package/helps/integration/task/http-post.md +35 -0
  21. package/helps/integration/task/http-post.ms.md +37 -0
  22. package/helps/integration/task/http-post.zh.md +35 -0
  23. package/helps/integration/task/log.ja.md +11 -0
  24. package/helps/integration/task/log.ko.md +16 -0
  25. package/helps/integration/task/log.md +12 -11
  26. package/helps/integration/task/log.ms.md +15 -0
  27. package/helps/integration/task/log.zh.md +11 -0
  28. package/package.json +7 -7
  29. package/server/engine/task/http-get.ts +6 -10
  30. package/server/engine/task/http-post.ts +2 -0
  31. package/server/engine/task/log.ts +27 -10
@@ -128,4 +128,6 @@ HttpPost.parameterSpec = [
128
128
  }
129
129
  ]
130
130
 
131
+ HttpPost.help = 'integration/task/http-post'
132
+
131
133
  TaskRegistry.registerTaskHandler('http-post', HttpPost)
@@ -1,14 +1,31 @@
1
- import { access } from '@things-factory/utils'
1
+ import { access, hasTemplateExpression } from '@things-factory/utils'
2
+ import { VM } from 'vm2'
2
3
  import { TaskRegistry } from '../task-registry'
3
4
 
4
- async function Log(step, { logger, data }) {
5
+ async function Log(step, { logger, data, variables, domain }) {
5
6
  var {
6
7
  params: { message, accessor, level = 'info' }
7
8
  } = step
8
9
 
9
- message = access(accessor, data) || message
10
- if (typeof message !== 'string') {
11
- message = JSON.stringify(message, null, 2)
10
+ if (hasTemplateExpression(message)) {
11
+ const vm = new VM({
12
+ sandbox: {
13
+ domain,
14
+ data,
15
+ variables
16
+ }
17
+ })
18
+
19
+ message = vm.run('`' + message + '`')
20
+ }
21
+
22
+ accessor = access(accessor, data)
23
+
24
+ if (accessor) {
25
+ if (accessor !== 'string') {
26
+ accessor = JSON.stringify(accessor, null, 2)
27
+ }
28
+ message += ': ' + accessor
12
29
  }
13
30
 
14
31
  switch (level) {
@@ -28,16 +45,16 @@ async function Log(step, { logger, data }) {
28
45
  }
29
46
 
30
47
  Log.parameterSpec = [
31
- {
32
- type: 'scenario-step-input',
33
- name: 'accessor',
34
- label: 'accessor'
35
- },
36
48
  {
37
49
  type: 'string',
38
50
  name: 'message',
39
51
  label: 'message'
40
52
  },
53
+ {
54
+ type: 'scenario-step-input',
55
+ name: 'accessor',
56
+ label: 'accessor'
57
+ },
41
58
  {
42
59
  type: 'select',
43
60
  name: 'level',