@enonic-types/lib-mail 0.1.1 → 7.11.0-B3

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 (3) hide show
  1. package/README.md +13 -4
  2. package/mail.d.ts +56 -56
  3. package/package.json +33 -32
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Enonic XP lib-mail TS types
2
2
 
3
3
  > TypeScript definitions for `lib-mail` library of Enonic XP
4
+
4
5
  ## Install
5
6
 
6
7
  ```bash
7
- npm i --save-dev @enonic/lib-mail
8
+ npm i --save-dev @enonic-types/lib-mail
8
9
  ```
9
10
 
10
11
  ## Use
@@ -12,6 +13,7 @@ npm i --save-dev @enonic/lib-mail
12
13
  Add the corresponding types to your `tsconfig.json` file that is used for application's server-side TypeScript code.
13
14
 
14
15
  `tsconfig.json`
16
+
15
17
  ```json
16
18
  {
17
19
  "compilerOptions": {
@@ -24,9 +26,11 @@ Add the corresponding types to your `tsconfig.json` file that is used for applic
24
26
 
25
27
  ### Require and custom imports
26
28
 
27
- To make `require` work out of box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP global objects, e.g. `log`, `app`, `__`, etc, requiring library by the default path will return typed object.
29
+ To make `require` work out of the box, you must install and add the `@enonic-types/global` types. Aside from providing definitions for XP
30
+ global objects, e.g. `log`, `app`, `__`, etc, requiring a library by the default path will return typed object.
28
31
 
29
32
  `tsconfig.json`
33
+
30
34
  ```diff
31
35
  {
32
36
  "compilerOptions": {
@@ -39,17 +43,21 @@ To make `require` work out of box, you must install and add the `@enonic-types/g
39
43
  ```
40
44
 
41
45
  `example.ts`
46
+
42
47
  ```ts
43
48
  const {send} = require('/lib/xp/mail');
44
49
  ```
45
50
 
46
- More detailed explanation on how it works and how to type custom import function can be found [here](https://github.com/enonic/xp/tree/master/modules/lib/typescript/README.md).
51
+ More detailed explanation on how it works and how to type custom import function can be
52
+ found [here](https://developer.enonic.com/docs/xp/stable/api).
47
53
 
48
54
  ### ES6-style import
49
55
 
50
- If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper types mapping to your configuration.
56
+ If you are planning to use `import` in your code and transpile it with the default `tsc` TypeScript compiler, you'll need to add proper
57
+ types mapping to your configuration.
51
58
 
52
59
  `tsconfig.json`
60
+
53
61
  ```diff
54
62
  {
55
63
  "compilerOptions": {
@@ -65,6 +73,7 @@ If you are planning to use `import` in your code and transpile it with the defau
65
73
  ```
66
74
 
67
75
  `example.ts`
76
+
68
77
  ```ts
69
78
  import {send} from '/lib/xp/mail';
70
79
  ```
package/mail.d.ts CHANGED
@@ -1,56 +1,56 @@
1
- declare global {
2
- interface XpLibraries {
3
- '/lib/xp/mail': typeof import('./mail');
4
- }
5
- }
6
- export interface Attachment {
7
- fileName: string;
8
- data: object;
9
- mimeType?: string;
10
- headers?: Record<string, string>;
11
- }
12
- export interface SendMessageParams {
13
- subject: string;
14
- from: string;
15
- body: string;
16
- to: string | string[];
17
- cc?: string | string[];
18
- bcc?: string | string[];
19
- replyTo?: string;
20
- contentType?: string;
21
- headers?: Record<string, string>;
22
- attachments?: Attachment[];
23
- }
24
- /**
25
- * This function sends an email message using the mail server configured.
26
- *
27
- * The address values can be either a simple email address (e.g. ‘name@domain.org’ ) or an address with a
28
- * display name. In the latter case the email will be enclosed with angle brackets (e.g. ‘Some Name <name@domain.org>’ ).
29
- *
30
- * The parameters `to`, `cc` and `bcc` can be passed as a single string or as an array of strings, if there are multiple addresses
31
- * to specify.
32
- *
33
- * The content-type of the email can be specified by using the `contentType` parameter. See example below for
34
- * sending a message with an HTML body.
35
- *
36
- * @example-ref examples/mail/send.js
37
- *
38
- * @param {object} params JSON with the parameters.
39
- * @param {string} params.from The email address, and optionally name of the sender of the message.
40
- * @param {(string|string[])} params.to The email address(es), and optionally name(s) of the primary message’s recipient(s).
41
- * @param {(string|string[])} [params.cc] The carbon copy email address(es).
42
- * @param {(string|string[])} [params.bcc] The blind carbon copy email address(es).
43
- * @param {string} [params.replyTo] The email address that should be used to reply to the message.
44
- * @param {string} params.subject The subject line of the message.
45
- * @param {string} params.body The text content of the message.
46
- * @param {string} [params.contentType] Content type of the message body.
47
- * @param {object} [params.headers] Custom headers in the form of name-value pairs.
48
- * @param {object[]} [params.attachments] Attachments to include in the email.
49
- * @param {string} params.attachments.fileName Attachment file name.
50
- * @param {*} params.attachments.data Attachment stream.
51
- * @param {string} [params.attachments.mimeType] Attachment content type. If not specified will be inferred from the file extension.
52
- * @param {object} [params.attachments.headers] Attachment headers, in the form of name-value pairs.
53
- *
54
- * @returns {boolean} True if the message was sent successfully, false otherwise.
55
- */
56
- export declare function send(params: SendMessageParams): boolean;
1
+ declare global {
2
+ interface XpLibraries {
3
+ '/lib/xp/mail': typeof import('./mail');
4
+ }
5
+ }
6
+ export interface Attachment {
7
+ fileName: string;
8
+ data: object;
9
+ mimeType?: string;
10
+ headers?: Record<string, string>;
11
+ }
12
+ export interface SendMessageParams {
13
+ subject: string;
14
+ from: string;
15
+ body: string;
16
+ to: string | string[];
17
+ cc?: string | string[];
18
+ bcc?: string | string[];
19
+ replyTo?: string;
20
+ contentType?: string;
21
+ headers?: Record<string, string>;
22
+ attachments?: Attachment[];
23
+ }
24
+ /**
25
+ * This function sends an email message using the mail server configured.
26
+ *
27
+ * The address values can be either a simple email address (e.g. ‘name@domain.org’ ) or an address with a
28
+ * display name. In the latter case the email will be enclosed with angle brackets (e.g. ‘Some Name <name@domain.org>’ ).
29
+ *
30
+ * The parameters `to`, `cc` and `bcc` can be passed as a single string or as an array of strings, if there are multiple addresses
31
+ * to specify.
32
+ *
33
+ * The content-type of the email can be specified by using the `contentType` parameter. See example below for
34
+ * sending a message with an HTML body.
35
+ *
36
+ * @example-ref examples/mail/send.js
37
+ *
38
+ * @param {object} params JSON with the parameters.
39
+ * @param {string} params.from The email address, and optionally name of the sender of the message.
40
+ * @param {(string|string[])} params.to The email address(es), and optionally name(s) of the primary message’s recipient(s).
41
+ * @param {(string|string[])} [params.cc] The carbon copy email address(es).
42
+ * @param {(string|string[])} [params.bcc] The blind carbon copy email address(es).
43
+ * @param {string} [params.replyTo] The email address that should be used to reply to the message.
44
+ * @param {string} params.subject The subject line of the message.
45
+ * @param {string} params.body The text content of the message.
46
+ * @param {string} [params.contentType] Content type of the message body.
47
+ * @param {object} [params.headers] Custom headers in the form of name-value pairs.
48
+ * @param {object[]} [params.attachments] Attachments to include in the email.
49
+ * @param {string} params.attachments.fileName Attachment file name.
50
+ * @param {*} params.attachments.data Attachment stream.
51
+ * @param {string} [params.attachments.mimeType] Attachment content type. If not specified will be inferred from the file extension.
52
+ * @param {object} [params.attachments.headers] Attachment headers, in the form of name-value pairs.
53
+ *
54
+ * @returns {boolean} True if the message was sent successfully, false otherwise.
55
+ */
56
+ export declare function send(params: SendMessageParams): boolean;
package/package.json CHANGED
@@ -1,32 +1,33 @@
1
- {
2
- "name": "@enonic-types/lib-mail",
3
- "version": "0.1.1",
4
- "description": "Type definitions for lib-mail.",
5
- "types": "mail.d.ts",
6
- "files": [
7
- "mail.d.ts"
8
- ],
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/enonic/xp.git#master"
12
- },
13
- "keywords": [
14
- "enonic",
15
- "enonic-xp",
16
- "lib-mail",
17
- "mail",
18
- "types",
19
- "typescript"
20
- ],
21
- "contributors": [
22
- "Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
23
- ],
24
- "license": "Apache-2.0",
25
- "bugs": {
26
- "url": "https://github.com/enonic/xp/issues"
27
- },
28
- "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
- "publishConfig": {
30
- "access": "public"
31
- }
32
- }
1
+ {
2
+ "name": "@enonic-types/lib-mail",
3
+ "version": "7.11.0-B3",
4
+ "description": "Type definitions for lib-mail.",
5
+ "types": "mail.d.ts",
6
+ "files": [
7
+ "mail.d.ts"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/enonic/xp.git#master"
12
+ },
13
+ "keywords": [
14
+ "enonic",
15
+ "enonic-xp",
16
+ "lib-mail",
17
+ "mail",
18
+ "types",
19
+ "typescript"
20
+ ],
21
+ "contributors": [
22
+ "Mikita Taukachou <edloidas@gmail.com> (https://edloidas.github.io/)"
23
+ ],
24
+ "license": "Apache-2.0",
25
+ "bugs": {
26
+ "url": "https://github.com/enonic/xp/issues"
27
+ },
28
+ "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
+ "dependencies": {},
30
+ "publishConfig": {
31
+ "access": "public"
32
+ }
33
+ }