@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
package/dist/entity.js
ADDED
|
@@ -0,0 +1,950 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
import 'reflect-metadata';
|
|
13
|
+
import { generateUUID } from './uuid.js';
|
|
14
|
+
function toUnixTimestamp(date) {
|
|
15
|
+
return parseInt(String(date.getTime() / 1000)).toFixed(0);
|
|
16
|
+
}
|
|
17
|
+
export var SerialiseMethod;
|
|
18
|
+
(function (SerialiseMethod) {
|
|
19
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
|
+
SerialiseMethod["TO_DICT"] = "to_dict";
|
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
|
+
SerialiseMethod["ONLY_ID"] = "only_id";
|
|
23
|
+
})(SerialiseMethod || (SerialiseMethod = {}));
|
|
24
|
+
var Entity = /** @class */ (function () {
|
|
25
|
+
function Entity(merchi) {
|
|
26
|
+
var _this = this;
|
|
27
|
+
this.isDirty = false;
|
|
28
|
+
this.backObjects = new Set();
|
|
29
|
+
this.key = generateUUID();
|
|
30
|
+
this.getPrimaryKeyValue = function () {
|
|
31
|
+
var name = _this.constructor.primaryKey;
|
|
32
|
+
var info = _this.propertiesMap.get(name);
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
if (info !== undefined) {
|
|
35
|
+
return info.currentValue;
|
|
36
|
+
}
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
return undefined;
|
|
39
|
+
};
|
|
40
|
+
this.setupProperties = function () {
|
|
41
|
+
var e_1, _a;
|
|
42
|
+
var properties = {};
|
|
43
|
+
var makeSetSingle = function (info) {
|
|
44
|
+
var get = function () {
|
|
45
|
+
return info.currentValue;
|
|
46
|
+
};
|
|
47
|
+
var set = function (newValue) {
|
|
48
|
+
info.currentValue = newValue;
|
|
49
|
+
_this.addBackObject(newValue);
|
|
50
|
+
_this.markDirty(info.property, newValue);
|
|
51
|
+
};
|
|
52
|
+
return { get: get,
|
|
53
|
+
set: set };
|
|
54
|
+
};
|
|
55
|
+
var makeSetScalar = function (info) {
|
|
56
|
+
var get = function () {
|
|
57
|
+
return info.currentValue;
|
|
58
|
+
};
|
|
59
|
+
var set = function (newValue) {
|
|
60
|
+
info.currentValue = newValue;
|
|
61
|
+
_this.markDirty(info.property, newValue);
|
|
62
|
+
};
|
|
63
|
+
return { get: get,
|
|
64
|
+
set: set };
|
|
65
|
+
};
|
|
66
|
+
var makeSetArray = function (info) {
|
|
67
|
+
var get = function () {
|
|
68
|
+
return info.currentValue;
|
|
69
|
+
};
|
|
70
|
+
var set = function (newValue) {
|
|
71
|
+
info.currentValue = newValue;
|
|
72
|
+
_this.addBackObjectList(newValue);
|
|
73
|
+
_this.markDirty(info.property, newValue);
|
|
74
|
+
};
|
|
75
|
+
return { get: get,
|
|
76
|
+
set: set };
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
for (var _b = __values(_this.propertiesMap.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
80
|
+
var info = _c.value;
|
|
81
|
+
if (info.type.prototype instanceof Entity) {
|
|
82
|
+
properties[info.attribute] = makeSetSingle(info);
|
|
83
|
+
}
|
|
84
|
+
else if (info.arrayType) {
|
|
85
|
+
properties[info.attribute] = makeSetArray(info);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
properties[info.attribute] = makeSetScalar(info);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_1) throw e_1.error; }
|
|
98
|
+
}
|
|
99
|
+
Object.defineProperties(_this, properties);
|
|
100
|
+
};
|
|
101
|
+
this.save = function (options) {
|
|
102
|
+
var primaryKey = _this.getPrimaryKeyValue();
|
|
103
|
+
var constructor = _this.constructor;
|
|
104
|
+
var resourceName = constructor.resourceName;
|
|
105
|
+
var singularName = constructor.singularName;
|
|
106
|
+
var resource = "/".concat(resourceName, "/").concat(String(primaryKey), "/");
|
|
107
|
+
var data = _this.toFormData();
|
|
108
|
+
var fetchOptions = { method: 'PATCH',
|
|
109
|
+
body: data };
|
|
110
|
+
fetchOptions.query = [];
|
|
111
|
+
if (options && options.embed) {
|
|
112
|
+
fetchOptions.query.push(['embed', JSON.stringify(options.embed)]);
|
|
113
|
+
}
|
|
114
|
+
if (!(options && options.withRights)) {
|
|
115
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
116
|
+
}
|
|
117
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).then(function (data) {
|
|
118
|
+
_this.fromJson(data[singularName]);
|
|
119
|
+
_this.cleanDirty();
|
|
120
|
+
return _this;
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
this.createFactory = function (_a) {
|
|
124
|
+
var _b = _a.resourceName, resourceName = _b === void 0 ? _this.constructor.resourceName : _b;
|
|
125
|
+
return function (options) {
|
|
126
|
+
var resource = "/".concat(resourceName, "/");
|
|
127
|
+
var data = _this.toFormData();
|
|
128
|
+
var singularName = _this.constructor.singularName;
|
|
129
|
+
var fetchOptions = { method: 'POST',
|
|
130
|
+
body: data };
|
|
131
|
+
fetchOptions.query = [];
|
|
132
|
+
if (options && options.embed) {
|
|
133
|
+
fetchOptions.query.push(['embed', JSON.stringify(options.embed)]);
|
|
134
|
+
}
|
|
135
|
+
if (!(options && options.withRights)) {
|
|
136
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
137
|
+
}
|
|
138
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
139
|
+
then(function (data) {
|
|
140
|
+
_this.fromJson(data[singularName]);
|
|
141
|
+
_this.cleanDirty();
|
|
142
|
+
return _this;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
this.create = this.createFactory({});
|
|
147
|
+
this.getEntityClass = function (name) {
|
|
148
|
+
if (name === undefined) {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
return _this.merchi[name];
|
|
152
|
+
};
|
|
153
|
+
this.cleanDirty = function () {
|
|
154
|
+
var e_2, _a;
|
|
155
|
+
// remove all dirty records of this entity, makes it untouched
|
|
156
|
+
// entity
|
|
157
|
+
_this.isDirty = false;
|
|
158
|
+
try {
|
|
159
|
+
for (var _b = __values(_this.propertiesMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
160
|
+
var entry = _c.value;
|
|
161
|
+
var propertyInfo = entry[1];
|
|
162
|
+
propertyInfo.dirty = false;
|
|
163
|
+
if (propertyInfo.currentValue !== undefined) {
|
|
164
|
+
if (propertyInfo.arrayType) {
|
|
165
|
+
propertyInfo.currentValue.map(function (v) { return v.cleanDirty(); });
|
|
166
|
+
}
|
|
167
|
+
else if (_this.isSingleEntityProperty(propertyInfo)) {
|
|
168
|
+
if (propertyInfo.currentValue) {
|
|
169
|
+
propertyInfo.currentValue.cleanDirty();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
176
|
+
finally {
|
|
177
|
+
try {
|
|
178
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
179
|
+
}
|
|
180
|
+
finally { if (e_2) throw e_2.error; }
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
this.fromJson = function (json, options) {
|
|
184
|
+
options = options || {};
|
|
185
|
+
var _a = options.makeDirty, makeDirty = _a === void 0 ? false : _a, _b = options.arrayValueStrict, arrayValueStrict = _b === void 0 ? true : _b;
|
|
186
|
+
options = { makeDirty: makeDirty, arrayValueStrict: arrayValueStrict };
|
|
187
|
+
var _loop_1 = function (key) {
|
|
188
|
+
var value = json[key];
|
|
189
|
+
if (value === undefined)
|
|
190
|
+
return "continue";
|
|
191
|
+
var propertyInfo = _this.propertiesMap.get(key);
|
|
192
|
+
if (propertyInfo !== undefined) {
|
|
193
|
+
propertyInfo.dirty = makeDirty;
|
|
194
|
+
if (propertyInfo.arrayType) {
|
|
195
|
+
// ignore array value if it is not an array and we did expect it
|
|
196
|
+
if (!arrayValueStrict && !Array.isArray(value))
|
|
197
|
+
return "continue";
|
|
198
|
+
var newValue = value.map(function (item, index) {
|
|
199
|
+
var currentValue = propertyInfo.currentValue;
|
|
200
|
+
// if property already have an array of entities as relationship,
|
|
201
|
+
// try to merge with json one by one, this behavior may need to be
|
|
202
|
+
// configurable in the future.
|
|
203
|
+
if (currentValue && currentValue[index]) {
|
|
204
|
+
return currentValue[index].fromJson(item, options);
|
|
205
|
+
}
|
|
206
|
+
var nested = new propertyInfo.arrayType(_this.merchi);
|
|
207
|
+
return nested.fromJson(item, options);
|
|
208
|
+
});
|
|
209
|
+
propertyInfo.currentValue = newValue;
|
|
210
|
+
}
|
|
211
|
+
else if (_this.isSingleEntityProperty(propertyInfo)) {
|
|
212
|
+
// if property already have a entity as relationship, try to merge
|
|
213
|
+
// with json first, this behavior may need to be configurable in the
|
|
214
|
+
// future.
|
|
215
|
+
if (propertyInfo.currentValue) {
|
|
216
|
+
propertyInfo.currentValue.fromJson(value, options);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
var nested = new propertyInfo.type(_this.merchi);
|
|
220
|
+
propertyInfo.currentValue = nested.fromJson(value, options);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
propertyInfo.currentValue = value;
|
|
225
|
+
if (propertyInfo.type === Date && !!value) {
|
|
226
|
+
propertyInfo.currentValue = new Date(value * 1000);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
for (var key in json) {
|
|
232
|
+
_loop_1(key);
|
|
233
|
+
}
|
|
234
|
+
return _this;
|
|
235
|
+
};
|
|
236
|
+
this.toJson = function () {
|
|
237
|
+
var e_3, _a;
|
|
238
|
+
var json = {};
|
|
239
|
+
try {
|
|
240
|
+
for (var _b = __values(_this.propertiesMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
241
|
+
var entry = _c.value;
|
|
242
|
+
var propertyName = entry[0];
|
|
243
|
+
var propertyInfo = entry[1];
|
|
244
|
+
if (propertyInfo.currentValue !== undefined) {
|
|
245
|
+
if (propertyInfo.arrayType) {
|
|
246
|
+
var array = propertyInfo.currentValue.map(function (v) { return v.toJson(); });
|
|
247
|
+
json[propertyName] = array;
|
|
248
|
+
}
|
|
249
|
+
else if (_this.isSingleEntityProperty(propertyInfo)) {
|
|
250
|
+
if (propertyInfo.currentValue === null) {
|
|
251
|
+
json[propertyName] = null;
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
json[propertyName] = propertyInfo.currentValue.toJson();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
var value = propertyInfo.currentValue;
|
|
259
|
+
json[propertyName] = value;
|
|
260
|
+
if (propertyInfo.type === Date && !!value) {
|
|
261
|
+
json[propertyName] = value.getTime() / 1000;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
268
|
+
finally {
|
|
269
|
+
try {
|
|
270
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
271
|
+
}
|
|
272
|
+
finally { if (e_3) throw e_3.error; }
|
|
273
|
+
}
|
|
274
|
+
return json;
|
|
275
|
+
};
|
|
276
|
+
this.forEachProperty = function (fn) {
|
|
277
|
+
var e_4, _a;
|
|
278
|
+
try {
|
|
279
|
+
for (var _b = __values(_this.propertiesMap.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
280
|
+
var info = _c.value;
|
|
281
|
+
fn(info);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
285
|
+
finally {
|
|
286
|
+
try {
|
|
287
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
288
|
+
}
|
|
289
|
+
finally { if (e_4) throw e_4.error; }
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
this.toFormData = function (options, fileIndex) {
|
|
293
|
+
if (options === undefined) {
|
|
294
|
+
options = {};
|
|
295
|
+
}
|
|
296
|
+
var result = options.existing || new FormData();
|
|
297
|
+
var prefix = options._prefix || '';
|
|
298
|
+
var excludeOld = options.excludeOld === undefined ?
|
|
299
|
+
true : options.excludeOld;
|
|
300
|
+
if (fileIndex === undefined) {
|
|
301
|
+
fileIndex = { value: 0 };
|
|
302
|
+
}
|
|
303
|
+
var appendData = function (name, value) {
|
|
304
|
+
/* istanbul ignore next */
|
|
305
|
+
if (name === undefined || value === undefined) {
|
|
306
|
+
/* istanbul ignore next */
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (prefix) {
|
|
310
|
+
name = prefix + '-' + name;
|
|
311
|
+
}
|
|
312
|
+
result.set(name, value);
|
|
313
|
+
};
|
|
314
|
+
if (_this.fileData !== undefined) {
|
|
315
|
+
result.set(String(fileIndex.value), _this.fileData);
|
|
316
|
+
appendData('fileDataIndex', fileIndex.value);
|
|
317
|
+
fileIndex.value++;
|
|
318
|
+
}
|
|
319
|
+
var processArrayProperty = function (info, value) {
|
|
320
|
+
var e_5, _a;
|
|
321
|
+
var remoteCount = value.length;
|
|
322
|
+
var initialLength = Array.from(result.entries()).length;
|
|
323
|
+
if (remoteCount === 0 && info.dirty) {
|
|
324
|
+
appendData(info.property + '-count', 0);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
var isDirty = false;
|
|
328
|
+
try {
|
|
329
|
+
for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
|
|
330
|
+
var item = value_1_1.value;
|
|
331
|
+
if (item.isDirty) {
|
|
332
|
+
isDirty = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
338
|
+
finally {
|
|
339
|
+
try {
|
|
340
|
+
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
341
|
+
}
|
|
342
|
+
finally { if (e_5) throw e_5.error; }
|
|
343
|
+
}
|
|
344
|
+
isDirty = isDirty || info.dirty;
|
|
345
|
+
if (!isDirty && excludeOld) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
for (var i = 0; i < remoteCount; ++i) {
|
|
349
|
+
var innerPrefix = info.property + '-' + i;
|
|
350
|
+
if (prefix) {
|
|
351
|
+
innerPrefix = prefix + '-' + innerPrefix;
|
|
352
|
+
}
|
|
353
|
+
value[i].toFormData({ existing: result, _prefix: innerPrefix, excludeOld: excludeOld }, fileIndex);
|
|
354
|
+
}
|
|
355
|
+
var finalLength = Array.from(result.entries()).length;
|
|
356
|
+
if ((finalLength - initialLength) > 0) {
|
|
357
|
+
appendData(info.property + '-count', remoteCount);
|
|
358
|
+
if (info.updatingOrder) {
|
|
359
|
+
appendData(info.property + '-*updateOrder', 'true');
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var processSingleEntityProperty = function (info, value) {
|
|
364
|
+
var primaryKey = _this.constructor.primaryKey;
|
|
365
|
+
var innerPrefix = info.property + '-0';
|
|
366
|
+
if (prefix) {
|
|
367
|
+
innerPrefix = prefix + '-' + innerPrefix;
|
|
368
|
+
}
|
|
369
|
+
if (value === null) {
|
|
370
|
+
if (info.dirty || !excludeOld) {
|
|
371
|
+
appendData(info.property + '-0-' + primaryKey, '-1');
|
|
372
|
+
appendData(info.property + '-count', 1);
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!(info.dirty || (value.isDirty)) && excludeOld) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
var initialLength = Array.from(result.entries()).length;
|
|
380
|
+
value.toFormData({ existing: result, _prefix: innerPrefix, excludeOld: excludeOld }, fileIndex);
|
|
381
|
+
var finalLength = Array.from(result.entries()).length;
|
|
382
|
+
if ((finalLength - initialLength) > 0) {
|
|
383
|
+
appendData(info.property + '-count', 1);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
var processScalarProperty = function (info, value) {
|
|
387
|
+
var primaryKey = _this.constructor.primaryKey;
|
|
388
|
+
if (!excludeOld ||
|
|
389
|
+
info.dirty ||
|
|
390
|
+
(info.property === primaryKey && value)) {
|
|
391
|
+
if (info.type === Date && !!value) {
|
|
392
|
+
value = value.getTime() / 1000;
|
|
393
|
+
}
|
|
394
|
+
else if (
|
|
395
|
+
// JSON/JSONB columns (e.g. Domain.jobAgentPolicy) are plain objects.
|
|
396
|
+
// FormData stringifies objects as "[object Object]" unless we encode.
|
|
397
|
+
value !== null &&
|
|
398
|
+
typeof value === 'object' &&
|
|
399
|
+
!(typeof Blob !== 'undefined' && value instanceof Blob)) {
|
|
400
|
+
value = JSON.stringify(value);
|
|
401
|
+
}
|
|
402
|
+
appendData(info.property, value);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
var processProperty = function (info) {
|
|
406
|
+
var value = _this[info.attribute];
|
|
407
|
+
if (value === undefined) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
else if (info.arrayType) {
|
|
411
|
+
processArrayProperty(info, value);
|
|
412
|
+
}
|
|
413
|
+
else if (_this.isSingleEntityProperty(info)) {
|
|
414
|
+
processSingleEntityProperty(info, value);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
processScalarProperty(info, value);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
_this.forEachProperty(processProperty);
|
|
421
|
+
return result;
|
|
422
|
+
};
|
|
423
|
+
this.addBackObject = function (remote) {
|
|
424
|
+
if (remote !== undefined) {
|
|
425
|
+
remote.backObjects.add(_this);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
this.addBackObjectList = function (remotes) {
|
|
429
|
+
if (remotes !== undefined) {
|
|
430
|
+
remotes.forEach(_this.addBackObject);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
this.updateOrder = function (property) {
|
|
434
|
+
_this.propertiesMap.get(property).updatingOrder = true;
|
|
435
|
+
};
|
|
436
|
+
this.markDirty = function (property, newValue) {
|
|
437
|
+
var e_6, _a;
|
|
438
|
+
if (newValue === undefined) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
_this.propertiesMap.get(property).dirty = true;
|
|
442
|
+
var openSet = []; /* Queue (BFS) */
|
|
443
|
+
var closedSet = new Set();
|
|
444
|
+
openSet.push(_this);
|
|
445
|
+
while (openSet.length > 0) {
|
|
446
|
+
var current = openSet.shift();
|
|
447
|
+
if (!closedSet.has(current)) {
|
|
448
|
+
current.isDirty = true;
|
|
449
|
+
closedSet.add(current);
|
|
450
|
+
try {
|
|
451
|
+
for (var _b = (e_6 = void 0, __values(current.backObjects)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
452
|
+
var child = _c.value;
|
|
453
|
+
openSet.push(child);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
457
|
+
finally {
|
|
458
|
+
try {
|
|
459
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
460
|
+
}
|
|
461
|
+
finally { if (e_6) throw e_6.error; }
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
this.delete = function (options) {
|
|
467
|
+
var primaryKey = _this.getPrimaryKeyValue();
|
|
468
|
+
var resourceName = _this.constructor.resourceName;
|
|
469
|
+
var resource = "/".concat(resourceName, "/").concat(String(primaryKey), "/");
|
|
470
|
+
var fetchOptions = { method: 'DELETE' };
|
|
471
|
+
fetchOptions.query = [];
|
|
472
|
+
if (!(options && options.withRights)) {
|
|
473
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
474
|
+
}
|
|
475
|
+
if (_this.merchi.sessionToken) {
|
|
476
|
+
fetchOptions.query.push(['session_token', _this.merchi.sessionToken]);
|
|
477
|
+
}
|
|
478
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions, true).then(function () { return _this; });
|
|
479
|
+
};
|
|
480
|
+
this.recover = function (options) {
|
|
481
|
+
var primaryKey = _this.getPrimaryKeyValue();
|
|
482
|
+
var constructor = _this.constructor;
|
|
483
|
+
var resourceName = constructor.resourceName;
|
|
484
|
+
var singularName = constructor.singularName;
|
|
485
|
+
var resource = "/unarchive/".concat(resourceName, "/").concat(String(primaryKey), "/");
|
|
486
|
+
var fetchOptions = { method: 'POST' };
|
|
487
|
+
fetchOptions.query = [];
|
|
488
|
+
if (options && options.embed) {
|
|
489
|
+
fetchOptions.query.push(['embed', JSON.stringify(options.embed)]);
|
|
490
|
+
}
|
|
491
|
+
if (!(options && options.withRights)) {
|
|
492
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
493
|
+
}
|
|
494
|
+
return _this.merchi.authenticatedFetch(resource, fetchOptions).then(function (data) {
|
|
495
|
+
_this.fromJson(data[singularName]);
|
|
496
|
+
return _this;
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
/* istanbul ignore next */
|
|
500
|
+
if (merchi !== undefined) {
|
|
501
|
+
this.merchi = merchi;
|
|
502
|
+
}
|
|
503
|
+
this.propertiesMap = this.makePropertiesMap();
|
|
504
|
+
this.setupProperties();
|
|
505
|
+
}
|
|
506
|
+
Entity.prototype.isSingleEntityProperty = function (info) {
|
|
507
|
+
// the choice of 'Product' below is unimportant -- all Entities should
|
|
508
|
+
// have the same prototype but i don't know how to get instanceof
|
|
509
|
+
// working, so i just compare prototypes directly.
|
|
510
|
+
return (info.type.prototype === this.merchi.Product.prototype ||
|
|
511
|
+
info.type.prototype instanceof Entity);
|
|
512
|
+
};
|
|
513
|
+
Entity.property = function (options) {
|
|
514
|
+
return function (target, propertyKey) {
|
|
515
|
+
if (!options) {
|
|
516
|
+
options = {};
|
|
517
|
+
}
|
|
518
|
+
var arrayType = options.arrayType;
|
|
519
|
+
var jsonName = options.jsonName || propertyKey;
|
|
520
|
+
var properties = Reflect.getMetadata(Entity.propertiesSetKey, target.constructor);
|
|
521
|
+
properties = properties || new Set();
|
|
522
|
+
properties.add(propertyKey);
|
|
523
|
+
Reflect.defineMetadata(Entity.propertiesSetKey, properties, target.constructor);
|
|
524
|
+
Reflect.defineMetadata(Entity.jsonNameKey, jsonName, target, propertyKey);
|
|
525
|
+
Reflect.defineMetadata(Entity.arrayTypeKey, arrayType, target, propertyKey);
|
|
526
|
+
Reflect.defineMetadata(Entity.extraOptionsKey, options, target, propertyKey);
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
Entity.prototype.makePropertiesMap = function () {
|
|
530
|
+
var map = new Map();
|
|
531
|
+
var self = this;
|
|
532
|
+
var properties = Reflect.getMetadata(Entity.propertiesSetKey, this.constructor);
|
|
533
|
+
properties.forEach(function (attributeName) {
|
|
534
|
+
var jsonName = Reflect.getMetadata(Entity.jsonNameKey, self, attributeName);
|
|
535
|
+
var propertyType = Reflect.getMetadata('design:type', self, attributeName);
|
|
536
|
+
// the array type is needed because 'design:type' breaks down
|
|
537
|
+
// with recursive classes, and also, does not contain the type
|
|
538
|
+
// of an arrays elements, which we need
|
|
539
|
+
var arrayType = Reflect.getMetadata(Entity.arrayTypeKey, self, attributeName);
|
|
540
|
+
var realArrayType = self.getEntityClass(arrayType);
|
|
541
|
+
var options = Reflect.getMetadata(Entity.extraOptionsKey, self, attributeName);
|
|
542
|
+
if (arrayType !== undefined) {
|
|
543
|
+
/* istanbul ignore next */
|
|
544
|
+
if (propertyType !== Object && propertyType !== Array) {
|
|
545
|
+
/* istanbul ignore next */
|
|
546
|
+
throw new Error('array type can only be given for arrays');
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
var type;
|
|
550
|
+
if (options.type === undefined) {
|
|
551
|
+
type = propertyType;
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
type = options.type;
|
|
555
|
+
if (typeof type === 'string') {
|
|
556
|
+
type = self.getEntityClass(type);
|
|
557
|
+
}
|
|
558
|
+
if (type.prototype instanceof Entity) {
|
|
559
|
+
type = self.merchi.setupClass(type);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
var normallyEmbeddedByDefault = !(realArrayType ||
|
|
563
|
+
type.prototype instanceof Entity);
|
|
564
|
+
var embeddedByDefault = options.embeddedByDefault !== undefined ?
|
|
565
|
+
options.embeddedByDefault : normallyEmbeddedByDefault;
|
|
566
|
+
/* istanbul ignore next */
|
|
567
|
+
if (type === Object) {
|
|
568
|
+
/* istanbul ignore next */
|
|
569
|
+
var resource = self.constructor.resourceName;
|
|
570
|
+
var err = 'Bad attribute type ' +
|
|
571
|
+
"".concat(resource, ".").concat(attributeName, ": ").concat(type);
|
|
572
|
+
throw new Error(err);
|
|
573
|
+
}
|
|
574
|
+
var propertyInfo = { property: jsonName,
|
|
575
|
+
attribute: attributeName,
|
|
576
|
+
type: type,
|
|
577
|
+
arrayType: realArrayType,
|
|
578
|
+
embeddedByDefault: embeddedByDefault,
|
|
579
|
+
dirty: true,
|
|
580
|
+
updatingOrder: false };
|
|
581
|
+
map.set(jsonName, propertyInfo);
|
|
582
|
+
});
|
|
583
|
+
return map;
|
|
584
|
+
};
|
|
585
|
+
Entity.get = function (key, options) {
|
|
586
|
+
var _this = this;
|
|
587
|
+
var resource = "/".concat(this.resourceName, "/").concat(String(key), "/");
|
|
588
|
+
var fetchOptions = {};
|
|
589
|
+
fetchOptions.query = [];
|
|
590
|
+
if (options && options.embed) {
|
|
591
|
+
fetchOptions.query.push(['embed', JSON.stringify(options.embed)]);
|
|
592
|
+
}
|
|
593
|
+
if (options && options.includeArchived) {
|
|
594
|
+
fetchOptions.query.push(['include_archived',
|
|
595
|
+
JSON.stringify(options.includeArchived)]);
|
|
596
|
+
}
|
|
597
|
+
if (!(options && options.withRights)) {
|
|
598
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
599
|
+
}
|
|
600
|
+
return this.merchi.authenticatedFetch(resource, fetchOptions).
|
|
601
|
+
then(function (data) {
|
|
602
|
+
var result = (new _this());
|
|
603
|
+
result.fromJson(data[_this.singularName]);
|
|
604
|
+
return result;
|
|
605
|
+
});
|
|
606
|
+
};
|
|
607
|
+
Entity.list = function (options) {
|
|
608
|
+
var _this = this;
|
|
609
|
+
var resource = "/".concat(this.resourceName, "/");
|
|
610
|
+
var fetchOptions = {};
|
|
611
|
+
fetchOptions.query = [];
|
|
612
|
+
if (options) {
|
|
613
|
+
if (options.embed) {
|
|
614
|
+
fetchOptions.query.push(['embed', JSON.stringify(options.embed)]);
|
|
615
|
+
}
|
|
616
|
+
if (options.offset !== undefined) {
|
|
617
|
+
fetchOptions.query.push(['offset', options.offset.toString()]);
|
|
618
|
+
}
|
|
619
|
+
if (options.descendants !== undefined) {
|
|
620
|
+
fetchOptions.query.push(['descendants', options.descendants.toString()]);
|
|
621
|
+
}
|
|
622
|
+
if (options.limit !== undefined) {
|
|
623
|
+
fetchOptions.query.push(['limit', options.limit.toString()]);
|
|
624
|
+
}
|
|
625
|
+
if (options.skipCount !== undefined) {
|
|
626
|
+
// Snake-case is the canonical form on the server; the API
|
|
627
|
+
// also accepts ``skipCount`` via its camelCase alias, but
|
|
628
|
+
// matching the wire shape of the other ``*_only`` /
|
|
629
|
+
// ``*_filter`` flags keeps logs and traffic captures
|
|
630
|
+
// consistent.
|
|
631
|
+
fetchOptions.query.push(['skip_count', options.skipCount.toString()]);
|
|
632
|
+
}
|
|
633
|
+
if (options.q !== undefined) {
|
|
634
|
+
fetchOptions.query.push(['q', options.q]);
|
|
635
|
+
}
|
|
636
|
+
if (options.sort !== undefined) {
|
|
637
|
+
fetchOptions.query.push(['sort', options.sort]);
|
|
638
|
+
}
|
|
639
|
+
if (options.order !== undefined) {
|
|
640
|
+
fetchOptions.query.push(['order', options.order]);
|
|
641
|
+
}
|
|
642
|
+
if (options.serialiseMethod !== undefined) {
|
|
643
|
+
fetchOptions.query.push(['serialise_method', options.serialiseMethod]);
|
|
644
|
+
}
|
|
645
|
+
if (options.tab !== undefined) {
|
|
646
|
+
fetchOptions.query.push(['tab', options.tab]);
|
|
647
|
+
}
|
|
648
|
+
if (options.trackingNumber !== undefined) {
|
|
649
|
+
fetchOptions.query.push(['tracking_number', options.trackingNumber]);
|
|
650
|
+
}
|
|
651
|
+
if (options.as !== undefined) {
|
|
652
|
+
fetchOptions.query.push(['as', options.as]);
|
|
653
|
+
}
|
|
654
|
+
if (options.state !== undefined) {
|
|
655
|
+
fetchOptions.query.push(['state', options.state]);
|
|
656
|
+
}
|
|
657
|
+
if (options.categoryId !== undefined) {
|
|
658
|
+
fetchOptions.query.push(['category_id', options.categoryId.toString()]);
|
|
659
|
+
}
|
|
660
|
+
if (options.platformCategoryId !== undefined) {
|
|
661
|
+
fetchOptions.query.push(['platform_category_id', options.platformCategoryId.toString()]);
|
|
662
|
+
}
|
|
663
|
+
if (options.inDomain !== undefined) {
|
|
664
|
+
fetchOptions.query.push(['in_domain', options.inDomain.toString()]);
|
|
665
|
+
}
|
|
666
|
+
if (options.inDomainName !== undefined) {
|
|
667
|
+
fetchOptions.query.push(['in_domain_name', options.inDomainName.toString()]);
|
|
668
|
+
}
|
|
669
|
+
if (options.inDomainRoles !== undefined) {
|
|
670
|
+
fetchOptions.query.push(['in_domain_roles',
|
|
671
|
+
JSON.stringify(options.inDomainRoles)]);
|
|
672
|
+
}
|
|
673
|
+
if (options.isPrivate !== undefined) {
|
|
674
|
+
fetchOptions.query.push(['is_private', options.isPrivate.toString()]);
|
|
675
|
+
}
|
|
676
|
+
if (options.asRole !== undefined) {
|
|
677
|
+
fetchOptions.query.push(['as_role', options.asRole.toString()]);
|
|
678
|
+
}
|
|
679
|
+
if (options.isJobManager !== undefined) {
|
|
680
|
+
fetchOptions.query.push(['is_job_manager', options.isJobManager.toString()]);
|
|
681
|
+
}
|
|
682
|
+
if (options.groupBuyOnly !== undefined) {
|
|
683
|
+
fetchOptions.query.push(['group_buy_only', options.groupBuyOnly.toString()]);
|
|
684
|
+
}
|
|
685
|
+
if (options.publicOnly !== undefined) {
|
|
686
|
+
fetchOptions.query.push(['public_only', options.publicOnly.toString()]);
|
|
687
|
+
}
|
|
688
|
+
if (options.isDraft !== undefined) {
|
|
689
|
+
fetchOptions.query.push(['is_draft', options.isDraft.toString()]);
|
|
690
|
+
}
|
|
691
|
+
if (options.managedOnly !== undefined) {
|
|
692
|
+
fetchOptions.query.push(['managed_only',
|
|
693
|
+
options.managedOnly.toString()]);
|
|
694
|
+
}
|
|
695
|
+
if (options.doesNotHaveAdminDomain !== undefined) {
|
|
696
|
+
fetchOptions.query.push(['does_not_have_admin_domain',
|
|
697
|
+
options.doesNotHaveAdminDomain.toString()]);
|
|
698
|
+
}
|
|
699
|
+
if (options.categories !== undefined) {
|
|
700
|
+
fetchOptions.query.push(['categories', options.categories.toString()]);
|
|
701
|
+
}
|
|
702
|
+
if (options.clientOnly !== undefined) {
|
|
703
|
+
fetchOptions.query.push(['client_only',
|
|
704
|
+
options.clientOnly.toString()]);
|
|
705
|
+
}
|
|
706
|
+
if (options.teamOnly !== undefined) {
|
|
707
|
+
fetchOptions.query.push(['team_only',
|
|
708
|
+
options.teamOnly.toString()]);
|
|
709
|
+
}
|
|
710
|
+
if (options.memberOnly !== undefined) {
|
|
711
|
+
fetchOptions.query.push(['member_only', options.memberOnly.toString()]);
|
|
712
|
+
}
|
|
713
|
+
if (options.merchiOnly !== undefined) {
|
|
714
|
+
fetchOptions.query.push(['merchi_only', options.merchiOnly.toString()]);
|
|
715
|
+
}
|
|
716
|
+
if (options.supplierResellOnly !== undefined) {
|
|
717
|
+
fetchOptions.query.push(['supplier_resell_only', options.supplierResellOnly.toString()]);
|
|
718
|
+
}
|
|
719
|
+
if (options.shopifyOnly !== undefined) {
|
|
720
|
+
fetchOptions.query.push(['shopify_only', options.shopifyOnly.toString()]);
|
|
721
|
+
}
|
|
722
|
+
if (options.inbound !== undefined) {
|
|
723
|
+
fetchOptions.query.push(['inbound', options.inbound.toString()]);
|
|
724
|
+
}
|
|
725
|
+
if (options.isMaster !== undefined) {
|
|
726
|
+
fetchOptions.query.push(['is_master', options.isMaster.toString()]);
|
|
727
|
+
}
|
|
728
|
+
if (options.domainRoles !== undefined) {
|
|
729
|
+
fetchOptions.query.push(['domain_roles',
|
|
730
|
+
options.domainRoles.join(',')]);
|
|
731
|
+
}
|
|
732
|
+
if (options.domainTypes !== undefined) {
|
|
733
|
+
fetchOptions.query.push(['domain_types',
|
|
734
|
+
options.domainTypes.join(',')]);
|
|
735
|
+
}
|
|
736
|
+
if (options.entityTypes !== undefined) {
|
|
737
|
+
fetchOptions.query.push(['entity_types',
|
|
738
|
+
options.entityTypes.join(',')]);
|
|
739
|
+
}
|
|
740
|
+
if (options.priceRange !== undefined) {
|
|
741
|
+
fetchOptions.query.push(['price_range',
|
|
742
|
+
options.priceRange.join(',')]);
|
|
743
|
+
}
|
|
744
|
+
if (options.productTypes !== undefined) {
|
|
745
|
+
fetchOptions.query.push(['product_types',
|
|
746
|
+
options.productTypes.join(',')]);
|
|
747
|
+
}
|
|
748
|
+
if (options.managedDomainsOnly !== undefined) {
|
|
749
|
+
fetchOptions.query.push(['managed_domains_only',
|
|
750
|
+
options.managedDomainsOnly.toString()]);
|
|
751
|
+
}
|
|
752
|
+
if (options.businessDomainsOnly !== undefined) {
|
|
753
|
+
fetchOptions.query.push(['business_domains_only',
|
|
754
|
+
options.businessDomainsOnly.toString()]);
|
|
755
|
+
}
|
|
756
|
+
if (options.dateFrom !== undefined) {
|
|
757
|
+
fetchOptions.query.push(['date_from',
|
|
758
|
+
toUnixTimestamp(options.dateFrom)]);
|
|
759
|
+
}
|
|
760
|
+
if (options.dateTo !== undefined) {
|
|
761
|
+
fetchOptions.query.push(['date_to', toUnixTimestamp(options.dateTo)]);
|
|
762
|
+
}
|
|
763
|
+
if (options.originalOf !== undefined) {
|
|
764
|
+
fetchOptions.query.push(['original_of',
|
|
765
|
+
options.originalOf.toString()]);
|
|
766
|
+
}
|
|
767
|
+
if (options.relatedAssignment !== undefined) {
|
|
768
|
+
fetchOptions.query.push(['related_assignment',
|
|
769
|
+
options.relatedAssignment.toString()]);
|
|
770
|
+
}
|
|
771
|
+
if (options.relatedDraft !== undefined) {
|
|
772
|
+
fetchOptions.query.push(['related_draft',
|
|
773
|
+
options.relatedDraft.toString()]);
|
|
774
|
+
}
|
|
775
|
+
if (options.relatedJob !== undefined) {
|
|
776
|
+
fetchOptions.query.push(['related_job', options.relatedJob.toString()]);
|
|
777
|
+
}
|
|
778
|
+
if (options.relatedJobs !== undefined) {
|
|
779
|
+
fetchOptions.query.push(['related_jobs', options.relatedJobs.toString()]);
|
|
780
|
+
}
|
|
781
|
+
if (options.relatedShipment !== undefined) {
|
|
782
|
+
fetchOptions.query.push(['related_shipment',
|
|
783
|
+
options.relatedShipment.toString()]);
|
|
784
|
+
}
|
|
785
|
+
if (options.relatedProduct !== undefined) {
|
|
786
|
+
fetchOptions.query.push(['related_product',
|
|
787
|
+
options.relatedProduct.toString()]);
|
|
788
|
+
}
|
|
789
|
+
if (options.jobNotifiable !== undefined) {
|
|
790
|
+
fetchOptions.query.push(['job_notifiable',
|
|
791
|
+
options.jobNotifiable.toString()]);
|
|
792
|
+
}
|
|
793
|
+
if (options.notificationType !== undefined) {
|
|
794
|
+
fetchOptions.query.push(['notification_type',
|
|
795
|
+
options.notificationType.toString()]);
|
|
796
|
+
}
|
|
797
|
+
if (options.notificationRecipient !== undefined) {
|
|
798
|
+
fetchOptions.query.push(['notification_recipient',
|
|
799
|
+
options.notificationRecipient.toString()]);
|
|
800
|
+
}
|
|
801
|
+
if (options.notificationSender !== undefined) {
|
|
802
|
+
fetchOptions.query.push(['notification_sender',
|
|
803
|
+
options.notificationSender.toString()]);
|
|
804
|
+
}
|
|
805
|
+
if (options.notificationJob !== undefined) {
|
|
806
|
+
fetchOptions.query.push(['notification_job',
|
|
807
|
+
options.notificationJob.toString()]);
|
|
808
|
+
}
|
|
809
|
+
if (options.relatedUser !== undefined) {
|
|
810
|
+
fetchOptions.query.push(['related_user',
|
|
811
|
+
options.relatedUser.toString()]);
|
|
812
|
+
}
|
|
813
|
+
if (options.clientId !== undefined) {
|
|
814
|
+
fetchOptions.query.push(['client_id', options.clientId.toString()]);
|
|
815
|
+
}
|
|
816
|
+
if (options.managerId !== undefined) {
|
|
817
|
+
fetchOptions.query.push(['manager_id', options.managerId.toString()]);
|
|
818
|
+
}
|
|
819
|
+
if (options.masterProduct !== undefined) {
|
|
820
|
+
fetchOptions.query.push(['master_product', options.masterProduct.toString()]);
|
|
821
|
+
}
|
|
822
|
+
if (options.clientCompanyId !== undefined) {
|
|
823
|
+
fetchOptions.query.push(['client_company_id',
|
|
824
|
+
options.clientCompanyId.toString()]);
|
|
825
|
+
}
|
|
826
|
+
if (options.savedByUser !== undefined) {
|
|
827
|
+
fetchOptions.query.push(['saved_by_user',
|
|
828
|
+
options.savedByUser.toString()]);
|
|
829
|
+
}
|
|
830
|
+
if (options.senderCompanyId !== undefined) {
|
|
831
|
+
fetchOptions.query.push(['sender_company_id',
|
|
832
|
+
options.senderCompanyId.toString()]);
|
|
833
|
+
}
|
|
834
|
+
if (options.receiverId !== undefined) {
|
|
835
|
+
fetchOptions.query.push(['receiver_id', options.receiverId.toString()]);
|
|
836
|
+
}
|
|
837
|
+
if (options.userAsReceiver !== undefined) {
|
|
838
|
+
fetchOptions.query.push(['user_as_receiver', options.userAsReceiver.toString()]);
|
|
839
|
+
}
|
|
840
|
+
if (options.companyCustomerId !== undefined) {
|
|
841
|
+
fetchOptions.query.push(['company_customer_id', options.companyCustomerId.toString()]);
|
|
842
|
+
}
|
|
843
|
+
if (options.companyId !== undefined) {
|
|
844
|
+
fetchOptions.query.push(['company_id', options.companyId.toString()]);
|
|
845
|
+
}
|
|
846
|
+
if (options.companySupplierId !== undefined) {
|
|
847
|
+
fetchOptions.query.push(['company_supplier_id', options.companySupplierId.toString()]);
|
|
848
|
+
}
|
|
849
|
+
if (options.conversationId !== undefined) {
|
|
850
|
+
fetchOptions.query.push(['conversation_id',
|
|
851
|
+
options.conversationId.toString()]);
|
|
852
|
+
}
|
|
853
|
+
if (options.groupBuyForJobId !== undefined) {
|
|
854
|
+
fetchOptions.query.push(['group_buy_for_job_id',
|
|
855
|
+
options.groupBuyForJobId.toString()]);
|
|
856
|
+
}
|
|
857
|
+
if (options.googleMerchantCenterExported !== undefined) {
|
|
858
|
+
fetchOptions.query.push(['google_merchant_center_exported',
|
|
859
|
+
options.googleMerchantCenterExported.toString()]);
|
|
860
|
+
}
|
|
861
|
+
if (options.section !== undefined) {
|
|
862
|
+
fetchOptions.query.push(['section', options.section.toString()]);
|
|
863
|
+
}
|
|
864
|
+
if (options.senderRole !== undefined) {
|
|
865
|
+
fetchOptions.query.push(['sender_role', options.senderRole.toString()]);
|
|
866
|
+
}
|
|
867
|
+
if (options.isOrder) {
|
|
868
|
+
fetchOptions.query.push(['is_order', 'true']);
|
|
869
|
+
}
|
|
870
|
+
if (options.tags !== undefined) {
|
|
871
|
+
fetchOptions.query.push(['tags', options.tags.join(',')]);
|
|
872
|
+
}
|
|
873
|
+
if (options.excludeTags !== undefined) {
|
|
874
|
+
fetchOptions.query.push(['exclude_tags', options.excludeTags.join(',')]);
|
|
875
|
+
}
|
|
876
|
+
if (options.excludeTagsInternal !== undefined) {
|
|
877
|
+
fetchOptions.query.push(['exclude_tags_internal', options.excludeTagsInternal.join(',')]);
|
|
878
|
+
}
|
|
879
|
+
if (options.tagsInternal !== undefined) {
|
|
880
|
+
fetchOptions.query.push(['tags_internal', options.tagsInternal.join(',')]);
|
|
881
|
+
}
|
|
882
|
+
if (options.tagNames !== undefined) {
|
|
883
|
+
fetchOptions.query.push(['tag_names', options.tagNames.join(',')]);
|
|
884
|
+
}
|
|
885
|
+
if (options.turnaroundTimeDays !== undefined) {
|
|
886
|
+
fetchOptions.query.push(['turnaround_time_days', options.turnaroundTimeDays.toString()]);
|
|
887
|
+
}
|
|
888
|
+
if (options.exclude !== undefined) {
|
|
889
|
+
fetchOptions.query.push(['exclude', options.exclude.join(',')]);
|
|
890
|
+
}
|
|
891
|
+
if (options.excludeDomains !== undefined) {
|
|
892
|
+
fetchOptions.query.push(['exclude_domains', options.excludeDomains.join(',')]);
|
|
893
|
+
}
|
|
894
|
+
if (options.excludeJobs !== undefined) {
|
|
895
|
+
fetchOptions.query.push(['exclude_jobs', options.excludeJobs.join(',')]);
|
|
896
|
+
}
|
|
897
|
+
if (options.includeOnly !== undefined) {
|
|
898
|
+
fetchOptions.query.push(['include_only', options.includeOnly.join(',')]);
|
|
899
|
+
}
|
|
900
|
+
if (options.orClientId !== undefined) {
|
|
901
|
+
fetchOptions.query.push(['or_client_id', options.orClientId.toString()]);
|
|
902
|
+
}
|
|
903
|
+
if (options.orClientCompanyId !== undefined) {
|
|
904
|
+
var companyIds = Array.isArray(options.orClientCompanyId)
|
|
905
|
+
? options.orClientCompanyId.join(',')
|
|
906
|
+
: options.orClientCompanyId.toString();
|
|
907
|
+
fetchOptions.query.push(['or_client_company_id', companyIds]);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
if (!(options && options.withRights)) {
|
|
911
|
+
fetchOptions.query.push(['skip_rights', 'y']);
|
|
912
|
+
}
|
|
913
|
+
return this.merchi.authenticatedFetch(resource, fetchOptions).then(function (data) {
|
|
914
|
+
var e_7, _a;
|
|
915
|
+
var metadata = { canCreate: data.canCreate,
|
|
916
|
+
available: data.available,
|
|
917
|
+
count: data.count,
|
|
918
|
+
limit: data.limit,
|
|
919
|
+
offset: data.offset };
|
|
920
|
+
var pluralName = _this.pluralName;
|
|
921
|
+
var singularName = _this.singularName;
|
|
922
|
+
var items = data[pluralName];
|
|
923
|
+
var entities = [];
|
|
924
|
+
try {
|
|
925
|
+
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
|
926
|
+
var item = items_1_1.value;
|
|
927
|
+
var entity = (new _this());
|
|
928
|
+
entity.fromJson(item[singularName]);
|
|
929
|
+
entities.push(entity);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
933
|
+
finally {
|
|
934
|
+
try {
|
|
935
|
+
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
|
|
936
|
+
}
|
|
937
|
+
finally { if (e_7) throw e_7.error; }
|
|
938
|
+
}
|
|
939
|
+
return { items: entities,
|
|
940
|
+
metadata: metadata };
|
|
941
|
+
});
|
|
942
|
+
};
|
|
943
|
+
Entity.jsonNameKey = Symbol('jsonName');
|
|
944
|
+
Entity.arrayTypeKey = Symbol('arrayType');
|
|
945
|
+
Entity.extraOptionsKey = Symbol('extraOptions');
|
|
946
|
+
Entity.propertiesSetKey = Symbol('propertiesSet');
|
|
947
|
+
Entity.primaryKey = 'id';
|
|
948
|
+
return Entity;
|
|
949
|
+
}());
|
|
950
|
+
export { Entity };
|