@raideno/convex-stripe 0.2.5 → 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/dist/index.d.ts +13 -1
- package/dist/server.js +16 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,6 @@ declare const CreateAccountImplementation: {
|
|
|
47
47
|
name: string;
|
|
48
48
|
handler: (context: GenericActionCtx<StripeDataModel>, args: {
|
|
49
49
|
entityId: string;
|
|
50
|
-
type: "express" | "custom";
|
|
51
50
|
} & Omit<default_2.AccountCreateParams, "type">, stripeOptions: default_2.RequestOptions, configuration: InternalConfiguration, options: InternalOptions) => Promise<{
|
|
52
51
|
_id: GenericId<"stripeAccounts">;
|
|
53
52
|
_creationTime: number;
|
|
@@ -165,6 +164,8 @@ declare const CreateCustomerImplementation: {
|
|
|
165
164
|
|
|
166
165
|
export declare function defineRedirectHandler<const T extends readonly string[], S extends ArgSchema = {}>(handler: RedirectHandler<T, S>): RedirectHandler<T, S>;
|
|
167
166
|
|
|
167
|
+
export declare function defineWebhookHandler<const T extends default_2.Event.Type>(handler: WebhookHandler<T>): WebhookHandler<T>;
|
|
168
|
+
|
|
168
169
|
declare type InferArgs<S extends ArgSchema> = {
|
|
169
170
|
[K in keyof S as S[K] extends Validator<any, "required", any> ? K : never]: Infer<S[K]>;
|
|
170
171
|
} & {
|
|
@@ -242,6 +243,10 @@ export declare interface InputConfiguration {
|
|
|
242
243
|
* Document your intended behavior here.
|
|
243
244
|
*/
|
|
244
245
|
detached?: boolean;
|
|
246
|
+
webhook?: {
|
|
247
|
+
/** Optional additional webhook handlers to handle custom Stripe events or override default behavior. */
|
|
248
|
+
handlers?: Array<ReturnType<typeof defineWebhookHandler>>;
|
|
249
|
+
};
|
|
245
250
|
redirect?: {
|
|
246
251
|
/** TTL for redirect state (ms). */
|
|
247
252
|
ttlMs?: number;
|
|
@@ -9051,4 +9056,11 @@ export declare const syncAllTablesExcept: (tables: Array<keyof typeof stripeTabl
|
|
|
9051
9056
|
|
|
9052
9057
|
export declare const syncOnlyTables: (tables: Array<keyof typeof stripeTables>) => Record<keyof typeof stripeTables, boolean>;
|
|
9053
9058
|
|
|
9059
|
+
declare type WebhookHandler<TEvents extends default_2.Event.Type> = {
|
|
9060
|
+
events: readonly TEvents[];
|
|
9061
|
+
handle: (event_: Extract<default_2.Event, {
|
|
9062
|
+
type: TEvents;
|
|
9063
|
+
}>, context: GenericActionCtx<StripeDataModel>, configuration: InternalConfiguration, options: InternalOptions) => Promise<void>;
|
|
9064
|
+
};
|
|
9065
|
+
|
|
9054
9066
|
export { }
|
package/dist/server.js
CHANGED
|
@@ -5632,6 +5632,9 @@ const DEFAULT_CONFIGURATION = {
|
|
|
5632
5632
|
ttlMs: 15 * 60 * 1e3,
|
|
5633
5633
|
handlers: []
|
|
5634
5634
|
},
|
|
5635
|
+
webhook: {
|
|
5636
|
+
handlers: []
|
|
5637
|
+
},
|
|
5635
5638
|
detached: false,
|
|
5636
5639
|
callbacks: {
|
|
5637
5640
|
afterChange: async () => {
|
|
@@ -9482,6 +9485,18 @@ const webhookImplementation = async (configuration, options, context, request, c
|
|
|
9482
9485
|
}
|
|
9483
9486
|
}
|
|
9484
9487
|
}
|
|
9488
|
+
for (const handler of configuration.webhook.handlers) {
|
|
9489
|
+
if (handler.events.includes(event.type)) {
|
|
9490
|
+
try {
|
|
9491
|
+
await handler.handle(event, context, configuration, options);
|
|
9492
|
+
options.logger.debug(`[STRIPE HOOK](HANDLED BY CONFIG): ${event.type}`);
|
|
9493
|
+
} catch (error) {
|
|
9494
|
+
options.logger.error(
|
|
9495
|
+
`[STRIPE HOOK](Error in config handler): ${error}`
|
|
9496
|
+
);
|
|
9497
|
+
}
|
|
9498
|
+
}
|
|
9499
|
+
}
|
|
9485
9500
|
return new Response("OK", { status: 200 });
|
|
9486
9501
|
};
|
|
9487
9502
|
const SyncAccountWebhookImplementation = defineActionImplementation({
|
|
@@ -9870,6 +9885,7 @@ export {
|
|
|
9870
9885
|
Logger,
|
|
9871
9886
|
buildSignedReturnUrl,
|
|
9872
9887
|
defineRedirectHandler,
|
|
9888
|
+
defineWebhookHandler,
|
|
9873
9889
|
internalConvexStripe,
|
|
9874
9890
|
stripeTables,
|
|
9875
9891
|
syncAllTables,
|