podverse-parser 5.0.0-beta.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package.json +6 -3
  2. package/.nvmrc +0 -1
  3. package/eslint.config.mjs +0 -38
  4. package/src/index.ts +0 -3
  5. package/src/lib/chapters/chapters.ts +0 -54
  6. package/src/lib/compat/channel.ts +0 -287
  7. package/src/lib/compat/chapters/chapters.ts +0 -23
  8. package/src/lib/compat/partytime/channel.ts +0 -289
  9. package/src/lib/compat/partytime/compatFull.ts +0 -7
  10. package/src/lib/compat/partytime/funding.ts +0 -8
  11. package/src/lib/compat/partytime/item.ts +0 -273
  12. package/src/lib/compat/partytime/liveItem.ts +0 -18
  13. package/src/lib/compat/partytime/value.ts +0 -64
  14. package/src/lib/rss/base/handleParsedManyData.ts +0 -16
  15. package/src/lib/rss/base/handleParsedOneData.ts +0 -17
  16. package/src/lib/rss/channel/channel.ts +0 -55
  17. package/src/lib/rss/channel/channelAbout.ts +0 -13
  18. package/src/lib/rss/channel/channelChat.ts +0 -14
  19. package/src/lib/rss/channel/channelDescription.ts +0 -14
  20. package/src/lib/rss/channel/channelFunding.ts +0 -14
  21. package/src/lib/rss/channel/channelImage.ts +0 -14
  22. package/src/lib/rss/channel/channelLicense.ts +0 -14
  23. package/src/lib/rss/channel/channelLocation.ts +0 -14
  24. package/src/lib/rss/channel/channelPerson.ts +0 -14
  25. package/src/lib/rss/channel/channelPodroll.ts +0 -21
  26. package/src/lib/rss/channel/channelRemoteItem.ts +0 -14
  27. package/src/lib/rss/channel/channelSeason.ts +0 -14
  28. package/src/lib/rss/channel/channelSocialInteract.ts +0 -14
  29. package/src/lib/rss/channel/channelTrailer.ts +0 -31
  30. package/src/lib/rss/channel/channelTxt.ts +0 -14
  31. package/src/lib/rss/channel/channelValue.ts +0 -30
  32. package/src/lib/rss/feed/feed.ts +0 -79
  33. package/src/lib/rss/hash/parsedFeed.ts +0 -9
  34. package/src/lib/rss/item/item.ts +0 -85
  35. package/src/lib/rss/item/itemAbout.ts +0 -13
  36. package/src/lib/rss/item/itemChaptersFeed.ts +0 -14
  37. package/src/lib/rss/item/itemChat.ts +0 -14
  38. package/src/lib/rss/item/itemContentLink.ts +0 -0
  39. package/src/lib/rss/item/itemDescription.ts +0 -14
  40. package/src/lib/rss/item/itemEnclosure.ts +0 -35
  41. package/src/lib/rss/item/itemImage.ts +0 -14
  42. package/src/lib/rss/item/itemLicense.ts +0 -14
  43. package/src/lib/rss/item/itemLocation.ts +0 -14
  44. package/src/lib/rss/item/itemPerson.ts +0 -14
  45. package/src/lib/rss/item/itemSeason.ts +0 -26
  46. package/src/lib/rss/item/itemSeasonEpisode.ts +0 -14
  47. package/src/lib/rss/item/itemSocialInteract.ts +0 -14
  48. package/src/lib/rss/item/itemSoundbite.ts +0 -14
  49. package/src/lib/rss/item/itemTranscript.ts +0 -14
  50. package/src/lib/rss/item/itemTxt.ts +0 -14
  51. package/src/lib/rss/item/itemValue.ts +0 -60
  52. package/src/lib/rss/liveItem/liveItem.ts +0 -34
  53. package/src/lib/rss/parser.ts +0 -85
  54. package/src/module-alias-config.ts +0 -8
  55. package/tsconfig.json +0 -25
@@ -1,289 +0,0 @@
1
- import { FeedObject, Phase4Medium } from "podcast-partytime";
2
- import { createSortableTitle, getBooleanOrNull } from "podverse-helpers";
3
- import { getMediumEnumValue, getChannelItunesTypeItunesTypeEnumValue } from "podverse-orm";
4
- import { compatChannelValue } from "@parser/lib/compat/partytime/value";
5
- import { Phase4PodcastImage } from "podcast-partytime/dist/parser/phase/phase-4";
6
-
7
- export const compatChannelDto = (parsedFeed: FeedObject) => ({
8
- podcast_guid: parsedFeed.guid,
9
- title: parsedFeed.title,
10
- sortable_title: createSortableTitle(parsedFeed.title),
11
- medium: getMediumEnumValue(parsedFeed.medium ?? Phase4Medium.Podcast)
12
- });
13
-
14
- export const compatChannelAboutDto = (parsedFeed: FeedObject) => ({
15
- author: (Array.isArray(parsedFeed.author) ? parsedFeed.author : parsedFeed.author ? [parsedFeed.author] : [])?.join(', ') || null,
16
- explicit: getBooleanOrNull(parsedFeed.explicit),
17
- language: parsedFeed.language || null,
18
- last_pub_date: parsedFeed.pubDate || null,
19
- website_link_url: parsedFeed.link || null,
20
- itunes_type: getChannelItunesTypeItunesTypeEnumValue(parsedFeed.itunesType || 'episodic'),
21
- episode_count: (parsedFeed.items?.length || 0) + (parsedFeed.podcastLiveItems?.length || 0),
22
- });
23
-
24
- export const compatChannelChatDto = (parsedFeed: FeedObject) => {
25
- if (!parsedFeed.chat) {
26
- return null;
27
- }
28
- return {
29
- server: parsedFeed.chat.server,
30
- protocol: parsedFeed.chat.protocol,
31
- account_id: parsedFeed.chat.accountId || null,
32
- space: parsedFeed.chat.space || null
33
- };
34
- };
35
-
36
- export const compatChannelDescriptionDto = (parsedFeed: FeedObject) => {
37
- if (!parsedFeed.description) {
38
- return null;
39
- }
40
- return {
41
- value: parsedFeed.description
42
- };
43
- };
44
-
45
- export const compatChannelFundingDtos = (parsedFeed: FeedObject) => {
46
- const dtos = [];
47
-
48
- if (Array.isArray(parsedFeed.podcastFunding)) {
49
- for (const f of parsedFeed.podcastFunding) {
50
- if (f.url) {
51
- dtos.push({
52
- url: f.url,
53
- title: f.message || null
54
- });
55
- }
56
- }
57
- }
58
-
59
- return dtos;
60
- };
61
-
62
- export const compatChannelImageDtos = (parsedFeed: FeedObject) => {
63
- const dtos = [];
64
- if (parsedFeed.itunesImage) {
65
- dtos.push({
66
- url: parsedFeed.itunesImage,
67
- image_width_size: null
68
- });
69
- } else if (parsedFeed.image?.url) {
70
- dtos.push({
71
- url: parsedFeed.image.url,
72
- image_width_size: null
73
- });
74
- }
75
-
76
- function hasWidth(image: Phase4PodcastImage['parsed']): image is { url: string; width: number } {
77
- return (image as { width: number }).width !== undefined;
78
- }
79
-
80
- if (Array.isArray(parsedFeed.podcastImages)) {
81
- for (const image of parsedFeed.podcastImages) {
82
- if (image.parsed.url && hasWidth(image.parsed)) {
83
- dtos.push({
84
- url: image.parsed.url,
85
- image_width_size: image.parsed.width
86
- });
87
- }
88
- }
89
- }
90
-
91
- return dtos;
92
- };
93
-
94
- export const compatChannelLicenseDto = (parsedFeed: FeedObject) => {
95
- if (!parsedFeed?.license?.identifier) {
96
- return null;
97
- }
98
- return {
99
- identifier: parsedFeed.license.identifier,
100
- url: parsedFeed.license.url || null
101
- };
102
- };
103
-
104
- export const compatChannelLocationDto = (parsedFeed: FeedObject) => {
105
- if (!parsedFeed?.podcastLocation?.geo && !parsedFeed?.podcastLocation?.osm) {
106
- return null;
107
- }
108
-
109
- return {
110
- geo: parsedFeed.podcastLocation.geo || null,
111
- osm: parsedFeed.podcastLocation.osm || null,
112
- name: parsedFeed.podcastLocation.name || null
113
- };
114
- };
115
-
116
- export const compatChannelPersonDtos = (parsedFeed: FeedObject) => {
117
- const dtos = [];
118
-
119
- if (Array.isArray(parsedFeed.podcastPeople)) {
120
- for (const p of parsedFeed.podcastPeople) {
121
- if (p.name) {
122
- dtos.push({
123
- name: p.name,
124
- role: p.role?.toLowerCase() || null,
125
- person_group: p.group?.toLowerCase() || 'cast',
126
- img: p.img || null,
127
- href: p.href || null
128
- });
129
- }
130
- }
131
- }
132
-
133
- return dtos;
134
- };
135
-
136
- export const compatChannelPodrollRemoteItemDtos = (parsedFeed: FeedObject) => {
137
- const dtos = [];
138
-
139
- if (Array.isArray(parsedFeed.podroll)) {
140
- for (const ri of parsedFeed.podroll) {
141
- if (ri.feedGuid) {
142
- dtos.push({
143
- feed_guid: ri.feedGuid,
144
- feed_url: ri.feedUrl || null,
145
- item_guid: null,
146
- title: /* PTDO: ri.title || */ null
147
- });
148
- }
149
- }
150
- }
151
-
152
- return dtos;
153
- };
154
-
155
- export const compatChannelPublisherRemoteItemDtos = (parsedFeed: FeedObject) => {
156
- const dtos = [];
157
-
158
- if (Array.isArray(parsedFeed.podroll)) {
159
- for (const ri of parsedFeed.podroll) {
160
- if (ri.feedGuid) {
161
- dtos.push({
162
- feed_guid: ri.feedGuid,
163
- feed_url: ri.feedUrl || null,
164
- item_guid: null,
165
- title: /* PTDO: ri.title || */ null
166
- });
167
- }
168
- }
169
- }
170
-
171
- return dtos;
172
- };
173
-
174
- export const compatChannelRemoteItemDtos = (parsedFeed: FeedObject) => {
175
- const dtos = [];
176
-
177
- if (Array.isArray(parsedFeed.podcastRemoteItems)) {
178
- for (const ri of parsedFeed.podcastRemoteItems) {
179
- if (ri.feedGuid) {
180
- dtos.push({
181
- feed_guid: ri.feedGuid,
182
- feed_url: ri.feedUrl || null,
183
- item_guid: null,
184
- title: /* PTDO: ri.title || */ null
185
- });
186
- }
187
- }
188
- }
189
-
190
- return dtos;
191
- };
192
-
193
- export const compatChannelSocialInteractDtos = (parsedFeed: FeedObject) => {
194
- const dtos = [];
195
-
196
- if (parsedFeed?.podcastSocial?.length) {
197
- for (const ps of parsedFeed.podcastSocial) {
198
- dtos.push({
199
- // PTDO: fix keys mismatch between partytime and podverse
200
- protocol: ps.platform,
201
- uri: ps.url,
202
- account_id: ps.id || null,
203
- account_url: ps.name || null,
204
- priority: ps.priority || null
205
- });
206
- }
207
- }
208
-
209
- return dtos;
210
- };
211
-
212
- export const compatChannelSeasonDtos = (parsedFeed: FeedObject) => {
213
- const dtos = [];
214
-
215
- const parsedItems = parsedFeed?.items || [];
216
-
217
- const seasonsIndex: { [key: number]: { name: string | null } } = {};
218
-
219
- for (const parsedItem of parsedItems) {
220
- const seasonNumber = parsedItem?.podcastSeason?.number || parsedItem?.itunesSeason;
221
- const seasonName = parsedItem?.podcastSeason?.name || null;
222
- if (Number.isInteger(seasonNumber)) {
223
- const seasonNumberAsNumber = seasonNumber as number;
224
- seasonsIndex[seasonNumberAsNumber] = {
225
- name: seasonName
226
- };
227
- }
228
- }
229
-
230
- for (const [number, { name }] of Object.entries(seasonsIndex)) {
231
- dtos.push({
232
- number: parseInt(number),
233
- name: name || null
234
- });
235
- }
236
-
237
- return dtos;
238
- };
239
-
240
- export const compatChannelTrailerDtos = (parsedFeed: FeedObject) => {
241
- const dtos = [];
242
- if (parsedFeed?.trailers?.length) {
243
- for (const pt of parsedFeed.trailers) {
244
- dtos.push({
245
- url: pt.url,
246
- title: /* PTDO: add pt.title || */ null,
247
- pubdate: pt.pubdate,
248
- length: pt.length || null,
249
- type: pt.type || null,
250
- season: pt.season || null
251
- });
252
- }
253
- }
254
-
255
- return dtos;
256
- };
257
-
258
- export const compatChannelTxtDtos = (parsedFeed: FeedObject) => {
259
- const dtos = [];
260
- if (parsedFeed?.podcastTxt?.length) {
261
- for (const pt of parsedFeed.podcastTxt) {
262
- dtos.push({
263
- purpose: pt.purpose || null,
264
- value: pt.value
265
- });
266
- }
267
- }
268
-
269
- return dtos;
270
- };
271
-
272
- export const compatChannelValueDtos = (parsedFeed: FeedObject) => {
273
- let dtos = [];
274
- if (parsedFeed.value) {
275
- const dto = compatChannelValue(parsedFeed.value);
276
-
277
- const formattedDto = {
278
- channel_value: {
279
- type: dto.type,
280
- method: dto.method,
281
- suggested: dto.suggested || null
282
- },
283
- channel_value_recipients: dto.channel_value_recipients
284
- };
285
-
286
- dtos.push(formattedDto);
287
- }
288
- return dtos;
289
- };
@@ -1,7 +0,0 @@
1
- export const convertParsedRSSFeedToCompat = () => {
2
- return {
3
- channel: {},
4
- items: [],
5
- liveItems: []
6
- };
7
- };
@@ -1,8 +0,0 @@
1
- import { Phase1Funding } from "podcast-partytime";
2
-
3
- export const fundingCompat = (funding: Phase1Funding) => {
4
- return {
5
- value: funding.message,
6
- url: funding.url
7
- };
8
- };
@@ -1,273 +0,0 @@
1
- import type { Episode } from 'podcast-partytime';
2
- import { Phase4PodcastImage } from 'podcast-partytime/dist/parser/phase/phase-4';
3
- import { getItemItunesEpisodeTypeEnumValue } from 'podverse-orm';
4
- import { compatItemValue } from './value';
5
-
6
- export const compatItemDto = (parsedItem: Episode) => ({
7
- guid: parsedItem.guid || null,
8
- guid_enclosure_url: parsedItem.enclosure.url,
9
- pubdate: parsedItem.pubDate || null,
10
- title: parsedItem.title || null
11
- });
12
-
13
- export const compatItemAboutDto = (parsedItem: Episode) => ({
14
- duration: parsedItem.duration?.toFixed(2) || null,
15
- explicit: parsedItem.explicit || false,
16
- website_link_url: parsedItem.link || null,
17
- item_itunes_episode_type: getItemItunesEpisodeTypeEnumValue(parsedItem.itunesEpisodeType || 'full')
18
- });
19
-
20
- export const compatItemChaptersFeedDto = (parsedItem: Episode) => {
21
- if (!parsedItem.podcastChapters?.url && !parsedItem.podcastChapters?.type) return null;
22
-
23
- return {
24
- url: parsedItem.podcastChapters?.url,
25
- type: parsedItem.podcastChapters?.type
26
- };
27
- };
28
-
29
- export const compatItemChatDto = (parsedItem: Episode) => {
30
- if (!parsedItem.chat) {
31
- return null;
32
- }
33
- return {
34
- server: parsedItem.chat.server,
35
- protocol: parsedItem.chat.protocol,
36
- account_id: parsedItem.chat.accountId || null,
37
- space: parsedItem.chat.space || null
38
- };
39
- };
40
-
41
- export const compatItemDescriptionDto = (parsedItem: Episode) => {
42
- if (!parsedItem.description) {
43
- return null;
44
- }
45
- return {
46
- value: parsedItem.description
47
- };
48
- };
49
-
50
- export const compatItemEnclosureDtos = (parsedItem: Episode) => {
51
- const dtos = [];
52
-
53
- if (parsedItem.alternativeEnclosures && parsedItem.alternativeEnclosures.length > 0) {
54
- for (const alternativeEnclosure of parsedItem.alternativeEnclosures) {
55
- const item_enclosure = {
56
- type: alternativeEnclosure.type,
57
- length: alternativeEnclosure.length || null,
58
- bitrate: alternativeEnclosure.bitrate || null,
59
- height: alternativeEnclosure.height || null,
60
- language: alternativeEnclosure.lang || null,
61
- title: alternativeEnclosure.title || null,
62
- rel: alternativeEnclosure.rel || null,
63
- codecs: alternativeEnclosure.codecs || null,
64
- item_enclosure_default: false
65
- };
66
-
67
- /*
68
- PTDO: why am I getting this error when I don't use any?
69
- src/lib/compat/partytime/item.ts:50:14 - error TS4023: Exported variable
70
- 'compatItemEnclosureDtos' has or is using name 'IntegrityType' from external module
71
- "/podverse-parser/node_modules/podcast-partytime/dist/parser/phase/phase-3" but cannot be named.
72
- */
73
- const item_enclosure_integrity = (alternativeEnclosure.integrity as any) || null;
74
-
75
- const item_enclosure_sources = alternativeEnclosure.source.map(source => ({
76
- uri: source.uri,
77
- content_type: source.contentType
78
- }));
79
-
80
- const formattedDto = {
81
- item_enclosure,
82
- item_enclosure_integrity,
83
- item_enclosure_sources
84
- };
85
-
86
- dtos.push(formattedDto);
87
- }
88
- }
89
-
90
- return dtos;
91
- };
92
-
93
- export const compatItemImageDtos = (parsedItem: Episode) => {
94
- const dtos = [];
95
- if (parsedItem.itunesImage) {
96
- dtos.push({
97
- url: parsedItem.itunesImage,
98
- image_width_size: null
99
- });
100
- } else if (parsedItem.image) {
101
- dtos.push({
102
- url: parsedItem.image,
103
- image_width_size: null
104
- });
105
- }
106
-
107
- function hasWidth(image: Phase4PodcastImage['parsed']): image is { url: string; width: number } {
108
- return (image as { width: number }).width !== undefined;
109
- }
110
-
111
- if (Array.isArray(parsedItem.podcastImages)) {
112
- for (const image of parsedItem.podcastImages) {
113
- if (image.parsed.url && hasWidth(image.parsed)) {
114
- dtos.push({
115
- url: image.parsed.url,
116
- image_width_size: image.parsed.width
117
- });
118
- }
119
- }
120
- }
121
-
122
- return dtos;
123
- };
124
-
125
- export const compatItemLicenseDto = (parsedItem: Episode) => {
126
- if (!parsedItem?.license?.identifier) {
127
- return null;
128
- }
129
- return {
130
- identifier: parsedItem.license.identifier,
131
- url: parsedItem.license.url || null
132
- };
133
- };
134
-
135
- export const compatItemLocationDto = (parsedItem: Episode) => {
136
- if (!parsedItem?.podcastLocation?.geo && !parsedItem?.podcastLocation?.osm) {
137
- return null;
138
- }
139
-
140
- return {
141
- geo: parsedItem.podcastLocation.geo || null,
142
- osm: parsedItem.podcastLocation.osm || null,
143
- name: parsedItem.podcastLocation.name || null
144
- };
145
- };
146
-
147
- export const compatItemPersonDtos = (parsedItem: Episode) => {
148
- const dtos = [];
149
-
150
- if (Array.isArray(parsedItem.podcastPeople)) {
151
- for (const p of parsedItem.podcastPeople) {
152
- if (p.name) {
153
- dtos.push({
154
- name: p.name,
155
- role: p.role?.toLowerCase() || null,
156
- person_group: p.group?.toLowerCase() || 'cast',
157
- img: p.img || null,
158
- href: p.href || null
159
- });
160
- }
161
- }
162
- }
163
-
164
- return dtos;
165
- };
166
-
167
- export const compatItemSeasonDto = (parsedItem: Episode) => {
168
- if (!parsedItem.podcastSeason?.number) {
169
- return null;
170
- }
171
-
172
- return {
173
- number: parsedItem.podcastSeason.number,
174
- title: parsedItem.podcastSeason.name || null
175
- };
176
- };
177
-
178
- export const compatItemSeasonEpisodeDto = (parsedItem: Episode) => {
179
- if (!parsedItem.podcastEpisode) {
180
- return null;
181
- }
182
-
183
- return {
184
- display: parsedItem.podcastEpisode.display || null,
185
- number: parsedItem.podcastEpisode.number
186
- };
187
- };
188
-
189
- export const compatItemSocialInteractDtos = (parsedItem: Episode) => {
190
- const dtos = [];
191
-
192
- if (parsedItem?.podcastSocialInteraction?.length) {
193
- for (const ps of parsedItem.podcastSocialInteraction) {
194
- dtos.push({
195
- // PTDO: fix keys mismatch between partytime and podverse
196
- protocol: ps.platform,
197
- uri: ps.url,
198
- account_id: ps.id || null,
199
- account_url: ps.profileUrl || null,
200
- priority: ps.priority || null
201
- });
202
- }
203
- }
204
-
205
- return dtos;
206
- };
207
-
208
- export const compatItemSoundbiteDtos = (parsedItem: Episode) => {
209
- const dtos = [];
210
-
211
- if (parsedItem?.podcastSoundbites?.length) {
212
- for (const s of parsedItem.podcastSoundbites) {
213
- dtos.push({
214
- start_time: s.startTime.toFixed(2),
215
- duration: s.duration.toFixed(2),
216
- title: s.title || null
217
- });
218
- }
219
- }
220
-
221
- return dtos;
222
- };
223
-
224
- export const compatItemTranscriptDtos = (parsedItem: Episode) => {
225
- const dtos = [];
226
-
227
- if (parsedItem?.podcastTranscripts?.length) {
228
- for (const t of parsedItem.podcastTranscripts) {
229
- dtos.push({
230
- url: t.url,
231
- type: t.type,
232
- language: t.language || null,
233
- rel: t.rel || null
234
- });
235
- }
236
- }
237
-
238
- return dtos;
239
- };
240
-
241
- export const compatItemTxtDtos = (parsedItem: Episode) => {
242
- const dtos = [];
243
-
244
- if (parsedItem?.podcastTxt?.length) {
245
- for (const txt of parsedItem.podcastTxt) {
246
- dtos.push({
247
- purpose: txt.purpose || null,
248
- value: txt.value
249
- });
250
- }
251
- }
252
-
253
- return dtos;
254
- };
255
-
256
- export const compatItemValueDtos = (parsedItem: Episode) => {
257
- let dtos = [];
258
- if (parsedItem.value) {
259
- const dto = compatItemValue(parsedItem.value);
260
- const formattedDto = {
261
- item_value: {
262
- type: dto.type,
263
- method: dto.method,
264
- suggested: dto.suggested || null
265
- },
266
- item_value_recipients: dto.item_value_recipients,
267
- item_value_time_splits: dto.item_value_time_splits
268
- };
269
-
270
- dtos.push(formattedDto);
271
- }
272
- return dtos;
273
- };
@@ -1,18 +0,0 @@
1
- import { Phase4PodcastLiveItem } from "podcast-partytime/dist/parser/phase/phase-4";
2
- import { getLiveItemStatusEnumValue, LiveItemStatusEnum } from "podverse-orm";
3
-
4
- export const compatLiveItemsDtos = (parsedLiveItems: Phase4PodcastLiveItem[]) => {
5
- const dtos = [];
6
- for (const parsedLiveItem of parsedLiveItems) {
7
- dtos.push({
8
- liveItem: {
9
- live_item_status: getLiveItemStatusEnumValue(parsedLiveItem.status) ?? LiveItemStatusEnum.Pending,
10
- start_time: parsedLiveItem.start,
11
- end_time: parsedLiveItem.end || null
12
- },
13
- item: parsedLiveItem
14
- });
15
- }
16
-
17
- return dtos;
18
- };
@@ -1,64 +0,0 @@
1
- import { Phase4Value, Phase4ValueRecipient } from "podcast-partytime";
2
-
3
- export const compatChannelValue = (value: Phase4Value) => {
4
- return {
5
- type: value.type,
6
- method: value.method,
7
- suggested: parseFloat(value.suggested ?? '0') || null,
8
- channel_value_recipients: compatValueRecipients(value.recipients)
9
- };
10
- };
11
-
12
- export const compatItemValue = (value: Phase4Value) => {
13
- return {
14
- type: value.type,
15
- method: value.method,
16
- suggested: parseFloat(value.suggested ?? '0') || null,
17
- item_value_recipients: compatValueRecipients(value.recipients),
18
- item_value_time_splits: value.valueTimeSplits?.map((valueTimeSplit) => {
19
- if (valueTimeSplit.type === 'remoteItem') {
20
- return {
21
- meta: {
22
- start_time: valueTimeSplit.startTime.toFixed(2),
23
- duration: valueTimeSplit.duration.toFixed(2),
24
- remote_start_time: valueTimeSplit.remoteStartTime?.toFixed(2) || (0).toFixed(2),
25
- remote_percentage: valueTimeSplit.remotePercentage?.toFixed(2) || (100).toFixed(2),
26
- },
27
- item_value_time_splits_recipients: [],
28
- item_value_time_splits_remote_item: valueTimeSplit.remoteItem ? {
29
- feed_guid: valueTimeSplit.remoteItem.feedGuid,
30
- feed_url: valueTimeSplit.remoteItem.feedUrl || null,
31
- item_guid: valueTimeSplit.remoteItem.itemGuid || null,
32
- title: /* PTDO: ri.title || */ null
33
- } : null
34
- };
35
- } else {
36
- // else: valueTimeSplit.type === 'recipients'
37
- return {
38
- meta: {
39
- start_time: valueTimeSplit.startTime.toFixed(2),
40
- duration: valueTimeSplit.duration.toFixed(2),
41
- remote_start_time: (0).toFixed(2),
42
- remote_percentage: (100).toFixed(2),
43
- },
44
- item_value_time_splits_recipients: compatValueRecipients(valueTimeSplit.recipients),
45
- item_value_time_splits_remote_item: null
46
- };
47
- }
48
- }) || []
49
- };
50
- };
51
-
52
- const compatValueRecipients = (recipients: Phase4ValueRecipient[]) => {
53
- return recipients.map((recipient) => {
54
- return {
55
- type: recipient.type,
56
- address: recipient.address,
57
- split: recipient.split,
58
- name: recipient.name || null,
59
- custom_key: recipient.customKey || null,
60
- custom_value: recipient.customValue || null,
61
- fee: recipient.fee || false
62
- };
63
- }) || [];
64
- };
@@ -1,16 +0,0 @@
1
- interface Service<T, P> {
2
- updateMany(parentEntity: P, dtos: Partial<T>[]): Promise<T[]>;
3
- deleteAll(parentEntity: P): Promise<void>;
4
- }
5
-
6
- export const handleParsedManyData = async<T, P> (
7
- parentEntity: P,
8
- service: Service<T, P>,
9
- dtos: Partial<T>[]
10
- ) => {
11
- if (dtos.length > 0) {
12
- await service.updateMany(parentEntity, dtos);
13
- } else {
14
- await service.deleteAll(parentEntity);
15
- }
16
- };
@@ -1,17 +0,0 @@
1
- interface Service<T, P> {
2
- update(parentEntity: P, dto: Partial<T>): Promise<T>;
3
- _delete?(parentEntity: P): Promise<void>;
4
- }
5
-
6
- export const handleParsedOneData = async <T, P>(
7
- parentEntity: P,
8
- service: Service<T, P>,
9
- dto: Partial<T> | null
10
- ) => {
11
- if (dto) {
12
- await service.update(parentEntity, dto);
13
- } else if (service._delete) {
14
- await service._delete(parentEntity);
15
- }
16
- };
17
-