@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.
Files changed (43) hide show
  1. package/README.md +52 -45
  2. package/dist/index.js +340 -213
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +11 -24
  5. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
  6. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -10
  7. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
  8. package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -12
  9. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
  10. package/dist-esm/src/emailClient.js +8 -34
  11. package/dist-esm/src/emailClient.js.map +1 -1
  12. package/dist-esm/src/generated/src/emailRestApiClient.js +53 -10
  13. package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
  14. package/dist-esm/src/generated/src/index.js +11 -0
  15. package/dist-esm/src/generated/src/index.js.map +1 -0
  16. package/dist-esm/src/generated/src/lroImpl.js +25 -0
  17. package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
  18. package/dist-esm/src/generated/src/models/index.js +14 -1
  19. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  20. package/dist-esm/src/generated/src/models/mappers.js +133 -85
  21. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  22. package/dist-esm/src/generated/src/models/parameters.js +25 -16
  23. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  24. package/dist-esm/src/generated/src/operations/email.js +79 -40
  25. package/dist-esm/src/generated/src/operations/email.js.map +1 -1
  26. package/dist-esm/src/generated/src/operationsInterfaces/email.js +9 -0
  27. package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -0
  28. package/dist-esm/src/generated/src/operationsInterfaces/index.js +9 -0
  29. package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -0
  30. package/dist-esm/src/models.js +1 -1
  31. package/dist-esm/src/models.js.map +1 -1
  32. package/dist-esm/test/public/emailClient.spec.js +98 -127
  33. package/dist-esm/test/public/emailClient.spec.js.map +1 -1
  34. package/dist-esm/test/public/utils/recordedClient.js +46 -32
  35. package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
  36. package/package.json +16 -15
  37. package/types/communication-email.d.ts +147 -134
  38. package/dist-esm/samples-dev/checkMessageStatus.js +0 -46
  39. package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
  40. package/dist-esm/src/constants.js +0 -4
  41. package/dist-esm/src/constants.js.map +0 -1
  42. package/dist-esm/src/generated/src/emailRestApiClientContext.js +0 -38
  43. 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,SAAS,GAA0B;IAC9C,aAAa,EAAE,WAAW;IAC1B,MAAM,EAAE;QACN,cAAc,EAAE,WAAW;QAC3B,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,aAAa,EAAE,YAAY;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,oBAAoB;QAClC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,aAAa;QAC7B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAuB;IAC9C,aAAa,EAAE,cAAc;IAC7B,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAuB;IACxD,aAAa,EAAE,wBAAwB;IACvC,MAAM,EAAE;QACN,cAAc,EAAE,0BAA0B;QAC1C,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAuB;IACxD,aAAa,EAAE,wBAAwB;IACvC,MAAM,EAAE;QACN,cAAc,EAAE,0BAA0B;QAC1C,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;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 OperationURLParameter,\n OperationQueryParameter,\n OperationParameter\n} from \"@azure/core-http\";\nimport { EmailMessage as EmailMessageMapper } from \"../models/mappers\";\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 messageId: OperationURLParameter = {\n parameterPath: \"messageId\",\n mapper: {\n serializedName: \"messageId\",\n required: true,\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const apiVersion: OperationQueryParameter = {\n parameterPath: \"apiVersion\",\n mapper: {\n defaultValue: \"2021-10-01-preview\",\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 emailMessage: OperationParameter = {\n parameterPath: \"emailMessage\",\n mapper: EmailMessageMapper\n};\n\nexport const repeatabilityRequestId: OperationParameter = {\n parameterPath: \"repeatabilityRequestId\",\n mapper: {\n serializedName: \"repeatability-request-id\",\n required: true,\n type: {\n name: \"String\"\n }\n }\n};\n\nexport const repeatabilityFirstSent: OperationParameter = {\n parameterPath: \"repeatabilityFirstSent\",\n mapper: {\n serializedName: \"repeatability-first-sent\",\n required: true,\n type: {\n name: \"String\"\n }\n }\n};\n"]}
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,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,WAAW,GAA0B;IAChD,aAAa,EAAE,aAAa;IAC5B,MAAM,EAAE;QACN,cAAc,EAAE,aAAa;QAC7B,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,aAAa,EAAE,YAAY;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,YAAY;QAC1B,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,aAAa;QAC7B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAuB;IAC7C,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE;QACN,YAAY,EAAE,kBAAkB;QAChC,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,aAAa,EAAE,SAAS;IACxB,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAuB;IAC9C,aAAa,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE;QACN,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM;SACb;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAuB;IACjD,aAAa,EAAE,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAC7C,MAAM,EAAE;QACN,cAAc,EAAE,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 coreHttp from "@azure/core-http";
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
- * Class representing a Email.
13
- */
14
- export class Email {
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 a message sent previously.
24
- * @param messageId System generated message id (GUID) returned from a previous call to send email
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
- getSendStatus(messageId, options) {
28
- const operationOptions = coreHttp.operationOptionsToRequestOptionsBase(options || {});
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 repeatabilityRequestId If specified, the client directs that the request is repeatable; that
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
- send(repeatabilityRequestId, repeatabilityFirstSent, emailMessage, options) {
45
- const operationOptions = coreHttp.operationOptionsToRequestOptionsBase(options || {});
46
- return this.client.sendOperationRequest({
47
- repeatabilityRequestId,
48
- repeatabilityFirstSent,
49
- emailMessage,
50
- options: operationOptions
51
- }, sendOperationSpec);
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 = new coreHttp.Serializer(Mappers, /* isXml */ false);
56
- const getSendStatusOperationSpec = {
57
- path: "/emails/{messageId}/status",
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.SendStatusResult,
62
- headersMapper: Mappers.EmailGetSendStatusHeaders
85
+ bodyMapper: Mappers.EmailSendResult,
86
+ headersMapper: Mappers.EmailGetSendResultHeaders
63
87
  },
64
88
  default: {
65
- bodyMapper: Mappers.CommunicationErrorResponse,
66
- headersMapper: Mappers.EmailGetSendStatusHeaders
89
+ bodyMapper: Mappers.ErrorResponse,
90
+ headersMapper: Mappers.EmailGetSendResultExceptionHeaders
67
91
  }
68
92
  },
69
93
  queryParameters: [Parameters.apiVersion],
70
- urlParameters: [Parameters.endpoint, Parameters.messageId],
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
- default: {
81
- bodyMapper: Mappers.CommunicationErrorResponse,
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.emailMessage,
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.repeatabilityRequestId,
91
- Parameters.repeatabilityFirstSent
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;AAEH,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAQnD;;GAEG;AACH,MAAM,OAAO,KAAK;IAGhB;;;OAGG;IACH,YAAY,MAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,aAAa,CACX,SAAiB,EACjB,OAAmC;QAEnC,MAAM,gBAAgB,GAAgC,QAAQ,CAAC,oCAAoC,CACjG,OAAO,IAAI,EAAE,CACd,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CACrC,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,EACxC,0BAA0B,CACY,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,CACF,sBAA8B,EAC9B,sBAA8B,EAC9B,YAA0B,EAC1B,OAAmC;QAEnC,MAAM,gBAAgB,GAAgC,QAAQ,CAAC,oCAAoC,CACjG,OAAO,IAAI,EAAE,CACd,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CACrC;YACE,sBAAsB;YACtB,sBAAsB;YACtB,YAAY;YACZ,OAAO,EAAE,gBAAgB;SAC1B,EACD,iBAAiB,CACY,CAAC;IAClC,CAAC;CACF;AACD,2BAA2B;AAE3B,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,0BAA0B,GAA2B;IACzD,IAAI,EAAE,4BAA4B;IAClC,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,UAAU,EAAE,OAAO,CAAC,gBAAgB;YACpC,aAAa,EAAE,OAAO,CAAC,yBAAyB;SACjD;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,0BAA0B;YAC9C,aAAa,EAAE,OAAO,CAAC,yBAAyB;SACjD;KACF;IACD,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;IAC1D,UAAU;CACX,CAAC;AACF,MAAM,iBAAiB,GAA2B;IAChD,IAAI,EAAE,cAAc;IACpB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,aAAa,EAAE,OAAO,CAAC,gBAAgB;SACxC;QACD,OAAO,EAAE;YACP,UAAU,EAAE,OAAO,CAAC,0BAA0B;YAC9C,aAAa,EAAE,OAAO,CAAC,gBAAgB;SACxC;KACF;IACD,WAAW,EAAE,UAAU,CAAC,YAAY;IACpC,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;IACpC,gBAAgB,EAAE;QAChB,UAAU,CAAC,WAAW;QACtB,UAAU,CAAC,sBAAsB;QACjC,UAAU,CAAC,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 * as coreHttp from \"@azure/core-http\";\nimport * as Mappers from \"../models/mappers\";\nimport * as Parameters from \"../models/parameters\";\nimport { EmailRestApiClient } from \"../emailRestApiClient\";\nimport {\n EmailGetSendStatusResponse,\n EmailMessage,\n EmailSendResponse\n} from \"../models\";\n\n/**\n * Class representing a Email.\n */\nexport class 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?: coreHttp.OperationOptions\n ): Promise<EmailGetSendStatusResponse> {\n const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(\n options || {}\n );\n return this.client.sendOperationRequest(\n { messageId, options: operationOptions },\n getSendStatusOperationSpec\n ) as Promise<EmailGetSendStatusResponse>;\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?: coreHttp.OperationOptions\n ): Promise<EmailSendResponse> {\n const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(\n options || {}\n );\n return this.client.sendOperationRequest(\n {\n repeatabilityRequestId,\n repeatabilityFirstSent,\n emailMessage,\n options: operationOptions\n },\n sendOperationSpec\n ) as Promise<EmailSendResponse>;\n }\n}\n// Operation Specifications\n\nconst serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);\n\nconst getSendStatusOperationSpec: coreHttp.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.EmailGetSendStatusHeaders\n }\n },\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint, Parameters.messageId],\n serializer\n};\nconst sendOperationSpec: coreHttp.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.EmailSendHeaders\n }\n },\n requestBody: Parameters.emailMessage,\n queryParameters: [Parameters.apiVersion],\n urlParameters: [Parameters.endpoint],\n headerParameters: [\n Parameters.contentType,\n Parameters.repeatabilityRequestId,\n Parameters.repeatabilityFirstSent\n ],\n mediaType: \"json\",\n serializer\n};\n"]}
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,CAC3B,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CACb,O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;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"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- export {};
3
+ export { KnownEmailSendStatus, } from "./generated/src/models";
4
4
  //# sourceMappingURL=models.js.map
@@ -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 { PipelineOptions } from \"@azure/core-http\";\n\n/**\n * Client options used to configure SMS Client API requests.\n */\nexport interface EmailClientOptions extends PipelineOptions {}\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
+ {"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 { matrix } from "@azure/test-utils";
7
- matrix([[true, false]], async function (useKeyCredential) {
8
- describe(`EmailClient [Playback/Live]${useKeyCredential ? " [KeyCredential]" : " [ConnectionString]"}`, () => {
9
- let recorder;
10
- let client;
11
- beforeEach(function () {
12
- if (useKeyCredential) {
13
- ({ client, recorder } = createRecordedEmailClientWithKeyCredential(this));
14
- }
15
- else {
16
- ({ client, recorder } = createRecordedEmailClientWithConnectionString(this));
17
- }
18
- });
19
- afterEach(async function () {
20
- var _a;
21
- if (!((_a = this.currentTest) === null || _a === void 0 ? void 0 : _a.isPending())) {
22
- await recorder.stop();
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
- name: "readme.txt",
100
- attachmentType: "txt",
101
- contentBytesBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
25
+ address: env.RECIPIENT_ADDRESS || "",
26
+ displayName: "someRecipient",
102
27
  },
103
28
  ],
104
- };
105
- const response = await client.send(emailMessage);
106
- assert.isNotNull(response.messageId);
107
- }).timeout(5000);
108
- it("successfully retrieves the email status with the returned message id", async function () {
109
- const emailMessage = {
110
- sender: env.SENDER_ADDRESS,
111
- recipients: {
112
- to: [
113
- {
114
- email: env.RECIPIENT_ADDRESS,
115
- displayName: "someRecipient",
116
- },
117
- ],
118
- },
119
- content: {
120
- subject: "someSubject",
121
- plainText: "somePlainTextBody",
122
- html: "<html><h1>someHtmlBody</html>",
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
- const response = await client.send(emailMessage);
126
- const messageId = response.messageId;
127
- if (messageId) {
128
- const messageStatusResponse = await client.getSendStatus(messageId);
129
- assert.isNotNull(messageStatusResponse.status);
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;AAGlC,OAAO,EAAY,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EACL,6CAA6C,EAC7C,0CAA0C,GAC3C,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,WAAW,gBAAgB;IACtD,QAAQ,CAAC,8BACP,gBAAgB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,qBAC1C,EAAE,EAAE,GAAG,EAAE;QACP,IAAI,QAAkB,CAAC;QACvB,IAAI,MAAmB,CAAC;QAExB,UAAU,CAAC;YACT,IAAI,gBAAgB,EAAE;gBACpB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,0CAA0C,CAAC,IAAI,CAAC,CAAC,CAAC;aAC3E;iBAAM;gBACL,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,6CAA6C,CAAC,IAAI,CAAC,CAAC,CAAC;aAC9E;QACH,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,KAAK;;YACb,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,SAAS,EAAE,CAAA,EAAE;gBAClC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mDAAmD,EA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C,IAAI,SAAS,EAAE;gBACb,MAAM,qBAAqB,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;gBACpE,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;aAChD;iBAAM;gBACL,MAAM,CAAC,IAAI,EAAE,CAAC;aACf;QACH,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,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 {\n createRecordedEmailClientWithConnectionString,\n createRecordedEmailClientWithKeyCredential,\n} from \"./utils/recordedClient\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport { matrix } from \"@azure/test-utils\";\n\nmatrix([[true, false]], async function (useKeyCredential) {\n describe(`EmailClient [Playback/Live]${\n useKeyCredential ? \" [KeyCredential]\" : \" [ConnectionString]\"\n }`, () => {\n let recorder: Recorder;\n let client: EmailClient;\n\n beforeEach(function (this: Context) {\n if (useKeyCredential) {\n ({ client, recorder } = createRecordedEmailClientWithKeyCredential(this));\n } else {\n ({ client, recorder } = createRecordedEmailClientWithConnectionString(this));\n }\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});\n"]}
1
+ {"version":3,"file":"emailClient.spec.js","sourceRoot":"","sources":["../../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AE;oBACF;wBACE,OAAO,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,EAAE;wBACpC,WAAW,EAAE,eAAe;qBAC7B;iBACF;aACF;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;gBACtB,SAAS,EAAE,mBAAmB;gBAC9B,IAAI,EAAE,+BAA+B;aACtC;YACD,WAAW,EAAE;gBACX;oBACE,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,YAAY;oBACzB,eAAe,EAAE,8BAA8B;iBAChD;aACF;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;QAE9C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,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"]}