@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.d.cts CHANGED
@@ -110,6 +110,10 @@ interface JoinConfigTier {
110
110
  free: boolean;
111
111
  /** The network authority's current founding promise for this tier, read before anyone applies. */
112
112
  founding?: JoinTierFounding;
113
+ /** Current additional-member offer; checkout freezes and confirms this price. */
114
+ seatOffer?: {
115
+ amountCents: number;
116
+ };
113
117
  }
114
118
  /** What the join page may say about the founding rate today; checkout confirms it on the issued offer. */
115
119
  interface JoinTierFounding {
@@ -123,7 +127,9 @@ interface JoinTierFounding {
123
127
  declare function joinConfigTiers(tiers: readonly ChapterTier[], defaults?: {
124
128
  currency?: string;
125
129
  interval?: "year" | "month";
126
- }, founding?: ReadonlyMap<string, JoinTierFounding>): JoinConfigTier[];
130
+ }, founding?: ReadonlyMap<string, JoinTierFounding>, seats?: ReadonlyMap<string, {
131
+ amountCents: number;
132
+ }>): JoinConfigTier[];
127
133
 
128
134
  /** A code-declared mail event. Copy stays in settings; this describes who receives it and the values the event supplies. */
129
135
  interface ChapterEmailEvent {
@@ -1508,6 +1514,8 @@ interface MembershipOfferPreview {
1508
1514
  renewalCents: number;
1509
1515
  discountDuration?: "first_term" | "while_active";
1510
1516
  initialTermEndsAt?: number;
1517
+ /** Current additional-member price, including zero for an included member. */
1518
+ seatPriceCents?: number;
1511
1519
  }
1512
1520
  /** The current published offering and founding policy for one SKU, computed exactly as issuance computes them.
1513
1521
  * Nothing is written, so a preview can never reserve a founding position or drift from the offer a member later accepts. */
package/dist/index.d.ts CHANGED
@@ -110,6 +110,10 @@ interface JoinConfigTier {
110
110
  free: boolean;
111
111
  /** The network authority's current founding promise for this tier, read before anyone applies. */
112
112
  founding?: JoinTierFounding;
113
+ /** Current additional-member offer; checkout freezes and confirms this price. */
114
+ seatOffer?: {
115
+ amountCents: number;
116
+ };
113
117
  }
114
118
  /** What the join page may say about the founding rate today; checkout confirms it on the issued offer. */
115
119
  interface JoinTierFounding {
@@ -123,7 +127,9 @@ interface JoinTierFounding {
123
127
  declare function joinConfigTiers(tiers: readonly ChapterTier[], defaults?: {
124
128
  currency?: string;
125
129
  interval?: "year" | "month";
126
- }, founding?: ReadonlyMap<string, JoinTierFounding>): JoinConfigTier[];
130
+ }, founding?: ReadonlyMap<string, JoinTierFounding>, seats?: ReadonlyMap<string, {
131
+ amountCents: number;
132
+ }>): JoinConfigTier[];
127
133
 
128
134
  /** A code-declared mail event. Copy stays in settings; this describes who receives it and the values the event supplies. */
129
135
  interface ChapterEmailEvent {
@@ -1508,6 +1514,8 @@ interface MembershipOfferPreview {
1508
1514
  renewalCents: number;
1509
1515
  discountDuration?: "first_term" | "while_active";
1510
1516
  initialTermEndsAt?: number;
1517
+ /** Current additional-member price, including zero for an included member. */
1518
+ seatPriceCents?: number;
1511
1519
  }
1512
1520
  /** The current published offering and founding policy for one SKU, computed exactly as issuance computes them.
1513
1521
  * Nothing is written, so a preview can never reserve a founding position or drift from the offer a member later accepts. */
package/dist/index.js CHANGED
@@ -559,6 +559,7 @@ var subscriptionCheckoutIntentsEntity = {
559
559
  interval: attr5("string", { indexed: true }),
560
560
  billingTerms: attr5("json", { optional: true }),
561
561
  paymentQuote: attr5("json", { optional: true }),
562
+ paymentReceipt: attr5("json", { optional: true }),
562
563
  membershipOffer: attr5("json", { optional: true }),
563
564
  purchaserEmailNormalized: attr5("string", { indexed: true }),
564
565
  requestedCustomerId: attr5("string", { indexed: true, optional: true }),
@@ -3128,7 +3129,7 @@ function findTier(tiers2, tierId) {
3128
3129
  if (!tierId) return tiers2.length === 1 ? tiers2[0] : null;
3129
3130
  return tiers2.find((tier) => tier.id === tierId) ?? null;
3130
3131
  }
3131
- function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new Map()) {
3132
+ function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new Map(), seats = /* @__PURE__ */ new Map()) {
3132
3133
  return tiers2.map((tier) => ({
3133
3134
  id: tier.id,
3134
3135
  name: tier.name,
@@ -3137,7 +3138,8 @@ function joinConfigTiers(tiers2, defaults = {}, founding = /* @__PURE__ */ new M
3137
3138
  interval: tier.interval ?? defaults.interval ?? "year",
3138
3139
  blurb: tier.blurb ?? "",
3139
3140
  free: tierIsFree(tier),
3140
- ...founding.has(tier.id) ? { founding: founding.get(tier.id) } : {}
3141
+ ...founding.has(tier.id) ? { founding: founding.get(tier.id) } : {},
3142
+ ...seats.has(tier.id) ? { seatOffer: seats.get(tier.id) } : {}
3141
3143
  }));
3142
3144
  }
3143
3145
 
@@ -3491,6 +3493,7 @@ async function previewMembershipCommercialOffer(db, input) {
3491
3493
  ...contract.founding && contract.discountPolicy ? { cohortLabel: contract.discountPolicy.cohortLabel } : {},
3492
3494
  dueTodayCents: contract.dueTodayCents,
3493
3495
  renewalCents: contract.renewalCents,
3496
+ ...offering.seatPriceCents !== void 0 ? { seatPriceCents: offering.seatPriceCents } : {},
3494
3497
  ...discount ? { discountDuration: discount.duration === "once" ? "first_term" : "while_active" } : {},
3495
3498
  ...contract.initialTermEndsAt !== void 0 ? { initialTermEndsAt: contract.initialTermEndsAt } : {}
3496
3499
  };
@@ -5856,7 +5859,7 @@ async function requestMembershipCommercialOffer(options) {
5856
5859
  async function requestMembershipOfferPreview(options) {
5857
5860
  const result = await requestAuthority(options, "offer-preview", { skuId: options.skuId });
5858
5861
  const preview = result.preview;
5859
- 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");
5862
+ 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");
5860
5863
  return preview;
5861
5864
  }
5862
5865
  async function requestMembershipCheckoutBinding(options) {
@@ -7139,7 +7142,7 @@ async function frozenCheckoutVariables(db, app) {
7139
7142
  const intent = (await db.query({ subscriptionCheckoutIntents: { $: { where: { id: String(app.id) }, limit: 1 } } })).subscriptionCheckoutIntents?.[0];
7140
7143
  const offer = intent?.membershipOffer, contract = offer?.contract;
7141
7144
  const offering = contract?.offering, quote = intent?.paymentQuote;
7142
- const amount = contract?.dueTodayCents ?? intent?.priceCents;
7145
+ const amount = quote?.lineItems?.dueTodayCents ?? contract?.dueTodayCents ?? intent?.priceCents;
7143
7146
  const currency = offering?.currency ?? intent?.currency;
7144
7147
  let formatted = "";
7145
7148
  if (Number.isSafeInteger(amount) && Number(amount) > 0 && typeof currency === "string" && /^[a-z]{3}$/.test(currency)) {