11import { Database , and , eq , sql } from "../src/drizzle/index.js"
22import { AuthTable } from "../src/schema/auth.sql.js"
33import { UserTable } from "../src/schema/user.sql.js"
4- import { BillingTable , PaymentTable , SubscriptionTable , BlackPlans , UsageTable } from "../src/schema/billing.sql.js"
4+ import {
5+ BillingTable ,
6+ PaymentTable ,
7+ SubscriptionTable ,
8+ BlackPlans ,
9+ UsageTable ,
10+ LiteTable ,
11+ } from "../src/schema/billing.sql.js"
512import { WorkspaceTable } from "../src/schema/workspace.sql.js"
613import { KeyTable } from "../src/schema/key.sql.js"
714import { BlackData } from "../src/black.js"
@@ -72,19 +79,22 @@ else {
7279 workspaceID : UserTable . workspaceID ,
7380 workspaceName : WorkspaceTable . name ,
7481 role : UserTable . role ,
75- subscribed : SubscriptionTable . timeCreated ,
82+ black : SubscriptionTable . timeCreated ,
83+ lite : LiteTable . timeCreated ,
7684 } )
7785 . from ( UserTable )
7886 . rightJoin ( WorkspaceTable , eq ( WorkspaceTable . id , UserTable . workspaceID ) )
7987 . leftJoin ( SubscriptionTable , eq ( SubscriptionTable . userID , UserTable . id ) )
88+ . leftJoin ( LiteTable , eq ( LiteTable . userID , UserTable . id ) )
8089 . where ( eq ( UserTable . accountID , accountID ) )
8190 . then ( ( rows ) =>
8291 rows . map ( ( row ) => ( {
8392 userID : row . userID ,
8493 workspaceID : row . workspaceID ,
8594 workspaceName : row . workspaceName ,
8695 role : row . role ,
87- subscribed : formatDate ( row . subscribed ) ,
96+ black : formatDate ( row . black ) ,
97+ lite : formatDate ( row . lite ) ,
8898 } ) ) ,
8999 ) ,
90100 )
@@ -151,13 +161,14 @@ async function printWorkspace(workspaceID: string) {
151161 balance : BillingTable . balance ,
152162 customerID : BillingTable . customerID ,
153163 reload : BillingTable . reload ,
154- subscriptionID : BillingTable . subscriptionID ,
155- subscription : {
164+ blackSubscriptionID : BillingTable . subscriptionID ,
165+ blackSubscription : {
156166 plan : BillingTable . subscriptionPlan ,
157167 booked : BillingTable . timeSubscriptionBooked ,
158168 enrichment : BillingTable . subscription ,
159169 } ,
160- timeSubscriptionSelected : BillingTable . timeSubscriptionSelected ,
170+ timeBlackSubscriptionSelected : BillingTable . timeSubscriptionSelected ,
171+ liteSubscriptionID : BillingTable . liteSubscriptionID ,
161172 } )
162173 . from ( BillingTable )
163174 . where ( eq ( BillingTable . workspaceID , workspace . id ) )
@@ -167,16 +178,21 @@ async function printWorkspace(workspaceID: string) {
167178 balance : `$${ ( row . balance / 100000000 ) . toFixed ( 2 ) } ` ,
168179 reload : row . reload ? "yes" : "no" ,
169180 customerID : row . customerID ,
170- subscriptionID : row . subscriptionID ,
171- subscription : row . subscriptionID
181+ liteSubscriptionID : row . liteSubscriptionID ,
182+ blackSubscriptionID : row . blackSubscriptionID ,
183+ blackSubscription : row . blackSubscriptionID
172184 ? [
173- `Black ${ row . subscription . enrichment ! . plan } ` ,
174- row . subscription . enrichment ! . seats > 1 ? `X ${ row . subscription . enrichment ! . seats } seats` : "" ,
175- row . subscription . enrichment ! . coupon ? `(coupon: ${ row . subscription . enrichment ! . coupon } )` : "" ,
176- `(ref: ${ row . subscriptionID } )` ,
185+ `Black ${ row . blackSubscription . enrichment ! . plan } ` ,
186+ row . blackSubscription . enrichment ! . seats > 1
187+ ? `X ${ row . blackSubscription . enrichment ! . seats } seats`
188+ : "" ,
189+ row . blackSubscription . enrichment ! . coupon
190+ ? `(coupon: ${ row . blackSubscription . enrichment ! . coupon } )`
191+ : "" ,
192+ `(ref: ${ row . blackSubscriptionID } )` ,
177193 ] . join ( " " )
178- : row . subscription . booked
179- ? `Waitlist ${ row . subscription . plan } plan${ row . timeSubscriptionSelected ? " (selected)" : "" } `
194+ : row . blackSubscription . booked
195+ ? `Waitlist ${ row . blackSubscription . plan } plan${ row . timeBlackSubscriptionSelected ? " (selected)" : "" } `
180196 : undefined ,
181197 } ) ) [ 0 ] ,
182198 ) ,
0 commit comments