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.
- package/lib/cjs/apiClient.js +10 -3
- package/lib/cjs/models/domains.js +2 -0
- package/lib/cjs/models/index.js +3 -0
- package/lib/cjs/models/serviceAccount.js +99 -0
- package/lib/cjs/models/workspaces.js +2 -0
- package/lib/cjs/nylas.js +4 -0
- package/lib/cjs/resources/applications.js +13 -0
- package/lib/cjs/resources/domains.js +232 -0
- package/lib/cjs/resources/redirectUris.js +2 -2
- package/lib/cjs/resources/resource.js +18 -4
- package/lib/cjs/resources/threads.js +2 -1
- package/lib/cjs/resources/workspaces.js +95 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/apiClient.js +10 -3
- package/lib/esm/models/domains.js +1 -0
- package/lib/esm/models/index.js +3 -0
- package/lib/esm/models/serviceAccount.js +93 -0
- package/lib/esm/models/workspaces.js +1 -0
- package/lib/esm/nylas.js +4 -0
- package/lib/esm/resources/applications.js +13 -0
- package/lib/esm/resources/domains.js +228 -0
- package/lib/esm/resources/redirectUris.js +2 -2
- package/lib/esm/resources/resource.js +18 -4
- package/lib/esm/resources/threads.js +2 -1
- package/lib/esm/resources/workspaces.js +91 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/apiClient.d.ts +1 -0
- package/lib/types/config.d.ts +6 -0
- package/lib/types/models/agentLists.d.ts +5 -0
- package/lib/types/models/applicationDetails.d.ts +149 -11
- package/lib/types/models/domains.d.ts +177 -0
- package/lib/types/models/events.d.ts +5 -0
- package/lib/types/models/index.d.ts +3 -0
- package/lib/types/models/policies.d.ts +6 -2
- package/lib/types/models/redirectUri.d.ts +15 -4
- package/lib/types/models/rules.d.ts +7 -1
- package/lib/types/models/serviceAccount.d.ts +46 -0
- package/lib/types/models/threads.d.ts +7 -0
- package/lib/types/models/workspaces.d.ts +191 -0
- package/lib/types/nylas.d.ts +10 -0
- package/lib/types/resources/applications.d.ts +14 -1
- package/lib/types/resources/domains.d.ts +137 -0
- package/lib/types/resources/redirectUris.d.ts +2 -2
- package/lib/types/resources/resource.d.ts +2 -0
- package/lib/types/resources/threads.d.ts +3 -2
- package/lib/types/resources/workspaces.d.ts +98 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { createPrivateKey, createSign, randomInt, } from 'node:crypto';
|
|
2
|
+
const NONCE_LENGTH = 20;
|
|
3
|
+
const NONCE_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
4
|
+
const SIGNED_BODY_METHODS = new Set(['post', 'put', 'patch']);
|
|
5
|
+
function normalizePrivateKey(privateKeyPem) {
|
|
6
|
+
if (Buffer.isBuffer(privateKeyPem) || privateKeyPem.includes('BEGIN')) {
|
|
7
|
+
return privateKeyPem;
|
|
8
|
+
}
|
|
9
|
+
return Buffer.from(privateKeyPem, 'base64').toString('utf8');
|
|
10
|
+
}
|
|
11
|
+
function loadRsaPrivateKey(privateKeyPem) {
|
|
12
|
+
const privateKey = createPrivateKey(normalizePrivateKey(privateKeyPem));
|
|
13
|
+
if (privateKey.asymmetricKeyType !== 'rsa') {
|
|
14
|
+
throw new Error('Service account private key must be RSA.');
|
|
15
|
+
}
|
|
16
|
+
return privateKey;
|
|
17
|
+
}
|
|
18
|
+
export function generateNonce(length = NONCE_LENGTH) {
|
|
19
|
+
if (!Number.isInteger(length) || length <= 0) {
|
|
20
|
+
throw new Error('Nonce length must be a positive integer.');
|
|
21
|
+
}
|
|
22
|
+
let nonce = '';
|
|
23
|
+
for (let i = 0; i < length; i++) {
|
|
24
|
+
nonce += NONCE_ALPHABET[randomInt(NONCE_ALPHABET.length)];
|
|
25
|
+
}
|
|
26
|
+
return nonce;
|
|
27
|
+
}
|
|
28
|
+
function canonicalValue(value) {
|
|
29
|
+
if (value === undefined || typeof value === 'function') {
|
|
30
|
+
return 'null';
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
return `[${value.map(canonicalValue).join(',')}]`;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === 'number' && !Number.isFinite(value)) {
|
|
36
|
+
throw new Error('Service account signing only supports finite numbers.');
|
|
37
|
+
}
|
|
38
|
+
if (value && typeof value === 'object') {
|
|
39
|
+
const data = value;
|
|
40
|
+
return `{${Object.keys(data)
|
|
41
|
+
.filter((key) => {
|
|
42
|
+
const item = data[key];
|
|
43
|
+
return item !== undefined && typeof item !== 'function';
|
|
44
|
+
})
|
|
45
|
+
.sort()
|
|
46
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalValue(data[key])}`)
|
|
47
|
+
.join(',')}}`;
|
|
48
|
+
}
|
|
49
|
+
return JSON.stringify(value);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Serialize JSON deterministically with sorted object keys and no extra
|
|
53
|
+
* whitespace, matching Nylas Service Account signing requirements.
|
|
54
|
+
*/
|
|
55
|
+
export function canonicalJson(data) {
|
|
56
|
+
return canonicalValue(data);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generates Nylas Service Account request signing headers.
|
|
60
|
+
*/
|
|
61
|
+
export class ServiceAccountSigner {
|
|
62
|
+
constructor({ privateKeyPem, privateKeyId }) {
|
|
63
|
+
this.privateKey = loadRsaPrivateKey(privateKeyPem);
|
|
64
|
+
this.privateKeyId = privateKeyId;
|
|
65
|
+
}
|
|
66
|
+
buildHeaders({ method, path, body, timestamp = Math.floor(Date.now() / 1000), nonce = generateNonce(), }) {
|
|
67
|
+
const methodLower = method.toLowerCase();
|
|
68
|
+
const serializedBody = body && SIGNED_BODY_METHODS.has(methodLower)
|
|
69
|
+
? canonicalJson(body)
|
|
70
|
+
: undefined;
|
|
71
|
+
const signingEnvelope = {
|
|
72
|
+
method: methodLower,
|
|
73
|
+
nonce,
|
|
74
|
+
path,
|
|
75
|
+
timestamp,
|
|
76
|
+
};
|
|
77
|
+
if (serializedBody) {
|
|
78
|
+
signingEnvelope.payload = serializedBody;
|
|
79
|
+
}
|
|
80
|
+
const signature = createSign('RSA-SHA256')
|
|
81
|
+
.update(canonicalJson(signingEnvelope))
|
|
82
|
+
.sign(this.privateKey, 'base64');
|
|
83
|
+
return {
|
|
84
|
+
headers: {
|
|
85
|
+
'X-Nylas-Kid': this.privateKeyId,
|
|
86
|
+
'X-Nylas-Nonce': nonce,
|
|
87
|
+
'X-Nylas-Timestamp': String(timestamp),
|
|
88
|
+
'X-Nylas-Signature': signature,
|
|
89
|
+
},
|
|
90
|
+
serializedBody,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/nylas.js
CHANGED
|
@@ -16,8 +16,10 @@ 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 { Domains } from './resources/domains.js';
|
|
19
20
|
import { Policies } from './resources/policies.js';
|
|
20
21
|
import { Rules } from './resources/rules.js';
|
|
22
|
+
import { Workspaces } from './resources/workspaces.js';
|
|
21
23
|
import { AgentLists } from './resources/agentLists.js';
|
|
22
24
|
/**
|
|
23
25
|
* The entry point to the Node SDK
|
|
@@ -45,8 +47,10 @@ class Nylas {
|
|
|
45
47
|
this.grants = new Grants(this.apiClient);
|
|
46
48
|
this.messages = new Messages(this.apiClient);
|
|
47
49
|
this.notetakers = new Notetakers(this.apiClient);
|
|
50
|
+
this.domains = new Domains(this.apiClient);
|
|
48
51
|
this.policies = new Policies(this.apiClient);
|
|
49
52
|
this.rules = new Rules(this.apiClient);
|
|
53
|
+
this.workspaces = new Workspaces(this.apiClient);
|
|
50
54
|
this.lists = new AgentLists(this.apiClient);
|
|
51
55
|
this.threads = new Threads(this.apiClient);
|
|
52
56
|
this.webhooks = new Webhooks(this.apiClient);
|
|
@@ -24,4 +24,17 @@ export class Applications extends Resource {
|
|
|
24
24
|
overrides,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Update application details.
|
|
29
|
+
*
|
|
30
|
+
* Each supplied nested object is a full replace, not a deep merge.
|
|
31
|
+
* @returns The updated application details
|
|
32
|
+
*/
|
|
33
|
+
update({ requestBody, overrides, }) {
|
|
34
|
+
return super._updatePatch({
|
|
35
|
+
path: makePathParams('/v3/applications', {}),
|
|
36
|
+
requestBody,
|
|
37
|
+
overrides,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
27
40
|
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { canonicalJson, } from '../models/serviceAccount.js';
|
|
2
|
+
import { makePathParams, objKeysToSnakeCase } from '../utils.js';
|
|
3
|
+
import { Resource } from './resource.js';
|
|
4
|
+
/**
|
|
5
|
+
* Nylas Manage Domains API
|
|
6
|
+
*
|
|
7
|
+
* Register email domains and run their DNS verification flow
|
|
8
|
+
* (ownership / MX / SPF / DKIM / feedback) for Transactional Send and Nylas Inbound.
|
|
9
|
+
*/
|
|
10
|
+
export class Domains extends Resource {
|
|
11
|
+
assertServiceAccountSigningHeaders(overrides) {
|
|
12
|
+
const headers = {
|
|
13
|
+
...(this.apiClient.headers ?? {}),
|
|
14
|
+
...(overrides?.headers ?? {}),
|
|
15
|
+
};
|
|
16
|
+
const normalizedHeaders = Object.fromEntries(Object.entries(headers).map(([header, value]) => [
|
|
17
|
+
header.toLowerCase(),
|
|
18
|
+
value,
|
|
19
|
+
]));
|
|
20
|
+
const missingHeader = Domains.REQUIRED_SERVICE_ACCOUNT_HEADERS.some((header) => !normalizedHeaders[header]?.trim());
|
|
21
|
+
if (missingHeader) {
|
|
22
|
+
throw new Error('Manage Domains API requests require Nylas Service Account signing headers.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
buildSignedRequest({ method, path, requestBody, signer, overrides, }) {
|
|
26
|
+
if (!signer) {
|
|
27
|
+
this.assertServiceAccountSigningHeaders(overrides);
|
|
28
|
+
const body = requestBody ? objKeysToSnakeCase(requestBody) : undefined;
|
|
29
|
+
return {
|
|
30
|
+
overrides: { ...overrides, skipAuth: true },
|
|
31
|
+
serializedBody: body ? canonicalJson(body) : undefined,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const body = requestBody ? objKeysToSnakeCase(requestBody) : undefined;
|
|
35
|
+
const signedRequest = signer.buildHeaders({ method, path, body });
|
|
36
|
+
const signedOverrides = {
|
|
37
|
+
...overrides,
|
|
38
|
+
skipAuth: true,
|
|
39
|
+
headers: {
|
|
40
|
+
...(overrides?.headers ?? {}),
|
|
41
|
+
...signedRequest.headers,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
this.assertServiceAccountSigningHeaders(signedOverrides);
|
|
45
|
+
return {
|
|
46
|
+
overrides: signedOverrides,
|
|
47
|
+
serializedBody: signedRequest.serializedBody,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Return all domains for the caller's organization.
|
|
52
|
+
*
|
|
53
|
+
* Requires Nylas Service Account request signing headers:
|
|
54
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
55
|
+
* @return The list of domains.
|
|
56
|
+
*/
|
|
57
|
+
list({ queryParams, signer, overrides, } = {}) {
|
|
58
|
+
const path = makePathParams('/v3/admin/domains', {});
|
|
59
|
+
if (signer) {
|
|
60
|
+
return super._list({
|
|
61
|
+
queryParams,
|
|
62
|
+
path,
|
|
63
|
+
getOverrides: () => this.buildSignedRequest({
|
|
64
|
+
method: 'GET',
|
|
65
|
+
path,
|
|
66
|
+
signer,
|
|
67
|
+
overrides,
|
|
68
|
+
}).overrides,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const signed = this.buildSignedRequest({
|
|
72
|
+
method: 'GET',
|
|
73
|
+
path,
|
|
74
|
+
overrides,
|
|
75
|
+
});
|
|
76
|
+
return super._list({
|
|
77
|
+
queryParams,
|
|
78
|
+
path,
|
|
79
|
+
overrides: signed.overrides,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Return a domain.
|
|
84
|
+
*
|
|
85
|
+
* Requires Nylas Service Account request signing headers:
|
|
86
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
87
|
+
* @return The domain.
|
|
88
|
+
*/
|
|
89
|
+
find({ domainId, signer, overrides, }) {
|
|
90
|
+
const path = makePathParams('/v3/admin/domains/{domainId}', { domainId });
|
|
91
|
+
const signed = this.buildSignedRequest({
|
|
92
|
+
method: 'GET',
|
|
93
|
+
path,
|
|
94
|
+
signer,
|
|
95
|
+
overrides,
|
|
96
|
+
});
|
|
97
|
+
return super._find({
|
|
98
|
+
path,
|
|
99
|
+
overrides: signed.overrides,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a domain.
|
|
104
|
+
*
|
|
105
|
+
* Requires Nylas Service Account request signing headers:
|
|
106
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
107
|
+
* @return The created domain.
|
|
108
|
+
*/
|
|
109
|
+
create({ requestBody, signer, overrides, }) {
|
|
110
|
+
const path = makePathParams('/v3/admin/domains', {});
|
|
111
|
+
const signed = this.buildSignedRequest({
|
|
112
|
+
method: 'POST',
|
|
113
|
+
path,
|
|
114
|
+
requestBody,
|
|
115
|
+
signer,
|
|
116
|
+
overrides,
|
|
117
|
+
});
|
|
118
|
+
return super._create({
|
|
119
|
+
path,
|
|
120
|
+
requestBody,
|
|
121
|
+
serializedBody: signed.serializedBody,
|
|
122
|
+
overrides: signed.overrides,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Update a domain.
|
|
127
|
+
*
|
|
128
|
+
* Note: the response echoes the sparse cleared input (typically just `name`
|
|
129
|
+
* and `updatedAt`), not a full domain. Re-fetch the domain with `find` if you
|
|
130
|
+
* need the complete record.
|
|
131
|
+
*
|
|
132
|
+
* Requires Nylas Service Account request signing headers:
|
|
133
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
134
|
+
* @return The updated domain fields.
|
|
135
|
+
*/
|
|
136
|
+
update({ domainId, requestBody, signer, overrides, }) {
|
|
137
|
+
const path = makePathParams('/v3/admin/domains/{domainId}', { domainId });
|
|
138
|
+
const signed = this.buildSignedRequest({
|
|
139
|
+
method: 'PUT',
|
|
140
|
+
path,
|
|
141
|
+
requestBody,
|
|
142
|
+
signer,
|
|
143
|
+
overrides,
|
|
144
|
+
});
|
|
145
|
+
return super._update({
|
|
146
|
+
path,
|
|
147
|
+
requestBody,
|
|
148
|
+
serializedBody: signed.serializedBody,
|
|
149
|
+
overrides: signed.overrides,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Delete a domain.
|
|
154
|
+
*
|
|
155
|
+
* Requires Nylas Service Account request signing headers:
|
|
156
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
157
|
+
* @return The deletion response.
|
|
158
|
+
*/
|
|
159
|
+
destroy({ domainId, signer, overrides, }) {
|
|
160
|
+
const path = makePathParams('/v3/admin/domains/{domainId}', { domainId });
|
|
161
|
+
const signed = this.buildSignedRequest({
|
|
162
|
+
method: 'DELETE',
|
|
163
|
+
path,
|
|
164
|
+
signer,
|
|
165
|
+
overrides,
|
|
166
|
+
});
|
|
167
|
+
return super._destroy({
|
|
168
|
+
path,
|
|
169
|
+
overrides: signed.overrides,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get the DNS record a customer must configure for a given verification type.
|
|
174
|
+
*
|
|
175
|
+
* Requires Nylas Service Account request signing headers:
|
|
176
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
177
|
+
* @return The verification result, including the DNS record to configure.
|
|
178
|
+
*/
|
|
179
|
+
info({ domainId, requestBody, signer, overrides, }) {
|
|
180
|
+
const path = makePathParams('/v3/admin/domains/{domainId}/info', {
|
|
181
|
+
domainId,
|
|
182
|
+
});
|
|
183
|
+
const signed = this.buildSignedRequest({
|
|
184
|
+
method: 'POST',
|
|
185
|
+
path,
|
|
186
|
+
requestBody,
|
|
187
|
+
signer,
|
|
188
|
+
overrides,
|
|
189
|
+
});
|
|
190
|
+
return super._create({
|
|
191
|
+
path,
|
|
192
|
+
requestBody,
|
|
193
|
+
serializedBody: signed.serializedBody,
|
|
194
|
+
overrides: signed.overrides,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Trigger a DNS verification check for a given verification type.
|
|
199
|
+
*
|
|
200
|
+
* Requires Nylas Service Account request signing headers:
|
|
201
|
+
* X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature.
|
|
202
|
+
* @return The verification result, including the current status.
|
|
203
|
+
*/
|
|
204
|
+
verify({ domainId, requestBody, signer, overrides, }) {
|
|
205
|
+
const path = makePathParams('/v3/admin/domains/{domainId}/verify', {
|
|
206
|
+
domainId,
|
|
207
|
+
});
|
|
208
|
+
const signed = this.buildSignedRequest({
|
|
209
|
+
method: 'POST',
|
|
210
|
+
path,
|
|
211
|
+
requestBody,
|
|
212
|
+
signer,
|
|
213
|
+
overrides,
|
|
214
|
+
});
|
|
215
|
+
return super._create({
|
|
216
|
+
path,
|
|
217
|
+
requestBody,
|
|
218
|
+
serializedBody: signed.serializedBody,
|
|
219
|
+
overrides: signed.overrides,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
Domains.REQUIRED_SERVICE_ACCOUNT_HEADERS = [
|
|
224
|
+
'x-nylas-kid',
|
|
225
|
+
'x-nylas-timestamp',
|
|
226
|
+
'x-nylas-nonce',
|
|
227
|
+
'x-nylas-signature',
|
|
228
|
+
];
|
|
@@ -44,7 +44,7 @@ export class RedirectUris extends Resource {
|
|
|
44
44
|
* @return The updated Redirect URI
|
|
45
45
|
*/
|
|
46
46
|
update({ redirectUriId, requestBody, overrides, }) {
|
|
47
|
-
return super.
|
|
47
|
+
return super._updatePatch({
|
|
48
48
|
overrides,
|
|
49
49
|
path: makePathParams('/v3/applications/redirect-uris/{redirectUriId}', {
|
|
50
50
|
redirectUriId,
|
|
@@ -54,7 +54,7 @@ export class RedirectUris extends Resource {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Delete a Redirect URI
|
|
57
|
-
* @return The
|
|
57
|
+
* @return The deletion response
|
|
58
58
|
*/
|
|
59
59
|
destroy({ redirectUriId, overrides, }) {
|
|
60
60
|
return super._destroy({
|
|
@@ -10,13 +10,26 @@ export class Resource {
|
|
|
10
10
|
constructor(apiClient) {
|
|
11
11
|
this.apiClient = apiClient;
|
|
12
12
|
}
|
|
13
|
-
async fetchList({ queryParams, path, overrides, }) {
|
|
13
|
+
async fetchList({ queryParams, path, overrides, getOverrides, }) {
|
|
14
14
|
const res = await this.apiClient.request({
|
|
15
15
|
method: 'GET',
|
|
16
16
|
path,
|
|
17
17
|
queryParams,
|
|
18
|
-
overrides,
|
|
18
|
+
overrides: getOverrides ? getOverrides() : overrides,
|
|
19
19
|
});
|
|
20
|
+
// Some list endpoints return a nested envelope after key conversion:
|
|
21
|
+
// { data: { items: T[], nextCursor? } }.
|
|
22
|
+
// This guard remaps that nested shape back to the flat shape the list machinery
|
|
23
|
+
// and public SDK surface expect.
|
|
24
|
+
const data = res.data;
|
|
25
|
+
if (data != null &&
|
|
26
|
+
!Array.isArray(data) &&
|
|
27
|
+
typeof data === 'object' &&
|
|
28
|
+
Array.isArray(data.items)) {
|
|
29
|
+
const nested = data;
|
|
30
|
+
res.data = nested.items;
|
|
31
|
+
res.nextCursor = nested.nextCursor ?? res.nextCursor;
|
|
32
|
+
}
|
|
20
33
|
if (queryParams?.limit) {
|
|
21
34
|
let entriesRemaining = queryParams.limit;
|
|
22
35
|
while (res.data.length != queryParams.limit) {
|
|
@@ -32,7 +45,7 @@ export class Resource {
|
|
|
32
45
|
limit: entriesRemaining,
|
|
33
46
|
pageToken: res.nextCursor,
|
|
34
47
|
},
|
|
35
|
-
overrides,
|
|
48
|
+
overrides: getOverrides ? getOverrides() : overrides,
|
|
36
49
|
});
|
|
37
50
|
res.data = res.data.concat(nextRes.data);
|
|
38
51
|
res.requestId = nextRes.requestId;
|
|
@@ -78,12 +91,13 @@ export class Resource {
|
|
|
78
91
|
overrides,
|
|
79
92
|
});
|
|
80
93
|
}
|
|
81
|
-
payloadRequest(method, { path, queryParams, requestBody, overrides }) {
|
|
94
|
+
payloadRequest(method, { path, queryParams, requestBody, serializedBody, overrides, }) {
|
|
82
95
|
return this.apiClient.request({
|
|
83
96
|
method,
|
|
84
97
|
path,
|
|
85
98
|
queryParams,
|
|
86
99
|
body: requestBody,
|
|
100
|
+
serializedBody,
|
|
87
101
|
overrides,
|
|
88
102
|
});
|
|
89
103
|
}
|
|
@@ -31,13 +31,14 @@ export class Threads extends Resource {
|
|
|
31
31
|
* Return a Thread
|
|
32
32
|
* @return The thread
|
|
33
33
|
*/
|
|
34
|
-
find({ identifier, threadId, overrides, }) {
|
|
34
|
+
find({ identifier, threadId, overrides, queryParams, }) {
|
|
35
35
|
return super._find({
|
|
36
36
|
path: makePathParams('/v3/grants/{identifier}/threads/{threadId}', {
|
|
37
37
|
identifier,
|
|
38
38
|
threadId,
|
|
39
39
|
}),
|
|
40
40
|
overrides,
|
|
41
|
+
queryParams,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { makePathParams } from '../utils.js';
|
|
2
|
+
import { Resource } from './resource.js';
|
|
3
|
+
/**
|
|
4
|
+
* Nylas Workspaces API
|
|
5
|
+
*
|
|
6
|
+
* Workspaces group grants in a Nylas application by email domain. Grants can be
|
|
7
|
+
* auto-grouped by matching email domain or manually assigned and removed.
|
|
8
|
+
*/
|
|
9
|
+
export class Workspaces extends Resource {
|
|
10
|
+
/**
|
|
11
|
+
* Return all workspaces for the application.
|
|
12
|
+
*
|
|
13
|
+
* The list endpoint is not paginated and returns every workspace as a flat array.
|
|
14
|
+
* @return The list of workspaces.
|
|
15
|
+
*/
|
|
16
|
+
list({ queryParams, overrides, } = {}) {
|
|
17
|
+
return super._list({
|
|
18
|
+
queryParams,
|
|
19
|
+
path: makePathParams('/v3/workspaces', {}),
|
|
20
|
+
overrides,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Return a workspace.
|
|
25
|
+
* @return The workspace.
|
|
26
|
+
*/
|
|
27
|
+
find({ workspaceId, overrides, }) {
|
|
28
|
+
return super._find({
|
|
29
|
+
path: makePathParams('/v3/workspaces/{workspaceId}', { workspaceId }),
|
|
30
|
+
overrides,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a workspace.
|
|
35
|
+
* @return The created workspace.
|
|
36
|
+
*/
|
|
37
|
+
create({ requestBody, overrides, }) {
|
|
38
|
+
return super._create({
|
|
39
|
+
path: makePathParams('/v3/workspaces', {}),
|
|
40
|
+
requestBody,
|
|
41
|
+
overrides,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Update a workspace.
|
|
46
|
+
*
|
|
47
|
+
* Issued as PATCH; the workspace must be addressed by its UUID.
|
|
48
|
+
* @return The updated workspace.
|
|
49
|
+
*/
|
|
50
|
+
update({ workspaceId, requestBody, overrides, }) {
|
|
51
|
+
return super._updatePatch({
|
|
52
|
+
path: makePathParams('/v3/workspaces/{workspaceId}', { workspaceId }),
|
|
53
|
+
requestBody,
|
|
54
|
+
overrides,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Delete a workspace.
|
|
59
|
+
* @return The deletion response.
|
|
60
|
+
*/
|
|
61
|
+
destroy({ workspaceId, overrides, }) {
|
|
62
|
+
return super._destroy({
|
|
63
|
+
path: makePathParams('/v3/workspaces/{workspaceId}', { workspaceId }),
|
|
64
|
+
overrides,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Start a background job that auto-groups grants into workspaces by email domain.
|
|
69
|
+
* @return The auto-group job response.
|
|
70
|
+
*/
|
|
71
|
+
autoGroup({ requestBody, overrides, } = {}) {
|
|
72
|
+
return super._create({
|
|
73
|
+
path: makePathParams('/v3/workspaces/auto-group', {}),
|
|
74
|
+
requestBody: requestBody ?? {},
|
|
75
|
+
overrides,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Manually assign grants to and/or remove grants from a workspace.
|
|
80
|
+
* @return The assignment response.
|
|
81
|
+
*/
|
|
82
|
+
manualAssign({ workspaceId, requestBody, overrides, }) {
|
|
83
|
+
return super._create({
|
|
84
|
+
path: makePathParams('/v3/workspaces/{workspaceId}/manual-assign', {
|
|
85
|
+
workspaceId,
|
|
86
|
+
}),
|
|
87
|
+
requestBody,
|
|
88
|
+
overrides,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated by scripts/exportVersion.js
|
|
2
|
-
export const SDK_VERSION = '8.
|
|
2
|
+
export const SDK_VERSION = '8.2.0';
|
package/lib/types/apiClient.d.ts
CHANGED
package/lib/types/config.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export type NylasConfig = {
|
|
|
17
17
|
export type OverridableNylasConfig = {
|
|
18
18
|
apiKey?: string;
|
|
19
19
|
apiUri?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Suppress the default bearer Authorization header for endpoints that use a
|
|
22
|
+
* different authentication mechanism.
|
|
23
|
+
* @ignore Not for public use
|
|
24
|
+
*/
|
|
25
|
+
skipAuth?: boolean;
|
|
20
26
|
/**
|
|
21
27
|
* @deprecated Providing timeout in milliseconds is deprecated and will be removed in the next major release. Please use seconds instead.
|
|
22
28
|
*/
|
|
@@ -67,6 +67,9 @@ export interface AgentListItem {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Interface representing a request to create a Nylas Agent Account list.
|
|
70
|
+
*
|
|
71
|
+
* The server derives `id`, `itemsCount`, `applicationId`, `organizationId`,
|
|
72
|
+
* `createdAt`, and `updatedAt`; they are intentionally not accepted here.
|
|
70
73
|
*/
|
|
71
74
|
export interface CreateAgentListRequest {
|
|
72
75
|
/**
|
|
@@ -84,6 +87,8 @@ export interface CreateAgentListRequest {
|
|
|
84
87
|
}
|
|
85
88
|
/**
|
|
86
89
|
* Interface representing a request to update a Nylas Agent Account list.
|
|
90
|
+
*
|
|
91
|
+
* List `type` is immutable after creation.
|
|
87
92
|
*/
|
|
88
93
|
export interface UpdateAgentListRequest {
|
|
89
94
|
/**
|