@volontariapp/domain-user 2.3.5-snap-7ff4433 → 2.3.5
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/CHANGELOG.md +0 -2
- package/dist/entities/user.entity.d.ts +1 -3
- package/dist/entities/user.entity.d.ts.map +1 -1
- package/dist/entities/user.entity.js +0 -41
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/models/user.model.js +3 -3
- package/dist/models/user.model.js.map +1 -1
- package/package.json +4 -16
- package/dist/models/mapper.d.ts +0 -2
- package/dist/models/mapper.d.ts.map +0 -1
- package/dist/models/mapper.js +0 -36
- package/dist/models/mapper.js.map +0 -1
- package/dist/repositories/index.d.ts +0 -4
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/index.js +0 -4
- package/dist/repositories/index.js.map +0 -1
- package/dist/repositories/interfaces/badge.repository.d.ts +0 -11
- package/dist/repositories/interfaces/badge.repository.d.ts.map +0 -1
- package/dist/repositories/interfaces/badge.repository.js +0 -2
- package/dist/repositories/interfaces/badge.repository.js.map +0 -1
- package/dist/repositories/interfaces/index.d.ts +0 -3
- package/dist/repositories/interfaces/index.d.ts.map +0 -1
- package/dist/repositories/interfaces/index.js +0 -3
- package/dist/repositories/interfaces/index.js.map +0 -1
- package/dist/repositories/interfaces/user.repository.d.ts +0 -16
- package/dist/repositories/interfaces/user.repository.d.ts.map +0 -1
- package/dist/repositories/interfaces/user.repository.js +0 -2
- package/dist/repositories/interfaces/user.repository.js.map +0 -1
- package/dist/repositories/postgres-badge.repository.d.ts +0 -12
- package/dist/repositories/postgres-badge.repository.d.ts.map +0 -1
- package/dist/repositories/postgres-badge.repository.js +0 -38
- package/dist/repositories/postgres-badge.repository.js.map +0 -1
- package/dist/repositories/postgres-user.repository.d.ts +0 -23
- package/dist/repositories/postgres-user.repository.d.ts.map +0 -1
- package/dist/repositories/postgres-user.repository.js +0 -96
- package/dist/repositories/postgres-user.repository.js.map +0 -1
- package/dist/services/auth.service.d.ts +0 -29
- package/dist/services/auth.service.d.ts.map +0 -1
- package/dist/services/auth.service.js +0 -93
- package/dist/services/auth.service.js.map +0 -1
- package/dist/services/badge.service.d.ts +0 -15
- package/dist/services/badge.service.d.ts.map +0 -1
- package/dist/services/badge.service.js +0 -139
- package/dist/services/badge.service.js.map +0 -1
- package/dist/services/user.service.d.ts +0 -19
- package/dist/services/user.service.d.ts.map +0 -1
- package/dist/services/user.service.js +0 -188
- package/dist/services/user.service.js.map +0 -1
- package/dist/test/__test-utils__/factories/badge.factory.d.ts +0 -7
- package/dist/test/__test-utils__/factories/badge.factory.d.ts.map +0 -1
- package/dist/test/__test-utils__/factories/badge.factory.js +0 -29
- package/dist/test/__test-utils__/factories/badge.factory.js.map +0 -1
- package/dist/test/__test-utils__/factories/commands.factory.d.ts +0 -6
- package/dist/test/__test-utils__/factories/commands.factory.d.ts.map +0 -1
- package/dist/test/__test-utils__/factories/commands.factory.js +0 -24
- package/dist/test/__test-utils__/factories/commands.factory.js.map +0 -1
- package/dist/test/__test-utils__/factories/user.factory.d.ts +0 -8
- package/dist/test/__test-utils__/factories/user.factory.d.ts.map +0 -1
- package/dist/test/__test-utils__/factories/user.factory.js +0 -42
- package/dist/test/__test-utils__/factories/user.factory.js.map +0 -1
- package/dist/test/__test-utils__/mocks/badge.repository.mock.d.ts +0 -4
- package/dist/test/__test-utils__/mocks/badge.repository.mock.d.ts.map +0 -1
- package/dist/test/__test-utils__/mocks/badge.repository.mock.js +0 -11
- package/dist/test/__test-utils__/mocks/badge.repository.mock.js.map +0 -1
- package/dist/test/__test-utils__/mocks/user.repository.mock.d.ts +0 -4
- package/dist/test/__test-utils__/mocks/user.repository.mock.d.ts.map +0 -1
- package/dist/test/__test-utils__/mocks/user.repository.mock.js +0 -16
- package/dist/test/__test-utils__/mocks/user.repository.mock.js.map +0 -1
- package/dist/test/data-source.d.ts +0 -8
- package/dist/test/data-source.d.ts.map +0 -1
- package/dist/test/data-source.js +0 -36
- package/dist/test/data-source.js.map +0 -1
- package/dist/test/integration/postgres-badge.repository.int.spec.d.ts +0 -2
- package/dist/test/integration/postgres-badge.repository.int.spec.d.ts.map +0 -1
- package/dist/test/integration/postgres-badge.repository.int.spec.js +0 -129
- package/dist/test/integration/postgres-badge.repository.int.spec.js.map +0 -1
- package/dist/test/integration/postgres-user.repository.int.spec.d.ts +0 -2
- package/dist/test/integration/postgres-user.repository.int.spec.d.ts.map +0 -1
- package/dist/test/integration/postgres-user.repository.int.spec.js +0 -222
- package/dist/test/integration/postgres-user.repository.int.spec.js.map +0 -1
- package/dist/test/migrations/1776334421317-InitialUserSchema.d.ts +0 -7
- package/dist/test/migrations/1776334421317-InitialUserSchema.d.ts.map +0 -1
- package/dist/test/migrations/1776334421317-InitialUserSchema.js +0 -58
- package/dist/test/migrations/1776334421317-InitialUserSchema.js.map +0 -1
- package/dist/test/setup.d.ts +0 -2
- package/dist/test/setup.d.ts.map +0 -1
- package/dist/test/setup.js +0 -2
- package/dist/test/setup.js.map +0 -1
- package/dist/test/unit/auth.service.unit.spec.d.ts +0 -2
- package/dist/test/unit/auth.service.unit.spec.d.ts.map +0 -1
- package/dist/test/unit/auth.service.unit.spec.js +0 -236
- package/dist/test/unit/auth.service.unit.spec.js.map +0 -1
- package/dist/test/unit/badge.service.unit.spec.d.ts +0 -2
- package/dist/test/unit/badge.service.unit.spec.d.ts.map +0 -1
- package/dist/test/unit/badge.service.unit.spec.js +0 -120
- package/dist/test/unit/badge.service.unit.spec.js.map +0 -1
- package/dist/test/unit/mapper.unit.spec.d.ts +0 -2
- package/dist/test/unit/mapper.unit.spec.d.ts.map +0 -1
- package/dist/test/unit/mapper.unit.spec.js +0 -358
- package/dist/test/unit/mapper.unit.spec.js.map +0 -1
- package/dist/test/unit/user.service.unit.spec.d.ts +0 -2
- package/dist/test/unit/user.service.unit.spec.d.ts.map +0 -1
- package/dist/test/unit/user.service.unit.spec.js +0 -480
- package/dist/test/unit/user.service.unit.spec.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BadgeEntity } from './badge.entity.js';
|
|
2
|
-
import { UserRoles } from '@volontariapp/shared';
|
|
2
|
+
import type { UserRoles } from '@volontariapp/shared';
|
|
3
3
|
export declare class UserEntity {
|
|
4
4
|
id: string;
|
|
5
5
|
email: string;
|
|
@@ -10,7 +10,5 @@ export declare class UserEntity {
|
|
|
10
10
|
role: UserRoles;
|
|
11
11
|
totalImpactScore: number;
|
|
12
12
|
badges: BadgeEntity[];
|
|
13
|
-
static isValidRna(rna?: string): boolean;
|
|
14
|
-
static create(data: Partial<UserEntity>): UserEntity;
|
|
15
13
|
}
|
|
16
14
|
//# sourceMappingURL=user.entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.entity.d.ts","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,qBAAa,UAAU;IACrB,EAAE,EAAG,MAAM,CAAC;IACZ,KAAK,EAAG,MAAM,CAAC;IACf,MAAM,EAAG,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAG,SAAS,CAAC;IACjB,gBAAgB,EAAG,MAAM,CAAC;IAC1B,MAAM,EAAG,WAAW,EAAE,CAAC;CACxB"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { INVALID_RNA } from '@volontariapp/errors-nest';
|
|
2
|
-
import { UserRoles } from '@volontariapp/shared';
|
|
3
|
-
const ADJECTIVES = ['Green', 'Social', 'Eco', 'Solidary', 'Active', 'Bright', 'Kind', 'Wild'];
|
|
4
|
-
const NOUNS = ['Hero', 'Leaf', 'Heart', 'Action', 'Seed', 'Root', 'Planet', 'Citizen'];
|
|
5
|
-
const generateRandomPseudo = () => {
|
|
6
|
-
const adj = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)];
|
|
7
|
-
const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)];
|
|
8
|
-
const suffix = Math.floor(100 + Math.random() * 900);
|
|
9
|
-
return `${adj}${noun}${suffix.toString()}`;
|
|
10
|
-
};
|
|
11
1
|
export class UserEntity {
|
|
12
2
|
id;
|
|
13
3
|
email;
|
|
@@ -18,36 +8,5 @@ export class UserEntity {
|
|
|
18
8
|
role;
|
|
19
9
|
totalImpactScore;
|
|
20
10
|
badges;
|
|
21
|
-
static isValidRna(rna) {
|
|
22
|
-
if (rna == null)
|
|
23
|
-
return true;
|
|
24
|
-
const rnaRegex = /^W[0-9]{9}$/;
|
|
25
|
-
return rnaRegex.test(rna);
|
|
26
|
-
}
|
|
27
|
-
static create(data) {
|
|
28
|
-
const user = new UserEntity();
|
|
29
|
-
Object.assign(user, data);
|
|
30
|
-
user.badges = data.badges ?? [];
|
|
31
|
-
user.totalImpactScore = data.totalImpactScore ?? 0;
|
|
32
|
-
if (user.rna != null) {
|
|
33
|
-
if (!UserEntity.isValidRna(user.rna)) {
|
|
34
|
-
throw INVALID_RNA(user.rna);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
user.rna = user.rna.trim().toUpperCase();
|
|
38
|
-
user.role = data.role ?? UserRoles.ORGANIZATION;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
user.role = data.role ?? UserRoles.VOLUNTEER;
|
|
43
|
-
}
|
|
44
|
-
if (data.pseudo != null) {
|
|
45
|
-
user.pseudo = data.pseudo.trim();
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
user.pseudo = generateRandomPseudo();
|
|
49
|
-
}
|
|
50
|
-
return user;
|
|
51
|
-
}
|
|
52
11
|
}
|
|
53
12
|
//# sourceMappingURL=user.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,UAAU;IACrB,EAAE,CAAU;IACZ,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,QAAQ,CAAU;IAClB,GAAG,CAAU;IACb,GAAG,CAAU;IACb,IAAI,CAAa;IACjB,gBAAgB,CAAU;IAC1B,MAAM,CAAiB;CACxB"}
|
|
@@ -42,7 +42,7 @@ __decorate([
|
|
|
42
42
|
__metadata("design:type", String)
|
|
43
43
|
], UserModel.prototype, "role", void 0);
|
|
44
44
|
__decorate([
|
|
45
|
-
Column({ name:
|
|
45
|
+
Column({ name: "password_hash" }),
|
|
46
46
|
__metadata("design:type", String)
|
|
47
47
|
], UserModel.prototype, "passwordHash", void 0);
|
|
48
48
|
__decorate([
|
|
@@ -50,7 +50,7 @@ __decorate([
|
|
|
50
50
|
__metadata("design:type", String)
|
|
51
51
|
], UserModel.prototype, "bio", void 0);
|
|
52
52
|
__decorate([
|
|
53
|
-
Column({ type: 'varchar', nullable: true
|
|
53
|
+
Column({ type: 'varchar', nullable: true }),
|
|
54
54
|
__metadata("design:type", String)
|
|
55
55
|
], UserModel.prototype, "logoPath", void 0);
|
|
56
56
|
__decorate([
|
|
@@ -58,7 +58,7 @@ __decorate([
|
|
|
58
58
|
__metadata("design:type", String)
|
|
59
59
|
], UserModel.prototype, "rna", void 0);
|
|
60
60
|
__decorate([
|
|
61
|
-
Column({ type: 'int', default: 0, name:
|
|
61
|
+
Column({ type: 'int', default: 0, name: "total_impact_score" }),
|
|
62
62
|
__metadata("design:type", Number)
|
|
63
63
|
], UserModel.prototype, "totalImpactScore", void 0);
|
|
64
64
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIrE,IAAM,SAAS,GAAf,MAAM,SAAS;IAEpB,EAAE,CAAU;IAGZ,KAAK,CAAU;IAGf,KAAK,CAAU;IAGf,MAAM,CAAU;IAGhB,IAAI,CAAU;IAGd,YAAY,CAAU;IAGtB,GAAG,CAAU;IAGb,QAAQ,CAAU;IAGlB,GAAG,CAAU;IAGb,gBAAgB,CAAU;IAG1B,UAAU,CAAoB;CAC/B,CAAA;AA/BC;IADC,sBAAsB,CAAC,MAAM,CAAC;;qCACnB;AAGZ;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;wCACxC;AAGf;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC7B;AAGf;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;yCACzB;AAGhB;IADC,MAAM,EAAE;;uCACK;AAGd;IADC,MAAM,CAAC,EAAE,IAAI,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"user.model.js","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIrE,IAAM,SAAS,GAAf,MAAM,SAAS;IAEpB,EAAE,CAAU;IAGZ,KAAK,CAAU;IAGf,KAAK,CAAU;IAGf,MAAM,CAAU;IAGhB,IAAI,CAAU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2.3.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -29,24 +29,12 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc -p tsconfig.json",
|
|
31
31
|
"lint": "eslint src/",
|
|
32
|
-
"test": "
|
|
33
|
-
"test:
|
|
34
|
-
"test:all": "yarn test && yarn test:integration",
|
|
35
|
-
"test:watch": "node --experimental-vm-modules ../../node_modules/.bin/jest --watch",
|
|
36
|
-
"test:coverage": "node --experimental-vm-modules ../../node_modules/.bin/jest --coverage --coverageReporters=\"text\" --coverageReporters=\"json-summary\" --coverageReporters=\"lcov\" --coverageReporters=\"json\"",
|
|
37
|
-
"test:coverage:integration": "node --experimental-vm-modules ../../node_modules/.bin/jest --config jest.integration.config.js --coverage --coverageReporters=\"text\" --coverageReporters=\"json-summary\" --coverageReporters=\"lcov\" --coverageReporters=\"json\" --runInBand",
|
|
32
|
+
"test": "echo \"No tests yet\"",
|
|
33
|
+
"test:coverage": "echo \"No tests yet\"",
|
|
38
34
|
"typeorm": "typeorm-ts-node-esm",
|
|
39
|
-
"migration:run": "TYPEORM_MIGRATION_RUN=true yarn typeorm migration:run -d src/test/data-source.ts"
|
|
40
|
-
"migration:run:local": "TYPEORM_MIGRATION_RUN=true DB_PORT=5433 DB_USER=testuser DB_PASSWORD=testpassword DB_NAME=volontariapp_test yarn typeorm migration:run -d src/test/data-source.ts",
|
|
41
|
-
"test:integration:local": "DB_PORT=5433 DB_USER=testuser DB_PASSWORD=testpassword DB_NAME=volontariapp_test node --experimental-vm-modules ../../node_modules/.bin/jest --config jest.integration.config.js --runInBand"
|
|
35
|
+
"migration:run": "TYPEORM_MIGRATION_RUN=true yarn typeorm migration:run -d src/test/data-source.ts"
|
|
42
36
|
},
|
|
43
37
|
"dependencies": {
|
|
44
|
-
"@volontariapp/auth": "2.1.15",
|
|
45
|
-
"@volontariapp/contracts": "4.0.2",
|
|
46
|
-
"@volontariapp/crypto": "0.3.6",
|
|
47
|
-
"@volontariapp/database": "1.8.0",
|
|
48
|
-
"@volontariapp/errors": "0.5.0",
|
|
49
|
-
"@volontariapp/errors-nest": "0.10.0",
|
|
50
38
|
"@volontariapp/logger": "0.2.3",
|
|
51
39
|
"@volontariapp/shared": "0.2.0"
|
|
52
40
|
},
|
package/dist/models/mapper.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../src/models/mapper.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,SA8BnC"}
|
package/dist/models/mapper.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { databaseMapper } from '@volontariapp/database';
|
|
2
|
-
import { UserEntity } from '../entities/user.entity.js';
|
|
3
|
-
import { UserModel } from './user.model.js';
|
|
4
|
-
import { BadgeEntity } from '../entities/badge.entity.js';
|
|
5
|
-
import { BadgeModel } from './badge.model.js';
|
|
6
|
-
export function registerUserMappings() {
|
|
7
|
-
databaseMapper.registerBidirectional(UserEntity, UserModel, {
|
|
8
|
-
exclude: ['badges', 'userBadges', 'passwordHash'],
|
|
9
|
-
overridesAtoB: [
|
|
10
|
-
{
|
|
11
|
-
field: 'role',
|
|
12
|
-
resolve: (source) => source.role,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
overridesBtoA: [
|
|
16
|
-
{
|
|
17
|
-
field: 'role',
|
|
18
|
-
resolve: (source) => source.role,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
field: 'badges',
|
|
22
|
-
resolve: (source) => {
|
|
23
|
-
if (!Array.isArray(source.userBadges)) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
return source.userBadges
|
|
27
|
-
.map((ub) => ub.badge)
|
|
28
|
-
.filter((b) => b !== undefined && b !== null)
|
|
29
|
-
.map((b) => databaseMapper.map(b, BadgeModel, BadgeEntity));
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
});
|
|
34
|
-
databaseMapper.registerBidirectional(BadgeEntity, BadgeModel);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=mapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.js","sourceRoot":"","sources":["../../src/models/mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,MAAM,UAAU,oBAAoB;IAClC,cAAc,CAAC,qBAAqB,CAAC,UAAU,EAAE,SAAS,EAAE;QAC1D,OAAO,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC;QACjD,aAAa,EAAE;YACb;gBACE,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,CAAC,MAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAc;aACvD;SACF;QAED,aAAa,EAAE;YACb;gBACE,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAiB;aACzD;YACD;gBACE,KAAK,EAAE,QAAQ;gBACf,OAAO,EAAE,CAAC,MAAiB,EAAiB,EAAE;oBAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;wBACtC,OAAO,EAAE,CAAC;oBACZ,CAAC;oBACD,OAAO,MAAM,CAAC,UAAU;yBACrB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;yBACrB,MAAM,CAAC,CAAC,CAAC,EAAmB,EAAE,CAAE,CAAa,KAAK,SAAS,IAAK,CAAa,KAAK,IAAI,CAAC;yBACvF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;gBAChE,CAAC;aACF;SACF;KACF,CAAC,CAAC;IACH,cAAc,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { BadgeEntity } from "../../entities/badge.entity.js";
|
|
2
|
-
export interface IBadgeRepository {
|
|
3
|
-
findById(id: string): Promise<BadgeEntity | null>;
|
|
4
|
-
findManyByIds(ids: string[]): Promise<BadgeEntity[]>;
|
|
5
|
-
findBySlug(slug: string): Promise<BadgeEntity | null>;
|
|
6
|
-
findAll(): Promise<BadgeEntity[]>;
|
|
7
|
-
create(badgeData: Partial<BadgeEntity>): Promise<BadgeEntity>;
|
|
8
|
-
update(id: string, badgeData: Partial<BadgeEntity>): Promise<BadgeEntity | null>;
|
|
9
|
-
delete(id: string): Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=badge.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge.repository.d.ts","sourceRoot":"","sources":["../../../src/repositories/interfaces/badge.repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAClD,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACrD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACtD,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAClC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"badge.repository.js","sourceRoot":"","sources":["../../../src/repositories/interfaces/badge.repository.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { UserEntity } from '../../entities/user.entity.js';
|
|
2
|
-
export interface IUserRepository {
|
|
3
|
-
findById(id: string): Promise<UserEntity | null>;
|
|
4
|
-
findByEmail(email: string): Promise<UserEntity | null>;
|
|
5
|
-
findByRna(rna: string): Promise<UserEntity | null>;
|
|
6
|
-
findAll(limit?: number, offset?: number): Promise<[UserEntity[], number]>;
|
|
7
|
-
create(user: Partial<UserEntity>): Promise<UserEntity>;
|
|
8
|
-
update(id: string, data: Partial<UserEntity>): Promise<UserEntity | null>;
|
|
9
|
-
delete(id: string): Promise<boolean>;
|
|
10
|
-
addBadgeToUser(userId: string, badgeId: string): Promise<void>;
|
|
11
|
-
removeBadgeFromUser(userId: string, badgeId: string): Promise<void>;
|
|
12
|
-
incrementImpactScore(userId: string, score: number): Promise<void>;
|
|
13
|
-
createWithHashedPassword(user: Partial<UserEntity>, password: string): Promise<UserEntity>;
|
|
14
|
-
findPasswordHashByEmail(email: string): Promise<string | null>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=user.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.repository.d.ts","sourceRoot":"","sources":["../../../src/repositories/interfaces/user.repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACjD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACvD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3F,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAChE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"user.repository.js","sourceRoot":"","sources":["../../../src/repositories/interfaces/user.repository.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseRepository } from '@volontariapp/database';
|
|
2
|
-
import type { Repository } from '@volontariapp/database';
|
|
3
|
-
import { BadgeModel } from '../models/badge.model.js';
|
|
4
|
-
import { BadgeEntity } from '../entities/badge.entity.js';
|
|
5
|
-
import { IBadgeRepository } from './interfaces/badge.repository.js';
|
|
6
|
-
export declare class PostgresBadgeRepository extends BaseRepository<BadgeModel, BadgeEntity> implements IBadgeRepository {
|
|
7
|
-
constructor(repository: Repository<BadgeModel>);
|
|
8
|
-
findManyByIds(ids: string[]): Promise<BadgeEntity[]>;
|
|
9
|
-
findBySlug(slug: string): Promise<BadgeEntity | null>;
|
|
10
|
-
findAll(): Promise<BadgeEntity[]>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=postgres-badge.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-badge.repository.d.ts","sourceRoot":"","sources":["../../src/repositories/postgres-badge.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,qBACa,uBACX,SAAQ,cAAc,CAAC,UAAU,EAAE,WAAW,CAC9C,YAAW,gBAAgB;gBACe,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC;IAGtE,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAGpD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAGrD,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAItC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { Injectable } from '@nestjs/common';
|
|
14
|
-
import { BaseRepository } from '@volontariapp/database';
|
|
15
|
-
import { BadgeModel } from '../models/badge.model.js';
|
|
16
|
-
import { BadgeEntity } from '../entities/badge.entity.js';
|
|
17
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
18
|
-
let PostgresBadgeRepository = class PostgresBadgeRepository extends BaseRepository {
|
|
19
|
-
constructor(repository) {
|
|
20
|
-
super(repository, BadgeEntity, BadgeModel);
|
|
21
|
-
}
|
|
22
|
-
async findManyByIds(ids) {
|
|
23
|
-
return this.findByIds(ids);
|
|
24
|
-
}
|
|
25
|
-
async findBySlug(slug) {
|
|
26
|
-
return this.findOne({ slug });
|
|
27
|
-
}
|
|
28
|
-
async findAll() {
|
|
29
|
-
return this.find();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
PostgresBadgeRepository = __decorate([
|
|
33
|
-
Injectable(),
|
|
34
|
-
__param(0, InjectRepository(BadgeModel)),
|
|
35
|
-
__metadata("design:paramtypes", [Function])
|
|
36
|
-
], PostgresBadgeRepository);
|
|
37
|
-
export { PostgresBadgeRepository };
|
|
38
|
-
//# sourceMappingURL=postgres-badge.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-badge.repository.js","sourceRoot":"","sources":["../../src/repositories/postgres-badge.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG5C,IAAM,uBAAuB,GAA7B,MAAM,uBACX,SAAQ,cAAuC;IAE/C,YAA0C,UAAkC;QAC1E,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC7C,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,GAAa;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CAEA,CAAA;AAhBU,uBAAuB;IADnC,UAAU,EAAE;IAIE,WAAA,gBAAgB,CAAC,UAAU,CAAC,CAAA;;GAH9B,uBAAuB,CAgBjC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Repository } from '@volontariapp/database';
|
|
2
|
-
import { BaseRepository } from '@volontariapp/database';
|
|
3
|
-
import type { DeepPartial } from 'typeorm';
|
|
4
|
-
import { UserModel } from '../models/user.model.js';
|
|
5
|
-
import { UserEntity } from '../entities/user.entity.js';
|
|
6
|
-
import { IUserRepository } from './interfaces/user.repository.js';
|
|
7
|
-
export declare const EMAIL_ENCRYPTION_SECRET = "EMAIL_ENCRYPTION_SECRET";
|
|
8
|
-
export declare class PostgresUserRepository extends BaseRepository<UserModel, UserEntity> implements IUserRepository {
|
|
9
|
-
private readonly emailSecret;
|
|
10
|
-
constructor(repository: Repository<UserModel>, emailSecret: string);
|
|
11
|
-
toEntity(model: UserModel): UserEntity;
|
|
12
|
-
protected toModel(entity: Partial<UserEntity>): DeepPartial<UserModel>;
|
|
13
|
-
private encryptEmail;
|
|
14
|
-
findByEmail(email: string): Promise<UserEntity | null>;
|
|
15
|
-
findByRna(rna: string): Promise<UserEntity | null>;
|
|
16
|
-
findAll(limit?: number, offset?: number): Promise<[UserEntity[], number]>;
|
|
17
|
-
addBadgeToUser(userId: string, badgeId: string): Promise<void>;
|
|
18
|
-
removeBadgeFromUser(userId: string, badgeId: string): Promise<void>;
|
|
19
|
-
incrementImpactScore(userId: string, score: number): Promise<void>;
|
|
20
|
-
createWithHashedPassword(user: Partial<UserEntity>, password: string): Promise<UserEntity>;
|
|
21
|
-
findPasswordHashByEmail(email: string): Promise<string | null>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=postgres-user.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-user.repository.d.ts","sourceRoot":"","sources":["../../src/repositories/postgres-user.repository.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,qBACa,sBACX,SAAQ,cAAc,CAAC,SAAS,EAAE,UAAU,CAC5C,YAAW,eAAe;IAIS,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADhC,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,EACZ,WAAW,EAAE,MAAM;IAKvD,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU;cAMnC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC;IAQ/E,OAAO,CAAC,YAAY;IAId,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAItD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAIlD,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC;IAQzE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlE,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAU1F,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAOrE"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { Injectable, Inject } from '@nestjs/common';
|
|
14
|
-
import { InjectRepository } from '@nestjs/typeorm';
|
|
15
|
-
import { BaseRepository } from '@volontariapp/database';
|
|
16
|
-
import { UserModel } from '../models/user.model.js';
|
|
17
|
-
import { UserEntity } from '../entities/user.entity.js';
|
|
18
|
-
import { encryptDeterministic, decrypt } from '@volontariapp/crypto';
|
|
19
|
-
export const EMAIL_ENCRYPTION_SECRET = 'EMAIL_ENCRYPTION_SECRET';
|
|
20
|
-
let PostgresUserRepository = class PostgresUserRepository extends BaseRepository {
|
|
21
|
-
emailSecret;
|
|
22
|
-
constructor(repository, emailSecret) {
|
|
23
|
-
super(repository, UserEntity, UserModel);
|
|
24
|
-
this.emailSecret = emailSecret;
|
|
25
|
-
}
|
|
26
|
-
toEntity(model) {
|
|
27
|
-
const entity = super.toEntity(model);
|
|
28
|
-
entity.email = decrypt(model.email, this.emailSecret);
|
|
29
|
-
return entity;
|
|
30
|
-
}
|
|
31
|
-
toModel(entity) {
|
|
32
|
-
const model = super.toModel(entity);
|
|
33
|
-
if (entity.email != null) {
|
|
34
|
-
model.email = encryptDeterministic(entity.email, this.emailSecret);
|
|
35
|
-
}
|
|
36
|
-
return model;
|
|
37
|
-
}
|
|
38
|
-
encryptEmail(email) {
|
|
39
|
-
return encryptDeterministic(email, this.emailSecret);
|
|
40
|
-
}
|
|
41
|
-
async findByEmail(email) {
|
|
42
|
-
return this.findOne({ email: this.encryptEmail(email) });
|
|
43
|
-
}
|
|
44
|
-
async findByRna(rna) {
|
|
45
|
-
return this.findOne({ rna });
|
|
46
|
-
}
|
|
47
|
-
async findAll(limit, offset) {
|
|
48
|
-
const [models, total] = await this.repository.findAndCount({
|
|
49
|
-
take: limit,
|
|
50
|
-
skip: offset,
|
|
51
|
-
});
|
|
52
|
-
return [this.toEntities(models), total];
|
|
53
|
-
}
|
|
54
|
-
async addBadgeToUser(userId, badgeId) {
|
|
55
|
-
const userBadgeRepo = this.repository.manager.getRepository('UserBadgeModel');
|
|
56
|
-
await userBadgeRepo.save({
|
|
57
|
-
user: { id: userId },
|
|
58
|
-
badge: { id: badgeId },
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async removeBadgeFromUser(userId, badgeId) {
|
|
62
|
-
const userBadgeRepo = this.repository.manager.getRepository('UserBadgeModel');
|
|
63
|
-
await userBadgeRepo.delete({
|
|
64
|
-
user: { id: userId },
|
|
65
|
-
badge: { id: badgeId },
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
async incrementImpactScore(userId, score) {
|
|
69
|
-
const where = this.buildIdWhere(userId);
|
|
70
|
-
await this.increment(where, 'totalImpactScore', score);
|
|
71
|
-
}
|
|
72
|
-
async createWithHashedPassword(user, password) {
|
|
73
|
-
const model = this.repository.create({
|
|
74
|
-
...user,
|
|
75
|
-
email: user.email != null ? this.encryptEmail(user.email) : undefined,
|
|
76
|
-
passwordHash: password,
|
|
77
|
-
});
|
|
78
|
-
const savedModel = await this.repository.save(model);
|
|
79
|
-
return this.toEntity(savedModel);
|
|
80
|
-
}
|
|
81
|
-
async findPasswordHashByEmail(email) {
|
|
82
|
-
const user = await this.repository.findOne({
|
|
83
|
-
where: { email: this.encryptEmail(email) },
|
|
84
|
-
select: ['passwordHash'],
|
|
85
|
-
});
|
|
86
|
-
return user ? user.passwordHash : null;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
PostgresUserRepository = __decorate([
|
|
90
|
-
Injectable(),
|
|
91
|
-
__param(0, InjectRepository(UserModel)),
|
|
92
|
-
__param(1, Inject(EMAIL_ENCRYPTION_SECRET)),
|
|
93
|
-
__metadata("design:paramtypes", [Function, String])
|
|
94
|
-
], PostgresUserRepository);
|
|
95
|
-
export { PostgresUserRepository };
|
|
96
|
-
//# sourceMappingURL=postgres-user.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-user.repository.js","sourceRoot":"","sources":["../../src/repositories/postgres-user.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAErE,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAG1D,IAAM,sBAAsB,GAA5B,MAAM,sBACX,SAAQ,cAAqC;IAKO;IAFpD,YAC+B,UAAiC,EACZ,WAAmB;QAErE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QAFS,gBAAW,GAAX,WAAW,CAAQ;IAGvE,CAAC;IAEe,QAAQ,CAAC,KAAgB;QACvC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEkB,OAAO,CAAC,MAA2B;QACpD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACxB,KAA4B,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A,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAC3B,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GANvB,sBAAsB,CAmFlC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as repositories from '../repositories/index.js';
|
|
2
|
-
import { JwtService } from '@volontariapp/auth';
|
|
3
|
-
export interface SignUpData {
|
|
4
|
-
email: string;
|
|
5
|
-
pseudo?: string;
|
|
6
|
-
password: string;
|
|
7
|
-
organisationInfo?: {
|
|
8
|
-
rna: string;
|
|
9
|
-
};
|
|
10
|
-
bio?: string;
|
|
11
|
-
logoPath?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LoginData {
|
|
14
|
-
email: string;
|
|
15
|
-
password: string;
|
|
16
|
-
}
|
|
17
|
-
export type AuthResult = {
|
|
18
|
-
accessToken: string;
|
|
19
|
-
refreshToken: string;
|
|
20
|
-
};
|
|
21
|
-
export declare class AuthService {
|
|
22
|
-
private readonly userRepository;
|
|
23
|
-
private readonly jwtService;
|
|
24
|
-
private readonly logger;
|
|
25
|
-
constructor(userRepository: repositories.IUserRepository, jwtService: JwtService);
|
|
26
|
-
signUp(command: SignUpData): Promise<AuthResult>;
|
|
27
|
-
logIn(command: LoginData): Promise<AuthResult>;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,MAAM,0BAA0B,CAAC;AAUzD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE;QACjB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBACa,WAAW;IAKpB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6C;gBAIjD,cAAc,EAAE,YAAY,CAAC,eAAe,EAC5C,UAAU,EAAE,UAAU;IAGnC,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAyChD,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;CAsBrD"}
|