@stevenkellner/team-conduct-api 1.0.35 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/firebase/FirebaseConfiguration.d.ts +45 -1
- package/lib/src/firebase/FirebaseConfiguration.js +44 -0
- package/lib/src/firebase/Firestore.d.ts +196 -0
- package/lib/src/firebase/Firestore.js +235 -0
- package/lib/src/{FirestoreScheme.d.ts → firebase/FirestoreScheme.d.ts} +15 -1
- package/lib/src/firebase/Messaging.d.ts +64 -0
- package/lib/src/firebase/checkAuthentication.d.ts +37 -0
- package/lib/src/{checkAuthentication.js → firebase/checkAuthentication.js} +26 -1
- package/lib/src/firebase/index.d.ts +4 -0
- package/lib/src/firebase/index.js +4 -0
- package/lib/src/firebase/pushNotification.d.ts +39 -0
- package/lib/src/firebase/pushNotification.js +88 -0
- package/lib/src/functions/fine/add.d.ts +10 -13
- package/lib/src/functions/fine/add.js +3 -30
- package/lib/src/functions/fine/delete.d.ts +10 -13
- package/lib/src/functions/fine/delete.js +3 -27
- package/lib/src/functions/fine/update.d.ts +10 -13
- package/lib/src/functions/fine/update.js +3 -28
- package/lib/src/functions/fineTemplate/add.d.ts +6 -9
- package/lib/src/functions/fineTemplate/add.js +3 -12
- package/lib/src/functions/fineTemplate/delete.d.ts +6 -9
- package/lib/src/functions/fineTemplate/delete.js +3 -12
- package/lib/src/functions/fineTemplate/update.d.ts +6 -9
- package/lib/src/functions/fineTemplate/update.js +3 -12
- package/lib/src/functions/invitation/getInvitation.d.ts +41 -42
- package/lib/src/functions/invitation/getInvitation.js +58 -81
- package/lib/src/functions/invitation/invite.d.ts +1 -2
- package/lib/src/functions/invitation/invite.js +3 -18
- package/lib/src/functions/invitation/register.d.ts +6 -11
- package/lib/src/functions/invitation/register.js +3 -39
- package/lib/src/functions/invitation/withdraw.d.ts +1 -2
- package/lib/src/functions/invitation/withdraw.js +3 -13
- package/lib/src/functions/notification/register.d.ts +7 -10
- package/lib/src/functions/notification/register.js +3 -15
- package/lib/src/functions/notification/subscribe.d.ts +8 -11
- package/lib/src/functions/notification/subscribe.js +3 -14
- package/lib/src/functions/paypalMe/edit.d.ts +6 -9
- package/lib/src/functions/paypalMe/edit.js +3 -14
- package/lib/src/functions/person/add.d.ts +7 -10
- package/lib/src/functions/person/add.js +3 -12
- package/lib/src/functions/person/delete.d.ts +6 -9
- package/lib/src/functions/person/delete.js +3 -14
- package/lib/src/functions/person/update.d.ts +7 -10
- package/lib/src/functions/person/update.js +3 -13
- package/lib/src/functions/team/new.d.ts +9 -12
- package/lib/src/functions/team/new.js +3 -22
- package/lib/src/functions/user/kickout.d.ts +6 -9
- package/lib/src/functions/user/kickout.js +3 -25
- package/lib/src/functions/user/login.d.ts +1 -2
- package/lib/src/functions/user/login.js +3 -13
- package/lib/src/functions/user/roleEdit.d.ts +8 -11
- package/lib/src/functions/user/roleEdit.js +3 -18
- package/lib/src/index.d.ts +0 -5
- package/lib/src/index.js +0 -5
- package/lib/src/locales/de.d.ts +10 -67
- package/lib/src/locales/de.js +8 -0
- package/lib/src/locales/en.d.ts +10 -0
- package/lib/src/locales/en.js +19 -2
- package/lib/src/types/Configuration.d.ts +33 -15
- package/lib/src/types/Configuration.js +24 -12
- package/lib/src/types/Currency.d.ts +20 -0
- package/lib/src/types/Currency.js +19 -0
- package/lib/src/types/Fine.d.ts +41 -0
- package/lib/src/types/Fine.js +32 -0
- package/lib/src/types/FineAmount.d.ts +160 -9
- package/lib/src/types/FineAmount.js +128 -7
- package/lib/src/types/FineTemplate.d.ts +41 -0
- package/lib/src/types/FineTemplate.js +32 -0
- package/lib/src/types/FineTemplateRepetition.d.ts +72 -10
- package/lib/src/types/FineTemplateRepetition.js +66 -12
- package/lib/src/types/Invitation.d.ts +48 -0
- package/lib/src/types/Invitation.js +39 -0
- package/lib/src/types/Locale.d.ts +16 -0
- package/lib/src/types/Locale.js +16 -0
- package/lib/src/types/Localization.d.ts +74 -74
- package/lib/src/types/Localization.js +80 -41
- package/lib/src/types/MoneyAmount.d.ts +67 -1
- package/lib/src/types/MoneyAmount.js +62 -0
- package/lib/src/types/NotificationProperties.d.ts +70 -9
- package/lib/src/types/NotificationProperties.js +49 -5
- package/lib/src/types/PayedState.d.ts +25 -9
- package/lib/src/types/PayedState.js +17 -27
- package/lib/src/types/Person.d.ts +45 -0
- package/lib/src/types/Person.js +36 -0
- package/lib/src/types/PersonPrivateProperties.d.ts +28 -0
- package/lib/src/types/PersonPrivateProperties.js +25 -0
- package/lib/src/types/PersonSignInProperties.d.ts +30 -0
- package/lib/src/types/PersonSignInProperties.js +27 -0
- package/lib/src/types/Pluralization.d.ts +46 -0
- package/lib/src/types/Pluralization.js +46 -0
- package/lib/src/types/Team.d.ts +38 -0
- package/lib/src/types/Team.js +29 -0
- package/lib/src/types/User.d.ts +68 -3
- package/lib/src/types/User.js +59 -5
- package/lib/src/types/UserRole.d.ts +26 -4
- package/lib/src/types/UserRole.js +25 -9
- package/lib/src/types/index.d.ts +2 -0
- package/lib/src/types/index.js +2 -0
- package/lib/test/firebase/FirebaseConfiguration.test.js +155 -0
- package/lib/test/firebase/Firestore.test.js +46 -0
- package/lib/test/firebase/checkAuthentication.test.d.ts +1 -0
- package/lib/test/firebase/checkAuthentication.test.js +305 -0
- package/lib/test/firebase/firebase-utils.d.ts +32 -0
- package/lib/test/firebase/firebase-utils.js +131 -0
- package/lib/test/firebase/pushNotification.test.d.ts +1 -0
- package/lib/test/firebase/pushNotification.test.js +300 -0
- package/lib/test/locales/localization.de.test.d.ts +1 -0
- package/lib/test/locales/localization.de.test.js +144 -0
- package/lib/test/locales/localization.en.test.d.ts +1 -0
- package/lib/test/locales/localization.en.test.js +144 -0
- package/lib/test/types/Configuration.test.d.ts +1 -0
- package/lib/test/types/Configuration.test.js +84 -0
- package/lib/test/types/Currency.test.d.ts +1 -0
- package/lib/test/types/Currency.test.js +41 -0
- package/lib/test/types/Fine.test.d.ts +1 -0
- package/lib/test/types/Fine.test.js +265 -0
- package/lib/test/types/FineAmount.test.d.ts +1 -0
- package/lib/test/types/FineAmount.test.js +445 -0
- package/lib/test/types/FineTemplate.test.d.ts +1 -0
- package/lib/test/types/FineTemplate.test.js +271 -0
- package/lib/test/types/FineTemplateRepetition.test.d.ts +1 -0
- package/lib/test/types/FineTemplateRepetition.test.js +361 -0
- package/lib/test/types/Invitation.test.d.ts +1 -0
- package/lib/test/types/Invitation.test.js +269 -0
- package/lib/test/types/Locale.test.d.ts +1 -0
- package/lib/test/types/Locale.test.js +46 -0
- package/lib/test/types/Localization.test.d.ts +1 -0
- package/lib/test/types/Localization.test.js +241 -0
- package/lib/test/types/MoneyAmount.test.d.ts +1 -0
- package/lib/test/types/MoneyAmount.test.js +276 -0
- package/lib/test/types/NotificationProperties.test.d.ts +1 -0
- package/lib/test/types/NotificationProperties.test.js +258 -0
- package/lib/test/types/PayedState.test.d.ts +1 -0
- package/lib/test/types/PayedState.test.js +105 -0
- package/lib/test/types/Person.test.d.ts +1 -0
- package/lib/test/types/Person.test.js +266 -0
- package/lib/test/types/PersonPrivateProperties.test.d.ts +1 -0
- package/lib/test/types/PersonPrivateProperties.test.js +155 -0
- package/lib/test/types/PersonSignInProperties.test.d.ts +1 -0
- package/lib/test/types/PersonSignInProperties.test.js +208 -0
- package/lib/test/types/Pluralization.test.d.ts +1 -0
- package/lib/test/types/Pluralization.test.js +206 -0
- package/lib/test/types/Team.test.d.ts +1 -0
- package/lib/test/types/Team.test.js +145 -0
- package/lib/test/types/User.test.d.ts +1 -0
- package/lib/test/types/User.test.js +232 -0
- package/lib/test/types/UserRole.test.d.ts +1 -0
- package/lib/test/types/UserRole.test.js +140 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/src/firebase/FirebaseConfiguration.ts +49 -1
- package/src/firebase/Firestore.ts +248 -0
- package/src/{FirestoreScheme.ts → firebase/FirestoreScheme.ts} +15 -1
- package/src/firebase/Messaging.ts +64 -0
- package/src/{checkAuthentication.ts → firebase/checkAuthentication.ts} +39 -1
- package/src/firebase/index.ts +5 -0
- package/src/firebase/pushNotification.ts +90 -0
- package/src/functions/fine/add.ts +10 -48
- package/src/functions/fine/delete.ts +9 -43
- package/src/functions/fine/update.ts +10 -44
- package/src/functions/fineTemplate/add.ts +7 -23
- package/src/functions/fineTemplate/delete.ts +7 -23
- package/src/functions/fineTemplate/update.ts +7 -24
- package/src/functions/index.ts +0 -1
- package/src/functions/invitation/getInvitation.ts +83 -109
- package/src/functions/invitation/invite.ts +2 -25
- package/src/functions/invitation/register.ts +9 -60
- package/src/functions/invitation/withdraw.ts +2 -16
- package/src/functions/notification/register.ts +7 -26
- package/src/functions/notification/subscribe.ts +8 -26
- package/src/functions/paypalMe/edit.ts +7 -25
- package/src/functions/person/add.ts +8 -24
- package/src/functions/person/delete.ts +6 -25
- package/src/functions/person/update.ts +8 -25
- package/src/functions/team/new.ts +12 -42
- package/src/functions/user/kickout.ts +8 -41
- package/src/functions/user/login.ts +2 -16
- package/src/functions/user/roleEdit.ts +8 -32
- package/src/index.ts +0 -5
- package/src/locales/de.ts +10 -1
- package/src/locales/en.ts +21 -2
- package/src/types/Configuration.ts +33 -23
- package/src/types/Currency.ts +24 -0
- package/src/types/Fine.ts +41 -0
- package/src/types/FineAmount.ts +162 -11
- package/src/types/FineTemplate.ts +41 -0
- package/src/types/FineTemplateRepetition.ts +75 -17
- package/src/types/Invitation.ts +48 -0
- package/src/types/Locale.ts +20 -0
- package/src/types/Localization.ts +96 -41
- package/src/types/MoneyAmount.ts +67 -1
- package/src/types/NotificationProperties.ts +67 -9
- package/src/types/PayedState.ts +25 -30
- package/src/types/Person.ts +45 -0
- package/src/types/PersonPrivateProperties.ts +28 -1
- package/src/types/PersonSignInProperties.ts +30 -0
- package/src/types/Pluralization.ts +46 -0
- package/src/types/Team.ts +38 -0
- package/src/types/User.ts +70 -4
- package/src/types/UserRole.ts +32 -16
- package/src/types/index.ts +2 -0
- package/lib/src/Firestore.d.ts +0 -24
- package/lib/src/Firestore.js +0 -62
- package/lib/src/checkAuthentication.d.ts +0 -6
- package/lib/src/firebaseFunctionsContext.d.ts +0 -39
- package/lib/src/firebaseFunctionsContext.js +0 -43
- package/lib/src/pushNotification.d.ts +0 -3
- package/lib/src/pushNotification.js +0 -35
- package/lib/test/localization-utils.d.ts +0 -1
- package/lib/test/localization-utils.js +0 -24
- package/lib/test/localization.de.test.js +0 -151
- package/lib/test/localization.en.test.js +0 -145
- package/src/Firestore.ts +0 -75
- package/src/firebaseFunctionsContext.ts +0 -48
- package/src/pushNotification.ts +0 -37
- /package/lib/src/{FirestoreScheme.js → firebase/FirestoreScheme.js} +0 -0
- /package/lib/test/{localization.de.test.d.ts → firebase/FirebaseConfiguration.test.d.ts} +0 -0
- /package/lib/test/{localization.en.test.d.ts → firebase/Firestore.test.d.ts} +0 -0
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Configuration = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Represents the configuration settings that will be passed to the functions parameters.
|
|
6
|
+
* Contains currency and locale preferences.
|
|
7
|
+
*/
|
|
6
8
|
class Configuration {
|
|
7
9
|
currency;
|
|
8
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
|
+
*/
|
|
9
16
|
constructor(currency, locale) {
|
|
10
17
|
this.currency = currency;
|
|
11
18
|
this.locale = locale;
|
|
12
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns the flattened representation of the configuration.
|
|
22
|
+
* @returns The flattened configuration object
|
|
23
|
+
*/
|
|
13
24
|
get flatten() {
|
|
14
25
|
return {
|
|
15
26
|
currency: this.currency,
|
|
@@ -19,21 +30,22 @@ class Configuration {
|
|
|
19
30
|
}
|
|
20
31
|
exports.Configuration = Configuration;
|
|
21
32
|
(function (Configuration) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Currency.builder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
26
|
-
})(Currency = Configuration.Currency || (Configuration.Currency = {}));
|
|
27
|
-
let Locale;
|
|
28
|
-
(function (Locale) {
|
|
29
|
-
Locale.all = (0, typescript_common_functionality_1.keys)(Localization_1.localizations);
|
|
30
|
-
Locale.builder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
31
|
-
})(Locale = Configuration.Locale || (Configuration.Locale = {}));
|
|
33
|
+
/**
|
|
34
|
+
* TypeBuilder for constructing Configuration instances from flattened data.
|
|
35
|
+
*/
|
|
32
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
|
+
*/
|
|
33
42
|
build(flatten) {
|
|
34
43
|
return new Configuration(flatten.currency, flatten.locale);
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
Configuration.TypeBuilder = TypeBuilder;
|
|
47
|
+
/**
|
|
48
|
+
* Singleton builder instance for Configuration.
|
|
49
|
+
*/
|
|
38
50
|
Configuration.builder = new TypeBuilder();
|
|
39
51
|
})(Configuration || (exports.Configuration = Configuration = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
/**
|
|
3
|
+
* Array of all available currencies.
|
|
4
|
+
*/
|
|
5
|
+
declare const currencies: readonly ["EUR", "USD"];
|
|
6
|
+
/**
|
|
7
|
+
* Supported currency types.
|
|
8
|
+
*/
|
|
9
|
+
export type Currency = typeof currencies[number];
|
|
10
|
+
export declare namespace Currency {
|
|
11
|
+
/**
|
|
12
|
+
* Array of all available currencies.
|
|
13
|
+
*/
|
|
14
|
+
const all: readonly Currency[];
|
|
15
|
+
/**
|
|
16
|
+
* Builder for constructing Currency values.
|
|
17
|
+
*/
|
|
18
|
+
const builder: ValueTypeBuilder<"EUR" | "USD">;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Currency = void 0;
|
|
4
|
+
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
|
+
/**
|
|
6
|
+
* Array of all available currencies.
|
|
7
|
+
*/
|
|
8
|
+
const currencies = ['EUR', 'USD'];
|
|
9
|
+
var Currency;
|
|
10
|
+
(function (Currency) {
|
|
11
|
+
/**
|
|
12
|
+
* Array of all available currencies.
|
|
13
|
+
*/
|
|
14
|
+
Currency.all = currencies;
|
|
15
|
+
/**
|
|
16
|
+
* Builder for constructing Currency values.
|
|
17
|
+
*/
|
|
18
|
+
Currency.builder = new typescript_common_functionality_1.ValueTypeBuilder();
|
|
19
|
+
})(Currency || (exports.Currency = Currency = {}));
|
package/lib/src/types/Fine.d.ts
CHANGED
|
@@ -1,21 +1,50 @@
|
|
|
1
1
|
import { Flattable, Guid, ITypeBuilder, Tagged, UtcDate } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { FineAmount } from './FineAmount';
|
|
3
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
|
+
*/
|
|
4
9
|
export declare class Fine implements Flattable<Fine.Flatten> {
|
|
5
10
|
id: Fine.Id;
|
|
6
11
|
payedState: PayedState;
|
|
7
12
|
date: UtcDate;
|
|
8
13
|
reason: string;
|
|
9
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
|
+
*/
|
|
10
24
|
constructor(id: Fine.Id, payedState: PayedState, date: UtcDate, reason: string, amount: FineAmount);
|
|
25
|
+
/**
|
|
26
|
+
* Returns the flattened representation for serialization.
|
|
27
|
+
*/
|
|
11
28
|
get flatten(): Fine.Flatten;
|
|
12
29
|
}
|
|
13
30
|
export declare namespace Fine {
|
|
31
|
+
/**
|
|
32
|
+
* Tagged GUID type for fine identifiers.
|
|
33
|
+
*/
|
|
14
34
|
type Id = Tagged<Guid, 'fine'>;
|
|
15
35
|
namespace Id {
|
|
36
|
+
/**
|
|
37
|
+
* Flattened representation of a fine ID (GUID string).
|
|
38
|
+
*/
|
|
16
39
|
type Flatten = string;
|
|
40
|
+
/**
|
|
41
|
+
* Type builder for Fine.Id serialization/deserialization.
|
|
42
|
+
*/
|
|
17
43
|
const builder: Tagged.TypeBuilder<Guid, "fine">;
|
|
18
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Flattened representation of a Fine for serialization.
|
|
47
|
+
*/
|
|
19
48
|
type Flatten = {
|
|
20
49
|
id: Id.Flatten;
|
|
21
50
|
payedState: PayedState;
|
|
@@ -23,8 +52,20 @@ export declare namespace Fine {
|
|
|
23
52
|
reason: string;
|
|
24
53
|
amount: FineAmount.Flatten;
|
|
25
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Type builder for Fine serialization/deserialization.
|
|
57
|
+
*/
|
|
26
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
|
+
*/
|
|
27
65
|
build(value: Flatten): Fine;
|
|
28
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Singleton instance of TypeBuilder for Fine.
|
|
69
|
+
*/
|
|
29
70
|
const builder: TypeBuilder;
|
|
30
71
|
}
|
package/lib/src/types/Fine.js
CHANGED
|
@@ -3,12 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Fine = void 0;
|
|
4
4
|
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
5
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
|
+
*/
|
|
6
11
|
class Fine {
|
|
7
12
|
id;
|
|
8
13
|
payedState;
|
|
9
14
|
date;
|
|
10
15
|
reason;
|
|
11
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
|
+
*/
|
|
12
26
|
constructor(id, payedState, date, reason, amount) {
|
|
13
27
|
this.id = id;
|
|
14
28
|
this.payedState = payedState;
|
|
@@ -16,6 +30,9 @@ class Fine {
|
|
|
16
30
|
this.reason = reason;
|
|
17
31
|
this.amount = amount;
|
|
18
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the flattened representation for serialization.
|
|
35
|
+
*/
|
|
19
36
|
get flatten() {
|
|
20
37
|
return {
|
|
21
38
|
id: this.id.flatten,
|
|
@@ -30,13 +47,28 @@ exports.Fine = Fine;
|
|
|
30
47
|
(function (Fine) {
|
|
31
48
|
let Id;
|
|
32
49
|
(function (Id) {
|
|
50
|
+
/**
|
|
51
|
+
* Type builder for Fine.Id serialization/deserialization.
|
|
52
|
+
*/
|
|
33
53
|
Id.builder = typescript_common_functionality_1.Tagged.builder('fine', typescript_common_functionality_1.Guid.builder);
|
|
34
54
|
})(Id = Fine.Id || (Fine.Id = {}));
|
|
55
|
+
/**
|
|
56
|
+
* Type builder for Fine serialization/deserialization.
|
|
57
|
+
*/
|
|
35
58
|
class TypeBuilder {
|
|
59
|
+
/**
|
|
60
|
+
* Builds a Fine instance from flattened data.
|
|
61
|
+
*
|
|
62
|
+
* @param value - Flattened fine data
|
|
63
|
+
* @returns Fine instance
|
|
64
|
+
*/
|
|
36
65
|
build(value) {
|
|
37
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));
|
|
38
67
|
}
|
|
39
68
|
}
|
|
40
69
|
Fine.TypeBuilder = TypeBuilder;
|
|
70
|
+
/**
|
|
71
|
+
* Singleton instance of TypeBuilder for Fine.
|
|
72
|
+
*/
|
|
41
73
|
Fine.builder = new TypeBuilder();
|
|
42
74
|
})(Fine || (exports.Fine = Fine = {}));
|
|
@@ -1,56 +1,207 @@
|
|
|
1
1
|
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { MoneyAmount } from './MoneyAmount';
|
|
3
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
|
+
*/
|
|
4
10
|
export type FineAmount = FineAmount.Money | FineAmount.Item;
|
|
5
11
|
export declare namespace FineAmount {
|
|
12
|
+
/**
|
|
13
|
+
* Represents a fine amount as a monetary value.
|
|
14
|
+
*/
|
|
6
15
|
class Money implements Flattable<Money.Flatten> {
|
|
7
16
|
amount: MoneyAmount;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new Money fine amount.
|
|
19
|
+
*
|
|
20
|
+
* @param amount - The monetary amount
|
|
21
|
+
*/
|
|
8
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
|
+
*/
|
|
9
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
|
+
*/
|
|
10
36
|
multiplied(factor: number): Money;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the flattened representation for serialization.
|
|
39
|
+
*/
|
|
11
40
|
get flatten(): Money.Flatten;
|
|
12
41
|
}
|
|
13
42
|
namespace Money {
|
|
43
|
+
/**
|
|
44
|
+
* Flattened representation of Money for serialization.
|
|
45
|
+
*/
|
|
14
46
|
type Flatten = {
|
|
15
47
|
type: 'money';
|
|
16
48
|
amount: MoneyAmount.Flatten;
|
|
17
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Type builder for Money serialization/deserialization.
|
|
52
|
+
*/
|
|
18
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
|
+
*/
|
|
19
60
|
build(value: Flatten): Money;
|
|
20
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Singleton instance of TypeBuilder for Money.
|
|
64
|
+
*/
|
|
21
65
|
const builder: TypeBuilder;
|
|
22
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Represents a fine amount as a quantity of items.
|
|
69
|
+
*/
|
|
23
70
|
class Item implements Flattable<Item.Flatten> {
|
|
24
71
|
item: Item.Type;
|
|
25
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
|
+
*/
|
|
26
79
|
constructor(item: Item.Type, count: number);
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
*/
|
|
29
107
|
multiplied(factor: number): Item;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the flattened representation for serialization.
|
|
110
|
+
*/
|
|
30
111
|
get flatten(): Item.Flatten;
|
|
31
112
|
}
|
|
32
113
|
namespace Item {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
132
|
}
|
|
38
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Flattened representation of Item for serialization.
|
|
135
|
+
*/
|
|
136
|
+
export type Flatten = {
|
|
39
137
|
type: 'item';
|
|
40
138
|
item: Item.Type;
|
|
41
139
|
count: number;
|
|
42
140
|
};
|
|
43
|
-
|
|
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
|
+
*/
|
|
44
151
|
build(value: Flatten): Item;
|
|
45
152
|
}
|
|
46
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Singleton instance of TypeBuilder for Item.
|
|
155
|
+
*/
|
|
156
|
+
export const builder: TypeBuilder;
|
|
157
|
+
export {};
|
|
47
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Creates a Money fine amount.
|
|
161
|
+
*
|
|
162
|
+
* @param MoneyAmount - The monetary amount
|
|
163
|
+
* @returns Money instance
|
|
164
|
+
*/
|
|
48
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
|
+
*/
|
|
49
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
|
+
*/
|
|
50
184
|
function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater';
|
|
185
|
+
/**
|
|
186
|
+
* Flattened representation of FineAmount (union of Money.Flatten and Item.Flatten).
|
|
187
|
+
*/
|
|
51
188
|
type Flatten = Money.Flatten | Item.Flatten;
|
|
189
|
+
/**
|
|
190
|
+
* Type builder for FineAmount serialization/deserialization.
|
|
191
|
+
*/
|
|
52
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
|
+
*/
|
|
53
201
|
build(value: Flatten): FineAmount;
|
|
54
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Singleton instance of TypeBuilder for FineAmount.
|
|
205
|
+
*/
|
|
55
206
|
const builder: TypeBuilder;
|
|
56
207
|
}
|
|
@@ -2,20 +2,44 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FineAmount = void 0;
|
|
4
4
|
const MoneyAmount_1 = require("./MoneyAmount");
|
|
5
|
+
const Configuration_1 = require("./Configuration");
|
|
5
6
|
const Localization_1 = require("./Localization");
|
|
6
7
|
var FineAmount;
|
|
7
8
|
(function (FineAmount) {
|
|
9
|
+
/**
|
|
10
|
+
* Represents a fine amount as a monetary value.
|
|
11
|
+
*/
|
|
8
12
|
class Money {
|
|
9
13
|
amount;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new Money fine amount.
|
|
16
|
+
*
|
|
17
|
+
* @param amount - The monetary amount
|
|
18
|
+
*/
|
|
10
19
|
constructor(amount) {
|
|
11
20
|
this.amount = amount;
|
|
12
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a formatted string representation of the amount.
|
|
24
|
+
*
|
|
25
|
+
* @param configuration - Configuration containing currency and locale
|
|
26
|
+
* @returns Formatted currency string (e.g., "$10.50")
|
|
27
|
+
*/
|
|
13
28
|
formatted(configuration) {
|
|
14
29
|
return this.amount.formatted(configuration.currency, configuration);
|
|
15
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns a new Money instance with the amount multiplied by a factor.
|
|
33
|
+
*
|
|
34
|
+
* @param factor - The multiplication factor
|
|
35
|
+
* @returns New Money instance with multiplied amount
|
|
36
|
+
*/
|
|
16
37
|
multiplied(factor) {
|
|
17
38
|
return new Money(this.amount.multiplied(factor));
|
|
18
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the flattened representation for serialization.
|
|
42
|
+
*/
|
|
19
43
|
get flatten() {
|
|
20
44
|
return {
|
|
21
45
|
type: 'money',
|
|
@@ -25,30 +49,67 @@ var FineAmount;
|
|
|
25
49
|
}
|
|
26
50
|
FineAmount.Money = Money;
|
|
27
51
|
(function (Money) {
|
|
52
|
+
/**
|
|
53
|
+
* Type builder for Money serialization/deserialization.
|
|
54
|
+
*/
|
|
28
55
|
class TypeBuilder {
|
|
56
|
+
/**
|
|
57
|
+
* Builds a Money instance from flattened data.
|
|
58
|
+
*
|
|
59
|
+
* @param value - Flattened money data
|
|
60
|
+
* @returns Money instance
|
|
61
|
+
*/
|
|
29
62
|
build(value) {
|
|
30
63
|
return new Money(MoneyAmount_1.MoneyAmount.builder.build(value.amount));
|
|
31
64
|
}
|
|
32
65
|
}
|
|
33
66
|
Money.TypeBuilder = TypeBuilder;
|
|
67
|
+
/**
|
|
68
|
+
* Singleton instance of TypeBuilder for Money.
|
|
69
|
+
*/
|
|
34
70
|
Money.builder = new TypeBuilder();
|
|
35
71
|
})(Money = FineAmount.Money || (FineAmount.Money = {}));
|
|
72
|
+
/**
|
|
73
|
+
* Represents a fine amount as a quantity of items.
|
|
74
|
+
*/
|
|
36
75
|
class Item {
|
|
37
76
|
item;
|
|
38
77
|
count;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new Item fine amount.
|
|
80
|
+
*
|
|
81
|
+
* @param item - The item type (e.g., 'crateOfBeer')
|
|
82
|
+
* @param count - The number of items
|
|
83
|
+
*/
|
|
39
84
|
constructor(item, count) {
|
|
40
85
|
this.item = item;
|
|
41
86
|
this.count = count;
|
|
42
87
|
}
|
|
43
|
-
formatted() {
|
|
44
|
-
|
|
88
|
+
formatted(configurationOrLocale) {
|
|
89
|
+
const locale = configurationOrLocale instanceof Configuration_1.Configuration ? configurationOrLocale.locale : configurationOrLocale;
|
|
90
|
+
return Localization_1.Localization.shared(locale).fineAmount.item.type[this.item].withCount.value(this.count);
|
|
45
91
|
}
|
|
46
|
-
|
|
47
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Returns a formatted string representation without explicitly showing count.
|
|
94
|
+
*
|
|
95
|
+
* @param locale - The locale for formatting
|
|
96
|
+
* @returns Formatted string without count display
|
|
97
|
+
*/
|
|
98
|
+
formattedWithoutCount(locale) {
|
|
99
|
+
return Localization_1.Localization.shared(locale).fineAmount.item.type[this.item].withoutCount.value(this.count);
|
|
48
100
|
}
|
|
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
|
+
*/
|
|
49
107
|
multiplied(factor) {
|
|
50
108
|
return new Item(this.item, this.count * factor);
|
|
51
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the flattened representation for serialization.
|
|
112
|
+
*/
|
|
52
113
|
get flatten() {
|
|
53
114
|
return {
|
|
54
115
|
type: 'item',
|
|
@@ -59,30 +120,76 @@ var FineAmount;
|
|
|
59
120
|
}
|
|
60
121
|
FineAmount.Item = Item;
|
|
61
122
|
(function (Item) {
|
|
123
|
+
const itemTypes = ['crateOfBeer'];
|
|
62
124
|
let Type;
|
|
63
125
|
(function (Type) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Array containing all possible item types.
|
|
128
|
+
*/
|
|
129
|
+
Type.all = itemTypes;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the localized name for an item type.
|
|
132
|
+
*
|
|
133
|
+
* @param type - The item type
|
|
134
|
+
* @param locale - The locale to use for formatting
|
|
135
|
+
* @returns Localized item name
|
|
136
|
+
*/
|
|
137
|
+
function formatted(type, locale) {
|
|
138
|
+
return Localization_1.Localization.shared(locale).fineAmount.item.type[type].name.value();
|
|
67
139
|
}
|
|
68
140
|
Type.formatted = formatted;
|
|
69
141
|
})(Type = Item.Type || (Item.Type = {}));
|
|
142
|
+
/**
|
|
143
|
+
* Type builder for Item serialization/deserialization.
|
|
144
|
+
*/
|
|
70
145
|
class TypeBuilder {
|
|
146
|
+
/**
|
|
147
|
+
* Builds an Item instance from flattened data.
|
|
148
|
+
*
|
|
149
|
+
* @param value - Flattened item data
|
|
150
|
+
* @returns Item instance
|
|
151
|
+
*/
|
|
71
152
|
build(value) {
|
|
72
153
|
return new Item(value.item, value.count);
|
|
73
154
|
}
|
|
74
155
|
}
|
|
75
156
|
Item.TypeBuilder = TypeBuilder;
|
|
157
|
+
/**
|
|
158
|
+
* Singleton instance of TypeBuilder for Item.
|
|
159
|
+
*/
|
|
76
160
|
Item.builder = new TypeBuilder();
|
|
77
161
|
})(Item = FineAmount.Item || (FineAmount.Item = {}));
|
|
162
|
+
/**
|
|
163
|
+
* Creates a Money fine amount.
|
|
164
|
+
*
|
|
165
|
+
* @param MoneyAmount - The monetary amount
|
|
166
|
+
* @returns Money instance
|
|
167
|
+
*/
|
|
78
168
|
function money(MoneyAmount) {
|
|
79
169
|
return new Money(MoneyAmount);
|
|
80
170
|
}
|
|
81
171
|
FineAmount.money = money;
|
|
172
|
+
/**
|
|
173
|
+
* Creates an Item fine amount.
|
|
174
|
+
*
|
|
175
|
+
* @param item - The item type
|
|
176
|
+
* @param count - The number of items
|
|
177
|
+
* @returns Item instance
|
|
178
|
+
*/
|
|
82
179
|
function item(item, count) {
|
|
83
180
|
return new Item(item, count);
|
|
84
181
|
}
|
|
85
182
|
FineAmount.item = item;
|
|
183
|
+
/**
|
|
184
|
+
* Compares two fine amounts and returns their relative ordering.
|
|
185
|
+
*
|
|
186
|
+
* Money amounts are considered greater than Item amounts.
|
|
187
|
+
* Within the same type, values are compared numerically.
|
|
188
|
+
*
|
|
189
|
+
* @param lhs - First fine amount to compare
|
|
190
|
+
* @param rhs - Second fine amount to compare
|
|
191
|
+
* @returns 'less' if lhs < rhs, 'equal' if lhs === rhs, 'greater' if lhs > rhs
|
|
192
|
+
*/
|
|
86
193
|
function compare(lhs, rhs) {
|
|
87
194
|
if (lhs instanceof Money) {
|
|
88
195
|
if (!(rhs instanceof Money))
|
|
@@ -102,7 +209,18 @@ var FineAmount;
|
|
|
102
209
|
return 'equal';
|
|
103
210
|
}
|
|
104
211
|
FineAmount.compare = compare;
|
|
212
|
+
/**
|
|
213
|
+
* Type builder for FineAmount serialization/deserialization.
|
|
214
|
+
*/
|
|
105
215
|
class TypeBuilder {
|
|
216
|
+
/**
|
|
217
|
+
* Builds a FineAmount instance from flattened data.
|
|
218
|
+
*
|
|
219
|
+
* Determines the type based on the 'type' discriminator field.
|
|
220
|
+
*
|
|
221
|
+
* @param value - Flattened fine amount data
|
|
222
|
+
* @returns FineAmount instance (Money or Item)
|
|
223
|
+
*/
|
|
106
224
|
build(value) {
|
|
107
225
|
switch (value.type) {
|
|
108
226
|
case 'money':
|
|
@@ -113,5 +231,8 @@ var FineAmount;
|
|
|
113
231
|
}
|
|
114
232
|
}
|
|
115
233
|
FineAmount.TypeBuilder = TypeBuilder;
|
|
234
|
+
/**
|
|
235
|
+
* Singleton instance of TypeBuilder for FineAmount.
|
|
236
|
+
*/
|
|
116
237
|
FineAmount.builder = new TypeBuilder();
|
|
117
238
|
})(FineAmount || (exports.FineAmount = FineAmount = {}));
|