@adaptware/eagles-db 0.6.15 → 0.6.17
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/client/edge.js +122 -6
- package/client/index-browser.js +119 -3
- package/client/index.d.ts +10788 -437
- package/client/index.js +122 -6
- package/client/package.json +1 -1
- package/client/schema.prisma +219 -1
- package/client/wasm.js +122 -6
- package/package.json +1 -1
- package/prisma/schema/interview.prisma +2 -0
- package/prisma/schema/migrations/20261023120000_payment_mismatch_amount/migration.sql +5 -0
- package/prisma/schema/payment/billingTransaction.prisma +3 -0
package/client/package.json
CHANGED
package/client/schema.prisma
CHANGED
|
@@ -2200,6 +2200,8 @@ model Interview {
|
|
|
2200
2200
|
ai_feedback Json?
|
|
2201
2201
|
human_feedback Json?
|
|
2202
2202
|
interview_preparation Json?
|
|
2203
|
+
/// Excalidraw snapshot flushed from Redis when the interview ends (`WhiteboardInterviewPersistenceService`).
|
|
2204
|
+
whiteboard_scene Json?
|
|
2203
2205
|
final_feedback Json?
|
|
2204
2206
|
interview_analysis_ranges Json?
|
|
2205
2207
|
interview_flow_summary String?
|
|
@@ -3181,6 +3183,212 @@ model LicensingLedgerEntry {
|
|
|
3181
3183
|
@@schema("licensing")
|
|
3182
3184
|
}
|
|
3183
3185
|
|
|
3186
|
+
// Org-level platform subscription: a recurring fee per organisation. Each period is a SubscriptionCharge, paid through
|
|
3187
|
+
// a Razorpay Order (BillingTransaction with transaction_type SUBSCRIPTION); the tax Invoice (kind SUBSCRIPTION) is issued
|
|
3188
|
+
// only once the charge is paid. Prices are all-inclusive (GST and fees are backed out on the invoice). Amounts are minor units.
|
|
3189
|
+
// Plan: docs/eagles-db/platform-subscription-implementation-plan.md.
|
|
3190
|
+
// Design sheet: https://docs.google.com/spreadsheets/d/1R-EBGAMdju_P78Qs05g4_NouSbCM_7W-IyCd8gyZCUI (Sheet2).
|
|
3191
|
+
|
|
3192
|
+
enum BillingCycle {
|
|
3193
|
+
MONTHLY
|
|
3194
|
+
ANNUAL
|
|
3195
|
+
|
|
3196
|
+
@@schema("licensing")
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
enum SubscriptionPlanType {
|
|
3200
|
+
TRIAL
|
|
3201
|
+
REGULAR
|
|
3202
|
+
/// Internal and demo orgs: amount 0, never charged, never PAST_DUE or SUSPENDED.
|
|
3203
|
+
INTERNAL
|
|
3204
|
+
|
|
3205
|
+
@@schema("licensing")
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
enum PlatformSubscriptionStatus {
|
|
3209
|
+
TRIALING
|
|
3210
|
+
ACTIVE
|
|
3211
|
+
/// Grace: charge OPEN until due_at; everyone in the org keeps full access.
|
|
3212
|
+
PAST_DUE
|
|
3213
|
+
/// After due_at (or a trial ending unpaid): only org admins can log in, payment screen only.
|
|
3214
|
+
SUSPENDED
|
|
3215
|
+
CANCELLED
|
|
3216
|
+
|
|
3217
|
+
@@schema("licensing")
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3220
|
+
enum SubscriptionChargeStatus {
|
|
3221
|
+
OPEN
|
|
3222
|
+
PAID
|
|
3223
|
+
VOID
|
|
3224
|
+
|
|
3225
|
+
@@schema("licensing")
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
/// Tells the payment-captured handler what to do: RENEWAL keeps the current record;
|
|
3229
|
+
/// CONVERSION, REACTIVATION and UPGRADE close it and start a new one on the payment day.
|
|
3230
|
+
enum SubscriptionChargeKind {
|
|
3231
|
+
RENEWAL
|
|
3232
|
+
CONVERSION
|
|
3233
|
+
REACTIVATION
|
|
3234
|
+
UPGRADE
|
|
3235
|
+
|
|
3236
|
+
@@schema("licensing")
|
|
3237
|
+
}
|
|
3238
|
+
|
|
3239
|
+
enum SubscriptionAccessAudience {
|
|
3240
|
+
/// Anyone in the suspended org (e.g. candidate-facing flows).
|
|
3241
|
+
ALL_USERS
|
|
3242
|
+
/// Org admins only (e.g. the payment screen).
|
|
3243
|
+
ADMIN_ONLY
|
|
3244
|
+
|
|
3245
|
+
@@schema("licensing")
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
/// Platform fee catalogue, one row per (currency, billing_cycle, type).
|
|
3249
|
+
/// A TRIAL plan has amount 0; trial_days sets the default trial length.
|
|
3250
|
+
/// An INTERNAL plan has amount 0 and is never billed (internal and demo orgs, assigned by org id).
|
|
3251
|
+
/// GST and fee rates come from the platform billing settings, not the plan.
|
|
3252
|
+
model SubscriptionPlan {
|
|
3253
|
+
id String @id @default(uuid())
|
|
3254
|
+
name String
|
|
3255
|
+
/// INR or USD; matched against Organisation.billing_currency.
|
|
3256
|
+
currency String @default("INR")
|
|
3257
|
+
/// All-inclusive price per billing cycle, minor units (1000000 = Rs 10,000): exactly what the org pays.
|
|
3258
|
+
amount Int
|
|
3259
|
+
billing_cycle BillingCycle @default(MONTHLY)
|
|
3260
|
+
type SubscriptionPlanType
|
|
3261
|
+
/// TRIAL plans only: default trial length in days, editable by Super Admin. Null otherwise.
|
|
3262
|
+
trial_days Int?
|
|
3263
|
+
/// Days to pay after a period starts unpaid.
|
|
3264
|
+
grace_days Int @default(7)
|
|
3265
|
+
created_at DateTime @default(now())
|
|
3266
|
+
updated_at DateTime @updatedAt
|
|
3267
|
+
created_by String
|
|
3268
|
+
updated_by String
|
|
3269
|
+
is_active Boolean @default(true)
|
|
3270
|
+
|
|
3271
|
+
subscriptions PlatformSubscription[] @relation("PlatformSubscriptionPlan")
|
|
3272
|
+
pending_downgrades PlatformSubscription[] @relation("PlatformSubscriptionNextPlan")
|
|
3273
|
+
subscription_charges SubscriptionCharge[]
|
|
3274
|
+
|
|
3275
|
+
@@unique([currency, billing_cycle, type])
|
|
3276
|
+
@@map("subscription_plans")
|
|
3277
|
+
@@schema("licensing")
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
/// History of an org's subscription: one record per plan/billing-anchor span.
|
|
3281
|
+
/// The current record has effective_end_date null and current_organisation_id set; the unique constraint on
|
|
3282
|
+
/// current_organisation_id allows at most one current record per org.
|
|
3283
|
+
model PlatformSubscription {
|
|
3284
|
+
id String @id @default(uuid())
|
|
3285
|
+
organisation_id String
|
|
3286
|
+
/// Equals organisation_id on the current record, null once the record is closed. Unique: one current record per org.
|
|
3287
|
+
current_organisation_id String? @unique
|
|
3288
|
+
plan_id String
|
|
3289
|
+
/// Pending downgrade, applied at the next billing date (billing date unchanged). Null when none.
|
|
3290
|
+
next_plan_id String?
|
|
3291
|
+
status PlatformSubscriptionStatus @default(TRIALING)
|
|
3292
|
+
/// Org's all-inclusive fee per billing cycle, minor units; copied from the plan, overridable.
|
|
3293
|
+
amount Int
|
|
3294
|
+
/// Billing anchor: the payment date that started this record (after a trial, after grace, or an
|
|
3295
|
+
/// upgrade). Unchanged when a renewal is paid within grace.
|
|
3296
|
+
effective_start_date DateTime
|
|
3297
|
+
/// Null on the current record; set to the date the next record starts.
|
|
3298
|
+
effective_end_date DateTime?
|
|
3299
|
+
/// TRIAL records only: start + plan.trial_days when the trial starts; Super Admin can change it
|
|
3300
|
+
/// per org. Unpaid at this time: SUSPENDED (no grace after a trial). Null otherwise.
|
|
3301
|
+
trial_ends_at DateTime?
|
|
3302
|
+
/// Copied from the plan.
|
|
3303
|
+
grace_days Int
|
|
3304
|
+
created_at DateTime @default(now())
|
|
3305
|
+
updated_at DateTime @updatedAt
|
|
3306
|
+
created_by String
|
|
3307
|
+
updated_by String
|
|
3308
|
+
is_active Boolean @default(true)
|
|
3309
|
+
|
|
3310
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3311
|
+
plan SubscriptionPlan @relation("PlatformSubscriptionPlan", fields: [plan_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3312
|
+
next_plan SubscriptionPlan? @relation("PlatformSubscriptionNextPlan", fields: [next_plan_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3313
|
+
charges SubscriptionCharge[]
|
|
3314
|
+
|
|
3315
|
+
@@index([organisation_id, effective_end_date])
|
|
3316
|
+
@@index([status, trial_ends_at])
|
|
3317
|
+
@@index([plan_id])
|
|
3318
|
+
@@index([next_plan_id])
|
|
3319
|
+
@@map("platform_subscriptions")
|
|
3320
|
+
@@schema("licensing")
|
|
3321
|
+
}
|
|
3322
|
+
|
|
3323
|
+
/// What the org owes for one billing period, reactivation or upgrade; paid through one Razorpay Order.
|
|
3324
|
+
/// Not a tax invoice: the Invoice (kind SUBSCRIPTION) is issued when the charge is paid and linked via invoice_id.
|
|
3325
|
+
/// Total = subscription_amount + grace_amount - credit_amount (all-inclusive, not stored).
|
|
3326
|
+
model SubscriptionCharge {
|
|
3327
|
+
/// Sent to Razorpay as billing_transactions.purchase_reference (subscription_charge:{id}).
|
|
3328
|
+
id String @id @default(uuid())
|
|
3329
|
+
subscription_id String
|
|
3330
|
+
/// Plan this charge bills for; for an upgrade, the new plan.
|
|
3331
|
+
plan_id String
|
|
3332
|
+
organisation_id String
|
|
3333
|
+
kind SubscriptionChargeKind
|
|
3334
|
+
status SubscriptionChargeStatus @default(OPEN)
|
|
3335
|
+
period_start DateTime
|
|
3336
|
+
period_end DateTime
|
|
3337
|
+
/// period_start + grace_days, end of day in the org's timezone. Unpaid after this: SUSPENDED.
|
|
3338
|
+
due_at DateTime
|
|
3339
|
+
subscription_amount Int
|
|
3340
|
+
/// Prorated days used but not paid: grace days when paid after grace, or days from period_start
|
|
3341
|
+
/// to the upgrade date when upgrading with an OPEN charge (which is voided).
|
|
3342
|
+
grace_amount Int @default(0)
|
|
3343
|
+
/// Upgrade only: prorated unused days of the old plan's paid period.
|
|
3344
|
+
credit_amount Int @default(0)
|
|
3345
|
+
/// Successful payment. No FK: payment-service boundary.
|
|
3346
|
+
billing_transaction_id String? @unique
|
|
3347
|
+
/// Tax invoice issued when the charge was paid.
|
|
3348
|
+
invoice_id String? @unique
|
|
3349
|
+
paid_at DateTime?
|
|
3350
|
+
/// Stops the billing job issuing the same charge twice.
|
|
3351
|
+
idempotency_key String @unique
|
|
3352
|
+
created_at DateTime @default(now())
|
|
3353
|
+
updated_at DateTime @updatedAt
|
|
3354
|
+
created_by String
|
|
3355
|
+
updated_by String
|
|
3356
|
+
|
|
3357
|
+
subscription PlatformSubscription @relation(fields: [subscription_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3358
|
+
plan SubscriptionPlan @relation(fields: [plan_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3359
|
+
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3360
|
+
invoice Invoice? @relation(fields: [invoice_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
|
|
3361
|
+
|
|
3362
|
+
@@index([organisation_id, status])
|
|
3363
|
+
@@index([subscription_id])
|
|
3364
|
+
@@index([plan_id])
|
|
3365
|
+
@@index([status, due_at])
|
|
3366
|
+
@@map("subscription_charges")
|
|
3367
|
+
@@schema("licensing")
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
/// Routes that stay open while an org is SUSPENDED (access level ADMIN_PAYMENT_ONLY).
|
|
3371
|
+
/// Managed by Super Admin; seeded with defaults (auth, payment screen, candidate portal).
|
|
3372
|
+
/// Everything not matched is blocked with 402 SUBSCRIPTION_SUSPENDED.
|
|
3373
|
+
model SubscriptionAccessRule {
|
|
3374
|
+
id String @id @default(uuid())
|
|
3375
|
+
/// API path pattern, `*` wildcard, e.g. /candidate/*.
|
|
3376
|
+
route_pattern String
|
|
3377
|
+
/// GET, POST, ... or * for any method.
|
|
3378
|
+
http_method String @default("*")
|
|
3379
|
+
audience SubscriptionAccessAudience @default(ADMIN_ONLY)
|
|
3380
|
+
description String?
|
|
3381
|
+
created_at DateTime @default(now())
|
|
3382
|
+
updated_at DateTime @updatedAt
|
|
3383
|
+
created_by String
|
|
3384
|
+
updated_by String
|
|
3385
|
+
is_active Boolean @default(true)
|
|
3386
|
+
|
|
3387
|
+
@@unique([route_pattern, http_method])
|
|
3388
|
+
@@map("subscription_access_rules")
|
|
3389
|
+
@@schema("licensing")
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3184
3392
|
/// Historical package purchase by an organisation (independent per transaction).
|
|
3185
3393
|
model PurchasedLicensePackage {
|
|
3186
3394
|
id String @id @default(uuid())
|
|
@@ -3881,6 +4089,8 @@ model Organisation {
|
|
|
3881
4089
|
license_package_organisations LicensePackageOrganisation[]
|
|
3882
4090
|
ai_cost_ledger_entries AiCostLedgerEntry[]
|
|
3883
4091
|
consent_documents ConsentDocument[]
|
|
4092
|
+
platform_subscriptions PlatformSubscription[]
|
|
4093
|
+
subscription_charges SubscriptionCharge[]
|
|
3884
4094
|
billing_transactions BillingTransaction[]
|
|
3885
4095
|
payment_webhook_events PaymentWebhookEvent[]
|
|
3886
4096
|
invoices Invoice[]
|
|
@@ -3923,6 +4133,8 @@ enum BillingTransactionType {
|
|
|
3923
4133
|
PURCHASE
|
|
3924
4134
|
TOP_UP
|
|
3925
4135
|
REFUND
|
|
4136
|
+
/// Platform subscription charge (purchase_reference subscription_charge:{id}).
|
|
4137
|
+
SUBSCRIPTION
|
|
3926
4138
|
|
|
3927
4139
|
@@schema("public")
|
|
3928
4140
|
}
|
|
@@ -3941,6 +4153,9 @@ enum BillingTransactionFailureCategory {
|
|
|
3941
4153
|
enum BillingPaymentMismatchStatus {
|
|
3942
4154
|
DETECTED
|
|
3943
4155
|
UNFULFILLED
|
|
4156
|
+
/// Razorpay captured a different amount or currency than the stored transaction: never applied, never
|
|
4157
|
+
/// recovered or refunded automatically (refund from the Razorpay dashboard).
|
|
4158
|
+
AMOUNT_MISMATCH
|
|
3944
4159
|
|
|
3945
4160
|
@@schema("public")
|
|
3946
4161
|
}
|
|
@@ -3991,11 +4206,13 @@ model BillingTransaction {
|
|
|
3991
4206
|
@@schema("public")
|
|
3992
4207
|
}
|
|
3993
4208
|
|
|
3994
|
-
// Tax invoices issued by Treadspace. Shared by license package purchases and
|
|
4209
|
+
// Tax invoices issued by Treadspace. Shared by license package purchases and platform subscriptions.
|
|
3995
4210
|
|
|
3996
4211
|
/// What the invoice was raised for.
|
|
3997
4212
|
enum InvoiceKind {
|
|
3998
4213
|
PACKAGE
|
|
4214
|
+
/// A paid platform subscription charge (licensing.subscription_charges.invoice_id).
|
|
4215
|
+
SUBSCRIPTION
|
|
3999
4216
|
|
|
4000
4217
|
@@schema("public")
|
|
4001
4218
|
}
|
|
@@ -4042,6 +4259,7 @@ model Invoice {
|
|
|
4042
4259
|
organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict)
|
|
4043
4260
|
billing_transaction BillingTransaction? @relation(fields: [billing_transaction_id], references: [id], onDelete: Restrict)
|
|
4044
4261
|
purchased_license_package PurchasedLicensePackage?
|
|
4262
|
+
subscription_charge SubscriptionCharge?
|
|
4045
4263
|
|
|
4046
4264
|
@@index([organisation_id, issued_at])
|
|
4047
4265
|
@@map("invoices")
|