podverse-orm 5.1.24-alpha.0 → 5.1.27-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 +2 -26
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +26 -25
- package/dist/config/types.d.ts +34 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/context.d.ts +20 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +40 -0
- package/dist/db/entities.d.ts +101 -0
- package/dist/db/entities.d.ts.map +1 -0
- package/dist/db/entities.js +211 -0
- package/dist/db/index.d.ts +12 -3
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +63 -227
- package/dist/entities/account/accountMembershipStatus.d.ts +1 -0
- package/dist/entities/account/accountMembershipStatus.d.ts.map +1 -1
- package/dist/entities/account/accountMembershipStatus.js +4 -0
- package/dist/factories/loggerService.d.ts +1 -2
- package/dist/factories/loggerService.d.ts.map +1 -1
- package/dist/factories/loggerService.js +14 -4
- package/dist/factory.d.ts +24 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +52 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/services/account/account.d.ts +5 -3
- package/dist/services/account/account.d.ts.map +1 -1
- package/dist/services/account/account.js +43 -16
- package/dist/services/account/accountDataExport.d.ts +46 -0
- package/dist/services/account/accountDataExport.d.ts.map +1 -0
- package/dist/services/account/accountDataExport.js +251 -0
- package/dist/services/account/accountFollowingChannel.d.ts +4 -0
- package/dist/services/account/accountFollowingChannel.d.ts.map +1 -1
- package/dist/services/account/accountFollowingChannel.js +21 -3
- package/dist/services/account/accountProfile.d.ts.map +1 -1
- package/dist/services/account/accountProfile.js +16 -2
- package/dist/services/base/baseGetOnlyService.js +2 -2
- package/dist/services/base/baseManyService.d.ts +1 -0
- package/dist/services/base/baseManyService.d.ts.map +1 -1
- package/dist/services/base/baseManyService.js +20 -11
- package/dist/services/base/baseOneService.d.ts.map +1 -1
- package/dist/services/base/baseOneService.js +11 -11
- package/dist/services/clip.d.ts +2 -0
- package/dist/services/clip.d.ts.map +1 -1
- package/dist/services/clip.js +33 -0
- package/dist/services/playlist/playlist.d.ts +2 -0
- package/dist/services/playlist/playlist.d.ts.map +1 -1
- package/dist/services/playlist/playlist.js +14 -0
- package/dist/services/stats/statsAggregatedAccount.d.ts +4 -0
- package/dist/services/stats/statsAggregatedAccount.d.ts.map +1 -1
- package/dist/services/stats/statsAggregatedAccount.js +34 -0
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.AccountService = void 0;
|
|
13
13
|
const podverse_helpers_1 = require("podverse-helpers");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
14
15
|
const account_1 = require("@orm/entities/account/account");
|
|
15
16
|
const db_1 = require("@orm/db");
|
|
16
17
|
const sharableStatus_1 = require("@orm/entities/sharableStatus");
|
|
@@ -20,6 +21,7 @@ const accountMembershipStatus_1 = require("./accountMembershipStatus");
|
|
|
20
21
|
const accountVerification_1 = require("./accountVerification");
|
|
21
22
|
const accountResetPassword_1 = require("./accountResetPassword");
|
|
22
23
|
const accountProfile_1 = require("./accountProfile");
|
|
24
|
+
const accountProfile_2 = require("@orm/entities/account/accountProfile");
|
|
23
25
|
const accountSettings_1 = require("@orm/entities/account/accountSettings/accountSettings");
|
|
24
26
|
const accountSettingsLocale_1 = require("@orm/entities/account/accountSettings/accountSettingsLocale");
|
|
25
27
|
const accountSettingsNotification_1 = require("@orm/entities/account/accountSettings/accountSettingsNotification");
|
|
@@ -78,6 +80,25 @@ class AccountService {
|
|
|
78
80
|
return this.repositoryRead.find(config);
|
|
79
81
|
});
|
|
80
82
|
}
|
|
83
|
+
getManyPublic(config) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const sharableStatusIds = (0, podverse_helpers_1.getSharableStatusIdsForProfileType)('global');
|
|
86
|
+
return this.repositoryRead.find(Object.assign(Object.assign({}, config), { where: Object.assign(Object.assign({}, config.where), { sharable_status: { id: (0, typeorm_1.In)(sharableStatusIds) }, account_profile: {
|
|
87
|
+
display_name: (0, typeorm_1.Not)((0, typeorm_1.IsNull)())
|
|
88
|
+
} }) }));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
getManySubscribed(accountIds, config) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (accountIds.length === 0) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
const sharableStatusIds = (0, podverse_helpers_1.getSharableStatusIdsForProfileType)('subscribed');
|
|
97
|
+
return this.repositoryRead.find(Object.assign(Object.assign({}, config), { where: Object.assign(Object.assign({}, config.where), { id: (0, typeorm_1.In)(accountIds), sharable_status: { id: (0, typeorm_1.In)(sharableStatusIds) }, account_profile: {
|
|
98
|
+
display_name: (0, typeorm_1.Not)((0, typeorm_1.IsNull)())
|
|
99
|
+
} }) }));
|
|
100
|
+
});
|
|
101
|
+
}
|
|
81
102
|
create(dto, qaVerified) {
|
|
82
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
104
|
if (!(0, podverse_helpers_1.validateEmail)(dto.email)) {
|
|
@@ -102,6 +123,13 @@ class AccountService {
|
|
|
102
123
|
});
|
|
103
124
|
const account = yield this.repositoryReadWrite.save(accountObj);
|
|
104
125
|
yield this.ensureAccountSettings(account, { alwaysCreate: true, locale: dto.locale });
|
|
126
|
+
// Create account_profile row with null display_name and bio
|
|
127
|
+
const accountProfileRepo = db_1.AppDataSourceReadWrite.getRepository(accountProfile_2.AccountProfile);
|
|
128
|
+
const accountProfile = new accountProfile_2.AccountProfile();
|
|
129
|
+
accountProfile.account = account;
|
|
130
|
+
accountProfile.display_name = null;
|
|
131
|
+
accountProfile.bio = null;
|
|
132
|
+
yield accountProfileRepo.save(accountProfile);
|
|
105
133
|
const saltedPassword = yield (0, password_1.hashPassword)(dto.password);
|
|
106
134
|
yield accountCredentialsService.update(account, {
|
|
107
135
|
email: dto.email,
|
|
@@ -122,23 +150,22 @@ class AccountService {
|
|
|
122
150
|
if (!account) {
|
|
123
151
|
throw new Error('Account not found');
|
|
124
152
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
throw new Error('SharableStatus not found');
|
|
138
|
-
}
|
|
139
|
-
account.sharable_status = sharableStatus;
|
|
140
|
-
yield this.repositoryReadWrite.save(account);
|
|
153
|
+
// Always update account profile
|
|
154
|
+
const accountProfileService = new accountProfile_1.AccountProfileService();
|
|
155
|
+
const accountProfileDto = {
|
|
156
|
+
display_name: dto.display_name,
|
|
157
|
+
bio: dto.bio
|
|
158
|
+
};
|
|
159
|
+
yield accountProfileService.update(account, accountProfileDto);
|
|
160
|
+
// Always update sharable status
|
|
161
|
+
const sharableStatusRepository = db_1.AppDataSourceRead.getRepository(sharableStatus_1.SharableStatus);
|
|
162
|
+
const sharableStatus = yield sharableStatusRepository.findOne({ where: { id: dto.sharable_status } });
|
|
163
|
+
if (!sharableStatus) {
|
|
164
|
+
throw new Error('SharableStatus not found');
|
|
141
165
|
}
|
|
166
|
+
account.sharable_status = sharableStatus;
|
|
167
|
+
yield this.repositoryReadWrite.save(account);
|
|
168
|
+
// Always update locale
|
|
142
169
|
const accountSettings = yield db_1.AppDataSourceReadWrite.getRepository(accountSettings_1.AccountSettings).findOne({
|
|
143
170
|
where: { account_id },
|
|
144
171
|
relations: ['account_settings_locale']
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare class AccountDataExportService {
|
|
2
|
+
private accountService;
|
|
3
|
+
constructor();
|
|
4
|
+
exportUserData(account_id: number): Promise<{
|
|
5
|
+
export_date: string;
|
|
6
|
+
account: {
|
|
7
|
+
id: number;
|
|
8
|
+
id_text: string;
|
|
9
|
+
verified: boolean;
|
|
10
|
+
sharable_status_id: number | null;
|
|
11
|
+
account_profile?: {
|
|
12
|
+
display_name: string | null;
|
|
13
|
+
bio: string | null;
|
|
14
|
+
} | null;
|
|
15
|
+
};
|
|
16
|
+
following: {
|
|
17
|
+
accounts: Array<{
|
|
18
|
+
id_text: string;
|
|
19
|
+
verified: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
channels: Array<{
|
|
22
|
+
id_text: string;
|
|
23
|
+
title: string | null;
|
|
24
|
+
feed: {
|
|
25
|
+
url: string;
|
|
26
|
+
} | null;
|
|
27
|
+
}>;
|
|
28
|
+
playlists: Array<{
|
|
29
|
+
id_text: string;
|
|
30
|
+
title: string | null;
|
|
31
|
+
account: {
|
|
32
|
+
id_text: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}>;
|
|
35
|
+
add_by_rss_channels: Array<{
|
|
36
|
+
feed_url: string;
|
|
37
|
+
title: string | null;
|
|
38
|
+
image_url: string | null;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
playlists: Array<unknown>;
|
|
42
|
+
clips: Array<unknown>;
|
|
43
|
+
queues: Array<unknown>;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=accountDataExport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountDataExport.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountDataExport.ts"],"names":[],"mappings":"AAeA,qBAAa,wBAAwB;IACnC,OAAO,CAAC,cAAc,CAAiB;;IAMjC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAChD,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE;YACP,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,EAAE,MAAM,CAAC;YAChB,QAAQ,EAAE,OAAO,CAAC;YAClB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;YAClC,eAAe,CAAC,EAAE;gBAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;gBAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;aACpB,GAAG,IAAI,CAAC;SACV,CAAC;QACF,SAAS,EAAE;YACT,QAAQ,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,OAAO,CAAA;aAAE,CAAC,CAAC;YACxD,QAAQ,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;gBAAC,IAAI,EAAE;oBAAE,GAAG,EAAE,MAAM,CAAA;iBAAE,GAAG,IAAI,CAAA;aAAE,CAAC,CAAC;YACzF,SAAS,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;gBAAC,OAAO,EAAE;oBAAE,OAAO,EAAE,MAAM,CAAA;iBAAE,GAAG,IAAI,CAAA;aAAE,CAAC,CAAC;YACjG,mBAAmB,EAAE,KAAK,CAAC;gBAAE,QAAQ,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;gBAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;aAAE,CAAC,CAAC;SAClG,CAAC;QACF,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACtB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;KACxB,CAAC;CAkSH"}
|
|
@@ -0,0 +1,251 @@
|
|
|
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.AccountDataExportService = void 0;
|
|
13
|
+
const accountFollowingAccount_1 = require("./accountFollowingAccount");
|
|
14
|
+
const accountFollowingChannel_1 = require("./accountFollowingChannel");
|
|
15
|
+
const accountFollowingPlaylist_1 = require("./accountFollowingPlaylist");
|
|
16
|
+
const accountFollowingAddByRSSChannel_1 = require("./accountFollowingAddByRSSChannel");
|
|
17
|
+
const playlist_1 = require("../playlist/playlist");
|
|
18
|
+
const playlistResource_1 = require("../playlist/playlistResource");
|
|
19
|
+
const clip_1 = require("../clip");
|
|
20
|
+
const queue_1 = require("../queue/queue");
|
|
21
|
+
const queueResource_1 = require("../queue/queueResource");
|
|
22
|
+
const account_1 = require("./account");
|
|
23
|
+
class AccountDataExportService {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.accountService = new account_1.AccountService();
|
|
26
|
+
}
|
|
27
|
+
exportUserData(account_id) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b, _c, _d;
|
|
30
|
+
const account = yield this.accountService.get(account_id, {
|
|
31
|
+
relations: [
|
|
32
|
+
'account_profile'
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
if (!account) {
|
|
36
|
+
throw new Error('Account not found');
|
|
37
|
+
}
|
|
38
|
+
const accountData = {
|
|
39
|
+
id: account.id,
|
|
40
|
+
id_text: account.id_text,
|
|
41
|
+
verified: account.verified,
|
|
42
|
+
sharable_status_id: (_b = (_a = account.sharable_status) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
|
|
43
|
+
account_profile: account.account_profile ? {
|
|
44
|
+
display_name: (_c = account.account_profile.display_name) !== null && _c !== void 0 ? _c : null,
|
|
45
|
+
bio: (_d = account.account_profile.bio) !== null && _d !== void 0 ? _d : null
|
|
46
|
+
} : null
|
|
47
|
+
};
|
|
48
|
+
// Get following relationships
|
|
49
|
+
const accountFollowingAccountService = new accountFollowingAccount_1.AccountFollowingAccountService();
|
|
50
|
+
const accountFollowingChannelService = new accountFollowingChannel_1.AccountFollowingChannelService();
|
|
51
|
+
const accountFollowingPlaylistService = new accountFollowingPlaylist_1.AccountFollowingPlaylistService();
|
|
52
|
+
const accountFollowingAddByRSSChannelService = new accountFollowingAddByRSSChannel_1.AccountFollowingAddByRSSChannelService();
|
|
53
|
+
const followingAccounts = yield accountFollowingAccountService.getFollowedAccountsPrivate(account_id, {
|
|
54
|
+
relations: ['following_account']
|
|
55
|
+
});
|
|
56
|
+
const followingChannels = yield accountFollowingChannelService.getFollowedChannels(account_id, null, {
|
|
57
|
+
relations: ['channel', 'channel.feed']
|
|
58
|
+
});
|
|
59
|
+
const followingPlaylists = yield accountFollowingPlaylistService.getFollowedPlaylistsPrivate(account_id, {
|
|
60
|
+
relations: ['playlist', 'playlist.account']
|
|
61
|
+
});
|
|
62
|
+
const followingAddByRSSChannels = yield accountFollowingAddByRSSChannelService.getFollowedAddByRSSChannels(account_id);
|
|
63
|
+
// Get user's playlists
|
|
64
|
+
const playlistService = new playlist_1.PlaylistService();
|
|
65
|
+
const playlistResourceService = new playlistResource_1.PlaylistResourceService();
|
|
66
|
+
const [playlists] = yield playlistService.getManyPrivate(account_id, null, {
|
|
67
|
+
relations: ['playlist_resources']
|
|
68
|
+
});
|
|
69
|
+
// Get user's clips
|
|
70
|
+
const clipService = new clip_1.ClipService();
|
|
71
|
+
const clips = yield clipService.getManyByAccount(account_id);
|
|
72
|
+
// Get user's queues
|
|
73
|
+
const queueService = new queue_1.QueueService();
|
|
74
|
+
const queueResourceService = new queueResource_1.QueueResourceService();
|
|
75
|
+
const queues = yield queueService.getAllPrivate(account_id);
|
|
76
|
+
const getMinimalItemInfo = (item) => {
|
|
77
|
+
var _a;
|
|
78
|
+
if (!item)
|
|
79
|
+
return null;
|
|
80
|
+
return {
|
|
81
|
+
id_text: item.id_text,
|
|
82
|
+
title: (_a = item.title) !== null && _a !== void 0 ? _a : null,
|
|
83
|
+
pub_date: item.pub_date ? item.pub_date.toISOString() : null,
|
|
84
|
+
channel: item.channel ? {
|
|
85
|
+
id_text: item.channel.id_text,
|
|
86
|
+
title: item.channel.title,
|
|
87
|
+
feed: item.channel.feed ? {
|
|
88
|
+
url: item.channel.feed.url
|
|
89
|
+
} : null
|
|
90
|
+
} : null
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const getMinimalClipInfo = (clip) => {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
if (!clip)
|
|
96
|
+
return null;
|
|
97
|
+
return {
|
|
98
|
+
id_text: clip.id_text,
|
|
99
|
+
title: (_a = clip.title) !== null && _a !== void 0 ? _a : null,
|
|
100
|
+
start_time: clip.start_time,
|
|
101
|
+
end_time: (_b = clip.end_time) !== null && _b !== void 0 ? _b : null,
|
|
102
|
+
created_at: clip.created_at.toISOString(),
|
|
103
|
+
item: getMinimalItemInfo((_c = clip.item) !== null && _c !== void 0 ? _c : null)
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
// Process playlists with resources
|
|
107
|
+
const playlistsData = yield Promise.all(playlists.map((playlist) => __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const resources = yield playlistResourceService.getManyByPlaylistIdText(playlist.id_text, account_id, {
|
|
109
|
+
relations: [
|
|
110
|
+
'item', 'item.channel', 'item.channel.feed',
|
|
111
|
+
'clip', 'clip.item', 'clip.item.channel', 'clip.item.channel.feed',
|
|
112
|
+
'item_soundbite', 'item_soundbite.item', 'item_soundbite.item.channel', 'item_soundbite.item.channel.feed'
|
|
113
|
+
]
|
|
114
|
+
});
|
|
115
|
+
const playlistResourcesData = resources.map((resource) => {
|
|
116
|
+
const resourceData = {
|
|
117
|
+
list_position: resource.list_position
|
|
118
|
+
};
|
|
119
|
+
if (resource.item) {
|
|
120
|
+
resourceData.item = getMinimalItemInfo(resource.item);
|
|
121
|
+
}
|
|
122
|
+
if (resource.clip) {
|
|
123
|
+
resourceData.clip = getMinimalClipInfo(resource.clip);
|
|
124
|
+
}
|
|
125
|
+
if (resource.item_soundbite) {
|
|
126
|
+
resourceData.item_soundbite = {
|
|
127
|
+
id: resource.item_soundbite.id,
|
|
128
|
+
item: getMinimalItemInfo(resource.item_soundbite.item)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
if (resource.add_by_rss_hash_id) {
|
|
132
|
+
resourceData.add_by_rss_hash_id = resource.add_by_rss_hash_id;
|
|
133
|
+
}
|
|
134
|
+
if (resource.add_by_rss_resource_data) {
|
|
135
|
+
resourceData.add_by_rss_resource_data = resource.add_by_rss_resource_data;
|
|
136
|
+
}
|
|
137
|
+
return resourceData;
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
id_text: playlist.id_text,
|
|
141
|
+
title: playlist.title,
|
|
142
|
+
description: playlist.description,
|
|
143
|
+
is_default_favorites: playlist.is_default_favorites,
|
|
144
|
+
item_count: playlist.item_count,
|
|
145
|
+
last_updated: playlist.last_updated,
|
|
146
|
+
medium_id: playlist.medium_id,
|
|
147
|
+
sharable_status_id: playlist.sharable_status_id,
|
|
148
|
+
playlist_resources: playlistResourcesData
|
|
149
|
+
};
|
|
150
|
+
})));
|
|
151
|
+
// Process clips
|
|
152
|
+
const clipsData = yield Promise.all(clips.map((clip) => __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
// Need to load item with channel and feed
|
|
154
|
+
const clipWithRelations = yield clipService.getByIdText(clip.id_text, {
|
|
155
|
+
relations: ['item', 'item.channel', 'item.channel.feed']
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
id_text: clip.id_text,
|
|
159
|
+
title: clip.title,
|
|
160
|
+
description: clip.description,
|
|
161
|
+
start_time: clip.start_time,
|
|
162
|
+
end_time: clip.end_time,
|
|
163
|
+
created_at: clip.created_at,
|
|
164
|
+
sharable_status_id: clip.sharable_status_id,
|
|
165
|
+
item: (clipWithRelations === null || clipWithRelations === void 0 ? void 0 : clipWithRelations.item) ? getMinimalItemInfo(clipWithRelations.item) : null
|
|
166
|
+
};
|
|
167
|
+
})));
|
|
168
|
+
// Process queues with resources
|
|
169
|
+
const queuesData = yield Promise.all(queues.map((queue) => __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
// Get all queue resources for this queue (both history and upcoming)
|
|
171
|
+
const [historyResources] = yield queueResourceService.getHistoryResourcesByQueueIdText(queue.id_text, {
|
|
172
|
+
relations: queueResource_1.listResourceRelations
|
|
173
|
+
});
|
|
174
|
+
const upcomingResources = yield queueResourceService.getAllUpcomingByQueueIdText(queue.id_text);
|
|
175
|
+
// Combine all resources, sorted by list_position
|
|
176
|
+
const allQueueResources = [...historyResources, ...upcomingResources].sort((a, b) => parseFloat(a.list_position) - parseFloat(b.list_position));
|
|
177
|
+
const queueResourcesData = allQueueResources.map((resource) => {
|
|
178
|
+
const resourceData = {
|
|
179
|
+
list_position: resource.list_position,
|
|
180
|
+
playback_position: resource.playback_position,
|
|
181
|
+
media_file_duration: resource.media_file_duration,
|
|
182
|
+
completed: resource.completed
|
|
183
|
+
};
|
|
184
|
+
if (resource.item) {
|
|
185
|
+
resourceData.item = getMinimalItemInfo(resource.item);
|
|
186
|
+
}
|
|
187
|
+
if (resource.clip) {
|
|
188
|
+
resourceData.clip = getMinimalClipInfo(resource.clip);
|
|
189
|
+
}
|
|
190
|
+
if (resource.item_soundbite) {
|
|
191
|
+
resourceData.item_soundbite = {
|
|
192
|
+
id: resource.item_soundbite.id,
|
|
193
|
+
item: getMinimalItemInfo(resource.item_soundbite.item)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (resource.add_by_rss_hash_id) {
|
|
197
|
+
resourceData.add_by_rss_hash_id = resource.add_by_rss_hash_id;
|
|
198
|
+
}
|
|
199
|
+
if (resource.add_by_rss_resource_data) {
|
|
200
|
+
resourceData.add_by_rss_resource_data = resource.add_by_rss_resource_data;
|
|
201
|
+
}
|
|
202
|
+
return resourceData;
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
id_text: queue.id_text,
|
|
206
|
+
medium_id: queue.medium_id,
|
|
207
|
+
is_active_queue: queue.is_active_queue,
|
|
208
|
+
queue_resources: queueResourcesData
|
|
209
|
+
};
|
|
210
|
+
})));
|
|
211
|
+
// Build export data
|
|
212
|
+
const exportData = {
|
|
213
|
+
export_date: new Date().toISOString(),
|
|
214
|
+
account: accountData,
|
|
215
|
+
following: {
|
|
216
|
+
accounts: followingAccounts.map(fa => ({
|
|
217
|
+
id_text: fa.following_account.id_text,
|
|
218
|
+
verified: fa.following_account.verified
|
|
219
|
+
})),
|
|
220
|
+
channels: followingChannels.map(fc => ({
|
|
221
|
+
id_text: fc.channel.id_text,
|
|
222
|
+
title: fc.channel.title,
|
|
223
|
+
feed: fc.channel.feed ? {
|
|
224
|
+
url: fc.channel.feed.url
|
|
225
|
+
} : null
|
|
226
|
+
})),
|
|
227
|
+
playlists: followingPlaylists.map(fp => {
|
|
228
|
+
var _a;
|
|
229
|
+
return ({
|
|
230
|
+
id_text: fp.playlist.id_text,
|
|
231
|
+
title: (_a = fp.playlist.title) !== null && _a !== void 0 ? _a : null,
|
|
232
|
+
account: fp.playlist.account ? {
|
|
233
|
+
id_text: fp.playlist.account.id_text
|
|
234
|
+
} : null
|
|
235
|
+
});
|
|
236
|
+
}),
|
|
237
|
+
add_by_rss_channels: followingAddByRSSChannels.map(fr => ({
|
|
238
|
+
feed_url: fr.feed_url,
|
|
239
|
+
title: fr.title,
|
|
240
|
+
image_url: fr.image_url
|
|
241
|
+
}))
|
|
242
|
+
},
|
|
243
|
+
playlists: playlistsData,
|
|
244
|
+
clips: clipsData,
|
|
245
|
+
queues: queuesData
|
|
246
|
+
};
|
|
247
|
+
return exportData;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.AccountDataExportService = AccountDataExportService;
|
|
@@ -13,5 +13,9 @@ export declare class AccountFollowingChannelService extends BaseManyService<Acco
|
|
|
13
13
|
}>;
|
|
14
14
|
followChannel(account_id: number, channel_id_text: string): Promise<AccountFollowingChannel>;
|
|
15
15
|
unfollowChannel(account_id: number, channel_id_text: string): Promise<void>;
|
|
16
|
+
getFollowedChannelsByAccountIdTextWithCount(account_id_text: string, mediumType?: QueryParamsMedium | null, config?: FindManyOptions<AccountFollowingChannel>): Promise<{
|
|
17
|
+
count: number;
|
|
18
|
+
results: AccountFollowingChannel[];
|
|
19
|
+
}>;
|
|
16
20
|
}
|
|
17
21
|
//# sourceMappingURL=accountFollowingChannel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountFollowingChannel.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountFollowingChannel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"accountFollowingChannel.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountFollowingChannel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAS,eAAe,EAAM,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAKrE,qBAAa,8BAA+B,SAAQ,eAAe,CAAC,uBAAuB,EAAE,SAAS,CAAC;IACrG,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,cAAc,CAAiB;gBAE3B,0BAA0B,CAAC,EAAE,aAAa;IAMhD,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI,EAChF,MAAM,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAuBlF,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,GAAG,IAAI,EACzF,MAAM,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAAG,OAAO,CAAC;QAC1D,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,uBAAuB,EAAE,CAAA;KAAE,CAAC;IA0BlD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoB5F,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3E,2CAA2C,CAC/C,eAAe,EAAE,MAAM,EACvB,UAAU,GAAE,iBAAiB,GAAG,IAAW,EAC3C,MAAM,CAAC,EAAE,eAAe,CAAC,uBAAuB,CAAC,GAChD,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,uBAAuB,EAAE,CAAA;KAAE,CAAC;CAyBlE"}
|
|
@@ -16,6 +16,7 @@ const accountFollowingChannel_1 = require("@orm/entities/account/accountFollowin
|
|
|
16
16
|
const baseManyService_1 = require("@orm/services/base/baseManyService");
|
|
17
17
|
const account_1 = require("@orm/services/account/account");
|
|
18
18
|
const channel_1 = require("../channel/channel");
|
|
19
|
+
const feedFlagStatus_1 = require("@orm/entities/feed/feedFlagStatus");
|
|
19
20
|
class AccountFollowingChannelService extends baseManyService_1.BaseManyService {
|
|
20
21
|
constructor(transactionalEntityManager) {
|
|
21
22
|
super(accountFollowingChannel_1.AccountFollowingChannel, 'account', transactionalEntityManager);
|
|
@@ -46,10 +47,10 @@ class AccountFollowingChannelService extends baseManyService_1.BaseManyService {
|
|
|
46
47
|
}
|
|
47
48
|
const where = {
|
|
48
49
|
account_id: (0, typeorm_1.Equal)(account.id),
|
|
50
|
+
channel: Object.assign({ feed: {
|
|
51
|
+
feed_flag_status: (0, typeorm_1.In)([feedFlagStatus_1.FeedFlagStatusStatusEnum.Active, feedFlagStatus_1.FeedFlagStatusStatusEnum.AlwaysParse])
|
|
52
|
+
} }, (medium_ids ? { medium_id: (0, typeorm_1.In)(medium_ids) } : {}))
|
|
49
53
|
};
|
|
50
|
-
if (medium_ids) {
|
|
51
|
-
where['channel'] = { medium_id: (0, typeorm_1.In)(medium_ids) };
|
|
52
|
-
}
|
|
53
54
|
const finalConfig = Object.assign(Object.assign({}, config), { where });
|
|
54
55
|
return this._getAllWithCount(account, finalConfig);
|
|
55
56
|
});
|
|
@@ -81,5 +82,22 @@ class AccountFollowingChannelService extends baseManyService_1.BaseManyService {
|
|
|
81
82
|
return this._delete(account, { channel_id: channel.id });
|
|
82
83
|
});
|
|
83
84
|
}
|
|
85
|
+
getFollowedChannelsByAccountIdTextWithCount(account_id_text_1) {
|
|
86
|
+
return __awaiter(this, arguments, void 0, function* (account_id_text, mediumType = null, config) {
|
|
87
|
+
const medium_ids = mediumType ? (0, podverse_helpers_1.getMediumIdArrayFromType)(mediumType) : null;
|
|
88
|
+
const account = yield this.accountService.getByIdText(account_id_text);
|
|
89
|
+
if (!account) {
|
|
90
|
+
throw new Error("Account not found.");
|
|
91
|
+
}
|
|
92
|
+
const where = {
|
|
93
|
+
account_id: (0, typeorm_1.Equal)(account.id),
|
|
94
|
+
channel: Object.assign({ feed: {
|
|
95
|
+
feed_flag_status: (0, typeorm_1.In)([feedFlagStatus_1.FeedFlagStatusStatusEnum.Active, feedFlagStatus_1.FeedFlagStatusStatusEnum.AlwaysParse])
|
|
96
|
+
} }, (medium_ids ? { medium_id: (0, typeorm_1.In)(medium_ids) } : {}))
|
|
97
|
+
};
|
|
98
|
+
const finalConfig = Object.assign(Object.assign({}, config), { where });
|
|
99
|
+
return this._getAllWithCount(account, finalConfig);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
84
102
|
}
|
|
85
103
|
exports.AccountFollowingChannelService = AccountFollowingChannelService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountProfile.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC;gBACtE,0BAA0B,CAAC,EAAE,aAAa;IAIhD,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"accountProfile.d.ts","sourceRoot":"","sources":["../../../src/services/account/accountProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,cAAc,EAAE,SAAS,CAAC;gBACtE,0BAA0B,CAAC,EAAE,aAAa;IAIhD,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;CAuBhF"}
|
|
@@ -21,9 +21,23 @@ class AccountProfileService extends baseOneService_1.BaseOneService {
|
|
|
21
21
|
_update: { get: () => super._update }
|
|
22
22
|
});
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
// Trim display_name and set to null if empty/whitespace
|
|
26
|
+
let display_name = (_a = dto.display_name) !== null && _a !== void 0 ? _a : null;
|
|
27
|
+
if (display_name !== null && typeof display_name === 'string') {
|
|
28
|
+
display_name = display_name.trim();
|
|
29
|
+
if (display_name === '') {
|
|
30
|
+
display_name = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Trim bio
|
|
34
|
+
let bio = (_b = dto.bio) !== null && _b !== void 0 ? _b : null;
|
|
35
|
+
if (bio !== null && typeof bio === 'string') {
|
|
36
|
+
bio = bio ? bio.trim() : null;
|
|
37
|
+
}
|
|
24
38
|
const finalDto = {
|
|
25
|
-
display_name
|
|
26
|
-
bio
|
|
39
|
+
display_name,
|
|
40
|
+
bio
|
|
27
41
|
};
|
|
28
42
|
return _super._update.call(this, account, finalDto);
|
|
29
43
|
});
|
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseGetOnlyService = void 0;
|
|
13
|
-
const
|
|
13
|
+
const context_1 = require("@orm/context");
|
|
14
14
|
class BaseGetOnlyService {
|
|
15
15
|
constructor(entity) {
|
|
16
|
-
this.repositoryRead =
|
|
16
|
+
this.repositoryRead = (0, context_1.getDataSourceRead)().getRepository(entity);
|
|
17
17
|
}
|
|
18
18
|
get(id, config) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -10,6 +10,7 @@ export declare class BaseManyService<T extends ObjectLiteral, K extends keyof T>
|
|
|
10
10
|
constructor(targetEntity: {
|
|
11
11
|
new (): T;
|
|
12
12
|
}, parentEntityKey: K, transactionalEntityManager?: EntityManager);
|
|
13
|
+
private getParentWhereValue;
|
|
13
14
|
_getAll(parentEntity: T[K], config?: FindManyOptions<T>): Promise<T[]>;
|
|
14
15
|
_getAllWithCount(parentEntity: T[K], config?: FindManyOptions<T>): Promise<{
|
|
15
16
|
count: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseManyService.d.ts","sourceRoot":"","sources":["../../../src/services/base/baseManyService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAoB,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"baseManyService.d.ts","sourceRoot":"","sources":["../../../src/services/base/baseManyService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAoB,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKtH,qBAAa,eAAe,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,SAAS,MAAM,CAAC;IACrE,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACxC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC;IAC7B,SAAS,CAAC,YAAY,EAAE;QAAE,QAAQ,CAAC,CAAA;KAAE,CAAC;IACtC,OAAO,CAAC,0BAA0B,CAAC,CAAgB;gBAEvC,YAAY,EAAE;QAAE,QAAQ,CAAC,CAAA;KAAE,EAAE,eAAe,EAAE,CAAC,EAAE,0BAA0B,CAAC,EAAE,aAAa;IAQvG,OAAO,CAAC,mBAAmB;IAOd,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAMtE,gBAAgB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,EAAE,CAAA;KAAE,CAAC;IAO3G,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAS/G,OAAO,CAClB,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAClB,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,4DAA4D;IACpF,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAC1B,cAAc,CAAC,EAAE,CAAC,GAChB,OAAO,CAAC,CAAC,CAAC;IA8BD,WAAW,CACtB,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAClB,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,EACtB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAClB,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,EAAE,CAAC;IAsDF,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnF,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAOpD"}
|
|
@@ -10,34 +10,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseManyService = void 0;
|
|
13
|
-
const
|
|
13
|
+
const context_1 = require("@orm/context");
|
|
14
14
|
const applyProperties_1 = require("@orm/lib/applyProperties");
|
|
15
15
|
const hasDifferentValues_1 = require("@orm/lib/hasDifferentValues");
|
|
16
|
-
const loggerService_1 = require("@orm/factories/loggerService");
|
|
17
16
|
class BaseManyService {
|
|
18
17
|
constructor(targetEntity, parentEntityKey, transactionalEntityManager) {
|
|
19
18
|
this.targetEntity = targetEntity;
|
|
20
19
|
this.parentEntityKey = parentEntityKey;
|
|
21
|
-
this.repositoryRead =
|
|
22
|
-
this.repositoryReadWrite =
|
|
20
|
+
this.repositoryRead = (0, context_1.getDataSourceRead)().getRepository(targetEntity);
|
|
21
|
+
this.repositoryReadWrite = (0, context_1.getDataSourceReadWrite)().getRepository(targetEntity);
|
|
23
22
|
this.transactionalEntityManager = transactionalEntityManager;
|
|
24
23
|
}
|
|
24
|
+
getParentWhereValue(parentEntity) {
|
|
25
|
+
if (parentEntity && typeof parentEntity === 'object' && 'id' in parentEntity) {
|
|
26
|
+
return { id: parentEntity.id };
|
|
27
|
+
}
|
|
28
|
+
return parentEntity;
|
|
29
|
+
}
|
|
25
30
|
_getAll(parentEntity, config) {
|
|
26
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const
|
|
32
|
+
const parentWhereValue = this.getParentWhereValue(parentEntity);
|
|
33
|
+
const where = { [this.parentEntityKey]: parentWhereValue };
|
|
28
34
|
return this.repositoryRead.find(Object.assign({ where }, config));
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
37
|
_getAllWithCount(parentEntity, config) {
|
|
32
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const
|
|
39
|
+
const parentWhereValue = this.getParentWhereValue(parentEntity);
|
|
40
|
+
const where = { [this.parentEntityKey]: parentWhereValue };
|
|
34
41
|
const [results, count] = yield this.repositoryRead.findAndCount(Object.assign({ where }, config));
|
|
35
42
|
return { count, results };
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
45
|
_get(parentEntity, whereKeyValues, config) {
|
|
39
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const
|
|
47
|
+
const parentWhereValue = this.getParentWhereValue(parentEntity);
|
|
48
|
+
const where = Object.assign({ [this.parentEntityKey]: parentWhereValue }, whereKeyValues);
|
|
41
49
|
return this.repositoryRead.findOne(Object.assign({ where }, config));
|
|
42
50
|
});
|
|
43
51
|
}
|
|
@@ -63,8 +71,9 @@ class BaseManyService {
|
|
|
63
71
|
return entity;
|
|
64
72
|
}
|
|
65
73
|
entity = (0, applyProperties_1.applyProperties)(entity, dto);
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
const loggerService = (0, context_1.getLoggerService)();
|
|
75
|
+
loggerService.debug(`Updating entity ${JSON.stringify(entity)}`);
|
|
76
|
+
loggerService.debug(`With DTO ${JSON.stringify(dto)}`);
|
|
68
77
|
return ((_a = this.transactionalEntityManager) !== null && _a !== void 0 ? _a : this.repositoryReadWrite).save(entity);
|
|
69
78
|
});
|
|
70
79
|
}
|
|
@@ -73,7 +82,7 @@ class BaseManyService {
|
|
|
73
82
|
var _a, _b;
|
|
74
83
|
const existingEntities = yield this._getAll(parentEntity);
|
|
75
84
|
const existingIdentifiers = dtos.map((dto) => {
|
|
76
|
-
|
|
85
|
+
const identifier = {};
|
|
77
86
|
for (const whereKey of whereKeys) {
|
|
78
87
|
identifier[whereKey] = dto[whereKey];
|
|
79
88
|
}
|
|
@@ -100,7 +109,7 @@ class BaseManyService {
|
|
|
100
109
|
}
|
|
101
110
|
yield ((_a = this.transactionalEntityManager) !== null && _a !== void 0 ? _a : this.repositoryReadWrite).save(updatedEntities);
|
|
102
111
|
const entitiesToDelete = existingEntities.filter(existingEntity => {
|
|
103
|
-
|
|
112
|
+
const identifier = {};
|
|
104
113
|
for (const whereKey of whereKeys) {
|
|
105
114
|
identifier[whereKey] = existingEntity[whereKey];
|
|
106
115
|
}
|
|
@@ -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;
|
|
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;AAKrG,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,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAKvE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAyB7E,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD"}
|