@vestcards/server-types 1.4.0 → 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/dist/apps/server/src/app.d.ts +98 -6
- package/dist/apps/server/src/config/env.d.ts +2 -0
- package/dist/apps/server/src/middleware/logger.d.ts +2 -0
- package/dist/apps/server/src/middleware/logger.test.d.ts +1 -0
- package/dist/apps/server/src/modules/auth/index.d.ts +4 -4
- package/dist/apps/server/src/modules/auth/lib.d.ts +3 -0
- package/dist/apps/server/src/modules/auth/tracing.d.ts +18 -0
- package/dist/apps/server/src/modules/auth/tracing.test.d.ts +1 -0
- package/dist/apps/server/src/modules/card/index.d.ts +6 -6
- package/dist/apps/server/src/modules/deck/access.d.ts +5 -0
- package/dist/apps/server/src/modules/deck/index.d.ts +4 -4
- package/dist/apps/server/src/modules/exam/exam.test.d.ts +1 -0
- package/dist/apps/server/src/modules/exam/index.d.ts +457 -0
- package/dist/apps/server/src/modules/exam/model.d.ts +18 -0
- package/dist/apps/server/src/modules/exam/service.d.ts +43 -0
- package/dist/apps/server/src/modules/library/index.d.ts +4 -4
- package/dist/apps/server/src/modules/ranking/cache.d.ts +6 -0
- package/dist/apps/server/src/modules/ranking/helpers.d.ts +9 -0
- package/dist/apps/server/src/modules/ranking/index.d.ts +4 -4
- package/dist/apps/server/src/modules/ranking/repository.d.ts +10 -0
- package/dist/apps/server/src/modules/stats/index.d.ts +4 -4
- package/dist/apps/server/src/modules/stats/service.d.ts +2 -2
- package/dist/apps/server/src/modules/study/index.d.ts +4 -4
- package/dist/apps/server/src/modules/topic/index.d.ts +4 -4
- package/dist/apps/server/src/modules/user/index.d.ts +4 -4
- package/dist/apps/server/src/modules/vesty/index.d.ts +4 -4
- package/dist/apps/server/src/modules/vesty/resilience.d.ts +40 -0
- package/dist/apps/server/src/modules/vesty/resilience.test.d.ts +1 -0
- package/dist/apps/server/src/modules/vesty/utils.d.ts +12 -19
- package/dist/apps/server/src/tests/helpers/index.d.ts +1 -0
- package/dist/apps/server/src/tests/helpers/redis-mock.d.ts +33 -0
- package/dist/apps/server/src/tests/preload/redis-mock.d.ts +1 -0
- package/dist/packages/db-core/src/db.d.ts +1 -2
- package/dist/packages/db-core/src/index.d.ts +1 -0
- package/dist/packages/db-core/src/queries/decks.d.ts +2 -0
- package/dist/packages/db-core/src/queries/index.d.ts +1 -0
- package/dist/packages/db-core/src/schema/exams.d.ts +721 -0
- package/dist/packages/db-core/src/schema/index.d.ts +1 -0
- package/dist/packages/db-core/src/tracing.d.ts +2 -0
- package/dist/packages/shared/src/constants.d.ts +2 -0
- package/dist/packages/shared/src/index.d.ts +1 -0
- package/dist/packages/shared/src/spaced-repetition/session-manager.d.ts +3 -0
- package/dist/packages/shared/src/theme/tokens/colors.d.ts +18 -18
- package/dist/packages/shared/src/types/permissions.d.ts +4 -0
- package/dist/packages/utils/src/logger/config.d.ts +12 -0
- package/dist/packages/utils/src/logger/index.d.ts +4 -1
- package/dist/packages/utils/src/logger/pino.d.ts +7 -0
- package/dist/packages/utils/src/logger/posthog.d.ts +12 -16
- package/dist/packages/utils/src/logger/timeout.d.ts +4 -0
- package/dist/packages/utils/src/logger/tracing.d.ts +34 -0
- package/package.json +1 -1
- /package/dist/apps/server/src/{libs → lib}/mappers.d.ts +0 -0
|
@@ -24,7 +24,7 @@ export declare const statsModule: Elysia<"/v1/stats", {
|
|
|
24
24
|
}>;
|
|
25
25
|
macroFn: {
|
|
26
26
|
readonly auth: {
|
|
27
|
-
readonly resolve: ({ request: { headers } }: {
|
|
27
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
28
28
|
body: unknown;
|
|
29
29
|
query: Record<string, string>;
|
|
30
30
|
params: {};
|
|
@@ -42,7 +42,7 @@ export declare const statsModule: Elysia<"/v1/stats", {
|
|
|
42
42
|
route: string;
|
|
43
43
|
request: Request;
|
|
44
44
|
store: {};
|
|
45
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
45
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
46
46
|
readonly 100: "Continue";
|
|
47
47
|
readonly 101: "Switching Protocols";
|
|
48
48
|
readonly 102: "Processing";
|
|
@@ -198,7 +198,7 @@ export declare const statsModule: Elysia<"/v1/stats", {
|
|
|
198
198
|
};
|
|
199
199
|
} & {
|
|
200
200
|
readonly permission: (permission?: import("@vestcards/shared").Permission) => {
|
|
201
|
-
readonly resolve: ({ request: { headers } }: {
|
|
201
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
202
202
|
body: unknown;
|
|
203
203
|
query: Record<string, string>;
|
|
204
204
|
params: {};
|
|
@@ -216,7 +216,7 @@ export declare const statsModule: Elysia<"/v1/stats", {
|
|
|
216
216
|
route: string;
|
|
217
217
|
request: Request;
|
|
218
218
|
store: {};
|
|
219
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
219
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
220
220
|
readonly 100: "Continue";
|
|
221
221
|
readonly 101: "Switching Protocols";
|
|
222
222
|
readonly 102: "Processing";
|
|
@@ -3,8 +3,8 @@ import type { StatsModel } from './model';
|
|
|
3
3
|
export declare abstract class StatsService {
|
|
4
4
|
static getDashboard(userId: string): Promise<StatsModel.DashboardStats>;
|
|
5
5
|
static getHomePageStats(userId: string): Promise<StatsModel.HomePageStats>;
|
|
6
|
-
static getTimeSpentStudyingToday(userId: string): Promise<number>;
|
|
7
|
-
static getTotalCardsStudiedTodayGroupedBySubject(userId: string): Promise<{
|
|
6
|
+
static getTimeSpentStudyingToday(userId: string, timezone: string): Promise<number>;
|
|
7
|
+
static getTotalCardsStudiedTodayGroupedBySubject(userId: string, timezone: string): Promise<{
|
|
8
8
|
subject: "matemática" | "geografia" | "física" | "biologia" | "história" | "literatura" | "gramática" | "sociologia" | "química" | "filosofia" | "redação" | "artes" | "inglês";
|
|
9
9
|
count: number;
|
|
10
10
|
}[]>;
|
|
@@ -24,7 +24,7 @@ export declare const studyModule: Elysia<"/v1/study", {
|
|
|
24
24
|
}>;
|
|
25
25
|
macroFn: {
|
|
26
26
|
readonly auth: {
|
|
27
|
-
readonly resolve: ({ request: { headers } }: {
|
|
27
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
28
28
|
body: unknown;
|
|
29
29
|
query: Record<string, string>;
|
|
30
30
|
params: {};
|
|
@@ -42,7 +42,7 @@ export declare const studyModule: Elysia<"/v1/study", {
|
|
|
42
42
|
route: string;
|
|
43
43
|
request: Request;
|
|
44
44
|
store: {};
|
|
45
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
45
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
46
46
|
readonly 100: "Continue";
|
|
47
47
|
readonly 101: "Switching Protocols";
|
|
48
48
|
readonly 102: "Processing";
|
|
@@ -198,7 +198,7 @@ export declare const studyModule: Elysia<"/v1/study", {
|
|
|
198
198
|
};
|
|
199
199
|
} & {
|
|
200
200
|
readonly permission: (permission?: import("@vestcards/shared").Permission) => {
|
|
201
|
-
readonly resolve: ({ request: { headers } }: {
|
|
201
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
202
202
|
body: unknown;
|
|
203
203
|
query: Record<string, string>;
|
|
204
204
|
params: {};
|
|
@@ -216,7 +216,7 @@ export declare const studyModule: Elysia<"/v1/study", {
|
|
|
216
216
|
route: string;
|
|
217
217
|
request: Request;
|
|
218
218
|
store: {};
|
|
219
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
219
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
220
220
|
readonly 100: "Continue";
|
|
221
221
|
readonly 101: "Switching Protocols";
|
|
222
222
|
readonly 102: "Processing";
|
|
@@ -24,7 +24,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
|
|
|
24
24
|
}>;
|
|
25
25
|
macroFn: {
|
|
26
26
|
readonly auth: {
|
|
27
|
-
readonly resolve: ({ request: { headers } }: {
|
|
27
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
28
28
|
body: unknown;
|
|
29
29
|
query: Record<string, string>;
|
|
30
30
|
params: {};
|
|
@@ -42,7 +42,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
|
|
|
42
42
|
route: string;
|
|
43
43
|
request: Request;
|
|
44
44
|
store: {};
|
|
45
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
45
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
46
46
|
readonly 100: "Continue";
|
|
47
47
|
readonly 101: "Switching Protocols";
|
|
48
48
|
readonly 102: "Processing";
|
|
@@ -198,7 +198,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
|
|
|
198
198
|
};
|
|
199
199
|
} & {
|
|
200
200
|
readonly permission: (permission?: import("@vestcards/shared").Permission) => {
|
|
201
|
-
readonly resolve: ({ request: { headers } }: {
|
|
201
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
202
202
|
body: unknown;
|
|
203
203
|
query: Record<string, string>;
|
|
204
204
|
params: {};
|
|
@@ -216,7 +216,7 @@ export declare const topicModule: Elysia<"/v1/topics", {
|
|
|
216
216
|
route: string;
|
|
217
217
|
request: Request;
|
|
218
218
|
store: {};
|
|
219
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
219
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
220
220
|
readonly 100: "Continue";
|
|
221
221
|
readonly 101: "Switching Protocols";
|
|
222
222
|
readonly 102: "Processing";
|
|
@@ -24,7 +24,7 @@ export declare const userModule: Elysia<"/v1/user", {
|
|
|
24
24
|
}>;
|
|
25
25
|
macroFn: {
|
|
26
26
|
readonly auth: {
|
|
27
|
-
readonly resolve: ({ request: { headers } }: {
|
|
27
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
28
28
|
body: unknown;
|
|
29
29
|
query: Record<string, string>;
|
|
30
30
|
params: {};
|
|
@@ -42,7 +42,7 @@ export declare const userModule: Elysia<"/v1/user", {
|
|
|
42
42
|
route: string;
|
|
43
43
|
request: Request;
|
|
44
44
|
store: {};
|
|
45
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
45
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
46
46
|
readonly 100: "Continue";
|
|
47
47
|
readonly 101: "Switching Protocols";
|
|
48
48
|
readonly 102: "Processing";
|
|
@@ -198,7 +198,7 @@ export declare const userModule: Elysia<"/v1/user", {
|
|
|
198
198
|
};
|
|
199
199
|
} & {
|
|
200
200
|
readonly permission: (permission?: import("@vestcards/shared").Permission) => {
|
|
201
|
-
readonly resolve: ({ request: { headers } }: {
|
|
201
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
202
202
|
body: unknown;
|
|
203
203
|
query: Record<string, string>;
|
|
204
204
|
params: {};
|
|
@@ -216,7 +216,7 @@ export declare const userModule: Elysia<"/v1/user", {
|
|
|
216
216
|
route: string;
|
|
217
217
|
request: Request;
|
|
218
218
|
store: {};
|
|
219
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
219
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
220
220
|
readonly 100: "Continue";
|
|
221
221
|
readonly 101: "Switching Protocols";
|
|
222
222
|
readonly 102: "Processing";
|
|
@@ -25,7 +25,7 @@ export declare const vestyModule: Elysia<"/v1/vesty", {
|
|
|
25
25
|
}>;
|
|
26
26
|
macroFn: {
|
|
27
27
|
readonly auth: {
|
|
28
|
-
readonly resolve: ({ request: { headers } }: {
|
|
28
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
29
29
|
body: unknown;
|
|
30
30
|
query: Record<string, string>;
|
|
31
31
|
params: {};
|
|
@@ -43,7 +43,7 @@ export declare const vestyModule: Elysia<"/v1/vesty", {
|
|
|
43
43
|
route: string;
|
|
44
44
|
request: Request;
|
|
45
45
|
store: {};
|
|
46
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
46
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
47
47
|
readonly 100: "Continue";
|
|
48
48
|
readonly 101: "Switching Protocols";
|
|
49
49
|
readonly 102: "Processing";
|
|
@@ -199,7 +199,7 @@ export declare const vestyModule: Elysia<"/v1/vesty", {
|
|
|
199
199
|
};
|
|
200
200
|
} & {
|
|
201
201
|
readonly permission: (permission?: import("@vestcards/shared").Permission) => {
|
|
202
|
-
readonly resolve: ({ request: { headers } }: {
|
|
202
|
+
readonly resolve: ({ request: { headers }, store }: {
|
|
203
203
|
body: unknown;
|
|
204
204
|
query: Record<string, string>;
|
|
205
205
|
params: {};
|
|
@@ -217,7 +217,7 @@ export declare const vestyModule: Elysia<"/v1/vesty", {
|
|
|
217
217
|
route: string;
|
|
218
218
|
request: Request;
|
|
219
219
|
store: {};
|
|
220
|
-
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 404 | 409 | 429 |
|
|
220
|
+
status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 200 | 500 | 400 | 401 | 403 | 404 | 409 | 429 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 300 | 301 | 302 | 303 | 304 | 307 | 308 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
|
|
221
221
|
readonly 100: "Continue";
|
|
222
222
|
readonly 101: "Switching Protocols";
|
|
223
223
|
readonly 102: "Processing";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristically decides whether a Gemini provider error is transient and worth
|
|
3
|
+
* retrying (overload, rate limit, timeout) versus a permanent failure (bad
|
|
4
|
+
* request, schema mismatch) that a retry or different model won't fix.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isRetryableGeminiError(error: unknown): boolean;
|
|
7
|
+
type RetryConfig = {
|
|
8
|
+
attemptsPerModel: number;
|
|
9
|
+
baseDelayMs: number;
|
|
10
|
+
maxDelayMs: number;
|
|
11
|
+
};
|
|
12
|
+
export type FallbackOptions<TModel extends string = string> = Partial<RetryConfig> & {
|
|
13
|
+
/** Invoked before a backoff wait or a fallback to the next model. */
|
|
14
|
+
onRetry?: (info: {
|
|
15
|
+
model: TModel;
|
|
16
|
+
attempt: number;
|
|
17
|
+
error: unknown;
|
|
18
|
+
nextModel?: TModel;
|
|
19
|
+
}) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Runs `run` against each model in order. Retries the same model with backoff
|
|
23
|
+
* on transient errors, then falls back to the next model, and finally rethrows
|
|
24
|
+
* the last error if every model is exhausted. Non-retryable errors short-circuit
|
|
25
|
+
* immediately. Returns the result together with the model that produced it.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runWithModelFallback<TModel extends string, TResult>(models: readonly TModel[], run: (model: TModel) => Promise<TResult>, options?: FallbackOptions<TModel>): Promise<{
|
|
28
|
+
result: TResult;
|
|
29
|
+
model: TModel;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Streaming counterpart of {@link runWithModelFallback}. Wraps an
|
|
33
|
+
* `AsyncIterable` source and retries / falls back to the next model — but only
|
|
34
|
+
* while no chunk has been emitted yet, since a stream cannot be safely restarted
|
|
35
|
+
* once the client has started receiving content. A `503` overload surfaces at
|
|
36
|
+
* connection time (before the first chunk), which is exactly the case this
|
|
37
|
+
* covers.
|
|
38
|
+
*/
|
|
39
|
+
export declare function streamWithModelFallback<TModel extends string, TChunk>(models: readonly TModel[], createStream: (model: TModel) => AsyncIterable<TChunk>, options?: FallbackOptions<TModel>): AsyncIterable<TChunk>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ChatMiddleware, JSONSchema } from '@tanstack/ai';
|
|
2
|
+
import { GeminiTextAdapter, type GeminiTextModel } from '@tanstack/ai-gemini';
|
|
2
3
|
import type { Subject } from '@vestcards/shared';
|
|
3
4
|
import type { VestyModel } from './model';
|
|
5
|
+
export declare const VESTY_PRIMARY_MODEL: "gemini-3.1-pro-preview" | "gemini-3-pro-preview" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "gemini-2.5-pro" | "gemini-2.5-flash" | "gemini-2.5-flash-preview-09-2025" | "gemini-2.5-flash-lite" | "gemini-2.5-flash-lite-preview-09-2025" | "gemini-2.0-flash" | "gemini-2.0-flash-lite";
|
|
6
|
+
export declare const VESTY_FALLBACK_MODEL: "gemini-3.1-pro-preview" | "gemini-3-pro-preview" | "gemini-3-flash-preview" | "gemini-3.1-flash-lite-preview" | "gemini-2.5-pro" | "gemini-2.5-flash" | "gemini-2.5-flash-preview-09-2025" | "gemini-2.5-flash-lite" | "gemini-2.5-flash-lite-preview-09-2025" | "gemini-2.0-flash" | "gemini-2.0-flash-lite";
|
|
7
|
+
export declare const VESTY_MODELS: readonly GeminiTextModel[];
|
|
8
|
+
export declare function getGeminiAdapter(model: GeminiTextModel): GeminiTextAdapter<GeminiTextModel>;
|
|
4
9
|
export declare const VESTY_SYSTEM_PROMPT: (userName: string) => string;
|
|
5
10
|
export declare const SUBJECT_DETECTION_SCHEMA: JSONSchema;
|
|
6
11
|
export declare const SUBJECT_DETECTION_PROMPT: string;
|
|
@@ -19,32 +24,18 @@ type DeckTopic = {
|
|
|
19
24
|
id: string;
|
|
20
25
|
name: string;
|
|
21
26
|
};
|
|
22
|
-
|
|
23
|
-
structuredOutput: (options: {
|
|
24
|
-
chatOptions: {
|
|
25
|
-
model: string;
|
|
26
|
-
messages: Array<{
|
|
27
|
-
role: 'user';
|
|
28
|
-
content: string;
|
|
29
|
-
}>;
|
|
30
|
-
systemPrompts: string[];
|
|
31
|
-
modelOptions: typeof GeminiModelOptions;
|
|
32
|
-
};
|
|
33
|
-
outputSchema: JSONSchema;
|
|
34
|
-
}) => Promise<{
|
|
35
|
-
data: unknown;
|
|
36
|
-
}>;
|
|
37
|
-
};
|
|
38
|
-
export declare function detectDeckSubject(adapter: StructuredOutputAdapter, input: Array<{
|
|
27
|
+
export declare function detectDeckSubject(model: GeminiTextModel, input: Array<{
|
|
39
28
|
role: 'user';
|
|
40
29
|
content: string;
|
|
41
30
|
}>): Promise<Subject | null>;
|
|
42
31
|
export declare function fetchDeckTopics(subject: Subject | null): Promise<DeckTopic[]>;
|
|
43
|
-
export declare function generateDeckFromPrompt(
|
|
32
|
+
export declare function generateDeckFromPrompt(model: GeminiTextModel, input: Array<{
|
|
44
33
|
role: 'user';
|
|
45
34
|
content: string;
|
|
46
35
|
}>, topicList: DeckTopic[], subject: Subject | null): Promise<VestyModel.GeneratedDeck>;
|
|
47
36
|
export declare function captureAiGeneration(userId: string, props: {
|
|
37
|
+
traceId: string;
|
|
38
|
+
model: string;
|
|
48
39
|
input: {
|
|
49
40
|
role: string;
|
|
50
41
|
content: string;
|
|
@@ -53,6 +44,8 @@ export declare function captureAiGeneration(userId: string, props: {
|
|
|
53
44
|
stream: boolean;
|
|
54
45
|
isError: false;
|
|
55
46
|
} | {
|
|
47
|
+
traceId: string;
|
|
48
|
+
model: string;
|
|
56
49
|
input: {
|
|
57
50
|
role: string;
|
|
58
51
|
content: string;
|
|
@@ -65,5 +58,5 @@ export declare function captureAiGeneration(userId: string, props: {
|
|
|
65
58
|
export declare function createAnalyticsMiddleware(userId: string, inputMessages: {
|
|
66
59
|
role: 'user' | 'assistant';
|
|
67
60
|
content: string;
|
|
68
|
-
}[]): ChatMiddleware;
|
|
61
|
+
}[], traceId: string, model: string): ChatMiddleware;
|
|
69
62
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface RedisSetOptions {
|
|
2
|
+
ex?: number;
|
|
3
|
+
}
|
|
4
|
+
interface RedisSetCall {
|
|
5
|
+
key: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
options?: RedisSetOptions;
|
|
8
|
+
}
|
|
9
|
+
declare class TestRedis {
|
|
10
|
+
private store;
|
|
11
|
+
private readError;
|
|
12
|
+
private writeError;
|
|
13
|
+
readonly getCalls: string[];
|
|
14
|
+
readonly setCalls: RedisSetCall[];
|
|
15
|
+
readonly delCalls: string[];
|
|
16
|
+
readonly client: {
|
|
17
|
+
get: (key: string) => Promise<unknown>;
|
|
18
|
+
set: (key: string, value: unknown, options?: RedisSetOptions) => Promise<string>;
|
|
19
|
+
del: (key: string) => Promise<number>;
|
|
20
|
+
};
|
|
21
|
+
seed(key: string, value: unknown): void;
|
|
22
|
+
read(key: string): unknown;
|
|
23
|
+
failReads(error?: Error): void;
|
|
24
|
+
failWrites(error?: Error): void;
|
|
25
|
+
clearFailures(): void;
|
|
26
|
+
clearCalls(): void;
|
|
27
|
+
reset(): void;
|
|
28
|
+
private get;
|
|
29
|
+
private set;
|
|
30
|
+
private del;
|
|
31
|
+
}
|
|
32
|
+
export declare const testRedis: TestRedis;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './decks';
|