@the-situation/indexer 0.17.0 → 0.18.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.
Files changed (133) hide show
  1. package/README.md +43 -4
  2. package/dist/aggregator/cohort.d.ts +30 -0
  3. package/dist/aggregator/cohort.d.ts.map +1 -0
  4. package/dist/aggregator/cohort.js +153 -0
  5. package/dist/aggregator/cohort.js.map +1 -0
  6. package/dist/aggregator/daily.d.ts +71 -0
  7. package/dist/aggregator/daily.d.ts.map +1 -0
  8. package/dist/aggregator/daily.js +249 -0
  9. package/dist/aggregator/daily.js.map +1 -0
  10. package/dist/aggregator/domains.d.ts +20 -0
  11. package/dist/aggregator/domains.d.ts.map +1 -0
  12. package/dist/aggregator/domains.js +38 -0
  13. package/dist/aggregator/domains.js.map +1 -0
  14. package/dist/aggregator/index.d.ts +31 -0
  15. package/dist/aggregator/index.d.ts.map +1 -0
  16. package/dist/aggregator/index.js +100 -0
  17. package/dist/aggregator/index.js.map +1 -0
  18. package/dist/aggregator/lifetime.d.ts +52 -0
  19. package/dist/aggregator/lifetime.d.ts.map +1 -0
  20. package/dist/aggregator/lifetime.js +222 -0
  21. package/dist/aggregator/lifetime.js.map +1 -0
  22. package/dist/aggregator/roi.d.ts +42 -0
  23. package/dist/aggregator/roi.d.ts.map +1 -0
  24. package/dist/aggregator/roi.js +153 -0
  25. package/dist/aggregator/roi.js.map +1 -0
  26. package/dist/aggregator/sources.d.ts +59 -0
  27. package/dist/aggregator/sources.d.ts.map +1 -0
  28. package/dist/aggregator/sources.js +53 -0
  29. package/dist/aggregator/sources.js.map +1 -0
  30. package/dist/aggregator/writers.d.ts +22 -0
  31. package/dist/aggregator/writers.d.ts.map +1 -0
  32. package/dist/aggregator/writers.js +147 -0
  33. package/dist/aggregator/writers.js.map +1 -0
  34. package/dist/api/app.d.ts +177 -13
  35. package/dist/api/app.d.ts.map +1 -1
  36. package/dist/api/app.js +4 -3
  37. package/dist/api/app.js.map +1 -1
  38. package/dist/api/routes/admin-subscriptions.d.ts +11 -11
  39. package/dist/api/routes/analytics.d.ts +205 -0
  40. package/dist/api/routes/analytics.d.ts.map +1 -0
  41. package/dist/api/routes/analytics.js +122 -0
  42. package/dist/api/routes/analytics.js.map +1 -0
  43. package/dist/api/routes/health.d.ts.map +1 -1
  44. package/dist/api/routes/health.js +2 -0
  45. package/dist/api/routes/health.js.map +1 -1
  46. package/dist/api/routes/index.d.ts +1 -0
  47. package/dist/api/routes/index.d.ts.map +1 -1
  48. package/dist/api/routes/index.js +1 -0
  49. package/dist/api/routes/index.js.map +1 -1
  50. package/dist/api/routes/rankings.d.ts +17 -3
  51. package/dist/api/routes/rankings.d.ts.map +1 -1
  52. package/dist/api/routes/rankings.js +44 -5
  53. package/dist/api/routes/rankings.js.map +1 -1
  54. package/dist/api/routes/trader-stats.d.ts +11 -2
  55. package/dist/api/routes/trader-stats.d.ts.map +1 -1
  56. package/dist/api/routes/trader-stats.js +72 -2
  57. package/dist/api/routes/trader-stats.js.map +1 -1
  58. package/dist/client/IndexerClient.d.ts +30 -1
  59. package/dist/client/IndexerClient.d.ts.map +1 -1
  60. package/dist/client/IndexerClient.js.map +1 -1
  61. package/dist/client/IndexerClientLive.d.ts.map +1 -1
  62. package/dist/client/IndexerClientLive.js +50 -1
  63. package/dist/client/IndexerClientLive.js.map +1 -1
  64. package/dist/client/convenience.d.ts +9 -2
  65. package/dist/client/convenience.d.ts.map +1 -1
  66. package/dist/client/convenience.js +9 -1
  67. package/dist/client/convenience.js.map +1 -1
  68. package/dist/client/index.d.ts +3 -2
  69. package/dist/client/index.d.ts.map +1 -1
  70. package/dist/client/index.js +1 -1
  71. package/dist/client/index.js.map +1 -1
  72. package/dist/config.d.ts +17 -1
  73. package/dist/config.d.ts.map +1 -1
  74. package/dist/config.js +39 -3
  75. package/dist/config.js.map +1 -1
  76. package/dist/etl/event-indexer.d.ts +1 -1
  77. package/dist/etl/lp-position-refresher.d.ts +2 -1
  78. package/dist/etl/lp-position-refresher.d.ts.map +1 -1
  79. package/dist/etl/lp-position-refresher.js +24 -11
  80. package/dist/etl/lp-position-refresher.js.map +1 -1
  81. package/dist/index.js +64 -8
  82. package/dist/index.js.map +1 -1
  83. package/dist/layers/ChainReaderLive.d.ts.map +1 -1
  84. package/dist/layers/ChainReaderLive.js +15 -0
  85. package/dist/layers/ChainReaderLive.js.map +1 -1
  86. package/dist/layers/VoyagerClientLive.d.ts +2 -1
  87. package/dist/layers/VoyagerClientLive.d.ts.map +1 -1
  88. package/dist/layers/VoyagerClientLive.js +89 -55
  89. package/dist/layers/VoyagerClientLive.js.map +1 -1
  90. package/dist/services/ChainReader.d.ts +10 -0
  91. package/dist/services/ChainReader.d.ts.map +1 -1
  92. package/dist/services/ChainReader.js.map +1 -1
  93. package/dist/services/VoyagerRateLimit.d.ts +11 -8
  94. package/dist/services/VoyagerRateLimit.d.ts.map +1 -1
  95. package/dist/services/VoyagerRateLimit.js +51 -26
  96. package/dist/services/VoyagerRateLimit.js.map +1 -1
  97. package/dist/types/analytics.d.ts +194 -0
  98. package/dist/types/analytics.d.ts.map +1 -0
  99. package/dist/types/analytics.js +10 -0
  100. package/dist/types/analytics.js.map +1 -0
  101. package/dist/types/api.d.ts +2 -0
  102. package/dist/types/api.d.ts.map +1 -1
  103. package/dist/types/index.d.ts +1 -0
  104. package/dist/types/index.d.ts.map +1 -1
  105. package/dist/warehouse/analytics-helpers.d.ts +36 -0
  106. package/dist/warehouse/analytics-helpers.d.ts.map +1 -0
  107. package/dist/warehouse/analytics-helpers.js +142 -0
  108. package/dist/warehouse/analytics-helpers.js.map +1 -0
  109. package/dist/warehouse/backfill.d.ts +26 -0
  110. package/dist/warehouse/backfill.d.ts.map +1 -0
  111. package/dist/warehouse/backfill.js +77 -0
  112. package/dist/warehouse/backfill.js.map +1 -0
  113. package/dist/warehouse/connection.d.ts +18 -0
  114. package/dist/warehouse/connection.d.ts.map +1 -0
  115. package/dist/warehouse/connection.js +24 -0
  116. package/dist/warehouse/connection.js.map +1 -0
  117. package/dist/warehouse/index.d.ts +14 -0
  118. package/dist/warehouse/index.d.ts.map +1 -0
  119. package/dist/warehouse/index.js +14 -0
  120. package/dist/warehouse/index.js.map +1 -0
  121. package/dist/warehouse/repositories/analytics.d.ts +61 -0
  122. package/dist/warehouse/repositories/analytics.d.ts.map +1 -0
  123. package/dist/warehouse/repositories/analytics.js +418 -0
  124. package/dist/warehouse/repositories/analytics.js.map +1 -0
  125. package/dist/warehouse/schema.d.ts +9 -0
  126. package/dist/warehouse/schema.d.ts.map +1 -0
  127. package/dist/warehouse/schema.js +219 -0
  128. package/dist/warehouse/schema.js.map +1 -0
  129. package/dist/warehouse/seed-domains.d.ts +29 -0
  130. package/dist/warehouse/seed-domains.d.ts.map +1 -0
  131. package/dist/warehouse/seed-domains.js +223 -0
  132. package/dist/warehouse/seed-domains.js.map +1 -0
  133. package/package.json +1 -1
package/dist/api/app.d.ts CHANGED
@@ -5,11 +5,19 @@ import { Elysia } from 'elysia';
5
5
  import type { DatabaseService } from '../services/Database';
6
6
  import type { EventBusService } from '../services/EventBus';
7
7
  import type { VoyagerRateLimitState } from '../services/VoyagerRateLimit';
8
+ import type { AnalyticsRepository } from '../warehouse/repositories/analytics';
8
9
  export interface AppConfig {
9
10
  readonly db: DatabaseService;
10
11
  readonly eventBus: EventBusService;
11
12
  readonly adminApiKey: string;
12
13
  readonly rateLimit: VoyagerRateLimitState;
14
+ /**
15
+ * Warehouse analytics repository. `null` (or omitted) when
16
+ * WAREHOUSE_DATABASE_URL is not set — analytics routes return 503 and
17
+ * filter-aware variants of /api/rankings, /api/positions/:trader/stats fall
18
+ * back to OLTP / 503 for filtered requests.
19
+ */
20
+ readonly analytics?: AnalyticsRepository | null;
13
21
  }
14
22
  export declare function createApp(config: AppConfig): Elysia<"", {
15
23
  decorator: {};
@@ -321,7 +329,9 @@ export declare function createApp(config: AppConfig): Elysia<"", {
321
329
  query: unknown;
322
330
  headers: unknown;
323
331
  response: {
324
- 200: import("../types").TraderStatsResponse;
332
+ 200: import("../types").TraderStatsResponse | {
333
+ error: string;
334
+ };
325
335
  422: {
326
336
  type: "validation";
327
337
  on: string;
@@ -346,7 +356,9 @@ export declare function createApp(config: AppConfig): Elysia<"", {
346
356
  query: unknown;
347
357
  headers: unknown;
348
358
  response: {
349
- 200: import("../types").RankingEntry[];
359
+ 200: import("../types").RankingEntry[] | {
360
+ error: string;
361
+ };
350
362
  };
351
363
  };
352
364
  };
@@ -527,10 +539,10 @@ export declare function createApp(config: AppConfig): Elysia<"", {
527
539
  name: string;
528
540
  webhook_url: string;
529
541
  filters: {
530
- traders?: string[];
531
- eventTypes?: ("settlement" | "trade_move" | "market_created")[];
542
+ eventTypes?: ("trade_move" | "settlement" | "market_created")[];
532
543
  marketTypes?: string[];
533
544
  marketAddresses?: string[];
545
+ traders?: string[];
534
546
  minCollateral?: number;
535
547
  };
536
548
  };
@@ -538,9 +550,9 @@ export declare function createApp(config: AppConfig): Elysia<"", {
538
550
  query: unknown;
539
551
  headers: unknown;
540
552
  response: {
541
- 200: {
553
+ 200: import("../types").SubscriptionResponse | {
542
554
  error: string;
543
- } | import("../types").SubscriptionResponse;
555
+ };
544
556
  422: {
545
557
  type: "validation";
546
558
  on: string;
@@ -582,9 +594,9 @@ export declare function createApp(config: AppConfig): Elysia<"", {
582
594
  query: unknown;
583
595
  headers: unknown;
584
596
  response: {
585
- 200: {
597
+ 200: import("../types").SubscriptionResponse | {
586
598
  error: string;
587
- } | import("../types").SubscriptionResponse | {
599
+ } | {
588
600
  error: string;
589
601
  };
590
602
  422: {
@@ -608,13 +620,13 @@ export declare function createApp(config: AppConfig): Elysia<"", {
608
620
  put: {
609
621
  body: {
610
622
  name?: string;
611
- secret?: string;
612
623
  webhook_url?: string;
624
+ secret?: string;
613
625
  filters?: {
614
- traders?: string[];
615
- eventTypes?: ("settlement" | "trade_move" | "market_created")[];
626
+ eventTypes?: ("trade_move" | "settlement" | "market_created")[];
616
627
  marketTypes?: string[];
617
628
  marketAddresses?: string[];
629
+ traders?: string[];
618
630
  minCollateral?: number;
619
631
  };
620
632
  is_active?: boolean;
@@ -625,9 +637,9 @@ export declare function createApp(config: AppConfig): Elysia<"", {
625
637
  query: unknown;
626
638
  headers: unknown;
627
639
  response: {
628
- 200: {
640
+ 200: import("../types").SubscriptionResponse | {
629
641
  error: string;
630
- } | import("../types").SubscriptionResponse | {
642
+ } | {
631
643
  error: string;
632
644
  };
633
645
  422: {
@@ -679,6 +691,158 @@ export declare function createApp(config: AppConfig): Elysia<"", {
679
691
  };
680
692
  };
681
693
  };
694
+ } & {
695
+ api: {
696
+ analytics: {
697
+ overview: {
698
+ get: {
699
+ body: unknown;
700
+ params: {};
701
+ query: unknown;
702
+ headers: unknown;
703
+ response: {
704
+ 200: import("../types").AnalyticsOverviewResponse | {
705
+ error: string;
706
+ };
707
+ };
708
+ };
709
+ };
710
+ };
711
+ };
712
+ } & {
713
+ api: {
714
+ analytics: {
715
+ domains: {
716
+ get: {
717
+ body: unknown;
718
+ params: {};
719
+ query: unknown;
720
+ headers: unknown;
721
+ response: {
722
+ 200: import("../types").DomainsResponse | {
723
+ error: string;
724
+ };
725
+ };
726
+ };
727
+ };
728
+ };
729
+ };
730
+ } & {
731
+ api: {
732
+ analytics: {
733
+ domains: {
734
+ ":slug": {
735
+ get: {
736
+ body: unknown;
737
+ params: {
738
+ slug: string;
739
+ } & {};
740
+ query: unknown;
741
+ headers: unknown;
742
+ response: {
743
+ 200: import("../types").DomainDetailResponse | {
744
+ error: string;
745
+ };
746
+ 422: {
747
+ type: "validation";
748
+ on: string;
749
+ summary?: string;
750
+ message?: string;
751
+ found?: unknown;
752
+ property?: string;
753
+ expected?: string;
754
+ };
755
+ };
756
+ };
757
+ };
758
+ };
759
+ };
760
+ };
761
+ } & {
762
+ api: {
763
+ analytics: {
764
+ cohorts: {
765
+ get: {
766
+ body: unknown;
767
+ params: {};
768
+ query: unknown;
769
+ headers: unknown;
770
+ response: {
771
+ 200: import("../types").CohortsResponse | {
772
+ error: string;
773
+ };
774
+ };
775
+ };
776
+ };
777
+ };
778
+ };
779
+ } & {
780
+ api: {
781
+ analytics: {
782
+ roi: {
783
+ get: {
784
+ body: unknown;
785
+ params: {};
786
+ query: unknown;
787
+ headers: unknown;
788
+ response: {
789
+ 200: import("../types").RoiResponse | {
790
+ error: string;
791
+ };
792
+ };
793
+ };
794
+ };
795
+ };
796
+ };
797
+ } & {
798
+ api: {
799
+ analytics: {
800
+ leaderboard: {
801
+ get: {
802
+ body: unknown;
803
+ params: {};
804
+ query: unknown;
805
+ headers: unknown;
806
+ response: {
807
+ 200: import("../types").AnalyticsLeaderboardResponse | {
808
+ error: string;
809
+ };
810
+ };
811
+ };
812
+ };
813
+ };
814
+ };
815
+ } & {
816
+ api: {
817
+ analytics: {
818
+ traders: {
819
+ ":address": {
820
+ get: {
821
+ body: unknown;
822
+ params: {
823
+ address: string;
824
+ } & {};
825
+ query: unknown;
826
+ headers: unknown;
827
+ response: {
828
+ 200: import("../types").TraderAnalyticsResponse | {
829
+ error: string;
830
+ };
831
+ 422: {
832
+ type: "validation";
833
+ on: string;
834
+ summary?: string;
835
+ message?: string;
836
+ found?: unknown;
837
+ property?: string;
838
+ expected?: string;
839
+ };
840
+ };
841
+ };
842
+ };
843
+ };
844
+ };
845
+ };
682
846
  } & {
683
847
  ws: {
684
848
  subscribe: {
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/api/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAqB1E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,eAAe,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqB1C"}
package/dist/api/app.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { cors } from '@elysiajs/cors';
5
5
  import { Elysia } from 'elysia';
6
6
  import { errorHandler } from './middleware/error-handler';
7
- import { activityFeedRoutes, adminRoutes, adminSubscriptionRoutes, spiceFaucetRoutes, healthRoutes, lpHistoryRoutes, marketEventsRoutes, marketLPsRoutes, marketRoutes, marketTradersRoutes, multinoulliSnapshotsRoute, positionRoutes, rankingRoutes, traderEventsRoutes, traderStatsRoutes, wsRoutes, } from './routes';
7
+ import { activityFeedRoutes, adminRoutes, adminSubscriptionRoutes, analyticsRoutes, spiceFaucetRoutes, healthRoutes, lpHistoryRoutes, marketEventsRoutes, marketLPsRoutes, marketRoutes, marketTradersRoutes, multinoulliSnapshotsRoute, positionRoutes, rankingRoutes, traderEventsRoutes, traderStatsRoutes, wsRoutes, } from './routes';
8
8
  export function createApp(config) {
9
9
  return new Elysia()
10
10
  .use(cors())
@@ -18,12 +18,13 @@ export function createApp(config) {
18
18
  .use(lpHistoryRoutes(config.db))
19
19
  .use(positionRoutes(config.db))
20
20
  .use(traderEventsRoutes(config.db))
21
- .use(traderStatsRoutes(config.db))
22
- .use(rankingRoutes(config.db))
21
+ .use(traderStatsRoutes(config.db, config.analytics ?? null))
22
+ .use(rankingRoutes(config.db, config.analytics ?? null))
23
23
  .use(activityFeedRoutes(config.db))
24
24
  .use(spiceFaucetRoutes(config.db))
25
25
  .use(adminRoutes(config.db, config.adminApiKey))
26
26
  .use(adminSubscriptionRoutes(config.db, config.adminApiKey))
27
+ .use(analyticsRoutes(config.analytics ?? null))
27
28
  .use(wsRoutes(config.eventBus));
28
29
  }
29
30
  //# sourceMappingURL=app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/api/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,MAAM,UAAU,CAAC;AASlB,MAAM,UAAU,SAAS,CAAC,MAAiB;IACzC,OAAO,IAAI,MAAM,EAAE;SAChB,GAAG,CAAC,IAAI,EAAE,CAAC;SACX,GAAG,CAAC,YAAY,CAAC;SACjB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;SAC9C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAC5B,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAClC,GAAG,CAAC,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SACzC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SACnC,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAC/B,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;SAC/B,GAAG,CAAC,c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28,10 +28,10 @@ export declare const adminSubscriptionRoutes: (db: DatabaseService, adminApiKey:
28
28
  name: string;
29
29
  webhook_url: string;
30
30
  filters: {
31
- traders?: string[];
32
- eventTypes?: ("settlement" | "trade_move" | "market_created")[];
31
+ eventTypes?: ("trade_move" | "settlement" | "market_created")[];
33
32
  marketTypes?: string[];
34
33
  marketAddresses?: string[];
34
+ traders?: string[];
35
35
  minCollateral?: number;
36
36
  };
37
37
  };
@@ -39,9 +39,9 @@ export declare const adminSubscriptionRoutes: (db: DatabaseService, adminApiKey:
39
39
  query: unknown;
40
40
  headers: unknown;
41
41
  response: {
42
- 200: {
42
+ 200: SubscriptionResponse | {
43
43
  error: string;
44
- } | SubscriptionResponse;
44
+ };
45
45
  422: {
46
46
  type: "validation";
47
47
  on: string;
@@ -83,9 +83,9 @@ export declare const adminSubscriptionRoutes: (db: DatabaseService, adminApiKey:
83
83
  query: unknown;
84
84
  headers: unknown;
85
85
  response: {
86
- 200: {
86
+ 200: SubscriptionResponse | {
87
87
  error: string;
88
- } | SubscriptionResponse | {
88
+ } | {
89
89
  error: string;
90
90
  };
91
91
  422: {
@@ -109,13 +109,13 @@ export declare const adminSubscriptionRoutes: (db: DatabaseService, adminApiKey:
109
109
  put: {
110
110
  body: {
111
111
  name?: string;
112
- secret?: string;
113
112
  webhook_url?: string;
113
+ secret?: string;
114
114
  filters?: {
115
- traders?: string[];
116
- eventTypes?: ("settlement" | "trade_move" | "market_created")[];
115
+ eventTypes?: ("trade_move" | "settlement" | "market_created")[];
117
116
  marketTypes?: string[];
118
117
  marketAddresses?: string[];
118
+ traders?: string[];
119
119
  minCollateral?: number;
120
120
  };
121
121
  is_active?: boolean;
@@ -126,9 +126,9 @@ export declare const adminSubscriptionRoutes: (db: DatabaseService, adminApiKey:
126
126
  query: unknown;
127
127
  headers: unknown;
128
128
  response: {
129
- 200: {
129
+ 200: SubscriptionResponse | {
130
130
  error: string;
131
- } | SubscriptionResponse | {
131
+ } | {
132
132
  error: string;
133
133
  };
134
134
  422: {
@@ -0,0 +1,205 @@
1
+ /**
2
+ * GET /api/analytics/* — analytics endpoints backed by the Postgres warehouse.
3
+ *
4
+ * Routes:
5
+ * GET /api/analytics/overview — platform-wide headline stats
6
+ * GET /api/analytics/domains — per-domain summary list
7
+ * GET /api/analytics/domains/:slug — domain detail (time-series + top-N)
8
+ * GET /api/analytics/cohorts — cohort retention curves
9
+ * GET /api/analytics/roi — ROI distribution + summary stats
10
+ * GET /api/analytics/leaderboard — leaderboard with ?domain= and time window
11
+ * GET /api/analytics/traders/:address — per-trader analytics (per-domain + cohort)
12
+ *
13
+ * These routes are only registered when WAREHOUSE_DATABASE_URL is set.
14
+ *
15
+ * Validation errors throw via parseAnalyticsFilters / parseEntityType — the
16
+ * shared error-handler maps Error → 400 (we tag it explicitly via `set.status`).
17
+ */
18
+ import { Elysia } from 'elysia';
19
+ import type { AnalyticsRepository } from '../../warehouse/repositories/analytics';
20
+ /**
21
+ * Registers analytics routes. When `repo` is null (warehouse not configured),
22
+ * every analytics route returns 503 with a clear message so consumers can
23
+ * fall back gracefully.
24
+ */
25
+ export declare const analyticsRoutes: (repo: AnalyticsRepository | null) => Elysia<"", {
26
+ decorator: {};
27
+ store: {};
28
+ derive: {};
29
+ resolve: {};
30
+ }, {
31
+ typebox: {};
32
+ error: {};
33
+ }, {
34
+ schema: {};
35
+ standaloneSchema: {};
36
+ macro: {};
37
+ macroFn: {};
38
+ parser: {};
39
+ response: {};
40
+ }, {
41
+ api: {
42
+ analytics: {
43
+ overview: {
44
+ get: {
45
+ body: unknown;
46
+ params: {};
47
+ query: unknown;
48
+ headers: unknown;
49
+ response: {
50
+ 200: import("../../types").AnalyticsOverviewResponse | {
51
+ error: string;
52
+ };
53
+ };
54
+ };
55
+ };
56
+ };
57
+ };
58
+ } & {
59
+ api: {
60
+ analytics: {
61
+ domains: {
62
+ get: {
63
+ body: unknown;
64
+ params: {};
65
+ query: unknown;
66
+ headers: unknown;
67
+ response: {
68
+ 200: import("../../types").DomainsResponse | {
69
+ error: string;
70
+ };
71
+ };
72
+ };
73
+ };
74
+ };
75
+ };
76
+ } & {
77
+ api: {
78
+ analytics: {
79
+ domains: {
80
+ ":slug": {
81
+ get: {
82
+ body: unknown;
83
+ params: {
84
+ slug: string;
85
+ } & {};
86
+ query: unknown;
87
+ headers: unknown;
88
+ response: {
89
+ 200: import("../../types").DomainDetailResponse | {
90
+ error: string;
91
+ };
92
+ 422: {
93
+ type: "validation";
94
+ on: string;
95
+ summary?: string;
96
+ message?: string;
97
+ found?: unknown;
98
+ property?: string;
99
+ expected?: string;
100
+ };
101
+ };
102
+ };
103
+ };
104
+ };
105
+ };
106
+ };
107
+ } & {
108
+ api: {
109
+ analytics: {
110
+ cohorts: {
111
+ get: {
112
+ body: unknown;
113
+ params: {};
114
+ query: unknown;
115
+ headers: unknown;
116
+ response: {
117
+ 200: import("../../types").CohortsResponse | {
118
+ error: string;
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ } & {
126
+ api: {
127
+ analytics: {
128
+ roi: {
129
+ get: {
130
+ body: unknown;
131
+ params: {};
132
+ query: unknown;
133
+ headers: unknown;
134
+ response: {
135
+ 200: import("../../types").RoiResponse | {
136
+ error: string;
137
+ };
138
+ };
139
+ };
140
+ };
141
+ };
142
+ };
143
+ } & {
144
+ api: {
145
+ analytics: {
146
+ leaderboard: {
147
+ get: {
148
+ body: unknown;
149
+ params: {};
150
+ query: unknown;
151
+ headers: unknown;
152
+ response: {
153
+ 200: import("../../types").AnalyticsLeaderboardResponse | {
154
+ error: string;
155
+ };
156
+ };
157
+ };
158
+ };
159
+ };
160
+ };
161
+ } & {
162
+ api: {
163
+ analytics: {
164
+ traders: {
165
+ ":address": {
166
+ get: {
167
+ body: unknown;
168
+ params: {
169
+ address: string;
170
+ } & {};
171
+ query: unknown;
172
+ headers: unknown;
173
+ response: {
174
+ 200: import("../../types").TraderAnalyticsResponse | {
175
+ error: string;
176
+ };
177
+ 422: {
178
+ type: "validation";
179
+ on: string;
180
+ summary?: string;
181
+ message?: string;
182
+ found?: unknown;
183
+ property?: string;
184
+ expected?: string;
185
+ };
186
+ };
187
+ };
188
+ };
189
+ };
190
+ };
191
+ };
192
+ }, {
193
+ derive: {};
194
+ resolve: {};
195
+ schema: {};
196
+ standaloneSchema: {};
197
+ response: {};
198
+ }, {
199
+ derive: {};
200
+ resolve: {};
201
+ schema: {};
202
+ standaloneSchema: {};
203
+ response: {};
204
+ }>;
205
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../src/api/routes/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EACV,mBAAmB,EACpB,MAAM,wCAAwC,CAAC;AAahD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,mBAAmB,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuG1D,CAAC"}