@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
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const UserRole_1 = require("../../src/types/UserRole");
5
+ const Locale_1 = require("../../src/types/Locale");
6
+ describe('UserRole', () => {
7
+ describe('UserRole type', () => {
8
+ it('should be valid user role types', () => {
9
+ const role1 = 'person-manager';
10
+ const role2 = 'fineTemplate-manager';
11
+ const role3 = 'fine-manager';
12
+ const role4 = 'fine-can-add';
13
+ const role5 = 'team-manager';
14
+ (0, core_1.expect)(role1).toBeEqual('person-manager');
15
+ (0, core_1.expect)(role2).toBeEqual('fineTemplate-manager');
16
+ (0, core_1.expect)(role3).toBeEqual('fine-manager');
17
+ (0, core_1.expect)(role4).toBeEqual('fine-can-add');
18
+ (0, core_1.expect)(role5).toBeEqual('team-manager');
19
+ });
20
+ });
21
+ describe('UserRole.all', () => {
22
+ it('should contain all user roles', () => {
23
+ (0, core_1.expect)(UserRole_1.UserRole.all).toBeEqual([
24
+ 'person-manager',
25
+ 'fineTemplate-manager',
26
+ 'fine-manager',
27
+ 'fine-can-add',
28
+ 'team-manager'
29
+ ]);
30
+ });
31
+ it('should have exactly 5 roles', () => {
32
+ (0, core_1.expect)(UserRole_1.UserRole.all.length).toBeEqual(5);
33
+ });
34
+ it('should contain person-manager', () => {
35
+ (0, core_1.expect)(UserRole_1.UserRole.all.includes('person-manager')).toBeTrue();
36
+ });
37
+ it('should contain fineTemplate-manager', () => {
38
+ (0, core_1.expect)(UserRole_1.UserRole.all.includes('fineTemplate-manager')).toBeTrue();
39
+ });
40
+ it('should contain fine-manager', () => {
41
+ (0, core_1.expect)(UserRole_1.UserRole.all.includes('fine-manager')).toBeTrue();
42
+ });
43
+ it('should contain fine-can-add', () => {
44
+ (0, core_1.expect)(UserRole_1.UserRole.all.includes('fine-can-add')).toBeTrue();
45
+ });
46
+ it('should contain team-manager', () => {
47
+ (0, core_1.expect)(UserRole_1.UserRole.all.includes('team-manager')).toBeTrue();
48
+ });
49
+ it('should contain only valid string types', () => {
50
+ for (const role of UserRole_1.UserRole.all) {
51
+ (0, core_1.expect)(typeof role).toBeEqual('string');
52
+ (0, core_1.expect)(role.length).toBeGreaterThan(0);
53
+ }
54
+ });
55
+ });
56
+ describe('UserRole.formatted', () => {
57
+ describe('formatted with en locale', () => {
58
+ it('should format person-manager', () => {
59
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('person-manager', 'en')).toBeEqual('Person Manager');
60
+ });
61
+ it('should format fineTemplate-manager', () => {
62
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fineTemplate-manager', 'en')).toBeEqual('Fine Template Manager');
63
+ });
64
+ it('should format fine-manager', () => {
65
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fine-manager', 'en')).toBeEqual('Fine Manager');
66
+ });
67
+ it('should format fine-can-add', () => {
68
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fine-can-add', 'en')).toBeEqual('Can add fines');
69
+ });
70
+ it('should format team-manager', () => {
71
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('team-manager', 'en')).toBeEqual('Team Manager');
72
+ });
73
+ });
74
+ describe('formatted with de locale', () => {
75
+ it('should format person-manager', () => {
76
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('person-manager', 'de')).toBeEqual('Personenmanager');
77
+ });
78
+ it('should format fineTemplate-manager', () => {
79
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fineTemplate-manager', 'de')).toBeEqual('Strafvorlagenmanager');
80
+ });
81
+ it('should format fine-manager', () => {
82
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fine-manager', 'de')).toBeEqual('Strafenmanager');
83
+ });
84
+ it('should format fine-can-add', () => {
85
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('fine-can-add', 'de')).toBeEqual('Kann Strafen hinzufügen');
86
+ });
87
+ it('should format team-manager', () => {
88
+ (0, core_1.expect)(UserRole_1.UserRole.formatted('team-manager', 'de')).toBeEqual('Teammanager');
89
+ });
90
+ });
91
+ describe('formatted for all roles and locales', () => {
92
+ it('should format all roles in all locales', () => {
93
+ for (const role of UserRole_1.UserRole.all) {
94
+ for (const locale of Locale_1.Locale.all) {
95
+ const formatted = UserRole_1.UserRole.formatted(role, locale);
96
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
97
+ (0, core_1.expect)(formatted.length).toBeGreaterThan(0);
98
+ }
99
+ }
100
+ });
101
+ it('should return different values for different locales', () => {
102
+ for (const role of UserRole_1.UserRole.all) {
103
+ const formattedEN = UserRole_1.UserRole.formatted(role, 'en');
104
+ const formattedDE = UserRole_1.UserRole.formatted(role, 'de');
105
+ // Most roles should have different translations
106
+ // (though some might be similar, so we just check they're strings)
107
+ (0, core_1.expect)(typeof formattedEN).toBeEqual('string');
108
+ (0, core_1.expect)(typeof formattedDE).toBeEqual('string');
109
+ }
110
+ });
111
+ });
112
+ });
113
+ describe('UserRole.builder', () => {
114
+ it('should build valid user role from string', () => {
115
+ const role1 = UserRole_1.UserRole.builder.build('person-manager');
116
+ const role2 = UserRole_1.UserRole.builder.build('team-manager');
117
+ (0, core_1.expect)(role1).toBeEqual('person-manager');
118
+ (0, core_1.expect)(role2).toBeEqual('team-manager');
119
+ });
120
+ it('should preserve user role value', () => {
121
+ for (const role of UserRole_1.UserRole.all) {
122
+ const built = UserRole_1.UserRole.builder.build(role);
123
+ (0, core_1.expect)(built).toBeEqual(role);
124
+ }
125
+ });
126
+ it('should build all user roles', () => {
127
+ const roles = [
128
+ 'person-manager',
129
+ 'fineTemplate-manager',
130
+ 'fine-manager',
131
+ 'fine-can-add',
132
+ 'team-manager'
133
+ ];
134
+ for (const role of roles) {
135
+ const built = UserRole_1.UserRole.builder.build(role);
136
+ (0, core_1.expect)(built).toBeEqual(role);
137
+ }
138
+ });
139
+ });
140
+ });
@@ -1 +1 @@
1
- {"root":["../index.ts","../src/Firestore.ts","../src/FirestoreScheme.ts","../src/checkAuthentication.ts","../src/firebaseFunctionsContext.ts","../src/index.ts","../src/pushNotification.ts","../src/firebase/FirebaseConfiguration.ts","../src/firebase/Messaging.ts","../src/firebase/index.ts","../src/functions/index.ts","../src/functions/fine/add.ts","../src/functions/fine/delete.ts","../src/functions/fine/update.ts","../src/functions/fineTemplate/add.ts","../src/functions/fineTemplate/delete.ts","../src/functions/fineTemplate/update.ts","../src/functions/invitation/getInvitation.ts","../src/functions/invitation/invite.ts","../src/functions/invitation/register.ts","../src/functions/invitation/withdraw.ts","../src/functions/notification/register.ts","../src/functions/notification/subscribe.ts","../src/functions/paypalMe/edit.ts","../src/functions/person/add.ts","../src/functions/person/delete.ts","../src/functions/person/update.ts","../src/functions/team/new.ts","../src/functions/user/kickout.ts","../src/functions/user/login.ts","../src/functions/user/roleEdit.ts","../src/locales/de.ts","../src/locales/en.ts","../src/types/Configuration.ts","../src/types/Fine.ts","../src/types/FineAmount.ts","../src/types/FineTemplate.ts","../src/types/FineTemplateRepetition.ts","../src/types/Invitation.ts","../src/types/Localization.ts","../src/types/MoneyAmount.ts","../src/types/NotificationProperties.ts","../src/types/PayedState.ts","../src/types/Person.ts","../src/types/PersonPrivateProperties.ts","../src/types/PersonSignInProperties.ts","../src/types/Pluralization.ts","../src/types/Team.ts","../src/types/User.ts","../src/types/UserRole.ts","../src/types/index.ts","../test/localization-utils.ts","../test/localization.de.test.ts","../test/localization.en.test.ts"],"version":"5.8.3"}
1
+ {"root":["../index.ts","../src/index.ts","../src/firebase/FirebaseConfiguration.ts","../src/firebase/Firestore.ts","../src/firebase/FirestoreScheme.ts","../src/firebase/Messaging.ts","../src/firebase/checkAuthentication.ts","../src/firebase/index.ts","../src/firebase/pushNotification.ts","../src/functions/index.ts","../src/functions/fine/add.ts","../src/functions/fine/delete.ts","../src/functions/fine/update.ts","../src/functions/fineTemplate/add.ts","../src/functions/fineTemplate/delete.ts","../src/functions/fineTemplate/update.ts","../src/functions/invitation/getInvitation.ts","../src/functions/invitation/invite.ts","../src/functions/invitation/register.ts","../src/functions/invitation/withdraw.ts","../src/functions/notification/register.ts","../src/functions/notification/subscribe.ts","../src/functions/paypalMe/edit.ts","../src/functions/person/add.ts","../src/functions/person/delete.ts","../src/functions/person/update.ts","../src/functions/team/new.ts","../src/functions/user/kickout.ts","../src/functions/user/login.ts","../src/functions/user/roleEdit.ts","../src/locales/de.ts","../src/locales/en.ts","../src/types/Configuration.ts","../src/types/Currency.ts","../src/types/Fine.ts","../src/types/FineAmount.ts","../src/types/FineTemplate.ts","../src/types/FineTemplateRepetition.ts","../src/types/Invitation.ts","../src/types/Locale.ts","../src/types/Localization.ts","../src/types/MoneyAmount.ts","../src/types/NotificationProperties.ts","../src/types/PayedState.ts","../src/types/Person.ts","../src/types/PersonPrivateProperties.ts","../src/types/PersonSignInProperties.ts","../src/types/Pluralization.ts","../src/types/Team.ts","../src/types/User.ts","../src/types/UserRole.ts","../src/types/index.ts","../test/firebase/FirebaseConfiguration.test.ts","../test/firebase/Firestore.test.ts","../test/firebase/checkAuthentication.test.ts","../test/firebase/firebase-utils.ts","../test/firebase/pushNotification.test.ts","../test/locales/localization.de.test.ts","../test/locales/localization.en.test.ts","../test/types/Configuration.test.ts","../test/types/Currency.test.ts","../test/types/Fine.test.ts","../test/types/FineAmount.test.ts","../test/types/FineTemplate.test.ts","../test/types/FineTemplateRepetition.test.ts","../test/types/Invitation.test.ts","../test/types/Locale.test.ts","../test/types/Localization.test.ts","../test/types/MoneyAmount.test.ts","../test/types/NotificationProperties.test.ts","../test/types/PayedState.test.ts","../test/types/Person.test.ts","../test/types/PersonPrivateProperties.test.ts","../test/types/PersonSignInProperties.test.ts","../test/types/Pluralization.test.ts","../test/types/Team.test.ts","../test/types/User.test.ts","../test/types/UserRole.test.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stevenkellner/team-conduct-api",
3
- "version": "1.0.36",
3
+ "version": "2.0.1",
4
4
  "description": "Firebase API for Team Conduct",
5
5
  "license": "MIT",
6
6
  "author": "Steven Kellner",
@@ -27,17 +27,18 @@
27
27
  },
28
28
  "devDependencies": {
29
29
  "@assertive-ts/core": "^2.1.0",
30
- "@eslint/compat": "^1.3.1",
31
- "@eslint/eslintrc": "^3.3.1",
32
- "@eslint/js": "^9.30.0",
30
+ "@eslint/compat": "^2.0.0",
31
+ "@eslint/eslintrc": "^3.3.3",
32
+ "@eslint/js": "^9.39.2",
33
33
  "@types/mocha": "^10.0.10",
34
- "@typescript-eslint/eslint-plugin": "^8.35.0",
35
- "@typescript-eslint/parser": "^8.35.0",
36
- "eslint": "^9.30.0",
34
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
35
+ "@typescript-eslint/parser": "^8.50.1",
36
+ "eslint": "^9.39.2",
37
37
  "eslint-config-google": "^0.14.0",
38
38
  "eslint-plugin-import": "^2.32.0",
39
- "mocha": "^11.7.1",
39
+ "mocha": "^11.7.5",
40
+ "npm-check-updates": "^19.2.0",
40
41
  "ts-node": "^10.9.2",
41
- "typescript": "^5.8.3"
42
+ "typescript": "^5.9.3"
42
43
  }
43
44
  }
@@ -1,8 +1,17 @@
1
- import { FirestoreScheme } from '../FirestoreScheme';
1
+ import { FirestoreScheme } from './FirestoreScheme';
2
2
  import { Messaging } from './Messaging';
3
3
 
4
+ /**
5
+ * Singleton configuration manager for Firebase services.
6
+ *
7
+ * Provides centralized access to Firestore document reference and Firebase Cloud Messaging.
8
+ * Must be configured once before accessing services.
9
+ */
4
10
  export class FirebaseConfiguration {
5
11
 
12
+ /**
13
+ * Singleton instance of FirebaseConfiguration.
14
+ */
6
15
  public static readonly shared = new FirebaseConfiguration();
7
16
 
8
17
  private configured: boolean = false;
@@ -11,8 +20,20 @@ export class FirebaseConfiguration {
11
20
 
12
21
  private _messaging: Messaging | null = null;
13
22
 
23
+ /**
24
+ * Private constructor to enforce singleton pattern.
25
+ */
14
26
  private constructor() {}
15
27
 
28
+ /**
29
+ * Configures the Firebase services.
30
+ *
31
+ * Must be called exactly once before accessing any Firebase services.
32
+ * Subsequent calls will throw an error.
33
+ *
34
+ * @param configuration - Configuration object containing Firestore and Messaging services
35
+ * @throws Error if already configured
36
+ */
16
37
  public configure(configuration: {
17
38
  baseFirestoreDocument: FirestoreScheme,
18
39
  messaging: Messaging
@@ -24,12 +45,39 @@ export class FirebaseConfiguration {
24
45
  this.configured = true;
25
46
  }
26
47
 
48
+ /**
49
+ * Reconfigures the Firebase services.
50
+ *
51
+ * Allows updating the configuration with new services.
52
+ *
53
+ * @param configuration - New configuration object containing Firestore and Messaging services
54
+ */
55
+ public reconfigure(configuration: {
56
+ baseFirestoreDocument: FirestoreScheme,
57
+ messaging: Messaging
58
+ }) {
59
+ this.configured = false;
60
+ this.configure(configuration);
61
+ }
62
+
63
+ /**
64
+ * Gets the base Firestore document reference.
65
+ *
66
+ * @returns The configured Firestore document scheme
67
+ * @throws Error if not yet configured
68
+ */
27
69
  public get baseFirestoreDocument(): FirestoreScheme {
28
70
  if (!this.configured || !this._baseFirestoreDocument)
29
71
  throw new Error('Configuration.baseFirestoreDocument is not configured');
30
72
  return this._baseFirestoreDocument;
31
73
  }
32
74
 
75
+ /**
76
+ * Gets the Firebase Cloud Messaging service.
77
+ *
78
+ * @returns The configured Messaging service
79
+ * @throws Error if not yet configured
80
+ */
33
81
  public get messaging(): Messaging {
34
82
  if (!this.configured || !this._messaging)
35
83
  throw new Error('Configuration.messaging is not configured');
@@ -0,0 +1,248 @@
1
+ import { FirestoreCollection, FirestoreDocument } from '@stevenkellner/firebase-function';
2
+ import { FirestoreScheme } from './FirestoreScheme';
3
+ import { Fine, FineTemplate, Invitation, Person, User, Team } from '../types';
4
+ import { FirebaseConfiguration } from '.';
5
+
6
+ /**
7
+ * Accessor class for Firestore documents and collections.
8
+ *
9
+ * Provides type-safe access to Firestore database documents and collections
10
+ * following the schema defined in {@link FirestoreScheme}.
11
+ *
12
+ * Uses a singleton pattern to ensure consistent access to the Firestore instance.
13
+ * All methods return strongly-typed Firestore references that can be used for
14
+ * database operations.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Access a team document
19
+ * const teamDoc = Firestore.shared.team(teamId);
20
+ *
21
+ * // Access a person in a team
22
+ * const personDoc = Firestore.shared.person(teamId, personId);
23
+ *
24
+ * // Access all fines in a team
25
+ * const finesCollection = Firestore.shared.fines(teamId);
26
+ * ```
27
+ *
28
+ * @remarks
29
+ * Requires {@link FirebaseConfiguration} to be configured before use.
30
+ * All document and collection references are lazy and don't perform any
31
+ * database operations until explicitly called.
32
+ */
33
+ export class Firestore {
34
+
35
+ /**
36
+ * Protected constructor to enforce singleton pattern.
37
+ * Use {@link Firestore.shared} to get an instance.
38
+ */
39
+ protected constructor() {}
40
+
41
+ /**
42
+ * The singleton instance of the Firestore accessor.
43
+ *
44
+ * @private
45
+ */
46
+ private static sharedInstance: Firestore | null = null;
47
+
48
+ /**
49
+ * Gets the singleton instance of the Firestore accessor.
50
+ *
51
+ * Creates the instance on first access and returns the same instance
52
+ * on subsequent calls.
53
+ *
54
+ * @returns The singleton Firestore accessor instance
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * const firestore = Firestore.shared;
59
+ * const teamDoc = firestore.team(teamId);
60
+ * ```
61
+ */
62
+ public static get shared(): Firestore {
63
+ if (!Firestore.sharedInstance)
64
+ Firestore.sharedInstance = new Firestore();
65
+ return Firestore.sharedInstance;
66
+ }
67
+
68
+ /**
69
+ * Gets the base Firestore schema from the configured Firebase instance.
70
+ *
71
+ * Accesses the global FirebaseConfiguration to retrieve the root document
72
+ * reference for all database operations.
73
+ *
74
+ * @returns The base Firestore schema with typed collections
75
+ *
76
+ * @throws {Error} If FirebaseConfiguration has not been configured
77
+ *
78
+ * @private
79
+ */
80
+ private get base(): FirestoreScheme {
81
+ return FirebaseConfiguration.shared.baseFirestoreDocument;
82
+ }
83
+
84
+ /**
85
+ * Gets a reference to a team document.
86
+ *
87
+ * @param id - The unique identifier of the team
88
+ * @returns A typed Firestore document reference for the team
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const teamDoc = Firestore.shared.team(teamId);
93
+ * const teamData = await teamDoc.get();
94
+ * ```
95
+ */
96
+ public team(id: Team.Id): FirestoreDocument<Team> {
97
+ return this.base
98
+ .collection('teams')
99
+ .document(id.guidString) as FirestoreDocument<Team>;
100
+ }
101
+
102
+ /**
103
+ * Gets a reference to a user document.
104
+ *
105
+ * @param id - The unique identifier of the user
106
+ * @returns A typed Firestore document reference for the user
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const userDoc = Firestore.shared.user(userId);
111
+ * const userData = await userDoc.get();
112
+ * ```
113
+ */
114
+ public user(id: User.Id): FirestoreDocument<User> {
115
+ return this.base
116
+ .collection('users')
117
+ .document(id.value);
118
+ }
119
+
120
+ /**
121
+ * Gets a reference to an invitation document.
122
+ *
123
+ * @param id - The unique identifier of the invitation
124
+ * @returns A typed Firestore document reference for the invitation
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * const invitationDoc = Firestore.shared.invitation(invitationId);
129
+ * const invitationData = await invitationDoc.get();
130
+ * ```
131
+ */
132
+ public invitation(id: Invitation.Id): FirestoreDocument<Invitation> {
133
+ return this.base
134
+ .collection('invitations')
135
+ .document(id.value);
136
+ }
137
+
138
+ /**
139
+ * Gets a reference to the persons collection within a team.
140
+ *
141
+ * @param teamId - The unique identifier of the team
142
+ * @returns A typed Firestore collection reference for persons in the team
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const personsCollection = Firestore.shared.persons(teamId);
147
+ * const allPersons = await personsCollection.getAll();
148
+ * ```
149
+ */
150
+ public persons(teamId: Team.Id): FirestoreCollection<{ [x: string]: FirestoreDocument<Person, never>; }> {
151
+ return this.base
152
+ .collection('teams')
153
+ .document(teamId.guidString)
154
+ .collection('persons');
155
+ }
156
+
157
+ /**
158
+ * Gets a reference to a specific person document within a team.
159
+ *
160
+ * @param teamId - The unique identifier of the team
161
+ * @param id - The unique identifier of the person
162
+ * @returns A typed Firestore document reference for the person
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const personDoc = Firestore.shared.person(teamId, personId);
167
+ * const personData = await personDoc.get();
168
+ * ```
169
+ */
170
+ public person(teamId: Team.Id, id: Person.Id): FirestoreDocument<Person> {
171
+ return this.persons(teamId)
172
+ .document(id.guidString);
173
+ }
174
+
175
+ /**
176
+ * Gets a reference to the fine templates collection within a team.
177
+ *
178
+ * @param teamId - The unique identifier of the team
179
+ * @returns A typed Firestore collection reference for fine templates in the team
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const templatesCollection = Firestore.shared.fineTemplates(teamId);
184
+ * const allTemplates = await templatesCollection.getAll();
185
+ * ```
186
+ */
187
+ public fineTemplates(teamId: Team.Id): FirestoreCollection<{ [x: string]: FirestoreDocument<FineTemplate, never>; }> {
188
+ return this.base
189
+ .collection('teams')
190
+ .document(teamId.guidString)
191
+ .collection('fineTemplates');
192
+ }
193
+
194
+ /**
195
+ * Gets a reference to a specific fine template document within a team.
196
+ *
197
+ * @param teamId - The unique identifier of the team
198
+ * @param id - The unique identifier of the fine template
199
+ * @returns A typed Firestore document reference for the fine template
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const templateDoc = Firestore.shared.fineTemplate(teamId, templateId);
204
+ * const templateData = await templateDoc.get();
205
+ * ```
206
+ */
207
+ public fineTemplate(teamId: Team.Id, id: FineTemplate.Id): FirestoreDocument<FineTemplate> {
208
+ return this.fineTemplates(teamId)
209
+ .document(id.guidString);
210
+ }
211
+
212
+ /**
213
+ * Gets a reference to the fines collection within a team.
214
+ *
215
+ * @param teamId - The unique identifier of the team
216
+ * @returns A typed Firestore collection reference for fines in the team
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * const finesCollection = Firestore.shared.fines(teamId);
221
+ * const allFines = await finesCollection.getAll();
222
+ * ```
223
+ */
224
+ public fines(teamId: Team.Id): FirestoreCollection<{ [x: string]: FirestoreDocument<Fine, never>; }> {
225
+ return this.base
226
+ .collection('teams')
227
+ .document(teamId.guidString)
228
+ .collection('fines');
229
+ }
230
+
231
+ /**
232
+ * Gets a reference to a specific fine document within a team.
233
+ *
234
+ * @param teamId - The unique identifier of the team
235
+ * @param id - The unique identifier of the fine
236
+ * @returns A typed Firestore document reference for the fine
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * const fineDoc = Firestore.shared.fine(teamId, fineId);
241
+ * const fineData = await fineDoc.get();
242
+ * ```
243
+ */
244
+ public fine(teamId: Team.Id, id: Fine.Id): FirestoreDocument<Fine> {
245
+ return this.fines(teamId)
246
+ .document(id.guidString);
247
+ }
248
+ }
@@ -1,6 +1,20 @@
1
1
  import { FirestoreCollection, FirestoreDocument } from '@stevenkellner/firebase-function';
2
- import { Fine, FineTemplate, Invitation, Person, Team, User } from './types';
2
+ import { Fine, FineTemplate, Invitation, Person, Team, User } from '../types';
3
3
 
4
+ /**
5
+ * Type definition for the Firestore database schema.
6
+ *
7
+ * Defines the hierarchical structure of the Firestore database:
8
+ * - **users**: Collection of user documents indexed by User.Id
9
+ * - **invitations**: Collection of invitation documents indexed by Invitation.Id
10
+ * - **teams**: Collection of team documents indexed by Team.Id, each containing:
11
+ * - **persons**: Subcollection of person documents indexed by Person.Id
12
+ * - **fineTemplates**: Subcollection of fine template documents indexed by FineTemplate.Id
13
+ * - **fines**: Subcollection of fine documents indexed by Fine.Id
14
+ *
15
+ * This type ensures type-safe access to Firestore collections and documents
16
+ * throughout the application.
17
+ */
4
18
  export type FirestoreScheme = FirestoreDocument<never, {
5
19
  users: FirestoreCollection<{
6
20
  [UserId in string]: FirestoreDocument<User>
@@ -1,29 +1,93 @@
1
+ /**
2
+ * Represents a notification payload for Firebase Cloud Messaging.
3
+ */
1
4
  export interface Notification {
5
+ /**
6
+ * The notification title.
7
+ */
2
8
  title?: string;
9
+ /**
10
+ * The notification body text.
11
+ */
3
12
  body?: string;
13
+ /**
14
+ * URL of an image to be displayed in the notification.
15
+ */
4
16
  imageUrl?: string;
5
17
  }
6
18
 
19
+ /**
20
+ * Response from sending batch messages to multiple devices.
21
+ */
7
22
  export interface BatchResponse {
23
+ /**
24
+ * Array of individual message responses.
25
+ */
8
26
  responses: {
27
+ /**
28
+ * Whether the message was sent successfully.
29
+ */
9
30
  success: boolean;
31
+ /**
32
+ * The message ID if successful.
33
+ */
10
34
  messageId?: string;
35
+ /**
36
+ * Error information if the message failed to send.
37
+ */
11
38
  error?: {
39
+ /**
40
+ * Error code identifier.
41
+ */
12
42
  code: string;
43
+ /**
44
+ * Human-readable error message.
45
+ */
13
46
  message: string;
47
+ /**
48
+ * Optional stack trace for debugging.
49
+ */
14
50
  stack?: string;
51
+ /**
52
+ * Converts the error to a JSON object.
53
+ */
15
54
  toJSON(): object;
16
55
  };
17
56
  }[];
57
+ /**
58
+ * Number of messages sent successfully.
59
+ */
18
60
  successCount: number;
61
+ /**
62
+ * Number of messages that failed to send.
63
+ */
19
64
  failureCount: number;
20
65
  }
21
66
 
67
+ /**
68
+ * Message to be sent to multiple device tokens.
69
+ */
22
70
  export interface MulticastMessage {
71
+ /**
72
+ * Array of device registration tokens to send the message to.
73
+ */
23
74
  tokens: string[];
75
+ /**
76
+ * Optional notification payload to include in the message.
77
+ */
24
78
  notification?: Notification;
25
79
  }
26
80
 
81
+ /**
82
+ * Firebase Cloud Messaging service interface.
83
+ */
27
84
  export interface Messaging {
85
+ /**
86
+ * Sends a multicast message to multiple devices.
87
+ *
88
+ * @param message - The multicast message containing tokens and notification
89
+ * @param dryRun - If true, validates the message without actually sending it
90
+ * @returns Promise resolving to batch response with success/failure details
91
+ */
28
92
  sendEachForMulticast(message: MulticastMessage, dryRun?: boolean): Promise<BatchResponse>;
29
93
  }