@epam/statgpt-shared-toolkit 0.2.0-rc.2 → 0.2.0-rc.3
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/constants/index.d.ts +2 -0
- package/constants/onboarding.d.ts +1 -0
- package/constants/share.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +43 -41
- package/package.json +1 -1
package/constants/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ONBOARDING_MODEL_POSTFIX = "onboarding";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SHARE_CONVERSATION_ROUTE = "share";
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N={CHAT:"/api/chat"},S="CUSTOM_PERIOD",a={decimal:"0.0",decimalSymbol:",",digitGroupingSymbol:" "},O="application/json",T="Content-Type",E="Api-Key",l="X-CONVERSATION-ID",C={BAD_REQUEST:400,UNAUTHORIZED:401,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,CONFLICT:409,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504},u="onboarding",I="share";var R=(e=>(e.MONTH="month",e.DAY="day",e))(R||{}),A=(e=>(e.UK="uk",e.EN="en",e))(A||{}),_=(e=>(e.IN="in",e.BETWEEN="between",e))(_||{});function g(e,t){const n=e.split("/")[0],r=t.split("/").pop();return`${n}/${r}`}const s=e=>(e==null?void 0:e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").replace(/-/g," "))||"";function D(e,t){return`${e==null?void 0:e[0]}/${t}/${e==null?void 0:e[1]}`}const y=(e,t)=>(Math.round(e*10**t)/10**t).toString(),H=(e,t)=>{const n=(t==null?void 0:t.decimal)||a.decimal,r=(t==null?void 0:t.decimalSymbol)||a.decimalSymbol,c=(t==null?void 0:t.digitGroupingSymbol)??a.digitGroupingSymbol,o=Number(e);if(o==null||Number.isNaN(o)||e===null||e==="")return"";const d=n.replace("0.",""),i=`${n==="0"?Math.trunc(o):y(o,d.length)} `.split(".");return i[0]=i[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${c}`),`${i.join(r)}`},h=e=>isNaN(Date.parse(e))?null:new Date(e),p=(e,t,n)=>{const r={[T]:(t==null?void 0:t.contentType)||O};return t!=null&&t.jwt?r.Authorization=`Bearer ${t.jwt}`:e&&(r[E]=e),t!=null&&t.chatReference&&(r[l]=t.chatReference),{...r,...n}},L=e=>{const t={...e};return t[E]&&(t[E]=t[E].substring(0,8)+"...[REDACTED]"),t.Authorization&&(t.Authorization="Bearer [REDACTED]"),t},b=e=>({"Content-Type":`multipart/form-data; boundary=${e}`}),B=e=>(e==null?void 0:e.toLowerCase())==="true",M=async(e,t,n)=>await fetch(e,{method:n.method||"GET",headers:t,body:n.body?JSON.stringify(n.body):void 0}),U=(e,t)=>{var n,r;return(r=(n=e==null?void 0:e.split("/"))==null?void 0:n.filter(c=>c!==t))==null?void 0:r.join("/")},$=e=>e.map(t=>({...t,name:t.name.split(/-\d+$/)[0]}));exports.API_KEY_HEADER=E;exports.API_ROUTES=N;exports.APPLICATION_JSON=O;exports.CONTENT_TYPE_HEADER=T;exports.CUSTOM_PERIOD=S;exports.CalendarResolution=R;exports.HTTP_ERROR_CODES=C;exports.Locale=A;exports.ONBOARDING_MODEL_POSTFIX=u;exports.QueryFilterType=_;exports.SHARE_CONVERSATION_ROUTE=I;exports.X_CONVERSATION_ID_HEADER=l;exports.cleanConversationNames=$;exports.defaultFormatNumbers=a;exports.formatNumberBySign=H;exports.getClearedConversationName=s;exports.getConversationId=D;exports.getConversationNavPath=g;exports.getConversationUrlWithoutLocale=U;exports.getHeaders=p;exports.getMultipartHeaders=b;exports.getTimePeriod=h;exports.parseBoolean=B;exports.sanitizeHeaders=L;exports.sendRequest=M;
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const D = {
|
|
2
2
|
CHAT: "/api/chat"
|
|
3
|
-
},
|
|
3
|
+
}, g = "CUSTOM_PERIOD", T = {
|
|
4
4
|
decimal: "0.0",
|
|
5
5
|
decimalSymbol: ",",
|
|
6
6
|
digitGroupingSymbol: " "
|
|
7
|
-
},
|
|
7
|
+
}, A = "application/json", l = "Content-Type", r = "Api-Key", d = "X-CONVERSATION-ID", u = {
|
|
8
8
|
BAD_REQUEST: 400,
|
|
9
9
|
UNAUTHORIZED: 401,
|
|
10
10
|
FORBIDDEN: 403,
|
|
@@ -16,68 +16,70 @@ const g = {
|
|
|
16
16
|
BAD_GATEWAY: 502,
|
|
17
17
|
SERVICE_UNAVAILABLE: 503,
|
|
18
18
|
GATEWAY_TIMEOUT: 504
|
|
19
|
-
};
|
|
20
|
-
var
|
|
21
|
-
function
|
|
19
|
+
}, I = "onboarding", C = "share";
|
|
20
|
+
var a = /* @__PURE__ */ ((t) => (t.MONTH = "month", t.DAY = "day", t))(a || {}), R = /* @__PURE__ */ ((t) => (t.UK = "uk", t.EN = "en", t))(R || {}), S = /* @__PURE__ */ ((t) => (t.IN = "in", t.BETWEEN = "between", t))(S || {});
|
|
21
|
+
function s(t, e) {
|
|
22
22
|
const n = t.split("/")[0], c = e.split("/").pop();
|
|
23
23
|
return `${n}/${c}`;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
function
|
|
25
|
+
const y = (t) => (t == null ? void 0 : t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").replace(/-/g, " ")) || "";
|
|
26
|
+
function h(t, e) {
|
|
27
27
|
return `${t == null ? void 0 : t[0]}/${e}/${t == null ? void 0 : t[1]}`;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
const n = (e == null ? void 0 : e.decimal) ||
|
|
29
|
+
const _ = (t, e) => (Math.round(t * 10 ** e) / 10 ** e).toString(), p = (t, e) => {
|
|
30
|
+
const n = (e == null ? void 0 : e.decimal) || T.decimal, c = (e == null ? void 0 : e.decimalSymbol) || T.decimalSymbol, i = (e == null ? void 0 : e.digitGroupingSymbol) ?? T.digitGroupingSymbol, E = Number(t);
|
|
31
31
|
if (E == null || Number.isNaN(E) || t === null || t === "")
|
|
32
32
|
return "";
|
|
33
|
-
const
|
|
34
|
-
return
|
|
33
|
+
const O = n.replace("0.", ""), o = `${n === "0" ? Math.trunc(E) : _(E, O.length)} `.split(".");
|
|
34
|
+
return o[0] = o[0].replace(
|
|
35
35
|
/(\d)(?=(\d\d\d)+(?!\d))/g,
|
|
36
36
|
`$1${i}`
|
|
37
|
-
), `${
|
|
38
|
-
},
|
|
37
|
+
), `${o.join(c)}`;
|
|
38
|
+
}, $ = (t) => isNaN(Date.parse(t)) ? null : new Date(t), H = (t, e, n) => {
|
|
39
39
|
const c = {
|
|
40
|
-
[
|
|
40
|
+
[l]: (e == null ? void 0 : e.contentType) || A
|
|
41
41
|
};
|
|
42
|
-
return e != null && e.jwt ? c.Authorization = `Bearer ${e.jwt}` : t && (c[r] = t), e != null && e.chatReference && (c[
|
|
43
|
-
},
|
|
42
|
+
return e != null && e.jwt ? c.Authorization = `Bearer ${e.jwt}` : t && (c[r] = t), e != null && e.chatReference && (c[d] = e.chatReference), { ...c, ...n };
|
|
43
|
+
}, B = (t) => {
|
|
44
44
|
const e = { ...t };
|
|
45
45
|
return e[r] && (e[r] = e[r].substring(0, 8) + "...[REDACTED]"), e.Authorization && (e.Authorization = "Bearer [REDACTED]"), e;
|
|
46
|
-
},
|
|
46
|
+
}, L = (t) => ({
|
|
47
47
|
"Content-Type": `multipart/form-data; boundary=${t}`
|
|
48
|
-
}),
|
|
48
|
+
}), b = (t) => (t == null ? void 0 : t.toLowerCase()) === "true", M = async (t, e, n) => await fetch(t, {
|
|
49
49
|
method: n.method || "GET",
|
|
50
50
|
headers: e,
|
|
51
51
|
body: n.body ? JSON.stringify(n.body) : void 0
|
|
52
|
-
}),
|
|
52
|
+
}), U = (t, e) => {
|
|
53
53
|
var n, c;
|
|
54
54
|
return (c = (n = t == null ? void 0 : t.split("/")) == null ? void 0 : n.filter((i) => i !== e)) == null ? void 0 : c.join("/");
|
|
55
|
-
},
|
|
55
|
+
}, G = (t) => t.map((e) => ({
|
|
56
56
|
...e,
|
|
57
57
|
name: e.name.split(/-\d+$/)[0]
|
|
58
58
|
}));
|
|
59
59
|
export {
|
|
60
60
|
r as API_KEY_HEADER,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
D as API_ROUTES,
|
|
62
|
+
A as APPLICATION_JSON,
|
|
63
|
+
l as CONTENT_TYPE_HEADER,
|
|
64
|
+
g as CUSTOM_PERIOD,
|
|
65
|
+
a as CalendarResolution,
|
|
66
|
+
u as HTTP_ERROR_CODES,
|
|
67
67
|
R as Locale,
|
|
68
|
+
I as ONBOARDING_MODEL_POSTFIX,
|
|
68
69
|
S as QueryFilterType,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
y as
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
H as
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
C as SHARE_CONVERSATION_ROUTE,
|
|
71
|
+
d as X_CONVERSATION_ID_HEADER,
|
|
72
|
+
G as cleanConversationNames,
|
|
73
|
+
T as defaultFormatNumbers,
|
|
74
|
+
p as formatNumberBySign,
|
|
75
|
+
y as getClearedConversationName,
|
|
76
|
+
h as getConversationId,
|
|
77
|
+
s as getConversationNavPath,
|
|
78
|
+
U as getConversationUrlWithoutLocale,
|
|
79
|
+
H as getHeaders,
|
|
80
|
+
L as getMultipartHeaders,
|
|
81
|
+
$ as getTimePeriod,
|
|
82
|
+
b as parseBoolean,
|
|
83
|
+
B as sanitizeHeaders,
|
|
84
|
+
M as sendRequest
|
|
83
85
|
};
|