@odla-ai/chapter 0.38.1 → 0.39.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 +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +27 -3
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +27 -3
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1319,7 +1319,7 @@ interface StripeEvent {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
/** A normalized, provider-agnostic webhook event. `kind` drives the db write;
|
|
1321
1321
|
* the application is resolved from `applicationId` (metadata) or `customerId`. */
|
|
1322
|
-
type WebhookEvent = {
|
|
1322
|
+
type WebhookEvent = ({
|
|
1323
1323
|
kind: "gift_paid";
|
|
1324
1324
|
giftIntentId: string;
|
|
1325
1325
|
providerObjectId: string;
|
|
@@ -1348,6 +1348,9 @@ type WebhookEvent = {
|
|
|
1348
1348
|
} | {
|
|
1349
1349
|
kind: "ignored";
|
|
1350
1350
|
type: string;
|
|
1351
|
+
}) & {
|
|
1352
|
+
appId?: string;
|
|
1353
|
+
environment?: string;
|
|
1351
1354
|
};
|
|
1352
1355
|
/** Resolve the application reference on a Stripe object: `applicationId` from
|
|
1353
1356
|
* metadata (direct, then subscription_details, then nested
|
|
@@ -1355,6 +1358,8 @@ type WebhookEvent = {
|
|
|
1355
1358
|
declare function findApplicationRef(obj: Record<string, unknown>): {
|
|
1356
1359
|
applicationId?: string;
|
|
1357
1360
|
customerId?: string;
|
|
1361
|
+
appId?: string;
|
|
1362
|
+
environment?: string;
|
|
1358
1363
|
};
|
|
1359
1364
|
/** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
|
|
1360
1365
|
* splits into first_payment vs renewal by `billing_reason`; refunds and
|
package/dist/index.d.ts
CHANGED
|
@@ -1319,7 +1319,7 @@ interface StripeEvent {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
/** A normalized, provider-agnostic webhook event. `kind` drives the db write;
|
|
1321
1321
|
* the application is resolved from `applicationId` (metadata) or `customerId`. */
|
|
1322
|
-
type WebhookEvent = {
|
|
1322
|
+
type WebhookEvent = ({
|
|
1323
1323
|
kind: "gift_paid";
|
|
1324
1324
|
giftIntentId: string;
|
|
1325
1325
|
providerObjectId: string;
|
|
@@ -1348,6 +1348,9 @@ type WebhookEvent = {
|
|
|
1348
1348
|
} | {
|
|
1349
1349
|
kind: "ignored";
|
|
1350
1350
|
type: string;
|
|
1351
|
+
}) & {
|
|
1352
|
+
appId?: string;
|
|
1353
|
+
environment?: string;
|
|
1351
1354
|
};
|
|
1352
1355
|
/** Resolve the application reference on a Stripe object: `applicationId` from
|
|
1353
1356
|
* metadata (direct, then subscription_details, then nested
|
|
@@ -1355,6 +1358,8 @@ type WebhookEvent = {
|
|
|
1355
1358
|
declare function findApplicationRef(obj: Record<string, unknown>): {
|
|
1356
1359
|
applicationId?: string;
|
|
1357
1360
|
customerId?: string;
|
|
1361
|
+
appId?: string;
|
|
1362
|
+
environment?: string;
|
|
1358
1363
|
};
|
|
1359
1364
|
/** Normalize a verified Stripe event into a {@link WebhookEvent}. `invoice.paid`
|
|
1360
1365
|
* splits into first_payment vs renewal by `billing_reason`; refunds and
|
package/dist/index.js
CHANGED
|
@@ -2334,9 +2334,21 @@ function webhookMutationId(eventId) {
|
|
|
2334
2334
|
function findApplicationRef(obj) {
|
|
2335
2335
|
const metaOf = (v) => v && typeof v === "object" ? v.metadata ?? {} : {};
|
|
2336
2336
|
const pick = (m) => typeof m.applicationId === "string" ? m.applicationId : void 0;
|
|
2337
|
-
const
|
|
2337
|
+
const candidates = [
|
|
2338
|
+
metaOf(obj),
|
|
2339
|
+
metaOf(obj.subscription_details),
|
|
2340
|
+
metaOf(obj.parent?.subscription_details)
|
|
2341
|
+
];
|
|
2342
|
+
const applicationId = candidates.map(pick).find(Boolean);
|
|
2343
|
+
const appId = candidates.map((metadata) => typeof metadata.odlaAppId === "string" ? metadata.odlaAppId : void 0).find(Boolean);
|
|
2344
|
+
const environment = candidates.map((metadata) => typeof metadata.odlaEnvironment === "string" ? metadata.odlaEnvironment : void 0).find(Boolean);
|
|
2338
2345
|
const customerId = typeof obj.customer === "string" ? obj.customer : void 0;
|
|
2339
|
-
return {
|
|
2346
|
+
return {
|
|
2347
|
+
...applicationId ? { applicationId } : {},
|
|
2348
|
+
...customerId ? { customerId } : {},
|
|
2349
|
+
...appId ? { appId } : {},
|
|
2350
|
+
...environment ? { environment } : {}
|
|
2351
|
+
};
|
|
2340
2352
|
}
|
|
2341
2353
|
function findGiftRef(obj) {
|
|
2342
2354
|
const metaOf = (value) => value && typeof value === "object" ? value.metadata ?? {} : {};
|