@atproto/api
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -73,2 +73,3 @@ import { Client as XrpcClient, ServiceClient as XrpcServiceClient } from '@atproto/xrpc'; | ||
export * as ComAtprotoAccountResetPassword from './types/com/atproto/account/resetPassword'; | ||
export * as ComAtprotoAdminBlob from './types/com/atproto/admin/blob'; | ||
export * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction'; | ||
@@ -164,24 +165,22 @@ export * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions'; | ||
}; | ||
export declare class Client { | ||
export declare class AtpBaseClient { | ||
xrpc: XrpcClient; | ||
constructor(); | ||
service(serviceUri: string | URL): ServiceClient; | ||
service(serviceUri: string | URL): AtpServiceClient; | ||
} | ||
declare const defaultInst: Client; | ||
export default defaultInst; | ||
export declare class ServiceClient { | ||
_baseClient: Client; | ||
export declare class AtpServiceClient { | ||
_baseClient: AtpBaseClient; | ||
xrpc: XrpcServiceClient; | ||
com: ComNS; | ||
app: AppNS; | ||
constructor(baseClient: Client, xrpcService: XrpcServiceClient); | ||
constructor(baseClient: AtpBaseClient, xrpcService: XrpcServiceClient); | ||
setHeader(key: string, value: string): void; | ||
} | ||
export declare class ComNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
atproto: AtprotoNS; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class AtprotoNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
account: AccountNS; | ||
@@ -196,7 +195,7 @@ admin: AdminNS; | ||
sync: SyncNS; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class AccountNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
create(data?: ComAtprotoAccountCreate.InputSchema, opts?: ComAtprotoAccountCreate.CallOptions): Promise<ComAtprotoAccountCreate.Response>; | ||
@@ -211,4 +210,4 @@ createInviteCode(data?: ComAtprotoAccountCreateInviteCode.InputSchema, opts?: ComAtprotoAccountCreateInviteCode.CallOptions): Promise<ComAtprotoAccountCreateInviteCode.Response>; | ||
export declare class AdminNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
getModerationAction(params?: ComAtprotoAdminGetModerationAction.QueryParams, opts?: ComAtprotoAdminGetModerationAction.CallOptions): Promise<ComAtprotoAdminGetModerationAction.Response>; | ||
@@ -226,14 +225,14 @@ getModerationActions(params?: ComAtprotoAdminGetModerationActions.QueryParams, opts?: ComAtprotoAdminGetModerationActions.CallOptions): Promise<ComAtprotoAdminGetModerationActions.Response>; | ||
export declare class BlobNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
upload(data?: ComAtprotoBlobUpload.InputSchema, opts?: ComAtprotoBlobUpload.CallOptions): Promise<ComAtprotoBlobUpload.Response>; | ||
} | ||
export declare class HandleNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
resolve(params?: ComAtprotoHandleResolve.QueryParams, opts?: ComAtprotoHandleResolve.CallOptions): Promise<ComAtprotoHandleResolve.Response>; | ||
} | ||
export declare class RepoNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
batchWrite(data?: ComAtprotoRepoBatchWrite.InputSchema, opts?: ComAtprotoRepoBatchWrite.CallOptions): Promise<ComAtprotoRepoBatchWrite.Response>; | ||
@@ -248,14 +247,14 @@ createRecord(data?: ComAtprotoRepoCreateRecord.InputSchema, opts?: ComAtprotoRepoCreateRecord.CallOptions): Promise<ComAtprotoRepoCreateRecord.Response>; | ||
export declare class ReportNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
create(data?: ComAtprotoReportCreate.InputSchema, opts?: ComAtprotoReportCreate.CallOptions): Promise<ComAtprotoReportCreate.Response>; | ||
} | ||
export declare class ServerNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
getAccountsConfig(params?: ComAtprotoServerGetAccountsConfig.QueryParams, opts?: ComAtprotoServerGetAccountsConfig.CallOptions): Promise<ComAtprotoServerGetAccountsConfig.Response>; | ||
} | ||
export declare class SessionNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
create(data?: ComAtprotoSessionCreate.InputSchema, opts?: ComAtprotoSessionCreate.CallOptions): Promise<ComAtprotoSessionCreate.Response>; | ||
@@ -267,4 +266,4 @@ delete(data?: ComAtprotoSessionDelete.InputSchema, opts?: ComAtprotoSessionDelete.CallOptions): Promise<ComAtprotoSessionDelete.Response>; | ||
export declare class SyncNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
getCheckout(params?: ComAtprotoSyncGetCheckout.QueryParams, opts?: ComAtprotoSyncGetCheckout.CallOptions): Promise<ComAtprotoSyncGetCheckout.Response>; | ||
@@ -277,8 +276,8 @@ getCommitPath(params?: ComAtprotoSyncGetCommitPath.QueryParams, opts?: ComAtprotoSyncGetCommitPath.CallOptions): Promise<ComAtprotoSyncGetCommitPath.Response>; | ||
export declare class AppNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
bsky: BskyNS; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class BskyNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
actor: ActorNS; | ||
@@ -290,8 +289,8 @@ embed: EmbedNS; | ||
system: SystemNS; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class ActorNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
profile: ProfileRecord; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
getProfile(params?: AppBskyActorGetProfile.QueryParams, opts?: AppBskyActorGetProfile.CallOptions): Promise<AppBskyActorGetProfile.Response>; | ||
@@ -304,4 +303,4 @@ getSuggestions(params?: AppBskyActorGetSuggestions.QueryParams, opts?: AppBskyActorGetSuggestions.CallOptions): Promise<AppBskyActorGetSuggestions.Response>; | ||
export declare class ProfileRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -326,11 +325,11 @@ cursor?: string; | ||
export declare class EmbedNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class FeedNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
post: PostRecord; | ||
repost: RepostRecord; | ||
vote: VoteRecord; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
getAuthorFeed(params?: AppBskyFeedGetAuthorFeed.QueryParams, opts?: AppBskyFeedGetAuthorFeed.CallOptions): Promise<AppBskyFeedGetAuthorFeed.Response>; | ||
@@ -344,4 +343,4 @@ getPostThread(params?: AppBskyFeedGetPostThread.QueryParams, opts?: AppBskyFeedGetPostThread.CallOptions): Promise<AppBskyFeedGetPostThread.Response>; | ||
export declare class PostRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -366,4 +365,4 @@ cursor?: string; | ||
export declare class RepostRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -388,4 +387,4 @@ cursor?: string; | ||
export declare class VoteRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -410,7 +409,7 @@ cursor?: string; | ||
export declare class GraphNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
assertion: AssertionRecord; | ||
confirmation: ConfirmationRecord; | ||
follow: FollowRecord; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
getFollowers(params?: AppBskyGraphGetFollowers.QueryParams, opts?: AppBskyGraphGetFollowers.CallOptions): Promise<AppBskyGraphGetFollowers.Response>; | ||
@@ -423,4 +422,4 @@ getFollows(params?: AppBskyGraphGetFollows.QueryParams, opts?: AppBskyGraphGetFollows.CallOptions): Promise<AppBskyGraphGetFollows.Response>; | ||
export declare class AssertionRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -445,4 +444,4 @@ cursor?: string; | ||
export declare class ConfirmationRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -467,4 +466,4 @@ cursor?: string; | ||
export declare class FollowRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -489,4 +488,4 @@ cursor?: string; | ||
export declare class NotificationNS { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
getCount(params?: AppBskyNotificationGetCount.QueryParams, opts?: AppBskyNotificationGetCount.CallOptions): Promise<AppBskyNotificationGetCount.Response>; | ||
@@ -497,9 +496,9 @@ list(params?: AppBskyNotificationList.QueryParams, opts?: AppBskyNotificationList.CallOptions): Promise<AppBskyNotificationList.Response>; | ||
export declare class SystemNS { | ||
_service: ServiceClient; | ||
_service: AtpServiceClient; | ||
declaration: DeclarationRecord; | ||
constructor(service: ServiceClient); | ||
constructor(service: AtpServiceClient); | ||
} | ||
export declare class DeclarationRecord { | ||
_service: ServiceClient; | ||
constructor(service: ServiceClient); | ||
_service: AtpServiceClient; | ||
constructor(service: AtpServiceClient); | ||
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{ | ||
@@ -506,0 +505,0 @@ cursor?: string; |
@@ -31,3 +31,2 @@ import { Headers } from '@atproto/xrpc'; | ||
indexedAt?: string; | ||
myState?: MyState; | ||
[k: string]: unknown; | ||
@@ -37,7 +36,1 @@ } | ||
export declare function validateActor(v: unknown): ValidationResult; | ||
export interface MyState { | ||
follow?: string; | ||
[k: string]: unknown; | ||
} | ||
export declare function isMyState(v: unknown): v is MyState; | ||
export declare function validateMyState(v: unknown): ValidationResult; |
@@ -6,6 +6,7 @@ import { ValidationResult } from '@atproto/lexicon'; | ||
import * as ComAtprotoAdminRecord from './record'; | ||
import * as ComAtprotoAdminBlob from './blob'; | ||
import * as ComAtprotoAdminModerationReport from './moderationReport'; | ||
export interface View { | ||
id: number; | ||
action: 'com.atproto.admin.moderationAction#takedown' | 'com.atproto.admin.moderationAction#flag' | 'com.atproto.admin.moderationAction#acknowledge' | (string & {}); | ||
action: ActionType; | ||
subject: ComAtprotoRepoRepoRef.Main | ComAtprotoRepoStrongRef.Main | { | ||
@@ -15,2 +16,3 @@ $type: string; | ||
}; | ||
subjectBlobCids: string[]; | ||
reason: string; | ||
@@ -27,3 +29,3 @@ createdBy: string; | ||
id: number; | ||
action: 'com.atproto.admin.moderationAction#takedown' | 'com.atproto.admin.moderationAction#flag' | 'com.atproto.admin.moderationAction#acknowledge' | (string & {}); | ||
action: ActionType; | ||
subject: ComAtprotoAdminRepo.View | ComAtprotoAdminRecord.View | { | ||
@@ -33,2 +35,3 @@ $type: string; | ||
}; | ||
subjectBlobs: ComAtprotoAdminBlob.View[]; | ||
reason: string; | ||
@@ -43,2 +46,9 @@ createdBy: string; | ||
export declare function validateViewDetail(v: unknown): ValidationResult; | ||
export interface ViewCurrent { | ||
id: number; | ||
action: ActionType; | ||
[k: string]: unknown; | ||
} | ||
export declare function isViewCurrent(v: unknown): v is ViewCurrent; | ||
export declare function validateViewCurrent(v: unknown): ValidationResult; | ||
export interface Reversal { | ||
@@ -52,4 +62,5 @@ reason: string; | ||
export declare function validateReversal(v: unknown): ValidationResult; | ||
export declare type ActionType = 'com.atproto.admin.moderationAction#takedown' | 'com.atproto.admin.moderationAction#flag' | 'com.atproto.admin.moderationAction#acknowledge' | (string & {}); | ||
export declare const TAKEDOWN = "com.atproto.admin.moderationAction#takedown"; | ||
export declare const FLAG = "com.atproto.admin.moderationAction#flag"; | ||
export declare const ACKNOWLEDGE = "com.atproto.admin.moderationAction#acknowledge"; |
import { ValidationResult } from '@atproto/lexicon'; | ||
import * as ComAtprotoAdminRepo from './repo'; | ||
import * as ComAtprotoAdminBlob from './blob'; | ||
import * as ComAtprotoAdminModerationAction from './moderationAction'; | ||
@@ -9,2 +10,3 @@ import * as ComAtprotoAdminModerationReport from './moderationReport'; | ||
value: {}; | ||
blobCids: string[]; | ||
indexedAt: string; | ||
@@ -21,2 +23,3 @@ moderation: Moderation; | ||
value: {}; | ||
blobs: ComAtprotoAdminBlob.View[]; | ||
indexedAt: string; | ||
@@ -30,3 +33,3 @@ moderation: ModerationDetail; | ||
export interface Moderation { | ||
takedownId?: number; | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent; | ||
[k: string]: unknown; | ||
@@ -37,5 +40,5 @@ } | ||
export interface ModerationDetail { | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent; | ||
actions: ComAtprotoAdminModerationAction.View[]; | ||
reports: ComAtprotoAdminModerationReport.View[]; | ||
takedownId?: number; | ||
[k: string]: unknown; | ||
@@ -42,0 +45,0 @@ } |
@@ -33,3 +33,3 @@ import { ValidationResult } from '@atproto/lexicon'; | ||
export interface Moderation { | ||
takedownId?: number; | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent; | ||
[k: string]: unknown; | ||
@@ -40,5 +40,5 @@ } | ||
export interface ModerationDetail { | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent; | ||
actions: ComAtprotoAdminModerationAction.View[]; | ||
reports: ComAtprotoAdminModerationReport.View[]; | ||
takedownId?: number; | ||
[k: string]: unknown; | ||
@@ -45,0 +45,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Headers } from '@atproto/xrpc'; | ||
import { Headers, XRPCError } from '@atproto/xrpc'; | ||
import * as ComAtprotoRepoRepoRef from '../repo/repoRef'; | ||
@@ -13,2 +13,3 @@ import * as ComAtprotoRepoRecordRef from '../repo/recordRef'; | ||
}; | ||
subjectBlobCids?: string[]; | ||
reason: string; | ||
@@ -29,2 +30,5 @@ createdBy: string; | ||
} | ||
export declare class SubjectHasActionError extends XRPCError { | ||
constructor(src: XRPCError); | ||
} | ||
export declare function toKnownErr(e: any): any; |
@@ -0,4 +1,4 @@ | ||
export * from './types'; | ||
export * from './client'; | ||
export { default } from './client'; | ||
export * from './session'; | ||
export { default as sessionClient } from './session'; | ||
export * from './agent'; | ||
export { AtpAgent as default } from './agent'; |
{ | ||
"name": "@atproto/api", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -6,8 +6,46 @@ # ATP API | ||
```typescript | ||
import API from '@atproto/api' | ||
import AtpAgent from '@atproto/api' | ||
const client = API.service('http://example.com') | ||
const agent = new AtpAgent({service: 'https://example.com'}) | ||
// provide a custom fetch implementation (shouldnt be needed in node or the browser) | ||
import {AtpAgentFetchHeaders, AtpAgentFetchHandlerResponse} from '@atproto/api' | ||
AtpAgent.configure({ | ||
async fetch( | ||
httpUri: string, | ||
httpMethod: string, | ||
httpHeaders: AtpAgentFetchHeaders, | ||
httpReqBody: any, | ||
): Promise<AtpAgentFetchHandlerResponse> { | ||
// insert definition here... | ||
return {status: 200, /*...*/} | ||
} | ||
}) | ||
``` | ||
### Session management | ||
```typescript | ||
import AtpAgent, {AtpSessionEvent, AtpSessionData} from '@atproto/api' | ||
const agent = new AtpAgent({ | ||
service: 'https://example.com', | ||
persistSession: (evt: AtpSessionEvent, sess?: AtpSessionData) { | ||
// store the session-data for reuse | ||
} | ||
}) | ||
await agent.login({identifier: 'alice@mail.com', password: 'hunter2'}) | ||
await agent.resumeSession(savedSessionData) | ||
await agent.createAccount({ | ||
email: 'alice@mail.com', | ||
password: 'hunter2', | ||
handle: 'alice.example.com' | ||
}) | ||
``` | ||
### API calls | ||
```typescript | ||
// xrpc methods | ||
const res1 = await client.com.atproto.repo.createRecord( | ||
const res1 = await agent.api.com.atproto.repo.createRecord( | ||
{ | ||
@@ -23,10 +61,10 @@ did: alice.did, | ||
) | ||
const res2 = await client.com.atproto.repo.listRecords({did: alice.did, type: 'app.bsky.feed.post'}) | ||
const res2 = await agent.api.com.atproto.repo.listRecords({did: alice.did, type: 'app.bsky.feed.post'}) | ||
// repo record methods | ||
const res3 = await client.app.bsky.feed.post.create({did: alice.did}, { | ||
const res3 = await agent.api.app.bsky.feed.post.create({did: alice.did}, { | ||
text: 'Hello, world!', | ||
createdAt: (new Date()).toISOString() | ||
}) | ||
const res4 = await client.app.bsky.feed.post.list({did: alice.did}) | ||
const res4 = await agent.api.app.bsky.feed.post.list({did: alice.did}) | ||
``` | ||
@@ -33,0 +71,0 @@ |
@@ -16,2 +16,3 @@ /** | ||
import * as ComAtprotoAccountResetPassword from './types/com/atproto/account/resetPassword' | ||
import * as ComAtprotoAdminBlob from './types/com/atproto/admin/blob' | ||
import * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction' | ||
@@ -99,2 +100,3 @@ import * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions' | ||
export * as ComAtprotoAccountResetPassword from './types/com/atproto/account/resetPassword' | ||
export * as ComAtprotoAdminBlob from './types/com/atproto/admin/blob' | ||
export * as ComAtprotoAdminGetModerationAction from './types/com/atproto/admin/getModerationAction' | ||
@@ -192,3 +194,3 @@ export * as ComAtprotoAdminGetModerationActions from './types/com/atproto/admin/getModerationActions' | ||
export class Client { | ||
export class AtpBaseClient { | ||
xrpc: XrpcClient = new XrpcClient() | ||
@@ -200,12 +202,9 @@ | ||
service(serviceUri: string | URL): ServiceClient { | ||
return new ServiceClient(this, this.xrpc.service(serviceUri)) | ||
service(serviceUri: string | URL): AtpServiceClient { | ||
return new AtpServiceClient(this, this.xrpc.service(serviceUri)) | ||
} | ||
} | ||
const defaultInst = new Client() | ||
export default defaultInst | ||
export class ServiceClient { | ||
_baseClient: Client | ||
export class AtpServiceClient { | ||
_baseClient: AtpBaseClient | ||
xrpc: XrpcServiceClient | ||
@@ -215,3 +214,3 @@ com: ComNS | ||
constructor(baseClient: Client, xrpcService: XrpcServiceClient) { | ||
constructor(baseClient: AtpBaseClient, xrpcService: XrpcServiceClient) { | ||
this._baseClient = baseClient | ||
@@ -229,6 +228,6 @@ this.xrpc = xrpcService | ||
export class ComNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
atproto: AtprotoNS | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -240,3 +239,3 @@ this.atproto = new AtprotoNS(service) | ||
export class AtprotoNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
account: AccountNS | ||
@@ -252,3 +251,3 @@ admin: AdminNS | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -268,5 +267,5 @@ this.account = new AccountNS(service) | ||
export class AccountNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -354,5 +353,5 @@ } | ||
export class AdminNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -473,5 +472,5 @@ } | ||
export class BlobNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -493,5 +492,5 @@ } | ||
export class HandleNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -513,5 +512,5 @@ } | ||
export class RepoNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -599,5 +598,5 @@ } | ||
export class ReportNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -619,5 +618,5 @@ } | ||
export class ServerNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -639,5 +638,5 @@ } | ||
export class SessionNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -692,5 +691,5 @@ } | ||
export class SyncNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -756,6 +755,6 @@ } | ||
export class AppNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
bsky: BskyNS | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -767,3 +766,3 @@ this.bsky = new BskyNS(service) | ||
export class BskyNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
actor: ActorNS | ||
@@ -776,3 +775,3 @@ embed: EmbedNS | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -789,6 +788,6 @@ this.actor = new ActorNS(service) | ||
export class ActorNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
profile: ProfileRecord | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -855,5 +854,5 @@ this.profile = new ProfileRecord(service) | ||
export class ProfileRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -917,5 +916,5 @@ } | ||
export class EmbedNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -926,3 +925,3 @@ } | ||
export class FeedNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
post: PostRecord | ||
@@ -932,3 +931,3 @@ repost: RepostRecord | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1008,5 +1007,5 @@ this.post = new PostRecord(service) | ||
export class PostRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1070,5 +1069,5 @@ } | ||
export class RepostRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1132,5 +1131,5 @@ } | ||
export class VoteRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1194,3 +1193,3 @@ } | ||
export class GraphNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
assertion: AssertionRecord | ||
@@ -1200,3 +1199,3 @@ confirmation: ConfirmationRecord | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1265,5 +1264,5 @@ this.assertion = new AssertionRecord(service) | ||
export class AssertionRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1331,5 +1330,5 @@ } | ||
export class ConfirmationRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1397,5 +1396,5 @@ } | ||
export class FollowRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1459,5 +1458,5 @@ } | ||
export class NotificationNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1501,6 +1500,6 @@ } | ||
export class SystemNS { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
declaration: DeclarationRecord | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1512,5 +1511,5 @@ this.declaration = new DeclarationRecord(service) | ||
export class DeclarationRecord { | ||
_service: ServiceClient | ||
_service: AtpServiceClient | ||
constructor(service: ServiceClient) { | ||
constructor(service: AtpServiceClient) { | ||
this._service = service | ||
@@ -1517,0 +1516,0 @@ } |
@@ -47,3 +47,2 @@ /** | ||
indexedAt?: string | ||
myState?: MyState | ||
[k: string]: unknown | ||
@@ -63,18 +62,1 @@ } | ||
} | ||
export interface MyState { | ||
follow?: string | ||
[k: string]: unknown | ||
} | ||
export function isMyState(v: unknown): v is MyState { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
v.$type === 'app.bsky.actor.getSuggestions#myState' | ||
) | ||
} | ||
export function validateMyState(v: unknown): ValidationResult { | ||
return lexicons.validate('app.bsky.actor.getSuggestions#myState', v) | ||
} |
@@ -11,2 +11,3 @@ /** | ||
import * as ComAtprotoAdminRecord from './record' | ||
import * as ComAtprotoAdminBlob from './blob' | ||
import * as ComAtprotoAdminModerationReport from './moderationReport' | ||
@@ -16,7 +17,3 @@ | ||
id: number | ||
action: | ||
| 'com.atproto.admin.moderationAction#takedown' | ||
| 'com.atproto.admin.moderationAction#flag' | ||
| 'com.atproto.admin.moderationAction#acknowledge' | ||
| (string & {}) | ||
action: ActionType | ||
subject: | ||
@@ -26,2 +23,3 @@ | ComAtprotoRepoRepoRef.Main | ||
| { $type: string; [k: string]: unknown } | ||
subjectBlobCids: string[] | ||
reason: string | ||
@@ -49,7 +47,3 @@ createdBy: string | ||
id: number | ||
action: | ||
| 'com.atproto.admin.moderationAction#takedown' | ||
| 'com.atproto.admin.moderationAction#flag' | ||
| 'com.atproto.admin.moderationAction#acknowledge' | ||
| (string & {}) | ||
action: ActionType | ||
subject: | ||
@@ -59,2 +53,3 @@ | ComAtprotoAdminRepo.View | ||
| { $type: string; [k: string]: unknown } | ||
subjectBlobs: ComAtprotoAdminBlob.View[] | ||
reason: string | ||
@@ -80,2 +75,20 @@ createdBy: string | ||
export interface ViewCurrent { | ||
id: number | ||
action: ActionType | ||
[k: string]: unknown | ||
} | ||
export function isViewCurrent(v: unknown): v is ViewCurrent { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
v.$type === 'com.atproto.admin.moderationAction#viewCurrent' | ||
) | ||
} | ||
export function validateViewCurrent(v: unknown): ValidationResult { | ||
return lexicons.validate('com.atproto.admin.moderationAction#viewCurrent', v) | ||
} | ||
export interface Reversal { | ||
@@ -100,2 +113,8 @@ reason: string | ||
export type ActionType = | ||
| 'com.atproto.admin.moderationAction#takedown' | ||
| 'com.atproto.admin.moderationAction#flag' | ||
| 'com.atproto.admin.moderationAction#acknowledge' | ||
| (string & {}) | ||
/** Moderation action type: Takedown. Indicates that content should not be served by the PDS. */ | ||
@@ -102,0 +121,0 @@ export const TAKEDOWN = 'com.atproto.admin.moderationAction#takedown' |
@@ -8,2 +8,3 @@ /** | ||
import * as ComAtprotoAdminRepo from './repo' | ||
import * as ComAtprotoAdminBlob from './blob' | ||
import * as ComAtprotoAdminModerationAction from './moderationAction' | ||
@@ -16,2 +17,3 @@ import * as ComAtprotoAdminModerationReport from './moderationReport' | ||
value: {} | ||
blobCids: string[] | ||
indexedAt: string | ||
@@ -39,2 +41,3 @@ moderation: Moderation | ||
value: {} | ||
blobs: ComAtprotoAdminBlob.View[] | ||
indexedAt: string | ||
@@ -59,3 +62,3 @@ moderation: ModerationDetail | ||
export interface Moderation { | ||
takedownId?: number | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent | ||
[k: string]: unknown | ||
@@ -77,5 +80,5 @@ } | ||
export interface ModerationDetail { | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent | ||
actions: ComAtprotoAdminModerationAction.View[] | ||
reports: ComAtprotoAdminModerationReport.View[] | ||
takedownId?: number | ||
[k: string]: unknown | ||
@@ -82,0 +85,0 @@ } |
@@ -70,3 +70,3 @@ /** | ||
export interface Moderation { | ||
takedownId?: number | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent | ||
[k: string]: unknown | ||
@@ -88,5 +88,5 @@ } | ||
export interface ModerationDetail { | ||
currentAction?: ComAtprotoAdminModerationAction.ViewCurrent | ||
actions: ComAtprotoAdminModerationAction.View[] | ||
reports: ComAtprotoAdminModerationReport.View[] | ||
takedownId?: number | ||
[k: string]: unknown | ||
@@ -93,0 +93,0 @@ } |
@@ -24,2 +24,3 @@ /** | ||
| { $type: string; [k: string]: unknown } | ||
subjectBlobCids?: string[] | ||
reason: string | ||
@@ -44,6 +45,13 @@ createdBy: string | ||
export class SubjectHasActionError extends XRPCError { | ||
constructor(src: XRPCError) { | ||
super(src.status, src.error, src.message) | ||
} | ||
} | ||
export function toKnownErr(e: any) { | ||
if (e instanceof XRPCError) { | ||
if (e.error === 'SubjectHasAction') return new SubjectHasActionError(e) | ||
} | ||
return e | ||
} |
@@ -0,4 +1,4 @@ | ||
export * from './types' | ||
export * from './client' | ||
export { default } from './client' | ||
export * from './session' | ||
export { default as sessionClient } from './session' | ||
export * from './agent' | ||
export { AtpAgent as default } from './agent' |
@@ -6,11 +6,7 @@ import { | ||
} from '@atproto/pds/tests/_util' | ||
import { | ||
sessionClient, | ||
SessionServiceClient, | ||
ComAtprotoAccountCreate, | ||
} from '..' | ||
import { AtpAgent, ComAtprotoAccountCreate } from '..' | ||
describe('errors', () => { | ||
let server: TestServerInfo | ||
let client: SessionServiceClient | ||
let client: AtpAgent | ||
let close: CloseFn | ||
@@ -22,3 +18,3 @@ | ||
}) | ||
client = sessionClient.service(server.url) | ||
client = new AtpAgent({ service: server.url }) | ||
close = server.close | ||
@@ -32,3 +28,3 @@ }) | ||
it('constructs the correct error instance', async () => { | ||
const res = client.com.atproto.account.create({ | ||
const res = client.api.com.atproto.account.create({ | ||
handle: 'admin', | ||
@@ -35,0 +31,0 @@ email: 'admin@test.com', |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1444364
199
26733
73