rerobe-js-orm 4.8.8 → 4.9.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/lib/constants/marketplace-constants.d.ts +52 -0
- package/lib/constants/marketplace-constants.js +82 -0
- package/lib/constants/product-constants.d.ts +6 -0
- package/lib/constants/product-constants.js +43 -1
- package/lib/constants/tax-constants.d.ts +19 -0
- package/lib/constants/tax-constants.js +70 -0
- package/lib/factories/Product/RetailProductFactory.d.ts +102 -0
- package/lib/factories/Product/RetailProductFactory.js +260 -0
- package/lib/form-states/Product/ProductFormState.d.ts +9 -0
- package/lib/form-states/Product/ProductFormState.js +46 -0
- package/lib/helpers/MarketplaceProductHelpers.d.ts +181 -0
- package/lib/helpers/MarketplaceProductHelpers.js +555 -0
- package/lib/helpers/OrderHelpers.d.ts +5 -2
- package/lib/helpers/OrderHelpers.js +18 -4
- package/lib/helpers/PricingHelpers.d.ts +29 -0
- package/lib/helpers/PricingHelpers.js +215 -0
- package/lib/helpers/ProductInventoryHelpers.d.ts +31 -0
- package/lib/helpers/ProductInventoryHelpers.js +66 -0
- package/lib/helpers/ProductSkuHelpers.d.ts +13 -0
- package/lib/helpers/ProductSkuHelpers.js +70 -0
- package/lib/helpers/TaxHelpers.d.ts +15 -0
- package/lib/helpers/TaxHelpers.js +76 -0
- package/lib/helpers/marketplace/CommissionPolicy.d.ts +20 -0
- package/lib/helpers/marketplace/CommissionPolicy.js +9 -0
- package/lib/helpers/marketplace/CommissionPolicyRegistry.d.ts +4 -0
- package/lib/helpers/marketplace/CommissionPolicyRegistry.js +21 -0
- package/lib/helpers/marketplace/EvenPerSellerStripeFeePolicy.d.ts +5 -0
- package/lib/helpers/marketplace/EvenPerSellerStripeFeePolicy.js +46 -0
- package/lib/helpers/marketplace/FeeAllocationPolicy.d.ts +10 -0
- package/lib/helpers/marketplace/FeeAllocationPolicy.js +36 -0
- package/lib/helpers/marketplace/FeeAllocationPolicyRegistry.d.ts +6 -0
- package/lib/helpers/marketplace/FeeAllocationPolicyRegistry.js +26 -0
- package/lib/helpers/marketplace/InventoryPolicy.d.ts +18 -0
- package/lib/helpers/marketplace/InventoryPolicy.js +7 -0
- package/lib/helpers/marketplace/InventoryPolicyRegistry.d.ts +4 -0
- package/lib/helpers/marketplace/InventoryPolicyRegistry.js +29 -0
- package/lib/helpers/marketplace/LineNetCommissionPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/LineNetCommissionPolicy.js +25 -0
- package/lib/helpers/marketplace/MarketplaceErrors.d.ts +6 -0
- package/lib/helpers/marketplace/MarketplaceErrors.js +21 -0
- package/lib/helpers/marketplace/MarketplaceLedgerHelpers.d.ts +40 -0
- package/lib/helpers/marketplace/MarketplaceLedgerHelpers.js +120 -0
- package/lib/helpers/marketplace/MarketplaceLegacyAdapters.d.ts +53 -0
- package/lib/helpers/marketplace/MarketplaceLegacyAdapters.js +99 -0
- package/lib/helpers/marketplace/MarketplaceLineDisplayHelpers.d.ts +40 -0
- package/lib/helpers/marketplace/MarketplaceLineDisplayHelpers.js +125 -0
- package/lib/helpers/marketplace/MarketplaceOrderHelpers.d.ts +15 -0
- package/lib/helpers/marketplace/MarketplaceOrderHelpers.js +77 -0
- package/lib/helpers/marketplace/MultivariantLocationInventoryPolicy.d.ts +9 -0
- package/lib/helpers/marketplace/MultivariantLocationInventoryPolicy.js +60 -0
- package/lib/helpers/marketplace/OneOfAKindInventoryPolicy.d.ts +9 -0
- package/lib/helpers/marketplace/OneOfAKindInventoryPolicy.js +55 -0
- package/lib/helpers/marketplace/OriginalCommissionShareCommissionPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/OriginalCommissionShareCommissionPolicy.js +26 -0
- package/lib/helpers/marketplace/ProportionalToLineNetPolicy.d.ts +5 -0
- package/lib/helpers/marketplace/ProportionalToLineNetPolicy.js +35 -0
- package/lib/helpers/marketplace/UntrackedStockInventoryPolicy.d.ts +7 -0
- package/lib/helpers/marketplace/UntrackedStockInventoryPolicy.js +23 -0
- package/lib/index.d.ts +18 -1
- package/lib/index.js +56 -1
- package/lib/models/Product.d.ts +16 -0
- package/lib/models/Product.js +140 -0
- package/lib/types/pricing-types.d.ts +85 -0
- package/lib/types/pricing-types.js +5 -0
- package/lib/types/rerobe-order-types.d.ts +86 -0
- package/lib/types/rerobe-product-types.d.ts +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatMarketplaceLineDisplayTitle = exports.buildMarketplaceLineDisplayTitle = exports.stripMarketplaceSellerPrefix = exports.getMarketplaceLineVariantLabel = exports.getMarketplaceLineSellerDisplayName = void 0;
|
|
4
|
+
const DEFAULT_PREFIX_SEPARATOR = ' - ';
|
|
5
|
+
const normalizeText = (value) => String(value || '')
|
|
6
|
+
.replace(/\s+/g, ' ')
|
|
7
|
+
.trim();
|
|
8
|
+
const getSnapshot = (lineItem) => (lineItem === null || lineItem === void 0 ? void 0 : lineItem.marketplace) || {};
|
|
9
|
+
const normalizeVariantOptionsInput = (options) => {
|
|
10
|
+
if (!options)
|
|
11
|
+
return {};
|
|
12
|
+
if (Array.isArray(options)) {
|
|
13
|
+
return options.reduce((acc, option) => {
|
|
14
|
+
const key = normalizeText((option === null || option === void 0 ? void 0 : option.name) || (option === null || option === void 0 ? void 0 : option.key) || (option === null || option === void 0 ? void 0 : option.label) || '');
|
|
15
|
+
const value = normalizeText(option === null || option === void 0 ? void 0 : option.value);
|
|
16
|
+
if (key && value)
|
|
17
|
+
acc[key] = value;
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
}
|
|
21
|
+
if (typeof options !== 'object')
|
|
22
|
+
return {};
|
|
23
|
+
return Object.keys(options).reduce((acc, key) => {
|
|
24
|
+
const safeKey = normalizeText(key);
|
|
25
|
+
const safeValue = normalizeText(options[key]);
|
|
26
|
+
if (safeKey && safeValue)
|
|
27
|
+
acc[safeKey] = safeValue;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
};
|
|
31
|
+
const getMarketplaceLineSellerDisplayName = (lineItem, fallbackSellerDisplayName) => {
|
|
32
|
+
const snapshot = getSnapshot(lineItem);
|
|
33
|
+
return normalizeText(fallbackSellerDisplayName ||
|
|
34
|
+
snapshot.sellerDisplayName ||
|
|
35
|
+
snapshot.managedMerchantName ||
|
|
36
|
+
snapshot.sellerName ||
|
|
37
|
+
'');
|
|
38
|
+
};
|
|
39
|
+
exports.getMarketplaceLineSellerDisplayName = getMarketplaceLineSellerDisplayName;
|
|
40
|
+
const getVariantOptionsFromLine = (lineItem) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const snapshot = (lineItem === null || lineItem === void 0 ? void 0 : lineItem.marketplace) || {};
|
|
43
|
+
const fromSnapshot = ((_a = snapshot === null || snapshot === void 0 ? void 0 : snapshot.variant) === null || _a === void 0 ? void 0 : _a.options) || (snapshot === null || snapshot === void 0 ? void 0 : snapshot.variantOptions) || null;
|
|
44
|
+
const normalizedFromSnapshot = normalizeVariantOptionsInput(fromSnapshot);
|
|
45
|
+
if (Object.keys(normalizedFromSnapshot).length)
|
|
46
|
+
return normalizedFromSnapshot;
|
|
47
|
+
const fromLine = ((_b = lineItem === null || lineItem === void 0 ? void 0 : lineItem.variant) === null || _b === void 0 ? void 0 : _b.options) || (lineItem === null || lineItem === void 0 ? void 0 : lineItem.selectedOptions) || null;
|
|
48
|
+
const normalizedFromLine = normalizeVariantOptionsInput(fromLine);
|
|
49
|
+
if (Object.keys(normalizedFromLine).length)
|
|
50
|
+
return normalizedFromLine;
|
|
51
|
+
return {};
|
|
52
|
+
};
|
|
53
|
+
const formatVariantOptions = (options) => {
|
|
54
|
+
const normalizedOptions = normalizeVariantOptionsInput(options);
|
|
55
|
+
const parts = Object.keys(normalizedOptions)
|
|
56
|
+
.map((key) => {
|
|
57
|
+
const value = normalizedOptions[key];
|
|
58
|
+
const safeKey = normalizeText(key);
|
|
59
|
+
const safeValue = normalizeText(value);
|
|
60
|
+
if (!safeKey || !safeValue)
|
|
61
|
+
return '';
|
|
62
|
+
return `${safeKey}: ${safeValue}`;
|
|
63
|
+
})
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
return parts.join(', ');
|
|
66
|
+
};
|
|
67
|
+
const getMarketplaceLineVariantLabel = (input) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const explicitOptions = input === null || input === void 0 ? void 0 : input.variantOptions;
|
|
70
|
+
const options = explicitOptions
|
|
71
|
+
? normalizeVariantOptionsInput(explicitOptions)
|
|
72
|
+
: getVariantOptionsFromLine(input === null || input === void 0 ? void 0 : input.lineItem);
|
|
73
|
+
const formatted = formatVariantOptions(options);
|
|
74
|
+
if (formatted)
|
|
75
|
+
return formatted;
|
|
76
|
+
const snapshot = ((_a = input === null || input === void 0 ? void 0 : input.lineItem) === null || _a === void 0 ? void 0 : _a.marketplace) || {};
|
|
77
|
+
const sku = normalizeText((input === null || input === void 0 ? void 0 : input.variantSku) || ((_b = snapshot === null || snapshot === void 0 ? void 0 : snapshot.variant) === null || _b === void 0 ? void 0 : _b.sku) || '');
|
|
78
|
+
return sku ? `SKU ${sku}` : '';
|
|
79
|
+
};
|
|
80
|
+
exports.getMarketplaceLineVariantLabel = getMarketplaceLineVariantLabel;
|
|
81
|
+
const stripMarketplaceSellerPrefix = (title, sellerDisplayName, prefixSeparator = DEFAULT_PREFIX_SEPARATOR) => {
|
|
82
|
+
const safeTitle = normalizeText(title);
|
|
83
|
+
const safeSeller = normalizeText(sellerDisplayName);
|
|
84
|
+
if (!safeTitle || !safeSeller)
|
|
85
|
+
return safeTitle;
|
|
86
|
+
const prefix = `${safeSeller}${prefixSeparator}`;
|
|
87
|
+
if (safeTitle.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
|
|
88
|
+
return safeTitle.slice(prefix.length).trim();
|
|
89
|
+
}
|
|
90
|
+
return safeTitle;
|
|
91
|
+
};
|
|
92
|
+
exports.stripMarketplaceSellerPrefix = stripMarketplaceSellerPrefix;
|
|
93
|
+
const buildMarketplaceLineDisplayTitle = (input, options = {}) => {
|
|
94
|
+
const { lineItem, sellerDisplayName: sellerDisplayNameInput } = input || {};
|
|
95
|
+
const snapshot = getSnapshot(lineItem);
|
|
96
|
+
const sellerDisplayName = (0, exports.getMarketplaceLineSellerDisplayName)(lineItem, sellerDisplayNameInput);
|
|
97
|
+
const rawTitle = (input === null || input === void 0 ? void 0 : input.title) || snapshot.lineDisplayTitle || (lineItem === null || lineItem === void 0 ? void 0 : lineItem.title) || (input === null || input === void 0 ? void 0 : input.brand) || (lineItem === null || lineItem === void 0 ? void 0 : lineItem.brand) || '';
|
|
98
|
+
const prefixSeparator = options.prefixSeparator || DEFAULT_PREFIX_SEPARATOR;
|
|
99
|
+
const baseTitle = (0, exports.stripMarketplaceSellerPrefix)(rawTitle, sellerDisplayName, prefixSeparator);
|
|
100
|
+
const shouldPrefix = options.includeSellerPrefix === undefined
|
|
101
|
+
? options.mode === 'staff' || options.mode === 'receipt'
|
|
102
|
+
: options.includeSellerPrefix;
|
|
103
|
+
const prefixedTitle = shouldPrefix && sellerDisplayName && baseTitle ? `${sellerDisplayName}${prefixSeparator}${baseTitle}` : baseTitle;
|
|
104
|
+
const variantLabel = (0, exports.getMarketplaceLineVariantLabel)(input || {});
|
|
105
|
+
const shouldAppendVariantLabel = options.appendVariantLabel === undefined
|
|
106
|
+
? options.mode === 'staff' || options.mode === 'receipt'
|
|
107
|
+
: options.appendVariantLabel;
|
|
108
|
+
const displayTitle = shouldAppendVariantLabel && variantLabel && prefixedTitle ? `${prefixedTitle} (${variantLabel})` : prefixedTitle;
|
|
109
|
+
return {
|
|
110
|
+
baseTitle,
|
|
111
|
+
displayTitle,
|
|
112
|
+
sellerDisplayName,
|
|
113
|
+
variantLabel,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
exports.buildMarketplaceLineDisplayTitle = buildMarketplaceLineDisplayTitle;
|
|
117
|
+
const formatMarketplaceLineDisplayTitle = (input, options = {}) => (0, exports.buildMarketplaceLineDisplayTitle)(input, options).displayTitle;
|
|
118
|
+
exports.formatMarketplaceLineDisplayTitle = formatMarketplaceLineDisplayTitle;
|
|
119
|
+
exports.default = {
|
|
120
|
+
buildMarketplaceLineDisplayTitle: exports.buildMarketplaceLineDisplayTitle,
|
|
121
|
+
formatMarketplaceLineDisplayTitle: exports.formatMarketplaceLineDisplayTitle,
|
|
122
|
+
getMarketplaceLineSellerDisplayName: exports.getMarketplaceLineSellerDisplayName,
|
|
123
|
+
getMarketplaceLineVariantLabel: exports.getMarketplaceLineVariantLabel,
|
|
124
|
+
stripMarketplaceSellerPrefix: exports.stripMarketplaceSellerPrefix,
|
|
125
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const isMarketplaceLineItem: (lineItem: any) => boolean;
|
|
2
|
+
export declare const getMarketplaceLineItems: (lineItems?: ReRobeOrderLineItem[]) => ReRobeOrderLineItem[];
|
|
3
|
+
export declare const summarizeMarketplaceAmounts: (lineItems?: ReRobeOrderLineItem[]) => MarketplaceLineAmounts;
|
|
4
|
+
export declare const groupMarketplaceLinesByManagedMerchant: (lineItems?: ReRobeOrderLineItem[]) => Record<string, ReRobeOrderLineItem[]>;
|
|
5
|
+
export declare const groupMarketplaceLinesByRelationship: (lineItems?: ReRobeOrderLineItem[]) => Record<string, ReRobeOrderLineItem[]>;
|
|
6
|
+
export declare const buildFeeBasketFromLineItems: (lineItems?: ReRobeOrderLineItem[]) => MarketplaceFeeBasketLine[];
|
|
7
|
+
declare const _default: {
|
|
8
|
+
isMarketplaceLineItem: (lineItem: any) => boolean;
|
|
9
|
+
getMarketplaceLineItems: (lineItems?: ReRobeOrderLineItem[]) => ReRobeOrderLineItem[];
|
|
10
|
+
summarizeMarketplaceAmounts: (lineItems?: ReRobeOrderLineItem[]) => MarketplaceLineAmounts;
|
|
11
|
+
groupMarketplaceLinesByManagedMerchant: (lineItems?: ReRobeOrderLineItem[]) => Record<string, ReRobeOrderLineItem[]>;
|
|
12
|
+
groupMarketplaceLinesByRelationship: (lineItems?: ReRobeOrderLineItem[]) => Record<string, ReRobeOrderLineItem[]>;
|
|
13
|
+
buildFeeBasketFromLineItems: (lineItems?: ReRobeOrderLineItem[]) => MarketplaceFeeBasketLine[];
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Order-level marketplace helpers: aggregate marketplace line snapshots and
|
|
3
|
+
// group lines for fan-out. All helpers are pure and accept already-loaded
|
|
4
|
+
// line items so backend/web/mobile callers share one source of truth.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildFeeBasketFromLineItems = exports.groupMarketplaceLinesByRelationship = exports.groupMarketplaceLinesByManagedMerchant = exports.summarizeMarketplaceAmounts = exports.getMarketplaceLineItems = exports.isMarketplaceLineItem = void 0;
|
|
7
|
+
const EMPTY_AMOUNTS = {
|
|
8
|
+
lineNetAmount: 0,
|
|
9
|
+
discountAmount: 0,
|
|
10
|
+
taxableAmount: 0,
|
|
11
|
+
taxAmount: 0,
|
|
12
|
+
lineGrossAmount: 0,
|
|
13
|
+
originalProductCommissionAmount: 0,
|
|
14
|
+
marketplaceCommissionAmount: 0,
|
|
15
|
+
stripeFeeAllocatedAmount: 0,
|
|
16
|
+
ribbnFeeAllocatedAmount: 0,
|
|
17
|
+
sellerProceedsAmount: 0,
|
|
18
|
+
managedMerchantProceedsAmount: 0,
|
|
19
|
+
marketplaceProceedsAmount: 0,
|
|
20
|
+
};
|
|
21
|
+
const round = (value) => Number(Number(value || 0).toFixed(2));
|
|
22
|
+
const isMarketplaceLineItem = (lineItem) => Boolean(lineItem && lineItem.marketplace && lineItem.marketplace.isMarketplaceItem);
|
|
23
|
+
exports.isMarketplaceLineItem = isMarketplaceLineItem;
|
|
24
|
+
const getMarketplaceLineItems = (lineItems = []) => Array.isArray(lineItems) ? lineItems.filter(exports.isMarketplaceLineItem) : [];
|
|
25
|
+
exports.getMarketplaceLineItems = getMarketplaceLineItems;
|
|
26
|
+
const summarizeMarketplaceAmounts = (lineItems = []) => {
|
|
27
|
+
const marketplaceLines = (0, exports.getMarketplaceLineItems)(lineItems);
|
|
28
|
+
if (marketplaceLines.length === 0) {
|
|
29
|
+
return Object.assign({}, EMPTY_AMOUNTS);
|
|
30
|
+
}
|
|
31
|
+
const totals = marketplaceLines.reduce((acc, line) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const amounts = ((_a = line.marketplace) === null || _a === void 0 ? void 0 : _a.amounts) || EMPTY_AMOUNTS;
|
|
34
|
+
Object.keys(EMPTY_AMOUNTS).forEach((key) => {
|
|
35
|
+
acc[key] = round((acc[key] || 0) + (Number(amounts[key]) || 0));
|
|
36
|
+
});
|
|
37
|
+
return acc;
|
|
38
|
+
}, Object.assign({}, EMPTY_AMOUNTS));
|
|
39
|
+
return totals;
|
|
40
|
+
};
|
|
41
|
+
exports.summarizeMarketplaceAmounts = summarizeMarketplaceAmounts;
|
|
42
|
+
const groupBy = (lineItems, selector) => {
|
|
43
|
+
const groups = {};
|
|
44
|
+
(0, exports.getMarketplaceLineItems)(lineItems).forEach((line) => {
|
|
45
|
+
const key = selector(line);
|
|
46
|
+
if (!key)
|
|
47
|
+
return;
|
|
48
|
+
if (!groups[key])
|
|
49
|
+
groups[key] = [];
|
|
50
|
+
groups[key].push(line);
|
|
51
|
+
});
|
|
52
|
+
return groups;
|
|
53
|
+
};
|
|
54
|
+
const groupMarketplaceLinesByManagedMerchant = (lineItems = []) => groupBy(lineItems, (line) => { var _a; return String(((_a = line.marketplace) === null || _a === void 0 ? void 0 : _a.managedMerchantId) || ''); });
|
|
55
|
+
exports.groupMarketplaceLinesByManagedMerchant = groupMarketplaceLinesByManagedMerchant;
|
|
56
|
+
const groupMarketplaceLinesByRelationship = (lineItems = []) => groupBy(lineItems, (line) => { var _a; return String(((_a = line.marketplace) === null || _a === void 0 ? void 0 : _a.relationshipId) || ''); });
|
|
57
|
+
exports.groupMarketplaceLinesByRelationship = groupMarketplaceLinesByRelationship;
|
|
58
|
+
const buildFeeBasketFromLineItems = (lineItems = []) => (0, exports.getMarketplaceLineItems)(lineItems).map((line, index) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const snapshot = line.marketplace;
|
|
61
|
+
return {
|
|
62
|
+
lineKey: snapshot.productId ? `${snapshot.productId}:${snapshot.variantId || ''}:${index}` : `line:${index}`,
|
|
63
|
+
sellerMerchantId: String(snapshot.managedMerchantId || ''),
|
|
64
|
+
lineNetAmount: Number(((_a = snapshot.amounts) === null || _a === void 0 ? void 0 : _a.lineNetAmount) || 0),
|
|
65
|
+
taxableAmount: Number(((_b = snapshot.amounts) === null || _b === void 0 ? void 0 : _b.taxableAmount) || 0),
|
|
66
|
+
quantity: Number(snapshot.quantity || 0),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
exports.buildFeeBasketFromLineItems = buildFeeBasketFromLineItems;
|
|
70
|
+
exports.default = {
|
|
71
|
+
isMarketplaceLineItem: exports.isMarketplaceLineItem,
|
|
72
|
+
getMarketplaceLineItems: exports.getMarketplaceLineItems,
|
|
73
|
+
summarizeMarketplaceAmounts: exports.summarizeMarketplaceAmounts,
|
|
74
|
+
groupMarketplaceLinesByManagedMerchant: exports.groupMarketplaceLinesByManagedMerchant,
|
|
75
|
+
groupMarketplaceLinesByRelationship: exports.groupMarketplaceLinesByRelationship,
|
|
76
|
+
buildFeeBasketFromLineItems: exports.buildFeeBasketFromLineItems,
|
|
77
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InventoryAdjustmentParams, InventoryAdjustmentResult, InventoryPolicy } from './InventoryPolicy';
|
|
2
|
+
export default class MultivariantLocationInventoryPolicy implements InventoryPolicy {
|
|
3
|
+
readonly kind: "MULTIVARIANT_LOCATION";
|
|
4
|
+
canHandle(product: CompleteProduct | null | undefined): boolean;
|
|
5
|
+
decrement(product: CompleteProduct, params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
6
|
+
restore(product: CompleteProduct, params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
7
|
+
private isUntrackedStock;
|
|
8
|
+
private adjust;
|
|
9
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const marketplace_constants_1 = require("../../constants/marketplace-constants");
|
|
4
|
+
// Multivariant policy: walk `variantInventory`, find the targeted variant,
|
|
5
|
+
// and adjust the requested location's `availableAmount`. Location resolution
|
|
6
|
+
// prefers an explicit `locationId`, then falls back to a `defaultLocationId`
|
|
7
|
+
// (typically the merchant's "Main" location), and finally to the legacy
|
|
8
|
+
// first-row behavior so existing single-location flows keep working. Always
|
|
9
|
+
// returns new arrays so callers can spread the result onto the product
|
|
10
|
+
// without mutating shared state.
|
|
11
|
+
const resolveLocationId = (variant, locationId, defaultLocationId) => {
|
|
12
|
+
const locations = Array.isArray(variant.locations) ? variant.locations : [];
|
|
13
|
+
if (locationId && locations.some((loc) => (loc === null || loc === void 0 ? void 0 : loc.id) === locationId))
|
|
14
|
+
return locationId;
|
|
15
|
+
if (defaultLocationId && locations.some((loc) => (loc === null || loc === void 0 ? void 0 : loc.id) === defaultLocationId))
|
|
16
|
+
return defaultLocationId;
|
|
17
|
+
return '';
|
|
18
|
+
};
|
|
19
|
+
const transformLocations = (variant, locationId, defaultLocationId, quantity, direction) => {
|
|
20
|
+
const locations = Array.isArray(variant.locations) ? variant.locations : [];
|
|
21
|
+
const targetLocationId = resolveLocationId(variant, locationId, defaultLocationId);
|
|
22
|
+
return locations.map((loc, index) => {
|
|
23
|
+
if (targetLocationId && loc.id !== targetLocationId)
|
|
24
|
+
return loc;
|
|
25
|
+
if (!targetLocationId && index > 0)
|
|
26
|
+
return loc;
|
|
27
|
+
const available = Number(loc.availableAmount) || 0;
|
|
28
|
+
return Object.assign(Object.assign({}, loc), { availableAmount: direction === 'restore' ? available + quantity : Math.max(0, available - quantity) });
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
class MultivariantLocationInventoryPolicy {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.kind = marketplace_constants_1.MARKETPLACE_INVENTORY_POLICY_KINDS.multivariantLocation;
|
|
34
|
+
}
|
|
35
|
+
canHandle(product) {
|
|
36
|
+
if (!product)
|
|
37
|
+
return false;
|
|
38
|
+
if (this.isUntrackedStock(product))
|
|
39
|
+
return false;
|
|
40
|
+
return Array.isArray(product.variantInventory) && product.variantInventory.length > 0;
|
|
41
|
+
}
|
|
42
|
+
decrement(product, params) {
|
|
43
|
+
return this.adjust(product, params, 'decrement');
|
|
44
|
+
}
|
|
45
|
+
restore(product, params) {
|
|
46
|
+
return this.adjust(product, params, 'restore');
|
|
47
|
+
}
|
|
48
|
+
isUntrackedStock(product) {
|
|
49
|
+
return String((product === null || product === void 0 ? void 0 : product.stockStatus) || '').trim() === marketplace_constants_1.STOCK_STATUSES.inStockUnlimited;
|
|
50
|
+
}
|
|
51
|
+
adjust(product, { variantId = '', locationId = '', defaultLocationId = '', quantity = 1 }, direction) {
|
|
52
|
+
const variants = Array.isArray(product.variantInventory) ? product.variantInventory : [];
|
|
53
|
+
const qty = Math.max(0, Number(quantity) || 0);
|
|
54
|
+
const variantInventory = variants.map((variant) => variant.id !== variantId
|
|
55
|
+
? variant
|
|
56
|
+
: Object.assign(Object.assign({}, variant), { locations: transformLocations(variant, locationId, defaultLocationId, qty, direction) }));
|
|
57
|
+
return { variantInventory };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.default = MultivariantLocationInventoryPolicy;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InventoryAdjustmentParams, InventoryAdjustmentResult, InventoryPolicy } from './InventoryPolicy';
|
|
2
|
+
export default class OneOfAKindInventoryPolicy implements InventoryPolicy {
|
|
3
|
+
readonly kind: "ONE_OF_A_KIND";
|
|
4
|
+
canHandle(product: CompleteProduct | null | undefined): boolean;
|
|
5
|
+
decrement(product: CompleteProduct, params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
6
|
+
restore(product: CompleteProduct, params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
7
|
+
private isUntrackedStock;
|
|
8
|
+
private adjust;
|
|
9
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const marketplace_constants_1 = require("../../constants/marketplace-constants");
|
|
4
|
+
// One-of-a-kind policy: a single physical item (UNIQUE class, qty 1).
|
|
5
|
+
// Decrement zeroes the stock and signals availableForSale = false via
|
|
6
|
+
// `quantity: 0`; restore returns it to qty 1. Status transitions remain the
|
|
7
|
+
// caller's responsibility (sold/listed) because the ORM does not own the
|
|
8
|
+
// product state machine here.
|
|
9
|
+
class OneOfAKindInventoryPolicy {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.kind = marketplace_constants_1.MARKETPLACE_INVENTORY_POLICY_KINDS.oneOfAKind;
|
|
12
|
+
}
|
|
13
|
+
canHandle(product) {
|
|
14
|
+
if (!product)
|
|
15
|
+
return false;
|
|
16
|
+
if (this.isUntrackedStock(product))
|
|
17
|
+
return false;
|
|
18
|
+
if (Array.isArray(product.variantInventory) && product.variantInventory.length > 0)
|
|
19
|
+
return false;
|
|
20
|
+
return String(product.productClass || 'UNIQUE') === 'UNIQUE';
|
|
21
|
+
}
|
|
22
|
+
decrement(product, params) {
|
|
23
|
+
return this.adjust(product, params, 'decrement');
|
|
24
|
+
}
|
|
25
|
+
restore(product, params) {
|
|
26
|
+
return this.adjust(product, params, 'restore');
|
|
27
|
+
}
|
|
28
|
+
isUntrackedStock(product) {
|
|
29
|
+
return String((product === null || product === void 0 ? void 0 : product.stockStatus) || '').trim() === marketplace_constants_1.STOCK_STATUSES.inStockUnlimited;
|
|
30
|
+
}
|
|
31
|
+
adjust(product, { locationId = '', defaultLocationId = '', quantity = 1 }, direction) {
|
|
32
|
+
const qty = Math.max(0, Number(quantity) || 0);
|
|
33
|
+
const next = direction === 'restore' ? qty : Math.max(0, (Number(product.quantity) || 0) - qty);
|
|
34
|
+
const locations = Array.isArray(product.inventoryLocations) ? product.inventoryLocations : [];
|
|
35
|
+
let targetLocationId = '';
|
|
36
|
+
if (locationId && locations.some((loc) => (loc === null || loc === void 0 ? void 0 : loc.id) === locationId)) {
|
|
37
|
+
targetLocationId = locationId;
|
|
38
|
+
}
|
|
39
|
+
else if (defaultLocationId && locations.some((loc) => (loc === null || loc === void 0 ? void 0 : loc.id) === defaultLocationId)) {
|
|
40
|
+
targetLocationId = defaultLocationId;
|
|
41
|
+
}
|
|
42
|
+
const inventoryLocations = Array.isArray(product.inventoryLocations)
|
|
43
|
+
? product.inventoryLocations.map((loc, index) => {
|
|
44
|
+
if (targetLocationId && loc.id !== targetLocationId)
|
|
45
|
+
return loc;
|
|
46
|
+
if (!targetLocationId && index > 0)
|
|
47
|
+
return loc;
|
|
48
|
+
const available = Number(loc.availableAmount) || 0;
|
|
49
|
+
return Object.assign(Object.assign({}, loc), { availableAmount: direction === 'restore' ? available + qty : Math.max(0, available - qty) });
|
|
50
|
+
})
|
|
51
|
+
: product.inventoryLocations;
|
|
52
|
+
return { quantity: next, inventoryLocations };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.default = OneOfAKindInventoryPolicy;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CommissionPolicy, CommissionPolicyContext, CommissionPolicyFeeContext, CommissionPolicyResult } from './CommissionPolicy';
|
|
2
|
+
export default class OriginalCommissionShareCommissionPolicy implements CommissionPolicy {
|
|
3
|
+
readonly basis: "ORIGINAL_COMMISSION_SHARE";
|
|
4
|
+
calculate({ taxableAmount, originalRate, marketplaceRate }: CommissionPolicyContext, { stripeFee, ribbnFee }: CommissionPolicyFeeContext): CommissionPolicyResult;
|
|
5
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const marketplace_constants_1 = require("../../constants/marketplace-constants");
|
|
4
|
+
const CommissionPolicy_1 = require("./CommissionPolicy");
|
|
5
|
+
// Marketplace commission is taken out of the original product commission
|
|
6
|
+
// pool. The managed merchant absorbs the marketplace cut, while the seller
|
|
7
|
+
// payout stays the same as if the sale had happened on the seller's own
|
|
8
|
+
// storefront.
|
|
9
|
+
class OriginalCommissionShareCommissionPolicy {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.basis = marketplace_constants_1.MARKETPLACE_COMMISSION_BASES.originalCommissionShare;
|
|
12
|
+
}
|
|
13
|
+
calculate({ taxableAmount, originalRate, marketplaceRate }, { stripeFee, ribbnFee }) {
|
|
14
|
+
const originalProductCommissionAmount = (0, CommissionPolicy_1.roundCommissionAmount)(taxableAmount * originalRate);
|
|
15
|
+
const marketplaceCommissionAmount = (0, CommissionPolicy_1.roundCommissionAmount)(originalProductCommissionAmount * marketplaceRate);
|
|
16
|
+
const managedMerchantProceedsAmount = (0, CommissionPolicy_1.roundCommissionAmount)(Math.max(0, originalProductCommissionAmount - marketplaceCommissionAmount));
|
|
17
|
+
const sellerProceedsAmount = (0, CommissionPolicy_1.roundCommissionAmount)(Math.max(0, taxableAmount - originalProductCommissionAmount - stripeFee - ribbnFee));
|
|
18
|
+
return {
|
|
19
|
+
originalProductCommissionAmount,
|
|
20
|
+
marketplaceCommissionAmount,
|
|
21
|
+
managedMerchantProceedsAmount,
|
|
22
|
+
sellerProceedsAmount,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = OriginalCommissionShareCommissionPolicy;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FeeAllocationContext, FeeAllocationPolicy } from './FeeAllocationPolicy';
|
|
2
|
+
export default class ProportionalToLineNetPolicy implements FeeAllocationPolicy {
|
|
3
|
+
readonly basis: "PROPORTIONAL_TO_LINE_NET";
|
|
4
|
+
allocate({ totalFeeAmount, basket }: FeeAllocationContext): MarketplaceFeeAllocation[];
|
|
5
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const marketplace_constants_1 = require("../../constants/marketplace-constants");
|
|
4
|
+
const FeeAllocationPolicy_1 = require("./FeeAllocationPolicy");
|
|
5
|
+
// Distributes a basket-level fee across marketplace line items in proportion
|
|
6
|
+
// to each line's tax-exclusive net. Lines with non-positive net are skipped
|
|
7
|
+
// so they never absorb a fee. Useful for Ribbn fees and any future
|
|
8
|
+
// marketplace fee that should follow line value rather than seller count.
|
|
9
|
+
class ProportionalToLineNetPolicy {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.basis = marketplace_constants_1.MARKETPLACE_FEE_ALLOCATION_BASES.proportionalToLineNet;
|
|
12
|
+
}
|
|
13
|
+
allocate({ totalFeeAmount, basket }) {
|
|
14
|
+
if (!Array.isArray(basket) || basket.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const safeTotal = Number(totalFeeAmount);
|
|
18
|
+
if (!Number.isFinite(safeTotal) || safeTotal <= 0) {
|
|
19
|
+
return basket.map((line) => ({ lineKey: line.lineKey, amount: 0 }));
|
|
20
|
+
}
|
|
21
|
+
const eligibleLines = basket.filter((line) => Number.isFinite(Number(line === null || line === void 0 ? void 0 : line.lineNetAmount)) && Number(line.lineNetAmount) > 0);
|
|
22
|
+
const totalEligibleNet = eligibleLines.reduce((acc, line) => acc + Number(line.lineNetAmount), 0);
|
|
23
|
+
if (totalEligibleNet <= 0) {
|
|
24
|
+
return basket.map((line) => ({ lineKey: line.lineKey, amount: 0 }));
|
|
25
|
+
}
|
|
26
|
+
const allocations = basket.map((line) => {
|
|
27
|
+
const lineNet = Number(line === null || line === void 0 ? void 0 : line.lineNetAmount);
|
|
28
|
+
const isEligible = Number.isFinite(lineNet) && lineNet > 0;
|
|
29
|
+
const share = isEligible ? lineNet / totalEligibleNet : 0;
|
|
30
|
+
return { lineKey: line.lineKey, amount: (0, FeeAllocationPolicy_1.roundFeeAmount)(safeTotal * share) };
|
|
31
|
+
});
|
|
32
|
+
return (0, FeeAllocationPolicy_1.reconcileAllocationsToTotal)(allocations, safeTotal);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = ProportionalToLineNetPolicy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InventoryAdjustmentParams, InventoryAdjustmentResult, InventoryPolicy } from './InventoryPolicy';
|
|
2
|
+
export default class UntrackedStockInventoryPolicy implements InventoryPolicy {
|
|
3
|
+
readonly kind: "UNTRACKED_STOCK";
|
|
4
|
+
canHandle(product: CompleteProduct | null | undefined): boolean;
|
|
5
|
+
decrement(_product: CompleteProduct, _params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
6
|
+
restore(_product: CompleteProduct, _params: InventoryAdjustmentParams): InventoryAdjustmentResult;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const marketplace_constants_1 = require("../../constants/marketplace-constants");
|
|
4
|
+
// Untracked-stock policy: cafe items, services, and other indefinite-stock
|
|
5
|
+
// products carry `stockStatus = IN_STOCK_UNLIMITED`. Both decrement and
|
|
6
|
+
// restore are no-ops so location counts never silently inflate or deflate.
|
|
7
|
+
class UntrackedStockInventoryPolicy {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.kind = marketplace_constants_1.MARKETPLACE_INVENTORY_POLICY_KINDS.untrackedStock;
|
|
10
|
+
}
|
|
11
|
+
canHandle(product) {
|
|
12
|
+
if (!product)
|
|
13
|
+
return false;
|
|
14
|
+
return String(product.stockStatus || '').trim() === marketplace_constants_1.STOCK_STATUSES.inStockUnlimited;
|
|
15
|
+
}
|
|
16
|
+
decrement(_product, _params) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
restore(_product, _params) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = UntrackedStockInventoryPolicy;
|
package/lib/index.d.ts
CHANGED
|
@@ -38,7 +38,24 @@ import WebhookFormState from './form-states/Merchant/WebhookFormState';
|
|
|
38
38
|
import MerchantConfigAutomatedPayouts from './models/MerchantConfigAutomatedPayouts';
|
|
39
39
|
import MerchantConfigAutomatedPayoutsFormState from './form-states/Merchant/MerchantConfigAutomatedPayoutsFormState';
|
|
40
40
|
import ReRobeProductHelpers from './helpers/ReRobeProductHelpers';
|
|
41
|
+
import MarketplaceProductHelpers from './helpers/MarketplaceProductHelpers';
|
|
41
42
|
import AnalyticsHelpers from './helpers/AnalyticsHelpers';
|
|
42
43
|
import OrderHelpers from './helpers/OrderHelpers';
|
|
43
44
|
import { DEFAULT_MARKETPLACE_SELLER_CAPABILITIES, MARKETPLACE_SELLER_CAPABILITIES, MERCHANT_ACCOUNT_CLASSES, MERCHANT_ACCOUNT_MODES, MERCHANT_RELATIONSHIP_TYPES } from './constants/merchant-constants';
|
|
44
|
-
|
|
45
|
+
import { DEFAULT_MARKETPLACE_COMMISSION_BASIS, DEFAULT_MARKETPLACE_LEDGER_STATUS, DEFAULT_MARKETPLACE_LISTING_STATUS, DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE, DEFAULT_RIBBN_FEE_ALLOCATION_BASIS, DEFAULT_STRIPE_FEE_ALLOCATION_BASIS, MARKETPLACE_COMMISSION_BASES, MARKETPLACE_FEE_ALLOCATION_BASES, MARKETPLACE_FEE_TYPES, MARKETPLACE_INVENTORY_POLICY_KINDS, MARKETPLACE_LEDGER_STATUSES, MARKETPLACE_LISTING_STATUSES, MARKETPLACE_RELATIONSHIP_TYPES, MARKETPLACE_SELLER_DEFAULT_COMMISSION, STOCK_STATUSES } from './constants/marketplace-constants';
|
|
46
|
+
import * as MarketplaceLedgerHelpers from './helpers/marketplace/MarketplaceLedgerHelpers';
|
|
47
|
+
import * as MarketplaceLegacyAdapters from './helpers/marketplace/MarketplaceLegacyAdapters';
|
|
48
|
+
import * as MarketplaceLineDisplayHelpers from './helpers/marketplace/MarketplaceLineDisplayHelpers';
|
|
49
|
+
import * as MarketplaceOrderHelpers from './helpers/marketplace/MarketplaceOrderHelpers';
|
|
50
|
+
import TaxHelpers from './helpers/TaxHelpers';
|
|
51
|
+
import PricingHelpers from './helpers/PricingHelpers';
|
|
52
|
+
import ProductSkuHelpers, { DEFAULT_SKU_LENGTH, SKU_ALPHABET } from './helpers/ProductSkuHelpers';
|
|
53
|
+
import ProductInventoryHelpers, { PLACEHOLDER_VARIANT_ID } from './helpers/ProductInventoryHelpers';
|
|
54
|
+
import RetailProductFactory from './factories/Product/RetailProductFactory';
|
|
55
|
+
import { FALLBACK_TAX_COUNTRY_CODE, TAX_CATEGORIES, TAX_CATEGORY_ALIASES, TAX_CATEGORY_BASE_LABELS, TAX_CATEGORY_RATES } from './constants/tax-constants';
|
|
56
|
+
import { ADMIN_SIMPLIFIED_STATES, ADMIN_STATES, PRODUCT_CLASS_VALUES, PRODUCT_STATES, PRODUCT_STATE_LABELS, RETAIL_EDITABLE_PRODUCT_STATES, getProductStateLabel, getRetailEditableProductStateOptions } from './constants/product-constants';
|
|
57
|
+
export { RibbnFile, ProductFromAlgoliaJSONDoc, ProductFromShopifyWebhookJSONDoc, ProductFromShopifyJSClientJSONDoc, ProductFormStateFactory, ProductCollectionFormStateFactory, ProductCollectionHelpers, SellRequestFormStateFactory, PickUpFormStateFactory, AddressFormStateFactory, UserFormStateFactory, UserFromShopifyWebhookJSONDoc, UserFromAuthTemplateMethod, DraftOrderFromMirakl, DraftOrderFromApp, ChatRoomFromNewUserSignUp, KlarnaSessionFactory, Product, ProductStateManager, Order, OrderFromShopifyWebhook, OrderFromShopifyAdminApi, OrderFromShopifyStorefrontApi, OrderFromApp, OrderFromTraderaEmail, OrderFormStateFactory, RefundFormStateFactory, PayoutAccount, PayoutAccountFormState, Merchant, MERCHANT_ACCOUNT_MODES, MERCHANT_ACCOUNT_CLASSES, MERCHANT_RELATIONSHIP_TYPES, MARKETPLACE_SELLER_CAPABILITIES, DEFAULT_MARKETPLACE_SELLER_CAPABILITIES, MerchantFormState, MerchantFormStateFactory, MerchantConfigAutomatedPayouts, MerchantConfigAutomatedPayoutsFormState, ReRobeProductHelpers, MarketplaceProductHelpers, MarketplaceLedgerHelpers, MarketplaceLegacyAdapters, MarketplaceLineDisplayHelpers, MarketplaceOrderHelpers, MARKETPLACE_LISTING_STATUSES, MARKETPLACE_COMMISSION_BASES, MARKETPLACE_RELATIONSHIP_TYPES, MARKETPLACE_FEE_TYPES, MARKETPLACE_FEE_ALLOCATION_BASES, MARKETPLACE_LEDGER_STATUSES, MARKETPLACE_INVENTORY_POLICY_KINDS, MARKETPLACE_SELLER_DEFAULT_COMMISSION, STOCK_STATUSES, DEFAULT_MARKETPLACE_LISTING_STATUS, DEFAULT_MARKETPLACE_COMMISSION_BASIS, DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE, DEFAULT_STRIPE_FEE_ALLOCATION_BASIS, DEFAULT_RIBBN_FEE_ALLOCATION_BASIS, DEFAULT_MARKETPLACE_LEDGER_STATUS, User, AnalyticsHelpers, OrderHelpers, WebhookFormState, MerchantWebPage, ShopifyMerchantAccount, CustomerNotification, TaxHelpers, PricingHelpers, ProductSkuHelpers, ProductInventoryHelpers, RetailProductFactory, SKU_ALPHABET, DEFAULT_SKU_LENGTH, PLACEHOLDER_VARIANT_ID, TAX_CATEGORIES, TAX_CATEGORY_RATES, TAX_CATEGORY_BASE_LABELS, TAX_CATEGORY_ALIASES, FALLBACK_TAX_COUNTRY_CODE, PRODUCT_STATES, PRODUCT_STATE_LABELS, PRODUCT_CLASS_VALUES, ADMIN_STATES, ADMIN_SIMPLIFIED_STATES, RETAIL_EDITABLE_PRODUCT_STATES, getProductStateLabel, getRetailEditableProductStateOptions, };
|
|
58
|
+
export type { PlaceholderVariantInput, PlaceholderVariantInventory, PlaceholderVariantLocation, } from './helpers/ProductInventoryHelpers';
|
|
59
|
+
export type { RetailOwnershipInput, RetailAccountingInput, RetailLocationInput, ClothingDetailsInput, NonClothingDetailsInput, OneOfAKindClothingInput, MultivariantClothingInput, TrackedRetailInput, UntrackedRetailInput, } from './factories/Product/RetailProductFactory';
|
|
60
|
+
export type { TaxCategoryValue } from './constants/tax-constants';
|
|
61
|
+
export type { CatalogRateInput, FrozenRateInput, IsTaxableValue, OrderLinePricing, OrderLinePricingLike, ProductPricing, ProductPricingLike, RateInput, TaxCategoryOption, TaxResolution, VariantPricing, VariantPricingLike, } from './types/pricing-types';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MARKETPLACE_FEE_ALLOCATION_BASES = exports.MARKETPLACE_FEE_TYPES = exports.MARKETPLACE_RELATIONSHIP_TYPES = exports.MARKETPLACE_COMMISSION_BASES = exports.MARKETPLACE_LISTING_STATUSES = exports.MarketplaceOrderHelpers = exports.MarketplaceLineDisplayHelpers = exports.MarketplaceLegacyAdapters = exports.MarketplaceLedgerHelpers = exports.MarketplaceProductHelpers = exports.ReRobeProductHelpers = exports.MerchantConfigAutomatedPayoutsFormState = exports.MerchantConfigAutomatedPayouts = exports.MerchantFormStateFactory = exports.MerchantFormState = exports.DEFAULT_MARKETPLACE_SELLER_CAPABILITIES = exports.MARKETPLACE_SELLER_CAPABILITIES = exports.MERCHANT_RELATIONSHIP_TYPES = exports.MERCHANT_ACCOUNT_CLASSES = exports.MERCHANT_ACCOUNT_MODES = exports.Merchant = exports.PayoutAccountFormState = exports.PayoutAccount = exports.RefundFormStateFactory = exports.OrderFormStateFactory = exports.OrderFromTraderaEmail = exports.OrderFromApp = exports.OrderFromShopifyStorefrontApi = exports.OrderFromShopifyAdminApi = exports.OrderFromShopifyWebhook = exports.Order = exports.ProductStateManager = exports.Product = exports.KlarnaSessionFactory = exports.ChatRoomFromNewUserSignUp = exports.DraftOrderFromApp = exports.DraftOrderFromMirakl = exports.UserFromAuthTemplateMethod = exports.UserFromShopifyWebhookJSONDoc = exports.UserFormStateFactory = exports.AddressFormStateFactory = exports.PickUpFormStateFactory = exports.SellRequestFormStateFactory = exports.ProductCollectionHelpers = exports.ProductCollectionFormStateFactory = exports.ProductFormStateFactory = exports.ProductFromShopifyJSClientJSONDoc = exports.ProductFromShopifyWebhookJSONDoc = exports.ProductFromAlgoliaJSONDoc = exports.RibbnFile = void 0;
|
|
4
|
+
exports.getRetailEditableProductStateOptions = exports.getProductStateLabel = exports.RETAIL_EDITABLE_PRODUCT_STATES = exports.ADMIN_SIMPLIFIED_STATES = exports.ADMIN_STATES = exports.PRODUCT_CLASS_VALUES = exports.PRODUCT_STATE_LABELS = exports.PRODUCT_STATES = exports.FALLBACK_TAX_COUNTRY_CODE = exports.TAX_CATEGORY_ALIASES = exports.TAX_CATEGORY_BASE_LABELS = exports.TAX_CATEGORY_RATES = exports.TAX_CATEGORIES = exports.PLACEHOLDER_VARIANT_ID = exports.DEFAULT_SKU_LENGTH = exports.SKU_ALPHABET = exports.RetailProductFactory = exports.ProductInventoryHelpers = exports.ProductSkuHelpers = exports.PricingHelpers = exports.TaxHelpers = exports.CustomerNotification = exports.ShopifyMerchantAccount = exports.MerchantWebPage = exports.WebhookFormState = exports.OrderHelpers = exports.AnalyticsHelpers = exports.User = exports.DEFAULT_MARKETPLACE_LEDGER_STATUS = exports.DEFAULT_RIBBN_FEE_ALLOCATION_BASIS = exports.DEFAULT_STRIPE_FEE_ALLOCATION_BASIS = exports.DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE = exports.DEFAULT_MARKETPLACE_COMMISSION_BASIS = exports.DEFAULT_MARKETPLACE_LISTING_STATUS = exports.STOCK_STATUSES = exports.MARKETPLACE_SELLER_DEFAULT_COMMISSION = exports.MARKETPLACE_INVENTORY_POLICY_KINDS = exports.MARKETPLACE_LEDGER_STATUSES = void 0;
|
|
4
5
|
const ProductFromShopifyJSClientJSONDoc_1 = require("./factories/Product/ProductFromShopifyJSClientJSONDoc");
|
|
5
6
|
exports.ProductFromShopifyJSClientJSONDoc = ProductFromShopifyJSClientJSONDoc_1.default;
|
|
6
7
|
const ProductFromAlgoliaJSONDoc_1 = require("./factories/Product/ProductFromAlgoliaJSONDoc");
|
|
@@ -81,6 +82,8 @@ const MerchantConfigAutomatedPayoutsFormState_1 = require("./form-states/Merchan
|
|
|
81
82
|
exports.MerchantConfigAutomatedPayoutsFormState = MerchantConfigAutomatedPayoutsFormState_1.default;
|
|
82
83
|
const ReRobeProductHelpers_1 = require("./helpers/ReRobeProductHelpers");
|
|
83
84
|
exports.ReRobeProductHelpers = ReRobeProductHelpers_1.default;
|
|
85
|
+
const MarketplaceProductHelpers_1 = require("./helpers/MarketplaceProductHelpers");
|
|
86
|
+
exports.MarketplaceProductHelpers = MarketplaceProductHelpers_1.default;
|
|
84
87
|
const AnalyticsHelpers_1 = require("./helpers/AnalyticsHelpers");
|
|
85
88
|
exports.AnalyticsHelpers = AnalyticsHelpers_1.default;
|
|
86
89
|
const OrderHelpers_1 = require("./helpers/OrderHelpers");
|
|
@@ -91,3 +94,55 @@ Object.defineProperty(exports, "MARKETPLACE_SELLER_CAPABILITIES", { enumerable:
|
|
|
91
94
|
Object.defineProperty(exports, "MERCHANT_ACCOUNT_CLASSES", { enumerable: true, get: function () { return merchant_constants_1.MERCHANT_ACCOUNT_CLASSES; } });
|
|
92
95
|
Object.defineProperty(exports, "MERCHANT_ACCOUNT_MODES", { enumerable: true, get: function () { return merchant_constants_1.MERCHANT_ACCOUNT_MODES; } });
|
|
93
96
|
Object.defineProperty(exports, "MERCHANT_RELATIONSHIP_TYPES", { enumerable: true, get: function () { return merchant_constants_1.MERCHANT_RELATIONSHIP_TYPES; } });
|
|
97
|
+
const marketplace_constants_1 = require("./constants/marketplace-constants");
|
|
98
|
+
Object.defineProperty(exports, "DEFAULT_MARKETPLACE_COMMISSION_BASIS", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_MARKETPLACE_COMMISSION_BASIS; } });
|
|
99
|
+
Object.defineProperty(exports, "DEFAULT_MARKETPLACE_LEDGER_STATUS", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_MARKETPLACE_LEDGER_STATUS; } });
|
|
100
|
+
Object.defineProperty(exports, "DEFAULT_MARKETPLACE_LISTING_STATUS", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_MARKETPLACE_LISTING_STATUS; } });
|
|
101
|
+
Object.defineProperty(exports, "DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_MARKETPLACE_RELATIONSHIP_TYPE; } });
|
|
102
|
+
Object.defineProperty(exports, "DEFAULT_RIBBN_FEE_ALLOCATION_BASIS", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_RIBBN_FEE_ALLOCATION_BASIS; } });
|
|
103
|
+
Object.defineProperty(exports, "DEFAULT_STRIPE_FEE_ALLOCATION_BASIS", { enumerable: true, get: function () { return marketplace_constants_1.DEFAULT_STRIPE_FEE_ALLOCATION_BASIS; } });
|
|
104
|
+
Object.defineProperty(exports, "MARKETPLACE_COMMISSION_BASES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_COMMISSION_BASES; } });
|
|
105
|
+
Object.defineProperty(exports, "MARKETPLACE_FEE_ALLOCATION_BASES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_FEE_ALLOCATION_BASES; } });
|
|
106
|
+
Object.defineProperty(exports, "MARKETPLACE_FEE_TYPES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_FEE_TYPES; } });
|
|
107
|
+
Object.defineProperty(exports, "MARKETPLACE_INVENTORY_POLICY_KINDS", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_INVENTORY_POLICY_KINDS; } });
|
|
108
|
+
Object.defineProperty(exports, "MARKETPLACE_LEDGER_STATUSES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_LEDGER_STATUSES; } });
|
|
109
|
+
Object.defineProperty(exports, "MARKETPLACE_LISTING_STATUSES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_LISTING_STATUSES; } });
|
|
110
|
+
Object.defineProperty(exports, "MARKETPLACE_RELATIONSHIP_TYPES", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_RELATIONSHIP_TYPES; } });
|
|
111
|
+
Object.defineProperty(exports, "MARKETPLACE_SELLER_DEFAULT_COMMISSION", { enumerable: true, get: function () { return marketplace_constants_1.MARKETPLACE_SELLER_DEFAULT_COMMISSION; } });
|
|
112
|
+
Object.defineProperty(exports, "STOCK_STATUSES", { enumerable: true, get: function () { return marketplace_constants_1.STOCK_STATUSES; } });
|
|
113
|
+
const MarketplaceLedgerHelpers = require("./helpers/marketplace/MarketplaceLedgerHelpers");
|
|
114
|
+
exports.MarketplaceLedgerHelpers = MarketplaceLedgerHelpers;
|
|
115
|
+
const MarketplaceLegacyAdapters = require("./helpers/marketplace/MarketplaceLegacyAdapters");
|
|
116
|
+
exports.MarketplaceLegacyAdapters = MarketplaceLegacyAdapters;
|
|
117
|
+
const MarketplaceLineDisplayHelpers = require("./helpers/marketplace/MarketplaceLineDisplayHelpers");
|
|
118
|
+
exports.MarketplaceLineDisplayHelpers = MarketplaceLineDisplayHelpers;
|
|
119
|
+
const MarketplaceOrderHelpers = require("./helpers/marketplace/MarketplaceOrderHelpers");
|
|
120
|
+
exports.MarketplaceOrderHelpers = MarketplaceOrderHelpers;
|
|
121
|
+
const TaxHelpers_1 = require("./helpers/TaxHelpers");
|
|
122
|
+
exports.TaxHelpers = TaxHelpers_1.default;
|
|
123
|
+
const PricingHelpers_1 = require("./helpers/PricingHelpers");
|
|
124
|
+
exports.PricingHelpers = PricingHelpers_1.default;
|
|
125
|
+
const ProductSkuHelpers_1 = require("./helpers/ProductSkuHelpers");
|
|
126
|
+
exports.ProductSkuHelpers = ProductSkuHelpers_1.default;
|
|
127
|
+
Object.defineProperty(exports, "DEFAULT_SKU_LENGTH", { enumerable: true, get: function () { return ProductSkuHelpers_1.DEFAULT_SKU_LENGTH; } });
|
|
128
|
+
Object.defineProperty(exports, "SKU_ALPHABET", { enumerable: true, get: function () { return ProductSkuHelpers_1.SKU_ALPHABET; } });
|
|
129
|
+
const ProductInventoryHelpers_1 = require("./helpers/ProductInventoryHelpers");
|
|
130
|
+
exports.ProductInventoryHelpers = ProductInventoryHelpers_1.default;
|
|
131
|
+
Object.defineProperty(exports, "PLACEHOLDER_VARIANT_ID", { enumerable: true, get: function () { return ProductInventoryHelpers_1.PLACEHOLDER_VARIANT_ID; } });
|
|
132
|
+
const RetailProductFactory_1 = require("./factories/Product/RetailProductFactory");
|
|
133
|
+
exports.RetailProductFactory = RetailProductFactory_1.default;
|
|
134
|
+
const tax_constants_1 = require("./constants/tax-constants");
|
|
135
|
+
Object.defineProperty(exports, "FALLBACK_TAX_COUNTRY_CODE", { enumerable: true, get: function () { return tax_constants_1.FALLBACK_TAX_COUNTRY_CODE; } });
|
|
136
|
+
Object.defineProperty(exports, "TAX_CATEGORIES", { enumerable: true, get: function () { return tax_constants_1.TAX_CATEGORIES; } });
|
|
137
|
+
Object.defineProperty(exports, "TAX_CATEGORY_ALIASES", { enumerable: true, get: function () { return tax_constants_1.TAX_CATEGORY_ALIASES; } });
|
|
138
|
+
Object.defineProperty(exports, "TAX_CATEGORY_BASE_LABELS", { enumerable: true, get: function () { return tax_constants_1.TAX_CATEGORY_BASE_LABELS; } });
|
|
139
|
+
Object.defineProperty(exports, "TAX_CATEGORY_RATES", { enumerable: true, get: function () { return tax_constants_1.TAX_CATEGORY_RATES; } });
|
|
140
|
+
const product_constants_1 = require("./constants/product-constants");
|
|
141
|
+
Object.defineProperty(exports, "ADMIN_SIMPLIFIED_STATES", { enumerable: true, get: function () { return product_constants_1.ADMIN_SIMPLIFIED_STATES; } });
|
|
142
|
+
Object.defineProperty(exports, "ADMIN_STATES", { enumerable: true, get: function () { return product_constants_1.ADMIN_STATES; } });
|
|
143
|
+
Object.defineProperty(exports, "PRODUCT_CLASS_VALUES", { enumerable: true, get: function () { return product_constants_1.PRODUCT_CLASS_VALUES; } });
|
|
144
|
+
Object.defineProperty(exports, "PRODUCT_STATES", { enumerable: true, get: function () { return product_constants_1.PRODUCT_STATES; } });
|
|
145
|
+
Object.defineProperty(exports, "PRODUCT_STATE_LABELS", { enumerable: true, get: function () { return product_constants_1.PRODUCT_STATE_LABELS; } });
|
|
146
|
+
Object.defineProperty(exports, "RETAIL_EDITABLE_PRODUCT_STATES", { enumerable: true, get: function () { return product_constants_1.RETAIL_EDITABLE_PRODUCT_STATES; } });
|
|
147
|
+
Object.defineProperty(exports, "getProductStateLabel", { enumerable: true, get: function () { return product_constants_1.getProductStateLabel; } });
|
|
148
|
+
Object.defineProperty(exports, "getRetailEditableProductStateOptions", { enumerable: true, get: function () { return product_constants_1.getRetailEditableProductStateOptions; } });
|
package/lib/models/Product.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Base from '../Base';
|
|
2
|
+
import { ProductPricing, TaxResolution, VariantPricing } from '../types/pricing-types';
|
|
2
3
|
export default class Product extends Base {
|
|
3
4
|
attributes: ProductAttributes;
|
|
4
5
|
filterAttributes: ProductFilterAttributes;
|
|
@@ -9,6 +10,21 @@ export default class Product extends Base {
|
|
|
9
10
|
constructor(props?: any);
|
|
10
11
|
toPartialObj(): ShopifyProduct;
|
|
11
12
|
toObj(): CompleteProduct;
|
|
13
|
+
isUntrackedStock(): boolean;
|
|
14
|
+
hasActiveMarketplaceListing(): boolean;
|
|
15
|
+
getActiveMarketplaceListings(): {
|
|
16
|
+
parentMarketplaceId: string;
|
|
17
|
+
listing: ProductMarketplaceListing;
|
|
18
|
+
}[];
|
|
19
|
+
getMarketplaceListingForParent(parentMarketplaceId: string): ProductMarketplaceListing | null;
|
|
20
|
+
isMarketplaceVisibleTo(parentMarketplaceId: string): boolean;
|
|
21
|
+
getResolvedTaxRate(countryCode: string): TaxResolution;
|
|
22
|
+
getPricing(countryCode: string): ProductPricing;
|
|
23
|
+
getVariantPricing(variantId: string, countryCode: string): VariantPricing | null;
|
|
24
|
+
getEffectiveSku(): string;
|
|
25
|
+
getEffectiveVariantSku(variantId: string): string;
|
|
26
|
+
describeVariant(variantId: string): string;
|
|
27
|
+
diagnoseVariantInventory(): 'no_variants' | 'all_zero_qty' | 'ok';
|
|
12
28
|
toProductInputObjForShopify(location?: string): any;
|
|
13
29
|
toProductInputObjForShopifyV2(locationId: string, weightUnit?: string): any[];
|
|
14
30
|
/**
|