@ikas/storefront-model-functions 5.0.0-beta.18 → 5.0.0-beta.19
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IkasOrder, IkasOrderPackage } from "@ikas/storefront-models";
|
|
2
|
+
export declare function initOrder(order: IkasOrder): void;
|
|
2
3
|
export declare function getItemCount(order: IkasOrder): number;
|
|
3
4
|
export declare function getItemQuantity(order: IkasOrder): number;
|
|
4
5
|
export declare function getDisplayedPackages(order: IkasOrder): IkasOrderPackage[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasOrderLineItemStatus as r,IkasOrderPackageFullfillStatus as e,IkasCampaignType as
|
|
1
|
+
import{IkasOrderLineItemStatus as r,IkasOrderPackageFullfillStatus as e,IkasCampaignType as n}from"@ikas/storefront-models";import{formatCurrency as t}from"../../utils/currency.js";import{validateEmail as u,formatDate as o}from"../../utils/helper.js";function i(r){r.orderLineItems.forEach((function(r){r.variant.mainImage=r.variant.mainImageId?{id:r.variant.mainImageId,isVideo:!1}:null}))}function d(r){var e;return(null===(e=r.orderLineItems)||void 0===e?void 0:e.length)||0}function c(r){var e;return(null===(e=r.orderLineItems)||void 0===e?void 0:e.reduce((function(r,e){return r+e.quantity}),0))||0}function a(n){var t,u=s(n),o=null===(t=n.orderPackages)||void 0===t?void 0:t.filter((function(r){return!r.deleted&&![e.REFUNDED,e.REFUND_REQUESTED,e.REFUND_REQUEST_ACCEPTED,e.REFUND_REJECTED].includes(r.orderPackageFulfillStatus)})),i=n.orderLineItems.filter((function(e){return!e.deleted&&(e.status===r.CANCELLED||e.status===r.CANCEL_REJECTED||e.status===r.CANCEL_REQUESTED)})),d=f(n),c=[];return u.length&&c.push({id:n.id+"-u",createdAt:Date.now(),updatedAt:Date.now(),errorMessage:null,note:null,orderLineItemIds:u.map((function(r){return r.id})),orderPackageFulfillStatus:e.UNFULFILLED,orderPackageNumber:n.orderNumber?n.orderNumber+"-u":"u",stockLocationId:u[0].stockLocationId||"",trackingInfo:null}),o&&c.push.apply(c,o),i.length&&c.push({id:n.id+"-c",createdAt:Date.now(),updatedAt:Date.now(),errorMessage:null,note:null,orderLineItemIds:i.map((function(r){return r.id})),orderPackageFulfillStatus:e.CANCELLED,orderPackageNumber:n.orderNumber?n.orderNumber+"-c":"c",stockLocationId:i[0].stockLocationId||"",trackingInfo:null}),d.length&&c.push({id:n.id+"-r",createdAt:Date.now(),updatedAt:Date.now(),errorMessage:null,note:null,orderLineItemIds:d.map((function(r){return r.id})),orderPackageFulfillStatus:e.REFUNDED,orderPackageNumber:n.orderNumber?n.orderNumber+"-r":"r",stockLocationId:d[0].stockLocationId||"",trackingInfo:null}),c}function l(e){var n=e.refundSettings;if(n&&!n.isActiveRefundSection)return[];var t=function(r){var e=r.orderedAt,n=Date.now();return Math.abs(n-e)/864e5}(e);return e.orderLineItems.filter((function(e){return[r.FULFILLED,r.UNFULFILLED,r.DELIVERED].includes(e.status)&&(!n.orderRefundDayLimit||n.orderRefundDayLimit>=t)}))}function s(e){return e.orderLineItems.filter((function(e){return e.status===r.UNFULFILLED}))}function f(e){return e.orderLineItems.filter((function(e){return e.status===r.REFUNDED||e.status===r.REFUND_REQUESTED||e.status===r.REFUND_REQUEST_ACCEPTED||e.status===r.REFUND_REJECTED}))}function m(r){var e;return(null===(e=r.taxLines)||void 0===e?void 0:e.reduce((function(r,e){return r+e.price}),0))||0}function E(r){return t(m(r),r.currencyCode,r.currencySymbol||"")}function v(r){var e;return(null===(e=r.shippingLines)||void 0===e?void 0:e.reduce((function(r,e){return r+e.finalPrice}),0))||0}function L(r){return t(v(r),r.currencyCode,r.currencySymbol||"")}function D(r){return t(r.totalPrice,r.currencyCode,r.currencySymbol||"")}function I(r){return t(r.totalFinalPrice,r.currencyCode,r.currencySymbol||"")}function N(r){var e;return!!(null===(e=r.customer)||void 0===e?void 0:e.id)&&!r.customer.isGuestCheckout}function g(r){var e;return!!(null===(e=r.customer)||void 0===e?void 0:e.email)&&u(r.customer.email)}function p(r){var e,n;return"".concat((null===(e=r.customer)||void 0===e?void 0:e.firstName)||""," ").concat((null===(n=r.customer)||void 0===n?void 0:n.lastName)||"")}function F(r){var e=new Date;return e.setTime(r.updatedAt),o(e)}function R(r){var e;return null===(e=r.orderAdjustments)||void 0===e?void 0:e.find((function(r){return!!r.couponId}))}function U(r){var e;return null===(e=r.orderAdjustments)||void 0===e?void 0:e.filter((function(r){return!r.couponId}))}function C(r){return!!r.refundSettings&&l(r).some((function(r){return null!==r.refundQuantity}))}function k(r){var e;return null===(e=r.orderAdjustments)||void 0===e?void 0:e.filter((function(r){return r.campaignType!==n.FREE_SHIPPING}))}export{R as getCouponAdjustment,p as getCustomerFullName,k as getDisplayedOrderAdjustments,a as getDisplayedPackages,F as getFormattedDate,L as getFormattedShippingTotal,I as getFormattedTotalFinalPrice,D as getFormattedTotalPrice,E as getFormattedTotalTax,d as getItemCount,c as getItemQuantity,U as getNonCouponAdjustments,l as getRefundableItems,f as getRefundedItems,v as getShippingTotal,m as getTotalTax,s as getUnfullfilledItems,N as hasCustomer,g as hasValidCustomerEmail,i as initOrder,C as isRefundEnabled};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { IkasProductOptionSet } from "@ikas/storefront-models";
|
|
1
|
+
import { IkasProductOption, IkasProductOptionSet } from "@ikas/storefront-models";
|
|
2
2
|
export declare function initProductOptionSet(optionSet: IkasProductOptionSet, locale: string | null): void;
|
|
3
|
-
export declare function getDisplayedOptions(optionSet: IkasProductOptionSet):
|
|
3
|
+
export declare function getDisplayedOptions(optionSet: IkasProductOptionSet): IkasProductOption[];
|
|
4
4
|
export declare function initOptionValues(optionSet: IkasProductOptionSet): void;
|
|
5
|
+
export declare function initProductOptionSetValues(optionSet: IkasProductOptionSet): void;
|
|
6
|
+
export declare function initSetValues(option: IkasProductOption): void;
|
|
5
7
|
export declare function hasValidValues(optionSet: IkasProductOptionSet): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasProductOptionType as n}from"@ikas/storefront-models";import o from"lodash/sortBy";import{initProductOption as t,initValues as i,hasValidValues as r}from"./option/index.js";function e(o,i){
|
|
1
|
+
import{IkasProductOptionType as n}from"@ikas/storefront-models";import o from"lodash/sortBy";import{initProductOption as t,initValues as i,hasValidValues as r}from"./option/index.js";function e(o,i){o.options.forEach((function(n){n.productOptionSetId=o.id,n.childOptions=[],t(n)})),function(n){n.options.forEach((function(o){var t=n.options.filter((function(n){return n.requiredOptionId===o.id}));t.length&&(o.childOptions=t)}))}(o),o.translations&&i&&(!function(o,t,i){var r;if(t&&t.some((function(n){return n.locale===i}))){var e=t.find((function(n){return n.locale===i}));null===(r=null==e?void 0:e.options)||void 0===r||r.forEach((function(t){var i,r=o.options.find((function(n){return n.id===t.id}));r&&(r.name=t.name||r.name,r.optionalText=t.optionalText||r.optionalText,r.type===n.CHOICE&&(null===(i=t.values)||void 0===i||i.forEach((function(n){var o,t=null===(o=r.selectSettings)||void 0===o?void 0:o.values.find((function(o){return o.id===n.id}));t&&(t.value=n.value||t.value)}))))}))}}(o,o.translations,i),delete o.translations),f(o)}function u(n){return o(n.options.filter((function(n){return!n.requiredOptionId})),"order")}function a(n){n.options.forEach((function(n){return i(n)}))}function f(n){n.options.forEach((function(n){return l(n)}))}function l(n){var o;n.values=[],null===(o=n.childOptions)||void 0===o||o.forEach((function(n){return l(n)}))}function c(n){return u(n).every(r)}export{u as getDisplayedOptions,c as hasValidValues,a as initOptionValues,e as initProductOptionSet,f as initProductOptionSetValues,l as initSetValues};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-model-functions",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.19",
|
|
4
4
|
"description": "Functions for ikas storefront models.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"build": "rm -rf build && rollup -c"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@ikas/storefront-config": "^5.0.0-beta.
|
|
20
|
-
"@ikas/storefront-models": "^5.0.0-beta.
|
|
19
|
+
"@ikas/storefront-config": "^5.0.0-beta.19",
|
|
20
|
+
"@ikas/storefront-models": "^5.0.0-beta.19",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
22
22
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
23
23
|
"rollup-plugin-rename-node-modules": "^1.2.0",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"lodash": "^4.17.21"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@ikas/storefront-config": "^5.0.0-beta.
|
|
37
|
-
"@ikas/storefront-models": "^5.0.0-beta.
|
|
36
|
+
"@ikas/storefront-config": "^5.0.0-beta.19",
|
|
37
|
+
"@ikas/storefront-models": "^5.0.0-beta.19",
|
|
38
38
|
"lodash": "^4.17.21"
|
|
39
39
|
}
|
|
40
40
|
}
|