MCPcopy Create free account
hub / github.com/TanStack/ai / render

Function render

scripts/generate-fal-image-field-map.ts:252–338  ·  view source on GitHub ↗
(
  overrides: Map<string, Partial<Record<RoleKey, string>>>,
)

Source from the content-addressed store, hash-verified

250// ---------------------------------------------------------------------------
251
252function render(
253 overrides: Map<string, Partial<Record<RoleKey, string>>>,
254): string {
255 const clientVersion = (
256 JSON.parse(readFileSync(CLIENT_PKG_JSON, 'utf8')) as { version: string }
257 ).version
258 const dtsHash = createHash('sha256')
259 .update(readFileSync(ENDPOINTS_DTS))
260 .digest('hex')
261
262 const sortedIds = [...overrides.keys()].sort()
263 const entries = sortedIds
264 .map((id) => {
265 const entry = overrides.get(id)!
266 const pairs = ROLE_ORDER.filter((role) => entry[role]).map(
267 (role) => `${role}: '${entry[role]}'`,
268 )
269 return ` '${id}': { ${pairs.join(', ')} },`
270 })
271 .join('\n')
272
273 // Union of every field name the runtime mapper may emit: the per-role
274 // defaults plus every field referenced by an override.
275 const fieldNames = new Set<string>(Object.values(DEFAULTS))
276 for (const entry of overrides.values()) {
277 for (const field of Object.values(entry)) fieldNames.add(field)
278 }
279 const fieldNameUnion = [...fieldNames]
280 .sort()
281 .map((name) => ` | '${name}'`)
282 .join('\n')
283
284 return `/* eslint-disable */
285// ---------------------------------------------------------------------------
286// AUTO-GENERATED — do not edit by hand.
287//
288// Generated from @fal-ai/client@${clientVersion} EndpointTypeMap by
289// scripts/generate-fal-image-field-map.ts. Regenerate after bumping
290// @fal-ai/client:
291//
292// pnpm tsx scripts/generate-fal-image-field-map.ts
293//
294// Maps fal endpoint ids to the image-conditioning input fields they accept
295// whenever those differ from the defaults in image-inputs.ts. Endpoints
296// matching the defaults are omitted. The \`satisfies\` clause below checks
297// every field name against the SDK's endpoint input types at compile time
298// (type-only import — nothing from endpoints.d.ts is shipped at runtime).
299// ---------------------------------------------------------------------------
300import type { EndpointTypeMap } from '@fal-ai/client/endpoints'
301
302/** sha256 of the endpoints.d.ts this file was generated from. */
303export const FAL_ENDPOINTS_DTS_SHA256 =
304 '${dtsHash}'
305
306/** Every input field name the image-input mappers may emit. */
307export type FalImageFieldName =
308${fieldNameUnion}
309

Callers 4

renderComponentFunction · 0.85
mcp-apps.test.tsxFile · 0.85
renderAndCaptureFunction · 0.85

Calls 4

parseMethod · 0.80
valuesMethod · 0.80
updateMethod · 0.65
getMethod · 0.65

Tested by 2

renderComponentFunction · 0.68
renderAndCaptureFunction · 0.68