@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.
@@ -542,7 +542,7 @@ function groupAttrs(document) {
542
542
  return {
543
543
  ...first ? { standardPriceCents: first.priceCents } : {},
544
544
  foundingDiscountCents: 0,
545
- stripePriceId: firstPaid?.stripePriceId ?? null,
545
+ ...firstPaid?.stripePriceId ? { stripePriceId: firstPaid.stripePriceId } : {},
546
546
  ...document.policy ?? {},
547
547
  ...document.scheduling ? { schedulingJson: document.scheduling } : {}
548
548
  };
@@ -568,24 +568,35 @@ async function materializeSignupControl(db, envelope, previous, receivedAt) {
568
568
  }
569
569
  }
570
570
  for (const tier of document.tiers) {
571
- ops.push({ t: "update", ns: "tiers", id: byPublicId("tiers", tier.id), attrs: {
571
+ const tierRef = byPublicId("tiers", tier.id);
572
+ ops.push({ t: "update", ns: "tiers", id: tierRef, attrs: {
572
573
  id: tier.id,
573
574
  groupId: document.target.chapterId,
574
575
  name: tier.name,
575
576
  priceCents: tier.priceCents,
576
- stripePriceId: tier.stripePriceId ?? null,
577
- blurb: tier.blurb ?? null,
577
+ ...tier.stripePriceId ? { stripePriceId: tier.stripePriceId } : {},
578
+ ...tier.blurb ? { blurb: tier.blurb } : {},
578
579
  sortOrder: tier.sortOrder,
579
580
  active: tier.available,
580
581
  createdAt: receivedAt
581
582
  } });
583
+ const retract = [
584
+ ...!tier.stripePriceId ? ["stripePriceId"] : [],
585
+ ...!tier.blurb ? ["blurb"] : []
586
+ ];
587
+ if (retract.length) ops.push({ t: "retract", ns: "tiers", id: tierRef, attrs: retract });
582
588
  }
589
+ const groupRef = byPublicId("groups", document.target.chapterId);
590
+ const attrs = groupAttrs(document);
583
591
  ops.push({
584
592
  t: "update",
585
593
  ns: "groups",
586
- id: byPublicId("groups", document.target.chapterId),
587
- attrs: groupAttrs(document)
594
+ id: groupRef,
595
+ attrs
588
596
  });
597
+ if (!("stripePriceId" in attrs)) {
598
+ ops.push({ t: "retract", ns: "groups", id: groupRef, attrs: ["stripePriceId"] });
599
+ }
589
600
  const id = `signup-control:${document.target.environment}:${document.revision}`;
590
601
  ops.push({ t: "update", ns: "signupControls", id, attrs: {
591
602
  id,