nylas 8.1.1 → 8.1.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.
@@ -5,7 +5,7 @@ const error_js_1 = require("./models/error.js");
5
5
  const utils_js_1 = require("./utils.js");
6
6
  const version_js_1 = require("./version.js");
7
7
  const form_data_encoder_1 = require("form-data-encoder");
8
- const stream_1 = require("stream");
8
+ const node_stream_1 = require("node:stream");
9
9
  const change_case_1 = require("change-case");
10
10
  /**
11
11
  * The header key for the debugging flow ID
@@ -164,7 +164,7 @@ class APIClient {
164
164
  // Set the Content-Type header with the boundary from the encoder
165
165
  requestOptions.headers['Content-Type'] = encoder.contentType;
166
166
  // Convert the encoded form data to a readable stream for the request body
167
- requestOptions.body = stream_1.Readable.from(encoder);
167
+ requestOptions.body = node_stream_1.Readable.from(encoder);
168
168
  // Node.js native fetch requires duplex: 'half' when sending a streaming body
169
169
  requestOptions.duplex = 'half';
170
170
  }
@@ -7,6 +7,7 @@ exports.MessageFields = void 0;
7
7
  var MessageFields;
8
8
  (function (MessageFields) {
9
9
  MessageFields["STANDARD"] = "standard";
10
+ MessageFields["INCLUDE_BASIC_HEADERS"] = "include_basic_headers";
10
11
  MessageFields["INCLUDE_HEADERS"] = "include_headers";
11
12
  MessageFields["INCLUDE_TRACKING_OPTIONS"] = "include_tracking_options";
12
13
  MessageFields["RAW_MIME"] = "raw_mime";
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Attachments = void 0;
4
4
  const utils_js_1 = require("../utils.js");
5
5
  const resource_js_1 = require("./resource.js");
6
+ const node_stream_1 = require("node:stream");
6
7
  /**
7
8
  * Nylas Attachments API
8
9
  *
@@ -23,15 +24,15 @@ class Attachments extends resource_js_1.Resource {
23
24
  /**
24
25
  * Download the attachment data
25
26
  *
26
- * This method returns a NodeJS.ReadableStream which can be used to stream the attachment data.
27
+ * This method returns a Web ReadableStream which can be used to stream the attachment data.
27
28
  * This is particularly useful for handling large attachments efficiently, as it avoids loading
28
- * the entire file into memory. The stream can be piped to a file stream or used in any other way
29
- * that Node.js streams are typically used.
29
+ * the entire file into memory. In Node.js, convert it with Readable.fromWeb() when a
30
+ * NodeJS.ReadableStream is required.
30
31
  *
31
32
  * @param identifier Grant ID or email account to query
32
33
  * @param attachmentId The id of the attachment to download.
33
34
  * @param queryParams The query parameters to include in the request
34
- * @returns {NodeJS.ReadableStream} The ReadableStream containing the file data.
35
+ * @returns {ReadableStream<Uint8Array>} The ReadableStream containing the file data.
35
36
  */
36
37
  download({ identifier, attachmentId, queryParams, overrides, }) {
37
38
  return this._getStream({
@@ -40,6 +41,27 @@ class Attachments extends resource_js_1.Resource {
40
41
  overrides,
41
42
  });
42
43
  }
44
+ /**
45
+ * Download the attachment data as a Node.js readable stream.
46
+ *
47
+ * This is a Node.js convenience wrapper around {@link Attachments.download}. Use
48
+ * {@link Attachments.download} directly in Fetch-native runtimes, such as Cloudflare Workers,
49
+ * where Web ReadableStreams are the standard stream primitive.
50
+ *
51
+ * @param identifier Grant ID or email account to query
52
+ * @param attachmentId The id of the attachment to download.
53
+ * @param queryParams The query parameters to include in the request
54
+ * @returns {NodeJS.ReadableStream} The Node.js readable stream containing the file data.
55
+ */
56
+ async downloadNodeStream({ identifier, attachmentId, queryParams, overrides, }) {
57
+ const stream = await this.download({
58
+ identifier,
59
+ attachmentId,
60
+ queryParams,
61
+ overrides,
62
+ });
63
+ return node_stream_1.Readable.fromWeb(stream);
64
+ }
43
65
  /**
44
66
  * Download the attachment as a byte array
45
67
  * @param identifier Grant ID or email account to query
@@ -81,13 +81,14 @@ class Messages extends resource_js_1.Resource {
81
81
  * Send an email
82
82
  * @return The sent message
83
83
  */
84
- async send({ identifier, requestBody, overrides, }) {
84
+ async send({ identifier, requestBody, queryParams, overrides, }) {
85
85
  const path = (0, utils_js_1.makePathParams)('/v3/grants/{identifier}/messages/send', {
86
86
  identifier,
87
87
  });
88
88
  const requestOptions = {
89
89
  method: 'POST',
90
90
  path,
91
+ queryParams,
91
92
  overrides,
92
93
  };
93
94
  // Use form data if the total payload size (body + attachments) is greater than 3mb
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  // This file is generated by scripts/exportVersion.js
5
- exports.SDK_VERSION = '8.1.1';
5
+ exports.SDK_VERSION = '8.1.2';
@@ -2,7 +2,7 @@ import { NylasApiError, NylasOAuthError, NylasSdkTimeoutError, } from './models/
2
2
  import { objKeysToCamelCase, objKeysToSnakeCase } from './utils.js';
3
3
  import { SDK_VERSION } from './version.js';
4
4
  import { FormDataEncoder } from 'form-data-encoder';
5
- import { Readable } from 'stream';
5
+ import { Readable } from 'node:stream';
6
6
  import { snakeCase } from 'change-case';
7
7
  /**
8
8
  * The header key for the debugging flow ID
@@ -4,6 +4,7 @@
4
4
  export var MessageFields;
5
5
  (function (MessageFields) {
6
6
  MessageFields["STANDARD"] = "standard";
7
+ MessageFields["INCLUDE_BASIC_HEADERS"] = "include_basic_headers";
7
8
  MessageFields["INCLUDE_HEADERS"] = "include_headers";
8
9
  MessageFields["INCLUDE_TRACKING_OPTIONS"] = "include_tracking_options";
9
10
  MessageFields["RAW_MIME"] = "raw_mime";
@@ -1,5 +1,6 @@
1
1
  import { makePathParams } from '../utils.js';
2
2
  import { Resource } from './resource.js';
3
+ import { Readable } from 'node:stream';
3
4
  /**
4
5
  * Nylas Attachments API
5
6
  *
@@ -20,15 +21,15 @@ export class Attachments extends Resource {
20
21
  /**
21
22
  * Download the attachment data
22
23
  *
23
- * This method returns a NodeJS.ReadableStream which can be used to stream the attachment data.
24
+ * This method returns a Web ReadableStream which can be used to stream the attachment data.
24
25
  * This is particularly useful for handling large attachments efficiently, as it avoids loading
25
- * the entire file into memory. The stream can be piped to a file stream or used in any other way
26
- * that Node.js streams are typically used.
26
+ * the entire file into memory. In Node.js, convert it with Readable.fromWeb() when a
27
+ * NodeJS.ReadableStream is required.
27
28
  *
28
29
  * @param identifier Grant ID or email account to query
29
30
  * @param attachmentId The id of the attachment to download.
30
31
  * @param queryParams The query parameters to include in the request
31
- * @returns {NodeJS.ReadableStream} The ReadableStream containing the file data.
32
+ * @returns {ReadableStream<Uint8Array>} The ReadableStream containing the file data.
32
33
  */
33
34
  download({ identifier, attachmentId, queryParams, overrides, }) {
34
35
  return this._getStream({
@@ -37,6 +38,27 @@ export class Attachments extends Resource {
37
38
  overrides,
38
39
  });
39
40
  }
41
+ /**
42
+ * Download the attachment data as a Node.js readable stream.
43
+ *
44
+ * This is a Node.js convenience wrapper around {@link Attachments.download}. Use
45
+ * {@link Attachments.download} directly in Fetch-native runtimes, such as Cloudflare Workers,
46
+ * where Web ReadableStreams are the standard stream primitive.
47
+ *
48
+ * @param identifier Grant ID or email account to query
49
+ * @param attachmentId The id of the attachment to download.
50
+ * @param queryParams The query parameters to include in the request
51
+ * @returns {NodeJS.ReadableStream} The Node.js readable stream containing the file data.
52
+ */
53
+ async downloadNodeStream({ identifier, attachmentId, queryParams, overrides, }) {
54
+ const stream = await this.download({
55
+ identifier,
56
+ attachmentId,
57
+ queryParams,
58
+ overrides,
59
+ });
60
+ return Readable.fromWeb(stream);
61
+ }
40
62
  /**
41
63
  * Download the attachment as a byte array
42
64
  * @param identifier Grant ID or email account to query
@@ -78,13 +78,14 @@ export class Messages extends Resource {
78
78
  * Send an email
79
79
  * @return The sent message
80
80
  */
81
- async send({ identifier, requestBody, overrides, }) {
81
+ async send({ identifier, requestBody, queryParams, overrides, }) {
82
82
  const path = makePathParams('/v3/grants/{identifier}/messages/send', {
83
83
  identifier,
84
84
  });
85
85
  const requestOptions = {
86
86
  method: 'POST',
87
87
  path,
88
+ queryParams,
88
89
  overrides,
89
90
  };
90
91
  // Use form data if the total payload size (body + attachments) is greater than 3mb
@@ -1,2 +1,2 @@
1
1
  // This file is generated by scripts/exportVersion.js
2
- export const SDK_VERSION = '8.1.1';
2
+ export const SDK_VERSION = '8.1.2';
@@ -177,6 +177,7 @@ export interface MessageHeaders {
177
177
  */
178
178
  export declare enum MessageFields {
179
179
  STANDARD = "standard",
180
+ INCLUDE_BASIC_HEADERS = "include_basic_headers",
180
181
  INCLUDE_HEADERS = "include_headers",
181
182
  INCLUDE_TRACKING_OPTIONS = "include_tracking_options",
182
183
  RAW_MIME = "raw_mime"
@@ -304,6 +305,15 @@ export interface FindMessageQueryParams {
304
305
  */
305
306
  fields?: MessageFields;
306
307
  }
308
+ /**
309
+ * Interface representing the query parameters for sending a message.
310
+ */
311
+ export interface SendMessageQueryParams {
312
+ /**
313
+ * Allows you to specify to return the sent message with headers included.
314
+ */
315
+ fields?: MessageFields;
316
+ }
307
317
  /**
308
318
  * Interface representing the request to clean a message.
309
319
  */
@@ -52,17 +52,30 @@ export declare class Attachments extends Resource {
52
52
  /**
53
53
  * Download the attachment data
54
54
  *
55
- * This method returns a NodeJS.ReadableStream which can be used to stream the attachment data.
55
+ * This method returns a Web ReadableStream which can be used to stream the attachment data.
56
56
  * This is particularly useful for handling large attachments efficiently, as it avoids loading
57
- * the entire file into memory. The stream can be piped to a file stream or used in any other way
58
- * that Node.js streams are typically used.
57
+ * the entire file into memory. In Node.js, convert it with Readable.fromWeb() when a
58
+ * NodeJS.ReadableStream is required.
59
59
  *
60
60
  * @param identifier Grant ID or email account to query
61
61
  * @param attachmentId The id of the attachment to download.
62
62
  * @param queryParams The query parameters to include in the request
63
- * @returns {NodeJS.ReadableStream} The ReadableStream containing the file data.
63
+ * @returns {ReadableStream<Uint8Array>} The ReadableStream containing the file data.
64
64
  */
65
65
  download({ identifier, attachmentId, queryParams, overrides, }: DownloadAttachmentParams & Overrides): Promise<ReadableStream<Uint8Array>>;
66
+ /**
67
+ * Download the attachment data as a Node.js readable stream.
68
+ *
69
+ * This is a Node.js convenience wrapper around {@link Attachments.download}. Use
70
+ * {@link Attachments.download} directly in Fetch-native runtimes, such as Cloudflare Workers,
71
+ * where Web ReadableStreams are the standard stream primitive.
72
+ *
73
+ * @param identifier Grant ID or email account to query
74
+ * @param attachmentId The id of the attachment to download.
75
+ * @param queryParams The query parameters to include in the request
76
+ * @returns {NodeJS.ReadableStream} The Node.js readable stream containing the file data.
77
+ */
78
+ downloadNodeStream({ identifier, attachmentId, queryParams, overrides, }: DownloadAttachmentParams & Overrides): Promise<NodeJS.ReadableStream>;
66
79
  /**
67
80
  * Download the attachment as a byte array
68
81
  * @param identifier Grant ID or email account to query
@@ -2,7 +2,7 @@ import { FormData } from 'formdata-node';
2
2
  import APIClient from '../apiClient.js';
3
3
  import { Overrides } from '../config.js';
4
4
  import { CreateDraftRequest, SendMessageRequest, UpdateDraftRequest } from '../models/drafts.js';
5
- import { CleanMessagesRequest, CleanMessagesResponse, FindMessageQueryParams, ListMessagesQueryParams, Message, ScheduledMessage, ScheduledMessagesList, StopScheduledMessageResponse, UpdateMessageRequest } from '../models/messages.js';
5
+ import { CleanMessagesRequest, CleanMessagesResponse, FindMessageQueryParams, ListMessagesQueryParams, Message, ScheduledMessage, ScheduledMessagesList, SendMessageQueryParams, StopScheduledMessageResponse, UpdateMessageRequest } from '../models/messages.js';
6
6
  import { NylasBaseResponse, NylasListResponse, NylasResponse } from '../models/response.js';
7
7
  import { AsyncListResponse, Resource } from './resource.js';
8
8
  import { SmartCompose } from './smartCompose.js';
@@ -50,10 +50,12 @@ export interface DestroyMessageParams {
50
50
  * The parameters for the {@link Messages.send} method
51
51
  * @property identifier The identifier of the grant to act upon
52
52
  * @property requestBody The message to send
53
+ * @property queryParams The query parameters to include in the request
53
54
  */
54
55
  export interface SendMessageParams {
55
56
  identifier: string;
56
57
  requestBody: SendMessageRequest;
58
+ queryParams?: SendMessageQueryParams;
57
59
  }
58
60
  /**
59
61
  * The parameters for the {@link Messages.listScheduledMessages} method
@@ -119,7 +121,7 @@ export declare class Messages extends Resource {
119
121
  * Send an email
120
122
  * @return The sent message
121
123
  */
122
- send({ identifier, requestBody, overrides, }: SendMessageParams & Overrides): Promise<NylasResponse<Message>>;
124
+ send({ identifier, requestBody, queryParams, overrides, }: SendMessageParams & Overrides): Promise<NylasResponse<Message>>;
123
125
  /**
124
126
  * Retrieve your scheduled messages
125
127
  * @return A list of scheduled messages
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "8.1.1";
1
+ export declare const SDK_VERSION = "8.1.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "8.1.1",
3
+ "version": "8.1.2",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/cjs/nylas.js",
6
6
  "types": "lib/types/nylas.d.ts",