import { NonEmptyString, UUID } from 'io-ts-types'; import { Iso } from 'monocle-ts'; import { AnyNewtype, CarrierOf, Newtype, URIOf } from 'newtype-ts'; import { AnyTuple, Overwrite } from 'typelevel-ts'; import * as O from 'fp-ts/lib/Option'; import * as Ord from 'fp-ts/lib/Ord'; /** * Utility interface used to attach a tag & unique symbol to a Newtype's _URI * field. * * NOTE: We are using the representation * `{ _Tag: 'MyTag'; _Symbol: unique symbol }` instead of * `{ MyTag: unique symbol }` in order to facilitate easily overwriting the tag * when making fresh newtypes. See the `SetTag` utility for more info. */ export interface NewtypeURI { readonly _Tag: Tag; readonly _Symbol: unique symbol; } /** * Utility interface used to attach "phantom params" to a Newtype's _URI field. */ export declare type PhantomParams = { readonly _PhantomParams: Ps; }; /** * A union type representing a valid URI for a SimSpaceNewtype that is also a * phantom type. */ export declare type SimSpacePhantomTypeURI = NewtypeURI & PhantomParams; /** * A union type representing a valid type for a SimspaceNewtype's _URI field. * This union type is used to allow or disallow constructing a phantom type by * either providing or not providing a tuple of PhantomParams" (type parameters * that affect the nominal type being constructed but that do not appear on the * underlying runtime type). */ export declare type SimSpaceNewtypeURI = NewtypeURI | SimSpacePhantomTypeURI; /** * A wrapper around newtype-ts' Newtype interface with exta constraints on the * _URI field. */ export interface SimSpaceNewtype extends Newtype { } /** * Utility type used to update an existing SimSpaceNewtype's _Tag field. * This can be used to provide a new identifier while extending an existing * SimSpaceNewtype. */ export declare type SetTag> = New extends SimSpaceNewtype ? Overwrite & PhantomParams; }> : { _URI: NewtypeURI; }; /** * A generic phantom type. `A` represents the underlying runtime type being * wrapped, and `B` represents an extra "phantom param" used to tag the nominal * type with extra information. * * Modeled after Haskell's `Const` from `Control.Applicative` and * `Data.Functor.Const`. * * NOTE: `fp-ts` already has a `Const` data type and module, which does not use * newtype-ts. Be careful to avoid collisions. */ export interface Const extends SimSpaceNewtype & PhantomParams<[B]>, A> { } /** * A specialized verson of the `Const` phantom type with its type params * flipped and the "phantom param" being constrained to a type-level literal * string. * * Modeled after Haskell's `Tagged` from `Data.Tagged`. * * NOTE: `io-ts` already has a `Tagged` type, but it is deprecated. Be careful * to avoid collisions. */ export interface Tagged extends SetTag<'Tagged', Const> { } /** * A specialized verson of the `Const` phantom type where the underlying * runtime type is fixed to type `string`. This is a useful phantom type for * providing extra safety by disambiguating between string IDs for different * types. * * Modeled after the `Key` phantom type in our Haskell codebase. * * Note: Some of the generated TypeScript type files already have a * `type Key = string` type alias. Be Careful to avoid collisions. */ export interface Key extends SetTag<'Key', Const> { } /** * A phantom type just like `Key` but the underlying type is an io-ts-types UUID * instead of a string. */ export interface UUIDKey extends SetTag<'UUIDKey', Const> { } /** * Gets a prism that validates UUIDs. * * NOTE: You may not need this if using io-ts Codecs. */ export declare function getPrismUUID(): import("monocle-ts").Prism, UUIDKey>; /** * A phantom type wrapper for expresing versions which are a part of * versioned entities. * * Modeled after the `Version` phantom type in our Haskell codebase. * * Note: Some of the generated TypeScript type files already have a * `type Version = number` type alias. Be Careful to avoid collisions. */ export interface Version extends SetTag<'Version', Const> { } /** * A specialized verson of the `Const` phantom type where the underlying * runtime type is fixed to type `string`. This is a useful phantom type for * providing extra safety by disambiguating between names for different types. */ export interface Name extends SetTag<'Name', Const> { } /** * A phantom type just like `Name` but the underlying type is an io-ts-types * NonEmptyString instead of a string. */ export interface NonEmptyName extends SetTag<'NonEmptyName', Const> { } /** * A specialized verson of the `Const` phantom type where the underlying * runtime type is fixed to type `string`. This is a useful phantom type for * providing extra safety by disambiguating between descriptions for different * types. */ export interface Description extends SetTag<'Description', Const> { } /** * NaN is a refinement of number */ export interface NaN extends SimSpaceNewtype, number> { } /** * Use this prism to return an option with prismNaN.getOption(someNumber) */ export declare const prismNaN: import("monocle-ts").Prism; /** * Infinity is a refinement of number */ export interface Infinity extends SimSpaceNewtype, number> { } export declare const prismInfinity: import("monocle-ts").Prism; /** * Finite is a refinement of number */ export interface Finite extends SimSpaceNewtype, number> { } export declare const prismFinite: import("monocle-ts").Prism; export interface IsoDate extends SimSpaceNewtype, string> { } export declare const isoDateToDate: (isoDate: IsoDate) => Date; export declare const ordIsoDate: Ord.Ord; export declare const prismIsoDate: import("monocle-ts").Prism; export declare type CoerceNewtype = N extends Newtype ? A : never; export declare const coerce: (n: N) => CoerceNewtype; export declare const coerceToString: >(s: S) => string; /** * Try to take a param and decode it into a UUID by way of io-ts UUID * branded type. If the param correctly decodes, then take the value * and wrap it in the proper newtype created for the param * * @param {string} param - Any param that can possibly be turned into a UUID * @param {string} paramName - The name of the param being passed in for logging purposes * @param {Iso>} iso - The iso used to wrap the param into a new type for that param */ export declare const buildKeyNewtypeFromParam: (paramName: string, iso: Iso>) => (param: string) => O.Option, string>>;