@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.
Files changed (180) hide show
  1. package/README.md +10 -3
  2. package/dist/admin/coverage.d.ts.map +1 -1
  3. package/dist/admin/coverage.js +26 -2
  4. package/dist/admin/read.d.ts +48 -1
  5. package/dist/admin/read.d.ts.map +1 -1
  6. package/dist/admin/read.js +89 -2
  7. package/dist/audit/actions.d.ts +13 -0
  8. package/dist/audit/actions.d.ts.map +1 -1
  9. package/dist/audit/actions.js +14 -1
  10. package/dist/capability.d.ts +33 -2
  11. package/dist/capability.d.ts.map +1 -1
  12. package/dist/capability.js +52 -9
  13. package/dist/client/api.d.ts +19 -0
  14. package/dist/client/api.d.ts.map +1 -1
  15. package/dist/client/api.js +34 -1
  16. package/dist/client/hooks.d.ts +20 -1
  17. package/dist/client/hooks.d.ts.map +1 -1
  18. package/dist/client/hooks.js +40 -2
  19. package/dist/client/projection.d.ts +29 -0
  20. package/dist/client/projection.d.ts.map +1 -1
  21. package/dist/config/allowances.d.ts +71 -0
  22. package/dist/config/allowances.d.ts.map +1 -0
  23. package/dist/config/allowances.js +115 -0
  24. package/dist/config/config.d.ts +155 -9
  25. package/dist/config/config.d.ts.map +1 -1
  26. package/dist/config/config.js +164 -14
  27. package/dist/data/meterCounter.d.ts +34 -0
  28. package/dist/data/meterCounter.d.ts.map +1 -0
  29. package/dist/data/meterCounter.js +33 -0
  30. package/dist/data/override.d.ts +56 -0
  31. package/dist/data/override.d.ts.map +1 -0
  32. package/dist/data/override.js +58 -0
  33. package/dist/data/period.d.ts +10 -0
  34. package/dist/data/period.d.ts.map +1 -0
  35. package/dist/data/period.js +37 -0
  36. package/dist/data/purchase.d.ts +2 -1
  37. package/dist/data/purchase.d.ts.map +1 -1
  38. package/dist/data/purchase.js +1 -0
  39. package/dist/data/tables.d.ts +17 -1
  40. package/dist/data/tables.d.ts.map +1 -1
  41. package/dist/data/tables.js +24 -4
  42. package/dist/data/usageReport.d.ts +68 -0
  43. package/dist/data/usageReport.d.ts.map +1 -0
  44. package/dist/data/usageReport.js +55 -0
  45. package/dist/data/usageRun.d.ts +77 -0
  46. package/dist/data/usageRun.d.ts.map +1 -0
  47. package/dist/data/usageRun.js +50 -0
  48. package/dist/data/webhookEvent.d.ts +1 -1
  49. package/dist/entitlement/allowance.d.ts +100 -0
  50. package/dist/entitlement/allowance.d.ts.map +1 -0
  51. package/dist/entitlement/allowance.js +171 -0
  52. package/dist/entitlement/manual.d.ts +5 -5
  53. package/dist/entitlement/manual.js +3 -3
  54. package/dist/entitlement/meter.d.ts +98 -0
  55. package/dist/entitlement/meter.d.ts.map +1 -0
  56. package/dist/entitlement/meter.js +177 -0
  57. package/dist/entitlement/override.d.ts +119 -0
  58. package/dist/entitlement/override.d.ts.map +1 -0
  59. package/dist/entitlement/override.js +256 -0
  60. package/dist/entitlement/resolver.d.ts +2 -1
  61. package/dist/entitlement/resolver.d.ts.map +1 -1
  62. package/dist/entitlement/resolver.js +32 -1
  63. package/dist/error/errors.d.ts +23 -3
  64. package/dist/error/errors.d.ts.map +1 -1
  65. package/dist/error/errors.js +35 -2
  66. package/dist/http/responses.d.ts +367 -0
  67. package/dist/http/responses.d.ts.map +1 -1
  68. package/dist/http/responses.js +146 -7
  69. package/dist/http/routes.d.ts.map +1 -1
  70. package/dist/http/routes.js +270 -16
  71. package/dist/http/schemas.d.ts +54 -0
  72. package/dist/http/schemas.d.ts.map +1 -1
  73. package/dist/http/schemas.js +61 -2
  74. package/dist/http/scopes.d.ts +25 -0
  75. package/dist/http/scopes.d.ts.map +1 -1
  76. package/dist/http/scopes.js +60 -1
  77. package/dist/http/view.d.ts +22 -4
  78. package/dist/http/view.d.ts.map +1 -1
  79. package/dist/http/view.js +88 -7
  80. package/dist/index.d.ts +2 -1
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +3 -2
  83. package/dist/migrations/0002_allowances.d.ts +26 -0
  84. package/dist/migrations/0002_allowances.d.ts.map +1 -0
  85. package/dist/migrations/0002_allowances.js +62 -0
  86. package/dist/peer.d.ts +2 -1
  87. package/dist/peer.d.ts.map +1 -1
  88. package/dist/projection/event.d.ts +1 -0
  89. package/dist/projection/event.d.ts.map +1 -1
  90. package/dist/projection/event.js +1 -0
  91. package/dist/projection/writer.d.ts.map +1 -1
  92. package/dist/projection/writer.js +3 -1
  93. package/dist/rails/contract.d.ts +6 -0
  94. package/dist/rails/contract.d.ts.map +1 -1
  95. package/dist/rails/google/playApi.d.ts.map +1 -1
  96. package/dist/rails/google/playApi.js +2 -0
  97. package/dist/rails/paddle/objects.d.ts +2 -0
  98. package/dist/rails/paddle/objects.d.ts.map +1 -1
  99. package/dist/rails/paddle/objects.js +7 -2
  100. package/dist/rails/paddle/usage.d.ts +11 -0
  101. package/dist/rails/paddle/usage.d.ts.map +1 -0
  102. package/dist/rails/paddle/usage.js +49 -0
  103. package/dist/rails/quantity.d.ts +12 -0
  104. package/dist/rails/quantity.d.ts.map +1 -0
  105. package/dist/rails/quantity.js +16 -0
  106. package/dist/rails/stripe/checkout.d.ts.map +1 -1
  107. package/dist/rails/stripe/checkout.js +1 -1
  108. package/dist/rails/stripe/objects.d.ts.map +1 -1
  109. package/dist/rails/stripe/objects.js +3 -0
  110. package/dist/rails/stripe/usage.d.ts +10 -0
  111. package/dist/rails/stripe/usage.d.ts.map +1 -0
  112. package/dist/rails/stripe/usage.js +49 -0
  113. package/dist/usage/pass.d.ts +120 -0
  114. package/dist/usage/pass.d.ts.map +1 -0
  115. package/dist/usage/pass.js +363 -0
  116. package/dist/usage/reporter.d.ts +36 -0
  117. package/dist/usage/reporter.d.ts.map +1 -0
  118. package/dist/usage/reporter.js +2 -0
  119. package/dist/version.generated.d.ts +1 -1
  120. package/dist/version.generated.js +1 -1
  121. package/dist/workflows/report.d.ts.map +1 -1
  122. package/dist/workflows/specs.d.ts +28 -0
  123. package/dist/workflows/specs.d.ts.map +1 -1
  124. package/dist/workflows/specs.js +26 -1
  125. package/dist/workflows/usage.d.ts +38 -0
  126. package/dist/workflows/usage.d.ts.map +1 -0
  127. package/dist/workflows/usage.js +77 -0
  128. package/dist/workflows/worker.js +2 -2
  129. package/docs/entitlements.md +249 -0
  130. package/docs/lemon-squeezy.md +1 -0
  131. package/docs/paddle.md +1 -0
  132. package/package.json +5 -5
  133. package/pithy.manifest.json +3 -8
  134. package/src/admin/coverage.ts +28 -0
  135. package/src/admin/read.ts +173 -1
  136. package/src/audit/actions.ts +13 -0
  137. package/src/capability.ts +87 -9
  138. package/src/client/api.ts +44 -0
  139. package/src/client/hooks.ts +44 -0
  140. package/src/client/projection.ts +31 -0
  141. package/src/config/allowances.ts +211 -0
  142. package/src/config/config.ts +283 -15
  143. package/src/data/meterCounter.ts +38 -0
  144. package/src/data/override.ts +74 -0
  145. package/src/data/period.ts +53 -0
  146. package/src/data/purchase.ts +9 -0
  147. package/src/data/tables.ts +25 -1
  148. package/src/data/usageReport.ts +64 -0
  149. package/src/data/usageRun.ts +66 -0
  150. package/src/entitlement/allowance.ts +213 -0
  151. package/src/entitlement/manual.ts +6 -6
  152. package/src/entitlement/meter.ts +252 -0
  153. package/src/entitlement/override.ts +381 -0
  154. package/src/entitlement/resolver.ts +43 -2
  155. package/src/error/errors.ts +48 -4
  156. package/src/http/responses.ts +305 -4
  157. package/src/http/routes.ts +365 -11
  158. package/src/http/schemas.ts +139 -1
  159. package/src/http/scopes.ts +68 -0
  160. package/src/http/view.ts +112 -7
  161. package/src/index.ts +18 -0
  162. package/src/migrations/0002_allowances.ts +149 -0
  163. package/src/projection/event.ts +9 -0
  164. package/src/projection/writer.ts +4 -0
  165. package/src/rails/contract.ts +6 -0
  166. package/src/rails/google/playApi.ts +2 -0
  167. package/src/rails/paddle/fixtures/subscription-charge.json +19 -0
  168. package/src/rails/paddle/objects.ts +6 -0
  169. package/src/rails/paddle/usage.ts +66 -0
  170. package/src/rails/quantity.ts +14 -0
  171. package/src/rails/stripe/checkout.ts +3 -1
  172. package/src/rails/stripe/fixtures/meter-event-created.json +12 -0
  173. package/src/rails/stripe/objects.ts +4 -0
  174. package/src/rails/stripe/usage.ts +61 -0
  175. package/src/usage/pass.ts +539 -0
  176. package/src/usage/reporter.ts +38 -0
  177. package/src/version.generated.ts +1 -1
  178. package/src/workflows/report.ts +4 -2
  179. package/src/workflows/specs.ts +34 -0
  180. package/src/workflows/usage.ts +97 -0
@@ -266,6 +266,39 @@ function jsonPost(body) {
266
266
  function isEntitlementsBody(value) {
267
267
  return isRecord(value) && isArrayOf(value.entitlements, isEntitlementView);
268
268
  }
269
+ /** Whether a value is a map whose every value passes `guard`. */
270
+ function isMapOf(value, guard) {
271
+ return isRecord(value) && Object.values(value).every(guard);
272
+ }
273
+ /** A quota on the wire: a whole number from 0, or null. */
274
+ function isQuota(value) {
275
+ return value === null || typeof value === "number" && Number.isInteger(value) && value >= 0;
276
+ }
277
+ /** A feature on the wire. */
278
+ function isSwitch(value) {
279
+ return typeof value === "boolean";
280
+ }
281
+ /** Whether a value is the entitlements envelope from a Worker that resolves allowances. */
282
+ function isAllowancesBody(value) {
283
+ return isRecord(value) && isMapOf(value.quotas, isQuota) && isMapOf(value.features, isSwitch);
284
+ }
285
+ /**
286
+ * The caller's resolved allowances. The client-side reading of `quota(c, name)` and `feature(c, name)`, for a
287
+ * paywall screen — never the enforcement, which the server does.
288
+ *
289
+ * A Worker that predates declarations answers no allowances, and that is a failure here rather than an empty
290
+ * map: an empty map reads as *zero of everything*, and a screen would tell a paying customer they have none.
291
+ */
292
+ async function getAllowances(options) {
293
+ const result = await callPayments("/entitlements", {}, options, isAllowancesBody);
294
+ return result.ok ? {
295
+ ok: true,
296
+ value: {
297
+ quotas: result.value.quotas,
298
+ features: result.value.features
299
+ }
300
+ } : result;
301
+ }
269
302
  /** Whether a value is the purchase envelope both write routes' single-purchase form returns. */
270
303
  function isPurchaseBody(value) {
271
304
  return isRecord(value) && isPurchaseView(value.purchase) && isArrayOf(value.entitlements, isEntitlementView);
@@ -439,4 +472,4 @@ function returnedCheckoutSession(options) {
439
472
  return value === null || value === "" ? null : value;
440
473
  }
441
474
  //#endregion
442
- export { CHECKOUT_SESSION_PARAM, PAYMENTS_BASE_PATH, PAYMENTS_HOSTED_RAILS, PAYMENTS_NO_BROWSER, PAYMENTS_UNREACHABLE, PAYMENTS_UNREADABLE, STORE_SUBSCRIPTION_URLS, callPayments, createCheckout, createPortal, getEntitlements, isEntitlementView, isPurchaseView, openBillingPortal, openStoreSubscriptions, restorePurchases, resumeCheckout, returnedCheckoutSession, startCheckout, submitPurchase };
475
+ export { CHECKOUT_SESSION_PARAM, PAYMENTS_BASE_PATH, PAYMENTS_HOSTED_RAILS, PAYMENTS_NO_BROWSER, PAYMENTS_UNREACHABLE, PAYMENTS_UNREADABLE, STORE_SUBSCRIPTION_URLS, callPayments, createCheckout, createPortal, getAllowances, getEntitlements, isEntitlementView, isPurchaseView, openBillingPortal, openStoreSubscriptions, restorePurchases, resumeCheckout, returnedCheckoutSession, startCheckout, submitPurchase };
@@ -1,6 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { type EntitlementView, type PaddleCheckoutHandoff, type PaymentsClientOptions, type PaymentsClientRail, type PaymentsFailure, type PaymentsHostedRail, type PurchaseView } from "./api";
3
+ import { type AllowancesView, type EntitlementView, type PaddleCheckoutHandoff, type PaymentsClientOptions, type PaymentsClientRail, type PaymentsFailure, type PaymentsHostedRail, type PurchaseView } from "./api";
4
4
  import { type PaddleCheckoutOptions } from "./checkout";
5
5
  import { type PaddleJs, type PaddleOptions, type PaddlePriceQuery, type PaddleSetup, type PricePreview } from "./paddle";
6
6
  /** What {@link useEntitlement} gives a screen. */
@@ -32,6 +32,25 @@ export interface UseEntitlement {
32
32
  * plan instead of locking it must not inherit this choice; see {@link useSubscription}.
33
33
  */
34
34
  export declare function useEntitlement(key: string, options?: PaymentsClientOptions): UseEntitlement;
35
+ /** What {@link useAllowances} gives a paywall screen. */
36
+ export interface UseAllowances {
37
+ /** The caller's resolved quotas and features, or null until a read has landed. Never guessed. */
38
+ allowances: AllowancesView | null;
39
+ /** Whether a read is in flight. */
40
+ loading: boolean;
41
+ /** Why the last read could not be made, or null. `allowances` keeps its last answer while this is set. */
42
+ readFailure: PaymentsFailure | null;
43
+ /** Re-read. Call it after a purchase or an upgrade completes. */
44
+ refresh: () => void;
45
+ }
46
+ /**
47
+ * What the caller's holder may have — "3 of 10 seats", "SSO included" — for a screen to show.
48
+ *
49
+ * **Null until it knows, never zero.** A paywall that rendered `0 of 0` from a read still in flight would tell
50
+ * a paying customer they have nothing. And it is a UX affordance, never a boundary: the server's `quota()` and
51
+ * the kit's meters are what refuse.
52
+ */
53
+ export declare function useAllowances(options?: PaymentsClientOptions): UseAllowances;
35
54
  /** What {@link useSubscription} gives a subscription screen. */
36
55
  export interface UseSubscription {
37
56
  /** Every entitlement the caller holds, as the server resolved it. */
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/client/hooks.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,eAAe,EAIpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAKlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EAGlB,MAAM,UAAU,CAAC;AA2DlB,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,QAAQ,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,WAAW,EAAE,eAAe,GAAG,IAAI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Y,GAAG,IAAI,CAAC;IAC7B,8FAA8F;IAC9F,OAAO,EAAE,OAAO,CAAC;IACjB,qDAAqD;IACrD,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,iBAAiB;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,eAAe,CA+CjB"}
@@ -1,6 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { getEntitlements, openBillingPortal, openStoreSubscriptions, restorePurchases, resumeCheckout, startCheckout, submitPurchase } from "./api.js";
3
+ import { getAllowances, getEntitlements, openBillingPortal, openStoreSubscriptions, restorePurchases, resumeCheckout, startCheckout, submitPurchase } from "./api.js";
4
4
  import { loadPaddle, previewPrices, priceQueryKey } from "./paddle.js";
5
5
  import { openPaddleCheckout } from "./checkout.js";
6
6
  import { readPaddleLinkTransaction } from "./paddleLink.js";
@@ -103,6 +103,44 @@ function useEntitlement(key, options) {
103
103
  };
104
104
  }
105
105
  /**
106
+ * What the caller's holder may have — "3 of 10 seats", "SSO included" — for a screen to show.
107
+ *
108
+ * **Null until it knows, never zero.** A paywall that rendered `0 of 0` from a read still in flight would tell
109
+ * a paying customer they have nothing. And it is a UX affordance, never a boundary: the server's `quota()` and
110
+ * the kit's meters are what refuse.
111
+ */
112
+ function useAllowances(options) {
113
+ const [allowances, setAllowances] = useState(null);
114
+ const [loading, setLoading] = useState(true);
115
+ const [readFailure, setReadFailure] = useState(null);
116
+ const latest = useLatest(options);
117
+ const live = useLive();
118
+ const basePath = options?.basePath;
119
+ const refresh = useCallback(() => {
120
+ setLoading(true);
121
+ getAllowances({
122
+ ...latest.current,
123
+ basePath
124
+ }).then((result) => {
125
+ if (!live.current) return;
126
+ if (result.ok) setAllowances(result.value);
127
+ setReadFailure(result.ok ? null : result.failure);
128
+ setLoading(false);
129
+ });
130
+ }, [
131
+ basePath,
132
+ latest,
133
+ live
134
+ ]);
135
+ useEffect(refresh, [refresh]);
136
+ return {
137
+ allowances,
138
+ loading,
139
+ readFailure,
140
+ refresh
141
+ };
142
+ }
143
+ /**
106
144
  * The caller's standing entitlements, and the one action a subscriber needs.
107
145
  *
108
146
  * Managing a subscription is the store's job, not Pithy's — Stripe's Billing Portal owns cancellation,
@@ -483,4 +521,4 @@ function usePricePreview(setup, query, options) {
483
521
  };
484
522
  }
485
523
  //#endregion
486
- export { useCheckout, useEntitlement, usePaddle, usePaddleCheckout, usePaddleLink, usePricePreview, usePurchase, useSubscription };
524
+ export { useAllowances, useCheckout, useEntitlement, usePaddle, usePaddleCheckout, usePaddleLink, usePricePreview, usePurchase, useSubscription };
@@ -38,6 +38,22 @@ export type PaymentsClientProduct = {
38
38
  paddle: string | null;
39
39
  };
40
40
  };
41
+ /** Numbered allowances and switches, as a browser reads them. */
42
+ export type PaymentsClientAllowances = {
43
+ /** Quotas by name: a whole number, or null for unlimited. */
44
+ quotas: Record<string, number | null>;
45
+ /** Features by name. */
46
+ features: Record<string, boolean>;
47
+ };
48
+ /** One declared entitlement key, browser-safe: what it is called and what it buys. */
49
+ export type PaymentsClientEntitlement = {
50
+ /** The tier's display name — `Growth`. Not translated: it is a product name. */
51
+ name: string;
52
+ /** Quotas by name: a whole number, or null for unlimited. */
53
+ quotas: Record<string, number | null>;
54
+ /** Features by name. */
55
+ features: Record<string, boolean>;
56
+ };
41
57
  /**
42
58
  * What a browser may know about this project's payments — the shape of `virtual:pithy/payments`.
43
59
  *
@@ -126,5 +142,18 @@ export type PaymentsClientProjection = {
126
142
  * purchase fulfills beyond its entitlements, stay server-side.
127
143
  */
128
144
  products: PaymentsClientProduct[];
145
+ /**
146
+ * What each entitlement key buys, keyed by the key — its display name, its quotas (a whole number,
147
+ * or null for unlimited) and its features — so a paywall can lay tiers side by side. What the
148
+ * caller's own holder resolves to is `GET {basePath}/entitlements`. A UX affordance, never a
149
+ * security boundary: the server enforces every number here. The ceilings an operator's override is
150
+ * bounded by stay server-side.
151
+ */
152
+ entitlements: {
153
+ /** One declared key, by the key. */
154
+ [key: string]: PaymentsClientEntitlement;
155
+ };
156
+ /** What a caller holding no key gets — the free floor — or null when none is declared. */
157
+ defaults: PaymentsClientAllowances | null;
129
158
  };
130
159
  //# sourceMappingURL=projection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/client/projection.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,EAAE,YAAY,GAAG,gBAAgB,GAAG,cAAc,CAAC;IACvD,kFAAkF;IAClF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,IAAI,EAAE;QACJ,2BAA2B;QAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,oCAAoC;QACpC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,2BAA2B;QAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,wBAAwB,GAChC;IACE;;;;OAIG;IACH,OAAO,EAAE,KAAK,CAAC;CAChB,GACD;IACE,0EAA0E;IAC1E,OAAO,EAAE,IAAI,CAAC;IACd,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,EAAE;QACL,mEAAmE;QACnE,KAAK,EAAE,OAAO,CAAC;QACf,oEAAoE;QACpE,MAAM,EAAE,OAAO,CAAC;Q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AC;KAC1C,CAAC;IACF,0FAA0F;IAC1F,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC3C,CAAC"}
@@ -0,0 +1,71 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ /**
5
+ * A quota or feature name — `emails`, `seats`, `auditExport`. camelCase or snake_case, starting with a
6
+ * lowercase letter, because it is an identifier code names and never copy a screen renders.
7
+ */
8
+ export declare const AllowanceName: z.ZodString;
9
+ export type AllowanceName = z.infer<typeof AllowanceName>;
10
+ /**
11
+ * One quota's value: a whole number of things, or `null` for unlimited. Never a float, never negative,
12
+ * never a string — a number that costs money to serve is not something to coerce.
13
+ */
14
+ export declare const QuotaValue: z.ZodNullable<z.ZodNumber>;
15
+ export type QuotaValue = z.infer<typeof QuotaValue>;
16
+ /** A ceiling an operator's override may not pass. A whole number, and never unlimited — that is not a ceiling. */
17
+ export declare const OverrideCeiling: z.ZodNumber;
18
+ export type OverrideCeiling = z.infer<typeof OverrideCeiling>;
19
+ /** A quota map: name → whole number or unlimited. */
20
+ export declare const QuotaMap: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>;
21
+ export type QuotaMap = z.infer<typeof QuotaMap>;
22
+ /** A feature map: name → on or off. */
23
+ export declare const FeatureMap: z.ZodRecord<z.ZodString, z.ZodBoolean>;
24
+ export type FeatureMap = z.infer<typeof FeatureMap>;
25
+ export declare const PaymentsEntitlementDeclaration: z.ZodObject<{
26
+ name: z.ZodString;
27
+ quotas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
28
+ features: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
29
+ overrideMax: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
30
+ }, z.core.$strip>;
31
+ export type PaymentsEntitlementDeclaration = z.output<typeof PaymentsEntitlementDeclaration>;
32
+ export type PaymentsEntitlementDeclarationInput = z.input<typeof PaymentsEntitlementDeclaration>;
33
+ export declare const PaymentsAllowanceDefaults: z.ZodObject<{
34
+ quotas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
35
+ features: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
36
+ }, z.core.$strip>;
37
+ export type PaymentsAllowanceDefaults = z.output<typeof PaymentsAllowanceDefaults>;
38
+ /** The slice of a parsed config the derivations below read. Structural, so a test needs no full catalog. */
39
+ export interface AllowanceDeclarations {
40
+ /** Every declared entitlement key and what it buys. */
41
+ entitlements: Readonly<Record<string, PaymentsEntitlementDeclaration>>;
42
+ /** The free floor, when declared. */
43
+ defaults?: PaymentsAllowanceDefaults | undefined;
44
+ }
45
+ /**
46
+ * Every quota name this project declares, on any key or on the floor, sorted.
47
+ *
48
+ * Derived, never written down, the way the set of grantable keys is derived from the products — a second
49
+ * list of names would be a list that disagrees with the declarations the first time one is added.
50
+ */
51
+ export declare function declaredQuotaNames(declarations: AllowanceDeclarations): string[];
52
+ /** Every feature name this project declares, on any key or on the floor, sorted. */
53
+ export declare function declaredFeatureNames(declarations: AllowanceDeclarations): string[];
54
+ /**
55
+ * The problems with a set of declarations, as sentences, each with the path it belongs at.
56
+ *
57
+ * Separate from the schema so `PaymentsConfig`'s check can report every one at once, beside the catalog
58
+ * problems it already reports, and so each rule is testable on its own.
59
+ */
60
+ export interface DeclarationProblem {
61
+ /** Where in the config the problem is. */
62
+ path: (string | number)[];
63
+ /** The sentence. Names the key and the name. */
64
+ message: string;
65
+ }
66
+ /**
67
+ * Check the rules a schema cannot state field by field: a name that is a quota on one key and a feature on
68
+ * another, and an `overrideMax` that names an undeclared quota or sits below the quota it bounds.
69
+ */
70
+ export declare function declarationProblems(declarations: AllowanceDeclarations): DeclarationProblem[];
71
+ //# sourceMappingURL=allowances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowances.d.ts","sourceRoot":"","sources":["../../src/config/allowances.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QAAQ,CAAC,EAAE,yBAAyB,GAAG,SAAS,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAMhF;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAMlF;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1B,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,qBAAqB,GAAG,kBAAkB,EAAE,CAmC7F"}
@@ -0,0 +1,115 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { z } from "zod";
4
+ //#region src/config/allowances.ts
5
+ /**
6
+ * What an entitlement buys: a display name, numbered allowances, and switches. Declared once per key.
7
+ *
8
+ * A key is the thing gating code names and the thing a product mentions — `growth` — and until this
9
+ * existed it was declared nowhere. It was only ever *mentioned*, in the array a product grants and in a
10
+ * second list of comp-only keys, and those two could disagree about the same key with no answer for which
11
+ * won. There was also nowhere to write what a key buys: "up to 25 students" could gate on the key and
12
+ * could not tell 25 from 26.
13
+ *
14
+ * **The declaration hangs on the key, not on the product, because a tier is sold by more than one
15
+ * product.** `growth_monthly` and `growth_annual` are two SKUs on two rails for one tier. Writing the
16
+ * numbers on the product writes them twice and reconciles them forever.
17
+ *
18
+ * **Two maps, not one.** A single `limits: { emails: 5000, sso: true }` reads well and answers
19
+ * `number | boolean | null`, and from there no caller can tell `0` from `false` from *nothing was
20
+ * declared* without writing the same narrowing every time. `quotas` holds integers and `null`, and
21
+ * `features` holds booleans, so each reader answers one type.
22
+ *
23
+ * **`null` is unlimited, and it is written, never inferred.** A quota a key does not mention is not
24
+ * unlimited for that key — it falls to `defaults`, then to `0`. Unlimited is a decision somebody wrote
25
+ * down, because a paywall that silently does not exist is invisible until the invoice.
26
+ */
27
+ /** The longest an allowance name may be. Long enough to read, short enough to sit in an audit row. */
28
+ const MAX_ALLOWANCE_NAME_LENGTH = 64;
29
+ /** The longest a declared tier name may be — the same bound a product's display name carries. */
30
+ const MAX_TIER_NAME_LENGTH = 120;
31
+ /**
32
+ * A quota or feature name — `emails`, `seats`, `auditExport`. camelCase or snake_case, starting with a
33
+ * lowercase letter, because it is an identifier code names and never copy a screen renders.
34
+ */
35
+ const AllowanceName = z.string().min(1).max(MAX_ALLOWANCE_NAME_LENGTH).regex(/^[a-z][A-Za-z0-9_]*$/, "An allowance name starts with a lowercase letter and holds only letters, digits, and underscores.").describe("A quota or feature name — `emails`, `seats`, `auditExport`. An identifier gating code reads, never display copy, and never translated.");
36
+ /**
37
+ * One quota's value: a whole number of things, or `null` for unlimited. Never a float, never negative,
38
+ * never a string — a number that costs money to serve is not something to coerce.
39
+ */
40
+ const QuotaValue = z.number().int("A quota is a whole number, or null for unlimited.").min(0, "A quota is never negative. Use 0 for none and null for unlimited.").nullable().describe("How many of a thing this grants: a whole number from 0, or null for unlimited.");
41
+ /** A ceiling an operator's override may not pass. A whole number, and never unlimited — that is not a ceiling. */
42
+ const OverrideCeiling = z.number().int("An override ceiling is a whole number.").min(0, "An override ceiling is never negative.").describe("The largest number an operator's override may set for this quota. A set past it is refused naming it, never clamped.");
43
+ /** A quota map: name → whole number or unlimited. */
44
+ const QuotaMap = z.record(AllowanceName, QuotaValue).describe("Numbered allowances by name. A whole number from 0, or null for unlimited.");
45
+ /** A feature map: name → on or off. */
46
+ const FeatureMap = z.record(AllowanceName, z.boolean().describe("Whether this switch is on.")).describe("Switches by name. A feature is read, never enforced: `false` denies nothing on its own.");
47
+ const PaymentsEntitlementDeclaration = z.object({
48
+ name: z.string().min(1).max(MAX_TIER_NAME_LENGTH).describe("The tier's display name — `Growth`. A product name, so it is not translated, the way a product's own name is not."),
49
+ quotas: QuotaMap.default({}).describe("What this key allows, by name — `{ emails: 5000, seats: 10 }`. A whole number from 0, or null for unlimited. Read with `quota(c, name)`, which resolves across every key the subject holds and answers the highest."),
50
+ features: FeatureMap.default({}).describe("The switches this key turns on or off, by name — `{ sso: true }`. Read with `feature(c, name)`, which is true when any held key says true. Never enforced on its own."),
51
+ overrideMax: z.record(AllowanceName, OverrideCeiling).optional().describe("Optional. Per quota, the largest number an operator's override may set — so `200000000` is refused where `20000` was meant. A quota with no ceiling accepts any whole number. Must name a quota this key declares, and must not sit below that quota's own value.")
52
+ }).describe("What one entitlement key buys: its display name, its numbered quotas, and its switches. Declared once, however many products sell it.");
53
+ const PaymentsAllowanceDefaults = z.object({
54
+ quotas: QuotaMap.default({}).describe("What a subject holding no key that speaks to a quota gets — the free floor. A name absent here resolves to 0."),
55
+ features: FeatureMap.default({}).describe("The switches a subject holding no key that speaks to them gets. A name absent here resolves to false.")
56
+ }).describe("The free floor: what a caller holding no key gets. Optional, and omitting it means an unentitled caller gets 0 of every quota and no feature.");
57
+ /**
58
+ * Every quota name this project declares, on any key or on the floor, sorted.
59
+ *
60
+ * Derived, never written down, the way the set of grantable keys is derived from the products — a second
61
+ * list of names would be a list that disagrees with the declarations the first time one is added.
62
+ */
63
+ function declaredQuotaNames(declarations) {
64
+ const names = new Set(Object.keys(declarations.defaults?.quotas ?? {}));
65
+ for (const declaration of Object.values(declarations.entitlements)) for (const name of Object.keys(declaration.quotas)) names.add(name);
66
+ return [...names].sort();
67
+ }
68
+ /** Every feature name this project declares, on any key or on the floor, sorted. */
69
+ function declaredFeatureNames(declarations) {
70
+ const names = new Set(Object.keys(declarations.defaults?.features ?? {}));
71
+ for (const declaration of Object.values(declarations.entitlements)) for (const name of Object.keys(declaration.features)) names.add(name);
72
+ return [...names].sort();
73
+ }
74
+ /**
75
+ * Check the rules a schema cannot state field by field: a name that is a quota on one key and a feature on
76
+ * another, and an `overrideMax` that names an undeclared quota or sits below the quota it bounds.
77
+ */
78
+ function declarationProblems(declarations) {
79
+ const problems = [];
80
+ const quotas = new Set(declaredQuotaNames(declarations));
81
+ for (const name of declaredFeatureNames(declarations)) {
82
+ if (!quotas.has(name)) continue;
83
+ problems.push({
84
+ path: ["entitlements"],
85
+ message: `"${name}" is declared as both a quota and a feature. A name is a number or a switch, never both. Rename one.`
86
+ });
87
+ }
88
+ for (const [key, declaration] of Object.entries(declarations.entitlements)) for (const [name, ceiling] of Object.entries(declaration.overrideMax ?? {})) {
89
+ if (!(name in declaration.quotas)) {
90
+ problems.push({
91
+ path: [
92
+ "entitlements",
93
+ key,
94
+ "overrideMax",
95
+ name
96
+ ],
97
+ message: `Entitlement "${key}" sets an overrideMax for "${name}", which it declares no quota for. A ceiling bounds a quota the key declares. Declared: ${Object.keys(declaration.quotas).sort().join(", ") || "none"}.`
98
+ });
99
+ continue;
100
+ }
101
+ const value = declaration.quotas[name];
102
+ if (value === null || value !== void 0 && ceiling < value) problems.push({
103
+ path: [
104
+ "entitlements",
105
+ key,
106
+ "overrideMax",
107
+ name
108
+ ],
109
+ message: `Entitlement "${key}" caps overrides of "${name}" at ${ceiling}, below the ${value === null ? "unlimited" : value} the plan itself grants. A ceiling under the plan would refuse an override the plan already allows.`
110
+ });
111
+ }
112
+ return problems;
113
+ }
114
+ //#endregion
115
+ export { AllowanceName, FeatureMap, OverrideCeiling, PaymentsAllowanceDefaults, PaymentsEntitlementDeclaration, QuotaMap, QuotaValue, declarationProblems, declaredFeatureNames, declaredQuotaNames };
@@ -1,7 +1,8 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { z } from "zod";
4
- import { type PaymentsRail } from "../data/rail";
4
+ import { PaymentsRail } from "../data/rail";
5
+ import { type DeclarationProblem } from "./allowances";
5
6
  export declare const PaymentsRailToggles: z.ZodObject<{
6
7
  apple: z.ZodDefault<z.ZodBoolean>;
7
8
  google: z.ZodDefault<z.ZodBoolean>;
@@ -77,6 +78,47 @@ export declare const PaymentsGrants: z.ZodObject<{
77
78
  }, z.core.$strip>>;
78
79
  }, z.core.$strip>;
79
80
  export type PaymentsGrants = z.infer<typeof PaymentsGrants>;
81
+ /**
82
+ * The rails a reported quantity can be billed on. Stripe takes a meter event; Paddle takes a one-time charge
83
+ * against the subscription. **Apple and Google cannot**: in-app purchase has no concept of a seat, so a
84
+ * quantity-billed product is web-rails-only and says so at boot.
85
+ *
86
+ * **Lemon Squeezy is deferred, with the reason recorded on pithy-sh/pithy#561.** Its usage records are
87
+ * written against a subscription *item*, which the projection does not store, so the same call shape does
88
+ * not fit without a new column and a refresh of every Lemon Squeezy subscription. Named here so the refusal
89
+ * can say so, rather than reading as an oversight.
90
+ */
91
+ export declare const REPORTED_BILLING_RAILS: readonly ["stripe", "paddle"];
92
+ /** How often a reported quantity goes to the store. */
93
+ export declare const PaymentsReportCadence: z.ZodEnum<{
94
+ "daily-peak": "daily-peak";
95
+ "period-end": "period-end";
96
+ }>;
97
+ export type PaymentsReportCadence = z.infer<typeof PaymentsReportCadence>;
98
+ export declare const PaymentsReportedBilling: z.ZodObject<{
99
+ kind: z.ZodLiteral<"reported">;
100
+ unit: z.ZodString;
101
+ cadence: z.ZodDefault<z.ZodEnum<{
102
+ "daily-peak": "daily-peak";
103
+ "period-end": "period-end";
104
+ }>>;
105
+ min: z.ZodDefault<z.ZodNumber>;
106
+ max: z.ZodNumber;
107
+ rails: z.ZodArray<z.ZodEnum<{
108
+ apple: "apple";
109
+ google: "google";
110
+ lemonSqueezy: "lemonSqueezy";
111
+ paddle: "paddle";
112
+ stripe: "stripe";
113
+ }>>;
114
+ stripe: z.ZodOptional<z.ZodObject<{
115
+ meterEventName: z.ZodString;
116
+ }, z.core.$strict>>;
117
+ paddle: z.ZodOptional<z.ZodObject<{
118
+ priceId: z.ZodString;
119
+ }, z.core.$strict>>;
120
+ }, z.core.$strict>;
121
+ export type PaymentsReportedBilling = z.output<typeof PaymentsReportedBilling>;
80
122
  export declare const PaymentsProduct: z.ZodObject<{
81
123
  type: z.ZodEnum<{
82
124
  consumable: "consumable";
@@ -106,9 +148,51 @@ export declare const PaymentsProduct: z.ZodObject<{
106
148
  amount: z.ZodNumber;
107
149
  }, z.core.$strip>>;
108
150
  }, z.core.$strip>>;
151
+ billing: z.ZodOptional<z.ZodObject<{
152
+ kind: z.ZodLiteral<"reported">;
153
+ unit: z.ZodString;
154
+ cadence: z.ZodDefault<z.ZodEnum<{
155
+ "daily-peak": "daily-peak";
156
+ "period-end": "period-end";
157
+ }>>;
158
+ min: z.ZodDefault<z.ZodNumber>;
159
+ max: z.ZodNumber;
160
+ rails: z.ZodArray<z.ZodEnum<{
161
+ apple: "apple";
162
+ google: "google";
163
+ lemonSqueezy: "lemonSqueezy";
164
+ paddle: "paddle";
165
+ stripe: "stripe";
166
+ }>>;
167
+ stripe: z.ZodOptional<z.ZodObject<{
168
+ meterEventName: z.ZodString;
169
+ }, z.core.$strict>>;
170
+ paddle: z.ZodOptional<z.ZodObject<{
171
+ priceId: z.ZodString;
172
+ }, z.core.$strict>>;
173
+ }, z.core.$strict>>;
109
174
  clawback: z.ZodDefault<z.ZodBoolean>;
110
175
  }, z.core.$strip>;
111
176
  export type PaymentsProduct = z.infer<typeof PaymentsProduct>;
177
+ /**
178
+ * The meters the kit counts itself, because the kit writes the rows they count. Everything the kit cannot
179
+ * see — seats, students, projects — is the adopter's count, read through `quota()`. Payments never counts
180
+ * members. Forever.
181
+ */
182
+ export declare const KIT_METERS: readonly ["emails", "storageBytes", "mediaItems"];
183
+ export type KitMeter = (typeof KIT_METERS)[number];
184
+ export declare const PaymentsMeters: z.ZodObject<{
185
+ emails: z.ZodOptional<z.ZodObject<{
186
+ enforce: z.ZodDefault<z.ZodBoolean>;
187
+ }, z.core.$strict>>;
188
+ storageBytes: z.ZodOptional<z.ZodObject<{
189
+ enforce: z.ZodDefault<z.ZodBoolean>;
190
+ }, z.core.$strict>>;
191
+ mediaItems: z.ZodOptional<z.ZodObject<{
192
+ enforce: z.ZodDefault<z.ZodBoolean>;
193
+ }, z.core.$strict>>;
194
+ }, z.core.$strict>;
195
+ export type PaymentsMeters = z.output<typeof PaymentsMeters>;
112
196
  export declare const PaymentsConfig: z.ZodObject<{
113
197
  billingSubject: z.ZodEnum<{
114
198
  organization: "organization";
@@ -150,9 +234,53 @@ export declare const PaymentsConfig: z.ZodObject<{
150
234
  amount: z.ZodNumber;
151
235
  }, z.core.$strip>>;
152
236
  }, z.core.$strip>>;
237
+ billing: z.ZodOptional<z.ZodObject<{
238
+ kind: z.ZodLiteral<"reported">;
239
+ unit: z.ZodString;
240
+ cadence: z.ZodDefault<z.ZodEnum<{
241
+ "daily-peak": "daily-peak";
242
+ "period-end": "period-end";
243
+ }>>;
244
+ min: z.ZodDefault<z.ZodNumber>;
245
+ max: z.ZodNumber;
246
+ rails: z.ZodArray<z.ZodEnum<{
247
+ apple: "apple";
248
+ google: "google";
249
+ lemonSqueezy: "lemonSqueezy";
250
+ paddle: "paddle";
251
+ stripe: "stripe";
252
+ }>>;
253
+ stripe: z.ZodOptional<z.ZodObject<{
254
+ meterEventName: z.ZodString;
255
+ }, z.core.$strict>>;
256
+ paddle: z.ZodOptional<z.ZodObject<{
257
+ priceId: z.ZodString;
258
+ }, z.core.$strict>>;
259
+ }, z.core.$strict>>;
153
260
  clawback: z.ZodDefault<z.ZodBoolean>;
154
261
  }, z.core.$strip>>>;
155
- manualEntitlements: z.ZodDefault<z.ZodArray<z.ZodString>>;
262
+ entitlements: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
263
+ name: z.ZodString;
264
+ quotas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
265
+ features: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
266
+ overrideMax: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
267
+ }, z.core.$strip>>>;
268
+ defaults: z.ZodOptional<z.ZodObject<{
269
+ quotas: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
270
+ features: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
271
+ }, z.core.$strip>>;
272
+ meters: z.ZodDefault<z.ZodObject<{
273
+ emails: z.ZodOptional<z.ZodObject<{
274
+ enforce: z.ZodDefault<z.ZodBoolean>;
275
+ }, z.core.$strict>>;
276
+ storageBytes: z.ZodOptional<z.ZodObject<{
277
+ enforce: z.ZodDefault<z.ZodBoolean>;
278
+ }, z.core.$strict>>;
279
+ mediaItems: z.ZodOptional<z.ZodObject<{
280
+ enforce: z.ZodDefault<z.ZodBoolean>;
281
+ }, z.core.$strict>>;
282
+ }, z.core.$strict>>;
283
+ manualEntitlements: z.ZodOptional<z.ZodNever>;
156
284
  stripe: z.ZodOptional<z.ZodObject<{
157
285
  successUrl: z.ZodURL;
158
286
  cancelUrl: z.ZodURL;
@@ -212,6 +340,18 @@ export interface PaymentsCatalogEntry {
212
340
  }
213
341
  /** The provider SKU this product is listed under on `rail`, or undefined when it does not ship there. */
214
342
  export declare function providerProductId(product: PaymentsProduct, rail: PaymentsRail): string | undefined;
343
+ /**
344
+ * What is wrong with one product's reported billing, as sentences naming the product — empty for a product
345
+ * that has none, or one that is sound.
346
+ *
347
+ * Every refusal here is at boot, because a reported product that cannot be reported is a subscription that
348
+ * bills nothing for a quantity the customer is using — invisible until somebody reads an invoice.
349
+ */
350
+ export declare function reportedBillingProblems(id: string, product: PaymentsProduct, config: Pick<PaymentsConfig, "rails">): DeclarationProblem[];
351
+ /** Every product billed by a reported quantity, with its id. */
352
+ export declare function reportedProducts(config: PaymentsConfig): (PaymentsCatalogEntry & {
353
+ billing: PaymentsReportedBilling;
354
+ })[];
215
355
  /** The product with this logical id, or undefined. Ids come from config, so an unknown one is a 404. */
216
356
  export declare function resolveProduct(config: PaymentsConfig, id: string): PaymentsCatalogEntry | undefined;
217
357
  /**
@@ -222,17 +362,23 @@ export declare function resolveProduct(config: PaymentsConfig, id: string): Paym
222
362
  */
223
363
  export declare function productForProviderSku(config: PaymentsConfig, rail: PaymentsRail, sku: string): PaymentsCatalogEntry | undefined;
224
364
  /**
225
- * Every entitlement key this project defines — what the catalog's products grant, plus what the adopter
226
- * declared grantable with no sale behind it.
365
+ * Every entitlement key this project defines — the keys `entitlements` declares. Every key a product
366
+ * mentions is among them, because the config refuses a mention with no declaration.
227
367
  *
228
- * The set a manual grant is checked against, and the set the control-plane catalog read publishes the first
229
- * half of. Computed once per composition: the catalog is config, so it cannot change under a running Worker.
368
+ * The set a manual grant is checked against, and the set the control-plane catalog read publishes.
369
+ * Computed once per composition: the catalog is config, so it cannot change under a running Worker.
230
370
  *
231
- * **Empty is a real answer.** A project composing payments with nothing to sell and nothing declared defines
232
- * no keys, and every grant against it is refused — which is correct, because there is no vocabulary to grant
233
- * in. It is the same statement `clientProjection` makes as `{ enabled: false }`.
371
+ * **Empty is a real answer.** A project composing payments with nothing declared defines no keys, and every
372
+ * grant against it is refused — which is correct, because there is no vocabulary to grant in. It is the same
373
+ * statement `clientProjection` makes as `{ enabled: false }`.
234
374
  */
235
375
  export declare function grantableEntitlements(config: PaymentsConfig): ReadonlySet<string>;
376
+ /**
377
+ * The declared keys no product sells — comp-only. Granted by hand through the control plane, sold by no
378
+ * checkout. What `manualEntitlements` used to list, said by the shape of the config rather than by a
379
+ * second list that could disagree with the first.
380
+ */
381
+ export declare function compOnlyEntitlements(config: PaymentsConfig): string[];
236
382
  /** The entitlement keys a product grants, or an empty list for an unknown product or one that grants none. */
237
383
  export declare function entitlementsForProduct(config: PaymentsConfig, id: string): readonly string[];
238
384
  /** Whether a rail is enabled for this project. A disabled rail refuses its routes and its webhook. */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,cAAc,CAA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