feat: add subscription billing foundation (schema, types, repository) - #674
feat: add subscription billing foundation (schema, types, repository)#674Ferryx349 wants to merge 2 commits into
Conversation
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
🦋 Changeset detectedLatest commit: 2452287 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Adds the initial data-layer foundation for subscription-based relay billing (schema, settings/types, and repositories) without wiring any runtime enforcement or payment flow changes, aligning with the prior “foundation-only” pattern used for invite codes.
Changes:
- Introduces
user_subscriptionspersistence + repository methods for lookup/upsert and future renewal/expiry queries. - Extends invoices with subscription billing fields (
fee_schedule,plan_id,subscription_id,period_start/end) and updates invoice mapping/upsert behavior plus tests. - Adds settings/types/docs support for
payments.subscriptionPlans[]and a changeset for the feature flag groundwork.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/repositories/user-subscription-repository.spec.ts | Adds unit coverage for the new subscription repository behaviors. |
| test/unit/repositories/invoice-repository.spec.ts | Extends invoice repository tests for new subscription-related columns and defaults. |
| src/utils/transform.ts | Maps new invoice DB columns onto the Invoice domain type. |
| src/repositories/user-subscription-repository.ts | New repository implementing subscription CRUD/query primitives. |
| src/repositories/invoice-repository.ts | Adds fee_schedule defaulting and includes new subscription columns in invoice upsert row shape. |
| src/@types/user-subscription.ts | Introduces subscription domain/DB row types and SubscriptionStatus enum. |
| src/@types/settings.ts | Adds subscription plan type definitions to settings schema. |
| src/@types/repositories.ts | Exposes IUserSubscriptionRepository interface. |
| src/@types/invoice.ts | Adds InvoiceFeeSchedule and optional subscription invoice fields. |
| resources/default-settings.yaml | Adds payments.subscriptionPlans default; removes an admin TTL entry (see comment). |
| migrations/20260708_120000_create_subscription_billing_foundation.js | Creates user_subscriptions, adds indexes/FKs, and extends invoices with subscription columns. |
| CONFIGURATION.md | Documents the new payments.subscriptionPlans[] settings surface. |
| .changeset/subscription-billing-foundation.md | Declares a minor release changeset for the new foundation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Description
Groundwork for subscription-based relay billing. Adds database schema, TypeScript types, settings shape, and repository layer only, no enforcement, workers, or payment flow changes. One-time admission billing remains unchanged.
Follows the same pattern as NIP-43 invite codes (#650): migration + types + repository + tests, nothing wired into runtime behavior yet.
Changes
Database
user_subscriptionstable (pubkeyPK, stableidUUID for invoice FK)plan_id,status, period timestamps,grace_until,cancel_at_period_end(status, current_period_end)for future worker queriesinvoiceswith nullable columns:fee_schedule(admission|subscription|publication, defaultadmission)plan_id,subscription_id,period_start,period_endPlans live in settings (
payments.subscriptionPlans[]), not a DB table.Related Issue
Part of :- #673
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: