podverse-orm 5.1.14-alpha.0 → 5.1.16-alpha.0
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/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +7 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +10 -0
- package/dist/entities/account/account.d.ts +2 -0
- package/dist/entities/account/account.d.ts.map +1 -1
- package/dist/entities/account/account.js +5 -0
- package/dist/entities/account/accountFCMDevice.d.ts +6 -0
- package/dist/entities/account/accountFCMDevice.d.ts.map +1 -1
- package/dist/entities/account/accountFCMDevice.js +21 -1
- package/dist/entities/account/accountNotificationChannel.d.ts +3 -0
- package/dist/entities/account/accountNotificationChannel.d.ts.map +1 -1
- package/dist/entities/account/accountNotificationChannel.js +13 -3
- package/dist/entities/account/accountNotificationChannelType.d.ts +8 -0
- package/dist/entities/account/accountNotificationChannelType.d.ts.map +1 -0
- package/dist/entities/account/accountNotificationChannelType.js +34 -0
- package/dist/entities/account/accountSettings/accountSettings.d.ts +11 -0
- package/dist/entities/account/accountSettings/accountSettings.d.ts.map +1 -0
- package/dist/entities/account/accountSettings/accountSettings.js +43 -0
- package/dist/entities/account/accountSettings/accountSettingsLocale.d.ts +8 -0
- package/dist/entities/account/accountSettings/accountSettingsLocale.d.ts.map +1 -0
- package/dist/entities/account/accountSettings/accountSettingsLocale.js +38 -0
- package/dist/entities/account/accountSettings/accountSettingsNotification.d.ts +9 -0
- package/dist/entities/account/accountSettings/accountSettingsNotification.d.ts.map +1 -0
- package/dist/entities/account/accountSettings/accountSettingsNotification.js +38 -0
- package/dist/entities/account/accountSettings/accountSettingsNotificationType.d.ts +9 -0
- package/dist/entities/account/accountSettings/accountSettingsNotificationType.d.ts.map +1 -0
- package/dist/entities/account/accountSettings/accountSettingsNotificationType.js +38 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/lib/hasDifferentValues.d.ts.map +1 -1
- package/dist/lib/hasDifferentValues.js +73 -9
- package/dist/services/account/account.d.ts +4 -1
- package/dist/services/account/account.d.ts.map +1 -1
- package/dist/services/account/account.js +97 -6
- package/dist/services/account/accountFCMDevice.d.ts +9 -3
- package/dist/services/account/accountFCMDevice.d.ts.map +1 -1
- package/dist/services/account/accountFCMDevice.js +73 -14
- package/dist/services/account/accountNotificationChannel.d.ts.map +1 -1
- package/dist/services/account/accountNotificationChannel.js +20 -1
- package/dist/services/account/accountNotificationChannelType.d.ts +13 -0
- package/dist/services/account/accountNotificationChannelType.d.ts.map +1 -0
- package/dist/services/account/accountNotificationChannelType.js +67 -0
- package/dist/services/account/accountSettings/accountSettingsLocale.d.ts +20 -0
- package/dist/services/account/accountSettings/accountSettingsLocale.d.ts.map +1 -0
- package/dist/services/account/accountSettings/accountSettingsLocale.js +73 -0
- package/dist/services/account/accountSettings/accountSettingsNotificationType.d.ts +16 -0
- package/dist/services/account/accountSettings/accountSettingsNotificationType.d.ts.map +1 -0
- package/dist/services/account/accountSettings/accountSettingsNotificationType.js +61 -0
- package/dist/services/base/baseOneService.d.ts.map +1 -1
- package/dist/services/base/baseOneService.js +5 -0
- package/package.json +2 -5
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AccountSettingsLocaleService = void 0;
|
|
13
|
+
const db_1 = require("@orm/db");
|
|
14
|
+
const accountSettingsLocale_1 = require("@orm/entities/account/accountSettings/accountSettingsLocale");
|
|
15
|
+
const accountSettings_1 = require("@orm/entities/account/accountSettings/accountSettings");
|
|
16
|
+
const accountFCMDevice_1 = require("@orm/entities/account/accountFCMDevice");
|
|
17
|
+
class AccountSettingsLocaleService {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.repositoryReadWrite = db_1.AppDataSourceReadWrite.getRepository(accountSettingsLocale_1.AccountSettingsLocale);
|
|
20
|
+
this.repositoryRead = db_1.AppDataSourceRead.getRepository(accountSettingsLocale_1.AccountSettingsLocale);
|
|
21
|
+
}
|
|
22
|
+
create(dto) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const accountSettingsRepo = db_1.AppDataSourceRead.getRepository(accountSettings_1.AccountSettings);
|
|
25
|
+
const accountSettings = yield accountSettingsRepo.findOne({
|
|
26
|
+
where: { account_id: dto.account_id }
|
|
27
|
+
});
|
|
28
|
+
if (!accountSettings) {
|
|
29
|
+
throw new Error('AccountSettings not found for account');
|
|
30
|
+
}
|
|
31
|
+
const obj = this.repositoryReadWrite.create({
|
|
32
|
+
account_settings_id: accountSettings.id,
|
|
33
|
+
locale: dto.locale
|
|
34
|
+
});
|
|
35
|
+
const saved = yield this.repositoryReadWrite.save(obj);
|
|
36
|
+
yield this.updateAccountFCMDeviceLocales(dto.account_id, dto.locale);
|
|
37
|
+
return saved;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
update(dto) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const accountSettingsRepo = db_1.AppDataSourceRead.getRepository(accountSettings_1.AccountSettings);
|
|
43
|
+
const accountSettings = yield accountSettingsRepo.findOne({
|
|
44
|
+
where: { account_id: dto.account_id },
|
|
45
|
+
relations: ['account_settings_locale']
|
|
46
|
+
});
|
|
47
|
+
if (!accountSettings) {
|
|
48
|
+
throw new Error('AccountSettings not found for account');
|
|
49
|
+
}
|
|
50
|
+
if (!accountSettings.account_settings_locale) {
|
|
51
|
+
return this.create(dto);
|
|
52
|
+
}
|
|
53
|
+
const localeSettings = accountSettings.account_settings_locale;
|
|
54
|
+
localeSettings.locale = dto.locale;
|
|
55
|
+
const saved = yield this.repositoryReadWrite.save(localeSettings);
|
|
56
|
+
yield this.updateAccountFCMDeviceLocales(dto.account_id, dto.locale);
|
|
57
|
+
return saved;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
updateAccountFCMDeviceLocales(account_id, locale) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const fcmDeviceRepo = db_1.AppDataSourceReadWrite.getRepository(accountFCMDevice_1.AccountFCMDevice);
|
|
63
|
+
const devices = yield fcmDeviceRepo.find({ where: { account_id } });
|
|
64
|
+
if (devices.length > 0) {
|
|
65
|
+
for (const device of devices) {
|
|
66
|
+
device.locale = locale;
|
|
67
|
+
}
|
|
68
|
+
yield fcmDeviceRepo.save(devices);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.AccountSettingsLocaleService = AccountSettingsLocaleService;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AccountNotificationTypeValues } from 'podverse-helpers';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { AccountSettingsNotificationType } from '@orm/entities/account/accountSettings/accountSettingsNotificationType';
|
|
4
|
+
type CreateDto = {
|
|
5
|
+
account_id: number;
|
|
6
|
+
type: AccountNotificationTypeValues;
|
|
7
|
+
};
|
|
8
|
+
export declare class AccountSettingsNotificationTypeService {
|
|
9
|
+
protected repositoryReadWrite: Repository<AccountSettingsNotificationType>;
|
|
10
|
+
protected repositoryRead: Repository<AccountSettingsNotificationType>;
|
|
11
|
+
constructor();
|
|
12
|
+
create(dto: CreateDto): Promise<AccountSettingsNotificationType>;
|
|
13
|
+
delete(type: AccountNotificationTypeValues, account_id: number): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=accountSettingsNotificationType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountSettingsNotificationType.d.ts","sourceRoot":"","sources":["../../../../src/services/account/accountSettings/accountSettingsNotificationType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,+BAA+B,EAAE,MAAM,uEAAuE,CAAC;AAGxH,KAAK,SAAS,GAAG;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,6BAA6B,CAAC;CACrC,CAAC;AAEF,qBAAa,sCAAsC;IACjD,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,+BAA+B,CAAC,CAAC;IAC3E,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,+BAA+B,CAAC,CAAC;;IAOhE,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAiBhE,MAAM,CAAC,IAAI,EAAE,6BAA6B,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BrF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AccountSettingsNotificationTypeService = void 0;
|
|
13
|
+
const db_1 = require("@orm/db");
|
|
14
|
+
const accountSettingsNotificationType_1 = require("@orm/entities/account/accountSettings/accountSettingsNotificationType");
|
|
15
|
+
const accountSettings_1 = require("@orm/entities/account/accountSettings/accountSettings");
|
|
16
|
+
class AccountSettingsNotificationTypeService {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.repositoryReadWrite = db_1.AppDataSourceReadWrite.getRepository(accountSettingsNotificationType_1.AccountSettingsNotificationType);
|
|
19
|
+
this.repositoryRead = db_1.AppDataSourceRead.getRepository(accountSettingsNotificationType_1.AccountSettingsNotificationType);
|
|
20
|
+
}
|
|
21
|
+
create(dto) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const accountSettingsRepo = db_1.AppDataSourceRead.getRepository(accountSettings_1.AccountSettings);
|
|
24
|
+
const accountSettings = yield accountSettingsRepo.findOne({ where: { account_id: dto.account_id }, relations: ['account_settings_notification'] });
|
|
25
|
+
if (!accountSettings || !accountSettings.account_settings_notification) {
|
|
26
|
+
throw new Error('AccountSettingsNotification not found for account');
|
|
27
|
+
}
|
|
28
|
+
const parent = accountSettings.account_settings_notification;
|
|
29
|
+
const obj = this.repositoryReadWrite.create({
|
|
30
|
+
type: dto.type,
|
|
31
|
+
account_settings_notification: parent,
|
|
32
|
+
});
|
|
33
|
+
return this.repositoryReadWrite.save(obj);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
delete(type, account_id) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const accountSettingsRepo = db_1.AppDataSourceRead.getRepository(accountSettings_1.AccountSettings);
|
|
39
|
+
const accountSettings = yield accountSettingsRepo.findOne({ where: { account_id }, relations: ['account_settings_notification'] });
|
|
40
|
+
if (!accountSettings || !accountSettings.account_settings_notification) {
|
|
41
|
+
throw new Error('AccountSettingsNotification not found for account');
|
|
42
|
+
}
|
|
43
|
+
const parentId = accountSettings.account_settings_notification.id;
|
|
44
|
+
const item = yield this.repositoryRead.findOne({
|
|
45
|
+
where: {
|
|
46
|
+
type,
|
|
47
|
+
account_settings_notification: {
|
|
48
|
+
id: parentId
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
relations: ['account_settings_notification']
|
|
52
|
+
});
|
|
53
|
+
if (!item) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
yield this.repositoryReadWrite.remove(item);
|
|
57
|
+
return;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.AccountSettingsNotificationTypeService = AccountSettingsNotificationTypeService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseOneService.d.ts","sourceRoot":"","sources":["../../../src/services/base/baseOneService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAoB,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMrG,qBAAa,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,SAAS,MAAM,CAAC;IACpE,OAAO,CAAC,eAAe,CAAI;IAC3B,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,0BAA0B,CAAC,CAAgB;gBAEvC,MAAM,EAAE;QAAE,QAAQ,CAAC,CAAA;KAAE,EAAE,eAAe,EAAE,CAAC,EAAE,0BAA0B,CAAC,EAAE,aAAa;IAO3F,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,C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{
|
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
var _a;
|
|
33
33
|
let entity = yield this._get(parentEntity, config);
|
|
34
|
+
loggerService_1.loggerService.debug(`parentEntityKey: ${this.parentEntityKey}`);
|
|
35
|
+
loggerService_1.loggerService.debug(`dto: ${dto ? JSON.stringify(dto) : 'null'}`);
|
|
36
|
+
loggerService_1.loggerService.debug(`config: ${config ? JSON.stringify(config) : 'null'}`);
|
|
37
|
+
loggerService_1.loggerService.debug(`Entity exists: ${!!entity}`);
|
|
38
|
+
loggerService_1.loggerService.debug(`Entity has different values: ${entity ? (0, hasDifferentValues_1.hasDifferentValues)(entity, dto) : 'N/A'}`);
|
|
34
39
|
if (!entity) {
|
|
35
40
|
entity = new this.repositoryReadWrite.target();
|
|
36
41
|
entity[this.parentEntityKey] = parentEntity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-orm",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.16-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,16 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "AGPLv3",
|
|
18
|
-
"overrides": {
|
|
19
|
-
"fast-xml-parser": "^4.1.2"
|
|
20
|
-
},
|
|
21
18
|
"dependencies": {
|
|
22
19
|
"async-mutex": "^0.5.0",
|
|
23
20
|
"bcrypt": "^6.0.0",
|
|
24
21
|
"module-alias": "^2.2.3",
|
|
25
22
|
"nanoid": "^5.1.6",
|
|
26
23
|
"pg": "^8.16.3",
|
|
27
|
-
"podverse-helpers": "^5.1.
|
|
24
|
+
"podverse-helpers": "^5.1.16-alpha.0",
|
|
28
25
|
"typeorm": "^0.3.26",
|
|
29
26
|
"typeorm-naming-strategies": "^4.1.0"
|
|
30
27
|
},
|