Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.1.0-rc.1"
".": "2.1.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 30
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/writerai%2Fwriter-d15316b8a3a086ae9ec8eea0d436b0885262df9bcf23b9587ad059e50357c220.yml
openapi_spec_hash: 4f81a4f4840438f80eff345e76ead962
config_hash: b3310cd2944d74a3599e847847226a42
config_hash: ee2e5a914fd298a6f4c740f5ce187f87
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 2.1.0 (2025-04-04)

Full Changelog: [v2.1.0-rc.1...v2.1.0](https://github.com/writer/writer-node/compare/v2.1.0-rc.1...v2.1.0)

### Features

* **api:** manual updates ([#217](https://github.com/writer/writer-node/issues/217)) ([9217f0e](https://github.com/writer/writer-node/commit/9217f0ecef3606bc5fdc00fdee5e008b240c8a93))


### Bug Fixes

* **api:** improve type resolution when importing as a package ([#214](https://github.com/writer/writer-node/issues/214)) ([0169d65](https://github.com/writer/writer-node/commit/0169d650344f16d5a69420a888325ed22567fa02))
* **client:** send `X-Stainless-Timeout` in seconds ([#209](https://github.com/writer/writer-node/issues/209)) ([6f6b153](https://github.com/writer/writer-node/commit/6f6b1535d1bacf27de69fdc1f8ae7162f32d82e4))

### Chores

* **docs:** improve migration doc ([#216](https://github.com/writer/writer-node/issues/216)) ([b2880ad](https://github.com/writer/writer-node/commit/b2880ad53b4caddd681b0647fe1c106efed08372))
* **internal:** add aliases for Record and Array ([#213](https://github.com/writer/writer-node/issues/213)) ([af62acf](https://github.com/writer/writer-node/commit/af62acfce3f4b7b1fe774ca716e06bcdd3a207b6))


## 2.1.0-rc.1 (2025-04-02)

Full Changelog: [v2.0.0...v2.1.0-rc.1](https://github.com/writer/writer-node/compare/v2.0.0...v2.1.0-rc.1)
Expand Down
242 changes: 120 additions & 122 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ For example, for a method that would call an endpoint at `/v1/parents/{parent_id

```ts
// Before
client.parents.children.create('p_123', 'c_456');
client.parents.children.retrieve('p_123', 'c_456');

// After
client.example.create('c_456', { parent_id: 'p_123' });
client.parents.children.retrieve('c_456', { parent_id: 'p_123' });
```

This affects the following methods:
Expand All @@ -121,11 +121,50 @@ For example:

```diff
- client.example.retrieve(encodeURIComponent('string/with/slash'))
+ client.example.retrieve('string/with/slash') // renders example/string%2Fwith%2Fslash
+ client.example.retrieve('string/with/slash') // retrieves /example/string%2Fwith%2Fslash
```

Previously without the `encodeURIComponent()` call we would have used the path `/example/string/with/slash`; now we'll use `/example/string%2Fwith%2Fslash`.

### Method params must be an object

When making requests to endpoints that expect something other than a JSON object, you must now pass the body as a property instead
of an individual argument.

For example, an endpoint that takes an array:

```typescript
// Before
client.example.create([{ name: 'name' }, { name: 'name' }]);

// After
client.example.create({ items: [{ name: 'name' }, { name: 'name' }] });
```

This affects the following methods:

- `client.files.upload()`

### Removed request options overloads

When making requests with no required body, query or header parameters, you must now explicitly pass `null`, `undefined` or an empty object `{}` to the params argument in order to customise request options.

```diff
client.example.list();
client.example.list({}, { headers: { ... } });
client.example.list(null, { headers: { ... } });
client.example.list(undefined, { headers: { ... } });
- client.example.list({ headers: { ... } });
+ client.example.list({}, { headers: { ... } });
```

This affects the following methods:

- `client.applications.list()`
- `client.applications.jobs.list()`
- `client.graphs.list()`
- `client.files.list()`

### Removed `httpAgent` in favor of `fetchOptions`

The `httpAgent` client option has been removed in favor of a [platform-specific `fetchOptions` property](https://github.com/writer/writer-node#fetch-options).
Expand Down Expand Up @@ -160,84 +199,83 @@ const client = new Writer({
});
```

### Removed request options overloads

When making requests with no required body, query or header parameters, you must now explicitly pass `null`, `undefined` or an empty object `{}` to the params argument in order to customise request options.

```diff
client.example.list();
client.example.list({}, { headers: { ... } });
client.example.list(null, { headers: { ... } });
client.example.list(undefined, { headers: { ... } });
- client.example.list({ headers: { ... } });
+ client.example.list({}, { headers: { ... } });
```

This affects the following methods:

- `client.applications.list()`
- `client.applications.jobs.list()`
- `client.graphs.list()`
- `client.files.list()`
### Changed exports

### Method params must be an object
#### Refactor of `writer-sdk/core`, `error`, `pagination`, `resource`, `streaming` and `uploads`

When making requests to endpoints that expect something other than a JSON object, you must now pass the body as a property instead
of an individual argument.
Much of the `writer-sdk/core` file was intended to be internal-only but it was publicly accessible, as such it has been refactored and split up into internal and public files, with public-facing code moved to a new `core` folder and internal code moving to the private `internal` folder.

For example, an endpoint that takes an array:
At the same time, we moved some public-facing files which were previously at the top level into `core` to make the file structure cleaner and more clear:

```typescript
// Before
client.example.create([{ name: 'name' }, { name: 'name' }]);
import 'writer-sdk/error';
import 'writer-sdk/pagination';
import 'writer-sdk/resource';
import 'writer-sdk/streaming';
import 'writer-sdk/uploads';

// After
client.example.create({ items: [{ name: 'name' }, { name: 'name' }] });
import 'writer-sdk/core/error';
import 'writer-sdk/core/pagination';
import 'writer-sdk/core/resource';
import 'writer-sdk/core/streaming';
import 'writer-sdk/core/uploads';
```

This affects the following methods:
If you were relying on anything that was only exported from `writer-sdk/core` and is also not accessible anywhere else, please open an issue and we'll consider adding it to the public API.

- `client.files.upload()`
#### Resource classes

### Pagination changes
Previously under certain circumstances it was possible to import resource classes like `Applications` directly from the root of the package. This was never valid at the type level and only worked in CommonJS files.
Now you must always either reference them as static class properties or import them directly from the files in which they are defined.

Note that the `for await` syntax is _not_ affected. This still works as-is:
```typescript
// Before
const { Applications } = require('writer-sdk');

```ts
// Automatically fetches more pages as needed.
for await (const graph of client.graphs.list()) {
console.log(graph);
}
// After
const { Writer } = require('writer-sdk');
Writer.Applications; // or import directly from writer-sdk/resources/applications/applications
```

#### Simplified interface
#### Cleaned up `uploads` exports

The pagination interface has been simplified:
As part of the `core` refactor, `writer-sdk/uploads` was moved to `writer-sdk/core/uploads`
and the following exports were removed, as they were not intended to be a part of the public API:

```ts
// Before
page.nextPageParams();
page.nextPageInfo();
// Required manually handling { url } | { params } type
- `fileFromPath`
- `BlobPart`
- `BlobLike`
- `FileLike`
- `ResponseLike`
- `isResponseLike`
- `isBlobLike`
- `isFileLike`
- `isUploadable`
- `isMultipartBody`
- `maybeMultipartFormRequestOptions`
- `multipartFormRequestOptions`
- `createForm`

// After
page.nextPageRequestOptions();
Note that `Uploadable` & `toFile` **are** still exported:

```typescript
import { type Uploadable, toFile } from 'writer-sdk/core/uploads';
```

#### Removed unnecessary classes
#### `APIClient`

Page classes for individual methods are now type aliases:
The `APIClient` base client class has been removed as it is no longer needed. If you were importing this class then you must now import the main client class:

```ts
```typescript
// Before
export class GraphsCursorPage extends CursorPage<Graph> {}
import { APIClient } from 'writer-sdk/core';

// After
export type GraphsCursorPage = CursorPage<Graph>;
import { Writer } from 'writer-sdk';
```

If you were importing these classes at runtime, you'll need to switch to importing the base class or only import them at the type-level.

### File handling

The deprecated `fileFromPath` helper has been removed in favor of native Node.js streams:
Expand Down Expand Up @@ -265,98 +303,58 @@ import Writer from 'writer-sdk';

The `writer-sdk/shims` imports have been removed. Your global types must now be [correctly configured](#minimum-types-requirements).

### `writer-sdk/src` directory removed

Previously IDEs may have auto-completed imports from the `writer-sdk/src` directory, however this
directory was only included for an improved go-to-definition experience and should not have been used at runtime.
### Pagination changes

If you have any `writer-sdk/src` imports, you must replace it with `writer-sdk`.
The `for await` syntax **is not affected**. This still works as-is:

```ts
// Before
import Writer from 'writer-sdk/src';

// After
import Writer from 'writer-sdk';
// Automatically fetches more pages as needed.
for await (const graph of client.graphs.list()) {
console.log(graph);
}
```

### Headers

The `headers` property on `APIError` objects is now an instance of the Web [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) class. It was previously just `Record<string, string | null | undefined>`.

### Removed exports
The interface for manually paginating through list results has been simplified:

#### Resource classes

If you were importing resource classes from the root package then you must now import them from the file they are defined in.
This was never valid at the type level and only worked in CommonJS files.

```typescript
```ts
// Before
const { Applications } = require('writer-sdk');
page.nextPageParams();
page.nextPageInfo();
// Required manually handling { url } | { params } type

// After
const { Writer } = require('writer-sdk');
Writer.Applications; // or import directly from writer-sdk/resources/applications/applications
page.nextPageRequestOptions();
```

#### Refactor of `writer-sdk/core`, `error`, `pagination`, `resource`, `streaming` and `uploads`

Much of the `writer-sdk/core` file was intended to be internal-only but it was publicly accessible, as such it has been refactored and split up into internal and public files, with public-facing code moved to a new `core` folder and internal code moving to the private `internal` folder.
#### Removed unnecessary classes

At the same time, we moved some public-facing files which were previously at the top level into `core` to make the file structure cleaner and more clear:
Page classes for individual methods are now type aliases:

```typescript
```ts
// Before
import 'writer-sdk/error';
import 'writer-sdk/pagination';
import 'writer-sdk/resource';
import 'writer-sdk/streaming';
import 'writer-sdk/uploads';
export class GraphsCursorPage extends CursorPage<Graph> {}

// After
import 'writer-sdk/core/error';
import 'writer-sdk/core/pagination';
import 'writer-sdk/core/resource';
import 'writer-sdk/core/streaming';
import 'writer-sdk/core/uploads';
export type GraphsCursorPage = CursorPage<Graph>;
```

If you were relying on anything that was only exported from `writer-sdk/core` and is also not accessible anywhere else, please open an issue and we'll consider adding it to the public API.

#### Cleaned up `uploads` exports

As part of the `core` refactor, `writer-sdk/uploads` was moved to `writer-sdk/core/uploads`
and the following exports were removed, as they were not intended to be a part of the public API:

- `fileFromPath`
- `BlobPart`
- `BlobLike`
- `FileLike`
- `ResponseLike`
- `isResponseLike`
- `isBlobLike`
- `isFileLike`
- `isUploadable`
- `isMultipartBody`
- `maybeMultipartFormRequestOptions`
- `multipartFormRequestOptions`
- `createForm`

Note that `Uploadable` & `toFile` **are** still exported:
If you were importing these classes at runtime, you'll need to switch to importing the base class or only import them at the type-level.

```typescript
import { type Uploadable, toFile } from 'writer-sdk/core/uploads';
```
### `writer-sdk/src` directory removed

#### `APIClient`
Previously IDEs may have auto-completed imports from the `writer-sdk/src` directory, however this
directory was only included for an improved go-to-definition experience and should not have been used at runtime.

The `APIClient` base client class has been removed as it is no longer needed. If you were importing this class then you must now import the main client class:
If you have any `writer-sdk/src/*` imports, you will need to replace them with `writer-sdk/*`.

```typescript
```ts
// Before
import { APIClient } from 'writer-sdk/core';
import Writer from 'writer-sdk/src';

// After
import { Writer } from 'writer-sdk';
import Writer from 'writer-sdk';
```

### Headers

The `headers` property on `APIError` objects is now an instance of the Web [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) class. It was previously just `Record<string, string | null | undefined>`.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "writer-sdk",
"version": "2.1.0-rc.1",
"version": "2.1.0",
"description": "The official TypeScript library for the Writer API",
"author": "Writer <dev-feedback@writer.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ export class Writer {
Accept: 'application/json',
'User-Agent': this.getUserAgent(),
'X-Stainless-Retry-Count': String(retryCount),
...(options.timeout ? { 'X-Stainless-Timeout': String(options.timeout) } : {}),
...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
...getPlatformHeaders(),
},
this.authHeaders(options),
Expand Down
Loading