@omerlo/omerlo-webkit 0.0.12 → 0.0.14

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
@@ -60,7 +60,7 @@ Then you need to use the component `OmerloWebkit` and give him the `userSession`
60
60
  ```ts
61
61
  // +layout.svelte
62
62
  <script lang="ts">
63
- import { OmerloWebkit } from 'omerlo-webkit'
63
+ import { OmerloWebkit } from '$omerlo'
64
64
  let { data, children } = $props();
65
65
  </script>
66
66
 
@@ -76,7 +76,7 @@ To use reader API, you can use the function `useReader` passing the sveltekit `f
76
76
  ```ts
77
77
  // +page.ts
78
78
  import type { PageLoad } from './$types';
79
- import { useReader } from 'omerlo-webkit';
79
+ import { useReader } from '$omerlo';
80
80
 
81
81
  export const load: PageLoad = async ({ fetch }) => {
82
82
  const oauthProviders = await useReader(fetch).listOauthProviders();
@@ -8,7 +8,7 @@ export declare const useReader: (f: typeof fetch) => {
8
8
  getIssue: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Issue>>;
9
9
  getBlocks: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").IssueBlock[]>>;
10
10
  searchContents: (issueId: string, q: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").SectionContent[]>>;
11
- getSectionContents: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Content[]>>;
11
+ getSectionContents: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").ContentSummary[]>>;
12
12
  };
13
13
  getMenu: (key: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Menu>>;
14
14
  listMenus: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").MenuSummary[]>>;
@@ -36,6 +36,7 @@ export declare const useReader: (f: typeof fetch) => {
36
36
  getOauthUser: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").OauthUser>>;
37
37
  registerDevice: (params: import("./reader").DeviceParams) => Promise<import("./reader/utils/api").ApiResponse<unknown>>;
38
38
  userInfo: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").UserInfo>>;
39
+ userEntitlements: () => Promise<import("./reader/utils/api").ApiResponse<import("./reader").UserEntitlement[]>>;
39
40
  verifyAccount: (params: import("./reader").VerifyAccountParams) => void;
40
41
  validateAccount: (params: import("./reader").ValidateAccountParams) => void;
41
42
  };
@@ -1,5 +1,6 @@
1
1
  export declare const accountsFetchers: (f: typeof fetch) => {
2
2
  userInfo: () => Promise<import("../utils/api").ApiResponse<UserInfo>>;
3
+ userEntitlements: () => Promise<import("../utils/api").ApiResponse<UserEntitlement[]>>;
3
4
  verifyAccount: (params: VerifyAccountParams) => void;
4
5
  validateAccount: (params: ValidateAccountParams) => void;
5
6
  };
@@ -17,3 +18,8 @@ export interface UserInfo {
17
18
  name: string;
18
19
  email: string;
19
20
  }
21
+ export declare function getUserEntitlements(f: typeof fetch): () => Promise<import("../utils/api").ApiResponse<UserEntitlement[]>>;
22
+ export interface UserEntitlement {
23
+ id: string;
24
+ feature_key: string;
25
+ }
@@ -1,7 +1,9 @@
1
+ import { parseMany } from '../utils/api';
1
2
  import { request } from '../utils/request';
2
3
  export const accountsFetchers = (f) => {
3
4
  return {
4
5
  userInfo: getUserInfo(f),
6
+ userEntitlements: getUserEntitlements(f),
5
7
  verifyAccount: verifyAccount(f),
6
8
  validateAccount: validateAccount(f)
7
9
  };
@@ -40,3 +42,18 @@ function parseUserInfo(data, _assoc) {
40
42
  email: data.email
41
43
  };
42
44
  }
45
+ //
46
+ // Get user's entitlements associated to the bearer token (Platform).
47
+ //
48
+ export function getUserEntitlements(f) {
49
+ return async () => {
50
+ const opts = { parser: parseMany(parseUserEntitlement) };
51
+ return request(f, '/account/me/entitlements', opts);
52
+ };
53
+ }
54
+ function parseUserEntitlement(data, _assoc) {
55
+ return {
56
+ id: data.id,
57
+ feature_key: data.feature_key
58
+ };
59
+ }
@@ -10,8 +10,8 @@ export declare const contentsFetchers: (f: typeof fetch) => {
10
10
  listContents: (params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
11
11
  };
12
12
  export interface ContentSeo {
13
- title: string;
14
- description: string;
13
+ title: string | null;
14
+ description: string | null;
15
15
  }
16
16
  export interface ContentSummary {
17
17
  id: string;
@@ -37,6 +37,7 @@ export interface ContentSummary {
37
37
  authors: (PersonSummary | OrganizationSummary)[];
38
38
  }
39
39
  export interface Content extends ContentSummary {
40
+ seo: ContentSeo;
40
41
  blocks: ContentBlock[];
41
42
  }
42
43
  export type ContentBlockRichtext = {
@@ -73,7 +74,7 @@ export type ContentBlockQuote = {
73
74
  export type ContentBlockRelatedContents = {
74
75
  id: string;
75
76
  kind: 'related-contents';
76
- contents: Content[];
77
+ contents: ContentSummary[];
77
78
  visual: Visual | null;
78
79
  template: ContentBlockTemplate | null;
79
80
  };
@@ -116,7 +116,7 @@ function getBlockTemplate(data, assocs) {
116
116
  ? getAssoc(assocs, 'block_templates', data.template_id)
117
117
  : null;
118
118
  }
119
- function getBlockContent(data, assocs) {
119
+ function getBlockContents(data, assocs) {
120
120
  return data.related_contents ? getAssocs(assocs, 'contents', data.related_contents) : [];
121
121
  }
122
122
  function parseContentBlockRichtext(data, assocs) {
@@ -147,7 +147,7 @@ function parseContentBlockQuote(data, assocs) {
147
147
  };
148
148
  }
149
149
  function parseContentBlockRelatedContents(data, assocs) {
150
- const contents = getBlockContent(data, assocs);
150
+ const contents = getBlockContents(data, assocs);
151
151
  return {
152
152
  ...baseBlock(data, assocs),
153
153
  contents
@@ -1,17 +1,17 @@
1
1
  import { type LocalesMetadata } from '../utils/response';
2
2
  import { type Visual } from './visuals';
3
3
  import { type ApiAssocs, type ApiData } from '../utils/api';
4
- import { type Content, type ContentSummary } from './contents';
4
+ import { type ContentSummary } from './contents';
5
5
  export declare const magazineFetchers: (f: typeof fetch) => {
6
6
  getIssue: (id: string) => Promise<import("../utils/api").ApiResponse<Issue>>;
7
7
  getBlocks: (sectionId: string) => Promise<import("../utils/api").ApiResponse<IssueBlock[]>>;
8
8
  searchContents: (issueId: string, q: string) => Promise<import("../utils/api").ApiResponse<SectionContent[]>>;
9
- getSectionContents: (sectionId: string) => Promise<import("../utils/api").ApiResponse<Content[]>>;
9
+ getSectionContents: (sectionId: string) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
10
10
  };
11
11
  export declare function issueFetcher(f: typeof fetch): (id: string) => Promise<import("../utils/api").ApiResponse<Issue>>;
12
12
  export declare function issueBlocksFetcher(f: typeof fetch): (sectionId: string) => Promise<import("../utils/api").ApiResponse<IssueBlock[]>>;
13
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[]>>;
14
+ export declare function sectionContentsFetcher(f: typeof fetch): (sectionId: string) => Promise<import("../utils/api").ApiResponse<ContentSummary[]>>;
15
15
  /******************************************************************************
16
16
  * Parsers
17
17
  ******************************************************************************/
@@ -23,7 +23,7 @@ export declare function parseIssueBlock(data: ApiData, assocs: ApiAssocs): Issue
23
23
  export declare function parseIssueBlockSlot(data: ApiData, assocs: ApiAssocs): IssueBlockSlot;
24
24
  export declare function parseIssueSectionContent(data: ApiData, assocs: ApiAssocs): SectionContent;
25
25
  export declare function parseIssueType(data: ApiData, _assocs: ApiAssocs): IssueType;
26
- export declare function parseIssueBlockConfiguration(data: ApiData, assocs: ApiAssocs): IssueBlockConfiguration;
26
+ export declare function parseIssueBlockConfiguration(data: ApiData): IssueBlockConfiguration;
27
27
  /******************************************************************************
28
28
  * Interfaces
29
29
  ******************************************************************************/
@@ -88,7 +88,7 @@ export interface IssueBlock {
88
88
  };
89
89
  updatedAt: Date;
90
90
  }
91
- export interface SectionContent extends Content {
91
+ export interface SectionContent extends ContentSummary {
92
92
  section: IssueSectionSummary;
93
93
  }
94
94
  export interface IssueBlockConfiguration {
@@ -3,7 +3,7 @@ import { parseVisual } from './visuals';
3
3
  import { parseMany } from '../utils/api';
4
4
  import { getAssoc } from '../utils/assocs';
5
5
  import { request } from '../utils/request';
6
- import { parseContent } from './contents';
6
+ import { parseContentSummary } from './contents';
7
7
  export const magazineFetchers = (f) => {
8
8
  return {
9
9
  getIssue: issueFetcher(f),
@@ -32,7 +32,7 @@ export function contentsSearch(f) {
32
32
  }
33
33
  export function sectionContentsFetcher(f) {
34
34
  return async (sectionId) => {
35
- const opts = { parser: parseMany(parseContent) };
35
+ const opts = { parser: parseMany(parseContentSummary) };
36
36
  return request(f, `/issues/sections/${sectionId}/contents`, opts);
37
37
  };
38
38
  }
@@ -108,7 +108,7 @@ export function parseIssueBlockSlot(data, assocs) {
108
108
  }
109
109
  export function parseIssueSectionContent(data, assocs) {
110
110
  return {
111
- ...parseContent(data, assocs),
111
+ ...parseContentSummary(data, assocs),
112
112
  section: getAssoc(assocs, 'issue_sections', data.section_id)
113
113
  };
114
114
  }
@@ -124,7 +124,7 @@ export function parseIssueType(data, _assocs) {
124
124
  updatedAt: new Date(data.updated_at)
125
125
  };
126
126
  }
127
- export function parseIssueBlockConfiguration(data, assocs) {
127
+ export function parseIssueBlockConfiguration(data) {
128
128
  return {
129
129
  id: data.id,
130
130
  key: data.key,
@@ -4,7 +4,7 @@ import { type EventSummary } from './events';
4
4
  import { type Organization, type OrganizationSummary } from './organizations';
5
5
  import type { ApiAssocs, ApiData } from '../utils/api';
6
6
  import type { LocalesMetadata } from '../utils/response';
7
- import type { Content } from './contents';
7
+ import type { ContentSummary } from './contents';
8
8
  import { type Image, type Slideshow, type Video } from './visuals';
9
9
  export type Profile = Person | Project | Event | Organization;
10
10
  export type ProfileSummary = PersonSummary | ProjectSummary | EventSummary | OrganizationSummary;
@@ -58,7 +58,7 @@ export type ProfileBlock = {
58
58
  updatedAt: Date;
59
59
  };
60
60
  export interface ProfileBlockContents extends ProfileBlock {
61
- contents: Content[];
61
+ contents: ContentSummary[];
62
62
  }
63
63
  export interface ProfileBlockRelations extends ProfileBlock {
64
64
  profiles: ProfileSummary[];
@@ -8,7 +8,7 @@ export declare const fetchers: (f: typeof fetch) => {
8
8
  getIssue: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").Issue>>;
9
9
  getBlocks: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").IssueBlock[]>>;
10
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[]>>;
11
+ getSectionContents: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").ContentSummary[]>>;
12
12
  };
13
13
  getMenu: (key: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/menu").Menu>>;
14
14
  listMenus: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/menu").MenuSummary[]>>;
@@ -36,6 +36,7 @@ export declare const fetchers: (f: typeof fetch) => {
36
36
  getOauthUser: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/oauth").OauthUser>>;
37
37
  registerDevice: (params: import("./endpoints/device").DeviceParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
38
38
  userInfo: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/accounts").UserInfo>>;
39
+ userEntitlements: () => Promise<import("./utils/api").ApiResponse<import("./endpoints/accounts").UserEntitlement[]>>;
39
40
  verifyAccount: (params: import("./endpoints/accounts").VerifyAccountParams) => void;
40
41
  validateAccount: (params: import("./endpoints/accounts").ValidateAccountParams) => void;
41
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omerlo/omerlo-webkit",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",