@azure/communication-email 1.0.0-beta.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +52 -45
- package/dist/index.js +340 -213
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js +11 -24
- package/dist-esm/samples-dev/sendEmailMultipleRecipients.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js +7 -10
- package/dist-esm/samples-dev/sendEmailSingleRecipient.js.map +1 -1
- package/dist-esm/samples-dev/sendEmailWithAttachments.js +9 -12
- package/dist-esm/samples-dev/sendEmailWithAttachments.js.map +1 -1
- package/dist-esm/src/emailClient.js +8 -34
- package/dist-esm/src/emailClient.js.map +1 -1
- package/dist-esm/src/generated/src/emailRestApiClient.js +53 -10
- package/dist-esm/src/generated/src/emailRestApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/index.js +11 -0
- package/dist-esm/src/generated/src/index.js.map +1 -0
- package/dist-esm/src/generated/src/lroImpl.js +25 -0
- package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
- package/dist-esm/src/generated/src/models/index.js +14 -1
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +133 -85
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +25 -16
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/email.js +79 -40
- package/dist-esm/src/generated/src/operations/email.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/email.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/email.js.map +1 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -0
- package/dist-esm/src/models.js +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/test/public/emailClient.spec.js +98 -127
- package/dist-esm/test/public/emailClient.spec.js.map +1 -1
- package/dist-esm/test/public/utils/recordedClient.js +46 -32
- package/dist-esm/test/public/utils/recordedClient.js.map +1 -1
- package/package.json +16 -15
- package/types/communication-email.d.ts +147 -134
- package/dist-esm/samples-dev/checkMessageStatus.js +0 -46
- package/dist-esm/samples-dev/checkMessageStatus.js.map +0 -1
- package/dist-esm/src/constants.js +0 -4
- package/dist-esm/src/constants.js.map +0 -1
- package/dist-esm/src/generated/src/emailRestApiClientContext.js +0 -38
- package/dist-esm/src/generated/src/emailRestApiClientContext.js.map +0 -1
@@ -1,45 +1,59 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT license.
|
3
|
-
import
|
4
|
-
import { env, record } from "@azure-tools/test-recorder";
|
3
|
+
import { Recorder, env } from "@azure-tools/test-recorder";
|
5
4
|
import { EmailClient } from "../../../src";
|
6
|
-
|
7
|
-
|
8
|
-
if (isNode) {
|
9
|
-
dotenv.config();
|
10
|
-
}
|
11
|
-
const replaceableVariables = {
|
12
|
-
COMMUNICATION_CONNECTION_STRING: "endpoint=https://someEndpoint/;accesskey=someAccessKeyw==",
|
5
|
+
const envSetupForPlayback = {
|
6
|
+
COMMUNICATION_CONNECTION_STRING_EMAIL: "endpoint=https://someEndpoint/;accesskey=someAccessKeyw==",
|
13
7
|
SENDER_ADDRESS: "someSender@contoso.com",
|
14
8
|
RECIPIENT_ADDRESS: "someRecipient@domain.com",
|
15
9
|
};
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
const sanitizerOptions = {
|
11
|
+
connectionStringSanitizers: [
|
12
|
+
{
|
13
|
+
actualConnString: env.COMMUNICATION_CONNECTION_STRING_EMAIL,
|
14
|
+
fakeConnString: envSetupForPlayback["COMMUNICATION_CONNECTION_STRING_EMAIL"],
|
15
|
+
},
|
16
|
+
],
|
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-03-31",
|
22
|
+
},
|
23
|
+
],
|
24
|
+
uriSanitizers: [
|
25
|
+
{
|
26
|
+
regex: true,
|
27
|
+
target: `emails/operations/.*?api`,
|
28
|
+
value: "emails/operations/someId?api",
|
29
|
+
},
|
30
|
+
],
|
31
|
+
bodySanitizers: [
|
32
|
+
{
|
33
|
+
regex: true,
|
34
|
+
target: `"id"\\s?:\\s?"[^"]*"`,
|
35
|
+
value: `"id":"someId"`,
|
36
|
+
},
|
28
37
|
],
|
29
|
-
queryParametersToSkip: [],
|
30
38
|
};
|
31
|
-
export function
|
32
|
-
const recorder =
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
export async function createRecorder(context) {
|
40
|
+
const recorder = new Recorder(context);
|
41
|
+
await recorder.start({ envSetupForPlayback });
|
42
|
+
await recorder.addSanitizers(sanitizerOptions, ["record", "playback"]);
|
43
|
+
await recorder.setMatcher("CustomDefaultMatcher", {
|
44
|
+
excludedHeaders: [
|
45
|
+
"Accept-Language",
|
46
|
+
"x-ms-content-sha256", // This is dependent on the current datetime
|
47
|
+
],
|
48
|
+
});
|
49
|
+
return recorder;
|
37
50
|
}
|
38
|
-
export function
|
39
|
-
|
40
|
-
const
|
51
|
+
export async function createRecordedEmailClientWithConnectionString(context) {
|
52
|
+
var _a;
|
53
|
+
const recorder = await createRecorder(context.currentTest);
|
54
|
+
const client = new EmailClient((_a = env.COMMUNICATION_CONNECTION_STRING_EMAIL) !== null && _a !== void 0 ? _a : "", recorder.configureClientOptions({}));
|
41
55
|
return {
|
42
|
-
client:
|
56
|
+
client: client,
|
43
57
|
recorder,
|
44
58
|
};
|
45
59
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"recordedClient.js","sourceRoot":"","sources":["../../../../test/public/utils/recordedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
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,qBAAqB,EAAE,KAAK,EAAE,WAAW,EAAE;QAClD;YACE,GAAG,EAAE,oBAAoB;YACzB,KAAK,EAAE,sEAAsE;SAC9E;KACF;IACD,aAAa,EAAE;QACb;YACE,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,0BAA0B;YAClC,KAAK,EAAE,8BAA8B;SACtC;KACF;IACD,cAAc,EAAE;QACd;YACE,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,sBAAsB;YAC9B,KAAK,EAAE,eAAe;SACvB;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: \"x-ms-content-sha256\", value: \"Sanitized\" },\n {\n key: \"Operation-Location\",\n value: \"https://someEndpoint/emails/operations/someId?api-version=2023-03-31\",\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"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-email",
|
3
|
-
"version": "1.0.0
|
3
|
+
"version": "1.0.0",
|
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",
|
@@ -18,8 +18,9 @@
|
|
18
18
|
"execute:samples": "dev-tool samples run samples-dev",
|
19
19
|
"extract-api": "tsc -p . && api-extractor run --local",
|
20
20
|
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
21
|
-
"
|
22
|
-
"integration-test:
|
21
|
+
"generate:client": "autorest --typescript ./swagger/README.md && rushx format",
|
22
|
+
"integration-test:browser": "dev-tool run test:browser",
|
23
|
+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
23
24
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
24
25
|
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
25
26
|
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
@@ -27,8 +28,8 @@
|
|
27
28
|
"test": "npm run build:test && npm run unit-test && npm run integration-test",
|
28
29
|
"test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
|
29
30
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
30
|
-
"unit-test:browser": "
|
31
|
-
"unit-test:node": "
|
31
|
+
"unit-test:browser": "dev-tool run test:browser",
|
32
|
+
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
32
33
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
33
34
|
},
|
34
35
|
"files": [
|
@@ -47,8 +48,10 @@
|
|
47
48
|
],
|
48
49
|
"dependencies": {
|
49
50
|
"@azure/core-auth": "^1.3.0",
|
50
|
-
"@azure/core-
|
51
|
-
"@azure/
|
51
|
+
"@azure/core-client": "^1.3.2",
|
52
|
+
"@azure/core-lro": "^2.5.0",
|
53
|
+
"@azure/core-rest-pipeline": "^1.8.0",
|
54
|
+
"@azure/communication-common": "^2.2.0",
|
52
55
|
"@azure/logger": "^1.0.0",
|
53
56
|
"tslib": "^1.9.3",
|
54
57
|
"uuid": "^8.3.2"
|
@@ -57,22 +60,20 @@
|
|
57
60
|
"@azure/dev-tool": "^1.0.0",
|
58
61
|
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
59
62
|
"@azure/test-utils": "^1.0.0",
|
60
|
-
"@azure-tools/test-recorder": "^
|
61
|
-
"@microsoft/api-extractor": "7.
|
62
|
-
"@types/node": "^
|
63
|
+
"@azure-tools/test-recorder": "^3.0.0",
|
64
|
+
"@microsoft/api-extractor": "^7.31.1",
|
65
|
+
"@types/node": "^14.0.0",
|
63
66
|
"@types/uuid": "^8.3.2",
|
64
67
|
"@types/chai": "^4.1.6",
|
65
68
|
"@types/mocha": "^7.0.2",
|
66
69
|
"chai": "^4.2.0",
|
67
|
-
"dotenv": "^
|
70
|
+
"dotenv": "^16.0.0",
|
68
71
|
"eslint": "^7.15.0",
|
69
72
|
"karma": "^6.2.0",
|
70
73
|
"karma-chrome-launcher": "^3.0.0",
|
71
74
|
"karma-coverage": "^2.0.0",
|
72
|
-
"karma-edge-launcher": "^0.4.2",
|
73
75
|
"karma-env-preprocessor": "^0.1.1",
|
74
76
|
"karma-firefox-launcher": "^1.1.0",
|
75
|
-
"karma-ie-launcher": "^1.0.0",
|
76
77
|
"karma-json-preprocessor": "^0.3.3",
|
77
78
|
"karma-json-to-file-reporter": "^1.0.1",
|
78
79
|
"karma-junit-reporter": "^2.0.1",
|
@@ -82,7 +83,7 @@
|
|
82
83
|
"mocha": "^7.1.1",
|
83
84
|
"mocha-junit-reporter": "^2.0.0",
|
84
85
|
"nyc": "^15.0.0",
|
85
|
-
"typescript": "~4.
|
86
|
+
"typescript": "~4.8.0",
|
86
87
|
"prettier": "^2.5.1",
|
87
88
|
"rimraf": "^3.0.0"
|
88
89
|
},
|
@@ -91,7 +92,7 @@
|
|
91
92
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
92
93
|
},
|
93
94
|
"engines": {
|
94
|
-
"node": ">=
|
95
|
+
"node": ">=14.0.0"
|
95
96
|
},
|
96
97
|
"sideEffects": false,
|
97
98
|
"autoPublish": true,
|
@@ -1,48 +1,33 @@
|
|
1
|
+
import { CommonClientOptions } from '@azure/core-client';
|
1
2
|
import { KeyCredential } from '@azure/core-auth';
|
2
|
-
import {
|
3
|
+
import { OperationOptions } from '@azure/core-client';
|
4
|
+
import { PollerLike } from '@azure/core-lro';
|
5
|
+
import { PollOperationState } from '@azure/core-lro';
|
6
|
+
import { TokenCredential } from '@azure/core-auth';
|
3
7
|
|
4
|
-
/**
|
5
|
-
* An object representing the email address and its display name
|
6
|
-
*/
|
8
|
+
/** An object representing the email address and its display name */
|
7
9
|
export declare interface EmailAddress {
|
8
|
-
/**
|
9
|
-
|
10
|
-
|
11
|
-
email: string;
|
12
|
-
/**
|
13
|
-
* Email display name.
|
14
|
-
*/
|
10
|
+
/** Email address. */
|
11
|
+
address: string;
|
12
|
+
/** Email display name. */
|
15
13
|
displayName?: string;
|
16
14
|
}
|
17
15
|
|
18
|
-
/**
|
19
|
-
* Attachment to the email.
|
20
|
-
*/
|
16
|
+
/** Attachment to the email. */
|
21
17
|
export declare interface EmailAttachment {
|
22
|
-
/**
|
23
|
-
* Name of the attachment
|
24
|
-
*/
|
18
|
+
/** Name of the attachment */
|
25
19
|
name: string;
|
26
|
-
/**
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Base64 encoded contents of the attachment
|
32
|
-
*/
|
33
|
-
contentBytesBase64: string;
|
20
|
+
/** MIME type of the content being attached. */
|
21
|
+
contentType: string;
|
22
|
+
/** Base64 encoded contents of the attachment */
|
23
|
+
contentInBase64: string;
|
34
24
|
}
|
35
25
|
|
36
|
-
/**
|
37
|
-
* Defines values for EmailAttachmentType.
|
38
|
-
*/
|
39
|
-
export declare type EmailAttachmentType = "avi" | "bmp" | "doc" | "docm" | "docx" | "gif" | "jpeg" | "mp3" | "one" | "pdf" | "png" | "ppsm" | "ppsx" | "ppt" | "pptm" | "pptx" | "pub" | "rpmsg" | "rtf" | "tif" | "txt" | "vsd" | "wav" | "wma" | "xls" | "xlsb" | "xlsm" | "xlsx";
|
40
|
-
|
41
26
|
/**
|
42
27
|
* The Email service client.
|
43
28
|
*/
|
44
29
|
export declare class EmailClient {
|
45
|
-
private readonly
|
30
|
+
private readonly generatedClient;
|
46
31
|
/**
|
47
32
|
* Initializes a new instance of the EmailClient class.
|
48
33
|
* @param connectionString - Connection string to connect to an Azure Communication Service resource.
|
@@ -56,145 +41,173 @@ export declare class EmailClient {
|
|
56
41
|
* @param credential - An object that is used to authenticate requests to the service. Use the Azure KeyCredential or `@azure/identity` to create a credential.
|
57
42
|
* @param options - Optional. Options to configure the HTTP pipeline.
|
58
43
|
*/
|
59
|
-
constructor(endpoint: string, credential: KeyCredential, options?: EmailClientOptions);
|
44
|
+
constructor(endpoint: string, credential: KeyCredential | TokenCredential, options?: EmailClientOptions);
|
60
45
|
/**
|
61
46
|
* Queues an email message to be sent to one or more recipients
|
62
|
-
* @param
|
47
|
+
* @param message - Message payload for sending an email
|
48
|
+
* @param options - The options parameters.
|
63
49
|
*/
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Gets the status of a message sent previously.
|
67
|
-
* @param messageId - System generated message id (GUID) returned from a previous call to send email
|
68
|
-
*/
|
69
|
-
getSendStatus(messageId: string): Promise<SendStatusResult>;
|
50
|
+
beginSend(message: EmailMessage, options?: EmailSendOptionalParams): Promise<PollerLike<PollOperationState<EmailSendResponse>, EmailSendResponse>>;
|
70
51
|
}
|
71
52
|
|
72
53
|
/**
|
73
|
-
* Client options used to configure
|
54
|
+
* Client options used to configure Email Client API requests.
|
74
55
|
*/
|
75
|
-
export declare interface EmailClientOptions extends
|
56
|
+
export declare interface EmailClientOptions extends CommonClientOptions {
|
76
57
|
}
|
77
58
|
|
78
|
-
/**
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
59
|
+
/** Content of the email. */
|
60
|
+
export declare type EmailContent = HtmlEmailContent | PlainTextEmailContent;
|
61
|
+
|
62
|
+
/** Message payload for sending an email */
|
63
|
+
export declare interface EmailMessage {
|
64
|
+
/** Custom email headers to be passed. */
|
65
|
+
headers?: {
|
66
|
+
[propertyName: string]: string;
|
67
|
+
};
|
68
|
+
/** Sender email address from a verified domain. */
|
69
|
+
senderAddress: string;
|
70
|
+
/** Email content to be sent. */
|
71
|
+
content: EmailContent;
|
72
|
+
/** Recipients for the email. */
|
73
|
+
recipients: EmailRecipients;
|
74
|
+
/** List of attachments. Please note that we limit the total size of an email request (which includes attachments) to 10MB. */
|
75
|
+
attachments?: EmailAttachment[];
|
76
|
+
/** Email addresses where recipients' replies will be sent to. */
|
77
|
+
replyTo?: EmailAddress[];
|
78
|
+
/** 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. */
|
79
|
+
disableUserEngagementTracking?: boolean;
|
94
80
|
}
|
95
81
|
|
96
|
-
/**
|
97
|
-
|
98
|
-
*/
|
99
|
-
|
100
|
-
/**
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Header value.
|
106
|
-
*/
|
107
|
-
value: string;
|
82
|
+
/** Recipients of the email */
|
83
|
+
export declare interface EmailRecipients {
|
84
|
+
/** Email To recipients */
|
85
|
+
to?: EmailAddress[];
|
86
|
+
/** Email CC recipients */
|
87
|
+
cc?: EmailAddress[];
|
88
|
+
/** Email BCC recipients */
|
89
|
+
bcc?: EmailAddress[];
|
108
90
|
}
|
109
91
|
|
110
|
-
/**
|
111
|
-
|
112
|
-
*/
|
113
|
-
|
92
|
+
/** Defines headers for Email_send operation. */
|
93
|
+
export declare interface EmailSendHeaders {
|
94
|
+
/** Location url of where to poll the status of this operation from. */
|
95
|
+
operationLocation?: string;
|
96
|
+
/** This header will only be present when the operation status is a non-terminal status. It indicates the minimum amount of time in seconds to wait before polling for operation status again. */
|
97
|
+
retryAfter?: number;
|
98
|
+
}
|
99
|
+
|
100
|
+
/** Optional parameters for the beginSend method. */
|
101
|
+
export declare interface EmailSendOptionalParams extends OperationOptions {
|
102
|
+
/** This is the ID used by the status monitor for this long running operation. */
|
103
|
+
operationId?: string;
|
104
|
+
/** Delay to wait until next poll, in milliseconds. */
|
105
|
+
updateIntervalInMs?: number;
|
106
|
+
/** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */
|
107
|
+
resumeFrom?: string;
|
108
|
+
}
|
109
|
+
|
110
|
+
/** Contains response data for the send operation. */
|
111
|
+
export declare type EmailSendResponse = EmailSendHeaders & EmailSendResult;
|
112
|
+
|
113
|
+
/** Status of the long running operation */
|
114
|
+
export declare interface EmailSendResult {
|
115
|
+
/** The unique id of the operation. Use a UUID. */
|
116
|
+
id: string;
|
117
|
+
/** Status of operation. */
|
118
|
+
status: EmailSendStatus;
|
119
|
+
/** Error details when status is a non-success terminal state. */
|
120
|
+
error?: ErrorDetail;
|
121
|
+
}
|
114
122
|
|
115
123
|
/**
|
116
|
-
*
|
124
|
+
* Defines values for EmailSendStatus. \
|
125
|
+
* {@link KnownEmailSendStatus} can be used interchangeably with EmailSendStatus,
|
126
|
+
* this enum contains the known values that the service supports.
|
127
|
+
* ### Known values supported by the service
|
128
|
+
* **NotStarted** \
|
129
|
+
* **Running** \
|
130
|
+
* **Succeeded** \
|
131
|
+
* **Failed** \
|
132
|
+
* **Canceled**
|
117
133
|
*/
|
118
|
-
export declare
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
customHeaders?: EmailCustomHeader[];
|
134
|
+
export declare type EmailSendStatus = string;
|
135
|
+
|
136
|
+
/** The resource management error additional info. */
|
137
|
+
export declare interface ErrorAdditionalInfo {
|
123
138
|
/**
|
124
|
-
*
|
139
|
+
* The additional info type.
|
140
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
125
141
|
*/
|
126
|
-
|
142
|
+
readonly type?: string;
|
127
143
|
/**
|
128
|
-
*
|
144
|
+
* The additional info.
|
145
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
129
146
|
*/
|
130
|
-
|
147
|
+
readonly info?: Record<string, unknown>;
|
148
|
+
}
|
149
|
+
|
150
|
+
/** The error detail. */
|
151
|
+
export declare interface ErrorDetail {
|
131
152
|
/**
|
132
|
-
* The
|
153
|
+
* The error code.
|
154
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
133
155
|
*/
|
134
|
-
|
156
|
+
readonly code?: string;
|
135
157
|
/**
|
136
|
-
*
|
158
|
+
* The error message.
|
159
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
137
160
|
*/
|
138
|
-
|
161
|
+
readonly message?: string;
|
139
162
|
/**
|
140
|
-
*
|
163
|
+
* The error target.
|
164
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
141
165
|
*/
|
142
|
-
|
166
|
+
readonly target?: string;
|
143
167
|
/**
|
144
|
-
*
|
168
|
+
* The error details.
|
169
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
145
170
|
*/
|
146
|
-
|
171
|
+
readonly details?: ErrorDetail[];
|
147
172
|
/**
|
148
|
-
*
|
173
|
+
* The error additional info.
|
174
|
+
* NOTE: This property will not be serialized. It can only be populated by the server.
|
149
175
|
*/
|
150
|
-
|
176
|
+
readonly additionalInfo?: ErrorAdditionalInfo[];
|
151
177
|
}
|
152
178
|
|
153
|
-
/**
|
154
|
-
|
155
|
-
*/
|
156
|
-
|
157
|
-
/**
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
/**
|
162
|
-
* Email cc recipients
|
163
|
-
*/
|
164
|
-
cC?: EmailAddress[];
|
165
|
-
/**
|
166
|
-
* Email bcc recipients
|
167
|
-
*/
|
168
|
-
bCC?: EmailAddress[];
|
179
|
+
/** Content of the email with a required html property. */
|
180
|
+
export declare interface HtmlEmailContent {
|
181
|
+
/** Subject of the email message */
|
182
|
+
subject: string;
|
183
|
+
/** Plain text version of the email message. */
|
184
|
+
plainText?: string;
|
185
|
+
/** Html version of the email message. */
|
186
|
+
html: string;
|
169
187
|
}
|
170
188
|
|
171
|
-
/**
|
172
|
-
|
173
|
-
*/
|
174
|
-
|
175
|
-
/**
|
176
|
-
|
177
|
-
|
178
|
-
|
189
|
+
/** Known values of {@link EmailSendStatus} that the service accepts. */
|
190
|
+
export declare enum KnownEmailSendStatus {
|
191
|
+
/** NotStarted */
|
192
|
+
NotStarted = "NotStarted",
|
193
|
+
/** Running */
|
194
|
+
Running = "Running",
|
195
|
+
/** Succeeded */
|
196
|
+
Succeeded = "Succeeded",
|
197
|
+
/** Failed */
|
198
|
+
Failed = "Failed",
|
199
|
+
/** Canceled */
|
200
|
+
Canceled = "Canceled"
|
179
201
|
}
|
180
202
|
|
181
|
-
/**
|
182
|
-
|
183
|
-
*/
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
export declare interface SendStatusResult {
|
190
|
-
/**
|
191
|
-
* System generated id of an email message sent.
|
192
|
-
*/
|
193
|
-
messageId: string;
|
194
|
-
/**
|
195
|
-
* The type indicating the status of a request.
|
196
|
-
*/
|
197
|
-
status: SendStatus;
|
203
|
+
/** Content of the email with a required plainText property. */
|
204
|
+
export declare interface PlainTextEmailContent {
|
205
|
+
/** Subject of the email message */
|
206
|
+
subject: string;
|
207
|
+
/** Plain text version of the email message. */
|
208
|
+
plainText: string;
|
209
|
+
/** Html version of the email message. */
|
210
|
+
html?: string;
|
198
211
|
}
|
199
212
|
|
200
213
|
export { }
|
@@ -1,46 +0,0 @@
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
2
|
-
// Licensed under the MIT License.
|
3
|
-
/**
|
4
|
-
* @summary Checks the message status of a sent email
|
5
|
-
*/
|
6
|
-
import { EmailClient } from "@azure/communication-email";
|
7
|
-
// Load the .env file (you will need to set these environment variables)
|
8
|
-
import * as dotenv from "dotenv";
|
9
|
-
dotenv.config();
|
10
|
-
const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";
|
11
|
-
const senderAddress = process.env["SENDER_ADDRESS"] || "";
|
12
|
-
const recipientAddress = process.env["RECIPIENT_ADDRESS"] || "";
|
13
|
-
const getMessageStatusFromEmail = async () => {
|
14
|
-
// Create the Email Client
|
15
|
-
const emailClient = new EmailClient(connectionString);
|
16
|
-
// Create the Email Message to be sent
|
17
|
-
const emailMessage = {
|
18
|
-
sender: senderAddress,
|
19
|
-
content: {
|
20
|
-
subject: "This is the subject",
|
21
|
-
plainText: "This is the body",
|
22
|
-
html: "<html><h1>This is the body</h1></html>",
|
23
|
-
},
|
24
|
-
recipients: {
|
25
|
-
to: [
|
26
|
-
{
|
27
|
-
email: recipientAddress,
|
28
|
-
displayName: "Customer Name",
|
29
|
-
},
|
30
|
-
],
|
31
|
-
},
|
32
|
-
};
|
33
|
-
try {
|
34
|
-
// Send the email message
|
35
|
-
const sendEmailResponse = await emailClient.send(emailMessage);
|
36
|
-
// Use the message id to get the status of the email
|
37
|
-
const messageId = sendEmailResponse.messageId || "";
|
38
|
-
const getMessageStatusResponse = await emailClient.getSendStatus(messageId);
|
39
|
-
console.log("Message Status: " + getMessageStatusResponse);
|
40
|
-
}
|
41
|
-
catch (error) {
|
42
|
-
console.log(error);
|
43
|
-
}
|
44
|
-
};
|
45
|
-
void getMessageStatusFromEmail();
|
46
|
-
//# sourceMappingURL=checkMessageStatus.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"checkMessageStatus.js","sourceRoot":"","sources":["../../samples-dev/checkMessageStatus.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAgB,MAAM,4BAA4B,CAAC;AAEvE,wEAAwE;AACxE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,IAAI,EAAE,CAAC;AAC9E,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;AAC1D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;AAEhE,MAAM,yBAAyB,GAAG,KAAK,IAAmB,EAAE;IAC1D,0BAA0B;IAC1B,MAAM,WAAW,GAAgB,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAEnE,sCAAsC;IACtC,MAAM,YAAY,GAAiB;QACjC,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE;YACP,OAAO,EAAE,qBAAqB;YAC9B,SAAS,EAAE,kBAAkB;YAC7B,IAAI,EAAE,wCAAwC;SAC/C;QACD,UAAU,EAAE;YACV,EAAE,EAAE;gBACF;oBACE,KAAK,EAAE,gBAAgB;oBACvB,WAAW,EAAE,eAAe;iBAC7B;aACF;SACF;KACF,CAAC;IAEF,IAAI;QACF,yBAAyB;QACzB,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE/D,oDAAoD;QACpD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,IAAI,EAAE,CAAC;QACpD,MAAM,wBAAwB,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAE5E,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,wBAAwB,CAAC,CAAC;KAC5D;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,KAAK,yBAAyB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * @summary Checks the message status of a sent email\n */\n\nimport { EmailClient, EmailMessage } from \"@azure/communication-email\";\n\n// Load the .env file (you will need to set these environment variables)\nimport * as dotenv from \"dotenv\";\ndotenv.config();\n\nconst connectionString = process.env[\"COMMUNICATION_CONNECTION_STRING\"] || \"\";\nconst senderAddress = process.env[\"SENDER_ADDRESS\"] || \"\";\nconst recipientAddress = process.env[\"RECIPIENT_ADDRESS\"] || \"\";\n\nconst getMessageStatusFromEmail = async (): Promise<void> => {\n // Create the Email Client\n const emailClient: EmailClient = new EmailClient(connectionString);\n\n // Create the Email Message to be sent\n const emailMessage: EmailMessage = {\n sender: senderAddress,\n content: {\n subject: \"This is the subject\",\n plainText: \"This is the body\",\n html: \"<html><h1>This is the body</h1></html>\",\n },\n recipients: {\n to: [\n {\n email: recipientAddress,\n displayName: \"Customer Name\",\n },\n ],\n },\n };\n\n try {\n // Send the email message\n const sendEmailResponse = await emailClient.send(emailMessage);\n\n // Use the message id to get the status of the email\n const messageId = sendEmailResponse.messageId || \"\";\n const getMessageStatusResponse = await emailClient.getSendStatus(messageId);\n\n console.log(\"Message Status: \" + getMessageStatusResponse);\n } catch (error) {\n console.log(error);\n }\n};\n\nvoid getMessageStatusFromEmail();\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,cAAc,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const SDK_VERSION: string = \"1.0.0-beta.1\";\n"]}
|