Skip to content

Commit

Permalink
Repo write commit metadata (#2745)
Browse files Browse the repository at this point in the history
* schemas & codegen

* impl

* bundle commit & rev
  • Loading branch information
dholms committed Aug 30, 2024
1 parent befebc0 commit bfbac24
Show file tree
Hide file tree
Showing 34 changed files with 411 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lexicons/com/atproto/repo/applyWrites.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"type": "object",
"required": [],
"properties": {
"commit": {
"type": "ref",
"ref": "com.atproto.repo.defs#commitMeta"
},
"results": {
"type": "array",
"items": {
Expand Down
4 changes: 4 additions & 0 deletions lexicons/com/atproto/repo/createRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
"properties": {
"uri": { "type": "string", "format": "at-uri" },
"cid": { "type": "string", "format": "cid" },
"commit": {
"type": "ref",
"ref": "com.atproto.repo.defs#commitMeta"
},
"validationStatus": {
"type": "string",
"knownValues": ["valid", "unknown"]
Expand Down
14 changes: 14 additions & 0 deletions lexicons/com/atproto/repo/defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"lexicon": 1,
"id": "com.atproto.repo.defs",
"defs": {
"commitMeta": {
"type": "object",
"required": ["cid", "rev"],
"properties": {
"cid": { "type": "string", "format": "cid" },
"rev": { "type": "string" }
}
}
}
}
12 changes: 12 additions & 0 deletions lexicons/com/atproto/repo/deleteRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {
"commit": {
"type": "ref",
"ref": "com.atproto.repo.defs#commitMeta"
}
}
}
},
"errors": [{ "name": "InvalidSwap" }]
}
}
Expand Down
4 changes: 4 additions & 0 deletions lexicons/com/atproto/repo/putRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
"properties": {
"uri": { "type": "string", "format": "at-uri" },
"cid": { "type": "string", "format": "cid" },
"commit": {
"type": "ref",
"ref": "com.atproto.repo.defs#commitMeta"
},
"validationStatus": {
"type": "string",
"knownValues": ["valid", "unknown"]
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as ComAtprotoModerationCreateReport from './types/com/atproto/moderatio
import * as ComAtprotoModerationDefs from './types/com/atproto/moderation/defs'
import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord'
import * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs'
import * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord'
import * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo'
import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord'
Expand Down Expand Up @@ -237,6 +238,7 @@ export * as ComAtprotoModerationCreateReport from './types/com/atproto/moderatio
export * as ComAtprotoModerationDefs from './types/com/atproto/moderation/defs'
export * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites'
export * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord'
export * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs'
export * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord'
export * as ComAtprotoRepoDescribeRepo from './types/com/atproto/repo/describeRepo'
export * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord'
Expand Down
44 changes: 44 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,10 @@ export const schemaDict = {
type: 'object',
required: [],
properties: {
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
results: {
type: 'array',
items: {
Expand Down Expand Up @@ -1461,6 +1465,10 @@ export const schemaDict = {
type: 'string',
format: 'cid',
},
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
validationStatus: {
type: 'string',
knownValues: ['valid', 'unknown'],
Expand All @@ -1478,6 +1486,25 @@ export const schemaDict = {
},
},
},
ComAtprotoRepoDefs: {
lexicon: 1,
id: 'com.atproto.repo.defs',
defs: {
commitMeta: {
type: 'object',
required: ['cid', 'rev'],
properties: {
cid: {
type: 'string',
format: 'cid',
},
rev: {
type: 'string',
},
},
},
},
},
ComAtprotoRepoDeleteRecord: {
lexicon: 1,
id: 'com.atproto.repo.deleteRecord',
Expand Down Expand Up @@ -1522,6 +1549,18 @@ export const schemaDict = {
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
},
},
},
errors: [
{
name: 'InvalidSwap',
Expand Down Expand Up @@ -1878,6 +1917,10 @@ export const schemaDict = {
type: 'string',
format: 'cid',
},
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
validationStatus: {
type: 'string',
knownValues: ['valid', 'unknown'],
Expand Down Expand Up @@ -12151,6 +12194,7 @@ export const ids = {
ComAtprotoModerationDefs: 'com.atproto.moderation.defs',
ComAtprotoRepoApplyWrites: 'com.atproto.repo.applyWrites',
ComAtprotoRepoCreateRecord: 'com.atproto.repo.createRecord',
ComAtprotoRepoDefs: 'com.atproto.repo.defs',
ComAtprotoRepoDeleteRecord: 'com.atproto.repo.deleteRecord',
ComAtprotoRepoDescribeRepo: 'com.atproto.repo.describeRepo',
ComAtprotoRepoGetRecord: 'com.atproto.repo.getRecord',
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/com/atproto/repo/applyWrites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -21,6 +22,7 @@ export interface InputSchema {
}

export interface OutputSchema {
commit?: ComAtprotoRepoDefs.CommitMeta
results?: (CreateResult | UpdateResult | DeleteResult)[]
[k: string]: unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -28,6 +29,7 @@ export interface InputSchema {
export interface OutputSchema {
uri: string
cid: string
commit?: ComAtprotoRepoDefs.CommitMeta
validationStatus?: 'valid' | 'unknown' | (string & {})
[k: string]: unknown
}
Expand Down
25 changes: 25 additions & 0 deletions packages/api/src/client/types/com/atproto/repo/defs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'

export interface CommitMeta {
cid: string
rev: string
[k: string]: unknown
}

export function isCommitMeta(v: unknown): v is CommitMeta {
return (
isObj(v) &&
hasProp(v, '$type') &&
v.$type === 'com.atproto.repo.defs#commitMeta'
)
}

export function validateCommitMeta(v: unknown): ValidationResult {
return lexicons.validate('com.atproto.repo.defs#commitMeta', v)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -23,6 +24,11 @@ export interface InputSchema {
[k: string]: unknown
}

export interface OutputSchema {
commit?: ComAtprotoRepoDefs.CommitMeta
[k: string]: unknown
}

export interface CallOptions {
signal?: AbortSignal
headers?: HeadersMap
Expand All @@ -33,6 +39,7 @@ export interface CallOptions {
export interface Response {
success: boolean
headers: HeadersMap
data: OutputSchema
}

export class InvalidSwapError extends XRPCError {
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/com/atproto/repo/putRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -30,6 +31,7 @@ export interface InputSchema {
export interface OutputSchema {
uri: string
cid: string
commit?: ComAtprotoRepoDefs.CommitMeta
validationStatus?: 'valid' | 'unknown' | (string & {})
[k: string]: unknown
}
Expand Down
44 changes: 44 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,10 @@ export const schemaDict = {
type: 'object',
required: [],
properties: {
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
results: {
type: 'array',
items: {
Expand Down Expand Up @@ -1461,6 +1465,10 @@ export const schemaDict = {
type: 'string',
format: 'cid',
},
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
validationStatus: {
type: 'string',
knownValues: ['valid', 'unknown'],
Expand All @@ -1478,6 +1486,25 @@ export const schemaDict = {
},
},
},
ComAtprotoRepoDefs: {
lexicon: 1,
id: 'com.atproto.repo.defs',
defs: {
commitMeta: {
type: 'object',
required: ['cid', 'rev'],
properties: {
cid: {
type: 'string',
format: 'cid',
},
rev: {
type: 'string',
},
},
},
},
},
ComAtprotoRepoDeleteRecord: {
lexicon: 1,
id: 'com.atproto.repo.deleteRecord',
Expand Down Expand Up @@ -1522,6 +1549,18 @@ export const schemaDict = {
},
},
},
output: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
},
},
},
errors: [
{
name: 'InvalidSwap',
Expand Down Expand Up @@ -1878,6 +1917,10 @@ export const schemaDict = {
type: 'string',
format: 'cid',
},
commit: {
type: 'ref',
ref: 'lex:com.atproto.repo.defs#commitMeta',
},
validationStatus: {
type: 'string',
knownValues: ['valid', 'unknown'],
Expand Down Expand Up @@ -10433,6 +10476,7 @@ export const ids = {
ComAtprotoModerationDefs: 'com.atproto.moderation.defs',
ComAtprotoRepoApplyWrites: 'com.atproto.repo.applyWrites',
ComAtprotoRepoCreateRecord: 'com.atproto.repo.createRecord',
ComAtprotoRepoDefs: 'com.atproto.repo.defs',
ComAtprotoRepoDeleteRecord: 'com.atproto.repo.deleteRecord',
ComAtprotoRepoDescribeRepo: 'com.atproto.repo.describeRepo',
ComAtprotoRepoGetRecord: 'com.atproto.repo.getRecord',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -22,6 +23,7 @@ export interface InputSchema {
}

export interface OutputSchema {
commit?: ComAtprotoRepoDefs.CommitMeta
results?: (CreateResult | UpdateResult | DeleteResult)[]
[k: string]: unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { lexicons } from '../../../../lexicons'
import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server'
import * as ComAtprotoRepoDefs from './defs'

export interface QueryParams {}

Expand All @@ -29,6 +30,7 @@ export interface InputSchema {
export interface OutputSchema {
uri: string
cid: string
commit?: ComAtprotoRepoDefs.CommitMeta
validationStatus?: 'valid' | 'unknown' | (string & {})
[k: string]: unknown
}
Expand Down
Loading

0 comments on commit bfbac24

Please sign in to comment.