@yanolja-next/ncp-bo-sdk 0.0.1 → 0.0.2

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.cjs 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.js CHANGED
@@ -1 +1,30 @@
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;
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
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "//TODO(IABNCP-228)": "Rename this file to package.json after npm publish is complete",
3
3
  "name": "@yanolja-next/ncp-bo-sdk",
4
4
  "private": false,
5
- "version": "0.0.1",
5
+ "version": "0.0.2",
6
6
  "description": "NCP Backoffice SDK - Build and deploy service backoffice UIs",
7
7
  "type": "module",
8
8
  "main": "./dist/index.cjs",
package/dist/index.mjs DELETED
@@ -1,30 +0,0 @@
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
- };