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