@live-change/email-service 0.2.5 → 0.2.6

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 (2) hide show
  1. package/auth.js +23 -1
  2. package/package.json +2 -2
package/auth.js CHANGED
@@ -1,9 +1,16 @@
1
+ const { validation } = require('@live-change/framework')
1
2
  const definition = require('./definition.js')
2
3
 
3
4
  const User = definition.foreignModel('user', 'User')
4
5
 
5
6
  const Email = definition.model({
6
7
  name: 'Email',
8
+ properties: {
9
+ email: {
10
+ type: String,
11
+ validation: ['nonEmpty', 'email']
12
+ }
13
+ },
7
14
  userItem: {
8
15
  userReadAccess: () => true
9
16
  },
@@ -66,6 +73,21 @@ definition.trigger({
66
73
  }
67
74
  })
68
75
 
76
+ definition.trigger({
77
+ name: "getEmail",
78
+ properties: {
79
+ email: {
80
+ type: String,
81
+ validation: ['nonEmpty', 'email']
82
+ }
83
+ },
84
+ async execute({ email }, context, emit) {
85
+ const emailData = await Email.get(email)
86
+ if(!emailData) throw 'notFound'
87
+ return emailData
88
+ }
89
+ })
90
+
69
91
  definition.trigger({
70
92
  name: "connectEmail",
71
93
  properties: {
@@ -120,7 +142,7 @@ definition.trigger({
120
142
  type: String
121
143
  }
122
144
  },
123
- async execute({ email }, { client, service }, emit) {
145
+ async execute({ email, session }, { client, service }, emit) {
124
146
  const emailData = await Email.get(email)
125
147
  if(!emailData) throw 'emailNotFound'
126
148
  const { user } = emailData
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/email-service",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,5 +28,5 @@
28
28
  "jsdom": "^18.1.1",
29
29
  "nodemailer": "^6.7.2"
30
30
  },
31
- "gitHead": "e9f8af40d836388f6847cf958c1d941dc8e273b1"
31
+ "gitHead": "2491e82b350403cf187887e8f06d140e0c362860"
32
32
  }