rerobe-js-orm 4.9.3 → 4.9.4

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.
@@ -35,6 +35,15 @@ export default class Product extends Base {
35
35
  }): {
36
36
  [k: string]: any;
37
37
  };
38
+ buildQuantityCloneData({ price, imageUrls, overrides, }?: {
39
+ price?: string | number;
40
+ imageUrls?: string[];
41
+ overrides?: {
42
+ [k: string]: any;
43
+ };
44
+ }): {
45
+ [k: string]: any;
46
+ };
38
47
  diagnoseVariantInventory(): 'no_variants' | 'all_zero_qty' | 'ok';
39
48
  toProductInputObjForShopify(location?: string): any;
40
49
  toProductInputObjForShopifyV2(locationId: string, weightUnit?: string): any[];
@@ -289,6 +289,32 @@ class Product extends Base_1.default {
289
289
  // immediately, mid-checkout.
290
290
  createdAt: null, createdAtTimestamp: null, bookedTimestamp: null, openTimestamp: null }), overrides);
291
291
  }
292
+ // Build the data for ONE concrete, single-unit clone of a multi-quantity
293
+ // product that has NO variant axes — tracked retail, SUPPLY, and
294
+ // always-in-stock ("non-clothing") items. The sibling of
295
+ // buildVariantCloneData: same UNIQUE, hidden-until-sold, born-now sold-unit
296
+ // shape, but carries no variant options. Back-linked to the stock-holding
297
+ // parent (via originalVariantProductId) so the parent's inventoryLocations are
298
+ // decremented at sale time while the parent itself stays LISTED. Tagged
299
+ // `quantityClone` so the sold/inventory pipeline routes it to the parent's
300
+ // inventoryLocations (not variantInventory).
301
+ //
302
+ // Pure: returns the clone's data object. The caller assigns a documentId and
303
+ // persists it (N copies for quantity > 1).
304
+ buildQuantityCloneData({ price = '', imageUrls = [], overrides = {}, } = {}) {
305
+ const parent = this.toObj();
306
+ const resolvedPrice = price || parent.price || '0';
307
+ const resolvedImageUrls = Array.isArray(imageUrls) && imageUrls.length ? imageUrls : parent.imageUrls || [];
308
+ const systemTags = Array.isArray(parent.systemTags)
309
+ ? parent.systemTags.filter((tag) => tag !== 'templateProduct')
310
+ : [];
311
+ return Object.assign(Object.assign(Object.assign({}, parent), { productClass: product_constants_1.PRODUCT_CLASS_VALUES.UNIQUE, variantInventory: [], status: product_constants_1.PRODUCT_STATES.hidden, systemTags: [...new Set([...systemTags, 'clonedProduct', 'quantityClone'])], price: String(resolvedPrice), imageUrls: resolvedImageUrls,
312
+ // Back-link to the stock-holding parent (decremented on sale). No variant.
313
+ originalVariantProductId: parent.documentId || '', chosenVariantId: '', chosenVariantSku: parent.sku || '',
314
+ // Born now (see buildVariantCloneData) so the reaper measures the clone's
315
+ // age, not the parent's.
316
+ createdAt: null, createdAtTimestamp: null, bookedTimestamp: null, openTimestamp: null }), overrides);
317
+ }
292
318
  // Diagnose whether a variant-inventory product is purchasable. Mirrors
293
319
  // the readiness gate the retail entry exposes as a confirm-before-save
294
320
  // dialog: a multivariant product with no variants generated yet, or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rerobe-js-orm",
3
- "version": "4.9.3",
3
+ "version": "4.9.4",
4
4
  "description": "ReRobe's Javascript ORM Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",