@vicin/phantom 1.0.8 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -82
- package/dist/index.d.mts +74 -11
- package/dist/index.d.ts +74 -11
- package/dist/index.global.js +8 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -2
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/assertors/brand.ts","../src/assertors/identity.ts","../src/assertors/trait.ts","../src/assertors/transformation.ts","../src/assertors/assertors.ts","../src/chain/chain.ts","../src/core/phantom.ts","../src/phantom.ts","../src/index.ts"],"names":["assertors","_PhantomChain","PhantomCore","_addTrait","_addTraits","_applyTransformation","_asBrand","_asIdentity","_dropTrait","_dropTraits","_revertTransformation","Phantom","Inspect","PhantomChain"],"mappings":";;;;;AAYO,IAAM,OAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACHG,IAAM,UAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACLG,IAAM,QAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,SAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,SAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,UAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACvCG,IAAM,mBAAA,GACX,MACA,CAAO,KAAA,EAAU,WAAA,KACf;AAcG,IAAM,oBAAA,GACX,MACA,CAAO,WAAA,EAAgB,KAAA,KACrB;;;AC5BJ,IAAM,SAAA,GAAY,QAAA;AAClB,IAAM,UAAA,GAAa,SAAA;AACnB,IAAM,oBAAA,GAAuB,mBAAA;AAC7B,IAAM,QAAA,GAAW,OAAA;AACjB,IAAM,WAAA,GAAc,UAAA;AACpB,IAAM,UAAA,GAAa,SAAA;AACnB,IAAM,W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,CAAA,eAAe,WAAA,CAAY,YAAA;AAAA,EAqCjC,MAAME,sBAAwB,aAAA,CAAiB;AAAA;AAA/C,EAAAF,SAAM,YAAA,GAAAE,aAAAA;AAAA,CAAA,EA5gBE,OAAA,KAAA,OAAA,GAAA,EAAA,CAAA,CAAA;;;ACRjB,IAAO,aAAA,GAAQ","file":"index.mjs","sourcesContent":["import type { Brand } from '../core';\n\n/**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\nexport const asBrand =\n <B extends Brand.Any>() =>\n <T>(value: T) =>\n value as Brand.Assign<B, T>;\n","import type { Identity } from '../core';\n\n/**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\nexport const asIdentity =\n <I extends Identity.Any>() =>\n <V>(value: V): Identity.Assign<I, V> =>\n value as any;\n","import type { Trait } from '../core';\n\n/**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\nexport const addTrait =\n <Tr extends Trait.Any>() =>\n <V>(value: V): Trait.Add<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\nexport const addTraits =\n <Tr extends Trait.Any[]>() =>\n <V>(value: V): Trait.AddMulti<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\nexport const dropTrait =\n <Tr extends Trait.Any>() =>\n <V>(value: V): Trait.Drop<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\nexport const dropTraits =\n <Tr extends Trait.Any[]>() =>\n <V>(value: V): Trait.DropMulti<Tr, V> =>\n value as any;\n","import type { Transformation } from '../core';\n\n/**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\nexport const applyTransformation =\n <Tr extends Transformation.Any>() =>\n <I, T>(input: I, transformed: T) =>\n transformed as Transformation.Apply<Tr, I, T>;\n\n/**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\nexport const revertTransformation =\n <Tr extends Transformation.Any>() =>\n <T, I>(transformed: T, input: I) =>\n input as Transformation.Revert<Tr, T, I>;\n","import { asBrand } from './brand';\nimport { asIdentity } from './identity';\nimport { addTrait, addTraits, dropTrait, dropTraits } from './trait';\nimport { applyTransformation, revertTransformation } from './transformation';\n\nconst _addTrait = addTrait;\nconst _addTraits = addTraits;\nconst _applyTransformation = applyTransformation;\nconst _asBrand = asBrand;\nconst _asIdentity = asIdentity;\nconst _dropTrait = dropTrait;\nconst _dropTraits = dropTraits;\nconst _revertTransformation = revertTransformation;\n\nexport namespace assertors {\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n}\n","/**\n * A fluent PhantomChain class for chaining Phantom assertors.\n *\n * This provides a better developer experience (DX) by allowing method chaining\n * with `.with(assertor)` instead of nesting function calls or using a variadic chain.\n * Each `.with()` applies the assertor to the current value, updating the type incrementally.\n * Call `.end()` to retrieve the final value.\n *\n * At runtime, assertors are zero-cost casts, so the PhantomChain adds minimal overhead\n * (just object creation and method calls).\n *\n * Example:\n * ```ts\n * const asMyBrand = Phantom.assertors.asBrand<MyBrand>();\n * const asMyTrait = Phantom.assertors.asTrait<MyTrait>();\n * const applyMyTransform = Phantom.assertors.applyTransformation<MyTransform>();\n *\n * const result = new PhantomChain(\"value\")\n * .with(asMyBrand)\n * .with(asMyTrait)\n * .with(applyMyTransform)\n * .end();\n * ```\n */\nexport class PhantomChain<T> {\n private value: T;\n\n constructor(value: T) {\n this.value = value;\n }\n\n /**\n * Apply the next assertor in the chain.\n *\n * @param assertor A function that takes the current value and returns the updated value (with new type).\n * @returns A new PhantomChain instance with the updated value and type.\n */\n with<U>(assertor: (value: T) => U): PhantomChain<U> {\n return new PhantomChain(assertor(this.value));\n }\n\n /**\n * End the chain and return the final value.\n *\n * @returns The value after all transformations.\n */\n end(): T {\n return this.value;\n }\n}\n","/**\n * Phantom meatadata object manipulators.\n *\n * Phantom matadata object holds all metadata used by 'phantom'.\n */\nexport namespace PhantomCore {\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = T extends {\n __Phantom: infer Phantom extends object;\n }\n ? Phantom\n : never;\n\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = T extends {\n __Phantom: { __OriginalType?: infer O };\n }\n ? Exclude<O, undefined>\n : T;\n\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = <T>(value: T): StripPhantom<T> => value as any;\n}\n","import {\n addTrait,\n addTraits,\n applyTransformation,\n asBrand,\n asIdentity,\n dropTrait,\n dropTraits,\n revertTransformation,\n} from './assertors';\nimport { PhantomChain } from './chain';\nimport type {\n BaseCore,\n InputCore,\n LabelCore,\n TagCore,\n TraitsCore,\n VariantsCore,\n BrandCore,\n IdentityCore,\n TraitCore,\n TransformationCore,\n ErrorType,\n} from './core';\nimport { PhantomCore } from './core';\n\nconst _addTrait = addTrait;\nconst _addTraits = addTraits;\nconst _applyTransformation = applyTransformation;\nconst _asBrand = asBrand;\nconst _asIdentity = asIdentity;\nconst _dropTrait = dropTrait;\nconst _dropTraits = dropTraits;\nconst _revertTransformation = revertTransformation;\nconst _PhantomChain = PhantomChain;\ntype _ErrorType<E> = ErrorType<E>;\n\nexport namespace Phantom {\n /** --------------------------------------\n * Types\n * --------------------------------------- */\n\n /**\n * Optional human-readable label metadata.\n *\n * Labels are descriptive only and do not affect identity.\n */\n export namespace Label {\n /** Marker type for labeled values */\n export type Any = LabelCore.Any;\n /** Extract the label */\n export type LabelOf<T> = LabelCore.LabelOf<T>;\n /** Check whether a label exists */\n export type HasLabel<T, L extends string = string> = LabelCore.HasLabel<\n T,\n L\n >;\n }\n\n /**\n * Nominal tag metadata.\n *\n * Tags uniquely identify a branded or identified type.\n * A value may only have a single tag.\n */\n export namespace Tag {\n /** Marker type for any tagged value */\n export type Any = TagCore.Any;\n /** Extract the tag from a type */\n export type TagOf<T> = TagCore.TagOf<T>;\n /** Check whether a type is tagged */\n export type HasTag<\n T,\n Ta extends string | symbol = string | symbol,\n > = TagCore.HasTag<T, Ta>;\n }\n\n /**\n * Variant metadata.\n *\n * Variants represent mutually exclusive states of a type.\n */\n export namespace Variants {\n /** Marker type for variant-bearing values */\n export type Any = VariantsCore.Any;\n /** Extract variant union */\n export type VariantsOf<T> = VariantsCore.VariantsOf<T>;\n /** Check whether variants exist */\n export type HasVariants<T> = VariantsCore.HasVariants<T>;\n }\n\n /**\n * Base-type metadata.\n *\n * Used to constrain which runtime types a brand, identity,\n * or transformation may be applied to.\n */\n export namespace Base {\n /** Marker type for base constraints */\n export type Any = BaseCore.Any;\n /** Extract the base type */\n export type BaseOf<T> = BaseCore.BaseOf<T>;\n /** Check whether a base constraint exists */\n export type HasBase<T, B = unknown> = BaseCore.HasBase<T, B>;\n }\n\n /**\n * Input metadata.\n *\n * Utilities for attaching and querying input metadata in transformations.\n */\n export namespace Input {\n /** Marker type for input value */\n export type Any = InputCore.Any;\n /** Extract the input */\n export type InputOf<T> = InputCore.InputOf<T>;\n /** Check whether an input exists */\n export type HasInput<T, I = unknown> = InputCore.HasInput<T, I>;\n }\n\n /**\n * Trait metadata.\n *\n * Traits behave like a set of capabilities that can be\n * added or removed independently.\n */\n export namespace Traits {\n /** Marker type for trait-bearing values */\n export type Any = TraitsCore.Any;\n /** Extract the trait map */\n export type TraitsOf<T> = TraitsCore.TraitsOf<T>;\n /** Extract trait keys */\n export type TraitKeysOf<T> = TraitsCore.TraitKeysOf<T>;\n /** Check if any traits exist */\n export type HasTraits<\n T,\n Tr extends string | symbol = string | symbol,\n > = TraitsCore.HasTraits<T, Tr>;\n }\n\n /**\n * Branding API.\n *\n * Brands provide nominal typing for otherwise identical values.\n * A value may only be branded once.\n */\n export namespace Brand {\n /** Type guard for any brand. */\n export type Any = BrandCore.Any;\n /** Declare a brand */\n export type Declare<\n T extends string | symbol,\n L extends string = never,\n > = BrandCore.Declare<T, L>;\n /** Assign a brand to a value. Fails if the value is already branded */\n export type Assign<B extends Any, T> = BrandCore.Assign<B, T>;\n /** Assign a brand if possible, otherwise return the original type */\n export type AssignSafe<B extends Any, T> = BrandCore.AssignSafe<B, T>;\n /** Check whether value is branded with */\n export type isBrand<T, B extends Brand.Any> = BrandCore.isBrand<T, B>;\n }\n\n /**\n * Identity API.\n *\n * Identities are brands with additional constraints:\n * - Base type\n * - Variants\n */\n export namespace Identity {\n /** Type guard for any identity. */\n export type Any = IdentityCore.Any;\n /** Declare an identity */\n export type Declare<\n T extends string | symbol,\n L extends string = never,\n B extends unknown = never,\n V extends string = never,\n > = IdentityCore.Declare<T, L, B, V>;\n /** Assign an identity to a value. Enforces base-type compatibility */\n export type Assign<I extends Any, T> = IdentityCore.Assign<I, T>;\n /** Safe identity assignment */\n export type AssignSafe<I extends Any, T> = IdentityCore.AssignSafe<I, T>;\n /** Set the active variant on an identity */\n export type WithVariant<\n I extends Any,\n V extends Variants.VariantsOf<I>,\n > = IdentityCore.WithVariant<I, V>;\n /** Set the active variant on a value */\n export type WithTypeVariant<\n T,\n V extends Variants.VariantsOf<T>,\n > = IdentityCore.WithTypeVariant<T, V>;\n /** Check whether value is branded with */\n export type isIdentity<T, I extends Any> = IdentityCore.isIdentity<T, I>;\n }\n\n /**\n * Trait API.\n *\n * Traits are additive capabilities that can be attached\n * or removed independently.\n */\n export namespace Trait {\n /** Type guard for any trait. */\n export type Any = TraitCore.Any;\n /** Declare a trait */\n export type Declare<Tr extends string | symbol> = TraitCore.Declare<Tr>;\n /** Add a trait */\n export type Add<Tr extends Any, T> = TraitCore.Add<Tr, T>;\n /** Add multiple traits */\n export type AddMulti<Tr extends readonly Any[], T> = TraitCore.AddMulti<\n Tr,\n T\n >;\n /** Remove a trait */\n export type Drop<Tr extends Any, T> = TraitCore.Drop<Tr, T>;\n /** Remove multiple traits */\n export type DropMulti<Tr extends readonly Any[], T> = TraitCore.DropMulti<\n Tr,\n T\n >;\n /** Check whether value has trait */\n export type HasTrait<T, Tr extends Any> = TraitCore.HasTrait<T, Tr>;\n }\n\n /**\n * Transformation API.\n *\n * Transformations represent reversible operations that\n * change the shape of a value while preserving its origin.\n */\n export namespace Transformation {\n /** Type guard for any transformation. */\n export type Any = TransformationCore.Any;\n /** Declare a transformation */\n export type Declare<\n I,\n T extends string | symbol,\n L extends string = never,\n B extends unknown = never,\n V extends string = never,\n > = TransformationCore.Declare<I, T, L, B, V>;\n /** Apply a transformation to a value. Enforces base-type compatibility */\n export type Apply<Tr extends Any, I, T> = TransformationCore.Apply<\n Tr,\n I,\n T\n >;\n /** Revert a transformation */\n export type Revert<Tr extends Any, T, I> = TransformationCore.Revert<\n Tr,\n T,\n I\n >;\n /** Revert a transformation whatever transformation was */\n export type RevertAny<T, I> = TransformationCore.RevertAny<T, I>;\n /** Check whether value is transformed with */\n export type isTransformed<\n T,\n Tr extends Any,\n > = TransformationCore.isTransformed<T, Tr>;\n }\n\n /**\n * Inspect API.\n *\n * Inspection helpers of phantom types.\n */\n export namespace Inspect {\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = PhantomCore.PhantomOf<T>;\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = PhantomCore.StripPhantom<T>;\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = PhantomCore.stripPhantom;\n /** Extract the label */\n export type LabelOf<T> = LabelCore.LabelOf<T>;\n /** Check whether a base constraint exists */\n export type HasLabel<T, L extends string = string> = LabelCore.HasLabel<\n T,\n L\n >;\n /** Extract the tag from a type */\n export type TagOf<T> = TagCore.TagOf<T>;\n /** Check whether a type is tagged */\n export type HasTag<\n T,\n Ta extends string | symbol = string | symbol,\n > = TagCore.HasTag<T, Ta>;\n /** Extract variant union */\n export type VariantsOf<T> = VariantsCore.VariantsOf<T>;\n /** Check whether variants exist */\n export type HasVariants<T> = VariantsCore.HasVariants<T>;\n /** Extract the base type */\n export type BaseOf<T> = BaseCore.BaseOf<T>;\n /** Check whether a base constraint exists */\n export type HasBase<T, B = unknown> = BaseCore.HasBase<T, B>;\n /** Extract the input */\n export type InputOf<T> = InputCore.InputOf<T>;\n /** Check whether an input exists */\n export type HasInput<T, I = unknown> = InputCore.HasInput<T, I>;\n /** Extract the trait map */\n export type TraitsOf<T> = TraitsCore.TraitsOf<T>;\n /** Extract trait keys */\n export type TraitKeysOf<T> = TraitsCore.TraitKeysOf<T>;\n /** Check if any traits exist */\n export type HasTraits<\n T,\n Tr extends string | symbol = string | symbol,\n > = TraitsCore.HasTraits<T, Tr>;\n /** Check whether value is branded with */\n export type isBrand<T, B extends Brand.Any> = BrandCore.isBrand<T, B>;\n /** Check whether value is branded with */\n export type isIdentity<T, I extends Identity.Any> = IdentityCore.isIdentity<\n T,\n I\n >;\n /** Check whether value has trait */\n export type HasTrait<T, Tr extends Trait.Any> = TraitCore.HasTrait<T, Tr>;\n /** Check whether value is transformed with */\n export type isTransformed<\n T,\n Tr extends Transformation.Any,\n > = TransformationCore.isTransformed<T, Tr>;\n }\n\n /** --------------------------------------\n * assertors\n * --------------------------------------- */\n\n export namespace assertors {\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n }\n\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n\n /** --------------------------------------\n * Phantom object manipulators\n * --------------------------------------- */\n\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = PhantomCore.PhantomOf<T>;\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = PhantomCore.StripPhantom<T>;\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = PhantomCore.stripPhantom;\n\n /** --------------------------------------\n * Error type\n * --------------------------------------- */\n\n /** Unique Error type for rules validation in phantom. */\n export type ErrorType<E> = _ErrorType<E>;\n\n /** --------------------------------------\n * Chain class\n * --------------------------------------- */\n\n /**\n * A fluent PhantomChain class for chaining Phantom assertors.\n *\n * This provides a better developer experience (DX) by allowing method chaining\n * with `.with(assertor)` instead of nesting function calls or using a variadic chain.\n * Each `.with()` applies the assertor to the current value, updating the type incrementally.\n * Call `.end()` to retrieve the final value.\n *\n * At runtime, assertors are zero-cost casts, so the PhantomChain adds minimal overhead\n * (just object creation and method calls).\n *\n * Example:\n * ```ts\n * const asMyBrand = Phantom.assertors.asBrand<MyBrand>();\n * const asMyTrait = Phantom.assertors.asTrait<MyTrait>();\n * const applyMyTransform = Phantom.assertors.applyTransformation<MyTransform>();\n *\n * const result = new PhantomChain(\"value\")\n * .with(asMyBrand)\n * .with(asMyTrait)\n * .with(applyMyTransform)\n * .end();\n * ```\n */\n export class PhantomChain<T> extends _PhantomChain<T> {}\n}\n","export {\n assertors,\n addTrait,\n addTraits,\n applyTransformation,\n asBrand,\n asIdentity,\n dropTrait,\n dropTraits,\n revertTransformation,\n} from './assertors';\nexport { PhantomChain } from './chain';\nexport { Phantom } from './phantom';\nexport type {\n Base,\n Brand,\n ErrorType,\n Identity,\n Input,\n Inspect,\n Label,\n PhantomCore,\n Tag,\n Trait,\n Traits,\n Transformation,\n Variants,\n} from './core';\nimport { Phantom } from './phantom';\nexport default Phantom;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/assertors/brand.ts","../src/assertors/identity.ts","../src/assertors/trait.ts","../src/assertors/transformation.ts","../src/assertors/assertors.ts","../src/chain/chain.ts","../src/core/phantom.ts","../src/phantom.ts","../src/index.ts"],"names":["assertors","_PhantomChain","PhantomCore","_addTrait","_addTraits","_applyTransformation","_asBrand","_asIdentity","_dropTrait","_dropTraits","_revertTransformation","Phantom","Inspect","PhantomChain"],"mappings":";;;;;AAcO,IAAM,OAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACLG,IAAM,UAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACLG,IAAM,QAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,SAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,SAAA,GACX,MACA,CAAI,KAAA,KACF;AAUG,IAAM,UAAA,GACX,MACA,CAAI,KAAA,KACF;;;ACvCG,IAAM,mBAAA,GACX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A,OAAA,GAAUL,SAAAA;AAYhB,EAAMK,SAAA,UAAA,GAAaJ,YAAAA;AAUnB,EAAMI,SAAA,QAAA,GAAWR,UAAAA;AAUjB,EAAMQ,SAAA,SAAA,GAAYP,WAAAA;AAUlB,EAAMO,SAAA,SAAA,GAAYH,WAAAA;AAUlB,EAAMG,SAAA,UAAA,GAAaF,YAAAA;AAanB,EAAME,SAAA,mBAAA,GAAsBN,qBAAAA;AAc5B,EAAMM,SAAA,oBAAA,GAAuBD,sBAAAA;AAW7B,EAAMC,QAAAA,CAAA,eAAe,WAAA,CAAY,YAAA;AAAA,EAqCjC,MAAME,sBAAwB,aAAA,CAAiB;AAAA;AAA/C,EAAAF,SAAM,YAAA,GAAAE,aAAAA;AAAA,CAAA,EAthBE,OAAA,KAAA,OAAA,GAAA,EAAA,CAAA,CAAA;;;ACRjB,IAAO,aAAA,GAAQ","file":"index.mjs","sourcesContent":["import type { Brand } from '../core';\n\n/**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @deprecated To unify Api surface 'asIdentity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\nexport const asBrand =\n <B extends Brand.Any>() =>\n <T>(value: T) =>\n value as Brand.Assign<B, T>;\n","import type { Identity } from '../core';\n\n/**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\nexport const asIdentity =\n <I extends Identity.Any>() =>\n <V>(value: V): Identity.Assign<I, V> =>\n value as any;\n","import type { Trait } from '../core';\n\n/**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\nexport const addTrait =\n <Tr extends Trait.Any>() =>\n <V>(value: V): Trait.Add<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\nexport const addTraits =\n <Tr extends Trait.Any[]>() =>\n <V>(value: V): Trait.AddMulti<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\nexport const dropTrait =\n <Tr extends Trait.Any>() =>\n <V>(value: V): Trait.Drop<Tr, V> =>\n value as any;\n\n/**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\nexport const dropTraits =\n <Tr extends Trait.Any[]>() =>\n <V>(value: V): Trait.DropMulti<Tr, V> =>\n value as any;\n","import type { Transformation } from '../core';\n\n/**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\nexport const applyTransformation =\n <Tr extends Transformation.Any>() =>\n <I, T>(input: I, transformed: T) =>\n transformed as Transformation.Apply<Tr, I, T>;\n\n/**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\nexport const revertTransformation =\n <Tr extends Transformation.Any>() =>\n <T, I>(transformed: T, input: I) =>\n input as Transformation.Revert<Tr, T, I>;\n","import { asBrand } from './brand';\nimport { asIdentity } from './identity';\nimport { addTrait, addTraits, dropTrait, dropTraits } from './trait';\nimport { applyTransformation, revertTransformation } from './transformation';\n\nconst _addTrait = addTrait;\nconst _addTraits = addTraits;\nconst _applyTransformation = applyTransformation;\nconst _asBrand = asBrand;\nconst _asIdentity = asIdentity;\nconst _dropTrait = dropTrait;\nconst _dropTraits = dropTraits;\nconst _revertTransformation = revertTransformation;\n\nexport namespace assertors {\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @deprecated To unify Api surface 'asIdentity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n}\n","/**\n * A fluent PhantomChain class for chaining Phantom assertors.\n *\n * This provides a better developer experience (DX) by allowing method chaining\n * with `.with(assertor)` instead of nesting function calls or using a variadic chain.\n * Each `.with()` applies the assertor to the current value, updating the type incrementally.\n * Call `.end()` to retrieve the final value.\n *\n * At runtime, assertors are zero-cost casts, so the PhantomChain adds minimal overhead\n * (just object creation and method calls).\n *\n * Example:\n * ```ts\n * const asMyBrand = Phantom.assertors.asBrand<MyBrand>();\n * const asMyTrait = Phantom.assertors.asTrait<MyTrait>();\n * const applyMyTransform = Phantom.assertors.applyTransformation<MyTransform>();\n *\n * const result = new PhantomChain(\"value\")\n * .with(asMyBrand)\n * .with(asMyTrait)\n * .with(applyMyTransform)\n * .end();\n * ```\n */\nexport class PhantomChain<T> {\n private value: T;\n\n constructor(value: T) {\n this.value = value;\n }\n\n /**\n * Apply the next assertor in the chain.\n *\n * @param assertor A function that takes the current value and returns the updated value (with new type).\n * @returns A new PhantomChain instance with the updated value and type.\n */\n with<U>(assertor: (value: T) => U): PhantomChain<U> {\n return new PhantomChain(assertor(this.value));\n }\n\n /**\n * End the chain and return the final value.\n *\n * @returns The value after all transformations.\n */\n end(): T {\n return this.value;\n }\n}\n","/** Stip phantom metadata object from a type */\ntype StripPhantom<T> = T extends {\n __Phantom: { __OriginalType?: infer O }; // If type result from ( .Assign / .Add / .Apply )\n}\n ? Exclude<O, undefined>\n : T extends {\n __Phantom: { __Base?: infer B }; // If type result from ( Identity.Declare / Transformation.Declare )\n }\n ? Exclude<B, undefined>\n : T extends { __Phantom: object } // If type result from ( Trait.Declare )\n ? unknown\n : T;\n\n/** run-time helper for 'StringPhantom', used for debugging mainly */\nexport const stripPhantom = <T>(value: T): StripPhantom<T> => value as any;\n\n// Avoid bundler bugs\ntype _StripPhantom<T> = StripPhantom<T>;\nconst _stripPhantom = stripPhantom;\n\n/**\n * Phantom meatadata object manipulators.\n *\n * Phantom matadata object holds all metadata used by 'phantom'.\n */\nexport namespace PhantomCore {\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = T extends {\n __Phantom: infer Phantom extends object;\n }\n ? Phantom\n : never;\n\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = _StripPhantom<T>;\n\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = _stripPhantom;\n}\n","import {\n addTrait,\n addTraits,\n applyTransformation,\n asBrand,\n asIdentity,\n dropTrait,\n dropTraits,\n revertTransformation,\n} from './assertors';\nimport { PhantomChain } from './chain';\nimport type {\n BaseCore,\n InputCore,\n LabelCore,\n TagCore,\n TraitsCore,\n VariantsCore,\n BrandCore,\n IdentityCore,\n TraitCore,\n TransformationCore,\n ErrorType,\n} from './core';\nimport { PhantomCore } from './core';\n\nconst _addTrait = addTrait;\nconst _addTraits = addTraits;\nconst _applyTransformation = applyTransformation;\nconst _asBrand = asBrand;\nconst _asIdentity = asIdentity;\nconst _dropTrait = dropTrait;\nconst _dropTraits = dropTraits;\nconst _revertTransformation = revertTransformation;\nconst _PhantomChain = PhantomChain;\ntype _ErrorType<E> = ErrorType<E>;\n\nexport namespace Phantom {\n /** --------------------------------------\n * Types\n * --------------------------------------- */\n\n /**\n * Optional human-readable label metadata.\n *\n * Labels are descriptive only and do not affect identity.\n */\n export namespace Label {\n /** Marker type for labeled values */\n export type Any = LabelCore.Any;\n /** Extract the label */\n export type LabelOf<T> = LabelCore.LabelOf<T>;\n /** Check whether a label exists */\n export type HasLabel<T, L extends string = string> = LabelCore.HasLabel<\n T,\n L\n >;\n }\n\n /**\n * Nominal tag metadata.\n *\n * Tags uniquely identify a branded or identified type.\n * A value may only have a single tag.\n */\n export namespace Tag {\n /** Marker type for any tagged value */\n export type Any = TagCore.Any;\n /** Extract the tag from a type */\n export type TagOf<T> = TagCore.TagOf<T>;\n /** Check whether a type is tagged */\n export type HasTag<\n T,\n Ta extends string | symbol = string | symbol,\n > = TagCore.HasTag<T, Ta>;\n }\n\n /**\n * Variant metadata.\n *\n * Variants represent mutually exclusive states of a type.\n */\n export namespace Variants {\n /** Marker type for variant-bearing values */\n export type Any = VariantsCore.Any;\n /** Extract variant union */\n export type VariantsOf<T> = VariantsCore.VariantsOf<T>;\n /** Check whether variants exist */\n export type HasVariants<T> = VariantsCore.HasVariants<T>;\n }\n\n /**\n * Base-type metadata.\n *\n * Used to constrain which runtime types a brand, identity,\n * or transformation may be applied to.\n */\n export namespace Base {\n /** Marker type for base constraints */\n export type Any = BaseCore.Any;\n /** Extract the base type */\n export type BaseOf<T> = BaseCore.BaseOf<T>;\n /** Check whether a base constraint exists */\n export type HasBase<T, B = unknown> = BaseCore.HasBase<T, B>;\n }\n\n /**\n * Input metadata.\n *\n * Utilities for attaching and querying input metadata in transformations.\n */\n export namespace Input {\n /** Marker type for input value */\n export type Any = InputCore.Any;\n /** Extract the input */\n export type InputOf<T> = InputCore.InputOf<T>;\n /** Check whether an input exists */\n export type HasInput<T, I = unknown> = InputCore.HasInput<T, I>;\n }\n\n /**\n * Trait metadata.\n *\n * Traits behave like a set of capabilities that can be\n * added or removed independently.\n */\n export namespace Traits {\n /** Marker type for trait-bearing values */\n export type Any = TraitsCore.Any;\n /** Extract the trait map */\n export type TraitsOf<T> = TraitsCore.TraitsOf<T>;\n /** Extract trait keys */\n export type TraitKeysOf<T> = TraitsCore.TraitKeysOf<T>;\n /** Check if any traits exist */\n export type HasTraits<\n T,\n Tr extends string | symbol = string | symbol,\n > = TraitsCore.HasTraits<T, Tr>;\n }\n\n /**\n * Branding API.\n *\n * Brands provide nominal typing for otherwise identical values.\n * A value may only be branded once.\n *\n * @deprecated To unify Api surface 'Identity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n */\n export namespace Brand {\n /** Type guard for any brand. */\n export type Any = BrandCore.Any;\n /** Declare a brand */\n export type Declare<\n T extends string | symbol,\n L extends string = never,\n > = BrandCore.Declare<T, L>;\n /** Assign a brand to a value. Fails if the value is already branded */\n export type Assign<B extends Any, T> = BrandCore.Assign<B, T>;\n /** Assign a brand if possible, otherwise return the original type */\n export type AssignSafe<B extends Any, T> = BrandCore.AssignSafe<B, T>;\n /** Check whether value is branded with */\n export type isBrand<T, B extends Brand.Any> = BrandCore.isBrand<T, B>;\n }\n\n /**\n * Identity API.\n *\n * Identities are brands with additional constraints:\n * - Base type\n * - Variants\n */\n export namespace Identity {\n /** Type guard for any identity. */\n export type Any = IdentityCore.Any;\n /** Declare an identity */\n export type Declare<\n T extends string | symbol,\n L extends string = never,\n B extends unknown = never,\n V extends string = never,\n > = IdentityCore.Declare<T, L, B, V>;\n /** Assign an identity to a value. Enforces base-type compatibility */\n export type Assign<I extends Any, T> = IdentityCore.Assign<I, T>;\n /** Safe identity assignment */\n export type AssignSafe<I extends Any, T> = IdentityCore.AssignSafe<I, T>;\n /** Set the active variant on an identity */\n export type WithVariant<\n I extends Any,\n V extends Variants.VariantsOf<I>,\n > = IdentityCore.WithVariant<I, V>;\n /** Set the active variant on a value */\n export type WithTypeVariant<\n T,\n V extends Variants.VariantsOf<T>,\n > = IdentityCore.WithTypeVariant<T, V>;\n /** Check whether value is branded with */\n export type isIdentity<T, I extends Any> = IdentityCore.isIdentity<T, I>;\n }\n\n /**\n * Trait API.\n *\n * Traits are additive capabilities that can be attached\n * or removed independently.\n */\n export namespace Trait {\n /** Type guard for any trait. */\n export type Any = TraitCore.Any;\n /** Declare a trait */\n export type Declare<Tr extends string | symbol> = TraitCore.Declare<Tr>;\n /** Add a trait */\n export type Add<Tr extends Any, T> = TraitCore.Add<Tr, T>;\n /** Add multiple traits */\n export type AddMulti<Tr extends readonly Any[], T> = TraitCore.AddMulti<\n Tr,\n T\n >;\n /** Remove a trait */\n export type Drop<Tr extends Any, T> = TraitCore.Drop<Tr, T>;\n /** Remove multiple traits */\n export type DropMulti<Tr extends readonly Any[], T> = TraitCore.DropMulti<\n Tr,\n T\n >;\n /** Check whether value has trait */\n export type HasTrait<T, Tr extends Any> = TraitCore.HasTrait<T, Tr>;\n }\n\n /**\n * Transformation API.\n *\n * Transformations represent reversible operations that\n * change the shape of a value while preserving its origin.\n */\n export namespace Transformation {\n /** Type guard for any transformation. */\n export type Any = TransformationCore.Any;\n /** Declare a transformation */\n export type Declare<\n I,\n T extends string | symbol,\n L extends string = never,\n B extends unknown = never,\n V extends string = never,\n > = TransformationCore.Declare<I, T, L, B, V>;\n /** Apply a transformation to a value. Enforces base-type compatibility */\n export type Apply<Tr extends Any, I, T> = TransformationCore.Apply<\n Tr,\n I,\n T\n >;\n /** Revert a transformation */\n export type Revert<Tr extends Any, T, I> = TransformationCore.Revert<\n Tr,\n T,\n I\n >;\n /** Revert a transformation whatever transformation was */\n export type RevertAny<T, I> = TransformationCore.RevertAny<T, I>;\n /** Check whether value is transformed with */\n export type isTransformed<\n T,\n Tr extends Any,\n > = TransformationCore.isTransformed<T, Tr>;\n }\n\n /**\n * Inspect API.\n *\n * Inspection helpers of phantom types.\n */\n export namespace Inspect {\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = PhantomCore.PhantomOf<T>;\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = PhantomCore.StripPhantom<T>;\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = PhantomCore.stripPhantom;\n /** Extract the label */\n export type LabelOf<T> = LabelCore.LabelOf<T>;\n /** Check whether a base constraint exists */\n export type HasLabel<T, L extends string = string> = LabelCore.HasLabel<\n T,\n L\n >;\n /** Extract the tag from a type */\n export type TagOf<T> = TagCore.TagOf<T>;\n /** Check whether a type is tagged */\n export type HasTag<\n T,\n Ta extends string | symbol = string | symbol,\n > = TagCore.HasTag<T, Ta>;\n /** Extract variant union */\n export type VariantsOf<T> = VariantsCore.VariantsOf<T>;\n /** Check whether variants exist */\n export type HasVariants<T> = VariantsCore.HasVariants<T>;\n /** Extract the base type */\n export type BaseOf<T> = BaseCore.BaseOf<T>;\n /** Check whether a base constraint exists */\n export type HasBase<T, B = unknown> = BaseCore.HasBase<T, B>;\n /** Extract the input */\n export type InputOf<T> = InputCore.InputOf<T>;\n /** Check whether an input exists */\n export type HasInput<T, I = unknown> = InputCore.HasInput<T, I>;\n /** Extract the trait map */\n export type TraitsOf<T> = TraitsCore.TraitsOf<T>;\n /** Extract trait keys */\n export type TraitKeysOf<T> = TraitsCore.TraitKeysOf<T>;\n /** Check if any traits exist */\n export type HasTraits<\n T,\n Tr extends string | symbol = string | symbol,\n > = TraitsCore.HasTraits<T, Tr>;\n /**\n * Check whether value is branded with\n *\n * @deprecated To unify Api surface 'isIdentity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n */\n export type isBrand<T, B extends Brand.Any> = BrandCore.isBrand<T, B>;\n /** Check whether value is branded with */\n export type isIdentity<T, I extends Identity.Any> = IdentityCore.isIdentity<\n T,\n I\n >;\n /** Check whether value has trait */\n export type HasTrait<T, Tr extends Trait.Any> = TraitCore.HasTrait<T, Tr>;\n /** Check whether value is transformed with */\n export type isTransformed<\n T,\n Tr extends Transformation.Any,\n > = TransformationCore.isTransformed<T, Tr>;\n }\n\n /** --------------------------------------\n * assertors\n * --------------------------------------- */\n\n export namespace assertors {\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @deprecated To unify Api surface 'asIdentity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n }\n\n /**\n * Creates a typed caster that assigns a {@link Brand} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the brand's nominal type applied. Use it for simple branded primitives\n * where you know the value is valid.\n *\n * @deprecated To unify Api surface 'asIdentity' should be used instea, will be removed in v2.0.0. for more info check 'https://www.npmjs.com/package/@vicin/phantom#deprecated-api'\n *\n * @template B - The brand declaration to assign.\n * @returns A function that casts any value to the branded type.\n */\n export const asBrand = _asBrand;\n\n /**\n * Creates a typed caster that assigns an {@link Identity} to a value.\n *\n * This is a zero-cost runtime assertion helper — it simply returns the value\n * with the identity's nominal type applied. Use it when you know a value\n * conforms to an identity but need to assert it for the type system.\n *\n * @template I - The identity declaration to assign.\n * @returns A function that casts any value to the assigned identity type.\n */\n export const asIdentity = _asIdentity;\n\n /**\n * Creates a typed caster that adds a single {@link Trait} to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to add.\n * @returns A function that adds the trait to any value.\n */\n export const addTrait = _addTrait;\n\n /**\n * Creates a typed caster that adds multiple {@link Trait}s to a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to add.\n * @returns A function that adds all traits to any value.\n */\n export const addTraits = _addTraits;\n\n /**\n * Creates a typed caster that removes a single {@link Trait} from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The trait declaration to remove.\n * @returns A function that drops the trait from any value.\n */\n export const dropTrait = _dropTrait;\n\n /**\n * Creates a typed caster that removes multiple {@link Trait}s from a value.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - Tuple of trait declarations to remove.\n * @returns A function that drops all specified traits from any value.\n */\n export const dropTraits = _dropTraits;\n\n /**\n * Creates a typed applicator for a {@link Transformation}.\n *\n * Use this for \"forward\" operations (e.g., encrypt, encode, wrap).\n * The `input` parameter is only used for type inference — it is not used at runtime.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that applies the transformation while preserving the input type for later revert.\n */\n export const applyTransformation = _applyTransformation;\n\n /**\n * Creates a typed reverter for a {@link Transformation}.\n *\n * Use this for \"reverse\" operations (e.g., decrypt, decode, unwrap).\n * The `transformed` parameter is used for type inference of the expected input,\n * and `input` is the computed result that must match the stored input type.\n *\n * Zero-runtime-cost assertion helper.\n *\n * @template Tr - The transformation declaration.\n * @returns A function that reverts the transformation, stripping phantom metadata.\n */\n export const revertTransformation = _revertTransformation;\n\n /** --------------------------------------\n * Phantom object manipulators\n * --------------------------------------- */\n\n /** Get phantom metadata object from a type */\n export type PhantomOf<T> = PhantomCore.PhantomOf<T>;\n /** Stip phantom metadata object from a type */\n export type StripPhantom<T> = PhantomCore.StripPhantom<T>;\n /** run-time helper for 'StringPhantom', used for debugging mainly */\n export const stripPhantom = PhantomCore.stripPhantom;\n\n /** --------------------------------------\n * Error type\n * --------------------------------------- */\n\n /** Unique Error type for rules validation in phantom. */\n export type ErrorType<E> = _ErrorType<E>;\n\n /** --------------------------------------\n * Chain class\n * --------------------------------------- */\n\n /**\n * A fluent PhantomChain class for chaining Phantom assertors.\n *\n * This provides a better developer experience (DX) by allowing method chaining\n * with `.with(assertor)` instead of nesting function calls or using a variadic chain.\n * Each `.with()` applies the assertor to the current value, updating the type incrementally.\n * Call `.end()` to retrieve the final value.\n *\n * At runtime, assertors are zero-cost casts, so the PhantomChain adds minimal overhead\n * (just object creation and method calls).\n *\n * Example:\n * ```ts\n * const asMyBrand = Phantom.assertors.asBrand<MyBrand>();\n * const asMyTrait = Phantom.assertors.asTrait<MyTrait>();\n * const applyMyTransform = Phantom.assertors.applyTransformation<MyTransform>();\n *\n * const result = new PhantomChain(\"value\")\n * .with(asMyBrand)\n * .with(asMyTrait)\n * .with(applyMyTransform)\n * .end();\n * ```\n */\n export class PhantomChain<T> extends _PhantomChain<T> {}\n}\n","export {\n assertors,\n addTrait,\n addTraits,\n applyTransformation,\n asBrand,\n asIdentity,\n dropTrait,\n dropTraits,\n revertTransformation,\n} from './assertors';\nexport { PhantomChain } from './chain';\nexport { Phantom } from './phantom';\nexport type {\n Base,\n Brand,\n ErrorType,\n Identity,\n Input,\n Inspect,\n Label,\n Tag,\n Trait,\n Traits,\n Transformation,\n Variants,\n} from './core';\nexport { PhantomCore, stripPhantom } from './core';\nimport { Phantom } from './phantom';\nexport default Phantom;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vicin/phantom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Powerful, lightweight TypeScript library for nominal typing.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,7 +38,20 @@
|
|
|
38
38
|
"keywords": [
|
|
39
39
|
"typescript",
|
|
40
40
|
"nominal-typing",
|
|
41
|
-
"ddd"
|
|
41
|
+
"ddd",
|
|
42
|
+
"domain-driven-design",
|
|
43
|
+
"branding",
|
|
44
|
+
"branded-types",
|
|
45
|
+
"type-safety",
|
|
46
|
+
"metadata",
|
|
47
|
+
"type-metadata",
|
|
48
|
+
"identity",
|
|
49
|
+
"traits",
|
|
50
|
+
"type-transformations",
|
|
51
|
+
"state-variants",
|
|
52
|
+
"type-pipe",
|
|
53
|
+
"zero-runtime",
|
|
54
|
+
"type-only"
|
|
42
55
|
],
|
|
43
56
|
"author": "Ziad ziadtaha62@gmail.com",
|
|
44
57
|
"license": "MIT",
|