@atproto/lex-client 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/client.d.ts +24 -21
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +14 -7
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +22 -22
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +62 -37
- package/dist/errors.js.map +1 -1
- package/dist/response.d.ts +66 -7
- package/dist/response.d.ts.map +1 -1
- package/dist/response.js +90 -69
- package/dist/response.js.map +1 -1
- package/dist/types.d.ts +8 -37
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +14 -27
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +15 -6
- package/dist/util.js.map +1 -1
- package/dist/xrpc.d.ts +40 -15
- package/dist/xrpc.d.ts.map +1 -1
- package/dist/xrpc.js +4 -2
- package/dist/xrpc.js.map +1 -1
- package/package.json +6 -6
- package/src/client.ts +83 -31
- package/src/errors.test.ts +243 -32
- package/src/errors.ts +91 -52
- package/src/response.ts +229 -102
- package/src/types.ts +17 -40
- package/src/util.test.ts +11 -11
- package/src/util.ts +33 -36
- package/src/xrpc.test.ts +691 -142
- package/src/xrpc.ts +73 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atproto/lex-client
|
|
2
2
|
|
|
3
|
+
## 0.0.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4779](https://github.com/bluesky-social/atproto/pull/4779) [`527f5d4`](https://github.com/bluesky-social/atproto/commit/527f5d4c5d0c9264c2ff6f23ad06a41163fc6809) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Improve handling of XRPC response errors by always using `XrpcResponseError` errors when upstream server responds with an error status code. Before, `XrpcResponseError` would only be used if the upstream server responded with a valid XRPC payload (json with `error` field). Any other response payload (e.g. non-json, invalid "error" payload) would be treated as the upstream server not being able to output a valid XRPC response, and would throw `XrpcUpstreamError` instead. This change allows to better reflect upstream server errors to downstream services (eg. return a 429 if the upstream server responds with a 429 status code, instead of a 502, even if the response payload is not a valid XRPC error payload).
|
|
8
|
+
|
|
9
|
+
`XrpcUpstreamError` was removed and replaced with `XrpcInvalidResponseError` to better reflect the intent to those errors (invalid status code, non-json, or invalid payload). `XrpcResponseValidationError` is a special case of `XrpcInvalidResponseError` that is thrown when the response does not conform to the expected XRPC output schema.
|
|
10
|
+
|
|
11
|
+
- [#4788](https://github.com/bluesky-social/atproto/pull/4788) [`a99dd58`](https://github.com/bluesky-social/atproto/commit/a99dd58b5fe1995e571cf5e7b0105355583efa93) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow XRPC endpoints with no `output` specified in their schema to output anything.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`527f5d4`](https://github.com/bluesky-social/atproto/commit/527f5d4c5d0c9264c2ff6f23ad06a41163fc6809), [`c4df84c`](https://github.com/bluesky-social/atproto/commit/c4df84cd78df68ee8cb7289e7b61b3a032ad484e), [`527f5d4`](https://github.com/bluesky-social/atproto/commit/527f5d4c5d0c9264c2ff6f23ad06a41163fc6809), [`e5e5bcf`](https://github.com/bluesky-social/atproto/commit/e5e5bcf85fbc0d418f05724d684e7265be6a0be9), [`ac6bd18`](https://github.com/bluesky-social/atproto/commit/ac6bd18f1dc3397dd29008eff2a1e40702a4e138), [`c5c6c7d`](https://github.com/bluesky-social/atproto/commit/c5c6c7dac3b08e5f63cc918f57705573028ad797)]:
|
|
14
|
+
- @atproto/lex-schema@0.0.17
|
|
15
|
+
|
|
16
|
+
## 0.0.17
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#4761](https://github.com/bluesky-social/atproto/pull/4761) [`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix `XrpcResponse.payload` to be typed as the schema's parse "Output"
|
|
21
|
+
|
|
22
|
+
- [#4761](https://github.com/bluesky-social/atproto/pull/4761) [`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow defining request and response processing defaults on the `Client` instance
|
|
23
|
+
|
|
24
|
+
- [#4773](https://github.com/bluesky-social/atproto/pull/4773) [`df8328c`](https://github.com/bluesky-social/atproto/commit/df8328c3c2f211fe16ccf58fa9f3968465cbf2b0) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Rename `XrpcParamsOptions` as `XrpcRequestParamsOptions`
|
|
25
|
+
|
|
26
|
+
- [#4761](https://github.com/bluesky-social/atproto/pull/4761) [`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add ability to process invalid Lexicon Data responses (instead of rejecting them as invalid)
|
|
27
|
+
|
|
28
|
+
- [#4761](https://github.com/bluesky-social/atproto/pull/4761) [`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow using a dynamic non-strict validation mode
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786), [`6a88461`](https://github.com/bluesky-social/atproto/commit/6a88461c5aa9486269f0769b7a3d52f384581786)]:
|
|
31
|
+
- @atproto/lex-schema@0.0.16
|
|
32
|
+
- @atproto/lex-data@0.0.14
|
|
33
|
+
- @atproto/lex-json@0.0.14
|
|
34
|
+
|
|
3
35
|
## 0.0.16
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { AtIdentifierString, CidString, DidString, Infer, InferMethodInputBody,
|
|
|
3
3
|
import { Agent, AgentOptions } from './agent.js';
|
|
4
4
|
import { XrpcFailure } from './errors.js';
|
|
5
5
|
import { com } from './lexicons/index.js';
|
|
6
|
-
import { XrpcResponse, XrpcResponseBody } from './response.js';
|
|
7
|
-
import { BinaryBodyInit,
|
|
8
|
-
import {
|
|
6
|
+
import { XrpcResponse, XrpcResponseBody, XrpcResponseOptions } from './response.js';
|
|
7
|
+
import { BinaryBodyInit, Service } from './types.js';
|
|
8
|
+
import { XrpcRequestHeadersOptions } from './util.js';
|
|
9
|
+
import { XrpcOptions, XrpcRequestParams, XrpcRequestProcessingOptions } from './xrpc.js';
|
|
9
10
|
export type { AtIdentifierString, CidString, DidString, Infer, InferMethodInputBody, InferMethodOutputBody, InferRecordKey, LexMap, LexValue, LexiconRecordKey, Main, NsidString, Params, Procedure, Query, RecordSchema, Restricted, TypedLexMap, };
|
|
10
11
|
/**
|
|
11
12
|
* Configuration options for creating a {@link Client}.
|
|
@@ -19,13 +20,10 @@ export type { AtIdentifierString, CidString, DidString, Infer, InferMethodInputB
|
|
|
19
20
|
* }
|
|
20
21
|
* ```
|
|
21
22
|
*/
|
|
22
|
-
export type ClientOptions =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
headers?: HeadersInit;
|
|
27
|
-
/** Service proxy identifier for routing requests through a specific service. */
|
|
28
|
-
service?: Service;
|
|
23
|
+
export type ClientOptions = XrpcRequestHeadersOptions & Pick<XrpcRequestProcessingOptions, 'validateRequest'> & XrpcResponseOptions;
|
|
24
|
+
export type ActionOptions = {
|
|
25
|
+
/** AbortSignal to cancel the request. */
|
|
26
|
+
signal?: AbortSignal;
|
|
29
27
|
};
|
|
30
28
|
/**
|
|
31
29
|
* A composable action that can be invoked via {@link Client.call}.
|
|
@@ -44,7 +42,7 @@ export type ClientOptions = {
|
|
|
44
42
|
* }
|
|
45
43
|
* ```
|
|
46
44
|
*/
|
|
47
|
-
export type Action<I = any, O = any> = (client: Client, input: I, options:
|
|
45
|
+
export type Action<I = any, O = any> = (client: Client, input: I, options: ActionOptions) => O | Promise<O>;
|
|
48
46
|
/**
|
|
49
47
|
* Extracts the input type from an {@link Action}.
|
|
50
48
|
* @typeParam A - The Action type to extract from
|
|
@@ -60,7 +58,7 @@ export type InferActionOutput<A extends Action> = A extends Action<any, infer O>
|
|
|
60
58
|
*
|
|
61
59
|
* @see {@link Client.createRecord}
|
|
62
60
|
*/
|
|
63
|
-
export type CreateRecordOptions =
|
|
61
|
+
export type CreateRecordOptions = Omit<XrpcOptions<typeof com.atproto.repo.createRecord.main>, 'body'> & {
|
|
64
62
|
/** Repository identifier (DID or handle). Defaults to authenticated user's DID. */
|
|
65
63
|
repo?: AtIdentifierString;
|
|
66
64
|
/** Compare-and-swap on the repo commit. If specified, must match current commit. */
|
|
@@ -73,7 +71,7 @@ export type CreateRecordOptions = CallOptions & {
|
|
|
73
71
|
*
|
|
74
72
|
* @see {@link Client.deleteRecord}
|
|
75
73
|
*/
|
|
76
|
-
export type DeleteRecordOptions =
|
|
74
|
+
export type DeleteRecordOptions = Omit<XrpcOptions<typeof com.atproto.repo.deleteRecord.main>, 'params'> & {
|
|
77
75
|
/** Repository identifier (DID or handle). Defaults to authenticated user's DID. */
|
|
78
76
|
repo?: AtIdentifierString;
|
|
79
77
|
/** Compare-and-swap on the repo commit. If specified, must match current commit. */
|
|
@@ -86,7 +84,7 @@ export type DeleteRecordOptions = CallOptions & {
|
|
|
86
84
|
*
|
|
87
85
|
* @see {@link Client.getRecord}
|
|
88
86
|
*/
|
|
89
|
-
export type GetRecordOptions =
|
|
87
|
+
export type GetRecordOptions = Omit<XrpcOptions<typeof com.atproto.repo.getRecord.main>, 'params'> & {
|
|
90
88
|
/** Repository identifier (DID or handle). Defaults to authenticated user's DID. */
|
|
91
89
|
repo?: AtIdentifierString;
|
|
92
90
|
};
|
|
@@ -95,7 +93,7 @@ export type GetRecordOptions = CallOptions & {
|
|
|
95
93
|
*
|
|
96
94
|
* @see {@link Client.putRecord}
|
|
97
95
|
*/
|
|
98
|
-
export type PutRecordOptions =
|
|
96
|
+
export type PutRecordOptions = Omit<XrpcOptions<typeof com.atproto.repo.putRecord.main>, 'body'> & {
|
|
99
97
|
/** Repository identifier (DID or handle). Defaults to authenticated user's DID. */
|
|
100
98
|
repo?: AtIdentifierString;
|
|
101
99
|
/** Compare-and-swap on the repo commit. If specified, must match current commit. */
|
|
@@ -110,7 +108,7 @@ export type PutRecordOptions = CallOptions & {
|
|
|
110
108
|
*
|
|
111
109
|
* @see {@link Client.listRecords}
|
|
112
110
|
*/
|
|
113
|
-
export type ListRecordsOptions =
|
|
111
|
+
export type ListRecordsOptions = Omit<XrpcOptions<typeof com.atproto.repo.listRecords.main>, 'params'> & {
|
|
114
112
|
/** Repository identifier (DID or handle). Defaults to authenticated user's DID. */
|
|
115
113
|
repo?: AtIdentifierString;
|
|
116
114
|
/** Maximum number of records to return. */
|
|
@@ -120,6 +118,8 @@ export type ListRecordsOptions = CallOptions & {
|
|
|
120
118
|
/** If true, returns records in reverse chronological order. */
|
|
121
119
|
reverse?: boolean;
|
|
122
120
|
};
|
|
121
|
+
export type UploadBlobOptions = Omit<XrpcOptions<typeof com.atproto.repo.uploadBlob.main>, 'body'>;
|
|
122
|
+
export type GetBlobOptions = Omit<XrpcOptions<typeof com.atproto.sync.getBlob.main>, 'params'>;
|
|
123
123
|
export type RecordKeyOptions<T extends RecordSchema, AlsoOptionalWhenRecordKeyIs extends LexiconRecordKey = never> = T['key'] extends `literal:${string}` | AlsoOptionalWhenRecordKeyIs ? {
|
|
124
124
|
rkey?: InferRecordKey<T>;
|
|
125
125
|
} : {
|
|
@@ -221,6 +221,11 @@ export declare class Client implements Agent {
|
|
|
221
221
|
readonly service?: Service;
|
|
222
222
|
/** Set of labeler DIDs specific to this client instance. */
|
|
223
223
|
readonly labelers: Set<DidString>;
|
|
224
|
+
readonly xrpcDefaults: {
|
|
225
|
+
readonly validateRequest: boolean;
|
|
226
|
+
readonly validateResponse: boolean;
|
|
227
|
+
readonly strictResponseProcessing: boolean;
|
|
228
|
+
};
|
|
224
229
|
constructor(agent: Agent | AgentOptions, options?: ClientOptions);
|
|
225
230
|
/**
|
|
226
231
|
* The DID of the authenticated user, or `undefined` if not authenticated.
|
|
@@ -512,9 +517,7 @@ export declare class Client implements Agent {
|
|
|
512
517
|
* console.log(response.body.blob) // Use this ref in records
|
|
513
518
|
* ```
|
|
514
519
|
*/
|
|
515
|
-
uploadBlob(body: BinaryBodyInit, options?:
|
|
516
|
-
encoding?: `${string}/${string}`;
|
|
517
|
-
}): Promise<XrpcResponse<Procedure<"com.atproto.repo.uploadBlob", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"*/*", undefined>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
520
|
+
uploadBlob(body: BinaryBodyInit, options?: UploadBlobOptions): Promise<XrpcResponse<Procedure<"com.atproto.repo.uploadBlob", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"*/*", undefined>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
518
521
|
blob: import("@atproto/lex-schema").BlobSchema<{
|
|
519
522
|
allowLegacy: false;
|
|
520
523
|
}>;
|
|
@@ -526,7 +529,7 @@ export declare class Client implements Agent {
|
|
|
526
529
|
* @param cid - The CID of the blob
|
|
527
530
|
* @param options - Call options
|
|
528
531
|
*/
|
|
529
|
-
getBlob(did: DidString, cid: CidString, options?:
|
|
532
|
+
getBlob(did: DidString, cid: CidString, options?: GetBlobOptions): Promise<XrpcResponse<Query<"com.atproto.sync.getBlob", import("@atproto/lex-schema").ParamsSchema<{
|
|
530
533
|
readonly did: import("@atproto/lex-schema").StringSchema<{
|
|
531
534
|
readonly format: "did";
|
|
532
535
|
}>;
|
|
@@ -563,7 +566,7 @@ export declare class Client implements Agent {
|
|
|
563
566
|
call<const T extends Query>(ns: NonNullable<unknown> extends XrpcRequestParams<T> ? Main<T> : Restricted<'This query type requires a "params" argument'>): Promise<XrpcResponseBody<T>>;
|
|
564
567
|
call<const T extends Procedure>(ns: undefined extends InferMethodInputBody<T, Uint8Array> ? Main<T> : Restricted<'This procedure type requires an "input" argument'>): Promise<XrpcResponseBody<T>>;
|
|
565
568
|
call<const T extends Action>(ns: void extends InferActionInput<T> ? Main<T> : Restricted<'This action type requires an "input" argument'>): Promise<InferActionOutput<T>>;
|
|
566
|
-
call<const T extends Action | Procedure | Query>(ns: Main<T>, arg: T extends Action ? InferActionInput<T> : T extends Procedure ? InferMethodInputBody<T, Uint8Array> : T extends Query ? XrpcRequestParams<T> : never, options?:
|
|
569
|
+
call<const T extends Action | Procedure | Query>(ns: Main<T>, arg: T extends Action ? InferActionInput<T> : T extends Procedure ? InferMethodInputBody<T, Uint8Array> : T extends Query ? XrpcRequestParams<T> : never, options?: T extends Action ? ActionOptions : T extends Procedure ? Omit<XrpcOptions<T>, 'body'> : T extends Query ? Omit<XrpcOptions<T>, 'params'> : never): Promise<T extends Action ? InferActionOutput<T> : T extends Procedure ? XrpcResponseBody<T> : T extends Query ? XrpcResponseBody<T> : never>;
|
|
567
570
|
/**
|
|
568
571
|
* Creates a new record with full type safety based on the schema.
|
|
569
572
|
*
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,KAAK,EACL,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,YAAY,EACZ,UAAU,EAEX,MAAM,qBAAqB,CAAA;AAC5B,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C,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAkB1B"}
|
package/dist/client.js
CHANGED
|
@@ -39,11 +39,17 @@ class Client {
|
|
|
39
39
|
service;
|
|
40
40
|
/** Set of labeler DIDs specific to this client instance. */
|
|
41
41
|
labelers;
|
|
42
|
+
xrpcDefaults;
|
|
42
43
|
constructor(agent, options = {}) {
|
|
43
44
|
this.agent = (0, agent_js_1.buildAgent)(agent);
|
|
44
45
|
this.service = options.service;
|
|
45
46
|
this.labelers = new Set(options.labelers);
|
|
46
47
|
this.headers = new Headers(options.headers);
|
|
48
|
+
this.xrpcDefaults = Object.freeze({
|
|
49
|
+
validateRequest: options.validateRequest ?? false,
|
|
50
|
+
validateResponse: options.validateResponse ?? true,
|
|
51
|
+
strictResponseProcessing: options.strictResponseProcessing ?? true,
|
|
52
|
+
});
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
49
55
|
* The DID of the authenticated user, or `undefined` if not authenticated.
|
|
@@ -108,7 +114,7 @@ class Client {
|
|
|
108
114
|
* @param init - Request initialization options
|
|
109
115
|
*/
|
|
110
116
|
fetchHandler(path, init) {
|
|
111
|
-
const headers = (0, util_js_1.
|
|
117
|
+
const headers = (0, util_js_1.buildXrpcRequestHeaders)({
|
|
112
118
|
headers: init.headers,
|
|
113
119
|
service: this.service,
|
|
114
120
|
labelers: [
|
|
@@ -125,10 +131,10 @@ class Client {
|
|
|
125
131
|
return this.agent.fetchHandler(path, { ...init, headers });
|
|
126
132
|
}
|
|
127
133
|
async xrpc(ns, options = {}) {
|
|
128
|
-
return (0, xrpc_js_1.xrpc)(this, ns, options);
|
|
134
|
+
return (0, xrpc_js_1.xrpc)(this, ns, (0, util_js_1.applyDefaults)(options, this.xrpcDefaults));
|
|
129
135
|
}
|
|
130
136
|
async xrpcSafe(ns, options = {}) {
|
|
131
|
-
return (0, xrpc_js_1.xrpcSafe)(this, ns, options);
|
|
137
|
+
return (0, xrpc_js_1.xrpcSafe)(this, ns, (0, util_js_1.applyDefaults)(options, this.xrpcDefaults));
|
|
132
138
|
}
|
|
133
139
|
/**
|
|
134
140
|
* Creates a new record in an AT Protocol repository.
|
|
@@ -263,10 +269,7 @@ class Client {
|
|
|
263
269
|
* ```
|
|
264
270
|
*/
|
|
265
271
|
async uploadBlob(body, options) {
|
|
266
|
-
return this.xrpc(index_js_1.com.atproto.repo.uploadBlob.main, {
|
|
267
|
-
...options,
|
|
268
|
-
body,
|
|
269
|
-
});
|
|
272
|
+
return this.xrpc(index_js_1.com.atproto.repo.uploadBlob.main, { ...options, body });
|
|
270
273
|
}
|
|
271
274
|
/**
|
|
272
275
|
* Retrieves a blob by DID and CID.
|
|
@@ -301,6 +304,8 @@ class Client {
|
|
|
301
304
|
async create(ns, input, options = {}) {
|
|
302
305
|
const schema = (0, lex_schema_1.getMain)(ns);
|
|
303
306
|
const record = schema.build(input);
|
|
307
|
+
if (options?.validateRequest)
|
|
308
|
+
schema.validate(record);
|
|
304
309
|
const rkey = options.rkey ?? getDefaultRecordKey(schema);
|
|
305
310
|
if (rkey !== undefined)
|
|
306
311
|
schema.keySchema.assert(rkey);
|
|
@@ -323,6 +328,8 @@ class Client {
|
|
|
323
328
|
async put(ns, input, options = {}) {
|
|
324
329
|
const schema = (0, lex_schema_1.getMain)(ns);
|
|
325
330
|
const record = schema.build(input);
|
|
331
|
+
if (options?.validateRequest)
|
|
332
|
+
schema.validate(record);
|
|
326
333
|
const rkey = options.rkey ?? getLiteralRecordKey(schema);
|
|
327
334
|
const response = await this.putRecord(record, rkey, options);
|
|
328
335
|
return response.body;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,oDAiB4B;AAC5B,yCAA4D;AAE5D,kDAAyC;AAGzC,uCAA+C;AAC/C,uCAA0E;AA8P1E;;;;;;;;;;;;;;;GAeG;AACH,M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AA;IAC1C,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;IAE1C,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAS;IAET,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAsB,CAAA;IACjD,CAAC;IAED,MAAM,IAAI,SAAS,CACjB,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexMap, LexValue, TypedLexMap } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferRecordKey,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n getMain,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport { XrpcFailure } from './errors.js'\nimport { com } from './lexicons/index.js'\nimport { XrpcResponse, XrpcResponseBody } from './response.js'\nimport { BinaryBodyInit, CallOptions, Service } from './types.js'\nimport { buildAtprotoHeaders } from './util.js'\nimport { XrpcOptions, XrpcRequestParams, xrpc, xrpcSafe } from './xrpc.js'\n\nexport type {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferRecordKey,\n LexMap,\n LexValue,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n TypedLexMap,\n}\n\n/**\n * Configuration options for creating a {@link Client}.\n *\n * @example\n * ```typescript\n * const options: ClientOptions = {\n * labelers: ['did:plc:labeler1'],\n * service: 'did:web:api.bsky.app#bsky_appview',\n * headers: { 'X-Custom-Header': 'value' }\n * }\n * ```\n */\nexport type ClientOptions = {\n /** Labeler DIDs to include in requests for content moderation. */\n labelers?: Iterable<DidString>\n /** Custom headers to include in all requests made by this client. */\n headers?: HeadersInit\n /** Service proxy identifier for routing requests through a specific service. */\n service?: Service\n}\n\n/**\n * A composable action that can be invoked via {@link Client.call}.\n *\n * Actions provide a way to define custom operations that integrate with the\n * Client's call interface, enabling type-safe, reusable business logic.\n *\n * @typeParam I - The input type for the action\n * @typeParam O - The output type for the action\n *\n * @example\n * ```typescript\n * const myAction: Action<{ userId: string }, { profile: Profile }> = async (client, input, options) => {\n * const response = await client.xrpc(someMethod, { params: { actor: input.userId }, ...options })\n * return { profile: response.body }\n * }\n * ```\n */\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: CallOptions,\n) => O | Promise<O>\n\n/**\n * Extracts the input type from an {@link Action}.\n * @typeParam A - The Action type to extract from\n */\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\n\n/**\n * Extracts the output type from an {@link Action}.\n * @typeParam A - The Action type to extract from\n */\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\n/**\n * Options for creating a record in an AT Protocol repository.\n *\n * @see {@link Client.createRecord}\n */\nexport type CreateRecordOptions = CallOptions & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Whether to validate the record against its lexicon schema. */\n validate?: boolean\n}\n\n/**\n * Options for deleting a record from an AT Protocol repository.\n *\n * @see {@link Client.deleteRecord}\n */\nexport type DeleteRecordOptions = CallOptions & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Compare-and-swap on the record CID. If specified, must match current record. */\n swapRecord?: string\n}\n\n/**\n * Options for retrieving a record from an AT Protocol repository.\n *\n * @see {@link Client.getRecord}\n */\nexport type GetRecordOptions = CallOptions & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n}\n\n/**\n * Options for creating or updating a record in an AT Protocol repository.\n *\n * @see {@link Client.putRecord}\n */\nexport type PutRecordOptions = CallOptions & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Compare-and-swap on the record CID. If specified, must match current record. */\n swapRecord?: string\n /** Whether to validate the record against its lexicon schema. */\n validate?: boolean\n}\n\n/**\n * Options for listing records in an AT Protocol repository collection.\n *\n * @see {@link Client.listRecords}\n */\nexport type ListRecordsOptions = CallOptions & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Maximum number of records to return. */\n limit?: number\n /** Pagination cursor from a previous response. */\n cursor?: string\n /** If true, returns records in reverse chronological order. */\n reverse?: boolean\n}\n\nexport type RecordKeyOptions<\n T extends RecordSchema,\n AlsoOptionalWhenRecordKeyIs extends LexiconRecordKey = never,\n> = T['key'] extends `literal:${string}` | AlsoOptionalWhenRecordKeyIs\n ? { rkey?: InferRecordKey<T> }\n : { rkey: InferRecordKey<T> }\n\n/**\n * Type-safe options for {@link Client.create}, combining record options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid' | 'any'>\n\n/**\n * Output type for record creation operations.\n * Contains the URI and CID of the newly created record.\n */\nexport type CreateOutput = InferMethodOutputBody<\n typeof com.atproto.repo.createRecord.main,\n Uint8Array\n>\n\n/**\n * Type-safe options for {@link Client.delete}, combining delete options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record deletion operations.\n */\nexport type DeleteOutput = InferMethodOutputBody<\n typeof com.atproto.repo.deleteRecord.main,\n Uint8Array\n>\n\n/**\n * Type-safe options for {@link Client.get}, combining get options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record retrieval operations.\n * Contains the record value validated against the schema type.\n * @typeParam T - The record schema type\n */\nexport type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>,\n 'value'\n> & { value: Infer<T> }\n\n/**\n * Type-safe options for {@link Client.put}, combining put options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record put (create/update) operations.\n * Contains the URI and CID of the record.\n */\nexport type PutOutput = InferMethodOutputBody<\n typeof com.atproto.repo.putRecord.main,\n Uint8Array\n>\n\n/**\n * Options for {@link Client.list} operations.\n */\nexport type ListOptions = ListRecordsOptions\n\n/**\n * Output type for record listing operations.\n * Contains validated records and any invalid records that failed schema validation.\n * @typeParam T - The record schema type\n */\nexport type ListOutput<T extends RecordSchema> = InferMethodOutputBody<\n typeof com.atproto.repo.listRecords.main,\n Uint8Array\n> & {\n /** Records that successfully validated against the schema. */\n records: ListRecord<Infer<T>>[]\n // @NOTE Because the schema uses \"type\": \"unknown\" instead of an open union,\n // we have to use LexMap instead of Unknown$TypedObject here, which is\n // unfortunate.\n /** Records that failed schema validation. */\n invalid: LexMap[]\n}\n\n/**\n * A record from a list operation with its value typed to the schema.\n * @typeParam Value - The validated record value type\n */\nexport type ListRecord<Value extends LexMap> =\n com.atproto.repo.listRecords.Record & {\n value: Value\n }\n\n/**\n * The Client class is the primary interface for interacting with AT Protocol\n * services. It provides type-safe methods for XRPC calls, record operations,\n * and blob handling.\n *\n * @example // Basic usage\n * ```typescript\n * import { Client } from '@atproto/lex'\n *\n * const client = new Client(oauthSession)\n *\n * const response = await client.xrpc(app.bsky.feed.getTimeline.main, {\n * params: { limit: 50 }\n * })\n * ```\n */\nexport class Client implements Agent {\n static appLabelers: readonly DidString[] = []\n\n /**\n * Configures the Client (or its sub classes) globally.\n */\n static configure(opts: { appLabelers?: Iterable<DidString> }) {\n if (opts.appLabelers) this.appLabelers = [...opts.appLabelers]\n }\n\n /** The underlying agent used for making requests. */\n public readonly agent: Agent\n\n /** Custom headers included in all requests. */\n public readonly headers: Headers\n\n /** Optional service identifier for routing requests. */\n public readonly service?: Service\n\n /** Set of labeler DIDs specific to this client instance. */\n public readonly labelers: Set<DidString>\n\n constructor(agent: Agent | AgentOptions, options: ClientOptions = {}) {\n this.agent = buildAgent(agent)\n this.service = options.service\n this.labelers = new Set(options.labelers)\n this.headers = new Headers(options.headers)\n }\n\n /**\n * The DID of the authenticated user, or `undefined` if not authenticated.\n */\n get did(): DidString | undefined {\n return this.agent.did\n }\n\n /**\n * The DID of the authenticated user.\n * @throws {Error} if not authenticated\n */\n get assertDid(): DidString {\n this.assertAuthenticated()\n return this.did\n }\n\n /**\n * Asserts that the client is authenticated.\n * Use as a type guard when you need to ensure authentication.\n *\n * @throws {Error} if not authenticated\n *\n * @example\n * ```typescript\n * client.assertAuthenticated()\n * // TypeScript now knows client.did is defined\n * console.log(client.did)\n * ```\n */\n public assertAuthenticated(): asserts this is { did: DidString } {\n if (!this.did) throw new Error('Client is not authenticated')\n }\n\n /**\n * Replaces all labelers with the given set.\n * @param labelers - Iterable of labeler DIDs\n */\n public setLabelers(labelers: Iterable<DidString> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n /**\n * Adds labelers to the current set.\n * @param labelers - Iterable of labeler DIDs to add\n */\n public addLabelers(labelers: Iterable<DidString>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n /**\n * Removes all labelers from this client instance.\n */\n public clearLabelers() {\n this.labelers.clear()\n }\n\n /**\n * {@link Agent}'s {@link Agent.fetchHandler} implementation, which adds\n * labelers and service proxying headers. This method allow a {@link Client}\n * instance to be used directly as an {@link Agent} for another\n * {@link Client}, enabling composition of headers (labelers, proxying, etc.).\n *\n * @param path - The request path\n * @param init - Request initialization options\n */\n public fetchHandler(\n path: `/${string}`,\n init: RequestInit,\n ): Promise<Response> {\n const headers = buildAtprotoHeaders({\n headers: init.headers,\n service: this.service,\n labelers: [\n ...(this.constructor as typeof Client).appLabelers.map(\n (l) => `${l};redact` as const,\n ),\n ...this.labelers,\n ],\n })\n\n // Incoming headers take precedence\n for (const [key, value] of this.headers) {\n if (!headers.has(key)) headers.set(key, value)\n }\n\n // @NOTE The agent here could be another Client instance.\n return this.agent.fetchHandler(path, { ...init, headers })\n }\n\n /**\n * Makes an XRPC request. Throws on failure.\n *\n * @param ns - The lexicon method definition (e.g., `app.bsky.feed.getTimeline`)\n * @param options - Request options including params and body\n * @returns The successful XRPC response\n * @throws {XrpcFailure} when the request fails or returns an error\n *\n * @example Query with parameters\n * ```typescript\n * const response = await client.xrpc(app.bsky.feed.getTimeline, {\n * params: { limit: 50, cursor: 'abc123' }\n * })\n * console.log(response.body.feed)\n * ```\n *\n * @example Procedure with body\n * ```typescript\n * const response = await client.xrpc(com.atproto.repo.createRecord, {\n * body: {\n * repo: client.assertDid,\n * collection: 'app.bsky.feed.post',\n * record: { text: 'Hello!', createdAt: new Date().toISOString() }\n * }\n * })\n * ```\n *\n * @see {@link xrpcSafe} for a non-throwing variant\n */\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n /**\n * Makes an XRPC request without throwing on failure.\n * Returns either a successful response or a failure object.\n *\n * @param ns - The lexicon method definition\n * @param options - Request options\n * @returns Either an XrpcResponse on success or XrpcFailure on failure\n *\n * @example\n * ```typescript\n * const result = await client.xrpcSafe(app.bsky.actor.getProfile.main, {\n * params: { actor: 'alice.bsky.social' }\n * })\n *\n * if (result.success) {\n * console.log(result.body.displayName)\n * } else {\n * console.error('Failed:', result.error)\n * }\n * ```\n *\n * @see {@link xrpc} for a throwing variant\n */\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>> {\n return xrpcSafe(this, ns, options)\n }\n\n /**\n * Creates a new record in an AT Protocol repository.\n *\n * @param record - The record to create, must include an {@link NsidString} `$type`\n * @param rkey - Optional record key; if omitted, server generates a TID\n * @param options - Create options including repo, swapCommit, validate\n * @returns The XRPC response containing the created record's URI and CID\n *\n * @example\n * ```typescript\n * const response = await client.createRecord(\n * { $type: 'app.bsky.feed.post', text: 'Hello!', createdAt: new Date().toISOString() },\n * undefined, // Let server generate rkey\n * { validate: true }\n * )\n * console.log(response.body.uri)\n * ```\n *\n * @see {@link create} for a higher-level typed alternative\n */\n public async createRecord(\n record: TypedLexMap<NsidString>,\n rkey?: string,\n options?: CreateRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.createRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n record,\n rkey,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n },\n })\n }\n\n /**\n * Deletes a record from an AT Protocol repository.\n *\n * @param collection - The collection NSID\n * @param rkey - The record key\n * @param options - Delete options including repo, swapCommit, swapRecord\n *\n * @see {@link delete} for a higher-level typed alternative\n */\n async deleteRecord(\n collection: NsidString,\n rkey: string,\n options?: DeleteRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.deleteRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n /**\n * Retrieves a record from an AT Protocol repository.\n *\n * @param collection - The collection NSID\n * @param rkey - The record key\n * @param options - Get options including repo\n *\n * @see {@link get} for a higher-level typed alternative\n */\n public async getRecord(\n collection: NsidString,\n rkey: string,\n options?: GetRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.getRecord.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n },\n })\n }\n\n /**\n * Creates or updates a record in a repository.\n *\n * @param record - The record to put, must include an {@link NsidString} `$type`\n * @param rkey - The record key\n * @param options - Put options including repo, swapCommit, swapRecord, validate\n *\n * @see {@link put} for a higher-level typed alternative\n */\n async putRecord(\n record: TypedLexMap<NsidString>,\n rkey: string,\n options?: PutRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.putRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n rkey,\n record,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n /**\n * Lists records in a collection.\n *\n * @param nsid - The collection NSID\n * @param options - List options including repo, limit, cursor, reverse\n *\n * @see {@link list} for a higher-level typed alternative\n */\n async listRecords(nsid: NsidString, options?: ListRecordsOptions) {\n return this.xrpc(com.atproto.repo.listRecords.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection: nsid,\n cursor: options?.cursor,\n limit: options?.limit,\n reverse: options?.reverse,\n },\n })\n }\n\n /**\n * Uploads a blob to an AT Protocol repository.\n *\n * @param body - The blob data (Uint8Array, ReadableStream, Blob, etc.)\n * @param options - Upload options including encoding hint\n * @returns Response containing the blob reference\n *\n * @example\n * ```typescript\n * const imageData = await fetch('image.png').then(r => r.arrayBuffer())\n * const response = await client.uploadBlob(new Uint8Array(imageData), {\n * encoding: 'image/png'\n * })\n * console.log(response.body.blob) // Use this ref in records\n * ```\n */\n async uploadBlob(\n body: BinaryBodyInit,\n options?: CallOptions & { encoding?: `${string}/${string}` },\n ) {\n return this.xrpc(com.atproto.repo.uploadBlob.main, {\n ...options,\n body,\n })\n }\n\n /**\n * Retrieves a blob by DID and CID.\n *\n * @param did - The DID of the repository containing the blob\n * @param cid - The CID of the blob\n * @param options - Call options\n */\n async getBlob(did: DidString, cid: CidString, options?: CallOptions) {\n return this.xrpc(com.atproto.sync.getBlob.main, {\n ...options,\n params: { did, cid },\n })\n }\n\n /**\n * Universal call method for queries, procedures, and custom actions.\n * Automatically determines the call type based on the lexicon definition.\n *\n * @param ns - The lexicon method or action definition\n * @param arg - The input argument (params for queries, body for procedures, input for actions)\n * @param options - Call options\n * @returns The method response body or action output\n * @see {@link xrpc} if you need access to the full response object\n *\n * @example Query\n * ```typescript\n * const profile = await client.call(app.bsky.actor.getProfile.main, {\n * actor: 'alice.bsky.social'\n * })\n * ```\n *\n * @example Procedure\n * ```typescript\n * const result = await client.call(com.atproto.repo.createRecord.main, {\n * repo: did,\n * collection: 'app.bsky.feed.post',\n * record: { text: 'Hello!' }\n * })\n * ```\n */\n public async call<const T extends Query>(\n ns: NonNullable<unknown> extends XrpcRequestParams<T>\n ? Main<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<XrpcResponseBody<T>>\n public async call<const T extends Procedure>(\n ns: undefined extends InferMethodInputBody<T, Uint8Array>\n ? Main<T>\n : Restricted<'This procedure type requires an \"input\" argument'>,\n ): Promise<XrpcResponseBody<T>>\n public async call<const T extends Action>(\n ns: void extends InferActionInput<T>\n ? Main<T>\n : Restricted<'This action type requires an \"input\" argument'>,\n ): Promise<InferActionOutput<T>>\n public async call<const T extends Action | Procedure | Query>(\n ns: Main<T>,\n arg: T extends Action\n ? InferActionInput<T>\n : T extends Procedure\n ? InferMethodInputBody<T, Uint8Array>\n : T extends Query\n ? XrpcRequestParams<T>\n : never,\n options?: CallOptions,\n ): Promise<\n T extends Action\n ? InferActionOutput<T>\n : T extends Procedure\n ? XrpcResponseBody<T>\n : T extends Query\n ? XrpcResponseBody<T>\n : never\n >\n public async call(\n ns: Main<Action> | Main<Procedure> | Main<Query>,\n arg?: LexValue | Params,\n options: CallOptions = {},\n ): Promise<unknown> {\n const method = getMain(ns)\n\n if (typeof method === 'function') {\n return method(this, arg, options)\n }\n\n if (method instanceof Procedure) {\n const result = await this.xrpc(method, { ...options, body: arg as any })\n return result.body\n } else if (method instanceof Query) {\n const result = await this.xrpc(method, { ...options, params: arg as any })\n return result.body\n } else {\n throw new TypeError('Invalid lexicon')\n }\n }\n\n /**\n * Creates a new record with full type safety based on the schema.\n *\n * @param ns - The record schema definition\n * @param input - The record data (without `$type`, which is added automatically)\n * @param options - Create options including rkey (required for some record types)\n * @returns The create output including URI and CID\n *\n * @example Creating a post\n * ```typescript\n * const result = await client.create(app.bsky.feed.post.main, {\n * text: 'Hello, world!',\n * createdAt: new Date().toISOString()\n * })\n * console.log(result.uri)\n * ```\n *\n * @example Creating a record with explicit rkey\n * ```typescript\n * const result = await client.create(app.bsky.actor.profile.main, {\n * displayName: 'Alice'\n * }, { rkey: 'self' })\n * ```\n */\n public async create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends CreateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T> = {} as CreateOptions<T>,\n ): Promise<CreateOutput> {\n const schema: T = getMain(ns)\n const record = schema.build(input) as TypedLexMap<NsidString>\n const rkey = options.rkey ?? getDefaultRecordKey(schema)\n if (rkey !== undefined) schema.keySchema.assert(rkey)\n const response = await this.createRecord(record, rkey, options)\n return response.body\n }\n\n /**\n * Deletes a record with type-safe options.\n *\n * @param ns - The record schema definition\n * @param options - Delete options (rkey required for non-literal keys)\n * @returns The delete output\n */\n public async delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends DeleteOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options?: DeleteOptions<T>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: DeleteOptions<T> = {} as DeleteOptions<T>,\n ): Promise<DeleteOutput> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.deleteRecord(schema.$type, rkey, options)\n return response.body\n }\n\n /**\n * Retrieves a record with type-safe validation.\n *\n * @param ns - The record schema definition\n * @param options - Get options (rkey required for non-literal keys)\n * @returns The record data validated against the schema\n *\n * @example\n * ```typescript\n * const profile = await client.get(app.bsky.actor.profile.main)\n * // profile.value is typed as app.bsky.actor.profile.Record\n * console.log(profile.value.displayName)\n * ```\n */\n public async get<const T extends RecordSchema>(\n ns: T['key'] extends `literal:${string}`\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<T>,\n options?: GetOptions<T>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<T>,\n options: GetOptions<T> = {} as GetOptions<T>,\n ): Promise<GetOutput<T>> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.getRecord(schema.$type, rkey, options)\n const value = schema.validate(response.body.value)\n return { ...response.body, value }\n }\n\n /**\n * Creates or updates a record with full type safety.\n *\n * @param ns - The record schema definition\n * @param input - The record data\n * @param options - Put options (rkey required for non-literal keys)\n * @returns The put output including URI and CID\n */\n public async put<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends PutOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T> = {} as PutOptions<T>,\n ): Promise<PutOutput> {\n const schema: T = getMain(ns)\n const record = schema.build(input) as TypedLexMap<NsidString>\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\n }\n\n /**\n * Lists records with type-safe validation and separation of valid/invalid records.\n *\n * @param ns - The record schema definition\n * @param options - List options\n * @returns Records split into valid (matching schema) and invalid arrays\n *\n * @example\n * ```typescript\n * const result = await client.list(app.bsky.feed.post.main, { limit: 100 })\n * console.log(`Found ${result.records.length} valid posts`)\n * console.log(`Found ${result.invalid.length} invalid records`)\n * ```\n */\n async list<const T extends RecordSchema>(\n ns: Main<T>,\n options?: ListOptions,\n ): Promise<ListOutput<T>> {\n const schema = getMain(ns)\n const { body } = await this.listRecords(schema.$type, options)\n\n const records: ListRecord<Infer<T>>[] = []\n const invalid: LexMap[] = []\n\n for (const record of body.records) {\n const parsed = schema.safeValidate(record.value)\n if (parsed.success) {\n records.push({ ...record, value: parsed.value })\n } else {\n invalid.push(record.value)\n }\n }\n\n return { ...body, records, invalid }\n }\n}\n\nfunction getDefaultRecordKey<const T extends RecordSchema>(\n schema: T,\n): undefined | InferRecordKey<T> {\n // Let the server generate the TID\n if (schema.key === 'tid') return undefined\n if (schema.key === 'any') return undefined\n\n return getLiteralRecordKey(schema)\n}\n\nfunction getLiteralRecordKey<const T extends RecordSchema>(\n schema: T,\n): InferRecordKey<T> {\n if (schema.key.startsWith('literal:')) {\n return schema.key.slice(8) as InferRecordKey<T>\n }\n\n throw new TypeError(\n `An \"rkey\" must be provided for record key type \"${schema.key}\" (${schema.$type})`,\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,oDAiB4B;AAC5B,yCAA4D;AAE5D,kDAAyC;AAOzC,uCAIkB;AAClB,uCAMkB;AAuRlB;;;;;;;;;;;;;;;GAeG;AACH,MAAa,MAAM;IACjB,MAAM,CAAC,WAAW,GAAyB,EAAE,CAAA;IAE7C;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAA2C;QAC1D,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;IAChE,CAAC;IAED,qDAAqD;IACrC,KAAK,CAAO;IAE5B,+CAA+C;IAC/B,OAAO,CAAS;IAEhC,wDAAwD;IACxC,OAAO,CAAU;IAEjC,4DAA4D;IAC5C,QAAQ,CAAgB;IAExB,YAAY,CAI3B;IAED,YAAY,KAA2B,EAAE,UAAyB,EAAE;QAClE,IAAI,CAAC,KAAK,GAAG,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;YAChC,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,KAAK;YACjD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IA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B,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexMap, LexValue, TypedLexMap } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferRecordKey,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n getMain,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport { XrpcFailure } from './errors.js'\nimport { com } from './lexicons/index.js'\nimport {\n XrpcResponse,\n XrpcResponseBody,\n XrpcResponseOptions,\n} from './response.js'\nimport { BinaryBodyInit, Service } from './types.js'\nimport {\n XrpcRequestHeadersOptions,\n applyDefaults,\n buildXrpcRequestHeaders,\n} from './util.js'\nimport {\n XrpcOptions,\n XrpcRequestParams,\n XrpcRequestProcessingOptions,\n xrpc,\n xrpcSafe,\n} from './xrpc.js'\n\nexport type {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferRecordKey,\n LexMap,\n LexValue,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n TypedLexMap,\n}\n\n/**\n * Configuration options for creating a {@link Client}.\n *\n * @example\n * ```typescript\n * const options: ClientOptions = {\n * labelers: ['did:plc:labeler1'],\n * service: 'did:web:api.bsky.app#bsky_appview',\n * headers: { 'X-Custom-Header': 'value' }\n * }\n * ```\n */\nexport type ClientOptions = XrpcRequestHeadersOptions &\n Pick<XrpcRequestProcessingOptions, 'validateRequest'> &\n XrpcResponseOptions\n\nexport type ActionOptions = {\n /** AbortSignal to cancel the request. */\n signal?: AbortSignal\n}\n\n/**\n * A composable action that can be invoked via {@link Client.call}.\n *\n * Actions provide a way to define custom operations that integrate with the\n * Client's call interface, enabling type-safe, reusable business logic.\n *\n * @typeParam I - The input type for the action\n * @typeParam O - The output type for the action\n *\n * @example\n * ```typescript\n * const myAction: Action<{ userId: string }, { profile: Profile }> = async (client, input, options) => {\n * const response = await client.xrpc(someMethod, { params: { actor: input.userId }, ...options })\n * return { profile: response.body }\n * }\n * ```\n */\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: ActionOptions,\n) => O | Promise<O>\n\n/**\n * Extracts the input type from an {@link Action}.\n * @typeParam A - The Action type to extract from\n */\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\n\n/**\n * Extracts the output type from an {@link Action}.\n * @typeParam A - The Action type to extract from\n */\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\n/**\n * Options for creating a record in an AT Protocol repository.\n *\n * @see {@link Client.createRecord}\n */\nexport type CreateRecordOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.createRecord.main>,\n 'body'\n> & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Whether to validate the record against its lexicon schema. */\n validate?: boolean\n}\n\n/**\n * Options for deleting a record from an AT Protocol repository.\n *\n * @see {@link Client.deleteRecord}\n */\nexport type DeleteRecordOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.deleteRecord.main>,\n 'params'\n> & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Compare-and-swap on the record CID. If specified, must match current record. */\n swapRecord?: string\n}\n\n/**\n * Options for retrieving a record from an AT Protocol repository.\n *\n * @see {@link Client.getRecord}\n */\nexport type GetRecordOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.getRecord.main>,\n 'params'\n> & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n}\n\n/**\n * Options for creating or updating a record in an AT Protocol repository.\n *\n * @see {@link Client.putRecord}\n */\nexport type PutRecordOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.putRecord.main>,\n 'body'\n> & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Compare-and-swap on the repo commit. If specified, must match current commit. */\n swapCommit?: string\n /** Compare-and-swap on the record CID. If specified, must match current record. */\n swapRecord?: string\n /** Whether to validate the record against its lexicon schema. */\n validate?: boolean\n}\n\n/**\n * Options for listing records in an AT Protocol repository collection.\n *\n * @see {@link Client.listRecords}\n */\nexport type ListRecordsOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.listRecords.main>,\n 'params'\n> & {\n /** Repository identifier (DID or handle). Defaults to authenticated user's DID. */\n repo?: AtIdentifierString\n /** Maximum number of records to return. */\n limit?: number\n /** Pagination cursor from a previous response. */\n cursor?: string\n /** If true, returns records in reverse chronological order. */\n reverse?: boolean\n}\n\nexport type UploadBlobOptions = Omit<\n XrpcOptions<typeof com.atproto.repo.uploadBlob.main>,\n 'body'\n>\n\nexport type GetBlobOptions = Omit<\n XrpcOptions<typeof com.atproto.sync.getBlob.main>,\n 'params'\n>\n\nexport type RecordKeyOptions<\n T extends RecordSchema,\n AlsoOptionalWhenRecordKeyIs extends LexiconRecordKey = never,\n> = T['key'] extends `literal:${string}` | AlsoOptionalWhenRecordKeyIs\n ? { rkey?: InferRecordKey<T> }\n : { rkey: InferRecordKey<T> }\n\n/**\n * Type-safe options for {@link Client.create}, combining record options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid' | 'any'>\n\n/**\n * Output type for record creation operations.\n * Contains the URI and CID of the newly created record.\n */\nexport type CreateOutput = InferMethodOutputBody<\n typeof com.atproto.repo.createRecord.main,\n Uint8Array\n>\n\n/**\n * Type-safe options for {@link Client.delete}, combining delete options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record deletion operations.\n */\nexport type DeleteOutput = InferMethodOutputBody<\n typeof com.atproto.repo.deleteRecord.main,\n Uint8Array\n>\n\n/**\n * Type-safe options for {@link Client.get}, combining get options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record retrieval operations.\n * Contains the record value validated against the schema type.\n * @typeParam T - The record schema type\n */\nexport type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>,\n 'value'\n> & { value: Infer<T> }\n\n/**\n * Type-safe options for {@link Client.put}, combining put options with key requirements.\n * @typeParam T - The record schema type\n */\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\n\n/**\n * Output type for record put (create/update) operations.\n * Contains the URI and CID of the record.\n */\nexport type PutOutput = InferMethodOutputBody<\n typeof com.atproto.repo.putRecord.main,\n Uint8Array\n>\n\n/**\n * Options for {@link Client.list} operations.\n */\nexport type ListOptions = ListRecordsOptions\n\n/**\n * Output type for record listing operations.\n * Contains validated records and any invalid records that failed schema validation.\n * @typeParam T - The record schema type\n */\nexport type ListOutput<T extends RecordSchema> = InferMethodOutputBody<\n typeof com.atproto.repo.listRecords.main,\n Uint8Array\n> & {\n /** Records that successfully validated against the schema. */\n records: ListRecord<Infer<T>>[]\n // @NOTE Because the schema uses \"type\": \"unknown\" instead of an open union,\n // we have to use LexMap instead of Unknown$TypedObject here, which is\n // unfortunate.\n /** Records that failed schema validation. */\n invalid: LexMap[]\n}\n\n/**\n * A record from a list operation with its value typed to the schema.\n * @typeParam Value - The validated record value type\n */\nexport type ListRecord<Value extends LexMap> =\n com.atproto.repo.listRecords.Record & {\n value: Value\n }\n\n/**\n * The Client class is the primary interface for interacting with AT Protocol\n * services. It provides type-safe methods for XRPC calls, record operations,\n * and blob handling.\n *\n * @example // Basic usage\n * ```typescript\n * import { Client } from '@atproto/lex'\n *\n * const client = new Client(oauthSession)\n *\n * const response = await client.xrpc(app.bsky.feed.getTimeline.main, {\n * params: { limit: 50 }\n * })\n * ```\n */\nexport class Client implements Agent {\n static appLabelers: readonly DidString[] = []\n\n /**\n * Configures the Client (or its sub classes) globally.\n */\n static configure(opts: { appLabelers?: Iterable<DidString> }) {\n if (opts.appLabelers) this.appLabelers = [...opts.appLabelers]\n }\n\n /** The underlying agent used for making requests. */\n public readonly agent: Agent\n\n /** Custom headers included in all requests. */\n public readonly headers: Headers\n\n /** Optional service identifier for routing requests. */\n public readonly service?: Service\n\n /** Set of labeler DIDs specific to this client instance. */\n public readonly labelers: Set<DidString>\n\n public readonly xrpcDefaults: {\n readonly validateRequest: boolean\n readonly validateResponse: boolean\n readonly strictResponseProcessing: boolean\n }\n\n constructor(agent: Agent | AgentOptions, options: ClientOptions = {}) {\n this.agent = buildAgent(agent)\n this.service = options.service\n this.labelers = new Set(options.labelers)\n this.headers = new Headers(options.headers)\n this.xrpcDefaults = Object.freeze({\n validateRequest: options.validateRequest ?? false,\n validateResponse: options.validateResponse ?? true,\n strictResponseProcessing: options.strictResponseProcessing ?? true,\n })\n }\n\n /**\n * The DID of the authenticated user, or `undefined` if not authenticated.\n */\n get did(): DidString | undefined {\n return this.agent.did\n }\n\n /**\n * The DID of the authenticated user.\n * @throws {Error} if not authenticated\n */\n get assertDid(): DidString {\n this.assertAuthenticated()\n return this.did\n }\n\n /**\n * Asserts that the client is authenticated.\n * Use as a type guard when you need to ensure authentication.\n *\n * @throws {Error} if not authenticated\n *\n * @example\n * ```typescript\n * client.assertAuthenticated()\n * // TypeScript now knows client.did is defined\n * console.log(client.did)\n * ```\n */\n public assertAuthenticated(): asserts this is { did: DidString } {\n if (!this.did) throw new Error('Client is not authenticated')\n }\n\n /**\n * Replaces all labelers with the given set.\n * @param labelers - Iterable of labeler DIDs\n */\n public setLabelers(labelers: Iterable<DidString> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n /**\n * Adds labelers to the current set.\n * @param labelers - Iterable of labeler DIDs to add\n */\n public addLabelers(labelers: Iterable<DidString>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n /**\n * Removes all labelers from this client instance.\n */\n public clearLabelers() {\n this.labelers.clear()\n }\n\n /**\n * {@link Agent}'s {@link Agent.fetchHandler} implementation, which adds\n * labelers and service proxying headers. This method allow a {@link Client}\n * instance to be used directly as an {@link Agent} for another\n * {@link Client}, enabling composition of headers (labelers, proxying, etc.).\n *\n * @param path - The request path\n * @param init - Request initialization options\n */\n public fetchHandler(\n path: `/${string}`,\n init: RequestInit,\n ): Promise<Response> {\n const headers = buildXrpcRequestHeaders({\n headers: init.headers,\n service: this.service,\n labelers: [\n ...(this.constructor as typeof Client).appLabelers.map(\n (l) => `${l};redact` as const,\n ),\n ...this.labelers,\n ],\n })\n\n // Incoming headers take precedence\n for (const [key, value] of this.headers) {\n if (!headers.has(key)) headers.set(key, value)\n }\n\n // @NOTE The agent here could be another Client instance.\n return this.agent.fetchHandler(path, { ...init, headers })\n }\n\n /**\n * Makes an XRPC request. Throws on failure.\n *\n * @param ns - The lexicon method definition (e.g., `app.bsky.feed.getTimeline`)\n * @param options - Request options including params and body\n * @returns The successful XRPC response\n * @throws {XrpcFailure} when the request fails or returns an error\n *\n * @example Query with parameters\n * ```typescript\n * const response = await client.xrpc(app.bsky.feed.getTimeline, {\n * params: { limit: 50, cursor: 'abc123' }\n * })\n * console.log(response.body.feed)\n * ```\n *\n * @example Procedure with body\n * ```typescript\n * const response = await client.xrpc(com.atproto.repo.createRecord, {\n * body: {\n * repo: client.assertDid,\n * collection: 'app.bsky.feed.post',\n * record: { text: 'Hello!', createdAt: new Date().toISOString() }\n * }\n * })\n * ```\n *\n * @see {@link xrpcSafe} for a non-throwing variant\n */\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M>> {\n return xrpc(this, ns, applyDefaults(options, this.xrpcDefaults))\n }\n\n /**\n * Makes an XRPC request without throwing on failure.\n * Returns either a successful response or a failure object.\n *\n * @param ns - The lexicon method definition\n * @param options - Request options\n * @returns Either an XrpcResponse on success or XrpcFailure on failure\n *\n * @example\n * ```typescript\n * const result = await client.xrpcSafe(app.bsky.actor.getProfile.main, {\n * params: { actor: 'alice.bsky.social' }\n * })\n *\n * if (result.success) {\n * console.log(result.body.displayName)\n * } else {\n * console.error('Failed:', result.error)\n * }\n * ```\n *\n * @see {@link xrpc} for a throwing variant\n */\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcFailure<M>> {\n return xrpcSafe(this, ns, applyDefaults(options, this.xrpcDefaults))\n }\n\n /**\n * Creates a new record in an AT Protocol repository.\n *\n * @param record - The record to create, must include an {@link NsidString} `$type`\n * @param rkey - Optional record key; if omitted, server generates a TID\n * @param options - Create options including repo, swapCommit, validate\n * @returns The XRPC response containing the created record's URI and CID\n *\n * @example\n * ```typescript\n * const response = await client.createRecord(\n * { $type: 'app.bsky.feed.post', text: 'Hello!', createdAt: new Date().toISOString() },\n * undefined, // Let server generate rkey\n * { validate: true }\n * )\n * console.log(response.body.uri)\n * ```\n *\n * @see {@link create} for a higher-level typed alternative\n */\n public async createRecord(\n record: TypedLexMap<NsidString>,\n rkey?: string,\n options?: CreateRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.createRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n record,\n rkey,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n },\n })\n }\n\n /**\n * Deletes a record from an AT Protocol repository.\n *\n * @param collection - The collection NSID\n * @param rkey - The record key\n * @param options - Delete options including repo, swapCommit, swapRecord\n *\n * @see {@link delete} for a higher-level typed alternative\n */\n async deleteRecord(\n collection: NsidString,\n rkey: string,\n options?: DeleteRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.deleteRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n /**\n * Retrieves a record from an AT Protocol repository.\n *\n * @param collection - The collection NSID\n * @param rkey - The record key\n * @param options - Get options including repo\n *\n * @see {@link get} for a higher-level typed alternative\n */\n public async getRecord(\n collection: NsidString,\n rkey: string,\n options?: GetRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.getRecord.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n },\n })\n }\n\n /**\n * Creates or updates a record in a repository.\n *\n * @param record - The record to put, must include an {@link NsidString} `$type`\n * @param rkey - The record key\n * @param options - Put options including repo, swapCommit, swapRecord, validate\n *\n * @see {@link put} for a higher-level typed alternative\n */\n async putRecord(\n record: TypedLexMap<NsidString>,\n rkey: string,\n options?: PutRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.putRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n rkey,\n record,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n /**\n * Lists records in a collection.\n *\n * @param nsid - The collection NSID\n * @param options - List options including repo, limit, cursor, reverse\n *\n * @see {@link list} for a higher-level typed alternative\n */\n async listRecords(nsid: NsidString, options?: ListRecordsOptions) {\n return this.xrpc(com.atproto.repo.listRecords.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection: nsid,\n cursor: options?.cursor,\n limit: options?.limit,\n reverse: options?.reverse,\n },\n })\n }\n\n /**\n * Uploads a blob to an AT Protocol repository.\n *\n * @param body - The blob data (Uint8Array, ReadableStream, Blob, etc.)\n * @param options - Upload options including encoding hint\n * @returns Response containing the blob reference\n *\n * @example\n * ```typescript\n * const imageData = await fetch('image.png').then(r => r.arrayBuffer())\n * const response = await client.uploadBlob(new Uint8Array(imageData), {\n * encoding: 'image/png'\n * })\n * console.log(response.body.blob) // Use this ref in records\n * ```\n */\n async uploadBlob(body: BinaryBodyInit, options?: UploadBlobOptions) {\n return this.xrpc(com.atproto.repo.uploadBlob.main, { ...options, body })\n }\n\n /**\n * Retrieves a blob by DID and CID.\n *\n * @param did - The DID of the repository containing the blob\n * @param cid - The CID of the blob\n * @param options - Call options\n */\n async getBlob(did: DidString, cid: CidString, options?: GetBlobOptions) {\n return this.xrpc(com.atproto.sync.getBlob.main, {\n ...options,\n params: { did, cid },\n })\n }\n\n /**\n * Universal call method for queries, procedures, and custom actions.\n * Automatically determines the call type based on the lexicon definition.\n *\n * @param ns - The lexicon method or action definition\n * @param arg - The input argument (params for queries, body for procedures, input for actions)\n * @param options - Call options\n * @returns The method response body or action output\n * @see {@link xrpc} if you need access to the full response object\n *\n * @example Query\n * ```typescript\n * const profile = await client.call(app.bsky.actor.getProfile.main, {\n * actor: 'alice.bsky.social'\n * })\n * ```\n *\n * @example Procedure\n * ```typescript\n * const result = await client.call(com.atproto.repo.createRecord.main, {\n * repo: did,\n * collection: 'app.bsky.feed.post',\n * record: { text: 'Hello!' }\n * })\n * ```\n */\n public async call<const T extends Query>(\n ns: NonNullable<unknown> extends XrpcRequestParams<T>\n ? Main<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<XrpcResponseBody<T>>\n public async call<const T extends Procedure>(\n ns: undefined extends InferMethodInputBody<T, Uint8Array>\n ? Main<T>\n : Restricted<'This procedure type requires an \"input\" argument'>,\n ): Promise<XrpcResponseBody<T>>\n public async call<const T extends Action>(\n ns: void extends InferActionInput<T>\n ? Main<T>\n : Restricted<'This action type requires an \"input\" argument'>,\n ): Promise<InferActionOutput<T>>\n public async call<const T extends Action | Procedure | Query>(\n ns: Main<T>,\n arg: T extends Action\n ? InferActionInput<T>\n : T extends Procedure\n ? InferMethodInputBody<T, Uint8Array>\n : T extends Query\n ? XrpcRequestParams<T>\n : never,\n options?: T extends Action\n ? ActionOptions\n : T extends Procedure\n ? Omit<XrpcOptions<T>, 'body'>\n : T extends Query\n ? Omit<XrpcOptions<T>, 'params'>\n : never,\n ): Promise<\n T extends Action\n ? InferActionOutput<T>\n : T extends Procedure\n ? XrpcResponseBody<T>\n : T extends Query\n ? XrpcResponseBody<T>\n : never\n >\n public async call(\n ns: Main<Action> | Main<Procedure> | Main<Query>,\n arg?: LexValue | Params,\n options: ActionOptions = {},\n ): Promise<unknown> {\n const method = getMain(ns)\n\n if (typeof method === 'function') {\n return method(this, arg, options)\n }\n\n if (method instanceof Procedure) {\n const result = await this.xrpc(method, { ...options, body: arg as any })\n return result.body\n } else if (method instanceof Query) {\n const result = await this.xrpc(method, { ...options, params: arg as any })\n return result.body\n } else {\n throw new TypeError('Invalid lexicon')\n }\n }\n\n /**\n * Creates a new record with full type safety based on the schema.\n *\n * @param ns - The record schema definition\n * @param input - The record data (without `$type`, which is added automatically)\n * @param options - Create options including rkey (required for some record types)\n * @returns The create output including URI and CID\n *\n * @example Creating a post\n * ```typescript\n * const result = await client.create(app.bsky.feed.post.main, {\n * text: 'Hello, world!',\n * createdAt: new Date().toISOString()\n * })\n * console.log(result.uri)\n * ```\n *\n * @example Creating a record with explicit rkey\n * ```typescript\n * const result = await client.create(app.bsky.actor.profile.main, {\n * displayName: 'Alice'\n * }, { rkey: 'self' })\n * ```\n */\n public async create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends CreateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T> = {} as CreateOptions<T>,\n ): Promise<CreateOutput> {\n const schema: T = getMain(ns)\n const record = schema.build(input) as TypedLexMap<NsidString>\n if (options?.validateRequest) schema.validate(record)\n const rkey = options.rkey ?? getDefaultRecordKey(schema)\n if (rkey !== undefined) schema.keySchema.assert(rkey)\n const response = await this.createRecord(record, rkey, options)\n return response.body\n }\n\n /**\n * Deletes a record with type-safe options.\n *\n * @param ns - The record schema definition\n * @param options - Delete options (rkey required for non-literal keys)\n * @returns The delete output\n */\n public async delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends DeleteOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options?: DeleteOptions<T>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: DeleteOptions<T> = {} as DeleteOptions<T>,\n ): Promise<DeleteOutput> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.deleteRecord(schema.$type, rkey, options)\n return response.body\n }\n\n /**\n * Retrieves a record with type-safe validation.\n *\n * @param ns - The record schema definition\n * @param options - Get options (rkey required for non-literal keys)\n * @returns The record data validated against the schema\n *\n * @example\n * ```typescript\n * const profile = await client.get(app.bsky.actor.profile.main)\n * // profile.value is typed as app.bsky.actor.profile.Record\n * console.log(profile.value.displayName)\n * ```\n */\n public async get<const T extends RecordSchema>(\n ns: T['key'] extends `literal:${string}`\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<T>,\n options?: GetOptions<T>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<T>,\n options: GetOptions<T> = {} as GetOptions<T>,\n ): Promise<GetOutput<T>> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.getRecord(schema.$type, rkey, options)\n const value = schema.validate(response.body.value)\n return { ...response.body, value }\n }\n\n /**\n * Creates or updates a record with full type safety.\n *\n * @param ns - The record schema definition\n * @param input - The record data\n * @param options - Put options (rkey required for non-literal keys)\n * @returns The put output including URI and CID\n */\n public async put<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends PutOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T> = {} as PutOptions<T>,\n ): Promise<PutOutput> {\n const schema: T = getMain(ns)\n const record = schema.build(input) as TypedLexMap<NsidString>\n if (options?.validateRequest) schema.validate(record)\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\n }\n\n /**\n * Lists records with type-safe validation and separation of valid/invalid records.\n *\n * @param ns - The record schema definition\n * @param options - List options\n * @returns Records split into valid (matching schema) and invalid arrays\n *\n * @example\n * ```typescript\n * const result = await client.list(app.bsky.feed.post.main, { limit: 100 })\n * console.log(`Found ${result.records.length} valid posts`)\n * console.log(`Found ${result.invalid.length} invalid records`)\n * ```\n */\n async list<const T extends RecordSchema>(\n ns: Main<T>,\n options?: ListOptions,\n ): Promise<ListOutput<T>> {\n const schema = getMain(ns)\n const { body } = await this.listRecords(schema.$type, options)\n\n const records: ListRecord<Infer<T>>[] = []\n const invalid: LexMap[] = []\n\n for (const record of body.records) {\n const parsed = schema.safeValidate(record.value)\n if (parsed.success) {\n records.push({ ...record, value: parsed.value })\n } else {\n invalid.push(record.value)\n }\n }\n\n return { ...body, records, invalid }\n }\n}\n\nfunction getDefaultRecordKey<const T extends RecordSchema>(\n schema: T,\n): undefined | InferRecordKey<T> {\n // Let the server generate the TID\n if (schema.key === 'tid') return undefined\n if (schema.key === 'any') return undefined\n\n return getLiteralRecordKey(schema)\n}\n\nfunction getLiteralRecordKey<const T extends RecordSchema>(\n schema: T,\n): InferRecordKey<T> {\n if (schema.key.startsWith('literal:')) {\n return schema.key.slice(8) as InferRecordKey<T>\n }\n\n throw new TypeError(\n `An \"rkey\" must be provided for record key type \"${schema.key}\" (${schema.$type})`,\n )\n}\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data';
|
|
1
|
+
import { LexError, LexErrorCode, LexErrorData, LexValue } from '@atproto/lex-data';
|
|
2
2
|
import { InferMethodError, LexValidationError, Procedure, Query, ResultFailure } from '@atproto/lex-schema';
|
|
3
|
-
import {
|
|
3
|
+
import { XrpcUnknownResponsePayload } from './types.js';
|
|
4
4
|
import { WWWAuthenticate } from './www-authenticate.js';
|
|
5
|
+
export type { XrpcUnknownResponsePayload };
|
|
5
6
|
export type DownstreamError<N extends LexErrorCode = LexErrorCode> = {
|
|
6
7
|
status: number;
|
|
7
8
|
headers?: Headers;
|
|
@@ -48,7 +49,7 @@ export type XrpcErrorPayload<N extends LexErrorCode = LexErrorCode> = {
|
|
|
48
49
|
*
|
|
49
50
|
* This function checks whether a given payload matches this schema.
|
|
50
51
|
*/
|
|
51
|
-
export declare function isXrpcErrorPayload(payload:
|
|
52
|
+
export declare function isXrpcErrorPayload(payload: XrpcUnknownResponsePayload | null | undefined): payload is XrpcErrorPayload;
|
|
52
53
|
/**
|
|
53
54
|
* Abstract base class for all XRPC errors.
|
|
54
55
|
*
|
|
@@ -60,7 +61,7 @@ export declare function isXrpcErrorPayload(payload: XrpcResponsePayload | null |
|
|
|
60
61
|
* @typeParam TReason - The reason type for ResultFailure
|
|
61
62
|
*
|
|
62
63
|
* @see {@link XrpcResponseError} - For valid XRPC error responses
|
|
63
|
-
* @see {@link
|
|
64
|
+
* @see {@link XrpcInvalidResponseError} - For invalid/unexpected responses
|
|
64
65
|
* @see {@link XrpcInternalError} - For network/internal errors
|
|
65
66
|
*/
|
|
66
67
|
export declare abstract class XrpcError<M extends Procedure | Query = Procedure | Query, N extends LexErrorCode = LexErrorCode, TReason = unknown> extends LexError<N> implements ResultFailure<TReason> {
|
|
@@ -106,18 +107,18 @@ export declare abstract class XrpcError<M extends Procedure | Query = Procedure
|
|
|
106
107
|
* }
|
|
107
108
|
* ```
|
|
108
109
|
*/
|
|
109
|
-
export declare class XrpcResponseError<M extends Procedure | Query = Procedure | Query
|
|
110
|
+
export declare class XrpcResponseError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, LexErrorCode, XrpcResponseError<M>> {
|
|
110
111
|
readonly response: Response;
|
|
111
|
-
readonly payload
|
|
112
|
+
readonly payload?: XrpcUnknownResponsePayload | undefined;
|
|
112
113
|
name: string;
|
|
113
|
-
constructor(method: M, response: Response, payload
|
|
114
|
+
constructor(method: M, response: Response, payload?: XrpcUnknownResponsePayload | undefined, options?: ErrorOptions);
|
|
114
115
|
get reason(): this;
|
|
115
116
|
shouldRetry(): boolean;
|
|
116
|
-
toJSON(): LexErrorData
|
|
117
|
+
toJSON(): LexErrorData;
|
|
117
118
|
toDownstreamError(): DownstreamError;
|
|
118
119
|
get status(): number;
|
|
119
120
|
get headers(): Headers;
|
|
120
|
-
get body():
|
|
121
|
+
get body(): undefined | Uint8Array | LexValue;
|
|
121
122
|
}
|
|
122
123
|
export type { WWWAuthenticate };
|
|
123
124
|
/**
|
|
@@ -146,7 +147,7 @@ export type { WWWAuthenticate };
|
|
|
146
147
|
* }
|
|
147
148
|
* ```
|
|
148
149
|
*/
|
|
149
|
-
export declare class XrpcAuthenticationError<M extends Procedure | Query = Procedure | Query
|
|
150
|
+
export declare class XrpcAuthenticationError<M extends Procedure | Query = Procedure | Query> extends XrpcResponseError<M> {
|
|
150
151
|
#private;
|
|
151
152
|
name: string;
|
|
152
153
|
shouldRetry(): boolean;
|
|
@@ -155,7 +156,6 @@ export declare class XrpcAuthenticationError<M extends Procedure | Query = Proce
|
|
|
155
156
|
* Contains authentication scheme parameters (e.g., Bearer realm, DPoP nonce).
|
|
156
157
|
*/
|
|
157
158
|
get wwwAuthenticate(): WWWAuthenticate;
|
|
158
|
-
toDownstreamError(): DownstreamError;
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
161
161
|
* Error class for invalid or unprocessable XRPC responses from upstream servers.
|
|
@@ -167,16 +167,17 @@ export declare class XrpcAuthenticationError<M extends Procedure | Query = Proce
|
|
|
167
167
|
* - Non-JSON error responses
|
|
168
168
|
* - Responses from non-XRPC endpoints
|
|
169
169
|
*
|
|
170
|
-
* The error code is always '
|
|
171
|
-
* when converted to a response.
|
|
170
|
+
* The error code is always 'InvalidResponse' and maps to HTTP 502 Bad Gateway
|
|
171
|
+
* when converted to a response. This should allow downstream clients to
|
|
172
|
+
* determine at which boundary the error occurred.
|
|
172
173
|
*
|
|
173
174
|
* @typeParam M - The XRPC method type
|
|
174
175
|
*/
|
|
175
|
-
export declare class
|
|
176
|
+
export declare class XrpcInvalidResponseError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, 'InvalidResponse', XrpcInvalidResponseError<M>> {
|
|
176
177
|
readonly response: Response;
|
|
177
|
-
readonly payload
|
|
178
|
+
readonly payload?: XrpcUnknownResponsePayload | undefined;
|
|
178
179
|
name: string;
|
|
179
|
-
constructor(method: M, response: Response, payload?:
|
|
180
|
+
constructor(method: M, response: Response, payload?: XrpcUnknownResponsePayload | undefined, message?: string, options?: ErrorOptions);
|
|
180
181
|
get reason(): this;
|
|
181
182
|
shouldRetry(): boolean;
|
|
182
183
|
toDownstreamError(): DownstreamError;
|
|
@@ -184,7 +185,7 @@ export declare class XrpcUpstreamError<M extends Procedure | Query = Procedure |
|
|
|
184
185
|
/**
|
|
185
186
|
* Error class for invalid XRPC responses that fail schema validation.
|
|
186
187
|
*
|
|
187
|
-
* This is a specific type of {@link
|
|
188
|
+
* This is a specific type of {@link XrpcInvalidResponseError} that indicates the
|
|
188
189
|
* upstream server returned a response that was structurally valid but did not
|
|
189
190
|
* conform to the expected schema for the method. This likely indicates a
|
|
190
191
|
* mismatch between client and server versions or an issue with the server's
|
|
@@ -192,11 +193,10 @@ export declare class XrpcUpstreamError<M extends Procedure | Query = Procedure |
|
|
|
192
193
|
*
|
|
193
194
|
* @typeParam M - The XRPC method type
|
|
194
195
|
*/
|
|
195
|
-
export declare class
|
|
196
|
+
export declare class XrpcResponseValidationError<M extends Procedure | Query = Procedure | Query> extends XrpcInvalidResponseError<M> {
|
|
196
197
|
readonly cause: LexValidationError;
|
|
197
198
|
name: string;
|
|
198
|
-
constructor(method: M, response: Response, payload:
|
|
199
|
-
toDownstreamError(): DownstreamError;
|
|
199
|
+
constructor(method: M, response: Response, payload: XrpcUnknownResponsePayload, cause: LexValidationError);
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Error class for unexpected internal/client-side errors during XRPC requests.
|
|
@@ -246,12 +246,12 @@ export declare class XrpcFetchError<M extends Procedure | Query = Procedure | Qu
|
|
|
246
246
|
* if (result.success) {
|
|
247
247
|
* console.log(result.body) // XrpcResponse
|
|
248
248
|
* } else {
|
|
249
|
-
* // result is XrpcFailure (XrpcResponseError |
|
|
249
|
+
* // result is XrpcFailure (XrpcResponseError | XrpcInvalidResponseError | XrpcInternalError)
|
|
250
250
|
* console.error(result.error, result.message)
|
|
251
251
|
* }
|
|
252
252
|
* ```
|
|
253
253
|
*/
|
|
254
|
-
export type XrpcFailure<M extends Procedure | Query = Procedure | Query> = XrpcResponseError<M> |
|
|
254
|
+
export type XrpcFailure<M extends Procedure | Query = Procedure | Query> = XrpcResponseError<M> | XrpcInvalidResponseError<M> | XrpcInternalError<M>;
|
|
255
255
|
/**
|
|
256
256
|
* Converts an unknown error into an appropriate {@link XrpcFailure} type.
|
|
257
257
|
*
|