nylas 7.10.0 → 7.11.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.
- package/lib/cjs/config.js +1 -1
- package/lib/cjs/models/availability.js +1 -1
- package/lib/cjs/models/credentials.js +1 -1
- package/lib/cjs/models/events.js +1 -1
- package/lib/cjs/models/freeBusy.js +1 -1
- package/lib/cjs/models/messages.js +3 -1
- package/lib/cjs/models/webhooks.js +1 -1
- package/lib/cjs/resources/drafts.js +6 -10
- package/lib/cjs/resources/messages.js +3 -5
- package/lib/cjs/utils.js +29 -7
- package/lib/cjs/version.js +1 -1
- package/lib/esm/models/messages.js +2 -0
- package/lib/esm/resources/drafts.js +7 -11
- package/lib/esm/resources/messages.js +4 -6
- package/lib/esm/utils.js +22 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/apiClient.d.ts +0 -2
- package/lib/types/models/attachments.d.ts +0 -2
- package/lib/types/models/folders.d.ts +10 -0
- package/lib/types/models/messages.d.ts +36 -1
- package/lib/types/resources/attachments.d.ts +0 -2
- package/lib/types/resources/resource.d.ts +0 -2
- package/lib/types/utils.d.ts +7 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/config.js
CHANGED
|
@@ -9,4 +9,4 @@ var AvailabilityMethod;
|
|
|
9
9
|
AvailabilityMethod["MaxFairness"] = "max-fairness";
|
|
10
10
|
AvailabilityMethod["MaxAvailability"] = "max-availability";
|
|
11
11
|
AvailabilityMethod["Collective"] = "collective";
|
|
12
|
-
})(AvailabilityMethod
|
|
12
|
+
})(AvailabilityMethod || (exports.AvailabilityMethod = AvailabilityMethod = {}));
|
|
@@ -9,4 +9,4 @@ var CredentialType;
|
|
|
9
9
|
CredentialType["ADMINCONSENT"] = "adminconsent";
|
|
10
10
|
CredentialType["SERVICEACCOUNT"] = "serviceaccount";
|
|
11
11
|
CredentialType["CONNECTOR"] = "connector";
|
|
12
|
-
})(CredentialType
|
|
12
|
+
})(CredentialType || (exports.CredentialType = CredentialType = {}));
|
package/lib/cjs/models/events.js
CHANGED
|
@@ -8,4 +8,6 @@ var MessageFields;
|
|
|
8
8
|
(function (MessageFields) {
|
|
9
9
|
MessageFields["STANDARD"] = "standard";
|
|
10
10
|
MessageFields["INCLUDE_HEADERS"] = "include_headers";
|
|
11
|
-
|
|
11
|
+
MessageFields["INCLUDE_TRACKING_OPTIONS"] = "include_tracking_options";
|
|
12
|
+
MessageFields["RAW_MIME"] = "raw_mime";
|
|
13
|
+
})(MessageFields || (exports.MessageFields = MessageFields = {}));
|
|
@@ -45,4 +45,4 @@ var WebhookTriggers;
|
|
|
45
45
|
WebhookTriggers["BookingRescheduled"] = "booking.rescheduled";
|
|
46
46
|
WebhookTriggers["BookingCancelled"] = "booking.cancelled";
|
|
47
47
|
WebhookTriggers["BookingReminder"] = "booking.reminder";
|
|
48
|
-
})(WebhookTriggers
|
|
48
|
+
})(WebhookTriggers || (exports.WebhookTriggers = WebhookTriggers = {}));
|
|
@@ -43,11 +43,9 @@ class Drafts extends resource_js_1.Resource {
|
|
|
43
43
|
const path = (0, utils_js_2.makePathParams)('/v3/grants/{identifier}/drafts', {
|
|
44
44
|
identifier,
|
|
45
45
|
});
|
|
46
|
-
// Use form data
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}, 0) || 0;
|
|
50
|
-
if (attachmentSize >= messages_js_1.Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
46
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
47
|
+
const totalPayloadSize = (0, utils_js_1.calculateTotalPayloadSize)(requestBody);
|
|
48
|
+
if (totalPayloadSize >= messages_js_1.Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
51
49
|
const form = messages_js_1.Messages._buildFormRequest(requestBody);
|
|
52
50
|
return this.apiClient.request({
|
|
53
51
|
method: 'POST',
|
|
@@ -78,11 +76,9 @@ class Drafts extends resource_js_1.Resource {
|
|
|
78
76
|
identifier,
|
|
79
77
|
draftId,
|
|
80
78
|
});
|
|
81
|
-
// Use form data
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
}, 0) || 0;
|
|
85
|
-
if (attachmentSize >= messages_js_1.Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
79
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
80
|
+
const totalPayloadSize = (0, utils_js_1.calculateTotalPayloadSize)(requestBody);
|
|
81
|
+
if (totalPayloadSize >= messages_js_1.Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
86
82
|
const form = messages_js_1.Messages._buildFormRequest(requestBody);
|
|
87
83
|
return this.apiClient.request({
|
|
88
84
|
method: 'PUT',
|
|
@@ -89,11 +89,9 @@ class Messages extends resource_js_1.Resource {
|
|
|
89
89
|
path,
|
|
90
90
|
overrides,
|
|
91
91
|
};
|
|
92
|
-
// Use form data
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
}, 0) || 0;
|
|
96
|
-
if (attachmentSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
92
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
93
|
+
const totalPayloadSize = (0, utils_js_1.calculateTotalPayloadSize)(requestBody);
|
|
94
|
+
if (totalPayloadSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
97
95
|
requestOptions.form = Messages._buildFormRequest(requestBody);
|
|
98
96
|
}
|
|
99
97
|
else {
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createFileRequestBuilder = createFileRequestBuilder;
|
|
4
|
+
exports.encodeAttachmentStreams = encodeAttachmentStreams;
|
|
5
|
+
exports.objKeysToCamelCase = objKeysToCamelCase;
|
|
6
|
+
exports.objKeysToSnakeCase = objKeysToSnakeCase;
|
|
7
|
+
exports.safePath = safePath;
|
|
8
|
+
exports.makePathParams = makePathParams;
|
|
9
|
+
exports.calculateTotalPayloadSize = calculateTotalPayloadSize;
|
|
4
10
|
const change_case_1 = require("change-case");
|
|
5
11
|
const fs = require("fs");
|
|
6
12
|
const path = require("path");
|
|
@@ -18,7 +24,6 @@ function createFileRequestBuilder(filePath) {
|
|
|
18
24
|
size: stats.size,
|
|
19
25
|
};
|
|
20
26
|
}
|
|
21
|
-
exports.createFileRequestBuilder = createFileRequestBuilder;
|
|
22
27
|
/**
|
|
23
28
|
* Converts a ReadableStream to a base64 encoded string.
|
|
24
29
|
* @param stream The ReadableStream containing the binary data.
|
|
@@ -52,7 +57,6 @@ async function encodeAttachmentStreams(attachments) {
|
|
|
52
57
|
return { ...attachment, content: base64EncodedContent }; // Replace the stream with its base64 string
|
|
53
58
|
}));
|
|
54
59
|
}
|
|
55
|
-
exports.encodeAttachmentStreams = encodeAttachmentStreams;
|
|
56
60
|
/**
|
|
57
61
|
* Applies the casing function and ensures numeric parts are preceded by underscores in snake_case.
|
|
58
62
|
* @param casingFunction The original casing function.
|
|
@@ -111,7 +115,6 @@ function convertCase(obj, casingFunction, excludeKeys) {
|
|
|
111
115
|
function objKeysToCamelCase(obj, exclude) {
|
|
112
116
|
return convertCase(obj, change_case_1.camelCase, exclude);
|
|
113
117
|
}
|
|
114
|
-
exports.objKeysToCamelCase = objKeysToCamelCase;
|
|
115
118
|
/**
|
|
116
119
|
* A utility function that recursively converts all keys in an object to snake_case.
|
|
117
120
|
* @param obj The object to convert
|
|
@@ -121,7 +124,6 @@ exports.objKeysToCamelCase = objKeysToCamelCase;
|
|
|
121
124
|
function objKeysToSnakeCase(obj, exclude) {
|
|
122
125
|
return convertCase(obj, change_case_1.snakeCase, exclude);
|
|
123
126
|
}
|
|
124
|
-
exports.objKeysToSnakeCase = objKeysToSnakeCase;
|
|
125
127
|
/**
|
|
126
128
|
* Safely encodes a path template with replacements.
|
|
127
129
|
* @param pathTemplate The path template to encode.
|
|
@@ -145,9 +147,29 @@ function safePath(pathTemplate, replacements) {
|
|
|
145
147
|
}
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
|
-
exports.safePath = safePath;
|
|
149
150
|
// Helper to create PathParams with type safety and runtime interpolation
|
|
150
151
|
function makePathParams(path, params) {
|
|
151
152
|
return safePath(path, params);
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Calculates the total payload size for a message request, including body and attachments.
|
|
156
|
+
* This is used to determine if multipart/form-data should be used instead of JSON.
|
|
157
|
+
* @param requestBody The message request body
|
|
158
|
+
* @returns The total estimated payload size in bytes
|
|
159
|
+
*/
|
|
160
|
+
function calculateTotalPayloadSize(requestBody) {
|
|
161
|
+
let totalSize = 0;
|
|
162
|
+
// Calculate size of the message body (JSON payload without attachments)
|
|
163
|
+
const messagePayloadWithoutAttachments = {
|
|
164
|
+
...requestBody,
|
|
165
|
+
attachments: undefined,
|
|
166
|
+
};
|
|
167
|
+
const messagePayloadString = JSON.stringify(objKeysToSnakeCase(messagePayloadWithoutAttachments));
|
|
168
|
+
totalSize += Buffer.byteLength(messagePayloadString, 'utf8');
|
|
169
|
+
// Add attachment sizes
|
|
170
|
+
const attachmentSize = requestBody.attachments?.reduce((total, attachment) => {
|
|
171
|
+
return total + (attachment.size || 0);
|
|
172
|
+
}, 0) || 0;
|
|
173
|
+
totalSize += attachmentSize;
|
|
174
|
+
return totalSize;
|
|
175
|
+
}
|
package/lib/cjs/version.js
CHANGED
|
@@ -5,4 +5,6 @@ export var MessageFields;
|
|
|
5
5
|
(function (MessageFields) {
|
|
6
6
|
MessageFields["STANDARD"] = "standard";
|
|
7
7
|
MessageFields["INCLUDE_HEADERS"] = "include_headers";
|
|
8
|
+
MessageFields["INCLUDE_TRACKING_OPTIONS"] = "include_tracking_options";
|
|
9
|
+
MessageFields["RAW_MIME"] = "raw_mime";
|
|
8
10
|
})(MessageFields || (MessageFields = {}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Messages } from './messages.js';
|
|
2
2
|
import { Resource } from './resource.js';
|
|
3
|
-
import { encodeAttachmentStreams } from '../utils.js';
|
|
3
|
+
import { encodeAttachmentStreams, calculateTotalPayloadSize, } from '../utils.js';
|
|
4
4
|
import { makePathParams } from '../utils.js';
|
|
5
5
|
/**
|
|
6
6
|
* Nylas Drafts API
|
|
@@ -40,11 +40,9 @@ export class Drafts extends Resource {
|
|
|
40
40
|
const path = makePathParams('/v3/grants/{identifier}/drafts', {
|
|
41
41
|
identifier,
|
|
42
42
|
});
|
|
43
|
-
// Use form data
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, 0) || 0;
|
|
47
|
-
if (attachmentSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
43
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
44
|
+
const totalPayloadSize = calculateTotalPayloadSize(requestBody);
|
|
45
|
+
if (totalPayloadSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
48
46
|
const form = Messages._buildFormRequest(requestBody);
|
|
49
47
|
return this.apiClient.request({
|
|
50
48
|
method: 'POST',
|
|
@@ -75,11 +73,9 @@ export class Drafts extends Resource {
|
|
|
75
73
|
identifier,
|
|
76
74
|
draftId,
|
|
77
75
|
});
|
|
78
|
-
// Use form data
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
}, 0) || 0;
|
|
82
|
-
if (attachmentSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
76
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
77
|
+
const totalPayloadSize = calculateTotalPayloadSize(requestBody);
|
|
78
|
+
if (totalPayloadSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
83
79
|
const form = Messages._buildFormRequest(requestBody);
|
|
84
80
|
return this.apiClient.request({
|
|
85
81
|
method: 'PUT',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeAttachmentStreams, objKeysToSnakeCase, makePathParams, } from '../utils.js';
|
|
1
|
+
import { encodeAttachmentStreams, objKeysToSnakeCase, makePathParams, calculateTotalPayloadSize, } from '../utils.js';
|
|
2
2
|
import { Resource } from './resource.js';
|
|
3
3
|
import { SmartCompose } from './smartCompose.js';
|
|
4
4
|
/**
|
|
@@ -86,11 +86,9 @@ export class Messages extends Resource {
|
|
|
86
86
|
path,
|
|
87
87
|
overrides,
|
|
88
88
|
};
|
|
89
|
-
// Use form data
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}, 0) || 0;
|
|
93
|
-
if (attachmentSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
89
|
+
// Use form data if the total payload size (body + attachments) is greater than 3mb
|
|
90
|
+
const totalPayloadSize = calculateTotalPayloadSize(requestBody);
|
|
91
|
+
if (totalPayloadSize >= Messages.MAXIMUM_JSON_ATTACHMENT_SIZE) {
|
|
94
92
|
requestOptions.form = Messages._buildFormRequest(requestBody);
|
|
95
93
|
}
|
|
96
94
|
else {
|
package/lib/esm/utils.js
CHANGED
|
@@ -142,3 +142,25 @@ export function safePath(pathTemplate, replacements) {
|
|
|
142
142
|
export function makePathParams(path, params) {
|
|
143
143
|
return safePath(path, params);
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Calculates the total payload size for a message request, including body and attachments.
|
|
147
|
+
* This is used to determine if multipart/form-data should be used instead of JSON.
|
|
148
|
+
* @param requestBody The message request body
|
|
149
|
+
* @returns The total estimated payload size in bytes
|
|
150
|
+
*/
|
|
151
|
+
export function calculateTotalPayloadSize(requestBody) {
|
|
152
|
+
let totalSize = 0;
|
|
153
|
+
// Calculate size of the message body (JSON payload without attachments)
|
|
154
|
+
const messagePayloadWithoutAttachments = {
|
|
155
|
+
...requestBody,
|
|
156
|
+
attachments: undefined,
|
|
157
|
+
};
|
|
158
|
+
const messagePayloadString = JSON.stringify(objKeysToSnakeCase(messagePayloadWithoutAttachments));
|
|
159
|
+
totalSize += Buffer.byteLength(messagePayloadString, 'utf8');
|
|
160
|
+
// Add attachment sizes
|
|
161
|
+
const attachmentSize = requestBody.attachments?.reduce((total, attachment) => {
|
|
162
|
+
return total + (attachment.size || 0);
|
|
163
|
+
}, 0) || 0;
|
|
164
|
+
totalSize += attachmentSize;
|
|
165
|
+
return totalSize;
|
|
166
|
+
}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This file is generated by scripts/exportVersion.js
|
|
2
|
-
export const SDK_VERSION = '7.
|
|
2
|
+
export const SDK_VERSION = '7.11.0';
|
package/lib/types/apiClient.d.ts
CHANGED
|
@@ -84,5 +84,15 @@ export interface ListFolderQueryParams extends ListQueryParams {
|
|
|
84
84
|
* (Microsoft and EWS only.) Use the ID of a folder to find all child folders it contains.
|
|
85
85
|
*/
|
|
86
86
|
parentId?: string;
|
|
87
|
+
/**
|
|
88
|
+
* (Microsoft only) When true, Nylas includes hidden folders in its response.
|
|
89
|
+
*/
|
|
90
|
+
includeHiddenFolders?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* (Microsoft only) If true, retrieves folders from a single-level hierarchy only.
|
|
93
|
+
* If false, retrieves folders across a multi-level hierarchy.
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
singleLevel?: boolean;
|
|
87
97
|
}
|
|
88
98
|
export type UpdateFolderRequest = Partial<CreateFolderRequest>;
|
|
@@ -74,6 +74,28 @@ export interface BaseMessage {
|
|
|
74
74
|
*/
|
|
75
75
|
unread?: boolean;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Interface representing message tracking options.
|
|
79
|
+
*/
|
|
80
|
+
export interface MessageTrackingOptions {
|
|
81
|
+
/**
|
|
82
|
+
* When true, shows that message open tracking is enabled.
|
|
83
|
+
*/
|
|
84
|
+
opens: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* When true, shows that thread replied tracking is enabled.
|
|
87
|
+
*/
|
|
88
|
+
threadReplies: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* When true, shows that link clicked tracking is enabled.
|
|
91
|
+
*/
|
|
92
|
+
links: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* A label describing the message tracking purpose.
|
|
95
|
+
* Maximum length: 2048 characters.
|
|
96
|
+
*/
|
|
97
|
+
label: string;
|
|
98
|
+
}
|
|
77
99
|
/**
|
|
78
100
|
* Interface representing a Nylas Message object.
|
|
79
101
|
*/
|
|
@@ -87,6 +109,17 @@ export interface Message extends BaseMessage {
|
|
|
87
109
|
* Only present if the 'fields' query parameter is set to includeHeaders.
|
|
88
110
|
*/
|
|
89
111
|
headers?: MessageHeaders[];
|
|
112
|
+
/**
|
|
113
|
+
* The message tracking options.
|
|
114
|
+
* Only present if the 'fields' query parameter is set to include_tracking_options.
|
|
115
|
+
*/
|
|
116
|
+
trackingOptions?: MessageTrackingOptions;
|
|
117
|
+
/**
|
|
118
|
+
* A Base64url-encoded string containing the message data (including the body content).
|
|
119
|
+
* Only present if the 'fields' query parameter is set to raw_mime.
|
|
120
|
+
* When this field is requested, only grant_id, object, id, and raw_mime fields are returned.
|
|
121
|
+
*/
|
|
122
|
+
rawMime?: string;
|
|
90
123
|
/**
|
|
91
124
|
* A list of key-value pairs storing additional data.
|
|
92
125
|
*/
|
|
@@ -144,7 +177,9 @@ export interface MessageHeaders {
|
|
|
144
177
|
*/
|
|
145
178
|
export declare enum MessageFields {
|
|
146
179
|
STANDARD = "standard",
|
|
147
|
-
INCLUDE_HEADERS = "include_headers"
|
|
180
|
+
INCLUDE_HEADERS = "include_headers",
|
|
181
|
+
INCLUDE_TRACKING_OPTIONS = "include_tracking_options",
|
|
182
|
+
RAW_MIME = "raw_mime"
|
|
148
183
|
}
|
|
149
184
|
/**
|
|
150
185
|
* Interface representing information about a scheduled message.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Overrides } from '../config.js';
|
|
4
2
|
import { Attachment, FindAttachmentQueryParams, DownloadAttachmentQueryParams } from '../models/attachments.js';
|
|
5
3
|
import { NylasResponse } from '../models/response.js';
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -43,3 +43,10 @@ export interface PathParams<Path extends string> {
|
|
|
43
43
|
toPath(): string;
|
|
44
44
|
}
|
|
45
45
|
export declare function makePathParams<Path extends string>(path: Path, params: Record<ExtractPathParams<Path>, string>): string;
|
|
46
|
+
/**
|
|
47
|
+
* Calculates the total payload size for a message request, including body and attachments.
|
|
48
|
+
* This is used to determine if multipart/form-data should be used instead of JSON.
|
|
49
|
+
* @param requestBody The message request body
|
|
50
|
+
* @returns The total estimated payload size in bytes
|
|
51
|
+
*/
|
|
52
|
+
export declare function calculateTotalPayloadSize(requestBody: any): number;
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "7.
|
|
1
|
+
export declare const SDK_VERSION = "7.11.0";
|