@epam/ai-dial-chat-hooks 1.3.0-dev.282 → 1.3.0-dev.288
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/entry-points/project.d.ts +3 -0
- package/entry-points/project.d.ts.map +1 -1
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +122 -119
- package/package.json +17 -17
- package/project/project-events.d.ts +2 -2
- package/project/project-events.d.ts.map +1 -1
- package/project/project-events.js +3 -2
- package/project/project-refresh.d.ts +12 -0
- package/project/project-refresh.d.ts.map +1 -0
- package/project/project-refresh.js +6 -0
- package/project/project-watch-stream.d.ts +26 -0
- package/project/project-watch-stream.d.ts.map +1 -0
- package/project/project-watch-stream.js +39 -0
- package/project/projects-api-client.d.ts +6 -0
- package/project/projects-api-client.d.ts.map +1 -1
- package/project/projects-api-client.js +1 -0
- package/project/use-project-conversations.d.ts +8 -6
- package/project/use-project-conversations.d.ts.map +1 -1
- package/project/use-project-conversations.js +129 -56
- package/project/use-project-watch.d.ts +24 -0
- package/project/use-project-watch.d.ts.map +1 -0
- package/project/use-project-watch.js +41 -0
- package/project/use-project.d.ts +4 -1
- package/project/use-project.d.ts.map +1 -1
- package/project/use-project.js +47 -22
- package/project/use-projects.d.ts.map +1 -1
- package/project/use-projects.js +49 -68
- package/project.js +8 -5
- package/shared/serialized-writer.d.ts +10 -0
- package/shared/serialized-writer.d.ts.map +1 -0
- package/shared/serialized-writer.js +35 -0
package/project/use-projects.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
import { mapProjectDtoToItem as e, mapProjectSource as t } from "./project-mapping.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useCallback as
|
|
2
|
+
import { applyProjectEvent as n } from "./project-events.js";
|
|
3
|
+
import { runProjectWatch as r } from "./project-watch-stream.js";
|
|
4
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
5
5
|
//#region src/project/use-projects.ts
|
|
6
|
-
var
|
|
7
|
-
1e3,
|
|
8
|
-
2e3,
|
|
9
|
-
4e3,
|
|
10
|
-
8e3,
|
|
11
|
-
16e3
|
|
12
|
-
], d = "\n", f = ({ items: n, incompleteSources: r }, i) => {
|
|
6
|
+
var c = 1e3, l = "\n", u = ({ items: n, incompleteSources: r }, i) => {
|
|
13
7
|
let a = n.map(e);
|
|
14
8
|
return {
|
|
15
9
|
reloadToken: i,
|
|
16
10
|
projects: a,
|
|
17
11
|
incompleteSources: r.map(t),
|
|
18
12
|
hasError: !1,
|
|
19
|
-
watchKey: a.slice(0,
|
|
13
|
+
watchKey: a.slice(0, c).map(({ id: e }) => e).sort().join(l)
|
|
20
14
|
};
|
|
21
|
-
},
|
|
22
|
-
let [
|
|
23
|
-
|
|
15
|
+
}, d = (e, t) => {
|
|
16
|
+
let [c, d] = s(0), [f, p] = s(), m = o(!1), h = o(void 0);
|
|
17
|
+
a(() => {
|
|
24
18
|
if (!t) return;
|
|
25
19
|
let n = new AbortController();
|
|
26
20
|
return (async () => {
|
|
27
21
|
try {
|
|
28
22
|
let t = await e.listProjects(n.signal);
|
|
29
23
|
if (n.signal.aborted) return;
|
|
30
|
-
|
|
24
|
+
p(u(t, c));
|
|
31
25
|
} catch {
|
|
32
26
|
if (n.signal.aborted) return;
|
|
33
|
-
|
|
34
|
-
reloadToken:
|
|
27
|
+
p({
|
|
28
|
+
reloadToken: c,
|
|
35
29
|
projects: [],
|
|
36
30
|
incompleteSources: [],
|
|
37
31
|
hasError: !0,
|
|
@@ -42,70 +36,57 @@ var l = 1e3, u = [
|
|
|
42
36
|
}, [
|
|
43
37
|
e,
|
|
44
38
|
t,
|
|
45
|
-
|
|
39
|
+
c
|
|
46
40
|
]);
|
|
47
|
-
let
|
|
48
|
-
|
|
41
|
+
let g = i(async () => {
|
|
42
|
+
h.current?.abort();
|
|
49
43
|
let t = new AbortController();
|
|
50
|
-
|
|
44
|
+
h.current = t;
|
|
51
45
|
try {
|
|
52
46
|
let n = await e.listProjects(t.signal);
|
|
53
47
|
if (t.signal.aborted) return;
|
|
54
|
-
|
|
48
|
+
p((e) => e == null || e.hasError ? e : u(n, e.reloadToken));
|
|
55
49
|
} catch {}
|
|
56
50
|
}, [e]);
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
a(() => () => h.current?.abort(), []);
|
|
52
|
+
let _ = f?.reloadToken === c ? f : void 0, v = t ? _?.watchKey ?? "" : "", { watchProjects: y } = e;
|
|
53
|
+
a(() => {
|
|
54
|
+
if (y == null || v === "" || m.current) return;
|
|
55
|
+
let e = new AbortController();
|
|
56
|
+
return r({
|
|
57
|
+
watchProjects: y,
|
|
58
|
+
ids: v.split(l),
|
|
59
|
+
signal: e.signal,
|
|
60
|
+
onEvent: (e) => p((t) => {
|
|
61
|
+
if (t == null) return t;
|
|
62
|
+
let r = n(t.projects, e);
|
|
63
|
+
return r === t.projects ? t : {
|
|
64
|
+
...t,
|
|
65
|
+
projects: r
|
|
69
66
|
};
|
|
70
|
-
}),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (t.signal.aborted) return;
|
|
77
|
-
if (!i) {
|
|
78
|
-
g.current = !0;
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
c(r + 1);
|
|
82
|
-
return;
|
|
67
|
+
}),
|
|
68
|
+
onReconnected: () => {
|
|
69
|
+
g();
|
|
70
|
+
},
|
|
71
|
+
onUnavailable: () => {
|
|
72
|
+
m.current = !0;
|
|
83
73
|
}
|
|
84
|
-
|
|
85
|
-
}, c = (e) => {
|
|
86
|
-
let t = u[e];
|
|
87
|
-
t == null ? g.current = !0 : a = setTimeout(() => {
|
|
88
|
-
s(e, !0);
|
|
89
|
-
}, t);
|
|
90
|
-
};
|
|
91
|
-
return s(0, !1), () => {
|
|
92
|
-
t.abort(), clearTimeout(a);
|
|
93
|
-
};
|
|
74
|
+
}), () => e.abort();
|
|
94
75
|
}, [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
76
|
+
y,
|
|
77
|
+
v,
|
|
78
|
+
g
|
|
98
79
|
]);
|
|
99
|
-
let
|
|
100
|
-
|
|
80
|
+
let b = i(() => {
|
|
81
|
+
d((e) => e + 1);
|
|
101
82
|
}, []);
|
|
102
83
|
return {
|
|
103
|
-
projects:
|
|
104
|
-
incompleteSources:
|
|
105
|
-
isLoading: t &&
|
|
106
|
-
hasError:
|
|
107
|
-
retry:
|
|
84
|
+
projects: _?.projects ?? [],
|
|
85
|
+
incompleteSources: _?.incompleteSources ?? [],
|
|
86
|
+
isLoading: t && _ == null,
|
|
87
|
+
hasError: _?.hasError ?? !1,
|
|
88
|
+
retry: b
|
|
108
89
|
};
|
|
109
90
|
};
|
|
110
91
|
//#endregion
|
|
111
|
-
export {
|
|
92
|
+
export { d as useProjects };
|
package/project.js
CHANGED
|
@@ -3,8 +3,11 @@ import { mapProjectDetailsToViewModel as r, mapProjectDtoToItem as i, mapProject
|
|
|
3
3
|
import { DEFAULT_PROJECT_CONTEXT_ALLOWED_EXTENSIONS as s, DEFAULT_PROJECT_CONTEXT_FILE_MAX_BYTES as c, DEFAULT_PROJECT_CONTEXT_TOTAL_MAX_BYTES as l, getMimeTypesForExtensions as u, resolveByteLimit as d, resolveExtensionList as f } from "./project/project-limits.js";
|
|
4
4
|
import { ProjectFormErrorField as p, ProjectFormErrorReason as m, getProjectFormError as h } from "./project/project-form-errors.js";
|
|
5
5
|
import { useProjects as g } from "./project/use-projects.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
6
|
+
import { ProjectRefreshOutcome as _ } from "./project/project-refresh.js";
|
|
7
|
+
import { useProject as v } from "./project/use-project.js";
|
|
8
|
+
import { useProjectWatch as y } from "./project/use-project-watch.js";
|
|
9
|
+
import { useCreateProject as b, useSaveProject as x } from "./project/use-project-submit.js";
|
|
10
|
+
import { useProjectConversations as S } from "./project/use-project-conversations.js";
|
|
11
|
+
import { ProjectActionError as C, useProjectActions as w } from "./project/use-project-actions.js";
|
|
12
|
+
import { createSerializedKeyedWriter as T } from "./shared/serialized-writer.js";
|
|
13
|
+
export { s as DEFAULT_PROJECT_CONTEXT_ALLOWED_EXTENSIONS, c as DEFAULT_PROJECT_CONTEXT_FILE_MAX_BYTES, l as DEFAULT_PROJECT_CONTEXT_TOTAL_MAX_BYTES, C as ProjectActionError, p as ProjectFormErrorField, m as ProjectFormErrorReason, _ as ProjectRefreshOutcome, e as buildCreateConversationDto, t as createProjectsApiClient, T as createSerializedKeyedWriter, u as getMimeTypesForExtensions, h as getProjectFormError, r as mapProjectDetailsToViewModel, i as mapProjectDtoToItem, a as mapProjectSource, o as mapStoredContextFiles, d as resolveByteLimit, f as resolveExtensionList, n as splitProjectConversationId, b as useCreateProject, v as useProject, w as useProjectActions, S as useProjectConversations, y as useProjectWatch, g as useProjects, x as useSaveProject };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A write queue that runs one write at a time, in call order, and never queues a key twice. */
|
|
2
|
+
export interface SerializedKeyedWriter {
|
|
3
|
+
/** Queues a write for `key`, or joins the one already queued; settles when that write ran or was dropped. */
|
|
4
|
+
enqueue: (key: string) => Promise<void>;
|
|
5
|
+
/** Drops the write queued for `key` if it has not started; its promise resolves without writing. */
|
|
6
|
+
drop: (key: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** Returns a {@link SerializedKeyedWriter} over `write`; a failed write rejects only its own callers. */
|
|
9
|
+
export declare const createSerializedKeyedWriter: (write: (key: string) => Promise<void>) => SerializedKeyedWriter;
|
|
10
|
+
//# sourceMappingURL=serialized-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialized-writer.d.ts","sourceRoot":"","sources":["../../src/shared/serialized-writer.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,WAAW,qBAAqB;IACpC,6GAA6G;IAC7G,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,oGAAoG;IACpG,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAQD,yGAAyG;AACzG,eAAO,MAAM,2BAA2B,GACtC,OAAO,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,KACpC,qBAuCF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/shared/serialized-writer.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = /* @__PURE__ */ new Map(), n = Promise.resolve();
|
|
4
|
+
return {
|
|
5
|
+
enqueue: (r) => {
|
|
6
|
+
let i = t.get(r);
|
|
7
|
+
if (i) return i.promise;
|
|
8
|
+
let a, o, s = new Promise((e, t) => {
|
|
9
|
+
a = e, o = t;
|
|
10
|
+
}), c = {
|
|
11
|
+
promise: s,
|
|
12
|
+
resolve: a,
|
|
13
|
+
reject: o
|
|
14
|
+
};
|
|
15
|
+
t.set(r, c);
|
|
16
|
+
let l = n;
|
|
17
|
+
return n = (async () => {
|
|
18
|
+
if (await l, t.get(r) !== c) c.resolve();
|
|
19
|
+
else {
|
|
20
|
+
t.delete(r);
|
|
21
|
+
try {
|
|
22
|
+
await e(r), c.resolve();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
c.reject(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
})(), s;
|
|
28
|
+
},
|
|
29
|
+
drop: (e) => {
|
|
30
|
+
t.delete(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { e as createSerializedKeyedWriter };
|