@atproto/lex-client 0.0.6 → 0.0.8
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 +20 -0
- package/dist/client.d.ts +5 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -8
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +2 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -1
- package/dist/errors.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +6 -6
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js +3 -3
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
- package/dist/lexicons/index.d.ts +2 -0
- package/dist/lexicons/index.d.ts.map +1 -0
- package/dist/lexicons/index.js +9 -0
- package/dist/lexicons/index.js.map +1 -0
- package/package.json +6 -6
- package/src/client.ts +6 -6
- package/src/errors.ts +3 -0
- package/src/lexicons/com/atproto/repo/listRecords.defs.ts +5 -5
- package/src/lexicons/index.ts +5 -0
- package/dist/lexicons.d.ts +0 -2
- package/dist/lexicons.d.ts.map +0 -1
- package/dist/lexicons.js +0 -6
- package/dist/lexicons.js.map +0 -1
- package/src/lexicons.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atproto/lex-client
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`d78484f`](https://github.com/bluesky-social/atproto/commit/d78484f94d8ba1352ec66030115000d515c9dafe), [`d78484f`](https://github.com/bluesky-social/atproto/commit/d78484f94d8ba1352ec66030115000d515c9dafe), [`d78484f`](https://github.com/bluesky-social/atproto/commit/d78484f94d8ba1352ec66030115000d515c9dafe), [`d78484f`](https://github.com/bluesky-social/atproto/commit/d78484f94d8ba1352ec66030115000d515c9dafe), [`d78484f`](https://github.com/bluesky-social/atproto/commit/d78484f94d8ba1352ec66030115000d515c9dafe)]:
|
|
8
|
+
- @atproto/lex-data@0.0.7
|
|
9
|
+
- @atproto/lex-schema@0.0.8
|
|
10
|
+
- @atproto/lex-json@0.0.7
|
|
11
|
+
|
|
12
|
+
## 0.0.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#4501](https://github.com/bluesky-social/atproto/pull/4501) [`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98) Thanks [@matthieusieben](https://github.com/matthieusieben)! - **breaking:** Use a record type (`com.example.record.Main`) instead of a record schema type (`typeof com.example.record.$defs.main`) as the generic parameter for `ListRecord`.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98), [`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98), [`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98), [`2f78893`](https://github.com/bluesky-social/atproto/commit/2f78893ace3bbf14d4bac36837820ddb46658c98)]:
|
|
19
|
+
- @atproto/lex-data@0.0.6
|
|
20
|
+
- @atproto/lex-schema@0.0.7
|
|
21
|
+
- @atproto/lex-json@0.0.6
|
|
22
|
+
|
|
3
23
|
## 0.0.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LexMap, LexValue } from '@atproto/lex-data';
|
|
2
2
|
import { AtIdentifierString, CidString, DidString, Infer, InferMethodInputBody, InferMethodOutputBody, InferMethodParams, InferRecordKey, LexiconRecordKey, Main, NsidString, Params, Procedure, Query, RecordSchema, Restricted, Schema } from '@atproto/lex-schema';
|
|
3
3
|
import { Agent, AgentOptions } from './agent.js';
|
|
4
|
-
import { com } from './lexicons.js';
|
|
4
|
+
import { com } from './lexicons/index.js';
|
|
5
5
|
import { LexRpcResponse, LexRpcResponseBody } from './response.js';
|
|
6
6
|
import { BinaryBodyInit, CallOptions, Service } from './types.js';
|
|
7
7
|
import { LexRpcFailure, LexRpcOptions } from './xrpc.js';
|
|
@@ -56,11 +56,11 @@ export type PutOptions<T extends RecordSchema> = PutRecordOptions & RecordKeyOpt
|
|
|
56
56
|
export type PutOutput = InferMethodOutputBody<typeof com.atproto.repo.putRecord.main, Uint8Array>;
|
|
57
57
|
export type ListOptions = ListRecordsOptions;
|
|
58
58
|
export type ListOutput<T extends RecordSchema> = InferMethodOutputBody<typeof com.atproto.repo.listRecords.main, Uint8Array> & {
|
|
59
|
-
records: ListRecord<T
|
|
59
|
+
records: ListRecord<Infer<T>>[];
|
|
60
60
|
invalid: LexMap[];
|
|
61
61
|
};
|
|
62
|
-
export type ListRecord<
|
|
63
|
-
value:
|
|
62
|
+
export type ListRecord<Value extends LexMap> = com.atproto.repo.listRecords.Record & {
|
|
63
|
+
value: Value;
|
|
64
64
|
};
|
|
65
65
|
export declare class Client implements Agent {
|
|
66
66
|
static appLabelers: readonly DidString[];
|
|
@@ -189,7 +189,7 @@ export declare class Client implements Agent {
|
|
|
189
189
|
readonly reverse: import("@atproto/lex-schema").OptionalSchema<boolean>;
|
|
190
190
|
}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
191
191
|
readonly cursor: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
192
|
-
readonly records: import("@atproto/lex-schema").ArraySchema<import("@atproto/lex-schema").RefSchema<com.atproto.repo.listRecords.$defs.
|
|
192
|
+
readonly records: import("@atproto/lex-schema").ArraySchema<import("@atproto/lex-schema").RefSchema<com.atproto.repo.listRecords.$defs.Record>>;
|
|
193
193
|
}>>, undefined>>>;
|
|
194
194
|
uploadBlob(body: BinaryBodyInit, options?: CallOptions & {
|
|
195
195
|
encoding?: `${string}/${string}`;
|
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,EAAY,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,KAAK,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EAEP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,KAAK,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,SAAS,EACT,KAAK,EACL,YAAY,EACZ,UAAU,EACV,MAAM,EAEP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEjE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAkB,MA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CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAC1C,IAAI,CAAC,CAAC,CAAC,GACP,UAAU,CAAC,iDAAiD,CAAC,EACjE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,SAAS,CAAC;IACR,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EAC3C,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EACX,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,SAAS,CAAC;IAcf,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EACrC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAkB1B"}
|
package/dist/client.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.Client = void 0;
|
|
|
4
4
|
const lex_data_1 = require("@atproto/lex-data");
|
|
5
5
|
const lex_schema_1 = require("@atproto/lex-schema");
|
|
6
6
|
const agent_js_1 = require("./agent.js");
|
|
7
|
-
const
|
|
7
|
+
const index_js_1 = require("./lexicons/index.js");
|
|
8
8
|
const util_js_1 = require("./util.js");
|
|
9
9
|
const xrpc_js_1 = require("./xrpc.js");
|
|
10
10
|
class Client {
|
|
@@ -75,7 +75,7 @@ class Client {
|
|
|
75
75
|
* @param rkey Leave `undefined` to have the server generate a TID.
|
|
76
76
|
*/
|
|
77
77
|
async createRecord(record, rkey, options) {
|
|
78
|
-
return this.xrpc(
|
|
78
|
+
return this.xrpc(index_js_1.com.atproto.repo.createRecord.main, {
|
|
79
79
|
...options,
|
|
80
80
|
body: {
|
|
81
81
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -88,7 +88,7 @@ class Client {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
async deleteRecord(collection, rkey, options) {
|
|
91
|
-
return this.xrpc(
|
|
91
|
+
return this.xrpc(index_js_1.com.atproto.repo.deleteRecord.main, {
|
|
92
92
|
...options,
|
|
93
93
|
body: {
|
|
94
94
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -100,7 +100,7 @@ class Client {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
async getRecord(collection, rkey, options) {
|
|
103
|
-
return this.xrpc(
|
|
103
|
+
return this.xrpc(index_js_1.com.atproto.repo.getRecord.main, {
|
|
104
104
|
...options,
|
|
105
105
|
params: {
|
|
106
106
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -110,7 +110,7 @@ class Client {
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
async putRecord(record, rkey, options) {
|
|
113
|
-
return this.xrpc(
|
|
113
|
+
return this.xrpc(index_js_1.com.atproto.repo.putRecord.main, {
|
|
114
114
|
...options,
|
|
115
115
|
body: {
|
|
116
116
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -124,7 +124,7 @@ class Client {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
async listRecords(nsid, options) {
|
|
127
|
-
return this.xrpc(
|
|
127
|
+
return this.xrpc(index_js_1.com.atproto.repo.listRecords.main, {
|
|
128
128
|
...options,
|
|
129
129
|
params: {
|
|
130
130
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -136,13 +136,13 @@ class Client {
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
async uploadBlob(body, options) {
|
|
139
|
-
return this.xrpc(
|
|
139
|
+
return this.xrpc(index_js_1.com.atproto.repo.uploadBlob.main, {
|
|
140
140
|
...options,
|
|
141
141
|
body,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
async getBlob(did, cid, options) {
|
|
145
|
-
return this.xrpc(
|
|
145
|
+
return this.xrpc(index_js_1.com.atproto.sync.getBlob.main, {
|
|
146
146
|
...options,
|
|
147
147
|
params: { did, cid },
|
|
148
148
|
});
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,gDAA8D;AAC9D,oDAmB4B;AAC5B,yCAA4D;AAC5D,+CAAmC;AAGnC,uCAA+C;AAC/C,uCAAwE;AAqHxE,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;IAEe,KAAK,CAAO;IACZ,OAAO,CAAS;IAChB,OAAO,CAAU;IACjB,QAAQ,CAAgB;IAExC,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;IAC7C,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IACvB,CAAC;IAED,IAAI,SAAS;QACX,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAEM,mBAAmB;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,mBAAQ,CAAC,wBAAwB,CAAC,CAAA;IAC7D,CAAC;IAEM,WAAW,CAAC,WAAgC,EAAE;QACnD,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1B,MAAS;IAET,kCAAkC;IAClC,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;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,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,SAAS,CACjB,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexError, LexMap, LexValue } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n getMain,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport { com } from './lexicons.js'\nimport { LexRpcResponse, LexRpcResponseBody } from './response.js'\nimport { BinaryBodyInit, CallOptions, Service } from './types.js'\nimport { buildAtprotoHeaders } from './util.js'\nimport { LexRpcFailure, LexRpcOptions, xrpc, xrpcSafe } from './xrpc.js'\n\nexport type {\n AtIdentifierString,\n CidString,\n DidString,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexMap,\n LexValue,\n LexiconRecordKey,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n}\n\nexport type ClientOptions = {\n labelers?: Iterable<DidString>\n headers?: HeadersInit\n service?: Service\n}\n\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: CallOptions,\n) => O | Promise<O>\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\nexport type CreateRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n validate?: boolean\n}\n\nexport type DeleteRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n}\n\nexport type GetRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n}\n\nexport type PutRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n validate?: boolean\n}\n\nexport type ListRecordsOptions = CallOptions & {\n repo?: AtIdentifierString\n limit?: number\n cursor?: string\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\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid'>\nexport type CreateOutput = InferMethodOutputBody<\n typeof com.atproto.repo.createRecord.main,\n Uint8Array\n>\n\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\nexport type DeleteOutput = InferMethodOutputBody<\n typeof com.atproto.repo.deleteRecord.main,\n Uint8Array\n>\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\nexport type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>,\n 'value'\n> & { value: Infer<T> }\n\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\nexport type PutOutput = InferMethodOutputBody<\n typeof com.atproto.repo.putRecord.main,\n Uint8Array\n>\n\nexport type ListOptions = ListRecordsOptions\nexport type ListOutput<T extends RecordSchema> = InferMethodOutputBody<\n typeof com.atproto.repo.listRecords.main,\n Uint8Array\n> & {\n records: ListRecord<T>[]\n // @NOTE Because the schema uses \"type\": \"unknown\" instead of an open union,\n // we have to use LexMap instead of TypedObject here.\n invalid: LexMap[]\n}\nexport type ListRecord<T extends RecordSchema> =\n com.atproto.repo.listRecords.DefRecord & {\n value: Infer<T>\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 public readonly agent: Agent\n public readonly headers: Headers\n public readonly service?: Service\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 get did(): DidString | undefined {\n return this.agent.did\n }\n\n get assertDid(): DidString {\n this.assertAuthenticated()\n return this.did\n }\n\n public assertAuthenticated(): asserts this is { did: DidString } {\n if (!this.did) throw new LexError('AuthenticationRequired')\n }\n\n public setLabelers(labelers: Iterable<DidString> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n public addLabelers(labelers: Iterable<DidString>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n public clearLabelers() {\n this.labelers.clear()\n }\n\n public fetchHandler(path: string, init: RequestInit): 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 * @throws {LexRpcFailure<M>} when the request fails or the response is an error\n */\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>> {\n return xrpcSafe(this, ns, options)\n }\n\n /**\n * @param rkey Leave `undefined` to have the server generate a TID.\n */\n public async createRecord(\n record: { $type: NsidString } & LexMap,\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 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 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 async putRecord(\n record: { $type: NsidString } & LexMap,\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 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 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 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 public async call<const T extends Query>(\n ns: NonNullable<unknown> extends InferMethodParams<T>\n ? Main<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<LexRpcResponseBody<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 ? InferMethodParams<T>\n : never,\n options?: CallOptions,\n ): Promise<\n T extends Action\n ? InferActionOutput<T>\n : T extends Procedure\n ? LexRpcResponseBody<T>\n : T extends Query\n ? LexRpcResponseBody<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 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)\n if (options.validateRequest) schema.assert(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 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 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.parse(response.body.value) as Infer<T>\n return { ...response.body, value }\n }\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)\n if (options.validateRequest) schema.assert(record)\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\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<T>[] = []\n const invalid: LexMap[] = []\n\n for (const record of body.records) {\n const parsed = (schema as Schema<Infer<T>>).safeParse(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)\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":";;;AAAA,gDAA8D;AAC9D,oDAmB4B;AAC5B,yCAA4D;AAC5D,kDAAyC;AAGzC,uCAA+C;AAC/C,uCAAwE;AAqHxE,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;IAEe,KAAK,CAAO;IACZ,OAAO,CAAS;IAChB,OAAO,CAAU;IACjB,QAAQ,CAAgB;IAExC,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;IAC7C,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IACvB,CAAC;IAED,IAAI,SAAS;QACX,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAEM,mBAAmB;QACxB,IAAI,CAAC,IAAI,C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,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACtC,CAAC;;AAjXH,wBAkXC;AAED,SAAS,mBAAmB,CAC1B,MAAS;IAET,kCAAkC;IAClC,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;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,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,SAAS,CACjB,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexError, LexMap, LexValue } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n getMain,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport { com } from './lexicons/index.js'\nimport { LexRpcResponse, LexRpcResponseBody } from './response.js'\nimport { BinaryBodyInit, CallOptions, Service } from './types.js'\nimport { buildAtprotoHeaders } from './util.js'\nimport { LexRpcFailure, LexRpcOptions, xrpc, xrpcSafe } from './xrpc.js'\n\nexport type {\n AtIdentifierString,\n CidString,\n DidString,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexMap,\n LexValue,\n LexiconRecordKey,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n}\n\nexport type ClientOptions = {\n labelers?: Iterable<DidString>\n headers?: HeadersInit\n service?: Service\n}\n\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: CallOptions,\n) => O | Promise<O>\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\nexport type CreateRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n validate?: boolean\n}\n\nexport type DeleteRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n}\n\nexport type GetRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n}\n\nexport type PutRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n validate?: boolean\n}\n\nexport type ListRecordsOptions = CallOptions & {\n repo?: AtIdentifierString\n limit?: number\n cursor?: string\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\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid'>\nexport type CreateOutput = InferMethodOutputBody<\n typeof com.atproto.repo.createRecord.main,\n Uint8Array\n>\n\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\nexport type DeleteOutput = InferMethodOutputBody<\n typeof com.atproto.repo.deleteRecord.main,\n Uint8Array\n>\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\nexport type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>,\n 'value'\n> & { value: Infer<T> }\n\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\nexport type PutOutput = InferMethodOutputBody<\n typeof com.atproto.repo.putRecord.main,\n Uint8Array\n>\n\nexport type ListOptions = ListRecordsOptions\nexport type ListOutput<T extends RecordSchema> = InferMethodOutputBody<\n typeof com.atproto.repo.listRecords.main,\n Uint8Array\n> & {\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 TypedObject here.\n invalid: LexMap[]\n}\nexport type ListRecord<Value extends LexMap> =\n com.atproto.repo.listRecords.Record & {\n value: Value\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 public readonly agent: Agent\n public readonly headers: Headers\n public readonly service?: Service\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 get did(): DidString | undefined {\n return this.agent.did\n }\n\n get assertDid(): DidString {\n this.assertAuthenticated()\n return this.did\n }\n\n public assertAuthenticated(): asserts this is { did: DidString } {\n if (!this.did) throw new LexError('AuthenticationRequired')\n }\n\n public setLabelers(labelers: Iterable<DidString> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n public addLabelers(labelers: Iterable<DidString>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n public clearLabelers() {\n this.labelers.clear()\n }\n\n public fetchHandler(path: string, init: RequestInit): 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 * @throws {LexRpcFailure<M>} when the request fails or the response is an error\n */\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>> {\n return xrpcSafe(this, ns, options)\n }\n\n /**\n * @param rkey Leave `undefined` to have the server generate a TID.\n */\n public async createRecord(\n record: { $type: NsidString } & LexMap,\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 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 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 async putRecord(\n record: { $type: NsidString } & LexMap,\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 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 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 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 public async call<const T extends Query>(\n ns: NonNullable<unknown> extends InferMethodParams<T>\n ? Main<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<LexRpcResponseBody<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 ? InferMethodParams<T>\n : never,\n options?: CallOptions,\n ): Promise<\n T extends Action\n ? InferActionOutput<T>\n : T extends Procedure\n ? LexRpcResponseBody<T>\n : T extends Query\n ? LexRpcResponseBody<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 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)\n if (options.validateRequest) schema.assert(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 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 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.parse(response.body.value) as Infer<T>\n return { ...response.body, value }\n }\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)\n if (options.validateRequest) schema.assert(record)\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\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 as Schema<Infer<T>>).safeParse(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)\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,6 +1,8 @@
|
|
|
1
1
|
import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data';
|
|
2
2
|
import { l } from '@atproto/lex-schema';
|
|
3
3
|
import { Payload } from './util.js';
|
|
4
|
+
export { LexError };
|
|
5
|
+
export type { LexErrorCode, LexErrorData };
|
|
4
6
|
export type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<LexErrorData<N>, 'application/json'>;
|
|
5
7
|
export declare class LexRpcError<N extends LexErrorCode = LexErrorCode> extends LexError<N> {
|
|
6
8
|
name: string;
|
|
@@ -78,5 +80,4 @@ export declare class LexRpcUnexpectedError extends LexRpcError<'InternalServerEr
|
|
|
78
80
|
toResponse(): Response;
|
|
79
81
|
static from(cause: unknown, message?: string): LexRpcUnexpectedError;
|
|
80
82
|
}
|
|
81
|
-
export {};
|
|
82
83
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -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,MAAM,MAAM,kBAAkB,CA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B,SAAQ,WAAW,CAAC,CAAC,CACrB,YAAW,mBAAmB,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAI,EAAG,qBAAqB,CAAS;IAGrC,QAAQ,CAAC,QAAQ,EAAE;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,EAAE,OAAO,CAAA;QAChB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;KACxB,CAAA;gBAGC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAC9C,OAAO,EAAE,OAAO,GAAG,IAAI,EACvB,OAAO,CAAC,EAAE,YAAY;IAUxB,QAAQ,CAAC,OAAO,EAAG,KAAK,CAAS;IAEjC,IAAI,MAAM,IAAI,IAAI,CAEjB;IAED,aAAa,IAAI,KAAK;IAItB,WAAW,IAAI,OAAO;IAKtB,UAAU,IAAI,QAAQ;CAGvB;AAED,qBAAa,qBACX,SAAQ,WAAW,CAAC,qBAAqB,CACzC,YAAW,mBAAmB,CAAC,qBAAqB,EAAE,OAAO,CAAC;IAE9D,IAAI,EAAG,uBAAuB,CAAS;IAEvC,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC;IAItE,QAAQ,CAAC,OAAO,SAAQ;IAExB,IAAI,MAAM,YAET;IAED,aAAa,IAAI,KAAK;IAItB,WAAW,IAAI,OAAO;IAItB,UAAU,IAAI,QAAQ;IAItB,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,MAEgB,GACxB,qBAAqB;CAIzB"}
|
package/dist/errors.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LexRpcUnexpectedError = exports.LexRpcUpstreamError = exports.LexRpcResponseError = exports.LexRpcError = void 0;
|
|
3
|
+
exports.LexRpcUnexpectedError = exports.LexRpcUpstreamError = exports.LexRpcResponseError = exports.LexRpcError = exports.LexError = void 0;
|
|
4
4
|
exports.isLexRpcErrorPayload = isLexRpcErrorPayload;
|
|
5
5
|
const lex_data_1 = require("@atproto/lex-data");
|
|
6
|
+
Object.defineProperty(exports, "LexError", { enumerable: true, get: function () { return lex_data_1.LexError; } });
|
|
6
7
|
const lex_schema_1 = require("@atproto/lex-schema");
|
|
7
8
|
class LexRpcError extends lex_data_1.LexError {
|
|
8
9
|
name = 'LexRpcError';
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;
|
|
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,CAAC;CACF;AAZD,kCAYC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAClC,OAAuB;IAEvB,OAAO,CACL,OAAO,KAAK,IAAI;QAChB,OAAO,CAAC,QAAQ,KAAK,kBAAkB;QACvC,cAAC,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CACrC,CAAA;AACH,CAAC;AAWD;;;GAGG;AACH,MAAa,mBAIX,SAAQ,WAAc;IAMX;IACA;IACA;IACA;IANX,IAAI,GAAG,qBAAqB,CAAA;IAE5B,YACW,MAAS,EACT,MAAc,EACd,OAAgB,E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ACxD,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"]}
|
|
@@ -14,7 +14,7 @@ declare const main: l.Query<"com.atproto.repo.listRecords", l.ParamsSchema<{
|
|
|
14
14
|
readonly reverse: l.OptionalSchema<boolean>;
|
|
15
15
|
}>, l.Payload<"application/json", l.ObjectSchema<{
|
|
16
16
|
readonly cursor: l.OptionalSchema<string>;
|
|
17
|
-
readonly records: l.ArraySchema<l.RefSchema<
|
|
17
|
+
readonly records: l.ArraySchema<l.RefSchema<Record$0>>;
|
|
18
18
|
}>>, undefined>;
|
|
19
19
|
export { main };
|
|
20
20
|
export type Params = l.InferMethodParams<typeof main>;
|
|
@@ -32,15 +32,15 @@ export declare const $lxm: "com.atproto.repo.listRecords", $params: l.ParamsSche
|
|
|
32
32
|
readonly reverse: l.OptionalSchema<boolean>;
|
|
33
33
|
}>, $output: l.Payload<"application/json", l.ObjectSchema<{
|
|
34
34
|
readonly cursor: l.OptionalSchema<string>;
|
|
35
|
-
readonly records: l.ArraySchema<l.RefSchema<
|
|
35
|
+
readonly records: l.ArraySchema<l.RefSchema<Record$0>>;
|
|
36
36
|
}>>;
|
|
37
|
-
type
|
|
37
|
+
type Record$0 = {
|
|
38
38
|
$type?: 'com.atproto.repo.listRecords#record';
|
|
39
39
|
uri: l.AtUriString;
|
|
40
40
|
cid: l.CidString;
|
|
41
41
|
value: l.UnknownObject;
|
|
42
42
|
};
|
|
43
|
-
export type {
|
|
44
|
-
declare const
|
|
45
|
-
export {
|
|
43
|
+
export type { Record$0 as Record };
|
|
44
|
+
declare const record$0: l.TypedObjectSchema<"com.atproto.repo.listRecords#record", l.Validator<Omit<Record$0, "$type">>>;
|
|
45
|
+
export { record$0 as record };
|
|
46
46
|
//# sourceMappingURL=listRecords.defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listRecords.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/listRecords.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,iCAAiC,CAAA;AAE5C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,sGAAsG;AACtG,QAAA,MAAM,IAAI;;;;;;;;;;;;;eAmBP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,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,gCAA0B,EACzC,OAAO;;;;;;;;;;EAAkB,EACzB,OAAO;;;GAAc,CAAA;AAEvB,KAAK,
|
|
1
|
+
{"version":3,"file":"listRecords.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/listRecords.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,iCAAiC,CAAA;AAE5C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,sGAAsG;AACtG,QAAA,MAAM,IAAI;;;;;;;;;;;;;eAmBP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,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,gCAA0B,EACzC,OAAO;;;;;;;;;;EAAkB,EACzB,OAAO;;;GAAc,CAAA;AAEvB,KAAK,QAAQ,GAAG;IACd,KAAK,CAAC,EAAE,qCAAqC,CAAA;IAC7C,GAAG,EAAE,CAAC,CAAC,WAAW,CAAA;IAClB,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;IAChB,KAAK,EAAE,CAAC,CAAC,aAAa,CAAA;CACvB,CAAA;AAED,YAAY,EAAE,QAAQ,IAAI,MAAM,EAAE,CAAA;AAElC,QAAA,MAAM,QAAQ,kGAQb,CAAA;AAED,OAAO,EAAE,QAAQ,IAAI,MAAM,EAAE,CAAA"}
|
|
@@ -22,15 +22,15 @@ lex_schema_1.l.query($nsid,
|
|
|
22
22
|
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
23
23
|
cursor: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
24
24
|
records: /*#__PURE__*/ lex_schema_1.l.array(
|
|
25
|
-
/*#__PURE__*/ lex_schema_1.l.ref((() =>
|
|
25
|
+
/*#__PURE__*/ lex_schema_1.l.ref((() => record$0))),
|
|
26
26
|
}));
|
|
27
27
|
exports.main = main;
|
|
28
28
|
exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$output = main.output;
|
|
29
|
-
const
|
|
29
|
+
const record$0 = /*#__PURE__*/ lex_schema_1.l.typedObject($nsid, 'record',
|
|
30
30
|
/*#__PURE__*/ lex_schema_1.l.object({
|
|
31
31
|
uri: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-uri' }),
|
|
32
32
|
cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
|
|
33
33
|
value: /*#__PURE__*/ lex_schema_1.l.unknownObject(),
|
|
34
34
|
}));
|
|
35
|
-
exports.record =
|
|
35
|
+
exports.record = record$0;
|
|
36
36
|
//# sourceMappingURL=listRecords.defs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listRecords.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/listRecords.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAAuC;AAEvC,MAAM,KAAK,GAAG,8BAA8B,CAAA;AAEnC,sBAAK;AAEd,sGAAsG;AACtG,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,KAAK,CACL,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,KAAK,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAC7B,aAAa,CAAC,cAAC,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACnE;IACD,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,OAAO,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,OAAO,EAAE,CAAC;CAC7D,CAAC;AACF,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;IAC1D,OAAO,EAAE,aAAa,CAAC,cAAC,CAAC,KAAK;IAC5B,aAAa,CAAC,cAAC,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"listRecords.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/listRecords.defs.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AM,CAAA;AAWvB,MAAM,QAAQ,GAAG,aAAa,CAAC,cAAC,CAAC,WAAW,CAC1C,KAAK,EACL,QAAQ;AACR,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACjD,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,KAAK,EAAE,aAAa,CAAC,cAAC,CAAC,aAAa,EAAE;CACvC,CAAC,CACH,CAAA;AAEoB,0BAAM","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.repo.listRecords'\n\nexport { $nsid }\n\n/** List a range of records in a repository, matching a specific collection. Does not require auth. */\nconst main =\n /*#__PURE__*/\n l.query(\n $nsid,\n /*#__PURE__*/ l.params({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n limit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.integer({ minimum: 1, maximum: 100, default: 50 }),\n ),\n cursor: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n reverse: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),\n }),\n /*#__PURE__*/ l.jsonPayload({\n cursor: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n records: /*#__PURE__*/ l.array(\n /*#__PURE__*/ l.ref<Record$0>((() => record$0) as any),\n ),\n }),\n )\nexport { main }\n\nexport type Params = l.InferMethodParams<typeof main>\nexport type Output = l.InferMethodOutput<typeof main>\nexport type OutputBody = l.InferMethodOutputBody<typeof main>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = main.parameters,\n $output = main.output\n\ntype Record$0 = {\n $type?: 'com.atproto.repo.listRecords#record'\n uri: l.AtUriString\n cid: l.CidString\n value: l.UnknownObject\n}\n\nexport type { Record$0 as Record }\n\nconst record$0 = /*#__PURE__*/ l.typedObject<Record$0>(\n $nsid,\n 'record',\n /*#__PURE__*/ l.object({\n uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n value: /*#__PURE__*/ l.unknownObject(),\n }),\n)\n\nexport { record$0 as record }\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.com = void 0;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
exports.com = tslib_1.__importStar(require("./com.js"));
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,wDAA+B","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as com from './com.js'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "HTTP client for interacting with Lexicon based APIs",
|
|
6
6
|
"keywords": [
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"tslib": "^2.8.1",
|
|
40
|
-
"@atproto/lex-data": "0.0.
|
|
41
|
-
"@atproto/lex-json": "0.0.
|
|
42
|
-
"@atproto/lex-schema": "0.0.
|
|
40
|
+
"@atproto/lex-data": "0.0.7",
|
|
41
|
+
"@atproto/lex-json": "0.0.7",
|
|
42
|
+
"@atproto/lex-schema": "0.0.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"vitest": "^4.0.16",
|
|
46
|
-
"@atproto/lex-cbor": "0.0.
|
|
47
|
-
"@atproto/lex-builder": "0.0.
|
|
46
|
+
"@atproto/lex-cbor": "0.0.7",
|
|
47
|
+
"@atproto/lex-builder": "0.0.10"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"prebuild": "node ./scripts/lex-build.mjs",
|
package/src/client.ts
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
getMain,
|
|
21
21
|
} from '@atproto/lex-schema'
|
|
22
22
|
import { Agent, AgentOptions, buildAgent } from './agent.js'
|
|
23
|
-
import { com } from './lexicons.js'
|
|
23
|
+
import { com } from './lexicons/index.js'
|
|
24
24
|
import { LexRpcResponse, LexRpcResponseBody } from './response.js'
|
|
25
25
|
import { BinaryBodyInit, CallOptions, Service } from './types.js'
|
|
26
26
|
import { buildAtprotoHeaders } from './util.js'
|
|
@@ -131,14 +131,14 @@ export type ListOutput<T extends RecordSchema> = InferMethodOutputBody<
|
|
|
131
131
|
typeof com.atproto.repo.listRecords.main,
|
|
132
132
|
Uint8Array
|
|
133
133
|
> & {
|
|
134
|
-
records: ListRecord<T
|
|
134
|
+
records: ListRecord<Infer<T>>[]
|
|
135
135
|
// @NOTE Because the schema uses "type": "unknown" instead of an open union,
|
|
136
136
|
// we have to use LexMap instead of TypedObject here.
|
|
137
137
|
invalid: LexMap[]
|
|
138
138
|
}
|
|
139
|
-
export type ListRecord<
|
|
140
|
-
com.atproto.repo.listRecords.
|
|
141
|
-
value:
|
|
139
|
+
export type ListRecord<Value extends LexMap> =
|
|
140
|
+
com.atproto.repo.listRecords.Record & {
|
|
141
|
+
value: Value
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
export class Client implements Agent {
|
|
@@ -497,7 +497,7 @@ export class Client implements Agent {
|
|
|
497
497
|
const schema = getMain(ns)
|
|
498
498
|
const { body } = await this.listRecords(schema.$type, options)
|
|
499
499
|
|
|
500
|
-
const records: ListRecord<T
|
|
500
|
+
const records: ListRecord<Infer<T>>[] = []
|
|
501
501
|
const invalid: LexMap[] = []
|
|
502
502
|
|
|
503
503
|
for (const record of body.records) {
|
package/src/errors.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data'
|
|
|
2
2
|
import { l } from '@atproto/lex-schema'
|
|
3
3
|
import { Payload } from './util.js'
|
|
4
4
|
|
|
5
|
+
export { LexError }
|
|
6
|
+
export type { LexErrorCode, LexErrorData }
|
|
7
|
+
|
|
5
8
|
export type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<
|
|
6
9
|
LexErrorData<N>,
|
|
7
10
|
'application/json'
|
|
@@ -25,7 +25,7 @@ const main =
|
|
|
25
25
|
/*#__PURE__*/ l.jsonPayload({
|
|
26
26
|
cursor: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),
|
|
27
27
|
records: /*#__PURE__*/ l.array(
|
|
28
|
-
/*#__PURE__*/ l.ref<
|
|
28
|
+
/*#__PURE__*/ l.ref<Record$0>((() => record$0) as any),
|
|
29
29
|
),
|
|
30
30
|
}),
|
|
31
31
|
)
|
|
@@ -39,16 +39,16 @@ export const $lxm = /*#__PURE__*/ main.nsid,
|
|
|
39
39
|
$params = main.parameters,
|
|
40
40
|
$output = main.output
|
|
41
41
|
|
|
42
|
-
type
|
|
42
|
+
type Record$0 = {
|
|
43
43
|
$type?: 'com.atproto.repo.listRecords#record'
|
|
44
44
|
uri: l.AtUriString
|
|
45
45
|
cid: l.CidString
|
|
46
46
|
value: l.UnknownObject
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export type {
|
|
49
|
+
export type { Record$0 as Record }
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const record$0 = /*#__PURE__*/ l.typedObject<Record$0>(
|
|
52
52
|
$nsid,
|
|
53
53
|
'record',
|
|
54
54
|
/*#__PURE__*/ l.object({
|
|
@@ -58,4 +58,4 @@ const def$0 = /*#__PURE__*/ l.typedObject<Def$0>(
|
|
|
58
58
|
}),
|
|
59
59
|
)
|
|
60
60
|
|
|
61
|
-
export {
|
|
61
|
+
export { record$0 as record }
|
package/dist/lexicons.d.ts
DELETED
package/dist/lexicons.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lexicons.d.ts","sourceRoot":"","sources":["../src/lexicons.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA"}
|
package/dist/lexicons.js
DELETED
package/dist/lexicons.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lexicons.js","sourceRoot":"","sources":["../src/lexicons.ts"],"names":[],"mappings":";;;;AAAA,iEAAwC","sourcesContent":["export * as com from './lexicons/com.js'\n"]}
|
package/src/lexicons.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as com from './lexicons/com.js'
|