Skip to content

Commit

Permalink
chore: add Sports and Music room APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSBulgakov committed Oct 28, 2024
1 parent 3cf62c3 commit 478cc24
Show file tree
Hide file tree
Showing 11 changed files with 1,203 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
VITE_EVENTS_API_URL=https://api.innohassle.ru/events/v0
VITE_ACCOUNTS_API_URL=https://api.innohassle.ru/accounts/v0
VITE_SEARCH_API_URL=https://api.innohassle.ru/search/v0
VITE_SPORTS_API_URL=https://api.innohassle.ru/sports/v0
VITE_MAPS_API_URL=https://api.innohassle.ru/maps/v0
VITE_MUSIC_ROOM_API_URL=https://api.innohassle.ru/music-room/v0
VITE_BOOKING_API_URL=https://api.innohassle.ru/room-booking/v0

# Should be the name of provider supported by Accounts API
Expand Down
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
"prettier:check": "prettier --ignore-unknown --check .",
"lint-staged": "lint-staged",
"prepare": "husky",
"gen:api": "pnpm run gen:accounts && pnpm run gen:events && pnpm run gen:maps && pnpm run gen:room-booking && pnpm run gen:search",
"gen:accounts": "openapi-typescript https://api.innohassle.ru/accounts/staging-v0/openapi.json -o ./src/api/accounts/types.ts --root-types --enum",
"gen:events": "openapi-typescript https://api.innohassle.ru/events/staging-v0/openapi.json -o ./src/api/events/types.ts --root-types --enum",
"gen:maps": "openapi-typescript https://api.innohassle.ru/maps/staging-v0/openapi.json -o ./src/api/maps/types.ts --root-types --enum",
"gen:room-booking": "openapi-typescript https://api.innohassle.ru/room-booking/staging-v0/openapi.json -o ./src/api/room-booking/types.ts --root-types --enum",
"gen:search": "openapi-typescript https://api.innohassle.ru/search/staging-v0/openapi.json -o ./src/api/search/types.ts --root-types --enum",
"gen:api": "pnpm exec openapi-typescript --root-types --enum",
"release": "bumpp package.json",
"update-deps": "taze minor -wIrl"
},
Expand Down
36 changes: 36 additions & 0 deletions redocly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apis:
accounts:
root: https://api.innohassle.ru/accounts/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/accounts/types.ts
# --root-types --enum
events:
root: https://api.innohassle.ru/events/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/events/types.ts
# --root-types --enum
maps:
root: https://api.innohassle.ru/maps/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/maps/types.ts
# --root-types --enum
music:
root: https://api.innohassle.ru/music-room/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/music-room/types.ts
# --root-types --enum
room:
root: https://api.innohassle.ru/room-booking/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/room-booking/types.ts
# --root-types --enum
search:
root: https://api.innohassle.ru/search/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/search/types.ts
# --root-types --enum
sports:
root: https://api.innohassle.ru/sports/staging-v0/openapi.json
x-openapi-ts:
output: ./src/api/sports/types.ts
# --root-types --enum
10 changes: 10 additions & 0 deletions src/api/accounts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ export interface components {
name?: string | null;
/** Issued At */
issued_at?: string | null;
/**
* Is Student
* @default false
*/
is_student: boolean;
/**
* Is Staff
* @default false
*/
is_staff: boolean;
};
/** ValidationError */
ValidationError: {
Expand Down
4 changes: 3 additions & 1 deletion src/api/events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,9 @@ export interface operations {
user_id: number;
export_type: string;
};
header?: never;
header?: {
"user-agent"?: string | null;
};
path: {
event_group_alias: string;
};
Expand Down
125 changes: 116 additions & 9 deletions src/api/maps/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,119 @@ export interface paths {
patch?: never;
trace?: never;
};
"/scenes/areas/search": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/** Search Areas */
get: operations["scenes_search_areas"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
schemas: {
/** Area */
Area: {
/** Svg Polygon Id */
/**
* Svg Polygon Id
* @description ID of the polygon in the SVG
*/
svg_polygon_id?: string | null;
/** Title */
/**
* Title
* @description Title of the area
*/
title?: string | null;
/** Legend Id */
/**
* Legend Id
* @description ID of the legend (if any)
*/
legend_id?: string | null;
/**
* Description
* @description Description of the area
*/
description?: string | null;
};
/** HTTPValidationError */
HTTPValidationError: {
/** Detail */
detail?: components["schemas"]["ValidationError"][];
};
/** LegendEntry */
LegendEntry: {
/** Legend Id */
/**
* Legend Id
* @description ID of the legend
*/
legend_id: string;
/** Color */
/**
* Color
* @description Color of the legend
*/
color?: string | null;
/** Legend */
/**
* Legend
* @description Description of the legend (may contain multiple lines)
*/
legend?: string | null;
};
/** Scene */
Scene: {
/** Scene Id */
/**
* Scene Id
* @description ID of the scene
*/
scene_id: string;
/** Title */
/**
* Title
* @description Title of the scene
*/
title: string;
/** Svg File */
/**
* Svg File
* @description Path to the SVG file in /static
*/
svg_file: string;
/**
* Legend
* @description Legend of the scene
* @default []
*/
legend: components["schemas"]["LegendEntry"][];
/**
* Areas
* @description Areas of the scene
* @default []
*/
areas: components["schemas"]["Area"][];
};
/** SearchResult */
SearchResult: {
/** Scene Id */
scene_id: string;
/** Matching Area Indexes */
matching_area_indexes: number[];
};
/** ValidationError */
ValidationError: {
/** Location */
loc: (string | number)[];
/** Message */
msg: string;
/** Error Type */
type: string;
};
};
responses: never;
parameters: never;
Expand All @@ -70,8 +142,12 @@ export interface components {
pathItems: never;
}
export type SchemaArea = components["schemas"]["Area"];
export type SchemaHttpValidationError =
components["schemas"]["HTTPValidationError"];
export type SchemaLegendEntry = components["schemas"]["LegendEntry"];
export type SchemaScene = components["schemas"]["Scene"];
export type SchemaSearchResult = components["schemas"]["SearchResult"];
export type SchemaValidationError = components["schemas"]["ValidationError"];
export type $defs = Record<string, never>;
export interface operations {
scenes_scenes: {
Expand All @@ -94,4 +170,35 @@ export interface operations {
};
};
};
scenes_search_areas: {
parameters: {
query: {
query: string;
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["SearchResult"][];
};
};
/** @description Validation Error */
422: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["HTTPValidationError"];
};
};
};
};
}
12 changes: 12 additions & 0 deletions src/api/music-room/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { authMiddleware } from "@/api/helpers/auth-middleware.ts";
import createQueryClient from "@/api/helpers/create-query-client.ts";
import createFetchClient from "openapi-fetch";
import * as musicRoomTypes from "./types.ts";

export type { musicRoomTypes };

export const musicRoomFetch = createFetchClient<musicRoomTypes.paths>({
baseUrl: import.meta.env.VITE_MUSIC_ROOM_API_URL,
});
musicRoomFetch.use(authMiddleware);
export const $musicRoom = createQueryClient(musicRoomFetch, "musicRoom");
Loading

0 comments on commit 478cc24

Please sign in to comment.