@omerlo/omerlo-webkit 0.0.4 → 0.0.6
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 +24 -24
- package/dist/components/OmerloWebkit.svelte +2 -3
- package/dist/components/OmerloWebkit.svelte.d.ts +1 -1
- package/dist/omerlo/index.d.ts +32 -4
- package/dist/omerlo/reader/endpoints/categories.d.ts +18 -0
- package/dist/omerlo/reader/endpoints/categories.js +39 -0
- package/dist/omerlo/reader/endpoints/content-templates.d.ts +23 -0
- package/dist/omerlo/reader/endpoints/content-templates.js +34 -0
- package/dist/omerlo/reader/endpoints/contents.d.ts +122 -0
- package/dist/omerlo/reader/endpoints/contents.js +187 -0
- package/dist/omerlo/reader/endpoints/device.js +1 -1
- 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.d.ts +5 -5
- package/dist/omerlo/reader/endpoints/notification.js +6 -8
- package/dist/omerlo/reader/endpoints/oauth.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 +34 -0
- package/dist/omerlo/reader/endpoints/visuals.js +44 -0
- 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 +30 -2
- package/dist/omerlo/reader/fetchers.js +12 -0
- 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 +12 -0
- package/dist/omerlo/reader/server/email.js +30 -0
- package/dist/omerlo/reader/server/hooks.d.ts +1 -1
- package/dist/omerlo/reader/server/hooks.js +39 -20
- package/dist/omerlo/reader/server/index.d.ts +1 -0
- package/dist/omerlo/reader/server/index.js +1 -0
- package/dist/omerlo/reader/server/token.d.ts +6 -6
- package/dist/omerlo/reader/server/token.js +7 -7
- package/dist/omerlo/reader/server/utils.d.ts +4 -4
- package/dist/omerlo/reader/server/utils.js +13 -7
- package/dist/omerlo/reader/stores/user_session.d.ts +2 -2
- package/dist/omerlo/reader/stores/user_session.js +11 -9
- 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/dist/omerlo/reader/utils/request.d.ts +10 -8
- package/dist/omerlo/reader/utils/request.js +39 -11
- package/dist/omerlo/reader/utils/response.d.ts +1 -1
- package/dist/omerlo/reader/utils/response.js +1 -1
- package/eslint.config.js +11 -2
- package/package.json +3 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ApiAssocs, PagingParams } from '../utils/api';
|
|
2
|
+
import { type ApiData } from '../utils/api';
|
|
3
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
4
|
+
import type { Category } from './categories';
|
|
5
|
+
import { type ProfileAddress } from './profiles';
|
|
6
|
+
import { type ProfileContact } from './profiles';
|
|
7
|
+
import { type ProfileDescription } from './profiles';
|
|
8
|
+
import type { ProfileType } from './profileType';
|
|
9
|
+
export declare const organizationFetchers: (f: typeof fetch) => {
|
|
10
|
+
listOrganizations: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<OrganizationSummary[]>>;
|
|
11
|
+
getOrganization: () => Promise<import("../utils/api").ApiResponse<Organization>>;
|
|
12
|
+
getOrgWebpage: (slug: string) => Promise<import("../utils/api").ApiResponse<import("./webpage").OrgWebpage>>;
|
|
13
|
+
listOrgWebpages: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./webpage").WebpageSummary[]>>;
|
|
14
|
+
};
|
|
15
|
+
export interface OrganizationSummary {
|
|
16
|
+
id: string;
|
|
17
|
+
profileType: ProfileType;
|
|
18
|
+
kind: string;
|
|
19
|
+
name: string;
|
|
20
|
+
profileImageURL: string | null;
|
|
21
|
+
meta: {
|
|
22
|
+
locales: LocalesMetadata;
|
|
23
|
+
};
|
|
24
|
+
summaryHtml: string | null;
|
|
25
|
+
summaryText: string | null;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
}
|
|
28
|
+
export interface Organization extends OrganizationSummary {
|
|
29
|
+
coverImageUrl: string | null;
|
|
30
|
+
categories: Category[];
|
|
31
|
+
contact: ProfileContact | null;
|
|
32
|
+
address: ProfileAddress | null;
|
|
33
|
+
description: ProfileDescription | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function parseOrganizationSummary(data: ApiData, assocs: ApiAssocs): OrganizationSummary;
|
|
36
|
+
export declare function parseOrganization(data: ApiData, assocs: ApiAssocs): Organization;
|
|
37
|
+
export declare function getOrganization(f: typeof fetch): () => Promise<import("../utils/api").ApiResponse<Organization>>;
|
|
38
|
+
export declare function listOrganizations(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<OrganizationSummary[]>>;
|
|
39
|
+
export declare function getOrgWebpage(f: typeof fetch): (slug: string) => Promise<import("../utils/api").ApiResponse<import("./webpage").OrgWebpage>>;
|
|
40
|
+
export declare function listOrgWebpages(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./webpage").WebpageSummary[]>>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { parseMany } from '../utils/api';
|
|
2
|
+
import { getAssoc, getAssocs } from '../utils/assocs';
|
|
3
|
+
import { parseProfileAddress } from './profiles';
|
|
4
|
+
import { parseProfileContact } from './profiles';
|
|
5
|
+
import { parseProfileDescription } from './profiles';
|
|
6
|
+
import { buildMeta } from '../utils/parseHelpers';
|
|
7
|
+
import { ParseWebpage, ParseWebpageSummary } from './webpage';
|
|
8
|
+
import { requestPublisher } from '../utils/request';
|
|
9
|
+
export const organizationFetchers = (f) => {
|
|
10
|
+
return {
|
|
11
|
+
listOrganizations: listOrganizations(f),
|
|
12
|
+
getOrganization: getOrganization(f),
|
|
13
|
+
getOrgWebpage: getOrgWebpage(f),
|
|
14
|
+
listOrgWebpages: listOrgWebpages(f)
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export function parseOrganizationSummary(data, assocs) {
|
|
18
|
+
return {
|
|
19
|
+
id: data.id,
|
|
20
|
+
profileType: getAssoc(assocs, 'profile_types', data.profile_type_id),
|
|
21
|
+
kind: 'organization',
|
|
22
|
+
name: data.name,
|
|
23
|
+
profileImageURL: data.logo_image_url,
|
|
24
|
+
meta: buildMeta(data.localized.locale),
|
|
25
|
+
summaryHtml: data.localized.summary_html,
|
|
26
|
+
summaryText: data.localized.summary_text,
|
|
27
|
+
updatedAt: new Date(data.updated_at)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function parseOrganization(data, assocs) {
|
|
31
|
+
const contact = data.localized.contact
|
|
32
|
+
? parseProfileContact(data.localized.contact, assocs)
|
|
33
|
+
: null;
|
|
34
|
+
const address = data.localized_address
|
|
35
|
+
? parseProfileAddress(data.localized_address, assocs)
|
|
36
|
+
: null;
|
|
37
|
+
const description = data.localized.description
|
|
38
|
+
? parseProfileDescription(data.localized.description, assocs)
|
|
39
|
+
: null;
|
|
40
|
+
return {
|
|
41
|
+
...parseOrganizationSummary(data, assocs),
|
|
42
|
+
coverImageUrl: data.cover_image_url,
|
|
43
|
+
categories: getAssocs(assocs, 'categories', data.category_ids),
|
|
44
|
+
contact,
|
|
45
|
+
address,
|
|
46
|
+
description
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function getOrganization(f) {
|
|
50
|
+
return async () => {
|
|
51
|
+
const opts = { parser: parseOrganization };
|
|
52
|
+
return requestPublisher(f, `organization`, opts);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function listOrganizations(f) {
|
|
56
|
+
return async (params) => {
|
|
57
|
+
const opts = { parser: parseMany(parseOrganizationSummary), queryParams: params };
|
|
58
|
+
return requestPublisher(f, `organizations`, opts);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function getOrgWebpage(f) {
|
|
62
|
+
return async (slug) => {
|
|
63
|
+
const opts = { parser: ParseWebpage };
|
|
64
|
+
return requestPublisher(f, `organization/pages/${slug}`, opts);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function listOrgWebpages(f) {
|
|
68
|
+
return async (params) => {
|
|
69
|
+
const opts = { parser: parseMany(ParseWebpageSummary), queryParams: params };
|
|
70
|
+
return requestPublisher(f, `organization/pages`, opts);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Category } from './categories';
|
|
2
|
+
import { type ApiAssocs, type ApiData } from '../utils/api';
|
|
3
|
+
import type { LocalesMetadata } from '../utils/response';
|
|
4
|
+
import { type ProfileAddress, type ProfileContact, type ProfileDescription } from './profiles';
|
|
5
|
+
import type { ProfileType } from './profileType';
|
|
6
|
+
export interface PersonSummary {
|
|
7
|
+
id: string;
|
|
8
|
+
profileType: ProfileType;
|
|
9
|
+
kind: string;
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
otherName: string | null;
|
|
13
|
+
pronoun: string | null;
|
|
14
|
+
profileImageURL: string | null;
|
|
15
|
+
coverImageURL: string | null;
|
|
16
|
+
meta: {
|
|
17
|
+
locales: LocalesMetadata;
|
|
18
|
+
};
|
|
19
|
+
summaryHtml: string | null;
|
|
20
|
+
summaryText: string | null;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
}
|
|
23
|
+
export declare function parsePersonSummary(data: ApiData, assocs: ApiAssocs): PersonSummary;
|
|
24
|
+
export interface Person extends PersonSummary {
|
|
25
|
+
categories: Category[];
|
|
26
|
+
address: ProfileAddress | null;
|
|
27
|
+
contact: ProfileContact | null;
|
|
28
|
+
description: ProfileDescription | null;
|
|
29
|
+
}
|
|
30
|
+
export declare function parsePerson(data: ApiData, assocs: ApiAssocs): Person;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ApiAssocs, ApiData } from '../utils/api';
|
|
2
|
+
export type Visual = Image | Slideshow | Video;
|
|
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 {
|
|
22
|
+
type: 'image';
|
|
23
|
+
url: string;
|
|
24
|
+
captionHtml: string | null;
|
|
25
|
+
captionText: string | null;
|
|
26
|
+
credit: string;
|
|
27
|
+
gravity: Gravity;
|
|
28
|
+
}
|
|
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;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
export declare const fetchers: (f: typeof fetch) => {
|
|
2
2
|
notifications: {
|
|
3
3
|
listTopics: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/notification").TopicSummary[]>>;
|
|
4
|
-
subscribeToTopic: (params: import("./endpoints/notification").
|
|
5
|
-
unsubscribeFromTopic: (params: import("./endpoints/notification").
|
|
4
|
+
subscribeToTopic: (params: import("./endpoints/notification").SubscriptionParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
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[]>>;
|
|
33
|
+
listCategories: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/categories").Category[]>>;
|
|
34
|
+
getCategory: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/categories").Category>>;
|
|
7
35
|
listOauthProviders: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/oauth").OauthProviderSummary[]>>;
|
|
8
36
|
getOauthUser: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/oauth").OauthUser>>;
|
|
9
37
|
registerDevice: (params: import("./endpoints/device").DeviceParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { accountsFetchers } from './endpoints/accounts';
|
|
2
|
+
import { categoriesFetchers } from './endpoints/categories';
|
|
2
3
|
import { deviceFetchers } from './endpoints/device';
|
|
3
4
|
import { notificationFetchers } from './endpoints/notification';
|
|
4
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';
|
|
5
11
|
export const fetchers = (f) => {
|
|
6
12
|
return {
|
|
7
13
|
...accountsFetchers(f),
|
|
8
14
|
...deviceFetchers(f),
|
|
9
15
|
...oauthFetchers(f),
|
|
16
|
+
...categoriesFetchers(f),
|
|
17
|
+
...contentsFetchers(f),
|
|
18
|
+
...mediaFetchers(f),
|
|
19
|
+
...organizationFetchers(f),
|
|
20
|
+
...menuFetchers(f),
|
|
10
21
|
notifications: notificationFetchers(f),
|
|
22
|
+
magazines: magazineFetchers(f)
|
|
11
23
|
};
|
|
12
24
|
};
|