@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.js CHANGED
@@ -110,6 +110,9 @@ function quantifiable(itemSchema) {
110
110
  quantity: z.number()
111
111
  });
112
112
  }
113
+ function singleOrMultiple(schema) {
114
+ return z.union([schema, z.array(schema)]);
115
+ }
113
116
 
114
117
  // src/inventory/products/schemas.ts
115
118
  var schemas_exports = {};
@@ -207,7 +210,7 @@ var cartContainsItemsConditionSchema = z3.object({
207
210
  var offerConditionSchema = z3.discriminatedUnion("type", [cartContainsItemsConditionSchema]);
208
211
  var storefrontOfferSchema = z3.object({
209
212
  id: z3.string(),
210
- target: z3.union([storefrontProductSchema, storefrontBundleSchema]),
213
+ target: singleOrMultiple(z3.union([storefrontProductSchema, storefrontBundleSchema])),
211
214
  targetVariations: z3.string().array(),
212
215
  condition: offerConditionSchema,
213
216
  discount: discountSchema
@@ -532,6 +535,7 @@ import { z as z9 } from "zod";
532
535
  var schemas_exports5 = {};
533
536
  __export(schemas_exports5, {
534
537
  activationSchema: () => activationSchema,
538
+ externalLicenseContent: () => externalLicenseContent,
535
539
  licenseSchema: () => licenseSchema
536
540
  });
537
541
  import { z as z8 } from "zod";
@@ -554,13 +558,22 @@ var ActivationMethod = /* @__PURE__ */ ((ActivationMethod2) => {
554
558
  })(ActivationMethod || {});
555
559
 
556
560
  // src/inventory/licenses/schemas.ts
561
+ var externalLicenseFileContent = z8.object({
562
+ fileName: z8.string(),
563
+ contentType: z8.string(),
564
+ data: z8.string()
565
+ });
566
+ var externalLicenseContent = z8.union([
567
+ z8.string(),
568
+ externalLicenseFileContent
569
+ ]);
557
570
  var licenseSchema = z8.object({
558
571
  id: z8.string(),
559
572
  status: z8.nativeEnum(LicenseStatus),
560
573
  product: productSummarySchema,
561
574
  activeNumberOfActivations: z8.number(),
562
575
  maxNumberOfActivations: z8.number(),
563
- externalFulfillment: z8.string().optional(),
576
+ externalFulfillment: externalLicenseContent.optional(),
564
577
  expiresAt: z8.coerce.date().optional(),
565
578
  createdAt: z8.coerce.date()
566
579
  });
@@ -1395,7 +1408,7 @@ var MoneyCollectionUtils = class {
1395
1408
  };
1396
1409
 
1397
1410
  // src/utils/offer.ts
1398
- var OfferUtils = class {
1411
+ var OfferUtils = class _OfferUtils {
1399
1412
  static eligible(offer, order) {
1400
1413
  switch (offer.condition.type) {
1401
1414
  case "CartContainsItems":
@@ -1404,7 +1417,7 @@ var OfferUtils = class {
1404
1417
  );
1405
1418
  const relevantReplacedItems = order.items.flatMap((i) => {
1406
1419
  var _a;
1407
- return i.type === "Bundle" && offer.target.type === "Bundle" && offer.target.id === i.bundleId && offer.id === i.offerId ? (_a = i.replaced) != null ? _a : [] : [];
1420
+ return offer.id === i.offerId && i.type === "Bundle" && _OfferUtils.targetContainsBundle(offer, i.id) ? (_a = i.replaced) != null ? _a : [] : [];
1408
1421
  }).filter((ref) => {
1409
1422
  const [productId, variationId] = ref.split("/");
1410
1423
  return offer.condition.relevantItemVariations[`Product/${productId}`] && offer.condition.relevantItemVariations[`Product/${productId}`].includes(variationId);
@@ -1422,6 +1435,9 @@ var OfferUtils = class {
1422
1435
  hasDiscount: Object.values(discount).some((v) => v > 0) || variation.hasDiscount
1423
1436
  };
1424
1437
  }
1438
+ static targetContainsBundle(offer, bundleId) {
1439
+ if (Array.isArray(offer.target)) return offer.target.some((i) => i.type === "Bundle" && i.id === bundleId);
1440
+ }
1425
1441
  };
1426
1442
 
1427
1443
  // src/index.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/storefront-api",
3
3
  "type": "module",
4
- "version": "0.4.56",
4
+ "version": "0.4.58",
5
5
  "description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",