/** * Category ID. A type alias to keep various concepts delineated. */ export declare type CID = number; /** * Tensor ID. A type alias to keep various concepts delineated. */ export declare type TID = number; /** * Product ID. A type alias to keep various concepts delineated. Each generic * product such as `milkshakes` or `coffees` will have its own unique PID. */ export declare type PID = number; /** * Stock Keeping Unit. A type alias to keep various concepts delineated. Each * specific product such as `small strawberry` `milkshake` or `large decaf iced * coffee` will have its own unique SKU. */ export declare type SKU = number; /** * A type alias to keep various concepts delineated. * * Each specific product such as `small strawberry milkshake` or `large decaf` * `iced coffee` will have its own unique Key. The Key is a tensor where the * first dimesnion is a generic product's PID, and any other dimensions * determine which attributes are added. * * @example * short latte (302:0:0, 600) * tall latte (302:0:1, 601) * grande latte (302:0:2, 602) <== default * iced tall latte (302:1:1, 603) * iced grande latte (302:1:2, 604) * iced venti latte (302:1:3, 605) */ export declare type Key = string; export declare enum Role { ANY = "any", APPLIED = "applied", COUNTED = "counted", MEASURED = "measured" } export interface FuzzerHints { role: Role; units: string; } /** * A catch-all type. */ export interface Entity { name: string; } /** * A generic product is a top-level item that can be combined with a set of * attributes to form a specific product. For example, a `latte` is a generic * product that must be configured with a size and iced vs hot to produce a * specific product like a `small iced latte`. */ export interface GenericEntity extends Entity { pid: PID; cid: CID; aliases: string[]; tensor: TID; defaultKey: Key; fuzzerHints: FuzzerHints; } /** * The interface for specific products like `large chocolate milkshake no` * `whipped cream` or `small coffee`. */ export interface SpecificEntity extends Entity { sku: SKU; key: Key; } /** * TypedEntity provides polymorphic behavior for both Generic and Specific * entities. The intention here is for it to be used similar to a mixin. */ export declare type TypedEntity = MenuItem | Option; export declare type GenericTypedEntity = TypedEntity & GenericEntity; export declare type SpecificTypedEntity = TypedEntity & SpecificEntity; export declare const MENUITEM: unique symbol; export declare type MENUITEM = typeof MENUITEM; export declare const OPTION: unique symbol; export declare type OPTION = typeof OPTION; /** * Menu item includes food, drink, or any "top-level" item which acts as a * parent to other items (such as options). */ export interface MenuItem extends Entity { kind: MENUITEM; } /** * Options are items which attach to MenuItems and child items in the cart. An * example of an Option would be a sauce or a drizzle. */ export interface Option extends Entity { kind: OPTION; } export declare const genericEntityFactory: (entity: GenericEntity, kind: symbol) => GenericTypedEntity; export declare const specificEntityFactory: (entity: SpecificEntity, kind: symbol) => SpecificTypedEntity; export declare function entityTyper(entity: Entity, kind: symbol): TypedEntity; export interface ICatalog { hasPID(pid: PID): boolean; hasSKU(sku: SKU): boolean; getGeneric(pid: PID): GenericTypedEntity; getGenericForKey(key: Key): GenericTypedEntity; getGenericMap(): Map; genericEntities(): IterableIterator; hasKey(key: Key): boolean; getSpecific(key: Key): SpecificTypedEntity; getSpecificFromName(name: string): SpecificTypedEntity; getSpecificFromSKU(sku: string): SpecificTypedEntity; getSpecificsForGeneric(pid: PID): IterableIterator; specificEntities(): IterableIterator; }