@lcas58/esmi-api-types 1.0.26 → 1.0.28
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.
- package/dist/src/routes/events/events.handlers.js +20 -4
- package/dist/src/routes/events/events.index.d.ts +26 -19
- package/dist/src/routes/events/events.routes.d.ts +60 -39
- package/dist/src/routes/events/schemas/event.schemas.d.ts +20 -8
- package/dist/src/routes/events/schemas/event.schemas.js +3 -0
- package/dist/src/routes/groups/groups.handlers.d.ts +7 -0
- package/dist/src/routes/groups/groups.handlers.js +205 -0
- package/dist/src/routes/groups/groups.index.d.ts +337 -0
- package/dist/src/routes/groups/groups.index.js +10 -0
- package/dist/src/routes/{events/discover.routes.d.ts → groups/groups.routes.d.ts} +719 -47
- package/dist/src/routes/groups/groups.routes.js +77 -0
- package/dist/src/routes/groups/schemas/group.schemas.d.ts +214 -0
- package/dist/src/routes/groups/schemas/group.schemas.js +48 -0
- package/dist/src/routes/groups/schemas/index.d.ts +1 -0
- package/dist/src/routes/groups/schemas/index.js +1 -0
- package/dist/src/shared/client-types.d.ts +2 -1
- package/package.json +1 -1
- package/dist/src/routes/events/discover.handlers.d.ts +0 -3
- package/dist/src/routes/events/discover.handlers.js +0 -15
- package/dist/src/routes/events/discover.index.d.ts +0 -72
- package/dist/src/routes/events/discover.index.js +0 -6
- package/dist/src/routes/events/discover.routes.js +0 -26
- package/dist/src/routes/leagues/leagues.handlers.d.ts +0 -3
- package/dist/src/routes/leagues/leagues.handlers.js +0 -50
- package/dist/src/routes/leagues/leagues.index.d.ts +0 -53
- package/dist/src/routes/leagues/leagues.index.js +0 -6
- package/dist/src/routes/leagues/leagues.routes.d.ts +0 -137
- package/dist/src/routes/leagues/leagues.routes.js +0 -47
- package/dist/src/routes/organizations/organizations.handlers.d.ts +0 -74
- package/dist/src/routes/organizations/organizations.handlers.js +0 -485
- package/dist/src/routes/organizations/organizations.index.d.ts +0 -517
- package/dist/src/routes/organizations/organizations.index.js +0 -12
- package/dist/src/routes/organizations/organizations.routes.d.ts +0 -1236
- package/dist/src/routes/organizations/organizations.routes.js +0 -137
- package/dist/src/routes/organizations/tasks.test.d.ts +0 -0
- package/dist/src/routes/organizations/tasks.test.js +0 -181
- package/dist/src/routes/tags/tags.handlers.d.ts +0 -3
- package/dist/src/routes/tags/tags.handlers.js +0 -15
- package/dist/src/routes/tags/tags.index.d.ts +0 -24
- package/dist/src/routes/tags/tags.index.js +0 -6
- package/dist/src/routes/tags/tags.routes.d.ts +0 -68
- package/dist/src/routes/tags/tags.routes.js +0 -25
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
+
import { jsonContent, jsonContentRequired } from "stoker/openapi/helpers";
|
|
4
|
+
import { notFoundSchema, unauthorizedSchema } from "../../lib/constants.js";
|
|
5
|
+
import { isAuth } from "../../middlewares/is-auth.js";
|
|
6
|
+
import { eventWithRelationsSchema } from "../events/schemas/index.js";
|
|
7
|
+
import { createGroupBodySchema, groupEventsQuerySchema, groupWithRelationsSchema, listGroupsQuerySchema, updateGroupBodySchema, } from "./schemas/index.js";
|
|
8
|
+
export const list = createRoute({
|
|
9
|
+
path: "/groups",
|
|
10
|
+
method: "get",
|
|
11
|
+
tags: ["Groups"],
|
|
12
|
+
request: {
|
|
13
|
+
query: listGroupsQuerySchema,
|
|
14
|
+
},
|
|
15
|
+
responses: {
|
|
16
|
+
[HttpStatusCodes.OK]: jsonContent(z.array(groupWithRelationsSchema), "List of groups"),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export const getOne = createRoute({
|
|
20
|
+
path: "/groups/{id}",
|
|
21
|
+
method: "get",
|
|
22
|
+
tags: ["Groups"],
|
|
23
|
+
request: {
|
|
24
|
+
params: z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
responses: {
|
|
29
|
+
[HttpStatusCodes.OK]: jsonContent(groupWithRelationsSchema, "Group details"),
|
|
30
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Group not found"),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const getEvents = createRoute({
|
|
34
|
+
path: "/groups/{id}/events",
|
|
35
|
+
method: "get",
|
|
36
|
+
tags: ["Groups"],
|
|
37
|
+
request: {
|
|
38
|
+
params: z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
}),
|
|
41
|
+
query: groupEventsQuerySchema,
|
|
42
|
+
},
|
|
43
|
+
responses: {
|
|
44
|
+
[HttpStatusCodes.OK]: jsonContent(z.array(eventWithRelationsSchema), "Events for this group"),
|
|
45
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Group not found"),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
export const create = createRoute({
|
|
49
|
+
path: "/groups",
|
|
50
|
+
method: "post",
|
|
51
|
+
tags: ["Groups"],
|
|
52
|
+
middleware: [isAuth()],
|
|
53
|
+
request: {
|
|
54
|
+
body: jsonContentRequired(createGroupBodySchema, "Group to create"),
|
|
55
|
+
},
|
|
56
|
+
responses: {
|
|
57
|
+
[HttpStatusCodes.OK]: jsonContent(groupWithRelationsSchema, "Created group"),
|
|
58
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const update = createRoute({
|
|
62
|
+
path: "/groups/{id}",
|
|
63
|
+
method: "patch",
|
|
64
|
+
tags: ["Groups"],
|
|
65
|
+
middleware: [isAuth()],
|
|
66
|
+
request: {
|
|
67
|
+
params: z.object({
|
|
68
|
+
id: z.string(),
|
|
69
|
+
}),
|
|
70
|
+
body: jsonContentRequired(updateGroupBodySchema, "Fields to update"),
|
|
71
|
+
},
|
|
72
|
+
responses: {
|
|
73
|
+
[HttpStatusCodes.OK]: jsonContent(groupWithRelationsSchema, "Updated group"),
|
|
74
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Group not found"),
|
|
75
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const groupWithRelationsSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
slug: z.ZodString;
|
|
6
|
+
description: z.ZodNullable<z.ZodString>;
|
|
7
|
+
source: z.ZodEnum<["internal", "external"]>;
|
|
8
|
+
city: z.ZodNullable<z.ZodString>;
|
|
9
|
+
state: z.ZodNullable<z.ZodString>;
|
|
10
|
+
country: z.ZodString;
|
|
11
|
+
sportId: z.ZodString;
|
|
12
|
+
sourceOrgId: z.ZodNullable<z.ZodString>;
|
|
13
|
+
externalUrl: z.ZodNullable<z.ZodString>;
|
|
14
|
+
createdByUserId: z.ZodNullable<z.ZodString>;
|
|
15
|
+
imageUrl: z.ZodNullable<z.ZodString>;
|
|
16
|
+
isActive: z.ZodBoolean;
|
|
17
|
+
createdAt: z.ZodDate;
|
|
18
|
+
updatedAt: z.ZodDate;
|
|
19
|
+
}, {
|
|
20
|
+
sport: z.ZodNullable<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
icon: z.ZodNullable<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
icon: string | null;
|
|
28
|
+
}, {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
icon: string | null;
|
|
32
|
+
}>>;
|
|
33
|
+
creator: z.ZodNullable<z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
image: z.ZodNullable<z.ZodString>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
image: string | null;
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}, {
|
|
42
|
+
image: string | null;
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
}>>;
|
|
46
|
+
_count: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
events: z.ZodNumber;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
events: number;
|
|
50
|
+
}, {
|
|
51
|
+
events: number;
|
|
52
|
+
}>>;
|
|
53
|
+
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
54
|
+
id: string;
|
|
55
|
+
description: string | null;
|
|
56
|
+
name: string;
|
|
57
|
+
city: string | null;
|
|
58
|
+
state: string | null;
|
|
59
|
+
sportId: string;
|
|
60
|
+
createdAt: Date;
|
|
61
|
+
sport: {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
icon: string | null;
|
|
65
|
+
} | null;
|
|
66
|
+
country: string;
|
|
67
|
+
source: "external" | "internal";
|
|
68
|
+
slug: string;
|
|
69
|
+
isActive: boolean;
|
|
70
|
+
sourceOrgId: string | null;
|
|
71
|
+
externalUrl: string | null;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
createdByUserId: string | null;
|
|
74
|
+
imageUrl: string | null;
|
|
75
|
+
creator: {
|
|
76
|
+
image: string | null;
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
} | null;
|
|
80
|
+
_count?: {
|
|
81
|
+
events: number;
|
|
82
|
+
} | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
id: string;
|
|
85
|
+
description: string | null;
|
|
86
|
+
name: string;
|
|
87
|
+
city: string | null;
|
|
88
|
+
state: string | null;
|
|
89
|
+
sportId: string;
|
|
90
|
+
createdAt: Date;
|
|
91
|
+
sport: {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
icon: string | null;
|
|
95
|
+
} | null;
|
|
96
|
+
country: string;
|
|
97
|
+
source: "external" | "internal";
|
|
98
|
+
slug: string;
|
|
99
|
+
isActive: boolean;
|
|
100
|
+
sourceOrgId: string | null;
|
|
101
|
+
externalUrl: string | null;
|
|
102
|
+
updatedAt: Date;
|
|
103
|
+
createdByUserId: string | null;
|
|
104
|
+
imageUrl: string | null;
|
|
105
|
+
creator: {
|
|
106
|
+
image: string | null;
|
|
107
|
+
id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
} | null;
|
|
110
|
+
_count?: {
|
|
111
|
+
events: number;
|
|
112
|
+
} | undefined;
|
|
113
|
+
}>;
|
|
114
|
+
export declare const listGroupsQuerySchema: z.ZodObject<{
|
|
115
|
+
sportId: z.ZodOptional<z.ZodString>;
|
|
116
|
+
city: z.ZodOptional<z.ZodString>;
|
|
117
|
+
state: z.ZodOptional<z.ZodString>;
|
|
118
|
+
source: z.ZodOptional<z.ZodEnum<["internal", "external"]>>;
|
|
119
|
+
search: z.ZodOptional<z.ZodString>;
|
|
120
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
121
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
limit: number;
|
|
124
|
+
offset: number;
|
|
125
|
+
search?: string | undefined;
|
|
126
|
+
city?: string | undefined;
|
|
127
|
+
state?: string | undefined;
|
|
128
|
+
sportId?: string | undefined;
|
|
129
|
+
source?: "external" | "internal" | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
search?: string | undefined;
|
|
132
|
+
city?: string | undefined;
|
|
133
|
+
state?: string | undefined;
|
|
134
|
+
sportId?: string | undefined;
|
|
135
|
+
source?: "external" | "internal" | undefined;
|
|
136
|
+
limit?: number | undefined;
|
|
137
|
+
offset?: number | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
export declare const createGroupBodySchema: z.ZodObject<{
|
|
140
|
+
name: z.ZodString;
|
|
141
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
142
|
+
description: z.ZodOptional<z.ZodString>;
|
|
143
|
+
sportId: z.ZodString;
|
|
144
|
+
city: z.ZodOptional<z.ZodString>;
|
|
145
|
+
state: z.ZodOptional<z.ZodString>;
|
|
146
|
+
imageUrl: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, "strip", z.ZodTypeAny, {
|
|
148
|
+
name: string;
|
|
149
|
+
sportId: string;
|
|
150
|
+
description?: string | undefined;
|
|
151
|
+
city?: string | undefined;
|
|
152
|
+
state?: string | undefined;
|
|
153
|
+
slug?: string | undefined;
|
|
154
|
+
imageUrl?: string | undefined;
|
|
155
|
+
}, {
|
|
156
|
+
name: string;
|
|
157
|
+
sportId: string;
|
|
158
|
+
description?: string | undefined;
|
|
159
|
+
city?: string | undefined;
|
|
160
|
+
state?: string | undefined;
|
|
161
|
+
slug?: string | undefined;
|
|
162
|
+
imageUrl?: string | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
export declare const updateGroupBodySchema: z.ZodEffects<z.ZodObject<{
|
|
165
|
+
name: z.ZodOptional<z.ZodString>;
|
|
166
|
+
description: z.ZodOptional<z.ZodString>;
|
|
167
|
+
city: z.ZodOptional<z.ZodString>;
|
|
168
|
+
state: z.ZodOptional<z.ZodString>;
|
|
169
|
+
imageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
170
|
+
}, "strip", z.ZodTypeAny, {
|
|
171
|
+
description?: string | undefined;
|
|
172
|
+
name?: string | undefined;
|
|
173
|
+
city?: string | undefined;
|
|
174
|
+
state?: string | undefined;
|
|
175
|
+
imageUrl?: string | null | undefined;
|
|
176
|
+
}, {
|
|
177
|
+
description?: string | undefined;
|
|
178
|
+
name?: string | undefined;
|
|
179
|
+
city?: string | undefined;
|
|
180
|
+
state?: string | undefined;
|
|
181
|
+
imageUrl?: string | null | undefined;
|
|
182
|
+
}>, {
|
|
183
|
+
description?: string | undefined;
|
|
184
|
+
name?: string | undefined;
|
|
185
|
+
city?: string | undefined;
|
|
186
|
+
state?: string | undefined;
|
|
187
|
+
imageUrl?: string | null | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
description?: string | undefined;
|
|
190
|
+
name?: string | undefined;
|
|
191
|
+
city?: string | undefined;
|
|
192
|
+
state?: string | undefined;
|
|
193
|
+
imageUrl?: string | null | undefined;
|
|
194
|
+
}>;
|
|
195
|
+
export declare const groupEventsQuerySchema: z.ZodObject<{
|
|
196
|
+
from: z.ZodOptional<z.ZodDate>;
|
|
197
|
+
to: z.ZodOptional<z.ZodDate>;
|
|
198
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
199
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
limit: number;
|
|
202
|
+
offset: number;
|
|
203
|
+
from?: Date | undefined;
|
|
204
|
+
to?: Date | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
from?: Date | undefined;
|
|
207
|
+
to?: Date | undefined;
|
|
208
|
+
limit?: number | undefined;
|
|
209
|
+
offset?: number | undefined;
|
|
210
|
+
}>;
|
|
211
|
+
export type GroupWithRelations = z.infer<typeof groupWithRelationsSchema>;
|
|
212
|
+
export type ListGroupsQuery = z.infer<typeof listGroupsQuerySchema>;
|
|
213
|
+
export type CreateGroupBody = z.infer<typeof createGroupBodySchema>;
|
|
214
|
+
export type UpdateGroupBody = z.infer<typeof updateGroupBodySchema>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
import { selectGroupSchema } from "../../../db/schema/index.js";
|
|
3
|
+
export const groupWithRelationsSchema = selectGroupSchema.extend({
|
|
4
|
+
sport: z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
icon: z.string().nullable(),
|
|
8
|
+
}).nullable(),
|
|
9
|
+
creator: z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
image: z.string().nullable(),
|
|
13
|
+
}).nullable(),
|
|
14
|
+
_count: z.object({
|
|
15
|
+
events: z.number(),
|
|
16
|
+
}).optional(),
|
|
17
|
+
});
|
|
18
|
+
export const listGroupsQuerySchema = z.object({
|
|
19
|
+
sportId: z.string().optional(),
|
|
20
|
+
city: z.string().optional(),
|
|
21
|
+
state: z.string().optional(),
|
|
22
|
+
source: z.enum(["internal", "external"]).optional(),
|
|
23
|
+
search: z.string().optional(),
|
|
24
|
+
limit: z.coerce.number().min(1).max(100).optional().default(20),
|
|
25
|
+
offset: z.coerce.number().min(0).optional().default(0),
|
|
26
|
+
});
|
|
27
|
+
export const createGroupBodySchema = z.object({
|
|
28
|
+
name: z.string().min(1).max(255),
|
|
29
|
+
slug: z.string().min(1).max(255).optional(),
|
|
30
|
+
description: z.string().optional(),
|
|
31
|
+
sportId: z.string().min(1),
|
|
32
|
+
city: z.string().max(100).optional(),
|
|
33
|
+
state: z.string().max(50).optional(),
|
|
34
|
+
imageUrl: z.string().url().optional(),
|
|
35
|
+
});
|
|
36
|
+
export const updateGroupBodySchema = z.object({
|
|
37
|
+
name: z.string().min(1).max(255).optional(),
|
|
38
|
+
description: z.string().optional(),
|
|
39
|
+
city: z.string().max(100).optional(),
|
|
40
|
+
state: z.string().max(50).optional(),
|
|
41
|
+
imageUrl: z.string().url().nullable().optional(),
|
|
42
|
+
}).refine(data => Object.values(data).some(v => v !== undefined), { message: "At least one field must be provided" });
|
|
43
|
+
export const groupEventsQuerySchema = z.object({
|
|
44
|
+
from: z.coerce.date().optional(),
|
|
45
|
+
to: z.coerce.date().optional(),
|
|
46
|
+
limit: z.coerce.number().min(1).max(100).optional().default(20),
|
|
47
|
+
offset: z.coerce.number().min(0).optional().default(0),
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type CreateGroupBody, createGroupBodySchema, groupEventsQuerySchema, type GroupWithRelations, groupWithRelationsSchema, type ListGroupsQuery, listGroupsQuerySchema, type UpdateGroupBody, updateGroupBodySchema, } from "./group.schemas.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createGroupBodySchema, groupEventsQuerySchema, groupWithRelationsSchema, listGroupsQuerySchema, updateGroupBodySchema, } from "./group.schemas.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type events from "../routes/events/events.index.js";
|
|
2
|
+
import type groups from "../routes/groups/groups.index.js";
|
|
2
3
|
import type index from "../routes/index.route.js";
|
|
3
4
|
import type marketing from "../routes/marketing/marketing.index.js";
|
|
4
5
|
import type sports from "../routes/sports/sports.index.js";
|
|
5
6
|
import type users from "../routes/users/users.index.js";
|
|
6
7
|
import type webhooks from "../routes/webhooks/webhooks.index.js";
|
|
7
|
-
export type AppType = typeof index | typeof events | typeof sports | typeof users | typeof marketing | typeof webhooks;
|
|
8
|
+
export type AppType = typeof index | typeof events | typeof groups | typeof sports | typeof users | typeof marketing | typeof webhooks;
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
2
|
-
import { runDiscoveryAgent } from "../../agent/runner.js";
|
|
3
|
-
import { createDb } from "../../db/index.js";
|
|
4
|
-
export const discover = async (c) => {
|
|
5
|
-
const body = c.req.valid("json");
|
|
6
|
-
const { db } = createDb(c.env);
|
|
7
|
-
const events = await runDiscoveryAgent(c.env, db, {
|
|
8
|
-
sportId: body.sportId,
|
|
9
|
-
city: body.city,
|
|
10
|
-
state: body.state,
|
|
11
|
-
from: body.from,
|
|
12
|
-
to: body.to,
|
|
13
|
-
});
|
|
14
|
-
return c.json(events, HttpStatusCodes.OK);
|
|
15
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shared/index.js").AppBindings, {
|
|
2
|
-
"/events/discover": {
|
|
3
|
-
$post: {
|
|
4
|
-
input: {
|
|
5
|
-
json: {
|
|
6
|
-
sportId: string;
|
|
7
|
-
city: string;
|
|
8
|
-
state: string;
|
|
9
|
-
from?: string | undefined;
|
|
10
|
-
to?: string | undefined;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
output: {
|
|
14
|
-
metadata: any;
|
|
15
|
-
id: string;
|
|
16
|
-
title: string;
|
|
17
|
-
createdAt: string;
|
|
18
|
-
sport: {
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
icon: string | null;
|
|
22
|
-
} | null;
|
|
23
|
-
sportId: string;
|
|
24
|
-
startsAt: string;
|
|
25
|
-
endsAt: string | null;
|
|
26
|
-
timezone: string;
|
|
27
|
-
location: {
|
|
28
|
-
id: string;
|
|
29
|
-
name: string;
|
|
30
|
-
formattedAddress: string;
|
|
31
|
-
city: string | null;
|
|
32
|
-
state: string | null;
|
|
33
|
-
latitude: number | null;
|
|
34
|
-
longitude: number | null;
|
|
35
|
-
} | null;
|
|
36
|
-
locationId: string | null;
|
|
37
|
-
externalLinkId: string | null;
|
|
38
|
-
source: "external" | "community";
|
|
39
|
-
thumbnailUrl: string | null;
|
|
40
|
-
createdByUserId: string | null;
|
|
41
|
-
creator: {
|
|
42
|
-
image: string | null;
|
|
43
|
-
id: string;
|
|
44
|
-
name: string;
|
|
45
|
-
} | null;
|
|
46
|
-
externalLink: {
|
|
47
|
-
url: string;
|
|
48
|
-
id: string;
|
|
49
|
-
domain: string;
|
|
50
|
-
} | null;
|
|
51
|
-
}[];
|
|
52
|
-
outputFormat: "text" | "json";
|
|
53
|
-
status: 200;
|
|
54
|
-
} | {
|
|
55
|
-
input: {
|
|
56
|
-
json: {
|
|
57
|
-
sportId: string;
|
|
58
|
-
city: string;
|
|
59
|
-
state: string;
|
|
60
|
-
from?: string | undefined;
|
|
61
|
-
to?: string | undefined;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
output: {
|
|
65
|
-
message: string;
|
|
66
|
-
};
|
|
67
|
-
outputFormat: "text" | "json";
|
|
68
|
-
status: 401;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
}, "/">;
|
|
72
|
-
export default router;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
-
import { jsonContent, jsonContentRequired } from "stoker/openapi/helpers";
|
|
4
|
-
import { unauthorizedSchema } from "../../lib/constants.js";
|
|
5
|
-
import { isAuth } from "../../middlewares/is-auth.js";
|
|
6
|
-
import { eventWithRelationsSchema } from "./schemas/index.js";
|
|
7
|
-
export const discoverRequestSchema = z.object({
|
|
8
|
-
sportId: z.string().min(1),
|
|
9
|
-
city: z.string().min(1),
|
|
10
|
-
state: z.string().min(1),
|
|
11
|
-
from: z.string().optional(),
|
|
12
|
-
to: z.string().optional(),
|
|
13
|
-
});
|
|
14
|
-
export const discover = createRoute({
|
|
15
|
-
path: "/events/discover",
|
|
16
|
-
method: "post",
|
|
17
|
-
tags: ["Events"],
|
|
18
|
-
middleware: [isAuth()],
|
|
19
|
-
request: {
|
|
20
|
-
body: jsonContentRequired(discoverRequestSchema, "Event discovery criteria"),
|
|
21
|
-
},
|
|
22
|
-
responses: {
|
|
23
|
-
[HttpStatusCodes.OK]: jsonContent(z.array(eventWithRelationsSchema), "Discovered events"),
|
|
24
|
-
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { eq, sql } from "drizzle-orm";
|
|
2
|
-
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
-
import * as HttpStatusPhrases from "stoker/http-status-phrases";
|
|
4
|
-
import { createDb } from "../../db/index.js";
|
|
5
|
-
import { event, eventTags, leagues, location, organization, tags, user } from "../../db/schema/index.js";
|
|
6
|
-
export const list = async (c) => {
|
|
7
|
-
const { db } = createDb(c.env);
|
|
8
|
-
const { locationId } = c.req.valid("param");
|
|
9
|
-
const data = await db
|
|
10
|
-
.select({
|
|
11
|
-
name: event.name,
|
|
12
|
-
description: event.description,
|
|
13
|
-
formattedAddress: location.formattedAddress,
|
|
14
|
-
type: event.type,
|
|
15
|
-
organization: {
|
|
16
|
-
name: organization.name,
|
|
17
|
-
description: organization.description,
|
|
18
|
-
ownerName: user.name,
|
|
19
|
-
},
|
|
20
|
-
mode: event.mode,
|
|
21
|
-
ageGroup: event.ageGroup,
|
|
22
|
-
gender: event.gender,
|
|
23
|
-
status: event.status,
|
|
24
|
-
numberOfTeams: leagues.numberOfTeams,
|
|
25
|
-
scheduleDays: leagues.scheduleDays,
|
|
26
|
-
scheduleTimes: leagues.scheduleTimes,
|
|
27
|
-
startDate: leagues.startDate,
|
|
28
|
-
endDate: leagues.endDate,
|
|
29
|
-
season: leagues.season,
|
|
30
|
-
registrationStart: leagues.registrationStart,
|
|
31
|
-
registrationEnd: leagues.registrationEnd,
|
|
32
|
-
teamFee: leagues.teamFee,
|
|
33
|
-
tags: sql `array_agg(json_build_object('id', ${tags.id}, 'name', ${tags.name}))`.as("tags"),
|
|
34
|
-
})
|
|
35
|
-
.from(event)
|
|
36
|
-
.innerJoin(leagues, eq(leagues.eventId, event.id))
|
|
37
|
-
.innerJoin(location, eq(event.locationId, location.id))
|
|
38
|
-
.innerJoin(organization, eq(event.organizationId, organization.id))
|
|
39
|
-
.innerJoin(user, eq(organization.ownerId, user.id))
|
|
40
|
-
.innerJoin(eventTags, eq(event.id, eventTags.eventId))
|
|
41
|
-
.innerJoin(tags, eq(eventTags.tagId, tags.id))
|
|
42
|
-
.where(eq(event.locationId, locationId))
|
|
43
|
-
.groupBy(event.id, leagues.id, location.id, organization.id, user.id);
|
|
44
|
-
if (data.length === 0) {
|
|
45
|
-
return c.json({
|
|
46
|
-
message: HttpStatusPhrases.NOT_FOUND,
|
|
47
|
-
}, HttpStatusCodes.NOT_FOUND);
|
|
48
|
-
}
|
|
49
|
-
return c.json(data, HttpStatusCodes.OK);
|
|
50
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shared/index.js").AppBindings, {
|
|
2
|
-
"/leagues/:locationId": {
|
|
3
|
-
$get: {
|
|
4
|
-
input: {
|
|
5
|
-
param: {
|
|
6
|
-
[x: string]: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
output: {
|
|
10
|
-
message: string;
|
|
11
|
-
};
|
|
12
|
-
outputFormat: "text" | "json";
|
|
13
|
-
status: 404;
|
|
14
|
-
} | {
|
|
15
|
-
input: {
|
|
16
|
-
param: {
|
|
17
|
-
[x: string]: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
output: {
|
|
21
|
-
status: string;
|
|
22
|
-
type: string;
|
|
23
|
-
description: string | null;
|
|
24
|
-
name: string;
|
|
25
|
-
formattedAddress: string;
|
|
26
|
-
organization: {
|
|
27
|
-
description: string;
|
|
28
|
-
name: string;
|
|
29
|
-
ownerName: string;
|
|
30
|
-
};
|
|
31
|
-
mode: string;
|
|
32
|
-
ageGroup: string;
|
|
33
|
-
gender: string;
|
|
34
|
-
tags: {
|
|
35
|
-
id: string;
|
|
36
|
-
name: string;
|
|
37
|
-
}[];
|
|
38
|
-
numberOfTeams: number;
|
|
39
|
-
scheduleDays: string | null;
|
|
40
|
-
scheduleTimes: string | null;
|
|
41
|
-
startDate: string;
|
|
42
|
-
endDate: string;
|
|
43
|
-
season: string | null;
|
|
44
|
-
registrationStart: string | null;
|
|
45
|
-
registrationEnd: string | null;
|
|
46
|
-
teamFee: number | null;
|
|
47
|
-
}[];
|
|
48
|
-
outputFormat: "text" | "json";
|
|
49
|
-
status: 200;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}, "/">;
|
|
53
|
-
export default router;
|