@adonis-agora/payments 0.2.0 → 0.3.0
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/CHANGELOG.md +2347 -0
- package/dist/assets/spa/assets/index-CT5Zon6P.css +1 -0
- package/dist/assets/spa/assets/index-CvEbJEnq.js +41 -0
- package/dist/assets/spa/assets/index-CvEbJEnq.js.map +1 -0
- package/dist/assets/spa/index.html +20 -0
- package/dist/commands/main.d.ts +4 -3
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +9 -2
- package/dist/commands/main.js.map +1 -1
- package/dist/commands/payments_health.d.ts +31 -0
- package/dist/commands/payments_health.d.ts.map +1 -0
- package/dist/commands/payments_health.js +113 -0
- package/dist/commands/payments_health.js.map +1 -0
- package/dist/commands/payments_sync.d.ts +18 -4
- package/dist/commands/payments_sync.d.ts.map +1 -1
- package/dist/commands/payments_sync.js +136 -40
- package/dist/commands/payments_sync.js.map +1 -1
- package/dist/configure.d.ts +12 -5
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +18 -5
- package/dist/configure.js.map +1 -1
- package/dist/providers/dashboard_provider.d.ts +97 -0
- package/dist/providers/dashboard_provider.d.ts.map +1 -0
- package/dist/providers/dashboard_provider.js +430 -0
- package/dist/providers/dashboard_provider.js.map +1 -0
- package/dist/providers/payments_client_provider.d.ts +41 -0
- package/dist/providers/payments_client_provider.d.ts.map +1 -0
- package/dist/providers/payments_client_provider.js +95 -0
- package/dist/providers/payments_client_provider.js.map +1 -0
- package/dist/providers/payments_provider.d.ts +35 -0
- package/dist/providers/payments_provider.d.ts.map +1 -1
- package/dist/providers/payments_provider.js +250 -36
- package/dist/providers/payments_provider.js.map +1 -1
- package/dist/src/billing/billing_health.d.ts +85 -0
- package/dist/src/billing/billing_health.d.ts.map +1 -0
- package/dist/src/billing/billing_health.js +155 -0
- package/dist/src/billing/billing_health.js.map +1 -0
- package/dist/src/billing/billing_overview.d.ts +4 -3
- package/dist/src/billing/billing_overview.d.ts.map +1 -1
- package/dist/src/billing/billing_overview.js +14 -5
- package/dist/src/billing/billing_overview.js.map +1 -1
- package/dist/src/billing/billing_store.d.ts +634 -5
- package/dist/src/billing/billing_store.d.ts.map +1 -1
- package/dist/src/billing/billing_store.js +18 -1
- package/dist/src/billing/billing_store.js.map +1 -1
- package/dist/src/billing/index.d.ts +2 -1
- package/dist/src/billing/index.d.ts.map +1 -1
- package/dist/src/billing/index.js +1 -0
- package/dist/src/billing/index.js.map +1 -1
- package/dist/src/billing/list_query.d.ts +16 -0
- package/dist/src/billing/list_query.d.ts.map +1 -0
- package/dist/src/billing/list_query.js +28 -0
- package/dist/src/billing/list_query.js.map +1 -0
- package/dist/src/billing/lucid_billing_store.d.ts +122 -4
- package/dist/src/billing/lucid_billing_store.d.ts.map +1 -1
- package/dist/src/billing/lucid_billing_store.js +811 -13
- package/dist/src/billing/lucid_billing_store.js.map +1 -1
- package/dist/src/billing/mixins/index.d.ts +3 -0
- package/dist/src/billing/mixins/index.d.ts.map +1 -1
- package/dist/src/billing/mixins/index.js +3 -0
- package/dist/src/billing/mixins/index.js.map +1 -1
- package/dist/src/billing/mixins/with_audit_event.d.ts +48 -0
- package/dist/src/billing/mixins/with_audit_event.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_audit_event.js +77 -0
- package/dist/src/billing/mixins/with_audit_event.js.map +1 -0
- package/dist/src/billing/mixins/with_customer.d.ts +39 -0
- package/dist/src/billing/mixins/with_customer.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_customer.js +68 -0
- package/dist/src/billing/mixins/with_customer.js.map +1 -0
- package/dist/src/billing/mixins/with_dispute.d.ts +68 -0
- package/dist/src/billing/mixins/with_dispute.d.ts.map +1 -0
- package/dist/src/billing/mixins/with_dispute.js +83 -0
- package/dist/src/billing/mixins/with_dispute.js.map +1 -0
- package/dist/src/billing/mixins/with_payment.d.ts +42 -0
- package/dist/src/billing/mixins/with_payment.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_payment.js +29 -3
- package/dist/src/billing/mixins/with_payment.js.map +1 -1
- package/dist/src/billing/mixins/with_subscription.d.ts +7 -0
- package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_subscription.js +15 -1
- package/dist/src/billing/mixins/with_subscription.js.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.d.ts +7 -0
- package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_usage_event.js +15 -1
- package/dist/src/billing/mixins/with_usage_event.js.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.d.ts +18 -0
- package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -1
- package/dist/src/billing/mixins/with_webhook_event.js +18 -1
- package/dist/src/billing/mixins/with_webhook_event.js.map +1 -1
- package/dist/src/billing/resolve_dispatch.d.ts +22 -0
- package/dist/src/billing/resolve_dispatch.d.ts.map +1 -0
- package/dist/src/billing/resolve_dispatch.js +44 -0
- package/dist/src/billing/resolve_dispatch.js.map +1 -0
- package/dist/src/billing/resolve_store.d.ts +18 -0
- package/dist/src/billing/resolve_store.d.ts.map +1 -0
- package/dist/src/billing/resolve_store.js +35 -0
- package/dist/src/billing/resolve_store.js.map +1 -0
- package/dist/src/billing/schema.d.ts +108 -0
- package/dist/src/billing/schema.d.ts.map +1 -0
- package/dist/src/billing/schema.js +350 -0
- package/dist/src/billing/schema.js.map +1 -0
- package/dist/src/billing/webhook_dispatcher.d.ts +95 -16
- package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -1
- package/dist/src/billing/webhook_dispatcher.js +186 -33
- package/dist/src/billing/webhook_dispatcher.js.map +1 -1
- package/dist/src/billing/webhook_events.d.ts +67 -1
- package/dist/src/billing/webhook_events.d.ts.map +1 -1
- package/dist/src/billing/webhook_events.js +15 -0
- package/dist/src/billing/webhook_events.js.map +1 -1
- package/dist/src/billing/webhook_processor.d.ts.map +1 -1
- package/dist/src/billing/webhook_processor.js +325 -5
- package/dist/src/billing/webhook_processor.js.map +1 -1
- package/dist/src/client/define_config.d.ts +150 -0
- package/dist/src/client/define_config.d.ts.map +1 -0
- package/dist/src/client/define_config.js +98 -0
- package/dist/src/client/define_config.js.map +1 -0
- package/dist/src/client/handlers.d.ts +71 -0
- package/dist/src/client/handlers.d.ts.map +1 -0
- package/dist/src/client/handlers.js +119 -0
- package/dist/src/client/handlers.js.map +1 -0
- package/dist/src/client/index.d.ts +16 -0
- package/dist/src/client/index.d.ts.map +1 -0
- package/dist/src/client/index.js +13 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/statuses.d.ts +38 -0
- package/dist/src/client/statuses.d.ts.map +1 -0
- package/dist/src/client/statuses.js +42 -0
- package/dist/src/client/statuses.js.map +1 -0
- package/dist/src/dashboard/actions.d.ts +143 -0
- package/dist/src/dashboard/actions.d.ts.map +1 -0
- package/dist/src/dashboard/actions.js +112 -0
- package/dist/src/dashboard/actions.js.map +1 -0
- package/dist/src/dashboard/auth.d.ts +136 -0
- package/dist/src/dashboard/auth.d.ts.map +1 -0
- package/dist/src/dashboard/auth.js +152 -0
- package/dist/src/dashboard/auth.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +80 -0
- package/dist/src/dashboard/define_config.d.ts.map +1 -0
- package/dist/src/dashboard/define_config.js +83 -0
- package/dist/src/dashboard/define_config.js.map +1 -0
- package/dist/src/dashboard/handlers.d.ts +281 -0
- package/dist/src/dashboard/handlers.d.ts.map +1 -0
- package/dist/src/dashboard/handlers.js +960 -0
- package/dist/src/dashboard/handlers.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +18 -0
- package/dist/src/dashboard/index.d.ts.map +1 -0
- package/dist/src/dashboard/index.js +14 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/login_page.d.ts +23 -0
- package/dist/src/dashboard/login_page.d.ts.map +1 -0
- package/dist/src/dashboard/login_page.js +170 -0
- package/dist/src/dashboard/login_page.js.map +1 -0
- package/dist/src/dashboard/period.d.ts +31 -0
- package/dist/src/dashboard/period.d.ts.map +1 -0
- package/dist/src/dashboard/period.js +44 -0
- package/dist/src/dashboard/period.js.map +1 -0
- package/dist/src/dashboard/session_cookie.d.ts +42 -0
- package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
- package/dist/src/dashboard/session_cookie.js +97 -0
- package/dist/src/dashboard/session_cookie.js.map +1 -0
- package/dist/src/dashboard/spa.d.ts +24 -0
- package/dist/src/dashboard/spa.d.ts.map +1 -0
- package/dist/src/dashboard/spa.js +52 -0
- package/dist/src/dashboard/spa.js.map +1 -0
- package/dist/src/define_config.d.ts +244 -9
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +97 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/diagnostics.d.ts +287 -7
- package/dist/src/diagnostics.d.ts.map +1 -1
- package/dist/src/diagnostics.js +317 -1
- package/dist/src/diagnostics.js.map +1 -1
- package/dist/src/driver.d.ts +139 -5
- package/dist/src/driver.d.ts.map +1 -1
- package/dist/src/drivers/abacate.d.ts +12 -2
- package/dist/src/drivers/abacate.d.ts.map +1 -1
- package/dist/src/drivers/abacate.js +112 -19
- package/dist/src/drivers/abacate.js.map +1 -1
- package/dist/src/drivers/adyen.d.ts +164 -0
- package/dist/src/drivers/adyen.d.ts.map +1 -0
- package/dist/src/drivers/adyen.js +678 -0
- package/dist/src/drivers/adyen.js.map +1 -0
- package/dist/src/drivers/asaas.d.ts +52 -2
- package/dist/src/drivers/asaas.d.ts.map +1 -1
- package/dist/src/drivers/asaas.js +364 -29
- package/dist/src/drivers/asaas.js.map +1 -1
- package/dist/src/drivers/dodo.d.ts +135 -0
- package/dist/src/drivers/dodo.d.ts.map +1 -0
- package/dist/src/drivers/dodo.js +864 -0
- package/dist/src/drivers/dodo.js.map +1 -0
- package/dist/src/drivers/efi.d.ts +98 -0
- package/dist/src/drivers/efi.d.ts.map +1 -0
- package/dist/src/drivers/efi.js +628 -0
- package/dist/src/drivers/efi.js.map +1 -0
- package/dist/src/drivers/infinitepay.d.ts +156 -0
- package/dist/src/drivers/infinitepay.d.ts.map +1 -0
- package/dist/src/drivers/infinitepay.js +321 -0
- package/dist/src/drivers/infinitepay.js.map +1 -0
- package/dist/src/drivers/lemonsqueezy.d.ts +125 -0
- package/dist/src/drivers/lemonsqueezy.d.ts.map +1 -0
- package/dist/src/drivers/lemonsqueezy.js +632 -0
- package/dist/src/drivers/lemonsqueezy.js.map +1 -0
- package/dist/src/drivers/mercadopago.d.ts +97 -0
- package/dist/src/drivers/mercadopago.d.ts.map +1 -0
- package/dist/src/drivers/mercadopago.js +844 -0
- package/dist/src/drivers/mercadopago.js.map +1 -0
- package/dist/src/drivers/mollie.d.ts +125 -0
- package/dist/src/drivers/mollie.d.ts.map +1 -0
- package/dist/src/drivers/mollie.js +812 -0
- package/dist/src/drivers/mollie.js.map +1 -0
- package/dist/src/drivers/paddle.d.ts +148 -0
- package/dist/src/drivers/paddle.d.ts.map +1 -0
- package/dist/src/drivers/paddle.js +738 -0
- package/dist/src/drivers/paddle.js.map +1 -0
- package/dist/src/drivers/pagarme.d.ts +97 -0
- package/dist/src/drivers/pagarme.d.ts.map +1 -0
- package/dist/src/drivers/pagarme.js +829 -0
- package/dist/src/drivers/pagarme.js.map +1 -0
- package/dist/src/drivers/pagbank.d.ts +57 -0
- package/dist/src/drivers/pagbank.d.ts.map +1 -0
- package/dist/src/drivers/pagbank.js +499 -0
- package/dist/src/drivers/pagbank.js.map +1 -0
- package/dist/src/drivers/paypal.d.ts +120 -0
- package/dist/src/drivers/paypal.d.ts.map +1 -0
- package/dist/src/drivers/paypal.js +891 -0
- package/dist/src/drivers/paypal.js.map +1 -0
- package/dist/src/drivers/polar.d.ts +118 -0
- package/dist/src/drivers/polar.d.ts.map +1 -0
- package/dist/src/drivers/polar.js +604 -0
- package/dist/src/drivers/polar.js.map +1 -0
- package/dist/src/drivers/razorpay.d.ts +103 -0
- package/dist/src/drivers/razorpay.d.ts.map +1 -0
- package/dist/src/drivers/razorpay.js +867 -0
- package/dist/src/drivers/razorpay.js.map +1 -0
- package/dist/src/drivers/shared.d.ts +33 -0
- package/dist/src/drivers/shared.d.ts.map +1 -0
- package/dist/src/drivers/shared.js +37 -0
- package/dist/src/drivers/shared.js.map +1 -0
- package/dist/src/drivers/square.d.ts +133 -0
- package/dist/src/drivers/square.d.ts.map +1 -0
- package/dist/src/drivers/square.js +905 -0
- package/dist/src/drivers/square.js.map +1 -0
- package/dist/src/drivers/stripe.d.ts +40 -3
- package/dist/src/drivers/stripe.d.ts.map +1 -1
- package/dist/src/drivers/stripe.js +806 -25
- package/dist/src/drivers/stripe.js.map +1 -1
- package/dist/src/drivers/woovi.d.ts +10 -3
- package/dist/src/drivers/woovi.d.ts.map +1 -1
- package/dist/src/drivers/woovi.js +162 -29
- package/dist/src/drivers/woovi.js.map +1 -1
- package/dist/src/ensure_customer.d.ts +34 -1
- package/dist/src/ensure_customer.d.ts.map +1 -1
- package/dist/src/ensure_customer.js +29 -4
- package/dist/src/ensure_customer.js.map +1 -1
- package/dist/src/http.d.ts +37 -3
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +69 -5
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +40 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/invoice/emit_invoice.d.ts.map +1 -1
- package/dist/src/invoice/emit_invoice.js +31 -11
- package/dist/src/invoice/emit_invoice.js.map +1 -1
- package/dist/src/money.d.ts +23 -5
- package/dist/src/money.d.ts.map +1 -1
- package/dist/src/money.js +72 -7
- package/dist/src/money.js.map +1 -1
- package/dist/src/payments_manager.d.ts +8 -1
- package/dist/src/payments_manager.d.ts.map +1 -1
- package/dist/src/payments_manager.js +168 -6
- package/dist/src/payments_manager.js.map +1 -1
- package/dist/src/services/main.d.ts +38 -0
- package/dist/src/services/main.d.ts.map +1 -1
- package/dist/src/services/main.js +130 -0
- package/dist/src/services/main.js.map +1 -1
- package/dist/src/telescope/index.d.ts +2 -0
- package/dist/src/telescope/index.d.ts.map +1 -1
- package/dist/src/telescope/index.js +1 -0
- package/dist/src/telescope/index.js.map +1 -1
- package/dist/src/telescope/payments_watcher.d.ts +10 -4
- package/dist/src/telescope/payments_watcher.d.ts.map +1 -1
- package/dist/src/telescope/payments_watcher.js +65 -13
- package/dist/src/telescope/payments_watcher.js.map +1 -1
- package/dist/src/telescope/register.d.ts +62 -0
- package/dist/src/telescope/register.d.ts.map +1 -0
- package/dist/src/telescope/register.js +48 -0
- package/dist/src/telescope/register.js.map +1 -0
- package/dist/src/testing/fake_payments.d.ts +62 -0
- package/dist/src/testing/fake_payments.d.ts.map +1 -0
- package/dist/src/testing/fake_payments.js +82 -0
- package/dist/src/testing/fake_payments.js.map +1 -0
- package/dist/src/testing/in_memory_billing_store.d.ts +151 -2
- package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -1
- package/dist/src/testing/in_memory_billing_store.js +517 -4
- package/dist/src/testing/in_memory_billing_store.js.map +1 -1
- package/dist/src/testing/index.d.ts +2 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +1 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/types.d.ts +161 -5
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +30 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/webhook_handlers.d.ts +96 -2
- package/dist/src/webhook_handlers.d.ts.map +1 -1
- package/dist/src/webhook_handlers.js +91 -10
- package/dist/src/webhook_handlers.js.map +1 -1
- package/dist/src/webhook_security.d.ts +94 -3
- package/dist/src/webhook_security.d.ts.map +1 -1
- package/dist/src/webhook_security.js +173 -9
- package/dist/src/webhook_security.js.map +1 -1
- package/dist/stubs/config/payments.stub +13 -0
- package/dist/stubs/config/payments_client.stub +42 -0
- package/dist/stubs/config/payments_dashboard.stub +38 -0
- package/dist/stubs/database/migrations/create_billing_tables.stub +35 -77
- package/dist/stubs/make/webhook_handler/main.stub +29 -11
- package/package.json +60 -25
|
@@ -4,13 +4,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
8
9
|
/**
|
|
9
10
|
* The Lucid model backing the `billing_payments` table. Mirrors the gateway payment —
|
|
10
11
|
* kept locally so webhook processing and the app can query payment history without
|
|
11
12
|
* calling the gateway API.
|
|
12
13
|
*/
|
|
13
14
|
export class BillingPayment extends BaseModel {
|
|
15
|
+
/**
|
|
16
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
17
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
18
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
19
|
+
* — and means an app that already ran the migration needs no new one.
|
|
20
|
+
*/
|
|
21
|
+
static assignUuid(row) {
|
|
22
|
+
if (!row.id)
|
|
23
|
+
row.id = randomUUID();
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
26
|
__decorate([
|
|
16
27
|
column({ isPrimary: true })
|
|
@@ -25,7 +36,7 @@ __decorate([
|
|
|
25
36
|
column()
|
|
26
37
|
], BillingPayment.prototype, "status", void 0);
|
|
27
38
|
__decorate([
|
|
28
|
-
column()
|
|
39
|
+
column({ consume: (value) => (value === null ? null : Number(value)) })
|
|
29
40
|
], BillingPayment.prototype, "amount", void 0);
|
|
30
41
|
__decorate([
|
|
31
42
|
column()
|
|
@@ -36,6 +47,12 @@ __decorate([
|
|
|
36
47
|
__decorate([
|
|
37
48
|
column({ serializeAs: null })
|
|
38
49
|
], BillingPayment.prototype, "subscriptionId", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
column()
|
|
52
|
+
], BillingPayment.prototype, "externalReference", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
column({ consume: (value) => (value === null ? null : Number(value)) })
|
|
55
|
+
], BillingPayment.prototype, "refundedAmount", void 0);
|
|
39
56
|
__decorate([
|
|
40
57
|
column({ serializeAs: null })
|
|
41
58
|
], BillingPayment.prototype, "payload", void 0);
|
|
@@ -48,6 +65,9 @@ __decorate([
|
|
|
48
65
|
__decorate([
|
|
49
66
|
column.dateTime({ serializeAs: null })
|
|
50
67
|
], BillingPayment.prototype, "paidAt", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
beforeCreate()
|
|
70
|
+
], BillingPayment, "assignUuid", null);
|
|
51
71
|
/**
|
|
52
72
|
* Mixin to attach payment columns to a custom model.
|
|
53
73
|
*/
|
|
@@ -65,7 +85,7 @@ export function withPayment() {
|
|
|
65
85
|
column()
|
|
66
86
|
], PaymentMixin.prototype, "status", void 0);
|
|
67
87
|
__decorate([
|
|
68
|
-
column()
|
|
88
|
+
column({ consume: (value) => (value === null ? null : Number(value)) })
|
|
69
89
|
], PaymentMixin.prototype, "amount", void 0);
|
|
70
90
|
__decorate([
|
|
71
91
|
column()
|
|
@@ -76,6 +96,12 @@ export function withPayment() {
|
|
|
76
96
|
__decorate([
|
|
77
97
|
column({ serializeAs: null })
|
|
78
98
|
], PaymentMixin.prototype, "subscriptionId", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
column()
|
|
101
|
+
], PaymentMixin.prototype, "externalReference", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
column({ consume: (value) => (value === null ? null : Number(value)) })
|
|
104
|
+
], PaymentMixin.prototype, "refundedAmount", void 0);
|
|
79
105
|
__decorate([
|
|
80
106
|
column({ serializeAs: null })
|
|
81
107
|
], PaymentMixin.prototype, "payload", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_payment.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_payment.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"with_payment.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_payment.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;IAC3C;;;;;OAKG;IAEI,AAAP,MAAM,CAAC,UAAU,CAAC,GAAmB;QACnC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,CAAC;CA0EF;AAvES;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;0CACT;AAIX;IADP,MAAM,EAAE;iDACiB;AAGlB;IADP,MAAM,EAAE;gDACgB;AAGjB;IADP,MAAM,EAAE;8CACc;AAYf;IADP,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;8CAC1D;AAGf;IADP,MAAM,EAAE;gDACgB;AAGjB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;kDACI;AAG1B;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;sDACQ;AAW9B;IADP,MAAM,EAAE;yDACgC;AAgBjC;IADP,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;sDAC3C;AAG9B;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;+CACW;AAGjC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;iDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;iDAC5B;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8CACP;AA3EzB;IADN,YAAY,EAAE;sCAGd;AAkGH;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,CACL,UAAiB,EACS,EAAE;QAC5B,MAAM,YAAa,SAAQ,UAAU;SA0CpC;QAxCS;YADP,MAAM,EAAE;uDACiB;QAGlB;YADP,MAAM,EAAE;sDACgB;QAGjB;YADP,MAAM,EAAE;oDACc;QAIf;YADP,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oDAC1D;QAGf;YADP,MAAM,EAAE;sDACgB;QAGjB;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;wDACI;QAG1B;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;4DACQ;QAI9B;YADP,MAAM,EAAE;+DACgC;QAIjC;YADP,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;4DAC3C;QAG9B;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;qDACW;QAGjC;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uDACV;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uDAC5B;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACP;QAElC,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -8,6 +8,13 @@ import type { DateTime } from 'luxon';
|
|
|
8
8
|
* model. Stores resolve it through the config (`billing.subscriptionModel`).
|
|
9
9
|
*/
|
|
10
10
|
export declare class BillingSubscription extends BaseModel {
|
|
11
|
+
/**
|
|
12
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
13
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
14
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
15
|
+
* — and means an app that already ran the migration needs no new one.
|
|
16
|
+
*/
|
|
17
|
+
static assignUuid(row: BillingSubscription): void;
|
|
11
18
|
id: string;
|
|
12
19
|
/** Gateway subscription id (Stripe `sub_...`, Asaas `sub_...`, Woovi `globalID`). */
|
|
13
20
|
gatewayId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_subscription.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with_subscription.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD;;;;;OAKG;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI;IAKzC,EAAE,EAAE,MAAM,CAAC;IAEnB,qFAAqF;IAE7E,SAAS,EAAE,MAAM,CAAC;IAGlB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,MAAM,CAAC;IAGf,UAAU,EAAE,MAAM,CAAC;IAGnB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG7B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAGxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGjC,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;CAC7B;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,CAAC,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,IAAI,KAAK,GAAG;IACjG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,KACtB,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,EAC1D,YAAY,KAAK,KAChB,sBAAsB,CAAC,KAAK,CAAC,CAkCjC"}
|
|
@@ -4,7 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
8
9
|
/**
|
|
9
10
|
* The Lucid model backing the `billing_subscriptions` table.
|
|
10
11
|
*
|
|
@@ -12,6 +13,16 @@ import { BaseModel, column } from '@adonisjs/lucid/orm';
|
|
|
12
13
|
* model. Stores resolve it through the config (`billing.subscriptionModel`).
|
|
13
14
|
*/
|
|
14
15
|
export class BillingSubscription extends BaseModel {
|
|
16
|
+
/**
|
|
17
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
18
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
19
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
20
|
+
* — and means an app that already ran the migration needs no new one.
|
|
21
|
+
*/
|
|
22
|
+
static assignUuid(row) {
|
|
23
|
+
if (!row.id)
|
|
24
|
+
row.id = randomUUID();
|
|
25
|
+
}
|
|
15
26
|
}
|
|
16
27
|
__decorate([
|
|
17
28
|
column({ isPrimary: true })
|
|
@@ -46,6 +57,9 @@ __decorate([
|
|
|
46
57
|
__decorate([
|
|
47
58
|
column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
48
59
|
], BillingSubscription.prototype, "updatedAt", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
beforeCreate()
|
|
62
|
+
], BillingSubscription, "assignUuid", null);
|
|
49
63
|
/**
|
|
50
64
|
* Mixin to attach subscription columns/relationships to a custom model.
|
|
51
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_subscription.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"with_subscription.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD;;;;;OAKG;IAEI,AAAP,MAAM,CAAC,UAAU,CAAC,GAAwB;QACxC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,CAAC;CAmCF;AAhCS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACT;AAIX;IADP,MAAM,EAAE;sDACiB;AAGlB;IADP,MAAM,EAAE;qDACgB;AAGjB;IADP,MAAM,EAAE;mDACc;AAGf;IADP,MAAM,EAAE;mDACc;AAGf;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;uDACH;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;wDACF;AAG7B;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;mDACP;AAGxB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACW;AAGjC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC5B;AApCrB;IADN,YAAY,EAAE;2CAGd;AAuDH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CACL,UAAiB,EACc,EAAE;QACjC,MAAM,iBAAkB,SAAQ,UAAU;SA8BzC;QA5BS;YADP,MAAM,EAAE;4DACiB;QAGlB;YADP,MAAM,EAAE;2DACgB;QAGjB;YADP,MAAM,EAAE;yDACc;QAGf;YADP,MAAM,EAAE;yDACc;QAGf;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;6DACH;QAGnB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8DACF;QAG7B;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;yDACP;QAGxB;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;0DACW;QAGjC;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;4DACV;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;4DAC5B;QAE9B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,13 @@ import type { DateTime } from 'luxon';
|
|
|
6
6
|
* the billing layer aggregates them per meter for a period to bill usage-based plans.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BillingUsageEvent extends BaseModel {
|
|
9
|
+
/**
|
|
10
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
11
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
12
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
13
|
+
* — and means an app that already ran the migration needs no new one.
|
|
14
|
+
*/
|
|
15
|
+
static assignUuid(row: BillingUsageEvent): void;
|
|
9
16
|
id: string;
|
|
10
17
|
/** The subscription this usage belongs to, when metered against a subscription. */
|
|
11
18
|
subscriptionId: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_usage_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with_usage_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C;;;;;OAKG;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI;IAKvC,EAAE,EAAE,MAAM,CAAC;IAEnB,mFAAmF;IAE3E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,qEAAqE;IAE7D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,wEAAwE;IAEhE,KAAK,EAAE,MAAM,CAAC;IAEtB,mFAAmF;IAE3E,QAAQ,EAAE,MAAM,CAAC;IAGjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGlC,UAAU,EAAE,QAAQ,CAAC;IAGrB,SAAS,EAAE,QAAQ,CAAC;CAC7B"}
|
|
@@ -4,13 +4,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
8
9
|
/**
|
|
9
10
|
* The Lucid model backing the `billing_usage_events` table — a metered subscription's
|
|
10
11
|
* consumption ledger. One row per usage event (e.g. an API call, a stored GB, a message);
|
|
11
12
|
* the billing layer aggregates them per meter for a period to bill usage-based plans.
|
|
12
13
|
*/
|
|
13
14
|
export class BillingUsageEvent extends BaseModel {
|
|
15
|
+
/**
|
|
16
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
17
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
18
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
19
|
+
* — and means an app that already ran the migration needs no new one.
|
|
20
|
+
*/
|
|
21
|
+
static assignUuid(row) {
|
|
22
|
+
if (!row.id)
|
|
23
|
+
row.id = randomUUID();
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
26
|
__decorate([
|
|
16
27
|
column({ isPrimary: true })
|
|
@@ -36,4 +47,7 @@ __decorate([
|
|
|
36
47
|
__decorate([
|
|
37
48
|
column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
38
49
|
], BillingUsageEvent.prototype, "updatedAt", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
beforeCreate()
|
|
52
|
+
], BillingUsageEvent, "assignUuid", null);
|
|
39
53
|
//# sourceMappingURL=with_usage_event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_usage_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"with_usage_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C;;;;;OAKG;IAEI,AAAP,MAAM,CAAC,UAAU,CAAC,GAAsB;QACtC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,CAAC;CA6BF;AA1BS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6CACT;AAIX;IADP,MAAM,EAAE;yDAC6B;AAI9B;IADP,MAAM,EAAE;qDACyB;AAI1B;IADP,MAAM,EAAE;gDACa;AAId;IADP,MAAM,EAAE;mDACgB;AAGjB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;mDACY;AAGlC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;qDACT;AAGrB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;oDAC5B;AA9BrB;IADN,YAAY,EAAE;yCAGd"}
|
|
@@ -6,6 +6,13 @@ import type { DateTime } from 'luxon';
|
|
|
6
6
|
* webhook is never processed twice.
|
|
7
7
|
*/
|
|
8
8
|
export declare class BillingWebhookEvent extends BaseModel {
|
|
9
|
+
/**
|
|
10
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
11
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
12
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
13
|
+
* — and means an app that already ran the migration needs no new one.
|
|
14
|
+
*/
|
|
15
|
+
static assignUuid(row: BillingWebhookEvent): void;
|
|
9
16
|
id: string;
|
|
10
17
|
/** Gateway event id — the idempotency key. */
|
|
11
18
|
gatewayEventId: string;
|
|
@@ -13,6 +20,17 @@ export declare class BillingWebhookEvent extends BaseModel {
|
|
|
13
20
|
type: string;
|
|
14
21
|
status: 'received' | 'processed' | 'failed';
|
|
15
22
|
payload: Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* The NORMALIZED event (`WebhookEvent.data`) this delivery carried.
|
|
25
|
+
*
|
|
26
|
+
* Stored so the dashboard's retry can rebuild the event without calling `parseWebhook`,
|
|
27
|
+
* which would re-verify a signature computed from headers the ledger never kept — the
|
|
28
|
+
* reason a retry used to answer `422` on every gateway that signs its webhooks.
|
|
29
|
+
*
|
|
30
|
+
* `null` on rows written before an earlier schema ran; the
|
|
31
|
+
* retry says so rather than replaying half an event.
|
|
32
|
+
*/
|
|
33
|
+
normalized: Record<string, unknown> | null;
|
|
16
34
|
/** Error message when processing failed. */
|
|
17
35
|
error: string | null;
|
|
18
36
|
createdAt: DateTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_webhook_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with_webhook_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAChD;;;;;OAKG;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI;IAKzC,EAAE,EAAE,MAAM,CAAC;IAEnB,8CAA8C;IAEtC,cAAc,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,MAAM,CAAC;IAGjB,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAG5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC;;;;;;;;;OASG;IAEK,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEnD,4CAA4C;IAEpC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;CAC7B"}
|
|
@@ -4,13 +4,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
import { BaseModel, beforeCreate, column } from '@adonisjs/lucid/orm';
|
|
8
9
|
/**
|
|
9
10
|
* The Lucid model backing the `billing_webhook_events` table — the idempotency ledger.
|
|
10
11
|
* Every webhook event is recorded here (keyed by gateway event id) so a re-delivered
|
|
11
12
|
* webhook is never processed twice.
|
|
12
13
|
*/
|
|
13
14
|
export class BillingWebhookEvent extends BaseModel {
|
|
15
|
+
/**
|
|
16
|
+
* The `id` column is a `uuid` with no database-side default (see the published
|
|
17
|
+
* migration), so nothing but this hook fills it. Generating it here rather than in the
|
|
18
|
+
* migration keeps every supported dialect working — `gen_random_uuid()` is Postgres-only
|
|
19
|
+
* — and means an app that already ran the migration needs no new one.
|
|
20
|
+
*/
|
|
21
|
+
static assignUuid(row) {
|
|
22
|
+
if (!row.id)
|
|
23
|
+
row.id = randomUUID();
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
26
|
__decorate([
|
|
16
27
|
column({ isPrimary: true })
|
|
@@ -30,6 +41,9 @@ __decorate([
|
|
|
30
41
|
__decorate([
|
|
31
42
|
column({ serializeAs: null })
|
|
32
43
|
], BillingWebhookEvent.prototype, "payload", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
column({ serializeAs: null })
|
|
46
|
+
], BillingWebhookEvent.prototype, "normalized", void 0);
|
|
33
47
|
__decorate([
|
|
34
48
|
column({ serializeAs: null })
|
|
35
49
|
], BillingWebhookEvent.prototype, "error", void 0);
|
|
@@ -39,4 +53,7 @@ __decorate([
|
|
|
39
53
|
__decorate([
|
|
40
54
|
column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
41
55
|
], BillingWebhookEvent.prototype, "updatedAt", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
beforeCreate()
|
|
58
|
+
], BillingWebhookEvent, "assignUuid", null);
|
|
42
59
|
//# sourceMappingURL=with_webhook_event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with_webhook_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"with_webhook_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGtE;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD;;;;;OAKG;IAEI,AAAP,MAAM,CAAC,UAAU,CAAC,GAAwB;QACxC,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,CAAC;IACrC,CAAC;CA2CF;AAxCS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACT;AAIX;IADP,MAAM,EAAE;2DACsB;AAGvB;IADP,MAAM,EAAE;qDACgB;AAGjB;IADP,MAAM,EAAE;iDACY;AAGb;IADP,MAAM,EAAE;mDAC2C;AAG5C;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACW;AAajC;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;uDACqB;AAI3C;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;kDACD;AAGrB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC5B;AA5CrB;IADN,YAAY,EAAE;2CAGd"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PaymentsConfig } from '../define_config.js';
|
|
2
|
+
import type { WebhookDispatchMode } from './webhook_dispatcher.js';
|
|
3
|
+
/** Which half of a split deployment a process is. */
|
|
4
|
+
export type BillingRole = 'all' | 'api' | 'worker';
|
|
5
|
+
/**
|
|
6
|
+
* The dispatch backend for a config: `billing.dispatcher` when set, else the
|
|
7
|
+
* legacy `billing.durable` alias, else `'auto'`.
|
|
8
|
+
*
|
|
9
|
+
* `dispatcher` is read FIRST because it is the only option able to name every backend; the
|
|
10
|
+
* boolean alias can only say durable or not.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveDispatchMode(config: PaymentsConfig): WebhookDispatchMode;
|
|
13
|
+
/** Which half this process is. Defaults to running both. */
|
|
14
|
+
export declare function resolveRole(config: PaymentsConfig): BillingRole;
|
|
15
|
+
/**
|
|
16
|
+
* Splitting api/worker only works when the dispatcher puts a channel between the
|
|
17
|
+
* halves. `'in-process'` runs the processor inline — an `'api'` process would
|
|
18
|
+
* process everything itself and a `'worker'` would sit idle — and `'auto'` can
|
|
19
|
+
* silently resolve to it, so neither may be split on.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertRoleIsDispatchable(role: BillingRole, mode: WebhookDispatchMode): void;
|
|
22
|
+
//# sourceMappingURL=resolve_dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve_dispatch.d.ts","sourceRoot":"","sources":["../../../src/billing/resolve_dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,mBAAmB,CAkB/E;AAED,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAO3F"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dispatch backend for a config: `billing.dispatcher` when set, else the
|
|
3
|
+
* legacy `billing.durable` alias, else `'auto'`.
|
|
4
|
+
*
|
|
5
|
+
* `dispatcher` is read FIRST because it is the only option able to name every backend; the
|
|
6
|
+
* boolean alias can only say durable or not.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveDispatchMode(config) {
|
|
9
|
+
const dispatcher = config.billing?.dispatcher;
|
|
10
|
+
// `'queue'` was in the type, in the config docs and in the dispatcher's own comments, and
|
|
11
|
+
// was implemented nowhere: `queueDispatch` was declared and never read, so the mode fell
|
|
12
|
+
// through to the `'auto'` branch and silently ran durable-or-in-process. Worse, splitting
|
|
13
|
+
// api/worker was ALLOWED on it, which produced an api process doing all the work and a
|
|
14
|
+
// worker sitting idle. Refusing at boot is the only honest answer until it exists.
|
|
15
|
+
if (dispatcher === 'queue') {
|
|
16
|
+
throw new Error('[payments] `billing.dispatcher: "queue"` is not implemented — it never was, and it silently ran the in-process or durable backend instead. Use "durable" (a real channel, and the only mode that can split billing.role) or "in-process". Track the queue backend in the roadmap.');
|
|
17
|
+
}
|
|
18
|
+
if (dispatcher !== undefined)
|
|
19
|
+
return dispatcher;
|
|
20
|
+
const legacy = config.billing?.durable ?? 'auto';
|
|
21
|
+
if (legacy === true)
|
|
22
|
+
return 'durable';
|
|
23
|
+
if (legacy === false)
|
|
24
|
+
return 'in-process';
|
|
25
|
+
return 'auto';
|
|
26
|
+
}
|
|
27
|
+
/** Which half this process is. Defaults to running both. */
|
|
28
|
+
export function resolveRole(config) {
|
|
29
|
+
return config.billing?.role ?? 'all';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Splitting api/worker only works when the dispatcher puts a channel between the
|
|
33
|
+
* halves. `'in-process'` runs the processor inline — an `'api'` process would
|
|
34
|
+
* process everything itself and a `'worker'` would sit idle — and `'auto'` can
|
|
35
|
+
* silently resolve to it, so neither may be split on.
|
|
36
|
+
*/
|
|
37
|
+
export function assertRoleIsDispatchable(role, mode) {
|
|
38
|
+
if (role === 'all')
|
|
39
|
+
return;
|
|
40
|
+
if (mode === 'durable')
|
|
41
|
+
return;
|
|
42
|
+
throw new Error(`[payments] billing.role is "${role}", which splits receiving from processing — but billing.dispatcher is "${mode}", which has no channel between the two halves. Set dispatcher to "durable", or drop billing.role.`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=resolve_dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve_dispatch.js","sourceRoot":"","sources":["../../../src/billing/resolve_dispatch.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;IAC9C,0FAA0F;IAC1F,yFAAyF;IACzF,0FAA0F;IAC1F,uFAAuF;IACvF,mFAAmF;IACnF,IAAK,UAAqB,KAAK,OAAO,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,mRAAmR,CACpR,CAAC;IACJ,CAAC;IACD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAEhD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,MAAM,CAAC;IACjD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,YAAY,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,WAAW,CAAC,MAAsB;IAChD,OAAO,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,KAAK,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAiB,EAAE,IAAyB;IACnF,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO;IAC3B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAE/B,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,0EAA0E,IAAI,oGAAoG,CACtN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PaymentsConfig } from '../define_config.js';
|
|
2
|
+
import type { BillingStore } from './billing_store.js';
|
|
3
|
+
import { LucidBillingStore } from './lucid_billing_store.js';
|
|
4
|
+
/**
|
|
5
|
+
* The billing store for a config: `billing.store` when the app declared one,
|
|
6
|
+
* otherwise the Lucid store over the published tables.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from the provider so the default, the override and the DI-token rule
|
|
9
|
+
* below are covered by tests that run the real thing rather than a copy of it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveBillingStore(config: PaymentsConfig): Promise<BillingStore>;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a resolved store may be bound in the container under the
|
|
14
|
+
* `LucidBillingStore` token. Binding a custom store there would make `@inject()`
|
|
15
|
+
* hand back something the annotation does not describe.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isInjectableAsLucid(store: BillingStore): store is LucidBillingStore;
|
|
18
|
+
//# sourceMappingURL=resolve_store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve_store.d.ts","sourceRoot":"","sources":["../../../src/billing/resolve_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,CAgBvF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,KAAK,IAAI,iBAAiB,CAEnF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LucidBillingStore } from './lucid_billing_store.js';
|
|
2
|
+
/**
|
|
3
|
+
* The billing store for a config: `billing.store` when the app declared one,
|
|
4
|
+
* otherwise the Lucid store over the published tables.
|
|
5
|
+
*
|
|
6
|
+
* Extracted from the provider so the default, the override and the DI-token rule
|
|
7
|
+
* below are covered by tests that run the real thing rather than a copy of it.
|
|
8
|
+
*/
|
|
9
|
+
export async function resolveBillingStore(config) {
|
|
10
|
+
const autoCreateSchema = config.billing?.autoCreateSchema !== false;
|
|
11
|
+
const factory = config.billing?.store;
|
|
12
|
+
if (!factory)
|
|
13
|
+
return new LucidBillingStore({}, { autoCreateSchema });
|
|
14
|
+
const store = await factory({ config: () => config });
|
|
15
|
+
// The flag has to reach a store the APP built too. `billing.store` is how an app swaps in
|
|
16
|
+
// its own models — `() => lucidBillingStore({ paymentModel: MyPayment })` — and that store
|
|
17
|
+
// is constructed before the provider ever reads the config, so it defaults to creating
|
|
18
|
+
// tables. Skipping it here would run DDL against exactly the shared database
|
|
19
|
+
// `autoCreateSchema: false` was set to protect.
|
|
20
|
+
//
|
|
21
|
+
// Only ever turned OFF: a store the app built and configured itself is not something to
|
|
22
|
+
// switch schema creation ON for behind its back.
|
|
23
|
+
if (!autoCreateSchema && store instanceof LucidBillingStore)
|
|
24
|
+
store.disableAutoCreateSchema();
|
|
25
|
+
return store;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether a resolved store may be bound in the container under the
|
|
29
|
+
* `LucidBillingStore` token. Binding a custom store there would make `@inject()`
|
|
30
|
+
* hand back something the annotation does not describe.
|
|
31
|
+
*/
|
|
32
|
+
export function isInjectableAsLucid(store) {
|
|
33
|
+
return store instanceof LucidBillingStore;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=resolve_store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve_store.js","sourceRoot":"","sources":["../../../src/billing/resolve_store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAsB;IAC9D,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,EAAE,gBAAgB,KAAK,KAAK,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;IACtC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,iBAAiB,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAErE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IACtD,0FAA0F;IAC1F,2FAA2F;IAC3F,uFAAuF;IACvF,6EAA6E;IAC7E,gDAAgD;IAChD,EAAE;IACF,wFAAwF;IACxF,iDAAiD;IACjD,IAAI,CAAC,gBAAgB,IAAI,KAAK,YAAY,iBAAiB;QAAE,KAAK,CAAC,uBAAuB,EAAE,CAAC;IAC7F,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAmB;IACrD,OAAO,KAAK,YAAY,iBAAiB,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The billing schema, as standalone idempotent functions.
|
|
3
|
+
*
|
|
4
|
+
* This is the ecosystem convention — a lib owns its own schema — and it is why
|
|
5
|
+
* `@adonis-agora/durable` exports `createDurableTables` and `@adonis-agora/authz` exports
|
|
6
|
+
* `createAuthzTables`. This package did not follow it, and the cost showed up quickly: every
|
|
7
|
+
* column added after the first release became another migration file with hand-written
|
|
8
|
+
* `hasColumn` / `hasTable` guards, and an app adopting the library had three files to publish
|
|
9
|
+
* and run before it could take a single payment.
|
|
10
|
+
*
|
|
11
|
+
* Two paths, one DDL. {@link LucidBillingStore} calls {@link createBillingTables} once on
|
|
12
|
+
* first use (`autoCreateSchema`, on by default), and the published migration stub calls the
|
|
13
|
+
* SAME function — so the two can never drift, which is the whole reason the DDL lives here
|
|
14
|
+
* rather than in a stub the store knows nothing about.
|
|
15
|
+
*
|
|
16
|
+
* The DDL is portable `rawQuery` (`CREATE TABLE IF NOT EXISTS`) rather than Knex's schema
|
|
17
|
+
* builder, matching the posture authz takes: it keeps the `@adonisjs/lucid` coupling to the
|
|
18
|
+
* `rawQuery` surface, and it is idempotent by construction — which is what lets an install
|
|
19
|
+
* that already ran the old Knex migration call this and have it do nothing.
|
|
20
|
+
*/
|
|
21
|
+
/** The bindings a Lucid `rawQuery` accepts. */
|
|
22
|
+
export type LucidQueryBindings = readonly unknown[] | Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* The slice of a Lucid query client these functions rely on. Both the root `Database` and a
|
|
25
|
+
* connection client satisfy it, so the dependency is on the surface rather than a concrete
|
|
26
|
+
* Lucid type.
|
|
27
|
+
*
|
|
28
|
+
* `rawQuery` is declared as a METHOD, not a function-typed property: methods are checked
|
|
29
|
+
* bivariantly, which is what lets a real Lucid client — whose signature is more specific than
|
|
30
|
+
* this mirror — satisfy the interface under `strictFunctionTypes`. Declared the other way, no
|
|
31
|
+
* real client satisfies it and the published migration stub does not compile in a consumer
|
|
32
|
+
* app even though every check inside this repo passes.
|
|
33
|
+
*/
|
|
34
|
+
export interface LucidQueryClient {
|
|
35
|
+
rawQuery(sql: string, bindings?: LucidQueryBindings): Promise<unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A Lucid `Database`, connection, or query client.
|
|
39
|
+
*
|
|
40
|
+
* Dialect detection accepts both shapes the library is handed: the root `Database` exposes
|
|
41
|
+
* the dialect via `connection().dialect`, while a migration's deferred query client
|
|
42
|
+
* (`this.defer((db) => …)`) exposes `dialect` directly.
|
|
43
|
+
*/
|
|
44
|
+
export interface LucidDatabase extends LucidQueryClient {
|
|
45
|
+
dialect?: {
|
|
46
|
+
name?: string;
|
|
47
|
+
};
|
|
48
|
+
connection?(name?: string): {
|
|
49
|
+
dialect?: {
|
|
50
|
+
name?: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Every table the billing layer owns.
|
|
56
|
+
*
|
|
57
|
+
* Deliberately NOT configurable, unlike authz's table names. The models are the source of
|
|
58
|
+
* truth here (`BillingModels` lets an app swap any of them), and DDL that could name a table
|
|
59
|
+
* the models do not read is a way to create an empty table beside a missing one. An app that
|
|
60
|
+
* renames a table swaps the model and writes its own migration.
|
|
61
|
+
*/
|
|
62
|
+
export declare const BILLING_TABLES: readonly ["billing_customers", "billing_subscriptions", "billing_payments", "billing_webhook_events", "billing_disputes", "billing_usage_events", "billing_audit_events"];
|
|
63
|
+
/** Best-effort dialect name; `undefined` when it cannot be read. */
|
|
64
|
+
export declare function detectDialect(db: LucidDatabase): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Create every billing table, idempotently.
|
|
67
|
+
*
|
|
68
|
+
* Safe to call from a Lucid migration's `up()`, and safe to call repeatedly at boot — which
|
|
69
|
+
* is exactly what {@link LucidBillingStore} does when `autoCreateSchema` is on. An install
|
|
70
|
+
* that already ran the older Knex migrations gets no-ops: every statement is
|
|
71
|
+
* `IF NOT EXISTS`.
|
|
72
|
+
*
|
|
73
|
+
* It also carries columns added AFTER a table shipped — see the block at the end. That is
|
|
74
|
+
* what makes this a real upgrade path rather than a first-install convenience: an app that
|
|
75
|
+
* ran the 0.2.0 migration and then upgrades gets the columns the new code reads, without
|
|
76
|
+
* having to be told to publish and run a second migration.
|
|
77
|
+
*/
|
|
78
|
+
export declare function createBillingTables(db: LucidDatabase): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Register a "forget the cached schema" callback. Returns the unregister function.
|
|
81
|
+
* Internal — {@link LucidBillingStore} is the only caller.
|
|
82
|
+
*/
|
|
83
|
+
export declare function registerBillingSchemaCache(reset: () => void): () => void;
|
|
84
|
+
/**
|
|
85
|
+
* Drop every billing table, newest-dependency-first.
|
|
86
|
+
*
|
|
87
|
+
* Only for a migration's `down()` and for tests. There is no auto-drop and there will not be
|
|
88
|
+
* one: a library that can delete a payments table on a config typo is a library that will.
|
|
89
|
+
*
|
|
90
|
+
* Every live store is told to forget its cached schema afterwards, so a store built before
|
|
91
|
+
* the drop re-creates the tables on its next query instead of querying tables that are gone.
|
|
92
|
+
*/
|
|
93
|
+
export declare function dropBillingTables(db: LucidDatabase): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Empty every billing table, keeping the schema.
|
|
96
|
+
*
|
|
97
|
+
* What a test suite actually needs between groups, and the reason it is here rather than in
|
|
98
|
+
* every app: dropping the tables invalidates the store (see above), while leaving the ROWS
|
|
99
|
+
* in place means one test's webhook ledger deduplicates the next test's event — the
|
|
100
|
+
* library's own idempotency working perfectly, against the suite. The app that found this
|
|
101
|
+
* hand-wrote it with a `to_regclass` guard; this is that, dialect-agnostically.
|
|
102
|
+
*
|
|
103
|
+
* Order is the reverse of creation, so a foreign key never blocks a delete. `DELETE FROM`
|
|
104
|
+
* rather than `TRUNCATE`: it is the one statement every dialect here spells the same way,
|
|
105
|
+
* and these tables are test-sized.
|
|
106
|
+
*/
|
|
107
|
+
export declare function truncateBillingTables(db: LucidDatabase): Promise<void>;
|
|
108
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/billing/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,kBAAkB,GAAG,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC7D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,2KAQjB,CAAC;AAEX,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAQnE;AAsFD;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAmP1E;AAaD;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKxE;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5E"}
|