nylas 8.1.2 → 8.3.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 (49) 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/messages.d.ts +5 -0
  35. package/lib/types/models/policies.d.ts +6 -2
  36. package/lib/types/models/redirectUri.d.ts +15 -4
  37. package/lib/types/models/rules.d.ts +7 -1
  38. package/lib/types/models/serviceAccount.d.ts +46 -0
  39. package/lib/types/models/threads.d.ts +7 -0
  40. package/lib/types/models/workspaces.d.ts +191 -0
  41. package/lib/types/nylas.d.ts +10 -0
  42. package/lib/types/resources/applications.d.ts +14 -1
  43. package/lib/types/resources/domains.d.ts +137 -0
  44. package/lib/types/resources/redirectUris.d.ts +2 -2
  45. package/lib/types/resources/resource.d.ts +2 -0
  46. package/lib/types/resources/threads.d.ts +3 -2
  47. package/lib/types/resources/workspaces.d.ts +98 -0
  48. package/lib/types/version.d.ts +1 -1
  49. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { RedirectUri } from './redirectUri.js';
1
+ import { RedirectUri, RedirectUriPlatform, RedirectUriSettings } from './redirectUri.js';
2
2
  /**
3
3
  * Interface for a Nylas application details object
4
4
  */
@@ -12,13 +12,17 @@ export interface ApplicationDetails {
12
12
  */
13
13
  organizationId: string;
14
14
  /**
15
- * Region identifier
15
+ * Region identifier (e.g. `us`, `eu`). Free-form string, not a closed enum.
16
16
  */
17
- region: 'us' | 'eu';
17
+ region: string;
18
18
  /**
19
- * Environment identifier
19
+ * Environment identifier (e.g. `sandbox`). Free-form string, not a closed enum.
20
20
  */
21
- environment: 'production' | 'staging';
21
+ environment: string;
22
+ /**
23
+ * White-label domain. Omitted when empty.
24
+ */
25
+ domain?: string;
22
26
  /**
23
27
  * Branding details for the application
24
28
  */
@@ -28,14 +32,33 @@ export interface ApplicationDetails {
28
32
  */
29
33
  hostedAuthentication?: HostedAuthentication;
30
34
  /**
31
- * List of redirect URIs
35
+ * Identity provider (IdP) settings for the application
32
36
  */
33
- redirectUris?: RedirectUri[];
37
+ idpSettings?: IdpSettings;
38
+ /**
39
+ * List of callback (redirect) URIs.
40
+ *
41
+ * Read-only on the application object; manage entries via the dedicated
42
+ * redirect-uris endpoints (`Nylas.applications.redirectUris`).
43
+ */
44
+ callbackUris?: RedirectUri[];
45
+ /**
46
+ * Unix timestamp (seconds) when the application was created. Omitted when empty.
47
+ */
48
+ createdAt?: number;
49
+ /**
50
+ * Unix timestamp (seconds) when the application was last updated. Omitted when empty.
51
+ */
52
+ updatedAt?: number;
53
+ /**
54
+ * Whether the application is blocked. Omitted when empty.
55
+ */
56
+ blocked?: boolean;
34
57
  }
35
58
  /**
36
59
  * Interface for branding details for the application
37
60
  */
38
- interface Branding {
61
+ export interface Branding {
39
62
  /**
40
63
  * Name of the application
41
64
  */
@@ -49,14 +72,14 @@ interface Branding {
49
72
  */
50
73
  websiteUrl?: string;
51
74
  /**
52
- * Description of the appli∏cati∏on
75
+ * Description of the application
53
76
  */
54
77
  description?: string;
55
78
  }
56
79
  /**
57
80
  * Interface for hosted authentication branding details
58
81
  */
59
- interface HostedAuthentication {
82
+ export interface HostedAuthentication {
60
83
  /**
61
84
  * URL of the background image
62
85
  */
@@ -89,5 +112,120 @@ interface HostedAuthentication {
89
112
  * CSS spacing attribute in px
90
113
  */
91
114
  spacing?: number;
115
+ /**
116
+ * URL of the terms of service
117
+ */
118
+ termsOfServiceUrl?: string;
119
+ /**
120
+ * URL of the privacy policy
121
+ */
122
+ privacyPolicyUrl?: string;
123
+ }
124
+ /**
125
+ * Interface for identity provider (IdP) settings for the application
126
+ */
127
+ export interface IdpSettings {
128
+ /**
129
+ * Comma-separated list of allowed origins. Each must be an absolute HTTPS URL
130
+ * (HTTP allowed for `localhost`/`127.0.0.1`) with no path, query, fragment, or userinfo.
131
+ */
132
+ origins?: string;
133
+ /**
134
+ * Comma-separated list of allowed issuers.
135
+ */
136
+ issuers?: string;
137
+ }
138
+ /**
139
+ * Interface for additional settings for the application.
140
+ *
141
+ * Write-only on update: these values can be set via `PATCH /v3/applications` but are
142
+ * stripped from every response, so they are not exposed on {@link ApplicationDetails}.
143
+ */
144
+ export interface AdditionalSettings {
145
+ /**
146
+ * Login URL.
147
+ */
148
+ loginUrl?: string;
149
+ /**
150
+ * Logout URL.
151
+ */
152
+ logoutUrl?: string;
153
+ /**
154
+ * Absolute refresh-token expiration, in seconds.
155
+ */
156
+ refreshTokenExpirationAbsolute?: number;
157
+ /**
158
+ * Idle refresh-token expiration, in seconds.
159
+ */
160
+ refreshTokenExpirationIdle?: number;
161
+ /**
162
+ * Whether to rotate the refresh token on use.
163
+ */
164
+ rotateRefreshToken?: boolean;
165
+ /**
166
+ * Whether to allow query parameters in redirect URIs.
167
+ */
168
+ allowQueryParamInRedirectUri?: boolean;
169
+ }
170
+ /**
171
+ * Branding details accepted on the application update path.
172
+ *
173
+ * Unlike the response {@link Branding} type, `name` is optional here — the source does
174
+ * not require `branding.name` on `PATCH /v3/applications`.
175
+ */
176
+ export type UpdateBranding = Partial<Branding>;
177
+ /**
178
+ * Callback URI shape accepted by application updates.
179
+ */
180
+ export interface UpdateApplicationRedirectUriRequest {
181
+ /**
182
+ * Existing callback URI ID. Include this when preserving or updating an existing URI.
183
+ */
184
+ id?: string;
185
+ /**
186
+ * Redirect URL.
187
+ */
188
+ url: string;
189
+ /**
190
+ * Platform identifier. One of `web`, `js`, `ios`, `android`, `desktop`.
191
+ * Defaults to `web` when omitted.
192
+ */
193
+ platform?: RedirectUriPlatform;
194
+ /**
195
+ * Optional settings for the redirect URI.
196
+ */
197
+ settings?: RedirectUriSettings;
198
+ }
199
+ /**
200
+ * Interface representing a request to update application details.
201
+ *
202
+ * All fields are optional; each supplied nested object is a full replace, not a deep merge.
203
+ */
204
+ export interface UpdateApplicationRequest {
205
+ /**
206
+ * Branding details for the application.
207
+ */
208
+ branding?: UpdateBranding;
209
+ /**
210
+ * Hosted authentication branding details.
211
+ */
212
+ hostedAuthentication?: HostedAuthentication;
213
+ /**
214
+ * Identity provider (IdP) settings for the application.
215
+ */
216
+ idpSettings?: IdpSettings;
217
+ /**
218
+ * List of callback URIs for the application.
219
+ */
220
+ callbackUris?: UpdateApplicationRedirectUriRequest[];
221
+ /**
222
+ * White-label domain for the application.
223
+ */
224
+ domain?: string;
225
+ /**
226
+ * Additional settings for the application.
227
+ *
228
+ * Write-only: persisted on update but stripped from the response.
229
+ */
230
+ additionalSettings?: AdditionalSettings;
92
231
  }
93
- export {};
@@ -0,0 +1,177 @@
1
+ import { ListQueryParams } from './listQueryParams.js';
2
+ /**
3
+ * Type for the DNS verification types supported by the Manage Domains API.
4
+ */
5
+ export type DomainVerificationType = 'ownership' | 'mx' | 'spf' | 'dkim' | 'feedback' | 'dmarc' | 'arc';
6
+ /**
7
+ * Type for the DNS verification types accepted by Manage Domains info and
8
+ * verify request bodies.
9
+ */
10
+ export type DomainVerificationRequestType = 'ownership' | 'mx' | 'spf' | 'dkim' | 'feedback';
11
+ /**
12
+ * Type for the status of a domain DNS verification attempt.
13
+ */
14
+ export type DomainVerificationStatus = 'pending' | 'done' | 'failed';
15
+ /**
16
+ * Interface representing a registered email domain.
17
+ *
18
+ * Every field is optional: the API only emits fields it has populated.
19
+ */
20
+ export interface Domain {
21
+ /**
22
+ * Server-generated domain ID.
23
+ */
24
+ id?: string;
25
+ /**
26
+ * Human-readable label.
27
+ */
28
+ name?: string;
29
+ /**
30
+ * The registered domain (for example, mail.example.com). Stored lowercased.
31
+ */
32
+ domainAddress?: string;
33
+ /**
34
+ * The ID of the organization that owns the domain. Derived from auth, never client-set.
35
+ */
36
+ organizationId?: string;
37
+ /**
38
+ * Whether the domain is a subdomain of a Nylas branded domain. Server-determined at create.
39
+ */
40
+ branded?: boolean;
41
+ /**
42
+ * Cluster region. Server-set from config at create.
43
+ */
44
+ region?: string;
45
+ /**
46
+ * Ownership (TXT) verification flag.
47
+ */
48
+ verifiedOwnership?: boolean;
49
+ /**
50
+ * MX verification flag.
51
+ */
52
+ verifiedMx?: boolean;
53
+ /**
54
+ * SPF verification flag.
55
+ */
56
+ verifiedSpf?: boolean;
57
+ /**
58
+ * Feedback MX verification flag.
59
+ */
60
+ verifiedFeedback?: boolean;
61
+ /**
62
+ * DKIM verification flag.
63
+ */
64
+ verifiedDkim?: boolean;
65
+ /**
66
+ * DMARC verification flag.
67
+ */
68
+ verifiedDmarc?: boolean;
69
+ /**
70
+ * ARC verification flag.
71
+ */
72
+ verifiedArc?: boolean;
73
+ /**
74
+ * Unix timestamp when the domain was created.
75
+ */
76
+ createdAt?: number;
77
+ /**
78
+ * Unix timestamp when the domain was last updated.
79
+ */
80
+ updatedAt?: number;
81
+ }
82
+ /**
83
+ * Interface representing a request to create a domain.
84
+ *
85
+ * Other Domain fields are not honored for create: the server sets region,
86
+ * branded, the verified flags, id, and timestamps.
87
+ */
88
+ export interface CreateDomainRequest {
89
+ /**
90
+ * Human-readable label.
91
+ */
92
+ name: string;
93
+ /**
94
+ * The domain to register. Normalized to lowercase. Cannot duplicate an existing
95
+ * domain in the organization.
96
+ */
97
+ domainAddress: string;
98
+ }
99
+ /**
100
+ * Interface representing a request to update a domain.
101
+ *
102
+ * Only `name` is updatable. `domainAddress` cannot be changed after create;
103
+ * delete and recreate the domain to use a different address.
104
+ */
105
+ export interface UpdateDomainRequest {
106
+ /**
107
+ * New human-readable label.
108
+ */
109
+ name?: string;
110
+ }
111
+ /**
112
+ * Interface representing a domain DNS verification attempt, used as the request
113
+ * body for both the Info and Verify endpoints.
114
+ */
115
+ export interface DomainVerificationAttempt {
116
+ /**
117
+ * The DNS verification type to fetch info for or verify.
118
+ */
119
+ type: DomainVerificationRequestType;
120
+ /**
121
+ * Free-form options. For dkim, may carry a key-length hint. Most callers omit this.
122
+ */
123
+ options?: Record<string, any>;
124
+ }
125
+ /**
126
+ * Interface representing the DNS record details for a verification attempt
127
+ * returned in a verification result.
128
+ */
129
+ export interface DomainVerificationAttemptResult {
130
+ /**
131
+ * The verification type that this attempt corresponds to.
132
+ */
133
+ type?: DomainVerificationType;
134
+ /**
135
+ * The DNS record values to configure (for example, host, type, and value).
136
+ */
137
+ options?: Record<string, any>;
138
+ }
139
+ /**
140
+ * Interface representing the result of a domain Info or Verify request.
141
+ *
142
+ * Info and Verify return the same shape. Every field is optional.
143
+ */
144
+ export interface DomainVerificationResult {
145
+ /**
146
+ * The ID of the domain being verified.
147
+ */
148
+ domainId?: string;
149
+ /**
150
+ * The verification attempt, including the DNS record to configure.
151
+ */
152
+ attempt?: DomainVerificationAttemptResult;
153
+ /**
154
+ * The current status for this verification type.
155
+ */
156
+ status?: DomainVerificationStatus;
157
+ /**
158
+ * Unix timestamp when the attempt record was created.
159
+ */
160
+ createdAt?: number;
161
+ /**
162
+ * Unix timestamp when the temporary attempt expires.
163
+ */
164
+ expiresAt?: number;
165
+ /**
166
+ * Optional in-between state.
167
+ */
168
+ details?: Record<string, any>;
169
+ /**
170
+ * Human-readable instruction for configuring the DNS record.
171
+ */
172
+ message?: string;
173
+ }
174
+ /**
175
+ * Interface representing query parameters for listing domains.
176
+ */
177
+ export type ListDomainsQueryParams = ListQueryParams;
@@ -314,6 +314,11 @@ export interface ListEventQueryParams extends ListQueryParams {
314
314
  * Master event id if recurring events.
315
315
  */
316
316
  masterEventId?: string;
317
+ /**
318
+ * Filter events by their iCalendar unique identifier.
319
+ * Useful for finding a specific event across calendaring systems.
320
+ */
321
+ icalUid?: string;
317
322
  /**
318
323
  * When set to false, treats tentative calendar events as busy:false.
319
324
  * Only applicable for Microsoft and EWS calendar providers. Defaults to true.
@@ -7,6 +7,7 @@ export * from './calendars.js';
7
7
  export * from './connectors.js';
8
8
  export * from './contacts.js';
9
9
  export * from './credentials.js';
10
+ export * from './domains.js';
10
11
  export * from './drafts.js';
11
12
  export * from './error.js';
12
13
  export * from './events.js';
@@ -21,6 +22,8 @@ export * from './redirectUri.js';
21
22
  export * from './response.js';
22
23
  export * from './rules.js';
23
24
  export * from './scheduler.js';
25
+ export * from './serviceAccount.js';
24
26
  export * from './smartCompose.js';
25
27
  export * from './threads.js';
26
28
  export * from './webhooks.js';
29
+ export * from './workspaces.js';
@@ -342,6 +342,11 @@ export interface CleanMessagesRequest {
342
342
  * If true, removes phrases such as "Best" and "Regards" in the email message signature.
343
343
  */
344
344
  removeConclusionPhrases?: boolean;
345
+ /**
346
+ * If true, converts the cleaned HTML message body to Markdown.
347
+ * Note: This can't be true when imagesAsMarkdown is false.
348
+ */
349
+ htmlAsMarkdown?: boolean;
345
350
  }
346
351
  /**
347
352
  * Interface representing the response after cleaning a message.
@@ -24,9 +24,13 @@ export interface PolicyLimits {
24
24
  */
25
25
  limitStorageTotal?: number;
26
26
  /**
27
- * Maximum number of messages each grant can send per day.
27
+ * Maximum number of messages each grant can receive per day. Use -1 for unlimited.
28
28
  */
29
- limitCountDailyMessagePerGrant?: number;
29
+ limitCountDailyMessageReceived?: number;
30
+ /**
31
+ * Maximum number of emails each grant can send per day. Use -1 for unlimited.
32
+ */
33
+ limitCountDailyEmailSent?: number;
30
34
  /**
31
35
  * How long, in days, to retain messages in the inbox.
32
36
  */
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The platform of a Redirect URI.
3
+ *
4
+ * One of `web`, `js`, `ios`, `android`, or `desktop`. Defaults to `web` when omitted.
5
+ */
6
+ export type RedirectUriPlatform = 'web' | 'js' | 'ios' | 'android' | 'desktop';
1
7
  /**
2
8
  * Interface representation of a Redirect URI object
3
9
  */
@@ -11,13 +17,17 @@ export type RedirectUri = {
11
17
  */
12
18
  url: string;
13
19
  /**
14
- * Platform identifier
20
+ * Platform identifier. One of `web`, `js`, `ios`, `android`, `desktop`.
15
21
  */
16
- platform: string;
22
+ platform: RedirectUriPlatform;
17
23
  /**
18
24
  * Configuration settings
19
25
  */
20
26
  settings?: RedirectUriSettings;
27
+ /**
28
+ * Unix timestamp (seconds) when the redirect URI was soft-deleted. Omitted when empty.
29
+ */
30
+ deletedAt?: number;
21
31
  };
22
32
  /**
23
33
  * Configuration settings for a Redirect URI object
@@ -57,9 +67,10 @@ export type CreateRedirectUriRequest = {
57
67
  */
58
68
  url: string;
59
69
  /**
60
- * Platform identifier.
70
+ * Platform identifier. One of `web`, `js`, `ios`, `android`, `desktop`.
71
+ * Defaults to `web` when omitted.
61
72
  */
62
- platform: string;
73
+ platform?: RedirectUriPlatform;
63
74
  /**
64
75
  * Optional settings for the redirect uri.
65
76
  */
@@ -230,6 +230,11 @@ export interface RuleEvaluationAppliedActions {
230
230
  * Whether the inbound message or outbound send was blocked.
231
231
  */
232
232
  blocked?: boolean;
233
+ /**
234
+ * Whether the message or send was blocked because an evaluation error
235
+ * triggered fail-closed handling, rather than a genuine rule match.
236
+ */
237
+ blockedByEvaluationError?: boolean;
233
238
  /**
234
239
  * Whether the message or stored sent copy was moved to spam.
235
240
  */
@@ -269,8 +274,9 @@ export interface RuleEvaluation {
269
274
  grantId: string;
270
275
  /**
271
276
  * The inbound message or stored sent copy associated with this evaluation.
277
+ * Omitted (absent) for smtp_rcpt evaluations and outbound sends with no stored copy.
272
278
  */
273
- messageId?: string | null;
279
+ messageId?: string;
274
280
  /**
275
281
  * Unix timestamp when the evaluation occurred.
276
282
  */
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Configuration for Nylas Service Account request signing.
3
+ */
4
+ export interface ServiceAccountSignerConfig {
5
+ /**
6
+ * RSA private key in PEM format. Base64-encoded PEM is also accepted.
7
+ */
8
+ privateKeyPem: string | Buffer;
9
+ /**
10
+ * The `private_key_id` from the Nylas Service Account credentials file.
11
+ */
12
+ privateKeyId: string;
13
+ }
14
+ /**
15
+ * Inputs for creating Nylas Service Account signing headers.
16
+ */
17
+ export interface BuildServiceAccountHeadersParams {
18
+ method: string;
19
+ path: string;
20
+ body?: Record<string, unknown>;
21
+ timestamp?: number;
22
+ nonce?: string;
23
+ }
24
+ /**
25
+ * Nylas Service Account signing headers and the canonical JSON body, when the
26
+ * request method signs a payload.
27
+ */
28
+ export interface ServiceAccountSignedRequest {
29
+ headers: Record<string, string>;
30
+ serializedBody?: string;
31
+ }
32
+ export declare function generateNonce(length?: number): string;
33
+ /**
34
+ * Serialize JSON deterministically with sorted object keys and no extra
35
+ * whitespace, matching Nylas Service Account signing requirements.
36
+ */
37
+ export declare function canonicalJson(data: Record<string, unknown>): string;
38
+ /**
39
+ * Generates Nylas Service Account request signing headers.
40
+ */
41
+ export declare class ServiceAccountSigner {
42
+ private readonly privateKey;
43
+ private readonly privateKeyId;
44
+ constructor({ privateKeyPem, privateKeyId }: ServiceAccountSignerConfig);
45
+ buildHeaders({ method, path, body, timestamp, nonce, }: BuildServiceAccountHeadersParams): ServiceAccountSignedRequest;
46
+ }
@@ -151,3 +151,10 @@ export interface ListThreadsQueryParams extends ListQueryParams {
151
151
  */
152
152
  searchQueryNative?: string;
153
153
  }
154
+ export interface FindThreadQueryParams {
155
+ /**
156
+ * Specify fields that you want Nylas to return
157
+ * as a comma-separated list (for example, select=id,updated_at).
158
+ */
159
+ select?: string;
160
+ }