/** * Originally ported from https://github.com/zio/zio/blob/master/core/shared/src/main/scala/zio/Has.scala * by Michael Arnaldi and the Matechs Garage Contributors * * Copyright 2017-2020 John A. De Goes and the ZIO Contributors * * Copyright 2020 Michael Arnaldi and the Matechs Garage Contributors. */ import type { Option } from './Option'; /** * URI used in Has */ export declare const HasURI: unique symbol; /** * Has signal presence of a specific service provided via Tag in the environment */ export interface Has { [HasURI]: { _T: () => T; }; } /** * URI used in Region */ export declare const RegionURI: unique symbol; /** * Branding sub-environments */ export interface Region { [RegionURI]: { _K: () => K; _T: () => T; }; } /** * Extract the type of a class constructor */ export declare type ConstructorType> = K extends { prototype: infer T; } ? T : never; export declare type Constructor = Function & { prototype: T; }; /** * Tag Encodes capabilities of reading and writing a service T into a generic environment */ export interface Tag { _tag: 'Tag'; _T: T; key: PropertyKey; def: boolean; overridable: () => Tag; fixed: () => Tag; refine: () => Tag; read: (r: Has) => T; readOption: (r: unknown) => Option; setKey: (s: PropertyKey) => Tag; of: (_: T) => Has; } /** * Extract the Has type from any augumented variant */ export declare type HasTag = [T] extends [Tag] ? Has : never; /** * Create a service entry Tag from a type and a URI */ export declare function tag>(_: T): Tag>; export declare function tag(): Tag; /** * Get the service type of a Has */ export declare type ServiceType = [T] extends [Has] ? A : never; /** * Replaces the service with the required Service Entry, in the specified environment */ export declare function replaceServiceIn(_: Tag, f: (t: T) => T): (r: R & Has) => R & Has; /** * Replaces the service with the required Service Entry, in the specified environment */ export declare function replaceServiceIn_(r: R & Has, _: Tag, f: (t: T) => T): R & Has; /** * Flags the current Has to be overridable, when this is used subsequently provided * environments will override pre-existing. Useful to provide defaults. */ export declare function overridable(h: Tag): Tag; export declare function mergeEnvironments(_: Tag, r: R1, t: T): R1 & Has; export declare class DerivationContext { readonly hasMap: Map, Tag>; derive(has: Tag, f: () => Tag): Tag; } export declare const isTag: (u: unknown) => u is Tag; //# sourceMappingURL=Has.d.ts.map