Skip to content

Commit

Permalink
Merge pull request #52 from lens-protocol/release/1.1.2
Browse files Browse the repository at this point in the history
Release/1.1.2
  • Loading branch information
cesarenaldi authored Dec 8, 2023
2 parents ab3181b + 5d40381 commit 39862c5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @lens-protocol/metadata

## 1.1.2

### Patch Changes

- e508560: **fixed** legacy PublicationMetadata schema not supporting SHORT_VIDEO main content focus

## 1.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lens-protocol/metadata",
"version": "1.1.1",
"version": "1.1.2",
"description": "Lens Protocol Metadata Standards",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
25 changes: 25 additions & 0 deletions src/legacy/__tests__/PublicationMetadataSchema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,32 @@ describe(`Given the PublicationMetadataSchema`, () => {
).toMatchObject({
mainContentFocus: PublicationMainFocus.SHORT_VIDEO,
});
});

it(`then should produce metadata that pass validation against the schema`, () => {
const metadata = PublicationMetadataSchema.parse({
version: '2.0.0',
metadata_id: 'd4c19b76-736e-4d41-8d3c-4874b80fdd78',
locale: 'en-GB',
mainContentFocus: 'VIDEO',
name: 'GM 🧘🏼‍♂️🚲🍂',
attributes: [],
media: [
{
item: 'ipfs://bafybeihuephqb3rts3xiz5m3ooutgmz5yand5ayqi4sczkpsflfy33qwvm',
type: 'video/quicktime',
cover: 'ipfs://bafybeiessuuhjv6szov6rwejjpjr6pil7pqpbi4hgnkedh6mzv6iyteqka',
},
],
appId: 'lenstube-bytes',
});

expectResult(() => PublicationMetadataSchema.safeParse(metadata)).toMatchObject({
mainContentFocus: PublicationMainFocus.SHORT_VIDEO,
});
});

it(`then should not cause any issue to other apps`, () => {
expectResult(() =>
PublicationMetadataSchema.safeParse({
version: '2.0.0',
Expand Down
19 changes: 16 additions & 3 deletions src/legacy/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,11 @@ const PublicationMetadataV2TextOnlySchema = PublicationMetadataV2CommonSchema.ex
});
export type PublicationMetadataV2TextOnly = z.infer<typeof PublicationMetadataV2TextOnlySchema>;

const PublicationMetadataV2VideoSchema = PublicationMetadataV2CommonSchema.extend({
mainContentFocus: z.literal(PublicationMainFocus.VIDEO),
const PublicationMetadataV2BaseVideoSchema = PublicationMetadataV2CommonSchema.extend({
mainContentFocus: z.union([
z.literal(PublicationMainFocus.VIDEO),
z.literal(PublicationMainFocus.SHORT_VIDEO),
]),

media: MediaSchema.array()
.min(1)
Expand All @@ -536,7 +539,16 @@ const PublicationMetadataV2VideoSchema = PublicationMetadataV2CommonSchema.exten
`Metadata ${PublicationMainFocus.VIDEO} requires an image to be attached.`,
),
});
export type PublicationMetadataV2Video = z.infer<typeof PublicationMetadataV2VideoSchema>;
const PublicationMetadataV2VideoSchema = PublicationMetadataV2BaseVideoSchema.extend({
mainContentFocus: z.literal(PublicationMainFocus.VIDEO),
});
const PublicationMetadataV2ShortVideoSchema = PublicationMetadataV2BaseVideoSchema.extend({
mainContentFocus: z.literal(PublicationMainFocus.SHORT_VIDEO),
});

export type PublicationMetadataV2Video =
| z.infer<typeof PublicationMetadataV2VideoSchema>
| z.infer<typeof PublicationMetadataV2ShortVideoSchema>;

/**
* @internal
Expand All @@ -550,6 +562,7 @@ export const PublicationMetadataV2Schema = z
PublicationMetadataV2LinkSchema,
PublicationMetadataV2TextOnlySchema,
PublicationMetadataV2VideoSchema,
PublicationMetadataV2ShortVideoSchema,
])
.transform((data) => {
if (data.mainContentFocus === PublicationMainFocus.VIDEO && data.appId === 'lenstube-bytes') {
Expand Down

0 comments on commit 39862c5

Please sign in to comment.