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,204 @@
1
+ import { z } from 'zod';
2
+ export declare const playerConfigSchema: z.ZodObject<{
3
+ theme: z.ZodString;
4
+ dataTableRows: z.ZodNumber;
5
+ budget: z.ZodNumber;
6
+ calendarUseToday: z.ZodEffects<z.ZodString, {
7
+ value: boolean;
8
+ error: null;
9
+ } | {
10
+ value: null;
11
+ error: string;
12
+ }, string>;
13
+ calendarDefaultDate: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
14
+ born: z.ZodNumber;
15
+ spendingCosts: z.ZodArray<z.ZodObject<{
16
+ category: z.ZodString;
17
+ cost: z.ZodNumber;
18
+ }, "strip", z.ZodTypeAny, {
19
+ cost: number;
20
+ category: string;
21
+ }, {
22
+ cost: number;
23
+ category: string;
24
+ }>, "atleastone">;
25
+ globalFilterTimeFrame: z.ZodString;
26
+ globalFilterSpecificYear: z.ZodNumber;
27
+ globalFilterSetFormat: z.ZodString;
28
+ globalFilterAgeGroup: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ born: number;
31
+ theme: string;
32
+ dataTableRows: number;
33
+ budget: number;
34
+ calendarUseToday: {
35
+ value: boolean;
36
+ error: null;
37
+ } | {
38
+ value: null;
39
+ error: string;
40
+ };
41
+ calendarDefaultDate: Date;
42
+ spendingCosts: [{
43
+ cost: number;
44
+ category: string;
45
+ }, ...{
46
+ cost: number;
47
+ category: string;
48
+ }[]];
49
+ globalFilterTimeFrame: string;
50
+ globalFilterSpecificYear: number;
51
+ globalFilterSetFormat: string;
52
+ globalFilterAgeGroup: string;
53
+ }, {
54
+ born: number;
55
+ theme: string;
56
+ dataTableRows: number;
57
+ budget: number;
58
+ calendarUseToday: string;
59
+ spendingCosts: [{
60
+ cost: number;
61
+ category: string;
62
+ }, ...{
63
+ cost: number;
64
+ category: string;
65
+ }[]];
66
+ globalFilterTimeFrame: string;
67
+ globalFilterSpecificYear: number;
68
+ globalFilterSetFormat: string;
69
+ globalFilterAgeGroup: string;
70
+ calendarDefaultDate?: unknown;
71
+ }>;
72
+ export declare const playerDataSchema: z.ZodObject<{
73
+ firstname: z.ZodString;
74
+ lastname: z.ZodString;
75
+ born: z.ZodNumber;
76
+ password: z.ZodOptional<z.ZodString>;
77
+ email: z.ZodString;
78
+ config: z.ZodObject<{
79
+ theme: z.ZodString;
80
+ dataTableRows: z.ZodNumber;
81
+ budget: z.ZodNumber;
82
+ calendarUseToday: z.ZodEffects<z.ZodString, {
83
+ value: boolean;
84
+ error: null;
85
+ } | {
86
+ value: null;
87
+ error: string;
88
+ }, string>;
89
+ calendarDefaultDate: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
90
+ born: z.ZodNumber;
91
+ spendingCosts: z.ZodArray<z.ZodObject<{
92
+ category: z.ZodString;
93
+ cost: z.ZodNumber;
94
+ }, "strip", z.ZodTypeAny, {
95
+ cost: number;
96
+ category: string;
97
+ }, {
98
+ cost: number;
99
+ category: string;
100
+ }>, "atleastone">;
101
+ globalFilterTimeFrame: z.ZodString;
102
+ globalFilterSpecificYear: z.ZodNumber;
103
+ globalFilterSetFormat: z.ZodString;
104
+ globalFilterAgeGroup: z.ZodString;
105
+ }, "strip", z.ZodTypeAny, {
106
+ born: number;
107
+ theme: string;
108
+ dataTableRows: number;
109
+ budget: number;
110
+ calendarUseToday: {
111
+ value: boolean;
112
+ error: null;
113
+ } | {
114
+ value: null;
115
+ error: string;
116
+ };
117
+ calendarDefaultDate: Date;
118
+ spendingCosts: [{
119
+ cost: number;
120
+ category: string;
121
+ }, ...{
122
+ cost: number;
123
+ category: string;
124
+ }[]];
125
+ globalFilterTimeFrame: string;
126
+ globalFilterSpecificYear: number;
127
+ globalFilterSetFormat: string;
128
+ globalFilterAgeGroup: string;
129
+ }, {
130
+ born: number;
131
+ theme: string;
132
+ dataTableRows: number;
133
+ budget: number;
134
+ calendarUseToday: string;
135
+ spendingCosts: [{
136
+ cost: number;
137
+ category: string;
138
+ }, ...{
139
+ cost: number;
140
+ category: string;
141
+ }[]];
142
+ globalFilterTimeFrame: string;
143
+ globalFilterSpecificYear: number;
144
+ globalFilterSetFormat: string;
145
+ globalFilterAgeGroup: string;
146
+ calendarDefaultDate?: unknown;
147
+ }>;
148
+ }, "strip", z.ZodTypeAny, {
149
+ email: string;
150
+ firstname: string;
151
+ lastname: string;
152
+ born: number;
153
+ config: {
154
+ born: number;
155
+ theme: string;
156
+ dataTableRows: number;
157
+ budget: number;
158
+ calendarUseToday: {
159
+ value: boolean;
160
+ error: null;
161
+ } | {
162
+ value: null;
163
+ error: string;
164
+ };
165
+ calendarDefaultDate: Date;
166
+ spendingCosts: [{
167
+ cost: number;
168
+ category: string;
169
+ }, ...{
170
+ cost: number;
171
+ category: string;
172
+ }[]];
173
+ globalFilterTimeFrame: string;
174
+ globalFilterSpecificYear: number;
175
+ globalFilterSetFormat: string;
176
+ globalFilterAgeGroup: string;
177
+ };
178
+ password?: string | undefined;
179
+ }, {
180
+ email: string;
181
+ firstname: string;
182
+ lastname: string;
183
+ born: number;
184
+ config: {
185
+ born: number;
186
+ theme: string;
187
+ dataTableRows: number;
188
+ budget: number;
189
+ calendarUseToday: string;
190
+ spendingCosts: [{
191
+ cost: number;
192
+ category: string;
193
+ }, ...{
194
+ cost: number;
195
+ category: string;
196
+ }[]];
197
+ globalFilterTimeFrame: string;
198
+ globalFilterSpecificYear: number;
199
+ globalFilterSetFormat: string;
200
+ globalFilterAgeGroup: string;
201
+ calendarDefaultDate?: unknown;
202
+ };
203
+ password?: string | undefined;
204
+ }>;
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ // Define schema for a single SpendingCost
3
+ const SpendingCostSchema = z.object({
4
+ category: z.string().min(1, 'Category is required.'),
5
+ cost: z.number().nonnegative('Cost must be a non-negative number.'),
6
+ });
7
+ //Add and Update Config
8
+ export const playerConfigSchema = z.object({
9
+ theme: z.string().min(1, 'Theme is required.'),
10
+ dataTableRows: z.number().nonnegative('Data Table Rows must be a non-negative number.'),
11
+ budget: z.number().nonnegative('Budget must be a non-negative number.'),
12
+ calendarUseToday: z.string().transform((val) => {
13
+ if (val === 'Yes')
14
+ return { value: true, error: null };
15
+ if (val === 'No')
16
+ return { value: false, error: null };
17
+ return { value: null, error: 'Invalid value; must be "Yes" or "No"' };
18
+ }),
19
+ calendarDefaultDate: z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
20
+ born: z.number().int().gte(1950, 'Year must be greater than 1950.'),
21
+ spendingCosts: z.array(SpendingCostSchema).nonempty('Spending Costs is required.'),
22
+ globalFilterTimeFrame: z.string().min(1, 'Global Filter Time Frame is required.'),
23
+ globalFilterSpecificYear: z.number().int().gte(1950, 'Year must be greater than 1950.'),
24
+ globalFilterSetFormat: z.string().min(1, 'Global Filter Set Format is required.'),
25
+ globalFilterAgeGroup: z.string().min(1, 'Global Filter Age Group is required.'),
26
+ });
27
+ //Add Config
28
+ export const playerDataSchema = z.object({
29
+ firstname: z.string().min(1, 'First name is required.'),
30
+ lastname: z.string().min(1, 'Last name is required.'),
31
+ born: z.number().int().gte(1950, 'Year must be greater than 1950.'),
32
+ password: z.string().optional(),
33
+ email: z.string().email('Invalid email address.'),
34
+ config: playerConfigSchema,
35
+ });
@@ -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,2 @@
1
+ import { SpendingItem } from './interfaces';
2
+ export declare function createInitialSpendingItem(playerId: string, date: Date): SpendingItem;
@@ -0,0 +1,12 @@
1
+ import { SPENDING } from './interfaces';
2
+ // Factory function for creating initial SpendingItem
3
+ export function createInitialSpendingItem(playerId, date) {
4
+ return {
5
+ _id: '',
6
+ playerId: playerId,
7
+ date: date,
8
+ type: SPENDING.TYPE.Tournament,
9
+ cost: 0,
10
+ linkedToTraining: false,
11
+ };
12
+ }
@@ -0,0 +1,2 @@
1
+ import { SpendingTotals } from './interfaces';
2
+ export declare const createDefaultSpendingTotal: (budget?: number) => SpendingTotals;
@@ -0,0 +1,25 @@
1
+ import { SPENDING_ARRAYS } from './interfaces';
2
+ import { COMMONS_ARRAYS } from '../general';
3
+ export const createDefaultSpendingTotal = (budget = 0) => {
4
+ const costPerType = {};
5
+ const costPerMonth = {};
6
+ const costPerMonthPerType = {};
7
+ SPENDING_ARRAYS.TYPE.forEach(type => (costPerType[type] = 0));
8
+ COMMONS_ARRAYS.MONTH.forEach(month => {
9
+ costPerMonth[month] = 0;
10
+ costPerMonthPerType[month] = {};
11
+ SPENDING_ARRAYS.TYPE.forEach(type => {
12
+ costPerMonthPerType[month][type] = 0;
13
+ });
14
+ });
15
+ return {
16
+ totalCost: 0,
17
+ budget,
18
+ budgetRemaining: budget,
19
+ costPerType,
20
+ costPerMonth,
21
+ costPerMonthPerType,
22
+ totalCostLastMonth: 0,
23
+ averageSpendingPerMonth: 0
24
+ };
25
+ };
@@ -0,0 +1,2 @@
1
+ import { SpendingTotals } from './interfaces';
2
+ export declare const createDefaultSpendingTotal: (budget?: number) => SpendingTotals;
@@ -0,0 +1,25 @@
1
+ import { SPENDING_ARRAYS } from './interfaces';
2
+ import { COMMONS_ARRAYS } from '../general';
3
+ export const createDefaultSpendingTotal = (budget = 0) => {
4
+ const costPerType = {};
5
+ const costPerMonth = {};
6
+ const costPerMonthPerType = {};
7
+ SPENDING_ARRAYS.TYPE.forEach(type => (costPerType[type] = 0));
8
+ COMMONS_ARRAYS.MONTH.forEach(month => {
9
+ costPerMonth[month] = 0;
10
+ costPerMonthPerType[month] = {};
11
+ SPENDING_ARRAYS.TYPE.forEach(type => {
12
+ costPerMonthPerType[month][type] = 0;
13
+ });
14
+ });
15
+ return {
16
+ totalCost: 0,
17
+ budget,
18
+ budgetRemaining: budget,
19
+ costPerType,
20
+ costPerMonth,
21
+ costPerMonthPerType,
22
+ totalCostLastMonth: 0,
23
+ averageSpendingPerMonth: 0
24
+ };
25
+ };
@@ -0,0 +1,61 @@
1
+ import { ValueOf } from '../general';
2
+ export declare const SPENDING: {
3
+ readonly TYPE: {
4
+ readonly None: "None";
5
+ readonly Tournament: "Tournament";
6
+ readonly Accommodation: "Accommodation";
7
+ readonly Equipment: "Equipment";
8
+ readonly Strings: "Strings";
9
+ readonly CourtHire: "Court Hire";
10
+ readonly Hit: "Hit";
11
+ readonly Gym: "Gym";
12
+ readonly Squad: "Squad";
13
+ readonly Lesson: "Lesson";
14
+ readonly Physical: "Physical";
15
+ readonly Physio: "Physio";
16
+ readonly Membership: "Membership";
17
+ };
18
+ };
19
+ export declare const createInitialSpendingCosts: () => {
20
+ category: string;
21
+ cost: number;
22
+ }[];
23
+ export type SPENDING_TYPE_UNION = ValueOf<typeof SPENDING.TYPE>;
24
+ export declare const SPENDING_ARRAYS: {
25
+ TYPE: SPENDING_TYPE_UNION[];
26
+ };
27
+ export interface SpendingItem {
28
+ _id: string;
29
+ playerId: string;
30
+ date: Date;
31
+ type: SPENDING_TYPE_UNION;
32
+ cost: number;
33
+ linkedToTraining: boolean;
34
+ }
35
+ export interface SpendingTotals {
36
+ totalCost: number;
37
+ totalCostLastMonth: number;
38
+ averageSpendingPerMonth: number;
39
+ budget: number;
40
+ budgetRemaining: number;
41
+ costPerType: {
42
+ [type: string]: number;
43
+ };
44
+ costPerMonth: {
45
+ [month: string]: number;
46
+ };
47
+ costPerMonthPerType: {
48
+ [month: string]: {
49
+ [type: string]: number;
50
+ };
51
+ };
52
+ }
53
+ export interface MonthlyCostPerType {
54
+ [month: string]: {
55
+ [type: string]: number;
56
+ };
57
+ }
58
+ export interface SpendingCosts {
59
+ category: string;
60
+ cost: number;
61
+ }
@@ -0,0 +1,37 @@
1
+ export const SPENDING = {
2
+ TYPE: {
3
+ None: 'None',
4
+ Tournament: 'Tournament',
5
+ Accommodation: 'Accommodation',
6
+ Equipment: 'Equipment',
7
+ Strings: 'Strings',
8
+ CourtHire: 'Court Hire',
9
+ Hit: 'Hit',
10
+ Gym: 'Gym',
11
+ Squad: 'Squad',
12
+ Lesson: 'Lesson',
13
+ Physical: 'Physical',
14
+ Physio: 'Physio',
15
+ Membership: 'Membership',
16
+ },
17
+ };
18
+ export const createInitialSpendingCosts = () => {
19
+ return [
20
+ { category: 'None', cost: 0 },
21
+ { category: 'Tournament', cost: 50 },
22
+ { category: 'Accommodation', cost: 175 },
23
+ { category: 'Equipment', cost: 100 },
24
+ { category: 'Strings', cost: 40 },
25
+ { category: 'Court Hire', cost: 7.5 },
26
+ { category: 'Hit', cost: 15 },
27
+ { category: 'Gym', cost: 25 },
28
+ { category: 'Squad', cost: 0 },
29
+ { category: 'Lesson', cost: 35 },
30
+ { category: 'Physical', cost: 30 },
31
+ { category: 'Physio', cost: 55 },
32
+ { category: 'Membership', cost: 120 }
33
+ ];
34
+ };
35
+ export const SPENDING_ARRAYS = {
36
+ TYPE: Object.values(SPENDING.TYPE),
37
+ };
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ export declare const spendingItemSchema: z.ZodObject<{
3
+ playerId: z.ZodString;
4
+ date: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
5
+ type: z.ZodEffects<z.ZodString, string, string>;
6
+ cost: z.ZodNumber;
7
+ linkedToTraining: z.ZodBoolean;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: string;
10
+ date: Date;
11
+ playerId: string;
12
+ cost: number;
13
+ linkedToTraining: boolean;
14
+ }, {
15
+ type: string;
16
+ playerId: string;
17
+ cost: number;
18
+ linkedToTraining: boolean;
19
+ date?: unknown;
20
+ }>;
21
+ export declare const spendingItemSchemaFromTraining: z.ZodObject<{
22
+ playerId: z.ZodString;
23
+ date: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, unknown>;
24
+ type: z.ZodString;
25
+ cost: z.ZodNumber;
26
+ linkedToTraining: z.ZodBoolean;
27
+ }, "strip", z.ZodTypeAny, {
28
+ type: string;
29
+ date: Date;
30
+ playerId: string;
31
+ cost: number;
32
+ linkedToTraining: boolean;
33
+ }, {
34
+ type: string;
35
+ playerId: string;
36
+ cost: number;
37
+ linkedToTraining: boolean;
38
+ date?: unknown;
39
+ }>;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { SPENDING } from './interfaces';
3
+ // Add spending to
4
+ export const spendingItemSchema = z.object({
5
+ playerId: z.string().min(1, 'PlayerId is required.'),
6
+ date: z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
7
+ type: z.string().min(1, 'Type is required.').refine(value => value !== SPENDING.TYPE.None, {
8
+ message: 'Type cannot be "None".',
9
+ }),
10
+ cost: z.number().gt(0, 'Cost must be greater than zero.'),
11
+ linkedToTraining: z.boolean(),
12
+ });
13
+ export const spendingItemSchemaFromTraining = z.object({
14
+ playerId: z.string().min(1, 'PlayerId is required.'),
15
+ date: z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
16
+ type: z.string().min(1, 'Type is required.'),
17
+ cost: z.number(),
18
+ linkedToTraining: z.boolean(),
19
+ });
@@ -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,3 @@
1
+ import { TournamentItem, TournamentYearItem } from './interfaces';
2
+ export declare function createInitialTournamentYearItem(date: Date): TournamentYearItem;
3
+ export declare function createInitialTournamentItem(playerId: string): TournamentItem;
@@ -0,0 +1,23 @@
1
+ import { COMMONS } from '../general';
2
+ import { TOURNAMENT } from './interfaces';
3
+ // Factory function for creating initial TournamentYearItem
4
+ export function createInitialTournamentYearItem(date) {
5
+ return {
6
+ yearId: '',
7
+ year: date.getFullYear(),
8
+ date: date,
9
+ category: TOURNAMENT.CATEGORY.T500,
10
+ show: COMMONS.BOOLEAN.Yes,
11
+ comment: '',
12
+ };
13
+ }
14
+ // Factory function for creating initial TournamentItem
15
+ export function createInitialTournamentItem(playerId) {
16
+ return {
17
+ _id: '',
18
+ playerId: playerId,
19
+ name: '',
20
+ type: TOURNAMENT.TYPE.TennisIreland,
21
+ tournamentYears: [], // Alternatively, you can use [createInitialTournamentYearItem()] if you need to initialize with a default year item
22
+ };
23
+ }
@@ -0,0 +1,43 @@
1
+ import { BOOLEAN_UNION } from '../general';
2
+ import { ValueOf } from '../general';
3
+ export declare const TOURNAMENT: {
4
+ readonly TYPE: {
5
+ readonly TennisIreland: "Tennis Ireland";
6
+ readonly TennisEuropean: "Tennis European";
7
+ readonly BelfastAndDistrictLeague: "Belfast And District League";
8
+ };
9
+ readonly CATEGORY: {
10
+ readonly WTN: "WTN Only";
11
+ readonly T100: "T100";
12
+ readonly T200: "T200";
13
+ readonly T500: "T500";
14
+ readonly T1000: "T1000";
15
+ readonly T1250: "T1250";
16
+ readonly T1500: "T1500";
17
+ readonly T2000: "T2000";
18
+ readonly EuropeC1: "Europe C1";
19
+ readonly EuropeC2: "Europe C2";
20
+ readonly EuropeC3: "Europe C3";
21
+ };
22
+ };
23
+ export type TOURNAMENT_TYPE_UNION = ValueOf<typeof TOURNAMENT.TYPE>;
24
+ export type TOURNAMENT_CATEGORY_UNION = ValueOf<typeof TOURNAMENT.CATEGORY>;
25
+ export declare const TOURNAMENT_ARRAYS: {
26
+ TYPE: TOURNAMENT_TYPE_UNION[];
27
+ CATEGORY: TOURNAMENT_CATEGORY_UNION[];
28
+ };
29
+ export interface TournamentItem {
30
+ _id: string;
31
+ playerId: string;
32
+ name: string;
33
+ type: TOURNAMENT_TYPE_UNION;
34
+ tournamentYears: TournamentYearItem[];
35
+ }
36
+ export interface TournamentYearItem {
37
+ yearId: string;
38
+ year: number;
39
+ date: Date;
40
+ category: TOURNAMENT_CATEGORY_UNION;
41
+ show: BOOLEAN_UNION;
42
+ comment: string;
43
+ }
@@ -0,0 +1,24 @@
1
+ export const TOURNAMENT = {
2
+ TYPE: {
3
+ TennisIreland: 'Tennis Ireland',
4
+ TennisEuropean: 'Tennis European',
5
+ BelfastAndDistrictLeague: 'Belfast And District League',
6
+ },
7
+ CATEGORY: {
8
+ WTN: 'WTN Only',
9
+ T100: 'T100',
10
+ T200: 'T200',
11
+ T500: 'T500',
12
+ T1000: 'T1000',
13
+ T1250: 'T1250',
14
+ T1500: 'T1500',
15
+ T2000: 'T2000',
16
+ EuropeC1: 'Europe C1',
17
+ EuropeC2: 'Europe C2',
18
+ EuropeC3: 'Europe C3',
19
+ },
20
+ };
21
+ export const TOURNAMENT_ARRAYS = {
22
+ TYPE: Object.values(TOURNAMENT.TYPE),
23
+ CATEGORY: Object.values(TOURNAMENT.CATEGORY),
24
+ };
@@ -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,22 @@
1
+ import { z } from 'zod';
2
+ // Add a tournament year to Year array
3
+ export const tournamentYearItemSchema = z.object({
4
+ year: z.number().int().gte(1950, 'Year must be greater than 1950.'),
5
+ date: z.preprocess((arg) => (typeof arg === 'string' || arg instanceof Date ? new Date(arg) : undefined), z.date().refine(date => !isNaN(date.getTime()), 'Invalid date.')),
6
+ category: z.string().min(1, 'Category is required.'),
7
+ show: z.string().min(1, 'Show is required.'),
8
+ comment: z.string()
9
+ });
10
+ // Add a tournament to . Array must be empty with a new tournament record
11
+ export const tournamentItemSchema = z.object({
12
+ playerId: z.string().min(1, 'PlayerId is required.'),
13
+ name: z.string().min(1, 'Name is required.'),
14
+ type: z.string().min(1, 'Type is required.'),
15
+ tournamentYears: z.array(z.any()).length(0, 'Year must be an empty array.'),
16
+ });
17
+ // Update a tournament to . Array will be undefined as this is for a partial update
18
+ export const tournamentPartialItemSchema = z.object({
19
+ playerId: z.string().min(1, 'PlayerId is required.'),
20
+ name: z.string().min(1, 'Name is required.'),
21
+ type: z.string().min(1, 'Type is required.'),
22
+ });
@@ -0,0 +1,4 @@
1
+ export * from './interfaces';
2
+ export * from './initialData';
3
+ export * from './initialStats';
4
+ export * from './validation';