Skip to content
Closed
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
222 changes: 133 additions & 89 deletions DefaultApi.md

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions apis/exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,58 @@ export class ApiException<T> extends Error {
// Reference: https://github.com/microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, ApiException.prototype);
}

/**
* The error messages carried by the response body, normalized to a flat
* string array regardless of which envelope shape the API returned
* (`{ errors: "..." }`, `{ errors: ["..."] }`, `{ errors: [{ code, title }] }`,
* or an object map such as `{ errors: { invalid_aliases: {...} } }`, which is
* surfaced as `"<key>: <value>"` entries). Returns an empty array when the
* body is not a recognizable error envelope. The raw body remains on `body`.
*/
public get errorMessages(): string[] {
let parsed: any = this.body;
if (typeof parsed === "string") {
try {
parsed = JSON.parse(parsed);
} catch {
return [];
}
}
if (parsed === null || typeof parsed !== "object") {
return [];
}
const errors: any = parsed.errors;
if (typeof errors === "string") {
return [errors];
}
if (Array.isArray(errors)) {
return errors
.map((e: any) => {
if (typeof e === "string") {
return e;
}
if (e !== null && typeof e === "object") {
const title = typeof e.title === "string" ? e.title : undefined;
const code = typeof e.code === "string" ? e.code : (e.code != null ? String(e.code) : undefined);
return title || code;
}
return undefined;
})
.filter((m: any): m is string => typeof m === "string");
}
if (errors !== null && typeof errors === "object") {
// Object-shaped envelopes (e.g. { invalid_aliases: {...} }) carry data
// under arbitrary keys; surface each so it isn't silently dropped. Key
// order is unspecified, so sort for deterministic output.
return Object.keys(errors)
.map((key: string) => {
const value: any = errors[key];
const rendered = typeof value === "string" ? value : JSON.stringify(value);
return key + ": " + rendered;
})
.sort();
}
return [];
}
}
1 change: 1 addition & 0 deletions dist/apis/exception.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export declare class ApiException<T> extends Error {
constructor(code: number, message: string, body: T, headers: {
[key: string]: string;
});
get errorMessages(): string[];
}
43 changes: 43 additions & 0 deletions dist/apis/exception.js

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

2 changes: 1 addition & 1 deletion dist/apis/exception.js.map

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

1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./servers";
export { RequiredError } from "./apis/baseapi";
export { PromiseMiddleware as Middleware } from './middleware';
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
export * from "./errors";
1 change: 1 addition & 0 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

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

25 changes: 25 additions & 0 deletions errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Generated from inputs/api/error-catalog.json. Do not edit by hand.

/**
* Sentinel error message strings the OneSignal API can return. Each value
* equals the literal message the server emits, so you can test membership
* against `ApiException.errorMessages` (e.g. NO_TARGETING_SPECIFIED).
*
* Note: 200-status sentinels such as NO_SUBSCRIBERS arrive on a successful
* response (CreateNotificationSuccessResponse.errors), not via the exception
* accessor — read the response's `errors` field for those.
*/
export const OneSignalErrors = {
/** HTTP 403 | retryable: no | emitted by: any API-key-authenticated endpoint (REST or Organization key) | note: Generic auth-failure message the public api.onesignal.com edge returns for any invalid or mismatched key — REST or Organization — so a single sentinel covers both. Supersedes the Rails-monolith INVALID_REST_API_KEY / INVALID_USER_AUTH_KEY strings, which the public host no longer returns verbatim. Note the double space after 'denied.' */
INVALID_API_KEY: "Access denied. Please include an 'Authorization: ...' header with a valid API key (https://documentation.onesignal.com/docs/en/keys-and-ids#api-keys).",
/** HTTP 400, 404 | retryable: no | emitted by: POST /notifications/{id}/history, POST /notifications/{id}/messages, GET /notifications/{id} (export) | note: Verified live 2026-06-16: GET /notifications/{bogus-uuid} returns 404 with this exact message. */
NOTIFICATION_NOT_FOUND: "Notification not found",
/** HTTP 200 | retryable: no | emitted by: POST /notifications | note: Returned with HTTP 200 OK (id is empty), not an error status. The flagship case for the errorMessages accessor — lets callers distinguish a sent notification from a no-op without parsing the polymorphic 200 body. */
NO_SUBSCRIBERS: "All included players are not subscribed",
/** HTTP 400 | retryable: no | emitted by: POST /notifications | note: Verified live 2026-06-16: a no-targeting POST /notifications returns 400 with this exact message. */
NO_TARGETING_SPECIFIED: "You must include which players, segments, or tags you wish to send this notification to.",
/** HTTP 503 | retryable: yes | emitted by: any endpoint (pgbouncer rejection) | note: Transient DB/pgbouncer failure — the canonical retryable sentinel. */
SERVICE_UNAVAILABLE: "Service temporarily unavailable",
} as const;

export type OneSignalErrorMessage = typeof OneSignalErrors[keyof typeof OneSignalErrors];
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export { RequiredError } from "./apis/baseapi";
export { PromiseMiddleware as Middleware } from './middleware';
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';

export * from "./errors";
2 changes: 1 addition & 1 deletion models/ApiKeyToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ApiKeyTokensListResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotificationAllOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/BasicNotificationAllOfAndroidBackgroundLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CopyTemplateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateApiKeyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateApiKeyResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateNotificationSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateSegmentConflictResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateSegmentSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateTemplateRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponseErrorsInner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CreateUserConflictResponseErrorsItemsMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CustomEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/CustomEventsRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/DeliveryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportEventsSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportSubscriptionsRequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/ExportSubscriptionsSuccessResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/Filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
2 changes: 1 addition & 1 deletion models/FilterExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OneSignal
* A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
*
* API Version: 5.6.0
* API Version: 5.7.0
* Contact: devrel@onesignal.com
*/

Expand Down
Loading