* Emit C# handler interfaces + a process-wide registration for client * *global* API groups. * * Unlike client-session APIs, these methods carry no implicit `sessionId` * dispatch key. The SDK consumer registers a single process-wide handler set * via `RegisterClientGlobalApiHandlers`; the runt
(clientSchema: Record<string, unknown>, classes: string[])
| 2310 | * runtime session triggered it. |
| 2311 | */ |
| 2312 | function emitClientGlobalApiRegistration(clientSchema: Record<string, unknown>, classes: string[]): string[] { |
| 2313 | const lines: string[] = []; |
| 2314 | const groups = collectClientGroups(clientSchema); |
| 2315 | |
| 2316 | for (const { methods } of groups) { |
| 2317 | for (const method of methods) { |
| 2318 | const resultSchema = getMethodResultSchema(method); |
| 2319 | if (!isVoidSchema(resultSchema) && !isOpaqueJson(resultSchema)) { |
| 2320 | emitRpcResultType(resultTypeName(method), resultSchema!, "public", classes); |
| 2321 | } |
| 2322 | |
| 2323 | const effectiveParams = resolveMethodParamsSchema(method); |
| 2324 | if (effectiveParams?.properties && Object.keys(effectiveParams.properties).length > 0) { |
| 2325 | const paramsClass = emitRpcClass(paramsTypeName(method), effectiveParams, "public", classes); |
| 2326 | if (paramsClass) classes.push(paramsClass); |
| 2327 | } |
| 2328 | } |
| 2329 | } |
| 2330 | |
| 2331 | for (const { groupName, groupNode, methods } of groups) { |
| 2332 | const interfaceName = clientHandlerInterfaceName(groupName); |
| 2333 | const groupExperimental = isNodeFullyExperimental(groupNode); |
| 2334 | const groupDeprecated = isNodeFullyDeprecated(groupNode); |
| 2335 | lines.push(`/// <summary>Handles \`${groupName}\` client global API methods.</summary>`); |
| 2336 | if (groupExperimental) { |
| 2337 | pushExperimentalAttribute(lines); |
| 2338 | } |
| 2339 | if (groupDeprecated) { |
| 2340 | pushObsoleteAttributes(lines); |
| 2341 | } |
| 2342 | lines.push(`public interface ${interfaceName}`); |
| 2343 | lines.push(`{`); |
| 2344 | for (const method of methods) { |
| 2345 | const effectiveParams = resolveMethodParamsSchema(method); |
| 2346 | const hasParams = !!effectiveParams?.properties && Object.keys(effectiveParams.properties).length > 0; |
| 2347 | const resultSchema = getMethodResultSchema(method); |
| 2348 | const taskType = resultTaskType(method); |
| 2349 | pushRpcMethodXmlDocs( |
| 2350 | lines, |
| 2351 | method, |
| 2352 | " ", |
| 2353 | [ |
| 2354 | ...(hasParams ? [{ name: "request", description: rpcParamsDescription(method, effectiveParams) }] : []), |
| 2355 | { name: "cancellationToken", description: CANCELLATION_TOKEN_DESCRIPTION, escapeDescription: false }, |
| 2356 | ], |
| 2357 | resultSchema, |
| 2358 | `Handles "${method.rpcMethod}".` |
| 2359 | ); |
| 2360 | if (method.stability === "experimental" && !groupExperimental) { |
| 2361 | pushExperimentalAttribute(lines, " "); |
| 2362 | } |
| 2363 | if (method.deprecated && !groupDeprecated) { |
| 2364 | pushObsoleteAttributes(lines, " "); |
| 2365 | } |
| 2366 | if (hasParams) { |
| 2367 | lines.push(` ${taskType} ${clientHandlerMethodName(method.rpcMethod)}(${paramsTypeName(method)} request, CancellationToken cancellationToken = default);`); |
| 2368 | } else { |
| 2369 | lines.push(` ${taskType} ${clientHandlerMethodName(method.rpcMethod)}(CancellationToken cancellationToken = default);`); |
no test coverage detected
searching dependent graphs…