Skip to content

Commit

Permalink
Enforce properties field on lexicon object schemas (#1628)
Browse files Browse the repository at this point in the history
* add empty properites to thread gate schema fragments

* tweak lexicon type
  • Loading branch information
dholms authored Sep 19, 2023
1 parent a5a0e4a commit 828dfa8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 13 deletions.
6 changes: 4 additions & 2 deletions lexicons/app/bsky/feed/threadgate.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
},
"mentionRule": {
"type": "object",
"description": "Allow replies from actors mentioned in your post."
"description": "Allow replies from actors mentioned in your post.",
"properties": {}
},
"followingRule": {
"type": "object",
"description": "Allow replies from actors you follow."
"description": "Allow replies from actors you follow.",
"properties": {}
},
"listRule": {
"type": "object",
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5693,10 +5693,12 @@ export const schemaDict = {
mentionRule: {
type: 'object',
description: 'Allow replies from actors mentioned in your post.',
properties: {},
},
followingRule: {
type: 'object',
description: 'Allow replies from actors you follow.',
properties: {},
},
listRule: {
type: 'object',
Expand Down
8 changes: 6 additions & 2 deletions packages/api/src/client/types/app/bsky/feed/threadgate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function validateRecord(v: unknown): ValidationResult {
}

/** Allow replies from actors mentioned in your post. */
export interface MentionRule {}
export interface MentionRule {
[k: string]: unknown
}

export function isMentionRule(v: unknown): v is MentionRule {
return (
Expand All @@ -47,7 +49,9 @@ export function validateMentionRule(v: unknown): ValidationResult {
}

/** Allow replies from actors you follow. */
export interface FollowingRule {}
export interface FollowingRule {
[k: string]: unknown
}

export function isFollowingRule(v: unknown): v is FollowingRule {
return (
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5693,10 +5693,12 @@ export const schemaDict = {
mentionRule: {
type: 'object',
description: 'Allow replies from actors mentioned in your post.',
properties: {},
},
followingRule: {
type: 'object',
description: 'Allow replies from actors you follow.',
properties: {},
},
listRule: {
type: 'object',
Expand Down
8 changes: 6 additions & 2 deletions packages/bsky/src/lexicon/types/app/bsky/feed/threadgate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function validateRecord(v: unknown): ValidationResult {
}

/** Allow replies from actors mentioned in your post. */
export interface MentionRule {}
export interface MentionRule {
[k: string]: unknown
}

export function isMentionRule(v: unknown): v is MentionRule {
return (
Expand All @@ -47,7 +49,9 @@ export function validateMentionRule(v: unknown): ValidationResult {
}

/** Allow replies from actors you follow. */
export interface FollowingRule {}
export interface FollowingRule {
[k: string]: unknown
}

export function isFollowingRule(v: unknown): v is FollowingRule {
return (
Expand Down
8 changes: 3 additions & 5 deletions packages/lexicon/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,9 @@ export const lexObject = z
description: z.string().optional(),
required: z.string().array().optional(),
nullable: z.string().array().optional(),
properties: z
.record(
z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]),
)
.optional(),
properties: z.record(
z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]),
),
})
.strict()
.superRefine(requiredPropertiesRefinement)
Expand Down
2 changes: 2 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5693,10 +5693,12 @@ export const schemaDict = {
mentionRule: {
type: 'object',
description: 'Allow replies from actors mentioned in your post.',
properties: {},
},
followingRule: {
type: 'object',
description: 'Allow replies from actors you follow.',
properties: {},
},
listRule: {
type: 'object',
Expand Down
8 changes: 6 additions & 2 deletions packages/pds/src/lexicon/types/app/bsky/feed/threadgate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export function validateRecord(v: unknown): ValidationResult {
}

/** Allow replies from actors mentioned in your post. */
export interface MentionRule {}
export interface MentionRule {
[k: string]: unknown
}

export function isMentionRule(v: unknown): v is MentionRule {
return (
Expand All @@ -47,7 +49,9 @@ export function validateMentionRule(v: unknown): ValidationResult {
}

/** Allow replies from actors you follow. */
export interface FollowingRule {}
export interface FollowingRule {
[k: string]: unknown
}

export function isFollowingRule(v: unknown): v is FollowingRule {
return (
Expand Down

0 comments on commit 828dfa8

Please sign in to comment.