@tallwatch/contracts 0.1.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 +36 -0
- package/dist/alerting/alert-channels.d.ts +183 -0
- package/dist/alerting/alert-channels.d.ts.map +1 -0
- package/dist/alerting/alert-channels.js +114 -0
- package/dist/alerting/alert-channels.js.map +1 -0
- package/dist/alerting/alert-dispatches.d.ts +216 -0
- package/dist/alerting/alert-dispatches.d.ts.map +1 -0
- package/dist/alerting/alert-dispatches.js +78 -0
- package/dist/alerting/alert-dispatches.js.map +1 -0
- package/dist/alerting/channel-connect.d.ts +25 -0
- package/dist/alerting/channel-connect.d.ts.map +1 -0
- package/dist/alerting/channel-connect.js +40 -0
- package/dist/alerting/channel-connect.js.map +1 -0
- package/dist/alerting/escalation-levels.d.ts +28 -0
- package/dist/alerting/escalation-levels.d.ts.map +1 -0
- package/dist/alerting/escalation-levels.js +21 -0
- package/dist/alerting/escalation-levels.js.map +1 -0
- package/dist/alerting/escalation-policies.d.ts +85 -0
- package/dist/alerting/escalation-policies.d.ts.map +1 -0
- package/dist/alerting/escalation-policies.js +36 -0
- package/dist/alerting/escalation-policies.js.map +1 -0
- package/dist/alerting/index.d.ts +10 -0
- package/dist/alerting/index.d.ts.map +1 -0
- package/dist/alerting/index.js +10 -0
- package/dist/alerting/index.js.map +1 -0
- package/dist/alerting/on-call-rotations.d.ts +40 -0
- package/dist/alerting/on-call-rotations.d.ts.map +1 -0
- package/dist/alerting/on-call-rotations.js +26 -0
- package/dist/alerting/on-call-rotations.js.map +1 -0
- package/dist/alerting/on-call.d.ts +81 -0
- package/dist/alerting/on-call.d.ts.map +1 -0
- package/dist/alerting/on-call.js +40 -0
- package/dist/alerting/on-call.js.map +1 -0
- package/dist/alerting/slack-actions.d.ts +26 -0
- package/dist/alerting/slack-actions.d.ts.map +1 -0
- package/dist/alerting/slack-actions.js +44 -0
- package/dist/alerting/slack-actions.js.map +1 -0
- package/dist/alerting/webhook-template.d.ts +10 -0
- package/dist/alerting/webhook-template.d.ts.map +1 -0
- package/dist/alerting/webhook-template.js +69 -0
- package/dist/alerting/webhook-template.js.map +1 -0
- package/dist/alerting/webhooks.d.ts +72 -0
- package/dist/alerting/webhooks.d.ts.map +1 -0
- package/dist/alerting/webhooks.js +49 -0
- package/dist/alerting/webhooks.js.map +1 -0
- package/dist/api-keys.d.ts +59 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +31 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/api-response.d.ts +21 -0
- package/dist/api-response.d.ts.map +1 -0
- package/dist/api-response.js +20 -0
- package/dist/api-response.js.map +1 -0
- package/dist/audit.d.ts +126 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +129 -0
- package/dist/audit.js.map +1 -0
- package/dist/billing/billing-catalog.d.ts +53 -0
- package/dist/billing/billing-catalog.d.ts.map +1 -0
- package/dist/billing/billing-catalog.js +121 -0
- package/dist/billing/billing-catalog.js.map +1 -0
- package/dist/billing/billing.d.ts +129 -0
- package/dist/billing/billing.d.ts.map +1 -0
- package/dist/billing/billing.js +68 -0
- package/dist/billing/billing.js.map +1 -0
- package/dist/billing/entitlements.d.ts +90 -0
- package/dist/billing/entitlements.d.ts.map +1 -0
- package/dist/billing/entitlements.js +107 -0
- package/dist/billing/entitlements.js.map +1 -0
- package/dist/billing/index.d.ts +5 -0
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +5 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/retention.d.ts +8 -0
- package/dist/billing/retention.d.ts.map +1 -0
- package/dist/billing/retention.js +43 -0
- package/dist/billing/retention.js.map +1 -0
- package/dist/brand.d.ts +3 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +4 -0
- package/dist/brand.js.map +1 -0
- package/dist/cli-device.d.ts +35 -0
- package/dist/cli-device.d.ts.map +1 -0
- package/dist/cli-device.js +41 -0
- package/dist/cli-device.js.map +1 -0
- package/dist/common.d.ts +63 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +91 -0
- package/dist/common.js.map +1 -0
- package/dist/http-url.d.ts +4 -0
- package/dist/http-url.d.ts.map +1 -0
- package/dist/http-url.js +63 -0
- package/dist/http-url.js.map +1 -0
- package/dist/incidents/incident-projection.d.ts +16 -0
- package/dist/incidents/incident-projection.d.ts.map +1 -0
- package/dist/incidents/incident-projection.js +25 -0
- package/dist/incidents/incident-projection.js.map +1 -0
- package/dist/incidents/incident-status-posts.d.ts +15 -0
- package/dist/incidents/incident-status-posts.d.ts.map +1 -0
- package/dist/incidents/incident-status-posts.js +15 -0
- package/dist/incidents/incident-status-posts.js.map +1 -0
- package/dist/incidents/incident-timeline.d.ts +251 -0
- package/dist/incidents/incident-timeline.d.ts.map +1 -0
- package/dist/incidents/incident-timeline.js +77 -0
- package/dist/incidents/incident-timeline.js.map +1 -0
- package/dist/incidents/incidents.d.ts +628 -0
- package/dist/incidents/incidents.d.ts.map +1 -0
- package/dist/incidents/incidents.js +140 -0
- package/dist/incidents/incidents.js.map +1 -0
- package/dist/incidents/index.d.ts +5 -0
- package/dist/incidents/index.d.ts.map +1 -0
- package/dist/incidents/index.js +5 -0
- package/dist/incidents/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/maintenance.d.ts +21 -0
- package/dist/maintenance.d.ts.map +1 -0
- package/dist/maintenance.js +25 -0
- package/dist/maintenance.js.map +1 -0
- package/dist/marketing.d.ts +15 -0
- package/dist/marketing.d.ts.map +1 -0
- package/dist/marketing.js +13 -0
- package/dist/marketing.js.map +1 -0
- package/dist/monitors/availability.d.ts +50 -0
- package/dist/monitors/availability.d.ts.map +1 -0
- package/dist/monitors/availability.js +26 -0
- package/dist/monitors/availability.js.map +1 -0
- package/dist/monitors/check-observation.d.ts +70 -0
- package/dist/monitors/check-observation.d.ts.map +1 -0
- package/dist/monitors/check-observation.js +38 -0
- package/dist/monitors/check-observation.js.map +1 -0
- package/dist/monitors/index.d.ts +12 -0
- package/dist/monitors/index.d.ts.map +1 -0
- package/dist/monitors/index.js +12 -0
- package/dist/monitors/index.js.map +1 -0
- package/dist/monitors/monitor-configs.d.ts +239 -0
- package/dist/monitors/monitor-configs.d.ts.map +1 -0
- package/dist/monitors/monitor-configs.js +135 -0
- package/dist/monitors/monitor-configs.js.map +1 -0
- package/dist/monitors/monitor-list-item.d.ts +30 -0
- package/dist/monitors/monitor-list-item.d.ts.map +1 -0
- package/dist/monitors/monitor-list-item.js +16 -0
- package/dist/monitors/monitor-list-item.js.map +1 -0
- package/dist/monitors/monitor-target.d.ts +3 -0
- package/dist/monitors/monitor-target.d.ts.map +1 -0
- package/dist/monitors/monitor-target.js +17 -0
- package/dist/monitors/monitor-target.js.map +1 -0
- package/dist/monitors/monitor-view.d.ts +48 -0
- package/dist/monitors/monitor-view.d.ts.map +1 -0
- package/dist/monitors/monitor-view.js +20 -0
- package/dist/monitors/monitor-view.js.map +1 -0
- package/dist/monitors/monitors-crud.d.ts +275 -0
- package/dist/monitors/monitors-crud.d.ts.map +1 -0
- package/dist/monitors/monitors-crud.js +126 -0
- package/dist/monitors/monitors-crud.js.map +1 -0
- package/dist/monitors/monitors.d.ts +153 -0
- package/dist/monitors/monitors.d.ts.map +1 -0
- package/dist/monitors/monitors.js +35 -0
- package/dist/monitors/monitors.js.map +1 -0
- package/dist/monitors/probes.d.ts +313 -0
- package/dist/monitors/probes.d.ts.map +1 -0
- package/dist/monitors/probes.js +67 -0
- package/dist/monitors/probes.js.map +1 -0
- package/dist/monitors/rollups.d.ts +111 -0
- package/dist/monitors/rollups.d.ts.map +1 -0
- package/dist/monitors/rollups.js +39 -0
- package/dist/monitors/rollups.js.map +1 -0
- package/dist/monitors/test-check.d.ts +69 -0
- package/dist/monitors/test-check.d.ts.map +1 -0
- package/dist/monitors/test-check.js +11 -0
- package/dist/monitors/test-check.js.map +1 -0
- package/dist/pagination.d.ts +36 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +27 -0
- package/dist/pagination.js.map +1 -0
- package/dist/projects.d.ts +45 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +23 -0
- package/dist/projects.js.map +1 -0
- package/dist/status-pages/index.d.ts +7 -0
- package/dist/status-pages/index.d.ts.map +1 -0
- package/dist/status-pages/index.js +7 -0
- package/dist/status-pages/index.js.map +1 -0
- package/dist/status-pages/public-status-page.d.ts +453 -0
- package/dist/status-pages/public-status-page.d.ts.map +1 -0
- package/dist/status-pages/public-status-page.js +93 -0
- package/dist/status-pages/public-status-page.js.map +1 -0
- package/dist/status-pages/slug-host.d.ts +3 -0
- package/dist/status-pages/slug-host.d.ts.map +1 -0
- package/dist/status-pages/slug-host.js +12 -0
- package/dist/status-pages/slug-host.js.map +1 -0
- package/dist/status-pages/status-overall.d.ts +20 -0
- package/dist/status-pages/status-overall.d.ts.map +1 -0
- package/dist/status-pages/status-overall.js +42 -0
- package/dist/status-pages/status-overall.js.map +1 -0
- package/dist/status-pages/status-page-config.d.ts +215 -0
- package/dist/status-pages/status-page-config.d.ts.map +1 -0
- package/dist/status-pages/status-page-config.js +124 -0
- package/dist/status-pages/status-page-config.js.map +1 -0
- package/dist/status-pages/status-page-incidents.d.ts +132 -0
- package/dist/status-pages/status-page-incidents.d.ts.map +1 -0
- package/dist/status-pages/status-page-incidents.js +66 -0
- package/dist/status-pages/status-page-incidents.js.map +1 -0
- package/dist/status-pages/status-page-subscribers.d.ts +62 -0
- package/dist/status-pages/status-page-subscribers.d.ts.map +1 -0
- package/dist/status-pages/status-page-subscribers.js +30 -0
- package/dist/status-pages/status-page-subscribers.js.map +1 -0
- package/package.json +127 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PlanIdSchema: z.ZodEnum<{
|
|
3
|
+
free: "free";
|
|
4
|
+
pro: "pro";
|
|
5
|
+
business: "business";
|
|
6
|
+
}>;
|
|
7
|
+
export type PlanId = z.infer<typeof PlanIdSchema>;
|
|
8
|
+
export declare const PaidPlanIdSchema: z.ZodEnum<{
|
|
9
|
+
pro: "pro";
|
|
10
|
+
business: "business";
|
|
11
|
+
}>;
|
|
12
|
+
export type PaidPlanId = z.infer<typeof PaidPlanIdSchema>;
|
|
13
|
+
export declare const BillingIntervalSchema: z.ZodEnum<{
|
|
14
|
+
month: "month";
|
|
15
|
+
year: "year";
|
|
16
|
+
}>;
|
|
17
|
+
export type BillingInterval = z.infer<typeof BillingIntervalSchema>;
|
|
18
|
+
export declare const UNLIMITED = -1;
|
|
19
|
+
export declare function formatLimit(n: number): string;
|
|
20
|
+
export type PlanLimits = {
|
|
21
|
+
monitors: number;
|
|
22
|
+
teamMembers: number;
|
|
23
|
+
regions: number;
|
|
24
|
+
minIntervalSec: number;
|
|
25
|
+
retentionDays: number;
|
|
26
|
+
statusPages: number;
|
|
27
|
+
customDomain: boolean;
|
|
28
|
+
sso: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type PlanDefinition = {
|
|
31
|
+
id: PlanId;
|
|
32
|
+
name: string;
|
|
33
|
+
blurb: string;
|
|
34
|
+
/** USD per month on the monthly plan. */
|
|
35
|
+
monthlyUsd: number;
|
|
36
|
+
/** USD billed once per year. */
|
|
37
|
+
annualUsd: number;
|
|
38
|
+
features: string[];
|
|
39
|
+
limits: PlanLimits;
|
|
40
|
+
};
|
|
41
|
+
export declare const PLAN_CATALOG: Record<PlanId, PlanDefinition>;
|
|
42
|
+
export declare const PLAN_ORDER: PlanId[];
|
|
43
|
+
export declare function priceEnvVar(plan: PaidPlanId, interval: BillingInterval): string;
|
|
44
|
+
export declare function annualSavingsPercent(plan: PlanId): number;
|
|
45
|
+
export type PlanChangeKind = "upgrade" | "downgrade" | "lateral";
|
|
46
|
+
export declare function planChangeKind(from: {
|
|
47
|
+
plan: PaidPlanId;
|
|
48
|
+
interval: BillingInterval;
|
|
49
|
+
}, to: {
|
|
50
|
+
plan: PaidPlanId;
|
|
51
|
+
interval: BillingInterval;
|
|
52
|
+
}): PlanChangeKind;
|
|
53
|
+
//# sourceMappingURL=billing-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing-catalog.d.ts","sourceRoot":"","sources":["../../src/billing/billing-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,YAAY;;;;EAAsC,CAAC;AAChE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,gBAAgB;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,qBAAqB;;;EAA4B,CAAC;AAC/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAQF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA+EvD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,EAAgC,CAAC;AAEhE,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,eAAe,GACxB,MAAM,CAGR;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAWjE,wBAAgB,cAAc,CAC5B,IAAI,EAAE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,EACrD,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,GAClD,cAAc,CAIhB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// The DB organization.plan enum also carries a dead `team` value (see
|
|
3
|
+
// packages/db/src/schema/auth-org.ts); billing never reads or writes it, so it
|
|
4
|
+
// is intentionally absent here. readEntitlement coerces any stray team -> free.
|
|
5
|
+
export const PlanIdSchema = z.enum(["free", "pro", "business"]);
|
|
6
|
+
export const PaidPlanIdSchema = z.enum(["pro", "business"]);
|
|
7
|
+
export const BillingIntervalSchema = z.enum(["month", "year"]);
|
|
8
|
+
export const UNLIMITED = -1;
|
|
9
|
+
export function formatLimit(n) {
|
|
10
|
+
return n === UNLIMITED ? "Unlimited" : n.toLocaleString("en-US");
|
|
11
|
+
}
|
|
12
|
+
// Prices are the published amounts (Pro $14.99/mo, Business $24.99/mo; annual is
|
|
13
|
+
// ~20% less, billed once a year). The real charge comes from the Stripe Price id
|
|
14
|
+
// (priceEnvVar), so the owner MUST create Stripe Prices that match these.
|
|
15
|
+
// `sso` is a catalog field, not enforced. `retentionDays` clamps charts,
|
|
16
|
+
// availability windows, and public uptime strips at query time (heap is
|
|
17
|
+
// still unbounded — P1-RES-01).
|
|
18
|
+
export const PLAN_CATALOG = {
|
|
19
|
+
free: {
|
|
20
|
+
id: "free",
|
|
21
|
+
name: "Free",
|
|
22
|
+
blurb: "Side projects and a first taste of consensus monitoring.",
|
|
23
|
+
monthlyUsd: 0,
|
|
24
|
+
annualUsd: 0,
|
|
25
|
+
features: [
|
|
26
|
+
"10 monitors with multi-region consensus",
|
|
27
|
+
"Checks every minute from 3 regions",
|
|
28
|
+
"Up to 3 team members",
|
|
29
|
+
"1 status page, custom domain included",
|
|
30
|
+
"Email and Slack alerts",
|
|
31
|
+
"7 days of check history",
|
|
32
|
+
"On-call rotations + escalation, email support",
|
|
33
|
+
],
|
|
34
|
+
limits: {
|
|
35
|
+
monitors: 10,
|
|
36
|
+
teamMembers: 3,
|
|
37
|
+
regions: 3,
|
|
38
|
+
minIntervalSec: 60,
|
|
39
|
+
retentionDays: 7,
|
|
40
|
+
statusPages: 1,
|
|
41
|
+
customDomain: true,
|
|
42
|
+
sso: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
pro: {
|
|
46
|
+
id: "pro",
|
|
47
|
+
name: "Pro",
|
|
48
|
+
blurb: "Growing teams shipping to production.",
|
|
49
|
+
monthlyUsd: 14.99,
|
|
50
|
+
annualUsd: 143.88,
|
|
51
|
+
features: [
|
|
52
|
+
"Everything in Free",
|
|
53
|
+
"100 monitors, up to 10 team members",
|
|
54
|
+
"30-second checks, all regions + tuning",
|
|
55
|
+
"All 7 alert channels",
|
|
56
|
+
"3 status pages, custom domain",
|
|
57
|
+
"90 days of check history",
|
|
58
|
+
"Programmable webhook payloads",
|
|
59
|
+
],
|
|
60
|
+
limits: {
|
|
61
|
+
monitors: 100,
|
|
62
|
+
teamMembers: 10,
|
|
63
|
+
regions: 6,
|
|
64
|
+
minIntervalSec: 30,
|
|
65
|
+
retentionDays: 90,
|
|
66
|
+
statusPages: 3,
|
|
67
|
+
customDomain: true,
|
|
68
|
+
sso: false,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
business: {
|
|
72
|
+
id: "business",
|
|
73
|
+
name: "Business",
|
|
74
|
+
blurb: "Teams that run many services and answer for downtime.",
|
|
75
|
+
monthlyUsd: 24.99,
|
|
76
|
+
annualUsd: 239.88,
|
|
77
|
+
features: [
|
|
78
|
+
"Everything in Pro",
|
|
79
|
+
"Unlimited monitors (fair use)",
|
|
80
|
+
"Unlimited team members and status pages",
|
|
81
|
+
"Remove Tallwatch branding",
|
|
82
|
+
"365 days of check history",
|
|
83
|
+
"Priority support",
|
|
84
|
+
"Early access to API, MCP, and cross-team rollup",
|
|
85
|
+
],
|
|
86
|
+
limits: {
|
|
87
|
+
monitors: UNLIMITED,
|
|
88
|
+
teamMembers: UNLIMITED,
|
|
89
|
+
regions: 6,
|
|
90
|
+
minIntervalSec: 30,
|
|
91
|
+
retentionDays: 365,
|
|
92
|
+
statusPages: UNLIMITED,
|
|
93
|
+
customDomain: true,
|
|
94
|
+
sso: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
export const PLAN_ORDER = ["free", "pro", "business"];
|
|
99
|
+
export function priceEnvVar(plan, interval) {
|
|
100
|
+
const suffix = interval === "year" ? "YEARLY" : "MONTHLY";
|
|
101
|
+
return `STRIPE_PRICE_${plan.toUpperCase()}_${suffix}`;
|
|
102
|
+
}
|
|
103
|
+
export function annualSavingsPercent(plan) {
|
|
104
|
+
const { monthlyUsd, annualUsd } = PLAN_CATALOG[plan];
|
|
105
|
+
if (monthlyUsd <= 0)
|
|
106
|
+
return 0;
|
|
107
|
+
return Math.round((1 - annualUsd / (monthlyUsd * 12)) * 100);
|
|
108
|
+
}
|
|
109
|
+
const PLAN_TIER = { pro: 1, business: 2 };
|
|
110
|
+
// Rank by tier first (business > pro), then interval commitment (year > month),
|
|
111
|
+
// so "moving up" (higher tier, or to annual) is an upgrade and the inverse a
|
|
112
|
+
// downgrade. Keyed on tier/interval, not price, so it survives price edits.
|
|
113
|
+
function planRank(plan, interval) {
|
|
114
|
+
return PLAN_TIER[plan] * 10 + (interval === "year" ? 1 : 0);
|
|
115
|
+
}
|
|
116
|
+
export function planChangeKind(from, to) {
|
|
117
|
+
const a = planRank(from.plan, from.interval);
|
|
118
|
+
const b = planRank(to.plan, to.interval);
|
|
119
|
+
return b > a ? "upgrade" : b < a ? "downgrade" : "lateral";
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=billing-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing-catalog.js","sourceRoot":"","sources":["../../src/billing/billing-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sEAAsE;AACtE,+EAA+E;AAC/E,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAGhE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAG5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAG/D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC;AAE5B,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAyBD,iFAAiF;AACjF,iFAAiF;AACjF,0EAA0E;AAC1E,yEAAyE;AACzE,wEAAwE;AAC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C;AAED,MAAM,UAAU,cAAc,CAC5B,IAAqD,EACrD,EAAmD;IAEnD,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export * from "./billing-catalog.js";
|
|
3
|
+
export * from "./entitlements.js";
|
|
4
|
+
export declare const SubscriptionStatusSchema: z.ZodEnum<{
|
|
5
|
+
active: "active";
|
|
6
|
+
paused: "paused";
|
|
7
|
+
trialing: "trialing";
|
|
8
|
+
past_due: "past_due";
|
|
9
|
+
canceled: "canceled";
|
|
10
|
+
incomplete: "incomplete";
|
|
11
|
+
incomplete_expired: "incomplete_expired";
|
|
12
|
+
unpaid: "unpaid";
|
|
13
|
+
}>;
|
|
14
|
+
export type SubscriptionStatus = z.infer<typeof SubscriptionStatusSchema>;
|
|
15
|
+
export declare const PaymentMethodSchema: z.ZodObject<{
|
|
16
|
+
brand: z.ZodString;
|
|
17
|
+
last4: z.ZodNullable<z.ZodString>;
|
|
18
|
+
exp_month: z.ZodNullable<z.ZodNumber>;
|
|
19
|
+
exp_year: z.ZodNullable<z.ZodNumber>;
|
|
20
|
+
email: z.ZodNullable<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
|
|
23
|
+
export declare const CheckoutRequestSchema: z.ZodObject<{
|
|
24
|
+
plan: z.ZodEnum<{
|
|
25
|
+
pro: "pro";
|
|
26
|
+
business: "business";
|
|
27
|
+
}>;
|
|
28
|
+
interval: z.ZodEnum<{
|
|
29
|
+
month: "month";
|
|
30
|
+
year: "year";
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type CheckoutRequest = z.infer<typeof CheckoutRequestSchema>;
|
|
34
|
+
export declare const CheckoutResponseSchema: z.ZodObject<{
|
|
35
|
+
client_secret: z.ZodString;
|
|
36
|
+
amount: z.ZodNumber;
|
|
37
|
+
currency: z.ZodString;
|
|
38
|
+
plan: z.ZodEnum<{
|
|
39
|
+
pro: "pro";
|
|
40
|
+
business: "business";
|
|
41
|
+
}>;
|
|
42
|
+
interval: z.ZodEnum<{
|
|
43
|
+
month: "month";
|
|
44
|
+
year: "year";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type CheckoutResponse = z.infer<typeof CheckoutResponseSchema>;
|
|
48
|
+
export declare const ChangePlanRequestSchema: z.ZodObject<{
|
|
49
|
+
plan: z.ZodEnum<{
|
|
50
|
+
pro: "pro";
|
|
51
|
+
business: "business";
|
|
52
|
+
}>;
|
|
53
|
+
interval: z.ZodEnum<{
|
|
54
|
+
month: "month";
|
|
55
|
+
year: "year";
|
|
56
|
+
}>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type ChangePlanRequest = z.infer<typeof ChangePlanRequestSchema>;
|
|
59
|
+
export declare const ChangePlanResponseSchema: z.ZodObject<{
|
|
60
|
+
effective: z.ZodEnum<{
|
|
61
|
+
now: "now";
|
|
62
|
+
period_end: "period_end";
|
|
63
|
+
}>;
|
|
64
|
+
effective_at: z.ZodNullable<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type ChangePlanResponse = z.infer<typeof ChangePlanResponseSchema>;
|
|
67
|
+
export declare const BillingStateSchema: z.ZodObject<{
|
|
68
|
+
plan: z.ZodEnum<{
|
|
69
|
+
free: "free";
|
|
70
|
+
pro: "pro";
|
|
71
|
+
business: "business";
|
|
72
|
+
}>;
|
|
73
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
74
|
+
active: "active";
|
|
75
|
+
paused: "paused";
|
|
76
|
+
trialing: "trialing";
|
|
77
|
+
past_due: "past_due";
|
|
78
|
+
canceled: "canceled";
|
|
79
|
+
incomplete: "incomplete";
|
|
80
|
+
incomplete_expired: "incomplete_expired";
|
|
81
|
+
unpaid: "unpaid";
|
|
82
|
+
}>>;
|
|
83
|
+
interval: z.ZodNullable<z.ZodEnum<{
|
|
84
|
+
month: "month";
|
|
85
|
+
year: "year";
|
|
86
|
+
}>>;
|
|
87
|
+
current_period_end: z.ZodNullable<z.ZodString>;
|
|
88
|
+
cancel_at_period_end: z.ZodBoolean;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
export type BillingState = z.infer<typeof BillingStateSchema>;
|
|
91
|
+
export declare const PaymentMethodResponseSchema: z.ZodObject<{
|
|
92
|
+
payment_method: z.ZodNullable<z.ZodObject<{
|
|
93
|
+
brand: z.ZodString;
|
|
94
|
+
last4: z.ZodNullable<z.ZodString>;
|
|
95
|
+
exp_month: z.ZodNullable<z.ZodNumber>;
|
|
96
|
+
exp_year: z.ZodNullable<z.ZodNumber>;
|
|
97
|
+
email: z.ZodNullable<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
export type PaymentMethodResponse = z.infer<typeof PaymentMethodResponseSchema>;
|
|
101
|
+
export declare const InvoiceSchema: z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
number: z.ZodNullable<z.ZodString>;
|
|
104
|
+
amount: z.ZodNumber;
|
|
105
|
+
currency: z.ZodString;
|
|
106
|
+
status: z.ZodString;
|
|
107
|
+
created: z.ZodString;
|
|
108
|
+
hosted_invoice_url: z.ZodNullable<z.ZodString>;
|
|
109
|
+
invoice_pdf: z.ZodNullable<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
export type Invoice = z.infer<typeof InvoiceSchema>;
|
|
112
|
+
export declare const InvoiceListResponseSchema: z.ZodObject<{
|
|
113
|
+
items: z.ZodArray<z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
number: z.ZodNullable<z.ZodString>;
|
|
116
|
+
amount: z.ZodNumber;
|
|
117
|
+
currency: z.ZodString;
|
|
118
|
+
status: z.ZodString;
|
|
119
|
+
created: z.ZodString;
|
|
120
|
+
hosted_invoice_url: z.ZodNullable<z.ZodString>;
|
|
121
|
+
invoice_pdf: z.ZodNullable<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
export type InvoiceListResponse = z.infer<typeof InvoiceListResponseSchema>;
|
|
125
|
+
export declare const SetupIntentResponseSchema: z.ZodObject<{
|
|
126
|
+
client_secret: z.ZodString;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export type SetupIntentResponse = z.infer<typeof SetupIntentResponseSchema>;
|
|
129
|
+
//# sourceMappingURL=billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../src/billing/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,eAAO,MAAM,wBAAwB;;;;;;;;;EASnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,mBAAmB;;;;;;iBAM9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,qBAAqB;;;;;;;;;iBAGhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAA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from "./billing-catalog.js";
|
|
4
|
+
export * from "./billing-catalog.js";
|
|
5
|
+
export * from "./entitlements.js";
|
|
6
|
+
export const SubscriptionStatusSchema = z.enum([
|
|
7
|
+
"active",
|
|
8
|
+
"past_due",
|
|
9
|
+
"canceled",
|
|
10
|
+
"incomplete",
|
|
11
|
+
"incomplete_expired",
|
|
12
|
+
"unpaid",
|
|
13
|
+
"paused",
|
|
14
|
+
"trialing",
|
|
15
|
+
]);
|
|
16
|
+
export const PaymentMethodSchema = z.object({
|
|
17
|
+
brand: z.string(),
|
|
18
|
+
last4: z.string().nullable(),
|
|
19
|
+
exp_month: z.number().int().min(1).max(12).nullable(),
|
|
20
|
+
exp_year: z.number().int().nullable(),
|
|
21
|
+
email: z.string().nullable(),
|
|
22
|
+
});
|
|
23
|
+
export const CheckoutRequestSchema = z.object({
|
|
24
|
+
plan: PaidPlanIdSchema,
|
|
25
|
+
interval: BillingIntervalSchema,
|
|
26
|
+
});
|
|
27
|
+
export const CheckoutResponseSchema = z.object({
|
|
28
|
+
client_secret: z.string(),
|
|
29
|
+
amount: z.number().int().nonnegative(),
|
|
30
|
+
currency: z.string(),
|
|
31
|
+
plan: PaidPlanIdSchema,
|
|
32
|
+
interval: BillingIntervalSchema,
|
|
33
|
+
});
|
|
34
|
+
export const ChangePlanRequestSchema = z.object({
|
|
35
|
+
plan: PaidPlanIdSchema,
|
|
36
|
+
interval: BillingIntervalSchema,
|
|
37
|
+
});
|
|
38
|
+
export const ChangePlanResponseSchema = z.object({
|
|
39
|
+
effective: z.enum(["now", "period_end"]),
|
|
40
|
+
effective_at: IsoTimestampSchema.nullable(),
|
|
41
|
+
});
|
|
42
|
+
export const BillingStateSchema = z.object({
|
|
43
|
+
plan: PlanIdSchema,
|
|
44
|
+
status: SubscriptionStatusSchema.nullable(),
|
|
45
|
+
interval: BillingIntervalSchema.nullable(),
|
|
46
|
+
current_period_end: IsoTimestampSchema.nullable(),
|
|
47
|
+
cancel_at_period_end: z.boolean(),
|
|
48
|
+
});
|
|
49
|
+
export const PaymentMethodResponseSchema = z.object({
|
|
50
|
+
payment_method: PaymentMethodSchema.nullable(),
|
|
51
|
+
});
|
|
52
|
+
export const InvoiceSchema = z.object({
|
|
53
|
+
id: z.string(),
|
|
54
|
+
number: z.string().nullable(),
|
|
55
|
+
amount: z.number().int().nonnegative(),
|
|
56
|
+
currency: z.string(),
|
|
57
|
+
status: z.string(),
|
|
58
|
+
created: IsoTimestampSchema,
|
|
59
|
+
hosted_invoice_url: z.string().nullable(),
|
|
60
|
+
invoice_pdf: z.string().nullable(),
|
|
61
|
+
});
|
|
62
|
+
export const InvoiceListResponseSchema = z.object({
|
|
63
|
+
items: z.array(InvoiceSchema),
|
|
64
|
+
});
|
|
65
|
+
export const SetupIntentResponseSchema = z.object({
|
|
66
|
+
client_secret: z.string(),
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/billing/billing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC7C,QAAQ;IACR,UAAU;IACV,UAAU;IACV,YAAY;IACZ,oBAAoB;IACpB,QAAQ;IACR,QAAQ;IACR,UAAU;CACX,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAA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AE,qBAAqB,CAAC,QAAQ,EAAE;IAC1C,kBAAkB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IACjD,oBAAoB,EAAE,CAAC,CAAC,OAAO,EAAE;CAClC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,OAAO,EAAE,kBAAkB;IAC3B,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;CAC9B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ChannelKind } from "../alerting/alert-channels.js";
|
|
3
|
+
import { type PlanId } from "./billing-catalog.js";
|
|
4
|
+
/** Trust organization.plan; status is a floor. Do not re-derive from prices. */
|
|
5
|
+
export declare function effectivePlan(plan: string | null, status: string | null): PlanId;
|
|
6
|
+
export declare function isWithinCap(current: number, limit: number): boolean;
|
|
7
|
+
export declare const PlanLimitResourceSchema: z.ZodEnum<{
|
|
8
|
+
regions: "regions";
|
|
9
|
+
custom_domain: "custom_domain";
|
|
10
|
+
monitors: "monitors";
|
|
11
|
+
team_members: "team_members";
|
|
12
|
+
status_pages: "status_pages";
|
|
13
|
+
check_interval: "check_interval";
|
|
14
|
+
alert_channel: "alert_channel";
|
|
15
|
+
programmable_webhook: "programmable_webhook";
|
|
16
|
+
remove_branding: "remove_branding";
|
|
17
|
+
}>;
|
|
18
|
+
export type PlanLimitResource = z.infer<typeof PlanLimitResourceSchema>;
|
|
19
|
+
export declare const PLAN_LIMIT_REACHED: "plan_limit_reached";
|
|
20
|
+
export declare const PlanLimitErrorSchema: z.ZodObject<{
|
|
21
|
+
code: z.ZodLiteral<"plan_limit_reached">;
|
|
22
|
+
resource: z.ZodEnum<{
|
|
23
|
+
regions: "regions";
|
|
24
|
+
custom_domain: "custom_domain";
|
|
25
|
+
monitors: "monitors";
|
|
26
|
+
team_members: "team_members";
|
|
27
|
+
status_pages: "status_pages";
|
|
28
|
+
check_interval: "check_interval";
|
|
29
|
+
alert_channel: "alert_channel";
|
|
30
|
+
programmable_webhook: "programmable_webhook";
|
|
31
|
+
remove_branding: "remove_branding";
|
|
32
|
+
}>;
|
|
33
|
+
limit: z.ZodNumber;
|
|
34
|
+
current: z.ZodNumber;
|
|
35
|
+
plan: z.ZodEnum<{
|
|
36
|
+
free: "free";
|
|
37
|
+
pro: "pro";
|
|
38
|
+
business: "business";
|
|
39
|
+
}>;
|
|
40
|
+
upgradeTo: z.ZodNullable<z.ZodEnum<{
|
|
41
|
+
free: "free";
|
|
42
|
+
pro: "pro";
|
|
43
|
+
business: "business";
|
|
44
|
+
}>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type PlanLimitError = z.infer<typeof PlanLimitErrorSchema>;
|
|
47
|
+
export declare function allowedChannelKinds(plan: PlanId): readonly ChannelKind[];
|
|
48
|
+
export declare function allowsProgrammableWebhook(plan: PlanId): boolean;
|
|
49
|
+
export declare function allowsRemoveBranding(plan: PlanId): boolean;
|
|
50
|
+
export declare function nextPlanFor(resource: PlanLimitResource, plan: PlanId): PlanId | null;
|
|
51
|
+
export declare const PlanLimitsSchema: z.ZodObject<{
|
|
52
|
+
monitors: z.ZodNumber;
|
|
53
|
+
teamMembers: z.ZodNumber;
|
|
54
|
+
regions: z.ZodNumber;
|
|
55
|
+
minIntervalSec: z.ZodNumber;
|
|
56
|
+
retentionDays: z.ZodNumber;
|
|
57
|
+
statusPages: z.ZodNumber;
|
|
58
|
+
customDomain: z.ZodBoolean;
|
|
59
|
+
sso: z.ZodBoolean;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export declare const PlanUsageSchema: z.ZodObject<{
|
|
62
|
+
monitors: z.ZodNumber;
|
|
63
|
+
teamMembers: z.ZodNumber;
|
|
64
|
+
statusPages: z.ZodNumber;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type PlanUsage = z.infer<typeof PlanUsageSchema>;
|
|
67
|
+
export declare const EntitlementsResponseSchema: z.ZodObject<{
|
|
68
|
+
plan: z.ZodEnum<{
|
|
69
|
+
free: "free";
|
|
70
|
+
pro: "pro";
|
|
71
|
+
business: "business";
|
|
72
|
+
}>;
|
|
73
|
+
limits: z.ZodObject<{
|
|
74
|
+
monitors: z.ZodNumber;
|
|
75
|
+
teamMembers: z.ZodNumber;
|
|
76
|
+
regions: z.ZodNumber;
|
|
77
|
+
minIntervalSec: z.ZodNumber;
|
|
78
|
+
retentionDays: z.ZodNumber;
|
|
79
|
+
statusPages: z.ZodNumber;
|
|
80
|
+
customDomain: z.ZodBoolean;
|
|
81
|
+
sso: z.ZodBoolean;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
usage: z.ZodObject<{
|
|
84
|
+
monitors: z.ZodNumber;
|
|
85
|
+
teamMembers: z.ZodNumber;
|
|
86
|
+
statusPages: z.ZodNumber;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export type EntitlementsResponse = z.infer<typeof EntitlementsResponseSchema>;
|
|
90
|
+
//# sourceMappingURL=entitlements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.d.ts","sourceRoot":"","sources":["../../src/billing/entitlements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAKL,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAC;AAS9B,gFAAgF;AAChF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAIR;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;;EAUlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,kBAAkB,EAAG,oBAA6B,CAAC;AAEhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;iBAO/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAKlE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAExE;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AA4BD,wBAAgB,WAAW,CACzB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,IAAI,CAQf;AAID,eAAO,MAAM,gBAAgB;;;;;;;;;iBAS3B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;iBAI1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;iBAIrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CHANNEL_KINDS } from "../alerting/alert-channels.js";
|
|
3
|
+
import { PLAN_CATALOG, PLAN_ORDER, PlanIdSchema, UNLIMITED, } from "./billing-catalog.js";
|
|
4
|
+
// MUST match ENTITLED_STATUSES in billing-sync.ts; past_due is deliberate grace.
|
|
5
|
+
const ENTITLED_STATUSES = new Set(["active", "trialing", "past_due"]);
|
|
6
|
+
function coercePlan(plan) {
|
|
7
|
+
return plan === "pro" || plan === "business" ? plan : "free";
|
|
8
|
+
}
|
|
9
|
+
/** Trust organization.plan; status is a floor. Do not re-derive from prices. */
|
|
10
|
+
export function effectivePlan(plan, status) {
|
|
11
|
+
const base = coercePlan(plan);
|
|
12
|
+
if (base === "free")
|
|
13
|
+
return "free";
|
|
14
|
+
return status !== null && ENTITLED_STATUSES.has(status) ? base : "free";
|
|
15
|
+
}
|
|
16
|
+
export function isWithinCap(current, limit) {
|
|
17
|
+
return limit === UNLIMITED || current < limit;
|
|
18
|
+
}
|
|
19
|
+
export const PlanLimitResourceSchema = z.enum([
|
|
20
|
+
"monitors",
|
|
21
|
+
"team_members",
|
|
22
|
+
"status_pages",
|
|
23
|
+
"regions",
|
|
24
|
+
"check_interval",
|
|
25
|
+
"alert_channel",
|
|
26
|
+
"programmable_webhook",
|
|
27
|
+
"custom_domain",
|
|
28
|
+
"remove_branding",
|
|
29
|
+
]);
|
|
30
|
+
export const PLAN_LIMIT_REACHED = "plan_limit_reached";
|
|
31
|
+
export const PlanLimitErrorSchema = z.object({
|
|
32
|
+
code: z.literal(PLAN_LIMIT_REACHED),
|
|
33
|
+
resource: PlanLimitResourceSchema,
|
|
34
|
+
limit: z.number().int(),
|
|
35
|
+
current: z.number().int(),
|
|
36
|
+
plan: PlanIdSchema,
|
|
37
|
+
upgradeTo: PlanIdSchema.nullable(),
|
|
38
|
+
});
|
|
39
|
+
// Feature policy, typed here so enforcement never parses the catalog's prose.
|
|
40
|
+
const FREE_CHANNEL_KINDS = ["email", "slack"];
|
|
41
|
+
export function allowedChannelKinds(plan) {
|
|
42
|
+
return plan === "free" ? FREE_CHANNEL_KINDS : CHANNEL_KINDS;
|
|
43
|
+
}
|
|
44
|
+
export function allowsProgrammableWebhook(plan) {
|
|
45
|
+
return plan !== "free";
|
|
46
|
+
}
|
|
47
|
+
export function allowsRemoveBranding(plan) {
|
|
48
|
+
return plan === "business";
|
|
49
|
+
}
|
|
50
|
+
// Comparable capacity for a resource under a plan (higher = more headroom).
|
|
51
|
+
function capacity(resource, plan) {
|
|
52
|
+
const limits = PLAN_CATALOG[plan].limits;
|
|
53
|
+
const uncap = (n) => (n === UNLIMITED ? Infinity : n);
|
|
54
|
+
switch (resource) {
|
|
55
|
+
case "monitors":
|
|
56
|
+
return uncap(limits.monitors);
|
|
57
|
+
case "team_members":
|
|
58
|
+
return uncap(limits.teamMembers);
|
|
59
|
+
case "status_pages":
|
|
60
|
+
return uncap(limits.statusPages);
|
|
61
|
+
case "regions":
|
|
62
|
+
return uncap(limits.regions);
|
|
63
|
+
case "check_interval":
|
|
64
|
+
return -limits.minIntervalSec; // lower interval = more capable
|
|
65
|
+
case "alert_channel":
|
|
66
|
+
return allowedChannelKinds(plan).length;
|
|
67
|
+
case "programmable_webhook":
|
|
68
|
+
return allowsProgrammableWebhook(plan) ? 1 : 0;
|
|
69
|
+
case "remove_branding":
|
|
70
|
+
return allowsRemoveBranding(plan) ? 1 : 0;
|
|
71
|
+
case "custom_domain":
|
|
72
|
+
return limits.customDomain ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function nextPlanFor(resource, plan) {
|
|
76
|
+
const current = capacity(resource, plan);
|
|
77
|
+
const start = PLAN_ORDER.indexOf(plan);
|
|
78
|
+
for (let i = start + 1; i < PLAN_ORDER.length; i++) {
|
|
79
|
+
const candidate = PLAN_ORDER[i];
|
|
80
|
+
if (capacity(resource, candidate) > current)
|
|
81
|
+
return candidate;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
// Zod mirror of the PlanLimits catalog type (billing-catalog.ts), kept in sync by
|
|
86
|
+
// hand because the source type feeds PLAN_CATALOG and would cycle if imported.
|
|
87
|
+
export const PlanLimitsSchema = z.object({
|
|
88
|
+
monitors: z.number().int(),
|
|
89
|
+
teamMembers: z.number().int(),
|
|
90
|
+
regions: z.number().int(),
|
|
91
|
+
minIntervalSec: z.number().int(),
|
|
92
|
+
retentionDays: z.number().int(),
|
|
93
|
+
statusPages: z.number().int(),
|
|
94
|
+
customDomain: z.boolean(),
|
|
95
|
+
sso: z.boolean(),
|
|
96
|
+
});
|
|
97
|
+
export const PlanUsageSchema = z.object({
|
|
98
|
+
monitors: z.number().int().nonnegative(),
|
|
99
|
+
teamMembers: z.number().int().nonnegative(),
|
|
100
|
+
statusPages: z.number().int().nonnegative(),
|
|
101
|
+
});
|
|
102
|
+
export const EntitlementsResponseSchema = z.object({
|
|
103
|
+
plan: PlanIdSchema,
|
|
104
|
+
limits: PlanLimitsSchema,
|
|
105
|
+
usage: PlanUsageSchema,
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=entitlements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.js","sourceRoot":"","sources":["../../src/billing/entitlements.ts"],"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O,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACzB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC7B,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;IACzB,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACxC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IAC3C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;CAC5C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,gBAAgB;IACxB,KAAK,EAAE,eAAe;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/billing/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/billing/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type RollupRange } from "../monitors/rollups.js";
|
|
2
|
+
export declare function retentionCutoff(retentionDays: number, nowMs?: number): Date;
|
|
3
|
+
export declare function historyDays(retentionDays: number, requestedDays: number): number;
|
|
4
|
+
export declare function clampRollupRange(range: RollupRange, retentionDays: number): RollupRange;
|
|
5
|
+
export declare function allowedRollupRanges(retentionDays: number): ReadonlyArray<RollupRange>;
|
|
6
|
+
export declare function periodFitsRetention(key: string, retentionDays: number): boolean;
|
|
7
|
+
export declare function kpiRollupRange(retentionDays: number): Extract<RollupRange, "7d" | "30d">;
|
|
8
|
+
//# sourceMappingURL=retention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../../src/billing/retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AASzE,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,SAAa,GACjB,IAAI,CAGN;AAED,wBAAgB,WAAW,CACzB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,CAER;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,WAAW,EAClB,aAAa,EAAE,MAAM,GACpB,WAAW,CAMb;AAED,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,GACpB,aAAa,CAAC,WAAW,CAAC,CAE5B;AASD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,GACpB,OAAO,CAKT;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,WAAW,EAAE,IAAI,GAAG,KAAK,CAAC,CAEpC"}
|