nylas 6.10.0 → 7.0.0-beta.1

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 (197) hide show
  1. package/README.md +26 -14
  2. package/lib/cjs/apiClient.js +115 -0
  3. package/lib/cjs/config.js +32 -0
  4. package/lib/cjs/models/applicationDetails.js +2 -0
  5. package/lib/cjs/models/auth.js +2 -0
  6. package/lib/cjs/models/availability.js +11 -0
  7. package/lib/cjs/models/calendars.js +2 -0
  8. package/lib/cjs/models/error.js +53 -0
  9. package/lib/cjs/models/events.js +2 -0
  10. package/lib/cjs/models/grants.js +2 -0
  11. package/lib/cjs/models/listQueryParams.js +2 -0
  12. package/lib/cjs/models/redirectUri.js +2 -0
  13. package/lib/cjs/models/response.js +2 -0
  14. package/lib/cjs/models/webhooks.js +18 -0
  15. package/lib/cjs/nylas.js +34 -0
  16. package/lib/cjs/resources/applications.js +30 -0
  17. package/lib/cjs/resources/auth.js +153 -0
  18. package/lib/cjs/resources/calendars.js +78 -0
  19. package/lib/cjs/resources/events.js +69 -0
  20. package/lib/cjs/resources/grants.js +65 -0
  21. package/lib/cjs/resources/redirectUris.js +64 -0
  22. package/lib/cjs/resources/resource.js +111 -0
  23. package/lib/cjs/resources/webhooks.js +98 -0
  24. package/lib/cjs/utils.js +58 -0
  25. package/lib/esm/apiClient.js +112 -0
  26. package/lib/esm/config.js +29 -0
  27. package/lib/esm/models/applicationDetails.js +1 -0
  28. package/lib/esm/models/auth.js +1 -0
  29. package/lib/esm/models/availability.js +8 -0
  30. package/lib/esm/models/calendars.js +1 -0
  31. package/lib/esm/models/error.js +45 -0
  32. package/lib/esm/models/events.js +1 -0
  33. package/lib/esm/models/grants.js +1 -0
  34. package/lib/esm/models/listQueryParams.js +1 -0
  35. package/lib/esm/models/redirectUri.js +1 -0
  36. package/lib/esm/models/response.js +1 -0
  37. package/lib/esm/models/webhooks.js +15 -0
  38. package/lib/esm/nylas.js +31 -0
  39. package/lib/esm/resources/applications.js +26 -0
  40. package/lib/esm/resources/auth.js +149 -0
  41. package/lib/esm/resources/calendars.js +74 -0
  42. package/lib/esm/resources/events.js +65 -0
  43. package/lib/esm/resources/grants.js +61 -0
  44. package/lib/esm/resources/redirectUris.js +60 -0
  45. package/lib/esm/resources/resource.js +107 -0
  46. package/lib/esm/resources/webhooks.js +94 -0
  47. package/lib/esm/utils.js +53 -0
  48. package/lib/types/apiClient.d.ts +65 -0
  49. package/lib/types/config.d.ts +50 -0
  50. package/lib/types/models/applicationDetails.d.ts +93 -0
  51. package/lib/types/models/auth.d.ts +196 -0
  52. package/lib/types/models/availability.d.ts +159 -0
  53. package/lib/types/models/calendars.d.ts +121 -0
  54. package/lib/types/models/error.d.ts +104 -0
  55. package/lib/types/models/events.d.ts +494 -0
  56. package/lib/types/models/grants.d.ts +134 -0
  57. package/lib/types/models/listQueryParams.d.ts +4 -0
  58. package/lib/types/models/redirectUri.d.ts +71 -0
  59. package/lib/types/models/response.d.ts +40 -0
  60. package/lib/types/models/webhooks.d.ts +45 -0
  61. package/lib/types/nylas.d.ts +44 -0
  62. package/lib/types/resources/applications.d.ts +26 -0
  63. package/lib/types/resources/auth.d.ts +66 -0
  64. package/lib/types/resources/calendars.d.ts +97 -0
  65. package/lib/types/resources/events.d.ts +87 -0
  66. package/lib/types/resources/grants.d.ts +63 -0
  67. package/lib/types/resources/redirectUris.d.ts +63 -0
  68. package/lib/types/resources/resource.d.ts +55 -0
  69. package/lib/types/resources/webhooks.d.ts +79 -0
  70. package/lib/types/utils.d.ts +22 -0
  71. package/package.json +28 -39
  72. package/lib/config.d.ts +0 -52
  73. package/lib/config.js +0 -47
  74. package/lib/models/access-token.d.ts +0 -18
  75. package/lib/models/access-token.js +0 -56
  76. package/lib/models/account.d.ts +0 -27
  77. package/lib/models/account.js +0 -73
  78. package/lib/models/application-details.d.ts +0 -14
  79. package/lib/models/application-details.js +0 -47
  80. package/lib/models/attributes.d.ts +0 -151
  81. package/lib/models/attributes.js +0 -382
  82. package/lib/models/calendar-availability.d.ts +0 -76
  83. package/lib/models/calendar-availability.js +0 -121
  84. package/lib/models/calendar-restful-model-collection.d.ts +0 -17
  85. package/lib/models/calendar-restful-model-collection.js +0 -181
  86. package/lib/models/calendar.d.ts +0 -33
  87. package/lib/models/calendar.js +0 -97
  88. package/lib/models/component-restful-model-collection.d.ts +0 -9
  89. package/lib/models/component-restful-model-collection.js +0 -34
  90. package/lib/models/component.d.ts +0 -37
  91. package/lib/models/component.js +0 -91
  92. package/lib/models/connect.d.ts +0 -73
  93. package/lib/models/connect.js +0 -193
  94. package/lib/models/contact-restful-model-collection.d.ts +0 -9
  95. package/lib/models/contact-restful-model-collection.js +0 -60
  96. package/lib/models/contact.d.ts +0 -129
  97. package/lib/models/contact.js +0 -289
  98. package/lib/models/delta-collection.d.ts +0 -17
  99. package/lib/models/delta-collection.js +0 -139
  100. package/lib/models/delta-stream.d.ts +0 -32
  101. package/lib/models/delta-stream.js +0 -250
  102. package/lib/models/delta.d.ts +0 -28
  103. package/lib/models/delta.js +0 -88
  104. package/lib/models/deltas.d.ts +0 -17
  105. package/lib/models/deltas.js +0 -49
  106. package/lib/models/draft.d.ts +0 -27
  107. package/lib/models/draft.js +0 -156
  108. package/lib/models/email-participant.d.ts +0 -13
  109. package/lib/models/email-participant.js +0 -46
  110. package/lib/models/event-conferencing.d.ts +0 -34
  111. package/lib/models/event-conferencing.js +0 -71
  112. package/lib/models/event-notification.d.ts +0 -27
  113. package/lib/models/event-notification.js +0 -62
  114. package/lib/models/event-participant.d.ts +0 -19
  115. package/lib/models/event-participant.js +0 -56
  116. package/lib/models/event-reminder-method.d.ts +0 -18
  117. package/lib/models/event-reminder-method.js +0 -47
  118. package/lib/models/event.d.ts +0 -104
  119. package/lib/models/event.js +0 -308
  120. package/lib/models/file.d.ts +0 -29
  121. package/lib/models/file.js +0 -136
  122. package/lib/models/folder.d.ts +0 -21
  123. package/lib/models/folder.js +0 -69
  124. package/lib/models/free-busy.d.ts +0 -58
  125. package/lib/models/free-busy.js +0 -132
  126. package/lib/models/job-status-restful-model-collection.d.ts +0 -9
  127. package/lib/models/job-status-restful-model-collection.js +0 -38
  128. package/lib/models/job-status.d.ts +0 -24
  129. package/lib/models/job-status.js +0 -68
  130. package/lib/models/management-account.d.ts +0 -63
  131. package/lib/models/management-account.js +0 -187
  132. package/lib/models/management-model-collection.d.ts +0 -10
  133. package/lib/models/management-model-collection.js +0 -39
  134. package/lib/models/management-model.d.ts +0 -6
  135. package/lib/models/management-model.js +0 -29
  136. package/lib/models/message-restful-model-collection.d.ts +0 -26
  137. package/lib/models/message-restful-model-collection.js +0 -80
  138. package/lib/models/message.d.ts +0 -57
  139. package/lib/models/message.js +0 -173
  140. package/lib/models/model-collection.d.ts +0 -25
  141. package/lib/models/model-collection.js +0 -201
  142. package/lib/models/model.d.ts +0 -12
  143. package/lib/models/model.js +0 -64
  144. package/lib/models/neural-categorizer.d.ts +0 -28
  145. package/lib/models/neural-categorizer.js +0 -139
  146. package/lib/models/neural-clean-conversation.d.ts +0 -16
  147. package/lib/models/neural-clean-conversation.js +0 -114
  148. package/lib/models/neural-ocr.d.ts +0 -14
  149. package/lib/models/neural-ocr.js +0 -50
  150. package/lib/models/neural-sentiment-analysis.d.ts +0 -20
  151. package/lib/models/neural-sentiment-analysis.js +0 -56
  152. package/lib/models/neural-signature-contact.d.ts +0 -43
  153. package/lib/models/neural-signature-contact.js +0 -142
  154. package/lib/models/neural-signature-extraction.d.ts +0 -17
  155. package/lib/models/neural-signature-extraction.js +0 -54
  156. package/lib/models/neural.d.ts +0 -36
  157. package/lib/models/neural.js +0 -163
  158. package/lib/models/nylas-api-error.d.ts +0 -26
  159. package/lib/models/nylas-api-error.js +0 -62
  160. package/lib/models/outbox-job-status.d.ts +0 -20
  161. package/lib/models/outbox-job-status.js +0 -64
  162. package/lib/models/outbox-message.d.ts +0 -16
  163. package/lib/models/outbox-message.js +0 -54
  164. package/lib/models/outbox.d.ts +0 -35
  165. package/lib/models/outbox.js +0 -158
  166. package/lib/models/rate-limit-error.d.ts +0 -26
  167. package/lib/models/rate-limit-error.js +0 -47
  168. package/lib/models/resource.d.ts +0 -22
  169. package/lib/models/resource.js +0 -66
  170. package/lib/models/restful-model-collection.d.ts +0 -15
  171. package/lib/models/restful-model-collection.js +0 -169
  172. package/lib/models/restful-model-instance.d.ts +0 -9
  173. package/lib/models/restful-model-instance.js +0 -37
  174. package/lib/models/restful-model.d.ts +0 -36
  175. package/lib/models/restful-model.js +0 -146
  176. package/lib/models/scheduler-booking-request.d.ts +0 -64
  177. package/lib/models/scheduler-booking-request.js +0 -148
  178. package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
  179. package/lib/models/scheduler-restful-model-collection.js +0 -133
  180. package/lib/models/scheduler-time-slot.d.ts +0 -20
  181. package/lib/models/scheduler-time-slot.js +0 -53
  182. package/lib/models/scheduler.d.ts +0 -226
  183. package/lib/models/scheduler.js +0 -446
  184. package/lib/models/thread.d.ts +0 -49
  185. package/lib/models/thread.js +0 -127
  186. package/lib/models/webhook-notification.d.ts +0 -133
  187. package/lib/models/webhook-notification.js +0 -314
  188. package/lib/models/webhook.d.ts +0 -50
  189. package/lib/models/webhook.js +0 -101
  190. package/lib/models/when.d.ts +0 -29
  191. package/lib/models/when.js +0 -76
  192. package/lib/nylas-connection.d.ts +0 -71
  193. package/lib/nylas-connection.js +0 -282
  194. package/lib/nylas.d.ts +0 -34
  195. package/lib/nylas.js +0 -199
  196. package/lib/services/tunnel.d.ts +0 -28
  197. package/lib/services/tunnel.js +0 -89
@@ -0,0 +1,63 @@
1
+ import { AsyncListResponse, Resource } from './resource';
2
+ import { NylasDeleteResponse, NylasResponse, NylasListResponse } from '../models/response';
3
+ import { CreateRedirectUriRequest, RedirectUri, UpdateRedirectUriRequest } from '../models/redirectUri';
4
+ import { Overrides } from '../config';
5
+ /**
6
+ * @property redirectUriId The id of the Redirect URI to retrieve.
7
+ */
8
+ interface FindRedirectUrisParams {
9
+ redirectUriId: string;
10
+ }
11
+ /**
12
+ * @property requestBody The values to create the Redirect URI with.
13
+ */
14
+ interface CreateRedirectUrisParams {
15
+ requestBody: CreateRedirectUriRequest;
16
+ }
17
+ /**
18
+ * @property redirectUriId The id of the Redirect URI to update.
19
+ * @property requestBody The values to update the Redirect URI with.
20
+ */
21
+ interface UpdateRedirectUrisParams {
22
+ redirectUriId: string;
23
+ requestBody: UpdateRedirectUriRequest;
24
+ }
25
+ /**
26
+ * @property redirectUriId The id of the Redirect URI to delete.
27
+ */
28
+ interface DestroyRedirectUrisParams {
29
+ redirectUriId: string;
30
+ }
31
+ /**
32
+ * A collection of redirect URI related API endpoints.
33
+ *
34
+ * These endpoints allows for the management of redirect URIs.
35
+ */
36
+ export declare class RedirectUris extends Resource {
37
+ /**
38
+ * Return all Redirect URIs
39
+ * @return The list of Redirect URIs
40
+ */
41
+ list({ overrides }?: Overrides): AsyncListResponse<NylasListResponse<RedirectUri>>;
42
+ /**
43
+ * Return a Redirect URI
44
+ * @return The Redirect URI
45
+ */
46
+ find({ redirectUriId, overrides, }: FindRedirectUrisParams & Overrides): Promise<NylasResponse<RedirectUri>>;
47
+ /**
48
+ * Create a Redirect URI
49
+ * @return The created Redirect URI
50
+ */
51
+ create({ requestBody, overrides, }: CreateRedirectUrisParams & Overrides): Promise<NylasResponse<RedirectUri>>;
52
+ /**
53
+ * Update a Redirect URI
54
+ * @return The updated Redirect URI
55
+ */
56
+ update({ redirectUriId, requestBody, overrides, }: UpdateRedirectUrisParams & Overrides): Promise<NylasResponse<RedirectUri>>;
57
+ /**
58
+ * Delete a Redirect URI
59
+ * @return The deleted Redirect URI
60
+ */
61
+ destroy({ redirectUriId, overrides, }: DestroyRedirectUrisParams & Overrides): Promise<NylasResponse<NylasDeleteResponse>>;
62
+ }
63
+ export {};
@@ -0,0 +1,55 @@
1
+ import APIClient from '../apiClient';
2
+ import { OverridableNylasConfig } from '../config';
3
+ import { ListQueryParams } from '../models/listQueryParams';
4
+ import { NylasResponse, NylasListResponse, ListResponseInnerType } from '../models/response';
5
+ interface ListParams<T> {
6
+ queryParams?: ListQueryParams;
7
+ path: string;
8
+ overrides?: OverridableNylasConfig;
9
+ useGenerator?: boolean;
10
+ }
11
+ interface FindParams<T> {
12
+ path: string;
13
+ queryParams?: Record<string, any>;
14
+ overrides?: OverridableNylasConfig;
15
+ }
16
+ interface PayloadParams<T> {
17
+ path: string;
18
+ queryParams?: Record<string, any>;
19
+ requestBody: Record<string, any>;
20
+ overrides?: OverridableNylasConfig;
21
+ }
22
+ interface DestroyParams {
23
+ path: string;
24
+ queryParams?: Record<string, any>;
25
+ overrides?: OverridableNylasConfig;
26
+ }
27
+ type List<T> = NylasListResponse<ListResponseInnerType<T>>;
28
+ /**
29
+ * Base class for Nylas API resources
30
+ *
31
+ * @ignore No public constructor or functions
32
+ */
33
+ export declare class Resource {
34
+ protected apiClient: APIClient;
35
+ /**
36
+ * @param apiClient client The configured Nylas API client
37
+ */
38
+ constructor(apiClient: APIClient);
39
+ private fetchList;
40
+ private listIterator;
41
+ protected _list<T extends List<T>>(listParams: ListParams<T>): AsyncListResponse<T>;
42
+ protected _find<T>({ path, queryParams, overrides, }: FindParams<T>): Promise<NylasResponse<T>>;
43
+ private payloadRequest;
44
+ protected _create<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
45
+ protected _update<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
46
+ protected _updatePatch<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
47
+ protected _destroy<T>({ path, queryParams, overrides, }: DestroyParams): Promise<T>;
48
+ }
49
+ type ListYieldReturn<T> = T & {
50
+ next: () => Promise<IteratorResult<T, undefined>>;
51
+ };
52
+ export interface AsyncListResponse<T> extends Promise<ListYieldReturn<T>> {
53
+ [Symbol.asyncIterator](): AsyncGenerator<T, undefined>;
54
+ }
55
+ export {};
@@ -0,0 +1,79 @@
1
+ import { AsyncListResponse, Resource } from './resource';
2
+ import { Overrides } from '../config';
3
+ import { NylasResponse, NylasListResponse } from '../models/response';
4
+ import { CreateWebhookRequest, UpdateWebhookRequest, Webhook, WebhookDeleteResponse, WebhookIpAddressesResponse, WebhookWithSecret } from '../models/webhooks';
5
+ /**
6
+ * @property webhookId The ID of the webhook destination to update
7
+ */
8
+ interface FindWebhookParams {
9
+ webhookId: string;
10
+ }
11
+ /**
12
+ * @property requestBody The webhook destination details
13
+ */
14
+ interface CreateWebhookParams {
15
+ requestBody: CreateWebhookRequest;
16
+ }
17
+ /**
18
+ * @property webhookId The ID of the webhook destination to update
19
+ * @property requestBody The updated webview destination details
20
+ */
21
+ interface UpdateWebhookParams {
22
+ webhookId: string;
23
+ requestBody: UpdateWebhookRequest;
24
+ }
25
+ /**
26
+ * @property webhookId The ID of the webhook destination to delete
27
+ */
28
+ interface DestroyWebhookParams {
29
+ webhookId: string;
30
+ }
31
+ /**
32
+ * Nylas Webhooks API
33
+ *
34
+ * The Nylas Webhooks API allows your application to receive notifications in real-time when certain events occur.
35
+ */
36
+ export declare class Webhooks extends Resource {
37
+ /**
38
+ * List all webhook destinations for the application
39
+ * @returns The list of webhook destinations
40
+ */
41
+ list({ overrides }?: Overrides): AsyncListResponse<NylasListResponse<Webhook>>;
42
+ /**
43
+ * Return a webhook destination
44
+ * @return The webhook destination
45
+ */
46
+ find({ webhookId, overrides, }: FindWebhookParams & Overrides): Promise<NylasResponse<Webhook>>;
47
+ /**
48
+ * Create a webhook destination
49
+ * @returns The created webhook destination
50
+ */
51
+ create({ requestBody, overrides, }: CreateWebhookParams & Overrides): Promise<NylasResponse<Webhook>>;
52
+ /**
53
+ * Update a webhook destination
54
+ * @returns The updated webhook destination
55
+ */
56
+ update({ webhookId, requestBody, overrides, }: UpdateWebhookParams & Overrides): Promise<NylasResponse<Webhook>>;
57
+ /**
58
+ * Delete a webhook destination
59
+ * @returns The deletion response
60
+ */
61
+ destroy({ webhookId, overrides, }: DestroyWebhookParams & Overrides): Promise<WebhookDeleteResponse>;
62
+ /**
63
+ * Update the webhook secret value for a destination
64
+ * @returns The updated webhook destination with the webhook secret
65
+ */
66
+ rotateSecret({ webhookId, overrides, }: DestroyWebhookParams & Overrides): Promise<NylasResponse<WebhookWithSecret>>;
67
+ /**
68
+ * Get the current list of IP addresses that Nylas sends webhooks from
69
+ * @returns The list of IP addresses that Nylas sends webhooks from
70
+ */
71
+ ipAddresses({ overrides }?: Overrides): Promise<NylasResponse<WebhookIpAddressesResponse>>;
72
+ /**
73
+ * Extract the challenge parameter from a URL
74
+ * @param url The URL sent by Nylas containing the challenge parameter
75
+ * @returns The challenge parameter
76
+ */
77
+ extractChallengeParameter(url: string): string;
78
+ }
79
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A utility function that recursively converts all keys in an object to camelCase.
3
+ * @param obj The object to convert
4
+ * @param exclude An array of keys to exclude from conversion
5
+ * @returns The converted object
6
+ * @ignore Not for public use.
7
+ */
8
+ export declare function objKeysToCamelCase(obj: Record<string, unknown>, exclude?: string[]): any;
9
+ /**
10
+ * A utility function that recursively converts all keys in an object to snake_case.
11
+ * @param obj The object to convert
12
+ * @param exclude An array of keys to exclude from conversion
13
+ * @returns The converted object
14
+ */
15
+ export declare function objKeysToSnakeCase(obj: Record<string, unknown>, exclude?: string[]): any;
16
+ /**
17
+ * A better "Partial" type that makes all properties optional, including nested ones.
18
+ * @see https://grrr.tech/posts/2021/typescript-partial/
19
+ */
20
+ export type Subset<K> = {
21
+ [attr in keyof K]?: K[attr] extends object ? Subset<K[attr]> : K[attr] extends object | null ? Subset<K[attr]> | null : K[attr] extends object | null | undefined ? Subset<K[attr]> | null | undefined : K[attr];
22
+ };
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "6.10.0",
3
+ "version": "7.0.0-beta.1",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
- "main": "lib/nylas.js",
6
- "types": "lib/nylas.d.ts",
5
+ "main": "lib/cjs/nylas.js",
6
+ "types": "lib/types/nylas.d.ts",
7
+ "module": "lib/esm/nylas.js",
7
8
  "files": [
8
9
  "lib"
9
10
  ],
11
+ "engines": {
12
+ "node": ">=16"
13
+ },
10
14
  "scripts": {
11
15
  "test": "jest",
12
16
  "test:coverage": "npm run test -- --coverage",
@@ -15,24 +19,11 @@
15
19
  "lint:ci": "npm run lint:fix -- --quiet",
16
20
  "lint:prettier": "prettier --write '**/*.{ts,js}'",
17
21
  "lint:prettier:check": "prettier --check '**/*.{ts,js}'",
18
- "build": "tsc",
22
+ "build": "rm -rf lib && npm run build-esm && npm run build-cjs",
23
+ "build-esm": "tsc -p tsconfig.esm.json",
24
+ "build-cjs": "tsc -p tsconfig.cjs.json",
19
25
  "prepare": "npm run build",
20
- "watch": "nodemon -w src --exec npm run build"
21
- },
22
- "jest": {
23
- "preset": "ts-jest/presets/js-with-ts",
24
- "globals": {
25
- "ts-jest": {
26
- "tsConfig": "tsconfig.test.json"
27
- }
28
- },
29
- "coverageThreshold": {
30
- "global": {
31
- "functions": 80,
32
- "lines": 80,
33
- "statements": 80
34
- }
35
- }
26
+ "build:docs": "typedoc --out docs"
36
27
  },
37
28
  "keywords": [
38
29
  "email",
@@ -43,39 +34,37 @@
43
34
  "author": "Nylas, Inc.",
44
35
  "license": "MIT",
45
36
  "dependencies": {
46
- "abort-controller": "^3.0.0",
47
- "backoff": "^2.5.0",
48
- "form-data": "^4.0.0",
49
- "JSONStream": "^1.3.5",
50
- "node-fetch": "^2.6.1",
51
- "uuid": "^8.3.2",
52
- "websocket": "^1.0.34"
37
+ "change-case": "^4.1.2",
38
+ "node-fetch": "^2.6.12",
39
+ "sha256": "^0.2.0",
40
+ "uuid": "^8.3.2"
53
41
  },
54
42
  "devDependencies": {
55
- "@babel/cli": "^7.13.16",
56
43
  "@babel/core": "^7.3.3",
57
- "@babel/plugin-proposal-object-rest-spread": "^7.3.2",
58
- "@babel/preset-env": "^7.3.1",
59
- "@types/backoff": "^2.5.1",
60
- "@types/jest": "^25.1.4",
61
- "@types/node-fetch": "^2.5.8",
44
+ "@types/jest": "^29.5.2",
45
+ "@types/node-fetch": "^2.6.4",
46
+ "@types/sha256": "^0.2.0",
62
47
  "@types/uuid": "^8.3.4",
63
- "@types/websocket": "^1.0.5",
64
48
  "@typescript-eslint/eslint-plugin": "^2.25.0",
65
49
  "@typescript-eslint/parser": "^2.25.0",
66
- "babel-eslint": "^10.0.1",
67
50
  "eslint": "^5.14.0",
68
51
  "eslint-config-prettier": "^4.0.0",
69
52
  "eslint-plugin-custom-rules": "^0.0.0",
70
53
  "eslint-plugin-prettier": "^3.0.1",
71
- "jest": "^24.9.0",
54
+ "jest": "^29.6.1",
72
55
  "prettier": "^1.19.1",
73
- "pretty-format": "^25.2.6",
74
- "ts-jest": "^25.2.1",
75
- "typescript": "^3.8.3"
56
+ "ts-jest": "^29.1.1",
57
+ "typedoc": "^0.24.8",
58
+ "typedoc-plugin-rename-defaults": "^0.6.5",
59
+ "typescript": "^4.9.5"
76
60
  },
77
61
  "repository": {
78
62
  "type": "git",
79
63
  "url": "https://github.com/nylas/nylas-nodejs.git"
64
+ },
65
+ "exports": {
66
+ "import": "./lib/esm/nylas.js",
67
+ "require": "./lib/cjs/nylas.js",
68
+ "types": "./lib/types/nylas.d.ts"
80
69
  }
81
70
  }
package/lib/config.d.ts DELETED
@@ -1,52 +0,0 @@
1
- import { WebhookTriggers } from './models/webhook';
2
- export declare let apiServer: string | null;
3
- export declare function setApiServer(newApiServer: string | null): void;
4
- export declare let clientSecret: string;
5
- export declare function setClientSecret(newClientSecret: string): void;
6
- export declare let timeout: number;
7
- export declare function setTimeout(newTimeout: number): void;
8
- export declare type NylasConfig = {
9
- /** Nylas application client ID */
10
- clientId: string;
11
- /** Nylas application client secret */
12
- clientSecret: string;
13
- /** API Server base URL */
14
- apiServer?: string;
15
- /** Timeout for outgoing API calls, in milliseconds */
16
- timeout?: number;
17
- };
18
- export declare enum ResponseType {
19
- CODE = "code",
20
- TOKEN = "token"
21
- }
22
- export declare type AuthenticateUrlConfig = {
23
- redirectURI: string;
24
- redirectOnError?: boolean;
25
- loginHint?: string;
26
- state?: string;
27
- provider?: string;
28
- scopes?: string[];
29
- responseType?: ResponseType;
30
- };
31
- export declare enum Region {
32
- Us = "us",
33
- Ireland = "ireland"
34
- }
35
- export declare const DEFAULT_REGION = Region.Us;
36
- export declare const regionConfig: {
37
- us: {
38
- nylasAPIUrl: string;
39
- dashboardApiUrl: string;
40
- callbackDomain: string;
41
- websocketDomain: string;
42
- telemetryApiUrl: string;
43
- };
44
- ireland: {
45
- nylasAPIUrl: string;
46
- dashboardApiUrl: string;
47
- callbackDomain: string;
48
- websocketDomain: string;
49
- telemetryApiUrl: string;
50
- };
51
- };
52
- export declare const DEFAULT_WEBHOOK_TRIGGERS: WebhookTriggers[];
package/lib/config.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- var webhook_1 = require("./models/webhook");
5
- exports.apiServer = null;
6
- function setApiServer(newApiServer) {
7
- exports.apiServer = newApiServer;
8
- }
9
- exports.setApiServer = setApiServer;
10
- exports.clientSecret = '';
11
- function setClientSecret(newClientSecret) {
12
- exports.clientSecret = newClientSecret;
13
- }
14
- exports.setClientSecret = setClientSecret;
15
- exports.timeout = 0;
16
- function setTimeout(newTimeout) {
17
- exports.timeout = newTimeout;
18
- }
19
- exports.setTimeout = setTimeout;
20
- var ResponseType;
21
- (function (ResponseType) {
22
- ResponseType["CODE"] = "code";
23
- ResponseType["TOKEN"] = "token";
24
- })(ResponseType = exports.ResponseType || (exports.ResponseType = {}));
25
- var Region;
26
- (function (Region) {
27
- Region["Us"] = "us";
28
- Region["Ireland"] = "ireland";
29
- })(Region = exports.Region || (exports.Region = {}));
30
- exports.DEFAULT_REGION = Region.Us;
31
- exports.regionConfig = (_a = {},
32
- _a[Region.Us] = {
33
- nylasAPIUrl: 'https://api.nylas.com',
34
- dashboardApiUrl: 'https://dashboard-api.nylas.com',
35
- callbackDomain: 'cb.nylas.com',
36
- websocketDomain: 'tunnel.nylas.com',
37
- telemetryApiUrl: 'https://cli.nylas.com',
38
- },
39
- _a[Region.Ireland] = {
40
- nylasAPIUrl: 'https://ireland.api.nylas.com',
41
- dashboardApiUrl: 'https://ireland.dashboard.nylas.com',
42
- callbackDomain: 'cb.nylas.com',
43
- websocketDomain: 'tunnel.nylas.com',
44
- telemetryApiUrl: 'https://cli.nylas.com',
45
- },
46
- _a);
47
- exports.DEFAULT_WEBHOOK_TRIGGERS = Object.values(webhook_1.WebhookTriggers);
@@ -1,18 +0,0 @@
1
- import Model from './model';
2
- import { Attribute } from './attributes';
3
- export declare type AccessTokenProperties = {
4
- accessToken: string;
5
- accountId: string;
6
- emailAddress: string;
7
- provider: string;
8
- tokenType: string;
9
- };
10
- export default class AccessToken extends Model implements AccessTokenProperties {
11
- accessToken: string;
12
- accountId: string;
13
- emailAddress: string;
14
- provider: string;
15
- tokenType: string;
16
- static attributes: Record<string, Attribute>;
17
- constructor(props?: AccessTokenProperties);
18
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var model_1 = __importDefault(require("./model"));
20
- var attributes_1 = __importDefault(require("./attributes"));
21
- var AccessToken = /** @class */ (function (_super) {
22
- __extends(AccessToken, _super);
23
- function AccessToken(props) {
24
- var _this = _super.call(this) || this;
25
- _this.accessToken = '';
26
- _this.accountId = '';
27
- _this.emailAddress = '';
28
- _this.provider = '';
29
- _this.tokenType = 'bearer';
30
- _this.initAttributes(props);
31
- return _this;
32
- }
33
- AccessToken.attributes = {
34
- accessToken: attributes_1.default.String({
35
- modelKey: 'accessToken',
36
- jsonKey: 'access_token',
37
- }),
38
- accountId: attributes_1.default.String({
39
- modelKey: 'accountId',
40
- jsonKey: 'account_id',
41
- }),
42
- emailAddress: attributes_1.default.String({
43
- modelKey: 'emailAddress',
44
- jsonKey: 'email_address',
45
- }),
46
- provider: attributes_1.default.String({
47
- modelKey: 'provider',
48
- }),
49
- tokenType: attributes_1.default.String({
50
- modelKey: 'tokenType',
51
- jsonKey: 'token_type',
52
- }),
53
- };
54
- return AccessToken;
55
- }(model_1.default));
56
- exports.default = AccessToken;
@@ -1,27 +0,0 @@
1
- import RestfulModel from './restful-model';
2
- import { Attribute } from './attributes';
3
- import NylasConnection from '../nylas-connection';
4
- export declare type AccountProperties = {
5
- name: string;
6
- emailAddress: string;
7
- provider: string;
8
- organizationUnit: string;
9
- syncState: string;
10
- linkedAt: Date;
11
- billingState?: string;
12
- accessToken?: string;
13
- };
14
- export default class Account extends RestfulModel implements AccountProperties {
15
- name: string;
16
- emailAddress: string;
17
- provider: string;
18
- organizationUnit: string;
19
- syncState: string;
20
- linkedAt: Date;
21
- accessToken: string;
22
- billingState?: string;
23
- static collectionName: string;
24
- static endpointName: string;
25
- static attributes: Record<string, Attribute>;
26
- constructor(connection: NylasConnection, props?: AccountProperties);
27
- }
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- var restful_model_1 = __importDefault(require("./restful-model"));
31
- var attributes_1 = __importDefault(require("./attributes"));
32
- var Account = /** @class */ (function (_super) {
33
- __extends(Account, _super);
34
- function Account(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.name = '';
37
- _this.emailAddress = '';
38
- _this.provider = '';
39
- _this.organizationUnit = '';
40
- _this.syncState = '';
41
- _this.linkedAt = new Date();
42
- _this.accessToken = '';
43
- _this.initAttributes(props);
44
- return _this;
45
- }
46
- Account.collectionName = 'accounts';
47
- Account.endpointName = 'account';
48
- Account.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
49
- modelKey: 'name',
50
- }), emailAddress: attributes_1.default.String({
51
- modelKey: 'emailAddress',
52
- jsonKey: 'email_address',
53
- }), provider: attributes_1.default.String({
54
- modelKey: 'provider',
55
- }), organizationUnit: attributes_1.default.String({
56
- modelKey: 'organizationUnit',
57
- jsonKey: 'organization_unit',
58
- }), syncState: attributes_1.default.String({
59
- modelKey: 'syncState',
60
- jsonKey: 'sync_state',
61
- }), billingState: attributes_1.default.String({
62
- modelKey: 'billingState',
63
- jsonKey: 'billing_state',
64
- }), linkedAt: attributes_1.default.DateTime({
65
- modelKey: 'linkedAt',
66
- jsonKey: 'linked_at',
67
- }), accessToken: attributes_1.default.String({
68
- modelKey: 'accessToken',
69
- jsonKey: 'access_token',
70
- }) });
71
- return Account;
72
- }(restful_model_1.default));
73
- exports.default = Account;
@@ -1,14 +0,0 @@
1
- import Model from './model';
2
- import { Attribute } from './attributes';
3
- export declare type ApplicationDetailsProperties = {
4
- applicationName?: string;
5
- iconUrl?: string;
6
- redirectUris?: string[];
7
- };
8
- export default class ApplicationDetails extends Model implements ApplicationDetailsProperties {
9
- applicationName: string;
10
- iconUrl: string;
11
- redirectUris: string[];
12
- static attributes: Record<string, Attribute>;
13
- constructor(props?: ApplicationDetailsProperties);
14
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var model_1 = __importDefault(require("./model"));
20
- var attributes_1 = __importDefault(require("./attributes"));
21
- var ApplicationDetails = /** @class */ (function (_super) {
22
- __extends(ApplicationDetails, _super);
23
- function ApplicationDetails(props) {
24
- var _this = _super.call(this) || this;
25
- _this.applicationName = '';
26
- _this.iconUrl = '';
27
- _this.redirectUris = [];
28
- _this.initAttributes(props);
29
- return _this;
30
- }
31
- ApplicationDetails.attributes = {
32
- applicationName: attributes_1.default.String({
33
- modelKey: 'applicationName',
34
- jsonKey: 'application_name',
35
- }),
36
- iconUrl: attributes_1.default.String({
37
- modelKey: 'iconUrl',
38
- jsonKey: 'icon_url',
39
- }),
40
- redirectUris: attributes_1.default.StringList({
41
- modelKey: 'redirectUris',
42
- jsonKey: 'redirect_uris',
43
- }),
44
- };
45
- return ApplicationDetails;
46
- }(model_1.default));
47
- exports.default = ApplicationDetails;