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 @@
{
".": "7.7.0"
".": "7.7.1"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 81
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-3fc1c86b4a83a16393aaf17d1fb3ac6098d30dd057ba872973b57285a7a3f0d0.yml
openapi_spec_hash: 02a545d217b13399f311e99561f9de1d
config_hash: 0789c3cddc625bb9712b3bded274ab6c
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-44c2e612f5d40e03f56712a4e123a193e6ea03cc64a91d0c34ee094563dafa1c.yml
openapi_spec_hash: 40bf6b3f7992d55f1bd543f32564ea86
config_hash: b1f6d0f43161b66d201043fcbe5c5695
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 7.7.1 (2026-03-03)

Full Changelog: [v7.7.0...v7.7.1](https://github.com/trycourier/courier-node/compare/v7.7.0...v7.7.1)

### Bug Fixes

* **api:** remove body_token parameter from tokens.addSingle method ([b8de6f7](https://github.com/trycourier/courier-node/commit/b8de6f7d6c936dce1b5e458b881635a4e0d920e4))
* **api:** remove brand field from ElementalContent ([2a3d25d](https://github.com/trycourier/courier-node/commit/2a3d25dac9b544179e928800dba0f53623cd3734))
* **docs/contributing:** correct pnpm link command ([d3b4a96](https://github.com/trycourier/courier-node/commit/d3b4a96b0d1112692832cff49bfd7897ec77df8c))


### Chores

* **internal/client:** fix form-urlencoded requests ([45deac0](https://github.com/trycourier/courier-node/commit/45deac06aa22be68b4ac57136d065dd85668901c))
* **internal:** avoid type checking errors with ts-reset ([88b8c18](https://github.com/trycourier/courier-node/commit/88b8c18a47ac0d71e5a58274eeb705b41dfb42c3))
* **internal:** codegen related update ([879dd2f](https://github.com/trycourier/courier-node/commit/879dd2f830081dd643bff1afafe1a4f3413f80c1))
* **internal:** remove mock server code ([cbd7d67](https://github.com/trycourier/courier-node/commit/cbd7d675567742542d481cf9275fa765524f2dae))
* update mock server docs ([f4a7c1f](https://github.com/trycourier/courier-node/commit/f4a7c1f3590b16463dd8edb1ef81a188ae276d06))


### Documentation

* add AUTO-GENERATED-OVERVIEW markers for README sync ([#228](https://github.com/trycourier/courier-node/issues/228)) ([63dc300](https://github.com/trycourier/courier-node/commit/63dc300ce3d67d339942446c86edeaa0f4aa69ee))
* sync README from mintlify-docs (2026-02-20 18:11 UTC) ([#229](https://github.com/trycourier/courier-node/issues/229)) ([f35a2aa](https://github.com/trycourier/courier-node/commit/f35a2aa144409b12c125a564a003421a9b8a7a5b))

## 7.7.0 (2026-02-06)

Full Changelog: [v7.6.3...v7.7.0](https://github.com/trycourier/courier-node/compare/v7.6.3...v7.7.0)
Expand Down
8 changes: 1 addition & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@ $ yarn link @trycourier/courier
# With pnpm
$ pnpm link --global
$ cd ../my-package
$ pnpm link -global @trycourier/courier
$ pnpm link --global @trycourier/courier
```

## 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
$ yarn run test
```
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,4 @@ Methods:
- <code title="get /users/{user_id}/tokens">client.users.tokens.<a href="./src/resources/users/tokens.ts">list</a>(userID) -> TokenListResponse</code>
- <code title="delete /users/{user_id}/tokens/{token}">client.users.tokens.<a href="./src/resources/users/tokens.ts">delete</a>(token, { ...params }) -> void</code>
- <code title="put /users/{user_id}/tokens">client.users.tokens.<a href="./src/resources/users/tokens.ts">addMultiple</a>(userID) -> void</code>
- <code title="put /users/{user_id}/tokens/{token}">client.users.tokens.<a href="./src/resources/users/tokens.ts">addSingle</a>(pathToken, { ...params }) -> void</code>
- <code title="put /users/{user_id}/tokens/{token}">client.users.tokens.<a href="./src/resources/users/tokens.ts">addSingle</a>(token, { ...params }) -> void</code>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/courier",
"version": "7.7.0",
"version": "7.7.1",
"description": "The official TypeScript library for the Courier API",
"author": "Courier <support@courier.com>",
"types": "dist/index.d.ts",
Expand Down
41 changes: 0 additions & 41 deletions scripts/mock

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
18 changes: 13 additions & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
import { getPlatformHeaders } from './internal/detect-platform';
import * as Shims from './internal/shims';
import * as Opts from './internal/request-options';
import * as qs from './internal/qs';
import { stringifyQuery } from './internal/utils/query';
import { VERSION } from './version';
import * as Errors from './core/error';
import * as Uploads from './core/uploads';
Expand Down Expand Up @@ -331,8 +331,8 @@ export class Courier {
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
}

protected stringifyQuery(query: Record<string, unknown>): string {
return qs.stringify(query, { arrayFormat: 'comma' });
protected stringifyQuery(query: object | Record<string, unknown>): string {
return stringifyQuery(query);
}

private getUserAgent(): string {
Expand Down Expand Up @@ -369,7 +369,7 @@ export class Courier {
}

if (typeof query === 'object' && query && !Array.isArray(query)) {
url.search = this.stringifyQuery(query as Record<string, unknown>);
url.search = this.stringifyQuery(query);
}

return url.toString();
Expand Down Expand Up @@ -553,7 +553,7 @@ export class Courier {
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(
Expand Down Expand Up @@ -802,6 +802,14 @@ export class Courier {
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
) {
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
} 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),
};
} else {
return this.#encoder({ body, headers });
}
Expand Down
1 change: 1 addition & 0 deletions src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './utils/env';
export * from './utils/log';
export * from './utils/uuid';
export * from './utils/sleep';
export * from './utils/query';
7 changes: 7 additions & 0 deletions src/internal/utils/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as qs from '../qs/stringify';

export function stringifyQuery(query: object | Record<string, unknown>) {
return qs.stringify(query, { arrayFormat: 'comma' });
}
2 changes: 0 additions & 2 deletions src/resources/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ export interface ElementalContent {
* For example, "2022-01-01"
*/
version: string;

brand?: string | null;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/resources/users/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ export class Tokens extends APIResource {
* ```ts
* await client.users.tokens.addSingle('token', {
* user_id: 'user_id',
* body_token: 'token',
* provider_key: 'firebase-fcm',
* });
* ```
*/
addSingle(pathToken: string, params: TokenAddSingleParams, options?: RequestOptions): APIPromise<void> {
addSingle(token: string, params: TokenAddSingleParams, options?: RequestOptions): APIPromise<void> {
const { user_id, ...body } = params;
return this._client.put(path`/users/${user_id}/tokens/${pathToken}`, {
return this._client.put(path`/users/${user_id}/tokens/${token}`, {
body,
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
Expand Down Expand Up @@ -272,11 +271,6 @@ export interface TokenAddSingleParams {
*/
user_id: string;

/**
* Body param: Full body of the token. Must match token in URL path parameter.
*/
body_token: string;

/**
* Body param
*/
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '7.7.0'; // x-release-please-version
export const VERSION = '7.7.1'; // x-release-please-version
14 changes: 7 additions & 7 deletions tests/api-resources/audiences.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const client = new Courier({
});

describe('resource audiences', () => {
// Prism tests are disabled
// Mock server tests are disabled
test.skip('retrieve', async () => {
const responsePromise = client.audiences.retrieve('audience_id');
const rawResponse = await responsePromise.asResponse();
Expand All @@ -20,7 +20,7 @@ describe('resource audiences', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('update', async () => {
const responsePromise = client.audiences.update('audience_id', {});
const rawResponse = await responsePromise.asResponse();
Expand All @@ -32,7 +32,7 @@ describe('resource audiences', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('list', async () => {
const responsePromise = client.audiences.list();
const rawResponse = await responsePromise.asResponse();
Expand All @@ -44,15 +44,15 @@ describe('resource audiences', () => {
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(
client.audiences.list({ cursor: 'cursor' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Courier.NotFoundError);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('delete', async () => {
const responsePromise = client.audiences.delete('audience_id');
const rawResponse = await responsePromise.asResponse();
Expand All @@ -64,7 +64,7 @@ describe('resource audiences', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('listMembers', async () => {
const responsePromise = client.audiences.listMembers('audience_id');
const rawResponse = await responsePromise.asResponse();
Expand All @@ -76,7 +76,7 @@ describe('resource audiences', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('listMembers: 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(
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/audit-events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const client = new Courier({
});

describe('resource auditEvents', () => {
// Prism tests are disabled
// Mock server tests are disabled
test.skip('retrieve', async () => {
const responsePromise = client.auditEvents.retrieve('audit-event-id');
const rawResponse = await responsePromise.asResponse();
Expand All @@ -20,7 +20,7 @@ describe('resource auditEvents', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('list', async () => {
const responsePromise = client.auditEvents.list();
const rawResponse = await responsePromise.asResponse();
Expand All @@ -32,7 +32,7 @@ describe('resource auditEvents', () => {
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(
Expand Down
4 changes: 2 additions & 2 deletions tests/api-resources/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const client = new Courier({
});

describe('resource auth', () => {
// Prism tests are disabled
// Mock server tests are disabled
test.skip('issueToken: only required params', async () => {
const responsePromise = client.auth.issueToken({
expires_in: '$YOUR_NUMBER days',
Expand All @@ -24,7 +24,7 @@ describe('resource auth', () => {
expect(dataAndResponse.response).toBe(rawResponse);
});

// Prism tests are disabled
// Mock server tests are disabled
test.skip('issueToken: required and optional params', async () => {
const response = await client.auth.issueToken({
expires_in: '$YOUR_NUMBER days',
Expand Down
Loading