Skip to content

Commit

Permalink
Merge pull request #444 from bluesky-social/repo-checkout
Browse files Browse the repository at this point in the history
Repo checkouts
  • Loading branch information
dholms authored Jan 5, 2023
2 parents f9fd8a2 + f647640 commit 423b6ab
Show file tree
Hide file tree
Showing 99 changed files with 2,136 additions and 1,812 deletions.
21 changes: 21 additions & 0 deletions lexicons/com/atproto/sync/getCheckout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getCheckout",
"defs": {
"main": {
"type": "query",
"description": "Gets the repo state.",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {"type": "string", "description": "The DID of the repo."},
"commit": {"type": "string", "description": "The commit to get the checkout from. Defaults to current HEAD."}
}
},
"output": {
"encoding": "application/cbor"
}
}
}
}
32 changes: 32 additions & 0 deletions lexicons/com/atproto/sync/getCommitPath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getCommitPath",
"defs": {
"main": {
"type": "query",
"description": "Gets the path of repo commits",
"parameters": {
"type": "params",
"required": ["did"],
"properties": {
"did": {"type": "string", "description": "The DID of the repo."},
"latest": { "type": "string", "description": "The most recent commit"},
"earliest": { "type": "string", "description": "The earliest commit to start from"}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["commits"],
"properties": {
"commits": {
"type": "array",
"items": { "type": "string" }
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"lexicon": 1,
"id": "com.atproto.sync.getRoot",
"id": "com.atproto.sync.getHead",
"defs": {
"main": {
"type": "query",
"description": "Gets the current root CID of a repo.",
"description": "Gets the current HEAD CID of a repo.",
"parameters": {
"type": "params",
"required": ["did"],
Expand Down
1 change: 0 additions & 1 deletion packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
## Libraries

- [API](./api): A library for communicating with ATP servers.
- [Auth](./auth): ATP's core permissioning library (based on UCANs).
- [Common](./common): A library containing code which is shared between ATP packages.
- [Crypto](./crypto): ATP's common cryptographic operations.
- [DID Resolver](./did-resolver): A library for resolving ATP's Decentralized ID methods.
Expand Down
52 changes: 39 additions & 13 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import * as ComAtprotoSessionCreate from './types/com/atproto/session/create'
import * as ComAtprotoSessionDelete from './types/com/atproto/session/delete'
import * as ComAtprotoSessionGet from './types/com/atproto/session/get'
import * as ComAtprotoSessionRefresh from './types/com/atproto/session/refresh'
import * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
import * as ComAtprotoSyncGetCommitPath from './types/com/atproto/sync/getCommitPath'
import * as ComAtprotoSyncGetHead from './types/com/atproto/sync/getHead'
import * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo'
import * as ComAtprotoSyncGetRoot from './types/com/atproto/sync/getRoot'
import * as ComAtprotoSyncUpdateRepo from './types/com/atproto/sync/updateRepo'
import * as AppBskyActorCreateScene from './types/app/bsky/actor/createScene'
import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -90,8 +92,10 @@ export * as ComAtprotoSessionCreate from './types/com/atproto/session/create'
export * as ComAtprotoSessionDelete from './types/com/atproto/session/delete'
export * as ComAtprotoSessionGet from './types/com/atproto/session/get'
export * as ComAtprotoSessionRefresh from './types/com/atproto/session/refresh'
export * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
export * as ComAtprotoSyncGetCommitPath from './types/com/atproto/sync/getCommitPath'
export * as ComAtprotoSyncGetHead from './types/com/atproto/sync/getHead'
export * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo'
export * as ComAtprotoSyncGetRoot from './types/com/atproto/sync/getRoot'
export * as ComAtprotoSyncUpdateRepo from './types/com/atproto/sync/updateRepo'
export * as AppBskyActorCreateScene from './types/app/bsky/actor/createScene'
export * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -481,6 +485,39 @@ export class SyncNS {
this._service = service
}

getCheckout(
params?: ComAtprotoSyncGetCheckout.QueryParams,
opts?: ComAtprotoSyncGetCheckout.CallOptions,
): Promise<ComAtprotoSyncGetCheckout.Response> {
return this._service.xrpc
.call('com.atproto.sync.getCheckout', params, undefined, opts)
.catch((e) => {
throw ComAtprotoSyncGetCheckout.toKnownErr(e)
})
}

getCommitPath(
params?: ComAtprotoSyncGetCommitPath.QueryParams,
opts?: ComAtprotoSyncGetCommitPath.CallOptions,
): Promise<ComAtprotoSyncGetCommitPath.Response> {
return this._service.xrpc
.call('com.atproto.sync.getCommitPath', params, undefined, opts)
.catch((e) => {
throw ComAtprotoSyncGetCommitPath.toKnownErr(e)
})
}

getHead(
params?: ComAtprotoSyncGetHead.QueryParams,
opts?: ComAtprotoSyncGetHead.CallOptions,
): Promise<ComAtprotoSyncGetHead.Response> {
return this._service.xrpc
.call('com.atproto.sync.getHead', params, undefined, opts)
.catch((e) => {
throw ComAtprotoSyncGetHead.toKnownErr(e)
})
}

getRepo(
params?: ComAtprotoSyncGetRepo.QueryParams,
opts?: ComAtprotoSyncGetRepo.CallOptions,
Expand All @@ -492,17 +529,6 @@ export class SyncNS {
})
}

getRoot(
params?: ComAtprotoSyncGetRoot.QueryParams,
opts?: ComAtprotoSyncGetRoot.CallOptions,
): Promise<ComAtprotoSyncGetRoot.Response> {
return this._service.xrpc
.call('com.atproto.sync.getRoot', params, undefined, opts)
.catch((e) => {
throw ComAtprotoSyncGetRoot.toKnownErr(e)
})
}

updateRepo(
data?: ComAtprotoSyncUpdateRepo.InputSchema,
opts?: ComAtprotoSyncUpdateRepo.CallOptions,
Expand Down
89 changes: 81 additions & 8 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,9 @@ export const schemaDict = {
},
},
},
ComAtprotoSyncGetRepo: {
ComAtprotoSyncGetCheckout: {
lexicon: 1,
id: 'com.atproto.sync.getRepo',
id: 'com.atproto.sync.getCheckout',
defs: {
main: {
type: 'query',
Expand All @@ -843,9 +843,10 @@ export const schemaDict = {
type: 'string',
description: 'The DID of the repo.',
},
from: {
commit: {
type: 'string',
description: 'A past commit CID.',
description:
'The commit to get the checkout from. Defaults to current HEAD.',
},
},
},
Expand All @@ -855,13 +856,56 @@ export const schemaDict = {
},
},
},
ComAtprotoSyncGetRoot: {
ComAtprotoSyncGetCommitPath: {
lexicon: 1,
id: 'com.atproto.sync.getCommitPath',
defs: {
main: {
type: 'query',
description: 'Gets the path of repo commits',
parameters: {
type: 'params',
required: ['did'],
properties: {
did: {
type: 'string',
description: 'The DID of the repo.',
},
latest: {
type: 'string',
description: 'The most recent commit',
},
earliest: {
type: 'string',
description: 'The earliest commit to start from',
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['commits'],
properties: {
commits: {
type: 'array',
items: {
type: 'string',
},
},
},
},
},
},
},
},
ComAtprotoSyncGetHead: {
lexicon: 1,
id: 'com.atproto.sync.getRoot',
id: 'com.atproto.sync.getHead',
defs: {
main: {
type: 'query',
description: 'Gets the current root CID of a repo.',
description: 'Gets the current HEAD CID of a repo.',
parameters: {
type: 'params',
required: ['did'],
Expand All @@ -887,6 +931,33 @@ export const schemaDict = {
},
},
},
ComAtprotoSyncGetRepo: {
lexicon: 1,
id: 'com.atproto.sync.getRepo',
defs: {
main: {
type: 'query',
description: 'Gets the repo state.',
parameters: {
type: 'params',
required: ['did'],
properties: {
did: {
type: 'string',
description: 'The DID of the repo.',
},
from: {
type: 'string',
description: 'A past commit CID.',
},
},
},
output: {
encoding: 'application/cbor',
},
},
},
},
ComAtprotoSyncUpdateRepo: {
lexicon: 1,
id: 'com.atproto.sync.updateRepo',
Expand Down Expand Up @@ -2998,8 +3069,10 @@ export const ids = {
ComAtprotoSessionDelete: 'com.atproto.session.delete',
ComAtprotoSessionGet: 'com.atproto.session.get',
ComAtprotoSessionRefresh: 'com.atproto.session.refresh',
ComAtprotoSyncGetCheckout: 'com.atproto.sync.getCheckout',
ComAtprotoSyncGetCommitPath: 'com.atproto.sync.getCommitPath',
ComAtprotoSyncGetHead: 'com.atproto.sync.getHead',
ComAtprotoSyncGetRepo: 'com.atproto.sync.getRepo',
ComAtprotoSyncGetRoot: 'com.atproto.sync.getRoot',
ComAtprotoSyncUpdateRepo: 'com.atproto.sync.updateRepo',
AppBskyActorCreateScene: 'app.bsky.actor.createScene',
AppBskyActorGetProfile: 'app.bsky.actor.getProfile',
Expand Down
29 changes: 29 additions & 0 deletions packages/api/src/client/types/com/atproto/sync/getCheckout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'

export interface QueryParams {
/** The DID of the repo. */
did: string
/** The commit to get the checkout from. Defaults to current HEAD. */
commit?: string
}

export type InputSchema = undefined

export interface CallOptions {
headers?: Headers
}

export interface Response {
success: boolean
headers: Headers
data: Uint8Array
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}
36 changes: 36 additions & 0 deletions packages/api/src/client/types/com/atproto/sync/getCommitPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'

export interface QueryParams {
/** The DID of the repo. */
did: string
/** The most recent commit */
latest?: string
/** The earliest commit to start from */
earliest?: string
}

export type InputSchema = undefined

export interface OutputSchema {
commits: string[]
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
}

export interface Response {
success: boolean
headers: Headers
data: OutputSchema
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}
3 changes: 0 additions & 3 deletions packages/auth/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions packages/auth/build.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/auth/jest.config.js

This file was deleted.

Loading

0 comments on commit 423b6ab

Please sign in to comment.