(
generatedSessionTypeCode: string,
additionalTypeNames: Iterable<string> = [],
additionalConstNames: Iterable<string> = [],
excludeTypeNames: Iterable<string> = []
)
| 3467 | } |
| 3468 | |
| 3469 | function generateGoSessionEventAliasFile( |
| 3470 | generatedSessionTypeCode: string, |
| 3471 | additionalTypeNames: Iterable<string> = [], |
| 3472 | additionalConstNames: Iterable<string> = [], |
| 3473 | excludeTypeNames: Iterable<string> = [] |
| 3474 | ): string { |
| 3475 | const excluded = new Set(excludeTypeNames); |
| 3476 | const typeNames = [...new Set([...collectGoTopLevelNames(generatedSessionTypeCode, "type"), ...additionalTypeNames])] |
| 3477 | .filter((name) => !excluded.has(name)) |
| 3478 | .sort(compareGoTypeNames); |
| 3479 | const constNames = [...new Set([...collectGoTopLevelNames(generatedSessionTypeCode, "const"), ...additionalConstNames])] |
| 3480 | .filter((name) => !excluded.has(name)) |
| 3481 | .sort(compareGoTypeNames); |
| 3482 | const lines: string[] = []; |
| 3483 | |
| 3484 | lines.push(...goDoNotEditHeader("session-events.schema.json")); |
| 3485 | lines.push(``); |
| 3486 | lines.push(`package copilot`); |
| 3487 | lines.push(``); |
| 3488 | lines.push(`import "github.com/github/copilot-sdk/go/rpc"`); |
| 3489 | lines.push(``); |
| 3490 | |
| 3491 | if (typeNames.length > 0) { |
| 3492 | lines.push(`// Session-event types are generated in the rpc package and aliased here for source compatibility.`); |
| 3493 | lines.push(`type (`); |
| 3494 | for (const typeName of typeNames) { |
| 3495 | lines.push(`\t${typeName} = rpc.${typeName}`); |
| 3496 | } |
| 3497 | lines.push(`)`); |
| 3498 | lines.push(``); |
| 3499 | } |
| 3500 | |
| 3501 | if (constNames.length > 0) { |
| 3502 | lines.push(`// Session-event constants are generated in the rpc package and re-exported here for source compatibility.`); |
| 3503 | lines.push(`const (`); |
| 3504 | for (const constName of constNames) { |
| 3505 | lines.push(`\t${constName} = rpc.${constName}`); |
| 3506 | } |
| 3507 | lines.push(`)`); |
| 3508 | lines.push(``); |
| 3509 | } |
| 3510 | |
| 3511 | return joinGoCode(lines); |
| 3512 | } |
| 3513 | |
| 3514 | function collectGoSharedSessionEventAliasNames( |
| 3515 | sharedDefinitionNames: Iterable<string>, |
no test coverage detected
searching dependent graphs…