@stevenkellner/team-conduct-api 1.0.21 → 1.0.23

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.
Files changed (42) hide show
  1. package/lib/src/functions/fine/add.js +7 -3
  2. package/lib/src/functions/fine/delete.js +5 -3
  3. package/lib/src/functions/fine/update.js +9 -6
  4. package/lib/src/locales/de.d.ts +66 -0
  5. package/lib/src/locales/de.js +99 -0
  6. package/lib/src/locales/en.d.ts +66 -0
  7. package/lib/src/locales/en.js +99 -0
  8. package/lib/src/types/Configuration.d.ts +3 -2
  9. package/lib/src/types/Configuration.js +2 -1
  10. package/lib/src/types/FineAmount.js +3 -3
  11. package/lib/src/types/FineTemplateRepetition.js +3 -3
  12. package/lib/src/types/Localization.d.ts +205 -60
  13. package/lib/src/types/Localization.js +65 -117
  14. package/lib/src/types/PayedState.js +1 -1
  15. package/lib/src/types/Pluralization.d.ts +17 -0
  16. package/lib/src/types/Pluralization.js +33 -0
  17. package/lib/src/types/UserRole.js +1 -1
  18. package/lib/src/types/index.d.ts +1 -0
  19. package/lib/src/types/index.js +1 -0
  20. package/lib/test/localization-utils.d.ts +0 -11
  21. package/lib/test/localization-utils.js +5 -49
  22. package/lib/test/localization.de.test.js +43 -80
  23. package/lib/test/localization.en.test.js +46 -85
  24. package/lib/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +3 -5
  26. package/src/functions/fine/add.ts +7 -3
  27. package/src/functions/fine/delete.ts +5 -3
  28. package/src/functions/fine/update.ts +10 -7
  29. package/src/locales/de.ts +97 -0
  30. package/src/locales/en.ts +97 -0
  31. package/src/types/Configuration.ts +4 -3
  32. package/src/types/FineAmount.ts +3 -3
  33. package/src/types/FineTemplateRepetition.ts +3 -3
  34. package/src/types/Localization.ts +67 -83
  35. package/src/types/PayedState.ts +1 -1
  36. package/src/types/Pluralization.ts +44 -0
  37. package/src/types/UserRole.ts +3 -3
  38. package/src/types/index.ts +1 -0
  39. package/lib/src/locales/de.json +0 -85
  40. package/lib/src/locales/en.json +0 -85
  41. package/src/locales/de.json +0 -85
  42. package/src/locales/en.json +0 -85
@@ -27,10 +27,14 @@ class FineAddFunction extends firebase_function_1.FirebaseFunction {
27
27
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.fine.id).set(parameters.fine);
28
28
  person.fineIds.push(parameters.fine.id);
29
29
  await Firestore_1.Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
30
- types_1.Localization.shared.setLocale(parameters.configuration.locale);
30
+ types_1.Localization.locale = parameters.configuration.locale;
31
31
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'new-fine', {
32
- title: types_1.Localization.shared.get(key => key.notification.fine.new.title, parameters.fine.reason),
33
- body: types_1.Localization.shared.get(key => key.notification.fine.new.body, parameters.fine.amount.formatted(parameters.configuration))
32
+ title: types_1.Localization.shared.notification.fine.new.title.value({
33
+ reason: parameters.fine.reason
34
+ }),
35
+ body: types_1.Localization.shared.notification.fine.new.body.value({
36
+ amount: parameters.fine.amount.formatted(parameters.configuration)
37
+ })
34
38
  });
35
39
  }
36
40
  }
@@ -27,10 +27,12 @@ class FineDeleteFunction extends firebase_function_1.FirebaseFunction {
27
27
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.id).remove();
28
28
  person.fineIds = person.fineIds.filter(id => id.guidString !== parameters.id.guidString);
29
29
  await Firestore_1.Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
30
- types_1.Localization.shared.setLocale(parameters.configuration.locale);
30
+ types_1.Localization.locale = parameters.configuration.locale;
31
31
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'fine-state-change', {
32
- title: types_1.Localization.shared.get(key => key.notification.fine.stateChange.title),
33
- body: types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyDeleted, fineSnapshot.data.reason, types_1.FineAmount.builder.build(fineSnapshot.data.amount).formatted(parameters.configuration))
32
+ title: types_1.Localization.shared.notification.fine.stateChange.title.value(),
33
+ body: types_1.Localization.shared.notification.fine.stateChange.bodyDeleted.value({
34
+ amount: types_1.FineAmount.builder.build(fineSnapshot.data.amount).formatted(parameters.configuration)
35
+ })
34
36
  });
35
37
  }
36
38
  }
@@ -22,16 +22,19 @@ class FineUpdateFunction extends firebase_function_1.FirebaseFunction {
22
22
  if (!fineSnapshot.exists)
23
23
  throw new firebase_function_1.FunctionsError('not-found', 'Fine not found');
24
24
  await Firestore_1.Firestore.shared.fine(parameters.teamId, parameters.fine.id).set(parameters.fine);
25
- types_1.Localization.shared.setLocale(parameters.configuration.locale);
25
+ types_1.Localization.locale = parameters.configuration.locale;
26
26
  if (parameters.fine.payedState !== fineSnapshot.data.payedState) {
27
- let body;
27
+ let bodyLocalization;
28
28
  if (parameters.fine.payedState === 'payed')
29
- body = types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyPayed, parameters.fine.amount.formatted(parameters.configuration), parameters.fine.reason);
29
+ bodyLocalization = types_1.Localization.shared.notification.fine.stateChange.bodyPayed;
30
30
  else
31
- body = types_1.Localization.shared.get(key => key.notification.fine.stateChange.bodyUnpayed, parameters.fine.reason, parameters.fine.amount.formatted(parameters.configuration));
31
+ bodyLocalization = types_1.Localization.shared.notification.fine.stateChange.bodyUnpayed;
32
32
  await (0, pushNotification_1.pushNotification)(parameters.teamId, parameters.personId, 'fine-state-change', {
33
- title: types_1.Localization.shared.get(key => key.notification.fine.stateChange.title),
34
- body: body
33
+ title: types_1.Localization.shared.notification.fine.stateChange.title.value(),
34
+ body: bodyLocalization.value({
35
+ reason: parameters.fine.reason,
36
+ amount: parameters.fine.amount.formatted(parameters.configuration)
37
+ })
35
38
  });
36
39
  }
37
40
  }
@@ -0,0 +1,66 @@
1
+ import { Pluralization } from '../types/Pluralization';
2
+ export declare const localizationDE: {
3
+ notification: {
4
+ fine: {
5
+ new: {
6
+ title: string;
7
+ body: string;
8
+ };
9
+ reminder: {
10
+ title: string;
11
+ body: string;
12
+ };
13
+ stateChange: {
14
+ title: string;
15
+ bodyPayed: string;
16
+ bodyUnpayed: string;
17
+ bodyDeleted: string;
18
+ };
19
+ };
20
+ };
21
+ fineAmount: {
22
+ item: {
23
+ type: {
24
+ crateOfBeer: {
25
+ name: string;
26
+ withCount: Pluralization;
27
+ withoutCount: Pluralization;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ fineTemplateRepetition: {
33
+ item: {
34
+ minute: {
35
+ name: string;
36
+ withCount: Pluralization;
37
+ withoutCount: Pluralization;
38
+ };
39
+ day: {
40
+ name: string;
41
+ withCount: Pluralization;
42
+ withoutCount: Pluralization;
43
+ };
44
+ item: {
45
+ name: string;
46
+ withCount: Pluralization;
47
+ withoutCount: Pluralization;
48
+ };
49
+ count: {
50
+ name: string;
51
+ withCount: Pluralization;
52
+ withoutCount: Pluralization;
53
+ };
54
+ };
55
+ };
56
+ payedState: {
57
+ payed: string;
58
+ notPayed: string;
59
+ };
60
+ userRole: {
61
+ personManager: string;
62
+ fineTemplateManager: string;
63
+ fineManager: string;
64
+ teamManager: string;
65
+ };
66
+ };
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localizationDE = void 0;
4
+ const Pluralization_1 = require("../types/Pluralization");
5
+ exports.localizationDE = {
6
+ notification: {
7
+ fine: {
8
+ new: {
9
+ title: '{{reason}}',
10
+ body: 'Du hast eine neue Strafe von {{amount}}. Bitte so schnell wie möglich zahlen.'
11
+ },
12
+ reminder: {
13
+ title: 'Du hast noch offene Strafen',
14
+ body: 'Bei dir sind noch {{amount}} offen. Bitte so schnell wie möglich zahlen.'
15
+ },
16
+ stateChange: {
17
+ title: 'Eine deiner Strafen hat sich geändert',
18
+ bodyPayed: 'Du hast eine Strafe von {{amount}} bezahlt ({{reason}}).',
19
+ bodyUnpayed: '{{reason}}, {{amount}} ist noch offen.',
20
+ bodyDeleted: '{{reason}}, {{amount}} wurde gelöscht.'
21
+ }
22
+ }
23
+ },
24
+ fineAmount: {
25
+ item: {
26
+ type: {
27
+ crateOfBeer: {
28
+ name: 'Kasten Bier',
29
+ withCount: new Pluralization_1.Pluralization({
30
+ one: 'Ein Kasten Bier',
31
+ other: '{{count}} Kästen Bier'
32
+ }),
33
+ withoutCount: new Pluralization_1.Pluralization({
34
+ one: 'Kasten Bier',
35
+ other: 'Kästen Bier'
36
+ })
37
+ }
38
+ }
39
+ }
40
+ },
41
+ fineTemplateRepetition: {
42
+ item: {
43
+ minute: {
44
+ name: 'Minute',
45
+ withCount: new Pluralization_1.Pluralization({
46
+ one: '1 Minute',
47
+ other: '{{count}} Minuten'
48
+ }),
49
+ withoutCount: new Pluralization_1.Pluralization({
50
+ one: 'Minute',
51
+ other: 'Minuten'
52
+ })
53
+ },
54
+ day: {
55
+ name: 'Tag',
56
+ withCount: new Pluralization_1.Pluralization({
57
+ one: '1 Tag',
58
+ other: '{{count}} Tage'
59
+ }),
60
+ withoutCount: new Pluralization_1.Pluralization({
61
+ one: 'Tag',
62
+ other: 'Tage'
63
+ })
64
+ },
65
+ item: {
66
+ name: 'Teil',
67
+ withCount: new Pluralization_1.Pluralization({
68
+ one: '1 Teil',
69
+ other: '{{count}} Teile'
70
+ }),
71
+ withoutCount: new Pluralization_1.Pluralization({
72
+ one: 'Teil',
73
+ other: 'Teile'
74
+ })
75
+ },
76
+ count: {
77
+ name: 'Anzahl',
78
+ withCount: new Pluralization_1.Pluralization({
79
+ one: '1 mal',
80
+ other: '{{count}} mal'
81
+ }),
82
+ withoutCount: new Pluralization_1.Pluralization({
83
+ one: 'mal',
84
+ other: 'mal'
85
+ })
86
+ }
87
+ }
88
+ },
89
+ payedState: {
90
+ payed: 'Bezahlt',
91
+ notPayed: 'Offen'
92
+ },
93
+ userRole: {
94
+ personManager: 'Personenmanager',
95
+ fineTemplateManager: 'Strafvorlagenmanager',
96
+ fineManager: 'Strafenmanager',
97
+ teamManager: 'Teammanager'
98
+ }
99
+ };
@@ -0,0 +1,66 @@
1
+ import { Pluralization } from '../types/Pluralization';
2
+ export declare const localizationEN: {
3
+ notification: {
4
+ fine: {
5
+ new: {
6
+ title: string;
7
+ body: string;
8
+ };
9
+ reminder: {
10
+ title: string;
11
+ body: string;
12
+ };
13
+ stateChange: {
14
+ title: string;
15
+ bodyPayed: string;
16
+ bodyUnpayed: string;
17
+ bodyDeleted: string;
18
+ };
19
+ };
20
+ };
21
+ fineAmount: {
22
+ item: {
23
+ type: {
24
+ crateOfBeer: {
25
+ name: string;
26
+ withCount: Pluralization;
27
+ withoutCount: Pluralization;
28
+ };
29
+ };
30
+ };
31
+ };
32
+ fineTemplateRepetition: {
33
+ item: {
34
+ minute: {
35
+ name: string;
36
+ withCount: Pluralization;
37
+ withoutCount: Pluralization;
38
+ };
39
+ day: {
40
+ name: string;
41
+ withCount: Pluralization;
42
+ withoutCount: Pluralization;
43
+ };
44
+ item: {
45
+ name: string;
46
+ withCount: Pluralization;
47
+ withoutCount: Pluralization;
48
+ };
49
+ count: {
50
+ name: string;
51
+ withCount: Pluralization;
52
+ withoutCount: Pluralization;
53
+ };
54
+ };
55
+ };
56
+ payedState: {
57
+ payed: string;
58
+ notPayed: string;
59
+ };
60
+ userRole: {
61
+ personManager: string;
62
+ fineTemplateManager: string;
63
+ fineManager: string;
64
+ teamManager: string;
65
+ };
66
+ };
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.localizationEN = void 0;
4
+ const Pluralization_1 = require("../types/Pluralization");
5
+ exports.localizationEN = {
6
+ notification: {
7
+ fine: {
8
+ new: {
9
+ title: '{{reason}}',
10
+ body: 'You have a new fine of {{amount}}. Please pay it as soon as possible.'
11
+ },
12
+ reminder: {
13
+ title: 'You still have outstanding fines',
14
+ body: 'You still have {{amount}} outstanding. Please pay as soon as possible.'
15
+ },
16
+ stateChange: {
17
+ title: 'One of your fines has changed',
18
+ bodyPayed: 'You have paid a fine of {{amount}} ({{reason}}).',
19
+ bodyUnpayed: '{{reason}}, {{amount}} is still outstanding.',
20
+ bodyDeleted: '{{reason}}, {{amount}} has been deleted.'
21
+ }
22
+ }
23
+ },
24
+ fineAmount: {
25
+ item: {
26
+ type: {
27
+ crateOfBeer: {
28
+ name: 'Crate of Beer',
29
+ withCount: new Pluralization_1.Pluralization({
30
+ one: 'a crate of beer',
31
+ other: '{{count}} crates of beer'
32
+ }),
33
+ withoutCount: new Pluralization_1.Pluralization({
34
+ one: 'Crate of Beer',
35
+ other: 'Crates of Beer'
36
+ })
37
+ }
38
+ }
39
+ }
40
+ },
41
+ fineTemplateRepetition: {
42
+ item: {
43
+ minute: {
44
+ name: 'Minute',
45
+ withCount: new Pluralization_1.Pluralization({
46
+ one: '1 minute',
47
+ other: '{{count}} minutes'
48
+ }),
49
+ withoutCount: new Pluralization_1.Pluralization({
50
+ one: 'minute',
51
+ other: 'minutes'
52
+ })
53
+ },
54
+ day: {
55
+ name: 'Day',
56
+ withCount: new Pluralization_1.Pluralization({
57
+ one: '1 day',
58
+ other: '{{count}} days'
59
+ }),
60
+ withoutCount: new Pluralization_1.Pluralization({
61
+ one: 'day',
62
+ other: 'days'
63
+ })
64
+ },
65
+ item: {
66
+ name: 'Item',
67
+ withCount: new Pluralization_1.Pluralization({
68
+ one: '1 item',
69
+ other: '{{count}} items'
70
+ }),
71
+ withoutCount: new Pluralization_1.Pluralization({
72
+ one: 'item',
73
+ other: 'items'
74
+ })
75
+ },
76
+ count: {
77
+ name: 'Count',
78
+ withCount: new Pluralization_1.Pluralization({
79
+ one: '1 time',
80
+ other: '{{count}} times'
81
+ }),
82
+ withoutCount: new Pluralization_1.Pluralization({
83
+ one: 'time',
84
+ other: 'times'
85
+ })
86
+ }
87
+ }
88
+ },
89
+ payedState: {
90
+ payed: 'Paid',
91
+ notPayed: 'Outstanding'
92
+ },
93
+ userRole: {
94
+ personManager: 'Person Manager',
95
+ fineTemplateManager: 'Fine Template Manager',
96
+ fineManager: 'Fine Manager',
97
+ teamManager: 'Team Manager'
98
+ }
99
+ };
@@ -1,3 +1,4 @@
1
+ import { localizations } from './Localization';
1
2
  import { Flattable, ITypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
2
3
  export declare class Configuration implements Flattable<Configuration.Flatten> {
3
4
  currency: Configuration.Currency;
@@ -11,10 +12,10 @@ export declare namespace Configuration {
11
12
  const all: Currency[];
12
13
  const builder: ValueTypeBuilder<Currency>;
13
14
  }
14
- type Locale = 'de' | 'en';
15
+ type Locale = keyof typeof localizations;
15
16
  namespace Locale {
16
17
  const all: Locale[];
17
- const builder: ValueTypeBuilder<Locale>;
18
+ const builder: ValueTypeBuilder<"en" | "de">;
18
19
  }
19
20
  type Flatten = {
20
21
  currency: Currency;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Configuration = void 0;
4
+ const Localization_1 = require("./Localization");
4
5
  const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
5
6
  class Configuration {
6
7
  currency;
@@ -25,7 +26,7 @@ exports.Configuration = Configuration;
25
26
  })(Currency = Configuration.Currency || (Configuration.Currency = {}));
26
27
  let Locale;
27
28
  (function (Locale) {
28
- Locale.all = ['de', 'en'];
29
+ Locale.all = (0, typescript_common_functionality_1.keys)(Localization_1.localizations);
29
30
  Locale.builder = new typescript_common_functionality_1.ValueTypeBuilder();
30
31
  })(Locale = Configuration.Locale || (Configuration.Locale = {}));
31
32
  class TypeBuilder {
@@ -41,10 +41,10 @@ var FineAmount;
41
41
  this.count = count;
42
42
  }
43
43
  formatted() {
44
- return Localization_1.Localization.shared.getN(key => key.fineAmount.item.type[this.item], this.count);
44
+ return Localization_1.Localization.shared.fineAmount.item.type[this.item].withCount.value(this.count);
45
45
  }
46
46
  formattedWithoutCount() {
47
- return Localization_1.Localization.shared.getN(key => key.fineAmount.item.type[`${this.item}WithoutCount`], this.count);
47
+ return Localization_1.Localization.shared.fineAmount.item.type[this.item].withoutCount.value(this.count);
48
48
  }
49
49
  multiplied(factor) {
50
50
  return new Item(this.item, this.count * factor);
@@ -63,7 +63,7 @@ var FineAmount;
63
63
  (function (Type) {
64
64
  Type.all = ['crateOfBeer'];
65
65
  function formatted(type) {
66
- return Localization_1.Localization.shared.get(key => key.fineAmount.item.type[type]);
66
+ return Localization_1.Localization.shared.fineAmount.item.type[type].name.value();
67
67
  }
68
68
  Type.formatted = formatted;
69
69
  })(Type = Item.Type || (Item.Type = {}));
@@ -11,10 +11,10 @@ class FineTemplateRepetition {
11
11
  this.maxCount = maxCount;
12
12
  }
13
13
  formatted(count) {
14
- return Localization_1.Localization.shared.getN(key => key.fineTemplateRepetition.item[this.item], count);
14
+ return Localization_1.Localization.shared.fineTemplateRepetition.item[this.item].withCount.value(count);
15
15
  }
16
16
  formattedWithoutCount(count) {
17
- return Localization_1.Localization.shared.getN(key => key.fineTemplateRepetition.item[`${this.item}WithoutCount`], count);
17
+ return Localization_1.Localization.shared.fineTemplateRepetition.item[this.item].withoutCount.value(count);
18
18
  }
19
19
  get flatten() {
20
20
  return {
@@ -34,7 +34,7 @@ exports.FineTemplateRepetition = FineTemplateRepetition;
34
34
  'count'
35
35
  ];
36
36
  function formatted(item) {
37
- return Localization_1.Localization.shared.get(key => key.fineTemplateRepetition.item[item]);
37
+ return Localization_1.Localization.shared.fineTemplateRepetition.item[item].name.value();
38
38
  }
39
39
  Item.formatted = formatted;
40
40
  Item.builder = new typescript_common_functionality_1.ValueTypeBuilder();