@stevenkellner/team-conduct-api 2.0.18 → 2.0.20

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 (231) hide show
  1. package/lib/src/functions/fine/add.d.ts +3 -8
  2. package/lib/src/functions/fine/add.js +1 -2
  3. package/lib/src/functions/fine/delete.d.ts +1 -6
  4. package/lib/src/functions/fine/delete.js +2 -3
  5. package/lib/src/functions/fine/update.d.ts +2 -8
  6. package/lib/src/functions/fine/update.js +1 -3
  7. package/lib/src/functions/fineTemplate/add.d.ts +3 -3
  8. package/lib/src/functions/fineTemplate/update.d.ts +3 -3
  9. package/lib/src/functions/firebaseFunctionsContext.d.ts +34 -1
  10. package/lib/src/functions/firebaseFunctionsContext.js +33 -33
  11. package/lib/src/functions/index.d.ts +10 -8
  12. package/lib/src/functions/index.js +11 -8
  13. package/lib/src/functions/notification/markNotificationAsRead.d.ts +14 -0
  14. package/lib/src/functions/notification/{subscribe.js → markNotificationAsRead.js} +5 -7
  15. package/lib/src/functions/person/kickout.d.ts +6 -6
  16. package/lib/src/functions/person/kickout.js +4 -4
  17. package/lib/src/functions/person/roleEdit.d.ts +5 -5
  18. package/lib/src/functions/person/roleEdit.js +3 -3
  19. package/lib/src/functions/{paypalMe/edit.d.ts → team/delete.d.ts} +5 -7
  20. package/lib/src/functions/{paypalMe/edit.js → team/delete.js} +4 -5
  21. package/lib/src/functions/team/new.d.ts +18 -18
  22. package/lib/src/functions/team/new.js +8 -4
  23. package/lib/src/functions/team/update.d.ts +34 -0
  24. package/lib/src/functions/team/update.js +23 -0
  25. package/lib/src/functions/user/register.d.ts +4 -0
  26. package/lib/src/functions/user/register.js +3 -1
  27. package/lib/src/functions/user/update.d.ts +26 -0
  28. package/lib/src/functions/user/update.js +15 -0
  29. package/lib/src/index.d.ts +1 -1
  30. package/lib/src/index.js +1 -1
  31. package/lib/src/locales/de.d.ts +1 -1
  32. package/lib/src/locales/de.js +6 -2
  33. package/lib/src/locales/en.d.ts +6 -2
  34. package/lib/src/locales/en.js +6 -2
  35. package/lib/src/types/{MoneyAmount.d.ts → Money.d.ts} +23 -23
  36. package/lib/src/types/{MoneyAmount.js → Money.js} +25 -25
  37. package/lib/src/types/fine/Fine.d.ts +275 -0
  38. package/lib/src/types/fine/Fine.js +318 -0
  39. package/lib/src/types/fine/FineTemplate.d.ts +154 -0
  40. package/lib/src/types/fine/FineTemplate.js +170 -0
  41. package/lib/src/types/{PayedState.d.ts → fine/PayedState.d.ts} +1 -1
  42. package/lib/src/types/{PayedState.js → fine/PayedState.js} +1 -1
  43. package/lib/src/types/fine/index.d.ts +3 -0
  44. package/lib/src/{firebase → types/fine}/index.js +3 -6
  45. package/lib/src/types/index.d.ts +7 -18
  46. package/lib/src/types/index.js +7 -18
  47. package/lib/src/types/{Localization.d.ts → localization/Localization.d.ts} +15 -43
  48. package/lib/src/types/localization/Localization.js +54 -0
  49. package/lib/src/types/localization/PluralLocalization.d.ts +23 -0
  50. package/lib/src/types/localization/PluralLocalization.js +35 -0
  51. package/lib/src/types/{Pluralization.d.ts → localization/Pluralization.d.ts} +1 -0
  52. package/lib/src/types/{Pluralization.js → localization/Pluralization.js} +1 -0
  53. package/lib/src/types/localization/ValueLocalization.d.ts +22 -0
  54. package/lib/src/types/localization/ValueLocalization.js +41 -0
  55. package/lib/src/types/localization/index.d.ts +5 -0
  56. package/lib/src/types/localization/index.js +21 -0
  57. package/lib/src/types/notification/InAppNotification.d.ts +152 -0
  58. package/lib/src/types/notification/InAppNotification.js +136 -0
  59. package/lib/src/types/notification/index.d.ts +1 -0
  60. package/lib/src/types/notification/index.js +17 -0
  61. package/lib/src/types/{Person.d.ts → person/Person.d.ts} +3 -3
  62. package/lib/src/types/{Person.js → person/Person.js} +3 -3
  63. package/lib/src/types/{PersonProperties.d.ts → person/PersonProperties.d.ts} +8 -7
  64. package/lib/src/types/{PersonProperties.js → person/PersonProperties.js} +7 -6
  65. package/lib/src/types/{PersonSignInProperties.d.ts → person/PersonSignInProperties.d.ts} +9 -11
  66. package/lib/src/types/{PersonSignInProperties.js → person/PersonSignInProperties.js} +7 -10
  67. package/lib/src/types/person/index.d.ts +3 -0
  68. package/lib/src/types/person/index.js +19 -0
  69. package/lib/src/types/{Invitation.d.ts → team/Invitation.d.ts} +1 -1
  70. package/lib/src/types/{Invitation.js → team/Invitation.js} +1 -1
  71. package/lib/src/types/team/Team.d.ts +144 -0
  72. package/lib/src/types/team/Team.js +141 -0
  73. package/lib/src/types/team/TeamRole.d.ts +30 -0
  74. package/lib/src/types/{UserRole.js → team/TeamRole.js} +16 -15
  75. package/lib/src/types/team/index.d.ts +3 -0
  76. package/lib/src/types/team/index.js +19 -0
  77. package/lib/src/types/{NotificationProperties.d.ts → user/NotificationProperties.d.ts} +8 -3
  78. package/lib/src/types/{NotificationProperties.js → user/NotificationProperties.js} +4 -0
  79. package/lib/src/types/user/User.d.ts +328 -0
  80. package/lib/src/types/user/User.js +355 -0
  81. package/lib/src/types/user/index.d.ts +2 -0
  82. package/lib/src/types/user/index.js +18 -0
  83. package/lib/src/utils/StaticUnionTypeBuilder.d.ts +9 -0
  84. package/lib/src/utils/StaticUnionTypeBuilder.js +23 -0
  85. package/lib/src/utils/index.d.ts +1 -0
  86. package/lib/src/utils/index.js +17 -0
  87. package/lib/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +4 -3
  89. package/src/functions/fine/add.ts +3 -5
  90. package/src/functions/fine/delete.ts +3 -5
  91. package/src/functions/fine/update.ts +2 -5
  92. package/src/functions/firebaseFunctionsContext.ts +40 -40
  93. package/src/functions/index.ts +11 -9
  94. package/src/functions/notification/markNotificationAsRead.ts +19 -0
  95. package/src/functions/person/add.ts +1 -1
  96. package/src/functions/person/kickout.ts +6 -6
  97. package/src/functions/person/roleEdit.ts +5 -5
  98. package/src/functions/{paypalMe/edit.ts → team/delete.ts} +5 -7
  99. package/src/functions/team/new.ts +19 -11
  100. package/src/functions/team/update.ts +40 -0
  101. package/src/functions/user/register.ts +7 -3
  102. package/src/functions/user/update.ts +29 -0
  103. package/src/index.ts +1 -1
  104. package/src/locales/de.ts +7 -3
  105. package/src/locales/en.ts +7 -3
  106. package/src/types/{MoneyAmount.ts → Money.ts} +29 -29
  107. package/src/types/fine/Fine.ts +399 -0
  108. package/src/types/fine/FineTemplate.ts +219 -0
  109. package/src/types/{PayedState.ts → fine/PayedState.ts} +2 -2
  110. package/src/types/fine/index.ts +3 -0
  111. package/src/types/index.ts +7 -18
  112. package/src/types/{Localization.ts → localization/Localization.ts} +7 -64
  113. package/src/types/localization/PluralLocalization.ts +32 -0
  114. package/src/types/{Pluralization.ts → localization/Pluralization.ts} +1 -0
  115. package/src/types/localization/ValueLocalization.ts +36 -0
  116. package/src/types/localization/index.ts +5 -0
  117. package/src/types/notification/InAppNotification.ts +184 -0
  118. package/src/types/notification/index.ts +1 -0
  119. package/src/types/{Person.ts → person/Person.ts} +3 -3
  120. package/src/types/{PersonProperties.ts → person/PersonProperties.ts} +8 -7
  121. package/src/types/{PersonSignInProperties.ts → person/PersonSignInProperties.ts} +13 -12
  122. package/src/types/person/index.ts +3 -0
  123. package/src/types/{Invitation.ts → team/Invitation.ts} +1 -1
  124. package/src/types/team/Team.ts +204 -0
  125. package/src/types/{UserRole.ts → team/TeamRole.ts} +19 -17
  126. package/src/types/team/index.ts +3 -0
  127. package/src/types/{NotificationProperties.ts → user/NotificationProperties.ts} +12 -3
  128. package/src/types/user/User.ts +451 -0
  129. package/src/types/user/index.ts +2 -0
  130. package/src/utils/StaticUnionTypeBuilder.ts +23 -0
  131. package/src/utils/index.ts +1 -0
  132. package/lib/src/firebase/FirebaseConfiguration.d.ts +0 -64
  133. package/lib/src/firebase/FirebaseConfiguration.js +0 -79
  134. package/lib/src/firebase/Firestore.d.ts +0 -201
  135. package/lib/src/firebase/Firestore.js +0 -244
  136. package/lib/src/firebase/FirestoreScheme.d.ts +0 -42
  137. package/lib/src/firebase/FirestoreScheme.js +0 -2
  138. package/lib/src/firebase/Messaging.d.ts +0 -90
  139. package/lib/src/firebase/Messaging.js +0 -2
  140. package/lib/src/firebase/checkAuthentication.d.ts +0 -38
  141. package/lib/src/firebase/checkAuthentication.js +0 -64
  142. package/lib/src/firebase/index.d.ts +0 -6
  143. package/lib/src/firebase/pushNotification.d.ts +0 -39
  144. package/lib/src/firebase/pushNotification.js +0 -88
  145. package/lib/src/functions/notification/subscribe.d.ts +0 -18
  146. package/lib/src/types/Configuration.d.ts +0 -46
  147. package/lib/src/types/Configuration.js +0 -51
  148. package/lib/src/types/Fine.d.ts +0 -71
  149. package/lib/src/types/Fine.js +0 -74
  150. package/lib/src/types/FineAmount.d.ts +0 -207
  151. package/lib/src/types/FineAmount.js +0 -238
  152. package/lib/src/types/FineTemplate.d.ts +0 -69
  153. package/lib/src/types/FineTemplate.js +0 -72
  154. package/lib/src/types/FineTemplateRepetition.d.ts +0 -87
  155. package/lib/src/types/FineTemplateRepetition.js +0 -103
  156. package/lib/src/types/Localization.js +0 -115
  157. package/lib/src/types/Team.d.ts +0 -62
  158. package/lib/src/types/Team.js +0 -64
  159. package/lib/src/types/User.d.ts +0 -221
  160. package/lib/src/types/User.js +0 -235
  161. package/lib/src/types/UserRole.d.ts +0 -29
  162. package/lib/test/firebase/FirebaseConfiguration.test.d.ts +0 -1
  163. package/lib/test/firebase/FirebaseConfiguration.test.js +0 -158
  164. package/lib/test/firebase/Firestore.test.d.ts +0 -1
  165. package/lib/test/firebase/Firestore.test.js +0 -46
  166. package/lib/test/firebase/checkAuthentication.test.d.ts +0 -1
  167. package/lib/test/firebase/checkAuthentication.test.js +0 -356
  168. package/lib/test/firebase/firebase-utils.d.ts +0 -32
  169. package/lib/test/firebase/firebase-utils.js +0 -134
  170. package/lib/test/firebase/pushNotification.test.d.ts +0 -1
  171. package/lib/test/firebase/pushNotification.test.js +0 -300
  172. package/lib/test/locales/localization.de.test.d.ts +0 -1
  173. package/lib/test/locales/localization.de.test.js +0 -144
  174. package/lib/test/locales/localization.en.test.d.ts +0 -1
  175. package/lib/test/locales/localization.en.test.js +0 -144
  176. package/lib/test/types/Configuration.test.d.ts +0 -1
  177. package/lib/test/types/Configuration.test.js +0 -84
  178. package/lib/test/types/Currency.test.d.ts +0 -1
  179. package/lib/test/types/Currency.test.js +0 -41
  180. package/lib/test/types/Fine.test.d.ts +0 -1
  181. package/lib/test/types/Fine.test.js +0 -265
  182. package/lib/test/types/FineAmount.test.d.ts +0 -1
  183. package/lib/test/types/FineAmount.test.js +0 -445
  184. package/lib/test/types/FineTemplate.test.d.ts +0 -1
  185. package/lib/test/types/FineTemplate.test.js +0 -271
  186. package/lib/test/types/FineTemplateRepetition.test.d.ts +0 -1
  187. package/lib/test/types/FineTemplateRepetition.test.js +0 -361
  188. package/lib/test/types/Invitation.test.d.ts +0 -1
  189. package/lib/test/types/Invitation.test.js +0 -269
  190. package/lib/test/types/Locale.test.d.ts +0 -1
  191. package/lib/test/types/Locale.test.js +0 -46
  192. package/lib/test/types/Localization.test.d.ts +0 -1
  193. package/lib/test/types/Localization.test.js +0 -241
  194. package/lib/test/types/MoneyAmount.test.d.ts +0 -1
  195. package/lib/test/types/MoneyAmount.test.js +0 -276
  196. package/lib/test/types/NotificationProperties.test.d.ts +0 -1
  197. package/lib/test/types/NotificationProperties.test.js +0 -258
  198. package/lib/test/types/PayedState.test.d.ts +0 -1
  199. package/lib/test/types/PayedState.test.js +0 -136
  200. package/lib/test/types/Person.test.d.ts +0 -1
  201. package/lib/test/types/Person.test.js +0 -266
  202. package/lib/test/types/PersonProperties.test.d.ts +0 -1
  203. package/lib/test/types/PersonProperties.test.js +0 -155
  204. package/lib/test/types/PersonSignInProperties.test.d.ts +0 -1
  205. package/lib/test/types/PersonSignInProperties.test.js +0 -208
  206. package/lib/test/types/Pluralization.test.d.ts +0 -1
  207. package/lib/test/types/Pluralization.test.js +0 -206
  208. package/lib/test/types/Team.test.d.ts +0 -1
  209. package/lib/test/types/Team.test.js +0 -145
  210. package/lib/test/types/User.test.d.ts +0 -1
  211. package/lib/test/types/User.test.js +0 -450
  212. package/lib/test/types/UserRole.test.d.ts +0 -1
  213. package/lib/test/types/UserRole.test.js +0 -140
  214. package/src/firebase/FirebaseConfiguration.ts +0 -99
  215. package/src/firebase/Firestore.ts +0 -258
  216. package/src/firebase/FirestoreScheme.ts +0 -41
  217. package/src/firebase/Messaging.ts +0 -93
  218. package/src/firebase/checkAuthentication.ts +0 -91
  219. package/src/firebase/index.ts +0 -7
  220. package/src/firebase/pushNotification.ts +0 -90
  221. package/src/functions/notification/subscribe.ts +0 -23
  222. package/src/types/Configuration.ts +0 -65
  223. package/src/types/Fine.ts +0 -100
  224. package/src/types/FineAmount.ts +0 -303
  225. package/src/types/FineTemplate.ts +0 -96
  226. package/src/types/FineTemplateRepetition.ts +0 -125
  227. package/src/types/Team.ts +0 -87
  228. package/src/types/User.ts +0 -302
  229. /package/lib/src/types/{Locale.d.ts → localization/Locale.d.ts} +0 -0
  230. /package/lib/src/types/{Locale.js → localization/Locale.js} +0 -0
  231. /package/src/types/{Locale.ts → localization/Locale.ts} +0 -0
@@ -0,0 +1,219 @@
1
+ import { Flattable, Guid, ITypeBuilder, Tagged, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+ import { Fine } from './Fine';
3
+ import { Localization } from '../localization/Localization';
4
+ import { Locale } from '../localization/Locale';
5
+
6
+ /**
7
+ * Represents a template for creating fines with predefined reason, amount, and optional repetition rules.
8
+ *
9
+ * Fine templates allow teams to quickly create recurring or standard fines without entering
10
+ * the same information repeatedly.
11
+ */
12
+ export class FineTemplate implements Flattable<FineTemplate.Flatten> {
13
+
14
+ /**
15
+ * Creates a new FineTemplate instance.
16
+ *
17
+ * @param id - Unique identifier for the fine template (GUID)
18
+ * @param reason - The reason or description for the fine
19
+ * @param amount - The monetary or item-based amount of the fine
20
+ * @param repetition - Optional repetition rules (null for non-recurring templates)
21
+ */
22
+ public constructor(
23
+ public id: FineTemplate.Id,
24
+ public reason: string,
25
+ public amount: Fine.Amount,
26
+ public repetition: FineTemplate.Repetition | null
27
+ ) {}
28
+
29
+ /**
30
+ * Returns the flattened representation for serialization.
31
+ */
32
+ public get flatten(): FineTemplate.Flatten {
33
+ return {
34
+ id: this.id.flatten,
35
+ reason: this.reason,
36
+ amount: this.amount.flatten,
37
+ repetition: this.repetition === null ? null : this.repetition.flatten
38
+ };
39
+ }
40
+ }
41
+
42
+ export namespace FineTemplate {
43
+
44
+ /**
45
+ * Tagged GUID type for fine template identifiers.
46
+ */
47
+ export type Id = Tagged<Guid, 'fineTemplate'>;
48
+
49
+ export namespace Id {
50
+
51
+ /**
52
+ * Flattened representation of a fine template ID (GUID string).
53
+ */
54
+ export type Flatten = string;
55
+
56
+ /**
57
+ * Type builder for FineTemplate.Id serialization/deserialization.
58
+ */
59
+ export const builder = Tagged.builder('fineTemplate' as const, Guid.builder);
60
+ }
61
+
62
+ /**
63
+ * Represents how a fine template repeats over time.
64
+ *
65
+ * Defines the repetition unit (minute, day, item, count) and optional maximum count for repetitions.
66
+ */
67
+ export class Repetition implements Flattable<Repetition.Flatten> {
68
+
69
+ /**
70
+ * Creates a new Repetition instance.
71
+ *
72
+ * @param item - The repetition unit type (minute, day, item, count)
73
+ * @param maxCount - Optional maximum number of repetitions (null for unlimited)
74
+ */
75
+ public constructor(
76
+ public item: Repetition.Item,
77
+ public maxCount: number | null
78
+ ) {}
79
+
80
+ /**
81
+ * Returns a localized formatted string including the count value.
82
+ *
83
+ * @param count - The number of repetitions
84
+ * @param locale - The locale to use for formatting
85
+ * @returns Formatted string (e.g., "every 5 minutes")
86
+ */
87
+ public formatted(count: number, locale: Locale): string {
88
+ return Localization.shared(locale).fineTemplateRepetition.item[this.item].withCount.value(count);
89
+ }
90
+
91
+ /**
92
+ * Returns a localized formatted string without explicitly showing the count.
93
+ *
94
+ * @param count - The number of repetitions
95
+ * @param locale - The locale to use for formatting
96
+ * @returns Formatted string without count display
97
+ */
98
+ public formattedWithoutCount(count: number, locale: Locale): string {
99
+ return Localization.shared(locale).fineTemplateRepetition.item[this.item].withoutCount.value(count);
100
+ }
101
+
102
+ /**
103
+ * Returns the flattened representation for serialization.
104
+ */
105
+ public get flatten(): Repetition.Flatten {
106
+ return {
107
+ item: this.item,
108
+ maxCount: this.maxCount
109
+ };
110
+ }
111
+ }
112
+
113
+ export namespace Repetition {
114
+
115
+ const repetitionItems = [
116
+ 'minute',
117
+ 'day',
118
+ 'item',
119
+ 'count'
120
+ ] as const;
121
+
122
+ /**
123
+ * Repetition unit type: 'minute', 'day', 'item', or 'count'.
124
+ */
125
+ export type Item = typeof repetitionItems[number];
126
+
127
+ export namespace Item {
128
+
129
+ /**
130
+ * Array containing all possible repetition item types.
131
+ */
132
+ export const all: readonly Item[] = repetitionItems;
133
+
134
+ /**
135
+ * Returns the localized name for a repetition item type.
136
+ *
137
+ * @param item - The repetition item type
138
+ * @param locale - The locale to use for formatting
139
+ * @returns Localized name string
140
+ */
141
+ export function formatted(item: Item, locale: Locale): string {
142
+ return Localization.shared(locale).fineTemplateRepetition.item[item].name.value();
143
+ }
144
+
145
+ /**
146
+ * Type builder for Item serialization/deserialization.
147
+ */
148
+ export const builder = new ValueTypeBuilder<Item>();
149
+ }
150
+
151
+ /**
152
+ * Flattened representation of Repetition for serialization.
153
+ */
154
+ export type Flatten = {
155
+ item: Item,
156
+ maxCount: number | null
157
+ }
158
+
159
+ /**
160
+ * Type builder for Repetition serialization/deserialization.
161
+ */
162
+ export class TypeBuilder implements ITypeBuilder<Flatten, Repetition> {
163
+
164
+ /**
165
+ * Builds a Repetition instance from flattened data.
166
+ *
167
+ * @param flatten - Flattened repetition data
168
+ * @returns Repetition instance
169
+ */
170
+ public build(flatten: Flatten): Repetition {
171
+ return new Repetition(
172
+ flatten.item,
173
+ flatten.maxCount
174
+ );
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Singleton instance of TypeBuilder for Repetition.
180
+ */
181
+ export const builder = new TypeBuilder();
182
+ }
183
+
184
+ /**
185
+ * Flattened representation of a FineTemplate for serialization.
186
+ */
187
+ export type Flatten = {
188
+ id: Id.Flatten,
189
+ reason: string,
190
+ amount: Fine.Amount.Flatten,
191
+ repetition: Repetition.Flatten | null
192
+ };
193
+
194
+ /**
195
+ * Type builder for FineTemplate serialization/deserialization.
196
+ */
197
+ export class TypeBuilder implements ITypeBuilder<Flatten, FineTemplate> {
198
+
199
+ /**
200
+ * Builds a FineTemplate instance from flattened data.
201
+ *
202
+ * @param value - Flattened fine template data
203
+ * @returns FineTemplate instance
204
+ */
205
+ public build(value: Flatten): FineTemplate {
206
+ return new FineTemplate(
207
+ Id.builder.build(value.id),
208
+ value.reason,
209
+ Fine.Amount.builder.build(value.amount),
210
+ value.repetition === null ? null : Repetition.builder.build(value.repetition)
211
+ );
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Singleton instance of TypeBuilder for FineTemplate.
217
+ */
218
+ export const builder = new TypeBuilder();
219
+ }
@@ -1,6 +1,6 @@
1
1
  import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { Localization } from './Localization';
3
- import { Locale } from './Locale';
2
+ import { Localization } from '../localization/Localization';
3
+ import { Locale } from '../localization/Locale';
4
4
 
5
5
  const payedStates = ['payed', 'notPayed'] as const;
6
6
 
@@ -0,0 +1,3 @@
1
+ export * from './Fine';
2
+ export * from './FineTemplate';
3
+ export * from './PayedState';
@@ -1,19 +1,8 @@
1
- export * from './Configuration';
2
- export * from './Fine';
3
- export * from './FineAmount';
4
- export * from './FineTemplate';
5
- export * from './FineTemplateRepetition';
6
- export * from './Invitation';
7
- export * from './Localization';
8
- export * from './MoneyAmount';
9
- export * from './NotificationProperties';
10
- export * from './PayedState';
11
- export * from './Person';
12
- export * from './PersonProperties';
13
- export * from './PersonSignInProperties';
14
- export * from './Pluralization';
15
- export * from './Team';
16
- export * from './User';
17
- export * from './UserRole';
1
+ export * from './fine';
2
+ export * from './localization';
3
+ export * from './notification';
4
+ export * from './person';
5
+ export * from './team';
6
+ export * from './user';
18
7
  export * from './Currency';
19
- export * from './Locale';
8
+ export * from './Money';
@@ -1,8 +1,10 @@
1
1
  import { mapRecord } from '@stevenkellner/typescript-common-functionality';
2
- import { localizationEN } from '../locales/en';
3
- import { localizationDE } from '../locales/de';
2
+ import { localizationEN } from '../../locales/en';
3
+ import { localizationDE } from '../../locales/de';
4
4
  import { Pluralization } from './Pluralization';
5
5
  import { Locale } from './Locale';
6
+ import { ValueLocalization } from './ValueLocalization';
7
+ import { PluralLocalization } from './PluralLocalization';
6
8
 
7
9
  /**
8
10
  * Type representing the structure of a localization dictionary.
@@ -51,6 +53,7 @@ export class Localization {
51
53
  /**
52
54
  * Returns the localization structure for the specified locale.
53
55
  * Transforms the raw localization data into ValueLocalization and PluralLocalization instances.
56
+ *
54
57
  * @param locale - The locale to retrieve localizations for
55
58
  * @returns The complete localization structure with type-safe access
56
59
  */
@@ -60,11 +63,12 @@ export class Localization {
60
63
 
61
64
  /**
62
65
  * Recursively maps raw localization data to localization class instances.
66
+ *
63
67
  * @param localization - The raw localization value to transform
64
68
  * @returns The transformed localization with proper class instances
65
69
  */
66
70
  private static mapSubLocalization<T extends SubLocalizationType>(localization: T): SubLocalization<T> {
67
- if (typeof localization === 'object' && ! (localization instanceof Pluralization))
71
+ if (typeof localization === 'object' && !(localization instanceof Pluralization))
68
72
  return mapRecord(localization as Record<string, SubLocalizationType>, subLocalization => Localization.mapSubLocalization(subLocalization)) as SubLocalization<T>;
69
73
  if (typeof localization === 'string')
70
74
  return new ValueLocalization(localization) as SubLocalization<T>;
@@ -74,65 +78,4 @@ export class Localization {
74
78
  }
75
79
  }
76
80
 
77
- /**
78
- * Handles localization strings with template variable substitution.
79
- * Supports {{variableName}} syntax for runtime value replacement.
80
- */
81
- export class ValueLocalization {
82
-
83
- /**
84
- * Creates a new ValueLocalization instance.
85
- * @param rawValue - The template string with {{variable}} placeholders
86
- */
87
- constructor(private readonly rawValue: string) {}
88
-
89
- /**
90
- * Returns the localized string with variables substituted.
91
- * Template variables in the format {{key}} are replaced with provided argument values.
92
- * @param args - Record of variable names to their replacement values
93
- * @returns The localized string with all variables replaced
94
- * @throws Error if a required template variable is not provided in args
95
- */
96
- public value(args: Record<string, string> = {}): string {
97
- let rawValue = this.rawValue;
98
- const regex = /\{\{(?<key>.*?)\}\}/;
99
- while (true) {
100
- const match = regex.exec(rawValue);
101
- if (!match)
102
- break;
103
- const key = match.groups!.key;
104
- if (!(key in args))
105
- throw new Error(`Missing argument for key: ${key}`);
106
- rawValue = rawValue.replace(match[0], args[key]);
107
- }
108
- return rawValue;
109
- }
110
- }
111
81
 
112
- /**
113
- * Handles pluralized localization strings that vary based on count.
114
- * Combines Pluralization logic with template variable substitution.
115
- */
116
- export class PluralLocalization {
117
-
118
- /**
119
- * Creates a new PluralLocalization instance.
120
- * @param pluralization - The Pluralization instance containing plural forms
121
- */
122
- constructor(private readonly pluralization: Pluralization) {}
123
-
124
- /**
125
- * Returns the appropriate pluralized string for the given count with variables substituted.
126
- * Automatically includes 'count' in the template variables.
127
- * @param count - The count to determine which plural form to use
128
- * @param args - Additional template variables to substitute (count is added automatically)
129
- * @returns The localized plural string with all variables replaced
130
- */
131
- public value(count: number, args: Record<string, string> = {}): string {
132
- const valueLocalization = new ValueLocalization(this.pluralization.get(count));
133
- return valueLocalization.value({
134
- count: `${count}`,
135
- ...args
136
- });
137
- }
138
- }
@@ -0,0 +1,32 @@
1
+ import { Pluralization } from './Pluralization';
2
+ import { ValueLocalization } from './ValueLocalization';
3
+
4
+ /**
5
+ * Handles pluralized localization strings that vary based on count.
6
+ * Combines Pluralization logic with template variable substitution.
7
+ */
8
+ export class PluralLocalization {
9
+
10
+ /**
11
+ * Creates a new PluralLocalization instance.
12
+ *
13
+ * @param pluralization - The Pluralization instance containing plural forms
14
+ */
15
+ constructor(private readonly pluralization: Pluralization) {}
16
+
17
+ /**
18
+ * Returns the appropriate pluralized string for the given count with variables substituted.
19
+ * Automatically includes 'count' in the template variables.
20
+ *
21
+ * @param count - The count to determine which plural form to use
22
+ * @param args - Additional template variables to substitute (count is added automatically)
23
+ * @returns The localized plural string with all variables replaced
24
+ */
25
+ public value(count: number, args: Record<string, string> = {}): string {
26
+ const valueLocalization = new ValueLocalization(this.pluralization.get(count));
27
+ return valueLocalization.value({
28
+ count: `${count}`,
29
+ ...args
30
+ });
31
+ }
32
+ }
@@ -37,6 +37,7 @@ export class Pluralization {
37
37
 
38
38
  /**
39
39
  * Creates a new Pluralization instance with specified plural forms.
40
+ *
40
41
  * @param countLocals - Object containing plural forms for different count categories
41
42
  * @param countLocals.zero - Optional form for zero items
42
43
  * @param countLocals.one - Optional form for one item
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Handles localization strings with template variable substitution.
3
+ * Supports {{variableName}} syntax for runtime value replacement.
4
+ */
5
+ export class ValueLocalization {
6
+
7
+ /**
8
+ * Creates a new ValueLocalization instance.
9
+ *
10
+ * @param rawValue - The template string with {{variable}} placeholders
11
+ */
12
+ constructor(private readonly rawValue: string) {}
13
+
14
+ /**
15
+ * Returns the localized string with variables substituted.
16
+ * Template variables in the format {{key}} are replaced with provided argument values.
17
+ *
18
+ * @param args - Record of variable names to their replacement values
19
+ * @returns The localized string with all variables replaced
20
+ * @throws Error if a required template variable is not provided in args
21
+ */
22
+ public value(args: Record<string, string> = {}): string {
23
+ let rawValue = this.rawValue;
24
+ const regex = /\{\{(?<key>.*?)\}\}/;
25
+ while (true) {
26
+ const match = regex.exec(rawValue);
27
+ if (!match)
28
+ break;
29
+ const key = match.groups!.key;
30
+ if (!(key in args))
31
+ throw new Error(`Missing argument for key: ${key}`);
32
+ rawValue = rawValue.replace(match[0], args[key]);
33
+ }
34
+ return rawValue;
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ export * from './Locale';
2
+ export * from './Localization';
3
+ export * from './Pluralization';
4
+ export * from './ValueLocalization';
5
+ export * from './PluralLocalization';
@@ -0,0 +1,184 @@
1
+ import { Flattable, Guid, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/typescript-common-functionality';
2
+ import { Fine } from '../fine/Fine';
3
+ import { Team } from '../team/Team';
4
+
5
+ /**
6
+ * Represents an in-app notification for a user.
7
+ *
8
+ * Stores information about team and fine events that are delivered
9
+ * as in-app notifications rather than push notifications.
10
+ */
11
+ export class InAppNotification implements Flattable<InAppNotification.Flatten> {
12
+
13
+ /**
14
+ * Creates a new InAppNotification instance.
15
+ *
16
+ * @param id - Unique identifier for the notification
17
+ * @param date - The date and time the notification was created
18
+ * @param isRead - Whether the notification has been read by the user
19
+ * @param event - The event data describing what triggered the notification
20
+ */
21
+ public constructor(
22
+ public id: InAppNotification.Id,
23
+ public date: UtcDate,
24
+ public isRead: boolean,
25
+ public event: InAppNotification.Event
26
+ ) {}
27
+
28
+ /**
29
+ * Returns the flattened representation for serialization.
30
+ */
31
+ public get flatten(): InAppNotification.Flatten {
32
+ return {
33
+ id: this.id.flatten,
34
+ date: this.date.flatten,
35
+ isRead: this.isRead,
36
+ event: InAppNotification.Event.flatten(this.event)
37
+ };
38
+ }
39
+ }
40
+
41
+ export namespace InAppNotification {
42
+
43
+ /**
44
+ * Tagged GUID type for in-app notification identifiers.
45
+ */
46
+ export type Id = Tagged<Guid, 'inAppNotification'>;
47
+
48
+ export namespace Id {
49
+
50
+ /**
51
+ * Flattened representation of a notification ID (GUID string).
52
+ */
53
+ export type Flatten = string;
54
+
55
+ /**
56
+ * Type builder for InAppNotification.Id serialization/deserialization.
57
+ */
58
+ export const builder = Tagged.builder('inAppNotification' as const, Guid.builder);
59
+ }
60
+
61
+ /**
62
+ * Union type representing the different events that can trigger an in-app notification.
63
+ */
64
+ export type Event =
65
+ | { type: 'fine-added'; teamId: Team.Id; fineId: Fine.Id; reason: string; }
66
+ | { type: 'fine-updated'; teamId: Team.Id; fineId: Fine.Id; reason: string; }
67
+ | { type: 'fine-payed'; teamId: Team.Id; fineId: Fine.Id; reason: string; }
68
+ | { type: 'fine-deleted'; teamId: Team.Id; reason: string; }
69
+ | { type: 'person-role-changed'; teamId: Team.Id; }
70
+ | { type: 'team-kickout'; teamId: Team.Id; };
71
+
72
+ export namespace Event {
73
+
74
+ /**
75
+ * Flattened representation of an Event for serialization.
76
+ */
77
+ export type Flatten =
78
+ | { type: 'fine-added'; teamId: Team.Id.Flatten; fineId: Fine.Id.Flatten; reason: string; }
79
+ | { type: 'fine-updated'; teamId: Team.Id.Flatten; fineId: Fine.Id.Flatten; reason: string; }
80
+ | { type: 'fine-payed'; teamId: Team.Id.Flatten; fineId: Fine.Id.Flatten; reason: string; }
81
+ | { type: 'fine-deleted'; teamId: Team.Id.Flatten; reason: string; }
82
+ | { type: 'person-role-changed'; teamId: Team.Id.Flatten; }
83
+ | { type: 'team-kickout'; teamId: Team.Id.Flatten; };
84
+
85
+ /**
86
+ * Flattens an Event instance for serialization.
87
+ *
88
+ * @param event - The event to flatten
89
+ * @returns The flattened event representation
90
+ */
91
+ export function flatten(event: Event): Flatten {
92
+ switch (event.type) {
93
+ case 'fine-added':
94
+ case 'fine-updated':
95
+ case 'fine-payed':
96
+ return { type: event.type, teamId: event.teamId.flatten, fineId: event.fineId.flatten, reason: event.reason };
97
+ case 'fine-deleted':
98
+ return { type: event.type, teamId: event.teamId.flatten, reason: event.reason };
99
+ case 'person-role-changed':
100
+ case 'team-kickout':
101
+ return { type: event.type, teamId: event.teamId.flatten };
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Type builder for Event serialization/deserialization.
107
+ */
108
+ export class TypeBuilder implements ITypeBuilder<Flatten, Event> {
109
+
110
+ /**
111
+ * Builds an Event instance from flattened data.
112
+ *
113
+ * @param value - The flattened event data
114
+ * @returns The appropriate Event instance based on the type discriminator
115
+ */
116
+ public build(value: Flatten): Event {
117
+ switch (value.type) {
118
+ case 'fine-added':
119
+ case 'fine-updated':
120
+ case 'fine-payed':
121
+ return {
122
+ type: value.type,
123
+ teamId: Team.Id.builder.build(value.teamId),
124
+ fineId: Fine.Id.builder.build(value.fineId),
125
+ reason: value.reason
126
+ };
127
+ case 'fine-deleted':
128
+ return {
129
+ type: value.type,
130
+ teamId: Team.Id.builder.build(value.teamId),
131
+ reason: value.reason
132
+ };
133
+ case 'person-role-changed':
134
+ case 'team-kickout':
135
+ return {
136
+ type: value.type,
137
+ teamId: Team.Id.builder.build(value.teamId)
138
+ };
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Singleton builder instance for Event.
145
+ */
146
+ export const builder = new TypeBuilder();
147
+ }
148
+
149
+ /**
150
+ * Flattened representation of an InAppNotification for serialization.
151
+ */
152
+ export type Flatten = {
153
+ id: Id.Flatten;
154
+ date: UtcDate.Flatten;
155
+ isRead: boolean;
156
+ event: Event.Flatten;
157
+ };
158
+
159
+ /**
160
+ * Type builder for InAppNotification serialization/deserialization.
161
+ */
162
+ export class TypeBuilder implements ITypeBuilder<Flatten, InAppNotification> {
163
+
164
+ /**
165
+ * Builds an InAppNotification instance from flattened data.
166
+ *
167
+ * @param value - The flattened notification data
168
+ * @returns A new InAppNotification instance
169
+ */
170
+ public build(value: Flatten): InAppNotification {
171
+ return new InAppNotification(
172
+ Id.builder.build(value.id),
173
+ UtcDate.builder.build(value.date),
174
+ value.isRead,
175
+ Event.builder.build(value.event)
176
+ );
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Singleton builder instance for InAppNotification.
182
+ */
183
+ export const builder = new TypeBuilder();
184
+ }
@@ -0,0 +1 @@
1
+ export * from './InAppNotification';
@@ -1,7 +1,7 @@
1
+ import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
1
2
  import { PersonProperties } from './PersonProperties';
2
3
  import { PersonSignInProperties } from './PersonSignInProperties';
3
- import { Fine } from './Fine';
4
- import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
4
+ import { Fine } from '../fine/Fine';
5
5
 
6
6
  /**
7
7
  * Represents a person within a team, including their personal details, assigned fines, and optional sign-in properties.
@@ -14,7 +14,7 @@ export class Person implements Flattable<Person.Flatten> {
14
14
  * Creates a new Person instance.
15
15
  *
16
16
  * @param id - Unique identifier for the person (GUID)
17
- * @param properties - Private properties including first name and optional last name
17
+ * @param properties - Personal properties including first name and last name
18
18
  * @param fineIds - Array of fine IDs assigned to this person (defaults to empty array)
19
19
  * @param signInProperties - Optional sign-in properties if the person has signed in (defaults to null)
20
20
  */