@stevenkellner/team-conduct-api 2.0.18 → 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 +4 -3
- 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,39 +0,0 @@
|
|
|
1
|
-
import { NotificationProperties, Person, Team } from '../types';
|
|
2
|
-
import { Notification } from '.';
|
|
3
|
-
/**
|
|
4
|
-
* Sends a push notification to a person if they are subscribed to the topic.
|
|
5
|
-
*
|
|
6
|
-
* Retrieves the person's notification properties, checks their subscription status,
|
|
7
|
-
* sends the notification to all their registered device tokens, and updates their
|
|
8
|
-
* token list to remove any failed tokens.
|
|
9
|
-
*
|
|
10
|
-
* @param teamId - The unique identifier of the team
|
|
11
|
-
* @param personId - The unique identifier of the person
|
|
12
|
-
* @param topic - The notification subscription topic (e.g., 'new-fine', 'fine-reminder', 'fine-state-change')
|
|
13
|
-
* @param notification - The notification content to send
|
|
14
|
-
*
|
|
15
|
-
* @returns A promise that resolves when the notification is sent and person data is updated
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* The function will silently return without sending if:
|
|
19
|
-
* - The person does not exist in the database
|
|
20
|
-
* - The person is not signed in (signInProperties is null)
|
|
21
|
-
* - The person is not subscribed to the specified topic
|
|
22
|
-
*
|
|
23
|
-
* After sending, the person's token list is automatically updated to remove
|
|
24
|
-
* any tokens that are invalid or unregistered, maintaining clean notification data.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* await pushNotification(
|
|
29
|
-
* teamId,
|
|
30
|
-
* personId,
|
|
31
|
-
* 'new-fine',
|
|
32
|
-
* {
|
|
33
|
-
* title: 'New Fine',
|
|
34
|
-
* body: 'You have received a new fine'
|
|
35
|
-
* }
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare function pushNotification(teamId: Team.Id, personId: Person.Id, topic: NotificationProperties.Subscription, notification: Notification): Promise<void>;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pushNotification = pushNotification;
|
|
4
|
-
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
|
-
const Firestore_1 = require("./Firestore");
|
|
6
|
-
const types_1 = require("../types");
|
|
7
|
-
const _1 = require(".");
|
|
8
|
-
/**
|
|
9
|
-
* Filters successful tokens from a Firebase Cloud Messaging batch response.
|
|
10
|
-
*
|
|
11
|
-
* Removes tokens that failed due to invalid or unregistered registration tokens,
|
|
12
|
-
* keeping only the tokens that successfully received the notification.
|
|
13
|
-
*
|
|
14
|
-
* @param response - The batch response from Firebase Cloud Messaging
|
|
15
|
-
* @param tokens - The array of device tokens that were sent the notification
|
|
16
|
-
* @returns A dictionary mapping token IDs to their corresponding device tokens for successful deliveries
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* Filters out tokens with the following error codes:
|
|
20
|
-
* - `messaging/invalid-registration-token`: The token format is invalid
|
|
21
|
-
* - `messaging/registration-token-not-registered`: The token is no longer registered
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
function successfulTokens(response, tokens) {
|
|
26
|
-
const successfulTokens = response.responses
|
|
27
|
-
.map((response, index) => ({
|
|
28
|
-
failed: response.error?.code === 'messaging/invalid-registration-token' || response.error?.code === 'messaging/registration-token-not-registered',
|
|
29
|
-
token: tokens[index]
|
|
30
|
-
}))
|
|
31
|
-
.filter(response => !response.failed)
|
|
32
|
-
.map(response => response.token);
|
|
33
|
-
const tokenDict = new typescript_common_functionality_1.Dictionary(types_1.NotificationProperties.TokenId.builder);
|
|
34
|
-
for (const token of successfulTokens)
|
|
35
|
-
tokenDict.set(types_1.NotificationProperties.TokenId.create(token), token);
|
|
36
|
-
return tokenDict;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Sends a push notification to a person if they are subscribed to the topic.
|
|
40
|
-
*
|
|
41
|
-
* Retrieves the person's notification properties, checks their subscription status,
|
|
42
|
-
* sends the notification to all their registered device tokens, and updates their
|
|
43
|
-
* token list to remove any failed tokens.
|
|
44
|
-
*
|
|
45
|
-
* @param teamId - The unique identifier of the team
|
|
46
|
-
* @param personId - The unique identifier of the person
|
|
47
|
-
* @param topic - The notification subscription topic (e.g., 'new-fine', 'fine-reminder', 'fine-state-change')
|
|
48
|
-
* @param notification - The notification content to send
|
|
49
|
-
*
|
|
50
|
-
* @returns A promise that resolves when the notification is sent and person data is updated
|
|
51
|
-
*
|
|
52
|
-
* @remarks
|
|
53
|
-
* The function will silently return without sending if:
|
|
54
|
-
* - The person does not exist in the database
|
|
55
|
-
* - The person is not signed in (signInProperties is null)
|
|
56
|
-
* - The person is not subscribed to the specified topic
|
|
57
|
-
*
|
|
58
|
-
* After sending, the person's token list is automatically updated to remove
|
|
59
|
-
* any tokens that are invalid or unregistered, maintaining clean notification data.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```typescript
|
|
63
|
-
* await pushNotification(
|
|
64
|
-
* teamId,
|
|
65
|
-
* personId,
|
|
66
|
-
* 'new-fine',
|
|
67
|
-
* {
|
|
68
|
-
* title: 'New Fine',
|
|
69
|
-
* body: 'You have received a new fine'
|
|
70
|
-
* }
|
|
71
|
-
* );
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
async function pushNotification(teamId, personId, topic, notification) {
|
|
75
|
-
const personSnapshot = await Firestore_1.Firestore.shared.person(teamId, personId).snapshot();
|
|
76
|
-
if (!personSnapshot.exists)
|
|
77
|
-
return;
|
|
78
|
-
const person = types_1.Person.builder.build(personSnapshot.data);
|
|
79
|
-
if (person.signInProperties === null || !person.signInProperties.notificationProperties.subscriptions.includes(topic))
|
|
80
|
-
return;
|
|
81
|
-
const tokens = person.signInProperties.notificationProperties.tokens.values;
|
|
82
|
-
const response = await _1.FirebaseConfiguration.shared.messaging.sendEachForMulticast({
|
|
83
|
-
tokens: tokens,
|
|
84
|
-
notification: notification
|
|
85
|
-
});
|
|
86
|
-
person.signInProperties.notificationProperties.tokens = successfulTokens(response, tokens);
|
|
87
|
-
await Firestore_1.Firestore.shared.person(teamId, personId).set(person);
|
|
88
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FirebaseFunction } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { NotificationProperties, Person, Team } from '../../types';
|
|
3
|
-
import { ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
|
-
export declare namespace NotificationSubscribeFunction {
|
|
5
|
-
type Parameters = {
|
|
6
|
-
teamId: Team.Id;
|
|
7
|
-
personId: Person.Id;
|
|
8
|
-
subscriptions: NotificationProperties.Subscription[];
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export declare class NotificationSubscribeFunction implements FirebaseFunction<NotificationSubscribeFunction.Parameters, void> {
|
|
12
|
-
parametersBuilder: ObjectTypeBuilder<{
|
|
13
|
-
teamId: string;
|
|
14
|
-
personId: string;
|
|
15
|
-
subscriptions: ("new-fine" | "fine-reminder" | "fine-state-change")[];
|
|
16
|
-
}, NotificationSubscribeFunction.Parameters>;
|
|
17
|
-
returnTypeBuilder: ValueTypeBuilder<void>;
|
|
18
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { Currency } from './Currency';
|
|
3
|
-
import { Locale } from './Locale';
|
|
4
|
-
/**
|
|
5
|
-
* Represents the configuration settings that will be passed to the functions parameters.
|
|
6
|
-
* Contains currency and locale preferences.
|
|
7
|
-
*/
|
|
8
|
-
export declare class Configuration implements Flattable<Configuration.Flatten> {
|
|
9
|
-
currency: Currency;
|
|
10
|
-
locale: Locale;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new Configuration instance.
|
|
13
|
-
* @param currency - The currency to use for monetary values (EUR, USD, ...)
|
|
14
|
-
* @param locale - The locale for localization (language/region)
|
|
15
|
-
*/
|
|
16
|
-
constructor(currency: Currency, locale: Locale);
|
|
17
|
-
/**
|
|
18
|
-
* Returns the flattened representation of the configuration.
|
|
19
|
-
* @returns The flattened configuration object
|
|
20
|
-
*/
|
|
21
|
-
get flatten(): Configuration.Flatten;
|
|
22
|
-
}
|
|
23
|
-
export declare namespace Configuration {
|
|
24
|
-
/**
|
|
25
|
-
* Flattened representation of Configuration for serialization.
|
|
26
|
-
*/
|
|
27
|
-
type Flatten = {
|
|
28
|
-
currency: Currency;
|
|
29
|
-
locale: Locale;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* TypeBuilder for constructing Configuration instances from flattened data.
|
|
33
|
-
*/
|
|
34
|
-
class TypeBuilder implements ITypeBuilder<Flatten, Configuration> {
|
|
35
|
-
/**
|
|
36
|
-
* Builds a Configuration instance from flattened data.
|
|
37
|
-
* @param flatten - The flattened configuration data
|
|
38
|
-
* @returns A new Configuration instance
|
|
39
|
-
*/
|
|
40
|
-
build(flatten: Flatten): Configuration;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Singleton builder instance for Configuration.
|
|
44
|
-
*/
|
|
45
|
-
const builder: TypeBuilder;
|
|
46
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Configuration = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Represents the configuration settings that will be passed to the functions parameters.
|
|
6
|
-
* Contains currency and locale preferences.
|
|
7
|
-
*/
|
|
8
|
-
class Configuration {
|
|
9
|
-
currency;
|
|
10
|
-
locale;
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new Configuration instance.
|
|
13
|
-
* @param currency - The currency to use for monetary values (EUR, USD, ...)
|
|
14
|
-
* @param locale - The locale for localization (language/region)
|
|
15
|
-
*/
|
|
16
|
-
constructor(currency, locale) {
|
|
17
|
-
this.currency = currency;
|
|
18
|
-
this.locale = locale;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Returns the flattened representation of the configuration.
|
|
22
|
-
* @returns The flattened configuration object
|
|
23
|
-
*/
|
|
24
|
-
get flatten() {
|
|
25
|
-
return {
|
|
26
|
-
currency: this.currency,
|
|
27
|
-
locale: this.locale
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.Configuration = Configuration;
|
|
32
|
-
(function (Configuration) {
|
|
33
|
-
/**
|
|
34
|
-
* TypeBuilder for constructing Configuration instances from flattened data.
|
|
35
|
-
*/
|
|
36
|
-
class TypeBuilder {
|
|
37
|
-
/**
|
|
38
|
-
* Builds a Configuration instance from flattened data.
|
|
39
|
-
* @param flatten - The flattened configuration data
|
|
40
|
-
* @returns A new Configuration instance
|
|
41
|
-
*/
|
|
42
|
-
build(flatten) {
|
|
43
|
-
return new Configuration(flatten.currency, flatten.locale);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
Configuration.TypeBuilder = TypeBuilder;
|
|
47
|
-
/**
|
|
48
|
-
* Singleton builder instance for Configuration.
|
|
49
|
-
*/
|
|
50
|
-
Configuration.builder = new TypeBuilder();
|
|
51
|
-
})(Configuration || (exports.Configuration = Configuration = {}));
|
package/lib/src/types/Fine.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Flattable, Guid, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { FineAmount } from './FineAmount';
|
|
3
|
-
import { PayedState } from './PayedState';
|
|
4
|
-
/**
|
|
5
|
-
* Represents a fine assigned to a person in a team.
|
|
6
|
-
*
|
|
7
|
-
* Contains information about the fine's payment status, date, reason, and monetary amount.
|
|
8
|
-
*/
|
|
9
|
-
export declare class Fine implements Flattable<Fine.Flatten> {
|
|
10
|
-
id: Fine.Id;
|
|
11
|
-
payedState: PayedState;
|
|
12
|
-
date: UtcDate;
|
|
13
|
-
reason: string;
|
|
14
|
-
amount: FineAmount;
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new Fine instance.
|
|
17
|
-
*
|
|
18
|
-
* @param id - Unique identifier for the fine (GUID)
|
|
19
|
-
* @param payedState - Payment status ('payed' or 'notPayed')
|
|
20
|
-
* @param date - Date when the fine was issued
|
|
21
|
-
* @param reason - Description or reason for the fine
|
|
22
|
-
* @param amount - Monetary amount of the fine
|
|
23
|
-
*/
|
|
24
|
-
constructor(id: Fine.Id, payedState: PayedState, date: UtcDate, reason: string, amount: FineAmount);
|
|
25
|
-
/**
|
|
26
|
-
* Returns the flattened representation for serialization.
|
|
27
|
-
*/
|
|
28
|
-
get flatten(): Fine.Flatten;
|
|
29
|
-
}
|
|
30
|
-
export declare namespace Fine {
|
|
31
|
-
/**
|
|
32
|
-
* Tagged GUID type for fine identifiers.
|
|
33
|
-
*/
|
|
34
|
-
type Id = Tagged<Guid, 'fine'>;
|
|
35
|
-
namespace Id {
|
|
36
|
-
/**
|
|
37
|
-
* Flattened representation of a fine ID (GUID string).
|
|
38
|
-
*/
|
|
39
|
-
type Flatten = string;
|
|
40
|
-
/**
|
|
41
|
-
* Type builder for Fine.Id serialization/deserialization.
|
|
42
|
-
*/
|
|
43
|
-
const builder: Tagged.TypeBuilder<Guid, "fine">;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Flattened representation of a Fine for serialization.
|
|
47
|
-
*/
|
|
48
|
-
type Flatten = {
|
|
49
|
-
id: Id.Flatten;
|
|
50
|
-
payedState: PayedState;
|
|
51
|
-
date: UtcDate.Flatten;
|
|
52
|
-
reason: string;
|
|
53
|
-
amount: FineAmount.Flatten;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Type builder for Fine serialization/deserialization.
|
|
57
|
-
*/
|
|
58
|
-
class TypeBuilder implements ITypeBuilder<Flatten, Fine> {
|
|
59
|
-
/**
|
|
60
|
-
* Builds a Fine instance from flattened data.
|
|
61
|
-
*
|
|
62
|
-
* @param value - Flattened fine data
|
|
63
|
-
* @returns Fine instance
|
|
64
|
-
*/
|
|
65
|
-
build(value: Flatten): Fine;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Singleton instance of TypeBuilder for Fine.
|
|
69
|
-
*/
|
|
70
|
-
const builder: TypeBuilder;
|
|
71
|
-
}
|
package/lib/src/types/Fine.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Fine = void 0;
|
|
4
|
-
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
|
-
const FineAmount_1 = require("./FineAmount");
|
|
6
|
-
/**
|
|
7
|
-
* Represents a fine assigned to a person in a team.
|
|
8
|
-
*
|
|
9
|
-
* Contains information about the fine's payment status, date, reason, and monetary amount.
|
|
10
|
-
*/
|
|
11
|
-
class Fine {
|
|
12
|
-
id;
|
|
13
|
-
payedState;
|
|
14
|
-
date;
|
|
15
|
-
reason;
|
|
16
|
-
amount;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new Fine instance.
|
|
19
|
-
*
|
|
20
|
-
* @param id - Unique identifier for the fine (GUID)
|
|
21
|
-
* @param payedState - Payment status ('payed' or 'notPayed')
|
|
22
|
-
* @param date - Date when the fine was issued
|
|
23
|
-
* @param reason - Description or reason for the fine
|
|
24
|
-
* @param amount - Monetary amount of the fine
|
|
25
|
-
*/
|
|
26
|
-
constructor(id, payedState, date, reason, amount) {
|
|
27
|
-
this.id = id;
|
|
28
|
-
this.payedState = payedState;
|
|
29
|
-
this.date = date;
|
|
30
|
-
this.reason = reason;
|
|
31
|
-
this.amount = amount;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns the flattened representation for serialization.
|
|
35
|
-
*/
|
|
36
|
-
get flatten() {
|
|
37
|
-
return {
|
|
38
|
-
id: this.id.flatten,
|
|
39
|
-
payedState: this.payedState,
|
|
40
|
-
date: this.date.flatten,
|
|
41
|
-
reason: this.reason,
|
|
42
|
-
amount: this.amount.flatten
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.Fine = Fine;
|
|
47
|
-
(function (Fine) {
|
|
48
|
-
let Id;
|
|
49
|
-
(function (Id) {
|
|
50
|
-
/**
|
|
51
|
-
* Type builder for Fine.Id serialization/deserialization.
|
|
52
|
-
*/
|
|
53
|
-
Id.builder = typescript_common_functionality_1.Tagged.builder('fine', typescript_common_functionality_1.Guid.builder);
|
|
54
|
-
})(Id = Fine.Id || (Fine.Id = {}));
|
|
55
|
-
/**
|
|
56
|
-
* Type builder for Fine serialization/deserialization.
|
|
57
|
-
*/
|
|
58
|
-
class TypeBuilder {
|
|
59
|
-
/**
|
|
60
|
-
* Builds a Fine instance from flattened data.
|
|
61
|
-
*
|
|
62
|
-
* @param value - Flattened fine data
|
|
63
|
-
* @returns Fine instance
|
|
64
|
-
*/
|
|
65
|
-
build(value) {
|
|
66
|
-
return new Fine(Id.builder.build(value.id), value.payedState, typescript_common_functionality_1.UtcDate.builder.build(value.date), value.reason, FineAmount_1.FineAmount.builder.build(value.amount));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
Fine.TypeBuilder = TypeBuilder;
|
|
70
|
-
/**
|
|
71
|
-
* Singleton instance of TypeBuilder for Fine.
|
|
72
|
-
*/
|
|
73
|
-
Fine.builder = new TypeBuilder();
|
|
74
|
-
})(Fine || (exports.Fine = Fine = {}));
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
-
import { MoneyAmount } from './MoneyAmount';
|
|
3
|
-
import { Configuration } from './Configuration';
|
|
4
|
-
import { Locale } from './Locale';
|
|
5
|
-
/**
|
|
6
|
-
* Represents the amount of a fine, either as a monetary value or as items.
|
|
7
|
-
*
|
|
8
|
-
* Can be either FineAmount.Money (e.g., $10) or FineAmount.Item (e.g., 2 crates of beer).
|
|
9
|
-
*/
|
|
10
|
-
export type FineAmount = FineAmount.Money | FineAmount.Item;
|
|
11
|
-
export declare namespace FineAmount {
|
|
12
|
-
/**
|
|
13
|
-
* Represents a fine amount as a monetary value.
|
|
14
|
-
*/
|
|
15
|
-
class Money implements Flattable<Money.Flatten> {
|
|
16
|
-
amount: MoneyAmount;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new Money fine amount.
|
|
19
|
-
*
|
|
20
|
-
* @param amount - The monetary amount
|
|
21
|
-
*/
|
|
22
|
-
constructor(amount: MoneyAmount);
|
|
23
|
-
/**
|
|
24
|
-
* Returns a formatted string representation of the amount.
|
|
25
|
-
*
|
|
26
|
-
* @param configuration - Configuration containing currency and locale
|
|
27
|
-
* @returns Formatted currency string (e.g., "$10.50")
|
|
28
|
-
*/
|
|
29
|
-
formatted(configuration: Configuration): string;
|
|
30
|
-
/**
|
|
31
|
-
* Returns a new Money instance with the amount multiplied by a factor.
|
|
32
|
-
*
|
|
33
|
-
* @param factor - The multiplication factor
|
|
34
|
-
* @returns New Money instance with multiplied amount
|
|
35
|
-
*/
|
|
36
|
-
multiplied(factor: number): Money;
|
|
37
|
-
/**
|
|
38
|
-
* Returns the flattened representation for serialization.
|
|
39
|
-
*/
|
|
40
|
-
get flatten(): Money.Flatten;
|
|
41
|
-
}
|
|
42
|
-
namespace Money {
|
|
43
|
-
/**
|
|
44
|
-
* Flattened representation of Money for serialization.
|
|
45
|
-
*/
|
|
46
|
-
type Flatten = {
|
|
47
|
-
type: 'money';
|
|
48
|
-
amount: MoneyAmount.Flatten;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Type builder for Money serialization/deserialization.
|
|
52
|
-
*/
|
|
53
|
-
class TypeBuilder implements ITypeBuilder<Flatten, Money> {
|
|
54
|
-
/**
|
|
55
|
-
* Builds a Money instance from flattened data.
|
|
56
|
-
*
|
|
57
|
-
* @param value - Flattened money data
|
|
58
|
-
* @returns Money instance
|
|
59
|
-
*/
|
|
60
|
-
build(value: Flatten): Money;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Singleton instance of TypeBuilder for Money.
|
|
64
|
-
*/
|
|
65
|
-
const builder: TypeBuilder;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Represents a fine amount as a quantity of items.
|
|
69
|
-
*/
|
|
70
|
-
class Item implements Flattable<Item.Flatten> {
|
|
71
|
-
item: Item.Type;
|
|
72
|
-
count: number;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a new Item fine amount.
|
|
75
|
-
*
|
|
76
|
-
* @param item - The item type (e.g., 'crateOfBeer')
|
|
77
|
-
* @param count - The number of items
|
|
78
|
-
*/
|
|
79
|
-
constructor(item: Item.Type, count: number);
|
|
80
|
-
/**
|
|
81
|
-
* Returns a formatted string representation including count.
|
|
82
|
-
*
|
|
83
|
-
* @param locale - The locale for formatting
|
|
84
|
-
* @returns Formatted string (e.g., "2 crates of beer")
|
|
85
|
-
*/
|
|
86
|
-
formatted(locale: Locale): string;
|
|
87
|
-
/**
|
|
88
|
-
* Returns a formatted string representation including count.
|
|
89
|
-
*
|
|
90
|
-
* @param configuration - Configuration containing locale
|
|
91
|
-
* @returns Formatted string (e.g., "2 crates of beer")
|
|
92
|
-
*/
|
|
93
|
-
formatted(configuration: Configuration): string;
|
|
94
|
-
/**
|
|
95
|
-
* Returns a formatted string representation without explicitly showing count.
|
|
96
|
-
*
|
|
97
|
-
* @param locale - The locale for formatting
|
|
98
|
-
* @returns Formatted string without count display
|
|
99
|
-
*/
|
|
100
|
-
formattedWithoutCount(locale: Locale): string;
|
|
101
|
-
/**
|
|
102
|
-
* Returns a new Item instance with the count multiplied by a factor.
|
|
103
|
-
*
|
|
104
|
-
* @param factor - The multiplication factor
|
|
105
|
-
* @returns New Item instance with multiplied count
|
|
106
|
-
*/
|
|
107
|
-
multiplied(factor: number): Item;
|
|
108
|
-
/**
|
|
109
|
-
* Returns the flattened representation for serialization.
|
|
110
|
-
*/
|
|
111
|
-
get flatten(): Item.Flatten;
|
|
112
|
-
}
|
|
113
|
-
namespace Item {
|
|
114
|
-
const itemTypes: readonly ["crateOfBeer"];
|
|
115
|
-
/**
|
|
116
|
-
* Item type: currently only 'crateOfBeer'.
|
|
117
|
-
*/
|
|
118
|
-
export type Type = typeof itemTypes[number];
|
|
119
|
-
export namespace Type {
|
|
120
|
-
/**
|
|
121
|
-
* Array containing all possible item types.
|
|
122
|
-
*/
|
|
123
|
-
const all: readonly Type[];
|
|
124
|
-
/**
|
|
125
|
-
* Returns the localized name for an item type.
|
|
126
|
-
*
|
|
127
|
-
* @param type - The item type
|
|
128
|
-
* @param locale - The locale to use for formatting
|
|
129
|
-
* @returns Localized item name
|
|
130
|
-
*/
|
|
131
|
-
function formatted(type: Type, locale: Locale): string;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Flattened representation of Item for serialization.
|
|
135
|
-
*/
|
|
136
|
-
export type Flatten = {
|
|
137
|
-
type: 'item';
|
|
138
|
-
item: Item.Type;
|
|
139
|
-
count: number;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Type builder for Item serialization/deserialization.
|
|
143
|
-
*/
|
|
144
|
-
export class TypeBuilder implements ITypeBuilder<Flatten, Item> {
|
|
145
|
-
/**
|
|
146
|
-
* Builds an Item instance from flattened data.
|
|
147
|
-
*
|
|
148
|
-
* @param value - Flattened item data
|
|
149
|
-
* @returns Item instance
|
|
150
|
-
*/
|
|
151
|
-
build(value: Flatten): Item;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Singleton instance of TypeBuilder for Item.
|
|
155
|
-
*/
|
|
156
|
-
export const builder: TypeBuilder;
|
|
157
|
-
export {};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Creates a Money fine amount.
|
|
161
|
-
*
|
|
162
|
-
* @param MoneyAmount - The monetary amount
|
|
163
|
-
* @returns Money instance
|
|
164
|
-
*/
|
|
165
|
-
function money(MoneyAmount: MoneyAmount): Money;
|
|
166
|
-
/**
|
|
167
|
-
* Creates an Item fine amount.
|
|
168
|
-
*
|
|
169
|
-
* @param item - The item type
|
|
170
|
-
* @param count - The number of items
|
|
171
|
-
* @returns Item instance
|
|
172
|
-
*/
|
|
173
|
-
function item(item: Item.Type, count: number): Item;
|
|
174
|
-
/**
|
|
175
|
-
* Compares two fine amounts and returns their relative ordering.
|
|
176
|
-
*
|
|
177
|
-
* Money amounts are considered greater than Item amounts.
|
|
178
|
-
* Within the same type, values are compared numerically.
|
|
179
|
-
*
|
|
180
|
-
* @param lhs - First fine amount to compare
|
|
181
|
-
* @param rhs - Second fine amount to compare
|
|
182
|
-
* @returns 'less' if lhs < rhs, 'equal' if lhs === rhs, 'greater' if lhs > rhs
|
|
183
|
-
*/
|
|
184
|
-
function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater';
|
|
185
|
-
/**
|
|
186
|
-
* Flattened representation of FineAmount (union of Money.Flatten and Item.Flatten).
|
|
187
|
-
*/
|
|
188
|
-
type Flatten = Money.Flatten | Item.Flatten;
|
|
189
|
-
/**
|
|
190
|
-
* Type builder for FineAmount serialization/deserialization.
|
|
191
|
-
*/
|
|
192
|
-
class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
|
|
193
|
-
/**
|
|
194
|
-
* Builds a FineAmount instance from flattened data.
|
|
195
|
-
*
|
|
196
|
-
* Determines the type based on the 'type' discriminator field.
|
|
197
|
-
*
|
|
198
|
-
* @param value - Flattened fine amount data
|
|
199
|
-
* @returns FineAmount instance (Money or Item)
|
|
200
|
-
*/
|
|
201
|
-
build(value: Flatten): FineAmount;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Singleton instance of TypeBuilder for FineAmount.
|
|
205
|
-
*/
|
|
206
|
-
const builder: TypeBuilder;
|
|
207
|
-
}
|