@azure/communication-email 1.0.1-beta.1 → 1.0.1-beta.2

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 (256) hide show
  1. package/{LICENSE.txt → LICENSE} +4 -4
  2. package/README.md +96 -15
  3. package/dist/browser/emailClient.d.ts +31 -0
  4. package/dist/browser/emailClient.d.ts.map +1 -0
  5. package/{dist-esm/src → dist/browser}/emailClient.js +10 -6
  6. package/dist/browser/emailClient.js.map +1 -0
  7. package/dist/browser/generated/src/emailRestApiClient.d.ts +17 -0
  8. package/dist/browser/generated/src/emailRestApiClient.d.ts.map +1 -0
  9. package/{dist-esm/src → dist/browser}/generated/src/emailRestApiClient.js +11 -4
  10. package/dist/browser/generated/src/emailRestApiClient.js.map +1 -0
  11. package/dist/browser/generated/src/index.d.ts +4 -0
  12. package/dist/browser/generated/src/index.d.ts.map +1 -0
  13. package/dist/browser/generated/src/index.js +11 -0
  14. package/dist/browser/generated/src/index.js.map +1 -0
  15. package/dist/browser/generated/src/lroImpl.d.ts +16 -0
  16. package/dist/browser/generated/src/lroImpl.d.ts.map +1 -0
  17. package/{dist-esm/src → dist/browser}/generated/src/lroImpl.js +11 -3
  18. package/dist/browser/generated/src/lroImpl.js.map +1 -0
  19. package/{types/communication-email.d.ts → dist/browser/generated/src/models/index.d.ts} +184 -215
  20. package/dist/browser/generated/src/models/index.d.ts.map +1 -0
  21. package/dist/browser/generated/src/models/mappers.d.ts +15 -0
  22. package/dist/browser/generated/src/models/mappers.d.ts.map +1 -0
  23. package/dist/browser/generated/src/models/parameters.d.ts +10 -0
  24. package/dist/browser/generated/src/models/parameters.d.ts.map +1 -0
  25. package/{dist-esm/src → dist/browser}/generated/src/models/parameters.js +1 -1
  26. package/{dist-esm/src → dist/browser}/generated/src/models/parameters.js.map +1 -1
  27. package/dist/browser/generated/src/operations/email.d.ts +33 -0
  28. package/dist/browser/generated/src/operations/email.d.ts.map +1 -0
  29. package/{dist-esm/src → dist/browser}/generated/src/operations/email.js +15 -9
  30. package/dist/browser/generated/src/operations/email.js.map +1 -0
  31. package/dist/browser/generated/src/operations/index.d.ts +2 -0
  32. package/dist/browser/generated/src/operations/index.d.ts.map +1 -0
  33. package/{dist-esm/src/generated/src → dist/browser/generated/src/operations}/index.js +1 -3
  34. package/{dist-esm/src → dist/browser}/generated/src/operations/index.js.map +1 -1
  35. package/dist/browser/generated/src/operationsInterfaces/email.d.ts +25 -0
  36. package/dist/browser/generated/src/operationsInterfaces/email.d.ts.map +1 -0
  37. package/dist/browser/generated/src/operationsInterfaces/email.js.map +1 -0
  38. package/dist/browser/generated/src/operationsInterfaces/index.d.ts +2 -0
  39. package/dist/browser/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  40. package/dist/browser/generated/src/operationsInterfaces/index.js +9 -0
  41. package/{dist-esm/src → dist/browser}/generated/src/operationsInterfaces/index.js.map +1 -1
  42. package/dist/browser/index.d.ts +3 -0
  43. package/dist/browser/index.d.ts.map +1 -0
  44. package/dist/browser/index.js +5 -0
  45. package/dist/browser/index.js.map +1 -0
  46. package/dist/browser/logger.d.ts +5 -0
  47. package/dist/browser/logger.d.ts.map +1 -0
  48. package/dist/browser/models.d.ts +57 -0
  49. package/dist/browser/models.d.ts.map +1 -0
  50. package/dist/browser/models.js +4 -0
  51. package/dist/browser/models.js.map +1 -0
  52. package/dist/browser/package.json +3 -0
  53. package/dist/commonjs/emailClient.d.ts +31 -0
  54. package/dist/commonjs/emailClient.d.ts.map +1 -0
  55. package/dist/commonjs/emailClient.js +46 -0
  56. package/dist/commonjs/emailClient.js.map +1 -0
  57. package/dist/commonjs/generated/src/emailRestApiClient.d.ts +17 -0
  58. package/dist/commonjs/generated/src/emailRestApiClient.d.ts.map +1 -0
  59. package/dist/commonjs/generated/src/emailRestApiClient.js +81 -0
  60. package/dist/commonjs/generated/src/emailRestApiClient.js.map +1 -0
  61. package/dist/commonjs/generated/src/index.d.ts +4 -0
  62. package/dist/commonjs/generated/src/index.d.ts.map +1 -0
  63. package/dist/commonjs/generated/src/index.js +16 -0
  64. package/dist/commonjs/generated/src/index.js.map +1 -0
  65. package/dist/commonjs/generated/src/lroImpl.d.ts +16 -0
  66. package/dist/commonjs/generated/src/lroImpl.d.ts.map +1 -0
  67. package/dist/commonjs/generated/src/lroImpl.js +37 -0
  68. package/dist/commonjs/generated/src/lroImpl.js.map +1 -0
  69. package/dist/commonjs/generated/src/models/index.d.ts +184 -0
  70. package/dist/commonjs/generated/src/models/index.d.ts.map +1 -0
  71. package/dist/commonjs/generated/src/models/index.js +25 -0
  72. package/dist/commonjs/generated/src/models/index.js.map +1 -0
  73. package/dist/commonjs/generated/src/models/mappers.d.ts +15 -0
  74. package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -0
  75. package/dist/commonjs/generated/src/models/mappers.js +388 -0
  76. package/dist/commonjs/generated/src/models/mappers.js.map +1 -0
  77. package/dist/commonjs/generated/src/models/parameters.d.ts +10 -0
  78. package/dist/commonjs/generated/src/models/parameters.d.ts.map +1 -0
  79. package/dist/commonjs/generated/src/models/parameters.js +88 -0
  80. package/dist/commonjs/generated/src/models/parameters.js.map +1 -0
  81. package/dist/commonjs/generated/src/operations/email.d.ts +33 -0
  82. package/dist/commonjs/generated/src/operations/email.d.ts.map +1 -0
  83. package/dist/commonjs/generated/src/operations/email.js +146 -0
  84. package/dist/commonjs/generated/src/operations/email.js.map +1 -0
  85. package/dist/commonjs/generated/src/operations/index.d.ts +2 -0
  86. package/dist/commonjs/generated/src/operations/index.d.ts.map +1 -0
  87. package/dist/commonjs/generated/src/operations/index.js +12 -0
  88. package/dist/commonjs/generated/src/operations/index.js.map +1 -0
  89. package/dist/commonjs/generated/src/operationsInterfaces/email.d.ts +25 -0
  90. package/dist/commonjs/generated/src/operationsInterfaces/email.d.ts.map +1 -0
  91. package/dist/commonjs/generated/src/operationsInterfaces/email.js +10 -0
  92. package/dist/commonjs/generated/src/operationsInterfaces/email.js.map +1 -0
  93. package/dist/commonjs/generated/src/operationsInterfaces/index.d.ts +2 -0
  94. package/dist/commonjs/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  95. package/dist/commonjs/generated/src/operationsInterfaces/index.js +12 -0
  96. package/dist/commonjs/generated/src/operationsInterfaces/index.js.map +1 -0
  97. package/dist/commonjs/index.d.ts +3 -0
  98. package/dist/commonjs/index.d.ts.map +1 -0
  99. package/dist/commonjs/index.js +8 -0
  100. package/dist/commonjs/index.js.map +1 -0
  101. package/dist/commonjs/logger.d.ts +5 -0
  102. package/dist/commonjs/logger.d.ts.map +1 -0
  103. package/dist/commonjs/logger.js +11 -0
  104. package/dist/commonjs/logger.js.map +1 -0
  105. package/dist/commonjs/models.d.ts +57 -0
  106. package/dist/commonjs/models.d.ts.map +1 -0
  107. package/dist/commonjs/models.js +8 -0
  108. package/dist/commonjs/models.js.map +1 -0
  109. package/dist/commonjs/package.json +3 -0
  110. package/dist/commonjs/tsdoc-metadata.json +11 -0
  111. package/dist/esm/emailClient.d.ts +31 -0
  112. package/dist/esm/emailClient.d.ts.map +1 -0
  113. package/dist/esm/emailClient.js +42 -0
  114. package/dist/esm/emailClient.js.map +1 -0
  115. package/dist/esm/generated/src/emailRestApiClient.d.ts +17 -0
  116. package/dist/esm/generated/src/emailRestApiClient.d.ts.map +1 -0
  117. package/dist/esm/generated/src/emailRestApiClient.js +76 -0
  118. package/dist/esm/generated/src/emailRestApiClient.js.map +1 -0
  119. package/dist/esm/generated/src/index.d.ts +4 -0
  120. package/dist/esm/generated/src/index.d.ts.map +1 -0
  121. package/dist/esm/generated/src/index.js +11 -0
  122. package/dist/esm/generated/src/index.js.map +1 -0
  123. package/dist/esm/generated/src/lroImpl.d.ts +16 -0
  124. package/dist/esm/generated/src/lroImpl.d.ts.map +1 -0
  125. package/dist/esm/generated/src/lroImpl.js +33 -0
  126. package/dist/esm/generated/src/lroImpl.js.map +1 -0
  127. package/dist/esm/generated/src/models/index.d.ts +184 -0
  128. package/dist/esm/generated/src/models/index.d.ts.map +1 -0
  129. package/dist/esm/generated/src/models/index.js +22 -0
  130. package/dist/esm/generated/src/models/index.js.map +1 -0
  131. package/dist/esm/generated/src/models/mappers.d.ts +15 -0
  132. package/dist/esm/generated/src/models/mappers.d.ts.map +1 -0
  133. package/dist/esm/generated/src/models/mappers.js +385 -0
  134. package/dist/esm/generated/src/models/mappers.js.map +1 -0
  135. package/dist/esm/generated/src/models/parameters.d.ts +10 -0
  136. package/dist/esm/generated/src/models/parameters.d.ts.map +1 -0
  137. package/dist/esm/generated/src/models/parameters.js +85 -0
  138. package/dist/esm/generated/src/models/parameters.js.map +1 -0
  139. package/dist/esm/generated/src/operations/email.d.ts +33 -0
  140. package/dist/esm/generated/src/operations/email.d.ts.map +1 -0
  141. package/dist/esm/generated/src/operations/email.js +141 -0
  142. package/dist/esm/generated/src/operations/email.js.map +1 -0
  143. package/dist/esm/generated/src/operations/index.d.ts +2 -0
  144. package/dist/esm/generated/src/operations/index.d.ts.map +1 -0
  145. package/dist/esm/generated/src/operations/index.js +9 -0
  146. package/dist/esm/generated/src/operations/index.js.map +1 -0
  147. package/dist/esm/generated/src/operationsInterfaces/email.d.ts +25 -0
  148. package/dist/esm/generated/src/operationsInterfaces/email.d.ts.map +1 -0
  149. package/{dist-esm/src/generated/src/operationsInterfaces/index.js → dist/esm/generated/src/operationsInterfaces/email.js} +2 -2
  150. package/dist/esm/generated/src/operationsInterfaces/email.js.map +1 -0
  151. package/dist/esm/generated/src/operationsInterfaces/index.d.ts +2 -0
  152. package/dist/esm/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  153. package/dist/esm/generated/src/operationsInterfaces/index.js +9 -0
  154. package/dist/esm/generated/src/operationsInterfaces/index.js.map +1 -0
  155. package/dist/esm/index.d.ts +3 -0
  156. package/dist/esm/index.d.ts.map +1 -0
  157. package/dist/esm/index.js +5 -0
  158. package/dist/esm/index.js.map +1 -0
  159. package/dist/esm/logger.d.ts +5 -0
  160. package/dist/esm/logger.d.ts.map +1 -0
  161. package/dist/esm/logger.js +8 -0
  162. package/dist/esm/logger.js.map +1 -0
  163. package/dist/esm/models.d.ts +57 -0
  164. package/dist/esm/models.d.ts.map +1 -0
  165. package/dist/esm/models.js +4 -0
  166. package/dist/esm/models.js.map +1 -0
  167. package/dist/esm/package.json +3 -0
  168. package/dist/react-native/emailClient.d.ts +31 -0
  169. package/dist/react-native/emailClient.d.ts.map +1 -0
  170. package/dist/react-native/emailClient.js +42 -0
  171. package/dist/react-native/emailClient.js.map +1 -0
  172. package/dist/react-native/generated/src/emailRestApiClient.d.ts +17 -0
  173. package/dist/react-native/generated/src/emailRestApiClient.d.ts.map +1 -0
  174. package/dist/react-native/generated/src/emailRestApiClient.js +76 -0
  175. package/dist/react-native/generated/src/emailRestApiClient.js.map +1 -0
  176. package/dist/react-native/generated/src/index.d.ts +4 -0
  177. package/dist/react-native/generated/src/index.d.ts.map +1 -0
  178. package/dist/react-native/generated/src/index.js +11 -0
  179. package/dist/react-native/generated/src/index.js.map +1 -0
  180. package/dist/react-native/generated/src/lroImpl.d.ts +16 -0
  181. package/dist/react-native/generated/src/lroImpl.d.ts.map +1 -0
  182. package/dist/react-native/generated/src/lroImpl.js +33 -0
  183. package/dist/react-native/generated/src/lroImpl.js.map +1 -0
  184. package/dist/react-native/generated/src/models/index.d.ts +184 -0
  185. package/dist/react-native/generated/src/models/index.d.ts.map +1 -0
  186. package/dist/react-native/generated/src/models/index.js +22 -0
  187. package/dist/react-native/generated/src/models/index.js.map +1 -0
  188. package/dist/react-native/generated/src/models/mappers.d.ts +15 -0
  189. package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -0
  190. package/dist/react-native/generated/src/models/mappers.js +385 -0
  191. package/dist/react-native/generated/src/models/mappers.js.map +1 -0
  192. package/dist/react-native/generated/src/models/parameters.d.ts +10 -0
  193. package/dist/react-native/generated/src/models/parameters.d.ts.map +1 -0
  194. package/dist/react-native/generated/src/models/parameters.js +85 -0
  195. package/dist/react-native/generated/src/models/parameters.js.map +1 -0
  196. package/dist/react-native/generated/src/operations/email.d.ts +33 -0
  197. package/dist/react-native/generated/src/operations/email.d.ts.map +1 -0
  198. package/dist/react-native/generated/src/operations/email.js +141 -0
  199. package/dist/react-native/generated/src/operations/email.js.map +1 -0
  200. package/dist/react-native/generated/src/operations/index.d.ts +2 -0
  201. package/dist/react-native/generated/src/operations/index.d.ts.map +1 -0
  202. package/dist/react-native/generated/src/operations/index.js +9 -0
  203. package/dist/react-native/generated/src/operations/index.js.map +1 -0
  204. package/dist/react-native/generated/src/operationsInterfaces/email.d.ts +25 -0
  205. package/dist/react-native/generated/src/operationsInterfaces/email.d.ts.map +1 -0
  206. package/{dist-esm/src/generated/src/operations/index.js → dist/react-native/generated/src/operationsInterfaces/email.js} +2 -2
  207. package/dist/react-native/generated/src/operationsInterfaces/email.js.map +1 -0
  208. package/dist/react-native/generated/src/operationsInterfaces/index.d.ts +2 -0
  209. package/dist/react-native/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  210. package/dist/react-native/generated/src/operationsInterfaces/index.js +9 -0
  211. package/dist/react-native/generated/src/operationsInterfaces/index.js.map +1 -0
  212. package/dist/react-native/index.d.ts +3 -0
  213. package/dist/react-native/index.d.ts.map +1 -0
  214. package/dist/react-native/index.js +5 -0
  215. package/dist/react-native/index.js.map +1 -0
  216. package/dist/react-native/logger.d.ts +5 -0
  217. package/dist/react-native/logger.d.ts.map +1 -0
  218. package/dist/react-native/logger.js +8 -0
  219. package/dist/react-native/logger.js.map +1 -0
  220. package/dist/react-native/models.d.ts +57 -0
  221. package/dist/react-native/models.d.ts.map +1 -0
  222. package/dist/react-native/models.js +4 -0
  223. package/dist/react-native/models.js.map +1 -0
  224. package/dist/react-native/package.json +3 -0
  225. package/package.json +83 -66
  226. package/dist/index.js +0 -802
  227. package/dist/index.js.map +0 -1
  228. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +0 -46
  229. package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +0 -1
  230. package/dist-esm/samples-dev/sendEmailSingleRecipient.js +0 -40
  231. package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +0 -1
  232. package/dist-esm/samples-dev/sendEmailWithAttachments.js +0 -47
  233. package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +0 -1
  234. package/dist-esm/samples-dev/sendEmailWithInlineAttachments.js +0 -48
  235. package/dist-esm/samples-dev/sendEmailWithInlineAttachments.js.map +0 -1
  236. package/dist-esm/src/emailClient.js.map +0 -1
  237. package/dist-esm/src/generated/src/emailRestApiClient.js.map +0 -1
  238. package/dist-esm/src/generated/src/index.js.map +0 -1
  239. package/dist-esm/src/generated/src/lroImpl.js.map +0 -1
  240. package/dist-esm/src/generated/src/operations/email.js.map +0 -1
  241. package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +0 -1
  242. package/dist-esm/src/index.js +0 -5
  243. package/dist-esm/src/index.js.map +0 -1
  244. package/dist-esm/src/models.js +0 -4
  245. package/dist-esm/src/models.js.map +0 -1
  246. package/dist-esm/test/public/emailClient.spec.js +0 -138
  247. package/dist-esm/test/public/emailClient.spec.js.map +0 -1
  248. package/dist-esm/test/public/utils/recordedClient.js +0 -59
  249. package/dist-esm/test/public/utils/recordedClient.js.map +0 -1
  250. /package/{dist-esm/src → dist/browser}/generated/src/models/index.js +0 -0
  251. /package/{dist-esm/src → dist/browser}/generated/src/models/index.js.map +0 -0
  252. /package/{dist-esm/src → dist/browser}/generated/src/models/mappers.js +0 -0
  253. /package/{dist-esm/src → dist/browser}/generated/src/models/mappers.js.map +0 -0
  254. /package/{dist-esm/src → dist/browser}/generated/src/operationsInterfaces/email.js +0 -0
  255. /package/{dist-esm/src → dist/browser}/logger.js +0 -0
  256. /package/{dist-esm/src → dist/browser}/logger.js.map +0 -0
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ Copyright (c) Microsoft Corporation.
2
2
 
3
- Copyright (c) 2022 Microsoft
3
+ MIT License
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions:
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -24,8 +24,8 @@ npm install @azure/communication-email
24
24
 
25
25
  Email clients can be authenticated using the connection string acquired from an Azure Communication Resource in the [Azure Portal][azure_portal].
26
26
 
27
- ```javascript
28
- const { EmailClient } = require("@azure/communication-email");
27
+ ```ts snippet:ReadmeSampleCreateClient_ConnectionString
28
+ import { EmailClient } from "@azure/communication-email";
29
29
 
30
30
  const connectionString = `endpoint=https://<resource-name>.communication.azure.com/;accessKey=<Base64-Encoded-Key>`;
31
31
  const client = new EmailClient(connectionString);
@@ -40,7 +40,7 @@ npm install @azure/identity
40
40
  The [`@azure/identity`][azure_identity] package provides a variety of credential types that your application can use to do this. The README for @azure/identity provides more details and samples to get you started.
41
41
  AZURE_CLIENT_SECRET, AZURE_CLIENT_ID and AZURE_TENANT_ID environment variables are needed to create a DefaultAzureCredential object.
42
42
 
43
- ```typescript
43
+ ```ts snippet:ReadmeSampleCreateClient_AAD
44
44
  import { DefaultAzureCredential } from "@azure/identity";
45
45
  import { EmailClient } from "@azure/communication-email";
46
46
 
@@ -53,7 +53,14 @@ const client = new EmailClient(endpoint, credential);
53
53
 
54
54
  To send an email message, call the `beginSend` function from the `EmailClient`. This will return a poller. You can use this poller to check on the status of the operation and retrieve the result once it's finished.
55
55
 
56
- ```javascript Snippet:Azure_Communication_Email_Send
56
+ ```ts snippet:ReadmeSample_SendEmail
57
+ import { DefaultAzureCredential } from "@azure/identity";
58
+ import { EmailClient } from "@azure/communication-email";
59
+
60
+ const endpoint = "https://<resource-name>.communication.azure.com";
61
+ const credential = new DefaultAzureCredential();
62
+ const client = new EmailClient(endpoint, credential);
63
+
57
64
  const message = {
58
65
  senderAddress: "sender@contoso.com",
59
66
  content: {
@@ -70,7 +77,7 @@ const message = {
70
77
  },
71
78
  };
72
79
 
73
- const poller = await emailClient.beginSend(message);
80
+ const poller = await client.beginSend(message);
74
81
  const response = await poller.pollUntilDone();
75
82
  ```
76
83
 
@@ -78,7 +85,14 @@ const response = await poller.pollUntilDone();
78
85
 
79
86
  To send an email message to multiple recipients, add a object for each recipient type and an object for each recipient.
80
87
 
81
- ```javascript Snippet:Azure_Communication_Email_Send_Multiple_Recipients
88
+ ```ts snippet:ReadmeSample_SendEmailToMultipleRecipients
89
+ import { DefaultAzureCredential } from "@azure/identity";
90
+ import { EmailClient } from "@azure/communication-email";
91
+
92
+ const endpoint = "https://<resource-name>.communication.azure.com";
93
+ const credential = new DefaultAzureCredential();
94
+ const client = new EmailClient(endpoint, credential);
95
+
82
96
  const message = {
83
97
  senderAddress: "sender@contoso.com",
84
98
  content: {
@@ -119,7 +133,7 @@ const message = {
119
133
  },
120
134
  };
121
135
 
122
- const poller = await emailClient.beginSend(message);
136
+ const poller = await client.beginSend(message);
123
137
  const response = await poller.pollUntilDone();
124
138
  ```
125
139
 
@@ -127,8 +141,17 @@ const response = await poller.pollUntilDone();
127
141
 
128
142
  Azure Communication Services support sending email with attachments.
129
143
 
130
- ```javascript Snippet:Azure_Communication_Email_Send_With_Attachments
131
- const filePath = "C://readme.txt";
144
+ ```ts snippet:ReadmeSample_SendEmailWithAttachments
145
+ import { DefaultAzureCredential } from "@azure/identity";
146
+ import { EmailClient } from "@azure/communication-email";
147
+ import { basename } from "node:path";
148
+ import { readFileSync } from "node:fs";
149
+
150
+ const endpoint = "https://<resource-name>.communication.azure.com";
151
+ const credential = new DefaultAzureCredential();
152
+ const client = new EmailClient(endpoint, credential);
153
+
154
+ const filePath = "path/to/readme.txt";
132
155
 
133
156
  const message = {
134
157
  senderAddress: "sender@contoso.com",
@@ -146,17 +169,75 @@ const message = {
146
169
  },
147
170
  attachments: [
148
171
  {
149
- name: path.basename(filePath),
172
+ name: basename(filePath),
150
173
  contentType: "text/plain",
151
174
  contentInBase64: readFileSync(filePath, "base64"),
152
175
  },
153
176
  ],
154
177
  };
155
178
 
156
- const poller = await emailClient.beginSend(message);
179
+ const poller = await client.beginSend(message);
157
180
  const response = await poller.pollUntilDone();
158
181
  ```
159
182
 
183
+ ### Send Email with Inline Attachments
184
+
185
+ Azure Communication Services support sending email with inline attachments.
186
+ Adding an optional `contentId` parameter to an `attachment` will make it an inline attachment.
187
+
188
+ ```ts snippet:ReadmeSample_SendEmailWithInlineAttachments
189
+ import { DefaultAzureCredential } from "@azure/identity";
190
+ import { EmailClient } from "@azure/communication-email";
191
+ import { readFileSync } from "node:fs";
192
+
193
+ const endpoint = "https://<resource-name>.communication.azure.com";
194
+ const credential = new DefaultAzureCredential();
195
+ const client = new EmailClient(endpoint, credential);
196
+
197
+ const imageBuffer = readFileSync("path/to/my_inline_image.jpg");
198
+ const contentInBase64 = imageBuffer.toString("base64");
199
+
200
+ const message = {
201
+ senderAddress: "sender@contoso.com",
202
+ content: {
203
+ subject: "This is the subject",
204
+ plainText: "This is the body",
205
+ html: '<html>This is the body<br /><img src="cid:inline_image" /></html>',
206
+ },
207
+ recipients: {
208
+ to: [
209
+ {
210
+ address: "customer@domain.com",
211
+ displayName: "Customer Name",
212
+ },
213
+ ],
214
+ },
215
+ attachments: [
216
+ {
217
+ name: "my_inline_image.jpg",
218
+ contentType: "image/jpeg",
219
+ contentInBase64: contentInBase64,
220
+ contentId: "inline_image",
221
+ },
222
+ ],
223
+ };
224
+
225
+ const poller = await client.beginSend(message);
226
+ const response = await poller.pollUntilDone();
227
+ ```
228
+
229
+ ## Troubleshooting
230
+
231
+ ### Logging
232
+
233
+ Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
234
+
235
+ ```ts snippet:SetLogLevel
236
+ import { setLogLevel } from "@azure/logger";
237
+
238
+ setLogLevel("info");
239
+ ```
240
+
160
241
  ## Next steps
161
242
 
162
243
  - [Read more about Email in Azure Communication Services][nextsteps]
@@ -177,11 +258,11 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
177
258
  [coc_contact]: mailto:opencode@microsoft.com
178
259
  [defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
179
260
  [azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
180
- [communication_resource_docs]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
261
+ [communication_resource_docs]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
181
262
  [email_resource_docs]: https://aka.ms/acsemail/createemailresource
182
- [communication_resource_create_portal]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
183
- [communication_resource_create_power_shell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
184
- [communication_resource_create_net]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net
263
+ [communication_resource_create_portal]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp
264
+ [communication_resource_create_power_shell]: https://learn.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
265
+ [communication_resource_create_net]: https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-net
185
266
  [package]: https://www.nuget.org/packages/Azure.Communication.Common/
186
267
  [product_docs]: https://aka.ms/acsemail/overview
187
268
  [nextsteps]: https://aka.ms/acsemail/overview
@@ -0,0 +1,31 @@
1
+ import type { EmailClientOptions, EmailMessage, EmailSendOptionalParams } from "./models.js";
2
+ import type { KeyCredential, TokenCredential } from "@azure/core-auth";
3
+ import type { PollerLike, PollOperationState } from "@azure/core-lro";
4
+ import type { EmailSendResponse } from "./generated/src/index.js";
5
+ /**
6
+ * The Email service client.
7
+ */
8
+ export declare class EmailClient {
9
+ private readonly generatedClient;
10
+ /**
11
+ * Initializes a new instance of the EmailClient class.
12
+ * @param connectionString - Connection string to connect to an Azure Communication Service resource.
13
+ * Example: "endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret";
14
+ * @param options - Optional. Options to configure the HTTP pipeline.
15
+ */
16
+ constructor(connectionString: string, options?: EmailClientOptions);
17
+ /**
18
+ * Initializes a new instance of the EmailClient class using an Azure KeyCredential.
19
+ * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).
20
+ * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.
21
+ * @param options - Optional. Options to configure the HTTP pipeline.
22
+ */
23
+ constructor(endpoint: string, credential: KeyCredential | TokenCredential, options?: EmailClientOptions);
24
+ /**
25
+ * Queues an email message to be sent to one or more recipients
26
+ * @param message - Message payload for sending an email
27
+ * @param options - The options parameters.
28
+ */
29
+ beginSend(message: EmailMessage, options?: EmailSendOptionalParams): Promise<PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>>;
30
+ }
31
+ //# sourceMappingURL=emailClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailClient.d.ts","sourceRoot":"","sources":["../../src/emailClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAStE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAUlE;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAqB;IAErD;;;;;OAKG;gBACS,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAElE;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,GAAG,eAAe,EAC3C,OAAO,CAAC,EAAE,kBAAkB;IAyB9B;;;;OAIG;IACH,SAAS,CACP,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,CAAC;CAGjF"}
@@ -2,8 +2,8 @@
2
2
  // Licensed under the MIT License.
3
3
  import { isTokenCredential } from "@azure/core-auth";
4
4
  import { createCommunicationAuthPolicy, isKeyCredential, parseClientArguments, } from "@azure/communication-common";
5
- import { EmailRestApiClient } from "./generated/src/emailRestApiClient";
6
- import { logger } from "./logger";
5
+ import { EmailRestApiClient } from "./generated/src/emailRestApiClient.js";
6
+ import { logger } from "./logger.js";
7
7
  /**
8
8
  * Checks whether the type of a value is EmailClientOptions or not.
9
9
  *
@@ -14,14 +14,18 @@ const isEmailClientOptions = (options) => !!options && !isTokenCredential(option
14
14
  * The Email service client.
15
15
  */
16
16
  export class EmailClient {
17
+ generatedClient;
17
18
  constructor(connectionStringOrUrl, credentialOrOptions, maybeOptions = {}) {
18
19
  const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);
19
20
  const options = isEmailClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;
20
- const internalPipelineOptions = Object.assign(Object.assign({}, options), {
21
- loggingOptions: {
22
- logger: logger.info,
21
+ const internalPipelineOptions = {
22
+ ...options,
23
+ ...{
24
+ loggingOptions: {
25
+ logger: logger.info,
26
+ },
23
27
  },
24
- });
28
+ };
25
29
  const authPolicy = createCommunicationAuthPolicy(credential);
26
30
  this.generatedClient = new EmailRestApiClient(url, internalPipelineOptions);
27
31
  this.generatedClient.pipeline.addPolicy(authPolicy);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailClient.js","sourceRoot":"","sources":["../../src/emailClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,CAAC,OAAY,EAAiC,EAAE,CAC3E,CAAC,CAAC,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,OAAO,WAAW;IACL,eAAe,CAAqB;IAsBrD,YACE,qBAA6B,EAC7B,mBAA0E,EAC1E,eAAmC,EAAE;QAErC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC;QAE/F,MAAM,uBAAuB,GAA4B;YACvD,GAAG,OAAO;YACV,GAAG;gBACD,cAAc,EAAE;oBACd,MAAM,EAAE,MAAM,CAAC,IAAI;iBACpB;aACF;SACF,CAAC;QAEF,MAAM,UAAU,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,eAAe,GAAG,IAAI,kBAAkB,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;QAC5E,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,SAAS,CACP,OAAqB,EACrB,OAAiC;QAEjC,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { EmailClientOptions, EmailMessage, EmailSendOptionalParams } from \"./models.js\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport type { PollerLike, PollOperationState } from \"@azure/core-lro\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport { EmailRestApiClient } from \"./generated/src/emailRestApiClient.js\";\nimport type { InternalPipelineOptions } from \"@azure/core-rest-pipeline\";\nimport { logger } from \"./logger.js\";\nimport type { EmailSendResponse } from \"./generated/src/index.js\";\n\n/**\n * Checks whether the type of a value is EmailClientOptions or not.\n *\n * @param options - The value being checked.\n */\nconst isEmailClientOptions = (options: any): options is EmailClientOptions =>\n !!options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * The Email service client.\n */\nexport class EmailClient {\n private readonly generatedClient: EmailRestApiClient;\n\n /**\n * Initializes a new instance of the EmailClient class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(connectionString: string, options?: EmailClientOptions);\n\n /**\n * Initializes a new instance of the EmailClient class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n constructor(\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options?: EmailClientOptions,\n );\n\n constructor(\n connectionStringOrUrl: string,\n credentialOrOptions?: EmailClientOptions | TokenCredential | KeyCredential,\n maybeOptions: EmailClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(connectionStringOrUrl, credentialOrOptions);\n const options = isEmailClientOptions(credentialOrOptions) ? credentialOrOptions : maybeOptions;\n\n const internalPipelineOptions: InternalPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.generatedClient = new EmailRestApiClient(url, internalPipelineOptions);\n this.generatedClient.pipeline.addPolicy(authPolicy);\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 beginSend(\n message: EmailMessage,\n options?: EmailSendOptionalParams,\n ): Promise<PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>> {\n return this.generatedClient.email.beginSend(message, options);\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import * as coreClient from "@azure/core-client";
2
+ import { Email } from "./operationsInterfaces/index.js";
3
+ import { EmailRestApiClientOptionalParams } from "./models/index.js";
4
+ export declare class EmailRestApiClient extends coreClient.ServiceClient {
5
+ endpoint: string;
6
+ apiVersion: string;
7
+ /**
8
+ * Initializes a new instance of the EmailRestApiClient class.
9
+ * @param endpoint The communication resource, for example https://my-resource.communication.azure.com
10
+ * @param options The parameter options
11
+ */
12
+ constructor(endpoint: string, options?: EmailRestApiClientOptionalParams);
13
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
14
+ private addCustomApiVersionPolicy;
15
+ email: Email;
16
+ }
17
+ //# sourceMappingURL=emailRestApiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailRestApiClient.d.ts","sourceRoot":"","sources":["../../../../src/generated/src/emailRestApiClient.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAOjD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAErE,qBAAa,kBAAmB,SAAQ,UAAU,CAAC,aAAa;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;gBACS,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gCAAgC;IAqCxE,8GAA8G;IAC9G,OAAO,CAAC,yBAAyB;IA2BjC,KAAK,EAAE,KAAK,CAAC;CACd"}
@@ -6,15 +6,16 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
  import * as coreClient from "@azure/core-client";
9
- import { EmailImpl } from "./operations";
9
+ import { EmailImpl } from "./operations/index.js";
10
10
  export class EmailRestApiClient extends coreClient.ServiceClient {
11
+ endpoint;
12
+ apiVersion;
11
13
  /**
12
14
  * Initializes a new instance of the EmailRestApiClient class.
13
15
  * @param endpoint The communication resource, for example https://my-resource.communication.azure.com
14
16
  * @param options The parameter options
15
17
  */
16
18
  constructor(endpoint, options) {
17
- var _a, _b;
18
19
  if (endpoint === undefined) {
19
20
  throw new Error("'endpoint' cannot be null");
20
21
  }
@@ -29,9 +30,14 @@ export class EmailRestApiClient extends coreClient.ServiceClient {
29
30
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
30
31
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
31
32
  : `${packageDetails}`;
32
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
33
+ const optionsWithDefaults = {
34
+ ...defaults,
35
+ ...options,
36
+ userAgentOptions: {
33
37
  userAgentPrefix
34
- }, baseUri: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
38
+ },
39
+ baseUri: options.endpoint ?? options.baseUri ?? "{endpoint}"
40
+ };
35
41
  super(optionsWithDefaults);
36
42
  // Parameter assignments
37
43
  this.endpoint = endpoint;
@@ -65,5 +71,6 @@ export class EmailRestApiClient extends coreClient.ServiceClient {
65
71
  };
66
72
  this.pipeline.addPolicy(apiVersionPolicy);
67
73
  }
74
+ email;
68
75
  }
69
76
  //# sourceMappingURL=emailRestApiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emailRestApiClient.js","sourceRoot":"","sources":["../../../../src/generated/src/emailRestApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAMjD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,MAAM,OAAO,kBAAmB,SAAQ,UAAU,CAAC,aAAa;IAC9D,QAAQ,CAAS;IACjB,UAAU,CAAS;IAEnB;;;;OAIG;IACH,YAAY,QAAgB,EAAE,OAA0C;QACtE,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;QACD,MAAM,QAAQ,GAAqC;YACjD,kBAAkB,EAAE,iCAAiC;SACtD,CAAC;QAEF,MAAM,cAAc,GAAG,oCAAoC,CAAC;QAC5D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;YAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,cAAc,EAAE;YACjE,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC;QAE1B,MAAM,mBAAmB,GAAG;YAC1B,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,gBAAgB,EAAE;gBAChB,eAAe;aAChB;YACD,OAAO,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,YAAY;SAC7D,CAAC;QACF,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,oBAAoB,CAAC;QAC7D,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,8GAA8G;IACtG,yBAAyB,CAAC,UAAmB;QACnD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,gBAAgB,GAAG;YACvB,IAAI,EAAE,wBAAwB;YAC9B,KAAK,CAAC,WAAW,CACf,OAAwB,EACxB,IAAiB;gBAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;wBACjD,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;4BACrC,OAAO,cAAc,GAAG,UAAU,CAAC;wBACrC,CAAC;6BAAM,CAAC;4BACN,OAAO,IAAI,CAAC;wBACd,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAQ;CACd","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 coreClient from \"@azure/core-client\";\nimport {\n PipelineRequest,\n PipelineResponse,\n SendRequest\n} from \"@azure/core-rest-pipeline\";\nimport { EmailImpl } from \"./operations/index.js\";\nimport { Email } from \"./operationsInterfaces/index.js\";\nimport { EmailRestApiClientOptionalParams } from \"./models/index.js\";\n\nexport class EmailRestApiClient extends coreClient.ServiceClient {\n endpoint: string;\n apiVersion: string;\n\n /**\n * Initializes a new instance of the EmailRestApiClient class.\n * @param endpoint The communication resource, for example https://my-resource.communication.azure.com\n * @param options The parameter options\n */\n constructor(endpoint: string, options?: EmailRestApiClientOptionalParams) {\n if (endpoint === undefined) {\n throw new Error(\"'endpoint' cannot be null\");\n }\n\n // Initializing default values for options\n if (!options) {\n options = {};\n }\n const defaults: EmailRestApiClientOptionalParams = {\n requestContentType: \"application/json; charset=utf-8\"\n };\n\n const packageDetails = `azsdk-js-communication-email/1.0.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`\n : `${packageDetails}`;\n\n const optionsWithDefaults = {\n ...defaults,\n ...options,\n userAgentOptions: {\n userAgentPrefix\n },\n baseUri: options.endpoint ?? options.baseUri ?? \"{endpoint}\"\n };\n super(optionsWithDefaults);\n // Parameter assignments\n this.endpoint = endpoint;\n\n // Assigning values to Constant parameters\n this.apiVersion = options.apiVersion || \"2024-07-01-preview\";\n this.email = new EmailImpl(this);\n this.addCustomApiVersionPolicy(options.apiVersion);\n }\n\n /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */\n private addCustomApiVersionPolicy(apiVersion?: string) {\n if (!apiVersion) {\n return;\n }\n const apiVersionPolicy = {\n name: \"CustomApiVersionPolicy\",\n async sendRequest(\n request: PipelineRequest,\n next: SendRequest\n ): Promise<PipelineResponse> {\n const param = request.url.split(\"?\");\n if (param.length > 1) {\n const newParams = param[1].split(\"&\").map((item) => {\n if (item.indexOf(\"api-version\") > -1) {\n return \"api-version=\" + apiVersion;\n } else {\n return item;\n }\n });\n request.url = param[0] + \"?\" + newParams.join(\"&\");\n }\n return next(request);\n }\n };\n this.pipeline.addPolicy(apiVersionPolicy);\n }\n\n email: Email;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./models/index.js";
2
+ export { EmailRestApiClient } from "./emailRestApiClient.js";
3
+ export * from "./operationsInterfaces/index.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/generated/src/index.ts"],"names":[],"mappings":"AAQA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,11 @@
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 "./models/index.js";
9
+ export { EmailRestApiClient } from "./emailRestApiClient.js";
10
+ export * from "./operationsInterfaces/index.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/generated/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,cAAc,iCAAiC,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 \"./models/index.js\";\nexport { EmailRestApiClient } from \"./emailRestApiClient.js\";\nexport * from \"./operationsInterfaces/index.js\";\n"]}
@@ -0,0 +1,16 @@
1
+ import { LongRunningOperation, LroResponse } from "@azure/core-lro";
2
+ export declare class LroImpl<T> implements LongRunningOperation<T> {
3
+ private sendOperationFn;
4
+ private args;
5
+ private spec;
6
+ requestPath: string;
7
+ requestMethod: string;
8
+ constructor(sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>, args: Record<string, unknown>, spec: {
9
+ readonly requestBody?: unknown;
10
+ readonly path?: string;
11
+ readonly httpMethod: string;
12
+ } & Record<string, any>, requestPath?: string, requestMethod?: string);
13
+ sendInitialRequest(): Promise<LroResponse<T>>;
14
+ sendPollRequest(path: string): Promise<LroResponse<T>>;
15
+ }
16
+ //# sourceMappingURL=lroImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lroImpl.d.ts","sourceRoot":"","sources":["../../../../src/generated/src/lroImpl.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEpE,qBAAa,OAAO,CAAC,CAAC,CAAE,YAAW,oBAAoB,CAAC,CAAC,CAAC;IAEtD,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,IAAI;IAKL,WAAW,EAAE,MAAM;IACnB,aAAa,EAAE,MAAM;gBARpB,eAAe,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAClE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE;QACZ,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC7B,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChB,WAAW,GAAE,MAAmB,EAChC,aAAa,GAAE,MAAwB;IAEnC,kBAAkB,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAG7C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAQpE"}
@@ -5,8 +5,12 @@
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 { __rest } from "tslib";
9
8
  export class LroImpl {
9
+ sendOperationFn;
10
+ args;
11
+ spec;
12
+ requestPath;
13
+ requestMethod;
10
14
  constructor(sendOperationFn, args, spec, requestPath = spec.path, requestMethod = spec.httpMethod) {
11
15
  this.sendOperationFn = sendOperationFn;
12
16
  this.args = args;
@@ -18,8 +22,12 @@ export class LroImpl {
18
22
  return this.sendOperationFn(this.args, this.spec);
19
23
  }
20
24
  async sendPollRequest(path) {
21
- const _a = this.spec, { requestBody } = _a, restSpec = __rest(_a, ["requestBody"]);
22
- return this.sendOperationFn(this.args, Object.assign(Object.assign({}, restSpec), { path, httpMethod: "GET" }));
25
+ const { requestBody, ...restSpec } = this.spec;
26
+ return this.sendOperationFn(this.args, {
27
+ ...restSpec,
28
+ path,
29
+ httpMethod: "GET"
30
+ });
23
31
  }
24
32
  }
25
33
  //# sourceMappingURL=lroImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lroImpl.js","sourceRoot":"","sources":["../../../../src/generated/src/lroImpl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,OAAO;IAER;IACA;IACA;IAKD;IACA;IATT,YACU,eAAkE,EAClE,IAA6B,EAC7B,IAIe,EAChB,cAAsB,IAAI,CAAC,IAAK,EAChC,gBAAwB,IAAI,CAAC,UAAU;QARtC,oBAAe,GAAf,eAAe,CAAmD;QAClE,SAAI,GAAJ,IAAI,CAAyB;QAC7B,SAAI,GAAJ,IAAI,CAIW;QAChB,gBAAW,GAAX,WAAW,CAAqB;QAChC,kBAAa,GAAb,aAAa,CAA0B;IAC7C,CAAC;IACG,KAAK,CAAC,kBAAkB;QAC7B,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IACM,KAAK,CAAC,eAAe,CAAC,IAAY;QACvC,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC;QAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE;YACrC,GAAG,QAAQ;YACX,IAAI;YACJ,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { LongRunningOperation, LroResponse } from \"@azure/core-lro\";\n\nexport class LroImpl<T> implements LongRunningOperation<T> {\n constructor(\n private sendOperationFn: (args: any, spec: any) => Promise<LroResponse<T>>,\n private args: Record<string, unknown>,\n private spec: {\n readonly requestBody?: unknown;\n readonly path?: string;\n readonly httpMethod: string;\n } & Record<string, any>,\n public requestPath: string = spec.path!,\n public requestMethod: string = spec.httpMethod\n ) {}\n public async sendInitialRequest(): Promise<LroResponse<T>> {\n return this.sendOperationFn(this.args, this.spec);\n }\n public async sendPollRequest(path: string): Promise<LroResponse<T>> {\n const { requestBody, ...restSpec } = this.spec;\n return this.sendOperationFn(this.args, {\n ...restSpec,\n path,\n httpMethod: \"GET\"\n });\n }\n}\n"]}