@sentry/junior 0.315.0 → 0.317.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.
Files changed (139) hide show
  1. package/dist/{admin-5jUYY46p.js → admin-CAugg87B.js} +1 -1
  2. package/dist/{agent-runner-C7GNLRB6.js → agent-runner-AjrEV6Qe.js} +13532 -12811
  3. package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
  4. package/dist/{agent-update-delivery-BNEYQsAf.js → agent-update-delivery-B_YIZcgf.js} +10 -37
  5. package/dist/api/schema.d.ts +609 -104
  6. package/dist/api/schema.js +6 -6
  7. package/dist/api.js +373 -469
  8. package/dist/{app-D_bAXRDe.d.ts → app-MoNAsVV5.d.ts} +52 -28
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +177 -132
  11. package/dist/catalog-runtime-DfSpJZdY.js +6 -0
  12. package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
  13. package/dist/{adapter-context-BlSGE44V.js → channel-access-j-YAVYK4.js} +2 -42
  14. package/dist/{chat-core-engine-CxkwRpn9.js → chat-core-engine-aH85nEHv.js} +4 -3
  15. package/dist/{child-message--2G3Ft26.js → child-message-DHjQLEd1.js} +1 -1
  16. package/dist/cli/chat.js +23 -23
  17. package/dist/cli/check.js +5 -5
  18. package/dist/cli/main.js +2 -2
  19. package/dist/cli/plugins.js +5 -4
  20. package/dist/cli/snapshot-create.js +5 -2
  21. package/dist/cli/upgrade.js +27 -5
  22. package/dist/config-CHQ8X251.js +2422 -0
  23. package/dist/{continue-in-slack-BGKjIdFp.js → continue-in-slack-D-FZ8Fin.js} +2 -3
  24. package/dist/{conversation-feed-Sl8lKKmR.js → conversation-feed--9S0_PXL.js} +9 -4
  25. package/dist/{proxy-path-Dc-0jXGi.js → conversation-privacy-B1uXn5sf.js} +2 -16
  26. package/dist/{conversation-turn-BoLK9i6g.js → conversation-turn-BUE_7xaN.js} +102 -172
  27. package/dist/{create-BOycVH9h.js → create-DoDIYgtZ.js} +12 -10
  28. package/dist/{credential-sync-Mn4OdkEh.js → credential-sync-BJOqGnjV.js} +17 -12
  29. package/dist/{db-DXTOYRzR.js → db-BFmyYZtJ.js} +20276 -27398
  30. package/dist/{deployment-CG3TchWh.js → deployment-DXq9ZLU4.js} +17 -15
  31. package/dist/{engine-context-dyWlfNdD.js → engine-context-CgQ7mlHt.js} +264 -50
  32. package/dist/{html-CfXEwl_h.js → html-B3VKTGbJ.js} +6 -2
  33. package/dist/instrumentation.js +15 -7
  34. package/dist/{job-runner-CySgpi9v.js → job-runner-A1lCkybD.js} +397 -22
  35. package/dist/{lineage-tRTOcrsL.js → lineage-Bktb0UcV.js} +1 -1
  36. package/dist/{list-DXBz8SYL.js → list-Bxvg5wXf.js} +260 -698
  37. package/dist/{logging-czs0nqLC.js → logging--smS7XRK.js} +2 -2
  38. package/dist/{mailbox-turn-79Nv1JXv.js → mailbox-turn-uSXhUFc9.js} +648 -2957
  39. package/dist/{message-BTox2Cmb.js → message-BNenhsmB.js} +12 -22
  40. package/dist/{model-input-IRGa98V7.js → model-input-BReSnwHp.js} +3 -3
  41. package/dist/nitro.d.ts +1 -1
  42. package/dist/nitro.js +20 -6
  43. package/dist/{oauth-callback-server-NXK7AlBp.js → oauth-callback-server-CE4soEIY.js} +2 -2
  44. package/dist/{oauth-relay-6NBPSpFE.js → oauth-relay-C36gX1gH.js} +2 -2
  45. package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
  46. package/dist/{parent-result-Dg6P6roR.js → parent-result-Ck1rFYRQ.js} +93 -106
  47. package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
  48. package/dist/profile-BQ-iBDsZ.js +4657 -0
  49. package/dist/{transcript-BHhJVY0P.js → prompt-Dv7gkpD6.js} +97 -103
  50. package/dist/proxy-path-BHYoKZdq.js +15 -0
  51. package/dist/registry-iXMT5Jmh.js +3279 -0
  52. package/dist/reports-WKHfGTsU.js +195 -0
  53. package/dist/{resolve-BUFkmxkT.js → resolve-tony4ibz.js} +9 -29
  54. package/dist/{result-DfATzX77.js → result-Bta_dlWa.js} +42 -117
  55. package/dist/run-conversation-DL6ru7iW.js +336 -0
  56. package/dist/{runner-CmKP3inb.js → runner-BstDRbD9.js} +7 -7
  57. package/dist/{sandbox-egress-signals-DYo5BsM7.js → sandbox-egress-signals-oSJMJOnn.js} +1 -1
  58. package/dist/{schema-DrBMdPmv.js → schema-DfqrHACA.js} +67 -84
  59. package/dist/sender-actors-CPglLd5R.js +83 -0
  60. package/dist/{service-account-CxTX7nnR.js → service-account-CTV_jaNu.js} +3 -1
  61. package/dist/{skills-BlHUDj7k.js → skills-BCEU41zM.js} +4 -4
  62. package/dist/{slack-conversation-unfurl-Dhe3lB1U.js → slack-conversation-unfurl-DxVmhbGP.js} +7 -6
  63. package/dist/{spawn-CfvlFdfz.js → spawn-frczVPIr.js} +11 -8
  64. package/dist/{system-prompt-table-CDCYVwqN.js → system-prompt-table-CiXy0eNR.js} +91 -70
  65. package/dist/{task-runner-DcdQJd9e.js → task-runner-C9Yc2_ae.js} +35 -49
  66. package/dist/{thread-context-DF5uDcWN.js → thread-context-CqZDKErp.js} +6 -6
  67. package/dist/topics-SRN7IVX-.js +24 -0
  68. package/dist/turn-membership-CENFf3kI.js +856 -0
  69. package/dist/{turn-wake-um5Ubd4m.js → turn-wake-BhloiI2h.js} +4 -5
  70. package/dist/{media-Cr9pGkzr.js → types-C4iC-IMC.js} +819 -777
  71. package/dist/user-customization-CvfuY9Eo.js +93 -0
  72. package/dist/users-ByG5RCEJ.js +181 -0
  73. package/dist/{validation-CJyuOPD2.js → validation-8gjfR91V.js} +1 -1
  74. package/dist/{version-Bhe7RPIe.js → version-BeZhWWBE.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{worker-D8PRgUqr.js → worker-BqMQQNRk.js} +5 -4
  77. package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
  78. package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
  79. package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
  80. package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
  81. package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
  82. package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
  83. package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
  84. package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
  85. package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
  86. package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
  87. package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
  88. package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
  89. package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
  90. package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
  91. package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
  92. package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
  93. package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
  94. package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
  95. package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
  96. package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
  97. package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
  98. package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
  99. package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
  100. package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
  101. package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
  102. package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
  103. package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
  104. package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
  105. package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
  106. package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
  107. package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
  108. package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
  109. package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
  110. package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
  111. package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
  112. package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
  113. package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
  114. package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
  115. package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
  116. package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
  117. package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
  118. package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
  119. package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
  120. package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
  121. package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
  122. package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
  123. package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
  124. package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
  125. package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
  126. package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
  127. package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
  128. package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
  129. package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
  130. package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
  131. package/package.json +5 -5
  132. package/skills/jr-rpc/SKILL.md +3 -5
  133. package/dist/direct-url-BYgYfuIy.js +0 -22
  134. package/dist/markers-CE0HMXWT.js +0 -67
  135. package/dist/people-Cegp1Iwq.js +0 -81
  136. package/dist/start-conversation-Uh8Sk1EF.js +0 -162
  137. package/dist/turn-session-routing-GtetHsdO.js +0 -1309
  138. package/dist/user-customization-B27StpVQ.js +0 -9
  139. package/dist/web-message-id-C6P83ans.js +0 -10
@@ -0,0 +1,407 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "e9774788-9b7a-4fba-a7ac-beba0fd9ee30",
6
+ "prevIds": ["a0694ee7-a7bb-4440-8283-3cb5add2ee08"],
7
+ "footprints": [
8
+ {
9
+ "statementType": "create_table",
10
+ "statementTarget": ["table", "public", "junior_questions"],
11
+ "writes": [
12
+ "s|tbl|public.junior_questions",
13
+ "n|tbl|public.junior_questions",
14
+ "e|tbl|public.junior_questions",
15
+ "n|rel|public.junior_questions",
16
+ "n|type|public.junior_questions",
17
+ "n|rel|public.junior_questions_pkey"
18
+ ],
19
+ "reads": ["n|sch|public"]
20
+ },
21
+ {
22
+ "statementType": "alter_column",
23
+ "statementTarget": ["column", "public", "junior_inbox_items", "title"],
24
+ "writes": ["s|colprop|public.junior_inbox_items.title.notNull"],
25
+ "reads": [
26
+ "n|tbl|public.junior_inbox_items",
27
+ "n|sch|public",
28
+ "n|col|public.junior_inbox_items.title"
29
+ ],
30
+ "sqlHash": "833d74c3bcd16cec"
31
+ },
32
+ {
33
+ "statementType": "alter_column",
34
+ "statementTarget": ["column", "public", "junior_inbox_items", "body"],
35
+ "writes": ["s|colprop|public.junior_inbox_items.body.notNull"],
36
+ "reads": [
37
+ "n|tbl|public.junior_inbox_items",
38
+ "n|sch|public",
39
+ "n|col|public.junior_inbox_items.body"
40
+ ],
41
+ "sqlHash": "568abfd4e22e842a"
42
+ },
43
+ {
44
+ "statementType": "create_index",
45
+ "statementTarget": [
46
+ "index",
47
+ "public",
48
+ "junior_questions",
49
+ "junior_questions_conversation_idx"
50
+ ],
51
+ "writes": [
52
+ "s|idx|public.junior_questions_conversation_idx",
53
+ "n|idx|public.junior_questions_conversation_idx",
54
+ "e|idx|public.junior_questions_conversation_idx",
55
+ "n|rel|public.junior_questions_conversation_idx"
56
+ ],
57
+ "reads": [
58
+ "n|tbl|public.junior_questions",
59
+ "n|sch|public",
60
+ "n|col|public.junior_questions.conversation_id"
61
+ ]
62
+ },
63
+ {
64
+ "statementType": "create_index",
65
+ "statementTarget": [
66
+ "index",
67
+ "public",
68
+ "junior_questions",
69
+ "junior_questions_search_idx"
70
+ ],
71
+ "writes": [
72
+ "s|idx|public.junior_questions_search_idx",
73
+ "n|idx|public.junior_questions_search_idx",
74
+ "e|idx|public.junior_questions_search_idx",
75
+ "n|rel|public.junior_questions_search_idx"
76
+ ],
77
+ "reads": ["n|tbl|public.junior_questions", "n|sch|public"]
78
+ },
79
+ {
80
+ "statementType": "create_index",
81
+ "statementTarget": [
82
+ "index",
83
+ "public",
84
+ "junior_questions",
85
+ "junior_questions_title_trgm_idx"
86
+ ],
87
+ "writes": [
88
+ "s|idx|public.junior_questions_title_trgm_idx",
89
+ "n|idx|public.junior_questions_title_trgm_idx",
90
+ "e|idx|public.junior_questions_title_trgm_idx",
91
+ "n|rel|public.junior_questions_title_trgm_idx"
92
+ ],
93
+ "reads": ["n|tbl|public.junior_questions", "n|sch|public"]
94
+ },
95
+ {
96
+ "statementType": "create_fk",
97
+ "statementTarget": ["table", "public", "junior_questions"],
98
+ "writes": [
99
+ "s|fk|public.junior_questions.junior_questions_HSrO9i8pUj0G_fkey",
100
+ "n|fk|public.junior_questions.junior_questions_HSrO9i8pUj0G_fkey",
101
+ "e|fk|public.junior_questions.junior_questions_HSrO9i8pUj0G_fkey",
102
+ "n|con|public.junior_questions.junior_questions_HSrO9i8pUj0G_fkey"
103
+ ],
104
+ "reads": [
105
+ "n|tbl|public.junior_questions",
106
+ "n|sch|public",
107
+ "n|tbl|public.junior_conversations",
108
+ "n|sch|public",
109
+ "n|col|public.junior_questions.conversation_id",
110
+ "n|col|public.junior_conversations.conversation_id",
111
+ "e|uniqueness|public.junior_conversations.conversation_id"
112
+ ]
113
+ },
114
+ {
115
+ "statementType": "alter_check",
116
+ "statementTarget": ["table", "public", "junior_inbox_items"],
117
+ "writes": [
118
+ "s|ck|public.junior_inbox_items.junior_inbox_items_kind_check"
119
+ ],
120
+ "reads": [
121
+ "n|tbl|public.junior_inbox_items",
122
+ "n|sch|public",
123
+ "n|col|public.junior_inbox_items.kind",
124
+ "n|col|public.junior_inbox_items.request",
125
+ "n|col|public.junior_inbox_items.answer",
126
+ "n|col|public.junior_inbox_items.subject_kind",
127
+ "e|col|public.junior_inbox_items.kind",
128
+ "e|col|public.junior_inbox_items.request",
129
+ "e|col|public.junior_inbox_items.answer",
130
+ "e|col|public.junior_inbox_items.subject_kind"
131
+ ],
132
+ "sqlHash": "e3747a4d3b5f2f77"
133
+ }
134
+ ],
135
+ "deltas": [
136
+ {
137
+ "op": "create",
138
+ "row": {
139
+ "schema": "public",
140
+ "name": "junior_questions",
141
+ "isRlsEnabled": false,
142
+ "entityType": "tables"
143
+ }
144
+ },
145
+ {
146
+ "op": "create",
147
+ "row": {
148
+ "schema": "public",
149
+ "table": "junior_questions",
150
+ "name": "id",
151
+ "type": "text",
152
+ "typeSchema": null,
153
+ "notNull": true,
154
+ "dimensions": 0,
155
+ "default": null,
156
+ "generated": null,
157
+ "identity": null,
158
+ "entityType": "columns"
159
+ }
160
+ },
161
+ {
162
+ "op": "create",
163
+ "row": {
164
+ "schema": "public",
165
+ "table": "junior_questions",
166
+ "name": "conversation_id",
167
+ "type": "text",
168
+ "typeSchema": null,
169
+ "notNull": true,
170
+ "dimensions": 0,
171
+ "default": null,
172
+ "generated": null,
173
+ "identity": null,
174
+ "entityType": "columns"
175
+ }
176
+ },
177
+ {
178
+ "op": "create",
179
+ "row": {
180
+ "schema": "public",
181
+ "table": "junior_questions",
182
+ "name": "turn_id",
183
+ "type": "text",
184
+ "typeSchema": null,
185
+ "notNull": false,
186
+ "dimensions": 0,
187
+ "default": null,
188
+ "generated": null,
189
+ "identity": null,
190
+ "entityType": "columns"
191
+ }
192
+ },
193
+ {
194
+ "op": "create",
195
+ "row": {
196
+ "schema": "public",
197
+ "table": "junior_questions",
198
+ "name": "title",
199
+ "type": "text",
200
+ "typeSchema": null,
201
+ "notNull": true,
202
+ "dimensions": 0,
203
+ "default": null,
204
+ "generated": null,
205
+ "identity": null,
206
+ "entityType": "columns"
207
+ }
208
+ },
209
+ {
210
+ "op": "create",
211
+ "row": {
212
+ "schema": "public",
213
+ "table": "junior_questions",
214
+ "name": "body",
215
+ "type": "text",
216
+ "typeSchema": null,
217
+ "notNull": true,
218
+ "dimensions": 0,
219
+ "default": null,
220
+ "generated": null,
221
+ "identity": null,
222
+ "entityType": "columns"
223
+ }
224
+ },
225
+ {
226
+ "op": "create",
227
+ "row": {
228
+ "schema": "public",
229
+ "table": "junior_questions",
230
+ "name": "request",
231
+ "type": "jsonb",
232
+ "typeSchema": null,
233
+ "notNull": false,
234
+ "dimensions": 0,
235
+ "default": null,
236
+ "generated": null,
237
+ "identity": null,
238
+ "entityType": "columns"
239
+ }
240
+ },
241
+ {
242
+ "op": "create",
243
+ "row": {
244
+ "schema": "public",
245
+ "table": "junior_questions",
246
+ "name": "answer",
247
+ "type": "jsonb",
248
+ "typeSchema": null,
249
+ "notNull": false,
250
+ "dimensions": 0,
251
+ "default": null,
252
+ "generated": null,
253
+ "identity": null,
254
+ "entityType": "columns"
255
+ }
256
+ },
257
+ {
258
+ "op": "create",
259
+ "row": {
260
+ "schema": "public",
261
+ "table": "junior_questions",
262
+ "name": "created_at",
263
+ "type": "timestamp with time zone",
264
+ "typeSchema": null,
265
+ "notNull": true,
266
+ "dimensions": 0,
267
+ "default": null,
268
+ "generated": null,
269
+ "identity": null,
270
+ "entityType": "columns"
271
+ }
272
+ },
273
+ {
274
+ "op": "create",
275
+ "row": {
276
+ "schema": "public",
277
+ "table": "junior_questions",
278
+ "name": "updated_at",
279
+ "type": "timestamp with time zone",
280
+ "typeSchema": null,
281
+ "notNull": true,
282
+ "dimensions": 0,
283
+ "default": null,
284
+ "generated": null,
285
+ "identity": null,
286
+ "entityType": "columns"
287
+ }
288
+ },
289
+ {
290
+ "op": "create",
291
+ "row": {
292
+ "schema": "public",
293
+ "table": "junior_questions",
294
+ "name": "junior_questions_conversation_idx",
295
+ "nameExplicit": true,
296
+ "columns": [
297
+ {
298
+ "value": "conversation_id",
299
+ "isExpression": false,
300
+ "asc": true,
301
+ "nullsFirst": false,
302
+ "opclass": null
303
+ }
304
+ ],
305
+ "isUnique": false,
306
+ "where": null,
307
+ "with": "",
308
+ "method": "btree",
309
+ "entityType": "indexes"
310
+ }
311
+ },
312
+ {
313
+ "op": "create",
314
+ "row": {
315
+ "schema": "public",
316
+ "table": "junior_questions",
317
+ "name": "junior_questions_search_idx",
318
+ "nameExplicit": true,
319
+ "columns": [
320
+ {
321
+ "value": "(setweight(to_tsvector('simple', \"title\"), 'A') || setweight(to_tsvector('simple', \"body\"), 'B'))",
322
+ "isExpression": true,
323
+ "asc": true,
324
+ "nullsFirst": false,
325
+ "opclass": null
326
+ }
327
+ ],
328
+ "isUnique": false,
329
+ "where": null,
330
+ "with": "",
331
+ "method": "gin",
332
+ "entityType": "indexes"
333
+ }
334
+ },
335
+ {
336
+ "op": "create",
337
+ "row": {
338
+ "schema": "public",
339
+ "table": "junior_questions",
340
+ "name": "junior_questions_title_trgm_idx",
341
+ "nameExplicit": true,
342
+ "columns": [
343
+ {
344
+ "value": "lower(\"title\") gin_trgm_ops",
345
+ "isExpression": true,
346
+ "asc": true,
347
+ "nullsFirst": false,
348
+ "opclass": null
349
+ }
350
+ ],
351
+ "isUnique": false,
352
+ "where": null,
353
+ "with": "",
354
+ "method": "gin",
355
+ "entityType": "indexes"
356
+ }
357
+ },
358
+ {
359
+ "op": "create",
360
+ "row": {
361
+ "schema": "public",
362
+ "table": "junior_questions",
363
+ "name": "junior_questions_HSrO9i8pUj0G_fkey",
364
+ "nameExplicit": false,
365
+ "columns": ["conversation_id"],
366
+ "schemaTo": "public",
367
+ "tableTo": "junior_conversations",
368
+ "columnsTo": ["conversation_id"],
369
+ "onUpdate": "NO ACTION",
370
+ "onDelete": "CASCADE",
371
+ "entityType": "fks"
372
+ }
373
+ },
374
+ {
375
+ "op": "create",
376
+ "row": {
377
+ "schema": "public",
378
+ "table": "junior_questions",
379
+ "name": "junior_questions_pkey",
380
+ "columns": ["id"],
381
+ "nameExplicit": false,
382
+ "entityType": "pks"
383
+ }
384
+ },
385
+ {
386
+ "op": "alter",
387
+ "key": "columns\u0000[\"public\",\"junior_inbox_items\",\"title\"]",
388
+ "set": {
389
+ "notNull": false
390
+ }
391
+ },
392
+ {
393
+ "op": "alter",
394
+ "key": "columns\u0000[\"public\",\"junior_inbox_items\",\"body\"]",
395
+ "set": {
396
+ "notNull": false
397
+ }
398
+ },
399
+ {
400
+ "op": "alter",
401
+ "key": "checks\u0000[\"public\",\"junior_inbox_items\",\"junior_inbox_items_kind_check\"]",
402
+ "set": {
403
+ "value": "(\"kind\" = 'notice' and \"request\" -> 'question' is null and \"answer\" is null) or (\"kind\" = 'action' and (\"request\" -> 'question' is not null or (\"subject_kind\" <> 'reply' and \"answer\" is null)))"
404
+ }
405
+ }
406
+ ]
407
+ }
@@ -0,0 +1,74 @@
1
+ -- New code reads the owner, visibility, and provider tenant of an Inbox item
2
+ -- from its subject (`chat/inbox-items/owner.ts`), and its schema no longer
3
+ -- names `dedupe_key`, `owner_kind`, `owner_id`, or `visibility`. They keep
4
+ -- their NOT NULL and their checks for one release, so the release before
5
+ -- this one can still read and write every row after a rollback. This
6
+ -- trigger writes them for new code: the owner that the code adding the item
7
+ -- names (`junior.inbox_item_owner_kind` and `junior.inbox_item_owner_id`,
8
+ -- set for its transaction), a dedupe key in the old form of its subject
9
+ -- kind, and the owner's visibility: its Destination's, but private while
10
+ -- an owner Conversation is private. A question item gets a copy of its
11
+ -- question's title and body, and an action also gets a copy of its
12
+ -- request, which the old kind check needs. An old worker writes all
13
+ -- of them itself, so the trigger leaves its rows alone. A later release
14
+ -- drops the trigger with the old columns and checks. Its name sorts after
15
+ -- `junior_inbox_items_legacy_subject_question`, so an old worker's question
16
+ -- item has its content before it runs.
17
+ CREATE OR REPLACE FUNCTION "junior_inbox_items_legacy_write"()
18
+ RETURNS trigger
19
+ LANGUAGE plpgsql
20
+ AS $function$
21
+ DECLARE
22
+ question record;
23
+ BEGIN
24
+ IF TG_OP = 'INSERT' AND NEW."dedupe_key" IS NULL THEN
25
+ NEW."owner_kind" := nullif(current_setting('junior.inbox_item_owner_kind', true), '');
26
+ NEW."owner_id" := nullif(current_setting('junior.inbox_item_owner_id', true), '');
27
+ IF NEW."owner_kind" IS NULL OR NEW."owner_id" IS NULL THEN
28
+ RAISE EXCEPTION 'Inbox item % has no owner to write', NEW."id";
29
+ END IF;
30
+ NEW."dedupe_key" := CASE
31
+ WHEN NEW."subject_kind" IN ('automation', 'reply', 'todo') THEN NEW."subject_kind" || ':' || NEW."subject_id"
32
+ WHEN NEW."subject_kind" = 'question' THEN NEW."subject_id"
33
+ ELSE 'plugin:' || NEW."subject_kind" || ':' || NEW."subject_id"
34
+ END;
35
+ NEW."visibility" := CASE
36
+ WHEN NEW."subject_kind" = 'todo' THEN 'private'
37
+ WHEN NEW."owner_kind" = 'automation' THEN (SELECT d."visibility" FROM "junior_automations" a JOIN "junior_destinations" d ON d."provider" = 'slack' AND d."provider_tenant_id" = a."team_id" AND d."provider_destination_id" = a."channel_id" WHERE a."id" = NEW."owner_id")
38
+ ELSE (SELECT CASE WHEN r."visibility" = 'public' THEN d."visibility" END FROM "junior_conversations" o JOIN "junior_conversations" r ON r."conversation_id" = o."root_conversation_id" JOIN "junior_destinations" d ON d."id" = r."destination_id" WHERE o."conversation_id" = NEW."owner_id")
39
+ END;
40
+ IF NEW."visibility" IS DISTINCT FROM 'public' THEN
41
+ NEW."visibility" := 'private';
42
+ END IF;
43
+ END IF;
44
+ IF NEW."subject_kind" = 'question'
45
+ AND (NEW."title" IS NULL OR NEW."body" IS NULL OR (NEW."kind" = 'action' AND NEW."request" IS NULL))
46
+ THEN
47
+ SELECT q."title", q."body", q."request" INTO question FROM "junior_questions" q WHERE q."id" = NEW."subject_id";
48
+ NEW."title" := coalesce(NEW."title", question."title", '');
49
+ NEW."body" := coalesce(NEW."body", question."body", '');
50
+ IF NEW."kind" = 'action' AND NEW."request" IS NULL THEN
51
+ -- The release before this one reads `evidence`, not `related`.
52
+ NEW."request" := CASE
53
+ WHEN question."request" ? 'related' THEN (question."request" - 'related') || jsonb_build_object('evidence', question."request" -> 'related')
54
+ ELSE coalesce(question."request", '{}'::jsonb)
55
+ END;
56
+ END IF;
57
+ END IF;
58
+ RETURN NEW;
59
+ END;
60
+ $function$;--> statement-breakpoint
61
+ CREATE OR REPLACE TRIGGER "junior_inbox_items_legacy_write" BEFORE INSERT OR UPDATE ON "junior_inbox_items" FOR EACH ROW EXECUTE FUNCTION "junior_inbox_items_legacy_write"();--> statement-breakpoint
62
+ -- A subject now has one open item in all provider tenants, not one in each.
63
+ -- Before the next migration makes that unique, the newest open item of a
64
+ -- subject stays open and the others close. Two tenants seldom share a
65
+ -- subject, because each subject id names one Conversation, Automation, or
66
+ -- plugin object.
67
+ -- junior:bounded-backfill: only open items whose subject has a newer open item in another provider tenant change.
68
+ UPDATE "junior_inbox_items" AS "item" SET "status" = 'dismissed', "closed_at" = now(), "close_reason" = 'A newer item asks about the same subject.', "updated_at" = now() WHERE "item"."status" = 'open' AND EXISTS (SELECT 1 FROM "junior_inbox_items" AS "newer" WHERE "newer"."status" = 'open' AND "newer"."subject_kind" = "item"."subject_kind" AND "newer"."subject_id" = "item"."subject_id" AND ("newer"."updated_at", "newer"."id") > ("item"."updated_at", "item"."id"));--> statement-breakpoint
69
+ -- junior:bounded-backfill: a snooze of a closed duplicate moves to the item that stays open in any provider tenant, as in `20261126153100_inbox_item_subjects`. It reads only the snoozes of the few duplicates.
70
+ UPDATE "junior_inbox_snoozes" AS "snooze" SET "inbox_item_id" = "move"."open_id" FROM (SELECT DISTINCT ON ("snooze"."user_id", "open"."id") "snooze"."id", "open"."id" AS "open_id" FROM "junior_inbox_snoozes" AS "snooze" JOIN "junior_inbox_items" AS "item" ON "item"."id" = "snooze"."inbox_item_id" JOIN "junior_inbox_items" AS "open" ON "open"."status" = 'open' AND "open"."subject_kind" = "item"."subject_kind" AND "open"."subject_id" = "item"."subject_id" WHERE "snooze"."state" = 'snoozed' AND "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.' AND NOT EXISTS (SELECT 1 FROM "junior_inbox_snoozes" AS "kept" WHERE "kept"."inbox_item_id" = "open"."id" AND "kept"."user_id" = "snooze"."user_id" AND "kept"."state" = 'snoozed') ORDER BY "snooze"."user_id", "open"."id", "snooze"."created_at" DESC) AS "move" WHERE "snooze"."id" = "move"."id";--> statement-breakpoint
71
+ -- junior:bounded-backfill: the assignees of a closed duplicate join the item that stays open, so they keep their ask. It reads only the assignees of the few duplicates. An open item with no assignees asks everyone, so it gets none.
72
+ INSERT INTO "junior_inbox_item_assignees" ("item_id", "user_id") SELECT DISTINCT "open"."id", "assignee"."user_id" FROM "junior_inbox_item_assignees" AS "assignee" JOIN "junior_inbox_items" AS "item" ON "item"."id" = "assignee"."item_id" JOIN "junior_inbox_items" AS "open" ON "open"."status" = 'open' AND "open"."subject_kind" = "item"."subject_kind" AND "open"."subject_id" = "item"."subject_id" WHERE "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.' AND EXISTS (SELECT 1 FROM "junior_inbox_item_assignees" AS "kept" WHERE "kept"."item_id" = "open"."id") ON CONFLICT DO NOTHING;--> statement-breakpoint
73
+ -- junior:bounded-backfill: the sent pushes of a closed duplicate clear, as for any closed item, so the devices close it. It reads only the deliveries of the few duplicates.
74
+ UPDATE "junior_inbox_item_deliveries" AS "delivery" SET "status" = 'cleared', "updated_at" = now() FROM "junior_inbox_items" AS "item" WHERE "item"."id" = "delivery"."item_id" AND "delivery"."status" = 'sent' AND "item"."status" = 'dismissed' AND "item"."close_reason" = 'A newer item asks about the same subject.';
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "096ac968-366f-4e75-9688-229400690f1a",
6
+ "prevIds": ["e9774788-9b7a-4fba-a7ac-beba0fd9ee30"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1 @@
1
+ CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "junior_inbox_items_open_subject_key_uidx" ON "junior_inbox_items" USING btree ("subject_kind","subject_id") WHERE "junior_inbox_items"."status" = 'open';
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "7e71a441-306d-4959-bbea-ca64d91520ac",
6
+ "prevIds": ["096ac968-366f-4e75-9688-229400690f1a"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1,7 @@
1
+ -- `junior_inbox_items_open_subject_key_uidx` now keeps one open item per
2
+ -- subject. Reads find the items of an owner through the subject, so the
3
+ -- indexes on `owner_id` and on the provider tenant have no reader.
4
+ DROP INDEX IF EXISTS "junior_inbox_items_open_subject_uidx";--> statement-breakpoint
5
+ DROP INDEX IF EXISTS "junior_inbox_items_owner_idx";--> statement-breakpoint
6
+ DROP INDEX IF EXISTS "junior_inbox_items_open_action_owner_idx";--> statement-breakpoint
7
+ DROP INDEX IF EXISTS "junior_inbox_items_answered_idx";
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "diff",
3
+ "version": "10",
4
+ "dialect": "postgres",
5
+ "id": "2e96746d-88c7-4345-a9b2-8d8a28e53faa",
6
+ "prevIds": ["7e71a441-306d-4959-bbea-ca64d91520ac"],
7
+ "footprints": [],
8
+ "deltas": []
9
+ }
@@ -0,0 +1,8 @@
1
+ -- This migration does not change the database. The three migrations before
2
+ -- it change `junior_inbox_items` by hand, because the new unique index must
3
+ -- build concurrently after the duplicate open items close. This snapshot
4
+ -- records the schema that they leave, so `drizzle-kit generate` does not
5
+ -- write their changes again. `owner_kind`, `owner_id`, `visibility`,
6
+ -- `provider`, and `provider_tenant_id` stay in the database for one release,
7
+ -- because old workers still write them. The next release drops them with
8
+ -- DROP COLUMN IF EXISTS.