@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.
@@ -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
+ };
@@ -2,3 +2,4 @@ export * from './api-urls';
2
2
  export * from './calendar';
3
3
  export * from './format-numbers-default';
4
4
  export * from './headers';
5
+ export * from './http-error-codes';
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S={CHAT:"/api/chat"},s="CUSTOM_PERIOD",o={decimal:"0.0",decimalSymbol:",",digitGroupingSymbol:" "},d="application/json",E="Content-Type",c="Api-Key",u="X-CONVERSATION-ID";var g=(e=>(e.MONTH="month",e.DAY="day",e))(g||{}),T=(e=>(e.UK="uk",e.EN="en",e))(T||{}),C=(e=>(e.IN="in",e.BETWEEN="between",e))(C||{});function O(e,t){const n=e.split("/")[0],r=t.split("/").pop();return`${n}/${r}`}const I=e=>(e==null?void 0:e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").replace(/-/g," "))||"";function N(e,t){return`${e==null?void 0:e[0]}/${t}/${e==null?void 0:e[1]}`}const _=(e,t)=>(Math.round(e*10**t)/10**t).toFixed(t),y=(e,t)=>{const n=(t==null?void 0:t.decimal)||o.decimal,r=(t==null?void 0:t.decimalSymbol)||o.decimalSymbol,a=(t==null?void 0:t.digitGroupingSymbol)??o.digitGroupingSymbol,i=Number(e);if(i==null||Number.isNaN(i)||e===null||e==="")return"";const A=n.replace("0.",""),l=`${n==="0"?Math.trunc(i):_(i,A.length)} `.split(".");return l[0]=l[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${a}`),`${l.join(r)}`},R=e=>isNaN(Date.parse(e))?null:new Date(e),D=(e,t,n)=>{const r={[E]:(t==null?void 0:t.contentType)||d};return t!=null&&t.jwt?r.Authorization=`Bearer ${t.jwt}`:e&&(r[c]=e),t!=null&&t.chatReference&&(r[u]=t.chatReference),{...r,...n}},h=e=>{const t={...e};return t[c]&&(t[c]=t[c].substring(0,8)+"...[REDACTED]"),t.Authorization&&(t.Authorization="Bearer [REDACTED]"),t},b=e=>(e==null?void 0:e.toLowerCase())==="true",H=async(e,t,n)=>await fetch(e,{method:n.method||"GET",headers:t,body:n.body?JSON.stringify(n.body):void 0}),$=(e,t)=>{var n,r;return(r=(n=e==null?void 0:e.split("/"))==null?void 0:n.filter(a=>a!==t))==null?void 0:r.join("/")};exports.API_KEY_HEADER=c;exports.API_ROUTES=S;exports.APPLICATION_JSON=d;exports.CONTENT_TYPE_HEADER=E;exports.CUSTOM_PERIOD=s;exports.CalendarResolution=g;exports.Locale=T;exports.QueryFilterType=C;exports.X_CONVERSATION_ID_HEADER=u;exports.defaultFormatNumbers=o;exports.formatNumberBySign=y;exports.getClearedConversationName=I;exports.getConversationId=N;exports.getConversationNavPath=O;exports.getConversationUrlWithoutLocale=$;exports.getHeaders=D;exports.getTimePeriod=R;exports.parseBoolean=b;exports.sanitizeHeaders=h;exports.sendRequest=H;
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 h = {
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
- }, E = "application/json", g = "Content-Type", i = "Api-Key", S = "X-CONVERSATION-ID";
8
- var a = /* @__PURE__ */ ((t) => (t.MONTH = "month", t.DAY = "day", t))(a || {}), A = /* @__PURE__ */ ((t) => (t.UK = "uk", t.EN = "en", t))(A || {}), T = /* @__PURE__ */ ((t) => (t.IN = "in", t.BETWEEN = "between", t))(T || {});
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 O = (t) => (t == null ? void 0 : t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").replace(/-/g, " ")) || "";
14
- function R(t, e) {
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 C = (t, e) => (Math.round(t * 10 ** e) / 10 ** e).toFixed(e), N = (t, e) => {
18
- const n = (e == null ? void 0 : e.decimal) || o.decimal, c = (e == null ? void 0 : e.decimalSymbol) || o.decimalSymbol, d = (e == null ? void 0 : e.digitGroupingSymbol) ?? o.digitGroupingSymbol, r = Number(t);
19
- if (r == null || Number.isNaN(r) || t === null || t === "")
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 u = n.replace("0.", ""), l = `${n === "0" ? Math.trunc(r) : C(r, u.length)} `.split(".");
22
- return l[0] = l[0].replace(
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${d}`
25
- ), `${l.join(c)}`;
26
- }, _ = (t) => isNaN(Date.parse(t)) ? null : new Date(t), $ = (t, e, n) => {
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
- [g]: (e == null ? void 0 : e.contentType) || E
40
+ [d]: (e == null ? void 0 : e.contentType) || A
29
41
  };
30
- return e != null && e.jwt ? c.Authorization = `Bearer ${e.jwt}` : t && (c[i] = t), e != null && e.chatReference && (c[S] = e.chatReference), { ...c, ...n };
31
- }, b = (t) => {
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[i] && (e[i] = e[i].substring(0, 8) + "...[REDACTED]"), e.Authorization && (e.Authorization = "Bearer [REDACTED]"), e;
34
- }, s = (t) => (t == null ? void 0 : t.toLowerCase()) === "true", p = async (t, e, n) => await fetch(t, {
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
- }), w = (t, e) => {
52
+ }), b = (t, e) => {
39
53
  var n, c;
40
- return (c = (n = t == null ? void 0 : t.split("/")) == null ? void 0 : n.filter((d) => d !== e)) == null ? void 0 : c.join("/");
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
- i as API_KEY_HEADER,
44
- h as API_ROUTES,
45
- E as APPLICATION_JSON,
46
- g as CONTENT_TYPE_HEADER,
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
- a as CalendarResolution,
49
- A as Locale,
50
- T as QueryFilterType,
51
- S as X_CONVERSATION_ID_HEADER,
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
- N as formatNumberBySign,
54
- O as getClearedConversationName,
55
- R as getConversationId,
68
+ h as formatNumberBySign,
69
+ N as getClearedConversationName,
70
+ y as getConversationId,
56
71
  I as getConversationNavPath,
57
- w as getConversationUrlWithoutLocale,
58
- $ as getHeaders,
59
- _ as getTimePeriod,
60
- s as parseBoolean,
61
- b as sanitizeHeaders,
62
- p as sendRequest
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
  };
@@ -0,0 +1,6 @@
1
+ export interface ApiResponse<T> {
2
+ success: boolean;
3
+ data?: T;
4
+ statusCode?: number;
5
+ message?: string;
6
+ }
@@ -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
@@ -1,4 +1,5 @@
1
1
  export * from './api';
2
+ export * from './api-response';
2
3
  export * from './data-query';
3
4
  export * from './format-numbers-type';
4
5
  export * from './log-data';
@@ -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
+ }
@@ -5,4 +5,5 @@ export interface RequestOptions {
5
5
  jwt?: string;
6
6
  chatReference?: string;
7
7
  signal?: AbortSignal;
8
+ isFormData?: boolean;
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epam/statgpt-shared-toolkit",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0-rc.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -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>;