@atproto/lex-client 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/agent.d.ts +10 -9
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +3 -0
  5. package/dist/agent.js.map +1 -1
  6. package/dist/client.d.ts +51 -113
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +38 -42
  9. package/dist/client.js.map +1 -1
  10. package/dist/errors.d.ts +82 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +132 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +7 -7
  19. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
  20. package/dist/lexicons/com/atproto/repo/createRecord.defs.js +8 -12
  21. package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
  22. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +7 -7
  23. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
  24. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +8 -12
  25. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
  26. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +5 -6
  27. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
  28. package/dist/lexicons/com/atproto/repo/getRecord.defs.js +6 -10
  29. package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
  30. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +5 -6
  31. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
  32. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +5 -8
  33. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  34. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +7 -7
  35. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
  36. package/dist/lexicons/com/atproto/repo/putRecord.defs.js +8 -12
  37. package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
  38. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +7 -7
  39. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
  40. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +6 -9
  41. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  42. package/dist/lexicons/com/atproto/sync/getBlob.d.ts +3 -0
  43. package/dist/lexicons/com/atproto/sync/getBlob.d.ts.map +1 -0
  44. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts +25 -0
  45. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts.map +1 -0
  46. package/dist/lexicons/com/atproto/sync/getBlob.defs.js +27 -0
  47. package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -0
  48. package/dist/lexicons/com/atproto/sync/getBlob.js +10 -0
  49. package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -0
  50. package/dist/lexicons/com/atproto/sync.d.ts +2 -0
  51. package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
  52. package/dist/lexicons/com/atproto/sync.js +9 -0
  53. package/dist/lexicons/com/atproto/sync.js.map +1 -0
  54. package/dist/lexicons/com/atproto.d.ts +1 -0
  55. package/dist/lexicons/com/atproto.d.ts.map +1 -1
  56. package/dist/lexicons/com/atproto.js +2 -1
  57. package/dist/lexicons/com/atproto.js.map +1 -1
  58. package/dist/lexicons.d.ts +2 -0
  59. package/dist/lexicons.d.ts.map +1 -0
  60. package/dist/lexicons.js +6 -0
  61. package/dist/lexicons.js.map +1 -0
  62. package/dist/response.d.ts +25 -8
  63. package/dist/response.d.ts.map +1 -1
  64. package/dist/response.js +123 -10
  65. package/dist/response.js.map +1 -1
  66. package/dist/types.d.ts +18 -4
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/types.js +0 -4
  69. package/dist/types.js.map +1 -1
  70. package/dist/util.d.ts +14 -0
  71. package/dist/util.d.ts.map +1 -0
  72. package/dist/util.js +65 -0
  73. package/dist/util.js.map +1 -0
  74. package/dist/xrpc.d.ts +35 -32
  75. package/dist/xrpc.d.ts.map +1 -1
  76. package/dist/xrpc.js +116 -124
  77. package/dist/xrpc.js.map +1 -1
  78. package/package.json +10 -10
  79. package/src/agent.ts +18 -14
  80. package/src/client.ts +135 -114
  81. package/src/errors.ts +206 -0
  82. package/src/index.ts +1 -1
  83. package/src/lexicons/com/atproto/repo/createRecord.defs.ts +31 -36
  84. package/src/lexicons/com/atproto/repo/deleteRecord.defs.ts +27 -32
  85. package/src/lexicons/com/atproto/repo/getRecord.defs.ts +12 -17
  86. package/src/lexicons/com/atproto/repo/listRecords.defs.ts +13 -15
  87. package/src/lexicons/com/atproto/repo/putRecord.defs.ts +32 -37
  88. package/src/lexicons/com/atproto/repo/uploadBlob.defs.ts +13 -15
  89. package/src/lexicons/com/atproto/sync/getBlob.defs.ts +37 -0
  90. package/src/lexicons/com/atproto/sync/getBlob.ts +6 -0
  91. package/src/lexicons/com/atproto/sync.ts +5 -0
  92. package/src/lexicons/com/atproto.ts +1 -0
  93. package/src/lexicons.ts +1 -0
  94. package/src/response.ts +201 -15
  95. package/src/types.ts +26 -5
  96. package/src/util.ts +84 -0
  97. package/src/xrpc.ts +220 -232
  98. package/tsconfig.tests.json +4 -7
  99. package/dist/error.d.ts +0 -66
  100. package/dist/error.d.ts.map +0 -1
  101. package/dist/error.js +0 -100
  102. package/dist/error.js.map +0 -1
  103. package/src/error.ts +0 -145
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @atproto/lex-client
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4443](https://github.com/bluesky-social/atproto/pull/4443) [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Rework `XrpcError` to extend `LexError` from `@atproto/data`
8
+
9
+ - [#4443](https://github.com/bluesky-social/atproto/pull/4443) [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Expose `asXrpcFailure` utility
10
+
11
+ - [#4443](https://github.com/bluesky-social/atproto/pull/4443) [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - `buildAgent` can now be given an `Agent` as input (and will act as identity in that case)
12
+
13
+ - Updated dependencies [[`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c), [`9af7a2d`](https://github.com/bluesky-social/atproto/commit/9af7a2d12240e91248610ce4fe7d93387733c59c)]:
14
+ - @atproto/lex-schema@0.0.6
15
+ - @atproto/lex-data@0.0.5
16
+ - @atproto/lex-json@0.0.5
17
+
18
+ ## 0.0.5
19
+
20
+ ### Patch Changes
21
+
22
+ - [#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
23
+
24
+ - [#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
25
+
26
+ - [#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.
27
+
28
+ - [#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
29
+
30
+ - [#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.
31
+
32
+ - [#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
33
+
34
+ - [#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
35
+
36
+ - [#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
37
+
38
+ - [#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
39
+
40
+ - 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)]:
41
+ - @atproto/lex-data@0.0.4
42
+ - @atproto/lex-schema@0.0.5
43
+ - @atproto/lex-json@0.0.4
44
+
3
45
  ## 0.0.4
4
46
 
5
47
  ### 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: (this: Agent,
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
  /**
@@ -29,5 +30,5 @@ export type AgentConfig = {
29
30
  fetch?: typeof globalThis.fetch;
30
31
  };
31
32
  export type AgentOptions = AgentConfig | string | URL;
32
- export declare function buildAgent(options: AgentOptions): Agent;
33
+ export declare function buildAgent(options: Agent | AgentOptions): Agent;
33
34
  //# sourceMappingURL=agent.d.ts.map
@@ -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,WAAW,KAAK;IACpB,GAAG,CAAC,EAAE,SAAS,CAAA;IAEf,YAAY,EAAE,CACZ,IAAI,EAAE,KAAK;IACX;;;;OAIG;IACH,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAA;CACvB;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"}
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,KAAK,GAAG,YAAY,GAAG,KAAK,CAyB/D"}
package/dist/agent.js CHANGED
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildAgent = buildAgent;
4
4
  function buildAgent(options) {
5
+ if (typeof options === 'object' && 'fetchHandler' in options) {
6
+ return options;
7
+ }
5
8
  const config = typeof options === 'string' || options instanceof URL
6
9
  ? { did: undefined, service: options }
7
10
  : options;
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 interface Agent {\n did?: DidString\n\n fetchHandler: (\n this: Agent,\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}\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"]}
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;AAyCA,gCAyBC;AAzBD,SAAgB,UAAU,CAAC,OAA6B;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC;QAC7D,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,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: Agent | AgentOptions): Agent {\n if (typeof options === 'object' && 'fetchHandler' in options) {\n return options\n }\n\n const config: Agent | 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,11 @@
1
- import { LexMap } from '@atproto/lex-data';
2
- import { AtIdentifierString, DidString, Infer, InferProcedureInputBody, InferProcedureOutputBody, InferQueryOutputBody, InferQueryParameters, InferRecordKey, LexiconRecordKey, NsidString, Procedure, Query, RecordSchema, Restricted } from '@atproto/lex-schema';
1
+ import { LexMap, LexValue } from '@atproto/lex-data';
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 { XrpcRequestFailure } from './error.js';
5
- import * as com from './lexicons/com.js';
6
- import { XrpcResponse, XrpcResponseBody } from './response.js';
7
- import { CallOptions, Namespace, Service } from './types.js';
8
- import { XrpcOptions } from './xrpc.js';
4
+ import { com } from './lexicons.js';
5
+ import { LexRpcResponse, LexRpcResponseBody } from './response.js';
6
+ import { BinaryBodyInit, CallOptions, Service } from './types.js';
7
+ import { LexRpcFailure, LexRpcOptions } from './xrpc.js';
8
+ export type { AtIdentifierString, CidString, DidString, InferMethodInputBody, InferMethodOutputBody, InferMethodParams, InferRecordKey, LexMap, LexValue, LexiconRecordKey, NsidString, Params, Procedure, Query, RecordSchema, Restricted, Schema, };
9
9
  export type ClientOptions = {
10
10
  labelers?: Iterable<DidString>;
11
11
  headers?: HeadersInit;
@@ -45,17 +45,17 @@ export type RecordKeyOptions<T extends RecordSchema, AlsoOptionalWhenRecordKeyIs
45
45
  rkey: InferRecordKey<T>;
46
46
  };
47
47
  export type CreateOptions<T extends RecordSchema> = CreateRecordOptions & RecordKeyOptions<T, 'tid'>;
48
- export type CreateOutput = XrpcResponseBody<typeof com.atproto.repo.createRecord.main>;
48
+ export type CreateOutput = InferMethodOutputBody<typeof com.atproto.repo.createRecord.main, Uint8Array>;
49
49
  export type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions & RecordKeyOptions<T>;
50
- export type DeleteOutput = XrpcResponseBody<typeof com.atproto.repo.deleteRecord.main>;
50
+ export type DeleteOutput = InferMethodOutputBody<typeof com.atproto.repo.deleteRecord.main, Uint8Array>;
51
51
  export type GetOptions<T extends RecordSchema> = GetRecordOptions & RecordKeyOptions<T>;
52
- export type GetOutput<T extends RecordSchema> = Omit<XrpcResponseBody<typeof com.atproto.repo.getRecord.main>, 'value'> & {
52
+ export type GetOutput<T extends RecordSchema> = Omit<InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>, 'value'> & {
53
53
  value: Infer<T>;
54
54
  };
55
55
  export type PutOptions<T extends RecordSchema> = PutRecordOptions & RecordKeyOptions<T>;
56
- export type PutOutput = XrpcResponseBody<typeof com.atproto.repo.putRecord.main>;
56
+ export type PutOutput = InferMethodOutputBody<typeof com.atproto.repo.putRecord.main, Uint8Array>;
57
57
  export type ListOptions = ListRecordsOptions;
58
- export type ListOutput<T extends RecordSchema> = XrpcResponseBody<typeof com.atproto.repo.listRecords.main> & {
58
+ export type ListOutput<T extends RecordSchema> = InferMethodOutputBody<typeof com.atproto.repo.listRecords.main, Uint8Array> & {
59
59
  records: ListRecord<T>[];
60
60
  invalid: LexMap[];
61
61
  };
@@ -84,16 +84,19 @@ export declare class Client implements Agent {
84
84
  addLabelers(labelers: Iterable<DidString>): void;
85
85
  clearLabelers(): void;
86
86
  fetchHandler(path: string, init: RequestInit): Promise<Response>;
87
- 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
- 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> | XrpcRequestFailure<M>>;
90
- xrpcSafe<const M extends Query | Procedure>(ns: Namespace<M>, options: XrpcOptions<M>): Promise<XrpcResponse<M> | XrpcRequestFailure<M>>;
87
+ /**
88
+ * @throws {LexRpcFailure<M>} when the request fails or the response is an error
89
+ */
90
+ xrpc<const M extends Query | Procedure>(ns: NonNullable<unknown> extends LexRpcOptions<M> ? Main<M> : Restricted<'This XRPC method requires an "options" argument'>): Promise<LexRpcResponse<M>>;
91
+ xrpc<const M extends Query | Procedure>(ns: Main<M>, options: LexRpcOptions<M>): Promise<LexRpcResponse<M>>;
92
+ xrpcSafe<const M extends Query | Procedure>(ns: NonNullable<unknown> extends LexRpcOptions<M> ? Main<M> : Restricted<'This XRPC method requires an "options" argument'>): Promise<LexRpcResponse<M> | LexRpcFailure<M>>;
93
+ xrpcSafe<const M extends Query | Procedure>(ns: Main<M>, options: LexRpcOptions<M>): Promise<LexRpcResponse<M> | LexRpcFailure<M>>;
91
94
  /**
92
95
  * @param rkey Leave `undefined` to have the server generate a TID.
93
96
  */
94
97
  createRecord(record: {
95
98
  $type: NsidString;
96
- } & LexMap, rkey?: string, options?: CreateRecordOptions): Promise<XrpcResponse<Procedure<"com.atproto.repo.createRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
99
+ } & LexMap, rkey?: string, options?: CreateRecordOptions): Promise<LexRpcResponse<Procedure<"com.atproto.repo.createRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
97
100
  readonly repo: import("@atproto/lex-schema").StringSchema<{
98
101
  readonly format: "at-identifier";
99
102
  }>;
@@ -114,28 +117,7 @@ export declare class Client implements Agent {
114
117
  readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
115
118
  readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
116
119
  }>>, 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
- 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<{
120
+ deleteRecord(collection: NsidString, rkey: string, options?: DeleteRecordOptions): Promise<LexRpcResponse<Procedure<"com.atproto.repo.deleteRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
139
121
  readonly repo: import("@atproto/lex-schema").StringSchema<{
140
122
  readonly format: "at-identifier";
141
123
  }>;
@@ -150,22 +132,7 @@ export declare class Client implements Agent {
150
132
  }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
151
133
  readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
152
134
  }>>, 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
- getRecord(collection: NsidString, rkey: string, options?: GetRecordOptions): Promise<XrpcResponse<Query<"com.atproto.repo.getRecord", import("@atproto/lex-schema").ParamsSchema<{
135
+ getRecord(collection: NsidString, rkey: string, options?: GetRecordOptions): Promise<LexRpcResponse<Query<"com.atproto.repo.getRecord", import("@atproto/lex-schema").ParamsSchema<{
169
136
  readonly repo: import("@atproto/lex-schema").StringSchema<{
170
137
  readonly format: "at-identifier";
171
138
  }>;
@@ -183,52 +150,9 @@ export declare class Client implements Agent {
183
150
  readonly cid: import("@atproto/lex-schema").OptionalSchema<string>;
184
151
  readonly value: import("@atproto/lex-schema").UnknownObjectSchema;
185
152
  }>>, 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
153
  putRecord(record: {
205
154
  $type: NsidString;
206
- } & 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<{
207
- readonly repo: import("@atproto/lex-schema").StringSchema<{
208
- readonly format: "at-identifier";
209
- }>;
210
- readonly collection: import("@atproto/lex-schema").StringSchema<{
211
- readonly format: "nsid";
212
- }>;
213
- readonly rkey: import("@atproto/lex-schema").StringSchema<{
214
- readonly format: "record-key";
215
- readonly maxLength: 512;
216
- }>;
217
- readonly validate: import("@atproto/lex-schema").OptionalSchema<boolean>;
218
- readonly record: import("@atproto/lex-schema").UnknownObjectSchema;
219
- readonly swapRecord: import("@atproto/lex-schema").OptionalSchema<string | null>;
220
- readonly swapCommit: import("@atproto/lex-schema").OptionalSchema<string>;
221
- }>>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
222
- readonly uri: import("@atproto/lex-schema").StringSchema<{
223
- readonly format: "at-uri";
224
- }>;
225
- readonly cid: import("@atproto/lex-schema").StringSchema<{
226
- readonly format: "cid";
227
- }>;
228
- readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
229
- readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
230
- }>>, 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<{
155
+ } & LexMap, rkey: string, options?: PutRecordOptions): Promise<LexRpcResponse<Procedure<"com.atproto.repo.putRecord", import("@atproto/lex-schema").ParamsSchema<{}>, import("@atproto/lex-schema").Payload<"application/json", import("@atproto/lex-schema").ObjectSchema<{
232
156
  readonly repo: import("@atproto/lex-schema").StringSchema<{
233
157
  readonly format: "at-identifier";
234
158
  }>;
@@ -253,7 +177,7 @@ export declare class Client implements Agent {
253
177
  readonly commit: import("@atproto/lex-schema").OptionalSchema<com.atproto.repo.defs.$defs.CommitMeta>;
254
178
  readonly validationStatus: import("@atproto/lex-schema").OptionalSchema<string>;
255
179
  }>>, readonly ["InvalidSwap"]>>>;
256
- listRecords(nsid: NsidString, options?: ListRecordsOptions): Promise<XrpcResponse<Query<"com.atproto.repo.listRecords", import("@atproto/lex-schema").ParamsSchema<{
180
+ listRecords(nsid: NsidString, options?: ListRecordsOptions): Promise<LexRpcResponse<Query<"com.atproto.repo.listRecords", import("@atproto/lex-schema").ParamsSchema<{
257
181
  readonly repo: import("@atproto/lex-schema").StringSchema<{
258
182
  readonly format: "at-identifier";
259
183
  }>;
@@ -267,18 +191,32 @@ export declare class Client implements Agent {
267
191
  readonly cursor: import("@atproto/lex-schema").OptionalSchema<string>;
268
192
  readonly records: import("@atproto/lex-schema").ArraySchema<import("@atproto/lex-schema").RefSchema<com.atproto.repo.listRecords.$defs.DefRecord>>;
269
193
  }>>, undefined>>>;
270
- call<const T extends Action>(ns: Namespace<T>, input: InferActionInput<T>, options?: CallOptions): Promise<InferActionOutput<T>>;
271
- call<const T extends Procedure>(ns: Namespace<T>, body: InferProcedureInputBody<T>, options?: CallOptions): Promise<InferProcedureOutputBody<T>>;
272
- call<const T extends Query>(ns: NonNullable<unknown> extends InferQueryParameters<T> ? Namespace<T> : Restricted<'This query type requires a "params" argument'>): Promise<InferQueryOutputBody<T>>;
273
- call<const T extends Query>(ns: Namespace<T>, params: NonNullable<unknown> extends InferQueryParameters<T> ? InferQueryParameters<T> | undefined : InferQueryParameters<T>, options?: CallOptions): Promise<InferQueryOutputBody<T>>;
274
- 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
- create<const T extends RecordSchema>(ns: Namespace<T>, input: Omit<Infer<T>, '$type'>, options: CreateOptions<T>): Promise<CreateOutput>;
276
- delete<const T extends RecordSchema>(ns: NonNullable<unknown> extends DeleteOptions<T> ? Namespace<T> : Restricted<'This record type requires an "options" argument'>): Promise<DeleteOutput>;
277
- delete<const T extends RecordSchema>(ns: Namespace<T>, options?: DeleteOptions<T>): Promise<DeleteOutput>;
278
- get<const T extends RecordSchema>(ns: T['key'] extends `literal:${string}` ? Namespace<T> : Restricted<'This record type requires an "options" argument'>): Promise<GetOutput<T>>;
279
- get<const T extends RecordSchema>(ns: Namespace<T>, options?: GetOptions<T>): Promise<GetOutput<T>>;
280
- put<const T extends RecordSchema>(ns: NonNullable<unknown> extends PutOptions<T> ? Namespace<T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<PutOutput>;
281
- put<const T extends RecordSchema>(ns: Namespace<T>, input: Omit<Infer<T>, '$type'>, options: PutOptions<T>): Promise<PutOutput>;
282
- list<const T extends RecordSchema>(ns: Namespace<T>, options?: ListOptions): Promise<ListOutput<T>>;
194
+ uploadBlob(body: BinaryBodyInit, options?: CallOptions & {
195
+ encoding?: `${string}/${string}`;
196
+ }): Promise<LexRpcResponse<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<{
197
+ readonly blob: import("@atproto/lex-schema").BlobSchema<{
198
+ allowLegacy: false;
199
+ }>;
200
+ }>>, undefined>>>;
201
+ getBlob(did: DidString, cid: CidString, options?: CallOptions): Promise<LexRpcResponse<Query<"com.atproto.sync.getBlob", import("@atproto/lex-schema").ParamsSchema<{
202
+ readonly did: import("@atproto/lex-schema").StringSchema<{
203
+ readonly format: "did";
204
+ }>;
205
+ readonly cid: import("@atproto/lex-schema").StringSchema<{
206
+ readonly format: "cid";
207
+ }>;
208
+ }>, import("@atproto/lex-schema").Payload<"*/*", undefined>, readonly ["BlobNotFound", "RepoNotFound", "RepoTakendown", "RepoSuspended", "RepoDeactivated"]>>>;
209
+ call<const T extends Query>(ns: NonNullable<unknown> extends InferMethodParams<T> ? Main<T> : Restricted<'This query type requires a "params" argument'>): Promise<LexRpcResponseBody<T>>;
210
+ call<const T extends Action>(ns: void extends InferActionInput<T> ? Main<T> : Restricted<'This action type requires an "input" argument'>): Promise<InferActionOutput<T>>;
211
+ call<const T extends Action | Procedure | Query>(ns: Main<T>, arg: T extends Action ? InferActionInput<T> : T extends Procedure ? InferMethodInputBody<T, Uint8Array> : T extends Query ? InferMethodParams<T> : never, options?: CallOptions): Promise<T extends Action ? InferActionOutput<T> : T extends Procedure ? LexRpcResponseBody<T> : T extends Query ? LexRpcResponseBody<T> : never>;
212
+ create<const T extends RecordSchema>(ns: NonNullable<unknown> extends CreateOptions<T> ? Main<T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<CreateOutput>;
213
+ create<const T extends RecordSchema>(ns: Main<T>, input: Omit<Infer<T>, '$type'>, options: CreateOptions<T>): Promise<CreateOutput>;
214
+ delete<const T extends RecordSchema>(ns: NonNullable<unknown> extends DeleteOptions<T> ? Main<T> : Restricted<'This record type requires an "options" argument'>): Promise<DeleteOutput>;
215
+ delete<const T extends RecordSchema>(ns: Main<T>, options?: DeleteOptions<T>): Promise<DeleteOutput>;
216
+ get<const T extends RecordSchema>(ns: T['key'] extends `literal:${string}` ? Main<T> : Restricted<'This record type requires an "options" argument'>): Promise<GetOutput<T>>;
217
+ get<const T extends RecordSchema>(ns: Main<T>, options?: GetOptions<T>): Promise<GetOutput<T>>;
218
+ put<const T extends RecordSchema>(ns: NonNullable<unknown> extends PutOptions<T> ? Main<T> : Restricted<'This record type requires an "options" argument'>, input: Omit<Infer<T>, '$type'>): Promise<PutOutput>;
219
+ put<const T extends RecordSchema>(ns: Main<T>, input: Omit<Infer<T>, '$type'>, options: PutOptions<T>): Promise<PutOutput>;
220
+ list<const T extends RecordSchema>(ns: Main<T>, options?: ListOptions): Promise<ListOutput<T>>;
283
221
  }
284
222
  //# sourceMappingURL=client.d.ts.map
@@ -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,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACpB,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,EAGL,kBAAkB,EAEnB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAW,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,WAAW,EAA4B,MAAM,WAAW,CAAA;AAEjE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,WAAW,KACjB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;AACnB,MAAM,MAAM,gBAAgB,CAAC,CAAC,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AS,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
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Client = void 0;
4
- const tslib_1 = require("tslib");
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 error_js_1 = require("./error.js");
8
- const com = tslib_1.__importStar(require("./lexicons/com.js"));
9
- const types_js_1 = require("./types.js");
7
+ const lexicons_js_1 = require("./lexicons.js");
8
+ const util_js_1 = require("./util.js");
10
9
  const xrpc_js_1 = require("./xrpc.js");
11
10
  class Client {
12
11
  static appLabelers = [];
@@ -22,10 +21,7 @@ class Client {
22
21
  service;
23
22
  labelers;
24
23
  constructor(agent, options = {}) {
25
- this.agent =
26
- typeof agent === 'object' && 'fetchHandler' in agent
27
- ? agent
28
- : (0, agent_js_1.buildAgent)(agent);
24
+ this.agent = (0, agent_js_1.buildAgent)(agent);
29
25
  this.service = options.service;
30
26
  this.labelers = new Set(options.labelers);
31
27
  this.headers = new Headers(options.headers);
@@ -39,7 +35,7 @@ class Client {
39
35
  }
40
36
  assertAuthenticated() {
41
37
  if (!this.did)
42
- throw new error_js_1.XrpcError(error_js_1.KnownError.AuthenticationRequired);
38
+ throw new lex_data_1.LexError('AuthenticationRequired');
43
39
  }
44
40
  setLabelers(labelers = []) {
45
41
  this.clearLabelers();
@@ -53,7 +49,7 @@ class Client {
53
49
  this.labelers.clear();
54
50
  }
55
51
  fetchHandler(path, init) {
56
- const headers = (0, xrpc_js_1.xrpcRequestHeaders)({
52
+ const headers = (0, util_js_1.buildAtprotoHeaders)({
57
53
  headers: init.headers,
58
54
  service: this.service,
59
55
  labelers: [
@@ -66,20 +62,20 @@ class Client {
66
62
  if (!headers.has(key))
67
63
  headers.set(key, value);
68
64
  }
65
+ // @NOTE The agent here could be another Client instance.
69
66
  return this.agent.fetchHandler(path, { ...init, headers });
70
67
  }
71
68
  async xrpc(ns, options = {}) {
72
69
  return (0, xrpc_js_1.xrpc)(this, ns, options);
73
70
  }
74
71
  async xrpcSafe(ns, options = {}) {
75
- const schema = (0, types_js_1.getMain)(ns);
76
- return this.xrpc(schema, options).catch((0, error_js_1.asXrpcRequestFailureFor)(schema));
72
+ return (0, xrpc_js_1.xrpcSafe)(this, ns, options);
77
73
  }
78
74
  /**
79
75
  * @param rkey Leave `undefined` to have the server generate a TID.
80
76
  */
81
77
  async createRecord(record, rkey, options) {
82
- return this.xrpc(com.atproto.repo.createRecord.main, {
78
+ return this.xrpc(lexicons_js_1.com.atproto.repo.createRecord.main, {
83
79
  ...options,
84
80
  body: {
85
81
  repo: options?.repo ?? this.assertDid,
@@ -91,11 +87,8 @@ class Client {
91
87
  },
92
88
  });
93
89
  }
94
- async createRecordsSafe(...args) {
95
- return this.createRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.createRecord.main));
96
- }
97
90
  async deleteRecord(collection, rkey, options) {
98
- return this.xrpc(com.atproto.repo.deleteRecord.main, {
91
+ return this.xrpc(lexicons_js_1.com.atproto.repo.deleteRecord.main, {
99
92
  ...options,
100
93
  body: {
101
94
  repo: options?.repo ?? this.assertDid,
@@ -106,11 +99,8 @@ class Client {
106
99
  },
107
100
  });
108
101
  }
109
- async deleteRecordsSafe(...args) {
110
- return this.deleteRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.deleteRecord.main));
111
- }
112
102
  async getRecord(collection, rkey, options) {
113
- return this.xrpc(com.atproto.repo.getRecord.main, {
103
+ return this.xrpc(lexicons_js_1.com.atproto.repo.getRecord.main, {
114
104
  ...options,
115
105
  params: {
116
106
  repo: options?.repo ?? this.assertDid,
@@ -119,11 +109,8 @@ class Client {
119
109
  },
120
110
  });
121
111
  }
122
- async getRecordsSafe(...args) {
123
- return this.getRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.getRecord.main));
124
- }
125
112
  async putRecord(record, rkey, options) {
126
- return this.xrpc(com.atproto.repo.putRecord.main, {
113
+ return this.xrpc(lexicons_js_1.com.atproto.repo.putRecord.main, {
127
114
  ...options,
128
115
  body: {
129
116
  repo: options?.repo ?? this.assertDid,
@@ -136,11 +123,8 @@ class Client {
136
123
  },
137
124
  });
138
125
  }
139
- async putRecordsSafe(...args) {
140
- return this.putRecord(...args).catch((0, error_js_1.asXrpcRequestFailureFor)(com.atproto.repo.putRecord.main));
141
- }
142
126
  async listRecords(nsid, options) {
143
- return this.xrpc(com.atproto.repo.listRecords.main, {
127
+ return this.xrpc(lexicons_js_1.com.atproto.repo.listRecords.main, {
144
128
  ...options,
145
129
  params: {
146
130
  repo: options?.repo ?? this.assertDid,
@@ -151,19 +135,29 @@ class Client {
151
135
  },
152
136
  });
153
137
  }
138
+ async uploadBlob(body, options) {
139
+ return this.xrpc(lexicons_js_1.com.atproto.repo.uploadBlob.main, {
140
+ ...options,
141
+ body,
142
+ });
143
+ }
144
+ async getBlob(did, cid, options) {
145
+ return this.xrpc(lexicons_js_1.com.atproto.sync.getBlob.main, {
146
+ ...options,
147
+ params: { did, cid },
148
+ });
149
+ }
154
150
  async call(ns, arg, options = {}) {
155
- const method = (0, types_js_1.getMain)(ns);
151
+ const method = (0, lex_schema_1.getMain)(ns);
156
152
  if (typeof method === 'function') {
157
153
  return method(this, arg, options);
158
154
  }
159
155
  if (method instanceof lex_schema_1.Procedure) {
160
- const body = arg;
161
- const result = await this.xrpc(method, { ...options, body });
156
+ const result = await this.xrpc(method, { ...options, body: arg });
162
157
  return result.body;
163
158
  }
164
159
  else if (method instanceof lex_schema_1.Query) {
165
- const params = arg;
166
- const result = await this.xrpc(method, { ...options, params });
160
+ const result = await this.xrpc(method, { ...options, params: arg });
167
161
  return result.body;
168
162
  }
169
163
  else {
@@ -171,10 +165,10 @@ class Client {
171
165
  }
172
166
  }
173
167
  async create(ns, input, options = {}) {
174
- const schema = (0, types_js_1.getMain)(ns);
175
- const record = options.validate
176
- ? schema.parse(schema.build(input))
177
- : schema.build(input);
168
+ const schema = (0, lex_schema_1.getMain)(ns);
169
+ const record = schema.build(input);
170
+ if (options.validateRequest)
171
+ schema.assert(record);
178
172
  const rkey = options.rkey ?? getDefaultRecordKey(schema);
179
173
  if (rkey !== undefined)
180
174
  schema.keySchema.assert(rkey);
@@ -182,27 +176,29 @@ class Client {
182
176
  return response.body;
183
177
  }
184
178
  async delete(ns, options = {}) {
185
- const schema = (0, types_js_1.getMain)(ns);
179
+ const schema = (0, lex_schema_1.getMain)(ns);
186
180
  const rkey = schema.keySchema.parse(options.rkey ?? getLiteralRecordKey(schema));
187
181
  const response = await this.deleteRecord(schema.$type, rkey, options);
188
182
  return response.body;
189
183
  }
190
184
  async get(ns, options = {}) {
191
- const schema = (0, types_js_1.getMain)(ns);
185
+ const schema = (0, lex_schema_1.getMain)(ns);
192
186
  const rkey = schema.keySchema.parse(options.rkey ?? getLiteralRecordKey(schema));
193
187
  const response = await this.getRecord(schema.$type, rkey, options);
194
188
  const value = schema.parse(response.body.value);
195
189
  return { ...response.body, value };
196
190
  }
197
191
  async put(ns, input, options = {}) {
198
- const schema = (0, types_js_1.getMain)(ns);
192
+ const schema = (0, lex_schema_1.getMain)(ns);
199
193
  const record = schema.build(input);
194
+ if (options.validateRequest)
195
+ schema.assert(record);
200
196
  const rkey = options.rkey ?? getLiteralRecordKey(schema);
201
197
  const response = await this.putRecord(record, rkey, options);
202
198
  return response.body;
203
199
  }
204
200
  async list(ns, options) {
205
- const schema = (0, types_js_1.getMain)(ns);
201
+ const schema = (0, lex_schema_1.getMain)(ns);
206
202
  const { body } = await this.listRecords(schema.$type, options);
207
203
  const records = [];
208
204
  const invalid = [];