@odla-ai/chapter 0.33.2 → 0.34.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.
@@ -570,7 +570,7 @@ function groupAttrs(document) {
570
570
  return {
571
571
  ...first ? { standardPriceCents: first.priceCents } : {},
572
572
  foundingDiscountCents: 0,
573
- stripePriceId: firstPaid?.stripePriceId ?? null,
573
+ ...firstPaid?.stripePriceId ? { stripePriceId: firstPaid.stripePriceId } : {},
574
574
  ...document.policy ?? {},
575
575
  ...document.scheduling ? { schedulingJson: document.scheduling } : {}
576
576
  };
@@ -596,24 +596,35 @@ async function materializeSignupControl(db, envelope, previous, receivedAt) {
596
596
  }
597
597
  }
598
598
  for (const tier of document.tiers) {
599
- ops.push({ t: "update", ns: "tiers", id: byPublicId("tiers", tier.id), attrs: {
599
+ const tierRef = byPublicId("tiers", tier.id);
600
+ ops.push({ t: "update", ns: "tiers", id: tierRef, attrs: {
600
601
  id: tier.id,
601
602
  groupId: document.target.chapterId,
602
603
  name: tier.name,
603
604
  priceCents: tier.priceCents,
604
- stripePriceId: tier.stripePriceId ?? null,
605
- blurb: tier.blurb ?? null,
605
+ ...tier.stripePriceId ? { stripePriceId: tier.stripePriceId } : {},
606
+ ...tier.blurb ? { blurb: tier.blurb } : {},
606
607
  sortOrder: tier.sortOrder,
607
608
  active: tier.available,
608
609
  createdAt: receivedAt
609
610
  } });
611
+ const retract = [
612
+ ...!tier.stripePriceId ? ["stripePriceId"] : [],
613
+ ...!tier.blurb ? ["blurb"] : []
614
+ ];
615
+ if (retract.length) ops.push({ t: "retract", ns: "tiers", id: tierRef, attrs: retract });
610
616
  }
617
+ const groupRef = byPublicId("groups", document.target.chapterId);
618
+ const attrs = groupAttrs(document);
611
619
  ops.push({
612
620
  t: "update",
613
621
  ns: "groups",
614
- id: byPublicId("groups", document.target.chapterId),
615
- attrs: groupAttrs(document)
622
+ id: groupRef,
623
+ attrs
616
624
  });
625
+ if (!("stripePriceId" in attrs)) {
626
+ ops.push({ t: "retract", ns: "groups", id: groupRef, attrs: ["stripePriceId"] });
627
+ }
617
628
  const id = `signup-control:${document.target.environment}:${document.revision}`;
618
629
  ops.push({ t: "update", ns: "signupControls", id, attrs: {
619
630
  id,