@vestcards/server-types 1.3.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.
Files changed (94) hide show
  1. package/dist/apps/server/src/app.d.ts +382 -20
  2. package/dist/apps/server/src/config/env.d.ts +9 -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 +14 -29
  7. package/dist/apps/server/src/middleware/logger.test.d.ts +1 -0
  8. package/dist/apps/server/src/modules/auth/index.d.ts +4 -4
  9. package/dist/apps/server/src/modules/auth/lib.d.ts +30 -3
  10. package/dist/apps/server/src/modules/auth/profile.d.ts +5 -0
  11. package/dist/apps/server/src/modules/auth/tracing.d.ts +18 -0
  12. package/dist/apps/server/src/modules/auth/tracing.test.d.ts +1 -0
  13. package/dist/apps/server/src/modules/auth/utils.d.ts +1 -0
  14. package/dist/apps/server/src/modules/card/index.d.ts +4 -4
  15. package/dist/apps/server/src/modules/cron/cron.test.d.ts +1 -0
  16. package/dist/apps/server/src/modules/cron/index.d.ts +53 -0
  17. package/dist/apps/server/src/modules/cron/jobs/expire-memberships.d.ts +1 -0
  18. package/dist/apps/server/src/modules/cron/jobs/payment-expiry-reminder.d.ts +1 -0
  19. package/dist/apps/server/src/modules/deck/access.d.ts +5 -0
  20. package/dist/apps/server/src/modules/deck/index.d.ts +23 -5
  21. package/dist/apps/server/src/modules/deck/model.d.ts +4 -0
  22. package/dist/apps/server/src/modules/deck/service.d.ts +5 -1
  23. package/dist/apps/server/src/modules/exam/exam.test.d.ts +1 -0
  24. package/dist/apps/server/src/modules/exam/index.d.ts +457 -0
  25. package/dist/apps/server/src/modules/exam/model.d.ts +18 -0
  26. package/dist/apps/server/src/modules/exam/service.d.ts +43 -0
  27. package/dist/apps/server/src/modules/library/index.d.ts +4 -4
  28. package/dist/apps/server/src/modules/ranking/cache.d.ts +6 -0
  29. package/dist/apps/server/src/modules/ranking/helpers.d.ts +9 -0
  30. package/dist/apps/server/src/modules/ranking/index.d.ts +412 -0
  31. package/dist/apps/server/src/modules/ranking/model.d.ts +28 -0
  32. package/dist/apps/server/src/modules/ranking/ranking.test.d.ts +1 -0
  33. package/dist/apps/server/src/modules/ranking/repository.d.ts +10 -0
  34. package/dist/apps/server/src/modules/ranking/service.d.ts +4 -0
  35. package/dist/apps/server/src/modules/stats/index.d.ts +446 -0
  36. package/dist/apps/server/src/modules/stats/model.d.ts +85 -0
  37. package/dist/apps/server/src/modules/stats/service.d.ts +27 -0
  38. package/dist/apps/server/src/modules/stats/stats.test.d.ts +1 -0
  39. package/dist/apps/server/src/modules/study/index.d.ts +4 -4
  40. package/dist/apps/server/src/modules/study/service.d.ts +4 -4
  41. package/dist/apps/server/src/modules/topic/index.d.ts +4 -4
  42. package/dist/apps/server/src/modules/user/index.d.ts +36 -19
  43. package/dist/apps/server/src/modules/user/model.d.ts +11 -1
  44. package/dist/apps/server/src/modules/user/service.d.ts +13 -29
  45. package/dist/apps/server/src/modules/vesty/index.d.ts +473 -0
  46. package/dist/apps/server/src/modules/vesty/model.d.ts +35 -0
  47. package/dist/apps/server/src/modules/vesty/resilience.d.ts +40 -0
  48. package/dist/apps/server/src/modules/vesty/resilience.test.d.ts +1 -0
  49. package/dist/apps/server/src/modules/vesty/service.d.ts +6 -0
  50. package/dist/apps/server/src/modules/vesty/services/generate-deck.d.ts +2 -0
  51. package/dist/apps/server/src/modules/vesty/services/insights.d.ts +3 -0
  52. package/dist/apps/server/src/modules/vesty/tools.d.ts +11 -0
  53. package/dist/apps/server/src/modules/vesty/utils.d.ts +62 -0
  54. package/dist/apps/server/src/modules/vesty/vesty.test.d.ts +1 -0
  55. package/dist/apps/server/src/server.d.ts +1 -0
  56. package/dist/apps/server/src/tests/helpers/fixtures.d.ts +8 -6
  57. package/dist/apps/server/src/tests/helpers/index.d.ts +1 -0
  58. package/dist/apps/server/src/tests/helpers/redis-mock.d.ts +33 -0
  59. package/dist/apps/server/src/tests/preload/redis-mock.d.ts +1 -0
  60. package/dist/apps/server/src/tests/preload/vesty-mock.d.ts +1 -0
  61. package/dist/packages/db-core/src/db.d.ts +1 -2
  62. package/dist/packages/db-core/src/index.d.ts +1 -1
  63. package/dist/packages/db-core/src/queries/decks.d.ts +2 -0
  64. package/dist/packages/db-core/src/queries/index.d.ts +1 -0
  65. package/dist/packages/db-core/src/schema/auth.d.ts +34 -0
  66. package/dist/packages/db-core/src/schema/exams.d.ts +721 -0
  67. package/dist/packages/db-core/src/schema/index.d.ts +1 -1
  68. package/dist/packages/db-core/src/schema/payment.d.ts +37 -1
  69. package/dist/packages/db-core/src/tracing.d.ts +2 -0
  70. package/dist/packages/email-core/src/templates/index.d.ts +2 -0
  71. package/dist/packages/email-core/src/templates/paymentExpiryReminder.d.ts +9 -0
  72. package/dist/packages/shared/src/constants.d.ts +2 -0
  73. package/dist/packages/shared/src/date/index.d.ts +1 -0
  74. package/dist/packages/shared/src/date/timezone.d.ts +29 -0
  75. package/dist/packages/shared/src/index.d.ts +1 -0
  76. package/dist/packages/shared/src/spaced-repetition/config.d.ts +17 -2
  77. package/dist/packages/shared/src/spaced-repetition/index.d.ts +1 -0
  78. package/dist/packages/shared/src/spaced-repetition/retention.d.ts +2 -0
  79. package/dist/packages/shared/src/spaced-repetition/session-manager.d.ts +3 -0
  80. package/dist/packages/shared/src/theme/tokens/colors.d.ts +27 -27
  81. package/dist/packages/shared/src/types/index.d.ts +1 -0
  82. package/dist/packages/shared/src/types/permissions.d.ts +6 -0
  83. package/dist/packages/shared/src/types/user.d.ts +20 -0
  84. package/dist/packages/shared/src/types/vesty.d.ts +7 -0
  85. package/dist/packages/utils/src/logger/config.d.ts +12 -0
  86. package/dist/packages/utils/src/logger/index.d.ts +5 -1
  87. package/dist/packages/utils/src/logger/pino.d.ts +7 -0
  88. package/dist/packages/utils/src/logger/posthog.d.ts +16 -0
  89. package/dist/packages/utils/src/logger/timeout.d.ts +4 -0
  90. package/dist/packages/utils/src/logger/tracing.d.ts +34 -0
  91. package/package.json +1 -1
  92. package/dist/apps/server/src/modules/study/constants.d.ts +0 -5
  93. package/dist/packages/db-core/src/views/deck.d.ts +0 -79
  94. /package/dist/apps/server/src/{libs → lib}/mappers.d.ts +0 -0
@@ -1,9 +1,9 @@
1
- export * from '../views/deck';
2
1
  export * from './auth';
3
2
  export * from './blog';
4
3
  export * from './data';
5
4
  export * from './deck';
6
5
  export * from './entity';
6
+ export * from './exams';
7
7
  export * from './marketing';
8
8
  export * from './organization';
9
9
  export * from './payment';
@@ -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";
@@ -0,0 +1,2 @@
1
+ import { Pool, type PoolConfig } from 'pg';
2
+ export declare function createTracedPool(config: PoolConfig): Pool;
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ export declare const VESTCARDS_OWNER_ID = "vestcards";
2
+ export declare const VESTCARDS_ORGANIZATION_ID = "vestcards";
@@ -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,2 +1,3 @@
1
+ export * from './constants';
1
2
  export * from './eden';
2
3
  export * from './types';
@@ -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;
@@ -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,16 +18,16 @@ declare const colors: {
18
18
  readonly 11: string;
19
19
  readonly 12: string;
20
20
  readonly a1: string;
21
+ readonly a3: string;
21
22
  readonly a2: string;
23
+ readonly a11: string;
22
24
  readonly a10: string;
23
- readonly a4: string;
24
25
  readonly a5: string;
25
- readonly a3: string;
26
+ readonly a4: string;
26
27
  readonly a6: string;
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,16 +49,16 @@ declare const colors: {
49
49
  readonly 11: string;
50
50
  readonly 12: string;
51
51
  readonly a1: string;
52
+ readonly a3: string;
52
53
  readonly a2: string;
54
+ readonly a11: string;
53
55
  readonly a10: string;
54
- readonly a4: string;
55
56
  readonly a5: string;
56
- readonly a3: string;
57
+ readonly a4: string;
57
58
  readonly a6: string;
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,16 +80,16 @@ declare const colors: {
80
80
  readonly 11: string;
81
81
  readonly 12: string;
82
82
  readonly a1: string;
83
+ readonly a3: string;
83
84
  readonly a2: string;
85
+ readonly a11: string;
84
86
  readonly a10: string;
85
- readonly a4: string;
86
87
  readonly a5: string;
87
- readonly a3: string;
88
+ readonly a4: string;
88
89
  readonly a6: string;
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,16 +111,16 @@ declare const colors: {
111
111
  readonly 11: string;
112
112
  readonly 12: string;
113
113
  readonly a1: string;
114
+ readonly a3: string;
114
115
  readonly a2: string;
116
+ readonly a11: string;
115
117
  readonly a10: string;
116
- readonly a4: string;
117
118
  readonly a5: string;
118
- readonly a3: string;
119
+ readonly a4: string;
119
120
  readonly a6: string;
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,16 +142,16 @@ declare const colors: {
142
142
  readonly 11: string;
143
143
  readonly 12: string;
144
144
  readonly a1: string;
145
+ readonly a3: string;
145
146
  readonly a2: string;
147
+ readonly a11: string;
146
148
  readonly a10: string;
147
- readonly a4: string;
148
149
  readonly a5: string;
149
- readonly a3: string;
150
+ readonly a4: string;
150
151
  readonly a6: string;
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,16 +173,16 @@ declare const colors: {
173
173
  readonly 11: string;
174
174
  readonly 12: string;
175
175
  readonly a1: string;
176
+ readonly a3: string;
176
177
  readonly a2: string;
178
+ readonly a11: string;
177
179
  readonly a10: string;
178
- readonly a4: string;
179
180
  readonly a5: string;
180
- readonly a3: string;
181
+ readonly a4: string;
181
182
  readonly a6: string;
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,16 +204,16 @@ declare const colors: {
204
204
  readonly 11: string;
205
205
  readonly 12: string;
206
206
  readonly a1: string;
207
+ readonly a3: string;
207
208
  readonly a2: string;
209
+ readonly a11: string;
208
210
  readonly a10: string;
209
- readonly a4: string;
210
211
  readonly a5: string;
211
- readonly a3: string;
212
+ readonly a4: string;
212
213
  readonly a6: string;
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,16 +235,16 @@ declare const colors: {
235
235
  readonly 11: string;
236
236
  readonly 12: string;
237
237
  readonly a1: string;
238
+ readonly a3: string;
238
239
  readonly a2: string;
240
+ readonly a11: string;
239
241
  readonly a10: string;
240
- readonly a4: string;
241
242
  readonly a5: string;
242
- readonly a3: string;
243
+ readonly a4: string;
243
244
  readonly a6: string;
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,16 +266,16 @@ declare const colors: {
266
266
  readonly 11: string;
267
267
  readonly 12: string;
268
268
  readonly a1: string;
269
+ readonly a3: string;
269
270
  readonly a2: string;
271
+ readonly a11: string;
270
272
  readonly a10: string;
271
- readonly a4: string;
272
273
  readonly a5: string;
273
- readonly a3: string;
274
+ readonly a4: string;
274
275
  readonly a6: string;
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;
@@ -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,11 +48,15 @@ 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";
54
55
  readonly WRITE: "study:write";
55
56
  };
57
+ readonly EXAM: {
58
+ readonly READ: "exam:read";
59
+ };
56
60
  readonly LIBRARY: {
57
61
  readonly READ: "library:read";
58
62
  readonly WRITE: "library:write";
@@ -98,8 +102,10 @@ export declare const Permission: {
98
102
  readonly BLOGPOST_UPDATE: "blogpost:update";
99
103
  readonly BLOGPOST_DELETE: "blogpost:delete";
100
104
  readonly VESTY_CHAT: "vesty:chat";
105
+ readonly VESTY_INSIGHTS: "vesty:insights";
101
106
  readonly STUDY_READ: "study:read";
102
107
  readonly STUDY_WRITE: "study:write";
108
+ readonly EXAM_READ: "exam:read";
103
109
  readonly LIBRARY_READ: "library:read";
104
110
  readonly LIBRARY_WRITE: "library:write";
105
111
  readonly LIBRARY_WRITE_PREMIUM: "library:write:premium";
@@ -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
+ }
@@ -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,2 +1,6 @@
1
1
  import { logger } from './logger';
2
- export { logger };
2
+ import { flushPostHogLogs, shutdownPostHogLogs } from './posthog';
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
+ };
@@ -0,0 +1,16 @@
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;
12
+ }
13
+ export declare function emitPostHogLog(level: LogLevel, args: unknown[], bindings?: PinoBindings): void;
14
+ export declare function flushPostHogLogs(options?: FlushOptions): Promise<void>;
15
+ export declare function shutdownPostHogLogs(): Promise<void>;
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.3.0",
3
+ "version": "1.5.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
- }>;
File without changes