@yanolja-next/ncp-bo-sdk 0.0.1
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/dist/index.js +1 -0
- package/dist/index.mjs +30 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +24 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("axios"),i=require("path-to-regexp"),s="/services/:id/backoffice",u=i.match(s,{end:!1}),h=()=>{const e=u(window.location.pathname);return e?e.path:"/"},l=e=>`${e}-backoffice`,C=(e,t,r)=>{const n=c.create({baseURL:`${t}/services/${e}`,headers:{"Content-Type":"application/json",...r==null?void 0:r.headers}});return n.interceptors.request.use(a=>{a.headers["X-NCP-CLIENT-PROJECT-ID"]=d();const o=localStorage.getItem("session_token");return o&&(a.headers.Authorization=`Bearer ${o}`),a}),n},d=()=>{const t=new URLSearchParams(window.location.search).get("project-id");if(!t)throw new Error("Missing project ID");return t};exports.SERVICE_BACKOFFICE_ROUTE=s;exports.getApiClient=C;exports.getBasePath=h;exports.getComponentName=l;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import n from "axios";
|
|
2
|
+
import { match as c } from "path-to-regexp";
|
|
3
|
+
const i = "/services/:id/backoffice", h = c(i, { end: !1 }), l = () => {
|
|
4
|
+
const e = h(window.location.pathname);
|
|
5
|
+
return e ? e.path : "/";
|
|
6
|
+
}, p = (e) => `${e}-backoffice`, C = (e, t, r) => {
|
|
7
|
+
const o = n.create({
|
|
8
|
+
baseURL: `${t}/services/${e}`,
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
...r == null ? void 0 : r.headers
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return o.interceptors.request.use((a) => {
|
|
15
|
+
a.headers["X-NCP-CLIENT-PROJECT-ID"] = m();
|
|
16
|
+
const s = localStorage.getItem("session_token");
|
|
17
|
+
return s && (a.headers.Authorization = `Bearer ${s}`), a;
|
|
18
|
+
}), o;
|
|
19
|
+
}, m = () => {
|
|
20
|
+
const t = new URLSearchParams(window.location.search).get("project-id");
|
|
21
|
+
if (!t)
|
|
22
|
+
throw new Error("Missing project ID");
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
i as SERVICE_BACKOFFICE_ROUTE,
|
|
27
|
+
C as getApiClient,
|
|
28
|
+
l as getBasePath,
|
|
29
|
+
p as getComponentName
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare const SERVICE_BACKOFFICE_ROUTE = "/services/:id/backoffice";
|
|
3
|
+
export declare const getBasePath: () => string;
|
|
4
|
+
export declare const getComponentName: (serviceName: string) => string;
|
|
5
|
+
export declare const getApiClient: (serviceName: string, baseUrl: string, options?: ApiClientOptions) => AxiosInstance;
|
|
6
|
+
interface ApiClientOptions {
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"//TODO(IABNCP-228)": "Rename this file to package.json after npm publish is complete",
|
|
3
|
+
"name": "@yanolja-next/ncp-bo-sdk",
|
|
4
|
+
"private": false,
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"description": "NCP Backoffice SDK - Build and deploy service backoffice UIs",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"types": "./dist/src/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/src/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"axios": "^1.7.2",
|
|
22
|
+
"path-to-regexp": "^8.3.0"
|
|
23
|
+
}
|
|
24
|
+
}
|