@stevenkellner/team-conduct-api 2.0.3 → 2.0.5
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/FirestoreScheme.d.ts +3 -0
- package/lib/src/functions/invitation/getInvitation.d.ts +5 -5
- package/lib/src/functions/invitation/getInvitation.js +1 -1
- package/lib/src/functions/person/add.d.ts +2 -2
- package/lib/src/functions/person/add.js +1 -1
- package/lib/src/functions/person/update.d.ts +2 -2
- package/lib/src/functions/person/update.js +1 -1
- package/lib/src/functions/team/new.d.ts +2 -2
- package/lib/src/functions/team/new.js +1 -1
- package/lib/src/types/PayedState.d.ts +7 -0
- package/lib/src/types/PayedState.js +15 -0
- package/lib/src/types/Person.d.ts +4 -4
- package/lib/src/types/Person.js +2 -2
- package/lib/src/types/{PersonPrivateProperties.d.ts → PersonProperties.d.ts} +9 -9
- package/lib/src/types/{PersonPrivateProperties.js → PersonProperties.js} +12 -12
- package/lib/src/types/PersonSignInProperties.d.ts +4 -4
- package/lib/src/types/PersonSignInProperties.js +6 -6
- package/lib/src/types/User.d.ts +118 -2
- package/lib/src/types/User.js +125 -2
- package/lib/src/types/index.d.ts +1 -1
- package/lib/src/types/index.js +1 -1
- package/lib/test/firebase/firebase-utils.js +7 -5
- package/lib/test/types/PayedState.test.js +31 -0
- package/lib/test/types/Person.test.js +20 -20
- package/lib/test/types/{PersonPrivateProperties.test.js → PersonProperties.test.js} +31 -31
- package/lib/test/types/PersonSignInProperties.test.js +38 -38
- package/lib/test/types/User.test.js +227 -9
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/firebase/FirestoreScheme.ts +3 -0
- package/src/functions/invitation/getInvitation.ts +7 -7
- package/src/functions/person/add.ts +3 -3
- package/src/functions/person/update.ts +3 -3
- package/src/functions/team/new.ts +3 -3
- package/src/types/PayedState.ts +15 -0
- package/src/types/Person.ts +4 -4
- package/src/types/{PersonPrivateProperties.ts → PersonProperties.ts} +10 -10
- package/src/types/PersonSignInProperties.ts +6 -6
- package/src/types/User.ts +162 -2
- package/src/types/index.ts +1 -1
- /package/lib/test/types/{PersonPrivateProperties.test.d.ts → PersonProperties.test.d.ts} +0 -0
|
@@ -15,6 +15,9 @@ import { Fine, FineTemplate, Invitation, Person, Team, User } from '../types';
|
|
|
15
15
|
* throughout the application.
|
|
16
16
|
*/
|
|
17
17
|
export type FirestoreScheme = FirestoreDocument<never, {
|
|
18
|
+
userAuthentications: FirestoreCollection<{
|
|
19
|
+
[UserAuthId in string]: FirestoreDocument<User.Id>;
|
|
20
|
+
}>;
|
|
18
21
|
users: FirestoreCollection<{
|
|
19
22
|
[UserId in string]: FirestoreDocument<User>;
|
|
20
23
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { Invitation, Person,
|
|
2
|
+
import { Invitation, Person, PersonProperties, Team } from '../../types';
|
|
3
3
|
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
4
|
export declare class InvitationGetInvitationFunction implements FirebaseFunction<Invitation.Id, InvitationGetInvitationFunction.ReturnType> {
|
|
5
5
|
parametersBuilder: import("@stevenkellner/typescript-common-functionality").Tagged.TypeBuilder<string, "invitation">;
|
|
@@ -11,7 +11,7 @@ export declare namespace InvitationGetInvitationFunction {
|
|
|
11
11
|
} | {
|
|
12
12
|
persons: {
|
|
13
13
|
id: Person.Id;
|
|
14
|
-
properties:
|
|
14
|
+
properties: PersonProperties;
|
|
15
15
|
}[];
|
|
16
16
|
};
|
|
17
17
|
namespace PersonIdOrPersons {
|
|
@@ -20,7 +20,7 @@ export declare namespace InvitationGetInvitationFunction {
|
|
|
20
20
|
} | {
|
|
21
21
|
persons: {
|
|
22
22
|
id: Person.Id.Flatten;
|
|
23
|
-
properties:
|
|
23
|
+
properties: PersonProperties.Flatten;
|
|
24
24
|
}[];
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -32,12 +32,12 @@ export declare namespace InvitationGetInvitationFunction {
|
|
|
32
32
|
static from(teamId: Team.Id, teamName: string, personId: Person.Id): ReturnType;
|
|
33
33
|
static from(teamId: Team.Id, teamName: string, persons: {
|
|
34
34
|
id: Person.Id;
|
|
35
|
-
properties:
|
|
35
|
+
properties: PersonProperties;
|
|
36
36
|
}[]): ReturnType;
|
|
37
37
|
get personId(): Person.Id | null;
|
|
38
38
|
get persons(): {
|
|
39
39
|
id: Person.Id;
|
|
40
|
-
properties:
|
|
40
|
+
properties: PersonProperties;
|
|
41
41
|
}[] | null;
|
|
42
42
|
get flatten(): ReturnType.Flatten;
|
|
43
43
|
}
|
|
@@ -64,7 +64,7 @@ exports.InvitationGetInvitationFunction = InvitationGetInvitationFunction;
|
|
|
64
64
|
}
|
|
65
65
|
return ReturnType.from(types_1.Team.Id.builder.build(value.teamId), value.teamName, value.persons.map(person => ({
|
|
66
66
|
id: types_1.Person.Id.builder.build(person.id),
|
|
67
|
-
properties: types_1.
|
|
67
|
+
properties: types_1.PersonProperties.builder.build(person.properties)
|
|
68
68
|
})));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { Person,
|
|
2
|
+
import { Person, PersonProperties, Team } from '../../types';
|
|
3
3
|
import { ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
4
|
export declare namespace PersonAddFunction {
|
|
5
5
|
type Parameters = {
|
|
6
6
|
teamId: Team.Id;
|
|
7
7
|
id: Person.Id;
|
|
8
|
-
properties:
|
|
8
|
+
properties: PersonProperties;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class PersonAddFunction implements FirebaseFunction<PersonAddFunction.Parameters, void> {
|
|
@@ -7,7 +7,7 @@ class PersonAddFunction {
|
|
|
7
7
|
parametersBuilder = new typescript_common_functionality_1.ObjectTypeBuilder({
|
|
8
8
|
teamId: types_1.Team.Id.builder,
|
|
9
9
|
id: types_1.Person.Id.builder,
|
|
10
|
-
properties: types_1.
|
|
10
|
+
properties: types_1.PersonProperties.builder
|
|
11
11
|
});
|
|
12
12
|
returnTypeBuilder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
13
13
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { Person,
|
|
2
|
+
import { Person, PersonProperties, Team } from '../../types';
|
|
3
3
|
import { ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
4
|
export declare namespace PersonUpdateFunction {
|
|
5
5
|
type Parameters = {
|
|
6
6
|
teamId: Team.Id;
|
|
7
7
|
id: Person.Id;
|
|
8
|
-
properties:
|
|
8
|
+
properties: PersonProperties;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class PersonUpdateFunction implements FirebaseFunction<PersonUpdateFunction.Parameters, void> {
|
|
@@ -7,7 +7,7 @@ class PersonUpdateFunction {
|
|
|
7
7
|
parametersBuilder = new typescript_common_functionality_1.ObjectTypeBuilder({
|
|
8
8
|
teamId: types_1.Team.Id.builder,
|
|
9
9
|
id: types_1.Person.Id.builder,
|
|
10
|
-
properties: types_1.
|
|
10
|
+
properties: types_1.PersonProperties.builder
|
|
11
11
|
});
|
|
12
12
|
returnTypeBuilder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ObjectTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
3
|
-
import { Person,
|
|
3
|
+
import { Person, PersonProperties, User, Team } from '../../types';
|
|
4
4
|
export declare namespace TeamNewFunction {
|
|
5
5
|
type Parameters = {
|
|
6
6
|
id: Team.Id;
|
|
7
7
|
name: string;
|
|
8
8
|
paypalMeLink: string | null;
|
|
9
9
|
personId: Person.Id;
|
|
10
|
-
personProperties:
|
|
10
|
+
personProperties: PersonProperties;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
export declare class TeamNewFunction implements FirebaseFunction<TeamNewFunction.Parameters, User> {
|
|
@@ -9,7 +9,7 @@ class TeamNewFunction {
|
|
|
9
9
|
name: new typescript_common_functionality_1.ValueTypeBuilder(),
|
|
10
10
|
paypalMeLink: new typescript_common_functionality_1.ValueTypeBuilder(),
|
|
11
11
|
personId: types_1.Person.Id.builder,
|
|
12
|
-
personProperties: types_1.
|
|
12
|
+
personProperties: types_1.PersonProperties.builder
|
|
13
13
|
});
|
|
14
14
|
returnTypeBuilder = types_1.User.builder;
|
|
15
15
|
}
|
|
@@ -20,6 +20,13 @@ export declare namespace PayedState {
|
|
|
20
20
|
* @returns Localized string representation of the payment state
|
|
21
21
|
*/
|
|
22
22
|
function formatted(state: PayedState, locale: Locale): string;
|
|
23
|
+
/**
|
|
24
|
+
* Toggles the payment state between 'payed' and 'notPayed'.
|
|
25
|
+
*
|
|
26
|
+
* @param state - The current payment state
|
|
27
|
+
* @returns The toggled payment state
|
|
28
|
+
*/
|
|
29
|
+
function toggled(state: PayedState): PayedState;
|
|
23
30
|
/**
|
|
24
31
|
* Type builder for PayedState serialization/deserialization.
|
|
25
32
|
*/
|
|
@@ -21,6 +21,21 @@ var PayedState;
|
|
|
21
21
|
return Localization_1.Localization.shared(locale).payedState[state].value();
|
|
22
22
|
}
|
|
23
23
|
PayedState.formatted = formatted;
|
|
24
|
+
/**
|
|
25
|
+
* Toggles the payment state between 'payed' and 'notPayed'.
|
|
26
|
+
*
|
|
27
|
+
* @param state - The current payment state
|
|
28
|
+
* @returns The toggled payment state
|
|
29
|
+
*/
|
|
30
|
+
function toggled(state) {
|
|
31
|
+
switch (state) {
|
|
32
|
+
case 'payed':
|
|
33
|
+
return 'notPayed';
|
|
34
|
+
case 'notPayed':
|
|
35
|
+
return 'payed';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
PayedState.toggled = toggled;
|
|
24
39
|
/**
|
|
25
40
|
* Type builder for PayedState serialization/deserialization.
|
|
26
41
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PersonProperties } from './PersonProperties';
|
|
2
2
|
import { PersonSignInProperties } from './PersonSignInProperties';
|
|
3
3
|
import { Fine } from './Fine';
|
|
4
4
|
import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
|
|
@@ -9,7 +9,7 @@ import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class Person implements Flattable<Person.Flatten> {
|
|
11
11
|
id: Person.Id;
|
|
12
|
-
properties:
|
|
12
|
+
properties: PersonProperties;
|
|
13
13
|
fineIds: Fine.Id[];
|
|
14
14
|
signInProperties: PersonSignInProperties | null;
|
|
15
15
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class Person implements Flattable<Person.Flatten> {
|
|
|
20
20
|
* @param fineIds - Array of fine IDs assigned to this person (defaults to empty array)
|
|
21
21
|
* @param signInProperties - Optional sign-in properties if the person has signed in (defaults to null)
|
|
22
22
|
*/
|
|
23
|
-
constructor(id: Person.Id, properties:
|
|
23
|
+
constructor(id: Person.Id, properties: PersonProperties, fineIds?: Fine.Id[], signInProperties?: PersonSignInProperties | null);
|
|
24
24
|
/**
|
|
25
25
|
* Returns the flattened representation of the person for serialization.
|
|
26
26
|
*/
|
|
@@ -52,7 +52,7 @@ export declare namespace Person {
|
|
|
52
52
|
*/
|
|
53
53
|
type Flatten = {
|
|
54
54
|
id: Id.Flatten;
|
|
55
|
-
properties:
|
|
55
|
+
properties: PersonProperties.Flatten;
|
|
56
56
|
fineIds: Fine.Id.Flatten[];
|
|
57
57
|
signInProperties: PersonSignInProperties.Flatten | null;
|
|
58
58
|
};
|
package/lib/src/types/Person.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Person = void 0;
|
|
4
|
-
const
|
|
4
|
+
const PersonProperties_1 = require("./PersonProperties");
|
|
5
5
|
const PersonSignInProperties_1 = require("./PersonSignInProperties");
|
|
6
6
|
const Fine_1 = require("./Fine");
|
|
7
7
|
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
@@ -71,7 +71,7 @@ exports.Person = Person;
|
|
|
71
71
|
* @returns Person instance
|
|
72
72
|
*/
|
|
73
73
|
build(value) {
|
|
74
|
-
return new Person(Id.builder.build(value.id),
|
|
74
|
+
return new Person(Id.builder.build(value.id), PersonProperties_1.PersonProperties.builder.build(value.properties), value.fineIds.map(fineId => Fine_1.Fine.Id.builder.build(fineId)), value.signInProperties ? PersonSignInProperties_1.PersonSignInProperties.builder.build(value.signInProperties) : null);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
Person.TypeBuilder = TypeBuilder;
|
|
@@ -5,7 +5,7 @@ import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functi
|
|
|
5
5
|
* Contains personal information that is private to the person,
|
|
6
6
|
* such as their name. The last name is optional.
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class PersonProperties implements Flattable<PersonProperties.Flatten> {
|
|
9
9
|
firstName: string;
|
|
10
10
|
lastName: string | null;
|
|
11
11
|
/**
|
|
@@ -17,9 +17,9 @@ export declare class PersonPrivateProperties implements Flattable<PersonPrivateP
|
|
|
17
17
|
/**
|
|
18
18
|
* Gets the flattened representation of these properties for serialization.
|
|
19
19
|
*/
|
|
20
|
-
get flatten():
|
|
20
|
+
get flatten(): PersonProperties.Flatten;
|
|
21
21
|
}
|
|
22
|
-
export declare namespace
|
|
22
|
+
export declare namespace PersonProperties {
|
|
23
23
|
/**
|
|
24
24
|
* Flattened representation of person private properties for serialization.
|
|
25
25
|
*/
|
|
@@ -28,18 +28,18 @@ export declare namespace PersonPrivateProperties {
|
|
|
28
28
|
lastName: string | null;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Builder for constructing
|
|
31
|
+
* Builder for constructing PersonProperties from flattened data.
|
|
32
32
|
*/
|
|
33
|
-
class TypeBuilder implements ITypeBuilder<Flatten,
|
|
33
|
+
class TypeBuilder implements ITypeBuilder<Flatten, PersonProperties> {
|
|
34
34
|
/**
|
|
35
|
-
* Builds a
|
|
35
|
+
* Builds a PersonProperties instance from flattened data.
|
|
36
36
|
* @param value - The flattened person private properties data
|
|
37
|
-
* @returns A new
|
|
37
|
+
* @returns A new PersonProperties instance
|
|
38
38
|
*/
|
|
39
|
-
build(value: Flatten):
|
|
39
|
+
build(value: Flatten): PersonProperties;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Singleton builder instance for
|
|
42
|
+
* Singleton builder instance for PersonProperties.
|
|
43
43
|
*/
|
|
44
44
|
const builder: TypeBuilder;
|
|
45
45
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PersonProperties = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Represents the private properties of a person.
|
|
6
6
|
*
|
|
7
7
|
* Contains personal information that is private to the person,
|
|
8
8
|
* such as their name. The last name is optional.
|
|
9
9
|
*/
|
|
10
|
-
class
|
|
10
|
+
class PersonProperties {
|
|
11
11
|
firstName;
|
|
12
12
|
lastName;
|
|
13
13
|
/**
|
|
@@ -29,24 +29,24 @@ class PersonPrivateProperties {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
exports.
|
|
33
|
-
(function (
|
|
32
|
+
exports.PersonProperties = PersonProperties;
|
|
33
|
+
(function (PersonProperties) {
|
|
34
34
|
/**
|
|
35
|
-
* Builder for constructing
|
|
35
|
+
* Builder for constructing PersonProperties from flattened data.
|
|
36
36
|
*/
|
|
37
37
|
class TypeBuilder {
|
|
38
38
|
/**
|
|
39
|
-
* Builds a
|
|
39
|
+
* Builds a PersonProperties instance from flattened data.
|
|
40
40
|
* @param value - The flattened person private properties data
|
|
41
|
-
* @returns A new
|
|
41
|
+
* @returns A new PersonProperties instance
|
|
42
42
|
*/
|
|
43
43
|
build(value) {
|
|
44
|
-
return new
|
|
44
|
+
return new PersonProperties(value.firstName, value.lastName);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
PersonProperties.TypeBuilder = TypeBuilder;
|
|
48
48
|
/**
|
|
49
|
-
* Singleton builder instance for
|
|
49
|
+
* Singleton builder instance for PersonProperties.
|
|
50
50
|
*/
|
|
51
|
-
|
|
52
|
-
})(
|
|
51
|
+
PersonProperties.builder = new TypeBuilder();
|
|
52
|
+
})(PersonProperties || (exports.PersonProperties = PersonProperties = {}));
|
|
@@ -10,17 +10,17 @@ import { UserRole } from './UserRole';
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class PersonSignInProperties implements Flattable<PersonSignInProperties.Flatten> {
|
|
12
12
|
userId: User.Id;
|
|
13
|
-
|
|
13
|
+
joinDate: UtcDate;
|
|
14
14
|
notificationProperties: NotificationProperties;
|
|
15
15
|
roles: UserRole[];
|
|
16
16
|
/**
|
|
17
17
|
* Creates new person sign-in properties.
|
|
18
18
|
* @param userId - The unique identifier of the user associated with this person
|
|
19
|
-
* @param
|
|
19
|
+
* @param joinDate - The timestamp when the person joined the team
|
|
20
20
|
* @param notificationProperties - Optional notification preferences (defaults to new NotificationProperties)
|
|
21
21
|
* @param roles - Optional array of user roles for access control (defaults to empty array)
|
|
22
22
|
*/
|
|
23
|
-
constructor(userId: User.Id,
|
|
23
|
+
constructor(userId: User.Id, joinDate: UtcDate, notificationProperties?: NotificationProperties, roles?: UserRole[]);
|
|
24
24
|
/**
|
|
25
25
|
* Gets the flattened representation of these sign-in properties for serialization.
|
|
26
26
|
*/
|
|
@@ -32,7 +32,7 @@ export declare namespace PersonSignInProperties {
|
|
|
32
32
|
*/
|
|
33
33
|
type Flatten = {
|
|
34
34
|
userId: User.Id.Flatten;
|
|
35
|
-
|
|
35
|
+
joinDate: UtcDate.Flatten;
|
|
36
36
|
notificationProperties: NotificationProperties.Flatten;
|
|
37
37
|
roles: UserRole[];
|
|
38
38
|
};
|
|
@@ -12,19 +12,19 @@ const User_1 = require("./User");
|
|
|
12
12
|
*/
|
|
13
13
|
class PersonSignInProperties {
|
|
14
14
|
userId;
|
|
15
|
-
|
|
15
|
+
joinDate;
|
|
16
16
|
notificationProperties;
|
|
17
17
|
roles;
|
|
18
18
|
/**
|
|
19
19
|
* Creates new person sign-in properties.
|
|
20
20
|
* @param userId - The unique identifier of the user associated with this person
|
|
21
|
-
* @param
|
|
21
|
+
* @param joinDate - The timestamp when the person joined the team
|
|
22
22
|
* @param notificationProperties - Optional notification preferences (defaults to new NotificationProperties)
|
|
23
23
|
* @param roles - Optional array of user roles for access control (defaults to empty array)
|
|
24
24
|
*/
|
|
25
|
-
constructor(userId,
|
|
25
|
+
constructor(userId, joinDate, notificationProperties = new NotificationProperties_1.NotificationProperties(), roles = []) {
|
|
26
26
|
this.userId = userId;
|
|
27
|
-
this.
|
|
27
|
+
this.joinDate = joinDate;
|
|
28
28
|
this.notificationProperties = notificationProperties;
|
|
29
29
|
this.roles = roles;
|
|
30
30
|
}
|
|
@@ -34,7 +34,7 @@ class PersonSignInProperties {
|
|
|
34
34
|
get flatten() {
|
|
35
35
|
return {
|
|
36
36
|
userId: this.userId.flatten,
|
|
37
|
-
|
|
37
|
+
joinDate: this.joinDate.flatten,
|
|
38
38
|
notificationProperties: this.notificationProperties.flatten,
|
|
39
39
|
roles: this.roles
|
|
40
40
|
};
|
|
@@ -52,7 +52,7 @@ exports.PersonSignInProperties = PersonSignInProperties;
|
|
|
52
52
|
* @returns A new PersonSignInProperties instance
|
|
53
53
|
*/
|
|
54
54
|
build(value) {
|
|
55
|
-
return new PersonSignInProperties(User_1.User.Id.builder.build(value.userId), typescript_common_functionality_1.UtcDate.builder.build(value.
|
|
55
|
+
return new PersonSignInProperties(User_1.User.Id.builder.build(value.userId), typescript_common_functionality_1.UtcDate.builder.build(value.joinDate), NotificationProperties_1.NotificationProperties.builder.build(value.notificationProperties), value.roles);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
PersonSignInProperties.TypeBuilder = TypeBuilder;
|
package/lib/src/types/User.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dictionary, Flattable, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
|
|
1
|
+
import { Dictionary, Flattable, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { Team } from './Team';
|
|
3
3
|
import { Person } from './Person';
|
|
4
4
|
/**
|
|
@@ -9,13 +9,15 @@ import { Person } from './Person';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class User implements Flattable<User.Flatten> {
|
|
11
11
|
id: User.Id;
|
|
12
|
+
signInDate: UtcDate;
|
|
13
|
+
signInType: User.SignInType;
|
|
12
14
|
teams: Dictionary<Team.Id, User.TeamProperties>;
|
|
13
15
|
/**
|
|
14
16
|
* Creates a new User instance.
|
|
15
17
|
* @param id - The unique identifier for this user
|
|
16
18
|
* @param teams - Dictionary mapping team IDs to team-specific user properties
|
|
17
19
|
*/
|
|
18
|
-
constructor(id: User.Id, teams?: Dictionary<Team.Id, User.TeamProperties>);
|
|
20
|
+
constructor(id: User.Id, signInDate: UtcDate, signInType: User.SignInType, teams?: Dictionary<Team.Id, User.TeamProperties>);
|
|
19
21
|
/**
|
|
20
22
|
* Gets the flattened representation of this user for serialization.
|
|
21
23
|
*/
|
|
@@ -36,6 +38,118 @@ export declare namespace User {
|
|
|
36
38
|
*/
|
|
37
39
|
const builder: Tagged.TypeBuilder<string, "user">;
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents email-based authentication sign-in type.
|
|
43
|
+
*
|
|
44
|
+
* Used when a user signs in using their email address.
|
|
45
|
+
*/
|
|
46
|
+
class SignInTypeEmail implements Flattable<SignInTypeEmail.Flatten> {
|
|
47
|
+
email: string;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new email sign-in type.
|
|
50
|
+
* @param email - The email address used for authentication
|
|
51
|
+
*/
|
|
52
|
+
constructor(email: string);
|
|
53
|
+
/**
|
|
54
|
+
* Gets the flattened representation for serialization.
|
|
55
|
+
*/
|
|
56
|
+
get flatten(): SignInTypeEmail.Flatten;
|
|
57
|
+
}
|
|
58
|
+
namespace SignInTypeEmail {
|
|
59
|
+
/**
|
|
60
|
+
* Flattened representation of email sign-in type for serialization.
|
|
61
|
+
*/
|
|
62
|
+
type Flatten = {
|
|
63
|
+
type: 'email';
|
|
64
|
+
email: string;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Builder for constructing SignInTypeEmail instances from flattened data.
|
|
68
|
+
*/
|
|
69
|
+
class TypeBuilder implements ITypeBuilder<Flatten, SignInTypeEmail> {
|
|
70
|
+
/**
|
|
71
|
+
* Builds a SignInTypeEmail instance from flattened data.
|
|
72
|
+
* @param value - The flattened email sign-in type data
|
|
73
|
+
* @returns A new SignInTypeEmail instance
|
|
74
|
+
*/
|
|
75
|
+
build(value: Flatten): SignInTypeEmail;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Singleton builder instance for SignInTypeEmail.
|
|
79
|
+
*/
|
|
80
|
+
const builder: TypeBuilder;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Represents OAuth-based authentication sign-in type.
|
|
84
|
+
*
|
|
85
|
+
* Used when a user signs in using an OAuth provider (Google or Apple).
|
|
86
|
+
*/
|
|
87
|
+
class SignInTypeOAuth implements Flattable<SignInTypeOAuth.Flatten> {
|
|
88
|
+
provider: 'google' | 'apple';
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new OAuth sign-in type.
|
|
91
|
+
* @param provider - The OAuth provider used for authentication ('google' or 'apple')
|
|
92
|
+
*/
|
|
93
|
+
constructor(provider: 'google' | 'apple');
|
|
94
|
+
/**
|
|
95
|
+
* Gets the flattened representation for serialization.
|
|
96
|
+
*/
|
|
97
|
+
get flatten(): SignInTypeOAuth.Flatten;
|
|
98
|
+
}
|
|
99
|
+
namespace SignInTypeOAuth {
|
|
100
|
+
/**
|
|
101
|
+
* Flattened representation of OAuth sign-in type for serialization.
|
|
102
|
+
*/
|
|
103
|
+
type Flatten = {
|
|
104
|
+
type: 'google' | 'apple';
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Builder for constructing SignInTypeOAuth instances from flattened data.
|
|
108
|
+
*/
|
|
109
|
+
class TypeBuilder implements ITypeBuilder<Flatten, SignInTypeOAuth> {
|
|
110
|
+
/**
|
|
111
|
+
* Builds a SignInTypeOAuth instance from flattened data.
|
|
112
|
+
* @param value - The flattened OAuth sign-in type data
|
|
113
|
+
* @returns A new SignInTypeOAuth instance
|
|
114
|
+
*/
|
|
115
|
+
build(value: Flatten): SignInTypeOAuth;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Singleton builder instance for SignInTypeOAuth.
|
|
119
|
+
*/
|
|
120
|
+
const builder: TypeBuilder;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Union type representing any sign-in method.
|
|
124
|
+
*
|
|
125
|
+
* Can be either email-based or OAuth-based authentication.
|
|
126
|
+
*/
|
|
127
|
+
type SignInType = SignInTypeEmail | SignInTypeOAuth;
|
|
128
|
+
namespace SignInType {
|
|
129
|
+
/**
|
|
130
|
+
* Flattened representation of any sign-in type for serialization.
|
|
131
|
+
*/
|
|
132
|
+
type Flatten = SignInTypeEmail.Flatten | SignInTypeOAuth.Flatten;
|
|
133
|
+
/**
|
|
134
|
+
* Builder for constructing SignInType instances from flattened data.
|
|
135
|
+
*
|
|
136
|
+
* Automatically determines the correct type based on the 'type' field.
|
|
137
|
+
*/
|
|
138
|
+
class TypeBuilder implements ITypeBuilder<Flatten, SignInType> {
|
|
139
|
+
/**
|
|
140
|
+
* Builds a SignInType instance from flattened data.
|
|
141
|
+
*
|
|
142
|
+
* Routes to the appropriate builder based on the type field.
|
|
143
|
+
* @param value - The flattened sign-in type data
|
|
144
|
+
* @returns Either a SignInTypeEmail or SignInTypeOAuth instance
|
|
145
|
+
*/
|
|
146
|
+
build(value: Flatten): SignInType;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Singleton builder instance for SignInType.
|
|
150
|
+
*/
|
|
151
|
+
const builder: TypeBuilder;
|
|
152
|
+
}
|
|
39
153
|
/**
|
|
40
154
|
* Properties that are specific to a user's membership in a particular team.
|
|
41
155
|
*/
|
|
@@ -85,6 +199,8 @@ export declare namespace User {
|
|
|
85
199
|
*/
|
|
86
200
|
type Flatten = {
|
|
87
201
|
id: Id.Flatten;
|
|
202
|
+
signInDate: string;
|
|
203
|
+
signInType: SignInType.Flatten;
|
|
88
204
|
teams: Dictionary.Flatten<TeamProperties>;
|
|
89
205
|
};
|
|
90
206
|
/**
|