@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
package/lib/src/types/Team.d.ts
CHANGED
|
@@ -1,24 +1,62 @@
|
|
|
1
1
|
import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a team in the system with its basic information.
|
|
4
|
+
*
|
|
5
|
+
* A team is a group of people who can track fines and payments together.
|
|
6
|
+
* Teams can optionally have a PayPal.Me link for simplified payment collection.
|
|
7
|
+
*/
|
|
2
8
|
export declare class Team implements Flattable<Team.Flatten> {
|
|
3
9
|
id: Team.Id;
|
|
4
10
|
name: string;
|
|
5
11
|
paypalMeLink: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new Team instance.
|
|
14
|
+
* @param id - The unique identifier for this team
|
|
15
|
+
* @param name - The display name of the team
|
|
16
|
+
* @param paypalMeLink - Optional PayPal.Me link for payment collection (null if not set)
|
|
17
|
+
*/
|
|
6
18
|
constructor(id: Team.Id, name: string, paypalMeLink: string | null);
|
|
19
|
+
/**
|
|
20
|
+
* Gets the flattened representation of this team for serialization.
|
|
21
|
+
*/
|
|
7
22
|
get flatten(): Team.Flatten;
|
|
8
23
|
}
|
|
9
24
|
export declare namespace Team {
|
|
25
|
+
/**
|
|
26
|
+
* Tagged type for team identifiers to prevent mixing with other GUID types.
|
|
27
|
+
*/
|
|
10
28
|
type Id = Tagged<Guid, 'team'>;
|
|
11
29
|
namespace Id {
|
|
30
|
+
/**
|
|
31
|
+
* Flattened representation of a team ID (plain GUID string).
|
|
32
|
+
*/
|
|
12
33
|
type Flatten = string;
|
|
34
|
+
/**
|
|
35
|
+
* Builder for constructing Team.Id instances from GUID strings.
|
|
36
|
+
*/
|
|
13
37
|
const builder: Tagged.TypeBuilder<Guid, "team">;
|
|
14
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Flattened representation of a Team for serialization.
|
|
41
|
+
*/
|
|
15
42
|
type Flatten = {
|
|
16
43
|
id: Id.Flatten;
|
|
17
44
|
name: string;
|
|
18
45
|
paypalMeLink: string | null;
|
|
19
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Builder for constructing Team instances from flattened data.
|
|
49
|
+
*/
|
|
20
50
|
class TypeBuilder implements ITypeBuilder<Flatten, Team> {
|
|
51
|
+
/**
|
|
52
|
+
* Builds a Team instance from flattened data.
|
|
53
|
+
* @param value - The flattened team data
|
|
54
|
+
* @returns A new Team instance
|
|
55
|
+
*/
|
|
21
56
|
build(value: Flatten): Team;
|
|
22
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Singleton builder instance for Team.
|
|
60
|
+
*/
|
|
23
61
|
const builder: TypeBuilder;
|
|
24
62
|
}
|
package/lib/src/types/Team.js
CHANGED
|
@@ -2,15 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Team = void 0;
|
|
4
4
|
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a team in the system with its basic information.
|
|
7
|
+
*
|
|
8
|
+
* A team is a group of people who can track fines and payments together.
|
|
9
|
+
* Teams can optionally have a PayPal.Me link for simplified payment collection.
|
|
10
|
+
*/
|
|
5
11
|
class Team {
|
|
6
12
|
id;
|
|
7
13
|
name;
|
|
8
14
|
paypalMeLink;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new Team instance.
|
|
17
|
+
* @param id - The unique identifier for this team
|
|
18
|
+
* @param name - The display name of the team
|
|
19
|
+
* @param paypalMeLink - Optional PayPal.Me link for payment collection (null if not set)
|
|
20
|
+
*/
|
|
9
21
|
constructor(id, name, paypalMeLink) {
|
|
10
22
|
this.id = id;
|
|
11
23
|
this.name = name;
|
|
12
24
|
this.paypalMeLink = paypalMeLink;
|
|
13
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the flattened representation of this team for serialization.
|
|
28
|
+
*/
|
|
14
29
|
get flatten() {
|
|
15
30
|
return {
|
|
16
31
|
id: this.id.flatten,
|
|
@@ -23,13 +38,27 @@ exports.Team = Team;
|
|
|
23
38
|
(function (Team) {
|
|
24
39
|
let Id;
|
|
25
40
|
(function (Id) {
|
|
41
|
+
/**
|
|
42
|
+
* Builder for constructing Team.Id instances from GUID strings.
|
|
43
|
+
*/
|
|
26
44
|
Id.builder = typescript_common_functionality_1.Tagged.builder('team', typescript_common_functionality_1.Guid.builder);
|
|
27
45
|
})(Id = Team.Id || (Team.Id = {}));
|
|
46
|
+
/**
|
|
47
|
+
* Builder for constructing Team instances from flattened data.
|
|
48
|
+
*/
|
|
28
49
|
class TypeBuilder {
|
|
50
|
+
/**
|
|
51
|
+
* Builds a Team instance from flattened data.
|
|
52
|
+
* @param value - The flattened team data
|
|
53
|
+
* @returns A new Team instance
|
|
54
|
+
*/
|
|
29
55
|
build(value) {
|
|
30
56
|
return new Team(Id.builder.build(value.id), value.name, value.paypalMeLink);
|
|
31
57
|
}
|
|
32
58
|
}
|
|
33
59
|
Team.TypeBuilder = TypeBuilder;
|
|
60
|
+
/**
|
|
61
|
+
* Singleton builder instance for Team.
|
|
62
|
+
*/
|
|
34
63
|
Team.builder = new TypeBuilder();
|
|
35
64
|
})(Team || (exports.Team = Team = {}));
|
package/lib/src/types/User.d.ts
CHANGED
|
@@ -1,40 +1,105 @@
|
|
|
1
1
|
import { Dictionary, Flattable, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { Team } from './Team';
|
|
3
3
|
import { Person } from './Person';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a user in the system with associated team memberships.
|
|
6
|
+
*
|
|
7
|
+
* A user can be a member of multiple teams, and for each team, they have
|
|
8
|
+
* specific properties (team name and associated person ID).
|
|
9
|
+
*/
|
|
4
10
|
export declare class User implements Flattable<User.Flatten> {
|
|
5
11
|
id: User.Id;
|
|
6
12
|
teams: Dictionary<Team.Id, User.TeamProperties>;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new User instance.
|
|
15
|
+
* @param id - The unique identifier for this user
|
|
16
|
+
* @param teams - Dictionary mapping team IDs to team-specific user properties
|
|
17
|
+
*/
|
|
7
18
|
constructor(id: User.Id, teams?: Dictionary<Team.Id, User.TeamProperties>);
|
|
19
|
+
/**
|
|
20
|
+
* Gets the flattened representation of this user for serialization.
|
|
21
|
+
*/
|
|
8
22
|
get flatten(): User.Flatten;
|
|
9
23
|
}
|
|
10
24
|
export declare namespace User {
|
|
25
|
+
/**
|
|
26
|
+
* Tagged type for user identifiers to prevent mixing with other string IDs.
|
|
27
|
+
*/
|
|
11
28
|
type Id = Tagged<string, 'user'>;
|
|
12
29
|
namespace Id {
|
|
30
|
+
/**
|
|
31
|
+
* Flattened representation of a user ID (plain string).
|
|
32
|
+
*/
|
|
13
33
|
type Flatten = string;
|
|
34
|
+
/**
|
|
35
|
+
* Builder for constructing User.Id instances from strings.
|
|
36
|
+
*/
|
|
14
37
|
const builder: Tagged.TypeBuilder<string, "user">;
|
|
15
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Properties that are specific to a user's membership in a particular team.
|
|
41
|
+
*/
|
|
16
42
|
class TeamProperties implements Flattable<TeamProperties.Flatten> {
|
|
17
|
-
|
|
43
|
+
teamId: Team.Id;
|
|
44
|
+
teamName: string;
|
|
18
45
|
personId: Person.Id;
|
|
19
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Creates new team-specific user properties.
|
|
48
|
+
* @param teamId - The ID of the team
|
|
49
|
+
* @param teamName - The display name of the team
|
|
50
|
+
* @param personId - The ID of the person associated with this user in this team
|
|
51
|
+
*/
|
|
52
|
+
constructor(teamId: Team.Id, teamName: string, personId: Person.Id);
|
|
53
|
+
/**
|
|
54
|
+
* Gets the flattened representation of these team properties.
|
|
55
|
+
*/
|
|
20
56
|
get flatten(): TeamProperties.Flatten;
|
|
21
57
|
}
|
|
22
58
|
namespace TeamProperties {
|
|
59
|
+
/**
|
|
60
|
+
* Flattened representation of team properties for serialization.
|
|
61
|
+
*/
|
|
23
62
|
type Flatten = {
|
|
24
|
-
|
|
63
|
+
teamId: Team.Id.Flatten;
|
|
64
|
+
teamName: string;
|
|
25
65
|
personId: Person.Id.Flatten;
|
|
26
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Builder for constructing TeamProperties from flattened data.
|
|
69
|
+
*/
|
|
27
70
|
class TypeBuilder implements ITypeBuilder<Flatten, TeamProperties> {
|
|
71
|
+
/**
|
|
72
|
+
* Builds a TeamProperties instance from flattened data.
|
|
73
|
+
* @param value - The flattened team properties data
|
|
74
|
+
* @returns A new TeamProperties instance
|
|
75
|
+
*/
|
|
28
76
|
build(value: Flatten): TeamProperties;
|
|
29
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Singleton builder instance for TeamProperties.
|
|
80
|
+
*/
|
|
30
81
|
const builder: TypeBuilder;
|
|
31
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Flattened representation of a User for serialization.
|
|
85
|
+
*/
|
|
32
86
|
type Flatten = {
|
|
33
87
|
id: Id.Flatten;
|
|
34
88
|
teams: Dictionary.Flatten<TeamProperties>;
|
|
35
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Builder for constructing User instances from flattened data.
|
|
92
|
+
*/
|
|
36
93
|
class TypeBuilder implements ITypeBuilder<Flatten, User> {
|
|
94
|
+
/**
|
|
95
|
+
* Builds a User instance from flattened data.
|
|
96
|
+
* @param value - The flattened user data
|
|
97
|
+
* @returns A new User instance with all teams reconstructed
|
|
98
|
+
*/
|
|
37
99
|
build(value: Flatten): User;
|
|
38
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Singleton builder instance for User.
|
|
103
|
+
*/
|
|
39
104
|
const builder: TypeBuilder;
|
|
40
105
|
}
|
package/lib/src/types/User.js
CHANGED
|
@@ -4,13 +4,27 @@ exports.User = void 0;
|
|
|
4
4
|
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
5
|
const Team_1 = require("./Team");
|
|
6
6
|
const Person_1 = require("./Person");
|
|
7
|
+
/**
|
|
8
|
+
* Represents a user in the system with associated team memberships.
|
|
9
|
+
*
|
|
10
|
+
* A user can be a member of multiple teams, and for each team, they have
|
|
11
|
+
* specific properties (team name and associated person ID).
|
|
12
|
+
*/
|
|
7
13
|
class User {
|
|
8
14
|
id;
|
|
9
15
|
teams;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new User instance.
|
|
18
|
+
* @param id - The unique identifier for this user
|
|
19
|
+
* @param teams - Dictionary mapping team IDs to team-specific user properties
|
|
20
|
+
*/
|
|
10
21
|
constructor(id, teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder)) {
|
|
11
22
|
this.id = id;
|
|
12
23
|
this.teams = teams;
|
|
13
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets the flattened representation of this user for serialization.
|
|
27
|
+
*/
|
|
14
28
|
get flatten() {
|
|
15
29
|
return {
|
|
16
30
|
id: this.id.flatten,
|
|
@@ -22,37 +36,77 @@ exports.User = User;
|
|
|
22
36
|
(function (User) {
|
|
23
37
|
let Id;
|
|
24
38
|
(function (Id) {
|
|
39
|
+
/**
|
|
40
|
+
* Builder for constructing User.Id instances from strings.
|
|
41
|
+
*/
|
|
25
42
|
Id.builder = typescript_common_functionality_1.Tagged.builder('user', new typescript_common_functionality_1.ValueTypeBuilder());
|
|
26
43
|
})(Id = User.Id || (User.Id = {}));
|
|
44
|
+
/**
|
|
45
|
+
* Properties that are specific to a user's membership in a particular team.
|
|
46
|
+
*/
|
|
27
47
|
class TeamProperties {
|
|
28
|
-
|
|
48
|
+
teamId;
|
|
49
|
+
teamName;
|
|
29
50
|
personId;
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Creates new team-specific user properties.
|
|
53
|
+
* @param teamId - The ID of the team
|
|
54
|
+
* @param teamName - The display name of the team
|
|
55
|
+
* @param personId - The ID of the person associated with this user in this team
|
|
56
|
+
*/
|
|
57
|
+
constructor(teamId, teamName, personId) {
|
|
58
|
+
this.teamId = teamId;
|
|
59
|
+
this.teamName = teamName;
|
|
32
60
|
this.personId = personId;
|
|
33
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Gets the flattened representation of these team properties.
|
|
64
|
+
*/
|
|
34
65
|
get flatten() {
|
|
35
66
|
return {
|
|
36
|
-
|
|
67
|
+
teamId: this.teamId.flatten,
|
|
68
|
+
teamName: this.teamName,
|
|
37
69
|
personId: this.personId.flatten
|
|
38
70
|
};
|
|
39
71
|
}
|
|
40
72
|
}
|
|
41
73
|
User.TeamProperties = TeamProperties;
|
|
42
74
|
(function (TeamProperties) {
|
|
75
|
+
/**
|
|
76
|
+
* Builder for constructing TeamProperties from flattened data.
|
|
77
|
+
*/
|
|
43
78
|
class TypeBuilder {
|
|
79
|
+
/**
|
|
80
|
+
* Builds a TeamProperties instance from flattened data.
|
|
81
|
+
* @param value - The flattened team properties data
|
|
82
|
+
* @returns A new TeamProperties instance
|
|
83
|
+
*/
|
|
44
84
|
build(value) {
|
|
45
|
-
return new TeamProperties(value.
|
|
85
|
+
return new TeamProperties(Team_1.Team.Id.builder.build(value.teamId), value.teamName, Person_1.Person.Id.builder.build(value.personId));
|
|
46
86
|
}
|
|
47
87
|
}
|
|
48
88
|
TeamProperties.TypeBuilder = TypeBuilder;
|
|
89
|
+
/**
|
|
90
|
+
* Singleton builder instance for TeamProperties.
|
|
91
|
+
*/
|
|
49
92
|
TeamProperties.builder = new TypeBuilder();
|
|
50
93
|
})(TeamProperties = User.TeamProperties || (User.TeamProperties = {}));
|
|
94
|
+
/**
|
|
95
|
+
* Builder for constructing User instances from flattened data.
|
|
96
|
+
*/
|
|
51
97
|
class TypeBuilder {
|
|
98
|
+
/**
|
|
99
|
+
* Builds a User instance from flattened data.
|
|
100
|
+
* @param value - The flattened user data
|
|
101
|
+
* @returns A new User instance with all teams reconstructed
|
|
102
|
+
*/
|
|
52
103
|
build(value) {
|
|
53
104
|
return new User(Id.builder.build(value.id), typescript_common_functionality_1.Dictionary.builder(Team_1.Team.Id.builder, User.TeamProperties.builder).build(value.teams));
|
|
54
105
|
}
|
|
55
106
|
}
|
|
56
107
|
User.TypeBuilder = TypeBuilder;
|
|
108
|
+
/**
|
|
109
|
+
* Singleton builder instance for User.
|
|
110
|
+
*/
|
|
57
111
|
User.builder = new TypeBuilder();
|
|
58
112
|
})(User || (exports.User = User = {}));
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
|
|
2
|
+
import { Locale } from './Locale';
|
|
3
|
+
/**
|
|
4
|
+
* Array of all available user roles.
|
|
5
|
+
*/
|
|
6
|
+
declare const userRoles: readonly ["person-manager", "fineTemplate-manager", "fine-manager", "fine-can-add", "team-manager"];
|
|
7
|
+
/**
|
|
8
|
+
* Represents user roles in the application.
|
|
9
|
+
* Defines different levels of permissions for team members.
|
|
10
|
+
*/
|
|
11
|
+
export type UserRole = typeof userRoles[number];
|
|
3
12
|
export declare namespace UserRole {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Array of all available user roles.
|
|
15
|
+
*/
|
|
16
|
+
const all: readonly UserRole[];
|
|
17
|
+
/**
|
|
18
|
+
* Returns the localized, human-readable name for a user role.
|
|
19
|
+
* @param role - The user role to format
|
|
20
|
+
* @param locale - The locale to use for localization
|
|
21
|
+
* @returns The localized role name
|
|
22
|
+
*/
|
|
23
|
+
function formatted(role: UserRole, locale: Locale): string;
|
|
24
|
+
/**
|
|
25
|
+
* Builder for constructing UserRole values.
|
|
26
|
+
*/
|
|
27
|
+
const builder: ValueTypeBuilder<"person-manager" | "fineTemplate-manager" | "fine-manager" | "fine-can-add" | "team-manager">;
|
|
7
28
|
}
|
|
29
|
+
export {};
|
|
@@ -3,16 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UserRole = void 0;
|
|
4
4
|
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
5
|
const Localization_1 = require("./Localization");
|
|
6
|
+
/**
|
|
7
|
+
* Array of all available user roles.
|
|
8
|
+
*/
|
|
9
|
+
const userRoles = [
|
|
10
|
+
'person-manager', // Can manage persons, i.e. add/edit/remove persons of the team
|
|
11
|
+
'fineTemplate-manager', // Can manage fine templates, i.e. add/edit/remove fine templates
|
|
12
|
+
'fine-manager', // Can manage fines, i.e. add/edit/remove fines
|
|
13
|
+
'fine-can-add', // Can add fines, but not edit or remove them
|
|
14
|
+
'team-manager' // Can manage team settings, i.e. invite/remove team members, change team name, etc.
|
|
15
|
+
];
|
|
6
16
|
var UserRole;
|
|
7
17
|
(function (UserRole) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Array of all available user roles.
|
|
20
|
+
*/
|
|
21
|
+
UserRole.all = userRoles;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the localized, human-readable name for a user role.
|
|
24
|
+
* @param role - The user role to format
|
|
25
|
+
* @param locale - The locale to use for localization
|
|
26
|
+
* @returns The localized role name
|
|
27
|
+
*/
|
|
28
|
+
function formatted(role, locale) {
|
|
16
29
|
const localizationKeyMap = {
|
|
17
30
|
'person-manager': 'personManager',
|
|
18
31
|
'fineTemplate-manager': 'fineTemplateManager',
|
|
@@ -20,8 +33,11 @@ var UserRole;
|
|
|
20
33
|
'fine-can-add': 'fineCanAdd',
|
|
21
34
|
'team-manager': 'teamManager'
|
|
22
35
|
};
|
|
23
|
-
return Localization_1.Localization.shared.userRole[localizationKeyMap[role]].value();
|
|
36
|
+
return Localization_1.Localization.shared(locale).userRole[localizationKeyMap[role]].value();
|
|
24
37
|
}
|
|
25
38
|
UserRole.formatted = formatted;
|
|
39
|
+
/**
|
|
40
|
+
* Builder for constructing UserRole values.
|
|
41
|
+
*/
|
|
26
42
|
UserRole.builder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
27
43
|
})(UserRole || (exports.UserRole = UserRole = {}));
|
package/lib/src/types/index.d.ts
CHANGED
package/lib/src/types/index.js
CHANGED
|
@@ -31,3 +31,5 @@ __exportStar(require("./Pluralization"), exports);
|
|
|
31
31
|
__exportStar(require("./Team"), exports);
|
|
32
32
|
__exportStar(require("./User"), exports);
|
|
33
33
|
__exportStar(require("./UserRole"), exports);
|
|
34
|
+
__exportStar(require("./Currency"), exports);
|
|
35
|
+
__exportStar(require("./Locale"), exports);
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const FirebaseConfiguration_1 = require("../../src/firebase/FirebaseConfiguration");
|
|
5
|
+
describe('FirebaseConfiguration', () => {
|
|
6
|
+
describe('FirebaseConfiguration.shared', () => {
|
|
7
|
+
it('should return a singleton instance', () => {
|
|
8
|
+
const instance1 = FirebaseConfiguration_1.FirebaseConfiguration.shared;
|
|
9
|
+
const instance2 = FirebaseConfiguration_1.FirebaseConfiguration.shared;
|
|
10
|
+
(0, core_1.expect)(instance1).toBeEqual(instance2);
|
|
11
|
+
});
|
|
12
|
+
it('should be an instance of FirebaseConfiguration', () => {
|
|
13
|
+
const instance = FirebaseConfiguration_1.FirebaseConfiguration.shared;
|
|
14
|
+
(0, core_1.expect)(instance instanceof FirebaseConfiguration_1.FirebaseConfiguration).toBeTrue();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('FirebaseConfiguration.configure', () => {
|
|
18
|
+
// Note: Since FirebaseConfiguration is a singleton and maintains state,
|
|
19
|
+
// we need to be careful with testing. In a real-world scenario, you might
|
|
20
|
+
// need to add a reset method for testing purposes or use dependency injection.
|
|
21
|
+
// For now, we'll test the error cases that don't require full configuration.
|
|
22
|
+
it('should throw error when configuring twice', () => {
|
|
23
|
+
// Create a mock configuration
|
|
24
|
+
const mockFirestore = {};
|
|
25
|
+
const mockMessaging = {
|
|
26
|
+
sendEachForMulticast: async () => ({
|
|
27
|
+
responses: [],
|
|
28
|
+
successCount: 0,
|
|
29
|
+
failureCount: 0
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
// We can't actually configure the shared instance in tests without affecting other tests
|
|
33
|
+
// This test documents the expected behavior
|
|
34
|
+
(0, core_1.expect)(() => {
|
|
35
|
+
// If already configured, this should throw
|
|
36
|
+
try {
|
|
37
|
+
FirebaseConfiguration_1.FirebaseConfiguration.shared.configure({
|
|
38
|
+
baseFirestoreDocument: mockFirestore,
|
|
39
|
+
messaging: mockMessaging
|
|
40
|
+
});
|
|
41
|
+
// If it succeeds, try configuring again to test the double-configuration error
|
|
42
|
+
FirebaseConfiguration_1.FirebaseConfiguration.shared.configure({
|
|
43
|
+
baseFirestoreDocument: mockFirestore,
|
|
44
|
+
messaging: mockMessaging
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error && error.message === 'Configuration is already configured')
|
|
49
|
+
throw error;
|
|
50
|
+
// If it's the "not configured" error, the first configure worked
|
|
51
|
+
// but we can't test double-configuration in this test environment
|
|
52
|
+
}
|
|
53
|
+
}).toThrow();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('FirebaseConfiguration getters', () => {
|
|
57
|
+
describe('baseFirestoreDocument', () => {
|
|
58
|
+
it('should throw error when not configured', () => {
|
|
59
|
+
// Create a fresh test to check unconfigured state
|
|
60
|
+
// Note: In practice, the shared instance might already be configured
|
|
61
|
+
try {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
|
+
const _ = FirebaseConfiguration_1.FirebaseConfiguration.shared.baseFirestoreDocument;
|
|
64
|
+
// If we get here, it was already configured (expected in normal operation)
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
(0, core_1.expect)(error instanceof Error).toBeTrue();
|
|
68
|
+
if (error instanceof Error)
|
|
69
|
+
(0, core_1.expect)(error.message).toBeEqual('Configuration.baseFirestoreDocument is not configured');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('messaging', () => {
|
|
74
|
+
it('should throw error when not configured', () => {
|
|
75
|
+
// Create a fresh test to check unconfigured state
|
|
76
|
+
try {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
const _ = FirebaseConfiguration_1.FirebaseConfiguration.shared.messaging;
|
|
79
|
+
// If we get here, it was already configured (expected in normal operation)
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
(0, core_1.expect)(error instanceof Error).toBeTrue();
|
|
83
|
+
if (error instanceof Error)
|
|
84
|
+
(0, core_1.expect)(error.message).toBeEqual('Configuration.messaging is not configured');
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe('FirebaseConfiguration behavior', () => {
|
|
90
|
+
it('should maintain singleton pattern', () => {
|
|
91
|
+
const instance = FirebaseConfiguration_1.FirebaseConfiguration.shared;
|
|
92
|
+
(0, core_1.expect)(instance).not.toBeNull();
|
|
93
|
+
(0, core_1.expect)(instance).not.toBeUndefined();
|
|
94
|
+
});
|
|
95
|
+
it('should have configure method', () => {
|
|
96
|
+
(0, core_1.expect)(typeof FirebaseConfiguration_1.FirebaseConfiguration.shared.configure).toBeEqual('function');
|
|
97
|
+
});
|
|
98
|
+
it('should have baseFirestoreDocument getter', () => {
|
|
99
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(FirebaseConfiguration_1.FirebaseConfiguration.shared), 'baseFirestoreDocument');
|
|
100
|
+
(0, core_1.expect)(descriptor).not.toBeEqual(undefined);
|
|
101
|
+
(0, core_1.expect)(descriptor?.get).not.toBeEqual(undefined);
|
|
102
|
+
});
|
|
103
|
+
it('should have messaging getter', () => {
|
|
104
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(FirebaseConfiguration_1.FirebaseConfiguration.shared), 'messaging');
|
|
105
|
+
(0, core_1.expect)(descriptor).not.toBeEqual(undefined);
|
|
106
|
+
(0, core_1.expect)(descriptor?.get).not.toBeEqual(undefined);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('FirebaseConfiguration configuration object', () => {
|
|
110
|
+
it('should accept valid configuration structure', () => {
|
|
111
|
+
const mockFirestore = {};
|
|
112
|
+
const mockMessaging = {
|
|
113
|
+
sendEachForMulticast: async () => ({
|
|
114
|
+
responses: [],
|
|
115
|
+
successCount: 0,
|
|
116
|
+
failureCount: 0
|
|
117
|
+
})
|
|
118
|
+
};
|
|
119
|
+
const configuration = {
|
|
120
|
+
baseFirestoreDocument: mockFirestore,
|
|
121
|
+
messaging: mockMessaging
|
|
122
|
+
};
|
|
123
|
+
(0, core_1.expect)(configuration.baseFirestoreDocument).toBeEqual(mockFirestore);
|
|
124
|
+
(0, core_1.expect)(configuration.messaging).toBeEqual(mockMessaging);
|
|
125
|
+
});
|
|
126
|
+
it('should require baseFirestoreDocument in configuration', () => {
|
|
127
|
+
const mockMessaging = {
|
|
128
|
+
sendEachForMulticast: async () => ({
|
|
129
|
+
responses: [],
|
|
130
|
+
successCount: 0,
|
|
131
|
+
failureCount: 0
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
const configuration = {
|
|
135
|
+
baseFirestoreDocument: {},
|
|
136
|
+
messaging: mockMessaging
|
|
137
|
+
};
|
|
138
|
+
(0, core_1.expect)(configuration.baseFirestoreDocument).not.toBeUndefined();
|
|
139
|
+
});
|
|
140
|
+
it('should require messaging in configuration', () => {
|
|
141
|
+
const mockFirestore = {};
|
|
142
|
+
const configuration = {
|
|
143
|
+
baseFirestoreDocument: mockFirestore,
|
|
144
|
+
messaging: {
|
|
145
|
+
sendEachForMulticast: async () => ({
|
|
146
|
+
responses: [],
|
|
147
|
+
successCount: 0,
|
|
148
|
+
failureCount: 0
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
(0, core_1.expect)(configuration.messaging).not.toBeUndefined();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Firestore_1 = require("../../src/firebase/Firestore");
|
|
5
|
+
describe('Firestore', () => {
|
|
6
|
+
describe('shared singleton', () => {
|
|
7
|
+
it('should return the same instance on multiple calls', () => {
|
|
8
|
+
const instance1 = Firestore_1.Firestore.shared;
|
|
9
|
+
const instance2 = Firestore_1.Firestore.shared;
|
|
10
|
+
(0, core_1.expect)(instance1).toBe(instance2);
|
|
11
|
+
});
|
|
12
|
+
it('should create an instance', () => {
|
|
13
|
+
const instance = Firestore_1.Firestore.shared;
|
|
14
|
+
(0, core_1.expect)(instance).toBeInstanceOf(Firestore_1.Firestore);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('accessor methods', () => {
|
|
18
|
+
it('should have team method', () => {
|
|
19
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.team).toBeEqual('function');
|
|
20
|
+
});
|
|
21
|
+
it('should have user method', () => {
|
|
22
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.user).toBeEqual('function');
|
|
23
|
+
});
|
|
24
|
+
it('should have invitation method', () => {
|
|
25
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.invitation).toBeEqual('function');
|
|
26
|
+
});
|
|
27
|
+
it('should have persons method', () => {
|
|
28
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.persons).toBeEqual('function');
|
|
29
|
+
});
|
|
30
|
+
it('should have person method', () => {
|
|
31
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.person).toBeEqual('function');
|
|
32
|
+
});
|
|
33
|
+
it('should have fineTemplates method', () => {
|
|
34
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.fineTemplates).toBeEqual('function');
|
|
35
|
+
});
|
|
36
|
+
it('should have fineTemplate method', () => {
|
|
37
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.fineTemplate).toBeEqual('function');
|
|
38
|
+
});
|
|
39
|
+
it('should have fines method', () => {
|
|
40
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.fines).toBeEqual('function');
|
|
41
|
+
});
|
|
42
|
+
it('should have fine method', () => {
|
|
43
|
+
(0, core_1.expect)(typeof Firestore_1.Firestore.shared.fine).toBeEqual('function');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|