@burdenoff/fe-libs 2026.528.3 → 2026.528.5
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.
|
@@ -13,6 +13,15 @@ export interface ActorInput {
|
|
|
13
13
|
actorType: string;
|
|
14
14
|
}
|
|
15
15
|
export interface UseActorProfilesOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Override the global gateway base URL. Most callers should leave this
|
|
18
|
+
* unset — the hook resolves the correct global gateway URL from the
|
|
19
|
+
* current hostname (LOCAL/ALPHA/PROD).
|
|
20
|
+
*
|
|
21
|
+
* Note: many microfes are handed a *workspace* gateway URL as their
|
|
22
|
+
* `apiGatewayUrl` prop, which is NOT compatible with this user query.
|
|
23
|
+
* Don't forward such a prop here unless you know it's a global URL.
|
|
24
|
+
*/
|
|
16
25
|
apiGatewayUrl?: string;
|
|
17
26
|
authToken?: string;
|
|
18
27
|
orgId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActorProfiles.d.ts","sourceRoot":"","sources":["../../../src/shared/actors/useActorProfiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useActorProfiles.d.ts","sourceRoot":"","sources":["../../../src/shared/actors/useActorProfiles.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAE3D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAmDD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAWlE;AAsBD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,uBAA4B,GACpC,eAAe,CAsHjB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolveGatewayUrls as e } from "../config/gatewayUrls.js";
|
|
2
|
+
import { graphqlFetch as t } from "../graphql/fetch.js";
|
|
3
|
+
import { useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
|
|
3
4
|
//#region src/shared/actors/useActorProfiles.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
5
|
+
var o = "\n query ActorProfileUser($id: ID!) {\n user(id: $id) {\n id\n email\n firstName\n lastName\n name\n username\n avatar\n }\n }\n";
|
|
6
|
+
function s(e) {
|
|
6
7
|
return e.length <= 12 ? e : `${e.slice(0, 8)}…${e.slice(-4)}`;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function c(e) {
|
|
9
10
|
switch (e.toLowerCase()) {
|
|
10
11
|
case "user": return "User";
|
|
11
12
|
case "app": return "App";
|
|
@@ -14,97 +15,104 @@ function s(e) {
|
|
|
14
15
|
default: return e.split("_").map((e) => e.charAt(0) + e.slice(1).toLowerCase()).join(" ");
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function l(e) {
|
|
18
19
|
return {
|
|
19
20
|
actorId: e.actorId,
|
|
20
21
|
actorType: e.actorType,
|
|
21
|
-
displayName: e.actorType.toLowerCase() === "user" ? `User ${
|
|
22
|
-
secondaryLabel:
|
|
22
|
+
displayName: e.actorType.toLowerCase() === "user" ? `User ${s(e.actorId)}` : c(e.actorType),
|
|
23
|
+
secondaryLabel: s(e.actorId),
|
|
23
24
|
resolved: !1
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
let t =
|
|
27
|
+
var u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = 300 * 1e3, p = /* @__PURE__ */ new Map();
|
|
28
|
+
function m(e) {
|
|
29
|
+
let t = p.get(e);
|
|
29
30
|
if (!t || t < Date.now()) {
|
|
30
|
-
|
|
31
|
+
u.delete(e), p.delete(e);
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
|
-
return
|
|
34
|
+
return u.get(e);
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
36
|
+
function h(e) {
|
|
37
|
+
u.set(e.actorId, e), p.set(e.actorId, Date.now() + f);
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
let { apiGatewayUrl:
|
|
39
|
+
function g(c, u = {}) {
|
|
40
|
+
let { apiGatewayUrl: f, authToken: p, orgId: g } = u, _ = r(() => {
|
|
41
|
+
if (f && !f.includes("workspaces")) return f;
|
|
42
|
+
try {
|
|
43
|
+
return e().globalBaseUrl;
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}, [f]), [v, y] = a(() => {
|
|
40
48
|
let e = {};
|
|
41
|
-
for (let t of
|
|
42
|
-
let n =
|
|
43
|
-
e[t.actorId] = n ??
|
|
49
|
+
for (let t of c) {
|
|
50
|
+
let n = m(t.actorId);
|
|
51
|
+
e[t.actorId] = n ?? l(t);
|
|
44
52
|
}
|
|
45
53
|
return e;
|
|
46
|
-
}),
|
|
47
|
-
return
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
async function n(
|
|
51
|
-
let n =
|
|
54
|
+
}), b = r(() => c.map((e) => `${e.actorId}|${e.actorType}`).sort().join(","), [c]), x = i(void 0);
|
|
55
|
+
return n(() => {
|
|
56
|
+
let e = !1;
|
|
57
|
+
x.current = p;
|
|
58
|
+
async function n(e) {
|
|
59
|
+
let n = m(e.actorId);
|
|
52
60
|
if (n?.resolved) return n;
|
|
53
|
-
if (
|
|
54
|
-
let
|
|
55
|
-
return
|
|
61
|
+
if (e.actorType.toLowerCase() !== "user") {
|
|
62
|
+
let t = l(e);
|
|
63
|
+
return h(t), t;
|
|
56
64
|
}
|
|
57
|
-
let r =
|
|
65
|
+
let r = e.actorId, i = d.get(r);
|
|
58
66
|
if (i) return i;
|
|
59
|
-
let
|
|
67
|
+
let a = (async () => {
|
|
60
68
|
try {
|
|
61
|
-
let n = await
|
|
69
|
+
let n = await t({
|
|
62
70
|
gateway: "global",
|
|
63
|
-
baseUrl:
|
|
64
|
-
authToken:
|
|
65
|
-
organizationId:
|
|
66
|
-
query:
|
|
67
|
-
variables: { id:
|
|
71
|
+
baseUrl: _,
|
|
72
|
+
authToken: p,
|
|
73
|
+
organizationId: g,
|
|
74
|
+
query: o,
|
|
75
|
+
variables: { id: e.actorId }
|
|
68
76
|
});
|
|
69
77
|
if (n.errors?.length || !n.data?.user) {
|
|
70
|
-
let
|
|
71
|
-
return
|
|
78
|
+
let t = l(e);
|
|
79
|
+
return h(t), t;
|
|
72
80
|
}
|
|
73
|
-
let r = n.data.user, i = r.name?.trim() || [r.firstName, r.lastName].filter(Boolean).join(" ").trim() || r.username?.trim() || r.email?.trim() || `User ${
|
|
74
|
-
actorId:
|
|
75
|
-
actorType:
|
|
81
|
+
let r = n.data.user, i = r.name?.trim() || [r.firstName, r.lastName].filter(Boolean).join(" ").trim() || r.username?.trim() || r.email?.trim() || `User ${s(e.actorId)}`, a = {
|
|
82
|
+
actorId: e.actorId,
|
|
83
|
+
actorType: e.actorType,
|
|
76
84
|
displayName: i,
|
|
77
|
-
secondaryLabel: r.email ??
|
|
85
|
+
secondaryLabel: r.email ?? s(e.actorId),
|
|
78
86
|
email: r.email ?? void 0,
|
|
79
87
|
avatarUrl: r.avatar ?? void 0,
|
|
80
88
|
resolved: !0
|
|
81
89
|
};
|
|
82
|
-
return
|
|
90
|
+
return h(a), a;
|
|
83
91
|
} catch {
|
|
84
|
-
return
|
|
92
|
+
return l(e);
|
|
85
93
|
} finally {
|
|
86
|
-
|
|
94
|
+
d.delete(r);
|
|
87
95
|
}
|
|
88
96
|
})();
|
|
89
|
-
return
|
|
97
|
+
return d.set(r, a), a;
|
|
90
98
|
}
|
|
91
99
|
async function r() {
|
|
92
|
-
let
|
|
93
|
-
|
|
94
|
-
let n = { ...
|
|
95
|
-
for (let
|
|
100
|
+
let t = await Promise.all(c.map(n));
|
|
101
|
+
e || y((e) => {
|
|
102
|
+
let n = { ...e };
|
|
103
|
+
for (let e of t) n[e.actorId] = e;
|
|
96
104
|
return n;
|
|
97
105
|
});
|
|
98
106
|
}
|
|
99
107
|
return r(), () => {
|
|
100
|
-
|
|
108
|
+
e = !0;
|
|
101
109
|
};
|
|
102
110
|
}, [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
]),
|
|
111
|
+
b,
|
|
112
|
+
p,
|
|
113
|
+
_,
|
|
114
|
+
g
|
|
115
|
+
]), v;
|
|
108
116
|
}
|
|
109
117
|
//#endregion
|
|
110
|
-
export {
|
|
118
|
+
export { l as buildActorFallback, g as useActorProfiles };
|