@odla-ai/chapter 0.39.2 → 0.40.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/dist/index.cjs +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +73 -21
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +3 -0
- package/dist/worker/index.d.ts +3 -0
- package/dist/worker/index.js +73 -21
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
- package/runbooks/greenfield.md +9 -4
package/dist/index.d.cts
CHANGED
|
@@ -1544,6 +1544,8 @@ type WebhookEvent = ({
|
|
|
1544
1544
|
}) & {
|
|
1545
1545
|
appId?: string;
|
|
1546
1546
|
environment?: string;
|
|
1547
|
+
dataEnvironment?: string;
|
|
1548
|
+
runtime?: string;
|
|
1547
1549
|
};
|
|
1548
1550
|
/** Resolve the application reference on a Stripe object: `applicationId` from
|
|
1549
1551
|
* metadata (direct, then subscription_details, then nested
|
|
@@ -1553,6 +1555,8 @@ declare function findApplicationRef(obj: Record<string, unknown>): {
|
|
|
1553
1555
|
customerId?: string;
|
|
1554
1556
|
appId?: string;
|
|
1555
1557
|
environment?: string;
|
|
1558
|
+
dataEnvironment?: string;
|
|
1559
|
+
runtime?: string;
|
|
1556
1560
|
};
|
|
1557
1561
|
/** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
|
|
1558
1562
|
* splits into first_payment vs renewal by `billing_reason`; refunds and
|
package/dist/index.d.ts
CHANGED
|
@@ -1544,6 +1544,8 @@ type WebhookEvent = ({
|
|
|
1544
1544
|
}) & {
|
|
1545
1545
|
appId?: string;
|
|
1546
1546
|
environment?: string;
|
|
1547
|
+
dataEnvironment?: string;
|
|
1548
|
+
runtime?: string;
|
|
1547
1549
|
};
|
|
1548
1550
|
/** Resolve the application reference on a Stripe object: `applicationId` from
|
|
1549
1551
|
* metadata (direct, then subscription_details, then nested
|
|
@@ -1553,6 +1555,8 @@ declare function findApplicationRef(obj: Record<string, unknown>): {
|
|
|
1553
1555
|
customerId?: string;
|
|
1554
1556
|
appId?: string;
|
|
1555
1557
|
environment?: string;
|
|
1558
|
+
dataEnvironment?: string;
|
|
1559
|
+
runtime?: string;
|
|
1556
1560
|
};
|
|
1557
1561
|
/** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
|
|
1558
1562
|
* splits into first_payment vs renewal by `billing_reason`; refunds and
|
package/dist/index.js
CHANGED
|
@@ -215,6 +215,7 @@ var applicationAttrs = {
|
|
|
215
215
|
tierId: attr("string", { indexed: true, optional: true }),
|
|
216
216
|
stripeCustomerId: attr("string", { indexed: true, optional: true }),
|
|
217
217
|
stripeSubscriptionId: attr("string", { indexed: true, optional: true }),
|
|
218
|
+
stripeRuntime: attr("string", { indexed: true, optional: true }),
|
|
218
219
|
renewalAt: attr("number", { optional: true }),
|
|
219
220
|
disclaimerAckAt: attr("number", { optional: true }),
|
|
220
221
|
refundPolicyAckAt: attr("number", { optional: true }),
|
|
@@ -310,6 +311,7 @@ var giftPurchaseIntentsEntity = { attrs: {
|
|
|
310
311
|
id: id2(),
|
|
311
312
|
chapterId: attr3("string", { indexed: true }),
|
|
312
313
|
environment: attr3("string", { indexed: true }),
|
|
314
|
+
runtime: attr3("string", { optional: true, indexed: true }),
|
|
313
315
|
purchaserType: attr3("string", { indexed: true }),
|
|
314
316
|
purchaserApplicationId: attr3("string", { optional: true, indexed: true }),
|
|
315
317
|
purchaserUserId: attr3("string", { optional: true, indexed: true }),
|
|
@@ -2655,12 +2657,16 @@ function findApplicationRef(obj) {
|
|
|
2655
2657
|
const applicationId = candidates.map(pick).find(Boolean);
|
|
2656
2658
|
const appId = candidates.map((metadata) => typeof metadata.odlaAppId === "string" ? metadata.odlaAppId : void 0).find(Boolean);
|
|
2657
2659
|
const environment = candidates.map((metadata) => typeof metadata.odlaEnvironment === "string" ? metadata.odlaEnvironment : void 0).find(Boolean);
|
|
2660
|
+
const dataEnvironment = candidates.map((metadata) => typeof metadata.odlaDataEnvironment === "string" ? metadata.odlaDataEnvironment : void 0).find(Boolean);
|
|
2661
|
+
const runtime = candidates.map((metadata) => typeof metadata.odlaRuntime === "string" ? metadata.odlaRuntime : void 0).find(Boolean);
|
|
2658
2662
|
const customerId = typeof obj.customer === "string" ? obj.customer : void 0;
|
|
2659
2663
|
return {
|
|
2660
2664
|
...applicationId ? { applicationId } : {},
|
|
2661
2665
|
...customerId ? { customerId } : {},
|
|
2662
2666
|
...appId ? { appId } : {},
|
|
2663
|
-
...environment ? { environment } : {}
|
|
2667
|
+
...environment ? { environment } : {},
|
|
2668
|
+
...dataEnvironment ? { dataEnvironment } : {},
|
|
2669
|
+
...runtime ? { runtime } : {}
|
|
2664
2670
|
};
|
|
2665
2671
|
}
|
|
2666
2672
|
function findGiftRef(obj) {
|
|
@@ -2670,17 +2676,31 @@ function findGiftRef(obj) {
|
|
|
2670
2676
|
const subscription = obj.subscription_details ?? parent?.subscription_details;
|
|
2671
2677
|
const giftIntentId = pick(metaOf(obj)) ?? pick(metaOf(subscription));
|
|
2672
2678
|
const subscriptionId = typeof obj.subscription === "string" ? obj.subscription : typeof subscription?.subscription === "string" ? String(subscription.subscription) : void 0;
|
|
2673
|
-
|
|
2679
|
+
const candidates = [metaOf(obj), metaOf(subscription)];
|
|
2680
|
+
const pickIdentity = (name) => candidates.map((metadata) => typeof metadata[name] === "string" ? String(metadata[name]) : void 0).find(Boolean);
|
|
2681
|
+
const appId = pickIdentity("odlaAppId");
|
|
2682
|
+
const environment = pickIdentity("odlaEnvironment");
|
|
2683
|
+
const dataEnvironment = pickIdentity("odlaDataEnvironment");
|
|
2684
|
+
const runtime = pickIdentity("odlaRuntime");
|
|
2685
|
+
return {
|
|
2686
|
+
...giftIntentId ? { giftIntentId } : {},
|
|
2687
|
+
providerObjectId: subscriptionId ?? String(obj.id ?? ""),
|
|
2688
|
+
...appId ? { appId } : {},
|
|
2689
|
+
...environment ? { environment } : {},
|
|
2690
|
+
...dataEnvironment ? { dataEnvironment } : {},
|
|
2691
|
+
...runtime ? { runtime } : {}
|
|
2692
|
+
};
|
|
2674
2693
|
}
|
|
2675
2694
|
function normalizeWebhookEvent(event) {
|
|
2676
2695
|
const obj = event.data?.object ?? {};
|
|
2677
2696
|
const gift = findGiftRef(obj);
|
|
2678
2697
|
if (gift.giftIntentId) {
|
|
2698
|
+
const { giftIntentId, providerObjectId, ...identity } = gift;
|
|
2679
2699
|
if (event.type === "payment_intent.succeeded" || event.type === "invoice.paid" && obj.billing_reason === "subscription_create") {
|
|
2680
|
-
return { kind: "gift_paid", giftIntentId
|
|
2700
|
+
return { kind: "gift_paid", giftIntentId, providerObjectId, ...identity };
|
|
2681
2701
|
}
|
|
2682
|
-
if (event.type === "charge.refunded") return { kind: "gift_revoked", giftIntentId
|
|
2683
|
-
if (event.type === "customer.subscription.deleted") return { kind: "gift_revoked", giftIntentId
|
|
2702
|
+
if (event.type === "charge.refunded") return { kind: "gift_revoked", giftIntentId, ...identity, reason: "refunded" };
|
|
2703
|
+
if (event.type === "customer.subscription.deleted") return { kind: "gift_revoked", giftIntentId, ...identity, reason: "canceled" };
|
|
2684
2704
|
return { kind: "ignored", type: event.type };
|
|
2685
2705
|
}
|
|
2686
2706
|
const ref = findApplicationRef(obj);
|