@lcas58/esmi-api-types 1.0.9 → 1.0.10
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.d.ts +2 -18
- package/dist/src/routes/events/events.handlers.js +24 -154
- package/dist/src/routes/events/events.index.d.ts +47 -442
- package/dist/src/routes/events/events.index.js +1 -3
- package/dist/src/routes/events/events.routes.d.ts +347 -1194
- package/dist/src/routes/events/events.routes.js +11 -53
- package/dist/src/routes/events/schemas/event.schemas.d.ts +173 -824
- package/dist/src/routes/events/schemas/event.schemas.js +26 -46
- package/dist/src/routes/events/schemas/index.d.ts +1 -1
- package/dist/src/routes/events/schemas/index.js +1 -1
- package/dist/src/routes/marketing/marketing.index.d.ts +14 -14
- package/dist/src/routes/marketing/marketing.routes.d.ts +5 -5
- package/dist/src/routes/sports/sports.handlers.d.ts +4 -0
- package/dist/src/routes/sports/sports.handlers.js +23 -0
- package/dist/src/routes/sports/sports.index.d.ts +45 -0
- package/dist/src/routes/sports/sports.index.js +7 -0
- package/dist/src/routes/sports/sports.routes.d.ts +90 -0
- package/dist/src/routes/sports/sports.routes.js +27 -0
- package/dist/src/routes/webhooks/webhooks.routes.d.ts +1 -0
- package/dist/src/routes/webhooks/webhooks.routes.js +2 -0
- package/dist/src/shared/client-types.d.ts +2 -4
- package/package.json +1 -1
|
@@ -1,49 +1,29 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { selectEventSchema } from "../../../db/schema/
|
|
3
|
-
import { insertLocationSchema, selectLocationSchema } from "../../../db/schema/location.js";
|
|
4
|
-
import { selectOrganizationSchema } from "../../../db/schema/organization.js";
|
|
5
|
-
import { selectUserSchema } from "../../../db/schema/user.js";
|
|
6
|
-
export const createEventSchema = z.object({
|
|
7
|
-
name: selectEventSchema.shape.name,
|
|
8
|
-
description: selectEventSchema.shape.description,
|
|
9
|
-
location: insertLocationSchema,
|
|
10
|
-
type: selectEventSchema.shape.type,
|
|
11
|
-
organizationId: selectEventSchema.shape.organizationId,
|
|
12
|
-
ageGroup: selectEventSchema.shape.ageGroup,
|
|
13
|
-
gender: selectEventSchema.shape.gender,
|
|
14
|
-
}).refine(data => data.location, {
|
|
15
|
-
message: "Location details must be provided",
|
|
16
|
-
});
|
|
17
|
-
// Patch event schema (all fields optional)
|
|
18
|
-
export const patchEventSchema = z.object({
|
|
19
|
-
name: selectEventSchema.shape.name.min(1).optional(),
|
|
20
|
-
description: selectEventSchema.shape.description,
|
|
21
|
-
location: insertLocationSchema.optional(),
|
|
22
|
-
type: selectEventSchema.shape.type.optional(),
|
|
23
|
-
organizationId: selectEventSchema.shape.organizationId.optional(),
|
|
24
|
-
mode: selectEventSchema.shape.mode.optional(),
|
|
25
|
-
ageGroup: selectEventSchema.shape.ageGroup.optional(),
|
|
26
|
-
gender: selectEventSchema.shape.gender,
|
|
27
|
-
status: selectEventSchema.shape.status.optional(),
|
|
28
|
-
});
|
|
29
|
-
// Query schema for list endpoint using Drizzle schema shape
|
|
30
|
-
export const listEventsQuerySchema = z.object({
|
|
31
|
-
status: selectEventSchema.shape.status.optional(),
|
|
32
|
-
type: selectEventSchema.shape.type.optional(),
|
|
33
|
-
organizationId: selectEventSchema.shape.organizationId.optional(),
|
|
34
|
-
});
|
|
35
|
-
// Response schemas with relations
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
import { selectEventSchema } from "../../../db/schema/index.js";
|
|
36
3
|
export const eventWithRelationsSchema = selectEventSchema.extend({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
4
|
+
sport: z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
icon: z.string().nullable(),
|
|
8
|
+
}).nullable(),
|
|
9
|
+
location: z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
formattedAddress: z.string(),
|
|
13
|
+
city: z.string().nullable(),
|
|
14
|
+
state: z.string().nullable(),
|
|
15
|
+
latitude: z.number().nullable(),
|
|
16
|
+
longitude: z.number().nullable(),
|
|
17
|
+
}).nullable(),
|
|
18
|
+
externalLink: z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
url: z.string(),
|
|
21
|
+
domain: z.string(),
|
|
22
|
+
}).nullable(),
|
|
40
23
|
});
|
|
41
|
-
export const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
upcoming: z.number(),
|
|
47
|
-
inProgress: z.number(),
|
|
48
|
-
completed: z.number(),
|
|
24
|
+
export const listEventsQuerySchema = z.object({
|
|
25
|
+
sportId: z.string().optional(),
|
|
26
|
+
source: z.enum(["external", "community"]).optional(),
|
|
27
|
+
limit: z.coerce.number().min(1).max(100).default(20).optional(),
|
|
28
|
+
offset: z.coerce.number().min(0).default(0).optional(),
|
|
49
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { eventWithRelationsSchema, listEventsQuerySchema, type EventWithRelations, type ListEventsQuery, } from "./event.schemas.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { eventWithRelationsSchema, listEventsQuerySchema, } from "./event.schemas.js";
|
|
@@ -11,8 +11,8 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
|
|
|
11
11
|
input: {};
|
|
12
12
|
output: {
|
|
13
13
|
id: number;
|
|
14
|
-
email: string;
|
|
15
14
|
createdAt: string | null;
|
|
15
|
+
email: string;
|
|
16
16
|
}[];
|
|
17
17
|
outputFormat: "text" | "json";
|
|
18
18
|
status: 200;
|
|
@@ -21,6 +21,19 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
|
|
|
21
21
|
} & {
|
|
22
22
|
"/marketing/email": {
|
|
23
23
|
$post: {
|
|
24
|
+
input: {
|
|
25
|
+
json: {
|
|
26
|
+
email: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
output: {
|
|
30
|
+
id: number;
|
|
31
|
+
createdAt: string | null;
|
|
32
|
+
email: string;
|
|
33
|
+
};
|
|
34
|
+
outputFormat: "text" | "json";
|
|
35
|
+
status: 200;
|
|
36
|
+
} | {
|
|
24
37
|
input: {
|
|
25
38
|
json: {
|
|
26
39
|
email: string;
|
|
@@ -39,19 +52,6 @@ declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shar
|
|
|
39
52
|
};
|
|
40
53
|
outputFormat: "text" | "json";
|
|
41
54
|
status: 422;
|
|
42
|
-
} | {
|
|
43
|
-
input: {
|
|
44
|
-
json: {
|
|
45
|
-
email: string;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
output: {
|
|
49
|
-
id: number;
|
|
50
|
-
email: string;
|
|
51
|
-
createdAt: string | null;
|
|
52
|
-
};
|
|
53
|
-
outputFormat: "text" | "json";
|
|
54
|
-
status: 200;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
}, "/">;
|
|
@@ -13,12 +13,12 @@ export declare const list: {
|
|
|
13
13
|
createdAt: z.ZodNullable<z.ZodDate>;
|
|
14
14
|
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
15
15
|
id: number;
|
|
16
|
-
email: string;
|
|
17
16
|
createdAt: Date | null;
|
|
17
|
+
email: string;
|
|
18
18
|
}, {
|
|
19
19
|
id: number;
|
|
20
|
-
email: string;
|
|
21
20
|
createdAt: Date | null;
|
|
21
|
+
email: string;
|
|
22
22
|
}>, "many">;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
@@ -53,8 +53,8 @@ export declare const create: {
|
|
|
53
53
|
"application/json": {
|
|
54
54
|
schema: z.ZodObject<Omit<{
|
|
55
55
|
id: z.ZodOptional<z.ZodNumber>;
|
|
56
|
-
email: z.ZodString;
|
|
57
56
|
createdAt: z.ZodOptional<z.ZodNullable<z.ZodDate>>;
|
|
57
|
+
email: z.ZodString;
|
|
58
58
|
}, "id" | "createdAt">, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
59
59
|
email: string;
|
|
60
60
|
}, {
|
|
@@ -75,12 +75,12 @@ export declare const create: {
|
|
|
75
75
|
createdAt: z.ZodNullable<z.ZodDate>;
|
|
76
76
|
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
77
77
|
id: number;
|
|
78
|
-
email: string;
|
|
79
78
|
createdAt: Date | null;
|
|
79
|
+
email: string;
|
|
80
80
|
}, {
|
|
81
81
|
id: number;
|
|
82
|
-
email: string;
|
|
83
82
|
createdAt: Date | null;
|
|
83
|
+
email: string;
|
|
84
84
|
}>;
|
|
85
85
|
};
|
|
86
86
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { eq } 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 { sport } from "../../db/schema/index.js";
|
|
6
|
+
export const list = async (c) => {
|
|
7
|
+
const { db } = createDb(c.env);
|
|
8
|
+
const sports = await db.query.sport.findMany({
|
|
9
|
+
orderBy: (sport, { asc }) => [asc(sport.name)],
|
|
10
|
+
});
|
|
11
|
+
return c.json(sports, HttpStatusCodes.OK);
|
|
12
|
+
};
|
|
13
|
+
export const getOne = async (c) => {
|
|
14
|
+
const { db } = createDb(c.env);
|
|
15
|
+
const { id } = c.req.valid("param");
|
|
16
|
+
const foundSport = await db.query.sport.findFirst({
|
|
17
|
+
where: eq(sport.id, id),
|
|
18
|
+
});
|
|
19
|
+
if (!foundSport) {
|
|
20
|
+
return c.json({ message: HttpStatusPhrases.NOT_FOUND }, HttpStatusCodes.NOT_FOUND);
|
|
21
|
+
}
|
|
22
|
+
return c.json(foundSport, HttpStatusCodes.OK);
|
|
23
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shared/index.js").AppBindings, {
|
|
2
|
+
"/sports": {
|
|
3
|
+
$get: {
|
|
4
|
+
input: {};
|
|
5
|
+
output: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
icon: string | null;
|
|
10
|
+
}[];
|
|
11
|
+
outputFormat: "text" | "json";
|
|
12
|
+
status: 200;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
} & {
|
|
16
|
+
"/sports/:id": {
|
|
17
|
+
$get: {
|
|
18
|
+
input: {
|
|
19
|
+
param: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
output: {
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
outputFormat: "text" | "json";
|
|
27
|
+
status: 404;
|
|
28
|
+
} | {
|
|
29
|
+
input: {
|
|
30
|
+
param: {
|
|
31
|
+
id: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
output: {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
icon: string | null;
|
|
39
|
+
};
|
|
40
|
+
outputFormat: "text" | "json";
|
|
41
|
+
status: 200;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}, "/">;
|
|
45
|
+
export default router;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRouter } from "../../lib/create-app.js";
|
|
2
|
+
import * as handlers from "./sports.handlers.js";
|
|
3
|
+
import * as routes from "./sports.routes.js";
|
|
4
|
+
const router = createRouter()
|
|
5
|
+
.openapi(routes.list, handlers.list)
|
|
6
|
+
.openapi(routes.getOne, handlers.getOne);
|
|
7
|
+
export default router;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const list: {
|
|
3
|
+
path: "/sports";
|
|
4
|
+
method: "get";
|
|
5
|
+
tags: string[];
|
|
6
|
+
responses: {
|
|
7
|
+
200: {
|
|
8
|
+
content: {
|
|
9
|
+
"application/json": {
|
|
10
|
+
schema: z.ZodArray<z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
icon: z.ZodNullable<z.ZodString>;
|
|
14
|
+
createdAt: z.ZodDate;
|
|
15
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
icon: string | null;
|
|
20
|
+
}, {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
icon: string | null;
|
|
25
|
+
}>, "many">;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
} & {
|
|
32
|
+
getRoutingPath(): "/sports";
|
|
33
|
+
};
|
|
34
|
+
export declare const getOne: {
|
|
35
|
+
path: "/sports/{id}";
|
|
36
|
+
method: "get";
|
|
37
|
+
tags: string[];
|
|
38
|
+
request: {
|
|
39
|
+
params: z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
id: string;
|
|
43
|
+
}, {
|
|
44
|
+
id: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
responses: {
|
|
48
|
+
200: {
|
|
49
|
+
content: {
|
|
50
|
+
"application/json": {
|
|
51
|
+
schema: z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
icon: z.ZodNullable<z.ZodString>;
|
|
55
|
+
createdAt: z.ZodDate;
|
|
56
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
createdAt: Date;
|
|
60
|
+
icon: string | null;
|
|
61
|
+
}, {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
createdAt: Date;
|
|
65
|
+
icon: string | null;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
description: string;
|
|
70
|
+
};
|
|
71
|
+
404: {
|
|
72
|
+
content: {
|
|
73
|
+
"application/json": {
|
|
74
|
+
schema: z.ZodObject<{
|
|
75
|
+
message: z.ZodString;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
message: string;
|
|
78
|
+
}, {
|
|
79
|
+
message: string;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
} & {
|
|
87
|
+
getRoutingPath(): "/sports/:id";
|
|
88
|
+
};
|
|
89
|
+
export type ListRoute = typeof list;
|
|
90
|
+
export type GetOneRoute = typeof getOne;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
|
+
import { jsonContent } from "stoker/openapi/helpers";
|
|
4
|
+
import { selectSportSchema } from "../../db/schema/index.js";
|
|
5
|
+
import { notFoundSchema } from "../../lib/constants.js";
|
|
6
|
+
export const list = createRoute({
|
|
7
|
+
path: "/sports",
|
|
8
|
+
method: "get",
|
|
9
|
+
tags: ["Sports"],
|
|
10
|
+
responses: {
|
|
11
|
+
[HttpStatusCodes.OK]: jsonContent(z.array(selectSportSchema), "List of sports"),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export const getOne = createRoute({
|
|
15
|
+
path: "/sports/{id}",
|
|
16
|
+
method: "get",
|
|
17
|
+
tags: ["Sports"],
|
|
18
|
+
request: {
|
|
19
|
+
params: z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
responses: {
|
|
24
|
+
[HttpStatusCodes.OK]: jsonContent(selectSportSchema, "Sport details"),
|
|
25
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Sport not found"),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAuth } from "../../middlewares/is-auth.js";
|
|
1
2
|
import { createRoute, z } from "@hono/zod-openapi";
|
|
2
3
|
import * as HttpStatusCodes from "stoker/http-status-codes";
|
|
3
4
|
import { jsonContent } from "stoker/openapi/helpers";
|
|
@@ -5,6 +6,7 @@ export const verify = createRoute({
|
|
|
5
6
|
method: "post",
|
|
6
7
|
path: "/webhooks/verify",
|
|
7
8
|
tags: ["Webhooks"],
|
|
9
|
+
middleware: [isAuth()],
|
|
8
10
|
request: {
|
|
9
11
|
body: jsonContent(z.object({
|
|
10
12
|
url: z.string().url(),
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type events from "../routes/events/events.index.js";
|
|
2
2
|
import type index from "../routes/index.route.js";
|
|
3
|
-
import type leagues from "../routes/leagues/leagues.index.js";
|
|
4
3
|
import type marketing from "../routes/marketing/marketing.index.js";
|
|
5
|
-
import type
|
|
6
|
-
import type tags from "../routes/tags/tags.index.js";
|
|
4
|
+
import type sports from "../routes/sports/sports.index.js";
|
|
7
5
|
import type webhooks from "../routes/webhooks/webhooks.index.js";
|
|
8
|
-
export type AppType = typeof index | typeof
|
|
6
|
+
export type AppType = typeof index | typeof events | typeof sports | typeof marketing | typeof webhooks;
|