Skip to content

Commit

Permalink
Merge pull request #108 from writer/release-please--branches--main--c…
Browse files Browse the repository at this point in the history
…hanges--next--components--writer-sdk

release: 1.4.0
  • Loading branch information
ramedina86 authored Nov 20, 2024
2 parents 3d783d7 + 1d807a9 commit 29ed155
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.3.0"
".": "1.4.0"
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.4.0 (2024-11-20)

Full Changelog: [v1.3.0...v1.4.0](https://github.com/writer/writer-node/compare/v1.3.0...v1.4.0)

### Features

* **api:** default timeout increase to 3 min ([#111](https://github.com/writer/writer-node/issues/111)) ([e0d48dc](https://github.com/writer/writer-node/commit/e0d48dc70007e2ff26f7045ee5362d8954328805))


### Chores

* rebuild project due to codegen change ([#107](https://github.com/writer/writer-node/issues/107)) ([f053183](https://github.com/writer/writer-node/commit/f0531839142b957f8e6574a654eceb82c9f7a4e0))
* rebuild project due to codegen change ([#109](https://github.com/writer/writer-node/issues/109)) ([7f35e1b](https://github.com/writer/writer-node/commit/7f35e1b0c9574e02273130e99d56f99829ff7062))
* rebuild project due to codegen change ([#110](https://github.com/writer/writer-node/issues/110)) ([fc9e0e0](https://github.com/writer/writer-node/commit/fc9e0e088f76f18055213deaf259381b7713b415))

## 1.3.0 (2024-11-12)

Full Changelog: [v1.2.0...v1.3.0](https://github.com/writer/writer-node/compare/v1.2.0...v1.3.0)
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ await client.chat.chat({ messages: [{ role: 'user' }], model: 'palmyra-x-004' },

### Timeouts

Requests time out after 1 minute by default. You can configure this with a `timeout` option:
Requests time out after 3 minutes by default. You can configure this with a `timeout` option:

<!-- prettier-ignore -->
```ts
// Configure the default for all requests:
const client = new Writer({
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
timeout: 20 * 1000, // 20 seconds (default is 3 minutes)
});

// Override per-request:
Expand Down Expand Up @@ -185,7 +185,7 @@ for (const graph of page.data) {

// Convenience methods are provided for manually paginating:
while (page.hasNextPage()) {
page = page.getNextPage();
page = await page.getNextPage();
// ...
}
```
Expand Down Expand Up @@ -342,6 +342,15 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher, using `import Writer from "npm:writer-sdk"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "writer-sdk",
"version": "1.3.0",
"version": "1.4.0",
"description": "The official TypeScript library for the Writer API",
"author": "Writer <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,6 @@
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-morph": "^19.0.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export abstract class APIClient {
constructor({
baseURL,
maxRetries = 2,
timeout = 60000, // 1 minute
timeout = 180000, // 3 minutes
httpAgent,
fetch: overridenFetch,
}: {
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class Writer extends Core.APIClient {
*
* @param {string | undefined} [opts.apiKey=process.env['WRITER_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['WRITER_BASE_URL'] ?? https://api.writer.com] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.timeout=3 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
Expand All @@ -167,7 +167,7 @@ export class Writer extends Core.APIClient {

super({
baseURL: options.baseURL!,
timeout: options.timeout ?? 60000 /* 1 minute */,
timeout: options.timeout ?? 180000 /* 3 minutes */,
httpAgent: options.httpAgent,
maxRetries: options.maxRetries,
fetch: options.fetch,
Expand Down Expand Up @@ -202,7 +202,7 @@ export class Writer extends Core.APIClient {
}

static Writer = this;
static DEFAULT_TIMEOUT = 60000; // 1 minute
static DEFAULT_TIMEOUT = 180000; // 3 minutes

static WriterError = Errors.WriterError;
static APIError = Errors.APIError;
Expand Down Expand Up @@ -302,7 +302,7 @@ export declare namespace Writer {
};
}

export { toFile, fileFromPath } from 'writer-sdk/uploads';
export { toFile, fileFromPath } from './uploads';
export {
WriterError,
APIError,
Expand All @@ -317,6 +317,6 @@ export {
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} from 'writer-sdk/error';
} from './error';

export default Writer;
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '1.3.0'; // x-release-please-version
export const VERSION = '1.4.0'; // x-release-please-version
12 changes: 2 additions & 10 deletions tests/api-resources/applications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ const client = new Writer({
describe('resource applications', () => {
test('generateContent: only required params', async () => {
const responsePromise = client.applications.generateContent('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
inputs: [
{ id: 'id', value: ['string', 'string', 'string'] },
{ id: 'id', value: ['string', 'string', 'string'] },
{ id: 'id', value: ['string', 'string', 'string'] },
],
inputs: [{ id: 'id', value: ['string'] }],
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -28,11 +24,7 @@ describe('resource applications', () => {

test('generateContent: required and optional params', async () => {
const response = await client.applications.generateContent('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
inputs: [
{ id: 'id', value: ['string', 'string', 'string'] },
{ id: 'id', value: ['string', 'string', 'string'] },
{ id: 'id', value: ['string', 'string', 'string'] },
],
inputs: [{ id: 'id', value: ['string'] }],
});
});
});
44 changes: 3 additions & 41 deletions tests/api-resources/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,10 @@ describe('resource chat', () => {
role: 'user',
content: 'Write a memo summarizing this earnings report.',
graph_data: {
sources: [
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
],
sources: [{ file_id: 'file_id', snippet: 'snippet' }],
status: 'processing',
subqueries: [
{
answer: 'answer',
query: 'query',
sources: [
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
],
},
{
answer: 'answer',
query: 'query',
sources: [
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
],
},
{
answer: 'answer',
query: 'query',
sources: [
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
{ file_id: 'file_id', snippet: 'snippet' },
],
},
{ answer: 'answer', query: 'query', sources: [{ file_id: 'file_id', snippet: 'snippet' }] },
],
},
name: 'name',
Expand All @@ -75,7 +45,7 @@ describe('resource chat', () => {
logprobs: true,
max_tokens: 0,
n: 0,
stop: ['string', 'string', 'string'],
stop: ['string'],
stream: false,
stream_options: { include_usage: true },
temperature: 0,
Expand All @@ -85,14 +55,6 @@ describe('resource chat', () => {
function: { name: 'name', description: 'description', parameters: { foo: 'bar' } },
type: 'function',
},
{
function: { name: 'name', description: 'description', parameters: { foo: 'bar' } },
type: 'function',
},
{
function: { name: 'name', description: 'description', parameters: { foo: 'bar' } },
type: 'function',
},
],
top_p: 0,
});
Expand Down
16 changes: 2 additions & 14 deletions tests/api-resources/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,7 @@ describe('resource files', () => {
});

test('retry: only required params', async () => {
const responsePromise = client.files.retry({
file_ids: [
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
],
});
const responsePromise = client.files.retry({ file_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'] });
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
Expand All @@ -106,13 +100,7 @@ describe('resource files', () => {
});

test('retry: required and optional params', async () => {
const response = await client.files.retry({
file_ids: [
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
],
});
const response = await client.files.retry({ file_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'] });
});

// requests with binary data not yet supported in test environment
Expand Down
40 changes: 0 additions & 40 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -759,16 +759,6 @@
dependencies:
"@swc/counter" "^0.1.3"

"@ts-morph/common@~0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.20.0.tgz#3f161996b085ba4519731e4d24c35f6cba5b80af"
integrity sha512-7uKjByfbPpwuzkstL3L5MQyuXPSKdoNG93Fmi2JoDcTf3pEP731JdRFAduRVkOs8oqxPsXKA+ScrWkdQ8t/I+Q==
dependencies:
fast-glob "^3.2.12"
minimatch "^7.4.3"
mkdirp "^2.1.6"
path-browserify "^1.0.1"

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
Expand Down Expand Up @@ -1315,11 +1305,6 @@ co@^4.6.0:
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==

code-block-writer@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-12.0.0.tgz#4dd58946eb4234105aff7f0035977b2afdc2a770"
integrity sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==

collect-v8-coverage@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9"
Expand Down Expand Up @@ -2680,23 +2665,11 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimatch@^7.4.3:
version "7.4.6"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-7.4.6.tgz#845d6f254d8f4a5e4fd6baf44d5f10c8448365fb"
integrity sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==

mkdirp@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19"
integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
Expand Down Expand Up @@ -2860,11 +2833,6 @@ parse-json@^5.2.0:
json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6"

path-browserify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==

path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
Expand Down Expand Up @@ -3283,14 +3251,6 @@ ts-jest@^29.1.0:
semver "^7.5.3"
yargs-parser "^21.0.1"

ts-morph@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-19.0.0.tgz#43e95fb0156c3fe3c77c814ac26b7d0be2f93169"
integrity sha512-D6qcpiJdn46tUqV45vr5UGM2dnIEuTGNxVhg0sk5NX11orcouwj6i1bMqZIz2mZTZB1Hcgy7C3oEVhAT+f6mbQ==
dependencies:
"@ts-morph/common" "~0.20.0"
code-block-writer "^12.0.0"

ts-node@^10.5.0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5"
Expand Down

0 comments on commit 29ed155

Please sign in to comment.