@azure/communication-email 1.0.0-beta.1 → 1.0.0
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/README.md +52 -45
- package/dist/index.js +340 -213
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +11 -24
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -10
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -12
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +8 -34
- package/dist-esm/src/emailClient.js.map +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js +53 -10
- package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/index.js +11 -0
- package/dist-esm/src/generated/src/index.js.map +1 -0
- package/dist-esm/src/generated/src/lroImpl.js +25 -0
- package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
- package/dist-esm/src/generated/src/models/index.js +14 -1
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +133 -85
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +25 -16
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +79 -40
- package/dist-esm/src/generated/src/operations/email.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/email.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -0
- 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 +98 -127
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +46 -32
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +16 -15
- package/types/communication-email.d.ts +147 -134
- package/dist-esm/samples-dev/checkMessageStatus.js +0 -46
- package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
- package/dist-esm/src/constants.js +0 -4
- package/dist-esm/src/constants.js.map +0 -1
- package/dist-esm/src/generated/src/emailRestApiClientContext.js +0 -38
- package/dist-esm/src/generated/src/emailRestApiClientContext.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../../src/generated/src/models/parameters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,aAAa,EAAE,UAAU;IACzB,MAAM,EAAE;QACN,cAAc,EAAE,UAAU;QAC1B,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;IACD,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../../src/generated/src/models/parameters.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,CAAC,MAAM,MAAM,GAAuB;IACxC,aAAa,EAAE,QAAQ;IACvB,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,QAAQ;QACxB,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,aAAa,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AE,wBAAwB;QACxC,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;SACb;KACF;CACF,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 {\n OperationParameter,\n OperationURLParameter,\n OperationQueryParameter\n} from \"@azure/core-client\";\nimport { EmailMessage as EmailMessageMapper } from \"../models/mappers\";\n\nexport const accept: OperationParameter = {\n parameterPath: \"accept\",\n mapper: {\n defaultValue: \"application/json\",\n isConstant: true,\n serializedName: \"Accept\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const endpoint: OperationURLParameter = {\n parameterPath: \"endpoint\",\n mapper: {\n serializedName: \"endpoint\",\n required: true,\n type: {\n name: \"String\"\n }\n },\n skipEncoding: true\n};\n\nexport const operationId: OperationURLParameter = {\n parameterPath: \"operationId\",\n mapper: {\n serializedName: \"operationId\",\n required: true,\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const apiVersion: OperationQueryParameter = {\n parameterPath: \"apiVersion\",\n mapper: {\n defaultValue: \"2023-03-31\",\n isConstant: true,\n serializedName: \"api-version\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const contentType: OperationParameter = {\n parameterPath: [\"options\", \"contentType\"],\n mapper: {\n defaultValue: \"application/json\",\n isConstant: true,\n serializedName: \"Content-Type\",\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const message: OperationParameter = {\n parameterPath: \"message\",\n mapper: EmailMessageMapper\n};\n\nexport const operationId1: OperationParameter = {\n parameterPath: [\"options\", \"operationId\"],\n mapper: {\n serializedName: \"Operation-Id\",\n type: {\n name: \"Uuid\"\n }\n }\n};\n\nexport const clientRequestId: OperationParameter = {\n parameterPath: [\"options\", \"clientRequestId\"],\n mapper: {\n serializedName: \"x-ms-client-request-id\",\n type: {\n name: \"Uuid\"\n }\n }\n};\n"]}
|
@@ -5,13 +5,13 @@
|
|
5
5
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
6
6
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
7
7
|
*/
|
8
|
-
import * as
|
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
|
-
|
12
|
-
|
13
|
-
*/
|
14
|
-
export class
|
11
|
+
import { LroEngine } from "@azure/core-lro";
|
12
|
+
import { LroImpl } from "../lroImpl";
|
13
|
+
/** Class containing Email operations. */
|
14
|
+
export class EmailImpl {
|
15
15
|
/**
|
16
16
|
* Initialize a new instance of the class Email class.
|
17
17
|
* @param client Reference to the service client
|
@@ -20,75 +20,114 @@ export class Email {
|
|
20
20
|
this.client = client;
|
21
21
|
}
|
22
22
|
/**
|
23
|
-
* Gets the status of
|
24
|
-
* @param
|
23
|
+
* Gets the status of the email send operation.
|
24
|
+
* @param operationId ID of the long running operation (GUID) returned from a previous call to send
|
25
|
+
* email
|
25
26
|
* @param options The options parameters.
|
26
27
|
*/
|
27
|
-
|
28
|
-
|
29
|
-
return this.client.sendOperationRequest({ messageId, options: operationOptions }, getSendStatusOperationSpec);
|
28
|
+
getSendResult(operationId, options) {
|
29
|
+
return this.client.sendOperationRequest({ operationId, options }, getSendResultOperationSpec);
|
30
30
|
}
|
31
31
|
/**
|
32
32
|
* Queues an email message to be sent to one or more recipients
|
33
|
-
* @param
|
34
|
-
* is, that the client can make the request multiple times with the same Repeatability-Request-Id and
|
35
|
-
* get back an appropriate response without the server executing the request multiple times. The value
|
36
|
-
* of the Repeatability-Request-Id is an opaque string representing a client-generated, globally unique
|
37
|
-
* for all time, identifier for the request. It is recommended to use version 4 (random) UUIDs.
|
38
|
-
* @param repeatabilityFirstSent Must be sent by clients to specify that a request is repeatable.
|
39
|
-
* Repeatability-First-Sent is used to specify the date and time at which the request was first created
|
40
|
-
* in the IMF-fix date form of HTTP-date as defined in RFC7231. eg- Tue, 26 Mar 2019 16:06:51 GMT
|
41
|
-
* @param emailMessage Message payload for sending an email
|
33
|
+
* @param message Message payload for sending an email
|
42
34
|
* @param options The options parameters.
|
43
35
|
*/
|
44
|
-
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
36
|
+
async beginSend(message, options) {
|
37
|
+
const directSendOperation = async (args, spec) => {
|
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();
|
52
76
|
}
|
53
77
|
}
|
54
78
|
// Operation Specifications
|
55
|
-
const serializer =
|
56
|
-
const
|
57
|
-
path: "/emails/{
|
79
|
+
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
80
|
+
const getSendResultOperationSpec = {
|
81
|
+
path: "/emails/operations/{operationId}",
|
58
82
|
httpMethod: "GET",
|
59
83
|
responses: {
|
60
84
|
200: {
|
61
|
-
bodyMapper: Mappers.
|
62
|
-
headersMapper: Mappers.
|
85
|
+
bodyMapper: Mappers.EmailSendResult,
|
86
|
+
headersMapper: Mappers.EmailGetSendResultHeaders
|
63
87
|
},
|
64
88
|
default: {
|
65
|
-
bodyMapper: Mappers.
|
66
|
-
headersMapper: Mappers.
|
89
|
+
bodyMapper: Mappers.ErrorResponse,
|
90
|
+
headersMapper: Mappers.EmailGetSendResultExceptionHeaders
|
67
91
|
}
|
68
92
|
},
|
69
93
|
queryParameters: [Parameters.apiVersion],
|
70
|
-
urlParameters: [Parameters.endpoint, Parameters.
|
94
|
+
urlParameters: [Parameters.endpoint, Parameters.operationId],
|
95
|
+
headerParameters: [Parameters.accept],
|
71
96
|
serializer
|
72
97
|
};
|
73
98
|
const sendOperationSpec = {
|
74
99
|
path: "/emails:send",
|
75
100
|
httpMethod: "POST",
|
76
101
|
responses: {
|
102
|
+
200: {
|
103
|
+
bodyMapper: Mappers.EmailSendResult,
|
104
|
+
headersMapper: Mappers.EmailSendHeaders
|
105
|
+
},
|
106
|
+
201: {
|
107
|
+
bodyMapper: Mappers.EmailSendResult,
|
108
|
+
headersMapper: Mappers.EmailSendHeaders
|
109
|
+
},
|
77
110
|
202: {
|
111
|
+
bodyMapper: Mappers.EmailSendResult,
|
78
112
|
headersMapper: Mappers.EmailSendHeaders
|
79
113
|
},
|
80
|
-
|
81
|
-
bodyMapper: Mappers.
|
114
|
+
204: {
|
115
|
+
bodyMapper: Mappers.EmailSendResult,
|
82
116
|
headersMapper: Mappers.EmailSendHeaders
|
117
|
+
},
|
118
|
+
default: {
|
119
|
+
bodyMapper: Mappers.ErrorResponse,
|
120
|
+
headersMapper: Mappers.EmailSendExceptionHeaders
|
83
121
|
}
|
84
122
|
},
|
85
|
-
requestBody: Parameters.
|
123
|
+
requestBody: Parameters.message,
|
86
124
|
queryParameters: [Parameters.apiVersion],
|
87
125
|
urlParameters: [Parameters.endpoint],
|
88
126
|
headerParameters: [
|
127
|
+
Parameters.accept,
|
89
128
|
Parameters.contentType,
|
90
|
-
Parameters.
|
91
|
-
Parameters.
|
129
|
+
Parameters.operationId1,
|
130
|
+
Parameters.clientRequestId
|
92
131
|
],
|
93
132
|
mediaType: "json",
|
94
133
|
serializer
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../../src/generated/src/operations/email.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
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;AAEnD,OAAO,EAAkC,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASrC,yCAAyC;AACzC,MAAM,OAAO,SAAS;IAGpB;;;OAGG;IACH,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,aAAa,CACX,WAAmB,EACnB,OAA0C;QAE1C,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CACrC,EAAE,WAAW,EAAE,OAAO,EAAE,EACxB,0BAA0B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H,UAAU,EAAE,OAAO,CAAC,eAAe;YACnC,aAAa,EAAE,OAAO,CAAC,gBAAgB;SACxC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,eAAe;YACnC,aAAa,EAAE,OAAO,CAAC,gBAAgB;SACxC;QACD,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,eAAe;YACnC,aAAa,EAAE,OAAO,CAAC,gBAAgB;SACxC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,aAAa;YACjC,aAAa,EAAE,OAAO,CAAC,yBAAyB;SACjD;KACF;IACD,WAAW,EAAE,UAAU,CAAC,OAAO;IAC/B,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE;QAChB,UAAU,CAAC,MAAM;QACjB,UAAU,CAAC,WAAW;QACtB,UAAU,CAAC,YAAY;QACvB,UAAU,CAAC,eAAe;KAC3B;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 { PollerLike, PollOperationState, LroEngine } from \"@azure/core-lro\";\nimport { LroImpl } from \"../lroImpl\";\nimport {\n EmailGetSendResultOptionalParams,\n EmailGetSendResultResponse,\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 the email send operation.\n * @param operationId ID of the long running operation (GUID) returned from a previous call to send\n * email\n * @param options The options parameters.\n */\n getSendResult(\n operationId: string,\n options?: EmailGetSendResultOptionalParams\n ): Promise<EmailGetSendResultResponse> {\n return this.client.sendOperationRequest(\n { operationId, options },\n getSendResultOperationSpec\n );\n }\n\n /**\n * Queues an email message to be sent to one or more recipients\n * @param message Message payload for sending an email\n * @param options The options parameters.\n */\n async beginSend(\n message: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<\n PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>\n > {\n const directSendOperation = async (\n args: coreClient.OperationArguments,\n spec: coreClient.OperationSpec\n ): Promise<EmailSendResponse> => {\n return this.client.sendOperationRequest(args, spec);\n };\n const sendOperation = async (\n args: coreClient.OperationArguments,\n spec: coreClient.OperationSpec\n ) => {\n let currentRawResponse:\n | coreClient.FullOperationResponse\n | undefined = undefined;\n const providedCallback = args.options?.onResponse;\n const callback: coreClient.RawResponseCallback = (\n rawResponse: coreClient.FullOperationResponse,\n flatResponse: unknown\n ) => {\n currentRawResponse = rawResponse;\n providedCallback?.(rawResponse, flatResponse);\n };\n const updatedArgs = {\n ...args,\n options: {\n ...args.options,\n onResponse: callback\n }\n };\n const flatResponse = await directSendOperation(updatedArgs, spec);\n return {\n flatResponse,\n rawResponse: {\n statusCode: currentRawResponse!.status,\n body: currentRawResponse!.parsedBody,\n headers: currentRawResponse!.headers.toJSON()\n }\n };\n };\n\n const lro = new LroImpl(\n sendOperation,\n { message, options },\n sendOperationSpec\n );\n const poller = new LroEngine(lro, {\n resumeFrom: options?.resumeFrom,\n intervalInMs: options?.updateIntervalInMs,\n lroResourceLocationConfig: \"azure-async-operation\"\n });\n await poller.poll();\n return poller;\n }\n\n /**\n * Queues an email message to be sent to one or more recipients\n * @param message Message payload for sending an email\n * @param options The options parameters.\n */\n async beginSendAndWait(\n message: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<EmailSendResponse> {\n const poller = await this.beginSend(message, options);\n return poller.pollUntilDone();\n }\n}\n// Operation Specifications\nconst serializer = coreClient.createSerializer(Mappers, /* isXml */ false);\n\nconst getSendResultOperationSpec: coreClient.OperationSpec = {\n path: \"/emails/operations/{operationId}\",\n httpMethod: \"GET\",\n responses: {\n 200: {\n bodyMapper: Mappers.EmailSendResult,\n headersMapper: Mappers.EmailGetSendResultHeaders\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n headersMapper: Mappers.EmailGetSendResultExceptionHeaders\n }\n },\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint, Parameters.operationId],\n headerParameters: [Parameters.accept],\n serializer\n};\nconst sendOperationSpec: coreClient.OperationSpec = {\n path: \"/emails:send\",\n httpMethod: \"POST\",\n responses: {\n 200: {\n bodyMapper: Mappers.EmailSendResult,\n headersMapper: Mappers.EmailSendHeaders\n },\n 201: {\n bodyMapper: Mappers.EmailSendResult,\n headersMapper: Mappers.EmailSendHeaders\n },\n 202: {\n bodyMapper: Mappers.EmailSendResult,\n headersMapper: Mappers.EmailSendHeaders\n },\n 204: {\n bodyMapper: Mappers.EmailSendResult,\n headersMapper: Mappers.EmailSendHeaders\n },\n default: {\n bodyMapper: Mappers.ErrorResponse,\n headersMapper: Mappers.EmailSendExceptionHeaders\n }\n },\n requestBody: Parameters.message,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [\n Parameters.accept,\n Parameters.contentType,\n Parameters.operationId1,\n Parameters.clientRequestId\n ],\n mediaType: \"json\",\n serializer\n};\n"]}
|
@@ -0,0 +1,9 @@
|
|
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
|
+
export {};
|
9
|
+
//# sourceMappingURL=email.js.map
|
@@ -0,0 +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 { PollerLike, PollOperationState } from \"@azure/core-lro\";\nimport {\n EmailGetSendResultOptionalParams,\n EmailGetSendResultResponse,\n EmailMessage,\n EmailSendOptionalParams,\n EmailSendResponse\n} from \"../models\";\n\n/** Interface representing a Email. */\nexport interface Email {\n /**\n * Gets the status of the email send operation.\n * @param operationId ID of the long running operation (GUID) returned from a previous call to send\n * email\n * @param options The options parameters.\n */\n getSendResult(\n operationId: string,\n options?: EmailGetSendResultOptionalParams\n ): Promise<EmailGetSendResultResponse>;\n /**\n * Queues an email message to be sent to one or more recipients\n * @param message Message payload for sending an email\n * @param options The options parameters.\n */\n beginSend(\n message: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<\n PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>\n >;\n /**\n * Queues an email message to be sent to one or more recipients\n * @param message Message payload for sending an email\n * @param options The options parameters.\n */\n beginSendAndWait(\n message: EmailMessage,\n options?: EmailSendOptionalParams\n ): Promise<EmailSendResponse>;\n}\n"]}
|
@@ -0,0 +1,9 @@
|
|
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
|
+
export * from "./email";
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/generated/src/operationsInterfaces/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,SAAS,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\nexport * from \"./email\";\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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA6DlC,OAAO,EAUL,oBAAoB,GACrB,MAAM,wBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\nimport { EmailRecipients, EmailAttachment, EmailAddress } from \"./models\";\n\n/**\n * Client options used to configure Email Client API requests.\n */\nexport interface EmailClientOptions extends CommonClientOptions {}\n\n/** Content of the email. */\nexport type EmailContent = HtmlEmailContent | PlainTextEmailContent;\n\n/** Content of the email with a required html property. */\nexport interface HtmlEmailContent {\n /** Subject of the email message */\n subject: string;\n /** Plain text version of the email message. */\n plainText?: string;\n /** Html version of the email message. */\n html: string;\n}\n\n/** Content of the email with a required plainText property. */\nexport interface PlainTextEmailContent {\n /** Subject of the email message */\n subject: string;\n /** Plain text version of the email message. */\n plainText: string;\n /** Html version of the email message. */\n html?: string;\n}\n\n/** Message payload for sending an email */\nexport interface EmailMessage {\n /** Custom email headers to be passed. */\n headers?: { [propertyName: string]: string };\n /** Sender email address from a verified domain. */\n senderAddress: string;\n /** Email content to be sent. */\n content: EmailContent;\n /** Recipients for the email. */\n recipients: EmailRecipients;\n /** List of attachments. Please note that we limit the total size of an email request (which includes attachments) to 10MB. */\n attachments?: EmailAttachment[];\n /** Email addresses where recipients' replies will be sent to. */\n replyTo?: EmailAddress[];\n /** 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. */\n disableUserEngagementTracking?: boolean;\n}\n\n/** Optional parameters for the beginSend method. */\nexport interface EmailSendOptionalParams extends OperationOptions {\n /** This is the ID used by the status monitor for this long running operation. */\n operationId?: string;\n /** Delay to wait until next poll, in milliseconds. */\n updateIntervalInMs?: number;\n /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */\n resumeFrom?: string;\n}\n\nexport {\n EmailRecipients,\n EmailAddress,\n EmailAttachment,\n EmailSendResponse,\n EmailSendHeaders,\n EmailSendResult,\n EmailSendStatus,\n ErrorDetail,\n ErrorAdditionalInfo,\n KnownEmailSendStatus,\n} from \"./generated/src/models\";\n"]}
|
@@ -1,137 +1,108 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
|
+
import { KnownEmailSendStatus } from "../../src";
|
3
4
|
import { env } from "@azure-tools/test-recorder";
|
4
|
-
import { createRecordedEmailClientWithConnectionString, createRecordedEmailClientWithKeyCredential, } from "./utils/recordedClient";
|
5
5
|
import { assert } from "chai";
|
6
|
-
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
});
|
25
|
-
it("successfully sends an email to a single recipient", async function () {
|
26
|
-
const emailMessage = {
|
27
|
-
sender: env.SENDER_ADDRESS,
|
28
|
-
recipients: {
|
29
|
-
to: [
|
30
|
-
{
|
31
|
-
email: env.RECIPIENT_ADDRESS,
|
32
|
-
displayName: "someRecipient",
|
33
|
-
},
|
34
|
-
],
|
35
|
-
},
|
36
|
-
content: {
|
37
|
-
subject: "someSubject",
|
38
|
-
plainText: "somePlainTextBody",
|
39
|
-
html: "<html><h1>someHtmlBody</html>",
|
40
|
-
},
|
41
|
-
};
|
42
|
-
const response = await client.send(emailMessage);
|
43
|
-
assert.isNotNull(response.messageId);
|
44
|
-
}).timeout(5000);
|
45
|
-
it("successfully sends an email to multiple types of recipients", async function () {
|
46
|
-
const emailMessage = {
|
47
|
-
sender: env.SENDER_ADDRESS,
|
48
|
-
recipients: {
|
49
|
-
to: [
|
50
|
-
{
|
51
|
-
email: env.RECIPIENT_ADDRESS,
|
52
|
-
displayName: "someRecipient",
|
53
|
-
},
|
54
|
-
{
|
55
|
-
email: env.RECIPIENT_ADDRESS,
|
56
|
-
displayName: "someRecipient",
|
57
|
-
},
|
58
|
-
],
|
59
|
-
cC: [
|
60
|
-
{
|
61
|
-
email: env.RECIPIENT_ADDRESS,
|
62
|
-
displayName: "someRecipient",
|
63
|
-
},
|
64
|
-
],
|
65
|
-
bCC: [
|
66
|
-
{
|
67
|
-
email: env.RECIPIENT_ADDRESS,
|
68
|
-
displayName: "someRecipient",
|
69
|
-
},
|
70
|
-
],
|
71
|
-
},
|
72
|
-
content: {
|
73
|
-
subject: "someSubject",
|
74
|
-
plainText: "somePlainTextBody",
|
75
|
-
html: "<html><h1>someHtmlBody</html>",
|
76
|
-
},
|
77
|
-
};
|
78
|
-
const response = await client.send(emailMessage);
|
79
|
-
assert.isNotNull(response.messageId);
|
80
|
-
}).timeout(5000);
|
81
|
-
it("successfully sends an email with an attachment", async function () {
|
82
|
-
const emailMessage = {
|
83
|
-
sender: env.SENDER_ADDRESS,
|
84
|
-
recipients: {
|
85
|
-
to: [
|
86
|
-
{
|
87
|
-
email: env.RECIPIENT_ADDRESS,
|
88
|
-
displayName: "someRecipient",
|
89
|
-
},
|
90
|
-
],
|
91
|
-
},
|
92
|
-
content: {
|
93
|
-
subject: "someSubject",
|
94
|
-
plainText: "somePlainTextBody",
|
95
|
-
html: "<html><h1>someHtmlBody</html>",
|
96
|
-
},
|
97
|
-
attachments: [
|
6
|
+
import { createRecordedEmailClientWithConnectionString } from "./utils/recordedClient";
|
7
|
+
describe(`EmailClient [Playback/Live]`, function () {
|
8
|
+
let recorder;
|
9
|
+
let client;
|
10
|
+
beforeEach(async function () {
|
11
|
+
({ client, recorder } = await createRecordedEmailClientWithConnectionString(this));
|
12
|
+
});
|
13
|
+
afterEach(async function () {
|
14
|
+
var _a;
|
15
|
+
if (!((_a = this.currentTest) === null || _a === void 0 ? void 0 : _a.isPending())) {
|
16
|
+
await recorder.stop();
|
17
|
+
}
|
18
|
+
});
|
19
|
+
it("successfully sends an email to a single recipient", async function () {
|
20
|
+
const emailMessage = {
|
21
|
+
senderAddress: env.SENDER_ADDRESS || "",
|
22
|
+
recipients: {
|
23
|
+
to: [
|
98
24
|
{
|
99
|
-
|
100
|
-
|
101
|
-
contentBytesBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
|
25
|
+
address: env.RECIPIENT_ADDRESS || "",
|
26
|
+
displayName: "someRecipient",
|
102
27
|
},
|
103
28
|
],
|
104
|
-
}
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
29
|
+
},
|
30
|
+
content: {
|
31
|
+
subject: "someSubject",
|
32
|
+
plainText: "somePlainTextBody",
|
33
|
+
html: "<html><h1>someHtmlBody</html>",
|
34
|
+
},
|
35
|
+
};
|
36
|
+
const poller = await client.beginSend(emailMessage);
|
37
|
+
const response = await poller.pollUntilDone();
|
38
|
+
assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
|
39
|
+
}).timeout(120000);
|
40
|
+
it("successfully sends an email to multiple types of recipients", async function () {
|
41
|
+
var _a, _b, _c, _d, _e;
|
42
|
+
const emailMessage = {
|
43
|
+
senderAddress: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
|
44
|
+
recipients: {
|
45
|
+
to: [
|
46
|
+
{
|
47
|
+
address: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
|
48
|
+
displayName: "someRecipient",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
address: (_c = env.RECIPIENT_ADDRESS) !== null && _c !== void 0 ? _c : "",
|
52
|
+
displayName: "someRecipient",
|
53
|
+
},
|
54
|
+
],
|
55
|
+
cc: [
|
56
|
+
{
|
57
|
+
address: (_d = env.RECIPIENT_ADDRESS) !== null && _d !== void 0 ? _d : "",
|
58
|
+
displayName: "someRecipient",
|
59
|
+
},
|
60
|
+
],
|
61
|
+
bcc: [
|
62
|
+
{
|
63
|
+
address: (_e = env.RECIPIENT_ADDRESS) !== null && _e !== void 0 ? _e : "",
|
64
|
+
displayName: "someRecipient",
|
65
|
+
},
|
66
|
+
],
|
67
|
+
},
|
68
|
+
content: {
|
69
|
+
subject: "someSubject",
|
70
|
+
plainText: "somePlainTextBody",
|
71
|
+
html: "<html><h1>someHtmlBody</html>",
|
72
|
+
},
|
73
|
+
};
|
74
|
+
const poller = await client.beginSend(emailMessage);
|
75
|
+
const response = await poller.pollUntilDone();
|
76
|
+
assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
|
77
|
+
}).timeout(120000);
|
78
|
+
it("successfully sends an email with an attachment", async function () {
|
79
|
+
var _a, _b;
|
80
|
+
const emailMessage = {
|
81
|
+
senderAddress: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
|
82
|
+
recipients: {
|
83
|
+
to: [
|
84
|
+
{
|
85
|
+
address: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
|
86
|
+
displayName: "someRecipient",
|
87
|
+
},
|
88
|
+
],
|
89
|
+
},
|
90
|
+
content: {
|
91
|
+
subject: "someSubject",
|
92
|
+
plainText: "somePlainTextBody",
|
93
|
+
html: "<html><h1>someHtmlBody</html>",
|
94
|
+
},
|
95
|
+
attachments: [
|
96
|
+
{
|
97
|
+
name: "readme.txt",
|
98
|
+
contentType: "text/plain",
|
99
|
+
contentInBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
|
123
100
|
},
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
}
|
131
|
-
else {
|
132
|
-
assert.fail();
|
133
|
-
}
|
134
|
-
}).timeout(5000);
|
135
|
-
});
|
101
|
+
],
|
102
|
+
};
|
103
|
+
const poller = await client.beginSend(emailMessage);
|
104
|
+
const response = await poller.pollUntilDone();
|
105
|
+
assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
|
106
|
+
}).timeout(120000);
|
136
107
|
});
|
137
108
|
//# 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;AAElC,OAAO,EAA6B,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC5E,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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AM,KAAK,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EmailClient, EmailMessage, KnownEmailSendStatus } 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 senderAddress: env.SENDER_ADDRESS || \"\",\n recipients: {\n to: [\n {\n address: 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 poller = await client.beginSend(emailMessage);\n const response = await poller.pollUntilDone();\n\n assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);\n }).timeout(120000);\n\n it(\"successfully sends an email to multiple types of recipients\", async function () {\n const emailMessage: EmailMessage = {\n senderAddress: env.SENDER_ADDRESS ?? \"\",\n recipients: {\n to: [\n {\n address: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n {\n address: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n cc: [\n {\n address: env.RECIPIENT_ADDRESS ?? \"\",\n displayName: \"someRecipient\",\n },\n ],\n bcc: [\n {\n address: 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 poller = await client.beginSend(emailMessage);\n const response = await poller.pollUntilDone();\n\n assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);\n }).timeout(120000);\n\n it(\"successfully sends an email with an attachment\", async function () {\n const emailMessage: EmailMessage = {\n senderAddress: env.SENDER_ADDRESS ?? \"\",\n recipients: {\n to: [\n {\n address: 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 contentType: \"text/plain\",\n contentInBase64: \"ZW1haWwgdGVzdCBhdHRhY2htZW50\",\n },\n ],\n };\n\n const poller = await client.beginSend(emailMessage);\n const response = await poller.pollUntilDone();\n\n assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);\n }).timeout(120000);\n});\n"]}
|