@odla-ai/chapter 0.52.1 → 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/README.md +17 -0
- package/dist/{chunk-WWF2TO3H.js → chunk-PTC43J7F.js} +39 -5
- package/dist/{chunk-WWF2TO3H.js.map → chunk-PTC43J7F.js.map} +1 -1
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/ui/admin/index.d.ts +4 -3
- package/dist/ui/admin/index.js +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/worker/index.cjs +299 -84
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +33 -1
- package/dist/worker/index.d.ts +33 -1
- package/dist/worker/index.js +292 -77
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -3694,7 +3695,7 @@ async function hash(value) {
|
|
|
3694
3695
|
const bytes = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(value)));
|
|
3695
3696
|
return [...new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3696
3697
|
}
|
|
3697
|
-
async function
|
|
3698
|
+
async function membershipDiscountCouponId(input, policyId) {
|
|
3698
3699
|
return policyId ? `odla_m_${await hash([input.appId, input.chapterId, input.environment, input.runtime, input.skuId, policyId])}` : void 0;
|
|
3699
3700
|
}
|
|
3700
3701
|
async function load(db, ns, id10) {
|
|
@@ -3720,7 +3721,7 @@ async function restore(row2, input) {
|
|
|
3720
3721
|
discountPolicy: contract.discountPolicy,
|
|
3721
3722
|
approvedFoundingCount: Number(row2.approvedFoundingCount),
|
|
3722
3723
|
now: Number(row2.issuedAt),
|
|
3723
|
-
couponId: await
|
|
3724
|
+
couponId: await membershipDiscountCouponId(input, contract.discountPolicy?.id)
|
|
3724
3725
|
});
|
|
3725
3726
|
if (expected.offering.chapterId !== input.chapterId || expected.offering.baseSkuId !== input.skuId) reject("invalid_offer_snapshot");
|
|
3726
3727
|
const result = {
|
|
@@ -3751,7 +3752,7 @@ async function previewMembershipCommercialOffer(db, input) {
|
|
|
3751
3752
|
discountPolicy: policy,
|
|
3752
3753
|
approvedFoundingCount: Number(approvedFoundingCount),
|
|
3753
3754
|
now: input.now,
|
|
3754
|
-
couponId: await
|
|
3755
|
+
couponId: await membershipDiscountCouponId(input, policy?.id)
|
|
3755
3756
|
});
|
|
3756
3757
|
const discount = contract.billingTerms.discount;
|
|
3757
3758
|
return {
|
|
@@ -3801,7 +3802,7 @@ async function issueMembershipCommercialOffer(db, input) {
|
|
|
3801
3802
|
discountPolicy: policy,
|
|
3802
3803
|
approvedFoundingCount: Number(approvedFoundingCount),
|
|
3803
3804
|
now: input.now,
|
|
3804
|
-
couponId: await
|
|
3805
|
+
couponId: await membershipDiscountCouponId(input, policy?.id)
|
|
3805
3806
|
});
|
|
3806
3807
|
const value = {
|
|
3807
3808
|
id: input.offerId,
|
|
@@ -4849,9 +4850,9 @@ async function subscriptionForSeat(sk, seat) {
|
|
|
4849
4850
|
if (!Array.isArray(discounts) || discounts.length > 5) reject3();
|
|
4850
4851
|
for (const discount of discounts) {
|
|
4851
4852
|
const couponRef = discount.source?.coupon ?? discount.coupon;
|
|
4852
|
-
const
|
|
4853
|
-
if (!
|
|
4854
|
-
const coupon = await read(sk, `/v1/coupons/${encodeURIComponent(
|
|
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" });
|
|
4855
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();
|
|
4856
4857
|
}
|
|
4857
4858
|
return sub;
|