( value: unknown, options: Base64HydrationOptions, state: HydrationState, logger: Logger )
| 472 | } |
| 473 | |
| 474 | async function hydrateValue( |
| 475 | value: unknown, |
| 476 | options: Base64HydrationOptions, |
| 477 | state: HydrationState, |
| 478 | logger: Logger |
| 479 | ): Promise<unknown> { |
| 480 | if (!value || typeof value !== 'object') { |
| 481 | return value |
| 482 | } |
| 483 | |
| 484 | if ( |
| 485 | options.preserveLargeValueMetadata && |
| 486 | (isLargeArrayManifest(value) || isLargeValueRef(value)) |
| 487 | ) { |
| 488 | return value |
| 489 | } |
| 490 | |
| 491 | if (isLargeArrayManifest(value)) { |
| 492 | const materialized = await materializeLargeArrayManifest(value, options) |
| 493 | return hydrateValue( |
| 494 | materialized, |
| 495 | withLocalLargeValueExecutionIds(options, materialized), |
| 496 | state, |
| 497 | logger |
| 498 | ) |
| 499 | } |
| 500 | |
| 501 | if (isLargeValueRef(value)) { |
| 502 | const materialized = await materializeLargeValueRef(value, options) |
| 503 | if (materialized === undefined) { |
| 504 | throw getLargeValueMaterializationError(value) |
| 505 | } |
| 506 | return hydrateValue( |
| 507 | materialized, |
| 508 | withLocalLargeValueExecutionIds(options, materialized), |
| 509 | state, |
| 510 | logger |
| 511 | ) |
| 512 | } |
| 513 | |
| 514 | if (isUserFileWithMetadata(value)) { |
| 515 | return hydrateUserFile(value, options, state, logger) |
| 516 | } |
| 517 | |
| 518 | if (state.seen.has(value)) { |
| 519 | return value |
| 520 | } |
| 521 | state.seen.add(value) |
| 522 | |
| 523 | if (Array.isArray(value)) { |
| 524 | const hydratedItems = await Promise.all( |
| 525 | value.map((item) => hydrateValue(item, options, state, logger)) |
| 526 | ) |
| 527 | return hydratedItems |
| 528 | } |
| 529 | |
| 530 | const entries = await Promise.all( |
| 531 | Object.entries(value).map(async ([key, entryValue]) => { |
no test coverage detected