@entrolytics/shared 2.3.0 → 2.3.2

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 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/analytics-types.ts","../src/event-protocol.ts","../src/index.ts"],"mappings":";UAGiB,eAAA;EACf,SAAA;EACA,SAAA,EAAW,IAAA;EACX,OAAA,EAAS,IAAA;EACT,OAAA;IACE,OAAA;IACA,MAAA;IACA,OAAA;IACA,IAAA;EAAA;AAAA;AAAA,UAIa,aAAA;EACf,SAAA;EACA,QAAA;EACA,QAAA;EACA,eAAA;EACA,WAAA;AAAA;AAAA,UAGe,cAAA;EACf,IAAA,EAAM,IAAA;EACN,SAAA;EACA,QAAA;EACA,QAAA;AAAA;AAAA,UAGe,OAAA;EACf,IAAA;EACA,KAAA;EACA,cAAA;EACA,WAAA;EACA,WAAA;AAAA;AAAA,UAGe,QAAA;EACf,cAAA;EACA,MAAA;EACA,cAAA;AAAA;AAAA,UAGe,WAAA;EACf,UAAA;EACA,OAAA;EACA,EAAA;EACA,SAAA;EACA,cAAA;AAAA;AAAA,UAGe,QAAA;EACf,OAAA;EACA,IAAA;EACA,SAAA;EACA,cAAA;AAAA;AAAA,UAIe,aAAA;EACf,QAAA;EACA,QAAA;EACA,SAAA;AAAA;AAAA,UAGe,aAAA;EACf,SAAA,EAAW,IAAA;EACX,SAAA;EACA,SAAA;EACA,IAAA;EACA,SAAA;EACA,OAAA;EACA,UAAA;EACA,OAAA;AAAA;AAAA,UAGe,UAAA;EACf,IAAA;EACA,OAAA;AAAA;;;AA3BF;UAiCiB,gBAAA;EACf,EAAA;EACA,SAAA;EACA,SAAA;EACA,SAAA;EACA,SAAA,EAAW,IAAA;EACX,SAAA;EACA,SAAA;EACA,GAAA;EACA,IAAA;EACA,QAAA;EACA,cAAA;EACA,OAAA;EACA,cAAA;EACA,EAAA;EACA,SAAA;EACA,UAAA;EACA,WAAA;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AS,WAAA;;;;iBAQ9C,YAAA,CAAa,MAAA,EAAQ,MAAA,EAAQ,KAAA,QAAa,IAAA;;;;iBAO1C,cAAA,CAAe,OAAA,UAAiB,KAAA;;;;iBAQhC,eAAA,CAAgB,OAAA,UAAiB,KAAA;AApOjD;;;AAAA,iBA4OgB,cAAA,CAAe,MAAA,EAAQ,SAAA,EAAW,KAAA,WAAgB,WAAA;;;;;iBAWlD,uBAAA,CAAA,GAA2B,iBAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,685 @@
1
+ //#region src/event-protocol.ts
2
+ /**
3
+ * Event Protocol Types
4
+ *
5
+ * These types define the canonical event structures used across the Entrolytics ecosystem.
6
+ * Used by: API Server, SDKs, CLI, worker processes.
7
+ *
8
+ * This file was extracted from the internal @entrolytics/protocol package to enable
9
+ * sharing with external packages.
10
+ */
11
+ /**
12
+ * Core event types supported by the analytics platform
13
+ */
14
+ const EventType = {
15
+ PageView: "pageview",
16
+ Custom: "custom_event",
17
+ Click: "click"
18
+ };
19
+
20
+ //#endregion
21
+ //#region src/index.ts
22
+ /**
23
+ * Shared constants across Entrolytics ecosystem
24
+ * Used by: CLI, SDKs, Dashboard, Integrations
25
+ */
26
+ /**
27
+ * Plan definitions and limits
28
+ */
29
+ const PLANS = {
30
+ starter: {
31
+ id: "starter",
32
+ name: "Starter",
33
+ price: 0,
34
+ limits: {
35
+ pageviewsPerMonth: 25e3,
36
+ websites: 2,
37
+ retentionDays: 30,
38
+ seats: 1
39
+ },
40
+ features: {
41
+ funnels: false,
42
+ attribution: false,
43
+ revenue: false,
44
+ customDashboards: false,
45
+ apiAccess: false,
46
+ weeklyReports: true,
47
+ support: "community"
48
+ }
49
+ },
50
+ pro: {
51
+ id: "pro",
52
+ name: "Pro",
53
+ price: 29,
54
+ limits: {
55
+ pageviewsPerMonth: 25e4,
56
+ websites: 10,
57
+ retentionDays: 365,
58
+ seats: 5
59
+ },
60
+ features: {
61
+ funnels: true,
62
+ attribution: true,
63
+ revenue: true,
64
+ customDashboards: false,
65
+ apiAccess: true,
66
+ weeklyReports: true,
67
+ support: "email"
68
+ }
69
+ },
70
+ business: {
71
+ id: "business",
72
+ name: "Business",
73
+ price: 99,
74
+ limits: {
75
+ pageviewsPerMonth: 1e6,
76
+ websites: -1,
77
+ retentionDays: 730,
78
+ seats: -1
79
+ },
80
+ features: {
81
+ funnels: true,
82
+ attribution: true,
83
+ revenue: true,
84
+ customDashboards: true,
85
+ apiAccess: true,
86
+ weeklyReports: true,
87
+ support: "priority"
88
+ }
89
+ },
90
+ enterprise: {
91
+ id: "enterprise",
92
+ name: "Enterprise",
93
+ price: -1,
94
+ limits: {
95
+ pageviewsPerMonth: -1,
96
+ websites: -1,
97
+ retentionDays: -1,
98
+ seats: -1
99
+ },
100
+ features: {
101
+ funnels: true,
102
+ attribution: true,
103
+ revenue: true,
104
+ customDashboards: true,
105
+ apiAccess: true,
106
+ weeklyReports: true,
107
+ support: "dedicated",
108
+ sso: true,
109
+ auditLogs: true,
110
+ customRetention: true
111
+ }
112
+ }
113
+ };
114
+ /**
115
+ * Plan feature names for display
116
+ */
117
+ const PLAN_FEATURES = {
118
+ funnels: "Funnel Analytics",
119
+ attribution: "Attribution Reports",
120
+ revenue: "Revenue Tracking",
121
+ customDashboards: "Custom Dashboards",
122
+ apiAccess: "API Access",
123
+ weeklyReports: "Weekly Email Reports",
124
+ sso: "SSO/SAML",
125
+ auditLogs: "Audit Logs",
126
+ customRetention: "Custom Data Retention"
127
+ };
128
+ /**
129
+ * Usage warning thresholds (percentages)
130
+ */
131
+ const USAGE_THRESHOLDS = {
132
+ warning: 90,
133
+ critical: 95
134
+ };
135
+ /**
136
+ * Billing-related error codes
137
+ */
138
+ const BILLING_ERRORS = {
139
+ quotaExceeded: "QUOTA_EXCEEDED",
140
+ planRequired: "PLAN_REQUIRED",
141
+ featureNotAvailable: "FEATURE_NOT_AVAILABLE",
142
+ subscriptionInactive: "SUBSCRIPTION_INACTIVE",
143
+ paymentFailed: "PAYMENT_FAILED"
144
+ };
145
+ /**
146
+ * API endpoint configuration
147
+ */
148
+ const API_ENDPOINTS = {
149
+ production: "https://api.entrolytics.com",
150
+ development: "http://localhost:3001"
151
+ };
152
+ /**
153
+ * Default API host
154
+ */
155
+ const DEFAULT_API_HOST = process.env.NODE_ENV === "production" ? API_ENDPOINTS.production : API_ENDPOINTS.development;
156
+ /**
157
+ * Environment variable naming conventions by framework
158
+ */
159
+ const ENV_VAR_NAMES = {
160
+ nextjs: {
161
+ websiteId: "NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID",
162
+ host: "NEXT_PUBLIC_ENTROLYTICS_HOST",
163
+ envFile: ".env.local"
164
+ },
165
+ react: {
166
+ websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
167
+ host: "VITE_ENTROLYTICS_HOST",
168
+ envFile: ".env",
169
+ fallback: {
170
+ websiteId: "REACT_APP_ENTROLYTICS_WEBSITE_ID",
171
+ host: "REACT_APP_ENTROLYTICS_HOST"
172
+ }
173
+ },
174
+ vue: {
175
+ websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
176
+ host: "VITE_ENTROLYTICS_HOST",
177
+ envFile: ".env"
178
+ },
179
+ svelte: {
180
+ websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
181
+ host: "PUBLIC_ENTROLYTICS_HOST",
182
+ envFile: ".env"
183
+ },
184
+ astro: {
185
+ websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
186
+ host: "PUBLIC_ENTROLYTICS_HOST",
187
+ envFile: ".env"
188
+ },
189
+ html: {
190
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
191
+ host: "ENTROLYTICS_HOST",
192
+ envFile: ".env"
193
+ },
194
+ node: {
195
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
196
+ host: "ENTROLYTICS_HOST",
197
+ envFile: ".env"
198
+ },
199
+ php: {
200
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
201
+ host: "ENTROLYTICS_HOST",
202
+ envFile: ".env"
203
+ },
204
+ python: {
205
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
206
+ host: "ENTROLYTICS_HOST",
207
+ envFile: ".env"
208
+ },
209
+ go: {
210
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
211
+ host: "ENTROLYTICS_HOST",
212
+ envFile: ".env"
213
+ }
214
+ };
215
+ /**
216
+ * CLI configuration constants
217
+ */
218
+ const CLI_CONFIG = {
219
+ tokenExpiryMinutes: 15,
220
+ maxTokensPerUser: 10,
221
+ pollIntervalMs: 2e3,
222
+ setupTimeoutMs: 3e5,
223
+ minCliVersion: "1.0.0"
224
+ };
225
+ /**
226
+ * Core event types - matches backend protocol values exactly
227
+ * Used by: API Server, SDKs, CLI, worker processes
228
+ * See: entrolytics/packages/protocol/src/events.ts
229
+ */
230
+ const EVENT_TYPES = {
231
+ pageView: "pageview",
232
+ custom: "custom_event",
233
+ click: "click"
234
+ };
235
+ /**
236
+ * Extended event types for SDK-level semantics
237
+ * These are higher-level event categories used by SDKs
238
+ * They map to the core EVENT_TYPES when sent to the backend
239
+ */
240
+ const SDK_EVENT_TYPES = {
241
+ pageView: "pageview",
242
+ click: "click",
243
+ formSubmit: "form_submit",
244
+ custom: "custom_event",
245
+ error: "error",
246
+ performance: "performance"
247
+ };
248
+ /**
249
+ * Web Vitals metric types (Phase 2)
250
+ * Core Web Vitals: LCP, INP, CLS
251
+ * Additional: TTFB, FCP
252
+ */
253
+ const VITAL_TYPES = {
254
+ LCP: "LCP",
255
+ INP: "INP",
256
+ CLS: "CLS",
257
+ TTFB: "TTFB",
258
+ FCP: "FCP"
259
+ };
260
+ /**
261
+ * Web Vitals rating thresholds
262
+ */
263
+ const VITAL_RATINGS = {
264
+ good: "good",
265
+ needsImprovement: "needs-improvement",
266
+ poor: "poor"
267
+ };
268
+ /**
269
+ * Web Vitals thresholds by metric (in milliseconds, except CLS which is unitless)
270
+ */
271
+ const VITAL_THRESHOLDS = {
272
+ LCP: {
273
+ good: 2500,
274
+ poor: 4e3
275
+ },
276
+ INP: {
277
+ good: 200,
278
+ poor: 500
279
+ },
280
+ CLS: {
281
+ good: .1,
282
+ poor: .25
283
+ },
284
+ TTFB: {
285
+ good: 800,
286
+ poor: 1800
287
+ },
288
+ FCP: {
289
+ good: 1800,
290
+ poor: 3e3
291
+ }
292
+ };
293
+ /**
294
+ * Navigation types for Web Vitals context
295
+ */
296
+ const NAVIGATION_TYPES = {
297
+ navigate: "navigate",
298
+ reload: "reload",
299
+ backForward: "back-forward",
300
+ backForwardCache: "back-forward-cache",
301
+ prerender: "prerender",
302
+ restore: "restore"
303
+ };
304
+ /**
305
+ * Form event types (Phase 2)
306
+ */
307
+ const FORM_EVENT_TYPES = {
308
+ start: "start",
309
+ fieldFocus: "field_focus",
310
+ fieldBlur: "field_blur",
311
+ fieldError: "field_error",
312
+ submit: "submit",
313
+ abandon: "abandon"
314
+ };
315
+ /**
316
+ * Form field types
317
+ */
318
+ const FORM_FIELD_TYPES = {
319
+ text: "text",
320
+ email: "email",
321
+ password: "password",
322
+ tel: "tel",
323
+ number: "number",
324
+ url: "url",
325
+ textarea: "textarea",
326
+ select: "select",
327
+ checkbox: "checkbox",
328
+ radio: "radio",
329
+ date: "date",
330
+ file: "file",
331
+ hidden: "hidden",
332
+ submit: "submit",
333
+ other: "other"
334
+ };
335
+ /**
336
+ * Deployment platform sources (Phase 2)
337
+ */
338
+ const DEPLOYMENT_SOURCES = {
339
+ vercel: "vercel",
340
+ netlify: "netlify",
341
+ cloudflare: "cloudflare",
342
+ railway: "railway",
343
+ render: "render",
344
+ fly: "fly",
345
+ heroku: "heroku",
346
+ aws: "aws",
347
+ gcp: "gcp",
348
+ azure: "azure",
349
+ custom: "custom"
350
+ };
351
+ /**
352
+ * Deployment environment variables by platform
353
+ */
354
+ const DEPLOYMENT_ENV_VARS = {
355
+ vercel: {
356
+ deployId: "VERCEL_DEPLOYMENT_ID",
357
+ gitSha: "VERCEL_GIT_COMMIT_SHA",
358
+ gitBranch: "VERCEL_GIT_COMMIT_REF",
359
+ url: "VERCEL_URL"
360
+ },
361
+ netlify: {
362
+ deployId: "DEPLOY_ID",
363
+ gitSha: "COMMIT_REF",
364
+ gitBranch: "BRANCH",
365
+ url: "DEPLOY_URL"
366
+ },
367
+ cloudflare: {
368
+ deployId: "CF_PAGES_COMMIT_SHA",
369
+ gitSha: "CF_PAGES_COMMIT_SHA",
370
+ gitBranch: "CF_PAGES_BRANCH",
371
+ url: "CF_PAGES_URL"
372
+ }
373
+ };
374
+ /**
375
+ * HTTP status codes
376
+ */
377
+ const HTTP_STATUS = {
378
+ ok: 200,
379
+ created: 201,
380
+ accepted: 202,
381
+ noContent: 204,
382
+ badRequest: 400,
383
+ unauthorized: 401,
384
+ forbidden: 403,
385
+ notFound: 404,
386
+ conflict: 409,
387
+ tooManyRequests: 429,
388
+ internalServerError: 500,
389
+ serviceUnavailable: 503
390
+ };
391
+ /**
392
+ * API route paths
393
+ */
394
+ const API_ROUTES = {
395
+ cliAuthToken: "/api/auth/cli/token",
396
+ cliAuthTokens: "/api/auth/cli/tokens",
397
+ cliValidate: "/api/auth/cli/validate",
398
+ cliToken: "/api/cli/token",
399
+ shareToken: (shareId) => `/api/share/${shareId}`,
400
+ links: "/api/links",
401
+ linkRedirect: (slug) => `/q/${slug}`,
402
+ websites: "/api/websites",
403
+ websiteById: (id) => `/api/websites/${id}`,
404
+ websiteEvents: (id) => `/api/websites/${id}/events`,
405
+ websiteRecentEvents: (id) => `/api/websites/${id}/recent-events`,
406
+ userOnboarding: "/api/user/onboarding",
407
+ userProfile: "/api/user/profile",
408
+ userEmailPreferences: "/api/me/email-preferences",
409
+ billingUsage: "/api/billing/usage",
410
+ billingCheckout: "/api/billing/checkout",
411
+ billingPortal: "/api/billing/portal",
412
+ billingWebhook: "/api/billing/webhook",
413
+ analyticsOverview: (websiteId) => `/api/analytics/${websiteId}/overview`,
414
+ analyticsTimeseries: (websiteId) => `/api/analytics/${websiteId}/timeseries`,
415
+ analyticsTopPages: (websiteId) => `/api/analytics/${websiteId}/top-pages`,
416
+ analyticsTopReferrers: (websiteId) => `/api/analytics/${websiteId}/top-referrers`,
417
+ analyticsGeography: (websiteId) => `/api/analytics/${websiteId}/geography`,
418
+ analyticsDevices: (websiteId) => `/api/analytics/${websiteId}/devices`,
419
+ collect: "/collect",
420
+ collectBatch: "/collect/batch",
421
+ send: "/collect",
422
+ collectVitals: "/api/collect/vitals",
423
+ collectVitalsBatch: "/api/collect/vitals/batch",
424
+ collectForms: "/api/collect/forms",
425
+ websiteVitals: (id) => `/api/websites/${id}/vitals`,
426
+ websiteForms: (id) => `/api/websites/${id}/forms`,
427
+ websiteDeployments: (id) => `/api/websites/${id}/deployments`,
428
+ health: "/api/health",
429
+ healthIntegrations: "/api/health/integrations"
430
+ };
431
+ /**
432
+ * Onboarding step identifiers
433
+ */
434
+ const ONBOARDING_STEPS = {
435
+ welcome: "welcome",
436
+ createWebsite: "create-website",
437
+ installTracking: "install-tracking",
438
+ verify: "verify",
439
+ complete: "complete",
440
+ skipped: "skipped"
441
+ };
442
+ /**
443
+ * CLI token statuses
444
+ */
445
+ const CLI_TOKEN_STATUS = {
446
+ pending: "pending",
447
+ used: "used",
448
+ expired: "expired",
449
+ revoked: "revoked"
450
+ };
451
+ /**
452
+ * User roles
453
+ */
454
+ const USER_ROLES = {
455
+ admin: "admin",
456
+ user: "user",
457
+ viewer: "viewer"
458
+ };
459
+ /**
460
+ * Framework package names
461
+ */
462
+ const FRAMEWORK_PACKAGES = {
463
+ nextjs: "@entrolytics/nextjs-sdk",
464
+ react: "@entrolytics/react-sdk",
465
+ vue: "@entrolytics/vue-sdk",
466
+ svelte: "@entrolytics/svelte-sdk",
467
+ astro: "@entrolytics/astro-sdk",
468
+ node: "@entrolytics/node-sdk"
469
+ };
470
+ /**
471
+ * Framework detection patterns
472
+ */
473
+ const FRAMEWORK_PATTERNS = {
474
+ nextjs: {
475
+ files: [
476
+ "next.config.js",
477
+ "next.config.mjs",
478
+ "next.config.ts"
479
+ ],
480
+ dependencies: ["next"]
481
+ },
482
+ react: {
483
+ files: ["vite.config.js", "vite.config.ts"],
484
+ dependencies: ["react", "vite"]
485
+ },
486
+ vue: {
487
+ files: ["vite.config.js", "vite.config.ts"],
488
+ dependencies: ["vue", "vite"]
489
+ },
490
+ svelte: {
491
+ files: ["svelte.config.js", "svelte.config.ts"],
492
+ dependencies: ["svelte"]
493
+ },
494
+ astro: {
495
+ files: ["astro.config.mjs", "astro.config.ts"],
496
+ dependencies: ["astro"]
497
+ }
498
+ };
499
+ /**
500
+ * Rate limiting configuration
501
+ * Updated to match server-side implementation
502
+ */
503
+ const RATE_LIMITS = {
504
+ cliTokenExchange: {
505
+ windowSeconds: 60,
506
+ maxRequests: 5
507
+ },
508
+ shareTokenGeneration: {
509
+ windowSeconds: 60,
510
+ maxRequests: 10
511
+ },
512
+ linkCreation: {
513
+ windowSeconds: 60,
514
+ maxRequests: 20
515
+ },
516
+ linkRedirect: {
517
+ windowSeconds: 60,
518
+ maxRequests: 100
519
+ },
520
+ apiGeneral: {
521
+ windowSeconds: 60,
522
+ maxRequests: 100
523
+ },
524
+ cliTokenGeneration: {
525
+ windowMs: 36e5,
526
+ maxRequests: 10
527
+ },
528
+ cliValidation: {
529
+ windowMs: 36e5,
530
+ maxRequests: 100
531
+ },
532
+ eventCollection: {
533
+ windowMs: 6e4,
534
+ maxRequests: 1e3
535
+ }
536
+ };
537
+ /**
538
+ * Error messages
539
+ */
540
+ const ERROR_MESSAGES = {
541
+ unauthorized: "Unauthorized access",
542
+ forbidden: "Access forbidden",
543
+ tokenExpired: "Token has expired",
544
+ tokenInvalid: "Invalid token",
545
+ tokenNotFound: "Token not found",
546
+ tokenAlreadyUsed: "Token has already been used",
547
+ tokenRevoked: "Token has been revoked",
548
+ tokenMissingJti: "Token missing JTI - please re-authenticate",
549
+ userBanned: "User account has been banned",
550
+ userDeleted: "User account has been deleted",
551
+ shareTokenExpired: "Share token has expired",
552
+ shareTokenRevoked: "Share has been revoked",
553
+ shareTokenInvalid: "Invalid share token",
554
+ invalidUrl: "Invalid URL provided",
555
+ invalidUrlProtocol: "URL must use http or https protocol",
556
+ openRedirectBlocked: "Open redirect attempt blocked",
557
+ invalidInput: "Invalid input provided",
558
+ missingRequired: "Missing required fields",
559
+ invalidFormat: "Invalid format",
560
+ notFound: "Resource not found",
561
+ websiteNotFound: "Website not found",
562
+ userNotFound: "User not found",
563
+ linkNotFound: "Link not found",
564
+ tooManyRequests: "Too many requests. Please try again later.",
565
+ rateLimitExceeded: "Rate limit exceeded",
566
+ internalError: "Internal server error",
567
+ serviceUnavailable: "Service temporarily unavailable"
568
+ };
569
+ /**
570
+ * Success messages
571
+ */
572
+ const SUCCESS_MESSAGES = {
573
+ tokenGenerated: "Setup token generated successfully",
574
+ tokenValidated: "Token validated successfully",
575
+ tokenRevoked: "Token revoked successfully",
576
+ allTokensRevoked: "All tokens revoked successfully",
577
+ websiteCreated: "Website created successfully",
578
+ linkCreated: "Link created successfully",
579
+ shareCreated: "Share created successfully",
580
+ onboardingComplete: "Onboarding completed successfully",
581
+ setupComplete: "Setup completed successfully"
582
+ };
583
+ /**
584
+ * Utility functions
585
+ */
586
+ function getEnvVarNames(framework) {
587
+ return ENV_VAR_NAMES[framework];
588
+ }
589
+ function getFrameworkPackage(framework) {
590
+ return FRAMEWORK_PACKAGES[framework] || null;
591
+ }
592
+ function isValidFramework(framework) {
593
+ return framework in ENV_VAR_NAMES;
594
+ }
595
+ function getApiRoute(route, ...args) {
596
+ const routeFn = API_ROUTES[route];
597
+ if (typeof routeFn === "function") return routeFn(...args);
598
+ return routeFn;
599
+ }
600
+ /**
601
+ * Get plan by ID
602
+ */
603
+ function getPlan(planId) {
604
+ return PLANS[planId];
605
+ }
606
+ /**
607
+ * Check if a feature is available for a plan
608
+ */
609
+ function isPlanFeatureEnabled(planId, feature) {
610
+ return PLANS[planId]?.features?.[feature] === true;
611
+ }
612
+ /**
613
+ * Get plan limit value (-1 means unlimited)
614
+ */
615
+ function getPlanLimit(planId, limit) {
616
+ return PLANS[planId]?.limits?.[limit] ?? 0;
617
+ }
618
+ /**
619
+ * Check if usage is at warning threshold
620
+ */
621
+ function isUsageWarning(current, limit) {
622
+ if (limit <= 0) return false;
623
+ return current / limit * 100 >= USAGE_THRESHOLDS.warning;
624
+ }
625
+ /**
626
+ * Check if usage is at critical threshold
627
+ */
628
+ function isUsageCritical(current, limit) {
629
+ if (limit <= 0) return false;
630
+ return current / limit * 100 >= USAGE_THRESHOLDS.critical;
631
+ }
632
+ /**
633
+ * Calculate Web Vital rating from value (Phase 2)
634
+ */
635
+ function getVitalRating(metric, value) {
636
+ const thresholds = VITAL_THRESHOLDS[metric];
637
+ if (value <= thresholds.good) return "good";
638
+ if (value <= thresholds.poor) return "needs-improvement";
639
+ return "poor";
640
+ }
641
+ /**
642
+ * Detect deployment context from environment variables (Phase 2)
643
+ * Works in Node.js environments only - returns null in browser
644
+ */
645
+ function detectDeploymentContext() {
646
+ const env = getEnv();
647
+ if (!env) return null;
648
+ if (env.VERCEL_DEPLOYMENT_ID) return {
649
+ deployId: env.VERCEL_DEPLOYMENT_ID,
650
+ gitSha: env.VERCEL_GIT_COMMIT_SHA,
651
+ gitBranch: env.VERCEL_GIT_COMMIT_REF,
652
+ deployUrl: env.VERCEL_URL ? `https://${env.VERCEL_URL}` : void 0,
653
+ source: "vercel"
654
+ };
655
+ if (env.DEPLOY_ID) return {
656
+ deployId: env.DEPLOY_ID,
657
+ gitSha: env.COMMIT_REF,
658
+ gitBranch: env.BRANCH,
659
+ deployUrl: env.DEPLOY_URL,
660
+ source: "netlify"
661
+ };
662
+ if (env.CF_PAGES_COMMIT_SHA) return {
663
+ deployId: env.CF_PAGES_COMMIT_SHA,
664
+ gitSha: env.CF_PAGES_COMMIT_SHA,
665
+ gitBranch: env.CF_PAGES_BRANCH,
666
+ deployUrl: env.CF_PAGES_URL,
667
+ source: "cloudflare"
668
+ };
669
+ return null;
670
+ }
671
+ /**
672
+ * Safe environment variable access (works in browser and Node.js)
673
+ */
674
+ function getEnv() {
675
+ try {
676
+ if (typeof globalThis !== "undefined" && "process" in globalThis) return globalThis.process?.env ?? null;
677
+ return null;
678
+ } catch {
679
+ return null;
680
+ }
681
+ }
682
+
683
+ //#endregion
684
+ export { API_ENDPOINTS, API_ROUTES, BILLING_ERRORS, CLI_CONFIG, CLI_TOKEN_STATUS, DEFAULT_API_HOST, DEPLOYMENT_ENV_VARS, DEPLOYMENT_SOURCES, ENV_VAR_NAMES, ERROR_MESSAGES, EVENT_TYPES, EventType, FORM_EVENT_TYPES, FORM_FIELD_TYPES, FRAMEWORK_PACKAGES, FRAMEWORK_PATTERNS, HTTP_STATUS, NAVIGATION_TYPES, ONBOARDING_STEPS, PLANS, PLAN_FEATURES, RATE_LIMITS, SDK_EVENT_TYPES, SUCCESS_MESSAGES, USAGE_THRESHOLDS, USER_ROLES, VITAL_RATINGS, VITAL_THRESHOLDS, VITAL_TYPES, detectDeploymentContext, getApiRoute, getEnvVarNames, getFrameworkPackage, getPlan, getPlanLimit, getVitalRating, isPlanFeatureEnabled, isUsageCritical, isUsageWarning, isValidFramework };
685
+ //# sourceMappingURL=index.js.map