@epam/ai-dial-chat-hooks 1.1.0-dev.456 → 1.1.0-dev.459

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/file-manager.d.ts CHANGED
@@ -85,6 +85,8 @@ export declare interface AttachmentCanvasUrlResolvers {
85
85
  resolveDialFileDownloadUrl: (fileId: string) => string | undefined;
86
86
  /** Resolves the best downloadable DIAL-file URL from an attachment's `url` or `referenceUrl`. */
87
87
  resolveDialUrl: (attachment: DisplayAttachment) => string | undefined;
88
+ /** Resolves a DIAL Core file id to a fetchable metadata URL (used for cache-freshness validation). */
89
+ resolveDialFileMetadataUrl: (fileId: string) => string | undefined;
88
90
  }
89
91
 
90
92
  /** The type of content the canvas can display. */
@@ -17,45 +17,80 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
17
17
  url: e
18
18
  }), b = new h({ max: 10 }), x = new h({ max: 50 }), S = () => {
19
19
  b.clear(), x.clear();
20
- }, C = (e) => {
21
- let t = b.get(e);
22
- return t ?? (t = fetch(e).then((e) => {
20
+ }, C = async (e, t) => {
21
+ let n = t.resolveDialFileMetadataUrl(e);
22
+ if (n != null) try {
23
+ let e = await fetch(n);
24
+ if (!e.ok) return;
25
+ let t = (await e.json())?.etag;
26
+ return typeof t == "string" ? t : void 0;
27
+ } catch {
28
+ return;
29
+ }
30
+ }, w = async (e, t, n) => {
31
+ let r = await C(t, n);
32
+ if (r == null) return fetch(e).then((e) => {
33
+ if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
34
+ return e.blob();
35
+ });
36
+ let i = b.get(e);
37
+ if (i != null && i.etag === r) return i.promise;
38
+ b.delete(e);
39
+ let a = fetch(e).then((e) => {
23
40
  if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
24
41
  return e.blob();
25
42
  }).catch((t) => {
26
43
  throw b.delete(e), t;
27
- }), b.set(e, t)), t;
28
- }, w = (e) => {
29
- let t = x.get(e);
30
- return t ?? (t = fetch(e).then((e) => {
44
+ });
45
+ return b.set(e, {
46
+ etag: r,
47
+ promise: a
48
+ }), a;
49
+ }, T = async (e, t, n) => {
50
+ let r = await C(t, n);
51
+ if (r == null) return fetch(e).then((e) => {
52
+ if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
53
+ return e.text();
54
+ });
55
+ let i = x.get(e);
56
+ if (i != null && i.etag === r) return i.promise;
57
+ x.delete(e);
58
+ let a = fetch(e).then((e) => {
31
59
  if (!e.ok) throw Object.assign(/* @__PURE__ */ Error(`HTTP ${e.status}`), { status: e.status });
32
60
  return e.text();
33
61
  }).catch((t) => {
34
62
  throw x.delete(e), t;
35
- }), x.set(e, t)), t;
36
- }, T = async (e, t) => {
63
+ });
64
+ return x.set(e, {
65
+ etag: r,
66
+ promise: a
67
+ }), a;
68
+ }, E = (e) => e.split("#")[0], D = (t) => {
69
+ if (t.url != null && e(t.url)) return E(t.url);
70
+ if (t.referenceUrl != null && e(t.referenceUrl)) return E(t.referenceUrl);
71
+ }, O = async (e, t) => {
37
72
  if ("file" in e) return URL.createObjectURL(e.file);
38
73
  let n = t.resolveDialUrl(e);
39
74
  if (n != null) try {
40
- let e = await C(n);
41
- return URL.createObjectURL(e);
75
+ let r = await w(n, D(e) ?? "", t);
76
+ return URL.createObjectURL(r);
42
77
  } catch (e) {
43
78
  let t = e.status;
44
79
  return t == null ? y(n) : v(t, n);
45
80
  }
46
81
  if (e.previewUrl != null) return e.previewUrl;
47
82
  if (e.data != null) return g(e.data, e.contentType);
48
- }, E = async (e, t) => {
83
+ }, k = async (e, t) => {
49
84
  if (e.data != null) return _(e.data);
50
85
  let n = t.resolveDialUrl(e);
51
86
  if (n != null) try {
52
- return await w(n);
87
+ return await T(n, D(e) ?? "", t);
53
88
  } catch (e) {
54
89
  let t = e.status;
55
90
  return t == null ? y(n) : v(t, n);
56
91
  }
57
92
  if ("file" in e) return e.file.text();
58
- }, D = (e, t) => e.data != null || t.resolveDialUrl(e) != null || "file" in e, O = (e, n) => {
93
+ }, A = (e, t) => e.data != null || t.resolveDialUrl(e) != null || "file" in e, j = (e, n) => {
59
94
  if ("file" in e) return {
60
95
  type: t.Image,
61
96
  url: URL.createObjectURL(e.file)
@@ -71,37 +106,37 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
71
106
  type: t.Image,
72
107
  url: r
73
108
  };
74
- }, k = async (e, n) => {
75
- let r = await E(e, n);
109
+ }, M = async (e, n) => {
110
+ let r = await k(e, n);
76
111
  return r == null ? null : typeof r == "string" ? {
77
112
  type: t.PlainText,
78
113
  text: r
79
114
  } : r;
80
- }, A = async (e, n) => {
81
- let r = await E(e, n);
115
+ }, N = async (e, n) => {
116
+ let r = await k(e, n);
82
117
  return r == null ? null : typeof r == "string" ? {
83
118
  type: t.Markdown,
84
119
  text: r
85
120
  } : r;
86
- }, j = 1048576, M = async (e, n, r) => {
87
- let i = await E(e, n);
121
+ }, P = 1048576, F = async (e, n, r) => {
122
+ let i = await k(e, n);
88
123
  return i == null ? null : typeof i == "string" ? {
89
124
  type: t.Code,
90
125
  text: i,
91
126
  language: r
92
127
  } : i;
93
- }, N = async (e, n) => {
94
- let r = await E(e, n);
128
+ }, I = async (e, n) => {
129
+ let r = await k(e, n);
95
130
  if (r == null) return null;
96
131
  if (typeof r != "string") return r;
97
- if (r.length > j) return null;
132
+ if (r.length > P) return null;
98
133
  let i = n.resolveDialUrl(e) ?? void 0;
99
134
  return {
100
135
  type: t.Html,
101
136
  srcdoc: r,
102
137
  url: i
103
138
  };
104
- }, P = (n, r, i) => {
139
+ }, L = (n, r, i) => {
105
140
  let a = n.body?.source?.attachment;
106
141
  if (a?.type !== o.PDF) return null;
107
142
  let s = e(a.url) ? i.resolveDialFileDownloadUrl(a.url) : a.url;
@@ -114,7 +149,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
114
149
  selectedHighlightId: f.some((e) => e.id === m) ? m : void 0,
115
150
  page: p(n)
116
151
  };
117
- }, F = (e) => {
152
+ }, R = (e) => {
118
153
  switch (e.type) {
119
154
  case "docx_text_range": return {
120
155
  kind: i.DocxTextRange,
@@ -139,7 +174,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
139
174
  end: e.end
140
175
  };
141
176
  }
142
- }, I = (n, i, o) => {
177
+ }, z = (n, i, o) => {
143
178
  let s = n.body?.source?.attachment;
144
179
  if (s?.url == null) return null;
145
180
  let c = a(s.title ?? s.url, s.type);
@@ -153,7 +188,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
153
188
  let i = l(e, t);
154
189
  m.push({
155
190
  id: i,
156
- locations: r.map(F)
191
+ locations: r.map(R)
157
192
  }), e === n && (h = i);
158
193
  }), {
159
194
  type: t.Ooxml,
@@ -164,7 +199,7 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
164
199
  selectedHighlightId: h
165
200
  } : {}
166
201
  };
167
- }, L = (n, r) => {
202
+ }, B = (n, r) => {
168
203
  let i = m(n.url);
169
204
  if (i == null) return null;
170
205
  let a = e(i.baseUrl) ? r.resolveDialFileDownloadUrl(i.baseUrl) : i.baseUrl;
@@ -194,39 +229,39 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
194
229
  selectedHighlightId: o,
195
230
  page: i.page
196
231
  };
197
- }, R = (e) => {
232
+ }, V = (e) => {
198
233
  try {
199
234
  let t = new URL(e).protocol;
200
235
  return t === "http:" || t === "https:" || t === "blob:";
201
236
  } catch {
202
237
  return !1;
203
238
  }
204
- }, z = (t) => t.url != null && !e(t.url) && R(t.url) ? t.url : void 0, B = async (e, n) => {
205
- let r = await T(e, n);
239
+ }, H = (t) => t.url != null && !e(t.url) && V(t.url) ? t.url : void 0, U = async (e, n) => {
240
+ let r = await O(e, n);
206
241
  if (r != null) return typeof r == "string" ? {
207
242
  type: t.Pdf,
208
243
  url: r
209
244
  } : r;
210
- let i = z(e);
245
+ let i = H(e);
211
246
  return i == null ? null : {
212
247
  type: t.Pdf,
213
248
  url: i
214
249
  };
215
- }, V = async (e, n, r) => {
216
- let i = await T(e, n);
250
+ }, W = async (e, n, r) => {
251
+ let i = await O(e, n);
217
252
  if (i != null) return typeof i == "string" ? {
218
253
  type: t.Ooxml,
219
254
  url: i,
220
255
  format: r
221
256
  } : i;
222
- let a = z(e);
257
+ let a = H(e);
223
258
  return a == null ? null : {
224
259
  type: t.Ooxml,
225
260
  url: a,
226
261
  format: r
227
262
  };
228
- }, H = async (e, n) => {
229
- let r = await E(e, n);
263
+ }, G = async (e, n) => {
264
+ let r = await k(e, n);
230
265
  if (r == null) return null;
231
266
  if (typeof r != "string") return r;
232
267
  try {
@@ -241,8 +276,8 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
241
276
  text: r
242
277
  };
243
278
  }
244
- }, U = async (e, n, r, i) => {
245
- let a = await E(e, n);
279
+ }, K = async (e, n, r, i) => {
280
+ let a = await k(e, n);
246
281
  if (a == null || typeof a != "string") return null;
247
282
  let o = {};
248
283
  try {
@@ -265,4 +300,4 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
265
300
  };
266
301
  };
267
302
  //#endregion
268
- export { I as annotationToOoxmlCanvasContent, P as annotationToPdfCanvasContent, S as clearAttachmentCache, D as hasAttachmentTextSource, L as referenceAttachmentToPdfCanvasContent, M as resolveCodeCanvasContent, N as resolveHtmlCanvasContent, O as resolveImageCanvasContent, H as resolveJsonCanvasContent, A as resolveMarkdownCanvasContent, V as resolveOoxmlCanvasContent, B as resolvePdfCanvasContent, k as resolveTextCanvasContent, U as resolveVisualizerCanvasContent };
303
+ export { z as annotationToOoxmlCanvasContent, L as annotationToPdfCanvasContent, S as clearAttachmentCache, A as hasAttachmentTextSource, B as referenceAttachmentToPdfCanvasContent, F as resolveCodeCanvasContent, I as resolveHtmlCanvasContent, j as resolveImageCanvasContent, G as resolveJsonCanvasContent, N as resolveMarkdownCanvasContent, W as resolveOoxmlCanvasContent, U as resolvePdfCanvasContent, M as resolveTextCanvasContent, K as resolveVisualizerCanvasContent };
package/index.d.ts CHANGED
@@ -277,6 +277,8 @@ export declare interface AttachmentCanvasUrlResolvers {
277
277
  resolveDialFileDownloadUrl: (fileId: string) => string | undefined;
278
278
  /** Resolves the best downloadable DIAL-file URL from an attachment's `url` or `referenceUrl`. */
279
279
  resolveDialUrl: (attachment: DisplayAttachment) => string | undefined;
280
+ /** Resolves a DIAL Core file id to a fetchable metadata URL (used for cache-freshness validation). */
281
+ resolveDialFileMetadataUrl: (fileId: string) => string | undefined;
280
282
  }
281
283
 
282
284
  /** The type of content the canvas can display. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.1.0-dev.456",
4
+ "version": "1.1.0-dev.459",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -104,21 +104,21 @@
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^19.2.6",
107
- "@epam/ai-dial-attachment-canvas": "1.1.0-dev.456",
108
- "@epam/ai-dial-attachment-input": "1.1.0-dev.456",
109
- "@epam/ai-dial-catalog": "1.1.0-dev.456",
110
- "@epam/ai-dial-chat-api-client": "1.1.0-dev.456",
111
- "@epam/ai-dial-chat-overlay": "1.1.0-dev.456",
112
- "@epam/ai-dial-chat-shared": "1.1.0-dev.456",
113
- "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.456",
114
- "@epam/ai-dial-mcp-apps": "1.1.0-dev.456",
115
- "@epam/ai-dial-publish-panel": "1.1.0-dev.456",
116
- "@epam/ai-dial-quotations": "1.1.0-dev.456",
107
+ "@epam/ai-dial-attachment-canvas": "1.1.0-dev.459",
108
+ "@epam/ai-dial-attachment-input": "1.1.0-dev.459",
109
+ "@epam/ai-dial-catalog": "1.1.0-dev.459",
110
+ "@epam/ai-dial-chat-api-client": "1.1.0-dev.459",
111
+ "@epam/ai-dial-chat-overlay": "1.1.0-dev.459",
112
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.459",
113
+ "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.459",
114
+ "@epam/ai-dial-mcp-apps": "1.1.0-dev.459",
115
+ "@epam/ai-dial-publish-panel": "1.1.0-dev.459",
116
+ "@epam/ai-dial-quotations": "1.1.0-dev.459",
117
117
  "@epam/ai-dial-react-file-manager": "*",
118
- "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.456",
119
- "@epam/ai-dial-share": "1.1.0-dev.456",
120
- "@epam/ai-dial-skill-editor": "1.1.0-dev.456",
121
- "@epam/ai-dial-source-panel": "1.1.0-dev.456",
118
+ "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.459",
119
+ "@epam/ai-dial-share": "1.1.0-dev.459",
120
+ "@epam/ai-dial-skill-editor": "1.1.0-dev.459",
121
+ "@epam/ai-dial-source-panel": "1.1.0-dev.459",
122
122
  "@epam/ai-dial-ui-kit": "*",
123
123
  "@modelcontextprotocol/sdk": "^1.27.1",
124
124
  "@epam/pdf-highlighter-kit": ">=0.0.14",