@pithy-sh/payments 0.3.10 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +11 -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 +38 -0
  14. package/dist/client/api.d.ts.map +1 -1
  15. package/dist/client/api.js +59 -1
  16. package/dist/client/hooks.d.ts +63 -1
  17. package/dist/client/hooks.d.ts.map +1 -1
  18. package/dist/client/hooks.js +96 -2
  19. package/dist/client/paddleLink.d.ts +31 -0
  20. package/dist/client/paddleLink.d.ts.map +1 -0
  21. package/dist/client/paddleLink.js +37 -0
  22. package/dist/client/projection.d.ts +29 -0
  23. package/dist/client/projection.d.ts.map +1 -1
  24. package/dist/config/allowances.d.ts +71 -0
  25. package/dist/config/allowances.d.ts.map +1 -0
  26. package/dist/config/allowances.js +115 -0
  27. package/dist/config/config.d.ts +155 -9
  28. package/dist/config/config.d.ts.map +1 -1
  29. package/dist/config/config.js +164 -14
  30. package/dist/data/meterCounter.d.ts +34 -0
  31. package/dist/data/meterCounter.d.ts.map +1 -0
  32. package/dist/data/meterCounter.js +33 -0
  33. package/dist/data/override.d.ts +56 -0
  34. package/dist/data/override.d.ts.map +1 -0
  35. package/dist/data/override.js +58 -0
  36. package/dist/data/paddleIds.d.ts +28 -0
  37. package/dist/data/paddleIds.d.ts.map +1 -0
  38. package/dist/data/paddleIds.js +73 -0
  39. package/dist/data/period.d.ts +10 -0
  40. package/dist/data/period.d.ts.map +1 -0
  41. package/dist/data/period.js +37 -0
  42. package/dist/data/purchase.d.ts +1 -0
  43. package/dist/data/purchase.d.ts.map +1 -1
  44. package/dist/data/purchase.js +1 -0
  45. package/dist/data/tables.d.ts +17 -1
  46. package/dist/data/tables.d.ts.map +1 -1
  47. package/dist/data/tables.js +24 -4
  48. package/dist/data/usageReport.d.ts +68 -0
  49. package/dist/data/usageReport.d.ts.map +1 -0
  50. package/dist/data/usageReport.js +55 -0
  51. package/dist/data/usageRun.d.ts +93 -0
  52. package/dist/data/usageRun.d.ts.map +1 -0
  53. package/dist/data/usageRun.js +50 -0
  54. package/dist/entitlement/allowance.d.ts +100 -0
  55. package/dist/entitlement/allowance.d.ts.map +1 -0
  56. package/dist/entitlement/allowance.js +171 -0
  57. package/dist/entitlement/manual.d.ts +5 -5
  58. package/dist/entitlement/manual.js +3 -3
  59. package/dist/entitlement/meter.d.ts +98 -0
  60. package/dist/entitlement/meter.d.ts.map +1 -0
  61. package/dist/entitlement/meter.js +177 -0
  62. package/dist/entitlement/override.d.ts +119 -0
  63. package/dist/entitlement/override.d.ts.map +1 -0
  64. package/dist/entitlement/override.js +256 -0
  65. package/dist/entitlement/resolver.d.ts +2 -1
  66. package/dist/entitlement/resolver.d.ts.map +1 -1
  67. package/dist/entitlement/resolver.js +32 -1
  68. package/dist/entitlement/unimplementedSubject.d.ts.map +1 -1
  69. package/dist/entitlement/unimplementedSubject.js +3 -2
  70. package/dist/error/errors.d.ts +19 -0
  71. package/dist/error/errors.d.ts.map +1 -1
  72. package/dist/error/errors.js +35 -2
  73. package/dist/http/responses.d.ts +390 -5
  74. package/dist/http/responses.d.ts.map +1 -1
  75. package/dist/http/responses.js +169 -13
  76. package/dist/http/routes.d.ts +6 -2
  77. package/dist/http/routes.d.ts.map +1 -1
  78. package/dist/http/routes.js +478 -52
  79. package/dist/http/schemas.d.ts +75 -1
  80. package/dist/http/schemas.d.ts.map +1 -1
  81. package/dist/http/schemas.js +80 -3
  82. package/dist/http/scopes.d.ts +25 -0
  83. package/dist/http/scopes.d.ts.map +1 -1
  84. package/dist/http/scopes.js +60 -1
  85. package/dist/http/view.d.ts +22 -4
  86. package/dist/http/view.d.ts.map +1 -1
  87. package/dist/http/view.js +88 -7
  88. package/dist/http/webhookGuard.d.ts.map +1 -1
  89. package/dist/http/webhookGuard.js +1 -1
  90. package/dist/index.d.ts +2 -1
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +3 -2
  93. package/dist/migrations/0002_allowances.d.ts +26 -0
  94. package/dist/migrations/0002_allowances.d.ts.map +1 -0
  95. package/dist/migrations/0002_allowances.js +62 -0
  96. package/dist/peer.d.ts +1 -0
  97. package/dist/peer.d.ts.map +1 -1
  98. package/dist/projection/event.d.ts +1 -0
  99. package/dist/projection/event.d.ts.map +1 -1
  100. package/dist/projection/event.js +1 -0
  101. package/dist/projection/writer.d.ts.map +1 -1
  102. package/dist/projection/writer.js +3 -1
  103. package/dist/rails/contract.d.ts +6 -0
  104. package/dist/rails/contract.d.ts.map +1 -1
  105. package/dist/rails/google/playApi.d.ts.map +1 -1
  106. package/dist/rails/google/playApi.js +2 -0
  107. package/dist/rails/paddle/events.d.ts.map +1 -1
  108. package/dist/rails/paddle/events.js +2 -1
  109. package/dist/rails/paddle/objects.d.ts +2 -0
  110. package/dist/rails/paddle/objects.d.ts.map +1 -1
  111. package/dist/rails/paddle/objects.js +7 -2
  112. package/dist/rails/paddle/refresh.d.ts +10 -5
  113. package/dist/rails/paddle/refresh.d.ts.map +1 -1
  114. package/dist/rails/paddle/refresh.js +8 -5
  115. package/dist/rails/paddle/refund.d.ts.map +1 -1
  116. package/dist/rails/paddle/refund.js +10 -2
  117. package/dist/rails/paddle/subscription.d.ts.map +1 -1
  118. package/dist/rails/paddle/subscription.js +8 -3
  119. package/dist/rails/paddle/usage.d.ts +11 -0
  120. package/dist/rails/paddle/usage.d.ts.map +1 -0
  121. package/dist/rails/paddle/usage.js +49 -0
  122. package/dist/rails/paddle/verify.d.ts.map +1 -1
  123. package/dist/rails/paddle/verify.js +2 -3
  124. package/dist/rails/quantity.d.ts +12 -0
  125. package/dist/rails/quantity.d.ts.map +1 -0
  126. package/dist/rails/quantity.js +16 -0
  127. package/dist/rails/stripe/checkout.d.ts.map +1 -1
  128. package/dist/rails/stripe/checkout.js +1 -1
  129. package/dist/rails/stripe/objects.d.ts.map +1 -1
  130. package/dist/rails/stripe/objects.js +3 -0
  131. package/dist/rails/stripe/usage.d.ts +10 -0
  132. package/dist/rails/stripe/usage.d.ts.map +1 -0
  133. package/dist/rails/stripe/usage.js +49 -0
  134. package/dist/secret/registry.d.ts.map +1 -1
  135. package/dist/secret/registry.js +3 -2
  136. package/dist/usage/pass.d.ts +120 -0
  137. package/dist/usage/pass.d.ts.map +1 -0
  138. package/dist/usage/pass.js +363 -0
  139. package/dist/usage/reporter.d.ts +36 -0
  140. package/dist/usage/reporter.d.ts.map +1 -0
  141. package/dist/usage/reporter.js +2 -0
  142. package/dist/version.generated.d.ts +1 -1
  143. package/dist/version.generated.d.ts.map +1 -1
  144. package/dist/version.generated.js +1 -1
  145. package/dist/workflows/specs.d.ts +28 -0
  146. package/dist/workflows/specs.d.ts.map +1 -1
  147. package/dist/workflows/specs.js +26 -1
  148. package/dist/workflows/usage.d.ts +38 -0
  149. package/dist/workflows/usage.d.ts.map +1 -0
  150. package/dist/workflows/usage.js +77 -0
  151. package/dist/workflows/worker.js +2 -2
  152. package/dist/workflows/workerConfig.d.ts.map +1 -1
  153. package/dist/workflows/workerConfig.js +8 -2
  154. package/docs/entitlements.md +249 -0
  155. package/docs/lemon-squeezy.md +1 -0
  156. package/docs/paddle.md +18 -2
  157. package/package.json +7 -7
  158. package/pithy.manifest.json +3 -8
  159. package/src/admin/coverage.ts +28 -0
  160. package/src/admin/read.ts +173 -1
  161. package/src/audit/actions.ts +13 -0
  162. package/src/capability.ts +87 -9
  163. package/src/client/api.ts +79 -0
  164. package/src/client/hooks.ts +122 -0
  165. package/src/client/paddleLink.ts +41 -0
  166. package/src/client/projection.ts +31 -0
  167. package/src/config/allowances.ts +211 -0
  168. package/src/config/config.ts +283 -15
  169. package/src/data/meterCounter.ts +38 -0
  170. package/src/data/override.ts +74 -0
  171. package/src/data/paddleIds.ts +74 -0
  172. package/src/data/period.ts +53 -0
  173. package/src/data/purchase.ts +9 -0
  174. package/src/data/tables.ts +25 -1
  175. package/src/data/usageReport.ts +64 -0
  176. package/src/data/usageRun.ts +66 -0
  177. package/src/entitlement/allowance.ts +213 -0
  178. package/src/entitlement/manual.ts +6 -6
  179. package/src/entitlement/meter.ts +252 -0
  180. package/src/entitlement/override.ts +381 -0
  181. package/src/entitlement/resolver.ts +43 -2
  182. package/src/entitlement/unimplementedSubject.ts +3 -4
  183. package/src/error/errors.ts +44 -1
  184. package/src/http/responses.ts +338 -10
  185. package/src/http/routes.ts +1089 -460
  186. package/src/http/schemas.ts +171 -2
  187. package/src/http/scopes.ts +68 -0
  188. package/src/http/view.ts +112 -7
  189. package/src/http/webhookGuard.ts +3 -2
  190. package/src/index.ts +18 -0
  191. package/src/migrations/0002_allowances.ts +149 -0
  192. package/src/projection/event.ts +9 -0
  193. package/src/projection/writer.ts +4 -0
  194. package/src/rails/contract.ts +6 -0
  195. package/src/rails/google/playApi.ts +2 -0
  196. package/src/rails/paddle/events.ts +2 -1
  197. package/src/rails/paddle/fixtures/subscription-charge.json +19 -0
  198. package/src/rails/paddle/objects.ts +6 -0
  199. package/src/rails/paddle/refresh.ts +17 -10
  200. package/src/rails/paddle/refund.ts +10 -2
  201. package/src/rails/paddle/subscription.ts +8 -3
  202. package/src/rails/paddle/usage.ts +66 -0
  203. package/src/rails/paddle/verify.ts +6 -4
  204. package/src/rails/quantity.ts +14 -0
  205. package/src/rails/stripe/checkout.ts +3 -1
  206. package/src/rails/stripe/fixtures/meter-event-created.json +12 -0
  207. package/src/rails/stripe/objects.ts +4 -0
  208. package/src/rails/stripe/usage.ts +61 -0
  209. package/src/secret/registry.ts +3 -2
  210. package/src/usage/pass.ts +539 -0
  211. package/src/usage/reporter.ts +38 -0
  212. package/src/version.generated.ts +1 -1
  213. package/src/workflows/specs.ts +34 -0
  214. package/src/workflows/usage.ts +97 -0
  215. package/src/workflows/workerConfig.ts +9 -3
@@ -80,7 +80,7 @@ export type CheckoutRequest = z.infer<typeof CheckoutRequest>;
80
80
  *
81
81
  * **No body at all on `keep`.** Withdrawing a scheduled cancellation takes no parameters: which
82
82
  * subscription is the server's answer, and there is nothing to say about it but *do not*. So that route
83
- * declares no schema and no `zValidator("json", …)`, exactly as `POST {base}/portal` does. A
83
+ * declares no schema and no `validate("json", …)`, exactly as `POST {base}/portal` does. A
84
84
  * `z.object({})` would read as a refusal of everything and be neither — Zod strips rather than refuses —
85
85
  * while making a POST with no body at all a 400 on a route that wants nothing.
86
86
  */
@@ -303,6 +303,41 @@ export declare const EntitlementRevokeRequest: z.ZodObject<{
303
303
  entitlement: z.ZodString;
304
304
  }, z.core.$strip>;
305
305
  export type EntitlementRevokeRequest = z.output<typeof EntitlementRevokeRequest>;
306
+ export declare const OverrideSetRequest: z.ZodObject<{
307
+ subjectType: z.ZodEnum<{
308
+ organization: "organization";
309
+ user: "user";
310
+ }>;
311
+ subjectId: z.ZodString;
312
+ version: z.ZodNumber;
313
+ reason: z.ZodString;
314
+ quotas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
315
+ features: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
316
+ }, z.core.$strict>;
317
+ export type OverrideSetRequest = z.output<typeof OverrideSetRequest>;
318
+ export declare const OverrideUnrestrictedRequest: z.ZodObject<{
319
+ subjectType: z.ZodEnum<{
320
+ organization: "organization";
321
+ user: "user";
322
+ }>;
323
+ subjectId: z.ZodString;
324
+ version: z.ZodNumber;
325
+ reason: z.ZodString;
326
+ unrestricted: z.ZodBoolean;
327
+ }, z.core.$strict>;
328
+ export type OverrideUnrestrictedRequest = z.output<typeof OverrideUnrestrictedRequest>;
329
+ export declare const OverrideClearRequest: z.ZodObject<{
330
+ subjectType: z.ZodEnum<{
331
+ organization: "organization";
332
+ user: "user";
333
+ }>;
334
+ subjectId: z.ZodString;
335
+ version: z.ZodOptional<z.ZodNumber>;
336
+ reason: z.ZodOptional<z.ZodString>;
337
+ quotas: z.ZodOptional<z.ZodArray<z.ZodString>>;
338
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
339
+ }, z.core.$strict>;
340
+ export type OverrideClearRequest = z.output<typeof OverrideClearRequest>;
306
341
  export declare const AdminPurchasesQuery: z.ZodObject<{
307
342
  subjectType: z.ZodOptional<z.ZodEnum<{
308
343
  organization: "organization";
@@ -367,6 +402,20 @@ export declare const AdminEntitlementsQuery: z.ZodObject<{
367
402
  limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
368
403
  }, z.core.$strip>;
369
404
  export type AdminEntitlementsQuery = z.output<typeof AdminEntitlementsQuery>;
405
+ export declare const AdminOverridesQuery: z.ZodObject<{
406
+ subjectType: z.ZodOptional<z.ZodEnum<{
407
+ organization: "organization";
408
+ user: "user";
409
+ }>>;
410
+ subjectId: z.ZodOptional<z.ZodString>;
411
+ unrestricted: z.ZodOptional<z.ZodEnum<{
412
+ false: "false";
413
+ true: "true";
414
+ }>>;
415
+ cursor: z.ZodOptional<z.ZodString>;
416
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
417
+ }, z.core.$strip>;
418
+ export type AdminOverridesQuery = z.output<typeof AdminOverridesQuery>;
370
419
  export declare const AdminReconcileRunsQuery: z.ZodObject<{
371
420
  rail: z.ZodOptional<z.ZodEnum<{
372
421
  apple: "apple";
@@ -383,6 +432,11 @@ export declare const AdminReconcileRunsQuery: z.ZodObject<{
383
432
  limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
384
433
  }, z.core.$strip>;
385
434
  export type AdminReconcileRunsQuery = z.output<typeof AdminReconcileRunsQuery>;
435
+ export declare const AdminUsageRunsQuery: z.ZodObject<{
436
+ cursor: z.ZodOptional<z.ZodString>;
437
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
438
+ }, z.core.$strip>;
439
+ export type AdminUsageRunsQuery = z.output<typeof AdminUsageRunsQuery>;
386
440
  /**
387
441
  * The two path segments on the per-subject management read: `…/entitlements/:subjectType/:subjectId`.
388
442
  *
@@ -403,4 +457,24 @@ export declare const AdminSubjectParam: z.ZodObject<{
403
457
  subjectId: z.ZodString;
404
458
  }, z.core.$strip>;
405
459
  export type AdminSubjectParam = z.output<typeof AdminSubjectParam>;
460
+ /**
461
+ * The transaction a Paddle payment link put in the URL — the `?transaction=` query on the resume read.
462
+ *
463
+ * **The id is the whole request, and it came from outside.** Paddle appends `?_ptxn=<transaction_id>` to a
464
+ * seller's Default payment link; the browser reads it and sends it here. So this is attacker-supplied text
465
+ * on an unauthenticated route, and the shape check is what makes it safe to echo back into a handoff a page
466
+ * will hand to `Paddle.Checkout.open`.
467
+ *
468
+ * **Checked against the rail's own primitive**, `isPaddleTransactionId`, rather than a regex written here:
469
+ * `rails/paddle/verify.ts` asks the same question of a submitted receipt, and two copies of one rule is the
470
+ * defect class this repository has paid for four times.
471
+ *
472
+ * **It names no holder, and that is structural rather than remembered.** The resume route takes no session
473
+ * and resolves no subject, so there is no field here for one — which `routeContract.test.ts`'s subject sweep
474
+ * asserts from the other side, by finding none.
475
+ */
476
+ export declare const PaddleResumeQuery: z.ZodObject<{
477
+ transaction: z.ZodString;
478
+ }, z.core.$strip>;
479
+ export type PaddleResumeQuery = z.output<typeof PaddleResumeQuery>;
406
480
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA4DxB,eAAO,MAAM,kBAAkB;;;;;;;;;iBAa5B,CAAC;AACJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAA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+D,CAAC;AAChG,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAWmD,CAAC;AACxF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE/E,eAAO,MAAM,mBAAmB;;;iBAEkC,CAAC;AACnE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB;;;;;;iBASgE,CAAC;AAC/F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB;;iBAW8D,CAAC;AAC7F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -2,9 +2,11 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { PaymentsHostedRail, PaymentsRail } from "../data/rail.js";
4
4
  import { PaymentsSubject } from "../data/subject.js";
5
+ import { AllowanceName, QuotaValue } from "../config/allowances.js";
5
6
  import { PurchaseStatus } from "../data/status.js";
6
7
  import { PurchaseEnvironment } from "../data/purchase.js";
7
8
  import { SubscriptionCancelTiming } from "../data/subscription.js";
9
+ import { isPaddleTransactionId } from "../data/paddleIds.js";
8
10
  import { DiscountCode, DiscountTerms } from "../data/discount.js";
9
11
  import { EntitlementKey } from "@pithy-sh/core/src/entitlement/entitlement";
10
12
  import { z } from "zod";
@@ -115,7 +117,7 @@ const CheckoutRequest = z.object({
115
117
  *
116
118
  * **No body at all on `keep`.** Withdrawing a scheduled cancellation takes no parameters: which
117
119
  * subscription is the server's answer, and there is nothing to say about it but *do not*. So that route
118
- * declares no schema and no `zValidator("json", …)`, exactly as `POST {base}/portal` does. A
120
+ * declares no schema and no `validate("json", …)`, exactly as `POST {base}/portal` does. A
119
121
  * `z.object({})` would read as a refusal of everything and be neither — Zod strips rather than refuses —
120
122
  * while making a POST with no body at all a 400 on a route that wants nothing.
121
123
  */
@@ -259,7 +261,7 @@ const PaddleWebhookNotification = z.object({
259
261
  const EntitlementGrantRequest = z.object({
260
262
  subjectType: PaymentsSubject.shape.subjectType.describe("Which kind of holder to grant — the half that makes the id an address. Named, never assumed from the project's `billingSubject`, so what an audit row records is what a management client asked for."),
261
263
  subjectId: PaymentsSubject.shape.subjectId.describe("The subject to grant. Support acts on somebody else's holding, so this is one of the two routes where the subject is a request field rather than the server's own answer."),
262
- entitlement: EntitlementKey.describe("The entitlement key to grant, as gating code names it. Not a store SKU. It must be one this project defines — a key some product grants, or one the adopter declared in `manualEntitlements` — and anything else is a 400 naming the key. Comping a key nothing sells is still the durable case; declaring it is how a project says so."),
264
+ entitlement: EntitlementKey.describe("The entitlement key to grant, as gating code names it. Not a store SKU. It must be one the `entitlements` map declares, and anything else is a 400 naming the key. Comping a key nothing sells is still the durable case; declaring it with no product behind it is how a project says so."),
263
265
  expiresAt: JsonDate.optional().describe("When the grant lapses, as an ISO 8601 timestamp. Omit for a comp that never ends. A past timestamp writes a row that grants nothing, which is a slower way of revoking.")
264
266
  }).describe("A control-plane request to grant one entitlement to one subject, with no purchase behind it.");
265
267
  /**
@@ -275,6 +277,54 @@ const EntitlementRevokeRequest = z.object({
275
277
  entitlement: EntitlementKey.describe("The entitlement key to revoke, as gating code names it.")
276
278
  }).describe("A control-plane request to revoke one entitlement from one subject, effective immediately.");
277
279
  /**
280
+ * ## The override writes
281
+ *
282
+ * Three routes, three scopes, and the split is the security core of them. **Set** pins numbers and switches;
283
+ * **unrestricted** hands a subject the whole product; **clear** removes pins. A credential that may raise one
284
+ * customer's email cap must not, by that fact, be able to hand anybody everything — so `unrestricted` is not a
285
+ * field on the set, and every one of these is a `strictObject`: a set body carrying `unrestricted: true` is a
286
+ * 400, never a field quietly dropped while the caller believes it took.
287
+ *
288
+ * **Both halves of the subject, a version, and on a set a reason.** The version is the one the caller read;
289
+ * a write behind the row is refused as stale. The reason is required because an override is a sentence about a
290
+ * commercial decision, and the audit event records it verbatim.
291
+ *
292
+ * Whether a name is declared, and whether a number is under its ceiling, are config-backed questions and stay
293
+ * in the handler: a schema constrains a value, it never replaces a lookup. What the schema does refuse is the
294
+ * shape — a float, a negative, a string where a quota belongs — as `validation/invalid_input`.
295
+ */
296
+ /** The longest reason a write may carry. A sentence, a ticket number, a contract reference — not a document. */
297
+ const MAX_OVERRIDE_REASON_LENGTH = 500;
298
+ /** The most names one write may carry. Far past any real catalog; bounded because a verified client can still loop. */
299
+ const MAX_OVERRIDE_NAMES = 100;
300
+ const OverrideSubjectType = PaymentsSubject.shape.subjectType.describe("Which kind of holder the override is for. Named, never assumed — and refused when it is not the kind this project bills.");
301
+ const OverrideSubjectId = PaymentsSubject.shape.subjectId.describe("The subject whose allowances this shades.");
302
+ const OverrideVersion = z.number().int().min(0).describe("The override version the caller read — `0` when the subject had none. A write naming a version behind the row is refused with `payments/override_stale` and changes nothing.");
303
+ const OverrideReason = z.string().trim().min(1).max(MAX_OVERRIDE_REASON_LENGTH).describe("Why — a contract, a goodwill credit, a migration. Required, and recorded verbatim on the audit event.");
304
+ const OverrideSetRequest = z.strictObject({
305
+ subjectType: OverrideSubjectType,
306
+ subjectId: OverrideSubjectId,
307
+ version: OverrideVersion,
308
+ reason: OverrideReason,
309
+ quotas: z.record(AllowanceName, QuotaValue).optional().describe("Quotas to pin, by name — a whole number from 0, or null for unlimited. Merged: a name absent here keeps whatever it had."),
310
+ features: z.record(AllowanceName, z.boolean().describe("Whether the switch is on.")).optional().describe("Features to pin, by name. Merged: a name absent here keeps whatever it had.")
311
+ }).refine((body) => Object.keys(body.quotas ?? {}).length + Object.keys(body.features ?? {}).length > 0, { message: "Name at least one quota or feature to pin." }).refine((body) => Object.keys(body.quotas ?? {}).length + Object.keys(body.features ?? {}).length <= MAX_OVERRIDE_NAMES, { message: `Pin at most ${MAX_OVERRIDE_NAMES} names in one write.` }).describe("A control-plane request to pin quotas and features for one subject. A merge by name, version-checked, with a reason.");
312
+ const OverrideUnrestrictedRequest = z.strictObject({
313
+ subjectType: OverrideSubjectType,
314
+ subjectId: OverrideSubjectId,
315
+ version: OverrideVersion,
316
+ reason: OverrideReason,
317
+ unrestricted: z.boolean().describe("True grants every quota unlimited and every feature on, for every name declared now and later, except the names the override pins. False takes it back and leaves the pins.")
318
+ }).describe("A control-plane request to turn `unrestricted` on or off for one subject. Its own route, behind its own scope.");
319
+ const OverrideClearRequest = z.strictObject({
320
+ subjectType: OverrideSubjectType,
321
+ subjectId: OverrideSubjectId,
322
+ version: OverrideVersion.optional().describe("The override version the caller read. Optional: sent, a clear behind the row is refused as stale; omitted, the clear is not checked, which is safe because a clear can only move a subject back toward its plan — unpinning a name on an unrestricted subject is refused."),
323
+ reason: OverrideReason.optional().describe("Why, when the caller says. Recorded on the audit event."),
324
+ quotas: z.array(AllowanceName).max(MAX_OVERRIDE_NAMES).optional().describe("Quota pins to remove. Each resolves from the plan again. Refused on an unrestricted subject, where it would resolve to unlimited."),
325
+ features: z.array(AllowanceName).max(MAX_OVERRIDE_NAMES).optional().describe("Feature pins to remove. Each resolves from the plan again. Refused on an unrestricted subject, where it would resolve to on.")
326
+ }).describe("A control-plane request to unpin names, or — naming neither list — to clear the subject's override entirely, `unrestricted` included. Idempotent: clearing nothing answers 200. A clear never resets the version.");
327
+ /**
278
328
  * ## The management read queries
279
329
  *
280
330
  * The `Admin*` shapes below belong to the **control-plane reads**, which take no bodies at all: there is
@@ -335,12 +385,22 @@ const AdminEntitlementsQuery = z.object({
335
385
  cursor: Cursor,
336
386
  limit: Limit
337
387
  }).refine(subjectFilterIsWhole, SUBJECT_FILTER_RULE).describe("The entitlement query: what to narrow it to, and where to resume.");
388
+ const AdminOverridesQuery = z.object({
389
+ ...SUBJECT_FILTER,
390
+ unrestricted: z.enum(["true", "false"]).optional().describe("`true` lists only the subjects that are `unrestricted` — the largest grant the kit has."),
391
+ cursor: Cursor,
392
+ limit: Limit
393
+ }).refine(subjectFilterIsWhole, SUBJECT_FILTER_RULE).describe("The override listing query: a holder, whether unrestricted, and where to resume.");
338
394
  const AdminReconcileRunsQuery = z.object({
339
395
  rail: PaymentsRail.optional().describe("Restrict to the passes narrowed to one store. A scheduled pass runs against every rail and carries no rail, so this never matches one."),
340
396
  environment: PurchaseEnvironment.optional().describe("Restrict to one store environment — the sandbox host and the production host each keep their own passes."),
341
397
  cursor: Cursor,
342
398
  limit: Limit
343
399
  }).describe("The reconciliation-run query: what to narrow it to, and where to resume.");
400
+ const AdminUsageRunsQuery = z.object({
401
+ cursor: Cursor,
402
+ limit: Limit
403
+ }).describe("The usage-run query: where to resume, and how many.");
344
404
  /**
345
405
  * The two path segments on the per-subject management read: `…/entitlements/:subjectType/:subjectId`.
346
406
  *
@@ -357,5 +417,22 @@ const AdminSubjectParam = z.object({
357
417
  subjectType: PaymentsSubject.shape.subjectType.describe("Which kind of holder to resolve — the `:subjectType` path segment. A closed enum, so an unknown kind is a 400 naming the two that exist."),
358
418
  subjectId: PaymentsSubject.shape.subjectId.describe("Whose entitlements to resolve — the `:subjectId` path segment. Opaque to payments: whatever id the adopter's auth capability or its own membership model issued.")
359
419
  }).describe("The `:subjectType/:subjectId` path segments on the per-subject management read.");
420
+ /**
421
+ * The transaction a Paddle payment link put in the URL — the `?transaction=` query on the resume read.
422
+ *
423
+ * **The id is the whole request, and it came from outside.** Paddle appends `?_ptxn=<transaction_id>` to a
424
+ * seller's Default payment link; the browser reads it and sends it here. So this is attacker-supplied text
425
+ * on an unauthenticated route, and the shape check is what makes it safe to echo back into a handoff a page
426
+ * will hand to `Paddle.Checkout.open`.
427
+ *
428
+ * **Checked against the rail's own primitive**, `isPaddleTransactionId`, rather than a regex written here:
429
+ * `rails/paddle/verify.ts` asks the same question of a submitted receipt, and two copies of one rule is the
430
+ * defect class this repository has paid for four times.
431
+ *
432
+ * **It names no holder, and that is structural rather than remembered.** The resume route takes no session
433
+ * and resolves no subject, so there is no field here for one — which `routeContract.test.ts`'s subject sweep
434
+ * asserts from the other side, by finding none.
435
+ */
436
+ const PaddleResumeQuery = z.object({ transaction: z.string().refine(isPaddleTransactionId, { message: "Not a Paddle transaction id. Expected the `txn_…` Paddle put in `_ptxn`." }).describe("The Paddle transaction to resume — the `_ptxn` value, `txn_…`. Publishable: Paddle itself put it in a URL it mailed to the buyer.") }).describe("The resume read's query: which transaction a Paddle payment link arrived for.");
360
437
  //#endregion
361
- export { AdminDiscountsQuery, AdminEntitlementsQuery, AdminPurchasesQuery, AdminReconcileRunsQuery, AdminSubjectParam, AdminSubscriptionsQuery, AppleWebhookNotification, CheckoutRequest, DiscountCreateRequest, EntitlementGrantRequest, EntitlementRevokeRequest, GoogleWebhookNotification, LemonSqueezyWebhookNotification, PaddleWebhookNotification, PurchaseSubmission, RestoreRequest, StripeWebhookNotification, SubscriptionCancelRequest, SubscriptionChangeRequest, SubscriptionPreviewRequest };
438
+ export { AdminDiscountsQuery, AdminEntitlementsQuery, AdminOverridesQuery, AdminPurchasesQuery, AdminReconcileRunsQuery, AdminSubjectParam, AdminSubscriptionsQuery, AdminUsageRunsQuery, AppleWebhookNotification, CheckoutRequest, DiscountCreateRequest, EntitlementGrantRequest, EntitlementRevokeRequest, GoogleWebhookNotification, LemonSqueezyWebhookNotification, OverrideClearRequest, OverrideSetRequest, OverrideUnrestrictedRequest, PaddleResumeQuery, PaddleWebhookNotification, PurchaseSubmission, RestoreRequest, StripeWebhookNotification, SubscriptionCancelRequest, SubscriptionChangeRequest, SubscriptionPreviewRequest };
@@ -130,6 +130,31 @@ export declare const PAYMENTS_RECONCILE_READ_SCOPE: ControlPlaneScope;
130
130
  * a reconciled catalog already matching and writes nothing.
131
131
  */
132
132
  export declare const PAYMENTS_RECONCILE_RUN_SCOPE: ControlPlaneScope;
133
+ /**
134
+ * Pin a number or a switch for one subject — a negotiated email allowance, a goodwill seat. A merge by name,
135
+ * version-checked, with a reason on the record and bounded by any `overrideMax` the catalog declares.
136
+ *
137
+ * **It does not confer `unrestricted`.** A credential that may raise one customer's email cap must not, by
138
+ * that fact, be able to hand anybody the entire product.
139
+ */
140
+ export declare const PAYMENTS_OVERRIDE_SET_SCOPE: ControlPlaneScope;
141
+ /**
142
+ * Turn `unrestricted` on or off for one subject: every quota unlimited and every feature on, for every name
143
+ * declared now and every name declared later. **The largest grant the kit has**, and the only one whose reach
144
+ * grows by itself, which is why it is its own scope and its own route — never a field on the set.
145
+ */
146
+ export declare const PAYMENTS_OVERRIDE_UNRESTRICTED_SCOPE: ControlPlaneScope;
147
+ /**
148
+ * Remove pins from one subject's override, or the whole override. Separate from setting, the way revoke is
149
+ * separate from grant: a tool that tidies up after a contract ends needs to clear and has no business
150
+ * pinning.
151
+ */
152
+ export declare const PAYMENTS_OVERRIDE_CLEAR_SCOPE: ControlPlaneScope;
153
+ /**
154
+ * Read the usage-reporting run log — when each pass ran, what it reported, and which subjects it skipped and
155
+ * why. Its own scope, separate from the reconciliation log's: its findings name subjects.
156
+ */
157
+ export declare const PAYMENTS_USAGE_READ_SCOPE: ControlPlaneScope;
133
158
  /**
134
159
  * Every control-plane scope payments defines — what `pithy dashboard connect` offers for this capability, and
135
160
  * the list a manifest or a doc quotes rather than re-typing. Core's `SEAM_SCOPES` is the same idea for the
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/http/scopes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAC;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAE,iBAA+C,CAAC;AAE7F;;;;;;GAMG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AM,iCAAiC,EAAE,iBAAkD,CAAC;AAEnG;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,EAAE,iBAA6C,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,EAAE,iBAAiD,CAAC;AAElG;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,EAAE,iBAAgD,CAAC;AAEhG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,EAAE,iBAA2C,CAAC;AAEtF;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,EAAE,iBAA6C,CAAC;AAE1F;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,4BAA4B,EAAE,iBAA4C,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,iBAA4C,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,EAAE,iBAAqD,CAAC;AAEzG;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,iBAA8C,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,iBAAyC,CAAC;AAElF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,iBAAiB,EAerE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CA6GlE"}
@@ -130,6 +130,31 @@ const PAYMENTS_RECONCILE_READ_SCOPE = "payments:reconcile:read";
130
130
  */
131
131
  const PAYMENTS_RECONCILE_RUN_SCOPE = "payments:reconcile:run";
132
132
  /**
133
+ * Pin a number or a switch for one subject — a negotiated email allowance, a goodwill seat. A merge by name,
134
+ * version-checked, with a reason on the record and bounded by any `overrideMax` the catalog declares.
135
+ *
136
+ * **It does not confer `unrestricted`.** A credential that may raise one customer's email cap must not, by
137
+ * that fact, be able to hand anybody the entire product.
138
+ */
139
+ const PAYMENTS_OVERRIDE_SET_SCOPE = "payments:overrides:set";
140
+ /**
141
+ * Turn `unrestricted` on or off for one subject: every quota unlimited and every feature on, for every name
142
+ * declared now and every name declared later. **The largest grant the kit has**, and the only one whose reach
143
+ * grows by itself, which is why it is its own scope and its own route — never a field on the set.
144
+ */
145
+ const PAYMENTS_OVERRIDE_UNRESTRICTED_SCOPE = "payments:overrides:unrestricted";
146
+ /**
147
+ * Remove pins from one subject's override, or the whole override. Separate from setting, the way revoke is
148
+ * separate from grant: a tool that tidies up after a contract ends needs to clear and has no business
149
+ * pinning.
150
+ */
151
+ const PAYMENTS_OVERRIDE_CLEAR_SCOPE = "payments:overrides:clear";
152
+ /**
153
+ * Read the usage-reporting run log — when each pass ran, what it reported, and which subjects it skipped and
154
+ * why. Its own scope, separate from the reconciliation log's: its findings name subjects.
155
+ */
156
+ const PAYMENTS_USAGE_READ_SCOPE = "payments:usage:read";
157
+ /**
133
158
  * Every control-plane scope payments defines — what `pithy dashboard connect` offers for this capability, and
134
159
  * the list a manifest or a doc quotes rather than re-typing. Core's `SEAM_SCOPES` is the same idea for the
135
160
  * seam's own routes.
@@ -144,8 +169,12 @@ const PAYMENTS_CONTROL_PLANE_SCOPES = [
144
169
  PAYMENTS_ENTITLEMENTS_READ_SCOPE,
145
170
  PAYMENTS_DISCOUNT_READ_SCOPE,
146
171
  PAYMENTS_RECONCILE_READ_SCOPE,
172
+ PAYMENTS_USAGE_READ_SCOPE,
147
173
  PAYMENTS_ENTITLEMENT_GRANT_SCOPE,
148
174
  PAYMENTS_ENTITLEMENT_REVOKE_SCOPE,
175
+ PAYMENTS_OVERRIDE_SET_SCOPE,
176
+ PAYMENTS_OVERRIDE_CLEAR_SCOPE,
177
+ PAYMENTS_OVERRIDE_UNRESTRICTED_SCOPE,
149
178
  PAYMENTS_DISCOUNT_CREATE_SCOPE,
150
179
  PAYMENTS_RECONCILE_RUN_SCOPE
151
180
  ];
@@ -235,8 +264,38 @@ function paymentsAdminRoutes(basePath) {
235
264
  path: `${basePath}/entitlements/revoke`,
236
265
  scope: PAYMENTS_ENTITLEMENT_REVOKE_SCOPE,
237
266
  summary: "Take an entitlement back, effective immediately."
267
+ },
268
+ {
269
+ method: "GET",
270
+ path: `${basePath}/admin/usage-runs`,
271
+ scope: PAYMENTS_USAGE_READ_SCOPE,
272
+ summary: "The usage-reporting passes this deployment has run — what each reported, and which subjects it skipped and why. The answer to why a quantity-billed customer was not billed."
273
+ },
274
+ {
275
+ method: "GET",
276
+ path: `${basePath}/admin/overrides`,
277
+ scope: PAYMENTS_ENTITLEMENTS_READ_SCOPE,
278
+ summary: "Page every subject's override — the numbers negotiated per customer, and which subjects are unrestricted."
279
+ },
280
+ {
281
+ method: "POST",
282
+ path: `${basePath}/entitlements/overrides`,
283
+ scope: PAYMENTS_OVERRIDE_SET_SCOPE,
284
+ summary: "Pin a negotiated number or switch for one subject, with a reason on the record. Merges by name; every other allowance keeps tracking the plan."
285
+ },
286
+ {
287
+ method: "POST",
288
+ path: `${basePath}/entitlements/overrides/unrestricted`,
289
+ scope: PAYMENTS_OVERRIDE_UNRESTRICTED_SCOPE,
290
+ summary: "Grant one subject the whole product — every quota unlimited and every feature on, including names declared later — or take it back."
291
+ },
292
+ {
293
+ method: "POST",
294
+ path: `${basePath}/entitlements/overrides/clear`,
295
+ scope: PAYMENTS_OVERRIDE_CLEAR_SCOPE,
296
+ summary: "Unpin allowances for one subject, or clear its override entirely. Unpinned names follow the plan again."
238
297
  }
239
298
  ];
240
299
  }
241
300
  //#endregion
242
- export { PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_DISCOUNT_CREATE_SCOPE, PAYMENTS_DISCOUNT_READ_SCOPE, PAYMENTS_ENTITLEMENTS_READ_SCOPE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_PURCHASES_READ_SCOPE, PAYMENTS_RECONCILE_READ_SCOPE, PAYMENTS_RECONCILE_RUN_SCOPE, PAYMENTS_SUBSCRIPTIONS_READ_SCOPE, paymentsAdminRoutes };
301
+ export { PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_DISCOUNT_CREATE_SCOPE, PAYMENTS_DISCOUNT_READ_SCOPE, PAYMENTS_ENTITLEMENTS_READ_SCOPE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_OVERRIDE_CLEAR_SCOPE, PAYMENTS_OVERRIDE_SET_SCOPE, PAYMENTS_OVERRIDE_UNRESTRICTED_SCOPE, PAYMENTS_PURCHASES_READ_SCOPE, PAYMENTS_RECONCILE_READ_SCOPE, PAYMENTS_RECONCILE_RUN_SCOPE, PAYMENTS_SUBSCRIPTIONS_READ_SCOPE, PAYMENTS_USAGE_READ_SCOPE, paymentsAdminRoutes };
@@ -1,11 +1,14 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { PaymentsPurchaseRecord } from "../admin/read";
4
- import type { PaymentsConfig } from "../config/config";
4
+ import { type PaymentsConfig } from "../config/config";
5
5
  import type { PaymentsEntitlement } from "../data/entitlement";
6
+ import { type PaymentsOverride } from "../data/override";
6
7
  import type { PaymentsReconcileRun } from "../data/reconcileRun";
8
+ import type { PaymentsUsageRun } from "../data/usageRun";
9
+ import type { ResolvedAllowances } from "../entitlement/allowance";
7
10
  import type { PurchaseProjection } from "../projection/writer";
8
- import type { PaymentsAdminCatalogResponse, PaymentsAdminEntitlementView, PaymentsAdminPurchaseView, PaymentsAdminReconcileRunView, PaymentsEntitlementView, PaymentsPurchaseView } from "./responses";
11
+ import type { PaymentsAdminAllowancesView, PaymentsAdminCatalogResponse, PaymentsAdminEntitlementView, PaymentsAdminOverrideView, PaymentsAdminPurchaseView, PaymentsAdminReconcileRunView, PaymentsAdminUsageRunView, PaymentsEntitlementView, PaymentsPurchaseView } from "./responses";
9
12
  /**
10
13
  * What a client is shown. Nothing in this package ever returns a raw row.
11
14
  *
@@ -76,7 +79,10 @@ export declare function entitlementView(entitlement: {
76
79
  */
77
80
  export declare function adminCatalogView(config: PaymentsConfig): PaymentsAdminCatalogResponse;
78
81
  /** Project one purchase for a management client. The record's columns, verbatim, with dates as strings. */
79
- export declare function adminPurchaseView(purchase: PaymentsPurchaseRecord): PaymentsAdminPurchaseView;
82
+ export declare function adminPurchaseView(purchase: PaymentsPurchaseRecord, reported?: {
83
+ quantity: number;
84
+ reportedAt: Date;
85
+ } | null): PaymentsAdminPurchaseView;
80
86
  /**
81
87
  * Project one entitlement row for a management client, resolving `granted` against `now`.
82
88
  *
@@ -85,7 +91,19 @@ export declare function adminPurchaseView(purchase: PaymentsPurchaseRecord): Pay
85
91
  * and the gate the adopter's own app calls applies the timestamp on every request. A dashboard that
86
92
  * rendered the flag would disagree with that gate, and the customer would believe the dashboard.
87
93
  */
88
- export declare function adminEntitlementView(row: PaymentsEntitlement, now: Date): PaymentsAdminEntitlementView;
94
+ export declare function adminEntitlementView(row: PaymentsEntitlement, now: Date, unrestricted?: boolean): PaymentsAdminEntitlementView;
95
+ /** Project one usage run for a management client. The row's columns, dates as ISO strings. */
96
+ export declare function adminUsageRunView(run: PaymentsUsageRun): PaymentsAdminUsageRunView;
97
+ /** Project one subject's override for a management client, or null when it has none. */
98
+ export declare function adminOverrideView(row: PaymentsOverride | undefined): PaymentsAdminOverrideView | null;
99
+ /** Project one override row for a management client. */
100
+ export declare function overrideView(row: PaymentsOverride): PaymentsAdminOverrideView;
101
+ /**
102
+ * Project every declared allowance for one subject: effective, provenance and inherited per name, plus the
103
+ * ceiling an override of each quota is bounded by for this subject. What an override editor draws its rows
104
+ * from.
105
+ */
106
+ export declare function adminAllowancesView(resolved: ResolvedAllowances, ceiling: (name: string) => number | undefined): PaymentsAdminAllowancesView;
89
107
  /**
90
108
  * Project one reconciliation run for a management client.
91
109
  *
@@ -1 +1 @@
1
- {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AC,UAAU,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,GACvD,yBAAyB,CAyB3B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,mBAAmB,EACxB,GAAG,EAAE,IAAI,EACT,YAAY,UAAQ,GACnB,4BAA4B,CAY9B;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,yBAAyB,CAclF;AAED,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,GAAG,SAAS,GAAG,yBAAyB,GAAG,IAAI,CAGrG;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,GAAG,yBAAyB,CAS7E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC5C,2BAA2B,CAsB7B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,oBAAoB,GAAG,6BAA6B,CAiB9F"}
package/dist/http/view.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { compOnlyEntitlements } from "../config/config.js";
4
+ import { isEmptyOverride } from "../data/override.js";
3
5
  //#region src/http/view.ts
4
6
  /**
5
7
  * What a client is shown. Nothing in this package ever returns a raw row.
@@ -92,17 +94,36 @@ function adminCatalogView(config) {
92
94
  name: product.name,
93
95
  entitlements: [...product.entitlements]
94
96
  }));
95
- const manualEntitlements = [...config.manualEntitlements];
96
- if (products.length === 0 && manualEntitlements.length === 0) return { enabled: false };
97
+ const compOnly = compOnlyEntitlements(config);
98
+ const sold = new Set(products.flatMap((product) => product.entitlements));
99
+ const entitlements = Object.entries(config.entitlements).map(([key, declaration]) => ({
100
+ key,
101
+ name: declaration.name,
102
+ quotas: { ...declaration.quotas },
103
+ features: { ...declaration.features },
104
+ overrideMax: { ...declaration.overrideMax ?? {} },
105
+ sold: sold.has(key)
106
+ }));
107
+ if (products.length === 0 && entitlements.length === 0) return { enabled: false };
97
108
  return {
98
109
  enabled: true,
99
110
  products,
100
- manualEntitlements
111
+ manualEntitlements: compOnly,
112
+ entitlements,
113
+ defaults: config.defaults === void 0 ? null : {
114
+ quotas: { ...config.defaults.quotas },
115
+ features: { ...config.defaults.features }
116
+ }
101
117
  };
102
118
  }
103
119
  /** Project one purchase for a management client. The record's columns, verbatim, with dates as strings. */
104
- function adminPurchaseView(purchase) {
120
+ function adminPurchaseView(purchase, reported) {
105
121
  return {
122
+ quantity: purchase.quantity ?? null,
123
+ ...reported === void 0 ? {} : {
124
+ reportedQuantity: reported?.quantity ?? null,
125
+ reportedAt: reported?.reportedAt.toISOString() ?? null
126
+ },
106
127
  id: purchase.id,
107
128
  subjectType: purchase.subjectType,
108
129
  subjectId: purchase.subjectId,
@@ -130,7 +151,7 @@ function adminPurchaseView(purchase) {
130
151
  * and the gate the adopter's own app calls applies the timestamp on every request. A dashboard that
131
152
  * rendered the flag would disagree with that gate, and the customer would believe the dashboard.
132
153
  */
133
- function adminEntitlementView(row, now) {
154
+ function adminEntitlementView(row, now, unrestricted = false) {
134
155
  const lapsed = row.expiresAt !== null && row.expiresAt.getTime() <= now.getTime();
135
156
  return {
136
157
  subjectType: row.subjectType,
@@ -139,7 +160,67 @@ function adminEntitlementView(row, now) {
139
160
  granted: row.active && !lapsed,
140
161
  expiresAt: row.expiresAt?.toISOString() ?? null,
141
162
  manual: row.manual,
142
- source: row.sourcePurchaseId
163
+ source: row.sourcePurchaseId,
164
+ unrestricted
165
+ };
166
+ }
167
+ /** Project one usage run for a management client. The row's columns, dates as ISO strings. */
168
+ function adminUsageRunView(run) {
169
+ return {
170
+ id: run.id,
171
+ startedAt: run.startedAt.toISOString(),
172
+ finishedAt: run.finishedAt.toISOString(),
173
+ scanned: run.scanned,
174
+ reported: run.reported,
175
+ sampled: run.sampled,
176
+ alreadyReported: run.alreadyReported,
177
+ skipped: run.skipped,
178
+ invalid: run.invalid,
179
+ failed: run.failed,
180
+ findings: run.findings.map((finding) => ({ ...finding }))
181
+ };
182
+ }
183
+ /** Project one subject's override for a management client, or null when it has none. */
184
+ function adminOverrideView(row) {
185
+ return row === void 0 || isEmptyOverride(row) ? null : overrideView(row);
186
+ }
187
+ /** Project one override row for a management client. */
188
+ function overrideView(row) {
189
+ return {
190
+ version: row.version,
191
+ unrestricted: row.unrestricted,
192
+ quotas: { ...row.quotas },
193
+ features: { ...row.features },
194
+ reason: row.reason,
195
+ updatedAt: row.updatedAt.toISOString()
196
+ };
197
+ }
198
+ /**
199
+ * Project every declared allowance for one subject: effective, provenance and inherited per name, plus the
200
+ * ceiling an override of each quota is bounded by for this subject. What an override editor draws its rows
201
+ * from.
202
+ */
203
+ function adminAllowancesView(resolved, ceiling) {
204
+ return {
205
+ quotas: resolved.quotas.map((quota) => ({
206
+ name: quota.name,
207
+ effective: quota.effective.value,
208
+ source: quota.effective.source,
209
+ key: quota.effective.key,
210
+ inherited: quota.inherited.value,
211
+ inheritedSource: quota.inherited.source,
212
+ inheritedKey: quota.inherited.key,
213
+ overrideMax: ceiling(quota.name) ?? null
214
+ })),
215
+ features: resolved.features.map((feature) => ({
216
+ name: feature.name,
217
+ effective: feature.effective.value,
218
+ source: feature.effective.source,
219
+ key: feature.effective.key,
220
+ inherited: feature.inherited.value,
221
+ inheritedSource: feature.inherited.source,
222
+ inheritedKey: feature.inherited.key
223
+ }))
143
224
  };
144
225
  }
145
226
  /**
@@ -169,4 +250,4 @@ function adminReconcileRunView(run) {
169
250
  };
170
251
  }
171
252
  //#endregion
172
- export { adminCatalogView, adminEntitlementView, adminPurchaseView, adminReconcileRunView, entitlementView, purchaseView };
253
+ export { adminAllowancesView, adminCatalogView, adminEntitlementView, adminOverrideView, adminPurchaseView, adminReconcileRunView, adminUsageRunView, entitlementView, overrideView, purchaseView };
@@ -1 +1 @@
1
- {"version":3,"file":"webhookGuard.d.ts","sourceRoot":"","sources":["../../src/http/webhookGuard.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,oBAAoB,CAAC;AAkGhF,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,+FAA+F;IAC/F,YAAY,EAAE,oBAAoB,CAAC;IACnC,kGAAkG;IAClG,UAAU,EAAE,MAAM,CAAC;CACpB;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,eAAe,CAQzE;AAED,qFAAqF;AACrF,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,MAAM,EAAE,cAAc,CAAC;IACvB,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,yEAAyE;IACzE,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAeD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,mBAAmB,GAC3B,iBAAiB,CAAC,YAAY,CAAC,CA6GjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,iBAAiB,GACz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AAW,mBAAmB;IAClC,wEAAwE;IACxE,MAAM,EAAE,cAAc,CAAC;IACvB,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,yEAAyE;IACzE,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAeD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,mBAAmB,GAC3B,iBAAiB,CAAC,YAAY,CAAC,CA6GjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAenH"}
@@ -24,7 +24,7 @@ import { sharedSecretsStore } from "@pithy-sh/secrets/src/sharedSecretsStore";
24
24
  * it.
25
25
  *
26
26
  * `c.req.text()` rather than `c.req.raw.text()`, and that distinction matters. Hono caches its own body reads,
27
- * so the route's `zValidator("json", …)` afterwards is served from the same cache and sees identical bytes.
27
+ * so the route's `validate("json", …)` afterwards is served from the same cache and sees identical bytes.
28
28
  * Reading `c.req.raw` directly would consume the stream and leave the validator with nothing.
29
29
  *
30
30
  * ## Why it persists before it hands off
package/dist/index.d.ts CHANGED
@@ -21,7 +21,8 @@
21
21
  */
22
22
  export { type PaymentsAuditAction, PaymentsAuditActions } from "./audit/actions";
23
23
  export { isPaymentsCapability, PAYMENTS_MIGRATION_ORDER, type PaymentsCapability, type PaymentsOptions, payments, } from "./capability";
24
- export { entitlementsForProduct, grantableEntitlements, PaymentsAppleProduct, type PaymentsCatalogEntry, PaymentsConfig, type PaymentsConfigInput, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, type PaymentsPaddleSettingsInput, PaymentsProduct, type PaymentsProductInput, PaymentsProductType, PaymentsRailToggles, type PaymentsRailTogglesInput, PaymentsStripeProduct, PaymentsStripeSettings, type PaymentsStripeSettingsInput, productForProviderSku, providerProductId, railEnabled, resolveProduct, } from "./config/config";
24
+ export { AllowanceName, declaredFeatureNames, declaredQuotaNames, PaymentsAllowanceDefaults, PaymentsEntitlementDeclaration, type PaymentsEntitlementDeclarationInput, QuotaValue, } from "./config/allowances";
25
+ export { compOnlyEntitlements, entitlementsForProduct, grantableEntitlements, KIT_METERS, type KitMeter, PaymentsAppleProduct, type PaymentsCatalogEntry, PaymentsConfig, type PaymentsConfigInput, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsMeters, PaymentsPaddleProduct, PaymentsPaddleSettings, type PaymentsPaddleSettingsInput, PaymentsProduct, type PaymentsProductInput, PaymentsProductType, PaymentsRailToggles, type PaymentsRailTogglesInput, PaymentsReportCadence, PaymentsReportedBilling, PaymentsStripeProduct, PaymentsStripeSettings, type PaymentsStripeSettingsInput, productForProviderSku, providerProductId, REPORTED_BILLING_RAILS, railEnabled, reportedBillingProblems, reportedProducts, resolveProduct, } from "./config/config";
25
26
  export { PaymentsEntitlement } from "./data/entitlement";
26
27
  export { minorUnitDigits, minorUnitsFromScaled } from "./data/money";
27
28
  export { PaymentsProviderAccount } from "./data/providerAccount";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"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