@omerlo/omerlo-webkit 0.0.37 → 0.0.39
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/omerlo/reader/endpoints/distributions.d.ts +15 -2
- package/dist/omerlo/reader/endpoints/distributions.js +28 -5
- package/dist/omerlo/reader/endpoints/magazines.js +36 -16
- package/dist/omerlo/reader/endpoints/media.d.ts +3 -0
- package/dist/omerlo/reader/endpoints/media.js +6 -1
- package/dist/omerlo/reader/endpoints/profiles.d.ts +4 -0
- package/dist/omerlo/reader/endpoints/profiles.js +12 -0
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
3
|
+
import { type IssueSummary } from './magazines';
|
|
4
|
+
import { type Visual } from './visuals';
|
|
3
5
|
export declare const distributionFetchers: (f: typeof fetch) => {
|
|
4
6
|
listReleases: (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
|
|
5
7
|
};
|
|
@@ -9,6 +11,17 @@ export interface Release {
|
|
|
9
11
|
issue: IssueSummary;
|
|
10
12
|
startsAt: Date;
|
|
11
13
|
endsAt: Date | null;
|
|
12
|
-
updatedAt: Date;
|
|
13
14
|
}
|
|
14
15
|
export declare function parseRelease(data: ApiData, assocs: ApiAssocs): Release;
|
|
16
|
+
export interface Distribution {
|
|
17
|
+
id: string;
|
|
18
|
+
meta: {
|
|
19
|
+
locales: LocalesMetadata;
|
|
20
|
+
};
|
|
21
|
+
name: string;
|
|
22
|
+
visual: Visual | null;
|
|
23
|
+
metadata: {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function parseDistribution(data: ApiData, assocs: ApiAssocs): Distribution;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { parseMany } from '../utils/api';
|
|
2
2
|
import { getAssoc } from '../utils/assocs';
|
|
3
|
-
import { parseDate } from '../utils/parseHelpers';
|
|
3
|
+
import { buildMeta, parseDate } from '../utils/parseHelpers';
|
|
4
4
|
import { request } from '../utils/request';
|
|
5
|
+
import { parseIssueSummary } from './magazines';
|
|
6
|
+
import { parseVisual } from './visuals';
|
|
5
7
|
export const distributionFetchers = (f) => {
|
|
6
8
|
return {
|
|
7
9
|
listReleases: releasesFetcher(f)
|
|
@@ -14,12 +16,33 @@ export function releasesFetcher(f) {
|
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
export function parseRelease(data, assocs) {
|
|
19
|
+
let issue;
|
|
20
|
+
// NOTE for retro compatibility
|
|
21
|
+
if (data.issue) {
|
|
22
|
+
issue = parseIssueSummary(data.issue, assocs);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
issue = getAssoc(assocs, 'issues', data.issue_id);
|
|
26
|
+
}
|
|
17
27
|
return {
|
|
18
28
|
id: data.id,
|
|
19
|
-
issue:
|
|
20
|
-
// isPublished: data.is_published,
|
|
29
|
+
issue: issue,
|
|
21
30
|
startsAt: new Date(data.starts_at),
|
|
22
|
-
endsAt: parseDate(data.ends_at)
|
|
23
|
-
updatedAt: new Date(data.updated_at)
|
|
31
|
+
endsAt: parseDate(data.ends_at)
|
|
24
32
|
};
|
|
25
33
|
}
|
|
34
|
+
export function parseDistribution(data, assocs) {
|
|
35
|
+
// NOTE for retro compatibility
|
|
36
|
+
if (data.localized) {
|
|
37
|
+
return {
|
|
38
|
+
id: data.id,
|
|
39
|
+
meta: buildMeta(data.localized.locale),
|
|
40
|
+
metadata: data.metadata,
|
|
41
|
+
name: data.localized.name,
|
|
42
|
+
visual: parseVisual(data.visual, assocs)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw "missing parser for distribution for reader's api";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -4,6 +4,7 @@ import { parseMany } from '../utils/api';
|
|
|
4
4
|
import { getAssoc } from '../utils/assocs';
|
|
5
5
|
import { request } from '../utils/request';
|
|
6
6
|
import { parseContentSummary } from './contents';
|
|
7
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
7
8
|
export const magazineFetchers = (f) => {
|
|
8
9
|
return {
|
|
9
10
|
getIssue: issueFetcher(f),
|
|
@@ -40,22 +41,41 @@ export function sectionContentsFetcher(f) {
|
|
|
40
41
|
* Parsers
|
|
41
42
|
******************************************************************************/
|
|
42
43
|
export function parseIssueSummary(data, assocs) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
// NOTE retrocompability
|
|
45
|
+
if (data.localized) {
|
|
46
|
+
return {
|
|
47
|
+
id: data.id,
|
|
48
|
+
issueType: getAssoc(assocs, 'issue_types', data.issue_type_id),
|
|
49
|
+
kind: data.issue_type,
|
|
50
|
+
name: data.localized.name,
|
|
51
|
+
descriptionText: data.localized.description_text,
|
|
52
|
+
descriptionHtml: data.localized.description_html,
|
|
53
|
+
color: data.color,
|
|
54
|
+
pdfUrl: data.pdf_url,
|
|
55
|
+
visual: parseVisual(data.localized.visual, assocs),
|
|
56
|
+
metadata: data.metadata,
|
|
57
|
+
meta: buildMeta(data.localized.locale),
|
|
58
|
+
updatedAt: new Date(data.updated_at)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return {
|
|
63
|
+
id: data.id,
|
|
64
|
+
issueType: getAssoc(assocs, 'issue_types', data.issue_type_id),
|
|
65
|
+
kind: data.kind,
|
|
66
|
+
name: data.name,
|
|
67
|
+
descriptionText: data.description_text,
|
|
68
|
+
descriptionHtml: data.description_html,
|
|
69
|
+
color: data.color,
|
|
70
|
+
pdfUrl: data.pdf_url,
|
|
71
|
+
visual: parseVisual(data.visual, assocs),
|
|
72
|
+
metadata: data.metadata,
|
|
73
|
+
meta: {
|
|
74
|
+
locales: parseLocalesMetadata(data.meta)
|
|
75
|
+
},
|
|
76
|
+
updatedAt: new Date(data.updated_at)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
59
79
|
}
|
|
60
80
|
export function parseIssue(data, assocs) {
|
|
61
81
|
return {
|
|
@@ -3,6 +3,7 @@ import type { ApiData } from '../utils/api';
|
|
|
3
3
|
import type { LocalesMetadata } from '../utils/response';
|
|
4
4
|
import { type Visual } from './visuals';
|
|
5
5
|
import { type ContentSummary } from './contents';
|
|
6
|
+
import { type Distribution, type Release } from './distributions';
|
|
6
7
|
export declare const mediaFetchers: (f: typeof fetch) => {
|
|
7
8
|
getMedia: () => Promise<import("../utils/api").ApiResponse<Media>>;
|
|
8
9
|
getMediaSection: (id: string) => Promise<import("../utils/api").ApiResponse<MediaSection>>;
|
|
@@ -87,6 +88,8 @@ export interface MediaBlock extends MediaBlockSummary {
|
|
|
87
88
|
export interface MediaBlockEntry {
|
|
88
89
|
contents: ContentSummary[];
|
|
89
90
|
section: MediaSectionSummary | null;
|
|
91
|
+
distribution: Distribution | null;
|
|
92
|
+
releases: Release[] | null;
|
|
90
93
|
}
|
|
91
94
|
export declare function parseMedia(data: ApiData, assocs: ApiAssocs): Media;
|
|
92
95
|
export declare function parseMediaBlockConfiguration(data: ApiData): MediaBlockConfigurationSummary;
|
|
@@ -4,6 +4,7 @@ import { parseVisual } from './visuals';
|
|
|
4
4
|
import { buildMeta } from '../utils/parseHelpers';
|
|
5
5
|
import { parseContentSummary } from './contents';
|
|
6
6
|
import { getAssocs } from '../utils/assocs';
|
|
7
|
+
import { parseDistribution, parseRelease } from './distributions';
|
|
7
8
|
export const mediaFetchers = (f) => {
|
|
8
9
|
return {
|
|
9
10
|
getMedia: getMedia(f),
|
|
@@ -130,6 +131,10 @@ function parseBlock(data, assocs) {
|
|
|
130
131
|
function parseBlockEntry(data, assocs) {
|
|
131
132
|
return {
|
|
132
133
|
contents: getAssocs(assocs, 'contents', data.content_ids),
|
|
133
|
-
section: data.section ? parseSectionSummary(data.section, assocs) : null
|
|
134
|
+
section: data.section ? parseSectionSummary(data.section, assocs) : null,
|
|
135
|
+
releases: data.releases
|
|
136
|
+
? data.releases.map((release) => parseRelease(release, assocs))
|
|
137
|
+
: [],
|
|
138
|
+
distribution: data.distribution ? parseDistribution(data.distribution, assocs) : null
|
|
134
139
|
};
|
|
135
140
|
}
|
|
@@ -68,3 +68,7 @@ export declare function parseProfileAddress(data: ApiData, _assocs: ApiAssocs):
|
|
|
68
68
|
export declare function parseProfileContact(data: ApiData, _assocs: ApiAssocs): ProfileContact;
|
|
69
69
|
export declare function parseProfileDescriptionBlock(data: ApiData, assocs: ApiAssocs): ProfileDescriptionBlock;
|
|
70
70
|
export declare function parseProfileDescription(data: ApiData, assocs: ApiAssocs): ProfileDescription;
|
|
71
|
+
export declare function isEvent(profile: ProfileSummary): profile is EventSummary;
|
|
72
|
+
export declare function isOrganization(profile: ProfileSummary): profile is OrganizationSummary;
|
|
73
|
+
export declare function isPerson(profile: ProfileSummary): profile is PersonSummary;
|
|
74
|
+
export declare function isProject(profile: ProfileSummary): profile is ProjectSummary;
|
|
@@ -95,3 +95,15 @@ export function parseProfileDescription(data, assocs) {
|
|
|
95
95
|
blocks
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
+
export function isEvent(profile) {
|
|
99
|
+
return profile.kind === 'event';
|
|
100
|
+
}
|
|
101
|
+
export function isOrganization(profile) {
|
|
102
|
+
return profile.kind === 'organization';
|
|
103
|
+
}
|
|
104
|
+
export function isPerson(profile) {
|
|
105
|
+
return profile.kind === 'person';
|
|
106
|
+
}
|
|
107
|
+
export function isProject(profile) {
|
|
108
|
+
return profile.kind === 'project';
|
|
109
|
+
}
|