rerobe-js-orm 4.8.4 → 4.8.5
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.MERCHANT_TYPES = void 0;
|
|
3
|
+
exports.AUTOMATED_PAYOUT_MONTH_DAYS = exports.AUTOMATED_PAYOUT_BUSINESS_DAYS = exports.AUTOMATED_PAYOUT_SCHEDULE = exports.SUBSCRIPTION_STATUSES = exports.RIBBN_WEBHOOK_EVENT_DICT = exports.IMPERIAL_WEIGHT_TYPES = exports.METRIC_WEIGHT_TYPES = exports.UNIT_SYSTEM_TYPES = exports.INDUSTRY_TYPE_OPTIONS = exports.INDUSTRY_TYPES = exports.PAYMENT_TIERS = exports.MERCHANT_TYPES = void 0;
|
|
4
4
|
exports.MERCHANT_TYPES = {
|
|
5
5
|
individual: 'INDIVIDUAL',
|
|
6
6
|
business: 'BUSINESS',
|
|
@@ -37,6 +37,17 @@ exports.INDUSTRY_TYPES = {
|
|
|
37
37
|
toys: 'TOYS',
|
|
38
38
|
other: 'OTHER',
|
|
39
39
|
};
|
|
40
|
+
exports.INDUSTRY_TYPE_OPTIONS = [
|
|
41
|
+
{ label: 'Beauty & Cosmetics', value: exports.INDUSTRY_TYPES.beauty },
|
|
42
|
+
{ label: 'Clothing & Apparel', value: exports.INDUSTRY_TYPES.clothing },
|
|
43
|
+
{ label: 'Electronics', value: exports.INDUSTRY_TYPES.electronics },
|
|
44
|
+
{ label: 'Furniture & Home', value: exports.INDUSTRY_TYPES.furniture },
|
|
45
|
+
{ label: 'Handcrafts & Artisan', value: exports.INDUSTRY_TYPES.handcrafts },
|
|
46
|
+
{ label: 'Jewelry & Watches', value: exports.INDUSTRY_TYPES.jewelry },
|
|
47
|
+
{ label: 'Sports & Outdoors', value: exports.INDUSTRY_TYPES.sports },
|
|
48
|
+
{ label: 'Toys & Games', value: exports.INDUSTRY_TYPES.toys },
|
|
49
|
+
{ label: 'Other', value: exports.INDUSTRY_TYPES.other },
|
|
50
|
+
];
|
|
40
51
|
exports.UNIT_SYSTEM_TYPES = {
|
|
41
52
|
metric: 'METRIC',
|
|
42
53
|
imperial: 'IMPERIAL',
|
package/lib/models/Product.d.ts
CHANGED
|
@@ -11,7 +11,14 @@ export default class Product extends Base {
|
|
|
11
11
|
toObj(): CompleteProduct;
|
|
12
12
|
toProductInputObjForShopify(location?: string): any;
|
|
13
13
|
toProductInputObjForShopifyV2(locationId: string, weightUnit?: string): any[];
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Builds a Shopify product input object for a product with variant inventory.
|
|
16
|
+
* @param locationsMap { RibbnLocationID => ShopifyLocation GUID } - Map of locationId to location Shopify ID
|
|
17
|
+
* @param weightUnit
|
|
18
|
+
* @param taxRate
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
toProductInputObjForShopifyV3(locationsInput: Map<string, string> | string, weightUnit?: string, taxRate?: number): {
|
|
15
22
|
productOptions: {
|
|
16
23
|
name: string;
|
|
17
24
|
values: {
|
package/lib/models/Product.js
CHANGED
|
@@ -296,8 +296,18 @@ class Product extends Base_1.default {
|
|
|
296
296
|
}
|
|
297
297
|
return [productInputObj];
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Builds a Shopify product input object for a product with variant inventory.
|
|
301
|
+
* @param locationsMap { RibbnLocationID => ShopifyLocation GUID } - Map of locationId to location Shopify ID
|
|
302
|
+
* @param weightUnit
|
|
303
|
+
* @param taxRate
|
|
304
|
+
* @returns
|
|
305
|
+
*/
|
|
306
|
+
toProductInputObjForShopifyV3(locationsInput, weightUnit, taxRate) {
|
|
300
307
|
var _a;
|
|
308
|
+
const isLegacy = typeof locationsInput === 'string';
|
|
309
|
+
const legacyGid = isLegacy ? `gid://shopify/Location/${locationsInput}` : undefined;
|
|
310
|
+
const locationsMap = isLegacy ? undefined : locationsInput;
|
|
301
311
|
const title = this.attributes.title || `Ribbn Product ${this.attributes.handle || this.filterAttributes.documentId}`;
|
|
302
312
|
const inInventoryStatuses = [
|
|
303
313
|
product_constants_1.PRODUCT_STATES.draft,
|
|
@@ -369,7 +379,7 @@ class Product extends Base_1.default {
|
|
|
369
379
|
// Fallback: single-variant product (legacy behavior)
|
|
370
380
|
const variant = Object.assign(Object.assign({ id: '' }, baseVariantFields()), { inventoryQuantities: [
|
|
371
381
|
{
|
|
372
|
-
locationId:
|
|
382
|
+
locationId: isLegacy ? legacyGid : locationsMap.get(this.consignmentAttributes.inventoryLocations[0].id),
|
|
373
383
|
name: 'available',
|
|
374
384
|
quantity: 0,
|
|
375
385
|
},
|
|
@@ -415,16 +425,24 @@ class Product extends Base_1.default {
|
|
|
415
425
|
name: String(v.options[axis] || ''),
|
|
416
426
|
}));
|
|
417
427
|
const inventoryQuantities = Array.isArray(v.locations) && v.locations.length > 0
|
|
418
|
-
?
|
|
419
|
-
|
|
420
|
-
|
|
428
|
+
? isLegacy
|
|
429
|
+
? [
|
|
430
|
+
{
|
|
431
|
+
locationId: legacyGid,
|
|
432
|
+
name: 'available',
|
|
433
|
+
quantity: (v.locations || []).reduce((acc, l) => acc + (Number(l === null || l === void 0 ? void 0 : l.availableAmount) || 0), 0),
|
|
434
|
+
},
|
|
435
|
+
]
|
|
436
|
+
: v.locations.map((location) => ({
|
|
437
|
+
locationId: locationsMap.get(location.id),
|
|
421
438
|
name: 'available',
|
|
422
|
-
quantity:
|
|
423
|
-
}
|
|
424
|
-
]
|
|
439
|
+
quantity: location.availableAmount,
|
|
440
|
+
}))
|
|
425
441
|
: [
|
|
426
442
|
{
|
|
427
|
-
locationId:
|
|
443
|
+
locationId: isLegacy
|
|
444
|
+
? legacyGid
|
|
445
|
+
: locationsMap.get(this.consignmentAttributes.inventoryLocations[0].id),
|
|
428
446
|
name: 'available',
|
|
429
447
|
quantity: inInventoryStatuses.indexOf(this.consignmentAttributes.status) !== -1 ? 1 : 0,
|
|
430
448
|
},
|