@azure/communication-email 1.0.0-alpha.20230303.2 → 1.0.0-alpha.20230303.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +32 -24
- package/dist/index.js +155 -220
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/checkMessageStatus.js +41 -0
- package/dist-esm/samples-dev/checkMessageStatus.js.map +1 -0
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +8 -10
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +5 -7
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +7 -9
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +19 -4
- package/dist-esm/src/emailClient.js.map +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/models/index.js +80 -14
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +87 -77
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +16 -14
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +26 -72
- package/dist-esm/src/generated/src/operations/email.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -1
- package/dist-esm/src/models.js +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/test/public/emailClient.spec.js +74 -24
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +13 -9
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +2 -3
- package/types/communication-email.d.ts +110 -132
- package/dist-esm/src/generated/src/lroImpl.js +0 -25
- package/dist-esm/src/generated/src/lroImpl.js.map +0 -1
@@ -8,8 +8,6 @@
|
|
8
8
|
import * as coreClient from "@azure/core-client";
|
9
9
|
import * as Mappers from "../models/mappers";
|
10
10
|
import * as Parameters from "../models/parameters";
|
11
|
-
import { LroEngine } from "@azure/core-lro";
|
12
|
-
import { LroImpl } from "../lroImpl";
|
13
11
|
/** Class containing Email operations. */
|
14
12
|
export class EmailImpl {
|
15
13
|
/**
|
@@ -20,78 +18,47 @@ export class EmailImpl {
|
|
20
18
|
this.client = client;
|
21
19
|
}
|
22
20
|
/**
|
23
|
-
* Gets the status of
|
24
|
-
* @param
|
25
|
-
* email
|
21
|
+
* Gets the status of a message sent previously.
|
22
|
+
* @param messageId System generated message id (GUID) returned from a previous call to send email
|
26
23
|
* @param options The options parameters.
|
27
24
|
*/
|
28
|
-
|
29
|
-
return this.client.sendOperationRequest({
|
25
|
+
getSendStatus(messageId, options) {
|
26
|
+
return this.client.sendOperationRequest({ messageId, options }, getSendStatusOperationSpec);
|
30
27
|
}
|
31
28
|
/**
|
32
29
|
* Queues an email message to be sent to one or more recipients
|
33
|
-
* @param
|
30
|
+
* @param repeatabilityRequestId If specified, the client directs that the request is repeatable; that
|
31
|
+
* is, that the client can make the request multiple times with the same Repeatability-Request-Id and
|
32
|
+
* get back an appropriate response without the server executing the request multiple times. The value
|
33
|
+
* of the Repeatability-Request-Id is an opaque string representing a client-generated, globally unique
|
34
|
+
* for all time, identifier for the request. It is recommended to use version 4 (random) UUIDs.
|
35
|
+
* @param repeatabilityFirstSent Must be sent by clients to specify that a request is repeatable.
|
36
|
+
* Repeatability-First-Sent is used to specify the date and time at which the request was first created
|
37
|
+
* in the IMF-fix date form of HTTP-date as defined in RFC7231. eg- Tue, 26 Mar 2019 16:06:51 GMT
|
38
|
+
* @param emailMessage Message payload for sending an email
|
34
39
|
* @param options The options parameters.
|
35
40
|
*/
|
36
|
-
|
37
|
-
|
38
|
-
return this.client.sendOperationRequest(args, spec);
|
39
|
-
};
|
40
|
-
const sendOperation = async (args, spec) => {
|
41
|
-
var _a;
|
42
|
-
let currentRawResponse = undefined;
|
43
|
-
const providedCallback = (_a = args.options) === null || _a === void 0 ? void 0 : _a.onResponse;
|
44
|
-
const callback = (rawResponse, flatResponse) => {
|
45
|
-
currentRawResponse = rawResponse;
|
46
|
-
providedCallback === null || providedCallback === void 0 ? void 0 : providedCallback(rawResponse, flatResponse);
|
47
|
-
};
|
48
|
-
const updatedArgs = Object.assign(Object.assign({}, args), { options: Object.assign(Object.assign({}, args.options), { onResponse: callback }) });
|
49
|
-
const flatResponse = await directSendOperation(updatedArgs, spec);
|
50
|
-
return {
|
51
|
-
flatResponse,
|
52
|
-
rawResponse: {
|
53
|
-
statusCode: currentRawResponse.status,
|
54
|
-
body: currentRawResponse.parsedBody,
|
55
|
-
headers: currentRawResponse.headers.toJSON()
|
56
|
-
}
|
57
|
-
};
|
58
|
-
};
|
59
|
-
const lro = new LroImpl(sendOperation, { message, options }, sendOperationSpec);
|
60
|
-
const poller = new LroEngine(lro, {
|
61
|
-
resumeFrom: options === null || options === void 0 ? void 0 : options.resumeFrom,
|
62
|
-
intervalInMs: options === null || options === void 0 ? void 0 : options.updateIntervalInMs,
|
63
|
-
lroResourceLocationConfig: "azure-async-operation"
|
64
|
-
});
|
65
|
-
await poller.poll();
|
66
|
-
return poller;
|
67
|
-
}
|
68
|
-
/**
|
69
|
-
* Queues an email message to be sent to one or more recipients
|
70
|
-
* @param message Message payload for sending an email
|
71
|
-
* @param options The options parameters.
|
72
|
-
*/
|
73
|
-
async beginSendAndWait(message, options) {
|
74
|
-
const poller = await this.beginSend(message, options);
|
75
|
-
return poller.pollUntilDone();
|
41
|
+
send(repeatabilityRequestId, repeatabilityFirstSent, emailMessage, options) {
|
42
|
+
return this.client.sendOperationRequest({ repeatabilityRequestId, repeatabilityFirstSent, emailMessage, options }, sendOperationSpec);
|
76
43
|
}
|
77
44
|
}
|
78
45
|
// Operation Specifications
|
79
46
|
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
80
|
-
const
|
81
|
-
path: "/emails/
|
47
|
+
const getSendStatusOperationSpec = {
|
48
|
+
path: "/emails/{messageId}/status",
|
82
49
|
httpMethod: "GET",
|
83
50
|
responses: {
|
84
51
|
200: {
|
85
|
-
bodyMapper: Mappers.
|
86
|
-
headersMapper: Mappers.
|
52
|
+
bodyMapper: Mappers.SendStatusResult,
|
53
|
+
headersMapper: Mappers.EmailGetSendStatusHeaders
|
87
54
|
},
|
88
55
|
default: {
|
89
|
-
bodyMapper: Mappers.
|
90
|
-
headersMapper: Mappers.
|
56
|
+
bodyMapper: Mappers.CommunicationErrorResponse,
|
57
|
+
headersMapper: Mappers.EmailGetSendStatusExceptionHeaders
|
91
58
|
}
|
92
59
|
},
|
93
60
|
queryParameters: [Parameters.apiVersion],
|
94
|
-
urlParameters: [Parameters.endpoint, Parameters.
|
61
|
+
urlParameters: [Parameters.endpoint, Parameters.messageId],
|
95
62
|
headerParameters: [Parameters.accept],
|
96
63
|
serializer
|
97
64
|
};
|
@@ -99,35 +66,22 @@ const sendOperationSpec = {
|
|
99
66
|
path: "/emails:send",
|
100
67
|
httpMethod: "POST",
|
101
68
|
responses: {
|
102
|
-
200: {
|
103
|
-
bodyMapper: Mappers.EmailSendResult,
|
104
|
-
headersMapper: Mappers.EmailSendHeaders
|
105
|
-
},
|
106
|
-
201: {
|
107
|
-
bodyMapper: Mappers.EmailSendResult,
|
108
|
-
headersMapper: Mappers.EmailSendHeaders
|
109
|
-
},
|
110
69
|
202: {
|
111
|
-
bodyMapper: Mappers.EmailSendResult,
|
112
|
-
headersMapper: Mappers.EmailSendHeaders
|
113
|
-
},
|
114
|
-
204: {
|
115
|
-
bodyMapper: Mappers.EmailSendResult,
|
116
70
|
headersMapper: Mappers.EmailSendHeaders
|
117
71
|
},
|
118
72
|
default: {
|
119
|
-
bodyMapper: Mappers.
|
73
|
+
bodyMapper: Mappers.CommunicationErrorResponse,
|
120
74
|
headersMapper: Mappers.EmailSendExceptionHeaders
|
121
75
|
}
|
122
76
|
},
|
123
|
-
requestBody: Parameters.
|
77
|
+
requestBody: Parameters.emailMessage,
|
124
78
|
queryParameters: [Parameters.apiVersion],
|
125
79
|
urlParameters: [Parameters.endpoint],
|
126
80
|
headerParameters: [
|
127
81
|
Parameters.accept,
|
128
82
|
Parameters.contentType,
|
129
|
-
Parameters.
|
130
|
-
Parameters.
|
83
|
+
Parameters.repeatabilityRequestId,
|
84
|
+
Parameters.repeatabilityFirstSent
|
131
85
|
],
|
132
86
|
mediaType: "json",
|
133
87
|
serializer
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/email.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/email.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAUnD,yCAAyC;AACzC,MAAM,OAAO,SAAS;IAGpB;;;OAGG;IACH,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,aAAa,CACX,SAAiB,EACjB,OAA0C;QAE1C,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CACrC,EAAE,SAAS,EAAE,OAAO,EAAE,EACtB,0BAA0B,CAC3B,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,CACF,sBAA8B,EAC9B,sBAA8B,EAC9B,YAA0B,EAC1B,OAAiC;QAEjC,OAAO,IAAI,CAAC,MA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C,sBAAsB;KAClC;IACD,SAAS,EAAE,MAAM;IACjB,UAAU;CACX,CAAC","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 { Email } from \"../operationsInterfaces\";\nimport * as coreClient from \"@azure/core-client\";\nimport * as Mappers from \"../models/mappers\";\nimport * as Parameters from \"../models/parameters\";\nimport { EmailRestApiClient } from \"../emailRestApiClient\";\nimport {\n EmailGetSendStatusOptionalParams,\n EmailGetSendStatusResponse,\n EmailMessage,\n EmailSendOptionalParams,\n EmailSendResponse\n} from \"../models\";\n\n/** Class containing Email operations. */\nexport class EmailImpl implements Email {\n private readonly client: EmailRestApiClient;\n\n /**\n * Initialize a new instance of the class Email class.\n * @param client Reference to the service client\n */\n constructor(client: EmailRestApiClient) {\n this.client = client;\n }\n\n /**\n * Gets the status of a message sent previously.\n * @param messageId System generated message id (GUID) returned from a previous call to send email\n * @param options The options parameters.\n */\n getSendStatus(\n messageId: string,\n options?: EmailGetSendStatusOptionalParams\n ): Promise<EmailGetSendStatusResponse> {\n return this.client.sendOperationRequest(\n { messageId, options },\n getSendStatusOperationSpec\n );\n }\n\n /**\n * Queues an email message to be sent to one or more recipients\n * @param repeatabilityRequestId If specified, the client directs that the request is repeatable; that\n * is, that the client can make the request multiple times with the same Repeatability-Request-Id and\n * get back an appropriate response without the server executing the request multiple times. The value\n * of the Repeatability-Request-Id is an opaque string representing a client-generated, globally unique\n * for all time, identifier for the request. It is recommended to use version 4 (random) UUIDs.\n * @param repeatabilityFirstSent Must be sent by clients to specify that a request is repeatable.\n * Repeatability-First-Sent is used to specify the date and time at which the request was first created\n * in the IMF-fix date form of HTTP-date as defined in RFC7231. eg- Tue, 26 Mar 2019 16:06:51 GMT\n * @param emailMessage Message payload for sending an email\n * @param options The options parameters.\n */\n send(\n repeatabilityRequestId: string,\n repeatabilityFirstSent: string,\n emailMessage: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<EmailSendResponse> {\n return this.client.sendOperationRequest(\n { repeatabilityRequestId, repeatabilityFirstSent, emailMessage, options },\n sendOperationSpec\n );\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst getSendStatusOperationSpec: coreClient.OperationSpec = {\n path: \"/emails/{messageId}/status\",\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.SendStatusResult,\n headersMapper: Mappers.EmailGetSendStatusHeaders\n },\n default: {\n bodyMapper: Mappers.CommunicationErrorResponse,\n headersMapper: Mappers.EmailGetSendStatusExceptionHeaders\n }\n },\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint, Parameters.messageId],\n headerParameters: [Parameters.accept],\n serializer\n};\nconst sendOperationSpec: coreClient.OperationSpec = {\n path: \"/emails:send\",\n httpMethod: \"POST\",\n responses: {\n 202: {\n headersMapper: Mappers.EmailSendHeaders\n },\n default: {\n bodyMapper: Mappers.CommunicationErrorResponse,\n headersMapper: Mappers.EmailSendExceptionHeaders\n }\n },\n requestBody: Parameters.emailMessage,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [\n Parameters.accept,\n Parameters.contentType,\n Parameters.repeatabilityRequestId,\n Parameters.repeatabilityFirstSent\n ],\n mediaType: \"json\",\n serializer\n};\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../src/generated/src/operationsInterfaces/email.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","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 {
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../src/generated/src/operationsInterfaces/email.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","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 {\n EmailGetSendStatusOptionalParams,\n EmailGetSendStatusResponse,\n EmailMessage,\n EmailSendOptionalParams,\n EmailSendResponse\n} from \"../models\";\n\n/** Interface representing a Email. */\nexport interface Email {\n /**\n * Gets the status of a message sent previously.\n * @param messageId System generated message id (GUID) returned from a previous call to send email\n * @param options The options parameters.\n */\n getSendStatus(\n messageId: string,\n options?: EmailGetSendStatusOptionalParams\n ): Promise<EmailGetSendStatusResponse>;\n /**\n * Queues an email message to be sent to one or more recipients\n * @param repeatabilityRequestId If specified, the client directs that the request is repeatable; that\n * is, that the client can make the request multiple times with the same Repeatability-Request-Id and\n * get back an appropriate response without the server executing the request multiple times. The value\n * of the Repeatability-Request-Id is an opaque string representing a client-generated, globally unique\n * for all time, identifier for the request. It is recommended to use version 4 (random) UUIDs.\n * @param repeatabilityFirstSent Must be sent by clients to specify that a request is repeatable.\n * Repeatability-First-Sent is used to specify the date and time at which the request was first created\n * in the IMF-fix date form of HTTP-date as defined in RFC7231. eg- Tue, 26 Mar 2019 16:06:51 GMT\n * @param emailMessage Message payload for sending an email\n * @param options The options parameters.\n */\n send(\n repeatabilityRequestId: string,\n repeatabilityFirstSent: string,\n emailMessage: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<EmailSendResponse>;\n}\n"]}
|
package/dist-esm/src/models.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions } from \"@azure/core-client\";\n\n/**\n * Client options used to configure SMS Client API requests.\n */\nexport interface EmailClientOptions extends CommonClientOptions {}\n\n/**\n * Results of a sent email.\n */\nexport interface SendEmailResult {\n /**\n * MessageId of the sent email.\n */\n messageId: string;\n}\n\nexport {\n EmailMessage,\n EmailCustomHeader,\n EmailContent,\n EmailImportance,\n EmailRecipients,\n EmailAddress,\n EmailAttachment,\n EmailAttachmentType,\n SendStatus,\n SendStatusResult,\n} from \"./generated/src/models\";\n"]}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
|
-
import { KnownEmailSendStatus } from "../../src";
|
4
3
|
import { env } from "@azure-tools/test-recorder";
|
5
4
|
import { assert } from "chai";
|
6
5
|
import { createRecordedEmailClientWithConnectionString } from "./utils/recordedClient";
|
@@ -18,11 +17,11 @@ describe(`EmailClient [Playback/Live]`, function () {
|
|
18
17
|
});
|
19
18
|
it("successfully sends an email to a single recipient", async function () {
|
20
19
|
const emailMessage = {
|
21
|
-
|
20
|
+
sender: env.SENDER_ADDRESS || "",
|
22
21
|
recipients: {
|
23
22
|
to: [
|
24
23
|
{
|
25
|
-
|
24
|
+
email: env.RECIPIENT_ADDRESS || "",
|
26
25
|
displayName: "someRecipient",
|
27
26
|
},
|
28
27
|
],
|
@@ -33,34 +32,33 @@ describe(`EmailClient [Playback/Live]`, function () {
|
|
33
32
|
html: "<html><h1>someHtmlBody</html>",
|
34
33
|
},
|
35
34
|
};
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
}).timeout(120000);
|
35
|
+
const response = await client.send(emailMessage);
|
36
|
+
assert.isNotNull(response.messageId);
|
37
|
+
}).timeout(5000);
|
40
38
|
it("successfully sends an email to multiple types of recipients", async function () {
|
41
39
|
var _a, _b, _c, _d, _e;
|
42
40
|
const emailMessage = {
|
43
|
-
|
41
|
+
sender: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
|
44
42
|
recipients: {
|
45
43
|
to: [
|
46
44
|
{
|
47
|
-
|
45
|
+
email: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
|
48
46
|
displayName: "someRecipient",
|
49
47
|
},
|
50
48
|
{
|
51
|
-
|
49
|
+
email: (_c = env.RECIPIENT_ADDRESS) !== null && _c !== void 0 ? _c : "",
|
52
50
|
displayName: "someRecipient",
|
53
51
|
},
|
54
52
|
],
|
55
53
|
cc: [
|
56
54
|
{
|
57
|
-
|
55
|
+
email: (_d = env.RECIPIENT_ADDRESS) !== null && _d !== void 0 ? _d : "",
|
58
56
|
displayName: "someRecipient",
|
59
57
|
},
|
60
58
|
],
|
61
59
|
bcc: [
|
62
60
|
{
|
63
|
-
|
61
|
+
email: (_e = env.RECIPIENT_ADDRESS) !== null && _e !== void 0 ? _e : "",
|
64
62
|
displayName: "someRecipient",
|
65
63
|
},
|
66
64
|
],
|
@@ -71,18 +69,17 @@ describe(`EmailClient [Playback/Live]`, function () {
|
|
71
69
|
html: "<html><h1>someHtmlBody</html>",
|
72
70
|
},
|
73
71
|
};
|
74
|
-
const
|
75
|
-
|
76
|
-
|
77
|
-
}).timeout(120000);
|
72
|
+
const response = await client.send(emailMessage);
|
73
|
+
assert.isNotNull(response.messageId);
|
74
|
+
}).timeout(5000);
|
78
75
|
it("successfully sends an email with an attachment", async function () {
|
79
76
|
var _a, _b;
|
80
77
|
const emailMessage = {
|
81
|
-
|
78
|
+
sender: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
|
82
79
|
recipients: {
|
83
80
|
to: [
|
84
81
|
{
|
85
|
-
|
82
|
+
email: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
|
86
83
|
displayName: "someRecipient",
|
87
84
|
},
|
88
85
|
],
|
@@ -95,14 +92,67 @@ describe(`EmailClient [Playback/Live]`, function () {
|
|
95
92
|
attachments: [
|
96
93
|
{
|
97
94
|
name: "readme.txt",
|
98
|
-
|
99
|
-
|
95
|
+
attachmentType: "txt",
|
96
|
+
contentBytesBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
|
100
97
|
},
|
101
98
|
],
|
102
99
|
};
|
103
|
-
const
|
104
|
-
|
105
|
-
|
106
|
-
|
100
|
+
const response = await client.send(emailMessage);
|
101
|
+
assert.isNotNull(response.messageId);
|
102
|
+
}).timeout(5000);
|
103
|
+
it("successfully retrieves the email status with the returned message id", async function () {
|
104
|
+
var _a, _b;
|
105
|
+
const emailMessage = {
|
106
|
+
sender: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
|
107
|
+
recipients: {
|
108
|
+
to: [
|
109
|
+
{
|
110
|
+
email: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
|
111
|
+
displayName: "someRecipient",
|
112
|
+
},
|
113
|
+
],
|
114
|
+
},
|
115
|
+
content: {
|
116
|
+
subject: "someSubject",
|
117
|
+
plainText: "somePlainTextBody",
|
118
|
+
html: "<html><h1>someHtmlBody</html>",
|
119
|
+
},
|
120
|
+
};
|
121
|
+
const response = await client.send(emailMessage);
|
122
|
+
const messageId = response.messageId;
|
123
|
+
if (messageId) {
|
124
|
+
const messageStatusResponse = await client.getSendStatus(messageId);
|
125
|
+
assert.isNotNull(messageStatusResponse.status);
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
assert.fail();
|
129
|
+
}
|
130
|
+
}).timeout(5000);
|
131
|
+
it("successfully sends an email with an empty to field", async function () {
|
132
|
+
const emailMessage = {
|
133
|
+
sender: env.SENDER_ADDRESS || "",
|
134
|
+
recipients: {
|
135
|
+
cc: [
|
136
|
+
{
|
137
|
+
email: env.RECIPIENT_ADDRESS || "",
|
138
|
+
displayName: "someRecipient",
|
139
|
+
},
|
140
|
+
],
|
141
|
+
bcc: [
|
142
|
+
{
|
143
|
+
email: env.RECIPIENT_ADDRESS || "",
|
144
|
+
displayName: "someRecipient",
|
145
|
+
},
|
146
|
+
],
|
147
|
+
},
|
148
|
+
content: {
|
149
|
+
subject: "someSubject",
|
150
|
+
plainText: "somePlainTextBody",
|
151
|
+
html: "<html><h1>someHtmlBody</html>",
|
152
|
+
},
|
153
|
+
};
|
154
|
+
const response = await client.send(emailMessage);
|
155
|
+
assert.isNotNull(response.messageId);
|
156
|
+
}).timeout(5000);
|
107
157
|
});
|
108
158
|
//# sourceMappingURL=emailClient.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"emailClient.spec.js","sourceRoot":"","sources":["../../../test/public/emailClient.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
1
|
+
{"version":3,"file":"emailClient.spec.js","sourceRoot":"","sources":["../../../test/public/emailClient.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAY,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,6CAA6C,EAAE,MAAM,wBAAwB,CAAC;AAEvF,QAAQ,CAAC,6BAA6B,EAAE;IACtC,IAAI,QAAkB,CAAC;IACvB,IAAI,MAAmB,CAAC;IAExB,UAAU,CAAC,KAAK;QACd,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,6CAA6C,CAAC,IAAI,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK;;QACb,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,SAAS,EAAE,CAAA,EAAE;YAClC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SACvB;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK;QAC3D,MAAM,YAAY,GAAiB;YACjC,MAAM,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE;YAChC,UAAU,EAAE;gBACV,EAAE,EAAE;oB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AS,GAAG,QAAQ,CAAC,SAAS,CAAC;QACrC,IAAI,SAAS,EAAE;YACb,MAAM,qBAAqB,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YACpE,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;SAChD;aAAM;YACL,MAAM,CAAC,IAAI,EAAE,CAAC;SACf;IACH,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,EAAE,CAAC,oDAAoD,EAAE,KAAK;QAC5D,MAAM,YAAY,GAAiB;YACjC,MAAM,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE;YAChC,UAAU,EAAE;gBACV,EAAE,EAAE;oBACF;wBACE,KAAK,EAAE,GAAG,CAAC,iBAAiB,IAAI,EAAE;wBAClC,WAAW,EAAE,eAAe;qBAC7B;iBACF;gBACD,GAAG,EAAE;oBACH;wBACE,KAAK,EAAE,GAAG,CAAC,iBAAiB,IAAI,EAAE;wBAClC,WAAW,EAAE,eAAe;qBAC7B;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;gBACtB,SAAS,EAAE,mBAAmB;gBAC9B,IAAI,EAAE,+BAA+B;aACtC;SACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjD,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EmailClient, EmailMessage } from \"../../src\";\nimport { Recorder, env } from \"@azure-tools/test-recorder\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport { createRecordedEmailClientWithConnectionString } from \"./utils/recordedClient\";\n\ndescribe(`EmailClient [Playback/Live]`, function () {\n let recorder: Recorder;\n let client: EmailClient;\n\n beforeEach(async function (this: Context) {\n ({ client, recorder } = await createRecordedEmailClientWithConnectionString(this));\n });\n\n afterEach(async function (this: Context) {\n if (!this.currentTest?.isPending()) {\n await recorder.stop();\n }\n });\n\n it(\"successfully sends an email to a single recipient\", async function () {\n const emailMessage: EmailMessage = {\n sender: env.SENDER_ADDRESS || \"\",\n recipients: {\n to: [\n {\n email: env.RECIPIENT_ADDRESS || \"\",\n displayName: \"someRecipient\",\n },\n ],\n },\n content: {\n subject: \"someSubject\",\n plainText: \"somePlainTextBody\",\n html: \"<html><h1>someHtmlBody</html>\",\n },\n };\n\n const response = await client.send(emailMessage);\n assert.isNotNull(response.messageId);\n }).timeout(5000);\n\n it(\"successfully sends an email to multiple types of recipients\", async function () {\n const emailMessage: EmailMessage = {\n sender: env.SENDER_ADDRESS ?? \"\",\n recipients: {\n to: [\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n cc: [\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n bcc: [\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n },\n content: {\n subject: \"someSubject\",\n plainText: \"somePlainTextBody\",\n html: \"<html><h1>someHtmlBody</html>\",\n },\n };\n\n const response = await client.send(emailMessage);\n assert.isNotNull(response.messageId);\n }).timeout(5000);\n\n it(\"successfully sends an email with an attachment\", async function () {\n const emailMessage: EmailMessage = {\n sender: env.SENDER_ADDRESS ?? \"\",\n recipients: {\n to: [\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n },\n content: {\n subject: \"someSubject\",\n plainText: \"somePlainTextBody\",\n html: \"<html><h1>someHtmlBody</html>\",\n },\n attachments: [\n {\n name: \"readme.txt\",\n attachmentType: \"txt\",\n contentBytesBase64: \"ZW1haWwgdGVzdCBhdHRhY2htZW50\",\n },\n ],\n };\n\n const response = await client.send(emailMessage);\n assert.isNotNull(response.messageId);\n }).timeout(5000);\n\n it(\"successfully retrieves the email status with the returned message id\", async function () {\n const emailMessage: EmailMessage = {\n sender: env.SENDER_ADDRESS ?? \"\",\n recipients: {\n to: [\n {\n email: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n },\n content: {\n subject: \"someSubject\",\n plainText: \"somePlainTextBody\",\n html: \"<html><h1>someHtmlBody</html>\",\n },\n };\n\n const response = await client.send(emailMessage);\n const messageId = response.messageId;\n if (messageId) {\n const messageStatusResponse = await client.getSendStatus(messageId);\n assert.isNotNull(messageStatusResponse.status);\n } else {\n assert.fail();\n }\n }).timeout(5000);\n\n it(\"successfully sends an email with an empty to field\", async function () {\n const emailMessage: EmailMessage = {\n sender: env.SENDER_ADDRESS || \"\",\n recipients: {\n cc: [\n {\n email: env.RECIPIENT_ADDRESS || \"\",\n displayName: \"someRecipient\",\n },\n ],\n bcc: [\n {\n email: env.RECIPIENT_ADDRESS || \"\",\n displayName: \"someRecipient\",\n },\n ],\n },\n content: {\n subject: \"someSubject\",\n plainText: \"somePlainTextBody\",\n html: \"<html><h1>someHtmlBody</html>\",\n },\n };\n\n const response = await client.send(emailMessage);\n assert.isNotNull(response.messageId);\n }).timeout(5000);\n});\n"]}
|
@@ -15,24 +15,28 @@ const sanitizerOptions = {
|
|
15
15
|
},
|
16
16
|
],
|
17
17
|
headerSanitizers: [
|
18
|
-
{ key: "
|
19
|
-
{
|
20
|
-
|
21
|
-
|
22
|
-
},
|
18
|
+
{ key: "repeatability-first-sent", value: "Sanitized" },
|
19
|
+
{ key: "repeatability-request-id", value: "Sanitized" },
|
20
|
+
{ key: "x-ms-client-request-id", value: "Sanitized" },
|
21
|
+
{ key: "x-ms-date", value: "Sanitized" },
|
22
|
+
{ key: "Date", value: "Sanitized" },
|
23
|
+
{ key: "Date", value: "Sanitized" },
|
24
|
+
{ key: "X-Azure-Ref", value: "Sanitized" },
|
25
|
+
{ key: "x-ms-request-id", value: "Sanitized" },
|
26
|
+
{ key: "Operation-Location", value: "https://someEndpoint/emails/someMessageId/status" },
|
23
27
|
],
|
24
28
|
uriSanitizers: [
|
25
29
|
{
|
26
30
|
regex: true,
|
27
|
-
target: `emails
|
28
|
-
value: "emails/
|
31
|
+
target: `emails/.*/status`,
|
32
|
+
value: "emails/Sanitized/status",
|
29
33
|
},
|
30
34
|
],
|
31
35
|
bodySanitizers: [
|
32
36
|
{
|
33
37
|
regex: true,
|
34
|
-
target: `"
|
35
|
-
value: `"
|
38
|
+
target: `"messageId"\\s?:\\s?"[^"]*"`,
|
39
|
+
value: `"messageId":"Sanitized"`,
|
36
40
|
},
|
37
41
|
],
|
38
42
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"recordedClient.js","sourceRoot":"","sources":["../../../../test/public/utils/recordedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,QAAQ,EAAoB,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAO3C,MAAM,mBAAmB,GAA4B;IACnD,qCAAqC,EACnC,2DAA2D;IAC7D,cAAc,EAAE,wBAAwB;IACxC,iBAAiB,EAAE,0BAA0B;CAC9C,CAAC;AAEF,MAAM,gBAAgB,GAAqB;IACzC,0BAA0B,EAAE;QAC1B;YACE,gBAAgB,EAAE,GAAG,CAAC,qCAAqC;YAC3D,cAAc,EAAE,mBAAmB,CAAC,uCAAuC,CAAC;SAC7E;KACF;IACD,gBAAgB,EAAE;QAChB,EAAE,GAAG,EAAE,
|
1
|
+
{"version":3,"file":"recordedClient.js","sourceRoot":"","sources":["../../../../test/public/utils/recordedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,QAAQ,EAAoB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MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAC,CAAC;IAC9C,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IACvE,MAAM,QAAQ,CAAC,UAAU,CAAC,sBAAsB,EAAE;QAChD,eAAe,EAAE;YACf,iBAAiB;YACjB,qBAAqB,EAAE,4CAA4C;SACpE;KACF,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,6CAA6C,CACjE,OAAgB;;IAEhB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAG,IAAI,WAAW,CAC5B,MAAA,GAAG,CAAC,qCAAqC,mCAAI,EAAE,EAC/C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC,CACpC,CAAC;IACF,OAAO;QACL,MAAM,EAAE,MAAM;QACd,QAAQ;KACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Context, Test } from \"mocha\";\nimport { Recorder, SanitizerOptions, env } from \"@azure-tools/test-recorder\";\nimport { EmailClient } from \"../../../src\";\n\nexport interface RecordedEmailClient {\n client: EmailClient;\n recorder: Recorder;\n}\n\nconst envSetupForPlayback: { [k: string]: string } = {\n COMMUNICATION_CONNECTION_STRING_EMAIL:\n \"endpoint=https://someEndpoint/;accesskey=someAccessKeyw==\",\n SENDER_ADDRESS: \"someSender@contoso.com\",\n RECIPIENT_ADDRESS: \"someRecipient@domain.com\",\n};\n\nconst sanitizerOptions: SanitizerOptions = {\n connectionStringSanitizers: [\n {\n actualConnString: env.COMMUNICATION_CONNECTION_STRING_EMAIL,\n fakeConnString: envSetupForPlayback[\"COMMUNICATION_CONNECTION_STRING_EMAIL\"],\n },\n ],\n headerSanitizers: [\n { key: \"repeatability-first-sent\", value: \"Sanitized\" },\n { key: \"repeatability-request-id\", value: \"Sanitized\" },\n { key: \"x-ms-client-request-id\", value: \"Sanitized\" },\n { key: \"x-ms-date\", value: \"Sanitized\" },\n { key: \"Date\", value: \"Sanitized\" },\n { key: \"Date\", value: \"Sanitized\" },\n { key: \"X-Azure-Ref\", value: \"Sanitized\" },\n { key: \"x-ms-request-id\", value: \"Sanitized\" },\n { key: \"Operation-Location\", value: \"https://someEndpoint/emails/someMessageId/status\" },\n ],\n uriSanitizers: [\n {\n regex: true,\n target: `emails/.*/status`,\n value: \"emails/Sanitized/status\",\n },\n ],\n bodySanitizers: [\n {\n regex: true,\n target: `\"messageId\"\\\\s?:\\\\s?\"[^\"]*\"`,\n value: `\"messageId\":\"Sanitized\"`,\n },\n ],\n};\n\nexport async function createRecorder(context: Test | undefined): Promise<Recorder> {\n const recorder = new Recorder(context);\n await recorder.start({ envSetupForPlayback });\n await recorder.addSanitizers(sanitizerOptions, [\"record\", \"playback\"]);\n await recorder.setMatcher(\"CustomDefaultMatcher\", {\n excludedHeaders: [\n \"Accept-Language\", // This is env-dependent\n \"x-ms-content-sha256\", // This is dependent on the current datetime\n ],\n });\n return recorder;\n}\n\nexport async function createRecordedEmailClientWithConnectionString(\n context: Context\n): Promise<RecordedEmailClient> {\n const recorder = await createRecorder(context.currentTest);\n\n const client = new EmailClient(\n env.COMMUNICATION_CONNECTION_STRING_EMAIL ?? \"\",\n recorder.configureClientOptions({})\n );\n return {\n client: client,\n recorder,\n };\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-email",
|
3
|
-
"version": "1.0.0-alpha.20230303.
|
3
|
+
"version": "1.0.0-alpha.20230303.3",
|
4
4
|
"description": "The is the JS Client SDK for email. This SDK enables users to send emails and get the status of sent email message.",
|
5
5
|
"author": "Microsoft Corporation",
|
6
6
|
"license": "MIT",
|
@@ -49,7 +49,6 @@
|
|
49
49
|
"dependencies": {
|
50
50
|
"@azure/core-auth": "^1.3.0",
|
51
51
|
"@azure/core-client": "^1.3.2",
|
52
|
-
"@azure/core-lro": ">=2.5.2-alpha <2.5.2-alphb",
|
53
52
|
"@azure/core-rest-pipeline": "^1.8.0",
|
54
53
|
"@azure/communication-common": "^2.2.0",
|
55
54
|
"@azure/logger": "^1.0.0",
|
@@ -60,7 +59,7 @@
|
|
60
59
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
61
60
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
62
61
|
"@azure/test-utils": ">=1.0.0-alpha <1.0.0-alphb",
|
63
|
-
"@azure-tools/test-recorder": "
|
62
|
+
"@azure-tools/test-recorder": "^2.0.0",
|
64
63
|
"@microsoft/api-extractor": "^7.31.1",
|
65
64
|
"@types/node": "^14.0.0",
|
66
65
|
"@types/uuid": "^8.3.2",
|