@sentry/junior 0.267.0 → 0.269.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/README.md +2 -9
- package/dist/{actor-DZSokpwj.js → actor-CP9K2Idu.js} +2 -1
- package/dist/{adapter-BybMEezj.js → adapter-2-CG25be.js} +3 -51
- package/dist/{admin-DOs1_EiW.js → admin-DSs8S5Uy.js} +1 -1
- package/dist/{agent-invocations-CxKldAeB.js → agent-invocations-C1RNOCs8.js} +2 -0
- package/dist/{agent-runner-DgNATN4D.js → agent-runner-CrDrPUtY.js} +3411 -1640
- package/dist/api/schema.d.ts +2 -5630
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +3 -1
- package/dist/api.js +268 -287
- package/dist/{app-DAB3fzyp.d.ts → app-BrMMzjYm.d.ts} +10 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +371 -223
- package/dist/{automation-CmeFBSEh.js → automation-p87hg_AV.js} +74 -74
- package/dist/{briefs-CWKjka7v.js → briefs-PtODdLNu.js} +4 -4
- package/dist/{catalog-runtime-cMlAI5LY.js → catalog-runtime-BsoSmTM0.js} +1 -1
- package/dist/cli/chat.js +16 -26
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +5 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-BjgbMawj.js → client-Cqf4TboL.js} +20 -15
- package/dist/{config-CdB6yJj5.js → config-CPsE4T5L.js} +2 -2
- package/dist/{connections-RE_65jzK.js → connections-upFXLmhG.js} +10 -11
- package/dist/{conversation-DSo310Ps.js → conversation-CTpD_PGk.js} +7 -84
- package/dist/{conversation-privacy-BzgJC5k0.js → conversation-privacy-D6zJc8ff.js} +1 -1
- package/dist/{credential-sync-DhEGEpgq.js → credential-sync-CS_6IC-f.js} +30 -34
- package/dist/{credentialed-CIGwoLU2.js → credentialed-BU-OW7HP.js} +577 -74
- package/dist/{store-B8CABbmR.d.ts → db-BzOCzVb1.d.ts} +17 -7
- package/dist/{executor-VYrx_K4w.js → executor-CNS7ONt-.js} +78 -4
- package/dist/instrumentation.js +2 -2
- package/dist/{assistant-reply-CT7VcXQe.js → interruption-marker-g6Xup3Fk.js} +8 -2
- package/dist/{job-queue-C0BZSa7r.js → job-queue-DI-k-Bbk.js} +2 -2
- package/dist/{list-1XQP-o6K.js → list-CGoQdXTp.js} +429 -1401
- package/dist/locks-D-0h111u.js +48 -0
- package/dist/{logging-DuZ1A4ab.js → logging-n7knse-O.js} +1 -1
- package/dist/{history-C84mlAwO.js → media-85PDJxO_.js} +83 -1
- package/dist/{message-NKSbbnA6.js → message-BpaWd8TT.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-qAHLPtml.js → oauth-callback-server-CpGmEw_i.js} +2 -2
- package/dist/{prompt-BW9jFsqZ.js → prompt-BlQB0QQt.js} +1 -1
- package/dist/{registry-FQutO926.js → registry-By36_xsm.js} +2 -2
- package/dist/reporting-schema-CZREhYc-.js +104 -0
- package/dist/reporting-window-CVarfId9.js +255 -0
- package/dist/{resolve-Bk4yeuHy.js → resolve-CUIBcdPd.js} +3 -3
- package/dist/{result-B9e9ATOU.js → result-BemsOMOO.js} +31 -12
- package/dist/{runner-C3S2ObH-.js → runner-BVok7PAA.js} +12 -11
- package/dist/{sandbox-egress-signals-DqpGzzMB.js → sandbox-egress-signals-BSUWQI95.js} +1 -1
- package/dist/{schema-X7Fj4fv1.js → schema-ChnFo5f2.js} +98 -6
- package/dist/schema-jK4-1u_H.d.ts +5927 -0
- package/dist/{service-account-Do30HUNv.js → service-account-DHvlLnZw.js} +4 -3
- package/dist/{service-account-BQasl-qq.js → service-account-hMmESDcr.js} +3 -3
- package/dist/{session-stop-DkOjt46_.js → session-stop-BQW_iFcd.js} +499 -23
- package/dist/{skills-CQHrwfOa.js → skills-DmJJIuLF.js} +2 -2
- package/dist/{spawn-BHuqN14f.js → spawn-ChCm46i-.js} +2 -2
- package/dist/{store-6EetVP-m.js → store-1DVhoKOL.js} +4 -4
- package/dist/{store-DvNZIsCr.js → store-DCo2n5iJ.js} +3 -3
- package/dist/{task-queue-B0DLgd2P.js → task-queue-HMC4QjFm.js} +3 -3
- package/dist/task-runner-cA6yjn_E.js +269 -0
- package/dist/{thread-state-DRmdJ2QN.js → thread-state-CHy8LS0C.js} +8 -18
- package/dist/{turn-failure-response-G11cs2gE.js → turn-failure-response-Dr7erLWs.js} +11 -16
- package/dist/{turn-lifecycle-OzLIwvi1.js → turn-lifecycle-bf2fIYi_.js} +1 -1
- package/dist/{tasks-0ilmuCux.js → turn-session-routing-BqO0qXLk.js} +959 -44
- package/dist/{validation-CxEmt1id.js → validation-DHR1ivfh.js} +1 -1
- package/dist/{version-Bapedn4A.js → version-CXCHLgWm.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DrN3oC2X.js → viewer-DSbD6DF6.js} +503 -241
- package/dist/{work-DUQoNcqP.js → work-BE_qTYGi.js} +17 -36
- package/dist/{worker-D1l4Ugk0.js → worker-Cm9_sWXg.js} +15 -7
- package/migrations/0065_user_customization.sql +1 -0
- package/migrations/0066_review_items.sql +53 -0
- package/migrations/0067_review_item_dedupe_tenant.sql +2 -0
- package/migrations/0068_review_item_slack_cards.sql +10 -0
- package/migrations/0069_system_identity.sql +25 -0
- package/migrations/0070_review_item_foreign_keys.sql +5 -0
- package/migrations/AGENTS.md +17 -0
- package/migrations/meta/0065_snapshot.json +3511 -0
- package/migrations/meta/0066_snapshot.json +4099 -0
- package/migrations/meta/0067_snapshot.json +3921 -0
- package/migrations/meta/0068_snapshot.json +4176 -0
- package/migrations/meta/0069_snapshot.json +3979 -0
- package/migrations/meta/0070_snapshot.json +3997 -0
- package/migrations/meta/_journal.json +42 -0
- package/package.json +5 -5
- package/dist/db-Bg-zC3r5.d.ts +0 -5
- package/dist/history-BgI33Kie.d.ts +0 -78
- package/dist/images-CecjXAAz.js +0 -64
- package/dist/task-runner-B-PD_JOj.js +0 -1074
- package/dist/turn-session-routing-Dyut9l7Y.js +0 -76
- package/dist/user-input-request-BDFBdF8r.js +0 -116
- package/dist/web-message-id-CJSUiksE.js +0 -236
- package/migrations/README.md +0 -30
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-DRmdJ2QN.js";
|
|
1
|
+
import { Dn as failTurnRecord, Nt as openConversationProjection, On as getTurnRecord, Tn as abandonTurnRecord, dn as PluginCredentialFailureError, hn as AuthorizationFlowDisabledError, mr as isTurnExecutionLimitExceededError, vr as getTerminalAssistantMessages, wn as saveTurnCheckpoint } from "./turn-session-routing-BqO0qXLk.js";
|
|
2
|
+
import { n as botConfig } from "./config-CPsE4T5L.js";
|
|
3
|
+
import { j as SYSTEM_IDENTITY_ID, x as getConversationStore, y as getConversationEventStore } from "./viewer-DSbD6DF6.js";
|
|
4
|
+
import { _ as sameActorIdentity, p as agentInstructionProvenance } from "./media-85PDJxO_.js";
|
|
5
|
+
import { Et as withoutSavedSteeringMessages, Mt as readBlockedReport, Tt as buildSteeringPiMessage, _t as recordSubagentEnded, ht as stopChildAgentsOf, vt as recordSubagentStarted } from "./agent-runner-CrDrPUtY.js";
|
|
6
|
+
import { E as markAgentInvocationSteered, H as TurnInputCommitLostError, K as isTurnInputCommitLostError, L as agentTypeInstructions, O as reportReplacedAgentInvocation, R as agentTypeStartsWithParentHistory, S as markAgentInvocationMailboxAppended, T as markAgentInvocationRunning, W as getConversationTurnBoundaryError, _ as getLatestAgentInvocationForConversation, c as getAgentInvocation, f as getAgentInvocationMessageId, m as getAgentInvocationTurnId, n as completeAgentInvocation, r as createAgentInvocation, s as getActiveAgentInvocationForConversation, w as markAgentInvocationPaused, y as isTerminalAgentInvocation } from "./store-1DVhoKOL.js";
|
|
7
|
+
import { r as getAssistantReplyText } from "./interruption-marker-g6Xup3Fk.js";
|
|
8
|
+
import { C as maybePostAutomatedTurnLimitNotice, D as recordFinishedTurnForAutomatedLimit, O as resetAutomatedTurnLimit } from "./session-stop-BQW_iFcd.js";
|
|
9
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DCo2n5iJ.js";
|
|
10
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-bf2fIYi_.js";
|
|
11
|
+
import { a as persistThreadStateById, n as getPersistedSandboxState, r as getPersistedThreadState } from "./thread-state-CHy8LS0C.js";
|
|
13
12
|
import { isDeepStrictEqual } from "node:util";
|
|
14
13
|
import { z } from "zod";
|
|
15
14
|
// src/chat/runtime/turn-execution.ts
|
|
@@ -86,16 +85,6 @@ async function loadForkHistory(invocation) {
|
|
|
86
85
|
return forkHistoryFrom((await openConversationProjection({ conversationId: invocation.parentConversationId })).messages, invocation.parentToolCallId);
|
|
87
86
|
}
|
|
88
87
|
// src/chat/agent-invocations/work.ts
|
|
89
|
-
var work_exports = /* @__PURE__ */ __exportAll({
|
|
90
|
-
agentInvocationInputText: () => agentInvocationInputText,
|
|
91
|
-
agentInvocationRunPolicy: () => agentInvocationRunPolicy,
|
|
92
|
-
buildAgentInvocationInboundMessage: () => buildAgentInvocationInboundMessage,
|
|
93
|
-
createAgentInvocationWorker: () => createAgentInvocationWorker,
|
|
94
|
-
createAndEnqueueAgentInvocation: () => createAndEnqueueAgentInvocation,
|
|
95
|
-
enqueueAgentInvocation: () => enqueueAgentInvocation,
|
|
96
|
-
resolveAgentInvocationId: () => resolveAgentInvocationId,
|
|
97
|
-
routeAgentInvocationWork: () => routeAgentInvocationWork
|
|
98
|
-
});
|
|
99
88
|
const agentInvocationMailboxMetadataSchema = z.object({
|
|
100
89
|
agentInvocationId: z.string().min(1),
|
|
101
90
|
kind: z.literal("agent_invocation")
|
|
@@ -121,6 +110,7 @@ function buildAgentInvocationInboundMessage(invocation, nowMs = Date.now()) {
|
|
|
121
110
|
inboundMessageId: getAgentInvocationMessageId(invocation.invocationId),
|
|
122
111
|
input: {
|
|
123
112
|
authorId: invocation.invocationId,
|
|
113
|
+
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
124
114
|
text: "[agent invocation]",
|
|
125
115
|
metadata: {
|
|
126
116
|
agentInvocationId: invocation.invocationId,
|
|
@@ -188,8 +178,7 @@ async function resolveAgentInvocationId(context) {
|
|
|
188
178
|
if (context.attempt.messages.length > 0) return;
|
|
189
179
|
const active = await getActiveAgentInvocationForConversation(context.conversationId);
|
|
190
180
|
if (active) return active.invocationId;
|
|
191
|
-
|
|
192
|
-
return latest?.status === "stopped" ? latest.invocationId : void 0;
|
|
181
|
+
return (await getLatestAgentInvocationForConversation(context.conversationId))?.invocationId;
|
|
193
182
|
}
|
|
194
183
|
/**
|
|
195
184
|
* Give queued parent messages to the running agent invocation of a child as
|
|
@@ -267,9 +256,9 @@ function agentInvocationTurnEnd(terminal) {
|
|
|
267
256
|
/** Project the terminal invocation into the idempotent turn lifecycle. */
|
|
268
257
|
async function persistTerminalLifecycle(terminal) {
|
|
269
258
|
const turnId = getAgentInvocationTurnId(terminal.invocationId);
|
|
270
|
-
if (terminal.status
|
|
259
|
+
if (terminal.status !== "completed") await abandonTurnRecord({
|
|
271
260
|
conversationId: terminal.childConversationId,
|
|
272
|
-
errorMessage: "Turn cancelled",
|
|
261
|
+
errorMessage: terminal.status === "stopped" ? "Turn cancelled" : terminal.errorMessage,
|
|
273
262
|
turnId
|
|
274
263
|
});
|
|
275
264
|
await finishTurn(terminal.childConversationId, turnId, agentInvocationTurnEnd(terminal));
|
|
@@ -506,8 +495,7 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
506
495
|
turnId
|
|
507
496
|
}));
|
|
508
497
|
} catch (error) {
|
|
509
|
-
|
|
510
|
-
const runError = error.cause;
|
|
498
|
+
const runError = error instanceof AgentRunError ? error.cause : error;
|
|
511
499
|
if (isInvocationInputCommitLost(runError)) return { status: "lost_lease" };
|
|
512
500
|
if (stopSignal?.aborted) return await finishStopped();
|
|
513
501
|
const blocking = blockingInvocationError(runError);
|
|
@@ -553,11 +541,4 @@ function createAgentInvocationWorker(agentRunner, options = {}) {
|
|
|
553
541
|
return { status: "completed" };
|
|
554
542
|
};
|
|
555
543
|
}
|
|
556
|
-
|
|
557
|
-
function routeAgentInvocationWork(options) {
|
|
558
|
-
return async (context) => {
|
|
559
|
-
const invocationId = await resolveAgentInvocationId(context);
|
|
560
|
-
return invocationId ? await options.invocationWorker(context, invocationId) : await options.fallbackWorker(context);
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
export { work_exports as a, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, AgentRunError as o, enqueueAgentInvocation as r, executeTurn as s, createAgentInvocationWorker as t };
|
|
544
|
+
export { AgentRunError as a, resolveAgentInvocationId as i, createAndEnqueueAgentInvocation as n, executeTurn as o, enqueueAgentInvocation as r, createAgentInvocationWorker as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import {
|
|
3
|
-
import { y as isProviderRetryError } from "./client-
|
|
4
|
-
import { i as getChatConfig } from "./config-
|
|
5
|
-
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-
|
|
6
|
-
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-
|
|
7
|
-
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-
|
|
2
|
+
import { Xn as isInvalidConversationRecordError, Yn as isFinalAttempt, qn as hasConversationStop } from "./turn-session-routing-BqO0qXLk.js";
|
|
3
|
+
import { y as isProviderRetryError } from "./client-Cqf4TboL.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-CPsE4T5L.js";
|
|
5
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-n7knse-O.js";
|
|
6
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-DI-k-Bbk.js";
|
|
7
|
+
import { C as requestAnotherSlice, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-DCo2n5iJ.js";
|
|
8
8
|
// src/chat/task-execution/attempt-selection.ts
|
|
9
9
|
function selectContiguousTurnBatch(messages) {
|
|
10
10
|
const first = messages[0];
|
|
@@ -116,6 +116,14 @@ async function recordFailedDeliveryAttempt(args) {
|
|
|
116
116
|
function isTerminalFailure(failure) {
|
|
117
117
|
return failure.status === "recorded" && failure.deadLetteredMessages.length > 0 && failure.pendingCount === 0;
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Return whether a failure of this attempt can end the conversation work. The
|
|
121
|
+
* retry limit applies to every attempt, also one with no messages, such as a
|
|
122
|
+
* resume. A message also ends it at its own delivery limit.
|
|
123
|
+
*/
|
|
124
|
+
function isLastConversationAttempt(work, messages) {
|
|
125
|
+
return (work.execution.retryCount ?? 0) + 1 >= 5 || messages.some((message) => isFinalAttempt(message));
|
|
126
|
+
}
|
|
119
127
|
function logRetryExhausted(args) {
|
|
120
128
|
logException(args.error, "conversation.work.retry.exhausted", {
|
|
121
129
|
"app.run.id": args.work.execution.runId ?? "unknown",
|
|
@@ -403,7 +411,7 @@ async function processConversationWorkInContext(message, options) {
|
|
|
403
411
|
conversationId,
|
|
404
412
|
destination,
|
|
405
413
|
drain,
|
|
406
|
-
isFinalAttempt:
|
|
414
|
+
isFinalAttempt: isLastConversationAttempt(leasedWork, attemptMessages),
|
|
407
415
|
messages: attemptMessages
|
|
408
416
|
},
|
|
409
417
|
conversationId,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_users" ADD COLUMN "customization" text;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
CREATE TABLE "junior_review_item_assignees" (
|
|
2
|
+
"item_id" text NOT NULL,
|
|
3
|
+
"user_id" text NOT NULL,
|
|
4
|
+
CONSTRAINT "junior_review_item_assignees_item_id_user_id_pk" PRIMARY KEY("item_id","user_id")
|
|
5
|
+
);
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
CREATE TABLE "junior_review_item_conversations" (
|
|
8
|
+
"item_id" text NOT NULL,
|
|
9
|
+
"conversation_id" text NOT NULL,
|
|
10
|
+
CONSTRAINT "junior_review_item_conversations_item_id_conversation_id_pk" PRIMARY KEY("item_id","conversation_id")
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE TABLE "junior_review_items" (
|
|
14
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
15
|
+
"kind" text NOT NULL,
|
|
16
|
+
"status" text NOT NULL,
|
|
17
|
+
"visibility" text NOT NULL,
|
|
18
|
+
"title" text NOT NULL,
|
|
19
|
+
"body" text NOT NULL,
|
|
20
|
+
"request" jsonb,
|
|
21
|
+
"answer" jsonb,
|
|
22
|
+
"assigned_to_everyone" boolean DEFAULT false NOT NULL,
|
|
23
|
+
"dedupe_key" text NOT NULL,
|
|
24
|
+
"subject_id" text,
|
|
25
|
+
"subject_title" text,
|
|
26
|
+
"subject_url" text,
|
|
27
|
+
"added_by_conversation_id" text NOT NULL,
|
|
28
|
+
"provider" text,
|
|
29
|
+
"provider_tenant_id" text,
|
|
30
|
+
"automation_id" text,
|
|
31
|
+
"closed_at" timestamp with time zone,
|
|
32
|
+
"closed_by_user_id" text,
|
|
33
|
+
"close_reason" text,
|
|
34
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
35
|
+
"updated_at" timestamp with time zone NOT NULL,
|
|
36
|
+
CONSTRAINT "junior_review_items_kind_check" CHECK (("junior_review_items"."kind" = 'notice' and "junior_review_items"."request" is null and "junior_review_items"."answer" is null) or ("junior_review_items"."kind" = 'action' and "junior_review_items"."request" is not null)),
|
|
37
|
+
CONSTRAINT "junior_review_items_status_check" CHECK (("junior_review_items"."status" = 'open' and "junior_review_items"."closed_at" is null) or ("junior_review_items"."status" in ('done', 'dismissed') and "junior_review_items"."closed_at" is not null)),
|
|
38
|
+
CONSTRAINT "junior_review_items_tenant_check" CHECK (("junior_review_items"."provider" is null) = ("junior_review_items"."provider_tenant_id" is null)),
|
|
39
|
+
CONSTRAINT "junior_review_items_visibility_check" CHECK ("junior_review_items"."visibility" = 'public' or not "junior_review_items"."assigned_to_everyone")
|
|
40
|
+
);
|
|
41
|
+
--> statement-breakpoint
|
|
42
|
+
ALTER TABLE "junior_review_item_assignees" ADD CONSTRAINT "junior_review_item_assignees_item_id_junior_review_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."junior_review_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
43
|
+
ALTER TABLE "junior_review_item_assignees" ADD CONSTRAINT "junior_review_item_assignees_user_id_junior_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."junior_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
44
|
+
ALTER TABLE "junior_review_item_conversations" ADD CONSTRAINT "junior_review_item_conversations_item_id_junior_review_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."junior_review_items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
45
|
+
ALTER TABLE "junior_review_item_conversations" ADD CONSTRAINT "junior_review_item_conversations_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
46
|
+
ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_automation_id_junior_automations_id_fk" FOREIGN KEY ("automation_id") REFERENCES "public"."junior_automations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
47
|
+
ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_closed_by_user_id_junior_users_id_fk" FOREIGN KEY ("closed_by_user_id") REFERENCES "public"."junior_users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
48
|
+
CREATE INDEX "junior_review_item_assignees_user_idx" ON "junior_review_item_assignees" USING btree ("user_id");--> statement-breakpoint
|
|
49
|
+
CREATE INDEX "junior_review_item_conversations_conversation_idx" ON "junior_review_item_conversations" USING btree ("conversation_id");--> statement-breakpoint
|
|
50
|
+
CREATE UNIQUE INDEX "junior_review_items_open_dedupe_uidx" ON "junior_review_items" USING btree ("dedupe_key") WHERE "junior_review_items"."status" = 'open';--> statement-breakpoint
|
|
51
|
+
CREATE INDEX "junior_review_items_status_idx" ON "junior_review_items" USING btree ("status","updated_at","id");--> statement-breakpoint
|
|
52
|
+
CREATE INDEX "junior_review_items_subject_idx" ON "junior_review_items" USING btree ("subject_id","status");--> statement-breakpoint
|
|
53
|
+
CREATE INDEX "junior_review_items_automation_idx" ON "junior_review_items" USING btree ("automation_id","status");
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
DROP INDEX "junior_review_items_open_dedupe_uidx";--> statement-breakpoint
|
|
2
|
+
CREATE UNIQUE INDEX "junior_review_items_open_dedupe_uidx" ON "junior_review_items" USING btree (coalesce("provider", ''),coalesce("provider_tenant_id", ''),"dedupe_key") WHERE "junior_review_items"."status" = 'open';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
CREATE TABLE "junior_review_item_slack_cards" (
|
|
2
|
+
"item_id" text NOT NULL,
|
|
3
|
+
"conversation_id" text NOT NULL,
|
|
4
|
+
"team_id" text NOT NULL,
|
|
5
|
+
"channel_id" text NOT NULL,
|
|
6
|
+
"message_ts" text NOT NULL,
|
|
7
|
+
CONSTRAINT "junior_review_item_slack_cards_item_id_conversation_id_pk" PRIMARY KEY("item_id","conversation_id")
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
ALTER TABLE "junior_review_item_slack_cards" ADD CONSTRAINT "junior_review_item_slack_cards_item_id_junior_review_items_id_fk" FOREIGN KEY ("item_id") REFERENCES "public"."junior_review_items"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Create the one system Identity with the fixed id `system`. Code writes this
|
|
2
|
+
-- id without a read, and Message and Conversation rows reference it through
|
|
3
|
+
-- foreign keys, so the row must exist. ON CONFLICT DO NOTHING makes a second
|
|
4
|
+
-- run do nothing.
|
|
5
|
+
INSERT INTO "junior_identities" (
|
|
6
|
+
"id",
|
|
7
|
+
"kind",
|
|
8
|
+
"provider",
|
|
9
|
+
"provider_tenant_id",
|
|
10
|
+
"provider_subject_id",
|
|
11
|
+
"display_name",
|
|
12
|
+
"created_at",
|
|
13
|
+
"updated_at"
|
|
14
|
+
)
|
|
15
|
+
VALUES (
|
|
16
|
+
'system',
|
|
17
|
+
'system',
|
|
18
|
+
'junior',
|
|
19
|
+
'',
|
|
20
|
+
'system',
|
|
21
|
+
'System',
|
|
22
|
+
CURRENT_TIMESTAMP,
|
|
23
|
+
CURRENT_TIMESTAMP
|
|
24
|
+
)
|
|
25
|
+
ON CONFLICT DO NOTHING;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "junior_review_items" DROP CONSTRAINT "junior_review_items_closed_by_user_id_junior_users_id_fk";
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "junior_review_item_slack_cards" ADD CONSTRAINT "junior_review_item_slack_cards_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_added_by_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("added_by_conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_closed_by_user_id_junior_users_id_fk" FOREIGN KEY ("closed_by_user_id") REFERENCES "public"."junior_users"("id") ON DELETE set null ON UPDATE no action;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SQL Migrations
|
|
2
|
+
|
|
3
|
+
`src/db/schema.ts` is the Drizzle schema entry point. This directory is the
|
|
4
|
+
append-only history that brings an existing database to that schema.
|
|
5
|
+
`src/chat/conversations/sql/migrations.ts` owns loading, locking, and the
|
|
6
|
+
bridge-version guard.
|
|
7
|
+
|
|
8
|
+
## Rules
|
|
9
|
+
|
|
10
|
+
- Never edit, rename, reorder, or delete an applied migration or its
|
|
11
|
+
metadata. Add a new migration to correct it.
|
|
12
|
+
- Change the table under `src/db/schema/`, then run
|
|
13
|
+
`pnpm --filter @sentry/junior db:generate --name <name>`. Commit the SQL,
|
|
14
|
+
`meta/_journal.json`, and the snapshot together.
|
|
15
|
+
- Put fixed row transformations in the migration that needs them.
|
|
16
|
+
- A schema without the core Drizzle journal must first upgrade through
|
|
17
|
+
`@sentry/junior@0.107.1`. Do not remove that guard.
|