@qazuor/qzpay-drizzle 1.7.3 → 1.7.5
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 +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/schema/index.cjs +8 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.js +8 -1
- package/dist/schema/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2129,7 +2129,14 @@ var billingWebhookEvents = pgCore.pgTable(
|
|
|
2129
2129
|
createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull().defaultNow()
|
|
2130
2130
|
},
|
|
2131
2131
|
(table) => ({
|
|
2132
|
-
|
|
2132
|
+
// UNIQUE index on `provider_event_id` underpins the optimistic-insert
|
|
2133
|
+
// idempotency pattern adopted by consumers: handlers try the INSERT
|
|
2134
|
+
// first and treat a UNIQUE violation as "duplicate webhook, skip".
|
|
2135
|
+
// Without the UNIQUE constraint a duplicate event lands twice and the
|
|
2136
|
+
// downstream dispatcher runs twice — a silent double-activation bug.
|
|
2137
|
+
// Discovered while validating Hospeda SPEC-143 T-143-15 (e2e webhook
|
|
2138
|
+
// idempotency).
|
|
2139
|
+
providerIdIdx: pgCore.uniqueIndex("idx_webhook_events_provider_id").on(table.providerEventId),
|
|
2133
2140
|
typeIdx: pgCore.index("idx_webhook_events_type").on(table.type),
|
|
2134
2141
|
statusIdx: pgCore.index("idx_webhook_events_status").on(table.status)
|
|
2135
2142
|
})
|
|
@@ -5904,13 +5911,14 @@ var QZPayDrizzleStorageAdapter = class {
|
|
|
5904
5911
|
const now = /* @__PURE__ */ new Date();
|
|
5905
5912
|
const hasTrial = input.trialDays !== void 0 && input.trialDays > 0;
|
|
5906
5913
|
const trialEnd = hasTrial && input.trialDays ? new Date(now.getTime() + input.trialDays * 24 * 60 * 60 * 1e3) : null;
|
|
5914
|
+
const initialStatus = input.mode === "paid" ? "incomplete" : hasTrial ? "trialing" : "active";
|
|
5907
5915
|
const drizzleInput = mapCoreSubscriptionCreateToDrizzle(input, {
|
|
5908
5916
|
livemode,
|
|
5909
5917
|
billingInterval: "month",
|
|
5910
5918
|
intervalCount: 1,
|
|
5911
5919
|
currentPeriodStart: now,
|
|
5912
5920
|
currentPeriodEnd: new Date(now.getTime() + 30 * 24 * 60 * 60 * 1e3),
|
|
5913
|
-
status:
|
|
5921
|
+
status: initialStatus,
|
|
5914
5922
|
trialStart: hasTrial ? now : null,
|
|
5915
5923
|
trialEnd
|
|
5916
5924
|
});
|