@pithy-sh/payments 0.4.0 → 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.
- package/README.md +10 -3
- package/dist/admin/coverage.d.ts.map +1 -1
- package/dist/admin/coverage.js +26 -2
- package/dist/admin/read.d.ts +48 -1
- package/dist/admin/read.d.ts.map +1 -1
- package/dist/admin/read.js +89 -2
- package/dist/audit/actions.d.ts +13 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +14 -1
- package/dist/capability.d.ts +33 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +52 -9
- package/dist/client/api.d.ts +19 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +34 -1
- package/dist/client/hooks.d.ts +20 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/hooks.js +40 -2
- package/dist/client/projection.d.ts +29 -0
- package/dist/client/projection.d.ts.map +1 -1
- package/dist/config/allowances.d.ts +71 -0
- package/dist/config/allowances.d.ts.map +1 -0
- package/dist/config/allowances.js +115 -0
- package/dist/config/config.d.ts +155 -9
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +164 -14
- package/dist/data/meterCounter.d.ts +34 -0
- package/dist/data/meterCounter.d.ts.map +1 -0
- package/dist/data/meterCounter.js +33 -0
- package/dist/data/override.d.ts +56 -0
- package/dist/data/override.d.ts.map +1 -0
- package/dist/data/override.js +58 -0
- package/dist/data/period.d.ts +10 -0
- package/dist/data/period.d.ts.map +1 -0
- package/dist/data/period.js +37 -0
- package/dist/data/purchase.d.ts +1 -0
- package/dist/data/purchase.d.ts.map +1 -1
- package/dist/data/purchase.js +1 -0
- package/dist/data/tables.d.ts +17 -1
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +24 -4
- package/dist/data/usageReport.d.ts +68 -0
- package/dist/data/usageReport.d.ts.map +1 -0
- package/dist/data/usageReport.js +55 -0
- package/dist/data/usageRun.d.ts +93 -0
- package/dist/data/usageRun.d.ts.map +1 -0
- package/dist/data/usageRun.js +50 -0
- package/dist/entitlement/allowance.d.ts +100 -0
- package/dist/entitlement/allowance.d.ts.map +1 -0
- package/dist/entitlement/allowance.js +171 -0
- package/dist/entitlement/manual.d.ts +5 -5
- package/dist/entitlement/manual.js +3 -3
- package/dist/entitlement/meter.d.ts +98 -0
- package/dist/entitlement/meter.d.ts.map +1 -0
- package/dist/entitlement/meter.js +177 -0
- package/dist/entitlement/override.d.ts +119 -0
- package/dist/entitlement/override.d.ts.map +1 -0
- package/dist/entitlement/override.js +256 -0
- package/dist/entitlement/resolver.d.ts +2 -1
- package/dist/entitlement/resolver.d.ts.map +1 -1
- package/dist/entitlement/resolver.js +32 -1
- package/dist/error/errors.d.ts +19 -0
- package/dist/error/errors.d.ts.map +1 -1
- package/dist/error/errors.js +35 -2
- package/dist/http/responses.d.ts +367 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +146 -7
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +270 -16
- package/dist/http/schemas.d.ts +54 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +61 -2
- package/dist/http/scopes.d.ts +25 -0
- package/dist/http/scopes.d.ts.map +1 -1
- package/dist/http/scopes.js +60 -1
- package/dist/http/view.d.ts +22 -4
- package/dist/http/view.d.ts.map +1 -1
- package/dist/http/view.js +88 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/migrations/0002_allowances.d.ts +26 -0
- package/dist/migrations/0002_allowances.d.ts.map +1 -0
- package/dist/migrations/0002_allowances.js +62 -0
- package/dist/peer.d.ts +1 -0
- package/dist/peer.d.ts.map +1 -1
- package/dist/projection/event.d.ts +1 -0
- package/dist/projection/event.d.ts.map +1 -1
- package/dist/projection/event.js +1 -0
- package/dist/projection/writer.d.ts.map +1 -1
- package/dist/projection/writer.js +3 -1
- package/dist/rails/contract.d.ts +6 -0
- package/dist/rails/contract.d.ts.map +1 -1
- package/dist/rails/google/playApi.d.ts.map +1 -1
- package/dist/rails/google/playApi.js +2 -0
- package/dist/rails/paddle/objects.d.ts +2 -0
- package/dist/rails/paddle/objects.d.ts.map +1 -1
- package/dist/rails/paddle/objects.js +7 -2
- package/dist/rails/paddle/usage.d.ts +11 -0
- package/dist/rails/paddle/usage.d.ts.map +1 -0
- package/dist/rails/paddle/usage.js +49 -0
- package/dist/rails/quantity.d.ts +12 -0
- package/dist/rails/quantity.d.ts.map +1 -0
- package/dist/rails/quantity.js +16 -0
- package/dist/rails/stripe/checkout.d.ts.map +1 -1
- package/dist/rails/stripe/checkout.js +1 -1
- package/dist/rails/stripe/objects.d.ts.map +1 -1
- package/dist/rails/stripe/objects.js +3 -0
- package/dist/rails/stripe/usage.d.ts +10 -0
- package/dist/rails/stripe/usage.d.ts.map +1 -0
- package/dist/rails/stripe/usage.js +49 -0
- package/dist/usage/pass.d.ts +120 -0
- package/dist/usage/pass.d.ts.map +1 -0
- package/dist/usage/pass.js +363 -0
- package/dist/usage/reporter.d.ts +36 -0
- package/dist/usage/reporter.d.ts.map +1 -0
- package/dist/usage/reporter.js +2 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/dist/workflows/specs.d.ts +28 -0
- package/dist/workflows/specs.d.ts.map +1 -1
- package/dist/workflows/specs.js +26 -1
- package/dist/workflows/usage.d.ts +38 -0
- package/dist/workflows/usage.d.ts.map +1 -0
- package/dist/workflows/usage.js +77 -0
- package/dist/workflows/worker.js +2 -2
- package/docs/entitlements.md +249 -0
- package/docs/lemon-squeezy.md +1 -0
- package/docs/paddle.md +1 -0
- package/package.json +5 -5
- package/pithy.manifest.json +3 -8
- package/src/admin/coverage.ts +28 -0
- package/src/admin/read.ts +173 -1
- package/src/audit/actions.ts +13 -0
- package/src/capability.ts +87 -9
- package/src/client/api.ts +44 -0
- package/src/client/hooks.ts +44 -0
- package/src/client/projection.ts +31 -0
- package/src/config/allowances.ts +211 -0
- package/src/config/config.ts +283 -15
- package/src/data/meterCounter.ts +38 -0
- package/src/data/override.ts +74 -0
- package/src/data/period.ts +53 -0
- package/src/data/purchase.ts +9 -0
- package/src/data/tables.ts +25 -1
- package/src/data/usageReport.ts +64 -0
- package/src/data/usageRun.ts +66 -0
- package/src/entitlement/allowance.ts +213 -0
- package/src/entitlement/manual.ts +6 -6
- package/src/entitlement/meter.ts +252 -0
- package/src/entitlement/override.ts +381 -0
- package/src/entitlement/resolver.ts +43 -2
- package/src/error/errors.ts +44 -1
- package/src/http/responses.ts +305 -4
- package/src/http/routes.ts +365 -11
- package/src/http/schemas.ts +139 -1
- package/src/http/scopes.ts +68 -0
- package/src/http/view.ts +112 -7
- package/src/index.ts +18 -0
- package/src/migrations/0002_allowances.ts +149 -0
- package/src/projection/event.ts +9 -0
- package/src/projection/writer.ts +4 -0
- package/src/rails/contract.ts +6 -0
- package/src/rails/google/playApi.ts +2 -0
- package/src/rails/paddle/fixtures/subscription-charge.json +19 -0
- package/src/rails/paddle/objects.ts +6 -0
- package/src/rails/paddle/usage.ts +66 -0
- package/src/rails/quantity.ts +14 -0
- package/src/rails/stripe/checkout.ts +3 -1
- package/src/rails/stripe/fixtures/meter-event-created.json +12 -0
- package/src/rails/stripe/objects.ts +4 -0
- package/src/rails/stripe/usage.ts +61 -0
- package/src/usage/pass.ts +539 -0
- package/src/usage/reporter.ts +38 -0
- package/src/version.generated.ts +1 -1
- package/src/workflows/specs.ts +34 -0
- package/src/workflows/usage.ts +97 -0
package/dist/http/schemas.d.ts
CHANGED
|
@@ -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
|
*
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/http/schemas.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8DxB,eAAO,MAAM,kBAAkB;;;;;;;;;iBAa5B,CAAC;AACJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,eAAO,MAAM,cAAc;;;;;;;;;iBAaqF,CAAC;AACjH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;iBAS4D,CAAC;AAClG,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;;;;;;iBAgBoD,CAAC;AACjF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;;iBAUiD,CAAC;AACxF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEnF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B;;iBAA4B,CAAC;AACpE,MAAM,MAAM,0BAA0B,GAAG,yBAAyB,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;;;;iBAMoC,CAAC;AAC3E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAA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ACnE,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"}
|
package/dist/http/schemas.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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";
|
|
@@ -260,7 +261,7 @@ const PaddleWebhookNotification = z.object({
|
|
|
260
261
|
const EntitlementGrantRequest = z.object({
|
|
261
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."),
|
|
262
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."),
|
|
263
|
-
entitlement: EntitlementKey.describe("The entitlement key to grant, as gating code names it. Not a store SKU. It must be one
|
|
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."),
|
|
264
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.")
|
|
265
266
|
}).describe("A control-plane request to grant one entitlement to one subject, with no purchase behind it.");
|
|
266
267
|
/**
|
|
@@ -276,6 +277,54 @@ const EntitlementRevokeRequest = z.object({
|
|
|
276
277
|
entitlement: EntitlementKey.describe("The entitlement key to revoke, as gating code names it.")
|
|
277
278
|
}).describe("A control-plane request to revoke one entitlement from one subject, effective immediately.");
|
|
278
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
|
+
/**
|
|
279
328
|
* ## The management read queries
|
|
280
329
|
*
|
|
281
330
|
* The `Admin*` shapes below belong to the **control-plane reads**, which take no bodies at all: there is
|
|
@@ -336,12 +385,22 @@ const AdminEntitlementsQuery = z.object({
|
|
|
336
385
|
cursor: Cursor,
|
|
337
386
|
limit: Limit
|
|
338
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.");
|
|
339
394
|
const AdminReconcileRunsQuery = z.object({
|
|
340
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."),
|
|
341
396
|
environment: PurchaseEnvironment.optional().describe("Restrict to one store environment — the sandbox host and the production host each keep their own passes."),
|
|
342
397
|
cursor: Cursor,
|
|
343
398
|
limit: Limit
|
|
344
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.");
|
|
345
404
|
/**
|
|
346
405
|
* The two path segments on the per-subject management read: `…/entitlements/:subjectType/:subjectId`.
|
|
347
406
|
*
|
|
@@ -376,4 +435,4 @@ const AdminSubjectParam = z.object({
|
|
|
376
435
|
*/
|
|
377
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.");
|
|
378
437
|
//#endregion
|
|
379
|
-
export { AdminDiscountsQuery, AdminEntitlementsQuery, AdminPurchasesQuery, AdminReconcileRunsQuery, AdminSubjectParam, AdminSubscriptionsQuery, AppleWebhookNotification, CheckoutRequest, DiscountCreateRequest, EntitlementGrantRequest, EntitlementRevokeRequest, GoogleWebhookNotification, LemonSqueezyWebhookNotification, PaddleResumeQuery, 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 };
|
package/dist/http/scopes.d.ts
CHANGED
|
@@ -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;AACH,eAAO,MAAM,4BAA4B,EAAE,iBAA6C,CAAC;AAEzF;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,EAAE,iBAAiD,CAAC;AAEjG;;;GAGG;AACH,eAAO,MAAM,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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AElF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,iBAAiB,EAerE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CA6GlE"}
|
package/dist/http/scopes.js
CHANGED
|
@@ -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 };
|
package/dist/http/view.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
*
|
package/dist/http/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/http/view.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/http/view.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH;;;;;GAKG;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|
|
|
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
|
|
96
|
-
|
|
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 };
|
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 {
|
|
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";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;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
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import { PAYMENTS_RAILS, PaymentsRail } from "./data/rail.js";
|
|
4
4
|
import { PaymentsSubject, PaymentsSubjectType, decodeSubjectReference, encodeSubjectReference, sameSubject } from "./data/subject.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AllowanceName, PaymentsAllowanceDefaults, PaymentsEntitlementDeclaration, QuotaValue, declaredFeatureNames, declaredQuotaNames } from "./config/allowances.js";
|
|
6
|
+
import { KIT_METERS, PaymentsAppleProduct, PaymentsConfig, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsMeters, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsRailToggles, PaymentsReportCadence, PaymentsReportedBilling, PaymentsStripeProduct, PaymentsStripeSettings, REPORTED_BILLING_RAILS, compOnlyEntitlements, entitlementsForProduct, grantableEntitlements, productForProviderSku, providerProductId, railEnabled, reportedBillingProblems, reportedProducts, resolveProduct } from "./config/config.js";
|
|
6
7
|
import { PaymentsEntitlement } from "./data/entitlement.js";
|
|
7
8
|
import { PaymentsProviderAccount } from "./data/providerAccount.js";
|
|
8
9
|
import { ACCESS_GRANTING_STATUSES, PurchaseStatus, grantingStatuses, statusGrantsAccess } from "./data/status.js";
|
|
@@ -43,4 +44,4 @@ import { PAYMENTS_RECONCILE_KEY, triggerPaymentsReconcile } from "./http/dispatc
|
|
|
43
44
|
import { paymentsWorkerName, resolvePaymentsConfig } from "./provision/resolvePaymentsConfig.js";
|
|
44
45
|
import { batchedRailAccess } from "./workflows/railAccess.js";
|
|
45
46
|
import { reconcilePayments } from "./workflows/reconcile.js";
|
|
46
|
-
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, RECONCILE_RUN_RETENTION_DAYS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, createPaymentsEntitlementResolver, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, isUnimplementedSubject, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, requireAuth, requireImplementedSubject, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, unimplementedSubject, webhookEventAwaitsOwner };
|
|
47
|
+
export { ACCESS_GRANTING_STATUSES, APPLE_API_AUDIENCE, APPLE_API_BASES, APPLE_ROOT_CERTIFICATES, AllowanceName, AppleSubscriptionStatuses, AppleWebhookNotification, CheckoutRequest, DEFAULT_EXPIRING_WITHIN_SECONDS, DEFAULT_STALE_AFTER_SECONDS, EntitlementGrantRequest, EntitlementRevokeRequest, GOOGLE_JWKS_URL, GOOGLE_OIDC_ISSUERS, GoogleJwk, GoogleJwks, GoogleWebhookNotification, KIT_METERS, ORPHAN_REPAIR_LIMIT, PAYMENTS_CAPABILITY, PAYMENTS_CATALOG_READ_SCOPE, PAYMENTS_CONTROL_PLANE_SCOPES, PAYMENTS_ENTITLEMENTS_TABLE, PAYMENTS_ENTITLEMENT_GRANT_SCOPE, PAYMENTS_ENTITLEMENT_PROVIDER, PAYMENTS_ENTITLEMENT_REVOKE_SCOPE, PAYMENTS_MIGRATION_ORDER, PAYMENTS_PROVIDER_ACCOUNTS_TABLE, PAYMENTS_PROVIDER_SECRET, PAYMENTS_PURCHASES_TABLE, PAYMENTS_RAILS, PAYMENTS_RECONCILE_KEY, PAYMENTS_RECONCILE_RUNS_TABLE, PAYMENTS_WEBHOOK_EVENTS_TABLE, PaymentsAllowanceDefaults, PaymentsAppleCredentials, PaymentsAppleProduct, PaymentsAuditActions, PaymentsConfig, PaymentsEntitlement, PaymentsEntitlementDeclaration, PaymentsGoogleCredentials, PaymentsGoogleProduct, PaymentsGrants, PaymentsLedgerGrant, PaymentsLemonSqueezyProduct, PaymentsLemonSqueezySettings, PaymentsMeters, PaymentsPaddleProduct, PaymentsPaddleSettings, PaymentsProduct, PaymentsProductType, PaymentsProviderAccount, PaymentsProviderCredentials, PaymentsPurchase, PaymentsRail, PaymentsRailToggles, PaymentsReconcileParams, PaymentsReconcileRun, PaymentsReportCadence, PaymentsReportedBilling, PaymentsStripeCredentials, PaymentsStripeProduct, PaymentsStripeSettings, PaymentsSubject, PaymentsSubjectType, PaymentsWebhookEvent, ProviderEvent, PurchaseEnvironment, PurchaseStatus, PurchaseSubmission, QuotaValue, RECONCILE_RUN_RETENTION_DAYS, REPORTED_BILLING_RAILS, RestoreRequest, STRIPE_API_VERSION, STRIPE_METADATA_ACCOUNT_REFERENCE, STRIPE_METADATA_PRICE, StripeWebhookNotification, WEBHOOK_EVENT_ORPHANED, appleSubscriptionStatus, applyGrants, authenticatedUserSubject, batchedRailAccess, clawbackGrants, clawbackRef, compOnlyEntitlements, createPaymentsEntitlementResolver, declaredFeatureNames, declaredQuotaNames, decodeSubjectReference, encodeSubjectReference, entitlementsForProduct, fulfillPurchase, grantEntitlement, grantRef, grantableEntitlements, grantingStatuses, implementedRails, installEntitlementResolver, isCheckoutRail, isPaymentsCapability, isUnimplementedSubject, ledgerGrantFor, linkProviderAccount, minorUnitDigits, minorUnitsFromScaled, mintAppleApiToken, noteIsRepairable, noteText, openPaymentsLedger, payments, paymentsDatabase, paymentsExampleSeed, paymentsSecretsRegistry, paymentsTables, paymentsWorkerName, paymentsWorkflowRegistry, paymentsWorkflows, productForProviderSku, projectPurchase, providerAccountForSubject, providerProductId, purchaseIsPaid, railCredentials, railEnabled, reconcilePayments, recordReconcileRun, registerPaymentsRoutes, repairOrphanedEvents, reportedBillingProblems, reportedProducts, requireAuth, requireImplementedSubject, requirePaymentsSubject, resolveEntitlements, resolveNotificationOwner, resolvePaymentsConfig, resolvePaymentsSubject, resolveProduct, resolveRailProvider, revokeEntitlement, sameSubject, statusGrantsAccess, triggerPaymentsReconcile, unimplementedSubject, webhookEventAwaitsOwner };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { Migration } from "kysely/migration";
|
|
4
|
+
/**
|
|
5
|
+
* Allowances, meters and reported usage: four tables and one column.
|
|
6
|
+
*
|
|
7
|
+
* **A new migration, because `0001` is history.** Every payments chain has been running since 0.1.0, and
|
|
8
|
+
* reshaping `0001` would reshape a database somebody is already running. So everything lands here, with a
|
|
9
|
+
* tested `down`.
|
|
10
|
+
*
|
|
11
|
+
* - `pithy_payments_overrides` — one subject's override, `UNIQUE (subjectType, subjectId)`. Keyed on the
|
|
12
|
+
* subject rather than on an entitlement key, so it survives a tier change.
|
|
13
|
+
* - `pithy_payments_meter_counters` — one subject's use of one kit meter in one period,
|
|
14
|
+
* `UNIQUE (subjectType, subjectId, meter, periodStart)`. The period is half the key, which is what makes a
|
|
15
|
+
* new period start at zero with nothing to reset it.
|
|
16
|
+
* - `pithy_payments_usage_reports` — one reported period of one quantity-billed subscription,
|
|
17
|
+
* `UNIQUE (rail, providerSubscriptionId, period)`. The key is the idempotency: a replayed run finds the row.
|
|
18
|
+
* - `pithy_payments_usage_runs` — one reporting pass, its tally kept, the way reconcile runs are.
|
|
19
|
+
* - `pithy_payments_purchases.quantity` — how many were bought, as the store states it. Nullable, because
|
|
20
|
+
* rows written before this did not record one and no store is asked again to invent it.
|
|
21
|
+
*
|
|
22
|
+
* The subject kind is closed with a `CHECK` on every subject-bearing table, as `0001` closes it, and every
|
|
23
|
+
* count a row holds is checked non-negative: a negative usage is a bug in the writer, never a fact.
|
|
24
|
+
*/
|
|
25
|
+
export declare const payments_0002_allowances: Migration;
|
|
26
|
+
//# sourceMappingURL=0002_allowances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0002_allowances.d.ts","sourceRoot":"","sources":["../../src/migrations/0002_allowances.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAyHtC,CAAC"}
|