@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,42 @@
|
|
|
1
|
+
//#region src/client/test-utils/cacheStore.ts
|
|
2
|
+
/**
|
|
3
|
+
* A {@link PaddleCacheStore} a test can look inside.
|
|
4
|
+
*
|
|
5
|
+
* `localStorage` is the store an adopter passes and the wrong one to test against: a suite that reached
|
|
6
|
+
* for it would need a DOM, would leak entries between tests, and could not answer "what is in there now"
|
|
7
|
+
* without re-deriving the key the module chose. This is a `Map`, and the `Map` is exposed — so a test can
|
|
8
|
+
* assert an entry was written, corrupt one to see what happens next, or count what a run left behind.
|
|
9
|
+
*
|
|
10
|
+
* It enumerates, because `Storage` does: `length` and `key` are what a sweep walks, and a stand-in
|
|
11
|
+
* missing them would quietly exercise the un-swept path on every test that thought it was testing one.
|
|
12
|
+
*/
|
|
13
|
+
function memoryStore() {
|
|
14
|
+
const entries = /* @__PURE__ */ new Map();
|
|
15
|
+
return {
|
|
16
|
+
entries,
|
|
17
|
+
get length() {
|
|
18
|
+
return entries.size;
|
|
19
|
+
},
|
|
20
|
+
key: (index) => [...entries.keys()][index] ?? null,
|
|
21
|
+
getItem: (key) => entries.get(key) ?? null,
|
|
22
|
+
setItem: (key, value) => {
|
|
23
|
+
entries.set(key, value);
|
|
24
|
+
},
|
|
25
|
+
removeItem: (key) => {
|
|
26
|
+
entries.delete(key);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** A store that refuses everything — Safari in private browsing, and a quota that is full. */
|
|
31
|
+
function refusingStore() {
|
|
32
|
+
const refuse = () => {
|
|
33
|
+
throw new Error("the store is unavailable");
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
getItem: refuse,
|
|
37
|
+
setItem: refuse,
|
|
38
|
+
removeItem: refuse
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { memoryStore, refusingStore };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One figure, in both of the forms Paddle sends it in, and what it is denominated in. */
|
|
2
|
+
export interface WholeUnitPrice {
|
|
3
|
+
/** Paddle's own rendering of the figure for this visitor. The only thing ever returned. */
|
|
4
|
+
readonly formatted: string;
|
|
5
|
+
/** The same figure in minor units — `"600"` for $6.00, `"6000"` for KD 6.000. Never rendered. */
|
|
6
|
+
readonly minorAmount: string;
|
|
7
|
+
/** The ISO-4217 code the quote is in. It decides how many digits the fraction occupies. */
|
|
8
|
+
readonly currency: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Paddle's rendering with an all-zero fraction removed, or that rendering exactly as it arrived.
|
|
12
|
+
*
|
|
13
|
+
* Opt-in everywhere it is reachable from, and never a default. Only an all-zero fraction ever goes, so an
|
|
14
|
+
* adopter selling at `$6.99` is unaffected either way — but which figures a seller advertises is a pricing
|
|
15
|
+
* decision, and this kit does not get to restyle somebody's prices on their behalf.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withoutZeroFraction(price: WholeUnitPrice): string;
|
|
18
|
+
//# sourceMappingURL=wholeUnits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wholeUnits.d.ts","sourceRoot":"","sources":["../../src/client/wholeUnits.ts"],"names":[],"mappings":"AA+EA,0FAA0F;AAC1F,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iGAAiG;IACjG,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAwCD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAYjE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { minorUnitDigits } from "../data/money.js";
|
|
2
|
+
//#region src/client/wholeUnits.ts
|
|
3
|
+
/**
|
|
4
|
+
* Removing a fraction that is entirely zero from a price Paddle already rendered.
|
|
5
|
+
*
|
|
6
|
+
* A seller whose plans are `$6`, `€12` and `KD 6` renders `$6.00`, `12,00 €` and `<U+200F>٦٫٠٠٠ د.ك.<U+200F>`, and on a
|
|
7
|
+
* pricing table the decimal is noise on every row. Two Pithy surfaces reached the same conclusion and each
|
|
8
|
+
* wrote `total.replace(/([.,])00(?=\D*$)/, "")` — the same rule, byte for byte, in two repositories. That
|
|
9
|
+
* regex is wrong in the three-decimal dinars, silent in every Arabic-Indic script, and cannot be made
|
|
10
|
+
* right, because the only thing either surface holds is the finished string. This module is the reason
|
|
11
|
+
* neither of them has to.
|
|
12
|
+
*
|
|
13
|
+
* **The decision is arithmetic, and only this package holds the number.** Paddle sends every figure twice:
|
|
14
|
+
* in minor units for comparing, and rendered for showing. $6.00 is `600`, so whether the fraction is zero
|
|
15
|
+
* is `amount % 10 ** places === 0` — no parsing, no locale, no guess. That is what `PriceLine.totals` says
|
|
16
|
+
* it is for. It also removes the whole ambiguity class: *is the trailing `000` in `$1,000` a fraction or a
|
|
17
|
+
* thousands group?* is never asked, because the fraction is known before the string is touched.
|
|
18
|
+
*
|
|
19
|
+
* **The removal never asks which character the separator is.** It is a property of the locale, not of the
|
|
20
|
+
* currency, so the ISO code cannot give it — `de-DE` renders EUR as `6,00 €` and `en-IE` renders the same
|
|
21
|
+
* currency as `€6.00`. And the browser cannot give it either: `Intl.NumberFormat(undefined, …)` answers
|
|
22
|
+
* for the **visitor's** locale while the string was rendered by **Paddle**, so matching the browser's
|
|
23
|
+
* separator is a silent no-op in exactly the case where the two differ, which is the case that matters.
|
|
24
|
+
*
|
|
25
|
+
* So the fraction is located positionally: the trailing run of `places` decimal digits, in whatever
|
|
26
|
+
* script, with a single non-digit before it that must itself follow a digit. Trailing symbols, spaces and
|
|
27
|
+
* bidi marks sit after the run and are carried through untouched. A run preceded by another digit is a
|
|
28
|
+
* thousands group and is left alone — `$1,000` and `1.000 €` both come back exactly as they arrived.
|
|
29
|
+
*
|
|
30
|
+
* **A digit is treated as its script's zero when the code point below it is not a decimal digit.** Every
|
|
31
|
+
* `Nd` block is ten contiguous points beginning at zero, so that one comparison answers it for
|
|
32
|
+
* Arabic-Indic, Devanagari and most of the rest. The usual shortcuts do not: `Number("٠")` is `NaN`, and
|
|
33
|
+
* `"٠".normalize("NFKD")` is still `"٠"`.
|
|
34
|
+
*
|
|
35
|
+
* **It is not a universal, and the first draft of this paragraph said it was — Jim, 2026-08-21.** Five of
|
|
36
|
+
* Unicode's seventy-two `Nd` blocks sit immediately after another one, so their zero has a decimal digit
|
|
37
|
+
* below it and this test answers `false` for it.
|
|
38
|
+
*
|
|
39
|
+
* **The direction of that error is the reason it is still the right test.** A missed zero means the
|
|
40
|
+
* fraction is not recognized and the figure is returned exactly as Paddle rendered it — a silent refusal
|
|
41
|
+
* to trim, never a mangled price. A false *positive* is what would remove a digit that mattered, and
|
|
42
|
+
* cannot happen here: block lengths are all ten, so the start of a digit run is always a block zero.
|
|
43
|
+
*
|
|
44
|
+
* Brute-forced rather than reasoned about: 152,592 combinations over `Intl.supportedValuesOf("currency")`
|
|
45
|
+
* against 34 locales and 15 amounts produced zero value-changing outputs, holding
|
|
46
|
+
* `digits(out) * 10**places === digits(in)` with exactly one non-digit removed.
|
|
47
|
+
*
|
|
48
|
+
* **Only an all-zero fraction ever goes.** Nothing here divides, rounds or truncates, and a real fraction
|
|
49
|
+
* comes back whole. Both halves have to agree before a character is removed — the arithmetic says the
|
|
50
|
+
* fraction is zero *and* the digits in the string are zeros — because the two figures disagreeing means
|
|
51
|
+
* somebody handed this the wrong pair, and the string is the only thing a visitor sees.
|
|
52
|
+
*
|
|
53
|
+
* **`minorUnitDigits` is shared with the server half, deliberately.** It is `../data/money`'s ISO-4217
|
|
54
|
+
* exponent table, the one the purchase projection already uses, and it imports nothing — so the browser
|
|
55
|
+
* bundle gains a set of currency codes and no graph. A second copy of that table here would be this
|
|
56
|
+
* issue's own defect, one layer down.
|
|
57
|
+
*
|
|
58
|
+
* **#465 corrected `./paddle.ts` about `Intl` and did not touch this module's reasoning — checked, 2026-08-28.**
|
|
59
|
+
* That correction is that `Intl` does know the currency exponents, so a server with only minor units may
|
|
60
|
+
* render a figure. Neither half of the argument here rested on it. This module never needed the exponent
|
|
61
|
+
* from `Intl` — it has ISO 4217, which is what a *store* denominates in, and that turned out to be the
|
|
62
|
+
* stronger choice: CLDR renders `HUF` and `COP` with no fraction at all, while Paddle bills both with two,
|
|
63
|
+
* so a `places` taken from `Intl` would answer 0 for a currency whose minor unit is the hundredth. And the
|
|
64
|
+
* separator claim above is untouched, because it is not a claim about what `Intl` knows: it is that
|
|
65
|
+
* `Intl.NumberFormat(undefined, …)` answers for the **visitor's** locale while the string in hand was
|
|
66
|
+
* rendered in **Paddle's**, and the two differing is exactly the case that matters. Trimming a string
|
|
67
|
+
* Paddle rendered stays right here; rendering one from scratch stays wrong here, and is right only where
|
|
68
|
+
* Paddle rendered nothing — `../data/renderMoney.ts`, on the server, from the negotiated locale.
|
|
69
|
+
*/
|
|
70
|
+
/** A decimal digit in any script. `Nd`, so Arabic-Indic and Devanagari count as much as ASCII. */
|
|
71
|
+
const DECIMAL_DIGIT = /\p{Nd}/u;
|
|
72
|
+
/** An amount in minor units, as Paddle writes one: an integer, optionally signed, and nothing else. */
|
|
73
|
+
const MINOR_UNITS = /^-?[0-9]+$/;
|
|
74
|
+
/** Whether a single character is a decimal digit. */
|
|
75
|
+
function isDecimalDigit(character) {
|
|
76
|
+
return character !== void 0 && DECIMAL_DIGIT.test(character);
|
|
77
|
+
}
|
|
78
|
+
/** Whether a single character is the zero of its own script. */
|
|
79
|
+
function isScriptZero(character) {
|
|
80
|
+
if (character === void 0 || !isDecimalDigit(character)) return false;
|
|
81
|
+
const code = character.codePointAt(0);
|
|
82
|
+
if (code === void 0) return false;
|
|
83
|
+
return !isDecimalDigit(String.fromCodePoint(code - 1));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The string with its trailing `places`-digit zero fraction and that fraction's separator removed.
|
|
87
|
+
*
|
|
88
|
+
* By code point rather than by UTF-16 unit: a digit outside the BMP would be two units, and a scan that
|
|
89
|
+
* counted units would cut one of them in half. The string itself is returned wherever the shape is not
|
|
90
|
+
* exactly a fraction, which is every refusal in this file — there is no partial removal.
|
|
91
|
+
*/
|
|
92
|
+
function withoutTrailingZeros(formatted, places) {
|
|
93
|
+
const characters = [...formatted];
|
|
94
|
+
let end = characters.length;
|
|
95
|
+
while (end > 0 && !isDecimalDigit(characters[end - 1])) end -= 1;
|
|
96
|
+
const start = end - places;
|
|
97
|
+
if (start < 2) return formatted;
|
|
98
|
+
for (let index = start; index < end; index += 1) if (!isScriptZero(characters[index])) return formatted;
|
|
99
|
+
if (isDecimalDigit(characters[start - 1])) return formatted;
|
|
100
|
+
if (!isDecimalDigit(characters[start - 2])) return formatted;
|
|
101
|
+
return [...characters.slice(0, start - 1), ...characters.slice(end)].join("");
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Paddle's rendering with an all-zero fraction removed, or that rendering exactly as it arrived.
|
|
105
|
+
*
|
|
106
|
+
* Opt-in everywhere it is reachable from, and never a default. Only an all-zero fraction ever goes, so an
|
|
107
|
+
* adopter selling at `$6.99` is unaffected either way — but which figures a seller advertises is a pricing
|
|
108
|
+
* decision, and this kit does not get to restyle somebody's prices on their behalf.
|
|
109
|
+
*/
|
|
110
|
+
function withoutZeroFraction(price) {
|
|
111
|
+
const places = minorUnitDigits(price.currency);
|
|
112
|
+
if (places === 0) return price.formatted;
|
|
113
|
+
if (!MINOR_UNITS.test(price.minorAmount)) return price.formatted;
|
|
114
|
+
const amount = Number(price.minorAmount);
|
|
115
|
+
if (!Number.isSafeInteger(amount)) return price.formatted;
|
|
116
|
+
if (amount % 10 ** places !== 0) return price.formatted;
|
|
117
|
+
return withoutTrailingZeros(price.formatted, places);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
export { withoutZeroFraction };
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type PaymentsRail } from "../data/rail";
|
|
3
|
+
export declare const PaymentsRailToggles: z.ZodObject<{
|
|
4
|
+
apple: z.ZodDefault<z.ZodBoolean>;
|
|
5
|
+
google: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
stripe: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
lemonSqueezy: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
paddle: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type PaymentsRailToggles = z.infer<typeof PaymentsRailToggles>;
|
|
11
|
+
export declare const PaymentsProductType: z.ZodEnum<{
|
|
12
|
+
consumable: "consumable";
|
|
13
|
+
non_consumable: "non_consumable";
|
|
14
|
+
subscription: "subscription";
|
|
15
|
+
}>;
|
|
16
|
+
export type PaymentsProductType = z.infer<typeof PaymentsProductType>;
|
|
17
|
+
export declare const PaymentsAppleProduct: z.ZodObject<{
|
|
18
|
+
productId: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type PaymentsAppleProduct = z.infer<typeof PaymentsAppleProduct>;
|
|
21
|
+
export declare const PaymentsGoogleProduct: z.ZodObject<{
|
|
22
|
+
productId: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type PaymentsGoogleProduct = z.infer<typeof PaymentsGoogleProduct>;
|
|
25
|
+
export declare const PaymentsStripeProduct: z.ZodObject<{
|
|
26
|
+
priceId: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type PaymentsStripeProduct = z.infer<typeof PaymentsStripeProduct>;
|
|
29
|
+
export declare const PaymentsLemonSqueezyProduct: z.ZodObject<{
|
|
30
|
+
variantId: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type PaymentsLemonSqueezyProduct = z.infer<typeof PaymentsLemonSqueezyProduct>;
|
|
33
|
+
export declare const PaymentsLemonSqueezySettings: z.ZodObject<{
|
|
34
|
+
successUrl: z.ZodURL;
|
|
35
|
+
storeCurrency: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type PaymentsLemonSqueezySettings = z.infer<typeof PaymentsLemonSqueezySettings>;
|
|
38
|
+
export declare const PaymentsPaddleProduct: z.ZodObject<{
|
|
39
|
+
priceId: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type PaymentsPaddleProduct = z.infer<typeof PaymentsPaddleProduct>;
|
|
42
|
+
export declare const PaymentsPaddleSettings: z.ZodObject<{
|
|
43
|
+
checkout: z.ZodDefault<z.ZodEnum<{
|
|
44
|
+
hosted: "hosted";
|
|
45
|
+
inline: "inline";
|
|
46
|
+
overlay: "overlay";
|
|
47
|
+
}>>;
|
|
48
|
+
clientToken: z.ZodString;
|
|
49
|
+
environment: z.ZodEnum<{
|
|
50
|
+
production: "production";
|
|
51
|
+
sandbox: "sandbox";
|
|
52
|
+
}>;
|
|
53
|
+
successUrl: z.ZodURL;
|
|
54
|
+
cancelUrl: z.ZodOptional<z.ZodURL>;
|
|
55
|
+
webhookFreshnessSeconds: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
storeCurrency: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export type PaymentsPaddleSettings = z.infer<typeof PaymentsPaddleSettings>;
|
|
59
|
+
export type PaymentsPaddleSettingsInput = z.input<typeof PaymentsPaddleSettings>;
|
|
60
|
+
export declare const PaymentsStripeSettings: z.ZodObject<{
|
|
61
|
+
successUrl: z.ZodURL;
|
|
62
|
+
cancelUrl: z.ZodURL;
|
|
63
|
+
portalReturnUrl: z.ZodURL;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type PaymentsStripeSettings = z.infer<typeof PaymentsStripeSettings>;
|
|
66
|
+
export declare const PaymentsLedgerGrant: z.ZodObject<{
|
|
67
|
+
currency: z.ZodString;
|
|
68
|
+
amount: z.ZodNumber;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type PaymentsLedgerGrant = z.infer<typeof PaymentsLedgerGrant>;
|
|
71
|
+
export declare const PaymentsGrants: z.ZodObject<{
|
|
72
|
+
ledger: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
currency: z.ZodString;
|
|
74
|
+
amount: z.ZodNumber;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type PaymentsGrants = z.infer<typeof PaymentsGrants>;
|
|
78
|
+
export declare const PaymentsProduct: z.ZodObject<{
|
|
79
|
+
type: z.ZodEnum<{
|
|
80
|
+
consumable: "consumable";
|
|
81
|
+
non_consumable: "non_consumable";
|
|
82
|
+
subscription: "subscription";
|
|
83
|
+
}>;
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
entitlements: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
86
|
+
apple: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
productId: z.ZodString;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
productId: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
stripe: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
priceId: z.ZodString;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
lemonSqueezy: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
variantId: z.ZodString;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
paddle: z.ZodOptional<z.ZodObject<{
|
|
99
|
+
priceId: z.ZodString;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
grants: z.ZodOptional<z.ZodObject<{
|
|
102
|
+
ledger: z.ZodOptional<z.ZodObject<{
|
|
103
|
+
currency: z.ZodString;
|
|
104
|
+
amount: z.ZodNumber;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
clawback: z.ZodDefault<z.ZodBoolean>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
export type PaymentsProduct = z.infer<typeof PaymentsProduct>;
|
|
110
|
+
export declare const PaymentsConfig: z.ZodObject<{
|
|
111
|
+
billingSubject: z.ZodEnum<{
|
|
112
|
+
organization: "organization";
|
|
113
|
+
user: "user";
|
|
114
|
+
}>;
|
|
115
|
+
rails: z.ZodDefault<z.ZodObject<{
|
|
116
|
+
apple: z.ZodDefault<z.ZodBoolean>;
|
|
117
|
+
google: z.ZodDefault<z.ZodBoolean>;
|
|
118
|
+
stripe: z.ZodDefault<z.ZodBoolean>;
|
|
119
|
+
lemonSqueezy: z.ZodDefault<z.ZodBoolean>;
|
|
120
|
+
paddle: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
products: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
123
|
+
type: z.ZodEnum<{
|
|
124
|
+
consumable: "consumable";
|
|
125
|
+
non_consumable: "non_consumable";
|
|
126
|
+
subscription: "subscription";
|
|
127
|
+
}>;
|
|
128
|
+
name: z.ZodString;
|
|
129
|
+
entitlements: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
130
|
+
apple: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
productId: z.ZodString;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
productId: z.ZodString;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
stripe: z.ZodOptional<z.ZodObject<{
|
|
137
|
+
priceId: z.ZodString;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
lemonSqueezy: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
variantId: z.ZodString;
|
|
141
|
+
}, z.core.$strip>>;
|
|
142
|
+
paddle: z.ZodOptional<z.ZodObject<{
|
|
143
|
+
priceId: z.ZodString;
|
|
144
|
+
}, z.core.$strip>>;
|
|
145
|
+
grants: z.ZodOptional<z.ZodObject<{
|
|
146
|
+
ledger: z.ZodOptional<z.ZodObject<{
|
|
147
|
+
currency: z.ZodString;
|
|
148
|
+
amount: z.ZodNumber;
|
|
149
|
+
}, z.core.$strip>>;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
clawback: z.ZodDefault<z.ZodBoolean>;
|
|
152
|
+
}, z.core.$strip>>>;
|
|
153
|
+
manualEntitlements: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
154
|
+
stripe: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
successUrl: z.ZodURL;
|
|
156
|
+
cancelUrl: z.ZodURL;
|
|
157
|
+
portalReturnUrl: z.ZodURL;
|
|
158
|
+
}, z.core.$strip>>;
|
|
159
|
+
lemonSqueezy: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
successUrl: z.ZodURL;
|
|
161
|
+
storeCurrency: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$strip>>;
|
|
163
|
+
paddle: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
checkout: z.ZodDefault<z.ZodEnum<{
|
|
165
|
+
hosted: "hosted";
|
|
166
|
+
inline: "inline";
|
|
167
|
+
overlay: "overlay";
|
|
168
|
+
}>>;
|
|
169
|
+
clientToken: z.ZodString;
|
|
170
|
+
environment: z.ZodEnum<{
|
|
171
|
+
production: "production";
|
|
172
|
+
sandbox: "sandbox";
|
|
173
|
+
}>;
|
|
174
|
+
successUrl: z.ZodURL;
|
|
175
|
+
cancelUrl: z.ZodOptional<z.ZodURL>;
|
|
176
|
+
webhookFreshnessSeconds: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
storeCurrency: z.ZodOptional<z.ZodString>;
|
|
178
|
+
}, z.core.$strict>>;
|
|
179
|
+
basePath: z.ZodDefault<z.ZodString>;
|
|
180
|
+
graceGrantsAccess: z.ZodDefault<z.ZodBoolean>;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
export type PaymentsConfig = z.output<typeof PaymentsConfig>;
|
|
183
|
+
export type PaymentsConfigInput = z.input<typeof PaymentsConfig>;
|
|
184
|
+
/**
|
|
185
|
+
* The catalog's pieces as *written*, beside the whole config as written.
|
|
186
|
+
*
|
|
187
|
+
* A catalog assembled in TypeScript — products built from a map of price ids, which is what makes the
|
|
188
|
+
* ids swappable per environment — needs a name for each piece it builds. The output types are the
|
|
189
|
+
* wrong ones: they are what `PaymentsConfig.parse()` returns, with every default already filled in, so
|
|
190
|
+
* typing an unparsed product with `PaymentsProduct` demands `entitlements` and `clawback` back from the
|
|
191
|
+
* author. The alternative was leaving adopters to write `z.input<typeof PaymentsProduct>` themselves,
|
|
192
|
+
* which works and makes the schema's internals part of the surface anyway.
|
|
193
|
+
*
|
|
194
|
+
* `PaymentsStripeSettings` defaults nothing today, so its input and output coincide. It is exported all
|
|
195
|
+
* the same: the three pieces a catalog is assembled from should be nameable as a set, and a default
|
|
196
|
+
* added later then shifts nothing.
|
|
197
|
+
*/
|
|
198
|
+
export type PaymentsProductInput = z.input<typeof PaymentsProduct>;
|
|
199
|
+
export type PaymentsRailTogglesInput = z.input<typeof PaymentsRailToggles>;
|
|
200
|
+
export type PaymentsStripeSettingsInput = z.input<typeof PaymentsStripeSettings>;
|
|
201
|
+
/**
|
|
202
|
+
* A catalog product and the logical id it is keyed by. Both halves travel together because every write
|
|
203
|
+
* needs the id — a purchase row stores `productId`, not the product — and every read needs the product.
|
|
204
|
+
*/
|
|
205
|
+
export interface PaymentsCatalogEntry {
|
|
206
|
+
/** The logical product id — the key in `products`, and what lands in a purchase row. */
|
|
207
|
+
id: string;
|
|
208
|
+
/** The catalog entry itself. */
|
|
209
|
+
product: PaymentsProduct;
|
|
210
|
+
}
|
|
211
|
+
/** The provider SKU this product is listed under on `rail`, or undefined when it does not ship there. */
|
|
212
|
+
export declare function providerProductId(product: PaymentsProduct, rail: PaymentsRail): string | undefined;
|
|
213
|
+
/** The product with this logical id, or undefined. Ids come from config, so an unknown one is a 404. */
|
|
214
|
+
export declare function resolveProduct(config: PaymentsConfig, id: string): PaymentsCatalogEntry | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The product a rail's own SKU maps to — the lookup every provider event needs, since a webhook carries
|
|
217
|
+
* the store's identifier and never a Pithy product id. Scoped to one rail: the same string can be a
|
|
218
|
+
* different product on a different store, and `PaymentsConfig`'s duplicate check is what guarantees the
|
|
219
|
+
* answer is unique within a rail.
|
|
220
|
+
*/
|
|
221
|
+
export declare function productForProviderSku(config: PaymentsConfig, rail: PaymentsRail, sku: string): PaymentsCatalogEntry | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Every entitlement key this project defines — what the catalog's products grant, plus what the adopter
|
|
224
|
+
* declared grantable with no sale behind it.
|
|
225
|
+
*
|
|
226
|
+
* The set a manual grant is checked against, and the set the control-plane catalog read publishes the first
|
|
227
|
+
* half of. Computed once per composition: the catalog is config, so it cannot change under a running Worker.
|
|
228
|
+
*
|
|
229
|
+
* **Empty is a real answer.** A project composing payments with nothing to sell and nothing declared defines
|
|
230
|
+
* no keys, and every grant against it is refused — which is correct, because there is no vocabulary to grant
|
|
231
|
+
* in. It is the same statement `clientProjection` makes as `{ enabled: false }`.
|
|
232
|
+
*/
|
|
233
|
+
export declare function grantableEntitlements(config: PaymentsConfig): ReadonlySet<string>;
|
|
234
|
+
/** The entitlement keys a product grants, or an empty list for an unknown product or one that grants none. */
|
|
235
|
+
export declare function entitlementsForProduct(config: PaymentsConfig, id: string): readonly string[];
|
|
236
|
+
/** Whether a rail is enabled for this project. A disabled rail refuses its routes and its webhook. */
|
|
237
|
+
export declare function railEnabled(config: PaymentsConfig, rail: PaymentsRail): boolean;
|
|
238
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"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"}
|