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,49 @@
1
+ import { z } from 'zod';
2
+ export declare const tournamentYearItemSchema: z.ZodObject<{
3
+ year: z.ZodNumber;
4
+ date: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
5
+ category: z.ZodString;
6
+ show: z.ZodString;
7
+ comment: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ show: string;
10
+ year: number;
11
+ date: Date;
12
+ comment: string;
13
+ category: string;
14
+ }, {
15
+ show: string;
16
+ year: number;
17
+ comment: string;
18
+ category: string;
19
+ date?: unknown;
20
+ }>;
21
+ export declare const tournamentItemSchema: z.ZodObject<{
22
+ playerId: z.ZodString;
23
+ name: z.ZodString;
24
+ type: z.ZodString;
25
+ tournamentYears: z.ZodArray<z.ZodAny, "many">;
26
+ }, "strip", z.ZodTypeAny, {
27
+ name: string;
28
+ type: string;
29
+ playerId: string;
30
+ tournamentYears: any[];
31
+ }, {
32
+ name: string;
33
+ type: string;
34
+ playerId: string;
35
+ tournamentYears: any[];
36
+ }>;
37
+ export declare const tournamentPartialItemSchema: z.ZodObject<{
38
+ playerId: z.ZodString;
39
+ name: z.ZodString;
40
+ type: z.ZodString;
41
+ }, "strip", z.ZodTypeAny, {
42
+ name: string;
43
+ type: string;
44
+ playerId: string;
45
+ }, {
46
+ name: string;
47
+ type: string;
48
+ playerId: string;
49
+ }>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tournamentPartialItemSchema = exports.tournamentItemSchema = exports.tournamentYearItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ // Add a tournament year to Year array
6
+ exports.tournamentYearItemSchema = zod_1.z.object({
7
+ year: zod_1.z.number().int().gte(1950, 'Year must be greater than 1950.'),
8
+ date: zod_1.z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), zod_1.z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
9
+ category: zod_1.z.string().min(1, 'Category is required.'),
10
+ show: zod_1.z.string().min(1, 'Show is required.'),
11
+ comment: zod_1.z.string()
12
+ });
13
+ // Add a tournament to . Array must be empty with a new tournament record
14
+ exports.tournamentItemSchema = zod_1.z.object({
15
+ playerId: zod_1.z.string().min(1, 'PlayerId is required.'),
16
+ name: zod_1.z.string().min(1, 'Name is required.'),
17
+ type: zod_1.z.string().min(1, 'Type is required.'),
18
+ tournamentYears: zod_1.z.array(zod_1.z.any()).length(0, 'Year must be an empty array.'),
19
+ });
20
+ // Update a tournament to . Array will be undefined as this is for a partial update
21
+ exports.tournamentPartialItemSchema = zod_1.z.object({
22
+ playerId: zod_1.z.string().min(1, 'PlayerId is required.'),
23
+ name: zod_1.z.string().min(1, 'Name is required.'),
24
+ type: zod_1.z.string().min(1, 'Type is required.'),
25
+ });
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './initialStats';
4
+ export * from './validation';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces"), exports);
18
+ __exportStar(require("./initialData"), exports);
19
+ __exportStar(require("./initialStats"), exports);
20
+ __exportStar(require("./validation"), exports);
@@ -0,0 +1,2 @@
1
+ import { TrainingItem } from './interfaces';
2
+ export declare function createInitialTrainingItem(playerId: string, date: Date): TrainingItem;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createInitialTrainingItem = createInitialTrainingItem;
4
+ const interfaces_1 = require("./interfaces");
5
+ // Factory function for creating initial TrainingItem
6
+ function createInitialTrainingItem(playerId, date) {
7
+ return {
8
+ _id: '',
9
+ playerId: playerId,
10
+ date: date,
11
+ type: interfaces_1.TRAINING.ACTIVITY.Individual,
12
+ time: 1,
13
+ };
14
+ }
@@ -0,0 +1,2 @@
1
+ import { TrainingTotals } from './interfaces';
2
+ export declare const createDefaultTrainingTotal: () => TrainingTotals;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDefaultTrainingTotal = void 0;
4
+ const general_1 = require("../general");
5
+ const interfaces_1 = require("./interfaces");
6
+ const createDefaultTrainingTotal = () => {
7
+ const hoursPerType = {};
8
+ const hoursPerMonth = {};
9
+ const hoursPerMonthPerType = {};
10
+ interfaces_1.TRAINING_ARRAYS.ACTIVITY.forEach(type => { hoursPerType[type] = 0; });
11
+ general_1.COMMONS_ARRAYS.MONTH.forEach(month => {
12
+ hoursPerMonth[month] = 0;
13
+ hoursPerMonthPerType[month] = {};
14
+ interfaces_1.TRAINING_ARRAYS.ACTIVITY.forEach(type => {
15
+ hoursPerMonthPerType[month][type] = 0;
16
+ });
17
+ });
18
+ return {
19
+ totalHours: 0,
20
+ totalHoursLastMonth: 0,
21
+ averageHoursPerMonth: 0,
22
+ hoursPerType,
23
+ hoursPerMonth,
24
+ hoursPerMonthPerType,
25
+ };
26
+ };
27
+ exports.createDefaultTrainingTotal = createDefaultTrainingTotal;
@@ -0,0 +1,2 @@
1
+ import { TrainingTotals } from './interfaces';
2
+ export declare const createDefaultTrainingTotal: () => TrainingTotals;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDefaultTrainingTotal = void 0;
4
+ const general_1 = require("../general");
5
+ const interfaces_1 = require("./interfaces");
6
+ const createDefaultTrainingTotal = () => {
7
+ const hoursPerType = {};
8
+ const hoursPerMonth = {};
9
+ const hoursPerMonthPerType = {};
10
+ interfaces_1.TRAINING_ARRAYS.ACTIVITY.forEach(type => { hoursPerType[type] = 0; });
11
+ general_1.COMMONS_ARRAYS.MONTH.forEach(month => {
12
+ hoursPerMonth[month] = 0;
13
+ hoursPerMonthPerType[month] = {};
14
+ interfaces_1.TRAINING_ARRAYS.ACTIVITY.forEach(type => {
15
+ hoursPerMonthPerType[month][type] = 0;
16
+ });
17
+ });
18
+ return {
19
+ totalHours: 0,
20
+ totalHoursLastMonth: 0,
21
+ averageHoursPerMonth: 0,
22
+ hoursPerType,
23
+ hoursPerMonth,
24
+ hoursPerMonthPerType,
25
+ };
26
+ };
27
+ exports.createDefaultTrainingTotal = createDefaultTrainingTotal;
@@ -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,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRAINING_ARRAYS = exports.TRAINING = void 0;
4
+ exports.TRAINING = {
5
+ ACTIVITY: {
6
+ Squad: 'Squad',
7
+ Individual: 'Individual',
8
+ Lesson: 'Lesson',
9
+ Hit: 'Hit',
10
+ MatchPractice: 'Match-Practice',
11
+ Physical: 'Physical',
12
+ OtherSports: 'Other Sports',
13
+ },
14
+ };
15
+ exports.TRAINING_ARRAYS = {
16
+ ACTIVITY: Object.values(exports.TRAINING.ACTIVITY),
17
+ };
@@ -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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trainingItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.trainingItemSchema = zod_1.z.object({
6
+ playerId: zod_1.z.string().min(1, 'PlayerId is required.'),
7
+ date: zod_1.z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), zod_1.z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
8
+ type: zod_1.z.string().min(1, 'Type is required.'),
9
+ time: zod_1.z.number().nonnegative('Time must be a non-negative number.'),
10
+ spendingId: zod_1.z.string().optional()
11
+ });
@@ -0,0 +1,3 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './validation';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./interfaces"), exports);
18
+ __exportStar(require("./initialData"), exports);
19
+ __exportStar(require("./validation"), exports);
@@ -0,0 +1,2 @@
1
+ import { TrainingWeeklyItem } from './interfaces';
2
+ export declare function createInitialTrainingWeeklyItem(playerId: string): TrainingWeeklyItem;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createInitialTrainingWeeklyItem = createInitialTrainingWeeklyItem;
4
+ const spending_1 = require("../spending");
5
+ const general_1 = require("../general");
6
+ const training_1 = require("../training");
7
+ function createInitialTrainingWeeklyItem(playerId) {
8
+ return {
9
+ _id: '',
10
+ playerId: playerId,
11
+ day: general_1.COMMONS.WEEKDAY.Monday,
12
+ type: training_1.TRAINING.ACTIVITY.Individual,
13
+ time: 1,
14
+ spendingType: spending_1.SPENDING.TYPE.CourtHire,
15
+ cost: 0,
16
+ };
17
+ }
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trainingWeeklyItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.trainingWeeklyItemSchema = zod_1.z.object({
6
+ playerId: zod_1.z.string().min(1, 'PlayerId is required.'),
7
+ day: zod_1.z.string().min(1, 'Day is required.'),
8
+ type: zod_1.z.string().min(1, 'Type is required.'),
9
+ time: zod_1.z.number().nonnegative('Time must be a non-negative number.'),
10
+ spendingType: zod_1.z.string().min(1, 'Spending Type is required.'),
11
+ cost: zod_1.z.number().nonnegative('Cost must be a non-negative number.')
12
+ });
@@ -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 @@
1
+ export {};
@@ -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,133 @@
1
+ //Common functions
2
+ export const COMMONS = {
3
+ WEEKDAY: {
4
+ Monday: 'Monday',
5
+ Tuesday: 'Tuesday',
6
+ Wednesday: 'Wednesday',
7
+ Thursday: 'Thursday',
8
+ Friday: 'Friday',
9
+ Saturday: 'Saturday',
10
+ Sunday: 'Sunday',
11
+ },
12
+ MONTH: {
13
+ January: 'January',
14
+ February: 'February',
15
+ March: 'March',
16
+ April: 'April',
17
+ May: 'May',
18
+ June: 'June',
19
+ July: 'July',
20
+ August: 'August',
21
+ September: 'September',
22
+ October: 'October',
23
+ November: 'November',
24
+ December: 'December',
25
+ },
26
+ BOOLEAN: {
27
+ Yes: 'Yes',
28
+ No: 'No',
29
+ },
30
+ };
31
+ export const COMMONS_ARRAYS = {
32
+ WEEKDAY: Object.values(COMMONS.WEEKDAY),
33
+ MONTH: Object.values(COMMONS.MONTH),
34
+ BOOLEAN: Object.values(COMMONS.BOOLEAN),
35
+ };
36
+ export const COLLECTION = {
37
+ matchplaySingles: "matchplaySingles",
38
+ matchplayDoubles: "matchplayDoubles",
39
+ opponent: "opponent",
40
+ performance: "performance",
41
+ player: "player",
42
+ spending: "spending",
43
+ trainingWeekly: "trainingWeekly",
44
+ training: "training",
45
+ tournament: "tournament",
46
+ };
47
+ export const CurrentMonth = new Date().toLocaleString('default', { month: 'long' });
48
+ export const CurrentYearMinus12 = new Date().getFullYear() - 12;
49
+ export const getMonthNameByOffset = (offset) => {
50
+ // Get the current date
51
+ const date = new Date();
52
+ // Set the date to the target month, accounting for the offset
53
+ date.setMonth(date.getMonth() - offset);
54
+ // Return the name of the target month
55
+ return date.toLocaleString('default', { month: 'long' });
56
+ };
57
+ export function getCurrentYear(date) {
58
+ const currentDate = date ? date : new Date();
59
+ return currentDate.getFullYear();
60
+ }
61
+ export const getCurrentMonthNumber = (date) => {
62
+ const currentDate = date ? date : new Date();
63
+ return currentDate.getMonth() + 1;
64
+ };
65
+ export const getMonthByName = (date) => {
66
+ const currentDate = date ? new Date(date) : new Date();
67
+ return COMMONS_ARRAYS.MONTH[currentDate.getMonth()];
68
+ };
69
+ export const getCurrentDateInDDMMYYYY = (date) => {
70
+ const day = String(date.getDate()).padStart(2, '0');
71
+ const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
72
+ const year = date.getFullYear();
73
+ return `${day}/${month}/${year}`;
74
+ };
75
+ export const getAgeGroup = (birthYear) => {
76
+ const currentYear = new Date().getFullYear();
77
+ const age = currentYear - birthYear;
78
+ if (age < 11) {
79
+ return `Under ${11}`;
80
+ }
81
+ else if (age >= 11 && age < 18) {
82
+ return `Under ${age}`;
83
+ }
84
+ else {
85
+ return 'Adult';
86
+ }
87
+ };
88
+ export const convertJsonToArray = (json, objectName, objectValue) => {
89
+ return Object.entries(json).map(([key, value]) => ({
90
+ [objectName]: key,
91
+ [objectValue]: value,
92
+ }));
93
+ };
94
+ export const normalizeKey = (key) => {
95
+ return key.toLowerCase().replace(/\s+/g, '-'); // Replace spaces with dashes
96
+ };
97
+ export const convertJsonToArrayWithTwoNumbers = (json, objectName, singlesKey, doublesKey) => {
98
+ return Object.entries(json).map(([key, value]) => ({
99
+ [objectName]: key,
100
+ [singlesKey]: value.singles,
101
+ [doublesKey]: value.doubles,
102
+ }));
103
+ };
104
+ export function convertToDate(dateInput) {
105
+ const parsedDate = new Date(dateInput);
106
+ // Fallback to the current date if the parsed date is invalid
107
+ if (isNaN(parsedDate.getTime())) {
108
+ console.warn("Invalid date input, returning current date.");
109
+ return new Date();
110
+ }
111
+ return parsedDate;
112
+ }
113
+ export function configDate(playerConfig) {
114
+ let parsedDate = new Date();
115
+ if (playerConfig.calendarUseToday === COMMONS.BOOLEAN.No) {
116
+ parsedDate = new Date(playerConfig.calendarDefaultDate);
117
+ //Fallback to the current date if the parsed date is invalid
118
+ if (isNaN(parsedDate.getTime())) {
119
+ console.warn("Invalid date input, returning current date.");
120
+ return new Date();
121
+ }
122
+ }
123
+ return parsedDate;
124
+ }
125
+ export function isValidPassword(password) {
126
+ const minLength = 8;
127
+ //const hasUpperCase = /[A-Z]/.test(password);
128
+ const hasLowerCase = /[a-z]/.test(password);
129
+ //const hasDigit = /\d/.test(password);
130
+ //const hasSpecialChar = /[\W_]/.test(password); // including symbols and underscores
131
+ return password.length >= minLength && hasLowerCase;
132
+ //return password.length >= minLength && hasUpperCase && hasLowerCase && hasDigit && hasSpecialChar;
133
+ }
@@ -0,0 +1,2 @@
1
+ export * from './generalInterfaces';
2
+ export * from './generalUtils';
@@ -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,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;