Add new type definitions to billing/core package
New type definitions have been added to the billing/core package: UpsertOrderParams and UpsertSubscriptionParams. These types were then exported and used in other services, removing duplication and ensuring type consistency across the package. The changes have been reflected in the package.json file of billing/core package.
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./components/*": "./src/components/*",
|
||||
"./schema": "./src/schema/index.ts"
|
||||
"./schema": "./src/schema/index.ts",
|
||||
"./types": "./src/types/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/supabase": "0.1.0",
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
import { Database } from '@kit/supabase/database';
|
||||
|
||||
type UpsertSubscriptionParams =
|
||||
Database['public']['Functions']['upsert_subscription']['Args'];
|
||||
|
||||
type UpsertOrderParams =
|
||||
Database['public']['Functions']['upsert_order']['Args'];
|
||||
import { UpsertOrderParams, UpsertSubscriptionParams } from '../types';
|
||||
|
||||
/**
|
||||
* @name BillingWebhookHandlerService
|
||||
@@ -44,7 +38,7 @@ export abstract class BillingWebhookHandlerService {
|
||||
onPaymentFailed: (sessionId: string) => Promise<unknown>;
|
||||
|
||||
// generic handler for any event
|
||||
onEvent?: (event: string, data: unknown) => Promise<unknown>;
|
||||
onEvent?: <Data>(event: string, data: Data) => Promise<unknown>;
|
||||
},
|
||||
): Promise<unknown>;
|
||||
}
|
||||
|
||||
24
packages/billing/core/src/types/index.ts
Normal file
24
packages/billing/core/src/types/index.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Database } from '@kit/supabase/database';
|
||||
|
||||
type LineItems = Array<{
|
||||
id: string;
|
||||
quantity: number;
|
||||
product_id: string;
|
||||
variant_id: string;
|
||||
price_amount: number;
|
||||
}>;
|
||||
|
||||
export type UpsertSubscriptionParams =
|
||||
Database['public']['Functions']['upsert_subscription']['Args'] & {
|
||||
line_items: LineItems & {
|
||||
interval: string;
|
||||
subscription_id: string;
|
||||
interval_count: number;
|
||||
type: 'per_seat' | 'flat' | 'metered';
|
||||
};
|
||||
};
|
||||
|
||||
export type UpsertOrderParams =
|
||||
Database['public']['Functions']['upsert_order']['Args'] & {
|
||||
line_items: LineItems;
|
||||
};
|
||||
Reference in New Issue
Block a user