/** * Copyright (c) 2025-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type GeneratorFn, ActionState } from '@finos/legend-shared'; import { type CartItem, type CartItemRequest, type CartSummary, TerminalResult, type TraderProfile, type TraderProfileItem } from '@finos/legend-server-marketplace'; import type { LegendMarketplaceBaseStore } from '../LegendMarketplaceBaseStore.js'; declare enum BUSINESS_REASONS { NEW_HIRE = "New Hire", NEW_ROLE = "New Role", USER_MOVE = "User Move", TRANSFER = "Transfer", OTHER_REASON = "Other Reason" } export interface CartVendorGroup { vpId: number; parentItem: CartItem | undefined; displayParent: { providerName: string; productName: string; categoryLabel: string; monthlyPrice: number | undefined; }; addons: CartItem[]; groupItems: CartItem[]; isSynthetic: boolean; addonTotalPrice: number; addonLabel: string; } export interface AddOnAssociationResult { success: boolean; message: string; recommendations?: TerminalResult[]; totalCount?: number | null; shouldCloseModal: boolean; } interface AddOnCartRequestOptions { overridePermissionId?: number; overrideModel?: string | null; } export declare class CartStore { readonly baseStore: LegendMarketplaceBaseStore; items: Record; targetUser: string | undefined; businessReason: string | undefined; readonly initState: ActionState; readonly loadingState: ActionState; readonly submitState: ActionState; readonly associationState: ActionState; associatingItemId: number | undefined; open: boolean; cartSummary: CartSummary; constructor(baseStore: LegendMarketplaceBaseStore); private get currentUser(); get cartUser(): string; get cartItemIds(): Set; isParentCartItem(item: CartItem): boolean; getGroupAddOns(groupItems: CartItem[]): CartItem[]; get vendorGroups(): CartVendorGroup[]; get vendorGroupIds(): number[]; setOpen(val: boolean): void; setTargetUser(val: string | undefined): GeneratorFn; setBusinessReason(val: string | undefined): void; isItemInCart(itemId: number): boolean; /** * Returns the add-on items that depend on the given cart item. * When a Terminal is deleted, its associated add-ons (same vendor) must also be removed. */ getDependentAddOns(cartId: number): CartItem[]; addToCartWithAPI(cartItemData: CartItemRequest, suppressSuccessToast?: boolean): GeneratorFn<{ success: boolean; recommendations?: TerminalResult[]; message: string; totalCount?: number | null; }>; associateAddOnToTerminal(selectedTerminal: TerminalResult, options?: AddOnCartRequestOptions): GeneratorFn; /** * Returns true if there is a cart entry matching both the given item id and * model. This model-aware check prevents an add-on that was added for one * vendor-profile terminal from being incorrectly considered "in cart" for a * different terminal that shares the same add-on product id. */ isAddOnInCartForModel(itemId: number, model: string | null | undefined): boolean; /** * Resolves the vendorProfileId for an item. Uses the item's own * vendorProfileId if present; otherwise derives it from the parent terminal * for the item's model. */ private resolveVendorProfileId; /** * Resolves the effective permissionId for a non-terminal item. * Priority: item's own permissionId > owned terminal's permissionId for the * same model. */ private resolvePermissionId; /** * Builds the CartItemRequest payload for a single order-profile item. */ private buildOrderProfileCartPayload; /** * Adds a list of order-profile items to the cart, skipping already-owned ones. * Accepts both terminal and add-on items; terminals are processed first so the * server-side cart can establish the terminal entry before its add-ons arrive. * * Every non-owned add-on is submitted with its actual item id and category. * The effective permissionId for an add-on is determined as follows: * 1. The item's own permissionId (the entitlement already belongs to a known * permission). * 2. The parent owned terminal's permissionId when the add-on's model matches * an owned terminal that carries a permissionId. * No permissionId-based deduplication is performed — the same product may * legitimately need to be added under several different terminal models. * * Every add-on also carries a vendorProfileId derived from its parent terminal * (owned or not). This is required so the server can correctly group items * under the right vendor profile even when the parent terminal is already * subscribed. The vendorProfileId is the terminal's catalog id (item.id), * independent of ownership status. */ addOrderProfileItemsToCart(items: TraderProfileItem[], suppressSuccessToast?: boolean): GeneratorFn; /** * Returns true when all non-owned items of the profile are present in the * cart. For multiselect profiles, at least one complete terminal bundle * (terminal + its associated add-ons) must be fully in the cart. * * Add-on items are checked with a model-aware cart lookup so that the same * product id appearing under two different vendor-profile models is not * considered "in cart" until it has been explicitly added for each model. */ isOrderProfileInCart(profile: TraderProfile): boolean; providerToCartRequest(provider: TerminalResult): CartItemRequest; buildAddonCartRequest(provider: TerminalResult, options?: AddOnCartRequestOptions): CartItemRequest; initialize(): GeneratorFn; refresh(): GeneratorFn; submitOrder(): GeneratorFn; clearCart(): GeneratorFn; deleteCartItem(cartId: number, confirmDelete?: boolean): GeneratorFn; deleteCartItemsSequentially(cartIds: number[], successMessage?: string): GeneratorFn; private requestCartActionAlert; requestDeleteItemConfirmation(item: CartItem, vendorGroup: CartItem[]): void; requestDeleteGroupConfirmation(vendorGroup: CartItem[]): void; requestClearCartConfirmation(): void; static readonly BUSINESS_REASONS: typeof BUSINESS_REASONS; } export {}; //# sourceMappingURL=CartStore.d.ts.map