@atproto/api 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/api",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "codegen": "lex gen-api ./src/client ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -8,6 +8,8 @@ import {
8
8
  import { schemas } from './lexicons'
9
9
  import { CID } from 'multiformats/cid'
10
10
  import * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
11
+ import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
12
+ import * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
11
13
  import * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'
12
14
  import * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'
13
15
  import * as ComAtprotoAdminGetModerationReport from './types/com/atproto/admin/getModerationReport'
@@ -34,9 +36,11 @@ import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
34
36
  import * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
35
37
  import * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
36
38
  import * as ComAtprotoServerCreateSession from './types/com/atproto/server/createSession'
39
+ import * as ComAtprotoServerDefs from './types/com/atproto/server/defs'
37
40
  import * as ComAtprotoServerDeleteAccount from './types/com/atproto/server/deleteAccount'
38
41
  import * as ComAtprotoServerDeleteSession from './types/com/atproto/server/deleteSession'
39
42
  import * as ComAtprotoServerDescribeServer from './types/com/atproto/server/describeServer'
43
+ import * as ComAtprotoServerGetAccountInviteCodes from './types/com/atproto/server/getAccountInviteCodes'
40
44
  import * as ComAtprotoServerGetSession from './types/com/atproto/server/getSession'
41
45
  import * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
42
46
  import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
@@ -86,6 +90,8 @@ import * as AppBskyRichtextFacet from './types/app/bsky/richtext/facet'
86
90
  import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
87
91
 
88
92
  export * as ComAtprotoAdminDefs from './types/com/atproto/admin/defs'
93
+ export * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes'
94
+ export * as ComAtprotoAdminGetInviteCodes from './types/com/atproto/admin/getInviteCodes'
89
95
  export * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'
90
96
  export * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'
91
97
  export * as ComAtprotoAdminGetModerationReport from './types/com/atproto/admin/getModerationReport'
@@ -112,9 +118,11 @@ export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
112
118
  export * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
113
119
  export * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
114
120
  export * as ComAtprotoServerCreateSession from './types/com/atproto/server/createSession'
121
+ export * as ComAtprotoServerDefs from './types/com/atproto/server/defs'
115
122
  export * as ComAtprotoServerDeleteAccount from './types/com/atproto/server/deleteAccount'
116
123
  export * as ComAtprotoServerDeleteSession from './types/com/atproto/server/deleteSession'
117
124
  export * as ComAtprotoServerDescribeServer from './types/com/atproto/server/describeServer'
125
+ export * as ComAtprotoServerGetAccountInviteCodes from './types/com/atproto/server/getAccountInviteCodes'
118
126
  export * as ComAtprotoServerGetSession from './types/com/atproto/server/getSession'
119
127
  export * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
120
128
  export * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
@@ -240,6 +248,28 @@ export class AdminNS {
240
248
  this._service = service
241
249
  }
242
250
 
251
+ disableInviteCodes(
252
+ data?: ComAtprotoAdminDisableInviteCodes.InputSchema,
253
+ opts?: ComAtprotoAdminDisableInviteCodes.CallOptions,
254
+ ): Promise<ComAtprotoAdminDisableInviteCodes.Response> {
255
+ return this._service.xrpc
256
+ .call('com.atproto.admin.disableInviteCodes', opts?.qp, data, opts)
257
+ .catch((e) => {
258
+ throw ComAtprotoAdminDisableInviteCodes.toKnownErr(e)
259
+ })
260
+ }
261
+
262
+ getInviteCodes(
263
+ params?: ComAtprotoAdminGetInviteCodes.QueryParams,
264
+ opts?: ComAtprotoAdminGetInviteCodes.CallOptions,
265
+ ): Promise<ComAtprotoAdminGetInviteCodes.Response> {
266
+ return this._service.xrpc
267
+ .call('com.atproto.admin.getInviteCodes', params, undefined, opts)
268
+ .catch((e) => {
269
+ throw ComAtprotoAdminGetInviteCodes.toKnownErr(e)
270
+ })
271
+ }
272
+
243
273
  getModerationAction(
244
274
  params?: ComAtprotoAdminGetModerationAction.QueryParams,
245
275
  opts?: ComAtprotoAdminGetModerationAction.CallOptions,
@@ -569,6 +599,17 @@ export class ServerNS {
569
599
  })
570
600
  }
571
601
 
602
+ getAccountInviteCodes(
603
+ params?: ComAtprotoServerGetAccountInviteCodes.QueryParams,
604
+ opts?: ComAtprotoServerGetAccountInviteCodes.CallOptions,
605
+ ): Promise<ComAtprotoServerGetAccountInviteCodes.Response> {
606
+ return this._service.xrpc
607
+ .call('com.atproto.server.getAccountInviteCodes', params, undefined, opts)
608
+ .catch((e) => {
609
+ throw ComAtprotoServerGetAccountInviteCodes.toKnownErr(e)
610
+ })
611
+ }
612
+
572
613
  getSession(
573
614
  params?: ComAtprotoServerGetSession.QueryParams,
574
615
  opts?: ComAtprotoServerGetSession.CallOptions,
@@ -299,6 +299,17 @@ export const schemaDict = {
299
299
  type: 'ref',
300
300
  ref: 'lex:com.atproto.admin.defs#moderation',
301
301
  },
302
+ invitedBy: {
303
+ type: 'ref',
304
+ ref: 'lex:com.atproto.server.defs#inviteCode',
305
+ },
306
+ invites: {
307
+ type: 'array',
308
+ items: {
309
+ type: 'ref',
310
+ ref: 'lex:com.atproto.server.defs#inviteCode',
311
+ },
312
+ },
302
313
  },
303
314
  },
304
315
  repoViewDetail: {
@@ -336,6 +347,17 @@ export const schemaDict = {
336
347
  type: 'ref',
337
348
  ref: 'lex:com.atproto.admin.defs#moderationDetail',
338
349
  },
350
+ invitedBy: {
351
+ type: 'ref',
352
+ ref: 'lex:com.atproto.server.defs#inviteCode',
353
+ },
354
+ invites: {
355
+ type: 'array',
356
+ items: {
357
+ type: 'ref',
358
+ ref: 'lex:com.atproto.server.defs#inviteCode',
359
+ },
360
+ },
339
361
  },
340
362
  },
341
363
  repoRef: {
@@ -530,6 +552,85 @@ export const schemaDict = {
530
552
  },
531
553
  },
532
554
  },
555
+ ComAtprotoAdminDisableInviteCodes: {
556
+ lexicon: 1,
557
+ id: 'com.atproto.admin.disableInviteCodes',
558
+ defs: {
559
+ main: {
560
+ type: 'procedure',
561
+ description:
562
+ 'Disable some set of codes and/or all codes associated with a set of users',
563
+ input: {
564
+ encoding: 'application/json',
565
+ schema: {
566
+ type: 'object',
567
+ properties: {
568
+ codes: {
569
+ type: 'array',
570
+ items: {
571
+ type: 'string',
572
+ },
573
+ },
574
+ accounts: {
575
+ type: 'array',
576
+ items: {
577
+ type: 'string',
578
+ },
579
+ },
580
+ },
581
+ },
582
+ },
583
+ },
584
+ },
585
+ },
586
+ ComAtprotoAdminGetInviteCodes: {
587
+ lexicon: 1,
588
+ id: 'com.atproto.admin.getInviteCodes',
589
+ defs: {
590
+ main: {
591
+ type: 'query',
592
+ description: 'Admin view of invite codes',
593
+ parameters: {
594
+ type: 'params',
595
+ properties: {
596
+ sort: {
597
+ type: 'string',
598
+ knownValues: ['recent', 'usage'],
599
+ default: 'recent',
600
+ },
601
+ limit: {
602
+ type: 'integer',
603
+ minimum: 1,
604
+ maximum: 500,
605
+ default: 100,
606
+ },
607
+ cursor: {
608
+ type: 'string',
609
+ },
610
+ },
611
+ },
612
+ output: {
613
+ encoding: 'application/json',
614
+ schema: {
615
+ type: 'object',
616
+ required: ['codes'],
617
+ properties: {
618
+ cursor: {
619
+ type: 'string',
620
+ },
621
+ codes: {
622
+ type: 'array',
623
+ items: {
624
+ type: 'ref',
625
+ ref: 'lex:com.atproto.server.defs#inviteCode',
626
+ },
627
+ },
628
+ },
629
+ },
630
+ },
631
+ },
632
+ },
633
+ },
533
634
  ComAtprotoAdminGetModerationAction: {
534
635
  lexicon: 1,
535
636
  id: 'com.atproto.admin.getModerationAction',
@@ -823,6 +924,9 @@ export const schemaDict = {
823
924
  term: {
824
925
  type: 'string',
825
926
  },
927
+ invitedBy: {
928
+ type: 'string',
929
+ },
826
930
  limit: {
827
931
  type: 'integer',
828
932
  minimum: 1,
@@ -1701,6 +1805,10 @@ export const schemaDict = {
1701
1805
  useCount: {
1702
1806
  type: 'integer',
1703
1807
  },
1808
+ forAccount: {
1809
+ type: 'string',
1810
+ format: 'did',
1811
+ },
1704
1812
  },
1705
1813
  },
1706
1814
  },
@@ -1777,6 +1885,66 @@ export const schemaDict = {
1777
1885
  },
1778
1886
  },
1779
1887
  },
1888
+ ComAtprotoServerDefs: {
1889
+ lexicon: 1,
1890
+ id: 'com.atproto.server.defs',
1891
+ defs: {
1892
+ inviteCode: {
1893
+ type: 'object',
1894
+ required: [
1895
+ 'code',
1896
+ 'available',
1897
+ 'disabled',
1898
+ 'forAccount',
1899
+ 'createdBy',
1900
+ 'createdAt',
1901
+ 'uses',
1902
+ ],
1903
+ properties: {
1904
+ code: {
1905
+ type: 'string',
1906
+ },
1907
+ available: {
1908
+ type: 'integer',
1909
+ },
1910
+ disabled: {
1911
+ type: 'boolean',
1912
+ },
1913
+ forAccount: {
1914
+ type: 'string',
1915
+ },
1916
+ createdBy: {
1917
+ type: 'string',
1918
+ },
1919
+ createdAt: {
1920
+ type: 'string',
1921
+ format: 'datetime',
1922
+ },
1923
+ uses: {
1924
+ type: 'array',
1925
+ items: {
1926
+ type: 'ref',
1927
+ ref: 'lex:com.atproto.server.defs#inviteCodeUse',
1928
+ },
1929
+ },
1930
+ },
1931
+ },
1932
+ inviteCodeUse: {
1933
+ type: 'object',
1934
+ required: ['usedBy', 'usedAt'],
1935
+ properties: {
1936
+ usedBy: {
1937
+ type: 'string',
1938
+ format: 'did',
1939
+ },
1940
+ usedAt: {
1941
+ type: 'string',
1942
+ format: 'datetime',
1943
+ },
1944
+ },
1945
+ },
1946
+ },
1947
+ },
1780
1948
  ComAtprotoServerDeleteAccount: {
1781
1949
  lexicon: 1,
1782
1950
  id: 'com.atproto.server.deleteAccount',
@@ -1868,6 +2036,50 @@ export const schemaDict = {
1868
2036
  },
1869
2037
  },
1870
2038
  },
2039
+ ComAtprotoServerGetAccountInviteCodes: {
2040
+ lexicon: 1,
2041
+ id: 'com.atproto.server.getAccountInviteCodes',
2042
+ defs: {
2043
+ main: {
2044
+ type: 'query',
2045
+ description: 'Get all invite codes for a given account',
2046
+ parameters: {
2047
+ type: 'params',
2048
+ properties: {
2049
+ includeUsed: {
2050
+ type: 'boolean',
2051
+ default: true,
2052
+ },
2053
+ createAvailable: {
2054
+ type: 'boolean',
2055
+ default: true,
2056
+ },
2057
+ },
2058
+ },
2059
+ output: {
2060
+ encoding: 'application/json',
2061
+ schema: {
2062
+ type: 'object',
2063
+ required: ['codes'],
2064
+ properties: {
2065
+ codes: {
2066
+ type: 'array',
2067
+ items: {
2068
+ type: 'ref',
2069
+ ref: 'lex:com.atproto.server.defs#inviteCode',
2070
+ },
2071
+ },
2072
+ },
2073
+ },
2074
+ },
2075
+ errors: [
2076
+ {
2077
+ name: 'DuplicateCreate',
2078
+ },
2079
+ ],
2080
+ },
2081
+ },
2082
+ },
1871
2083
  ComAtprotoServerGetSession: {
1872
2084
  lexicon: 1,
1873
2085
  id: 'com.atproto.server.getSession',
@@ -4174,6 +4386,8 @@ export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
4174
4386
  export const lexicons: Lexicons = new Lexicons(schemas)
4175
4387
  export const ids = {
4176
4388
  ComAtprotoAdminDefs: 'com.atproto.admin.defs',
4389
+ ComAtprotoAdminDisableInviteCodes: 'com.atproto.admin.disableInviteCodes',
4390
+ ComAtprotoAdminGetInviteCodes: 'com.atproto.admin.getInviteCodes',
4177
4391
  ComAtprotoAdminGetModerationAction: 'com.atproto.admin.getModerationAction',
4178
4392
  ComAtprotoAdminGetModerationActions: 'com.atproto.admin.getModerationActions',
4179
4393
  ComAtprotoAdminGetModerationReport: 'com.atproto.admin.getModerationReport',
@@ -4202,9 +4416,12 @@ export const ids = {
4202
4416
  ComAtprotoServerCreateAccount: 'com.atproto.server.createAccount',
4203
4417
  ComAtprotoServerCreateInviteCode: 'com.atproto.server.createInviteCode',
4204
4418
  ComAtprotoServerCreateSession: 'com.atproto.server.createSession',
4419
+ ComAtprotoServerDefs: 'com.atproto.server.defs',
4205
4420
  ComAtprotoServerDeleteAccount: 'com.atproto.server.deleteAccount',
4206
4421
  ComAtprotoServerDeleteSession: 'com.atproto.server.deleteSession',
4207
4422
  ComAtprotoServerDescribeServer: 'com.atproto.server.describeServer',
4423
+ ComAtprotoServerGetAccountInviteCodes:
4424
+ 'com.atproto.server.getAccountInviteCodes',
4208
4425
  ComAtprotoServerGetSession: 'com.atproto.server.getSession',
4209
4426
  ComAtprotoServerRefreshSession: 'com.atproto.server.refreshSession',
4210
4427
  ComAtprotoServerRequestAccountDelete:
@@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as ComAtprotoRepoStrongRef from '../repo/strongRef'
9
9
  import * as ComAtprotoModerationDefs from '../moderation/defs'
10
+ import * as ComAtprotoServerDefs from '../server/defs'
10
11
 
11
12
  export interface ActionView {
12
13
  id: number
@@ -167,6 +168,8 @@ export interface RepoView {
167
168
  relatedRecords: {}[]
168
169
  indexedAt: string
169
170
  moderation: Moderation
171
+ invitedBy?: ComAtprotoServerDefs.InviteCode
172
+ invites?: ComAtprotoServerDefs.InviteCode[]
170
173
  [k: string]: unknown
171
174
  }
172
175
 
@@ -189,6 +192,8 @@ export interface RepoViewDetail {
189
192
  relatedRecords: {}[]
190
193
  indexedAt: string
191
194
  moderation: ModerationDetail
195
+ invitedBy?: ComAtprotoServerDefs.InviteCode
196
+ invites?: ComAtprotoServerDefs.InviteCode[]
192
197
  [k: string]: unknown
193
198
  }
194
199
 
@@ -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
+
10
+ export interface QueryParams {}
11
+
12
+ export interface InputSchema {
13
+ codes?: string[]
14
+ accounts?: 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 function toKnownErr(e: any) {
30
+ if (e instanceof XRPCError) {
31
+ }
32
+ return e
33
+ }
@@ -0,0 +1,39 @@
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 ComAtprotoServerDefs from '../server/defs'
10
+
11
+ export interface QueryParams {
12
+ sort?: 'recent' | 'usage' | (string & {})
13
+ limit?: number
14
+ cursor?: string
15
+ }
16
+
17
+ export type InputSchema = undefined
18
+
19
+ export interface OutputSchema {
20
+ cursor?: string
21
+ codes: ComAtprotoServerDefs.InviteCode[]
22
+ [k: string]: unknown
23
+ }
24
+
25
+ export interface CallOptions {
26
+ headers?: Headers
27
+ }
28
+
29
+ export interface Response {
30
+ success: boolean
31
+ headers: Headers
32
+ data: OutputSchema
33
+ }
34
+
35
+ export function toKnownErr(e: any) {
36
+ if (e instanceof XRPCError) {
37
+ }
38
+ return e
39
+ }
@@ -10,6 +10,7 @@ import * as ComAtprotoAdminDefs from './defs'
10
10
 
11
11
  export interface QueryParams {
12
12
  term?: string
13
+ invitedBy?: string
13
14
  limit?: number
14
15
  cursor?: string
15
16
  }
@@ -11,6 +11,7 @@ export interface QueryParams {}
11
11
 
12
12
  export interface InputSchema {
13
13
  useCount: number
14
+ forAccount?: string
14
15
  [k: string]: unknown
15
16
  }
16
17
 
@@ -0,0 +1,48 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { ValidationResult, BlobRef } from '@atproto/lexicon'
5
+ import { isObj, hasProp } from '../../../../util'
6
+ import { lexicons } from '../../../../lexicons'
7
+ import { CID } from 'multiformats/cid'
8
+
9
+ export interface InviteCode {
10
+ code: string
11
+ available: number
12
+ disabled: boolean
13
+ forAccount: string
14
+ createdBy: string
15
+ createdAt: string
16
+ uses: InviteCodeUse[]
17
+ [k: string]: unknown
18
+ }
19
+
20
+ export function isInviteCode(v: unknown): v is InviteCode {
21
+ return (
22
+ isObj(v) &&
23
+ hasProp(v, '$type') &&
24
+ v.$type === 'com.atproto.server.defs#inviteCode'
25
+ )
26
+ }
27
+
28
+ export function validateInviteCode(v: unknown): ValidationResult {
29
+ return lexicons.validate('com.atproto.server.defs#inviteCode', v)
30
+ }
31
+
32
+ export interface InviteCodeUse {
33
+ usedBy: string
34
+ usedAt: string
35
+ [k: string]: unknown
36
+ }
37
+
38
+ export function isInviteCodeUse(v: unknown): v is InviteCodeUse {
39
+ return (
40
+ isObj(v) &&
41
+ hasProp(v, '$type') &&
42
+ v.$type === 'com.atproto.server.defs#inviteCodeUse'
43
+ )
44
+ }
45
+
46
+ export function validateInviteCodeUse(v: unknown): ValidationResult {
47
+ return lexicons.validate('com.atproto.server.defs#inviteCodeUse', v)
48
+ }
@@ -0,0 +1,44 @@
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 ComAtprotoServerDefs from './defs'
10
+
11
+ export interface QueryParams {
12
+ includeUsed?: boolean
13
+ createAvailable?: boolean
14
+ }
15
+
16
+ export type InputSchema = undefined
17
+
18
+ export interface OutputSchema {
19
+ codes: ComAtprotoServerDefs.InviteCode[]
20
+ [k: string]: unknown
21
+ }
22
+
23
+ export interface CallOptions {
24
+ headers?: Headers
25
+ }
26
+
27
+ export interface Response {
28
+ success: boolean
29
+ headers: Headers
30
+ data: OutputSchema
31
+ }
32
+
33
+ export class DuplicateCreateError extends XRPCError {
34
+ constructor(src: XRPCError) {
35
+ super(src.status, src.error, src.message)
36
+ }
37
+ }
38
+
39
+ export function toKnownErr(e: any) {
40
+ if (e instanceof XRPCError) {
41
+ if (e.error === 'DuplicateCreate') return new DuplicateCreateError(e)
42
+ }
43
+ return e
44
+ }