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.
- package/README.md +26 -14
- package/lib/cjs/apiClient.js +115 -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/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/esm/apiClient.js +112 -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/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/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/package.json +28 -39
- package/lib/config.d.ts +0 -52
- package/lib/config.js +0 -47
- 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 -33
- package/lib/models/calendar.js +0 -97
- 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-reminder-method.d.ts +0 -18
- package/lib/models/event-reminder-method.js +0 -47
- package/lib/models/event.d.ts +0 -104
- package/lib/models/event.js +0 -308
- 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 -62
- 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/rate-limit-error.d.ts +0 -26
- package/lib/models/rate-limit-error.js +0 -47
- 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 -133
- package/lib/models/webhook-notification.js +0 -314
- package/lib/models/webhook.d.ts +0 -50
- package/lib/models/webhook.js +0 -101
- package/lib/models/when.d.ts +0 -29
- package/lib/models/when.js +0 -76
- package/lib/nylas-connection.d.ts +0 -71
- package/lib/nylas-connection.js +0 -282
- package/lib/nylas.d.ts +0 -34
- package/lib/nylas.js +0 -199
- package/lib/services/tunnel.d.ts +0 -28
- package/lib/services/tunnel.js +0 -89
package/lib/services/tunnel.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { client as WebSocketClient } from 'websocket';
|
|
2
|
-
import { Region } from '../config';
|
|
3
|
-
import Webhook, { WebhookTriggers } from '../models/webhook';
|
|
4
|
-
import { WebhookDelta } from '../models/webhook-notification';
|
|
5
|
-
export interface OpenWebhookTunnelOptions {
|
|
6
|
-
onMessage: (msg: WebhookDelta) => void;
|
|
7
|
-
onConnectFail?: (error: Error) => void;
|
|
8
|
-
onError?: (error: Error) => void;
|
|
9
|
-
onClose?: (wsClient: WebSocketClient) => void;
|
|
10
|
-
onConnect?: (wsClient: WebSocketClient) => void;
|
|
11
|
-
region?: Region;
|
|
12
|
-
triggers?: WebhookTriggers[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Open a webhook tunnel and register it with the Nylas API
|
|
16
|
-
* 1. Creates a UUID
|
|
17
|
-
* 2. Opens a websocket connection to Nylas' webhook forwarding service,
|
|
18
|
-
* with the UUID as a header
|
|
19
|
-
* 3. Creates a new webhook pointed at the forwarding service with the UUID as the path
|
|
20
|
-
*
|
|
21
|
-
* When an event is received by the forwarding service, it will push directly to this websocket
|
|
22
|
-
* connection
|
|
23
|
-
*
|
|
24
|
-
* @param config Configuration for the webhook tunnel, including callback functions,
|
|
25
|
-
* region, and events to subscribe to
|
|
26
|
-
* @return The webhook details response from the API
|
|
27
|
-
*/
|
|
28
|
-
export declare const openWebhookTunnel: (config: OpenWebhookTunnelOptions) => Promise<Webhook>;
|
package/lib/services/tunnel.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var websocket_1 = require("websocket");
|
|
7
|
-
var uuid_1 = require("uuid");
|
|
8
|
-
var config_1 = require("../config");
|
|
9
|
-
var nylas_1 = __importDefault(require("../nylas"));
|
|
10
|
-
var webhook_notification_1 = require("../models/webhook-notification");
|
|
11
|
-
/**
|
|
12
|
-
* Create a webhook to the Nylas forwarding service which will pass messages to our websocket
|
|
13
|
-
* @param callbackDomain The domain name of the callback
|
|
14
|
-
* @param tunnelPath The path to the tunnel
|
|
15
|
-
* @param triggers The list of triggers to subscribe to
|
|
16
|
-
* @return The webhook details response from the API
|
|
17
|
-
*/
|
|
18
|
-
var buildTunnelWebhook = function (callbackDomain, tunnelPath, triggers) {
|
|
19
|
-
var callbackUrl = "https://" + callbackDomain + "/" + tunnelPath;
|
|
20
|
-
return nylas_1.default.webhooks
|
|
21
|
-
.build({
|
|
22
|
-
callbackUrl: callbackUrl,
|
|
23
|
-
state: 'active',
|
|
24
|
-
test: true,
|
|
25
|
-
triggers: triggers,
|
|
26
|
-
})
|
|
27
|
-
.save();
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Open a webhook tunnel and register it with the Nylas API
|
|
31
|
-
* 1. Creates a UUID
|
|
32
|
-
* 2. Opens a websocket connection to Nylas' webhook forwarding service,
|
|
33
|
-
* with the UUID as a header
|
|
34
|
-
* 3. Creates a new webhook pointed at the forwarding service with the UUID as the path
|
|
35
|
-
*
|
|
36
|
-
* When an event is received by the forwarding service, it will push directly to this websocket
|
|
37
|
-
* connection
|
|
38
|
-
*
|
|
39
|
-
* @param config Configuration for the webhook tunnel, including callback functions,
|
|
40
|
-
* region, and events to subscribe to
|
|
41
|
-
* @return The webhook details response from the API
|
|
42
|
-
*/
|
|
43
|
-
exports.openWebhookTunnel = function (config) {
|
|
44
|
-
var triggers = config.triggers || config_1.DEFAULT_WEBHOOK_TRIGGERS;
|
|
45
|
-
var region = config.region || config_1.DEFAULT_REGION;
|
|
46
|
-
var _a = config_1.regionConfig[region], websocketDomain = _a.websocketDomain, callbackDomain = _a.callbackDomain;
|
|
47
|
-
// This UUID will map our websocket to a webhook in the forwarding server
|
|
48
|
-
var tunnelId = uuid_1.v4();
|
|
49
|
-
var client = new websocket_1.client({ closeTimeout: 60000 });
|
|
50
|
-
client.on('connectFailed', function (error) {
|
|
51
|
-
config.onConnectFail && config.onConnectFail(error);
|
|
52
|
-
});
|
|
53
|
-
client.on('connect', function (connection) {
|
|
54
|
-
config.onConnect && config.onConnect(client);
|
|
55
|
-
connection.on('error', function (error) {
|
|
56
|
-
config.onError && config.onError(error);
|
|
57
|
-
});
|
|
58
|
-
connection.on('close', function () {
|
|
59
|
-
config.onClose && config.onClose(client);
|
|
60
|
-
});
|
|
61
|
-
connection.on('message', function (message) {
|
|
62
|
-
// This shouldn't happen. If any of these are seen, open an issue
|
|
63
|
-
if (message.type === 'binary') {
|
|
64
|
-
config.onError &&
|
|
65
|
-
config.onError(new Error('Unknown binary message received'));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
var req = JSON.parse(message.utf8Data);
|
|
70
|
-
var deltas = JSON.parse(req.body).deltas;
|
|
71
|
-
deltas.forEach(function (delta) {
|
|
72
|
-
return config.onMessage(new webhook_notification_1.WebhookDelta().fromJSON(delta));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
config.onError &&
|
|
77
|
-
config.onError(new Error("Error converting Nylas websocket event to JSON: " + (e &&
|
|
78
|
-
e.message)));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
client.connect("wss://" + websocketDomain, undefined, undefined, {
|
|
83
|
-
'Client-Id': nylas_1.default.clientId,
|
|
84
|
-
'Client-Secret': nylas_1.default.clientSecret,
|
|
85
|
-
'Tunnel-Id': tunnelId,
|
|
86
|
-
Region: region,
|
|
87
|
-
});
|
|
88
|
-
return buildTunnelWebhook(callbackDomain, tunnelId, triggers);
|
|
89
|
-
};
|