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

Function emitClientGlobalApiRegistration

scripts/codegen/go.ts:4356–4455  ·  view source on GitHub ↗
(lines: string[], clientSchema: Record<string, unknown>, resolveType: (name: string) => string, unionInfos: Map<string, GoDiscriminatedUnionInfo>)

Source from the content-addressed store, hash-verified

4354}
4355
4356function emitClientGlobalApiRegistration(lines: string[], clientSchema: Record<string, unknown>, resolveType: (name: string) => string, unionInfos: Map<string, GoDiscriminatedUnionInfo>): void {
4357 const groups = collectClientGroups(clientSchema);
4358
4359 for (const { groupName, groupNode, methods } of groups) {
4360 const interfaceName = clientHandlerInterfaceName(groupName);
4361 const groupExperimental = isNodeFullyExperimental(groupNode);
4362 const groupDeprecated = isNodeFullyDeprecated(groupNode);
4363 if (groupDeprecated) {
4364 pushGoComment(lines, `Deprecated: ${interfaceName} contains deprecated APIs that will be removed in a future version.`);
4365 }
4366 if (groupExperimental) {
4367 pushGoExperimentalApiComment(lines, interfaceName);
4368 }
4369 lines.push(`type ${interfaceName} interface {`);
4370 for (const method of methods) {
4371 const resultSchema = getMethodResultSchema(method);
4372 pushGoRpcMethodComment(
4373 lines,
4374 clientHandlerMethodName(method.rpcMethod),
4375 method,
4376 resultSchema,
4377 goRpcParamsDescription(method, getMethodParamsSchema(method)),
4378 "\t",
4379 "handles"
4380 );
4381 if (method.deprecated && !groupDeprecated) {
4382 pushGoComment(lines, `Deprecated: ${clientHandlerMethodName(method.rpcMethod)} is deprecated and will be removed in a future version.`, "\t");
4383 }
4384 if (method.stability === "experimental" && !groupExperimental) {
4385 pushGoExperimentalMethodComment(lines, clientHandlerMethodName(method.rpcMethod), "\t");
4386 }
4387 const paramsType = resolveType(goParamsTypeName(method));
4388 const nullableInner = resultSchema ? getNullableInner(resultSchema) : undefined;
4389 let returnType: string;
4390 if (isOpaqueJson(resultSchema)) {
4391 returnType = "any";
4392 } else {
4393 const resultType = nullableInner
4394 ? resolveType(goNullableResultTypeName(method, nullableInner))
4395 : resolveType(goResultTypeName(method));
4396 returnType = unionInfos.has(resultType) ? resultType : `*${resultType}`;
4397 }
4398 lines.push(`\t${clientHandlerMethodName(method.rpcMethod)}(request *${paramsType}) (${returnType}, error)`);
4399 }
4400 lines.push(`}`);
4401 lines.push(``);
4402 }
4403
4404 lines.push(`// ClientGlobalAPIHandlers provides all client-global API handler groups.`);
4405 lines.push(`//`);
4406 lines.push(`// Unlike client-session handlers these carry no implicit session id dispatch`);
4407 lines.push(`// key; a single set of handlers serves the entire connection.`);
4408 lines.push(`type ClientGlobalAPIHandlers struct {`);
4409 for (const { groupName } of groups) {
4410 lines.push(`\t${toGoFieldName(groupName)} ${clientHandlerInterfaceName(groupName)}`);
4411 }
4412 lines.push(`}`);
4413 lines.push(``);

Callers 1

generateRpcFunction · 0.70

Calls 15

isNodeFullyExperimentalFunction · 0.85
isNodeFullyDeprecatedFunction · 0.85
pushGoCommentFunction · 0.85
pushGoRpcMethodCommentFunction · 0.85
goRpcParamsDescriptionFunction · 0.85
goParamsTypeNameFunction · 0.85
getNullableInnerFunction · 0.85
isOpaqueJsonFunction · 0.85
goNullableResultTypeNameFunction · 0.85
goResultTypeNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…