@cimplify/sdk 0.6.4 → 0.6.6

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.
@@ -0,0 +1,38 @@
1
+ export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise, aV as AddOn, bE as AddOnDetails, b_ as AddOnGroupDetails, aX as AddOnOption, bZ as AddOnOptionDetails, aY as AddOnOptionPrice, aW as AddOnWithOptions, c3 as AddToCartInput, dN as AddressData, ed as AddressInfo, bt as AdjustmentType, ch as AmountToPay, bA as AppliedDiscount, dY as AuthResponse, A as AuthService, m as AuthStatus, ef as AuthenticatedCustomer, eh as AuthenticatedData, dB as AvailabilityCheck, dC as AvailabilityResult, di as AvailableSlot, bz as BenefitType, dl as Booking, dc as BookingRequirementOverride, dk as BookingStatus, dm as BookingWithDetails, cB as BufferTimes, b4 as Bundle, b8 as BundleComponentData, b9 as BundleComponentInfo, b3 as BundlePriceType, b6 as BundleProduct, bJ as BundleSelectionData, bH as BundleSelectionInput, bI as BundleStoredSelection, b5 as BundleSummary, b7 as BundleWithDetails, cQ as Business, d2 as BusinessHours, cP as BusinessPreferences, B as BusinessService, d1 as BusinessSettings, cO as BusinessType, c$ as BusinessWithLocations, a6 as CHECKOUT_MODE, aj as CHECKOUT_MUTATION, a9 as CHECKOUT_STEP, af as CONTACT_TYPE, dr as CancelBookingInput, cv as CancelOrderInput, cD as CancellationPolicy, bO as Cart, bF as CartAddOn, br as CartChannel, bP as CartItem, c0 as CartItemDetails, i as CartOperations, bq as CartStatus, c5 as CartSummary, bQ as CartTotals, b as CatalogueQueries, a_ as Category, d3 as CategoryInfo, a$ as CategorySummary, o as ChangePasswordInput, dp as CheckSlotAvailabilityInput, d$ as CheckoutAddressInfo, e1 as CheckoutCustomerInfo, X as CheckoutFormData, ct as CheckoutInput, J as CheckoutMode, j as CheckoutOperations, N as CheckoutOrderType, V as CheckoutPaymentMethod, Y as CheckoutResult, j as CheckoutService, a0 as CheckoutStatus, a1 as CheckoutStatusContext, W as CheckoutStep, by as ChosenPrice, C as CimplifyClient, a as CimplifyConfig, v as CimplifyElement, u as CimplifyElements, b0 as Collection, b2 as CollectionProduct, b1 as CollectionSummary, bf as ComponentGroup, bg as ComponentGroupWithComponents, bk as ComponentPriceBreakdown, bi as ComponentSelectionInput, bc as ComponentSourceType, bd as Composite, bh as CompositeComponent, bL as CompositePriceBreakdown, bj as CompositePriceResult, ba as CompositePricingMode, bM as CompositeSelectionData, bi as CompositeSelectionInput, bK as CompositeStoredSelection, be as CompositeWithDetails, a5 as ContactType, dJ as CreateAddressInput, dL as CreateMobileMoneyInput, dE as Customer, dF as CustomerAddress, dH as CustomerLinkPreferences, dG as CustomerMobileMoney, cA as CustomerServicePreferences, an as DEFAULT_COUNTRY, am as DEFAULT_CURRENCY, ae as DEVICE_TYPE, dj as DayAvailability, cK as DepositResult, aJ as DepositType, a4 as DeviceType, aI as DigitalProductType, bB as DiscountBreakdown, bC as DiscountDetails, bT as DisplayAddOn, bU as DisplayAddOnOption, bR as DisplayCart, bS as DisplayCartItem, x as ELEMENT_TYPES, E as EVENT_TYPES, ec as ElementAppearance, em as ElementEventHandler, H as ElementEventType, z as ElementOptions, D as ElementType, ei as ElementsCheckoutData, ej as ElementsCheckoutResult, eg as ElementsCustomerInfo, y as ElementsOptions, dP as EnrollAndLinkOrderInput, dS as EnrollAndLinkOrderResult, dM as EnrollmentData, aq as Err, cg as FeeBearerType, F as FetchQuoteInput, ce as FulfillmentLink, cd as FulfillmentStatus, cc as FulfillmentType, e3 as FxQuote, e2 as FxQuoteRequest, e4 as FxRateResponse, r as FxService, dn as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, bb as GroupPricingBehavior, el as IframeToParentMessage, I as InventoryService, dD as InventorySummary, aG as InventoryType, K as KitchenOrderItem, t as KitchenOrderResult, ah as LINK_MUTATION, ag as LINK_QUERY, bN as LineConfiguration, ci as LineItem, c9 as LineType, dI as LinkData, dR as LinkEnrollResult, L as LinkService, dT as LinkSession, dQ as LinkStatusResult, s as LiteBootstrap, q as LiteService, cT as Location, cN as LocationAppointment, bn as LocationProductPrice, dA as LocationStock, cR as LocationTaxBehavior, cS as LocationTaxOverrides, cW as LocationTimeProfile, d0 as LocationWithDetails, M as MESSAGE_TYPES, ac as MOBILE_MONEY_PROVIDER, dO as MobileMoneyData, e0 as MobileMoneyDetails, a3 as MobileMoneyProvider, al as ORDER_MUTATION, a7 as ORDER_TYPE, eb as ObservabilityHooks, ap as Ok, cj as Order, c8 as OrderChannel, cs as OrderFilter, cf as OrderFulfillmentSummary, cm as OrderGroup, cq as OrderGroupDetails, cn as OrderGroupPayment, cl as OrderGroupPaymentState, cp as OrderGroupPaymentSummary, ck as OrderHistory, ca as OrderLineState, cb as OrderLineStatus, cr as OrderPaymentEvent, O as OrderQueries, co as OrderSplitDetail, c6 as OrderStatus, n as OtpResult, a8 as PAYMENT_METHOD, ak as PAYMENT_MUTATION, aa as PAYMENT_STATE, ab as PICKUP_TIME_TYPE, ek as ParentToIframeMessage, ee as PaymentMethodInfo, c7 as PaymentState, d_ as PickupTime, dZ as PickupTimeType, bm as Price, bu as PriceAdjustment, bx as PriceDecisionPath, bl as PriceEntryType, bw as PricePathTaxInfo, P as PriceQuote, bs as PriceSource, cF as PricingOverrides, $ as ProcessAndResolveOptions, Z as ProcessCheckoutOptions, _ as ProcessCheckoutResult, aL as Product, aZ as ProductAddOn, bo as ProductAvailability, dy as ProductStock, bp as ProductTimeProfile, aF as ProductType, aN as ProductVariant, aS as ProductVariantValue, aM as ProductWithDetails, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, cw as RefundOrderInput, cz as ReminderMethod, cC as ReminderSettings, e5 as RequestContext, e8 as RequestErrorEvent, dW as RequestOtpInput, e6 as RequestStartEvent, e7 as RequestSuccessEvent, dq as RescheduleBookingInput, cI as ResourceAssignment, d9 as ResourceAvailabilityException, d8 as ResourceAvailabilityRule, dd as ResourceType, ao as Result, e9 as RetryEvent, dV as RevokeAllSessionsResult, dU as RevokeSessionResult, cY as Room, aK as SalesChannel, cG as SchedulingMetadata, cJ as SchedulingResult, p as SchedulingService, S as SearchOptions, bD as SelectedAddOnOption, de as Service, d5 as ServiceAvailabilityException, ds as ServiceAvailabilityParams, dt as ServiceAvailabilityResult, d4 as ServiceAvailabilityRule, cZ as ServiceCharge, cE as ServiceNotes, cL as ServiceScheduleRequest, db as ServiceStaffRequirement, cx as ServiceStatus, df as ServiceWithStaff, ea as SessionChangeEvent, dg as Staff, cH as StaffAssignment, d7 as StaffAvailabilityException, d6 as StaffAvailabilityRule, da as StaffBookingProfile, cy as StaffRole, cM as StaffScheduleItem, dw as Stock, dx as StockLevel, du as StockOwnershipType, dv as StockStatus, c_ as StorefrontBootstrap, cX as Table, T as TableInfo, bv as TaxPathComponent, cU as TimeRange, cV as TimeRanges, dh as TimeSlot, c1 as UICart, bV as UICartBusiness, bX as UICartCustomer, bW as UICartLocation, bY as UICartPricing, c2 as UICartResponse, dK as UpdateAddressInput, c4 as UpdateCartItemInput, cu as UpdateOrderStatusInput, U as UpdateProfileInput, aP as VariantAxis, aU as VariantAxisSelection, aR as VariantAxisValue, aQ as VariantAxisWithValues, bG as VariantDetails, b$ as VariantDetailsDTO, aO as VariantDisplayAttribute, aT as VariantLocationAvailability, dz as VariantStock, aH as VariantStrategy, dX as VerifyOtpInput, aD as combine, aE as combineObject, c as createCimplifyClient, w as createElements, as as err, ax as flatMap, aB as fromPromise, k as generateIdempotencyKey, ay as getOrElse, au as isErr, at as isOk, aw as mapError, av as mapResult, ar as ok, aA as toNullable, aC as tryCatch, az as unwrap } from './client-CUFdFugo.mjs';
2
+ export { QueryBuilder, query } from './advanced.mjs';
3
+ export { C as CURRENCY_SYMBOLS, x as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, w as ProductWithPrice, T as TaxComponent, v as TaxInfo, n as categorizePaymentError, u as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, e as formatProductPrice, i as getBasePrice, g as getCurrencySymbol, k as getDiscountPercentage, h as getDisplayPrice, l as getMarkupPercentage, m as getProductCurrency, j as isOnSale, r as isPaymentStatusFailure, s as isPaymentStatusRequiresAction, t as isPaymentStatusSuccess, o as normalizePaymentResponse, q as normalizeStatusResponse, p as parsePrice } from './index-CJ9GkIXf.mjs';
4
+ import { A as ApiError } from './payment-D-u3asA8.mjs';
5
+ export { h as AuthorizationType, c as CimplifyError, C as Currency, E as ErrorCode, b as ErrorCodeType, I as InitializePaymentResult, M as Money, a as Pagination, P as PaginationParams, l as Payment, o as PaymentErrorDetails, k as PaymentMethod, g as PaymentMethodType, j as PaymentProcessingState, f as PaymentProvider, m as PaymentResponse, e as PaymentStatus, n as PaymentStatusResponse, S as SubmitAuthorizationInput, i as isCimplifyError, d as isRetryableError } from './payment-D-u3asA8.mjs';
6
+ export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme } from './ads-t3FBTU8p.mjs';
7
+
8
+ /** Context sent with every request to scope operations to a specific location/branch */
9
+ interface FrontendContext {
10
+ location_id?: string;
11
+ }
12
+ /** Request body for POST /api/q */
13
+ interface QueryRequest {
14
+ query: string;
15
+ variables?: Record<string, unknown>;
16
+ cache_hint?: string;
17
+ context?: FrontendContext;
18
+ }
19
+ /** Request body for POST /api/m */
20
+ interface MutationRequest {
21
+ method: string;
22
+ args: unknown[];
23
+ context?: FrontendContext;
24
+ }
25
+ /** Response metadata */
26
+ interface ResponseMetadata {
27
+ execution_time_ms: number;
28
+ cache_hit: boolean;
29
+ }
30
+ /** Standard API response wrapper */
31
+ interface ApiResponse<T> {
32
+ success: boolean;
33
+ data?: T;
34
+ error?: ApiError;
35
+ metadata?: ResponseMetadata;
36
+ }
37
+
38
+ export { ApiError, type ApiResponse, type FrontendContext, type MutationRequest, type QueryRequest, type ResponseMetadata };
@@ -0,0 +1,38 @@
1
+ export { ad as AUTHORIZATION_TYPE, ai as AUTH_MUTATION, a2 as AbortablePromise, aV as AddOn, bE as AddOnDetails, b_ as AddOnGroupDetails, aX as AddOnOption, bZ as AddOnOptionDetails, aY as AddOnOptionPrice, aW as AddOnWithOptions, c3 as AddToCartInput, dN as AddressData, ed as AddressInfo, bt as AdjustmentType, ch as AmountToPay, bA as AppliedDiscount, dY as AuthResponse, A as AuthService, m as AuthStatus, ef as AuthenticatedCustomer, eh as AuthenticatedData, dB as AvailabilityCheck, dC as AvailabilityResult, di as AvailableSlot, bz as BenefitType, dl as Booking, dc as BookingRequirementOverride, dk as BookingStatus, dm as BookingWithDetails, cB as BufferTimes, b4 as Bundle, b8 as BundleComponentData, b9 as BundleComponentInfo, b3 as BundlePriceType, b6 as BundleProduct, bJ as BundleSelectionData, bH as BundleSelectionInput, bI as BundleStoredSelection, b5 as BundleSummary, b7 as BundleWithDetails, cQ as Business, d2 as BusinessHours, cP as BusinessPreferences, B as BusinessService, d1 as BusinessSettings, cO as BusinessType, c$ as BusinessWithLocations, a6 as CHECKOUT_MODE, aj as CHECKOUT_MUTATION, a9 as CHECKOUT_STEP, af as CONTACT_TYPE, dr as CancelBookingInput, cv as CancelOrderInput, cD as CancellationPolicy, bO as Cart, bF as CartAddOn, br as CartChannel, bP as CartItem, c0 as CartItemDetails, i as CartOperations, bq as CartStatus, c5 as CartSummary, bQ as CartTotals, b as CatalogueQueries, a_ as Category, d3 as CategoryInfo, a$ as CategorySummary, o as ChangePasswordInput, dp as CheckSlotAvailabilityInput, d$ as CheckoutAddressInfo, e1 as CheckoutCustomerInfo, X as CheckoutFormData, ct as CheckoutInput, J as CheckoutMode, j as CheckoutOperations, N as CheckoutOrderType, V as CheckoutPaymentMethod, Y as CheckoutResult, j as CheckoutService, a0 as CheckoutStatus, a1 as CheckoutStatusContext, W as CheckoutStep, by as ChosenPrice, C as CimplifyClient, a as CimplifyConfig, v as CimplifyElement, u as CimplifyElements, b0 as Collection, b2 as CollectionProduct, b1 as CollectionSummary, bf as ComponentGroup, bg as ComponentGroupWithComponents, bk as ComponentPriceBreakdown, bi as ComponentSelectionInput, bc as ComponentSourceType, bd as Composite, bh as CompositeComponent, bL as CompositePriceBreakdown, bj as CompositePriceResult, ba as CompositePricingMode, bM as CompositeSelectionData, bi as CompositeSelectionInput, bK as CompositeStoredSelection, be as CompositeWithDetails, a5 as ContactType, dJ as CreateAddressInput, dL as CreateMobileMoneyInput, dE as Customer, dF as CustomerAddress, dH as CustomerLinkPreferences, dG as CustomerMobileMoney, cA as CustomerServicePreferences, an as DEFAULT_COUNTRY, am as DEFAULT_CURRENCY, ae as DEVICE_TYPE, dj as DayAvailability, cK as DepositResult, aJ as DepositType, a4 as DeviceType, aI as DigitalProductType, bB as DiscountBreakdown, bC as DiscountDetails, bT as DisplayAddOn, bU as DisplayAddOnOption, bR as DisplayCart, bS as DisplayCartItem, x as ELEMENT_TYPES, E as EVENT_TYPES, ec as ElementAppearance, em as ElementEventHandler, H as ElementEventType, z as ElementOptions, D as ElementType, ei as ElementsCheckoutData, ej as ElementsCheckoutResult, eg as ElementsCustomerInfo, y as ElementsOptions, dP as EnrollAndLinkOrderInput, dS as EnrollAndLinkOrderResult, dM as EnrollmentData, aq as Err, cg as FeeBearerType, F as FetchQuoteInput, ce as FulfillmentLink, cd as FulfillmentStatus, cc as FulfillmentType, e3 as FxQuote, e2 as FxQuoteRequest, e4 as FxRateResponse, r as FxService, dn as GetAvailableSlotsInput, l as GetOrdersOptions, G as GetProductsOptions, bb as GroupPricingBehavior, el as IframeToParentMessage, I as InventoryService, dD as InventorySummary, aG as InventoryType, K as KitchenOrderItem, t as KitchenOrderResult, ah as LINK_MUTATION, ag as LINK_QUERY, bN as LineConfiguration, ci as LineItem, c9 as LineType, dI as LinkData, dR as LinkEnrollResult, L as LinkService, dT as LinkSession, dQ as LinkStatusResult, s as LiteBootstrap, q as LiteService, cT as Location, cN as LocationAppointment, bn as LocationProductPrice, dA as LocationStock, cR as LocationTaxBehavior, cS as LocationTaxOverrides, cW as LocationTimeProfile, d0 as LocationWithDetails, M as MESSAGE_TYPES, ac as MOBILE_MONEY_PROVIDER, dO as MobileMoneyData, e0 as MobileMoneyDetails, a3 as MobileMoneyProvider, al as ORDER_MUTATION, a7 as ORDER_TYPE, eb as ObservabilityHooks, ap as Ok, cj as Order, c8 as OrderChannel, cs as OrderFilter, cf as OrderFulfillmentSummary, cm as OrderGroup, cq as OrderGroupDetails, cn as OrderGroupPayment, cl as OrderGroupPaymentState, cp as OrderGroupPaymentSummary, ck as OrderHistory, ca as OrderLineState, cb as OrderLineStatus, cr as OrderPaymentEvent, O as OrderQueries, co as OrderSplitDetail, c6 as OrderStatus, n as OtpResult, a8 as PAYMENT_METHOD, ak as PAYMENT_MUTATION, aa as PAYMENT_STATE, ab as PICKUP_TIME_TYPE, ek as ParentToIframeMessage, ee as PaymentMethodInfo, c7 as PaymentState, d_ as PickupTime, dZ as PickupTimeType, bm as Price, bu as PriceAdjustment, bx as PriceDecisionPath, bl as PriceEntryType, bw as PricePathTaxInfo, P as PriceQuote, bs as PriceSource, cF as PricingOverrides, $ as ProcessAndResolveOptions, Z as ProcessCheckoutOptions, _ as ProcessCheckoutResult, aL as Product, aZ as ProductAddOn, bo as ProductAvailability, dy as ProductStock, bp as ProductTimeProfile, aF as ProductType, aN as ProductVariant, aS as ProductVariantValue, aM as ProductWithDetails, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, h as RefreshQuoteResult, cw as RefundOrderInput, cz as ReminderMethod, cC as ReminderSettings, e5 as RequestContext, e8 as RequestErrorEvent, dW as RequestOtpInput, e6 as RequestStartEvent, e7 as RequestSuccessEvent, dq as RescheduleBookingInput, cI as ResourceAssignment, d9 as ResourceAvailabilityException, d8 as ResourceAvailabilityRule, dd as ResourceType, ao as Result, e9 as RetryEvent, dV as RevokeAllSessionsResult, dU as RevokeSessionResult, cY as Room, aK as SalesChannel, cG as SchedulingMetadata, cJ as SchedulingResult, p as SchedulingService, S as SearchOptions, bD as SelectedAddOnOption, de as Service, d5 as ServiceAvailabilityException, ds as ServiceAvailabilityParams, dt as ServiceAvailabilityResult, d4 as ServiceAvailabilityRule, cZ as ServiceCharge, cE as ServiceNotes, cL as ServiceScheduleRequest, db as ServiceStaffRequirement, cx as ServiceStatus, df as ServiceWithStaff, ea as SessionChangeEvent, dg as Staff, cH as StaffAssignment, d7 as StaffAvailabilityException, d6 as StaffAvailabilityRule, da as StaffBookingProfile, cy as StaffRole, cM as StaffScheduleItem, dw as Stock, dx as StockLevel, du as StockOwnershipType, dv as StockStatus, c_ as StorefrontBootstrap, cX as Table, T as TableInfo, bv as TaxPathComponent, cU as TimeRange, cV as TimeRanges, dh as TimeSlot, c1 as UICart, bV as UICartBusiness, bX as UICartCustomer, bW as UICartLocation, bY as UICartPricing, c2 as UICartResponse, dK as UpdateAddressInput, c4 as UpdateCartItemInput, cu as UpdateOrderStatusInput, U as UpdateProfileInput, aP as VariantAxis, aU as VariantAxisSelection, aR as VariantAxisValue, aQ as VariantAxisWithValues, bG as VariantDetails, b$ as VariantDetailsDTO, aO as VariantDisplayAttribute, aT as VariantLocationAvailability, dz as VariantStock, aH as VariantStrategy, dX as VerifyOtpInput, aD as combine, aE as combineObject, c as createCimplifyClient, w as createElements, as as err, ax as flatMap, aB as fromPromise, k as generateIdempotencyKey, ay as getOrElse, au as isErr, at as isOk, aw as mapError, av as mapResult, ar as ok, aA as toNullable, aC as tryCatch, az as unwrap } from './client-CjqNbEM6.js';
2
+ export { QueryBuilder, query } from './advanced.js';
3
+ export { C as CURRENCY_SYMBOLS, x as FormatCompactOptions, F as FormatPriceOptions, M as MOBILE_MONEY_PROVIDERS, P as PriceInfo, w as ProductWithPrice, T as TaxComponent, v as TaxInfo, n as categorizePaymentError, u as detectMobileMoneyProvider, c as formatMoney, d as formatNumberCompact, f as formatPrice, a as formatPriceAdjustment, b as formatPriceCompact, e as formatProductPrice, i as getBasePrice, g as getCurrencySymbol, k as getDiscountPercentage, h as getDisplayPrice, l as getMarkupPercentage, m as getProductCurrency, j as isOnSale, r as isPaymentStatusFailure, s as isPaymentStatusRequiresAction, t as isPaymentStatusSuccess, o as normalizePaymentResponse, q as normalizeStatusResponse, p as parsePrice } from './index-B5Bj-Ikg.js';
4
+ import { A as ApiError } from './payment-D-u3asA8.js';
5
+ export { h as AuthorizationType, c as CimplifyError, C as Currency, E as ErrorCode, b as ErrorCodeType, I as InitializePaymentResult, M as Money, a as Pagination, P as PaginationParams, l as Payment, o as PaymentErrorDetails, k as PaymentMethod, g as PaymentMethodType, j as PaymentProcessingState, f as PaymentProvider, m as PaymentResponse, e as PaymentStatus, n as PaymentStatusResponse, S as SubmitAuthorizationInput, i as isCimplifyError, d as isRetryableError } from './payment-D-u3asA8.js';
6
+ export { c as AdConfig, e as AdContextValue, d as AdCreative, a as AdPosition, A as AdSlot, b as AdTheme } from './ads-t3FBTU8p.js';
7
+
8
+ /** Context sent with every request to scope operations to a specific location/branch */
9
+ interface FrontendContext {
10
+ location_id?: string;
11
+ }
12
+ /** Request body for POST /api/q */
13
+ interface QueryRequest {
14
+ query: string;
15
+ variables?: Record<string, unknown>;
16
+ cache_hint?: string;
17
+ context?: FrontendContext;
18
+ }
19
+ /** Request body for POST /api/m */
20
+ interface MutationRequest {
21
+ method: string;
22
+ args: unknown[];
23
+ context?: FrontendContext;
24
+ }
25
+ /** Response metadata */
26
+ interface ResponseMetadata {
27
+ execution_time_ms: number;
28
+ cache_hit: boolean;
29
+ }
30
+ /** Standard API response wrapper */
31
+ interface ApiResponse<T> {
32
+ success: boolean;
33
+ data?: T;
34
+ error?: ApiError;
35
+ metadata?: ResponseMetadata;
36
+ }
37
+
38
+ export { ApiError, type ApiResponse, type FrontendContext, type MutationRequest, type QueryRequest, type ResponseMetadata };
package/dist/index.js CHANGED
@@ -2533,8 +2533,9 @@ var CimplifyElements = class {
2533
2533
  this.paymentData = null;
2534
2534
  this.checkoutInProgress = false;
2535
2535
  this.activeCheckoutAbort = null;
2536
+ this.businessIdResolvePromise = null;
2536
2537
  this.client = client;
2537
- this.businessId = businessId;
2538
+ this.businessId = businessId ?? null;
2538
2539
  this.linkUrl = options.linkUrl || DEFAULT_LINK_URL;
2539
2540
  this.options = options;
2540
2541
  this.boundHandleMessage = this.handleMessage.bind(this);
@@ -2757,6 +2758,24 @@ var CimplifyElements = class {
2757
2758
  getPublicKey() {
2758
2759
  return this.client.getPublicKey();
2759
2760
  }
2761
+ getBusinessId() {
2762
+ return this.businessId;
2763
+ }
2764
+ async resolveBusinessId() {
2765
+ if (this.businessId) {
2766
+ return this.businessId;
2767
+ }
2768
+ if (this.businessIdResolvePromise) {
2769
+ return this.businessIdResolvePromise;
2770
+ }
2771
+ this.businessIdResolvePromise = this.client.resolveBusinessId().then((resolvedBusinessId) => {
2772
+ this.businessId = resolvedBusinessId;
2773
+ return resolvedBusinessId;
2774
+ }).catch(() => null).finally(() => {
2775
+ this.businessIdResolvePromise = null;
2776
+ });
2777
+ return this.businessIdResolvePromise;
2778
+ }
2760
2779
  getAppearance() {
2761
2780
  return this.options.appearance;
2762
2781
  }
@@ -2861,8 +2880,8 @@ var CimplifyElement = class {
2861
2880
  return;
2862
2881
  }
2863
2882
  this.container = target;
2864
- this.createIframe();
2865
2883
  this.mounted = true;
2884
+ void this.createIframe();
2866
2885
  }
2867
2886
  destroy() {
2868
2887
  if (this.iframe) {
@@ -2916,11 +2935,21 @@ var CimplifyElement = class {
2916
2935
  isMounted() {
2917
2936
  return this.mounted && Boolean(this.iframe) && this.iframe?.isConnected === true;
2918
2937
  }
2919
- createIframe() {
2938
+ async createIframe() {
2920
2939
  if (!this.container) return;
2940
+ const resolvedBusinessId = this.businessId ?? await this.parent.resolveBusinessId();
2941
+ if (!resolvedBusinessId || !this.container || !this.mounted) {
2942
+ console.error("Unable to mount element without a resolved business ID");
2943
+ this.emit(EVENT_TYPES.ERROR, {
2944
+ code: "BUSINESS_ID_REQUIRED",
2945
+ message: "Unable to initialize checkout without a business ID."
2946
+ });
2947
+ return;
2948
+ }
2949
+ this.businessId = resolvedBusinessId;
2921
2950
  const iframe = document.createElement("iframe");
2922
2951
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
2923
- url.searchParams.set("businessId", this.businessId);
2952
+ url.searchParams.set("businessId", resolvedBusinessId);
2924
2953
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
2925
2954
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
2926
2955
  iframe.src = url.toString();
@@ -2940,7 +2969,7 @@ var CimplifyElement = class {
2940
2969
  const publicKey = this.parent.getPublicKey();
2941
2970
  this.sendMessage({
2942
2971
  type: MESSAGE_TYPES.INIT,
2943
- businessId: this.businessId,
2972
+ businessId: resolvedBusinessId,
2944
2973
  publicKey,
2945
2974
  demoMode: publicKey.length === 0,
2946
2975
  prefillEmail: this.options.prefillEmail,
@@ -3085,6 +3114,8 @@ var CimplifyClient = class {
3085
3114
  constructor(config = {}) {
3086
3115
  this.accessToken = null;
3087
3116
  this.context = {};
3117
+ this.businessId = null;
3118
+ this.businessIdResolvePromise = null;
3088
3119
  this.inflightRequests = /* @__PURE__ */ new Map();
3089
3120
  this.publicKey = config.publicKey || getEnvPublicKey() || "";
3090
3121
  const urls = deriveUrls();
@@ -3148,6 +3179,47 @@ var CimplifyClient = class {
3148
3179
  getLocationId() {
3149
3180
  return this.context.location_id ?? null;
3150
3181
  }
3182
+ /** Cache a resolved business ID for future element/checkouts initialization. */
3183
+ setBusinessId(businessId) {
3184
+ const normalized = businessId.trim();
3185
+ if (!normalized) {
3186
+ return;
3187
+ }
3188
+ this.businessId = normalized;
3189
+ }
3190
+ /** Get cached business ID if available. */
3191
+ getBusinessId() {
3192
+ return this.businessId;
3193
+ }
3194
+ /**
3195
+ * Resolve business ID from public key once and cache it.
3196
+ * Subsequent calls return the cached value (or shared in-flight promise).
3197
+ */
3198
+ async resolveBusinessId() {
3199
+ if (this.businessId) {
3200
+ return this.businessId;
3201
+ }
3202
+ if (this.businessIdResolvePromise) {
3203
+ return this.businessIdResolvePromise;
3204
+ }
3205
+ this.businessIdResolvePromise = (async () => {
3206
+ const result = await this.business.getInfo();
3207
+ if (!result.ok || !result.value?.id) {
3208
+ throw new CimplifyError(
3209
+ ErrorCode.NOT_FOUND,
3210
+ "Unable to resolve business ID from the current public key.",
3211
+ true
3212
+ );
3213
+ }
3214
+ this.businessId = result.value.id;
3215
+ return result.value.id;
3216
+ })();
3217
+ try {
3218
+ return await this.businessIdResolvePromise;
3219
+ } finally {
3220
+ this.businessIdResolvePromise = null;
3221
+ }
3222
+ }
3151
3223
  loadAccessToken() {
3152
3224
  if (typeof window !== "undefined" && window.localStorage) {
3153
3225
  return localStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
@@ -3465,7 +3537,10 @@ var CimplifyClient = class {
3465
3537
  * ```
3466
3538
  */
3467
3539
  elements(businessId, options) {
3468
- return createElements(this, businessId, options);
3540
+ if (businessId) {
3541
+ this.setBusinessId(businessId);
3542
+ }
3543
+ return createElements(this, businessId ?? this.businessId ?? void 0, options);
3469
3544
  }
3470
3545
  };
3471
3546
  function createCimplifyClient(config = {}) {
package/dist/index.mjs CHANGED
@@ -2531,8 +2531,9 @@ var CimplifyElements = class {
2531
2531
  this.paymentData = null;
2532
2532
  this.checkoutInProgress = false;
2533
2533
  this.activeCheckoutAbort = null;
2534
+ this.businessIdResolvePromise = null;
2534
2535
  this.client = client;
2535
- this.businessId = businessId;
2536
+ this.businessId = businessId ?? null;
2536
2537
  this.linkUrl = options.linkUrl || DEFAULT_LINK_URL;
2537
2538
  this.options = options;
2538
2539
  this.boundHandleMessage = this.handleMessage.bind(this);
@@ -2755,6 +2756,24 @@ var CimplifyElements = class {
2755
2756
  getPublicKey() {
2756
2757
  return this.client.getPublicKey();
2757
2758
  }
2759
+ getBusinessId() {
2760
+ return this.businessId;
2761
+ }
2762
+ async resolveBusinessId() {
2763
+ if (this.businessId) {
2764
+ return this.businessId;
2765
+ }
2766
+ if (this.businessIdResolvePromise) {
2767
+ return this.businessIdResolvePromise;
2768
+ }
2769
+ this.businessIdResolvePromise = this.client.resolveBusinessId().then((resolvedBusinessId) => {
2770
+ this.businessId = resolvedBusinessId;
2771
+ return resolvedBusinessId;
2772
+ }).catch(() => null).finally(() => {
2773
+ this.businessIdResolvePromise = null;
2774
+ });
2775
+ return this.businessIdResolvePromise;
2776
+ }
2758
2777
  getAppearance() {
2759
2778
  return this.options.appearance;
2760
2779
  }
@@ -2859,8 +2878,8 @@ var CimplifyElement = class {
2859
2878
  return;
2860
2879
  }
2861
2880
  this.container = target;
2862
- this.createIframe();
2863
2881
  this.mounted = true;
2882
+ void this.createIframe();
2864
2883
  }
2865
2884
  destroy() {
2866
2885
  if (this.iframe) {
@@ -2914,11 +2933,21 @@ var CimplifyElement = class {
2914
2933
  isMounted() {
2915
2934
  return this.mounted && Boolean(this.iframe) && this.iframe?.isConnected === true;
2916
2935
  }
2917
- createIframe() {
2936
+ async createIframe() {
2918
2937
  if (!this.container) return;
2938
+ const resolvedBusinessId = this.businessId ?? await this.parent.resolveBusinessId();
2939
+ if (!resolvedBusinessId || !this.container || !this.mounted) {
2940
+ console.error("Unable to mount element without a resolved business ID");
2941
+ this.emit(EVENT_TYPES.ERROR, {
2942
+ code: "BUSINESS_ID_REQUIRED",
2943
+ message: "Unable to initialize checkout without a business ID."
2944
+ });
2945
+ return;
2946
+ }
2947
+ this.businessId = resolvedBusinessId;
2919
2948
  const iframe = document.createElement("iframe");
2920
2949
  const url = new URL(`${this.linkUrl}/elements/${this.type}`);
2921
- url.searchParams.set("businessId", this.businessId);
2950
+ url.searchParams.set("businessId", resolvedBusinessId);
2922
2951
  if (this.options.prefillEmail) url.searchParams.set("email", this.options.prefillEmail);
2923
2952
  if (this.options.mode) url.searchParams.set("mode", this.options.mode);
2924
2953
  iframe.src = url.toString();
@@ -2938,7 +2967,7 @@ var CimplifyElement = class {
2938
2967
  const publicKey = this.parent.getPublicKey();
2939
2968
  this.sendMessage({
2940
2969
  type: MESSAGE_TYPES.INIT,
2941
- businessId: this.businessId,
2970
+ businessId: resolvedBusinessId,
2942
2971
  publicKey,
2943
2972
  demoMode: publicKey.length === 0,
2944
2973
  prefillEmail: this.options.prefillEmail,
@@ -3083,6 +3112,8 @@ var CimplifyClient = class {
3083
3112
  constructor(config = {}) {
3084
3113
  this.accessToken = null;
3085
3114
  this.context = {};
3115
+ this.businessId = null;
3116
+ this.businessIdResolvePromise = null;
3086
3117
  this.inflightRequests = /* @__PURE__ */ new Map();
3087
3118
  this.publicKey = config.publicKey || getEnvPublicKey() || "";
3088
3119
  const urls = deriveUrls();
@@ -3146,6 +3177,47 @@ var CimplifyClient = class {
3146
3177
  getLocationId() {
3147
3178
  return this.context.location_id ?? null;
3148
3179
  }
3180
+ /** Cache a resolved business ID for future element/checkouts initialization. */
3181
+ setBusinessId(businessId) {
3182
+ const normalized = businessId.trim();
3183
+ if (!normalized) {
3184
+ return;
3185
+ }
3186
+ this.businessId = normalized;
3187
+ }
3188
+ /** Get cached business ID if available. */
3189
+ getBusinessId() {
3190
+ return this.businessId;
3191
+ }
3192
+ /**
3193
+ * Resolve business ID from public key once and cache it.
3194
+ * Subsequent calls return the cached value (or shared in-flight promise).
3195
+ */
3196
+ async resolveBusinessId() {
3197
+ if (this.businessId) {
3198
+ return this.businessId;
3199
+ }
3200
+ if (this.businessIdResolvePromise) {
3201
+ return this.businessIdResolvePromise;
3202
+ }
3203
+ this.businessIdResolvePromise = (async () => {
3204
+ const result = await this.business.getInfo();
3205
+ if (!result.ok || !result.value?.id) {
3206
+ throw new CimplifyError(
3207
+ ErrorCode.NOT_FOUND,
3208
+ "Unable to resolve business ID from the current public key.",
3209
+ true
3210
+ );
3211
+ }
3212
+ this.businessId = result.value.id;
3213
+ return result.value.id;
3214
+ })();
3215
+ try {
3216
+ return await this.businessIdResolvePromise;
3217
+ } finally {
3218
+ this.businessIdResolvePromise = null;
3219
+ }
3220
+ }
3149
3221
  loadAccessToken() {
3150
3222
  if (typeof window !== "undefined" && window.localStorage) {
3151
3223
  return localStorage.getItem(ACCESS_TOKEN_STORAGE_KEY);
@@ -3463,7 +3535,10 @@ var CimplifyClient = class {
3463
3535
  * ```
3464
3536
  */
3465
3537
  elements(businessId, options) {
3466
- return createElements(this, businessId, options);
3538
+ if (businessId) {
3539
+ this.setBusinessId(businessId);
3540
+ }
3541
+ return createElements(this, businessId ?? this.businessId ?? void 0, options);
3467
3542
  }
3468
3543
  };
3469
3544
  function createCimplifyClient(config = {}) {
@@ -0,0 +1,170 @@
1
+ /** Decimal value represented as string for precision */
2
+ type Money = string;
3
+ /** Supported currencies */
4
+ type Currency = "GHS" | "USD" | "NGN" | "KES" | "ZAR" | string;
5
+ /** Pagination parameters */
6
+ interface PaginationParams {
7
+ page?: number;
8
+ limit?: number;
9
+ offset?: number;
10
+ }
11
+ /** Pagination metadata in response */
12
+ interface Pagination {
13
+ total_count: number;
14
+ current_page: number;
15
+ page_size: number;
16
+ total_pages: number;
17
+ }
18
+ /** Strongly-typed error codes for better DX */
19
+ declare const ErrorCode: {
20
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
21
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
22
+ readonly TIMEOUT: "TIMEOUT";
23
+ readonly UNAUTHORIZED: "UNAUTHORIZED";
24
+ readonly FORBIDDEN: "FORBIDDEN";
25
+ readonly NOT_FOUND: "NOT_FOUND";
26
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
27
+ readonly CART_EMPTY: "CART_EMPTY";
28
+ readonly CART_EXPIRED: "CART_EXPIRED";
29
+ readonly CART_NOT_FOUND: "CART_NOT_FOUND";
30
+ readonly ITEM_UNAVAILABLE: "ITEM_UNAVAILABLE";
31
+ readonly VARIANT_NOT_FOUND: "VARIANT_NOT_FOUND";
32
+ readonly VARIANT_OUT_OF_STOCK: "VARIANT_OUT_OF_STOCK";
33
+ readonly ADDON_REQUIRED: "ADDON_REQUIRED";
34
+ readonly ADDON_MAX_EXCEEDED: "ADDON_MAX_EXCEEDED";
35
+ readonly CHECKOUT_VALIDATION_FAILED: "CHECKOUT_VALIDATION_FAILED";
36
+ readonly DELIVERY_ADDRESS_REQUIRED: "DELIVERY_ADDRESS_REQUIRED";
37
+ readonly CUSTOMER_INFO_REQUIRED: "CUSTOMER_INFO_REQUIRED";
38
+ readonly PAYMENT_FAILED: "PAYMENT_FAILED";
39
+ readonly PAYMENT_CANCELLED: "PAYMENT_CANCELLED";
40
+ readonly INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS";
41
+ readonly CARD_DECLINED: "CARD_DECLINED";
42
+ readonly INVALID_OTP: "INVALID_OTP";
43
+ readonly OTP_EXPIRED: "OTP_EXPIRED";
44
+ readonly AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED";
45
+ readonly PAYMENT_ACTION_NOT_COMPLETED: "PAYMENT_ACTION_NOT_COMPLETED";
46
+ readonly SLOT_UNAVAILABLE: "SLOT_UNAVAILABLE";
47
+ readonly BOOKING_CONFLICT: "BOOKING_CONFLICT";
48
+ readonly SERVICE_NOT_FOUND: "SERVICE_NOT_FOUND";
49
+ readonly OUT_OF_STOCK: "OUT_OF_STOCK";
50
+ readonly INSUFFICIENT_QUANTITY: "INSUFFICIENT_QUANTITY";
51
+ };
52
+ type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
53
+ /** API error structure */
54
+ interface ApiError {
55
+ code: string;
56
+ message: string;
57
+ retryable: boolean;
58
+ }
59
+ /**
60
+ * Custom error class for SDK errors with typed error codes.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * try {
65
+ * await client.cart.addItem({ item_id: "prod_123" });
66
+ * } catch (error) {
67
+ * if (isCimplifyError(error)) {
68
+ * switch (error.code) {
69
+ * case ErrorCode.ITEM_UNAVAILABLE:
70
+ * toast.error("This item is no longer available");
71
+ * break;
72
+ * case ErrorCode.VARIANT_OUT_OF_STOCK:
73
+ * toast.error("Selected option is out of stock");
74
+ * break;
75
+ * default:
76
+ * toast.error(error.message);
77
+ * }
78
+ * }
79
+ * }
80
+ * ```
81
+ */
82
+ declare class CimplifyError extends Error {
83
+ code: string;
84
+ retryable: boolean;
85
+ constructor(code: string, message: string, retryable?: boolean);
86
+ /** User-friendly message safe to display */
87
+ get userMessage(): string;
88
+ }
89
+ /** Type guard for CimplifyError */
90
+ declare function isCimplifyError(error: unknown): error is CimplifyError;
91
+ /** Check if error is retryable */
92
+ declare function isRetryableError(error: unknown): boolean;
93
+
94
+ type PaymentStatus = "pending" | "processing" | "created" | "pending_confirmation" | "success" | "succeeded" | "failed" | "declined" | "authorized" | "refunded" | "partially_refunded" | "partially_paid" | "paid" | "unpaid" | "requires_action" | "requires_payment_method" | "requires_capture" | "captured" | "cancelled" | "completed" | "voided" | "error" | "unknown";
95
+ type PaymentProvider = "stripe" | "paystack" | "mtn" | "vodafone" | "airtel" | "cellulant" | "offline" | "cash" | "manual";
96
+ type PaymentMethodType = "card" | "mobile_money" | "bank_transfer" | "cash" | "custom";
97
+ /** Authorization types for payment verification (OTP, PIN, etc.) */
98
+ type AuthorizationType = "otp" | "pin" | "phone" | "birthday" | "address";
99
+ /** Payment processing state machine states (for UI) */
100
+ type PaymentProcessingState = "initial" | "preparing" | "processing" | "verifying" | "awaiting_authorization" | "success" | "error" | "timeout";
101
+ interface PaymentMethod {
102
+ type: PaymentMethodType;
103
+ provider?: string;
104
+ phone_number?: string;
105
+ card_last_four?: string;
106
+ custom_value?: string;
107
+ }
108
+ interface Payment {
109
+ id: string;
110
+ order_id: string;
111
+ business_id: string;
112
+ amount: Money;
113
+ currency: Currency;
114
+ payment_method: PaymentMethod;
115
+ status: PaymentStatus;
116
+ provider: PaymentProvider;
117
+ provider_reference?: string;
118
+ failure_reason?: string;
119
+ created_at: string;
120
+ updated_at: string;
121
+ }
122
+ interface InitializePaymentResult {
123
+ payment_id: string;
124
+ status: PaymentStatus;
125
+ redirect_url?: string;
126
+ authorization_url?: string;
127
+ reference: string;
128
+ provider: PaymentProvider;
129
+ }
130
+ /** Normalized payment response from checkout or payment initialization */
131
+ interface PaymentResponse {
132
+ method: string;
133
+ provider: string;
134
+ requires_action: boolean;
135
+ public_key?: string;
136
+ client_secret?: string;
137
+ access_code?: string;
138
+ redirect_url?: string;
139
+ transaction_id?: string;
140
+ order_id?: string;
141
+ reference?: string;
142
+ metadata?: Record<string, unknown>;
143
+ instructions?: string;
144
+ display_text?: string;
145
+ requires_authorization?: boolean;
146
+ authorization_type?: AuthorizationType;
147
+ provider_payment_id?: string;
148
+ }
149
+ /** Payment status polling response */
150
+ interface PaymentStatusResponse {
151
+ status: PaymentStatus;
152
+ paid: boolean;
153
+ amount?: Money;
154
+ currency?: string;
155
+ reference?: string;
156
+ message?: string;
157
+ }
158
+ interface PaymentErrorDetails {
159
+ code: string;
160
+ message: string;
161
+ recoverable: boolean;
162
+ technical?: string;
163
+ }
164
+ interface SubmitAuthorizationInput {
165
+ reference: string;
166
+ auth_type: AuthorizationType;
167
+ value: string;
168
+ }
169
+
170
+ export { type ApiError as A, type Currency as C, ErrorCode as E, type InitializePaymentResult as I, type Money as M, type PaginationParams as P, type SubmitAuthorizationInput as S, type Pagination as a, type ErrorCodeType as b, CimplifyError as c, isRetryableError as d, type PaymentStatus as e, type PaymentProvider as f, type PaymentMethodType as g, type AuthorizationType as h, isCimplifyError as i, type PaymentProcessingState as j, type PaymentMethod as k, type Payment as l, type PaymentResponse as m, type PaymentStatusResponse as n, type PaymentErrorDetails as o };