@pithy-sh/payments 0.1.1 → 0.1.3
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/dist/admin/coverage.d.ts +35 -0
- package/dist/admin/coverage.d.ts.map +1 -0
- package/dist/admin/coverage.js +56 -0
- package/dist/admin/read.d.ts +222 -0
- package/dist/admin/read.d.ts.map +1 -0
- package/dist/admin/read.js +159 -0
- package/dist/audit/actions.d.ts +211 -0
- package/dist/audit/actions.d.ts.map +1 -0
- package/dist/audit/actions.js +211 -0
- package/dist/capability.d.ts +72 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +228 -0
- package/dist/client/api.d.ts +435 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +415 -0
- package/dist/client/checkout.d.ts +144 -0
- package/dist/client/checkout.d.ts.map +1 -0
- package/dist/client/checkout.js +173 -0
- package/dist/client/fixtures/price-preview-de.js +89 -0
- package/dist/client/fixtures/price-preview-gb.js +89 -0
- package/dist/client/fixtures/price-preview-jp-yen.js +89 -0
- package/dist/client/fixtures/price-preview-us-country-only.js +89 -0
- package/dist/client/fixtures/price-preview-us-new-york.js +89 -0
- package/dist/client/fixtures/pricePreview.d.ts +54 -0
- package/dist/client/fixtures/pricePreview.d.ts.map +1 -0
- package/dist/client/fixtures/pricePreview.js +61 -0
- package/dist/client/hooks.d.ts +235 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +428 -0
- package/dist/client/paddle.d.ts +433 -0
- package/dist/client/paddle.d.ts.map +1 -0
- package/dist/client/paddle.js +391 -0
- package/dist/client/paddleCache.d.ts +123 -0
- package/dist/client/paddleCache.d.ts.map +1 -0
- package/dist/client/paddleCache.js +159 -0
- package/dist/client/paddlePrices.d.ts +94 -0
- package/dist/client/paddlePrices.d.ts.map +1 -0
- package/dist/client/paddlePrices.js +55 -0
- package/dist/client/paddlePricesTag.d.ts +127 -0
- package/dist/client/paddlePricesTag.d.ts.map +1 -0
- package/dist/client/paddlePricesTag.js +207 -0
- package/dist/client/projection.d.ts +128 -0
- package/dist/client/projection.d.ts.map +1 -0
- package/dist/client/projection.js +0 -0
- package/dist/client/test-utils/cacheStore.d.ts +18 -0
- package/dist/client/test-utils/cacheStore.d.ts.map +1 -0
- package/dist/client/test-utils/cacheStore.js +42 -0
- package/dist/client/wholeUnits.d.ts +18 -0
- package/dist/client/wholeUnits.d.ts.map +1 -0
- package/dist/client/wholeUnits.js +120 -0
- package/dist/config/config.d.ts +238 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +249 -0
- package/dist/data/discount.d.ts +127 -0
- package/dist/data/discount.d.ts.map +1 -0
- package/dist/data/discount.js +91 -0
- package/dist/data/entitlement.d.ts +43 -0
- package/dist/data/entitlement.d.ts.map +1 -0
- package/dist/data/entitlement.js +43 -0
- package/dist/data/money.d.ts +15 -0
- package/dist/data/money.d.ts.map +1 -0
- package/dist/data/money.js +76 -0
- package/dist/data/pause.d.ts +133 -0
- package/dist/data/pause.d.ts.map +1 -0
- package/dist/data/pause.js +63 -0
- package/dist/data/providerAccount.d.ts +40 -0
- package/dist/data/providerAccount.d.ts.map +1 -0
- package/dist/data/providerAccount.js +34 -0
- package/dist/data/purchase.d.ts +107 -0
- package/dist/data/purchase.d.ts.map +1 -0
- package/dist/data/purchase.js +77 -0
- package/dist/data/rail.d.ts +74 -0
- package/dist/data/rail.d.ts.map +1 -0
- package/dist/data/rail.js +74 -0
- package/dist/data/reconcileRun.d.ts +120 -0
- package/dist/data/reconcileRun.d.ts.map +1 -0
- package/dist/data/reconcileRun.js +120 -0
- package/dist/data/renderMoney.d.ts +85 -0
- package/dist/data/renderMoney.d.ts.map +1 -0
- package/dist/data/renderMoney.js +146 -0
- package/dist/data/status.d.ts +58 -0
- package/dist/data/status.d.ts.map +1 -0
- package/dist/data/status.js +68 -0
- package/dist/data/subject.d.ts +111 -0
- package/dist/data/subject.d.ts.map +1 -0
- package/dist/data/subject.js +125 -0
- package/dist/data/subscription.d.ts +624 -0
- package/dist/data/subscription.d.ts.map +1 -0
- package/dist/data/subscription.js +497 -0
- package/dist/data/syncCursor.d.ts +33 -0
- package/dist/data/syncCursor.d.ts.map +1 -0
- package/dist/data/syncCursor.js +29 -0
- package/dist/data/tables.d.ts +37 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/data/tables.js +44 -0
- package/dist/data/webhookEvent.d.ts +134 -0
- package/dist/data/webhookEvent.d.ts.map +1 -0
- package/dist/data/webhookEvent.js +128 -0
- package/dist/entitlement/manual.d.ts +101 -0
- package/dist/entitlement/manual.d.ts.map +1 -0
- package/dist/entitlement/manual.js +84 -0
- package/dist/entitlement/resolver.d.ts +60 -0
- package/dist/entitlement/resolver.d.ts.map +1 -0
- package/dist/entitlement/resolver.js +101 -0
- package/dist/entitlement/subjectSeam.d.ts +102 -0
- package/dist/entitlement/subjectSeam.d.ts.map +1 -0
- package/dist/entitlement/subjectSeam.js +85 -0
- package/dist/error/errors.d.ts +247 -0
- package/dist/error/errors.d.ts.map +1 -0
- package/dist/error/errors.js +326 -0
- package/dist/grants/apply.d.ts +74 -0
- package/dist/grants/apply.d.ts.map +1 -0
- package/dist/grants/apply.js +148 -0
- package/dist/grants/clawback.d.ts +43 -0
- package/dist/grants/clawback.d.ts.map +1 -0
- package/dist/grants/clawback.js +71 -0
- package/dist/grants/ledgerSeam.d.ts +89 -0
- package/dist/grants/ledgerSeam.d.ts.map +1 -0
- package/dist/grants/ledgerSeam.js +66 -0
- package/dist/http/dispatch.d.ts +35 -0
- package/dist/http/dispatch.d.ts.map +1 -0
- package/dist/http/dispatch.js +40 -0
- package/dist/http/guards.d.ts +43 -0
- package/dist/http/guards.d.ts.map +1 -0
- package/dist/http/guards.js +52 -0
- package/dist/http/manifestConfig.d.ts +38 -0
- package/dist/http/manifestConfig.d.ts.map +1 -0
- package/dist/http/manifestConfig.js +49 -0
- package/dist/http/responses.d.ts +1455 -0
- package/dist/http/responses.d.ts.map +1 -0
- package/dist/http/responses.js +728 -0
- package/dist/http/routes.d.ts +315 -0
- package/dist/http/routes.d.ts.map +1 -0
- package/dist/http/routes.js +1966 -0
- package/dist/http/schemas.d.ts +404 -0
- package/dist/http/schemas.d.ts.map +1 -0
- package/dist/http/schemas.js +359 -0
- package/dist/http/scopes.d.ts +160 -0
- package/dist/http/scopes.d.ts.map +1 -0
- package/dist/http/scopes.js +240 -0
- package/dist/http/view.d.ts +96 -0
- package/dist/http/view.d.ts.map +1 -0
- package/dist/http/view.js +170 -0
- package/dist/http/webhookGuard.d.ts +109 -0
- package/dist/http/webhookGuard.d.ts.map +1 -0
- package/dist/http/webhookGuard.js +206 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/migrations/0001_purchases.d.ts +35 -0
- package/dist/migrations/0001_purchases.d.ts.map +1 -0
- package/dist/migrations/0001_purchases.js +80 -0
- package/dist/pricing/location.d.ts +138 -0
- package/dist/pricing/location.d.ts.map +1 -0
- package/dist/pricing/location.js +81 -0
- package/dist/pricing/visitor.d.ts +56 -0
- package/dist/pricing/visitor.d.ts.map +1 -0
- package/dist/pricing/visitor.js +35 -0
- package/dist/projection/event.d.ts +66 -0
- package/dist/projection/event.d.ts.map +1 -0
- package/dist/projection/event.js +45 -0
- package/dist/projection/orphans.d.ts +114 -0
- package/dist/projection/orphans.d.ts.map +1 -0
- package/dist/projection/orphans.js +162 -0
- package/dist/projection/owner.d.ts +121 -0
- package/dist/projection/owner.d.ts.map +1 -0
- package/dist/projection/owner.js +114 -0
- package/dist/projection/resolve.d.ts +30 -0
- package/dist/projection/resolve.d.ts.map +1 -0
- package/dist/projection/resolve.js +42 -0
- package/dist/projection/writer.d.ts +103 -0
- package/dist/projection/writer.d.ts.map +1 -0
- package/dist/projection/writer.js +280 -0
- package/dist/provision/resolvePaymentsConfig.d.ts +48 -0
- package/dist/provision/resolvePaymentsConfig.d.ts.map +1 -0
- package/dist/provision/resolvePaymentsConfig.js +41 -0
- package/dist/rails/apple/certs.d.ts +7 -0
- package/dist/rails/apple/certs.d.ts.map +1 -0
- package/dist/rails/apple/certs.js +8 -0
- package/dist/rails/apple/der.d.ts +107 -0
- package/dist/rails/apple/der.d.ts.map +1 -0
- package/dist/rails/apple/der.js +217 -0
- package/dist/rails/apple/fixtures/chain.d.ts +117 -0
- package/dist/rails/apple/fixtures/chain.d.ts.map +1 -0
- package/dist/rails/apple/fixtures/chain.js +289 -0
- package/dist/rails/apple/http.d.ts +74 -0
- package/dist/rails/apple/http.d.ts.map +1 -0
- package/dist/rails/apple/http.js +32 -0
- package/dist/rails/apple/jws.d.ts +17 -0
- package/dist/rails/apple/jws.d.ts.map +1 -0
- package/dist/rails/apple/jws.js +75 -0
- package/dist/rails/apple/notification.d.ts +116 -0
- package/dist/rails/apple/notification.d.ts.map +1 -0
- package/dist/rails/apple/notification.js +199 -0
- package/dist/rails/apple/rail.d.ts +25 -0
- package/dist/rails/apple/rail.d.ts.map +1 -0
- package/dist/rails/apple/rail.js +68 -0
- package/dist/rails/apple/serverApi.d.ts +120 -0
- package/dist/rails/apple/serverApi.d.ts.map +1 -0
- package/dist/rails/apple/serverApi.js +244 -0
- package/dist/rails/apple/verify.d.ts +36 -0
- package/dist/rails/apple/verify.d.ts.map +1 -0
- package/dist/rails/apple/verify.js +46 -0
- package/dist/rails/apple/x509.d.ts +85 -0
- package/dist/rails/apple/x509.d.ts.map +1 -0
- package/dist/rails/apple/x509.js +273 -0
- package/dist/rails/contract.d.ts +871 -0
- package/dist/rails/contract.d.ts.map +1 -0
- package/dist/rails/contract.js +60 -0
- package/dist/rails/google/fixtures/push.d.ts +71 -0
- package/dist/rails/google/fixtures/push.d.ts.map +1 -0
- package/dist/rails/google/fixtures/push.js +107 -0
- package/dist/rails/google/http.d.ts +77 -0
- package/dist/rails/google/http.d.ts.map +1 -0
- package/dist/rails/google/http.js +39 -0
- package/dist/rails/google/jwt.d.ts +53 -0
- package/dist/rails/google/jwt.d.ts.map +1 -0
- package/dist/rails/google/jwt.js +94 -0
- package/dist/rails/google/oidc.d.ts +112 -0
- package/dist/rails/google/oidc.d.ts.map +1 -0
- package/dist/rails/google/oidc.js +179 -0
- package/dist/rails/google/playApi.d.ts +188 -0
- package/dist/rails/google/playApi.d.ts.map +1 -0
- package/dist/rails/google/playApi.js +350 -0
- package/dist/rails/google/rail.d.ts +57 -0
- package/dist/rails/google/rail.d.ts.map +1 -0
- package/dist/rails/google/rail.js +70 -0
- package/dist/rails/google/rtdn.d.ts +105 -0
- package/dist/rails/google/rtdn.d.ts.map +1 -0
- package/dist/rails/google/rtdn.js +179 -0
- package/dist/rails/google/verify.d.ts +20 -0
- package/dist/rails/google/verify.d.ts.map +1 -0
- package/dist/rails/google/verify.js +76 -0
- package/dist/rails/lemonSqueezy/api.d.ts +92 -0
- package/dist/rails/lemonSqueezy/api.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/api.js +121 -0
- package/dist/rails/lemonSqueezy/checkout.d.ts +52 -0
- package/dist/rails/lemonSqueezy/checkout.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/checkout.js +84 -0
- package/dist/rails/lemonSqueezy/discounts.d.ts +50 -0
- package/dist/rails/lemonSqueezy/discounts.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/discounts.js +75 -0
- package/dist/rails/lemonSqueezy/fixtures/events.d.ts +56 -0
- package/dist/rails/lemonSqueezy/fixtures/events.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/fixtures/events.js +144 -0
- package/dist/rails/lemonSqueezy/objects.d.ts +229 -0
- package/dist/rails/lemonSqueezy/objects.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/objects.js +379 -0
- package/dist/rails/lemonSqueezy/portal.d.ts +35 -0
- package/dist/rails/lemonSqueezy/portal.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/portal.js +18 -0
- package/dist/rails/lemonSqueezy/pricing.d.ts +25 -0
- package/dist/rails/lemonSqueezy/pricing.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/pricing.js +54 -0
- package/dist/rails/lemonSqueezy/rail.d.ts +41 -0
- package/dist/rails/lemonSqueezy/rail.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/rail.js +67 -0
- package/dist/rails/lemonSqueezy/read.d.ts +28 -0
- package/dist/rails/lemonSqueezy/read.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/read.js +37 -0
- package/dist/rails/lemonSqueezy/refresh.d.ts +42 -0
- package/dist/rails/lemonSqueezy/refresh.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/refresh.js +40 -0
- package/dist/rails/lemonSqueezy/signature.d.ts +56 -0
- package/dist/rails/lemonSqueezy/signature.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/signature.js +92 -0
- package/dist/rails/lemonSqueezy/verify.d.ts +33 -0
- package/dist/rails/lemonSqueezy/verify.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/verify.js +41 -0
- package/dist/rails/lemonSqueezy/webhook.d.ts +53 -0
- package/dist/rails/lemonSqueezy/webhook.d.ts.map +1 -0
- package/dist/rails/lemonSqueezy/webhook.js +179 -0
- package/dist/rails/paddle/adjustments.d.ts +60 -0
- package/dist/rails/paddle/adjustments.d.ts.map +1 -0
- package/dist/rails/paddle/adjustments.js +66 -0
- package/dist/rails/paddle/api.d.ts +138 -0
- package/dist/rails/paddle/api.d.ts.map +1 -0
- package/dist/rails/paddle/api.js +152 -0
- package/dist/rails/paddle/checkout.d.ts +69 -0
- package/dist/rails/paddle/checkout.d.ts.map +1 -0
- package/dist/rails/paddle/checkout.js +100 -0
- package/dist/rails/paddle/discounts.d.ts +67 -0
- package/dist/rails/paddle/discounts.d.ts.map +1 -0
- package/dist/rails/paddle/discounts.js +73 -0
- package/dist/rails/paddle/events.d.ts +140 -0
- package/dist/rails/paddle/events.d.ts.map +1 -0
- package/dist/rails/paddle/events.js +183 -0
- package/dist/rails/paddle/fixtures/browserForged.d.ts +42 -0
- package/dist/rails/paddle/fixtures/browserForged.d.ts.map +1 -0
- package/dist/rails/paddle/fixtures/browserForged.js +52 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.d.ts +78 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.d.ts.map +1 -0
- package/dist/rails/paddle/fixtures/pausedSubscription.js +76 -0
- package/dist/rails/paddle/objects.d.ts +519 -0
- package/dist/rails/paddle/objects.d.ts.map +1 -0
- package/dist/rails/paddle/objects.js +588 -0
- package/dist/rails/paddle/portal.d.ts +45 -0
- package/dist/rails/paddle/portal.d.ts.map +1 -0
- package/dist/rails/paddle/portal.js +42 -0
- package/dist/rails/paddle/rail.d.ts +55 -0
- package/dist/rails/paddle/rail.d.ts.map +1 -0
- package/dist/rails/paddle/rail.js +117 -0
- package/dist/rails/paddle/read.d.ts +53 -0
- package/dist/rails/paddle/read.d.ts.map +1 -0
- package/dist/rails/paddle/read.js +66 -0
- package/dist/rails/paddle/recorded.d.ts +49 -0
- package/dist/rails/paddle/recorded.d.ts.map +1 -0
- package/dist/rails/paddle/recorded.js +79 -0
- package/dist/rails/paddle/refresh.d.ts +54 -0
- package/dist/rails/paddle/refresh.d.ts.map +1 -0
- package/dist/rails/paddle/refresh.js +94 -0
- package/dist/rails/paddle/refund.d.ts +82 -0
- package/dist/rails/paddle/refund.d.ts.map +1 -0
- package/dist/rails/paddle/refund.js +175 -0
- package/dist/rails/paddle/signature.d.ts +83 -0
- package/dist/rails/paddle/signature.d.ts.map +1 -0
- package/dist/rails/paddle/signature.js +163 -0
- package/dist/rails/paddle/subscription.d.ts +137 -0
- package/dist/rails/paddle/subscription.d.ts.map +1 -0
- package/dist/rails/paddle/subscription.js +538 -0
- package/dist/rails/paddle/verify.d.ts +46 -0
- package/dist/rails/paddle/verify.d.ts.map +1 -0
- package/dist/rails/paddle/verify.js +43 -0
- package/dist/rails/paddle/webhook.d.ts +98 -0
- package/dist/rails/paddle/webhook.d.ts.map +1 -0
- package/dist/rails/paddle/webhook.js +181 -0
- package/dist/rails/providers.d.ts +73 -0
- package/dist/rails/providers.d.ts.map +1 -0
- package/dist/rails/providers.js +62 -0
- package/dist/rails/stripe/api.d.ts +118 -0
- package/dist/rails/stripe/api.d.ts.map +1 -0
- package/dist/rails/stripe/api.js +153 -0
- package/dist/rails/stripe/checkout.d.ts +60 -0
- package/dist/rails/stripe/checkout.d.ts.map +1 -0
- package/dist/rails/stripe/checkout.js +86 -0
- package/dist/rails/stripe/discounts.d.ts +50 -0
- package/dist/rails/stripe/discounts.d.ts.map +1 -0
- package/dist/rails/stripe/discounts.js +87 -0
- package/dist/rails/stripe/fixtures/events.d.ts +64 -0
- package/dist/rails/stripe/fixtures/events.d.ts.map +1 -0
- package/dist/rails/stripe/fixtures/events.js +67 -0
- package/dist/rails/stripe/objects.d.ts +237 -0
- package/dist/rails/stripe/objects.d.ts.map +1 -0
- package/dist/rails/stripe/objects.js +389 -0
- package/dist/rails/stripe/portal.d.ts +29 -0
- package/dist/rails/stripe/portal.d.ts.map +1 -0
- package/dist/rails/stripe/portal.js +41 -0
- package/dist/rails/stripe/pricing.d.ts +25 -0
- package/dist/rails/stripe/pricing.d.ts.map +1 -0
- package/dist/rails/stripe/pricing.js +68 -0
- package/dist/rails/stripe/rail.d.ts +28 -0
- package/dist/rails/stripe/rail.d.ts.map +1 -0
- package/dist/rails/stripe/rail.js +81 -0
- package/dist/rails/stripe/refresh.d.ts +33 -0
- package/dist/rails/stripe/refresh.d.ts.map +1 -0
- package/dist/rails/stripe/refresh.js +21 -0
- package/dist/rails/stripe/signature.d.ts +71 -0
- package/dist/rails/stripe/signature.d.ts.map +1 -0
- package/dist/rails/stripe/signature.js +92 -0
- package/dist/rails/stripe/verify.d.ts +15 -0
- package/dist/rails/stripe/verify.d.ts.map +1 -0
- package/dist/rails/stripe/verify.js +63 -0
- package/dist/rails/stripe/webhook.d.ts +26 -0
- package/dist/rails/stripe/webhook.d.ts.map +1 -0
- package/dist/rails/stripe/webhook.js +31 -0
- package/dist/secret/registry.d.ts +192 -0
- package/dist/secret/registry.d.ts.map +1 -0
- package/dist/secret/registry.js +154 -0
- package/dist/seeds/example.d.ts +3 -0
- package/dist/seeds/example.d.ts.map +1 -0
- package/dist/seeds/example.js +171 -0
- package/dist/version.generated.d.ts +5 -0
- package/dist/version.generated.d.ts.map +1 -0
- package/dist/version.generated.js +7 -0
- package/dist/workflows/paddleSweep.d.ts +175 -0
- package/dist/workflows/paddleSweep.d.ts.map +1 -0
- package/dist/workflows/paddleSweep.js +433 -0
- package/dist/workflows/railAccess.d.ts +48 -0
- package/dist/workflows/railAccess.d.ts.map +1 -0
- package/dist/workflows/railAccess.js +36 -0
- package/dist/workflows/reconcile.d.ts +161 -0
- package/dist/workflows/reconcile.d.ts.map +1 -0
- package/dist/workflows/reconcile.js +352 -0
- package/dist/workflows/report.d.ts +28 -0
- package/dist/workflows/report.d.ts.map +1 -0
- package/dist/workflows/report.js +54 -0
- package/dist/workflows/retryPolicy.d.ts +29 -0
- package/dist/workflows/retryPolicy.d.ts.map +1 -0
- package/dist/workflows/retryPolicy.js +37 -0
- package/dist/workflows/specs.d.ts +102 -0
- package/dist/workflows/specs.d.ts.map +1 -0
- package/dist/workflows/specs.js +84 -0
- package/dist/workflows/worker.d.ts +62 -0
- package/dist/workflows/worker.d.ts.map +1 -0
- package/dist/workflows/worker.js +92 -0
- package/dist/workflows/workerConfig.d.ts +46 -0
- package/dist/workflows/workerConfig.d.ts.map +1 -0
- package/dist/workflows/workerConfig.js +38 -0
- package/package.json +22 -13
- package/pithy.manifest.json +19 -13
- package/src/version.generated.ts +1 -1
- package/src/client/paddlePrices.iife.ts +0 -43
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/data/money.ts
|
|
2
|
+
/**
|
|
3
|
+
* Money, as the three rails report it and as the purchases table stores it.
|
|
4
|
+
*
|
|
5
|
+
* `amountMinor` is an integer in the currency's minor unit — cents for USD, yen for JPY, fils for KWD.
|
|
6
|
+
* No rail reports that directly. Apple reports thousandths of the currency unit ("milliunits"), Google
|
|
7
|
+
* reports millionths ("micros"), and Stripe reports minor units already. Converting means dividing by the
|
|
8
|
+
* rail's scale and then multiplying by the currency's own exponent, and the exponent is the part that
|
|
9
|
+
* catches people out: dividing Apple's 500000 for ¥500 by ten yields 50000, a hundredfold overstatement,
|
|
10
|
+
* because the yen has no subunit to divide into.
|
|
11
|
+
*
|
|
12
|
+
* So this holds the short list of currencies whose exponent is not two. It is a fixed list — ISO 4217 does
|
|
13
|
+
* not churn — and an unknown code falls back to two rather than throwing, because a webhook must not fail
|
|
14
|
+
* over a reporting detail.
|
|
15
|
+
*
|
|
16
|
+
* **{@link minorUnitDigits} is read from the browser half too**, by `../client/wholeUnits`, which is why
|
|
17
|
+
* this module imports nothing and must keep importing nothing: it is on the browser allowlist in
|
|
18
|
+
* `../client/sameOrigin.test.ts`, so anything reached from here lands in an adopter's bundle. The
|
|
19
|
+
* exponent is the same fact on both sides — how many digits the fraction occupies — and a second table
|
|
20
|
+
* for the client would be the drift `#427` exists to remove.
|
|
21
|
+
*/
|
|
22
|
+
/** Currencies with no subunit — the amount is already in minor units whatever the rail's scale. */
|
|
23
|
+
const ZERO_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
24
|
+
"BIF",
|
|
25
|
+
"CLP",
|
|
26
|
+
"DJF",
|
|
27
|
+
"GNF",
|
|
28
|
+
"ISK",
|
|
29
|
+
"JPY",
|
|
30
|
+
"KMF",
|
|
31
|
+
"KRW",
|
|
32
|
+
"PYG",
|
|
33
|
+
"RWF",
|
|
34
|
+
"UGX",
|
|
35
|
+
"UYI",
|
|
36
|
+
"VND",
|
|
37
|
+
"VUV",
|
|
38
|
+
"XAF",
|
|
39
|
+
"XOF",
|
|
40
|
+
"XPF"
|
|
41
|
+
]);
|
|
42
|
+
/** Currencies whose minor unit is a thousandth, not a hundredth. */
|
|
43
|
+
const THREE_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
44
|
+
"BHD",
|
|
45
|
+
"IQD",
|
|
46
|
+
"JOD",
|
|
47
|
+
"KWD",
|
|
48
|
+
"LYD",
|
|
49
|
+
"OMR",
|
|
50
|
+
"TND"
|
|
51
|
+
]);
|
|
52
|
+
/** How many digits the currency's minor unit occupies. Two unless ISO 4217 says otherwise. */
|
|
53
|
+
function minorUnitDigits(currency) {
|
|
54
|
+
const code = currency.toUpperCase();
|
|
55
|
+
if (ZERO_DECIMAL_CURRENCIES.has(code)) return 0;
|
|
56
|
+
if (THREE_DECIMAL_CURRENCIES.has(code)) return 3;
|
|
57
|
+
return 2;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Convert a rail-reported amount into minor units, or null when it cannot be trusted.
|
|
61
|
+
*
|
|
62
|
+
* `scale` is what one currency unit is worth in the rail's own integer — 1000 for Apple's milliunits,
|
|
63
|
+
* 1_000_000 for Google's micros, 10 ** `minorUnitDigits` for a rail already reporting minor units.
|
|
64
|
+
*
|
|
65
|
+
* Null is returned rather than an approximation for a missing price, a missing currency, a non-finite
|
|
66
|
+
* number, or a negative amount. The last matters: `pithy_payments_purchases` refuses a negative
|
|
67
|
+
* `amountMinor` by CHECK constraint, so a rail reporting one would abort the whole projection batch and
|
|
68
|
+
* lose the purchase. An absent amount costs a reporting figure; a lost purchase costs a subscriber.
|
|
69
|
+
*/
|
|
70
|
+
function minorUnitsFromScaled(scaled, scale, currency) {
|
|
71
|
+
if (scaled === null || currency === null) return null;
|
|
72
|
+
if (!Number.isFinite(scaled) || scaled < 0) return null;
|
|
73
|
+
return Math.round(scaled * 10 ** minorUnitDigits(currency) / scale);
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { minorUnitDigits, minorUnitsFromScaled };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { PaymentsRail } from "./rail";
|
|
2
|
+
import type { PurchaseStatus } from "./status";
|
|
3
|
+
/**
|
|
4
|
+
* When a paused subscription comes back — the one place every rail answers it.
|
|
5
|
+
*
|
|
6
|
+
* A pause is not an ending, and the single most useful thing anything can say about one is the date it
|
|
7
|
+
* ends. Two rails parsed that date out of a provider response and then dropped it, which is worse than
|
|
8
|
+
* never reading it: the value was provably present and understood, and no caller could reach it (#369).
|
|
9
|
+
* So the answer is stated once here rather than per rail, and the seam is shaped so a sixth rail inherits
|
|
10
|
+
* it instead of repeating the omission.
|
|
11
|
+
*
|
|
12
|
+
* ## Three facts, and they are different facts
|
|
13
|
+
*
|
|
14
|
+
* - **Not paused.** `status` is anything but `paused`, and there is nothing to resume. `resumesAt` is null
|
|
15
|
+
* and {@link pauseResumesAt} will not let it be anything else — a date beside a live subscription is a
|
|
16
|
+
* sentence nobody can write ("active until it resumes on the 14th"), and the purchases table carries a
|
|
17
|
+
* check constraint saying so.
|
|
18
|
+
* - **Paused, with a date.** The provider named it. `resumesAt` is that instant, decoded from the
|
|
19
|
+
* provider's own string and never computed from anything else.
|
|
20
|
+
* - **Paused, indefinitely.** The provider was asked and said none: a Play pause with no `autoResumeTime`,
|
|
21
|
+
* a Paddle pause with no scheduled resume, a Lemon Squeezy pause with `resumes_at: null`. `resumesAt` is
|
|
22
|
+
* null, and "paused until the 14th" and "paused indefinitely" are different sentences a consumer will
|
|
23
|
+
* want to write.
|
|
24
|
+
*
|
|
25
|
+
* **Null on a paused row therefore means indefinite, not "we did not look"** — and that is only true
|
|
26
|
+
* because {@link PAYMENTS_PAUSE_RESUMPTION} is total over the rails and every rail able to report `paused`
|
|
27
|
+
* either reads its provider's field or states why there is no field to read. A rail's `{ none }` reason is
|
|
28
|
+
* a fact about that store, so a consumer that wants to distinguish "this store never dates a pause" from
|
|
29
|
+
* "this pause has no date" reads the table: it is exported for exactly that question.
|
|
30
|
+
*
|
|
31
|
+
* ## Never computed
|
|
32
|
+
*
|
|
33
|
+
* The date is the provider's or it does not exist. Nothing here adds a pause duration to a start date, and
|
|
34
|
+
* nothing falls back to a period end — the fallback available when this was filed was `periodEnd`, which
|
|
35
|
+
* is a period end and not a resumption, and reaching for it would have put a wrong date in a letter to a
|
|
36
|
+
* paying customer. That is worse than an absent one. The only input this function takes is the string the
|
|
37
|
+
* provider sent, which is what makes "never computed" a property of the signature rather than a promise.
|
|
38
|
+
*/
|
|
39
|
+
/** How one rail answers "when does this come back": the provider field it reads, or why there is none. */
|
|
40
|
+
export type PauseResumption = {
|
|
41
|
+
/** The provider field carrying the resume date, in that provider's own spelling. */
|
|
42
|
+
readonly field: string;
|
|
43
|
+
} | {
|
|
44
|
+
/** Why this rail has no resume date to read. A fact about the store, not an exemption. */
|
|
45
|
+
readonly none: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Every rail, and where its paused subscriptions state their resume date.
|
|
49
|
+
*
|
|
50
|
+
* `satisfies Record<PaymentsRail, …>` rather than a partial map, exactly as `PAYMENTS_TABLE_DISCLOSURE`
|
|
51
|
+
* is: **a sixth rail does not compile until somebody decides how it answers this.** That is the structural
|
|
52
|
+
* half of the gate; `pause.test.ts` is the other half, and drives each declared field through the rail
|
|
53
|
+
* that reads it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const PAYMENTS_PAUSE_RESUMPTION: {
|
|
56
|
+
/**
|
|
57
|
+
* No pause at all. StoreKit has no paused state — a subscriber either renews, lapses, or is refunded —
|
|
58
|
+
* so `appleStatus` cannot produce `paused` and there is no date to look for.
|
|
59
|
+
*/
|
|
60
|
+
readonly apple: {
|
|
61
|
+
readonly none: "StoreKit has no paused subscription state, so no Apple purchase is ever projected as paused.";
|
|
62
|
+
};
|
|
63
|
+
/** Play states it directly. Absent for an indefinite pause, which is a state Play genuinely has. */
|
|
64
|
+
readonly google: {
|
|
65
|
+
readonly field: "pausedStateContext.autoResumeTime";
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Stripe's `paused` is not a pause with a date. It is a trial that ended with no payment method while
|
|
69
|
+
* `trial_settings.end_behavior.missing_payment_method` is `pause`, and it resumes when a card arrives
|
|
70
|
+
* rather than on a date — Stripe publishes none for it.
|
|
71
|
+
*
|
|
72
|
+
* `pause_collection.resumes_at` is a **different mechanism**: pausing collection leaves the subscription
|
|
73
|
+
* `active`, so it never produces a row this field could sit on. Modeling that is a separate question
|
|
74
|
+
* about a state this package does not have, and it is on #369's sweep rather than smuggled in here.
|
|
75
|
+
*/
|
|
76
|
+
readonly stripe: {
|
|
77
|
+
readonly none: "Stripe's `paused` is a trial ended without a payment method; it resumes when one arrives, and Stripe publishes no date for it. `pause_collection.resumes_at` is a different mechanism that leaves the status `active`.";
|
|
78
|
+
};
|
|
79
|
+
/** Lemon Squeezy states it on the pause object. Null there is an open-ended pause. */
|
|
80
|
+
readonly lemonSqueezy: {
|
|
81
|
+
readonly field: "pause.resumes_at";
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Paddle states it on the scheduled change — and **not** in the field named after it.
|
|
85
|
+
*
|
|
86
|
+
* Verified against a live sandbox on 2026-08-15. Pausing immediately with a `resume_at` leaves
|
|
87
|
+
* `scheduled_change: { action: "resume", effective_at: "2026-10-01T00:00:00Z", resume_at: null }`: the
|
|
88
|
+
* date moves to `effective_at` and the field literally called `resume_at` is null. `resume_at` carries
|
|
89
|
+
* it only while a *pause* is scheduled and the subscription is still `active`, which is not a paused
|
|
90
|
+
* subscription and not this field. Pausing with no resume date leaves `scheduled_change: null` — an
|
|
91
|
+
* indefinite pause, reported as one.
|
|
92
|
+
*
|
|
93
|
+
* A fix keyed on `resume_at` alone would therefore have shipped null for every paused Paddle
|
|
94
|
+
* subscription while looking correct, so both spellings are read and the one that means resumption wins.
|
|
95
|
+
*/
|
|
96
|
+
readonly paddle: {
|
|
97
|
+
readonly field: "scheduled_change.effective_at (action `resume`), or scheduled_change.resume_at";
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* A rail that reads a resume date, as a type.
|
|
102
|
+
*
|
|
103
|
+
* Derived from the table rather than restated, so {@link pauseResumesAt} **cannot be called** for a rail
|
|
104
|
+
* declared `{ none }`: a store with no resume date has no way to report one, and the refusal is a compile
|
|
105
|
+
* error rather than a review comment.
|
|
106
|
+
*/
|
|
107
|
+
export type ResumingRail = {
|
|
108
|
+
[Rail in PaymentsRail]: (typeof PAYMENTS_PAUSE_RESUMPTION)[Rail] extends {
|
|
109
|
+
readonly field: string;
|
|
110
|
+
} ? Rail : never;
|
|
111
|
+
}[PaymentsRail];
|
|
112
|
+
/** What a rail hands over: which rail, what state it is reporting, and the provider's own string. */
|
|
113
|
+
export interface PauseResumptionInput {
|
|
114
|
+
/** The rail reporting. Only a rail declaring a field in {@link PAYMENTS_PAUSE_RESUMPTION} may. */
|
|
115
|
+
rail: ResumingRail;
|
|
116
|
+
/** The normalized status this event carries. Anything but `paused` has nothing to resume. */
|
|
117
|
+
status: PurchaseStatus;
|
|
118
|
+
/**
|
|
119
|
+
* The provider's own resume date, verbatim — an RFC 3339 string. Null, undefined or empty is the
|
|
120
|
+
* provider saying there is none, which is an indefinite pause rather than a missing read.
|
|
121
|
+
*/
|
|
122
|
+
reported: string | null | undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The resume date to project, from what the provider said.
|
|
126
|
+
*
|
|
127
|
+
* Refuses an unreadable string rather than passing it on: `new Date("soon")` is an Invalid Date, and
|
|
128
|
+
* `SQLiteDate` encodes one as `NaN` — a corrupt column value that no read can tell from a real instant.
|
|
129
|
+
* That is the same refusal every other timestamp on these rails makes, and it leaves the delivery recorded
|
|
130
|
+
* for the reconciliation pass rather than silently written.
|
|
131
|
+
*/
|
|
132
|
+
export declare function pauseResumesAt(input: PauseResumptionInput): Date | null;
|
|
133
|
+
//# sourceMappingURL=pause.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../src/data/pause.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,0GAA0G;AAC1G,MAAM,MAAM,eAAe,GACvB;IACE,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IACE,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEN;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;IACpC;;;OAGG;;iBACM,IAAI,EAAE,8FAA8F;;IAC7G,oGAAoG;;iBAC1F,KAAK,EAAE,mCAAmC;;IACpD;;;;;;;;OAQG;;iBAED,IAAI,EAAE,wNAAwN;;IAEhO,sFAAsF;;iBACtE,KAAK,EAAE,kBAAkB;;IACzC;;;;;;;;;;;;OAYG;;iBACO,KAAK,EAAE,gFAAgF;;CACzC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;KACxB,IAAI,IAAI,YAAY,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,IAAI,CAAC,SAAS;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,KAAK;CACnH,CAAC,YAAY,CAAC,CAAC;AAEhB,qGAAqG;AACrG,MAAM,WAAW,oBAAoB;IACnC,kGAAkG;IAClG,IAAI,EAAE,YAAY,CAAC;IACnB,6FAA6F;IAC7F,MAAM,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAcvE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { PaymentsVerificationFailedError } from "../error/errors.js";
|
|
2
|
+
//#region src/data/pause.ts
|
|
3
|
+
/**
|
|
4
|
+
* Every rail, and where its paused subscriptions state their resume date.
|
|
5
|
+
*
|
|
6
|
+
* `satisfies Record<PaymentsRail, …>` rather than a partial map, exactly as `PAYMENTS_TABLE_DISCLOSURE`
|
|
7
|
+
* is: **a sixth rail does not compile until somebody decides how it answers this.** That is the structural
|
|
8
|
+
* half of the gate; `pause.test.ts` is the other half, and drives each declared field through the rail
|
|
9
|
+
* that reads it.
|
|
10
|
+
*/
|
|
11
|
+
const PAYMENTS_PAUSE_RESUMPTION = {
|
|
12
|
+
/**
|
|
13
|
+
* No pause at all. StoreKit has no paused state — a subscriber either renews, lapses, or is refunded —
|
|
14
|
+
* so `appleStatus` cannot produce `paused` and there is no date to look for.
|
|
15
|
+
*/
|
|
16
|
+
apple: { none: "StoreKit has no paused subscription state, so no Apple purchase is ever projected as paused." },
|
|
17
|
+
/** Play states it directly. Absent for an indefinite pause, which is a state Play genuinely has. */
|
|
18
|
+
google: { field: "pausedStateContext.autoResumeTime" },
|
|
19
|
+
/**
|
|
20
|
+
* Stripe's `paused` is not a pause with a date. It is a trial that ended with no payment method while
|
|
21
|
+
* `trial_settings.end_behavior.missing_payment_method` is `pause`, and it resumes when a card arrives
|
|
22
|
+
* rather than on a date — Stripe publishes none for it.
|
|
23
|
+
*
|
|
24
|
+
* `pause_collection.resumes_at` is a **different mechanism**: pausing collection leaves the subscription
|
|
25
|
+
* `active`, so it never produces a row this field could sit on. Modeling that is a separate question
|
|
26
|
+
* about a state this package does not have, and it is on #369's sweep rather than smuggled in here.
|
|
27
|
+
*/
|
|
28
|
+
stripe: { none: "Stripe's `paused` is a trial ended without a payment method; it resumes when one arrives, and Stripe publishes no date for it. `pause_collection.resumes_at` is a different mechanism that leaves the status `active`." },
|
|
29
|
+
/** Lemon Squeezy states it on the pause object. Null there is an open-ended pause. */
|
|
30
|
+
lemonSqueezy: { field: "pause.resumes_at" },
|
|
31
|
+
/**
|
|
32
|
+
* Paddle states it on the scheduled change — and **not** in the field named after it.
|
|
33
|
+
*
|
|
34
|
+
* Verified against a live sandbox on 2026-08-15. Pausing immediately with a `resume_at` leaves
|
|
35
|
+
* `scheduled_change: { action: "resume", effective_at: "2026-10-01T00:00:00Z", resume_at: null }`: the
|
|
36
|
+
* date moves to `effective_at` and the field literally called `resume_at` is null. `resume_at` carries
|
|
37
|
+
* it only while a *pause* is scheduled and the subscription is still `active`, which is not a paused
|
|
38
|
+
* subscription and not this field. Pausing with no resume date leaves `scheduled_change: null` — an
|
|
39
|
+
* indefinite pause, reported as one.
|
|
40
|
+
*
|
|
41
|
+
* A fix keyed on `resume_at` alone would therefore have shipped null for every paused Paddle
|
|
42
|
+
* subscription while looking correct, so both spellings are read and the one that means resumption wins.
|
|
43
|
+
*/
|
|
44
|
+
paddle: { field: "scheduled_change.effective_at (action `resume`), or scheduled_change.resume_at" }
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The resume date to project, from what the provider said.
|
|
48
|
+
*
|
|
49
|
+
* Refuses an unreadable string rather than passing it on: `new Date("soon")` is an Invalid Date, and
|
|
50
|
+
* `SQLiteDate` encodes one as `NaN` — a corrupt column value that no read can tell from a real instant.
|
|
51
|
+
* That is the same refusal every other timestamp on these rails makes, and it leaves the delivery recorded
|
|
52
|
+
* for the reconciliation pass rather than silently written.
|
|
53
|
+
*/
|
|
54
|
+
function pauseResumesAt(input) {
|
|
55
|
+
if (input.status !== "paused") return null;
|
|
56
|
+
const { reported } = input;
|
|
57
|
+
if (reported === null || reported === void 0 || reported === "") return null;
|
|
58
|
+
const parsed = new Date(reported);
|
|
59
|
+
if (Number.isNaN(parsed.getTime())) throw new PaymentsVerificationFailedError({ detail: `${input.rail}: the resume date "${reported}" is not a readable timestamp.` });
|
|
60
|
+
return parsed;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { PAYMENTS_PAUSE_RESUMPTION, pauseResumesAt };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A provider identity mapped back to the subject that holds it — the row in
|
|
4
|
+
* `pithy_payments_provider_accounts`, keyed `UNIQUE (rail, providerAccountId)`.
|
|
5
|
+
*
|
|
6
|
+
* A Stripe webhook arrives carrying `cus_123`, and names no holder of ours. This table is the only way back. The
|
|
7
|
+
* link is established at purchase time, and all three rails provide the hook — Apple's `appAccountToken`,
|
|
8
|
+
* Google's `obfuscatedAccountId`, Stripe's `client_reference_id`. All three must be set by the app that
|
|
9
|
+
* starts the purchase, or webhooks arrive orphaned with nobody to project them against.
|
|
10
|
+
*
|
|
11
|
+
* What it maps back to is the **subject pair**, which is what makes the argument stronger rather than
|
|
12
|
+
* weaker: under organization billing the person who started the checkout is not the holder, so a row
|
|
13
|
+
* carrying only their user id would attribute every later renewal to them personally. The two columns are
|
|
14
|
+
* written together and read together — `data/subject.ts`.
|
|
15
|
+
*
|
|
16
|
+
* **The unique stays `(rail, providerAccountId)` and is never widened by the subject.** A provider
|
|
17
|
+
* identity binds to one holder, once, for the life of the link: widening the key would let a second
|
|
18
|
+
* subject claim the same `cus_123` and collect the first one's renewals. A rebind is a support operation
|
|
19
|
+
* with a deliberate delete, not something a purchase flow can do by writing a row.
|
|
20
|
+
*/
|
|
21
|
+
export declare const PaymentsProviderAccount: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
rail: z.ZodEnum<{
|
|
24
|
+
apple: "apple";
|
|
25
|
+
google: "google";
|
|
26
|
+
lemonSqueezy: "lemonSqueezy";
|
|
27
|
+
paddle: "paddle";
|
|
28
|
+
stripe: "stripe";
|
|
29
|
+
}>;
|
|
30
|
+
providerAccountId: z.ZodString;
|
|
31
|
+
subjectType: z.ZodEnum<{
|
|
32
|
+
organization: "organization";
|
|
33
|
+
user: "user";
|
|
34
|
+
}>;
|
|
35
|
+
subjectId: z.ZodString;
|
|
36
|
+
createdAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type PaymentsProviderAccount = z.output<typeof PaymentsProviderAccount>;
|
|
39
|
+
export type PaymentsProviderAccountRow = z.input<typeof PaymentsProviderAccount>;
|
|
40
|
+
//# sourceMappingURL=providerAccount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providerAccount.d.ts","sourceRoot":"","sources":["../../src/data/providerAccount.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;iBAiBmF,CAAC;AACxH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC/E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PaymentsRail } from "./rail.js";
|
|
2
|
+
import { PaymentsSubject } from "./subject.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
|
|
5
|
+
//#region src/data/providerAccount.ts
|
|
6
|
+
/**
|
|
7
|
+
* A provider identity mapped back to the subject that holds it — the row in
|
|
8
|
+
* `pithy_payments_provider_accounts`, keyed `UNIQUE (rail, providerAccountId)`.
|
|
9
|
+
*
|
|
10
|
+
* A Stripe webhook arrives carrying `cus_123`, and names no holder of ours. This table is the only way back. The
|
|
11
|
+
* link is established at purchase time, and all three rails provide the hook — Apple's `appAccountToken`,
|
|
12
|
+
* Google's `obfuscatedAccountId`, Stripe's `client_reference_id`. All three must be set by the app that
|
|
13
|
+
* starts the purchase, or webhooks arrive orphaned with nobody to project them against.
|
|
14
|
+
*
|
|
15
|
+
* What it maps back to is the **subject pair**, which is what makes the argument stronger rather than
|
|
16
|
+
* weaker: under organization billing the person who started the checkout is not the holder, so a row
|
|
17
|
+
* carrying only their user id would attribute every later renewal to them personally. The two columns are
|
|
18
|
+
* written together and read together — `data/subject.ts`.
|
|
19
|
+
*
|
|
20
|
+
* **The unique stays `(rail, providerAccountId)` and is never widened by the subject.** A provider
|
|
21
|
+
* identity binds to one holder, once, for the life of the link: widening the key would let a second
|
|
22
|
+
* subject claim the same `cus_123` and collect the first one's renewals. A rebind is a support operation
|
|
23
|
+
* with a deliberate delete, not something a purchase flow can do by writing a row.
|
|
24
|
+
*/
|
|
25
|
+
const PaymentsProviderAccount = z.object({
|
|
26
|
+
id: z.string().describe("The row's UUID."),
|
|
27
|
+
rail: PaymentsRail.describe("Which store this identity belongs to."),
|
|
28
|
+
providerAccountId: z.string().describe("The rail's own account identifier — Stripe's customer id, Apple's appAccountToken, Google's obfuscatedAccountId."),
|
|
29
|
+
subjectType: PaymentsSubject.shape.subjectType.describe("Whether `subjectId` names a user or an organization. Half the answer — the id alone is ambiguous, so the two columns travel together."),
|
|
30
|
+
subjectId: PaymentsSubject.shape.subjectId.describe("The subject this provider identity resolves to — a Pithy user id, or the adopter's organization id."),
|
|
31
|
+
createdAt: SQLiteDate.describe("When the link was established, which is the first purchase that carried it.")
|
|
32
|
+
}).describe("A provider identity mapped to the subject that holds it — the row in `pithy_payments_provider_accounts`.");
|
|
33
|
+
//#endregion
|
|
34
|
+
export { PaymentsProviderAccount };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Which store environment a purchase happened in. Every purchase carries it, and it never widens: a
|
|
4
|
+
* sandbox StoreKit transaction reaching production must not grant a real entitlement, and granting one is
|
|
5
|
+
* the most common in-app-purchase security defect there is.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PurchaseEnvironment: z.ZodEnum<{
|
|
8
|
+
production: "production";
|
|
9
|
+
sandbox: "sandbox";
|
|
10
|
+
}>;
|
|
11
|
+
export type PurchaseEnvironment = z.infer<typeof PurchaseEnvironment>;
|
|
12
|
+
/**
|
|
13
|
+
* What a purchase row *is* — the thing that grants access, or the thing that took the money.
|
|
14
|
+
*
|
|
15
|
+
* On three of the four rails these are one object and `charge` is the only value ever written: an Apple
|
|
16
|
+
* renewal, a Play renewal and a Stripe invoice each carry both the money and the subscription's state, so
|
|
17
|
+
* one row does both jobs and nothing needs distinguishing.
|
|
18
|
+
*
|
|
19
|
+
* Lemon Squeezy splits them, and splits them at the source. Its `subscription_*` webhooks carry a
|
|
20
|
+
* subscription object with the status and the renewal date and no charge; its `subscription_payment_*`
|
|
21
|
+
* webhooks carry an invoice with the money and no subscription state. Neither names the other's key —
|
|
22
|
+
* an LS subscription has no latest-invoice pointer — so collapsing them onto one row would mean inventing
|
|
23
|
+
* the missing pointer and stamping two different clocks into one monotonic watermark, which is exactly
|
|
24
|
+
* the ordering defect `providerEventAt` exists to prevent.
|
|
25
|
+
*
|
|
26
|
+
* So that rail writes two rows, and this field says which is which. **`state` never credits a ledger.**
|
|
27
|
+
* A `grants` clause fires once per paid provider transaction, and a subscription's state is not a
|
|
28
|
+
* transaction — without this discriminator a live subscription's honest `active` status passes
|
|
29
|
+
* `purchaseIsPaid` and every subscriber is credited once more than they paid for.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PurchaseRole: z.ZodEnum<{
|
|
32
|
+
charge: "charge";
|
|
33
|
+
state: "state";
|
|
34
|
+
}>;
|
|
35
|
+
export type PurchaseRole = z.infer<typeof PurchaseRole>;
|
|
36
|
+
/**
|
|
37
|
+
* One provider transaction, as the projection of provider truth — the row in `pithy_payments_purchases`.
|
|
38
|
+
*
|
|
39
|
+
* `UNIQUE (rail, providerTransactionId)` is the idempotency guard all three write paths rely on: a client
|
|
40
|
+
* submission, a webhook, and a reconciliation pass produce the identical row, so a dropped client call
|
|
41
|
+
* costs nothing and a replayed webhook changes nothing.
|
|
42
|
+
*
|
|
43
|
+
* The owner is a **subject pair**, not a user id: the buyer is whoever the project bills, which under
|
|
44
|
+
* organization billing is the organization rather than the person who happened to click. Both columns are
|
|
45
|
+
* written together, and `data/subject.ts` states why either alone is ambiguous.
|
|
46
|
+
*
|
|
47
|
+
* `providerEventAt` is what makes the write monotonic. Providers do not guarantee delivery order, so an
|
|
48
|
+
* `expired` notification can arrive after the `renewed` that superseded it. Last-write-wins would
|
|
49
|
+
* silently revoke a paying subscriber, so the writer ignores any event staler than the row it is
|
|
50
|
+
* updating.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PaymentsPurchase: z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
subjectType: z.ZodEnum<{
|
|
55
|
+
organization: "organization";
|
|
56
|
+
user: "user";
|
|
57
|
+
}>;
|
|
58
|
+
subjectId: z.ZodString;
|
|
59
|
+
rail: z.ZodEnum<{
|
|
60
|
+
apple: "apple";
|
|
61
|
+
google: "google";
|
|
62
|
+
lemonSqueezy: "lemonSqueezy";
|
|
63
|
+
paddle: "paddle";
|
|
64
|
+
stripe: "stripe";
|
|
65
|
+
}>;
|
|
66
|
+
providerTransactionId: z.ZodString;
|
|
67
|
+
productId: z.ZodString;
|
|
68
|
+
providerProductId: z.ZodString;
|
|
69
|
+
type: z.ZodEnum<{
|
|
70
|
+
consumable: "consumable";
|
|
71
|
+
non_consumable: "non_consumable";
|
|
72
|
+
subscription: "subscription";
|
|
73
|
+
}>;
|
|
74
|
+
status: z.ZodEnum<{
|
|
75
|
+
active: "active";
|
|
76
|
+
canceled: "canceled";
|
|
77
|
+
expired: "expired";
|
|
78
|
+
in_grace: "in_grace";
|
|
79
|
+
never_paid: "never_paid";
|
|
80
|
+
on_hold: "on_hold";
|
|
81
|
+
paused: "paused";
|
|
82
|
+
refunded: "refunded";
|
|
83
|
+
revoked: "revoked";
|
|
84
|
+
}>;
|
|
85
|
+
role: z.ZodDefault<z.ZodEnum<{
|
|
86
|
+
charge: "charge";
|
|
87
|
+
state: "state";
|
|
88
|
+
}>>;
|
|
89
|
+
environment: z.ZodEnum<{
|
|
90
|
+
production: "production";
|
|
91
|
+
sandbox: "sandbox";
|
|
92
|
+
}>;
|
|
93
|
+
purchasedAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
94
|
+
expiresAt: z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>;
|
|
95
|
+
revokedAt: z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>;
|
|
96
|
+
resumesAt: z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>;
|
|
97
|
+
originalTransactionId: z.ZodNullable<z.ZodString>;
|
|
98
|
+
amountMinor: z.ZodNullable<z.ZodNumber>;
|
|
99
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
100
|
+
providerEventAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
101
|
+
payload: z.ZodCodec<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
102
|
+
createdAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
103
|
+
updatedAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
export type PaymentsPurchase = z.output<typeof PaymentsPurchase>;
|
|
106
|
+
export type PaymentsPurchaseRow = z.input<typeof PaymentsPurchase>;
|
|
107
|
+
//# sourceMappingURL=purchase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchase.d.ts","sourceRoot":"","sources":["../../src/data/purchase.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;EAE2E,CAAC;AAC5G,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY;;;EAItB,CAAC;AACJ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAOxD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6D4D,CAAC;AAC1F,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACjE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { PaymentsRail } from "./rail.js";
|
|
2
|
+
import { PaymentsSubject } from "./subject.js";
|
|
3
|
+
import { PaymentsProductType } from "../config/config.js";
|
|
4
|
+
import { PurchaseStatus } from "./status.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { SQLiteDate, sqliteJson } from "@pithy-sh/core/src/data/codecs";
|
|
7
|
+
//#region src/data/purchase.ts
|
|
8
|
+
/**
|
|
9
|
+
* Which store environment a purchase happened in. Every purchase carries it, and it never widens: a
|
|
10
|
+
* sandbox StoreKit transaction reaching production must not grant a real entitlement, and granting one is
|
|
11
|
+
* the most common in-app-purchase security defect there is.
|
|
12
|
+
*/
|
|
13
|
+
const PurchaseEnvironment = z.enum(["production", "sandbox"]).describe("The store environment a purchase happened in. A sandbox purchase never grants in production.");
|
|
14
|
+
/**
|
|
15
|
+
* What a purchase row *is* — the thing that grants access, or the thing that took the money.
|
|
16
|
+
*
|
|
17
|
+
* On three of the four rails these are one object and `charge` is the only value ever written: an Apple
|
|
18
|
+
* renewal, a Play renewal and a Stripe invoice each carry both the money and the subscription's state, so
|
|
19
|
+
* one row does both jobs and nothing needs distinguishing.
|
|
20
|
+
*
|
|
21
|
+
* Lemon Squeezy splits them, and splits them at the source. Its `subscription_*` webhooks carry a
|
|
22
|
+
* subscription object with the status and the renewal date and no charge; its `subscription_payment_*`
|
|
23
|
+
* webhooks carry an invoice with the money and no subscription state. Neither names the other's key —
|
|
24
|
+
* an LS subscription has no latest-invoice pointer — so collapsing them onto one row would mean inventing
|
|
25
|
+
* the missing pointer and stamping two different clocks into one monotonic watermark, which is exactly
|
|
26
|
+
* the ordering defect `providerEventAt` exists to prevent.
|
|
27
|
+
*
|
|
28
|
+
* So that rail writes two rows, and this field says which is which. **`state` never credits a ledger.**
|
|
29
|
+
* A `grants` clause fires once per paid provider transaction, and a subscription's state is not a
|
|
30
|
+
* transaction — without this discriminator a live subscription's honest `active` status passes
|
|
31
|
+
* `purchaseIsPaid` and every subscriber is credited once more than they paid for.
|
|
32
|
+
*/
|
|
33
|
+
const PurchaseRole = z.enum(["charge", "state"]).describe("Whether this row records money moving (`charge`) or a subscription's standing (`state`). Only `charge` rows fulfill a `grants` clause. Every rail but Lemon Squeezy writes `charge` for everything.");
|
|
34
|
+
/** The raw verified provider payload — an object, whatever the rail's own shape. Retained as received. */
|
|
35
|
+
const ProviderPayload = z.record(z.string(), z.unknown()).describe("The rail's verified response, as received. Shapes differ per rail, so only the envelope is fixed.");
|
|
36
|
+
/**
|
|
37
|
+
* One provider transaction, as the projection of provider truth — the row in `pithy_payments_purchases`.
|
|
38
|
+
*
|
|
39
|
+
* `UNIQUE (rail, providerTransactionId)` is the idempotency guard all three write paths rely on: a client
|
|
40
|
+
* submission, a webhook, and a reconciliation pass produce the identical row, so a dropped client call
|
|
41
|
+
* costs nothing and a replayed webhook changes nothing.
|
|
42
|
+
*
|
|
43
|
+
* The owner is a **subject pair**, not a user id: the buyer is whoever the project bills, which under
|
|
44
|
+
* organization billing is the organization rather than the person who happened to click. Both columns are
|
|
45
|
+
* written together, and `data/subject.ts` states why either alone is ambiguous.
|
|
46
|
+
*
|
|
47
|
+
* `providerEventAt` is what makes the write monotonic. Providers do not guarantee delivery order, so an
|
|
48
|
+
* `expired` notification can arrive after the `renewed` that superseded it. Last-write-wins would
|
|
49
|
+
* silently revoke a paying subscriber, so the writer ignores any event staler than the row it is
|
|
50
|
+
* updating.
|
|
51
|
+
*/
|
|
52
|
+
const PaymentsPurchase = z.object({
|
|
53
|
+
id: z.string().describe("The purchase's UUID. Text rather than an autoincrement integer because these surface in API responses, and sequential ids would leak order volume."),
|
|
54
|
+
subjectType: PaymentsSubject.shape.subjectType.describe("Whether `subjectId` names a user or an organization. Half the owner — the id alone is ambiguous, so the two columns travel together."),
|
|
55
|
+
subjectId: PaymentsSubject.shape.subjectId.describe("The subject that owns the purchase — the authenticated buyer, or the organization they bought for."),
|
|
56
|
+
rail: PaymentsRail.describe("Which store this transaction came from."),
|
|
57
|
+
providerTransactionId: z.string().describe("The rail's own transaction id. `UNIQUE (rail, providerTransactionId)` — the idempotency anchor."),
|
|
58
|
+
productId: z.string().describe("The logical catalog product id, from `products` in pithy.config.ts."),
|
|
59
|
+
providerProductId: z.string().describe("The rail's own SKU or price id, exactly as the provider presented it."),
|
|
60
|
+
type: PaymentsProductType.describe("The product type, copied from the catalog at projection time so a later config edit cannot rewrite history."),
|
|
61
|
+
status: PurchaseStatus.describe("The normalized status. Nothing downstream ever sees a rail-specific state."),
|
|
62
|
+
role: PurchaseRole.default("charge").describe("Whether this row is the money or the subscription's standing. Defaults to `charge`, which is what every rail but Lemon Squeezy writes for every row."),
|
|
63
|
+
environment: PurchaseEnvironment.describe("Which store environment the purchase happened in. Every purchase carries it: a sandbox StoreKit transaction reaching production must never grant a real entitlement."),
|
|
64
|
+
purchasedAt: SQLiteDate.describe("When the store recorded the purchase."),
|
|
65
|
+
expiresAt: SQLiteDate.nullable().describe("When access lapses, or null for a purchase that never expires. Evaluated at read time as well as write time."),
|
|
66
|
+
revokedAt: SQLiteDate.nullable().describe("When the purchase was refunded or revoked, or null."),
|
|
67
|
+
resumesAt: SQLiteDate.nullable().describe("When a paused subscription comes back, as the provider stated it — never computed. Null on a paused row means the provider said none, which is an indefinite pause; null everywhere else means the purchase is not paused, and the table's check constraint is what keeps those two apart. See `data/pause.ts`."),
|
|
68
|
+
originalTransactionId: z.string().nullable().describe("Chains renewals back to the transaction that started the subscription. Null for a one-time purchase."),
|
|
69
|
+
amountMinor: z.number().int().nullable().describe("The amount charged, in the currency's minor unit — an integer, never a float. Nullable: not every rail reports it on every event."),
|
|
70
|
+
currency: z.string().nullable().describe("The ISO currency the amount is in, or null when the rail did not report one."),
|
|
71
|
+
providerEventAt: SQLiteDate.describe("The provider's own timestamp for the event that produced this row. The monotonic write rule compares against it, so out-of-order delivery cannot revoke a live subscription."),
|
|
72
|
+
payload: sqliteJson(ProviderPayload).describe("The raw verified provider payload, Zod-validated on write and on read. Retained for reconciliation and audit."),
|
|
73
|
+
createdAt: SQLiteDate.describe("When this row was first projected."),
|
|
74
|
+
updatedAt: SQLiteDate.describe("When this row was last projected.")
|
|
75
|
+
}).describe("One verified provider transaction — the row in `pithy_payments_purchases`.");
|
|
76
|
+
//#endregion
|
|
77
|
+
export { PaymentsPurchase, PurchaseEnvironment, PurchaseRole };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The five payment rails, as one normalized name each. Nothing downstream of a rail's own module ever
|
|
4
|
+
* branches on a store's vocabulary — Apple's `originalTransactionId`, Google's `purchaseToken`, Stripe's
|
|
5
|
+
* `subscription` and Paddle's `sub_…` all arrive as a `(rail, providerTransactionId)` pair, which is what
|
|
6
|
+
* lets one projection serve five stores and one entitlement resolve across them.
|
|
7
|
+
*
|
|
8
|
+
* Adding a sixth rail (Amazon Appstore) is a member here plus a provider module. Nothing else in the
|
|
9
|
+
* package knows how many there are.
|
|
10
|
+
*
|
|
11
|
+
* `lemonSqueezy` and `paddle` are the two **merchants of record**: each owns the tax registration, the VAT
|
|
12
|
+
* thresholds, the invoices and the chargebacks, where the other three leave every one of those to the
|
|
13
|
+
* adopter. That is a commercial difference rather than a technical one, and the only place it shows in
|
|
14
|
+
* this package is that a refund can arrive with no local write preceding it — both issue them on their own.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PaymentsRail: z.ZodEnum<{
|
|
17
|
+
apple: "apple";
|
|
18
|
+
google: "google";
|
|
19
|
+
lemonSqueezy: "lemonSqueezy";
|
|
20
|
+
paddle: "paddle";
|
|
21
|
+
stripe: "stripe";
|
|
22
|
+
}>;
|
|
23
|
+
export type PaymentsRail = z.infer<typeof PaymentsRail>;
|
|
24
|
+
/** Every rail, in a stable order — for iterating the catalog's per-rail blocks and cross-checking them. */
|
|
25
|
+
export declare const PAYMENTS_RAILS: readonly PaymentsRail[];
|
|
26
|
+
/**
|
|
27
|
+
* The rails that sell in a browser — and mint a billing portal, which is the same statement.
|
|
28
|
+
*
|
|
29
|
+
* **One name, because it is one question.** {@link CheckoutRail} declares `createCheckoutSession` and
|
|
30
|
+
* `createPortalSession` together, so a rail cannot start a purchase on the web without also having a
|
|
31
|
+
* portal to send that buyer back to. "Sells in a browser" and "mints a portal we can link to" are not
|
|
32
|
+
* two lists that happen to match today; they are one list, held that way by an interface. Two names
|
|
33
|
+
* would suggest a divergence the type system does not permit, and the next person would have to read
|
|
34
|
+
* both to learn they are the same.
|
|
35
|
+
*
|
|
36
|
+
* The day a rail sells without a portal, `CheckoutRail` splits first — and `providers.test.ts`, which
|
|
37
|
+
* compares this list against the rails that actually satisfy `isCheckoutRail`, goes red. That is the
|
|
38
|
+
* moment a second name is earned, and it arrives with a failing test rather than a judgment call.
|
|
39
|
+
*
|
|
40
|
+
* **Enumerated rather than computed**, because nothing can compute it. A screen cannot construct a rail
|
|
41
|
+
* provider to discover what it implements, and `PaymentsRail.options` cannot answer it either — Apple and
|
|
42
|
+
* Google are rails and are not hosted. So it is a named subset with a gate over it, in both programs: this
|
|
43
|
+
* one, and its DOM-safe mirror in `src/client/api.ts`, which stays a hand-written union because pulling
|
|
44
|
+
* Zod into an adopter's browser program is what that file exists to avoid.
|
|
45
|
+
*
|
|
46
|
+
* Ordered, and the order is only used to make a refusal deterministic when a product sells on two rails
|
|
47
|
+
* and the caller named neither. See `checkoutRailFor`.
|
|
48
|
+
*
|
|
49
|
+
* **Extracted from {@link PaymentsRail} rather than spelled again.** A member misspelled here is a
|
|
50
|
+
* compile error rather than a rail that silently never matches, and the extraction is what lets the four
|
|
51
|
+
* schemas that narrow to this subset share one definition instead of four literals.
|
|
52
|
+
*
|
|
53
|
+
* **One subset, not two.** These are also exactly the rails that mint discount codes today, and both
|
|
54
|
+
* discount schemas narrow to this. A second constant would be a mirror with nothing to mirror. The day a
|
|
55
|
+
* rail mints and does not sell, or sells and does not mint, `providers.test.ts` disagrees with itself and
|
|
56
|
+
* the subset splits — with a failing test rather than a judgment call, which is the same bargain
|
|
57
|
+
* `CheckoutRail` makes for selling and portal-minting.
|
|
58
|
+
*/
|
|
59
|
+
export declare const PaymentsHostedRail: z.ZodEnum<{
|
|
60
|
+
lemonSqueezy: "lemonSqueezy";
|
|
61
|
+
paddle: "paddle";
|
|
62
|
+
stripe: "stripe";
|
|
63
|
+
}>;
|
|
64
|
+
export type PaymentsHostedRail = z.infer<typeof PaymentsHostedRail>;
|
|
65
|
+
/**
|
|
66
|
+
* The same three as a plain array, for the callers that iterate rather than parse.
|
|
67
|
+
*
|
|
68
|
+
* Derived from the schema rather than written beside it. Four request and response schemas wrote this
|
|
69
|
+
* subset out by hand and Paddle reached none of them (#465), so a rail that sold, minted portals and minted
|
|
70
|
+
* discount codes was a 400 at every point a caller had to name it. One list, one edit — and
|
|
71
|
+
* `providers.test.ts` holds it to the rails that satisfy the interfaces at runtime, in both directions.
|
|
72
|
+
*/
|
|
73
|
+
export declare const PAYMENTS_HOSTED_RAILS: readonly PaymentsRail[];
|
|
74
|
+
//# sourceMappingURL=rail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rail.d.ts","sourceRoot":"","sources":["../../src/data/rail.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY;;;;;;EAE6F,CAAC;AACvH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,2GAA2G;AAC3G,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAyB,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,kBAAkB;;;;EAE9B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,YAAY,EAA+B,CAAC"}
|