From d483a245f874b651581942315b93e3d9ee0dfc89 Mon Sep 17 00:00:00 2001 From: Richard Toth Date: Fri, 21 Mar 2025 15:17:53 +0100 Subject: [PATCH] init commit --- .gitignore | 2 ++ package-lock.json | 29 ++++++++++++++++++++++++++ package.json | 20 ++++++++++++++++++ src/index.ts | 17 +++++++++++++++ src/interfaces/api-pagination.ts | 8 +++++++ src/interfaces/api-result.ts | 10 +++++++++ src/interfaces/category.ts | 12 +++++++++++ src/interfaces/club.ts | 12 +++++++++++ src/interfaces/entry.ts | 18 ++++++++++++++++ src/interfaces/in-memory-cache.ts | 8 +++++++ src/interfaces/official.ts | 10 +++++++++ src/interfaces/pagination.ts | 4 ++++ src/interfaces/player.ts | 14 +++++++++++++ src/interfaces/ranking-entry.ts | 12 +++++++++++ src/interfaces/ranking.ts | 8 +++++++ src/interfaces/system-data.ts | 4 ++++ src/interfaces/team-administrator.ts | 11 ++++++++++ src/interfaces/team-category.ts | 10 +++++++++ src/interfaces/team-entry.ts | 15 ++++++++++++++ src/interfaces/team.ts | 7 +++++++ src/interfaces/tournament.ts | 31 ++++++++++++++++++++++++++++ tsconfig.json | 13 ++++++++++++ 22 files changed, 275 insertions(+) create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 src/interfaces/api-pagination.ts create mode 100644 src/interfaces/api-result.ts create mode 100644 src/interfaces/category.ts create mode 100644 src/interfaces/club.ts create mode 100644 src/interfaces/entry.ts create mode 100644 src/interfaces/in-memory-cache.ts create mode 100644 src/interfaces/official.ts create mode 100644 src/interfaces/pagination.ts create mode 100644 src/interfaces/player.ts create mode 100644 src/interfaces/ranking-entry.ts create mode 100644 src/interfaces/ranking.ts create mode 100644 src/interfaces/system-data.ts create mode 100644 src/interfaces/team-administrator.ts create mode 100644 src/interfaces/team-category.ts create mode 100644 src/interfaces/team-entry.ts create mode 100644 src/interfaces/team.ts create mode 100644 src/interfaces/tournament.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..574f702 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,29 @@ +{ + "name": "@mtlsz/common", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@mtlsz/common", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "typescript": "^5.8.2" + } + }, + "node_modules/typescript": { + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..fe2dacb --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "@mtlsz/common", + "version": "1.0.2", + "description": "MTLSZ frontend packages", + "main": "dist/index.ts", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://git.tothbt.com/tothbt/mtlsz-frontend-packages" + }, + "author": "TRWEB", + "license": "ISC", + "devDependencies": { + "typescript": "^5.8.2" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..76b13ab --- /dev/null +++ b/src/index.ts @@ -0,0 +1,17 @@ +export * from './interfaces/club'; +export * from './interfaces/player'; +export * from './interfaces/api-pagination'; +export * from './interfaces/api-result'; +export * from './interfaces/category'; +export * from './interfaces/entry'; +export * from './interfaces/in-memory-cache'; +export * from './interfaces/official'; +export * from './interfaces/pagination'; +export * from './interfaces/ranking-entry'; +export * from './interfaces/ranking'; +export * from './interfaces/system-data'; +export * from './interfaces/team-administrator'; +export * from './interfaces/team-category'; +export * from './interfaces/team-entry'; +export * from './interfaces/team'; +export * from './interfaces/tournament'; \ No newline at end of file diff --git a/src/interfaces/api-pagination.ts b/src/interfaces/api-pagination.ts new file mode 100644 index 0000000..81dd2ae --- /dev/null +++ b/src/interfaces/api-pagination.ts @@ -0,0 +1,8 @@ +export interface ApiPagination { + '@id': string; + '@type': string; + 'hydra:first': string; + 'hydra:last': string; + 'hydra:next'?: string; + 'hydra:previous'?: string; +} diff --git a/src/interfaces/api-result.ts b/src/interfaces/api-result.ts new file mode 100644 index 0000000..3b40459 --- /dev/null +++ b/src/interfaces/api-result.ts @@ -0,0 +1,10 @@ +import { ApiPagination } from "./api-pagination"; + +export interface ApiResult { + '@context': string; + '@id': string; + type: string; + 'hydra:member': Array; + 'hydra:totalItems': number; + 'hydra:view': ApiPagination +} diff --git a/src/interfaces/category.ts b/src/interfaces/category.ts new file mode 100644 index 0000000..d9b277e --- /dev/null +++ b/src/interfaces/category.ts @@ -0,0 +1,12 @@ +export interface Category { + id?: number; + name: string; + singles: boolean; + doubles: boolean; + mixed: boolean; + shortName: string; + gender: string; + class: number; + age?: string; + priority: number; +} diff --git a/src/interfaces/club.ts b/src/interfaces/club.ts new file mode 100644 index 0000000..51c8f24 --- /dev/null +++ b/src/interfaces/club.ts @@ -0,0 +1,12 @@ +export interface Club { + id?: number; + name: string; + shortName: string; + players?: Array; + city?: string; + contactName?: string; + email?: string; + address?: string; + phone?: string; + active: boolean; +} \ No newline at end of file diff --git a/src/interfaces/entry.ts b/src/interfaces/entry.ts new file mode 100644 index 0000000..5483559 --- /dev/null +++ b/src/interfaces/entry.ts @@ -0,0 +1,18 @@ +import { Category } from "./category"; +import { Club } from "./club"; +import { Player } from "./player"; +import { Tournament } from "./tournament"; + +export interface Entry { + id?: number; + player1: Player; + player2?: Player; + sentBy: Club; + status: number; + category: Category; + tournament: Tournament; + createdAt: string; + updatedAt?: string; + sameEntry?: Entry; + missingEntryFromOtherClub?: boolean; +} diff --git a/src/interfaces/in-memory-cache.ts b/src/interfaces/in-memory-cache.ts new file mode 100644 index 0000000..4a4fc92 --- /dev/null +++ b/src/interfaces/in-memory-cache.ts @@ -0,0 +1,8 @@ +/** + * This is just a simple interface for clearCache method + * which removes the data from the memory. E.g set + * your list to empty array, null or whatever. + */ +export declare interface InMemoryCache { + clearCache(): void; +} diff --git a/src/interfaces/official.ts b/src/interfaces/official.ts new file mode 100644 index 0000000..ef24dec --- /dev/null +++ b/src/interfaces/official.ts @@ -0,0 +1,10 @@ +export interface Official { + id?: number; + name: string; + email: string; + phone?: string; + /** @deprecated Use referee and umpire booleans instead */ + type?: number; + referee: boolean; + umpire: boolean; +} diff --git a/src/interfaces/pagination.ts b/src/interfaces/pagination.ts new file mode 100644 index 0000000..e96e118 --- /dev/null +++ b/src/interfaces/pagination.ts @@ -0,0 +1,4 @@ +export declare interface Pagination { + forward(): void; + back(): void; +} diff --git a/src/interfaces/player.ts b/src/interfaces/player.ts new file mode 100644 index 0000000..44d428e --- /dev/null +++ b/src/interfaces/player.ts @@ -0,0 +1,14 @@ +import { Club } from "./club"; + +export interface Player { + id?: number; + firstName: string; + lastName: string; + gender: string; + birthDate: string; + officialId?: number; + club: Club; + email?: string; + keycloakUserId?: string; + active?: boolean; +} diff --git a/src/interfaces/ranking-entry.ts b/src/interfaces/ranking-entry.ts new file mode 100644 index 0000000..5228478 --- /dev/null +++ b/src/interfaces/ranking-entry.ts @@ -0,0 +1,12 @@ +import { Player } from "./player"; +import { Ranking } from "./ranking"; + +export interface RankingEntry { + id?: number; + ranking: Ranking; + player: Player; + place: number; + tournamentCount: number; + points: number; + validFrom: Date; +} \ No newline at end of file diff --git a/src/interfaces/ranking.ts b/src/interfaces/ranking.ts new file mode 100644 index 0000000..844eeaa --- /dev/null +++ b/src/interfaces/ranking.ts @@ -0,0 +1,8 @@ +export interface Ranking { + id?: number; + gender: string; + age: string | null; + singles: boolean; + doubles: boolean; + mixed: boolean; +} \ No newline at end of file diff --git a/src/interfaces/system-data.ts b/src/interfaces/system-data.ts new file mode 100644 index 0000000..278ced7 --- /dev/null +++ b/src/interfaces/system-data.ts @@ -0,0 +1,4 @@ +export interface SystemData { + type: string; + value: string; +} diff --git a/src/interfaces/team-administrator.ts b/src/interfaces/team-administrator.ts new file mode 100644 index 0000000..973e443 --- /dev/null +++ b/src/interfaces/team-administrator.ts @@ -0,0 +1,11 @@ +import { Club } from "./club"; + +export interface TeamAdministrator { + id?: number; + keycloakId?: string; + lastName: string; + firstName: string; + email: string; + active?: boolean; + club: Club; +} diff --git a/src/interfaces/team-category.ts b/src/interfaces/team-category.ts new file mode 100644 index 0000000..36cfb99 --- /dev/null +++ b/src/interfaces/team-category.ts @@ -0,0 +1,10 @@ +import { Category } from "./category"; + +export interface TeamCategory { + id?: number; + name: string; + class: number; + gender: string; + age?: string; + categories?: Category[]; +} \ No newline at end of file diff --git a/src/interfaces/team-entry.ts b/src/interfaces/team-entry.ts new file mode 100644 index 0000000..d76e93f --- /dev/null +++ b/src/interfaces/team-entry.ts @@ -0,0 +1,15 @@ +import { Club } from "./club"; +import { Team } from "./team"; +import { TeamCategory } from "./team-category"; +import { Tournament } from "./tournament"; + +export interface TeamEntry { + id?: number; + sentBy: Club; + status: number; + category: TeamCategory; + tournament: Tournament; + createdAt: string; + updatedAt?: string; + team: Team; +} diff --git a/src/interfaces/team.ts b/src/interfaces/team.ts new file mode 100644 index 0000000..a3d5b2d --- /dev/null +++ b/src/interfaces/team.ts @@ -0,0 +1,7 @@ +import { Club } from "./club"; + +export interface Team { + id?: number; + name: string; + club: Club; +} diff --git a/src/interfaces/tournament.ts b/src/interfaces/tournament.ts new file mode 100644 index 0000000..7182590 --- /dev/null +++ b/src/interfaces/tournament.ts @@ -0,0 +1,31 @@ +import { Category } from "./category"; +import { Club } from "./club"; +import { Official } from "./official"; +import { TeamCategory } from "./team-category"; + +export interface Tournament { + id?: number; + name: string; + dateFrom: string; + dateTo?: string; + entryDeadline?: string; + entryOpenFrom?: string; + categories: Array; + teamCategories?: Array; + /** + * @deprecated use organizerName instead + */ + organizer?: Club; + organizerName?: string; + active: boolean; + city?: string; + onlyWithLicence: boolean; + teamChampionship: boolean; + allowedWithoutPartner: boolean; + allowedSimilarEntries: boolean; + entriesChecked?: boolean; + referee: Official | null; + deputyReferee: Official | null; + drawUrl: string | null; + notificationsSentAt?: Date | null; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9b2d394 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": false, + "outDir": "dist", + "module": "commonjs", + "target": "ES6", + "strict": true + }, + "include": [ + "src" + ] +} \ No newline at end of file