@moonbase.sh/storefront-api 0.4.56 → 0.4.58

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/dist/index.cjs CHANGED
@@ -166,6 +166,9 @@ function quantifiable(itemSchema) {
166
166
  quantity: import_zod.z.number()
167
167
  });
168
168
  }
169
+ function singleOrMultiple(schema) {
170
+ return import_zod.z.union([schema, import_zod.z.array(schema)]);
171
+ }
169
172
 
170
173
  // src/inventory/products/schemas.ts
171
174
  var schemas_exports = {};
@@ -263,7 +266,7 @@ var cartContainsItemsConditionSchema = import_zod3.z.object({
263
266
  var offerConditionSchema = import_zod3.z.discriminatedUnion("type", [cartContainsItemsConditionSchema]);
264
267
  var storefrontOfferSchema = import_zod3.z.object({
265
268
  id: import_zod3.z.string(),
266
- target: import_zod3.z.union([storefrontProductSchema, storefrontBundleSchema]),
269
+ target: singleOrMultiple(import_zod3.z.union([storefrontProductSchema, storefrontBundleSchema])),
267
270
  targetVariations: import_zod3.z.string().array(),
268
271
  condition: offerConditionSchema,
269
272
  discount: discountSchema
@@ -588,6 +591,7 @@ var import_zod9 = require("zod");
588
591
  var schemas_exports5 = {};
589
592
  __export(schemas_exports5, {
590
593
  activationSchema: () => activationSchema,
594
+ externalLicenseContent: () => externalLicenseContent,
591
595
  licenseSchema: () => licenseSchema
592
596
  });
593
597
  var import_zod8 = require("zod");
@@ -610,13 +614,22 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
610
614
  })(ActivationMethod || {});
611
615
 
612
616
  // src/inventory/licenses/schemas.ts
617
+ var externalLicenseFileContent = import_zod8.z.object({
618
+ fileName: import_zod8.z.string(),
619
+ contentType: import_zod8.z.string(),
620
+ data: import_zod8.z.string()
621
+ });
622
+ var externalLicenseContent = import_zod8.z.union([
623
+ import_zod8.z.string(),
624
+ externalLicenseFileContent
625
+ ]);
613
626
  var licenseSchema = import_zod8.z.object({
614
627
  id: import_zod8.z.string(),
615
628
  status: import_zod8.z.nativeEnum(LicenseStatus),
616
629
  product: productSummarySchema,
617
630
  activeNumberOfActivations: import_zod8.z.number(),
618
631
  maxNumberOfActivations: import_zod8.z.number(),
619
- externalFulfillment: import_zod8.z.string().optional(),
632
+ externalFulfillment: externalLicenseContent.optional(),
620
633
  expiresAt: import_zod8.z.coerce.date().optional(),
621
634
  createdAt: import_zod8.z.coerce.date()
622
635
  });
@@ -1451,7 +1464,7 @@ var MoneyCollectionUtils = class {
1451
1464
  };
1452
1465
 
1453
1466
  // src/utils/offer.ts
1454
- var OfferUtils = class {
1467
+ var OfferUtils = class _OfferUtils {
1455
1468
  static eligible(offer, order) {
1456
1469
  switch (offer.condition.type) {
1457
1470
  case "CartContainsItems":
@@ -1460,7 +1473,7 @@ var OfferUtils = class {
1460
1473
  );
1461
1474
  const relevantReplacedItems = order.items.flatMap((i) => {
1462
1475
  var _a;
1463
- return i.type === "Bundle" && offer.target.type === "Bundle" && offer.target.id === i.bundleId && offer.id === i.offerId ? (_a = i.replaced) != null ? _a : [] : [];
1476
+ return offer.id === i.offerId && i.type === "Bundle" && _OfferUtils.targetContainsBundle(offer, i.id) ? (_a = i.replaced) != null ? _a : [] : [];
1464
1477
  }).filter((ref) => {
1465
1478
  const [productId, variationId] = ref.split("/");
1466
1479
  return offer.condition.relevantItemVariations[`Product/${productId}`] && offer.condition.relevantItemVariations[`Product/${productId}`].includes(variationId);
@@ -1478,6 +1491,9 @@ var OfferUtils = class {
1478
1491
  hasDiscount: Object.values(discount).some((v) => v > 0) || variation.hasDiscount
1479
1492
  };
1480
1493
  }
1494
+ static targetContainsBundle(offer, bundleId) {
1495
+ if (Array.isArray(offer.target)) return offer.target.some((i) => i.type === "Bundle" && i.id === bundleId);
1496
+ }
1481
1497
  };
1482
1498
 
1483
1499
  // src/index.ts