nylas 8.1.2 → 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 (48) hide show
  1. package/lib/cjs/apiClient.js +10 -3
  2. package/lib/cjs/models/domains.js +2 -0
  3. package/lib/cjs/models/index.js +3 -0
  4. package/lib/cjs/models/serviceAccount.js +99 -0
  5. package/lib/cjs/models/workspaces.js +2 -0
  6. package/lib/cjs/nylas.js +4 -0
  7. package/lib/cjs/resources/applications.js +13 -0
  8. package/lib/cjs/resources/domains.js +232 -0
  9. package/lib/cjs/resources/redirectUris.js +2 -2
  10. package/lib/cjs/resources/resource.js +18 -4
  11. package/lib/cjs/resources/threads.js +2 -1
  12. package/lib/cjs/resources/workspaces.js +95 -0
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/esm/apiClient.js +10 -3
  15. package/lib/esm/models/domains.js +1 -0
  16. package/lib/esm/models/index.js +3 -0
  17. package/lib/esm/models/serviceAccount.js +93 -0
  18. package/lib/esm/models/workspaces.js +1 -0
  19. package/lib/esm/nylas.js +4 -0
  20. package/lib/esm/resources/applications.js +13 -0
  21. package/lib/esm/resources/domains.js +228 -0
  22. package/lib/esm/resources/redirectUris.js +2 -2
  23. package/lib/esm/resources/resource.js +18 -4
  24. package/lib/esm/resources/threads.js +2 -1
  25. package/lib/esm/resources/workspaces.js +91 -0
  26. package/lib/esm/version.js +1 -1
  27. package/lib/types/apiClient.d.ts +1 -0
  28. package/lib/types/config.d.ts +6 -0
  29. package/lib/types/models/agentLists.d.ts +5 -0
  30. package/lib/types/models/applicationDetails.d.ts +149 -11
  31. package/lib/types/models/domains.d.ts +177 -0
  32. package/lib/types/models/events.d.ts +5 -0
  33. package/lib/types/models/index.d.ts +3 -0
  34. package/lib/types/models/policies.d.ts +6 -2
  35. package/lib/types/models/redirectUri.d.ts +15 -4
  36. package/lib/types/models/rules.d.ts +7 -1
  37. package/lib/types/models/serviceAccount.d.ts +46 -0
  38. package/lib/types/models/threads.d.ts +7 -0
  39. package/lib/types/models/workspaces.d.ts +191 -0
  40. package/lib/types/nylas.d.ts +10 -0
  41. package/lib/types/resources/applications.d.ts +14 -1
  42. package/lib/types/resources/domains.d.ts +137 -0
  43. package/lib/types/resources/redirectUris.d.ts +2 -2
  44. package/lib/types/resources/resource.d.ts +2 -0
  45. package/lib/types/resources/threads.d.ts +3 -2
  46. package/lib/types/resources/workspaces.d.ts +98 -0
  47. package/lib/types/version.d.ts +1 -1
  48. package/package.json +1 -1
@@ -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';
@@ -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);
@@ -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;
@@ -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
+ ];
@@ -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
  /**
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Workspaces = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const resource_js_1 = require("./resource.js");
6
+ /**
7
+ * Nylas Workspaces API
8
+ *
9
+ * Workspaces group grants in a Nylas application by email domain. Grants can be
10
+ * auto-grouped by matching email domain or manually assigned and removed.
11
+ */
12
+ class Workspaces extends resource_js_1.Resource {
13
+ /**
14
+ * Return all workspaces for the application.
15
+ *
16
+ * The list endpoint is not paginated and returns every workspace as a flat array.
17
+ * @return The list of workspaces.
18
+ */
19
+ list({ queryParams, overrides, } = {}) {
20
+ return super._list({
21
+ queryParams,
22
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces', {}),
23
+ overrides,
24
+ });
25
+ }
26
+ /**
27
+ * Return a workspace.
28
+ * @return The workspace.
29
+ */
30
+ find({ workspaceId, overrides, }) {
31
+ return super._find({
32
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces/{workspaceId}', { workspaceId }),
33
+ overrides,
34
+ });
35
+ }
36
+ /**
37
+ * Create a workspace.
38
+ * @return The created workspace.
39
+ */
40
+ create({ requestBody, overrides, }) {
41
+ return super._create({
42
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces', {}),
43
+ requestBody,
44
+ overrides,
45
+ });
46
+ }
47
+ /**
48
+ * Update a workspace.
49
+ *
50
+ * Issued as PATCH; the workspace must be addressed by its UUID.
51
+ * @return The updated workspace.
52
+ */
53
+ update({ workspaceId, requestBody, overrides, }) {
54
+ return super._updatePatch({
55
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces/{workspaceId}', { workspaceId }),
56
+ requestBody,
57
+ overrides,
58
+ });
59
+ }
60
+ /**
61
+ * Delete a workspace.
62
+ * @return The deletion response.
63
+ */
64
+ destroy({ workspaceId, overrides, }) {
65
+ return super._destroy({
66
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces/{workspaceId}', { workspaceId }),
67
+ overrides,
68
+ });
69
+ }
70
+ /**
71
+ * Start a background job that auto-groups grants into workspaces by email domain.
72
+ * @return The auto-group job response.
73
+ */
74
+ autoGroup({ requestBody, overrides, } = {}) {
75
+ return super._create({
76
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces/auto-group', {}),
77
+ requestBody: requestBody ?? {},
78
+ overrides,
79
+ });
80
+ }
81
+ /**
82
+ * Manually assign grants to and/or remove grants from a workspace.
83
+ * @return The assignment response.
84
+ */
85
+ manualAssign({ workspaceId, requestBody, overrides, }) {
86
+ return super._create({
87
+ path: (0, utils_js_1.makePathParams)('/v3/workspaces/{workspaceId}/manual-assign', {
88
+ workspaceId,
89
+ }),
90
+ requestBody,
91
+ overrides,
92
+ });
93
+ }
94
+ }
95
+ exports.Workspaces = Workspaces;
@@ -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.1.2';
5
+ exports.SDK_VERSION = '8.2.0';
@@ -63,12 +63,15 @@ export default class APIClient {
63
63
  ...this.headers,
64
64
  ...overrides?.headers,
65
65
  };
66
- return {
66
+ const defaultHeaders = {
67
67
  Accept: 'application/json',
68
68
  'User-Agent': `Nylas Node SDK v${SDK_VERSION}`,
69
- Authorization: `Bearer ${overrides?.apiKey || this.apiKey}`,
70
69
  ...mergedHeaders,
71
70
  };
71
+ if (!overrides?.skipAuth) {
72
+ defaultHeaders.Authorization = `Bearer ${overrides?.apiKey || this.apiKey}`;
73
+ }
74
+ return defaultHeaders;
72
75
  }
73
76
  async sendRequest(options) {
74
77
  const req = await this.newRequest(options);
@@ -147,7 +150,11 @@ export default class APIClient {
147
150
  requestOptions.url = this.setRequestUrl(optionParams);
148
151
  requestOptions.headers = this.setRequestHeaders(optionParams);
149
152
  requestOptions.method = optionParams.method;
150
- if (optionParams.body) {
153
+ if (optionParams.serializedBody) {
154
+ requestOptions.body = optionParams.serializedBody;
155
+ requestOptions.headers['Content-Type'] = 'application/json';
156
+ }
157
+ else if (optionParams.body) {
151
158
  requestOptions.body = JSON.stringify(objKeysToSnakeCase(optionParams.body, ['metadata']) // metadata should remain as is
152
159
  );
153
160
  requestOptions.headers['Content-Type'] = 'application/json';
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,7 @@ export * from './calendars.js';
8
8
  export * from './connectors.js';
9
9
  export * from './contacts.js';
10
10
  export * from './credentials.js';
11
+ export * from './domains.js';
11
12
  export * from './drafts.js';
12
13
  export * from './error.js';
13
14
  export * from './events.js';
@@ -22,6 +23,8 @@ export * from './redirectUri.js';
22
23
  export * from './response.js';
23
24
  export * from './rules.js';
24
25
  export * from './scheduler.js';
26
+ export * from './serviceAccount.js';
25
27
  export * from './smartCompose.js';
26
28
  export * from './threads.js';
27
29
  export * from './webhooks.js';
30
+ export * from './workspaces.js';