diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e36af54..9ae8398 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: - name: Set up pnpm uses: pnpm/action-setup@v4 with: - version: '10.27.0' + version: '10.30.1' - name: Bootstrap run: ./scripts/bootstrap @@ -56,7 +56,7 @@ jobs: - name: Set up pnpm uses: pnpm/action-setup@v4 with: - version: '10.27.0' + version: '10.30.1' - name: Bootstrap run: ./scripts/bootstrap @@ -94,7 +94,7 @@ jobs: - name: Set up pnpm uses: pnpm/action-setup@v4 with: - version: '10.27.0' + version: '10.30.1' - name: Bootstrap run: ./scripts/bootstrap diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2e2ea5f..5c2117a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.0.0-alpha.8" + ".": "1.0.0-alpha.9" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f0a3e7..22ea625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 1.0.0-alpha.9 (2026-02-23) + +Full Changelog: [v1.0.0-alpha.8...v1.0.0-alpha.9](https://github.com/warpdotdev/oz-sdk-typescript/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) + +### Bug Fixes + +* **docs/contributing:** correct pnpm link command ([7de7a5b](https://github.com/warpdotdev/oz-sdk-typescript/commit/7de7a5bba2bb7ed232bd7bed6bb10a47aa838678)) + + +### Chores + +* **internal/client:** fix form-urlencoded requests ([8193077](https://github.com/warpdotdev/oz-sdk-typescript/commit/8193077e420b7c6c8bf1cd17bfcd283ac0c7860b)) +* **internal:** avoid type checking errors with ts-reset ([be80828](https://github.com/warpdotdev/oz-sdk-typescript/commit/be80828361a15d93dafc3063e90f5c1723e312f4)) +* **internal:** remove mock server code ([7f8bc16](https://github.com/warpdotdev/oz-sdk-typescript/commit/7f8bc16fa7c3186906067ef3b4494e08a32a4c6d)) +* **internal:** upgrade pnpm version ([b8d239e](https://github.com/warpdotdev/oz-sdk-typescript/commit/b8d239eed2092ca12b758ece537c54cba4c00815)) +* update mock server docs ([b6d0ab3](https://github.com/warpdotdev/oz-sdk-typescript/commit/b6d0ab3a27db6f7e2ee50a0e62952981feff5199)) + ## 1.0.0-alpha.8 (2026-02-08) Full Changelog: [v1.0.0-alpha.7...v1.0.0-alpha.8](https://github.com/warpdotdev/oz-sdk-typescript/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b2aed4d..d673dbf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,17 +60,11 @@ $ yarn link oz-agent-sdk # With pnpm $ pnpm link --global $ cd ../my-package -$ pnpm link -—global oz-agent-sdk +$ pnpm link --global oz-agent-sdk ``` ## Running tests -Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. - -```sh -$ npx prism mock path/to/your/openapi.yml -``` - ```sh $ pnpm run test ``` diff --git a/package.json b/package.json index f2d3b28..dc72c0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oz-agent-sdk", - "version": "1.0.0-alpha.8", + "version": "1.0.0-alpha.9", "description": "The official TypeScript library for the Oz API API", "author": "Oz API <>", "types": "dist/index.d.ts", @@ -8,7 +8,7 @@ "type": "commonjs", "repository": "github:warpdotdev/oz-sdk-typescript", "license": "Apache-2.0", - "packageManager": "pnpm@10.27.0", + "packageManager": "pnpm@10.30.1", "files": [ "**/*" ], diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6e..0000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index 7bce051..548da9b 100755 --- a/scripts/test +++ b/scripts/test @@ -4,53 +4,7 @@ set -e cd "$(dirname "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" ./node_modules/.bin/jest "$@" diff --git a/src/client.ts b/src/client.ts index cffca6d..a23a24a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -445,7 +445,7 @@ export class OzAPI { loggerFor(this).info(`${responseInfo} - ${retryMessage}`); const errText = await response.text().catch((err: any) => castToError(err).message); - const errJSON = safeJSON(errText); + const errJSON = safeJSON(errText) as any; const errMessage = errJSON ? undefined : errText; loggerFor(this).debug( @@ -694,6 +694,14 @@ export class OzAPI { (Symbol.iterator in body && 'next' in body && typeof body.next === 'function')) ) { return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable) }; + } else if ( + typeof body === 'object' && + headers.values.get('content-type') === 'application/x-www-form-urlencoded' + ) { + return { + bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' }, + body: this.stringifyQuery(body as Record), + }; } else { return this.#encoder({ body, headers }); } diff --git a/src/version.ts b/src/version.ts index 0d4128f..5d13c5b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.0.0-alpha.8'; // x-release-please-version +export const VERSION = '1.0.0-alpha.9'; // x-release-please-version diff --git a/tests/api-resources/agent/agent.test.ts b/tests/api-resources/agent/agent.test.ts index 5870223..a3f1749 100644 --- a/tests/api-resources/agent/agent.test.ts +++ b/tests/api-resources/agent/agent.test.ts @@ -8,7 +8,7 @@ const client = new OzAPI({ }); describe('resource agent', () => { - // Prism tests are disabled + // Mock server tests are disabled test.skip('list', async () => { const responsePromise = client.agent.list(); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource agent', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( @@ -35,7 +35,7 @@ describe('resource agent', () => { ).rejects.toThrow(OzAPI.NotFoundError); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('run', async () => { const responsePromise = client.agent.run({}); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/agent/runs.test.ts b/tests/api-resources/agent/runs.test.ts index efa28c3..153f8d5 100644 --- a/tests/api-resources/agent/runs.test.ts +++ b/tests/api-resources/agent/runs.test.ts @@ -8,7 +8,7 @@ const client = new OzAPI({ }); describe('resource runs', () => { - // Prism tests are disabled + // Mock server tests are disabled test.skip('retrieve', async () => { const responsePromise = client.agent.runs.retrieve('runId'); const rawResponse = await responsePromise.asResponse(); @@ -20,7 +20,7 @@ describe('resource runs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('list', async () => { const responsePromise = client.agent.runs.list(); const rawResponse = await responsePromise.asResponse(); @@ -32,7 +32,7 @@ describe('resource runs', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error await expect( @@ -60,7 +60,7 @@ describe('resource runs', () => { ).rejects.toThrow(OzAPI.NotFoundError); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('cancel', async () => { const responsePromise = client.agent.runs.cancel('runId'); const rawResponse = await responsePromise.asResponse(); diff --git a/tests/api-resources/agent/schedules.test.ts b/tests/api-resources/agent/schedules.test.ts index ea36bce..ca0b6c1 100644 --- a/tests/api-resources/agent/schedules.test.ts +++ b/tests/api-resources/agent/schedules.test.ts @@ -8,7 +8,7 @@ const client = new OzAPI({ }); describe('resource schedules', () => { - // Prism tests are disabled + // Mock server tests are disabled test.skip('create: only required params', async () => { const responsePromise = client.agent.schedules.create({ cron_schedule: '0 9 * * *', @@ -24,7 +24,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('create: required and optional params', async () => { const response = await client.agent.schedules.create({ cron_schedule: '0 9 * * *', @@ -54,7 +54,7 @@ describe('resource schedules', () => { }); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('retrieve', async () => { const responsePromise = client.agent.schedules.retrieve('scheduleId'); const rawResponse = await responsePromise.asResponse(); @@ -66,7 +66,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('update: only required params', async () => { const responsePromise = client.agent.schedules.update('scheduleId', { cron_schedule: 'cron_schedule', @@ -83,7 +83,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('update: required and optional params', async () => { const response = await client.agent.schedules.update('scheduleId', { cron_schedule: 'cron_schedule', @@ -112,7 +112,7 @@ describe('resource schedules', () => { }); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('list', async () => { const responsePromise = client.agent.schedules.list(); const rawResponse = await responsePromise.asResponse(); @@ -124,7 +124,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('delete', async () => { const responsePromise = client.agent.schedules.delete('scheduleId'); const rawResponse = await responsePromise.asResponse(); @@ -136,7 +136,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('pause', async () => { const responsePromise = client.agent.schedules.pause('scheduleId'); const rawResponse = await responsePromise.asResponse(); @@ -148,7 +148,7 @@ describe('resource schedules', () => { expect(dataAndResponse.response).toBe(rawResponse); }); - // Prism tests are disabled + // Mock server tests are disabled test.skip('resume', async () => { const responsePromise = client.agent.schedules.resume('scheduleId'); const rawResponse = await responsePromise.asResponse();