nylas 8.0.5 โ†’ 8.1.1

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 (39) hide show
  1. package/README.md +117 -46
  2. package/lib/cjs/models/agentLists.js +2 -0
  3. package/lib/cjs/models/index.js +3 -0
  4. package/lib/cjs/models/policies.js +2 -0
  5. package/lib/cjs/models/rules.js +2 -0
  6. package/lib/cjs/nylas.js +6 -0
  7. package/lib/cjs/resources/agentLists.js +99 -0
  8. package/lib/cjs/resources/attachments.js +28 -0
  9. package/lib/cjs/resources/messages.js +1 -1
  10. package/lib/cjs/resources/policies.js +66 -0
  11. package/lib/cjs/resources/rules.js +79 -0
  12. package/lib/cjs/utils.js +1 -1
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/esm/models/agentLists.js +1 -0
  15. package/lib/esm/models/index.js +3 -0
  16. package/lib/esm/models/policies.js +1 -0
  17. package/lib/esm/models/rules.js +1 -0
  18. package/lib/esm/nylas.js +6 -0
  19. package/lib/esm/resources/agentLists.js +95 -0
  20. package/lib/esm/resources/attachments.js +28 -0
  21. package/lib/esm/resources/messages.js +1 -1
  22. package/lib/esm/resources/policies.js +62 -0
  23. package/lib/esm/resources/rules.js +75 -0
  24. package/lib/esm/utils.js +1 -1
  25. package/lib/esm/version.js +1 -1
  26. package/lib/types/models/agentLists.d.ts +123 -0
  27. package/lib/types/models/attachments.d.ts +81 -0
  28. package/lib/types/models/auth.d.ts +1 -1
  29. package/lib/types/models/grants.d.ts +37 -2
  30. package/lib/types/models/index.d.ts +3 -0
  31. package/lib/types/models/policies.d.ts +167 -0
  32. package/lib/types/models/rules.d.ts +318 -0
  33. package/lib/types/nylas.d.ts +15 -0
  34. package/lib/types/resources/agentLists.d.ts +108 -0
  35. package/lib/types/resources/attachments.d.ts +31 -1
  36. package/lib/types/resources/policies.d.ts +69 -0
  37. package/lib/types/resources/rules.d.ts +82 -0
  38. package/lib/types/version.d.ts +1 -1
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -2,59 +2,63 @@
2
2
  <a href="https://www.nylas.com/">
3
3
  <img src="/diagrams/nylas-logo.png" alt="Nylas" height="80" />
4
4
  </a>
5
-
5
+
6
6
  <h1>Nylas Node.js SDK</h1>
7
-
7
+
8
8
  <p>
9
- <strong>The official Node.js SDK for the Nylas Communications Platform</strong>
9
+ <strong>The official Node.js SDK for Nylas โ€” the infrastructure that powers communications</strong>
10
10
  </p>
11
-
11
+
12
12
  <p>
13
13
  <a href="https://www.npmjs.com/package/nylas"><img src="https://img.shields.io/npm/v/nylas" alt="npm version" /></a>
14
14
  <a href="https://codecov.io/gh/nylas/nylas-nodejs"><img src="https://codecov.io/gh/nylas/nylas-nodejs/branch/main/graph/badge.svg?token=94IMGU4F09" alt="code coverage" /></a>
15
15
  <a href="https://www.npmjs.com/package/nylas"><img src="https://img.shields.io/npm/dm/nylas" alt="downloads" /></a>
16
16
  <a href="LICENSE.txt"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="license" /></a>
17
17
  </p>
18
-
18
+
19
19
  <p>
20
- <a href="https://developer.nylas.com/docs/v3/sdks/node/">๐Ÿ“– Documentation</a> โ€ข
21
- <a href="https://dashboard.nylas.com/register">๐Ÿš€ Get Started</a> โ€ข
22
- <a href="https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=javascript">๐Ÿ’ก Examples</a> โ€ข
23
- <a href="https://developer.nylas.com/docs/api/">๐Ÿ“š API Reference</a>
20
+ <a href="https://developer.nylas.com/docs/v3/sdks/node/">๐Ÿ“– SDK Guide</a> ยท
21
+ <a href="https://developer.nylas.com/docs/api/v3/">๐Ÿ“š API Reference</a> ยท
22
+ <a href="https://dashboard-v3.nylas.com/register">๐Ÿš€ Sign up</a> ยท
23
+ <a href="https://github.com/orgs/nylas-samples/repositories?q=node">๐Ÿ’ก Samples</a> ยท
24
+ <a href="https://forums.nylas.com">๐Ÿ’ฌ Forum</a>
24
25
  </p>
25
26
  </div>
26
27
 
27
28
  <br />
28
29
 
29
- 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/).
30
+ The official Node.js SDK for [Nylas](https://developer.nylas.com/docs/v3/) โ€” the infrastructure that powers communications. Integrate with Gmail, Microsoft, IMAP, Zoom, and 250+ email, calendar, and meeting providers in 5 minutes. Covers [Email](https://developer.nylas.com/docs/v3/email/), [Calendar](https://developer.nylas.com/docs/v3/calendar/), [Contacts](https://developer.nylas.com/docs/v3/email/contacts/), [Scheduler](https://developer.nylas.com/docs/v3/scheduler/), [Notetaker](https://developer.nylas.com/docs/v3/notetaker/), and [Agent Accounts](https://developer.nylas.com/docs/v3/agent-accounts/).
30
31
 
31
- 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.
32
+ This repository is for contributors and anyone installing the SDK from source. If you just want to use the SDK in your app, head straight to the [**Node.js SDK guide**](https://developer.nylas.com/docs/v3/sdks/node/) on developer.nylas.com.
32
33
 
33
- Here are some resources to help you get started:
34
+ ## Get started
34
35
 
35
- - [Sign up for your free Nylas account](https://dashboard.nylas.com/register)
36
- - [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)
37
- - [Nylas API v3 Quickstart Guide](https://developer.nylas.com/docs/v3-beta/v3-quickstart/)
38
- - [Nylas SDK Reference](https://nylas-nodejs-sdk-reference.pages.dev/)
39
- - [Nylas API Reference](https://developer.nylas.com/docs/api/)
40
- - [Nylas Samples repo for code samples and example applications](https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=javascript)
36
+ 1. [Sign up for a free Nylas account](https://dashboard-v3.nylas.com/register) and grab your API key from the [Nylas Dashboard](https://dashboard-v3.nylas.com/).
37
+ 2. Read the [Getting started guide](https://developer.nylas.com/docs/v3/getting-started/) for the core concepts (applications, grants, API keys).
38
+ 3. Install the SDK and make your first request โ€” see below.
41
39
 
42
- ## โš™๏ธ Install
40
+ You can also bootstrap from the terminal:
43
41
 
44
- **Note:** The Nylas Node SDK requires Node.js v16 or later.
42
+ ```bash
43
+ brew install nylas/nylas-cli/nylas
44
+ nylas init
45
+ ```
45
46
 
46
- ### Set up using npm
47
+ More options in the [CLI getting-started guide](https://cli.nylas.com/guides/getting-started).
47
48
 
48
- 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.
49
+ ## โš™๏ธ Install
49
50
 
50
- Then, head to the nearest command line and run the following:
51
- `npm install nylas`
51
+ > **Requirements:** Node.js v18 or later.
52
52
 
53
- Alternatively, you can use [Yarn](https://yarnpkg.com/en/) to install the Nylas Node SDK by running the `yarn add nylas` command.
53
+ ```bash
54
+ npm install nylas
55
+ # or
56
+ yarn add nylas
57
+ ```
54
58
 
55
- ### Build from source
59
+ The package ships its own TypeScript types โ€” no `@types/nylas` needed. It's a hybrid ESM + CommonJS package, so both `import` and `require` work.
56
60
 
57
- To install this package from source, clone this repo and run `npm install` from inside the project directory.
61
+ To install from source:
58
62
 
59
63
  ```bash
60
64
  git clone https://github.com/nylas/nylas-nodejs.git
@@ -62,48 +66,115 @@ cd nylas-nodejs
62
66
  npm install
63
67
  ```
64
68
 
65
- ## โšก๏ธ Usage
66
-
67
- To use this SDK, you must first [get a free Nylas account](https://dashboard.nylas.com/register).
68
-
69
- Then, follow the Quickstart guide to [set up your first app and get your API keys](https://developer.nylas.com/docs/v3-beta/v3-quickstart/).
69
+ ### Runtime support
70
70
 
71
- For code examples that demonstrate how to use this SDK, take a look at our [Node repos in the Nylas Samples collection](https://github.com/orgs/nylas-samples/repositories?q=&type=all&language=javascript&sort=).
71
+ Tested on Node.js 18+. Also runs on AWS Lambda, Cloudflare Workers, and Vite/edge environments โ€” see the [`examples/`](examples/) directory for working setups.
72
72
 
73
- ### ๐Ÿš€ Making Your First Request
73
+ ## โšก๏ธ Usage
74
74
 
75
- 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.
75
+ You access Nylas resources (messages, calendars, events, contacts, โ€ฆ) through an instance of `Nylas`. Initialize it with your API key โ€” and optionally an `apiUri` matching your [data residency](https://developer.nylas.com/docs/dev-guide/platform/data-residency/).
76
76
 
77
77
  ```typescript
78
78
  import Nylas from "nylas";
79
+ // or: const Nylas = require("nylas").default;
79
80
 
80
81
  const nylas = new Nylas({
81
- apiKey: "NYLAS_API_KEY",
82
+ apiKey: process.env.NYLAS_API_KEY,
83
+ apiUri: process.env.NYLAS_API_URI, // e.g. https://api.us.nylas.com
84
+ timeout: 30, // optional, in seconds
82
85
  });
83
86
  ```
84
87
 
85
- 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:
88
+ Once initialized, use it to make requests against a [grant](https://developer.nylas.com/docs/v3/auth/) (an authenticated end-user account):
86
89
 
87
90
  ```typescript
88
- nylas.calendars.list({ identifier: "GRANT_ID" }).then(calendars => {
89
- console.log(calendars);
91
+ const calendars = await nylas.calendars.list({
92
+ identifier: process.env.NYLAS_GRANT_ID,
90
93
  });
94
+ console.log(calendars);
95
+ ```
96
+
97
+ ### Error handling
98
+
99
+ The SDK throws typed errors you can catch and inspect. Every API error carries a `requestId` and `flowId` โ€” include both when filing a support ticket so we can trace the request end-to-end.
100
+
101
+ ```typescript
102
+ import { NylasApiError, NylasOAuthError, NylasSdkTimeoutError } from "nylas";
103
+
104
+ try {
105
+ await nylas.calendars.list({ identifier: grantId });
106
+ } catch (err) {
107
+ if (err instanceof NylasApiError) {
108
+ console.error(err.statusCode, err.type, err.message, err.requestId, err.flowId);
109
+ } else if (err instanceof NylasSdkTimeoutError) {
110
+ console.error("Timed out:", err.url, err.timeout);
111
+ } else {
112
+ throw err;
113
+ }
114
+ }
91
115
  ```
92
116
 
93
- ## ๐Ÿ“š Documentation
117
+ Step-by-step walkthroughs in the SDK guide:
94
118
 
95
- 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.
119
+ - [Send and receive email](https://developer.nylas.com/docs/v3/sdks/node/send-email/)
120
+ - [Read messages and threads](https://developer.nylas.com/docs/v3/sdks/node/read-messages-threads/)
121
+ - [Manage events on a calendar](https://developer.nylas.com/docs/v3/sdks/node/manage-events/)
122
+ - [Manage contacts](https://developer.nylas.com/docs/v3/sdks/node/manage-contacts/)
123
+ - [Manage folders and labels](https://developer.nylas.com/docs/v3/sdks/node/manage-folders-labels/)
124
+ - [Test webhooks locally](https://developer.nylas.com/docs/v3/sdks/node/webhook-testing/)
96
125
 
97
- ## โœจ Upgrading from 6.x
126
+ ## ๐Ÿ’ก Examples
98
127
 
99
- See [UPGRADE.md](UPGRADE.md) for instructions on upgrading from 6.x to 7.x.
128
+ Runnable examples live in [`examples/`](examples/) โ€” including [agent accounts](examples/agent-accounts/), [attachments](examples/attachments/) (incl. large attachments), [calendars](examples/calendars/), [folders](examples/folders/), [grants](examples/grants/), [messages](examples/messages/), [notetakers](examples/notetakers/), and edge runtimes ([AWS Lambda](examples/aws-lambda/), [Cloudflare + Vite](examples/cloudflare-vite-calendars/), [generic edge](examples/edge-environment/)).
100
129
 
101
- **Note**: The Node SDK v7.x is not compatible with the Nylas API earlier than v3-beta.
130
+ For full sample apps and product quickstarts, browse [**nylas-samples** on GitHub](https://github.com/orgs/nylas-samples/repositories?q=node) โ€” every official SDK has Email, Calendar, Contacts, Scheduler, and Webhooks quickstarts.
131
+
132
+ ## ๐Ÿค– AI agents
133
+
134
+ [nylas/skills](https://github.com/nylas/skills) drops Nylas into Claude Code, Cursor, Codex, and other agents that support the skills format:
135
+
136
+ ```bash
137
+ npx skills add nylas/skills
138
+ /plugin marketplace add nylas/skills # Claude Code
139
+ ```
140
+
141
+ The CLI also installs an MCP server for Claude Desktop, Claude Code, Cursor, Windsurf, or VS Code:
142
+
143
+ ```bash
144
+ brew install nylas/nylas-cli/nylas
145
+ nylas mcp install
146
+ ```
147
+
148
+ Walkthrough: [give AI agents email access via MCP](https://cli.nylas.com/guides/give-ai-agents-email-access-via-mcp).
149
+
150
+ ## ๐Ÿ“š Reference
151
+
152
+ - **SDK guide:** [developer.nylas.com/docs/v3/sdks/node](https://developer.nylas.com/docs/v3/sdks/node/)
153
+ - **API reference:** [developer.nylas.com/docs/api/v3](https://developer.nylas.com/docs/api/v3/)
154
+ - **TypeDoc reference:** [nylas-nodejs-sdk-reference.pages.dev](https://nylas-nodejs-sdk-reference.pages.dev/) โ€” generated method/class docs for this SDK
155
+ - **Webhooks (notifications):** [developer.nylas.com/docs/v3/notifications](https://developer.nylas.com/docs/v3/notifications/)
156
+ - **Auth flows:** [developer.nylas.com/docs/v3/auth](https://developer.nylas.com/docs/v3/auth/)
157
+ - **Dev guide & best practices:** [developer.nylas.com/docs/dev-guide](https://developer.nylas.com/docs/dev-guide/)
158
+ - **Changelog:** [CHANGELOG.md](CHANGELOG.md)
159
+
160
+ ## โœจ Upgrading
161
+
162
+ See [`CHANGELOG.md`](CHANGELOG.md) for per-release notes. Older upgrade guidance lives in [`UPGRADE.md`](UPGRADE.md).
102
163
 
103
164
  ## ๐Ÿ’™ Contributing
104
165
 
105
- Please refer to [Contributing](Contributing.md) for information about how to make contributions to this project. We welcome questions, bug reports, and pull requests.
166
+ Issues, ideas, and pull requests welcome โ€” see [Contributing.md](Contributing.md). Before opening a large change, please open an issue or post in the [forum](https://forums.nylas.com) so we can sanity-check the direction.
167
+
168
+ ## ๐Ÿ”’ Security
169
+
170
+ Found a vulnerability? Please **don't** open a public issue. Report it through our [Vulnerability Disclosure Policy](https://www.nylas.com/security/vulnerability-disclosure-policy/).
171
+
172
+ ## ๐Ÿ”— Other Nylas SDKs
173
+
174
+ - [nylas-python](https://github.com/nylas/nylas-python) ยท `pip install nylas`
175
+ - [nylas-ruby](https://github.com/nylas/nylas-ruby) ยท `gem install nylas`
176
+ - [nylas-java](https://github.com/nylas/nylas-java) ยท Maven / Gradle (Kotlin too)
106
177
 
107
178
  ## ๐Ÿ“ License
108
179
 
109
- This project is licensed under the terms of the MIT license. Please refer to [LICENSE](LICENSE.txt) for the full terms.
180
+ MIT โ€” see [LICENSE.txt](LICENSE.txt).
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // This file is generated by scripts/generateModelIndex.js
18
+ __exportStar(require("./agentLists.js"), exports);
18
19
  __exportStar(require("./applicationDetails.js"), exports);
19
20
  __exportStar(require("./attachments.js"), exports);
20
21
  __exportStar(require("./auth.js"), exports);
@@ -32,8 +33,10 @@ __exportStar(require("./grants.js"), exports);
32
33
  __exportStar(require("./listQueryParams.js"), exports);
33
34
  __exportStar(require("./messages.js"), exports);
34
35
  __exportStar(require("./notetakers.js"), exports);
36
+ __exportStar(require("./policies.js"), exports);
35
37
  __exportStar(require("./redirectUri.js"), exports);
36
38
  __exportStar(require("./response.js"), exports);
39
+ __exportStar(require("./rules.js"), exports);
37
40
  __exportStar(require("./scheduler.js"), exports);
38
41
  __exportStar(require("./smartCompose.js"), exports);
39
42
  __exportStar(require("./threads.js"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/cjs/nylas.js CHANGED
@@ -35,6 +35,9 @@ const contacts_js_1 = require("./resources/contacts.js");
35
35
  const attachments_js_1 = require("./resources/attachments.js");
36
36
  const scheduler_js_1 = require("./resources/scheduler.js");
37
37
  const notetakers_js_1 = require("./resources/notetakers.js");
38
+ const policies_js_1 = require("./resources/policies.js");
39
+ const rules_js_1 = require("./resources/rules.js");
40
+ const agentLists_js_1 = require("./resources/agentLists.js");
38
41
  /**
39
42
  * The entry point to the Node SDK
40
43
  *
@@ -61,6 +64,9 @@ class Nylas {
61
64
  this.grants = new grants_js_1.Grants(this.apiClient);
62
65
  this.messages = new messages_js_1.Messages(this.apiClient);
63
66
  this.notetakers = new notetakers_js_1.Notetakers(this.apiClient);
67
+ this.policies = new policies_js_1.Policies(this.apiClient);
68
+ this.rules = new rules_js_1.Rules(this.apiClient);
69
+ this.lists = new agentLists_js_1.AgentLists(this.apiClient);
64
70
  this.threads = new threads_js_1.Threads(this.apiClient);
65
71
  this.webhooks = new webhooks_js_1.Webhooks(this.apiClient);
66
72
  this.folders = new folders_js_1.Folders(this.apiClient);
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentLists = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const resource_js_1 = require("./resource.js");
6
+ /**
7
+ * Nylas Agent Account Lists API
8
+ *
9
+ * Lists manage values that rules can reference using the in_list operator.
10
+ */
11
+ class AgentLists extends resource_js_1.Resource {
12
+ /**
13
+ * Return all lists.
14
+ * @return The list of Agent Account lists.
15
+ */
16
+ list({ queryParams, overrides, } = {}) {
17
+ return super._list({
18
+ queryParams,
19
+ path: (0, utils_js_1.makePathParams)('/v3/lists', {}),
20
+ overrides,
21
+ });
22
+ }
23
+ /**
24
+ * Return a list.
25
+ * @return The Agent Account list.
26
+ */
27
+ find({ listId, overrides, }) {
28
+ return super._find({
29
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}', { listId }),
30
+ overrides,
31
+ });
32
+ }
33
+ /**
34
+ * Create a list.
35
+ * @return The created Agent Account list.
36
+ */
37
+ create({ requestBody, overrides, }) {
38
+ return super._create({
39
+ path: (0, utils_js_1.makePathParams)('/v3/lists', {}),
40
+ requestBody,
41
+ overrides,
42
+ });
43
+ }
44
+ /**
45
+ * Update a list.
46
+ * @return The updated Agent Account list.
47
+ */
48
+ update({ listId, requestBody, overrides, }) {
49
+ return super._update({
50
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}', { listId }),
51
+ requestBody,
52
+ overrides,
53
+ });
54
+ }
55
+ /**
56
+ * Delete a list.
57
+ * @return The deletion response.
58
+ */
59
+ destroy({ listId, overrides, }) {
60
+ return super._destroy({
61
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}', { listId }),
62
+ overrides,
63
+ });
64
+ }
65
+ /**
66
+ * Return items in a list.
67
+ * @return The list items.
68
+ */
69
+ listItems({ listId, queryParams, overrides, }) {
70
+ return super._list({
71
+ queryParams,
72
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}/items', { listId }),
73
+ overrides,
74
+ });
75
+ }
76
+ /**
77
+ * Add items to a list.
78
+ * @return The updated Agent Account list.
79
+ */
80
+ addItems({ listId, requestBody, overrides, }) {
81
+ return super._create({
82
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}/items', { listId }),
83
+ requestBody,
84
+ overrides,
85
+ });
86
+ }
87
+ /**
88
+ * Remove items from a list.
89
+ * @return The updated Agent Account list.
90
+ */
91
+ removeItems({ listId, requestBody, overrides, }) {
92
+ return super._destroy({
93
+ path: (0, utils_js_1.makePathParams)('/v3/lists/{listId}/items', { listId }),
94
+ requestBody,
95
+ overrides,
96
+ });
97
+ }
98
+ }
99
+ exports.AgentLists = AgentLists;
@@ -54,5 +54,33 @@ class Attachments extends resource_js_1.Resource {
54
54
  overrides,
55
55
  });
56
56
  }
57
+ /**
58
+ * Create a resumable upload session for a large attachment (up to 150 MB).
59
+ * Upload bytes to the returned `url`, then call {@link Attachments.completeUploadSession}.
60
+ *
61
+ * @see https://developer.nylas.com/docs/v3/email/send-large-attachments/
62
+ * @return Session details including `attachmentId` and pre-signed `url`
63
+ */
64
+ createUploadSession({ identifier, requestBody, overrides, }) {
65
+ return super._create({
66
+ path: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/attachment-uploads', {
67
+ identifier,
68
+ }),
69
+ requestBody,
70
+ overrides,
71
+ });
72
+ }
73
+ /**
74
+ * Complete an upload session after the file has been uploaded to the pre-signed URL.
75
+ *
76
+ * @see https://developer.nylas.com/docs/v3/email/send-large-attachments/
77
+ */
78
+ completeUploadSession({ identifier, attachmentId, overrides, }) {
79
+ return super._create({
80
+ path: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/attachment-uploads/{attachmentId}/complete', { identifier, attachmentId }),
81
+ requestBody: {},
82
+ overrides,
83
+ });
84
+ }
57
85
  }
58
86
  exports.Attachments = Attachments;
@@ -162,7 +162,7 @@ class Messages extends resource_js_1.Resource {
162
162
  ...requestBody,
163
163
  attachments: undefined,
164
164
  };
165
- form.append('message', JSON.stringify((0, utils_js_1.objKeysToSnakeCase)(messagePayload)));
165
+ form.append('message', JSON.stringify((0, utils_js_1.objKeysToSnakeCase)(messagePayload, ['metadata'])));
166
166
  // Add a separate form field for each attachment
167
167
  if (requestBody.attachments && requestBody.attachments.length > 0) {
168
168
  requestBody.attachments.map((attachment, index) => {
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Policies = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const resource_js_1 = require("./resource.js");
6
+ /**
7
+ * Nylas Agent Account Policies API
8
+ *
9
+ * Policies define limits, spam settings, options, and linked rules for Agent Accounts.
10
+ */
11
+ class Policies extends resource_js_1.Resource {
12
+ /**
13
+ * Return all policies.
14
+ * @return The list of policies.
15
+ */
16
+ list({ queryParams, overrides, } = {}) {
17
+ return super._list({
18
+ queryParams,
19
+ path: (0, utils_js_1.makePathParams)('/v3/policies', {}),
20
+ overrides,
21
+ });
22
+ }
23
+ /**
24
+ * Return a policy.
25
+ * @return The policy.
26
+ */
27
+ find({ policyId, overrides, }) {
28
+ return super._find({
29
+ path: (0, utils_js_1.makePathParams)('/v3/policies/{policyId}', { policyId }),
30
+ overrides,
31
+ });
32
+ }
33
+ /**
34
+ * Create a policy.
35
+ * @return The created policy.
36
+ */
37
+ create({ requestBody, overrides, }) {
38
+ return super._create({
39
+ path: (0, utils_js_1.makePathParams)('/v3/policies', {}),
40
+ requestBody,
41
+ overrides,
42
+ });
43
+ }
44
+ /**
45
+ * Update a policy.
46
+ * @return The updated policy.
47
+ */
48
+ update({ policyId, requestBody, overrides, }) {
49
+ return super._update({
50
+ path: (0, utils_js_1.makePathParams)('/v3/policies/{policyId}', { policyId }),
51
+ requestBody,
52
+ overrides,
53
+ });
54
+ }
55
+ /**
56
+ * Delete a policy.
57
+ * @return The deletion response.
58
+ */
59
+ destroy({ policyId, overrides, }) {
60
+ return super._destroy({
61
+ path: (0, utils_js_1.makePathParams)('/v3/policies/{policyId}', { policyId }),
62
+ overrides,
63
+ });
64
+ }
65
+ }
66
+ exports.Policies = Policies;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rules = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const resource_js_1 = require("./resource.js");
6
+ /**
7
+ * Nylas Agent Account Rules API
8
+ *
9
+ * Rules define inbound and outbound filtering logic for Agent Accounts.
10
+ */
11
+ class Rules extends resource_js_1.Resource {
12
+ /**
13
+ * Return all rules.
14
+ * @return The list of rules.
15
+ */
16
+ list({ queryParams, overrides, } = {}) {
17
+ return super._list({
18
+ queryParams,
19
+ path: (0, utils_js_1.makePathParams)('/v3/rules', {}),
20
+ overrides,
21
+ });
22
+ }
23
+ /**
24
+ * Return a rule.
25
+ * @return The rule.
26
+ */
27
+ find({ ruleId, overrides, }) {
28
+ return super._find({
29
+ path: (0, utils_js_1.makePathParams)('/v3/rules/{ruleId}', { ruleId }),
30
+ overrides,
31
+ });
32
+ }
33
+ /**
34
+ * Create a rule.
35
+ * @return The created rule.
36
+ */
37
+ create({ requestBody, overrides, }) {
38
+ return super._create({
39
+ path: (0, utils_js_1.makePathParams)('/v3/rules', {}),
40
+ requestBody,
41
+ overrides,
42
+ });
43
+ }
44
+ /**
45
+ * Update a rule.
46
+ * @return The updated rule.
47
+ */
48
+ update({ ruleId, requestBody, overrides, }) {
49
+ return super._update({
50
+ path: (0, utils_js_1.makePathParams)('/v3/rules/{ruleId}', { ruleId }),
51
+ requestBody,
52
+ overrides,
53
+ });
54
+ }
55
+ /**
56
+ * Delete a rule.
57
+ * @return The deletion response.
58
+ */
59
+ destroy({ ruleId, overrides, }) {
60
+ return super._destroy({
61
+ path: (0, utils_js_1.makePathParams)('/v3/rules/{ruleId}', { ruleId }),
62
+ overrides,
63
+ });
64
+ }
65
+ /**
66
+ * Return rule evaluation records for a grant.
67
+ * @return The list of rule evaluation records.
68
+ */
69
+ listEvaluations({ identifier, queryParams, overrides, }) {
70
+ return super._list({
71
+ queryParams,
72
+ path: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/rule-evaluations', {
73
+ identifier,
74
+ }),
75
+ overrides,
76
+ });
77
+ }
78
+ }
79
+ exports.Rules = Rules;
package/lib/cjs/utils.js CHANGED
@@ -249,7 +249,7 @@ function calculateTotalPayloadSize(requestBody) {
249
249
  ...requestBody,
250
250
  attachments: undefined,
251
251
  };
252
- const messagePayloadString = JSON.stringify(objKeysToSnakeCase(messagePayloadWithoutAttachments));
252
+ const messagePayloadString = JSON.stringify(objKeysToSnakeCase(messagePayloadWithoutAttachments, ['metadata']));
253
253
  totalSize += Buffer.byteLength(messagePayloadString, 'utf8');
254
254
  // Add attachment sizes
255
255
  const attachmentSize = requestBody.attachments?.reduce((total, attachment) => {
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // This file is generated by scripts/exportVersion.js
5
- exports.SDK_VERSION = '8.0.5';
5
+ exports.SDK_VERSION = '8.1.1';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  // This file is generated by scripts/generateModelIndex.js
2
+ export * from './agentLists.js';
2
3
  export * from './applicationDetails.js';
3
4
  export * from './attachments.js';
4
5
  export * from './auth.js';
@@ -16,8 +17,10 @@ export * from './grants.js';
16
17
  export * from './listQueryParams.js';
17
18
  export * from './messages.js';
18
19
  export * from './notetakers.js';
20
+ export * from './policies.js';
19
21
  export * from './redirectUri.js';
20
22
  export * from './response.js';
23
+ export * from './rules.js';
21
24
  export * from './scheduler.js';
22
25
  export * from './smartCompose.js';
23
26
  export * from './threads.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/lib/esm/nylas.js CHANGED
@@ -16,6 +16,9 @@ import { Contacts } from './resources/contacts.js';
16
16
  import { Attachments } from './resources/attachments.js';
17
17
  import { Scheduler } from './resources/scheduler.js';
18
18
  import { Notetakers } from './resources/notetakers.js';
19
+ import { Policies } from './resources/policies.js';
20
+ import { Rules } from './resources/rules.js';
21
+ import { AgentLists } from './resources/agentLists.js';
19
22
  /**
20
23
  * The entry point to the Node SDK
21
24
  *
@@ -42,6 +45,9 @@ class Nylas {
42
45
  this.grants = new Grants(this.apiClient);
43
46
  this.messages = new Messages(this.apiClient);
44
47
  this.notetakers = new Notetakers(this.apiClient);
48
+ this.policies = new Policies(this.apiClient);
49
+ this.rules = new Rules(this.apiClient);
50
+ this.lists = new AgentLists(this.apiClient);
45
51
  this.threads = new Threads(this.apiClient);
46
52
  this.webhooks = new Webhooks(this.apiClient);
47
53
  this.folders = new Folders(this.apiClient);