@pithy-sh/payments 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/admin/coverage.d.ts.map +1 -1
- package/dist/admin/coverage.js +26 -2
- package/dist/admin/read.d.ts +48 -1
- package/dist/admin/read.d.ts.map +1 -1
- package/dist/admin/read.js +89 -2
- package/dist/audit/actions.d.ts +13 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +14 -1
- package/dist/capability.d.ts +33 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +52 -9
- package/dist/client/api.d.ts +19 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +34 -1
- package/dist/client/hooks.d.ts +20 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/hooks.js +40 -2
- package/dist/client/projection.d.ts +29 -0
- package/dist/client/projection.d.ts.map +1 -1
- package/dist/config/allowances.d.ts +71 -0
- package/dist/config/allowances.d.ts.map +1 -0
- package/dist/config/allowances.js +115 -0
- package/dist/config/config.d.ts +155 -9
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +164 -14
- package/dist/data/meterCounter.d.ts +34 -0
- package/dist/data/meterCounter.d.ts.map +1 -0
- package/dist/data/meterCounter.js +33 -0
- package/dist/data/override.d.ts +56 -0
- package/dist/data/override.d.ts.map +1 -0
- package/dist/data/override.js +58 -0
- package/dist/data/period.d.ts +10 -0
- package/dist/data/period.d.ts.map +1 -0
- package/dist/data/period.js +37 -0
- package/dist/data/purchase.d.ts +2 -1
- package/dist/data/purchase.d.ts.map +1 -1
- package/dist/data/purchase.js +1 -0
- package/dist/data/tables.d.ts +17 -1
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +24 -4
- package/dist/data/usageReport.d.ts +68 -0
- package/dist/data/usageReport.d.ts.map +1 -0
- package/dist/data/usageReport.js +55 -0
- package/dist/data/usageRun.d.ts +77 -0
- package/dist/data/usageRun.d.ts.map +1 -0
- package/dist/data/usageRun.js +50 -0
- package/dist/data/webhookEvent.d.ts +1 -1
- package/dist/entitlement/allowance.d.ts +100 -0
- package/dist/entitlement/allowance.d.ts.map +1 -0
- package/dist/entitlement/allowance.js +171 -0
- package/dist/entitlement/manual.d.ts +5 -5
- package/dist/entitlement/manual.js +3 -3
- package/dist/entitlement/meter.d.ts +98 -0
- package/dist/entitlement/meter.d.ts.map +1 -0
- package/dist/entitlement/meter.js +177 -0
- package/dist/entitlement/override.d.ts +119 -0
- package/dist/entitlement/override.d.ts.map +1 -0
- package/dist/entitlement/override.js +256 -0
- package/dist/entitlement/resolver.d.ts +2 -1
- package/dist/entitlement/resolver.d.ts.map +1 -1
- package/dist/entitlement/resolver.js +32 -1
- package/dist/error/errors.d.ts +23 -3
- package/dist/error/errors.d.ts.map +1 -1
- package/dist/error/errors.js +35 -2
- package/dist/http/responses.d.ts +367 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +146 -7
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +270 -16
- package/dist/http/schemas.d.ts +54 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +61 -2
- package/dist/http/scopes.d.ts +25 -0
- package/dist/http/scopes.d.ts.map +1 -1
- package/dist/http/scopes.js +60 -1
- package/dist/http/view.d.ts +22 -4
- package/dist/http/view.d.ts.map +1 -1
- package/dist/http/view.js +88 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/migrations/0002_allowances.d.ts +26 -0
- package/dist/migrations/0002_allowances.d.ts.map +1 -0
- package/dist/migrations/0002_allowances.js +62 -0
- package/dist/peer.d.ts +2 -1
- package/dist/peer.d.ts.map +1 -1
- package/dist/projection/event.d.ts +1 -0
- package/dist/projection/event.d.ts.map +1 -1
- package/dist/projection/event.js +1 -0
- package/dist/projection/writer.d.ts.map +1 -1
- package/dist/projection/writer.js +3 -1
- package/dist/rails/contract.d.ts +6 -0
- package/dist/rails/contract.d.ts.map +1 -1
- package/dist/rails/google/playApi.d.ts.map +1 -1
- package/dist/rails/google/playApi.js +2 -0
- package/dist/rails/paddle/objects.d.ts +2 -0
- package/dist/rails/paddle/objects.d.ts.map +1 -1
- package/dist/rails/paddle/objects.js +7 -2
- package/dist/rails/paddle/usage.d.ts +11 -0
- package/dist/rails/paddle/usage.d.ts.map +1 -0
- package/dist/rails/paddle/usage.js +49 -0
- package/dist/rails/quantity.d.ts +12 -0
- package/dist/rails/quantity.d.ts.map +1 -0
- package/dist/rails/quantity.js +16 -0
- package/dist/rails/stripe/checkout.d.ts.map +1 -1
- package/dist/rails/stripe/checkout.js +1 -1
- package/dist/rails/stripe/objects.d.ts.map +1 -1
- package/dist/rails/stripe/objects.js +3 -0
- package/dist/rails/stripe/usage.d.ts +10 -0
- package/dist/rails/stripe/usage.d.ts.map +1 -0
- package/dist/rails/stripe/usage.js +49 -0
- package/dist/usage/pass.d.ts +120 -0
- package/dist/usage/pass.d.ts.map +1 -0
- package/dist/usage/pass.js +363 -0
- package/dist/usage/reporter.d.ts +36 -0
- package/dist/usage/reporter.d.ts.map +1 -0
- package/dist/usage/reporter.js +2 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/workflows/report.d.ts.map +1 -1
- package/dist/workflows/specs.d.ts +28 -0
- package/dist/workflows/specs.d.ts.map +1 -1
- package/dist/workflows/specs.js +26 -1
- package/dist/workflows/usage.d.ts +38 -0
- package/dist/workflows/usage.d.ts.map +1 -0
- package/dist/workflows/usage.js +77 -0
- package/dist/workflows/worker.js +2 -2
- package/docs/entitlements.md +249 -0
- package/docs/lemon-squeezy.md +1 -0
- package/docs/paddle.md +1 -0
- package/package.json +5 -5
- package/pithy.manifest.json +3 -8
- package/src/admin/coverage.ts +28 -0
- package/src/admin/read.ts +173 -1
- package/src/audit/actions.ts +13 -0
- package/src/capability.ts +87 -9
- package/src/client/api.ts +44 -0
- package/src/client/hooks.ts +44 -0
- package/src/client/projection.ts +31 -0
- package/src/config/allowances.ts +211 -0
- package/src/config/config.ts +283 -15
- package/src/data/meterCounter.ts +38 -0
- package/src/data/override.ts +74 -0
- package/src/data/period.ts +53 -0
- package/src/data/purchase.ts +9 -0
- package/src/data/tables.ts +25 -1
- package/src/data/usageReport.ts +64 -0
- package/src/data/usageRun.ts +66 -0
- package/src/entitlement/allowance.ts +213 -0
- package/src/entitlement/manual.ts +6 -6
- package/src/entitlement/meter.ts +252 -0
- package/src/entitlement/override.ts +381 -0
- package/src/entitlement/resolver.ts +43 -2
- package/src/error/errors.ts +48 -4
- package/src/http/responses.ts +305 -4
- package/src/http/routes.ts +365 -11
- package/src/http/schemas.ts +139 -1
- package/src/http/scopes.ts +68 -0
- package/src/http/view.ts +112 -7
- package/src/index.ts +18 -0
- package/src/migrations/0002_allowances.ts +149 -0
- package/src/projection/event.ts +9 -0
- package/src/projection/writer.ts +4 -0
- package/src/rails/contract.ts +6 -0
- package/src/rails/google/playApi.ts +2 -0
- package/src/rails/paddle/fixtures/subscription-charge.json +19 -0
- package/src/rails/paddle/objects.ts +6 -0
- package/src/rails/paddle/usage.ts +66 -0
- package/src/rails/quantity.ts +14 -0
- package/src/rails/stripe/checkout.ts +3 -1
- package/src/rails/stripe/fixtures/meter-event-created.json +12 -0
- package/src/rails/stripe/objects.ts +4 -0
- package/src/rails/stripe/usage.ts +61 -0
- package/src/usage/pass.ts +539 -0
- package/src/usage/reporter.ts +38 -0
- package/src/version.generated.ts +1 -1
- package/src/workflows/report.ts +4 -2
- package/src/workflows/specs.ts +34 -0
- package/src/workflows/usage.ts +97 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Three payment rails — Apple, Google, Stripe — resolving to one cross-rail entitlement, in your own Worker and your own D1.
|
|
4
4
|
|
|
5
|
-
Buy Pro on iOS, be entitled on the web. That resolution is the whole product, and it is the same one **[RevenueCat](https://www.revenuecat.com)** built a very good business on — their SDKs, their store-quirk coverage and their dashboards are genuinely ahead of this package. The honest difference is not the feature list. It is **where the purchase history lives**: RevenueCat is a hosted data plane holding your customers' transactions, and this is
|
|
5
|
+
Buy Pro on iOS, be entitled on the web. That resolution is the whole product, and it is the same one **[RevenueCat](https://www.revenuecat.com)** built a very good business on — their SDKs, their store-quirk coverage and their dashboards are genuinely ahead of this package. The honest difference is not the feature list. It is **where the purchase history lives**: RevenueCat is a hosted data plane holding your customers' transactions, and this is ten tables in a D1 you own, written by a Worker you deploy.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
pithy add payments
|
|
@@ -38,11 +38,16 @@ _Everything else is on the site. `pithy.sh/docs` is canonical — new prose goes
|
|
|
38
38
|
| `GET /payments/admin/discounts` | The discount codes this project has issued | control-plane: `payments:discounts:read` |
|
|
39
39
|
| `POST /payments/entitlements/grant` | Comp or repair an entitlement | control-plane: `payments:entitlements:grant` |
|
|
40
40
|
| `POST /payments/entitlements/revoke` | Take one back | control-plane: `payments:entitlements:revoke` |
|
|
41
|
-
| `
|
|
41
|
+
| `POST /payments/entitlements/overrides` | Pin a negotiated quota or feature for one subject — a merge by name, version-checked, with a reason | control-plane: `payments:overrides:set` |
|
|
42
|
+
| `POST /payments/entitlements/overrides/unrestricted` | Grant one subject the whole product, or take it back | control-plane: `payments:overrides:unrestricted` |
|
|
43
|
+
| `POST /payments/entitlements/overrides/clear` | Unpin names for one subject, or clear its override | control-plane: `payments:overrides:clear` |
|
|
44
|
+
| `GET /payments/admin/catalog` | What this project sells, what each entitlement buys, and the keys it comps by hand | control-plane: `payments:catalog:read` |
|
|
42
45
|
| `GET /payments/admin/purchases` | The purchase log, paged | control-plane: `payments:purchases:read` |
|
|
43
46
|
| `GET /payments/admin/subscriptions` | The purchases that renew | control-plane: `payments:subscriptions:read` |
|
|
44
47
|
| `GET /payments/admin/entitlements` | The entitlement model, paged | control-plane: `payments:entitlements:read` |
|
|
45
|
-
| `GET /payments/admin/entitlements/:subjectType/:subjectId` | One subject's entitlements | control-plane: `payments:entitlements:read` |
|
|
48
|
+
| `GET /payments/admin/entitlements/:subjectType/:subjectId` | One subject's entitlements, override and resolved allowances | control-plane: `payments:entitlements:read` |
|
|
49
|
+
| `GET /payments/admin/overrides` | Every subject's override, and who is unrestricted | control-plane: `payments:entitlements:read` |
|
|
50
|
+
| `GET /payments/admin/usage-runs` | The usage-reporting passes this deployment has run | control-plane: `payments:usage:read` |
|
|
46
51
|
| `GET /payments/admin/reconcile-runs` | The reconciliation passes this deployment has run | control-plane: `payments:reconcile:read` |
|
|
47
52
|
| `POST /payments/admin/reconcile-runs` | Start a pass now, rather than waiting for the nightly one | control-plane: `payments:reconcile:run` |
|
|
48
53
|
|
|
@@ -134,6 +139,8 @@ The read that ships before the four verbs beside it. A capability that can cance
|
|
|
134
139
|
| `nextBilledAt` | When the next charge falls due, or null when none is going to. **Null is neither canceled nor broken** |
|
|
135
140
|
| `scheduledChange` | The change waiting to land, or null. `action` is `cancel`, `pause` or `resume`; `effectiveAt` is when it happens; `resumesAt` is when a paused subscription comes back, or null |
|
|
136
141
|
| `nextEvent` | What happens next and when, already resolved — `{ "kind": "renews" \| "ends" \| "pauses" \| "resumes", "at": "…" }`, or `{ "kind": "unknown", "at": null }` |
|
|
142
|
+
| `reportedQuantity` | For a product billed by a reported quantity, the last count sent to the store, or null when none has been. Absent from a Worker that predates reported billing |
|
|
143
|
+
| `reportedAt` | When that count was sent, ISO-8601, or null |
|
|
137
144
|
|
|
138
145
|
**Render `nextEvent`, not `status`.** The subscription above is one somebody canceled. Paddle reports it as `active`, with no cancellation date and a blank next billing date (recorded against the sandbox, 2026-08-28): two of the three say the subscription is fine and the third says nothing at all. The day it ends exists only on `scheduledChange.effectiveAt`. A screen that reads the status tells a customer who canceled that they will be billed again, and `nextEvent` is that precedence resolved on the server so no client has to rediscover it.
|
|
139
146
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/admin/coverage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/admin/coverage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AASrD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAC1B;IACE;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,iBAAiB,EAAE,GAAG,iBAAiB,EAAE,CAAC,CAAC;CACtE,GACD;IACE,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEN,4EAA4E;AAC5E,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,cAAc,EAAE,kBAAkB,CAsFtF,CAAC"}
|
package/dist/admin/coverage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { PAYMENTS_ENTITLEMENTS_READ_SCOPE, PAYMENTS_PURCHASES_READ_SCOPE, PAYMENTS_RECONCILE_READ_SCOPE, PAYMENTS_SUBSCRIPTIONS_READ_SCOPE } from "../http/scopes.js";
|
|
3
|
+
import { PAYMENTS_ENTITLEMENTS_READ_SCOPE, PAYMENTS_PURCHASES_READ_SCOPE, PAYMENTS_RECONCILE_READ_SCOPE, PAYMENTS_SUBSCRIPTIONS_READ_SCOPE, PAYMENTS_USAGE_READ_SCOPE } from "../http/scopes.js";
|
|
4
4
|
//#region src/admin/coverage.ts
|
|
5
5
|
/** Every payments table, and what a management client may learn from it. */
|
|
6
6
|
const PAYMENTS_TABLE_DISCLOSURE = {
|
|
@@ -52,7 +52,31 @@ const PAYMENTS_TABLE_DISCLOSURE = {
|
|
|
52
52
|
* every event between the old value and the new, silently and unrepairably. The sweep's own state is
|
|
53
53
|
* the sweep's; what it *found* is in the purchases and webhook-event tables, which are readable.
|
|
54
54
|
*/
|
|
55
|
-
pithyPaymentsSyncCursors: { withheld: "A sweep's resume token is internal bookkeeping, not a fact about a customer. Reading it answers nothing a management client asks, and the write it invites would silently skip every event between two cursor values." }
|
|
55
|
+
pithyPaymentsSyncCursors: { withheld: "A sweep's resume token is internal bookkeeping, not a fact about a customer. Reading it answers nothing a management client asks, and the write it invites would silently skip every event between two cursor values." },
|
|
56
|
+
/**
|
|
57
|
+
* One subject's override, read on the subject's entitlement read — the version a set must send back, the
|
|
58
|
+
* pins, and whether the subject is `unrestricted`. Read where the entitlements are because the two answer
|
|
59
|
+
* one question together: what this subject may have, and why. `unrestricted` also surfaces on the
|
|
60
|
+
* entitlement listing, because a privilege this size must not be inferable only from a row nobody opens.
|
|
61
|
+
*/
|
|
62
|
+
pithyPaymentsOverrides: { reads: [PAYMENTS_ENTITLEMENTS_READ_SCOPE] },
|
|
63
|
+
/**
|
|
64
|
+
* Withheld. A counter exists to refuse a write at a limit and for no other purpose, and the subject read
|
|
65
|
+
* already says what the limit is. A page of every subject's usage is a page of every customer's activity,
|
|
66
|
+
* and nothing a management client does needs it.
|
|
67
|
+
*/
|
|
68
|
+
pithyPaymentsMeterCounters: { withheld: "A meter counts to refuse at a limit and for nothing else. The limit is on the subject's entitlement read; a page of every subject's usage is a page of every customer's activity, which no pane needs." },
|
|
69
|
+
/**
|
|
70
|
+
* The last count reported for a subscription, on the subscription read — what a quantity-billed customer
|
|
71
|
+
* was billed for, and when it was sent.
|
|
72
|
+
*/
|
|
73
|
+
pithyPaymentsUsageReports: { reads: [PAYMENTS_SUBSCRIPTIONS_READ_SCOPE] },
|
|
74
|
+
/**
|
|
75
|
+
* The usage-reporting run log, on its own scope — the reporting pass's health, as the reconcile run log is
|
|
76
|
+
* reconciliation's. Unlike that log it names subjects, in the findings an operator acts on, so it is not
|
|
77
|
+
* the health monitor's scope: it is granted to whoever answers "why was this customer not billed".
|
|
78
|
+
*/
|
|
79
|
+
pithyPaymentsUsageRuns: { reads: [PAYMENTS_USAGE_READ_SCOPE] }
|
|
56
80
|
};
|
|
57
81
|
//#endregion
|
|
58
82
|
export { PAYMENTS_TABLE_DISCLOSURE };
|
package/dist/admin/read.d.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
4
4
|
import type { z } from "zod";
|
|
5
5
|
import { PaymentsEntitlement } from "../data/entitlement";
|
|
6
|
+
import { PaymentsOverride } from "../data/override";
|
|
6
7
|
import { type PurchaseEnvironment } from "../data/purchase";
|
|
7
8
|
import type { PaymentsRail } from "../data/rail";
|
|
8
9
|
import { PaymentsReconcileRun } from "../data/reconcileRun";
|
|
9
10
|
import type { PurchaseStatus } from "../data/status";
|
|
10
|
-
import type
|
|
11
|
+
import { type PaymentsSubject } from "../data/subject";
|
|
12
|
+
import { PaymentsUsageRun } from "../data/usageRun";
|
|
11
13
|
/**
|
|
12
14
|
* The management read model — the queries behind the control-plane reads, and nothing else.
|
|
13
15
|
*
|
|
@@ -113,6 +115,7 @@ export declare const PaymentsPurchaseRecord: z.ZodObject<{
|
|
|
113
115
|
originalTransactionId: z.ZodNullable<z.ZodString>;
|
|
114
116
|
amountMinor: z.ZodNullable<z.ZodNumber>;
|
|
115
117
|
currency: z.ZodNullable<z.ZodString>;
|
|
118
|
+
quantity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
116
119
|
updatedAt: z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>;
|
|
117
120
|
}, z.core.$strip>;
|
|
118
121
|
export type PaymentsPurchaseRecord = z.output<typeof PaymentsPurchaseRecord>;
|
|
@@ -198,6 +201,50 @@ export declare function listEntitlements(d1: D1Database, query?: EntitlementsQue
|
|
|
198
201
|
* surface an existence oracle for user and organization ids alike.
|
|
199
202
|
*/
|
|
200
203
|
export declare function readEntitlements(d1: D1Database, subject: PaymentsSubject): Promise<PaymentsEntitlement[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Which of `subjects` are `unrestricted` — what the entitlement listing marks on each row. One query for the
|
|
206
|
+
* page rather than one per row, on the override index that leads on `unrestricted`.
|
|
207
|
+
*/
|
|
208
|
+
export declare function unrestrictedSubjects(d1: D1Database, subjects: readonly PaymentsSubject[]): Promise<Set<string>>;
|
|
209
|
+
/** What {@link listOverrides} accepts. */
|
|
210
|
+
export interface OverridesQuery {
|
|
211
|
+
/** Narrow to one subject. */
|
|
212
|
+
subject?: PaymentsSubject;
|
|
213
|
+
/** Narrow to the subjects that are `unrestricted`. */
|
|
214
|
+
unrestricted?: boolean;
|
|
215
|
+
/** Where to resume. */
|
|
216
|
+
cursor?: string;
|
|
217
|
+
/** How many rows to return, clamped by `pageLimit`. */
|
|
218
|
+
limit?: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Every subject's override, most recently changed first. A row a clear emptied is kept only so its version
|
|
222
|
+
* never repeats, and overrides nothing, so it is not listed.
|
|
223
|
+
*/
|
|
224
|
+
export declare function listOverrides(d1: D1Database, query?: OverridesQuery): Promise<PaymentsPage<PaymentsOverride>>;
|
|
225
|
+
/** Every `unrestricted` subject this deployment holds — what `pithy doctor` names. */
|
|
226
|
+
export declare function listUnrestrictedSubjects(d1: D1Database): Promise<PaymentsSubject[]>;
|
|
227
|
+
/** What {@link listUsageRuns} accepts. */
|
|
228
|
+
export interface UsageRunsQuery {
|
|
229
|
+
/** Where to resume, from a previous page's `nextCursor`. A malformed one is a first page. */
|
|
230
|
+
cursor?: string;
|
|
231
|
+
/** How many rows to return, clamped by `pageLimit`. */
|
|
232
|
+
limit?: number;
|
|
233
|
+
}
|
|
234
|
+
/** The usage-reporting passes this deployment has run, newest first — the same keyset the reconcile log uses. */
|
|
235
|
+
export declare function listUsageRuns(d1: D1Database, query?: UsageRunsQuery): Promise<PaymentsPage<PaymentsUsageRun>>;
|
|
236
|
+
/**
|
|
237
|
+
* The newest accepted report of each subscription, by its store id — what the subscription reads show as the
|
|
238
|
+
* last reported count. Keyed on the subscription rather than on one period's purchase row, because the report
|
|
239
|
+
* for a period lands at that period's end and the current row has none until then.
|
|
240
|
+
*/
|
|
241
|
+
export declare function lastReports(d1: D1Database, subscriptions: readonly {
|
|
242
|
+
rail: PaymentsRail;
|
|
243
|
+
providerSubscriptionId: string;
|
|
244
|
+
}[]): Promise<Map<string, {
|
|
245
|
+
quantity: number;
|
|
246
|
+
reportedAt: Date;
|
|
247
|
+
}>>;
|
|
201
248
|
/** What {@link listReconcileRuns} accepts. */
|
|
202
249
|
export interface ReconcileRunsQuery {
|
|
203
250
|
/** Restrict to the passes narrowed to one store. Never matches a pass that ran against every rail. */
|
package/dist/admin/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/admin/read.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/admin/read.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAA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,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAyB7C"}
|
package/dist/admin/read.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { encodeSubjectReference } from "../data/subject.js";
|
|
3
4
|
import { PaymentsEntitlement } from "../data/entitlement.js";
|
|
5
|
+
import { PaymentsOverride } from "../data/override.js";
|
|
4
6
|
import { PaymentsPurchase } from "../data/purchase.js";
|
|
5
7
|
import { PaymentsReconcileRun } from "../data/reconcileRun.js";
|
|
6
|
-
import {
|
|
8
|
+
import { PaymentsUsageReport } from "../data/usageReport.js";
|
|
9
|
+
import { PaymentsUsageRun } from "../data/usageRun.js";
|
|
10
|
+
import { PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_OVERRIDES_TABLE, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_USAGE_REPORTS_TABLE, PAYMENTS_USAGE_RUNS_TABLE, paymentsDatabase } from "../data/tables.js";
|
|
11
|
+
import { chunkByBoundParameters } from "@pithy-sh/core/src/data/boundParameters";
|
|
7
12
|
import { decodeCursor, pageLimit, toPage } from "@pithy-sh/core/src/data/cursor";
|
|
8
13
|
//#region src/admin/read.ts
|
|
9
14
|
/**
|
|
@@ -29,6 +34,7 @@ const PaymentsPurchaseRecord = PaymentsPurchase.pick({
|
|
|
29
34
|
environment: true,
|
|
30
35
|
amountMinor: true,
|
|
31
36
|
currency: true,
|
|
37
|
+
quantity: true,
|
|
32
38
|
purchasedAt: true,
|
|
33
39
|
expiresAt: true,
|
|
34
40
|
revokedAt: true,
|
|
@@ -134,6 +140,87 @@ async function readEntitlements(d1, subject) {
|
|
|
134
140
|
return (await paymentsDatabase(d1).selectFrom(PAYMENTS_ENTITLEMENTS_TABLE).selectAll().where("subjectType", "=", subject.subjectType).where("subjectId", "=", subject.subjectId).orderBy("entitlement", "asc").execute()).map((row) => PaymentsEntitlement.parse(row));
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
143
|
+
* Which of `subjects` are `unrestricted` — what the entitlement listing marks on each row. One query for the
|
|
144
|
+
* page rather than one per row, on the override index that leads on `unrestricted`.
|
|
145
|
+
*/
|
|
146
|
+
async function unrestrictedSubjects(d1, subjects) {
|
|
147
|
+
if (subjects.length === 0) return /* @__PURE__ */ new Set();
|
|
148
|
+
const db = paymentsDatabase(d1);
|
|
149
|
+
const found = /* @__PURE__ */ new Set();
|
|
150
|
+
for (const ids of chunkByBoundParameters([...new Set(subjects.map((subject) => subject.subjectId))], 1)) {
|
|
151
|
+
const rows = await db.selectFrom(PAYMENTS_OVERRIDES_TABLE).select(["subjectType", "subjectId"]).where("unrestricted", "=", 1).where("subjectId", "in", ids).execute();
|
|
152
|
+
for (const row of rows) found.add(encodeSubjectReference(row));
|
|
153
|
+
}
|
|
154
|
+
return found;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Every subject's override, most recently changed first. A row a clear emptied is kept only so its version
|
|
158
|
+
* never repeats, and overrides nothing, so it is not listed.
|
|
159
|
+
*/
|
|
160
|
+
async function listOverrides(d1, query = {}) {
|
|
161
|
+
const limit = pageLimit(query.limit);
|
|
162
|
+
const after = resume(query.cursor);
|
|
163
|
+
let selection = paymentsDatabase(d1).selectFrom(PAYMENTS_OVERRIDES_TABLE).selectAll().where((eb) => eb.or([
|
|
164
|
+
eb("unrestricted", "=", 1),
|
|
165
|
+
eb("quotas", "!=", "{}"),
|
|
166
|
+
eb("features", "!=", "{}")
|
|
167
|
+
])).orderBy("updatedAt", "desc").orderBy("id", "desc").limit(limit + 1);
|
|
168
|
+
if (query.subject !== void 0) selection = selection.where("subjectType", "=", query.subject.subjectType).where("subjectId", "=", query.subject.subjectId);
|
|
169
|
+
if (query.unrestricted !== void 0) {
|
|
170
|
+
const flag = query.unrestricted ? 1 : 0;
|
|
171
|
+
selection = selection.where("unrestricted", "=", flag);
|
|
172
|
+
}
|
|
173
|
+
if (after) selection = selection.where((eb) => eb.or([eb("updatedAt", "<", after.sort), eb.and([eb("updatedAt", "=", after.sort), eb("id", "<", after.id)])]));
|
|
174
|
+
const rows = await selection.execute();
|
|
175
|
+
return toPage(rows.map((row) => PaymentsOverride.parse(row)), limit, (override) => ({
|
|
176
|
+
sort: override.updatedAt.getTime(),
|
|
177
|
+
id: override.id
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
/** Every `unrestricted` subject this deployment holds — what `pithy doctor` names. */
|
|
181
|
+
async function listUnrestrictedSubjects(d1) {
|
|
182
|
+
return (await paymentsDatabase(d1).selectFrom(PAYMENTS_OVERRIDES_TABLE).select(["subjectType", "subjectId"]).where("unrestricted", "=", 1).orderBy("subjectType").orderBy("subjectId").execute()).map((row) => ({
|
|
183
|
+
subjectType: row.subjectType,
|
|
184
|
+
subjectId: row.subjectId
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
/** The usage-reporting passes this deployment has run, newest first — the same keyset the reconcile log uses. */
|
|
188
|
+
async function listUsageRuns(d1, query = {}) {
|
|
189
|
+
const limit = pageLimit(query.limit);
|
|
190
|
+
const after = resume(query.cursor);
|
|
191
|
+
let selection = paymentsDatabase(d1).selectFrom(PAYMENTS_USAGE_RUNS_TABLE).selectAll().orderBy("startedAt", "desc").orderBy("id", "desc").limit(limit + 1);
|
|
192
|
+
if (after) selection = selection.where((eb) => eb.or([eb("startedAt", "<", after.sort), eb.and([eb("startedAt", "=", after.sort), eb("id", "<", after.id)])]));
|
|
193
|
+
const rows = await selection.execute();
|
|
194
|
+
return toPage(rows.map((row) => PaymentsUsageRun.parse(row)), limit, (run) => ({
|
|
195
|
+
sort: run.startedAt.getTime(),
|
|
196
|
+
id: run.id
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The newest accepted report of each subscription, by its store id — what the subscription reads show as the
|
|
201
|
+
* last reported count. Keyed on the subscription rather than on one period's purchase row, because the report
|
|
202
|
+
* for a period lands at that period's end and the current row has none until then.
|
|
203
|
+
*/
|
|
204
|
+
async function lastReports(d1, subscriptions) {
|
|
205
|
+
const latest = /* @__PURE__ */ new Map();
|
|
206
|
+
if (subscriptions.length === 0) return latest;
|
|
207
|
+
const db = paymentsDatabase(d1);
|
|
208
|
+
const ids = [...new Set(subscriptions.map((entry) => entry.providerSubscriptionId))];
|
|
209
|
+
for (const chunk of chunkByBoundParameters(ids, 1)) {
|
|
210
|
+
const rows = await db.selectFrom(PAYMENTS_USAGE_REPORTS_TABLE).selectAll().where("providerSubscriptionId", "in", chunk).where("status", "=", "reported").orderBy("reportedAt", "desc").execute();
|
|
211
|
+
for (const row of rows) {
|
|
212
|
+
const report = PaymentsUsageReport.parse(row);
|
|
213
|
+
const key = `${report.rail}:${report.providerSubscriptionId}`;
|
|
214
|
+
if (report.reportedAt === null || latest.has(key)) continue;
|
|
215
|
+
latest.set(key, {
|
|
216
|
+
quantity: report.quantity,
|
|
217
|
+
reportedAt: report.reportedAt
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return latest;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
137
224
|
* The reconciliation passes this deployment has run, newest first.
|
|
138
225
|
*
|
|
139
226
|
* Ordered on `startedAt`, not `finishedAt`, and the difference is the health question: a pass that began and
|
|
@@ -158,4 +245,4 @@ async function listReconcileRuns(d1, query = {}) {
|
|
|
158
245
|
}));
|
|
159
246
|
}
|
|
160
247
|
//#endregion
|
|
161
|
-
export { PaymentsPurchaseRecord, listEntitlements, listPurchases, listReconcileRuns, listSubscriptions, readEntitlements };
|
|
248
|
+
export { PaymentsPurchaseRecord, lastReports, listEntitlements, listOverrides, listPurchases, listReconcileRuns, listSubscriptions, listUnrestrictedSubjects, listUsageRuns, readEntitlements, unrestrictedSubjects };
|
package/dist/audit/actions.d.ts
CHANGED
|
@@ -207,6 +207,19 @@ export declare const PaymentsAuditActions: {
|
|
|
207
207
|
* indistinguishable from the 04:00 cron, which is exactly the question somebody reading the trail is asking.
|
|
208
208
|
*/
|
|
209
209
|
readonly reconcileRunStarted: "payments/reconcile_run_started";
|
|
210
|
+
/**
|
|
211
|
+
* A management client pinned allowances for one subject, or turned `unrestricted` on or off. The first
|
|
212
|
+
* runtime-writable input to an entitlement decision, so every write is recorded with the subject, the
|
|
213
|
+
* mode, the before and the after — and the **reason**, verbatim, because six months later the only
|
|
214
|
+
* question anybody asks about an override is why.
|
|
215
|
+
*/
|
|
216
|
+
readonly overrideSet: "payments/override_set";
|
|
217
|
+
/** A management client unpinned allowances for one subject, or cleared its override. */
|
|
218
|
+
readonly overrideCleared: "payments/override_cleared";
|
|
219
|
+
/**
|
|
220
|
+
* A management client read the usage-reporting run log. Counts and filters only, as every management read.
|
|
221
|
+
*/
|
|
222
|
+
readonly usageRunsRead: "payments/usage_runs_read";
|
|
210
223
|
};
|
|
211
224
|
/** One of the payments audit action codes. */
|
|
212
225
|
export type PaymentsAuditAction = (typeof PaymentsAuditActions)[keyof typeof PaymentsAuditActions];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/audit/actions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oBAAoB;IAC/B,2GAA2G;aAC3G,gBAAgB,EAAE,4BAA4B;IAC9C,6FAA6F;aAC7F,gBAAgB,EAAE,4BAA4B;IAC9C,iHAAiH;aACjH,eAAe,EAAE,2BAA2B;IAC5C,iHAAiH;aACjH,iBAAiB,EAAE,6BAA6B;IAChD;;;;;;;;;OASG;aACH,wBAAwB,EAAE,qCAAqC;IAC/D;;;;;;;OAOG;aACH,kBAAkB,EAAE,8BAA8B;IAClD;;;OAGG;aACH,eAAe,EAAE,2BAA2B;IAC5C;;;OAGG;aACH,YAAY,EAAE,wBAAwB;IACtC;;;;;;;;;OASG;aACH,cAAc,EAAE,0BAA0B;IA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GAA4G;aAC5G,eAAe,EAAE,2BAA2B;IAC5C;;;;;;OAMG;aACH,aAAa,EAAE,yBAAyB;IACxC;;;;OAIG;aACH,kBAAkB,EAAE,8BAA8B;IAClD,+GAA+G;aAC/G,kBAAkB,EAAE,8BAA8B;IAClD;;;;;;;;;;;;OAYG;aACH,aAAa,EAAE,yBAAyB;IACxC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;aACH,uBAAuB,EAAE,oCAAoC;IAC7D;;;;;;;;;OASG;aACH,oBAAoB,EAAE,gCAAgC;IACtD;;;;;;;OAOG;aACH,2BAA2B,EAAE,wCAAwC;IACrE;;;;;;;;;;;;;;;;;;;;;;;OAuBG;aACH,2BAA2B,EAAE,wCAAwC;IACrE,8GAA8G;aAC9G,iBAAiB,EAAE,6BAA6B;IAChD;;;;;OAKG;aACH,gBAAgB,EAAE,4BAA4B;IAC9C;;;;;;;OAOG;aACH,WAAW,EAAE,uBAAuB;IACpC;;;;;;;OAOG;aACH,iBAAiB,EAAE,8BAA8B;IACjD;;;;;;;OAOG;aACH,mBAAmB,EAAE,gCAAgC;IACrD;;;;;OAKG;aACH,WAAW,EAAE,uBAAuB;IACpC,wFAAwF;aACxF,eAAe,EAAE,2BAA2B;IAC5C;;OAEG;aACH,aAAa,EAAE,0BAA0B;CACjC,CAAC;AAEX,8CAA8C;AAC9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/audit/actions.js
CHANGED
|
@@ -207,7 +207,20 @@ const PaymentsAuditActions = {
|
|
|
207
207
|
* grant and revoke rows behind it name what moved. Without it a pass triggered from a browser is
|
|
208
208
|
* indistinguishable from the 04:00 cron, which is exactly the question somebody reading the trail is asking.
|
|
209
209
|
*/
|
|
210
|
-
reconcileRunStarted: "payments/reconcile_run_started"
|
|
210
|
+
reconcileRunStarted: "payments/reconcile_run_started",
|
|
211
|
+
/**
|
|
212
|
+
* A management client pinned allowances for one subject, or turned `unrestricted` on or off. The first
|
|
213
|
+
* runtime-writable input to an entitlement decision, so every write is recorded with the subject, the
|
|
214
|
+
* mode, the before and the after — and the **reason**, verbatim, because six months later the only
|
|
215
|
+
* question anybody asks about an override is why.
|
|
216
|
+
*/
|
|
217
|
+
overrideSet: "payments/override_set",
|
|
218
|
+
/** A management client unpinned allowances for one subject, or cleared its override. */
|
|
219
|
+
overrideCleared: "payments/override_cleared",
|
|
220
|
+
/**
|
|
221
|
+
* A management client read the usage-reporting run log. Counts and filters only, as every management read.
|
|
222
|
+
*/
|
|
223
|
+
usageRunsRead: "payments/usage_runs_read"
|
|
211
224
|
};
|
|
212
225
|
//#endregion
|
|
213
226
|
export { PaymentsAuditActions };
|
package/dist/capability.d.ts
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { type Capability } from "@pithy-sh/core/src/capability/capability";
|
|
4
4
|
import type { DatabaseSpecMap } from "@pithy-sh/core/src/data/databases";
|
|
5
|
+
import type { UsageMeter } from "@pithy-sh/core/src/entitlement/meter";
|
|
5
6
|
import type { KvNamespaceSpecMap } from "@pithy-sh/core/src/kv/namespaces";
|
|
6
7
|
import { PaymentsConfig, type PaymentsConfigInput } from "./config/config";
|
|
7
8
|
import type { PaymentsSubjectResolver } from "./entitlement/subjectSeam";
|
|
8
9
|
import { type PaymentsPeer } from "./peer";
|
|
9
|
-
import {
|
|
10
|
+
import type { PaymentsQuantityResolver } from "./usage/pass";
|
|
11
|
+
import { paymentsUsageWorkflows, paymentsWorkflows } from "./workflows/specs";
|
|
10
12
|
/**
|
|
11
13
|
* Where payments' migrations sort in the app database. Unique per database; the registry composes keys
|
|
12
14
|
* like `1000_payments_0001_purchases`. Sits after vector (900), and was `NEXT_FREE_ORDER` when it was
|
|
@@ -39,9 +41,22 @@ export type PaymentsOptions = PaymentsConfigInput & {
|
|
|
39
41
|
* it is optional and the authenticated caller is the answer.
|
|
40
42
|
*/
|
|
41
43
|
resolveSubject?: PaymentsSubjectResolver;
|
|
44
|
+
/**
|
|
45
|
+
* How many of a quantity-billed product's units one subject has — students, coaches, seats. Required
|
|
46
|
+
* when any product declares `billing: { kind: "reported" }`, and refused at boot without one. Called by the
|
|
47
|
+
* usage-reporting pass on a schedule, with the env and no request; never by payments for anything else, and
|
|
48
|
+
* payments never counts members itself. Rides here rather than in config for the reason `resolveSubject`
|
|
49
|
+
* does: a function does not survive the config's round trip through JSON. See `usage/pass.ts`.
|
|
50
|
+
*/
|
|
51
|
+
resolveQuantity?: PaymentsQuantityResolver;
|
|
42
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* The Workflows payments contributes: reconciliation always, usage reporting when the catalog sells a reported
|
|
55
|
+
* product.
|
|
56
|
+
*/
|
|
57
|
+
type PaymentsWorkflowSpecs = typeof paymentsWorkflows & Partial<typeof paymentsUsageWorkflows>;
|
|
43
58
|
/** The payments capability, with its resolved catalog attached for other tooling to read. */
|
|
44
|
-
export interface PaymentsCapability extends Capability<DatabaseSpecMap, KvNamespaceSpecMap, "payments",
|
|
59
|
+
export interface PaymentsCapability extends Capability<DatabaseSpecMap, KvNamespaceSpecMap, "payments", PaymentsWorkflowSpecs> {
|
|
45
60
|
/** The resolved catalog. */
|
|
46
61
|
paymentsConfig: PaymentsConfig;
|
|
47
62
|
/**
|
|
@@ -50,6 +65,21 @@ export interface PaymentsCapability extends Capability<DatabaseSpecMap, KvNamesp
|
|
|
50
65
|
* payments bundles it (#645). See `peer.ts`.
|
|
51
66
|
*/
|
|
52
67
|
paymentsPeer: PaymentsPeer;
|
|
68
|
+
/**
|
|
69
|
+
* The meter `@pithy-sh/email` charges at enqueue — found structurally through core's
|
|
70
|
+
* `composedUsageMeter`, so email imports nothing from this package. Charges nothing for a meter this
|
|
71
|
+
* config leaves advisory. See `entitlement/meter.ts`.
|
|
72
|
+
*/
|
|
73
|
+
usageMeter: UsageMeter;
|
|
74
|
+
/**
|
|
75
|
+
* What the usage-reporting Workflow reads off the composition: the adopter's `resolveQuantity`, when the
|
|
76
|
+
* catalog bills by a reported quantity, and undefined otherwise. On the capability rather than in the
|
|
77
|
+
* config, so it is never serialized and never reaches a browser. `reportPaymentsUsage` in
|
|
78
|
+
* `workflows/usage.ts` reads it.
|
|
79
|
+
*/
|
|
80
|
+
paymentsUsage: {
|
|
81
|
+
resolveQuantity: PaymentsQuantityResolver;
|
|
82
|
+
} | undefined;
|
|
53
83
|
}
|
|
54
84
|
/**
|
|
55
85
|
* Three rails — Apple, Google, Stripe — projecting onto one cross-rail entitlement, in the adopter's own
|
|
@@ -79,4 +109,5 @@ export interface PaymentsCapability extends Capability<DatabaseSpecMap, KvNamesp
|
|
|
79
109
|
export declare function payments(options: PaymentsOptions): PaymentsCapability;
|
|
80
110
|
/** Whether a capability is the payments capability — carries its resolved catalog. */
|
|
81
111
|
export declare function isPaymentsCapability(capability: Capability): capability is PaymentsCapability;
|
|
112
|
+
export {};
|
|
82
113
|
//# sourceMappingURL=capability.d.ts.map
|
package/dist/capability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAEvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAI3E,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAoB,MAAM,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FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { PaymentsConfig } from "./config/config.js";
|
|
3
|
+
import { PaymentsConfig, reportedProducts } from "./config/config.js";
|
|
4
4
|
import { paymentsTables } from "./data/tables.js";
|
|
5
|
+
import { paymentsUsageMeter } from "./entitlement/meter.js";
|
|
5
6
|
import { installEntitlementResolver } from "./entitlement/resolver.js";
|
|
6
7
|
import { requireImplementedSubject } from "./entitlement/unimplementedSubject.js";
|
|
7
8
|
import { paymentsManifestConfig } from "./http/manifestConfig.js";
|
|
8
9
|
import { paymentsSecretsRegistry } from "./secret/registry.js";
|
|
9
|
-
import { paymentsWorkflows } from "./workflows/specs.js";
|
|
10
|
+
import { paymentsUsageWorkflows, paymentsWorkflows } from "./workflows/specs.js";
|
|
10
11
|
import { paymentsAdminRoutes } from "./http/scopes.js";
|
|
11
12
|
import { registerPaymentsRoutes } from "./http/routes.js";
|
|
12
13
|
import { payments_0001_purchases } from "./migrations/0001_purchases.js";
|
|
14
|
+
import { payments_0002_allowances } from "./migrations/0002_allowances.js";
|
|
13
15
|
import { paymentsPeer } from "./peer.js";
|
|
14
16
|
import { paymentsInapplicableSecrets, paymentsSecretBranches } from "./secret/branches.js";
|
|
15
17
|
import { paymentsExampleSeed } from "./seeds/example.js";
|
|
@@ -120,6 +122,24 @@ function requireResolvableSubject(config, resolveSubject) {
|
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
/**
|
|
125
|
+
* Refuse a catalog that bills by a reported quantity and gives payments nothing to ask.
|
|
126
|
+
*
|
|
127
|
+
* The same shape as {@link requireResolvableSubject}, and the same reasoning: the fault is total and the
|
|
128
|
+
* evidence is in hand. A quantity-billed subscription with no resolver is a subscription that bills nothing
|
|
129
|
+
* for what the customer is using, every period, and nothing anywhere fails — the store simply never hears a
|
|
130
|
+
* number. So it is refused here, naming every product it would happen to.
|
|
131
|
+
*/
|
|
132
|
+
function requireQuantityResolver(config, resolveQuantity) {
|
|
133
|
+
if (resolveQuantity !== void 0) return;
|
|
134
|
+
const reported = reportedProducts(config);
|
|
135
|
+
if (reported.length === 0) return;
|
|
136
|
+
throw new ValidationError({
|
|
137
|
+
message: `This catalog bills ${products(reported)} by a reported quantity, and nothing can say how many.`,
|
|
138
|
+
action: "Pass `resolveQuantity` to `payments(...)` in this Worker's pithy.config.ts, or drop `billing` from those products.",
|
|
139
|
+
detail: `Products with \`billing.kind: "reported"\`: ${reported.map((entry) => entry.id).join(", ")}. Payments never counts members itself, so without a resolver no count is ever reported and the store bills nothing.`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
123
143
|
* What a browser may know about this project's payments — the `virtual:pithy/payments` module.
|
|
124
144
|
*
|
|
125
145
|
* The list is short and each entry earns its place. **Enabled rails**, so a paywall can show an Apple-only
|
|
@@ -182,7 +202,16 @@ function clientProjection(config, environment) {
|
|
|
182
202
|
environment: config.paddle.environment,
|
|
183
203
|
checkout: config.paddle.checkout
|
|
184
204
|
},
|
|
185
|
-
products
|
|
205
|
+
products,
|
|
206
|
+
entitlements: Object.fromEntries(Object.entries(config.entitlements).map(([key, declaration]) => [key, {
|
|
207
|
+
name: declaration.name,
|
|
208
|
+
quotas: { ...declaration.quotas },
|
|
209
|
+
features: { ...declaration.features }
|
|
210
|
+
}])),
|
|
211
|
+
defaults: config.defaults === void 0 ? null : {
|
|
212
|
+
quotas: { ...config.defaults.quotas },
|
|
213
|
+
features: { ...config.defaults.features }
|
|
214
|
+
}
|
|
186
215
|
};
|
|
187
216
|
}
|
|
188
217
|
/**
|
|
@@ -211,19 +240,31 @@ function clientProjection(config, environment) {
|
|
|
211
240
|
* {@link requireResolvableSubject}.
|
|
212
241
|
*/
|
|
213
242
|
function payments(options) {
|
|
214
|
-
const { resolveSubject, ...catalog } = options;
|
|
243
|
+
const { resolveSubject, resolveQuantity, ...catalog } = options;
|
|
215
244
|
const resolved = PaymentsConfig.parse(catalog);
|
|
216
245
|
requireResolvableSubject(resolved, resolveSubject);
|
|
246
|
+
requireQuantityResolver(resolved, resolveQuantity);
|
|
217
247
|
const subject = {
|
|
218
248
|
billingSubject: resolved.billingSubject,
|
|
219
249
|
...resolveSubject ? { resolveSubject } : {}
|
|
220
250
|
};
|
|
251
|
+
const allowances = {
|
|
252
|
+
declarations: resolved,
|
|
253
|
+
meters: resolved.meters
|
|
254
|
+
};
|
|
221
255
|
const peers = { ledger: void 0 };
|
|
222
|
-
const migrations = {
|
|
256
|
+
const migrations = {
|
|
257
|
+
"0001_purchases": payments_0001_purchases,
|
|
258
|
+
"0002_allowances": payments_0002_allowances
|
|
259
|
+
};
|
|
260
|
+
const workflows = reportedProducts(resolved).length > 0 ? {
|
|
261
|
+
...paymentsWorkflows,
|
|
262
|
+
...paymentsUsageWorkflows
|
|
263
|
+
} : paymentsWorkflows;
|
|
223
264
|
const requiredBindings = [{
|
|
224
265
|
type: "d1",
|
|
225
266
|
name: "DB"
|
|
226
|
-
}, ...workflowBindings(
|
|
267
|
+
}, ...workflowBindings(workflows)];
|
|
227
268
|
const capability = defineCapability({
|
|
228
269
|
name: "payments",
|
|
229
270
|
version: PACKAGE_VERSION,
|
|
@@ -233,7 +274,7 @@ function payments(options) {
|
|
|
233
274
|
secretRegistry: paymentsSecretsRegistry,
|
|
234
275
|
secretBranches: paymentsSecretBranches(resolved.rails),
|
|
235
276
|
inapplicableSecrets: paymentsInapplicableSecrets(resolved.rails),
|
|
236
|
-
workflows
|
|
277
|
+
workflows,
|
|
237
278
|
compose: (context) => {
|
|
238
279
|
checkLedgerGrants(context, resolved);
|
|
239
280
|
peers.ledger = composedLedger(context.capabilities);
|
|
@@ -248,7 +289,7 @@ function payments(options) {
|
|
|
248
289
|
migrationOrder: PAYMENTS_MIGRATION_ORDER,
|
|
249
290
|
migrations
|
|
250
291
|
} },
|
|
251
|
-
middleware: [installEntitlementResolver(PAYMENTS_DATABASE_NAME, subject)],
|
|
292
|
+
middleware: [installEntitlementResolver(PAYMENTS_DATABASE_NAME, subject, allowances)],
|
|
252
293
|
adminRoutes: paymentsAdminRoutes(resolved.basePath),
|
|
253
294
|
manifestConfig: paymentsManifestConfig(resolved.billingSubject),
|
|
254
295
|
routes: registerPaymentsRoutes({
|
|
@@ -260,7 +301,9 @@ function payments(options) {
|
|
|
260
301
|
});
|
|
261
302
|
return Object.assign(capability, {
|
|
262
303
|
paymentsConfig: resolved,
|
|
263
|
-
paymentsPeer
|
|
304
|
+
paymentsPeer,
|
|
305
|
+
usageMeter: paymentsUsageMeter(allowances, "DB"),
|
|
306
|
+
paymentsUsage: resolveQuantity === void 0 ? void 0 : { resolveQuantity }
|
|
264
307
|
});
|
|
265
308
|
}
|
|
266
309
|
/** Whether a capability is the payments capability — carries its resolved catalog. */
|
package/dist/client/api.d.ts
CHANGED
|
@@ -310,6 +310,25 @@ export declare function isPurchaseView(value: unknown): value is PurchaseView;
|
|
|
310
310
|
* dragging the Worker's schema graph in behind it would break their build.
|
|
311
311
|
*/
|
|
312
312
|
export declare function callPayments<T>(path: string, init: PaymentsRequestInit, options: PaymentsClientOptions | undefined, guard: (value: unknown) => value is T): Promise<PaymentsResult<T>>;
|
|
313
|
+
/**
|
|
314
|
+
* What the caller's holder may have, as `GET /payments/entitlements` resolves it: every declared quota (a
|
|
315
|
+
* whole number, or null for unlimited) and every declared feature. **A UX affordance, never a security
|
|
316
|
+
* boundary** — a paywall shows "3 of 10 seats", and the server is what refuses the eleventh.
|
|
317
|
+
*/
|
|
318
|
+
export interface AllowancesView {
|
|
319
|
+
/** Quotas by name. `null` is unlimited. */
|
|
320
|
+
quotas: Readonly<Record<string, number | null>>;
|
|
321
|
+
/** Features by name. */
|
|
322
|
+
features: Readonly<Record<string, boolean>>;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* The caller's resolved allowances. The client-side reading of `quota(c, name)` and `feature(c, name)`, for a
|
|
326
|
+
* paywall screen — never the enforcement, which the server does.
|
|
327
|
+
*
|
|
328
|
+
* A Worker that predates declarations answers no allowances, and that is a failure here rather than an empty
|
|
329
|
+
* map: an empty map reads as *zero of everything*, and a screen would tell a paying customer they have none.
|
|
330
|
+
*/
|
|
331
|
+
export declare function getAllowances(options?: PaymentsClientOptions): Promise<PaymentsResult<AllowancesView>>;
|
|
313
332
|
/**
|
|
314
333
|
* The caller's own entitlements. Always the caller's — the id comes from the session, never from here.
|
|
315
334
|
*
|
package/dist/client/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,CAAC;AAE3F;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAAyC,CAAC;AAEzG,6FAA6F;AAC7F,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjE,+FAA+F;AAC/F,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAM7D;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,IAAI,EAAE,QAAQ,CAAC;IACf,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;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