@stevenkellner/team-conduct-api 1.0.34 → 1.0.36
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.
|
@@ -27,20 +27,25 @@ export declare namespace InvitationGetInvitationFunction {
|
|
|
27
27
|
}
|
|
28
28
|
class ReturnType implements Flattable<ReturnType.Flatten> {
|
|
29
29
|
teamId: Team.Id;
|
|
30
|
+
teamName: string;
|
|
30
31
|
private personIdOrPersons;
|
|
31
32
|
private constructor();
|
|
32
|
-
static from(teamId: Team.Id, personId: Person.Id): ReturnType;
|
|
33
|
-
static from(teamId: Team.Id, persons: {
|
|
33
|
+
static from(teamId: Team.Id, teamName: string, personId: Person.Id): ReturnType;
|
|
34
|
+
static from(teamId: Team.Id, teamName: string, persons: {
|
|
34
35
|
id: Person.Id;
|
|
35
36
|
properties: PersonPrivateProperties;
|
|
36
37
|
}[]): ReturnType;
|
|
37
38
|
get personId(): Person.Id | null;
|
|
38
|
-
get persons():
|
|
39
|
+
get persons(): {
|
|
40
|
+
id: Person.Id;
|
|
41
|
+
properties: PersonPrivateProperties;
|
|
42
|
+
}[] | null;
|
|
39
43
|
get flatten(): ReturnType.Flatten;
|
|
40
44
|
}
|
|
41
45
|
namespace ReturnType {
|
|
42
46
|
type Flatten = {
|
|
43
47
|
teamId: Team.Id.Flatten;
|
|
48
|
+
teamName: string;
|
|
44
49
|
} & InvitationGetInvitationFunction.PersonIdOrPersons.Flatten;
|
|
45
50
|
class TypeBuilder implements ITypeBuilder<Flatten, ReturnType> {
|
|
46
51
|
build(value: Flatten): ReturnType;
|
|
@@ -15,8 +15,12 @@ class InvitationGetInvitationFunction extends firebase_function_1.FirebaseFuncti
|
|
|
15
15
|
if (!invitationSnapshot.exists)
|
|
16
16
|
throw new firebase_function_1.FunctionsError('not-found', 'Invitation not found');
|
|
17
17
|
const invitation = types_1.Invitation.builder.build(invitationSnapshot.data);
|
|
18
|
+
const teamSnapshot = await Firestore_1.Firestore.shared.team(invitation.teamId).snapshot();
|
|
19
|
+
if (!teamSnapshot.exists)
|
|
20
|
+
throw new firebase_function_1.FunctionsError('not-found', 'Team not found');
|
|
21
|
+
const team = types_1.Team.builder.build(teamSnapshot.data);
|
|
18
22
|
if (invitation.personId !== null)
|
|
19
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, invitation.personId);
|
|
23
|
+
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, invitation.personId);
|
|
20
24
|
const personSnapshots = await Firestore_1.Firestore.shared.persons(invitation.teamId).documentSnapshots();
|
|
21
25
|
const persons = (0, typescript_common_functionality_1.compactMap)(personSnapshots, personSnapshot => {
|
|
22
26
|
if (!personSnapshot.exists)
|
|
@@ -29,25 +33,27 @@ class InvitationGetInvitationFunction extends firebase_function_1.FirebaseFuncti
|
|
|
29
33
|
properties: person.properties
|
|
30
34
|
};
|
|
31
35
|
});
|
|
32
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, persons);
|
|
36
|
+
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, persons);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
exports.InvitationGetInvitationFunction = InvitationGetInvitationFunction;
|
|
36
40
|
(function (InvitationGetInvitationFunction) {
|
|
37
41
|
class ReturnType {
|
|
38
42
|
teamId;
|
|
43
|
+
teamName;
|
|
39
44
|
personIdOrPersons;
|
|
40
|
-
constructor(teamId, personIdOrPersons) {
|
|
45
|
+
constructor(teamId, teamName, personIdOrPersons) {
|
|
41
46
|
this.teamId = teamId;
|
|
47
|
+
this.teamName = teamName;
|
|
42
48
|
this.personIdOrPersons = personIdOrPersons;
|
|
43
49
|
}
|
|
44
|
-
static from(teamId, personIdOrPersons) {
|
|
50
|
+
static from(teamId, teamName, personIdOrPersons) {
|
|
45
51
|
if (Array.isArray(personIdOrPersons)) {
|
|
46
|
-
return new ReturnType(teamId, {
|
|
52
|
+
return new ReturnType(teamId, teamName, {
|
|
47
53
|
persons: personIdOrPersons
|
|
48
54
|
});
|
|
49
55
|
}
|
|
50
|
-
return new ReturnType(teamId, {
|
|
56
|
+
return new ReturnType(teamId, teamName, {
|
|
51
57
|
personId: personIdOrPersons
|
|
52
58
|
});
|
|
53
59
|
}
|
|
@@ -59,17 +65,19 @@ exports.InvitationGetInvitationFunction = InvitationGetInvitationFunction;
|
|
|
59
65
|
get persons() {
|
|
60
66
|
if (!('persons' in this.personIdOrPersons))
|
|
61
67
|
return null;
|
|
62
|
-
return this.personIdOrPersons.persons
|
|
68
|
+
return this.personIdOrPersons.persons;
|
|
63
69
|
}
|
|
64
70
|
get flatten() {
|
|
65
71
|
if ('personId' in this.personIdOrPersons) {
|
|
66
72
|
return {
|
|
67
73
|
teamId: this.teamId.flatten,
|
|
74
|
+
teamName: this.teamName,
|
|
68
75
|
personId: this.personIdOrPersons.personId.flatten
|
|
69
76
|
};
|
|
70
77
|
}
|
|
71
78
|
return {
|
|
72
79
|
teamId: this.teamId.flatten,
|
|
80
|
+
teamName: this.teamName,
|
|
73
81
|
persons: this.personIdOrPersons.persons.map(person => ({
|
|
74
82
|
id: person.id.flatten,
|
|
75
83
|
properties: person.properties.flatten
|
|
@@ -82,9 +90,9 @@ exports.InvitationGetInvitationFunction = InvitationGetInvitationFunction;
|
|
|
82
90
|
class TypeBuilder {
|
|
83
91
|
build(value) {
|
|
84
92
|
if ('personId' in value) {
|
|
85
|
-
return ReturnType.from(types_1.Team.Id.builder.build(value.teamId), types_1.Person.Id.builder.build(value.personId));
|
|
93
|
+
return ReturnType.from(types_1.Team.Id.builder.build(value.teamId), value.teamName, types_1.Person.Id.builder.build(value.personId));
|
|
86
94
|
}
|
|
87
|
-
return ReturnType.from(types_1.Team.Id.builder.build(value.teamId), value.persons.map(person => ({
|
|
95
|
+
return ReturnType.from(types_1.Team.Id.builder.build(value.teamId), value.teamName, value.persons.map(person => ({
|
|
88
96
|
id: types_1.Person.Id.builder.build(person.id),
|
|
89
97
|
properties: types_1.PersonPrivateProperties.builder.build(person.properties)
|
|
90
98
|
})));
|
package/package.json
CHANGED
|
@@ -19,8 +19,13 @@ export class InvitationGetInvitationFunction extends FirebaseFunction<Invitation
|
|
|
19
19
|
throw new FunctionsError('not-found', 'Invitation not found');
|
|
20
20
|
const invitation = Invitation.builder.build(invitationSnapshot.data);
|
|
21
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
|
+
|
|
22
27
|
if (invitation.personId !== null)
|
|
23
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, invitation.personId);
|
|
28
|
+
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, invitation.personId);
|
|
24
29
|
|
|
25
30
|
const personSnapshots = await Firestore.shared.persons(invitation.teamId).documentSnapshots();
|
|
26
31
|
const persons = compactMap(personSnapshots, personSnapshot => {
|
|
@@ -34,7 +39,7 @@ export class InvitationGetInvitationFunction extends FirebaseFunction<Invitation
|
|
|
34
39
|
properties: person.properties
|
|
35
40
|
};
|
|
36
41
|
});
|
|
37
|
-
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, persons);
|
|
42
|
+
return InvitationGetInvitationFunction.ReturnType.from(invitation.teamId, team.name, persons);
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -65,18 +70,19 @@ export namespace InvitationGetInvitationFunction {
|
|
|
65
70
|
|
|
66
71
|
private constructor(
|
|
67
72
|
public teamId: Team.Id,
|
|
73
|
+
public teamName: string,
|
|
68
74
|
private personIdOrPersons: PersonIdOrPersons
|
|
69
75
|
) {}
|
|
70
76
|
|
|
71
|
-
public static from(teamId: Team.Id, personId: Person.Id): ReturnType;
|
|
72
|
-
public static from(teamId: Team.Id, persons: { id: Person.Id, properties: PersonPrivateProperties }[]): ReturnType;
|
|
73
|
-
public static from(teamId: Team.Id, personIdOrPersons: Person.Id | { id: Person.Id, properties: PersonPrivateProperties }[]): ReturnType {
|
|
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 {
|
|
74
80
|
if (Array.isArray(personIdOrPersons)) {
|
|
75
|
-
return new ReturnType(teamId, {
|
|
81
|
+
return new ReturnType(teamId, teamName, {
|
|
76
82
|
persons: personIdOrPersons
|
|
77
83
|
});
|
|
78
84
|
}
|
|
79
|
-
return new ReturnType(teamId, {
|
|
85
|
+
return new ReturnType(teamId, teamName, {
|
|
80
86
|
personId: personIdOrPersons
|
|
81
87
|
});
|
|
82
88
|
}
|
|
@@ -87,21 +93,26 @@ export namespace InvitationGetInvitationFunction {
|
|
|
87
93
|
return this.personIdOrPersons.personId;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
public get persons():
|
|
96
|
+
public get persons(): {
|
|
97
|
+
id: Person.Id,
|
|
98
|
+
properties: PersonPrivateProperties,
|
|
99
|
+
}[] | null {
|
|
91
100
|
if (!('persons' in this.personIdOrPersons))
|
|
92
101
|
return null;
|
|
93
|
-
return this.personIdOrPersons.persons
|
|
102
|
+
return this.personIdOrPersons.persons;
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
public get flatten(): ReturnType.Flatten {
|
|
97
106
|
if ('personId' in this.personIdOrPersons) {
|
|
98
107
|
return {
|
|
99
108
|
teamId: this.teamId.flatten,
|
|
109
|
+
teamName: this.teamName,
|
|
100
110
|
personId: this.personIdOrPersons.personId.flatten
|
|
101
111
|
};
|
|
102
112
|
}
|
|
103
113
|
return {
|
|
104
114
|
teamId: this.teamId.flatten,
|
|
115
|
+
teamName: this.teamName,
|
|
105
116
|
persons: this.personIdOrPersons.persons.map(person => ({
|
|
106
117
|
id: person.id.flatten,
|
|
107
118
|
properties: person.properties.flatten
|
|
@@ -113,7 +124,8 @@ export namespace InvitationGetInvitationFunction {
|
|
|
113
124
|
export namespace ReturnType {
|
|
114
125
|
|
|
115
126
|
export type Flatten = {
|
|
116
|
-
teamId: Team.Id.Flatten
|
|
127
|
+
teamId: Team.Id.Flatten,
|
|
128
|
+
teamName: string
|
|
117
129
|
} & InvitationGetInvitationFunction.PersonIdOrPersons.Flatten;
|
|
118
130
|
|
|
119
131
|
export class TypeBuilder implements ITypeBuilder<Flatten, ReturnType> {
|
|
@@ -122,11 +134,13 @@ export namespace InvitationGetInvitationFunction {
|
|
|
122
134
|
if ('personId' in value) {
|
|
123
135
|
return ReturnType.from(
|
|
124
136
|
Team.Id.builder.build(value.teamId),
|
|
137
|
+
value.teamName,
|
|
125
138
|
Person.Id.builder.build(value.personId)
|
|
126
139
|
);
|
|
127
140
|
}
|
|
128
141
|
return ReturnType.from(
|
|
129
142
|
Team.Id.builder.build(value.teamId),
|
|
143
|
+
value.teamName,
|
|
130
144
|
value.persons.map(person => ({
|
|
131
145
|
id: Person.Id.builder.build(person.id),
|
|
132
146
|
properties: PersonPrivateProperties.builder.build(person.properties)
|