@atproto/lex-client 0.3.7 → 0.4.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 (135) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +4 -3
  3. package/dist/client.d.ts +4 -11
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +6 -12
  6. package/dist/client.js.map +1 -1
  7. package/dist/index.d.ts +2 -5
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -5
  10. package/dist/index.js.map +1 -1
  11. package/dist/lexicons/com/atproto/repo/applyWrites.d.ts +2 -2
  12. package/dist/lexicons/com/atproto/repo/applyWrites.d.ts.map +1 -1
  13. package/dist/lexicons/com/atproto/repo/applyWrites.defs.d.ts +23 -23
  14. package/dist/lexicons/com/atproto/repo/applyWrites.defs.d.ts.map +1 -1
  15. package/dist/lexicons/com/atproto/repo/applyWrites.defs.js +13 -64
  16. package/dist/lexicons/com/atproto/repo/applyWrites.defs.js.map +1 -1
  17. package/dist/lexicons/com/atproto/repo/applyWrites.js +2 -2
  18. package/dist/lexicons/com/atproto/repo/applyWrites.js.map +1 -1
  19. package/dist/lexicons/com/atproto/repo/createRecord.d.ts +2 -2
  20. package/dist/lexicons/com/atproto/repo/createRecord.d.ts.map +1 -1
  21. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +2 -2
  22. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
  23. package/dist/lexicons/com/atproto/repo/createRecord.defs.js +6 -24
  24. package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
  25. package/dist/lexicons/com/atproto/repo/createRecord.js +2 -2
  26. package/dist/lexicons/com/atproto/repo/createRecord.js.map +1 -1
  27. package/dist/lexicons/com/atproto/repo/defs.d.ts +1 -1
  28. package/dist/lexicons/com/atproto/repo/defs.d.ts.map +1 -1
  29. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts +4 -4
  30. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts.map +1 -1
  31. package/dist/lexicons/com/atproto/repo/defs.defs.js +3 -7
  32. package/dist/lexicons/com/atproto/repo/defs.defs.js.map +1 -1
  33. package/dist/lexicons/com/atproto/repo/defs.js +1 -1
  34. package/dist/lexicons/com/atproto/repo/defs.js.map +1 -1
  35. package/dist/lexicons/com/atproto/repo/deleteRecord.d.ts +2 -2
  36. package/dist/lexicons/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  37. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +2 -2
  38. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
  39. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +6 -19
  40. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
  41. package/dist/lexicons/com/atproto/repo/deleteRecord.js +2 -2
  42. package/dist/lexicons/com/atproto/repo/deleteRecord.js.map +1 -1
  43. package/dist/lexicons/com/atproto/repo/getRecord.d.ts +2 -2
  44. package/dist/lexicons/com/atproto/repo/getRecord.d.ts.map +1 -1
  45. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +1 -1
  46. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
  47. package/dist/lexicons/com/atproto/repo/getRecord.defs.js +5 -14
  48. package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
  49. package/dist/lexicons/com/atproto/repo/getRecord.js +2 -2
  50. package/dist/lexicons/com/atproto/repo/getRecord.js.map +1 -1
  51. package/dist/lexicons/com/atproto/repo/listRecords.d.ts +2 -2
  52. package/dist/lexicons/com/atproto/repo/listRecords.d.ts.map +1 -1
  53. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +5 -5
  54. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
  55. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +5 -22
  56. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  57. package/dist/lexicons/com/atproto/repo/listRecords.js +2 -2
  58. package/dist/lexicons/com/atproto/repo/listRecords.js.map +1 -1
  59. package/dist/lexicons/com/atproto/repo/putRecord.d.ts +2 -2
  60. package/dist/lexicons/com/atproto/repo/putRecord.d.ts.map +1 -1
  61. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +2 -2
  62. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
  63. package/dist/lexicons/com/atproto/repo/putRecord.defs.js +6 -25
  64. package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
  65. package/dist/lexicons/com/atproto/repo/putRecord.js +2 -2
  66. package/dist/lexicons/com/atproto/repo/putRecord.js.map +1 -1
  67. package/dist/lexicons/com/atproto/repo/uploadBlob.d.ts +2 -2
  68. package/dist/lexicons/com/atproto/repo/uploadBlob.d.ts.map +1 -1
  69. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +1 -1
  70. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
  71. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +4 -6
  72. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  73. package/dist/lexicons/com/atproto/repo/uploadBlob.js +2 -2
  74. package/dist/lexicons/com/atproto/repo/uploadBlob.js.map +1 -1
  75. package/dist/lexicons/com/atproto/repo.d.ts +8 -8
  76. package/dist/lexicons/com/atproto/repo.d.ts.map +1 -1
  77. package/dist/lexicons/com/atproto/repo.js +8 -8
  78. package/dist/lexicons/com/atproto/repo.js.map +1 -1
  79. package/dist/lexicons/com/atproto/sync/getBlob.d.ts +2 -2
  80. package/dist/lexicons/com/atproto/sync/getBlob.d.ts.map +1 -1
  81. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts +1 -1
  82. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts.map +1 -1
  83. package/dist/lexicons/com/atproto/sync/getBlob.defs.js +5 -14
  84. package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -1
  85. package/dist/lexicons/com/atproto/sync/getBlob.js +2 -2
  86. package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -1
  87. package/dist/lexicons/com/atproto/sync.d.ts +1 -1
  88. package/dist/lexicons/com/atproto/sync.d.ts.map +1 -1
  89. package/dist/lexicons/com/atproto/sync.js +1 -1
  90. package/dist/lexicons/com/atproto/sync.js.map +1 -1
  91. package/dist/lexicons/com/atproto.d.ts +2 -2
  92. package/dist/lexicons/com/atproto.d.ts.map +1 -1
  93. package/dist/lexicons/com/atproto.js +2 -2
  94. package/dist/lexicons/com/atproto.js.map +1 -1
  95. package/dist/lexicons/com.d.ts +1 -1
  96. package/dist/lexicons/com.d.ts.map +1 -1
  97. package/dist/lexicons/com.js +1 -1
  98. package/dist/lexicons/com.js.map +1 -1
  99. package/dist/lexicons/index.d.ts +1 -1
  100. package/dist/lexicons/index.d.ts.map +1 -1
  101. package/dist/lexicons/index.js +1 -1
  102. package/dist/lexicons/index.js.map +1 -1
  103. package/dist/write-operation-builder.d.ts +1 -1
  104. package/dist/write-operation-builder.d.ts.map +1 -1
  105. package/dist/write-operation-builder.js +4 -4
  106. package/dist/write-operation-builder.js.map +1 -1
  107. package/package.json +13 -6
  108. package/dist/agent.d.ts +0 -127
  109. package/dist/agent.d.ts.map +0 -1
  110. package/dist/agent.js +0 -41
  111. package/dist/agent.js.map +0 -1
  112. package/dist/errors.d.ts +0 -277
  113. package/dist/errors.d.ts.map +0 -1
  114. package/dist/errors.js +0 -388
  115. package/dist/errors.js.map +0 -1
  116. package/dist/response.d.ts +0 -124
  117. package/dist/response.d.ts.map +0 -1
  118. package/dist/response.js +0 -178
  119. package/dist/response.js.map +0 -1
  120. package/dist/types.d.ts +0 -54
  121. package/dist/types.d.ts.map +0 -1
  122. package/dist/types.js +0 -16
  123. package/dist/types.js.map +0 -1
  124. package/dist/util.d.ts +0 -90
  125. package/dist/util.d.ts.map +0 -1
  126. package/dist/util.js +0 -210
  127. package/dist/util.js.map +0 -1
  128. package/dist/www-authenticate.d.ts +0 -35
  129. package/dist/www-authenticate.d.ts.map +0 -1
  130. package/dist/www-authenticate.js +0 -54
  131. package/dist/www-authenticate.js.map +0 -1
  132. package/dist/xrpc.d.ts +0 -194
  133. package/dist/xrpc.d.ts.map +0 -1
  134. package/dist/xrpc.js +0 -235
  135. package/dist/xrpc.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,aAAa,EAEnB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAyB5D,YAAY,EAAE,0BAA0B,EAAE,CAAA;AAE1C,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI;IACnE,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CACtB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B,EAAE,WAAW,CAAC,MAAM,CAE1D,CAAA;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAA;AACnB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAAC,C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;;;;;GAkBG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,IAEnE,iBAAiB,CAAC,CAAC,CAAC,GAEpB,wBAAwB,CAAC,CAAC,CAAC,GAE3B,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAExB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,SAAS,GAAG,KAAK,EACvD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,OAAO,GACb,WAAW,CAAC,CAAC,CAAC,CAUhB"}
package/dist/errors.js DELETED
@@ -1,388 +0,0 @@
1
- import { LexError } from '@atproto/lex-data';
2
- import { lexErrorDataSchema, } from '@atproto/lex-schema';
3
- import { parseWWWAuthenticateHeader } from './www-authenticate.js';
4
- /**
5
- * Mapping that allows generating an XRPC error code from an HTTP status code
6
- * when the response does not contain a valid XRPC error payload. This is used
7
- * to convert non-XRPC error responses from upstream servers into a standardized
8
- * XRPC error for downstream clients.
9
- */
10
- const StatusErrorCodes = new Map([
11
- [400, 'InvalidRequest'],
12
- [401, 'AuthenticationRequired'],
13
- [403, 'Forbidden'],
14
- [404, 'XRPCNotSupported'],
15
- [406, 'NotAcceptable'],
16
- [413, 'PayloadTooLarge'],
17
- [415, 'UnsupportedMediaType'],
18
- [429, 'RateLimitExceeded'],
19
- [500, 'InternalServerError'],
20
- [501, 'MethodNotImplemented'],
21
- [502, 'UpstreamFailure'],
22
- [503, 'NotEnoughResources'],
23
- [504, 'UpstreamTimeout'],
24
- ]);
25
- /**
26
- * HTTP status codes that indicate a transient error that may succeed on retry.
27
- *
28
- * Includes:
29
- * - 408 Request Timeout
30
- * - 425 Too Early
31
- * - 429 Too Many Requests (rate limited)
32
- * - 500 Internal Server Error
33
- * - 502 Bad Gateway
34
- * - 503 Service Unavailable
35
- * - 504 Gateway Timeout
36
- * - 522 Connection Timed Out (Cloudflare)
37
- * - 524 A Timeout Occurred (Cloudflare)
38
- */
39
- export const RETRYABLE_HTTP_STATUS_CODES = new Set([
40
- 408, 425, 429, 500, 502, 503, 504, 522, 524,
41
- ]);
42
- export { LexError };
43
- /**
44
- * All unsuccessful responses should follow a standard error response
45
- * schema. The Content-Type should be application/json, and the payload
46
- * should be a JSON object with the following fields:
47
- *
48
- * - `error` (string, required): type name of the error (generic ASCII
49
- * constant, no whitespace)
50
- * - `message` (string, optional): description of the error, appropriate for
51
- * display to humans
52
- *
53
- * This function checks whether a given payload matches this schema.
54
- */
55
- export function isXrpcErrorPayload(payload) {
56
- return (payload != null &&
57
- payload.encoding === 'application/json' &&
58
- lexErrorDataSchema.matches(payload.body));
59
- }
60
- /**
61
- * Abstract base class for all XRPC errors.
62
- *
63
- * Extends {@link LexError} and implements {@link ResultFailure} for use with
64
- * safe/result-based error handling patterns.
65
- *
66
- * @typeParam M - The XRPC method type (Procedure or Query)
67
- * @typeParam N - The error code type
68
- * @typeParam TReason - The reason type for ResultFailure
69
- *
70
- * @see {@link XrpcResponseError} - For valid XRPC error responses
71
- * @see {@link XrpcInvalidResponseError} - For invalid/unexpected responses
72
- * @see {@link XrpcInternalError} - For network/internal errors
73
- */
74
- export class XrpcError extends LexError {
75
- constructor(method, error, message = `${error} Lexicon RPC error`, options) {
76
- super(error, message, options);
77
- this.method = method;
78
- this.name = 'XrpcError';
79
- /**
80
- * @see {@link ResultFailure.success}
81
- */
82
- this.success = false;
83
- }
84
- matchesSchemaErrors() {
85
- return this.method.errors?.includes(this.error) ?? false;
86
- }
87
- }
88
- /**
89
- * Error class for valid XRPC error responses from the server.
90
- *
91
- * This represents a properly formatted XRPC error where the server returned
92
- * a non-2xx status with a valid JSON error payload containing `error` and
93
- * optional `message` fields.
94
- *
95
- * Use {@link matchesSchemaErrors} to check if the error matches the method's declared
96
- * error types for type-safe error handling.
97
- *
98
- * @typeParam M - The XRPC method type
99
- * @typeParam N - The error code type (inferred from method or generic)
100
- *
101
- * @example Handling specific errors
102
- * ```typescript
103
- * try {
104
- * await client.xrpc(someMethod, options)
105
- * } catch (err) {
106
- * if (err instanceof XrpcResponseError && err.error === 'RecordNotFound') {
107
- * // Handle not found case
108
- * }
109
- * }
110
- * ```
111
- */
112
- export class XrpcResponseError extends XrpcError {
113
- constructor(method, response, payload, options) {
114
- const { error, message } = isXrpcErrorPayload(payload)
115
- ? payload.body
116
- : {
117
- error: StatusErrorCodes.get(response.status) ??
118
- (response.status >= 500 ? 'UpstreamFailure' : 'InvalidRequest'),
119
- message: buildResponseOverviewMessage(response),
120
- };
121
- super(method, error, message, options);
122
- this.response = response;
123
- this.payload = payload;
124
- this.name = 'XrpcResponseError';
125
- }
126
- get reason() {
127
- return this;
128
- }
129
- shouldRetry() {
130
- return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
131
- }
132
- toJSON() {
133
- // Return the original error payload if it's a valid XRPC error, otherwise
134
- // convert to an XRPC error format.
135
- const { payload } = this;
136
- if (isXrpcErrorPayload(payload)) {
137
- return payload.body;
138
- }
139
- return super.toJSON();
140
- }
141
- toDownstreamError() {
142
- const { status, headers } = this.response;
143
- // If the upstream server returned a 500 error, we want to return a 502 Bad
144
- // Gateway to downstream clients, as the issue is with the upstream server,
145
- // not us. We still return the original error code and message in the body
146
- // for transparency, but we do not want to expose internal server errors
147
- // from the upstream server as-is to downstream clients.
148
- return {
149
- status: status === 500 ? 502 : status,
150
- headers: stripHopByHopHeaders(headers),
151
- body: this.toJSON(),
152
- };
153
- }
154
- get status() {
155
- return this.response.status;
156
- }
157
- get headers() {
158
- return this.response.headers;
159
- }
160
- get body() {
161
- return this.payload?.body;
162
- }
163
- }
164
- /**
165
- * Error class for 401 Unauthorized XRPC responses.
166
- *
167
- * Extends {@link XrpcResponseError} with access to parsed WWW-Authenticate header
168
- * information, useful for implementing authentication flows.
169
- *
170
- * Authentication errors are never retryable as they require user intervention
171
- * (e.g., re-authentication, token refresh).
172
- *
173
- * @typeParam M - The XRPC method type
174
- * @typeParam N - The error code type
175
- *
176
- * @example Handling authentication errors
177
- * ```typescript
178
- * try {
179
- * await client.xrpc(someMethod, options)
180
- * } catch (err) {
181
- * if (err instanceof XrpcAuthenticationError) {
182
- * const { DPoP } = err.wwwAuthenticate
183
- * if (DPoP?.error === 'use_dpop_nonce') {
184
- * // Handle DPoP nonce requirement
185
- * }
186
- * }
187
- * }
188
- * ```
189
- */
190
- export class XrpcAuthenticationError extends XrpcResponseError {
191
- constructor() {
192
- super(...arguments);
193
- this.name = 'XrpcAuthenticationError';
194
- }
195
- shouldRetry() {
196
- return false;
197
- }
198
- #wwwAuthenticateCached;
199
- /**
200
- * Parsed WWW-Authenticate header from the response.
201
- * Contains authentication scheme parameters (e.g., Bearer realm, DPoP nonce).
202
- */
203
- get wwwAuthenticate() {
204
- return (this.#wwwAuthenticateCached ??=
205
- parseWWWAuthenticateHeader(this.response.headers.get('www-authenticate')) ?? {});
206
- }
207
- }
208
- /**
209
- * Error class for invalid or unprocessable XRPC responses from upstream servers.
210
- *
211
- * This occurs when the server returns a response that doesn't conform to the
212
- * XRPC protocol, such as:
213
- * - Missing or invalid Content-Type header
214
- * - Response body that doesn't match the method's output schema
215
- * - Non-JSON error responses
216
- * - Responses from non-XRPC endpoints
217
- *
218
- * The error code is always 'InvalidResponse' and maps to HTTP 502 Bad Gateway
219
- * when converted to a response. This should allow downstream clients to
220
- * determine at which boundary the error occurred.
221
- *
222
- * @typeParam M - The XRPC method type
223
- */
224
- export class XrpcInvalidResponseError extends XrpcError {
225
- constructor(method, response, payload, message = buildResponseOverviewMessage(response), options) {
226
- super(method, 'InvalidResponse', message, options);
227
- this.response = response;
228
- this.payload = payload;
229
- this.name = 'XrpcInvalidResponseError';
230
- }
231
- get reason() {
232
- return this;
233
- }
234
- shouldRetry() {
235
- return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
236
- }
237
- toDownstreamError() {
238
- return { status: 502, body: this.toJSON() };
239
- }
240
- }
241
- /**
242
- * Error class for invalid XRPC responses that fail schema validation.
243
- *
244
- * This is a specific type of {@link XrpcInvalidResponseError} that indicates the
245
- * upstream server returned a response that was structurally valid but did not
246
- * conform to the expected schema for the method. This likely indicates a
247
- * mismatch between client and server versions or an issue with the server's
248
- * XRPC implementation.
249
- *
250
- * @typeParam M - The XRPC method type
251
- */
252
- export class XrpcResponseValidationError extends XrpcInvalidResponseError {
253
- constructor(method, response, payload, cause) {
254
- super(method, response, payload, `Invalid response payload: ${cause.message}`, { cause });
255
- this.cause = cause;
256
- this.name = 'XrpcResponseValidationError';
257
- }
258
- }
259
- /**
260
- * Error class for unexpected internal/client-side errors during XRPC requests.
261
- *
262
- * The error code is always 'InternalServerError' and these errors not
263
- * considered retryable as they stem from unforeseen issues in the
264
- * implementation.
265
- *
266
- * @typeParam M - The XRPC method type
267
- */
268
- export class XrpcInternalError extends XrpcError {
269
- constructor(method, message, options) {
270
- super(method, 'InternalServerError', message ?? 'Unable to fulfill XRPC request', options);
271
- this.name = 'XrpcInternalError';
272
- }
273
- get reason() {
274
- return this;
275
- }
276
- shouldRetry() {
277
- return false;
278
- }
279
- toJSON() {
280
- // @NOTE Do not expose internal error details to downstream clients
281
- return { error: this.error, message: 'Internal Server Error' };
282
- }
283
- toDownstreamError() {
284
- return { status: 500, body: this.toJSON() };
285
- }
286
- }
287
- /**
288
- * Special case of XrpcInternalError that specifically represents errors thrown
289
- * by {@link Agent.fetchHandler} during the XRPC request. This includes:
290
- * - Network errors (connection refused, DNS failure)
291
- * - Request timeouts
292
- * - Request aborted via AbortSignal
293
- *
294
- * These errors are optimistically considered retryable, as many fetch errors
295
- * are transient and may succeed on retry.
296
- */
297
- export class XrpcFetchError extends XrpcInternalError {
298
- constructor(method, cause) {
299
- const message = cause instanceof Error ? cause.message : String(cause);
300
- super(method, `Unexpected fetchHandler() error: ${message}`, { cause });
301
- this.name = 'XrpcFetchError';
302
- }
303
- shouldRetry() {
304
- // Ideally, we would inspect the reason to determine if it's retryable (by
305
- // detecting network errors, timeouts, etc.). Since these cases are highly
306
- // platform-dependent, we optimistically assume all fetch errors are
307
- // transient and retryable.
308
- return true;
309
- }
310
- toJSON() {
311
- // @NOTE Do not expose internal error details to downstream clients
312
- return { error: this.error, message: 'Failed to perform upstream request' };
313
- }
314
- toDownstreamError() {
315
- // While it might technically be a 500 error, we use 502 Bad Gateway here to
316
- // indicate that the error occurred while communicating with the upstream
317
- // server, allowing downstream clients to distinguish between errors in our
318
- // internal processing (500) and errors in the upstream server or network
319
- // (502).
320
- return { status: 502, body: this.toJSON() };
321
- }
322
- }
323
- /**
324
- * Converts an unknown error into an appropriate {@link XrpcFailure} type.
325
- *
326
- * If the error is already an XrpcFailure for the given method, returns it as-is.
327
- * Otherwise, wraps it in an {@link XrpcInternalError}.
328
- *
329
- * @param method - The XRPC method that was called
330
- * @param cause - The error to convert
331
- * @returns An XrpcFailure instance
332
- *
333
- * @example
334
- * ```typescript
335
- * try {
336
- * const response = await fetch(...)
337
- * // ... process response
338
- * } catch (err) {
339
- * return asXrpcFailure(method, err)
340
- * }
341
- * ```
342
- */
343
- export function asXrpcFailure(method, cause) {
344
- if (cause instanceof XrpcResponseError ||
345
- cause instanceof XrpcInvalidResponseError ||
346
- cause instanceof XrpcInternalError) {
347
- if (cause.method === method)
348
- return cause;
349
- }
350
- return new XrpcInternalError(method, undefined, { cause });
351
- }
352
- const HOP_BY_HOP_HEADERS = new Set([
353
- 'connection',
354
- 'keep-alive',
355
- 'proxy-authenticate',
356
- 'proxy-authorization',
357
- 'te',
358
- 'trailer',
359
- 'transfer-encoding',
360
- 'upgrade',
361
- ]);
362
- function stripHopByHopHeaders(headers) {
363
- const result = new Headers(headers);
364
- // Remove statically known hop-by-hop headers
365
- for (const name of HOP_BY_HOP_HEADERS) {
366
- result.delete(name);
367
- }
368
- // Remove headers listed in the "Connection" header
369
- const connection = headers.get('connection');
370
- if (connection) {
371
- for (const name of connection.split(',')) {
372
- result.delete(name.trim());
373
- }
374
- }
375
- // These are not actually hop-by-hop headers, but we remove them because the
376
- // upstream payload gets parsed and re-serialized, so content length and
377
- // encoding may no longer be accurate.
378
- result.delete('content-length');
379
- result.delete('content-encoding');
380
- return result;
381
- }
382
- function buildResponseOverviewMessage(response) {
383
- if (response.status < 400) {
384
- return `Upstream server responded with an invalid status code (${response.status})`;
385
- }
386
- return `Upstream server responded with a ${response.status} error`;
387
- }
388
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAML,kBAAkB,GACnB,MAAM,qBAAqB,CAAA;AAK5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAElE;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAuB;IACrD,CAAC,GAAG,EAAE,gBAAgB,CAAC;IACvB,CAAC,GAAG,EAAE,wBAAwB,CAAC;IAC/B,CAAC,GAAG,EAAE,WAAW,CAAC;IAClB,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACzB,CAAC,GAAG,EAAE,eAAe,CAAC;IACtB,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACxB,CAAC,GAAG,EAAE,sBAAsB,CAAC;IAC7B,CAAC,GAAG,EAAE,mBAAmB,CAAC;IAC1B,CAAC,GAAG,EAAE,qBAAqB,CAAC;IAC5B,CAAC,GAAG,EAAE,sBAAsB,CAAC;IAC7B,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACxB,CAAC,GAAG,EAAE,oBAAoB,CAAC;IAC3B,CAAC,GAAG,EAAE,iBAAiB,CAAC;CACzB,CAAC,CAAA;AAWF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAC;IACtE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAA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AC;IACH,CAAC;IAED,4EAA4E;IAC5E,wEAAwE;IACxE,sCAAsC;IACtC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC/B,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;IAEjC,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,4BAA4B,CAAC,QAAkB;IACtD,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QAC1B,OAAO,0DAA0D,QAAQ,CAAC,MAAM,GAAG,CAAA;IACrF,CAAC;IAED,OAAO,oCAAoC,QAAQ,CAAC,MAAM,QAAQ,CAAA;AACpE,CAAC","sourcesContent":["import type { LexErrorCode, LexErrorData, LexValue } from '@atproto/lex-data'\nimport { LexError } from '@atproto/lex-data'\nimport {\n type InferMethodError,\n type LexValidationError,\n type Procedure,\n type Query,\n type ResultFailure,\n lexErrorDataSchema,\n} from '@atproto/lex-schema'\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Agent } from './agent.js'\nimport type { XrpcUnknownResponsePayload } from './types.js'\nimport type { WWWAuthenticate } from './www-authenticate.js'\nimport { parseWWWAuthenticateHeader } from './www-authenticate.js'\n\n/**\n * Mapping that allows generating an XRPC error code from an HTTP status code\n * when the response does not contain a valid XRPC error payload. This is used\n * to convert non-XRPC error responses from upstream servers into a standardized\n * XRPC error for downstream clients.\n */\nconst StatusErrorCodes = new Map<number, LexErrorCode>([\n [400, 'InvalidRequest'],\n [401, 'AuthenticationRequired'],\n [403, 'Forbidden'],\n [404, 'XRPCNotSupported'],\n [406, 'NotAcceptable'],\n [413, 'PayloadTooLarge'],\n [415, 'UnsupportedMediaType'],\n [429, 'RateLimitExceeded'],\n [500, 'InternalServerError'],\n [501, 'MethodNotImplemented'],\n [502, 'UpstreamFailure'],\n [503, 'NotEnoughResources'],\n [504, 'UpstreamTimeout'],\n])\n\nexport type { XrpcUnknownResponsePayload }\n\nexport type DownstreamError<N extends LexErrorCode = LexErrorCode> = {\n status: number\n headers?: Headers\n encoding?: 'application/json'\n body: LexErrorData<N>\n}\n\n/**\n * HTTP status codes that indicate a transient error that may succeed on retry.\n *\n * Includes:\n * - 408 Request Timeout\n * - 425 Too Early\n * - 429 Too Many Requests (rate limited)\n * - 500 Internal Server Error\n * - 502 Bad Gateway\n * - 503 Service Unavailable\n * - 504 Gateway Timeout\n * - 522 Connection Timed Out (Cloudflare)\n * - 524 A Timeout Occurred (Cloudflare)\n */\nexport const RETRYABLE_HTTP_STATUS_CODES: ReadonlySet<number> = new Set([\n 408, 425, 429, 500, 502, 503, 504, 522, 524,\n])\n\nexport { LexError }\nexport type { LexErrorCode, LexErrorData }\n\n/**\n * The payload structure for XRPC error responses.\n *\n * All XRPC errors return JSON with an `error` code and optional `message`.\n *\n * @typeParam N - The specific error code type\n */\nexport type XrpcErrorPayload<N extends LexErrorCode = LexErrorCode> = {\n body: LexErrorData<N>\n encoding: 'application/json'\n}\n\n/**\n * All unsuccessful responses should follow a standard error response\n * schema. The Content-Type should be application/json, and the payload\n * should be a JSON object with the following fields:\n *\n * - `error` (string, required): type name of the error (generic ASCII\n * constant, no whitespace)\n * - `message` (string, optional): description of the error, appropriate for\n * display to humans\n *\n * This function checks whether a given payload matches this schema.\n */\nexport function isXrpcErrorPayload(\n payload: XrpcUnknownResponsePayload | null | undefined,\n): payload is XrpcErrorPayload {\n return (\n payload != null &&\n payload.encoding === 'application/json' &&\n lexErrorDataSchema.matches(payload.body)\n )\n}\n\n/**\n * Abstract base class for all XRPC errors.\n *\n * Extends {@link LexError} and implements {@link ResultFailure} for use with\n * safe/result-based error handling patterns.\n *\n * @typeParam M - The XRPC method type (Procedure or Query)\n * @typeParam N - The error code type\n * @typeParam TReason - The reason type for ResultFailure\n *\n * @see {@link XrpcResponseError} - For valid XRPC error responses\n * @see {@link XrpcInvalidResponseError} - For invalid/unexpected responses\n * @see {@link XrpcInternalError} - For network/internal errors\n */\nexport abstract class XrpcError<\n M extends Procedure | Query = Procedure | Query,\n N extends LexErrorCode = LexErrorCode,\n TReason = unknown,\n>\n extends LexError<N>\n implements ResultFailure<TReason>\n{\n name = 'XrpcError'\n\n constructor(\n readonly method: M,\n error: N,\n message: string = `${error} Lexicon RPC error`,\n options?: ErrorOptions,\n ) {\n super(error, message, options)\n }\n\n /**\n * @see {@link ResultFailure.success}\n */\n readonly success = false as const\n\n /**\n * @see {@link ResultFailure.reason}\n */\n abstract readonly reason: TReason\n\n /**\n * Indicates whether the error is transient and can be retried.\n */\n abstract shouldRetry(): boolean\n\n abstract toDownstreamError(): DownstreamError\n\n matchesSchemaErrors(): this is XrpcError<M, InferMethodError<M>> {\n return this.method.errors?.includes(this.error) ?? false\n }\n}\n\n/**\n * Error class for valid XRPC error responses from the server.\n *\n * This represents a properly formatted XRPC error where the server returned\n * a non-2xx status with a valid JSON error payload containing `error` and\n * optional `message` fields.\n *\n * Use {@link matchesSchemaErrors} to check if the error matches the method's declared\n * error types for type-safe error handling.\n *\n * @typeParam M - The XRPC method type\n * @typeParam N - The error code type (inferred from method or generic)\n *\n * @example Handling specific errors\n * ```typescript\n * try {\n * await client.xrpc(someMethod, options)\n * } catch (err) {\n * if (err instanceof XrpcResponseError && err.error === 'RecordNotFound') {\n * // Handle not found case\n * }\n * }\n * ```\n */\nexport class XrpcResponseError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcError<M, LexErrorCode, XrpcResponseError<M>> {\n name = 'XrpcResponseError'\n\n constructor(\n method: M,\n readonly response: Response,\n readonly payload?: XrpcUnknownResponsePayload,\n options?: ErrorOptions,\n ) {\n const { error, message } = isXrpcErrorPayload(payload)\n ? payload.body\n : {\n error:\n StatusErrorCodes.get(response.status) ??\n (response.status >= 500 ? 'UpstreamFailure' : 'InvalidRequest'),\n message: buildResponseOverviewMessage(response),\n }\n super(method, error, message, options)\n }\n\n override get reason(): this {\n return this\n }\n\n override shouldRetry(): boolean {\n return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status)\n }\n\n override toJSON(): LexErrorData {\n // Return the original error payload if it's a valid XRPC error, otherwise\n // convert to an XRPC error format.\n const { payload } = this\n if (isXrpcErrorPayload(payload)) {\n return payload.body\n }\n\n return super.toJSON()\n }\n\n override toDownstreamError(): DownstreamError {\n const { status, headers } = this.response\n // If the upstream server returned a 500 error, we want to return a 502 Bad\n // Gateway to downstream clients, as the issue is with the upstream server,\n // not us. We still return the original error code and message in the body\n // for transparency, but we do not want to expose internal server errors\n // from the upstream server as-is to downstream clients.\n return {\n status: status === 500 ? 502 : status,\n headers: stripHopByHopHeaders(headers),\n body: this.toJSON(),\n }\n }\n\n get status(): number {\n return this.response.status\n }\n\n get headers(): Headers {\n return this.response.headers\n }\n\n get body(): undefined | Uint8Array | LexValue {\n return this.payload?.body\n }\n}\n\nexport type { WWWAuthenticate }\n\n/**\n * Error class for 401 Unauthorized XRPC responses.\n *\n * Extends {@link XrpcResponseError} with access to parsed WWW-Authenticate header\n * information, useful for implementing authentication flows.\n *\n * Authentication errors are never retryable as they require user intervention\n * (e.g., re-authentication, token refresh).\n *\n * @typeParam M - The XRPC method type\n * @typeParam N - The error code type\n *\n * @example Handling authentication errors\n * ```typescript\n * try {\n * await client.xrpc(someMethod, options)\n * } catch (err) {\n * if (err instanceof XrpcAuthenticationError) {\n * const { DPoP } = err.wwwAuthenticate\n * if (DPoP?.error === 'use_dpop_nonce') {\n * // Handle DPoP nonce requirement\n * }\n * }\n * }\n * ```\n */\nexport class XrpcAuthenticationError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcResponseError<M> {\n name = 'XrpcAuthenticationError'\n\n override shouldRetry(): boolean {\n return false\n }\n\n #wwwAuthenticateCached?: WWWAuthenticate\n /**\n * Parsed WWW-Authenticate header from the response.\n * Contains authentication scheme parameters (e.g., Bearer realm, DPoP nonce).\n */\n get wwwAuthenticate(): WWWAuthenticate {\n return (this.#wwwAuthenticateCached ??=\n parseWWWAuthenticateHeader(\n this.response.headers.get('www-authenticate'),\n ) ?? {})\n }\n}\n\n/**\n * Error class for invalid or unprocessable XRPC responses from upstream servers.\n *\n * This occurs when the server returns a response that doesn't conform to the\n * XRPC protocol, such as:\n * - Missing or invalid Content-Type header\n * - Response body that doesn't match the method's output schema\n * - Non-JSON error responses\n * - Responses from non-XRPC endpoints\n *\n * The error code is always 'InvalidResponse' and maps to HTTP 502 Bad Gateway\n * when converted to a response. This should allow downstream clients to\n * determine at which boundary the error occurred.\n *\n * @typeParam M - The XRPC method type\n */\nexport class XrpcInvalidResponseError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcError<M, 'InvalidResponse', XrpcInvalidResponseError<M>> {\n name = 'XrpcInvalidResponseError'\n\n constructor(\n method: M,\n readonly response: Response,\n readonly payload?: XrpcUnknownResponsePayload,\n message: string = buildResponseOverviewMessage(response),\n options?: ErrorOptions,\n ) {\n super(method, 'InvalidResponse', message, options)\n }\n\n override get reason(): this {\n return this\n }\n\n override shouldRetry(): boolean {\n return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status)\n }\n\n override toDownstreamError(): DownstreamError {\n return { status: 502, body: this.toJSON() }\n }\n}\n\n/**\n * Error class for invalid XRPC responses that fail schema validation.\n *\n * This is a specific type of {@link XrpcInvalidResponseError} that indicates the\n * upstream server returned a response that was structurally valid but did not\n * conform to the expected schema for the method. This likely indicates a\n * mismatch between client and server versions or an issue with the server's\n * XRPC implementation.\n *\n * @typeParam M - The XRPC method type\n */\nexport class XrpcResponseValidationError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcInvalidResponseError<M> {\n name = 'XrpcResponseValidationError'\n\n constructor(\n method: M,\n response: Response,\n payload: XrpcUnknownResponsePayload,\n readonly cause: LexValidationError,\n ) {\n super(\n method,\n response,\n payload,\n `Invalid response payload: ${cause.message}`,\n { cause },\n )\n }\n}\n\n/**\n * Error class for unexpected internal/client-side errors during XRPC requests.\n *\n * The error code is always 'InternalServerError' and these errors not\n * considered retryable as they stem from unforeseen issues in the\n * implementation.\n *\n * @typeParam M - The XRPC method type\n */\nexport class XrpcInternalError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcError<M, 'InternalServerError', XrpcInternalError<M>> {\n name = 'XrpcInternalError'\n\n constructor(method: M, message?: string, options?: ErrorOptions) {\n super(\n method,\n 'InternalServerError',\n message ?? 'Unable to fulfill XRPC request',\n options,\n )\n }\n\n override get reason(): this {\n return this\n }\n\n override shouldRetry(): boolean {\n return false\n }\n\n override toJSON(): LexErrorData {\n // @NOTE Do not expose internal error details to downstream clients\n return { error: this.error, message: 'Internal Server Error' }\n }\n\n override toDownstreamError(): DownstreamError {\n return { status: 500, body: this.toJSON() }\n }\n}\n\n/**\n * Special case of XrpcInternalError that specifically represents errors thrown\n * by {@link Agent.fetchHandler} during the XRPC request. This includes:\n * - Network errors (connection refused, DNS failure)\n * - Request timeouts\n * - Request aborted via AbortSignal\n *\n * These errors are optimistically considered retryable, as many fetch errors\n * are transient and may succeed on retry.\n */\nexport class XrpcFetchError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcInternalError<M> {\n name = 'XrpcFetchError'\n\n constructor(method: M, cause: unknown) {\n const message = cause instanceof Error ? cause.message : String(cause)\n super(method, `Unexpected fetchHandler() error: ${message}`, { cause })\n }\n\n override shouldRetry(): boolean {\n // Ideally, we would inspect the reason to determine if it's retryable (by\n // detecting network errors, timeouts, etc.). Since these cases are highly\n // platform-dependent, we optimistically assume all fetch errors are\n // transient and retryable.\n return true\n }\n\n override toJSON(): LexErrorData {\n // @NOTE Do not expose internal error details to downstream clients\n return { error: this.error, message: 'Failed to perform upstream request' }\n }\n\n override toDownstreamError(): DownstreamError {\n // While it might technically be a 500 error, we use 502 Bad Gateway here to\n // indicate that the error occurred while communicating with the upstream\n // server, allowing downstream clients to distinguish between errors in our\n // internal processing (500) and errors in the upstream server or network\n // (502).\n return { status: 502, body: this.toJSON() }\n }\n}\n\n/**\n * Union type of all possible XRPC failure types.\n *\n * Used as the return type for safe/non-throwing XRPC methods. Check the\n * `success` property to distinguish between success and failure:\n *\n * @typeParam M - The XRPC method type\n *\n * @example\n * ```typescript\n * const result = await client.xrpcSafe(someMethod, options)\n * if (result.success) {\n * console.log(result.body) // XrpcResponse\n * } else {\n * // result is XrpcFailure (XrpcResponseError | XrpcInvalidResponseError | XrpcInternalError)\n * console.error(result.error, result.message)\n * }\n * ```\n */\nexport type XrpcFailure<M extends Procedure | Query = Procedure | Query> =\n // The server returned a valid XRPC error response\n | XrpcResponseError<M>\n // The response was not a valid XRPC response, or it does not match the schema\n | XrpcInvalidResponseError<M>\n // Something went wrong (network error, etc.)\n | XrpcInternalError<M>\n\n/**\n * Converts an unknown error into an appropriate {@link XrpcFailure} type.\n *\n * If the error is already an XrpcFailure for the given method, returns it as-is.\n * Otherwise, wraps it in an {@link XrpcInternalError}.\n *\n * @param method - The XRPC method that was called\n * @param cause - The error to convert\n * @returns An XrpcFailure instance\n *\n * @example\n * ```typescript\n * try {\n * const response = await fetch(...)\n * // ... process response\n * } catch (err) {\n * return asXrpcFailure(method, err)\n * }\n * ```\n */\nexport function asXrpcFailure<M extends Procedure | Query>(\n method: M,\n cause: unknown,\n): XrpcFailure<M> {\n if (\n cause instanceof XrpcResponseError ||\n cause instanceof XrpcInvalidResponseError ||\n cause instanceof XrpcInternalError\n ) {\n if (cause.method === method) return cause\n }\n\n return new XrpcInternalError(method, undefined, { cause })\n}\n\nconst HOP_BY_HOP_HEADERS = new Set([\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n])\n\nfunction stripHopByHopHeaders(headers: Headers): Headers {\n const result = new Headers(headers)\n\n // Remove statically known hop-by-hop headers\n for (const name of HOP_BY_HOP_HEADERS) {\n result.delete(name)\n }\n\n // Remove headers listed in the \"Connection\" header\n const connection = headers.get('connection')\n if (connection) {\n for (const name of connection.split(',')) {\n result.delete(name.trim())\n }\n }\n\n // These are not actually hop-by-hop headers, but we remove them because the\n // upstream payload gets parsed and re-serialized, so content length and\n // encoding may no longer be accurate.\n result.delete('content-length')\n result.delete('content-encoding')\n\n return result\n}\n\nfunction buildResponseOverviewMessage(response: Response): string {\n if (response.status < 400) {\n return `Upstream server responded with an invalid status code (${response.status})`\n }\n\n return `Upstream server responded with a ${response.status} error`\n}\n"]}
@@ -1,124 +0,0 @@
1
- import type { InferMethodOutputEncoding, InferOutput, LexValue, Payload, Procedure, Query, ResultSuccess, Validator } from '@atproto/lex-schema';
2
- import type { EncodingString } from './types.js';
3
- type InferEncodingType<TEncoding extends string> = TEncoding extends '*/*' ? EncodingString : TEncoding extends `${infer T extends string}/*` ? `${T}/${string}` : TEncoding;
4
- type InferBodyType<TEncoding extends string, TSchema> = TSchema extends Validator ? InferOutput<TSchema> : TEncoding extends `application/json` ? LexValue : Uint8Array<ArrayBuffer>;
5
- /**
6
- * The body type of an XRPC response, inferred from the method's output schema.
7
- *
8
- * For JSON responses, this is the parsed LexValue. For binary responses,
9
- * this is a Uint8Array.
10
- *
11
- * @typeParam M - The XRPC method type (Procedure or Query)
12
- */
13
- export type XrpcResponseBody<M extends Procedure | Query> = M['output'] extends Payload<infer TEncoding, infer TSchema> ? TEncoding extends string ? InferBodyType<TEncoding, TSchema> : undefined | LexValue | Uint8Array<ArrayBuffer> : never;
14
- /**
15
- * The full payload type of an XRPC response, including body and encoding.
16
- *
17
- * Returns `null` for methods that have no output.
18
- *
19
- * @typeParam M - The XRPC method type (Procedure or Query)
20
- */
21
- export type XrpcResponsePayload<M extends Procedure | Query> = M['output'] extends Payload<infer TEncoding, infer TSchema> ? TEncoding extends string ? {
22
- encoding: InferEncodingType<TEncoding>;
23
- body: InferBodyType<TEncoding, TSchema>;
24
- } : undefined | {
25
- body: LexValue | Uint8Array<ArrayBuffer>;
26
- encoding: string;
27
- } : never;
28
- export type XrpcResponseOptions = {
29
- /**
30
- * Whether to validate the response against the method's output schema.
31
- * Disabling this can improve performance but may lead to runtime errors if
32
- * the response does not conform to the expected schema. Only set this to
33
- * `false` if you are certain that the upstream service will always return
34
- * valid responses.
35
- *
36
- * @default true
37
- */
38
- validateResponse?: boolean;
39
- /**
40
- * Whether to strictly process response payloads according to Lex encoding
41
- * rules. By default, the client will reject responses with invalid Lex data
42
- * (floats and invalid $bytes / $link objects).
43
- *
44
- * Setting this option to `false` will allow the client to accept such
45
- * responses in a non-strict mode, where invalid Lex data will be returned
46
- * as-is (e.g., floats will not be rejected, and invalid $bytes / $link
47
- * objects will not be converted to Uint8Array / Cid). When in non-strict
48
- * mode, the validation will also be relaxed when validating the response
49
- * against the method's output schema, allowing values that do not strictly
50
- * conform to the schema (e.g. datetime strings that are not valid RFC3339
51
- * format, blobs that are not of the right size/mime-type, etc.) to be
52
- * accepted as long as their basic structure is correct.
53
- *
54
- * When validation is enabled (the default), the values defined through the
55
- * method schema will be enforced, ensuring that the client can still process
56
- * the response even if the server returns invalid Lex data.
57
- *
58
- * @default true
59
- * @see {@link LexParseOptions.strict}
60
- */
61
- strictResponseProcessing?: boolean;
62
- };
63
- /**
64
- * Small container for XRPC response.
65
- *
66
- * @implements {ResultSuccess<XrpcResponse<M>>} for convenience in result handling contexts.
67
- *
68
- * @example
69
- *
70
- * ```typescript
71
- * import { app } from '#/lexicons'
72
- * import { XrpcResponse } from '@atproto/lex-client'
73
- *
74
- * const fetchResponse = await fetch('https://example.com/xrpc/app.bsky.feed.getTimeline')
75
- *
76
- * const response = await XrpcResponse.fromFetchResponse(
77
- * app.bsky.feed.getTimeline.main,
78
- * fetchResponse,
79
- * )
80
- *
81
- * // Fully typed (validated) response body, according to the method's output schema
82
- * const { cursor, feed } = response.body
83
- * ```
84
- */
85
- export declare class XrpcResponse<M extends Procedure | Query> implements ResultSuccess<XrpcResponse<M>> {
86
- readonly method: M;
87
- readonly status: number;
88
- readonly headers: Headers;
89
- readonly payload: XrpcResponsePayload<M>;
90
- /** @see {@link ResultSuccess.success} */
91
- readonly success: true;
92
- /** @see {@link ResultSuccess.value} */
93
- get value(): this;
94
- constructor(method: M, status: number, headers: Headers, payload: XrpcResponsePayload<M>);
95
- /**
96
- * Whether the response payload was parsed as {@link LexValue} (`true`) or is
97
- * in binary form {@link Uint8Array} (`false`).
98
- */
99
- get isParsed(): boolean;
100
- /**
101
- * The Content-Type encoding of the response (e.g., 'application/json').
102
- * Returns `undefined` if the response has no body.
103
- */
104
- get encoding(): InferMethodOutputEncoding<M>;
105
- /**
106
- * The parsed response body.
107
- *
108
- * For 'application/json' responses, this is the parsed and validated LexValue.
109
- * For binary responses, this is a Uint8Array.
110
- * Returns `undefined` if the response has no body.
111
- */
112
- get body(): XrpcResponseBody<M>;
113
- /**
114
- * @throws {XrpcResponseError} in case of (valid) XRPC error responses. Use
115
- * {@link XrpcResponseError.matchesSchemaErrors} to narrow the error type based on
116
- * the method's declared error schema. This can be narrowed further as a
117
- * {@link XrpcAuthenticationError} if the error is an authentication error.
118
- * @throws {XrpcInvalidResponseError} when the response is not a valid XRPC
119
- * response, or if the response does not conform to the method's schema.
120
- */
121
- static fromFetchResponse<const M extends Procedure | Query>(method: M, response: Response, options?: XrpcResponseOptions): Promise<XrpcResponse<M>>;
122
- }
123
- export {};
124
- //# sourceMappingURL=response.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAK,EACL,aAAa,EACb,SAAS,EACV,MAAM,qBAAqB,CAAA;AAQ5B,OAAO,KAAK,EAAE,cAAc,EAA8B,MAAM,YAAY,CAAA;AAW5E,KAAK,iBAAiB,CAAC,SAAS,SAAS,MAAM,IAAI,SAAS,SAAS,KAAK,GACtE,cAAc,GACd,SAAS,SAAS,GAAG,MAAM,CAAC,SAAS,MAAM,IAAI,GAC7C,GAAG,CAAC,IAAI,MAAM,EAAE,GAChB,SAAS,CAAA;AAEf,KAAK,aAAa,CAChB,SAAS,SAAS,MAAM,EACxB,O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