@merchi/sdk 1.40.2
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/.eslintrc.cjs +43 -0
- package/.turbo/turbo-build.log +1 -0
- package/.turbo/turbo-test.log +849 -0
- package/LICENSE +21 -0
- package/README.md +244 -0
- package/coverage/clover.xml +5057 -0
- package/coverage/coverage-final.json +133 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +191 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/constants/auto_assign_production_on_actions.ts.html +103 -0
- package/coverage/lcov-report/src/constants/call_to_actions.ts.html +127 -0
- package/coverage/lcov-report/src/constants/discount_types.ts.html +100 -0
- package/coverage/lcov-report/src/constants/domain_types.ts.html +121 -0
- package/coverage/lcov-report/src/constants/errors.ts.html +181 -0
- package/coverage/lcov-report/src/constants/event_types.ts.html +100 -0
- package/coverage/lcov-report/src/constants/field_types.ts.html +133 -0
- package/coverage/lcov-report/src/constants/index.html +551 -0
- package/coverage/lcov-report/src/constants/index.ts.html +238 -0
- package/coverage/lcov-report/src/constants/input_types.ts.html +124 -0
- package/coverage/lcov-report/src/constants/inventory_statuses.ts.html +103 -0
- package/coverage/lcov-report/src/constants/invoice_types.ts.html +100 -0
- package/coverage/lcov-report/src/constants/item_types.ts.html +100 -0
- package/coverage/lcov-report/src/constants/job/drafting_status.ts.html +106 -0
- package/coverage/lcov-report/src/constants/job/index.html +176 -0
- package/coverage/lcov-report/src/constants/job/payment_status.ts.html +106 -0
- package/coverage/lcov-report/src/constants/job/production_status.ts.html +121 -0
- package/coverage/lcov-report/src/constants/job/shipment_status.ts.html +118 -0
- package/coverage/lcov-report/src/constants/job/supply_chain_request_status.ts.html +103 -0
- package/coverage/lcov-report/src/constants/job_priorities.ts.html +103 -0
- package/coverage/lcov-report/src/constants/job_status.ts.html +232 -0
- package/coverage/lcov-report/src/constants/job_types.ts.html +133 -0
- package/coverage/lcov-report/src/constants/notification_sections.ts.html +124 -0
- package/coverage/lcov-report/src/constants/notification_types.ts.html +385 -0
- package/coverage/lcov-report/src/constants/notification_urgencies.ts.html +106 -0
- package/coverage/lcov-report/src/constants/payment_types.ts.html +115 -0
- package/coverage/lcov-report/src/constants/platform.ts.html +103 -0
- package/coverage/lcov-report/src/constants/product_types.ts.html +163 -0
- package/coverage/lcov-report/src/constants/rights.ts.html +100 -0
- package/coverage/lcov-report/src/constants/robots_meta_directives.ts.html +118 -0
- package/coverage/lcov-report/src/constants/roles.ts.html +223 -0
- package/coverage/lcov-report/src/constants/shipment_companies.ts.html +142 -0
- package/coverage/lcov-report/src/constants/shipment_services.ts.html +94 -0
- package/coverage/lcov-report/src/constants/system_roles.ts.html +94 -0
- package/coverage/lcov-report/src/constants/theme_status.ts.html +100 -0
- package/coverage/lcov-report/src/constants/user_types.ts.html +136 -0
- package/coverage/lcov-report/src/constants/white_label_accessibilities.ts.html +103 -0
- package/coverage/lcov-report/src/cookie.ts.html +133 -0
- package/coverage/lcov-report/src/entities/address.ts.html +280 -0
- package/coverage/lcov-report/src/entities/agent_conversation.ts.html +202 -0
- package/coverage/lcov-report/src/entities/agent_skill.ts.html +382 -0
- package/coverage/lcov-report/src/entities/agent_skill_approval.ts.html +163 -0
- package/coverage/lcov-report/src/entities/agent_skill_version.ts.html +277 -0
- package/coverage/lcov-report/src/entities/agent_token_usage.ts.html +349 -0
- package/coverage/lcov-report/src/entities/assignment.ts.html +382 -0
- package/coverage/lcov-report/src/entities/automatic_payment_relationship.ts.html +172 -0
- package/coverage/lcov-report/src/entities/bank.ts.html +220 -0
- package/coverage/lcov-report/src/entities/cart.ts.html +391 -0
- package/coverage/lcov-report/src/entities/cart_item.ts.html +340 -0
- package/coverage/lcov-report/src/entities/cart_shipment_group.ts.html +148 -0
- package/coverage/lcov-report/src/entities/cart_shipment_quote.ts.html +184 -0
- package/coverage/lcov-report/src/entities/category.ts.html +262 -0
- package/coverage/lcov-report/src/entities/company.ts.html +1276 -0
- package/coverage/lcov-report/src/entities/company_invitation.ts.html +184 -0
- package/coverage/lcov-report/src/entities/country_tax.ts.html +223 -0
- package/coverage/lcov-report/src/entities/discount.ts.html +235 -0
- package/coverage/lcov-report/src/entities/discount_group.ts.html +214 -0
- package/coverage/lcov-report/src/entities/domain.ts.html +3349 -0
- package/coverage/lcov-report/src/entities/domain_chat_settings.ts.html +331 -0
- package/coverage/lcov-report/src/entities/domain_invitation.ts.html +193 -0
- package/coverage/lcov-report/src/entities/domain_tag.ts.html +211 -0
- package/coverage/lcov-report/src/entities/draft.ts.html +322 -0
- package/coverage/lcov-report/src/entities/draft_comment.ts.html +274 -0
- package/coverage/lcov-report/src/entities/draft_preview.ts.html +196 -0
- package/coverage/lcov-report/src/entities/draft_preview_layer.ts.html +148 -0
- package/coverage/lcov-report/src/entities/draft_template.ts.html +328 -0
- package/coverage/lcov-report/src/entities/email_address.ts.html +157 -0
- package/coverage/lcov-report/src/entities/email_counter.ts.html +145 -0
- package/coverage/lcov-report/src/entities/enrolled_domain.ts.html +205 -0
- package/coverage/lcov-report/src/entities/exchange_rate.ts.html +151 -0
- package/coverage/lcov-report/src/entities/file.ts.html +580 -0
- package/coverage/lcov-report/src/entities/index.html +1271 -0
- package/coverage/lcov-report/src/entities/internal_tag.ts.html +238 -0
- package/coverage/lcov-report/src/entities/inventory.ts.html +274 -0
- package/coverage/lcov-report/src/entities/inventory_group.ts.html +193 -0
- package/coverage/lcov-report/src/entities/inventory_unit_variation.ts.html +172 -0
- package/coverage/lcov-report/src/entities/invoice.ts.html +661 -0
- package/coverage/lcov-report/src/entities/item.ts.html +262 -0
- package/coverage/lcov-report/src/entities/job.ts.html +1288 -0
- package/coverage/lcov-report/src/entities/job_comment.ts.html +244 -0
- package/coverage/lcov-report/src/entities/job_note.ts.html +205 -0
- package/coverage/lcov-report/src/entities/job_operation_log.ts.html +208 -0
- package/coverage/lcov-report/src/entities/matching_inventory.ts.html +172 -0
- package/coverage/lcov-report/src/entities/notification.ts.html +403 -0
- package/coverage/lcov-report/src/entities/payment.ts.html +316 -0
- package/coverage/lcov-report/src/entities/payment_device.ts.html +175 -0
- package/coverage/lcov-report/src/entities/phone_number.ts.html +193 -0
- package/coverage/lcov-report/src/entities/product.ts.html +1543 -0
- package/coverage/lcov-report/src/entities/product_form.ts.html +238 -0
- package/coverage/lcov-report/src/entities/product_form_version.ts.html +238 -0
- package/coverage/lcov-report/src/entities/product_review.ts.html +748 -0
- package/coverage/lcov-report/src/entities/production_comment.ts.html +244 -0
- package/coverage/lcov-report/src/entities/quote.ts.html +505 -0
- package/coverage/lcov-report/src/entities/quote_item.ts.html +298 -0
- package/coverage/lcov-report/src/entities/reminder.ts.html +307 -0
- package/coverage/lcov-report/src/entities/session.ts.html +169 -0
- package/coverage/lcov-report/src/entities/shipment.ts.html +673 -0
- package/coverage/lcov-report/src/entities/shipment_item.ts.html +130 -0
- package/coverage/lcov-report/src/entities/shipment_item_fulfillment.ts.html +130 -0
- package/coverage/lcov-report/src/entities/shipment_log.ts.html +196 -0
- package/coverage/lcov-report/src/entities/shipment_method.ts.html +268 -0
- package/coverage/lcov-report/src/entities/shipment_method_variation.ts.html +202 -0
- package/coverage/lcov-report/src/entities/short_url.ts.html +193 -0
- package/coverage/lcov-report/src/entities/subscription_plan.ts.html +304 -0
- package/coverage/lcov-report/src/entities/supply_domain.ts.html +166 -0
- package/coverage/lcov-report/src/entities/support_conversation.ts.html +280 -0
- package/coverage/lcov-report/src/entities/support_message.ts.html +175 -0
- package/coverage/lcov-report/src/entities/system_role.ts.html +136 -0
- package/coverage/lcov-report/src/entities/theme.ts.html +331 -0
- package/coverage/lcov-report/src/entities/theme_css_setting.ts.html +154 -0
- package/coverage/lcov-report/src/entities/user.ts.html +1369 -0
- package/coverage/lcov-report/src/entities/user_company.ts.html +166 -0
- package/coverage/lcov-report/src/entities/variation.ts.html +277 -0
- package/coverage/lcov-report/src/entities/variation_field.ts.html +889 -0
- package/coverage/lcov-report/src/entities/variation_fields_option.ts.html +406 -0
- package/coverage/lcov-report/src/entities/variation_option.ts.html +259 -0
- package/coverage/lcov-report/src/entities/variations_group.ts.html +208 -0
- package/coverage/lcov-report/src/entity.ts.html +3379 -0
- package/coverage/lcov-report/src/index.html +221 -0
- package/coverage/lcov-report/src/index.ts.html +652 -0
- package/coverage/lcov-report/src/merchi.ts.html +1420 -0
- package/coverage/lcov-report/src/pricing/discount.ts.html +136 -0
- package/coverage/lcov-report/src/pricing/estimate.ts.html +1015 -0
- package/coverage/lcov-report/src/pricing/index.html +206 -0
- package/coverage/lcov-report/src/pricing/index.ts.html +106 -0
- package/coverage/lcov-report/src/pricing/inventory.ts.html +352 -0
- package/coverage/lcov-report/src/pricing/matrix.ts.html +736 -0
- package/coverage/lcov-report/src/pricing/round.ts.html +166 -0
- package/coverage/lcov-report/src/pricing/visibility.ts.html +418 -0
- package/coverage/lcov-report/src/request.ts.html +673 -0
- package/coverage/lcov-report/src/test_util.ts.html +139 -0
- package/coverage/lcov-report/src/toasts.ts.html +187 -0
- package/coverage/lcov-report/src/util/float.ts.html +121 -0
- package/coverage/lcov-report/src/util/index.html +161 -0
- package/coverage/lcov-report/src/util/index.ts.html +106 -0
- package/coverage/lcov-report/src/util/query_string.ts.html +124 -0
- package/coverage/lcov-report/src/util/validation.ts.html +91 -0
- package/coverage/lcov-report/src/uuid.ts.html +109 -0
- package/coverage/lcov.info +7758 -0
- package/dist/constants/auto_assign_production_on_actions.js +7 -0
- package/dist/constants/call_to_actions.js +15 -0
- package/dist/constants/call_to_actions.test.js +4 -0
- package/dist/constants/discount_types.js +6 -0
- package/dist/constants/discount_types.test.js +4 -0
- package/dist/constants/domain_types.js +13 -0
- package/dist/constants/domain_types.test.js +4 -0
- package/dist/constants/errors.js +32 -0
- package/dist/constants/event_types.js +6 -0
- package/dist/constants/event_types.test.js +4 -0
- package/dist/constants/field_types.js +17 -0
- package/dist/constants/field_types.test.js +4 -0
- package/dist/constants/index.js +25 -0
- package/dist/constants/input_types.js +14 -0
- package/dist/constants/input_types.test.js +4 -0
- package/dist/constants/inventory_status.test.js +4 -0
- package/dist/constants/inventory_statuses.js +7 -0
- package/dist/constants/invoice_types.js +6 -0
- package/dist/constants/invoice_types.test.js +4 -0
- package/dist/constants/item_types.js +6 -0
- package/dist/constants/item_types.test.js +4 -0
- package/dist/constants/job/drafting_status.js +8 -0
- package/dist/constants/job/drafting_status.test.js +4 -0
- package/dist/constants/job/payment_status.js +8 -0
- package/dist/constants/job/payment_status.test.js +4 -0
- package/dist/constants/job/production_status.js +13 -0
- package/dist/constants/job/production_status.test.js +4 -0
- package/dist/constants/job/shipment_status.js +12 -0
- package/dist/constants/job/shipment_status.test.js +4 -0
- package/dist/constants/job/supply_chain_request_status.js +7 -0
- package/dist/constants/job/supply_chain_request_status.test.js +4 -0
- package/dist/constants/job_priorities.js +7 -0
- package/dist/constants/job_priorities.test.js +4 -0
- package/dist/constants/job_status.js +50 -0
- package/dist/constants/job_status.test.js +4 -0
- package/dist/constants/job_types.js +17 -0
- package/dist/constants/job_types.test.js +4 -0
- package/dist/constants/notification_sections.js +14 -0
- package/dist/constants/notification_sections.test.js +4 -0
- package/dist/constants/notification_types.js +101 -0
- package/dist/constants/notification_types.test.js +4 -0
- package/dist/constants/notification_urgencies.js +7 -0
- package/dist/constants/notification_urgencies.test.js +4 -0
- package/dist/constants/payment_types.js +11 -0
- package/dist/constants/payment_types.test.js +4 -0
- package/dist/constants/platform.js +5 -0
- package/dist/constants/platform.test.js +8 -0
- package/dist/constants/product_types.js +27 -0
- package/dist/constants/product_types.test.js +4 -0
- package/dist/constants/rights.js +6 -0
- package/dist/constants/rights.test.js +4 -0
- package/dist/constants/robots_meta_directives.js +11 -0
- package/dist/constants/robots_meta_directives.test.js +4 -0
- package/dist/constants/roles.js +64 -0
- package/dist/constants/roles.test.js +4 -0
- package/dist/constants/shipment_companies.js +20 -0
- package/dist/constants/shipment_companies.test.js +4 -0
- package/dist/constants/shipment_services.js +4 -0
- package/dist/constants/shipment_services.test.js +4 -0
- package/dist/constants/system_roles.js +4 -0
- package/dist/constants/system_roles.test.js +4 -0
- package/dist/constants/theme_status.js +6 -0
- package/dist/constants/theme_status.test.js +4 -0
- package/dist/constants/user_types.js +18 -0
- package/dist/constants/user_types.test.js +4 -0
- package/dist/constants/white_label_accessibilities.js +6 -0
- package/dist/constants/white_label_accessibilities.test.js +4 -0
- package/dist/cookie.js +15 -0
- package/dist/cookie.test.js +10 -0
- package/dist/entities/address.js +104 -0
- package/dist/entities/address.test.js +6 -0
- package/dist/entities/agent_conversation.js +78 -0
- package/dist/entities/agent_conversation.test.js +6 -0
- package/dist/entities/agent_skill.js +133 -0
- package/dist/entities/agent_skill.test.js +11 -0
- package/dist/entities/agent_skill_approval.js +61 -0
- package/dist/entities/agent_skill_version.js +99 -0
- package/dist/entities/agent_token_analytics.js +1 -0
- package/dist/entities/agent_token_usage.js +127 -0
- package/dist/entities/agent_token_usage.test.js +6 -0
- package/dist/entities/assignment.js +135 -0
- package/dist/entities/assignment.test.js +30 -0
- package/dist/entities/automatic_payment_relationship.js +65 -0
- package/dist/entities/automatic_payment_relationship.test.js +6 -0
- package/dist/entities/bank.js +85 -0
- package/dist/entities/bank.test.js +6 -0
- package/dist/entities/cart.js +173 -0
- package/dist/entities/cart.test.js +51 -0
- package/dist/entities/cart_item.js +125 -0
- package/dist/entities/cart_item.test.js +28 -0
- package/dist/entities/cart_shipment_group.js +53 -0
- package/dist/entities/cart_shipment_quote.js +70 -0
- package/dist/entities/category.js +101 -0
- package/dist/entities/category.test.js +52 -0
- package/dist/entities/company.js +509 -0
- package/dist/entities/company.test.js +6 -0
- package/dist/entities/company_invitation.js +70 -0
- package/dist/entities/company_invitation.test.js +6 -0
- package/dist/entities/country_tax.js +80 -0
- package/dist/entities/country_tax.test.js +11 -0
- package/dist/entities/discount.js +89 -0
- package/dist/entities/discount.test.js +34 -0
- package/dist/entities/discount_group.js +80 -0
- package/dist/entities/discount_group.test.js +6 -0
- package/dist/entities/domain.js +567 -0
- package/dist/entities/domain.test.js +356 -0
- package/dist/entities/domain_chat_settings.js +134 -0
- package/dist/entities/domain_chat_settings.test.js +15 -0
- package/dist/entities/domain_invitation.js +74 -0
- package/dist/entities/domain_invitation.test.js +6 -0
- package/dist/entities/domain_tag.js +77 -0
- package/dist/entities/domain_tag.test.js +6 -0
- package/dist/entities/draft.js +122 -0
- package/dist/entities/draft.test.js +26 -0
- package/dist/entities/draft_comment.js +107 -0
- package/dist/entities/draft_comment.test.js +6 -0
- package/dist/entities/draft_preview.js +74 -0
- package/dist/entities/draft_preview.test.js +36 -0
- package/dist/entities/draft_preview_layer.js +54 -0
- package/dist/entities/draft_preview_layer.test.js +6 -0
- package/dist/entities/draft_template.js +119 -0
- package/dist/entities/draft_template.test.js +12 -0
- package/dist/entities/email_address.js +56 -0
- package/dist/entities/email_address.test.js +6 -0
- package/dist/entities/email_counter.js +53 -0
- package/dist/entities/email_counter.test.js +6 -0
- package/dist/entities/enrolled_domain.js +74 -0
- package/dist/entities/enrolled_domain.test.js +6 -0
- package/dist/entities/exchange_rate.js +56 -0
- package/dist/entities/exchange_rate.test.js +6 -0
- package/dist/entities/file.js +218 -0
- package/dist/entities/file.test.js +38 -0
- package/dist/entities/internal_tag.js +84 -0
- package/dist/entities/internal_tag.test.js +6 -0
- package/dist/entities/inventory.js +97 -0
- package/dist/entities/inventory.test.js +22 -0
- package/dist/entities/inventory_group.js +69 -0
- package/dist/entities/inventory_group.test.js +6 -0
- package/dist/entities/inventory_unit_variation.js +61 -0
- package/dist/entities/inventory_unit_variation.test.js +6 -0
- package/dist/entities/invoice.js +268 -0
- package/dist/entities/invoice.test.js +45 -0
- package/dist/entities/item.js +96 -0
- package/dist/entities/item.test.js +17 -0
- package/dist/entities/job.js +519 -0
- package/dist/entities/job.test.js +83 -0
- package/dist/entities/job_comment.js +94 -0
- package/dist/entities/job_comment.test.js +6 -0
- package/dist/entities/job_note.js +78 -0
- package/dist/entities/job_operation_log.js +82 -0
- package/dist/entities/job_operation_log.test.js +6 -0
- package/dist/entities/matching_inventory.js +63 -0
- package/dist/entities/notification.js +163 -0
- package/dist/entities/notification.test.js +51 -0
- package/dist/entities/payment.js +122 -0
- package/dist/entities/payment.test.js +22 -0
- package/dist/entities/payment_device.js +65 -0
- package/dist/entities/payment_device.test.js +6 -0
- package/dist/entities/phone_number.js +72 -0
- package/dist/entities/phone_number.test.js +6 -0
- package/dist/entities/product.js +619 -0
- package/dist/entities/product.test.js +720 -0
- package/dist/entities/product_form.js +92 -0
- package/dist/entities/product_form_version.js +95 -0
- package/dist/entities/product_review.js +234 -0
- package/dist/entities/production_comment.js +94 -0
- package/dist/entities/production_comment.test.js +6 -0
- package/dist/entities/quote.js +168 -0
- package/dist/entities/quote.test.js +86 -0
- package/dist/entities/quote_item.js +99 -0
- package/dist/entities/quote_item.test.js +40 -0
- package/dist/entities/reminder.js +120 -0
- package/dist/entities/reminder.test.js +14 -0
- package/dist/entities/session.js +63 -0
- package/dist/entities/session.test.js +6 -0
- package/dist/entities/shipment.js +256 -0
- package/dist/entities/shipment.test.js +20 -0
- package/dist/entities/shipment_item.js +45 -0
- package/dist/entities/shipment_item.test.js +6 -0
- package/dist/entities/shipment_item_fulfillment.js +46 -0
- package/dist/entities/shipment_item_fulfillment.test.js +6 -0
- package/dist/entities/shipment_log.js +75 -0
- package/dist/entities/shipment_method.js +104 -0
- package/dist/entities/shipment_method.test.js +6 -0
- package/dist/entities/shipment_method_variation.js +77 -0
- package/dist/entities/shipment_method_variation.test.js +6 -0
- package/dist/entities/short_url.js +73 -0
- package/dist/entities/short_url.test.js +6 -0
- package/dist/entities/subscription_plan.js +122 -0
- package/dist/entities/subscription_plan.test.js +6 -0
- package/dist/entities/supply_domain.js +62 -0
- package/dist/entities/supply_domain.test.js +6 -0
- package/dist/entities/support_conversation.js +106 -0
- package/dist/entities/support_conversation.test.js +6 -0
- package/dist/entities/support_message.js +66 -0
- package/dist/entities/support_message.test.js +6 -0
- package/dist/entities/system_role.js +49 -0
- package/dist/entities/system_role.test.js +6 -0
- package/dist/entities/theme.js +125 -0
- package/dist/entities/theme.test.js +35 -0
- package/dist/entities/theme_css_setting.js +57 -0
- package/dist/entities/theme_css_setting.test.js +6 -0
- package/dist/entities/user.js +508 -0
- package/dist/entities/user.test.js +134 -0
- package/dist/entities/user_company.js +62 -0
- package/dist/entities/user_company.test.js +6 -0
- package/dist/entities/variation.js +108 -0
- package/dist/entities/variation.test.js +6 -0
- package/dist/entities/variation_field.js +381 -0
- package/dist/entities/variation_field.test.js +69 -0
- package/dist/entities/variation_fields_option.js +153 -0
- package/dist/entities/variation_fields_option.test.js +43 -0
- package/dist/entities/variation_option.js +104 -0
- package/dist/entities/variation_option.test.js +6 -0
- package/dist/entities/variations_group.js +79 -0
- package/dist/entities/variations_group.test.js +6 -0
- package/dist/entity.js +950 -0
- package/dist/index.js +86 -0
- package/dist/merchi.js +296 -0
- package/dist/merchi.test.js +21 -0
- package/dist/pricing/discount.js +11 -0
- package/dist/pricing/discount.test.js +35 -0
- package/dist/pricing/estimate.js +335 -0
- package/dist/pricing/estimate.test.js +403 -0
- package/dist/pricing/golden.test.js +61 -0
- package/dist/pricing/index.js +7 -0
- package/dist/pricing/index.test.js +8 -0
- package/dist/pricing/inventory.js +238 -0
- package/dist/pricing/inventory.test.js +188 -0
- package/dist/pricing/matrix.js +245 -0
- package/dist/pricing/matrix.test.js +437 -0
- package/dist/pricing/round.js +29 -0
- package/dist/pricing/round.test.js +27 -0
- package/dist/pricing/types.js +1 -0
- package/dist/pricing/visibility.js +227 -0
- package/dist/pricing/visibility.test.js +210 -0
- package/dist/request.js +169 -0
- package/dist/request.test.js +70 -0
- package/dist/test_util.js +17 -0
- package/dist/toasts.js +14 -0
- package/dist/toasts.test.js +28 -0
- package/dist/util/float.js +34 -0
- package/dist/util/index.js +3 -0
- package/dist/util/query_string.js +13 -0
- package/dist/util/query_string.test.js +6 -0
- package/dist/util/validation.js +3 -0
- package/dist/util/validation.test.js +12 -0
- package/dist/uuid.js +8 -0
- package/dist/uuid.test.js +11 -0
- package/jest.config.js +23 -0
- package/merchi_sdk_ts-1.13.1.tgz +0 -0
- package/package.json +41 -0
- package/src/constants/auto_assign_production_on_actions.ts +6 -0
- package/src/constants/call_to_actions.test.ts +5 -0
- package/src/constants/call_to_actions.ts +14 -0
- package/src/constants/discount_types.test.ts +5 -0
- package/src/constants/discount_types.ts +5 -0
- package/src/constants/domain_types.test.ts +5 -0
- package/src/constants/domain_types.ts +12 -0
- package/src/constants/errors.ts +32 -0
- package/src/constants/event_types.test.ts +5 -0
- package/src/constants/event_types.ts +5 -0
- package/src/constants/field_types.test.ts +5 -0
- package/src/constants/field_types.ts +16 -0
- package/src/constants/index.ts +51 -0
- package/src/constants/input_types.test.ts +5 -0
- package/src/constants/input_types.ts +13 -0
- package/src/constants/inventory_status.test.ts +5 -0
- package/src/constants/inventory_statuses.ts +6 -0
- package/src/constants/invoice_types.test.ts +5 -0
- package/src/constants/invoice_types.ts +5 -0
- package/src/constants/item_types.test.ts +5 -0
- package/src/constants/item_types.ts +5 -0
- package/src/constants/job/drafting_status.test.ts +5 -0
- package/src/constants/job/drafting_status.ts +7 -0
- package/src/constants/job/payment_status.test.ts +5 -0
- package/src/constants/job/payment_status.ts +7 -0
- package/src/constants/job/production_status.test.ts +5 -0
- package/src/constants/job/production_status.ts +12 -0
- package/src/constants/job/shipment_status.test.ts +5 -0
- package/src/constants/job/shipment_status.ts +11 -0
- package/src/constants/job/supply_chain_request_status.test.ts +5 -0
- package/src/constants/job/supply_chain_request_status.ts +6 -0
- package/src/constants/job_priorities.test.ts +5 -0
- package/src/constants/job_priorities.ts +6 -0
- package/src/constants/job_status.test.ts +5 -0
- package/src/constants/job_status.ts +49 -0
- package/src/constants/job_types.test.ts +5 -0
- package/src/constants/job_types.ts +16 -0
- package/src/constants/notification_sections.test.ts +5 -0
- package/src/constants/notification_sections.ts +13 -0
- package/src/constants/notification_types.test.ts +5 -0
- package/src/constants/notification_types.ts +100 -0
- package/src/constants/notification_urgencies.test.ts +5 -0
- package/src/constants/notification_urgencies.ts +7 -0
- package/src/constants/payment_types.test.ts +5 -0
- package/src/constants/payment_types.ts +10 -0
- package/src/constants/platform.test.ts +15 -0
- package/src/constants/platform.ts +6 -0
- package/src/constants/product_types.test.ts +6 -0
- package/src/constants/product_types.ts +26 -0
- package/src/constants/rights.test.ts +5 -0
- package/src/constants/rights.ts +5 -0
- package/src/constants/robots_meta_directives.test.ts +5 -0
- package/src/constants/robots_meta_directives.ts +11 -0
- package/src/constants/roles.test.ts +5 -0
- package/src/constants/roles.ts +46 -0
- package/src/constants/shipment_companies.test.ts +5 -0
- package/src/constants/shipment_companies.ts +19 -0
- package/src/constants/shipment_services.test.ts +5 -0
- package/src/constants/shipment_services.ts +3 -0
- package/src/constants/system_roles.test.ts +5 -0
- package/src/constants/system_roles.ts +3 -0
- package/src/constants/theme_status.test.ts +5 -0
- package/src/constants/theme_status.ts +5 -0
- package/src/constants/user_types.test.ts +5 -0
- package/src/constants/user_types.ts +17 -0
- package/src/constants/white_label_accessibilities.test.ts +5 -0
- package/src/constants/white_label_accessibilities.ts +6 -0
- package/src/cookie.test.ts +11 -0
- package/src/cookie.ts +16 -0
- package/src/entities/address.test.ts +7 -0
- package/src/entities/address.ts +65 -0
- package/src/entities/agent_conversation.test.ts +7 -0
- package/src/entities/agent_conversation.ts +39 -0
- package/src/entities/agent_skill.test.ts +13 -0
- package/src/entities/agent_skill.ts +99 -0
- package/src/entities/agent_skill_approval.ts +26 -0
- package/src/entities/agent_skill_version.ts +64 -0
- package/src/entities/agent_token_analytics.ts +49 -0
- package/src/entities/agent_token_usage.test.ts +7 -0
- package/src/entities/agent_token_usage.ts +88 -0
- package/src/entities/assignment.test.ts +39 -0
- package/src/entities/assignment.ts +99 -0
- package/src/entities/automatic_payment_relationship.test.ts +8 -0
- package/src/entities/automatic_payment_relationship.ts +29 -0
- package/src/entities/bank.test.ts +7 -0
- package/src/entities/bank.ts +45 -0
- package/src/entities/cart.test.ts +57 -0
- package/src/entities/cart.ts +102 -0
- package/src/entities/cart_item.test.ts +33 -0
- package/src/entities/cart_item.ts +85 -0
- package/src/entities/cart_shipment_group.ts +21 -0
- package/src/entities/cart_shipment_quote.ts +33 -0
- package/src/entities/category.test.ts +57 -0
- package/src/entities/category.ts +59 -0
- package/src/entities/company.test.ts +7 -0
- package/src/entities/company.ts +397 -0
- package/src/entities/company_invitation.test.ts +7 -0
- package/src/entities/company_invitation.ts +33 -0
- package/src/entities/country_tax.test.ts +13 -0
- package/src/entities/country_tax.ts +46 -0
- package/src/entities/discount.test.ts +36 -0
- package/src/entities/discount.ts +50 -0
- package/src/entities/discount_group.test.ts +7 -0
- package/src/entities/discount_group.ts +43 -0
- package/src/entities/domain.test.ts +393 -0
- package/src/entities/domain.ts +1088 -0
- package/src/entities/domain_chat_settings.test.ts +16 -0
- package/src/entities/domain_chat_settings.ts +82 -0
- package/src/entities/domain_invitation.test.ts +7 -0
- package/src/entities/domain_invitation.ts +36 -0
- package/src/entities/domain_tag.test.ts +7 -0
- package/src/entities/domain_tag.ts +42 -0
- package/src/entities/draft.test.ts +29 -0
- package/src/entities/draft.ts +79 -0
- package/src/entities/draft_comment.test.ts +7 -0
- package/src/entities/draft_comment.ts +63 -0
- package/src/entities/draft_preview.test.ts +42 -0
- package/src/entities/draft_preview.ts +37 -0
- package/src/entities/draft_preview_layer.test.ts +7 -0
- package/src/entities/draft_preview_layer.ts +21 -0
- package/src/entities/draft_template.test.ts +14 -0
- package/src/entities/draft_template.ts +81 -0
- package/src/entities/email_address.test.ts +7 -0
- package/src/entities/email_address.ts +24 -0
- package/src/entities/email_counter.test.ts +7 -0
- package/src/entities/email_counter.ts +20 -0
- package/src/entities/enrolled_domain.test.ts +7 -0
- package/src/entities/enrolled_domain.ts +40 -0
- package/src/entities/exchange_rate.test.ts +7 -0
- package/src/entities/exchange_rate.ts +22 -0
- package/src/entities/file.test.ts +43 -0
- package/src/entities/file.ts +165 -0
- package/src/entities/internal_tag.test.ts +7 -0
- package/src/entities/internal_tag.ts +51 -0
- package/src/entities/inventory.test.ts +28 -0
- package/src/entities/inventory.ts +63 -0
- package/src/entities/inventory_group.test.ts +7 -0
- package/src/entities/inventory_group.ts +36 -0
- package/src/entities/inventory_unit_variation.test.ts +7 -0
- package/src/entities/inventory_unit_variation.ts +29 -0
- package/src/entities/invoice.test.ts +50 -0
- package/src/entities/invoice.ts +192 -0
- package/src/entities/item.test.ts +19 -0
- package/src/entities/item.ts +59 -0
- package/src/entities/job.test.ts +95 -0
- package/src/entities/job.ts +401 -0
- package/src/entities/job_comment.test.ts +7 -0
- package/src/entities/job_comment.ts +53 -0
- package/src/entities/job_note.ts +40 -0
- package/src/entities/job_operation_log.test.ts +7 -0
- package/src/entities/job_operation_log.ts +41 -0
- package/src/entities/matching_inventory.ts +29 -0
- package/src/entities/notification.test.ts +58 -0
- package/src/entities/notification.ts +106 -0
- package/src/entities/payment.test.ts +27 -0
- package/src/entities/payment.ts +77 -0
- package/src/entities/payment_device.test.ts +7 -0
- package/src/entities/payment_device.ts +30 -0
- package/src/entities/phone_number.test.ts +7 -0
- package/src/entities/phone_number.ts +36 -0
- package/src/entities/product.test.ts +776 -0
- package/src/entities/product.ts +486 -0
- package/src/entities/product_form.ts +51 -0
- package/src/entities/product_form_version.ts +51 -0
- package/src/entities/product_review.ts +221 -0
- package/src/entities/production_comment.test.ts +7 -0
- package/src/entities/production_comment.ts +53 -0
- package/src/entities/quote.test.ts +98 -0
- package/src/entities/quote.ts +140 -0
- package/src/entities/quote_item.test.ts +50 -0
- package/src/entities/quote_item.ts +71 -0
- package/src/entities/reminder.test.ts +16 -0
- package/src/entities/reminder.ts +74 -0
- package/src/entities/session.test.ts +7 -0
- package/src/entities/session.ts +28 -0
- package/src/entities/shipment.test.ts +24 -0
- package/src/entities/shipment.ts +196 -0
- package/src/entities/shipment_item.test.ts +7 -0
- package/src/entities/shipment_item.ts +15 -0
- package/src/entities/shipment_item_fulfillment.test.ts +8 -0
- package/src/entities/shipment_item_fulfillment.ts +15 -0
- package/src/entities/shipment_log.ts +37 -0
- package/src/entities/shipment_method.test.ts +7 -0
- package/src/entities/shipment_method.ts +61 -0
- package/src/entities/shipment_method_variation.test.ts +7 -0
- package/src/entities/shipment_method_variation.ts +39 -0
- package/src/entities/short_url.test.ts +7 -0
- package/src/entities/short_url.ts +36 -0
- package/src/entities/subscription_plan.test.ts +7 -0
- package/src/entities/subscription_plan.ts +73 -0
- package/src/entities/supply_domain.test.ts +7 -0
- package/src/entities/supply_domain.ts +27 -0
- package/src/entities/support_conversation.test.ts +7 -0
- package/src/entities/support_conversation.ts +65 -0
- package/src/entities/support_message.test.ts +7 -0
- package/src/entities/support_message.ts +30 -0
- package/src/entities/system_role.test.ts +7 -0
- package/src/entities/system_role.ts +17 -0
- package/src/entities/theme.test.ts +38 -0
- package/src/entities/theme.ts +82 -0
- package/src/entities/theme_css_setting.test.ts +7 -0
- package/src/entities/theme_css_setting.ts +23 -0
- package/src/entities/user.test.ts +154 -0
- package/src/entities/user.ts +428 -0
- package/src/entities/user_company.test.ts +7 -0
- package/src/entities/user_company.ts +27 -0
- package/src/entities/variation.test.ts +7 -0
- package/src/entities/variation.ts +64 -0
- package/src/entities/variation_field.test.ts +76 -0
- package/src/entities/variation_field.ts +268 -0
- package/src/entities/variation_fields_option.test.ts +46 -0
- package/src/entities/variation_fields_option.ts +107 -0
- package/src/entities/variation_option.test.ts +7 -0
- package/src/entities/variation_option.ts +58 -0
- package/src/entities/variations_group.test.ts +7 -0
- package/src/entities/variations_group.ts +41 -0
- package/src/entity.ts +1098 -0
- package/src/index.ts +189 -0
- package/src/merchi.test.ts +25 -0
- package/src/merchi.ts +445 -0
- package/src/pricing/__fixtures__/conditional_field_hidden.json +112 -0
- package/src/pricing/__fixtures__/conditional_field_visible.json +113 -0
- package/src/pricing/__fixtures__/group_product.json +130 -0
- package/src/pricing/__fixtures__/non_selectable_number_field.json +108 -0
- package/src/pricing/__fixtures__/quantity_break_discount.json +104 -0
- package/src/pricing/__fixtures__/simple_selectable_field.json +110 -0
- package/src/pricing/discount.test.ts +47 -0
- package/src/pricing/discount.ts +17 -0
- package/src/pricing/estimate.test.ts +486 -0
- package/src/pricing/estimate.ts +310 -0
- package/src/pricing/golden.test.ts +51 -0
- package/src/pricing/index.test.ts +9 -0
- package/src/pricing/index.ts +7 -0
- package/src/pricing/inventory.test.ts +197 -0
- package/src/pricing/inventory.ts +89 -0
- package/src/pricing/matrix.test.ts +553 -0
- package/src/pricing/matrix.ts +217 -0
- package/src/pricing/round.test.ts +31 -0
- package/src/pricing/round.ts +27 -0
- package/src/pricing/types.ts +140 -0
- package/src/pricing/visibility.test.ts +223 -0
- package/src/pricing/visibility.ts +111 -0
- package/src/request.test.ts +79 -0
- package/src/request.ts +196 -0
- package/src/test_util.ts +18 -0
- package/src/toasts.test.ts +38 -0
- package/src/toasts.ts +34 -0
- package/src/util/float.ts +12 -0
- package/src/util/index.ts +7 -0
- package/src/util/query_string.test.ts +7 -0
- package/src/util/query_string.ts +13 -0
- package/src/util/validation.test.ts +16 -0
- package/src/util/validation.ts +2 -0
- package/src/uuid.test.ts +15 -0
- package/src/uuid.ts +8 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { estimateQuote } from './estimate.js';
|
|
13
|
+
var base = {
|
|
14
|
+
currency: 'AUD', taxPercent: 10,
|
|
15
|
+
product: { unitPrice: 10, minimumPrice: null, discountGroup: null },
|
|
16
|
+
fields: [], groupFields: [], hasGroups: false,
|
|
17
|
+
};
|
|
18
|
+
test('returns unsupported when rules flag it', function () {
|
|
19
|
+
var r = estimateQuote(__assign(__assign({}, base), { unsupported: 'group_buy_product' }), { quantity: 5, fieldValues: {} });
|
|
20
|
+
expect(r).toEqual({ unsupported: 'group_buy_product' });
|
|
21
|
+
});
|
|
22
|
+
test('simple linear price + tax', function () {
|
|
23
|
+
var r = estimateQuote(base, { quantity: 5, fieldValues: {} });
|
|
24
|
+
expect(r.cost).toBe(50);
|
|
25
|
+
expect(r.taxAmount).toBe(5);
|
|
26
|
+
expect(r.totalCost).toBe(55);
|
|
27
|
+
expect(r.costPerUnit).toBe(10);
|
|
28
|
+
expect(r.currency).toBe('AUD');
|
|
29
|
+
});
|
|
30
|
+
test('minimum price floor raises unit price', function () {
|
|
31
|
+
var rules = __assign(__assign({}, base), { product: { unitPrice: 10, minimumPrice: 80, discountGroup: null } });
|
|
32
|
+
var r = estimateQuote(rules, { quantity: 5, fieldValues: {} });
|
|
33
|
+
expect(r.cost).toBe(80);
|
|
34
|
+
});
|
|
35
|
+
test('quantity-break discount applied', function () {
|
|
36
|
+
var rules = __assign(__assign({}, base), { product: {
|
|
37
|
+
unitPrice: 10, minimumPrice: null,
|
|
38
|
+
discountGroup: { groupRestricted: false, discounts: [{ lowerLimit: 100, amount: 10 }] },
|
|
39
|
+
} });
|
|
40
|
+
var r = estimateQuote(rules, { quantity: 100, fieldValues: {} });
|
|
41
|
+
expect(r.cost).toBe(900);
|
|
42
|
+
});
|
|
43
|
+
test('selectable field option setup + unit cost', function () {
|
|
44
|
+
var rules = __assign(__assign({}, base), { fields: [{
|
|
45
|
+
id: 1, originalId: 1, position: 0, fieldType: 2, independent: true,
|
|
46
|
+
isSelectable: true, selectedBy: [],
|
|
47
|
+
variationCost: 0, variationUnitCost: 0,
|
|
48
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
49
|
+
options: [{
|
|
50
|
+
id: 101, originalId: 101, position: 0, default: false,
|
|
51
|
+
variationCost: 5, variationUnitCost: 0.5,
|
|
52
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
53
|
+
selectedBy: [],
|
|
54
|
+
}],
|
|
55
|
+
}] });
|
|
56
|
+
var r = estimateQuote(rules, { quantity: 10, fieldValues: { 1: { selectedOptionIds: [101] } } });
|
|
57
|
+
expect(r.cost).toBe(110); // 10*10 + 5 + 0.5*10
|
|
58
|
+
});
|
|
59
|
+
test('hidden conditional field is not costed', function () {
|
|
60
|
+
var rules = __assign(__assign({}, base), { fields: [{
|
|
61
|
+
id: 2, originalId: 2, position: 0, fieldType: 2, independent: true,
|
|
62
|
+
isSelectable: true, selectedBy: [999],
|
|
63
|
+
variationCost: 0, variationUnitCost: 0,
|
|
64
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
65
|
+
options: [{
|
|
66
|
+
id: 201, originalId: 201, position: 0, default: false,
|
|
67
|
+
variationCost: 7, variationUnitCost: 0,
|
|
68
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
69
|
+
selectedBy: [],
|
|
70
|
+
}],
|
|
71
|
+
}] });
|
|
72
|
+
var r = estimateQuote(rules, { quantity: 10, fieldValues: { 2: { selectedOptionIds: [201] } } });
|
|
73
|
+
expect(r.cost).toBe(100);
|
|
74
|
+
});
|
|
75
|
+
test('area field multiplies height/width rate cards when dimensions set', function () {
|
|
76
|
+
var rules = __assign(__assign({}, base), { product: { unitPrice: 1, minimumPrice: null, discountGroup: null }, fields: [{
|
|
77
|
+
id: 14, originalId: 14, position: 0, fieldType: 14, independent: true,
|
|
78
|
+
isSelectable: false, selectedBy: [],
|
|
79
|
+
variationCost: 0, variationUnitCost: 0,
|
|
80
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
81
|
+
areaUnit: 'mm',
|
|
82
|
+
heightVariationCost: 2, widthVariationCost: 2,
|
|
83
|
+
heightVariationUnitCost: 3, widthVariationUnitCost: 4,
|
|
84
|
+
heightVariationCostDiscountGroup: null,
|
|
85
|
+
heightVariationUnitCostDiscountGroup: null,
|
|
86
|
+
widthVariationCostDiscountGroup: null,
|
|
87
|
+
widthVariationUnitCostDiscountGroup: null,
|
|
88
|
+
options: [],
|
|
89
|
+
}] });
|
|
90
|
+
var empty = estimateQuote(rules, {
|
|
91
|
+
quantity: 1, fieldValues: { 14: { value: '' } },
|
|
92
|
+
});
|
|
93
|
+
expect(empty.cost).toBe(1);
|
|
94
|
+
var priced = estimateQuote(rules, {
|
|
95
|
+
quantity: 1, fieldValues: { 14: { value: '2,5' } },
|
|
96
|
+
});
|
|
97
|
+
// area 2*5=10; onceOff 2*2*10=40; unit 3*4*10=120 → cost = 1 + 40 + 120 = 161
|
|
98
|
+
expect(priced.cost).toBe(161);
|
|
99
|
+
expect(priced.totalCost).toBe(177.1); // +10% tax
|
|
100
|
+
// String fieldType (some JSON paths) must still hit the area calculator.
|
|
101
|
+
var asString = estimateQuote(__assign(__assign({}, rules), { fields: [__assign(__assign({}, rules.fields[0]), { fieldType: '14' })] }), { quantity: 1, fieldValues: { 14: { value: '2,5' } } });
|
|
102
|
+
expect(asString.cost).toBe(161);
|
|
103
|
+
});
|
|
104
|
+
test('non-selectable field with value adds field cost; empty adds nothing', function () {
|
|
105
|
+
var mk = function (sel) {
|
|
106
|
+
var rules = __assign(__assign({}, base), { fields: [{
|
|
107
|
+
id: 3, originalId: 3, position: 0, fieldType: 5, independent: true,
|
|
108
|
+
isSelectable: false, selectedBy: [],
|
|
109
|
+
variationCost: 4, variationUnitCost: 0,
|
|
110
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
111
|
+
options: [],
|
|
112
|
+
}] });
|
|
113
|
+
return estimateQuote(rules, { quantity: 10, fieldValues: { 3: sel } });
|
|
114
|
+
};
|
|
115
|
+
expect(mk({ value: 'hello' }).cost).toBe(104);
|
|
116
|
+
expect(mk({ value: '' }).cost).toBe(100);
|
|
117
|
+
expect(mk(undefined).cost).toBe(100);
|
|
118
|
+
// Server `is_empty` uses `not self.value`: numeric 0 is empty, string '0' is not.
|
|
119
|
+
expect(mk({ value: 0 }).cost).toBe(100);
|
|
120
|
+
expect(mk({ value: '0' }).cost).toBe(104);
|
|
121
|
+
});
|
|
122
|
+
test('tax computed from unrounded cost, not rounded cost (non-10% rate)', function () {
|
|
123
|
+
var rules = __assign(__assign({}, base), { taxPercent: 33, fields: [{
|
|
124
|
+
id: 7, originalId: 7, position: 0, fieldType: 5, independent: true,
|
|
125
|
+
isSelectable: false, selectedBy: [],
|
|
126
|
+
variationCost: 0.075, variationUnitCost: 0,
|
|
127
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
128
|
+
options: [],
|
|
129
|
+
}] });
|
|
130
|
+
var r = estimateQuote(rules, { quantity: 10, fieldValues: { 7: { value: 'x' } } });
|
|
131
|
+
// unrounded cost = 100 + 0.075 = 100.075
|
|
132
|
+
expect(r.cost).toBe(100.08); // roundHalfEven(100.075, 2)
|
|
133
|
+
// tax from UNROUNDED: round(100.075*0.33, 2) = round(33.02475, 2) = 33.02
|
|
134
|
+
// (the buggy round(round(100.075,2)*0.33,2) would give 33.03)
|
|
135
|
+
expect(r.taxAmount).toBe(33.02);
|
|
136
|
+
expect(r.totalCost).toBe(133.1); // round(100.075 + 33.02475, 3)
|
|
137
|
+
});
|
|
138
|
+
test('zero-qty group adds no field cost even when a visible field has value', function () {
|
|
139
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, groupFields: [
|
|
140
|
+
{
|
|
141
|
+
id: 50, originalId: 50, position: 0, fieldType: 5, independent: false,
|
|
142
|
+
isSelectable: false, selectedBy: [],
|
|
143
|
+
variationCost: 20, variationUnitCost: 0,
|
|
144
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
145
|
+
options: [],
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
// hidden conditional group field: skipped in the non-zero-qty group too
|
|
149
|
+
id: 51, originalId: 51, position: 1, fieldType: 5, independent: false,
|
|
150
|
+
isSelectable: false, selectedBy: [888],
|
|
151
|
+
variationCost: 99, variationUnitCost: 0,
|
|
152
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
153
|
+
options: [],
|
|
154
|
+
},
|
|
155
|
+
] });
|
|
156
|
+
var r = estimateQuote(rules, {
|
|
157
|
+
fieldValues: {},
|
|
158
|
+
groups: [
|
|
159
|
+
{ quantity: 0, fieldValues: { 50: { value: 'present' } } },
|
|
160
|
+
{ quantity: 5, fieldValues: {} },
|
|
161
|
+
],
|
|
162
|
+
});
|
|
163
|
+
// zero-qty group contributes exactly 0 (no +20 setup); other group: 5*10 = 50
|
|
164
|
+
expect(r.groupCosts).toEqual([0, 50]);
|
|
165
|
+
expect(r.cost).toBe(50);
|
|
166
|
+
});
|
|
167
|
+
test('groupCost preserves 3rd-decimal precision', function () {
|
|
168
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, groupFields: [{
|
|
169
|
+
id: 60, originalId: 60, position: 0, fieldType: 5, independent: false,
|
|
170
|
+
isSelectable: false, selectedBy: [],
|
|
171
|
+
variationCost: 0, variationUnitCost: 0.001,
|
|
172
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
173
|
+
options: [],
|
|
174
|
+
}] });
|
|
175
|
+
var r = estimateQuote(rules, {
|
|
176
|
+
fieldValues: {},
|
|
177
|
+
groups: [{ quantity: 3, fieldValues: { 60: { value: 'x' } } }],
|
|
178
|
+
});
|
|
179
|
+
// groupCost = 3*10 + 0.001*3 = 30.003, serialized at 3dp (not 2dp)
|
|
180
|
+
expect(r.groupCosts).toEqual([30.003]);
|
|
181
|
+
});
|
|
182
|
+
test('group product: weighted unit price and summed group costs', function () {
|
|
183
|
+
var rules = __assign(__assign({}, base), { hasGroups: true });
|
|
184
|
+
var r = estimateQuote(rules, {
|
|
185
|
+
fieldValues: {},
|
|
186
|
+
groups: [{ quantity: 3, fieldValues: {} }, { quantity: 7, fieldValues: {} }],
|
|
187
|
+
});
|
|
188
|
+
expect(r.cost).toBe(100);
|
|
189
|
+
expect(r.groupCosts).toEqual([30, 70]);
|
|
190
|
+
expect(r.costPerUnit).toBe(10);
|
|
191
|
+
});
|
|
192
|
+
test('product setupPrice applied once to job', function () {
|
|
193
|
+
var rules = __assign(__assign({}, base), { product: {
|
|
194
|
+
unitPrice: 10, minimumPrice: null, setupPrice: 25,
|
|
195
|
+
setupPerGroup: false, discountGroup: null,
|
|
196
|
+
} });
|
|
197
|
+
var r = estimateQuote(rules, { quantity: 5, fieldValues: {} });
|
|
198
|
+
expect(r.cost).toBe(75);
|
|
199
|
+
expect(r.taxAmount).toBe(7.5);
|
|
200
|
+
});
|
|
201
|
+
test('product setupPrice applied once across groups when setupPerGroup is false', function () {
|
|
202
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, product: {
|
|
203
|
+
unitPrice: 10, minimumPrice: null, setupPrice: 25,
|
|
204
|
+
setupPerGroup: false, discountGroup: null,
|
|
205
|
+
} });
|
|
206
|
+
var r = estimateQuote(rules, {
|
|
207
|
+
fieldValues: {},
|
|
208
|
+
groups: [{ quantity: 3, fieldValues: {} }, { quantity: 7, fieldValues: {} }],
|
|
209
|
+
});
|
|
210
|
+
expect(r.groupCosts).toEqual([30, 70]);
|
|
211
|
+
expect(r.cost).toBe(125);
|
|
212
|
+
});
|
|
213
|
+
test('product setupPrice applied per non-empty group when setupPerGroup is true', function () {
|
|
214
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, product: {
|
|
215
|
+
unitPrice: 10, minimumPrice: null, setupPrice: 25,
|
|
216
|
+
setupPerGroup: true, discountGroup: null,
|
|
217
|
+
} });
|
|
218
|
+
var r = estimateQuote(rules, {
|
|
219
|
+
fieldValues: {},
|
|
220
|
+
groups: [
|
|
221
|
+
{ quantity: 3, fieldValues: {} },
|
|
222
|
+
{ quantity: 0, fieldValues: {} },
|
|
223
|
+
{ quantity: 7, fieldValues: {} },
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
expect(r.groupCosts).toEqual([55, 0, 95]);
|
|
227
|
+
expect(r.cost).toBe(150);
|
|
228
|
+
});
|
|
229
|
+
test('group quantities from form inputs are numeric strings and must not concatenate', function () {
|
|
230
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, product: {
|
|
231
|
+
unitPrice: 10,
|
|
232
|
+
minimumPrice: null,
|
|
233
|
+
discountGroup: {
|
|
234
|
+
groupRestricted: false,
|
|
235
|
+
discounts: [{ lowerLimit: 1000, amount: 50 }],
|
|
236
|
+
},
|
|
237
|
+
} });
|
|
238
|
+
var r = estimateQuote(rules, {
|
|
239
|
+
fieldValues: {},
|
|
240
|
+
groups: [
|
|
241
|
+
{ quantity: '100', fieldValues: {} },
|
|
242
|
+
{ quantity: '1', fieldValues: {} },
|
|
243
|
+
],
|
|
244
|
+
});
|
|
245
|
+
// 100+1=101, below the 1000-unit break. String concat would yield "01001"→1001
|
|
246
|
+
// and incorrectly apply the 50% discount.
|
|
247
|
+
expect(r.groupCosts).toEqual([1000, 10]);
|
|
248
|
+
expect(r.cost).toBe(1010);
|
|
249
|
+
expect(r.costPerUnit).toBe(10);
|
|
250
|
+
});
|
|
251
|
+
test('group product with no groups array: zero cost', function () {
|
|
252
|
+
var rules = __assign(__assign({}, base), { hasGroups: true });
|
|
253
|
+
var r = estimateQuote(rules, { fieldValues: {} });
|
|
254
|
+
expect(r.cost).toBe(0);
|
|
255
|
+
expect(r.costPerUnit).toBe(10);
|
|
256
|
+
});
|
|
257
|
+
test('zero quantity yields zero cost and no NaN unit price', function () {
|
|
258
|
+
var r = estimateQuote(base, { quantity: 0, fieldValues: {} });
|
|
259
|
+
expect(r.cost).toBe(0);
|
|
260
|
+
expect(r.costPerUnit).toBe(10);
|
|
261
|
+
});
|
|
262
|
+
test('missing quantity treated as zero', function () {
|
|
263
|
+
var r = estimateQuote(base, { fieldValues: {} });
|
|
264
|
+
expect(r.cost).toBe(0);
|
|
265
|
+
});
|
|
266
|
+
test('option setup + unit-cost discount groups (non-restricted) applied', function () {
|
|
267
|
+
var dg = { groupRestricted: false, discounts: [{ lowerLimit: 5, amount: 50 }] };
|
|
268
|
+
var rules = __assign(__assign({}, base), { fields: [{
|
|
269
|
+
id: 1, originalId: 1, position: 0, fieldType: 2, independent: true,
|
|
270
|
+
isSelectable: true, selectedBy: [],
|
|
271
|
+
variationCost: 0, variationUnitCost: 0,
|
|
272
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
273
|
+
options: [{
|
|
274
|
+
id: 101, originalId: 101, position: 0, default: false,
|
|
275
|
+
variationCost: 10, variationUnitCost: 2,
|
|
276
|
+
variationCostDiscountGroup: dg, variationUnitCostDiscountGroup: dg,
|
|
277
|
+
selectedBy: [],
|
|
278
|
+
}],
|
|
279
|
+
}] });
|
|
280
|
+
var r = estimateQuote(rules, { quantity: 10, fieldValues: { 1: { selectedOptionIds: [101] } } });
|
|
281
|
+
// setup: 10 * (1-0.5) = 5; unit: 2 * 0.5 = 1 -> 1*10 = 10; base 100
|
|
282
|
+
expect(r.cost).toBe(115);
|
|
283
|
+
});
|
|
284
|
+
test('unknown selectedOptionId is skipped; originalId lookup matches', function () {
|
|
285
|
+
var rules = __assign(__assign({}, base), { fields: [{
|
|
286
|
+
id: 1, originalId: 1, position: 0, fieldType: 2, independent: true,
|
|
287
|
+
isSelectable: true, selectedBy: [],
|
|
288
|
+
variationCost: 0, variationUnitCost: 0,
|
|
289
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
290
|
+
options: [{
|
|
291
|
+
id: 101, originalId: 999, position: 0, default: false,
|
|
292
|
+
variationCost: 3, variationUnitCost: 0,
|
|
293
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
294
|
+
selectedBy: [],
|
|
295
|
+
}],
|
|
296
|
+
}] });
|
|
297
|
+
// 999 resolves via originalId (+3 setup); 555 is unknown and skipped
|
|
298
|
+
var r = estimateQuote(rules, { quantity: 10, fieldValues: { 1: { selectedOptionIds: [999, 555] } } });
|
|
299
|
+
expect(r.cost).toBe(103);
|
|
300
|
+
});
|
|
301
|
+
test('group product: group fields and group-restricted independent unit cost', function () {
|
|
302
|
+
var restrictedDg = { groupRestricted: true, discounts: [{ lowerLimit: 5, amount: 50 }] };
|
|
303
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, groupFields: [{
|
|
304
|
+
id: 10, originalId: 10, position: 0, fieldType: 5, independent: false,
|
|
305
|
+
isSelectable: false, selectedBy: [],
|
|
306
|
+
variationCost: 4, variationUnitCost: 1,
|
|
307
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
308
|
+
options: [],
|
|
309
|
+
}], fields: [{
|
|
310
|
+
id: 20, originalId: 20, position: 0, fieldType: 2, independent: true,
|
|
311
|
+
isSelectable: true, selectedBy: [],
|
|
312
|
+
variationCost: 0, variationUnitCost: 0,
|
|
313
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
314
|
+
options: [{
|
|
315
|
+
id: 120, originalId: 120, position: 0, default: false,
|
|
316
|
+
variationCost: 0, variationUnitCost: 2,
|
|
317
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: restrictedDg,
|
|
318
|
+
selectedBy: [],
|
|
319
|
+
}],
|
|
320
|
+
}] });
|
|
321
|
+
var r = estimateQuote(rules, {
|
|
322
|
+
fieldValues: { 20: { selectedOptionIds: [120] } },
|
|
323
|
+
groups: [
|
|
324
|
+
{ quantity: 3, fieldValues: { 10: { value: 'x' } } },
|
|
325
|
+
{ quantity: 7, fieldValues: {} },
|
|
326
|
+
],
|
|
327
|
+
});
|
|
328
|
+
// groups base: 3*10 + (4 + 1*3) = 30 + 7 = 37; 7*10 = 70 -> groupCosts [37,70]
|
|
329
|
+
// independent restricted unit: q3<5 -> 2, q7>=5 -> 1; total 2*3 + 1*7 = 13
|
|
330
|
+
// cost = 37 + 70 + 13 = 120
|
|
331
|
+
expect(r.groupCosts).toEqual([37, 70]);
|
|
332
|
+
expect(r.cost).toBe(120);
|
|
333
|
+
expect(r.costPerUnit).toBe(10);
|
|
334
|
+
});
|
|
335
|
+
test('group product: restricted product discount, zero-qty group, hidden fields skipped', function () {
|
|
336
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, product: {
|
|
337
|
+
unitPrice: 10, minimumPrice: null,
|
|
338
|
+
discountGroup: { groupRestricted: true, discounts: [] },
|
|
339
|
+
}, groupFields: [{
|
|
340
|
+
id: 30, originalId: 30, position: 0, fieldType: 2, independent: false,
|
|
341
|
+
isSelectable: true, selectedBy: [888],
|
|
342
|
+
variationCost: 50, variationUnitCost: 0,
|
|
343
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
344
|
+
options: [],
|
|
345
|
+
}], fields: [{
|
|
346
|
+
id: 40, originalId: 40, position: 0, fieldType: 2, independent: true,
|
|
347
|
+
isSelectable: true, selectedBy: [888],
|
|
348
|
+
variationCost: 60, variationUnitCost: 0,
|
|
349
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
350
|
+
options: [],
|
|
351
|
+
}] });
|
|
352
|
+
var r = estimateQuote(rules, {
|
|
353
|
+
fieldValues: {},
|
|
354
|
+
groups: [{ quantity: 0, fieldValues: {} }],
|
|
355
|
+
});
|
|
356
|
+
// restricted product discount group (empty discounts -> no change); group qty 0;
|
|
357
|
+
// both conditional fields hidden (selectedBy [888] unmet) so not costed
|
|
358
|
+
expect(r.cost).toBe(0);
|
|
359
|
+
expect(r.groupCosts).toEqual([0]);
|
|
360
|
+
expect(r.costPerUnit).toBe(10);
|
|
361
|
+
});
|
|
362
|
+
test('group field visibility is scoped per group (no cross-group leak)', function () {
|
|
363
|
+
// Size field (24mm=801, 25mm=802) and a premium group field gated by 25mm
|
|
364
|
+
// (selectedBy [802]) whose selected option 811 costs 5 setup.
|
|
365
|
+
var opt = function (id, selectedBy) {
|
|
366
|
+
if (selectedBy === void 0) { selectedBy = []; }
|
|
367
|
+
return ({
|
|
368
|
+
id: id,
|
|
369
|
+
originalId: id, position: id, default: false,
|
|
370
|
+
variationCost: 0, variationUnitCost: 0,
|
|
371
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
372
|
+
selectedBy: selectedBy,
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
var rules = __assign(__assign({}, base), { hasGroups: true, product: { unitPrice: 0, minimumPrice: null, discountGroup: null }, taxPercent: 0, groupFields: [
|
|
376
|
+
{
|
|
377
|
+
id: 800, originalId: 800, position: 0, fieldType: 2, independent: false,
|
|
378
|
+
isSelectable: true, selectedBy: [],
|
|
379
|
+
variationCost: 0, variationUnitCost: 0,
|
|
380
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
381
|
+
options: [opt(801), opt(802)],
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: 810, originalId: 810, position: 1, fieldType: 2, independent: false,
|
|
385
|
+
isSelectable: true, selectedBy: [802],
|
|
386
|
+
variationCost: 0, variationUnitCost: 0,
|
|
387
|
+
variationCostDiscountGroup: null, variationUnitCostDiscountGroup: null,
|
|
388
|
+
options: [__assign(__assign({}, opt(811)), { variationCost: 5 })],
|
|
389
|
+
},
|
|
390
|
+
] });
|
|
391
|
+
// Group A picks 24mm but ALSO has premium 811 selected; Group B picks 25mm + 811.
|
|
392
|
+
// Scoped: A's premium field is hidden (24mm) -> 811 NOT costed; B's is visible
|
|
393
|
+
// -> 811 costs 5. A global resolver would wrongly cost A's 811 too (total 10).
|
|
394
|
+
var r = estimateQuote(rules, {
|
|
395
|
+
fieldValues: {},
|
|
396
|
+
groups: [
|
|
397
|
+
{ quantity: 10, fieldValues: { 800: { selectedOptionIds: [801] }, 810: { selectedOptionIds: [811] } } },
|
|
398
|
+
{ quantity: 10, fieldValues: { 800: { selectedOptionIds: [802] }, 810: { selectedOptionIds: [811] } } },
|
|
399
|
+
],
|
|
400
|
+
});
|
|
401
|
+
expect(r.groupCosts).toEqual([0, 5]);
|
|
402
|
+
expect(r.cost).toBe(5);
|
|
403
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
+
};
|
|
26
|
+
import * as fs from 'fs';
|
|
27
|
+
import * as path from 'path';
|
|
28
|
+
import { estimateQuote } from './estimate.js';
|
|
29
|
+
import { resolveVisibleFields } from './visibility.js';
|
|
30
|
+
// Fixtures are vendored into the SDK so the golden parity test is
|
|
31
|
+
// self-contained in CI. They are generated by the merchi_api fixture
|
|
32
|
+
// generator (tests/tests/pricing_fixtures.py) from the real server estimate.
|
|
33
|
+
var FIXTURES_DIR = path.resolve(__dirname, '__fixtures__');
|
|
34
|
+
function loadFixtures() {
|
|
35
|
+
if (!fs.existsSync(FIXTURES_DIR))
|
|
36
|
+
return [];
|
|
37
|
+
return fs.readdirSync(FIXTURES_DIR)
|
|
38
|
+
.filter(function (f) { return f.endsWith('.json'); })
|
|
39
|
+
.map(function (f) { return JSON.parse(fs.readFileSync(path.join(FIXTURES_DIR, f), 'utf-8')); });
|
|
40
|
+
}
|
|
41
|
+
var fixtures = loadFixtures();
|
|
42
|
+
test('pricing fixtures exist', function () {
|
|
43
|
+
expect(fixtures.length).toBeGreaterThan(0);
|
|
44
|
+
});
|
|
45
|
+
describe.each(fixtures)('golden parity: $name', function (fixture) {
|
|
46
|
+
test('estimateQuote matches server', function () {
|
|
47
|
+
var result = estimateQuote(fixture.bundle, fixture.selections);
|
|
48
|
+
expect(result.cost).toBeCloseTo(fixture.expected.cost, 2);
|
|
49
|
+
expect(result.costPerUnit).toBeCloseTo(fixture.expected.costPerUnit, 3);
|
|
50
|
+
expect(result.taxAmount).toBeCloseTo(fixture.expected.taxAmount, 2);
|
|
51
|
+
expect(result.totalCost).toBeCloseTo(fixture.expected.totalCost, 2);
|
|
52
|
+
expect(result.groupCosts.length).toBe(fixture.expected.groupCosts.length);
|
|
53
|
+
result.groupCosts.forEach(function (c, i) {
|
|
54
|
+
return expect(c).toBeCloseTo(fixture.expected.groupCosts[i], 2);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
test('resolveVisibleFields matches server', function () {
|
|
58
|
+
var visible = __spreadArray([], __read(resolveVisibleFields(fixture.bundle, fixture.selections)), false).sort(function (a, b) { return a - b; });
|
|
59
|
+
expect(visible).toEqual(fixture.expected.visibleFieldIds);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export { roundHalfEven } from './round.js';
|
|
3
|
+
export { applyDiscount } from './discount.js';
|
|
4
|
+
export { resolveVisibleFields, resolveVisibleOptionIds } from './visibility.js';
|
|
5
|
+
export { resolveUnavailableOptionIds } from './inventory.js';
|
|
6
|
+
export { estimateQuote } from './estimate.js';
|
|
7
|
+
export { buildPriceMatrix } from './matrix.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { pricing } from '../index.js';
|
|
2
|
+
test('pricing namespace exposes calculator functions', function () {
|
|
3
|
+
expect(typeof pricing.estimateQuote).toBe('function');
|
|
4
|
+
expect(typeof pricing.buildPriceMatrix).toBe('function');
|
|
5
|
+
expect(typeof pricing.resolveVisibleFields).toBe('function');
|
|
6
|
+
expect(typeof pricing.applyDiscount).toBe('function');
|
|
7
|
+
expect(typeof pricing.roundHalfEven).toBe('function');
|
|
8
|
+
});
|