@omerlo/omerlo-webkit 0.0.17 → 0.0.19

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 CHANGED
@@ -1,13 +1,13 @@
1
1
  # Omerlo WebKit
2
2
 
3
- This webkit is a wapper arround Omerlo's API to create quickly a website using Omerlo.
3
+ This webkit is a wrapper around Omerlo's API to create quickly a website using Omerlo solutions.
4
4
 
5
- The user's session and tokens will be managed by Omerlo Webkit. The connection state is dispatched
5
+ User's session and tokens will be managed by Omerlo Webkit. The connection state is dispatched
6
6
  over all window's tab, no need to refresh other tabs.
7
7
 
8
8
  ## Using the omerlo webkit
9
9
 
10
- Install the package `omerlo-webkit`
10
+ Install `omerlo-webkit` package
11
11
 
12
12
  ```sh
13
13
  npm i @omerlo/omerlo-webkit
@@ -5,6 +5,7 @@ import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
5
5
  import { type LocalesMetadata } from '../utils/response';
6
6
  import type { PersonSummary } from './person';
7
7
  import type { OrganizationSummary } from './organizations';
8
+ export type AuthorSummary = PersonSummary | OrganizationSummary;
8
9
  export declare const contentsFetchers: (f: typeof fetch) => {
9
10
  getContent: (id: string) => Promise<import("../utils/api").ApiResponse<Content>>;
10
11
  listContents: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
@@ -34,7 +35,7 @@ export interface ContentSummary {
34
35
  meta: {
35
36
  locales: LocalesMetadata;
36
37
  };
37
- authors: (PersonSummary | OrganizationSummary)[];
38
+ authors: AuthorSummary[];
38
39
  }
39
40
  export interface Content extends ContentSummary {
40
41
  seo: ContentSeo;
@@ -35,6 +35,10 @@ export function listContents(f) {
35
35
  export function parseContentSummary(data, assocs) {
36
36
  if (data.localized) {
37
37
  // NOTE: This is to support publisher public api v2
38
+ const metadata = (data.metadata ?? []).reduce((acc, { key, value }) => {
39
+ acc[key] = value;
40
+ return acc;
41
+ }, {});
38
42
  return {
39
43
  id: data.id,
40
44
  template: getAssoc(assocs, 'templates', data.template_id),
@@ -53,7 +57,7 @@ export function parseContentSummary(data, assocs) {
53
57
  subtitleText: data.localized.subtitle_text,
54
58
  visual: parseVisual(data.localized.visual, assocs),
55
59
  meta: buildMeta(data.localized.locale),
56
- metadata: {},
60
+ metadata: metadata,
57
61
  authors: getAssocs(assocs, 'profiles', data.localized.author_ids)
58
62
  };
59
63
  }
@@ -76,7 +80,7 @@ export function parseContentSummary(data, assocs) {
76
80
  subtitleText: data.subtitle_text,
77
81
  visual: parseVisual(data.visual, assocs),
78
82
  meta: { locales: parseLocalesMetadata(data.meta) },
79
- metadata: {},
83
+ metadata: data.metadata,
80
84
  authors: getAssocs(assocs, 'profiles', data.author_ids)
81
85
  };
82
86
  }
@@ -13,7 +13,8 @@ export function parseEventSummary(data, assocs) {
13
13
  kind: 'event',
14
14
  type: data.type,
15
15
  isAllDay: data.is_all_day,
16
- profileImageURL: data.logo_image_url,
16
+ // NOTE remove logo_image_url once using reader api
17
+ profileImageURL: data.logo_image_url || data.profile_image_url,
17
18
  coverImageURL: data.cover_image_url,
18
19
  subscriptionURL: data.subscription_url,
19
20
  name,
@@ -35,6 +35,9 @@ export interface IssueSummary {
35
35
  color: string | null;
36
36
  pdfUrl: string | null;
37
37
  visual: Visual | null;
38
+ metadata: {
39
+ [key: string]: string;
40
+ };
38
41
  meta: {
39
42
  locales: LocalesMetadata;
40
43
  };
@@ -44,9 +47,6 @@ export interface Issue extends IssueSummary {
44
47
  advertisingKey: string | null;
45
48
  descriptionHtml: string | null;
46
49
  descriptionText: string | null;
47
- metadata: {
48
- [key: string]: string;
49
- };
50
50
  sections: IssueSectionSummary[];
51
51
  }
52
52
  export interface IssueType {
@@ -48,6 +48,7 @@ export function parseIssueSummary(data, assocs) {
48
48
  color: data.color,
49
49
  pdfUrl: data.pdf_url,
50
50
  visual: parseVisual(data.visual, assocs),
51
+ metadata: data.metadata,
51
52
  meta: {
52
53
  locales: parseLocalesMetadata(data.meta)
53
54
  },
@@ -60,7 +61,6 @@ export function parseIssue(data, assocs) {
60
61
  advertisingKey: data.advertising_key,
61
62
  descriptionText: data.description_text,
62
63
  descriptionHtml: data.description_html,
63
- metadata: data.metadata,
64
64
  sections: data.sections.map((section) => parseIssueSectionSummary(section, assocs))
65
65
  };
66
66
  }
@@ -20,7 +20,8 @@ export function parseOrganizationSummary(data, assocs) {
20
20
  profileType: getAssoc(assocs, 'profile_types', data.profile_type_id),
21
21
  kind: 'organization',
22
22
  name: data.name,
23
- profileImageURL: data.logo_image_url,
23
+ // NOTE remove logo_image_url once using reader api
24
+ profileImageURL: data.logo_image_url || data.profile_image_url,
24
25
  meta: buildMeta(data.localized?.locale),
25
26
  summaryHtml: data.localized?.summary_html,
26
27
  summaryText: data.localized?.summary_text,
@@ -11,7 +11,8 @@ export function parsePersonSummary(data, assocs) {
11
11
  lastName: data.last_name,
12
12
  otherName: data.other_name,
13
13
  pronoun: data.pronoun,
14
- profileImageURL: data.avatar_image_url,
14
+ // NOTE remove logo_image_url once using reader api
15
+ profileImageURL: data.avatar_image_url || data.profile_image_url,
15
16
  coverImageURL: data.cover_image_url,
16
17
  meta: buildMeta(data.localized?.locale),
17
18
  summaryHtml: data.localized?.summary_html,
@@ -7,7 +7,8 @@ export function parseProjectSummary(data, assocs) {
7
7
  id: data.id,
8
8
  profileType: getAssoc(assocs, 'profile_types', data.profile_type_id),
9
9
  kind: 'project',
10
- profileImageURL: data.logo_image_url,
10
+ // NOTE remove logo_image_url once using reader api
11
+ profileImageURL: data.logo_image_url || data.profile_image_url,
11
12
  coverImageURL: data.cover_image_url,
12
13
  meta: buildMeta(data.localized?.locale),
13
14
  name: data.localized?.name,
@@ -4,7 +4,7 @@ import { parseContentBlockTemplate, parseContentTemplate } from './endpoints/con
4
4
  import { parseProfileTypeSummary } from './endpoints/profileType';
5
5
  import { registerAssocParser } from './utils/assocs';
6
6
  import { parseContentSummary } from './endpoints/contents';
7
- import { parseIssueBlockConfiguration, parseIssueType } from './endpoints/magazines';
7
+ import { parseIssueBlockConfiguration, parseIssueSummary, parseIssueType } from './endpoints/magazines';
8
8
  export * from './stores/user_session';
9
9
  export function initReader() {
10
10
  registerAssocParser('categories', parseCategory);
@@ -14,6 +14,7 @@ export function initReader() {
14
14
  registerAssocParser('profile_block_types', parseProfileBlock);
15
15
  registerAssocParser('content_block_templates', parseContentBlockTemplate);
16
16
  registerAssocParser('contents', parseContentSummary);
17
+ registerAssocParser('issues', parseIssueSummary);
17
18
  registerAssocParser('issue_types', parseIssueType);
18
19
  registerAssocParser('issue_block_configurations', parseIssueBlockConfiguration);
19
20
  // NOTE: Those ones are for retro compatibility with publisher public api v2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omerlo/omerlo-webkit",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",
@@ -64,7 +64,7 @@
64
64
  "typescript-eslint": "^8.0.0",
65
65
  "vite": "^5.0.11"
66
66
  },
67
- "description": "This webkit is a wapper arround Omerlo's API to create quickly a website using Omerlo.",
67
+ "description": "Omerlo's API wrapper to help developing blazing fast website.",
68
68
  "main": "eslint.config.js",
69
69
  "directories": {},
70
70
  "repository": {