@omerlo/omerlo-webkit 0.0.5 → 0.0.7
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/README.md +0 -2
- package/dist/omerlo/index.d.ts +32 -6
- package/dist/omerlo/reader/endpoints/categories.d.ts +1 -1
- package/dist/omerlo/reader/endpoints/categories.js +16 -13
- package/dist/omerlo/reader/endpoints/content-templates.d.ts +9 -2
- package/dist/omerlo/reader/endpoints/content-templates.js +34 -1
- package/dist/omerlo/reader/endpoints/contents.d.ts +98 -27
- package/dist/omerlo/reader/endpoints/contents.js +187 -2
- package/dist/omerlo/reader/endpoints/events.d.ts +32 -0
- package/dist/omerlo/reader/endpoints/events.js +45 -0
- package/dist/omerlo/reader/endpoints/magazines.d.ts +104 -0
- package/dist/omerlo/reader/endpoints/magazines.js +135 -0
- package/dist/omerlo/reader/endpoints/media.d.ts +65 -0
- package/dist/omerlo/reader/endpoints/media.js +133 -0
- package/dist/omerlo/reader/endpoints/menu.d.ts +31 -0
- package/dist/omerlo/reader/endpoints/menu.js +49 -0
- package/dist/omerlo/reader/endpoints/notification.js +1 -1
- package/dist/omerlo/reader/endpoints/organizations.d.ts +40 -0
- package/dist/omerlo/reader/endpoints/organizations.js +72 -0
- package/dist/omerlo/reader/endpoints/person.d.ts +30 -0
- package/dist/omerlo/reader/endpoints/person.js +39 -0
- package/dist/omerlo/reader/endpoints/profileType.d.ts +27 -0
- package/dist/omerlo/reader/endpoints/profileType.js +28 -0
- package/dist/omerlo/reader/endpoints/profiles.d.ts +70 -0
- package/dist/omerlo/reader/endpoints/profiles.js +97 -0
- package/dist/omerlo/reader/endpoints/projects.d.ts +28 -0
- package/dist/omerlo/reader/endpoints/projects.js +37 -0
- package/dist/omerlo/reader/endpoints/visuals.d.ts +28 -10
- package/dist/omerlo/reader/endpoints/visuals.js +44 -1
- package/dist/omerlo/reader/endpoints/webpage.d.ts +20 -0
- package/dist/omerlo/reader/endpoints/webpage.js +21 -0
- package/dist/omerlo/reader/fetchers.d.ts +26 -0
- package/dist/omerlo/reader/fetchers.js +11 -1
- package/dist/omerlo/reader/index.d.ts +18 -1
- package/dist/omerlo/reader/index.js +18 -0
- package/dist/omerlo/reader/server/email.d.ts +4 -4
- package/dist/omerlo/reader/server/email.js +5 -5
- package/dist/omerlo/reader/server/hooks.js +17 -3
- package/dist/omerlo/reader/utils/api.d.ts +1 -1
- package/dist/omerlo/reader/utils/api.js +4 -3
- package/dist/omerlo/reader/utils/assocs.d.ts +5 -4
- package/dist/omerlo/reader/utils/assocs.js +23 -0
- package/dist/omerlo/reader/utils/parseHelpers.d.ts +7 -0
- package/dist/omerlo/reader/utils/parseHelpers.js +22 -0
- package/eslint.config.js +10 -1
- package/package.json +2 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {} from '../utils/api';
|
|
2
|
+
import { parseProfileAddress, parseProfileContact, parseProfileDescription } from './profiles';
|
|
3
|
+
import { getAssoc, getAssocs } from '../utils/assocs';
|
|
4
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
5
|
+
export function parsePersonSummary(data, assocs) {
|
|
6
|
+
return {
|
|
7
|
+
id: data.id,
|
|
8
|
+
profileType: getAssoc(assocs, 'profile_types', data.profile_type_id),
|
|
9
|
+
kind: 'person',
|
|
10
|
+
firstName: data.first_name,
|
|
11
|
+
lastName: data.last_name,
|
|
12
|
+
otherName: data.other_name,
|
|
13
|
+
pronoun: data.pronoun,
|
|
14
|
+
profileImageURL: data.avatar_image_url,
|
|
15
|
+
coverImageURL: data.cover_image_url,
|
|
16
|
+
meta: buildMeta(data.localized?.locale),
|
|
17
|
+
summaryHtml: data.localized?.summary_html,
|
|
18
|
+
summaryText: data.localized?.summary_text,
|
|
19
|
+
updatedAt: new Date(data.updated_at)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function parsePerson(data, assocs) {
|
|
23
|
+
const address = data.localized_address
|
|
24
|
+
? parseProfileAddress(data.localized_address, assocs)
|
|
25
|
+
: null;
|
|
26
|
+
const contact = data.localized_contact
|
|
27
|
+
? parseProfileContact(data.localized_contact, assocs)
|
|
28
|
+
: null;
|
|
29
|
+
const description = data.localized_description
|
|
30
|
+
? parseProfileDescription(data.localized_description, assocs)
|
|
31
|
+
: null;
|
|
32
|
+
return {
|
|
33
|
+
...parsePersonSummary(data, assocs),
|
|
34
|
+
categories: getAssocs(assocs, 'categories', data.category_ids),
|
|
35
|
+
address,
|
|
36
|
+
contact,
|
|
37
|
+
description
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ApiAssocs, type ApiData } from '../utils/api';
|
|
2
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
3
|
+
export interface ProfileTypeSummary {
|
|
4
|
+
id: string;
|
|
5
|
+
kind: 'person' | 'project' | 'organization' | 'event';
|
|
6
|
+
key: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
meta: {
|
|
9
|
+
locales: LocalesMetadata;
|
|
10
|
+
};
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseProfileTypeSummary(data: ApiData, _assocs: ApiAssocs): ProfileTypeSummary;
|
|
14
|
+
export interface ProfileType extends ProfileTypeSummary {
|
|
15
|
+
hasPhone: boolean;
|
|
16
|
+
hasEmail: boolean;
|
|
17
|
+
hasLinkedIn: boolean;
|
|
18
|
+
hasWebsite: boolean;
|
|
19
|
+
hasTwitter: boolean;
|
|
20
|
+
hasFacebook: boolean;
|
|
21
|
+
hasBlueSky: boolean;
|
|
22
|
+
hasCountry: boolean;
|
|
23
|
+
hasState: boolean;
|
|
24
|
+
hasCity: boolean;
|
|
25
|
+
hasStreet: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function parseProfileType(data: ApiData, assocs: ApiAssocs): ProfileType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {} from '../utils/api';
|
|
2
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
3
|
+
export function parseProfileTypeSummary(data, _assocs) {
|
|
4
|
+
return {
|
|
5
|
+
id: data.id,
|
|
6
|
+
kind: data.kind,
|
|
7
|
+
key: data.key,
|
|
8
|
+
name: data.localized.name,
|
|
9
|
+
meta: buildMeta(data.localized.locale),
|
|
10
|
+
updatedAt: new Date(data.updated_at)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function parseProfileType(data, assocs) {
|
|
14
|
+
return {
|
|
15
|
+
...parseProfileTypeSummary(data, assocs),
|
|
16
|
+
hasPhone: data.has_phone || false,
|
|
17
|
+
hasEmail: data.has_email || false,
|
|
18
|
+
hasLinkedIn: data.has_linkedin || false,
|
|
19
|
+
hasWebsite: data.has_website || false,
|
|
20
|
+
hasTwitter: data.has_twitter || false,
|
|
21
|
+
hasFacebook: data.has_facebook || false,
|
|
22
|
+
hasBlueSky: data.has_bluesky || false,
|
|
23
|
+
hasCountry: data.has_country || false,
|
|
24
|
+
hasState: data.has_state || false,
|
|
25
|
+
hasCity: data.has_city || false,
|
|
26
|
+
hasStreet: data.has_street || false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type Person, type PersonSummary } from './person';
|
|
2
|
+
import { type Project, type ProjectSummary } from './projects';
|
|
3
|
+
import { type EventSummary } from './events';
|
|
4
|
+
import { type Organization, type OrganizationSummary } from './organizations';
|
|
5
|
+
import type { ApiAssocs, ApiData } from '../utils/api';
|
|
6
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
7
|
+
import type { Content } from './contents';
|
|
8
|
+
import { type Image, type Slideshow, type Video } from './visuals';
|
|
9
|
+
export type Profile = Person | Project | Event | Organization;
|
|
10
|
+
export type ProfileSummary = PersonSummary | ProjectSummary | EventSummary | OrganizationSummary;
|
|
11
|
+
export type ProfileBlockKind = ProfileBlockContents | ProfileBlockRelations;
|
|
12
|
+
export declare function parseProfileSummary(data: ApiData, assocs: ApiAssocs): ProfileSummary;
|
|
13
|
+
export interface ProfileAddress {
|
|
14
|
+
state: string | null;
|
|
15
|
+
location: string | null;
|
|
16
|
+
city: string | null;
|
|
17
|
+
country: string | null;
|
|
18
|
+
street: string | null;
|
|
19
|
+
meta: {
|
|
20
|
+
locales: LocalesMetadata;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface ProfileContact {
|
|
24
|
+
phone: string | null;
|
|
25
|
+
email: string | null;
|
|
26
|
+
linkedin: string | null;
|
|
27
|
+
website: string | null;
|
|
28
|
+
facebook: string | null;
|
|
29
|
+
twitter: string | null;
|
|
30
|
+
meta: {
|
|
31
|
+
locales: LocalesMetadata;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface ProfileDescription {
|
|
35
|
+
meta: {
|
|
36
|
+
locales: LocalesMetadata;
|
|
37
|
+
};
|
|
38
|
+
blocks: ProfileDescriptionBlock[];
|
|
39
|
+
}
|
|
40
|
+
export type ProfileDescriptionBlock = {
|
|
41
|
+
kind: string;
|
|
42
|
+
contentHtml: string;
|
|
43
|
+
contentText: string;
|
|
44
|
+
image: Image | null;
|
|
45
|
+
slideshow: Slideshow | null;
|
|
46
|
+
video: Video | null;
|
|
47
|
+
};
|
|
48
|
+
export type ProfileBlock = {
|
|
49
|
+
id: string;
|
|
50
|
+
profileType: string;
|
|
51
|
+
profileBlockType: string;
|
|
52
|
+
kind: string;
|
|
53
|
+
layout: string;
|
|
54
|
+
meta: {
|
|
55
|
+
locales: LocalesMetadata | null;
|
|
56
|
+
};
|
|
57
|
+
name: string | null;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
};
|
|
60
|
+
export interface ProfileBlockContents extends ProfileBlock {
|
|
61
|
+
contents: Content[];
|
|
62
|
+
}
|
|
63
|
+
export interface ProfileBlockRelations extends ProfileBlock {
|
|
64
|
+
profiles: ProfileSummary[];
|
|
65
|
+
}
|
|
66
|
+
export declare function parseProfileBlock(data: ApiData, assocs: ApiAssocs): ProfileBlockKind;
|
|
67
|
+
export declare function parseProfileAddress(data: ApiData, _assocs: ApiAssocs): ProfileAddress;
|
|
68
|
+
export declare function parseProfileContact(data: ApiData, _assocs: ApiAssocs): ProfileContact;
|
|
69
|
+
export declare function parseProfileDescriptionBlock(data: ApiData, assocs: ApiAssocs): ProfileDescriptionBlock;
|
|
70
|
+
export declare function parseProfileDescription(data: ApiData, assocs: ApiAssocs): ProfileDescription;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { parsePersonSummary } from './person';
|
|
2
|
+
import { parseProjectSummary } from './projects';
|
|
3
|
+
import { parseEventSummary } from './events';
|
|
4
|
+
import { parseOrganizationSummary } from './organizations';
|
|
5
|
+
import { getAssocs } from '../utils/assocs';
|
|
6
|
+
import { parseImage, parseSlideshow, parseVideo } from './visuals';
|
|
7
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
8
|
+
function getProfileParser() {
|
|
9
|
+
return {
|
|
10
|
+
person: parsePersonSummary,
|
|
11
|
+
project: parseProjectSummary,
|
|
12
|
+
event: parseEventSummary,
|
|
13
|
+
organization: parseOrganizationSummary
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function parseProfileSummary(data, assocs) {
|
|
17
|
+
const profileParser = getProfileParser();
|
|
18
|
+
const parser = profileParser[data.kind];
|
|
19
|
+
return parser(data, assocs);
|
|
20
|
+
}
|
|
21
|
+
export function parseProfileBlock(data, assocs) {
|
|
22
|
+
if (data.kind === 'selected_content') {
|
|
23
|
+
const contents = data.content_ids
|
|
24
|
+
? getAssocs(assocs, 'contents', data.content_ids)
|
|
25
|
+
: [];
|
|
26
|
+
return {
|
|
27
|
+
...profileBlockParser(data, assocs),
|
|
28
|
+
contents
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const profiles = data.profile_ids
|
|
33
|
+
? getAssocs(assocs, 'profiles', data.profile_ids)
|
|
34
|
+
: [];
|
|
35
|
+
return {
|
|
36
|
+
...profileBlockParser(data, assocs),
|
|
37
|
+
profiles
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function profileBlockParser(data, _assocs) {
|
|
42
|
+
const name = data.localized ? data.localized.name : null;
|
|
43
|
+
const meta = data.localized ? buildMeta(data.localized.locale) : { locales: null };
|
|
44
|
+
return {
|
|
45
|
+
id: data.id,
|
|
46
|
+
profileType: data.profile_type_id,
|
|
47
|
+
layout: data.layout,
|
|
48
|
+
kind: data.kind,
|
|
49
|
+
profileBlockType: data.block_type_id,
|
|
50
|
+
meta,
|
|
51
|
+
name,
|
|
52
|
+
updatedAt: new Date(data.updated_at)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function parseProfileAddress(data, _assocs) {
|
|
56
|
+
return {
|
|
57
|
+
state: data.state,
|
|
58
|
+
location: data.location,
|
|
59
|
+
city: data.city,
|
|
60
|
+
street: data.street,
|
|
61
|
+
country: data.country,
|
|
62
|
+
meta: buildMeta(data.locale)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function parseProfileContact(data, _assocs) {
|
|
66
|
+
return {
|
|
67
|
+
phone: data.phone,
|
|
68
|
+
email: data.email,
|
|
69
|
+
linkedin: data.linkedin,
|
|
70
|
+
website: data.website,
|
|
71
|
+
facebook: data.facebook,
|
|
72
|
+
twitter: data.twitter,
|
|
73
|
+
meta: buildMeta(data.locale)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function parseProfileDescriptionBlock(data, assocs) {
|
|
77
|
+
const image = data.image ? parseImage(data.image, assocs) : null;
|
|
78
|
+
const slideshow = data.slideshow ? parseSlideshow(data.slideshow, assocs) : null;
|
|
79
|
+
const video = data.video ? parseVideo(data.video, assocs) : null;
|
|
80
|
+
return {
|
|
81
|
+
kind: data.kind,
|
|
82
|
+
contentHtml: data.content_html,
|
|
83
|
+
contentText: data.content_text,
|
|
84
|
+
image,
|
|
85
|
+
slideshow,
|
|
86
|
+
video
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export function parseProfileDescription(data, assocs) {
|
|
90
|
+
const blocks = data.blocks
|
|
91
|
+
? data.blocks.map((block) => parseProfileDescriptionBlock(block, assocs))
|
|
92
|
+
: [];
|
|
93
|
+
return {
|
|
94
|
+
meta: buildMeta(data.locale),
|
|
95
|
+
blocks
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
2
|
+
import type { Category } from './categories';
|
|
3
|
+
import { type ProfileAddress, type ProfileContact, type ProfileDescription } from './profiles';
|
|
4
|
+
import { type ApiData, type ApiAssocs } from '../utils/api';
|
|
5
|
+
import type { ProfileType } from './profileType';
|
|
6
|
+
export interface ProjectSummary {
|
|
7
|
+
id: string;
|
|
8
|
+
profileType: ProfileType;
|
|
9
|
+
kind: string;
|
|
10
|
+
profileImageURL: string | null;
|
|
11
|
+
coverImageURL: string | null;
|
|
12
|
+
meta: {
|
|
13
|
+
locales: LocalesMetadata;
|
|
14
|
+
};
|
|
15
|
+
name: string;
|
|
16
|
+
summaryHtml: string | null;
|
|
17
|
+
summaryText: string | null;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseProjectSummary(data: ApiData, assocs: ApiAssocs): ProjectSummary;
|
|
21
|
+
export interface Project extends ProjectSummary {
|
|
22
|
+
coverImageUrl: string | null;
|
|
23
|
+
categories: Category[];
|
|
24
|
+
contact: ProfileContact | null;
|
|
25
|
+
address: ProfileAddress | null;
|
|
26
|
+
description: ProfileDescription | null;
|
|
27
|
+
}
|
|
28
|
+
export declare function parseProject(data: ApiData, assocs: ApiAssocs): Project;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { parseProfileAddress, parseProfileContact, parseProfileDescription } from './profiles';
|
|
2
|
+
import {} from '../utils/api';
|
|
3
|
+
import { getAssoc, getAssocs } from '../utils/assocs';
|
|
4
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
5
|
+
export function parseProjectSummary(data, assocs) {
|
|
6
|
+
return {
|
|
7
|
+
id: data.id,
|
|
8
|
+
profileType: getAssoc(assocs, 'profile_types', data.profile_type_id),
|
|
9
|
+
kind: 'project',
|
|
10
|
+
profileImageURL: data.logo_image_url,
|
|
11
|
+
coverImageURL: data.cover_image_url,
|
|
12
|
+
meta: buildMeta(data.localized),
|
|
13
|
+
name: data.localized.name,
|
|
14
|
+
summaryHtml: data.localized.summary_html,
|
|
15
|
+
summaryText: data.localized.summary_text,
|
|
16
|
+
updatedAt: new Date(data.updated_at)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function parseProject(data, assocs) {
|
|
20
|
+
const contact = data.localized_contact
|
|
21
|
+
? parseProfileContact(data.localized_contact, assocs)
|
|
22
|
+
: null;
|
|
23
|
+
const address = data.localized_address
|
|
24
|
+
? parseProfileAddress(data.localized_address, assocs)
|
|
25
|
+
: null;
|
|
26
|
+
const description = data.localized_description
|
|
27
|
+
? parseProfileDescription(data.localized_description, assocs)
|
|
28
|
+
: null;
|
|
29
|
+
return {
|
|
30
|
+
...parseProjectSummary(data, assocs),
|
|
31
|
+
coverImageUrl: data.cover_image_url,
|
|
32
|
+
categories: getAssocs(assocs, 'categories', data.category_ids),
|
|
33
|
+
contact,
|
|
34
|
+
address,
|
|
35
|
+
description
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
+
import type { ApiAssocs, ApiData } from '../utils/api';
|
|
1
2
|
export type Visual = Image | Slideshow | Video;
|
|
2
|
-
export
|
|
3
|
+
export interface Video {
|
|
4
|
+
type: 'video';
|
|
5
|
+
url: string;
|
|
6
|
+
captionHtml: string | null;
|
|
7
|
+
captionText: string | null;
|
|
8
|
+
credit: string | null;
|
|
9
|
+
videoID: string;
|
|
10
|
+
monetized: boolean;
|
|
11
|
+
provider: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
embedURL: string;
|
|
14
|
+
thumbnailURL: string;
|
|
15
|
+
isTrackingEnabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface Slideshow {
|
|
18
|
+
type: 'slideshow';
|
|
19
|
+
images: Image[];
|
|
20
|
+
}
|
|
21
|
+
export interface Image {
|
|
3
22
|
type: 'image';
|
|
4
23
|
url: string;
|
|
5
|
-
captionHtml: string;
|
|
6
|
-
captionText: string;
|
|
24
|
+
captionHtml: string | null;
|
|
25
|
+
captionText: string | null;
|
|
7
26
|
credit: string;
|
|
8
27
|
gravity: Gravity;
|
|
9
|
-
}
|
|
10
|
-
export type Slideshow = {
|
|
11
|
-
type: 'slideshow';
|
|
12
|
-
};
|
|
13
|
-
export type Video = {
|
|
14
|
-
type: 'video';
|
|
15
|
-
};
|
|
28
|
+
}
|
|
16
29
|
export type Gravity = 'center' | 'north' | 'northeast' | 'east' | 'southeast' | 'south' | 'southwest' | 'west' | 'northwest';
|
|
30
|
+
export type VisualType = 'image' | 'slideshow' | 'video';
|
|
31
|
+
export declare function parseVisual(data: ApiData, assocs: ApiAssocs): Visual | null;
|
|
32
|
+
export declare function parseImage(data: ApiData, _assocs: ApiAssocs): Image;
|
|
33
|
+
export declare function parseSlideshow(data: ApiData, assocs: ApiAssocs): Slideshow;
|
|
34
|
+
export declare function parseVideo(data: ApiData, _assocs: ApiAssocs): Video;
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
const VisualParser = {
|
|
2
|
+
image: parseImage,
|
|
3
|
+
slideshow: parseSlideshow,
|
|
4
|
+
video: parseVideo
|
|
5
|
+
};
|
|
6
|
+
export function parseVisual(data, assocs) {
|
|
7
|
+
const type = data?.type;
|
|
8
|
+
if (!type)
|
|
9
|
+
return null;
|
|
10
|
+
return VisualParser[type]?.(data, assocs) ?? null;
|
|
11
|
+
}
|
|
12
|
+
export function parseImage(data, _assocs) {
|
|
13
|
+
return {
|
|
14
|
+
type: 'image',
|
|
15
|
+
url: data.url,
|
|
16
|
+
captionHtml: data.caption_html,
|
|
17
|
+
captionText: data.caption_text,
|
|
18
|
+
credit: data.credit,
|
|
19
|
+
gravity: data.gravity
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function parseSlideshow(data, assocs) {
|
|
23
|
+
return {
|
|
24
|
+
type: 'slideshow',
|
|
25
|
+
images: Array.isArray(data.images)
|
|
26
|
+
? data.images.map((imageData) => parseImage(imageData, assocs))
|
|
27
|
+
: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function parseVideo(data, _assocs) {
|
|
31
|
+
return {
|
|
32
|
+
type: 'video',
|
|
33
|
+
videoID: data.video_id,
|
|
34
|
+
monetized: data.monetized,
|
|
35
|
+
provider: data.provider,
|
|
36
|
+
embedURL: data.embed_url,
|
|
37
|
+
thumbnailURL: data.thumbnail_url,
|
|
38
|
+
url: data.url,
|
|
39
|
+
captionHtml: data.caption_html,
|
|
40
|
+
credit: data.credit,
|
|
41
|
+
captionText: data.caption_text,
|
|
42
|
+
isTrackingEnabled: data.is_tracking_enabled
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ApiAssocs, type ApiData } from '../utils/api';
|
|
2
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
3
|
+
export interface WebpageSummary {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
useDefaultLayout: boolean;
|
|
8
|
+
seoEnabled: boolean;
|
|
9
|
+
meta: {
|
|
10
|
+
locales: LocalesMetadata;
|
|
11
|
+
};
|
|
12
|
+
title: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
url: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface OrgWebpage extends WebpageSummary {
|
|
17
|
+
html: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function ParseWebpageSummary(data: ApiData, _assocs: ApiAssocs): WebpageSummary;
|
|
20
|
+
export declare function ParseWebpage(data: ApiData, assocs: ApiAssocs): OrgWebpage;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {} from '../utils/api';
|
|
2
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
3
|
+
export function ParseWebpageSummary(data, _assocs) {
|
|
4
|
+
return {
|
|
5
|
+
id: data.id,
|
|
6
|
+
name: data.name,
|
|
7
|
+
type: data.type,
|
|
8
|
+
useDefaultLayout: data.use_default_layout,
|
|
9
|
+
seoEnabled: data.seo_enabled,
|
|
10
|
+
meta: buildMeta(data.localized.locale),
|
|
11
|
+
title: data.localized.title,
|
|
12
|
+
slug: data.localized.slug,
|
|
13
|
+
url: data.localized.url
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function ParseWebpage(data, assocs) {
|
|
17
|
+
return {
|
|
18
|
+
...ParseWebpageSummary(data, assocs),
|
|
19
|
+
html: data.localized.html
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -4,6 +4,32 @@ export declare const fetchers: (f: typeof fetch) => {
|
|
|
4
4
|
subscribeToTopic: (params: import("./endpoints/notification").SubscriptionParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
5
5
|
unsubscribeFromTopic: (params: import("./endpoints/notification").SubscriptionParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
6
6
|
};
|
|
7
|
+
magazines: {
|
|
8
|
+
getIssue: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").Issue>>;
|
|
9
|
+
getBlocks: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").IssueBlock[]>>;
|
|
10
|
+
searchContents: (issueId: string, q: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").SectionContent[]>>;
|
|
11
|
+
getSectionContents: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").Content[]>>;
|
|
12
|
+
};
|
|
13
|
+
getMenu: (key: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/menu").Menu>>;
|
|
14
|
+
listMenus: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/menu").MenuSummary[]>>;
|
|
15
|
+
listOrganizations: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/organizations").OrganizationSummary[]>>;
|
|
16
|
+
getOrganization: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/organizations").Organization>>;
|
|
17
|
+
getOrgWebpage: (slug: string) => Promise<import("./utils/api").ApiResponse<import(".").OrgWebpage>>;
|
|
18
|
+
listOrgWebpages: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").WebpageSummary[]>>;
|
|
19
|
+
getMedia: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/media").Media>>;
|
|
20
|
+
getMediaOrganization: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/organizations").Organization>>;
|
|
21
|
+
listMediaOrganizations: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/organizations").OrganizationSummary[]>>;
|
|
22
|
+
getMediaEvent: (id: string) => Promise<import("./utils/api").ApiResponse<import(".").Event>>;
|
|
23
|
+
listMediaEvents: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").EventSummary[]>>;
|
|
24
|
+
listMediaEventBlocks: (id: string, params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").ProfileBlockKind[]>>;
|
|
25
|
+
getMediaPerson: (id: string) => Promise<import("./utils/api").ApiResponse<import(".").Person>>;
|
|
26
|
+
listMediaPersons: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").PersonSummary[]>>;
|
|
27
|
+
getMediaProject: (id: string) => Promise<import("./utils/api").ApiResponse<import(".").Project>>;
|
|
28
|
+
listMediaProjects: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").ProjectSummary[]>>;
|
|
29
|
+
getMediaProfileType: (id: string) => Promise<import("./utils/api").ApiResponse<import(".").ProfileType>>;
|
|
30
|
+
listMediaProfileTypes: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import(".").ProfileTypeSummary[]>>;
|
|
31
|
+
getContent: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").Content>>;
|
|
32
|
+
listContents: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").ContentSummary[]>>;
|
|
7
33
|
listCategories: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/categories").Category[]>>;
|
|
8
34
|
getCategory: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/categories").Category>>;
|
|
9
35
|
listOauthProviders: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/oauth").OauthProviderSummary[]>>;
|
|
@@ -3,12 +3,22 @@ import { categoriesFetchers } from './endpoints/categories';
|
|
|
3
3
|
import { deviceFetchers } from './endpoints/device';
|
|
4
4
|
import { notificationFetchers } from './endpoints/notification';
|
|
5
5
|
import { oauthFetchers } from './endpoints/oauth';
|
|
6
|
+
import { contentsFetchers } from './endpoints/contents';
|
|
7
|
+
import { mediaFetchers } from './endpoints/media';
|
|
8
|
+
import { organizationFetchers } from './endpoints/organizations';
|
|
9
|
+
import { menuFetchers } from './endpoints/menu';
|
|
10
|
+
import { magazineFetchers } from './endpoints/magazines';
|
|
6
11
|
export const fetchers = (f) => {
|
|
7
12
|
return {
|
|
8
13
|
...accountsFetchers(f),
|
|
9
14
|
...deviceFetchers(f),
|
|
10
15
|
...oauthFetchers(f),
|
|
11
16
|
...categoriesFetchers(f),
|
|
12
|
-
|
|
17
|
+
...contentsFetchers(f),
|
|
18
|
+
...mediaFetchers(f),
|
|
19
|
+
...organizationFetchers(f),
|
|
20
|
+
...menuFetchers(f),
|
|
21
|
+
notifications: notificationFetchers(f),
|
|
22
|
+
magazines: magazineFetchers(f)
|
|
13
23
|
};
|
|
14
24
|
};
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
export * from './stores/user_session';
|
|
2
|
-
export type * from './endpoints/oauth';
|
|
3
2
|
export type * from './endpoints/accounts';
|
|
3
|
+
export type * from './endpoints/categories';
|
|
4
|
+
export type * from './endpoints/content-templates';
|
|
5
|
+
export type * from './endpoints/contents';
|
|
6
|
+
export type * from './endpoints/device';
|
|
7
|
+
export type * from './endpoints/events';
|
|
8
|
+
export type * from './endpoints/magazines';
|
|
9
|
+
export type * from './endpoints/media';
|
|
10
|
+
export type * from './endpoints/menu';
|
|
11
|
+
export type * from './endpoints/notification';
|
|
12
|
+
export type * from './endpoints/oauth';
|
|
13
|
+
export type * from './endpoints/organizations';
|
|
14
|
+
export type * from './endpoints/person';
|
|
15
|
+
export type * from './endpoints/profileType';
|
|
16
|
+
export type * from './endpoints/profiles';
|
|
17
|
+
export type * from './endpoints/projects';
|
|
18
|
+
export type * from './endpoints/visuals';
|
|
19
|
+
export type * from './endpoints/webpage';
|
|
20
|
+
export type * from './utils/response';
|
|
@@ -1 +1,19 @@
|
|
|
1
|
+
import { parseCategory } from './endpoints/categories';
|
|
2
|
+
import { parseProfileBlock, parseProfileSummary } from './endpoints/profiles';
|
|
3
|
+
import { parseContentBlockTemplate, parseContentTemplate } from './endpoints/content-templates';
|
|
4
|
+
import { parseProfileTypeSummary } from './endpoints/profileType';
|
|
5
|
+
import { registerAssocParser } from './utils/assocs';
|
|
6
|
+
import { parseContentSummary } from './endpoints/contents';
|
|
7
|
+
import { parseIssueBlockConfiguration, parseIssueType } from './endpoints/magazines';
|
|
1
8
|
export * from './stores/user_session';
|
|
9
|
+
registerAssocParser('categories', parseCategory);
|
|
10
|
+
registerAssocParser('profiles', parseProfileSummary);
|
|
11
|
+
registerAssocParser('content_templates', parseContentTemplate);
|
|
12
|
+
registerAssocParser('profile_types', parseProfileTypeSummary);
|
|
13
|
+
registerAssocParser('profile_block_types', parseProfileBlock);
|
|
14
|
+
registerAssocParser('content_block_templates', parseContentBlockTemplate);
|
|
15
|
+
registerAssocParser('contents', parseContentSummary);
|
|
16
|
+
registerAssocParser('issue_types', parseIssueType);
|
|
17
|
+
registerAssocParser('issue_block_configurations', parseIssueBlockConfiguration);
|
|
18
|
+
// NOTE: This one is for retro compatibility with publisher public api v2
|
|
19
|
+
registerAssocParser('templates', parseContentTemplate);
|
|
@@ -5,8 +5,8 @@ export interface EmailParams {
|
|
|
5
5
|
body: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
* Send an email.
|
|
9
|
+
*
|
|
10
|
+
* Return `true` if the email has been sent. It could take a couple of minutes to be received.
|
|
11
|
+
*/
|
|
12
12
|
export declare function sendEmail(params: EmailParams): Promise<boolean>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { env } from '$env/dynamic/private';
|
|
2
2
|
import { ApiError } from '../utils/api';
|
|
3
|
-
import { getApplicationToken } from
|
|
3
|
+
import { getApplicationToken } from './utils';
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
* Send an email.
|
|
6
|
+
*
|
|
7
|
+
* Return `true` if the email has been sent. It could take a couple of minutes to be received.
|
|
8
|
+
*/
|
|
9
9
|
export async function sendEmail(params) {
|
|
10
10
|
const url = getOmerloEndpoint();
|
|
11
11
|
const accessToken = await getApplicationToken();
|
|
@@ -45,9 +45,23 @@ export const proxyHook = async ({ event, resolve }) => {
|
|
|
45
45
|
return await handleApiProxy({ event, resolve });
|
|
46
46
|
}
|
|
47
47
|
// TODO remove once every API will be done in Reader
|
|
48
|
-
if (event.url.pathname.startsWith('/api/publisher')) {
|
|
49
|
-
const
|
|
50
|
-
|
|
48
|
+
if (event.url.pathname.startsWith('/api/publisher/')) {
|
|
49
|
+
const pathAfterPublisher = event.url.pathname.slice('/api/publisher/'.length);
|
|
50
|
+
const resourceConfigs = {
|
|
51
|
+
'media/': { idKey: env['PRIVATE_OMERLO_MEDIA_ID'], resourcePath: 'medias' },
|
|
52
|
+
'organization/': {
|
|
53
|
+
idKey: env['PRIVATE_OMERLO_ORGANIZATION_ID'],
|
|
54
|
+
resourcePath: 'organizations'
|
|
55
|
+
},
|
|
56
|
+
'issue/': { idKey: env['PRIVATE_OMERLO_ISSUE_ID'], resourcePath: 'issues' }
|
|
57
|
+
};
|
|
58
|
+
for (const [prefix, config] of Object.entries(resourceConfigs)) {
|
|
59
|
+
if (pathAfterPublisher.startsWith(prefix)) {
|
|
60
|
+
event.url.pathname = event.url.pathname.replace(`/api/publisher/${prefix}`, `/api/public/publisher/v2/${config.resourcePath}/${config.idKey}/`);
|
|
61
|
+
return handleApiProxy({ event, resolve });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
event.url.pathname = event.url.pathname.replace('/api/publisher/', `/api/public/publisher/v2/`);
|
|
51
65
|
return handleApiProxy({ event, resolve });
|
|
52
66
|
}
|
|
53
67
|
return resolve(event);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Assoc } from './assocs';
|
|
2
|
-
export type ApiAssocs = Record<string,
|
|
2
|
+
export type ApiAssocs = Record<string, Assoc>;
|
|
3
3
|
export declare function parseApiResponse<T>(response: Response, parser: (data: ApiData, assocs: ApiAssocs) => T): Promise<ApiResponse<T>>;
|
|
4
4
|
export declare function parseMany<T>(parser: (data: ApiData, assocs: ApiAssocs) => T): (response: ApiData[], assocs: ApiAssocs) => T[];
|
|
5
5
|
export interface ApiResponse<T> {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { parseAssocs } from './assocs';
|
|
1
|
+
import { initAssocs, parseAssocs } from './assocs';
|
|
2
2
|
export async function parseApiResponse(response, parser) {
|
|
3
3
|
const payload = await response.json();
|
|
4
4
|
let data = null, meta = null;
|
|
5
5
|
if (response.ok) {
|
|
6
|
-
|
|
6
|
+
const assocs = initAssocs(payload.assocs);
|
|
7
|
+
parseAssocs(assocs);
|
|
7
8
|
meta = payload.meta;
|
|
8
|
-
data = parser(payload.data,
|
|
9
|
+
data = parser(payload.data, assocs);
|
|
9
10
|
}
|
|
10
11
|
const errors = payload.errors || [];
|
|
11
12
|
return { ok: response.ok, status: response.status, parser, meta, data, errors };
|