@igstack/app-catalog-backend-core 1.0.1 → 2.0.0-alpha-20260914211846
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/generated/prisma/client.mjs.map +1 -1
- package/dist/generated/prisma/internal/class.d.mts +12 -0
- package/dist/generated/prisma/internal/class.d.mts.map +1 -1
- package/dist/generated/prisma/internal/class.mjs +4 -4
- package/dist/generated/prisma/internal/class.mjs.map +1 -1
- package/dist/generated/prisma/internal/prismaNamespace.d.mts +91 -3
- package/dist/generated/prisma/internal/prismaNamespace.d.mts.map +1 -1
- package/dist/generated/prisma/models/DbComment.d.mts +1234 -0
- package/dist/generated/prisma/models/DbComment.d.mts.map +1 -0
- package/dist/generated/prisma/models/DbResource.d.mts +229 -2
- package/dist/generated/prisma/models/DbResource.d.mts.map +1 -1
- package/dist/generated/prisma/models.d.mts +2 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/middleware/createAcMiddleware.d.mts.map +1 -1
- package/dist/middleware/createAcMiddleware.mjs +4 -2
- package/dist/middleware/createAcMiddleware.mjs.map +1 -1
- package/dist/middleware/featureRegistry.mjs +1 -7
- package/dist/middleware/featureRegistry.mjs.map +1 -1
- package/dist/modules/comments/commentsRouter.d.mts +47 -0
- package/dist/modules/comments/commentsRouter.d.mts.map +1 -0
- package/dist/modules/comments/commentsRouter.mjs +55 -0
- package/dist/modules/comments/commentsRouter.mjs.map +1 -0
- package/dist/modules/comments/service.d.mts +25 -0
- package/dist/modules/comments/service.d.mts.map +1 -0
- package/dist/modules/comments/service.mjs +86 -0
- package/dist/modules/comments/service.mjs.map +1 -0
- package/dist/modules/comments/visitorIdentity.d.mts +15 -0
- package/dist/modules/comments/visitorIdentity.d.mts.map +1 -0
- package/dist/modules/comments/visitorIdentity.mjs +121 -0
- package/dist/modules/comments/visitorIdentity.mjs.map +1 -0
- package/dist/server/acTrpcContext.d.mts +10 -1
- package/dist/server/acTrpcContext.d.mts.map +1 -1
- package/dist/server/acTrpcContext.mjs +3 -2
- package/dist/server/acTrpcContext.mjs.map +1 -1
- package/dist/server/controller.d.mts +40 -0
- package/dist/server/controller.d.mts.map +1 -1
- package/dist/server/controller.mjs +2 -0
- package/dist/server/controller.mjs.map +1 -1
- package/dist/utils/cookies.mjs +12 -0
- package/dist/utils/cookies.mjs.map +1 -0
- package/package.json +4 -4
- package/prisma/migrations/20260914000000_add_comments/migration.sql +22 -0
- package/prisma/schema.prisma +27 -0
- package/src/__tests__/comments.test.ts +73 -0
- package/src/generated/prisma/browser.ts +10 -0
- package/src/generated/prisma/client.ts +10 -0
- package/src/generated/prisma/internal/class.ts +14 -4
- package/src/generated/prisma/internal/prismaNamespace.ts +91 -1
- package/src/generated/prisma/internal/prismaNamespaceBrowser.ts +15 -0
- package/src/generated/prisma/models/DbComment.ts +1452 -0
- package/src/generated/prisma/models/DbResource.ts +238 -0
- package/src/generated/prisma/models.ts +1 -0
- package/src/index.ts +10 -0
- package/src/middleware/createAcMiddleware.ts +5 -0
- package/src/middleware/featureRegistry.ts +1 -11
- package/src/modules/comments/commentsRouter.ts +85 -0
- package/src/modules/comments/service.ts +154 -0
- package/src/modules/comments/visitorIdentity.ts +146 -0
- package/src/server/acTrpcContext.ts +10 -1
- package/src/server/controller.ts +3 -0
- package/src/utils/cookies.ts +10 -0
|
@@ -357,6 +357,7 @@ export type DbResourceWhereInput = {
|
|
|
357
357
|
createdAt?: Prisma.DateTimeFilter<"DbResource"> | Date | string
|
|
358
358
|
updatedAt?: Prisma.DateTimeFilter<"DbResource"> | Date | string
|
|
359
359
|
sourceRefs?: Prisma.SourceReferenceListRelationFilter
|
|
360
|
+
comments?: Prisma.DbCommentListRelationFilter
|
|
360
361
|
parent?: Prisma.XOR<Prisma.DbResourceNullableScalarRelationFilter, Prisma.DbResourceWhereInput> | null
|
|
361
362
|
children?: Prisma.DbResourceListRelationFilter
|
|
362
363
|
}
|
|
@@ -396,6 +397,7 @@ export type DbResourceOrderByWithRelationInput = {
|
|
|
396
397
|
createdAt?: Prisma.SortOrder
|
|
397
398
|
updatedAt?: Prisma.SortOrder
|
|
398
399
|
sourceRefs?: Prisma.SourceReferenceOrderByRelationAggregateInput
|
|
400
|
+
comments?: Prisma.DbCommentOrderByRelationAggregateInput
|
|
399
401
|
parent?: Prisma.DbResourceOrderByWithRelationInput
|
|
400
402
|
children?: Prisma.DbResourceOrderByRelationAggregateInput
|
|
401
403
|
}
|
|
@@ -438,6 +440,7 @@ export type DbResourceWhereUniqueInput = Prisma.AtLeast<{
|
|
|
438
440
|
createdAt?: Prisma.DateTimeFilter<"DbResource"> | Date | string
|
|
439
441
|
updatedAt?: Prisma.DateTimeFilter<"DbResource"> | Date | string
|
|
440
442
|
sourceRefs?: Prisma.SourceReferenceListRelationFilter
|
|
443
|
+
comments?: Prisma.DbCommentListRelationFilter
|
|
441
444
|
parent?: Prisma.XOR<Prisma.DbResourceNullableScalarRelationFilter, Prisma.DbResourceWhereInput> | null
|
|
442
445
|
children?: Prisma.DbResourceListRelationFilter
|
|
443
446
|
}, "id" | "slug">
|
|
@@ -554,6 +557,7 @@ export type DbResourceCreateInput = {
|
|
|
554
557
|
createdAt?: Date | string
|
|
555
558
|
updatedAt?: Date | string
|
|
556
559
|
sourceRefs?: Prisma.SourceReferenceCreateNestedManyWithoutResourceInput
|
|
560
|
+
comments?: Prisma.DbCommentCreateNestedManyWithoutResourceInput
|
|
557
561
|
parent?: Prisma.DbResourceCreateNestedOneWithoutChildrenInput
|
|
558
562
|
children?: Prisma.DbResourceCreateNestedManyWithoutParentInput
|
|
559
563
|
}
|
|
@@ -593,6 +597,7 @@ export type DbResourceUncheckedCreateInput = {
|
|
|
593
597
|
createdAt?: Date | string
|
|
594
598
|
updatedAt?: Date | string
|
|
595
599
|
sourceRefs?: Prisma.SourceReferenceUncheckedCreateNestedManyWithoutResourceInput
|
|
600
|
+
comments?: Prisma.DbCommentUncheckedCreateNestedManyWithoutResourceInput
|
|
596
601
|
children?: Prisma.DbResourceUncheckedCreateNestedManyWithoutParentInput
|
|
597
602
|
}
|
|
598
603
|
|
|
@@ -630,6 +635,7 @@ export type DbResourceUpdateInput = {
|
|
|
630
635
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
631
636
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
632
637
|
sourceRefs?: Prisma.SourceReferenceUpdateManyWithoutResourceNestedInput
|
|
638
|
+
comments?: Prisma.DbCommentUpdateManyWithoutResourceNestedInput
|
|
633
639
|
parent?: Prisma.DbResourceUpdateOneWithoutChildrenNestedInput
|
|
634
640
|
children?: Prisma.DbResourceUpdateManyWithoutParentNestedInput
|
|
635
641
|
}
|
|
@@ -669,6 +675,7 @@ export type DbResourceUncheckedUpdateInput = {
|
|
|
669
675
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
670
676
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
671
677
|
sourceRefs?: Prisma.SourceReferenceUncheckedUpdateManyWithoutResourceNestedInput
|
|
678
|
+
comments?: Prisma.DbCommentUncheckedUpdateManyWithoutResourceNestedInput
|
|
672
679
|
children?: Prisma.DbResourceUncheckedUpdateManyWithoutParentNestedInput
|
|
673
680
|
}
|
|
674
681
|
|
|
@@ -1002,6 +1009,20 @@ export type DbResourceUncheckedUpdateManyWithoutParentNestedInput = {
|
|
|
1002
1009
|
deleteMany?: Prisma.DbResourceScalarWhereInput | Prisma.DbResourceScalarWhereInput[]
|
|
1003
1010
|
}
|
|
1004
1011
|
|
|
1012
|
+
export type DbResourceCreateNestedOneWithoutCommentsInput = {
|
|
1013
|
+
create?: Prisma.XOR<Prisma.DbResourceCreateWithoutCommentsInput, Prisma.DbResourceUncheckedCreateWithoutCommentsInput>
|
|
1014
|
+
connectOrCreate?: Prisma.DbResourceCreateOrConnectWithoutCommentsInput
|
|
1015
|
+
connect?: Prisma.DbResourceWhereUniqueInput
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
export type DbResourceUpdateOneRequiredWithoutCommentsNestedInput = {
|
|
1019
|
+
create?: Prisma.XOR<Prisma.DbResourceCreateWithoutCommentsInput, Prisma.DbResourceUncheckedCreateWithoutCommentsInput>
|
|
1020
|
+
connectOrCreate?: Prisma.DbResourceCreateOrConnectWithoutCommentsInput
|
|
1021
|
+
upsert?: Prisma.DbResourceUpsertWithoutCommentsInput
|
|
1022
|
+
connect?: Prisma.DbResourceWhereUniqueInput
|
|
1023
|
+
update?: Prisma.XOR<Prisma.XOR<Prisma.DbResourceUpdateToOneWithWhereWithoutCommentsInput, Prisma.DbResourceUpdateWithoutCommentsInput>, Prisma.DbResourceUncheckedUpdateWithoutCommentsInput>
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1005
1026
|
export type DbResourceCreateNestedOneWithoutSourceRefsInput = {
|
|
1006
1027
|
create?: Prisma.XOR<Prisma.DbResourceCreateWithoutSourceRefsInput, Prisma.DbResourceUncheckedCreateWithoutSourceRefsInput>
|
|
1007
1028
|
connectOrCreate?: Prisma.DbResourceCreateOrConnectWithoutSourceRefsInput
|
|
@@ -1050,6 +1071,7 @@ export type DbResourceCreateWithoutChildrenInput = {
|
|
|
1050
1071
|
createdAt?: Date | string
|
|
1051
1072
|
updatedAt?: Date | string
|
|
1052
1073
|
sourceRefs?: Prisma.SourceReferenceCreateNestedManyWithoutResourceInput
|
|
1074
|
+
comments?: Prisma.DbCommentCreateNestedManyWithoutResourceInput
|
|
1053
1075
|
parent?: Prisma.DbResourceCreateNestedOneWithoutChildrenInput
|
|
1054
1076
|
}
|
|
1055
1077
|
|
|
@@ -1088,6 +1110,7 @@ export type DbResourceUncheckedCreateWithoutChildrenInput = {
|
|
|
1088
1110
|
createdAt?: Date | string
|
|
1089
1111
|
updatedAt?: Date | string
|
|
1090
1112
|
sourceRefs?: Prisma.SourceReferenceUncheckedCreateNestedManyWithoutResourceInput
|
|
1113
|
+
comments?: Prisma.DbCommentUncheckedCreateNestedManyWithoutResourceInput
|
|
1091
1114
|
}
|
|
1092
1115
|
|
|
1093
1116
|
export type DbResourceCreateOrConnectWithoutChildrenInput = {
|
|
@@ -1129,6 +1152,7 @@ export type DbResourceCreateWithoutParentInput = {
|
|
|
1129
1152
|
createdAt?: Date | string
|
|
1130
1153
|
updatedAt?: Date | string
|
|
1131
1154
|
sourceRefs?: Prisma.SourceReferenceCreateNestedManyWithoutResourceInput
|
|
1155
|
+
comments?: Prisma.DbCommentCreateNestedManyWithoutResourceInput
|
|
1132
1156
|
children?: Prisma.DbResourceCreateNestedManyWithoutParentInput
|
|
1133
1157
|
}
|
|
1134
1158
|
|
|
@@ -1166,6 +1190,7 @@ export type DbResourceUncheckedCreateWithoutParentInput = {
|
|
|
1166
1190
|
createdAt?: Date | string
|
|
1167
1191
|
updatedAt?: Date | string
|
|
1168
1192
|
sourceRefs?: Prisma.SourceReferenceUncheckedCreateNestedManyWithoutResourceInput
|
|
1193
|
+
comments?: Prisma.DbCommentUncheckedCreateNestedManyWithoutResourceInput
|
|
1169
1194
|
children?: Prisma.DbResourceUncheckedCreateNestedManyWithoutParentInput
|
|
1170
1195
|
}
|
|
1171
1196
|
|
|
@@ -1224,6 +1249,7 @@ export type DbResourceUpdateWithoutChildrenInput = {
|
|
|
1224
1249
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1225
1250
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1226
1251
|
sourceRefs?: Prisma.SourceReferenceUpdateManyWithoutResourceNestedInput
|
|
1252
|
+
comments?: Prisma.DbCommentUpdateManyWithoutResourceNestedInput
|
|
1227
1253
|
parent?: Prisma.DbResourceUpdateOneWithoutChildrenNestedInput
|
|
1228
1254
|
}
|
|
1229
1255
|
|
|
@@ -1262,6 +1288,7 @@ export type DbResourceUncheckedUpdateWithoutChildrenInput = {
|
|
|
1262
1288
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1263
1289
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1264
1290
|
sourceRefs?: Prisma.SourceReferenceUncheckedUpdateManyWithoutResourceNestedInput
|
|
1291
|
+
comments?: Prisma.DbCommentUncheckedUpdateManyWithoutResourceNestedInput
|
|
1265
1292
|
}
|
|
1266
1293
|
|
|
1267
1294
|
export type DbResourceUpsertWithWhereUniqueWithoutParentInput = {
|
|
@@ -1319,6 +1346,174 @@ export type DbResourceScalarWhereInput = {
|
|
|
1319
1346
|
updatedAt?: Prisma.DateTimeFilter<"DbResource"> | Date | string
|
|
1320
1347
|
}
|
|
1321
1348
|
|
|
1349
|
+
export type DbResourceCreateWithoutCommentsInput = {
|
|
1350
|
+
id?: string
|
|
1351
|
+
slug: string
|
|
1352
|
+
type?: string
|
|
1353
|
+
displayName: string
|
|
1354
|
+
abbreviation?: string | null
|
|
1355
|
+
nicknames?: Prisma.DbResourceCreatenicknamesInput | string[]
|
|
1356
|
+
description: string
|
|
1357
|
+
access?:PrismaJson.AccessMethod | Prisma.NullableJsonNullValueInput
|
|
1358
|
+
teams?: Prisma.DbResourceCreateteamsInput | string[]
|
|
1359
|
+
accessRequest?:PrismaJson.AccessRequest | Prisma.NullableJsonNullValueInput
|
|
1360
|
+
notes?: string | null
|
|
1361
|
+
tags?: Prisma.DbResourceCreatetagsInput | string[]
|
|
1362
|
+
appUrl?: string | null
|
|
1363
|
+
links?:PrismaJson.AppLink[] | Prisma.NullableJsonNullValueInput
|
|
1364
|
+
iconName?: string | null
|
|
1365
|
+
screenshotIds?: Prisma.DbResourceCreatescreenshotIdsInput | string[]
|
|
1366
|
+
deprecated?:PrismaJson.AppDeprecation | Prisma.NullableJsonNullValueInput
|
|
1367
|
+
aiPrompt?: string | null
|
|
1368
|
+
aiMemory?: string | null
|
|
1369
|
+
urlIssues?: Prisma.DbResourceCreateurlIssuesInput | string[]
|
|
1370
|
+
tiers?:PrismaJson.TierVariant[] | Prisma.NullableJsonNullValueInput
|
|
1371
|
+
tier?: string | null
|
|
1372
|
+
aliases?: Prisma.DbResourceCreatealiasesInput | string[]
|
|
1373
|
+
ownerPersonSlug?: string | null
|
|
1374
|
+
approverSlugs?: Prisma.DbResourceCreateapproverSlugsInput | string[]
|
|
1375
|
+
accessComments?: string | null
|
|
1376
|
+
extra?:PrismaJson.SubResourceExtra | Prisma.NullableJsonNullValueInput
|
|
1377
|
+
lastCheckedAt?: Date | string | null
|
|
1378
|
+
nextCheckAfter?: Date | string | null
|
|
1379
|
+
lastContentChangeAt?: Date | string | null
|
|
1380
|
+
createdAt?: Date | string
|
|
1381
|
+
updatedAt?: Date | string
|
|
1382
|
+
sourceRefs?: Prisma.SourceReferenceCreateNestedManyWithoutResourceInput
|
|
1383
|
+
parent?: Prisma.DbResourceCreateNestedOneWithoutChildrenInput
|
|
1384
|
+
children?: Prisma.DbResourceCreateNestedManyWithoutParentInput
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
export type DbResourceUncheckedCreateWithoutCommentsInput = {
|
|
1388
|
+
id?: string
|
|
1389
|
+
slug: string
|
|
1390
|
+
type?: string
|
|
1391
|
+
displayName: string
|
|
1392
|
+
abbreviation?: string | null
|
|
1393
|
+
nicknames?: Prisma.DbResourceCreatenicknamesInput | string[]
|
|
1394
|
+
description: string
|
|
1395
|
+
access?:PrismaJson.AccessMethod | Prisma.NullableJsonNullValueInput
|
|
1396
|
+
teams?: Prisma.DbResourceCreateteamsInput | string[]
|
|
1397
|
+
accessRequest?:PrismaJson.AccessRequest | Prisma.NullableJsonNullValueInput
|
|
1398
|
+
notes?: string | null
|
|
1399
|
+
tags?: Prisma.DbResourceCreatetagsInput | string[]
|
|
1400
|
+
appUrl?: string | null
|
|
1401
|
+
links?:PrismaJson.AppLink[] | Prisma.NullableJsonNullValueInput
|
|
1402
|
+
iconName?: string | null
|
|
1403
|
+
screenshotIds?: Prisma.DbResourceCreatescreenshotIdsInput | string[]
|
|
1404
|
+
deprecated?:PrismaJson.AppDeprecation | Prisma.NullableJsonNullValueInput
|
|
1405
|
+
aiPrompt?: string | null
|
|
1406
|
+
aiMemory?: string | null
|
|
1407
|
+
urlIssues?: Prisma.DbResourceCreateurlIssuesInput | string[]
|
|
1408
|
+
tiers?:PrismaJson.TierVariant[] | Prisma.NullableJsonNullValueInput
|
|
1409
|
+
parentSlug?: string | null
|
|
1410
|
+
tier?: string | null
|
|
1411
|
+
aliases?: Prisma.DbResourceCreatealiasesInput | string[]
|
|
1412
|
+
ownerPersonSlug?: string | null
|
|
1413
|
+
approverSlugs?: Prisma.DbResourceCreateapproverSlugsInput | string[]
|
|
1414
|
+
accessComments?: string | null
|
|
1415
|
+
extra?:PrismaJson.SubResourceExtra | Prisma.NullableJsonNullValueInput
|
|
1416
|
+
lastCheckedAt?: Date | string | null
|
|
1417
|
+
nextCheckAfter?: Date | string | null
|
|
1418
|
+
lastContentChangeAt?: Date | string | null
|
|
1419
|
+
createdAt?: Date | string
|
|
1420
|
+
updatedAt?: Date | string
|
|
1421
|
+
sourceRefs?: Prisma.SourceReferenceUncheckedCreateNestedManyWithoutResourceInput
|
|
1422
|
+
children?: Prisma.DbResourceUncheckedCreateNestedManyWithoutParentInput
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
export type DbResourceCreateOrConnectWithoutCommentsInput = {
|
|
1426
|
+
where: Prisma.DbResourceWhereUniqueInput
|
|
1427
|
+
create: Prisma.XOR<Prisma.DbResourceCreateWithoutCommentsInput, Prisma.DbResourceUncheckedCreateWithoutCommentsInput>
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
export type DbResourceUpsertWithoutCommentsInput = {
|
|
1431
|
+
update: Prisma.XOR<Prisma.DbResourceUpdateWithoutCommentsInput, Prisma.DbResourceUncheckedUpdateWithoutCommentsInput>
|
|
1432
|
+
create: Prisma.XOR<Prisma.DbResourceCreateWithoutCommentsInput, Prisma.DbResourceUncheckedCreateWithoutCommentsInput>
|
|
1433
|
+
where?: Prisma.DbResourceWhereInput
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
export type DbResourceUpdateToOneWithWhereWithoutCommentsInput = {
|
|
1437
|
+
where?: Prisma.DbResourceWhereInput
|
|
1438
|
+
data: Prisma.XOR<Prisma.DbResourceUpdateWithoutCommentsInput, Prisma.DbResourceUncheckedUpdateWithoutCommentsInput>
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
export type DbResourceUpdateWithoutCommentsInput = {
|
|
1442
|
+
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1443
|
+
slug?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1444
|
+
type?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1445
|
+
displayName?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1446
|
+
abbreviation?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1447
|
+
nicknames?: Prisma.DbResourceUpdatenicknamesInput | string[]
|
|
1448
|
+
description?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1449
|
+
access?:PrismaJson.AccessMethod | Prisma.NullableJsonNullValueInput
|
|
1450
|
+
teams?: Prisma.DbResourceUpdateteamsInput | string[]
|
|
1451
|
+
accessRequest?:PrismaJson.AccessRequest | Prisma.NullableJsonNullValueInput
|
|
1452
|
+
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1453
|
+
tags?: Prisma.DbResourceUpdatetagsInput | string[]
|
|
1454
|
+
appUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1455
|
+
links?:PrismaJson.AppLink[] | Prisma.NullableJsonNullValueInput
|
|
1456
|
+
iconName?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1457
|
+
screenshotIds?: Prisma.DbResourceUpdatescreenshotIdsInput | string[]
|
|
1458
|
+
deprecated?:PrismaJson.AppDeprecation | Prisma.NullableJsonNullValueInput
|
|
1459
|
+
aiPrompt?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1460
|
+
aiMemory?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1461
|
+
urlIssues?: Prisma.DbResourceUpdateurlIssuesInput | string[]
|
|
1462
|
+
tiers?:PrismaJson.TierVariant[] | Prisma.NullableJsonNullValueInput
|
|
1463
|
+
tier?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1464
|
+
aliases?: Prisma.DbResourceUpdatealiasesInput | string[]
|
|
1465
|
+
ownerPersonSlug?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1466
|
+
approverSlugs?: Prisma.DbResourceUpdateapproverSlugsInput | string[]
|
|
1467
|
+
accessComments?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1468
|
+
extra?:PrismaJson.SubResourceExtra | Prisma.NullableJsonNullValueInput
|
|
1469
|
+
lastCheckedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1470
|
+
nextCheckAfter?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1471
|
+
lastContentChangeAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1472
|
+
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1473
|
+
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1474
|
+
sourceRefs?: Prisma.SourceReferenceUpdateManyWithoutResourceNestedInput
|
|
1475
|
+
parent?: Prisma.DbResourceUpdateOneWithoutChildrenNestedInput
|
|
1476
|
+
children?: Prisma.DbResourceUpdateManyWithoutParentNestedInput
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
export type DbResourceUncheckedUpdateWithoutCommentsInput = {
|
|
1480
|
+
id?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1481
|
+
slug?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1482
|
+
type?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1483
|
+
displayName?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1484
|
+
abbreviation?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1485
|
+
nicknames?: Prisma.DbResourceUpdatenicknamesInput | string[]
|
|
1486
|
+
description?: Prisma.StringFieldUpdateOperationsInput | string
|
|
1487
|
+
access?:PrismaJson.AccessMethod | Prisma.NullableJsonNullValueInput
|
|
1488
|
+
teams?: Prisma.DbResourceUpdateteamsInput | string[]
|
|
1489
|
+
accessRequest?:PrismaJson.AccessRequest | Prisma.NullableJsonNullValueInput
|
|
1490
|
+
notes?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1491
|
+
tags?: Prisma.DbResourceUpdatetagsInput | string[]
|
|
1492
|
+
appUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1493
|
+
links?:PrismaJson.AppLink[] | Prisma.NullableJsonNullValueInput
|
|
1494
|
+
iconName?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1495
|
+
screenshotIds?: Prisma.DbResourceUpdatescreenshotIdsInput | string[]
|
|
1496
|
+
deprecated?:PrismaJson.AppDeprecation | Prisma.NullableJsonNullValueInput
|
|
1497
|
+
aiPrompt?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1498
|
+
aiMemory?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1499
|
+
urlIssues?: Prisma.DbResourceUpdateurlIssuesInput | string[]
|
|
1500
|
+
tiers?:PrismaJson.TierVariant[] | Prisma.NullableJsonNullValueInput
|
|
1501
|
+
parentSlug?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1502
|
+
tier?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1503
|
+
aliases?: Prisma.DbResourceUpdatealiasesInput | string[]
|
|
1504
|
+
ownerPersonSlug?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1505
|
+
approverSlugs?: Prisma.DbResourceUpdateapproverSlugsInput | string[]
|
|
1506
|
+
accessComments?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
|
1507
|
+
extra?:PrismaJson.SubResourceExtra | Prisma.NullableJsonNullValueInput
|
|
1508
|
+
lastCheckedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1509
|
+
nextCheckAfter?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1510
|
+
lastContentChangeAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1511
|
+
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1512
|
+
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1513
|
+
sourceRefs?: Prisma.SourceReferenceUncheckedUpdateManyWithoutResourceNestedInput
|
|
1514
|
+
children?: Prisma.DbResourceUncheckedUpdateManyWithoutParentNestedInput
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1322
1517
|
export type DbResourceCreateWithoutSourceRefsInput = {
|
|
1323
1518
|
id?: string
|
|
1324
1519
|
slug: string
|
|
@@ -1352,6 +1547,7 @@ export type DbResourceCreateWithoutSourceRefsInput = {
|
|
|
1352
1547
|
lastContentChangeAt?: Date | string | null
|
|
1353
1548
|
createdAt?: Date | string
|
|
1354
1549
|
updatedAt?: Date | string
|
|
1550
|
+
comments?: Prisma.DbCommentCreateNestedManyWithoutResourceInput
|
|
1355
1551
|
parent?: Prisma.DbResourceCreateNestedOneWithoutChildrenInput
|
|
1356
1552
|
children?: Prisma.DbResourceCreateNestedManyWithoutParentInput
|
|
1357
1553
|
}
|
|
@@ -1390,6 +1586,7 @@ export type DbResourceUncheckedCreateWithoutSourceRefsInput = {
|
|
|
1390
1586
|
lastContentChangeAt?: Date | string | null
|
|
1391
1587
|
createdAt?: Date | string
|
|
1392
1588
|
updatedAt?: Date | string
|
|
1589
|
+
comments?: Prisma.DbCommentUncheckedCreateNestedManyWithoutResourceInput
|
|
1393
1590
|
children?: Prisma.DbResourceUncheckedCreateNestedManyWithoutParentInput
|
|
1394
1591
|
}
|
|
1395
1592
|
|
|
@@ -1442,6 +1639,7 @@ export type DbResourceUpdateWithoutSourceRefsInput = {
|
|
|
1442
1639
|
lastContentChangeAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1443
1640
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1444
1641
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1642
|
+
comments?: Prisma.DbCommentUpdateManyWithoutResourceNestedInput
|
|
1445
1643
|
parent?: Prisma.DbResourceUpdateOneWithoutChildrenNestedInput
|
|
1446
1644
|
children?: Prisma.DbResourceUpdateManyWithoutParentNestedInput
|
|
1447
1645
|
}
|
|
@@ -1480,6 +1678,7 @@ export type DbResourceUncheckedUpdateWithoutSourceRefsInput = {
|
|
|
1480
1678
|
lastContentChangeAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
|
1481
1679
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1482
1680
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1681
|
+
comments?: Prisma.DbCommentUncheckedUpdateManyWithoutResourceNestedInput
|
|
1483
1682
|
children?: Prisma.DbResourceUncheckedUpdateManyWithoutParentNestedInput
|
|
1484
1683
|
}
|
|
1485
1684
|
|
|
@@ -1552,6 +1751,7 @@ export type DbResourceUpdateWithoutParentInput = {
|
|
|
1552
1751
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1553
1752
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1554
1753
|
sourceRefs?: Prisma.SourceReferenceUpdateManyWithoutResourceNestedInput
|
|
1754
|
+
comments?: Prisma.DbCommentUpdateManyWithoutResourceNestedInput
|
|
1555
1755
|
children?: Prisma.DbResourceUpdateManyWithoutParentNestedInput
|
|
1556
1756
|
}
|
|
1557
1757
|
|
|
@@ -1589,6 +1789,7 @@ export type DbResourceUncheckedUpdateWithoutParentInput = {
|
|
|
1589
1789
|
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1590
1790
|
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
|
1591
1791
|
sourceRefs?: Prisma.SourceReferenceUncheckedUpdateManyWithoutResourceNestedInput
|
|
1792
|
+
comments?: Prisma.DbCommentUncheckedUpdateManyWithoutResourceNestedInput
|
|
1592
1793
|
children?: Prisma.DbResourceUncheckedUpdateManyWithoutParentNestedInput
|
|
1593
1794
|
}
|
|
1594
1795
|
|
|
@@ -1634,11 +1835,13 @@ export type DbResourceUncheckedUpdateManyWithoutParentInput = {
|
|
|
1634
1835
|
|
|
1635
1836
|
export type DbResourceCountOutputType = {
|
|
1636
1837
|
sourceRefs: number
|
|
1838
|
+
comments: number
|
|
1637
1839
|
children: number
|
|
1638
1840
|
}
|
|
1639
1841
|
|
|
1640
1842
|
export type DbResourceCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
1641
1843
|
sourceRefs?: boolean | DbResourceCountOutputTypeCountSourceRefsArgs
|
|
1844
|
+
comments?: boolean | DbResourceCountOutputTypeCountCommentsArgs
|
|
1642
1845
|
children?: boolean | DbResourceCountOutputTypeCountChildrenArgs
|
|
1643
1846
|
}
|
|
1644
1847
|
|
|
@@ -1659,6 +1862,13 @@ export type DbResourceCountOutputTypeCountSourceRefsArgs<ExtArgs extends runtime
|
|
|
1659
1862
|
where?: Prisma.SourceReferenceWhereInput
|
|
1660
1863
|
}
|
|
1661
1864
|
|
|
1865
|
+
/**
|
|
1866
|
+
* DbResourceCountOutputType without action
|
|
1867
|
+
*/
|
|
1868
|
+
export type DbResourceCountOutputTypeCountCommentsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
1869
|
+
where?: Prisma.DbCommentWhereInput
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1662
1872
|
/**
|
|
1663
1873
|
* DbResourceCountOutputType without action
|
|
1664
1874
|
*/
|
|
@@ -1702,6 +1912,7 @@ export type DbResourceSelect<ExtArgs extends runtime.Types.Extensions.InternalAr
|
|
|
1702
1912
|
createdAt?: boolean
|
|
1703
1913
|
updatedAt?: boolean
|
|
1704
1914
|
sourceRefs?: boolean | Prisma.DbResource$sourceRefsArgs<ExtArgs>
|
|
1915
|
+
comments?: boolean | Prisma.DbResource$commentsArgs<ExtArgs>
|
|
1705
1916
|
parent?: boolean | Prisma.DbResource$parentArgs<ExtArgs>
|
|
1706
1917
|
children?: boolean | Prisma.DbResource$childrenArgs<ExtArgs>
|
|
1707
1918
|
_count?: boolean | Prisma.DbResourceCountOutputTypeDefaultArgs<ExtArgs>
|
|
@@ -1820,6 +2031,7 @@ export type DbResourceSelectScalar = {
|
|
|
1820
2031
|
export type DbResourceOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "slug" | "type" | "displayName" | "abbreviation" | "nicknames" | "description" | "access" | "teams" | "accessRequest" | "notes" | "tags" | "appUrl" | "links" | "iconName" | "screenshotIds" | "deprecated" | "aiPrompt" | "aiMemory" | "urlIssues" | "tiers" | "parentSlug" | "tier" | "aliases" | "ownerPersonSlug" | "approverSlugs" | "accessComments" | "extra" | "lastCheckedAt" | "nextCheckAfter" | "lastContentChangeAt" | "createdAt" | "updatedAt", ExtArgs["result"]["dbResource"]>
|
|
1821
2032
|
export type DbResourceInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
1822
2033
|
sourceRefs?: boolean | Prisma.DbResource$sourceRefsArgs<ExtArgs>
|
|
2034
|
+
comments?: boolean | Prisma.DbResource$commentsArgs<ExtArgs>
|
|
1823
2035
|
parent?: boolean | Prisma.DbResource$parentArgs<ExtArgs>
|
|
1824
2036
|
children?: boolean | Prisma.DbResource$childrenArgs<ExtArgs>
|
|
1825
2037
|
_count?: boolean | Prisma.DbResourceCountOutputTypeDefaultArgs<ExtArgs>
|
|
@@ -1835,6 +2047,7 @@ export type $DbResourcePayload<ExtArgs extends runtime.Types.Extensions.Internal
|
|
|
1835
2047
|
name: "DbResource"
|
|
1836
2048
|
objects: {
|
|
1837
2049
|
sourceRefs: Prisma.$SourceReferencePayload<ExtArgs>[]
|
|
2050
|
+
comments: Prisma.$DbCommentPayload<ExtArgs>[]
|
|
1838
2051
|
parent: Prisma.$DbResourcePayload<ExtArgs> | null
|
|
1839
2052
|
children: Prisma.$DbResourcePayload<ExtArgs>[]
|
|
1840
2053
|
}
|
|
@@ -2285,6 +2498,7 @@ readonly fields: DbResourceFieldRefs;
|
|
|
2285
2498
|
export interface Prisma__DbResourceClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
|
|
2286
2499
|
readonly [Symbol.toStringTag]: "PrismaPromise"
|
|
2287
2500
|
sourceRefs<T extends Prisma.DbResource$sourceRefsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.DbResource$sourceRefsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SourceReferencePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
|
2501
|
+
comments<T extends Prisma.DbResource$commentsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.DbResource$commentsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$DbCommentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
|
2288
2502
|
parent<T extends Prisma.DbResource$parentArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.DbResource$parentArgs<ExtArgs>>): Prisma.Prisma__DbResourceClient<runtime.Types.Result.GetResult<Prisma.$DbResourcePayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
|
2289
2503
|
children<T extends Prisma.DbResource$childrenArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.DbResource$childrenArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$DbResourcePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
|
2290
2504
|
/**
|
|
@@ -2768,6 +2982,30 @@ export type DbResource$sourceRefsArgs<ExtArgs extends runtime.Types.Extensions.I
|
|
|
2768
2982
|
distinct?: Prisma.SourceReferenceScalarFieldEnum | Prisma.SourceReferenceScalarFieldEnum[]
|
|
2769
2983
|
}
|
|
2770
2984
|
|
|
2985
|
+
/**
|
|
2986
|
+
* DbResource.comments
|
|
2987
|
+
*/
|
|
2988
|
+
export type DbResource$commentsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
|
2989
|
+
/**
|
|
2990
|
+
* Select specific fields to fetch from the DbComment
|
|
2991
|
+
*/
|
|
2992
|
+
select?: Prisma.DbCommentSelect<ExtArgs> | null
|
|
2993
|
+
/**
|
|
2994
|
+
* Omit specific fields from the DbComment
|
|
2995
|
+
*/
|
|
2996
|
+
omit?: Prisma.DbCommentOmit<ExtArgs> | null
|
|
2997
|
+
/**
|
|
2998
|
+
* Choose, which related nodes to fetch as well
|
|
2999
|
+
*/
|
|
3000
|
+
include?: Prisma.DbCommentInclude<ExtArgs> | null
|
|
3001
|
+
where?: Prisma.DbCommentWhereInput
|
|
3002
|
+
orderBy?: Prisma.DbCommentOrderByWithRelationInput | Prisma.DbCommentOrderByWithRelationInput[]
|
|
3003
|
+
cursor?: Prisma.DbCommentWhereUniqueInput
|
|
3004
|
+
take?: number
|
|
3005
|
+
skip?: number
|
|
3006
|
+
distinct?: Prisma.DbCommentScalarFieldEnum | Prisma.DbCommentScalarFieldEnum[]
|
|
3007
|
+
}
|
|
3008
|
+
|
|
2771
3009
|
/**
|
|
2772
3010
|
* DbResource.parent
|
|
2773
3011
|
*/
|
|
@@ -17,6 +17,7 @@ export type * from './models/DbGroup'
|
|
|
17
17
|
export type * from './models/DbGroupMembership'
|
|
18
18
|
export type * from './models/DbApprovalMethod'
|
|
19
19
|
export type * from './models/DbResource'
|
|
20
|
+
export type * from './models/DbComment'
|
|
20
21
|
export type * from './models/DbAppTagDefinition'
|
|
21
22
|
export type * from './models/DbAsset'
|
|
22
23
|
export type * from './models/Source'
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,16 @@ export { registerAuthRoutes } from './modules/auth/registerAuthRoutes'
|
|
|
26
26
|
|
|
27
27
|
export { createAuthRouter, type AuthRouter } from './modules/auth/authRouter'
|
|
28
28
|
|
|
29
|
+
// Comments
|
|
30
|
+
// CommentView is part of the router's inferred type, so it has to be nameable
|
|
31
|
+
// from outside the package or every consumer's `useTRPC` becomes unportable.
|
|
32
|
+
export { createCommentsRouter } from './modules/comments/commentsRouter'
|
|
33
|
+
export {
|
|
34
|
+
EDIT_WINDOW_MS,
|
|
35
|
+
MAX_BODY_LENGTH,
|
|
36
|
+
type CommentView,
|
|
37
|
+
} from './modules/comments/service'
|
|
38
|
+
|
|
29
39
|
// Icon management
|
|
30
40
|
export {
|
|
31
41
|
registerIconRestController,
|
|
@@ -12,6 +12,7 @@ import { createTrpcRouter } from '../server/controller'
|
|
|
12
12
|
import { createAcTrpcContext } from '../server/acTrpcContext'
|
|
13
13
|
import { createAuth } from '../modules/auth/auth'
|
|
14
14
|
import { createMockUserFromDevConfig } from '../modules/auth/devMockUserUtils'
|
|
15
|
+
import { resolveVisitor } from '../modules/comments/visitorIdentity'
|
|
15
16
|
|
|
16
17
|
export async function createAcMiddleware(
|
|
17
18
|
options: AcMiddlewareOptions,
|
|
@@ -39,6 +40,7 @@ export async function createAcMiddleware(
|
|
|
39
40
|
// Create tRPC context factory
|
|
40
41
|
const createContext = async ({
|
|
41
42
|
req,
|
|
43
|
+
res,
|
|
42
44
|
}: trpcExpress.CreateExpressContextOptions) => {
|
|
43
45
|
const companySpecificBackend = await resolveBackend()
|
|
44
46
|
|
|
@@ -79,6 +81,9 @@ export async function createAcMiddleware(
|
|
|
79
81
|
companySpecificBackend,
|
|
80
82
|
user,
|
|
81
83
|
isAdmin,
|
|
84
|
+
// Issued here, on every request, so the cookie already exists by the time
|
|
85
|
+
// someone writes a comment.
|
|
86
|
+
visitor: resolveVisitor(req, res),
|
|
82
87
|
})
|
|
83
88
|
}
|
|
84
89
|
|
|
@@ -9,17 +9,7 @@ import { registerIconRestController } from '../modules/icons/iconRestController'
|
|
|
9
9
|
import { registerAssetRestController } from '../modules/assets/assetRestController'
|
|
10
10
|
import { registerScreenshotRestController } from '../modules/assets/screenshotRestController'
|
|
11
11
|
import { createMockSessionResponse } from '../modules/auth/devMockUserUtils'
|
|
12
|
-
|
|
13
|
-
/** Parse a single cookie value from the Cookie header */
|
|
14
|
-
function getCookie(
|
|
15
|
-
req: { headers: { cookie?: string } },
|
|
16
|
-
name: string,
|
|
17
|
-
): string | undefined {
|
|
18
|
-
const cookies = req.headers.cookie ?? ''
|
|
19
|
-
if (!cookies) return undefined
|
|
20
|
-
const match = cookies.match(new RegExp(`(?:^|;\\s*)${name}=([^;]*)`))
|
|
21
|
-
return match?.[1] !== undefined ? decodeURIComponent(match[1]) : undefined
|
|
22
|
-
}
|
|
12
|
+
import { getCookie } from '../utils/cookies'
|
|
23
13
|
|
|
24
14
|
interface FeatureRegistration {
|
|
25
15
|
name: keyof AcFeatureToggles
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { TRPCError } from '@trpc/server'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { publicProcedure, router } from '../../server/trpcSetup'
|
|
4
|
+
import type { Visitor } from './visitorIdentity'
|
|
5
|
+
import {
|
|
6
|
+
CommentError,
|
|
7
|
+
MAX_BODY_LENGTH,
|
|
8
|
+
addComment,
|
|
9
|
+
deleteComment,
|
|
10
|
+
editComment,
|
|
11
|
+
listComments,
|
|
12
|
+
} from './service'
|
|
13
|
+
|
|
14
|
+
const bodyInput = z.string().min(1).max(MAX_BODY_LENGTH)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Writing needs a visitor token, and the token is issued on the request that reads
|
|
18
|
+
* the comment list — so by the time anyone can click Post, the cookie exists. A
|
|
19
|
+
* missing one here means cookies are blocked, which no error code describes well;
|
|
20
|
+
* PRECONDITION_FAILED at least separates it from a permission problem.
|
|
21
|
+
*/
|
|
22
|
+
function requireVisitor(visitor: Visitor | null): Visitor {
|
|
23
|
+
if (!visitor) {
|
|
24
|
+
throw new TRPCError({
|
|
25
|
+
code: 'PRECONDITION_FAILED',
|
|
26
|
+
message: 'Commenting needs cookies enabled',
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
return visitor
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const REASON_CODES = {
|
|
33
|
+
'not-found': 'NOT_FOUND',
|
|
34
|
+
'not-author': 'FORBIDDEN',
|
|
35
|
+
'window-closed': 'FORBIDDEN',
|
|
36
|
+
empty: 'BAD_REQUEST',
|
|
37
|
+
} as const
|
|
38
|
+
|
|
39
|
+
async function mapErrors<T>(work: () => Promise<T>): Promise<T> {
|
|
40
|
+
try {
|
|
41
|
+
return await work()
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof CommentError) {
|
|
44
|
+
throw new TRPCError({
|
|
45
|
+
code: REASON_CODES[error.reason],
|
|
46
|
+
message: error.message,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
throw error
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function createCommentsRouter() {
|
|
54
|
+
return router({
|
|
55
|
+
list: publicProcedure
|
|
56
|
+
.input(z.object({ resourceSlug: z.string() }))
|
|
57
|
+
.query(({ input, ctx }) => listComments(input.resourceSlug, ctx.visitor)),
|
|
58
|
+
|
|
59
|
+
add: publicProcedure
|
|
60
|
+
.input(z.object({ resourceSlug: z.string(), body: bodyInput }))
|
|
61
|
+
.mutation(({ input, ctx }) =>
|
|
62
|
+
mapErrors(() =>
|
|
63
|
+
addComment(
|
|
64
|
+
input.resourceSlug,
|
|
65
|
+
input.body,
|
|
66
|
+
requireVisitor(ctx.visitor),
|
|
67
|
+
),
|
|
68
|
+
),
|
|
69
|
+
),
|
|
70
|
+
|
|
71
|
+
edit: publicProcedure
|
|
72
|
+
.input(z.object({ id: z.string(), body: bodyInput }))
|
|
73
|
+
.mutation(({ input, ctx }) =>
|
|
74
|
+
mapErrors(() =>
|
|
75
|
+
editComment(input.id, input.body, requireVisitor(ctx.visitor)),
|
|
76
|
+
),
|
|
77
|
+
),
|
|
78
|
+
|
|
79
|
+
remove: publicProcedure
|
|
80
|
+
.input(z.object({ id: z.string() }))
|
|
81
|
+
.mutation(({ input, ctx }) =>
|
|
82
|
+
mapErrors(() => deleteComment(input.id, requireVisitor(ctx.visitor))),
|
|
83
|
+
),
|
|
84
|
+
})
|
|
85
|
+
}
|