@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
@@ -0,0 +1,451 @@
1
+ import { Dictionary, Flattable, ITypeBuilder, Tagged, UtcDate, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+ import { Team } from '../team/Team';
3
+ import { Person } from '../person/Person';
4
+ import { NotificationProperties } from './NotificationProperties';
5
+
6
+ /**
7
+ * Represents a user in the system with associated team memberships.
8
+ *
9
+ * A user can be a member of multiple teams, and for each team, they have
10
+ * specific properties (team name and associated person ID).
11
+ */
12
+ export class User implements Flattable<User.Flatten> {
13
+
14
+ /**
15
+ * Creates a new User instance.
16
+ *
17
+ * @param id - The unique identifier for this user
18
+ * @param signInDate - The date when the user signed in
19
+ * @param signInType - The authentication method used
20
+ * @param properties - The user's profile properties
21
+ * @param settings - The user's app settings
22
+ * @param teams - Dictionary mapping team IDs to team-specific user properties
23
+ */
24
+ public constructor(
25
+ public id: User.Id,
26
+ public signInDate: UtcDate,
27
+ public signInType: User.SignInType,
28
+ public properties: User.Properties,
29
+ public settings: User.Settings,
30
+ public teams: Dictionary<Team.Id, User.TeamProperties> = new Dictionary(Team.Id.builder)
31
+ ) {}
32
+
33
+ /**
34
+ * Gets the flattened representation of this user for serialization.
35
+ */
36
+ public get flatten(): User.Flatten {
37
+ return {
38
+ id: this.id.flatten,
39
+ signInDate: this.signInDate.flatten,
40
+ signInType: this.signInType.flatten,
41
+ properties: this.properties.flatten,
42
+ settings: this.settings.flatten,
43
+ teams: this.teams.flatten
44
+ };
45
+ }
46
+ }
47
+
48
+ export namespace User {
49
+
50
+ /**
51
+ * Tagged type for user identifiers to prevent mixing with other string IDs.
52
+ */
53
+ export type Id = Tagged<string, 'user'>;
54
+
55
+ export namespace Id {
56
+
57
+ /**
58
+ * Flattened representation of a user ID (plain string).
59
+ */
60
+ export type Flatten = string;
61
+
62
+ /**
63
+ * Builder for constructing User.Id instances from strings.
64
+ */
65
+ export const builder = Tagged.builder('user' as const, new ValueTypeBuilder<string>());
66
+ }
67
+
68
+ /**
69
+ * Union type representing any sign-in method.
70
+ *
71
+ * Can be either email-based or OAuth-based authentication.
72
+ */
73
+ export type SignInType = SignInType.Email | SignInType.OAuth;
74
+
75
+ export namespace SignInType {
76
+
77
+ /**
78
+ * Represents email-based authentication sign-in type.
79
+ *
80
+ * Used when a user signs in using their email address.
81
+ */
82
+ export class Email implements Flattable<Email.Flatten> {
83
+
84
+ /**
85
+ * Creates a new email sign-in type.
86
+ *
87
+ * @param email - The email address used for authentication
88
+ */
89
+ public constructor(
90
+ public email: string
91
+ ) {}
92
+
93
+ /**
94
+ * Gets the flattened representation for serialization.
95
+ */
96
+ public get flatten(): Email.Flatten {
97
+ return {
98
+ type: 'email',
99
+ email: this.email
100
+ };
101
+ }
102
+ }
103
+
104
+ export namespace Email {
105
+
106
+ /**
107
+ * Flattened representation of email sign-in type for serialization.
108
+ */
109
+ export type Flatten = {
110
+ type: 'email',
111
+ email: string
112
+ };
113
+
114
+ /**
115
+ * Builder for constructing Email instances from flattened data.
116
+ */
117
+ export class TypeBuilder implements ITypeBuilder<Flatten, Email> {
118
+
119
+ /**
120
+ * Builds an Email instance from flattened data.
121
+ *
122
+ * @param value - The flattened email sign-in type data
123
+ * @returns A new Email instance
124
+ */
125
+ public build(value: Flatten): Email {
126
+ return new Email(value.email);
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Singleton builder instance for Email.
132
+ */
133
+ export const builder = new TypeBuilder();
134
+ }
135
+
136
+ /**
137
+ * Represents OAuth-based authentication sign-in type.
138
+ *
139
+ * Used when a user signs in using an OAuth provider (Google or Apple).
140
+ */
141
+ export class OAuth implements Flattable<OAuth.Flatten> {
142
+
143
+ /**
144
+ * Creates a new OAuth sign-in type.
145
+ *
146
+ * @param provider - The OAuth provider used for authentication ('google' or 'apple')
147
+ */
148
+ public constructor(
149
+ public provider: 'google' | 'apple'
150
+ ) {}
151
+
152
+ /**
153
+ * Gets the flattened representation for serialization.
154
+ */
155
+ public get flatten(): OAuth.Flatten {
156
+ return {
157
+ type: this.provider
158
+ };
159
+ }
160
+ }
161
+
162
+ export namespace OAuth {
163
+
164
+ /**
165
+ * Flattened representation of OAuth sign-in type for serialization.
166
+ */
167
+ export type Flatten = {
168
+ type: 'google' | 'apple'
169
+ };
170
+
171
+ /**
172
+ * Builder for constructing OAuth instances from flattened data.
173
+ */
174
+ export class TypeBuilder implements ITypeBuilder<Flatten, OAuth> {
175
+
176
+ /**
177
+ * Builds an OAuth instance from flattened data.
178
+ *
179
+ * @param value - The flattened OAuth sign-in type data
180
+ * @returns A new OAuth instance
181
+ */
182
+ public build(value: Flatten): OAuth {
183
+ return new OAuth(value.type);
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Singleton builder instance for OAuth.
189
+ */
190
+ export const builder = new TypeBuilder();
191
+ }
192
+
193
+ /**
194
+ * Flattened representation of any sign-in type for serialization.
195
+ */
196
+ export type Flatten = Email.Flatten | OAuth.Flatten;
197
+
198
+ /**
199
+ * Builder for constructing SignInType instances from flattened data.
200
+ *
201
+ * Automatically determines the correct type based on the 'type' field.
202
+ */
203
+ export class TypeBuilder implements ITypeBuilder<Flatten, SignInType> {
204
+
205
+ /**
206
+ * Builds a SignInType instance from flattened data.
207
+ *
208
+ * Routes to the appropriate builder based on the type field.
209
+ *
210
+ * @param value - The flattened sign-in type data
211
+ * @returns Either an Email or OAuth instance
212
+ */
213
+ public build(value: Flatten): SignInType {
214
+ if (value.type === 'email')
215
+ return Email.builder.build(value);
216
+ else
217
+ return OAuth.builder.build(value);
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Singleton builder instance for SignInType.
223
+ */
224
+ export const builder = new TypeBuilder();
225
+ }
226
+
227
+ /**
228
+ * Represents a user's profile information.
229
+ */
230
+ export class Properties implements Flattable<Properties.Flatten> {
231
+
232
+ /**
233
+ * Creates a new Properties instance.
234
+ *
235
+ * @param firstName - The user's first name
236
+ * @param lastName - The user's last name
237
+ * @param bio - The user's bio (null if not set)
238
+ * @param profilePictureUrl - The URL of the user's profile picture (null if not set)
239
+ */
240
+ public constructor(
241
+ public firstName: string,
242
+ public lastName: string,
243
+ public bio: string | null = null,
244
+ public profilePictureUrl: string | null = null
245
+ ) {}
246
+
247
+ /**
248
+ * Gets the flattened representation for serialization.
249
+ */
250
+ public get flatten(): Properties.Flatten {
251
+ return {
252
+ firstName: this.firstName,
253
+ lastName: this.lastName,
254
+ bio: this.bio,
255
+ profilePictureUrl: this.profilePictureUrl
256
+ };
257
+ }
258
+ }
259
+
260
+ export namespace Properties {
261
+
262
+ /**
263
+ * Flattened representation of a user's properties for serialization.
264
+ */
265
+ export type Flatten = {
266
+ firstName: string,
267
+ lastName: string,
268
+ bio: string | null,
269
+ profilePictureUrl: string | null
270
+ };
271
+
272
+ /**
273
+ * Builder for constructing Properties instances from flattened data.
274
+ */
275
+ export class TypeBuilder implements ITypeBuilder<Flatten, Properties> {
276
+
277
+ /**
278
+ * Builds a Properties instance from flattened data.
279
+ *
280
+ * @param value - The flattened user properties data
281
+ * @returns A new Properties instance
282
+ */
283
+ public build(value: Flatten): Properties {
284
+ return new Properties(value.firstName, value.lastName, value.bio, value.profilePictureUrl);
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Singleton builder instance for Properties.
290
+ */
291
+ export const builder = new TypeBuilder();
292
+ }
293
+
294
+ /**
295
+ * Properties specific to a user's membership in a particular team.
296
+ */
297
+ export class TeamProperties implements Flattable<TeamProperties.Flatten> {
298
+
299
+ /**
300
+ * Creates new team-specific user properties.
301
+ *
302
+ * @param teamId - The ID of the team
303
+ * @param teamName - The display name of the team
304
+ * @param personId - The ID of the person associated with this user in this team
305
+ */
306
+ public constructor(
307
+ public teamId: Team.Id,
308
+ public teamName: string,
309
+ public personId: Person.Id
310
+ ) {}
311
+
312
+ /**
313
+ * Gets the flattened representation of these team properties.
314
+ */
315
+ public get flatten(): TeamProperties.Flatten {
316
+ return {
317
+ teamId: this.teamId.flatten,
318
+ teamName: this.teamName,
319
+ personId: this.personId.flatten
320
+ };
321
+ }
322
+ }
323
+
324
+ export namespace TeamProperties {
325
+
326
+ /**
327
+ * Flattened representation of team properties for serialization.
328
+ */
329
+ export type Flatten = {
330
+ teamId: Team.Id.Flatten,
331
+ teamName: string,
332
+ personId: Person.Id.Flatten
333
+ };
334
+
335
+ /**
336
+ * Builder for constructing TeamProperties from flattened data.
337
+ */
338
+ export class TypeBuilder implements ITypeBuilder<Flatten, TeamProperties> {
339
+
340
+ /**
341
+ * Builds a TeamProperties instance from flattened data.
342
+ *
343
+ * @param value - The flattened team properties data
344
+ * @returns A new TeamProperties instance
345
+ */
346
+ public build(value: Flatten): TeamProperties {
347
+ return new TeamProperties(Team.Id.builder.build(value.teamId), value.teamName, Person.Id.builder.build(value.personId));
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Singleton builder instance for TeamProperties.
353
+ */
354
+ export const builder = new TypeBuilder();
355
+ }
356
+
357
+ /**
358
+ * App-level settings for a user.
359
+ */
360
+ export class Settings implements Flattable<Settings.Flatten> {
361
+
362
+ /**
363
+ * Creates new user settings.
364
+ *
365
+ * @param notification - The user's notification preferences and device tokens
366
+ */
367
+ public constructor(
368
+ public notification: NotificationProperties
369
+ ) {}
370
+
371
+ /**
372
+ * Gets the flattened representation of these user settings for serialization.
373
+ */
374
+ public get flatten(): Settings.Flatten {
375
+ return {
376
+ notification: this.notification.flatten
377
+ };
378
+ }
379
+ }
380
+
381
+ export namespace Settings {
382
+
383
+ /**
384
+ * Flattened representation of user settings for serialization.
385
+ */
386
+ export type Flatten = {
387
+ notification: NotificationProperties.Flatten
388
+ };
389
+
390
+ /**
391
+ * Builder for constructing Settings instances from flattened data.
392
+ */
393
+ export class TypeBuilder implements ITypeBuilder<Flatten, Settings> {
394
+
395
+ /**
396
+ * Builds a Settings instance from flattened data.
397
+ *
398
+ * @param value - The flattened user settings data
399
+ * @returns A new Settings instance
400
+ */
401
+ public build(value: Flatten): Settings {
402
+ return new Settings(NotificationProperties.builder.build(value.notification));
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Singleton builder instance for Settings.
408
+ */
409
+ export const builder = new TypeBuilder();
410
+ }
411
+
412
+ /**
413
+ * Flattened representation of a User for serialization.
414
+ */
415
+ export type Flatten = {
416
+ id: Id.Flatten,
417
+ signInDate: string,
418
+ signInType: SignInType.Flatten,
419
+ properties: Properties.Flatten,
420
+ settings: Settings.Flatten,
421
+ teams: Dictionary.Flatten<TeamProperties>
422
+ }
423
+
424
+ /**
425
+ * Builder for constructing User instances from flattened data.
426
+ */
427
+ export class TypeBuilder implements ITypeBuilder<Flatten, User> {
428
+
429
+ /**
430
+ * Builds a User instance from flattened data.
431
+ *
432
+ * @param value - The flattened user data
433
+ * @returns A new User instance with all teams reconstructed
434
+ */
435
+ public build(value: Flatten): User {
436
+ return new User(
437
+ Id.builder.build(value.id),
438
+ UtcDate.builder.build(value.signInDate),
439
+ SignInType.builder.build(value.signInType),
440
+ Properties.builder.build(value.properties),
441
+ Settings.builder.build(value.settings),
442
+ Dictionary.builder(Team.Id.builder, User.TeamProperties.builder).build(value.teams)
443
+ );
444
+ }
445
+ }
446
+
447
+ /**
448
+ * Singleton builder instance for User.
449
+ */
450
+ export const builder = new TypeBuilder();
451
+ }
@@ -0,0 +1,2 @@
1
+ export * from './NotificationProperties';
2
+ export * from './User';
@@ -0,0 +1,23 @@
1
+ import { ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
+
3
+ export class StaticUnionTypeBuilder<UnionT, Raw, T> implements ITypeBuilder<Raw | UnionT, T | UnionT> {
4
+
5
+ constructor(
6
+ private readonly isUnionType: (raw: Raw | UnionT) => raw is UnionT,
7
+ private readonly typeBuilder: ITypeBuilder<Raw, T>
8
+ ) {}
9
+
10
+ public build(raw: Raw | UnionT): T | UnionT {
11
+ if (this.isUnionType(raw))
12
+ return raw;
13
+ return this.typeBuilder.build(raw);
14
+ }
15
+
16
+ public static doNotUpdate<Raw, T>(typeBuilder: ITypeBuilder<Raw, T>): StaticUnionTypeBuilder<'do-not-update', Raw, T> {
17
+ return new StaticUnionTypeBuilder<'do-not-update', Raw, T>((raw): raw is 'do-not-update' => raw === 'do-not-update', typeBuilder);
18
+ }
19
+
20
+ public static doNotUpdateRemove<Raw, T>(typeBuilder: ITypeBuilder<Raw, T>): StaticUnionTypeBuilder<'do-not-update' | 'remove', Raw, T> {
21
+ return new StaticUnionTypeBuilder<'do-not-update' | 'remove', Raw, T>((raw): raw is 'do-not-update' | 'remove' => raw === 'do-not-update' || raw === 'remove', typeBuilder);
22
+ }
23
+ }
@@ -0,0 +1 @@
1
+ export * from './StaticUnionTypeBuilder';
@@ -1,64 +0,0 @@
1
- import { FirestoreScheme } from './FirestoreScheme';
2
- import { Messaging } from './Messaging';
3
- import { Firestore as FirebaseFirestore } from 'firebase-admin/firestore';
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
- */
10
- export declare class FirebaseConfiguration {
11
- /**
12
- * Singleton instance of FirebaseConfiguration.
13
- */
14
- static readonly shared: FirebaseConfiguration;
15
- private configured;
16
- private _firebaseFirestore;
17
- private _baseFirestoreDocument;
18
- private _messaging;
19
- /**
20
- * Private constructor to enforce singleton pattern.
21
- */
22
- private constructor();
23
- /**
24
- * Configures the Firebase services.
25
- *
26
- * Must be called exactly once before accessing any Firebase services.
27
- * Subsequent calls will throw an error.
28
- *
29
- * @param configuration - Configuration object containing Firestore and Messaging services
30
- * @throws Error if already configured
31
- */
32
- configure(configuration: {
33
- firebaseFirestore: FirebaseFirestore;
34
- baseFirestoreDocument: FirestoreScheme;
35
- messaging: Messaging;
36
- }): void;
37
- /**
38
- * Reconfigures the Firebase services.
39
- *
40
- * Allows updating the configuration with new services.
41
- *
42
- * @param configuration - New configuration object containing Firestore and Messaging services
43
- */
44
- reconfigure(configuration: {
45
- firebaseFirestore: FirebaseFirestore;
46
- baseFirestoreDocument: FirestoreScheme;
47
- messaging: Messaging;
48
- }): void;
49
- get firebaseFirestore(): FirebaseFirestore;
50
- /**
51
- * Gets the base Firestore document reference.
52
- *
53
- * @returns The configured Firestore document scheme
54
- * @throws Error if not yet configured
55
- */
56
- get baseFirestoreDocument(): FirestoreScheme;
57
- /**
58
- * Gets the Firebase Cloud Messaging service.
59
- *
60
- * @returns The configured Messaging service
61
- * @throws Error if not yet configured
62
- */
63
- get messaging(): Messaging;
64
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FirebaseConfiguration = void 0;
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
- */
10
- class FirebaseConfiguration {
11
- /**
12
- * Singleton instance of FirebaseConfiguration.
13
- */
14
- static shared = new FirebaseConfiguration();
15
- configured = false;
16
- _firebaseFirestore = null;
17
- _baseFirestoreDocument = null;
18
- _messaging = null;
19
- /**
20
- * Private constructor to enforce singleton pattern.
21
- */
22
- constructor() { }
23
- /**
24
- * Configures the Firebase services.
25
- *
26
- * Must be called exactly once before accessing any Firebase services.
27
- * Subsequent calls will throw an error.
28
- *
29
- * @param configuration - Configuration object containing Firestore and Messaging services
30
- * @throws Error if already configured
31
- */
32
- configure(configuration) {
33
- if (this.configured)
34
- throw new Error('Configuration is already configured');
35
- this._firebaseFirestore = configuration.firebaseFirestore;
36
- this._baseFirestoreDocument = configuration.baseFirestoreDocument;
37
- this._messaging = configuration.messaging;
38
- this.configured = true;
39
- }
40
- /**
41
- * Reconfigures the Firebase services.
42
- *
43
- * Allows updating the configuration with new services.
44
- *
45
- * @param configuration - New configuration object containing Firestore and Messaging services
46
- */
47
- reconfigure(configuration) {
48
- this.configured = false;
49
- this.configure(configuration);
50
- }
51
- get firebaseFirestore() {
52
- if (!this.configured || !this._firebaseFirestore)
53
- throw new Error('Configuration.firebaseFirestore is not configured');
54
- return this._firebaseFirestore;
55
- }
56
- /**
57
- * Gets the base Firestore document reference.
58
- *
59
- * @returns The configured Firestore document scheme
60
- * @throws Error if not yet configured
61
- */
62
- get baseFirestoreDocument() {
63
- if (!this.configured || !this._baseFirestoreDocument)
64
- throw new Error('Configuration.baseFirestoreDocument is not configured');
65
- return this._baseFirestoreDocument;
66
- }
67
- /**
68
- * Gets the Firebase Cloud Messaging service.
69
- *
70
- * @returns The configured Messaging service
71
- * @throws Error if not yet configured
72
- */
73
- get messaging() {
74
- if (!this.configured || !this._messaging)
75
- throw new Error('Configuration.messaging is not configured');
76
- return this._messaging;
77
- }
78
- }
79
- exports.FirebaseConfiguration = FirebaseConfiguration;