@atproto/lex-client 0.0.21 → 0.1.0-next.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 (67) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/agent.js +2 -6
  3. package/dist/agent.js.map +1 -1
  4. package/dist/client.js +26 -39
  5. package/dist/client.js.map +1 -1
  6. package/dist/errors.js +32 -47
  7. package/dist/errors.js.map +1 -1
  8. package/dist/index.js +6 -9
  9. package/dist/index.js.map +1 -1
  10. package/dist/lexicons/com/atproto/repo/createRecord.defs.js +23 -27
  11. package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
  12. package/dist/lexicons/com/atproto/repo/createRecord.js +2 -6
  13. package/dist/lexicons/com/atproto/repo/createRecord.js.map +1 -1
  14. package/dist/lexicons/com/atproto/repo/defs.defs.js +7 -10
  15. package/dist/lexicons/com/atproto/repo/defs.defs.js.map +1 -1
  16. package/dist/lexicons/com/atproto/repo/defs.js +2 -6
  17. package/dist/lexicons/com/atproto/repo/defs.js.map +1 -1
  18. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +18 -22
  19. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
  20. package/dist/lexicons/com/atproto/repo/deleteRecord.js +2 -6
  21. package/dist/lexicons/com/atproto/repo/deleteRecord.js.map +1 -1
  22. package/dist/lexicons/com/atproto/repo/getRecord.defs.js +14 -17
  23. package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
  24. package/dist/lexicons/com/atproto/repo/getRecord.js +2 -6
  25. package/dist/lexicons/com/atproto/repo/getRecord.js.map +1 -1
  26. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +23 -26
  27. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  28. package/dist/lexicons/com/atproto/repo/listRecords.js +2 -6
  29. package/dist/lexicons/com/atproto/repo/listRecords.js.map +1 -1
  30. package/dist/lexicons/com/atproto/repo/putRecord.defs.js +24 -28
  31. package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
  32. package/dist/lexicons/com/atproto/repo/putRecord.js +2 -6
  33. package/dist/lexicons/com/atproto/repo/putRecord.js.map +1 -1
  34. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +8 -11
  35. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  36. package/dist/lexicons/com/atproto/repo/uploadBlob.js +2 -6
  37. package/dist/lexicons/com/atproto/repo/uploadBlob.js.map +1 -1
  38. package/dist/lexicons/com/atproto/repo.js +7 -11
  39. package/dist/lexicons/com/atproto/repo.js.map +1 -1
  40. package/dist/lexicons/com/atproto/sync/getBlob.defs.js +9 -12
  41. package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -1
  42. package/dist/lexicons/com/atproto/sync/getBlob.js +2 -6
  43. package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -1
  44. package/dist/lexicons/com/atproto/sync.js +1 -5
  45. package/dist/lexicons/com/atproto/sync.js.map +1 -1
  46. package/dist/lexicons/com/atproto.js +2 -6
  47. package/dist/lexicons/com/atproto.js.map +1 -1
  48. package/dist/lexicons/com.js +1 -5
  49. package/dist/lexicons/com.js.map +1 -1
  50. package/dist/lexicons/index.js +1 -5
  51. package/dist/lexicons/index.js.map +1 -1
  52. package/dist/response.js +14 -22
  53. package/dist/response.js.map +1 -1
  54. package/dist/types.d.ts +6 -2
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/types.js +1 -4
  57. package/dist/types.js.map +1 -1
  58. package/dist/util.js +6 -14
  59. package/dist/util.js.map +1 -1
  60. package/dist/www-authenticate.js +1 -4
  61. package/dist/www-authenticate.js.map +1 -1
  62. package/dist/xrpc.d.ts.map +1 -1
  63. package/dist/xrpc.js +25 -28
  64. package/dist/xrpc.js.map +1 -1
  65. package/package.json +10 -11
  66. package/src/types.ts +8 -4
  67. package/src/xrpc.ts +7 -2
package/dist/errors.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XrpcFetchError = exports.XrpcInternalError = exports.XrpcResponseValidationError = exports.XrpcInvalidResponseError = exports.XrpcAuthenticationError = exports.XrpcResponseError = exports.XrpcError = exports.LexError = exports.RETRYABLE_HTTP_STATUS_CODES = void 0;
4
- exports.isXrpcErrorPayload = isXrpcErrorPayload;
5
- exports.asXrpcFailure = asXrpcFailure;
6
- const lex_data_1 = require("@atproto/lex-data");
7
- Object.defineProperty(exports, "LexError", { enumerable: true, get: function () { return lex_data_1.LexError; } });
8
- const lex_schema_1 = require("@atproto/lex-schema");
9
- const www_authenticate_js_1 = require("./www-authenticate.js");
1
+ import { LexError, } from '@atproto/lex-data';
2
+ import { lexErrorDataSchema, } from '@atproto/lex-schema';
3
+ import { parseWWWAuthenticateHeader, } from './www-authenticate.js';
10
4
  /**
11
5
  * Mapping that allows generating an XRPC error code from an HTTP status code
12
6
  * when the response does not contain a valid XRPC error payload. This is used
@@ -42,9 +36,10 @@ const StatusErrorCodes = new Map([
42
36
  * - 522 Connection Timed Out (Cloudflare)
43
37
  * - 524 A Timeout Occurred (Cloudflare)
44
38
  */
45
- exports.RETRYABLE_HTTP_STATUS_CODES = new Set([
39
+ export const RETRYABLE_HTTP_STATUS_CODES = new Set([
46
40
  408, 425, 429, 500, 502, 503, 504, 522, 524,
47
41
  ]);
42
+ export { LexError };
48
43
  /**
49
44
  * All unsuccessful responses should follow a standard error response
50
45
  * schema. The Content-Type should be application/json, and the payload
@@ -57,10 +52,10 @@ exports.RETRYABLE_HTTP_STATUS_CODES = new Set([
57
52
  *
58
53
  * This function checks whether a given payload matches this schema.
59
54
  */
60
- function isXrpcErrorPayload(payload) {
55
+ export function isXrpcErrorPayload(payload) {
61
56
  return (payload != null &&
62
57
  payload.encoding === 'application/json' &&
63
- lex_schema_1.lexErrorDataSchema.matches(payload.body));
58
+ lexErrorDataSchema.matches(payload.body));
64
59
  }
65
60
  /**
66
61
  * Abstract base class for all XRPC errors.
@@ -76,22 +71,20 @@ function isXrpcErrorPayload(payload) {
76
71
  * @see {@link XrpcInvalidResponseError} - For invalid/unexpected responses
77
72
  * @see {@link XrpcInternalError} - For network/internal errors
78
73
  */
79
- class XrpcError extends lex_data_1.LexError {
80
- method;
81
- name = 'XrpcError';
74
+ export class XrpcError extends LexError {
82
75
  constructor(method, error, message = `${error} Lexicon RPC error`, options) {
83
76
  super(error, message, options);
84
77
  this.method = method;
78
+ this.name = 'XrpcError';
79
+ /**
80
+ * @see {@link ResultFailure.success}
81
+ */
82
+ this.success = false;
85
83
  }
86
- /**
87
- * @see {@link ResultFailure.success}
88
- */
89
- success = false;
90
84
  matchesSchemaErrors() {
91
85
  return this.method.errors?.includes(this.error) ?? false;
92
86
  }
93
87
  }
94
- exports.XrpcError = XrpcError;
95
88
  /**
96
89
  * Error class for valid XRPC error responses from the server.
97
90
  *
@@ -116,10 +109,7 @@ exports.XrpcError = XrpcError;
116
109
  * }
117
110
  * ```
118
111
  */
119
- class XrpcResponseError extends XrpcError {
120
- response;
121
- payload;
122
- name = 'XrpcResponseError';
112
+ export class XrpcResponseError extends XrpcError {
123
113
  constructor(method, response, payload, options) {
124
114
  const { error, message } = isXrpcErrorPayload(payload)
125
115
  ? payload.body
@@ -131,12 +121,13 @@ class XrpcResponseError extends XrpcError {
131
121
  super(method, error, message, options);
132
122
  this.response = response;
133
123
  this.payload = payload;
124
+ this.name = 'XrpcResponseError';
134
125
  }
135
126
  get reason() {
136
127
  return this;
137
128
  }
138
129
  shouldRetry() {
139
- return exports.RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
130
+ return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
140
131
  }
141
132
  toJSON() {
142
133
  // Return the original error payload if it's a valid XRPC error, otherwise
@@ -170,7 +161,6 @@ class XrpcResponseError extends XrpcError {
170
161
  return this.payload?.body;
171
162
  }
172
163
  }
173
- exports.XrpcResponseError = XrpcResponseError;
174
164
  /**
175
165
  * Error class for 401 Unauthorized XRPC responses.
176
166
  *
@@ -197,8 +187,11 @@ exports.XrpcResponseError = XrpcResponseError;
197
187
  * }
198
188
  * ```
199
189
  */
200
- class XrpcAuthenticationError extends XrpcResponseError {
201
- name = 'XrpcAuthenticationError';
190
+ export class XrpcAuthenticationError extends XrpcResponseError {
191
+ constructor() {
192
+ super(...arguments);
193
+ this.name = 'XrpcAuthenticationError';
194
+ }
202
195
  shouldRetry() {
203
196
  return false;
204
197
  }
@@ -209,10 +202,9 @@ class XrpcAuthenticationError extends XrpcResponseError {
209
202
  */
210
203
  get wwwAuthenticate() {
211
204
  return (this.#wwwAuthenticateCached ??=
212
- (0, www_authenticate_js_1.parseWWWAuthenticateHeader)(this.response.headers.get('www-authenticate')) ?? {});
205
+ parseWWWAuthenticateHeader(this.response.headers.get('www-authenticate')) ?? {});
213
206
  }
214
207
  }
215
- exports.XrpcAuthenticationError = XrpcAuthenticationError;
216
208
  /**
217
209
  * Error class for invalid or unprocessable XRPC responses from upstream servers.
218
210
  *
@@ -229,26 +221,23 @@ exports.XrpcAuthenticationError = XrpcAuthenticationError;
229
221
  *
230
222
  * @typeParam M - The XRPC method type
231
223
  */
232
- class XrpcInvalidResponseError extends XrpcError {
233
- response;
234
- payload;
235
- name = 'XrpcInvalidResponseError';
224
+ export class XrpcInvalidResponseError extends XrpcError {
236
225
  constructor(method, response, payload, message = buildResponseOverviewMessage(response), options) {
237
226
  super(method, 'InvalidResponse', message, options);
238
227
  this.response = response;
239
228
  this.payload = payload;
229
+ this.name = 'XrpcInvalidResponseError';
240
230
  }
241
231
  get reason() {
242
232
  return this;
243
233
  }
244
234
  shouldRetry() {
245
- return exports.RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
235
+ return RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
246
236
  }
247
237
  toDownstreamError() {
248
238
  return { status: 502, body: this.toJSON() };
249
239
  }
250
240
  }
251
- exports.XrpcInvalidResponseError = XrpcInvalidResponseError;
252
241
  /**
253
242
  * Error class for invalid XRPC responses that fail schema validation.
254
243
  *
@@ -260,15 +249,13 @@ exports.XrpcInvalidResponseError = XrpcInvalidResponseError;
260
249
  *
261
250
  * @typeParam M - The XRPC method type
262
251
  */
263
- class XrpcResponseValidationError extends XrpcInvalidResponseError {
264
- cause;
265
- name = 'XrpcResponseValidationError';
252
+ export class XrpcResponseValidationError extends XrpcInvalidResponseError {
266
253
  constructor(method, response, payload, cause) {
267
254
  super(method, response, payload, `Invalid response payload: ${cause.message}`, { cause });
268
255
  this.cause = cause;
256
+ this.name = 'XrpcResponseValidationError';
269
257
  }
270
258
  }
271
- exports.XrpcResponseValidationError = XrpcResponseValidationError;
272
259
  /**
273
260
  * Error class for unexpected internal/client-side errors during XRPC requests.
274
261
  *
@@ -278,10 +265,10 @@ exports.XrpcResponseValidationError = XrpcResponseValidationError;
278
265
  *
279
266
  * @typeParam M - The XRPC method type
280
267
  */
281
- class XrpcInternalError extends XrpcError {
282
- name = 'XrpcInternalError';
268
+ export class XrpcInternalError extends XrpcError {
283
269
  constructor(method, message, options) {
284
270
  super(method, 'InternalServerError', message ?? 'Unable to fulfill XRPC request', options);
271
+ this.name = 'XrpcInternalError';
285
272
  }
286
273
  get reason() {
287
274
  return this;
@@ -297,7 +284,6 @@ class XrpcInternalError extends XrpcError {
297
284
  return { status: 500, body: this.toJSON() };
298
285
  }
299
286
  }
300
- exports.XrpcInternalError = XrpcInternalError;
301
287
  /**
302
288
  * Special case of XrpcInternalError that specifically represents errors thrown
303
289
  * by {@link Agent.fetchHandler} during the XRPC request. This includes:
@@ -308,11 +294,11 @@ exports.XrpcInternalError = XrpcInternalError;
308
294
  * These errors are optimistically considered retryable, as many fetch errors
309
295
  * are transient and may succeed on retry.
310
296
  */
311
- class XrpcFetchError extends XrpcInternalError {
312
- name = 'XrpcFetchError';
297
+ export class XrpcFetchError extends XrpcInternalError {
313
298
  constructor(method, cause) {
314
299
  const message = cause instanceof Error ? cause.message : String(cause);
315
300
  super(method, `Unexpected fetchHandler() error: ${message}`, { cause });
301
+ this.name = 'XrpcFetchError';
316
302
  }
317
303
  shouldRetry() {
318
304
  // Ideally, we would inspect the reason to determine if it's retryable (by
@@ -334,7 +320,6 @@ class XrpcFetchError extends XrpcInternalError {
334
320
  return { status: 502, body: this.toJSON() };
335
321
  }
336
322
  }
337
- exports.XrpcFetchError = XrpcFetchError;
338
323
  /**
339
324
  * Converts an unknown error into an appropriate {@link XrpcFailure} type.
340
325
  *
@@ -355,7 +340,7 @@ exports.XrpcFetchError = XrpcFetchError;
355
340
  * }
356
341
  * ```
357
342
  */
358
- function asXrpcFailure(method, cause) {
343
+ export function asXrpcFailure(method, cause) {
359
344
  if (cause instanceof XrpcResponseError ||
360
345
  cause instanceof XrpcInvalidResponseError ||
361
346
  cause instanceof XrpcInternalError) {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAkGA,gDAQC;AAsZD,sCAaC;AA7gBD,gDAK0B;AAkEjB,yFAtEP,mBAAQ,OAsEO;AAjEjB,oDAO4B;AAI5B,+DAG8B;AAE9B;;;;;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;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AmD;IACnD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,CAAC;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 {\n LexError,\n LexErrorCode,\n LexErrorData,\n LexValue,\n} from '@atproto/lex-data'\nimport {\n InferMethodError,\n LexValidationError,\n Procedure,\n Query,\n ResultFailure,\n lexErrorDataSchema,\n} from '@atproto/lex-schema'\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Agent } from './agent.js'\nimport { XrpcUnknownResponsePayload } from './types.js'\nimport {\n WWWAuthenticate,\n parseWWWAuthenticateHeader,\n} 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
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,GAIT,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAML,kBAAkB,GACnB,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAEL,0BAA0B,GAC3B,MAAM,uBAAuB,CAAA;AAE9B;;;;;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;;;;;;;;;;;;;GAa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C;QACf,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACzC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC5B,CAAC;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 {\n LexError,\n LexErrorCode,\n LexErrorData,\n LexValue,\n} from '@atproto/lex-data'\nimport {\n InferMethodError,\n LexValidationError,\n Procedure,\n Query,\n ResultFailure,\n lexErrorDataSchema,\n} from '@atproto/lex-schema'\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport { Agent } from './agent.js'\nimport { XrpcUnknownResponsePayload } from './types.js'\nimport {\n WWWAuthenticate,\n parseWWWAuthenticateHeader,\n} 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"]}
package/dist/index.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./agent.js"), exports);
5
- tslib_1.__exportStar(require("./client.js"), exports);
6
- tslib_1.__exportStar(require("./errors.js"), exports);
7
- tslib_1.__exportStar(require("./response.js"), exports);
8
- tslib_1.__exportStar(require("./types.js"), exports);
9
- tslib_1.__exportStar(require("./xrpc.js"), exports);
1
+ export * from './agent.js';
2
+ export * from './client.js';
3
+ export * from './errors.js';
4
+ export * from './response.js';
5
+ export * from './types.js';
6
+ export * from './xrpc.js';
10
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,sDAA2B;AAC3B,sDAA2B;AAC3B,wDAA6B;AAC7B,qDAA0B;AAC1B,oDAAyB","sourcesContent":["export * from './agent.js'\nexport * from './client.js'\nexport * from './errors.js'\nexport * from './response.js'\nexport * from './types.js'\nexport * from './xrpc.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA","sourcesContent":["export * from './agent.js'\nexport * from './client.js'\nexport * from './errors.js'\nexport * from './response.js'\nexport * from './types.js'\nexport * from './xrpc.js'\n"]}
@@ -1,37 +1,33 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$output = exports.$input = exports.$params = exports.$lxm = exports.main = exports.$nsid = void 0;
7
- const tslib_1 = require("tslib");
8
- const lex_schema_1 = require("@atproto/lex-schema");
9
- const RepoDefs = tslib_1.__importStar(require("./defs.defs.js"));
4
+ import { l } from '@atproto/lex-schema';
5
+ import * as RepoDefs from './defs.defs.js';
10
6
  const $nsid = 'com.atproto.repo.createRecord';
11
- exports.$nsid = $nsid;
7
+ export { $nsid };
12
8
  /** Create a single new repository record. Requires auth, implemented by PDS. */
13
9
  const main =
14
10
  /*#__PURE__*/
15
- lex_schema_1.l.procedure($nsid,
16
- /*#__PURE__*/ lex_schema_1.l.params(),
17
- /*#__PURE__*/ lex_schema_1.l.jsonPayload({
18
- repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
19
- collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
20
- rkey: /*#__PURE__*/ lex_schema_1.l.optional(
21
- /*#__PURE__*/ lex_schema_1.l.string({ format: 'record-key', maxLength: 512 })),
22
- validate: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.boolean()),
23
- record: /*#__PURE__*/ lex_schema_1.l.lexMap(),
24
- swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
25
- /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
11
+ l.procedure($nsid,
12
+ /*#__PURE__*/ l.params(),
13
+ /*#__PURE__*/ l.jsonPayload({
14
+ repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),
15
+ collection: /*#__PURE__*/ l.string({ format: 'nsid' }),
16
+ rkey: /*#__PURE__*/ l.optional(
17
+ /*#__PURE__*/ l.string({ format: 'record-key', maxLength: 512 })),
18
+ validate: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),
19
+ record: /*#__PURE__*/ l.lexMap(),
20
+ swapCommit: /*#__PURE__*/ l.optional(
21
+ /*#__PURE__*/ l.string({ format: 'cid' })),
26
22
  }),
27
- /*#__PURE__*/ lex_schema_1.l.jsonPayload({
28
- uri: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-uri' }),
29
- cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
30
- commit: /*#__PURE__*/ lex_schema_1.l.optional(
31
- /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
32
- validationStatus: /*#__PURE__*/ lex_schema_1.l.optional(
33
- /*#__PURE__*/ lex_schema_1.l.string()),
23
+ /*#__PURE__*/ l.jsonPayload({
24
+ uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),
25
+ cid: /*#__PURE__*/ l.string({ format: 'cid' }),
26
+ commit: /*#__PURE__*/ l.optional(
27
+ /*#__PURE__*/ l.ref((() => RepoDefs.commitMeta))),
28
+ validationStatus: /*#__PURE__*/ l.optional(
29
+ /*#__PURE__*/ l.string()),
34
30
  }), ['InvalidSwap']);
35
- exports.main = main;
36
- exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
31
+ export { main };
32
+ export const $lxm = /*#__PURE__*/ main.nsid, $params = /*#__PURE__*/ main.parameters, $input = /*#__PURE__*/ main.input, $output = /*#__PURE__*/ main.output;
37
33
  //# sourceMappingURL=createRecord.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd,gFAA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AC,cAAC,CAAC,MAAM,EAAyC,CAChE;CACF,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAcA,QAAA,IAAI,GAAiB,IAAI,CAAC,IAAI,EACzC,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EACvC,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.createRecord'\n\nexport { $nsid }\n\n/** Create a single new repository record. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'record-key', maxLength: 512 }),\n ),\n validate: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),\n record: /*#__PURE__*/ l.lexMap(),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n /*#__PURE__*/ l.jsonPayload({\n uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n validationStatus: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string<{ knownValues: ['valid', 'unknown'] }>(),\n ),\n }),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
1
+ {"version":3,"file":"createRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,gFAAgF;AAChF,MAAM,IAAI;AACR,aAAa;AACb,CAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE;AACxB,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IAC5B,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CACjE;IACD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC7D,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAAE;IAChC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;CACF,CAAC;AACF,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACjD,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IAC9B,aAAa,CAAC,CAAC,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAQ,CACnC,CACF;IACD,gBAAgB,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ;IACxC,aAAa,CAAC,CAAC,CAAC,MAAM,EAAyC,CAChE;CACF,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAcf,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EACzC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,EACvC,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,EACjC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.createRecord'\n\nexport { $nsid }\n\n/** Create a single new repository record. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'record-key', maxLength: 512 }),\n ),\n validate: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),\n record: /*#__PURE__*/ l.lexMap(),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n /*#__PURE__*/ l.jsonPayload({\n uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n validationStatus: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string<{ knownValues: ['valid', 'unknown'] }>(),\n ),\n }),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
@@ -1,10 +1,6 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$defs = void 0;
7
- const tslib_1 = require("tslib");
8
- tslib_1.__exportStar(require("./createRecord.defs.js"), exports);
9
- exports.$defs = tslib_1.__importStar(require("./createRecord.defs.js"));
4
+ export * from './createRecord.defs.js';
5
+ export * as $defs from './createRecord.defs.js';
10
6
  //# sourceMappingURL=createRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRecord.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iEAAsC;AACtC,wEAA+C","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './createRecord.defs.js'\nexport * as $defs from './createRecord.defs.js'\n"]}
1
+ {"version":3,"file":"createRecord.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,wBAAwB,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './createRecord.defs.js'\nexport * as $defs from './createRecord.defs.js'\n"]}
@@ -1,16 +1,13 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.commitMeta = exports.$nsid = void 0;
7
- const lex_schema_1 = require("@atproto/lex-schema");
4
+ import { l } from '@atproto/lex-schema';
8
5
  const $nsid = 'com.atproto.repo.defs';
9
- exports.$nsid = $nsid;
10
- const commitMeta = /*#__PURE__*/ lex_schema_1.l.typedObject($nsid, 'commitMeta',
11
- /*#__PURE__*/ lex_schema_1.l.object({
12
- cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
13
- rev: /*#__PURE__*/ lex_schema_1.l.string({ format: 'tid' }),
6
+ export { $nsid };
7
+ const commitMeta = /*#__PURE__*/ l.typedObject($nsid, 'commitMeta',
8
+ /*#__PURE__*/ l.object({
9
+ cid: /*#__PURE__*/ l.string({ format: 'cid' }),
10
+ rev: /*#__PURE__*/ l.string({ format: 'tid' }),
14
11
  }));
15
- exports.commitMeta = commitMeta;
12
+ export { commitMeta };
16
13
  //# sourceMappingURL=defs.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAAuC;AAEvC,MAAM,KAAK,GAAG,uBAAuB,CAAA;AAE5B,sBAAK;AAUd,MAAM,UAAU,GAAG,aAAa,CAAC,cAAC,CAAC,WAAW,CAC5C,KAAK,EACL,YAAY;AACZ,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAC/C,CAAC,CACH,CAAA;AAEQ,gCAAU","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.repo.defs'\n\nexport { $nsid }\n\ntype CommitMeta = {\n $type?: 'com.atproto.repo.defs#commitMeta'\n cid: l.CidString\n rev: l.TidString\n}\n\nexport type { CommitMeta }\n\nconst commitMeta = /*#__PURE__*/ l.typedObject<CommitMeta>(\n $nsid,\n 'commitMeta',\n /*#__PURE__*/ l.object({\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n rev: /*#__PURE__*/ l.string({ format: 'tid' }),\n }),\n)\n\nexport { commitMeta }\n"]}
1
+ {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,MAAM,KAAK,GAAG,uBAAuB,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,CAAA;AAUhB,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAC5C,KAAK,EACL,YAAY;AACZ,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAC/C,CAAC,CACH,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.repo.defs'\n\nexport { $nsid }\n\ntype CommitMeta = {\n $type?: 'com.atproto.repo.defs#commitMeta'\n cid: l.CidString\n rev: l.TidString\n}\n\nexport type { CommitMeta }\n\nconst commitMeta = /*#__PURE__*/ l.typedObject<CommitMeta>(\n $nsid,\n 'commitMeta',\n /*#__PURE__*/ l.object({\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n rev: /*#__PURE__*/ l.string({ format: 'tid' }),\n }),\n)\n\nexport { commitMeta }\n"]}
@@ -1,10 +1,6 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$defs = void 0;
7
- const tslib_1 = require("tslib");
8
- tslib_1.__exportStar(require("./defs.defs.js"), exports);
9
- exports.$defs = tslib_1.__importStar(require("./defs.defs.js"));
4
+ export * from './defs.defs.js';
5
+ export * as $defs from './defs.defs.js';
10
6
  //# sourceMappingURL=defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,yDAA8B;AAC9B,gEAAuC","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './defs.defs.js'\nexport * as $defs from './defs.defs.js'\n"]}
1
+ {"version":3,"file":"defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './defs.defs.js'\nexport * as $defs from './defs.defs.js'\n"]}
@@ -1,32 +1,28 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$output = exports.$input = exports.$params = exports.$lxm = exports.main = exports.$nsid = void 0;
7
- const tslib_1 = require("tslib");
8
- const lex_schema_1 = require("@atproto/lex-schema");
9
- const RepoDefs = tslib_1.__importStar(require("./defs.defs.js"));
4
+ import { l } from '@atproto/lex-schema';
5
+ import * as RepoDefs from './defs.defs.js';
10
6
  const $nsid = 'com.atproto.repo.deleteRecord';
11
- exports.$nsid = $nsid;
7
+ export { $nsid };
12
8
  /** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */
13
9
  const main =
14
10
  /*#__PURE__*/
15
- lex_schema_1.l.procedure($nsid,
16
- /*#__PURE__*/ lex_schema_1.l.params(),
17
- /*#__PURE__*/ lex_schema_1.l.jsonPayload({
18
- repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
19
- collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
20
- rkey: /*#__PURE__*/ lex_schema_1.l.string({ format: 'record-key' }),
21
- swapRecord: /*#__PURE__*/ lex_schema_1.l.optional(
22
- /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
23
- swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
24
- /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
11
+ l.procedure($nsid,
12
+ /*#__PURE__*/ l.params(),
13
+ /*#__PURE__*/ l.jsonPayload({
14
+ repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),
15
+ collection: /*#__PURE__*/ l.string({ format: 'nsid' }),
16
+ rkey: /*#__PURE__*/ l.string({ format: 'record-key' }),
17
+ swapRecord: /*#__PURE__*/ l.optional(
18
+ /*#__PURE__*/ l.string({ format: 'cid' })),
19
+ swapCommit: /*#__PURE__*/ l.optional(
20
+ /*#__PURE__*/ l.string({ format: 'cid' })),
25
21
  }),
26
- /*#__PURE__*/ lex_schema_1.l.jsonPayload({
27
- commit: /*#__PURE__*/ lex_schema_1.l.optional(
28
- /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
22
+ /*#__PURE__*/ l.jsonPayload({
23
+ commit: /*#__PURE__*/ l.optional(
24
+ /*#__PURE__*/ l.ref((() => RepoDefs.commitMeta))),
29
25
  }), ['InvalidSwap']);
30
- exports.main = main;
31
- exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
26
+ export { main };
27
+ export const $lxm = /*#__PURE__*/ main.nsid, $params = /*#__PURE__*/ main.parameters, $input = /*#__PURE__*/ main.input, $output = /*#__PURE__*/ main.output;
32
28
  //# sourceMappingURL=deleteRecord.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd,iGAAiG;AACjG,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;AACxB,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACtD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;IACD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;CACF,CAAC;AACF,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAC9B,aAAa,CAAC,cAAC,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAQ,CACnC,CACF;CACF,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAcA,QAAA,IAAI,GAAiB,IAAI,CAAC,IAAI,EACzC,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EACvC,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.deleteRecord'\n\nexport { $nsid }\n\n/** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.string({ format: 'record-key' }),\n swapRecord: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n /*#__PURE__*/ l.jsonPayload({\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n }),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
1
+ {"version":3,"file":"deleteRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,iGAAiG;AACjG,MAAM,I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DIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.deleteRecord'\n\nexport { $nsid }\n\n/** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.string({ format: 'record-key' }),\n swapRecord: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n /*#__PURE__*/ l.jsonPayload({\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n }),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport type $Params = l.InferMethodParams<typeof main>\nexport type $Input<B = l.BinaryData> = l.InferMethodInput<typeof main, B>\nexport type $InputBody<B = l.BinaryData> = l.InferMethodInputBody<\n typeof main,\n B\n>\nexport type $Output<B = l.BinaryData> = l.InferMethodOutput<typeof main, B>\nexport type $OutputBody<B = l.BinaryData> = l.InferMethodOutputBody<\n typeof main,\n B\n>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
@@ -1,10 +1,6 @@
1
- "use strict";
2
1
  /*
3
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$defs = void 0;
7
- const tslib_1 = require("tslib");
8
- tslib_1.__exportStar(require("./deleteRecord.defs.js"), exports);
9
- exports.$defs = tslib_1.__importStar(require("./deleteRecord.defs.js"));
4
+ export * from './deleteRecord.defs.js';
5
+ export * as $defs from './deleteRecord.defs.js';
10
6
  //# sourceMappingURL=deleteRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRecord.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iEAAsC;AACtC,wEAA+C","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './deleteRecord.defs.js'\nexport * as $defs from './deleteRecord.defs.js'\n"]}
1
+ {"version":3,"file":"deleteRecord.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,wBAAwB,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * from './deleteRecord.defs.js'\nexport * as $defs from './deleteRecord.defs.js'\n"]}