(
schema: JSONSchema7,
definitionCollections: DefinitionCollections = collectDefinitionCollections(schema as Record<string, unknown>)
)
| 1170 | } |
| 1171 | |
| 1172 | export function getSharedSessionEventEnvelopeProperties( |
| 1173 | schema: JSONSchema7, |
| 1174 | definitionCollections: DefinitionCollections = collectDefinitionCollections(schema as Record<string, unknown>) |
| 1175 | ): SessionEventEnvelopeProperty[] { |
| 1176 | const variants = getSessionEventVariantSchemas(schema, definitionCollections); |
| 1177 | const firstVariant = variants[0]; |
| 1178 | const firstProperties = firstVariant.properties ?? {}; |
| 1179 | |
| 1180 | return Object.entries(firstProperties) |
| 1181 | .filter(([name]) => name !== "type" && name !== "data") |
| 1182 | .map(([name]) => { |
| 1183 | const propertySchemas = variants |
| 1184 | .map((variant) => variant.properties?.[name]) |
| 1185 | .filter((propSchema): propSchema is JSONSchema7 => typeof propSchema === "object" && propSchema !== null); |
| 1186 | |
| 1187 | if (propertySchemas.length !== variants.length) return undefined; |
| 1188 | |
| 1189 | return { |
| 1190 | name, |
| 1191 | schema: selectSessionEventEnvelopePropertySchema(propertySchemas), |
| 1192 | required: variants.every((variant) => (variant.required ?? []).includes(name)), |
| 1193 | }; |
| 1194 | }) |
| 1195 | .filter((property): property is SessionEventEnvelopeProperty => property !== undefined); |
| 1196 | } |
| 1197 | |
| 1198 | function selectSessionEventEnvelopePropertySchema(propertySchemas: JSONSchema7[]): JSONSchema7 { |
| 1199 | // Some variants further constrain a shared envelope property, e.g. ephemeral const true. |
no test coverage detected
searching dependent graphs…