@sentry/api 0.353.0 → 0.356.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -25
- package/dist/client/types.gen.d.ts +14 -16
- package/dist/client/utils.gen.d.ts +1 -1
- package/dist/error-results.gen.d.ts +255 -233
- package/dist/index.d.ts +3 -3
- package/dist/index.js +464 -359
- package/dist/pagination.gen.d.ts +97 -229
- package/dist/sdk.gen.d.ts +130 -8
- package/dist/sentry-client.gen.d.ts +2885 -540
- package/dist/sentry-errors.d.ts +23 -10
- package/dist/sentry-pagination.d.ts +35 -62
- package/dist/types.gen.d.ts +909 -258
- package/dist/valibot.gen.d.ts +457 -167
- package/dist/valibot.js +590 -175
- package/dist/zod.gen.d.ts +4094 -3184
- package/dist/zod.js +668 -236
- package/package.json +2 -1
package/dist/sentry-errors.d.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type SdkResult<TData = unknown, TError = unknown> = {
|
|
7
7
|
data: TData;
|
|
8
|
-
error
|
|
8
|
+
error?: never;
|
|
9
9
|
request: Request;
|
|
10
10
|
response: Response;
|
|
11
11
|
} | {
|
|
12
|
-
data
|
|
12
|
+
data?: never;
|
|
13
13
|
error: TError;
|
|
14
14
|
request: Request;
|
|
15
15
|
response: Response | undefined;
|
|
@@ -21,9 +21,12 @@ export type DocumentedSentryApiError<TErrorMap> = {
|
|
|
21
21
|
}[ErrorStatus<TErrorMap>];
|
|
22
22
|
/** An API error returned under a status absent from the operation's schema. */
|
|
23
23
|
export type UndocumentedSentryApiError = SentryApiError<number, unknown, false>;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Non-HTTP failures propagate unchanged. Typed-error helpers only
|
|
26
|
+
* return HTTP failures and no longer produce this legacy wrapper.
|
|
27
|
+
*/
|
|
25
28
|
export type SentryApiTransportError = SentryApiError<undefined, unknown, false>;
|
|
26
|
-
export type SentryApiResultError<TErrorMap> = DocumentedSentryApiError<TErrorMap> | UndocumentedSentryApiError
|
|
29
|
+
export type SentryApiResultError<TErrorMap> = DocumentedSentryApiError<TErrorMap> | UndocumentedSentryApiError;
|
|
27
30
|
export type NarrowedResult<TData, TErrorMap> = {
|
|
28
31
|
ok: true;
|
|
29
32
|
data: TData;
|
|
@@ -38,18 +41,28 @@ export declare class SentryApiError<TStatus extends number | undefined = number
|
|
|
38
41
|
readonly body: TBody;
|
|
39
42
|
readonly response: Response | undefined;
|
|
40
43
|
readonly documented: TDocumented;
|
|
41
|
-
|
|
44
|
+
readonly request?: Request;
|
|
45
|
+
/** Original response text, captured during the same read as the parsed body. */
|
|
46
|
+
readonly rawBody?: string;
|
|
47
|
+
constructor(status: TStatus, body: TBody, response: Response | undefined, documented: TDocumented, message?: string, options?: ErrorOptions & {
|
|
48
|
+
request?: Request;
|
|
49
|
+
rawBody?: string;
|
|
50
|
+
});
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
|
-
* Convert an SDK result to a status-discriminated result.
|
|
53
|
+
* Convert an SDK result to a status-discriminated HTTP result.
|
|
45
54
|
*
|
|
46
55
|
* Prefer the generated `narrowError_<operation>` wrappers. They supply the
|
|
47
56
|
* operation's complete error map and documented statuses automatically.
|
|
57
|
+
* Base SentryApiError instances for this response are reclassified, including
|
|
58
|
+
* ones supplied by an interceptor. Other errors (including subclasses) are
|
|
59
|
+
* thrown unchanged. Status narrowing does not validate the response body.
|
|
48
60
|
*/
|
|
49
|
-
export declare const narrowError: <TData, TErrorMap>(result: SdkResult<TData
|
|
61
|
+
export declare const narrowError: <TData, TErrorMap>(result: SdkResult<TData>, documentedStatuses: ReadonlyArray<ErrorStatus<TErrorMap>>) => NarrowedResult<TData, TErrorMap>;
|
|
50
62
|
/**
|
|
51
|
-
* Call an SDK operation and
|
|
52
|
-
* Generated operation wrappers use this helper.
|
|
63
|
+
* Call an SDK operation and narrow its default HTTP errors by status.
|
|
64
|
+
* Generated operation wrappers use this helper. Errors outside narrowError's
|
|
65
|
+
* HTTP contract reject without being relabeled or wrapped.
|
|
53
66
|
*/
|
|
54
|
-
export declare const callWithTypedErrors: <TData, TErrorMap>(call: () => Promise<SdkResult<TData
|
|
67
|
+
export declare const callWithTypedErrors: <TData, TErrorMap>(call: () => Promise<SdkResult<TData>>, documentedStatuses: ReadonlyArray<ErrorStatus<TErrorMap>>) => Promise<NarrowedResult<TData, TErrorMap>>;
|
|
55
68
|
export {};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* These helpers make it ergonomic to paginate through results
|
|
6
6
|
* returned by the generated SDK functions.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import type { SdkResult } from "./sentry-errors";
|
|
9
9
|
export type UnwrappedResult<TData> = {
|
|
10
10
|
data: TData;
|
|
11
11
|
response: Response;
|
|
@@ -19,36 +19,32 @@ export type PaginatedResponse<T> = {
|
|
|
19
19
|
/** Cursor for the previous page. `undefined` on the first page. */
|
|
20
20
|
prevCursor?: string;
|
|
21
21
|
};
|
|
22
|
+
/** Aggregate data has no single HTTP response. Only `exhausted` means complete. */
|
|
23
|
+
export type PaginatedCollection<TItem> = {
|
|
24
|
+
data: Array<TItem>;
|
|
25
|
+
stopReason: "exhausted" | "limit" | "maxPages";
|
|
26
|
+
/** Omitted when exhausted or when trimming a page makes continuation unsafe. */
|
|
27
|
+
nextCursor?: string;
|
|
28
|
+
};
|
|
22
29
|
export type PaginateAllOptions = {
|
|
23
30
|
/** Hard cap on the number of pages fetched. Default: 50. */
|
|
24
31
|
maxPages?: number;
|
|
32
|
+
/** Resume from a previous nextCursor, keeping the same filters and page size. */
|
|
33
|
+
startCursor?: string;
|
|
25
34
|
};
|
|
26
35
|
export type PaginateUpToOptions = {
|
|
27
36
|
/** Hard cap on the number of items returned. Required. */
|
|
28
37
|
limit: number;
|
|
29
38
|
/** Safety cap on the number of pages fetched. Default: 50. */
|
|
30
39
|
maxPages?: number;
|
|
31
|
-
/** Resume
|
|
40
|
+
/** Resume forward traversal from a previous nextCursor, keeping the same query. */
|
|
32
41
|
startCursor?: string;
|
|
33
42
|
/** Called after each page is fetched. Useful for progress indicators. */
|
|
34
43
|
onPage?: (fetched: number, limit: number) => void;
|
|
35
|
-
/**
|
|
36
|
-
* When true, preserve `nextCursor` even when the last page was trimmed
|
|
37
|
-
* to fit `limit`. Default: false (the safe default — see body comment).
|
|
38
|
-
*
|
|
39
|
-
* Use this only for endpoints that have **no** server-side per-page
|
|
40
|
-
* control (so the trimmed tail items remain reachable via the same
|
|
41
|
-
* cursor on the next call). Sentry's `/issues/{id}/events/` is one
|
|
42
|
-
* such endpoint: it has no `per_page` param, so dropping the cursor
|
|
43
|
-
* on overshoot would orphan the items the helper trimmed.
|
|
44
|
-
*
|
|
45
|
-
* For endpoints that DO support `per_page` / `limit`, leave this
|
|
46
|
-
* `false` — returning a cursor that points past trimmed items would
|
|
47
|
-
* cause callers resuming pagination to skip records.
|
|
48
|
-
*/
|
|
49
|
-
keepCursorOnOvershoot?: boolean;
|
|
50
44
|
};
|
|
51
45
|
export type PageFetcher<TData, TError> = (cursor: string | undefined) => Promise<SdkResult<TData, TError>>;
|
|
46
|
+
/** The remaining item budget lets a custom fetcher reduce its HTTP page size. */
|
|
47
|
+
export type BudgetedPageFetcher<TData, TError> = (cursor: string | undefined, remaining: number) => Promise<SdkResult<TData, TError>>;
|
|
52
48
|
/**
|
|
53
49
|
* Parse Sentry's Link header to extract pagination cursors.
|
|
54
50
|
*
|
|
@@ -69,7 +65,7 @@ export declare const parseSentryLinkHeader: (header: string | null) => {
|
|
|
69
65
|
prevCursor?: string;
|
|
70
66
|
};
|
|
71
67
|
/**
|
|
72
|
-
* Internal: merge a managed
|
|
68
|
+
* Internal: merge a managed cursor and verified page-size budget into `options.query`
|
|
73
69
|
* and re-shape the result back to the SDK's `Options<TData>` type.
|
|
74
70
|
*
|
|
75
71
|
* Used exclusively by the auto-generated wrappers in `pagination.gen.ts`
|
|
@@ -91,17 +87,25 @@ export declare const parseSentryLinkHeader: (header: string | null) => {
|
|
|
91
87
|
export declare const _withCursor: <TOptions>(options: {
|
|
92
88
|
query?: unknown;
|
|
93
89
|
[k: string]: unknown;
|
|
94
|
-
}, cursor: string | undefined
|
|
90
|
+
}, cursor: string | undefined, pageSize?: {
|
|
91
|
+
parameter: "per_page" | "limit";
|
|
92
|
+
max: number;
|
|
93
|
+
remaining: number;
|
|
94
|
+
}) => TOptions;
|
|
95
95
|
/**
|
|
96
96
|
* Unwrap an SDK result, throwing on error.
|
|
97
97
|
*
|
|
98
98
|
* Returns `{ data, response }` so callers retain access to the
|
|
99
99
|
* raw Response (and its headers) for pagination or other needs.
|
|
100
100
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
101
|
+
* Throws the exact error supplied by the operation, including custom mapped
|
|
102
|
+
* errors and failures without an HTTP response. The SDK normalizes default
|
|
103
|
+
* HTTP errors before this helper runs.
|
|
104
|
+
*
|
|
105
|
+
* The context argument remains accepted for compatibility. It no longer
|
|
106
|
+
* changes error messages or wraps errors.
|
|
103
107
|
*/
|
|
104
|
-
export declare const unwrapResult: <TData, TError = unknown>(result: SdkResult<TData, TError>,
|
|
108
|
+
export declare const unwrapResult: <TData, TError = unknown>(result: SdkResult<TData, TError>, _context: string) => UnwrappedResult<TData>;
|
|
105
109
|
/**
|
|
106
110
|
* Unwrap an SDK result and extract pagination cursors from the
|
|
107
111
|
* Link header. Throws on error.
|
|
@@ -134,47 +138,16 @@ export declare const unwrapPaginatedResult: <TData>(result: SdkResult<TData>, co
|
|
|
134
138
|
*/
|
|
135
139
|
export declare const fetchPage: <TData, TError = unknown>(fetcher: PageFetcher<TData, TError>, context: string, cursor?: string) => Promise<PaginatedResponse<TData>>;
|
|
136
140
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* Fetches pages sequentially until there is no next cursor or
|
|
140
|
-
* `maxPages` is reached (default: 50). Returns all items concatenated.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* const allRepos = await paginateAll(
|
|
145
|
-
* (cursor) => listAnOrganization_sRepositories({
|
|
146
|
-
* path: { organization_id_or_slug: 'my-org' },
|
|
147
|
-
* query: { cursor },
|
|
148
|
-
* }),
|
|
149
|
-
* 'listRepos',
|
|
150
|
-
* );
|
|
151
|
-
* ```
|
|
141
|
+
* Collect pages until the collection is exhausted or `maxPages` is reached.
|
|
142
|
+
* A request cap returns `stopReason: "maxPages"` and a safe resume cursor.
|
|
152
143
|
*/
|
|
153
|
-
export declare const paginateAll: <TItem, TError = unknown>(fetcher: PageFetcher<Array<TItem>, TError>, context: string, options?: PaginateAllOptions) => Promise<
|
|
144
|
+
export declare const paginateAll: <TItem, TError = unknown>(fetcher: PageFetcher<Array<TItem>, TError>, context: string, options?: PaginateAllOptions) => Promise<PaginatedCollection<TItem>>;
|
|
154
145
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
146
|
+
* Collect up to `limit` items, passing the remaining budget to the fetcher.
|
|
147
|
+
* Generated wrappers use it to reduce supported HTTP page sizes.
|
|
157
148
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* mid-page, no `nextCursor` is returned and the caller should treat
|
|
162
|
-
* the result as the final page they're going to fetch.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```ts
|
|
166
|
-
* // Fetch up to 250 issues, in pages of 100 (Sentry's API max)
|
|
167
|
-
* const { data, nextCursor } = await paginateUpTo(
|
|
168
|
-
* (cursor) => listAnOrganization_sIssues({
|
|
169
|
-
* path: { organization_id_or_slug: 'my-org' },
|
|
170
|
-
* query: { cursor, limit: 100 },
|
|
171
|
-
* }),
|
|
172
|
-
* { limit: 250 },
|
|
173
|
-
* 'listIssues',
|
|
174
|
-
* );
|
|
175
|
-
* ```
|
|
149
|
+
* If a server still returns more items than fit, trim the page and omit its
|
|
150
|
+
* cursor: resuming past discarded items would skip records. Such a result
|
|
151
|
+
* has `stopReason: "limit"`, even if the server has no further pages.
|
|
176
152
|
*/
|
|
177
|
-
export declare const paginateUpTo: <TItem, TError = unknown>(fetcher:
|
|
178
|
-
data: Array<TItem>;
|
|
179
|
-
nextCursor?: string;
|
|
180
|
-
}>;
|
|
153
|
+
export declare const paginateUpTo: <TItem, TError = unknown>(fetcher: BudgetedPageFetcher<Array<TItem>, TError>, options: PaginateUpToOptions, context: string) => Promise<PaginatedCollection<TItem>>;
|