@things-factory/integration-notification 7.0.0-alpha.9 → 7.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-notification",
3
- "version": "7.0.0-alpha.9",
3
+ "version": "7.0.0",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -23,8 +23,9 @@
23
23
  "clean": "npm run clean:server"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/integration-base": "^7.0.0-alpha.9",
27
- "@things-factory/notification": "^7.0.0-alpha.9"
26
+ "@things-factory/integration-base": "^7.0.0",
27
+ "@things-factory/notification": "^7.0.0",
28
+ "ses": "^1.5.0"
28
29
  },
29
- "gitHead": "99fc5aead211b3c82e3ebbf76e8d5d1db01b1ddc"
30
+ "gitHead": "00f3917ca132679e3571f3f4fd16f4caf84f488e"
30
31
  }
@@ -1,6 +1,5 @@
1
1
  import { ILike } from 'typeorm'
2
- import { VM } from 'vm2'
3
-
2
+ import 'ses'
4
3
  import { User } from '@things-factory/auth-base'
5
4
  import { TaskRegistry } from '@things-factory/integration-base'
6
5
  import { notify } from '@things-factory/notification'
@@ -32,16 +31,22 @@ async function Notification(step, { logger, domain, user, data, variables }) {
32
31
  )
33
32
  ).filter(receiver => !!receiver)
34
33
 
35
- const vm = new VM({
36
- sandbox: {
37
- domain,
38
- user,
39
- data,
40
- variables
41
- }
34
+ const compartment = new Compartment({
35
+ domain,
36
+ user,
37
+ data,
38
+ variables,
39
+ console
42
40
  })
43
41
 
44
- body = vm.run('`' + body + '`')
42
+ let evalBody
43
+ try {
44
+ evalBody = compartment.evaluate('`' + body + '`')
45
+ } catch (err) {
46
+ throw new Error(`Failed to evaluate body: ${err.message}`)
47
+ }
48
+
49
+ body = evalBody
45
50
  const timestamp = String(Date.now())
46
51
 
47
52
  if (push) {
@@ -113,7 +118,11 @@ Notification.parameterSpec = [
113
118
  name: 'body',
114
119
  label: 'message-body',
115
120
  property: {
116
- language: 'text'
121
+ language: 'text',
122
+ showLineNumbers: true
123
+ },
124
+ styles: {
125
+ flex: '1'
117
126
  }
118
127
  },
119
128
  {