merchi_sdk_ts 0.0.1-a
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/.babelrc +13 -0
- package/.eslintrc.cjs +43 -0
- package/LICENSE +21 -0
- package/README.md +2 -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 +4 -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 +14 -0
- package/dist/constants/field_types.test.js +4 -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 +16 -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 +98 -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 +26 -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 +1 -0
- package/dist/constants/robots_meta_directives.test.js +4 -0
- package/dist/constants/roles.js +25 -0
- package/dist/constants/roles.test.js +4 -0
- package/dist/constants/shipment_companies.js +19 -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_foundations.js +7 -0
- package/dist/constants/theme_foundations.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 +16 -0
- package/dist/cookie.test.js +12 -0
- package/dist/entities/address.js +166 -0
- package/dist/entities/address.test.js +6 -0
- package/dist/entities/assignment.js +185 -0
- package/dist/entities/assignment.test.js +38 -0
- package/dist/entities/automatic_payment_relationship.js +77 -0
- package/dist/entities/automatic_payment_relationship.test.js +6 -0
- package/dist/entities/backup.js +44 -0
- package/dist/entities/backup.test.js +6 -0
- package/dist/entities/bank.js +116 -0
- package/dist/entities/bank.test.js +6 -0
- package/dist/entities/cart.js +203 -0
- package/dist/entities/cart.test.js +52 -0
- package/dist/entities/cart_item.js +153 -0
- package/dist/entities/cart_item.test.js +34 -0
- package/dist/entities/cart_shipment_group.js +62 -0
- package/dist/entities/cart_shipment_quote.js +85 -0
- package/dist/entities/category.js +92 -0
- package/dist/entities/category.test.js +52 -0
- package/dist/entities/company.js +648 -0
- package/dist/entities/company.test.js +6 -0
- package/dist/entities/company_invitation.js +82 -0
- package/dist/entities/company_invitation.test.js +6 -0
- package/dist/entities/component.js +209 -0
- package/dist/entities/component.test.js +12 -0
- package/dist/entities/component_tag.js +50 -0
- package/dist/entities/component_tag.test.js +6 -0
- package/dist/entities/component_version.js +80 -0
- package/dist/entities/component_version.test.js +6 -0
- package/dist/entities/country_tax.js +110 -0
- package/dist/entities/country_tax.test.js +11 -0
- package/dist/entities/discount.js +77 -0
- package/dist/entities/discount.test.js +20 -0
- package/dist/entities/discount_group.js +74 -0
- package/dist/entities/discount_group.test.js +6 -0
- package/dist/entities/domain.js +535 -0
- package/dist/entities/domain.test.js +75 -0
- package/dist/entities/domain_invitation.js +90 -0
- package/dist/entities/domain_invitation.test.js +6 -0
- package/dist/entities/domain_tag.js +100 -0
- package/dist/entities/domain_tag.test.js +6 -0
- package/dist/entities/draft.js +180 -0
- package/dist/entities/draft.test.js +39 -0
- package/dist/entities/draft_comment.js +132 -0
- package/dist/entities/draft_comment.test.js +6 -0
- package/dist/entities/draft_template.js +105 -0
- package/dist/entities/draft_template.test.js +6 -0
- package/dist/entities/email_address.js +68 -0
- package/dist/entities/email_address.test.js +6 -0
- package/dist/entities/email_counter.js +56 -0
- package/dist/entities/email_counter.test.js +6 -0
- package/dist/entities/enrolled_domain.js +85 -0
- package/dist/entities/enrolled_domain.test.js +6 -0
- package/dist/entities/exchange_rate.js +62 -0
- package/dist/entities/exchange_rate.test.js +6 -0
- package/dist/entities/file.js +383 -0
- package/dist/entities/file.test.js +38 -0
- package/dist/entities/internal_tag.js +120 -0
- package/dist/entities/internal_tag.test.js +6 -0
- package/dist/entities/inventory.js +120 -0
- package/dist/entities/inventory.test.js +26 -0
- package/dist/entities/inventory_unit_variation.js +64 -0
- package/dist/entities/inventory_unit_variation.test.js +6 -0
- package/dist/entities/invoice.js +420 -0
- package/dist/entities/invoice.test.js +39 -0
- package/dist/entities/item.js +102 -0
- package/dist/entities/item.test.js +17 -0
- package/dist/entities/job.js +744 -0
- package/dist/entities/job.test.js +103 -0
- package/dist/entities/job_comment.js +120 -0
- package/dist/entities/job_comment.test.js +6 -0
- package/dist/entities/matching_inventory.js +77 -0
- package/dist/entities/menu.js +78 -0
- package/dist/entities/menu.test.js +6 -0
- package/dist/entities/menu_item.js +76 -0
- package/dist/entities/menu_item.test.js +6 -0
- package/dist/entities/notification.js +234 -0
- package/dist/entities/notification.test.js +6 -0
- package/dist/entities/page.js +84 -0
- package/dist/entities/page.test.js +6 -0
- package/dist/entities/payment.js +141 -0
- package/dist/entities/payment.test.js +18 -0
- package/dist/entities/payment_device.js +87 -0
- package/dist/entities/payment_device.test.js +6 -0
- package/dist/entities/phone_number.js +98 -0
- package/dist/entities/phone_number.test.js +6 -0
- package/dist/entities/product.js +806 -0
- package/dist/entities/product.test.js +811 -0
- package/dist/entities/production_comment.js +120 -0
- package/dist/entities/production_comment.test.js +6 -0
- package/dist/entities/quote.js +208 -0
- package/dist/entities/quote.test.js +107 -0
- package/dist/entities/quote_item.js +121 -0
- package/dist/entities/quote_item.test.js +56 -0
- package/dist/entities/seo_domain_page.js +82 -0
- package/dist/entities/seo_domain_page.test.js +6 -0
- package/dist/entities/session.js +77 -0
- package/dist/entities/session.test.js +6 -0
- package/dist/entities/shipment.js +401 -0
- package/dist/entities/shipment.test.js +28 -0
- package/dist/entities/shipment_item.js +49 -0
- package/dist/entities/shipment_item.test.js +6 -0
- package/dist/entities/shipment_item_fulfillment.js +48 -0
- package/dist/entities/shipment_item_fulfillment.test.js +6 -0
- package/dist/entities/shipment_method.js +146 -0
- package/dist/entities/shipment_method.test.js +6 -0
- package/dist/entities/shipment_method_variation.js +104 -0
- package/dist/entities/shipment_method_variation.test.js +6 -0
- package/dist/entities/short_url.js +95 -0
- package/dist/entities/short_url.test.js +6 -0
- package/dist/entities/subscription_plan.js +172 -0
- package/dist/entities/subscription_plan.test.js +6 -0
- package/dist/entities/supply_domain.js +73 -0
- package/dist/entities/supply_domain.test.js +6 -0
- package/dist/entities/system_role.js +50 -0
- package/dist/entities/system_role.test.js +6 -0
- package/dist/entities/theme.js +614 -0
- package/dist/entities/theme.test.js +39 -0
- package/dist/entities/theme_css_setting.js +67 -0
- package/dist/entities/theme_css_setting.test.js +6 -0
- package/dist/entities/user.js +749 -0
- package/dist/entities/user.test.js +157 -0
- package/dist/entities/user_company.js +78 -0
- package/dist/entities/user_company.test.js +6 -0
- package/dist/entities/variation.js +147 -0
- package/dist/entities/variation.test.js +6 -0
- package/dist/entities/variation_field.js +313 -0
- package/dist/entities/variation_field.test.js +69 -0
- package/dist/entities/variation_fields_option.js +190 -0
- package/dist/entities/variation_fields_option.test.js +47 -0
- package/dist/entities/variation_option.js +129 -0
- package/dist/entities/variation_option.test.js +6 -0
- package/dist/entities/variations_group.js +111 -0
- package/dist/entities/variations_group.test.js +6 -0
- package/dist/entity.js +888 -0
- package/dist/merchi.js +259 -0
- package/dist/merchi.test.js +35 -0
- package/dist/request.js +132 -0
- package/dist/request.test.js +46 -0
- package/dist/test_util.js +19 -0
- package/dist/toasts.js +27 -0
- package/dist/toasts.test.js +46 -0
- package/dist/util/float.js +24 -0
- package/dist/util/query_string.js +11 -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 +13 -0
- package/jest.config.js +17 -0
- package/package.json +44 -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 +3 -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 +13 -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 +15 -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 +97 -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 +25 -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 +38 -0
- package/src/constants/shipment_companies.test.ts +5 -0
- package/src/constants/shipment_companies.ts +18 -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_foundations.test.ts +5 -0
- package/src/constants/theme_foundations.ts +6 -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/assignment.test.ts +39 -0
- package/src/entities/assignment.ts +92 -0
- package/src/entities/automatic_payment_relationship.test.ts +8 -0
- package/src/entities/automatic_payment_relationship.ts +26 -0
- package/src/entities/backup.test.ts +7 -0
- package/src/entities/backup.ts +14 -0
- package/src/entities/bank.test.ts +7 -0
- package/src/entities/bank.ts +45 -0
- package/src/entities/cart.test.ts +50 -0
- package/src/entities/cart.ts +89 -0
- package/src/entities/cart_item.test.ts +33 -0
- package/src/entities/cart_item.ts +77 -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 +37 -0
- package/src/entities/company.test.ts +7 -0
- package/src/entities/company.ts +275 -0
- package/src/entities/company_invitation.test.ts +7 -0
- package/src/entities/company_invitation.ts +33 -0
- package/src/entities/component.test.ts +14 -0
- package/src/entities/component.ts +92 -0
- package/src/entities/component_tag.test.ts +7 -0
- package/src/entities/component_tag.ts +17 -0
- package/src/entities/component_version.test.ts +7 -0
- package/src/entities/component_version.ts +30 -0
- package/src/entities/country_tax.test.ts +13 -0
- package/src/entities/country_tax.ts +46 -0
- package/src/entities/discount.test.ts +18 -0
- package/src/entities/discount.ts +34 -0
- package/src/entities/discount_group.test.ts +7 -0
- package/src/entities/discount_group.ts +28 -0
- package/src/entities/domain.test.ts +79 -0
- package/src/entities/domain.ts +246 -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 +43 -0
- package/src/entities/draft.ts +88 -0
- package/src/entities/draft_comment.test.ts +7 -0
- package/src/entities/draft_comment.ts +54 -0
- package/src/entities/draft_template.test.ts +7 -0
- package/src/entities/draft_template.ts +40 -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 +172 -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 +56 -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 +43 -0
- package/src/entities/invoice.ts +179 -0
- package/src/entities/item.test.ts +19 -0
- package/src/entities/item.ts +44 -0
- package/src/entities/job.test.ts +95 -0
- package/src/entities/job.ts +349 -0
- package/src/entities/job_comment.test.ts +7 -0
- package/src/entities/job_comment.ts +50 -0
- package/src/entities/matching_inventory.ts +29 -0
- package/src/entities/menu.test.ts +7 -0
- package/src/entities/menu.ts +30 -0
- package/src/entities/menu_item.test.ts +7 -0
- package/src/entities/menu_item.ts +29 -0
- package/src/entities/notification.test.ts +7 -0
- package/src/entities/notification.ts +99 -0
- package/src/entities/page.test.ts +7 -0
- package/src/entities/page.ts +32 -0
- package/src/entities/payment.test.ts +19 -0
- package/src/entities/payment.ts +65 -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 +750 -0
- package/src/entities/product.ts +427 -0
- package/src/entities/production_comment.test.ts +7 -0
- package/src/entities/production_comment.ts +50 -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/seo_domain_page.test.ts +7 -0
- package/src/entities/seo_domain_page.ts +33 -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 +185 -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_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/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 +267 -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 +394 -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 +61 -0
- package/src/entities/variation_field.test.ts +76 -0
- package/src/entities/variation_field.ts +169 -0
- package/src/entities/variation_fields_option.test.ts +46 -0
- package/src/entities/variation_fields_option.ts +95 -0
- package/src/entities/variation_option.test.ts +7 -0
- package/src/entities/variation_option.ts +52 -0
- package/src/entities/variations_group.test.ts +7 -0
- package/src/entities/variations_group.ts +41 -0
- package/src/entity.ts +1002 -0
- package/src/merchi.test.ts +25 -0
- package/src/merchi.ts +379 -0
- package/src/request.test.ts +43 -0
- package/src/request.ts +124 -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/query_string.test.ts +7 -0
- package/src/util/query_string.ts +11 -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 +23 -0
- package/webpack.config.cjs +27 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
|
|
3
|
+
test('can make VariationField', () => {
|
|
4
|
+
const merchi = new Merchi();
|
|
5
|
+
const variationField = new merchi.VariationField();
|
|
6
|
+
expect(variationField).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('isSelectable', () => {
|
|
10
|
+
const merchi = new Merchi();
|
|
11
|
+
const vf = new merchi.VariationField();
|
|
12
|
+
expect(vf.isSelectable).toThrow();
|
|
13
|
+
vf.fieldType = 1;
|
|
14
|
+
expect(vf.isSelectable()).toBe(false);
|
|
15
|
+
vf.fieldType = 11;
|
|
16
|
+
expect(vf.isSelectable()).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('buildEmptyVariation cost', () => {
|
|
20
|
+
const merchi = new Merchi();
|
|
21
|
+
const vf = new merchi.VariationField();
|
|
22
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
23
|
+
vf.defaultValue = 'a';
|
|
24
|
+
vf.fieldType = 11;
|
|
25
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
26
|
+
vf.variationCost = 2;
|
|
27
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
28
|
+
const o1 = new merchi.VariationFieldsOption();
|
|
29
|
+
const o2 = new merchi.VariationFieldsOption();
|
|
30
|
+
o1.default = true;
|
|
31
|
+
vf.options = [o1, o2];
|
|
32
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
33
|
+
o1.variationCost = 3;
|
|
34
|
+
expect(vf.buildEmptyVariation().onceOffCost).toEqual(3);
|
|
35
|
+
vf.fieldType = 1;
|
|
36
|
+
expect(vf.buildEmptyVariation().onceOffCost).toEqual(2);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('buildEmptyVariation seller editable options', () => {
|
|
40
|
+
const merchi = new Merchi();
|
|
41
|
+
const vf = new merchi.VariationField();
|
|
42
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
43
|
+
vf.defaultValue = 'a';
|
|
44
|
+
vf.fieldType = 11;
|
|
45
|
+
vf.sellerProductEditable = true;
|
|
46
|
+
vf.variationCost = 2;
|
|
47
|
+
expect(vf.buildEmptyVariation).toThrow();
|
|
48
|
+
const o1 = new merchi.VariationFieldsOption();
|
|
49
|
+
const o2 = new merchi.VariationFieldsOption();
|
|
50
|
+
o1.include = true;
|
|
51
|
+
o1.id = 1;
|
|
52
|
+
o1.variationCost = 1;
|
|
53
|
+
o2.default = true;
|
|
54
|
+
o2.id = 2;
|
|
55
|
+
o2.variationCost = 1;
|
|
56
|
+
vf.options = [o1, o2];
|
|
57
|
+
expect(vf.buildEmptyVariation().value).toEqual('1');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('buildEmptyVariation selectable options', () => {
|
|
61
|
+
const merchi = new Merchi();
|
|
62
|
+
const vf = new merchi.VariationField();
|
|
63
|
+
const o1 = new merchi.VariationFieldsOption();
|
|
64
|
+
const o2 = new merchi.VariationFieldsOption();
|
|
65
|
+
|
|
66
|
+
o1.value = 'test 1';
|
|
67
|
+
o2.value = 'test 2';
|
|
68
|
+
vf.options = [o1, o2];
|
|
69
|
+
vf.variationCost = 2;
|
|
70
|
+
vf.defaultValue = 'a';
|
|
71
|
+
vf.fieldType = 11;
|
|
72
|
+
|
|
73
|
+
const v = vf.buildEmptyVariation();
|
|
74
|
+
expect(v.selectableOptions![0].value).toEqual('test 1');
|
|
75
|
+
expect(v.selectableOptions![1].value).toEqual('test 2');
|
|
76
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { cloneDeepWith } from 'lodash';
|
|
2
|
+
import { DiscountGroup } from './discount_group';
|
|
3
|
+
import { Entity } from '../entity';
|
|
4
|
+
import { Product } from './product';
|
|
5
|
+
import { Variation } from './variation';
|
|
6
|
+
import { VariationFieldsOption } from './variation_fields_option';
|
|
7
|
+
import { FieldType } from '../constants/field_types';
|
|
8
|
+
|
|
9
|
+
export class VariationField extends Entity {
|
|
10
|
+
protected static resourceName = 'variation_fields';
|
|
11
|
+
protected static singularName = 'variationField';
|
|
12
|
+
protected static pluralName = 'variationFields';
|
|
13
|
+
|
|
14
|
+
@VariationField.property({type: Date})
|
|
15
|
+
public archived?: Date | null;
|
|
16
|
+
|
|
17
|
+
@VariationField.property()
|
|
18
|
+
public id?: number;
|
|
19
|
+
|
|
20
|
+
@VariationField.property()
|
|
21
|
+
public position?: number;
|
|
22
|
+
|
|
23
|
+
@VariationField.property()
|
|
24
|
+
public required?: boolean;
|
|
25
|
+
|
|
26
|
+
@VariationField.property()
|
|
27
|
+
public independent?: boolean;
|
|
28
|
+
|
|
29
|
+
@VariationField.property()
|
|
30
|
+
public name?: string;
|
|
31
|
+
|
|
32
|
+
@VariationField.property({type: String})
|
|
33
|
+
public placeholder?: string | null;
|
|
34
|
+
|
|
35
|
+
@VariationField.property()
|
|
36
|
+
public defaultValue?: string;
|
|
37
|
+
|
|
38
|
+
@VariationField.property()
|
|
39
|
+
public currency?: string;
|
|
40
|
+
|
|
41
|
+
@VariationField.property()
|
|
42
|
+
public fieldType?: FieldType;
|
|
43
|
+
|
|
44
|
+
@VariationField.property()
|
|
45
|
+
public margin?: number;
|
|
46
|
+
|
|
47
|
+
@VariationField.property()
|
|
48
|
+
public variationCost?: number;
|
|
49
|
+
|
|
50
|
+
@VariationField.property({type: 'DiscountGroup'})
|
|
51
|
+
public variationCostDiscountGroup?: DiscountGroup | null;
|
|
52
|
+
|
|
53
|
+
@VariationField.property()
|
|
54
|
+
public variationUnitCost?: number;
|
|
55
|
+
|
|
56
|
+
@VariationField.property({embeddedByDefault: false})
|
|
57
|
+
public buyUnitCost?: number;
|
|
58
|
+
|
|
59
|
+
@VariationField.property({embeddedByDefault: false})
|
|
60
|
+
public buyCost?: number;
|
|
61
|
+
|
|
62
|
+
@VariationField.property({type: 'DiscountGroup'})
|
|
63
|
+
public variationUnitCostDiscountGroup?: DiscountGroup | null;
|
|
64
|
+
|
|
65
|
+
@VariationField.property()
|
|
66
|
+
public rows?: number;
|
|
67
|
+
|
|
68
|
+
@VariationField.property({type: Number})
|
|
69
|
+
public fieldMin?: number | null;
|
|
70
|
+
|
|
71
|
+
@VariationField.property({type: Number})
|
|
72
|
+
public fieldMax?: number | null;
|
|
73
|
+
|
|
74
|
+
@VariationField.property()
|
|
75
|
+
public allowDecimal?: boolean;
|
|
76
|
+
|
|
77
|
+
@VariationField.property()
|
|
78
|
+
public sellerProductEditable?: boolean;
|
|
79
|
+
|
|
80
|
+
@VariationField.property()
|
|
81
|
+
public multipleSelect?: boolean;
|
|
82
|
+
|
|
83
|
+
@VariationField.property()
|
|
84
|
+
public showFilePreview?: boolean;
|
|
85
|
+
|
|
86
|
+
@VariationField.property()
|
|
87
|
+
public allowFileMultiple?: boolean;
|
|
88
|
+
|
|
89
|
+
@VariationField.property()
|
|
90
|
+
public allowFileJpeg?: boolean;
|
|
91
|
+
|
|
92
|
+
@VariationField.property()
|
|
93
|
+
public allowFileGif?: boolean;
|
|
94
|
+
|
|
95
|
+
@VariationField.property()
|
|
96
|
+
public allowFilePdf?: boolean;
|
|
97
|
+
|
|
98
|
+
@VariationField.property()
|
|
99
|
+
public allowFilePng?: boolean;
|
|
100
|
+
|
|
101
|
+
@VariationField.property()
|
|
102
|
+
public allowFileAi?: boolean;
|
|
103
|
+
|
|
104
|
+
@VariationField.property()
|
|
105
|
+
public product?: Product;
|
|
106
|
+
|
|
107
|
+
@VariationField.property({arrayType: 'Variation'})
|
|
108
|
+
public variations?: Variation[];
|
|
109
|
+
|
|
110
|
+
@VariationField.property({arrayType: 'VariationFieldsOption'})
|
|
111
|
+
public options?: VariationFieldsOption[];
|
|
112
|
+
|
|
113
|
+
public isSelectable = () => {
|
|
114
|
+
if (this.fieldType === undefined) {
|
|
115
|
+
throw new Error('fieldType is undefined, did you forget to embed it?');
|
|
116
|
+
}
|
|
117
|
+
const selectable = new Set([FieldType.SELECT,
|
|
118
|
+
FieldType.CHECKBOX,
|
|
119
|
+
FieldType.RADIO,
|
|
120
|
+
FieldType.IMAGE_SELECT,
|
|
121
|
+
FieldType.COLOUR_SELECT]);
|
|
122
|
+
return selectable.has(this.fieldType);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
public buildEmptyVariation = () => {
|
|
126
|
+
if (this.defaultValue === undefined) {
|
|
127
|
+
throw new Error('defaultValue is undefined, did you forget to embed it?');
|
|
128
|
+
}
|
|
129
|
+
if (this.variationCost === undefined) {
|
|
130
|
+
const err = 'variationCost is undefined, did you forget to embed it?';
|
|
131
|
+
throw new Error(err);
|
|
132
|
+
}
|
|
133
|
+
if (this.options === undefined) {
|
|
134
|
+
throw new Error('options is undefined, did you forget to embed it?');
|
|
135
|
+
}
|
|
136
|
+
const result = new this.merchi.Variation(this.merchi);
|
|
137
|
+
result.selectableOptions = [];
|
|
138
|
+
if (this.isSelectable()) {
|
|
139
|
+
let onceOffCost = 0;
|
|
140
|
+
const value = [];
|
|
141
|
+
for (const option of this.options) {
|
|
142
|
+
if ((this.sellerProductEditable && option.include) ||
|
|
143
|
+
(!this.sellerProductEditable && option.default)) {
|
|
144
|
+
if (option.variationCost === undefined) {
|
|
145
|
+
throw new Error('option.variationCost is undefined, did you ' +
|
|
146
|
+
'forget to embed it?');
|
|
147
|
+
}
|
|
148
|
+
value.push(option.id);
|
|
149
|
+
onceOffCost += option.variationCost;
|
|
150
|
+
}
|
|
151
|
+
result.selectableOptions.push(option.buildVariationOption());
|
|
152
|
+
}
|
|
153
|
+
result.value = value.join();
|
|
154
|
+
result.onceOffCost = onceOffCost;
|
|
155
|
+
} else {
|
|
156
|
+
result.value = this.defaultValue;
|
|
157
|
+
result.onceOffCost = this.variationCost;
|
|
158
|
+
}
|
|
159
|
+
result.unitCostTotal = 0;
|
|
160
|
+
result.cost = result.onceOffCost;
|
|
161
|
+
function customiser(value: any, index: any) {
|
|
162
|
+
if (index === 'merchi') {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
result.variationField = cloneDeepWith(this, customiser);
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
|
|
3
|
+
test('can make VariationFieldsOption', () => {
|
|
4
|
+
const merchi = new Merchi();
|
|
5
|
+
const variationFieldsOption = new merchi.VariationFieldsOption();
|
|
6
|
+
expect(variationFieldsOption).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('totalCost', () => {
|
|
10
|
+
const merchi = new Merchi();
|
|
11
|
+
const vfo = new merchi.VariationFieldsOption();
|
|
12
|
+
expect(() => vfo.totalCost(33)).toThrow();
|
|
13
|
+
vfo.variationCost = 12.4;
|
|
14
|
+
expect(() => vfo.totalCost(33)).toThrow();
|
|
15
|
+
vfo.variationUnitCost = 9.98;
|
|
16
|
+
expect(vfo.totalCost(33)).toEqual(341.74);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('buildVariationOption', () => {
|
|
20
|
+
const merchi = new Merchi();
|
|
21
|
+
const option = new merchi.VariationFieldsOption();
|
|
22
|
+
const file = new merchi.MerchiFile();
|
|
23
|
+
file.id = 1;
|
|
24
|
+
option.id = 1;
|
|
25
|
+
option.value = 'aa';
|
|
26
|
+
option.position = 3;
|
|
27
|
+
option.default = true;
|
|
28
|
+
option.colour = '#AAAAAA';
|
|
29
|
+
option.linkedFile = file;
|
|
30
|
+
option.currency = 'AUD';
|
|
31
|
+
option.variationCost = 100;
|
|
32
|
+
option.variationUnitCost = 1;
|
|
33
|
+
const variationOption = option.buildVariationOption();
|
|
34
|
+
expect(variationOption.optionId).toEqual(option.id);
|
|
35
|
+
expect(variationOption.value).toEqual(option.value);
|
|
36
|
+
expect(variationOption.position).toEqual(option.position);
|
|
37
|
+
expect(variationOption.default).toEqual(option.default);
|
|
38
|
+
expect(variationOption.colour).toEqual(option.colour);
|
|
39
|
+
expect(variationOption.linkedFile!.id).toEqual(1);
|
|
40
|
+
expect(variationOption.quantity).toEqual(0);
|
|
41
|
+
expect(variationOption.currency).toEqual(option.currency);
|
|
42
|
+
expect(variationOption.onceOffCost).toEqual(option.variationCost);
|
|
43
|
+
expect(variationOption.unitCost).toEqual(option.variationUnitCost);
|
|
44
|
+
expect(variationOption.unitCostTotal).toEqual(0);
|
|
45
|
+
expect(variationOption.totalCost).toEqual(option.variationCost);
|
|
46
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { DiscountGroup } from './discount_group';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { MerchiFile } from './file';
|
|
4
|
+
import { InventoryUnitVariation } from './inventory_unit_variation';
|
|
5
|
+
import { Variation } from './variation';
|
|
6
|
+
import { VariationField } from './variation_field';
|
|
7
|
+
|
|
8
|
+
export class VariationFieldsOption extends Entity {
|
|
9
|
+
protected static resourceName = 'variation_fields_options';
|
|
10
|
+
protected static singularName = 'variationFieldsOption';
|
|
11
|
+
protected static pluralName = 'variationFieldsOptions';
|
|
12
|
+
|
|
13
|
+
@VariationFieldsOption.property({type: Date})
|
|
14
|
+
public archived?: Date | null;
|
|
15
|
+
|
|
16
|
+
@VariationFieldsOption.property()
|
|
17
|
+
public id?: number;
|
|
18
|
+
|
|
19
|
+
@VariationFieldsOption.property({type: String})
|
|
20
|
+
public value?: string | null;
|
|
21
|
+
|
|
22
|
+
@VariationFieldsOption.property({type: String})
|
|
23
|
+
public colour?: string | null;
|
|
24
|
+
|
|
25
|
+
@VariationFieldsOption.property()
|
|
26
|
+
public currency?: string;
|
|
27
|
+
|
|
28
|
+
@VariationFieldsOption.property()
|
|
29
|
+
public default?: boolean;
|
|
30
|
+
|
|
31
|
+
@VariationFieldsOption.property()
|
|
32
|
+
public include?: boolean;
|
|
33
|
+
|
|
34
|
+
@VariationFieldsOption.property()
|
|
35
|
+
public position?: number;
|
|
36
|
+
|
|
37
|
+
@VariationFieldsOption.property()
|
|
38
|
+
public variationCost?: number;
|
|
39
|
+
|
|
40
|
+
@VariationFieldsOption.property({type: 'DiscountGroup'})
|
|
41
|
+
public variationCostDiscountGroup?: DiscountGroup | null;
|
|
42
|
+
|
|
43
|
+
@VariationFieldsOption.property()
|
|
44
|
+
public variationUnitCost?: number;
|
|
45
|
+
|
|
46
|
+
@VariationFieldsOption.property({embeddedByDefault: false})
|
|
47
|
+
public buyUnitCost?: number;
|
|
48
|
+
|
|
49
|
+
@VariationFieldsOption.property({embeddedByDefault: false})
|
|
50
|
+
public buyCost?: number;
|
|
51
|
+
|
|
52
|
+
@VariationFieldsOption.property({type: 'DiscountGroup'})
|
|
53
|
+
public variationUnitCostDiscountGroup?: DiscountGroup | null;
|
|
54
|
+
|
|
55
|
+
@VariationFieldsOption.property({type: VariationField})
|
|
56
|
+
public variationField?: VariationField | null;
|
|
57
|
+
|
|
58
|
+
@VariationFieldsOption.property({type: MerchiFile})
|
|
59
|
+
public linkedFile?: MerchiFile | null;
|
|
60
|
+
|
|
61
|
+
@VariationFieldsOption.property({arrayType: 'Variation'})
|
|
62
|
+
public selectedByVariations?: Variation[];
|
|
63
|
+
|
|
64
|
+
@VariationFieldsOption.property({arrayType: 'InventoryUnitVariation'})
|
|
65
|
+
public inventoryUnitVariations?: InventoryUnitVariation[];
|
|
66
|
+
|
|
67
|
+
public totalCost = (quantity: number) => {
|
|
68
|
+
if (this.variationCost === undefined) {
|
|
69
|
+
throw new Error('variationCost is unknown');
|
|
70
|
+
}
|
|
71
|
+
if (this.variationUnitCost === undefined) {
|
|
72
|
+
throw new Error('variationUnitCost is unknown');
|
|
73
|
+
}
|
|
74
|
+
return this.variationCost + this.variationUnitCost * quantity;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
public buildVariationOption = () => {
|
|
78
|
+
const result = new this.merchi.VariationOption(this.merchi);
|
|
79
|
+
result.optionId = this.id;
|
|
80
|
+
result.include = this.include;
|
|
81
|
+
result.value = this.value;
|
|
82
|
+
result.position = this.position;
|
|
83
|
+
result.default = this.default;
|
|
84
|
+
result.colour = this.colour;
|
|
85
|
+
result.linkedFile = this.linkedFile;
|
|
86
|
+
result.quantity = 0;
|
|
87
|
+
|
|
88
|
+
result.currency = this.currency;
|
|
89
|
+
result.unitCost = this.variationUnitCost;
|
|
90
|
+
result.unitCostTotal = 0;
|
|
91
|
+
result.onceOffCost = this.variationCost;
|
|
92
|
+
result.totalCost = this.variationCost;
|
|
93
|
+
return result;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Entity } from '../entity';
|
|
2
|
+
import { MerchiFile } from './file';
|
|
3
|
+
|
|
4
|
+
export class VariationOption extends Entity {
|
|
5
|
+
protected static singularName = 'variationOption';
|
|
6
|
+
protected static pluralName = 'variationOptions';
|
|
7
|
+
|
|
8
|
+
@VariationOption.property()
|
|
9
|
+
public optionId?: number;
|
|
10
|
+
|
|
11
|
+
@VariationOption.property({type: String})
|
|
12
|
+
public value?: string | null;
|
|
13
|
+
|
|
14
|
+
@VariationOption.property({type: String})
|
|
15
|
+
public colour?: string | null;
|
|
16
|
+
|
|
17
|
+
@VariationOption.property()
|
|
18
|
+
public position?: number;
|
|
19
|
+
|
|
20
|
+
@VariationOption.property()
|
|
21
|
+
public available?: boolean;
|
|
22
|
+
|
|
23
|
+
@VariationOption.property()
|
|
24
|
+
public default?: boolean;
|
|
25
|
+
|
|
26
|
+
@VariationOption.property()
|
|
27
|
+
public include?: boolean;
|
|
28
|
+
|
|
29
|
+
@VariationOption.property({type: MerchiFile})
|
|
30
|
+
public linkedFile?: MerchiFile | null;
|
|
31
|
+
|
|
32
|
+
@VariationOption.property()
|
|
33
|
+
public fieldName?: string;
|
|
34
|
+
|
|
35
|
+
@VariationOption.property()
|
|
36
|
+
public quantity?: number;
|
|
37
|
+
|
|
38
|
+
@VariationOption.property()
|
|
39
|
+
public currency?: string;
|
|
40
|
+
|
|
41
|
+
@VariationOption.property()
|
|
42
|
+
public onceOffCost?: number;
|
|
43
|
+
|
|
44
|
+
@VariationOption.property()
|
|
45
|
+
public unitCost?: number;
|
|
46
|
+
|
|
47
|
+
@VariationOption.property()
|
|
48
|
+
public unitCostTotal?: number;
|
|
49
|
+
|
|
50
|
+
@VariationOption.property()
|
|
51
|
+
public totalCost?: number;
|
|
52
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CartItem } from './cart_item';
|
|
2
|
+
import { Entity } from '../entity';
|
|
3
|
+
import { Job } from './job';
|
|
4
|
+
import { Variation } from './variation';
|
|
5
|
+
import { MatchingInventory } from './matching_inventory';
|
|
6
|
+
|
|
7
|
+
export class VariationsGroup extends Entity {
|
|
8
|
+
protected static resourceName = 'variations_groups';
|
|
9
|
+
protected static singularName = 'variationsGroup';
|
|
10
|
+
protected static pluralName = 'variationsGroups';
|
|
11
|
+
|
|
12
|
+
@VariationsGroup.property({type: Date})
|
|
13
|
+
public archived?: Date | null;
|
|
14
|
+
|
|
15
|
+
@VariationsGroup.property()
|
|
16
|
+
public id?: number;
|
|
17
|
+
|
|
18
|
+
@VariationsGroup.property()
|
|
19
|
+
public quantity?: number;
|
|
20
|
+
|
|
21
|
+
@VariationsGroup.property({type: Number})
|
|
22
|
+
public groupCost?: number | null;
|
|
23
|
+
|
|
24
|
+
@VariationsGroup.property({type: Job})
|
|
25
|
+
public job?: Job | null;
|
|
26
|
+
|
|
27
|
+
@VariationsGroup.property({type: CartItem})
|
|
28
|
+
public cartItem?: CartItem | null;
|
|
29
|
+
|
|
30
|
+
@VariationsGroup.property({type: MatchingInventory})
|
|
31
|
+
public matchingInventory?: MatchingInventory | null;
|
|
32
|
+
|
|
33
|
+
@VariationsGroup.property({arrayType: 'Variation'})
|
|
34
|
+
public variations?: Variation[];
|
|
35
|
+
|
|
36
|
+
@VariationsGroup.property({embeddedByDefault: false})
|
|
37
|
+
public inventoryCount?: number;
|
|
38
|
+
|
|
39
|
+
@VariationsGroup.property({embeddedByDefault: false})
|
|
40
|
+
public inventorySufficient?: boolean;
|
|
41
|
+
}
|