@odla-ai/chapter 0.52.0 → 0.53.0

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
@@ -155,6 +155,7 @@ __export(src_exports, {
155
155
  membershipAuthorityEntities: () => membershipAuthorityEntities,
156
156
  membershipAuthorityRules: () => membershipAuthorityRules,
157
157
  membershipCheckoutBindingId: () => membershipCheckoutBindingId,
158
+ membershipDiscountCouponId: () => membershipDiscountCouponId,
158
159
  membershipDiscountPolicyVersion: () => membershipDiscountPolicyVersion,
159
160
  membershipOfferEntities: () => membershipOfferEntities,
160
161
  membershipOfferIdForRequest: () => membershipOfferIdForRequest,
@@ -1838,7 +1839,9 @@ var DEFAULT_JOIN_COPY = {
1838
1839
  incomplete: "The payment did not complete. Please try again.",
1839
1840
  consent: "I have read and agree to the pricing and refund policy above.",
1840
1841
  foundingMember: "Founding member rate",
1841
- foundingDiscount: "Founding discount"
1842
+ foundingDiscount: "Founding discount",
1843
+ standardRate: "Standard rate",
1844
+ yourRate: "Your rate"
1842
1845
  },
1843
1846
  done: {
1844
1847
  label: "You're booked",
@@ -3692,7 +3695,7 @@ async function hash(value) {
3692
3695
  const bytes = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(value)));
3693
3696
  return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
3694
3697
  }
3695
- async function couponId(input, policyId) {
3698
+ async function membershipDiscountCouponId(input, policyId) {
3696
3699
  return policyId ? `odla_m_${await hash([input.appId, input.chapterId, input.environment, input.runtime, input.skuId, policyId])}` : void 0;
3697
3700
  }
3698
3701
  async function load(db, ns, id10) {
@@ -3718,7 +3721,7 @@ async function restore(row2, input) {
3718
3721
  discountPolicy: contract.discountPolicy,
3719
3722
  approvedFoundingCount: Number(row2.approvedFoundingCount),
3720
3723
  now: Number(row2.issuedAt),
3721
- couponId: await couponId(input, contract.discountPolicy?.id)
3724
+ couponId: await membershipDiscountCouponId(input, contract.discountPolicy?.id)
3722
3725
  });
3723
3726
  if (expected.offering.chapterId !== input.chapterId || expected.offering.baseSkuId !== input.skuId) reject("invalid_offer_snapshot");
3724
3727
  const result = {
@@ -3749,7 +3752,7 @@ async function previewMembershipCommercialOffer(db, input) {
3749
3752
  discountPolicy: policy,
3750
3753
  approvedFoundingCount: Number(approvedFoundingCount),
3751
3754
  now: input.now,
3752
- couponId: await couponId(input, policy?.id)
3755
+ couponId: await membershipDiscountCouponId(input, policy?.id)
3753
3756
  });
3754
3757
  const discount = contract.billingTerms.discount;
3755
3758
  return {
@@ -3799,7 +3802,7 @@ async function issueMembershipCommercialOffer(db, input) {
3799
3802
  discountPolicy: policy,
3800
3803
  approvedFoundingCount: Number(approvedFoundingCount),
3801
3804
  now: input.now,
3802
- couponId: await couponId(input, policy?.id)
3805
+ couponId: await membershipDiscountCouponId(input, policy?.id)
3803
3806
  });
3804
3807
  const value = {
3805
3808
  id: input.offerId,
@@ -4847,9 +4850,9 @@ async function subscriptionForSeat(sk, seat) {
4847
4850
  if (!Array.isArray(discounts) || discounts.length > 5) reject3();
4848
4851
  for (const discount of discounts) {
4849
4852
  const couponRef = discount.source?.coupon ?? discount.coupon;
4850
- const couponId2 = typeof couponRef === "string" ? couponRef : couponRef?.id;
4851
- if (!couponId2 || typeof couponId2 !== "string") reject3();
4852
- const coupon = await read(sk, `/v1/coupons/${encodeURIComponent(couponId2)}`, { "expand[0]": "applies_to" });
4853
+ const couponId = typeof couponRef === "string" ? couponRef : couponRef?.id;
4854
+ if (!couponId || typeof couponId !== "string") reject3();
4855
+ const coupon = await read(sk, `/v1/coupons/${encodeURIComponent(couponId)}`, { "expand[0]": "applies_to" });
4853
4856
  if (coupon.livemode !== (seat.environment === "prod") || !Array.isArray(coupon.applies_to?.products) || coupon.applies_to.products.length !== 1 || coupon.applies_to.products[0] !== primary.price.product) reject3();
4854
4857
  }
4855
4858
  return sub;