@omerlo/omerlo-webkit 0.0.14 → 0.0.16
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/index.d.ts +1 -0
- package/dist/omerlo/reader/endpoints/contents.d.ts +2 -2
- package/dist/omerlo/reader/endpoints/contents.js +3 -3
- package/dist/omerlo/reader/endpoints/distributions.d.ts +14 -0
- package/dist/omerlo/reader/endpoints/distributions.js +25 -0
- package/dist/omerlo/reader/fetchers.d.ts +1 -0
- package/dist/omerlo/reader/fetchers.js +5 -1
- package/package.json +1 -1
package/dist/omerlo/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const useReader: (f: typeof fetch) => {
|
|
|
5
5
|
unsubscribeFromTopic: (params: import("./reader").SubscriptionParams) => Promise<import("./reader/utils/api").ApiResponse<unknown>>;
|
|
6
6
|
};
|
|
7
7
|
magazines: {
|
|
8
|
+
listReleases: (distributionId: string, params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader/endpoints/distributions").Release[]>>;
|
|
8
9
|
getIssue: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Issue>>;
|
|
9
10
|
getBlocks: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").IssueBlock[]>>;
|
|
10
11
|
searchContents: (issueId: string, q: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").SectionContent[]>>;
|
|
@@ -73,7 +73,7 @@ export type ContentBlockQuote = {
|
|
|
73
73
|
};
|
|
74
74
|
export type ContentBlockRelatedContents = {
|
|
75
75
|
id: string;
|
|
76
|
-
kind: '
|
|
76
|
+
kind: 'related_contents';
|
|
77
77
|
contents: ContentSummary[];
|
|
78
78
|
visual: Visual | null;
|
|
79
79
|
template: ContentBlockTemplate | null;
|
|
@@ -115,7 +115,7 @@ export type ContentBlockVideo = {
|
|
|
115
115
|
template: ContentBlockTemplate | null;
|
|
116
116
|
};
|
|
117
117
|
export type ContentBlock = ContentBlockRichtext | ContentBlockData | ContentBlockHTML | ContentBlockQuote | ContentBlockRelatedContents | ContentBlockQuestion | ContentBlockImage | ContentBlockSlideshow | ContentBlockVideo;
|
|
118
|
-
export type ContentBlockType = 'richtext' | 'data' | 'html' | 'quote' | '
|
|
118
|
+
export type ContentBlockType = 'richtext' | 'data' | 'html' | 'quote' | 'related_contents' | 'question' | 'image' | 'slideshow' | 'video';
|
|
119
119
|
export declare function getContent(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<Content>>;
|
|
120
120
|
export declare function listContents(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
|
|
121
121
|
export declare function parseContentSummary(data: ApiData, assocs: ApiAssocs): ContentSummary;
|
|
@@ -49,7 +49,7 @@ export function parseContentSummary(data, assocs) {
|
|
|
49
49
|
leadText: data.localized.lead_text,
|
|
50
50
|
subtitleHtml: data.localized.subtitle_html,
|
|
51
51
|
subtitleText: data.localized.subtitle_text,
|
|
52
|
-
visual: parseVisual(data.visual, assocs),
|
|
52
|
+
visual: parseVisual(data.localized.visual, assocs),
|
|
53
53
|
meta: buildMeta(data.localized.locale),
|
|
54
54
|
metadata: {},
|
|
55
55
|
authors: getAssocs(assocs, 'profiles', data.localized.author_ids)
|
|
@@ -101,7 +101,7 @@ const ContentBlockParser = {
|
|
|
101
101
|
data: parseContentBlockData,
|
|
102
102
|
html: parseContentBlockHTML,
|
|
103
103
|
quote: parseContentBlockQuote,
|
|
104
|
-
|
|
104
|
+
related_contents: parseContentBlockRelatedContents,
|
|
105
105
|
question: parseContentBlockQuestion,
|
|
106
106
|
image: parseContentBlockImage,
|
|
107
107
|
slideshow: parseContentBlockSlideshow,
|
|
@@ -117,7 +117,7 @@ function getBlockTemplate(data, assocs) {
|
|
|
117
117
|
: null;
|
|
118
118
|
}
|
|
119
119
|
function getBlockContents(data, assocs) {
|
|
120
|
-
return data.
|
|
120
|
+
return data.content_ids ? getAssocs(assocs, 'contents', data.content_ids) : [];
|
|
121
121
|
}
|
|
122
122
|
function parseContentBlockRichtext(data, assocs) {
|
|
123
123
|
return {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
|
|
2
|
+
import type { Issue } from './magazines';
|
|
3
|
+
export declare const distributionFetchers: (f: typeof fetch) => {
|
|
4
|
+
listReleases: (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
|
|
5
|
+
};
|
|
6
|
+
export declare function releasesFetcher(f: typeof fetch): (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
|
|
7
|
+
export interface Release {
|
|
8
|
+
id: string;
|
|
9
|
+
issue: Issue;
|
|
10
|
+
startsAt: Date;
|
|
11
|
+
endsAt: Date | null;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseRelease(data: ApiData, assocs: ApiAssocs): Release;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseMany } from '../utils/api';
|
|
2
|
+
import { getAssoc } from '../utils/assocs';
|
|
3
|
+
import { parseDate } from '../utils/parseHelpers';
|
|
4
|
+
import { request } from '../utils/request';
|
|
5
|
+
export const distributionFetchers = (f) => {
|
|
6
|
+
return {
|
|
7
|
+
listReleases: releasesFetcher(f)
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export function releasesFetcher(f) {
|
|
11
|
+
return async (distributionId, params) => {
|
|
12
|
+
const opts = { parser: parseMany(parseRelease), queryParams: params };
|
|
13
|
+
return request(f, `/distributions/${distributionId}/releases`, opts);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function parseRelease(data, assocs) {
|
|
17
|
+
return {
|
|
18
|
+
id: data.id,
|
|
19
|
+
issue: getAssoc(assocs, 'issues', data.issue_id),
|
|
20
|
+
// isPublished: data.is_published,
|
|
21
|
+
startsAt: new Date(data.starts_at),
|
|
22
|
+
endsAt: parseDate(data.ends_at),
|
|
23
|
+
updatedAt: new Date(data.updated_at)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -5,6 +5,7 @@ export declare const fetchers: (f: typeof fetch) => {
|
|
|
5
5
|
unsubscribeFromTopic: (params: import("./endpoints/notification").SubscriptionParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
6
6
|
};
|
|
7
7
|
magazines: {
|
|
8
|
+
listReleases: (distributionId: string, params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/distributions").Release[]>>;
|
|
8
9
|
getIssue: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").Issue>>;
|
|
9
10
|
getBlocks: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").IssueBlock[]>>;
|
|
10
11
|
searchContents: (issueId: string, q: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").SectionContent[]>>;
|
|
@@ -8,6 +8,7 @@ import { mediaFetchers } from './endpoints/media';
|
|
|
8
8
|
import { organizationFetchers } from './endpoints/organizations';
|
|
9
9
|
import { menuFetchers } from './endpoints/menu';
|
|
10
10
|
import { magazineFetchers } from './endpoints/magazines';
|
|
11
|
+
import { distributionFetchers } from './endpoints/distributions';
|
|
11
12
|
export const fetchers = (f) => {
|
|
12
13
|
return {
|
|
13
14
|
...accountsFetchers(f),
|
|
@@ -19,6 +20,9 @@ export const fetchers = (f) => {
|
|
|
19
20
|
...organizationFetchers(f),
|
|
20
21
|
...menuFetchers(f),
|
|
21
22
|
notifications: notificationFetchers(f),
|
|
22
|
-
magazines:
|
|
23
|
+
magazines: {
|
|
24
|
+
...magazineFetchers(f),
|
|
25
|
+
...distributionFetchers(f)
|
|
26
|
+
}
|
|
23
27
|
};
|
|
24
28
|
};
|