| 268 | * @since 3.14.0 |
| 269 | */ |
| 270 | export const fromRecord = < |
| 271 | const Layers extends Record<PropertyKey, Layer.Layer<any, any, any>>, |
| 272 | const Preload extends boolean = false |
| 273 | >( |
| 274 | layers: Layers, |
| 275 | options?: { |
| 276 | readonly idleTimeToLive?: IdleTimeToLiveInput<keyof Layers> | undefined |
| 277 | /** |
| 278 | * Preloaded entries are retained only for their idle TTL. Keys whose idle |
| 279 | * TTL is zero are not preloaded (including when no TTL is specified). |
| 280 | */ |
| 281 | readonly preload?: Preload | undefined |
| 282 | } | undefined |
| 283 | ): Effect.Effect< |
| 284 | LayerMap< |
| 285 | keyof Layers, |
| 286 | Layer.Success<Layers[keyof Layers]>, |
| 287 | Layer.Error<Layers[keyof Layers]> |
| 288 | >, |
| 289 | Preload extends true ? Layer.Error<Layers[keyof Layers]> : never, |
| 290 | Scope.Scope | (Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never) |
| 291 | > => |
| 292 | make((key: keyof Layers) => layers[key], { |
| 293 | ...options, |
| 294 | preloadKeys: options?.preload ? InternalRecord.ownEnumerableKeys(layers) as Array<keyof Layers> : undefined |
| 295 | }) as any |
| 296 | |
| 297 | /** |
| 298 | * Service class shape produced by `LayerMap.Service`. |