MCPcopy Create free account
hub / github.com/Effect-TS/effect / toPart

Function toPart

packages/tools/ai-codegen/src/Generator.ts:452–465  ·  view source on GitHub ↗
(member: unknown)

Source from the content-addressed store, hash-verified

450 }
451
452 const toPart = (member: unknown): Part | undefined => {
453 const schema = dereference(member)
454 if (schema === undefined) return undefined
455 if (isPlainObject(schema)) return { _tag: "Object", schema }
456 const mode = bareChoice(schema)
457 if (mode === undefined) return undefined
458 const branches: Array<JsonSchema.JsonSchema> = []
459 for (const branch of schema[mode] as ReadonlyArray<unknown>) {
460 const resolved = dereference(branch)
461 if (resolved === undefined || !(isPlainObject(resolved) || excludesObject(resolved))) return undefined
462 branches.push(resolved)
463 }
464 return { _tag: "Choice", mode, branches }
465 }
466
467 const compose = (js: JsonSchema.JsonSchema): JsonSchema.JsonSchema => {
468 // Sibling choices must both hold.

Callers 1

composeFunction · 0.70

Calls 5

dereferenceFunction · 0.85
isPlainObjectFunction · 0.85
bareChoiceFunction · 0.85
excludesObjectFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected