MCPcopy Index your code
hub / github.com/anomalyco/opencode / renderImportedProjection

Function renderImportedProjection

packages/httpapi-codegen/src/index.ts:400–419  ·  view source on GitHub ↗
(groups: ReadonlyArray<Group>, endpoints: Readonly<Record<string, string>>)

Source from the content-addressed store, hash-verified

398}
399
400function renderImportedProjection(groups: ReadonlyArray<Group>, endpoints: Readonly<Record<string, string>>) {
401 const imports = groups.flatMap((group) =>
402 group.endpoints.map((endpoint) => {
403 const name = endpoints[`${group.identifier}.${endpoint.endpoint.name}`]
404 if (name === undefined) {
405 throw new GenerationError({
406 reason: `Missing imported endpoint: ${group.identifier}.${endpoint.endpoint.name}`,
407 })
408 }
409 return name
410 }),
411 )
412 const source = `const Api = HttpApi.make("generated").${groups
413 .map((group) => {
414 const options = group.endpoints[0]?.topLevel ? ", { topLevel: true }" : ""
415 return `add(HttpApiGroup.make(${JSON.stringify(group.identifier)}${options})${group.endpoints.map((endpoint) => `.add(${endpoints[`${group.identifier}.${endpoint.endpoint.name}`]})`).join("")})`
416 })
417 .join(".")}\n\n`
418 return { imports: [...new Set(imports)], source }
419}
420
421function renderPromiseTypes(
422 groups: ReadonlyArray<Group>,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected