From 06c79c09556e006dc770a01da0805f8bb4075981 Mon Sep 17 00:00:00 2001 From: dholms Date: Thu, 7 Mar 2024 19:26:15 -0600 Subject: [PATCH] add ver to labels --- lexicons/com/atproto/label/defs.json | 4 ++++ packages/api/src/client/lexicons.ts | 4 ++++ packages/api/src/client/types/com/atproto/label/defs.ts | 2 ++ packages/bsky/src/lexicon/lexicons.ts | 4 ++++ packages/bsky/src/lexicon/types/com/atproto/label/defs.ts | 2 ++ packages/ozone/src/lexicon/lexicons.ts | 4 ++++ packages/ozone/src/lexicon/types/com/atproto/label/defs.ts | 2 ++ packages/ozone/src/mod-service/util.ts | 4 +++- packages/ozone/tests/__snapshots__/get-record.test.ts.snap | 2 ++ packages/ozone/tests/__snapshots__/get-repo.test.ts.snap | 1 + packages/ozone/tests/sequencer.test.ts | 2 +- packages/pds/src/lexicon/lexicons.ts | 4 ++++ packages/pds/src/lexicon/types/com/atproto/label/defs.ts | 2 ++ 13 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lexicons/com/atproto/label/defs.json b/lexicons/com/atproto/label/defs.json index d2ae860aa3e..229ad192f2a 100644 --- a/lexicons/com/atproto/label/defs.json +++ b/lexicons/com/atproto/label/defs.json @@ -7,6 +7,10 @@ "description": "Metadata tag on an atproto resource (eg, repo or record).", "required": ["src", "uri", "val", "cts"], "properties": { + "ver": { + "type": "integer", + "description": "The AT Protocol version of the label object." + }, "src": { "type": "string", "format": "did", diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index a9d629dedfd..afc7ed866b1 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -2202,6 +2202,10 @@ export const schemaDict = { 'Metadata tag on an atproto resource (eg, repo or record).', required: ['src', 'uri', 'val', 'cts'], properties: { + ver: { + type: 'integer', + description: 'The AT Protocol version of the label object.', + }, src: { type: 'string', format: 'did', diff --git a/packages/api/src/client/types/com/atproto/label/defs.ts b/packages/api/src/client/types/com/atproto/label/defs.ts index 62433110031..425978d6d0e 100644 --- a/packages/api/src/client/types/com/atproto/label/defs.ts +++ b/packages/api/src/client/types/com/atproto/label/defs.ts @@ -8,6 +8,8 @@ import { CID } from 'multiformats/cid' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { + /** The AT Protocol version of the label object. */ + ver?: number /** DID of the actor who created this label. */ src: string /** AT URI of the record, repository (account), or other resource that this label applies to. */ diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index a9d629dedfd..afc7ed866b1 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -2202,6 +2202,10 @@ export const schemaDict = { 'Metadata tag on an atproto resource (eg, repo or record).', required: ['src', 'uri', 'val', 'cts'], properties: { + ver: { + type: 'integer', + description: 'The AT Protocol version of the label object.', + }, src: { type: 'string', format: 'did', diff --git a/packages/bsky/src/lexicon/types/com/atproto/label/defs.ts b/packages/bsky/src/lexicon/types/com/atproto/label/defs.ts index 83e81c78f70..935b2aa4bb3 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/label/defs.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/label/defs.ts @@ -8,6 +8,8 @@ import { CID } from 'multiformats/cid' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { + /** The AT Protocol version of the label object. */ + ver?: number /** DID of the actor who created this label. */ src: string /** AT URI of the record, repository (account), or other resource that this label applies to. */ diff --git a/packages/ozone/src/lexicon/lexicons.ts b/packages/ozone/src/lexicon/lexicons.ts index a9d629dedfd..afc7ed866b1 100644 --- a/packages/ozone/src/lexicon/lexicons.ts +++ b/packages/ozone/src/lexicon/lexicons.ts @@ -2202,6 +2202,10 @@ export const schemaDict = { 'Metadata tag on an atproto resource (eg, repo or record).', required: ['src', 'uri', 'val', 'cts'], properties: { + ver: { + type: 'integer', + description: 'The AT Protocol version of the label object.', + }, src: { type: 'string', format: 'did', diff --git a/packages/ozone/src/lexicon/types/com/atproto/label/defs.ts b/packages/ozone/src/lexicon/types/com/atproto/label/defs.ts index 83e81c78f70..935b2aa4bb3 100644 --- a/packages/ozone/src/lexicon/types/com/atproto/label/defs.ts +++ b/packages/ozone/src/lexicon/types/com/atproto/label/defs.ts @@ -8,6 +8,8 @@ import { CID } from 'multiformats/cid' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { + /** The AT Protocol version of the label object. */ + ver?: number /** DID of the actor who created this label. */ src: string /** AT URI of the record, repository (account), or other resource that this label applies to. */ diff --git a/packages/ozone/src/mod-service/util.ts b/packages/ozone/src/mod-service/util.ts index f6db50e7234..5d25578dff1 100644 --- a/packages/ozone/src/mod-service/util.ts +++ b/packages/ozone/src/mod-service/util.ts @@ -7,6 +7,7 @@ export type SignedLabel = Label & { sig: Uint8Array } export const formatLabel = (row: LabelRow): Label => { return noUndefinedVals({ + ver: 1, src: row.src, uri: row.uri, cid: row.cid === '' ? undefined : row.cid, @@ -37,8 +38,9 @@ export const signLabel = async ( label: Label, signingKey: Keypair, ): Promise => { - const { src, uri, cid, val, neg, cts } = label + const { ver, src, uri, cid, val, neg, cts } = label const reformatted = noUndefinedVals({ + ver: ver ?? 1, src, uri, cid, diff --git a/packages/ozone/tests/__snapshots__/get-record.test.ts.snap b/packages/ozone/tests/__snapshots__/get-record.test.ts.snap index 5ed0b0e62f9..0de6e23df61 100644 --- a/packages/ozone/tests/__snapshots__/get-record.test.ts.snap +++ b/packages/ozone/tests/__snapshots__/get-record.test.ts.snap @@ -17,6 +17,7 @@ Object { "src": "user(2)", "uri": "record(0)", "val": "!unspecced-takedown", + "ver": 1, }, Object { "cid": "cids(0)", @@ -117,6 +118,7 @@ Object { "src": "user(2)", "uri": "record(0)", "val": "!unspecced-takedown", + "ver": 1, }, Object { "cid": "cids(0)", diff --git a/packages/ozone/tests/__snapshots__/get-repo.test.ts.snap b/packages/ozone/tests/__snapshots__/get-repo.test.ts.snap index 27e045023ee..e4528d2a67f 100644 --- a/packages/ozone/tests/__snapshots__/get-repo.test.ts.snap +++ b/packages/ozone/tests/__snapshots__/get-repo.test.ts.snap @@ -18,6 +18,7 @@ Object { "src": "user(2)", "uri": "user(0)", "val": "!unspecced-takedown", + "ver": 1, }, ], "moderation": Object { diff --git a/packages/ozone/tests/sequencer.test.ts b/packages/ozone/tests/sequencer.test.ts index 45ce60edc6f..f12092bd27e 100644 --- a/packages/ozone/tests/sequencer.test.ts +++ b/packages/ozone/tests/sequencer.test.ts @@ -33,7 +33,7 @@ describe('sequencer', () => { } const evtToDbRow = (e: LabelsEvt) => { - const label = e.labels[0] + const { ver: _, ...label } = e.labels[0] return { id: e.seq, ...label, diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index a9d629dedfd..afc7ed866b1 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -2202,6 +2202,10 @@ export const schemaDict = { 'Metadata tag on an atproto resource (eg, repo or record).', required: ['src', 'uri', 'val', 'cts'], properties: { + ver: { + type: 'integer', + description: 'The AT Protocol version of the label object.', + }, src: { type: 'string', format: 'did', diff --git a/packages/pds/src/lexicon/types/com/atproto/label/defs.ts b/packages/pds/src/lexicon/types/com/atproto/label/defs.ts index 83e81c78f70..935b2aa4bb3 100644 --- a/packages/pds/src/lexicon/types/com/atproto/label/defs.ts +++ b/packages/pds/src/lexicon/types/com/atproto/label/defs.ts @@ -8,6 +8,8 @@ import { CID } from 'multiformats/cid' /** Metadata tag on an atproto resource (eg, repo or record). */ export interface Label { + /** The AT Protocol version of the label object. */ + ver?: number /** DID of the actor who created this label. */ src: string /** AT URI of the record, repository (account), or other resource that this label applies to. */