@vestcards/server-types 1.3.0 → 1.4.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 (61) hide show
  1. package/dist/apps/server/src/app.d.ts +288 -18
  2. package/dist/apps/server/src/config/env.d.ts +7 -1
  3. package/dist/apps/server/src/lib/metrics.d.ts +4 -0
  4. package/dist/apps/server/src/lib/posthog.d.ts +2 -0
  5. package/dist/apps/server/src/middleware/errorHandler.d.ts +1 -1
  6. package/dist/apps/server/src/middleware/logger.d.ts +12 -29
  7. package/dist/apps/server/src/modules/auth/lib.d.ts +27 -3
  8. package/dist/apps/server/src/modules/auth/profile.d.ts +5 -0
  9. package/dist/apps/server/src/modules/auth/utils.d.ts +1 -0
  10. package/dist/apps/server/src/modules/card/index.d.ts +2 -2
  11. package/dist/apps/server/src/modules/cron/cron.test.d.ts +1 -0
  12. package/dist/apps/server/src/modules/cron/index.d.ts +53 -0
  13. package/dist/apps/server/src/modules/cron/jobs/expire-memberships.d.ts +1 -0
  14. package/dist/apps/server/src/modules/cron/jobs/payment-expiry-reminder.d.ts +1 -0
  15. package/dist/apps/server/src/modules/deck/index.d.ts +19 -1
  16. package/dist/apps/server/src/modules/deck/model.d.ts +4 -0
  17. package/dist/apps/server/src/modules/deck/service.d.ts +5 -1
  18. package/dist/apps/server/src/modules/ranking/index.d.ts +412 -0
  19. package/dist/apps/server/src/modules/ranking/model.d.ts +28 -0
  20. package/dist/apps/server/src/modules/ranking/ranking.test.d.ts +1 -0
  21. package/dist/apps/server/src/modules/ranking/service.d.ts +4 -0
  22. package/dist/apps/server/src/modules/stats/index.d.ts +446 -0
  23. package/dist/apps/server/src/modules/stats/model.d.ts +85 -0
  24. package/dist/apps/server/src/modules/stats/service.d.ts +27 -0
  25. package/dist/apps/server/src/modules/stats/stats.test.d.ts +1 -0
  26. package/dist/apps/server/src/modules/study/service.d.ts +4 -4
  27. package/dist/apps/server/src/modules/user/index.d.ts +32 -15
  28. package/dist/apps/server/src/modules/user/model.d.ts +11 -1
  29. package/dist/apps/server/src/modules/user/service.d.ts +13 -29
  30. package/dist/apps/server/src/modules/vesty/index.d.ts +473 -0
  31. package/dist/apps/server/src/modules/vesty/model.d.ts +35 -0
  32. package/dist/apps/server/src/modules/vesty/service.d.ts +6 -0
  33. package/dist/apps/server/src/modules/vesty/services/generate-deck.d.ts +2 -0
  34. package/dist/apps/server/src/modules/vesty/services/insights.d.ts +3 -0
  35. package/dist/apps/server/src/modules/vesty/tools.d.ts +11 -0
  36. package/dist/apps/server/src/modules/vesty/utils.d.ts +69 -0
  37. package/dist/apps/server/src/modules/vesty/vesty.test.d.ts +1 -0
  38. package/dist/apps/server/src/server.d.ts +1 -0
  39. package/dist/apps/server/src/tests/helpers/fixtures.d.ts +8 -6
  40. package/dist/apps/server/src/tests/preload/vesty-mock.d.ts +1 -0
  41. package/dist/packages/db-core/src/index.d.ts +0 -1
  42. package/dist/packages/db-core/src/schema/auth.d.ts +34 -0
  43. package/dist/packages/db-core/src/schema/index.d.ts +0 -1
  44. package/dist/packages/db-core/src/schema/payment.d.ts +37 -1
  45. package/dist/packages/email-core/src/templates/index.d.ts +2 -0
  46. package/dist/packages/email-core/src/templates/paymentExpiryReminder.d.ts +9 -0
  47. package/dist/packages/shared/src/date/index.d.ts +1 -0
  48. package/dist/packages/shared/src/date/timezone.d.ts +29 -0
  49. package/dist/packages/shared/src/spaced-repetition/config.d.ts +17 -2
  50. package/dist/packages/shared/src/spaced-repetition/index.d.ts +1 -0
  51. package/dist/packages/shared/src/spaced-repetition/retention.d.ts +2 -0
  52. package/dist/packages/shared/src/theme/tokens/colors.d.ts +18 -18
  53. package/dist/packages/shared/src/types/index.d.ts +1 -0
  54. package/dist/packages/shared/src/types/permissions.d.ts +2 -0
  55. package/dist/packages/shared/src/types/user.d.ts +20 -0
  56. package/dist/packages/shared/src/types/vesty.d.ts +7 -0
  57. package/dist/packages/utils/src/logger/index.d.ts +2 -1
  58. package/dist/packages/utils/src/logger/posthog.d.ts +20 -0
  59. package/package.json +1 -1
  60. package/dist/apps/server/src/modules/study/constants.d.ts +0 -5
  61. package/dist/packages/db-core/src/views/deck.d.ts +0 -79
@@ -0,0 +1,69 @@
1
+ import type { ChatMiddleware, JSONSchema } from '@tanstack/ai';
2
+ import type { Subject } from '@vestcards/shared';
3
+ import type { VestyModel } from './model';
4
+ export declare const VESTY_SYSTEM_PROMPT: (userName: string) => string;
5
+ export declare const SUBJECT_DETECTION_SCHEMA: JSONSchema;
6
+ export declare const SUBJECT_DETECTION_PROMPT: string;
7
+ export declare const GeminiModelOptions: {
8
+ thinkingConfig: {
9
+ includeThoughts: boolean;
10
+ thinkingBudget: number;
11
+ };
12
+ };
13
+ export declare const GENERATE_DECK_SYSTEM_PROMPT: (topics: Array<{
14
+ id: string;
15
+ name: string;
16
+ }>) => string;
17
+ export declare const GENERATED_DECK_OUTPUT_SCHEMA: JSONSchema;
18
+ type DeckTopic = {
19
+ id: string;
20
+ name: string;
21
+ };
22
+ type StructuredOutputAdapter = {
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<{
39
+ role: 'user';
40
+ content: string;
41
+ }>): Promise<Subject | null>;
42
+ export declare function fetchDeckTopics(subject: Subject | null): Promise<DeckTopic[]>;
43
+ export declare function generateDeckFromPrompt(adapter: StructuredOutputAdapter, input: Array<{
44
+ role: 'user';
45
+ content: string;
46
+ }>, topicList: DeckTopic[], subject: Subject | null): Promise<VestyModel.GeneratedDeck>;
47
+ export declare function captureAiGeneration(userId: string, props: {
48
+ input: {
49
+ role: string;
50
+ content: string;
51
+ }[];
52
+ latency: number;
53
+ stream: boolean;
54
+ isError: false;
55
+ } | {
56
+ input: {
57
+ role: string;
58
+ content: string;
59
+ }[];
60
+ latency: number;
61
+ stream: boolean;
62
+ isError: true;
63
+ error: string;
64
+ }): void;
65
+ export declare function createAnalyticsMiddleware(userId: string, inputMessages: {
66
+ role: 'user' | 'assistant';
67
+ content: string;
68
+ }[]): ChatMiddleware;
69
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,2 @@
1
+ import './modules/cron';
1
2
  import './config/env';
@@ -1,4 +1,4 @@
1
- import { MembershipStatus } from '@vestcards/shared';
1
+ import { type BillingType, type DeckStatus, MembershipStatus } from '@vestcards/shared';
2
2
  /**
3
3
  * Create a test topic
4
4
  */
@@ -22,10 +22,10 @@ export declare function createDeck(data: {
22
22
  ownerId: string;
23
23
  lastEditedBy?: string;
24
24
  free?: boolean;
25
- status?: string;
25
+ status?: DeckStatus;
26
26
  keywords?: string[];
27
27
  }): Promise<{
28
- status: import("@vestcards/shared").DeckStatus;
28
+ status: DeckStatus;
29
29
  id: string;
30
30
  createdAt: Date;
31
31
  updatedAt: Date;
@@ -82,7 +82,7 @@ export declare function createTestDeck(data: {
82
82
  answer: string | null;
83
83
  extend: unknown;
84
84
  }[];
85
- status: import("@vestcards/shared").DeckStatus;
85
+ status: DeckStatus;
86
86
  id: string;
87
87
  createdAt: Date;
88
88
  updatedAt: Date;
@@ -166,11 +166,13 @@ export declare function deleteOfficialEntity(entityId: string): Promise<void>;
166
166
  export declare function createMembership(data: {
167
167
  entityId: string;
168
168
  status?: MembershipStatus;
169
+ billingType?: BillingType;
169
170
  startedAt?: Date;
170
171
  expiresAt?: Date;
172
+ createdAt?: Date;
171
173
  }): Promise<{
172
- status: MembershipStatus;
173
174
  value: number;
175
+ status: MembershipStatus;
174
176
  id: string;
175
177
  entityId: string;
176
178
  createdAt: Date;
@@ -180,7 +182,7 @@ export declare function createMembership(data: {
180
182
  asaasPaymentId: string;
181
183
  asaasInstallmentId: string | null;
182
184
  installmentCount: number;
183
- billingType: import("@vestcards/shared").BillingType;
185
+ billingType: BillingType;
184
186
  couponCode: string | null;
185
187
  idempotencyKey: string | null;
186
188
  startedAt: Date | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
1
  export { db } from './db';
2
2
  export * from './schema';
3
3
  export * from './utils';
4
- export * from './views/deck';
@@ -825,6 +825,23 @@ export declare const userSettings: import("drizzle-orm/pg-core").PgTableWithColu
825
825
  identity: undefined;
826
826
  generated: undefined;
827
827
  }, {}, {}>;
828
+ timezone: import("drizzle-orm/pg-core").PgColumn<{
829
+ name: "timezone";
830
+ tableName: "user_settings";
831
+ dataType: "string";
832
+ columnType: "PgText";
833
+ data: string;
834
+ driverParam: string;
835
+ notNull: true;
836
+ hasDefault: true;
837
+ isPrimaryKey: false;
838
+ isAutoincrement: false;
839
+ hasRuntimeDefault: false;
840
+ enumValues: [string, ...string[]];
841
+ baseColumn: never;
842
+ identity: undefined;
843
+ generated: undefined;
844
+ }, {}, {}>;
828
845
  university: import("drizzle-orm/pg-core").PgColumn<{
829
846
  name: "university";
830
847
  tableName: "user_settings";
@@ -876,6 +893,23 @@ export declare const userSettings: import("drizzle-orm/pg-core").PgTableWithColu
876
893
  identity: undefined;
877
894
  generated: undefined;
878
895
  }, {}, {}>;
896
+ newCardsPerDeckDailyLimit: import("drizzle-orm/pg-core").PgColumn<{
897
+ name: "new_cards_per_deck_daily_limit";
898
+ tableName: "user_settings";
899
+ dataType: "number";
900
+ columnType: "PgInteger";
901
+ data: number;
902
+ driverParam: string | number;
903
+ notNull: false;
904
+ hasDefault: false;
905
+ isPrimaryKey: false;
906
+ isAutoincrement: false;
907
+ hasRuntimeDefault: false;
908
+ enumValues: undefined;
909
+ baseColumn: never;
910
+ identity: undefined;
911
+ generated: undefined;
912
+ }, {}, {}>;
879
913
  createdAt: import("drizzle-orm/pg-core").PgColumn<{
880
914
  name: "created_at";
881
915
  tableName: "user_settings";
@@ -1,4 +1,3 @@
1
- export * from '../views/deck';
2
1
  export * from './auth';
3
2
  export * from './blog';
4
3
  export * from './data';
@@ -1,4 +1,4 @@
1
- import { type BillingType, MembershipStatus } from '@vestcards/shared';
1
+ import { type BillingType, MembershipStatus, PlanType } from '@vestcards/shared';
2
2
  import type { InferInsertModel, InferSelectModel } from 'drizzle-orm';
3
3
  export declare const customMoneyType: {
4
4
  (): import("drizzle-orm/pg-core").PgCustomColumnBuilder<{
@@ -64,6 +64,42 @@ export declare const plan: import("drizzle-orm/pg-core").PgTableWithColumns<{
64
64
  identity: undefined;
65
65
  generated: undefined;
66
66
  }, {}, {}>;
67
+ planType: import("drizzle-orm/pg-core").PgColumn<{
68
+ name: "plan_type";
69
+ tableName: "plan";
70
+ dataType: "string";
71
+ columnType: "PgText";
72
+ data: PlanType;
73
+ driverParam: string;
74
+ notNull: true;
75
+ hasDefault: true;
76
+ isPrimaryKey: false;
77
+ isAutoincrement: false;
78
+ hasRuntimeDefault: false;
79
+ enumValues: [string, ...string[]];
80
+ baseColumn: never;
81
+ identity: undefined;
82
+ generated: undefined;
83
+ }, {}, {
84
+ $type: PlanType;
85
+ }>;
86
+ active: import("drizzle-orm/pg-core").PgColumn<{
87
+ name: "active";
88
+ tableName: "plan";
89
+ dataType: "boolean";
90
+ columnType: "PgBoolean";
91
+ data: boolean;
92
+ driverParam: boolean;
93
+ notNull: true;
94
+ hasDefault: true;
95
+ isPrimaryKey: false;
96
+ isAutoincrement: false;
97
+ hasRuntimeDefault: false;
98
+ enumValues: undefined;
99
+ baseColumn: never;
100
+ identity: undefined;
101
+ generated: undefined;
102
+ }, {}, {}>;
67
103
  accessTimeInMonths: import("drizzle-orm/pg-core").PgColumn<{
68
104
  name: "access_time_in_months";
69
105
  tableName: "plan";
@@ -5,6 +5,7 @@ import { type EmailCardDemandActionValues } from './cardDemandAction';
5
5
  import { type EmailDeleteAccountRequestValues } from './deleteAccountRequest';
6
6
  import { type EmailConfirmAccountValues } from './emailVerification';
7
7
  import { type EmailForgotPasswordValues } from './forgotPassword';
8
+ import { type EmailPaymentExpiryReminderValues } from './paymentExpiryReminder';
8
9
  import { type EmailPurchaseConfirmationValues } from './purchaseConfirmation';
9
10
  import { type EmailPrePaymentDetailsValues } from './purchasePrePayment';
10
11
  import { type EmailPurchaseRefundValues } from './purchaseRefund';
@@ -23,6 +24,7 @@ export interface EmailTemplateFunctions {
23
24
  DeleteAccountRequest: (data: EmailDeleteAccountRequestValues) => EmailTemplateType;
24
25
  CardDemand: (data: EmailCardDemandValues) => EmailTemplateType;
25
26
  CardDemandAction: (data: EmailCardDemandActionValues) => EmailTemplateType;
27
+ PaymentExpiryReminder: (data: EmailPaymentExpiryReminderValues) => EmailTemplateType;
26
28
  }
27
29
  export type EmailTemplate = keyof EmailTemplateFunctions;
28
30
  export type EmailTemplateValues<T extends EmailTemplate> = Parameters<EmailTemplateFunctions[T]>[0];
@@ -0,0 +1,9 @@
1
+ export interface EmailPaymentExpiryReminderValues {
2
+ name: string;
3
+ paymentMethod: string;
4
+ expiresAt: string;
5
+ }
6
+ export declare const EMAILPaymentExpiryReminder: ({ name, paymentMethod, expiresAt }: EmailPaymentExpiryReminderValues) => {
7
+ subject: string;
8
+ html: string;
9
+ };
@@ -11,4 +11,5 @@ export * from './fns';
11
11
  export * from './format';
12
12
  export { toDate } from './helpers';
13
13
  export * from './relative';
14
+ export * from './timezone';
14
15
  export * from './types';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Returns true if `tz` is a valid IANA timezone identifier recognised by the
3
+ * runtime's Intl API (e.g. "America/Sao_Paulo", "America/Manaus", "UTC").
4
+ */
5
+ export declare function isValidIANATimezone(tz: string): boolean;
6
+ /**
7
+ * Returns `tz` if it is a valid IANA timezone, otherwise falls back to
8
+ * `DEFAULT_TZ` ("America/Sao_Paulo"). Use this as a safety net when reading
9
+ * timezone values from the database to avoid crashing on corrupted data.
10
+ */
11
+ export declare function safeTimezone(tz: string | null | undefined): string;
12
+ /**
13
+ * Returns the ISO weekday index (Mon = 0 … Sun = 6) for `date` evaluated in
14
+ * `timezone`. Uses `toZonedTime` so the result is always consistent with the
15
+ * given timezone regardless of the server's local clock.
16
+ */
17
+ export declare function getWeekdayIndex(date: Date, timezone: string): number;
18
+ /**
19
+ * Returns the UTC `Date` for the start of `date`'s day in `timezone` (00:00:00.000 local → UTC).
20
+ */
21
+ export declare function startOfDayInTz(date: Date, timezone: string): Date;
22
+ /**
23
+ * Returns the UTC `Date` for the end of `date`'s day in `timezone` (23:59:59.999 local → UTC).
24
+ */
25
+ export declare function endOfDayInTz(date: Date, timezone: string): Date;
26
+ /**
27
+ * Returns the UTC `Date` that corresponds to Monday midnight (00:00:00) in `timezone`.
28
+ */
29
+ export declare function getWeekStartUTC(now: Date, timezone: string): Date;
@@ -1,5 +1,20 @@
1
1
  export declare const FSRS_RETENTION = 0.9;
2
+ export declare const FSRS_RETRIEVABILITY_DECAY = 0.1542;
3
+ export declare const FSRS_RETENTION_FACTOR: number;
2
4
  export declare const MAX_CARDS_TO_FETCH = 50;
3
- export declare const MAX_LEARN_PER_DAY = 200;
4
- export declare const MAX_NEW_PER_DECK_DAY = 10;
5
+ export declare const LEARNING_SETTINGS_LIMITS: {
6
+ readonly learnDailyLimit: {
7
+ readonly recommended: 200;
8
+ readonly min: 100;
9
+ readonly max: 500;
10
+ readonly step: 50;
11
+ };
12
+ readonly newCardsPerDeckDailyLimit: {
13
+ readonly recommended: 10;
14
+ readonly min: 1;
15
+ readonly max: 50;
16
+ readonly step: 5;
17
+ };
18
+ };
5
19
  export declare const THRESHOLD_CARDS_FOR_REFETCH = 10;
20
+ export declare const isRecommendedLearningSettings: (learnDailyLimit: number | null, newCardsPerDeckDailyLimit: number | null) => boolean;
@@ -1,4 +1,5 @@
1
1
  export * from './config';
2
2
  export * from './fsrs';
3
+ export * from './retention';
3
4
  export * from './session-manager';
4
5
  export * from './utils';
@@ -0,0 +1,2 @@
1
+ export declare function calculateRetrievability(elapsedDays: number, stability: number): number;
2
+ export declare function calculateRetentionPercentage(elapsedDays: number, stability: number): number;
@@ -19,10 +19,10 @@ declare const colors: {
19
19
  readonly 12: string;
20
20
  readonly a1: string;
21
21
  readonly a2: string;
22
+ readonly a3: string;
22
23
  readonly a10: string;
23
- readonly a4: string;
24
24
  readonly a5: string;
25
- readonly a3: string;
25
+ readonly a4: string;
26
26
  readonly a6: string;
27
27
  readonly a7: string;
28
28
  readonly a8: string;
@@ -50,10 +50,10 @@ declare const colors: {
50
50
  readonly 12: string;
51
51
  readonly a1: string;
52
52
  readonly a2: string;
53
+ readonly a3: string;
53
54
  readonly a10: string;
54
- readonly a4: string;
55
55
  readonly a5: string;
56
- readonly a3: string;
56
+ readonly a4: string;
57
57
  readonly a6: string;
58
58
  readonly a7: string;
59
59
  readonly a8: string;
@@ -81,10 +81,10 @@ declare const colors: {
81
81
  readonly 12: string;
82
82
  readonly a1: string;
83
83
  readonly a2: string;
84
+ readonly a3: string;
84
85
  readonly a10: string;
85
- readonly a4: string;
86
86
  readonly a5: string;
87
- readonly a3: string;
87
+ readonly a4: string;
88
88
  readonly a6: string;
89
89
  readonly a7: string;
90
90
  readonly a8: string;
@@ -112,10 +112,10 @@ declare const colors: {
112
112
  readonly 12: string;
113
113
  readonly a1: string;
114
114
  readonly a2: string;
115
+ readonly a3: string;
115
116
  readonly a10: string;
116
- readonly a4: string;
117
117
  readonly a5: string;
118
- readonly a3: string;
118
+ readonly a4: string;
119
119
  readonly a6: string;
120
120
  readonly a7: string;
121
121
  readonly a8: string;
@@ -143,10 +143,10 @@ declare const colors: {
143
143
  readonly 12: string;
144
144
  readonly a1: string;
145
145
  readonly a2: string;
146
+ readonly a3: string;
146
147
  readonly a10: string;
147
- readonly a4: string;
148
148
  readonly a5: string;
149
- readonly a3: string;
149
+ readonly a4: string;
150
150
  readonly a6: string;
151
151
  readonly a7: string;
152
152
  readonly a8: string;
@@ -174,10 +174,10 @@ declare const colors: {
174
174
  readonly 12: string;
175
175
  readonly a1: string;
176
176
  readonly a2: string;
177
+ readonly a3: string;
177
178
  readonly a10: string;
178
- readonly a4: string;
179
179
  readonly a5: string;
180
- readonly a3: string;
180
+ readonly a4: string;
181
181
  readonly a6: string;
182
182
  readonly a7: string;
183
183
  readonly a8: string;
@@ -205,10 +205,10 @@ declare const colors: {
205
205
  readonly 12: string;
206
206
  readonly a1: string;
207
207
  readonly a2: string;
208
+ readonly a3: string;
208
209
  readonly a10: string;
209
- readonly a4: string;
210
210
  readonly a5: string;
211
- readonly a3: string;
211
+ readonly a4: string;
212
212
  readonly a6: string;
213
213
  readonly a7: string;
214
214
  readonly a8: string;
@@ -236,10 +236,10 @@ declare const colors: {
236
236
  readonly 12: string;
237
237
  readonly a1: string;
238
238
  readonly a2: string;
239
+ readonly a3: string;
239
240
  readonly a10: string;
240
- readonly a4: string;
241
241
  readonly a5: string;
242
- readonly a3: string;
242
+ readonly a4: string;
243
243
  readonly a6: string;
244
244
  readonly a7: string;
245
245
  readonly a8: string;
@@ -267,10 +267,10 @@ declare const colors: {
267
267
  readonly 12: string;
268
268
  readonly a1: string;
269
269
  readonly a2: string;
270
+ readonly a3: string;
270
271
  readonly a10: string;
271
- readonly a4: string;
272
272
  readonly a5: string;
273
- readonly a3: string;
273
+ readonly a4: string;
274
274
  readonly a6: string;
275
275
  readonly a7: string;
276
276
  readonly a8: string;
@@ -7,3 +7,4 @@ export * from './studyPlan';
7
7
  export * from './subject';
8
8
  export * from './topic';
9
9
  export * from './user';
10
+ export * from './vesty';
@@ -48,6 +48,7 @@ export declare const PERMISSIONS: {
48
48
  };
49
49
  readonly VESTY: {
50
50
  readonly CHAT: "vesty:chat";
51
+ readonly INSIGHTS: "vesty:insights";
51
52
  };
52
53
  readonly STUDY: {
53
54
  readonly READ: "study:read";
@@ -98,6 +99,7 @@ export declare const Permission: {
98
99
  readonly BLOGPOST_UPDATE: "blogpost:update";
99
100
  readonly BLOGPOST_DELETE: "blogpost:delete";
100
101
  readonly VESTY_CHAT: "vesty:chat";
102
+ readonly VESTY_INSIGHTS: "vesty:insights";
101
103
  readonly STUDY_READ: "study:read";
102
104
  readonly STUDY_WRITE: "study:write";
103
105
  readonly LIBRARY_READ: "library:read";
@@ -4,6 +4,22 @@ export declare enum UserRole {
4
4
  User = "user"
5
5
  }
6
6
  export type UserScopeRole = (typeof UserRole)[keyof typeof UserRole];
7
+ export interface IUserProfile {
8
+ id: string;
9
+ name: string;
10
+ surname: string;
11
+ email: string;
12
+ image: string | null;
13
+ role: UserScopeRole;
14
+ goal: string | null;
15
+ learnDailyLimit: number | null;
16
+ newCardsPerDeckDailyLimit: number | null;
17
+ universityId: number | null;
18
+ universityName: string | null;
19
+ courseId: number | null;
20
+ courseName: string | null;
21
+ authProviders: string[];
22
+ }
7
23
  export declare enum OrganizationRole {
8
24
  Owner = "owner",
9
25
  Admin = "admin",
@@ -20,3 +36,7 @@ export declare enum MembershipStatus {
20
36
  Expired = "expired"
21
37
  }
22
38
  export type BillingType = 'PIX' | 'CREDIT_CARD' | 'BOLETO';
39
+ export declare enum PlanType {
40
+ Fixed = "FIXED",
41
+ Seasonal = "SEASONAL"
42
+ }
@@ -0,0 +1,7 @@
1
+ import type { Subject } from './deck';
2
+ export interface IVestyChatRelatedDeck {
3
+ id: string;
4
+ title: string;
5
+ subject: Subject;
6
+ topicName: string;
7
+ }
@@ -1,2 +1,3 @@
1
1
  import { logger } from './logger';
2
- export { logger };
2
+ import { flushPostHogLogs, shutdownPostHogLogs } from './posthog';
3
+ export { flushPostHogLogs, logger, shutdownPostHogLogs };
@@ -0,0 +1,20 @@
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;
11
+ }
12
+ export declare function emitPostHogLog(level: LogLevel, args: unknown[], bindings?: PinoBindings): void;
13
+ export declare function flushPostHogLogs(options?: FlushOptions): Promise<void>;
14
+ 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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestcards/server-types",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -1,5 +0,0 @@
1
- export declare const FSRS_RETENTION = 0.9;
2
- export declare const MAX_CARDS_TO_FETCH = 50;
3
- export declare const MAX_LEARN_PER_DAY = 200;
4
- export declare const MAX_NEW_PER_DECK_DAY = 10;
5
- export declare const THRESHOLD_CARDS_FOR_REFETCH = 10;
@@ -1,79 +0,0 @@
1
- export declare const userCurrentReviewStreak: import("drizzle-orm/pg-core").PgViewWithSelection<"user_current_review_streak", false, {
2
- user_id: import("drizzle-orm/pg-core").PgColumn<{
3
- name: "user_id";
4
- tableName: "user_current_review_streak";
5
- dataType: "string";
6
- columnType: "PgText";
7
- data: string;
8
- driverParam: string;
9
- notNull: true;
10
- hasDefault: false;
11
- isPrimaryKey: false;
12
- isAutoincrement: false;
13
- hasRuntimeDefault: false;
14
- enumValues: [string, ...string[]];
15
- baseColumn: never;
16
- identity: undefined;
17
- generated: undefined;
18
- }, {}, {}>;
19
- current_streak: import("drizzle-orm/pg-core").PgColumn<{
20
- name: "current_streak";
21
- tableName: "user_current_review_streak";
22
- dataType: "number";
23
- columnType: "PgInteger";
24
- data: number;
25
- driverParam: string | number;
26
- notNull: true;
27
- hasDefault: false;
28
- isPrimaryKey: false;
29
- isAutoincrement: false;
30
- hasRuntimeDefault: false;
31
- enumValues: undefined;
32
- baseColumn: never;
33
- identity: undefined;
34
- generated: undefined;
35
- }, {}, {}>;
36
- week_activity: import("drizzle-orm/pg-core").PgColumn<{
37
- name: "week_activity";
38
- tableName: "user_current_review_streak";
39
- dataType: "array";
40
- columnType: "PgArray";
41
- data: boolean[];
42
- driverParam: string | boolean[];
43
- notNull: true;
44
- hasDefault: false;
45
- isPrimaryKey: false;
46
- isAutoincrement: false;
47
- hasRuntimeDefault: false;
48
- enumValues: undefined;
49
- baseColumn: import("drizzle-orm").Column<{
50
- name: "week_activity";
51
- tableName: "user_current_review_streak";
52
- dataType: "boolean";
53
- columnType: "PgBoolean";
54
- data: boolean;
55
- driverParam: boolean;
56
- notNull: false;
57
- hasDefault: false;
58
- isPrimaryKey: false;
59
- isAutoincrement: false;
60
- hasRuntimeDefault: false;
61
- enumValues: undefined;
62
- baseColumn: never;
63
- identity: undefined;
64
- generated: undefined;
65
- }, {}, {}>;
66
- identity: undefined;
67
- generated: undefined;
68
- }, {}, {
69
- baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
70
- name: "week_activity";
71
- dataType: "boolean";
72
- columnType: "PgBoolean";
73
- data: boolean;
74
- driverParam: boolean;
75
- enumValues: undefined;
76
- }, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
77
- size: undefined;
78
- }>;
79
- }>;