@odla-ai/chapter 0.55.0 → 0.56.1

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
@@ -841,6 +841,7 @@ var subscriptionCheckoutIntentsEntity = {
841
841
  interval: attr5("string", { indexed: true }),
842
842
  billingTerms: attr5("json", { optional: true }),
843
843
  paymentQuote: attr5("json", { optional: true }),
844
+ paymentReceipt: attr5("json", { optional: true }),
844
845
  membershipOffer: attr5("json", { optional: true }),
845
846
  purchaserEmailNormalized: attr5("string", { indexed: true }),
846
847
  requestedCustomerId: attr5("string", { indexed: true, optional: true }),
@@ -3410,7 +3411,7 @@ function findTier(tiers2, tierId) {
3410
3411
  if (!tierId) return tiers2.length === 1 ? tiers2[0] : null;
3411
3412
  return tiers2.find((tier) => tier.id === tierId) ?? null;
3412
3413
  }
3413
- function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new Map()) {
3414
+ function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new Map(), seats = /* @__PURE__ */ new Map()) {
3414
3415
  return tiers2.map((tier) => ({
3415
3416
  id: tier.id,
3416
3417
  name: tier.name,
@@ -3419,7 +3420,8 @@ function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new M
3419
3420
  interval: tier.interval ?? defaults.interval ?? "year",
3420
3421
  blurb: tier.blurb ?? "",
3421
3422
  free: tierIsFree(tier),
3422
- ...founding.has(tier.id) ? { founding: founding.get(tier.id) } : {}
3423
+ ...founding.has(tier.id) ? { founding: founding.get(tier.id) } : {},
3424
+ ...seats.has(tier.id) ? { seatOffer: seats.get(tier.id) } : {}
3423
3425
  }));
3424
3426
  }
3425
3427
 
@@ -3773,6 +3775,7 @@ async function previewMembershipCommercialOffer(db, input) {
3773
3775
  ...contract.founding && contract.discountPolicy ? { cohortLabel: contract.discountPolicy.cohortLabel } : {},
3774
3776
  dueTodayCents: contract.dueTodayCents,
3775
3777
  renewalCents: contract.renewalCents,
3778
+ ...offering.seatPriceCents !== void 0 ? { seatPriceCents: offering.seatPriceCents } : {},
3776
3779
  ...discount ? { discountDuration: discount.duration === "once" ? "first_term" : "while_active" } : {},
3777
3780
  ...contract.initialTermEndsAt !== void 0 ? { initialTermEndsAt: contract.initialTermEndsAt } : {}
3778
3781
  };
@@ -6138,7 +6141,7 @@ async function requestMembershipCommercialOffer(options) {
6138
6141
  async function requestMembershipOfferPreview(options) {
6139
6142
  const result = await requestAuthority(options, "offer-preview", { skuId: options.skuId });
6140
6143
  const preview = result.preview;
6141
- if (!preview || preview.skuId !== options.skuId || typeof preview.founding !== "boolean" || !Number.isSafeInteger(preview.basePriceCents) || !Number.isSafeInteger(preview.dueTodayCents) || preview.dueTodayCents < 0 || preview.dueTodayCents > preview.basePriceCents || !Number.isSafeInteger(preview.renewalCents) || !/^[a-z]{3}$/.test(preview.currency) || !["month", "year"].includes(preview.interval) || preview.cohortLabel !== void 0 && typeof preview.cohortLabel !== "string" || preview.discountDuration !== void 0 && !["first_term", "while_active"].includes(preview.discountDuration)) throw new Error("invalid offer preview");
6144
+ if (!preview || preview.skuId !== options.skuId || typeof preview.founding !== "boolean" || !Number.isSafeInteger(preview.basePriceCents) || !Number.isSafeInteger(preview.dueTodayCents) || preview.dueTodayCents < 0 || preview.dueTodayCents > preview.basePriceCents || !Number.isSafeInteger(preview.renewalCents) || !/^[a-z]{3}$/.test(preview.currency) || !["month", "year"].includes(preview.interval) || preview.cohortLabel !== void 0 && typeof preview.cohortLabel !== "string" || preview.seatPriceCents !== void 0 && (!Number.isSafeInteger(preview.seatPriceCents) || preview.seatPriceCents < 0) || preview.discountDuration !== void 0 && !["first_term", "while_active"].includes(preview.discountDuration)) throw new Error("invalid offer preview");
6142
6145
  return preview;
6143
6146
  }
6144
6147
  async function requestMembershipCheckoutBinding(options) {
@@ -7421,7 +7424,7 @@ async function frozenCheckoutVariables(db, app) {
7421
7424
  const intent = (await db.query({ subscriptionCheckoutIntents: { $: { where: { id: String(app.id) }, limit: 1 } } })).subscriptionCheckoutIntents?.[0];
7422
7425
  const offer = intent?.membershipOffer, contract = offer?.contract;
7423
7426
  const offering = contract?.offering, quote = intent?.paymentQuote;
7424
- const amount = contract?.dueTodayCents ?? intent?.priceCents;
7427
+ const amount = quote?.lineItems?.dueTodayCents ?? contract?.dueTodayCents ?? intent?.priceCents;
7425
7428
  const currency = offering?.currency ?? intent?.currency;
7426
7429
  let formatted = "";
7427
7430
  if (Number.isSafeInteger(amount) && Number(amount) > 0 && typeof currency === "string" && /^[a-z]{3}$/.test(currency)) {