@omerlo/omerlo-webkit 0.0.31 → 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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requestOmerlo } from '../utils/request';
|
|
2
2
|
export const integrationFetchers = (f) => {
|
|
3
3
|
return {
|
|
4
4
|
getReference: getReference(f)
|
|
@@ -7,7 +7,7 @@ export const integrationFetchers = (f) => {
|
|
|
7
7
|
export function getReference(f) {
|
|
8
8
|
return async (key) => {
|
|
9
9
|
const opts = { parser: parseReference };
|
|
10
|
-
return
|
|
10
|
+
return requestOmerlo(f, `/core/v2/references/${key}`, opts);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
export function parseReference(data, _assocs) {
|
|
@@ -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 }) => {
|
|
@@ -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
|
+
}
|