@dodopayments/convex 0.2.3 → 0.2.7
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/README.md +85 -87
- package/dist/client/index.d.ts +14 -7
- package/dist/component/lib.d.ts +19 -3
- package/dist/component/lib.js +20 -4
- package/dist/component/lib.js.map +1 -1
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/node_modules/zod/v3/types.js +2 -2
- package/dist/node_modules/zod/v3/types.js.map +1 -1
- package/dist/packages/core/dist/{chunk-YWHOVR2R.js → chunk-BVTJMX2W.js} +59 -17
- package/dist/packages/core/dist/chunk-BVTJMX2W.js.map +1 -0
- package/package.json +8 -4
- package/dist/packages/core/dist/chunk-YWHOVR2R.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as convex_server from 'convex/server';
|
|
2
|
-
import { GenericActionCtx } from 'convex/server';
|
|
2
|
+
import { FunctionReference, GenericActionCtx, GenericDataModel } from 'convex/server';
|
|
3
3
|
import { CheckoutSessionPayload } from '@dodopayments/core/checkout';
|
|
4
4
|
export { CheckoutHandlerConfig, CheckoutSessionBillingAddress, CheckoutSessionCustomer, CheckoutSessionPayload, CheckoutSessionProductCartItem, CheckoutSessionResponse, PaymentMethodType } from '@dodopayments/core/checkout';
|
|
5
5
|
export { Dispute, LicenseKey, Payment, Refund, Subscription, WebhookEventHandlers, WebhookPayload } from '@dodopayments/core/schemas';
|
|
@@ -9,10 +9,13 @@ export { WebhookHandlerConfig } from '@dodopayments/core/webhook';
|
|
|
9
9
|
type CustomerPortalArgs = {
|
|
10
10
|
send_email?: boolean;
|
|
11
11
|
};
|
|
12
|
+
type RunActionCtx = {
|
|
13
|
+
runAction: GenericActionCtx<GenericDataModel>["runAction"];
|
|
14
|
+
};
|
|
12
15
|
interface DodoPaymentsComponent {
|
|
13
16
|
lib: {
|
|
14
|
-
checkout:
|
|
15
|
-
customerPortal:
|
|
17
|
+
checkout: FunctionReference<"action", "internal">;
|
|
18
|
+
customerPortal: FunctionReference<"action", "internal">;
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
type DodoPaymentsClientConfig = {
|
|
@@ -34,14 +37,18 @@ declare class DodoPayments {
|
|
|
34
37
|
* Creates a Dodo Payments checkout session.
|
|
35
38
|
* Uses session checkout with full feature support.
|
|
36
39
|
*/
|
|
37
|
-
checkout: (ctx:
|
|
40
|
+
checkout: (ctx: RunActionCtx, args: {
|
|
38
41
|
payload: CheckoutSessionPayload;
|
|
39
|
-
}) => Promise<
|
|
42
|
+
}) => Promise<{
|
|
43
|
+
checkout_url: string;
|
|
44
|
+
}>;
|
|
40
45
|
/**
|
|
41
46
|
* Retrieves a URL for the customer portal.
|
|
42
|
-
*
|
|
47
|
+
* Requires the user to be identified via the identify function in the config.
|
|
43
48
|
*/
|
|
44
|
-
customerPortal: (ctx: any, args?: CustomerPortalArgs) => Promise<
|
|
49
|
+
customerPortal: (ctx: any, args?: CustomerPortalArgs) => Promise<{
|
|
50
|
+
portal_url: string;
|
|
51
|
+
}>;
|
|
45
52
|
};
|
|
46
53
|
}
|
|
47
54
|
|
|
@@ -54,7 +61,7 @@ type CustomerPortalResponse = {
|
|
|
54
61
|
portal_url: string;
|
|
55
62
|
};
|
|
56
63
|
|
|
57
|
-
type ConvexWebhookHandlerConfig = Omit<WebhookHandlerConfig<GenericActionCtx<
|
|
64
|
+
type ConvexWebhookHandlerConfig = Omit<WebhookHandlerConfig<GenericActionCtx<GenericDataModel>>, "webhookKey">;
|
|
58
65
|
/**
|
|
59
66
|
* Creates a Convex HTTP action to securely handle Dodo Payments webhooks.
|
|
60
67
|
*
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ class DodoPayments {
|
|
|
22
22
|
},
|
|
23
23
|
/**
|
|
24
24
|
* Retrieves a URL for the customer portal.
|
|
25
|
-
*
|
|
25
|
+
* Requires the user to be identified via the identify function in the config.
|
|
26
26
|
*/
|
|
27
27
|
customerPortal: async (ctx, args) => {
|
|
28
28
|
const identity = await this.config.identify(ctx);
|
|
@@ -5268,6 +5268,12 @@ var SubscriptionExpiredPayloadSchema = objectType({
|
|
|
5268
5268
|
timestamp: stringType().transform((d) => new Date(d)),
|
|
5269
5269
|
data: SubscriptionSchema
|
|
5270
5270
|
});
|
|
5271
|
+
var SubscriptionUpdatedPayloadSchema = objectType({
|
|
5272
|
+
business_id: stringType(),
|
|
5273
|
+
type: literalType("subscription.updated"),
|
|
5274
|
+
timestamp: stringType().transform((d) => new Date(d)),
|
|
5275
|
+
data: SubscriptionSchema
|
|
5276
|
+
});
|
|
5271
5277
|
var LicenseKeyCreatedPayloadSchema = objectType({
|
|
5272
5278
|
business_id: stringType(),
|
|
5273
5279
|
type: literalType("license_key.created"),
|
|
@@ -5296,6 +5302,7 @@ var WebhookPayloadSchema = discriminatedUnionType("type", [
|
|
|
5296
5302
|
SubscriptionCancelledPayloadSchema,
|
|
5297
5303
|
SubscriptionFailedPayloadSchema,
|
|
5298
5304
|
SubscriptionExpiredPayloadSchema,
|
|
5305
|
+
SubscriptionUpdatedPayloadSchema,
|
|
5299
5306
|
LicenseKeyCreatedPayloadSchema
|
|
5300
5307
|
]);
|
|
5301
5308
|
|
|
@@ -6224,6 +6231,9 @@ async function handleWebhookPayload(payload, config, context) {
|
|
|
6224
6231
|
if (payload.type === "subscription.expired") {
|
|
6225
6232
|
await callHandler(config.onSubscriptionExpired, payload);
|
|
6226
6233
|
}
|
|
6234
|
+
if (payload.type === "subscription.updated") {
|
|
6235
|
+
await callHandler(config.onSubscriptionUpdated, payload);
|
|
6236
|
+
}
|
|
6227
6237
|
if (payload.type === "license_key.created") {
|
|
6228
6238
|
await callHandler(config.onLicenseKeyCreated, payload);
|
|
6229
6239
|
}
|