@lcas58/esmi-api-types 1.0.27 → 1.0.29

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.
@@ -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,211 @@
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
+ platform: z.ZodNullable<z.ZodString>;
8
+ city: z.ZodNullable<z.ZodString>;
9
+ state: z.ZodNullable<z.ZodString>;
10
+ country: z.ZodString;
11
+ sportId: z.ZodString;
12
+ externalUrl: z.ZodNullable<z.ZodString>;
13
+ createdByUserId: z.ZodNullable<z.ZodString>;
14
+ imageUrl: z.ZodNullable<z.ZodString>;
15
+ isActive: z.ZodBoolean;
16
+ createdAt: z.ZodDate;
17
+ updatedAt: z.ZodDate;
18
+ }, {
19
+ sport: z.ZodNullable<z.ZodObject<{
20
+ id: z.ZodString;
21
+ name: z.ZodString;
22
+ icon: z.ZodNullable<z.ZodString>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ id: string;
25
+ name: string;
26
+ icon: string | null;
27
+ }, {
28
+ id: string;
29
+ name: string;
30
+ icon: string | null;
31
+ }>>;
32
+ creator: z.ZodNullable<z.ZodObject<{
33
+ id: z.ZodString;
34
+ name: z.ZodString;
35
+ image: z.ZodNullable<z.ZodString>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ image: string | null;
38
+ id: string;
39
+ name: string;
40
+ }, {
41
+ image: string | null;
42
+ id: string;
43
+ name: string;
44
+ }>>;
45
+ _count: z.ZodOptional<z.ZodObject<{
46
+ events: z.ZodNumber;
47
+ }, "strip", z.ZodTypeAny, {
48
+ events: number;
49
+ }, {
50
+ events: number;
51
+ }>>;
52
+ }>, z.UnknownKeysParam, z.ZodTypeAny, {
53
+ id: string;
54
+ description: string | null;
55
+ name: string;
56
+ createdAt: Date;
57
+ sport: {
58
+ id: string;
59
+ name: string;
60
+ icon: string | null;
61
+ } | null;
62
+ sportId: string;
63
+ city: string | null;
64
+ state: string | null;
65
+ country: string;
66
+ slug: string;
67
+ platform: string | null;
68
+ externalUrl: string | null;
69
+ updatedAt: Date;
70
+ createdByUserId: string | null;
71
+ imageUrl: string | null;
72
+ isActive: boolean;
73
+ creator: {
74
+ image: string | null;
75
+ id: string;
76
+ name: string;
77
+ } | null;
78
+ _count?: {
79
+ events: number;
80
+ } | undefined;
81
+ }, {
82
+ id: string;
83
+ description: string | null;
84
+ name: string;
85
+ createdAt: Date;
86
+ sport: {
87
+ id: string;
88
+ name: string;
89
+ icon: string | null;
90
+ } | null;
91
+ sportId: string;
92
+ city: string | null;
93
+ state: string | null;
94
+ country: string;
95
+ slug: string;
96
+ platform: string | null;
97
+ externalUrl: string | null;
98
+ updatedAt: Date;
99
+ createdByUserId: string | null;
100
+ imageUrl: string | null;
101
+ isActive: boolean;
102
+ creator: {
103
+ image: string | null;
104
+ id: string;
105
+ name: string;
106
+ } | null;
107
+ _count?: {
108
+ events: number;
109
+ } | undefined;
110
+ }>;
111
+ export declare const listGroupsQuerySchema: z.ZodObject<{
112
+ sportId: z.ZodOptional<z.ZodString>;
113
+ city: z.ZodOptional<z.ZodString>;
114
+ state: z.ZodOptional<z.ZodString>;
115
+ platform: z.ZodOptional<z.ZodString>;
116
+ search: z.ZodOptional<z.ZodString>;
117
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
118
+ offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
119
+ }, "strip", z.ZodTypeAny, {
120
+ limit: number;
121
+ offset: number;
122
+ search?: string | undefined;
123
+ sportId?: string | undefined;
124
+ city?: string | undefined;
125
+ state?: string | undefined;
126
+ platform?: string | undefined;
127
+ }, {
128
+ search?: string | undefined;
129
+ sportId?: string | undefined;
130
+ city?: string | undefined;
131
+ state?: string | undefined;
132
+ platform?: string | undefined;
133
+ limit?: number | undefined;
134
+ offset?: number | undefined;
135
+ }>;
136
+ export declare const createGroupBodySchema: z.ZodObject<{
137
+ name: z.ZodString;
138
+ slug: z.ZodOptional<z.ZodString>;
139
+ description: z.ZodOptional<z.ZodString>;
140
+ sportId: z.ZodString;
141
+ city: z.ZodOptional<z.ZodString>;
142
+ state: z.ZodOptional<z.ZodString>;
143
+ imageUrl: z.ZodOptional<z.ZodString>;
144
+ }, "strip", z.ZodTypeAny, {
145
+ name: string;
146
+ sportId: string;
147
+ description?: string | undefined;
148
+ city?: string | undefined;
149
+ state?: string | undefined;
150
+ slug?: string | undefined;
151
+ imageUrl?: string | undefined;
152
+ }, {
153
+ name: string;
154
+ sportId: string;
155
+ description?: string | undefined;
156
+ city?: string | undefined;
157
+ state?: string | undefined;
158
+ slug?: string | undefined;
159
+ imageUrl?: string | undefined;
160
+ }>;
161
+ export declare const updateGroupBodySchema: z.ZodEffects<z.ZodObject<{
162
+ name: z.ZodOptional<z.ZodString>;
163
+ description: z.ZodOptional<z.ZodString>;
164
+ city: z.ZodOptional<z.ZodString>;
165
+ state: z.ZodOptional<z.ZodString>;
166
+ imageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ description?: string | undefined;
169
+ name?: string | undefined;
170
+ city?: string | undefined;
171
+ state?: string | undefined;
172
+ imageUrl?: string | null | undefined;
173
+ }, {
174
+ description?: string | undefined;
175
+ name?: string | undefined;
176
+ city?: string | undefined;
177
+ state?: string | undefined;
178
+ imageUrl?: string | null | undefined;
179
+ }>, {
180
+ description?: string | undefined;
181
+ name?: string | undefined;
182
+ city?: string | undefined;
183
+ state?: string | undefined;
184
+ imageUrl?: string | null | undefined;
185
+ }, {
186
+ description?: string | undefined;
187
+ name?: string | undefined;
188
+ city?: string | undefined;
189
+ state?: string | undefined;
190
+ imageUrl?: string | null | undefined;
191
+ }>;
192
+ export declare const groupEventsQuerySchema: z.ZodObject<{
193
+ from: z.ZodOptional<z.ZodDate>;
194
+ to: z.ZodOptional<z.ZodDate>;
195
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
196
+ offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ limit: number;
199
+ offset: number;
200
+ from?: Date | undefined;
201
+ to?: Date | undefined;
202
+ }, {
203
+ from?: Date | undefined;
204
+ to?: Date | undefined;
205
+ limit?: number | undefined;
206
+ offset?: number | undefined;
207
+ }>;
208
+ export type GroupWithRelations = z.infer<typeof groupWithRelationsSchema>;
209
+ export type ListGroupsQuery = z.infer<typeof listGroupsQuerySchema>;
210
+ export type CreateGroupBody = z.infer<typeof createGroupBodySchema>;
211
+ 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
+ platform: z.string().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,7 +1,7 @@
1
1
  {
2
2
  "name": "@lcas58/esmi-api-types",
3
3
  "type": "module",
4
- "version": "1.0.27",
4
+ "version": "1.0.29",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {