@atproto/lex-client 0.0.3 → 0.0.5
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 +36 -0
- package/dist/agent.d.ts +9 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js.map +1 -1
- package/dist/client.d.ts +32 -96
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +31 -31
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/createRecord.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +5 -6
- package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/getRecord.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +5 -6
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/putRecord.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +3 -5
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/sync/getBlob.d.ts +3 -0
- package/dist/lexicons/com/atproto/sync/getBlob.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts +25 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.js +27 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.js +10 -0
- package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -0
- package/dist/lexicons/com/atproto/sync.d.ts +2 -0
- package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync.js +9 -0
- package/dist/lexicons/com/atproto/sync.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +1 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -1
- package/dist/lexicons/com/atproto.js +2 -1
- package/dist/lexicons/com/atproto.js.map +1 -1
- package/dist/lexicons.d.ts +2 -0
- package/dist/lexicons.d.ts.map +1 -0
- package/dist/lexicons.js +6 -0
- package/dist/lexicons.js.map +1 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +14 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +65 -0
- package/dist/util.js.map +1 -0
- package/dist/xrpc-error.d.ts +87 -0
- package/dist/xrpc-error.d.ts.map +1 -0
- package/dist/xrpc-error.js +127 -0
- package/dist/xrpc-error.js.map +1 -0
- package/dist/xrpc-response.d.ts +35 -0
- package/dist/xrpc-response.d.ts.map +1 -0
- package/dist/xrpc-response.js +140 -0
- package/dist/xrpc-response.js.map +1 -0
- package/dist/xrpc.d.ts +29 -32
- package/dist/xrpc.d.ts.map +1 -1
- package/dist/xrpc.js +119 -125
- package/dist/xrpc.js.map +1 -1
- package/package.json +6 -6
- package/src/agent.ts +12 -12
- package/src/client.ts +92 -77
- package/src/index.ts +0 -2
- package/src/lexicons/com/atproto/repo/createRecord.defs.ts +9 -8
- package/src/lexicons/com/atproto/repo/deleteRecord.defs.ts +9 -8
- package/src/lexicons/com/atproto/repo/getRecord.defs.ts +7 -7
- package/src/lexicons/com/atproto/repo/listRecords.defs.ts +7 -6
- package/src/lexicons/com/atproto/repo/putRecord.defs.ts +9 -8
- package/src/lexicons/com/atproto/repo/uploadBlob.defs.ts +9 -8
- package/src/lexicons/com/atproto/sync/getBlob.defs.ts +37 -0
- package/src/lexicons/com/atproto/sync/getBlob.ts +6 -0
- package/src/lexicons/com/atproto/sync.ts +5 -0
- package/src/lexicons/com/atproto.ts +1 -0
- package/src/lexicons.ts +1 -0
- package/src/types.ts +27 -0
- package/src/util.ts +84 -0
- package/src/xrpc-error.ts +195 -0
- package/src/xrpc-response.ts +213 -0
- package/src/xrpc.ts +209 -220
- package/dist/error.d.ts +0 -66
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -100
- package/dist/error.js.map +0 -1
- package/dist/response.d.ts +0 -21
- package/dist/response.d.ts.map +0 -1
- package/dist/response.js +0 -31
- package/dist/response.js.map +0 -1
- package/src/error.ts +0 -145
- package/src/response.ts +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @atproto/lex-client
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Complete rework of the error mechanics
|
|
8
|
+
|
|
9
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add support for `uploadBlob` and `getBlob` methods
|
|
10
|
+
|
|
11
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Validate records when `validateRequest` is set when calling `create` and `put` methods.
|
|
12
|
+
|
|
13
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Export `FetchHandler` as a distinct type
|
|
14
|
+
|
|
15
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - No longer validate records when `validate` option is set in `create()` method. Use `validateRequest` option for that purpose.
|
|
16
|
+
|
|
17
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Rename `XrpcFailure` error name field to `error` for consistency with XRPC error payloads
|
|
18
|
+
|
|
19
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Allow specifying request content-type through the `encoding` option
|
|
20
|
+
|
|
21
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Improve handling of binary payloads
|
|
22
|
+
|
|
23
|
+
- [#4457](https://github.com/bluesky-social/atproto/pull/4457) [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove `createRecordsSafe`, `deleteRecordsSafe`, `getRecordsSafe` and `putRecordsSafe` methods
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece), [`e6b6107`](https://github.com/bluesky-social/atproto/commit/e6b6107e028fee964972274b71f5da1329a7bece)]:
|
|
26
|
+
- @atproto/lex-data@0.0.4
|
|
27
|
+
- @atproto/lex-schema@0.0.5
|
|
28
|
+
- @atproto/lex-json@0.0.4
|
|
29
|
+
|
|
30
|
+
## 0.0.4
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`693784c`](https://github.com/bluesky-social/atproto/commit/693784c3a0dee4b6a29aa1e018fce682dcae148f)]:
|
|
35
|
+
- @atproto/lex-data@0.0.3
|
|
36
|
+
- @atproto/lex-json@0.0.3
|
|
37
|
+
- @atproto/lex-schema@0.0.4
|
|
38
|
+
|
|
3
39
|
## 0.0.3
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { DidString } from '@atproto/lex-schema';
|
|
2
|
+
export type FetchHandler = (
|
|
3
|
+
/**
|
|
4
|
+
* The URL (pathname + query parameters) to make the request to, without the
|
|
5
|
+
* origin. The origin (protocol, hostname, and port) must be added by this
|
|
6
|
+
* {@link FetchHandler}, typically based on authentication or other factors.
|
|
7
|
+
*/
|
|
8
|
+
path: string, init: RequestInit) => Promise<Response>;
|
|
2
9
|
export interface Agent {
|
|
3
|
-
did?: DidString;
|
|
4
|
-
fetchHandler:
|
|
5
|
-
/**
|
|
6
|
-
* The URL (pathname + query parameters) to make the request to, without the
|
|
7
|
-
* origin. The origin (protocol, hostname, and port) must be added by this
|
|
8
|
-
* {@link FetchHandler}, typically based on authentication or other factors.
|
|
9
|
-
*/
|
|
10
|
-
path: string, init: RequestInit) => Promise<Response>;
|
|
10
|
+
readonly did?: DidString;
|
|
11
|
+
fetchHandler: FetchHandler;
|
|
11
12
|
}
|
|
12
13
|
export type AgentConfig = {
|
|
13
14
|
/**
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,MAAM,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,MAAM,MAAM,YAAY,GAAG;AACzB;;;;GAIG;AACH,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAA;IACxB,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,CAAC,EAAE,SAAS,CAAA;IAEf;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,GAAG,CAAA;IAErB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,GAAG,CAAA;AAErD,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,KAAK,CAqBvD"}
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;AAyCA,gCAqBC;AArBD,SAAgB,UAAU,CAAC,OAAqB;IAC9C,MAAM,MAAM,GACV,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,GAAG;QACnD,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;QACtC,CAAC,CAAC,OAAO,CAAA;IAEb,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,MAAM,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAA;IACrE,CAAC;IAED,OAAO;QACL,IAAI,GAAG;YACL,OAAO,MAAM,CAAC,GAAG,CAAA;QACnB,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI;YAC3B,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { DidString } from '@atproto/lex-schema'\n\nexport
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;AAyCA,gCAqBC;AArBD,SAAgB,UAAU,CAAC,OAAqB;IAC9C,MAAM,MAAM,GACV,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,GAAG;QACnD,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;QACtC,CAAC,CAAC,OAAO,CAAA;IAEb,MAAM,EAAE,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,MAAM,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAA;IACrE,CAAC;IAED,OAAO;QACL,IAAI,GAAG;YACL,OAAO,MAAM,CAAC,GAAG,CAAA;QACnB,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI;YAC3B,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { DidString } from '@atproto/lex-schema'\n\nexport type FetchHandler = (\n /**\n * The URL (pathname + query parameters) to make the request to, without the\n * origin. The origin (protocol, hostname, and port) must be added by this\n * {@link FetchHandler}, typically based on authentication or other factors.\n */\n path: string,\n init: RequestInit,\n) => Promise<Response>\n\nexport interface Agent {\n readonly did?: DidString\n fetchHandler: FetchHandler\n}\n\nexport type AgentConfig = {\n /**\n * The identifier (DID) of the user represented by this agent.\n */\n did?: DidString\n\n /**\n * The service URL to make requests to. This can be a string, URL, or a\n * function that returns a string or URL. This is useful for dynamic URLs,\n * such as a service URL that changes based on authentication.\n */\n service: string | URL\n\n /**\n * Bring your own fetch implementation. Typically useful for testing, logging,\n * mocking, or adding retries, session management, signatures, proof of\n * possession (DPoP), SSRF protection, etc. Defaults to the global `fetch`\n * function.\n */\n fetch?: typeof globalThis.fetch\n}\n\nexport type AgentOptions = AgentConfig | string | URL\n\nexport function buildAgent(options: AgentOptions): Agent {\n const config: AgentConfig =\n typeof options === 'string' || options instanceof URL\n ? { did: undefined, service: options }\n : options\n\n const { service, fetch = globalThis.fetch } = config\n\n if (typeof fetch !== 'function') {\n throw new TypeError('fetch() is not available in this environment')\n }\n\n return {\n get did() {\n return config.did\n },\n\n async fetchHandler(path, init) {\n return fetch(new URL(path, service), init)\n },\n }\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { LexMap } from '@atproto/lex-data';
|
|
2
|
-
import { AtIdentifierString, DidString, Infer,
|
|
2
|
+
import { AtIdentifierString, CidString, DidString, Infer, InferMethodInputBody, InferMethodOutputBody, InferMethodParams, InferRecordKey, LexiconRecordKey, NsidString, Procedure, Query, RecordSchema, Restricted } from '@atproto/lex-schema';
|
|
3
3
|
import { Agent, AgentOptions } from './agent.js';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { XrpcResponse, XrpcResponseBody } from './
|
|
7
|
-
import { CallOptions, Namespace, Service } from './types.js';
|
|
8
|
-
import { XrpcOptions } from './xrpc.js';
|
|
4
|
+
import { com } from './lexicons.js';
|
|
5
|
+
import { BinaryBodyInit, CallOptions, Namespace, Service } from './types.js';
|
|
6
|
+
import { XrpcFailure, XrpcOptions, XrpcResponse, XrpcResponseBody } from './xrpc.js';
|
|
9
7
|
export type ClientOptions = {
|
|
10
8
|
labelers?: Iterable<DidString>;
|
|
11
9
|
headers?: HeadersInit;
|
|
@@ -45,17 +43,17 @@ export type RecordKeyOptions<T extends RecordSchema, AlsoOptionalWhenRecordKeyIs
|
|
|
45
43
|
rkey: InferRecordKey<T>;
|
|
46
44
|
};
|
|
47
45
|
export type CreateOptions<T extends RecordSchema> = CreateRecordOptions & RecordKeyOptions<T, 'tid'>;
|
|
48
|
-
export type CreateOutput =
|
|
46
|
+
export type CreateOutput = InferMethodOutputBody<typeof com.atproto.repo.createRecord.main, Uint8Array>;
|
|
49
47
|
export type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions & RecordKeyOptions<T>;
|
|
50
|
-
export type DeleteOutput =
|
|
48
|
+
export type DeleteOutput = InferMethodOutputBody<typeof com.atproto.repo.deleteRecord.main, Uint8Array>;
|
|
51
49
|
export type GetOptions<T extends RecordSchema> = GetRecordOptions & RecordKeyOptions<T>;
|
|
52
|
-
export type GetOutput<T extends RecordSchema> = Omit<
|
|
50
|
+
export type GetOutput<T extends RecordSchema> = Omit<InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>, 'value'> & {
|
|
53
51
|
value: Infer<T>;
|
|
54
52
|
};
|
|
55
53
|
export type PutOptions<T extends RecordSchema> = PutRecordOptions & RecordKeyOptions<T>;
|
|
56
|
-
export type PutOutput =
|
|
54
|
+
export type PutOutput = InferMethodOutputBody<typeof com.atproto.repo.putRecord.main, Uint8Array>;
|
|
57
55
|
export type ListOptions = ListRecordsOptions;
|
|
58
|
-
export type ListOutput<T extends RecordSchema> =
|
|
56
|
+
export type ListOutput<T extends RecordSchema> = InferMethodOutputBody<typeof com.atproto.repo.listRecords.main, Uint8Array> & {
|
|
59
57
|
records: ListRecord<T>[];
|
|
60
58
|
invalid: LexMap[];
|
|
61
59
|
};
|
|
@@ -84,10 +82,13 @@ export declare class Client implements Agent {
|
|
|
84
82
|
addLabelers(labelers: Iterable<DidString>): void;
|
|
85
83
|
clearLabelers(): void;
|
|
86
84
|
fetchHandler(path: string, init: RequestInit): Promise<Response>;
|
|
85
|
+
/**
|
|
86
|
+
* @throws {XrpcFailure<M>} when the request fails or the response is an error
|
|
87
|
+
*/
|
|
87
88
|
xrpc<const M extends Query | Procedure>(ns: NonNullable<unknown> extends XrpcOptions<M> ? Namespace<M> : Restricted<'This XRPC method requires an "options" argument'>): Promise<XrpcResponse<M>>;
|
|
88
89
|
xrpc<const M extends Query | Procedure>(ns: Namespace<M>, options: XrpcOptions<M>): Promise<XrpcResponse<M>>;
|
|
89
|
-
xrpcSafe<const M extends Query | Procedure>(ns: NonNullable<unknown> extends XrpcOptions<M> ? Namespace<M> : Restricted<'This XRPC method requires an "options" argument'>): Promise<XrpcResponse<M> |
|
|
90
|
-
xrpcSafe<const M extends Query | Procedure>(ns: Namespace<M>, options: XrpcOptions<M>): Promise<XrpcResponse<M> |
|
|
90
|
+
xrpcSafe<const M extends Query | Procedure>(ns: NonNullable<unknown> extends XrpcOptions<M> ? Namespace<M> : Restricted<'This XRPC method requires an "options" argument'>): Promise<XrpcResponse<M> | XrpcFailure<M>>;
|
|
91
|
+
xrpcSafe<const M extends Query | Procedure>(ns: Namespace<M>, options: XrpcOptions<M>): Promise<XrpcResponse<M> | XrpcFailure<M>>;
|
|
91
92
|
/**
|
|
92
93
|
* @param rkey Leave `undefined` to have the server generate a TID.
|
|
93
94
|
*/
|
|
@@ -114,27 +115,6 @@ export declare class Client implements Agent {
|
|
|
114
115
|
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
115
116
|
readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
116
117
|
}>>, readonly ["InvalidSwap"]>>>;
|
|
117
|
-
createRecordsSafe(...args: Parameters<Client['createRecord']>): Promise<import("./error.js").XrpcFailure<"Unknown", import("./error.js").XrpcResponseError<string, import("./error.js").XrpcErrorBody<string>>> | import("./error.js").XrpcFailure<"UnexpectedError", unknown> | XrpcResponse<Procedure<"com.atproto.repo.createRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
118
|
-
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
119
|
-
readonly format: "at-identifier";
|
|
120
|
-
}>;
|
|
121
|
-
readonly collection: import("@atproto/lex-schema").StringSchema<{
|
|
122
|
-
readonly format: "nsid";
|
|
123
|
-
}>;
|
|
124
|
-
readonly rkey: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
125
|
-
readonly validate: import("@atproto/lex-schema").OptionalSchema<boolean>;
|
|
126
|
-
readonly record: import("@atproto/lex-schema").UnknownObjectSchema;
|
|
127
|
-
readonly swapCommit: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
128
|
-
}>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
129
|
-
readonly uri: import("@atproto/lex-schema").StringSchema<{
|
|
130
|
-
readonly format: "at-uri";
|
|
131
|
-
}>;
|
|
132
|
-
readonly cid: import("@atproto/lex-schema").StringSchema<{
|
|
133
|
-
readonly format: "cid";
|
|
134
|
-
}>;
|
|
135
|
-
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
136
|
-
readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
137
|
-
}>>, readonly ["InvalidSwap"]>> | import("./error.js").XrpcResponseError<"InvalidSwap", import("./error.js").XrpcErrorBody<"InvalidSwap">>>;
|
|
138
118
|
deleteRecord(collection: NsidString, rkey: string, options?: DeleteRecordOptions): Promise<XrpcResponse<Procedure<"com.atproto.repo.deleteRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
139
119
|
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
140
120
|
readonly format: "at-identifier";
|
|
@@ -150,21 +130,6 @@ export declare class Client implements Agent {
|
|
|
150
130
|
}>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
151
131
|
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
152
132
|
}>>, readonly ["InvalidSwap"]>>>;
|
|
153
|
-
deleteRecordsSafe(...args: Parameters<Client['deleteRecord']>): Promise<import("./error.js").XrpcFailure<"Unknown", import("./error.js").XrpcResponseError<string, import("./error.js").XrpcErrorBody<string>>> | import("./error.js").XrpcFailure<"UnexpectedError", unknown> | import("./error.js").XrpcResponseError<"InvalidSwap", import("./error.js").XrpcErrorBody<"InvalidSwap">> | XrpcResponse<Procedure<"com.atproto.repo.deleteRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
154
|
-
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
155
|
-
readonly format: "at-identifier";
|
|
156
|
-
}>;
|
|
157
|
-
readonly collection: import("@atproto/lex-schema").StringSchema<{
|
|
158
|
-
readonly format: "nsid";
|
|
159
|
-
}>;
|
|
160
|
-
readonly rkey: import("@atproto/lex-schema").StringSchema<{
|
|
161
|
-
readonly format: "record-key";
|
|
162
|
-
}>;
|
|
163
|
-
readonly swapRecord: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
164
|
-
readonly swapCommit: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
165
|
-
}>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
166
|
-
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
167
|
-
}>>, readonly ["InvalidSwap"]>>>;
|
|
168
133
|
getRecord(collection: NsidString, rkey: string, options?: GetRecordOptions): Promise<XrpcResponse<Query<"com.atproto.repo.getRecord", import("@atproto/lex-schema").ParamsSchema<{
|
|
169
134
|
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
170
135
|
readonly format: "at-identifier";
|
|
@@ -183,24 +148,6 @@ export declare class Client implements Agent {
|
|
|
183
148
|
readonly cid: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
184
149
|
readonly value: import("@atproto/lex-schema").UnknownObjectSchema;
|
|
185
150
|
}>>, readonly ["RecordNotFound"]>>>;
|
|
186
|
-
getRecordsSafe(...args: Parameters<Client['getRecord']>): Promise<import("./error.js").XrpcFailure<"Unknown", import("./error.js").XrpcResponseError<string, import("./error.js").XrpcErrorBody<string>>> | import("./error.js").XrpcFailure<"UnexpectedError", unknown> | XrpcResponse<Query<"com.atproto.repo.getRecord", import("@atproto/lex-schema").ParamsSchema<{
|
|
187
|
-
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
188
|
-
readonly format: "at-identifier";
|
|
189
|
-
}>;
|
|
190
|
-
readonly collection: import("@atproto/lex-schema").StringSchema<{
|
|
191
|
-
readonly format: "nsid";
|
|
192
|
-
}>;
|
|
193
|
-
readonly rkey: import("@atproto/lex-schema").StringSchema<{
|
|
194
|
-
readonly format: "record-key";
|
|
195
|
-
}>;
|
|
196
|
-
readonly cid: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
197
|
-
}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
198
|
-
readonly uri: import("@atproto/lex-schema").StringSchema<{
|
|
199
|
-
readonly format: "at-uri";
|
|
200
|
-
}>;
|
|
201
|
-
readonly cid: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
202
|
-
readonly value: import("@atproto/lex-schema").UnknownObjectSchema;
|
|
203
|
-
}>>, readonly ["RecordNotFound"]>> | import("./error.js").XrpcResponseError<"RecordNotFound", import("./error.js").XrpcErrorBody<"RecordNotFound">>>;
|
|
204
151
|
putRecord(record: {
|
|
205
152
|
$type: NsidString;
|
|
206
153
|
} & LexMap, rkey: string, options?: PutRecordOptions): Promise<XrpcResponse<Procedure<"com.atproto.repo.putRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
@@ -228,31 +175,6 @@ export declare class Client implements Agent {
|
|
|
228
175
|
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
229
176
|
readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
230
177
|
}>>, readonly ["InvalidSwap"]>>>;
|
|
231
|
-
putRecordsSafe(...args: Parameters<Client['putRecord']>): Promise<import("./error.js").XrpcFailure<"Unknown", import("./error.js").XrpcResponseError<string, import("./error.js").XrpcErrorBody<string>>> | import("./error.js").XrpcFailure<"UnexpectedError", unknown> | import("./error.js").XrpcResponseError<"InvalidSwap", import("./error.js").XrpcErrorBody<"InvalidSwap">> | XrpcResponse<Procedure<"com.atproto.repo.putRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
232
|
-
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
233
|
-
readonly format: "at-identifier";
|
|
234
|
-
}>;
|
|
235
|
-
readonly collection: import("@atproto/lex-schema").StringSchema<{
|
|
236
|
-
readonly format: "nsid";
|
|
237
|
-
}>;
|
|
238
|
-
readonly rkey: import("@atproto/lex-schema").StringSchema<{
|
|
239
|
-
readonly format: "record-key";
|
|
240
|
-
readonly maxLength: 512;
|
|
241
|
-
}>;
|
|
242
|
-
readonly validate: import("@atproto/lex-schema").OptionalSchema<boolean>;
|
|
243
|
-
readonly record: import("@atproto/lex-schema").UnknownObjectSchema;
|
|
244
|
-
readonly swapRecord: import("@atproto/lex-schema").OptionalSchema<string | null>;
|
|
245
|
-
readonly swapCommit: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
246
|
-
}>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
|
|
247
|
-
readonly uri: import("@atproto/lex-schema").StringSchema<{
|
|
248
|
-
readonly format: "at-uri";
|
|
249
|
-
}>;
|
|
250
|
-
readonly cid: import("@atproto/lex-schema").StringSchema<{
|
|
251
|
-
readonly format: "cid";
|
|
252
|
-
}>;
|
|
253
|
-
readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
|
|
254
|
-
readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
255
|
-
}>>, readonly ["InvalidSwap"]>>>;
|
|
256
178
|
listRecords(nsid: NsidString, options?: ListRecordsOptions): Promise<XrpcResponse<Query<"com.atproto.repo.listRecords", import("@atproto/lex-schema").ParamsSchema<{
|
|
257
179
|
readonly repo: import("@atproto/lex-schema").StringSchema<{
|
|
258
180
|
readonly format: "at-identifier";
|
|
@@ -267,10 +189,24 @@ export declare class Client implements Agent {
|
|
|
267
189
|
readonly cursor: import("@atproto/lex-schema").OptionalSchema<string>;
|
|
268
190
|
readonly records: import("@atproto/lex-schema").ArraySchema<import("@atproto/lex-schema").RefSchema<com.atproto.repo.listRecords.$defs.DefRecord>>;
|
|
269
191
|
}>>, undefined>>>;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
192
|
+
uploadBlob(body: BinaryBodyInit, options?: CallOptions & {
|
|
193
|
+
encoding?: `${string}/${string}`;
|
|
194
|
+
}): 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<{
|
|
195
|
+
readonly blob: import("@atproto/lex-schema").BlobSchema<{
|
|
196
|
+
allowLegacy: false;
|
|
197
|
+
}>;
|
|
198
|
+
}>>, undefined>>>;
|
|
199
|
+
getBlob(did: DidString, cid: CidString, options?: CallOptions): Promise<XrpcResponse<Query<"com.atproto.sync.getBlob", import("@atproto/lex-schema").ParamsSchema<{
|
|
200
|
+
readonly did: import("@atproto/lex-schema").StringSchema<{
|
|
201
|
+
readonly format: "did";
|
|
202
|
+
}>;
|
|
203
|
+
readonly cid: import("@atproto/lex-schema").StringSchema<{
|
|
204
|
+
readonly format: "cid";
|
|
205
|
+
}>;
|
|
206
|
+
}>, import("@atproto/lex-schema").Payload<"*/*", undefined>, readonly ["BlobNotFound", "RepoNotFound", "RepoTakendown", "RepoSuspended", "RepoDeactivated"]>>>;
|
|
207
|
+
call<const T extends Query>(ns: NonNullable<unknown> extends InferMethodParams<T> ? Namespace<T> : Restricted<'This query type requires a "params" argument'>): Promise<XrpcResponseBody<T>>;
|
|
208
|
+
call<const T extends Action>(ns: void extends InferActionInput<T> ? Namespace<T> : Restricted<'This action type requires an "input" argument'>): Promise<InferActionOutput<T>>;
|
|
209
|
+
call<const T extends Action | Procedure | Query>(ns: Namespace<T>, arg: T extends Action ? InferActionInput<T> : T extends Procedure ? InferMethodInputBody<T, Uint8Array> : T extends Query ? InferMethodParams<T> : never, options?: CallOptions): Promise<T extends Action ? InferActionOutput<T> : T extends Procedure ? XrpcResponseBody<T> : T extends Query ? XrpcResponseBody<T> : never>;
|
|
274
210
|
create<const T extends RecordSchema>(ns: NonNullable<unknown> extends CreateOptions<T> ? Namespace<T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<CreateOutput>;
|
|
275
211
|
create<const T extends RecordSchema>(ns: Namespace<T>, input: Omit<Infer<T>, '$type'>, options: CreateOptions<T>): Promise<CreateOutput>;
|
|
276
212
|
delete<const T extends RecordSchema>(ns: NonNullable<unknown> extends DeleteOptions<T> ? Namespace<T> : Restricted<'This record type requires an "options" argument'>): Promise<DeleteOutput>;
|
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,EAAY,MAAM,mBAAmB,CAAA;AACpD,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,mBAAmB,CAAA;AACpD,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,KAAK,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,UAAU,EAEV,SAAS,EACT,KAAK,EACL,YAAY,EACZ,UAAU,EAEX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAc,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,OAAO,EACL,cAAc,EACd,WAAW,EACX,SAAS,EACT,OAAO,EAER,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,gBAAgB,EAGjB,MAAM,WAAW,CAAA;AAElB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC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I,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,SAAS,CAAC,CAAC,CAAC,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;CAkB1B"}
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const lex_schema_1 = require("@atproto/lex-schema");
|
|
6
5
|
const agent_js_1 = require("./agent.js");
|
|
7
|
-
const
|
|
8
|
-
const com = tslib_1.__importStar(require("./lexicons/com.js"));
|
|
6
|
+
const lexicons_js_1 = require("./lexicons.js");
|
|
9
7
|
const types_js_1 = require("./types.js");
|
|
8
|
+
const util_js_1 = require("./util.js");
|
|
9
|
+
const xrpc_error_js_1 = require("./xrpc-error.js");
|
|
10
10
|
const xrpc_js_1 = require("./xrpc.js");
|
|
11
11
|
class Client {
|
|
12
12
|
static appLabelers = [];
|
|
@@ -39,7 +39,7 @@ class Client {
|
|
|
39
39
|
}
|
|
40
40
|
assertAuthenticated() {
|
|
41
41
|
if (!this.did)
|
|
42
|
-
throw new
|
|
42
|
+
throw new xrpc_error_js_1.XrpcError('AuthenticationRequired');
|
|
43
43
|
}
|
|
44
44
|
setLabelers(labelers = []) {
|
|
45
45
|
this.clearLabelers();
|
|
@@ -53,7 +53,7 @@ class Client {
|
|
|
53
53
|
this.labelers.clear();
|
|
54
54
|
}
|
|
55
55
|
fetchHandler(path, init) {
|
|
56
|
-
const headers = (0,
|
|
56
|
+
const headers = (0, util_js_1.buildAtprotoHeaders)({
|
|
57
57
|
headers: init.headers,
|
|
58
58
|
service: this.service,
|
|
59
59
|
labelers: [
|
|
@@ -66,20 +66,20 @@ class Client {
|
|
|
66
66
|
if (!headers.has(key))
|
|
67
67
|
headers.set(key, value);
|
|
68
68
|
}
|
|
69
|
+
// @NOTE The agent here could be another Client instance.
|
|
69
70
|
return this.agent.fetchHandler(path, { ...init, headers });
|
|
70
71
|
}
|
|
71
72
|
async xrpc(ns, options = {}) {
|
|
72
73
|
return (0, xrpc_js_1.xrpc)(this, ns, options);
|
|
73
74
|
}
|
|
74
75
|
async xrpcSafe(ns, options = {}) {
|
|
75
|
-
|
|
76
|
-
return this.xrpc(schema, options).catch((0, error_js_1.asXrpcRequestFailureFor)(schema));
|
|
76
|
+
return (0, xrpc_js_1.xrpcSafe)(this, ns, options);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* @param rkey Leave `undefined` to have the server generate a TID.
|
|
80
80
|
*/
|
|
81
81
|
async createRecord(record, rkey, options) {
|
|
82
|
-
return this.xrpc(com.atproto.repo.createRecord.main, {
|
|
82
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.createRecord.main, {
|
|
83
83
|
...options,
|
|
84
84
|
body: {
|
|
85
85
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -91,11 +91,8 @@ class Client {
|
|
|
91
91
|
},
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
async createRecordsSafe(...args) {
|
|
95
|
-
return this.createRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.createRecord.main));
|
|
96
|
-
}
|
|
97
94
|
async deleteRecord(collection, rkey, options) {
|
|
98
|
-
return this.xrpc(com.atproto.repo.deleteRecord.main, {
|
|
95
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.deleteRecord.main, {
|
|
99
96
|
...options,
|
|
100
97
|
body: {
|
|
101
98
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -106,11 +103,8 @@ class Client {
|
|
|
106
103
|
},
|
|
107
104
|
});
|
|
108
105
|
}
|
|
109
|
-
async deleteRecordsSafe(...args) {
|
|
110
|
-
return this.deleteRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.deleteRecord.main));
|
|
111
|
-
}
|
|
112
106
|
async getRecord(collection, rkey, options) {
|
|
113
|
-
return this.xrpc(com.atproto.repo.getRecord.main, {
|
|
107
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.getRecord.main, {
|
|
114
108
|
...options,
|
|
115
109
|
params: {
|
|
116
110
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -119,11 +113,8 @@ class Client {
|
|
|
119
113
|
},
|
|
120
114
|
});
|
|
121
115
|
}
|
|
122
|
-
async getRecordsSafe(...args) {
|
|
123
|
-
return this.getRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.getRecord.main));
|
|
124
|
-
}
|
|
125
116
|
async putRecord(record, rkey, options) {
|
|
126
|
-
return this.xrpc(com.atproto.repo.putRecord.main, {
|
|
117
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.putRecord.main, {
|
|
127
118
|
...options,
|
|
128
119
|
body: {
|
|
129
120
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -136,11 +127,8 @@ class Client {
|
|
|
136
127
|
},
|
|
137
128
|
});
|
|
138
129
|
}
|
|
139
|
-
async putRecordsSafe(...args) {
|
|
140
|
-
return this.putRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.putRecord.main));
|
|
141
|
-
}
|
|
142
130
|
async listRecords(nsid, options) {
|
|
143
|
-
return this.xrpc(com.atproto.repo.listRecords.main, {
|
|
131
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.listRecords.main, {
|
|
144
132
|
...options,
|
|
145
133
|
params: {
|
|
146
134
|
repo: options?.repo ?? this.assertDid,
|
|
@@ -151,19 +139,29 @@ class Client {
|
|
|
151
139
|
},
|
|
152
140
|
});
|
|
153
141
|
}
|
|
142
|
+
async uploadBlob(body, options) {
|
|
143
|
+
return this.xrpc(lexicons_js_1.com.atproto.repo.uploadBlob.main, {
|
|
144
|
+
...options,
|
|
145
|
+
body,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async getBlob(did, cid, options) {
|
|
149
|
+
return this.xrpc(lexicons_js_1.com.atproto.sync.getBlob.main, {
|
|
150
|
+
...options,
|
|
151
|
+
params: { did, cid },
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
154
|
async call(ns, arg, options = {}) {
|
|
155
155
|
const method = (0, types_js_1.getMain)(ns);
|
|
156
156
|
if (typeof method === 'function') {
|
|
157
157
|
return method(this, arg, options);
|
|
158
158
|
}
|
|
159
159
|
if (method instanceof lex_schema_1.Procedure) {
|
|
160
|
-
const
|
|
161
|
-
const result = await this.xrpc(method, { ...options, body });
|
|
160
|
+
const result = await this.xrpc(method, { ...options, body: arg });
|
|
162
161
|
return result.body;
|
|
163
162
|
}
|
|
164
163
|
else if (method instanceof lex_schema_1.Query) {
|
|
165
|
-
const
|
|
166
|
-
const result = await this.xrpc(method, { ...options, params });
|
|
164
|
+
const result = await this.xrpc(method, { ...options, params: arg });
|
|
167
165
|
return result.body;
|
|
168
166
|
}
|
|
169
167
|
else {
|
|
@@ -172,9 +170,9 @@ class Client {
|
|
|
172
170
|
}
|
|
173
171
|
async create(ns, input, options = {}) {
|
|
174
172
|
const schema = (0, types_js_1.getMain)(ns);
|
|
175
|
-
const record =
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
const record = schema.build(input);
|
|
174
|
+
if (options.validateRequest)
|
|
175
|
+
schema.assert(record);
|
|
178
176
|
const rkey = options.rkey ?? getDefaultRecordKey(schema);
|
|
179
177
|
if (rkey !== undefined)
|
|
180
178
|
schema.keySchema.assert(rkey);
|
|
@@ -197,6 +195,8 @@ class Client {
|
|
|
197
195
|
async put(ns, input, options = {}) {
|
|
198
196
|
const schema = (0, types_js_1.getMain)(ns);
|
|
199
197
|
const record = schema.build(input);
|
|
198
|
+
if (options.validateRequest)
|
|
199
|
+
schema.assert(record);
|
|
200
200
|
const rkey = options.rkey ?? getLiteralRecordKey(schema);
|
|
201
201
|
const response = await this.putRecord(record, rkey, options);
|
|
202
202
|
return response.body;
|