(
schema: ApiSchema,
externalJsonSerializableRefs: Map<string, Set<string>> = new Map(),
externalValueTypes: Set<string> = new Set()
)
| 2436 | } |
| 2437 | |
| 2438 | function generateRpcCode( |
| 2439 | schema: ApiSchema, |
| 2440 | externalJsonSerializableRefs: Map<string, Set<string>> = new Map(), |
| 2441 | externalValueTypes: Set<string> = new Set() |
| 2442 | ): string { |
| 2443 | emittedRpcClassSchemas.clear(); |
| 2444 | emittedRpcEnumResultTypes.clear(); |
| 2445 | experimentalRpcTypes.clear(); |
| 2446 | nonExperimentalRpcTypes.clear(); |
| 2447 | rpcKnownTypes.clear(); |
| 2448 | rpcEnumOutput = []; |
| 2449 | generatedEnums.clear(); // Clear shared enum deduplication map |
| 2450 | externalRpcValueTypes = new Set([...externalValueTypes].map(typeToClassName)); |
| 2451 | rpcDefinitions = collectDefinitionCollections(schema as Record<string, unknown>); |
| 2452 | const allMethods = [ |
| 2453 | ...collectRpcMethods(schema.server || {}), |
| 2454 | ...collectRpcMethods(schema.session || {}), |
| 2455 | ...collectRpcMethods(schema.clientSession || {}), |
| 2456 | ...collectRpcMethods(schema.clientGlobal || {}), |
| 2457 | ]; |
| 2458 | for (const name of collectRpcMethodReferencedDefinitionNames( |
| 2459 | allMethods.filter((method) => method.stability !== "experimental"), |
| 2460 | rpcDefinitions |
| 2461 | )) { |
| 2462 | nonExperimentalRpcTypes.add(typeToClassName(name)); |
| 2463 | } |
| 2464 | for (const name of collectExperimentalOnlyRpcReferencedDefinitionNames(allMethods, rpcDefinitions)) { |
| 2465 | experimentalRpcTypes.add(typeToClassName(name)); |
| 2466 | } |
| 2467 | for (const defs of [rpcDefinitions.definitions, rpcDefinitions.$defs]) { |
| 2468 | for (const [name, def] of Object.entries(defs ?? {})) { |
| 2469 | if (typeof def === "object" && def !== null && isSchemaExperimental(def as JSONSchema7)) { |
| 2470 | experimentalRpcTypes.add(typeToClassName(name)); |
| 2471 | } |
| 2472 | } |
| 2473 | } |
| 2474 | const classes: string[] = []; |
| 2475 | |
| 2476 | let serverRpcParts: string[] = []; |
| 2477 | if (schema.server) serverRpcParts = emitServerRpcClasses(schema.server, classes); |
| 2478 | |
| 2479 | let sessionRpcParts: string[] = []; |
| 2480 | if (schema.session) sessionRpcParts = emitSessionRpcClasses(schema.session, classes); |
| 2481 | |
| 2482 | let clientSessionParts: string[] = []; |
| 2483 | if (schema.clientSession) clientSessionParts = emitClientSessionApiRegistration(schema.clientSession, classes); |
| 2484 | |
| 2485 | let clientGlobalParts: string[] = []; |
| 2486 | if (schema.clientGlobal) clientGlobalParts = emitClientGlobalApiRegistration(schema.clientGlobal, classes); |
| 2487 | |
| 2488 | const lines: string[] = []; |
| 2489 | lines.push(`${COPYRIGHT} |
| 2490 | |
| 2491 | // AUTO-GENERATED FILE - DO NOT EDIT |
| 2492 | // Generated from: api.schema.json |
| 2493 | |
| 2494 | #pragma warning disable CS0612 // Type or member is obsolete |
| 2495 | #pragma warning disable CS0618 // Type or member is obsolete (with message) |
no test coverage detected
searching dependent graphs…