@pithy-sh/payments 0.3.10 → 0.5.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/README.md +11 -3
- package/dist/admin/coverage.d.ts.map +1 -1
- package/dist/admin/coverage.js +26 -2
- package/dist/admin/read.d.ts +48 -1
- package/dist/admin/read.d.ts.map +1 -1
- package/dist/admin/read.js +89 -2
- package/dist/audit/actions.d.ts +13 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +14 -1
- package/dist/capability.d.ts +33 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +52 -9
- package/dist/client/api.d.ts +38 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +59 -1
- package/dist/client/hooks.d.ts +63 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/hooks.js +96 -2
- package/dist/client/paddleLink.d.ts +31 -0
- package/dist/client/paddleLink.d.ts.map +1 -0
- package/dist/client/paddleLink.js +37 -0
- package/dist/client/projection.d.ts +29 -0
- package/dist/client/projection.d.ts.map +1 -1
- package/dist/config/allowances.d.ts +71 -0
- package/dist/config/allowances.d.ts.map +1 -0
- package/dist/config/allowances.js +115 -0
- package/dist/config/config.d.ts +155 -9
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +164 -14
- package/dist/data/meterCounter.d.ts +34 -0
- package/dist/data/meterCounter.d.ts.map +1 -0
- package/dist/data/meterCounter.js +33 -0
- package/dist/data/override.d.ts +56 -0
- package/dist/data/override.d.ts.map +1 -0
- package/dist/data/override.js +58 -0
- package/dist/data/paddleIds.d.ts +28 -0
- package/dist/data/paddleIds.d.ts.map +1 -0
- package/dist/data/paddleIds.js +73 -0
- package/dist/data/period.d.ts +10 -0
- package/dist/data/period.d.ts.map +1 -0
- package/dist/data/period.js +37 -0
- package/dist/data/purchase.d.ts +1 -0
- package/dist/data/purchase.d.ts.map +1 -1
- package/dist/data/purchase.js +1 -0
- package/dist/data/tables.d.ts +17 -1
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +24 -4
- package/dist/data/usageReport.d.ts +68 -0
- package/dist/data/usageReport.d.ts.map +1 -0
- package/dist/data/usageReport.js +55 -0
- package/dist/data/usageRun.d.ts +93 -0
- package/dist/data/usageRun.d.ts.map +1 -0
- package/dist/data/usageRun.js +50 -0
- package/dist/entitlement/allowance.d.ts +100 -0
- package/dist/entitlement/allowance.d.ts.map +1 -0
- package/dist/entitlement/allowance.js +171 -0
- package/dist/entitlement/manual.d.ts +5 -5
- package/dist/entitlement/manual.js +3 -3
- package/dist/entitlement/meter.d.ts +98 -0
- package/dist/entitlement/meter.d.ts.map +1 -0
- package/dist/entitlement/meter.js +177 -0
- package/dist/entitlement/override.d.ts +119 -0
- package/dist/entitlement/override.d.ts.map +1 -0
- package/dist/entitlement/override.js +256 -0
- package/dist/entitlement/resolver.d.ts +2 -1
- package/dist/entitlement/resolver.d.ts.map +1 -1
- package/dist/entitlement/resolver.js +32 -1
- package/dist/entitlement/unimplementedSubject.d.ts.map +1 -1
- package/dist/entitlement/unimplementedSubject.js +3 -2
- package/dist/error/errors.d.ts +19 -0
- package/dist/error/errors.d.ts.map +1 -1
- package/dist/error/errors.js +35 -2
- package/dist/http/responses.d.ts +390 -5
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +169 -13
- package/dist/http/routes.d.ts +6 -2
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +478 -52
- package/dist/http/schemas.d.ts +75 -1
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +80 -3
- package/dist/http/scopes.d.ts +25 -0
- package/dist/http/scopes.d.ts.map +1 -1
- package/dist/http/scopes.js +60 -1
- package/dist/http/view.d.ts +22 -4
- package/dist/http/view.d.ts.map +1 -1
- package/dist/http/view.js +88 -7
- package/dist/http/webhookGuard.d.ts.map +1 -1
- package/dist/http/webhookGuard.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/migrations/0002_allowances.d.ts +26 -0
- package/dist/migrations/0002_allowances.d.ts.map +1 -0
- package/dist/migrations/0002_allowances.js +62 -0
- package/dist/peer.d.ts +1 -0
- package/dist/peer.d.ts.map +1 -1
- package/dist/projection/event.d.ts +1 -0
- package/dist/projection/event.d.ts.map +1 -1
- package/dist/projection/event.js +1 -0
- package/dist/projection/writer.d.ts.map +1 -1
- package/dist/projection/writer.js +3 -1
- package/dist/rails/contract.d.ts +6 -0
- package/dist/rails/contract.d.ts.map +1 -1
- package/dist/rails/google/playApi.d.ts.map +1 -1
- package/dist/rails/google/playApi.js +2 -0
- package/dist/rails/paddle/events.d.ts.map +1 -1
- package/dist/rails/paddle/events.js +2 -1
- package/dist/rails/paddle/objects.d.ts +2 -0
- package/dist/rails/paddle/objects.d.ts.map +1 -1
- package/dist/rails/paddle/objects.js +7 -2
- package/dist/rails/paddle/refresh.d.ts +10 -5
- package/dist/rails/paddle/refresh.d.ts.map +1 -1
- package/dist/rails/paddle/refresh.js +8 -5
- package/dist/rails/paddle/refund.d.ts.map +1 -1
- package/dist/rails/paddle/refund.js +10 -2
- package/dist/rails/paddle/subscription.d.ts.map +1 -1
- package/dist/rails/paddle/subscription.js +8 -3
- package/dist/rails/paddle/usage.d.ts +11 -0
- package/dist/rails/paddle/usage.d.ts.map +1 -0
- package/dist/rails/paddle/usage.js +49 -0
- package/dist/rails/paddle/verify.d.ts.map +1 -1
- package/dist/rails/paddle/verify.js +2 -3
- package/dist/rails/quantity.d.ts +12 -0
- package/dist/rails/quantity.d.ts.map +1 -0
- package/dist/rails/quantity.js +16 -0
- package/dist/rails/stripe/checkout.d.ts.map +1 -1
- package/dist/rails/stripe/checkout.js +1 -1
- package/dist/rails/stripe/objects.d.ts.map +1 -1
- package/dist/rails/stripe/objects.js +3 -0
- package/dist/rails/stripe/usage.d.ts +10 -0
- package/dist/rails/stripe/usage.d.ts.map +1 -0
- package/dist/rails/stripe/usage.js +49 -0
- package/dist/secret/registry.d.ts.map +1 -1
- package/dist/secret/registry.js +3 -2
- package/dist/usage/pass.d.ts +120 -0
- package/dist/usage/pass.d.ts.map +1 -0
- package/dist/usage/pass.js +363 -0
- package/dist/usage/reporter.d.ts +36 -0
- package/dist/usage/reporter.d.ts.map +1 -0
- package/dist/usage/reporter.js +2 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.d.ts.map +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/workflows/specs.d.ts +28 -0
- package/dist/workflows/specs.d.ts.map +1 -1
- package/dist/workflows/specs.js +26 -1
- package/dist/workflows/usage.d.ts +38 -0
- package/dist/workflows/usage.d.ts.map +1 -0
- package/dist/workflows/usage.js +77 -0
- package/dist/workflows/worker.js +2 -2
- package/dist/workflows/workerConfig.d.ts.map +1 -1
- package/dist/workflows/workerConfig.js +8 -2
- package/docs/entitlements.md +249 -0
- package/docs/lemon-squeezy.md +1 -0
- package/docs/paddle.md +18 -2
- package/package.json +7 -7
- package/pithy.manifest.json +3 -8
- package/src/admin/coverage.ts +28 -0
- package/src/admin/read.ts +173 -1
- package/src/audit/actions.ts +13 -0
- package/src/capability.ts +87 -9
- package/src/client/api.ts +79 -0
- package/src/client/hooks.ts +122 -0
- package/src/client/paddleLink.ts +41 -0
- package/src/client/projection.ts +31 -0
- package/src/config/allowances.ts +211 -0
- package/src/config/config.ts +283 -15
- package/src/data/meterCounter.ts +38 -0
- package/src/data/override.ts +74 -0
- package/src/data/paddleIds.ts +74 -0
- package/src/data/period.ts +53 -0
- package/src/data/purchase.ts +9 -0
- package/src/data/tables.ts +25 -1
- package/src/data/usageReport.ts +64 -0
- package/src/data/usageRun.ts +66 -0
- package/src/entitlement/allowance.ts +213 -0
- package/src/entitlement/manual.ts +6 -6
- package/src/entitlement/meter.ts +252 -0
- package/src/entitlement/override.ts +381 -0
- package/src/entitlement/resolver.ts +43 -2
- package/src/entitlement/unimplementedSubject.ts +3 -4
- package/src/error/errors.ts +44 -1
- package/src/http/responses.ts +338 -10
- package/src/http/routes.ts +1089 -460
- package/src/http/schemas.ts +171 -2
- package/src/http/scopes.ts +68 -0
- package/src/http/view.ts +112 -7
- package/src/http/webhookGuard.ts +3 -2
- package/src/index.ts +18 -0
- package/src/migrations/0002_allowances.ts +149 -0
- package/src/projection/event.ts +9 -0
- package/src/projection/writer.ts +4 -0
- package/src/rails/contract.ts +6 -0
- package/src/rails/google/playApi.ts +2 -0
- package/src/rails/paddle/events.ts +2 -1
- package/src/rails/paddle/fixtures/subscription-charge.json +19 -0
- package/src/rails/paddle/objects.ts +6 -0
- package/src/rails/paddle/refresh.ts +17 -10
- package/src/rails/paddle/refund.ts +10 -2
- package/src/rails/paddle/subscription.ts +8 -3
- package/src/rails/paddle/usage.ts +66 -0
- package/src/rails/paddle/verify.ts +6 -4
- package/src/rails/quantity.ts +14 -0
- package/src/rails/stripe/checkout.ts +3 -1
- package/src/rails/stripe/fixtures/meter-event-created.json +12 -0
- package/src/rails/stripe/objects.ts +4 -0
- package/src/rails/stripe/usage.ts +61 -0
- package/src/secret/registry.ts +3 -2
- package/src/usage/pass.ts +539 -0
- package/src/usage/reporter.ts +38 -0
- package/src/version.generated.ts +1 -1
- package/src/workflows/specs.ts +34 -0
- package/src/workflows/usage.ts +97 -0
- package/src/workflows/workerConfig.ts +9 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { PAYMENTS_RAILS, PaymentsRail } from "./data/rail.js";
|
|
4
4
|
import { PaymentsSubject, PaymentsSubjectType, decodeSubjectReference, encodeSubjectReference, sameSubject } from "./data/subject.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AllowanceName, PaymentsAllowanceDefaults, PaymentsEntitlementDeclaration, QuotaValue, declaredFeatureNames, declaredQuotaNames } from "./config/allowances.js";
|
|
6
|
+
import { KIT_METERS, PaymentsAppleProduct, PaymentsConfig, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsMeters, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsRailToggles, PaymentsReportCadence, PaymentsReportedBilling, PaymentsStripeProduct, PaymentsStripeSettings, REPORTED_BILLING_RAILS, compOnlyEntitlements, entitlementsForProduct, grantableEntitlements, productForProviderSku, providerProductId, railEnabled, reportedBillingProblems, reportedProducts, resolveProduct } from "./config/config.js";
|
|
6
7
|
import { PaymentsEntitlement } from "./data/entitlement.js";
|
|
7
8
|
import { PaymentsProviderAccount } from "./data/providerAccount.js";
|
|
8
9
|
import { ACCESS_GRANTING_STATUSES, PurchaseStatus, grantingStatuses, statusGrantsAccess } from "./data/status.js";
|
|
@@ -43,4 +44,4 @@ import { PAYMENTS_RECONCILE_KEY, triggerPaymentsReconcile } from "./http/dispatc
|
|
|
43
44
|
import { paymentsWorkerName, resolvePaymentsConfig } from "./provision/resolvePaymentsConfig.js";
|
|
44
45
|
import { batchedRailAccess } from "./workflows/railAccess.js";
|
|
45
46
|
import { reconcilePayments } from "./workflows/reconcile.js";
|
|
46
|
-
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, RECONCILE_RUN_RETENTION_DAYS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, createPaymentsEntitlementResolver, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, isUnimplementedSubject, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, requireAuth, requireImplementedSubject, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, unimplementedSubject, webhookEventAwaitsOwner };
|
|
47
|
+
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AllowanceName, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, KIT_METERS, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAllowanceDefaults, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsEntitlementDeclaration, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsMeters, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsReportCadence, PaymentsReportedBilling, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, QuotaValue, RECONCILE_RUN_RETENTION_DAYS, REPORTED_BILLING_RAILS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, compOnlyEntitlements, createPaymentsEntitlementResolver, declaredFeatureNames, declaredQuotaNames, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, isUnimplementedSubject, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, reportedBillingProblems, reportedProducts, requireAuth, requireImplementedSubject, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, unimplementedSubject, webhookEventAwaitsOwner };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { Migration } from "kysely/migration";
|
|
4
|
+
/**
|
|
5
|
+
* Allowances, meters and reported usage: four tables and one column.
|
|
6
|
+
*
|
|
7
|
+
* **A new migration, because `0001` is history.** Every payments chain has been running since 0.1.0, and
|
|
8
|
+
* reshaping `0001` would reshape a database somebody is already running. So everything lands here, with a
|
|
9
|
+
* tested `down`.
|
|
10
|
+
*
|
|
11
|
+
* - `pithy_payments_overrides` — one subject's override, `UNIQUE (subjectType, subjectId)`. Keyed on the
|
|
12
|
+
* subject rather than on an entitlement key, so it survives a tier change.
|
|
13
|
+
* - `pithy_payments_meter_counters` — one subject's use of one kit meter in one period,
|
|
14
|
+
* `UNIQUE (subjectType, subjectId, meter, periodStart)`. The period is half the key, which is what makes a
|
|
15
|
+
* new period start at zero with nothing to reset it.
|
|
16
|
+
* - `pithy_payments_usage_reports` — one reported period of one quantity-billed subscription,
|
|
17
|
+
* `UNIQUE (rail, providerSubscriptionId, period)`. The key is the idempotency: a replayed run finds the row.
|
|
18
|
+
* - `pithy_payments_usage_runs` — one reporting pass, its tally kept, the way reconcile runs are.
|
|
19
|
+
* - `pithy_payments_purchases.quantity` — how many were bought, as the store states it. Nullable, because
|
|
20
|
+
* rows written before this did not record one and no store is asked again to invent it.
|
|
21
|
+
*
|
|
22
|
+
* The subject kind is closed with a `CHECK` on every subject-bearing table, as `0001` closes it, and every
|
|
23
|
+
* count a row holds is checked non-negative: a negative usage is a bug in the writer, never a fact.
|
|
24
|
+
*/
|
|
25
|
+
export declare const payments_0002_allowances: Migration;
|
|
26
|
+
//# sourceMappingURL=0002_allowances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0002_allowances.d.ts","sourceRoot":"","sources":["../../src/migrations/0002_allowances.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAyHtC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { sql } from "kysely";
|
|
4
|
+
//#region src/migrations/0002_allowances.ts
|
|
5
|
+
/**
|
|
6
|
+
* Allowances, meters and reported usage: four tables and one column.
|
|
7
|
+
*
|
|
8
|
+
* **A new migration, because `0001` is history.** Every payments chain has been running since 0.1.0, and
|
|
9
|
+
* reshaping `0001` would reshape a database somebody is already running. So everything lands here, with a
|
|
10
|
+
* tested `down`.
|
|
11
|
+
*
|
|
12
|
+
* - `pithy_payments_overrides` — one subject's override, `UNIQUE (subjectType, subjectId)`. Keyed on the
|
|
13
|
+
* subject rather than on an entitlement key, so it survives a tier change.
|
|
14
|
+
* - `pithy_payments_meter_counters` — one subject's use of one kit meter in one period,
|
|
15
|
+
* `UNIQUE (subjectType, subjectId, meter, periodStart)`. The period is half the key, which is what makes a
|
|
16
|
+
* new period start at zero with nothing to reset it.
|
|
17
|
+
* - `pithy_payments_usage_reports` — one reported period of one quantity-billed subscription,
|
|
18
|
+
* `UNIQUE (rail, providerSubscriptionId, period)`. The key is the idempotency: a replayed run finds the row.
|
|
19
|
+
* - `pithy_payments_usage_runs` — one reporting pass, its tally kept, the way reconcile runs are.
|
|
20
|
+
* - `pithy_payments_purchases.quantity` — how many were bought, as the store states it. Nullable, because
|
|
21
|
+
* rows written before this did not record one and no store is asked again to invent it.
|
|
22
|
+
*
|
|
23
|
+
* The subject kind is closed with a `CHECK` on every subject-bearing table, as `0001` closes it, and every
|
|
24
|
+
* count a row holds is checked non-negative: a negative usage is a bug in the writer, never a fact.
|
|
25
|
+
*/
|
|
26
|
+
const payments_0002_allowances = {
|
|
27
|
+
up: async (db) => {
|
|
28
|
+
await db.schema.alterTable("pithyPaymentsPurchases").addColumn("quantity", "integer").execute();
|
|
29
|
+
await db.schema.createTable("pithyPaymentsOverrides").addColumn("id", "text", (c) => c.primaryKey()).addColumn("subjectType", "text", (c) => c.notNull()).addColumn("subjectId", "text", (c) => c.notNull()).addColumn("unrestricted", "integer", (c) => c.notNull().defaultTo(0)).addColumn("quotas", "text", (c) => c.notNull()).addColumn("features", "text", (c) => c.notNull()).addColumn("version", "integer", (c) => c.notNull()).addColumn("reason", "text", (c) => c.notNull()).addColumn("createdAt", "integer", (c) => c.notNull()).addColumn("updatedAt", "integer", (c) => c.notNull()).addUniqueConstraint("pithyPaymentsOverridesSubjectIdx", ["subjectType", "subjectId"]).addCheckConstraint("pithyPaymentsOverridesSubjectType", sql`subject_type in ('user', 'organization')`).addCheckConstraint("pithyPaymentsOverridesUnrestricted", sql`unrestricted in (0, 1)`).addCheckConstraint("pithyPaymentsOverridesVersion", sql`version >= 1`).execute();
|
|
30
|
+
await db.schema.createIndex("pithyPaymentsOverridesUpdatedIdx").on("pithyPaymentsOverrides").columns(["updatedAt", "id"]).execute();
|
|
31
|
+
await db.schema.createIndex("pithyPaymentsOverridesUnrestrictedIdx").on("pithyPaymentsOverrides").columns([
|
|
32
|
+
"unrestricted",
|
|
33
|
+
"subjectType",
|
|
34
|
+
"subjectId"
|
|
35
|
+
]).execute();
|
|
36
|
+
await db.schema.createTable("pithyPaymentsMeterCounters").addColumn("id", "text", (c) => c.primaryKey()).addColumn("subjectType", "text", (c) => c.notNull()).addColumn("subjectId", "text", (c) => c.notNull()).addColumn("meter", "text", (c) => c.notNull()).addColumn("periodStart", "integer", (c) => c.notNull()).addColumn("used", "integer", (c) => c.notNull().defaultTo(0)).addColumn("createdAt", "integer", (c) => c.notNull()).addColumn("updatedAt", "integer", (c) => c.notNull()).addUniqueConstraint("pithyPaymentsMeterCountersPeriodIdx", [
|
|
37
|
+
"subjectType",
|
|
38
|
+
"subjectId",
|
|
39
|
+
"meter",
|
|
40
|
+
"periodStart"
|
|
41
|
+
]).addCheckConstraint("pithyPaymentsMeterCountersSubjectType", sql`subject_type in ('user', 'organization')`).addCheckConstraint("pithyPaymentsMeterCountersUsed", sql`used >= 0`).execute();
|
|
42
|
+
await db.schema.createTable("pithyPaymentsUsageReports").addColumn("id", "text", (c) => c.primaryKey()).addColumn("rail", "text", (c) => c.notNull()).addColumn("providerSubscriptionId", "text", (c) => c.notNull()).addColumn("purchaseId", "text", (c) => c.notNull()).addColumn("productId", "text", (c) => c.notNull()).addColumn("subjectType", "text", (c) => c.notNull()).addColumn("subjectId", "text", (c) => c.notNull()).addColumn("cadence", "text", (c) => c.notNull()).addColumn("period", "text", (c) => c.notNull()).addColumn("quantity", "integer", (c) => c.notNull()).addColumn("status", "text", (c) => c.notNull()).addColumn("sampledAt", "integer", (c) => c.notNull()).addColumn("reportedAt", "integer").addColumn("createdAt", "integer", (c) => c.notNull()).addColumn("updatedAt", "integer", (c) => c.notNull()).addUniqueConstraint("pithyPaymentsUsageReportsPeriodIdx", [
|
|
43
|
+
"rail",
|
|
44
|
+
"providerSubscriptionId",
|
|
45
|
+
"period"
|
|
46
|
+
]).addCheckConstraint("pithyPaymentsUsageReportsSubjectType", sql`subject_type in ('user', 'organization')`).addCheckConstraint("pithyPaymentsUsageReportsCadence", sql`cadence in ('period-end', 'daily-peak')`).addCheckConstraint("pithyPaymentsUsageReportsStatus", sql`status in ('sampling', 'claimed', 'reported')`).addCheckConstraint("pithyPaymentsUsageReportsQuantity", sql`quantity >= 0`).execute();
|
|
47
|
+
await db.schema.createTable("pithyPaymentsUsageRuns").addColumn("id", "text", (c) => c.primaryKey()).addColumn("startedAt", "integer", (c) => c.notNull()).addColumn("finishedAt", "integer", (c) => c.notNull()).addColumn("scanned", "integer", (c) => c.notNull().defaultTo(0)).addColumn("reported", "integer", (c) => c.notNull().defaultTo(0)).addColumn("sampled", "integer", (c) => c.notNull().defaultTo(0)).addColumn("alreadyReported", "integer", (c) => c.notNull().defaultTo(0)).addColumn("skipped", "integer", (c) => c.notNull().defaultTo(0)).addColumn("invalid", "integer", (c) => c.notNull().defaultTo(0)).addColumn("failed", "integer", (c) => c.notNull().defaultTo(0)).addColumn("findings", "text", (c) => c.notNull()).addColumn("createdAt", "integer", (c) => c.notNull()).addCheckConstraint("pithyPaymentsUsageRunsCounts", sql`scanned >= 0 and reported >= 0 and sampled >= 0 and already_reported >= 0 and skipped >= 0 and invalid >= 0 and failed >= 0`).execute();
|
|
48
|
+
await db.schema.createIndex("pithyPaymentsUsageRunsStartedIdx").on("pithyPaymentsUsageRuns").columns(["startedAt", "id"]).execute();
|
|
49
|
+
},
|
|
50
|
+
down: async (db) => {
|
|
51
|
+
await db.schema.dropIndex("pithyPaymentsUsageRunsStartedIdx").execute();
|
|
52
|
+
await db.schema.dropTable("pithyPaymentsUsageRuns").execute();
|
|
53
|
+
await db.schema.dropTable("pithyPaymentsUsageReports").execute();
|
|
54
|
+
await db.schema.dropTable("pithyPaymentsMeterCounters").execute();
|
|
55
|
+
await db.schema.dropIndex("pithyPaymentsOverridesUnrestrictedIdx").execute();
|
|
56
|
+
await db.schema.dropIndex("pithyPaymentsOverridesUpdatedIdx").execute();
|
|
57
|
+
await db.schema.dropTable("pithyPaymentsOverrides").execute();
|
|
58
|
+
await db.schema.alterTable("pithyPaymentsPurchases").dropColumn("quantity").execute();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { payments_0002_allowances };
|
package/dist/peer.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ export declare const paymentsPeer: {
|
|
|
66
66
|
originalTransactionId: import("zod").ZodNullable<import("zod").ZodString>;
|
|
67
67
|
amountMinor: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
68
68
|
currency: import("zod").ZodNullable<import("zod").ZodString>;
|
|
69
|
+
quantity: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
69
70
|
providerEventAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
|
|
70
71
|
payload: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>]>, import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
71
72
|
createdAt: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>;
|
package/dist/peer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAA4B,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAA4B,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKf,CAAC;AAEX,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC"}
|
|
@@ -60,6 +60,7 @@ export declare const ProviderEvent: z.ZodObject<{
|
|
|
60
60
|
originalTransactionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
61
61
|
amountMinor: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
62
62
|
currency: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
63
|
+
quantity: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
63
64
|
providerEventAt: z.ZodDate;
|
|
64
65
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
65
66
|
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/projection/event.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/projection/event.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgFvB,CAAC;AACJ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAC3D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
package/dist/projection/event.js
CHANGED
|
@@ -40,6 +40,7 @@ const ProviderEvent = z.object({
|
|
|
40
40
|
originalTransactionId: z.string().nullable().default(null).describe("The transaction that started the subscription, chaining renewals back to it. Null for a one-off."),
|
|
41
41
|
amountMinor: z.number().int().nullable().default(null).describe("The amount charged in the currency's minor unit, or null when the rail did not report one."),
|
|
42
42
|
currency: z.string().nullable().default(null).describe("The ISO currency of `amountMinor`, or null when the rail did not report one."),
|
|
43
|
+
quantity: z.number().int().positive().nullable().default(null).describe("How many were bought, as the store states it, or null where it does not say. Never invented: a rail that reads no quantity leaves this null rather than writing 1."),
|
|
43
44
|
providerEventAt: z.date().describe("The provider's own timestamp for this event. The monotonic write rule compares against it, so an event staler than the row it would update changes nothing."),
|
|
44
45
|
payload: z.record(z.string(), z.unknown()).describe("The verified provider payload, stored as received. The reconciliation and audit record.")
|
|
45
46
|
}).describe("One provider event, normalized and bound to its owner — the projection writer's input. A rail produces this shape less the subject pair; the route adds it.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/projection/writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAKjF,OAAO,EAEL,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAcxG,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,gHAAgH;AAChH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3C,8FAA8F;IAC9F,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,wFAAwF;IACxF,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;IACzD,wEAAwE;IACxE,YAAY,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC9C;AAED,wGAAwG;AACxG,MAAM,WAAW,sBAAsB;IACrC,gGAAgG;IAChG,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,WAAW,EAAE,mBAAmB,CAAC;IACjC,wGAAwG;IACxG,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,w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e,CACnC,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC,CAiH7B;AA2HD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,mBAAmB,GAAG,mBAAmB,CAErG"}
|
|
@@ -10,8 +10,8 @@ import { PaymentsEnvironmentMismatchError, PaymentsProductNotFoundError, Payment
|
|
|
10
10
|
import { ProviderEvent } from "./event.js";
|
|
11
11
|
import { InternalError } from "@pithy-sh/core/src/error/pithyError";
|
|
12
12
|
import { withD1Retry } from "@pithy-sh/core/src/data/withD1Retry";
|
|
13
|
-
import { chunkByBoundParameters } from "@pithy-sh/core/src/data/boundParameters";
|
|
14
13
|
import { sql } from "kysely";
|
|
14
|
+
import { chunkByBoundParameters } from "@pithy-sh/core/src/data/boundParameters";
|
|
15
15
|
//#region src/projection/writer.ts
|
|
16
16
|
/**
|
|
17
17
|
* Project one normalized provider event. Returns what changed; throws only the three refusals above and
|
|
@@ -65,6 +65,7 @@ async function projectPurchase(d1, input, options) {
|
|
|
65
65
|
originalTransactionId: event.originalTransactionId,
|
|
66
66
|
amountMinor: event.amountMinor,
|
|
67
67
|
currency: event.currency,
|
|
68
|
+
quantity: event.quantity,
|
|
68
69
|
providerEventAt: event.providerEventAt,
|
|
69
70
|
payload: event.payload,
|
|
70
71
|
createdAt: existing?.createdAt ?? now,
|
|
@@ -195,6 +196,7 @@ function upsertPurchase(db, row) {
|
|
|
195
196
|
originalTransactionId: row.originalTransactionId,
|
|
196
197
|
amountMinor: row.amountMinor,
|
|
197
198
|
currency: row.currency,
|
|
199
|
+
quantity: row.quantity,
|
|
198
200
|
providerEventAt: row.providerEventAt,
|
|
199
201
|
payload: row.payload,
|
|
200
202
|
updatedAt: row.updatedAt
|
package/dist/rails/contract.d.ts
CHANGED
|
@@ -344,6 +344,12 @@ export interface CheckoutSessionInput {
|
|
|
344
344
|
providerProductId: string;
|
|
345
345
|
/** Whether this buys a recurring subscription or a one-off. Decides the hosted flow the store presents. */
|
|
346
346
|
subscription: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Whether the product bills by a reported quantity (`billing.kind: "reported"`). Such a price is metered on
|
|
349
|
+
* Stripe, and Stripe refuses a line quantity on a metered price — so the line goes out with none, and the
|
|
350
|
+
* count arrives later as reported usage. Absent is a flat-priced product.
|
|
351
|
+
*/
|
|
352
|
+
reported?: boolean;
|
|
347
353
|
/**
|
|
348
354
|
* The subject the purchase is for — the authenticated caller, or the organization the project bills on
|
|
349
355
|
* their behalf, as the configured subject seam resolved it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/rails/contract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,kBAAkB,EAAE,aAAa,GAAG,WAAW,CAAC,CAAC;AAEzF,mGAAmG;AACnG,MAAM,WAAW,kBAAkB;IACjC,4GAA4G;IAC5G,GAAG,EAAE,IAAI,CAAC;IACV;;;;;;;;;;;;OAYG;IACH,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BAAkB,CAChC,QAAQ,EAAE,oBAAoB,GAC7B,QAAQ,IAAI,oBAAoB,GAAG,gBAAgB,CASrD;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;OASG;IACH,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACvC;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;OAOG;IACH,cAAc,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAChG;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,oBAAoB,GAAG,QAAQ,IAAI,oBAAoB,GAAG,UAAU,CAE1G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playApi.d.ts","sourceRoot":"","sources":["../../../src/rails/google/playApi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAuB,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"playApi.d.ts","sourceRoot":"","sources":["../../../src/rails/google/playApi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAuB,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMxD,OAAO,K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mBAAmB,CACvC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAU3C"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { PaymentsProviderUnavailableError, PaymentsRailNotConfiguredError, PaymentsVerificationFailedError } from "../../error/errors.js";
|
|
4
4
|
import { pauseResumesAt } from "../../data/pause.js";
|
|
5
|
+
import { statedQuantity } from "../quantity.js";
|
|
5
6
|
import { googleHttpFetch, googleJson } from "./http.js";
|
|
6
7
|
import { base64UrlEncode, pemPrivateKey } from "./jwt.js";
|
|
7
8
|
import { z } from "zod";
|
|
@@ -279,6 +280,7 @@ function playProductEvent(purchase, context) {
|
|
|
279
280
|
originalTransactionId: null,
|
|
280
281
|
amountMinor: null,
|
|
281
282
|
currency: null,
|
|
283
|
+
quantity: statedQuantity(purchase.quantity),
|
|
282
284
|
providerEventAt: context.eventAt,
|
|
283
285
|
payload: purchase
|
|
284
286
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/events.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAA+B,MAAM,OAAO,CAAC;AAIlG,OAAO,EAAE,KAAK,8BAA8B,EAAmB,MAAM,WAAW,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,MAAM,CAAC;A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"./read.js";
|
|
|
6
6
|
import { recordedPayload } from "./recorded.js";
|
|
7
7
|
import { readPaddleEvent } from "./webhook.js";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
+
import { commandName } from "@pithy-sh/core/src/cli/command";
|
|
9
10
|
//#region src/rails/paddle/events.ts
|
|
10
11
|
/**
|
|
11
12
|
* The events sweep — the repair `refresh` cannot make.
|
|
@@ -118,7 +119,7 @@ async function sweepPaddleEvents(options) {
|
|
|
118
119
|
events: [],
|
|
119
120
|
cursor: options.cursor,
|
|
120
121
|
hasMore: false,
|
|
121
|
-
gap: `Paddle no longer knows event ${options.cursor}, so the sweep cannot resume from it. Paddle retains 90 days of events, and anything between that cursor and the retention window is gone. Reconcile the affected purchases with
|
|
122
|
+
gap: `Paddle no longer knows event ${options.cursor}, so the sweep cannot resume from it. Paddle retains 90 days of events, and anything between that cursor and the retention window is gone. Reconcile the affected purchases with \`${commandName("payments reconcile")}\`, passing --rail paddle and this environment's --env, then clear the cursor to restart from the oldest retained event.`
|
|
122
123
|
};
|
|
123
124
|
throw cause;
|
|
124
125
|
}
|
|
@@ -124,6 +124,7 @@ export declare const PaddleTransaction: z.ZodObject<{
|
|
|
124
124
|
id: z.ZodOptional<z.ZodString>;
|
|
125
125
|
}, z.core.$loose>>;
|
|
126
126
|
price_id: z.ZodOptional<z.ZodString>;
|
|
127
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
127
128
|
}, z.core.$loose>>>;
|
|
128
129
|
details: z.ZodOptional<z.ZodObject<{
|
|
129
130
|
totals: z.ZodOptional<z.ZodObject<{
|
|
@@ -188,6 +189,7 @@ export declare const PaddleSubscription: z.ZodObject<{
|
|
|
188
189
|
id: z.ZodOptional<z.ZodString>;
|
|
189
190
|
}, z.core.$loose>>;
|
|
190
191
|
status: z.ZodOptional<z.ZodString>;
|
|
192
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
191
193
|
}, z.core.$loose>>>;
|
|
192
194
|
current_billing_period: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
193
195
|
starts_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/objects.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/objects.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAWrD,4EAA4E;AAC5E,eAAO,MAAM,WAAW;;;;;iBAkBsE,CAAC;AAC/F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAgBtD,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBA2BuF,CAAC;AACrH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,K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AC/B,YAAY,EAAE,kBAAkB,EAChC,UAAU,EAAE,IAAI,EAChB,WAAW,EAAE,mBAAmB,GAC/B,oBAAoB,CA2BtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIrH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAClD,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlH"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { decodeSubjectReference } from "../../data/subject.js";
|
|
4
4
|
import { PaymentsVerificationFailedError } from "../../error/errors.js";
|
|
5
5
|
import { pauseResumesAt } from "../../data/pause.js";
|
|
6
|
+
import { statedQuantity } from "../quantity.js";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
//#region src/rails/paddle/objects.ts
|
|
8
9
|
/**
|
|
@@ -104,7 +105,8 @@ const PaddleEvent = z.object({
|
|
|
104
105
|
/** One transaction line item, narrowed to the price it names. */
|
|
105
106
|
const PaddleTransactionItem = z.object({
|
|
106
107
|
price: z.object({ id: z.string().optional().describe("The price sold — this rail's SKU.") }).loose().optional().describe("The price object, which is where a transaction carries its SKU."),
|
|
107
|
-
price_id: z.string().optional().describe("The price id, on the shapes that carry it flat.")
|
|
108
|
+
price_id: z.string().optional().describe("The price id, on the shapes that carry it flat."),
|
|
109
|
+
quantity: z.number().int().optional().describe("How many of the price this line sold.")
|
|
108
110
|
}).loose().describe("One line of a transaction. Single-product checkouts have exactly one.");
|
|
109
111
|
/** An adjustment's fields — a refund, a credit, or a chargeback, which on this rail can arrive unsolicited. */
|
|
110
112
|
const PaddleAdjustment = z.object({
|
|
@@ -169,7 +171,8 @@ const PaddleSubscription = z.object({
|
|
|
169
171
|
customer_id: z.string().nullish().describe("The Paddle customer — this rail's `providerAccountId`."),
|
|
170
172
|
items: z.array(z.object({
|
|
171
173
|
price: z.object({ id: z.string().optional().describe("The price — `pri_…`. This rail's SKU.") }).loose().optional().describe("The price this item is billed at."),
|
|
172
|
-
status: z.string().optional().describe("The item's own status, which can differ from the subscription's.")
|
|
174
|
+
status: z.string().optional().describe("The item's own status, which can differ from the subscription's."),
|
|
175
|
+
quantity: z.number().int().optional().describe("How many of the price the subscription bills.")
|
|
173
176
|
}).loose().describe("One priced item on the subscription.")).optional().describe("The priced items. The first carries this rail's SKU."),
|
|
174
177
|
current_billing_period: z.object({
|
|
175
178
|
starts_at: z.string().nullish().describe("When the current period began."),
|
|
@@ -396,6 +399,7 @@ function transactionEvent(transaction, occurredAt, environment) {
|
|
|
396
399
|
revokedAt: null,
|
|
397
400
|
amountMinor: minorAmount(transaction.details?.totals?.grand_total),
|
|
398
401
|
currency: currencyOf(transaction.details?.totals?.currency_code ?? transaction.currency_code),
|
|
402
|
+
quantity: statedQuantity(transaction.items?.[0]?.quantity),
|
|
399
403
|
providerEventAt: occurredAt,
|
|
400
404
|
payload: { ...transaction }
|
|
401
405
|
};
|
|
@@ -481,6 +485,7 @@ function subscriptionEvent(subscription, occurredAt, environment) {
|
|
|
481
485
|
}),
|
|
482
486
|
amountMinor: null,
|
|
483
487
|
currency: null,
|
|
488
|
+
quantity: statedQuantity(subscription.items?.[0]?.quantity),
|
|
484
489
|
providerEventAt: occurredAt,
|
|
485
490
|
payload: { ...subscription }
|
|
486
491
|
};
|
|
@@ -14,9 +14,12 @@ import { type PaddleEnvironment, type PaddleHttpFetch } from "./api";
|
|
|
14
14
|
*
|
|
15
15
|
* ## Which rows it can answer for
|
|
16
16
|
*
|
|
17
|
-
* Paddle's ids are globally prefixed, so the row's own key says what to ask:
|
|
18
|
-
*
|
|
19
|
-
* money row records a closed period and has nothing to re-read.
|
|
17
|
+
* Paddle's ids are globally prefixed, so the row's own key says what to ask: a subscription id is a
|
|
18
|
+
* subscription, a transaction id is a transaction. Both are addressable, so both are re-read — unlike
|
|
19
|
+
* Lemon Squeezy, where a money row records a closed period and has nothing to re-read. **What counts as
|
|
20
|
+
* one of those keys is `data/paddleIds.ts`'s to say**, not this module's: a prefix test here accepted the
|
|
21
|
+
* bare prefix and an uppercase id, and spent a round trip finding out the store had never issued it
|
|
22
|
+
* (#681).
|
|
20
23
|
*
|
|
21
24
|
* A **subscription** transaction's money row is born `expired`, which is in the Workflow's terminal set,
|
|
22
25
|
* so the pass never selects one. Should one reach here it is answered honestly rather than skipped: a
|
|
@@ -49,8 +52,10 @@ export declare function refreshPaddlePurchase(purchase: PaymentsPurchase, option
|
|
|
49
52
|
* list price. Nothing here multiplies a price by a percentage — a second calculation would be a second
|
|
50
53
|
* answer to the one question a customer checks against their statement.
|
|
51
54
|
*
|
|
52
|
-
* Only a
|
|
53
|
-
* answers `undefined` — the same "nothing to say about
|
|
55
|
+
* Only a subscription row can be asked, and `data/paddleIds.ts` says which rows those are. A transaction
|
|
56
|
+
* records one closed period and has no "next", so it answers `undefined` — the same "nothing to say about
|
|
57
|
+
* this purchase" the refresh path uses, and the same answer a column holding something Paddle never
|
|
58
|
+
* issued now gets without a round trip (#681).
|
|
54
59
|
*/
|
|
55
60
|
export declare function readPaddlePricing(purchase: PaymentsPurchase, options: RefreshPaddleOptions): Promise<SubscriptionPricing | undefined>;
|
|
56
61
|
//# sourceMappingURL=refresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAA+B,MAAM,OAAO,CAAC;AAIlG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,wFAAwF;AACxF,MAAM,WAAW,oBAAoB;IACnC,8BAA8B;IAC9B,WAAW,EAAE,yBAAyB,CAAC;IACvC,yCAAyC;IACzC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,oEAAoE;IACpE,GAAG,EAAE,IAAI,CAAC;IACV,wDAAwD;IACxD,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,oFAAoF;AACpF,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CA4B3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAoC1C"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { paddleHttpFetch, paddleJson } from "./api.js";
|
|
4
4
|
import { currencyOf, minorAmount, subscriptionEvent, transactionEvent } from "./objects.js";
|
|
5
5
|
import { readSubscription, readTransaction } from "./read.js";
|
|
6
|
+
import { isPaddleSubscriptionId, isPaddleTransactionId } from "../../data/paddleIds.js";
|
|
6
7
|
//#region src/rails/paddle/refresh.ts
|
|
7
8
|
/** Re-read one purchase, or `undefined` when Paddle has nothing to say about it. */
|
|
8
9
|
async function refreshPaddlePurchase(purchase, options) {
|
|
@@ -13,7 +14,7 @@ async function refreshPaddlePurchase(purchase, options) {
|
|
|
13
14
|
};
|
|
14
15
|
const id = purchase.providerTransactionId;
|
|
15
16
|
const environment = options.environment === "production" ? "production" : "sandbox";
|
|
16
|
-
if (id
|
|
17
|
+
if (isPaddleSubscriptionId(id)) {
|
|
17
18
|
const subscription = await readSubscription(id, read);
|
|
18
19
|
if (subscription === void 0) return void 0;
|
|
19
20
|
return {
|
|
@@ -21,7 +22,7 @@ async function refreshPaddlePurchase(purchase, options) {
|
|
|
21
22
|
providerEventAt: options.now
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
if (id
|
|
25
|
+
if (isPaddleTransactionId(id)) {
|
|
25
26
|
const transaction = await readTransaction(id, read);
|
|
26
27
|
if (transaction === void 0) return void 0;
|
|
27
28
|
return {
|
|
@@ -38,12 +39,14 @@ async function refreshPaddlePurchase(purchase, options) {
|
|
|
38
39
|
* list price. Nothing here multiplies a price by a percentage — a second calculation would be a second
|
|
39
40
|
* answer to the one question a customer checks against their statement.
|
|
40
41
|
*
|
|
41
|
-
* Only a
|
|
42
|
-
* answers `undefined` — the same "nothing to say about
|
|
42
|
+
* Only a subscription row can be asked, and `data/paddleIds.ts` says which rows those are. A transaction
|
|
43
|
+
* records one closed period and has no "next", so it answers `undefined` — the same "nothing to say about
|
|
44
|
+
* this purchase" the refresh path uses, and the same answer a column holding something Paddle never
|
|
45
|
+
* issued now gets without a round trip (#681).
|
|
43
46
|
*/
|
|
44
47
|
async function readPaddlePricing(purchase, options) {
|
|
45
48
|
const id = purchase.providerTransactionId;
|
|
46
|
-
if (!id
|
|
49
|
+
if (!isPaddleSubscriptionId(id)) return void 0;
|
|
47
50
|
const answer = await paddleJson(options.transport ?? paddleHttpFetch, `/subscriptions/${encodeURIComponent(id)}`, {
|
|
48
51
|
what: `subscription ${id}'s pricing`,
|
|
49
52
|
apiKey: options.credentials.apiKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refund.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/refund.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refund.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/refund.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAuD,MAAM,yBAAyB,CAAC;AAE7G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAoD,MAAM,OAAO,CAAC;AAIvH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,WAAW,EAAE,yBAAyB,CAAC;IACvC,qCAAqC;IACrC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,wDAAwD;IACxD,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,8BAA8B,KAAK,CAAC;AA2GjD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAyFxB"}
|
|
@@ -5,6 +5,7 @@ import { RefundRequest } from "../../data/subscription.js";
|
|
|
5
5
|
import { paddleHttpFetch, paddleJson, redactPaddleSecrets } from "./api.js";
|
|
6
6
|
import { PaddleAdjustment } from "./objects.js";
|
|
7
7
|
import { PADDLE_ADJUSTMENTS_INCLUDE, readTransaction } from "./read.js";
|
|
8
|
+
import { isPaddleTransactionId } from "../../data/paddleIds.js";
|
|
8
9
|
import { REVOKING_ACTIONS } from "./adjustments.js";
|
|
9
10
|
//#region src/rails/paddle/refund.ts
|
|
10
11
|
/**
|
|
@@ -37,10 +38,17 @@ function refuse(detail) {
|
|
|
37
38
|
detail
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The transaction this purchase row names, or null when it names none.
|
|
43
|
+
*
|
|
44
|
+
* **The primitive decides, not a prefix test here.** `startsWith` accepted the bare prefix and Paddle's
|
|
45
|
+
* alphabet in uppercase, neither of which is an id the store can hold — so a malformed row cost a
|
|
46
|
+
* `GET /transactions/{id}` and then refused on the 404, naming the store rather than the row (#681).
|
|
47
|
+
* `data/paddleIds.ts` is the one place that says what a transaction id is.
|
|
48
|
+
*/
|
|
41
49
|
function transactionIdOf(purchase) {
|
|
42
50
|
const id = purchase.providerTransactionId;
|
|
43
|
-
return id
|
|
51
|
+
return isPaddleTransactionId(id) ? id : null;
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
54
|
* The adjustment already standing against this transaction, or undefined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/subscription.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAIL,uBAAuB,EAGvB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAA+B,MAAM,OAAO,CAAC;AAYlG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,4FAA4F;AAC5F,MAAM,WAAW,yBAAyB;IACxC,yFAAyF;IACzF,WAAW,EAAE,yBAAyB,CAAC;IACvC,qCAAqC;IACrC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,wDAAwD;IACxD,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AA+fD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAK3C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,yBAAyB,EAClC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CAuBlC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,CAAC,CA0B/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAsB/B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,oBAAoB,CAAC,CAsB/B"}
|
|
@@ -4,6 +4,7 @@ import { PaymentsProviderUnavailableError, PaymentsSubscriptionChangeRefusedErro
|
|
|
4
4
|
import { SubscriptionChangeQuote, SubscriptionStanding } from "../../data/subscription.js";
|
|
5
5
|
import { paddleHttpFetch, paddleJson } from "./api.js";
|
|
6
6
|
import { PaddleSubscription, PaddleSubscriptionPreview, currencyOf, minorAmount, subscriptionPendingChange, subscriptionStatus } from "./objects.js";
|
|
7
|
+
import { isPaddleSubscriptionId } from "../../data/paddleIds.js";
|
|
7
8
|
import { renderMoney } from "../../data/renderMoney.js";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
//#region src/rails/paddle/subscription.ts
|
|
@@ -89,12 +90,16 @@ function orNull(value) {
|
|
|
89
90
|
* The subscription this purchase names, or null when it names none.
|
|
90
91
|
*
|
|
91
92
|
* Paddle's ids are globally prefixed, so the row's own key says what it is — `refreshPaddlePurchase`'s rule,
|
|
92
|
-
* and for the same reason: a money row's family key is
|
|
93
|
-
* subscription from a row that is not one.
|
|
93
|
+
* and for the same reason: a money row's family key is the subscription's, and falling back to it would act
|
|
94
|
+
* on a subscription from a row that is not one.
|
|
95
|
+
*
|
|
96
|
+
* **`isPaddleSubscriptionId` rather than a prefix test, and all five callers feel it.** The prefix alone,
|
|
97
|
+
* and an id in an alphabet Paddle does not issue, used to read as subscriptions here: the read answered
|
|
98
|
+
* after a wasted round trip, and the other four refused on the store's answer instead of on the row (#681).
|
|
94
99
|
*/
|
|
95
100
|
function subscriptionIdOf(purchase) {
|
|
96
101
|
const id = purchase.providerTransactionId;
|
|
97
|
-
return id
|
|
102
|
+
return isPaddleSubscriptionId(id) ? id : null;
|
|
98
103
|
}
|
|
99
104
|
/** The subscription, or a refusal. Used by the write verbs, which have nothing to do without it. */
|
|
100
105
|
async function loadSubscription(id, options) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { UsageReporter } from "../../usage/reporter";
|
|
4
|
+
import { type PaddleEnvironment, type PaddleHttpFetch } from "./api";
|
|
5
|
+
/** The Paddle reporter, over the API key, the account and a transport. */
|
|
6
|
+
export declare function paddleUsageReporter(options: {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
environment: PaddleEnvironment;
|
|
9
|
+
transport?: PaddleHttpFetch;
|
|
10
|
+
}): UsageReporter;
|
|
11
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../../src/rails/paddle/usage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAA+B,MAAM,OAAO,CAAC;AAwBlG,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;IAC/B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B,GAAG,aAAa,CA8BhB"}
|