@stevenkellner/team-conduct-api 2.0.18 → 2.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/lib/src/functions/fine/add.d.ts +3 -8
  2. package/lib/src/functions/fine/add.js +1 -2
  3. package/lib/src/functions/fine/delete.d.ts +1 -6
  4. package/lib/src/functions/fine/delete.js +2 -3
  5. package/lib/src/functions/fine/update.d.ts +2 -8
  6. package/lib/src/functions/fine/update.js +1 -3
  7. package/lib/src/functions/fineTemplate/add.d.ts +3 -3
  8. package/lib/src/functions/fineTemplate/update.d.ts +3 -3
  9. package/lib/src/functions/firebaseFunctionsContext.d.ts +34 -1
  10. package/lib/src/functions/firebaseFunctionsContext.js +33 -33
  11. package/lib/src/functions/index.d.ts +10 -8
  12. package/lib/src/functions/index.js +11 -8
  13. package/lib/src/functions/notification/markNotificationAsRead.d.ts +14 -0
  14. package/lib/src/functions/notification/{subscribe.js → markNotificationAsRead.js} +5 -7
  15. package/lib/src/functions/person/kickout.d.ts +6 -6
  16. package/lib/src/functions/person/kickout.js +4 -4
  17. package/lib/src/functions/person/roleEdit.d.ts +5 -5
  18. package/lib/src/functions/person/roleEdit.js +3 -3
  19. package/lib/src/functions/{paypalMe/edit.d.ts → team/delete.d.ts} +5 -7
  20. package/lib/src/functions/{paypalMe/edit.js → team/delete.js} +4 -5
  21. package/lib/src/functions/team/new.d.ts +18 -18
  22. package/lib/src/functions/team/new.js +8 -4
  23. package/lib/src/functions/team/update.d.ts +34 -0
  24. package/lib/src/functions/team/update.js +23 -0
  25. package/lib/src/functions/user/register.d.ts +4 -0
  26. package/lib/src/functions/user/register.js +3 -1
  27. package/lib/src/functions/user/update.d.ts +26 -0
  28. package/lib/src/functions/user/update.js +15 -0
  29. package/lib/src/index.d.ts +1 -1
  30. package/lib/src/index.js +1 -1
  31. package/lib/src/locales/de.d.ts +1 -1
  32. package/lib/src/locales/de.js +6 -2
  33. package/lib/src/locales/en.d.ts +6 -2
  34. package/lib/src/locales/en.js +6 -2
  35. package/lib/src/types/{MoneyAmount.d.ts → Money.d.ts} +23 -23
  36. package/lib/src/types/{MoneyAmount.js → Money.js} +25 -25
  37. package/lib/src/types/fine/Fine.d.ts +275 -0
  38. package/lib/src/types/fine/Fine.js +318 -0
  39. package/lib/src/types/fine/FineTemplate.d.ts +154 -0
  40. package/lib/src/types/fine/FineTemplate.js +170 -0
  41. package/lib/src/types/{PayedState.d.ts → fine/PayedState.d.ts} +1 -1
  42. package/lib/src/types/{PayedState.js → fine/PayedState.js} +1 -1
  43. package/lib/src/types/fine/index.d.ts +3 -0
  44. package/lib/src/{firebase → types/fine}/index.js +3 -6
  45. package/lib/src/types/index.d.ts +7 -18
  46. package/lib/src/types/index.js +7 -18
  47. package/lib/src/types/{Localization.d.ts → localization/Localization.d.ts} +15 -43
  48. package/lib/src/types/localization/Localization.js +54 -0
  49. package/lib/src/types/localization/PluralLocalization.d.ts +23 -0
  50. package/lib/src/types/localization/PluralLocalization.js +35 -0
  51. package/lib/src/types/{Pluralization.d.ts → localization/Pluralization.d.ts} +1 -0
  52. package/lib/src/types/{Pluralization.js → localization/Pluralization.js} +1 -0
  53. package/lib/src/types/localization/ValueLocalization.d.ts +22 -0
  54. package/lib/src/types/localization/ValueLocalization.js +41 -0
  55. package/lib/src/types/localization/index.d.ts +5 -0
  56. package/lib/src/types/localization/index.js +21 -0
  57. package/lib/src/types/notification/InAppNotification.d.ts +152 -0
  58. package/lib/src/types/notification/InAppNotification.js +136 -0
  59. package/lib/src/types/notification/index.d.ts +1 -0
  60. package/lib/src/types/notification/index.js +17 -0
  61. package/lib/src/types/{Person.d.ts → person/Person.d.ts} +3 -3
  62. package/lib/src/types/{Person.js → person/Person.js} +3 -3
  63. package/lib/src/types/{PersonProperties.d.ts → person/PersonProperties.d.ts} +8 -7
  64. package/lib/src/types/{PersonProperties.js → person/PersonProperties.js} +7 -6
  65. package/lib/src/types/{PersonSignInProperties.d.ts → person/PersonSignInProperties.d.ts} +9 -11
  66. package/lib/src/types/{PersonSignInProperties.js → person/PersonSignInProperties.js} +7 -10
  67. package/lib/src/types/person/index.d.ts +3 -0
  68. package/lib/src/types/person/index.js +19 -0
  69. package/lib/src/types/{Invitation.d.ts → team/Invitation.d.ts} +1 -1
  70. package/lib/src/types/{Invitation.js → team/Invitation.js} +1 -1
  71. package/lib/src/types/team/Team.d.ts +144 -0
  72. package/lib/src/types/team/Team.js +141 -0
  73. package/lib/src/types/team/TeamRole.d.ts +30 -0
  74. package/lib/src/types/{UserRole.js → team/TeamRole.js} +16 -15
  75. package/lib/src/types/team/index.d.ts +3 -0
  76. package/lib/src/types/team/index.js +19 -0
  77. package/lib/src/types/{NotificationProperties.d.ts → user/NotificationProperties.d.ts} +8 -3
  78. package/lib/src/types/{NotificationProperties.js → user/NotificationProperties.js} +4 -0
  79. package/lib/src/types/user/User.d.ts +328 -0
  80. package/lib/src/types/user/User.js +355 -0
  81. package/lib/src/types/user/index.d.ts +2 -0
  82. package/lib/src/types/user/index.js +18 -0
  83. package/lib/src/utils/StaticUnionTypeBuilder.d.ts +9 -0
  84. package/lib/src/utils/StaticUnionTypeBuilder.js +23 -0
  85. package/lib/src/utils/index.d.ts +1 -0
  86. package/lib/src/utils/index.js +17 -0
  87. package/lib/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +4 -3
  89. package/src/functions/fine/add.ts +3 -5
  90. package/src/functions/fine/delete.ts +3 -5
  91. package/src/functions/fine/update.ts +2 -5
  92. package/src/functions/firebaseFunctionsContext.ts +40 -40
  93. package/src/functions/index.ts +11 -9
  94. package/src/functions/notification/markNotificationAsRead.ts +19 -0
  95. package/src/functions/person/add.ts +1 -1
  96. package/src/functions/person/kickout.ts +6 -6
  97. package/src/functions/person/roleEdit.ts +5 -5
  98. package/src/functions/{paypalMe/edit.ts → team/delete.ts} +5 -7
  99. package/src/functions/team/new.ts +19 -11
  100. package/src/functions/team/update.ts +40 -0
  101. package/src/functions/user/register.ts +7 -3
  102. package/src/functions/user/update.ts +29 -0
  103. package/src/index.ts +1 -1
  104. package/src/locales/de.ts +7 -3
  105. package/src/locales/en.ts +7 -3
  106. package/src/types/{MoneyAmount.ts → Money.ts} +29 -29
  107. package/src/types/fine/Fine.ts +399 -0
  108. package/src/types/fine/FineTemplate.ts +219 -0
  109. package/src/types/{PayedState.ts → fine/PayedState.ts} +2 -2
  110. package/src/types/fine/index.ts +3 -0
  111. package/src/types/index.ts +7 -18
  112. package/src/types/{Localization.ts → localization/Localization.ts} +7 -64
  113. package/src/types/localization/PluralLocalization.ts +32 -0
  114. package/src/types/{Pluralization.ts → localization/Pluralization.ts} +1 -0
  115. package/src/types/localization/ValueLocalization.ts +36 -0
  116. package/src/types/localization/index.ts +5 -0
  117. package/src/types/notification/InAppNotification.ts +184 -0
  118. package/src/types/notification/index.ts +1 -0
  119. package/src/types/{Person.ts → person/Person.ts} +3 -3
  120. package/src/types/{PersonProperties.ts → person/PersonProperties.ts} +8 -7
  121. package/src/types/{PersonSignInProperties.ts → person/PersonSignInProperties.ts} +13 -12
  122. package/src/types/person/index.ts +3 -0
  123. package/src/types/{Invitation.ts → team/Invitation.ts} +1 -1
  124. package/src/types/team/Team.ts +204 -0
  125. package/src/types/{UserRole.ts → team/TeamRole.ts} +19 -17
  126. package/src/types/team/index.ts +3 -0
  127. package/src/types/{NotificationProperties.ts → user/NotificationProperties.ts} +12 -3
  128. package/src/types/user/User.ts +451 -0
  129. package/src/types/user/index.ts +2 -0
  130. package/src/utils/StaticUnionTypeBuilder.ts +23 -0
  131. package/src/utils/index.ts +1 -0
  132. package/lib/src/firebase/FirebaseConfiguration.d.ts +0 -64
  133. package/lib/src/firebase/FirebaseConfiguration.js +0 -79
  134. package/lib/src/firebase/Firestore.d.ts +0 -201
  135. package/lib/src/firebase/Firestore.js +0 -244
  136. package/lib/src/firebase/FirestoreScheme.d.ts +0 -42
  137. package/lib/src/firebase/FirestoreScheme.js +0 -2
  138. package/lib/src/firebase/Messaging.d.ts +0 -90
  139. package/lib/src/firebase/Messaging.js +0 -2
  140. package/lib/src/firebase/checkAuthentication.d.ts +0 -38
  141. package/lib/src/firebase/checkAuthentication.js +0 -64
  142. package/lib/src/firebase/index.d.ts +0 -6
  143. package/lib/src/firebase/pushNotification.d.ts +0 -39
  144. package/lib/src/firebase/pushNotification.js +0 -88
  145. package/lib/src/functions/notification/subscribe.d.ts +0 -18
  146. package/lib/src/types/Configuration.d.ts +0 -46
  147. package/lib/src/types/Configuration.js +0 -51
  148. package/lib/src/types/Fine.d.ts +0 -71
  149. package/lib/src/types/Fine.js +0 -74
  150. package/lib/src/types/FineAmount.d.ts +0 -207
  151. package/lib/src/types/FineAmount.js +0 -238
  152. package/lib/src/types/FineTemplate.d.ts +0 -69
  153. package/lib/src/types/FineTemplate.js +0 -72
  154. package/lib/src/types/FineTemplateRepetition.d.ts +0 -87
  155. package/lib/src/types/FineTemplateRepetition.js +0 -103
  156. package/lib/src/types/Localization.js +0 -115
  157. package/lib/src/types/Team.d.ts +0 -62
  158. package/lib/src/types/Team.js +0 -64
  159. package/lib/src/types/User.d.ts +0 -221
  160. package/lib/src/types/User.js +0 -235
  161. package/lib/src/types/UserRole.d.ts +0 -29
  162. package/lib/test/firebase/FirebaseConfiguration.test.d.ts +0 -1
  163. package/lib/test/firebase/FirebaseConfiguration.test.js +0 -158
  164. package/lib/test/firebase/Firestore.test.d.ts +0 -1
  165. package/lib/test/firebase/Firestore.test.js +0 -46
  166. package/lib/test/firebase/checkAuthentication.test.d.ts +0 -1
  167. package/lib/test/firebase/checkAuthentication.test.js +0 -356
  168. package/lib/test/firebase/firebase-utils.d.ts +0 -32
  169. package/lib/test/firebase/firebase-utils.js +0 -134
  170. package/lib/test/firebase/pushNotification.test.d.ts +0 -1
  171. package/lib/test/firebase/pushNotification.test.js +0 -300
  172. package/lib/test/locales/localization.de.test.d.ts +0 -1
  173. package/lib/test/locales/localization.de.test.js +0 -144
  174. package/lib/test/locales/localization.en.test.d.ts +0 -1
  175. package/lib/test/locales/localization.en.test.js +0 -144
  176. package/lib/test/types/Configuration.test.d.ts +0 -1
  177. package/lib/test/types/Configuration.test.js +0 -84
  178. package/lib/test/types/Currency.test.d.ts +0 -1
  179. package/lib/test/types/Currency.test.js +0 -41
  180. package/lib/test/types/Fine.test.d.ts +0 -1
  181. package/lib/test/types/Fine.test.js +0 -265
  182. package/lib/test/types/FineAmount.test.d.ts +0 -1
  183. package/lib/test/types/FineAmount.test.js +0 -445
  184. package/lib/test/types/FineTemplate.test.d.ts +0 -1
  185. package/lib/test/types/FineTemplate.test.js +0 -271
  186. package/lib/test/types/FineTemplateRepetition.test.d.ts +0 -1
  187. package/lib/test/types/FineTemplateRepetition.test.js +0 -361
  188. package/lib/test/types/Invitation.test.d.ts +0 -1
  189. package/lib/test/types/Invitation.test.js +0 -269
  190. package/lib/test/types/Locale.test.d.ts +0 -1
  191. package/lib/test/types/Locale.test.js +0 -46
  192. package/lib/test/types/Localization.test.d.ts +0 -1
  193. package/lib/test/types/Localization.test.js +0 -241
  194. package/lib/test/types/MoneyAmount.test.d.ts +0 -1
  195. package/lib/test/types/MoneyAmount.test.js +0 -276
  196. package/lib/test/types/NotificationProperties.test.d.ts +0 -1
  197. package/lib/test/types/NotificationProperties.test.js +0 -258
  198. package/lib/test/types/PayedState.test.d.ts +0 -1
  199. package/lib/test/types/PayedState.test.js +0 -136
  200. package/lib/test/types/Person.test.d.ts +0 -1
  201. package/lib/test/types/Person.test.js +0 -266
  202. package/lib/test/types/PersonProperties.test.d.ts +0 -1
  203. package/lib/test/types/PersonProperties.test.js +0 -155
  204. package/lib/test/types/PersonSignInProperties.test.d.ts +0 -1
  205. package/lib/test/types/PersonSignInProperties.test.js +0 -208
  206. package/lib/test/types/Pluralization.test.d.ts +0 -1
  207. package/lib/test/types/Pluralization.test.js +0 -206
  208. package/lib/test/types/Team.test.d.ts +0 -1
  209. package/lib/test/types/Team.test.js +0 -145
  210. package/lib/test/types/User.test.d.ts +0 -1
  211. package/lib/test/types/User.test.js +0 -450
  212. package/lib/test/types/UserRole.test.d.ts +0 -1
  213. package/lib/test/types/UserRole.test.js +0 -140
  214. package/src/firebase/FirebaseConfiguration.ts +0 -99
  215. package/src/firebase/Firestore.ts +0 -258
  216. package/src/firebase/FirestoreScheme.ts +0 -41
  217. package/src/firebase/Messaging.ts +0 -93
  218. package/src/firebase/checkAuthentication.ts +0 -91
  219. package/src/firebase/index.ts +0 -7
  220. package/src/firebase/pushNotification.ts +0 -90
  221. package/src/functions/notification/subscribe.ts +0 -23
  222. package/src/types/Configuration.ts +0 -65
  223. package/src/types/Fine.ts +0 -100
  224. package/src/types/FineAmount.ts +0 -303
  225. package/src/types/FineTemplate.ts +0 -96
  226. package/src/types/FineTemplateRepetition.ts +0 -125
  227. package/src/types/Team.ts +0 -87
  228. package/src/types/User.ts +0 -302
  229. /package/lib/src/types/{Locale.d.ts → localization/Locale.d.ts} +0 -0
  230. /package/lib/src/types/{Locale.js → localization/Locale.js} +0 -0
  231. /package/src/types/{Locale.ts → localization/Locale.ts} +0 -0
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Document = exports.Collection = void 0;
4
- exports.expectThrowsFunctionsError = expectThrowsFunctionsError;
5
- exports.configureFirebase = configureFirebase;
6
- /* eslint-disable @typescript-eslint/no-explicit-any */
7
- const core_1 = require("@assertive-ts/core");
8
- const index_1 = require("../../src/types/index");
9
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
10
- const firebase_function_1 = require("@stevenkellner/firebase-function");
11
- const src_1 = require("../../src");
12
- class Collection {
13
- documents;
14
- constructor(documents) {
15
- this.documents = documents;
16
- }
17
- document(key) {
18
- const documentData = this.documents[key];
19
- if (!documentData)
20
- throw new Error(`Unexpected document key: ${key}`);
21
- return documentData;
22
- }
23
- static docs(documents) {
24
- return new Collection(documents);
25
- }
26
- }
27
- exports.Collection = Collection;
28
- class Document {
29
- collections;
30
- data;
31
- constructor(collections, data) {
32
- this.collections = collections;
33
- this.data = data;
34
- }
35
- collection(key) {
36
- const collectionData = this.collections[key];
37
- if (!collectionData)
38
- throw new Error(`Unexpected collection key: ${key}`);
39
- return collectionData;
40
- }
41
- snapshot() {
42
- return {
43
- exists: this.data !== undefined,
44
- data: this.data
45
- };
46
- }
47
- set(values) {
48
- this.data = typescript_common_functionality_1.Flattable.flatten(values);
49
- }
50
- static colls(collections) {
51
- return new Document(collections, undefined);
52
- }
53
- static data(data) {
54
- return new Document({}, data);
55
- }
56
- static empty() {
57
- return new Document({}, undefined);
58
- }
59
- static collsAndData(collections, data) {
60
- return new Document(collections, data);
61
- }
62
- static user(id, teams) {
63
- return Document.data(index_1.User.builder.build({
64
- id: id.value,
65
- signInDate: typescript_common_functionality_1.UtcDate.now.flatten,
66
- signInType: { type: 'google' },
67
- teams: teams.flatten
68
- }).flatten);
69
- }
70
- static personNotSignedIn(id) {
71
- return Document.data(index_1.Person.builder.build({
72
- id: id.guidString,
73
- properties: index_1.PersonProperties.builder.build({
74
- firstName: 'Test',
75
- lastName: 'User'
76
- }).flatten,
77
- fineIds: [],
78
- signInProperties: null
79
- }).flatten);
80
- }
81
- static person(id, userId, roles) {
82
- return Document.data(index_1.Person.builder.build({
83
- id: id.guidString,
84
- properties: index_1.PersonProperties.builder.build({
85
- firstName: 'Test',
86
- lastName: 'User'
87
- }).flatten,
88
- fineIds: [],
89
- signInProperties: index_1.PersonSignInProperties.builder.build({
90
- joinDate: typescript_common_functionality_1.UtcDate.now.flatten,
91
- userId: userId.value,
92
- notificationProperties: new index_1.NotificationProperties().flatten,
93
- roles: roles
94
- }).flatten
95
- }).flatten);
96
- }
97
- static personWithSubscriptions(id, subscriptions, tokens) {
98
- return Document.data(index_1.Person.builder.build({
99
- id: id.guidString,
100
- properties: index_1.PersonProperties.builder.build({
101
- firstName: 'Test',
102
- lastName: 'User'
103
- }).flatten,
104
- fineIds: [],
105
- signInProperties: index_1.PersonSignInProperties.builder.build({
106
- joinDate: typescript_common_functionality_1.UtcDate.now.flatten,
107
- userId: 'user-123',
108
- notificationProperties: new index_1.NotificationProperties(tokens, subscriptions).flatten,
109
- roles: []
110
- }).flatten
111
- }).flatten);
112
- }
113
- }
114
- exports.Document = Document;
115
- async function expectThrowsFunctionsError(fn, expectedCode, message = null) {
116
- try {
117
- await fn();
118
- throw new Error('Expected function to throw a FunctionsError');
119
- }
120
- catch (error) {
121
- (0, core_1.expect)(error).toBeInstanceOf(firebase_function_1.FunctionsError);
122
- (0, core_1.expect)(error.code).toBeEqual(expectedCode);
123
- if (message !== null)
124
- (0, core_1.expect)(error.message).toBeEqual(message);
125
- return error;
126
- }
127
- }
128
- function configureFirebase(collections, messaging) {
129
- src_1.FirebaseConfiguration.shared.reconfigure({
130
- firebaseFirestore: undefined,
131
- baseFirestoreDocument: Document.colls(collections),
132
- messaging: messaging
133
- });
134
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,300 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mocha_1 = require("mocha");
4
- const core_1 = require("@assertive-ts/core");
5
- const pushNotification_1 = require("../../src/firebase/pushNotification");
6
- const index_1 = require("../../src/types/index");
7
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
8
- const firebase_utils_1 = require("./firebase-utils");
9
- const src_1 = require("../../src");
10
- (0, mocha_1.describe)('pushNotification', () => {
11
- const teamId = index_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
12
- const personId = index_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
13
- (0, mocha_1.describe)('person does not exist', () => {
14
- (0, mocha_1.it)('should return without error when person does not exist', async () => {
15
- (0, firebase_utils_1.configureFirebase)({
16
- teams: firebase_utils_1.Collection.docs({
17
- [teamId.guidString]: firebase_utils_1.Document.colls({
18
- persons: firebase_utils_1.Collection.docs({
19
- [personId.guidString]: firebase_utils_1.Document.empty()
20
- })
21
- })
22
- })
23
- });
24
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
25
- title: 'Test Notification',
26
- body: 'Test Body'
27
- });
28
- });
29
- });
30
- (0, mocha_1.describe)('person is not signed in', () => {
31
- (0, mocha_1.it)('should return without sending when signInProperties is null', async () => {
32
- (0, firebase_utils_1.configureFirebase)({
33
- teams: firebase_utils_1.Collection.docs({
34
- [teamId.guidString]: firebase_utils_1.Document.colls({
35
- persons: firebase_utils_1.Collection.docs({
36
- [personId.guidString]: firebase_utils_1.Document.personNotSignedIn(personId)
37
- })
38
- })
39
- })
40
- });
41
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
42
- title: 'Test Notification',
43
- body: 'Test Body'
44
- });
45
- });
46
- });
47
- (0, mocha_1.describe)('person is not subscribed to topic', () => {
48
- (0, mocha_1.it)('should return without sending when person is not subscribed', async () => {
49
- (0, firebase_utils_1.configureFirebase)({
50
- teams: firebase_utils_1.Collection.docs({
51
- [teamId.guidString]: firebase_utils_1.Document.colls({
52
- persons: firebase_utils_1.Collection.docs({
53
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['fine-reminder'])
54
- })
55
- })
56
- })
57
- });
58
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
59
- title: 'Test Notification',
60
- body: 'Test Body'
61
- });
62
- });
63
- });
64
- (0, mocha_1.describe)('successful notification', () => {
65
- (0, mocha_1.it)('should send notification to subscribed person with tokens', async () => {
66
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
67
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token-1'), 'device-token-1');
68
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token-2'), 'device-token-2');
69
- let messagingCalled = false;
70
- (0, firebase_utils_1.configureFirebase)({
71
- teams: firebase_utils_1.Collection.docs({
72
- [teamId.guidString]: firebase_utils_1.Document.colls({
73
- persons: firebase_utils_1.Collection.docs({
74
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['new-fine', 'fine-reminder'], tokens)
75
- })
76
- })
77
- })
78
- }, {
79
- sendEachForMulticast: async (message) => {
80
- messagingCalled = true;
81
- return {
82
- responses: message.tokens.map(token => ({
83
- success: true,
84
- messageId: `msg-${token}`
85
- })),
86
- successCount: message.tokens.length,
87
- failureCount: 0
88
- };
89
- }
90
- });
91
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
92
- title: 'New Fine',
93
- body: 'You have received a new fine'
94
- });
95
- (0, core_1.expect)(messagingCalled).toBeTrue();
96
- });
97
- (0, mocha_1.it)('should send notification for different subscription topics', async () => {
98
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
99
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token-1'), 'device-token-1');
100
- let messagingCalled = false;
101
- (0, firebase_utils_1.configureFirebase)({
102
- teams: firebase_utils_1.Collection.docs({
103
- [teamId.guidString]: firebase_utils_1.Document.colls({
104
- persons: firebase_utils_1.Collection.docs({
105
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['fine-state-change'], tokens)
106
- })
107
- })
108
- })
109
- }, {
110
- sendEachForMulticast: async (message) => {
111
- messagingCalled = true;
112
- return {
113
- responses: message.tokens.map(token => ({
114
- success: true,
115
- messageId: `msg-${token}`
116
- })),
117
- successCount: message.tokens.length,
118
- failureCount: 0
119
- };
120
- }
121
- });
122
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'fine-state-change', {
123
- title: 'Fine State Changed',
124
- body: 'A fine state has been updated'
125
- });
126
- (0, core_1.expect)(messagingCalled).toBeTrue();
127
- });
128
- });
129
- (0, mocha_1.describe)('token filtering', () => {
130
- (0, mocha_1.it)('should handle person with empty token list', async () => {
131
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
132
- let messagingCalled = false;
133
- (0, firebase_utils_1.configureFirebase)({
134
- teams: firebase_utils_1.Collection.docs({
135
- [teamId.guidString]: firebase_utils_1.Document.colls({
136
- persons: firebase_utils_1.Collection.docs({
137
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['new-fine'], tokens)
138
- })
139
- })
140
- })
141
- }, {
142
- sendEachForMulticast: async (message) => {
143
- messagingCalled = true;
144
- return {
145
- responses: message.tokens.map(token => ({
146
- success: true,
147
- messageId: `msg-${token}`
148
- })),
149
- successCount: message.tokens.length,
150
- failureCount: 0
151
- };
152
- }
153
- });
154
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
155
- title: 'Test Notification',
156
- body: 'Test Body'
157
- });
158
- (0, core_1.expect)(messagingCalled).toBeTrue();
159
- });
160
- (0, mocha_1.it)('should handle person with multiple tokens, removing invalid ones', async () => {
161
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
162
- for (let i = 1; i <= 5; i++)
163
- tokens.set(index_1.NotificationProperties.TokenId.create(`device-token-${i}`), `device-token-${i}`);
164
- let messagingCalled = false;
165
- (0, firebase_utils_1.configureFirebase)({
166
- teams: firebase_utils_1.Collection.docs({
167
- [teamId.guidString]: firebase_utils_1.Document.colls({
168
- persons: firebase_utils_1.Collection.docs({
169
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['new-fine'], tokens)
170
- })
171
- })
172
- })
173
- }, {
174
- sendEachForMulticast: async (message) => {
175
- messagingCalled = true;
176
- return {
177
- responses: message.tokens.map((token, index) => ({
178
- success: index % 2 === 0,
179
- messageId: index % 2 === 0 ? `msg-${token}` : undefined,
180
- error: index % 2 === 0 ? undefined : {
181
- code: index % 4 === 1 ? 'messaging/invalid-registration-token' : 'messaging/invalid-registration-token',
182
- message: 'The provided token is invalid.',
183
- toJSON: () => ({})
184
- }
185
- })),
186
- successCount: Math.ceil(message.tokens.length / 2),
187
- failureCount: Math.floor(message.tokens.length / 2)
188
- };
189
- }
190
- });
191
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
192
- title: 'Test Notification',
193
- body: 'Test Body'
194
- });
195
- (0, core_1.expect)(messagingCalled).toBeTrue();
196
- const personSnapshot = await src_1.Firestore.shared.person(teamId, personId).snapshot();
197
- (0, core_1.expect)(personSnapshot.exists).toBeTrue();
198
- const person = index_1.Person.builder.build(personSnapshot.data);
199
- (0, core_1.expect)(person.signInProperties).not.toBeNull();
200
- const newTokens = person.signInProperties.notificationProperties.tokens.values;
201
- (0, core_1.expect)(newTokens.length).toBeEqual(3);
202
- (0, core_1.expect)(newTokens).toContainAll('device-token-1', 'device-token-3', 'device-token-5');
203
- });
204
- });
205
- (0, mocha_1.describe)('subscription matching', () => {
206
- (0, mocha_1.it)('should send when person is subscribed to multiple topics including the target', async () => {
207
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
208
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token'), 'device-token');
209
- let messagingCalled = false;
210
- (0, firebase_utils_1.configureFirebase)({
211
- teams: firebase_utils_1.Collection.docs({
212
- [teamId.guidString]: firebase_utils_1.Document.colls({
213
- persons: firebase_utils_1.Collection.docs({
214
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['new-fine', 'fine-reminder', 'fine-state-change'], tokens)
215
- })
216
- })
217
- })
218
- }, {
219
- sendEachForMulticast: async (message) => {
220
- messagingCalled = true;
221
- return {
222
- responses: message.tokens.map(token => ({
223
- success: true,
224
- messageId: `msg-${token}`
225
- })),
226
- successCount: message.tokens.length,
227
- failureCount: 0
228
- };
229
- }
230
- });
231
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'fine-reminder', {
232
- title: 'Fine Reminder',
233
- body: 'This is a reminder about your fine'
234
- });
235
- (0, core_1.expect)(messagingCalled).toBeTrue();
236
- });
237
- (0, mocha_1.it)('should not send when topic is not in subscription list', async () => {
238
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
239
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token'), 'device-token');
240
- let messagingCalled = false;
241
- (0, firebase_utils_1.configureFirebase)({
242
- teams: firebase_utils_1.Collection.docs({
243
- [teamId.guidString]: firebase_utils_1.Document.colls({
244
- persons: firebase_utils_1.Collection.docs({
245
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, ['fine-reminder'], tokens)
246
- })
247
- })
248
- })
249
- }, {
250
- sendEachForMulticast: async (message) => {
251
- messagingCalled = true;
252
- return {
253
- responses: message.tokens.map(token => ({
254
- success: true,
255
- messageId: `msg-${token}`
256
- })),
257
- successCount: message.tokens.length,
258
- failureCount: 0
259
- };
260
- }
261
- });
262
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'fine-state-change', {
263
- title: 'Fine State Changed',
264
- body: 'A fine state has been updated'
265
- });
266
- (0, core_1.expect)(messagingCalled).toBeFalse();
267
- });
268
- (0, mocha_1.it)('should handle person with no subscriptions', async () => {
269
- const tokens = new typescript_common_functionality_1.Dictionary(index_1.NotificationProperties.TokenId.builder);
270
- tokens.set(index_1.NotificationProperties.TokenId.create('device-token'), 'device-token');
271
- let messagingCalled = false;
272
- (0, firebase_utils_1.configureFirebase)({
273
- teams: firebase_utils_1.Collection.docs({
274
- [teamId.guidString]: firebase_utils_1.Document.colls({
275
- persons: firebase_utils_1.Collection.docs({
276
- [personId.guidString]: firebase_utils_1.Document.personWithSubscriptions(personId, [], tokens)
277
- })
278
- })
279
- })
280
- }, {
281
- sendEachForMulticast: async (message) => {
282
- messagingCalled = true;
283
- return {
284
- responses: message.tokens.map(token => ({
285
- success: true,
286
- messageId: `msg-${token}`
287
- })),
288
- successCount: message.tokens.length,
289
- failureCount: 0
290
- };
291
- }
292
- });
293
- await (0, pushNotification_1.pushNotification)(teamId, personId, 'new-fine', {
294
- title: 'Test Notification',
295
- body: 'Test Body'
296
- });
297
- (0, core_1.expect)(messagingCalled).toBeFalse();
298
- });
299
- });
300
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@assertive-ts/core");
4
- const types_1 = require("../../src/types");
5
- describe('Localization for de', () => {
6
- const locale = 'de';
7
- const localization = types_1.Localization.shared(locale);
8
- describe('notification.fine should be tested', () => {
9
- it('notification.fine.new should be tested', () => {
10
- (0, core_1.expect)(localization.notification.fine.new.title.value({ reason: 'fine-reason' })).toBeEqual('fine-reason');
11
- (0, core_1.expect)(localization.notification.fine.new.body.value({ amount: '10,50 €' })).toBeEqual('Du hast eine neue Strafe von 10,50 €. Bitte so schnell wie möglich zahlen.');
12
- });
13
- it('notification.fine.reminder should be tested', () => {
14
- (0, core_1.expect)(localization.notification.fine.reminder.title.value()).toBeEqual('Du hast noch offene Strafen');
15
- (0, core_1.expect)(localization.notification.fine.reminder.body.value({ amount: '10,50 €' })).toBeEqual('Bei dir sind noch 10,50 € offen. Bitte so schnell wie möglich zahlen.');
16
- });
17
- it('notification.fine.stateChange should be tested', () => {
18
- (0, core_1.expect)(localization.notification.fine.stateChange.title.value()).toBeEqual('Eine deiner Strafen hat sich geändert');
19
- (0, core_1.expect)(localization.notification.fine.stateChange.bodyPayed.value({ amount: '10,50 €', reason: 'fine-reason' })).toBeEqual('Du hast eine Strafe von 10,50 € bezahlt (fine-reason).');
20
- (0, core_1.expect)(localization.notification.fine.stateChange.bodyUnpayed.value({ amount: '10,50 €', reason: 'fine-reason' })).toBeEqual('fine-reason, 10,50 € ist noch offen.');
21
- (0, core_1.expect)(localization.notification.fine.stateChange.bodyDeleted.value({ amount: '10,50 €', reason: 'fine-reason' })).toBeEqual('fine-reason, 10,50 € wurde gelöscht.');
22
- });
23
- });
24
- describe('fineAmount should be tested', () => {
25
- it('fineAmount.item.type.crateOfBeer should be tested', () => {
26
- (0, core_1.expect)(localization.fineAmount.item.type.crateOfBeer.name.value()).toBeEqual('Kasten Bier');
27
- (0, core_1.expect)(localization.fineAmount.item.type.crateOfBeer.withCount.value(1)).toBeEqual('Ein Kasten Bier');
28
- (0, core_1.expect)(localization.fineAmount.item.type.crateOfBeer.withCount.value(4)).toBeEqual('4 Kästen Bier');
29
- (0, core_1.expect)(localization.fineAmount.item.type.crateOfBeer.withoutCount.value(1)).toBeEqual('Kasten Bier');
30
- (0, core_1.expect)(localization.fineAmount.item.type.crateOfBeer.withoutCount.value(4)).toBeEqual('Kästen Bier');
31
- });
32
- it('fineAmount.item.type.crateOfBeer should be formatted correctly', () => {
33
- (0, core_1.expect)(types_1.FineAmount.Item.Type.formatted('crateOfBeer', locale)).toBeEqual('Kasten Bier');
34
- (0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formatted(locale)).toBeEqual('Ein Kasten Bier');
35
- (0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formatted(locale)).toBeEqual('4 Kästen Bier');
36
- (0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formattedWithoutCount(locale)).toBeEqual('Kasten Bier');
37
- (0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formattedWithoutCount(locale)).toBeEqual('Kästen Bier');
38
- });
39
- });
40
- describe('fineTemplateRepetition should be tested', () => {
41
- it('fineTemplateRepetition.item.minute should be tested', () => {
42
- (0, core_1.expect)(localization.fineTemplateRepetition.item.minute.name.value()).toBeEqual('Minute');
43
- (0, core_1.expect)(localization.fineTemplateRepetition.item.minute.withCount.value(1)).toBeEqual('1 Minute');
44
- (0, core_1.expect)(localization.fineTemplateRepetition.item.minute.withCount.value(4)).toBeEqual('4 Minuten');
45
- (0, core_1.expect)(localization.fineTemplateRepetition.item.minute.withoutCount.value(1)).toBeEqual('Minute');
46
- (0, core_1.expect)(localization.fineTemplateRepetition.item.minute.withoutCount.value(4)).toBeEqual('Minuten');
47
- });
48
- it('fineTemplateRepetition.item.minute should be formatted correctly', () => {
49
- (0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('minute', locale)).toBeEqual('Minute');
50
- (0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formatted(1, locale)).toBeEqual('1 Minute');
51
- (0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formatted(4, locale)).toBeEqual('4 Minuten');
52
- (0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formattedWithoutCount(1, locale)).toBeEqual('Minute');
53
- (0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formattedWithoutCount(4, locale)).toBeEqual('Minuten');
54
- });
55
- it('fineTemplateRepetition.item.day should be tested', () => {
56
- (0, core_1.expect)(localization.fineTemplateRepetition.item.day.name.value()).toBeEqual('Tag');
57
- (0, core_1.expect)(localization.fineTemplateRepetition.item.day.withCount.value(1)).toBeEqual('1 Tag');
58
- (0, core_1.expect)(localization.fineTemplateRepetition.item.day.withCount.value(4)).toBeEqual('4 Tage');
59
- (0, core_1.expect)(localization.fineTemplateRepetition.item.day.withoutCount.value(1)).toBeEqual('Tag');
60
- (0, core_1.expect)(localization.fineTemplateRepetition.item.day.withoutCount.value(4)).toBeEqual('Tage');
61
- });
62
- it('fineTemplateRepetition.item.day should be formatted correctly', () => {
63
- (0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('day', locale)).toBeEqual('Tag');
64
- (0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formatted(1, locale)).toBeEqual('1 Tag');
65
- (0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formatted(4, locale)).toBeEqual('4 Tage');
66
- (0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formattedWithoutCount(1, locale)).toBeEqual('Tag');
67
- (0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formattedWithoutCount(4, locale)).toBeEqual('Tage');
68
- });
69
- it('fineTemplateRepetition.item.item should be tested', () => {
70
- (0, core_1.expect)(localization.fineTemplateRepetition.item.item.name.value()).toBeEqual('Teil');
71
- (0, core_1.expect)(localization.fineTemplateRepetition.item.item.withCount.value(1)).toBeEqual('1 Teil');
72
- (0, core_1.expect)(localization.fineTemplateRepetition.item.item.withCount.value(4)).toBeEqual('4 Teile');
73
- (0, core_1.expect)(localization.fineTemplateRepetition.item.item.withoutCount.value(1)).toBeEqual('Teil');
74
- (0, core_1.expect)(localization.fineTemplateRepetition.item.item.withoutCount.value(4)).toBeEqual('Teile');
75
- });
76
- it('fineTemplateRepetition.item.item should be formatted correctly', () => {
77
- (0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('item', locale)).toBeEqual('Teil');
78
- (0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formatted(1, locale)).toBeEqual('1 Teil');
79
- (0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formatted(4, locale)).toBeEqual('4 Teile');
80
- (0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formattedWithoutCount(1, locale)).toBeEqual('Teil');
81
- (0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formattedWithoutCount(4, locale)).toBeEqual('Teile');
82
- });
83
- it('fineTemplateRepetition.item.count should be tested', () => {
84
- (0, core_1.expect)(localization.fineTemplateRepetition.item.count.name.value()).toBeEqual('Anzahl');
85
- (0, core_1.expect)(localization.fineTemplateRepetition.item.count.withCount.value(1)).toBeEqual('1 mal');
86
- (0, core_1.expect)(localization.fineTemplateRepetition.item.count.withCount.value(4)).toBeEqual('4 mal');
87
- (0, core_1.expect)(localization.fineTemplateRepetition.item.count.withoutCount.value(1)).toBeEqual('mal');
88
- (0, core_1.expect)(localization.fineTemplateRepetition.item.count.withoutCount.value(4)).toBeEqual('mal');
89
- });
90
- it('fineTemplateRepetition.item.count should be formatted correctly', () => {
91
- (0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('count', locale)).toBeEqual('Anzahl');
92
- (0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formatted(1, locale)).toBeEqual('1 mal');
93
- (0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formatted(4, locale)).toBeEqual('4 mal');
94
- (0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formattedWithoutCount(1, locale)).toBeEqual('mal');
95
- (0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formattedWithoutCount(4, locale)).toBeEqual('mal');
96
- });
97
- });
98
- describe('payedState should be tested', () => {
99
- it('payedState.payed should be tested', () => {
100
- (0, core_1.expect)(localization.payedState.payed.value()).toBeEqual('Bezahlt');
101
- });
102
- it('payedState.payed should be formatted correctly', () => {
103
- (0, core_1.expect)(types_1.PayedState.formatted('payed', locale)).toBeEqual('Bezahlt');
104
- });
105
- it('payedState.notPayed should be tested', () => {
106
- (0, core_1.expect)(localization.payedState.notPayed.value()).toBeEqual('Offen');
107
- });
108
- it('payedState.notPayed should be formatted correctly', () => {
109
- (0, core_1.expect)(types_1.PayedState.formatted('notPayed', locale)).toBeEqual('Offen');
110
- });
111
- });
112
- describe('userRole should be tested', () => {
113
- it('userRole.personManager should be tested', () => {
114
- (0, core_1.expect)(localization.userRole.personManager.value()).toBeEqual('Personenmanager');
115
- });
116
- it('userRole.personManager should be formatted correctly', () => {
117
- (0, core_1.expect)(types_1.UserRole.formatted('person-manager', locale)).toBeEqual('Personenmanager');
118
- });
119
- it('userRole.fineTemplateManager should be tested', () => {
120
- (0, core_1.expect)(localization.userRole.fineTemplateManager.value()).toBeEqual('Strafvorlagenmanager');
121
- });
122
- it('userRole.fineTemplateManager should be formatted correctly', () => {
123
- (0, core_1.expect)(types_1.UserRole.formatted('fineTemplate-manager', locale)).toBeEqual('Strafvorlagenmanager');
124
- });
125
- it('userRole.fineManager should be tested', () => {
126
- (0, core_1.expect)(localization.userRole.fineManager.value()).toBeEqual('Strafenmanager');
127
- });
128
- it('userRole.fineManager should be formatted correctly', () => {
129
- (0, core_1.expect)(types_1.UserRole.formatted('fine-manager', locale)).toBeEqual('Strafenmanager');
130
- });
131
- it('userRole.fineCanAdd should be tested', () => {
132
- (0, core_1.expect)(localization.userRole.fineCanAdd.value()).toBeEqual('Kann Strafen hinzufügen');
133
- });
134
- it('userRole.fineCanAdd should be formatted correctly', () => {
135
- (0, core_1.expect)(types_1.UserRole.formatted('fine-can-add', locale)).toBeEqual('Kann Strafen hinzufügen');
136
- });
137
- it('userRole.teamManager should be tested', () => {
138
- (0, core_1.expect)(localization.userRole.teamManager.value()).toBeEqual('Teammanager');
139
- });
140
- it('userRole.teamManager should be formatted correctly', () => {
141
- (0, core_1.expect)(types_1.UserRole.formatted('team-manager', locale)).toBeEqual('Teammanager');
142
- });
143
- });
144
- });
@@ -1 +0,0 @@
1
- export {};