@atproto/lexicon-resolver 0.2.6 → 0.3.0

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 (80) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/lexicon.d.ts +13 -13
  3. package/dist/lexicon.d.ts.map +1 -1
  4. package/dist/lexicon.js +46 -20
  5. package/dist/lexicon.js.map +1 -1
  6. package/dist/lexicons/com/atproto/lexicon/schema.d.ts +3 -0
  7. package/dist/lexicons/com/atproto/lexicon/schema.d.ts.map +1 -0
  8. package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts +50 -0
  9. package/dist/lexicons/com/atproto/lexicon/schema.defs.d.ts.map +1 -0
  10. package/dist/lexicons/com/atproto/lexicon/schema.defs.js +15 -0
  11. package/dist/lexicons/com/atproto/lexicon/schema.defs.js.map +1 -0
  12. package/dist/lexicons/com/atproto/lexicon/schema.js +45 -0
  13. package/dist/lexicons/com/atproto/lexicon/schema.js.map +1 -0
  14. package/dist/lexicons/com/atproto/lexicon.d.ts +2 -0
  15. package/dist/lexicons/com/atproto/lexicon.d.ts.map +1 -0
  16. package/dist/lexicons/com/atproto/lexicon.js +41 -0
  17. package/dist/lexicons/com/atproto/lexicon.js.map +1 -0
  18. package/dist/lexicons/com/atproto/sync/getRecord.d.ts +3 -0
  19. package/dist/lexicons/com/atproto/sync/getRecord.d.ts.map +1 -0
  20. package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts +31 -0
  21. package/dist/lexicons/com/atproto/sync/getRecord.defs.d.ts.map +1 -0
  22. package/dist/lexicons/com/atproto/sync/getRecord.defs.js +24 -0
  23. package/dist/lexicons/com/atproto/sync/getRecord.defs.js.map +1 -0
  24. package/dist/lexicons/com/atproto/sync/getRecord.js +45 -0
  25. package/dist/lexicons/com/atproto/sync/getRecord.js.map +1 -0
  26. package/dist/lexicons/com/atproto/sync.d.ts +2 -0
  27. package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
  28. package/dist/lexicons/com/atproto/sync.js +41 -0
  29. package/dist/lexicons/com/atproto/sync.js.map +1 -0
  30. package/dist/lexicons/com/atproto.d.ts +3 -0
  31. package/dist/lexicons/com/atproto.d.ts.map +1 -0
  32. package/dist/lexicons/com/atproto.js +42 -0
  33. package/dist/lexicons/com/atproto.js.map +1 -0
  34. package/dist/lexicons/com.d.ts +2 -0
  35. package/dist/lexicons/com.d.ts.map +1 -0
  36. package/dist/lexicons/com.js +41 -0
  37. package/dist/lexicons/com.js.map +1 -0
  38. package/dist/lexicons/index.d.ts +2 -0
  39. package/dist/lexicons/index.d.ts.map +1 -0
  40. package/dist/lexicons/index.js +41 -0
  41. package/dist/lexicons/index.js.map +1 -0
  42. package/dist/record.d.ts +9 -10
  43. package/dist/record.d.ts.map +1 -1
  44. package/dist/record.js +10 -13
  45. package/dist/record.js.map +1 -1
  46. package/package.json +7 -9
  47. package/src/lexicon.ts +29 -37
  48. package/src/lexicons/com/atproto/lexicon/schema.defs.ts +43 -0
  49. package/src/lexicons/com/atproto/lexicon/schema.ts +6 -0
  50. package/src/lexicons/com/atproto/lexicon.ts +5 -0
  51. package/src/lexicons/com/atproto/sync/getRecord.defs.ts +39 -0
  52. package/src/lexicons/com/atproto/sync/getRecord.ts +6 -0
  53. package/src/lexicons/com/atproto/sync.ts +5 -0
  54. package/src/lexicons/com/atproto.ts +6 -0
  55. package/src/lexicons/com.ts +5 -0
  56. package/src/lexicons/index.ts +5 -0
  57. package/src/record.ts +42 -25
  58. package/tests/lexicon.test.ts +4 -3
  59. package/tests/record.test.ts +8 -5
  60. package/tsconfig.build.tsbuildinfo +1 -1
  61. package/dist/client/index.d.ts +0 -28
  62. package/dist/client/index.d.ts.map +0 -1
  63. package/dist/client/index.js +0 -118
  64. package/dist/client/index.js.map +0 -1
  65. package/dist/client/lexicons.d.ts +0 -105
  66. package/dist/client/lexicons.d.ts.map +0 -1
  67. package/dist/client/lexicons.js +0 -75
  68. package/dist/client/lexicons.js.map +0 -1
  69. package/dist/client/types/com/atproto/sync/getRecord.d.ts +0 -38
  70. package/dist/client/types/com/atproto/sync/getRecord.d.ts.map +0 -1
  71. package/dist/client/types/com/atproto/sync/getRecord.js +0 -58
  72. package/dist/client/types/com/atproto/sync/getRecord.js.map +0 -1
  73. package/dist/client/util.d.ts +0 -37
  74. package/dist/client/util.d.ts.map +0 -1
  75. package/dist/client/util.js +0 -38
  76. package/dist/client/util.js.map +0 -1
  77. package/src/client/index.ts +0 -67
  78. package/src/client/lexicons.ts +0 -98
  79. package/src/client/types/com/atproto/sync/getRecord.ts +0 -78
  80. package/src/client/util.ts +0 -82
@@ -0,0 +1,5 @@
1
+ /*
2
+ * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
3
+ */
4
+
5
+ export * as com from './com.js'
package/src/record.ts CHANGED
@@ -1,6 +1,13 @@
1
- import { CID } from 'multiformats/cid'
2
1
  import { IdResolver, parseToAtprotoDocument } from '@atproto/identity'
3
- import { RepoRecord } from '@atproto/lexicon'
2
+ import {
3
+ AgentConfig,
4
+ Cid,
5
+ Client,
6
+ DidString,
7
+ FetchHandler,
8
+ LexMap,
9
+ l,
10
+ } from '@atproto/lex'
4
11
  import {
5
12
  Commit,
6
13
  MST,
@@ -9,28 +16,39 @@ import {
9
16
  readCarWithRoot,
10
17
  verifyCommitSig,
11
18
  } from '@atproto/repo'
12
- import { AtUri, ensureValidDid } from '@atproto/syntax'
13
- import { BuildFetchHandlerOptions, FetchHandler } from '@atproto/xrpc'
19
+ import { AtUri, AtUriString } from '@atproto/syntax'
14
20
  import { safeFetchWrap } from '@atproto-labs/fetch-node'
15
- import { AtpBaseClient as Client } from './client/index.js'
16
- import { isValidDid } from './util.js'
21
+ import { com } from './lexicons/index.js'
22
+
23
+ export { AtUri, IdResolver }
24
+ export type {
25
+ AgentConfig,
26
+ AtUriString,
27
+ Cid,
28
+ Commit,
29
+ DidString,
30
+ FetchHandler,
31
+ LexMap,
32
+ }
17
33
 
18
34
  /**
19
35
  * Resolve a record from the network.
20
36
  */
21
- export type RecordResolver = (uri: AtUri | string) => Promise<RecordResolution>
37
+ export type RecordResolver = (
38
+ uri: AtUri | AtUriString,
39
+ ) => Promise<RecordResolution>
22
40
 
23
41
  /**
24
42
  * Resolve a record from the network, verifying its authenticity.
25
43
  */
26
44
  export type AtprotoRecordResolver = (
27
- uri: AtUri | string,
45
+ uri: AtUri | AtUriString,
28
46
  options?: ResolveRecordOptions,
29
47
  ) => Promise<RecordResolution>
30
48
 
31
49
  export type BuildRecordResolverOptions = {
32
50
  idResolver?: IdResolver
33
- rpc?: Partial<BuildFetchHandlerOptions> | FetchHandler
51
+ rpc?: Partial<AgentConfig> | FetchHandler
34
52
  }
35
53
 
36
54
  export type ResolveRecordOptions = {
@@ -40,12 +58,10 @@ export type ResolveRecordOptions = {
40
58
  export type RecordResolution = {
41
59
  commit: Commit
42
60
  uri: AtUri
43
- cid: CID
44
- record: RepoRecord
61
+ cid: Cid
62
+ record: LexMap
45
63
  }
46
64
 
47
- export { AtUri, CID, type Commit, IdResolver, type RepoRecord }
48
-
49
65
  /**
50
66
  * Build a record resolver function.
51
67
  */
@@ -54,7 +70,7 @@ export function buildRecordResolver(
54
70
  ): AtprotoRecordResolver {
55
71
  const { idResolver = new IdResolver(), rpc } = options
56
72
  return async function resolveRecord(
57
- uriStr: AtUri | string,
73
+ uriStr: AtUri | AtUriString,
58
74
  opts: ResolveRecordOptions = {},
59
75
  ): Promise<RecordResolution> {
60
76
  const uri = typeof uriStr === 'string' ? new AtUri(uriStr) : uriStr
@@ -79,18 +95,18 @@ export function buildRecordResolver(
79
95
  }
80
96
  const client = new Client(
81
97
  typeof rpc === 'function'
82
- ? rpc
98
+ ? { fetchHandler: rpc }
83
99
  : {
84
100
  ...rpc,
85
101
  service: rpc?.service ?? pds,
86
102
  fetch: rpc?.fetch ?? safeFetch,
87
103
  },
88
104
  )
89
- const { data: proofBytes } = await client.com.atproto.sync
90
- .getRecord({
105
+ const proofBytes = await client
106
+ .call(com.atproto.sync.getRecord, {
91
107
  did,
92
- collection: uri.collection,
93
- rkey: uri.rkey,
108
+ collection: uri.collection as l.NsidString,
109
+ rkey: uri.rkey as l.RecordKeyString,
94
110
  })
95
111
  .catch((err) => {
96
112
  throw new RecordResolutionError('Could not fetch record proof', {
@@ -123,22 +139,23 @@ export class RecordResolutionError extends Error {
123
139
  async function getDidFromUri(
124
140
  uri: AtUri,
125
141
  { idResolver }: { idResolver: IdResolver },
126
- ) {
127
- if (uri.host.startsWith('did:')) {
128
- ensureValidDid(uri.host)
142
+ ): Promise<DidString> {
143
+ if (l.isDidString(uri.host)) {
129
144
  return uri.host
130
145
  }
146
+
131
147
  const resolved = await idResolver.handle.resolve(uri.host)
132
- if (!resolved || !isValidDid(resolved)) {
148
+ if (!resolved || !l.isDidString(resolved)) {
133
149
  throw new RecordResolutionError('Could not resolve handle found in AT-URI')
134
150
  }
151
+
135
152
  return resolved
136
153
  }
137
154
 
138
155
  async function verifyRecordProof(
139
156
  proofBytes: Uint8Array,
140
157
  { uri, signingKey }: { uri: AtUri; signingKey: string },
141
- ) {
158
+ ): Promise<RecordResolution> {
142
159
  const { root, blocks } = await readCarWithRoot(proofBytes).catch((err) => {
143
160
  throw new RecordResolutionError('Malformed record proof', { cause: err })
144
161
  })
@@ -162,6 +179,6 @@ async function verifyRecordProof(
162
179
  if (!cid) {
163
180
  throw new RecordResolutionError('Record not found in proof')
164
181
  }
165
- const record = await blockstore.readRecord(cid)
182
+ const record = (await blockstore.readRecord(cid)) as LexMap
166
183
  return { commit, uri, cid, record }
167
184
  }
@@ -1,5 +1,5 @@
1
1
  import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
2
- import { NSID } from '@atproto/syntax'
2
+ import { DidString, NSID } from '@atproto/syntax'
3
3
  import {
4
4
  AtprotoLexiconResolver,
5
5
  buildLexiconResolver,
@@ -157,7 +157,7 @@ describe('Lexicon resolution', () => {
157
157
  name: 'LexiconResolutionError',
158
158
  message: 'Invalid Lexicon document (example.alice.baddoc)',
159
159
  cause: expect.objectContaining({
160
- name: 'ZodError',
160
+ name: 'LexValidationError',
161
161
  }),
162
162
  }),
163
163
  )
@@ -184,7 +184,7 @@ describe('Lexicon resolution', () => {
184
184
  sc.getHeaders(sc.dids.carol),
185
185
  )
186
186
  const result = await resolveLexicon('example.alice.override', {
187
- didAuthority: sc.dids.carol,
187
+ didAuthority: sc.dids.carol as DidString,
188
188
  forceRefresh: true,
189
189
  })
190
190
  expect(result.commit.did).toEqual(sc.dids.carol)
@@ -248,6 +248,7 @@ describe('Lexicon resolution', () => {
248
248
  })
249
249
 
250
250
  it('fails on invalid NSID', async () => {
251
+ // @ts-expect-error testing invalid input
251
252
  await expect(resolveLexiconDidAuthority('not an nsid')).rejects.toThrow(
252
253
  'Disallowed characters in NSID',
253
254
  )
@@ -1,5 +1,7 @@
1
- import { dataToCborBlock } from '@atproto/common'
1
+ import assert from 'node:assert'
2
2
  import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
3
+ import { AtUriString, l } from '@atproto/lex'
4
+ import { encode } from '@atproto/lex-cbor'
3
5
  import { AtprotoRecordResolver, buildRecordResolver } from '../src/index.js'
4
6
 
5
7
  describe('Record resolution', () => {
@@ -36,6 +38,7 @@ describe('Record resolution', () => {
36
38
 
37
39
  it('resolves record by AT-URI string.', async () => {
38
40
  const post = await sc.post(sc.dids.alice, 'post2')
41
+ assert(l.isAtUriString(post.ref.uriStr))
39
42
  const result = await resolveRecord(post.ref.uriStr, {
40
43
  forceRefresh: true,
41
44
  })
@@ -78,13 +81,13 @@ describe('Record resolution', () => {
78
81
 
79
82
  it('does not resolve record with corrupted CAR block.', async () => {
80
83
  const post = await sc.post(sc.dids.alice, 'post4')
81
- const badBlock = await dataToCborBlock({})
84
+ const badCbor = encode({})
82
85
  await network.pds.ctx.actorStore.transact(sc.dids.alice, (txn) =>
83
86
  txn.repo.db.db
84
87
  .updateTable('repo_block')
85
88
  .set({
86
- content: badBlock.bytes,
87
- size: badBlock.bytes.byteLength,
89
+ content: badCbor,
90
+ size: badCbor.byteLength,
88
91
  })
89
92
  .where('cid', '=', post.ref.cidStr)
90
93
  .execute(),
@@ -168,7 +171,7 @@ describe('Record resolution', () => {
168
171
  return doc
169
172
  },
170
173
  )
171
- const result = await resolveRecord(post.ref.uriStr, {
174
+ const result = await resolveRecord(post.ref.uriStr as AtUriString, {
172
175
  forceRefresh: true,
173
176
  })
174
177
  expect(result.commit.did).toEqual(sc.dids.alice)
@@ -1 +1 @@
1
- {"root":["./src/index.ts","./src/lexicon.ts","./src/record.ts","./src/util.ts","./src/client/index.ts","./src/client/lexicons.ts","./src/client/util.ts","./src/client/types/com/atproto/sync/getRecord.ts"],"version":"5.8.3"}
1
+ {"root":["./src/index.ts","./src/lexicon.ts","./src/record.ts","./src/util.ts","./src/lexicons/com.ts","./src/lexicons/index.ts","./src/lexicons/com/atproto.ts","./src/lexicons/com/atproto/lexicon.ts","./src/lexicons/com/atproto/sync.ts","./src/lexicons/com/atproto/lexicon/schema.defs.ts","./src/lexicons/com/atproto/lexicon/schema.ts","./src/lexicons/com/atproto/sync/getRecord.defs.ts","./src/lexicons/com/atproto/sync/getRecord.ts"],"version":"5.8.3"}
@@ -1,28 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import { XrpcClient, type FetchHandler, type FetchHandlerOptions } from '@atproto/xrpc';
5
- import * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js';
6
- export * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js';
7
- export declare class AtpBaseClient extends XrpcClient {
8
- com: ComNS;
9
- constructor(options: FetchHandler | FetchHandlerOptions);
10
- /** @deprecated use `this` instead */
11
- get xrpc(): XrpcClient;
12
- }
13
- export declare class ComNS {
14
- _client: XrpcClient;
15
- atproto: ComAtprotoNS;
16
- constructor(client: XrpcClient);
17
- }
18
- export declare class ComAtprotoNS {
19
- _client: XrpcClient;
20
- sync: ComAtprotoSyncNS;
21
- constructor(client: XrpcClient);
22
- }
23
- export declare class ComAtprotoSyncNS {
24
- _client: XrpcClient;
25
- constructor(client: XrpcClient);
26
- getRecord(params?: ComAtprotoSyncGetRecord.QueryParams, opts?: ComAtprotoSyncGetRecord.CallOptions): Promise<ComAtprotoSyncGetRecord.Response>;
27
- }
28
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,uBAAuB,MAAM,uCAAuC,CAAA;AAEhF,OAAO,KAAK,uBAAuB,MAAM,uCAAuC,CAAA;AAEhF,qBAAa,aAAc,SAAQ,UAAU;IAC3C,GAAG,EAAE,KAAK,CAAA;gBAEE,OAAO,EAAE,YAAY,GAAG,mBAAmB;IAKvD,qCAAqC;IACrC,IAAI,IAAI,IAAI,UAAU,CAErB;CACF;AAED,qBAAa,KAAK;IAChB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,YAAY,CAAA;gBAET,MAAM,EAAE,UAAU;CAI/B;AAED,qBAAa,YAAY;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,IAAI,EAAE,gBAAgB,CAAA;gBAEV,MAAM,EAAE,UAAU;CAI/B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,EAAE,UAAU,CAAA;gBAEP,MAAM,EAAE,UAAU;IAI9B,SAAS,CACP,MAAM,CAAC,EAAE,uBAAuB,CAAC,WAAW,EAC5C,IAAI,CAAC,EAAE,uBAAuB,CAAC,WAAW,GACzC,OAAO,CAAC,uBAAuB,CAAC,QAAQ,CAAC;CAO7C"}
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ComAtprotoSyncNS = exports.ComAtprotoNS = exports.ComNS = exports.AtpBaseClient = exports.ComAtprotoSyncGetRecord = void 0;
37
- /**
38
- * GENERATED CODE - DO NOT MODIFY
39
- */
40
- const xrpc_1 = require("@atproto/xrpc");
41
- const lexicons_js_1 = require("./lexicons.js");
42
- const ComAtprotoSyncGetRecord = __importStar(require("./types/com/atproto/sync/getRecord.js"));
43
- exports.ComAtprotoSyncGetRecord = __importStar(require("./types/com/atproto/sync/getRecord.js"));
44
- class AtpBaseClient extends xrpc_1.XrpcClient {
45
- constructor(options) {
46
- super(options, lexicons_js_1.schemas);
47
- Object.defineProperty(this, "com", {
48
- enumerable: true,
49
- configurable: true,
50
- writable: true,
51
- value: void 0
52
- });
53
- this.com = new ComNS(this);
54
- }
55
- /** @deprecated use `this` instead */
56
- get xrpc() {
57
- return this;
58
- }
59
- }
60
- exports.AtpBaseClient = AtpBaseClient;
61
- class ComNS {
62
- constructor(client) {
63
- Object.defineProperty(this, "_client", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
69
- Object.defineProperty(this, "atproto", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- this._client = client;
76
- this.atproto = new ComAtprotoNS(client);
77
- }
78
- }
79
- exports.ComNS = ComNS;
80
- class ComAtprotoNS {
81
- constructor(client) {
82
- Object.defineProperty(this, "_client", {
83
- enumerable: true,
84
- configurable: true,
85
- writable: true,
86
- value: void 0
87
- });
88
- Object.defineProperty(this, "sync", {
89
- enumerable: true,
90
- configurable: true,
91
- writable: true,
92
- value: void 0
93
- });
94
- this._client = client;
95
- this.sync = new ComAtprotoSyncNS(client);
96
- }
97
- }
98
- exports.ComAtprotoNS = ComAtprotoNS;
99
- class ComAtprotoSyncNS {
100
- constructor(client) {
101
- Object.defineProperty(this, "_client", {
102
- enumerable: true,
103
- configurable: true,
104
- writable: true,
105
- value: void 0
106
- });
107
- this._client = client;
108
- }
109
- getRecord(params, opts) {
110
- return this._client
111
- .call('com.atproto.sync.getRecord', params, undefined, opts)
112
- .catch((e) => {
113
- throw ComAtprotoSyncGetRecord.toKnownErr(e);
114
- });
115
- }
116
- }
117
- exports.ComAtprotoSyncNS = ComAtprotoSyncNS;
118
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,wCAIsB;AACtB,+CAAuC;AAGvC,+FAAgF;AAEhF,iGAAgF;AAEhF,MAAa,aAAc,SAAQ,iBAAU;IAG3C,YAAY,OAA2C;QACrD,KAAK,CAAC,OAAO,EAAE,qBAAO,CAAC,CAAA;QAHzB;;;;;WAAU;QAIR,IAAI,CAAC,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED,qCAAqC;IACrC,IAAI,IAAI;QACN,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAZD,sCAYC;AAED,MAAa,KAAK;IAIhB,YAAY,MAAkB;QAH9B;;;;;WAAmB;QACnB;;;;;WAAqB;QAGnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;CACF;AARD,sBAQC;AAED,MAAa,YAAY;IAIvB,YAAY,MAAkB;QAH9B;;;;;WAAmB;QACnB;;;;;WAAsB;QAGpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC1C,CAAC;CACF;AARD,oCAQC;AAED,MAAa,gBAAgB;IAG3B,YAAY,MAAkB;QAF9B;;;;;WAAmB;QAGjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,SAAS,CACP,MAA4C,EAC5C,IAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO;aAChB,IAAI,CAAC,4BAA4B,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC;aAC3D,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,uBAAuB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AAjBD,4CAiBC","sourcesContent":["/**\n * GENERATED CODE - DO NOT MODIFY\n */\nimport {\n XrpcClient,\n type FetchHandler,\n type FetchHandlerOptions,\n} from '@atproto/xrpc'\nimport { schemas } from './lexicons.js'\nimport { CID } from 'multiformats/cid'\nimport { type OmitKey, type Un$Typed } from './util.js'\nimport * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js'\n\nexport * as ComAtprotoSyncGetRecord from './types/com/atproto/sync/getRecord.js'\n\nexport class AtpBaseClient extends XrpcClient {\n com: ComNS\n\n constructor(options: FetchHandler | FetchHandlerOptions) {\n super(options, schemas)\n this.com = new ComNS(this)\n }\n\n /** @deprecated use `this` instead */\n get xrpc(): XrpcClient {\n return this\n }\n}\n\nexport class ComNS {\n _client: XrpcClient\n atproto: ComAtprotoNS\n\n constructor(client: XrpcClient) {\n this._client = client\n this.atproto = new ComAtprotoNS(client)\n }\n}\n\nexport class ComAtprotoNS {\n _client: XrpcClient\n sync: ComAtprotoSyncNS\n\n constructor(client: XrpcClient) {\n this._client = client\n this.sync = new ComAtprotoSyncNS(client)\n }\n}\n\nexport class ComAtprotoSyncNS {\n _client: XrpcClient\n\n constructor(client: XrpcClient) {\n this._client = client\n }\n\n getRecord(\n params?: ComAtprotoSyncGetRecord.QueryParams,\n opts?: ComAtprotoSyncGetRecord.CallOptions,\n ): Promise<ComAtprotoSyncGetRecord.Response> {\n return this._client\n .call('com.atproto.sync.getRecord', params, undefined, opts)\n .catch((e) => {\n throw ComAtprotoSyncGetRecord.toKnownErr(e)\n })\n }\n}\n"]}
@@ -1,105 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import { Lexicons, type ValidationResult } from '@atproto/lexicon';
5
- export declare const schemaDict: {
6
- readonly ComAtprotoSyncGetRecord: {
7
- readonly lexicon: 1;
8
- readonly id: "com.atproto.sync.getRecord";
9
- readonly defs: {
10
- readonly main: {
11
- readonly type: "query";
12
- readonly description: "Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.";
13
- readonly parameters: {
14
- readonly type: "params";
15
- readonly required: ["did", "collection", "rkey"];
16
- readonly properties: {
17
- readonly did: {
18
- readonly type: "string";
19
- readonly format: "did";
20
- readonly description: "The DID of the repo.";
21
- };
22
- readonly collection: {
23
- readonly type: "string";
24
- readonly format: "nsid";
25
- };
26
- readonly rkey: {
27
- readonly type: "string";
28
- readonly description: "Record Key";
29
- readonly format: "record-key";
30
- };
31
- };
32
- };
33
- readonly output: {
34
- readonly encoding: "application/vnd.ipld.car";
35
- };
36
- readonly errors: [{
37
- readonly name: "RecordNotFound";
38
- }, {
39
- readonly name: "RepoNotFound";
40
- }, {
41
- readonly name: "RepoTakendown";
42
- }, {
43
- readonly name: "RepoSuspended";
44
- }, {
45
- readonly name: "RepoDeactivated";
46
- }];
47
- };
48
- };
49
- };
50
- };
51
- export declare const schemas: {
52
- readonly lexicon: 1;
53
- readonly id: "com.atproto.sync.getRecord";
54
- readonly defs: {
55
- readonly main: {
56
- readonly type: "query";
57
- readonly description: "Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.";
58
- readonly parameters: {
59
- readonly type: "params";
60
- readonly required: ["did", "collection", "rkey"];
61
- readonly properties: {
62
- readonly did: {
63
- readonly type: "string";
64
- readonly format: "did";
65
- readonly description: "The DID of the repo.";
66
- };
67
- readonly collection: {
68
- readonly type: "string";
69
- readonly format: "nsid";
70
- };
71
- readonly rkey: {
72
- readonly type: "string";
73
- readonly description: "Record Key";
74
- readonly format: "record-key";
75
- };
76
- };
77
- };
78
- readonly output: {
79
- readonly encoding: "application/vnd.ipld.car";
80
- };
81
- readonly errors: [{
82
- readonly name: "RecordNotFound";
83
- }, {
84
- readonly name: "RepoNotFound";
85
- }, {
86
- readonly name: "RepoTakendown";
87
- }, {
88
- readonly name: "RepoSuspended";
89
- }, {
90
- readonly name: "RepoDeactivated";
91
- }];
92
- };
93
- };
94
- }[];
95
- export declare const lexicons: Lexicons;
96
- export declare function validate<T extends {
97
- $type: string;
98
- }>(v: unknown, id: string, hash: string, requiredType: true): ValidationResult<T>;
99
- export declare function validate<T extends {
100
- $type?: string;
101
- }>(v: unknown, id: string, hash: string, requiredType?: false): ValidationResult<T>;
102
- export declare const ids: {
103
- readonly ComAtprotoSyncGetRecord: "com.atproto.sync.getRecord";
104
- };
105
- //# sourceMappingURL=lexicons.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lexicons.d.ts","sourceRoot":"","sources":["../../src/client/lexicons.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,QAAQ,EAER,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAA;AAGzB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDwB,CAAA;AAC/C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAmD,CAAA;AACvE,eAAO,MAAM,QAAQ,EAAE,QAAgC,CAAA;AAEvD,wBAAgB,QAAQ,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAClD,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GACjB,gBAAgB,CAAC,CAAC,CAAC,CAAA;AACtB,wBAAgB,QAAQ,CAAC,CAAC,SAAS;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,KAAK,GACnB,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAiBtB,eAAO,MAAM,GAAG;;CAEN,CAAA"}
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ids = exports.lexicons = exports.schemas = exports.schemaDict = void 0;
4
- exports.validate = validate;
5
- /**
6
- * GENERATED CODE - DO NOT MODIFY
7
- */
8
- const lexicon_1 = require("@atproto/lexicon");
9
- const util_js_1 = require("./util.js");
10
- exports.schemaDict = {
11
- ComAtprotoSyncGetRecord: {
12
- lexicon: 1,
13
- id: 'com.atproto.sync.getRecord',
14
- defs: {
15
- main: {
16
- type: 'query',
17
- description: 'Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.',
18
- parameters: {
19
- type: 'params',
20
- required: ['did', 'collection', 'rkey'],
21
- properties: {
22
- did: {
23
- type: 'string',
24
- format: 'did',
25
- description: 'The DID of the repo.',
26
- },
27
- collection: {
28
- type: 'string',
29
- format: 'nsid',
30
- },
31
- rkey: {
32
- type: 'string',
33
- description: 'Record Key',
34
- format: 'record-key',
35
- },
36
- },
37
- },
38
- output: {
39
- encoding: 'application/vnd.ipld.car',
40
- },
41
- errors: [
42
- {
43
- name: 'RecordNotFound',
44
- },
45
- {
46
- name: 'RepoNotFound',
47
- },
48
- {
49
- name: 'RepoTakendown',
50
- },
51
- {
52
- name: 'RepoSuspended',
53
- },
54
- {
55
- name: 'RepoDeactivated',
56
- },
57
- ],
58
- },
59
- },
60
- },
61
- };
62
- exports.schemas = Object.values(exports.schemaDict);
63
- exports.lexicons = new lexicon_1.Lexicons(exports.schemas);
64
- function validate(v, id, hash, requiredType) {
65
- return (requiredType ? util_js_1.is$typed : util_js_1.maybe$typed)(v, id, hash)
66
- ? exports.lexicons.validate(`${id}#${hash}`, v)
67
- : {
68
- success: false,
69
- error: new lexicon_1.ValidationError(`Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`),
70
- };
71
- }
72
- exports.ids = {
73
- ComAtprotoSyncGetRecord: 'com.atproto.sync.getRecord',
74
- };
75
- //# sourceMappingURL=lexicons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lexicons.js","sourceRoot":"","sources":["../../src/client/lexicons.ts"],"names":[],"mappings":";;;AA+EA,4BAcC;AA7FD;;GAEG;AACH,8CAKyB;AACzB,uCAA8D;AAEjD,QAAA,UAAU,GAAG;IACxB,uBAAuB,EAAE;QACvB,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,4BAA4B;QAChC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,WAAW,EACT,iIAAiI;gBACnI,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC;oBACvC,UAAU,EAAE;wBACV,GAAG,EAAE;4BACH,IAAI,EAAE,QAAQ;4BACd,MAAM,EAAE,KAAK;4BACb,WAAW,EAAE,sBAAsB;yBACpC;wBACD,UAAU,EAAE;4BACV,IAAI,EAAE,QAAQ;4BACd,MAAM,EAAE,MAAM;yBACf;wBACD,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,YAAY;4BACzB,MAAM,EAAE,YAAY;yBACrB;qBACF;iBACF;gBACD,MAAM,EAAE;oBACN,QAAQ,EAAE,0BAA0B;iBACrC;gBACD,MAAM,EAAE;oBACN;wBACE,IAAI,EAAE,gBAAgB;qBACvB;oBACD;wBACE,IAAI,EAAE,cAAc;qBACrB;oBACD;wBACE,IAAI,EAAE,eAAe;qBACtB;oBACD;wBACE,IAAI,EAAE,eAAe;qBACtB;oBACD;wBACE,IAAI,EAAE,iBAAiB;qBACxB;iBACF;aACF;SACF;KACF;CAC4C,CAAA;AAClC,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAU,CAAwB,CAAA;AAC1D,QAAA,QAAQ,GAAa,IAAI,kBAAQ,CAAC,eAAO,CAAC,CAAA;AAcvD,SAAgB,QAAQ,CACtB,CAAU,EACV,EAAU,EACV,IAAY,EACZ,YAAsB;IAEtB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,kBAAQ,CAAC,CAAC,CAAC,qBAAW,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC;QACzD,CAAC,CAAC,gBAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC;YACE,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,IAAI,yBAAe,CACxB,2BAA2B,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,kBAAkB,CACpF;SACF,CAAA;AACP,CAAC;AAEY,QAAA,GAAG,GAAG;IACjB,uBAAuB,EAAE,4BAA4B;CAC7C,CAAA","sourcesContent":["/**\n * GENERATED CODE - DO NOT MODIFY\n */\nimport {\n type LexiconDoc,\n Lexicons,\n ValidationError,\n type ValidationResult,\n} from '@atproto/lexicon'\nimport { type $Typed, is$typed, maybe$typed } from './util.js'\n\nexport const schemaDict = {\n ComAtprotoSyncGetRecord: {\n lexicon: 1,\n id: 'com.atproto.sync.getRecord',\n defs: {\n main: {\n type: 'query',\n description:\n 'Get data blocks needed to prove the existence or non-existence of record in the current version of repo. Does not require auth.',\n parameters: {\n type: 'params',\n required: ['did', 'collection', 'rkey'],\n properties: {\n did: {\n type: 'string',\n format: 'did',\n description: 'The DID of the repo.',\n },\n collection: {\n type: 'string',\n format: 'nsid',\n },\n rkey: {\n type: 'string',\n description: 'Record Key',\n format: 'record-key',\n },\n },\n },\n output: {\n encoding: 'application/vnd.ipld.car',\n },\n errors: [\n {\n name: 'RecordNotFound',\n },\n {\n name: 'RepoNotFound',\n },\n {\n name: 'RepoTakendown',\n },\n {\n name: 'RepoSuspended',\n },\n {\n name: 'RepoDeactivated',\n },\n ],\n },\n },\n },\n} as const satisfies Record<string, LexiconDoc>\nexport const schemas = Object.values(schemaDict) satisfies LexiconDoc[]\nexport const lexicons: Lexicons = new Lexicons(schemas)\n\nexport function validate<T extends { $type: string }>(\n v: unknown,\n id: string,\n hash: string,\n requiredType: true,\n): ValidationResult<T>\nexport function validate<T extends { $type?: string }>(\n v: unknown,\n id: string,\n hash: string,\n requiredType?: false,\n): ValidationResult<T>\nexport function validate(\n v: unknown,\n id: string,\n hash: string,\n requiredType?: boolean,\n): ValidationResult {\n return (requiredType ? is$typed : maybe$typed)(v, id, hash)\n ? lexicons.validate(`${id}#${hash}`, v)\n : {\n success: false,\n error: new ValidationError(\n `Must be an object with \"${hash === 'main' ? id : `${id}#${hash}`}\" $type property`,\n ),\n }\n}\n\nexport const ids = {\n ComAtprotoSyncGetRecord: 'com.atproto.sync.getRecord',\n} as const\n"]}
@@ -1,38 +0,0 @@
1
- /**
2
- * GENERATED CODE - DO NOT MODIFY
3
- */
4
- import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
- export type QueryParams = {
6
- /** The DID of the repo. */
7
- did: string;
8
- collection: string;
9
- /** Record Key */
10
- rkey: string;
11
- };
12
- export type InputSchema = undefined;
13
- export interface CallOptions {
14
- signal?: AbortSignal;
15
- headers?: HeadersMap;
16
- }
17
- export interface Response {
18
- success: boolean;
19
- headers: HeadersMap;
20
- data: Uint8Array;
21
- }
22
- export declare class RecordNotFoundError extends XRPCError {
23
- constructor(src: XRPCError);
24
- }
25
- export declare class RepoNotFoundError extends XRPCError {
26
- constructor(src: XRPCError);
27
- }
28
- export declare class RepoTakendownError extends XRPCError {
29
- constructor(src: XRPCError);
30
- }
31
- export declare class RepoSuspendedError extends XRPCError {
32
- constructor(src: XRPCError);
33
- }
34
- export declare class RepoDeactivatedError extends XRPCError {
35
- constructor(src: XRPCError);
36
- }
37
- export declare function toKnownErr(e: any): any;
38
- //# sourceMappingURL=getRecord.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRecord.d.ts","sourceRoot":"","sources":["../../../../../../src/client/types/com/atproto/sync/getRecord.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAcrD,MAAM,MAAM,WAAW,GAAG;IACxB,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AACD,MAAM,MAAM,WAAW,GAAG,SAAS,CAAA;AAEnC,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,UAAU,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,GAAG,EAAE,SAAS;CAG3B;AAED,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,GAAG,EAAE,SAAS;CAG3B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,GAAG,OAUhC"}