@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.
Files changed (34) hide show
  1. package/README.md +32 -24
  2. package/dist/index.js +155 -220
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/checkMessageStatus.js +41 -0
  5. package/dist-esm/samples-dev/checkMessageStatus.js.map +1 -0
  6. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +8 -10
  7. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
  8. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +5 -7
  9. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
  10. package/dist-esm/samples-dev/sendEmailWithAttachments.js +7 -9
  11. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
  12. package/dist-esm/src/emailClient.js +19 -4
  13. package/dist-esm/src/emailClient.js.map +1 -1
  14. package/dist-esm/src/generated/src/emailRestApiClient.js +1 -1
  15. package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
  16. package/dist-esm/src/generated/src/models/index.js +80 -14
  17. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/src/models/mappers.js +87 -77
  19. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  20. package/dist-esm/src/generated/src/models/parameters.js +16 -14
  21. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  22. package/dist-esm/src/generated/src/operations/email.js +26 -72
  23. package/dist-esm/src/generated/src/operations/email.js.map +1 -1
  24. package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -1
  25. package/dist-esm/src/models.js +1 -1
  26. package/dist-esm/src/models.js.map +1 -1
  27. package/dist-esm/test/public/emailClient.spec.js +74 -24
  28. package/dist-esm/test/public/emailClient.spec.js.map +1 -1
  29. package/dist-esm/test/public/utils/recordedClient.js +13 -9
  30. package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
  31. package/package.json +2 -3
  32. package/types/communication-email.d.ts +110 -132
  33. package/dist-esm/src/generated/src/lroImpl.js +0 -25
  34. package/dist-esm/src/generated/src/lroImpl.js.map +0 -1
@@ -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 the email send operation.
24
- * @param operationId ID of the long running operation (GUID) returned from a previous call to send
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
- getSendResult(operationId, options) {
29
- return this.client.sendOperationRequest({ operationId, options }, getSendResultOperationSpec);
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 message Message payload for sending an email
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
- 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();
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 getSendResultOperationSpec = {
81
- path: "/emails/operations/{operationId}",
47
+ const getSendStatusOperationSpec = {
48
+ path: "/emails/{messageId}/status",
82
49
  httpMethod: "GET",
83
50
  responses: {
84
51
  200: {
85
- bodyMapper: Mappers.EmailSendResult,
86
- headersMapper: Mappers.EmailGetSendResultHeaders
52
+ bodyMapper: Mappers.SendStatusResult,
53
+ headersMapper: Mappers.EmailGetSendStatusHeaders
87
54
  },
88
55
  default: {
89
- bodyMapper: Mappers.ErrorResponse,
90
- headersMapper: Mappers.EmailGetSendResultExceptionHeaders
56
+ bodyMapper: Mappers.CommunicationErrorResponse,
57
+ headersMapper: Mappers.EmailGetSendStatusExceptionHeaders
91
58
  }
92
59
  },
93
60
  queryParameters: [Parameters.apiVersion],
94
- urlParameters: [Parameters.endpoint, Parameters.operationId],
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.ErrorResponse,
73
+ bodyMapper: Mappers.CommunicationErrorResponse,
120
74
  headersMapper: Mappers.EmailSendExceptionHeaders
121
75
  }
122
76
  },
123
- requestBody: Parameters.message,
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.operationId1,
130
- Parameters.clientRequestId
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":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ft 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"]}
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,MAAM,CAAC,oBAAoB,CACrC,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,YAAY,EAAE,OAAO,EAAE,EACzE,iBAAiB,CAClB,CAAC;IACJ,CAAC;CACF;AACD,2BAA2B;AAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;AAE3E,MAAM,0BAA0B,GAA6B;IAC3D,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,kCAAkC;SAC1D;KACF;IACD,eAAe,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;IACxC,aAAa,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;IAC1D,gBAAgB,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;IACrC,UAAU;CACX,CAAC;AACF,MAAM,iBAAiB,GAA6B;IAClD,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,yBAAyB;SACjD;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,MAAM;QACjB,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 { 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 { 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"]}
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"]}
@@ -1,4 +1,4 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- export { KnownEmailSendStatus, } from "./generated/src/models";
3
+ export {};
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;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 userEngagementTrackingDisabled?: 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
+ {"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
- senderAddress: env.SENDER_ADDRESS || "",
20
+ sender: env.SENDER_ADDRESS || "",
22
21
  recipients: {
23
22
  to: [
24
23
  {
25
- address: env.RECIPIENT_ADDRESS || "",
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 poller = await client.beginSend(emailMessage);
37
- const response = await poller.pollUntilDone();
38
- assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
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
- senderAddress: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
41
+ sender: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
44
42
  recipients: {
45
43
  to: [
46
44
  {
47
- address: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
45
+ email: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
48
46
  displayName: "someRecipient",
49
47
  },
50
48
  {
51
- address: (_c = env.RECIPIENT_ADDRESS) !== null && _c !== void 0 ? _c : "",
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
- address: (_d = env.RECIPIENT_ADDRESS) !== null && _d !== void 0 ? _d : "",
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
- address: (_e = env.RECIPIENT_ADDRESS) !== null && _e !== void 0 ? _e : "",
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 poller = await client.beginSend(emailMessage);
75
- const response = await poller.pollUntilDone();
76
- assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
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
- senderAddress: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
78
+ sender: (_a = env.SENDER_ADDRESS) !== null && _a !== void 0 ? _a : "",
82
79
  recipients: {
83
80
  to: [
84
81
  {
85
- address: (_b = env.RECIPIENT_ADDRESS) !== null && _b !== void 0 ? _b : "",
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
- contentType: "text/plain",
99
- contentInBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
95
+ attachmentType: "txt",
96
+ contentBytesBase64: "ZW1haWwgdGVzdCBhdHRhY2htZW50",
100
97
  },
101
98
  ],
102
99
  };
103
- const poller = await client.beginSend(emailMessage);
104
- const response = await poller.pollUntilDone();
105
- assert.isTrue(response.status === KnownEmailSendStatus.Succeeded);
106
- }).timeout(120000);
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;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,6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,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"]}
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,CA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,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: "x-ms-content-sha256", value: "Sanitized" },
19
- {
20
- key: "Operation-Location",
21
- value: "https://someEndpoint/emails/operations/someId?api-version=2023-01-15-preview",
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/operations/.*?api`,
28
- value: "emails/operations/someId?api",
31
+ target: `emails/.*/status`,
32
+ value: "emails/Sanitized/status",
29
33
  },
30
34
  ],
31
35
  bodySanitizers: [
32
36
  {
33
37
  regex: true,
34
- target: `"id"\\s?:\\s?"[^"]*"`,
35
- value: `"id":"someId"`,
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,qCA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Content":["// 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: \"x-ms-content-sha256\", value: \"Sanitized\" },\n {\n key: \"Operation-Location\",\n value: \"https://someEndpoint/emails/operations/someId?api-version=2023-01-15-preview\",\n },\n ],\n uriSanitizers: [\n {\n regex: true,\n target: `emails/operations/.*?api`,\n value: \"emails/operations/someId?api\",\n },\n ],\n bodySanitizers: [\n {\n regex: true,\n target: `\"id\"\\\\s?:\\\\s?\"[^\"]*\"`,\n value: `\"id\":\"someId\"`,\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"]}
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,0BAA0B,EAAE,KAAK,EAAE,WAAW,EAAE;QACvD,EAAE,GAAG,EAAE,0BAA0B,EAAE,KAAK,EAAE,WAAW,EAAE;QACvD,EAAE,GAAG,EAAE,wBAAwB,EAAE,KAAK,EAAE,WAAW,EAAE;QACrD,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;QACxC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE;QACnC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE;QACnC,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE;QAC1C,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE;QAC9C,EAAE,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,kDAAkD,EAAE;KACzF;IACD,aAAa,EAAE;QACb;YACE,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,kBAAkB;YAC1B,KAAK,EAAE,yBAAyB;SACjC;KACF;IACD,cAAc,EAAE;QACd;YACE,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,6BAA6B;YACrC,KAAK,EAAE,yBAAyB;SACjC;KACF;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAyB;IAC5D,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.2",
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": ">=3.0.0-alpha <3.0.0-alphb",
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",