@lcas58/esmi-api-types 1.0.21 → 1.0.23

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.
@@ -1,7 +1,8 @@
1
1
  import type { AppRouteHandler } from "../../lib/types.js";
2
- import type { DiscoverExternalRoute, DiscoverRoute, GetOneRoute, ListRoute, SaveExternalRoute } from "./events.routes.js";
2
+ import type { ChatRoute, DiscoverExternalRoute, DiscoverRoute, GetOneRoute, ListRoute, SaveExternalRoute } from "./events.routes.js";
3
3
  export declare const list: AppRouteHandler<ListRoute>;
4
4
  export declare const getOne: AppRouteHandler<GetOneRoute>;
5
5
  export declare const discover: AppRouteHandler<DiscoverRoute>;
6
6
  export declare const discoverExternal: AppRouteHandler<DiscoverExternalRoute>;
7
7
  export declare const saveExternal: AppRouteHandler<SaveExternalRoute>;
8
+ export declare const chat: AppRouteHandler<ChatRoute>;
@@ -1,10 +1,11 @@
1
1
  import { and, eq, gte, ilike, inArray, isNotNull, lte } from "drizzle-orm";
2
2
  import * as HttpStatusCodes from "stoker/http-status-codes";
3
3
  import * as HttpStatusPhrases from "stoker/http-status-phrases";
4
- import { agentEventsToRaw, runExternalDiscoveryAgent } from "../../agent/runner.js";
5
- import { saveEvents, searchLocalEvents } from "../../agent/tools.js";
4
+ import { agentEventsToRaw, runChatAgent, runExternalDiscoveryAgent } from "../../agent/runner.js";
5
+ import { getKnownExternalUrls, saveEvents, searchLocalEvents } from "../../agent/tools.js";
6
6
  import { createDb } from "../../db/index.js";
7
7
  import { event, location } from "../../db/schema/index.js";
8
+ import { buildCacheKey, buildSeenKey, getCachedDiscovery, markUrlsSeen, setCachedDiscovery } from "../../lib/discovery-cache.js";
8
9
  export const list = async (c) => {
9
10
  const { db } = createDb(c.env);
10
11
  const query = c.req.valid("query");
@@ -15,10 +16,12 @@ export const list = async (c) => {
15
16
  const state = query.state?.trim();
16
17
  // Time window (default: now → +7 days)
17
18
  const now = new Date();
18
- const from = query.from ? new Date(query.from) : now;
19
- const to = query.to
20
- ? new Date(query.to)
21
- : new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
19
+ const from = query.from ?? now;
20
+ const to = query.to ?? new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
21
+ // If `to` was date-only (midnight), extend to end of that day
22
+ if (query.to && to.getUTCHours() === 0 && to.getUTCMinutes() === 0 && to.getUTCSeconds() === 0) {
23
+ to.setUTCHours(23, 59, 59, 999);
24
+ }
22
25
  const whereConditions = [];
23
26
  if (sportId) {
24
27
  whereConditions.push(eq(event.sportId, sportId));
@@ -107,17 +110,59 @@ export const discover = async (c) => {
107
110
  });
108
111
  return c.json(events, HttpStatusCodes.OK);
109
112
  };
113
+ function filterByDateRange(events, from, to) {
114
+ if (!from && !to)
115
+ return events;
116
+ return events.filter((e) => {
117
+ const date = e.startsAt.split("T")[0];
118
+ if (from && date < from.split("T")[0])
119
+ return false;
120
+ if (to && date > to.split("T")[0])
121
+ return false;
122
+ return true;
123
+ });
124
+ }
110
125
  export const discoverExternal = async (c) => {
111
126
  const body = c.req.valid("json");
112
127
  const { db } = createDb(c.env);
113
- const previews = await runExternalDiscoveryAgent(c.env, db, {
128
+ const kv = c.env.DISCOVERY_CACHE;
129
+ const today = new Date().toISOString().split("T")[0];
130
+ const cacheKey = buildCacheKey(body.sportId, body.city, body.state, today);
131
+ const seenKey = buildSeenKey(body.sportId, body.city, body.state);
132
+ // Step 1: If not refresh, try cache first
133
+ if (!body.refresh) {
134
+ const cached = await getCachedDiscovery(kv, cacheKey);
135
+ if (cached !== null && cached.length > 0) {
136
+ const filtered = filterByDateRange(cached, body.from, body.to);
137
+ if (filtered.length > 0) {
138
+ console.log(`[discover] cache HIT for ${cacheKey} (${cached.length} total, ${filtered.length} in range)`);
139
+ return c.json(filtered, HttpStatusCodes.OK);
140
+ }
141
+ console.log(`[discover] cache HIT but 0 events in date range, falling through to agent`);
142
+ }
143
+ else {
144
+ console.log(`[discover] cache MISS for ${cacheKey}`);
145
+ }
146
+ }
147
+ // Step 2: Collect known URLs from DB for exclusion prompt
148
+ const dbUrls = await getKnownExternalUrls(db, body.sportId, body.city, body.state);
149
+ const knownUrls = dbUrls.length > 0 ? dbUrls : undefined;
150
+ // Step 3: Run agent web search
151
+ const results = await runExternalDiscoveryAgent(c.env, db, {
114
152
  sportId: body.sportId,
115
153
  city: body.city,
116
154
  state: body.state,
117
155
  from: body.from,
118
156
  to: body.to,
119
- });
120
- return c.json(previews, HttpStatusCodes.OK);
157
+ }, knownUrls);
158
+ // Step 4: Cache results (only if non-empty)
159
+ if (results.length > 0) {
160
+ await setCachedDiscovery(kv, cacheKey, results);
161
+ await markUrlsSeen(kv, seenKey, results.map((e) => e.url));
162
+ }
163
+ const filtered = filterByDateRange(results, body.from, body.to);
164
+ console.log(`[discover] agent returned ${results.length} events, returning ${filtered.length} in range for ${cacheKey}`);
165
+ return c.json(filtered, HttpStatusCodes.OK);
121
166
  };
122
167
  export const saveExternal = async (c) => {
123
168
  const { events: previews, city, state } = c.req.valid("json");
@@ -154,3 +199,14 @@ export const saveExternal = async (c) => {
154
199
  });
155
200
  return c.json(savedEvents, HttpStatusCodes.OK);
156
201
  };
202
+ export const chat = async (c) => {
203
+ const body = c.req.valid("json");
204
+ const { db } = createDb(c.env);
205
+ const result = await runChatAgent(c.env, db, {
206
+ message: body.message,
207
+ history: body.history,
208
+ city: body.city,
209
+ state: body.state,
210
+ });
211
+ return c.json(result, HttpStatusCodes.OK);
212
+ };
@@ -128,6 +128,7 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
128
128
  state: string;
129
129
  from?: string | undefined;
130
130
  to?: string | undefined;
131
+ refresh?: boolean | undefined;
131
132
  };
132
133
  };
133
134
  output: {
@@ -179,6 +180,7 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
179
180
  state: string;
180
181
  from?: string | undefined;
181
182
  to?: string | undefined;
183
+ refresh?: boolean | undefined;
182
184
  };
183
185
  };
184
186
  output: {
@@ -198,6 +200,7 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
198
200
  state: string;
199
201
  from?: string | undefined;
200
202
  to?: string | undefined;
203
+ refresh?: boolean | undefined;
201
204
  };
202
205
  };
203
206
  output: {
@@ -213,6 +216,7 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
213
216
  state: string;
214
217
  from?: string | undefined;
215
218
  to?: string | undefined;
219
+ refresh?: boolean | undefined;
216
220
  };
217
221
  };
218
222
  output: {
@@ -223,6 +227,8 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
223
227
  startsAt: string;
224
228
  timezone: string;
225
229
  formattedAddress: string;
230
+ latitude: number | null;
231
+ longitude: number | null;
226
232
  venueName: string;
227
233
  description?: string | undefined;
228
234
  endsAt?: string | undefined;
@@ -244,6 +250,8 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
244
250
  startsAt: string;
245
251
  timezone: string;
246
252
  formattedAddress: string;
253
+ latitude: number | null;
254
+ longitude: number | null;
247
255
  venueName: string;
248
256
  description?: string | undefined;
249
257
  endsAt?: string | undefined;
@@ -304,6 +312,8 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
304
312
  startsAt: string;
305
313
  timezone: string;
306
314
  formattedAddress: string;
315
+ latitude: number | null;
316
+ longitude: number | null;
307
317
  venueName: string;
308
318
  description?: string | undefined;
309
319
  endsAt?: string | undefined;
@@ -319,5 +329,57 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
319
329
  status: 401;
320
330
  };
321
331
  };
332
+ } & {
333
+ "/events/chat": {
334
+ $post: {
335
+ input: {
336
+ json: {
337
+ message: string;
338
+ city?: string | undefined;
339
+ state?: string | undefined;
340
+ history?: {
341
+ content: string;
342
+ role: "user" | "assistant";
343
+ }[] | undefined;
344
+ };
345
+ };
346
+ output: {
347
+ message: string;
348
+ };
349
+ outputFormat: "text" | "json";
350
+ status: 401;
351
+ } | {
352
+ input: {
353
+ json: {
354
+ message: string;
355
+ city?: string | undefined;
356
+ state?: string | undefined;
357
+ history?: {
358
+ content: string;
359
+ role: "user" | "assistant";
360
+ }[] | undefined;
361
+ };
362
+ };
363
+ output: {
364
+ events: {
365
+ url: string;
366
+ id: string;
367
+ title: string;
368
+ sport: string;
369
+ startsAt: string;
370
+ timezone: string;
371
+ formattedAddress: string;
372
+ latitude: number | null;
373
+ longitude: number | null;
374
+ venueName: string;
375
+ description?: string | undefined;
376
+ endsAt?: string | undefined;
377
+ }[];
378
+ reply: string;
379
+ };
380
+ outputFormat: "text" | "json";
381
+ status: 200;
382
+ };
383
+ };
322
384
  }, "/">;
323
385
  export default router;
@@ -6,5 +6,6 @@ const router = createRouter()
6
6
  .openapi(routes.getOne, handlers.getOne)
7
7
  .openapi(routes.discover, handlers.discover)
8
8
  .openapi(routes.discoverExternal, handlers.discoverExternal)
9
- .openapi(routes.saveExternal, handlers.saveExternal);
9
+ .openapi(routes.saveExternal, handlers.saveExternal)
10
+ .openapi(routes.chat, handlers.chat);
10
11
  export default router;
@@ -594,10 +594,12 @@ export declare const discoverRequestSchema: z.ZodObject<{
594
594
  state: z.ZodString;
595
595
  from: z.ZodOptional<z.ZodString>;
596
596
  to: z.ZodOptional<z.ZodString>;
597
+ refresh: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
597
598
  }, "strip", z.ZodTypeAny, {
598
599
  sportId: string;
599
600
  city: string;
600
601
  state: string;
602
+ refresh: boolean;
601
603
  from?: string | undefined;
602
604
  to?: string | undefined;
603
605
  }, {
@@ -606,6 +608,7 @@ export declare const discoverRequestSchema: z.ZodObject<{
606
608
  state: string;
607
609
  from?: string | undefined;
608
610
  to?: string | undefined;
611
+ refresh?: boolean | undefined;
609
612
  }>;
610
613
  export declare const discover: {
611
614
  path: "/events/discover";
@@ -623,10 +626,12 @@ export declare const discover: {
623
626
  state: z.ZodString;
624
627
  from: z.ZodOptional<z.ZodString>;
625
628
  to: z.ZodOptional<z.ZodString>;
629
+ refresh: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
626
630
  }, "strip", z.ZodTypeAny, {
627
631
  sportId: string;
628
632
  city: string;
629
633
  state: string;
634
+ refresh: boolean;
630
635
  from?: string | undefined;
631
636
  to?: string | undefined;
632
637
  }, {
@@ -635,6 +640,7 @@ export declare const discover: {
635
640
  state: string;
636
641
  from?: string | undefined;
637
642
  to?: string | undefined;
643
+ refresh?: boolean | undefined;
638
644
  }>;
639
645
  };
640
646
  };
@@ -935,10 +941,12 @@ export declare const discoverExternal: {
935
941
  state: z.ZodString;
936
942
  from: z.ZodOptional<z.ZodString>;
937
943
  to: z.ZodOptional<z.ZodString>;
944
+ refresh: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
938
945
  }, "strip", z.ZodTypeAny, {
939
946
  sportId: string;
940
947
  city: string;
941
948
  state: string;
949
+ refresh: boolean;
942
950
  from?: string | undefined;
943
951
  to?: string | undefined;
944
952
  }, {
@@ -947,6 +955,7 @@ export declare const discoverExternal: {
947
955
  state: string;
948
956
  from?: string | undefined;
949
957
  to?: string | undefined;
958
+ refresh?: boolean | undefined;
950
959
  }>;
951
960
  };
952
961
  };
@@ -966,6 +975,8 @@ export declare const discoverExternal: {
966
975
  url: z.ZodString;
967
976
  venueName: z.ZodString;
968
977
  formattedAddress: z.ZodString;
978
+ latitude: z.ZodNullable<z.ZodNumber>;
979
+ longitude: z.ZodNullable<z.ZodNumber>;
969
980
  description: z.ZodOptional<z.ZodString>;
970
981
  endsAt: z.ZodOptional<z.ZodString>;
971
982
  }, "strip", z.ZodTypeAny, {
@@ -976,6 +987,8 @@ export declare const discoverExternal: {
976
987
  startsAt: string;
977
988
  timezone: string;
978
989
  formattedAddress: string;
990
+ latitude: number | null;
991
+ longitude: number | null;
979
992
  venueName: string;
980
993
  description?: string | undefined;
981
994
  endsAt?: string | undefined;
@@ -987,6 +1000,8 @@ export declare const discoverExternal: {
987
1000
  startsAt: string;
988
1001
  timezone: string;
989
1002
  formattedAddress: string;
1003
+ latitude: number | null;
1004
+ longitude: number | null;
990
1005
  venueName: string;
991
1006
  description?: string | undefined;
992
1007
  endsAt?: string | undefined;
@@ -1033,6 +1048,8 @@ export declare const saveExternal: {
1033
1048
  url: z.ZodString;
1034
1049
  venueName: z.ZodString;
1035
1050
  formattedAddress: z.ZodString;
1051
+ latitude: z.ZodNullable<z.ZodNumber>;
1052
+ longitude: z.ZodNullable<z.ZodNumber>;
1036
1053
  description: z.ZodOptional<z.ZodString>;
1037
1054
  endsAt: z.ZodOptional<z.ZodString>;
1038
1055
  }, "strip", z.ZodTypeAny, {
@@ -1043,6 +1060,8 @@ export declare const saveExternal: {
1043
1060
  startsAt: string;
1044
1061
  timezone: string;
1045
1062
  formattedAddress: string;
1063
+ latitude: number | null;
1064
+ longitude: number | null;
1046
1065
  venueName: string;
1047
1066
  description?: string | undefined;
1048
1067
  endsAt?: string | undefined;
@@ -1054,6 +1073,8 @@ export declare const saveExternal: {
1054
1073
  startsAt: string;
1055
1074
  timezone: string;
1056
1075
  formattedAddress: string;
1076
+ latitude: number | null;
1077
+ longitude: number | null;
1057
1078
  venueName: string;
1058
1079
  description?: string | undefined;
1059
1080
  endsAt?: string | undefined;
@@ -1069,6 +1090,8 @@ export declare const saveExternal: {
1069
1090
  startsAt: string;
1070
1091
  timezone: string;
1071
1092
  formattedAddress: string;
1093
+ latitude: number | null;
1094
+ longitude: number | null;
1072
1095
  venueName: string;
1073
1096
  description?: string | undefined;
1074
1097
  endsAt?: string | undefined;
@@ -1084,6 +1107,8 @@ export declare const saveExternal: {
1084
1107
  startsAt: string;
1085
1108
  timezone: string;
1086
1109
  formattedAddress: string;
1110
+ latitude: number | null;
1111
+ longitude: number | null;
1087
1112
  venueName: string;
1088
1113
  description?: string | undefined;
1089
1114
  endsAt?: string | undefined;
@@ -1374,8 +1399,262 @@ export declare const saveExternal: {
1374
1399
  } & {
1375
1400
  getRoutingPath(): "/events/save-external";
1376
1401
  };
1402
+ export declare const chatRequestSchema: z.ZodObject<{
1403
+ message: z.ZodString;
1404
+ history: z.ZodOptional<z.ZodArray<z.ZodObject<{
1405
+ role: z.ZodEnum<["user", "assistant"]>;
1406
+ content: z.ZodString;
1407
+ }, "strip", z.ZodTypeAny, {
1408
+ content: string;
1409
+ role: "user" | "assistant";
1410
+ }, {
1411
+ content: string;
1412
+ role: "user" | "assistant";
1413
+ }>, "many">>;
1414
+ city: z.ZodOptional<z.ZodString>;
1415
+ state: z.ZodOptional<z.ZodString>;
1416
+ }, "strip", z.ZodTypeAny, {
1417
+ message: string;
1418
+ city?: string | undefined;
1419
+ state?: string | undefined;
1420
+ history?: {
1421
+ content: string;
1422
+ role: "user" | "assistant";
1423
+ }[] | undefined;
1424
+ }, {
1425
+ message: string;
1426
+ city?: string | undefined;
1427
+ state?: string | undefined;
1428
+ history?: {
1429
+ content: string;
1430
+ role: "user" | "assistant";
1431
+ }[] | undefined;
1432
+ }>;
1433
+ export declare const chatResponseSchema: z.ZodObject<{
1434
+ reply: z.ZodString;
1435
+ events: z.ZodArray<z.ZodObject<{
1436
+ id: z.ZodString;
1437
+ title: z.ZodString;
1438
+ sport: z.ZodString;
1439
+ startsAt: z.ZodString;
1440
+ timezone: z.ZodString;
1441
+ url: z.ZodString;
1442
+ venueName: z.ZodString;
1443
+ formattedAddress: z.ZodString;
1444
+ latitude: z.ZodNullable<z.ZodNumber>;
1445
+ longitude: z.ZodNullable<z.ZodNumber>;
1446
+ description: z.ZodOptional<z.ZodString>;
1447
+ endsAt: z.ZodOptional<z.ZodString>;
1448
+ }, "strip", z.ZodTypeAny, {
1449
+ url: string;
1450
+ id: string;
1451
+ title: string;
1452
+ sport: string;
1453
+ startsAt: string;
1454
+ timezone: string;
1455
+ formattedAddress: string;
1456
+ latitude: number | null;
1457
+ longitude: number | null;
1458
+ venueName: string;
1459
+ description?: string | undefined;
1460
+ endsAt?: string | undefined;
1461
+ }, {
1462
+ url: string;
1463
+ id: string;
1464
+ title: string;
1465
+ sport: string;
1466
+ startsAt: string;
1467
+ timezone: string;
1468
+ formattedAddress: string;
1469
+ latitude: number | null;
1470
+ longitude: number | null;
1471
+ venueName: string;
1472
+ description?: string | undefined;
1473
+ endsAt?: string | undefined;
1474
+ }>, "many">;
1475
+ }, "strip", z.ZodTypeAny, {
1476
+ events: {
1477
+ url: string;
1478
+ id: string;
1479
+ title: string;
1480
+ sport: string;
1481
+ startsAt: string;
1482
+ timezone: string;
1483
+ formattedAddress: string;
1484
+ latitude: number | null;
1485
+ longitude: number | null;
1486
+ venueName: string;
1487
+ description?: string | undefined;
1488
+ endsAt?: string | undefined;
1489
+ }[];
1490
+ reply: string;
1491
+ }, {
1492
+ events: {
1493
+ url: string;
1494
+ id: string;
1495
+ title: string;
1496
+ sport: string;
1497
+ startsAt: string;
1498
+ timezone: string;
1499
+ formattedAddress: string;
1500
+ latitude: number | null;
1501
+ longitude: number | null;
1502
+ venueName: string;
1503
+ description?: string | undefined;
1504
+ endsAt?: string | undefined;
1505
+ }[];
1506
+ reply: string;
1507
+ }>;
1508
+ export declare const chat: {
1509
+ path: "/events/chat";
1510
+ method: "post";
1511
+ tags: string[];
1512
+ middleware: [import("hono").MiddlewareHandler];
1513
+ request: {
1514
+ body: {
1515
+ required: boolean;
1516
+ content: {
1517
+ "application/json": {
1518
+ schema: z.ZodObject<{
1519
+ message: z.ZodString;
1520
+ history: z.ZodOptional<z.ZodArray<z.ZodObject<{
1521
+ role: z.ZodEnum<["user", "assistant"]>;
1522
+ content: z.ZodString;
1523
+ }, "strip", z.ZodTypeAny, {
1524
+ content: string;
1525
+ role: "user" | "assistant";
1526
+ }, {
1527
+ content: string;
1528
+ role: "user" | "assistant";
1529
+ }>, "many">>;
1530
+ city: z.ZodOptional<z.ZodString>;
1531
+ state: z.ZodOptional<z.ZodString>;
1532
+ }, "strip", z.ZodTypeAny, {
1533
+ message: string;
1534
+ city?: string | undefined;
1535
+ state?: string | undefined;
1536
+ history?: {
1537
+ content: string;
1538
+ role: "user" | "assistant";
1539
+ }[] | undefined;
1540
+ }, {
1541
+ message: string;
1542
+ city?: string | undefined;
1543
+ state?: string | undefined;
1544
+ history?: {
1545
+ content: string;
1546
+ role: "user" | "assistant";
1547
+ }[] | undefined;
1548
+ }>;
1549
+ };
1550
+ };
1551
+ description: string;
1552
+ };
1553
+ };
1554
+ responses: {
1555
+ 200: {
1556
+ content: {
1557
+ "application/json": {
1558
+ schema: z.ZodObject<{
1559
+ reply: z.ZodString;
1560
+ events: z.ZodArray<z.ZodObject<{
1561
+ id: z.ZodString;
1562
+ title: z.ZodString;
1563
+ sport: z.ZodString;
1564
+ startsAt: z.ZodString;
1565
+ timezone: z.ZodString;
1566
+ url: z.ZodString;
1567
+ venueName: z.ZodString;
1568
+ formattedAddress: z.ZodString;
1569
+ latitude: z.ZodNullable<z.ZodNumber>;
1570
+ longitude: z.ZodNullable<z.ZodNumber>;
1571
+ description: z.ZodOptional<z.ZodString>;
1572
+ endsAt: z.ZodOptional<z.ZodString>;
1573
+ }, "strip", z.ZodTypeAny, {
1574
+ url: string;
1575
+ id: string;
1576
+ title: string;
1577
+ sport: string;
1578
+ startsAt: string;
1579
+ timezone: string;
1580
+ formattedAddress: string;
1581
+ latitude: number | null;
1582
+ longitude: number | null;
1583
+ venueName: string;
1584
+ description?: string | undefined;
1585
+ endsAt?: string | undefined;
1586
+ }, {
1587
+ url: string;
1588
+ id: string;
1589
+ title: string;
1590
+ sport: string;
1591
+ startsAt: string;
1592
+ timezone: string;
1593
+ formattedAddress: string;
1594
+ latitude: number | null;
1595
+ longitude: number | null;
1596
+ venueName: string;
1597
+ description?: string | undefined;
1598
+ endsAt?: string | undefined;
1599
+ }>, "many">;
1600
+ }, "strip", z.ZodTypeAny, {
1601
+ events: {
1602
+ url: string;
1603
+ id: string;
1604
+ title: string;
1605
+ sport: string;
1606
+ startsAt: string;
1607
+ timezone: string;
1608
+ formattedAddress: string;
1609
+ latitude: number | null;
1610
+ longitude: number | null;
1611
+ venueName: string;
1612
+ description?: string | undefined;
1613
+ endsAt?: string | undefined;
1614
+ }[];
1615
+ reply: string;
1616
+ }, {
1617
+ events: {
1618
+ url: string;
1619
+ id: string;
1620
+ title: string;
1621
+ sport: string;
1622
+ startsAt: string;
1623
+ timezone: string;
1624
+ formattedAddress: string;
1625
+ latitude: number | null;
1626
+ longitude: number | null;
1627
+ venueName: string;
1628
+ description?: string | undefined;
1629
+ endsAt?: string | undefined;
1630
+ }[];
1631
+ reply: string;
1632
+ }>;
1633
+ };
1634
+ };
1635
+ description: string;
1636
+ };
1637
+ 401: {
1638
+ content: {
1639
+ "application/json": {
1640
+ schema: z.ZodObject<{
1641
+ message: z.ZodString;
1642
+ }, "strip", z.ZodTypeAny, {
1643
+ message: string;
1644
+ }, {
1645
+ message: string;
1646
+ }>;
1647
+ };
1648
+ };
1649
+ description: string;
1650
+ };
1651
+ };
1652
+ } & {
1653
+ getRoutingPath(): "/events/chat";
1654
+ };
1377
1655
  export type ListRoute = typeof list;
1378
1656
  export type GetOneRoute = typeof getOne;
1379
1657
  export type DiscoverRoute = typeof discover;
1380
1658
  export type DiscoverExternalRoute = typeof discoverExternal;
1381
1659
  export type SaveExternalRoute = typeof saveExternal;
1660
+ export type ChatRoute = typeof chat;
@@ -35,6 +35,7 @@ export const discoverRequestSchema = z.object({
35
35
  state: z.string().min(1),
36
36
  from: z.string().optional(),
37
37
  to: z.string().optional(),
38
+ refresh: z.boolean().optional().default(false),
38
39
  });
39
40
  export const discover = createRoute({
40
41
  path: "/events/discover",
@@ -79,3 +80,30 @@ export const saveExternal = createRoute({
79
80
  [HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
80
81
  },
81
82
  });
83
+ const chatMessageSchema = z.object({
84
+ role: z.enum(["user", "assistant"]),
85
+ content: z.string(),
86
+ });
87
+ export const chatRequestSchema = z.object({
88
+ message: z.string().min(1),
89
+ history: z.array(chatMessageSchema).optional(),
90
+ city: z.string().optional(),
91
+ state: z.string().optional(),
92
+ });
93
+ export const chatResponseSchema = z.object({
94
+ reply: z.string(),
95
+ events: z.array(externalEventPreviewSchema),
96
+ });
97
+ export const chat = createRoute({
98
+ path: "/events/chat",
99
+ method: "post",
100
+ tags: ["Events"],
101
+ middleware: [isAuth()],
102
+ request: {
103
+ body: jsonContentRequired(chatRequestSchema, "Chat message"),
104
+ },
105
+ responses: {
106
+ [HttpStatusCodes.OK]: jsonContent(chatResponseSchema, "Chat response with friendly text and events"),
107
+ [HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
108
+ },
109
+ });
@@ -288,6 +288,8 @@ export declare const externalEventPreviewSchema: z.ZodObject<{
288
288
  url: z.ZodString;
289
289
  venueName: z.ZodString;
290
290
  formattedAddress: z.ZodString;
291
+ latitude: z.ZodNullable<z.ZodNumber>;
292
+ longitude: z.ZodNullable<z.ZodNumber>;
291
293
  description: z.ZodOptional<z.ZodString>;
292
294
  endsAt: z.ZodOptional<z.ZodString>;
293
295
  }, "strip", z.ZodTypeAny, {
@@ -298,6 +300,8 @@ export declare const externalEventPreviewSchema: z.ZodObject<{
298
300
  startsAt: string;
299
301
  timezone: string;
300
302
  formattedAddress: string;
303
+ latitude: number | null;
304
+ longitude: number | null;
301
305
  venueName: string;
302
306
  description?: string | undefined;
303
307
  endsAt?: string | undefined;
@@ -309,6 +313,8 @@ export declare const externalEventPreviewSchema: z.ZodObject<{
309
313
  startsAt: string;
310
314
  timezone: string;
311
315
  formattedAddress: string;
316
+ latitude: number | null;
317
+ longitude: number | null;
312
318
  venueName: string;
313
319
  description?: string | undefined;
314
320
  endsAt?: string | undefined;
@@ -45,6 +45,8 @@ export const externalEventPreviewSchema = z.object({
45
45
  url: z.string(),
46
46
  venueName: z.string(),
47
47
  formattedAddress: z.string(),
48
+ latitude: z.number().nullable(),
49
+ longitude: z.number().nullable(),
48
50
  description: z.string().optional(),
49
51
  endsAt: z.string().optional(),
50
52
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcas58/esmi-api-types",
3
3
  "type": "module",
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {