@atproto/api 0.3.1 → 0.3.3

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.
@@ -74,7 +74,7 @@ async function fetchHandler(
74
74
  } else if (resMimeType.startsWith('text/')) {
75
75
  resBody = await res.text()
76
76
  } else {
77
- throw new Error('TODO: non-textual response body')
77
+ resBody = await res.blob()
78
78
  }
79
79
  }
80
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -71,10 +71,12 @@ import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
71
71
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
72
72
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
73
73
  import * as AppBskyActorDefs from './types/app/bsky/actor/defs'
74
+ import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
74
75
  import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
75
76
  import * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles'
76
77
  import * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions'
77
78
  import * as AppBskyActorProfile from './types/app/bsky/actor/profile'
79
+ import * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
78
80
  import * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
79
81
  import * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
80
82
  import * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
@@ -177,10 +179,12 @@ export * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
177
179
  export * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl'
178
180
  export * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos'
179
181
  export * as AppBskyActorDefs from './types/app/bsky/actor/defs'
182
+ export * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
180
183
  export * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
181
184
  export * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles'
182
185
  export * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions'
183
186
  export * as AppBskyActorProfile from './types/app/bsky/actor/profile'
187
+ export * as AppBskyActorPutPreferences from './types/app/bsky/actor/putPreferences'
184
188
  export * as AppBskyActorSearchActors from './types/app/bsky/actor/searchActors'
185
189
  export * as AppBskyActorSearchActorsTypeahead from './types/app/bsky/actor/searchActorsTypeahead'
186
190
  export * as AppBskyEmbedExternal from './types/app/bsky/embed/external'
@@ -1012,6 +1016,17 @@ export class ActorNS {
1012
1016
  this.profile = new ProfileRecord(service)
1013
1017
  }
1014
1018
 
1019
+ getPreferences(
1020
+ params?: AppBskyActorGetPreferences.QueryParams,
1021
+ opts?: AppBskyActorGetPreferences.CallOptions,
1022
+ ): Promise<AppBskyActorGetPreferences.Response> {
1023
+ return this._service.xrpc
1024
+ .call('app.bsky.actor.getPreferences', params, undefined, opts)
1025
+ .catch((e) => {
1026
+ throw AppBskyActorGetPreferences.toKnownErr(e)
1027
+ })
1028
+ }
1029
+
1015
1030
  getProfile(
1016
1031
  params?: AppBskyActorGetProfile.QueryParams,
1017
1032
  opts?: AppBskyActorGetProfile.CallOptions,
@@ -1045,6 +1060,17 @@ export class ActorNS {
1045
1060
  })
1046
1061
  }
1047
1062
 
1063
+ putPreferences(
1064
+ data?: AppBskyActorPutPreferences.InputSchema,
1065
+ opts?: AppBskyActorPutPreferences.CallOptions,
1066
+ ): Promise<AppBskyActorPutPreferences.Response> {
1067
+ return this._service.xrpc
1068
+ .call('app.bsky.actor.putPreferences', opts?.qp, data, opts)
1069
+ .catch((e) => {
1070
+ throw AppBskyActorPutPreferences.toKnownErr(e)
1071
+ })
1072
+ }
1073
+
1048
1074
  searchActors(
1049
1075
  params?: AppBskyActorSearchActors.QueryParams,
1050
1076
  opts?: AppBskyActorSearchActors.CallOptions,
@@ -3509,6 +3509,66 @@ export const schemaDict = {
3509
3509
  },
3510
3510
  },
3511
3511
  },
3512
+ preferences: {
3513
+ type: 'array',
3514
+ items: {
3515
+ type: 'union',
3516
+ refs: [
3517
+ 'lex:app.bsky.actor.defs#adultContentPref',
3518
+ 'lex:app.bsky.actor.defs#contentLabelPref',
3519
+ ],
3520
+ },
3521
+ },
3522
+ adultContentPref: {
3523
+ type: 'object',
3524
+ required: ['enabled'],
3525
+ properties: {
3526
+ enabled: {
3527
+ type: 'boolean',
3528
+ default: false,
3529
+ },
3530
+ },
3531
+ },
3532
+ contentLabelPref: {
3533
+ type: 'object',
3534
+ required: ['label', 'visibility'],
3535
+ properties: {
3536
+ label: {
3537
+ type: 'string',
3538
+ },
3539
+ visibility: {
3540
+ type: 'string',
3541
+ knownValues: ['show', 'warn', 'hide'],
3542
+ },
3543
+ },
3544
+ },
3545
+ },
3546
+ },
3547
+ AppBskyActorGetPreferences: {
3548
+ lexicon: 1,
3549
+ id: 'app.bsky.actor.getPreferences',
3550
+ defs: {
3551
+ main: {
3552
+ type: 'query',
3553
+ description: 'Get private preferences attached to the account.',
3554
+ parameters: {
3555
+ type: 'params',
3556
+ properties: {},
3557
+ },
3558
+ output: {
3559
+ encoding: 'application/json',
3560
+ schema: {
3561
+ type: 'object',
3562
+ required: ['preferences'],
3563
+ properties: {
3564
+ preferences: {
3565
+ type: 'ref',
3566
+ ref: 'lex:app.bsky.actor.defs#preferences',
3567
+ },
3568
+ },
3569
+ },
3570
+ },
3571
+ },
3512
3572
  },
3513
3573
  },
3514
3574
  AppBskyActorGetProfile: {
@@ -3655,6 +3715,29 @@ export const schemaDict = {
3655
3715
  },
3656
3716
  },
3657
3717
  },
3718
+ AppBskyActorPutPreferences: {
3719
+ lexicon: 1,
3720
+ id: 'app.bsky.actor.putPreferences',
3721
+ defs: {
3722
+ main: {
3723
+ type: 'procedure',
3724
+ description: 'Sets the private preferences attached to the account.',
3725
+ input: {
3726
+ encoding: 'application/json',
3727
+ schema: {
3728
+ type: 'object',
3729
+ required: ['preferences'],
3730
+ properties: {
3731
+ preferences: {
3732
+ type: 'ref',
3733
+ ref: 'lex:app.bsky.actor.defs#preferences',
3734
+ },
3735
+ },
3736
+ },
3737
+ },
3738
+ },
3739
+ },
3740
+ },
3658
3741
  AppBskyActorSearchActors: {
3659
3742
  lexicon: 1,
3660
3743
  id: 'app.bsky.actor.searchActors',
@@ -5659,10 +5742,12 @@ export const ids = {
5659
5742
  ComAtprotoSyncRequestCrawl: 'com.atproto.sync.requestCrawl',
5660
5743
  ComAtprotoSyncSubscribeRepos: 'com.atproto.sync.subscribeRepos',
5661
5744
  AppBskyActorDefs: 'app.bsky.actor.defs',
5745
+ AppBskyActorGetPreferences: 'app.bsky.actor.getPreferences',
5662
5746
  AppBskyActorGetProfile: 'app.bsky.actor.getProfile',
5663
5747
  AppBskyActorGetProfiles: 'app.bsky.actor.getProfiles',
5664
5748
  AppBskyActorGetSuggestions: 'app.bsky.actor.getSuggestions',
5665
5749
  AppBskyActorProfile: 'app.bsky.actor.profile',
5750
+ AppBskyActorPutPreferences: 'app.bsky.actor.putPreferences',
5666
5751
  AppBskyActorSearchActors: 'app.bsky.actor.searchActors',
5667
5752
  AppBskyActorSearchActorsTypeahead: 'app.bsky.actor.searchActorsTypeahead',
5668
5753
  AppBskyEmbedExternal: 'app.bsky.embed.external',
@@ -103,3 +103,44 @@ export function isViewerState(v: unknown): v is ViewerState {
103
103
  export function validateViewerState(v: unknown): ValidationResult {
104
104
  return lexicons.validate('app.bsky.actor.defs#viewerState', v)
105
105
  }
106
+
107
+ export type Preferences = (
108
+ | AdultContentPref
109
+ | ContentLabelPref
110
+ | { $type: string; [k: string]: unknown }
111
+ )[]
112
+
113
+ export interface AdultContentPref {
114
+ enabled: boolean
115
+ [k: string]: unknown
116
+ }
117
+
118
+ export function isAdultContentPref(v: unknown): v is AdultContentPref {
119
+ return (
120
+ isObj(v) &&
121
+ hasProp(v, '$type') &&
122
+ v.$type === 'app.bsky.actor.defs#adultContentPref'
123
+ )
124
+ }
125
+
126
+ export function validateAdultContentPref(v: unknown): ValidationResult {
127
+ return lexicons.validate('app.bsky.actor.defs#adultContentPref', v)
128
+ }
129
+
130
+ export interface ContentLabelPref {
131
+ label: string
132
+ visibility: 'show' | 'warn' | 'hide' | (string & {})
133
+ [k: string]: unknown
134
+ }
135
+
136
+ export function isContentLabelPref(v: unknown): v is ContentLabelPref {
137
+ return (
138
+ isObj(v) &&
139
+ hasProp(v, '$type') &&
140
+ v.$type === 'app.bsky.actor.defs#contentLabelPref'
141
+ )
142
+ }
143
+
144
+ export function validateContentLabelPref(v: unknown): ValidationResult {
145
+ return lexicons.validate('app.bsky.actor.defs#contentLabelPref', v)
146
+ }
@@ -0,0 +1,34 @@
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 AppBskyActorDefs from './defs'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export type InputSchema = undefined
14
+
15
+ export interface OutputSchema {
16
+ preferences: AppBskyActorDefs.Preferences
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export interface CallOptions {
21
+ headers?: Headers
22
+ }
23
+
24
+ export interface Response {
25
+ success: boolean
26
+ headers: Headers
27
+ data: OutputSchema
28
+ }
29
+
30
+ export function toKnownErr(e: any) {
31
+ if (e instanceof XRPCError) {
32
+ }
33
+ return e
34
+ }
@@ -0,0 +1,33 @@
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 AppBskyActorDefs from './defs'
10
+
11
+ export interface QueryParams {}
12
+
13
+ export interface InputSchema {
14
+ preferences: AppBskyActorDefs.Preferences
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 function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }