@atproto/lex-client 0.0.9 → 0.0.11

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 (53) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE.txt +1 -1
  3. package/dist/agent.d.ts +5 -0
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +15 -1
  6. package/dist/agent.js.map +1 -1
  7. package/dist/client.d.ts +59 -40
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +2 -6
  10. package/dist/client.js.map +1 -1
  11. package/dist/errors.d.ts +52 -51
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +90 -71
  14. package/dist/errors.js.map +1 -1
  15. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +20 -10
  16. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
  17. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts +1 -1
  18. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts.map +1 -1
  19. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +14 -6
  20. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
  21. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +12 -4
  22. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
  23. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +11 -11
  24. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
  25. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +2 -1
  26. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  27. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +18 -10
  28. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
  29. package/dist/response.d.ts +14 -13
  30. package/dist/response.d.ts.map +1 -1
  31. package/dist/response.js +36 -35
  32. package/dist/response.js.map +1 -1
  33. package/dist/util.d.ts +1 -1
  34. package/dist/util.d.ts.map +1 -1
  35. package/dist/util.js.map +1 -1
  36. package/dist/www-authenticate.d.ts +12 -0
  37. package/dist/www-authenticate.d.ts.map +1 -0
  38. package/dist/www-authenticate.js +57 -0
  39. package/dist/www-authenticate.js.map +1 -0
  40. package/dist/xrpc.d.ts +14 -21
  41. package/dist/xrpc.d.ts.map +1 -1
  42. package/dist/xrpc.js +18 -35
  43. package/dist/xrpc.js.map +1 -1
  44. package/package.json +6 -6
  45. package/src/agent.ts +34 -1
  46. package/src/client.ts +34 -33
  47. package/src/errors.ts +161 -128
  48. package/src/lexicons/com/atproto/repo/listRecords.defs.ts +4 -1
  49. package/src/response.ts +71 -71
  50. package/src/util.ts +1 -1
  51. package/src/www-authenticate.test.ts +227 -0
  52. package/src/www-authenticate.ts +77 -0
  53. package/src/xrpc.ts +53 -95
package/dist/errors.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data';
2
- import { l } from '@atproto/lex-schema';
3
- import { Payload } from './util.js';
2
+ import { InferMethodError, Procedure, Query, ResultFailure } from '@atproto/lex-schema';
3
+ import { XrpcPayload } from './util.js';
4
+ import { WWWAuthenticate } from './www-authenticate.js';
5
+ export declare const RETRYABLE_HTTP_STATUS_CODES: ReadonlySet<number>;
4
6
  export { LexError };
5
7
  export type { LexErrorCode, LexErrorData };
6
- export type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<LexErrorData<N>, 'application/json'>;
7
- export declare class LexRpcError<N extends LexErrorCode = LexErrorCode> extends LexError<N> {
8
- name: string;
9
- constructor(error: N, message?: string, options?: ErrorOptions);
10
- }
8
+ export type XrpcErrorPayload<N extends LexErrorCode = LexErrorCode> = XrpcPayload<LexErrorData<N>, 'application/json'>;
11
9
  /**
12
10
  * All unsuccessful responses should follow a standard error response
13
11
  * schema. The Content-Type should be application/json, and the payload
@@ -20,64 +18,67 @@ export declare class LexRpcError<N extends LexErrorCode = LexErrorCode> extends
20
18
  *
21
19
  * This function checks whether a given payload matches this schema.
22
20
  */
23
- export declare function isLexRpcErrorPayload(payload: Payload | null): payload is LexRpcErrorPayload;
24
- /**
25
- * Interface representing a failed XRPC request result.
26
- */
27
- type LexRpcFailureResult<N extends LexErrorCode, E> = l.ResultFailure<E> & {
28
- readonly error: N;
29
- shouldRetry(): boolean;
30
- matchesSchema(): boolean;
31
- };
21
+ export declare function isXrpcErrorPayload(payload: XrpcPayload | null): payload is XrpcErrorPayload;
22
+ export declare abstract class XrpcError<M extends Procedure | Query = Procedure | Query, N extends LexErrorCode = LexErrorCode, TReason = unknown> extends LexError<N> implements ResultFailure<TReason> {
23
+ readonly method: M;
24
+ name: string;
25
+ constructor(method: M, error: N, message?: string, options?: ErrorOptions);
26
+ /**
27
+ * @see {@link ResultFailure.success}
28
+ */
29
+ readonly success: false;
30
+ /**
31
+ * @see {@link ResultFailure.reason}
32
+ */
33
+ abstract readonly reason: TReason;
34
+ /**
35
+ * Indicates whether the error is transient and can be retried.
36
+ */
37
+ abstract shouldRetry(): boolean;
38
+ matchesSchema(): this is XrpcError<M, InferMethodError<M>>;
39
+ }
32
40
  /**
33
- * Class used to represent an HTTP request that resulted in an XRPC method error
34
- * That is, a non-2xx response with a valid XRPC error payload.
41
+ * Class used to represent an HTTP request that resulted in an XRPC method
42
+ * error. That is, a non-2xx response with a valid XRPC error payload.
35
43
  */
36
- export declare class LexRpcResponseError<M extends l.Procedure | l.Query = l.Procedure | l.Query, N extends LexErrorCode = LexErrorCode> extends LexRpcError<N> implements LexRpcFailureResult<N, LexRpcResponseError<M, N>> {
37
- readonly method: M;
38
- readonly status: number;
39
- readonly headers: Headers;
40
- readonly payload: LexRpcErrorPayload<N>;
44
+ export declare class XrpcResponseError<M extends Procedure | Query = Procedure | Query, N extends LexErrorCode = InferMethodError<M> | LexErrorCode> extends XrpcError<M, N, XrpcResponseError<M, N>> {
45
+ readonly response: Response;
46
+ readonly payload: XrpcErrorPayload<N>;
41
47
  name: string;
42
- constructor(method: M, status: number, headers: Headers, payload: LexRpcErrorPayload<N>, options?: ErrorOptions);
43
- readonly success = false;
48
+ constructor(method: M, response: Response, payload: XrpcErrorPayload<N>, options?: ErrorOptions);
44
49
  get reason(): this;
45
- get body(): LexErrorData;
46
- matchesSchema(): this is M extends {
47
- errors: readonly (infer E extends string)[];
48
- } ? LexRpcResponseError<M, E> : never;
49
50
  shouldRetry(): boolean;
50
51
  toJSON(): LexErrorData<N>;
51
52
  toResponse(): Response;
53
+ get body(): LexErrorData;
54
+ }
55
+ export type { WWWAuthenticate };
56
+ export declare class XrpcAuthenticationError<M extends Procedure | Query = Procedure | Query, N extends LexErrorCode = LexErrorCode> extends XrpcResponseError<M, N> {
57
+ #private;
58
+ name: string;
59
+ shouldRetry(): boolean;
60
+ get wwwAuthenticate(): WWWAuthenticate;
52
61
  }
53
62
  /**
54
- * This class represents an invalid XRPC response from the server.
63
+ * This class represents invalid or unprocessable XRPC response from the
64
+ * upstream server.
55
65
  */
56
- export declare class LexRpcUpstreamError<N extends 'InvalidResponse' | 'UpstreamFailure' = 'InvalidResponse' | 'UpstreamFailure'> extends LexRpcError<N> implements LexRpcFailureResult<N, LexRpcUpstreamError<N>> {
57
- name: "LexRpcUpstreamError";
58
- readonly response: {
59
- status: number;
60
- headers: Headers;
61
- payload: Payload | null;
62
- };
63
- constructor(error: N, message: string, response: {
64
- status: number;
65
- headers: Headers;
66
- }, payload: Payload | null, options?: ErrorOptions);
67
- readonly success: false;
66
+ export declare class XrpcUpstreamError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, 'UpstreamFailure', XrpcUpstreamError<M>> {
67
+ readonly response: Response;
68
+ readonly payload: XrpcPayload | null;
69
+ name: string;
70
+ constructor(method: M, response: Response, payload: XrpcPayload | null, message?: string, options?: ErrorOptions);
68
71
  get reason(): this;
69
- matchesSchema(): false;
70
72
  shouldRetry(): boolean;
71
73
  toResponse(): Response;
72
74
  }
73
- export declare class LexRpcUnexpectedError extends LexRpcError<'InternalServerError'> implements LexRpcFailureResult<'InternalServerError', unknown> {
74
- name: "LexRpcUnexpectedError";
75
- protected constructor(message: string, options: Required<ErrorOptions>);
76
- readonly success = false;
77
- get reason(): unknown;
78
- matchesSchema(): false;
79
- shouldRetry(): boolean;
75
+ export declare class XrpcInternalError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, 'InternalServerError', XrpcInternalError<M>> {
76
+ name: string;
77
+ constructor(method: M, message?: string, options?: ErrorOptions);
78
+ get reason(): this;
79
+ shouldRetry(): true;
80
80
  toResponse(): Response;
81
- static from(cause: unknown, message?: string): LexRpcUnexpectedError;
82
81
  }
82
+ export type XrpcFailure<M extends Procedure | Query = Procedure | Query> = XrpcResponseError<M> | XrpcUpstreamError<M> | XrpcInternalError<M>;
83
+ export declare function asXrpcFailure<M extends Procedure | Query>(method: M, cause: unknown): XrpcFailure<M>;
83
84
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,QAAQ,EAAE,CAAA;AACnB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA;AAE1C,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,OAAO,CAC7E,YAAY,CAAC,CAAC,CAAC,EACf,kBAAkB,CACnB,CAAA;AAED,qBAAa,WAAW,CACtB,CAAC,SAAS,YAAY,GAAG,YAAY,CACrC,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACnB,IAAI,SAAgB;gBAGlB,KAAK,EAAE,CAAC,EACR,OAAO,G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1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LexRpcUnexpectedError = exports.LexRpcUpstreamError = exports.LexRpcResponseError = exports.LexRpcError = exports.LexError = void 0;
4
- exports.isLexRpcErrorPayload = isLexRpcErrorPayload;
3
+ exports.XrpcInternalError = exports.XrpcUpstreamError = exports.XrpcAuthenticationError = exports.XrpcResponseError = exports.XrpcError = exports.LexError = exports.RETRYABLE_HTTP_STATUS_CODES = void 0;
4
+ exports.isXrpcErrorPayload = isXrpcErrorPayload;
5
+ exports.asXrpcFailure = asXrpcFailure;
5
6
  const lex_data_1 = require("@atproto/lex-data");
6
7
  Object.defineProperty(exports, "LexError", { enumerable: true, get: function () { return lex_data_1.LexError; } });
7
8
  const lex_schema_1 = require("@atproto/lex-schema");
8
- class LexRpcError extends lex_data_1.LexError {
9
- name = 'LexRpcError';
10
- constructor(error, message = `${error} Lexicon RPC error`, options) {
11
- super(error, message, options);
12
- }
13
- }
14
- exports.LexRpcError = LexRpcError;
9
+ const www_authenticate_js_1 = require("./www-authenticate.js");
10
+ exports.RETRYABLE_HTTP_STATUS_CODES = new Set([
11
+ 408, 425, 429, 500, 502, 503, 504, 522, 524,
12
+ ]);
15
13
  /**
16
14
  * All unsuccessful responses should follow a standard error response
17
15
  * schema. The Content-Type should be application/json, and the payload
@@ -24,110 +22,131 @@ exports.LexRpcError = LexRpcError;
24
22
  *
25
23
  * This function checks whether a given payload matches this schema.
26
24
  */
27
- function isLexRpcErrorPayload(payload) {
25
+ function isXrpcErrorPayload(payload) {
28
26
  return (payload !== null &&
29
27
  payload.encoding === 'application/json' &&
30
- lex_schema_1.l.lexErrorData.matches(payload.body));
28
+ lex_schema_1.lexErrorDataSchema.matches(payload.body));
29
+ }
30
+ class XrpcError extends lex_data_1.LexError {
31
+ method;
32
+ name = 'XrpcError';
33
+ constructor(method, error, message = `${error} Lexicon RPC error`, options) {
34
+ super(error, message, options);
35
+ this.method = method;
36
+ }
37
+ /**
38
+ * @see {@link ResultFailure.success}
39
+ */
40
+ success = false;
41
+ matchesSchema() {
42
+ return this.method.errors?.includes(this.error) ?? false;
43
+ }
31
44
  }
45
+ exports.XrpcError = XrpcError;
32
46
  /**
33
- * Class used to represent an HTTP request that resulted in an XRPC method error
34
- * That is, a non-2xx response with a valid XRPC error payload.
47
+ * Class used to represent an HTTP request that resulted in an XRPC method
48
+ * error. That is, a non-2xx response with a valid XRPC error payload.
35
49
  */
36
- class LexRpcResponseError extends LexRpcError {
37
- method;
38
- status;
39
- headers;
50
+ class XrpcResponseError extends XrpcError {
51
+ response;
40
52
  payload;
41
- name = 'LexRpcResponseError';
42
- constructor(method, status, headers, payload, options) {
53
+ name = 'XrpcResponseError';
54
+ constructor(method, response, payload, options) {
43
55
  const { error, message } = payload.body;
44
- super(error, message, options);
45
- this.method = method;
46
- this.status = status;
47
- this.headers = headers;
56
+ super(method, error, message, options);
57
+ this.response = response;
48
58
  this.payload = payload;
49
59
  }
50
- success = false;
51
60
  get reason() {
52
61
  return this;
53
62
  }
54
- get body() {
55
- return this.payload.body;
56
- }
57
- matchesSchema() {
58
- return this.method.errors?.includes(this.error) ?? false;
59
- }
60
63
  shouldRetry() {
61
- // Do not retry client errors
62
- if (this.status < 500)
63
- return false;
64
- return true;
64
+ return exports.RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
65
65
  }
66
66
  toJSON() {
67
67
  return this.payload.body;
68
68
  }
69
69
  toResponse() {
70
- const { status, headers } = this;
71
- return Response.json(this.toJSON(), { status, headers });
70
+ // Re-expose schema-valid errors as-is to downstream clients
71
+ if (this.matchesSchema()) {
72
+ const status = this.response.status >= 500 ? 502 : this.response.status;
73
+ return Response.json(this.toJSON(), { status });
74
+ }
75
+ return this.response.status >= 500
76
+ ? // The upstream server had an error, return a generic upstream failure
77
+ Response.json({ error: 'UpstreamFailure' }, { status: 502 })
78
+ : // If the error is on our side, return a generic internal server error
79
+ Response.json({ error: 'InternalServerError' }, { status: 500 });
80
+ }
81
+ get body() {
82
+ return this.payload.body;
72
83
  }
73
84
  }
74
- exports.LexRpcResponseError = LexRpcResponseError;
85
+ exports.XrpcResponseError = XrpcResponseError;
86
+ class XrpcAuthenticationError extends XrpcResponseError {
87
+ name = 'XrpcAuthenticationError';
88
+ shouldRetry() {
89
+ return false;
90
+ }
91
+ #wwwAuthenticate;
92
+ get wwwAuthenticate() {
93
+ return (this.#wwwAuthenticate ??=
94
+ (0, www_authenticate_js_1.parseWWWAuthenticateHeader)(this.response.headers.get('www-authenticate')) ?? {});
95
+ }
96
+ }
97
+ exports.XrpcAuthenticationError = XrpcAuthenticationError;
75
98
  /**
76
- * This class represents an invalid XRPC response from the server.
99
+ * This class represents invalid or unprocessable XRPC response from the
100
+ * upstream server.
77
101
  */
78
- class LexRpcUpstreamError extends LexRpcError {
79
- name = 'LexRpcUpstreamError';
80
- // For debugging purposes, we keep the response details here
102
+ class XrpcUpstreamError extends XrpcError {
81
103
  response;
82
- constructor(error, message, response, payload, options) {
83
- super(error, message, { cause: options?.cause });
84
- this.response = {
85
- status: response.status,
86
- headers: response.headers,
87
- payload,
88
- };
104
+ payload;
105
+ name = 'XrpcUpstreamError';
106
+ constructor(method, response, payload, message = `Unexpected upstream XRPC response`, options) {
107
+ super(method, 'UpstreamFailure', message, options);
108
+ this.response = response;
109
+ this.payload = payload;
89
110
  }
90
- success = false;
91
111
  get reason() {
92
112
  return this;
93
113
  }
94
- matchesSchema() {
95
- return false;
96
- }
97
114
  shouldRetry() {
98
- // Do not retry client errors
99
- return this.response.status >= 500;
115
+ return exports.RETRYABLE_HTTP_STATUS_CODES.has(this.response.status);
100
116
  }
101
117
  toResponse() {
102
118
  return Response.json(this.toJSON(), { status: 502 });
103
119
  }
104
120
  }
105
- exports.LexRpcUpstreamError = LexRpcUpstreamError;
106
- class LexRpcUnexpectedError extends LexRpcError {
107
- name = 'LexRpcUnexpectedError';
108
- constructor(message, options) {
109
- super('InternalServerError', message, options);
121
+ exports.XrpcUpstreamError = XrpcUpstreamError;
122
+ class XrpcInternalError extends XrpcError {
123
+ name = 'XrpcInternalError';
124
+ constructor(method, message, options) {
125
+ super(method, 'InternalServerError', message ?? 'Unable to fulfill XRPC request', options);
110
126
  }
111
- success = false;
112
127
  get reason() {
113
- return this.cause;
114
- }
115
- matchesSchema() {
116
- return false;
128
+ return this;
117
129
  }
118
130
  shouldRetry() {
131
+ // Ideally, we would inspect the reason to determine if it's retryable
132
+ // (by detecting network errors, timeouts, etc.). Since these cases are
133
+ // highly platform-dependent, we optimistically assume all internal
134
+ // errors are retryable.
119
135
  return true;
120
136
  }
121
137
  toResponse() {
122
- return Response.json(this.toJSON(), { status: 500 });
138
+ // Do not expose internal error details to downstream clients
139
+ return Response.json({ error: this.error }, { status: 500 });
123
140
  }
124
- static from(cause, message = cause instanceof lex_data_1.LexError
125
- ? cause.message
126
- : 'XRPC request failed') {
127
- if (cause instanceof LexRpcUnexpectedError)
141
+ }
142
+ exports.XrpcInternalError = XrpcInternalError;
143
+ function asXrpcFailure(method, cause) {
144
+ if (cause instanceof XrpcResponseError ||
145
+ cause instanceof XrpcUpstreamError ||
146
+ cause instanceof XrpcInternalError) {
147
+ if (cause.method === method)
128
148
  return cause;
129
- return new LexRpcUnexpectedError(message, { cause });
130
149
  }
150
+ return new XrpcInternalError(method, undefined, { cause });
131
151
  }
132
- exports.LexRpcUnexpectedError = LexRpcUnexpectedError;
133
152
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAsCA,oDAQC;AA9CD,gDAAwE;AAI/D,yFAJA,mBAAQ,OAIA;AAHjB,oDAAuC;AAWvC,MAAa,WAEX,SAAQ,mBAAW;IACnB,IAAI,GAAG,aAAa,CAAA;IAEpB,YACE,KAAQ,EACR,UAAkB,GAAG,KAAK,oBAAoB,EAC9C,OAAsB;QAEtB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAChC,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KAAK,CAAA;IACd,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU;QACR,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACtD,CAAC;IAED,MAAM,CAAC,IAAI,CACT,KAAc,EACd,UAAkB,KAAK,YAAY,mBAAQ;QACzC,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,qBAAqB;QAEzB,IAAI,KAAK,YAAY,qBAAqB;YAAE,OAAO,KAAK,CAAA;QACxD,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;CACF;AArCD,sDAqCC","sourcesContent":["import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data'\nimport { l } from '@atproto/lex-schema'\nimport { Payload } from './util.js'\n\nexport { LexError }\nexport type { LexErrorCode, LexErrorData }\n\nexport type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<\n LexErrorData<N>,\n 'application/json'\n>\n\nexport class LexRpcError<\n N extends LexErrorCode = LexErrorCode,\n> extends LexError<N> {\n name = 'LexRpcError'\n\n constructor(\n error: N,\n message: string = `${error} Lexicon RPC error`,\n options?: ErrorOptions,\n ) {\n super(error, message, options)\n }\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 isLexRpcErrorPayload(\n payload: Payload | null,\n): payload is LexRpcErrorPayload {\n return (\n payload !== null &&\n payload.encoding === 'application/json' &&\n l.lexErrorData.matches(payload.body)\n )\n}\n\n/**\n * Interface representing a failed XRPC request result.\n */\ntype LexRpcFailureResult<N extends LexErrorCode, E> = l.ResultFailure<E> & {\n readonly error: N\n shouldRetry(): boolean\n matchesSchema(): boolean\n}\n\n/**\n * Class used to represent an HTTP request that resulted in an XRPC method error\n * That is, a non-2xx response with a valid XRPC error payload.\n */\nexport class LexRpcResponseError<\n M extends l.Procedure | l.Query = l.Procedure | l.Query,\n N extends LexErrorCode = LexErrorCode,\n >\n extends LexRpcError<N>\n implements LexRpcFailureResult<N, LexRpcResponseError<M, N>>\n{\n name = 'LexRpcResponseError'\n\n constructor(\n readonly method: M,\n readonly status: number,\n readonly headers: Headers,\n readonly payload: LexRpcErrorPayload<N>,\n options?: ErrorOptions,\n ) {\n const { error, message } = payload.body\n super(error, message, options)\n }\n\n readonly success = false\n\n get reason(): this {\n return this as this\n }\n\n get body(): LexErrorData {\n return this.payload.body\n }\n\n matchesSchema(): this is M extends {\n errors: readonly (infer E extends string)[]\n }\n ? LexRpcResponseError<M, E>\n : never {\n return this.method.errors?.includes(this.error) ?? false\n }\n\n shouldRetry(): boolean {\n // Do not retry client errors\n if (this.status < 500) return false\n\n return true\n }\n\n toJSON() {\n return this.payload.body\n }\n\n toResponse(): Response {\n const { status, headers } = this\n return Response.json(this.toJSON(), { status, headers })\n }\n}\n\n/**\n * This class represents an invalid XRPC response from the server.\n */\nexport class LexRpcUpstreamError<\n N extends 'InvalidResponse' | 'UpstreamFailure' =\n | 'InvalidResponse'\n | 'UpstreamFailure',\n >\n extends LexRpcError<N>\n implements LexRpcFailureResult<N, LexRpcUpstreamError<N>>\n{\n name = 'LexRpcUpstreamError' as const\n\n // For debugging purposes, we keep the response details here\n readonly response: {\n status: number\n headers: Headers\n payload: Payload | null\n }\n\n constructor(\n error: N,\n message: string,\n response: { status: number; headers: Headers },\n payload: Payload | null,\n options?: ErrorOptions,\n ) {\n super(error, message, { cause: options?.cause })\n this.response = {\n status: response.status,\n headers: response.headers,\n payload,\n }\n }\n\n readonly success = false as const\n\n get reason(): this {\n return this\n }\n\n matchesSchema(): false {\n return false\n }\n\n shouldRetry(): boolean {\n // Do not retry client errors\n return this.response.status >= 500\n }\n\n toResponse(): Response {\n return Response.json(this.toJSON(), { status: 502 })\n }\n}\n\nexport class LexRpcUnexpectedError\n extends LexRpcError<'InternalServerError'>\n implements LexRpcFailureResult<'InternalServerError', unknown>\n{\n name = 'LexRpcUnexpectedError' as const\n\n protected constructor(message: string, options: Required<ErrorOptions>) {\n super('InternalServerError', message, options)\n }\n\n readonly success = false\n\n get reason() {\n return this.cause\n }\n\n matchesSchema(): false {\n return false\n }\n\n shouldRetry(): boolean {\n return true\n }\n\n toResponse(): Response {\n return Response.json(this.toJSON(), { status: 500 })\n }\n\n static from(\n cause: unknown,\n message: string = cause instanceof LexError\n ? cause.message\n : 'XRPC request failed',\n ): LexRpcUnexpectedError {\n if (cause instanceof LexRpcUnexpectedError) return cause\n return new LexRpcUnexpectedError(message, { cause })\n }\n}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAoCA,gDAQC;AAwLD,sCAaC;AAjPD,gDAAwE;AAkB/D,yFAlBA,mBAAQ,OAkBA;AAjBjB,oDAM4B;AAE5B,+DAG8B;AAEjB,QAAA,2BAA2B,GAAwB,IAAI,GAAG,CAAC;IACtE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CAC5C,CAAC,CAAA;AAQF;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAChC,OAA2B;IAE3B,OAAO,CACL,OAAO,KAAK,IAAI;QAChB,OAAO,CAAC,QAAQ,KAAK,kBAAkB;QACvC,+BAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CACzC,CAAA;AACH,CAAC;AAED,MAAsB,SAKpB,SAAQ,mBAAW;IAMR;IAHX,IAAI,GAAG,WAAW,CAAA;IAElB,YACW,MAAS,EAClB,KAAQ,EACR,UAAkB,GAAG,KAAK,o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AI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC9D,CAAC;IAEQ,UAAU;QACjB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACtD,CAAC;CACF;AA1BD,8CA0BC;AAED,MAAa,iBAEX,SAAQ,SAAyD;IACjE,IAAI,GAAG,mBAAmB,CAAA;IAE1B,YAAY,MAAS,EAAE,OAAgB,EAAE,OAAsB;QAC7D,KAAK,CACH,MAAM,EACN,qBAAqB,EACrB,OAAO,IAAI,gCAAgC,EAC3C,OAAO,CACR,CAAA;IACH,CAAC;IAED,IAAa,MAAM;QACjB,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,WAAW;QAClB,sEAAsE;QACtE,uEAAuE;QACvE,mEAAmE;QACnE,wBAAwB;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;IAEQ,UAAU;QACjB,6DAA6D;QAC7D,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IAC9D,CAAC;CACF;AA9BD,8CA8BC;AAUD,SAAgB,aAAa,CAC3B,MAAS,EACT,KAAc;IAEd,IACE,KAAK,YAAY,iBAAiB;QAClC,KAAK,YAAY,iBAAiB;QAClC,KAAK,YAAY,iBAAiB,EAClC,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAA;IAC3C,CAAC;IAED,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AAC5D,CAAC","sourcesContent":["import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data'\nimport {\n InferMethodError,\n Procedure,\n Query,\n ResultFailure,\n lexErrorDataSchema,\n} from '@atproto/lex-schema'\nimport { XrpcPayload } from './util.js'\nimport {\n WWWAuthenticate,\n parseWWWAuthenticateHeader,\n} from './www-authenticate.js'\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\nexport type XrpcErrorPayload<N extends LexErrorCode = LexErrorCode> =\n XrpcPayload<LexErrorData<N>, 'application/json'>\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: XrpcPayload | null,\n): payload is XrpcErrorPayload {\n return (\n payload !== null &&\n payload.encoding === 'application/json' &&\n lexErrorDataSchema.matches(payload.body)\n )\n}\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 matchesSchema(): this is XrpcError<M, InferMethodError<M>> {\n return this.method.errors?.includes(this.error) ?? false\n }\n}\n\n/**\n * Class used to represent an HTTP request that resulted in an XRPC method\n * error. That is, a non-2xx response with a valid XRPC error payload.\n */\nexport class XrpcResponseError<\n M extends Procedure | Query = Procedure | Query,\n N extends LexErrorCode = InferMethodError<M> | LexErrorCode,\n> extends XrpcError<M, N, XrpcResponseError<M, N>> {\n name = 'XrpcResponseError'\n\n constructor(\n method: M,\n readonly response: Response,\n readonly payload: XrpcErrorPayload<N>,\n options?: ErrorOptions,\n ) {\n const { error, message } = payload.body\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() {\n return this.payload.body\n }\n\n override toResponse(): Response {\n // Re-expose schema-valid errors as-is to downstream clients\n if (this.matchesSchema()) {\n const status = this.response.status >= 500 ? 502 : this.response.status\n return Response.json(this.toJSON(), { status })\n }\n\n return this.response.status >= 500\n ? // The upstream server had an error, return a generic upstream failure\n Response.json({ error: 'UpstreamFailure' }, { status: 502 })\n : // If the error is on our side, return a generic internal server error\n Response.json({ error: 'InternalServerError' }, { status: 500 })\n }\n\n get body(): LexErrorData {\n return this.payload.body\n }\n}\n\nexport type { WWWAuthenticate }\nexport class XrpcAuthenticationError<\n M extends Procedure | Query = Procedure | Query,\n N extends LexErrorCode = LexErrorCode,\n> extends XrpcResponseError<M, N> {\n name = 'XrpcAuthenticationError'\n\n override shouldRetry(): boolean {\n return false\n }\n\n #wwwAuthenticate?: WWWAuthenticate\n get wwwAuthenticate(): WWWAuthenticate {\n return (this.#wwwAuthenticate ??=\n parseWWWAuthenticateHeader(\n this.response.headers.get('www-authenticate'),\n ) ?? {})\n }\n}\n\n/**\n * This class represents invalid or unprocessable XRPC response from the\n * upstream server.\n */\nexport class XrpcUpstreamError<\n M extends Procedure | Query = Procedure | Query,\n> extends XrpcError<M, 'UpstreamFailure', XrpcUpstreamError<M>> {\n name = 'XrpcUpstreamError'\n\n constructor(\n method: M,\n readonly response: Response,\n readonly payload: XrpcPayload | null,\n message: string = `Unexpected upstream XRPC response`,\n options?: ErrorOptions,\n ) {\n super(method, 'UpstreamFailure', 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 toResponse(): Response {\n return Response.json(this.toJSON(), { status: 502 })\n }\n}\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(): true {\n // Ideally, we would inspect the reason to determine if it's retryable\n // (by detecting network errors, timeouts, etc.). Since these cases are\n // highly platform-dependent, we optimistically assume all internal\n // errors are retryable.\n return true\n }\n\n override toResponse(): Response {\n // Do not expose internal error details to downstream clients\n return Response.json({ error: this.error }, { status: 500 })\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 | XrpcUpstreamError<M>\n // Something went wrong (network error, etc.)\n | XrpcInternalError<M>\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 XrpcUpstreamError ||\n cause instanceof XrpcInternalError\n ) {\n if (cause.method === method) return cause\n }\n\n return new XrpcInternalError(method, undefined, { cause })\n}\n"]}
@@ -10,10 +10,15 @@ declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<
10
10
  readonly collection: l.StringSchema<{
11
11
  readonly format: "nsid";
12
12
  }>;
13
- readonly rkey: l.OptionalSchema<string>;
14
- readonly validate: l.OptionalSchema<boolean>;
13
+ readonly rkey: l.OptionalSchema<l.StringSchema<{
14
+ readonly format: "record-key";
15
+ readonly maxLength: 512;
16
+ }>>;
17
+ readonly validate: l.OptionalSchema<l.BooleanSchema>;
15
18
  readonly record: l.UnknownObjectSchema;
16
- readonly swapCommit: l.OptionalSchema<string>;
19
+ readonly swapCommit: l.OptionalSchema<l.StringSchema<{
20
+ readonly format: "cid";
21
+ }>>;
17
22
  }>>, l.Payload<"application/json", l.ObjectSchema<{
18
23
  readonly uri: l.StringSchema<{
19
24
  readonly format: "at-uri";
@@ -21,8 +26,8 @@ declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<
21
26
  readonly cid: l.StringSchema<{
22
27
  readonly format: "cid";
23
28
  }>;
24
- readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
25
- readonly validationStatus: l.OptionalSchema<string>;
29
+ readonly commit: l.OptionalSchema<l.RefSchema<l.Validator<RepoDefs.CommitMeta, RepoDefs.CommitMeta>>>;
30
+ readonly validationStatus: l.OptionalSchema<l.StringSchema<{}>>;
26
31
  }>>, readonly ["InvalidSwap"]>;
27
32
  export { main };
28
33
  export type Params = l.InferMethodParams<typeof main>;
@@ -37,10 +42,15 @@ export declare const $lxm: "com.atproto.repo.createRecord", $params: l.ParamsSch
37
42
  readonly collection: l.StringSchema<{
38
43
  readonly format: "nsid";
39
44
  }>;
40
- readonly rkey: l.OptionalSchema<string>;
41
- readonly validate: l.OptionalSchema<boolean>;
45
+ readonly rkey: l.OptionalSchema<l.StringSchema<{
46
+ readonly format: "record-key";
47
+ readonly maxLength: 512;
48
+ }>>;
49
+ readonly validate: l.OptionalSchema<l.BooleanSchema>;
42
50
  readonly record: l.UnknownObjectSchema;
43
- readonly swapCommit: l.OptionalSchema<string>;
51
+ readonly swapCommit: l.OptionalSchema<l.StringSchema<{
52
+ readonly format: "cid";
53
+ }>>;
44
54
  }>>, $output: l.Payload<"application/json", l.ObjectSchema<{
45
55
  readonly uri: l.StringSchema<{
46
56
  readonly format: "at-uri";
@@ -48,7 +58,7 @@ export declare const $lxm: "com.atproto.repo.createRecord", $params: l.ParamsSch
48
58
  readonly cid: l.StringSchema<{
49
59
  readonly format: "cid";
50
60
  }>;
51
- readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
52
- readonly validationStatus: l.OptionalSchema<string>;
61
+ readonly commit: l.OptionalSchema<l.RefSchema<l.Validator<RepoDefs.CommitMeta, RepoDefs.CommitMeta>>>;
62
+ readonly validationStatus: l.OptionalSchema<l.StringSchema<{}>>;
53
63
  }>>;
54
64
  //# sourceMappingURL=createRecord.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,gFAAgF;AAChF,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;8BA4BP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,iCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;GAA4B,CAAA"}
1
+ {"version":3,"file":"createRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,gFAAgF;AAChF,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;8BA4BP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,iCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;GAA4B,CAAA"}
@@ -7,6 +7,6 @@ type CommitMeta = {
7
7
  rev: l.TidString;
8
8
  };
9
9
  export type { CommitMeta };
10
- declare const commitMeta: l.TypedObjectSchema<"com.atproto.repo.defs#commitMeta", l.Validator<Omit<CommitMeta, "$type">>>;
10
+ declare const commitMeta: l.TypedObjectSchema<"com.atproto.repo.defs#commitMeta", l.Validator<CommitMeta, CommitMeta>>;
11
11
  export { commitMeta };
12
12
  //# sourceMappingURL=defs.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,0BAA0B,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,kCAAkC,CAAA;IAC1C,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;IAChB,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;CACjB,CAAA;AAED,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B,QAAA,MAAM,UAAU,iGAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"defs.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,0BAA0B,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,kCAAkC,CAAA;IAC1C,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;IAChB,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;CACjB,CAAA;AAED,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B,QAAA,MAAM,UAAU,8FAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -13,10 +13,14 @@ declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<
13
13
  readonly rkey: l.StringSchema<{
14
14
  readonly format: "record-key";
15
15
  }>;
16
- readonly swapRecord: l.OptionalSchema<string>;
17
- readonly swapCommit: l.OptionalSchema<string>;
16
+ readonly swapRecord: l.OptionalSchema<l.StringSchema<{
17
+ readonly format: "cid";
18
+ }>>;
19
+ readonly swapCommit: l.OptionalSchema<l.StringSchema<{
20
+ readonly format: "cid";
21
+ }>>;
18
22
  }>>, l.Payload<"application/json", l.ObjectSchema<{
19
- readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
23
+ readonly commit: l.OptionalSchema<l.RefSchema<l.Validator<RepoDefs.CommitMeta, RepoDefs.CommitMeta>>>;
20
24
  }>>, readonly ["InvalidSwap"]>;
21
25
  export { main };
22
26
  export type Params = l.InferMethodParams<typeof main>;
@@ -34,9 +38,13 @@ export declare const $lxm: "com.atproto.repo.deleteRecord", $params: l.ParamsSch
34
38
  readonly rkey: l.StringSchema<{
35
39
  readonly format: "record-key";
36
40
  }>;
37
- readonly swapRecord: l.OptionalSchema<string>;
38
- readonly swapCommit: l.OptionalSchema<string>;
41
+ readonly swapRecord: l.OptionalSchema<l.StringSchema<{
42
+ readonly format: "cid";
43
+ }>>;
44
+ readonly swapCommit: l.OptionalSchema<l.StringSchema<{
45
+ readonly format: "cid";
46
+ }>>;
39
47
  }>>, $output: l.Payload<"application/json", l.ObjectSchema<{
40
- readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
48
+ readonly commit: l.OptionalSchema<l.RefSchema<l.Validator<RepoDefs.CommitMeta, RepoDefs.CommitMeta>>>;
41
49
  }>>;
42
50
  //# sourceMappingURL=deleteRecord.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,iGAAiG;AACjG,QAAA,MAAM,IAAI;;;;;;;;;;;;;;8BAwBP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAA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;;;;;;;;;;;;;;;GAA2B,EACjC,OAAO;;GAA4B,CAAA"}
@@ -12,12 +12,16 @@ declare const main: l.Query<"com.atproto.repo.getRecord", l.ParamsSchema<{
12
12
  readonly rkey: l.StringSchema<{
13
13
  readonly format: "record-key";
14
14
  }>;
15
- readonly cid: l.OptionalSchema<string>;
15
+ readonly cid: l.OptionalSchema<l.StringSchema<{
16
+ readonly format: "cid";
17
+ }>>;
16
18
  }>, l.Payload<"application/json", l.ObjectSchema<{
17
19
  readonly uri: l.StringSchema<{
18
20
  readonly format: "at-uri";
19
21
  }>;
20
- readonly cid: l.OptionalSchema<string>;
22
+ readonly cid: l.OptionalSchema<l.StringSchema<{
23
+ readonly format: "cid";
24
+ }>>;
21
25
  readonly value: l.UnknownObjectSchema;
22
26
  }>>, readonly ["RecordNotFound"]>;
23
27
  export { main };
@@ -34,12 +38,16 @@ export declare const $lxm: "com.atproto.repo.getRecord", $params: l.ParamsSchema
34
38
  readonly rkey: l.StringSchema<{
35
39
  readonly format: "record-key";
36
40
  }>;
37
- readonly cid: l.OptionalSchema<string>;
41
+ readonly cid: l.OptionalSchema<l.StringSchema<{
42
+ readonly format: "cid";
43
+ }>>;
38
44
  }>, $output: l.Payload<"application/json", l.ObjectSchema<{
39
45
  readonly uri: l.StringSchema<{
40
46
  readonly format: "at-uri";
41
47
  }>;
42
- readonly cid: l.OptionalSchema<string>;
48
+ readonly cid: l.OptionalSchema<l.StringSchema<{
49
+ readonly format: "cid";
50
+ }>>;
43
51
  readonly value: l.UnknownObjectSchema;
44
52
  }>>;
45
53
  //# sourceMappingURL=getRecord.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/getRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,+BAA+B,CAAA;AAE1C,OAAO,EAAE,KAAK,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