@stevenkellner/team-conduct-api 1.0.14 → 1.0.16
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/locales/de.json +4 -0
- package/lib/src/locales/en.json +4 -0
- package/lib/src/types/FineAmount.d.ts +2 -0
- package/lib/src/types/FineAmount.js +22 -0
- package/lib/src/types/Localization.d.ts +1 -0
- package/lib/src/types/Localization.js +2 -1
- package/lib/test/localization.de.test.js +4 -0
- package/lib/test/localization.en.test.js +4 -0
- package/package.json +1 -1
- package/src/locales/de.json +4 -0
- package/src/locales/en.json +22 -18
- package/src/types/FineAmount.ts +23 -0
- package/src/types/Localization.ts +2 -1
package/lib/src/locales/de.json
CHANGED
package/lib/src/locales/en.json
CHANGED
|
@@ -24,6 +24,7 @@ export declare namespace FineAmount {
|
|
|
24
24
|
count: number;
|
|
25
25
|
constructor(item: Item.Type, count: number);
|
|
26
26
|
formatted(): string;
|
|
27
|
+
formattedWithoutCount(): string;
|
|
27
28
|
get flatten(): Item.Flatten;
|
|
28
29
|
}
|
|
29
30
|
namespace Item {
|
|
@@ -44,6 +45,7 @@ export declare namespace FineAmount {
|
|
|
44
45
|
}
|
|
45
46
|
function money(MoneyAmount: MoneyAmount): Money;
|
|
46
47
|
function item(item: Item.Type, count: number): Item;
|
|
48
|
+
function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater';
|
|
47
49
|
type Flatten = Money.Flatten | Item.Flatten;
|
|
48
50
|
class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
|
|
49
51
|
build(value: Flatten): FineAmount;
|
|
@@ -40,6 +40,9 @@ var FineAmount;
|
|
|
40
40
|
formatted() {
|
|
41
41
|
return Localization_1.Localization.shared.getN(key => key.fineAmount.item.type[this.item], this.count);
|
|
42
42
|
}
|
|
43
|
+
formattedWithoutCount() {
|
|
44
|
+
return Localization_1.Localization.shared.getN(key => key.fineAmount.item.type[`${this.item}WithoutCount`], this.count);
|
|
45
|
+
}
|
|
43
46
|
get flatten() {
|
|
44
47
|
return {
|
|
45
48
|
type: 'item',
|
|
@@ -74,6 +77,25 @@ var FineAmount;
|
|
|
74
77
|
return new Item(item, count);
|
|
75
78
|
}
|
|
76
79
|
FineAmount.item = item;
|
|
80
|
+
function compare(lhs, rhs) {
|
|
81
|
+
if (lhs instanceof Money) {
|
|
82
|
+
if (!(rhs instanceof Money))
|
|
83
|
+
return 'greater';
|
|
84
|
+
const lhsAmount = lhs.amount.completeValue;
|
|
85
|
+
const rhsAmount = rhs.amount.completeValue;
|
|
86
|
+
if (lhsAmount !== rhsAmount)
|
|
87
|
+
return lhsAmount < rhsAmount ? 'less' : 'greater';
|
|
88
|
+
}
|
|
89
|
+
if (lhs instanceof Item) {
|
|
90
|
+
if (!(rhs instanceof Item))
|
|
91
|
+
return 'less';
|
|
92
|
+
if (lhs.count === rhs.count)
|
|
93
|
+
return 'equal';
|
|
94
|
+
return lhs.count < rhs.count ? 'less' : 'greater';
|
|
95
|
+
}
|
|
96
|
+
return 'equal';
|
|
97
|
+
}
|
|
98
|
+
FineAmount.compare = compare;
|
|
77
99
|
class TypeBuilder {
|
|
78
100
|
build(value) {
|
|
79
101
|
switch (value.type) {
|
|
@@ -85,7 +85,8 @@ exports.localizationNKey = {
|
|
|
85
85
|
fineAmount: {
|
|
86
86
|
item: {
|
|
87
87
|
type: {
|
|
88
|
-
crateOfBeer: 'fineAmount.item.type.crateOfBeer?count=%s'
|
|
88
|
+
crateOfBeer: 'fineAmount.item.type.crateOfBeer?count=%s',
|
|
89
|
+
crateOfBeerWithoutCount: 'fineAmount.item.type.crateOfBeerWithoutCount?count=%s'
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
},
|
|
@@ -70,11 +70,15 @@ describe('Localization for de', () => {
|
|
|
70
70
|
testedKeys.test(key => key.fineAmount.item.type.crateOfBeer, 'Kasten Bier');
|
|
71
71
|
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 1, 'Ein Kasten Bier');
|
|
72
72
|
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 4, '4 Kästen Bier');
|
|
73
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeerWithoutCount, 1, 'Kasten Bier');
|
|
74
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeerWithoutCount, 4, 'Kästen Bier');
|
|
73
75
|
});
|
|
74
76
|
it('fineAmount.item.type.crateOfBeer should be formatted correctly', () => {
|
|
75
77
|
(0, core_1.expect)(types_1.FineAmount.Item.Type.formatted('crateOfBeer')).toBeEqual('Kasten Bier');
|
|
76
78
|
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formatted()).toBeEqual('Ein Kasten Bier');
|
|
77
79
|
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formatted()).toBeEqual('4 Kästen Bier');
|
|
80
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formattedWithoutCount()).toBeEqual('Kasten Bier');
|
|
81
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formattedWithoutCount()).toBeEqual('Kästen Bier');
|
|
78
82
|
});
|
|
79
83
|
});
|
|
80
84
|
describe('fineTemplateRepetition should be tested', () => {
|
|
@@ -66,11 +66,15 @@ describe('Localization for en', () => {
|
|
|
66
66
|
testedKeys.test(key => key.fineAmount.item.type.crateOfBeer, 'Crate of Beer');
|
|
67
67
|
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 1, 'a crate of beer');
|
|
68
68
|
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 4, '4 crates of beer');
|
|
69
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeerWithoutCount, 1, 'Crate of Beer');
|
|
70
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeerWithoutCount, 4, 'Crates of Beer');
|
|
69
71
|
});
|
|
70
72
|
it('fineAmount.item.type.crateOfBeer should be formatted correctly', () => {
|
|
71
73
|
(0, core_1.expect)(types_1.FineAmount.Item.Type.formatted('crateOfBeer')).toBeEqual('Crate of Beer');
|
|
72
74
|
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formatted()).toBeEqual('a crate of beer');
|
|
73
75
|
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formatted()).toBeEqual('4 crates of beer');
|
|
76
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formattedWithoutCount()).toBeEqual('Crate of Beer');
|
|
77
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formattedWithoutCount()).toBeEqual('Crates of Beer');
|
|
74
78
|
});
|
|
75
79
|
});
|
|
76
80
|
describe('fineTemplateRepetition should be tested', () => {
|
package/package.json
CHANGED
package/src/locales/de.json
CHANGED
package/src/locales/en.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
"notification": {
|
|
3
|
+
"fine": {
|
|
4
|
+
"new": {
|
|
5
|
+
"title": "%s",
|
|
6
|
+
"body": "You have a new fine of %s. Please pay it as soon as possible."
|
|
7
|
+
},
|
|
8
|
+
"reminder": {
|
|
9
|
+
"title": "You still have outstanding fines",
|
|
10
|
+
"body": "You still have %s outstanding. Please pay as soon as possible."
|
|
11
|
+
},
|
|
12
|
+
"state-change": {
|
|
13
|
+
"title": "One of your fines has changed",
|
|
14
|
+
"body-payed": "You have paid a fine of %1$s (%2$s).",
|
|
15
|
+
"body-unpayed": "%1$s, %2$s is still outstanding.",
|
|
16
|
+
"body-deleted": "%1$s, %2$s has been deleted."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
20
|
"fineAmount": {
|
|
21
21
|
"item": {
|
|
22
22
|
"type": {
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"crateOfBeer?count=%s": {
|
|
25
25
|
"one": "a crate of beer",
|
|
26
26
|
"other": "%s crates of beer"
|
|
27
|
+
},
|
|
28
|
+
"crateOfBeerWithoutCount?count=%s": {
|
|
29
|
+
"one": "Crate of Beer",
|
|
30
|
+
"other": "Crates of Beer"
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
}
|
package/src/types/FineAmount.ts
CHANGED
|
@@ -55,6 +55,10 @@ export namespace FineAmount {
|
|
|
55
55
|
return Localization.shared.getN(key => key.fineAmount.item.type[this.item], this.count);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
public formattedWithoutCount(): string {
|
|
59
|
+
return Localization.shared.getN(key => key.fineAmount.item.type[`${this.item}WithoutCount`], this.count);
|
|
60
|
+
}
|
|
61
|
+
|
|
58
62
|
public get flatten(): Item.Flatten {
|
|
59
63
|
return {
|
|
60
64
|
type: 'item',
|
|
@@ -103,6 +107,25 @@ export namespace FineAmount {
|
|
|
103
107
|
return new Item(item, count);
|
|
104
108
|
}
|
|
105
109
|
|
|
110
|
+
export function compare(lhs: FineAmount, rhs: FineAmount): 'less' | 'equal' | 'greater' {
|
|
111
|
+
if (lhs instanceof Money) {
|
|
112
|
+
if (!(rhs instanceof Money))
|
|
113
|
+
return 'greater';
|
|
114
|
+
const lhsAmount = lhs.amount.completeValue;
|
|
115
|
+
const rhsAmount = rhs.amount.completeValue;
|
|
116
|
+
if (lhsAmount !== rhsAmount)
|
|
117
|
+
return lhsAmount < rhsAmount ? 'less' : 'greater';
|
|
118
|
+
}
|
|
119
|
+
if (lhs instanceof Item) {
|
|
120
|
+
if (!(rhs instanceof Item))
|
|
121
|
+
return 'less';
|
|
122
|
+
if (lhs.count === rhs.count)
|
|
123
|
+
return 'equal';
|
|
124
|
+
return lhs.count < rhs.count ? 'less' : 'greater';
|
|
125
|
+
}
|
|
126
|
+
return 'equal';
|
|
127
|
+
}
|
|
128
|
+
|
|
106
129
|
export type Flatten = Money.Flatten | Item.Flatten;
|
|
107
130
|
|
|
108
131
|
export class TypeBuilder implements ITypeBuilder<Flatten, FineAmount> {
|
|
@@ -51,7 +51,8 @@ export const localizationNKey = {
|
|
|
51
51
|
fineAmount: {
|
|
52
52
|
item: {
|
|
53
53
|
type: {
|
|
54
|
-
crateOfBeer: 'fineAmount.item.type.crateOfBeer?count=%s'
|
|
54
|
+
crateOfBeer: 'fineAmount.item.type.crateOfBeer?count=%s',
|
|
55
|
+
crateOfBeerWithoutCount: 'fineAmount.item.type.crateOfBeerWithoutCount?count=%s'
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
},
|