@stevenkellner/team-conduct-api 1.0.36 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +40 -43
- package/lib/src/functions/invitation/getInvitation.js +57 -88
- 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 +81 -118
- 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,154 +1,117 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Invitation, Person, PersonPrivateProperties, Team } from '../../types';
|
|
3
|
-
import {
|
|
4
|
-
import { compactMap, Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
3
|
+
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
5
4
|
|
|
6
|
-
export class
|
|
5
|
+
export abstract class InvitationGetInvitationFunctionBase extends FirebaseFunction<Invitation.Id, InvitationGetInvitationFunctionReturnType> {
|
|
7
6
|
|
|
8
7
|
public parametersBuilder = Invitation.Id.builder;
|
|
9
8
|
|
|
10
|
-
public returnTypeBuilder =
|
|
11
|
-
|
|
12
|
-
public async execute(invitationId: Invitation.Id): Promise<InvitationGetInvitationFunction.ReturnType> {
|
|
13
|
-
|
|
14
|
-
if (this.userId === null)
|
|
15
|
-
throw new FunctionsError('unauthenticated', 'User not authenticated');
|
|
16
|
-
|
|
17
|
-
const invitationSnapshot = await Firestore.shared.invitation(invitationId).snapshot();
|
|
18
|
-
if (!invitationSnapshot.exists)
|
|
19
|
-
throw new FunctionsError('not-found', 'Invitation not found');
|
|
20
|
-
const invitation = Invitation.builder.build(invitationSnapshot.data);
|
|
21
|
-
|
|
22
|
-
const teamSnapshot = await Firestore.shared.team(invitation.teamId).snapshot();
|
|
23
|
-
if (!teamSnapshot.exists)
|
|
24
|
-
throw new FunctionsError('not-found', 'Team not found');
|
|
25
|
-
const team = Team.builder.build(teamSnapshot.data);
|
|
26
|
-
|
|
27
|
-
if (invitation.personId !== null)
|
|
28
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, invitation.personId);
|
|
29
|
-
|
|
30
|
-
const personSnapshots = await Firestore.shared.persons(invitation.teamId).documentSnapshots();
|
|
31
|
-
const persons = compactMap(personSnapshots, personSnapshot => {
|
|
32
|
-
if (!personSnapshot.exists)
|
|
33
|
-
return null;
|
|
34
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
35
|
-
if (person.signInProperties !== null)
|
|
36
|
-
return null;
|
|
37
|
-
return {
|
|
38
|
-
id: person.id,
|
|
39
|
-
properties: person.properties
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, persons);
|
|
43
|
-
}
|
|
9
|
+
public returnTypeBuilder = InvitationGetInvitationFunctionReturnType.builder;
|
|
44
10
|
}
|
|
45
11
|
|
|
46
|
-
export
|
|
12
|
+
export type PersonIdOrPersons = {
|
|
13
|
+
personId: Person.Id;
|
|
14
|
+
} | {
|
|
15
|
+
persons: {
|
|
16
|
+
id: Person.Id,
|
|
17
|
+
properties: PersonPrivateProperties,
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export namespace PersonIdOrPersons {
|
|
47
22
|
|
|
48
|
-
export type
|
|
49
|
-
personId: Person.Id
|
|
23
|
+
export type Flatten = {
|
|
24
|
+
personId: Person.Id.Flatten,
|
|
50
25
|
} | {
|
|
51
26
|
persons: {
|
|
52
|
-
id: Person.Id,
|
|
53
|
-
properties: PersonPrivateProperties,
|
|
27
|
+
id: Person.Id.Flatten,
|
|
28
|
+
properties: PersonPrivateProperties.Flatten,
|
|
54
29
|
}[];
|
|
55
30
|
};
|
|
31
|
+
}
|
|
56
32
|
|
|
57
|
-
|
|
33
|
+
export class InvitationGetInvitationFunctionReturnType implements Flattable<InvitationGetInvitationFunctionReturnType.Flatten> {
|
|
58
34
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
properties: PersonPrivateProperties.Flatten,
|
|
65
|
-
}[];
|
|
66
|
-
};
|
|
67
|
-
}
|
|
35
|
+
private constructor(
|
|
36
|
+
public teamId: Team.Id,
|
|
37
|
+
public teamName: string,
|
|
38
|
+
private personIdOrPersons: PersonIdOrPersons
|
|
39
|
+
) {}
|
|
68
40
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
) {}
|
|
76
|
-
|
|
77
|
-
public static from(teamId: Team.Id, teamName: string, personId: Person.Id): ReturnType;
|
|
78
|
-
public static from(teamId: Team.Id, teamName: string, persons: { id: Person.Id, properties: PersonPrivateProperties }[]): ReturnType;
|
|
79
|
-
public static from(teamId: Team.Id, teamName: string, personIdOrPersons: Person.Id | { id: Person.Id, properties: PersonPrivateProperties }[]): ReturnType {
|
|
80
|
-
if (Array.isArray(personIdOrPersons)) {
|
|
81
|
-
return new ReturnType(teamId, teamName, {
|
|
82
|
-
persons: personIdOrPersons
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return new ReturnType(teamId, teamName, {
|
|
86
|
-
personId: personIdOrPersons
|
|
41
|
+
public static from(teamId: Team.Id, teamName: string, personId: Person.Id): InvitationGetInvitationFunctionReturnType;
|
|
42
|
+
public static from(teamId: Team.Id, teamName: string, persons: { id: Person.Id, properties: PersonPrivateProperties }[]): InvitationGetInvitationFunctionReturnType;
|
|
43
|
+
public static from(teamId: Team.Id, teamName: string, personIdOrPersons: Person.Id | { id: Person.Id, properties: PersonPrivateProperties }[]): InvitationGetInvitationFunctionReturnType {
|
|
44
|
+
if (Array.isArray(personIdOrPersons)) {
|
|
45
|
+
return new InvitationGetInvitationFunctionReturnType(teamId, teamName, {
|
|
46
|
+
persons: personIdOrPersons
|
|
87
47
|
});
|
|
88
48
|
}
|
|
49
|
+
return new InvitationGetInvitationFunctionReturnType(teamId, teamName, {
|
|
50
|
+
personId: personIdOrPersons
|
|
51
|
+
});
|
|
52
|
+
}
|
|
89
53
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
54
|
+
public get personId(): Person.Id | null {
|
|
55
|
+
if (!('personId' in this.personIdOrPersons))
|
|
56
|
+
return null;
|
|
57
|
+
return this.personIdOrPersons.personId;
|
|
58
|
+
}
|
|
95
59
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
60
|
+
public get persons(): {
|
|
61
|
+
id: Person.Id,
|
|
62
|
+
properties: PersonPrivateProperties,
|
|
63
|
+
}[] | null {
|
|
64
|
+
if (!('persons' in this.personIdOrPersons))
|
|
65
|
+
return null;
|
|
66
|
+
return this.personIdOrPersons.persons;
|
|
67
|
+
}
|
|
104
68
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
teamId: this.teamId.flatten,
|
|
109
|
-
teamName: this.teamName,
|
|
110
|
-
personId: this.personIdOrPersons.personId.flatten
|
|
111
|
-
};
|
|
112
|
-
}
|
|
69
|
+
public get flatten(): InvitationGetInvitationFunctionReturnType.Flatten {
|
|
70
|
+
if ('personId' in this.personIdOrPersons) {
|
|
113
71
|
return {
|
|
114
72
|
teamId: this.teamId.flatten,
|
|
115
73
|
teamName: this.teamName,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
74
|
+
personId: this.personIdOrPersons.personId.flatten
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
teamId: this.teamId.flatten,
|
|
79
|
+
teamName: this.teamName,
|
|
80
|
+
persons: this.personIdOrPersons.persons.map(person => ({
|
|
81
|
+
id: person.id.flatten,
|
|
82
|
+
properties: person.properties.flatten
|
|
83
|
+
}))
|
|
121
84
|
}
|
|
122
85
|
}
|
|
86
|
+
}
|
|
123
87
|
|
|
124
|
-
|
|
88
|
+
export namespace InvitationGetInvitationFunctionReturnType {
|
|
125
89
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
90
|
+
export type Flatten = {
|
|
91
|
+
teamId: Team.Id.Flatten,
|
|
92
|
+
teamName: string
|
|
93
|
+
} & PersonIdOrPersons.Flatten;
|
|
130
94
|
|
|
131
|
-
|
|
95
|
+
export class TypeBuilder implements ITypeBuilder<Flatten, InvitationGetInvitationFunctionReturnType> {
|
|
132
96
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
Team.Id.builder.build(value.teamId),
|
|
137
|
-
value.teamName,
|
|
138
|
-
Person.Id.builder.build(value.personId)
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
return ReturnType.from(
|
|
97
|
+
public build(value: Flatten): InvitationGetInvitationFunctionReturnType {
|
|
98
|
+
if ('personId' in value) {
|
|
99
|
+
return InvitationGetInvitationFunctionReturnType.from(
|
|
142
100
|
Team.Id.builder.build(value.teamId),
|
|
143
101
|
value.teamName,
|
|
144
|
-
|
|
145
|
-
id: Person.Id.builder.build(person.id),
|
|
146
|
-
properties: PersonPrivateProperties.builder.build(person.properties)
|
|
147
|
-
}))
|
|
102
|
+
Person.Id.builder.build(value.personId)
|
|
148
103
|
);
|
|
149
104
|
}
|
|
105
|
+
return InvitationGetInvitationFunctionReturnType.from(
|
|
106
|
+
Team.Id.builder.build(value.teamId),
|
|
107
|
+
value.teamName,
|
|
108
|
+
value.persons.map(person => ({
|
|
109
|
+
id: Person.Id.builder.build(person.id),
|
|
110
|
+
properties: PersonPrivateProperties.builder.build(person.properties)
|
|
111
|
+
}))
|
|
112
|
+
);
|
|
150
113
|
}
|
|
151
|
-
|
|
152
|
-
export const builder = new TypeBuilder();
|
|
153
114
|
}
|
|
115
|
+
|
|
116
|
+
export const builder = new TypeBuilder();
|
|
154
117
|
}
|
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Invitation } from '../../types';
|
|
3
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
5
3
|
|
|
6
|
-
export class
|
|
4
|
+
export abstract class InvitationInviteFunctionBase extends FirebaseFunction<Invitation, Invitation.Id> {
|
|
7
5
|
|
|
8
6
|
public parametersBuilder = Invitation.builder;
|
|
9
7
|
|
|
10
8
|
public returnTypeBuilder = Invitation.Id.builder;
|
|
11
|
-
|
|
12
|
-
public async execute(invitation: Invitation): Promise<Invitation.Id> {
|
|
13
|
-
|
|
14
|
-
await checkAuthentication(this.userId, invitation.teamId, 'team-manager');
|
|
15
|
-
|
|
16
|
-
if (invitation.personId !== null) {
|
|
17
|
-
|
|
18
|
-
const personSnapshot = await Firestore.shared.person(invitation.teamId, invitation.personId).snapshot();
|
|
19
|
-
if (!personSnapshot.exists)
|
|
20
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
21
|
-
|
|
22
|
-
if (personSnapshot.data.signInProperties !== null)
|
|
23
|
-
throw new FunctionsError('already-exists', 'Person already has an account');
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const invitationId = invitation.createId();
|
|
28
|
-
await Firestore.shared.invitation(invitationId).set(invitation);
|
|
29
|
-
|
|
30
|
-
return invitationId;
|
|
31
|
-
}
|
|
32
9
|
}
|
|
@@ -1,69 +1,18 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
2
|
-
import { Person,
|
|
3
|
-
import {
|
|
4
|
-
import { Flattable, ObjectTypeBuilder, UtcDate } from '@stevenkellner/typescript-common-functionality';
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
+
import { Person, Team, User } from '../../types';
|
|
3
|
+
import { Flattable, ObjectTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
5
4
|
|
|
6
|
-
export
|
|
5
|
+
export type InvitationRegisterFunctionParameters = {
|
|
6
|
+
teamId: Team.Id
|
|
7
|
+
personId: Person.Id
|
|
8
|
+
};
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
teamId: Team.Id
|
|
10
|
-
personId: Person.Id
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class InvitationRegisterFunction extends FirebaseFunction<InvitationRegisterFunction.Parameters, User> {
|
|
10
|
+
export abstract class InvitationRegisterFunctionBase extends FirebaseFunction<InvitationRegisterFunctionParameters, User> {
|
|
15
11
|
|
|
16
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
12
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<InvitationRegisterFunctionParameters>, InvitationRegisterFunctionParameters>({
|
|
17
13
|
teamId: Team.Id.builder,
|
|
18
14
|
personId: Person.Id.builder
|
|
19
15
|
});
|
|
20
16
|
|
|
21
17
|
public returnTypeBuilder = User.builder;
|
|
22
|
-
|
|
23
|
-
public async execute(parameters: InvitationRegisterFunction.Parameters): Promise<User> {
|
|
24
|
-
|
|
25
|
-
if (this.userId === null)
|
|
26
|
-
throw new FunctionsError('unauthenticated', 'User not authenticated');
|
|
27
|
-
const userId = User.Id.builder.build(this.userId);
|
|
28
|
-
const user = await this.getUser(userId);
|
|
29
|
-
|
|
30
|
-
if (user.teams.has(parameters.teamId))
|
|
31
|
-
throw new FunctionsError('already-exists', 'User already in team');
|
|
32
|
-
|
|
33
|
-
const teamSnapshot = await Firestore.shared.team(parameters.teamId).snapshot();
|
|
34
|
-
if (!teamSnapshot.exists)
|
|
35
|
-
throw new FunctionsError('not-found', 'Team not found');
|
|
36
|
-
const team = Team.builder.build(teamSnapshot.data);
|
|
37
|
-
|
|
38
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.personId).snapshot();
|
|
39
|
-
if (!personSnapshot.exists)
|
|
40
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
41
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
42
|
-
|
|
43
|
-
if (person.signInProperties !== null)
|
|
44
|
-
throw new FunctionsError('already-exists', 'Person already registered');
|
|
45
|
-
|
|
46
|
-
await this.removeUserInvitation(parameters.teamId, parameters.personId);
|
|
47
|
-
|
|
48
|
-
user.teams.set(parameters.teamId, new User.TeamProperties(team.name, parameters.personId));
|
|
49
|
-
await Firestore.shared.user(userId).set(user);
|
|
50
|
-
|
|
51
|
-
person.signInProperties = new PersonSignInProperties(userId, UtcDate.now);
|
|
52
|
-
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
53
|
-
|
|
54
|
-
return user;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private async getUser(userId: User.Id): Promise<User> {
|
|
58
|
-
const userSnapshot = await Firestore.shared.user(userId).snapshot();
|
|
59
|
-
if (userSnapshot.exists)
|
|
60
|
-
return User.builder.build(userSnapshot.data);
|
|
61
|
-
return new User(userId);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private async removeUserInvitation(teamId: Team.Id, personId: Person.Id) {
|
|
65
|
-
const invitation = new Invitation(teamId, personId);
|
|
66
|
-
const invitationId = invitation.createId();
|
|
67
|
-
await Firestore.shared.invitation(invitationId).remove();
|
|
68
|
-
}
|
|
69
18
|
}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Invitation } from '../../types';
|
|
3
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
5
3
|
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
6
4
|
|
|
7
|
-
export class
|
|
5
|
+
export abstract class InvitationWithdrawFunctionBase extends FirebaseFunction<Invitation, void> {
|
|
8
6
|
|
|
9
7
|
public parametersBuilder = Invitation.builder;
|
|
10
8
|
|
|
11
9
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
12
|
-
|
|
13
|
-
public async execute(invitation: Invitation): Promise<void> {
|
|
14
|
-
|
|
15
|
-
await checkAuthentication(this.userId, invitation.teamId, 'team-manager');
|
|
16
|
-
|
|
17
|
-
const invitationId = invitation.createId();
|
|
18
|
-
const invitationSnapshot = await Firestore.shared.invitation(invitationId).snapshot();
|
|
19
|
-
if (!invitationSnapshot.exists)
|
|
20
|
-
throw new FunctionsError('not-found', 'Invitation not found');
|
|
21
|
-
|
|
22
|
-
await Firestore.shared.invitation(invitationId).remove();
|
|
23
|
-
}
|
|
24
10
|
}
|
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
3
2
|
import { Person, Team } from '../../types';
|
|
4
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
personId: Person.Id,
|
|
12
|
-
token: string
|
|
13
|
-
}
|
|
5
|
+
export type NotificationRegisterFunctionParameters = {
|
|
6
|
+
teamId: Team.Id,
|
|
7
|
+
personId: Person.Id,
|
|
8
|
+
token: string
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
export class
|
|
11
|
+
export abstract class NotificationRegisterFunctionBase extends FirebaseFunction<NotificationRegisterFunctionParameters, void> {
|
|
17
12
|
|
|
18
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
13
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<NotificationRegisterFunctionParameters>, NotificationRegisterFunctionParameters>({
|
|
19
14
|
teamId: Team.Id.builder,
|
|
20
15
|
personId: Person.Id.builder,
|
|
21
16
|
token: new ValueTypeBuilder()
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
25
|
-
|
|
26
|
-
public async execute(parameters: NotificationRegisterFunction.Parameters): Promise<void> {
|
|
27
|
-
|
|
28
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.personId).snapshot();
|
|
29
|
-
if (!personSnapshot.exists)
|
|
30
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
31
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
32
|
-
|
|
33
|
-
if (person.signInProperties === null)
|
|
34
|
-
throw new FunctionsError('unauthenticated', 'Person not signed in');
|
|
35
|
-
|
|
36
|
-
person.signInProperties.notificationProperties.tokens.set(NotificationProperties.TokenId.create(parameters.token), parameters.token);
|
|
37
|
-
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
38
|
-
}
|
|
39
20
|
}
|
|
@@ -1,38 +1,20 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { NotificationProperties, Person, Team } from '../../types';
|
|
3
3
|
import { ArrayTypeBuilder, Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { Firestore } from '../../Firestore';
|
|
5
4
|
|
|
6
|
-
export
|
|
5
|
+
export type NotificationSubscribeFunctionParameters = {
|
|
6
|
+
teamId: Team.Id,
|
|
7
|
+
personId: Person.Id,
|
|
8
|
+
subscriptions: NotificationProperties.Subscription[]
|
|
9
|
+
};
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
teamId: Team.Id,
|
|
10
|
-
personId: Person.Id,
|
|
11
|
-
subscriptions: NotificationProperties.Subscription[]
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class NotificationSubscribeFunction extends FirebaseFunction<NotificationSubscribeFunction.Parameters, void> {
|
|
11
|
+
export abstract class NotificationSubscribeFunctionBase extends FirebaseFunction<NotificationSubscribeFunctionParameters, void> {
|
|
16
12
|
|
|
17
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
13
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<NotificationSubscribeFunctionParameters>, NotificationSubscribeFunctionParameters>({
|
|
18
14
|
teamId: Team.Id.builder,
|
|
19
15
|
personId: Person.Id.builder,
|
|
20
16
|
subscriptions: new ArrayTypeBuilder(new ValueTypeBuilder())
|
|
21
17
|
});
|
|
22
18
|
|
|
23
19
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
24
|
-
|
|
25
|
-
public async execute(parameters: NotificationSubscribeFunction.Parameters): Promise<void> {
|
|
26
|
-
|
|
27
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.personId).snapshot();
|
|
28
|
-
if (!personSnapshot.exists)
|
|
29
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
30
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
31
|
-
|
|
32
|
-
if (person.signInProperties === null)
|
|
33
|
-
throw new FunctionsError('unauthenticated', 'Person not signed in');
|
|
34
|
-
|
|
35
|
-
person.signInProperties.notificationProperties.subscriptions = parameters.subscriptions;
|
|
36
|
-
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
37
|
-
}
|
|
38
20
|
}
|
|
@@ -1,36 +1,18 @@
|
|
|
1
1
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { FirebaseFunction
|
|
2
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
3
3
|
import { Team } from '../../types';
|
|
4
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
5
|
+
export type PaypalMeEditFunctionParameters = {
|
|
6
|
+
teamId: Team.Id;
|
|
7
|
+
paypalMeLink: string | null;
|
|
8
|
+
};
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id;
|
|
11
|
-
paypalMeLink: string | null;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class PaypalMeEditFunction extends FirebaseFunction<PaypalMeEditFunction.Parameters, void> {
|
|
10
|
+
export abstract class PaypalMeEditFunctionBase extends FirebaseFunction<PaypalMeEditFunctionParameters, void> {
|
|
16
11
|
|
|
17
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
12
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<PaypalMeEditFunctionParameters>, PaypalMeEditFunctionParameters>({
|
|
18
13
|
teamId: Team.Id.builder,
|
|
19
14
|
paypalMeLink: new ValueTypeBuilder()
|
|
20
15
|
});
|
|
21
16
|
|
|
22
17
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
23
|
-
|
|
24
|
-
public async execute(parameters: PaypalMeEditFunction.Parameters): Promise<void> {
|
|
25
|
-
|
|
26
|
-
await checkAuthentication(this.userId, parameters.teamId, 'team-manager');
|
|
27
|
-
|
|
28
|
-
const teamSnapshot = await Firestore.shared.team(parameters.teamId).snapshot();
|
|
29
|
-
if (!teamSnapshot.exists)
|
|
30
|
-
throw new FunctionsError('not-found', 'Team not found');
|
|
31
|
-
const team = Team.builder.build(teamSnapshot.data);
|
|
32
|
-
|
|
33
|
-
team.paypalMeLink = parameters.paypalMeLink;
|
|
34
|
-
await Firestore.shared.team(parameters.teamId).set(team);
|
|
35
|
-
}
|
|
36
18
|
}
|
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Person, PersonPrivateProperties, Team } from '../../types';
|
|
3
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
5
|
+
export type PersonAddFunctionParameters = {
|
|
6
|
+
teamId: Team.Id
|
|
7
|
+
id: Person.Id,
|
|
8
|
+
properties: PersonPrivateProperties
|
|
9
|
+
};
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id
|
|
11
|
-
id: Person.Id,
|
|
12
|
-
properties: PersonPrivateProperties
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class PersonAddFunction extends FirebaseFunction<PersonAddFunction.Parameters, void> {
|
|
11
|
+
export abstract class PersonAddFunctionBase extends FirebaseFunction<PersonAddFunctionParameters, void> {
|
|
17
12
|
|
|
18
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
13
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<PersonAddFunctionParameters>, PersonAddFunctionParameters>({
|
|
19
14
|
teamId: Team.Id.builder,
|
|
20
15
|
id: Person.Id.builder,
|
|
21
16
|
properties: PersonPrivateProperties.builder
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
25
|
-
|
|
26
|
-
public async execute(parameters: PersonAddFunction.Parameters): Promise<void> {
|
|
27
|
-
|
|
28
|
-
await checkAuthentication(this.userId, parameters.teamId, 'person-manager');
|
|
29
|
-
|
|
30
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.id).snapshot();
|
|
31
|
-
if (personSnapshot.exists)
|
|
32
|
-
throw new FunctionsError('already-exists', 'Person already exists');
|
|
33
|
-
|
|
34
|
-
await Firestore.shared.person(parameters.teamId, parameters.id).set(new Person(parameters.id, parameters.properties));
|
|
35
|
-
}
|
|
36
20
|
}
|
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Person, Team } from '../../types';
|
|
3
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id,
|
|
11
|
-
id: Person.Id
|
|
12
|
-
}
|
|
5
|
+
export type PersonDeleteFunctionParameters = {
|
|
6
|
+
teamId: Team.Id,
|
|
7
|
+
id: Person.Id
|
|
13
8
|
}
|
|
14
9
|
|
|
15
|
-
export class
|
|
10
|
+
export abstract class PersonDeleteFunctionBase extends FirebaseFunction<PersonDeleteFunctionParameters, void> {
|
|
16
11
|
|
|
17
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
12
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<PersonDeleteFunctionParameters>, PersonDeleteFunctionParameters>({
|
|
18
13
|
teamId: Team.Id.builder,
|
|
19
14
|
id: Person.Id.builder
|
|
20
15
|
});
|
|
21
16
|
|
|
22
17
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
23
|
-
|
|
24
|
-
public async execute(parameters: PersonDeleteFunction.Parameters): Promise<void> {
|
|
25
|
-
|
|
26
|
-
await checkAuthentication(this.userId, parameters.teamId, 'person-manager');
|
|
27
|
-
|
|
28
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.id).snapshot();
|
|
29
|
-
if (!personSnapshot.exists)
|
|
30
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
31
|
-
|
|
32
|
-
if (personSnapshot.data.signInProperties !== null)
|
|
33
|
-
throw new FunctionsError('failed-precondition', 'Person is signed in');
|
|
34
|
-
|
|
35
|
-
await Firestore.shared.person(parameters.teamId, parameters.id).remove();
|
|
36
|
-
}
|
|
37
18
|
}
|
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
import { FirebaseFunction
|
|
1
|
+
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Person, PersonPrivateProperties, Team } from '../../types';
|
|
3
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
|
-
import { Firestore } from '../../Firestore';
|
|
6
4
|
|
|
7
|
-
export
|
|
5
|
+
export type PersonUpdateFunctionParameters = {
|
|
6
|
+
teamId: Team.Id,
|
|
7
|
+
id: Person.Id,
|
|
8
|
+
properties: PersonPrivateProperties
|
|
9
|
+
};
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
teamId: Team.Id,
|
|
11
|
-
id: Person.Id,
|
|
12
|
-
properties: PersonPrivateProperties
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class PersonUpdateFunction extends FirebaseFunction<PersonUpdateFunction.Parameters, void> {
|
|
11
|
+
export abstract class PersonUpdateFunctionBase extends FirebaseFunction<PersonUpdateFunctionParameters, void> {
|
|
17
12
|
|
|
18
|
-
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<
|
|
13
|
+
public parametersBuilder = new ObjectTypeBuilder<Flattable.Flatten<PersonUpdateFunctionParameters>, PersonUpdateFunctionParameters>({
|
|
19
14
|
teamId: Team.Id.builder,
|
|
20
15
|
id: Person.Id.builder,
|
|
21
16
|
properties: PersonPrivateProperties.builder
|
|
22
17
|
});
|
|
23
18
|
|
|
24
19
|
public returnTypeBuilder = new ValueTypeBuilder<void>();
|
|
25
|
-
|
|
26
|
-
public async execute(parameters: PersonUpdateFunction.Parameters): Promise<void> {
|
|
27
|
-
|
|
28
|
-
await checkAuthentication(this.userId, parameters.teamId, 'person-manager');
|
|
29
|
-
|
|
30
|
-
const personSnapshot = await Firestore.shared.person(parameters.teamId, parameters.id).snapshot();
|
|
31
|
-
if (!personSnapshot.exists)
|
|
32
|
-
throw new FunctionsError('not-found', 'Person not found');
|
|
33
|
-
const person = Person.builder.build(personSnapshot.data);
|
|
34
|
-
|
|
35
|
-
await Firestore.shared.person(parameters.teamId, parameters.id).set(new Person(parameters.id, parameters.properties, person.fineIds, person.signInProperties));
|
|
36
|
-
}
|
|
37
20
|
}
|