Skip to content
Merged
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "41bba7c", "specHash": "5bf3652", "version": "1.17.1" }
{ "engineHash": "1c54d3c", "specHash": "5bf3652", "version": "1.17.1" }
2 changes: 1 addition & 1 deletion docs/docgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ See the endpoint docs at

```ts
await client.docgen.getDocgenJobsV2025R0({
limit: 500,
limit: 10000,
} satisfies GetDocgenJobsV2025R0QueryParams);
```

Expand Down
35 changes: 35 additions & 0 deletions docs/event-stream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Event Stream

The Event Stream class utilizes long-polling to receive real-time events from Box. The SDK provides an easy way to set up and manage the event stream which is extended from the stream.Readable class.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Event Stream](#event-stream)
- [Listening to the Event Stream](#listening-to-the-event-stream)
- [Deduplication](#deduplication)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Listening to the Event Stream

When the `EventStream` is started, it will begin long-polling asynchronously. Events received from the API are then forwarded to all listeners.

You can also listen for errors and the end of the stream using the `error` and `end` events respectively.

```ts
const eventsStream = await client.events.getEventStream();
eventsStream.on('data', (event) => {
console.log('Received event:', event);
});
eventsStream.on('error', (error) => {
console.error('Error in events stream:', error);
});
eventsStream.on('end', () => {
console.log('Events stream ended');
});
```

## Deduplication

The `EventStream` class automatically deduplicates events based on their `event_id`. This means that if the same event is received multiple times, it will only be emitted once to the listeners.
24 changes: 24 additions & 0 deletions docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Get events long poll endpoint](#get-events-long-poll-endpoint)
- [List user and enterprise events](#list-user-and-enterprise-events)
- [Get event stream](#get-event-stream)

## Get events long poll endpoint

Expand Down Expand Up @@ -107,3 +108,26 @@ including a list of event objects. The response includes a
`chunk_size` parameter indicating how many events were returned in this
chunk, as well as the next `stream_position` that can be
queried.

## Get event stream

Get an event stream for the Box API

This operation is performed by calling function `getEventStream`.

```ts
client.events.getEventStream();
```

### Arguments

- queryParams `GetEventStreamQueryParams`
- Query parameters of getEvents method
- headersInput `GetEventStreamHeadersInput`
- Headers of getEvents method
- cancellationToken `undefined | CancellationToken`
- Token used for request cancellation.

### Returns

This function returns a value of type `EventStream`.
90 changes: 37 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"browser": {
"./src/internal/utilsNode.ts": "./src/internal/utilsBrowser.ts",
"./lib/internal/utilsNode.js": "./lib/internal/utilsBrowser.js",
"./src/box/eventStream.ts": "./src/box/eventStreamBrowser.ts",
"./lib-esm/box/eventStream.js": "./lib-esm/box/eventStreamBrowser.js",
"./lib-esm/internal/utilsNode.js": "./lib-esm/internal/utilsBrowser.js"
},
"module": "./lib-esm/index.js",
Expand Down
Loading
Loading