@epam/statgpt-shared-toolkit 0.6.1 → 0.6.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.
Files changed (4) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +159 -183
  3. package/package.json +2 -2
  4. package/LICENSE +0 -21
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",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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("date-fns");var t={CHAT:`/api/chat`},n=`CUSTOM_PERIOD`,r={decimal:`0.0`,decimalSymbol:`,`,digitGroupingSymbol:` `},i=`application/json`,a=`Content-Type`,o=`Api-Key`,s=`X-CONVERSATION-ID`,c=`Ocp-Apim-Subscription-Key`,l=`X-Source-Artefact-Urn`,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},d=`onboarding`,f=`share`,p=class 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 m(e){let t=e;return typeof e==`object`&&!!e&&t.isHttpError===!0&&typeof t.status==`number`&&typeof t.message==`string`&&(t.code===void 0||typeof t.code==`string`)}var h=function(e){return e.MONTH=`month`,e.DAY=`day`,e}({}),g=function(e){return e.UK=`uk`,e.EN=`en`,e}({}),_=function(e){return e.IN=`in`,e.BETWEEN=`between`,e.EXCLUDED=`excluded`,e}({});function v(e,t){return`${e.split(`/`)[0]}/${t.split(`/`).pop()}`}var y=e=>e.messages.flatMap(e=>{let t=e.custom_content?.attachments??[],n=e.custom_content?.stages?.flatMap(({attachments:e})=>e??[])??[];return[...t,...n]}),b=e=>e.endsWith(`/`),x=e=>{let t=e.toLowerCase();return t.startsWith(`http://`)||t.startsWith(`https://`)},S=e=>!!e&&!x(e)&&!b(e),C=e=>[...new Set(y(e).map(e=>e.url).filter(e=>!!e).filter(e=>S(e)))],w=(e,t)=>e?.map(e=>({...e,url:e.url?t[e.url]??e.url:e.url})),T=(e,t)=>({...e,messages:e.messages.map(e=>({...e,custom_content:e.custom_content?{...e.custom_content,attachments:w(e.custom_content.attachments,t),stages:e.custom_content.stages?.map(e=>({...e,attachments:w(e.attachments,t)}))}:e.custom_content}))}),E=e=>e?.split(/-\d+$/)[0]??``,D=e=>/\p{L}/u.test(e)||/\p{N}/u.test(e),O=e=>{if(!e)return``;let t=e.toLowerCase(),n=[],r=``;for(let e of t)D(e)?r+=e:r&&=(n.push(r),``);return r&&n.push(r),n.join(` `)};function k(e,t){return`${e?.[0]}/${t}/${e?.[1]}`}var A=(e,t)=>(Math.round(e*10**t)/10**t).toString(),j=(e,t)=>{let n=t?.decimal||r.decimal,i=t?.decimalSymbol||r.decimalSymbol,a=t?.digitGroupingSymbol??r.digitGroupingSymbol,o=Number(e);if(o==null||Number.isNaN(o)||e===null||e===``)return``;let s=n.replace(`0.`,``),c=`${n===`0`?Math.trunc(o):A(o,s.length)} `.split(`.`);return c[0]=c[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${a}`),`${c.join(i)}`},M=t=>{if(!t.includes(`T`)){for(let n of N){let r=(0,e.parse)(t,n,new Date);if((0,e.isValid)(r))return r}return null}let n=(0,e.parseISO)(t);return(0,e.isValid)(n)?n:null},N=[`yyyy-MM-dd`,`MM-dd-yyyy`],P=(e,t,n)=>{let r={};return t?.contentType!==null&&(r[a]=t?.contentType||`application/json`),t?.jwt?r.Authorization=`Bearer ${t.jwt}`:e&&(r[o]=e),t?.chatReference&&(r[s]=t.chatReference),{...r,...n}},F=e=>{let t={...e};return t[`Api-Key`]&&(t[o]=t[o].substring(0,8)+`...[REDACTED]`),t.Authorization&&=`Bearer [REDACTED]`,t[`Ocp-Apim-Subscription-Key`]&&(t[c]=t[c].substring(0,8)+`...[REDACTED]`),t},I=e=>({"Content-Type":`multipart/form-data; boundary=${e}`}),L=e=>e?.toLowerCase()===`true`,R=async(e,t,n)=>await fetch(e,{method:n.method||`GET`,headers:t,body:n.body?JSON.stringify(n.body):void 0}),z=(e,t)=>e?.split(`/`)?.filter(e=>e!==t)?.join(`/`),B=e=>e.replace(/^conversations\//,``),V=e=>e.split(`/`).slice(0,-1).join(`/`),H=e=>E(decodeURIComponent(e.split(`/`).at(-1)??``)),U=e=>e.map(e=>({...e,name:E(e.name)})),W=new Set([`)`,`]`,`}`,`>`,`,`,`.`,`!`,`?`,`:`,`;`]);function G(e){let t=e.length;for(;t>0&&W.has(e[t-1]);)t--;return t===e.length?{cleanUrl:e,trailing:``}:{cleanUrl:e.slice(0,t),trailing:e.slice(t)}}function K(e){if(!e)return[{type:`text`,value:``}];let t=[],n=0;for(let r of e.matchAll(/\bhttps?:\/\/[^\s<>"']+/gi)){let i=r[0],a=r.index??0;a>n&&t.push({type:`text`,value:e.slice(n,a)});let{cleanUrl:o,trailing:s}=G(i);o?t.push({type:`link`,value:o}):t.push({type:`text`,value:i}),s&&t.push({type:`text`,value:s}),n=a+i.length}return n<e.length&&t.push({type:`text`,value:e.slice(n)}),t.length?t:[{type:`text`,value:e}]}exports.API_KEY_HEADER=o,exports.API_ROUTES=t,exports.APPLICATION_JSON=i,exports.CONTENT_TYPE_HEADER=a,exports.CUSTOM_PERIOD=n,exports.CalendarResolution=h,exports.HTTP_ERROR_CODES=u,exports.HttpError=p,exports.Locale=g,exports.OCP_APIM_SUBSCRIPTION_KEY_HEADER=c,exports.ONBOARDING_MODEL_POSTFIX=d,exports.QueryFilterType=_,exports.SHARE_CONVERSATION_ROUTE=f,exports.X_CONVERSATION_ID_HEADER=s,exports.X_SOURCE_ARTEFACT_URN_HEADER=l,exports.cleanConversationNames=U,exports.defaultFormatNumbers=r,exports.deleteConversationNamePostfix=E,exports.formatNumberBySign=j,exports.getClearedConversationName=O,exports.getConversationAttachmentUrls=C,exports.getConversationAttachments=y,exports.getConversationFolderIdFromConversationId=V,exports.getConversationId=k,exports.getConversationIdFromResourceUrl=B,exports.getConversationNameFromConversationId=H,exports.getConversationNavPath=v,exports.getConversationUrlWithoutLocale=z,exports.getHeaders=P,exports.getMultipartHeaders=I,exports.getTimePeriod=M,exports.isDialFileAttachmentUrl=S,exports.isHttpError=m,exports.linkifyText=K,exports.parseBoolean=L,exports.replaceConversationAttachmentUrls=T,exports.sanitizeHeaders=F,exports.sendRequest=R,exports.splitTrailingPunctuation=G;
package/index.mjs CHANGED
@@ -1,190 +1,166 @@
1
- import { parse as h, isValid as m, parseISO as f } from "date-fns";
2
- const M = {
3
- CHAT: "/api/chat"
4
- }, w = "CUSTOM_PERIOD", u = {
5
- decimal: "0.0",
6
- decimalSymbol: ",",
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", L = {
9
- BAD_REQUEST: 400,
10
- UNAUTHORIZED: 401,
11
- FORBIDDEN: 403,
12
- NOT_FOUND: 404,
13
- METHOD_NOT_ALLOWED: 405,
14
- CONFLICT: 409,
15
- TOO_MANY_REQUESTS: 429,
16
- INTERNAL_SERVER_ERROR: 500,
17
- BAD_GATEWAY: 502,
18
- SERVICE_UNAVAILABLE: 503,
19
- GATEWAY_TIMEOUT: 504
20
- }, B = "onboarding", P = "share";
21
- class $ extends Error {
22
- constructor(e) {
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
- }
25
- }
26
- function F(t) {
27
- const e = t;
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");
1
+ import { isValid as e, parse as t, parseISO as n } from "date-fns";
2
+ //#region libs/shared-toolkit/src/constants/api-urls.ts
3
+ var r = { CHAT: "/api/chat" }, i = "CUSTOM_PERIOD", a = {
4
+ decimal: "0.0",
5
+ decimalSymbol: ",",
6
+ digitGroupingSymbol: " "
7
+ }, o = "application/json", s = "Content-Type", c = "Api-Key", l = "X-CONVERSATION-ID", u = "Ocp-Apim-Subscription-Key", d = "X-Source-Artefact-Urn", f = {
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
+ }, p = "onboarding", m = "share", h = class extends Error {
20
+ constructor(e) {
21
+ 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;
22
+ }
23
+ };
24
+ function g(e) {
25
+ let t = e;
26
+ return typeof e == "object" && !!e && t.isHttpError === !0 && typeof t.status == "number" && typeof t.message == "string" && (t.code === void 0 || typeof t.code == "string");
29
27
  }
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
- function G(t, e) {
32
- const n = t.split("/")[0], r = e.split("/").pop();
33
- return `${n}/${r}`;
28
+ //#endregion
29
+ //#region libs/shared-toolkit/src/types/calendar.ts
30
+ var _ = /* @__PURE__ */ function(e) {
31
+ return e.MONTH = "month", e.DAY = "day", e;
32
+ }({}), v = /* @__PURE__ */ function(e) {
33
+ return e.UK = "uk", e.EN = "en", e;
34
+ }({}), y = /* @__PURE__ */ function(e) {
35
+ return e.IN = "in", e.BETWEEN = "between", e.EXCLUDED = "excluded", e;
36
+ }({});
37
+ //#endregion
38
+ //#region libs/shared-toolkit/src/utils/conversation-id-to-navigation.ts
39
+ function b(e, t) {
40
+ return `${e.split("/")[0]}/${t.split("/").pop()}`;
34
41
  }
35
- const C = (t) => t.messages.flatMap((e) => {
36
- const n = e.custom_content?.attachments ?? [], r = e.custom_content?.stages?.flatMap(
37
- ({ attachments: o }) => o ?? []
38
- ) ?? [];
39
- return [...n, ...r];
40
- }), R = (t) => t.endsWith("/"), I = (t) => {
41
- const e = t.toLowerCase();
42
- return e.startsWith("http://") || e.startsWith("https://");
43
- }, S = (t) => !!t && !I(t) && !R(t), j = (t) => [
44
- ...new Set(
45
- C(t).map((e) => e.url).filter((e) => !!e).filter((e) => S(e))
46
- )
47
- ], E = (t, e) => t?.map((n) => ({
48
- ...n,
49
- url: n.url ? e[n.url] ?? n.url : n.url
50
- })), W = (t, e) => ({
51
- ...t,
52
- messages: t.messages.map((n) => ({
53
- ...n,
54
- custom_content: n.custom_content ? {
55
- ...n.custom_content,
56
- attachments: E(
57
- n.custom_content.attachments,
58
- e
59
- ),
60
- stages: n.custom_content.stages?.map((r) => ({
61
- ...r,
62
- attachments: E(
63
- r.attachments,
64
- e
65
- )
66
- }))
67
- } : n.custom_content
68
- }))
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
- if (!t) return "";
71
- const e = t.toLowerCase(), n = [];
72
- let r = "";
73
- for (const o of e)
74
- y(o) ? r += o : r && (n.push(r), r = "");
75
- return r && n.push(r), n.join(" ");
42
+ //#endregion
43
+ //#region libs/shared-toolkit/src/utils/conversation-attachments.ts
44
+ var x = (e) => e.messages.flatMap((e) => {
45
+ let t = e.custom_content?.attachments ?? [], n = e.custom_content?.stages?.flatMap(({ attachments: e }) => e ?? []) ?? [];
46
+ return [...t, ...n];
47
+ }), S = (e) => e.endsWith("/"), C = (e) => {
48
+ let t = e.toLowerCase();
49
+ return t.startsWith("http://") || t.startsWith("https://");
50
+ }, w = (e) => !!e && !C(e) && !S(e), T = (e) => [...new Set(x(e).map((e) => e.url).filter((e) => !!e).filter((e) => w(e)))], E = (e, t) => e?.map((e) => ({
51
+ ...e,
52
+ url: e.url ? t[e.url] ?? e.url : e.url
53
+ })), D = (e, t) => ({
54
+ ...e,
55
+ messages: e.messages.map((e) => ({
56
+ ...e,
57
+ custom_content: e.custom_content ? {
58
+ ...e.custom_content,
59
+ attachments: E(e.custom_content.attachments, t),
60
+ stages: e.custom_content.stages?.map((e) => ({
61
+ ...e,
62
+ attachments: E(e.attachments, t)
63
+ }))
64
+ } : e.custom_content
65
+ }))
66
+ }), O = (e) => e?.split(/-\d+$/)[0] ?? "", k = (e) => /\p{L}/u.test(e) || /\p{N}/u.test(e), A = (e) => {
67
+ if (!e) return "";
68
+ let t = e.toLowerCase(), n = [], r = "";
69
+ for (let e of t) k(e) ? r += e : r &&= (n.push(r), "");
70
+ return r && n.push(r), n.join(" ");
76
71
  };
77
- function Y(t, e) {
78
- return `${t?.[0]}/${e}/${t?.[1]}`;
72
+ //#endregion
73
+ //#region libs/shared-toolkit/src/utils/conversation-navigation-to-id.ts
74
+ function j(e, t) {
75
+ return `${e?.[0]}/${t}/${e?.[1]}`;
79
76
  }
80
- const D = (t, e) => (Math.round(t * 10 ** e) / 10 ** e).toString(), z = (t, e) => {
81
- const n = e?.decimal || u.decimal, r = e?.decimalSymbol || u.decimalSymbol, o = e?.digitGroupingSymbol ?? u.digitGroupingSymbol, s = Number(t);
82
- if (s == null || Number.isNaN(s) || t === null || t === "")
83
- return "";
84
- const c = n.replace("0.", ""), l = `${n === "0" ? Math.trunc(s) : D(s, c.length)} `.split(".");
85
- return l[0] = l[0].replace(
86
- /(\d)(?=(\d\d\d)+(?!\d))/g,
87
- `$1${o}`
88
- ), `${l.join(r)}`;
89
- }, X = (t) => {
90
- if (!t.includes("T")) {
91
- for (const n of U) {
92
- const r = h(t, n, /* @__PURE__ */ new Date());
93
- if (m(r))
94
- return r;
95
- }
96
- return null;
97
- }
98
- const e = f(t);
99
- return m(e) ? e : null;
100
- }, U = ["yyyy-MM-dd", "MM-dd-yyyy"], k = (t, e, n) => {
101
- const r = {};
102
- return e?.contentType !== null && (r[T] = e?.contentType || A), e?.jwt ? r.Authorization = `Bearer ${e.jwt}` : t && (r[i] = t), e?.chatReference && (r[N] = e.chatReference), { ...r, ...n };
103
- }, K = (t) => {
104
- const e = { ...t };
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
- }, J = (t) => ({
107
- "Content-Type": `multipart/form-data; boundary=${t}`
108
- }), q = (t) => t?.toLowerCase() === "true", Z = async (t, e, n) => await fetch(t, {
109
- method: n.method || "GET",
110
- headers: e,
111
- body: n.body ? JSON.stringify(n.body) : void 0
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
- decodeURIComponent(t.split("/").at(-1) ?? "")
114
- ), rt = (t) => t.map((e) => ({
115
- ...e,
116
- name: p(e.name)
117
- })), b = /* @__PURE__ */ new Set([
118
- ")",
119
- "]",
120
- "}",
121
- ">",
122
- ",",
123
- ".",
124
- "!",
125
- "?",
126
- ":",
127
- ";"
77
+ //#endregion
78
+ //#region libs/shared-toolkit/src/utils/format-numbers.ts
79
+ var M = (e, t) => (Math.round(e * 10 ** t) / 10 ** t).toString(), N = (e, t) => {
80
+ let n = t?.decimal || a.decimal, r = t?.decimalSymbol || a.decimalSymbol, i = t?.digitGroupingSymbol ?? a.digitGroupingSymbol, o = Number(e);
81
+ if (o == null || Number.isNaN(o) || e === null || e === "") return "";
82
+ let s = n.replace("0.", ""), c = `${n === "0" ? Math.trunc(o) : M(o, s.length)} `.split(".");
83
+ return c[0] = c[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${i}`), `${c.join(r)}`;
84
+ }, P = (r) => {
85
+ if (!r.includes("T")) {
86
+ for (let n of F) {
87
+ let i = t(r, n, /* @__PURE__ */ new Date());
88
+ if (e(i)) return i;
89
+ }
90
+ return null;
91
+ }
92
+ let i = n(r);
93
+ return e(i) ? i : null;
94
+ }, F = ["yyyy-MM-dd", "MM-dd-yyyy"], I = (e, t, n) => {
95
+ let r = {};
96
+ return t?.contentType !== null && (r[s] = t?.contentType || "application/json"), t?.jwt ? r.Authorization = `Bearer ${t.jwt}` : e && (r[c] = e), t?.chatReference && (r[l] = t.chatReference), {
97
+ ...r,
98
+ ...n
99
+ };
100
+ }, L = (e) => {
101
+ let t = { ...e };
102
+ return t["Api-Key"] && (t[c] = t[c].substring(0, 8) + "...[REDACTED]"), t.Authorization &&= "Bearer [REDACTED]", t["Ocp-Apim-Subscription-Key"] && (t[u] = t[u].substring(0, 8) + "...[REDACTED]"), t;
103
+ }, R = (e) => ({ "Content-Type": `multipart/form-data; boundary=${e}` }), z = (e) => e?.toLowerCase() === "true", B = async (e, t, n) => await fetch(e, {
104
+ method: n.method || "GET",
105
+ headers: t,
106
+ body: n.body ? JSON.stringify(n.body) : void 0
107
+ }), V = (e, t) => e?.split("/")?.filter((e) => e !== t)?.join("/"), H = (e) => e.replace(/^conversations\//, ""), U = (e) => e.split("/").slice(0, -1).join("/"), W = (e) => O(decodeURIComponent(e.split("/").at(-1) ?? "")), G = (e) => e.map((e) => ({
108
+ ...e,
109
+ name: O(e.name)
110
+ })), K = new Set([
111
+ ")",
112
+ "]",
113
+ "}",
114
+ ">",
115
+ ",",
116
+ ".",
117
+ "!",
118
+ "?",
119
+ ":",
120
+ ";"
128
121
  ]);
129
- function v(t) {
130
- let e = t.length;
131
- for (; e > 0 && b.has(t[e - 1]); )
132
- e--;
133
- return e === t.length ? { cleanUrl: t, trailing: "" } : {
134
- cleanUrl: t.slice(0, e),
135
- trailing: t.slice(e)
136
- };
122
+ function q(e) {
123
+ let t = e.length;
124
+ for (; t > 0 && K.has(e[t - 1]);) t--;
125
+ return t === e.length ? {
126
+ cleanUrl: e,
127
+ trailing: ""
128
+ } : {
129
+ cleanUrl: e.slice(0, t),
130
+ trailing: e.slice(t)
131
+ };
137
132
  }
138
- function ot(t) {
139
- if (!t) return [{ type: "text", value: "" }];
140
- const e = [];
141
- let n = 0;
142
- for (const r of t.matchAll(/\bhttps?:\/\/[^\s<>"']+/gi)) {
143
- const o = r[0], s = r.index ?? 0;
144
- s > n && e.push({ type: "text", value: t.slice(n, s) });
145
- const { cleanUrl: c, trailing: a } = v(o);
146
- c ? e.push({ type: "link", value: c }) : e.push({ type: "text", value: o }), a && e.push({ type: "text", value: a }), n = s + o.length;
147
- }
148
- return n < t.length && e.push({ type: "text", value: t.slice(n) }), e.length ? e : [{ type: "text", value: t }];
133
+ function J(e) {
134
+ if (!e) return [{
135
+ type: "text",
136
+ value: ""
137
+ }];
138
+ let t = [], n = 0;
139
+ for (let r of e.matchAll(/\bhttps?:\/\/[^\s<>"']+/gi)) {
140
+ let i = r[0], a = r.index ?? 0;
141
+ a > n && t.push({
142
+ type: "text",
143
+ value: e.slice(n, a)
144
+ });
145
+ let { cleanUrl: o, trailing: s } = q(i);
146
+ o ? t.push({
147
+ type: "link",
148
+ value: o
149
+ }) : t.push({
150
+ type: "text",
151
+ value: i
152
+ }), s && t.push({
153
+ type: "text",
154
+ value: s
155
+ }), n = a + i.length;
156
+ }
157
+ return n < e.length && t.push({
158
+ type: "text",
159
+ value: e.slice(n)
160
+ }), t.length ? t : [{
161
+ type: "text",
162
+ value: e
163
+ }];
149
164
  }
150
- export {
151
- i as API_KEY_HEADER,
152
- M as API_ROUTES,
153
- A as APPLICATION_JSON,
154
- T as CONTENT_TYPE_HEADER,
155
- w as CUSTOM_PERIOD,
156
- _ as CalendarResolution,
157
- L as HTTP_ERROR_CODES,
158
- $ as HttpError,
159
- g as Locale,
160
- d as OCP_APIM_SUBSCRIPTION_KEY_HEADER,
161
- B as ONBOARDING_MODEL_POSTFIX,
162
- O as QueryFilterType,
163
- P as SHARE_CONVERSATION_ROUTE,
164
- N as X_CONVERSATION_ID_HEADER,
165
- x as X_SOURCE_ARTEFACT_URN_HEADER,
166
- rt as cleanConversationNames,
167
- u as defaultFormatNumbers,
168
- p as deleteConversationNamePostfix,
169
- z as formatNumberBySign,
170
- V as getClearedConversationName,
171
- j as getConversationAttachmentUrls,
172
- C as getConversationAttachments,
173
- et as getConversationFolderIdFromConversationId,
174
- Y as getConversationId,
175
- tt as getConversationIdFromResourceUrl,
176
- nt as getConversationNameFromConversationId,
177
- G as getConversationNavPath,
178
- Q as getConversationUrlWithoutLocale,
179
- k as getHeaders,
180
- J as getMultipartHeaders,
181
- X as getTimePeriod,
182
- S as isDialFileAttachmentUrl,
183
- F as isHttpError,
184
- ot as linkifyText,
185
- q as parseBoolean,
186
- W as replaceConversationAttachmentUrls,
187
- K as sanitizeHeaders,
188
- Z as sendRequest,
189
- v as splitTrailingPunctuation
190
- };
165
+ //#endregion
166
+ export { c as API_KEY_HEADER, r as API_ROUTES, o as APPLICATION_JSON, s as CONTENT_TYPE_HEADER, i as CUSTOM_PERIOD, _ as CalendarResolution, f as HTTP_ERROR_CODES, h as HttpError, v as Locale, u as OCP_APIM_SUBSCRIPTION_KEY_HEADER, p as ONBOARDING_MODEL_POSTFIX, y as QueryFilterType, m as SHARE_CONVERSATION_ROUTE, l as X_CONVERSATION_ID_HEADER, d as X_SOURCE_ARTEFACT_URN_HEADER, G as cleanConversationNames, a as defaultFormatNumbers, O as deleteConversationNamePostfix, N as formatNumberBySign, A as getClearedConversationName, T as getConversationAttachmentUrls, x as getConversationAttachments, U as getConversationFolderIdFromConversationId, j as getConversationId, H as getConversationIdFromResourceUrl, W as getConversationNameFromConversationId, b as getConversationNavPath, V as getConversationUrlWithoutLocale, I as getHeaders, R as getMultipartHeaders, P as getTimePeriod, w as isDialFileAttachmentUrl, g as isHttpError, J as linkifyText, z as parseBoolean, D as replaceConversationAttachmentUrls, L as sanitizeHeaders, B as sendRequest, q as splitTrailingPunctuation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epam/statgpt-shared-toolkit",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -13,7 +13,7 @@
13
13
  "browser": "./index.mjs",
14
14
  "module": "./index.mjs",
15
15
  "types": "./index.d.ts",
16
- "dependencies": {
16
+ "peerDependencies": {
17
17
  "@epam/ai-dial-shared": "^0.43.3",
18
18
  "date-fns": "^4.1.0"
19
19
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 EPAM Systems
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.