@stevenkellner/team-conduct-api 1.0.12 → 1.0.14
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/index.ts +1 -4
- package/lib/index.d.ts +1 -4
- package/lib/index.js +1 -4
- package/lib/src/firebaseFunctionsContext.d.ts +1 -14
- package/lib/src/firebaseFunctionsContext.js +19 -36
- package/lib/src/functions/fine/add.js +3 -37
- package/lib/src/functions/fine/delete.js +3 -37
- package/lib/src/functions/fine/update.js +4 -38
- package/lib/src/functions/index.d.ts +18 -0
- package/lib/src/functions/index.js +34 -0
- package/lib/src/index.d.ts +8 -0
- package/lib/src/index.js +24 -0
- package/lib/src/locales/de.json +65 -0
- package/lib/src/locales/en.json +65 -0
- package/lib/src/types/FineAmount.d.ts +2 -1
- package/lib/src/types/FineAmount.js +7 -42
- package/lib/src/types/FineTemplateRepetition.d.ts +2 -0
- package/lib/src/types/FineTemplateRepetition.js +8 -0
- package/lib/src/types/Localization.d.ts +70 -0
- package/lib/src/types/Localization.js +123 -0
- package/lib/src/types/PayedState.d.ts +1 -0
- package/lib/src/types/PayedState.js +5 -0
- package/lib/src/types/UserRole.d.ts +1 -0
- package/lib/src/types/UserRole.js +11 -0
- package/lib/src/types/index.d.ts +1 -0
- package/lib/src/types/index.js +1 -0
- package/lib/test/localization-utils.d.ts +12 -0
- package/lib/test/localization-utils.js +68 -0
- package/lib/test/localization.de.test.d.ts +1 -0
- package/lib/test/localization.de.test.js +162 -0
- package/lib/test/localization.en.test.d.ts +1 -0
- package/lib/test/localization.en.test.js +158 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -1
- package/src/firebaseFunctionsContext.ts +7 -18
- package/src/functions/fine/add.ts +5 -5
- package/src/functions/fine/delete.ts +4 -5
- package/src/functions/fine/update.ts +5 -6
- package/src/functions/index.ts +19 -0
- package/src/index.ts +8 -0
- package/src/locales/de.json +63 -28
- package/src/locales/en.json +49 -14
- package/src/types/FineAmount.ts +7 -9
- package/src/types/FineTemplateRepetition.ts +9 -0
- package/src/types/Localization.ts +94 -0
- package/src/types/PayedState.ts +5 -0
- package/src/types/UserRole.ts +11 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const core_1 = require("@assertive-ts/core");
|
|
37
|
+
const localizationEN = __importStar(require("../src/locales/en.json"));
|
|
38
|
+
const types_1 = require("../src/types");
|
|
39
|
+
const localization_utils_1 = require("./localization-utils");
|
|
40
|
+
describe('Localization for en', () => {
|
|
41
|
+
const testedKeys = new localization_utils_1.TestedKeys((0, localization_utils_1.localizationWithoutDefault)(localizationEN));
|
|
42
|
+
before(() => {
|
|
43
|
+
types_1.Localization.shared.setLocale('en');
|
|
44
|
+
});
|
|
45
|
+
after('all values should be tested', () => {
|
|
46
|
+
testedKeys.checkAllTested();
|
|
47
|
+
});
|
|
48
|
+
describe('notification.fine should be tested', () => {
|
|
49
|
+
it('notification.fine.new should be tested', () => {
|
|
50
|
+
testedKeys.testArgs(key => key.notification.fine.new.title, ['fine-reason'], 'fine-reason');
|
|
51
|
+
testedKeys.testArgs(key => key.notification.fine.new.body, ['10.50 €'], 'You have a new fine of 10.50 €. Please pay it as soon as possible.');
|
|
52
|
+
});
|
|
53
|
+
it('notification.fine.reminder should be tested', () => {
|
|
54
|
+
testedKeys.test(key => key.notification.fine.reminder.title, 'You still have outstanding fines');
|
|
55
|
+
testedKeys.testArgs(key => key.notification.fine.reminder.body, ['10.50 €'], 'You still have 10.50 € outstanding. Please pay as soon as possible.');
|
|
56
|
+
});
|
|
57
|
+
it('notification.fine.stateChange should be tested', () => {
|
|
58
|
+
testedKeys.test(key => key.notification.fine.stateChange.title, 'One of your fines has changed');
|
|
59
|
+
testedKeys.testArgs(key => key.notification.fine.stateChange.bodyPayed, ['10.50 €', 'fine-reason'], 'You have paid a fine of 10.50 € (fine-reason).');
|
|
60
|
+
testedKeys.testArgs(key => key.notification.fine.stateChange.bodyUnpayed, ['10.50 €', 'fine-reason'], '10.50 €, fine-reason is still outstanding.');
|
|
61
|
+
testedKeys.testArgs(key => key.notification.fine.stateChange.bodyDeleted, ['10.50 €', 'fine-reason'], '10.50 €, fine-reason has been deleted.');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('fineAmount should be tested', () => {
|
|
65
|
+
it('fineAmount.item.type.crateOfBeer should be tested', () => {
|
|
66
|
+
testedKeys.test(key => key.fineAmount.item.type.crateOfBeer, 'Crate of Beer');
|
|
67
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 1, 'a crate of beer');
|
|
68
|
+
testedKeys.testN(key => key.fineAmount.item.type.crateOfBeer, 4, '4 crates of beer');
|
|
69
|
+
});
|
|
70
|
+
it('fineAmount.item.type.crateOfBeer should be formatted correctly', () => {
|
|
71
|
+
(0, core_1.expect)(types_1.FineAmount.Item.Type.formatted('crateOfBeer')).toBeEqual('Crate of Beer');
|
|
72
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 1).formatted()).toBeEqual('a crate of beer');
|
|
73
|
+
(0, core_1.expect)(new types_1.FineAmount.Item('crateOfBeer', 4).formatted()).toBeEqual('4 crates of beer');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('fineTemplateRepetition should be tested', () => {
|
|
77
|
+
it('fineTemplateRepetition.item.minute should be tested', () => {
|
|
78
|
+
testedKeys.test(key => key.fineTemplateRepetition.item.minute, 'Minute');
|
|
79
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.minute, 1, '1 minute');
|
|
80
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.minute, 4, '4 minutes');
|
|
81
|
+
});
|
|
82
|
+
it('fineTemplateRepetition.item.minute should be formatted correctly', () => {
|
|
83
|
+
(0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('minute')).toBeEqual('Minute');
|
|
84
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formatted(1)).toBeEqual('1 minute');
|
|
85
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('minute', null).formatted(4)).toBeEqual('4 minutes');
|
|
86
|
+
});
|
|
87
|
+
it('fineTemplateRepetition.item.day should be tested', () => {
|
|
88
|
+
testedKeys.test(key => key.fineTemplateRepetition.item.day, 'Day');
|
|
89
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.day, 1, '1 day');
|
|
90
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.day, 4, '4 days');
|
|
91
|
+
});
|
|
92
|
+
it('fineTemplateRepetition.item.day should be formatted correctly', () => {
|
|
93
|
+
(0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('day')).toBeEqual('Day');
|
|
94
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formatted(1)).toBeEqual('1 day');
|
|
95
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('day', null).formatted(4)).toBeEqual('4 days');
|
|
96
|
+
});
|
|
97
|
+
it('fineTemplateRepetition.item.item should be tested', () => {
|
|
98
|
+
testedKeys.test(key => key.fineTemplateRepetition.item.item, 'Item');
|
|
99
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.item, 1, '1 item');
|
|
100
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.item, 4, '4 items');
|
|
101
|
+
});
|
|
102
|
+
it('fineTemplateRepetition.item.item should be formatted correctly', () => {
|
|
103
|
+
(0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('item')).toBeEqual('Item');
|
|
104
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formatted(1)).toBeEqual('1 item');
|
|
105
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('item', null).formatted(4)).toBeEqual('4 items');
|
|
106
|
+
});
|
|
107
|
+
it('fineTemplateRepetition.item.count should be tested', () => {
|
|
108
|
+
testedKeys.test(key => key.fineTemplateRepetition.item.count, 'Count');
|
|
109
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.count, 1, '1 time');
|
|
110
|
+
testedKeys.testN(key => key.fineTemplateRepetition.item.count, 4, '4 times');
|
|
111
|
+
});
|
|
112
|
+
it('fineTemplateRepetition.item.count should be formatted correctly', () => {
|
|
113
|
+
(0, core_1.expect)(types_1.FineTemplateRepetition.Item.formatted('count')).toBeEqual('Count');
|
|
114
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formatted(1)).toBeEqual('1 time');
|
|
115
|
+
(0, core_1.expect)(new types_1.FineTemplateRepetition('count', null).formatted(4)).toBeEqual('4 times');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('payedState should be tested', () => {
|
|
119
|
+
it('payedState.payed should be tested', () => {
|
|
120
|
+
testedKeys.test(key => key.payedState.payed, 'Paid');
|
|
121
|
+
});
|
|
122
|
+
it('payedState.payed should be formatted correctly', () => {
|
|
123
|
+
(0, core_1.expect)(types_1.PayedState.formatted('payed')).toBeEqual('Paid');
|
|
124
|
+
});
|
|
125
|
+
it('payedState.notPayed should be tested', () => {
|
|
126
|
+
testedKeys.test(key => key.payedState.notPayed, 'Outstanding');
|
|
127
|
+
});
|
|
128
|
+
it('payedState.notPayed should be formatted correctly', () => {
|
|
129
|
+
(0, core_1.expect)(types_1.PayedState.formatted('notPayed')).toBeEqual('Outstanding');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('userRole should be tested', () => {
|
|
133
|
+
it('userRole.personManager should be tested', () => {
|
|
134
|
+
testedKeys.test(key => key.userRole.personManager, 'Person Manager');
|
|
135
|
+
});
|
|
136
|
+
it('userRole.personManager should be formatted correctly', () => {
|
|
137
|
+
(0, core_1.expect)(types_1.UserRole.formatted('person-manager')).toBeEqual('Person Manager');
|
|
138
|
+
});
|
|
139
|
+
it('userRole.fineTemplateManager should be tested', () => {
|
|
140
|
+
testedKeys.test(key => key.userRole.fineTemplateManager, 'Fine Template Manager');
|
|
141
|
+
});
|
|
142
|
+
it('userRole.fineTemplateManager should be formatted correctly', () => {
|
|
143
|
+
(0, core_1.expect)(types_1.UserRole.formatted('fineTemplate-manager')).toBeEqual('Fine Template Manager');
|
|
144
|
+
});
|
|
145
|
+
it('userRole.fineManager should be tested', () => {
|
|
146
|
+
testedKeys.test(key => key.userRole.fineManager, 'Fine Manager');
|
|
147
|
+
});
|
|
148
|
+
it('userRole.fineManager should be formatted correctly', () => {
|
|
149
|
+
(0, core_1.expect)(types_1.UserRole.formatted('fine-manager')).toBeEqual('Fine Manager');
|
|
150
|
+
});
|
|
151
|
+
it('userRole.teamManager should be tested', () => {
|
|
152
|
+
testedKeys.test(key => key.userRole.teamManager, 'Team Manager');
|
|
153
|
+
});
|
|
154
|
+
it('userRole.teamManager should be formatted correctly', () => {
|
|
155
|
+
(0, core_1.expect)(types_1.UserRole.formatted('team-manager')).toBeEqual('Team Manager');
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
package/lib/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../index.ts","../src/Firestore.ts","../src/FirestoreScheme.ts","../src/checkAuthentication.ts","../src/firebaseFunctionsContext.ts","../src/pushNotification.ts","../src/firebase/FirebaseConfiguration.ts","../src/firebase/Messaging.ts","../src/firebase/index.ts","../src/functions/fine/add.ts","../src/functions/fine/delete.ts","../src/functions/fine/update.ts","../src/functions/fineTemplate/add.ts","../src/functions/fineTemplate/delete.ts","../src/functions/fineTemplate/update.ts","../src/functions/invitation/invite.ts","../src/functions/invitation/register.ts","../src/functions/invitation/withdraw.ts","../src/functions/notification/register.ts","../src/functions/notification/subscribe.ts","../src/functions/paypalMe/edit.ts","../src/functions/person/add.ts","../src/functions/person/delete.ts","../src/functions/person/update.ts","../src/functions/team/new.ts","../src/functions/user/login.ts","../src/functions/user/roleEdit.ts","../src/types/Configuration.ts","../src/types/Fine.ts","../src/types/FineAmount.ts","../src/types/FineTemplate.ts","../src/types/FineTemplateRepetition.ts","../src/types/Invitation.ts","../src/types/MoneyAmount.ts","../src/types/NotificationProperties.ts","../src/types/PayedState.ts","../src/types/Person.ts","../src/types/PersonPrivateProperties.ts","../src/types/PersonSignInProperties.ts","../src/types/Team.ts","../src/types/User.ts","../src/types/UserRole.ts","../src/types/index.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../index.ts","../src/Firestore.ts","../src/FirestoreScheme.ts","../src/checkAuthentication.ts","../src/firebaseFunctionsContext.ts","../src/index.ts","../src/pushNotification.ts","../src/firebase/FirebaseConfiguration.ts","../src/firebase/Messaging.ts","../src/firebase/index.ts","../src/functions/index.ts","../src/functions/fine/add.ts","../src/functions/fine/delete.ts","../src/functions/fine/update.ts","../src/functions/fineTemplate/add.ts","../src/functions/fineTemplate/delete.ts","../src/functions/fineTemplate/update.ts","../src/functions/invitation/invite.ts","../src/functions/invitation/register.ts","../src/functions/invitation/withdraw.ts","../src/functions/notification/register.ts","../src/functions/notification/subscribe.ts","../src/functions/paypalMe/edit.ts","../src/functions/person/add.ts","../src/functions/person/delete.ts","../src/functions/person/update.ts","../src/functions/team/new.ts","../src/functions/user/login.ts","../src/functions/user/roleEdit.ts","../src/types/Configuration.ts","../src/types/Fine.ts","../src/types/FineAmount.ts","../src/types/FineTemplate.ts","../src/types/FineTemplateRepetition.ts","../src/types/Invitation.ts","../src/types/Localization.ts","../src/types/MoneyAmount.ts","../src/types/NotificationProperties.ts","../src/types/PayedState.ts","../src/types/Person.ts","../src/types/PersonPrivateProperties.ts","../src/types/PersonSignInProperties.ts","../src/types/Team.ts","../src/types/User.ts","../src/types/UserRole.ts","../src/types/index.ts","../test/localization-utils.ts","../test/localization.de.test.ts","../test/localization.en.test.ts"],"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stevenkellner/team-conduct-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Firebase API for Team Conduct",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Steven Kellner",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"build:watch": "tsc --watch",
|
|
18
18
|
"lint": "eslint --ext .js,.ts .",
|
|
19
19
|
"lint:fix": "eslint --ext .js,.ts . --fix",
|
|
20
|
+
"test": "mocha",
|
|
20
21
|
"upgrade": "ncu --upgrade --install always",
|
|
21
22
|
"release": "npm run rebuild && npm run lint && npm version patch && git push --follow-tags"
|
|
22
23
|
},
|
|
@@ -26,15 +27,19 @@
|
|
|
26
27
|
"i18n": "^0.15.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
30
|
+
"@assertive-ts/core": "^2.1.0",
|
|
29
31
|
"@eslint/compat": "^1.2.9",
|
|
30
32
|
"@eslint/eslintrc": "^3.3.1",
|
|
31
33
|
"@eslint/js": "^9.26.0",
|
|
32
34
|
"@types/i18n": "^0.13.12",
|
|
35
|
+
"@types/mocha": "^10.0.10",
|
|
33
36
|
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
34
37
|
"@typescript-eslint/parser": "^8.32.0",
|
|
35
38
|
"eslint": "^9.26.0",
|
|
36
39
|
"eslint-config-google": "^0.14.0",
|
|
37
40
|
"eslint-plugin-import": "^2.31.0",
|
|
41
|
+
"mocha": "^11.3.0",
|
|
42
|
+
"ts-node": "^10.9.2",
|
|
38
43
|
"typescript": "^5.8.3"
|
|
39
44
|
}
|
|
40
45
|
}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { FirebaseFunctionsContext } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { TeamNewFunction
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { InvitationWithdrawFunction } from './functions/invitation/withdraw';
|
|
10
|
-
import { InvitationRegisterFunction } from './functions/invitation/register';
|
|
11
|
-
import { PersonAddFunction } from './functions/person/add';
|
|
12
|
-
import { PersonUpdateFunction } from './functions/person/update';
|
|
13
|
-
import { PersonDeleteFunction } from './functions/person/delete';
|
|
14
|
-
import { FineAddFunction } from './functions/fine/add';
|
|
15
|
-
import { FineUpdateFunction } from './functions/fine/update';
|
|
16
|
-
import { FineDeleteFunction } from './functions/fine/delete';
|
|
17
|
-
import { FineTemplateAddFunction } from './functions/fineTemplate/add';
|
|
18
|
-
import { FineTemplateUpdateFunction } from './functions/fineTemplate/update';
|
|
19
|
-
import { FineTemplateDeleteFunction } from './functions/fineTemplate/delete';
|
|
2
|
+
import { TeamNewFunction, UserLoginFunction, UserRoleEditFunction,
|
|
3
|
+
PaypalMeEditFunction, NotificationRegisterFunction, NotificationSubscribeFunction,
|
|
4
|
+
InvitationInviteFunction, InvitationRegisterFunction, InvitationWithdrawFunction,
|
|
5
|
+
PersonAddFunction, PersonDeleteFunction, PersonUpdateFunction,
|
|
6
|
+
FineTemplateAddFunction, FineTemplateDeleteFunction, FineTemplateUpdateFunction,
|
|
7
|
+
FineAddFunction, FineDeleteFunction, FineUpdateFunction
|
|
8
|
+
} from './functions';
|
|
20
9
|
|
|
21
10
|
export const firebaseFunctionsContext = FirebaseFunctionsContext.build(builder => ({
|
|
22
11
|
team: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
|
|
2
2
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
3
|
-
import { Configuration, Fine, Person, Team } from '../../types';
|
|
3
|
+
import { Configuration, Fine, Localization, Person, Team } from '../../types';
|
|
4
4
|
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
5
|
import { Firestore } from '../../Firestore';
|
|
6
6
|
import { pushNotification } from '../../pushNotification';
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
|
|
9
9
|
export namespace FineAddFunction {
|
|
10
10
|
|
|
@@ -45,10 +45,10 @@ export class FineAddFunction extends FirebaseFunction<FineAddFunction.Parameters
|
|
|
45
45
|
person.fineIds.push(parameters.fine.id);
|
|
46
46
|
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
Localization.shared.setLocale(parameters.configuration.locale);
|
|
49
49
|
await pushNotification(parameters.teamId, parameters.personId, 'new-fine', {
|
|
50
|
-
title:
|
|
51
|
-
body:
|
|
50
|
+
title: Localization.shared.get(key => key.notification.fine.new.title, parameters.fine.reason),
|
|
51
|
+
body: Localization.shared.get(key => key.notification.fine.new.body, parameters.fine.amount.formatted(parameters.configuration))
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
|
|
2
|
-
import { Configuration, Fine, FineAmount, Person, Team } from '../../types';
|
|
2
|
+
import { Configuration, Fine, FineAmount, Localization, Person, Team } from '../../types';
|
|
3
3
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
4
4
|
import { checkAuthentication } from '../../checkAuthentication';
|
|
5
5
|
import { Firestore } from '../../Firestore';
|
|
6
6
|
import { pushNotification } from '../../pushNotification';
|
|
7
|
-
import * as i18n from 'i18n';
|
|
8
7
|
|
|
9
8
|
export namespace FineDeleteFunction {
|
|
10
9
|
|
|
@@ -45,10 +44,10 @@ export class FineDeleteFunction extends FirebaseFunction<FineDeleteFunction.Para
|
|
|
45
44
|
person.fineIds = person.fineIds.filter(id => id.guidString !== parameters.id.guidString);
|
|
46
45
|
await Firestore.shared.person(parameters.teamId, parameters.personId).set(person);
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
Localization.shared.setLocale(parameters.configuration.locale);
|
|
49
48
|
await pushNotification(parameters.teamId, parameters.personId, 'fine-state-change', {
|
|
50
|
-
title:
|
|
51
|
-
body:
|
|
49
|
+
title: Localization.shared.get(key => key.notification.fine.stateChange.title),
|
|
50
|
+
body: Localization.shared.get(key => key.notification.fine.stateChange.bodyDeleted, fineSnapshot.data.reason, FineAmount.builder.build(fineSnapshot.data.amount).formatted(parameters.configuration))
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Configuration } from '../../types/Configuration';
|
|
2
2
|
import { FirebaseFunction, FunctionsError } from '@stevenkellner/firebase-function';
|
|
3
3
|
import { pushNotification } from '../../pushNotification';
|
|
4
|
-
import { Fine, Person, Team } from '../../types';
|
|
4
|
+
import { Fine, Localization, Person, Team } from '../../types';
|
|
5
5
|
import { Flattable, ObjectTypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
6
6
|
import { checkAuthentication } from '../../checkAuthentication';
|
|
7
7
|
import { Firestore } from '../../Firestore';
|
|
8
|
-
import * as i18n from 'i18n';
|
|
9
8
|
|
|
10
9
|
export namespace FineUpdateFunction {
|
|
11
10
|
|
|
@@ -38,15 +37,15 @@ export class FineUpdateFunction extends FirebaseFunction<FineUpdateFunction.Para
|
|
|
38
37
|
|
|
39
38
|
await Firestore.shared.fine(parameters.teamId, parameters.fine.id).set(parameters.fine);
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
Localization.shared.setLocale(parameters.configuration.locale);
|
|
42
41
|
if (parameters.fine.payedState !== fineSnapshot.data.payedState) {
|
|
43
42
|
let body: string;
|
|
44
43
|
if (parameters.fine.payedState === 'payed')
|
|
45
|
-
body =
|
|
44
|
+
body = Localization.shared.get(key => key.notification.fine.stateChange.bodyPayed, parameters.fine.amount.formatted(parameters.configuration), parameters.fine.reason);
|
|
46
45
|
else
|
|
47
|
-
body =
|
|
46
|
+
body = Localization.shared.get(key => key.notification.fine.stateChange.bodyUnpayed, parameters.fine.reason, parameters.fine.amount.formatted(parameters.configuration));
|
|
48
47
|
await pushNotification(parameters.teamId, parameters.personId, 'fine-state-change', {
|
|
49
|
-
title:
|
|
48
|
+
title: Localization.shared.get(key => key.notification.fine.stateChange.title),
|
|
50
49
|
body: body
|
|
51
50
|
});
|
|
52
51
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
export * from './team/new';
|
|
3
|
+
export * from './user/login';
|
|
4
|
+
export * from './user/roleEdit';
|
|
5
|
+
export * from './paypalMe/edit';
|
|
6
|
+
export * from './notification/register';
|
|
7
|
+
export * from './notification/subscribe';
|
|
8
|
+
export * from './invitation/invite';
|
|
9
|
+
export * from './invitation/withdraw';
|
|
10
|
+
export * from './invitation/register';
|
|
11
|
+
export * from './person/add';
|
|
12
|
+
export * from './person/update';
|
|
13
|
+
export * from './person/delete';
|
|
14
|
+
export * from './fine/add';
|
|
15
|
+
export * from './fine/update';
|
|
16
|
+
export * from './fine/delete';
|
|
17
|
+
export * from './fineTemplate/add';
|
|
18
|
+
export * from './fineTemplate/update';
|
|
19
|
+
export * from './fineTemplate/delete';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './firebase';
|
|
2
|
+
export * from './functions';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './checkAuthentication';
|
|
5
|
+
export * from './firebaseFunctionsContext';
|
|
6
|
+
export * from './Firestore';
|
|
7
|
+
export * from './FirestoreScheme';
|
|
8
|
+
export * from './pushNotification';
|
package/src/locales/de.json
CHANGED
|
@@ -1,30 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"notification": {
|
|
3
|
+
"fine": {
|
|
4
|
+
"new": {
|
|
5
|
+
"title": "%s",
|
|
6
|
+
"body": "Du hast eine neue Strafe von %s. Bitte so schnell wie möglich zahlen."
|
|
7
|
+
},
|
|
8
|
+
"reminder": {
|
|
9
|
+
"title": "Du hast noch offene Strafen",
|
|
10
|
+
"body": "Bei dir sind noch %s offen. Bitte so schnell wie möglich zahlen."
|
|
11
|
+
},
|
|
12
|
+
"state-change": {
|
|
13
|
+
"title": "Eine deiner Strafen hat sich geändert",
|
|
14
|
+
"body-payed": "Du hast eine Strafe von %1$s bezahlt (%2$s).",
|
|
15
|
+
"body-unpayed": "%1$s, %2$s ist noch offen.",
|
|
16
|
+
"body-deleted": "%1$s, %2$s wurde gelöscht."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"fineAmount": {
|
|
21
|
+
"item": {
|
|
22
|
+
"type": {
|
|
23
|
+
"crateOfBeer": "Kasten Bier",
|
|
24
|
+
"crateOfBeer?count=%s": {
|
|
25
|
+
"one": "Ein Kasten Bier",
|
|
26
|
+
"other": "%s Kästen Bier"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"fineTemplateRepetition": {
|
|
32
|
+
"item": {
|
|
33
|
+
"minute": "Minute",
|
|
34
|
+
"minute?count=%s": {
|
|
35
|
+
"one": "1 Minute",
|
|
36
|
+
"other": "%s Minuten"
|
|
37
|
+
},
|
|
38
|
+
"day": "Tag",
|
|
39
|
+
"day?count=%s": {
|
|
40
|
+
"one": "1 Tag",
|
|
41
|
+
"other": "%s Tage"
|
|
42
|
+
},
|
|
43
|
+
"item": "Teil",
|
|
44
|
+
"item?count=%s": {
|
|
45
|
+
"one": "1 Teil",
|
|
46
|
+
"other": "%s Teile"
|
|
47
|
+
},
|
|
48
|
+
"count": "Anzahl",
|
|
49
|
+
"count?count=%s": {
|
|
50
|
+
"one": "1 mal",
|
|
51
|
+
"other": "%s mal"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"payedState": {
|
|
56
|
+
"payed": "Bezahlt",
|
|
57
|
+
"notPayed": "Offen"
|
|
58
|
+
},
|
|
59
|
+
"userRole": {
|
|
60
|
+
"personManager": "Personenmanager",
|
|
61
|
+
"fineTemplateManager": "Strafvorlagenmanager",
|
|
62
|
+
"fineManager": "Strafenmanager",
|
|
63
|
+
"teamManager": "Teammanager"
|
|
64
|
+
}
|
|
30
65
|
}
|
package/src/locales/en.json
CHANGED
|
@@ -6,25 +6,60 @@
|
|
|
6
6
|
"body": "You have a new fine of %s. Please pay it as soon as possible."
|
|
7
7
|
},
|
|
8
8
|
"reminder": {
|
|
9
|
-
"title": "You still have outstanding
|
|
9
|
+
"title": "You still have outstanding fines",
|
|
10
10
|
"body": "You still have %s outstanding. Please pay as soon as possible."
|
|
11
11
|
},
|
|
12
12
|
"state-change": {
|
|
13
|
-
"title": "One of your
|
|
14
|
-
"body-
|
|
15
|
-
"body-unpayed": "%1$s, %2$s
|
|
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
16
|
"body-deleted": "%1$s, %2$s has been deleted."
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
"fineAmount": {
|
|
21
|
+
"item": {
|
|
22
|
+
"type": {
|
|
23
|
+
"crateOfBeer": "Crate of Beer",
|
|
24
|
+
"crateOfBeer?count=%s": {
|
|
25
|
+
"one": "a crate of beer",
|
|
26
|
+
"other": "%s crates of beer"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"fineTemplateRepetition": {
|
|
32
|
+
"item": {
|
|
33
|
+
"minute": "Minute",
|
|
34
|
+
"minute?count=%s": {
|
|
35
|
+
"one": "1 minute",
|
|
36
|
+
"other": "%s minutes"
|
|
37
|
+
},
|
|
38
|
+
"day": "Day",
|
|
39
|
+
"day?count=%s": {
|
|
40
|
+
"one": "1 day",
|
|
41
|
+
"other": "%s days"
|
|
42
|
+
},
|
|
43
|
+
"item": "Item",
|
|
44
|
+
"item?count=%s": {
|
|
45
|
+
"one": "1 item",
|
|
46
|
+
"other": "%s items"
|
|
47
|
+
},
|
|
48
|
+
"count": "Count",
|
|
49
|
+
"count?count=%s": {
|
|
50
|
+
"one": "1 time",
|
|
51
|
+
"other": "%s times"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"payedState": {
|
|
56
|
+
"payed": "Paid",
|
|
57
|
+
"notPayed": "Outstanding"
|
|
58
|
+
},
|
|
59
|
+
"userRole": {
|
|
60
|
+
"personManager": "Person Manager",
|
|
61
|
+
"fineTemplateManager": "Fine Template Manager",
|
|
62
|
+
"fineManager": "Fine Manager",
|
|
63
|
+
"teamManager": "Team Manager"
|
|
64
|
+
}
|
|
30
65
|
}
|
package/src/types/FineAmount.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flattable, ITypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
2
|
import { MoneyAmount } from './MoneyAmount';
|
|
3
|
-
import * as i18n from 'i18n';
|
|
4
3
|
import { Configuration } from './Configuration';
|
|
4
|
+
import { Localization } from './Localization';
|
|
5
5
|
|
|
6
6
|
export type FineAmount =
|
|
7
7
|
| FineAmount.Money
|
|
@@ -51,14 +51,8 @@ export namespace FineAmount {
|
|
|
51
51
|
public count: number
|
|
52
52
|
) {}
|
|
53
53
|
|
|
54
|
-
public formatted(
|
|
55
|
-
|
|
56
|
-
minimumFractionDigits: 0,
|
|
57
|
-
maximumFractionDigits: 0
|
|
58
|
-
});
|
|
59
|
-
if (this.count === 1)
|
|
60
|
-
return i18n.__(`FineAmount.Item.Type.${this.item}.singular`, numberFormat.format(this.count));
|
|
61
|
-
return i18n.__(`FineAmount.Item.Type.${this.item}.plural`, numberFormat.format(this.count));
|
|
54
|
+
public formatted(): string {
|
|
55
|
+
return Localization.shared.getN(key => key.fineAmount.item.type[this.item], this.count);
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
public get flatten(): Item.Flatten {
|
|
@@ -78,6 +72,10 @@ export namespace FineAmount {
|
|
|
78
72
|
export namespace Type {
|
|
79
73
|
|
|
80
74
|
export const all: Type[] = ['crateOfBeer'];
|
|
75
|
+
|
|
76
|
+
export function formatted(type: Type): string {
|
|
77
|
+
return Localization.shared.get(key => key.fineAmount.item.type[type]);
|
|
78
|
+
}
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
export type Flatten = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Flattable, ITypeBuilder, ValueTypeBuilder } from '@stevenkellner/typescript-common-functionality';
|
|
2
|
+
import { Localization } from './Localization';
|
|
2
3
|
|
|
3
4
|
export class FineTemplateRepetition implements Flattable<FineTemplateRepetition.Flatten> {
|
|
4
5
|
|
|
@@ -7,6 +8,10 @@ export class FineTemplateRepetition implements Flattable<FineTemplateRepetition.
|
|
|
7
8
|
public maxCount: number | null
|
|
8
9
|
) {}
|
|
9
10
|
|
|
11
|
+
public formatted(count: number): string {
|
|
12
|
+
return Localization.shared.getN(key => key.fineTemplateRepetition.item[this.item], count);
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
public get flatten(): FineTemplateRepetition.Flatten {
|
|
11
16
|
return {
|
|
12
17
|
item: this.item,
|
|
@@ -32,6 +37,10 @@ export namespace FineTemplateRepetition {
|
|
|
32
37
|
'count'
|
|
33
38
|
];
|
|
34
39
|
|
|
40
|
+
export function formatted(item: Item): string {
|
|
41
|
+
return Localization.shared.get(key => key.fineTemplateRepetition.item[item]);
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
export const builder = new ValueTypeBuilder<Item>();
|
|
36
45
|
}
|
|
37
46
|
|