@sentry/api 0.445.0 → 0.446.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.
Files changed (39) hide show
  1. package/README.md +28 -0
  2. package/dist/api-client/api-path.d.ts +34 -0
  3. package/dist/api-client/auth-token.d.ts +6 -0
  4. package/dist/api-client/core.d.ts +84 -0
  5. package/dist/api-client/endpoints/client-keys.d.ts +38 -0
  6. package/dist/api-client/endpoints/dashboards.d.ts +23 -0
  7. package/dist/api-client/endpoints/index.d.ts +18 -0
  8. package/dist/api-client/endpoints/index.js +762 -0
  9. package/dist/api-client/endpoints/monitors.d.ts +49 -0
  10. package/dist/api-client/endpoints/organizations.d.ts +35 -0
  11. package/dist/api-client/endpoints/profiling.d.ts +32 -0
  12. package/dist/api-client/endpoints/projects.d.ts +63 -0
  13. package/dist/api-client/endpoints/releases.d.ts +45 -0
  14. package/dist/api-client/endpoints/replays.d.ts +53 -0
  15. package/dist/api-client/endpoints/repositories.d.ts +31 -0
  16. package/dist/api-client/endpoints/snapshots.d.ts +29 -0
  17. package/dist/api-client/endpoints/teams.d.ts +23 -0
  18. package/dist/api-client/endpoints/traces.d.ts +25 -0
  19. package/dist/api-client/endpoints/uptime-monitors.d.ts +61 -0
  20. package/dist/api-client/errors.d.ts +151 -0
  21. package/dist/api-client/idempotent-operations.d.ts +33 -0
  22. package/dist/api-client/index.d.ts +20 -0
  23. package/dist/api-client/index.js +1647 -0
  24. package/dist/api-client/pagination.d.ts +119 -0
  25. package/dist/api-client/response-cache/body.d.ts +31 -0
  26. package/dist/api-client/response-cache/index.d.ts +14 -0
  27. package/dist/api-client/response-cache/invalidation.d.ts +42 -0
  28. package/dist/api-client/response-cache/keys.d.ts +25 -0
  29. package/dist/api-client/response-cache/memory-store.d.ts +37 -0
  30. package/dist/api-client/response-cache/policy.d.ts +81 -0
  31. package/dist/api-client/response-cache/store.d.ts +52 -0
  32. package/dist/api-client/response-cache/tiers.d.ts +28 -0
  33. package/dist/api-client/response.d.ts +27 -0
  34. package/dist/api-client/retry.d.ts +57 -0
  35. package/dist/api-client/standard-schema.d.ts +65 -0
  36. package/dist/api-client/time-params.d.ts +46 -0
  37. package/dist/api-client/transport.d.ts +156 -0
  38. package/dist/api-client/validate.d.ts +22 -0
  39. package/package.json +15 -2
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Authenticated fetch for Sentry API requests, shared by the CLI and MCP.
3
+ * Standard Web APIs only, so it runs in Node and Cloudflare Workers.
4
+ *
5
+ * Per request it sets the Authorization header, refreshes the credential once
6
+ * after a 401 (any method), times out each attempt, retries through
7
+ * `retry`, replays request bodies, optionally follows redirects only to
8
+ * trusted origins, and serves and invalidates cached GETs through an injected
9
+ * cache. The host supplies credentials, header rules, error classes, logging,
10
+ * and spans.
11
+ */
12
+ import { type RetryPolicy } from "./retry.js";
13
+ import type { CacheLookup } from "./response-cache/policy.js";
14
+ type FetchInput = Request | string | URL;
15
+ /** The fields the transport reads; hosts extend it with their own. */
16
+ export type TransportCredential = {
17
+ token: string;
18
+ /** Stable hash of the login, for cache scoping; never a raw token. */
19
+ identity: string;
20
+ };
21
+ export type CredentialProvider<C extends TransportCredential> = {
22
+ /** The credential for a new request, before any refresh. Cache lookups use it. */
23
+ current(): C | Promise<C>;
24
+ /** Called after a cache miss, before the first attempt, to refresh ahead of expiry. */
25
+ prepare?(credential: C): Promise<C>;
26
+ /** After a 401: the refreshed credential, or undefined when it cannot refresh. */
27
+ refresh?(credential: C): Promise<C | undefined>;
28
+ /** The Authorization value. Throws for a malformed token. */
29
+ authorization?(credential: C): string;
30
+ };
31
+ /** How the caller reads a successful body; see {@link ApiTransportRequestOptions.responseBody}. */
32
+ export type ResponseBodyMode = "auto" | "buffer" | "stream";
33
+ /** The GET cache, keyed by the host. `CacheLookup` comes from `response-cache`. */
34
+ export type TransportCache = {
35
+ lookup(request: CachedRequest): Promise<CacheLookup | undefined>;
36
+ /** Store a successful GET; `response` is a clone the cache may consume. */
37
+ store(request: CachedRequest, response: Response): Promise<void>;
38
+ /** Drop entries a successful write to `url` made stale. */
39
+ invalidate(url: string, identity: string): Promise<void>;
40
+ };
41
+ export type CachedRequest = {
42
+ url: string;
43
+ /** For `Vary` matching. */
44
+ requestHeaders: Record<string, string>;
45
+ identity: string;
46
+ };
47
+ type TransportLogger = {
48
+ debug(message: string, ...args: unknown[]): void;
49
+ };
50
+ export type ApiTransportOptions<C extends TransportCredential> = {
51
+ /**
52
+ * Without credentials the transport leaves Authorization to the request,
53
+ * does not refresh, and does not cache, since entries are scoped to the
54
+ * credential's identity.
55
+ */
56
+ credentials?: CredentialProvider<C>;
57
+ retry: RetryPolicy;
58
+ /** Per-attempt timeout, or a function of the request URL. Default: none. */
59
+ timeoutMs?: number | ((url: string) => number);
60
+ /** Underlying fetch, read on each call. Defaults to `globalThis.fetch`. */
61
+ fetch?: (input: FetchInput, init?: RequestInit) => Promise<Response>;
62
+ /** Sent when the request sets no `User-Agent`. */
63
+ userAgent?: string;
64
+ /**
65
+ * Add host headers, such as tracing or proxy headers, before Authorization
66
+ * is set. Throw to reject the request, for example for an untrusted host.
67
+ */
68
+ prepareHeaders?(headers: Headers, request: {
69
+ input: FetchInput;
70
+ credential: C;
71
+ }): void;
72
+ /** Writes the host knows are safe to replay, such as a catalog of idempotent operations. */
73
+ isIdempotent?(method: string, url: string): boolean;
74
+ /** Set to `1` on the request replayed after a credential refresh. */
75
+ refreshedRequestHeader?: string;
76
+ /** Which origins may receive the credential when following redirects. */
77
+ origins?: {
78
+ trusts(url: URL, credential: C): boolean;
79
+ /** The error for an untrusted or unusable redirect destination. */
80
+ reject(destination: string, credential: C): Error;
81
+ };
82
+ /** Host error classes. Without them the transport throws its own. */
83
+ errors?: {
84
+ /**
85
+ * The final attempt timed out. `idempotent` is false when a write may
86
+ * have been applied.
87
+ */
88
+ timeout?(info: {
89
+ timeoutMs: number;
90
+ idempotent: boolean;
91
+ }): Error;
92
+ /** A fetch error to throw at once, without retrying, such as a TLS failure. */
93
+ fatal?(error: unknown): Error | undefined;
94
+ /** A 429 that is not retried. Undefined returns the response. */
95
+ rateLimited?(response: Response, info: {
96
+ path: string;
97
+ retryAfterMs: number | undefined;
98
+ }): Promise<Error | undefined>;
99
+ };
100
+ cache?: TransportCache;
101
+ /**
102
+ * Whether the current scope skips cache reads, such as a tool call with
103
+ * `fresh: true`. Hosts back it with request-scoped state like
104
+ * `AsyncLocalStorage`. The response is still stored, replacing the entry.
105
+ */
106
+ fresh?(): boolean;
107
+ logger?: TransportLogger;
108
+ /** Wrap each request, including cache lookups, in a host span. */
109
+ span?(request: {
110
+ method: string;
111
+ path: string;
112
+ }, run: () => Promise<Response>): Promise<Response>;
113
+ };
114
+ export type ApiTransportRequestOptions = {
115
+ /**
116
+ * Replaying the request is harmless, so 5xx, timeouts, and network errors
117
+ * retry for any method. For writes the server dedupes, such as
118
+ * content-addressed chunk uploads.
119
+ */
120
+ idempotent?: boolean;
121
+ /**
122
+ * `buffer` reads a successful body within the attempt's timeout and retry
123
+ * budget; `auto` does so only when it has a `Content-Type`, as the
124
+ * `@sentry/api` auto parser returns a stream otherwise. Default `stream`.
125
+ */
126
+ responseBody?: ResponseBodyMode;
127
+ /**
128
+ * Follow redirects manually, checking each destination with `origins`
129
+ * and recording where the response came from; see
130
+ * {@link getValidatedResponseSource}. Skips the cache.
131
+ */
132
+ validateRedirects?: boolean;
133
+ };
134
+ export type ApiTransport = {
135
+ request(input: FetchInput, init?: RequestInit, options?: ApiTransportRequestOptions): Promise<Response>;
136
+ };
137
+ /** The request's last attempt hit the transport's own timeout. */
138
+ export declare class ApiTimeoutError extends Error {
139
+ readonly timeoutMs: number;
140
+ readonly idempotent: boolean;
141
+ constructor(timeoutMs: number, idempotent: boolean);
142
+ }
143
+ /** Where a response fetched with `validateRedirects` came from. */
144
+ export type ValidatedResponseSource = {
145
+ origin: string;
146
+ identity: string;
147
+ };
148
+ /** The final origin and credential identity of a `validateRedirects` response. */
149
+ export declare function getValidatedResponseSource(response: Response): ValidatedResponseSource | undefined;
150
+ /** Extract the full URL from a fetch input; `String(request)` is not its URL. */
151
+ export declare function extractInputUrl(input: FetchInput): string;
152
+ /** The URL pathname for logs and spans, or the raw input when it does not parse. */
153
+ export declare function extractUrlPath(input: FetchInput): string;
154
+ /** Create a transport; see {@link ApiTransportOptions}. */
155
+ export declare function createApiTransport<C extends TransportCredential>(config: ApiTransportOptions<C>): ApiTransport;
156
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Response validation through the Standard Schema interface, so the shared
3
+ * client works with any validator that implements it. The MCP passes Zod
4
+ * schemas and the CLI valibot ones; this module depends on neither.
5
+ */
6
+ import type { StandardSchemaV1 } from "./standard-schema.js";
7
+ /** A schema the host supplies to check a response body. */
8
+ export type ResponseSchema<Output = unknown> = StandardSchemaV1<unknown, Output>;
9
+ /** A response did not match the schema the caller validated it with. */
10
+ export declare class ApiResponseValidationError extends Error {
11
+ readonly issues: readonly StandardSchemaV1.Issue[];
12
+ constructor(issues: readonly StandardSchemaV1.Issue[]);
13
+ }
14
+ /**
15
+ * Validate `data` with `schema` and return the schema's output.
16
+ *
17
+ * Responses are validated synchronously, as every caller does today, so a
18
+ * schema with async refinements is rejected rather than awaited.
19
+ *
20
+ * @throws {ApiResponseValidationError} When `data` does not match
21
+ */
22
+ export declare function validateResponse<Schema extends StandardSchemaV1>(schema: Schema, data: unknown): StandardSchemaV1.InferOutput<Schema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/api",
3
- "version": "0.445.0",
3
+ "version": "0.446.0",
4
4
  "description": "Official auto-generated TypeScript client for the Sentry public REST API",
5
5
  "keywords": [
6
6
  "sentry",
@@ -21,7 +21,7 @@
21
21
  "build": "node build.mjs",
22
22
  "test": "bun test",
23
23
  "test:node": "node --test test/node-cancellation.mjs",
24
- "typecheck": "tsc -p tsconfig.test.json"
24
+ "typecheck": "tsc -p tsconfig.test.json && tsc -p tsconfig.browser.json"
25
25
  },
26
26
  "exports": {
27
27
  ".": {
@@ -40,6 +40,14 @@
40
40
  "import": "./dist/browser.js",
41
41
  "types": "./dist/browser.d.ts"
42
42
  },
43
+ "./client": {
44
+ "types": "./dist/api-client/index.d.ts",
45
+ "import": "./dist/api-client/index.js"
46
+ },
47
+ "./client/endpoints": {
48
+ "types": "./dist/api-client/endpoints/index.d.ts",
49
+ "import": "./dist/api-client/endpoints/index.js"
50
+ },
43
51
  "./operations": {
44
52
  "types": "./dist/operations.d.ts",
45
53
  "import": "./dist/operations.js"
@@ -60,6 +68,9 @@
60
68
  "bugs": {
61
69
  "url": "https://github.com/getsentry/sentry-api-schema/issues"
62
70
  },
71
+ "dependencies": {
72
+ "http-cache-semantics": "^4.2.0"
73
+ },
63
74
  "peerDependencies": {
64
75
  "typescript": "*",
65
76
  "valibot": "*",
@@ -79,7 +90,9 @@
79
90
  "devDependencies": {
80
91
  "@hey-api/openapi-ts": "0.98.0",
81
92
  "@types/bun": "^1.3.13",
93
+ "@types/http-cache-semantics": "^4.2.0",
82
94
  "@types/node": "^22",
95
+ "fast-check": "^4.8.0",
83
96
  "typescript": "^5.9.3",
84
97
  "valibot": "^1.4.2",
85
98
  "zod": "^3.24.0"