@lcas58/esmi-api-types 1.0.6 → 1.0.7
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/app.d.ts +1 -1
- package/dist/src/app.js +0 -1
- package/dist/src/routes/events/events.handlers.d.ts +20 -0
- package/dist/src/routes/events/events.handlers.js +177 -0
- package/dist/src/routes/events/events.index.d.ts +501 -0
- package/dist/src/routes/events/events.index.js +9 -0
- package/dist/src/routes/events/events.routes.d.ts +1375 -0
- package/dist/src/routes/events/events.routes.js +72 -0
- package/dist/src/routes/events/schemas/event.schemas.d.ts +896 -0
- package/dist/src/routes/events/schemas/event.schemas.js +49 -0
- package/dist/src/routes/events/schemas/index.d.ts +1 -0
- package/dist/src/routes/events/schemas/index.js +1 -0
- package/dist/src/routes/index.route.d.ts +13 -0
- package/dist/src/routes/index.route.js +19 -0
- package/dist/src/routes/leagues/leagues.handlers.d.ts +3 -0
- package/dist/src/routes/leagues/leagues.handlers.js +49 -0
- package/dist/src/routes/leagues/leagues.index.d.ts +53 -0
- package/dist/src/routes/leagues/leagues.index.js +6 -0
- package/dist/src/routes/leagues/leagues.routes.d.ts +137 -0
- package/dist/src/routes/leagues/leagues.routes.js +47 -0
- package/dist/src/routes/marketing/marketing.handlers.d.ts +4 -0
- package/dist/src/routes/marketing/marketing.handlers.js +20 -0
- package/dist/src/routes/marketing/marketing.index.d.ts +58 -0
- package/dist/src/routes/marketing/marketing.index.js +7 -0
- package/dist/src/routes/marketing/marketing.routes.d.ts +154 -0
- package/dist/src/routes/marketing/marketing.routes.js +27 -0
- package/dist/src/routes/organizations/organizations.handlers.d.ts +74 -0
- package/dist/src/routes/organizations/organizations.handlers.js +485 -0
- package/dist/src/routes/organizations/organizations.index.d.ts +517 -0
- package/dist/src/routes/organizations/organizations.index.js +12 -0
- package/dist/src/routes/organizations/organizations.routes.d.ts +1236 -0
- package/dist/src/routes/organizations/organizations.routes.js +137 -0
- package/dist/src/routes/organizations/tasks.test.d.ts +0 -0
- package/dist/src/routes/organizations/tasks.test.js +181 -0
- package/dist/src/routes/tags/tags.handlers.d.ts +3 -0
- package/dist/src/routes/tags/tags.handlers.js +15 -0
- package/dist/src/routes/tags/tags.index.d.ts +24 -0
- package/dist/src/routes/tags/tags.index.js +6 -0
- package/dist/src/routes/tags/tags.routes.d.ts +68 -0
- package/dist/src/routes/tags/tags.routes.js +25 -0
- package/dist/src/shared/client-types.d.ts +8 -3
- package/dist/src/shared/client-types.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,137 @@
|
|
|
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 { createErrorSchema } from "stoker/openapi/schemas";
|
|
5
|
+
import { createOrganizationWithDetailsSchema, getOrganizationWithDetailsSchema, patchOrganizationSchema, selectOrganizationSchema } from "../../db/schema/organization.js";
|
|
6
|
+
import { notFoundSchema, unauthorizedSchema, unprocessableEntitySchema } from "../../lib/constants.js";
|
|
7
|
+
import { uuidParamsSchema } from "../../lib/openapi-schemas.js";
|
|
8
|
+
import { isAuth } from "../../middlewares/is-auth.js";
|
|
9
|
+
const tags = ["Organizations"];
|
|
10
|
+
export const getOne = createRoute({
|
|
11
|
+
path: "/organizations/{id}",
|
|
12
|
+
method: "get",
|
|
13
|
+
tags,
|
|
14
|
+
middleware: [isAuth()],
|
|
15
|
+
request: {
|
|
16
|
+
params: z.object({
|
|
17
|
+
id: z.string(),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
responses: {
|
|
21
|
+
[HttpStatusCodes.OK]: jsonContent(getOrganizationWithDetailsSchema, "The organization"),
|
|
22
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Organization not found"),
|
|
23
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(uuidParamsSchema("id")), "Invalid id error"),
|
|
24
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
export const list = createRoute({
|
|
28
|
+
path: "/organizations",
|
|
29
|
+
method: "get",
|
|
30
|
+
tags,
|
|
31
|
+
middleware: [isAuth()],
|
|
32
|
+
request: {
|
|
33
|
+
query: z.object({
|
|
34
|
+
ownerId: z.string().optional(),
|
|
35
|
+
city: z.string().optional(),
|
|
36
|
+
state: z.string().optional(),
|
|
37
|
+
country: z.string().optional(),
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
responses: {
|
|
41
|
+
[HttpStatusCodes.OK]: jsonContent(z.array(selectOrganizationSchema), "Organizations matching the provided owner or location filters"),
|
|
42
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(z.object({
|
|
43
|
+
ownerId: z.string(),
|
|
44
|
+
})), "Invalid ownerId error"),
|
|
45
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
export const listLocations = createRoute({
|
|
49
|
+
path: "/organizations/locations",
|
|
50
|
+
method: "get",
|
|
51
|
+
tags,
|
|
52
|
+
middleware: [isAuth()],
|
|
53
|
+
responses: {
|
|
54
|
+
[HttpStatusCodes.OK]: jsonContent(z.array(z.object({
|
|
55
|
+
city: z.string(),
|
|
56
|
+
state: z.string().nullable(),
|
|
57
|
+
country: z.string(),
|
|
58
|
+
})), "Distinct organization locations"),
|
|
59
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
export const create = createRoute({
|
|
63
|
+
path: "/organizations",
|
|
64
|
+
method: "post",
|
|
65
|
+
tags,
|
|
66
|
+
middleware: [isAuth()],
|
|
67
|
+
request: {
|
|
68
|
+
body: jsonContentRequired(createOrganizationWithDetailsSchema, "The organization to create with details"),
|
|
69
|
+
},
|
|
70
|
+
responses: {
|
|
71
|
+
[HttpStatusCodes.CREATED]: jsonContent(selectOrganizationSchema, "The created organization"),
|
|
72
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(createOrganizationWithDetailsSchema), "The validation error(s)"),
|
|
73
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
export const patch = createRoute({
|
|
77
|
+
path: "/organizations/{id}",
|
|
78
|
+
method: "patch",
|
|
79
|
+
tags,
|
|
80
|
+
request: {
|
|
81
|
+
params: uuidParamsSchema("id"),
|
|
82
|
+
body: jsonContentRequired(patchOrganizationSchema, "The organization to update"),
|
|
83
|
+
},
|
|
84
|
+
responses: {
|
|
85
|
+
[HttpStatusCodes.OK]: jsonContent(selectOrganizationSchema, "The updated organization"),
|
|
86
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Organization not found"),
|
|
87
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(uuidParamsSchema("id"))
|
|
88
|
+
.or(createErrorSchema(patchOrganizationSchema)), "The validation error(s)"),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
export const remove = createRoute({
|
|
92
|
+
path: "/organizations/{id}",
|
|
93
|
+
method: "delete",
|
|
94
|
+
request: {
|
|
95
|
+
params: uuidParamsSchema("id"),
|
|
96
|
+
},
|
|
97
|
+
tags,
|
|
98
|
+
responses: {
|
|
99
|
+
[HttpStatusCodes.NO_CONTENT]: {
|
|
100
|
+
description: "Organization deleted",
|
|
101
|
+
},
|
|
102
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Organization not found"),
|
|
103
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(uuidParamsSchema("id")), "Invalid id error"),
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
export const checkOwnership = createRoute({
|
|
107
|
+
path: "/organizations/{id}/ownership",
|
|
108
|
+
method: "get",
|
|
109
|
+
tags,
|
|
110
|
+
middleware: [isAuth()],
|
|
111
|
+
request: {
|
|
112
|
+
params: uuidParamsSchema("id"),
|
|
113
|
+
},
|
|
114
|
+
responses: {
|
|
115
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
116
|
+
isOwner: z.boolean(),
|
|
117
|
+
}), "Organization ownership status"),
|
|
118
|
+
[HttpStatusCodes.NOT_FOUND]: jsonContent(notFoundSchema, "Organization not found"),
|
|
119
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(createErrorSchema(uuidParamsSchema("id")), "Invalid id error"),
|
|
120
|
+
[HttpStatusCodes.UNAUTHORIZED]: jsonContent(unauthorizedSchema, "Unauthorized"),
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
export const checkOrganizationName = createRoute({
|
|
124
|
+
path: "/organizations/name",
|
|
125
|
+
method: "get",
|
|
126
|
+
tags,
|
|
127
|
+
request: {
|
|
128
|
+
query: z.object({ name: z.string() }),
|
|
129
|
+
},
|
|
130
|
+
responses: {
|
|
131
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
132
|
+
exists: z.boolean(),
|
|
133
|
+
suggestions: z.array(z.string()).optional(),
|
|
134
|
+
}), "Organization name availability with suggestions"),
|
|
135
|
+
[HttpStatusCodes.UNPROCESSABLE_ENTITY]: jsonContent(unprocessableEntitySchema, "Invalid name error"),
|
|
136
|
+
},
|
|
137
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// /* eslint-disable ts/ban-ts-comment */
|
|
3
|
+
// import { testClient } from "hono/testing";
|
|
4
|
+
// import { execSync } from "node:child_process";
|
|
5
|
+
// import fs from "node:fs";
|
|
6
|
+
// import * as HttpStatusPhrases from "stoker/http-status-phrases";
|
|
7
|
+
// import { afterAll, beforeAll, describe, expect, expectTypeOf, it } from "vitest";
|
|
8
|
+
// import { ZodIssueCode } from "zod";
|
|
9
|
+
// import env from "../../env.js";
|
|
10
|
+
// import { ZOD_ERROR_CODES, ZOD_ERROR_MESSAGES } from "../../lib/constants.js";
|
|
11
|
+
// import createApp from "../../lib/create-app.js";
|
|
12
|
+
// import router from "./tasks.index";
|
|
13
|
+
// if (env.NODE_ENV !== "test") {
|
|
14
|
+
// throw new Error("NODE_ENV must be 'test'");
|
|
15
|
+
// }
|
|
16
|
+
// const client = testClient(createApp().route("/", router));
|
|
17
|
+
// describe("tasks routes", () => {
|
|
18
|
+
// beforeAll(async () => {
|
|
19
|
+
// execSync("pnpm drizzle-kit push");
|
|
20
|
+
// });
|
|
21
|
+
// afterAll(async () => {
|
|
22
|
+
// fs.rmSync("test.db", { force: true });
|
|
23
|
+
// });
|
|
24
|
+
// it("post /tasks validates the body when creating", async () => {
|
|
25
|
+
// const response = await client.tasks.$post({
|
|
26
|
+
// // @ts-expect-error
|
|
27
|
+
// json: {
|
|
28
|
+
// done: false,
|
|
29
|
+
// },
|
|
30
|
+
// });
|
|
31
|
+
// expect(response.status).toBe(422);
|
|
32
|
+
// if (response.status === 422) {
|
|
33
|
+
// const json = await response.json();
|
|
34
|
+
// expect(json.error.issues[0].path[0]).toBe("name");
|
|
35
|
+
// expect(json.error.issues[0].message).toBe(ZOD_ERROR_MESSAGES.REQUIRED);
|
|
36
|
+
// }
|
|
37
|
+
// });
|
|
38
|
+
// const id = "1";
|
|
39
|
+
// const name = "Learn vitest";
|
|
40
|
+
// it("post /tasks creates a task", async () => {
|
|
41
|
+
// const response = await client.tasks.$post({
|
|
42
|
+
// json: {
|
|
43
|
+
// name,
|
|
44
|
+
// done: false,
|
|
45
|
+
// },
|
|
46
|
+
// });
|
|
47
|
+
// expect(response.status).toBe(200);
|
|
48
|
+
// if (response.status === 200) {
|
|
49
|
+
// const json = await response.json();
|
|
50
|
+
// expect(json.name).toBe(name);
|
|
51
|
+
// expect(json.done).toBe(false);
|
|
52
|
+
// }
|
|
53
|
+
// });
|
|
54
|
+
// it("get /tasks lists all tasks", async () => {
|
|
55
|
+
// const response = await client.tasks.$get();
|
|
56
|
+
// expect(response.status).toBe(200);
|
|
57
|
+
// if (response.status === 200) {
|
|
58
|
+
// const json = await response.json();
|
|
59
|
+
// expectTypeOf(json).toBeArray();
|
|
60
|
+
// expect(json.length).toBe(1);
|
|
61
|
+
// }
|
|
62
|
+
// });
|
|
63
|
+
// it("get /tasks/{id} validates the id param", async () => {
|
|
64
|
+
// const response = await client.tasks[":id"].$get({
|
|
65
|
+
// param: {
|
|
66
|
+
// id: "wat",
|
|
67
|
+
// },
|
|
68
|
+
// });
|
|
69
|
+
// expect(response.status).toBe(422);
|
|
70
|
+
// if (response.status === 422) {
|
|
71
|
+
// const json = await response.json();
|
|
72
|
+
// expect(json.error.issues[0].path[0]).toBe("id");
|
|
73
|
+
// expect(json.error.issues[0].message).toBe(ZOD_ERROR_MESSAGES.EXPECTED_NUMBER);
|
|
74
|
+
// }
|
|
75
|
+
// });
|
|
76
|
+
// it("get /tasks/{id} returns 404 when task not found", async () => {
|
|
77
|
+
// const response = await client.tasks[":id"].$get({
|
|
78
|
+
// param: {
|
|
79
|
+
// id: "999",
|
|
80
|
+
// },
|
|
81
|
+
// });
|
|
82
|
+
// expect(response.status).toBe(404);
|
|
83
|
+
// if (response.status === 404) {
|
|
84
|
+
// const json = await response.json();
|
|
85
|
+
// expect(json.message).toBe(HttpStatusPhrases.NOT_FOUND);
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
88
|
+
// it("get /tasks/{id} gets a single task", async () => {
|
|
89
|
+
// const response = await client.tasks[":id"].$get({
|
|
90
|
+
// param: {
|
|
91
|
+
// id,
|
|
92
|
+
// },
|
|
93
|
+
// });
|
|
94
|
+
// expect(response.status).toBe(200);
|
|
95
|
+
// if (response.status === 200) {
|
|
96
|
+
// const json = await response.json();
|
|
97
|
+
// expect(json.name).toBe(name);
|
|
98
|
+
// expect(json.done).toBe(false);
|
|
99
|
+
// }
|
|
100
|
+
// });
|
|
101
|
+
// it("patch /tasks/{id} validates the body when updating", async () => {
|
|
102
|
+
// const response = await client.tasks[":id"].$patch({
|
|
103
|
+
// param: {
|
|
104
|
+
// id,
|
|
105
|
+
// },
|
|
106
|
+
// json: {
|
|
107
|
+
// name: "",
|
|
108
|
+
// },
|
|
109
|
+
// });
|
|
110
|
+
// expect(response.status).toBe(422);
|
|
111
|
+
// if (response.status === 422) {
|
|
112
|
+
// const json = await response.json();
|
|
113
|
+
// expect(json.error.issues[0].path[0]).toBe("name");
|
|
114
|
+
// expect(json.error.issues[0].code).toBe(ZodIssueCode.too_small);
|
|
115
|
+
// }
|
|
116
|
+
// });
|
|
117
|
+
// it("patch /tasks/{id} validates the id param", async () => {
|
|
118
|
+
// const response = await client.tasks[":id"].$patch({
|
|
119
|
+
// param: {
|
|
120
|
+
// id: "wat",
|
|
121
|
+
// },
|
|
122
|
+
// json: {},
|
|
123
|
+
// });
|
|
124
|
+
// expect(response.status).toBe(422);
|
|
125
|
+
// if (response.status === 422) {
|
|
126
|
+
// const json = await response.json();
|
|
127
|
+
// expect(json.error.issues[0].path[0]).toBe("id");
|
|
128
|
+
// expect(json.error.issues[0].message).toBe(ZOD_ERROR_MESSAGES.EXPECTED_NUMBER);
|
|
129
|
+
// }
|
|
130
|
+
// });
|
|
131
|
+
// it("patch /tasks/{id} validates empty body", async () => {
|
|
132
|
+
// const response = await client.tasks[":id"].$patch({
|
|
133
|
+
// param: {
|
|
134
|
+
// id,
|
|
135
|
+
// },
|
|
136
|
+
// json: {},
|
|
137
|
+
// });
|
|
138
|
+
// expect(response.status).toBe(422);
|
|
139
|
+
// if (response.status === 422) {
|
|
140
|
+
// const json = await response.json();
|
|
141
|
+
// expect(json.error.issues[0].code).toBe(ZOD_ERROR_CODES.INVALID_UPDATES);
|
|
142
|
+
// expect(json.error.issues[0].message).toBe(ZOD_ERROR_MESSAGES.NO_UPDATES);
|
|
143
|
+
// }
|
|
144
|
+
// });
|
|
145
|
+
// it("patch /tasks/{id} updates a single property of a task", async () => {
|
|
146
|
+
// const response = await client.tasks[":id"].$patch({
|
|
147
|
+
// param: {
|
|
148
|
+
// id,
|
|
149
|
+
// },
|
|
150
|
+
// json: {
|
|
151
|
+
// done: true,
|
|
152
|
+
// },
|
|
153
|
+
// });
|
|
154
|
+
// expect(response.status).toBe(200);
|
|
155
|
+
// if (response.status === 200) {
|
|
156
|
+
// const json = await response.json();
|
|
157
|
+
// expect(json.done).toBe(true);
|
|
158
|
+
// }
|
|
159
|
+
// });
|
|
160
|
+
// it("delete /tasks/{id} validates the id when deleting", async () => {
|
|
161
|
+
// const response = await client.tasks[":id"].$delete({
|
|
162
|
+
// param: {
|
|
163
|
+
// id: "wat",
|
|
164
|
+
// },
|
|
165
|
+
// });
|
|
166
|
+
// expect(response.status).toBe(422);
|
|
167
|
+
// if (response.status === 422) {
|
|
168
|
+
// const json = await response.json();
|
|
169
|
+
// expect(json.error.issues[0].path[0]).toBe("id");
|
|
170
|
+
// expect(json.error.issues[0].message).toBe(ZOD_ERROR_MESSAGES.EXPECTED_NUMBER);
|
|
171
|
+
// }
|
|
172
|
+
// });
|
|
173
|
+
// it("delete /tasks/{id} removes a task", async () => {
|
|
174
|
+
// const response = await client.tasks[":id"].$delete({
|
|
175
|
+
// param: {
|
|
176
|
+
// id,
|
|
177
|
+
// },
|
|
178
|
+
// });
|
|
179
|
+
// expect(response.status).toBe(204);
|
|
180
|
+
// });
|
|
181
|
+
// });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createDb } from "../../db/index.js";
|
|
2
|
+
export const list = async (c) => {
|
|
3
|
+
const { db } = createDb(c.env);
|
|
4
|
+
const { type } = c.req.valid("query");
|
|
5
|
+
const tags = await db.query.tags.findMany({
|
|
6
|
+
where: type ? (tags, { eq }) => eq(tags.type, type) : undefined,
|
|
7
|
+
});
|
|
8
|
+
return c.json({
|
|
9
|
+
tags: tags.map(tag => ({
|
|
10
|
+
...tag,
|
|
11
|
+
createdAt: tag.createdAt.toISOString(),
|
|
12
|
+
updatedAt: tag.updatedAt.toISOString(),
|
|
13
|
+
})),
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const router: import("@hono/zod-openapi").OpenAPIHono<import("../../shared/index.js").AppBindings, {
|
|
2
|
+
"/tags": {
|
|
3
|
+
$get: {
|
|
4
|
+
input: {
|
|
5
|
+
query: {
|
|
6
|
+
type?: string | string[] | undefined;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
output: {
|
|
10
|
+
tags: {
|
|
11
|
+
id: string;
|
|
12
|
+
type: string;
|
|
13
|
+
name: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
outputFormat: "text" | "json";
|
|
20
|
+
status: 200;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}, "/">;
|
|
24
|
+
export default router;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const list: {
|
|
3
|
+
method: "get";
|
|
4
|
+
path: "/tags";
|
|
5
|
+
request: {
|
|
6
|
+
query: z.ZodObject<{
|
|
7
|
+
type: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
type?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
type?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
responses: {
|
|
15
|
+
200: {
|
|
16
|
+
content: {
|
|
17
|
+
"application/json": {
|
|
18
|
+
schema: z.ZodObject<{
|
|
19
|
+
tags: z.ZodArray<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
type: z.ZodString;
|
|
23
|
+
description: z.ZodOptional<z.ZodString>;
|
|
24
|
+
createdAt: z.ZodDate;
|
|
25
|
+
updatedAt: z.ZodDate;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
id: string;
|
|
28
|
+
type: string;
|
|
29
|
+
name: string;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
description?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
id: string;
|
|
35
|
+
type: string;
|
|
36
|
+
name: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
description?: string | undefined;
|
|
40
|
+
}>, "many">;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
tags: {
|
|
43
|
+
id: string;
|
|
44
|
+
type: string;
|
|
45
|
+
name: string;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
}[];
|
|
50
|
+
}, {
|
|
51
|
+
tags: {
|
|
52
|
+
id: string;
|
|
53
|
+
type: string;
|
|
54
|
+
name: string;
|
|
55
|
+
createdAt: Date;
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
}[];
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
} & {
|
|
66
|
+
getRoutingPath(): "/tags";
|
|
67
|
+
};
|
|
68
|
+
export type ListRoute = typeof list;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
const tagSchema = z.object({
|
|
5
|
+
id: z.string().uuid(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
type: z.string(),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
createdAt: z.date(),
|
|
10
|
+
updatedAt: z.date(),
|
|
11
|
+
});
|
|
12
|
+
export const list = createRoute({
|
|
13
|
+
method: "get",
|
|
14
|
+
path: "/tags",
|
|
15
|
+
request: {
|
|
16
|
+
query: z.object({
|
|
17
|
+
type: z.string().optional(),
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
responses: {
|
|
21
|
+
[HttpStatusCodes.OK]: jsonContent(z.object({
|
|
22
|
+
tags: z.array(tagSchema),
|
|
23
|
+
}), "List of tags filtered by type"),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
* Usage in frontend:
|
|
5
5
|
* ```typescript
|
|
6
6
|
* import { hc } from 'hono/client';
|
|
7
|
-
* import type { AppType } from '@esmi
|
|
7
|
+
* import type { AppType } from '@lcas58/esmi-api-types/client-types';
|
|
8
8
|
*
|
|
9
9
|
* const client = hc<AppType>('https://api.example.com');
|
|
10
10
|
* const res = await client.events.$get();
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
import type
|
|
14
|
-
|
|
13
|
+
import type events from "../routes/events/events.index.js";
|
|
14
|
+
import type index from "../routes/index.route.js";
|
|
15
|
+
import type leagues from "../routes/leagues/leagues.index.js";
|
|
16
|
+
import type marketing from "../routes/marketing/marketing.index.js";
|
|
17
|
+
import type organizations from "../routes/organizations/organizations.index.js";
|
|
18
|
+
import type tags from "../routes/tags/tags.index.js";
|
|
19
|
+
export type AppType = typeof index | typeof organizations | typeof events | typeof leagues | typeof marketing | typeof tags;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Usage in frontend:
|
|
5
5
|
* ```typescript
|
|
6
6
|
* import { hc } from 'hono/client';
|
|
7
|
-
* import type { AppType } from '@esmi
|
|
7
|
+
* import type { AppType } from '@lcas58/esmi-api-types/client-types';
|
|
8
8
|
*
|
|
9
9
|
* const client = hc<AppType>('https://api.example.com');
|
|
10
10
|
* const res = await client.events.$get();
|
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.
|
|
4
|
+
"version": "1.0.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist/src/app.js",
|
|
21
21
|
"dist/src/db/schema",
|
|
22
22
|
"dist/src/lib/types.d.ts",
|
|
23
|
-
"dist/src/routes
|
|
23
|
+
"dist/src/routes",
|
|
24
24
|
"dist/src/shared"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|