@@ -13,6 +13,12 @@ import type { OutputProperty } from '@/tools/types'
1313
1414interface BufferSchemaType {
1515 fields ?: Record < string , string >
16+ /**
17+ * Fields Buffer has removed or is removing from the API. They stay in the outputs (always null)
18+ * so saved references keep resolving, but are never selected, since querying a removed field
19+ * fails the whole GraphQL request.
20+ */
21+ retired ?: string [ ]
1622 members ?: string [ ]
1723 values ?: string [ ]
1824 defaults ?: string [ ]
@@ -48,6 +54,7 @@ export function bufferSelection(type: string): string {
4854 return `__typename ${ schema . members . map ( ( member ) => `... on ${ member } { ${ bufferSelection ( member ) } }` ) . join ( ' ' ) } `
4955 }
5056 return Object . entries ( schema . fields ?? { } )
57+ . filter ( ( [ field ] ) => ! schema . retired ?. includes ( field ) )
5158 . map ( ( [ field , wireType ] ) => {
5259 const selection = bufferSelection ( baseType ( wireType ) )
5360 return selection ? `${ field } { ${ selection } }` : field
@@ -77,7 +84,9 @@ export function bufferOutputProperties(type: string): Record<string, OutputPrope
7784 const object = Boolean ( nested ?. fields || nested ?. members )
7885 const property : OutputProperty = {
7986 type : object ? 'object' : scalarType ( nestedType ) ,
80- description : `${ type } ${ field } ` ,
87+ description : schema . retired ?. includes ( field )
88+ ? `${ type } ${ field } (removed by Buffer, always null)`
89+ : `${ type } ${ field } ` ,
8190 ...( object ? { properties : bufferOutputProperties ( nestedType ) } : { } ) ,
8291 }
8392 properties [ field ] = wireType . startsWith ( '[' )
@@ -133,12 +142,12 @@ export function projectBufferObject(type: string, value: unknown): unknown {
133142 }
134143 return object
135144 ? projectBufferObject ( nestedType , entry )
136- : parseValue ( nestedType , entry , `Buffer response ${ type } .${ field } []` )
145+ : parseValue ( nestedType , entry , `Buffer response ${ type } .${ field } []` , 'output' )
137146 } )
138147 } else {
139148 result [ field ] = object
140149 ? projectBufferObject ( nestedType , candidate )
141- : parseValue ( nestedType , candidate , `Buffer response ${ type } .${ field } ` )
150+ : parseValue ( nestedType , candidate , `Buffer response ${ type } .${ field } ` , 'output' )
142151 }
143152 }
144153 return result
@@ -202,7 +211,16 @@ export function bufferInputDescription(type: string, description: string): strin
202211 : description
203212}
204213
205- function parseValue ( wireType : string , value : unknown , path : string ) : unknown {
214+ /**
215+ * Validates one wire value. Enum membership is enforced only on inputs: Buffer adds enum values
216+ * to responses without notice (GraphQL clients must tolerate them), so an output keeps any string.
217+ */
218+ function parseValue (
219+ wireType : string ,
220+ value : unknown ,
221+ path : string ,
222+ direction : 'input' | 'output' = 'input'
223+ ) : unknown {
206224 if ( value == null ) {
207225 if ( wireType . endsWith ( '!' ) ) throw new Error ( `${ path } is required` )
208226 return null
@@ -211,12 +229,14 @@ function parseValue(wireType: string, value: unknown, path: string): unknown {
211229 if ( type . startsWith ( '[' ) ) {
212230 if ( ! Array . isArray ( value ) ) throw new Error ( `${ path } must be an array` )
213231 if ( value . length > 1000 ) throw new Error ( `${ path } exceeds the integration limit of 1000 items` )
214- return value . map ( ( entry , index ) => parseValue ( type . slice ( 1 , - 1 ) , entry , `${ path } [${ index } ]` ) )
232+ return value . map ( ( entry , index ) =>
233+ parseValue ( type . slice ( 1 , - 1 ) , entry , `${ path } [${ index } ]` , direction )
234+ )
215235 }
216236 const schema = BUFFER_SCHEMA [ type ]
217237 if ( schema ?. fields ) return parseBufferInput ( type , value , path )
218238 if ( typeof value !== scalarType ( type ) ) throw new Error ( `${ path } must be a ${ scalarType ( type ) } ` )
219- if ( schema ?. values && ! schema . values . includes ( String ( value ) ) )
239+ if ( direction === 'input' && schema ?. values && ! schema . values . includes ( String ( value ) ) )
220240 throw new Error ( `${ path } must be one of ${ schema . values . join ( ', ' ) } ` )
221241 if ( type === 'Int' && ! Number . isInteger ( value ) ) throw new Error ( `${ path } must be an integer` )
222242 if ( ( type === 'Int' || type === 'Float' ) && ! Number . isFinite ( value ) )
@@ -385,8 +405,13 @@ const BUFFER_SCHEMA: Record<string, BufferSchemaType> = {
385405 } ,
386406 ChannelAction : {
387407 values : [
408+ 'approvePosts' ,
388409 'backfillChannel' ,
410+ 'cleanQueue' ,
411+ 'deleteDrafts' ,
412+ 'emptyQueue' ,
389413 'exportInsights' ,
414+ 'interactWithTakeaways' ,
390415 'manageCapabilities' ,
391416 'manageChannelSettings' ,
392417 'manageComments' ,
@@ -399,6 +424,7 @@ const BUFFER_SCHEMA: Record<string, BufferSchemaType> = {
399424 'reconnectChannel' ,
400425 'removeChannel' ,
401426 'scheduleUpdates' ,
427+ 'shuffleQueue' ,
402428 'viewCapabilities' ,
403429 'viewChannel' ,
404430 'viewComments' ,
@@ -1415,6 +1441,7 @@ const BUFFER_SCHEMA: Record<string, BufferSchemaType> = {
14151441 metadata : 'ThreadItemMetadata' ,
14161442 text : 'String!' ,
14171443 } ,
1444+ retired : [ 'linkAttachment' ] ,
14181445 } ,
14191446 ThreadedPostInput : {
14201447 fields : {
0 commit comments