@stevenkellner/team-conduct-api 2.0.17 → 2.0.19

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 +7 -6
  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
@@ -1,238 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FineAmount = void 0;
4
- const MoneyAmount_1 = require("./MoneyAmount");
5
- const Configuration_1 = require("./Configuration");
6
- const Localization_1 = require("./Localization");
7
- var FineAmount;
8
- (function (FineAmount) {
9
- /**
10
- * Represents a fine amount as a monetary value.
11
- */
12
- class Money {
13
- amount;
14
- /**
15
- * Creates a new Money fine amount.
16
- *
17
- * @param amount - The monetary amount
18
- */
19
- constructor(amount) {
20
- this.amount = amount;
21
- }
22
- /**
23
- * Returns a formatted string representation of the amount.
24
- *
25
- * @param configuration - Configuration containing currency and locale
26
- * @returns Formatted currency string (e.g., "$10.50")
27
- */
28
- formatted(configuration) {
29
- return this.amount.formatted(configuration.currency, configuration);
30
- }
31
- /**
32
- * Returns a new Money instance with the amount multiplied by a factor.
33
- *
34
- * @param factor - The multiplication factor
35
- * @returns New Money instance with multiplied amount
36
- */
37
- multiplied(factor) {
38
- return new Money(this.amount.multiplied(factor));
39
- }
40
- /**
41
- * Returns the flattened representation for serialization.
42
- */
43
- get flatten() {
44
- return {
45
- type: 'money',
46
- amount: this.amount.flatten
47
- };
48
- }
49
- }
50
- FineAmount.Money = Money;
51
- (function (Money) {
52
- /**
53
- * Type builder for Money serialization/deserialization.
54
- */
55
- class TypeBuilder {
56
- /**
57
- * Builds a Money instance from flattened data.
58
- *
59
- * @param value - Flattened money data
60
- * @returns Money instance
61
- */
62
- build(value) {
63
- return new Money(MoneyAmount_1.MoneyAmount.builder.build(value.amount));
64
- }
65
- }
66
- Money.TypeBuilder = TypeBuilder;
67
- /**
68
- * Singleton instance of TypeBuilder for Money.
69
- */
70
- Money.builder = new TypeBuilder();
71
- })(Money = FineAmount.Money || (FineAmount.Money = {}));
72
- /**
73
- * Represents a fine amount as a quantity of items.
74
- */
75
- class Item {
76
- item;
77
- count;
78
- /**
79
- * Creates a new Item fine amount.
80
- *
81
- * @param item - The item type (e.g., 'crateOfBeer')
82
- * @param count - The number of items
83
- */
84
- constructor(item, count) {
85
- this.item = item;
86
- this.count = count;
87
- }
88
- formatted(configurationOrLocale) {
89
- const locale = configurationOrLocale instanceof Configuration_1.Configuration ? configurationOrLocale.locale : configurationOrLocale;
90
- return Localization_1.Localization.shared(locale).fineAmount.item.type[this.item].withCount.value(this.count);
91
- }
92
- /**
93
- * Returns a formatted string representation without explicitly showing count.
94
- *
95
- * @param locale - The locale for formatting
96
- * @returns Formatted string without count display
97
- */
98
- formattedWithoutCount(locale) {
99
- return Localization_1.Localization.shared(locale).fineAmount.item.type[this.item].withoutCount.value(this.count);
100
- }
101
- /**
102
- * Returns a new Item instance with the count multiplied by a factor.
103
- *
104
- * @param factor - The multiplication factor
105
- * @returns New Item instance with multiplied count
106
- */
107
- multiplied(factor) {
108
- return new Item(this.item, this.count * factor);
109
- }
110
- /**
111
- * Returns the flattened representation for serialization.
112
- */
113
- get flatten() {
114
- return {
115
- type: 'item',
116
- item: this.item,
117
- count: this.count
118
- };
119
- }
120
- }
121
- FineAmount.Item = Item;
122
- (function (Item) {
123
- const itemTypes = ['crateOfBeer'];
124
- let Type;
125
- (function (Type) {
126
- /**
127
- * Array containing all possible item types.
128
- */
129
- Type.all = itemTypes;
130
- /**
131
- * Returns the localized name for an item type.
132
- *
133
- * @param type - The item type
134
- * @param locale - The locale to use for formatting
135
- * @returns Localized item name
136
- */
137
- function formatted(type, locale) {
138
- return Localization_1.Localization.shared(locale).fineAmount.item.type[type].name.value();
139
- }
140
- Type.formatted = formatted;
141
- })(Type = Item.Type || (Item.Type = {}));
142
- /**
143
- * Type builder for Item serialization/deserialization.
144
- */
145
- class TypeBuilder {
146
- /**
147
- * Builds an Item instance from flattened data.
148
- *
149
- * @param value - Flattened item data
150
- * @returns Item instance
151
- */
152
- build(value) {
153
- return new Item(value.item, value.count);
154
- }
155
- }
156
- Item.TypeBuilder = TypeBuilder;
157
- /**
158
- * Singleton instance of TypeBuilder for Item.
159
- */
160
- Item.builder = new TypeBuilder();
161
- })(Item = FineAmount.Item || (FineAmount.Item = {}));
162
- /**
163
- * Creates a Money fine amount.
164
- *
165
- * @param MoneyAmount - The monetary amount
166
- * @returns Money instance
167
- */
168
- function money(MoneyAmount) {
169
- return new Money(MoneyAmount);
170
- }
171
- FineAmount.money = money;
172
- /**
173
- * Creates an Item fine amount.
174
- *
175
- * @param item - The item type
176
- * @param count - The number of items
177
- * @returns Item instance
178
- */
179
- function item(item, count) {
180
- return new Item(item, count);
181
- }
182
- FineAmount.item = item;
183
- /**
184
- * Compares two fine amounts and returns their relative ordering.
185
- *
186
- * Money amounts are considered greater than Item amounts.
187
- * Within the same type, values are compared numerically.
188
- *
189
- * @param lhs - First fine amount to compare
190
- * @param rhs - Second fine amount to compare
191
- * @returns 'less' if lhs < rhs, 'equal' if lhs === rhs, 'greater' if lhs > rhs
192
- */
193
- function compare(lhs, rhs) {
194
- if (lhs instanceof Money) {
195
- if (!(rhs instanceof Money))
196
- return 'greater';
197
- const lhsAmount = lhs.amount.completeValue;
198
- const rhsAmount = rhs.amount.completeValue;
199
- if (lhsAmount !== rhsAmount)
200
- return lhsAmount < rhsAmount ? 'less' : 'greater';
201
- }
202
- if (lhs instanceof Item) {
203
- if (!(rhs instanceof Item))
204
- return 'less';
205
- if (lhs.count === rhs.count)
206
- return 'equal';
207
- return lhs.count < rhs.count ? 'less' : 'greater';
208
- }
209
- return 'equal';
210
- }
211
- FineAmount.compare = compare;
212
- /**
213
- * Type builder for FineAmount serialization/deserialization.
214
- */
215
- class TypeBuilder {
216
- /**
217
- * Builds a FineAmount instance from flattened data.
218
- *
219
- * Determines the type based on the 'type' discriminator field.
220
- *
221
- * @param value - Flattened fine amount data
222
- * @returns FineAmount instance (Money or Item)
223
- */
224
- build(value) {
225
- switch (value.type) {
226
- case 'money':
227
- return Money.builder.build(value);
228
- case 'item':
229
- return Item.builder.build(value);
230
- }
231
- }
232
- }
233
- FineAmount.TypeBuilder = TypeBuilder;
234
- /**
235
- * Singleton instance of TypeBuilder for FineAmount.
236
- */
237
- FineAmount.builder = new TypeBuilder();
238
- })(FineAmount || (exports.FineAmount = FineAmount = {}));
@@ -1,69 +0,0 @@
1
- import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
2
- import { FineAmount } from './FineAmount';
3
- import { FineTemplateRepetition } from './FineTemplateRepetition';
4
- /**
5
- * Represents a template for creating fines with predefined reason, amount, and optional repetition rules.
6
- *
7
- * Fine templates allow teams to quickly create recurring or standard fines without entering
8
- * the same information repeatedly.
9
- */
10
- export declare class FineTemplate implements Flattable<FineTemplate.Flatten> {
11
- id: FineTemplate.Id;
12
- reason: string;
13
- amount: FineAmount;
14
- repetition: FineTemplateRepetition | null;
15
- /**
16
- * Creates a new FineTemplate instance.
17
- *
18
- * @param id - Unique identifier for the fine template (GUID)
19
- * @param reason - The reason or description for the fine
20
- * @param amount - The monetary or item-based amount of the fine
21
- * @param repetition - Optional repetition rules (null for non-recurring templates)
22
- */
23
- constructor(id: FineTemplate.Id, reason: string, amount: FineAmount, repetition: FineTemplateRepetition | null);
24
- /**
25
- * Returns the flattened representation for serialization.
26
- */
27
- get flatten(): FineTemplate.Flatten;
28
- }
29
- export declare namespace FineTemplate {
30
- /**
31
- * Tagged GUID type for fine template identifiers.
32
- */
33
- type Id = Tagged<Guid, 'fineTemplate'>;
34
- namespace Id {
35
- /**
36
- * Flattened representation of a fine template ID (GUID string).
37
- */
38
- type Flatten = string;
39
- /**
40
- * Type builder for FineTemplate.Id serialization/deserialization.
41
- */
42
- const builder: Tagged.TypeBuilder<Guid, "fineTemplate">;
43
- }
44
- /**
45
- * Flattened representation of a FineTemplate for serialization.
46
- */
47
- type Flatten = {
48
- id: Id.Flatten;
49
- reason: string;
50
- amount: FineAmount.Flatten;
51
- repetition: FineTemplateRepetition.Flatten | null;
52
- };
53
- /**
54
- * Type builder for FineTemplate serialization/deserialization.
55
- */
56
- class TypeBuilder implements ITypeBuilder<Flatten, FineTemplate> {
57
- /**
58
- * Builds a FineTemplate instance from flattened data.
59
- *
60
- * @param value - Flattened fine template data
61
- * @returns FineTemplate instance
62
- */
63
- build(value: Flatten): FineTemplate;
64
- }
65
- /**
66
- * Singleton instance of TypeBuilder for FineTemplate.
67
- */
68
- const builder: TypeBuilder;
69
- }
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FineTemplate = void 0;
4
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
- const FineAmount_1 = require("./FineAmount");
6
- const FineTemplateRepetition_1 = require("./FineTemplateRepetition");
7
- /**
8
- * Represents a template for creating fines with predefined reason, amount, and optional repetition rules.
9
- *
10
- * Fine templates allow teams to quickly create recurring or standard fines without entering
11
- * the same information repeatedly.
12
- */
13
- class FineTemplate {
14
- id;
15
- reason;
16
- amount;
17
- repetition;
18
- /**
19
- * Creates a new FineTemplate instance.
20
- *
21
- * @param id - Unique identifier for the fine template (GUID)
22
- * @param reason - The reason or description for the fine
23
- * @param amount - The monetary or item-based amount of the fine
24
- * @param repetition - Optional repetition rules (null for non-recurring templates)
25
- */
26
- constructor(id, reason, amount, repetition) {
27
- this.id = id;
28
- this.reason = reason;
29
- this.amount = amount;
30
- this.repetition = repetition;
31
- }
32
- /**
33
- * Returns the flattened representation for serialization.
34
- */
35
- get flatten() {
36
- return {
37
- id: this.id.flatten,
38
- reason: this.reason,
39
- amount: this.amount.flatten,
40
- repetition: this.repetition === null ? null : this.repetition.flatten
41
- };
42
- }
43
- }
44
- exports.FineTemplate = FineTemplate;
45
- (function (FineTemplate) {
46
- let Id;
47
- (function (Id) {
48
- /**
49
- * Type builder for FineTemplate.Id serialization/deserialization.
50
- */
51
- Id.builder = typescript_common_functionality_1.Tagged.builder('fineTemplate', typescript_common_functionality_1.Guid.builder);
52
- })(Id = FineTemplate.Id || (FineTemplate.Id = {}));
53
- /**
54
- * Type builder for FineTemplate serialization/deserialization.
55
- */
56
- class TypeBuilder {
57
- /**
58
- * Builds a FineTemplate instance from flattened data.
59
- *
60
- * @param value - Flattened fine template data
61
- * @returns FineTemplate instance
62
- */
63
- build(value) {
64
- return new FineTemplate(Id.builder.build(value.id), value.reason, FineAmount_1.FineAmount.builder.build(value.amount), value.repetition === null ? null : FineTemplateRepetition_1.FineTemplateRepetition.builder.build(value.repetition));
65
- }
66
- }
67
- FineTemplate.TypeBuilder = TypeBuilder;
68
- /**
69
- * Singleton instance of TypeBuilder for FineTemplate.
70
- */
71
- FineTemplate.builder = new TypeBuilder();
72
- })(FineTemplate || (exports.FineTemplate = FineTemplate = {}));
@@ -1,87 +0,0 @@
1
- import { Flattable, ITypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { Locale } from './Locale';
3
- /**
4
- * Represents how a fine template repeats over time.
5
- *
6
- * Defines the repetition unit (minute, day, item, count) and optional maximum count for repetitions.
7
- */
8
- export declare class FineTemplateRepetition implements Flattable<FineTemplateRepetition.Flatten> {
9
- item: FineTemplateRepetition.Item;
10
- maxCount: number | null;
11
- /**
12
- * Creates a new FineTemplateRepetition instance.
13
- *
14
- * @param item - The repetition unit type (minute, day, item, count)
15
- * @param maxCount - Optional maximum number of repetitions (null for unlimited)
16
- */
17
- constructor(item: FineTemplateRepetition.Item, maxCount: number | null);
18
- /**
19
- * Returns a localized formatted string including the count value.
20
- *
21
- * @param count - The number of repetitions
22
- * @param locale - The locale to use for formatting
23
- * @returns Formatted string (e.g., "every 5 minutes")
24
- */
25
- formatted(count: number, locale: Locale): string;
26
- /**
27
- * Returns a localized formatted string without explicitly showing the count.
28
- *
29
- * @param count - The number of repetitions
30
- * @param locale - The locale to use for formatting
31
- * @returns Formatted string without count display
32
- */
33
- formattedWithoutCount(count: number, locale: Locale): string;
34
- /**
35
- * Returns the flattened representation for serialization.
36
- */
37
- get flatten(): FineTemplateRepetition.Flatten;
38
- }
39
- export declare namespace FineTemplateRepetition {
40
- const repetitionItems: readonly ["minute", "day", "item", "count"];
41
- /**
42
- * Repetition unit type: 'minute', 'day', 'item', or 'count'.
43
- */
44
- export type Item = typeof repetitionItems[number];
45
- export namespace Item {
46
- /**
47
- * Array containing all possible repetition item types.
48
- */
49
- const all: readonly Item[];
50
- /**
51
- * Returns the localized name for a repetition item type.
52
- *
53
- * @param item - The repetition item type
54
- * @param locale - The locale to use for formatting
55
- * @returns Localized name string
56
- */
57
- function formatted(item: Item, locale: Locale): string;
58
- /**
59
- * Type builder for Item serialization/deserialization.
60
- */
61
- const builder: ValueTypeBuilder<"item" | "minute" | "day" | "count">;
62
- }
63
- /**
64
- * Flattened representation of FineTemplateRepetition for serialization.
65
- */
66
- export type Flatten = {
67
- item: Item;
68
- maxCount: number | null;
69
- };
70
- /**
71
- * Type builder for FineTemplateRepetition serialization/deserialization.
72
- */
73
- export class TypeBuilder implements ITypeBuilder<Flatten, FineTemplateRepetition> {
74
- /**
75
- * Builds a FineTemplateRepetition instance from flattened data.
76
- *
77
- * @param flatten - Flattened repetition data
78
- * @returns FineTemplateRepetition instance
79
- */
80
- build(flatten: Flatten): FineTemplateRepetition;
81
- }
82
- /**
83
- * Singleton instance of TypeBuilder for FineTemplateRepetition.
84
- */
85
- export const builder: TypeBuilder;
86
- export {};
87
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FineTemplateRepetition = void 0;
4
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
- const Localization_1 = require("./Localization");
6
- /**
7
- * Represents how a fine template repeats over time.
8
- *
9
- * Defines the repetition unit (minute, day, item, count) and optional maximum count for repetitions.
10
- */
11
- class FineTemplateRepetition {
12
- item;
13
- maxCount;
14
- /**
15
- * Creates a new FineTemplateRepetition instance.
16
- *
17
- * @param item - The repetition unit type (minute, day, item, count)
18
- * @param maxCount - Optional maximum number of repetitions (null for unlimited)
19
- */
20
- constructor(item, maxCount) {
21
- this.item = item;
22
- this.maxCount = maxCount;
23
- }
24
- /**
25
- * Returns a localized formatted string including the count value.
26
- *
27
- * @param count - The number of repetitions
28
- * @param locale - The locale to use for formatting
29
- * @returns Formatted string (e.g., "every 5 minutes")
30
- */
31
- formatted(count, locale) {
32
- return Localization_1.Localization.shared(locale).fineTemplateRepetition.item[this.item].withCount.value(count);
33
- }
34
- /**
35
- * Returns a localized formatted string without explicitly showing the count.
36
- *
37
- * @param count - The number of repetitions
38
- * @param locale - The locale to use for formatting
39
- * @returns Formatted string without count display
40
- */
41
- formattedWithoutCount(count, locale) {
42
- return Localization_1.Localization.shared(locale).fineTemplateRepetition.item[this.item].withoutCount.value(count);
43
- }
44
- /**
45
- * Returns the flattened representation for serialization.
46
- */
47
- get flatten() {
48
- return {
49
- item: this.item,
50
- maxCount: this.maxCount
51
- };
52
- }
53
- }
54
- exports.FineTemplateRepetition = FineTemplateRepetition;
55
- (function (FineTemplateRepetition) {
56
- const repetitionItems = [
57
- 'minute',
58
- 'day',
59
- 'item',
60
- 'count'
61
- ];
62
- let Item;
63
- (function (Item) {
64
- /**
65
- * Array containing all possible repetition item types.
66
- */
67
- Item.all = repetitionItems;
68
- /**
69
- * Returns the localized name for a repetition item type.
70
- *
71
- * @param item - The repetition item type
72
- * @param locale - The locale to use for formatting
73
- * @returns Localized name string
74
- */
75
- function formatted(item, locale) {
76
- return Localization_1.Localization.shared(locale).fineTemplateRepetition.item[item].name.value();
77
- }
78
- Item.formatted = formatted;
79
- /**
80
- * Type builder for Item serialization/deserialization.
81
- */
82
- Item.builder = new typescript_common_functionality_1.ValueTypeBuilder();
83
- })(Item = FineTemplateRepetition.Item || (FineTemplateRepetition.Item = {}));
84
- /**
85
- * Type builder for FineTemplateRepetition serialization/deserialization.
86
- */
87
- class TypeBuilder {
88
- /**
89
- * Builds a FineTemplateRepetition instance from flattened data.
90
- *
91
- * @param flatten - Flattened repetition data
92
- * @returns FineTemplateRepetition instance
93
- */
94
- build(flatten) {
95
- return new FineTemplateRepetition(flatten.item, flatten.maxCount);
96
- }
97
- }
98
- FineTemplateRepetition.TypeBuilder = TypeBuilder;
99
- /**
100
- * Singleton instance of TypeBuilder for FineTemplateRepetition.
101
- */
102
- FineTemplateRepetition.builder = new TypeBuilder();
103
- })(FineTemplateRepetition || (exports.FineTemplateRepetition = FineTemplateRepetition = {}));
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PluralLocalization = exports.ValueLocalization = exports.Localization = exports.localizations = void 0;
4
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
- const en_1 = require("../locales/en");
6
- const de_1 = require("../locales/de");
7
- const Pluralization_1 = require("./Pluralization");
8
- /**
9
- * Helper function to ensure a record satisfies the localization structure
10
- * while preserving its concrete type.
11
- */
12
- const satisfiesLocalizationRecord = (value) => value;
13
- /**
14
- * Record of all available localizations keyed by locale.
15
- * Each localization must match the structure of LocalizationDict.
16
- */
17
- exports.localizations = satisfiesLocalizationRecord({
18
- en: en_1.localizationEN,
19
- de: de_1.localizationDE
20
- });
21
- /**
22
- * Main localization class that provides access to localized strings.
23
- * Transforms raw localization data into type-safe localization objects.
24
- */
25
- class Localization {
26
- /**
27
- * Returns the localization structure for the specified locale.
28
- * Transforms the raw localization data into ValueLocalization and PluralLocalization instances.
29
- * @param locale - The locale to retrieve localizations for
30
- * @returns The complete localization structure with type-safe access
31
- */
32
- static shared(locale) {
33
- return Localization.mapSubLocalization(exports.localizations[locale]);
34
- }
35
- /**
36
- * Recursively maps raw localization data to localization class instances.
37
- * @param localization - The raw localization value to transform
38
- * @returns The transformed localization with proper class instances
39
- */
40
- static mapSubLocalization(localization) {
41
- if (typeof localization === 'object' && !(localization instanceof Pluralization_1.Pluralization))
42
- return (0, typescript_common_functionality_1.mapRecord)(localization, subLocalization => Localization.mapSubLocalization(subLocalization));
43
- if (typeof localization === 'string')
44
- return new ValueLocalization(localization);
45
- if (localization instanceof Pluralization_1.Pluralization)
46
- return new PluralLocalization(localization);
47
- throw new Error('Invalid localization structure');
48
- }
49
- }
50
- exports.Localization = Localization;
51
- /**
52
- * Handles localization strings with template variable substitution.
53
- * Supports {{variableName}} syntax for runtime value replacement.
54
- */
55
- class ValueLocalization {
56
- rawValue;
57
- /**
58
- * Creates a new ValueLocalization instance.
59
- * @param rawValue - The template string with {{variable}} placeholders
60
- */
61
- constructor(rawValue) {
62
- this.rawValue = rawValue;
63
- }
64
- /**
65
- * Returns the localized string with variables substituted.
66
- * Template variables in the format {{key}} are replaced with provided argument values.
67
- * @param args - Record of variable names to their replacement values
68
- * @returns The localized string with all variables replaced
69
- * @throws Error if a required template variable is not provided in args
70
- */
71
- value(args = {}) {
72
- let rawValue = this.rawValue;
73
- const regex = /\{\{(?<key>.*?)\}\}/;
74
- while (true) {
75
- const match = regex.exec(rawValue);
76
- if (!match)
77
- break;
78
- const key = match.groups.key;
79
- if (!(key in args))
80
- throw new Error(`Missing argument for key: ${key}`);
81
- rawValue = rawValue.replace(match[0], args[key]);
82
- }
83
- return rawValue;
84
- }
85
- }
86
- exports.ValueLocalization = ValueLocalization;
87
- /**
88
- * Handles pluralized localization strings that vary based on count.
89
- * Combines Pluralization logic with template variable substitution.
90
- */
91
- class PluralLocalization {
92
- pluralization;
93
- /**
94
- * Creates a new PluralLocalization instance.
95
- * @param pluralization - The Pluralization instance containing plural forms
96
- */
97
- constructor(pluralization) {
98
- this.pluralization = pluralization;
99
- }
100
- /**
101
- * Returns the appropriate pluralized string for the given count with variables substituted.
102
- * Automatically includes 'count' in the template variables.
103
- * @param count - The count to determine which plural form to use
104
- * @param args - Additional template variables to substitute (count is added automatically)
105
- * @returns The localized plural string with all variables replaced
106
- */
107
- value(count, args = {}) {
108
- const valueLocalization = new ValueLocalization(this.pluralization.get(count));
109
- return valueLocalization.value({
110
- count: `${count}`,
111
- ...args
112
- });
113
- }
114
- }
115
- exports.PluralLocalization = PluralLocalization;