(propertySchemas: JSONSchema7[])
| 1196 | } |
| 1197 | |
| 1198 | function selectSessionEventEnvelopePropertySchema(propertySchemas: JSONSchema7[]): JSONSchema7 { |
| 1199 | // Some variants further constrain a shared envelope property, e.g. ephemeral const true. |
| 1200 | // Generate the base property from the least restrictive schema that has useful metadata. |
| 1201 | return ( |
| 1202 | propertySchemas.find((schema) => !isConstOrEnumSchema(schema) && schema.description) ?? |
| 1203 | propertySchemas.find((schema) => !isConstOrEnumSchema(schema)) ?? |
| 1204 | propertySchemas.find((schema) => schema.description) ?? |
| 1205 | propertySchemas[0] |
| 1206 | ); |
| 1207 | } |
| 1208 | |
| 1209 | function isConstOrEnumSchema(schema: JSONSchema7): boolean { |
| 1210 | return "const" in schema || (Array.isArray(schema.enum) && schema.enum.length > 0); |
no test coverage detected
searching dependent graphs…