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