@goscribe/server 1.3.3 → 1.5.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/.env.example +12 -0
- package/.vscode/settings.json +3 -0
- package/REFACTOR_NOTES.md +60 -0
- package/TESTING_PROMPT.md +225 -0
- package/dist/controllers/admin.controller.d.ts +715 -0
- package/dist/controllers/admin.controller.js +9 -0
- package/dist/controllers/annotations.controller.d.ts +439 -0
- package/dist/controllers/annotations.controller.js +9 -0
- package/dist/controllers/app-router.controller.d.ts +3011 -0
- package/dist/controllers/app-router.controller.js +38 -0
- package/dist/controllers/app-router.controller.test.d.ts +1 -0
- package/dist/controllers/app-router.controller.test.js +36 -0
- package/dist/controllers/auth.controller.d.ts +323 -0
- package/dist/controllers/auth.controller.js +9 -0
- package/dist/controllers/base.controller.d.ts +4 -0
- package/dist/controllers/base.controller.js +5 -0
- package/dist/controllers/chat.controller.d.ts +341 -0
- package/dist/controllers/chat.controller.js +9 -0
- package/dist/controllers/copilot.controller.d.ts +397 -0
- package/dist/controllers/copilot.controller.js +9 -0
- package/dist/controllers/flashcards.controller.d.ts +651 -0
- package/dist/controllers/flashcards.controller.js +9 -0
- package/dist/controllers/members.controller.d.ts +339 -0
- package/dist/controllers/members.controller.js +9 -0
- package/dist/controllers/notifications.controller.d.ts +199 -0
- package/dist/controllers/notifications.controller.js +9 -0
- package/dist/controllers/payment.controller.d.ts +181 -0
- package/dist/controllers/payment.controller.js +9 -0
- package/dist/controllers/podcast.controller.d.ts +575 -0
- package/dist/controllers/podcast.controller.js +9 -0
- package/dist/controllers/router-module.controller.d.ts +5 -0
- package/dist/controllers/router-module.controller.js +6 -0
- package/dist/controllers/studyguide.controller.d.ts +73 -0
- package/dist/controllers/studyguide.controller.js +9 -0
- package/dist/controllers/worksheets.controller.d.ts +829 -0
- package/dist/controllers/worksheets.controller.js +9 -0
- package/dist/controllers/workspace.controller.d.ts +1207 -0
- package/dist/controllers/workspace.controller.js +9 -0
- package/dist/lib/activity_human_description.test.js +16 -15
- package/dist/lib/activity_log_service.test.js +28 -23
- package/dist/lib/ai/config.d.ts +20 -0
- package/dist/lib/ai/config.js +31 -0
- package/dist/lib/ai/embedding-client.d.ts +8 -0
- package/dist/lib/ai/embedding-client.js +30 -0
- package/dist/lib/ai/index.d.ts +47 -0
- package/dist/lib/ai/index.js +28 -0
- package/dist/lib/ai/inference-backend/client.d.ts +28 -0
- package/dist/lib/ai/inference-backend/client.js +301 -0
- package/dist/lib/ai/inference-backend/mocks.d.ts +12 -0
- package/dist/lib/ai/inference-backend/mocks.js +133 -0
- package/dist/lib/ai/inference-backend/types.d.ts +44 -0
- package/dist/lib/ai/inference-backend/types.js +1 -0
- package/dist/lib/ai/json-parse.d.ts +2 -0
- package/dist/lib/ai/json-parse.js +34 -0
- package/dist/lib/ai/llm-client.d.ts +6 -0
- package/dist/lib/ai/llm-client.js +19 -0
- package/dist/lib/ai/mock.d.ts +2 -0
- package/dist/lib/ai/mock.js +10 -0
- package/dist/lib/ai/types.d.ts +9 -0
- package/dist/lib/ai/types.js +1 -0
- package/dist/lib/chunking.d.ts +19 -0
- package/dist/lib/chunking.js +47 -0
- package/dist/lib/curated-kb-seed.d.ts +12 -0
- package/dist/lib/curated-kb-seed.js +155 -0
- package/dist/lib/email.js +67 -108
- package/dist/lib/embeddings.d.ts +2 -0
- package/dist/lib/embeddings.js +1 -0
- package/dist/lib/ensure-curated-kb-catalog.d.ts +6 -0
- package/dist/lib/ensure-curated-kb-catalog.js +53 -0
- package/dist/lib/env.d.ts +1 -5
- package/dist/lib/env.js +2 -7
- package/dist/lib/inference.d.ts +1 -8
- package/dist/lib/inference.js +1 -19
- package/dist/lib/kb-meta.d.ts +8 -0
- package/dist/lib/kb-meta.js +77 -0
- package/dist/lib/note-text.d.ts +1 -0
- package/dist/lib/note-text.js +47 -0
- package/dist/lib/notification-service.test.js +37 -36
- package/dist/lib/pdf.d.ts +11 -0
- package/dist/lib/pdf.js +11 -0
- package/dist/lib/usage_service.d.ts +2 -1
- package/dist/lib/usage_service.js +30 -12
- package/dist/lib/worksheet-generation.js +4 -4
- package/dist/lib/worksheet-generation.test.js +32 -17
- package/dist/lib/workspace-kb.d.ts +5 -0
- package/dist/lib/workspace-kb.js +7 -0
- package/dist/models/controller-context.model.d.ts +8 -0
- package/dist/models/controller-context.model.js +1 -0
- package/dist/repositories/artifact.repository.d.ts +60 -0
- package/dist/repositories/artifact.repository.js +40 -0
- package/dist/repositories/base.repository.d.ts +14 -0
- package/dist/repositories/base.repository.js +14 -0
- package/dist/repositories/invitation.repository.d.ts +94 -0
- package/dist/repositories/invitation.repository.js +44 -0
- package/dist/repositories/notification.repository.d.ts +72 -0
- package/dist/repositories/notification.repository.js +44 -0
- package/dist/repositories/router-module.repository.d.ts +10 -0
- package/dist/repositories/router-module.repository.js +14 -0
- package/dist/repositories/user.repository.d.ts +74 -0
- package/dist/repositories/user.repository.js +37 -0
- package/dist/repositories/workspace-member.repository.d.ts +31 -0
- package/dist/repositories/workspace-member.repository.js +31 -0
- package/dist/repositories/workspace.repository.d.ts +97 -0
- package/dist/repositories/workspace.repository.js +79 -0
- package/dist/routers/_app.d.ts +528 -33
- package/dist/routers/_app.js +4 -0
- package/dist/routers/admin.d.ts +0 -4
- package/dist/routers/admin.js +21 -549
- package/dist/routers/annotations.js +12 -170
- package/dist/routers/artifactVersions.d.ts +65 -0
- package/dist/routers/artifactVersions.js +14 -0
- package/dist/routers/auth.d.ts +0 -6
- package/dist/routers/auth.js +36 -421
- package/dist/routers/chat.js +15 -229
- package/dist/routers/copilot.d.ts +14 -13
- package/dist/routers/copilot.js +13 -532
- package/dist/routers/flashcards.d.ts +5 -5
- package/dist/routers/flashcards.js +23 -349
- package/dist/routers/knowledgeBase.d.ts +421 -0
- package/dist/routers/knowledgeBase.js +118 -0
- package/dist/routers/members.d.ts +0 -41
- package/dist/routers/members.js +22 -710
- package/dist/routers/notes.d.ts +94 -0
- package/dist/routers/notes.js +37 -0
- package/dist/routers/notifications.js +7 -109
- package/dist/routers/payment.d.ts +3 -2
- package/dist/routers/payment.js +11 -393
- package/dist/routers/podcast.d.ts +1 -1
- package/dist/routers/podcast.js +11 -784
- package/dist/routers/studyguide.js +3 -129
- package/dist/routers/worksheets.d.ts +29 -14
- package/dist/routers/worksheets.js +49 -628
- package/dist/routers/workspace.d.ts +0 -4
- package/dist/routers/workspace.js +28 -922
- package/dist/scripts/purge-deleted-users.js +2 -2
- package/dist/server.js +10 -3
- package/dist/services/activity/activity-human-description.service.d.ts +13 -0
- package/dist/services/activity/activity-human-description.service.js +221 -0
- package/dist/services/activity/activity-human-description.service.test.d.ts +1 -0
- package/dist/services/activity/activity-human-description.service.test.js +16 -0
- package/dist/services/activity/activity-log.service.d.ts +87 -0
- package/dist/services/activity/activity-log.service.js +276 -0
- package/dist/services/activity/activity-log.service.test.d.ts +1 -0
- package/dist/services/activity/activity-log.service.test.js +27 -0
- package/dist/services/activity-human-description.service.d.ts +13 -0
- package/dist/services/activity-human-description.service.js +221 -0
- package/dist/services/activity-human-description.service.test.d.ts +1 -0
- package/dist/services/activity-human-description.service.test.js +16 -0
- package/dist/services/activity-log.service.d.ts +87 -0
- package/dist/services/activity-log.service.js +276 -0
- package/dist/services/activity-log.service.test.d.ts +1 -0
- package/dist/services/activity-log.service.test.js +27 -0
- package/dist/services/admin/admin.service.d.ts +270 -0
- package/dist/services/admin/admin.service.js +476 -0
- package/dist/services/admin.service.d.ts +270 -0
- package/dist/services/admin.service.js +476 -0
- package/dist/services/ai/ai-session.service.d.ts +5 -0
- package/dist/services/ai/ai-session.service.js +4 -0
- package/dist/services/ai-session.service.d.ts +60 -0
- package/dist/services/ai-session.service.js +561 -0
- package/dist/services/annotation.service.d.ts +177 -0
- package/dist/services/annotation.service.js +154 -0
- package/dist/services/artifact-notification.service.d.ts +14 -0
- package/dist/services/artifact-notification.service.js +20 -0
- package/dist/services/artifact-version.service.d.ts +38 -0
- package/dist/services/artifact-version.service.js +129 -0
- package/dist/services/artifacts/annotation.service.d.ts +177 -0
- package/dist/services/artifacts/annotation.service.js +154 -0
- package/dist/services/artifacts/artifact-version.service.d.ts +38 -0
- package/dist/services/artifacts/artifact-version.service.js +129 -0
- package/dist/services/artifacts/chat.service.d.ts +127 -0
- package/dist/services/artifacts/chat.service.js +182 -0
- package/dist/services/artifacts/study-guide.service.d.ts +18 -0
- package/dist/services/artifacts/study-guide.service.js +65 -0
- package/dist/services/auth/auth.service.d.ts +94 -0
- package/dist/services/auth/auth.service.js +368 -0
- package/dist/services/auth.service.d.ts +94 -0
- package/dist/services/auth.service.js +368 -0
- package/dist/services/base.service.d.ts +14 -0
- package/dist/services/base.service.js +14 -0
- package/dist/services/billing/payment.service.d.ts +55 -0
- package/dist/services/billing/payment.service.js +368 -0
- package/dist/services/billing/subscription.service.d.ts +37 -0
- package/dist/services/billing/subscription.service.js +654 -0
- package/dist/services/billing/usage.service.d.ts +27 -0
- package/dist/services/billing/usage.service.js +77 -0
- package/dist/services/chat.service.d.ts +127 -0
- package/dist/services/chat.service.js +182 -0
- package/dist/services/content/copilot.service.d.ts +113 -0
- package/dist/services/content/copilot.service.js +453 -0
- package/dist/services/content/flashcard-progress.service.d.ts +159 -0
- package/dist/services/content/flashcard-progress.service.js +432 -0
- package/dist/services/content/flashcard.service.d.ts +140 -0
- package/dist/services/content/flashcard.service.js +326 -0
- package/dist/services/content/media-analysis.service.d.ts +23 -0
- package/dist/services/content/media-analysis.service.js +404 -0
- package/dist/services/content/podcast.service.d.ts +267 -0
- package/dist/services/content/podcast.service.js +653 -0
- package/dist/services/content/worksheet-content.service.d.ts +37 -0
- package/dist/services/content/worksheet-content.service.js +84 -0
- package/dist/services/content/worksheet-content.service.test.d.ts +1 -0
- package/dist/services/content/worksheet-content.service.test.js +69 -0
- package/dist/services/content/worksheet-generation.service.d.ts +91 -0
- package/dist/services/content/worksheet-generation.service.js +95 -0
- package/dist/services/content/worksheet-generation.service.test.d.ts +1 -0
- package/dist/services/content/worksheet-generation.service.test.js +20 -0
- package/dist/services/content/worksheet.service.d.ts +347 -0
- package/dist/services/content/worksheet.service.js +599 -0
- package/dist/services/copilot.service.d.ts +116 -0
- package/dist/services/copilot.service.js +447 -0
- package/dist/services/flashcard-progress.service.d.ts +2 -2
- package/dist/services/flashcard-progress.service.js +3 -2
- package/dist/services/flashcard.service.d.ts +140 -0
- package/dist/services/flashcard.service.js +325 -0
- package/dist/services/invitation.service.d.ts +66 -0
- package/dist/services/invitation.service.js +348 -0
- package/dist/services/knowledge/knowledge-base.service.d.ts +316 -0
- package/dist/services/knowledge/knowledge-base.service.js +544 -0
- package/dist/services/knowledge-base.service.d.ts +316 -0
- package/dist/services/knowledge-base.service.js +536 -0
- package/dist/services/media-analysis.service.d.ts +23 -0
- package/dist/services/media-analysis.service.js +384 -0
- package/dist/services/member.service.d.ts +36 -0
- package/dist/services/member.service.js +193 -0
- package/dist/services/members/invitation.service.d.ts +66 -0
- package/dist/services/members/invitation.service.js +348 -0
- package/dist/services/members/member.service.d.ts +36 -0
- package/dist/services/members/member.service.js +193 -0
- package/dist/services/note.service.d.ts +55 -0
- package/dist/services/note.service.js +111 -0
- package/dist/services/notification.service.d.ts +214 -0
- package/dist/services/notification.service.js +550 -0
- package/dist/services/notification.service.test.d.ts +1 -0
- package/dist/services/notification.service.test.js +87 -0
- package/dist/services/notifications/notification.service.d.ts +214 -0
- package/dist/services/notifications/notification.service.js +550 -0
- package/dist/services/notifications/notification.service.test.d.ts +1 -0
- package/dist/services/notifications/notification.service.test.js +87 -0
- package/dist/services/payment.service.d.ts +55 -0
- package/dist/services/payment.service.js +368 -0
- package/dist/services/podcast.service.d.ts +267 -0
- package/dist/services/podcast.service.js +654 -0
- package/dist/services/router-module.service.d.ts +7 -0
- package/dist/services/router-module.service.js +10 -0
- package/dist/services/study-guide.service.d.ts +18 -0
- package/dist/services/study-guide.service.js +65 -0
- package/dist/services/subscription.service.d.ts +37 -0
- package/dist/services/subscription.service.js +654 -0
- package/dist/services/usage-limit-policy.service.d.ts +12 -0
- package/dist/services/usage-limit-policy.service.js +22 -0
- package/dist/services/usage-limit-policy.service.test.d.ts +1 -0
- package/dist/services/usage-limit-policy.service.test.js +46 -0
- package/dist/services/usage.service.d.ts +27 -0
- package/dist/services/usage.service.js +77 -0
- package/dist/services/worksheet-content.service.d.ts +42 -0
- package/dist/services/worksheet-content.service.js +84 -0
- package/dist/services/worksheet-content.service.test.d.ts +1 -0
- package/dist/services/worksheet-content.service.test.js +69 -0
- package/dist/services/worksheet-generation.service.d.ts +91 -0
- package/dist/services/worksheet-generation.service.js +95 -0
- package/dist/services/worksheet-generation.service.test.d.ts +1 -0
- package/dist/services/worksheet-generation.service.test.js +20 -0
- package/dist/services/worksheet.service.d.ts +385 -0
- package/dist/services/worksheet.service.js +596 -0
- package/dist/services/workspace/workspace-analytics.service.d.ts +24 -0
- package/dist/services/workspace/workspace-analytics.service.js +95 -0
- package/dist/services/workspace/workspace-kb.service.d.ts +40 -0
- package/dist/services/workspace/workspace-kb.service.js +184 -0
- package/dist/services/workspace/workspace.service.d.ts +307 -0
- package/dist/services/workspace/workspace.service.js +394 -0
- package/dist/services/workspace-analytics.service.d.ts +24 -0
- package/dist/services/workspace-analytics.service.js +95 -0
- package/dist/services/workspace-kb.service.d.ts +40 -0
- package/dist/services/workspace-kb.service.js +184 -0
- package/dist/services/workspace-progress.service.d.ts +27 -0
- package/dist/services/workspace-progress.service.js +56 -0
- package/dist/services/workspace-progress.service.test.d.ts +1 -0
- package/dist/services/workspace-progress.service.test.js +49 -0
- package/dist/services/workspace.service.d.ts +307 -0
- package/dist/services/workspace.service.js +390 -0
- package/dist/trpc.js +2 -2
- package/package.json +5 -6
- package/prisma/migrations/20260509000001_add_knowledge_base/migration.sql +99 -0
- package/prisma/migrations/20260509000002_curate_knowledge_base/migration.sql +52 -0
- package/prisma/migrations/20260522000000_add_notes/migration.sql +27 -0
- package/prisma/migrations/20260524000000_remove_notes/migration.sql +3 -0
- package/prisma/schema.prisma +150 -48
- package/prisma/seed.mjs +67 -0
- package/scripts/debug/README.md +4 -0
- package/src/README.md +63 -0
- package/src/lib/ai/config.ts +34 -0
- package/src/lib/ai/embedding-client.ts +47 -0
- package/src/lib/ai/index.ts +62 -0
- package/src/lib/ai/inference-backend/client.ts +479 -0
- package/src/lib/ai/inference-backend/mocks.ts +171 -0
- package/src/lib/ai/inference-backend/types.ts +50 -0
- package/src/lib/ai/json-parse.ts +35 -0
- package/src/lib/ai/llm-client.ts +31 -0
- package/src/lib/ai/mock.ts +12 -0
- package/src/lib/ai/types.ts +11 -0
- package/src/lib/chunking.ts +81 -0
- package/src/lib/curated-kb-seed.ts +164 -0
- package/src/lib/email.ts +77 -115
- package/src/lib/embeddings.ts +9 -0
- package/src/lib/ensure-curated-kb-catalog.ts +60 -0
- package/src/lib/env.ts +2 -7
- package/src/lib/inference.ts +1 -21
- package/src/lib/kb-meta.ts +81 -0
- package/src/lib/pdf.ts +23 -0
- package/src/lib/workspace-kb.ts +7 -0
- package/src/repositories/artifact.repository.ts +55 -0
- package/src/repositories/base.repository.ts +19 -0
- package/src/repositories/invitation.repository.ts +53 -0
- package/src/repositories/notification.repository.ts +53 -0
- package/src/repositories/user.repository.ts +44 -0
- package/src/repositories/workspace-member.repository.ts +38 -0
- package/src/repositories/workspace.repository.ts +89 -0
- package/src/routers/_app.ts +4 -0
- package/src/routers/admin.ts +124 -692
- package/src/routers/annotations.ts +25 -203
- package/src/routers/artifactVersions.ts +32 -0
- package/src/routers/auth.ts +81 -519
- package/src/routers/chat.ts +42 -245
- package/src/routers/copilot.ts +41 -666
- package/src/routers/flashcards.ts +108 -404
- package/src/routers/knowledgeBase.ts +216 -0
- package/src/routers/members.ts +60 -782
- package/src/routers/notifications.ts +15 -117
- package/src/routers/payment.ts +37 -446
- package/src/routers/podcast.ts +36 -898
- package/src/routers/studyguide.ts +5 -144
- package/src/routers/worksheets.ts +171 -735
- package/src/routers/workspace.ts +138 -1109
- package/src/scripts/purge-deleted-users.ts +2 -2
- package/src/server.ts +10 -3
- package/src/{lib/activity_human_description.test.ts → services/activity/activity-human-description.service.test.ts} +1 -1
- package/src/{lib/activity_log_service.test.ts → services/activity/activity-log.service.test.ts} +1 -1
- package/src/{lib/activity_log_service.ts → services/activity/activity-log.service.ts} +2 -2
- package/src/services/admin/admin.service.ts +612 -0
- package/src/services/ai/ai-session.service.ts +5 -0
- package/src/services/artifacts/annotation.service.ts +189 -0
- package/src/services/artifacts/artifact-version.service.ts +151 -0
- package/src/services/artifacts/chat.service.ts +197 -0
- package/src/services/artifacts/study-guide.service.ts +72 -0
- package/src/services/auth/auth.service.ts +473 -0
- package/src/services/base.service.ts +19 -0
- package/src/services/billing/payment.service.ts +436 -0
- package/src/{lib/subscription_service.ts → services/billing/subscription.service.ts} +5 -5
- package/src/{lib/usage_service.ts → services/billing/usage.service.ts} +32 -12
- package/src/services/content/copilot.service.ts +596 -0
- package/src/services/{flashcard-progress.service.ts → content/flashcard-progress.service.ts} +6 -3
- package/src/services/content/flashcard.service.ts +394 -0
- package/src/services/content/media-analysis.service.ts +556 -0
- package/src/services/content/podcast.service.ts +777 -0
- package/src/services/content/worksheet-content.service.test.ts +83 -0
- package/src/services/content/worksheet-content.service.ts +117 -0
- package/src/{lib/worksheet-generation.test.ts → services/content/worksheet-generation.service.test.ts} +1 -1
- package/src/services/content/worksheet.service.ts +751 -0
- package/src/services/knowledge/knowledge-base.service.ts +705 -0
- package/src/services/members/invitation.service.ts +427 -0
- package/src/services/members/member.service.ts +241 -0
- package/src/{lib/notification-service.test.ts → services/notifications/notification.service.test.ts} +2 -2
- package/src/{lib/notification-service.ts → services/notifications/notification.service.ts} +102 -1
- package/src/services/workspace/workspace-analytics.service.ts +107 -0
- package/src/services/workspace/workspace-kb.service.ts +273 -0
- package/src/services/workspace/workspace.service.ts +481 -0
- package/src/trpc.ts +2 -2
- package/src/lib/ai-session.ts +0 -704
- package/src/lib/workspace-access.ts +0 -13
- /package/{check-difficulty.cjs → scripts/debug/check-difficulty.cjs} +0 -0
- /package/{check-questions.cjs → scripts/debug/check-questions.cjs} +0 -0
- /package/{db-summary.cjs → scripts/debug/db-summary.cjs} +0 -0
- /package/{mcq-test.cjs → scripts/debug/mcq-test.cjs} +0 -0
- /package/{test-generate.js → scripts/debug/test-generate.js} +0 -0
- /package/{test-ratio.cjs → scripts/debug/test-ratio.cjs} +0 -0
- /package/{zod-test.cjs → scripts/debug/zod-test.cjs} +0 -0
- /package/src/{lib/activity_human_description.ts → services/activity/activity-human-description.service.ts} +0 -0
- /package/src/{lib/worksheet-generation.ts → services/content/worksheet-generation.service.ts} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const notes: import("@trpc/server").TRPCBuiltRouter<{
|
|
2
|
+
ctx: import("../context.js").Context;
|
|
3
|
+
meta: object;
|
|
4
|
+
errorShape: {
|
|
5
|
+
data: {
|
|
6
|
+
zodError: string | null;
|
|
7
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
8
|
+
httpStatus: number;
|
|
9
|
+
path?: string;
|
|
10
|
+
stack?: string;
|
|
11
|
+
};
|
|
12
|
+
message: string;
|
|
13
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
14
|
+
};
|
|
15
|
+
transformer: true;
|
|
16
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
17
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
18
|
+
input: {
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
};
|
|
21
|
+
output: {
|
|
22
|
+
id: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
title: string;
|
|
26
|
+
emoji: string;
|
|
27
|
+
blocks: import("@prisma/client/runtime/library").JsonValue;
|
|
28
|
+
}[];
|
|
29
|
+
meta: object;
|
|
30
|
+
}>;
|
|
31
|
+
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
32
|
+
input: {
|
|
33
|
+
noteId: string;
|
|
34
|
+
};
|
|
35
|
+
output: {
|
|
36
|
+
id: string;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
39
|
+
workspaceId: string;
|
|
40
|
+
title: string;
|
|
41
|
+
userId: string;
|
|
42
|
+
emoji: string;
|
|
43
|
+
blocks: import("@prisma/client/runtime/library").JsonValue;
|
|
44
|
+
};
|
|
45
|
+
meta: object;
|
|
46
|
+
}>;
|
|
47
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
48
|
+
input: {
|
|
49
|
+
workspaceId: string;
|
|
50
|
+
title?: string | undefined;
|
|
51
|
+
emoji?: string | undefined;
|
|
52
|
+
blocks?: unknown[] | undefined;
|
|
53
|
+
};
|
|
54
|
+
output: {
|
|
55
|
+
id: string;
|
|
56
|
+
createdAt: Date;
|
|
57
|
+
updatedAt: Date;
|
|
58
|
+
workspaceId: string;
|
|
59
|
+
title: string;
|
|
60
|
+
userId: string;
|
|
61
|
+
emoji: string;
|
|
62
|
+
blocks: import("@prisma/client/runtime/library").JsonValue;
|
|
63
|
+
};
|
|
64
|
+
meta: object;
|
|
65
|
+
}>;
|
|
66
|
+
update: import("@trpc/server").TRPCMutationProcedure<{
|
|
67
|
+
input: {
|
|
68
|
+
noteId: string;
|
|
69
|
+
title?: string | undefined;
|
|
70
|
+
emoji?: string | undefined;
|
|
71
|
+
blocks?: unknown[] | undefined;
|
|
72
|
+
};
|
|
73
|
+
output: {
|
|
74
|
+
id: string;
|
|
75
|
+
createdAt: Date;
|
|
76
|
+
updatedAt: Date;
|
|
77
|
+
workspaceId: string;
|
|
78
|
+
title: string;
|
|
79
|
+
userId: string;
|
|
80
|
+
emoji: string;
|
|
81
|
+
blocks: import("@prisma/client/runtime/library").JsonValue;
|
|
82
|
+
};
|
|
83
|
+
meta: object;
|
|
84
|
+
}>;
|
|
85
|
+
delete: import("@trpc/server").TRPCMutationProcedure<{
|
|
86
|
+
input: {
|
|
87
|
+
noteId: string;
|
|
88
|
+
};
|
|
89
|
+
output: {
|
|
90
|
+
success: boolean;
|
|
91
|
+
};
|
|
92
|
+
meta: object;
|
|
93
|
+
}>;
|
|
94
|
+
}>>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { router, authedProcedure } from '../trpc.js';
|
|
3
|
+
import { NoteService } from '../services/note.service.js';
|
|
4
|
+
const noteBlockSchema = z.lazy(() => z.object({
|
|
5
|
+
id: z.string().optional(),
|
|
6
|
+
type: z.string(),
|
|
7
|
+
props: z.record(z.string(), z.unknown()).optional(),
|
|
8
|
+
content: z.unknown().optional(),
|
|
9
|
+
children: z.array(noteBlockSchema).optional(),
|
|
10
|
+
}));
|
|
11
|
+
export const notes = router({
|
|
12
|
+
list: authedProcedure
|
|
13
|
+
.input(z.object({ workspaceId: z.string() }))
|
|
14
|
+
.query(({ ctx, input }) => new NoteService(ctx.db).list(input.workspaceId, ctx.userId)),
|
|
15
|
+
get: authedProcedure
|
|
16
|
+
.input(z.object({ noteId: z.string() }))
|
|
17
|
+
.query(({ ctx, input }) => new NoteService(ctx.db).get(input.noteId, ctx.userId)),
|
|
18
|
+
create: authedProcedure
|
|
19
|
+
.input(z.object({
|
|
20
|
+
workspaceId: z.string(),
|
|
21
|
+
title: z.string().optional(),
|
|
22
|
+
emoji: z.string().optional(),
|
|
23
|
+
blocks: z.array(noteBlockSchema).optional(),
|
|
24
|
+
}))
|
|
25
|
+
.mutation(({ ctx, input }) => new NoteService(ctx.db).create(input.workspaceId, ctx.userId, input)),
|
|
26
|
+
update: authedProcedure
|
|
27
|
+
.input(z.object({
|
|
28
|
+
noteId: z.string(),
|
|
29
|
+
title: z.string().optional(),
|
|
30
|
+
emoji: z.string().optional(),
|
|
31
|
+
blocks: z.array(noteBlockSchema).optional(),
|
|
32
|
+
}))
|
|
33
|
+
.mutation(({ ctx, input }) => new NoteService(ctx.db).update(input.noteId, ctx.userId, input)),
|
|
34
|
+
delete: authedProcedure
|
|
35
|
+
.input(z.object({ noteId: z.string() }))
|
|
36
|
+
.mutation(({ ctx, input }) => new NoteService(ctx.db).delete(input.noteId, ctx.userId)),
|
|
37
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { authedProcedure, router } from '../trpc.js';
|
|
3
|
-
import
|
|
3
|
+
import { NotificationService } from '../services/notifications/notification.service.js';
|
|
4
4
|
const listInputSchema = z.object({
|
|
5
5
|
cursor: z.string().optional(),
|
|
6
6
|
limit: z.number().min(1).max(50).default(20),
|
|
@@ -10,118 +10,16 @@ const listInputSchema = z.object({
|
|
|
10
10
|
export const notifications = router({
|
|
11
11
|
list: authedProcedure
|
|
12
12
|
.input(listInputSchema)
|
|
13
|
-
.query(
|
|
14
|
-
|
|
15
|
-
const userId = ctx.userId;
|
|
16
|
-
const items = await ctx.db.notification.findMany({
|
|
17
|
-
where: {
|
|
18
|
-
userId,
|
|
19
|
-
...(unreadOnly ? { read: false } : {}),
|
|
20
|
-
...(types?.length ? { type: { in: types } } : {}),
|
|
21
|
-
},
|
|
22
|
-
include: {
|
|
23
|
-
actor: {
|
|
24
|
-
select: {
|
|
25
|
-
id: true,
|
|
26
|
-
name: true,
|
|
27
|
-
email: true,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
workspace: {
|
|
31
|
-
select: {
|
|
32
|
-
id: true,
|
|
33
|
-
title: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
orderBy: [{ createdAt: 'desc' }, { id: 'desc' }],
|
|
38
|
-
take: limit + 1,
|
|
39
|
-
...(cursor ? { cursor: { id: cursor }, skip: 1 } : {}),
|
|
40
|
-
});
|
|
41
|
-
let nextCursor;
|
|
42
|
-
if (items.length > limit) {
|
|
43
|
-
const next = items.pop();
|
|
44
|
-
nextCursor = next?.id;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
items,
|
|
48
|
-
nextCursor,
|
|
49
|
-
};
|
|
50
|
-
}),
|
|
51
|
-
unreadCount: authedProcedure.query(async ({ ctx }) => {
|
|
52
|
-
const count = await ctx.db.notification.count({
|
|
53
|
-
where: {
|
|
54
|
-
userId: ctx.userId,
|
|
55
|
-
read: false,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
return { count };
|
|
59
|
-
}),
|
|
13
|
+
.query(({ ctx, input }) => new NotificationService(ctx.db).list(ctx.userId, input)),
|
|
14
|
+
unreadCount: authedProcedure.query(({ ctx }) => new NotificationService(ctx.db).unreadCount(ctx.userId)),
|
|
60
15
|
markRead: authedProcedure
|
|
61
16
|
.input(z.object({ id: z.string() }))
|
|
62
|
-
.mutation(
|
|
63
|
-
const now = new Date();
|
|
64
|
-
await ctx.db.notification.updateMany({
|
|
65
|
-
where: {
|
|
66
|
-
id: input.id,
|
|
67
|
-
userId: ctx.userId,
|
|
68
|
-
},
|
|
69
|
-
data: {
|
|
70
|
-
read: true,
|
|
71
|
-
readAt: now,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
const unreadCount = await ctx.db.notification.count({
|
|
75
|
-
where: { userId: ctx.userId, read: false },
|
|
76
|
-
});
|
|
77
|
-
await PusherService.emitNotificationReadState(ctx.userId, { unreadCount });
|
|
78
|
-
return { success: true };
|
|
79
|
-
}),
|
|
17
|
+
.mutation(({ ctx, input }) => new NotificationService(ctx.db).markRead(ctx.userId, input.id)),
|
|
80
18
|
markManyRead: authedProcedure
|
|
81
19
|
.input(z.object({ ids: z.array(z.string()).min(1) }))
|
|
82
|
-
.mutation(
|
|
83
|
-
|
|
84
|
-
await ctx.db.notification.updateMany({
|
|
85
|
-
where: {
|
|
86
|
-
id: { in: input.ids },
|
|
87
|
-
userId: ctx.userId,
|
|
88
|
-
},
|
|
89
|
-
data: {
|
|
90
|
-
read: true,
|
|
91
|
-
readAt: now,
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
const unreadCount = await ctx.db.notification.count({
|
|
95
|
-
where: { userId: ctx.userId, read: false },
|
|
96
|
-
});
|
|
97
|
-
await PusherService.emitNotificationReadState(ctx.userId, { unreadCount });
|
|
98
|
-
return { success: true };
|
|
99
|
-
}),
|
|
100
|
-
markAllRead: authedProcedure
|
|
101
|
-
.mutation(async ({ ctx }) => {
|
|
102
|
-
const now = new Date();
|
|
103
|
-
await ctx.db.notification.updateMany({
|
|
104
|
-
where: {
|
|
105
|
-
userId: ctx.userId,
|
|
106
|
-
read: false,
|
|
107
|
-
},
|
|
108
|
-
data: {
|
|
109
|
-
read: true,
|
|
110
|
-
readAt: now,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
await PusherService.emitNotificationReadState(ctx.userId, { unreadCount: 0 });
|
|
114
|
-
return { success: true };
|
|
115
|
-
}),
|
|
20
|
+
.mutation(({ ctx, input }) => new NotificationService(ctx.db).markManyRead(ctx.userId, input.ids)),
|
|
21
|
+
markAllRead: authedProcedure.mutation(({ ctx }) => new NotificationService(ctx.db).markAllRead(ctx.userId)),
|
|
116
22
|
delete: authedProcedure
|
|
117
23
|
.input(z.object({ id: z.string() }))
|
|
118
|
-
.mutation(
|
|
119
|
-
await ctx.db.notification.deleteMany({
|
|
120
|
-
where: {
|
|
121
|
-
id: input.id,
|
|
122
|
-
userId: ctx.userId,
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
return { success: true };
|
|
126
|
-
}),
|
|
24
|
+
.mutation(({ ctx, input }) => new NotificationService(ctx.db).delete(ctx.userId, input.id)),
|
|
127
25
|
});
|
|
@@ -60,7 +60,7 @@ export declare const paymentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
60
60
|
getUsageOverview: import("@trpc/server").TRPCQueryProcedure<{
|
|
61
61
|
input: void;
|
|
62
62
|
output: {
|
|
63
|
-
usage: import("../
|
|
63
|
+
usage: import("../services/billing/usage.service.js").UserUsage;
|
|
64
64
|
limits: {
|
|
65
65
|
id: string;
|
|
66
66
|
planId: string;
|
|
@@ -71,7 +71,8 @@ export declare const paymentRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
71
71
|
maxStudyGuides: number;
|
|
72
72
|
createdAt: Date;
|
|
73
73
|
updatedAt: Date;
|
|
74
|
-
|
|
74
|
+
isFallbackPlan: boolean;
|
|
75
|
+
};
|
|
75
76
|
hasActivePlan: boolean;
|
|
76
77
|
};
|
|
77
78
|
meta: object;
|