nylas 8.1.1 → 8.2.0

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 (57) hide show
  1. package/lib/cjs/apiClient.js +12 -5
  2. package/lib/cjs/models/domains.js +2 -0
  3. package/lib/cjs/models/index.js +3 -0
  4. package/lib/cjs/models/messages.js +1 -0
  5. package/lib/cjs/models/serviceAccount.js +99 -0
  6. package/lib/cjs/models/workspaces.js +2 -0
  7. package/lib/cjs/nylas.js +4 -0
  8. package/lib/cjs/resources/applications.js +13 -0
  9. package/lib/cjs/resources/attachments.js +26 -4
  10. package/lib/cjs/resources/domains.js +232 -0
  11. package/lib/cjs/resources/messages.js +2 -1
  12. package/lib/cjs/resources/redirectUris.js +2 -2
  13. package/lib/cjs/resources/resource.js +18 -4
  14. package/lib/cjs/resources/threads.js +2 -1
  15. package/lib/cjs/resources/workspaces.js +95 -0
  16. package/lib/cjs/version.js +1 -1
  17. package/lib/esm/apiClient.js +11 -4
  18. package/lib/esm/models/domains.js +1 -0
  19. package/lib/esm/models/index.js +3 -0
  20. package/lib/esm/models/messages.js +1 -0
  21. package/lib/esm/models/serviceAccount.js +93 -0
  22. package/lib/esm/models/workspaces.js +1 -0
  23. package/lib/esm/nylas.js +4 -0
  24. package/lib/esm/resources/applications.js +13 -0
  25. package/lib/esm/resources/attachments.js +26 -4
  26. package/lib/esm/resources/domains.js +228 -0
  27. package/lib/esm/resources/messages.js +2 -1
  28. package/lib/esm/resources/redirectUris.js +2 -2
  29. package/lib/esm/resources/resource.js +18 -4
  30. package/lib/esm/resources/threads.js +2 -1
  31. package/lib/esm/resources/workspaces.js +91 -0
  32. package/lib/esm/version.js +1 -1
  33. package/lib/types/apiClient.d.ts +1 -0
  34. package/lib/types/config.d.ts +6 -0
  35. package/lib/types/models/agentLists.d.ts +5 -0
  36. package/lib/types/models/applicationDetails.d.ts +149 -11
  37. package/lib/types/models/domains.d.ts +177 -0
  38. package/lib/types/models/events.d.ts +5 -0
  39. package/lib/types/models/index.d.ts +3 -0
  40. package/lib/types/models/messages.d.ts +10 -0
  41. package/lib/types/models/policies.d.ts +6 -2
  42. package/lib/types/models/redirectUri.d.ts +15 -4
  43. package/lib/types/models/rules.d.ts +7 -1
  44. package/lib/types/models/serviceAccount.d.ts +46 -0
  45. package/lib/types/models/threads.d.ts +7 -0
  46. package/lib/types/models/workspaces.d.ts +191 -0
  47. package/lib/types/nylas.d.ts +10 -0
  48. package/lib/types/resources/applications.d.ts +14 -1
  49. package/lib/types/resources/attachments.d.ts +17 -4
  50. package/lib/types/resources/domains.d.ts +137 -0
  51. package/lib/types/resources/messages.d.ts +4 -2
  52. package/lib/types/resources/redirectUris.d.ts +2 -2
  53. package/lib/types/resources/resource.d.ts +2 -0
  54. package/lib/types/resources/threads.d.ts +3 -2
  55. package/lib/types/resources/workspaces.d.ts +98 -0
  56. package/lib/types/version.d.ts +1 -1
  57. package/package.json +1 -1
@@ -5,7 +5,7 @@ const error_js_1 = require("./models/error.js");
5
5
  const utils_js_1 = require("./utils.js");
6
6
  const version_js_1 = require("./version.js");
7
7
  const form_data_encoder_1 = require("form-data-encoder");
8
- const stream_1 = require("stream");
8
+ const node_stream_1 = require("node:stream");
9
9
  const change_case_1 = require("change-case");
10
10
  /**
11
11
  * The header key for the debugging flow ID
@@ -66,12 +66,15 @@ class APIClient {
66
66
  ...this.headers,
67
67
  ...overrides?.headers,
68
68
  };
69
- return {
69
+ const defaultHeaders = {
70
70
  Accept: 'application/json',
71
71
  'User-Agent': `Nylas Node SDK v${version_js_1.SDK_VERSION}`,
72
- Authorization: `Bearer ${overrides?.apiKey || this.apiKey}`,
73
72
  ...mergedHeaders,
74
73
  };
74
+ if (!overrides?.skipAuth) {
75
+ defaultHeaders.Authorization = `Bearer ${overrides?.apiKey || this.apiKey}`;
76
+ }
77
+ return defaultHeaders;
75
78
  }
76
79
  async sendRequest(options) {
77
80
  const req = await this.newRequest(options);
@@ -150,7 +153,11 @@ class APIClient {
150
153
  requestOptions.url = this.setRequestUrl(optionParams);
151
154
  requestOptions.headers = this.setRequestHeaders(optionParams);
152
155
  requestOptions.method = optionParams.method;
153
- if (optionParams.body) {
156
+ if (optionParams.serializedBody) {
157
+ requestOptions.body = optionParams.serializedBody;
158
+ requestOptions.headers['Content-Type'] = 'application/json';
159
+ }
160
+ else if (optionParams.body) {
154
161
  requestOptions.body = JSON.stringify((0, utils_js_1.objKeysToSnakeCase)(optionParams.body, ['metadata']) // metadata should remain as is
155
162
  );
156
163
  requestOptions.headers['Content-Type'] = 'application/json';
@@ -164,7 +171,7 @@ class APIClient {
164
171
  // Set the Content-Type header with the boundary from the encoder
165
172
  requestOptions.headers['Content-Type'] = encoder.contentType;
166
173
  // Convert the encoded form data to a readable stream for the request body
167
- requestOptions.body = stream_1.Readable.from(encoder);
174
+ requestOptions.body = node_stream_1.Readable.from(encoder);
168
175
  // Node.js native fetch requires duplex: 'half' when sending a streaming body
169
176
  requestOptions.duplex = 'half';
170
177
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,6 +24,7 @@ __exportStar(require("./calendars.js"), exports);
24
24
  __exportStar(require("./connectors.js"), exports);
25
25
  __exportStar(require("./contacts.js"), exports);
26
26
  __exportStar(require("./credentials.js"), exports);
27
+ __exportStar(require("./domains.js"), exports);
27
28
  __exportStar(require("./drafts.js"), exports);
28
29
  __exportStar(require("./error.js"), exports);
29
30
  __exportStar(require("./events.js"), exports);
@@ -38,6 +39,8 @@ __exportStar(require("./redirectUri.js"), exports);
38
39
  __exportStar(require("./response.js"), exports);
39
40
  __exportStar(require("./rules.js"), exports);
40
41
  __exportStar(require("./scheduler.js"), exports);
42
+ __exportStar(require("./serviceAccount.js"), exports);
41
43
  __exportStar(require("./smartCompose.js"), exports);
42
44
  __exportStar(require("./threads.js"), exports);
43
45
  __exportStar(require("./webhooks.js"), exports);
46
+ __exportStar(require("./workspaces.js"), exports);
@@ -7,6 +7,7 @@ exports.MessageFields = void 0;
7
7
  var MessageFields;
8
8
  (function (MessageFields) {
9
9
  MessageFields["STANDARD"] = "standard";
10
+ MessageFields["INCLUDE_BASIC_HEADERS"] = "include_basic_headers";
10
11
  MessageFields["INCLUDE_HEADERS"] = "include_headers";
11
12
  MessageFields["INCLUDE_TRACKING_OPTIONS"] = "include_tracking_options";
12
13
  MessageFields["RAW_MIME"] = "raw_mime";
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceAccountSigner = void 0;
4
+ exports.generateNonce = generateNonce;
5
+ exports.canonicalJson = canonicalJson;
6
+ const node_crypto_1 = require("node:crypto");
7
+ const NONCE_LENGTH = 20;
8
+ const NONCE_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
9
+ const SIGNED_BODY_METHODS = new Set(['post', 'put', 'patch']);
10
+ function normalizePrivateKey(privateKeyPem) {
11
+ if (Buffer.isBuffer(privateKeyPem) || privateKeyPem.includes('BEGIN')) {
12
+ return privateKeyPem;
13
+ }
14
+ return Buffer.from(privateKeyPem, 'base64').toString('utf8');
15
+ }
16
+ function loadRsaPrivateKey(privateKeyPem) {
17
+ const privateKey = (0, node_crypto_1.createPrivateKey)(normalizePrivateKey(privateKeyPem));
18
+ if (privateKey.asymmetricKeyType !== 'rsa') {
19
+ throw new Error('Service account private key must be RSA.');
20
+ }
21
+ return privateKey;
22
+ }
23
+ function generateNonce(length = NONCE_LENGTH) {
24
+ if (!Number.isInteger(length) || length <= 0) {
25
+ throw new Error('Nonce length must be a positive integer.');
26
+ }
27
+ let nonce = '';
28
+ for (let i = 0; i < length; i++) {
29
+ nonce += NONCE_ALPHABET[(0, node_crypto_1.randomInt)(NONCE_ALPHABET.length)];
30
+ }
31
+ return nonce;
32
+ }
33
+ function canonicalValue(value) {
34
+ if (value === undefined || typeof value === 'function') {
35
+ return 'null';
36
+ }
37
+ if (Array.isArray(value)) {
38
+ return `[${value.map(canonicalValue).join(',')}]`;
39
+ }
40
+ if (typeof value === 'number' && !Number.isFinite(value)) {
41
+ throw new Error('Service account signing only supports finite numbers.');
42
+ }
43
+ if (value && typeof value === 'object') {
44
+ const data = value;
45
+ return `{${Object.keys(data)
46
+ .filter((key) => {
47
+ const item = data[key];
48
+ return item !== undefined && typeof item !== 'function';
49
+ })
50
+ .sort()
51
+ .map((key) => `${JSON.stringify(key)}:${canonicalValue(data[key])}`)
52
+ .join(',')}}`;
53
+ }
54
+ return JSON.stringify(value);
55
+ }
56
+ /**
57
+ * Serialize JSON deterministically with sorted object keys and no extra
58
+ * whitespace, matching Nylas Service Account signing requirements.
59
+ */
60
+ function canonicalJson(data) {
61
+ return canonicalValue(data);
62
+ }
63
+ /**
64
+ * Generates Nylas Service Account request signing headers.
65
+ */
66
+ class ServiceAccountSigner {
67
+ constructor({ privateKeyPem, privateKeyId }) {
68
+ this.privateKey = loadRsaPrivateKey(privateKeyPem);
69
+ this.privateKeyId = privateKeyId;
70
+ }
71
+ buildHeaders({ method, path, body, timestamp = Math.floor(Date.now() / 1000), nonce = generateNonce(), }) {
72
+ const methodLower = method.toLowerCase();
73
+ const serializedBody = body && SIGNED_BODY_METHODS.has(methodLower)
74
+ ? canonicalJson(body)
75
+ : undefined;
76
+ const signingEnvelope = {
77
+ method: methodLower,
78
+ nonce,
79
+ path,
80
+ timestamp,
81
+ };
82
+ if (serializedBody) {
83
+ signingEnvelope.payload = serializedBody;
84
+ }
85
+ const signature = (0, node_crypto_1.createSign)('RSA-SHA256')
86
+ .update(canonicalJson(signingEnvelope))
87
+ .sign(this.privateKey, 'base64');
88
+ return {
89
+ headers: {
90
+ 'X-Nylas-Kid': this.privateKeyId,
91
+ 'X-Nylas-Nonce': nonce,
92
+ 'X-Nylas-Timestamp': String(timestamp),
93
+ 'X-Nylas-Signature': signature,
94
+ },
95
+ serializedBody,
96
+ };
97
+ }
98
+ }
99
+ exports.ServiceAccountSigner = ServiceAccountSigner;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/cjs/nylas.js CHANGED
@@ -35,8 +35,10 @@ 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 domains_js_1 = require("./resources/domains.js");
38
39
  const policies_js_1 = require("./resources/policies.js");
39
40
  const rules_js_1 = require("./resources/rules.js");
41
+ const workspaces_js_1 = require("./resources/workspaces.js");
40
42
  const agentLists_js_1 = require("./resources/agentLists.js");
41
43
  /**
42
44
  * The entry point to the Node SDK
@@ -64,8 +66,10 @@ class Nylas {
64
66
  this.grants = new grants_js_1.Grants(this.apiClient);
65
67
  this.messages = new messages_js_1.Messages(this.apiClient);
66
68
  this.notetakers = new notetakers_js_1.Notetakers(this.apiClient);
69
+ this.domains = new domains_js_1.Domains(this.apiClient);
67
70
  this.policies = new policies_js_1.Policies(this.apiClient);
68
71
  this.rules = new rules_js_1.Rules(this.apiClient);
72
+ this.workspaces = new workspaces_js_1.Workspaces(this.apiClient);
69
73
  this.lists = new agentLists_js_1.AgentLists(this.apiClient);
70
74
  this.threads = new threads_js_1.Threads(this.apiClient);
71
75
  this.webhooks = new webhooks_js_1.Webhooks(this.apiClient);
@@ -27,5 +27,18 @@ class Applications extends resource_js_1.Resource {
27
27
  overrides,
28
28
  });
29
29
  }
30
+ /**
31
+ * Update application details.
32
+ *
33
+ * Each supplied nested object is a full replace, not a deep merge.
34
+ * @returns The updated application details
35
+ */
36
+ update({ requestBody, overrides, }) {
37
+ return super._updatePatch({
38
+ path: (0, utils_js_1.makePathParams)('/v3/applications', {}),
39
+ requestBody,
40
+ overrides,
41
+ });
42
+ }
30
43
  }
31
44
  exports.Applications = Applications;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Attachments = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
5
  const resource_js_1 = require("./resource.js");
6
+ const node_stream_1 = require("node:stream");
6
7
  /**
7
8
  * Nylas Attachments API
8
9
  *
@@ -23,15 +24,15 @@ class Attachments extends resource_js_1.Resource {
23
24
  /**
24
25
  * Download the attachment data
25
26
  *
26
- * This method returns a NodeJS.ReadableStream which can be used to stream the attachment data.
27
+ * This method returns a Web ReadableStream which can be used to stream the attachment data.
27
28
  * This is particularly useful for handling large attachments efficiently, as it avoids loading
28
- * the entire file into memory. The stream can be piped to a file stream or used in any other way
29
- * that Node.js streams are typically used.
29
+ * the entire file into memory. In Node.js, convert it with Readable.fromWeb() when a
30
+ * NodeJS.ReadableStream is required.
30
31
  *
31
32
  * @param identifier Grant ID or email account to query
32
33
  * @param attachmentId The id of the attachment to download.
33
34
  * @param queryParams The query parameters to include in the request
34
- * @returns {NodeJS.ReadableStream} The ReadableStream containing the file data.
35
+ * @returns {ReadableStream<Uint8Array>} The ReadableStream containing the file data.
35
36
  */
36
37
  download({ identifier, attachmentId, queryParams, overrides, }) {
37
38
  return this._getStream({
@@ -40,6 +41,27 @@ class Attachments extends resource_js_1.Resource {
40
41
  overrides,
41
42
  });
42
43
  }
44
+ /**
45
+ * Download the attachment data as a Node.js readable stream.
46
+ *
47
+ * This is a Node.js convenience wrapper around {@link Attachments.download}. Use
48
+ * {@link Attachments.download} directly in Fetch-native runtimes, such as Cloudflare Workers,
49
+ * where Web ReadableStreams are the standard stream primitive.
50
+ *
51
+ * @param identifier Grant ID or email account to query
52
+ * @param attachmentId The id of the attachment to download.
53
+ * @param queryParams The query parameters to include in the request
54
+ * @returns {NodeJS.ReadableStream} The Node.js readable stream containing the file data.
55
+ */
56
+ async downloadNodeStream({ identifier, attachmentId, queryParams, overrides, }) {
57
+ const stream = await this.download({
58
+ identifier,
59
+ attachmentId,
60
+ queryParams,
61
+ overrides,
62
+ });
63
+ return node_stream_1.Readable.fromWeb(stream);
64
+ }
43
65
  /**
44
66
  * Download the attachment as a byte array
45
67
  * @param identifier Grant ID or email account to query
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Domains = void 0;
4
+ const serviceAccount_js_1 = require("../models/serviceAccount.js");
5
+ const utils_js_1 = require("../utils.js");
6
+ const resource_js_1 = require("./resource.js");
7
+ /**
8
+ * Nylas Manage Domains API
9
+ *
10
+ * Register email domains and run their DNS verification flow
11
+ * (ownership / MX / SPF / DKIM / feedback) for Transactional Send and Nylas Inbound.
12
+ */
13
+ class Domains extends resource_js_1.Resource {
14
+ assertServiceAccountSigningHeaders(overrides) {
15
+ const headers = {
16
+ ...(this.apiClient.headers ?? {}),
17
+ ...(overrides?.headers ?? {}),
18
+ };
19
+ const normalizedHeaders = Object.fromEntries(Object.entries(headers).map(([header, value]) => [
20
+ header.toLowerCase(),
21
+ value,
22
+ ]));
23
+ const missingHeader = Domains.REQUIRED_SERVICE_ACCOUNT_HEADERS.some((header) => !normalizedHeaders[header]?.trim());
24
+ if (missingHeader) {
25
+ throw new Error('Manage Domains API requests require Nylas Service Account signing headers.');
26
+ }
27
+ }
28
+ buildSignedRequest({ method, path, requestBody, signer, overrides, }) {
29
+ if (!signer) {
30
+ this.assertServiceAccountSigningHeaders(overrides);
31
+ const body = requestBody ? (0, utils_js_1.objKeysToSnakeCase)(requestBody) : undefined;
32
+ return {
33
+ overrides: { ...overrides, skipAuth: true },
34
+ serializedBody: body ? (0, serviceAccount_js_1.canonicalJson)(body) : undefined,
35
+ };
36
+ }
37
+ const body = requestBody ? (0, utils_js_1.objKeysToSnakeCase)(requestBody) : undefined;
38
+ const signedRequest = signer.buildHeaders({ method, path, body });
39
+ const signedOverrides = {
40
+ ...overrides,
41
+ skipAuth: true,
42
+ headers: {
43
+ ...(overrides?.headers ?? {}),
44
+ ...signedRequest.headers,
45
+ },
46
+ };
47
+ this.assertServiceAccountSigningHeaders(signedOverrides);
48
+ return {
49
+ overrides: signedOverrides,
50
+ serializedBody: signedRequest.serializedBody,
51
+ };
52
+ }
53
+ /**
54
+ * Return all domains for the caller's organization.
55
+ *
56
+ * Requires Nylas Service Account request signing headers:
57
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
58
+ * @return The list of domains.
59
+ */
60
+ list({ queryParams, signer, overrides, } = {}) {
61
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains', {});
62
+ if (signer) {
63
+ return super._list({
64
+ queryParams,
65
+ path,
66
+ getOverrides: () => this.buildSignedRequest({
67
+ method: 'GET',
68
+ path,
69
+ signer,
70
+ overrides,
71
+ }).overrides,
72
+ });
73
+ }
74
+ const signed = this.buildSignedRequest({
75
+ method: 'GET',
76
+ path,
77
+ overrides,
78
+ });
79
+ return super._list({
80
+ queryParams,
81
+ path,
82
+ overrides: signed.overrides,
83
+ });
84
+ }
85
+ /**
86
+ * Return a domain.
87
+ *
88
+ * Requires Nylas Service Account request signing headers:
89
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
90
+ * @return The domain.
91
+ */
92
+ find({ domainId, signer, overrides, }) {
93
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains/{domainId}', { domainId });
94
+ const signed = this.buildSignedRequest({
95
+ method: 'GET',
96
+ path,
97
+ signer,
98
+ overrides,
99
+ });
100
+ return super._find({
101
+ path,
102
+ overrides: signed.overrides,
103
+ });
104
+ }
105
+ /**
106
+ * Create a domain.
107
+ *
108
+ * Requires Nylas Service Account request signing headers:
109
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
110
+ * @return The created domain.
111
+ */
112
+ create({ requestBody, signer, overrides, }) {
113
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains', {});
114
+ const signed = this.buildSignedRequest({
115
+ method: 'POST',
116
+ path,
117
+ requestBody,
118
+ signer,
119
+ overrides,
120
+ });
121
+ return super._create({
122
+ path,
123
+ requestBody,
124
+ serializedBody: signed.serializedBody,
125
+ overrides: signed.overrides,
126
+ });
127
+ }
128
+ /**
129
+ * Update a domain.
130
+ *
131
+ * Note: the response echoes the sparse cleared input (typically just `name`
132
+ * and `updatedAt`), not a full domain. Re-fetch the domain with `find` if you
133
+ * need the complete record.
134
+ *
135
+ * Requires Nylas Service Account request signing headers:
136
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
137
+ * @return The updated domain fields.
138
+ */
139
+ update({ domainId, requestBody, signer, overrides, }) {
140
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains/{domainId}', { domainId });
141
+ const signed = this.buildSignedRequest({
142
+ method: 'PUT',
143
+ path,
144
+ requestBody,
145
+ signer,
146
+ overrides,
147
+ });
148
+ return super._update({
149
+ path,
150
+ requestBody,
151
+ serializedBody: signed.serializedBody,
152
+ overrides: signed.overrides,
153
+ });
154
+ }
155
+ /**
156
+ * Delete a domain.
157
+ *
158
+ * Requires Nylas Service Account request signing headers:
159
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
160
+ * @return The deletion response.
161
+ */
162
+ destroy({ domainId, signer, overrides, }) {
163
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains/{domainId}', { domainId });
164
+ const signed = this.buildSignedRequest({
165
+ method: 'DELETE',
166
+ path,
167
+ signer,
168
+ overrides,
169
+ });
170
+ return super._destroy({
171
+ path,
172
+ overrides: signed.overrides,
173
+ });
174
+ }
175
+ /**
176
+ * Get the DNS record a customer must configure for a given verification type.
177
+ *
178
+ * Requires Nylas Service Account request signing headers:
179
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
180
+ * @return The verification result, including the DNS record to configure.
181
+ */
182
+ info({ domainId, requestBody, signer, overrides, }) {
183
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains/{domainId}/info', {
184
+ domainId,
185
+ });
186
+ const signed = this.buildSignedRequest({
187
+ method: 'POST',
188
+ path,
189
+ requestBody,
190
+ signer,
191
+ overrides,
192
+ });
193
+ return super._create({
194
+ path,
195
+ requestBody,
196
+ serializedBody: signed.serializedBody,
197
+ overrides: signed.overrides,
198
+ });
199
+ }
200
+ /**
201
+ * Trigger a DNS verification check for a given verification type.
202
+ *
203
+ * Requires Nylas Service Account request signing headers:
204
+ * X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
205
+ * @return The verification result, including the current status.
206
+ */
207
+ verify({ domainId, requestBody, signer, overrides, }) {
208
+ const path = (0, utils_js_1.makePathParams)('/v3/admin/domains/{domainId}/verify', {
209
+ domainId,
210
+ });
211
+ const signed = this.buildSignedRequest({
212
+ method: 'POST',
213
+ path,
214
+ requestBody,
215
+ signer,
216
+ overrides,
217
+ });
218
+ return super._create({
219
+ path,
220
+ requestBody,
221
+ serializedBody: signed.serializedBody,
222
+ overrides: signed.overrides,
223
+ });
224
+ }
225
+ }
226
+ exports.Domains = Domains;
227
+ Domains.REQUIRED_SERVICE_ACCOUNT_HEADERS = [
228
+ 'x-nylas-kid',
229
+ 'x-nylas-timestamp',
230
+ 'x-nylas-nonce',
231
+ 'x-nylas-signature',
232
+ ];
@@ -81,13 +81,14 @@ class Messages extends resource_js_1.Resource {
81
81
  * Send an email
82
82
  * @return The sent message
83
83
  */
84
- async send({ identifier, requestBody, overrides, }) {
84
+ async send({ identifier, requestBody, queryParams, overrides, }) {
85
85
  const path = (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/messages/send', {
86
86
  identifier,
87
87
  });
88
88
  const requestOptions = {
89
89
  method: 'POST',
90
90
  path,
91
+ queryParams,
91
92
  overrides,
92
93
  };
93
94
  // Use form data if the total payload size (body + attachments) is greater than 3mb
@@ -47,7 +47,7 @@ class RedirectUris extends resource_js_1.Resource {
47
47
  * @return The updated Redirect URI
48
48
  */
49
49
  update({ redirectUriId, requestBody, overrides, }) {
50
- return super._update({
50
+ return super._updatePatch({
51
51
  overrides,
52
52
  path: (0, utils_js_1.makePathParams)('/v3/applications/redirect-uris/{redirectUriId}', {
53
53
  redirectUriId,
@@ -57,7 +57,7 @@ class RedirectUris extends resource_js_1.Resource {
57
57
  }
58
58
  /**
59
59
  * Delete a Redirect URI
60
- * @return The deleted Redirect URI
60
+ * @return The deletion response
61
61
  */
62
62
  destroy({ redirectUriId, overrides, }) {
63
63
  return super._destroy({
@@ -13,13 +13,26 @@ class Resource {
13
13
  constructor(apiClient) {
14
14
  this.apiClient = apiClient;
15
15
  }
16
- async fetchList({ queryParams, path, overrides, }) {
16
+ async fetchList({ queryParams, path, overrides, getOverrides, }) {
17
17
  const res = await this.apiClient.request({
18
18
  method: 'GET',
19
19
  path,
20
20
  queryParams,
21
- overrides,
21
+ overrides: getOverrides ? getOverrides() : overrides,
22
22
  });
23
+ // Some list endpoints return a nested envelope after key conversion:
24
+ // { data: { items: T[], nextCursor? } }.
25
+ // This guard remaps that nested shape back to the flat shape the list machinery
26
+ // and public SDK surface expect.
27
+ const data = res.data;
28
+ if (data != null &&
29
+ !Array.isArray(data) &&
30
+ typeof data === 'object' &&
31
+ Array.isArray(data.items)) {
32
+ const nested = data;
33
+ res.data = nested.items;
34
+ res.nextCursor = nested.nextCursor ?? res.nextCursor;
35
+ }
23
36
  if (queryParams?.limit) {
24
37
  let entriesRemaining = queryParams.limit;
25
38
  while (res.data.length != queryParams.limit) {
@@ -35,7 +48,7 @@ class Resource {
35
48
  limit: entriesRemaining,
36
49
  pageToken: res.nextCursor,
37
50
  },
38
- overrides,
51
+ overrides: getOverrides ? getOverrides() : overrides,
39
52
  });
40
53
  res.data = res.data.concat(nextRes.data);
41
54
  res.requestId = nextRes.requestId;
@@ -81,12 +94,13 @@ class Resource {
81
94
  overrides,
82
95
  });
83
96
  }
84
- payloadRequest(method, { path, queryParams, requestBody, overrides }) {
97
+ payloadRequest(method, { path, queryParams, requestBody, serializedBody, overrides, }) {
85
98
  return this.apiClient.request({
86
99
  method,
87
100
  path,
88
101
  queryParams,
89
102
  body: requestBody,
103
+ serializedBody,
90
104
  overrides,
91
105
  });
92
106
  }
@@ -34,13 +34,14 @@ class Threads extends resource_js_1.Resource {
34
34
  * Return a Thread
35
35
  * @return The thread
36
36
  */
37
- find({ identifier, threadId, overrides, }) {
37
+ find({ identifier, threadId, overrides, queryParams, }) {
38
38
  return super._find({
39
39
  path: (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/threads/{threadId}', {
40
40
  identifier,
41
41
  threadId,
42
42
  }),
43
43
  overrides,
44
+ queryParams,
44
45
  });
45
46
  }
46
47
  /**