@omerlo/omerlo-webkit 0.0.30 → 0.0.32

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.
@@ -11,6 +11,7 @@ export declare const useReader: (f: typeof fetch) => {
11
11
  searchContents: (issueId: string, q: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").SectionContent[]>>;
12
12
  getSectionContents: (sectionId: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").ContentSummary[]>>;
13
13
  };
14
+ getReference: (key: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader/endpoints/integration").Reference>>;
14
15
  listProjects: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").ProjectSummary[]>>;
15
16
  getProject: (id: string) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").Project>>;
16
17
  listPeople: (params?: Partial<import("./reader/utils/api").PagingParams>) => Promise<import("./reader/utils/api").ApiResponse<import("./reader").PersonSummary[]>>;
@@ -0,0 +1,11 @@
1
+ import type { ApiAssocs, ApiData } from '../utils/api';
2
+ export declare const integrationFetchers: (f: typeof fetch) => {
3
+ getReference: (key: string) => Promise<import("../utils/api").ApiResponse<Reference>>;
4
+ };
5
+ export declare function getReference(f: typeof fetch): (key: string) => Promise<import("../utils/api").ApiResponse<Reference>>;
6
+ export interface Reference {
7
+ id: string;
8
+ provider: string;
9
+ urn: string;
10
+ }
11
+ export declare function parseReference(data: ApiData, _assocs: ApiAssocs): Reference;
@@ -0,0 +1,19 @@
1
+ import { requestOmerlo } from '../utils/request';
2
+ export const integrationFetchers = (f) => {
3
+ return {
4
+ getReference: getReference(f)
5
+ };
6
+ };
7
+ export function getReference(f) {
8
+ return async (key) => {
9
+ const opts = { parser: parseReference };
10
+ return requestOmerlo(f, `/core/v2/references/${key}`, opts);
11
+ };
12
+ }
13
+ export function parseReference(data, _assocs) {
14
+ return {
15
+ id: data.id,
16
+ provider: data.provider,
17
+ urn: data.urn
18
+ };
19
+ }
@@ -11,6 +11,7 @@ export declare const fetchers: (f: typeof fetch) => {
11
11
  searchContents: (issueId: string, q: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/magazines").SectionContent[]>>;
12
12
  getSectionContents: (sectionId: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/contents").ContentSummary[]>>;
13
13
  };
14
+ getReference: (key: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/integration").Reference>>;
14
15
  listProjects: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/projects").ProjectSummary[]>>;
15
16
  getProject: (id: string) => Promise<import("./utils/api").ApiResponse<import("./endpoints/projects").Project>>;
16
17
  listPeople: (params?: Partial<import("./utils/api").PagingParams>) => Promise<import("./utils/api").ApiResponse<import("./endpoints/person").PersonSummary[]>>;
@@ -1,6 +1,7 @@
1
1
  import { accountsFetchers } from './endpoints/accounts';
2
2
  import { categoriesFetchers } from './endpoints/categories';
3
3
  import { deviceFetchers } from './endpoints/device';
4
+ import { integrationFetchers } from './endpoints/integration';
4
5
  import { notificationFetchers } from './endpoints/notification';
5
6
  import { oauthFetchers } from './endpoints/oauth';
6
7
  import { contentsFetchers } from './endpoints/contents';
@@ -27,6 +28,7 @@ export const fetchers = (f) => {
27
28
  ...eventFetchers(f),
28
29
  ...personFetchers(f),
29
30
  ...projectFetchers(f),
31
+ ...integrationFetchers(f),
30
32
  notifications: notificationFetchers(f),
31
33
  magazines: {
32
34
  ...magazineFetchers(f),
@@ -64,6 +64,10 @@ export const proxyHook = async ({ event, resolve }) => {
64
64
  event.url.pathname = event.url.pathname.replace('/api/publisher/', `/api/public/publisher/v2/`);
65
65
  return handleApiProxy({ event, resolve });
66
66
  }
67
+ if (event.url.pathname.startsWith('/api/omerlo/')) {
68
+ event.url.pathname = event.url.pathname.replace('/api/omerlo/', '/api/public/');
69
+ return handleApiProxy({ event, resolve });
70
+ }
67
71
  return resolve(event);
68
72
  };
69
73
  export const handleUserToken = async ({ event, resolve }) => {
@@ -11,7 +11,9 @@ export interface ApiResponse<T> {
11
11
  meta: ApiResponseMeta | null;
12
12
  }
13
13
  export interface ApiResponseMeta {
14
+ base: string;
14
15
  next: string | null;
16
+ previous: string | null;
15
17
  }
16
18
  export interface ApiParams {
17
19
  locale?: string | null;
@@ -16,4 +16,10 @@ export declare function dirtyRequest(f: typeof fetch, path: string, opts: DirtyF
16
16
  */
17
17
  export declare function requestPublisher<T>(f: typeof fetch, path: string, opts: Partial<FetchOptions<T>>): Promise<ApiResponse<T>>;
18
18
  export declare function dirtyRequestPublisher(f: typeof fetch, path: string, opts: DirtyFetchOptions): Promise<Response>;
19
+ /**
20
+ * NOTE: This is for OLD api and will be removed once every API will
21
+ * be developped in Reader.
22
+ */
23
+ export declare function requestOmerlo<T>(f: typeof fetch, path: string, opts: Partial<FetchOptions<T>>): Promise<ApiResponse<T>>;
24
+ export declare function dirtyRequestOmerlo(f: typeof fetch, path: string, opts: DirtyFetchOptions): Promise<Response>;
19
25
  export {};
@@ -62,3 +62,24 @@ export async function dirtyRequestPublisher(f, path, opts) {
62
62
  }
63
63
  return f(path.toString(), opts);
64
64
  }
65
+ /**
66
+ * NOTE: This is for OLD api and will be removed once every API will
67
+ * be developped in Reader.
68
+ */
69
+ export async function requestOmerlo(f, path, opts) {
70
+ const { body, headers, method, queryParams, parser } = parseRequestOpts(opts);
71
+ return dirtyRequestOmerlo(f, path, { body, headers, method, queryParams }).then(async (resp) => {
72
+ return parseApiResponse(resp, parser);
73
+ });
74
+ }
75
+ export async function dirtyRequestOmerlo(f, path, opts) {
76
+ const queryParams = new URLSearchParams();
77
+ path = `/api/omerlo/${path}`;
78
+ if (opts?.queryParams) {
79
+ Object.entries(opts.queryParams).forEach(([key, value]) => {
80
+ queryParams.append(key, String(value));
81
+ });
82
+ path = `${path}?${queryParams}`;
83
+ }
84
+ return f(path.toString(), opts);
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omerlo/omerlo-webkit",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",