@stevenkellner/team-conduct-api 2.0.17 → 2.0.19
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/functions/fine/add.d.ts +3 -8
- package/lib/src/functions/fine/add.js +1 -2
- package/lib/src/functions/fine/delete.d.ts +1 -6
- package/lib/src/functions/fine/delete.js +2 -3
- package/lib/src/functions/fine/update.d.ts +2 -8
- package/lib/src/functions/fine/update.js +1 -3
- package/lib/src/functions/fineTemplate/add.d.ts +3 -3
- package/lib/src/functions/fineTemplate/update.d.ts +3 -3
- package/lib/src/functions/firebaseFunctionsContext.d.ts +34 -1
- package/lib/src/functions/firebaseFunctionsContext.js +33 -33
- package/lib/src/functions/index.d.ts +10 -8
- package/lib/src/functions/index.js +11 -8
- package/lib/src/functions/notification/markNotificationAsRead.d.ts +14 -0
- package/lib/src/functions/notification/{subscribe.js → markNotificationAsRead.js} +5 -7
- package/lib/src/functions/person/kickout.d.ts +6 -6
- package/lib/src/functions/person/kickout.js +4 -4
- package/lib/src/functions/person/roleEdit.d.ts +5 -5
- package/lib/src/functions/person/roleEdit.js +3 -3
- package/lib/src/functions/{paypalMe/edit.d.ts → team/delete.d.ts} +5 -7
- package/lib/src/functions/{paypalMe/edit.js → team/delete.js} +4 -5
- package/lib/src/functions/team/new.d.ts +18 -18
- package/lib/src/functions/team/new.js +8 -4
- package/lib/src/functions/team/update.d.ts +34 -0
- package/lib/src/functions/team/update.js +23 -0
- package/lib/src/functions/user/register.d.ts +4 -0
- package/lib/src/functions/user/register.js +3 -1
- package/lib/src/functions/user/update.d.ts +26 -0
- package/lib/src/functions/user/update.js +15 -0
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/locales/de.d.ts +1 -1
- package/lib/src/locales/de.js +6 -2
- package/lib/src/locales/en.d.ts +6 -2
- package/lib/src/locales/en.js +6 -2
- package/lib/src/types/{MoneyAmount.d.ts → Money.d.ts} +23 -23
- package/lib/src/types/{MoneyAmount.js → Money.js} +25 -25
- package/lib/src/types/fine/Fine.d.ts +275 -0
- package/lib/src/types/fine/Fine.js +318 -0
- package/lib/src/types/fine/FineTemplate.d.ts +154 -0
- package/lib/src/types/fine/FineTemplate.js +170 -0
- package/lib/src/types/{PayedState.d.ts → fine/PayedState.d.ts} +1 -1
- package/lib/src/types/{PayedState.js → fine/PayedState.js} +1 -1
- package/lib/src/types/fine/index.d.ts +3 -0
- package/lib/src/{firebase → types/fine}/index.js +3 -6
- package/lib/src/types/index.d.ts +7 -18
- package/lib/src/types/index.js +7 -18
- package/lib/src/types/{Localization.d.ts → localization/Localization.d.ts} +15 -43
- package/lib/src/types/localization/Localization.js +54 -0
- package/lib/src/types/localization/PluralLocalization.d.ts +23 -0
- package/lib/src/types/localization/PluralLocalization.js +35 -0
- package/lib/src/types/{Pluralization.d.ts → localization/Pluralization.d.ts} +1 -0
- package/lib/src/types/{Pluralization.js → localization/Pluralization.js} +1 -0
- package/lib/src/types/localization/ValueLocalization.d.ts +22 -0
- package/lib/src/types/localization/ValueLocalization.js +41 -0
- package/lib/src/types/localization/index.d.ts +5 -0
- package/lib/src/types/localization/index.js +21 -0
- package/lib/src/types/notification/InAppNotification.d.ts +152 -0
- package/lib/src/types/notification/InAppNotification.js +136 -0
- package/lib/src/types/notification/index.d.ts +1 -0
- package/lib/src/types/notification/index.js +17 -0
- package/lib/src/types/{Person.d.ts → person/Person.d.ts} +3 -3
- package/lib/src/types/{Person.js → person/Person.js} +3 -3
- package/lib/src/types/{PersonProperties.d.ts → person/PersonProperties.d.ts} +8 -7
- package/lib/src/types/{PersonProperties.js → person/PersonProperties.js} +7 -6
- package/lib/src/types/{PersonSignInProperties.d.ts → person/PersonSignInProperties.d.ts} +9 -11
- package/lib/src/types/{PersonSignInProperties.js → person/PersonSignInProperties.js} +7 -10
- package/lib/src/types/person/index.d.ts +3 -0
- package/lib/src/types/person/index.js +19 -0
- package/lib/src/types/{Invitation.d.ts → team/Invitation.d.ts} +1 -1
- package/lib/src/types/{Invitation.js → team/Invitation.js} +1 -1
- package/lib/src/types/team/Team.d.ts +144 -0
- package/lib/src/types/team/Team.js +141 -0
- package/lib/src/types/team/TeamRole.d.ts +30 -0
- package/lib/src/types/{UserRole.js → team/TeamRole.js} +16 -15
- package/lib/src/types/team/index.d.ts +3 -0
- package/lib/src/types/team/index.js +19 -0
- package/lib/src/types/{NotificationProperties.d.ts → user/NotificationProperties.d.ts} +8 -3
- package/lib/src/types/{NotificationProperties.js → user/NotificationProperties.js} +4 -0
- package/lib/src/types/user/User.d.ts +328 -0
- package/lib/src/types/user/User.js +355 -0
- package/lib/src/types/user/index.d.ts +2 -0
- package/lib/src/types/user/index.js +18 -0
- package/lib/src/utils/StaticUnionTypeBuilder.d.ts +9 -0
- package/lib/src/utils/StaticUnionTypeBuilder.js +23 -0
- package/lib/src/utils/index.d.ts +1 -0
- package/lib/src/utils/index.js +17 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/functions/fine/add.ts +3 -5
- package/src/functions/fine/delete.ts +3 -5
- package/src/functions/fine/update.ts +2 -5
- package/src/functions/firebaseFunctionsContext.ts +40 -40
- package/src/functions/index.ts +11 -9
- package/src/functions/notification/markNotificationAsRead.ts +19 -0
- package/src/functions/person/add.ts +1 -1
- package/src/functions/person/kickout.ts +6 -6
- package/src/functions/person/roleEdit.ts +5 -5
- package/src/functions/{paypalMe/edit.ts → team/delete.ts} +5 -7
- package/src/functions/team/new.ts +19 -11
- package/src/functions/team/update.ts +40 -0
- package/src/functions/user/register.ts +7 -3
- package/src/functions/user/update.ts +29 -0
- package/src/index.ts +1 -1
- package/src/locales/de.ts +7 -3
- package/src/locales/en.ts +7 -3
- package/src/types/{MoneyAmount.ts → Money.ts} +29 -29
- package/src/types/fine/Fine.ts +399 -0
- package/src/types/fine/FineTemplate.ts +219 -0
- package/src/types/{PayedState.ts → fine/PayedState.ts} +2 -2
- package/src/types/fine/index.ts +3 -0
- package/src/types/index.ts +7 -18
- package/src/types/{Localization.ts → localization/Localization.ts} +7 -64
- package/src/types/localization/PluralLocalization.ts +32 -0
- package/src/types/{Pluralization.ts → localization/Pluralization.ts} +1 -0
- package/src/types/localization/ValueLocalization.ts +36 -0
- package/src/types/localization/index.ts +5 -0
- package/src/types/notification/InAppNotification.ts +184 -0
- package/src/types/notification/index.ts +1 -0
- package/src/types/{Person.ts → person/Person.ts} +3 -3
- package/src/types/{PersonProperties.ts → person/PersonProperties.ts} +8 -7
- package/src/types/{PersonSignInProperties.ts → person/PersonSignInProperties.ts} +13 -12
- package/src/types/person/index.ts +3 -0
- package/src/types/{Invitation.ts → team/Invitation.ts} +1 -1
- package/src/types/team/Team.ts +204 -0
- package/src/types/{UserRole.ts → team/TeamRole.ts} +19 -17
- package/src/types/team/index.ts +3 -0
- package/src/types/{NotificationProperties.ts → user/NotificationProperties.ts} +12 -3
- package/src/types/user/User.ts +451 -0
- package/src/types/user/index.ts +2 -0
- package/src/utils/StaticUnionTypeBuilder.ts +23 -0
- package/src/utils/index.ts +1 -0
- package/lib/src/firebase/FirebaseConfiguration.d.ts +0 -64
- package/lib/src/firebase/FirebaseConfiguration.js +0 -79
- package/lib/src/firebase/Firestore.d.ts +0 -201
- package/lib/src/firebase/Firestore.js +0 -244
- package/lib/src/firebase/FirestoreScheme.d.ts +0 -42
- package/lib/src/firebase/FirestoreScheme.js +0 -2
- package/lib/src/firebase/Messaging.d.ts +0 -90
- package/lib/src/firebase/Messaging.js +0 -2
- package/lib/src/firebase/checkAuthentication.d.ts +0 -38
- package/lib/src/firebase/checkAuthentication.js +0 -64
- package/lib/src/firebase/index.d.ts +0 -6
- package/lib/src/firebase/pushNotification.d.ts +0 -39
- package/lib/src/firebase/pushNotification.js +0 -88
- package/lib/src/functions/notification/subscribe.d.ts +0 -18
- package/lib/src/types/Configuration.d.ts +0 -46
- package/lib/src/types/Configuration.js +0 -51
- package/lib/src/types/Fine.d.ts +0 -71
- package/lib/src/types/Fine.js +0 -74
- package/lib/src/types/FineAmount.d.ts +0 -207
- package/lib/src/types/FineAmount.js +0 -238
- package/lib/src/types/FineTemplate.d.ts +0 -69
- package/lib/src/types/FineTemplate.js +0 -72
- package/lib/src/types/FineTemplateRepetition.d.ts +0 -87
- package/lib/src/types/FineTemplateRepetition.js +0 -103
- package/lib/src/types/Localization.js +0 -115
- package/lib/src/types/Team.d.ts +0 -62
- package/lib/src/types/Team.js +0 -64
- package/lib/src/types/User.d.ts +0 -221
- package/lib/src/types/User.js +0 -235
- package/lib/src/types/UserRole.d.ts +0 -29
- package/lib/test/firebase/FirebaseConfiguration.test.d.ts +0 -1
- package/lib/test/firebase/FirebaseConfiguration.test.js +0 -158
- package/lib/test/firebase/Firestore.test.d.ts +0 -1
- package/lib/test/firebase/Firestore.test.js +0 -46
- package/lib/test/firebase/checkAuthentication.test.d.ts +0 -1
- package/lib/test/firebase/checkAuthentication.test.js +0 -356
- package/lib/test/firebase/firebase-utils.d.ts +0 -32
- package/lib/test/firebase/firebase-utils.js +0 -134
- package/lib/test/firebase/pushNotification.test.d.ts +0 -1
- package/lib/test/firebase/pushNotification.test.js +0 -300
- package/lib/test/locales/localization.de.test.d.ts +0 -1
- package/lib/test/locales/localization.de.test.js +0 -144
- package/lib/test/locales/localization.en.test.d.ts +0 -1
- package/lib/test/locales/localization.en.test.js +0 -144
- package/lib/test/types/Configuration.test.d.ts +0 -1
- package/lib/test/types/Configuration.test.js +0 -84
- package/lib/test/types/Currency.test.d.ts +0 -1
- package/lib/test/types/Currency.test.js +0 -41
- package/lib/test/types/Fine.test.d.ts +0 -1
- package/lib/test/types/Fine.test.js +0 -265
- package/lib/test/types/FineAmount.test.d.ts +0 -1
- package/lib/test/types/FineAmount.test.js +0 -445
- package/lib/test/types/FineTemplate.test.d.ts +0 -1
- package/lib/test/types/FineTemplate.test.js +0 -271
- package/lib/test/types/FineTemplateRepetition.test.d.ts +0 -1
- package/lib/test/types/FineTemplateRepetition.test.js +0 -361
- package/lib/test/types/Invitation.test.d.ts +0 -1
- package/lib/test/types/Invitation.test.js +0 -269
- package/lib/test/types/Locale.test.d.ts +0 -1
- package/lib/test/types/Locale.test.js +0 -46
- package/lib/test/types/Localization.test.d.ts +0 -1
- package/lib/test/types/Localization.test.js +0 -241
- package/lib/test/types/MoneyAmount.test.d.ts +0 -1
- package/lib/test/types/MoneyAmount.test.js +0 -276
- package/lib/test/types/NotificationProperties.test.d.ts +0 -1
- package/lib/test/types/NotificationProperties.test.js +0 -258
- package/lib/test/types/PayedState.test.d.ts +0 -1
- package/lib/test/types/PayedState.test.js +0 -136
- package/lib/test/types/Person.test.d.ts +0 -1
- package/lib/test/types/Person.test.js +0 -266
- package/lib/test/types/PersonProperties.test.d.ts +0 -1
- package/lib/test/types/PersonProperties.test.js +0 -155
- package/lib/test/types/PersonSignInProperties.test.d.ts +0 -1
- package/lib/test/types/PersonSignInProperties.test.js +0 -208
- package/lib/test/types/Pluralization.test.d.ts +0 -1
- package/lib/test/types/Pluralization.test.js +0 -206
- package/lib/test/types/Team.test.d.ts +0 -1
- package/lib/test/types/Team.test.js +0 -145
- package/lib/test/types/User.test.d.ts +0 -1
- package/lib/test/types/User.test.js +0 -450
- package/lib/test/types/UserRole.test.d.ts +0 -1
- package/lib/test/types/UserRole.test.js +0 -140
- package/src/firebase/FirebaseConfiguration.ts +0 -99
- package/src/firebase/Firestore.ts +0 -258
- package/src/firebase/FirestoreScheme.ts +0 -41
- package/src/firebase/Messaging.ts +0 -93
- package/src/firebase/checkAuthentication.ts +0 -91
- package/src/firebase/index.ts +0 -7
- package/src/firebase/pushNotification.ts +0 -90
- package/src/functions/notification/subscribe.ts +0 -23
- package/src/types/Configuration.ts +0 -65
- package/src/types/Fine.ts +0 -100
- package/src/types/FineAmount.ts +0 -303
- package/src/types/FineTemplate.ts +0 -96
- package/src/types/FineTemplateRepetition.ts +0 -125
- package/src/types/Team.ts +0 -87
- package/src/types/User.ts +0 -302
- /package/lib/src/types/{Locale.d.ts → localization/Locale.d.ts} +0 -0
- /package/lib/src/types/{Locale.js → localization/Locale.js} +0 -0
- /package/src/types/{Locale.ts → localization/Locale.ts} +0 -0
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { Flattable, ITypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { Localization } from './Localization';
|
|
3
|
-
import { Locale } from './Locale';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents how a fine template repeats over time.
|
|
7
|
-
*
|
|
8
|
-
* Defines the repetition unit (minute, day, item, count) and optional maximum count for repetitions.
|
|
9
|
-
*/
|
|
10
|
-
export class FineTemplateRepetition implements Flattable<FineTemplateRepetition.Flatten> {
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new FineTemplateRepetition instance.
|
|
14
|
-
*
|
|
15
|
-
* @param item - The repetition unit type (minute, day, item, count)
|
|
16
|
-
* @param maxCount - Optional maximum number of repetitions (null for unlimited)
|
|
17
|
-
*/
|
|
18
|
-
public constructor(
|
|
19
|
-
public item: FineTemplateRepetition.Item,
|
|
20
|
-
public maxCount: number | null
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns a localized formatted string including the count value.
|
|
25
|
-
*
|
|
26
|
-
* @param count - The number of repetitions
|
|
27
|
-
* @param locale - The locale to use for formatting
|
|
28
|
-
* @returns Formatted string (e.g., "every 5 minutes")
|
|
29
|
-
*/
|
|
30
|
-
public formatted(count: number, locale: Locale): string {
|
|
31
|
-
return Localization.shared(locale).fineTemplateRepetition.item[this.item].withCount.value(count);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns a localized formatted string without explicitly showing the count.
|
|
36
|
-
*
|
|
37
|
-
* @param count - The number of repetitions
|
|
38
|
-
* @param locale - The locale to use for formatting
|
|
39
|
-
* @returns Formatted string without count display
|
|
40
|
-
*/
|
|
41
|
-
public formattedWithoutCount(count: number, locale: Locale): string {
|
|
42
|
-
return Localization.shared(locale).fineTemplateRepetition.item[this.item].withoutCount.value(count);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Returns the flattened representation for serialization.
|
|
47
|
-
*/
|
|
48
|
-
public get flatten(): FineTemplateRepetition.Flatten {
|
|
49
|
-
return {
|
|
50
|
-
item: this.item,
|
|
51
|
-
maxCount: this.maxCount
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export namespace FineTemplateRepetition {
|
|
57
|
-
|
|
58
|
-
const repetitionItems = [
|
|
59
|
-
'minute',
|
|
60
|
-
'day',
|
|
61
|
-
'item',
|
|
62
|
-
'count'
|
|
63
|
-
] as const;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Repetition unit type: 'minute', 'day', 'item', or 'count'.
|
|
67
|
-
*/
|
|
68
|
-
export type Item = typeof repetitionItems[number];
|
|
69
|
-
|
|
70
|
-
export namespace Item {
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Array containing all possible repetition item types.
|
|
74
|
-
*/
|
|
75
|
-
export const all: readonly Item[] = repetitionItems;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Returns the localized name for a repetition item type.
|
|
79
|
-
*
|
|
80
|
-
* @param item - The repetition item type
|
|
81
|
-
* @param locale - The locale to use for formatting
|
|
82
|
-
* @returns Localized name string
|
|
83
|
-
*/
|
|
84
|
-
export function formatted(item: Item, locale: Locale): string {
|
|
85
|
-
return Localization.shared(locale).fineTemplateRepetition.item[item].name.value();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Type builder for Item serialization/deserialization.
|
|
90
|
-
*/
|
|
91
|
-
export const builder = new ValueTypeBuilder<Item>();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Flattened representation of FineTemplateRepetition for serialization.
|
|
96
|
-
*/
|
|
97
|
-
export type Flatten = {
|
|
98
|
-
item: Item,
|
|
99
|
-
maxCount: number | null
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Type builder for FineTemplateRepetition serialization/deserialization.
|
|
104
|
-
*/
|
|
105
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, FineTemplateRepetition> {
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Builds a FineTemplateRepetition instance from flattened data.
|
|
109
|
-
*
|
|
110
|
-
* @param flatten - Flattened repetition data
|
|
111
|
-
* @returns FineTemplateRepetition instance
|
|
112
|
-
*/
|
|
113
|
-
public build(flatten: Flatten): FineTemplateRepetition {
|
|
114
|
-
return new FineTemplateRepetition(
|
|
115
|
-
flatten.item,
|
|
116
|
-
flatten.maxCount
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Singleton instance of TypeBuilder for FineTemplateRepetition.
|
|
123
|
-
*/
|
|
124
|
-
export const builder = new TypeBuilder();
|
|
125
|
-
}
|
package/src/types/Team.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Flattable, Guid, ITypeBuilder, Tagged } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a team in the system with its basic information.
|
|
5
|
-
*
|
|
6
|
-
* A team is a group of people who can track fines and payments together.
|
|
7
|
-
* Teams can optionally have a PayPal.Me link for simplified payment collection.
|
|
8
|
-
*/
|
|
9
|
-
export class Team implements Flattable<Team.Flatten> {
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new Team instance.
|
|
13
|
-
* @param id - The unique identifier for this team
|
|
14
|
-
* @param name - The display name of the team
|
|
15
|
-
* @param paypalMeLink - Optional PayPal.Me link for payment collection (null if not set)
|
|
16
|
-
*/
|
|
17
|
-
public constructor(
|
|
18
|
-
public id: Team.Id,
|
|
19
|
-
public name: string,
|
|
20
|
-
public paypalMeLink: string | null
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Gets the flattened representation of this team for serialization.
|
|
25
|
-
*/
|
|
26
|
-
public get flatten(): Team.Flatten {
|
|
27
|
-
return {
|
|
28
|
-
id: this.id.flatten,
|
|
29
|
-
name: this.name,
|
|
30
|
-
paypalMeLink: this.paypalMeLink
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export namespace Team {
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Tagged type for team identifiers to prevent mixing with other GUID types.
|
|
39
|
-
*/
|
|
40
|
-
export type Id = Tagged<Guid, 'team'>;
|
|
41
|
-
|
|
42
|
-
export namespace Id {
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Flattened representation of a team ID (plain GUID string).
|
|
46
|
-
*/
|
|
47
|
-
export type Flatten = string;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Builder for constructing Team.Id instances from GUID strings.
|
|
51
|
-
*/
|
|
52
|
-
export const builder = Tagged.builder('team' as const, Guid.builder);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Flattened representation of a Team for serialization.
|
|
57
|
-
*/
|
|
58
|
-
export type Flatten = {
|
|
59
|
-
id: Id.Flatten,
|
|
60
|
-
name: string,
|
|
61
|
-
paypalMeLink: string | null
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Builder for constructing Team instances from flattened data.
|
|
66
|
-
*/
|
|
67
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, Team> {
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Builds a Team instance from flattened data.
|
|
71
|
-
* @param value - The flattened team data
|
|
72
|
-
* @returns A new Team instance
|
|
73
|
-
*/
|
|
74
|
-
public build(value: Flatten): Team {
|
|
75
|
-
return new Team(
|
|
76
|
-
Id.builder.build(value.id),
|
|
77
|
-
value.name,
|
|
78
|
-
value.paypalMeLink
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Singleton builder instance for Team.
|
|
85
|
-
*/
|
|
86
|
-
export const builder = new TypeBuilder();
|
|
87
|
-
}
|
package/src/types/User.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { Dictionary, Flattable, ITypeBuilder, Tagged, UtcDate, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { Team } from './Team';
|
|
3
|
-
import { Person } from './Person';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents a user in the system with associated team memberships.
|
|
7
|
-
*
|
|
8
|
-
* A user can be a member of multiple teams, and for each team, they have
|
|
9
|
-
* specific properties (team name and associated person ID).
|
|
10
|
-
*/
|
|
11
|
-
export class User implements Flattable<User.Flatten> {
|
|
12
|
-
|
|
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
|
-
*/
|
|
18
|
-
public constructor(
|
|
19
|
-
public id: User.Id,
|
|
20
|
-
public signInDate: UtcDate,
|
|
21
|
-
public signInType: User.SignInType,
|
|
22
|
-
public teams: Dictionary<Team.Id, User.TeamProperties> = new Dictionary(Team.Id.builder)
|
|
23
|
-
) {}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Gets the flattened representation of this user for serialization.
|
|
27
|
-
*/
|
|
28
|
-
public get flatten(): User.Flatten {
|
|
29
|
-
return {
|
|
30
|
-
id: this.id.flatten,
|
|
31
|
-
signInDate: this.signInDate.flatten,
|
|
32
|
-
signInType: this.signInType.flatten,
|
|
33
|
-
teams: this.teams.flatten
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export namespace User {
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Tagged type for user identifiers to prevent mixing with other string IDs.
|
|
42
|
-
*/
|
|
43
|
-
export type Id = Tagged<string, 'user'>;
|
|
44
|
-
|
|
45
|
-
export namespace Id {
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Flattened representation of a user ID (plain string).
|
|
49
|
-
*/
|
|
50
|
-
export type Flatten = string;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Builder for constructing User.Id instances from strings.
|
|
54
|
-
*/
|
|
55
|
-
export const builder = Tagged.builder('user' as const, new ValueTypeBuilder<string>());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Represents email-based authentication sign-in type.
|
|
60
|
-
*
|
|
61
|
-
* Used when a user signs in using their email address.
|
|
62
|
-
*/
|
|
63
|
-
export class SignInTypeEmail implements Flattable<SignInTypeEmail.Flatten> {
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Creates a new email sign-in type.
|
|
67
|
-
* @param email - The email address used for authentication
|
|
68
|
-
*/
|
|
69
|
-
public constructor(
|
|
70
|
-
public email: string
|
|
71
|
-
) {}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gets the flattened representation for serialization.
|
|
75
|
-
*/
|
|
76
|
-
public get flatten(): SignInTypeEmail.Flatten {
|
|
77
|
-
return {
|
|
78
|
-
type: 'email',
|
|
79
|
-
email: this.email
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export namespace SignInTypeEmail {
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Flattened representation of email sign-in type for serialization.
|
|
88
|
-
*/
|
|
89
|
-
export type Flatten = {
|
|
90
|
-
type: 'email',
|
|
91
|
-
email: string
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Builder for constructing SignInTypeEmail instances from flattened data.
|
|
96
|
-
*/
|
|
97
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, SignInTypeEmail> {
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Builds a SignInTypeEmail instance from flattened data.
|
|
101
|
-
* @param value - The flattened email sign-in type data
|
|
102
|
-
* @returns A new SignInTypeEmail instance
|
|
103
|
-
*/
|
|
104
|
-
public build(value: Flatten): SignInTypeEmail {
|
|
105
|
-
return new SignInTypeEmail(value.email);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Singleton builder instance for SignInTypeEmail.
|
|
111
|
-
*/
|
|
112
|
-
export const builder = new TypeBuilder();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Represents OAuth-based authentication sign-in type.
|
|
117
|
-
*
|
|
118
|
-
* Used when a user signs in using an OAuth provider (Google or Apple).
|
|
119
|
-
*/
|
|
120
|
-
export class SignInTypeOAuth implements Flattable<SignInTypeOAuth.Flatten> {
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Creates a new OAuth sign-in type.
|
|
124
|
-
* @param provider - The OAuth provider used for authentication ('google' or 'apple')
|
|
125
|
-
*/
|
|
126
|
-
public constructor(
|
|
127
|
-
public provider: 'google' | 'apple'
|
|
128
|
-
) {}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Gets the flattened representation for serialization.
|
|
132
|
-
*/
|
|
133
|
-
public get flatten(): SignInTypeOAuth.Flatten {
|
|
134
|
-
return {
|
|
135
|
-
type: this.provider
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export namespace SignInTypeOAuth {
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Flattened representation of OAuth sign-in type for serialization.
|
|
144
|
-
*/
|
|
145
|
-
export type Flatten = {
|
|
146
|
-
type: 'google' | 'apple'
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Builder for constructing SignInTypeOAuth instances from flattened data.
|
|
151
|
-
*/
|
|
152
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, SignInTypeOAuth> {
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Builds a SignInTypeOAuth instance from flattened data.
|
|
156
|
-
* @param value - The flattened OAuth sign-in type data
|
|
157
|
-
* @returns A new SignInTypeOAuth instance
|
|
158
|
-
*/
|
|
159
|
-
public build(value: Flatten): SignInTypeOAuth {
|
|
160
|
-
return new SignInTypeOAuth(value.type);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Singleton builder instance for SignInTypeOAuth.
|
|
166
|
-
*/
|
|
167
|
-
export const builder = new TypeBuilder();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Union type representing any sign-in method.
|
|
172
|
-
*
|
|
173
|
-
* Can be either email-based or OAuth-based authentication.
|
|
174
|
-
*/
|
|
175
|
-
export type SignInType = SignInTypeEmail | SignInTypeOAuth;
|
|
176
|
-
|
|
177
|
-
export namespace SignInType {
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Flattened representation of any sign-in type for serialization.
|
|
181
|
-
*/
|
|
182
|
-
export type Flatten = SignInTypeEmail.Flatten | SignInTypeOAuth.Flatten;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Builder for constructing SignInType instances from flattened data.
|
|
186
|
-
*
|
|
187
|
-
* Automatically determines the correct type based on the 'type' field.
|
|
188
|
-
*/
|
|
189
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, SignInType> {
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Builds a SignInType instance from flattened data.
|
|
193
|
-
*
|
|
194
|
-
* Routes to the appropriate builder based on the type field.
|
|
195
|
-
* @param value - The flattened sign-in type data
|
|
196
|
-
* @returns Either a SignInTypeEmail or SignInTypeOAuth instance
|
|
197
|
-
*/
|
|
198
|
-
public build(value: Flatten): SignInType {
|
|
199
|
-
if (value.type === 'email')
|
|
200
|
-
return SignInTypeEmail.builder.build(value);
|
|
201
|
-
else
|
|
202
|
-
return SignInTypeOAuth.builder.build(value);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Singleton builder instance for SignInType.
|
|
208
|
-
*/
|
|
209
|
-
export const builder = new TypeBuilder();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Properties that are specific to a user's membership in a particular team.
|
|
214
|
-
*/
|
|
215
|
-
export class TeamProperties implements Flattable<TeamProperties.Flatten> {
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Creates new team-specific user properties.
|
|
219
|
-
* @param teamId - The ID of the team
|
|
220
|
-
* @param teamName - The display name of the team
|
|
221
|
-
* @param personId - The ID of the person associated with this user in this team
|
|
222
|
-
*/
|
|
223
|
-
public constructor(
|
|
224
|
-
public teamId: Team.Id,
|
|
225
|
-
public teamName: string,
|
|
226
|
-
public personId: Person.Id
|
|
227
|
-
) {}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Gets the flattened representation of these team properties.
|
|
231
|
-
*/
|
|
232
|
-
public get flatten(): TeamProperties.Flatten {
|
|
233
|
-
return {
|
|
234
|
-
teamId: this.teamId.flatten,
|
|
235
|
-
teamName: this.teamName,
|
|
236
|
-
personId: this.personId.flatten
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
export namespace TeamProperties {
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Flattened representation of team properties for serialization.
|
|
245
|
-
*/
|
|
246
|
-
export type Flatten = {
|
|
247
|
-
teamId: Team.Id.Flatten,
|
|
248
|
-
teamName: string,
|
|
249
|
-
personId: Person.Id.Flatten
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Builder for constructing TeamProperties from flattened data.
|
|
254
|
-
*/
|
|
255
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, TeamProperties> {
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Builds a TeamProperties instance from flattened data.
|
|
259
|
-
* @param value - The flattened team properties data
|
|
260
|
-
* @returns A new TeamProperties instance
|
|
261
|
-
*/
|
|
262
|
-
public build(value: Flatten): TeamProperties {
|
|
263
|
-
return new TeamProperties(Team.Id.builder.build(value.teamId), value.teamName, Person.Id.builder.build(value.personId));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Singleton builder instance for TeamProperties.
|
|
269
|
-
*/
|
|
270
|
-
export const builder = new TypeBuilder();
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Flattened representation of a User for serialization.
|
|
275
|
-
*/
|
|
276
|
-
export type Flatten = {
|
|
277
|
-
id: Id.Flatten,
|
|
278
|
-
signInDate: string,
|
|
279
|
-
signInType: SignInType.Flatten,
|
|
280
|
-
teams: Dictionary.Flatten<TeamProperties>
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Builder for constructing User instances from flattened data.
|
|
285
|
-
*/
|
|
286
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, User> {
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Builds a User instance from flattened data.
|
|
290
|
-
* @param value - The flattened user data
|
|
291
|
-
* @returns A new User instance with all teams reconstructed
|
|
292
|
-
*/
|
|
293
|
-
public build(value: Flatten): User {
|
|
294
|
-
return new User(Id.builder.build(value.id), UtcDate.builder.build(value.signInDate), SignInType.builder.build(value.signInType), Dictionary.builder(Team.Id.builder, User.TeamProperties.builder).build(value.teams));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Singleton builder instance for User.
|
|
300
|
-
*/
|
|
301
|
-
export const builder = new TypeBuilder();
|
|
302
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|