@epam/statgpt-shared-toolkit 0.5.0-rc.3 → 0.5.0-rc.30
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 +21 -21
- package/models/data-query.d.ts +7 -1
- package/package.json +1 -1
- package/types/query-filter-type.d.ts +2 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("date-fns"),f={CHAT:"/api/chat"},I="CUSTOM_PERIOD",l={decimal:"0.0",decimalSymbol:",",digitGroupingSymbol:" "},_="application/json",T="Content-Type",a="Api-Key",
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("date-fns"),f={CHAT:"/api/chat"},I="CUSTOM_PERIOD",l={decimal:"0.0",decimalSymbol:",",digitGroupingSymbol:" "},_="application/json",T="Content-Type",a="Api-Key",C="X-CONVERSATION-ID",u="Ocp-Apim-Subscription-Key",S="X-Source-Artefact-Urn",D={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},v="onboarding",U="share";class y extends Error{constructor(e){super(e.message),this.isHttpError=!0,this.name="HttpError",this.code=e.code,this.status=e.status,this.details=e.details,this.displayMessage=e.displayMessage}}function b(t){const e=t;return typeof t=="object"&&t!==null&&e.isHttpError===!0&&typeof e.status=="number"&&typeof e.message=="string"&&(e.code===void 0||typeof e.code=="string")}var p=(t=>(t.MONTH="month",t.DAY="day",t))(p||{}),N=(t=>(t.UK="uk",t.EN="en",t))(N||{}),O=(t=>(t.IN="in",t.BETWEEN="between",t.EXCLUDED="excluded",t))(O||{});function H(t,e){const n=t.split("/")[0],r=e.split("/").pop();return`${n}/${r}`}const R=t=>t.messages.flatMap(e=>{const n=e.custom_content?.attachments??[],r=e.custom_content?.stages?.flatMap(({attachments:o})=>o??[])??[];return[...n,...r]}),P=t=>t.endsWith("/"),M=t=>{const e=t.toLowerCase();return e.startsWith("http://")||e.startsWith("https://")},g=t=>!!t&&!M(t)&&!P(t),F=t=>[...new Set(R(t).map(e=>e.url).filter(e=>!!e).filter(e=>g(e)))],A=(t,e)=>t?.map(n=>({...n,url:n.url?e[n.url]??n.url:n.url})),L=(t,e)=>({...t,messages:t.messages.map(n=>({...n,custom_content:n.custom_content?{...n.custom_content,attachments:A(n.custom_content.attachments,e),stages:n.custom_content.stages?.map(r=>({...r,attachments:A(r.attachments,e)}))}:n.custom_content}))}),m=t=>t?.split(/-\d+$/)[0]??"",B=t=>new RegExp("\\p{L}","u").test(t)||new RegExp("\\p{N}","u").test(t),x=t=>{if(!t)return"";const e=t.toLowerCase(),n=[];let r="";for(const o of e)B(o)?r+=o:r&&(n.push(r),r="");return r&&n.push(r),n.join(" ")};function w(t,e){return`${t?.[0]}/${e}/${t?.[1]}`}const $=(t,e)=>(Math.round(t*10**e)/10**e).toString(),G=(t,e)=>{const n=e?.decimal||l.decimal,r=e?.decimalSymbol||l.decimalSymbol,o=e?.digitGroupingSymbol??l.digitGroupingSymbol,s=Number(t);if(s==null||Number.isNaN(s)||t===null||t==="")return"";const i=n.replace("0.",""),d=`${n==="0"?Math.trunc(s):$(s,i.length)} `.split(".");return d[0]=d[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${o}`),`${d.join(r)}`},V=t=>{if(!t.includes("T")){for(const n of Y){const r=c.parse(t,n,new Date);if(c.isValid(r))return r}return null}const e=c.parseISO(t);return c.isValid(e)?e:null},Y=["yyyy-MM-dd","MM-dd-yyyy"],j=(t,e,n)=>{const r={};return e?.contentType!==null&&(r[T]=e?.contentType||_),e?.jwt?r.Authorization=`Bearer ${e.jwt}`:t&&(r[a]=t),e?.chatReference&&(r[C]=e.chatReference),{...r,...n}},W=t=>{const e={...t};return e[a]&&(e[a]=e[a].substring(0,8)+"...[REDACTED]"),e.Authorization&&(e.Authorization="Bearer [REDACTED]"),e[u]&&(e[u]=e[u].substring(0,8)+"...[REDACTED]"),e},X=t=>({"Content-Type":`multipart/form-data; boundary=${t}`}),z=t=>t?.toLowerCase()==="true",K=async(t,e,n)=>await fetch(t,{method:n.method||"GET",headers:e,body:n.body?JSON.stringify(n.body):void 0}),k=(t,e)=>t?.split("/")?.filter(n=>n!==e)?.join("/"),q=t=>t.replace(/^conversations\//,""),J=t=>t.split("/").slice(0,-1).join("/"),Q=t=>m(decodeURIComponent(t.split("/").at(-1)??"")),Z=t=>t.map(e=>({...e,name:m(e.name)})),tt=new Set([")","]","}",">",",",".","!","?",":",";"]);function h(t){let e=t.length;for(;e>0&&tt.has(t[e-1]);)e--;return e===t.length?{cleanUrl:t,trailing:""}:{cleanUrl:t.slice(0,e),trailing:t.slice(e)}}function et(t){if(!t)return[{type:"text",value:""}];const e=[];let n=0;for(const r of t.matchAll(/\bhttps?:\/\/[^\s<>"']+/gi)){const o=r[0],s=r.index??0;s>n&&e.push({type:"text",value:t.slice(n,s)});const{cleanUrl:i,trailing:E}=h(o);i?e.push({type:"link",value:i}):e.push({type:"text",value:o}),E&&e.push({type:"text",value:E}),n=s+o.length}return n<t.length&&e.push({type:"text",value:t.slice(n)}),e.length?e:[{type:"text",value:t}]}exports.API_KEY_HEADER=a;exports.API_ROUTES=f;exports.APPLICATION_JSON=_;exports.CONTENT_TYPE_HEADER=T;exports.CUSTOM_PERIOD=I;exports.CalendarResolution=p;exports.HTTP_ERROR_CODES=D;exports.HttpError=y;exports.Locale=N;exports.OCP_APIM_SUBSCRIPTION_KEY_HEADER=u;exports.ONBOARDING_MODEL_POSTFIX=v;exports.QueryFilterType=O;exports.SHARE_CONVERSATION_ROUTE=U;exports.X_CONVERSATION_ID_HEADER=C;exports.X_SOURCE_ARTEFACT_URN_HEADER=S;exports.cleanConversationNames=Z;exports.defaultFormatNumbers=l;exports.deleteConversationNamePostfix=m;exports.formatNumberBySign=G;exports.getClearedConversationName=x;exports.getConversationAttachmentUrls=F;exports.getConversationAttachments=R;exports.getConversationFolderIdFromConversationId=J;exports.getConversationId=w;exports.getConversationIdFromResourceUrl=q;exports.getConversationNameFromConversationId=Q;exports.getConversationNavPath=H;exports.getConversationUrlWithoutLocale=k;exports.getHeaders=j;exports.getMultipartHeaders=X;exports.getTimePeriod=V;exports.isDialFileAttachmentUrl=g;exports.isHttpError=b;exports.linkifyText=et;exports.parseBoolean=z;exports.replaceConversationAttachmentUrls=L;exports.sanitizeHeaders=W;exports.sendRequest=K;exports.splitTrailingPunctuation=h;
|
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const M = {
|
|
|
5
5
|
decimal: "0.0",
|
|
6
6
|
decimalSymbol: ",",
|
|
7
7
|
digitGroupingSymbol: " "
|
|
8
|
-
}, A = "application/json", T = "Content-Type", i = "Api-Key", N = "X-CONVERSATION-ID", d = "Ocp-Apim-Subscription-Key", x = "X-Source-Artefact-Urn",
|
|
8
|
+
}, A = "application/json", T = "Content-Type", i = "Api-Key", N = "X-CONVERSATION-ID", d = "Ocp-Apim-Subscription-Key", x = "X-Source-Artefact-Urn", L = {
|
|
9
9
|
BAD_REQUEST: 400,
|
|
10
10
|
UNAUTHORIZED: 401,
|
|
11
11
|
FORBIDDEN: 403,
|
|
@@ -17,32 +17,32 @@ const M = {
|
|
|
17
17
|
BAD_GATEWAY: 502,
|
|
18
18
|
SERVICE_UNAVAILABLE: 503,
|
|
19
19
|
GATEWAY_TIMEOUT: 504
|
|
20
|
-
},
|
|
21
|
-
class
|
|
20
|
+
}, B = "onboarding", P = "share";
|
|
21
|
+
class $ extends Error {
|
|
22
22
|
constructor(e) {
|
|
23
23
|
super(e.message), this.isHttpError = !0, this.name = "HttpError", this.code = e.code, this.status = e.status, this.details = e.details, this.displayMessage = e.displayMessage;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function F(t) {
|
|
27
27
|
const e = t;
|
|
28
28
|
return typeof t == "object" && t !== null && e.isHttpError === !0 && typeof e.status == "number" && typeof e.message == "string" && (e.code === void 0 || typeof e.code == "string");
|
|
29
29
|
}
|
|
30
|
-
var _ = /* @__PURE__ */ ((t) => (t.MONTH = "month", t.DAY = "day", t))(_ || {}), g = /* @__PURE__ */ ((t) => (t.UK = "uk", t.EN = "en", t))(g || {}), O = /* @__PURE__ */ ((t) => (t.IN = "in", t.BETWEEN = "between", t))(O || {});
|
|
30
|
+
var _ = /* @__PURE__ */ ((t) => (t.MONTH = "month", t.DAY = "day", t))(_ || {}), g = /* @__PURE__ */ ((t) => (t.UK = "uk", t.EN = "en", t))(g || {}), O = /* @__PURE__ */ ((t) => (t.IN = "in", t.BETWEEN = "between", t.EXCLUDED = "excluded", t))(O || {});
|
|
31
31
|
function G(t, e) {
|
|
32
32
|
const n = t.split("/")[0], r = e.split("/").pop();
|
|
33
33
|
return `${n}/${r}`;
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const C = (t) => t.messages.flatMap((e) => {
|
|
36
36
|
const n = e.custom_content?.attachments ?? [], r = e.custom_content?.stages?.flatMap(
|
|
37
37
|
({ attachments: o }) => o ?? []
|
|
38
38
|
) ?? [];
|
|
39
39
|
return [...n, ...r];
|
|
40
|
-
}),
|
|
40
|
+
}), R = (t) => t.endsWith("/"), I = (t) => {
|
|
41
41
|
const e = t.toLowerCase();
|
|
42
42
|
return e.startsWith("http://") || e.startsWith("https://");
|
|
43
|
-
},
|
|
43
|
+
}, S = (t) => !!t && !I(t) && !R(t), j = (t) => [
|
|
44
44
|
...new Set(
|
|
45
|
-
|
|
45
|
+
C(t).map((e) => e.url).filter((e) => !!e).filter((e) => S(e))
|
|
46
46
|
)
|
|
47
47
|
], E = (t, e) => t?.map((n) => ({
|
|
48
48
|
...n,
|
|
@@ -66,12 +66,12 @@ const R = (t) => t.messages.flatMap((e) => {
|
|
|
66
66
|
}))
|
|
67
67
|
} : n.custom_content
|
|
68
68
|
}))
|
|
69
|
-
}), p = (t) => t?.split(/-\d+$/)[0] ?? "",
|
|
69
|
+
}), p = (t) => t?.split(/-\d+$/)[0] ?? "", y = (t) => new RegExp("\\p{L}", "u").test(t) || new RegExp("\\p{N}", "u").test(t), V = (t) => {
|
|
70
70
|
if (!t) return "";
|
|
71
71
|
const e = t.toLowerCase(), n = [];
|
|
72
72
|
let r = "";
|
|
73
73
|
for (const o of e)
|
|
74
|
-
|
|
74
|
+
y(o) ? r += o : r && (n.push(r), r = "");
|
|
75
75
|
return r && n.push(r), n.join(" ");
|
|
76
76
|
};
|
|
77
77
|
function Y(t, e) {
|
|
@@ -105,11 +105,11 @@ const D = (t, e) => (Math.round(t * 10 ** e) / 10 ** e).toString(), z = (t, e) =
|
|
|
105
105
|
return e[i] && (e[i] = e[i].substring(0, 8) + "...[REDACTED]"), e.Authorization && (e.Authorization = "Bearer [REDACTED]"), e[d] && (e[d] = e[d].substring(0, 8) + "...[REDACTED]"), e;
|
|
106
106
|
}, J = (t) => ({
|
|
107
107
|
"Content-Type": `multipart/form-data; boundary=${t}`
|
|
108
|
-
}), q = (t) => t?.toLowerCase() === "true",
|
|
108
|
+
}), q = (t) => t?.toLowerCase() === "true", Z = async (t, e, n) => await fetch(t, {
|
|
109
109
|
method: n.method || "GET",
|
|
110
110
|
headers: e,
|
|
111
111
|
body: n.body ? JSON.stringify(n.body) : void 0
|
|
112
|
-
}),
|
|
112
|
+
}), Q = (t, e) => t?.split("/")?.filter((n) => n !== e)?.join("/"), tt = (t) => t.replace(/^conversations\//, ""), et = (t) => t.split("/").slice(0, -1).join("/"), nt = (t) => p(
|
|
113
113
|
decodeURIComponent(t.split("/").at(-1) ?? "")
|
|
114
114
|
), rt = (t) => t.map((e) => ({
|
|
115
115
|
...e,
|
|
@@ -154,11 +154,11 @@ export {
|
|
|
154
154
|
T as CONTENT_TYPE_HEADER,
|
|
155
155
|
w as CUSTOM_PERIOD,
|
|
156
156
|
_ as CalendarResolution,
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
L as HTTP_ERROR_CODES,
|
|
158
|
+
$ as HttpError,
|
|
159
159
|
g as Locale,
|
|
160
160
|
d as OCP_APIM_SUBSCRIPTION_KEY_HEADER,
|
|
161
|
-
|
|
161
|
+
B as ONBOARDING_MODEL_POSTFIX,
|
|
162
162
|
O as QueryFilterType,
|
|
163
163
|
P as SHARE_CONVERSATION_ROUTE,
|
|
164
164
|
N as X_CONVERSATION_ID_HEADER,
|
|
@@ -169,22 +169,22 @@ export {
|
|
|
169
169
|
z as formatNumberBySign,
|
|
170
170
|
V as getClearedConversationName,
|
|
171
171
|
j as getConversationAttachmentUrls,
|
|
172
|
-
|
|
172
|
+
C as getConversationAttachments,
|
|
173
173
|
et as getConversationFolderIdFromConversationId,
|
|
174
174
|
Y as getConversationId,
|
|
175
175
|
tt as getConversationIdFromResourceUrl,
|
|
176
176
|
nt as getConversationNameFromConversationId,
|
|
177
177
|
G as getConversationNavPath,
|
|
178
|
-
|
|
178
|
+
Q as getConversationUrlWithoutLocale,
|
|
179
179
|
k as getHeaders,
|
|
180
180
|
J as getMultipartHeaders,
|
|
181
181
|
X as getTimePeriod,
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
S as isDialFileAttachmentUrl,
|
|
183
|
+
F as isHttpError,
|
|
184
184
|
ot as linkifyText,
|
|
185
185
|
q as parseBoolean,
|
|
186
186
|
W as replaceConversationAttachmentUrls,
|
|
187
187
|
K as sanitizeHeaders,
|
|
188
|
-
|
|
188
|
+
Z as sendRequest,
|
|
189
189
|
v as splitTrailingPunctuation
|
|
190
190
|
};
|
package/models/data-query.d.ts
CHANGED
|
@@ -2,21 +2,27 @@ import { QueryFilterType } from '../types/query-filter-type';
|
|
|
2
2
|
export interface DataQuery {
|
|
3
3
|
title?: string;
|
|
4
4
|
urn: string;
|
|
5
|
+
sdmx1Source?: string;
|
|
5
6
|
metadata: {
|
|
6
7
|
countryDimension: string;
|
|
7
8
|
indicatorDimensions: string[];
|
|
8
9
|
datasetUrl?: string;
|
|
10
|
+
timePeriodDimension?: string;
|
|
11
|
+
keyDimensionIdsInDsdOrder?: string[];
|
|
9
12
|
};
|
|
10
|
-
filters
|
|
13
|
+
filters?: QueryFilter[];
|
|
11
14
|
}
|
|
12
15
|
export interface JsonDataQuery {
|
|
13
16
|
urn: string;
|
|
17
|
+
sdmx1Source?: string;
|
|
14
18
|
metadata: {
|
|
15
19
|
country_dimension?: string;
|
|
16
20
|
countryDimension: string;
|
|
17
21
|
indicator_dimensions?: string[];
|
|
18
22
|
indicatorDimensions: string[];
|
|
19
23
|
datasetUrl?: string;
|
|
24
|
+
timePeriodDimension?: string;
|
|
25
|
+
keyDimensionIdsInDsdOrder?: string[];
|
|
20
26
|
};
|
|
21
27
|
filters: JsonQueryFilter[];
|
|
22
28
|
}
|
package/package.json
CHANGED