@debugbundle/shared-types 0.1.0-next.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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Tier capabilities — single source of truth for plan-gated features and limits.
3
+ *
4
+ * Route code checks capabilities, not tier names:
5
+ * const caps = getTierCapabilities(project.organization_plan);
6
+ * if (!caps.remote_probes) return reply.status(403).send({ error: "upgrade_required" });
7
+ *
8
+ * Adding a tier or moving a feature between tiers = one config change here.
9
+ * Source-of-truth for values: /spec/tiers.md (finalized).
10
+ */
11
+ export declare const TIER_CAPABILITIES: {
12
+ readonly free: {
13
+ readonly remote_probes: false;
14
+ readonly github_automation: false;
15
+ readonly cloud_improvement_bundles: false;
16
+ readonly shared_dashboards: false;
17
+ readonly member_invites: false;
18
+ readonly included_capacity_units: 1;
19
+ readonly max_members: 1;
20
+ readonly ingestion_rate_per_min: 1000;
21
+ readonly retrieval_rate_per_min: 100;
22
+ readonly bundle_retention_days: 7;
23
+ readonly raw_event_retention_days: 7;
24
+ readonly monthly_bundle_requests: 100;
25
+ readonly monthly_raw_ingested_events: 750;
26
+ readonly retained_bundle_cap: 50;
27
+ readonly monthly_remote_activations: 0;
28
+ readonly monthly_alert_deliveries: 25;
29
+ };
30
+ readonly solo: {
31
+ readonly remote_probes: true;
32
+ readonly github_automation: true;
33
+ readonly cloud_improvement_bundles: false;
34
+ readonly shared_dashboards: false;
35
+ readonly member_invites: false;
36
+ readonly included_capacity_units: 2;
37
+ readonly max_members: 1;
38
+ readonly ingestion_rate_per_min: 5000;
39
+ readonly retrieval_rate_per_min: 300;
40
+ readonly bundle_retention_days: 30;
41
+ readonly raw_event_retention_days: 14;
42
+ readonly monthly_bundle_requests: 250;
43
+ readonly monthly_raw_ingested_events: 2000;
44
+ readonly retained_bundle_cap: 150;
45
+ readonly monthly_remote_activations: 25;
46
+ readonly monthly_alert_deliveries: 75;
47
+ };
48
+ readonly team: {
49
+ readonly remote_probes: true;
50
+ readonly github_automation: true;
51
+ readonly cloud_improvement_bundles: true;
52
+ readonly shared_dashboards: true;
53
+ readonly member_invites: true;
54
+ readonly included_capacity_units: 10;
55
+ readonly max_members: 5;
56
+ readonly ingestion_rate_per_min: 10000;
57
+ readonly retrieval_rate_per_min: 500;
58
+ readonly bundle_retention_days: 90;
59
+ readonly raw_event_retention_days: 30;
60
+ readonly monthly_bundle_requests: 500;
61
+ readonly monthly_raw_ingested_events: 5000;
62
+ readonly retained_bundle_cap: 300;
63
+ readonly monthly_remote_activations: 50;
64
+ readonly monthly_alert_deliveries: 150;
65
+ };
66
+ };
67
+ export type TierName = keyof typeof TIER_CAPABILITIES;
68
+ /** Structural type for tier capabilities — widened from const literals for extensibility. */
69
+ export interface TierCapabilities {
70
+ readonly remote_probes: boolean;
71
+ readonly github_automation: boolean;
72
+ readonly cloud_improvement_bundles: boolean;
73
+ readonly shared_dashboards: boolean;
74
+ readonly member_invites: boolean;
75
+ readonly included_capacity_units: number;
76
+ readonly max_members: number;
77
+ readonly ingestion_rate_per_min: number;
78
+ readonly retrieval_rate_per_min: number;
79
+ readonly bundle_retention_days: number;
80
+ readonly raw_event_retention_days: number;
81
+ readonly monthly_bundle_requests: number;
82
+ readonly monthly_raw_ingested_events: number;
83
+ readonly retained_bundle_cap: number;
84
+ readonly monthly_remote_activations: number;
85
+ readonly monthly_alert_deliveries: number;
86
+ }
87
+ /** Whether the instance is running in self-host mode (all tier limits bypassed). */
88
+ export declare function isSelfHostMode(): boolean;
89
+ /** Resolve a plan string to its capabilities. Unknown plans fall back to free. */
90
+ export declare function getTierCapabilities(plan: string | undefined): TierCapabilities;
91
+ //# sourceMappingURL=tier-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier-capabilities.d.ts","sourceRoot":"","sources":["../src/tier-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DpB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAEtD,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,yBAAyB,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,0BAA0B,EAAE,MAAM,CAAC;IAC5C,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;CAC3C;AA0BD,oFAAoF;AACpF,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,gBAAgB,CAQ9E"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Tier capabilities — single source of truth for plan-gated features and limits.
3
+ *
4
+ * Route code checks capabilities, not tier names:
5
+ * const caps = getTierCapabilities(project.organization_plan);
6
+ * if (!caps.remote_probes) return reply.status(403).send({ error: "upgrade_required" });
7
+ *
8
+ * Adding a tier or moving a feature between tiers = one config change here.
9
+ * Source-of-truth for values: /spec/tiers.md (finalized).
10
+ */
11
+ export const TIER_CAPABILITIES = {
12
+ free: {
13
+ remote_probes: false,
14
+ github_automation: false,
15
+ cloud_improvement_bundles: false,
16
+ shared_dashboards: false,
17
+ member_invites: false,
18
+ included_capacity_units: 1,
19
+ max_members: 1,
20
+ ingestion_rate_per_min: 1_000,
21
+ retrieval_rate_per_min: 100,
22
+ bundle_retention_days: 7,
23
+ raw_event_retention_days: 7,
24
+ // Allowance buckets (account-level pool, not per capacity unit)
25
+ monthly_bundle_requests: 100,
26
+ monthly_raw_ingested_events: 750,
27
+ retained_bundle_cap: 50,
28
+ monthly_remote_activations: 0,
29
+ monthly_alert_deliveries: 25,
30
+ },
31
+ solo: {
32
+ remote_probes: true,
33
+ github_automation: true,
34
+ cloud_improvement_bundles: false,
35
+ shared_dashboards: false,
36
+ member_invites: false,
37
+ included_capacity_units: 2,
38
+ max_members: 1,
39
+ ingestion_rate_per_min: 5_000,
40
+ retrieval_rate_per_min: 300,
41
+ bundle_retention_days: 30,
42
+ raw_event_retention_days: 14,
43
+ // Per-unit allowance (multiply by included and purchased capacity units)
44
+ monthly_bundle_requests: 250,
45
+ monthly_raw_ingested_events: 2_000,
46
+ retained_bundle_cap: 150,
47
+ monthly_remote_activations: 25,
48
+ monthly_alert_deliveries: 75,
49
+ },
50
+ team: {
51
+ remote_probes: true,
52
+ github_automation: true,
53
+ cloud_improvement_bundles: true,
54
+ shared_dashboards: true,
55
+ member_invites: true,
56
+ included_capacity_units: 10,
57
+ max_members: 5,
58
+ ingestion_rate_per_min: 10_000,
59
+ retrieval_rate_per_min: 500,
60
+ bundle_retention_days: 90,
61
+ raw_event_retention_days: 30,
62
+ // Per-unit allowance (multiply by included and purchased capacity units)
63
+ monthly_bundle_requests: 500,
64
+ monthly_raw_ingested_events: 5_000,
65
+ retained_bundle_cap: 300,
66
+ monthly_remote_activations: 50,
67
+ monthly_alert_deliveries: 150,
68
+ },
69
+ };
70
+ /**
71
+ * Self-host mode: all features unlocked, all limits effectively unlimited.
72
+ * Activated by setting SELFHOST_MODE=true in the environment.
73
+ * Auth and security remain fully enforced — only billing/quota gates are bypassed.
74
+ */
75
+ const SELFHOST_CAPABILITIES = {
76
+ remote_probes: true,
77
+ github_automation: true,
78
+ cloud_improvement_bundles: true,
79
+ shared_dashboards: true,
80
+ member_invites: true,
81
+ included_capacity_units: 1_000_000,
82
+ max_members: 1_000,
83
+ ingestion_rate_per_min: 1_000_000,
84
+ retrieval_rate_per_min: 100_000,
85
+ bundle_retention_days: 36_500,
86
+ raw_event_retention_days: 36_500,
87
+ monthly_bundle_requests: 1_000_000_000,
88
+ monthly_raw_ingested_events: 1_000_000_000,
89
+ retained_bundle_cap: 1_000_000,
90
+ monthly_remote_activations: 1_000_000,
91
+ monthly_alert_deliveries: 1_000_000,
92
+ };
93
+ /** Whether the instance is running in self-host mode (all tier limits bypassed). */
94
+ export function isSelfHostMode() {
95
+ return typeof process !== "undefined" && process.env["SELFHOST_MODE"] === "true";
96
+ }
97
+ /** Resolve a plan string to its capabilities. Unknown plans fall back to free. */
98
+ export function getTierCapabilities(plan) {
99
+ if (isSelfHostMode()) {
100
+ return SELFHOST_CAPABILITIES;
101
+ }
102
+ if (plan !== undefined && plan in TIER_CAPABILITIES) {
103
+ return TIER_CAPABILITIES[plan];
104
+ }
105
+ return TIER_CAPABILITIES.free;
106
+ }
107
+ //# sourceMappingURL=tier-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tier-capabilities.js","sourceRoot":"","sources":["../src/tier-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,KAAK;QACxB,yBAAyB,EAAE,KAAK;QAChC,iBAAiB,EAAE,KAAK;QACxB,cAAc,EAAE,KAAK;QACrB,uBAAuB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AAC;AAwBX;;;;GAIG;AACH,MAAM,qBAAqB,GAAqB;IAC9C,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,yBAAyB,EAAE,IAAI;IAC/B,iBAAiB,EAAE,IAAI;IACvB,cAAc,EAAE,IAAI;IACpB,uBAAuB,EAAE,SAAS;IAClC,WAAW,EAAE,KAAK;IAClB,sBAAsB,EAAE,SAAS;IACjC,sBAAsB,EAAE,OAAO;IAC/B,qBAAqB,EAAE,MAAM;IAC7B,wBAAwB,EAAE,MAAM;IAChC,uBAAuB,EAAE,aAAa;IACtC,2BAA2B,EAAE,aAAa;IAC1C,mBAAmB,EAAE,SAAS;IAC9B,0BAA0B,EAAE,SAAS;IACrC,wBAAwB,EAAE,SAAS;CACpC,CAAC;AAEF,oFAAoF;AACpF,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AACnF,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,IAAwB;IAC1D,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,IAAI,iBAAiB,EAAE,CAAC;QACpD,OAAO,iBAAiB,CAAC,IAAgB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,iBAAiB,CAAC,IAAI,CAAC;AAChC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@debugbundle/shared-types",
3
+ "version": "0.1.0-next.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "AGPL-3.0-only",
7
+ "description": "Shared DebugBundle schemas, types, and constants",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "zod": "^3.24.2"
24
+ }
25
+ }