@odla-ai/chapter 0.39.2 → 0.40.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
@@ -363,6 +363,8 @@ interface ChapterPrices {
363
363
  interface ChapterPolicy {
364
364
  disclaimerText?: string;
365
365
  refundPolicyText?: string;
366
+ /** Plain-language merchant identity shown immediately before payment consent. */
367
+ merchantDisclosureText?: string;
366
368
  trustCopy?: string;
367
369
  commitmentText?: string;
368
370
  normsText?: string;
@@ -1544,6 +1546,8 @@ type WebhookEvent = ({
1544
1546
  }) & {
1545
1547
  appId?: string;
1546
1548
  environment?: string;
1549
+ dataEnvironment?: string;
1550
+ runtime?: string;
1547
1551
  };
1548
1552
  /** Resolve the application reference on a Stripe object: `applicationId` from
1549
1553
  * metadata (direct, then subscription_details, then nested
@@ -1553,6 +1557,8 @@ declare function findApplicationRef(obj: Record<string, unknown>): {
1553
1557
  customerId?: string;
1554
1558
  appId?: string;
1555
1559
  environment?: string;
1560
+ dataEnvironment?: string;
1561
+ runtime?: string;
1556
1562
  };
1557
1563
  /** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
1558
1564
  * splits into first_payment vs renewal by `billing_reason`; refunds and
@@ -1743,6 +1749,7 @@ interface JoinConfigGroup {
1743
1749
  foundingDiscountCents?: number;
1744
1750
  disclaimerText?: string;
1745
1751
  refundPolicyText?: string;
1752
+ merchantDisclosureText?: string;
1746
1753
  trustCopy?: string;
1747
1754
  commitmentText?: string;
1748
1755
  normsText?: string;
@@ -2640,6 +2647,8 @@ interface SignupControlApplication {
2640
2647
  interface SignupControlPolicy {
2641
2648
  disclaimerText: string;
2642
2649
  refundPolicyText: string;
2650
+ /** Plain-language merchant identity displayed before payment consent. */
2651
+ merchantDisclosureText?: string;
2643
2652
  trustCopy?: string;
2644
2653
  commitmentText?: string;
2645
2654
  normsText?: string;
package/dist/index.d.ts CHANGED
@@ -363,6 +363,8 @@ interface ChapterPrices {
363
363
  interface ChapterPolicy {
364
364
  disclaimerText?: string;
365
365
  refundPolicyText?: string;
366
+ /** Plain-language merchant identity shown immediately before payment consent. */
367
+ merchantDisclosureText?: string;
366
368
  trustCopy?: string;
367
369
  commitmentText?: string;
368
370
  normsText?: string;
@@ -1544,6 +1546,8 @@ type WebhookEvent = ({
1544
1546
  }) & {
1545
1547
  appId?: string;
1546
1548
  environment?: string;
1549
+ dataEnvironment?: string;
1550
+ runtime?: string;
1547
1551
  };
1548
1552
  /** Resolve the application reference on a Stripe object: `applicationId` from
1549
1553
  * metadata (direct, then subscription_details, then nested
@@ -1553,6 +1557,8 @@ declare function findApplicationRef(obj: Record<string, unknown>): {
1553
1557
  customerId?: string;
1554
1558
  appId?: string;
1555
1559
  environment?: string;
1560
+ dataEnvironment?: string;
1561
+ runtime?: string;
1556
1562
  };
1557
1563
  /** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
1558
1564
  * splits into first_payment vs renewal by `billing_reason`; refunds and
@@ -1743,6 +1749,7 @@ interface JoinConfigGroup {
1743
1749
  foundingDiscountCents?: number;
1744
1750
  disclaimerText?: string;
1745
1751
  refundPolicyText?: string;
1752
+ merchantDisclosureText?: string;
1746
1753
  trustCopy?: string;
1747
1754
  commitmentText?: string;
1748
1755
  normsText?: string;
@@ -2640,6 +2647,8 @@ interface SignupControlApplication {
2640
2647
  interface SignupControlPolicy {
2641
2648
  disclaimerText: string;
2642
2649
  refundPolicyText: string;
2650
+ /** Plain-language merchant identity displayed before payment consent. */
2651
+ merchantDisclosureText?: string;
2643
2652
  trustCopy?: string;
2644
2653
  commitmentText?: string;
2645
2654
  normsText?: string;
package/dist/index.js CHANGED
@@ -165,6 +165,7 @@ function joinConfig(group, paymentsReady2, tiers2 = [], conditions = {}) {
165
165
  conditions,
166
166
  disclaimerText: group.disclaimerText ?? "",
167
167
  refundPolicyText: group.refundPolicyText ?? "",
168
+ merchantDisclosureText: group.merchantDisclosureText ?? "",
168
169
  trustCopy: group.trustCopy ?? "",
169
170
  commitmentText: group.commitmentText ?? "",
170
171
  normsText: group.normsText ?? "",
@@ -215,6 +216,7 @@ var applicationAttrs = {
215
216
  tierId: attr("string", { indexed: true, optional: true }),
216
217
  stripeCustomerId: attr("string", { indexed: true, optional: true }),
217
218
  stripeSubscriptionId: attr("string", { indexed: true, optional: true }),
219
+ stripeRuntime: attr("string", { indexed: true, optional: true }),
218
220
  renewalAt: attr("number", { optional: true }),
219
221
  disclaimerAckAt: attr("number", { optional: true }),
220
222
  refundPolicyAckAt: attr("number", { optional: true }),
@@ -310,6 +312,7 @@ var giftPurchaseIntentsEntity = { attrs: {
310
312
  id: id2(),
311
313
  chapterId: attr3("string", { indexed: true }),
312
314
  environment: attr3("string", { indexed: true }),
315
+ runtime: attr3("string", { optional: true, indexed: true }),
313
316
  purchaserType: attr3("string", { indexed: true }),
314
317
  purchaserApplicationId: attr3("string", { optional: true, indexed: true }),
315
318
  purchaserUserId: attr3("string", { optional: true, indexed: true }),
@@ -509,6 +512,7 @@ var groups = {
509
512
  calendarLink: attr4("string", { optional: true }),
510
513
  disclaimerText: attr4("string"),
511
514
  refundPolicyText: attr4("string"),
515
+ merchantDisclosureText: attr4("string", { optional: true }),
512
516
  trustCopy: attr4("string"),
513
517
  commitmentText: attr4("string", { optional: true }),
514
518
  normsText: attr4("string", { optional: true }),
@@ -734,6 +738,7 @@ function buildGroupSeed(config) {
734
738
  replyTo: emails?.replyTo ?? emails?.notificationEmail ?? "",
735
739
  disclaimerText: policy.disclaimerText ?? "",
736
740
  refundPolicyText: policy.refundPolicyText ?? "",
741
+ merchantDisclosureText: policy.merchantDisclosureText ?? "",
737
742
  trustCopy: policy.trustCopy ?? "",
738
743
  emailTemplates: emails?.templates ?? defaultEmailTemplates(config.name),
739
744
  schedulingJson: scheduling
@@ -2655,12 +2660,16 @@ function findApplicationRef(obj) {
2655
2660
  const applicationId = candidates.map(pick).find(Boolean);
2656
2661
  const appId = candidates.map((metadata) => typeof metadata.odlaAppId === "string" ? metadata.odlaAppId : void 0).find(Boolean);
2657
2662
  const environment = candidates.map((metadata) => typeof metadata.odlaEnvironment === "string" ? metadata.odlaEnvironment : void 0).find(Boolean);
2663
+ const dataEnvironment = candidates.map((metadata) => typeof metadata.odlaDataEnvironment === "string" ? metadata.odlaDataEnvironment : void 0).find(Boolean);
2664
+ const runtime = candidates.map((metadata) => typeof metadata.odlaRuntime === "string" ? metadata.odlaRuntime : void 0).find(Boolean);
2658
2665
  const customerId = typeof obj.customer === "string" ? obj.customer : void 0;
2659
2666
  return {
2660
2667
  ...applicationId ? { applicationId } : {},
2661
2668
  ...customerId ? { customerId } : {},
2662
2669
  ...appId ? { appId } : {},
2663
- ...environment ? { environment } : {}
2670
+ ...environment ? { environment } : {},
2671
+ ...dataEnvironment ? { dataEnvironment } : {},
2672
+ ...runtime ? { runtime } : {}
2664
2673
  };
2665
2674
  }
2666
2675
  function findGiftRef(obj) {
@@ -2670,17 +2679,31 @@ function findGiftRef(obj) {
2670
2679
  const subscription = obj.subscription_details ?? parent?.subscription_details;
2671
2680
  const giftIntentId = pick(metaOf(obj)) ?? pick(metaOf(subscription));
2672
2681
  const subscriptionId = typeof obj.subscription === "string" ? obj.subscription : typeof subscription?.subscription === "string" ? String(subscription.subscription) : void 0;
2673
- return { ...giftIntentId ? { giftIntentId } : {}, providerObjectId: subscriptionId ?? String(obj.id ?? "") };
2682
+ const candidates = [metaOf(obj), metaOf(subscription)];
2683
+ const pickIdentity = (name) => candidates.map((metadata) => typeof metadata[name] === "string" ? String(metadata[name]) : void 0).find(Boolean);
2684
+ const appId = pickIdentity("odlaAppId");
2685
+ const environment = pickIdentity("odlaEnvironment");
2686
+ const dataEnvironment = pickIdentity("odlaDataEnvironment");
2687
+ const runtime = pickIdentity("odlaRuntime");
2688
+ return {
2689
+ ...giftIntentId ? { giftIntentId } : {},
2690
+ providerObjectId: subscriptionId ?? String(obj.id ?? ""),
2691
+ ...appId ? { appId } : {},
2692
+ ...environment ? { environment } : {},
2693
+ ...dataEnvironment ? { dataEnvironment } : {},
2694
+ ...runtime ? { runtime } : {}
2695
+ };
2674
2696
  }
2675
2697
  function normalizeWebhookEvent(event) {
2676
2698
  const obj = event.data?.object ?? {};
2677
2699
  const gift = findGiftRef(obj);
2678
2700
  if (gift.giftIntentId) {
2701
+ const { giftIntentId, providerObjectId, ...identity } = gift;
2679
2702
  if (event.type === "payment_intent.succeeded" || event.type === "invoice.paid" && obj.billing_reason === "subscription_create") {
2680
- return { kind: "gift_paid", giftIntentId: gift.giftIntentId, providerObjectId: gift.providerObjectId };
2703
+ return { kind: "gift_paid", giftIntentId, providerObjectId, ...identity };
2681
2704
  }
2682
- if (event.type === "charge.refunded") return { kind: "gift_revoked", giftIntentId: gift.giftIntentId, reason: "refunded" };
2683
- if (event.type === "customer.subscription.deleted") return { kind: "gift_revoked", giftIntentId: gift.giftIntentId, reason: "canceled" };
2705
+ if (event.type === "charge.refunded") return { kind: "gift_revoked", giftIntentId, ...identity, reason: "refunded" };
2706
+ if (event.type === "customer.subscription.deleted") return { kind: "gift_revoked", giftIntentId, ...identity, reason: "canceled" };
2684
2707
  return { kind: "ignored", type: event.type };
2685
2708
  }
2686
2709
  const ref = findApplicationRef(obj);
@@ -4178,7 +4201,14 @@ function policyOf(value, errors) {
4178
4201
  errors.push("document.policy must be an object");
4179
4202
  return void 0;
4180
4203
  }
4181
- const allowed2 = /* @__PURE__ */ new Set(["disclaimerText", "refundPolicyText", "trustCopy", "commitmentText", "normsText"]);
4204
+ const allowed2 = /* @__PURE__ */ new Set([
4205
+ "disclaimerText",
4206
+ "refundPolicyText",
4207
+ "merchantDisclosureText",
4208
+ "trustCopy",
4209
+ "commitmentText",
4210
+ "normsText"
4211
+ ]);
4182
4212
  unknownKeys3(input, allowed2, "document.policy", errors);
4183
4213
  const result = {};
4184
4214
  for (const key of allowed2) {