@lowdefy/connection-sendgrid 4.0.0-alpha.28 → 4.0.0-alpha.29

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": "@lowdefy/connection-sendgrid",
3
- "version": "4.0.0-alpha.28",
3
+ "version": "4.0.0-alpha.29",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -35,18 +35,17 @@
35
35
  "dist/*"
36
36
  ],
37
37
  "scripts": {
38
- "build": "yarn swc",
38
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
39
39
  "clean": "rm -rf dist",
40
- "prepare": "yarn build",
41
- "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
40
+ "prepublishOnly": "pnpm build",
42
41
  "test": "jest --coverage"
43
42
  },
44
43
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-alpha.28",
44
+ "@lowdefy/helpers": "4.0.0-alpha.29",
46
45
  "@sendgrid/mail": "7.7.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@lowdefy/ajv": "4.0.0-alpha.28",
48
+ "@lowdefy/ajv": "4.0.0-alpha.29",
50
49
  "@swc/cli": "0.1.57",
51
50
  "@swc/core": "1.2.194",
52
51
  "@swc/jest": "0.2.21",
@@ -55,5 +54,5 @@
55
54
  "publishConfig": {
56
55
  "access": "public"
57
56
  },
58
- "gitHead": "d0bad6be18362c0ceea1c18239c61bba0ba59300"
57
+ "gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
59
58
  }
@@ -1,22 +0,0 @@
1
- /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ import SendGridMailSend from './SendGridMailSend/SendGridMailSend.js';
16
- import schema from './schema.js';
17
- export default {
18
- schema,
19
- requests: {
20
- SendGridMailSend
21
- }
22
- };
@@ -1,48 +0,0 @@
1
- /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ import sendgrid from '@sendgrid/mail';
16
- import { type } from '@lowdefy/helpers';
17
- import schema from './schema.js';
18
- // https://sendgrid.api-docs.io/v3.0/how-to-use-the-sendgrid-v3-api/api-authentication
19
- // https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/README.md#email-use-cases
20
- async function SendGridMailSend({ request , connection }) {
21
- const { apiKey , from , templateId , mailSettings } = connection;
22
- sendgrid.setApiKey(apiKey);
23
- const messages = (type.isArray(request) ? request : [
24
- request
25
- ]).map((msg)=>({
26
- ...msg,
27
- from,
28
- templateId,
29
- mailSettings
30
- }));
31
- try {
32
- await sendgrid.send(messages);
33
- } catch (error) {
34
- if (error.response) {
35
- throw new Error(JSON.stringify(error.response.body));
36
- }
37
- throw error;
38
- }
39
- return {
40
- response: 'Mail sent successfully'
41
- };
42
- }
43
- SendGridMailSend.schema = schema;
44
- SendGridMailSend.meta = {
45
- checkRead: false,
46
- checkWrite: false
47
- };
48
- export default SendGridMailSend;
@@ -1,226 +0,0 @@
1
- /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ export default {
16
- $schema: 'http://json-schema.org/draft-07/schema#',
17
- title: 'Lowdefy Request Schema - SendGridMailSend',
18
- type: 'object',
19
- definitions: {
20
- email: {
21
- anyOf: [
22
- {
23
- type: 'string',
24
- examples: [
25
- 'someone@example.org',
26
- 'Name One <someone@example.org>'
27
- ],
28
- errorMessage: {
29
- type: 'SendGridMailSend request property "{{ dataPath }}" should be a string.'
30
- }
31
- },
32
- {
33
- type: 'object',
34
- required: [
35
- 'name',
36
- 'email'
37
- ],
38
- properties: {
39
- name: {
40
- type: 'string',
41
- examples: [
42
- 'Some One'
43
- ],
44
- errorMessage: {
45
- type: 'SendGridMailSend request property "{{ dataPath }}" should be a string.'
46
- }
47
- },
48
- email: {
49
- type: 'string',
50
- examples: [
51
- 'someone@example.org'
52
- ],
53
- errorMessage: {
54
- type: 'SendGridMailSend request property "{{ dataPath }}" should be a string.'
55
- }
56
- }
57
- },
58
- errorMessage: {
59
- type: 'SendGridMailSend request property "{{ dataPath }}" should be an object with properties "name" and "email".'
60
- }
61
- },
62
- ],
63
- errorMessage: {
64
- anyOf: 'SendGridMailSend request property "{{ dataPath }}" should be an email address, or an object with properties "name" and "email".'
65
- }
66
- },
67
- emails: {
68
- anyOf: [
69
- {
70
- $ref: '#/definitions/email'
71
- },
72
- {
73
- type: 'array',
74
- items: {
75
- $ref: '#/definitions/email'
76
- },
77
- errorMessage: {
78
- type: 'SendGridMailSend request property "{{ dataPath }}" should be a list of email addresses'
79
- }
80
- },
81
- ],
82
- errorMessage: {
83
- anyOf: 'SendGridMailSend request property "{{ dataPath }}" should be an email address, or a list of email addresses.'
84
- }
85
- },
86
- oneRequest: {
87
- type: 'object',
88
- required: [
89
- 'to'
90
- ],
91
- properties: {
92
- to: {
93
- $ref: '#/definitions/emails',
94
- description: 'Email address to send to.'
95
- },
96
- cc: {
97
- $ref: '#/definitions/emails',
98
- description: 'Email address to cc in communication.'
99
- },
100
- bcc: {
101
- $ref: '#/definitions/emails',
102
- description: 'Email address to bcc in communication.'
103
- },
104
- replyTo: {
105
- $ref: '#/definitions/emails',
106
- description: 'Email address to reply to.'
107
- },
108
- subject: {
109
- type: 'string',
110
- description: 'Email subject.',
111
- errorMessage: {
112
- type: 'SendGridMailSend request property "subject" should be a string.'
113
- }
114
- },
115
- text: {
116
- type: 'string',
117
- description: 'Email message in plain text format.',
118
- errorMessage: {
119
- type: 'SendGridMailSend request property "text" should be a string.'
120
- }
121
- },
122
- html: {
123
- type: 'string',
124
- description: 'Email message in html format.',
125
- errorMessage: {
126
- type: 'SendGridMailSend request property "html" should be a string.'
127
- }
128
- },
129
- dynamicTemplateData: {
130
- type: 'object',
131
- description: 'SendGrid template data to render into email template.',
132
- errorMessage: {
133
- type: 'SendGridMailSend request property "dynamicTemplateData" should be an object.'
134
- }
135
- },
136
- attachments: {
137
- type: 'array',
138
- description: 'List of email attachments to include with email.',
139
- items: {
140
- type: 'object',
141
- properties: {
142
- content: {
143
- type: 'string',
144
- description: 'Base 64 encoded attachment content.',
145
- errorMessage: {
146
- type: 'SendGridMailSend request property "content" should be a string.'
147
- }
148
- },
149
- filename: {
150
- type: 'string',
151
- description: 'Name of the attachment file.',
152
- errorMessage: {
153
- type: 'SendGridMailSend request property "filename" should be a string.'
154
- }
155
- },
156
- type: {
157
- type: 'string',
158
- description: "The mime type of the content you are attaching. For example, 'text/plain' or 'text/html'.",
159
- errorMessage: {
160
- type: 'SendGridMailSend request property "type" should be a string.'
161
- }
162
- },
163
- disposition: {
164
- type: 'string',
165
- errorMessage: {
166
- type: 'SendGridMailSend request property "disposition" should be a string.'
167
- }
168
- },
169
- contentId: {
170
- type: 'string',
171
- errorMessage: {
172
- type: 'SendGridMailSend request property "contentId" should be a string.'
173
- }
174
- }
175
- },
176
- errorMessage: {
177
- type: 'SendGridMailSend request property "attachments" should be an array of objects.'
178
- }
179
- },
180
- errorMessage: {
181
- type: 'SendGridMailSend request property "attachments" should be an array.'
182
- }
183
- },
184
- categories: {
185
- type: 'array',
186
- items: {
187
- type: 'string',
188
- errorMessage: {
189
- type: 'SendGridMailSend request property "categories" should be an array of strings.'
190
- }
191
- },
192
- errorMessage: {
193
- type: 'SendGridMailSend request property "categories" should be an array.'
194
- }
195
- },
196
- sendAt: {
197
- type: 'integer',
198
- description: "A unix timestamp allowing you to specify when you want your email to be delivered. You can't schedule more than 72 hours in advance."
199
- },
200
- templateId: {
201
- type: 'string',
202
- description: 'SendGrid email template ID to render email when sending.'
203
- }
204
- },
205
- errorMessage: {
206
- required: {
207
- to: 'SendGridMailSend request should have required property "to".'
208
- }
209
- }
210
- }
211
- },
212
- anyOf: [
213
- {
214
- $ref: '#/definitions/oneRequest'
215
- },
216
- {
217
- type: 'array',
218
- items: {
219
- $ref: '#/definitions/oneRequest'
220
- }
221
- },
222
- ],
223
- errorMessage: {
224
- anyOf: 'SendGridMailSend request properties should be an object or a array describing emails to send.'
225
- }
226
- };
@@ -1,140 +0,0 @@
1
- /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ export default {
16
- $schema: 'http://json-schema.org/draft-07/schema#',
17
- title: 'Lowdefy Connection Schema - SendGridMail',
18
- type: 'object',
19
- definitions: {
20
- email: {
21
- anyOf: [
22
- {
23
- type: 'string',
24
- examples: [
25
- 'someone@example.org',
26
- 'Name One <someone@example.org>'
27
- ],
28
- errorMessage: {
29
- type: 'SendGridMail connection property "{{ instancePath }}" should be a string.'
30
- }
31
- },
32
- {
33
- type: 'object',
34
- required: [
35
- 'name',
36
- 'email'
37
- ],
38
- properties: {
39
- name: {
40
- type: 'string',
41
- examples: [
42
- 'Some One'
43
- ],
44
- errorMessage: {
45
- type: 'SendGridMail connection property "{{ instancePath }}" should be a string.'
46
- }
47
- },
48
- email: {
49
- type: 'string',
50
- examples: [
51
- 'someone@example.org'
52
- ],
53
- errorMessage: {
54
- type: 'SendGridMail connection property "{{ instancePath }}" should be a string.'
55
- }
56
- }
57
- },
58
- errorMessage: {
59
- type: 'SendGridMail connection property "{{ instancePath }}" should be an object with properties "name" and "email".'
60
- }
61
- },
62
- ],
63
- errorMessage: {
64
- anyOf: 'SendGridMail connection property "{{ instancePath }}" should be an email address, or an object with properties "name" and "email".'
65
- }
66
- },
67
- emails: {
68
- anyOf: [
69
- {
70
- $ref: '#/definitions/email'
71
- },
72
- {
73
- type: 'array',
74
- items: {
75
- $ref: '#/definitions/email'
76
- },
77
- errorMessage: {
78
- type: 'SendGridMail connection property "{{ instancePath }}" should be a list of email addresses'
79
- }
80
- },
81
- ],
82
- errorMessage: {
83
- anyOf: 'SendGridMail connection property "{{ instancePath }}" should be an email address, or a list of email addresses.'
84
- }
85
- }
86
- },
87
- required: [
88
- 'apiKey',
89
- 'from'
90
- ],
91
- properties: {
92
- from: {
93
- $ref: '#/definitions/emails',
94
- description: 'Email address to send email from.'
95
- },
96
- apiKey: {
97
- type: 'string',
98
- description: 'SendGrid API key.',
99
- errorMessage: {
100
- type: 'SendGridMail connection property "apiKey" should be a string.'
101
- }
102
- },
103
- templateId: {
104
- type: 'string',
105
- description: 'SendGrid email template ID to render email when sending.',
106
- errorMessage: {
107
- type: 'SendGridMail connection property "templateId" should be a string.'
108
- }
109
- },
110
- mailSettings: {
111
- type: 'object',
112
- properties: {
113
- sandboxMode: {
114
- type: 'object',
115
- properties: {
116
- enable: {
117
- type: 'boolean',
118
- errorMessage: {
119
- type: 'SendGridMail connection property "mailSettings.sandboxMode.enable" should be a boolean.'
120
- }
121
- }
122
- },
123
- errorMessage: {
124
- type: 'SendGridMail connection property "mailSettings.sandboxMode" should be an object.'
125
- }
126
- }
127
- },
128
- errorMessage: {
129
- type: 'SendGridMail connection property "mailSettings" should be an object.'
130
- }
131
- }
132
- },
133
- errorMessage: {
134
- type: 'SendGridMail connection properties should be an object.',
135
- required: {
136
- apiKey: 'SendGridMail connection should have required property "apiKey".',
137
- from: 'SendGridMail connection should have required property "from".'
138
- }
139
- }
140
- };
@@ -1,15 +0,0 @@
1
- /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ export { default as SendGridMail } from './connections/SendGridMail/SendGridMail.js';
package/dist/types.js DELETED
@@ -1,19 +0,0 @@
1
- /* eslint-disable import/namespace */ /*
2
- Copyright 2020-2022 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ import * as connections from './connections.js';
16
- export default {
17
- connections: Object.keys(connections),
18
- requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)).flat()
19
- };