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.
@@ -44,6 +44,10 @@ export namespace INDUSTRY_TYPES {
44
44
  let toys: string;
45
45
  let other: string;
46
46
  }
47
+ export const INDUSTRY_TYPE_OPTIONS: {
48
+ label: string;
49
+ value: string;
50
+ }[];
47
51
  export namespace UNIT_SYSTEM_TYPES {
48
52
  let metric: string;
49
53
  let imperial: string;
@@ -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',
@@ -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
- toProductInputObjForShopifyV3(locationId: string, weightUnit?: string, taxRate?: number): {
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: {
@@ -296,8 +296,18 @@ class Product extends Base_1.default {
296
296
  }
297
297
  return [productInputObj];
298
298
  }
299
- toProductInputObjForShopifyV3(locationId, weightUnit, taxRate) {
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: `gid://shopify/Location/${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
- locationId: `gid://shopify/Location/${locationId}`,
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: (v.locations || []).reduce((acc, l) => acc + (Number(l === null || l === void 0 ? void 0 : l.availableAmount) || 0), 0),
423
- },
424
- ]
439
+ quantity: location.availableAmount,
440
+ }))
425
441
  : [
426
442
  {
427
- locationId: `gid://shopify/Location/${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
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.8.4",
3
+ "version": "4.8.5",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",