MCPcopy Index your code
hub / github.com/github/copilot-sdk / generateSessionEvents

Function generateSessionEvents

scripts/codegen/typescript.ts:340–387  ·  view source on GitHub ↗
(schemaPath?: string)

Source from the content-addressed store, hash-verified

338// ── Session Events ──────────────────────────────────────────────────────────
339
340async function generateSessionEvents(schemaPath?: string): Promise<void> {
341 console.log("TypeScript: generating session-events...");
342
343 const resolvedPath = schemaPath ?? (await getSessionEventsSchemaPath());
344 const schema = (await loadSchemaJson(resolvedPath)) as JSONSchema7;
345 const processed = propagateInternalVisibility(postProcessSchema(schema));
346 const definitionCollections = collectDefinitionCollections(processed as Record<string, unknown>);
347 const sessionEvent =
348 resolveSchema({ $ref: "#/definitions/SessionEvent" }, definitionCollections) ??
349 resolveSchema({ $ref: "#/$defs/SessionEvent" }, definitionCollections) ??
350 processed;
351 const schemaForCompile = withSharedDefinitions(sessionEvent, definitionCollections);
352 appendPropertyMarkerTagsToDescriptions(schemaForCompile);
353
354 const ts = await compile(normalizeSchemaForTypeScript(schemaForCompile), "SessionEvent", {
355 bannerComment: `/**
356 * AUTO-GENERATED FILE - DO NOT EDIT
357 * Generated from: session-events.schema.json
358 */`,
359 style: { semi: true, singleQuote: false, trailingComma: "all" },
360 additionalProperties: false,
361 strictIndexSignatures: true,
362 });
363
364 let annotatedTs = annotateTypeScriptTypes(ts, experimentalDefinitionNames(definitionCollections), TS_EXPERIMENTAL_JSDOC);
365 // Add @internal JSDoc annotations for session-event types marked
366 // `visibility: "internal"` in the schema. The tag drives `stripInternal`
367 // so the whole type is dropped from the published .d.ts.
368 const sessionInternalTypes = new Set<string>();
369 for (const [name, def] of Object.entries(definitionCollections.definitions ?? {})) {
370 if (def && typeof def === "object" && (def as Record<string, unknown>).visibility === "internal") {
371 sessionInternalTypes.add(name);
372 }
373 }
374 for (const [name, def] of Object.entries(definitionCollections.$defs ?? {})) {
375 if (def && typeof def === "object" && (def as Record<string, unknown>).visibility === "internal") {
376 sessionInternalTypes.add(name);
377 }
378 }
379 for (const intType of sessionInternalTypes) {
380 annotatedTs = annotatedTs.replace(
381 new RegExp(`(^|\\n)(export (?:interface|type) ${intType}\\b)`, "m"),
382 `$1/** @internal */\n$2`
383 );
384 }
385 const outPath = await writeGeneratedFile("nodejs/src/generated/session-events.ts", annotatedTs);
386 console.log(` ✓ ${outPath}`);
387}
388
389// ── RPC Types ───────────────────────────────────────────────────────────────
390

Callers 1

generateFunction · 0.70

Calls 14

loadSchemaJsonFunction · 0.85
postProcessSchemaFunction · 0.85
resolveSchemaFunction · 0.85
withSharedDefinitionsFunction · 0.85
annotateTypeScriptTypesFunction · 0.85
writeGeneratedFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…