nylas 7.0.0-beta.1 → 7.0.0-beta.3
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.
- package/README.md +20 -11
- package/lib/cjs/apiClient.js +18 -12
- package/lib/cjs/models/connectors.js +2 -0
- package/lib/cjs/models/credentials.js +12 -0
- package/lib/cjs/models/drafts.js +2 -0
- package/lib/cjs/models/files.js +2 -0
- package/lib/cjs/models/freeBusy.js +11 -0
- package/lib/cjs/models/messages.js +11 -0
- package/lib/cjs/models/smartCompose.js +2 -0
- package/lib/cjs/models/threads.js +2 -0
- package/lib/cjs/models/webhooks.js +3 -0
- package/lib/cjs/nylas.js +22 -14
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/resources/applications.js +4 -4
- package/lib/cjs/resources/auth.js +12 -10
- package/lib/cjs/resources/calendars.js +14 -2
- package/lib/cjs/resources/connectors.js +68 -0
- package/lib/cjs/resources/credentials.js +60 -0
- package/lib/cjs/resources/drafts.js +81 -0
- package/lib/cjs/resources/events.js +2 -2
- package/lib/cjs/resources/grants.js +4 -4
- package/lib/cjs/resources/messages.js +121 -0
- package/lib/cjs/resources/redirectUris.js +3 -3
- package/lib/cjs/resources/smartCompose.js +34 -0
- package/lib/cjs/resources/threads.js +54 -0
- package/lib/cjs/resources/webhooks.js +2 -2
- package/lib/cjs/utils.js +17 -1
- package/lib/cjs/version.js +5 -0
- package/lib/esm/apiClient.js +10 -4
- package/lib/esm/models/connectors.js +1 -0
- package/lib/esm/models/credentials.js +9 -0
- package/lib/esm/models/drafts.js +1 -0
- package/lib/esm/models/files.js +1 -0
- package/lib/esm/models/freeBusy.js +8 -0
- package/lib/esm/models/messages.js +8 -0
- package/lib/esm/models/smartCompose.js +1 -0
- package/lib/esm/models/threads.js +1 -0
- package/lib/esm/models/webhooks.js +3 -0
- package/lib/esm/nylas.js +15 -7
- package/lib/esm/package.json +3 -0
- package/lib/esm/resources/applications.js +2 -2
- package/lib/esm/resources/auth.js +10 -8
- package/lib/esm/resources/calendars.js +13 -1
- package/lib/esm/resources/connectors.js +64 -0
- package/lib/esm/resources/credentials.js +56 -0
- package/lib/esm/resources/drafts.js +77 -0
- package/lib/esm/resources/events.js +1 -1
- package/lib/esm/resources/grants.js +3 -3
- package/lib/esm/resources/messages.js +117 -0
- package/lib/esm/resources/redirectUris.js +2 -2
- package/lib/esm/resources/smartCompose.js +30 -0
- package/lib/esm/resources/threads.js +50 -0
- package/lib/esm/resources/webhooks.js +1 -1
- package/lib/esm/utils.js +15 -0
- package/lib/esm/version.js +2 -0
- package/lib/types/apiClient.d.ts +4 -2
- package/lib/types/models/applicationDetails.d.ts +1 -1
- package/lib/types/models/auth.d.ts +1 -1
- package/lib/types/models/calendars.d.ts +2 -2
- package/lib/types/models/connectors.d.ts +127 -0
- package/lib/types/models/credentials.d.ts +151 -0
- package/lib/types/models/drafts.d.ts +92 -0
- package/lib/types/models/events.d.ts +3 -3
- package/lib/types/models/files.d.ts +17 -0
- package/lib/types/models/freeBusy.d.ts +79 -0
- package/lib/types/models/grants.d.ts +1 -1
- package/lib/types/models/messages.d.ts +271 -0
- package/lib/types/models/smartCompose.d.ts +18 -0
- package/lib/types/models/threads.d.ts +153 -0
- package/lib/types/models/webhooks.d.ts +80 -2
- package/lib/types/nylas.d.ts +27 -7
- package/lib/types/resources/applications.d.ts +6 -6
- package/lib/types/resources/auth.d.ts +4 -4
- package/lib/types/resources/calendars.d.ts +21 -6
- package/lib/types/resources/connectors.d.ts +80 -0
- package/lib/types/resources/credentials.d.ts +80 -0
- package/lib/types/resources/drafts.d.ts +87 -0
- package/lib/types/resources/events.d.ts +4 -4
- package/lib/types/resources/grants.d.ts +5 -5
- package/lib/types/resources/messages.d.ts +129 -0
- package/lib/types/resources/redirectUris.d.ts +4 -4
- package/lib/types/resources/resource.d.ts +4 -4
- package/lib/types/resources/smartCompose.d.ts +41 -0
- package/lib/types/resources/threads.d.ts +70 -0
- package/lib/types/resources/webhooks.d.ts +5 -5
- package/lib/types/utils.d.ts +2 -0
- package/lib/types/version.d.ts +1 -0
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
# Nylas Node.js SDK
|
|
6
6
|
|
|
7
|
+
[
|
|
8
|
+
](https://www.npmjs.com/package/nylas/v/beta@)
|
|
7
9
|
[](https://codecov.io/gh/nylas/nylas-nodejs)
|
|
8
10
|
|
|
9
|
-
This is the GitHub repository for the Nylas Node SDK
|
|
11
|
+
This is the GitHub repository for the Nylas Node SDK. This repo is primarily for anyone who wants to make contributions to the SDK, or install it from source. If you are looking to use Node to access the Nylas Email, Calendar, or Contacts API you should refer to our official [Node SDK Quickstart Guide](https://developer.nylas.com/docs/developer-tools/sdk/node-sdk/).
|
|
10
12
|
|
|
11
13
|
The Nylas Communications Platform provides REST APIs for [Email](https://developer.nylas.com/docs/connectivity/email/), [Calendar](https://developer.nylas.com/docs/connectivity/calendar/), and [Contacts](https://developer.nylas.com/docs/connectivity/contacts/), and the Node SDK is the quickest way to build your integration using JavaScript.
|
|
12
14
|
|
|
13
15
|
Here are some resources to help you get started:
|
|
14
16
|
|
|
15
|
-
- [Nylas
|
|
16
|
-
- [
|
|
17
|
+
- [Sign up for your free Nylas account](https://dashboard.nylas.com/register)
|
|
18
|
+
- [Sign up for the Nylas v3 Beta program to access the v3 Dashboard](https://info.nylas.com/apiv3betasignup.html?utm_source=github&utm_medium=devrel-surfaces&utm_campaign=&utm_content=node-sdk-upgrade)
|
|
19
|
+
- [Nylas API v3 Quickstart Guide](https://developer.nylas.com/docs/v3-beta/v3-quickstart/)
|
|
20
|
+
- [Nylas SDK Reference](https://nylas-nodejs-sdk-reference.pages.dev/)
|
|
17
21
|
- [Nylas API Reference](https://developer.nylas.com/docs/api/)
|
|
18
|
-
|
|
22
|
+
- [Nylas Samples repo for code samples and example applications](https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=javascript)
|
|
19
23
|
|
|
20
24
|
## ⚙️ Install
|
|
21
25
|
|
|
@@ -23,12 +27,12 @@ Here are some resources to help you get started:
|
|
|
23
27
|
|
|
24
28
|
### Set up using npm
|
|
25
29
|
|
|
26
|
-
To run the Nylas Node SDK,
|
|
30
|
+
To run the Nylas Node SDK, first install [Node](https://nodejs.org/en/download/) and [npm](https://www.npmjs.com/get-npm) on your machine.
|
|
27
31
|
|
|
28
32
|
Then, head to the nearest command line and run the following:
|
|
29
|
-
`npm install nylas`
|
|
33
|
+
`npm install nylas@beta`
|
|
30
34
|
|
|
31
|
-
Alternatively,
|
|
35
|
+
Alternatively, you can use [Yarn](https://yarnpkg.com/en/) to install the Nylas Node SDK by running the `yarn add nylas` command.
|
|
32
36
|
|
|
33
37
|
### Build from source
|
|
34
38
|
|
|
@@ -50,7 +54,7 @@ For code examples that demonstrate how to use this SDK, take a look at our [Node
|
|
|
50
54
|
|
|
51
55
|
### 🚀 Making Your First Request
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
You access Nylas resources (messages, calendars, events, contacts) through an instance of `Nylas`. The `Nylas` object must be initialized with your Nylas API key, and you can provide other additional configurations such as the Nylas API url and the timeout.
|
|
54
58
|
|
|
55
59
|
```typescript
|
|
56
60
|
import Nylas from "nylas";
|
|
@@ -61,6 +65,7 @@ const nylas = new Nylas({
|
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
Once initialized you can use the object to make requests for a given account's resources, for example to list all the calendars for a given account:
|
|
68
|
+
|
|
64
69
|
```typescript
|
|
65
70
|
nylas.calendars.list({ identifier: "GRANT_ID" }).then(calendars => {
|
|
66
71
|
console.log(calendars);
|
|
@@ -71,12 +76,16 @@ nylas.calendars.list({ identifier: "GRANT_ID" }).then(calendars => {
|
|
|
71
76
|
|
|
72
77
|
Nylas maintains a [reference guide for the Node SDK](https://nylas-nodejs-sdk-reference.pages.dev/) to help you get familiar with the available methods and classes.
|
|
73
78
|
|
|
79
|
+
## ✨ Upgrading from 6.x
|
|
80
|
+
|
|
81
|
+
See [UPGRADE.md](UPGRADE.md) for instructions on upgrading from 6.x to 7.x.
|
|
82
|
+
|
|
83
|
+
**Note**: The Node SDK v7.x is not compatible with the Nylas API earlier than v3-beta.
|
|
84
|
+
|
|
74
85
|
## 💙 Contributing
|
|
75
86
|
|
|
76
87
|
Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.
|
|
77
88
|
|
|
78
89
|
## 📝 License
|
|
79
90
|
|
|
80
|
-
This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.
|
package/lib/cjs/apiClient.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const node_fetch_1 = require("node-fetch");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const SDK_VERSION = PACKAGE_JSON.version;
|
|
4
|
+
const error_js_1 = require("./models/error.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const version_js_1 = require("./version.js");
|
|
8
7
|
/**
|
|
9
8
|
* The API client for communicating with the Nylas API
|
|
10
9
|
* @ignore Not for public use
|
|
@@ -21,7 +20,7 @@ class APIClient {
|
|
|
21
20
|
}
|
|
22
21
|
setQueryStrings(url, queryParams) {
|
|
23
22
|
if (queryParams) {
|
|
24
|
-
const snakeCaseParams = (0,
|
|
23
|
+
const snakeCaseParams = (0, utils_js_1.objKeysToSnakeCase)(queryParams, ['metadataPair']);
|
|
25
24
|
for (const [key, value] of Object.entries(snakeCaseParams)) {
|
|
26
25
|
if (key == 'metadataPair') {
|
|
27
26
|
// The API understands a metadata_pair filter in the form of:
|
|
@@ -42,7 +41,7 @@ class APIClient {
|
|
|
42
41
|
setRequestHeaders({ headers, overrides, }) {
|
|
43
42
|
return {
|
|
44
43
|
Accept: 'application/json',
|
|
45
|
-
'User-Agent': `Nylas Node SDK v${SDK_VERSION}`,
|
|
44
|
+
'User-Agent': `Nylas Node SDK v${version_js_1.SDK_VERSION}`,
|
|
46
45
|
Authorization: `Bearer ${overrides?.apiKey || this.apiKey}`,
|
|
47
46
|
...headers,
|
|
48
47
|
};
|
|
@@ -53,9 +52,16 @@ class APIClient {
|
|
|
53
52
|
requestOptions.headers = this.setRequestHeaders(optionParams);
|
|
54
53
|
requestOptions.method = optionParams.method;
|
|
55
54
|
if (optionParams.body) {
|
|
56
|
-
requestOptions.body = JSON.stringify((0,
|
|
55
|
+
requestOptions.body = JSON.stringify((0, utils_js_1.objKeysToSnakeCase)(optionParams.body));
|
|
57
56
|
requestOptions.headers['Content-Type'] = 'application/json';
|
|
58
57
|
}
|
|
58
|
+
if (optionParams.form) {
|
|
59
|
+
requestOptions.body = optionParams.form;
|
|
60
|
+
requestOptions.headers = {
|
|
61
|
+
...requestOptions.headers,
|
|
62
|
+
...optionParams.form.getHeaders(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
59
65
|
return requestOptions;
|
|
60
66
|
}
|
|
61
67
|
newRequest(options) {
|
|
@@ -70,7 +76,7 @@ class APIClient {
|
|
|
70
76
|
const text = await response.text();
|
|
71
77
|
try {
|
|
72
78
|
const responseJSON = JSON.parse(text);
|
|
73
|
-
return (0,
|
|
79
|
+
return (0, utils_js_1.objKeysToCamelCase)(responseJSON);
|
|
74
80
|
}
|
|
75
81
|
catch (e) {
|
|
76
82
|
throw new Error(`Could not parse response from the server: ${text}`);
|
|
@@ -81,7 +87,7 @@ class APIClient {
|
|
|
81
87
|
const controller = new AbortController();
|
|
82
88
|
const timeout = setTimeout(() => {
|
|
83
89
|
controller.abort();
|
|
84
|
-
throw new
|
|
90
|
+
throw new error_js_1.NylasSdkTimeoutError(req.url, this.timeout);
|
|
85
91
|
}, this.timeout);
|
|
86
92
|
const response = await (0, node_fetch_1.default)(req, { signal: controller.signal });
|
|
87
93
|
clearTimeout(timeout);
|
|
@@ -96,12 +102,12 @@ class APIClient {
|
|
|
96
102
|
let error;
|
|
97
103
|
try {
|
|
98
104
|
const parsedError = JSON.parse(text);
|
|
99
|
-
const camelCaseError = (0,
|
|
105
|
+
const camelCaseError = (0, utils_js_1.objKeysToCamelCase)(parsedError);
|
|
100
106
|
if (authErrorResponse) {
|
|
101
|
-
error = new
|
|
107
|
+
error = new error_js_1.NylasOAuthError(camelCaseError, response.status);
|
|
102
108
|
}
|
|
103
109
|
else {
|
|
104
|
-
error = new
|
|
110
|
+
error = new error_js_1.NylasApiError(camelCaseError, response.status);
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
catch (e) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CredentialType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing the type of credential
|
|
6
|
+
*/
|
|
7
|
+
var CredentialType;
|
|
8
|
+
(function (CredentialType) {
|
|
9
|
+
CredentialType["ADMINCONSENT"] = "adminconsent";
|
|
10
|
+
CredentialType["SERVICEACCOUNT"] = "serviceaccount";
|
|
11
|
+
CredentialType["CONNECTOR"] = "connector";
|
|
12
|
+
})(CredentialType = exports.CredentialType || (exports.CredentialType = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FreeBusyType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing the type of free/busy information returned for a calendar.
|
|
6
|
+
*/
|
|
7
|
+
var FreeBusyType;
|
|
8
|
+
(function (FreeBusyType) {
|
|
9
|
+
FreeBusyType["FREE_BUSY"] = "free_busy";
|
|
10
|
+
FreeBusyType["ERROR"] = "error";
|
|
11
|
+
})(FreeBusyType = exports.FreeBusyType || (exports.FreeBusyType = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessageFields = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing the message fields that can be included in a response.
|
|
6
|
+
*/
|
|
7
|
+
var MessageFields;
|
|
8
|
+
(function (MessageFields) {
|
|
9
|
+
MessageFields["STANDARD"] = "standard";
|
|
10
|
+
MessageFields["INCLUDE_HEADERS"] = "include_headers";
|
|
11
|
+
})(MessageFields = exports.MessageFields || (exports.MessageFields = {}));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebhookTriggers = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Enum representing the available webhook triggers.
|
|
6
|
+
*/
|
|
4
7
|
var WebhookTriggers;
|
|
5
8
|
(function (WebhookTriggers) {
|
|
6
9
|
WebhookTriggers["CalendarCreated"] = "calendar.created";
|
package/lib/cjs/nylas.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
const apiClient_js_1 = require("./apiClient.js");
|
|
4
|
+
const config_js_1 = require("./config.js");
|
|
5
|
+
const calendars_js_1 = require("./resources/calendars.js");
|
|
6
|
+
const events_js_1 = require("./resources/events.js");
|
|
7
|
+
const auth_js_1 = require("./resources/auth.js");
|
|
8
|
+
const webhooks_js_1 = require("./resources/webhooks.js");
|
|
9
|
+
const applications_js_1 = require("./resources/applications.js");
|
|
10
|
+
const messages_js_1 = require("./resources/messages.js");
|
|
11
|
+
const drafts_js_1 = require("./resources/drafts.js");
|
|
12
|
+
const threads_js_1 = require("./resources/threads.js");
|
|
13
|
+
const connectors_js_1 = require("./resources/connectors.js");
|
|
10
14
|
/**
|
|
11
15
|
* The entry point to the Node SDK
|
|
12
16
|
*
|
|
@@ -18,16 +22,20 @@ class Nylas {
|
|
|
18
22
|
* @param config Configuration options for the Nylas SDK
|
|
19
23
|
*/
|
|
20
24
|
constructor(config) {
|
|
21
|
-
this.apiClient = new
|
|
25
|
+
this.apiClient = new apiClient_js_1.default({
|
|
22
26
|
apiKey: config.apiKey,
|
|
23
|
-
apiUri: config.apiUri ||
|
|
27
|
+
apiUri: config.apiUri || config_js_1.DEFAULT_SERVER_URL,
|
|
24
28
|
timeout: config.timeout || 30,
|
|
25
29
|
});
|
|
26
|
-
this.applications = new
|
|
27
|
-
this.auth = new
|
|
28
|
-
this.calendars = new
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
30
|
+
this.applications = new applications_js_1.Applications(this.apiClient);
|
|
31
|
+
this.auth = new auth_js_1.Auth(this.apiClient);
|
|
32
|
+
this.calendars = new calendars_js_1.Calendars(this.apiClient);
|
|
33
|
+
this.connectors = new connectors_js_1.Connectors(this.apiClient);
|
|
34
|
+
this.drafts = new drafts_js_1.Drafts(this.apiClient);
|
|
35
|
+
this.events = new events_js_1.Events(this.apiClient);
|
|
36
|
+
this.messages = new messages_js_1.Messages(this.apiClient);
|
|
37
|
+
this.threads = new threads_js_1.Threads(this.apiClient);
|
|
38
|
+
this.webhooks = new webhooks_js_1.Webhooks(this.apiClient);
|
|
31
39
|
return this;
|
|
32
40
|
}
|
|
33
41
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Applications = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
|
+
const redirectUris_js_1 = require("./redirectUris.js");
|
|
6
6
|
/**
|
|
7
7
|
* Nylas Applications API
|
|
8
8
|
*
|
|
9
9
|
* This endpoint allows for getting application details as well as redirect URI operations.
|
|
10
10
|
*/
|
|
11
|
-
class Applications extends
|
|
11
|
+
class Applications extends resource_js_1.Resource {
|
|
12
12
|
/**
|
|
13
13
|
* @param apiClient client The configured Nylas API client
|
|
14
14
|
*/
|
|
15
15
|
constructor(apiClient) {
|
|
16
16
|
super(apiClient);
|
|
17
|
-
this.redirectUris = new
|
|
17
|
+
this.redirectUris = new redirectUris_js_1.RedirectUris(apiClient);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Get application details
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Auth = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const resource_js_1 = require("./resource.js");
|
|
7
|
+
const grants_js_1 = require("./grants.js");
|
|
8
8
|
/**
|
|
9
9
|
* A collection of authentication related API endpoints
|
|
10
10
|
*
|
|
11
11
|
* These endpoints allow for various functionality related to authentication.
|
|
12
12
|
* Also contains the Grants API and collection of provider API endpoints.
|
|
13
13
|
*/
|
|
14
|
-
class Auth extends
|
|
14
|
+
class Auth extends resource_js_1.Resource {
|
|
15
15
|
/**
|
|
16
16
|
* @param apiClient The configured Nylas API client
|
|
17
17
|
*/
|
|
18
18
|
constructor(apiClient) {
|
|
19
19
|
super(apiClient);
|
|
20
20
|
this.apiClient = apiClient;
|
|
21
|
-
this.grants = new
|
|
21
|
+
this.grants = new grants_js_1.Grants(apiClient);
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Build the URL for authenticating users to your application with OAuth 2.0
|
|
@@ -74,7 +74,7 @@ class Auth extends resource_1.Resource {
|
|
|
74
74
|
url.searchParams.set('code_challenge_method', 's256');
|
|
75
75
|
const secret = (0, uuid_1.v4)();
|
|
76
76
|
const secretHash = this.hashPKCESecret(secret);
|
|
77
|
-
url.searchParams.set('code_challenge',
|
|
77
|
+
url.searchParams.set('code_challenge', secretHash);
|
|
78
78
|
// Return the url with secret & hashed secret
|
|
79
79
|
return { secret, secretHash, url: url.toString() };
|
|
80
80
|
}
|
|
@@ -138,16 +138,18 @@ class Auth extends resource_1.Resource {
|
|
|
138
138
|
if (config.prompt) {
|
|
139
139
|
url.searchParams.set('prompt', config.prompt);
|
|
140
140
|
}
|
|
141
|
-
if (config.metadata) {
|
|
142
|
-
url.searchParams.set('metadata', config.metadata);
|
|
143
|
-
}
|
|
144
141
|
if (config.state) {
|
|
145
142
|
url.searchParams.set('state', config.state);
|
|
146
143
|
}
|
|
147
144
|
return url;
|
|
148
145
|
}
|
|
149
146
|
hashPKCESecret(secret) {
|
|
150
|
-
|
|
147
|
+
const hash = (0, node_crypto_1.createHash)('sha256')
|
|
148
|
+
.update(secret)
|
|
149
|
+
.digest('hex');
|
|
150
|
+
return Buffer.from(hash)
|
|
151
|
+
.toString('base64')
|
|
152
|
+
.replace(/=+$/, '');
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
exports.Auth = Auth;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Calendars = void 0;
|
|
4
|
-
const
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
5
|
/**
|
|
6
6
|
* Nylas Calendar API
|
|
7
7
|
*
|
|
8
8
|
* The Nylas calendar API allows you to create new calendars or manage existing ones.
|
|
9
9
|
* A calendar can be accessed by one, or several people, and can contain events.
|
|
10
10
|
*/
|
|
11
|
-
class Calendars extends
|
|
11
|
+
class Calendars extends resource_js_1.Resource {
|
|
12
12
|
/**
|
|
13
13
|
* Return all Calendars
|
|
14
14
|
* @return A list of calendars
|
|
@@ -74,5 +74,17 @@ class Calendars extends resource_1.Resource {
|
|
|
74
74
|
overrides,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the free/busy schedule for a list of email addresses
|
|
79
|
+
* @return The free/busy response
|
|
80
|
+
*/
|
|
81
|
+
getFreeBusy({ identifier, requestBody, overrides, }) {
|
|
82
|
+
return this.apiClient.request({
|
|
83
|
+
method: 'POST',
|
|
84
|
+
path: `/v3/grants/${identifier}/calendars/free-busy`,
|
|
85
|
+
body: requestBody,
|
|
86
|
+
overrides,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
77
89
|
}
|
|
78
90
|
exports.Calendars = Calendars;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Connectors = void 0;
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
|
+
const credentials_js_1 = require("./credentials.js");
|
|
6
|
+
class Connectors extends resource_js_1.Resource {
|
|
7
|
+
/**
|
|
8
|
+
* @param apiClient client The configured Nylas API client
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
super(apiClient);
|
|
12
|
+
this.credentials = new credentials_js_1.Credentials(apiClient);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Return all connectors
|
|
16
|
+
* @return A list of connectors
|
|
17
|
+
*/
|
|
18
|
+
list({ queryParams, overrides, }) {
|
|
19
|
+
return super._list({
|
|
20
|
+
queryParams,
|
|
21
|
+
overrides,
|
|
22
|
+
path: `/v3/connectors`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Return a connector
|
|
27
|
+
* @return The connector
|
|
28
|
+
*/
|
|
29
|
+
find({ provider, overrides, }) {
|
|
30
|
+
return super._find({
|
|
31
|
+
path: `/v3/connectors/${provider}`,
|
|
32
|
+
overrides,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a connector
|
|
37
|
+
* @return The created connector
|
|
38
|
+
*/
|
|
39
|
+
create({ requestBody, overrides, }) {
|
|
40
|
+
return super._create({
|
|
41
|
+
path: `/v3/connectors`,
|
|
42
|
+
requestBody,
|
|
43
|
+
overrides,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Update a connector
|
|
48
|
+
* @return The updated connector
|
|
49
|
+
*/
|
|
50
|
+
update({ provider, requestBody, overrides, }) {
|
|
51
|
+
return super._update({
|
|
52
|
+
path: `/v3/connectors/${provider}`,
|
|
53
|
+
requestBody,
|
|
54
|
+
overrides,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Delete a connector
|
|
59
|
+
* @return The deleted connector
|
|
60
|
+
*/
|
|
61
|
+
destroy({ provider, overrides, }) {
|
|
62
|
+
return super._destroy({
|
|
63
|
+
path: `/v3/connectors/${provider}`,
|
|
64
|
+
overrides,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Connectors = Connectors;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Credentials = void 0;
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
|
+
class Credentials extends resource_js_1.Resource {
|
|
6
|
+
/**
|
|
7
|
+
* Return all credentials
|
|
8
|
+
* @return A list of credentials
|
|
9
|
+
*/
|
|
10
|
+
list({ provider, queryParams, overrides, }) {
|
|
11
|
+
return super._list({
|
|
12
|
+
queryParams,
|
|
13
|
+
overrides,
|
|
14
|
+
path: `/v3/credentials/${provider}/creds`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Return a credential
|
|
19
|
+
* @return The credential
|
|
20
|
+
*/
|
|
21
|
+
find({ provider, credentialsId, overrides, }) {
|
|
22
|
+
return super._find({
|
|
23
|
+
path: `/v3/credentials/${provider}/creds/${credentialsId}`,
|
|
24
|
+
overrides,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a credential
|
|
29
|
+
* @return The created credential
|
|
30
|
+
*/
|
|
31
|
+
create({ provider, requestBody, overrides, }) {
|
|
32
|
+
return super._create({
|
|
33
|
+
path: `/v3/credentials/${provider}/creds`,
|
|
34
|
+
requestBody,
|
|
35
|
+
overrides,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update a credential
|
|
40
|
+
* @return The updated credential
|
|
41
|
+
*/
|
|
42
|
+
update({ provider, credentialsId, requestBody, overrides, }) {
|
|
43
|
+
return super._update({
|
|
44
|
+
path: `/v3/credentials/${provider}/creds/${credentialsId}}`,
|
|
45
|
+
requestBody,
|
|
46
|
+
overrides,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Delete a credential
|
|
51
|
+
* @return The deleted credential
|
|
52
|
+
*/
|
|
53
|
+
destroy({ provider, credentialsId, overrides, }) {
|
|
54
|
+
return super._destroy({
|
|
55
|
+
path: `/v3/credentials/${provider}/creds/${credentialsId}}`,
|
|
56
|
+
overrides,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Credentials = Credentials;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Drafts = void 0;
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
|
+
const messages_js_1 = require("./messages.js");
|
|
6
|
+
/**
|
|
7
|
+
* Nylas Drafts API
|
|
8
|
+
*
|
|
9
|
+
* The Nylas Drafts API allows you to list, find, update, delete, and send drafts on user accounts.
|
|
10
|
+
*/
|
|
11
|
+
class Drafts extends resource_js_1.Resource {
|
|
12
|
+
/**
|
|
13
|
+
* Return all Drafts
|
|
14
|
+
* @return A list of drafts
|
|
15
|
+
*/
|
|
16
|
+
list({ identifier, queryParams, overrides, }) {
|
|
17
|
+
return super._list({
|
|
18
|
+
queryParams,
|
|
19
|
+
overrides,
|
|
20
|
+
path: `/v3/grants/${identifier}/drafts`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Return a Draft
|
|
25
|
+
* @return The draft
|
|
26
|
+
*/
|
|
27
|
+
find({ identifier, draftId, overrides, }) {
|
|
28
|
+
return super._find({
|
|
29
|
+
path: `/v3/grants/${identifier}/drafts/${draftId}`,
|
|
30
|
+
overrides,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return a Draft
|
|
35
|
+
* @return The draft
|
|
36
|
+
*/
|
|
37
|
+
create({ identifier, requestBody, overrides, }) {
|
|
38
|
+
const form = messages_js_1.Messages._buildFormRequest(requestBody);
|
|
39
|
+
return this.apiClient.request({
|
|
40
|
+
method: 'POST',
|
|
41
|
+
path: `/v3/grants/${identifier}/drafts`,
|
|
42
|
+
form,
|
|
43
|
+
overrides,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Update a Draft
|
|
48
|
+
* @return The updated draft
|
|
49
|
+
*/
|
|
50
|
+
update({ identifier, draftId, requestBody, overrides, }) {
|
|
51
|
+
const form = messages_js_1.Messages._buildFormRequest(requestBody);
|
|
52
|
+
return this.apiClient.request({
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
path: `/v3/grants/${identifier}/drafts/${draftId}`,
|
|
55
|
+
form,
|
|
56
|
+
overrides,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Delete a Draft
|
|
61
|
+
* @return The deleted draft
|
|
62
|
+
*/
|
|
63
|
+
destroy({ identifier, draftId, overrides, }) {
|
|
64
|
+
return super._destroy({
|
|
65
|
+
path: `/v3/grants/${identifier}/drafts/${draftId}`,
|
|
66
|
+
overrides,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Send a Draft
|
|
71
|
+
* @return The sent draft
|
|
72
|
+
*/
|
|
73
|
+
send({ identifier, draftId, overrides, }) {
|
|
74
|
+
return super._create({
|
|
75
|
+
path: `/v3/grants/${identifier}/drafts/${draftId}`,
|
|
76
|
+
requestBody: {},
|
|
77
|
+
overrides,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Drafts = Drafts;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Events = void 0;
|
|
4
|
-
const
|
|
4
|
+
const resource_js_1 = require("./resource.js");
|
|
5
5
|
/**
|
|
6
6
|
* Nylas Events API
|
|
7
7
|
*
|
|
8
8
|
* The Nylas Events API allows you to create, update, and delete events on user calendars.
|
|
9
9
|
*/
|
|
10
|
-
class Events extends
|
|
10
|
+
class Events extends resource_js_1.Resource {
|
|
11
11
|
/**
|
|
12
12
|
* Return all Events
|
|
13
13
|
* @return The list of Events
|