@stevenkellner/team-conduct-api 1.0.35 → 2.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 (218) hide show
  1. package/lib/src/firebase/FirebaseConfiguration.d.ts +45 -1
  2. package/lib/src/firebase/FirebaseConfiguration.js +44 -0
  3. package/lib/src/firebase/Firestore.d.ts +196 -0
  4. package/lib/src/firebase/Firestore.js +235 -0
  5. package/lib/src/{FirestoreScheme.d.ts → firebase/FirestoreScheme.d.ts} +15 -1
  6. package/lib/src/firebase/Messaging.d.ts +64 -0
  7. package/lib/src/firebase/checkAuthentication.d.ts +37 -0
  8. package/lib/src/{checkAuthentication.js → firebase/checkAuthentication.js} +26 -1
  9. package/lib/src/firebase/index.d.ts +4 -0
  10. package/lib/src/firebase/index.js +4 -0
  11. package/lib/src/firebase/pushNotification.d.ts +39 -0
  12. package/lib/src/firebase/pushNotification.js +88 -0
  13. package/lib/src/functions/fine/add.d.ts +10 -13
  14. package/lib/src/functions/fine/add.js +3 -30
  15. package/lib/src/functions/fine/delete.d.ts +10 -13
  16. package/lib/src/functions/fine/delete.js +3 -27
  17. package/lib/src/functions/fine/update.d.ts +10 -13
  18. package/lib/src/functions/fine/update.js +3 -28
  19. package/lib/src/functions/fineTemplate/add.d.ts +6 -9
  20. package/lib/src/functions/fineTemplate/add.js +3 -12
  21. package/lib/src/functions/fineTemplate/delete.d.ts +6 -9
  22. package/lib/src/functions/fineTemplate/delete.js +3 -12
  23. package/lib/src/functions/fineTemplate/update.d.ts +6 -9
  24. package/lib/src/functions/fineTemplate/update.js +3 -12
  25. package/lib/src/functions/invitation/getInvitation.d.ts +41 -42
  26. package/lib/src/functions/invitation/getInvitation.js +58 -81
  27. package/lib/src/functions/invitation/invite.d.ts +1 -2
  28. package/lib/src/functions/invitation/invite.js +3 -18
  29. package/lib/src/functions/invitation/register.d.ts +6 -11
  30. package/lib/src/functions/invitation/register.js +3 -39
  31. package/lib/src/functions/invitation/withdraw.d.ts +1 -2
  32. package/lib/src/functions/invitation/withdraw.js +3 -13
  33. package/lib/src/functions/notification/register.d.ts +7 -10
  34. package/lib/src/functions/notification/register.js +3 -15
  35. package/lib/src/functions/notification/subscribe.d.ts +8 -11
  36. package/lib/src/functions/notification/subscribe.js +3 -14
  37. package/lib/src/functions/paypalMe/edit.d.ts +6 -9
  38. package/lib/src/functions/paypalMe/edit.js +3 -14
  39. package/lib/src/functions/person/add.d.ts +7 -10
  40. package/lib/src/functions/person/add.js +3 -12
  41. package/lib/src/functions/person/delete.d.ts +6 -9
  42. package/lib/src/functions/person/delete.js +3 -14
  43. package/lib/src/functions/person/update.d.ts +7 -10
  44. package/lib/src/functions/person/update.js +3 -13
  45. package/lib/src/functions/team/new.d.ts +9 -12
  46. package/lib/src/functions/team/new.js +3 -22
  47. package/lib/src/functions/user/kickout.d.ts +6 -9
  48. package/lib/src/functions/user/kickout.js +3 -25
  49. package/lib/src/functions/user/login.d.ts +1 -2
  50. package/lib/src/functions/user/login.js +3 -13
  51. package/lib/src/functions/user/roleEdit.d.ts +8 -11
  52. package/lib/src/functions/user/roleEdit.js +3 -18
  53. package/lib/src/index.d.ts +0 -5
  54. package/lib/src/index.js +0 -5
  55. package/lib/src/locales/de.d.ts +10 -67
  56. package/lib/src/locales/de.js +8 -0
  57. package/lib/src/locales/en.d.ts +10 -0
  58. package/lib/src/locales/en.js +19 -2
  59. package/lib/src/types/Configuration.d.ts +33 -15
  60. package/lib/src/types/Configuration.js +24 -12
  61. package/lib/src/types/Currency.d.ts +20 -0
  62. package/lib/src/types/Currency.js +19 -0
  63. package/lib/src/types/Fine.d.ts +41 -0
  64. package/lib/src/types/Fine.js +32 -0
  65. package/lib/src/types/FineAmount.d.ts +160 -9
  66. package/lib/src/types/FineAmount.js +128 -7
  67. package/lib/src/types/FineTemplate.d.ts +41 -0
  68. package/lib/src/types/FineTemplate.js +32 -0
  69. package/lib/src/types/FineTemplateRepetition.d.ts +72 -10
  70. package/lib/src/types/FineTemplateRepetition.js +66 -12
  71. package/lib/src/types/Invitation.d.ts +48 -0
  72. package/lib/src/types/Invitation.js +39 -0
  73. package/lib/src/types/Locale.d.ts +16 -0
  74. package/lib/src/types/Locale.js +16 -0
  75. package/lib/src/types/Localization.d.ts +74 -74
  76. package/lib/src/types/Localization.js +80 -41
  77. package/lib/src/types/MoneyAmount.d.ts +67 -1
  78. package/lib/src/types/MoneyAmount.js +62 -0
  79. package/lib/src/types/NotificationProperties.d.ts +70 -9
  80. package/lib/src/types/NotificationProperties.js +49 -5
  81. package/lib/src/types/PayedState.d.ts +25 -9
  82. package/lib/src/types/PayedState.js +17 -27
  83. package/lib/src/types/Person.d.ts +45 -0
  84. package/lib/src/types/Person.js +36 -0
  85. package/lib/src/types/PersonPrivateProperties.d.ts +28 -0
  86. package/lib/src/types/PersonPrivateProperties.js +25 -0
  87. package/lib/src/types/PersonSignInProperties.d.ts +30 -0
  88. package/lib/src/types/PersonSignInProperties.js +27 -0
  89. package/lib/src/types/Pluralization.d.ts +46 -0
  90. package/lib/src/types/Pluralization.js +46 -0
  91. package/lib/src/types/Team.d.ts +38 -0
  92. package/lib/src/types/Team.js +29 -0
  93. package/lib/src/types/User.d.ts +68 -3
  94. package/lib/src/types/User.js +59 -5
  95. package/lib/src/types/UserRole.d.ts +26 -4
  96. package/lib/src/types/UserRole.js +25 -9
  97. package/lib/src/types/index.d.ts +2 -0
  98. package/lib/src/types/index.js +2 -0
  99. package/lib/test/firebase/FirebaseConfiguration.test.js +155 -0
  100. package/lib/test/firebase/Firestore.test.js +46 -0
  101. package/lib/test/firebase/checkAuthentication.test.d.ts +1 -0
  102. package/lib/test/firebase/checkAuthentication.test.js +305 -0
  103. package/lib/test/firebase/firebase-utils.d.ts +32 -0
  104. package/lib/test/firebase/firebase-utils.js +131 -0
  105. package/lib/test/firebase/pushNotification.test.d.ts +1 -0
  106. package/lib/test/firebase/pushNotification.test.js +300 -0
  107. package/lib/test/locales/localization.de.test.d.ts +1 -0
  108. package/lib/test/locales/localization.de.test.js +144 -0
  109. package/lib/test/locales/localization.en.test.d.ts +1 -0
  110. package/lib/test/locales/localization.en.test.js +144 -0
  111. package/lib/test/types/Configuration.test.d.ts +1 -0
  112. package/lib/test/types/Configuration.test.js +84 -0
  113. package/lib/test/types/Currency.test.d.ts +1 -0
  114. package/lib/test/types/Currency.test.js +41 -0
  115. package/lib/test/types/Fine.test.d.ts +1 -0
  116. package/lib/test/types/Fine.test.js +265 -0
  117. package/lib/test/types/FineAmount.test.d.ts +1 -0
  118. package/lib/test/types/FineAmount.test.js +445 -0
  119. package/lib/test/types/FineTemplate.test.d.ts +1 -0
  120. package/lib/test/types/FineTemplate.test.js +271 -0
  121. package/lib/test/types/FineTemplateRepetition.test.d.ts +1 -0
  122. package/lib/test/types/FineTemplateRepetition.test.js +361 -0
  123. package/lib/test/types/Invitation.test.d.ts +1 -0
  124. package/lib/test/types/Invitation.test.js +269 -0
  125. package/lib/test/types/Locale.test.d.ts +1 -0
  126. package/lib/test/types/Locale.test.js +46 -0
  127. package/lib/test/types/Localization.test.d.ts +1 -0
  128. package/lib/test/types/Localization.test.js +241 -0
  129. package/lib/test/types/MoneyAmount.test.d.ts +1 -0
  130. package/lib/test/types/MoneyAmount.test.js +276 -0
  131. package/lib/test/types/NotificationProperties.test.d.ts +1 -0
  132. package/lib/test/types/NotificationProperties.test.js +258 -0
  133. package/lib/test/types/PayedState.test.d.ts +1 -0
  134. package/lib/test/types/PayedState.test.js +105 -0
  135. package/lib/test/types/Person.test.d.ts +1 -0
  136. package/lib/test/types/Person.test.js +266 -0
  137. package/lib/test/types/PersonPrivateProperties.test.d.ts +1 -0
  138. package/lib/test/types/PersonPrivateProperties.test.js +155 -0
  139. package/lib/test/types/PersonSignInProperties.test.d.ts +1 -0
  140. package/lib/test/types/PersonSignInProperties.test.js +208 -0
  141. package/lib/test/types/Pluralization.test.d.ts +1 -0
  142. package/lib/test/types/Pluralization.test.js +206 -0
  143. package/lib/test/types/Team.test.d.ts +1 -0
  144. package/lib/test/types/Team.test.js +145 -0
  145. package/lib/test/types/User.test.d.ts +1 -0
  146. package/lib/test/types/User.test.js +232 -0
  147. package/lib/test/types/UserRole.test.d.ts +1 -0
  148. package/lib/test/types/UserRole.test.js +140 -0
  149. package/lib/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +10 -9
  151. package/src/firebase/FirebaseConfiguration.ts +49 -1
  152. package/src/firebase/Firestore.ts +248 -0
  153. package/src/{FirestoreScheme.ts → firebase/FirestoreScheme.ts} +15 -1
  154. package/src/firebase/Messaging.ts +64 -0
  155. package/src/{checkAuthentication.ts → firebase/checkAuthentication.ts} +39 -1
  156. package/src/firebase/index.ts +5 -0
  157. package/src/firebase/pushNotification.ts +90 -0
  158. package/src/functions/fine/add.ts +10 -48
  159. package/src/functions/fine/delete.ts +9 -43
  160. package/src/functions/fine/update.ts +10 -44
  161. package/src/functions/fineTemplate/add.ts +7 -23
  162. package/src/functions/fineTemplate/delete.ts +7 -23
  163. package/src/functions/fineTemplate/update.ts +7 -24
  164. package/src/functions/index.ts +0 -1
  165. package/src/functions/invitation/getInvitation.ts +83 -109
  166. package/src/functions/invitation/invite.ts +2 -25
  167. package/src/functions/invitation/register.ts +9 -60
  168. package/src/functions/invitation/withdraw.ts +2 -16
  169. package/src/functions/notification/register.ts +7 -26
  170. package/src/functions/notification/subscribe.ts +8 -26
  171. package/src/functions/paypalMe/edit.ts +7 -25
  172. package/src/functions/person/add.ts +8 -24
  173. package/src/functions/person/delete.ts +6 -25
  174. package/src/functions/person/update.ts +8 -25
  175. package/src/functions/team/new.ts +12 -42
  176. package/src/functions/user/kickout.ts +8 -41
  177. package/src/functions/user/login.ts +2 -16
  178. package/src/functions/user/roleEdit.ts +8 -32
  179. package/src/index.ts +0 -5
  180. package/src/locales/de.ts +10 -1
  181. package/src/locales/en.ts +21 -2
  182. package/src/types/Configuration.ts +33 -23
  183. package/src/types/Currency.ts +24 -0
  184. package/src/types/Fine.ts +41 -0
  185. package/src/types/FineAmount.ts +162 -11
  186. package/src/types/FineTemplate.ts +41 -0
  187. package/src/types/FineTemplateRepetition.ts +75 -17
  188. package/src/types/Invitation.ts +48 -0
  189. package/src/types/Locale.ts +20 -0
  190. package/src/types/Localization.ts +96 -41
  191. package/src/types/MoneyAmount.ts +67 -1
  192. package/src/types/NotificationProperties.ts +67 -9
  193. package/src/types/PayedState.ts +25 -30
  194. package/src/types/Person.ts +45 -0
  195. package/src/types/PersonPrivateProperties.ts +28 -1
  196. package/src/types/PersonSignInProperties.ts +30 -0
  197. package/src/types/Pluralization.ts +46 -0
  198. package/src/types/Team.ts +38 -0
  199. package/src/types/User.ts +70 -4
  200. package/src/types/UserRole.ts +32 -16
  201. package/src/types/index.ts +2 -0
  202. package/lib/src/Firestore.d.ts +0 -24
  203. package/lib/src/Firestore.js +0 -62
  204. package/lib/src/checkAuthentication.d.ts +0 -6
  205. package/lib/src/firebaseFunctionsContext.d.ts +0 -39
  206. package/lib/src/firebaseFunctionsContext.js +0 -43
  207. package/lib/src/pushNotification.d.ts +0 -3
  208. package/lib/src/pushNotification.js +0 -35
  209. package/lib/test/localization-utils.d.ts +0 -1
  210. package/lib/test/localization-utils.js +0 -24
  211. package/lib/test/localization.de.test.js +0 -151
  212. package/lib/test/localization.en.test.js +0 -145
  213. package/src/Firestore.ts +0 -75
  214. package/src/firebaseFunctionsContext.ts +0 -48
  215. package/src/pushNotification.ts +0 -37
  216. /package/lib/src/{FirestoreScheme.js → firebase/FirestoreScheme.js} +0 -0
  217. /package/lib/test/{localization.de.test.d.ts → firebase/FirebaseConfiguration.test.d.ts} +0 -0
  218. /package/lib/test/{localization.en.test.d.ts → firebase/Firestore.test.d.ts} +0 -0
@@ -1,22 +1,18 @@
1
- import { Flattable, ObjectTypeBuilder, UtcDate, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
3
- import { Person, PersonPrivateProperties, PersonSignInProperties, User, UserRole, Team, NotificationProperties } from '../../types';
4
- import { Firestore } from '../../Firestore';
1
+ import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+ import { FirebaseFunction } from '@stevenkellner/firebase-function';
3
+ import { Person, PersonPrivateProperties, User, Team } from '../../types';
5
4
 
6
- export namespace TeamNewFunction {
5
+ export type TeamNewFunctionParameters = {
6
+ id: Team.Id
7
+ name: string
8
+ paypalMeLink: string | null
9
+ personId: Person.Id
10
+ personProperties: PersonPrivateProperties
11
+ };
7
12
 
8
- export type Parameters = {
9
- id: Team.Id
10
- name: string
11
- paypalMeLink: string | null
12
- personId: Person.Id
13
- personProperties: PersonPrivateProperties
14
- }
15
- }
16
-
17
- export class TeamNewFunction extends FirebaseFunction<TeamNewFunction.Parameters, User> {
13
+ export abstract class TeamNewFunctionBase extends FirebaseFunction<TeamNewFunctionParameters, User> {
18
14
 
19
- public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<TeamNewFunction.Parameters>, TeamNewFunction.Parameters>({
15
+ public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<TeamNewFunctionParameters>, TeamNewFunctionParameters>({
20
16
  id: Team.Id.builder,
21
17
  name: new ValueTypeBuilder(),
22
18
  paypalMeLink: new ValueTypeBuilder(),
@@ -25,30 +21,4 @@ export class TeamNewFunction extends FirebaseFunction<TeamNewFunction.Parameters
25
21
  });
26
22
 
27
23
  public returnTypeBuilder = User.builder;
28
-
29
- public async execute(parameters: TeamNewFunction.Parameters): Promise<User> {
30
-
31
- if (this.userId === null)
32
- throw new FunctionsError('permission-denied', 'User is not authenticated');
33
- const userId = User.Id.builder.build(this.userId);
34
-
35
- const teamSnapshot = await Firestore.shared.team(parameters.id).snapshot();
36
- if (teamSnapshot.exists)
37
- throw new FunctionsError('already-exists', 'Team already exists');
38
-
39
- const userSnapshot = await Firestore.shared.user(userId).snapshot();
40
- let user = new User(userId);
41
- if (userSnapshot.exists)
42
- user = User.builder.build(userSnapshot.data);
43
-
44
- user.teams.set(parameters.id, new User.TeamProperties(parameters.name, parameters.personId));
45
- await Firestore.shared.user(userId).set(user);
46
-
47
- await Firestore.shared.team(parameters.id).set(new Team(parameters.id, parameters.name, parameters.paypalMeLink));
48
-
49
- const signInProperties = new PersonSignInProperties(userId, UtcDate.now, new NotificationProperties(), UserRole.all);
50
- await Firestore.shared.person(parameters.id, parameters.personId).set(new Person(parameters.personId, parameters.personProperties, [], signInProperties));
51
-
52
- return user;
53
- }
54
24
  }
@@ -1,51 +1,18 @@
1
- import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
2
- import { Person, Team, User } from '../../types';
1
+ import { FirebaseFunction } from '@stevenkellner/firebase-function';
2
+ import { Team, User } from '../../types';
3
3
  import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
4
- import { Firestore } from '../../Firestore';
5
- import { checkAuthentication } from '../../checkAuthentication';
6
4
 
7
- export namespace UserKickoutFunction {
5
+ export type UserKickoutFunctionParameters = {
6
+ teamId: Team.Id
7
+ userId: User.Id
8
+ };
8
9
 
9
- export type Parameters = {
10
- teamId: Team.Id
11
- userId: User.Id
12
- };
13
- }
14
-
15
- export class UserKickoutFunction extends FirebaseFunction<UserKickoutFunction.Parameters, void> {
10
+ export abstract class UserKickoutFunctionBase extends FirebaseFunction<UserKickoutFunctionParameters, void> {
16
11
 
17
- public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserKickoutFunction.Parameters>, UserKickoutFunction.Parameters>({
12
+ public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserKickoutFunctionParameters>, UserKickoutFunctionParameters>({
18
13
  teamId: Team.Id.builder,
19
14
  userId: User.Id.builder
20
15
  });
21
16
 
22
17
  public returnTypeBuilder = new ValueTypeBuilder<void>();
23
-
24
- public async execute(parameters: UserKickoutFunction.Parameters): Promise<void> {
25
-
26
- const userId = await checkAuthentication(this.userId, parameters.teamId, 'team-manager');
27
-
28
- if (userId.value === parameters.userId.value)
29
- throw new FunctionsError('invalid-argument', 'You cannot kick yourself out of a team.');
30
-
31
- const userSnapshot = await Firestore.shared.user(parameters.userId).snapshot();
32
- if (!userSnapshot.exists)
33
- throw new FunctionsError('not-found', 'User not found.');
34
- const user = User.builder.build(userSnapshot.data);
35
-
36
- const userTeamProperties = user.teams.getOptional(parameters.teamId);
37
- if (userTeamProperties === null)
38
- throw new FunctionsError('not-found', 'User is not a member of the team.');
39
-
40
- const personSnapshot = await Firestore.shared.person(parameters.teamId, userTeamProperties.personId).snapshot();
41
- if (!personSnapshot.exists)
42
- throw new FunctionsError('not-found', 'Person not found.');
43
- const person = Person.builder.build(personSnapshot.data);
44
-
45
- person.signInProperties = null;
46
- await Firestore.shared.person(parameters.teamId, userTeamProperties.personId).set(person);
47
-
48
- user.teams.delete(parameters.teamId);
49
- await Firestore.shared.user(parameters.userId).set(user);
50
- }
51
18
  }
@@ -1,24 +1,10 @@
1
- import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
1
+ import { FirebaseFunction } from '@stevenkellner/firebase-function';
2
2
  import { User } from '../../types';
3
3
  import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
4
- import { Firestore } from '../../Firestore';
5
4
 
6
- export class UserLoginFunction extends FirebaseFunction<null, User> {
5
+ export abstract class UserLoginFunctionBase extends FirebaseFunction<null, User> {
7
6
 
8
7
  public parametersBuilder = new ValueTypeBuilder<null>();
9
8
 
10
9
  public returnTypeBuilder = User.builder;
11
-
12
- public async execute(): Promise<User> {
13
-
14
- if (this.userId === null)
15
- throw new FunctionsError('unauthenticated', 'User is not authenticated.');
16
- const userId = User.Id.builder.build(this.userId);
17
-
18
- const userSnapshot = await Firestore.shared.user(userId).snapshot();
19
- if (!userSnapshot.exists)
20
- throw new FunctionsError('not-found', 'User not found.');
21
-
22
- return User.builder.build(userSnapshot.data);
23
- }
24
10
  }
@@ -1,44 +1,20 @@
1
- import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
2
- import { checkAuthentication } from '../../checkAuthentication';
1
+ import { FirebaseFunction } from '@stevenkellner/firebase-function';
3
2
  import { Person, Team, UserRole } from '../../types';
4
3
  import { ArrayTypeBuilder, Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
5
- import { Firestore } from '../../Firestore';
6
4
 
7
- export namespace UserRoleEditFunction {
5
+ export type UserRoleEditFunctionParameters = {
6
+ teamId: Team.Id
7
+ personId: Person.Id
8
+ roles: UserRole[]
9
+ };
8
10
 
9
- export type Parameters = {
10
- teamId: Team.Id
11
- personId: Person.Id
12
- roles: UserRole[]
13
- };
14
- }
15
-
16
- export class UserRoleEditFunction extends FirebaseFunction<UserRoleEditFunction.Parameters, void> {
11
+ export abstract class UserRoleEditFunctionBase extends FirebaseFunction<UserRoleEditFunctionParameters, void> {
17
12
 
18
- public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserRoleEditFunction.Parameters>, UserRoleEditFunction.Parameters>({
13
+ public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserRoleEditFunctionParameters>, UserRoleEditFunctionParameters>({
19
14
  teamId: Team.Id.builder,
20
15
  personId: Person.Id.builder,
21
16
  roles: new ArrayTypeBuilder(new ValueTypeBuilder())
22
17
  });
23
18
 
24
19
  public returnTypeBuilder = new ValueTypeBuilder<void>();
25
-
26
- public async execute(parameters: UserRoleEditFunction.Parameters): Promise<void> {
27
-
28
- const userId = await checkAuthentication(this.userId, parameters.teamId, 'team-manager');
29
-
30
- const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.personId).snapshot();
31
- if (!personSnapshot.exists)
32
- throw new FunctionsError('not-found', 'User does not exist');
33
- const person = Person.builder.build(personSnapshot.data);
34
-
35
- if (person.signInProperties === null)
36
- throw new FunctionsError('permission-denied', 'User is not signed in');
37
-
38
- if (person.signInProperties.userId.value === userId.value && !parameters.roles.includes('team-manager'))
39
- throw new FunctionsError('unavailable', 'User cannot remove their own team-manager role');
40
-
41
- person.signInProperties.roles = parameters.roles;
42
- await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
43
- }
44
20
  }
package/src/index.ts CHANGED
@@ -1,8 +1,3 @@
1
1
  export * from './firebase';
2
2
  export * from './functions';
3
3
  export * from './types';
4
- export * from './checkAuthentication';
5
- export * from './firebaseFunctionsContext';
6
- export * from './Firestore';
7
- export * from './FirestoreScheme';
8
- export * from './pushNotification';
package/src/locales/de.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { Pluralization } from '../types/Pluralization';
2
+ import { LocalizationDict } from '../types/Localization';
2
3
 
3
- export const localizationDE = {
4
+ /**
5
+ * German (de) localization strings for the application.
6
+ * Contains translations for notifications, fine amounts, fine template repetitions,
7
+ * payment states, and user roles.
8
+ *
9
+ * Supports template variables using {{variableName}} syntax that will be replaced
10
+ * at runtime with actual values.
11
+ */
12
+ export const localizationDE: LocalizationDict = {
4
13
  notification: {
5
14
  fine: {
6
15
  new: {
package/src/locales/en.ts CHANGED
@@ -1,6 +1,25 @@
1
1
  import { Pluralization } from '../types/Pluralization';
2
+ import { SubLocalizationType } from '../types/Localization';
2
3
 
3
- export const localizationEN = {
4
+ /**
5
+ * Helper function to ensure a value satisfies the Localization structure
6
+ * while preserving its concrete type (as const) for type inference.
7
+ * @param value - The localization object to validate
8
+ * @returns The same value with its inferred type preserved
9
+ */
10
+ const satisfiesLocalization = <T extends { [Key in string]: SubLocalizationType }>(value: T): T => value;
11
+
12
+ /**
13
+ * English (en) localization strings for the application.
14
+ * Contains translations for notifications, fine amounts, fine template repetitions,
15
+ * payment states, and user roles.
16
+ *
17
+ * Supports template variables using {{variableName}} syntax that will be replaced
18
+ * at runtime with actual values.
19
+ *
20
+ * This serves as the base localization - other locales should match this structure.
21
+ */
22
+ export const localizationEN = satisfiesLocalization({
4
23
  notification: {
5
24
  fine: {
6
25
  new: {
@@ -95,4 +114,4 @@ export const localizationEN = {
95
114
  fineCanAdd: 'Can add fines',
96
115
  teamManager: 'Team Manager'
97
116
  }
98
- }
117
+ });
@@ -1,13 +1,27 @@
1
- import { localizations } from './Localization';
2
- import { Flattable, ITypeBuilder, keys, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
3
-
1
+ import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+ import { Currency } from './Currency';
3
+ import { Locale } from './Locale';
4
+
5
+ /**
6
+ * Represents the configuration settings that will be passed to the functions parameters.
7
+ * Contains currency and locale preferences.
8
+ */
4
9
  export class Configuration implements Flattable<Configuration.Flatten> {
5
10
 
11
+ /**
12
+ * Creates a new Configuration instance.
13
+ * @param currency - The currency to use for monetary values (EUR, USD, ...)
14
+ * @param locale - The locale for localization (language/region)
15
+ */
6
16
  public constructor(
7
- public currency: Configuration.Currency,
8
- public locale: Configuration.Locale
17
+ public currency: Currency,
18
+ public locale: Locale
9
19
  ) {}
10
20
 
21
+ /**
22
+ * Returns the flattened representation of the configuration.
23
+ * @returns The flattened configuration object
24
+ */
11
25
  public get flatten(): Configuration.Flatten {
12
26
  return {
13
27
  currency: this.currency,
@@ -18,31 +32,24 @@ export class Configuration implements Flattable<Configuration.Flatten> {
18
32
 
19
33
  export namespace Configuration {
20
34
 
21
- export type Currency = 'EUR' | 'USD';
22
-
23
- export namespace Currency {
24
-
25
- export const all: Currency[] = ['EUR', 'USD'];
26
-
27
- export const builder = new ValueTypeBuilder<Currency>();
28
- }
29
-
30
- export type Locale = keyof typeof localizations;
31
-
32
- export namespace Locale {
33
-
34
- export const all: Locale[] = keys(localizations);
35
-
36
- export const builder = new ValueTypeBuilder<Locale>();
37
- }
38
-
35
+ /**
36
+ * Flattened representation of Configuration for serialization.
37
+ */
39
38
  export type Flatten = {
40
39
  currency: Currency,
41
40
  locale: Locale
42
41
  };
43
42
 
43
+ /**
44
+ * TypeBuilder for constructing Configuration instances from flattened data.
45
+ */
44
46
  export class TypeBuilder implements ITypeBuilder<Flatten, Configuration> {
45
47
 
48
+ /**
49
+ * Builds a Configuration instance from flattened data.
50
+ * @param flatten - The flattened configuration data
51
+ * @returns A new Configuration instance
52
+ */
46
53
  public build(flatten: Flatten): Configuration {
47
54
  return new Configuration(
48
55
  flatten.currency,
@@ -51,5 +58,8 @@ export namespace Configuration {
51
58
  }
52
59
  }
53
60
 
61
+ /**
62
+ * Singleton builder instance for Configuration.
63
+ */
54
64
  export const builder = new TypeBuilder();
55
65
  }
@@ -0,0 +1,24 @@
1
+ import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+
3
+ /**
4
+ * Array of all available currencies.
5
+ */
6
+ const currencies = ['EUR', 'USD'] as const;
7
+
8
+ /**
9
+ * Supported currency types.
10
+ */
11
+ export type Currency = typeof currencies[number];
12
+
13
+ export namespace Currency {
14
+
15
+ /**
16
+ * Array of all available currencies.
17
+ */
18
+ export const all: readonly Currency[] = currencies;
19
+
20
+ /**
21
+ * Builder for constructing Currency values.
22
+ */
23
+ export const builder = new ValueTypeBuilder<Currency>();
24
+ }
package/src/types/Fine.ts CHANGED
@@ -2,8 +2,22 @@ import { Flattable, Guid, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/t
2
2
  import { FineAmount } from './FineAmount';
3
3
  import { PayedState } from './PayedState';
4
4
 
5
+ /**
6
+ * Represents a fine assigned to a person in a team.
7
+ *
8
+ * Contains information about the fine's payment status, date, reason, and monetary amount.
9
+ */
5
10
  export class Fine implements Flattable<Fine.Flatten> {
6
11
 
12
+ /**
13
+ * Creates a new Fine instance.
14
+ *
15
+ * @param id - Unique identifier for the fine (GUID)
16
+ * @param payedState - Payment status ('payed' or 'notPayed')
17
+ * @param date - Date when the fine was issued
18
+ * @param reason - Description or reason for the fine
19
+ * @param amount - Monetary amount of the fine
20
+ */
7
21
  public constructor(
8
22
  public id: Fine.Id,
9
23
  public payedState: PayedState,
@@ -12,6 +26,9 @@ export class Fine implements Flattable<Fine.Flatten> {
12
26
  public amount: FineAmount
13
27
  ) {}
14
28
 
29
+ /**
30
+ * Returns the flattened representation for serialization.
31
+ */
15
32
  public get flatten(): Fine.Flatten {
16
33
  return {
17
34
  id: this.id.flatten,
@@ -25,15 +42,27 @@ export class Fine implements Flattable<Fine.Flatten> {
25
42
 
26
43
  export namespace Fine {
27
44
 
45
+ /**
46
+ * Tagged GUID type for fine identifiers.
47
+ */
28
48
  export type Id = Tagged<Guid, 'fine'>;
29
49
 
30
50
  export namespace Id {
31
51
 
52
+ /**
53
+ * Flattened representation of a fine ID (GUID string).
54
+ */
32
55
  export type Flatten = string;
33
56
 
57
+ /**
58
+ * Type builder for Fine.Id serialization/deserialization.
59
+ */
34
60
  export const builder = Tagged.builder('fine' as const, Guid.builder);
35
61
  }
36
62
 
63
+ /**
64
+ * Flattened representation of a Fine for serialization.
65
+ */
37
66
  export type Flatten = {
38
67
  id: Id.Flatten,
39
68
  payedState: PayedState,
@@ -42,8 +71,17 @@ export namespace Fine {
42
71
  amount: FineAmount.Flatten
43
72
  };
44
73
 
74
+ /**
75
+ * Type builder for Fine serialization/deserialization.
76
+ */
45
77
  export class TypeBuilder implements ITypeBuilder<Flatten, Fine> {
46
78
 
79
+ /**
80
+ * Builds a Fine instance from flattened data.
81
+ *
82
+ * @param value - Flattened fine data
83
+ * @returns Fine instance
84
+ */
47
85
  public build(value: Flatten): Fine {
48
86
  return new Fine(
49
87
  Id.builder.build(value.id),
@@ -55,5 +93,8 @@ export namespace Fine {
55
93
  }
56
94
  }
57
95
 
96
+ /**
97
+ * Singleton instance of TypeBuilder for Fine.
98
+ */
58
99
  export const builder = new TypeBuilder();
59
100
  }