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

Function emitGroup

scripts/codegen/typescript.ts:732–813  ·  view source on GitHub ↗
(
    node: Record<string, unknown>,
    indent: string,
    isSession: boolean,
    parentExperimental = false,
    parentDeprecated = false,
    visibilityFilter?: "public" | "internal",
)

Source from the content-addressed store, hash-verified

730}
731
732function emitGroup(
733 node: Record<string, unknown>,
734 indent: string,
735 isSession: boolean,
736 parentExperimental = false,
737 parentDeprecated = false,
738 visibilityFilter?: "public" | "internal",
739): string[] {
740 const lines: string[] = [];
741 for (const [key, value] of Object.entries(node)) {
742 if (isRpcMethod(value)) {
743 const isInternalMethod = (value as RpcMethod).visibility === "internal";
744 if (visibilityFilter === "public" && isInternalMethod) continue;
745 if (visibilityFilter === "internal" && !isInternalMethod) continue;
746 const { rpcMethod, params } = value;
747 const resultType = tsResultType(value);
748 const paramsType = paramsTypeName(value);
749 const effectiveParams = getMethodParamsSchema(value);
750
751 const paramEntries = effectiveParams?.properties
752 ? Object.entries(effectiveParams.properties).filter(([k]) => k !== "sessionId")
753 : [];
754 const hasParams = hasSchemaPayload(effectiveParams);
755 const hasNonSessionParams = paramEntries.length > 0;
756
757 const sigParams: string[] = [];
758 let bodyArg: string;
759
760 if (isSession) {
761 if (hasNonSessionParams) {
762 const optMark = isParamsOptional(value) ? "?" : "";
763 // sessionId is already stripped from the generated type definition,
764 // so no need for Omit<..., "sessionId">
765 sigParams.push(`params${optMark}: ${paramsType}`);
766 bodyArg = "{ sessionId, ...params }";
767 } else {
768 bodyArg = "{ sessionId }";
769 }
770 } else {
771 if (hasParams) {
772 const optMark = isParamsOptional(value) ? "?" : "";
773 sigParams.push(`params${optMark}: ${paramsType}`);
774 bodyArg = "params";
775 } else {
776 bodyArg = "{}";
777 }
778 }
779
780 pushTsRpcMethodJsDoc(lines, indent, value, {
781 paramsName: sigParams.length > 0 ? "params" : undefined,
782 paramsDescription: rpcParamsDescription(value, effectiveParams),
783 includeDeprecated: (value as RpcMethod).deprecated && !parentDeprecated,
784 includeExperimental: (value as RpcMethod).stability === "experimental" && !parentExperimental,
785 });
786 lines.push(`${indent}${key}: async (${sigParams.join(", ")}): Promise<${resultType}> =>`);
787 lines.push(`${indent} connection.sendRequest("${rpcMethod}", ${bodyArg}),`);
788 } else if (typeof value === "object" && value !== null) {
789 const groupExperimental = isNodeFullyExperimental(value as Record<string, unknown>);

Callers 1

generateRpcFunction · 0.85

Calls 13

tsResultTypeFunction · 0.85
hasSchemaPayloadFunction · 0.85
pushTsRpcMethodJsDocFunction · 0.85
isNodeFullyExperimentalFunction · 0.85
isNodeFullyDeprecatedFunction · 0.85
tsExperimentalJSDocFunction · 0.85
joinMethod · 0.80
isRpcMethodFunction · 0.70
paramsTypeNameFunction · 0.70
getMethodParamsSchemaFunction · 0.70
isParamsOptionalFunction · 0.70
rpcParamsDescriptionFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…