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

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 +32 -24
  2. package/dist/index.js +155 -220
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/checkMessageStatus.js +41 -0
  5. package/dist-esm/samples-dev/checkMessageStatus.js.map +1 -0
  6. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +8 -10
  7. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
  8. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +5 -7
  9. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
  10. package/dist-esm/samples-dev/sendEmailWithAttachments.js +7 -9
  11. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
  12. package/dist-esm/src/emailClient.js +19 -4
  13. package/dist-esm/src/emailClient.js.map +1 -1
  14. package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
  15. package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
  16. package/dist-esm/src/generated/src/models/index.js +80 -14
  17. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/src/models/mappers.js +87 -77
  19. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  20. package/dist-esm/src/generated/src/models/parameters.js +16 -14
  21. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  22. package/dist-esm/src/generated/src/operations/email.js +26 -72
  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 +74 -24
  28. package/dist-esm/test/public/emailClient.spec.js.map +1 -1
  29. package/dist-esm/test/public/utils/recordedClient.js +13 -9
  30. package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
  31. package/package.json +1 -2
  32. package/types/communication-email.d.ts +110 -132
  33. package/dist-esm/src/generated/src/lroImpl.js +0 -25
  34. package/dist-esm/src/generated/src/lroImpl.js.map +0 -1
@@ -1,14 +1,11 @@
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';
6
3
  import { TokenCredential } from '@azure/core-auth';
7
4
 
8
5
  /** An object representing the email address and its display name */
9
6
  export declare interface EmailAddress {
10
7
  /** Email address. */
11
- address: string;
8
+ email: string;
12
9
  /** Email display name. */
13
10
  displayName?: string;
14
11
  }
@@ -17,12 +14,48 @@ export declare interface EmailAddress {
17
14
  export declare interface EmailAttachment {
18
15
  /** Name of the attachment */
19
16
  name: string;
20
- /** MIME type of the content being attached. */
21
- contentType: string;
17
+ /** The type of attachment file. */
18
+ attachmentType: EmailAttachmentType;
22
19
  /** Base64 encoded contents of the attachment */
23
- contentInBase64: string;
20
+ contentBytesBase64: string;
24
21
  }
25
22
 
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
+
26
59
  /**
27
60
  * The Email service client.
28
61
  */
@@ -41,42 +74,79 @@ export declare class EmailClient {
41
74
  * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.
42
75
  * @param options - Optional. Options to configure the HTTP pipeline.
43
76
  */
44
- constructor(endpoint: string, credential: KeyCredential | TokenCredential, options?: EmailClientOptions);
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);
45
85
  /**
46
86
  * Queues an email message to be sent to one or more recipients
47
- * @param message - Message payload for sending an email
48
- * @param options - The options parameters.
87
+ * @param emailMessage - Message payload for sending an email
49
88
  */
50
- beginSend(message: EmailMessage, options?: EmailSendOptionalParams): Promise<PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>>;
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>;
51
95
  }
52
96
 
53
97
  /**
54
- * Client options used to configure Email Client API requests.
98
+ * Client options used to configure SMS Client API requests.
55
99
  */
56
100
  export declare interface EmailClientOptions extends CommonClientOptions {
57
101
  }
58
102
 
59
103
  /** Content of the email. */
60
- export declare type EmailContent = HtmlEmailContent | PlainTextEmailContent;
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;
61
131
 
62
132
  /** Message payload for sending an email */
63
133
  export declare interface EmailMessage {
64
134
  /** Custom email headers to be passed. */
65
- headers?: {
66
- [propertyName: string]: string;
67
- };
135
+ customHeaders?: EmailCustomHeader[];
68
136
  /** Sender email address from a verified domain. */
69
- senderAddress: string;
137
+ sender: string;
70
138
  /** Email content to be sent. */
71
139
  content: EmailContent;
140
+ /** The importance type for the email. */
141
+ importance?: EmailImportance;
72
142
  /** Recipients for the email. */
73
143
  recipients: EmailRecipients;
74
- /** List of attachments. Please note that we limit the total size of an email request (which includes attachments) to 10MB. */
144
+ /** list of attachments */
75
145
  attachments?: EmailAttachment[];
76
146
  /** Email addresses where recipients' replies will be sent to. */
77
147
  replyTo?: EmailAddress[];
78
148
  /** 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. */
79
- userEngagementTrackingDisabled?: boolean;
149
+ disableUserEngagementTracking?: boolean;
80
150
  }
81
151
 
82
152
  /** Recipients of the email */
@@ -89,125 +159,33 @@ export declare interface EmailRecipients {
89
159
  bcc?: EmailAddress[];
90
160
  }
91
161
 
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;
121
- }
122
-
123
162
  /**
124
- * Defines values for EmailSendStatus. \
125
- * {@link KnownEmailSendStatus} can be used interchangeably with EmailSendStatus,
126
- * this enum contains the known values that the service supports.
127
- * ### Known values supported by the service
128
- * **NotStarted** \
129
- * **Running** \
130
- * **Succeeded** \
131
- * **Failed** \
132
- * **Canceled**
163
+ * Results of a sent email.
133
164
  */
134
- export declare type EmailSendStatus = string;
135
-
136
- /** The resource management error additional info. */
137
- export declare interface ErrorAdditionalInfo {
165
+ export declare interface SendEmailResult {
138
166
  /**
139
- * The additional info type.
140
- * NOTE: This property will not be serialized. It can only be populated by the server.
167
+ * MessageId of the sent email.
141
168
  */
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"
169
+ messageId: string;
201
170
  }
202
171
 
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;
172
+ /**
173
+ * Defines values for SendStatus. \
174
+ * {@link KnownSendStatus} can be used interchangeably with SendStatus,
175
+ * this enum contains the known values that the service supports.
176
+ * ### 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.
180
+ */
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;
211
189
  }
212
190
 
213
191
  export { }
@@ -1,25 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __rest } from "tslib";
9
- export class LroImpl {
10
- constructor(sendOperationFn, args, spec, requestPath = spec.path, requestMethod = spec.httpMethod) {
11
- this.sendOperationFn = sendOperationFn;
12
- this.args = args;
13
- this.spec = spec;
14
- this.requestPath = requestPath;
15
- this.requestMethod = requestMethod;
16
- }
17
- async sendInitialRequest() {
18
- return this.sendOperationFn(this.args, this.spec);
19
- }
20
- async sendPollRequest(path) {
21
- const _a = this.spec, { requestBody } = _a, restSpec = __rest(_a, ["requestBody"]);
22
- return this.sendOperationFn(this.args, Object.assign(Object.assign({}, restSpec), { path, httpMethod: "GET" }));
23
- }
24
- }
25
- //# sourceMappingURL=lroImpl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lroImpl.js","sourceRoot":"","sources":["../../../../src/generated/src/lroImpl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAIH,MAAM,OAAO,OAAO;IAClB,YACU,eAAkE,EAClE,IAA6B,EAC7B,IAIe,EAChB,cAAsB,IAAI,CAAC,IAAK,EAChC,gBAAwB,IAAI,CAAC,UAAU;QARtC,oBAAe,GAAf,eAAe,CAAmD;QAClE,SAAI,GAAJ,IAAI,CAAyB;QAC7B,SAAI,GAAJ,IAAI,CAIW;QAChB,gBAAW,GAAX,WAAW,CAAqB;QAChC,kBAAa,GAAb,aAAa,CAA0B;IAC7C,CAAC;IACG,KAAK,CAAC,kBAAkB;QAC7B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IACM,KAAK,CAAC,eAAe,CAAC,IAAY;QACvC,MAAM,KAA+B,IAAI,CAAC,IAAI,EAAxC,EAAE,WAAW,OAA2B,EAAtB,QAAQ,cAA1B,eAA4B,CAAY,CAAC;QAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,kCAChC,QAAQ,KACX,IAAI,EACJ,UAAU,EAAE,KAAK,IACjB,CAAC;IACL,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { LongRunningOperation, LroResponse } from \"@azure/core-lro\";\n\nexport class LroImpl<T> implements LongRunningOperation<T> {\n constructor(\n private sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>,\n private args: Record<string, unknown>,\n private spec: {\n readonly requestBody?: unknown;\n readonly path?: string;\n readonly httpMethod: string;\n } & Record<string, any>,\n public requestPath: string = spec.path!,\n public requestMethod: string = spec.httpMethod\n ) {}\n public async sendInitialRequest(): Promise<LroResponse<T>> {\n return this.sendOperationFn(this.args, this.spec);\n }\n public async sendPollRequest(path: string): Promise<LroResponse<T>> {\n const { requestBody, ...restSpec } = this.spec;\n return this.sendOperationFn(this.args, {\n ...restSpec,\n path,\n httpMethod: \"GET\"\n });\n }\n}\n"]}