@omerlo/omerlo-webkit 0.0.24 → 0.0.26
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
CHANGED
|
@@ -26,6 +26,7 @@ export declare const useReader: (f: typeof fetch) => {
|
|
|
26
26
|
listMenus: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").MenuSummary[]>>;
|
|
27
27
|
getMedia: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Media>>;
|
|
28
28
|
getMediaSection: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").MediaSection>>;
|
|
29
|
+
getMediaBlock: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").MediaBlock>>;
|
|
29
30
|
getContent: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Content>>;
|
|
30
31
|
listContents: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").ContentSummary[]>>;
|
|
31
32
|
listCategories: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Category[]>>;
|
|
@@ -2,12 +2,15 @@ import type { ApiAssocs } from '../utils/api';
|
|
|
2
2
|
import type { ApiData } from '../utils/api';
|
|
3
3
|
import type { LocalesMetadata } from '../utils/response';
|
|
4
4
|
import { type Visual } from './visuals';
|
|
5
|
+
import type { ContentSummary } from './contents';
|
|
5
6
|
export declare const mediaFetchers: (f: typeof fetch) => {
|
|
6
7
|
getMedia: () => Promise<import("../utils/api").ApiResponse<Media>>;
|
|
7
8
|
getMediaSection: (id: string) => Promise<import("../utils/api").ApiResponse<MediaSection>>;
|
|
9
|
+
getMediaBlock: (id: string) => Promise<import("../utils/api").ApiResponse<MediaBlock>>;
|
|
8
10
|
};
|
|
9
11
|
export declare function getMedia(f: typeof fetch): () => Promise<import("../utils/api").ApiResponse<Media>>;
|
|
10
12
|
export declare function getMediaSection(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<MediaSection>>;
|
|
13
|
+
export declare function getMediaBlock(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<MediaBlock>>;
|
|
11
14
|
export interface Media {
|
|
12
15
|
id: string;
|
|
13
16
|
displayName: string | null;
|
|
@@ -17,7 +20,7 @@ export interface Media {
|
|
|
17
20
|
name: string;
|
|
18
21
|
key: string;
|
|
19
22
|
contact: MediaContact | null;
|
|
20
|
-
sections:
|
|
23
|
+
sections: MediaSectionHierarchy[];
|
|
21
24
|
metadata: Record<string, string>;
|
|
22
25
|
updatedAt: Date;
|
|
23
26
|
}
|
|
@@ -45,32 +48,43 @@ export interface MediaSectionSummary {
|
|
|
45
48
|
color: string;
|
|
46
49
|
updatedAt: Date;
|
|
47
50
|
}
|
|
51
|
+
export interface MediaSectionHierarchy extends MediaSectionSummary {
|
|
52
|
+
sections: MediaSectionSummary[];
|
|
53
|
+
}
|
|
48
54
|
export interface MediaSection extends MediaSectionSummary {
|
|
49
55
|
description: string | null;
|
|
50
|
-
parentId: string | null;
|
|
51
56
|
advertisingKey: string | null;
|
|
57
|
+
sections: MediaSectionSummary[];
|
|
52
58
|
blocks: MediaBlockSummary[];
|
|
53
59
|
}
|
|
54
60
|
export interface MediaBlockConfigurationSummary {
|
|
55
|
-
|
|
56
|
-
blockType: 'content' | 'distribution' | 'html' | 'media' | 'most_popular' | 'section';
|
|
57
|
-
name: string;
|
|
61
|
+
type: 'content' | 'distribution' | 'html' | 'media' | 'most_popular' | 'section';
|
|
58
62
|
key: string;
|
|
59
63
|
}
|
|
60
64
|
export interface MediaBlockSummary {
|
|
61
65
|
id: string;
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
}
|
|
67
|
+
export interface MediaBlock extends MediaBlockSummary {
|
|
68
|
+
name: string | null;
|
|
64
69
|
description: string | null;
|
|
65
|
-
html: string | null;
|
|
66
70
|
visual: Visual | null;
|
|
71
|
+
html: string | null;
|
|
72
|
+
metadata: {
|
|
73
|
+
[key: string]: string;
|
|
74
|
+
};
|
|
67
75
|
meta: {
|
|
68
76
|
locales: LocalesMetadata;
|
|
69
77
|
};
|
|
70
78
|
textColor: string | null;
|
|
71
79
|
backgroundColor: string | null;
|
|
72
|
-
|
|
80
|
+
backgroundSvg: string | null;
|
|
81
|
+
configuration: MediaBlockConfigurationSummary;
|
|
82
|
+
entries: MediaBlockEntry[];
|
|
73
83
|
updatedAt: Date;
|
|
74
84
|
}
|
|
85
|
+
export interface MediaBlockEntry {
|
|
86
|
+
contents: ContentSummary[];
|
|
87
|
+
section: MediaSectionSummary | null;
|
|
88
|
+
}
|
|
75
89
|
export declare function parseMedia(data: ApiData, assocs: ApiAssocs): Media;
|
|
76
90
|
export declare function parseMediaBlockConfiguration(data: ApiData): MediaBlockConfigurationSummary;
|
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requestPublisher } from '../utils/request';
|
|
2
2
|
import { parseVisual } from './visuals';
|
|
3
3
|
import { buildMeta } from '../utils/parseHelpers';
|
|
4
|
-
import {
|
|
4
|
+
import { getAssocs } from '../utils/assocs';
|
|
5
5
|
export const mediaFetchers = (f) => {
|
|
6
6
|
return {
|
|
7
7
|
getMedia: getMedia(f),
|
|
8
|
-
getMediaSection: getMediaSection(f)
|
|
8
|
+
getMediaSection: getMediaSection(f),
|
|
9
|
+
getMediaBlock: getMediaBlock(f)
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
export function getMedia(f) {
|
|
12
13
|
return async () => {
|
|
13
14
|
const opts = { parser: parseMedia };
|
|
15
|
+
// NOTE the `/` is REALLY important
|
|
14
16
|
return requestPublisher(f, 'media/', opts);
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
export function getMediaSection(f) {
|
|
18
20
|
return async (id) => {
|
|
19
21
|
const opts = { parser: parseSection };
|
|
20
|
-
return
|
|
22
|
+
return requestPublisher(f, `/sections/${id}`, opts);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function getMediaBlock(f) {
|
|
26
|
+
return async (id) => {
|
|
27
|
+
const opts = { parser: parseBlock };
|
|
28
|
+
return requestPublisher(f, `/blocks/${id}`, opts);
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
export function parseMedia(data, assocs) {
|
|
@@ -30,7 +38,7 @@ export function parseMedia(data, assocs) {
|
|
|
30
38
|
key: data.key,
|
|
31
39
|
contact,
|
|
32
40
|
metadata: data.metadata,
|
|
33
|
-
sections: data.sections.map((section, assocs) =>
|
|
41
|
+
sections: data.sections.map((section, assocs) => parseSectionHierarchy(section, assocs)),
|
|
34
42
|
updatedAt: data.updated_at
|
|
35
43
|
};
|
|
36
44
|
}
|
|
@@ -50,7 +58,6 @@ function parseMediaContact(data, _assocs) {
|
|
|
50
58
|
function parseSection(data, assocs) {
|
|
51
59
|
return {
|
|
52
60
|
id: data.id,
|
|
53
|
-
parentId: data.parent_id,
|
|
54
61
|
name: data.localized.name,
|
|
55
62
|
description: data.localized.description,
|
|
56
63
|
slug: data.localized.slug,
|
|
@@ -58,41 +65,62 @@ function parseSection(data, assocs) {
|
|
|
58
65
|
meta: buildMeta(data.localized.locale),
|
|
59
66
|
color: data.color,
|
|
60
67
|
advertisingKey: data.advertising_key,
|
|
68
|
+
sections: data.sections.map((section) => parseSectionSummary(section, assocs)),
|
|
61
69
|
blocks: data.blocks.map((block, assocs) => parseBlockSummary(block, assocs)),
|
|
62
70
|
updatedAt: data.updated_at
|
|
63
71
|
};
|
|
64
72
|
}
|
|
65
|
-
function parseSectionSummary(
|
|
73
|
+
function parseSectionSummary(data, assocs) {
|
|
74
|
+
return {
|
|
75
|
+
id: data.id,
|
|
76
|
+
color: data.color,
|
|
77
|
+
meta: buildMeta(data.localized.locale),
|
|
78
|
+
name: data.localized.name,
|
|
79
|
+
slug: data.localized.slug,
|
|
80
|
+
visual: parseVisual(data.visual, assocs),
|
|
81
|
+
updatedAt: data.updated_at
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function parseSectionHierarchy(data, assocs) {
|
|
66
85
|
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
meta: buildMeta(section.localized.locale),
|
|
70
|
-
name: section.localized.name,
|
|
71
|
-
slug: section.localized.slug,
|
|
72
|
-
visual: parseVisual(section.visual, assocs),
|
|
73
|
-
updatedAt: section.updated_at
|
|
86
|
+
...parseSectionSummary(data, assocs),
|
|
87
|
+
sections: data.sections.map((section) => parseSectionHierarchy(section, assocs))
|
|
74
88
|
};
|
|
75
89
|
}
|
|
76
90
|
export function parseMediaBlockConfiguration(data) {
|
|
77
91
|
return {
|
|
78
|
-
|
|
79
|
-
blockType: data.block_type,
|
|
80
|
-
name: data.name,
|
|
92
|
+
type: data.block_type,
|
|
81
93
|
key: data.key
|
|
82
94
|
};
|
|
83
95
|
}
|
|
84
|
-
function parseBlockSummary(data,
|
|
96
|
+
function parseBlockSummary(data, _assocs) {
|
|
85
97
|
return {
|
|
86
|
-
id: data.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
id: data.id
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function parseBlock(data, assocs) {
|
|
102
|
+
return {
|
|
103
|
+
...parseBlockSummary(data, assocs),
|
|
104
|
+
name: data.localized?.name,
|
|
105
|
+
description: data.localized?.description,
|
|
106
|
+
visual: parseVisual(data.visual, assocs),
|
|
107
|
+
html: data.localized?.html,
|
|
108
|
+
metadata: data.metadata,
|
|
109
|
+
meta: buildMeta(data.localized?.locale),
|
|
110
|
+
textColor: data.color,
|
|
111
|
+
backgroundColor: data.background_color,
|
|
112
|
+
backgroundSvg: data.background_svg,
|
|
113
|
+
configuration: {
|
|
114
|
+
type: data.block_type,
|
|
115
|
+
key: data.configuration_key
|
|
116
|
+
},
|
|
117
|
+
entries: data.entries.map((entry) => parseBlockEntry(entry, assocs)),
|
|
96
118
|
updatedAt: data.updatedAt
|
|
97
119
|
};
|
|
98
120
|
}
|
|
121
|
+
function parseBlockEntry(data, assocs) {
|
|
122
|
+
return {
|
|
123
|
+
contents: getAssocs(assocs, 'contents', data.content_ids),
|
|
124
|
+
section: data.section ? parseSectionSummary(data.section, assocs) : null
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -26,6 +26,7 @@ export declare const fetchers: (f: typeof fetch) => {
|
|
|
26
26
|
listMenus: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/menu").MenuSummary[]>>;
|
|
27
27
|
getMedia: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/media").Media>>;
|
|
28
28
|
getMediaSection: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/media").MediaSection>>;
|
|
29
|
+
getMediaBlock: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/media").MediaBlock>>;
|
|
29
30
|
getContent: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").Content>>;
|
|
30
31
|
listContents: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").ContentSummary[]>>;
|
|
31
32
|
listCategories: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/categories").Category[]>>;
|