@azure/communication-email 1.0.0-alpha.20230303.3 → 1.0.0-alpha.20230306.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. package/README.md +24 -32
  2. package/dist/index.js +220 -155
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +10 -8
  5. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
  6. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -5
  7. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
  8. package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -7
  9. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
  10. package/dist-esm/src/emailClient.js +4 -19
  11. package/dist-esm/src/emailClient.js.map +1 -1
  12. package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
  13. package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
  14. package/dist-esm/src/generated/src/lroImpl.js +25 -0
  15. package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
  16. package/dist-esm/src/generated/src/models/index.js +14 -80
  17. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/src/models/mappers.js +77 -87
  19. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  20. package/dist-esm/src/generated/src/models/parameters.js +14 -16
  21. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  22. package/dist-esm/src/generated/src/operations/email.js +72 -26
  23. package/dist-esm/src/generated/src/operations/email.js.map +1 -1
  24. package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -1
  25. package/dist-esm/src/models.js +1 -1
  26. package/dist-esm/src/models.js.map +1 -1
  27. package/dist-esm/test/public/emailClient.spec.js +24 -74
  28. package/dist-esm/test/public/emailClient.spec.js.map +1 -1
  29. package/dist-esm/test/public/utils/recordedClient.js +9 -13
  30. package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
  31. package/package.json +3 -2
  32. package/types/communication-email.d.ts +132 -110
  33. package/dist-esm/samples-dev/checkMessageStatus.js +0 -41
  34. package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
@@ -1,11 +1,14 @@
1
1
  import { CommonClientOptions } from '@azure/core-client';
2
2
  import { KeyCredential } from '@azure/core-auth';
3
+ import { OperationOptions } from '@azure/core-client';
4
+ import { PollerLike } from '@azure/core-lro';
5
+ import { PollOperationState } from '@azure/core-lro';
3
6
  import { TokenCredential } from '@azure/core-auth';
4
7
 
5
8
  /** An object representing the email address and its display name */
6
9
  export declare interface EmailAddress {
7
10
  /** Email address. */
8
- email: string;
11
+ address: string;
9
12
  /** Email display name. */
10
13
  displayName?: string;
11
14
  }
@@ -14,48 +17,12 @@ export declare interface EmailAddress {
14
17
  export declare interface EmailAttachment {
15
18
  /** Name of the attachment */
16
19
  name: string;
17
- /** The type of attachment file. */
18
- attachmentType: EmailAttachmentType;
20
+ /** MIME type of the content being attached. */
21
+ contentType: string;
19
22
  /** Base64 encoded contents of the attachment */
20
- contentBytesBase64: string;
23
+ contentInBase64: string;
21
24
  }
22
25
 
23
- /**
24
- * Defines values for EmailAttachmentType. \
25
- * {@link KnownEmailAttachmentType} can be used interchangeably with EmailAttachmentType,
26
- * this enum contains the known values that the service supports.
27
- * ### Known values supported by the service
28
- * **avi** \
29
- * **bmp** \
30
- * **doc** \
31
- * **docm** \
32
- * **docx** \
33
- * **gif** \
34
- * **jpeg** \
35
- * **mp3** \
36
- * **one** \
37
- * **pdf** \
38
- * **png** \
39
- * **ppsm** \
40
- * **ppsx** \
41
- * **ppt** \
42
- * **pptm** \
43
- * **pptx** \
44
- * **pub** \
45
- * **rpmsg** \
46
- * **rtf** \
47
- * **tif** \
48
- * **txt** \
49
- * **vsd** \
50
- * **wav** \
51
- * **wma** \
52
- * **xls** \
53
- * **xlsb** \
54
- * **xlsm** \
55
- * **xlsx**
56
- */
57
- export declare type EmailAttachmentType = string;
58
-
59
26
  /**
60
27
  * The Email service client.
61
28
  */
@@ -74,79 +41,42 @@ export declare class EmailClient {
74
41
  * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.
75
42
  * @param options - Optional. Options to configure the HTTP pipeline.
76
43
  */
77
- constructor(endpoint: string, credential: KeyCredential, options?: EmailClientOptions);
78
- /**
79
- * Initializes a new instance of the EmailClient class using a TokenCredential.
80
- * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).
81
- * @param credential - TokenCredential that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.
82
- * @param options - Optional. Options to configure the HTTP pipeline.
83
- */
84
- constructor(endpoint: string, credential: TokenCredential, options?: EmailClientOptions);
44
+ constructor(endpoint: string, credential: KeyCredential | TokenCredential, options?: EmailClientOptions);
85
45
  /**
86
46
  * Queues an email message to be sent to one or more recipients
87
- * @param emailMessage - Message payload for sending an email
47
+ * @param message - Message payload for sending an email
48
+ * @param options - The options parameters.
88
49
  */
89
- send(emailMessage: EmailMessage): Promise<SendEmailResult>;
90
- /**
91
- * Gets the status of a message sent previously.
92
- * @param messageId - System generated message id (GUID) returned from a previous call to send email
93
- */
94
- getSendStatus(messageId: string): Promise<SendStatusResult>;
50
+ beginSend(message: EmailMessage, options?: EmailSendOptionalParams): Promise<PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>>;
95
51
  }
96
52
 
97
53
  /**
98
- * Client options used to configure SMS Client API requests.
54
+ * Client options used to configure Email Client API requests.
99
55
  */
100
56
  export declare interface EmailClientOptions extends CommonClientOptions {
101
57
  }
102
58
 
103
59
  /** Content of the email. */
104
- export declare interface EmailContent {
105
- /** Subject of the email message */
106
- subject: string;
107
- /** Plain text version of the email message. */
108
- plainText?: string;
109
- /** Html version of the email message. */
110
- html?: string;
111
- }
112
-
113
- /** Custom header for email. */
114
- export declare interface EmailCustomHeader {
115
- /** Header name. */
116
- name: string;
117
- /** Header value. */
118
- value: string;
119
- }
120
-
121
- /**
122
- * Defines values for EmailImportance. \
123
- * {@link KnownEmailImportance} can be used interchangeably with EmailImportance,
124
- * this enum contains the known values that the service supports.
125
- * ### Known values supported by the service
126
- * **high** \
127
- * **normal** \
128
- * **low**
129
- */
130
- export declare type EmailImportance = string;
60
+ export declare type EmailContent = HtmlEmailContent | PlainTextEmailContent;
131
61
 
132
62
  /** Message payload for sending an email */
133
63
  export declare interface EmailMessage {
134
64
  /** Custom email headers to be passed. */
135
- customHeaders?: EmailCustomHeader[];
65
+ headers?: {
66
+ [propertyName: string]: string;
67
+ };
136
68
  /** Sender email address from a verified domain. */
137
- sender: string;
69
+ senderAddress: string;
138
70
  /** Email content to be sent. */
139
71
  content: EmailContent;
140
- /** The importance type for the email. */
141
- importance?: EmailImportance;
142
72
  /** Recipients for the email. */
143
73
  recipients: EmailRecipients;
144
- /** list of attachments */
74
+ /** List of attachments. Please note that we limit the total size of an email request (which includes attachments) to 10MB. */
145
75
  attachments?: EmailAttachment[];
146
76
  /** Email addresses where recipients' replies will be sent to. */
147
77
  replyTo?: EmailAddress[];
148
78
  /** Indicates whether user engagement tracking should be disabled for this request if the resource-level user engagement tracking setting was already enabled in the control plane. */
149
- disableUserEngagementTracking?: boolean;
79
+ userEngagementTrackingDisabled?: boolean;
150
80
  }
151
81
 
152
82
  /** Recipients of the email */
@@ -159,33 +89,125 @@ export declare interface EmailRecipients {
159
89
  bcc?: EmailAddress[];
160
90
  }
161
91
 
162
- /**
163
- * Results of a sent email.
164
- */
165
- export declare interface SendEmailResult {
166
- /**
167
- * MessageId of the sent email.
168
- */
169
- messageId: string;
92
+ /** Defines headers for Email_send operation. */
93
+ export declare interface EmailSendHeaders {
94
+ /** Location url of where to poll the status of this operation from. */
95
+ operationLocation?: string;
96
+ /** This header will only be present when the operation status is a non-terminal status. It indicates the minimum amount of time in seconds to wait before polling for operation status again. */
97
+ retryAfter?: number;
98
+ }
99
+
100
+ /** Optional parameters for the beginSend method. */
101
+ export declare interface EmailSendOptionalParams extends OperationOptions {
102
+ /** This is the ID used by the status monitor for this long running operation. */
103
+ operationId?: string;
104
+ /** Delay to wait until next poll, in milliseconds. */
105
+ updateIntervalInMs?: number;
106
+ /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */
107
+ resumeFrom?: string;
108
+ }
109
+
110
+ /** Contains response data for the send operation. */
111
+ export declare type EmailSendResponse = EmailSendHeaders & EmailSendResult;
112
+
113
+ /** Status of the long running operation */
114
+ export declare interface EmailSendResult {
115
+ /** The unique id of the operation. Use a UUID. */
116
+ id: string;
117
+ /** Status of operation. */
118
+ status: EmailSendStatus;
119
+ /** Error details when status is a non-success terminal state. */
120
+ error?: ErrorDetail;
170
121
  }
171
122
 
172
123
  /**
173
- * Defines values for SendStatus. \
174
- * {@link KnownSendStatus} can be used interchangeably with SendStatus,
124
+ * Defines values for EmailSendStatus. \
125
+ * {@link KnownEmailSendStatus} can be used interchangeably with EmailSendStatus,
175
126
  * this enum contains the known values that the service supports.
176
127
  * ### Known values supported by the service
177
- * **queued**: The message has passed basic validations and has been queued to be processed further. \
178
- * **outForDelivery**: The message has been processed and is now out for delivery. \
179
- * **dropped**: The message could not be processed and was dropped.
128
+ * **NotStarted** \
129
+ * **Running** \
130
+ * **Succeeded** \
131
+ * **Failed** \
132
+ * **Canceled**
180
133
  */
181
- export declare type SendStatus = string;
182
-
183
- /** Status of an email message that was sent previously. */
184
- export declare interface SendStatusResult {
185
- /** System generated id of an email message sent. */
186
- messageId: string;
187
- /** The type indicating the status of a request. */
188
- status: SendStatus;
134
+ export declare type EmailSendStatus = string;
135
+
136
+ /** The resource management error additional info. */
137
+ export declare interface ErrorAdditionalInfo {
138
+ /**
139
+ * The additional info type.
140
+ * NOTE: This property will not be serialized. It can only be populated by the server.
141
+ */
142
+ readonly type?: string;
143
+ /**
144
+ * The additional info.
145
+ * NOTE: This property will not be serialized. It can only be populated by the server.
146
+ */
147
+ readonly info?: Record<string, unknown>;
148
+ }
149
+
150
+ /** The error detail. */
151
+ export declare interface ErrorDetail {
152
+ /**
153
+ * The error code.
154
+ * NOTE: This property will not be serialized. It can only be populated by the server.
155
+ */
156
+ readonly code?: string;
157
+ /**
158
+ * The error message.
159
+ * NOTE: This property will not be serialized. It can only be populated by the server.
160
+ */
161
+ readonly message?: string;
162
+ /**
163
+ * The error target.
164
+ * NOTE: This property will not be serialized. It can only be populated by the server.
165
+ */
166
+ readonly target?: string;
167
+ /**
168
+ * The error details.
169
+ * NOTE: This property will not be serialized. It can only be populated by the server.
170
+ */
171
+ readonly details?: ErrorDetail[];
172
+ /**
173
+ * The error additional info.
174
+ * NOTE: This property will not be serialized. It can only be populated by the server.
175
+ */
176
+ readonly additionalInfo?: ErrorAdditionalInfo[];
177
+ }
178
+
179
+ /** Content of the email with a required html property. */
180
+ export declare interface HtmlEmailContent {
181
+ /** Subject of the email message */
182
+ subject: string;
183
+ /** Plain text version of the email message. */
184
+ plainText?: string;
185
+ /** Html version of the email message. */
186
+ html: string;
187
+ }
188
+
189
+ /** Known values of {@link EmailSendStatus} that the service accepts. */
190
+ export declare enum KnownEmailSendStatus {
191
+ /** NotStarted */
192
+ NotStarted = "NotStarted",
193
+ /** Running */
194
+ Running = "Running",
195
+ /** Succeeded */
196
+ Succeeded = "Succeeded",
197
+ /** Failed */
198
+ Failed = "Failed",
199
+ /** Canceled */
200
+ Canceled = "Canceled"
201
+ }
202
+
203
+ /** Content of the email with a required plainText property. */
204
+ export declare interface PlainTextEmailContent {
205
+ /** Subject of the email message */
206
+ subject: string;
207
+ /** Plain text version of the email message. */
208
+ plainText: string;
209
+ /** Html version of the email message. */
210
+ html?: string;
189
211
  }
190
212
 
191
213
  export { }
@@ -1,41 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
- /**
4
- * @summary Checks the message status of a sent email
5
- */
6
- import { EmailClient } from "@azure/communication-email";
7
- // Load the .env file (you will need to set these environment variables)
8
- import * as dotenv from "dotenv";
9
- dotenv.config();
10
- const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";
11
- const senderAddress = process.env["SENDER_ADDRESS"] || "";
12
- const recipientAddress = process.env["RECIPIENT_ADDRESS"] || "";
13
- const getMessageStatusFromEmail = async () => {
14
- // Create the Email Client
15
- const emailClient = new EmailClient(connectionString);
16
- // Create the Email Message to be sent
17
- const emailMessage = {
18
- sender: senderAddress,
19
- content: {
20
- subject: "This is the subject",
21
- plainText: "This is the body",
22
- html: "<html><h1>This is the body</h1></html>",
23
- },
24
- recipients: {
25
- to: [{ email: recipientAddress, displayName: "Customer Name" }],
26
- },
27
- };
28
- try {
29
- // Send the email message
30
- const sendEmailResponse = await emailClient.send(emailMessage);
31
- // Use the message id to get the status of the email
32
- const messageId = sendEmailResponse.messageId || "";
33
- const getMessageStatusResponse = await emailClient.getSendStatus(messageId);
34
- console.log("Message Status: " + getMessageStatusResponse);
35
- }
36
- catch (error) {
37
- console.log(error);
38
- }
39
- };
40
- void getMessageStatusFromEmail();
41
- //# sourceMappingURL=checkMessageStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkMessageStatus.js","sourceRoot":"","sources":["../../samples-dev/checkMessageStatus.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAgB,MAAM,4BAA4B,CAAC;AAEvE,wEAAwE;AACxE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,IAAI,EAAE,CAAC;AAC9E,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;AAC1D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;AAEhE,MAAM,yBAAyB,GAAG,KAAK,IAAmB,EAAE;IAC1D,0BAA0B;IAC1B,MAAM,WAAW,GAAgB,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAEnE,sCAAsC;IACtC,MAAM,YAAY,GAAiB;QACjC,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACP,OAAO,EAAE,qBAAqB;YAC9B,SAAS,EAAE,kBAAkB;YAC7B,IAAI,EAAE,wCAAwC;SAC/C;QACD,UAAU,EAAE;YACV,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC;SAChE;KACF,CAAC;IAEF,IAAI;QACF,yBAAyB;QACzB,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE/D,oDAAoD;QACpD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,IAAI,EAAE,CAAC;QACpD,MAAM,wBAAwB,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAE5E,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,wBAAwB,CAAC,CAAC;KAC5D;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,KAAK,yBAAyB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * @summary Checks the message status of a sent email\n */\n\nimport { EmailClient, EmailMessage } from \"@azure/communication-email\";\n\n// Load the .env file (you will need to set these environment variables)\nimport * as dotenv from \"dotenv\";\ndotenv.config();\n\nconst connectionString = process.env[\"COMMUNICATION_CONNECTION_STRING\"] || \"\";\nconst senderAddress = process.env[\"SENDER_ADDRESS\"] || \"\";\nconst recipientAddress = process.env[\"RECIPIENT_ADDRESS\"] || \"\";\n\nconst getMessageStatusFromEmail = async (): Promise<void> => {\n // Create the Email Client\n const emailClient: EmailClient = new EmailClient(connectionString);\n\n // Create the Email Message to be sent\n const emailMessage: EmailMessage = {\n sender: senderAddress,\n content: {\n subject: \"This is the subject\",\n plainText: \"This is the body\",\n html: \"<html><h1>This is the body</h1></html>\",\n },\n recipients: {\n to: [{ email: recipientAddress, displayName: \"Customer Name\" }],\n },\n };\n\n try {\n // Send the email message\n const sendEmailResponse = await emailClient.send(emailMessage);\n\n // Use the message id to get the status of the email\n const messageId = sendEmailResponse.messageId || \"\";\n const getMessageStatusResponse = await emailClient.getSendStatus(messageId);\n\n console.log(\"Message Status: \" + getMessageStatusResponse);\n } catch (error) {\n console.log(error);\n }\n};\n\nvoid getMessageStatusFromEmail();\n"]}