Barazo lexicon schemas and TypeScript types barazo.forum
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lexicons): change enum to knownValues for forward compatibility (#26)

AT Protocol `enum` rejects unknown values, making it impossible to add
new content formats or maturity levels without breaking existing
validators. `knownValues` is the open-set alternative that allows
extensibility while preserving autocomplete for known values.

Changed fields:
- contentFormat in post.json and reply.json
- maturityLevel in preferences.json

Regenerated TypeScript types and updated tests.

Fixes barazo-forum/barazo-workspace#24

authored by

Guido X Jansen and committed by
GitHub
ad8fa16b e1f7230d

+11 -11
+1 -1
lexicons/forum/barazo/actor/preferences.json
··· 13 13 "properties": { 14 14 "maturityLevel": { 15 15 "type": "string", 16 - "enum": ["safe", "mature", "all"], 16 + "knownValues": ["safe", "mature", "all"], 17 17 "description": "Maximum maturity tier to show. Default: 'safe'." 18 18 }, 19 19 "mutedWords": {
+1 -1
lexicons/forum/barazo/topic/post.json
··· 26 26 }, 27 27 "contentFormat": { 28 28 "type": "string", 29 - "enum": ["markdown"], 29 + "knownValues": ["markdown"], 30 30 "description": "Content format. Defaults to 'markdown' if omitted." 31 31 }, 32 32 "community": {
+1 -1
lexicons/forum/barazo/topic/reply.json
··· 19 19 }, 20 20 "contentFormat": { 21 21 "type": "string", 22 - "enum": ["markdown"], 22 + "knownValues": ["markdown"], 23 23 "description": "Content format. Defaults to 'markdown' if omitted." 24 24 }, 25 25 "root": {
+3 -3
src/generated/lexicons.ts
··· 227 227 properties: { 228 228 maturityLevel: { 229 229 type: 'string', 230 - enum: ['safe', 'mature', 'all'], 230 + knownValues: ['safe', 'mature', 'all'], 231 231 description: "Maximum maturity tier to show. Default: 'safe'.", 232 232 }, 233 233 mutedWords: { ··· 394 394 }, 395 395 contentFormat: { 396 396 type: 'string', 397 - enum: ['markdown'], 397 + knownValues: ['markdown'], 398 398 description: "Content format. Defaults to 'markdown' if omitted.", 399 399 }, 400 400 community: { ··· 460 460 }, 461 461 contentFormat: { 462 462 type: 'string', 463 - enum: ['markdown'], 463 + knownValues: ['markdown'], 464 464 description: "Content format. Defaults to 'markdown' if omitted.", 465 465 }, 466 466 root: {
+1 -1
src/generated/types/forum/barazo/actor/preferences.ts
··· 17 17 export interface Main { 18 18 $type: 'forum.barazo.actor.preferences' 19 19 /** Maximum maturity tier to show. Default: 'safe'. */ 20 - maturityLevel: 'safe' | 'mature' | 'all' 20 + maturityLevel: 'safe' | 'mature' | 'all' | (string & {}) 21 21 /** Global muted words (apply to all communities). */ 22 22 mutedWords?: string[] 23 23 /** Blocked accounts (content hidden everywhere). */
+1 -1
src/generated/types/forum/barazo/topic/post.ts
··· 22 22 /** Topic body in markdown. */ 23 23 content: string 24 24 /** Content format. Defaults to 'markdown' if omitted. */ 25 - contentFormat?: 'markdown' 25 + contentFormat?: 'markdown' | (string & {}) 26 26 /** DID of the community where this record was created. Immutable origin identifier for cross-community attribution. */ 27 27 community: string 28 28 /** Category rkey within the community. */
+1 -1
src/generated/types/forum/barazo/topic/reply.ts
··· 21 21 /** Reply body in markdown. */ 22 22 content: string 23 23 /** Content format. Defaults to 'markdown' if omitted. */ 24 - contentFormat?: 'markdown' 24 + contentFormat?: 'markdown' | (string & {}) 25 25 root: ComAtprotoRepoStrongRef.Main 26 26 parent: ComAtprotoRepoStrongRef.Main 27 27 /** DID of the community where this reply was created. Immutable origin identifier. */
+2 -2
tests/lexicon-schemas.test.ts
··· 241 241 expect(main['key']).toBe('literal:self') 242 242 }) 243 243 244 - it('has maturityLevel enum with safe, mature, all', () => { 244 + it('has maturityLevel knownValues with safe, mature, all', () => { 245 245 const defs = schema['defs'] as Record<string, unknown> 246 246 const main = defs['main'] as Record<string, unknown> 247 247 const record = main['record'] as Record<string, unknown> 248 248 const props = record['properties'] as Record<string, unknown> 249 249 const ml = props['maturityLevel'] as Record<string, unknown> 250 - expect(ml['enum']).toEqual(['safe', 'mature', 'all']) 250 + expect(ml['knownValues']).toEqual(['safe', 'mature', 'all']) 251 251 }) 252 252 253 253 it('defines crossPostConfig as a separate def', () => {