@authhero/cloudflare-adapter 2.27.0 → 2.28.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.
@@ -606,6 +606,73 @@ declare const dailyStatsSchema: z.ZodObject<{
606
606
  leaked_passwords: number;
607
607
  }>;
608
608
  export type DailyStats = z.infer<typeof dailyStatsSchema>;
609
+ declare const analyticsResourceSchema: z.ZodEnum<[
610
+ "active-users",
611
+ "logins",
612
+ "signups",
613
+ "refresh-tokens",
614
+ "sessions"
615
+ ]>;
616
+ export type AnalyticsResource = z.infer<typeof analyticsResourceSchema>;
617
+ declare const analyticsIntervalSchema: z.ZodEnum<[
618
+ "hour",
619
+ "day",
620
+ "week",
621
+ "month"
622
+ ]>;
623
+ export type AnalyticsInterval = z.infer<typeof analyticsIntervalSchema>;
624
+ declare const analyticsGroupBySchema: z.ZodEnum<[
625
+ "time",
626
+ "connection",
627
+ "client_id",
628
+ "user_type",
629
+ "event"
630
+ ]>;
631
+ export type AnalyticsGroupBy = z.infer<typeof analyticsGroupBySchema>;
632
+ declare const analyticsUserTypeSchema: z.ZodEnum<[
633
+ "password",
634
+ "social",
635
+ "passwordless",
636
+ "enterprise"
637
+ ]>;
638
+ export type AnalyticsUserType = z.infer<typeof analyticsUserTypeSchema>;
639
+ export interface AnalyticsFilters {
640
+ connection?: string[];
641
+ client_id?: string[];
642
+ user_type?: AnalyticsUserType[];
643
+ user_id?: string[];
644
+ }
645
+ export interface AnalyticsQueryParams {
646
+ /** Inclusive lower bound, ISO 8601 datetime in UTC */
647
+ from: string;
648
+ /** Exclusive upper bound, ISO 8601 datetime in UTC */
649
+ to: string;
650
+ interval: AnalyticsInterval;
651
+ /** IANA timezone for bucket boundaries */
652
+ tz: string;
653
+ filters: AnalyticsFilters;
654
+ group_by: AnalyticsGroupBy[];
655
+ limit: number;
656
+ offset: number;
657
+ /** Column name, prefix with `-` for descending */
658
+ order_by?: string;
659
+ }
660
+ export interface AnalyticsColumnMeta {
661
+ name: string;
662
+ /** ClickHouse-style type label (e.g. "Date", "String", "UInt64", "DateTime") */
663
+ type: string;
664
+ }
665
+ export interface AnalyticsQueryResponse {
666
+ meta: AnalyticsColumnMeta[];
667
+ data: Array<Record<string, unknown>>;
668
+ rows: number;
669
+ rows_before_limit_at_least?: number;
670
+ statistics?: {
671
+ elapsed: number;
672
+ rows_read?: number;
673
+ bytes_read?: number;
674
+ };
675
+ }
609
676
  export interface CacheAdapter {
610
677
  /**
611
678
  * Get a value from the cache
@@ -683,6 +750,14 @@ export interface StatsAdapter {
683
750
  */
684
751
  getActiveUsers(tenantId: string): Promise<number>;
685
752
  }
753
+ export interface AnalyticsAdapter {
754
+ /**
755
+ * Run an analytics query for a tenant. The adapter is responsible for
756
+ * injecting the tenant_id predicate; the route handler never trusts a
757
+ * tenant value from a client-controlled source.
758
+ */
759
+ query(tenantId: string, resource: AnalyticsResource, params: AnalyticsQueryParams): Promise<AnalyticsQueryResponse>;
760
+ }
686
761
  /**
687
762
  * Logical buckets that consumers can rate-limit against. Backends decide
688
763
  * how each scope is enforced (e.g. mapping to a separate Cloudflare Workers
@@ -907,6 +982,7 @@ export interface AnalyticsEngineLogsAdapterConfig {
907
982
  * Create a stats adapter that queries Analytics Engine
908
983
  */
909
984
  export declare function createAnalyticsEngineStatsAdapter(config: AnalyticsEngineLogsAdapterConfig): StatsAdapter;
985
+ export declare function createAnalyticsEngineAnalyticsAdapter(config: AnalyticsEngineLogsAdapterConfig): AnalyticsAdapter;
910
986
  /**
911
987
  * Create an Analytics Engine logs adapter
912
988
  *