@stevenkellner/team-conduct-api 1.0.36 → 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 +40 -43
  26. package/lib/src/functions/invitation/getInvitation.js +57 -88
  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 +81 -118
  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,24 +1,62 @@
1
1
  import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
2
+ /**
3
+ * Represents a team in the system with its basic information.
4
+ *
5
+ * A team is a group of people who can track fines and payments together.
6
+ * Teams can optionally have a PayPal.Me link for simplified payment collection.
7
+ */
2
8
  export declare class Team implements Flattable<Team.Flatten> {
3
9
  id: Team.Id;
4
10
  name: string;
5
11
  paypalMeLink: string | null;
12
+ /**
13
+ * Creates a new Team instance.
14
+ * @param id - The unique identifier for this team
15
+ * @param name - The display name of the team
16
+ * @param paypalMeLink - Optional PayPal.Me link for payment collection (null if not set)
17
+ */
6
18
  constructor(id: Team.Id, name: string, paypalMeLink: string | null);
19
+ /**
20
+ * Gets the flattened representation of this team for serialization.
21
+ */
7
22
  get flatten(): Team.Flatten;
8
23
  }
9
24
  export declare namespace Team {
25
+ /**
26
+ * Tagged type for team identifiers to prevent mixing with other GUID types.
27
+ */
10
28
  type Id = Tagged<Guid, 'team'>;
11
29
  namespace Id {
30
+ /**
31
+ * Flattened representation of a team ID (plain GUID string).
32
+ */
12
33
  type Flatten = string;
34
+ /**
35
+ * Builder for constructing Team.Id instances from GUID strings.
36
+ */
13
37
  const builder: Tagged.TypeBuilder<Guid, "team">;
14
38
  }
39
+ /**
40
+ * Flattened representation of a Team for serialization.
41
+ */
15
42
  type Flatten = {
16
43
  id: Id.Flatten;
17
44
  name: string;
18
45
  paypalMeLink: string | null;
19
46
  };
47
+ /**
48
+ * Builder for constructing Team instances from flattened data.
49
+ */
20
50
  class TypeBuilder implements ITypeBuilder<Flatten, Team> {
51
+ /**
52
+ * Builds a Team instance from flattened data.
53
+ * @param value - The flattened team data
54
+ * @returns A new Team instance
55
+ */
21
56
  build(value: Flatten): Team;
22
57
  }
58
+ /**
59
+ * Singleton builder instance for Team.
60
+ */
23
61
  const builder: TypeBuilder;
24
62
  }
@@ -2,15 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Team = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
+ /**
6
+ * Represents a team in the system with its basic information.
7
+ *
8
+ * A team is a group of people who can track fines and payments together.
9
+ * Teams can optionally have a PayPal.Me link for simplified payment collection.
10
+ */
5
11
  class Team {
6
12
  id;
7
13
  name;
8
14
  paypalMeLink;
15
+ /**
16
+ * Creates a new Team instance.
17
+ * @param id - The unique identifier for this team
18
+ * @param name - The display name of the team
19
+ * @param paypalMeLink - Optional PayPal.Me link for payment collection (null if not set)
20
+ */
9
21
  constructor(id, name, paypalMeLink) {
10
22
  this.id = id;
11
23
  this.name = name;
12
24
  this.paypalMeLink = paypalMeLink;
13
25
  }
26
+ /**
27
+ * Gets the flattened representation of this team for serialization.
28
+ */
14
29
  get flatten() {
15
30
  return {
16
31
  id: this.id.flatten,
@@ -23,13 +38,27 @@ exports.Team = Team;
23
38
  (function (Team) {
24
39
  let Id;
25
40
  (function (Id) {
41
+ /**
42
+ * Builder for constructing Team.Id instances from GUID strings.
43
+ */
26
44
  Id.builder = typescript_common_functionality_1.Tagged.builder('team', typescript_common_functionality_1.Guid.builder);
27
45
  })(Id = Team.Id || (Team.Id = {}));
46
+ /**
47
+ * Builder for constructing Team instances from flattened data.
48
+ */
28
49
  class TypeBuilder {
50
+ /**
51
+ * Builds a Team instance from flattened data.
52
+ * @param value - The flattened team data
53
+ * @returns A new Team instance
54
+ */
29
55
  build(value) {
30
56
  return new Team(Id.builder.build(value.id), value.name, value.paypalMeLink);
31
57
  }
32
58
  }
33
59
  Team.TypeBuilder = TypeBuilder;
60
+ /**
61
+ * Singleton builder instance for Team.
62
+ */
34
63
  Team.builder = new TypeBuilder();
35
64
  })(Team || (exports.Team = Team = {}));
@@ -1,40 +1,105 @@
1
1
  import { Dictionary, Flattable, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
2
2
  import { Team } from './Team';
3
3
  import { Person } from './Person';
4
+ /**
5
+ * Represents a user in the system with associated team memberships.
6
+ *
7
+ * A user can be a member of multiple teams, and for each team, they have
8
+ * specific properties (team name and associated person ID).
9
+ */
4
10
  export declare class User implements Flattable<User.Flatten> {
5
11
  id: User.Id;
6
12
  teams: Dictionary<Team.Id, User.TeamProperties>;
13
+ /**
14
+ * Creates a new User instance.
15
+ * @param id - The unique identifier for this user
16
+ * @param teams - Dictionary mapping team IDs to team-specific user properties
17
+ */
7
18
  constructor(id: User.Id, teams?: Dictionary<Team.Id, User.TeamProperties>);
19
+ /**
20
+ * Gets the flattened representation of this user for serialization.
21
+ */
8
22
  get flatten(): User.Flatten;
9
23
  }
10
24
  export declare namespace User {
25
+ /**
26
+ * Tagged type for user identifiers to prevent mixing with other string IDs.
27
+ */
11
28
  type Id = Tagged<string, 'user'>;
12
29
  namespace Id {
30
+ /**
31
+ * Flattened representation of a user ID (plain string).
32
+ */
13
33
  type Flatten = string;
34
+ /**
35
+ * Builder for constructing User.Id instances from strings.
36
+ */
14
37
  const builder: Tagged.TypeBuilder<string, "user">;
15
38
  }
39
+ /**
40
+ * Properties that are specific to a user's membership in a particular team.
41
+ */
16
42
  class TeamProperties implements Flattable<TeamProperties.Flatten> {
17
- name: string;
43
+ teamId: Team.Id;
44
+ teamName: string;
18
45
  personId: Person.Id;
19
- constructor(name: string, personId: Person.Id);
46
+ /**
47
+ * Creates new team-specific user properties.
48
+ * @param teamId - The ID of the team
49
+ * @param teamName - The display name of the team
50
+ * @param personId - The ID of the person associated with this user in this team
51
+ */
52
+ constructor(teamId: Team.Id, teamName: string, personId: Person.Id);
53
+ /**
54
+ * Gets the flattened representation of these team properties.
55
+ */
20
56
  get flatten(): TeamProperties.Flatten;
21
57
  }
22
58
  namespace TeamProperties {
59
+ /**
60
+ * Flattened representation of team properties for serialization.
61
+ */
23
62
  type Flatten = {
24
- name: string;
63
+ teamId: Team.Id.Flatten;
64
+ teamName: string;
25
65
  personId: Person.Id.Flatten;
26
66
  };
67
+ /**
68
+ * Builder for constructing TeamProperties from flattened data.
69
+ */
27
70
  class TypeBuilder implements ITypeBuilder<Flatten, TeamProperties> {
71
+ /**
72
+ * Builds a TeamProperties instance from flattened data.
73
+ * @param value - The flattened team properties data
74
+ * @returns A new TeamProperties instance
75
+ */
28
76
  build(value: Flatten): TeamProperties;
29
77
  }
78
+ /**
79
+ * Singleton builder instance for TeamProperties.
80
+ */
30
81
  const builder: TypeBuilder;
31
82
  }
83
+ /**
84
+ * Flattened representation of a User for serialization.
85
+ */
32
86
  type Flatten = {
33
87
  id: Id.Flatten;
34
88
  teams: Dictionary.Flatten<TeamProperties>;
35
89
  };
90
+ /**
91
+ * Builder for constructing User instances from flattened data.
92
+ */
36
93
  class TypeBuilder implements ITypeBuilder<Flatten, User> {
94
+ /**
95
+ * Builds a User instance from flattened data.
96
+ * @param value - The flattened user data
97
+ * @returns A new User instance with all teams reconstructed
98
+ */
37
99
  build(value: Flatten): User;
38
100
  }
101
+ /**
102
+ * Singleton builder instance for User.
103
+ */
39
104
  const builder: TypeBuilder;
40
105
  }
@@ -4,13 +4,27 @@ exports.User = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
5
  const Team_1 = require("./Team");
6
6
  const Person_1 = require("./Person");
7
+ /**
8
+ * Represents a user in the system with associated team memberships.
9
+ *
10
+ * A user can be a member of multiple teams, and for each team, they have
11
+ * specific properties (team name and associated person ID).
12
+ */
7
13
  class User {
8
14
  id;
9
15
  teams;
16
+ /**
17
+ * Creates a new User instance.
18
+ * @param id - The unique identifier for this user
19
+ * @param teams - Dictionary mapping team IDs to team-specific user properties
20
+ */
10
21
  constructor(id, teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder)) {
11
22
  this.id = id;
12
23
  this.teams = teams;
13
24
  }
25
+ /**
26
+ * Gets the flattened representation of this user for serialization.
27
+ */
14
28
  get flatten() {
15
29
  return {
16
30
  id: this.id.flatten,
@@ -22,37 +36,77 @@ exports.User = User;
22
36
  (function (User) {
23
37
  let Id;
24
38
  (function (Id) {
39
+ /**
40
+ * Builder for constructing User.Id instances from strings.
41
+ */
25
42
  Id.builder = typescript_common_functionality_1.Tagged.builder('user', new typescript_common_functionality_1.ValueTypeBuilder());
26
43
  })(Id = User.Id || (User.Id = {}));
44
+ /**
45
+ * Properties that are specific to a user's membership in a particular team.
46
+ */
27
47
  class TeamProperties {
28
- name;
48
+ teamId;
49
+ teamName;
29
50
  personId;
30
- constructor(name, personId) {
31
- this.name = name;
51
+ /**
52
+ * Creates new team-specific user properties.
53
+ * @param teamId - The ID of the team
54
+ * @param teamName - The display name of the team
55
+ * @param personId - The ID of the person associated with this user in this team
56
+ */
57
+ constructor(teamId, teamName, personId) {
58
+ this.teamId = teamId;
59
+ this.teamName = teamName;
32
60
  this.personId = personId;
33
61
  }
62
+ /**
63
+ * Gets the flattened representation of these team properties.
64
+ */
34
65
  get flatten() {
35
66
  return {
36
- name: this.name,
67
+ teamId: this.teamId.flatten,
68
+ teamName: this.teamName,
37
69
  personId: this.personId.flatten
38
70
  };
39
71
  }
40
72
  }
41
73
  User.TeamProperties = TeamProperties;
42
74
  (function (TeamProperties) {
75
+ /**
76
+ * Builder for constructing TeamProperties from flattened data.
77
+ */
43
78
  class TypeBuilder {
79
+ /**
80
+ * Builds a TeamProperties instance from flattened data.
81
+ * @param value - The flattened team properties data
82
+ * @returns A new TeamProperties instance
83
+ */
44
84
  build(value) {
45
- return new TeamProperties(value.name, Person_1.Person.Id.builder.build(value.personId));
85
+ return new TeamProperties(Team_1.Team.Id.builder.build(value.teamId), value.teamName, Person_1.Person.Id.builder.build(value.personId));
46
86
  }
47
87
  }
48
88
  TeamProperties.TypeBuilder = TypeBuilder;
89
+ /**
90
+ * Singleton builder instance for TeamProperties.
91
+ */
49
92
  TeamProperties.builder = new TypeBuilder();
50
93
  })(TeamProperties = User.TeamProperties || (User.TeamProperties = {}));
94
+ /**
95
+ * Builder for constructing User instances from flattened data.
96
+ */
51
97
  class TypeBuilder {
98
+ /**
99
+ * Builds a User instance from flattened data.
100
+ * @param value - The flattened user data
101
+ * @returns A new User instance with all teams reconstructed
102
+ */
52
103
  build(value) {
53
104
  return new User(Id.builder.build(value.id), typescript_common_functionality_1.Dictionary.builder(Team_1.Team.Id.builder, User.TeamProperties.builder).build(value.teams));
54
105
  }
55
106
  }
56
107
  User.TypeBuilder = TypeBuilder;
108
+ /**
109
+ * Singleton builder instance for User.
110
+ */
57
111
  User.builder = new TypeBuilder();
58
112
  })(User || (exports.User = User = {}));
@@ -1,7 +1,29 @@
1
1
  import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
- export type UserRole = 'person-manager' | 'fineTemplate-manager' | 'fine-manager' | 'fine-can-add' | 'team-manager';
2
+ import { Locale } from './Locale';
3
+ /**
4
+ * Array of all available user roles.
5
+ */
6
+ declare const userRoles: readonly ["person-manager", "fineTemplate-manager", "fine-manager", "fine-can-add", "team-manager"];
7
+ /**
8
+ * Represents user roles in the application.
9
+ * Defines different levels of permissions for team members.
10
+ */
11
+ export type UserRole = typeof userRoles[number];
3
12
  export declare namespace UserRole {
4
- const all: UserRole[];
5
- function formatted(role: UserRole): string;
6
- const builder: ValueTypeBuilder<UserRole>;
13
+ /**
14
+ * Array of all available user roles.
15
+ */
16
+ const all: readonly UserRole[];
17
+ /**
18
+ * Returns the localized, human-readable name for a user role.
19
+ * @param role - The user role to format
20
+ * @param locale - The locale to use for localization
21
+ * @returns The localized role name
22
+ */
23
+ function formatted(role: UserRole, locale: Locale): string;
24
+ /**
25
+ * Builder for constructing UserRole values.
26
+ */
27
+ const builder: ValueTypeBuilder<"person-manager" | "fineTemplate-manager" | "fine-manager" | "fine-can-add" | "team-manager">;
7
28
  }
29
+ export {};
@@ -3,16 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserRole = void 0;
4
4
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
5
  const Localization_1 = require("./Localization");
6
+ /**
7
+ * Array of all available user roles.
8
+ */
9
+ const userRoles = [
10
+ 'person-manager', // Can manage persons, i.e. add/edit/remove persons of the team
11
+ 'fineTemplate-manager', // Can manage fine templates, i.e. add/edit/remove fine templates
12
+ 'fine-manager', // Can manage fines, i.e. add/edit/remove fines
13
+ 'fine-can-add', // Can add fines, but not edit or remove them
14
+ 'team-manager' // Can manage team settings, i.e. invite/remove team members, change team name, etc.
15
+ ];
6
16
  var UserRole;
7
17
  (function (UserRole) {
8
- UserRole.all = [
9
- 'person-manager',
10
- 'fineTemplate-manager',
11
- 'fine-manager',
12
- 'fine-can-add',
13
- 'team-manager'
14
- ];
15
- function formatted(role) {
18
+ /**
19
+ * Array of all available user roles.
20
+ */
21
+ UserRole.all = userRoles;
22
+ /**
23
+ * Returns the localized, human-readable name for a user role.
24
+ * @param role - The user role to format
25
+ * @param locale - The locale to use for localization
26
+ * @returns The localized role name
27
+ */
28
+ function formatted(role, locale) {
16
29
  const localizationKeyMap = {
17
30
  'person-manager': 'personManager',
18
31
  'fineTemplate-manager': 'fineTemplateManager',
@@ -20,8 +33,11 @@ var UserRole;
20
33
  'fine-can-add': 'fineCanAdd',
21
34
  'team-manager': 'teamManager'
22
35
  };
23
- return Localization_1.Localization.shared.userRole[localizationKeyMap[role]].value();
36
+ return Localization_1.Localization.shared(locale).userRole[localizationKeyMap[role]].value();
24
37
  }
25
38
  UserRole.formatted = formatted;
39
+ /**
40
+ * Builder for constructing UserRole values.
41
+ */
26
42
  UserRole.builder = new typescript_common_functionality_1.ValueTypeBuilder();
27
43
  })(UserRole || (exports.UserRole = UserRole = {}));
@@ -15,3 +15,5 @@ export * from './Pluralization';
15
15
  export * from './Team';
16
16
  export * from './User';
17
17
  export * from './UserRole';
18
+ export * from './Currency';
19
+ export * from './Locale';
@@ -31,3 +31,5 @@ __exportStar(require("./Pluralization"), exports);
31
31
  __exportStar(require("./Team"), exports);
32
32
  __exportStar(require("./User"), exports);
33
33
  __exportStar(require("./UserRole"), exports);
34
+ __exportStar(require("./Currency"), exports);
35
+ __exportStar(require("./Locale"), exports);
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const FirebaseConfiguration_1 = require("../../src/firebase/FirebaseConfiguration");
5
+ describe('FirebaseConfiguration', () => {
6
+ describe('FirebaseConfiguration.shared', () => {
7
+ it('should return a singleton instance', () => {
8
+ const instance1 = FirebaseConfiguration_1.FirebaseConfiguration.shared;
9
+ const instance2 = FirebaseConfiguration_1.FirebaseConfiguration.shared;
10
+ (0, core_1.expect)(instance1).toBeEqual(instance2);
11
+ });
12
+ it('should be an instance of FirebaseConfiguration', () => {
13
+ const instance = FirebaseConfiguration_1.FirebaseConfiguration.shared;
14
+ (0, core_1.expect)(instance instanceof FirebaseConfiguration_1.FirebaseConfiguration).toBeTrue();
15
+ });
16
+ });
17
+ describe('FirebaseConfiguration.configure', () => {
18
+ // Note: Since FirebaseConfiguration is a singleton and maintains state,
19
+ // we need to be careful with testing. In a real-world scenario, you might
20
+ // need to add a reset method for testing purposes or use dependency injection.
21
+ // For now, we'll test the error cases that don't require full configuration.
22
+ it('should throw error when configuring twice', () => {
23
+ // Create a mock configuration
24
+ const mockFirestore = {};
25
+ const mockMessaging = {
26
+ sendEachForMulticast: async () => ({
27
+ responses: [],
28
+ successCount: 0,
29
+ failureCount: 0
30
+ })
31
+ };
32
+ // We can't actually configure the shared instance in tests without affecting other tests
33
+ // This test documents the expected behavior
34
+ (0, core_1.expect)(() => {
35
+ // If already configured, this should throw
36
+ try {
37
+ FirebaseConfiguration_1.FirebaseConfiguration.shared.configure({
38
+ baseFirestoreDocument: mockFirestore,
39
+ messaging: mockMessaging
40
+ });
41
+ // If it succeeds, try configuring again to test the double-configuration error
42
+ FirebaseConfiguration_1.FirebaseConfiguration.shared.configure({
43
+ baseFirestoreDocument: mockFirestore,
44
+ messaging: mockMessaging
45
+ });
46
+ }
47
+ catch (error) {
48
+ if (error instanceof Error && error.message === 'Configuration is already configured')
49
+ throw error;
50
+ // If it's the "not configured" error, the first configure worked
51
+ // but we can't test double-configuration in this test environment
52
+ }
53
+ }).toThrow();
54
+ });
55
+ });
56
+ describe('FirebaseConfiguration getters', () => {
57
+ describe('baseFirestoreDocument', () => {
58
+ it('should throw error when not configured', () => {
59
+ // Create a fresh test to check unconfigured state
60
+ // Note: In practice, the shared instance might already be configured
61
+ try {
62
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
+ const _ = FirebaseConfiguration_1.FirebaseConfiguration.shared.baseFirestoreDocument;
64
+ // If we get here, it was already configured (expected in normal operation)
65
+ }
66
+ catch (error) {
67
+ (0, core_1.expect)(error instanceof Error).toBeTrue();
68
+ if (error instanceof Error)
69
+ (0, core_1.expect)(error.message).toBeEqual('Configuration.baseFirestoreDocument is not configured');
70
+ }
71
+ });
72
+ });
73
+ describe('messaging', () => {
74
+ it('should throw error when not configured', () => {
75
+ // Create a fresh test to check unconfigured state
76
+ try {
77
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
78
+ const _ = FirebaseConfiguration_1.FirebaseConfiguration.shared.messaging;
79
+ // If we get here, it was already configured (expected in normal operation)
80
+ }
81
+ catch (error) {
82
+ (0, core_1.expect)(error instanceof Error).toBeTrue();
83
+ if (error instanceof Error)
84
+ (0, core_1.expect)(error.message).toBeEqual('Configuration.messaging is not configured');
85
+ }
86
+ });
87
+ });
88
+ });
89
+ describe('FirebaseConfiguration behavior', () => {
90
+ it('should maintain singleton pattern', () => {
91
+ const instance = FirebaseConfiguration_1.FirebaseConfiguration.shared;
92
+ (0, core_1.expect)(instance).not.toBeNull();
93
+ (0, core_1.expect)(instance).not.toBeUndefined();
94
+ });
95
+ it('should have configure method', () => {
96
+ (0, core_1.expect)(typeof FirebaseConfiguration_1.FirebaseConfiguration.shared.configure).toBeEqual('function');
97
+ });
98
+ it('should have baseFirestoreDocument getter', () => {
99
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(FirebaseConfiguration_1.FirebaseConfiguration.shared), 'baseFirestoreDocument');
100
+ (0, core_1.expect)(descriptor).not.toBeEqual(undefined);
101
+ (0, core_1.expect)(descriptor?.get).not.toBeEqual(undefined);
102
+ });
103
+ it('should have messaging getter', () => {
104
+ const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(FirebaseConfiguration_1.FirebaseConfiguration.shared), 'messaging');
105
+ (0, core_1.expect)(descriptor).not.toBeEqual(undefined);
106
+ (0, core_1.expect)(descriptor?.get).not.toBeEqual(undefined);
107
+ });
108
+ });
109
+ describe('FirebaseConfiguration configuration object', () => {
110
+ it('should accept valid configuration structure', () => {
111
+ const mockFirestore = {};
112
+ const mockMessaging = {
113
+ sendEachForMulticast: async () => ({
114
+ responses: [],
115
+ successCount: 0,
116
+ failureCount: 0
117
+ })
118
+ };
119
+ const configuration = {
120
+ baseFirestoreDocument: mockFirestore,
121
+ messaging: mockMessaging
122
+ };
123
+ (0, core_1.expect)(configuration.baseFirestoreDocument).toBeEqual(mockFirestore);
124
+ (0, core_1.expect)(configuration.messaging).toBeEqual(mockMessaging);
125
+ });
126
+ it('should require baseFirestoreDocument in configuration', () => {
127
+ const mockMessaging = {
128
+ sendEachForMulticast: async () => ({
129
+ responses: [],
130
+ successCount: 0,
131
+ failureCount: 0
132
+ })
133
+ };
134
+ const configuration = {
135
+ baseFirestoreDocument: {},
136
+ messaging: mockMessaging
137
+ };
138
+ (0, core_1.expect)(configuration.baseFirestoreDocument).not.toBeUndefined();
139
+ });
140
+ it('should require messaging in configuration', () => {
141
+ const mockFirestore = {};
142
+ const configuration = {
143
+ baseFirestoreDocument: mockFirestore,
144
+ messaging: {
145
+ sendEachForMulticast: async () => ({
146
+ responses: [],
147
+ successCount: 0,
148
+ failureCount: 0
149
+ })
150
+ }
151
+ };
152
+ (0, core_1.expect)(configuration.messaging).not.toBeUndefined();
153
+ });
154
+ });
155
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const Firestore_1 = require("../../src/firebase/Firestore");
5
+ describe('Firestore', () => {
6
+ describe('shared singleton', () => {
7
+ it('should return the same instance on multiple calls', () => {
8
+ const instance1 = Firestore_1.Firestore.shared;
9
+ const instance2 = Firestore_1.Firestore.shared;
10
+ (0, core_1.expect)(instance1).toBe(instance2);
11
+ });
12
+ it('should create an instance', () => {
13
+ const instance = Firestore_1.Firestore.shared;
14
+ (0, core_1.expect)(instance).toBeInstanceOf(Firestore_1.Firestore);
15
+ });
16
+ });
17
+ describe('accessor methods', () => {
18
+ it('should have team method', () => {
19
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.team).toBeEqual('function');
20
+ });
21
+ it('should have user method', () => {
22
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.user).toBeEqual('function');
23
+ });
24
+ it('should have invitation method', () => {
25
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.invitation).toBeEqual('function');
26
+ });
27
+ it('should have persons method', () => {
28
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.persons).toBeEqual('function');
29
+ });
30
+ it('should have person method', () => {
31
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.person).toBeEqual('function');
32
+ });
33
+ it('should have fineTemplates method', () => {
34
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.fineTemplates).toBeEqual('function');
35
+ });
36
+ it('should have fineTemplate method', () => {
37
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.fineTemplate).toBeEqual('function');
38
+ });
39
+ it('should have fines method', () => {
40
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.fines).toBeEqual('function');
41
+ });
42
+ it('should have fine method', () => {
43
+ (0, core_1.expect)(typeof Firestore_1.Firestore.shared.fine).toBeEqual('function');
44
+ });
45
+ });
46
+ });
@@ -0,0 +1 @@
1
+ export {};