@stevenkellner/team-conduct-api 1.0.35 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/firebase/FirebaseConfiguration.d.ts +45 -1
- package/lib/src/firebase/FirebaseConfiguration.js +44 -0
- package/lib/src/firebase/Firestore.d.ts +196 -0
- package/lib/src/firebase/Firestore.js +235 -0
- package/lib/src/{FirestoreScheme.d.ts → firebase/FirestoreScheme.d.ts} +15 -1
- package/lib/src/firebase/Messaging.d.ts +64 -0
- package/lib/src/firebase/checkAuthentication.d.ts +37 -0
- package/lib/src/{checkAuthentication.js → firebase/checkAuthentication.js} +26 -1
- package/lib/src/firebase/index.d.ts +4 -0
- package/lib/src/firebase/index.js +4 -0
- package/lib/src/firebase/pushNotification.d.ts +39 -0
- package/lib/src/firebase/pushNotification.js +88 -0
- package/lib/src/functions/fine/add.d.ts +10 -13
- package/lib/src/functions/fine/add.js +3 -30
- package/lib/src/functions/fine/delete.d.ts +10 -13
- package/lib/src/functions/fine/delete.js +3 -27
- package/lib/src/functions/fine/update.d.ts +10 -13
- package/lib/src/functions/fine/update.js +3 -28
- package/lib/src/functions/fineTemplate/add.d.ts +6 -9
- package/lib/src/functions/fineTemplate/add.js +3 -12
- package/lib/src/functions/fineTemplate/delete.d.ts +6 -9
- package/lib/src/functions/fineTemplate/delete.js +3 -12
- package/lib/src/functions/fineTemplate/update.d.ts +6 -9
- package/lib/src/functions/fineTemplate/update.js +3 -12
- package/lib/src/functions/invitation/getInvitation.d.ts +41 -42
- package/lib/src/functions/invitation/getInvitation.js +58 -81
- package/lib/src/functions/invitation/invite.d.ts +1 -2
- package/lib/src/functions/invitation/invite.js +3 -18
- package/lib/src/functions/invitation/register.d.ts +6 -11
- package/lib/src/functions/invitation/register.js +3 -39
- package/lib/src/functions/invitation/withdraw.d.ts +1 -2
- package/lib/src/functions/invitation/withdraw.js +3 -13
- package/lib/src/functions/notification/register.d.ts +7 -10
- package/lib/src/functions/notification/register.js +3 -15
- package/lib/src/functions/notification/subscribe.d.ts +8 -11
- package/lib/src/functions/notification/subscribe.js +3 -14
- package/lib/src/functions/paypalMe/edit.d.ts +6 -9
- package/lib/src/functions/paypalMe/edit.js +3 -14
- package/lib/src/functions/person/add.d.ts +7 -10
- package/lib/src/functions/person/add.js +3 -12
- package/lib/src/functions/person/delete.d.ts +6 -9
- package/lib/src/functions/person/delete.js +3 -14
- package/lib/src/functions/person/update.d.ts +7 -10
- package/lib/src/functions/person/update.js +3 -13
- package/lib/src/functions/team/new.d.ts +9 -12
- package/lib/src/functions/team/new.js +3 -22
- package/lib/src/functions/user/kickout.d.ts +6 -9
- package/lib/src/functions/user/kickout.js +3 -25
- package/lib/src/functions/user/login.d.ts +1 -2
- package/lib/src/functions/user/login.js +3 -13
- package/lib/src/functions/user/roleEdit.d.ts +8 -11
- package/lib/src/functions/user/roleEdit.js +3 -18
- package/lib/src/index.d.ts +0 -5
- package/lib/src/index.js +0 -5
- package/lib/src/locales/de.d.ts +10 -67
- package/lib/src/locales/de.js +8 -0
- package/lib/src/locales/en.d.ts +10 -0
- package/lib/src/locales/en.js +19 -2
- package/lib/src/types/Configuration.d.ts +33 -15
- package/lib/src/types/Configuration.js +24 -12
- package/lib/src/types/Currency.d.ts +20 -0
- package/lib/src/types/Currency.js +19 -0
- package/lib/src/types/Fine.d.ts +41 -0
- package/lib/src/types/Fine.js +32 -0
- package/lib/src/types/FineAmount.d.ts +160 -9
- package/lib/src/types/FineAmount.js +128 -7
- package/lib/src/types/FineTemplate.d.ts +41 -0
- package/lib/src/types/FineTemplate.js +32 -0
- package/lib/src/types/FineTemplateRepetition.d.ts +72 -10
- package/lib/src/types/FineTemplateRepetition.js +66 -12
- package/lib/src/types/Invitation.d.ts +48 -0
- package/lib/src/types/Invitation.js +39 -0
- package/lib/src/types/Locale.d.ts +16 -0
- package/lib/src/types/Locale.js +16 -0
- package/lib/src/types/Localization.d.ts +74 -74
- package/lib/src/types/Localization.js +80 -41
- package/lib/src/types/MoneyAmount.d.ts +67 -1
- package/lib/src/types/MoneyAmount.js +62 -0
- package/lib/src/types/NotificationProperties.d.ts +70 -9
- package/lib/src/types/NotificationProperties.js +49 -5
- package/lib/src/types/PayedState.d.ts +25 -9
- package/lib/src/types/PayedState.js +17 -27
- package/lib/src/types/Person.d.ts +45 -0
- package/lib/src/types/Person.js +36 -0
- package/lib/src/types/PersonPrivateProperties.d.ts +28 -0
- package/lib/src/types/PersonPrivateProperties.js +25 -0
- package/lib/src/types/PersonSignInProperties.d.ts +30 -0
- package/lib/src/types/PersonSignInProperties.js +27 -0
- package/lib/src/types/Pluralization.d.ts +46 -0
- package/lib/src/types/Pluralization.js +46 -0
- package/lib/src/types/Team.d.ts +38 -0
- package/lib/src/types/Team.js +29 -0
- package/lib/src/types/User.d.ts +68 -3
- package/lib/src/types/User.js +59 -5
- package/lib/src/types/UserRole.d.ts +26 -4
- package/lib/src/types/UserRole.js +25 -9
- package/lib/src/types/index.d.ts +2 -0
- package/lib/src/types/index.js +2 -0
- package/lib/test/firebase/FirebaseConfiguration.test.js +155 -0
- package/lib/test/firebase/Firestore.test.js +46 -0
- package/lib/test/firebase/checkAuthentication.test.d.ts +1 -0
- package/lib/test/firebase/checkAuthentication.test.js +305 -0
- package/lib/test/firebase/firebase-utils.d.ts +32 -0
- package/lib/test/firebase/firebase-utils.js +131 -0
- package/lib/test/firebase/pushNotification.test.d.ts +1 -0
- package/lib/test/firebase/pushNotification.test.js +300 -0
- package/lib/test/locales/localization.de.test.d.ts +1 -0
- package/lib/test/locales/localization.de.test.js +144 -0
- package/lib/test/locales/localization.en.test.d.ts +1 -0
- package/lib/test/locales/localization.en.test.js +144 -0
- package/lib/test/types/Configuration.test.d.ts +1 -0
- package/lib/test/types/Configuration.test.js +84 -0
- package/lib/test/types/Currency.test.d.ts +1 -0
- package/lib/test/types/Currency.test.js +41 -0
- package/lib/test/types/Fine.test.d.ts +1 -0
- package/lib/test/types/Fine.test.js +265 -0
- package/lib/test/types/FineAmount.test.d.ts +1 -0
- package/lib/test/types/FineAmount.test.js +445 -0
- package/lib/test/types/FineTemplate.test.d.ts +1 -0
- package/lib/test/types/FineTemplate.test.js +271 -0
- package/lib/test/types/FineTemplateRepetition.test.d.ts +1 -0
- package/lib/test/types/FineTemplateRepetition.test.js +361 -0
- package/lib/test/types/Invitation.test.d.ts +1 -0
- package/lib/test/types/Invitation.test.js +269 -0
- package/lib/test/types/Locale.test.d.ts +1 -0
- package/lib/test/types/Locale.test.js +46 -0
- package/lib/test/types/Localization.test.d.ts +1 -0
- package/lib/test/types/Localization.test.js +241 -0
- package/lib/test/types/MoneyAmount.test.d.ts +1 -0
- package/lib/test/types/MoneyAmount.test.js +276 -0
- package/lib/test/types/NotificationProperties.test.d.ts +1 -0
- package/lib/test/types/NotificationProperties.test.js +258 -0
- package/lib/test/types/PayedState.test.d.ts +1 -0
- package/lib/test/types/PayedState.test.js +105 -0
- package/lib/test/types/Person.test.d.ts +1 -0
- package/lib/test/types/Person.test.js +266 -0
- package/lib/test/types/PersonPrivateProperties.test.d.ts +1 -0
- package/lib/test/types/PersonPrivateProperties.test.js +155 -0
- package/lib/test/types/PersonSignInProperties.test.d.ts +1 -0
- package/lib/test/types/PersonSignInProperties.test.js +208 -0
- package/lib/test/types/Pluralization.test.d.ts +1 -0
- package/lib/test/types/Pluralization.test.js +206 -0
- package/lib/test/types/Team.test.d.ts +1 -0
- package/lib/test/types/Team.test.js +145 -0
- package/lib/test/types/User.test.d.ts +1 -0
- package/lib/test/types/User.test.js +232 -0
- package/lib/test/types/UserRole.test.d.ts +1 -0
- package/lib/test/types/UserRole.test.js +140 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/src/firebase/FirebaseConfiguration.ts +49 -1
- package/src/firebase/Firestore.ts +248 -0
- package/src/{FirestoreScheme.ts → firebase/FirestoreScheme.ts} +15 -1
- package/src/firebase/Messaging.ts +64 -0
- package/src/{checkAuthentication.ts → firebase/checkAuthentication.ts} +39 -1
- package/src/firebase/index.ts +5 -0
- package/src/firebase/pushNotification.ts +90 -0
- package/src/functions/fine/add.ts +10 -48
- package/src/functions/fine/delete.ts +9 -43
- package/src/functions/fine/update.ts +10 -44
- package/src/functions/fineTemplate/add.ts +7 -23
- package/src/functions/fineTemplate/delete.ts +7 -23
- package/src/functions/fineTemplate/update.ts +7 -24
- package/src/functions/index.ts +0 -1
- package/src/functions/invitation/getInvitation.ts +83 -109
- package/src/functions/invitation/invite.ts +2 -25
- package/src/functions/invitation/register.ts +9 -60
- package/src/functions/invitation/withdraw.ts +2 -16
- package/src/functions/notification/register.ts +7 -26
- package/src/functions/notification/subscribe.ts +8 -26
- package/src/functions/paypalMe/edit.ts +7 -25
- package/src/functions/person/add.ts +8 -24
- package/src/functions/person/delete.ts +6 -25
- package/src/functions/person/update.ts +8 -25
- package/src/functions/team/new.ts +12 -42
- package/src/functions/user/kickout.ts +8 -41
- package/src/functions/user/login.ts +2 -16
- package/src/functions/user/roleEdit.ts +8 -32
- package/src/index.ts +0 -5
- package/src/locales/de.ts +10 -1
- package/src/locales/en.ts +21 -2
- package/src/types/Configuration.ts +33 -23
- package/src/types/Currency.ts +24 -0
- package/src/types/Fine.ts +41 -0
- package/src/types/FineAmount.ts +162 -11
- package/src/types/FineTemplate.ts +41 -0
- package/src/types/FineTemplateRepetition.ts +75 -17
- package/src/types/Invitation.ts +48 -0
- package/src/types/Locale.ts +20 -0
- package/src/types/Localization.ts +96 -41
- package/src/types/MoneyAmount.ts +67 -1
- package/src/types/NotificationProperties.ts +67 -9
- package/src/types/PayedState.ts +25 -30
- package/src/types/Person.ts +45 -0
- package/src/types/PersonPrivateProperties.ts +28 -1
- package/src/types/PersonSignInProperties.ts +30 -0
- package/src/types/Pluralization.ts +46 -0
- package/src/types/Team.ts +38 -0
- package/src/types/User.ts +70 -4
- package/src/types/UserRole.ts +32 -16
- package/src/types/index.ts +2 -0
- package/lib/src/Firestore.d.ts +0 -24
- package/lib/src/Firestore.js +0 -62
- package/lib/src/checkAuthentication.d.ts +0 -6
- package/lib/src/firebaseFunctionsContext.d.ts +0 -39
- package/lib/src/firebaseFunctionsContext.js +0 -43
- package/lib/src/pushNotification.d.ts +0 -3
- package/lib/src/pushNotification.js +0 -35
- package/lib/test/localization-utils.d.ts +0 -1
- package/lib/test/localization-utils.js +0 -24
- package/lib/test/localization.de.test.js +0 -151
- package/lib/test/localization.en.test.js +0 -145
- package/src/Firestore.ts +0 -75
- package/src/firebaseFunctionsContext.ts +0 -48
- package/src/pushNotification.ts +0 -37
- /package/lib/src/{FirestoreScheme.js → firebase/FirestoreScheme.js} +0 -0
- /package/lib/test/{localization.de.test.d.ts → firebase/FirebaseConfiguration.test.d.ts} +0 -0
- /package/lib/test/{localization.en.test.d.ts → firebase/Firestore.test.d.ts} +0 -0
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { Flattable, ObjectTypeBuilder,
|
|
2
|
-
import { FirebaseFunction
|
|
3
|
-
import { Person, PersonPrivateProperties,
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
1
|
+
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
3
|
+
import { Person, PersonPrivateProperties, User, Team } from '../../types';
|
|
5
4
|
|
|
6
|
-
export
|
|
5
|
+
export type TeamNewFunctionParameters = {
|
|
6
|
+
id: Team.Id
|
|
7
|
+
name: string
|
|
8
|
+
paypalMeLink: string | null
|
|
9
|
+
personId: Person.Id
|
|
10
|
+
personProperties: PersonPrivateProperties
|
|
11
|
+
};
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
id: Team.Id
|
|
10
|
-
name: string
|
|
11
|
-
paypalMeLink: string | null
|
|
12
|
-
personId: Person.Id
|
|
13
|
-
personProperties: PersonPrivateProperties
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class TeamNewFunction extends FirebaseFunction<TeamNewFunction.Parameters, User> {
|
|
13
|
+
export abstract class TeamNewFunctionBase extends FirebaseFunction<TeamNewFunctionParameters, User> {
|
|
18
14
|
|
|
19
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
15
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<TeamNewFunctionParameters>, TeamNewFunctionParameters>({
|
|
20
16
|
id: Team.Id.builder,
|
|
21
17
|
name: new ValueTypeBuilder(),
|
|
22
18
|
paypalMeLink: new ValueTypeBuilder(),
|
|
@@ -25,30 +21,4 @@ export class TeamNewFunction extends FirebaseFunction<TeamNewFunction.Parameters
|
|
|
25
21
|
});
|
|
26
22
|
|
|
27
23
|
public returnTypeBuilder = User.builder;
|
|
28
|
-
|
|
29
|
-
public async execute(parameters: TeamNewFunction.Parameters): Promise<User> {
|
|
30
|
-
|
|
31
|
-
if (this.userId === null)
|
|
32
|
-
throw new FunctionsError('permission-denied', 'User is not authenticated');
|
|
33
|
-
const userId = User.Id.builder.build(this.userId);
|
|
34
|
-
|
|
35
|
-
const teamSnapshot = await Firestore.shared.team(parameters.id).snapshot();
|
|
36
|
-
if (teamSnapshot.exists)
|
|
37
|
-
throw new FunctionsError('already-exists', 'Team already exists');
|
|
38
|
-
|
|
39
|
-
const userSnapshot = await Firestore.shared.user(userId).snapshot();
|
|
40
|
-
let user = new User(userId);
|
|
41
|
-
if (userSnapshot.exists)
|
|
42
|
-
user = User.builder.build(userSnapshot.data);
|
|
43
|
-
|
|
44
|
-
user.teams.set(parameters.id, new User.TeamProperties(parameters.name, parameters.personId));
|
|
45
|
-
await Firestore.shared.user(userId).set(user);
|
|
46
|
-
|
|
47
|
-
await Firestore.shared.team(parameters.id).set(new Team(parameters.id, parameters.name, parameters.paypalMeLink));
|
|
48
|
-
|
|
49
|
-
const signInProperties = new PersonSignInProperties(userId, UtcDate.now, new NotificationProperties(), UserRole.all);
|
|
50
|
-
await Firestore.shared.person(parameters.id, parameters.personId).set(new Person(parameters.personId, parameters.personProperties, [], signInProperties));
|
|
51
|
-
|
|
52
|
-
return user;
|
|
53
|
-
}
|
|
54
24
|
}
|
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
2
|
-
import {
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
+
import { Team, User } from '../../types';
|
|
3
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
5
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
6
4
|
|
|
7
|
-
export
|
|
5
|
+
export type UserKickoutFunctionParameters = {
|
|
6
|
+
teamId: Team.Id
|
|
7
|
+
userId: User.Id
|
|
8
|
+
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id
|
|
11
|
-
userId: User.Id
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class UserKickoutFunction extends FirebaseFunction<UserKickoutFunction.Parameters, void> {
|
|
10
|
+
export abstract class UserKickoutFunctionBase extends FirebaseFunction<UserKickoutFunctionParameters, void> {
|
|
16
11
|
|
|
17
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
12
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserKickoutFunctionParameters>, UserKickoutFunctionParameters>({
|
|
18
13
|
teamId: Team.Id.builder,
|
|
19
14
|
userId: User.Id.builder
|
|
20
15
|
});
|
|
21
16
|
|
|
22
17
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
23
|
-
|
|
24
|
-
public async execute(parameters: UserKickoutFunction.Parameters): Promise<void> {
|
|
25
|
-
|
|
26
|
-
const userId = await checkAuthentication(this.userId, parameters.teamId, 'team-manager');
|
|
27
|
-
|
|
28
|
-
if (userId.value === parameters.userId.value)
|
|
29
|
-
throw new FunctionsError('invalid-argument', 'You cannot kick yourself out of a team.');
|
|
30
|
-
|
|
31
|
-
const userSnapshot = await Firestore.shared.user(parameters.userId).snapshot();
|
|
32
|
-
if (!userSnapshot.exists)
|
|
33
|
-
throw new FunctionsError('not-found', 'User not found.');
|
|
34
|
-
const user = User.builder.build(userSnapshot.data);
|
|
35
|
-
|
|
36
|
-
const userTeamProperties = user.teams.getOptional(parameters.teamId);
|
|
37
|
-
if (userTeamProperties === null)
|
|
38
|
-
throw new FunctionsError('not-found', 'User is not a member of the team.');
|
|
39
|
-
|
|
40
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, userTeamProperties.personId).snapshot();
|
|
41
|
-
if (!personSnapshot.exists)
|
|
42
|
-
throw new FunctionsError('not-found', 'Person not found.');
|
|
43
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
44
|
-
|
|
45
|
-
person.signInProperties = null;
|
|
46
|
-
await Firestore.shared.person(parameters.teamId, userTeamProperties.personId).set(person);
|
|
47
|
-
|
|
48
|
-
user.teams.delete(parameters.teamId);
|
|
49
|
-
await Firestore.shared.user(parameters.userId).set(user);
|
|
50
|
-
}
|
|
51
18
|
}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { User } from '../../types';
|
|
3
3
|
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
5
4
|
|
|
6
|
-
export class
|
|
5
|
+
export abstract class UserLoginFunctionBase extends FirebaseFunction<null, User> {
|
|
7
6
|
|
|
8
7
|
public parametersBuilder = new ValueTypeBuilder<null>();
|
|
9
8
|
|
|
10
9
|
public returnTypeBuilder = User.builder;
|
|
11
|
-
|
|
12
|
-
public async execute(): Promise<User> {
|
|
13
|
-
|
|
14
|
-
if (this.userId === null)
|
|
15
|
-
throw new FunctionsError('unauthenticated', 'User is not authenticated.');
|
|
16
|
-
const userId = User.Id.builder.build(this.userId);
|
|
17
|
-
|
|
18
|
-
const userSnapshot = await Firestore.shared.user(userId).snapshot();
|
|
19
|
-
if (!userSnapshot.exists)
|
|
20
|
-
throw new FunctionsError('not-found', 'User not found.');
|
|
21
|
-
|
|
22
|
-
return User.builder.build(userSnapshot.data);
|
|
23
|
-
}
|
|
24
10
|
}
|
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
2
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
3
2
|
import { Person, Team, UserRole } from '../../types';
|
|
4
3
|
import { ArrayTypeBuilder, Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
5
|
+
export type UserRoleEditFunctionParameters = {
|
|
6
|
+
teamId: Team.Id
|
|
7
|
+
personId: Person.Id
|
|
8
|
+
roles: UserRole[]
|
|
9
|
+
};
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id
|
|
11
|
-
personId: Person.Id
|
|
12
|
-
roles: UserRole[]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class UserRoleEditFunction extends FirebaseFunction<UserRoleEditFunction.Parameters, void> {
|
|
11
|
+
export abstract class UserRoleEditFunctionBase extends FirebaseFunction<UserRoleEditFunctionParameters, void> {
|
|
17
12
|
|
|
18
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
13
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<UserRoleEditFunctionParameters>, UserRoleEditFunctionParameters>({
|
|
19
14
|
teamId: Team.Id.builder,
|
|
20
15
|
personId: Person.Id.builder,
|
|
21
16
|
roles: new ArrayTypeBuilder(new ValueTypeBuilder())
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
25
|
-
|
|
26
|
-
public async execute(parameters: UserRoleEditFunction.Parameters): Promise<void> {
|
|
27
|
-
|
|
28
|
-
const userId = await checkAuthentication(this.userId, parameters.teamId, 'team-manager');
|
|
29
|
-
|
|
30
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.personId).snapshot();
|
|
31
|
-
if (!personSnapshot.exists)
|
|
32
|
-
throw new FunctionsError('not-found', 'User does not exist');
|
|
33
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
34
|
-
|
|
35
|
-
if (person.signInProperties === null)
|
|
36
|
-
throw new FunctionsError('permission-denied', 'User is not signed in');
|
|
37
|
-
|
|
38
|
-
if (person.signInProperties.userId.value === userId.value && !parameters.roles.includes('team-manager'))
|
|
39
|
-
throw new FunctionsError('unavailable', 'User cannot remove their own team-manager role');
|
|
40
|
-
|
|
41
|
-
person.signInProperties.roles = parameters.roles;
|
|
42
|
-
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
43
|
-
}
|
|
44
20
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export * from './firebase';
|
|
2
2
|
export * from './functions';
|
|
3
3
|
export * from './types';
|
|
4
|
-
export * from './checkAuthentication';
|
|
5
|
-
export * from './firebaseFunctionsContext';
|
|
6
|
-
export * from './Firestore';
|
|
7
|
-
export * from './FirestoreScheme';
|
|
8
|
-
export * from './pushNotification';
|
package/src/locales/de.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Pluralization } from '../types/Pluralization';
|
|
2
|
+
import { LocalizationDict } from '../types/Localization';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* German (de) localization strings for the application.
|
|
6
|
+
* Contains translations for notifications, fine amounts, fine template repetitions,
|
|
7
|
+
* payment states, and user roles.
|
|
8
|
+
*
|
|
9
|
+
* Supports template variables using {{variableName}} syntax that will be replaced
|
|
10
|
+
* at runtime with actual values.
|
|
11
|
+
*/
|
|
12
|
+
export const localizationDE: LocalizationDict = {
|
|
4
13
|
notification: {
|
|
5
14
|
fine: {
|
|
6
15
|
new: {
|
package/src/locales/en.ts
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { Pluralization } from '../types/Pluralization';
|
|
2
|
+
import { SubLocalizationType } from '../types/Localization';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to ensure a value satisfies the Localization structure
|
|
6
|
+
* while preserving its concrete type (as const) for type inference.
|
|
7
|
+
* @param value - The localization object to validate
|
|
8
|
+
* @returns The same value with its inferred type preserved
|
|
9
|
+
*/
|
|
10
|
+
const satisfiesLocalization = <T extends { [Key in string]: SubLocalizationType }>(value: T): T => value;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* English (en) localization strings for the application.
|
|
14
|
+
* Contains translations for notifications, fine amounts, fine template repetitions,
|
|
15
|
+
* payment states, and user roles.
|
|
16
|
+
*
|
|
17
|
+
* Supports template variables using {{variableName}} syntax that will be replaced
|
|
18
|
+
* at runtime with actual values.
|
|
19
|
+
*
|
|
20
|
+
* This serves as the base localization - other locales should match this structure.
|
|
21
|
+
*/
|
|
22
|
+
export const localizationEN = satisfiesLocalization({
|
|
4
23
|
notification: {
|
|
5
24
|
fine: {
|
|
6
25
|
new: {
|
|
@@ -95,4 +114,4 @@ export const localizationEN = {
|
|
|
95
114
|
fineCanAdd: 'Can add fines',
|
|
96
115
|
teamManager: 'Team Manager'
|
|
97
116
|
}
|
|
98
|
-
}
|
|
117
|
+
});
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
import { Currency } from './Currency';
|
|
3
|
+
import { Locale } from './Locale';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the configuration settings that will be passed to the functions parameters.
|
|
7
|
+
* Contains currency and locale preferences.
|
|
8
|
+
*/
|
|
4
9
|
export class Configuration implements Flattable<Configuration.Flatten> {
|
|
5
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Configuration instance.
|
|
13
|
+
* @param currency - The currency to use for monetary values (EUR, USD, ...)
|
|
14
|
+
* @param locale - The locale for localization (language/region)
|
|
15
|
+
*/
|
|
6
16
|
public constructor(
|
|
7
|
-
public currency:
|
|
8
|
-
public locale:
|
|
17
|
+
public currency: Currency,
|
|
18
|
+
public locale: Locale
|
|
9
19
|
) {}
|
|
10
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Returns the flattened representation of the configuration.
|
|
23
|
+
* @returns The flattened configuration object
|
|
24
|
+
*/
|
|
11
25
|
public get flatten(): Configuration.Flatten {
|
|
12
26
|
return {
|
|
13
27
|
currency: this.currency,
|
|
@@ -18,31 +32,24 @@ export class Configuration implements Flattable<Configuration.Flatten> {
|
|
|
18
32
|
|
|
19
33
|
export namespace Configuration {
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export const all: Currency[] = ['EUR', 'USD'];
|
|
26
|
-
|
|
27
|
-
export const builder = new ValueTypeBuilder<Currency>();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type Locale = keyof typeof localizations;
|
|
31
|
-
|
|
32
|
-
export namespace Locale {
|
|
33
|
-
|
|
34
|
-
export const all: Locale[] = keys(localizations);
|
|
35
|
-
|
|
36
|
-
export const builder = new ValueTypeBuilder<Locale>();
|
|
37
|
-
}
|
|
38
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Flattened representation of Configuration for serialization.
|
|
37
|
+
*/
|
|
39
38
|
export type Flatten = {
|
|
40
39
|
currency: Currency,
|
|
41
40
|
locale: Locale
|
|
42
41
|
};
|
|
43
42
|
|
|
43
|
+
/**
|
|
44
|
+
* TypeBuilder for constructing Configuration instances from flattened data.
|
|
45
|
+
*/
|
|
44
46
|
export class TypeBuilder implements ITypeBuilder<Flatten, Configuration> {
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Builds a Configuration instance from flattened data.
|
|
50
|
+
* @param flatten - The flattened configuration data
|
|
51
|
+
* @returns A new Configuration instance
|
|
52
|
+
*/
|
|
46
53
|
public build(flatten: Flatten): Configuration {
|
|
47
54
|
return new Configuration(
|
|
48
55
|
flatten.currency,
|
|
@@ -51,5 +58,8 @@ export namespace Configuration {
|
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Singleton builder instance for Configuration.
|
|
63
|
+
*/
|
|
54
64
|
export const builder = new TypeBuilder();
|
|
55
65
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Array of all available currencies.
|
|
5
|
+
*/
|
|
6
|
+
const currencies = ['EUR', 'USD'] as const;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Supported currency types.
|
|
10
|
+
*/
|
|
11
|
+
export type Currency = typeof currencies[number];
|
|
12
|
+
|
|
13
|
+
export namespace Currency {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Array of all available currencies.
|
|
17
|
+
*/
|
|
18
|
+
export const all: readonly Currency[] = currencies;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Builder for constructing Currency values.
|
|
22
|
+
*/
|
|
23
|
+
export const builder = new ValueTypeBuilder<Currency>();
|
|
24
|
+
}
|
package/src/types/Fine.ts
CHANGED
|
@@ -2,8 +2,22 @@ import { Flattable, Guid, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/t
|
|
|
2
2
|
import { FineAmount } from './FineAmount';
|
|
3
3
|
import { PayedState } from './PayedState';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Represents a fine assigned to a person in a team.
|
|
7
|
+
*
|
|
8
|
+
* Contains information about the fine's payment status, date, reason, and monetary amount.
|
|
9
|
+
*/
|
|
5
10
|
export class Fine implements Flattable<Fine.Flatten> {
|
|
6
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new Fine instance.
|
|
14
|
+
*
|
|
15
|
+
* @param id - Unique identifier for the fine (GUID)
|
|
16
|
+
* @param payedState - Payment status ('payed' or 'notPayed')
|
|
17
|
+
* @param date - Date when the fine was issued
|
|
18
|
+
* @param reason - Description or reason for the fine
|
|
19
|
+
* @param amount - Monetary amount of the fine
|
|
20
|
+
*/
|
|
7
21
|
public constructor(
|
|
8
22
|
public id: Fine.Id,
|
|
9
23
|
public payedState: PayedState,
|
|
@@ -12,6 +26,9 @@ export class Fine implements Flattable<Fine.Flatten> {
|
|
|
12
26
|
public amount: FineAmount
|
|
13
27
|
) {}
|
|
14
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Returns the flattened representation for serialization.
|
|
31
|
+
*/
|
|
15
32
|
public get flatten(): Fine.Flatten {
|
|
16
33
|
return {
|
|
17
34
|
id: this.id.flatten,
|
|
@@ -25,15 +42,27 @@ export class Fine implements Flattable<Fine.Flatten> {
|
|
|
25
42
|
|
|
26
43
|
export namespace Fine {
|
|
27
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Tagged GUID type for fine identifiers.
|
|
47
|
+
*/
|
|
28
48
|
export type Id = Tagged<Guid, 'fine'>;
|
|
29
49
|
|
|
30
50
|
export namespace Id {
|
|
31
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Flattened representation of a fine ID (GUID string).
|
|
54
|
+
*/
|
|
32
55
|
export type Flatten = string;
|
|
33
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Type builder for Fine.Id serialization/deserialization.
|
|
59
|
+
*/
|
|
34
60
|
export const builder = Tagged.builder('fine' as const, Guid.builder);
|
|
35
61
|
}
|
|
36
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Flattened representation of a Fine for serialization.
|
|
65
|
+
*/
|
|
37
66
|
export type Flatten = {
|
|
38
67
|
id: Id.Flatten,
|
|
39
68
|
payedState: PayedState,
|
|
@@ -42,8 +71,17 @@ export namespace Fine {
|
|
|
42
71
|
amount: FineAmount.Flatten
|
|
43
72
|
};
|
|
44
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Type builder for Fine serialization/deserialization.
|
|
76
|
+
*/
|
|
45
77
|
export class TypeBuilder implements ITypeBuilder<Flatten, Fine> {
|
|
46
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Builds a Fine instance from flattened data.
|
|
81
|
+
*
|
|
82
|
+
* @param value - Flattened fine data
|
|
83
|
+
* @returns Fine instance
|
|
84
|
+
*/
|
|
47
85
|
public build(value: Flatten): Fine {
|
|
48
86
|
return new Fine(
|
|
49
87
|
Id.builder.build(value.id),
|
|
@@ -55,5 +93,8 @@ export namespace Fine {
|
|
|
55
93
|
}
|
|
56
94
|
}
|
|
57
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Singleton instance of TypeBuilder for Fine.
|
|
98
|
+
*/
|
|
58
99
|
export const builder = new TypeBuilder();
|
|
59
100
|
}
|