@omerlo/omerlo-webkit 0.0.14 → 0.0.15

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.
@@ -5,6 +5,7 @@ export declare const useReader: (f: typeof fetch) => {
5
5
  unsubscribeFromTopic: (params: import("./reader").SubscriptionParams) => Promise<import("./reader/utils/api").ApiResponse<unknown>>;
6
6
  };
7
7
  magazines: {
8
+ listReleases: (distributionId: string, params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader/endpoints/distributions").Release[]>>;
8
9
  getIssue: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Issue>>;
9
10
  getBlocks: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").IssueBlock[]>>;
10
11
  searchContents: (issueId: string, q: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").SectionContent[]>>;
@@ -117,7 +117,9 @@ function getBlockTemplate(data, assocs) {
117
117
  : null;
118
118
  }
119
119
  function getBlockContents(data, assocs) {
120
- return data.related_contents ? getAssocs(assocs, 'contents', data.related_contents) : [];
120
+ return data.related_contents
121
+ ? getAssocs(assocs, 'contents', data.related_contents)
122
+ : [];
121
123
  }
122
124
  function parseContentBlockRichtext(data, assocs) {
123
125
  return {
@@ -0,0 +1,14 @@
1
+ import { type ApiAssocs, type ApiData, type PagingParams } from '../utils/api';
2
+ import type { Issue } from './magazines';
3
+ export declare const distributionFetchers: (f: typeof fetch) => {
4
+ listReleases: (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
5
+ };
6
+ export declare function releasesFetcher(f: typeof fetch): (distributionId: string, params?: Partial<PagingParams>) => Promise<import("../utils/api").ApiResponse<Release[]>>;
7
+ export interface Release {
8
+ id: string;
9
+ issue: Issue;
10
+ startsAt: Date;
11
+ endsAt: Date | null;
12
+ updatedAt: Date;
13
+ }
14
+ export declare function parseRelease(data: ApiData, assocs: ApiAssocs): Release;
@@ -0,0 +1,25 @@
1
+ import { parseMany } from '../utils/api';
2
+ import { getAssoc } from '../utils/assocs';
3
+ import { parseDate } from '../utils/parseHelpers';
4
+ import { request } from '../utils/request';
5
+ export const distributionFetchers = (f) => {
6
+ return {
7
+ listReleases: releasesFetcher(f)
8
+ };
9
+ };
10
+ export function releasesFetcher(f) {
11
+ return async (distributionId, params) => {
12
+ const opts = { parser: parseMany(parseRelease), queryParams: params };
13
+ return request(f, `/distributions/${distributionId}/releases`, opts);
14
+ };
15
+ }
16
+ export function parseRelease(data, assocs) {
17
+ return {
18
+ id: data.id,
19
+ issue: getAssoc(assocs, 'issues', data.issue_id),
20
+ // isPublished: data.is_published,
21
+ startsAt: new Date(data.starts_at),
22
+ endsAt: parseDate(data.ends_at),
23
+ updatedAt: new Date(data.updated_at)
24
+ };
25
+ }
@@ -5,6 +5,7 @@ export declare const fetchers: (f: typeof fetch) => {
5
5
  unsubscribeFromTopic: (params: import("./endpoints/notification").SubscriptionParams) => Promise<import("./utils/api").ApiResponse<unknown>>;
6
6
  };
7
7
  magazines: {
8
+ listReleases: (distributionId: string, params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/distributions").Release[]>>;
8
9
  getIssue: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").Issue>>;
9
10
  getBlocks: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").IssueBlock[]>>;
10
11
  searchContents: (issueId: string, q: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").SectionContent[]>>;
@@ -8,6 +8,7 @@ import { mediaFetchers } from './endpoints/media';
8
8
  import { organizationFetchers } from './endpoints/organizations';
9
9
  import { menuFetchers } from './endpoints/menu';
10
10
  import { magazineFetchers } from './endpoints/magazines';
11
+ import { distributionFetchers } from './endpoints/distributions';
11
12
  export const fetchers = (f) => {
12
13
  return {
13
14
  ...accountsFetchers(f),
@@ -19,6 +20,9 @@ export const fetchers = (f) => {
19
20
  ...organizationFetchers(f),
20
21
  ...menuFetchers(f),
21
22
  notifications: notificationFetchers(f),
22
- magazines: magazineFetchers(f)
23
+ magazines: {
24
+ ...magazineFetchers(f),
25
+ ...distributionFetchers(f)
26
+ }
23
27
  };
24
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omerlo/omerlo-webkit",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",