tenniscommon 1.0.1

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.
Files changed (207) hide show
  1. package/README.md +40 -0
  2. package/dist/cjs/common/general/generalInterfaces.d.ts +16 -0
  3. package/dist/cjs/common/general/generalInterfaces.js +2 -0
  4. package/dist/cjs/common/general/generalUtils.d.ts +88 -0
  5. package/dist/cjs/common/general/generalUtils.js +148 -0
  6. package/dist/cjs/common/general/index.d.ts +2 -0
  7. package/dist/cjs/common/general/index.js +18 -0
  8. package/dist/cjs/common/matchplay/index.d.ts +4 -0
  9. package/dist/cjs/common/matchplay/index.js +20 -0
  10. package/dist/cjs/common/matchplay/initialData.d.ts +3 -0
  11. package/dist/cjs/common/matchplay/initialData.js +65 -0
  12. package/dist/cjs/common/matchplay/initialStats.d.ts +7 -0
  13. package/dist/cjs/common/matchplay/initialStats.js +105 -0
  14. package/dist/cjs/common/matchplay/initialTotals.d.ts +4 -0
  15. package/dist/cjs/common/matchplay/initialTotals.js +72 -0
  16. package/dist/cjs/common/matchplay/interfaces.d.ts +184 -0
  17. package/dist/cjs/common/matchplay/interfaces.js +106 -0
  18. package/dist/cjs/common/matchplay/validation.d.ts +783 -0
  19. package/dist/cjs/common/matchplay/validation.js +108 -0
  20. package/dist/cjs/common/opponent/index.d.ts +3 -0
  21. package/dist/cjs/common/opponent/index.js +19 -0
  22. package/dist/cjs/common/opponent/initialData.d.ts +3 -0
  23. package/dist/cjs/common/opponent/initialData.js +25 -0
  24. package/dist/cjs/common/opponent/interfaces.d.ts +22 -0
  25. package/dist/cjs/common/opponent/interfaces.js +8 -0
  26. package/dist/cjs/common/opponent/validation.d.ts +23 -0
  27. package/dist/cjs/common/opponent/validation.js +13 -0
  28. package/dist/cjs/common/performance/index.d.ts +3 -0
  29. package/dist/cjs/common/performance/index.js +19 -0
  30. package/dist/cjs/common/performance/initialData.d.ts +2 -0
  31. package/dist/cjs/common/performance/initialData.js +13 -0
  32. package/dist/cjs/common/performance/interfaces.d.ts +68 -0
  33. package/dist/cjs/common/performance/interfaces.js +37 -0
  34. package/dist/cjs/common/performance/validation.d.ts +17 -0
  35. package/dist/cjs/common/performance/validation.js +11 -0
  36. package/dist/cjs/common/player/index.d.ts +3 -0
  37. package/dist/cjs/common/player/index.js +19 -0
  38. package/dist/cjs/common/player/initialData.d.ts +37 -0
  39. package/dist/cjs/common/player/initialData.js +60 -0
  40. package/dist/cjs/common/player/interfaces.d.ts +28 -0
  41. package/dist/cjs/common/player/interfaces.js +2 -0
  42. package/dist/cjs/common/player/validation.d.ts +204 -0
  43. package/dist/cjs/common/player/validation.js +38 -0
  44. package/dist/cjs/common/spending/index.d.ts +4 -0
  45. package/dist/cjs/common/spending/index.js +20 -0
  46. package/dist/cjs/common/spending/initialData.d.ts +2 -0
  47. package/dist/cjs/common/spending/initialData.js +15 -0
  48. package/dist/cjs/common/spending/initialStats.d.ts +2 -0
  49. package/dist/cjs/common/spending/initialStats.js +29 -0
  50. package/dist/cjs/common/spending/initialTotals.d.ts +2 -0
  51. package/dist/cjs/common/spending/initialTotals.js +29 -0
  52. package/dist/cjs/common/spending/interfaces.d.ts +61 -0
  53. package/dist/cjs/common/spending/interfaces.js +41 -0
  54. package/dist/cjs/common/spending/validation.d.ts +39 -0
  55. package/dist/cjs/common/spending/validation.js +22 -0
  56. package/dist/cjs/common/tournament/index.d.ts +3 -0
  57. package/dist/cjs/common/tournament/index.js +19 -0
  58. package/dist/cjs/common/tournament/initialData.d.ts +3 -0
  59. package/dist/cjs/common/tournament/initialData.js +27 -0
  60. package/dist/cjs/common/tournament/interfaces.d.ts +43 -0
  61. package/dist/cjs/common/tournament/interfaces.js +27 -0
  62. package/dist/cjs/common/tournament/validation.d.ts +49 -0
  63. package/dist/cjs/common/tournament/validation.js +25 -0
  64. package/dist/cjs/common/training/index.d.ts +4 -0
  65. package/dist/cjs/common/training/index.js +20 -0
  66. package/dist/cjs/common/training/initialData.d.ts +2 -0
  67. package/dist/cjs/common/training/initialData.js +14 -0
  68. package/dist/cjs/common/training/initialStats.d.ts +2 -0
  69. package/dist/cjs/common/training/initialStats.js +27 -0
  70. package/dist/cjs/common/training/initialTotals.d.ts +2 -0
  71. package/dist/cjs/common/training/initialTotals.js +27 -0
  72. package/dist/cjs/common/training/interfaces.d.ts +40 -0
  73. package/dist/cjs/common/training/interfaces.js +17 -0
  74. package/dist/cjs/common/training/validation.d.ts +20 -0
  75. package/dist/cjs/common/training/validation.js +11 -0
  76. package/dist/cjs/common/trainingWeekly/index.d.ts +3 -0
  77. package/dist/cjs/common/trainingWeekly/index.js +19 -0
  78. package/dist/cjs/common/trainingWeekly/initialData.d.ts +2 -0
  79. package/dist/cjs/common/trainingWeekly/initialData.js +17 -0
  80. package/dist/cjs/common/trainingWeekly/interfaces.d.ts +12 -0
  81. package/dist/cjs/common/trainingWeekly/interfaces.js +2 -0
  82. package/dist/cjs/common/trainingWeekly/validation.d.ts +23 -0
  83. package/dist/cjs/common/trainingWeekly/validation.js +12 -0
  84. package/dist/esm/common/general/generalInterfaces.d.ts +16 -0
  85. package/dist/esm/common/general/generalInterfaces.js +1 -0
  86. package/dist/esm/common/general/generalUtils.d.ts +88 -0
  87. package/dist/esm/common/general/generalUtils.js +133 -0
  88. package/dist/esm/common/general/index.d.ts +2 -0
  89. package/dist/esm/common/general/index.js +2 -0
  90. package/dist/esm/common/matchplay/index.d.ts +4 -0
  91. package/dist/esm/common/matchplay/index.js +4 -0
  92. package/dist/esm/common/matchplay/initialData.d.ts +3 -0
  93. package/dist/esm/common/matchplay/initialData.js +61 -0
  94. package/dist/esm/common/matchplay/initialStats.d.ts +7 -0
  95. package/dist/esm/common/matchplay/initialStats.js +96 -0
  96. package/dist/esm/common/matchplay/initialTotals.d.ts +4 -0
  97. package/dist/esm/common/matchplay/initialTotals.js +66 -0
  98. package/dist/esm/common/matchplay/interfaces.d.ts +184 -0
  99. package/dist/esm/common/matchplay/interfaces.js +103 -0
  100. package/dist/esm/common/matchplay/validation.d.ts +783 -0
  101. package/dist/esm/common/matchplay/validation.js +105 -0
  102. package/dist/esm/common/opponent/index.d.ts +3 -0
  103. package/dist/esm/common/opponent/index.js +3 -0
  104. package/dist/esm/common/opponent/initialData.d.ts +3 -0
  105. package/dist/esm/common/opponent/initialData.js +21 -0
  106. package/dist/esm/common/opponent/interfaces.d.ts +22 -0
  107. package/dist/esm/common/opponent/interfaces.js +5 -0
  108. package/dist/esm/common/opponent/validation.d.ts +23 -0
  109. package/dist/esm/common/opponent/validation.js +10 -0
  110. package/dist/esm/common/performance/index.d.ts +3 -0
  111. package/dist/esm/common/performance/index.js +3 -0
  112. package/dist/esm/common/performance/initialData.d.ts +2 -0
  113. package/dist/esm/common/performance/initialData.js +10 -0
  114. package/dist/esm/common/performance/interfaces.d.ts +68 -0
  115. package/dist/esm/common/performance/interfaces.js +34 -0
  116. package/dist/esm/common/performance/validation.d.ts +17 -0
  117. package/dist/esm/common/performance/validation.js +8 -0
  118. package/dist/esm/common/player/index.d.ts +3 -0
  119. package/dist/esm/common/player/index.js +3 -0
  120. package/dist/esm/common/player/initialData.d.ts +37 -0
  121. package/dist/esm/common/player/initialData.js +55 -0
  122. package/dist/esm/common/player/interfaces.d.ts +28 -0
  123. package/dist/esm/common/player/interfaces.js +1 -0
  124. package/dist/esm/common/player/validation.d.ts +204 -0
  125. package/dist/esm/common/player/validation.js +35 -0
  126. package/dist/esm/common/spending/index.d.ts +4 -0
  127. package/dist/esm/common/spending/index.js +4 -0
  128. package/dist/esm/common/spending/initialData.d.ts +2 -0
  129. package/dist/esm/common/spending/initialData.js +12 -0
  130. package/dist/esm/common/spending/initialStats.d.ts +2 -0
  131. package/dist/esm/common/spending/initialStats.js +25 -0
  132. package/dist/esm/common/spending/initialTotals.d.ts +2 -0
  133. package/dist/esm/common/spending/initialTotals.js +25 -0
  134. package/dist/esm/common/spending/interfaces.d.ts +61 -0
  135. package/dist/esm/common/spending/interfaces.js +37 -0
  136. package/dist/esm/common/spending/validation.d.ts +39 -0
  137. package/dist/esm/common/spending/validation.js +19 -0
  138. package/dist/esm/common/tournament/index.d.ts +3 -0
  139. package/dist/esm/common/tournament/index.js +3 -0
  140. package/dist/esm/common/tournament/initialData.d.ts +3 -0
  141. package/dist/esm/common/tournament/initialData.js +23 -0
  142. package/dist/esm/common/tournament/interfaces.d.ts +43 -0
  143. package/dist/esm/common/tournament/interfaces.js +24 -0
  144. package/dist/esm/common/tournament/validation.d.ts +49 -0
  145. package/dist/esm/common/tournament/validation.js +22 -0
  146. package/dist/esm/common/training/index.d.ts +4 -0
  147. package/dist/esm/common/training/index.js +4 -0
  148. package/dist/esm/common/training/initialData.d.ts +2 -0
  149. package/dist/esm/common/training/initialData.js +11 -0
  150. package/dist/esm/common/training/initialStats.d.ts +2 -0
  151. package/dist/esm/common/training/initialStats.js +23 -0
  152. package/dist/esm/common/training/initialTotals.d.ts +2 -0
  153. package/dist/esm/common/training/initialTotals.js +23 -0
  154. package/dist/esm/common/training/interfaces.d.ts +40 -0
  155. package/dist/esm/common/training/interfaces.js +14 -0
  156. package/dist/esm/common/training/validation.d.ts +20 -0
  157. package/dist/esm/common/training/validation.js +8 -0
  158. package/dist/esm/common/trainingWeekly/index.d.ts +3 -0
  159. package/dist/esm/common/trainingWeekly/index.js +3 -0
  160. package/dist/esm/common/trainingWeekly/initialData.d.ts +2 -0
  161. package/dist/esm/common/trainingWeekly/initialData.js +14 -0
  162. package/dist/esm/common/trainingWeekly/interfaces.d.ts +12 -0
  163. package/dist/esm/common/trainingWeekly/interfaces.js +1 -0
  164. package/dist/esm/common/trainingWeekly/validation.d.ts +23 -0
  165. package/dist/esm/common/trainingWeekly/validation.js +9 -0
  166. package/dist/types/common/general/generalInterfaces.d.ts +16 -0
  167. package/dist/types/common/general/generalUtils.d.ts +88 -0
  168. package/dist/types/common/general/index.d.ts +2 -0
  169. package/dist/types/common/matchplay/index.d.ts +4 -0
  170. package/dist/types/common/matchplay/initialData.d.ts +3 -0
  171. package/dist/types/common/matchplay/initialStats.d.ts +7 -0
  172. package/dist/types/common/matchplay/initialTotals.d.ts +4 -0
  173. package/dist/types/common/matchplay/interfaces.d.ts +184 -0
  174. package/dist/types/common/matchplay/validation.d.ts +783 -0
  175. package/dist/types/common/opponent/index.d.ts +3 -0
  176. package/dist/types/common/opponent/initialData.d.ts +3 -0
  177. package/dist/types/common/opponent/interfaces.d.ts +22 -0
  178. package/dist/types/common/opponent/validation.d.ts +23 -0
  179. package/dist/types/common/performance/index.d.ts +3 -0
  180. package/dist/types/common/performance/initialData.d.ts +2 -0
  181. package/dist/types/common/performance/interfaces.d.ts +68 -0
  182. package/dist/types/common/performance/validation.d.ts +17 -0
  183. package/dist/types/common/player/index.d.ts +3 -0
  184. package/dist/types/common/player/initialData.d.ts +37 -0
  185. package/dist/types/common/player/interfaces.d.ts +28 -0
  186. package/dist/types/common/player/validation.d.ts +204 -0
  187. package/dist/types/common/spending/index.d.ts +4 -0
  188. package/dist/types/common/spending/initialData.d.ts +2 -0
  189. package/dist/types/common/spending/initialStats.d.ts +2 -0
  190. package/dist/types/common/spending/initialTotals.d.ts +2 -0
  191. package/dist/types/common/spending/interfaces.d.ts +61 -0
  192. package/dist/types/common/spending/validation.d.ts +39 -0
  193. package/dist/types/common/tournament/index.d.ts +3 -0
  194. package/dist/types/common/tournament/initialData.d.ts +3 -0
  195. package/dist/types/common/tournament/interfaces.d.ts +43 -0
  196. package/dist/types/common/tournament/validation.d.ts +49 -0
  197. package/dist/types/common/training/index.d.ts +4 -0
  198. package/dist/types/common/training/initialData.d.ts +2 -0
  199. package/dist/types/common/training/initialStats.d.ts +2 -0
  200. package/dist/types/common/training/initialTotals.d.ts +2 -0
  201. package/dist/types/common/training/interfaces.d.ts +40 -0
  202. package/dist/types/common/training/validation.d.ts +20 -0
  203. package/dist/types/common/trainingWeekly/index.d.ts +3 -0
  204. package/dist/types/common/trainingWeekly/initialData.d.ts +2 -0
  205. package/dist/types/common/trainingWeekly/interfaces.d.ts +12 -0
  206. package/dist/types/common/trainingWeekly/validation.d.ts +23 -0
  207. package/package.json +95 -0
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './initialStats';
4
+ export * from './validation';
@@ -0,0 +1,2 @@
1
+ import { TrainingItem } from './interfaces';
2
+ export declare function createInitialTrainingItem(playerId: string, date: Date): TrainingItem;
@@ -0,0 +1,11 @@
1
+ import { TRAINING } from './interfaces';
2
+ // Factory function for creating initial TrainingItem
3
+ export function createInitialTrainingItem(playerId, date) {
4
+ return {
5
+ _id: '',
6
+ playerId: playerId,
7
+ date: date,
8
+ type: TRAINING.ACTIVITY.Individual,
9
+ time: 1,
10
+ };
11
+ }
@@ -0,0 +1,2 @@
1
+ import { TrainingTotals } from './interfaces';
2
+ export declare const createDefaultTrainingTotal: () => TrainingTotals;
@@ -0,0 +1,23 @@
1
+ import { COMMONS_ARRAYS } from '../general';
2
+ import { TRAINING_ARRAYS } from './interfaces';
3
+ export const createDefaultTrainingTotal = () => {
4
+ const hoursPerType = {};
5
+ const hoursPerMonth = {};
6
+ const hoursPerMonthPerType = {};
7
+ TRAINING_ARRAYS.ACTIVITY.forEach(type => { hoursPerType[type] = 0; });
8
+ COMMONS_ARRAYS.MONTH.forEach(month => {
9
+ hoursPerMonth[month] = 0;
10
+ hoursPerMonthPerType[month] = {};
11
+ TRAINING_ARRAYS.ACTIVITY.forEach(type => {
12
+ hoursPerMonthPerType[month][type] = 0;
13
+ });
14
+ });
15
+ return {
16
+ totalHours: 0,
17
+ totalHoursLastMonth: 0,
18
+ averageHoursPerMonth: 0,
19
+ hoursPerType,
20
+ hoursPerMonth,
21
+ hoursPerMonthPerType,
22
+ };
23
+ };
@@ -0,0 +1,2 @@
1
+ import { TrainingTotals } from './interfaces';
2
+ export declare const createDefaultTrainingTotal: () => TrainingTotals;
@@ -0,0 +1,23 @@
1
+ import { COMMONS_ARRAYS } from '../general';
2
+ import { TRAINING_ARRAYS } from './interfaces';
3
+ export const createDefaultTrainingTotal = () => {
4
+ const hoursPerType = {};
5
+ const hoursPerMonth = {};
6
+ const hoursPerMonthPerType = {};
7
+ TRAINING_ARRAYS.ACTIVITY.forEach(type => { hoursPerType[type] = 0; });
8
+ COMMONS_ARRAYS.MONTH.forEach(month => {
9
+ hoursPerMonth[month] = 0;
10
+ hoursPerMonthPerType[month] = {};
11
+ TRAINING_ARRAYS.ACTIVITY.forEach(type => {
12
+ hoursPerMonthPerType[month][type] = 0;
13
+ });
14
+ });
15
+ return {
16
+ totalHours: 0,
17
+ totalHoursLastMonth: 0,
18
+ averageHoursPerMonth: 0,
19
+ hoursPerType,
20
+ hoursPerMonth,
21
+ hoursPerMonthPerType,
22
+ };
23
+ };
@@ -0,0 +1,40 @@
1
+ import { ValueOf } from '../general';
2
+ export declare const TRAINING: {
3
+ readonly ACTIVITY: {
4
+ readonly Squad: "Squad";
5
+ readonly Individual: "Individual";
6
+ readonly Lesson: "Lesson";
7
+ readonly Hit: "Hit";
8
+ readonly MatchPractice: "Match-Practice";
9
+ readonly Physical: "Physical";
10
+ readonly OtherSports: "Other Sports";
11
+ };
12
+ };
13
+ export type TRAINING_ACTIVITY_UNION = ValueOf<typeof TRAINING.ACTIVITY>;
14
+ export declare const TRAINING_ARRAYS: {
15
+ ACTIVITY: TRAINING_ACTIVITY_UNION[];
16
+ };
17
+ export interface TrainingItem {
18
+ _id: string;
19
+ playerId: string;
20
+ date: Date;
21
+ type: TRAINING_ACTIVITY_UNION;
22
+ time: number;
23
+ spendingId?: string;
24
+ }
25
+ export interface TrainingTotals {
26
+ totalHours: number;
27
+ totalHoursLastMonth: number;
28
+ averageHoursPerMonth: number;
29
+ hoursPerType: {
30
+ [type: string]: number;
31
+ };
32
+ hoursPerMonth: {
33
+ [month: string]: number;
34
+ };
35
+ hoursPerMonthPerType: {
36
+ [month: string]: {
37
+ [type: string]: number;
38
+ };
39
+ };
40
+ }
@@ -0,0 +1,14 @@
1
+ export const TRAINING = {
2
+ ACTIVITY: {
3
+ Squad: 'Squad',
4
+ Individual: 'Individual',
5
+ Lesson: 'Lesson',
6
+ Hit: 'Hit',
7
+ MatchPractice: 'Match-Practice',
8
+ Physical: 'Physical',
9
+ OtherSports: 'Other Sports',
10
+ },
11
+ };
12
+ export const TRAINING_ARRAYS = {
13
+ ACTIVITY: Object.values(TRAINING.ACTIVITY),
14
+ };
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ export declare const trainingItemSchema: z.ZodObject<{
3
+ playerId: z.ZodString;
4
+ date: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
5
+ type: z.ZodString;
6
+ time: z.ZodNumber;
7
+ spendingId: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: string;
10
+ time: number;
11
+ date: Date;
12
+ playerId: string;
13
+ spendingId?: string | undefined;
14
+ }, {
15
+ type: string;
16
+ time: number;
17
+ playerId: string;
18
+ date?: unknown;
19
+ spendingId?: string | undefined;
20
+ }>;
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ export const trainingItemSchema = z.object({
3
+ playerId: z.string().min(1, 'PlayerId is required.'),
4
+ date: z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
5
+ type: z.string().min(1, 'Type is required.'),
6
+ time: z.number().nonnegative('Time must be a non-negative number.'),
7
+ spendingId: z.string().optional()
8
+ });
@@ -0,0 +1,3 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './validation';
@@ -0,0 +1,3 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './validation';
@@ -0,0 +1,2 @@
1
+ import { TrainingWeeklyItem } from './interfaces';
2
+ export declare function createInitialTrainingWeeklyItem(playerId: string): TrainingWeeklyItem;
@@ -0,0 +1,14 @@
1
+ import { SPENDING } from '../spending';
2
+ import { COMMONS } from '../general';
3
+ import { TRAINING } from '../training';
4
+ export function createInitialTrainingWeeklyItem(playerId) {
5
+ return {
6
+ _id: '',
7
+ playerId: playerId,
8
+ day: COMMONS.WEEKDAY.Monday,
9
+ type: TRAINING.ACTIVITY.Individual,
10
+ time: 1,
11
+ spendingType: SPENDING.TYPE.CourtHire,
12
+ cost: 0,
13
+ };
14
+ }
@@ -0,0 +1,12 @@
1
+ import { TRAINING_ACTIVITY_UNION } from '../training';
2
+ import { SPENDING_TYPE_UNION } from '../spending';
3
+ import { WEEKDAY_UNION } from '../general';
4
+ export interface TrainingWeeklyItem {
5
+ _id: string;
6
+ playerId: string;
7
+ day: WEEKDAY_UNION;
8
+ type: TRAINING_ACTIVITY_UNION;
9
+ time: number;
10
+ spendingType: SPENDING_TYPE_UNION;
11
+ cost: number;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ export declare const trainingWeeklyItemSchema: z.ZodObject<{
3
+ playerId: z.ZodString;
4
+ day: z.ZodString;
5
+ type: z.ZodString;
6
+ time: z.ZodNumber;
7
+ spendingType: z.ZodString;
8
+ cost: z.ZodNumber;
9
+ }, "strip", z.ZodTypeAny, {
10
+ type: string;
11
+ time: number;
12
+ day: string;
13
+ playerId: string;
14
+ cost: number;
15
+ spendingType: string;
16
+ }, {
17
+ type: string;
18
+ time: number;
19
+ day: string;
20
+ playerId: string;
21
+ cost: number;
22
+ spendingType: string;
23
+ }>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export const trainingWeeklyItemSchema = z.object({
3
+ playerId: z.string().min(1, 'PlayerId is required.'),
4
+ day: z.string().min(1, 'Day is required.'),
5
+ type: z.string().min(1, 'Type is required.'),
6
+ time: z.number().nonnegative('Time must be a non-negative number.'),
7
+ spendingType: z.string().min(1, 'Spending Type is required.'),
8
+ cost: z.number().nonnegative('Cost must be a non-negative number.')
9
+ });
@@ -0,0 +1,16 @@
1
+ import { ZodIssue } from 'zod';
2
+ export interface FetchOptions extends RequestInit {
3
+ headers?: HeadersInit;
4
+ }
5
+ export interface FetchResponse<T, E = ZodIssue[]> {
6
+ ok: boolean;
7
+ status: number;
8
+ message: string;
9
+ body: T;
10
+ errors?: E;
11
+ }
12
+ export interface DeleteResponse {
13
+ message: string;
14
+ }
15
+ export type FilterOption<T> = T | 'all';
16
+ export type ValueOf<T> = T[keyof T];
@@ -0,0 +1,88 @@
1
+ import { PlayerConfig } from '../player';
2
+ import { ValueOf } from './generalInterfaces';
3
+ export declare const COMMONS: {
4
+ readonly WEEKDAY: {
5
+ readonly Monday: "Monday";
6
+ readonly Tuesday: "Tuesday";
7
+ readonly Wednesday: "Wednesday";
8
+ readonly Thursday: "Thursday";
9
+ readonly Friday: "Friday";
10
+ readonly Saturday: "Saturday";
11
+ readonly Sunday: "Sunday";
12
+ };
13
+ readonly MONTH: {
14
+ readonly January: "January";
15
+ readonly February: "February";
16
+ readonly March: "March";
17
+ readonly April: "April";
18
+ readonly May: "May";
19
+ readonly June: "June";
20
+ readonly July: "July";
21
+ readonly August: "August";
22
+ readonly September: "September";
23
+ readonly October: "October";
24
+ readonly November: "November";
25
+ readonly December: "December";
26
+ };
27
+ readonly BOOLEAN: {
28
+ readonly Yes: "Yes";
29
+ readonly No: "No";
30
+ };
31
+ };
32
+ export type keyValuePair = {
33
+ id: string;
34
+ name: string;
35
+ };
36
+ export type WEEKDAY_UNION = ValueOf<typeof COMMONS.WEEKDAY>;
37
+ export type MONTH_UNION = ValueOf<typeof COMMONS.MONTH>;
38
+ export type BOOLEAN_UNION = ValueOf<typeof COMMONS.BOOLEAN>;
39
+ export declare const COMMONS_ARRAYS: {
40
+ WEEKDAY: WEEKDAY_UNION[];
41
+ MONTH: MONTH_UNION[];
42
+ BOOLEAN: BOOLEAN_UNION[];
43
+ };
44
+ export declare const COLLECTION: {
45
+ readonly matchplaySingles: "matchplaySingles";
46
+ readonly matchplayDoubles: "matchplayDoubles";
47
+ readonly opponent: "opponent";
48
+ readonly performance: "performance";
49
+ readonly player: "player";
50
+ readonly spending: "spending";
51
+ readonly trainingWeekly: "trainingWeekly";
52
+ readonly training: "training";
53
+ readonly tournament: "tournament";
54
+ };
55
+ export declare const CurrentMonth: string;
56
+ export declare const CurrentYearMinus12: number;
57
+ export declare const getMonthNameByOffset: (offset: number) => string;
58
+ export declare function getCurrentYear(date?: Date): number;
59
+ export declare const getCurrentMonthNumber: (date?: Date) => number;
60
+ export declare const getMonthByName: (date?: string) => string;
61
+ export declare const getCurrentDateInDDMMYYYY: (date: Date) => string;
62
+ export declare const getAgeGroup: (birthYear: number) => string;
63
+ type KeyValue<T extends string, U extends string> = {
64
+ [key in T]: string;
65
+ } & {
66
+ [value in U]: number;
67
+ };
68
+ export declare const convertJsonToArray: <T extends string, U extends string>(json: {
69
+ [s: string]: number;
70
+ }, objectName: T, objectValue: U) => KeyValue<T, U>[];
71
+ export declare const normalizeKey: (key: string) => string;
72
+ type KeyValueWithTwoNumbers<T extends string, U extends string, V extends string> = {
73
+ [key in T]: string;
74
+ } & {
75
+ [key in U]: number;
76
+ } & {
77
+ [key in V]: number;
78
+ };
79
+ export declare const convertJsonToArrayWithTwoNumbers: <T extends string, U extends string, V extends string>(json: {
80
+ [s: string]: {
81
+ singles: number;
82
+ doubles: number;
83
+ };
84
+ }, objectName: T, singlesKey: U, doublesKey: V) => KeyValueWithTwoNumbers<T, U, V>[];
85
+ export declare function convertToDate(dateInput: string | Date): Date;
86
+ export declare function configDate(playerConfig: PlayerConfig): Date;
87
+ export declare function isValidPassword(password: string): boolean;
88
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './generalInterfaces';
2
+ export * from './generalUtils';
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './initialStats';
4
+ export * from './validation';
@@ -0,0 +1,3 @@
1
+ import { MatchplayItem } from './interfaces';
2
+ export declare function createInitialMatchplaySinglesItem(playerId: string, date: Date): MatchplayItem;
3
+ export declare function createInitialMatchplayDoublesItem(playerId: string, date: Date): MatchplayItem;
@@ -0,0 +1,7 @@
1
+ import { MatchplayStats, EnhancedStatsPack, MatchStats, BasicStatsPack, SpecificStats, StatsPack } from './interfaces';
2
+ export declare const createMatchplayStats: () => MatchplayStats;
3
+ export declare const createStatsPack: () => StatsPack;
4
+ export declare const createBasicStatsPack: () => BasicStatsPack;
5
+ export declare const createEnhancedStatsPack: () => EnhancedStatsPack;
6
+ export declare const createMatchStats: () => MatchStats;
7
+ export declare const createSpecificStats: () => SpecificStats;
@@ -0,0 +1,4 @@
1
+ import { ByType, MatchplayTotals, MatchStats } from './interfaces';
2
+ export declare const createDefaultMatchplayTotals: () => MatchplayTotals;
3
+ export declare const createDefaultByType: () => ByType;
4
+ export declare const createDefaultMatchStats: () => MatchStats;
@@ -0,0 +1,184 @@
1
+ import { ValueOf } from '../general';
2
+ export declare const MATCH: {
3
+ readonly FORMAT: {
4
+ readonly Singles: "Singles";
5
+ readonly Doubles: "Doubles";
6
+ };
7
+ readonly SURFACE: {
8
+ readonly Grass: "Grass";
9
+ readonly Clay: "Clay";
10
+ readonly Hard: "Hard";
11
+ };
12
+ readonly WINNER: {
13
+ readonly Player: "Player";
14
+ readonly Opponent: "Opponent";
15
+ };
16
+ readonly DECIDING_SET_FORMAT: {
17
+ readonly ChampionshipTiebreak: "Championship Tiebreak";
18
+ readonly ThirdSet: "Thirdset";
19
+ };
20
+ readonly RESULT: {
21
+ readonly Win: "Win";
22
+ readonly Loss: "Loss";
23
+ };
24
+ readonly AGE_GROUP: {
25
+ readonly U12: "U12";
26
+ readonly U14: "U14";
27
+ readonly U16: "U16";
28
+ readonly U18: "U18";
29
+ readonly Adult: "Adult";
30
+ };
31
+ readonly ROUND: {
32
+ readonly RoundRobin: "Round Robin";
33
+ readonly Consolation: "Consolation";
34
+ readonly Qualifier: "Qualifier";
35
+ readonly Round64: "Round 64";
36
+ readonly Round32: "Round 32";
37
+ readonly Round16: "Round 16";
38
+ readonly QF: "QF";
39
+ readonly SF: "SF";
40
+ readonly Final: "Final";
41
+ };
42
+ readonly LOCATION: {
43
+ readonly Indoor: "Indoor";
44
+ readonly Outdoor: "Outdoor";
45
+ };
46
+ readonly SET_FORMAT: {
47
+ readonly Full: "Full";
48
+ readonly FourAll: "Four All";
49
+ readonly FastFour: "Fast Four";
50
+ };
51
+ readonly SET_SCORES_PLAYER: readonly ["6-0", "6-1", "6-2", "6-3", "6-4", "7-5", "7-6"];
52
+ readonly SET_SCORES_OPPONENT: readonly ["0-6", "1-6", "2-6", "3-6", "4-6", "5-7", "6-7"];
53
+ readonly FOUR_ALL_SET_SCORES_PLAYER: readonly ["4-0", "4-1", "4-2", "5-3", "5-4"];
54
+ readonly FOUR_ALL_SET_SCORES_OPPONENT: readonly ["0-4", "1-4", "2-4", "3-5", "4-5"];
55
+ readonly FAST_FOUR_SET_SCORES_PLAYER: readonly ["4-0", "4-1", "4-2", "4-3"];
56
+ readonly FAST_FOUR_SET_SCORES_OPPONENT: readonly ["0-4", "1-4", "2-4", "3-4"];
57
+ readonly TIE_BREAK_CHAMPIONSHIP_SCORES_PLAYER: readonly ["10-0", "10-1", "10-2", "10-3", "10-4", "10-5", "10-6", "10-7", "10-8", "11-9", "12-10", "13-11", "14-12", "15-13", "16-14"];
58
+ readonly TIE_BREAK_CHAMPIONSHIP_SCORES_OPPONENT: readonly ["0-10", "1-10", "2-10", "3-10", "4-10", "5-10", "6-10", "7-10", "8-10", "9-11", "10-12", "11-13", "12-14", "13-15", "14-16"];
59
+ readonly TIE_BREAK_SCORES_PLAYER: readonly ["7-0", "7-1", "7-2", "7-3", "7-4", "7-5", "8-6", "9-7", "10-8", "11-9", "12-10"];
60
+ readonly TIE_BREAK_SCORES_OPPONENT: readonly ["0-7", "1-7", "2-7", "3-7", "4-7", "5-7", "6-8", "7-9", "8-10", "9-11", "10-12"];
61
+ };
62
+ export type MATCH_FORMAT_UNION = ValueOf<typeof MATCH.FORMAT>;
63
+ export type MATCH_SURFACE_UNION = ValueOf<typeof MATCH.SURFACE>;
64
+ export type MATCH_WINNER_UNION = ValueOf<typeof MATCH.WINNER>;
65
+ export type MATCH_DECIDING_SET_FORMAT_UNION = ValueOf<typeof MATCH.DECIDING_SET_FORMAT>;
66
+ export type MATCH_RESULT_UNION = ValueOf<typeof MATCH.RESULT>;
67
+ export type MATCH_AGE_GROUP_UNION = ValueOf<typeof MATCH.AGE_GROUP>;
68
+ export type MATCH_ROUND_UNION = ValueOf<typeof MATCH.ROUND>;
69
+ export type MATCH_LOCATION_UNION = ValueOf<typeof MATCH.LOCATION>;
70
+ export type MATCH_SET_FORMAT_UNION = ValueOf<typeof MATCH.SET_FORMAT>;
71
+ export declare const MATCH_ARRAYS: {
72
+ FORMAT: MATCH_FORMAT_UNION[];
73
+ SURFACE: MATCH_SURFACE_UNION[];
74
+ WINNER: MATCH_WINNER_UNION[];
75
+ DECIDING_SET_FORMAT: MATCH_DECIDING_SET_FORMAT_UNION[];
76
+ RESULT: MATCH_RESULT_UNION[];
77
+ AGE_GROUP: MATCH_AGE_GROUP_UNION[];
78
+ ROUND: MATCH_ROUND_UNION[];
79
+ LOCATION: MATCH_LOCATION_UNION[];
80
+ SET_FORMAT: MATCH_SET_FORMAT_UNION[];
81
+ };
82
+ export interface MatchplayItem {
83
+ _id: string;
84
+ playerId: string;
85
+ date: Date;
86
+ tournamentId: string;
87
+ tournamentYearId: string;
88
+ matchFormat: MATCH_FORMAT_UNION;
89
+ matchAgeGroup: MATCH_AGE_GROUP_UNION;
90
+ matchRound: MATCH_ROUND_UNION;
91
+ matchSurface: MATCH_SURFACE_UNION;
92
+ matchLocation: MATCH_LOCATION_UNION;
93
+ matchSetFormat: MATCH_SET_FORMAT_UNION;
94
+ matchResult: MATCH_RESULT_UNION;
95
+ partnerId?: string;
96
+ opponentId: string;
97
+ opponentIdTwo?: string;
98
+ firstSetWon: MATCH_WINNER_UNION;
99
+ secondSetWon: MATCH_WINNER_UNION;
100
+ decidingSetFormat?: MATCH_DECIDING_SET_FORMAT_UNION;
101
+ decidingSetWon?: MATCH_WINNER_UNION;
102
+ firstSet: string;
103
+ firstSetTieBreak?: string;
104
+ secondSet: string;
105
+ secondSetTieBreak?: string;
106
+ decidingSet?: string;
107
+ decidingSetTieBreak?: string;
108
+ comment: string;
109
+ }
110
+ export interface MatchplayStats {
111
+ Career: StatsPack;
112
+ CareerSingles: StatsPack;
113
+ CareerDoubles: StatsPack;
114
+ combinedMatchesPerMonth: {
115
+ [month: string]: {
116
+ singles: number;
117
+ doubles: number;
118
+ };
119
+ };
120
+ }
121
+ export interface MatchStats {
122
+ matches: number;
123
+ won: number;
124
+ lost: number;
125
+ wonPercentage: number;
126
+ lostPercentage: number;
127
+ }
128
+ export interface SpecificStats {
129
+ total: number;
130
+ won: number;
131
+ lost: number;
132
+ wonPercentage: number;
133
+ lostPercentage: number;
134
+ }
135
+ export interface StatsPack {
136
+ basicStatsPack: BasicStatsPack;
137
+ enhancedStatsPack: EnhancedStatsPack;
138
+ }
139
+ export interface EnhancedStatsPack {
140
+ matchStats_ByFormat: {
141
+ [key in MATCH_FORMAT_UNION]: MatchStats;
142
+ };
143
+ matchStats_ByAgeGroup: {
144
+ [key in MATCH_AGE_GROUP_UNION]: MatchStats;
145
+ };
146
+ matchStats_ByRound: {
147
+ [key in MATCH_ROUND_UNION]: MatchStats;
148
+ };
149
+ matchStats_BySurface: {
150
+ [key in MATCH_SURFACE_UNION]: MatchStats;
151
+ };
152
+ matchStats_ByLocation: {
153
+ [key in MATCH_LOCATION_UNION]: MatchStats;
154
+ };
155
+ matchStats_BySetFormat: {
156
+ [key in MATCH_SET_FORMAT_UNION]: MatchStats;
157
+ };
158
+ matchStats_ByFirstSetWin: MatchStats;
159
+ matchStats_ByFirstSetLost: MatchStats;
160
+ matchStats_ByFirstSetTiebreak: MatchStats;
161
+ matchStats_BySecondSetWin: MatchStats;
162
+ matchStats_BySecondSetLost: MatchStats;
163
+ matchStats_BySecondSetTiebreak: MatchStats;
164
+ matchStats_ByGoingToDecidingSet: MatchStats;
165
+ matchStats_ByDecidingSetFormat: {
166
+ [key in MATCH_DECIDING_SET_FORMAT_UNION]: MatchStats;
167
+ };
168
+ matchStats_ByDecidingSetWin: MatchStats;
169
+ matchStats_ByDecidingSetLost: MatchStats;
170
+ }
171
+ export interface BasicStatsPack {
172
+ overall: MatchStats;
173
+ firstSet: SpecificStats;
174
+ firstSetTieBreak: SpecificStats;
175
+ secondSet: SpecificStats;
176
+ secondSetTieBreak: SpecificStats;
177
+ firstAndSecondSets: SpecificStats;
178
+ firstAndSecondSetTieBreaks: SpecificStats;
179
+ decidingSet: SpecificStats;
180
+ decidingSetTieBreak: SpecificStats;
181
+ champTieBreak: SpecificStats;
182
+ secondSetWinAfterFirstSetLoss: SpecificStats;
183
+ games: SpecificStats;
184
+ }