nylas 7.0.0-beta.2 → 7.0.0-beta.3

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 (72) hide show
  1. package/README.md +19 -10
  2. package/lib/cjs/apiClient.js +7 -0
  3. package/lib/cjs/models/connectors.js +2 -0
  4. package/lib/cjs/models/credentials.js +12 -0
  5. package/lib/cjs/models/drafts.js +2 -0
  6. package/lib/cjs/models/files.js +2 -0
  7. package/lib/cjs/models/freeBusy.js +11 -0
  8. package/lib/cjs/models/messages.js +11 -0
  9. package/lib/cjs/models/smartCompose.js +2 -0
  10. package/lib/cjs/models/threads.js +2 -0
  11. package/lib/cjs/models/webhooks.js +3 -0
  12. package/lib/cjs/nylas.js +8 -0
  13. package/lib/cjs/resources/auth.js +8 -6
  14. package/lib/cjs/resources/calendars.js +12 -0
  15. package/lib/cjs/resources/connectors.js +68 -0
  16. package/lib/cjs/resources/credentials.js +60 -0
  17. package/lib/cjs/resources/drafts.js +81 -0
  18. package/lib/cjs/resources/grants.js +2 -2
  19. package/lib/cjs/resources/messages.js +121 -0
  20. package/lib/cjs/resources/redirectUris.js +1 -1
  21. package/lib/cjs/resources/smartCompose.js +34 -0
  22. package/lib/cjs/resources/threads.js +54 -0
  23. package/lib/cjs/utils.js +17 -1
  24. package/lib/cjs/version.js +1 -1
  25. package/lib/esm/apiClient.js +7 -0
  26. package/lib/esm/models/connectors.js +1 -0
  27. package/lib/esm/models/credentials.js +9 -0
  28. package/lib/esm/models/drafts.js +1 -0
  29. package/lib/esm/models/files.js +1 -0
  30. package/lib/esm/models/freeBusy.js +8 -0
  31. package/lib/esm/models/messages.js +8 -0
  32. package/lib/esm/models/smartCompose.js +1 -0
  33. package/lib/esm/models/threads.js +1 -0
  34. package/lib/esm/models/webhooks.js +3 -0
  35. package/lib/esm/nylas.js +8 -0
  36. package/lib/esm/resources/auth.js +8 -6
  37. package/lib/esm/resources/calendars.js +12 -0
  38. package/lib/esm/resources/connectors.js +64 -0
  39. package/lib/esm/resources/credentials.js +56 -0
  40. package/lib/esm/resources/drafts.js +77 -0
  41. package/lib/esm/resources/grants.js +2 -2
  42. package/lib/esm/resources/messages.js +117 -0
  43. package/lib/esm/resources/redirectUris.js +1 -1
  44. package/lib/esm/resources/smartCompose.js +30 -0
  45. package/lib/esm/resources/threads.js +50 -0
  46. package/lib/esm/utils.js +15 -0
  47. package/lib/esm/version.js +1 -1
  48. package/lib/types/apiClient.d.ts +3 -1
  49. package/lib/types/models/auth.d.ts +1 -1
  50. package/lib/types/models/calendars.d.ts +1 -1
  51. package/lib/types/models/connectors.d.ts +127 -0
  52. package/lib/types/models/credentials.d.ts +151 -0
  53. package/lib/types/models/drafts.d.ts +92 -0
  54. package/lib/types/models/files.d.ts +17 -0
  55. package/lib/types/models/freeBusy.d.ts +79 -0
  56. package/lib/types/models/messages.d.ts +271 -0
  57. package/lib/types/models/smartCompose.d.ts +18 -0
  58. package/lib/types/models/threads.d.ts +153 -0
  59. package/lib/types/models/webhooks.d.ts +80 -2
  60. package/lib/types/nylas.d.ts +20 -0
  61. package/lib/types/resources/calendars.d.ts +16 -1
  62. package/lib/types/resources/connectors.d.ts +80 -0
  63. package/lib/types/resources/credentials.d.ts +80 -0
  64. package/lib/types/resources/drafts.d.ts +87 -0
  65. package/lib/types/resources/grants.d.ts +1 -1
  66. package/lib/types/resources/messages.d.ts +129 -0
  67. package/lib/types/resources/smartCompose.d.ts +41 -0
  68. package/lib/types/resources/threads.d.ts +70 -0
  69. package/lib/types/resources/webhooks.d.ts +1 -1
  70. package/lib/types/utils.d.ts +2 -0
  71. package/lib/types/version.d.ts +1 -1
  72. package/package.json +5 -3
@@ -1,2 +1,2 @@
1
1
  // This file is generated by scripts/exportVersion.js
2
- export const SDK_VERSION = '7.0.0-beta.2';
2
+ export const SDK_VERSION = '7.0.0-beta.3';
@@ -1,5 +1,6 @@
1
1
  import { Request, Response } from 'node-fetch';
2
2
  import { NylasConfig, OverridableNylasConfig } from './config.js';
3
+ import * as FormData from 'form-data';
3
4
  /**
4
5
  * Options for a request to the Nylas API
5
6
  * @property path The path to the API endpoint
@@ -16,6 +17,7 @@ export interface RequestOptionsParams {
16
17
  headers?: Record<string, string>;
17
18
  queryParams?: Record<string, any>;
18
19
  body?: any;
20
+ form?: FormData;
19
21
  overrides?: OverridableNylasConfig;
20
22
  }
21
23
  /**
@@ -33,7 +35,7 @@ interface RequestOptions {
33
35
  method: string;
34
36
  headers: Record<string, string>;
35
37
  url: URL;
36
- body?: string;
38
+ body?: any;
37
39
  overrides?: Partial<NylasConfig>;
38
40
  }
39
41
  /**
@@ -5,7 +5,7 @@ type AccessType = 'online' | 'offline';
5
5
  /**
6
6
  * Type for the different OAuth providers Nylas supports.
7
7
  */
8
- export type Provider = 'google' | 'imap' | 'microsoft';
8
+ export type Provider = 'google' | 'imap' | 'microsoft' | 'virtual-calendar';
9
9
  /**
10
10
  * Configuration for generating a URL for OAuth 2.0 authentication.
11
11
  */
@@ -47,7 +47,7 @@ export interface CreateCalenderRequest {
47
47
  /**
48
48
  * Interface of a Nylas update calendar request
49
49
  */
50
- export interface UpdateCalenderRequest extends CreateCalenderRequest {
50
+ export interface UpdateCalenderRequest extends Partial<CreateCalenderRequest> {
51
51
  /**
52
52
  * The background color of the calendar in the hexadecimal format (e.g. #0099EE).
53
53
  * Empty indicates default color.
@@ -0,0 +1,127 @@
1
+ import { Provider } from './auth.js';
2
+ import { ListQueryParams } from './listQueryParams.js';
3
+ /**
4
+ * Interface representing the Nylas connector response.
5
+ */
6
+ export interface Connector {
7
+ /**
8
+ * Custom name of the connector
9
+ */
10
+ name: string;
11
+ /**
12
+ * The provider type
13
+ */
14
+ provider: Provider;
15
+ /**
16
+ * Optional settings from provider
17
+ */
18
+ settings?: Record<string, unknown>;
19
+ /**
20
+ * Default scopes for the connector
21
+ */
22
+ scope?: string[];
23
+ }
24
+ /**
25
+ * Interface representing a Google connector creation request.
26
+ */
27
+ export interface GoogleCreateConnectorSettings {
28
+ /**
29
+ * The Google Client ID
30
+ */
31
+ clientId: string;
32
+ /**
33
+ * The Google Client Secret
34
+ */
35
+ clientSecret: string;
36
+ /**
37
+ * The Google Pub/Sub topic name
38
+ */
39
+ topicName?: string;
40
+ }
41
+ /**
42
+ * Interface representing a Microsoft connector creation request.
43
+ */
44
+ export interface MicrosoftCreateConnectorSettings {
45
+ /**
46
+ * The Microsoft Client ID
47
+ */
48
+ clientId: string;
49
+ /**
50
+ * The Microsoft Client Secret
51
+ */
52
+ clientSecret: string;
53
+ /**
54
+ * The Microsoft tenant ID
55
+ */
56
+ tenant?: string;
57
+ }
58
+ /**
59
+ * Interface representing the base Nylas connector creation request.
60
+ */
61
+ interface BaseCreateConnectionRequest {
62
+ /**
63
+ * Custom name of the connector
64
+ */
65
+ name: string;
66
+ /**
67
+ * The provider type
68
+ */
69
+ provider: Provider;
70
+ }
71
+ /**
72
+ * Interface representing the base Nylas connector creation request.
73
+ */
74
+ export interface GoogleCreateConnectorRequest extends BaseCreateConnectionRequest {
75
+ /**
76
+ * The Google OAuth provider credentials and settings
77
+ */
78
+ settings: GoogleCreateConnectorSettings;
79
+ /**
80
+ * The Google OAuth scopes
81
+ */
82
+ scope?: string[];
83
+ }
84
+ export interface MicrosoftCreateConnectorRequest extends BaseCreateConnectionRequest {
85
+ /**
86
+ * The Microsoft OAuth provider credentials and settings
87
+ */
88
+ settings: MicrosoftCreateConnectorSettings;
89
+ /**
90
+ * The Microsoft OAuth scopes
91
+ */
92
+ scope?: string[];
93
+ }
94
+ /**
95
+ * Interface representing the base Nylas connector creation request.
96
+ */
97
+ export type ImapCreateConnectorRequest = BaseCreateConnectionRequest;
98
+ /**
99
+ * Interface representing the base Nylas connector creation request.
100
+ */
101
+ export type VirtualCalendarsCreateConnectorRequest = BaseCreateConnectionRequest;
102
+ /**
103
+ * The type of the Nylas connector creation request.
104
+ */
105
+ export type CreateConnectorRequest = GoogleCreateConnectorRequest | MicrosoftCreateConnectorRequest | ImapCreateConnectorRequest | VirtualCalendarsCreateConnectorRequest;
106
+ /**
107
+ * Interface representing the base Nylas connector creation request.
108
+ */
109
+ export interface UpdateConnectorRequest {
110
+ /**
111
+ * Custom name of the connector
112
+ */
113
+ name?: string;
114
+ /**
115
+ * The OAuth provider credentials and settings
116
+ */
117
+ settings?: Record<string, unknown>;
118
+ /**
119
+ * The OAuth scopes
120
+ */
121
+ scope?: string[];
122
+ }
123
+ /**
124
+ * Interface of the query parameters for listing connectors.
125
+ */
126
+ export type ListConnectorsQueryParams = ListQueryParams;
127
+ export {};
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Interface representing a Nylas Credential object.
3
+ */
4
+ export interface Credential {
5
+ /**
6
+ * Globally unique object identifier
7
+ */
8
+ id: string;
9
+ /**
10
+ * Name of the credential
11
+ */
12
+ name: string;
13
+ /**
14
+ * The type of credential
15
+ */
16
+ credentialType?: CredentialType;
17
+ /**
18
+ * Hashed value of the credential that you created
19
+ */
20
+ hashedData?: string;
21
+ /**
22
+ * Timestamp of when the credential was created
23
+ */
24
+ createdAt?: number;
25
+ /**
26
+ * Timestamp of when the credential was updated
27
+ */
28
+ updatedAt?: number;
29
+ }
30
+ /**
31
+ * Interface representing additional data needed to create a credential for Microsoft Admin Consent
32
+ */
33
+ export interface MicrosoftAdminConsentSettings {
34
+ clientId: string;
35
+ clientSecret: string;
36
+ [key: string]: string;
37
+ }
38
+ /**
39
+ * Interface representing additional data needed to create a credential for Google Service Account
40
+ */
41
+ export interface GoogleServiceAccountCredential {
42
+ privateKeyId: string;
43
+ privateKey: string;
44
+ clientEmail: string;
45
+ [key: string]: string;
46
+ }
47
+ /**
48
+ * Interface representing additional data needed to create a credential for a Connector Override
49
+ */
50
+ export type ConnectorOverrideCredential = Record<string, unknown>;
51
+ /**
52
+ * Type representing the data needed to create a credential
53
+ */
54
+ export type CredentialData = MicrosoftAdminConsentSettings | GoogleServiceAccountCredential | ConnectorOverrideCredential;
55
+ /**
56
+ * Interface representing a request to create a Microsoft Admin Consent credential
57
+ */
58
+ export interface CreateMicrosoftCredentialRequest {
59
+ /**
60
+ * Unique name of this credential
61
+ */
62
+ name: string;
63
+ /**
64
+ * Type of credential for the admin consent flow
65
+ */
66
+ credentialType: CredentialType.ADMINCONSENT;
67
+ /**
68
+ * Data that specifies some special data required for this credential
69
+ */
70
+ credentialData: MicrosoftAdminConsentSettings;
71
+ }
72
+ /**
73
+ * Interface representing a request to create a Google Service Account credential
74
+ */
75
+ export interface CreateGoogleCredentialRequest {
76
+ /**
77
+ * Unique name of this credential
78
+ */
79
+ name: string;
80
+ /**
81
+ * Type of credential for the app permission flow
82
+ */
83
+ credentialType: CredentialType.SERVICEACCOUNT;
84
+ /**
85
+ * Data that specifies some special data required for this credential
86
+ */
87
+ credentialData: GoogleServiceAccountCredential;
88
+ }
89
+ /**
90
+ * Interface representing a request to create a Connector Override credential
91
+ */
92
+ export interface CreateOverrideCredentialRequest {
93
+ /**
94
+ * Unique name of this credential
95
+ */
96
+ name: string;
97
+ /**
98
+ * Type of credential to force the override of a connector's client values
99
+ */
100
+ credentialType: CredentialType.CONNECTOR;
101
+ /**
102
+ * Data that specifies some special data required for this credential
103
+ */
104
+ credentialData: ConnectorOverrideCredential;
105
+ }
106
+ /**
107
+ * Interface representing a request to create a credential
108
+ */
109
+ export type CreateCredentialRequest = CreateMicrosoftCredentialRequest | CreateGoogleCredentialRequest | CreateOverrideCredentialRequest;
110
+ /**
111
+ * Interface representing a request to update a credential
112
+ */
113
+ export interface UpdateCredentialRequest {
114
+ /**
115
+ * Unique name of this credential
116
+ */
117
+ name?: string;
118
+ /**
119
+ * Data that specifies some special data required for this credential
120
+ */
121
+ credentialData?: CredentialData;
122
+ }
123
+ /**
124
+ * Enum representing the type of credential
125
+ */
126
+ export declare enum CredentialType {
127
+ ADMINCONSENT = "adminconsent",
128
+ SERVICEACCOUNT = "serviceaccount",
129
+ CONNECTOR = "connector"
130
+ }
131
+ /**
132
+ * Interface representing the query parameters for listing credentials.
133
+ */
134
+ export interface ListCredentialsQueryParams {
135
+ /**
136
+ * Limit the number of results
137
+ */
138
+ limit?: number;
139
+ /**
140
+ * Offset the results by this number
141
+ */
142
+ offset?: number;
143
+ /**
144
+ * Sort the results by field name
145
+ */
146
+ sortBy?: 'createdAt' | 'updatedAt';
147
+ /**
148
+ * Order the results by ascending or descending
149
+ */
150
+ orderBy?: 'desc' | 'asc';
151
+ }
@@ -0,0 +1,92 @@
1
+ import { BaseMessage, BaseCreateMessage } from './messages.js';
2
+ import { ListQueryParams } from './listQueryParams.js';
3
+ /**
4
+ * Interface representing a request to create a draft.
5
+ */
6
+ export interface CreateDraftRequest extends BaseCreateMessage {
7
+ /**
8
+ * Unix timestamp to send the message at.
9
+ */
10
+ sendAt?: number;
11
+ /**
12
+ * The ID of the message that you are replying to.
13
+ */
14
+ replyToMessageId?: string;
15
+ /**
16
+ * Options for tracking opens, links, and thread replies.
17
+ */
18
+ trackingOptions?: TrackingOptions;
19
+ }
20
+ /**
21
+ * Interface representing a request to send a message.
22
+ */
23
+ export interface SendMessageRequest extends CreateDraftRequest {
24
+ /**
25
+ * Whether or not to use draft support.
26
+ * This is primarily used when dealing with large attachments.
27
+ */
28
+ useDraft?: boolean;
29
+ }
30
+ /**
31
+ * Interface representing a Nylas Draft object.
32
+ */
33
+ export interface Draft extends BaseMessage, Omit<CreateDraftRequest, 'attachments'> {
34
+ /**
35
+ * The type of object.
36
+ */
37
+ object: 'draft';
38
+ }
39
+ /**
40
+ * Interface representing a request to update a draft.
41
+ */
42
+ export type UpdateDraftRequest = Partial<CreateDraftRequest>;
43
+ /**
44
+ * Interface representing the different tracking options for when a message is sent.
45
+ */
46
+ export interface TrackingOptions {
47
+ label?: string;
48
+ links?: string;
49
+ opens?: string;
50
+ threadReplies?: string;
51
+ }
52
+ /**
53
+ * Interface representing the query parameters for listing drafts.
54
+ */
55
+ export interface ListDraftsQueryParams extends ListQueryParams {
56
+ /**
57
+ * Return items with a matching literal subject.
58
+ */
59
+ subject?: string;
60
+ /**
61
+ * Return emails that have been sent or received from this list of email addresses.
62
+ */
63
+ anyEmail?: string[];
64
+ /**
65
+ * Return items containing drafts to be sent these email address.
66
+ */
67
+ to?: string[];
68
+ /**
69
+ * Return items containing drafts cc'ing these email address.
70
+ */
71
+ cc?: string[];
72
+ /**
73
+ * Return items containing drafts bcc'ing these email address.
74
+ */
75
+ bcc?: string[];
76
+ /**
77
+ * Return drafts that are unread.
78
+ */
79
+ unread?: boolean;
80
+ /**
81
+ * Return drafts that are starred.
82
+ */
83
+ starred?: boolean;
84
+ /**
85
+ * Return drafts that belong to this thread.
86
+ */
87
+ threadId?: string;
88
+ /**
89
+ * Return drafts that contain attachments.
90
+ */
91
+ hasAttachment?: boolean;
92
+ }
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ interface BaseFile {
3
+ filename: string;
4
+ contentType: string;
5
+ size?: number;
6
+ isInline?: boolean;
7
+ contentId?: string;
8
+ contentDisposition?: string;
9
+ }
10
+ export interface CreateFileRequest extends BaseFile {
11
+ content: NodeJS.ReadableStream;
12
+ }
13
+ export interface File extends BaseFile {
14
+ id: string;
15
+ grantId: string;
16
+ }
17
+ export {};
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Interface representation of a Nylas free-busy time slot object.
3
+ */
4
+ export interface FreeBusyTimeSlot {
5
+ /**
6
+ * Unix timestamp for the start of the slot.
7
+ */
8
+ startTime: number;
9
+ /**
10
+ * Unix timestamp for the end of the slot.
11
+ */
12
+ endTime: number;
13
+ /**
14
+ * The status of the time slot.
15
+ */
16
+ status: string;
17
+ }
18
+ /**
19
+ * Class representation of a Nylas get free-busy request
20
+ */
21
+ export interface GetFreeBusyRequest {
22
+ /**
23
+ * Unix timestamp representing the start of the time block for assessing the account's free/busy schedule.
24
+ */
25
+ startTime: number;
26
+ /**
27
+ * Unix timestamp representing the end of the time block for assessing the account's free/busy schedule.
28
+ */
29
+ endTime: number;
30
+ /**
31
+ * A list of email addresses to check the free/busy schedules for.
32
+ */
33
+ emails: string[];
34
+ }
35
+ /**
36
+ * Enum representing the type of free/busy information returned for a calendar.
37
+ */
38
+ export declare enum FreeBusyType {
39
+ FREE_BUSY = "free_busy",
40
+ ERROR = "error"
41
+ }
42
+ /**
43
+ * Union type of the possible Nylas get free busy response.
44
+ */
45
+ export type GetFreeBusyResponse = FreeBusy | FreeBusyError;
46
+ /**
47
+ * This interface represents a successful free-busy response.
48
+ */
49
+ export interface FreeBusy {
50
+ /**
51
+ * The participant's email address.
52
+ */
53
+ email: string;
54
+ /**
55
+ * A list of busy time slots.
56
+ */
57
+ timeSlots: FreeBusyTimeSlot[];
58
+ /**
59
+ * The type of the response.
60
+ */
61
+ object: FreeBusyType.FREE_BUSY;
62
+ }
63
+ /**
64
+ * This interface represents a failed free-busy response.
65
+ */
66
+ export interface FreeBusyError {
67
+ /**
68
+ * The participant's email address.
69
+ */
70
+ email: string;
71
+ /**
72
+ * Description of the error fetching data for this participant.
73
+ */
74
+ error: string;
75
+ /**
76
+ * The type of the response.
77
+ */
78
+ object: FreeBusyType.ERROR;
79
+ }