@myparcel-dev/pdk-admin 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/__tests__/doComponentTestSetup.d.ts +2 -0
- package/dist/__tests__/doComponentTestTeardown.d.ts +1 -0
- package/dist/__tests__/index.d.ts +3 -0
- package/dist/__tests__/mocks/index.d.ts +14 -0
- package/dist/__tests__/mocks/mockDefaultAccount.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultAppConfig.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultAppInfo.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultCarriers.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultConfig.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultDynamicContext.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultEndpoints.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultGlobalContext.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultLogger.d.ts +1 -0
- package/dist/__tests__/mocks/mockDefaultPluginSettings.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultPrintOptionsView.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultProposition.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultShop.d.ts +2 -0
- package/dist/__tests__/mocks/mockDefaultTranslations.d.ts +2 -0
- package/dist/actions/composables/index.d.ts +2 -0
- package/dist/actions/composables/mutations/account/index.d.ts +2 -0
- package/dist/actions/composables/mutations/account/useDeleteAccountMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/account/useUpdateAccountMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/debug/index.d.ts +3 -0
- package/dist/actions/composables/mutations/debug/useDownloadLogsMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/debug/useSwitchToAcceptanceApiMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/debug/useSwitchToProductionApiMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/index.d.ts +7 -0
- package/dist/actions/composables/mutations/orders/index.d.ts +3 -0
- package/dist/actions/composables/mutations/orders/useExportOrdersMutation.d.ts +5 -0
- package/dist/actions/composables/mutations/orders/usePrintOrdersMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/orders/useUpdateOrdersMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/settings/index.d.ts +2 -0
- package/dist/actions/composables/mutations/settings/useUpdatePluginSettingsMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/settings/useUpdateProductSettingsMutation.d.ts +3 -0
- package/dist/actions/composables/mutations/shipments/index.d.ts +4 -0
- package/dist/actions/composables/mutations/shipments/useDeleteShipmentsMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/shipments/useExportReturnMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/shipments/usePrintShipmentsMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/shipments/useUpdateShipmentsMutation.d.ts +4 -0
- package/dist/actions/composables/mutations/usePdkMutation.d.ts +15 -0
- package/dist/actions/composables/mutations/webhooks/index.d.ts +2 -0
- package/dist/actions/composables/mutations/webhooks/useCreateWebhooksMutation.d.ts +1 -0
- package/dist/actions/composables/mutations/webhooks/useDeleteWebhooksMutation.d.ts +3 -0
- package/dist/actions/composables/queries/account/index.d.ts +1 -0
- package/dist/actions/composables/queries/account/useFetchContextQuery.d.ts +3 -0
- package/dist/actions/composables/queries/account/useOrderCapabilitiesQuery.d.ts +29 -0
- package/dist/actions/composables/queries/account/useShipmentCapabilitiesQuery.d.ts +45 -0
- package/dist/actions/composables/queries/index.d.ts +6 -0
- package/dist/actions/composables/queries/orders/index.d.ts +1 -0
- package/dist/actions/composables/queries/orders/useFetchOrdersQuery.d.ts +3 -0
- package/dist/actions/composables/queries/products/index.d.ts +1 -0
- package/dist/actions/composables/queries/products/useFetchProductsQuery.d.ts +3 -0
- package/dist/actions/composables/queries/queryKeys.d.ts +2 -0
- package/dist/actions/composables/queries/shipments/index.d.ts +1 -0
- package/dist/actions/composables/queries/shipments/useFetchShipmentsQuery.d.ts +4 -0
- package/dist/actions/composables/queries/webhooks/index.d.ts +1 -0
- package/dist/actions/composables/queries/webhooks/useFetchWebhooksQuery.d.ts +3 -0
- package/dist/actions/defineAction.d.ts +8 -0
- package/dist/actions/definitions/account.d.ts +13 -0
- package/dist/actions/definitions/context.d.ts +6 -0
- package/dist/actions/definitions/debug.d.ts +13 -0
- package/dist/actions/definitions/index.d.ts +8 -0
- package/dist/actions/definitions/modal.d.ts +17 -0
- package/dist/actions/definitions/orders.d.ts +39 -0
- package/dist/actions/definitions/settings.d.ts +2 -0
- package/dist/actions/definitions/shipments.d.ts +15 -0
- package/dist/actions/definitions/webhooks.d.ts +4 -0
- package/dist/actions/executors/createHandlerWithParameters.d.ts +5 -0
- package/dist/actions/executors/createMutationHandler.d.ts +3 -0
- package/dist/actions/executors/createOrdersMutationHandler.d.ts +3 -0
- package/dist/actions/executors/createQueryHandler.d.ts +3 -0
- package/dist/actions/executors/createShipmentsMutationHandler.d.ts +3 -0
- package/dist/actions/executors/doMutate.d.ts +4 -0
- package/dist/actions/executors/executeAction.d.ts +6 -0
- package/dist/actions/executors/executeAfterHandle.d.ts +3 -0
- package/dist/actions/executors/executeBeforeHandle.d.ts +4 -0
- package/dist/actions/executors/executeHandler.d.ts +3 -0
- package/dist/actions/executors/executeNextAction.d.ts +6 -0
- package/dist/actions/executors/index.d.ts +14 -0
- package/dist/actions/executors/resolveOrderParameters.d.ts +3 -0
- package/dist/actions/executors/resolveQuerySuffix.d.ts +3 -0
- package/dist/actions/executors/types.d.ts +19 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/orderModeActions.d.ts +37 -0
- package/dist/actions/print/index.d.ts +3 -0
- package/dist/actions/print/openOrPrintPdf.d.ts +3 -0
- package/dist/actions/print/resolvePrintParameters.d.ts +3 -0
- package/dist/actions/print/waitForLabelPrompt.d.ts +3 -0
- package/dist/actions/stopActionHandler.d.ts +2 -0
- package/dist/components/OrderBox/OrderShipmentsTable.vue.d.ts +7 -0
- package/dist/components/OrderBox/OrderShipmentsTableRow.vue.d.ts +19 -0
- package/dist/components/OrderBox/ShipmentOptionsBox.vue.d.ts +3 -0
- package/dist/components/OrderBox/ShipmentTableBox.vue.d.ts +3 -0
- package/dist/components/OrderListItem/OrderModeOrderListItem.vue.d.ts +3 -0
- package/dist/components/OrderListItem/ShipmentLabel.vue.d.ts +14 -0
- package/dist/components/OrderListItem/ShipmentModeOrderListItem.vue.d.ts +3 -0
- package/dist/components/PluginSettings/AccountSettings.vue.d.ts +3 -0
- package/dist/components/PluginSettings/DebugOptions.vue.d.ts +3 -0
- package/dist/components/PluginSettings/EditApiKeyForm.vue.d.ts +8 -0
- package/dist/components/PluginSettings/PluginSettingsForms.vue.d.ts +3 -0
- package/dist/components/PluginSettings/WebhooksStatus.vue.d.ts +3 -0
- package/dist/components/PluginSettings/createUpdateAccountSettingsValidator.d.ts +4 -0
- package/dist/components/common/ActionButton.vue.d.ts +48 -0
- package/dist/components/common/BulkSelectCheckbox.vue.d.ts +20 -0
- package/dist/components/common/CarrierLogo.vue.d.ts +15 -0
- package/dist/components/common/DateRelative.vue.d.ts +15 -0
- package/dist/components/common/DeliveryOptionsDeliveryType.vue.d.ts +15 -0
- package/dist/components/common/DeliveryOptionsExcerpt.vue.d.ts +3 -0
- package/dist/components/common/DeliveryOptionsExcerptCarrierName.vue.d.ts +15 -0
- package/dist/components/common/DeliveryOptionsPackageType.vue.d.ts +15 -0
- package/dist/components/common/DigitalStampWeightRange.vue.d.ts +14 -0
- package/dist/components/common/NotificationContainer.vue.d.ts +17 -0
- package/dist/components/common/PackageType.vue.d.ts +15 -0
- package/dist/components/common/PlainElement.d.ts +2 -0
- package/dist/components/common/ResetButton.vue.d.ts +14 -0
- package/dist/components/common/ReturnsForm.vue.d.ts +15 -0
- package/dist/components/common/ShipmentBarcode.vue.d.ts +14 -0
- package/dist/components/common/ShipmentOptionsForm.vue.d.ts +15 -0
- package/dist/components/common/ShipmentStatus.vue.d.ts +14 -0
- package/dist/components/common/StatusIndicator.vue.d.ts +27 -0
- package/dist/components/common/SubmitButton.vue.d.ts +14 -0
- package/dist/components/common/TabNavigation.vue.d.ts +70 -0
- package/dist/components/common/index.d.ts +20 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/modals/PrintOptionsModal.vue.d.ts +3 -0
- package/dist/components/modals/PrintOptionsModalForm.vue.d.ts +3 -0
- package/dist/components/modals/ShipmentOptionsModal.vue.d.ts +3 -0
- package/dist/components/modals/ShipmentOptionsModalForm.vue.d.ts +15 -0
- package/dist/composables/components/index.d.ts +15 -0
- package/dist/composables/components/useBulkSelectCheckbox.d.ts +9 -0
- package/dist/composables/components/useCheckboxGroupContext.d.ts +4 -0
- package/dist/composables/components/useDropOffInputContext.d.ts +13 -0
- package/dist/composables/components/useDropdownButtonContext.d.ts +15 -0
- package/dist/composables/components/useElementContext.d.ts +7 -0
- package/dist/composables/components/useElementOptions.d.ts +6 -0
- package/dist/composables/components/useInputWithOptionsContext.d.ts +10 -0
- package/dist/composables/components/useModalElementContext.d.ts +11 -0
- package/dist/composables/components/useMultiSelectInputContext.d.ts +4 -0
- package/dist/composables/components/useRadioGroupContext.d.ts +10 -0
- package/dist/composables/components/useSelectInputContext.d.ts +4 -0
- package/dist/composables/components/useShippingMethodsInputContext.d.ts +13 -0
- package/dist/composables/components/useTableContext.d.ts +7 -0
- package/dist/composables/components/useToggleInputContext.d.ts +11 -0
- package/dist/composables/components/useTriStateInputContext.d.ts +17 -0
- package/dist/composables/context/index.d.ts +8 -0
- package/dist/composables/context/useAppInfo.d.ts +2 -0
- package/dist/composables/context/useContext.d.ts +3 -0
- package/dist/composables/context/useGlobalContext.d.ts +2 -0
- package/dist/composables/context/useInstanceContext.d.ts +8 -0
- package/dist/composables/context/useModalContext.d.ts +11 -0
- package/dist/composables/context/useModalOrder.d.ts +1 -0
- package/dist/composables/context/useOrderMode.d.ts +12 -0
- package/dist/composables/context/usePluginSettings.d.ts +2 -0
- package/dist/composables/formatter/default/createCurrencyFormat.d.ts +1 -0
- package/dist/composables/formatter/default/createLongDateFormat.d.ts +1 -0
- package/dist/composables/formatter/default/createRelativeTimeFormat.d.ts +1 -0
- package/dist/composables/formatter/default/defaultCurrencyFormatters.d.ts +2 -0
- package/dist/composables/formatter/default/defaultDateFormatters.d.ts +4 -0
- package/dist/composables/formatter/default/index.d.ts +6 -0
- package/dist/composables/formatter/default/parseDate.d.ts +1 -0
- package/dist/composables/formatter/formatter.types.d.ts +23 -0
- package/dist/composables/formatter/index.d.ts +4 -0
- package/dist/composables/formatter/useFormatter.d.ts +2 -0
- package/dist/composables/formatter/useLocalizedFormatter.d.ts +2 -0
- package/dist/composables/index.d.ts +17 -0
- package/dist/composables/language/index.d.ts +4 -0
- package/dist/composables/language/resolveTranslatedString.d.ts +3 -0
- package/dist/composables/language/resolveTranslationKey.d.ts +2 -0
- package/dist/composables/language/types.d.ts +1 -0
- package/dist/composables/language/useLanguage.d.ts +23 -0
- package/dist/composables/orders/index.d.ts +3 -0
- package/dist/composables/orders/useOrder.d.ts +3 -0
- package/dist/composables/orders/useOrderData.d.ts +9 -0
- package/dist/composables/orders/useOrdersData.d.ts +3 -0
- package/dist/composables/products/index.d.ts +1 -0
- package/dist/composables/products/useProductData.d.ts +8 -0
- package/dist/composables/shipments/index.d.ts +3 -0
- package/dist/composables/shipments/useShipment.d.ts +3 -0
- package/dist/composables/shipments/useShipmentData.d.ts +12 -0
- package/dist/composables/shipments/useShipmentsData.d.ts +2 -0
- package/dist/composables/useAdminConfig.d.ts +2 -0
- package/dist/composables/useAdminInstance.d.ts +2 -0
- package/dist/composables/useDigitalStampRanges.d.ts +12 -0
- package/dist/composables/useGlobalPdkAdmin.d.ts +2 -0
- package/dist/composables/useLoadMore.d.ts +14 -0
- package/dist/composables/useLoading.d.ts +10 -0
- package/dist/composables/useLogger.d.ts +2 -0
- package/dist/composables/useStoreContextQuery.d.ts +3 -0
- package/dist/composables/useStoreQuery.d.ts +4 -0
- package/dist/composables/useWeekdays.d.ts +9 -0
- package/dist/data/components.d.ts +195 -0
- package/dist/data/constants.d.ts +63 -0
- package/dist/data/endpoints.d.ts +5 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/orderMode.d.ts +25 -0
- package/dist/data/view.d.ts +9 -0
- package/dist/deprecated.d.ts +6 -0
- package/dist/forms/createReturnsForm.d.ts +1 -0
- package/dist/forms/form-builder/builders/buildAfterUpdate.d.ts +3 -0
- package/dist/forms/form-builder/builders/buildFormStateWatcher.d.ts +3 -0
- package/dist/forms/form-builder/builders/index.d.ts +2 -0
- package/dist/forms/form-builder/conditions/index.d.ts +3 -0
- package/dist/forms/form-builder/conditions/validateIfCondition.d.ts +2 -0
- package/dist/forms/form-builder/conditions/validateIfConditions.d.ts +2 -0
- package/dist/forms/form-builder/conditions/validateIsTruthy.d.ts +2 -0
- package/dist/forms/form-builder/index.d.ts +5 -0
- package/dist/forms/form-builder/operations/executeCustomOperationHandlers.d.ts +2 -0
- package/dist/forms/form-builder/operations/executeOperation.d.ts +2 -0
- package/dist/forms/form-builder/operations/executeOperations.d.ts +2 -0
- package/dist/forms/form-builder/operations/executeSetPropOperation.d.ts +2 -0
- package/dist/forms/form-builder/operations/executeSetValueOperation.d.ts +2 -0
- package/dist/forms/form-builder/operations/index.d.ts +5 -0
- package/dist/forms/form-builder/operations/parseBuilders.d.ts +3 -0
- package/dist/forms/form-builder/types/FormCondition.types.d.ts +36 -0
- package/dist/forms/form-builder/types/FormOperations.types.d.ts +16 -0
- package/dist/forms/form-builder/types/SubOperationBuilder.types.d.ts +13 -0
- package/dist/forms/form-builder/types/common.types.d.ts +21 -0
- package/dist/forms/form-builder/types/index.d.ts +4 -0
- package/dist/forms/form-builder/utils/createPropSetter.d.ts +4 -0
- package/dist/forms/form-builder/utils/createValueGetter.d.ts +4 -0
- package/dist/forms/form-builder/utils/createValueSetter.d.ts +11 -0
- package/dist/forms/form-builder/utils/index.d.ts +4 -0
- package/dist/forms/formKeys.d.ts +10 -0
- package/dist/forms/helpers/addBulkEditNotification.d.ts +1 -0
- package/dist/forms/helpers/addCapabilitiesClearNotification.d.ts +15 -0
- package/dist/forms/helpers/createDefaultOption.d.ts +3 -0
- package/dist/forms/helpers/createLabel.d.ts +1 -0
- package/dist/forms/helpers/defineFormField.d.ts +2 -0
- package/dist/forms/helpers/getDeliveryTypes.d.ts +3 -0
- package/dist/forms/helpers/getFieldLabel.d.ts +7 -0
- package/dist/forms/helpers/getFormCarrierName.d.ts +2 -0
- package/dist/forms/helpers/getPackageTypes.d.ts +3 -0
- package/dist/forms/helpers/index.d.ts +14 -0
- package/dist/forms/helpers/resolveFormComponent.d.ts +3 -0
- package/dist/forms/helpers/setFieldProp.d.ts +8 -0
- package/dist/forms/helpers/triStateFieldIsEnabled.d.ts +2 -0
- package/dist/forms/helpers/updateFieldsDefaults.d.ts +6 -0
- package/dist/forms/helpers/useFormCapabilities.d.ts +66 -0
- package/dist/forms/index.d.ts +6 -0
- package/dist/forms/pluginSettings/createFormTab.d.ts +3 -0
- package/dist/forms/pluginSettings/createPluginSettingsForm.d.ts +4 -0
- package/dist/forms/pluginSettings/createPluginSettingsTabs.d.ts +4 -0
- package/dist/forms/pluginSettings/createPluginSettingsTabsComponent.d.ts +4 -0
- package/dist/forms/pluginSettings/filterPluginSettingsView.d.ts +15 -0
- package/dist/forms/pluginSettings/generateFormFields.d.ts +8 -0
- package/dist/forms/pluginSettings/index.d.ts +7 -0
- package/dist/forms/pluginSettings/resolveSettingsValues.d.ts +8 -0
- package/dist/forms/pluginSettings/types.d.ts +13 -0
- package/dist/forms/shipmentOptions/createShipmentOptionsForm.d.ts +4 -0
- package/dist/forms/shipmentOptions/field.d.ts +22 -0
- package/dist/forms/shipmentOptions/fieldFactoryRegistry.d.ts +21 -0
- package/dist/forms/shipmentOptions/fields/createCarrierField.d.ts +4 -0
- package/dist/forms/shipmentOptions/fields/createDeliveryTypeField.d.ts +3 -0
- package/dist/forms/shipmentOptions/fields/createDigitalStampRangeField.d.ts +4 -0
- package/dist/forms/shipmentOptions/fields/createDimensionFields.d.ts +3 -0
- package/dist/forms/shipmentOptions/fields/createInsuranceField.d.ts +17 -0
- package/dist/forms/shipmentOptions/fields/createLabelAmountField.d.ts +3 -0
- package/dist/forms/shipmentOptions/fields/createPackageTypeField.d.ts +3 -0
- package/dist/forms/shipmentOptions/fields/createRef.d.ts +3 -0
- package/dist/forms/shipmentOptions/fields/createShipmentOptionField.d.ts +15 -0
- package/dist/forms/shipmentOptions/fields/index.d.ts +7 -0
- package/dist/forms/shipmentOptions/index.d.ts +4 -0
- package/dist/forms/shipmentOptions/types.d.ts +2 -0
- package/dist/forms/shipmentOptions/useCapabilitiesAutoClear.d.ts +36 -0
- package/dist/forms/shipmentOptions/useCapabilitiesWatcher.d.ts +22 -0
- package/dist/forms/shipmentOptions/wireProxyCapabilities.d.ts +31 -0
- package/dist/index.d.ts +19 -0
- package/dist/pdk/PdkAdmin.d.ts +18 -0
- package/dist/pdk/boot.d.ts +3 -0
- package/dist/pdk/createAdminConfig.d.ts +2 -0
- package/dist/pdk/createPdkAdmin.d.ts +8 -0
- package/dist/pdk/createPdkAdminPlugin.d.ts +3 -0
- package/dist/pdk/fillShipmentsQueryData.d.ts +4 -0
- package/dist/pdk/index.d.ts +11 -0
- package/dist/pdk/instance/createInstanceContext.d.ts +5 -0
- package/dist/pdk/instance/createQueryClient.d.ts +2 -0
- package/dist/pdk/instance/index.d.ts +3 -0
- package/dist/pdk/instance/plugins/createContextPlugin.d.ts +2 -0
- package/dist/pdk/instance/plugins/createLoggerPlugin.d.ts +2 -0
- package/dist/pdk/instance/plugins/createRegisterComponentsPlugin.d.ts +5 -0
- package/dist/pdk/instance/plugins/createStorePlugin.d.ts +2 -0
- package/dist/pdk/instance/plugins/createVueQueryPlugin.d.ts +5 -0
- package/dist/pdk/instance/plugins/index.d.ts +6 -0
- package/dist/pdk/instance/plugins/plugins.types.d.ts +3 -0
- package/dist/pdk/renderMap.d.ts +3 -0
- package/dist/pdk/sendBootEvent.d.ts +3 -0
- package/dist/pdk/setupAdminApp.d.ts +3 -0
- package/dist/pdk/testIdDirective.d.ts +5 -0
- package/dist/sdk/PdkFetchClient.d.ts +11 -0
- package/dist/sdk/composables/api/index.d.ts +1 -0
- package/dist/sdk/composables/api/useFetchCarrier.d.ts +1 -0
- package/dist/sdk/composables/index.d.ts +3 -0
- package/dist/sdk/composables/useMyParcelApi.d.ts +5 -0
- package/dist/sdk/composables/usePdkAdminApi.d.ts +6 -0
- package/dist/sdk/endpoints/abstractPdkEndpoint.d.ts +7 -0
- package/dist/sdk/endpoints/index.d.ts +1 -0
- package/dist/sdk/index.d.ts +3 -0
- package/dist/services/actions/createAction.d.ts +4 -0
- package/dist/services/actions/createActionContext.d.ts +3 -0
- package/dist/services/actions/downloadFile.d.ts +4 -0
- package/dist/services/actions/getActionIdentifier.d.ts +2 -0
- package/dist/services/actions/index.d.ts +4 -0
- package/dist/services/addErrorToNotifications.d.ts +2 -0
- package/dist/services/context/getElementContext.d.ts +2 -0
- package/dist/services/context/index.d.ts +1 -0
- package/dist/services/createNotification.d.ts +5 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/instantiateAction.d.ts +2 -0
- package/dist/services/instantiateActions.d.ts +8 -0
- package/dist/services/logger.d.ts +19 -0
- package/dist/services/mutations/getCallbackForMutationMode.d.ts +4 -0
- package/dist/services/mutations/getModalMutationOptions.d.ts +2 -0
- package/dist/services/mutations/index.d.ts +3 -0
- package/dist/services/mutations/mutationMode.d.ts +4 -0
- package/dist/services/print/index.d.ts +1 -0
- package/dist/services/print/openPdfInNewWindow.d.ts +4 -0
- package/dist/stores/createQueryCacheKey.d.ts +3 -0
- package/dist/stores/index.d.ts +6 -0
- package/dist/stores/types.d.ts +13 -0
- package/dist/stores/useActionStore.d.ts +25 -0
- package/dist/stores/useModalStore.d.ts +16 -0
- package/dist/stores/useNotificationStore.d.ts +60 -0
- package/dist/stores/useQueryStore.d.ts +80 -0
- package/dist/symbols.d.ts +5 -0
- package/dist/testing.d.ts +1 -0
- package/dist/types/actions/actions.types.d.ts +31 -0
- package/dist/types/actions/endpoints.types.d.ts +9 -0
- package/dist/types/actions/index.d.ts +4 -0
- package/dist/types/actions/parameters.types.d.ts +55 -0
- package/dist/types/actions/response.types.d.ts +7 -0
- package/dist/types/actions.types.d.ts +45 -0
- package/dist/types/admin.types.d.ts +26 -0
- package/dist/types/common.types.d.ts +53 -0
- package/dist/types/components-form.types.d.ts +107 -0
- package/dist/types/components.types.d.ts +273 -0
- package/dist/types/configuration.types.d.ts +95 -0
- package/dist/types/context.types.d.ts +20 -0
- package/dist/types/endpoints.types.d.ts +7 -0
- package/dist/types/form.types.d.ts +39 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/language.types.d.ts +9 -0
- package/dist/types/sdk.types.d.ts +212 -0
- package/dist/utils/booleanToTriState.d.ts +2 -0
- package/dist/utils/convertDotNotationToObject.d.ts +1 -0
- package/dist/utils/createAssetUrl.d.ts +1 -0
- package/dist/utils/createClasses.d.ts +8 -0
- package/dist/utils/createObjectWithKeys.d.ts +3 -0
- package/dist/utils/decodeHtmlEntities.d.ts +7 -0
- package/dist/utils/downloadBlob.d.ts +1 -0
- package/dist/utils/downloadFileFromUrl.d.ts +1 -0
- package/dist/utils/encodeArrayParameter.d.ts +2 -0
- package/dist/utils/extendAdminInstance.d.ts +2 -0
- package/dist/utils/fakeLinkClick.d.ts +4 -0
- package/dist/utils/forms/createFormElement.d.ts +3 -0
- package/dist/utils/forms/createShipmentFormName.d.ts +1 -0
- package/dist/utils/forms/formToBody.d.ts +2 -0
- package/dist/utils/forms/generateFieldId.d.ts +3 -0
- package/dist/utils/forms/getEnabledValues.d.ts +11 -0
- package/dist/utils/forms/index.d.ts +5 -0
- package/dist/utils/generateLabelFilename.d.ts +3 -0
- package/dist/utils/getOrderId.d.ts +3 -0
- package/dist/utils/getOrderShipmentIds.d.ts +2 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/openUrlInNewTab.d.ts +1 -0
- package/dist/utils/prefixComponent.d.ts +3 -0
- package/dist/utils/query/index.d.ts +3 -0
- package/dist/utils/query/setQueryData.d.ts +2 -0
- package/dist/utils/query/setQueryOrder.d.ts +10 -0
- package/dist/utils/query/setQueryShipment.d.ts +3 -0
- package/dist/utils/resolveCarrier.d.ts +1 -0
- package/dist/utils/translations/getDeliveryTypeTranslation.d.ts +2 -0
- package/dist/utils/translations/getDynamicTranslation.d.ts +1 -0
- package/dist/utils/translations/getPackageTypeTranslation.d.ts +2 -0
- package/dist/utils/translations/index.d.ts +4 -0
- package/dist/utils/translations/translateSelectOption.d.ts +3 -0
- package/dist/utils/triStateToBoolean.d.ts +2 -0
- package/dist/utils/unprefixComponent.d.ts +3 -0
- package/dist/utils/validateId.d.ts +2 -0
- package/dist/views/ChildProductSettings.vue.d.ts +3 -0
- package/dist/views/Modals.vue.d.ts +3 -0
- package/dist/views/Notifications.vue.d.ts +3 -0
- package/dist/views/OrderBox.vue.d.ts +3 -0
- package/dist/views/OrderListItem.vue.d.ts +3 -0
- package/dist/views/PluginSettings.vue.d.ts +3 -0
- package/dist/views/ProductSettings.vue.d.ts +35 -0
- package/dist/views/integrated/OrderBoxView.vue.d.ts +13 -0
- package/dist/views/integrated/OrderListItemView.vue.d.ts +13 -0
- package/dist/views/integrated/index.d.ts +7 -0
- package/package.json +3 -3
- package/src/actions/composables/queries/account/useOrderCapabilitiesQuery.spec.ts +56 -0
- package/src/actions/composables/queries/account/useOrderCapabilitiesQuery.ts +11 -8
- package/src/actions/composables/queries/account/useShipmentCapabilitiesQuery.spec.ts +64 -0
- package/src/actions/composables/queries/account/useShipmentCapabilitiesQuery.ts +8 -7
- package/src/forms/shipmentOptions/createShipmentOptionsForm.spec.ts +1 -0
- package/src/forms/shipmentOptions/createShipmentOptionsForm.ts +21 -2
- package/src/forms/shipmentOptions/field.ts +12 -0
- package/src/forms/shipmentOptions/fields/createDimensionFields.spec.ts +49 -0
- package/src/forms/shipmentOptions/fields/createDimensionFields.ts +32 -0
- package/src/forms/shipmentOptions/fields/index.ts +1 -0
- package/src/forms/shipmentOptions/useCapabilitiesWatcher.spec.ts +1 -1
- package/src/forms/shipmentOptions/useCapabilitiesWatcher.ts +2 -1
- package/src/forms/shipmentOptions/wireProxyCapabilities.spec.ts +59 -7
- package/src/forms/shipmentOptions/wireProxyCapabilities.ts +31 -20
- package/src/types/sdk.types.ts +1 -1
|
@@ -15,15 +15,18 @@ import {usePdkAdminApi} from '../../../../sdk';
|
|
|
15
15
|
export type OrderCapabilitiesInput = {
|
|
16
16
|
cc?: string;
|
|
17
17
|
weight?: number;
|
|
18
|
+
isBusiness?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
* Order-scoped capabilities query — fires the shared CapabilitiesAction with ONLY destination
|
|
22
|
-
* and
|
|
23
|
-
* the union of `packageTypes`, `deliveryTypes`, and `options` valid
|
|
22
|
+
* Order-scoped capabilities query — fires the shared CapabilitiesAction with ONLY destination,
|
|
23
|
+
* weight and the recipient business flag, no carrier/packageType/deliveryType filters. Returns
|
|
24
|
+
* one entry per carrier with the union of `packageTypes`, `deliveryTypes`, and `options` valid
|
|
25
|
+
* for the order context.
|
|
24
26
|
*
|
|
25
|
-
* Drives the carrier / packageType / deliveryType dropdowns. Refetches only on cc / weight
|
|
26
|
-
* changes so option toggles and dropdown picks don't trigger needless network
|
|
27
|
+
* Drives the carrier / packageType / deliveryType dropdowns. Refetches only on cc / weight /
|
|
28
|
+
* isBusiness changes so option toggles and dropdown picks don't trigger needless network
|
|
29
|
+
* round-trips.
|
|
27
30
|
*
|
|
28
31
|
* Errors are logged via `globalLogger.error` so we have a breadcrumb for support, but we
|
|
29
32
|
* deliberately don't surface a user-facing toast — an intermittent capabilities failure
|
|
@@ -38,7 +41,7 @@ export const useOrderCapabilitiesQuery = (
|
|
|
38
41
|
return useQuery(
|
|
39
42
|
queryKey,
|
|
40
43
|
async () => {
|
|
41
|
-
const {cc, weight} = input.value;
|
|
44
|
+
const {cc, weight, isBusiness} = input.value;
|
|
42
45
|
|
|
43
46
|
if (!cc) return [];
|
|
44
47
|
|
|
@@ -46,8 +49,8 @@ export const useOrderCapabilitiesQuery = (
|
|
|
46
49
|
const proxyCapabilities = pdk.proxyCapabilities as unknown as ProxyCapabilitiesCall;
|
|
47
50
|
|
|
48
51
|
const body: ProxyCapabilitiesBody = {
|
|
49
|
-
recipient: {countryCode: cc},
|
|
50
|
-
...(weight
|
|
52
|
+
recipient: {countryCode: cc, ...(isBusiness === undefined ? null : {isBusiness})},
|
|
53
|
+
...(weight === undefined ? null : {physicalProperties: {weight: {value: weight, unit: 'g'}}}),
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
const response = await proxyCapabilities({body, parameters: {filterSupported: true}});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {ref} from 'vue';
|
|
2
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
3
|
+
import {useShipmentCapabilitiesQuery} from './useShipmentCapabilitiesQuery';
|
|
4
|
+
|
|
5
|
+
type RequestBody = {recipient: {countryCode: string; isBusiness?: boolean}};
|
|
6
|
+
|
|
7
|
+
let capturedBody: RequestBody | undefined;
|
|
8
|
+
|
|
9
|
+
const proxyCapabilities = vi.fn((options: {body: RequestBody}) => {
|
|
10
|
+
capturedBody = options.body;
|
|
11
|
+
|
|
12
|
+
return Promise.resolve({results: []});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
vi.mock('@tanstack/vue-query', () => ({
|
|
16
|
+
useQuery: (queryKey: unknown, queryFn: () => Promise<unknown>) => ({queryFn}),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
vi.mock('../../../../sdk', () => ({
|
|
20
|
+
usePdkAdminApi: () => ({proxyCapabilities}),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
vi.mock('../../../../services', () => ({
|
|
24
|
+
globalLogger: {error: vi.fn(), debug: vi.fn(), warn: vi.fn(), info: vi.fn()},
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
type QueryFnHolder = {queryFn: () => Promise<unknown>};
|
|
28
|
+
|
|
29
|
+
const fullSelection = (isBusiness?: boolean) => ({
|
|
30
|
+
cc: 'NL',
|
|
31
|
+
carrier: 'POSTNL',
|
|
32
|
+
packageType: 'PACKAGE',
|
|
33
|
+
deliveryType: 'STANDARD',
|
|
34
|
+
...(isBusiness === undefined ? null : {isBusiness}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('useShipmentCapabilitiesQuery', () => {
|
|
38
|
+
it('forwards the business flag on the recipient body', async () => {
|
|
39
|
+
capturedBody = undefined;
|
|
40
|
+
|
|
41
|
+
const query = useShipmentCapabilitiesQuery(ref(fullSelection(true))) as unknown as QueryFnHolder;
|
|
42
|
+
await query.queryFn();
|
|
43
|
+
|
|
44
|
+
expect(capturedBody?.recipient).toEqual({countryCode: 'NL', isBusiness: true});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('sends an explicit consumer flag on the recipient body', async () => {
|
|
48
|
+
capturedBody = undefined;
|
|
49
|
+
|
|
50
|
+
const query = useShipmentCapabilitiesQuery(ref(fullSelection(false))) as unknown as QueryFnHolder;
|
|
51
|
+
await query.queryFn();
|
|
52
|
+
|
|
53
|
+
expect(capturedBody?.recipient).toEqual({countryCode: 'NL', isBusiness: false});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('omits isBusiness when the flag is not provided', async () => {
|
|
57
|
+
capturedBody = undefined;
|
|
58
|
+
|
|
59
|
+
const query = useShipmentCapabilitiesQuery(ref(fullSelection())) as unknown as QueryFnHolder;
|
|
60
|
+
await query.queryFn();
|
|
61
|
+
|
|
62
|
+
expect(capturedBody?.recipient).toEqual({countryCode: 'NL'});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -22,6 +22,7 @@ import {usePdkAdminApi} from '../../../../sdk';
|
|
|
22
22
|
export type CapabilitiesSelection = {
|
|
23
23
|
cc?: string;
|
|
24
24
|
weight?: number;
|
|
25
|
+
isBusiness?: boolean;
|
|
25
26
|
carrier?: string;
|
|
26
27
|
packageType?: string;
|
|
27
28
|
deliveryType?: string;
|
|
@@ -29,10 +30,10 @@ export type CapabilitiesSelection = {
|
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Shipment-scoped capabilities query — fires the shared CapabilitiesAction with the FULL
|
|
32
|
-
* selection (carrier + packageType + deliveryType + cc + weight) and returns the
|
|
33
|
-
* carrier entry (the one shipment configuration the user has chosen). Drives the option
|
|
34
|
-
* and acts as the invalid-combo signal: when `results` is empty, the chosen combination
|
|
35
|
-
* valid for the order context.
|
|
33
|
+
* selection (carrier + packageType + deliveryType + cc + weight + isBusiness) and returns the
|
|
34
|
+
* matching carrier entry (the one shipment configuration the user has chosen). Drives the option
|
|
35
|
+
* panel and acts as the invalid-combo signal: when `results` is empty, the chosen combination
|
|
36
|
+
* isn't valid for the order context.
|
|
36
37
|
*
|
|
37
38
|
* The selection ref is the only refetch trigger — no window-focus, mount, or reconnect refetches.
|
|
38
39
|
* Server-side option filtering is opted in via the `filterSupported` query parameter so admin sees
|
|
@@ -60,7 +61,7 @@ export const useShipmentCapabilitiesQuery = (
|
|
|
60
61
|
return useQuery(
|
|
61
62
|
queryKey,
|
|
62
63
|
async () => {
|
|
63
|
-
const {cc, weight, carrier, packageType, deliveryType} = selection.value;
|
|
64
|
+
const {cc, weight, isBusiness, carrier, packageType, deliveryType} = selection.value;
|
|
64
65
|
|
|
65
66
|
// The `enabled` gate guarantees these are all present when this runs; TypeScript can't
|
|
66
67
|
// see through the runtime check, so we narrow explicitly here.
|
|
@@ -70,10 +71,10 @@ export const useShipmentCapabilitiesQuery = (
|
|
|
70
71
|
const proxyCapabilities = pdk.proxyCapabilities as unknown as ProxyCapabilitiesCall;
|
|
71
72
|
|
|
72
73
|
const body: ProxyCapabilitiesBody = {
|
|
73
|
-
recipient: {countryCode: cc},
|
|
74
|
+
recipient: {countryCode: cc, ...(isBusiness === undefined ? null : {isBusiness})},
|
|
74
75
|
// PDK orders carry physical-properties weight in grams (see WeightServiceInterface::UNIT_GRAMS),
|
|
75
76
|
// and the SDK's PhysicalPropertiesWeightV2 expects a {value, unit} object — not a primitive.
|
|
76
|
-
...(weight
|
|
77
|
+
...(weight === undefined ? null : {physicalProperties: {weight: {value: weight, unit: 'g'}}}),
|
|
77
78
|
carrier,
|
|
78
79
|
packageType,
|
|
79
80
|
deliveryType,
|
|
@@ -27,6 +27,7 @@ vi.mock('@myparcel-dev/vue-form-builder', () => ({
|
|
|
27
27
|
|
|
28
28
|
vi.mock('./fields', () => ({
|
|
29
29
|
createDigitalStampRangeField: () => ({name: '__static_digitalStampRange'}),
|
|
30
|
+
createDimensionFields: () => [{name: '__static_length'}, {name: '__static_width'}, {name: '__static_height'}],
|
|
30
31
|
createLabelAmountField: () => ({name: '__static_labelAmount'}),
|
|
31
32
|
createPackageTypeField: () => ({name: '__static_packageType'}),
|
|
32
33
|
}));
|
|
@@ -17,9 +17,24 @@ import {type ShipmentOptionsRefs} from './types';
|
|
|
17
17
|
import {createShipmentOptionField} from './fields/createShipmentOptionField';
|
|
18
18
|
import {createDeliveryTypeField} from './fields/createDeliveryTypeField';
|
|
19
19
|
import {createCarrierField} from './fields/createCarrierField';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
createDigitalStampRangeField,
|
|
22
|
+
createDimensionFields,
|
|
23
|
+
createLabelAmountField,
|
|
24
|
+
createPackageTypeField,
|
|
25
|
+
} from './fields';
|
|
21
26
|
import {fieldFactoryRegistry} from './fieldFactoryRegistry';
|
|
22
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
FIELD_CARRIER,
|
|
29
|
+
FIELD_DELIVERY_TYPE,
|
|
30
|
+
FIELD_HEIGHT,
|
|
31
|
+
FIELD_LABEL_AMOUNT,
|
|
32
|
+
FIELD_LENGTH,
|
|
33
|
+
FIELD_MANUAL_WEIGHT,
|
|
34
|
+
FIELD_PACKAGE_TYPE,
|
|
35
|
+
FIELD_SHIPMENT_OPTIONS_PREFIX,
|
|
36
|
+
FIELD_WIDTH,
|
|
37
|
+
} from './field';
|
|
23
38
|
|
|
24
39
|
export const createShipmentOptionsForm = (orders?: OneOrMore<Plugin.ModelPdkOrder>): FormInstance => {
|
|
25
40
|
const ordersArray = toArray(orders ?? []).map(toRaw);
|
|
@@ -107,6 +122,9 @@ const buildDynamicRefs = (
|
|
|
107
122
|
refs[FIELD_PACKAGE_TYPE] = get(order, FIELD_PACKAGE_TYPE);
|
|
108
123
|
refs[FIELD_DELIVERY_TYPE] = get(order, FIELD_DELIVERY_TYPE);
|
|
109
124
|
refs[FIELD_MANUAL_WEIGHT] = get(order, FIELD_MANUAL_WEIGHT);
|
|
125
|
+
refs[FIELD_LENGTH] = get(order, FIELD_LENGTH);
|
|
126
|
+
refs[FIELD_WIDTH] = get(order, FIELD_WIDTH);
|
|
127
|
+
refs[FIELD_HEIGHT] = get(order, FIELD_HEIGHT);
|
|
110
128
|
|
|
111
129
|
// Dynamic shipment option refs from carrier options
|
|
112
130
|
for (const key of optionKeys) {
|
|
@@ -129,6 +147,7 @@ const createShipmentOptionsFields = (
|
|
|
129
147
|
createDeliveryTypeField(refs),
|
|
130
148
|
createLabelAmountField(refs),
|
|
131
149
|
createDigitalStampRangeField(refs, order),
|
|
150
|
+
...createDimensionFields(refs),
|
|
132
151
|
];
|
|
133
152
|
|
|
134
153
|
// Dynamic shipment option fields — driven by carrier.options
|
|
@@ -16,6 +16,12 @@ export const DELIVERY_TYPE = 'deliveryType';
|
|
|
16
16
|
|
|
17
17
|
export const MANUAL_WEIGHT = 'manualWeight';
|
|
18
18
|
|
|
19
|
+
export const LENGTH = 'length';
|
|
20
|
+
|
|
21
|
+
export const WIDTH = 'width';
|
|
22
|
+
|
|
23
|
+
export const HEIGHT = 'height';
|
|
24
|
+
|
|
19
25
|
export const PROP_OPTIONS = 'options';
|
|
20
26
|
|
|
21
27
|
export const KEY_DESCRIPTION = 'description';
|
|
@@ -32,4 +38,10 @@ export const FIELD_DELIVERY_TYPE: FieldName = `${DELIVERY_OPTIONS_PREFIX}.${DELI
|
|
|
32
38
|
|
|
33
39
|
export const FIELD_MANUAL_WEIGHT: FieldName = `${PHYSICAL_PROPERTIES_PREFIX}.${MANUAL_WEIGHT}`;
|
|
34
40
|
|
|
41
|
+
export const FIELD_LENGTH: FieldName = `${PHYSICAL_PROPERTIES_PREFIX}.${LENGTH}`;
|
|
42
|
+
|
|
43
|
+
export const FIELD_WIDTH: FieldName = `${PHYSICAL_PROPERTIES_PREFIX}.${WIDTH}`;
|
|
44
|
+
|
|
45
|
+
export const FIELD_HEIGHT: FieldName = `${PHYSICAL_PROPERTIES_PREFIX}.${HEIGHT}`;
|
|
46
|
+
|
|
35
47
|
export const FIELD_SHIPMENT_OPTIONS_PREFIX: FieldName = `${DELIVERY_OPTIONS_PREFIX}.${SHIPMENT_OPTIONS}`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {describe, expect, it, vi} from 'vitest';
|
|
2
|
+
import {FIELD_HEIGHT, FIELD_LENGTH, FIELD_WIDTH} from '../field';
|
|
3
|
+
import {createDimensionFields} from './createDimensionFields';
|
|
4
|
+
|
|
5
|
+
// Full mock (no importOriginal) to avoid the Vue file import chain
|
|
6
|
+
// that triggers "Install @vitejs/plugin-vue" errors.
|
|
7
|
+
vi.mock('../../helpers', () => ({
|
|
8
|
+
resolveFormComponent: () => 'MockNumberInput',
|
|
9
|
+
defineFormField: (config: Record<string, unknown>) => config,
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
describe('createDimensionFields', () => {
|
|
13
|
+
it('creates a field per dimension, in centimeters', () => {
|
|
14
|
+
const fields = createDimensionFields({});
|
|
15
|
+
|
|
16
|
+
expect(fields.map((field) => field.name)).toEqual([FIELD_LENGTH, FIELD_WIDTH, FIELD_HEIGHT]);
|
|
17
|
+
expect(fields.map((field) => field.label)).toEqual(['length_in_cm', 'width_in_cm', 'height_in_cm']);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Only `attributes` is bound to the rendered input; `props` is merely readable from `element.props`
|
|
22
|
+
* by components that opt in, and no number input does. A `min` on `props` would silently do nothing,
|
|
23
|
+
* so assert the channel and not just the value.
|
|
24
|
+
*/
|
|
25
|
+
it('puts min on attributes so it reaches the input', () => {
|
|
26
|
+
const fields = createDimensionFields({});
|
|
27
|
+
|
|
28
|
+
fields.forEach((field) => {
|
|
29
|
+
expect(field.attributes).toEqual({min: 0});
|
|
30
|
+
expect(field.props?.min).toBeUndefined();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('leaves untouched fields undefined rather than defaulting them to 0', () => {
|
|
35
|
+
const fields = createDimensionFields({});
|
|
36
|
+
|
|
37
|
+
expect(fields.map((field) => field.ref?.value)).toEqual([undefined, undefined, undefined]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('seeds each field from the order refs when a value was stored', () => {
|
|
41
|
+
const fields = createDimensionFields({
|
|
42
|
+
[FIELD_LENGTH]: 40,
|
|
43
|
+
[FIELD_WIDTH]: 20,
|
|
44
|
+
[FIELD_HEIGHT]: 30,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(fields.map((field) => field.ref?.value)).toEqual([40, 20, 30]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {type InteractiveElementConfiguration} from '@myparcel-dev/vue-form-builder';
|
|
2
|
+
import {type ShipmentOptionsRefs} from '../types';
|
|
3
|
+
import {FIELD_HEIGHT, FIELD_LENGTH, FIELD_WIDTH, type FieldName} from '../field';
|
|
4
|
+
import {defineFormField, resolveFormComponent} from '../../helpers';
|
|
5
|
+
import {AdminComponent} from '../../../data';
|
|
6
|
+
import {createRef} from './createRef';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The parcel dimensions the merchant may fill in manually, in centimeters — the same unit the API
|
|
10
|
+
* expects and the backoffice shows, so nothing is converted.
|
|
11
|
+
*
|
|
12
|
+
* `min` is a UX guard, not validation
|
|
13
|
+
*
|
|
14
|
+
* The refs have no fallback on purpose. An untouched field must stay undefined so it is left out of
|
|
15
|
+
* the request entirely; defaulting to 0 would send a dimension the merchant never entered.
|
|
16
|
+
*/
|
|
17
|
+
const DIMENSION_FIELDS: [name: FieldName, label: string][] = [
|
|
18
|
+
[FIELD_LENGTH, 'length_in_cm'],
|
|
19
|
+
[FIELD_WIDTH, 'width_in_cm'],
|
|
20
|
+
[FIELD_HEIGHT, 'height_in_cm'],
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const createDimensionFields = (refs: ShipmentOptionsRefs): InteractiveElementConfiguration[] =>
|
|
24
|
+
DIMENSION_FIELDS.map(([name, label]) =>
|
|
25
|
+
defineFormField({
|
|
26
|
+
name,
|
|
27
|
+
label,
|
|
28
|
+
ref: createRef<number | undefined>(refs, name),
|
|
29
|
+
component: resolveFormComponent(AdminComponent.NumberInput),
|
|
30
|
+
attributes: {min: 0},
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
@@ -4,7 +4,8 @@ import {type CapabilitiesSelection} from '../../actions/composables/queries/acco
|
|
|
4
4
|
|
|
5
5
|
const DEBOUNCE_MS = 100;
|
|
6
6
|
|
|
7
|
-
export type OrderInput = {cc?: string; weight?: number};
|
|
7
|
+
export type OrderInput = {cc?: string; weight?: number; isBusiness?: boolean};
|
|
8
|
+
|
|
8
9
|
export type FormInput = {carrier?: string; packageType?: string; deliveryType?: string};
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {describe, expect, it, vi, beforeEach} from 'vitest';
|
|
2
1
|
import {effectScope, nextTick, ref} from 'vue';
|
|
2
|
+
import {describe, expect, it, vi, beforeEach} from 'vitest';
|
|
3
3
|
import {BackendEndpoint, TriState} from '@myparcel-dev/pdk-common';
|
|
4
4
|
import {FIELD_CARRIER, FIELD_DELIVERY_TYPE, FIELD_MANUAL_WEIGHT, FIELD_PACKAGE_TYPE} from './field';
|
|
5
5
|
|
|
@@ -35,12 +35,12 @@ const buildForm = (initial: Record<string, unknown>) => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
|
-
getValue: <T
|
|
38
|
+
getValue: <T>(name: string): T => fields.get(name)?.ref.value as T,
|
|
39
39
|
setExternally: (name: string, value: unknown) => {
|
|
40
40
|
const field = fields.get(name);
|
|
41
41
|
|
|
42
42
|
if (field) {
|
|
43
|
-
|
|
43
|
+
field.ref.value = value;
|
|
44
44
|
} else {
|
|
45
45
|
fields.set(name, {ref: ref(value)});
|
|
46
46
|
}
|
|
@@ -55,12 +55,14 @@ beforeEach(() => {
|
|
|
55
55
|
useShipmentCapabilitiesQueryMock.mockClear();
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// `isBusiness` is omitted from the shipping address unless explicitly passed — production
|
|
59
|
+
// orders may not carry the flag at all, so the flag-absent shape is the representative default.
|
|
60
|
+
const orderShape = (cc = 'NL', initialWeight = 1500, isBusiness: boolean | undefined = undefined) =>
|
|
59
61
|
({
|
|
60
62
|
externalIdentifier: 'order-1',
|
|
61
|
-
shippingAddress: {cc},
|
|
63
|
+
shippingAddress: {cc, ...(isBusiness === undefined ? null : {isBusiness})},
|
|
62
64
|
physicalProperties: {initialWeight},
|
|
63
|
-
}
|
|
65
|
+
} as never);
|
|
64
66
|
|
|
65
67
|
describe('wireProxyCapabilities', () => {
|
|
66
68
|
it('treats TriState.Inherit (-1) as "no manual override" and falls back to initialWeight', async () => {
|
|
@@ -105,7 +107,9 @@ describe('wireProxyCapabilities', () => {
|
|
|
105
107
|
const orderInputRef = useOrderCapabilitiesQueryMock.mock.calls[0][0] as {value: {weight?: number}};
|
|
106
108
|
|
|
107
109
|
// Wait for the debounce (refDebounced default 100ms in this codebase).
|
|
108
|
-
await new Promise((resolve) =>
|
|
110
|
+
await new Promise((resolve) => {
|
|
111
|
+
setTimeout(resolve, 150);
|
|
112
|
+
});
|
|
109
113
|
await nextTick();
|
|
110
114
|
|
|
111
115
|
expect(orderInputRef.value.weight).toBe(4200);
|
|
@@ -113,6 +117,54 @@ describe('wireProxyCapabilities', () => {
|
|
|
113
117
|
scope.stop();
|
|
114
118
|
});
|
|
115
119
|
|
|
120
|
+
it('forwards the recipient business flag from the order shipping address to both queries', async () => {
|
|
121
|
+
const form = buildForm({
|
|
122
|
+
[FIELD_CARRIER]: 'POSTNL',
|
|
123
|
+
[FIELD_PACKAGE_TYPE]: 'PACKAGE',
|
|
124
|
+
[FIELD_DELIVERY_TYPE]: 'STANDARD',
|
|
125
|
+
[FIELD_MANUAL_WEIGHT]: TriState.Inherit,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const scope = effectScope();
|
|
129
|
+
const {wireProxyCapabilities} = await import('./wireProxyCapabilities');
|
|
130
|
+
|
|
131
|
+
scope.run(() => {
|
|
132
|
+
wireProxyCapabilities(form as never, orderShape('NL', 1500, true));
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const orderInputRef = useOrderCapabilitiesQueryMock.mock.calls[0][0] as {value: {isBusiness?: boolean}};
|
|
136
|
+
const selectionRef = useShipmentCapabilitiesQueryMock.mock.calls[0][0] as {value: {isBusiness?: boolean}};
|
|
137
|
+
|
|
138
|
+
expect(orderInputRef.value.isBusiness).toBe(true);
|
|
139
|
+
expect(selectionRef.value.isBusiness).toBe(true);
|
|
140
|
+
|
|
141
|
+
scope.stop();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('leaves isBusiness undefined for both queries when the order has no flag', async () => {
|
|
145
|
+
const form = buildForm({
|
|
146
|
+
[FIELD_CARRIER]: 'POSTNL',
|
|
147
|
+
[FIELD_PACKAGE_TYPE]: 'PACKAGE',
|
|
148
|
+
[FIELD_DELIVERY_TYPE]: 'STANDARD',
|
|
149
|
+
[FIELD_MANUAL_WEIGHT]: TriState.Inherit,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const scope = effectScope();
|
|
153
|
+
const {wireProxyCapabilities} = await import('./wireProxyCapabilities');
|
|
154
|
+
|
|
155
|
+
scope.run(() => {
|
|
156
|
+
wireProxyCapabilities(form as never, orderShape());
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const orderInputRef = useOrderCapabilitiesQueryMock.mock.calls[0][0] as {value: {isBusiness?: boolean}};
|
|
160
|
+
const selectionRef = useShipmentCapabilitiesQueryMock.mock.calls[0][0] as {value: {isBusiness?: boolean}};
|
|
161
|
+
|
|
162
|
+
expect(orderInputRef.value.isBusiness).toBeUndefined();
|
|
163
|
+
expect(selectionRef.value.isBusiness).toBeUndefined();
|
|
164
|
+
|
|
165
|
+
scope.stop();
|
|
166
|
+
});
|
|
167
|
+
|
|
116
168
|
it('skips wiring and returns undefined when the order has no externalIdentifier (bulk path)', async () => {
|
|
117
169
|
const form = buildForm({});
|
|
118
170
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {computed, onScopeDispose, type Ref} from 'vue';
|
|
2
2
|
import {type FormInstance} from '@myparcel-dev/vue-form-builder';
|
|
3
3
|
import {BackendEndpoint, type Plugin} from '@myparcel-dev/pdk-common';
|
|
4
|
-
import {globalLogger} from '../../services';
|
|
5
4
|
import {useQueryStore} from '../../stores';
|
|
5
|
+
import {globalLogger} from '../../services';
|
|
6
6
|
import {
|
|
7
7
|
useShipmentCapabilitiesQuery,
|
|
8
8
|
type CapabilitiesSelection,
|
|
@@ -15,15 +15,38 @@ import {useCapabilitiesWatcher, type FormInput, type OrderInput} from './useCapa
|
|
|
15
15
|
import {FIELD_CARRIER, FIELD_DELIVERY_TYPE, FIELD_MANUAL_WEIGHT, FIELD_PACKAGE_TYPE} from './field';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
18
|
+
* Resolve the order-scoped capabilities input from the form + order.
|
|
19
|
+
*
|
|
20
|
+
* Read weight through `form.getValue()` (which goes through `q(field.ref)` / `toValue`) rather
|
|
21
|
+
* than `form.values` so reactive deps are tracked when called inside a computed. Manual weight from
|
|
22
|
+
* `FIELD_MANUAL_WEIGHT` wins when set — it carries `TriState.Inherit` (-1) when unset, and only a
|
|
23
|
+
* positive number is a real override; otherwise fall back to the order's initial weight.
|
|
24
|
+
*
|
|
25
|
+
* `isBusiness` is the PDK-derived recipient flag (from the company name), forwarded as-is — no
|
|
26
|
+
* company or other PII is handled here.
|
|
27
|
+
*/
|
|
28
|
+
const resolveOrderInput = (form: FormInstance, order: Plugin.ModelContextOrderDataContext): OrderInput => {
|
|
29
|
+
const manualWeightRaw = form.getValue(FIELD_MANUAL_WEIGHT);
|
|
30
|
+
const manualWeight = typeof manualWeightRaw === 'number' && manualWeightRaw > 0 ? manualWeightRaw : undefined;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
cc: order.shippingAddress?.cc,
|
|
34
|
+
weight: manualWeight ?? order.physicalProperties?.initialWeight,
|
|
35
|
+
isBusiness: order.shippingAddress?.isBusiness,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Wire BOTH capabilities queries — order-scoped (cc + weight + isBusiness) and shipment-scoped
|
|
41
|
+
* (full selection) — into the shipment-options form for a single order, register them in the
|
|
42
|
+
* query store under composite-string modifiers (`${orderId}.order` and `${orderId}.shipment`),
|
|
43
|
+
* and tear them down when the form's scope disposes (modal close).
|
|
22
44
|
*
|
|
23
45
|
* The two queries serve different concerns:
|
|
24
46
|
*
|
|
25
47
|
* - **Order query** drives the carrier / packageType / deliveryType dropdowns from each
|
|
26
|
-
* carrier's flat union arrays. Refetches only when destination or
|
|
48
|
+
* carrier's flat union arrays. Refetches only when destination, weight or the recipient
|
|
49
|
+
* business flag change.
|
|
27
50
|
* - **Shipment query** drives per-option metadata (`isRequired`, `requires`, `excludes`,
|
|
28
51
|
* `insuredAmount`) for the chosen combination. Refetches when any axis of the selection
|
|
29
52
|
* changes; the empty-result case is the invalid-combo signal consumed by
|
|
@@ -51,20 +74,7 @@ export const wireProxyCapabilities = (
|
|
|
51
74
|
const orderModifier = `${orderId}.order`;
|
|
52
75
|
const shipmentModifier = `${orderId}.shipment`;
|
|
53
76
|
|
|
54
|
-
|
|
55
|
-
// than `form.values[name]` so reactive deps are tracked correctly inside computed/watchers.
|
|
56
|
-
const orderInput = computed<OrderInput>(() => {
|
|
57
|
-
// FIELD_MANUAL_WEIGHT carries `TriState.Inherit` (-1) when the user hasn't entered a manual
|
|
58
|
-
// override; only positive numbers represent an actual weight. Treat anything else as "unset"
|
|
59
|
-
// and fall back to the order's initial weight.
|
|
60
|
-
const manualWeightRaw = form.getValue(FIELD_MANUAL_WEIGHT);
|
|
61
|
-
const manualWeight = typeof manualWeightRaw === 'number' && manualWeightRaw > 0 ? manualWeightRaw : undefined;
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
cc: order.shippingAddress?.cc,
|
|
65
|
-
weight: manualWeight ?? order.physicalProperties?.initialWeight,
|
|
66
|
-
};
|
|
67
|
-
});
|
|
77
|
+
const orderInput = computed<OrderInput>(() => resolveOrderInput(form, order));
|
|
68
78
|
|
|
69
79
|
const formInput = computed<FormInput>(() => ({
|
|
70
80
|
carrier: form.getValue<string | undefined>(FIELD_CARRIER),
|
|
@@ -77,6 +87,7 @@ export const wireProxyCapabilities = (
|
|
|
77
87
|
const orderInputForQuery = computed<OrderCapabilitiesInput>(() => ({
|
|
78
88
|
cc: selection.value.cc,
|
|
79
89
|
weight: selection.value.weight,
|
|
90
|
+
isBusiness: selection.value.isBusiness,
|
|
80
91
|
}));
|
|
81
92
|
|
|
82
93
|
const orderQuery = useOrderCapabilitiesQuery(orderInputForQuery);
|
package/src/types/sdk.types.ts
CHANGED
|
@@ -209,7 +209,7 @@ interface ProxyCapabilitiesDefinition extends PdkEndpointDefinition {
|
|
|
209
209
|
* SDK's `PhysicalPropertiesWeightV2` model defines it on the wire.
|
|
210
210
|
*/
|
|
211
211
|
body: {
|
|
212
|
-
recipient: {countryCode: string};
|
|
212
|
+
recipient: {countryCode: string; isBusiness?: boolean};
|
|
213
213
|
physicalProperties?: {
|
|
214
214
|
weight?: {value: number; unit: 'g' | 'kg'};
|
|
215
215
|
};
|