@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.
Files changed (46) hide show
  1. package/README.md +0 -2
  2. package/dist/omerlo/index.d.ts +32 -6
  3. package/dist/omerlo/reader/endpoints/categories.d.ts +1 -1
  4. package/dist/omerlo/reader/endpoints/categories.js +16 -13
  5. package/dist/omerlo/reader/endpoints/content-templates.d.ts +9 -2
  6. package/dist/omerlo/reader/endpoints/content-templates.js +34 -1
  7. package/dist/omerlo/reader/endpoints/contents.d.ts +98 -27
  8. package/dist/omerlo/reader/endpoints/contents.js +187 -2
  9. package/dist/omerlo/reader/endpoints/events.d.ts +32 -0
  10. package/dist/omerlo/reader/endpoints/events.js +45 -0
  11. package/dist/omerlo/reader/endpoints/magazines.d.ts +104 -0
  12. package/dist/omerlo/reader/endpoints/magazines.js +135 -0
  13. package/dist/omerlo/reader/endpoints/media.d.ts +65 -0
  14. package/dist/omerlo/reader/endpoints/media.js +133 -0
  15. package/dist/omerlo/reader/endpoints/menu.d.ts +31 -0
  16. package/dist/omerlo/reader/endpoints/menu.js +49 -0
  17. package/dist/omerlo/reader/endpoints/notification.js +1 -1
  18. package/dist/omerlo/reader/endpoints/organizations.d.ts +40 -0
  19. package/dist/omerlo/reader/endpoints/organizations.js +72 -0
  20. package/dist/omerlo/reader/endpoints/person.d.ts +30 -0
  21. package/dist/omerlo/reader/endpoints/person.js +39 -0
  22. package/dist/omerlo/reader/endpoints/profileType.d.ts +27 -0
  23. package/dist/omerlo/reader/endpoints/profileType.js +28 -0
  24. package/dist/omerlo/reader/endpoints/profiles.d.ts +70 -0
  25. package/dist/omerlo/reader/endpoints/profiles.js +97 -0
  26. package/dist/omerlo/reader/endpoints/projects.d.ts +28 -0
  27. package/dist/omerlo/reader/endpoints/projects.js +37 -0
  28. package/dist/omerlo/reader/endpoints/visuals.d.ts +28 -10
  29. package/dist/omerlo/reader/endpoints/visuals.js +44 -1
  30. package/dist/omerlo/reader/endpoints/webpage.d.ts +20 -0
  31. package/dist/omerlo/reader/endpoints/webpage.js +21 -0
  32. package/dist/omerlo/reader/fetchers.d.ts +26 -0
  33. package/dist/omerlo/reader/fetchers.js +11 -1
  34. package/dist/omerlo/reader/index.d.ts +18 -1
  35. package/dist/omerlo/reader/index.js +18 -0
  36. package/dist/omerlo/reader/server/email.d.ts +4 -4
  37. package/dist/omerlo/reader/server/email.js +5 -5
  38. package/dist/omerlo/reader/server/hooks.js +17 -3
  39. package/dist/omerlo/reader/utils/api.d.ts +1 -1
  40. package/dist/omerlo/reader/utils/api.js +4 -3
  41. package/dist/omerlo/reader/utils/assocs.d.ts +5 -4
  42. package/dist/omerlo/reader/utils/assocs.js +23 -0
  43. package/dist/omerlo/reader/utils/parseHelpers.d.ts +7 -0
  44. package/dist/omerlo/reader/utils/parseHelpers.js +22 -0
  45. package/eslint.config.js +10 -1
  46. package/package.json +2 -1
@@ -0,0 +1,104 @@
1
+ import { type LocalesMetadata } from '../utils/response';
2
+ import { type Visual } from './visuals';
3
+ import { type ApiAssocs, type ApiData } from '../utils/api';
4
+ import { type Content, type ContentSummary } from './contents';
5
+ export declare const magazineFetchers: (f: typeof fetch) => {
6
+ getIssue: (id: string) => Promise<import("../utils/api").ApiResponse<Issue>>;
7
+ getBlocks: (sectionId: string) => Promise<import("../utils/api").ApiResponse<IssueBlock[]>>;
8
+ searchContents: (issueId: string, q: string) => Promise<import("../utils/api").ApiResponse<SectionContent[]>>;
9
+ getSectionContents: (sectionId: string) => Promise<import("../utils/api").ApiResponse<Content[]>>;
10
+ };
11
+ export declare function issueFetcher(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<Issue>>;
12
+ export declare function issueBlocksFetcher(f: typeof fetch): (sectionId: string) => Promise<import("../utils/api").ApiResponse<IssueBlock[]>>;
13
+ export declare function contentsSearch(f: typeof fetch): (issueId: string, q: string) => Promise<import("../utils/api").ApiResponse<SectionContent[]>>;
14
+ export declare function sectionContentsFetcher(f: typeof fetch): (sectionId: string) => Promise<import("../utils/api").ApiResponse<Content[]>>;
15
+ /******************************************************************************
16
+ * Parsers
17
+ ******************************************************************************/
18
+ export declare function parseIssueSummary(data: ApiData, assocs: ApiAssocs): IssueSummary;
19
+ export declare function parseIssue(data: ApiData, assocs: ApiAssocs): Issue;
20
+ export declare function parseIssueSectionSummary(data: ApiData, assocs: ApiAssocs): IssueSectionSummary;
21
+ export declare function parseIssueSection(data: ApiData, assocs: ApiAssocs): IssueSection;
22
+ export declare function parseIssueBlock(data: ApiData, assocs: ApiAssocs): IssueBlock;
23
+ export declare function parseIssueBlockSlot(data: ApiData, assocs: ApiAssocs): IssueBlockSlot;
24
+ export declare function parseIssueSectionContent(data: ApiData, assocs: ApiAssocs): SectionContent;
25
+ export declare function parseIssueType(data: ApiData, _assocs: ApiAssocs): IssueType;
26
+ export declare function parseIssueBlockConfiguration(data: ApiData, assocs: ApiAssocs): IssueBlockConfiguration;
27
+ /******************************************************************************
28
+ * Interfaces
29
+ ******************************************************************************/
30
+ export interface IssueSummary {
31
+ id: string;
32
+ issueType: IssueType;
33
+ kind: 'pdf' | 'regular';
34
+ name: string;
35
+ color: string | null;
36
+ pdfUrl: string | null;
37
+ visual: Visual | null;
38
+ meta: {
39
+ locales: LocalesMetadata;
40
+ };
41
+ updatedAt: Date;
42
+ }
43
+ export interface Issue extends IssueSummary {
44
+ advertisingKey: string | null;
45
+ descriptionHtml: string | null;
46
+ descriptionText: string | null;
47
+ metadata: {
48
+ [key: string]: string;
49
+ };
50
+ sections: IssueSectionSummary[];
51
+ }
52
+ export interface IssueType {
53
+ id: string;
54
+ key: string;
55
+ name: string;
56
+ svgIcon: string | null;
57
+ meta: {
58
+ locales: LocalesMetadata;
59
+ };
60
+ updatedAt: Date;
61
+ }
62
+ export interface IssueSectionSummary {
63
+ id: string;
64
+ name: string;
65
+ advertisingKey: string | null;
66
+ color: string | null;
67
+ visual: Visual | null;
68
+ meta: {
69
+ locales: LocalesMetadata;
70
+ };
71
+ updatedAt: Date;
72
+ }
73
+ export interface IssueSection extends IssueSectionSummary {
74
+ description: string | null;
75
+ }
76
+ export interface IssueBlock {
77
+ id: string;
78
+ configuration: IssueBlockConfiguration;
79
+ textColor: string | null;
80
+ backgroundColor: string | null;
81
+ backgroundSvg: string | null;
82
+ name: string | null;
83
+ description: string | null;
84
+ visual: Visual | null;
85
+ slots: IssueBlockSlot[];
86
+ meta: {
87
+ locales: LocalesMetadata;
88
+ };
89
+ updatedAt: Date;
90
+ }
91
+ export interface SectionContent extends Content {
92
+ section: IssueSectionSummary;
93
+ }
94
+ export interface IssueBlockConfiguration {
95
+ id: string;
96
+ key: string;
97
+ minContents: number;
98
+ maxContents: number;
99
+ updatedAt: Date;
100
+ }
101
+ export interface IssueBlockSlot {
102
+ id: string;
103
+ content: ContentSummary;
104
+ }
@@ -0,0 +1,135 @@
1
+ import { parseLocalesMetadata } from '../utils/response';
2
+ import { parseVisual } from './visuals';
3
+ import { parseMany } from '../utils/api';
4
+ import { getAssoc } from '../utils/assocs';
5
+ import { request } from '../utils/request';
6
+ import { parseContent } from './contents';
7
+ export const magazineFetchers = (f) => {
8
+ return {
9
+ getIssue: issueFetcher(f),
10
+ getBlocks: issueBlocksFetcher(f),
11
+ searchContents: contentsSearch(f),
12
+ getSectionContents: sectionContentsFetcher(f)
13
+ };
14
+ };
15
+ export function issueFetcher(f) {
16
+ return async (id) => {
17
+ const opts = { parser: parseIssue };
18
+ return request(f, `/issues/${id}`, opts);
19
+ };
20
+ }
21
+ export function issueBlocksFetcher(f) {
22
+ return async (sectionId) => {
23
+ const opts = { parser: parseMany(parseIssueBlock) };
24
+ return request(f, `/issues/sections/${sectionId}/blocks`, opts);
25
+ };
26
+ }
27
+ export function contentsSearch(f) {
28
+ return async (issueId, q) => {
29
+ const opts = { parser: parseMany(parseIssueSectionContent), queryParams: { q } };
30
+ return request(f, `/issues/${issueId}/contents/search`, opts);
31
+ };
32
+ }
33
+ export function sectionContentsFetcher(f) {
34
+ return async (sectionId) => {
35
+ const opts = { parser: parseMany(parseContent) };
36
+ return request(f, `/issues/sections/${sectionId}/contents`, opts);
37
+ };
38
+ }
39
+ /******************************************************************************
40
+ * Parsers
41
+ ******************************************************************************/
42
+ export function parseIssueSummary(data, assocs) {
43
+ return {
44
+ id: data.id,
45
+ issueType: getAssoc(assocs, 'issue_types', data.issue_type_id),
46
+ kind: data.kind,
47
+ name: data.name,
48
+ color: data.color,
49
+ pdfUrl: data.pdf_url,
50
+ visual: parseVisual(data.visual, assocs),
51
+ meta: {
52
+ locales: parseLocalesMetadata(data.meta)
53
+ },
54
+ updatedAt: new Date(data.updated_at)
55
+ };
56
+ }
57
+ export function parseIssue(data, assocs) {
58
+ return {
59
+ ...parseIssueSummary(data, assocs),
60
+ advertisingKey: data.advertising_key,
61
+ descriptionText: data.description_text,
62
+ descriptionHtml: data.description_html,
63
+ metadata: data.metadata,
64
+ sections: data.sections.map((section) => parseIssueSectionSummary(section, assocs))
65
+ };
66
+ }
67
+ export function parseIssueSectionSummary(data, assocs) {
68
+ return {
69
+ id: data.id,
70
+ name: data.name,
71
+ advertisingKey: data.advertising_key,
72
+ color: data.color,
73
+ visual: parseVisual(data.visual, assocs),
74
+ meta: {
75
+ locales: parseLocalesMetadata(data.meta)
76
+ },
77
+ updatedAt: new Date(data.updated_at)
78
+ };
79
+ }
80
+ export function parseIssueSection(data, assocs) {
81
+ return {
82
+ ...parseIssueSectionSummary(data, assocs),
83
+ description: data.description
84
+ };
85
+ }
86
+ export function parseIssueBlock(data, assocs) {
87
+ return {
88
+ id: data.id,
89
+ configuration: getAssoc(assocs, 'issue_block_configurations', data.configuration_id),
90
+ textColor: data.text_color,
91
+ backgroundColor: data.background_color,
92
+ backgroundSvg: data.background_svg,
93
+ name: data.name,
94
+ description: data.description,
95
+ visual: parseVisual(data.visual, assocs),
96
+ slots: data.slots.map((slot) => parseIssueBlockSlot(slot, assocs)),
97
+ meta: {
98
+ locales: parseLocalesMetadata(data.meta)
99
+ },
100
+ updatedAt: new Date(data.updated_at)
101
+ };
102
+ }
103
+ export function parseIssueBlockSlot(data, assocs) {
104
+ return {
105
+ id: data.id,
106
+ content: getAssoc(assocs, 'contents', data.content_id)
107
+ };
108
+ }
109
+ export function parseIssueSectionContent(data, assocs) {
110
+ return {
111
+ ...parseContent(data, assocs),
112
+ section: getAssoc(assocs, 'issue_sections', data.section_id)
113
+ };
114
+ }
115
+ export function parseIssueType(data, _assocs) {
116
+ return {
117
+ id: data.id,
118
+ key: data.key,
119
+ name: data.name,
120
+ svgIcon: data.svg_icon,
121
+ meta: {
122
+ locales: parseLocalesMetadata(data.meta)
123
+ },
124
+ updatedAt: new Date(data.updated_at)
125
+ };
126
+ }
127
+ export function parseIssueBlockConfiguration(data, assocs) {
128
+ return {
129
+ id: data.id,
130
+ key: data.key,
131
+ minContents: data.min_contents,
132
+ maxContents: data.max_contents,
133
+ updatedAt: new Date(data.updated_at)
134
+ };
135
+ }
@@ -0,0 +1,65 @@
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 Visual } from './visuals';
5
+ export declare const mediaFetchers: (f: typeof fetch) => {
6
+ getMedia: () => Promise<import("../utils/api").ApiResponse<Media>>;
7
+ getMediaOrganization: (id: string) => Promise<import("../utils/api").ApiResponse<import("./organizations").Organization>>;
8
+ listMediaOrganizations: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./organizations").OrganizationSummary[]>>;
9
+ getMediaEvent: (id: string) => Promise<import("../utils/api").ApiResponse<import("./events").Event>>;
10
+ listMediaEvents: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./events").EventSummary[]>>;
11
+ listMediaEventBlocks: (id: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./profiles").ProfileBlockKind[]>>;
12
+ getMediaPerson: (id: string) => Promise<import("../utils/api").ApiResponse<import("./person").Person>>;
13
+ listMediaPersons: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./person").PersonSummary[]>>;
14
+ getMediaProject: (id: string) => Promise<import("../utils/api").ApiResponse<import("./projects").Project>>;
15
+ listMediaProjects: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./projects").ProjectSummary[]>>;
16
+ getMediaProfileType: (id: string) => Promise<import("../utils/api").ApiResponse<import("./profileType").ProfileType>>;
17
+ listMediaProfileTypes: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./profileType").ProfileTypeSummary[]>>;
18
+ };
19
+ export interface MediaSummary {
20
+ id: string;
21
+ organization: string;
22
+ name: string;
23
+ key: string;
24
+ sections: Section[];
25
+ }
26
+ export interface Media extends MediaSummary {
27
+ contact: MediaContact | null;
28
+ }
29
+ export type Section = {
30
+ id: string;
31
+ color: string;
32
+ position: number;
33
+ meta: {
34
+ locales: LocalesMetadata;
35
+ };
36
+ name: string;
37
+ slug: string;
38
+ visual: Visual;
39
+ };
40
+ export interface MediaContact {
41
+ phone: string | null;
42
+ email: string | null;
43
+ linkedin: string | null;
44
+ youtube: string | null;
45
+ instagram: string | null;
46
+ website: string | null;
47
+ facebook: string | null;
48
+ twitter: string | null;
49
+ meta: {
50
+ locales: LocalesMetadata;
51
+ };
52
+ }
53
+ export declare function parseMedia(data: ApiData, assocs: ApiAssocs): Media;
54
+ export declare function getMedia(f: typeof fetch): () => Promise<import("../utils/api").ApiResponse<Media>>;
55
+ export declare function getMediaOrganization(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<import("./organizations").Organization>>;
56
+ export declare function listMediaOrganizations(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./organizations").OrganizationSummary[]>>;
57
+ export declare function getMediaEvent(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<import("./events").Event>>;
58
+ export declare function listMediaEvents(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./events").EventSummary[]>>;
59
+ export declare function listMediaEventBlocks(f: typeof fetch): (id: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./profiles").ProfileBlockKind[]>>;
60
+ export declare function getMediaPerson(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<import("./person").Person>>;
61
+ export declare function listMediaPersons(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./person").PersonSummary[]>>;
62
+ export declare function getMediaProject(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<import("./projects").Project>>;
63
+ export declare function listMediaProjects(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./projects").ProjectSummary[]>>;
64
+ export declare function getMediaProfileType(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<import("./profileType").ProfileType>>;
65
+ export declare function listMediaProfileTypes(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<import("./profileType").ProfileTypeSummary[]>>;
@@ -0,0 +1,133 @@
1
+ import { parseMany } from '../utils/api';
2
+ import { requestPublisher } from '../utils/request';
3
+ import { parseVisual } from './visuals';
4
+ import { buildMeta } from '../utils/parseHelpers';
5
+ import { parseOrganization, parseOrganizationSummary } from './organizations';
6
+ import { parseEvent, parseEventSummary } from './events';
7
+ import { parseProfileBlock } from './profiles';
8
+ import { parsePerson, parsePersonSummary } from './person';
9
+ import { parseProject, parseProjectSummary } from './projects';
10
+ import { parseProfileType, parseProfileTypeSummary } from './profileType';
11
+ export const mediaFetchers = (f) => {
12
+ return {
13
+ getMedia: getMedia(f),
14
+ getMediaOrganization: getMediaOrganization(f),
15
+ listMediaOrganizations: listMediaOrganizations(f),
16
+ getMediaEvent: getMediaEvent(f),
17
+ listMediaEvents: listMediaEvents(f),
18
+ listMediaEventBlocks: listMediaEventBlocks(f),
19
+ getMediaPerson: getMediaPerson(f),
20
+ listMediaPersons: listMediaPersons(f),
21
+ getMediaProject: getMediaProject(f),
22
+ listMediaProjects: listMediaProjects(f),
23
+ getMediaProfileType: getMediaProfileType(f),
24
+ listMediaProfileTypes: listMediaProfileTypes(f)
25
+ };
26
+ };
27
+ function parseMediaContact(data, _assocs) {
28
+ return {
29
+ phone: data.phone,
30
+ email: data.email,
31
+ linkedin: data.linkedin,
32
+ website: data.website,
33
+ facebook: data.facebook,
34
+ twitter: data.twitter,
35
+ instagram: data.instagram,
36
+ youtube: data.youtube,
37
+ meta: buildMeta(data.locale)
38
+ };
39
+ }
40
+ export function parseMedia(data, assocs) {
41
+ const contact = data.localized_contact ? parseMediaContact(data.localized_contact, assocs) : null;
42
+ return {
43
+ id: data.id,
44
+ organization: data.organization_id,
45
+ name: data.name,
46
+ key: data.key,
47
+ sections: parseSections(data, assocs),
48
+ contact
49
+ };
50
+ }
51
+ function parseSections(data, assocs) {
52
+ return data.sections.map((section) => ({
53
+ id: section.id,
54
+ color: section.color,
55
+ position: section.position,
56
+ meta: buildMeta(section.localized.locale),
57
+ name: section.localized.name,
58
+ slug: section.localized.slug,
59
+ visual: parseVisual(section.visual, assocs)
60
+ }));
61
+ }
62
+ export function getMedia(f) {
63
+ return async () => {
64
+ const opts = { parser: parseMedia };
65
+ return requestPublisher(f, 'media/', opts);
66
+ };
67
+ }
68
+ export function getMediaOrganization(f) {
69
+ return async (id) => {
70
+ const opts = { parser: parseOrganization };
71
+ return requestPublisher(f, `media/organizations/${id}`, opts);
72
+ };
73
+ }
74
+ export function listMediaOrganizations(f) {
75
+ return async (params) => {
76
+ const opts = { parser: parseMany(parseOrganizationSummary), queryParams: params };
77
+ return requestPublisher(f, `media/organizations`, opts);
78
+ };
79
+ }
80
+ export function getMediaEvent(f) {
81
+ return async (id) => {
82
+ const opts = { parser: parseEvent };
83
+ return requestPublisher(f, `media/events/${id}`, opts);
84
+ };
85
+ }
86
+ export function listMediaEvents(f) {
87
+ return async (params) => {
88
+ const opts = { parser: parseMany(parseEventSummary), queryParams: params };
89
+ return requestPublisher(f, `media/events`, opts);
90
+ };
91
+ }
92
+ export function listMediaEventBlocks(f) {
93
+ return async (id, params) => {
94
+ const opts = { parser: parseMany(parseProfileBlock), queryParams: params };
95
+ return requestPublisher(f, `media/events/${id}/blocks`, opts);
96
+ };
97
+ }
98
+ export function getMediaPerson(f) {
99
+ return async (id) => {
100
+ const opts = { parser: parsePerson };
101
+ return requestPublisher(f, `media/people/${id}`, opts);
102
+ };
103
+ }
104
+ export function listMediaPersons(f) {
105
+ return async (params) => {
106
+ const opts = { parser: parseMany(parsePersonSummary), queryParams: params };
107
+ return requestPublisher(f, `media/people`, opts);
108
+ };
109
+ }
110
+ export function getMediaProject(f) {
111
+ return async (id) => {
112
+ const opts = { parser: parseProject };
113
+ return requestPublisher(f, `media/projects/${id}`, opts);
114
+ };
115
+ }
116
+ export function listMediaProjects(f) {
117
+ return async (params) => {
118
+ const opts = { parser: parseMany(parseProjectSummary), queryParams: params };
119
+ return requestPublisher(f, `media/projects`, opts);
120
+ };
121
+ }
122
+ export function getMediaProfileType(f) {
123
+ return async (id) => {
124
+ const opts = { parser: parseProfileType };
125
+ return requestPublisher(f, `media/profile-types/${id}`, opts);
126
+ };
127
+ }
128
+ export function listMediaProfileTypes(f) {
129
+ return async (params) => {
130
+ const opts = { parser: parseMany(parseProfileTypeSummary), queryParams: params };
131
+ return requestPublisher(f, `media/profile-types`, opts);
132
+ };
133
+ }
@@ -0,0 +1,31 @@
1
+ import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
2
+ import type { LocalesMetadata } from '../utils/response';
3
+ export interface MenuSummary {
4
+ id: string;
5
+ name: string;
6
+ key: string;
7
+ insertedAt: Date;
8
+ updatedAt: Date;
9
+ }
10
+ export declare const menuFetchers: (f: typeof fetch) => {
11
+ getMenu: (key: string) => Promise<import("../utils/api").ApiResponse<Menu>>;
12
+ listMenus: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<MenuSummary[]>>;
13
+ };
14
+ export declare function listMenus(f: typeof fetch): (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<MenuSummary[]>>;
15
+ export declare function getMenu(f: typeof fetch): (key: string) => Promise<import("../utils/api").ApiResponse<Menu>>;
16
+ export interface Menu extends MenuSummary {
17
+ meta: {
18
+ locales: LocalesMetadata;
19
+ };
20
+ items: MenuItem[];
21
+ }
22
+ export interface MenuItem {
23
+ id: string;
24
+ name: string;
25
+ url: string;
26
+ openNewTab: boolean;
27
+ items: MenuItem[];
28
+ }
29
+ export declare function parseMenuSummary(data: ApiData, _assocs: ApiAssocs): MenuSummary;
30
+ export declare function parseMenu(data: ApiData, _assocs: ApiAssocs): Menu;
31
+ export declare function parseMenuItem(data: ApiData, _assocs: ApiAssocs): MenuItem;
@@ -0,0 +1,49 @@
1
+ import { parseMany } from '../utils/api';
2
+ import { buildMeta } from '../utils/parseHelpers';
3
+ import { requestPublisher } from '../utils/request';
4
+ export const menuFetchers = (f) => {
5
+ return {
6
+ getMenu: getMenu(f),
7
+ listMenus: listMenus(f)
8
+ };
9
+ };
10
+ export function listMenus(f) {
11
+ return async (params) => {
12
+ const opts = { parser: parseMany(parseMenuSummary), queryParams: params };
13
+ return requestPublisher(f, `media/menus`, opts);
14
+ };
15
+ }
16
+ export function getMenu(f) {
17
+ return async (key) => {
18
+ const opts = { parser: parseMenu };
19
+ return requestPublisher(f, `media/menus/${key}`, opts);
20
+ };
21
+ }
22
+ export function parseMenuSummary(data, _assocs) {
23
+ return {
24
+ id: data.id,
25
+ name: data.name,
26
+ key: data.key,
27
+ insertedAt: new Date(data.inserted_at),
28
+ updatedAt: new Date(data.updated_at)
29
+ };
30
+ }
31
+ export function parseMenu(data, _assocs) {
32
+ return {
33
+ ...parseMenuSummary(data, _assocs),
34
+ items: getItems(data.localized, _assocs),
35
+ meta: buildMeta(data.localized.locale)
36
+ };
37
+ }
38
+ export function parseMenuItem(data, _assocs) {
39
+ return {
40
+ id: data.id,
41
+ name: data.name,
42
+ url: data.url,
43
+ openNewTab: data.open_new_tab,
44
+ items: getItems(data, _assocs)
45
+ };
46
+ }
47
+ function getItems(data, _assocs) {
48
+ return data.items.map((item) => parseMenuItem(item, _assocs));
49
+ }
@@ -17,7 +17,7 @@ export function listTopics(f) {
17
17
  export function parseTopicSummary(data, _assocs) {
18
18
  return {
19
19
  id: data.id,
20
- name: data.localized.name,
20
+ name: data.name,
21
21
  meta: {
22
22
  locales: parseLocalesMetadata(data.meta)
23
23
  },
@@ -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;