@atproto/api 0.6.18 → 0.6.20

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 (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/client/index.d.ts +22 -3
  3. package/dist/client/lexicons.d.ts +302 -14
  4. package/dist/client/types/app/bsky/actor/searchActors.d.ts +1 -0
  5. package/dist/client/types/app/bsky/actor/searchActorsTypeahead.d.ts +1 -0
  6. package/dist/client/types/app/bsky/feed/searchPosts.d.ts +26 -0
  7. package/dist/client/types/app/bsky/unspecced/defs.d.ts +13 -0
  8. package/dist/client/types/app/bsky/unspecced/searchActorsSkeleton.d.ts +27 -0
  9. package/dist/client/types/app/bsky/unspecced/searchPostsSkeleton.d.ts +26 -0
  10. package/dist/client/types/com/atproto/admin/searchRepos.d.ts +1 -0
  11. package/dist/client/types/com/atproto/server/confirmEmail.d.ts +30 -0
  12. package/dist/client/types/com/atproto/server/createSession.d.ts +1 -0
  13. package/dist/client/types/com/atproto/server/getSession.d.ts +1 -0
  14. package/dist/client/types/com/atproto/server/requestEmailConfirmation.d.ts +13 -0
  15. package/dist/client/types/{app/bsky/unspecced/applyLabels.d.ts → com/atproto/server/requestEmailUpdate.d.ts} +4 -4
  16. package/dist/client/types/com/atproto/server/updateEmail.d.ts +27 -0
  17. package/dist/index.js +850 -336
  18. package/dist/index.js.map +3 -3
  19. package/dist/types.d.ts +1 -0
  20. package/package.json +7 -7
  21. package/src/agent.ts +4 -0
  22. package/src/client/index.ts +93 -13
  23. package/src/client/lexicons.ts +351 -23
  24. package/src/client/types/app/bsky/actor/searchActors.ts +3 -0
  25. package/src/client/types/app/bsky/actor/searchActorsTypeahead.ts +3 -0
  26. package/src/client/types/app/bsky/feed/searchPosts.ts +50 -0
  27. package/src/client/types/app/bsky/unspecced/defs.ts +41 -0
  28. package/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts +52 -0
  29. package/src/client/types/app/bsky/unspecced/searchPostsSkeleton.ts +50 -0
  30. package/src/client/types/com/atproto/admin/searchRepos.ts +2 -0
  31. package/src/client/types/com/atproto/server/confirmEmail.ts +61 -0
  32. package/src/client/types/com/atproto/server/createSession.ts +1 -0
  33. package/src/client/types/com/atproto/server/getSession.ts +1 -0
  34. package/src/client/types/com/atproto/server/requestEmailConfirmation.ts +28 -0
  35. package/src/client/types/{app/bsky/unspecced/applyLabels.ts → com/atproto/server/requestEmailUpdate.ts} +5 -4
  36. package/src/client/types/com/atproto/server/updateEmail.ts +55 -0
  37. package/src/rich-text/detection.ts +1 -1
  38. package/src/types.ts +1 -0
  39. package/tests/agent.test.ts +9 -0
  40. package/tests/rich-text-detection.test.ts +17 -17
@@ -0,0 +1,50 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+ import * as AppBskyUnspeccedDefs from './defs'
10
+
11
+ export interface QueryParams {
12
+ /** search query string; syntax, phrase, boolean, and faceting is unspecified, but Lucene query syntax is recommended */
13
+ q: string
14
+ limit?: number
15
+ /** optional pagination mechanism; may not necessarily allow scrolling through entire result set */
16
+ cursor?: string
17
+ }
18
+
19
+ export type InputSchema = undefined
20
+
21
+ export interface OutputSchema {
22
+ cursor?: string
23
+ /** count of search hits. optional, may be rounded/truncated, and may not be possible to paginate through all hits */
24
+ hitsTotal?: number
25
+ posts: AppBskyUnspeccedDefs.SkeletonSearchPost[]
26
+ [k: string]: unknown
27
+ }
28
+
29
+ export interface CallOptions {
30
+ headers?: Headers
31
+ }
32
+
33
+ export interface Response {
34
+ success: boolean
35
+ headers: Headers
36
+ data: OutputSchema
37
+ }
38
+
39
+ export class BadQueryStringError extends XRPCError {
40
+ constructor(src: XRPCError) {
41
+ super(src.status, src.error, src.message, src.headers)
42
+ }
43
+ }
44
+
45
+ export function toKnownErr(e: any) {
46
+ if (e instanceof XRPCError) {
47
+ if (e.error === 'BadQueryString') return new BadQueryStringError(e)
48
+ }
49
+ return e
50
+ }
@@ -9,7 +9,9 @@ import { CID } from 'multiformats/cid'
9
9
  import * as ComAtprotoAdminDefs from './defs'
10
10
 
11
11
  export interface QueryParams {
12
+ /** DEPRECATED: use 'q' instead */
12
13
  term?: string
14
+ q?: string
13
15
  invitedBy?: string
14
16
  limit?: number
15
17
  cursor?: string
@@ -0,0 +1,61 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+
10
+ export interface QueryParams {}
11
+
12
+ export interface InputSchema {
13
+ email: string
14
+ token: string
15
+ [k: string]: unknown
16
+ }
17
+
18
+ export interface CallOptions {
19
+ headers?: Headers
20
+ qp?: QueryParams
21
+ encoding: 'application/json'
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ }
28
+
29
+ export class AccountNotFoundError extends XRPCError {
30
+ constructor(src: XRPCError) {
31
+ super(src.status, src.error, src.message, src.headers)
32
+ }
33
+ }
34
+
35
+ export class ExpiredTokenError extends XRPCError {
36
+ constructor(src: XRPCError) {
37
+ super(src.status, src.error, src.message, src.headers)
38
+ }
39
+ }
40
+
41
+ export class InvalidTokenError extends XRPCError {
42
+ constructor(src: XRPCError) {
43
+ super(src.status, src.error, src.message, src.headers)
44
+ }
45
+ }
46
+
47
+ export class InvalidEmailError extends XRPCError {
48
+ constructor(src: XRPCError) {
49
+ super(src.status, src.error, src.message, src.headers)
50
+ }
51
+ }
52
+
53
+ export function toKnownErr(e: any) {
54
+ if (e instanceof XRPCError) {
55
+ if (e.error === 'AccountNotFound') return new AccountNotFoundError(e)
56
+ if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
57
+ if (e.error === 'InvalidToken') return new InvalidTokenError(e)
58
+ if (e.error === 'InvalidEmail') return new InvalidEmailError(e)
59
+ }
60
+ return e
61
+ }
@@ -22,6 +22,7 @@ export interface OutputSchema {
22
22
  handle: string
23
23
  did: string
24
24
  email?: string
25
+ emailConfirmed?: boolean
25
26
  [k: string]: unknown
26
27
  }
27
28
 
@@ -15,6 +15,7 @@ export interface OutputSchema {
15
15
  handle: string
16
16
  did: string
17
17
  email?: string
18
+ emailConfirmed?: boolean
18
19
  [k: string]: unknown
19
20
  }
20
21
 
@@ -0,0 +1,28 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+
10
+ export interface QueryParams {}
11
+
12
+ export type InputSchema = undefined
13
+
14
+ export interface CallOptions {
15
+ headers?: Headers
16
+ qp?: QueryParams
17
+ }
18
+
19
+ export interface Response {
20
+ success: boolean
21
+ headers: Headers
22
+ }
23
+
24
+ export function toKnownErr(e: any) {
25
+ if (e instanceof XRPCError) {
26
+ }
27
+ return e
28
+ }
@@ -6,24 +6,25 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
6
  import { isObj, hasProp } from '../../../../util'
7
7
  import { lexicons } from '../../../../lexicons'
8
8
  import { CID } from 'multiformats/cid'
9
- import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs'
10
9
 
11
10
  export interface QueryParams {}
12
11
 
13
- export interface InputSchema {
14
- labels: ComAtprotoLabelDefs.Label[]
12
+ export type InputSchema = undefined
13
+
14
+ export interface OutputSchema {
15
+ tokenRequired: boolean
15
16
  [k: string]: unknown
16
17
  }
17
18
 
18
19
  export interface CallOptions {
19
20
  headers?: Headers
20
21
  qp?: QueryParams
21
- encoding: 'application/json'
22
22
  }
23
23
 
24
24
  export interface Response {
25
25
  success: boolean
26
26
  headers: Headers
27
+ data: OutputSchema
27
28
  }
28
29
 
29
30
  export function toKnownErr(e: any) {
@@ -0,0 +1,55 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { Headers, XRPCError } from '@atproto/xrpc'
5
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
6
+ import { isObj, hasProp } from '../../../../util'
7
+ import { lexicons } from '../../../../lexicons'
8
+ import { CID } from 'multiformats/cid'
9
+
10
+ export interface QueryParams {}
11
+
12
+ export interface InputSchema {
13
+ email: string
14
+ /** Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed. */
15
+ token?: string
16
+ [k: string]: unknown
17
+ }
18
+
19
+ export interface CallOptions {
20
+ headers?: Headers
21
+ qp?: QueryParams
22
+ encoding: 'application/json'
23
+ }
24
+
25
+ export interface Response {
26
+ success: boolean
27
+ headers: Headers
28
+ }
29
+
30
+ export class ExpiredTokenError extends XRPCError {
31
+ constructor(src: XRPCError) {
32
+ super(src.status, src.error, src.message, src.headers)
33
+ }
34
+ }
35
+
36
+ export class InvalidTokenError extends XRPCError {
37
+ constructor(src: XRPCError) {
38
+ super(src.status, src.error, src.message, src.headers)
39
+ }
40
+ }
41
+
42
+ export class TokenRequiredError extends XRPCError {
43
+ constructor(src: XRPCError) {
44
+ super(src.status, src.error, src.message, src.headers)
45
+ }
46
+ }
47
+
48
+ export function toKnownErr(e: any) {
49
+ if (e instanceof XRPCError) {
50
+ if (e.error === 'ExpiredToken') return new ExpiredTokenError(e)
51
+ if (e.error === 'InvalidToken') return new InvalidTokenError(e)
52
+ if (e.error === 'TokenRequired') return new TokenRequiredError(e)
53
+ }
54
+ return e
55
+ }
@@ -90,7 +90,7 @@ export function detectFacets(text: UnicodeString): Facet[] | undefined {
90
90
  features: [
91
91
  {
92
92
  $type: 'app.bsky.richtext.facet#tag',
93
- tag,
93
+ tag: tag.replace(/^#/, ''),
94
94
  },
95
95
  ],
96
96
  })
package/src/types.ts CHANGED
@@ -14,6 +14,7 @@ export interface AtpSessionData {
14
14
  handle: string
15
15
  did: string
16
16
  email?: string
17
+ emailConfirmed?: boolean
17
18
  }
18
19
 
19
20
  /**
@@ -48,6 +48,7 @@ describe('agent', () => {
48
48
  expect(agent.session?.handle).toEqual(res.data.handle)
49
49
  expect(agent.session?.did).toEqual(res.data.did)
50
50
  expect(agent.session?.email).toEqual('user1@test.com')
51
+ expect(agent.session?.emailConfirmed).toEqual(false)
51
52
 
52
53
  const { data: sessionInfo } = await agent.api.com.atproto.server.getSession(
53
54
  {},
@@ -56,6 +57,7 @@ describe('agent', () => {
56
57
  did: res.data.did,
57
58
  handle: res.data.handle,
58
59
  email: 'user1@test.com',
60
+ emailConfirmed: false,
59
61
  })
60
62
 
61
63
  expect(events.length).toEqual(1)
@@ -93,6 +95,7 @@ describe('agent', () => {
93
95
  expect(agent2.session?.handle).toEqual(res1.data.handle)
94
96
  expect(agent2.session?.did).toEqual(res1.data.did)
95
97
  expect(agent2.session?.email).toEqual('user2@test.com')
98
+ expect(agent2.session?.emailConfirmed).toEqual(false)
96
99
 
97
100
  const { data: sessionInfo } =
98
101
  await agent2.api.com.atproto.server.getSession({})
@@ -100,6 +103,7 @@ describe('agent', () => {
100
103
  did: res1.data.did,
101
104
  handle: res1.data.handle,
102
105
  email,
106
+ emailConfirmed: false,
103
107
  })
104
108
 
105
109
  expect(events.length).toEqual(2)
@@ -142,6 +146,7 @@ describe('agent', () => {
142
146
  did: res1.data.did,
143
147
  handle: res1.data.handle,
144
148
  email: res1.data.email,
149
+ emailConfirmed: false,
145
150
  })
146
151
 
147
152
  expect(events.length).toEqual(2)
@@ -206,6 +211,8 @@ describe('agent', () => {
206
211
  expect(agent.session?.refreshJwt).not.toEqual(session1.refreshJwt)
207
212
  expect(agent.session?.handle).toEqual(session1.handle)
208
213
  expect(agent.session?.did).toEqual(session1.did)
214
+ expect(agent.session?.email).toEqual(session1.email)
215
+ expect(agent.session?.emailConfirmed).toEqual(session1.emailConfirmed)
209
216
 
210
217
  expect(events.length).toEqual(2)
211
218
  expect(events[0]).toEqual('create')
@@ -283,6 +290,8 @@ describe('agent', () => {
283
290
  expect(agent.session?.refreshJwt).not.toEqual(session1.refreshJwt)
284
291
  expect(agent.session?.handle).toEqual(session1.handle)
285
292
  expect(agent.session?.did).toEqual(session1.did)
293
+ expect(agent.session?.email).toEqual(session1.email)
294
+ expect(agent.session?.emailConfirmed).toEqual(session1.emailConfirmed)
286
295
 
287
296
  expect(events.length).toEqual(2)
288
297
  expect(events[0]).toEqual('create')
@@ -216,28 +216,28 @@ describe('detectFacets', () => {
216
216
  string[],
217
217
  { byteStart: number; byteEnd: number }[],
218
218
  ][] = [
219
- ['#a', ['#a'], [{ byteStart: 0, byteEnd: 2 }]],
219
+ ['#a', ['a'], [{ byteStart: 0, byteEnd: 2 }]],
220
220
  [
221
221
  '#a #b',
222
- ['#a', '#b'],
222
+ ['a', 'b'],
223
223
  [
224
224
  { byteStart: 0, byteEnd: 2 },
225
225
  { byteStart: 3, byteEnd: 5 },
226
226
  ],
227
227
  ],
228
228
  ['#1', [], []],
229
- ['#tag', ['#tag'], [{ byteStart: 0, byteEnd: 4 }]],
230
- ['body #tag', ['#tag'], [{ byteStart: 5, byteEnd: 9 }]],
231
- ['#tag body', ['#tag'], [{ byteStart: 0, byteEnd: 4 }]],
232
- ['body #tag body', ['#tag'], [{ byteStart: 5, byteEnd: 9 }]],
229
+ ['#tag', ['tag'], [{ byteStart: 0, byteEnd: 4 }]],
230
+ ['body #tag', ['tag'], [{ byteStart: 5, byteEnd: 9 }]],
231
+ ['#tag body', ['tag'], [{ byteStart: 0, byteEnd: 4 }]],
232
+ ['body #tag body', ['tag'], [{ byteStart: 5, byteEnd: 9 }]],
233
233
  ['body #1', [], []],
234
- ['body #a1', ['#a1'], [{ byteStart: 5, byteEnd: 8 }]],
234
+ ['body #a1', ['a1'], [{ byteStart: 5, byteEnd: 8 }]],
235
235
  ['#', [], []],
236
236
  ['text #', [], []],
237
237
  ['text # text', [], []],
238
238
  [
239
239
  'body #thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
240
- ['#thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
240
+ ['thisisa64characterstring_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
241
241
  [{ byteStart: 5, byteEnd: 71 }],
242
242
  ],
243
243
  [
@@ -247,19 +247,19 @@ describe('detectFacets', () => {
247
247
  ],
248
248
  [
249
249
  'its a #double#rainbow',
250
- ['#double#rainbow'],
250
+ ['double#rainbow'],
251
251
  [{ byteStart: 6, byteEnd: 21 }],
252
252
  ],
253
- ['##hashash', ['##hashash'], [{ byteStart: 0, byteEnd: 9 }]],
254
- ['some #n0n3s@n5e!', ['#n0n3s@n5e'], [{ byteStart: 5, byteEnd: 15 }]],
253
+ ['##hashash', ['#hashash'], [{ byteStart: 0, byteEnd: 9 }]],
254
+ ['some #n0n3s@n5e!', ['n0n3s@n5e'], [{ byteStart: 5, byteEnd: 15 }]],
255
255
  [
256
256
  'works #with,punctuation',
257
- ['#with,punctuation'],
257
+ ['with,punctuation'],
258
258
  [{ byteStart: 6, byteEnd: 23 }],
259
259
  ],
260
260
  [
261
261
  'strips trailing #punctuation, #like. #this!',
262
- ['#punctuation', '#like', '#this'],
262
+ ['punctuation', 'like', 'this'],
263
263
  [
264
264
  { byteStart: 16, byteEnd: 28 },
265
265
  { byteStart: 30, byteEnd: 35 },
@@ -268,12 +268,12 @@ describe('detectFacets', () => {
268
268
  ],
269
269
  [
270
270
  'strips #multi_trailing___...',
271
- ['#multi_trailing'],
271
+ ['multi_trailing'],
272
272
  [{ byteStart: 7, byteEnd: 22 }],
273
273
  ],
274
274
  [
275
275
  'works with #🦋 emoji, and #butter🦋fly',
276
- ['#🦋', '#butter🦋fly'],
276
+ ['🦋', 'butter🦋fly'],
277
277
  [
278
278
  { byteStart: 11, byteEnd: 16 },
279
279
  { byteStart: 28, byteEnd: 42 },
@@ -281,7 +281,7 @@ describe('detectFacets', () => {
281
281
  ],
282
282
  [
283
283
  '#same #same #but #diff',
284
- ['#same', '#same', '#but', '#diff'],
284
+ ['same', 'same', 'but', 'diff'],
285
285
  [
286
286
  { byteStart: 0, byteEnd: 5 },
287
287
  { byteStart: 6, byteEnd: 11 },
@@ -298,7 +298,7 @@ describe('detectFacets', () => {
298
298
  let detectedTags: string[] = []
299
299
  let detectedIndices: { byteStart: number; byteEnd: number }[] = []
300
300
 
301
- for (const { facet } of rt.segments()) {
301
+ for (const { facet, ...rest } of rt.segments()) {
302
302
  if (!facet) continue
303
303
  for (const feature of facet.features) {
304
304
  if (isTag(feature)) {