@epam/statgpt-shared-toolkit 0.1.0-rc.0 → 0.1.0-rc.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/constants/http-error-codes.d.ts +13 -0
- package/constants/index.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +53 -37
- package/models/api-response.d.ts +6 -0
- package/models/data-query.d.ts +2 -0
- package/models/index.d.ts +1 -0
- package/models/onboarding-schema.d.ts +17 -0
- package/models/request-options.d.ts +1 -0
- package/package.json +1 -1
- package/utils/headers.d.ts +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const HTTP_ERROR_CODES: {
|
|
2
|
+
BAD_REQUEST: number;
|
|
3
|
+
UNAUTHORIZED: number;
|
|
4
|
+
FORBIDDEN: number;
|
|
5
|
+
NOT_FOUND: number;
|
|
6
|
+
METHOD_NOT_ALLOWED: number;
|
|
7
|
+
CONFLICT: number;
|
|
8
|
+
TOO_MANY_REQUESTS: number;
|
|
9
|
+
INTERNAL_SERVER_ERROR: number;
|
|
10
|
+
BAD_GATEWAY: number;
|
|
11
|
+
SERVICE_UNAVAILABLE: number;
|
|
12
|
+
GATEWAY_TIMEOUT: number;
|
|
13
|
+
};
|
package/constants/index.d.ts
CHANGED
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 u={CHAT:"/api/chat"},g="CUSTOM_PERIOD",o={decimal:"0.0",decimalSymbol:",",digitGroupingSymbol:" "},T="application/json",l="Content-Type",E="Api-Key",d="X-CONVERSATION-ID",S={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};var O=(e=>(e.MONTH="month",e.DAY="day",e))(O||{}),A=(e=>(e.UK="uk",e.EN="en",e))(A||{}),R=(e=>(e.IN="in",e.BETWEEN="between",e))(R||{});function C(e,t){const n=e.split("/")[0],r=t.split("/").pop();return`${n}/${r}`}const N=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 I=(e,t)=>(Math.round(e*10**t)/10**t).toString(),s=(e,t)=>{const n=(t==null?void 0:t.decimal)||o.decimal,r=(t==null?void 0:t.decimalSymbol)||o.decimalSymbol,i=(t==null?void 0:t.digitGroupingSymbol)??o.digitGroupingSymbol,c=Number(e);if(c==null||Number.isNaN(c)||e===null||e==="")return"";const _=n.replace("0.",""),a=`${n==="0"?Math.trunc(c):I(c,_.length)} `.split(".");return a[0]=a[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${i}`),`${a.join(r)}`},y=e=>isNaN(Date.parse(e))?null:new Date(e),H=(e,t,n)=>{const r={[l]:(t==null?void 0:t.contentType)||T};return t!=null&&t.jwt?r.Authorization=`Bearer ${t.jwt}`:e&&(r[E]=e),t!=null&&t.chatReference&&(r[d]=t.chatReference),{...r,...n}},h=e=>{const t={...e};return t[E]&&(t[E]=t[E].substring(0,8)+"...[REDACTED]"),t.Authorization&&(t.Authorization="Bearer [REDACTED]"),t},p=e=>({"Content-Type":`multipart/form-data; boundary=${e}`}),b=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}),B=(e,t)=>{var n,r;return(r=(n=e==null?void 0:e.split("/"))==null?void 0:n.filter(i=>i!==t))==null?void 0:r.join("/")};exports.API_KEY_HEADER=E;exports.API_ROUTES=u;exports.APPLICATION_JSON=T;exports.CONTENT_TYPE_HEADER=l;exports.CUSTOM_PERIOD=g;exports.CalendarResolution=O;exports.HTTP_ERROR_CODES=S;exports.Locale=A;exports.QueryFilterType=R;exports.X_CONVERSATION_ID_HEADER=d;exports.defaultFormatNumbers=o;exports.formatNumberBySign=s;exports.getClearedConversationName=N;exports.getConversationId=D;exports.getConversationNavPath=C;exports.getConversationUrlWithoutLocale=B;exports.getHeaders=H;exports.getMultipartHeaders=p;exports.getTimePeriod=y;exports.parseBoolean=b;exports.sanitizeHeaders=h;exports.sendRequest=L;
|
package/index.mjs
CHANGED
|
@@ -1,63 +1,79 @@
|
|
|
1
|
-
const
|
|
1
|
+
const g = {
|
|
2
2
|
CHAT: "/api/chat"
|
|
3
3
|
}, D = "CUSTOM_PERIOD", o = {
|
|
4
4
|
decimal: "0.0",
|
|
5
5
|
decimalSymbol: ",",
|
|
6
6
|
digitGroupingSymbol: " "
|
|
7
|
-
},
|
|
8
|
-
|
|
7
|
+
}, A = "application/json", d = "Content-Type", r = "Api-Key", O = "X-CONVERSATION-ID", C = {
|
|
8
|
+
BAD_REQUEST: 400,
|
|
9
|
+
UNAUTHORIZED: 401,
|
|
10
|
+
FORBIDDEN: 403,
|
|
11
|
+
NOT_FOUND: 404,
|
|
12
|
+
METHOD_NOT_ALLOWED: 405,
|
|
13
|
+
CONFLICT: 409,
|
|
14
|
+
TOO_MANY_REQUESTS: 429,
|
|
15
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
16
|
+
BAD_GATEWAY: 502,
|
|
17
|
+
SERVICE_UNAVAILABLE: 503,
|
|
18
|
+
GATEWAY_TIMEOUT: 504
|
|
19
|
+
};
|
|
20
|
+
var R = /* @__PURE__ */ ((t) => (t.MONTH = "month", t.DAY = "day", t))(R || {}), S = /* @__PURE__ */ ((t) => (t.UK = "uk", t.EN = "en", t))(S || {}), u = /* @__PURE__ */ ((t) => (t.IN = "in", t.BETWEEN = "between", t))(u || {});
|
|
9
21
|
function I(t, e) {
|
|
10
22
|
const n = t.split("/")[0], c = e.split("/").pop();
|
|
11
23
|
return `${n}/${c}`;
|
|
12
24
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
25
|
+
const N = (t) => (t == null ? void 0 : t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").replace(/-/g, " ")) || "";
|
|
26
|
+
function y(t, e) {
|
|
15
27
|
return `${t == null ? void 0 : t[0]}/${e}/${t == null ? void 0 : t[1]}`;
|
|
16
28
|
}
|
|
17
|
-
const
|
|
18
|
-
const n = (e == null ? void 0 : e.decimal) || o.decimal, c = (e == null ? void 0 : e.decimalSymbol) || o.decimalSymbol,
|
|
19
|
-
if (
|
|
29
|
+
const _ = (t, e) => (Math.round(t * 10 ** e) / 10 ** e).toString(), h = (t, e) => {
|
|
30
|
+
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, E = Number(t);
|
|
31
|
+
if (E == null || Number.isNaN(E) || t === null || t === "")
|
|
20
32
|
return "";
|
|
21
|
-
const
|
|
22
|
-
return
|
|
33
|
+
const l = n.replace("0.", ""), T = `${n === "0" ? Math.trunc(E) : _(E, l.length)} `.split(".");
|
|
34
|
+
return T[0] = T[0].replace(
|
|
23
35
|
/(\d)(?=(\d\d\d)+(?!\d))/g,
|
|
24
|
-
`$1${
|
|
25
|
-
), `${
|
|
26
|
-
},
|
|
36
|
+
`$1${i}`
|
|
37
|
+
), `${T.join(c)}`;
|
|
38
|
+
}, $ = (t) => isNaN(Date.parse(t)) ? null : new Date(t), p = (t, e, n) => {
|
|
27
39
|
const c = {
|
|
28
|
-
[
|
|
40
|
+
[d]: (e == null ? void 0 : e.contentType) || A
|
|
29
41
|
};
|
|
30
|
-
return e != null && e.jwt ? c.Authorization = `Bearer ${e.jwt}` : t && (c[
|
|
31
|
-
},
|
|
42
|
+
return e != null && e.jwt ? c.Authorization = `Bearer ${e.jwt}` : t && (c[r] = t), e != null && e.chatReference && (c[O] = e.chatReference), { ...c, ...n };
|
|
43
|
+
}, s = (t) => {
|
|
32
44
|
const e = { ...t };
|
|
33
|
-
return e[
|
|
34
|
-
},
|
|
45
|
+
return e[r] && (e[r] = e[r].substring(0, 8) + "...[REDACTED]"), e.Authorization && (e.Authorization = "Bearer [REDACTED]"), e;
|
|
46
|
+
}, H = (t) => ({
|
|
47
|
+
"Content-Type": `multipart/form-data; boundary=${t}`
|
|
48
|
+
}), B = (t) => (t == null ? void 0 : t.toLowerCase()) === "true", L = async (t, e, n) => await fetch(t, {
|
|
35
49
|
method: n.method || "GET",
|
|
36
50
|
headers: e,
|
|
37
51
|
body: n.body ? JSON.stringify(n.body) : void 0
|
|
38
|
-
}),
|
|
52
|
+
}), b = (t, e) => {
|
|
39
53
|
var n, c;
|
|
40
|
-
return (c = (n = t == null ? void 0 : t.split("/")) == null ? void 0 : n.filter((
|
|
54
|
+
return (c = (n = t == null ? void 0 : t.split("/")) == null ? void 0 : n.filter((i) => i !== e)) == null ? void 0 : c.join("/");
|
|
41
55
|
};
|
|
42
56
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
r as API_KEY_HEADER,
|
|
58
|
+
g as API_ROUTES,
|
|
59
|
+
A as APPLICATION_JSON,
|
|
60
|
+
d as CONTENT_TYPE_HEADER,
|
|
47
61
|
D as CUSTOM_PERIOD,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
R as CalendarResolution,
|
|
63
|
+
C as HTTP_ERROR_CODES,
|
|
64
|
+
S as Locale,
|
|
65
|
+
u as QueryFilterType,
|
|
66
|
+
O as X_CONVERSATION_ID_HEADER,
|
|
52
67
|
o as defaultFormatNumbers,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
h as formatNumberBySign,
|
|
69
|
+
N as getClearedConversationName,
|
|
70
|
+
y as getConversationId,
|
|
56
71
|
I as getConversationNavPath,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
b as getConversationUrlWithoutLocale,
|
|
73
|
+
p as getHeaders,
|
|
74
|
+
H as getMultipartHeaders,
|
|
75
|
+
$ as getTimePeriod,
|
|
76
|
+
B as parseBoolean,
|
|
77
|
+
s as sanitizeHeaders,
|
|
78
|
+
L as sendRequest
|
|
63
79
|
};
|
package/models/data-query.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface DataQuery {
|
|
|
5
5
|
metadata: {
|
|
6
6
|
countryDimension: string;
|
|
7
7
|
indicatorDimensions: string[];
|
|
8
|
+
datasetUrl?: string;
|
|
8
9
|
};
|
|
9
10
|
filters: QueryFilter[];
|
|
10
11
|
}
|
|
@@ -15,6 +16,7 @@ export interface JsonDataQuery {
|
|
|
15
16
|
countryDimension: string;
|
|
16
17
|
indicator_dimensions?: string[];
|
|
17
18
|
indicatorDimensions: string[];
|
|
19
|
+
datasetUrl?: string;
|
|
18
20
|
};
|
|
19
21
|
filters: JsonQueryFilter[];
|
|
20
22
|
}
|
package/models/index.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface OnboardingFileSchema {
|
|
2
|
+
isStarted: boolean;
|
|
3
|
+
isSkipped: boolean;
|
|
4
|
+
isFinished: boolean;
|
|
5
|
+
infoElements: {
|
|
6
|
+
dataGrid: boolean;
|
|
7
|
+
metadataPerSeries: boolean;
|
|
8
|
+
charts: boolean;
|
|
9
|
+
chartsNavigation: boolean;
|
|
10
|
+
openAdvancedView: boolean;
|
|
11
|
+
filters: boolean;
|
|
12
|
+
chartPerSeries: boolean;
|
|
13
|
+
metadataPerDataset: boolean;
|
|
14
|
+
exitAdvancedView: boolean;
|
|
15
|
+
};
|
|
16
|
+
lastDisplayedElement: string;
|
|
17
|
+
}
|
package/package.json
CHANGED
package/utils/headers.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare const getHeaders: (apiKey?: string, options?: {
|
|
|
5
5
|
contentType?: string;
|
|
6
6
|
}, optionsHeaders?: Record<string, string>) => Record<string, string>;
|
|
7
7
|
export declare const sanitizeHeaders: (headers: ApiHeaders) => Record<string, string>;
|
|
8
|
+
export declare const getMultipartHeaders: (boundary: string) => Record<string, string>;
|