@vestcards/server-types 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/apps/server/src/app.d.ts +128 -6
  2. package/dist/apps/server/src/config/env.d.ts +2 -0
  3. package/dist/apps/server/src/middleware/logger.d.ts +2 -0
  4. package/dist/apps/server/src/middleware/logger.test.d.ts +1 -0
  5. package/dist/apps/server/src/modules/auth/index.d.ts +4 -4
  6. package/dist/apps/server/src/modules/auth/lib.d.ts +3 -0
  7. package/dist/apps/server/src/modules/auth/tracing.d.ts +18 -0
  8. package/dist/apps/server/src/modules/auth/tracing.test.d.ts +1 -0
  9. package/dist/apps/server/src/modules/card/index.d.ts +6 -6
  10. package/dist/apps/server/src/modules/deck/access.d.ts +5 -0
  11. package/dist/apps/server/src/modules/deck/index.d.ts +4 -4
  12. package/dist/apps/server/src/modules/exam/exam.test.d.ts +1 -0
  13. package/dist/apps/server/src/modules/exam/index.d.ts +457 -0
  14. package/dist/apps/server/src/modules/exam/model.d.ts +18 -0
  15. package/dist/apps/server/src/modules/exam/service.d.ts +43 -0
  16. package/dist/apps/server/src/modules/library/index.d.ts +4 -4
  17. package/dist/apps/server/src/modules/ranking/cache.d.ts +6 -0
  18. package/dist/apps/server/src/modules/ranking/helpers.d.ts +9 -0
  19. package/dist/apps/server/src/modules/ranking/index.d.ts +4 -4
  20. package/dist/apps/server/src/modules/ranking/repository.d.ts +10 -0
  21. package/dist/apps/server/src/modules/stats/index.d.ts +4 -4
  22. package/dist/apps/server/src/modules/stats/service.d.ts +2 -2
  23. package/dist/apps/server/src/modules/study/index.d.ts +34 -4
  24. package/dist/apps/server/src/modules/study/model.d.ts +4 -0
  25. package/dist/apps/server/src/modules/study/service.d.ts +4 -1
  26. package/dist/apps/server/src/modules/topic/index.d.ts +4 -4
  27. package/dist/apps/server/src/modules/user/index.d.ts +4 -4
  28. package/dist/apps/server/src/modules/vesty/index.d.ts +4 -4
  29. package/dist/apps/server/src/modules/vesty/resilience.d.ts +40 -0
  30. package/dist/apps/server/src/modules/vesty/resilience.test.d.ts +1 -0
  31. package/dist/apps/server/src/modules/vesty/utils.d.ts +12 -19
  32. package/dist/apps/server/src/tests/helpers/index.d.ts +1 -0
  33. package/dist/apps/server/src/tests/helpers/redis-mock.d.ts +33 -0
  34. package/dist/apps/server/src/tests/preload/redis-mock.d.ts +1 -0
  35. package/dist/packages/db-core/src/db.d.ts +1 -2
  36. package/dist/packages/db-core/src/index.d.ts +1 -0
  37. package/dist/packages/db-core/src/queries/decks.d.ts +2 -0
  38. package/dist/packages/db-core/src/queries/index.d.ts +1 -0
  39. package/dist/packages/db-core/src/schema/exams.d.ts +721 -0
  40. package/dist/packages/db-core/src/schema/index.d.ts +1 -0
  41. package/dist/packages/db-core/src/tracing.d.ts +2 -0
  42. package/dist/packages/shared/src/constants.d.ts +2 -0
  43. package/dist/packages/shared/src/index.d.ts +1 -0
  44. package/dist/packages/shared/src/spaced-repetition/session-manager.d.ts +3 -0
  45. package/dist/packages/shared/src/theme/tokens/colors.d.ts +18 -18
  46. package/dist/packages/shared/src/types/permissions.d.ts +4 -0
  47. package/dist/packages/utils/src/logger/config.d.ts +12 -0
  48. package/dist/packages/utils/src/logger/index.d.ts +4 -1
  49. package/dist/packages/utils/src/logger/pino.d.ts +7 -0
  50. package/dist/packages/utils/src/logger/posthog.d.ts +12 -16
  51. package/dist/packages/utils/src/logger/timeout.d.ts +4 -0
  52. package/dist/packages/utils/src/logger/tracing.d.ts +34 -0
  53. package/package.json +1 -1
  54. /package/dist/apps/server/src/{libs → lib}/mappers.d.ts +0 -0
@@ -3,6 +3,7 @@ export * from './blog';
3
3
  export * from './data';
4
4
  export * from './deck';
5
5
  export * from './entity';
6
+ export * from './exams';
6
7
  export * from './marketing';
7
8
  export * from './organization';
8
9
  export * from './payment';
@@ -0,0 +1,2 @@
1
+ import { Pool, type PoolConfig } from 'pg';
2
+ export declare function createTracedPool(config: PoolConfig): Pool;
@@ -0,0 +1,2 @@
1
+ export declare const VESTCARDS_OWNER_ID = "vestcards";
2
+ export declare const VESTCARDS_ORGANIZATION_ID = "vestcards";
@@ -1,2 +1,3 @@
1
+ export * from './constants';
1
2
  export * from './eden';
2
3
  export * from './types';
@@ -17,9 +17,12 @@ export interface SessionProgress {
17
17
  */
18
18
  export declare class FlashcardSessionManager {
19
19
  private recentlyReviewed;
20
+ private reviewHistory;
20
21
  private _reviewsCompleted;
21
22
  private _correctGrades;
22
23
  getProgress(): SessionProgress;
23
24
  nextCard(data: ISessionData): ISessionCard | undefined;
24
25
  onRate(cardId: string, rating: ReviewRating): SessionProgress;
26
+ undoRate(cardId: string, rating: ReviewRating): SessionProgress;
27
+ private rebuildStateFromHistory;
25
28
  }
@@ -18,8 +18,9 @@ declare const colors: {
18
18
  readonly 11: string;
19
19
  readonly 12: string;
20
20
  readonly a1: string;
21
- readonly a2: string;
22
21
  readonly a3: string;
22
+ readonly a2: string;
23
+ readonly a11: string;
23
24
  readonly a10: string;
24
25
  readonly a5: string;
25
26
  readonly a4: string;
@@ -27,7 +28,6 @@ declare const colors: {
27
28
  readonly a7: string;
28
29
  readonly a8: string;
29
30
  readonly a9: string;
30
- readonly a11: string;
31
31
  readonly a12: string;
32
32
  readonly DEFAULT: string;
33
33
  readonly hover: string;
@@ -49,8 +49,9 @@ declare const colors: {
49
49
  readonly 11: string;
50
50
  readonly 12: string;
51
51
  readonly a1: string;
52
- readonly a2: string;
53
52
  readonly a3: string;
53
+ readonly a2: string;
54
+ readonly a11: string;
54
55
  readonly a10: string;
55
56
  readonly a5: string;
56
57
  readonly a4: string;
@@ -58,7 +59,6 @@ declare const colors: {
58
59
  readonly a7: string;
59
60
  readonly a8: string;
60
61
  readonly a9: string;
61
- readonly a11: string;
62
62
  readonly a12: string;
63
63
  readonly DEFAULT: string;
64
64
  readonly hover: string;
@@ -80,8 +80,9 @@ declare const colors: {
80
80
  readonly 11: string;
81
81
  readonly 12: string;
82
82
  readonly a1: string;
83
- readonly a2: string;
84
83
  readonly a3: string;
84
+ readonly a2: string;
85
+ readonly a11: string;
85
86
  readonly a10: string;
86
87
  readonly a5: string;
87
88
  readonly a4: string;
@@ -89,7 +90,6 @@ declare const colors: {
89
90
  readonly a7: string;
90
91
  readonly a8: string;
91
92
  readonly a9: string;
92
- readonly a11: string;
93
93
  readonly a12: string;
94
94
  readonly DEFAULT: string;
95
95
  readonly hover: string;
@@ -111,8 +111,9 @@ declare const colors: {
111
111
  readonly 11: string;
112
112
  readonly 12: string;
113
113
  readonly a1: string;
114
- readonly a2: string;
115
114
  readonly a3: string;
115
+ readonly a2: string;
116
+ readonly a11: string;
116
117
  readonly a10: string;
117
118
  readonly a5: string;
118
119
  readonly a4: string;
@@ -120,7 +121,6 @@ declare const colors: {
120
121
  readonly a7: string;
121
122
  readonly a8: string;
122
123
  readonly a9: string;
123
- readonly a11: string;
124
124
  readonly a12: string;
125
125
  readonly DEFAULT: string;
126
126
  readonly hover: string;
@@ -142,8 +142,9 @@ declare const colors: {
142
142
  readonly 11: string;
143
143
  readonly 12: string;
144
144
  readonly a1: string;
145
- readonly a2: string;
146
145
  readonly a3: string;
146
+ readonly a2: string;
147
+ readonly a11: string;
147
148
  readonly a10: string;
148
149
  readonly a5: string;
149
150
  readonly a4: string;
@@ -151,7 +152,6 @@ declare const colors: {
151
152
  readonly a7: string;
152
153
  readonly a8: string;
153
154
  readonly a9: string;
154
- readonly a11: string;
155
155
  readonly a12: string;
156
156
  readonly DEFAULT: string;
157
157
  readonly hover: string;
@@ -173,8 +173,9 @@ declare const colors: {
173
173
  readonly 11: string;
174
174
  readonly 12: string;
175
175
  readonly a1: string;
176
- readonly a2: string;
177
176
  readonly a3: string;
177
+ readonly a2: string;
178
+ readonly a11: string;
178
179
  readonly a10: string;
179
180
  readonly a5: string;
180
181
  readonly a4: string;
@@ -182,7 +183,6 @@ declare const colors: {
182
183
  readonly a7: string;
183
184
  readonly a8: string;
184
185
  readonly a9: string;
185
- readonly a11: string;
186
186
  readonly a12: string;
187
187
  readonly DEFAULT: string;
188
188
  readonly hover: string;
@@ -204,8 +204,9 @@ declare const colors: {
204
204
  readonly 11: string;
205
205
  readonly 12: string;
206
206
  readonly a1: string;
207
- readonly a2: string;
208
207
  readonly a3: string;
208
+ readonly a2: string;
209
+ readonly a11: string;
209
210
  readonly a10: string;
210
211
  readonly a5: string;
211
212
  readonly a4: string;
@@ -213,7 +214,6 @@ declare const colors: {
213
214
  readonly a7: string;
214
215
  readonly a8: string;
215
216
  readonly a9: string;
216
- readonly a11: string;
217
217
  readonly a12: string;
218
218
  readonly DEFAULT: string;
219
219
  readonly hover: string;
@@ -235,8 +235,9 @@ declare const colors: {
235
235
  readonly 11: string;
236
236
  readonly 12: string;
237
237
  readonly a1: string;
238
- readonly a2: string;
239
238
  readonly a3: string;
239
+ readonly a2: string;
240
+ readonly a11: string;
240
241
  readonly a10: string;
241
242
  readonly a5: string;
242
243
  readonly a4: string;
@@ -244,7 +245,6 @@ declare const colors: {
244
245
  readonly a7: string;
245
246
  readonly a8: string;
246
247
  readonly a9: string;
247
- readonly a11: string;
248
248
  readonly a12: string;
249
249
  readonly DEFAULT: string;
250
250
  readonly hover: string;
@@ -266,8 +266,9 @@ declare const colors: {
266
266
  readonly 11: string;
267
267
  readonly 12: string;
268
268
  readonly a1: string;
269
- readonly a2: string;
270
269
  readonly a3: string;
270
+ readonly a2: string;
271
+ readonly a11: string;
271
272
  readonly a10: string;
272
273
  readonly a5: string;
273
274
  readonly a4: string;
@@ -275,7 +276,6 @@ declare const colors: {
275
276
  readonly a7: string;
276
277
  readonly a8: string;
277
278
  readonly a9: string;
278
- readonly a11: string;
279
279
  readonly a12: string;
280
280
  readonly DEFAULT: string;
281
281
  readonly hover: string;
@@ -54,6 +54,9 @@ export declare const PERMISSIONS: {
54
54
  readonly READ: "study:read";
55
55
  readonly WRITE: "study:write";
56
56
  };
57
+ readonly EXAM: {
58
+ readonly READ: "exam:read";
59
+ };
57
60
  readonly LIBRARY: {
58
61
  readonly READ: "library:read";
59
62
  readonly WRITE: "library:write";
@@ -102,6 +105,7 @@ export declare const Permission: {
102
105
  readonly VESTY_INSIGHTS: "vesty:insights";
103
106
  readonly STUDY_READ: "study:read";
104
107
  readonly STUDY_WRITE: "study:write";
108
+ readonly EXAM_READ: "exam:read";
105
109
  readonly LIBRARY_READ: "library:read";
106
110
  readonly LIBRARY_WRITE: "library:write";
107
111
  readonly LIBRARY_WRITE_PREMIUM: "library:write:premium";
@@ -0,0 +1,12 @@
1
+ export interface PostHogLogsConfig {
2
+ endpoint: string;
3
+ projectToken: string;
4
+ resourceAttributes: Record<string, string>;
5
+ }
6
+ export interface PostHogTracesConfig {
7
+ endpoint: string;
8
+ projectToken: string;
9
+ resourceAttributes: Record<string, string>;
10
+ }
11
+ export declare function getPostHogLogsConfig(env: NodeJS.ProcessEnv): PostHogLogsConfig | undefined;
12
+ export declare function getPostHogTracesConfig(env: NodeJS.ProcessEnv): PostHogTracesConfig | undefined;
@@ -1,3 +1,6 @@
1
1
  import { logger } from './logger';
2
2
  import { flushPostHogLogs, shutdownPostHogLogs } from './posthog';
3
- export { flushPostHogLogs, logger, shutdownPostHogLogs };
3
+ import type { TraceAttributes } from './tracing';
4
+ import { finishPostHogTraceSpan, flushPostHogTraces, getActivePostHogTraceSpan, setPostHogTraceAttributes, shutdownPostHogTraces, startActivePostHogTraceSpan, startPostHogTraceSpan } from './tracing';
5
+ export type { TraceAttributes };
6
+ export { finishPostHogTraceSpan, flushPostHogLogs, flushPostHogTraces, getActivePostHogTraceSpan, logger, setPostHogTraceAttributes, shutdownPostHogLogs, shutdownPostHogTraces, startActivePostHogTraceSpan, startPostHogTraceSpan, };
@@ -0,0 +1,7 @@
1
+ import type { LogAttributes } from '@opentelemetry/api-logs';
2
+ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
3
+ export type PinoBindings = Record<string, unknown>;
4
+ export declare function parsePinoArgs(args: unknown[], bindings: PinoBindings): {
5
+ body: string;
6
+ attributes: LogAttributes;
7
+ };
@@ -1,20 +1,16 @@
1
- import { type LogAttributes } from '@opentelemetry/api-logs';
2
- type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
3
- type PinoBindings = Record<string, unknown>;
4
- interface PostHogLogsConfig {
5
- endpoint: string;
6
- projectToken: string;
7
- resourceAttributes: Record<string, string>;
8
- }
9
- interface FlushOptions {
10
- timeoutMs?: number;
1
+ import { getPostHogLogsConfig } from './config';
2
+ import { type LogLevel, type PinoBindings, parsePinoArgs } from './pino';
3
+ import { type FlushOptions } from './timeout';
4
+ export declare class PostHogLogBridge {
5
+ private readonly logger;
6
+ private readonly provider;
7
+ constructor(env?: NodeJS.ProcessEnv);
8
+ emit(level: LogLevel, args: unknown[], bindings?: PinoBindings): void;
9
+ flush(options?: FlushOptions): Promise<void>;
10
+ shutdown(): Promise<void>;
11
+ private createProvider;
11
12
  }
12
13
  export declare function emitPostHogLog(level: LogLevel, args: unknown[], bindings?: PinoBindings): void;
13
14
  export declare function flushPostHogLogs(options?: FlushOptions): Promise<void>;
14
15
  export declare function shutdownPostHogLogs(): Promise<void>;
15
- export declare function getPostHogLogsConfig(env: NodeJS.ProcessEnv): PostHogLogsConfig | undefined;
16
- export declare function parsePinoArgs(args: unknown[], bindings: PinoBindings): {
17
- body: string;
18
- attributes: LogAttributes;
19
- };
20
- export {};
16
+ export { getPostHogLogsConfig, parsePinoArgs };
@@ -0,0 +1,4 @@
1
+ export interface FlushOptions {
2
+ timeoutMs?: number;
3
+ }
4
+ export declare function withTimeout(promise: Promise<void>, timeoutMs: number | undefined): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { type AttributeValue, type Span } from '@opentelemetry/api';
2
+ import { getPostHogTracesConfig } from './config';
3
+ import { type FlushOptions } from './timeout';
4
+ export type TraceAttributes = Record<string, AttributeValue>;
5
+ type SpanKindName = 'internal' | 'server' | 'client' | 'producer' | 'consumer';
6
+ interface StartTraceSpanOptions {
7
+ kind?: SpanKindName;
8
+ }
9
+ interface FinishTraceSpanOptions {
10
+ attributes?: TraceAttributes;
11
+ error?: unknown;
12
+ statusCode?: number | string;
13
+ }
14
+ export declare class PostHogTracer {
15
+ private readonly provider;
16
+ private readonly tracer;
17
+ constructor(env?: NodeJS.ProcessEnv);
18
+ startSpan(name: string, attributes?: TraceAttributes, options?: StartTraceSpanOptions): Span | undefined;
19
+ startActiveSpan<T>(name: string, attributes: TraceAttributes, options: StartTraceSpanOptions, callback: () => T): T;
20
+ getActiveSpan(): Span | undefined;
21
+ setAttributes(span: unknown, attributes: TraceAttributes): void;
22
+ finishSpan(span: unknown, options?: FinishTraceSpanOptions): void;
23
+ flush(options?: FlushOptions): Promise<void>;
24
+ shutdown(): Promise<void>;
25
+ private createProvider;
26
+ }
27
+ export declare function startPostHogTraceSpan(name: string, attributes?: TraceAttributes, options?: StartTraceSpanOptions): Span | undefined;
28
+ export declare function startActivePostHogTraceSpan<T>(name: string, attributes: TraceAttributes, options: StartTraceSpanOptions, callback: () => T): T;
29
+ export declare function getActivePostHogTraceSpan(): Span | undefined;
30
+ export declare function setPostHogTraceAttributes(span: unknown, attributes: TraceAttributes): void;
31
+ export declare function finishPostHogTraceSpan(span: unknown, options?: FinishTraceSpanOptions): void;
32
+ export declare function flushPostHogTraces(options?: FlushOptions): Promise<void>;
33
+ export declare function shutdownPostHogTraces(): Promise<void>;
34
+ export { getPostHogTracesConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestcards/server-types",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "private": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
File without changes