@delopay/sdk 0.47.0 → 0.48.0

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/dist/index.d.cts CHANGED
@@ -1142,6 +1142,27 @@ interface PlatformFeeRuleRecord {
1142
1142
  created_at: number;
1143
1143
  modified_at: number;
1144
1144
  }
1145
+ /** Sample transaction + candidate program for `POST /admin/fees/rules/preview`. */
1146
+ interface FeeRulePreviewRequest {
1147
+ algorithm: PlatformFeeProgram;
1148
+ /** Amount in minor units. */
1149
+ amount: number;
1150
+ currency: Currency;
1151
+ payment_method?: PaymentMethod | null;
1152
+ connector?: Connector | null;
1153
+ card_network?: string | null;
1154
+ /** USD minor units (previous-month volume snapshot). */
1155
+ merchant_volume?: number | null;
1156
+ }
1157
+ interface FeeRulePreviewResponse {
1158
+ /** Matched rule name, or null when only the default selection matched. */
1159
+ matched_rule: string | null;
1160
+ /** True when the matched branch sets no concrete fee (engine falls through to the legacy schedule/tier chain). */
1161
+ fell_through: boolean;
1162
+ /** Computed fee in minor units, or null when fell_through. */
1163
+ fee_amount: number | null;
1164
+ fee_currency: string | null;
1165
+ }
1145
1166
  interface ProjectCreateRequest {
1146
1167
  project_name: string;
1147
1168
  description?: string | null;
@@ -3026,6 +3047,15 @@ declare class FeeRulesManager {
3026
3047
  * (other shops' programs are left intact).
3027
3048
  */
3028
3049
  delete(merchantId: string, profileId?: string): Promise<void>;
3050
+ /**
3051
+ * Dry-run a candidate fee-rule program against a sample transaction.
3052
+ * Returns the matched rule name, whether it fell through, and the computed fee.
3053
+ * Does not persist anything.
3054
+ *
3055
+ * @param input - Candidate program + sample transaction fields.
3056
+ * @param merchantId - The merchant account ID.
3057
+ */
3058
+ preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse>;
3029
3059
  }
3030
3060
 
3031
3061
  /** View and revoke recurring payment mandates. */
@@ -4591,6 +4621,29 @@ declare const Webhooks: {
4591
4621
  verify(rawBody: string | Uint8Array, signatureHeader: string, secret: string): Promise<WebhookEvent>;
4592
4622
  };
4593
4623
 
4624
+ /** A single condition leaf in the builder's condition tree. */
4625
+ interface LeafNode {
4626
+ kind: 'leaf';
4627
+ lhs: string;
4628
+ comparison: EuclidComparisonType;
4629
+ value: EuclidValue;
4630
+ }
4631
+ /** An AND (`all`) or OR (`any`) group of condition nodes. */
4632
+ interface GroupNode {
4633
+ kind: 'all' | 'any';
4634
+ children: ConditionNode[];
4635
+ }
4636
+ type ConditionNode = LeafNode | GroupNode;
4637
+ /**
4638
+ * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;
4639
+ * string values (payment_method, connector, currency, card_network) tag as
4640
+ * `enum_variant`.
4641
+ */
4642
+ declare function leaf(lhs: string, comparison: EuclidComparisonType, value: string | number): LeafNode;
4643
+ /** AND group — all children must match. */
4644
+ declare function allOf(...children: ConditionNode[]): GroupNode;
4645
+ /** OR group — any child matching is enough. */
4646
+ declare function anyOf(...children: ConditionNode[]): GroupNode;
4594
4647
  /**
4595
4648
  * How a rule (or the default) prices a transaction. `fee_type` is inferred:
4596
4649
  * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.
@@ -4623,6 +4676,16 @@ interface FeeRuleConditions {
4623
4676
  amountGreaterThan?: number;
4624
4677
  /** `amount < n` (minor units). */
4625
4678
  amountLessThan?: number;
4679
+ /**
4680
+ * `merchant_volume == n` — the merchant's previous-month volume snapshot
4681
+ * (USD minor units). Combine with any other condition, e.g.
4682
+ * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.
4683
+ */
4684
+ merchantVolumeEquals?: number;
4685
+ /** `merchant_volume > n` (USD minor units). */
4686
+ merchantVolumeGreaterThan?: number;
4687
+ /** `merchant_volume < n` (USD minor units). */
4688
+ merchantVolumeLessThan?: number;
4626
4689
  }
4627
4690
  interface FeeRuleInput {
4628
4691
  name: string;
@@ -4630,8 +4693,35 @@ interface FeeRuleInput {
4630
4693
  when?: FeeRuleConditions;
4631
4694
  /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */
4632
4695
  rawConditions?: EuclidComparison[];
4696
+ /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */
4697
+ match?: ConditionNode;
4633
4698
  fee: FeeSpecInput;
4634
4699
  }
4700
+ /**
4701
+ * Decode a rule's `statements[]` back into a condition tree.
4702
+ *
4703
+ * Returns a tree that is **logically equivalent** to the source. It is
4704
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4705
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4706
+ * shape differs (still equivalent).
4707
+ */
4708
+ declare function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode;
4709
+ /**
4710
+ * Decode a stored program into the builder's editable model.
4711
+ *
4712
+ * Returns a tree that is **logically equivalent** to the source. It is
4713
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4714
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4715
+ * shape differs (still equivalent).
4716
+ */
4717
+ declare function programToTree(program: PlatformFeeProgram): {
4718
+ rules: {
4719
+ name: string;
4720
+ match: ConditionNode;
4721
+ fee: PlatformFeeOutput | null;
4722
+ }[];
4723
+ otherwise: PlatformFeeOutput | null;
4724
+ };
4635
4725
  /**
4636
4726
  * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire
4637
4727
  * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers
@@ -4804,4 +4894,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
4804
4894
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
4805
4895
  declare function shadowFor(style: SurfaceStyle): string;
4806
4896
 
4807
- export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
4897
+ export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.d.ts CHANGED
@@ -1142,6 +1142,27 @@ interface PlatformFeeRuleRecord {
1142
1142
  created_at: number;
1143
1143
  modified_at: number;
1144
1144
  }
1145
+ /** Sample transaction + candidate program for `POST /admin/fees/rules/preview`. */
1146
+ interface FeeRulePreviewRequest {
1147
+ algorithm: PlatformFeeProgram;
1148
+ /** Amount in minor units. */
1149
+ amount: number;
1150
+ currency: Currency;
1151
+ payment_method?: PaymentMethod | null;
1152
+ connector?: Connector | null;
1153
+ card_network?: string | null;
1154
+ /** USD minor units (previous-month volume snapshot). */
1155
+ merchant_volume?: number | null;
1156
+ }
1157
+ interface FeeRulePreviewResponse {
1158
+ /** Matched rule name, or null when only the default selection matched. */
1159
+ matched_rule: string | null;
1160
+ /** True when the matched branch sets no concrete fee (engine falls through to the legacy schedule/tier chain). */
1161
+ fell_through: boolean;
1162
+ /** Computed fee in minor units, or null when fell_through. */
1163
+ fee_amount: number | null;
1164
+ fee_currency: string | null;
1165
+ }
1145
1166
  interface ProjectCreateRequest {
1146
1167
  project_name: string;
1147
1168
  description?: string | null;
@@ -3026,6 +3047,15 @@ declare class FeeRulesManager {
3026
3047
  * (other shops' programs are left intact).
3027
3048
  */
3028
3049
  delete(merchantId: string, profileId?: string): Promise<void>;
3050
+ /**
3051
+ * Dry-run a candidate fee-rule program against a sample transaction.
3052
+ * Returns the matched rule name, whether it fell through, and the computed fee.
3053
+ * Does not persist anything.
3054
+ *
3055
+ * @param input - Candidate program + sample transaction fields.
3056
+ * @param merchantId - The merchant account ID.
3057
+ */
3058
+ preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse>;
3029
3059
  }
3030
3060
 
3031
3061
  /** View and revoke recurring payment mandates. */
@@ -4591,6 +4621,29 @@ declare const Webhooks: {
4591
4621
  verify(rawBody: string | Uint8Array, signatureHeader: string, secret: string): Promise<WebhookEvent>;
4592
4622
  };
4593
4623
 
4624
+ /** A single condition leaf in the builder's condition tree. */
4625
+ interface LeafNode {
4626
+ kind: 'leaf';
4627
+ lhs: string;
4628
+ comparison: EuclidComparisonType;
4629
+ value: EuclidValue;
4630
+ }
4631
+ /** An AND (`all`) or OR (`any`) group of condition nodes. */
4632
+ interface GroupNode {
4633
+ kind: 'all' | 'any';
4634
+ children: ConditionNode[];
4635
+ }
4636
+ type ConditionNode = LeafNode | GroupNode;
4637
+ /**
4638
+ * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;
4639
+ * string values (payment_method, connector, currency, card_network) tag as
4640
+ * `enum_variant`.
4641
+ */
4642
+ declare function leaf(lhs: string, comparison: EuclidComparisonType, value: string | number): LeafNode;
4643
+ /** AND group — all children must match. */
4644
+ declare function allOf(...children: ConditionNode[]): GroupNode;
4645
+ /** OR group — any child matching is enough. */
4646
+ declare function anyOf(...children: ConditionNode[]): GroupNode;
4594
4647
  /**
4595
4648
  * How a rule (or the default) prices a transaction. `fee_type` is inferred:
4596
4649
  * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.
@@ -4623,6 +4676,16 @@ interface FeeRuleConditions {
4623
4676
  amountGreaterThan?: number;
4624
4677
  /** `amount < n` (minor units). */
4625
4678
  amountLessThan?: number;
4679
+ /**
4680
+ * `merchant_volume == n` — the merchant's previous-month volume snapshot
4681
+ * (USD minor units). Combine with any other condition, e.g.
4682
+ * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.
4683
+ */
4684
+ merchantVolumeEquals?: number;
4685
+ /** `merchant_volume > n` (USD minor units). */
4686
+ merchantVolumeGreaterThan?: number;
4687
+ /** `merchant_volume < n` (USD minor units). */
4688
+ merchantVolumeLessThan?: number;
4626
4689
  }
4627
4690
  interface FeeRuleInput {
4628
4691
  name: string;
@@ -4630,8 +4693,35 @@ interface FeeRuleInput {
4630
4693
  when?: FeeRuleConditions;
4631
4694
  /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */
4632
4695
  rawConditions?: EuclidComparison[];
4696
+ /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */
4697
+ match?: ConditionNode;
4633
4698
  fee: FeeSpecInput;
4634
4699
  }
4700
+ /**
4701
+ * Decode a rule's `statements[]` back into a condition tree.
4702
+ *
4703
+ * Returns a tree that is **logically equivalent** to the source. It is
4704
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4705
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4706
+ * shape differs (still equivalent).
4707
+ */
4708
+ declare function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode;
4709
+ /**
4710
+ * Decode a stored program into the builder's editable model.
4711
+ *
4712
+ * Returns a tree that is **logically equivalent** to the source. It is
4713
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4714
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4715
+ * shape differs (still equivalent).
4716
+ */
4717
+ declare function programToTree(program: PlatformFeeProgram): {
4718
+ rules: {
4719
+ name: string;
4720
+ match: ConditionNode;
4721
+ fee: PlatformFeeOutput | null;
4722
+ }[];
4723
+ otherwise: PlatformFeeOutput | null;
4724
+ };
4635
4725
  /**
4636
4726
  * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire
4637
4727
  * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers
@@ -4804,4 +4894,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
4804
4894
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
4805
4895
  declare function shadowFor(style: SurfaceStyle): string;
4806
4896
 
4807
- export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
4897
+ export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ import {
22
22
  Search,
23
23
  Subscriptions,
24
24
  Webhooks,
25
+ allOf,
26
+ anyOf,
25
27
  applyBrandingVariables,
26
28
  buildBrandingExport,
27
29
  buttonPadValue,
@@ -37,14 +39,17 @@ import {
37
39
  inputPadValue,
38
40
  isDarkSurface,
39
41
  isHexColor,
42
+ leaf,
40
43
  logoDimensions,
41
44
  parseImportedBranding,
45
+ programToTree,
42
46
  radiusValue,
47
+ ruleMatchToTree,
43
48
  sanitizeCustomCss,
44
49
  shadowFor,
45
50
  surfacePadValue,
46
51
  verticalGapValue
47
- } from "./chunk-NNSPBDYP.js";
52
+ } from "./chunk-SX46W7E4.js";
48
53
  export {
49
54
  Analytics,
50
55
  AnalyticsDashboard,
@@ -69,6 +74,8 @@ export {
69
74
  Search,
70
75
  Subscriptions,
71
76
  Webhooks,
77
+ allOf,
78
+ anyOf,
72
79
  applyBrandingVariables,
73
80
  buildBrandingExport,
74
81
  buttonPadValue,
@@ -84,9 +91,12 @@ export {
84
91
  inputPadValue,
85
92
  isDarkSurface,
86
93
  isHexColor,
94
+ leaf,
87
95
  logoDimensions,
88
96
  parseImportedBranding,
97
+ programToTree,
89
98
  radiusValue,
99
+ ruleMatchToTree,
90
100
  sanitizeCustomCss,
91
101
  shadowFor,
92
102
  surfacePadValue,
package/dist/internal.cjs CHANGED
@@ -55,6 +55,8 @@ __export(internal_exports, {
55
55
  Search: () => Search,
56
56
  Subscriptions: () => Subscriptions,
57
57
  Webhooks: () => Webhooks,
58
+ allOf: () => allOf,
59
+ anyOf: () => anyOf,
58
60
  applyBrandingVariables: () => applyBrandingVariables,
59
61
  buildBrandingExport: () => buildBrandingExport,
60
62
  buttonPadValue: () => buttonPadValue,
@@ -70,9 +72,12 @@ __export(internal_exports, {
70
72
  inputPadValue: () => inputPadValue,
71
73
  isDarkSurface: () => isDarkSurface,
72
74
  isHexColor: () => isHexColor,
75
+ leaf: () => leaf,
73
76
  logoDimensions: () => logoDimensions,
74
77
  parseImportedBranding: () => parseImportedBranding,
78
+ programToTree: () => programToTree,
75
79
  radiusValue: () => radiusValue,
80
+ ruleMatchToTree: () => ruleMatchToTree,
76
81
  sanitizeCustomCss: () => sanitizeCustomCss,
77
82
  shadowFor: () => shadowFor,
78
83
  surfacePadValue: () => surfacePadValue,
@@ -809,6 +814,20 @@ var FeeRulesManager = class {
809
814
  query: { merchant_id: merchantId, profile_id: profileId }
810
815
  });
811
816
  }
817
+ /**
818
+ * Dry-run a candidate fee-rule program against a sample transaction.
819
+ * Returns the matched rule name, whether it fell through, and the computed fee.
820
+ * Does not persist anything.
821
+ *
822
+ * @param input - Candidate program + sample transaction fields.
823
+ * @param merchantId - The merchant account ID.
824
+ */
825
+ async preview(input, merchantId) {
826
+ return this.request("POST", "/merchant-fees/rules/preview", {
827
+ body: input,
828
+ query: { merchant_id: merchantId }
829
+ });
830
+ }
812
831
  };
813
832
 
814
833
  // src/resources/mandates.ts
@@ -3255,6 +3274,16 @@ var Delopay = class {
3255
3274
  Delopay.webhooks = Webhooks;
3256
3275
 
3257
3276
  // src/feeProgram.ts
3277
+ function leaf(lhs, comparison, value) {
3278
+ const tagged = typeof value === "number" ? { type: "number", value } : { type: "enum_variant", value };
3279
+ return { kind: "leaf", lhs, comparison, value: tagged };
3280
+ }
3281
+ function allOf(...children) {
3282
+ return { kind: "all", children };
3283
+ }
3284
+ function anyOf(...children) {
3285
+ return { kind: "any", children };
3286
+ }
3258
3287
  function toFeeOutput(spec) {
3259
3288
  const hasPct = spec.percentage != null;
3260
3289
  const hasFlat = spec.flat != null;
@@ -3287,9 +3316,83 @@ function buildConditions(when = {}, raw = []) {
3287
3316
  if (when.amountLessThan != null) {
3288
3317
  out.push(numberCondition("amount", "less_than", when.amountLessThan));
3289
3318
  }
3319
+ if (when.merchantVolumeEquals != null) {
3320
+ out.push(numberCondition("merchant_volume", "equal", when.merchantVolumeEquals));
3321
+ }
3322
+ if (when.merchantVolumeGreaterThan != null) {
3323
+ out.push(numberCondition("merchant_volume", "greater_than", when.merchantVolumeGreaterThan));
3324
+ }
3325
+ if (when.merchantVolumeLessThan != null) {
3326
+ out.push(numberCondition("merchant_volume", "less_than", when.merchantVolumeLessThan));
3327
+ }
3290
3328
  out.push(...raw);
3291
3329
  return out;
3292
3330
  }
3331
+ function leafToComparison(node) {
3332
+ return { lhs: node.lhs, comparison: node.comparison, value: node.value, metadata: {} };
3333
+ }
3334
+ function normalizeNode(node) {
3335
+ if (node.kind === "leaf") return node;
3336
+ const children = node.children.map(normalizeNode);
3337
+ const flat = [];
3338
+ for (const c of children) {
3339
+ if (c.kind === node.kind) flat.push(...c.children);
3340
+ else flat.push(c);
3341
+ }
3342
+ if (flat.length === 1) return flat[0];
3343
+ return { kind: node.kind, children: flat };
3344
+ }
3345
+ function toStatement(node) {
3346
+ if (node.kind === "leaf") return { condition: [leafToComparison(node)], nested: null };
3347
+ if (node.kind === "any") {
3348
+ return { condition: [], nested: node.children.map(toStatement) };
3349
+ }
3350
+ const leaves = node.children.filter((c) => c.kind === "leaf");
3351
+ const groups = node.children.filter((c) => c.kind !== "leaf");
3352
+ const condition = leaves.map(leafToComparison);
3353
+ if (groups.length === 0) return { condition, nested: null };
3354
+ const [first, ...rest] = groups;
3355
+ const nested = first.children.map((branch) => toStatement(normalizeNode(allOf(branch, ...rest))));
3356
+ return { condition, nested };
3357
+ }
3358
+ function assertNoEmptyAnyOf(node) {
3359
+ if (node.kind === "leaf") return;
3360
+ if (node.kind === "any" && node.children.length === 0) {
3361
+ throw new Error("feeProgram: an anyOf() group must have at least one condition");
3362
+ }
3363
+ node.children.forEach(assertNoEmptyAnyOf);
3364
+ }
3365
+ function encodeStatements(match) {
3366
+ const m = normalizeNode(match);
3367
+ if (m.kind === "any") return m.children.map(toStatement);
3368
+ return [toStatement(m)];
3369
+ }
3370
+ function comparisonToLeaf(c) {
3371
+ return { kind: "leaf", lhs: c.lhs, comparison: c.comparison, value: c.value };
3372
+ }
3373
+ function statementToNode(stmt) {
3374
+ const leaves = stmt.condition.map(comparisonToLeaf);
3375
+ if (stmt.nested && stmt.nested.length > 0) {
3376
+ const orNode = anyOf(...stmt.nested.map(statementToNode));
3377
+ if (leaves.length === 0) return orNode;
3378
+ return allOf(...leaves, orNode);
3379
+ }
3380
+ return leaves.length === 1 ? leaves[0] : allOf(...leaves);
3381
+ }
3382
+ function ruleMatchToTree(statements) {
3383
+ if (statements.length === 1) return normalizeNode(statementToNode(statements[0]));
3384
+ return normalizeNode(anyOf(...statements.map(statementToNode)));
3385
+ }
3386
+ function programToTree(program) {
3387
+ return {
3388
+ rules: program.rules.map((r) => ({
3389
+ name: r.name,
3390
+ match: ruleMatchToTree(r.statements),
3391
+ fee: r.connectorSelection.fee ?? null
3392
+ })),
3393
+ otherwise: program.defaultSelection.fee ?? null
3394
+ };
3395
+ }
3293
3396
  var FeeProgramBuilder = class {
3294
3397
  constructor() {
3295
3398
  this.rules = [];
@@ -3297,10 +3400,12 @@ var FeeProgramBuilder = class {
3297
3400
  }
3298
3401
  /** Append a rule. Provided `when`/`rawConditions` are ANDed. */
3299
3402
  rule(input) {
3403
+ if (input.match) assertNoEmptyAnyOf(input.match);
3404
+ const statements = input.match ? encodeStatements(input.match) : [{ condition: buildConditions(input.when, input.rawConditions) }];
3300
3405
  this.rules.push({
3301
3406
  name: input.name,
3302
3407
  connectorSelection: { fee: toFeeOutput(input.fee) },
3303
- statements: [{ condition: buildConditions(input.when, input.rawConditions) }]
3408
+ statements
3304
3409
  });
3305
3410
  return this;
3306
3411
  }
@@ -4399,6 +4504,17 @@ var PlatformFeeRulesManager = class {
4399
4504
  query: { merchant_id: merchantId, profile_id: profileId }
4400
4505
  });
4401
4506
  }
4507
+ /**
4508
+ * Dry-run a candidate fee-rule program against a sample transaction.
4509
+ * Returns the matched rule name, whether it fell through, and the computed fee.
4510
+ * Does not persist anything.
4511
+ */
4512
+ async preview(input, merchantId) {
4513
+ return this.request("POST", "/admin/fees/rules/preview", {
4514
+ body: input,
4515
+ query: { merchant_id: merchantId }
4516
+ });
4517
+ }
4402
4518
  };
4403
4519
 
4404
4520
  // src/internal/client.ts
@@ -4456,6 +4572,8 @@ var DelopayInternal = class extends Delopay {
4456
4572
  Search,
4457
4573
  Subscriptions,
4458
4574
  Webhooks,
4575
+ allOf,
4576
+ anyOf,
4459
4577
  applyBrandingVariables,
4460
4578
  buildBrandingExport,
4461
4579
  buttonPadValue,
@@ -4471,9 +4589,12 @@ var DelopayInternal = class extends Delopay {
4471
4589
  inputPadValue,
4472
4590
  isDarkSurface,
4473
4591
  isHexColor,
4592
+ leaf,
4474
4593
  logoDimensions,
4475
4594
  parseImportedBranding,
4595
+ programToTree,
4476
4596
  radiusValue,
4597
+ ruleMatchToTree,
4477
4598
  sanitizeCustomCss,
4478
4599
  shadowFor,
4479
4600
  surfacePadValue,