@sentry/junior 0.298.0 → 0.300.0
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/dist/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
- package/dist/{state-CSuA2J1V.js → adapter-S5UkjNK3.js} +53 -136
- package/dist/{admin-BF3DbYGf.js → admin-UrTniSPO.js} +2 -2
- package/dist/{agent-runner-Q9GkoerG.js → agent-runner-bY4_0UPm.js} +1444 -1478
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +382 -68
- package/dist/{app-DOg_mCtV.d.ts → app-D-AcIcCV.d.ts} +17 -4
- package/dist/app.d.ts +1 -1
- package/dist/app.js +148 -483
- package/dist/{automation-Cn8qmbdr.js → automation-Dw82oQ-h.js} +2 -2
- package/dist/{background-compaction-queue-BZhGFOK6.js → background-compaction-queue-B6U3060-.js} +9 -5
- package/dist/{briefs-CQrCRF6-.js → briefs-DqiwWu-n.js} +4 -4
- package/dist/{catalog-runtime-DZeD2WbL.js → catalog-runtime-D1oYNv04.js} +1 -1
- package/dist/cli/chat.js +17 -17
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-BOByVnxe.js → config-9nHoFiJP.js} +117 -12
- package/dist/{connections-BNN5cJam.js → connections-DZjTN3JC.js} +6 -6
- package/dist/continue-in-slack-Dtv7_U42.js +176 -0
- package/dist/{conversation-DCkzvxqB.js → conversation-Dyjq2CZ8.js} +36 -13
- package/dist/{conversation-feed-CMA12Rjs.js → conversation-feed-CcDxlrlQ.js} +109 -3
- package/dist/{conversation-privacy-C0eRxsgb.js → conversation-privacy-D-5HTXjS.js} +1 -1
- package/dist/{conversation-turn-D9qvcDX6.js → conversation-turn-Cxl8WZD7.js} +85 -68
- package/dist/{credential-sync-B_iUpxGL.js → credential-sync-C49ClwDX.js} +18 -18
- package/dist/{db-DoMcnYol.d.ts → db-2resqBh1.d.ts} +1 -1
- package/dist/{db-CoMNr2Zm.js → db-BJNo6fK5.js} +176 -12
- package/dist/{executor-C-m8VrzX.js → executor-DBIaOeJ_.js} +47 -13
- package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
- package/dist/instrumentation.js +14 -5
- package/dist/lineage-0dereG7H.js +37 -0
- package/dist/{logging-CJTi5niy.js → logging-BIclibct.js} +1 -1
- package/dist/{message-Q6_5DAWR.js → message-dkOl-Iii.js} +9 -10
- package/dist/model-input-CLo9TaUd.js +82 -0
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +17 -9
- package/dist/{oauth-callback-server-CH5XAyo-.js → oauth-callback-server-WmpjfJgQ.js} +2 -2
- package/dist/{plugins-HYh_JOdw.js → plugins-BBX07Jzt.js} +1 -1
- package/dist/{projection-BgwEE36_.js → projection-w_X-zi7v.js} +1035 -692
- package/dist/{prompt-DXc9DYT9.js → prompt-B1Xw46-S.js} +4 -4
- package/dist/{registry-9XwqSnM-.js → registry-BmP5vnlj.js} +4 -4
- package/dist/{resolve-DUIAbcRL.js → resolve-goo34bJK.js} +3 -3
- package/dist/{result-C2Vn8QGn.js → result-PVBeU0Wf.js} +158 -69
- package/dist/{runner-CXGtw-Mc.js → runner-DKrfvNV6.js} +9 -9
- package/dist/{sandbox-egress-signals-Di3S_dO7.js → sandbox-egress-signals-DsUcqrI0.js} +1 -1
- package/dist/{schema-Dyp7racy.js → schema-C9iNFz5n.js} +51 -7
- package/dist/{schema-BnbZ-rKv.d.ts → schema-Dns-sTas.d.ts} +1285 -761
- package/dist/{service-account-DM3KBBeG.js → service-account-CMAAloAL.js} +3 -3
- package/dist/{service-account-GzAMUQ8a.js → service-account-CmowamcB.js} +4 -4
- package/dist/session-stop-BcAXze8a.js +3330 -0
- package/dist/{skills-DCK9SD_l.js → skills-DfsazET6.js} +3 -3
- package/dist/slack-conversation-unfurl-CzQonuWz.js +370 -0
- package/dist/spawn-C7o0FDDp.js +73 -0
- package/dist/state-zSilNpbi.js +132 -0
- package/dist/{user-input-request-CXNIov9n.js → statuses-Hn-HsOph.js} +115 -26
- package/dist/{stop-Dh2DfwpK.js → stop-CFOujp8C.js} +9105 -6007
- package/dist/{store-DrA17Fbz.js → store-Dkeis_8o.js} +10 -10
- package/dist/{store-B1zepKG8.js → store-E3x2Fg_F.js} +24 -4
- package/dist/{task-queue-D1rXWfFN.js → task-queue-D-hCqdZW.js} +4 -4
- package/dist/{task-runner-CT4M8oDz.js → task-runner-vohUPLHe.js} +10 -10
- package/dist/{thread-context-DnqUkbzN.js → thread-context-BzvdkgI9.js} +18 -18
- package/dist/{turn-session-routing-VXDVXLRl.js → turn-session-routing-Bo_LxFum.js} +5 -5
- package/dist/turn-user-message-D5RnVmxQ.js +355 -0
- package/dist/users-2bggndVg.js +424 -0
- package/dist/{validation-zxAJBDDy.js → validation-BbWikeSa.js} +1 -1
- package/dist/{version-DcZ40a0g.js → version-GVBMW2jA.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CgiGjW10.js → viewer-BpxRliyO.js} +36 -163
- package/dist/{warmup-CwKbxQLl.js → warmup-BW2qwnal.js} +1140 -145
- package/dist/{worker-CbDUzaBA.js → worker-Cbd-iuwZ.js} +25 -20
- package/migrations/0104_code_change_draft.sql +1 -0
- package/migrations/0105_attachment_uploads.sql +14 -0
- package/migrations/0106_conversation_agent_config.sql +1 -0
- package/migrations/0107_attachment_deferred_download.sql +2 -0
- package/migrations/meta/0104_snapshot.json +4516 -0
- package/migrations/meta/0105_snapshot.json +4611 -0
- package/migrations/meta/0106_snapshot.json +4617 -0
- package/migrations/meta/0107_snapshot.json +4617 -0
- package/migrations/meta/_journal.json +28 -0
- package/package.json +10 -8
- package/dist/attempt-selection-ClP3MMPr.js +0 -61
- package/dist/locks-D-0h111u.js +0 -48
- package/dist/notification-Bv25xbj0.js +0 -1284
- package/dist/prompt-input-BUr4J9RO.js +0 -1424
- package/dist/session-stop-D4i7e6iT.js +0 -181
- package/dist/spawn-6cX6xE9G.js +0 -80
- package/dist/turn-cancel-l460pfGW.js +0 -201
- package/dist/turn-user-message-BSPmkm7X.js +0 -608
- package/dist/turn-wake-DVFVXyhX.js +0 -161
- package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
|
@@ -1,61 +1,21 @@
|
|
|
1
|
-
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail
|
|
2
|
-
import {
|
|
3
|
-
import { M as
|
|
4
|
-
import { r as detectImageMediaType } from "./media-BepyEUNm.js";
|
|
5
|
-
import { a as withLock } from "./locks-D-0h111u.js";
|
|
1
|
+
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail } from "./logging-BIclibct.js";
|
|
2
|
+
import { H as clearCachedUser, M as findActorIdentityId, U as readCachedUserByEmail, o as getDb } from "./db-BJNo6fK5.js";
|
|
3
|
+
import { M as juniorIdentities, N as juniorUsers } from "./executor-DBIaOeJ_.js";
|
|
6
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
5
|
import { and, asc, eq, inArray, isNotNull } from "drizzle-orm";
|
|
8
6
|
import { identitySchema, userSchema } from "@sentry/junior-plugin-api";
|
|
9
|
-
// src/chat/state/cache.ts
|
|
10
|
-
const MAX_CACHE_KEY_LENGTH = 512;
|
|
11
|
-
const LOAD_WAIT_MS = 1e4;
|
|
12
|
-
/**
|
|
13
|
-
* Create a cache in the state adapter under `junior:cache:{namespace}:`.
|
|
14
|
-
* Entries are wrapped, so `null` and `false` values are cache hits.
|
|
15
|
-
*/
|
|
16
|
-
function createCache(state, namespace) {
|
|
17
|
-
return { async getOrLoad(key, load, options) {
|
|
18
|
-
if (!key.trim()) throw new Error("Cache key is required");
|
|
19
|
-
if (key.length > MAX_CACHE_KEY_LENGTH) throw new Error("Cache key exceeds the maximum length");
|
|
20
|
-
const cacheKey = `junior:cache:${namespace}:${key}`;
|
|
21
|
-
const cached = async () => options?.refresh ? void 0 : await state.get(cacheKey) ?? void 0;
|
|
22
|
-
await state.connect();
|
|
23
|
-
const hit = await cached();
|
|
24
|
-
if (hit) return hit.value;
|
|
25
|
-
const attempt = await withLock(state, `${cacheKey}:load`, async () => {
|
|
26
|
-
const loadedMeanwhile = await cached();
|
|
27
|
-
if (loadedMeanwhile) return loadedMeanwhile.value;
|
|
28
|
-
const entry = await load();
|
|
29
|
-
if (entry.ttlMs !== void 0) {
|
|
30
|
-
if (!(entry.ttlMs > 0)) throw new Error("Cache ttlMs must be positive");
|
|
31
|
-
await state.set(cacheKey, { value: entry.value }, entry.ttlMs);
|
|
32
|
-
}
|
|
33
|
-
return entry.value;
|
|
34
|
-
}, {
|
|
35
|
-
keepAlive: true,
|
|
36
|
-
waitMs: LOAD_WAIT_MS
|
|
37
|
-
});
|
|
38
|
-
if (attempt.acquired) return attempt.value;
|
|
39
|
-
return (await load()).value;
|
|
40
|
-
} };
|
|
41
|
-
}
|
|
42
7
|
// src/chat/identities/avatar.ts
|
|
43
8
|
/**
|
|
44
9
|
* Profile photos of people, saved on their native Slack and Google
|
|
45
|
-
* identities.
|
|
46
|
-
* load a photo from Slack or
|
|
10
|
+
* identities. `/api/people/avatars/:identityId` serves each photo through
|
|
11
|
+
* the shared image route code, so browsers never load a photo from Slack or
|
|
12
|
+
* Google.
|
|
47
13
|
*/
|
|
48
14
|
const AVATAR_HOSTS = {
|
|
49
15
|
slack: ["avatars.slack-edge.com"],
|
|
50
16
|
[GOOGLE_IDENTITY_PROVIDER]: ["googleusercontent.com"]
|
|
51
17
|
};
|
|
52
18
|
const AVATAR_PROVIDERS = Object.keys(AVATAR_HOSTS);
|
|
53
|
-
const AVATAR_CACHE_TTL_MS = 864e5;
|
|
54
|
-
const AVATAR_FAILURE_TTL_MS = 3e5;
|
|
55
|
-
const AVATAR_FETCH_TIMEOUT_MS = 5e3;
|
|
56
|
-
const MAX_AVATAR_BYTES = 1048576;
|
|
57
|
-
const AVATAR_EDGE_PX = 96;
|
|
58
|
-
const MAX_AVATAR_REDIRECTS = 3;
|
|
59
19
|
/**
|
|
60
20
|
* Return the URL when it is HTTPS on a photo host of the provider or a
|
|
61
21
|
* subdomain. Junior fetches only these URLs.
|
|
@@ -68,11 +28,8 @@ function parseAvatarUrl(value, provider) {
|
|
|
68
28
|
const host = url.hostname.toLowerCase();
|
|
69
29
|
return hosts.some((allowed) => host === allowed || host.endsWith(`.${allowed}`)) ? url.href : void 0;
|
|
70
30
|
}
|
|
71
|
-
function avatarUrlHash(url) {
|
|
72
|
-
return createHash("sha256").update(url).digest("hex");
|
|
73
|
-
}
|
|
74
31
|
function avatarVersion(url) {
|
|
75
|
-
return
|
|
32
|
+
return createHash("sha256").update(url).digest("hex").slice(0, 16);
|
|
76
33
|
}
|
|
77
34
|
function avatarPath(identityId, avatarUrl) {
|
|
78
35
|
return `/api/people/avatars/${encodeURIComponent(identityId)}?v=${avatarVersion(avatarUrl)}`;
|
|
@@ -83,17 +40,23 @@ function avatarPath(identityId, avatarUrl) {
|
|
|
83
40
|
*/
|
|
84
41
|
async function readUserAvatarUrls(db, userIds) {
|
|
85
42
|
if (userIds.length === 0) return /* @__PURE__ */ new Map();
|
|
86
|
-
|
|
43
|
+
return userAvatarUrlsFromIdentities(await db.select({
|
|
87
44
|
avatarUrl: juniorIdentities.avatarUrl,
|
|
88
45
|
identityId: juniorIdentities.id,
|
|
89
46
|
provider: juniorIdentities.provider,
|
|
90
47
|
updatedAt: juniorIdentities.updatedAt,
|
|
91
48
|
userId: juniorIdentities.userId
|
|
92
|
-
}).from(juniorIdentities).where(and(inArray(juniorIdentities.userId, [...new Set(userIds)]), eq(juniorIdentities.kind, "user"), inArray(juniorIdentities.provider, AVATAR_PROVIDERS), isNotNull(juniorIdentities.avatarUrl)));
|
|
49
|
+
}).from(juniorIdentities).where(and(inArray(juniorIdentities.userId, [...new Set(userIds)]), eq(juniorIdentities.kind, "user"), inArray(juniorIdentities.provider, AVATAR_PROVIDERS), isNotNull(juniorIdentities.avatarUrl))));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pick the photo path of each user from their user Identities, for a caller
|
|
53
|
+
* that already read them: the Slack photo, then the Google photo.
|
|
54
|
+
*/
|
|
55
|
+
function userAvatarUrlsFromIdentities(rows) {
|
|
93
56
|
const rank = (row) => AVATAR_PROVIDERS.indexOf(row.provider);
|
|
94
|
-
rows.sort((left, right) => rank(left) - rank(right) || right.updatedAt.getTime() - left.updatedAt.getTime());
|
|
57
|
+
const ranked = rows.filter((row) => rank(row) >= 0).sort((left, right) => rank(left) - rank(right) || right.updatedAt.getTime() - left.updatedAt.getTime());
|
|
95
58
|
const avatars = /* @__PURE__ */ new Map();
|
|
96
|
-
for (const row of
|
|
59
|
+
for (const row of ranked) if (row.userId && row.avatarUrl && !avatars.has(row.userId)) avatars.set(row.userId, avatarPath(row.identityId, row.avatarUrl));
|
|
97
60
|
return avatars;
|
|
98
61
|
}
|
|
99
62
|
/**
|
|
@@ -104,110 +67,21 @@ function identityAvatarUrl(row, userAvatarUrls) {
|
|
|
104
67
|
if (row.userId) return userAvatarUrls.get(row.userId);
|
|
105
68
|
return row.avatarUrl ? avatarPath(row.identityId, row.avatarUrl) : void 0;
|
|
106
69
|
}
|
|
107
|
-
async function readBoundedBody(response, maxBytes) {
|
|
108
|
-
if (!response.body) return /* @__PURE__ */ new Uint8Array();
|
|
109
|
-
const reader = response.body.getReader();
|
|
110
|
-
const chunks = [];
|
|
111
|
-
let total = 0;
|
|
112
|
-
while (true) {
|
|
113
|
-
const { done, value } = await reader.read();
|
|
114
|
-
if (done) return Buffer.concat(chunks);
|
|
115
|
-
total += value.byteLength;
|
|
116
|
-
if (total > maxBytes) {
|
|
117
|
-
await reader.cancel();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
chunks.push(value);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
function avatarFetchFailed(host, attributes) {
|
|
124
|
-
logWarn("avatar.fetch.failed", {
|
|
125
|
-
"server.address": host,
|
|
126
|
-
...attributes
|
|
127
|
-
});
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
async function fetchAvatarResponse(url, provider, signal) {
|
|
131
|
-
let current = url;
|
|
132
|
-
for (let redirects = 0;; redirects += 1) {
|
|
133
|
-
const response = await fetch(current, {
|
|
134
|
-
redirect: "manual",
|
|
135
|
-
signal
|
|
136
|
-
});
|
|
137
|
-
const location = response.headers.get("location");
|
|
138
|
-
if (response.status < 300 || response.status >= 400 || !location) return response;
|
|
139
|
-
await response.body?.cancel();
|
|
140
|
-
const next = URL.canParse(location, current) ? parseAvatarUrl(new URL(location, current).href, provider) : void 0;
|
|
141
|
-
if (!next) return "redirect_off_host";
|
|
142
|
-
if (redirects >= MAX_AVATAR_REDIRECTS) return "too_many_redirects";
|
|
143
|
-
current = next;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async function fetchAvatarImage(url, provider) {
|
|
147
|
-
const host = new URL(url).hostname;
|
|
148
|
-
let data;
|
|
149
|
-
try {
|
|
150
|
-
const response = await fetchAvatarResponse(url, provider, AbortSignal.timeout(AVATAR_FETCH_TIMEOUT_MS));
|
|
151
|
-
if (typeof response === "string") return avatarFetchFailed(host, { "app.reason": response });
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
await response.body?.cancel();
|
|
154
|
-
return avatarFetchFailed(host, { "http.response.status_code": response.status });
|
|
155
|
-
}
|
|
156
|
-
data = await readBoundedBody(response, MAX_AVATAR_BYTES);
|
|
157
|
-
} catch (error) {
|
|
158
|
-
return avatarFetchFailed(host, { "exception.message": error instanceof Error ? error.message : String(error) });
|
|
159
|
-
}
|
|
160
|
-
if (!data) return avatarFetchFailed(host, { "app.reason": "too_large" });
|
|
161
|
-
const contentType = detectImageMediaType(data);
|
|
162
|
-
if (!contentType) return avatarFetchFailed(host, { "app.reason": "not_an_image" });
|
|
163
|
-
try {
|
|
164
|
-
return {
|
|
165
|
-
contentType: "image/webp",
|
|
166
|
-
data: await shrinkAvatar(data)
|
|
167
|
-
};
|
|
168
|
-
} catch (error) {
|
|
169
|
-
logWarn("avatar.resize.failed", {
|
|
170
|
-
"server.address": host,
|
|
171
|
-
"exception.message": error instanceof Error ? error.message : String(error)
|
|
172
|
-
});
|
|
173
|
-
return {
|
|
174
|
-
contentType,
|
|
175
|
-
data: Buffer.from(data).toString("base64")
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
async function shrinkAvatar(data) {
|
|
180
|
-
const { default: sharp } = await import("sharp");
|
|
181
|
-
return (await sharp(data).rotate().resize({
|
|
182
|
-
width: AVATAR_EDGE_PX,
|
|
183
|
-
height: AVATAR_EDGE_PX,
|
|
184
|
-
withoutEnlargement: true
|
|
185
|
-
}).webp({ quality: 80 }).toBuffer()).toString("base64");
|
|
186
|
-
}
|
|
187
70
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* not return one.
|
|
71
|
+
* Return how to fetch the photo of one user Identity, or nothing when it has
|
|
72
|
+
* no photo on a photo host of its provider. A redirect cannot leave the
|
|
73
|
+
* photo hosts of the provider.
|
|
192
74
|
*/
|
|
193
|
-
async function
|
|
75
|
+
async function readAvatarFetch(db, identityId) {
|
|
194
76
|
const [row] = await db.select({
|
|
195
77
|
avatarUrl: juniorIdentities.avatarUrl,
|
|
196
78
|
provider: juniorIdentities.provider
|
|
197
79
|
}).from(juniorIdentities).where(and(eq(juniorIdentities.id, identityId), eq(juniorIdentities.kind, "user"))).limit(1);
|
|
198
80
|
const url = row ? parseAvatarUrl(row.avatarUrl, row.provider) : void 0;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
value: loaded,
|
|
205
|
-
ttlMs: loaded ? AVATAR_CACHE_TTL_MS : AVATAR_FAILURE_TTL_MS
|
|
206
|
-
};
|
|
207
|
-
});
|
|
208
|
-
return image ? {
|
|
209
|
-
image,
|
|
210
|
-
version: avatarVersion(row.avatarUrl)
|
|
81
|
+
const hosts = row && AVATAR_HOSTS[row.provider];
|
|
82
|
+
return url && hosts ? {
|
|
83
|
+
hosts,
|
|
84
|
+
url
|
|
211
85
|
} : void 0;
|
|
212
86
|
}
|
|
213
87
|
// src/chat/plugins/viewer.ts
|
|
@@ -234,13 +108,8 @@ function userFromRows(userRow, identityRows) {
|
|
|
234
108
|
});
|
|
235
109
|
}
|
|
236
110
|
async function readUserByNormalizedEmail(db, normalizedEmail) {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
identity: juniorIdentities
|
|
240
|
-
}).from(juniorUsers).leftJoin(juniorIdentities, and(eq(juniorIdentities.userId, juniorUsers.id), eq(juniorIdentities.kind, "user"))).where(eq(juniorUsers.primaryEmailNormalized, normalizedEmail)).orderBy(asc(juniorIdentities.provider), asc(juniorIdentities.providerTenantId), asc(juniorIdentities.providerSubjectId));
|
|
241
|
-
const userRow = rows[0]?.user;
|
|
242
|
-
if (!userRow) return void 0;
|
|
243
|
-
return userFromRows(userRow, rows.flatMap((row) => row.identity ? [row.identity] : []));
|
|
111
|
+
const cached = await readCachedUserByEmail(db, normalizedEmail);
|
|
112
|
+
return cached ? userFromRows(cached.user, cached.identities) : void 0;
|
|
244
113
|
}
|
|
245
114
|
/** Resolve or create the canonical user for one verified viewer email. */
|
|
246
115
|
async function resolveViewerUserFromSql(db, email) {
|
|
@@ -275,10 +144,12 @@ async function findUserByEmail(email) {
|
|
|
275
144
|
}
|
|
276
145
|
/** Update one canonical user's display name in SQL. */
|
|
277
146
|
async function updateViewerDisplayNameFromSql(db, userId, displayName) {
|
|
278
|
-
const
|
|
147
|
+
const rows = await db.update(juniorUsers).set({
|
|
279
148
|
displayName,
|
|
280
149
|
updatedAt: /* @__PURE__ */ new Date()
|
|
281
|
-
}).where(eq(juniorUsers.id, userId)).returning()
|
|
150
|
+
}).where(eq(juniorUsers.id, userId)).returning();
|
|
151
|
+
await clearCachedUser(userId);
|
|
152
|
+
const userRow = rows[0];
|
|
282
153
|
return userRow ? await readUserById(db, userRow) : void 0;
|
|
283
154
|
}
|
|
284
155
|
/** Read the photo path of one canonical user: Slack, then Google. */
|
|
@@ -298,10 +169,12 @@ async function updateViewerDisplayName(userId, displayName) {
|
|
|
298
169
|
async function setUserAdminFromSql(db, email, isAdmin) {
|
|
299
170
|
const user = isAdmin ? await resolveViewerUserFromSql(db, email) : await findUserByEmailFromSql(db, email);
|
|
300
171
|
if (!user) return void 0;
|
|
301
|
-
const
|
|
172
|
+
const rows = await db.update(juniorUsers).set({
|
|
302
173
|
isAdmin,
|
|
303
174
|
updatedAt: /* @__PURE__ */ new Date()
|
|
304
|
-
}).where(eq(juniorUsers.id, user.id)).returning()
|
|
175
|
+
}).where(eq(juniorUsers.id, user.id)).returning();
|
|
176
|
+
await clearCachedUser(user.id);
|
|
177
|
+
const userRow = rows[0];
|
|
305
178
|
return userRow ? await readUserById(db, userRow) : void 0;
|
|
306
179
|
}
|
|
307
180
|
/** List every Junior admin by primary email. */
|
|
@@ -334,4 +207,4 @@ async function readIdentityByIdFromSql(db, identityId) {
|
|
|
334
207
|
async function readIdentityById(identityId) {
|
|
335
208
|
return await readIdentityByIdFromSql(getDb(), identityId);
|
|
336
209
|
}
|
|
337
|
-
export { readActorIdentityFromSql as a, readViewerAvatarUrl as c, updateViewerDisplayName as d, identityAvatarUrl as f,
|
|
210
|
+
export { readActorIdentityFromSql as a, readViewerAvatarUrl as c, updateViewerDisplayName as d, identityAvatarUrl as f, userAvatarUrlsFromIdentities as g, readUserAvatarUrls as h, readActorIdentity as i, resolveViewerUser as l, readAvatarFetch as m, findUserByEmailFromSql as n, readIdentityById as o, parseAvatarUrl as p, listAdminUsersFromSql as r, readIdentityByIdFromSql as s, findUserByEmail as t, setUserAdminFromSql as u };
|