@app-vitals/agent-admin 1.111.0 → 1.113.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/e2e/real/member-agents.real.e2e.ts +8 -4
- package/package.json +2 -2
- package/prisma/client/internal/class.ts +4 -4
- package/prisma/client/internal/prismaNamespace.ts +1 -0
- package/prisma/client/internal/prismaNamespaceBrowser.ts +1 -0
- package/prisma/client/models/UserNotificationPrefs.ts +29 -1
- package/prisma/migrations/20261201000000_rename_user_notification_prefs_to_user_prefs/migration.sql +4 -0
- package/prisma/schema/schema.prisma +3 -0
- package/src/admin-boot.ts +15 -6
- package/src/admin-extension.ts +10 -1
- package/src/admin-ui-layout.ts +2 -0
- package/src/admin-ui-preferences-pages.ts +79 -0
- package/src/admin-ui-preferences.smoke.test.ts +168 -0
- package/src/admin-ui-preferences.ts +103 -0
- package/src/admin-ui-settings-layout.ts +12 -1
- package/src/admin-ui.ts +78 -12
- package/src/drop-email-key-columns-migration.integration.test.ts +0 -4
- package/src/principals-api.integration.test.ts +3 -3
- package/src/timezone-resolver.ts +88 -0
- package/src/timezone-resolver.unit.test.ts +127 -0
- package/src/user-notification-prefs.ts +10 -65
- package/src/user-notification-prefs.unit.test.ts +9 -0
- package/src/user-prefs-rename-migration.integration.test.ts +71 -0
- package/src/{user-notification-prefs.integration.test.ts → user-prefs.integration.test.ts} +22 -5
- package/src/user-prefs.ts +98 -0
|
@@ -3351,6 +3351,7 @@ export type ChatThreadWatchScalarFieldEnum = (typeof ChatThreadWatchScalarFieldE
|
|
|
3351
3351
|
|
|
3352
3352
|
export const UserNotificationPrefsScalarFieldEnum = {
|
|
3353
3353
|
memberId: 'memberId',
|
|
3354
|
+
timezone: 'timezone',
|
|
3354
3355
|
autoFollowSessions: 'autoFollowSessions',
|
|
3355
3356
|
reminderHourLocal: 'reminderHourLocal',
|
|
3356
3357
|
autoFollowSince: 'autoFollowSince',
|
|
@@ -523,6 +523,7 @@ export type ChatThreadWatchScalarFieldEnum = (typeof ChatThreadWatchScalarFieldE
|
|
|
523
523
|
|
|
524
524
|
export const UserNotificationPrefsScalarFieldEnum = {
|
|
525
525
|
memberId: 'memberId',
|
|
526
|
+
timezone: 'timezone',
|
|
526
527
|
autoFollowSessions: 'autoFollowSessions',
|
|
527
528
|
reminderHourLocal: 'reminderHourLocal',
|
|
528
529
|
autoFollowSince: 'autoFollowSince',
|
|
@@ -36,6 +36,7 @@ export type UserNotificationPrefsSumAggregateOutputType = {
|
|
|
36
36
|
|
|
37
37
|
export type UserNotificationPrefsMinAggregateOutputType = {
|
|
38
38
|
memberId: string | null
|
|
39
|
+
timezone: string | null
|
|
39
40
|
autoFollowSessions: boolean | null
|
|
40
41
|
reminderHourLocal: number | null
|
|
41
42
|
autoFollowSince: Date | null
|
|
@@ -45,6 +46,7 @@ export type UserNotificationPrefsMinAggregateOutputType = {
|
|
|
45
46
|
|
|
46
47
|
export type UserNotificationPrefsMaxAggregateOutputType = {
|
|
47
48
|
memberId: string | null
|
|
49
|
+
timezone: string | null
|
|
48
50
|
autoFollowSessions: boolean | null
|
|
49
51
|
reminderHourLocal: number | null
|
|
50
52
|
autoFollowSince: Date | null
|
|
@@ -54,6 +56,7 @@ export type UserNotificationPrefsMaxAggregateOutputType = {
|
|
|
54
56
|
|
|
55
57
|
export type UserNotificationPrefsCountAggregateOutputType = {
|
|
56
58
|
memberId: number
|
|
59
|
+
timezone: number
|
|
57
60
|
autoFollowSessions: number
|
|
58
61
|
reminderHourLocal: number
|
|
59
62
|
autoFollowSince: number
|
|
@@ -73,6 +76,7 @@ export type UserNotificationPrefsSumAggregateInputType = {
|
|
|
73
76
|
|
|
74
77
|
export type UserNotificationPrefsMinAggregateInputType = {
|
|
75
78
|
memberId?: true
|
|
79
|
+
timezone?: true
|
|
76
80
|
autoFollowSessions?: true
|
|
77
81
|
reminderHourLocal?: true
|
|
78
82
|
autoFollowSince?: true
|
|
@@ -82,6 +86,7 @@ export type UserNotificationPrefsMinAggregateInputType = {
|
|
|
82
86
|
|
|
83
87
|
export type UserNotificationPrefsMaxAggregateInputType = {
|
|
84
88
|
memberId?: true
|
|
89
|
+
timezone?: true
|
|
85
90
|
autoFollowSessions?: true
|
|
86
91
|
reminderHourLocal?: true
|
|
87
92
|
autoFollowSince?: true
|
|
@@ -91,6 +96,7 @@ export type UserNotificationPrefsMaxAggregateInputType = {
|
|
|
91
96
|
|
|
92
97
|
export type UserNotificationPrefsCountAggregateInputType = {
|
|
93
98
|
memberId?: true
|
|
99
|
+
timezone?: true
|
|
94
100
|
autoFollowSessions?: true
|
|
95
101
|
reminderHourLocal?: true
|
|
96
102
|
autoFollowSince?: true
|
|
@@ -187,6 +193,7 @@ export type UserNotificationPrefsGroupByArgs<ExtArgs extends runtime.Types.Exten
|
|
|
187
193
|
|
|
188
194
|
export type UserNotificationPrefsGroupByOutputType = {
|
|
189
195
|
memberId: string
|
|
196
|
+
timezone: string | null
|
|
190
197
|
autoFollowSessions: boolean
|
|
191
198
|
reminderHourLocal: number
|
|
192
199
|
autoFollowSince: Date | null
|
|
@@ -219,6 +226,7 @@ export type UserNotificationPrefsWhereInput = {
|
|
|
219
226
|
OR?: Prisma.UserNotificationPrefsWhereInput[]
|
|
220
227
|
NOT?: Prisma.UserNotificationPrefsWhereInput | Prisma.UserNotificationPrefsWhereInput[]
|
|
221
228
|
memberId?: Prisma.StringFilter<"UserNotificationPrefs"> | string
|
|
229
|
+
timezone?: Prisma.StringNullableFilter<"UserNotificationPrefs"> | string | null
|
|
222
230
|
autoFollowSessions?: Prisma.BoolFilter<"UserNotificationPrefs"> | boolean
|
|
223
231
|
reminderHourLocal?: Prisma.IntFilter<"UserNotificationPrefs"> | number
|
|
224
232
|
autoFollowSince?: Prisma.DateTimeNullableFilter<"UserNotificationPrefs"> | Date | string | null
|
|
@@ -228,6 +236,7 @@ export type UserNotificationPrefsWhereInput = {
|
|
|
228
236
|
|
|
229
237
|
export type UserNotificationPrefsOrderByWithRelationInput = {
|
|
230
238
|
memberId?: Prisma.SortOrder
|
|
239
|
+
timezone?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
231
240
|
autoFollowSessions?: Prisma.SortOrder
|
|
232
241
|
reminderHourLocal?: Prisma.SortOrder
|
|
233
242
|
autoFollowSince?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
@@ -240,6 +249,7 @@ export type UserNotificationPrefsWhereUniqueInput = Prisma.AtLeast<{
|
|
|
240
249
|
AND?: Prisma.UserNotificationPrefsWhereInput | Prisma.UserNotificationPrefsWhereInput[]
|
|
241
250
|
OR?: Prisma.UserNotificationPrefsWhereInput[]
|
|
242
251
|
NOT?: Prisma.UserNotificationPrefsWhereInput | Prisma.UserNotificationPrefsWhereInput[]
|
|
252
|
+
timezone?: Prisma.StringNullableFilter<"UserNotificationPrefs"> | string | null
|
|
243
253
|
autoFollowSessions?: Prisma.BoolFilter<"UserNotificationPrefs"> | boolean
|
|
244
254
|
reminderHourLocal?: Prisma.IntFilter<"UserNotificationPrefs"> | number
|
|
245
255
|
autoFollowSince?: Prisma.DateTimeNullableFilter<"UserNotificationPrefs"> | Date | string | null
|
|
@@ -249,6 +259,7 @@ export type UserNotificationPrefsWhereUniqueInput = Prisma.AtLeast<{
|
|
|
249
259
|
|
|
250
260
|
export type UserNotificationPrefsOrderByWithAggregationInput = {
|
|
251
261
|
memberId?: Prisma.SortOrder
|
|
262
|
+
timezone?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
252
263
|
autoFollowSessions?: Prisma.SortOrder
|
|
253
264
|
reminderHourLocal?: Prisma.SortOrder
|
|
254
265
|
autoFollowSince?: Prisma.SortOrderInput | Prisma.SortOrder
|
|
@@ -266,6 +277,7 @@ export type UserNotificationPrefsScalarWhereWithAggregatesInput = {
|
|
|
266
277
|
OR?: Prisma.UserNotificationPrefsScalarWhereWithAggregatesInput[]
|
|
267
278
|
NOT?: Prisma.UserNotificationPrefsScalarWhereWithAggregatesInput | Prisma.UserNotificationPrefsScalarWhereWithAggregatesInput[]
|
|
268
279
|
memberId?: Prisma.StringWithAggregatesFilter<"UserNotificationPrefs"> | string
|
|
280
|
+
timezone?: Prisma.StringNullableWithAggregatesFilter<"UserNotificationPrefs"> | string | null
|
|
269
281
|
autoFollowSessions?: Prisma.BoolWithAggregatesFilter<"UserNotificationPrefs"> | boolean
|
|
270
282
|
reminderHourLocal?: Prisma.IntWithAggregatesFilter<"UserNotificationPrefs"> | number
|
|
271
283
|
autoFollowSince?: Prisma.DateTimeNullableWithAggregatesFilter<"UserNotificationPrefs"> | Date | string | null
|
|
@@ -275,6 +287,7 @@ export type UserNotificationPrefsScalarWhereWithAggregatesInput = {
|
|
|
275
287
|
|
|
276
288
|
export type UserNotificationPrefsCreateInput = {
|
|
277
289
|
memberId: string
|
|
290
|
+
timezone?: string | null
|
|
278
291
|
autoFollowSessions?: boolean
|
|
279
292
|
reminderHourLocal?: number
|
|
280
293
|
autoFollowSince?: Date | string | null
|
|
@@ -284,6 +297,7 @@ export type UserNotificationPrefsCreateInput = {
|
|
|
284
297
|
|
|
285
298
|
export type UserNotificationPrefsUncheckedCreateInput = {
|
|
286
299
|
memberId: string
|
|
300
|
+
timezone?: string | null
|
|
287
301
|
autoFollowSessions?: boolean
|
|
288
302
|
reminderHourLocal?: number
|
|
289
303
|
autoFollowSince?: Date | string | null
|
|
@@ -293,6 +307,7 @@ export type UserNotificationPrefsUncheckedCreateInput = {
|
|
|
293
307
|
|
|
294
308
|
export type UserNotificationPrefsUpdateInput = {
|
|
295
309
|
memberId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
310
|
+
timezone?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
296
311
|
autoFollowSessions?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
297
312
|
reminderHourLocal?: Prisma.IntFieldUpdateOperationsInput | number
|
|
298
313
|
autoFollowSince?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
@@ -302,6 +317,7 @@ export type UserNotificationPrefsUpdateInput = {
|
|
|
302
317
|
|
|
303
318
|
export type UserNotificationPrefsUncheckedUpdateInput = {
|
|
304
319
|
memberId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
320
|
+
timezone?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
305
321
|
autoFollowSessions?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
306
322
|
reminderHourLocal?: Prisma.IntFieldUpdateOperationsInput | number
|
|
307
323
|
autoFollowSince?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
@@ -311,6 +327,7 @@ export type UserNotificationPrefsUncheckedUpdateInput = {
|
|
|
311
327
|
|
|
312
328
|
export type UserNotificationPrefsCreateManyInput = {
|
|
313
329
|
memberId: string
|
|
330
|
+
timezone?: string | null
|
|
314
331
|
autoFollowSessions?: boolean
|
|
315
332
|
reminderHourLocal?: number
|
|
316
333
|
autoFollowSince?: Date | string | null
|
|
@@ -320,6 +337,7 @@ export type UserNotificationPrefsCreateManyInput = {
|
|
|
320
337
|
|
|
321
338
|
export type UserNotificationPrefsUpdateManyMutationInput = {
|
|
322
339
|
memberId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
340
|
+
timezone?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
323
341
|
autoFollowSessions?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
324
342
|
reminderHourLocal?: Prisma.IntFieldUpdateOperationsInput | number
|
|
325
343
|
autoFollowSince?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
@@ -329,6 +347,7 @@ export type UserNotificationPrefsUpdateManyMutationInput = {
|
|
|
329
347
|
|
|
330
348
|
export type UserNotificationPrefsUncheckedUpdateManyInput = {
|
|
331
349
|
memberId?: Prisma.StringFieldUpdateOperationsInput | string
|
|
350
|
+
timezone?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
332
351
|
autoFollowSessions?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
|
333
352
|
reminderHourLocal?: Prisma.IntFieldUpdateOperationsInput | number
|
|
334
353
|
autoFollowSince?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
@@ -338,6 +357,7 @@ export type UserNotificationPrefsUncheckedUpdateManyInput = {
|
|
|
338
357
|
|
|
339
358
|
export type UserNotificationPrefsCountOrderByAggregateInput = {
|
|
340
359
|
memberId?: Prisma.SortOrder
|
|
360
|
+
timezone?: Prisma.SortOrder
|
|
341
361
|
autoFollowSessions?: Prisma.SortOrder
|
|
342
362
|
reminderHourLocal?: Prisma.SortOrder
|
|
343
363
|
autoFollowSince?: Prisma.SortOrder
|
|
@@ -351,6 +371,7 @@ export type UserNotificationPrefsAvgOrderByAggregateInput = {
|
|
|
351
371
|
|
|
352
372
|
export type UserNotificationPrefsMaxOrderByAggregateInput = {
|
|
353
373
|
memberId?: Prisma.SortOrder
|
|
374
|
+
timezone?: Prisma.SortOrder
|
|
354
375
|
autoFollowSessions?: Prisma.SortOrder
|
|
355
376
|
reminderHourLocal?: Prisma.SortOrder
|
|
356
377
|
autoFollowSince?: Prisma.SortOrder
|
|
@@ -360,6 +381,7 @@ export type UserNotificationPrefsMaxOrderByAggregateInput = {
|
|
|
360
381
|
|
|
361
382
|
export type UserNotificationPrefsMinOrderByAggregateInput = {
|
|
362
383
|
memberId?: Prisma.SortOrder
|
|
384
|
+
timezone?: Prisma.SortOrder
|
|
363
385
|
autoFollowSessions?: Prisma.SortOrder
|
|
364
386
|
reminderHourLocal?: Prisma.SortOrder
|
|
365
387
|
autoFollowSince?: Prisma.SortOrder
|
|
@@ -375,6 +397,7 @@ export type UserNotificationPrefsSumOrderByAggregateInput = {
|
|
|
375
397
|
|
|
376
398
|
export type UserNotificationPrefsSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
|
377
399
|
memberId?: boolean
|
|
400
|
+
timezone?: boolean
|
|
378
401
|
autoFollowSessions?: boolean
|
|
379
402
|
reminderHourLocal?: boolean
|
|
380
403
|
autoFollowSince?: boolean
|
|
@@ -384,6 +407,7 @@ export type UserNotificationPrefsSelect<ExtArgs extends runtime.Types.Extensions
|
|
|
384
407
|
|
|
385
408
|
export type UserNotificationPrefsSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
|
386
409
|
memberId?: boolean
|
|
410
|
+
timezone?: boolean
|
|
387
411
|
autoFollowSessions?: boolean
|
|
388
412
|
reminderHourLocal?: boolean
|
|
389
413
|
autoFollowSince?: boolean
|
|
@@ -393,6 +417,7 @@ export type UserNotificationPrefsSelectCreateManyAndReturn<ExtArgs extends runti
|
|
|
393
417
|
|
|
394
418
|
export type UserNotificationPrefsSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
|
395
419
|
memberId?: boolean
|
|
420
|
+
timezone?: boolean
|
|
396
421
|
autoFollowSessions?: boolean
|
|
397
422
|
reminderHourLocal?: boolean
|
|
398
423
|
autoFollowSince?: boolean
|
|
@@ -402,6 +427,7 @@ export type UserNotificationPrefsSelectUpdateManyAndReturn<ExtArgs extends runti
|
|
|
402
427
|
|
|
403
428
|
export type UserNotificationPrefsSelectScalar = {
|
|
404
429
|
memberId?: boolean
|
|
430
|
+
timezone?: boolean
|
|
405
431
|
autoFollowSessions?: boolean
|
|
406
432
|
reminderHourLocal?: boolean
|
|
407
433
|
autoFollowSince?: boolean
|
|
@@ -409,13 +435,14 @@ export type UserNotificationPrefsSelectScalar = {
|
|
|
409
435
|
updatedAt?: boolean
|
|
410
436
|
}
|
|
411
437
|
|
|
412
|
-
export type UserNotificationPrefsOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"memberId" | "autoFollowSessions" | "reminderHourLocal" | "autoFollowSince" | "createdAt" | "updatedAt", ExtArgs["result"]["userNotificationPrefs"]>
|
|
438
|
+
export type UserNotificationPrefsOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"memberId" | "timezone" | "autoFollowSessions" | "reminderHourLocal" | "autoFollowSince" | "createdAt" | "updatedAt", ExtArgs["result"]["userNotificationPrefs"]>
|
|
413
439
|
|
|
414
440
|
export type $UserNotificationPrefsPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
415
441
|
name: "UserNotificationPrefs"
|
|
416
442
|
objects: {}
|
|
417
443
|
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
|
418
444
|
memberId: string
|
|
445
|
+
timezone: string | null
|
|
419
446
|
autoFollowSessions: boolean
|
|
420
447
|
reminderHourLocal: number
|
|
421
448
|
autoFollowSince: Date | null
|
|
@@ -845,6 +872,7 @@ export interface Prisma__UserNotificationPrefsClient<T, Null = never, ExtArgs ex
|
|
|
845
872
|
*/
|
|
846
873
|
export interface UserNotificationPrefsFieldRefs {
|
|
847
874
|
readonly memberId: Prisma.FieldRef<"UserNotificationPrefs", 'String'>
|
|
875
|
+
readonly timezone: Prisma.FieldRef<"UserNotificationPrefs", 'String'>
|
|
848
876
|
readonly autoFollowSessions: Prisma.FieldRef<"UserNotificationPrefs", 'Boolean'>
|
|
849
877
|
readonly reminderHourLocal: Prisma.FieldRef<"UserNotificationPrefs", 'Int'>
|
|
850
878
|
readonly autoFollowSince: Prisma.FieldRef<"UserNotificationPrefs", 'DateTime'>
|
package/prisma/migrations/20261201000000_rename_user_notification_prefs_to_user_prefs/migration.sql
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- Rename in place (no data copy) and add a nullable IANA timezone column.
|
|
2
|
+
ALTER TABLE "UserNotificationPrefs" RENAME TO "UserPrefs";
|
|
3
|
+
ALTER TABLE "UserPrefs" RENAME CONSTRAINT "UserNotificationPrefs_pkey" TO "UserPrefs_pkey";
|
|
4
|
+
ALTER TABLE "UserPrefs" ADD COLUMN "timezone" TEXT;
|
|
@@ -665,11 +665,14 @@ model ChatThreadWatch {
|
|
|
665
665
|
// has no native CHECK constraint support in this schema style.
|
|
666
666
|
model UserNotificationPrefs {
|
|
667
667
|
memberId String @id // AccountMember.id
|
|
668
|
+
timezone String? // IANA zone name, validated in UserPrefsService
|
|
668
669
|
autoFollowSessions Boolean @default(true)
|
|
669
670
|
reminderHourLocal Int @default(9)
|
|
670
671
|
autoFollowSince DateTime?
|
|
671
672
|
createdAt DateTime @default(now())
|
|
672
673
|
updatedAt DateTime @updatedAt
|
|
674
|
+
|
|
675
|
+
@@map("UserPrefs") // model rename to UserPrefs is deferred to ACM 4.1
|
|
673
676
|
}
|
|
674
677
|
|
|
675
678
|
|
package/src/admin-boot.ts
CHANGED
|
@@ -47,8 +47,8 @@ import { createAccountCreatedNotifier } from "./account-created-notifier.ts";
|
|
|
47
47
|
import { AccountInviteService } from "./account-invites.ts";
|
|
48
48
|
import { AccountLifecycle } from "./account-lifecycle.ts";
|
|
49
49
|
import { AccountMemberService } from "./account-members.ts";
|
|
50
|
-
import { ensureAccountMember } from "./ensure-account-member.ts";
|
|
51
50
|
import { AccountOnboardingService } from "./account-onboarding.ts";
|
|
51
|
+
import { AccountRepoLookupService } from "./account-repo-lookup.ts";
|
|
52
52
|
import { AccountTrialExpirySweeper } from "./account-trial-expiry-sweeper.ts";
|
|
53
53
|
import { AccountTrialWarningSweeper } from "./account-trial-warning-sweeper.ts";
|
|
54
54
|
import { AccountService } from "./accounts.ts";
|
|
@@ -98,13 +98,10 @@ import {
|
|
|
98
98
|
import { parseChatCredentialConfig } from "./chat-credential-config.ts";
|
|
99
99
|
import { HttpChatServiceProvisioningClient } from "./chat-service-provisioning-client.ts";
|
|
100
100
|
import { SystemClock } from "./clock.ts";
|
|
101
|
-
import {
|
|
102
|
-
PrismaInstallationAgents,
|
|
103
|
-
PrismaInstallationAudit,
|
|
104
|
-
} from "./installation-ports.ts";
|
|
105
101
|
import { CronRunNowService } from "./cron-run-now.ts";
|
|
106
102
|
import { parseCronRunNowConfig } from "./cron-run-now-config.ts";
|
|
107
103
|
import { isDevAuthAllowed } from "./dev-auth-guard.ts";
|
|
104
|
+
import { ensureAccountMember } from "./ensure-account-member.ts";
|
|
108
105
|
import { HttpGithubAppProvisioningClient } from "./github-app-provisioning-client.ts";
|
|
109
106
|
import {
|
|
110
107
|
createGithubAccessPreview,
|
|
@@ -124,10 +121,13 @@ import {
|
|
|
124
121
|
} from "./github-repo-refresher.ts";
|
|
125
122
|
import { HttpGoogleAuthClient } from "./google-auth-client.ts";
|
|
126
123
|
import { HttpChatClient } from "./http-chat-client.ts";
|
|
124
|
+
import {
|
|
125
|
+
PrismaInstallationAgents,
|
|
126
|
+
PrismaInstallationAudit,
|
|
127
|
+
} from "./installation-ports.ts";
|
|
127
128
|
import { HttpOktaAuthClient } from "./okta-auth-client.ts";
|
|
128
129
|
import { mountPlatformApis } from "./platform-routes.ts";
|
|
129
130
|
import { parsePodServiceAccountConfig } from "./pod-service-account-config.ts";
|
|
130
|
-
import { AccountRepoLookupService } from "./account-repo-lookup.ts";
|
|
131
131
|
import { PrincipalLookupService } from "./principal-lookup.ts";
|
|
132
132
|
import { createAdminPrismaClient } from "./prisma-client.ts";
|
|
133
133
|
import { isPushEnabled } from "./push-sender.ts";
|
|
@@ -139,12 +139,14 @@ import { HttpSlackProvisioningClient } from "./slack-provisioning-client.ts";
|
|
|
139
139
|
import { SpecialtyTypes } from "./specialty-types.ts";
|
|
140
140
|
import { runStartupPolicyReconcile } from "./startup-policy-reconcile.ts";
|
|
141
141
|
import { runTemplateSeed } from "./template-seed.ts";
|
|
142
|
+
import { createTimezoneResolver } from "./timezone-resolver.ts";
|
|
142
143
|
import { makeStrictTokenCrypto, makeTokenCrypto } from "./token-crypto.ts";
|
|
143
144
|
import {
|
|
144
145
|
resolveTrialExpirySweepIntervalMs,
|
|
145
146
|
TrialExpirySweeper,
|
|
146
147
|
} from "./trial-expiry-sweeper.ts";
|
|
147
148
|
import { TrialExpiryWarningSweeper } from "./trial-expiry-warning-sweeper.ts";
|
|
149
|
+
import { UserPrefsService } from "./user-prefs.ts";
|
|
148
150
|
|
|
149
151
|
// startAdmin() is the process boot: it runs the real migration preflight,
|
|
150
152
|
// constructs a real PrismaClient (live DB connection), calls Bun.serve to bind
|
|
@@ -394,7 +396,13 @@ export async function startAdmin(
|
|
|
394
396
|
// may build on exists and before any route is mounted. With no extensions
|
|
395
397
|
// (or hookless ones) every contribution below is empty and the admin is the
|
|
396
398
|
// bare platform.
|
|
399
|
+
const resolveTimezone = createTimezoneResolver({
|
|
400
|
+
userPrefs: new UserPrefsService(prisma),
|
|
401
|
+
members: new AccountMemberService(prisma),
|
|
402
|
+
deployment: process.env.SHIPWRIGHT_ADMIN_TZ,
|
|
403
|
+
});
|
|
397
404
|
const extensionContext: AdminExtensionContext = {
|
|
405
|
+
resolveTimezone,
|
|
398
406
|
env: process.env,
|
|
399
407
|
prisma,
|
|
400
408
|
sessionSecret,
|
|
@@ -737,6 +745,7 @@ export async function startAdmin(
|
|
|
737
745
|
lifecycle: accountLifecycle,
|
|
738
746
|
},
|
|
739
747
|
timezone: adminTz,
|
|
748
|
+
userPrefs: new UserPrefsService(prisma),
|
|
740
749
|
...(chatClient ? { chatClient } : {}),
|
|
741
750
|
...(pushService
|
|
742
751
|
? {
|
package/src/admin-extension.ts
CHANGED
|
@@ -113,6 +113,15 @@ export interface AdminExtensionContext {
|
|
|
113
113
|
appBaseUrl: string;
|
|
114
114
|
/** SHIPWRIGHT_ADMIN_TZ, when set: the admin UI's display timezone. */
|
|
115
115
|
timezone?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Per-request display timezone: the signed-in user's saved setting, then
|
|
118
|
+
* the browser `tz` cookie, then the deployment default. Prefer this over
|
|
119
|
+
* the boot-time `timezone` when rendering a page for a request.
|
|
120
|
+
*/
|
|
121
|
+
resolveTimezone?: (input: {
|
|
122
|
+
email?: string | undefined;
|
|
123
|
+
cookie?: string | undefined;
|
|
124
|
+
}) => Promise<string>;
|
|
116
125
|
/** Web Push, present only when VAPID is fully configured. */
|
|
117
126
|
push?: { service: PushService; maxDetail: string; vapidPublicKey: string };
|
|
118
127
|
/** Sentry, present only when SENTRY_DSN is set (as the admin API gets it). */
|
|
@@ -157,7 +166,7 @@ export interface AgentDetailCardContext {
|
|
|
157
166
|
isAdmin: boolean;
|
|
158
167
|
/** The agent's owning account; null for unassigned agents. */
|
|
159
168
|
accountId?: string | null;
|
|
160
|
-
/** The
|
|
169
|
+
/** The display timezone (IANA name), resolved for this request. */
|
|
161
170
|
timezone?: string;
|
|
162
171
|
}
|
|
163
172
|
|
package/src/admin-ui-layout.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { themeBootScript } from "@app-vitals/agent-lib/web/toolbar.ts";
|
|
18
18
|
import { baseStyles, escapeHtml } from "./admin-ui-styles.ts";
|
|
19
|
+
import { tzCookieScript } from "./timezone-resolver.ts";
|
|
19
20
|
|
|
20
21
|
interface RenderAdminPageOptions {
|
|
21
22
|
/** Raw, unescaped page title — HTML-escaped internally before rendering. */
|
|
@@ -54,6 +55,7 @@ export function renderAdminPage(opts: RenderAdminPageOptions): string {
|
|
|
54
55
|
<title>${escapeHtml(opts.title)}</title>
|
|
55
56
|
<meta name="color-scheme" content="light dark" />
|
|
56
57
|
${themeBootScript()}
|
|
58
|
+
${tzCookieScript()}
|
|
57
59
|
<style>${baseStyles()}${opts.extraStyles ?? ""}</style>${opts.headExtra ? `\n ${opts.headExtra}` : ""}
|
|
58
60
|
</head>
|
|
59
61
|
${bodyTag}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/admin-ui-preferences-pages.ts
|
|
3
|
+
* Render function for Settings > Preferences (per-user display timezone).
|
|
4
|
+
* Pure string -> string; routes live in admin-ui-preferences.ts.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { renderAdminPage } from "./admin-ui-layout.ts";
|
|
8
|
+
import {
|
|
9
|
+
SETTINGS_PREFERENCES_PATH as BASE,
|
|
10
|
+
buildSettingsNav,
|
|
11
|
+
renderSettingsLayout,
|
|
12
|
+
type SettingsNav,
|
|
13
|
+
} from "./admin-ui-settings-layout.ts";
|
|
14
|
+
import { escapeHtml } from "./admin-ui-styles.ts";
|
|
15
|
+
|
|
16
|
+
export interface PreferencesPageOpts {
|
|
17
|
+
userEmail: string;
|
|
18
|
+
isAdmin?: boolean;
|
|
19
|
+
isOwner?: boolean;
|
|
20
|
+
nav?: SettingsNav;
|
|
21
|
+
/** Saved zone, or null when the browser timezone is used. */
|
|
22
|
+
savedTimezone: string | null;
|
|
23
|
+
/** The zone in effect for this request. */
|
|
24
|
+
effectiveTimezone: string;
|
|
25
|
+
/** Whether the viewer has a member profile to save onto. */
|
|
26
|
+
canSave: boolean;
|
|
27
|
+
/** IANA zone names for the picker. */
|
|
28
|
+
zones: readonly string[];
|
|
29
|
+
error?: string;
|
|
30
|
+
notice?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The IANA zones the runtime knows, always including UTC. */
|
|
34
|
+
export function supportedTimezones(): string[] {
|
|
35
|
+
const zones = Intl.supportedValuesOf("timeZone");
|
|
36
|
+
return zones.includes("UTC") ? zones : ["UTC", ...zones];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function renderPreferencesPage(o: PreferencesPageOpts): string {
|
|
40
|
+
const error = o.error
|
|
41
|
+
? `<div class="alert alert-error">${escapeHtml(o.error)}</div>`
|
|
42
|
+
: "";
|
|
43
|
+
const notice = o.notice
|
|
44
|
+
? `<div class="alert alert-success">${escapeHtml(o.notice)}</div>`
|
|
45
|
+
: "";
|
|
46
|
+
const options = [
|
|
47
|
+
`<option value=""${o.savedTimezone === null ? " selected" : ""}>Use browser timezone</option>`,
|
|
48
|
+
...o.zones.map(
|
|
49
|
+
(z) =>
|
|
50
|
+
`<option value="${escapeHtml(z)}"${z === o.savedTimezone ? " selected" : ""}>${escapeHtml(z)}</option>`,
|
|
51
|
+
),
|
|
52
|
+
].join("");
|
|
53
|
+
const form = o.canSave
|
|
54
|
+
? `<form method="POST" action="${BASE}/save" style="display:flex;gap:8px;align-items:end;flex-wrap:wrap">
|
|
55
|
+
<label>Timezone <select name="timezone" class="form-input">${options}</select></label>
|
|
56
|
+
<button type="submit" class="btn btn-primary">Save</button>
|
|
57
|
+
</form>
|
|
58
|
+
<form method="POST" action="${BASE}/clear" style="margin-top:8px">
|
|
59
|
+
<button type="submit" class="btn btn-secondary">Use browser timezone</button>
|
|
60
|
+
</form>`
|
|
61
|
+
: `<p class="help-text">Your sign-in has no member profile, so a timezone cannot be saved. The browser timezone is used.</p>`;
|
|
62
|
+
return renderAdminPage({
|
|
63
|
+
title: "Preferences — Settings — Shipwright Admin",
|
|
64
|
+
body: renderSettingsLayout({
|
|
65
|
+
userName: o.userEmail,
|
|
66
|
+
title: "Preferences",
|
|
67
|
+
nav: o.nav ?? buildSettingsNav({ preferences: true }),
|
|
68
|
+
active: BASE,
|
|
69
|
+
isAdmin: o.isAdmin ?? false,
|
|
70
|
+
isOwner: o.isOwner ?? false,
|
|
71
|
+
body: `${error}${notice}
|
|
72
|
+
<div class="card">
|
|
73
|
+
<div class="card-title">Display timezone</div>
|
|
74
|
+
<p class="help-text">Dates and times in the admin UI use this timezone. Leave it unset to follow your browser. Currently showing: ${escapeHtml(o.effectiveTimezone)}.</p>
|
|
75
|
+
${form}
|
|
76
|
+
</div>`,
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/admin-ui-preferences.smoke.test.ts
|
|
3
|
+
* Settings > Preferences: per-user timezone save/clear, and the per-request
|
|
4
|
+
* resolution chain (user setting, tz cookie, deployment default) through the
|
|
5
|
+
* full admin UI app.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, expect, it } from "bun:test";
|
|
9
|
+
import { makeMockDeps, makeSessionCookie } from "./admin-ui.fixtures.ts";
|
|
10
|
+
import { createAdminUIApp } from "./admin-ui.ts";
|
|
11
|
+
import { InvalidTimezoneError, isValidIanaTimezone } from "./user-prefs.ts";
|
|
12
|
+
|
|
13
|
+
const EMAIL = "m@acme.com";
|
|
14
|
+
|
|
15
|
+
function setup(opts: { deployment?: string; member?: boolean } = {}) {
|
|
16
|
+
const store = new Map<string, string | null>();
|
|
17
|
+
const userPrefs = {
|
|
18
|
+
getTimezone: async (id: string) => store.get(id) ?? null,
|
|
19
|
+
upsertByMemberId: async (
|
|
20
|
+
id: string,
|
|
21
|
+
patch: { timezone?: string | null },
|
|
22
|
+
) => {
|
|
23
|
+
if (patch.timezone != null && !isValidIanaTimezone(patch.timezone)) {
|
|
24
|
+
throw new InvalidTimezoneError(patch.timezone);
|
|
25
|
+
}
|
|
26
|
+
store.set(id, patch.timezone ?? null);
|
|
27
|
+
return null;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const accountServices = {
|
|
31
|
+
accounts: { getByMemberEmail: async () => ({ id: "a1", name: "Acme" }) },
|
|
32
|
+
members: {
|
|
33
|
+
getByEmail: async (e: string) =>
|
|
34
|
+
e === EMAIL && opts.member !== false
|
|
35
|
+
? { id: "mem-1", role: "member", accountId: "a1" }
|
|
36
|
+
: null,
|
|
37
|
+
},
|
|
38
|
+
} as never;
|
|
39
|
+
const app = createAdminUIApp(
|
|
40
|
+
makeMockDeps({
|
|
41
|
+
userPrefs,
|
|
42
|
+
accountServices,
|
|
43
|
+
...(opts.deployment ? { timezone: opts.deployment } : {}),
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
return { app, store };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const session = async () =>
|
|
50
|
+
`admin_session=${await makeSessionCookie(undefined, "u2", EMAIL, false)}`;
|
|
51
|
+
|
|
52
|
+
async function get(
|
|
53
|
+
app: ReturnType<typeof createAdminUIApp>,
|
|
54
|
+
path: string,
|
|
55
|
+
extraCookie = "",
|
|
56
|
+
) {
|
|
57
|
+
return app.request(path, {
|
|
58
|
+
headers: { cookie: `${await session()}${extraCookie}` },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function post(
|
|
63
|
+
app: ReturnType<typeof createAdminUIApp>,
|
|
64
|
+
path: string,
|
|
65
|
+
fields: Record<string, string>,
|
|
66
|
+
) {
|
|
67
|
+
return app.request(path, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
body: new URLSearchParams(fields).toString(),
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
72
|
+
cookie: await session(),
|
|
73
|
+
},
|
|
74
|
+
redirect: "manual",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The mock agent was created at 2024-01-01T00:00Z.
|
|
79
|
+
const LA_DATE = "12/31/2023";
|
|
80
|
+
const TOKYO_DATE = "1/1/2024";
|
|
81
|
+
|
|
82
|
+
describe("Settings > Preferences", () => {
|
|
83
|
+
it("renders the picker with the browser option and a nav entry", async () => {
|
|
84
|
+
const { app } = setup();
|
|
85
|
+
const res = await get(app, "/admin/settings/preferences");
|
|
86
|
+
expect(res.status).toBe(200);
|
|
87
|
+
const body = await res.text();
|
|
88
|
+
expect(body).toContain("Use browser timezone");
|
|
89
|
+
expect(body).toContain('<option value="Asia/Tokyo"');
|
|
90
|
+
expect(body).toContain('href="/admin/settings/preferences"');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("saves, shows, and clears the user timezone", async () => {
|
|
94
|
+
const { app, store } = setup();
|
|
95
|
+
const saved = await post(app, "/admin/settings/preferences/save", {
|
|
96
|
+
timezone: "Asia/Tokyo",
|
|
97
|
+
});
|
|
98
|
+
expect(saved.status).toBe(302);
|
|
99
|
+
expect(store.get("mem-1")).toBe("Asia/Tokyo");
|
|
100
|
+
const page = await (await get(app, "/admin/settings/preferences")).text();
|
|
101
|
+
expect(page).toContain('<option value="Asia/Tokyo" selected>');
|
|
102
|
+
|
|
103
|
+
const cleared = await post(app, "/admin/settings/preferences/clear", {});
|
|
104
|
+
expect(cleared.status).toBe(302);
|
|
105
|
+
expect(store.get("mem-1")).toBeNull();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("treats an empty selection as clear", async () => {
|
|
109
|
+
const { app, store } = setup();
|
|
110
|
+
store.set("mem-1", "Asia/Tokyo");
|
|
111
|
+
await post(app, "/admin/settings/preferences/save", { timezone: "" });
|
|
112
|
+
expect(store.get("mem-1")).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("rejects an invalid timezone with 422 and saves nothing", async () => {
|
|
116
|
+
const { app, store } = setup();
|
|
117
|
+
const res = await post(app, "/admin/settings/preferences/save", {
|
|
118
|
+
timezone: "Not/AZone",
|
|
119
|
+
});
|
|
120
|
+
expect(res.status).toBe(422);
|
|
121
|
+
expect(store.has("mem-1")).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("403s a save from a viewer with no member profile", async () => {
|
|
125
|
+
const { app } = setup({ member: false });
|
|
126
|
+
const res = await post(app, "/admin/settings/preferences/save", {
|
|
127
|
+
timezone: "UTC",
|
|
128
|
+
});
|
|
129
|
+
expect(res.status).toBe(403);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("includes the browser cookie script on pages", async () => {
|
|
133
|
+
const { app } = setup();
|
|
134
|
+
const body = await (await get(app, "/admin/agents")).text();
|
|
135
|
+
expect(body).toContain("resolvedOptions().timeZone");
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("per-request timezone resolution", () => {
|
|
140
|
+
it("uses the deployment default with no setting and no cookie", async () => {
|
|
141
|
+
const { app } = setup({ deployment: "America/Los_Angeles" });
|
|
142
|
+
expect(await (await get(app, "/admin/agents")).text()).toContain(LA_DATE);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("uses the browser cookie when nothing is saved", async () => {
|
|
146
|
+
const { app } = setup();
|
|
147
|
+
const body = await (
|
|
148
|
+
await get(app, "/admin/agents", "; tz=Asia%2FTokyo")
|
|
149
|
+
).text();
|
|
150
|
+
expect(body).toContain(TOKYO_DATE);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("ignores an invalid cookie", async () => {
|
|
154
|
+
const { app } = setup();
|
|
155
|
+
const res = await get(app, "/admin/agents", "; tz=Bogus%2FZone");
|
|
156
|
+
expect(res.status).toBe(200);
|
|
157
|
+
expect(await res.text()).toContain(LA_DATE);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("prefers the saved setting over the cookie", async () => {
|
|
161
|
+
const { app, store } = setup();
|
|
162
|
+
store.set("mem-1", "America/Los_Angeles");
|
|
163
|
+
const body = await (
|
|
164
|
+
await get(app, "/admin/agents", "; tz=Asia%2FTokyo")
|
|
165
|
+
).text();
|
|
166
|
+
expect(body).toContain(LA_DATE);
|
|
167
|
+
});
|
|
168
|
+
});
|