nylas 7.0.0-beta.0 → 7.0.0-beta.2
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/README.md +27 -19
- package/lib/cjs/apiClient.js +114 -0
- package/lib/cjs/config.js +32 -0
- package/lib/cjs/models/applicationDetails.js +2 -0
- package/lib/cjs/models/auth.js +2 -0
- package/lib/cjs/models/availability.js +11 -0
- package/lib/cjs/models/calendars.js +2 -0
- package/lib/cjs/models/error.js +53 -0
- package/lib/cjs/models/events.js +2 -0
- package/lib/cjs/models/grants.js +2 -0
- package/lib/cjs/models/listQueryParams.js +2 -0
- package/lib/cjs/models/redirectUri.js +2 -0
- package/lib/cjs/models/response.js +2 -0
- package/lib/cjs/models/webhooks.js +18 -0
- package/lib/cjs/nylas.js +34 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/resources/applications.js +30 -0
- package/lib/cjs/resources/auth.js +153 -0
- package/lib/cjs/resources/calendars.js +78 -0
- package/lib/cjs/resources/events.js +69 -0
- package/lib/cjs/resources/grants.js +65 -0
- package/lib/cjs/resources/redirectUris.js +64 -0
- package/lib/cjs/resources/resource.js +111 -0
- package/lib/cjs/resources/webhooks.js +98 -0
- package/lib/cjs/utils.js +58 -0
- package/lib/cjs/version.js +5 -0
- package/lib/esm/apiClient.js +111 -0
- package/lib/esm/config.js +29 -0
- package/lib/esm/models/applicationDetails.js +1 -0
- package/lib/esm/models/auth.js +1 -0
- package/lib/esm/models/availability.js +8 -0
- package/lib/esm/models/calendars.js +1 -0
- package/lib/esm/models/error.js +45 -0
- package/lib/esm/models/events.js +1 -0
- package/lib/esm/models/grants.js +1 -0
- package/lib/esm/models/listQueryParams.js +1 -0
- package/lib/esm/models/redirectUri.js +1 -0
- package/lib/esm/models/response.js +1 -0
- package/lib/esm/models/webhooks.js +15 -0
- package/lib/esm/nylas.js +31 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/resources/applications.js +26 -0
- package/lib/esm/resources/auth.js +149 -0
- package/lib/esm/resources/calendars.js +74 -0
- package/lib/esm/resources/events.js +65 -0
- package/lib/esm/resources/grants.js +61 -0
- package/lib/esm/resources/redirectUris.js +60 -0
- package/lib/esm/resources/resource.js +107 -0
- package/lib/esm/resources/webhooks.js +94 -0
- package/lib/esm/utils.js +53 -0
- package/lib/esm/version.js +2 -0
- package/lib/types/apiClient.d.ts +65 -0
- package/lib/types/config.d.ts +50 -0
- package/lib/types/models/applicationDetails.d.ts +93 -0
- package/lib/types/models/auth.d.ts +196 -0
- package/lib/types/models/availability.d.ts +159 -0
- package/lib/types/models/calendars.d.ts +121 -0
- package/lib/types/models/error.d.ts +104 -0
- package/lib/types/models/events.d.ts +494 -0
- package/lib/types/models/grants.d.ts +134 -0
- package/lib/types/models/listQueryParams.d.ts +4 -0
- package/lib/types/models/redirectUri.d.ts +71 -0
- package/lib/types/models/response.d.ts +40 -0
- package/lib/types/models/webhooks.d.ts +45 -0
- package/lib/types/nylas.d.ts +44 -0
- package/lib/types/resources/applications.d.ts +26 -0
- package/lib/types/resources/auth.d.ts +66 -0
- package/lib/types/resources/calendars.d.ts +97 -0
- package/lib/types/resources/events.d.ts +87 -0
- package/lib/types/resources/grants.d.ts +63 -0
- package/lib/types/resources/redirectUris.d.ts +63 -0
- package/lib/types/resources/resource.d.ts +55 -0
- package/lib/types/resources/webhooks.d.ts +79 -0
- package/lib/types/utils.d.ts +22 -0
- package/lib/types/version.d.ts +1 -0
- package/package.json +33 -42
- package/lib/config.d.ts +0 -70
- package/lib/config.js +0 -68
- package/lib/models/access-token.d.ts +0 -18
- package/lib/models/access-token.js +0 -56
- package/lib/models/account.d.ts +0 -27
- package/lib/models/account.js +0 -73
- package/lib/models/application-details.d.ts +0 -14
- package/lib/models/application-details.js +0 -47
- package/lib/models/attributes.d.ts +0 -151
- package/lib/models/attributes.js +0 -382
- package/lib/models/calendar-availability.d.ts +0 -76
- package/lib/models/calendar-availability.js +0 -121
- package/lib/models/calendar-restful-model-collection.d.ts +0 -17
- package/lib/models/calendar-restful-model-collection.js +0 -181
- package/lib/models/calendar.d.ts +0 -31
- package/lib/models/calendar.js +0 -93
- package/lib/models/component-restful-model-collection.d.ts +0 -9
- package/lib/models/component-restful-model-collection.js +0 -34
- package/lib/models/component.d.ts +0 -37
- package/lib/models/component.js +0 -91
- package/lib/models/connect.d.ts +0 -73
- package/lib/models/connect.js +0 -193
- package/lib/models/contact-restful-model-collection.d.ts +0 -9
- package/lib/models/contact-restful-model-collection.js +0 -60
- package/lib/models/contact.d.ts +0 -129
- package/lib/models/contact.js +0 -289
- package/lib/models/delta-collection.d.ts +0 -17
- package/lib/models/delta-collection.js +0 -139
- package/lib/models/delta-stream.d.ts +0 -32
- package/lib/models/delta-stream.js +0 -250
- package/lib/models/delta.d.ts +0 -28
- package/lib/models/delta.js +0 -88
- package/lib/models/deltas.d.ts +0 -17
- package/lib/models/deltas.js +0 -49
- package/lib/models/draft.d.ts +0 -27
- package/lib/models/draft.js +0 -156
- package/lib/models/email-participant.d.ts +0 -13
- package/lib/models/email-participant.js +0 -46
- package/lib/models/event-conferencing.d.ts +0 -34
- package/lib/models/event-conferencing.js +0 -71
- package/lib/models/event-notification.d.ts +0 -27
- package/lib/models/event-notification.js +0 -62
- package/lib/models/event-participant.d.ts +0 -19
- package/lib/models/event-participant.js +0 -56
- package/lib/models/event.d.ts +0 -96
- package/lib/models/event.js +0 -297
- package/lib/models/file.d.ts +0 -29
- package/lib/models/file.js +0 -136
- package/lib/models/folder.d.ts +0 -21
- package/lib/models/folder.js +0 -69
- package/lib/models/free-busy.d.ts +0 -58
- package/lib/models/free-busy.js +0 -132
- package/lib/models/job-status-restful-model-collection.d.ts +0 -9
- package/lib/models/job-status-restful-model-collection.js +0 -38
- package/lib/models/job-status.d.ts +0 -24
- package/lib/models/job-status.js +0 -68
- package/lib/models/management-account.d.ts +0 -63
- package/lib/models/management-account.js +0 -187
- package/lib/models/management-model-collection.d.ts +0 -10
- package/lib/models/management-model-collection.js +0 -39
- package/lib/models/management-model.d.ts +0 -6
- package/lib/models/management-model.js +0 -29
- package/lib/models/message-restful-model-collection.d.ts +0 -26
- package/lib/models/message-restful-model-collection.js +0 -80
- package/lib/models/message.d.ts +0 -57
- package/lib/models/message.js +0 -173
- package/lib/models/model-collection.d.ts +0 -25
- package/lib/models/model-collection.js +0 -201
- package/lib/models/model.d.ts +0 -12
- package/lib/models/model.js +0 -64
- package/lib/models/neural-categorizer.d.ts +0 -28
- package/lib/models/neural-categorizer.js +0 -139
- package/lib/models/neural-clean-conversation.d.ts +0 -16
- package/lib/models/neural-clean-conversation.js +0 -114
- package/lib/models/neural-ocr.d.ts +0 -14
- package/lib/models/neural-ocr.js +0 -50
- package/lib/models/neural-sentiment-analysis.d.ts +0 -20
- package/lib/models/neural-sentiment-analysis.js +0 -56
- package/lib/models/neural-signature-contact.d.ts +0 -43
- package/lib/models/neural-signature-contact.js +0 -142
- package/lib/models/neural-signature-extraction.d.ts +0 -17
- package/lib/models/neural-signature-extraction.js +0 -54
- package/lib/models/neural.d.ts +0 -36
- package/lib/models/neural.js +0 -163
- package/lib/models/nylas-api-error.d.ts +0 -26
- package/lib/models/nylas-api-error.js +0 -61
- package/lib/models/outbox-job-status.d.ts +0 -20
- package/lib/models/outbox-job-status.js +0 -64
- package/lib/models/outbox-message.d.ts +0 -16
- package/lib/models/outbox-message.js +0 -54
- package/lib/models/outbox.d.ts +0 -35
- package/lib/models/outbox.js +0 -158
- package/lib/models/resource.d.ts +0 -22
- package/lib/models/resource.js +0 -66
- package/lib/models/restful-model-collection.d.ts +0 -15
- package/lib/models/restful-model-collection.js +0 -169
- package/lib/models/restful-model-instance.d.ts +0 -9
- package/lib/models/restful-model-instance.js +0 -37
- package/lib/models/restful-model.d.ts +0 -36
- package/lib/models/restful-model.js +0 -146
- package/lib/models/scheduler-booking-request.d.ts +0 -64
- package/lib/models/scheduler-booking-request.js +0 -148
- package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
- package/lib/models/scheduler-restful-model-collection.js +0 -133
- package/lib/models/scheduler-time-slot.d.ts +0 -20
- package/lib/models/scheduler-time-slot.js +0 -53
- package/lib/models/scheduler.d.ts +0 -226
- package/lib/models/scheduler.js +0 -446
- package/lib/models/thread.d.ts +0 -49
- package/lib/models/thread.js +0 -127
- package/lib/models/webhook-notification.d.ts +0 -108
- package/lib/models/webhook-notification.js +0 -239
- package/lib/models/webhook.d.ts +0 -50
- package/lib/models/webhook.js +0 -101
- package/lib/models/when.d.ts +0 -23
- package/lib/models/when.js +0 -65
- package/lib/nylas-connection.d.ts +0 -71
- package/lib/nylas-connection.js +0 -258
- package/lib/nylas.d.ts +0 -57
- package/lib/nylas.js +0 -210
- package/lib/server-bindings/express-binding.d.ts +0 -18
- package/lib/server-bindings/express-binding.js +0 -163
- package/lib/server-bindings/server-binding.d.ts +0 -65
- package/lib/server-bindings/server-binding.js +0 -87
- package/lib/services/routes.d.ts +0 -26
- package/lib/services/routes.js +0 -95
- package/lib/services/tunnel.d.ts +0 -29
- package/lib/services/tunnel.js +0 -112
package/lib/services/tunnel.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { client as WebSocketClient } from 'websocket';
|
|
2
|
-
import { Region } from '../config';
|
|
3
|
-
import Nylas from '../nylas';
|
|
4
|
-
import Webhook, { WebhookTriggers } from '../models/webhook';
|
|
5
|
-
import { WebhookDelta } from '../models/webhook-notification';
|
|
6
|
-
export interface OpenWebhookTunnelOptions {
|
|
7
|
-
onMessage: (msg: WebhookDelta) => void;
|
|
8
|
-
onConnectFail?: (error: Error) => void;
|
|
9
|
-
onError?: (error: Error) => void;
|
|
10
|
-
onClose?: (wsClient: WebSocketClient) => void;
|
|
11
|
-
onConnect?: (wsClient: WebSocketClient) => void;
|
|
12
|
-
region?: Region;
|
|
13
|
-
triggers?: WebhookTriggers[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Open a webhook tunnel and register it with the Nylas API
|
|
17
|
-
* 1. Creates a UUID
|
|
18
|
-
* 2. Opens a websocket connection to Nylas' webhook forwarding service,
|
|
19
|
-
* with the UUID as a header
|
|
20
|
-
* 3. Creates a new webhook pointed at the forwarding service with the UUID as the path
|
|
21
|
-
*
|
|
22
|
-
* When an event is received by the forwarding service, it will push directly to this websocket
|
|
23
|
-
* connection
|
|
24
|
-
*
|
|
25
|
-
* @param nylasClient The configured Nylas application
|
|
26
|
-
* @param config Configuration for the webhook tunnel, including callback functions, region, and events to subscribe to
|
|
27
|
-
* @return The webhook details response from the API
|
|
28
|
-
*/
|
|
29
|
-
export declare const openWebhookTunnel: (nylasClient: Nylas, config: OpenWebhookTunnelOptions) => Promise<Webhook>;
|
package/lib/services/tunnel.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var websocket_1 = require("websocket");
|
|
4
|
-
var uuid_1 = require("uuid");
|
|
5
|
-
var config_1 = require("../config");
|
|
6
|
-
var webhook_notification_1 = require("../models/webhook-notification");
|
|
7
|
-
/**
|
|
8
|
-
* Deletes the Nylas webhook
|
|
9
|
-
* @param nylasClient The Nylas application configured with the webhook
|
|
10
|
-
* @param nylasWebhook The Nylas webhook details
|
|
11
|
-
*/
|
|
12
|
-
var deleteTunnelWebhook = function (nylasClient, nylasWebhook) {
|
|
13
|
-
if (nylasWebhook && nylasWebhook.id) {
|
|
14
|
-
/* eslint-disable no-console */
|
|
15
|
-
console.log("Shutting down the webhook tunnel and deleting id: " + nylasWebhook.id);
|
|
16
|
-
/* eslint-enable no-console */
|
|
17
|
-
nylasClient.webhooks
|
|
18
|
-
.delete(nylasWebhook)
|
|
19
|
-
.then(function () { return process.exit(); })
|
|
20
|
-
.catch(function (err) {
|
|
21
|
-
console.warn("Error while trying to deregister the webhook " + nylasWebhook.id + ": " + err.message);
|
|
22
|
-
process.exit();
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Create a webhook to the Nylas forwarding service which will pass messages to our websocket
|
|
28
|
-
* @param nylasClient The configured Nylas application
|
|
29
|
-
* @param callbackDomain The domain name of the callback
|
|
30
|
-
* @param tunnelPath The path to the tunnel
|
|
31
|
-
* @param triggers The list of triggers to subscribe to
|
|
32
|
-
* @return The webhook details response from the API
|
|
33
|
-
*/
|
|
34
|
-
var buildTunnelWebhook = function (nylasClient, callbackDomain, tunnelPath, triggers) {
|
|
35
|
-
var callbackUrl = "https://" + callbackDomain + "/" + tunnelPath;
|
|
36
|
-
return nylasClient.webhooks
|
|
37
|
-
.build({
|
|
38
|
-
callbackUrl: callbackUrl,
|
|
39
|
-
state: 'active',
|
|
40
|
-
test: true,
|
|
41
|
-
triggers: triggers,
|
|
42
|
-
})
|
|
43
|
-
.save()
|
|
44
|
-
.then(function (webhook) {
|
|
45
|
-
// Ensure that, upon all exits, delete the webhook on the Nylas application
|
|
46
|
-
process.on('SIGINT', function () { return deleteTunnelWebhook(nylasClient, webhook); });
|
|
47
|
-
process.on('SIGTERM', function () { return deleteTunnelWebhook(nylasClient, webhook); });
|
|
48
|
-
process.on('SIGBREAK', function () { return deleteTunnelWebhook(nylasClient, webhook); });
|
|
49
|
-
return webhook;
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Open a webhook tunnel and register it with the Nylas API
|
|
54
|
-
* 1. Creates a UUID
|
|
55
|
-
* 2. Opens a websocket connection to Nylas' webhook forwarding service,
|
|
56
|
-
* with the UUID as a header
|
|
57
|
-
* 3. Creates a new webhook pointed at the forwarding service with the UUID as the path
|
|
58
|
-
*
|
|
59
|
-
* When an event is received by the forwarding service, it will push directly to this websocket
|
|
60
|
-
* connection
|
|
61
|
-
*
|
|
62
|
-
* @param nylasClient The configured Nylas application
|
|
63
|
-
* @param config Configuration for the webhook tunnel, including callback functions, region, and events to subscribe to
|
|
64
|
-
* @return The webhook details response from the API
|
|
65
|
-
*/
|
|
66
|
-
exports.openWebhookTunnel = function (nylasClient, config) {
|
|
67
|
-
var triggers = config.triggers || config_1.DEFAULT_WEBHOOK_TRIGGERS;
|
|
68
|
-
var region = config.region || config_1.DEFAULT_REGION;
|
|
69
|
-
var _a = config_1.regionConfig[region], websocketDomain = _a.websocketDomain, callbackDomain = _a.callbackDomain;
|
|
70
|
-
// This UUID will map our websocket to a webhook in the forwarding server
|
|
71
|
-
var tunnelId = uuid_1.v4();
|
|
72
|
-
var client = new websocket_1.client({ closeTimeout: 60000 });
|
|
73
|
-
client.on('connectFailed', function (error) {
|
|
74
|
-
config.onConnectFail && config.onConnectFail(error);
|
|
75
|
-
});
|
|
76
|
-
client.on('connect', function (connection) {
|
|
77
|
-
config.onConnect && config.onConnect(client);
|
|
78
|
-
connection.on('error', function (error) {
|
|
79
|
-
config.onError && config.onError(error);
|
|
80
|
-
});
|
|
81
|
-
connection.on('close', function () {
|
|
82
|
-
config.onClose && config.onClose(client);
|
|
83
|
-
});
|
|
84
|
-
connection.on('message', function (message) {
|
|
85
|
-
// This shouldn't happen. If any of these are seen, open an issue
|
|
86
|
-
if (message.type === 'binary') {
|
|
87
|
-
config.onError &&
|
|
88
|
-
config.onError(new Error('Unknown binary message received'));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
var req = JSON.parse(message.utf8Data);
|
|
93
|
-
var deltas = JSON.parse(req.body).deltas;
|
|
94
|
-
deltas.forEach(function (delta) {
|
|
95
|
-
return config.onMessage(new webhook_notification_1.WebhookDelta().fromJSON(delta));
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
config.onError &&
|
|
100
|
-
config.onError(new Error("Error converting Nylas websocket event to JSON: " + (e &&
|
|
101
|
-
e.message)));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
client.connect("wss://" + websocketDomain, undefined, undefined, {
|
|
106
|
-
'Client-Id': nylasClient.clientId,
|
|
107
|
-
'Client-Secret': nylasClient.clientSecret,
|
|
108
|
-
'Tunnel-Id': tunnelId,
|
|
109
|
-
Region: region,
|
|
110
|
-
});
|
|
111
|
-
return buildTunnelWebhook(nylasClient, callbackDomain, tunnelId, triggers);
|
|
112
|
-
};
|