@vestcards/server-types 1.2.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.
- package/dist/apps/server/src/app.d.ts +437 -16
- package/dist/apps/server/src/config/env.d.ts +7 -1
- package/dist/apps/server/src/lib/metrics.d.ts +4 -0
- package/dist/apps/server/src/lib/posthog.d.ts +2 -0
- package/dist/apps/server/src/libs/mappers.d.ts +5 -0
- package/dist/apps/server/src/middleware/errorHandler.d.ts +1 -1
- package/dist/apps/server/src/middleware/logger.d.ts +12 -29
- package/dist/apps/server/src/modules/auth/lib.d.ts +45 -17
- package/dist/apps/server/src/modules/auth/profile.d.ts +5 -0
- package/dist/apps/server/src/modules/auth/utils.d.ts +1 -0
- package/dist/apps/server/src/modules/card/index.d.ts +89 -0
- package/dist/apps/server/src/modules/card/model.d.ts +17 -0
- package/dist/apps/server/src/modules/card/service.d.ts +8 -1
- package/dist/apps/server/src/modules/cron/cron.test.d.ts +1 -0
- package/dist/apps/server/src/modules/cron/index.d.ts +53 -0
- package/dist/apps/server/src/modules/cron/jobs/expire-memberships.d.ts +1 -0
- package/dist/apps/server/src/modules/cron/jobs/payment-expiry-reminder.d.ts +1 -0
- package/dist/apps/server/src/modules/deck/index.d.ts +19 -1
- package/dist/apps/server/src/modules/deck/model.d.ts +4 -0
- package/dist/apps/server/src/modules/deck/service.d.ts +5 -1
- package/dist/apps/server/src/modules/ranking/index.d.ts +412 -0
- package/dist/apps/server/src/modules/ranking/model.d.ts +28 -0
- package/dist/apps/server/src/modules/ranking/ranking.test.d.ts +1 -0
- package/dist/apps/server/src/modules/ranking/service.d.ts +4 -0
- package/dist/apps/server/src/modules/stats/index.d.ts +446 -0
- package/dist/apps/server/src/modules/stats/model.d.ts +85 -0
- package/dist/apps/server/src/modules/stats/service.d.ts +27 -0
- package/dist/apps/server/src/modules/stats/stats.test.d.ts +1 -0
- package/dist/apps/server/src/modules/study/service.d.ts +7 -7
- package/dist/apps/server/src/modules/user/errors.d.ts +3 -0
- package/dist/apps/server/src/modules/user/index.d.ts +94 -15
- package/dist/apps/server/src/modules/user/model.d.ts +17 -1
- package/dist/apps/server/src/modules/user/service.d.ts +17 -29
- package/dist/apps/server/src/modules/vesty/index.d.ts +473 -0
- package/dist/apps/server/src/modules/vesty/model.d.ts +35 -0
- package/dist/apps/server/src/modules/vesty/service.d.ts +6 -0
- package/dist/apps/server/src/modules/vesty/services/generate-deck.d.ts +2 -0
- package/dist/apps/server/src/modules/vesty/services/insights.d.ts +3 -0
- package/dist/apps/server/src/modules/vesty/tools.d.ts +11 -0
- package/dist/apps/server/src/modules/vesty/utils.d.ts +69 -0
- package/dist/apps/server/src/modules/vesty/vesty.test.d.ts +1 -0
- package/dist/apps/server/src/server.d.ts +1 -0
- package/dist/apps/server/src/tests/helpers/fixtures.d.ts +9 -6
- package/dist/apps/server/src/tests/preload/vesty-mock.d.ts +1 -0
- package/dist/apps/server/src/utils/api.d.ts +1 -1
- package/dist/apps/server/src/utils/select.d.ts +17 -0
- package/dist/packages/db-core/src/index.d.ts +0 -1
- package/dist/packages/db-core/src/schema/auth.d.ts +94 -0
- package/dist/packages/db-core/src/schema/deck.d.ts +17 -0
- package/dist/packages/db-core/src/schema/payment.d.ts +37 -1
- package/dist/packages/email-core/src/templates/deleteAccountRequest.d.ts +8 -0
- package/dist/packages/email-core/src/templates/footer.d.ts +1 -1
- package/dist/packages/email-core/src/templates/index.d.ts +4 -0
- package/dist/packages/email-core/src/templates/paymentExpiryReminder.d.ts +9 -0
- package/dist/packages/shared/src/date/index.d.ts +1 -0
- package/dist/packages/shared/src/date/timezone.d.ts +29 -0
- package/dist/packages/shared/src/spaced-repetition/config.d.ts +20 -0
- package/dist/packages/shared/src/spaced-repetition/fsrs.d.ts +13 -0
- package/dist/packages/shared/src/spaced-repetition/index.d.ts +5 -0
- package/dist/packages/shared/src/spaced-repetition/retention.d.ts +2 -0
- package/dist/packages/shared/src/spaced-repetition/session-manager.d.ts +25 -0
- package/dist/packages/shared/src/spaced-repetition/utils.d.ts +26 -0
- package/dist/packages/shared/src/theme/tokens/border.d.ts +1 -1
- package/dist/packages/shared/src/theme/tokens/colors.d.ts +18 -18
- package/dist/packages/shared/src/types/deck.d.ts +10 -0
- package/dist/packages/shared/src/types/index.d.ts +1 -0
- package/dist/packages/shared/src/types/permissions.d.ts +2 -0
- package/dist/packages/shared/src/types/user.d.ts +20 -0
- package/dist/packages/shared/src/types/vesty.d.ts +7 -0
- package/dist/packages/utils/src/logger/index.d.ts +2 -1
- package/dist/packages/utils/src/logger/posthog.d.ts +20 -0
- package/package.json +1 -1
- package/dist/apps/server/src/modules/study/lib/constants.d.ts +0 -5
- package/dist/apps/server/src/modules/study/lib/fsrs.d.ts +0 -12
- package/dist/packages/db-core/src/views/deck.d.ts +0 -79
|
@@ -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?:
|
|
25
|
+
status?: DeckStatus;
|
|
26
26
|
keywords?: string[];
|
|
27
27
|
}): Promise<{
|
|
28
|
-
status:
|
|
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:
|
|
85
|
+
status: DeckStatus;
|
|
86
86
|
id: string;
|
|
87
87
|
createdAt: Date;
|
|
88
88
|
updatedAt: Date;
|
|
@@ -125,6 +125,7 @@ export declare function createCardReview(data: {
|
|
|
125
125
|
lapses?: number;
|
|
126
126
|
last_review?: Date | null;
|
|
127
127
|
}): Promise<{
|
|
128
|
+
suspended: boolean;
|
|
128
129
|
id: string;
|
|
129
130
|
createdAt: Date;
|
|
130
131
|
cardId: string;
|
|
@@ -165,11 +166,13 @@ export declare function deleteOfficialEntity(entityId: string): Promise<void>;
|
|
|
165
166
|
export declare function createMembership(data: {
|
|
166
167
|
entityId: string;
|
|
167
168
|
status?: MembershipStatus;
|
|
169
|
+
billingType?: BillingType;
|
|
168
170
|
startedAt?: Date;
|
|
169
171
|
expiresAt?: Date;
|
|
172
|
+
createdAt?: Date;
|
|
170
173
|
}): Promise<{
|
|
171
|
-
status: MembershipStatus;
|
|
172
174
|
value: number;
|
|
175
|
+
status: MembershipStatus;
|
|
173
176
|
id: string;
|
|
174
177
|
entityId: string;
|
|
175
178
|
createdAt: Date;
|
|
@@ -179,7 +182,7 @@ export declare function createMembership(data: {
|
|
|
179
182
|
asaasPaymentId: string;
|
|
180
183
|
asaasInstallmentId: string | null;
|
|
181
184
|
installmentCount: number;
|
|
182
|
-
billingType:
|
|
185
|
+
billingType: BillingType;
|
|
183
186
|
couponCode: string | null;
|
|
184
187
|
idempotencyKey: string | null;
|
|
185
188
|
startedAt: Date | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -27,5 +27,5 @@ export declare const paginateResults: <T, TOtherData = {}>(data: T[], { size, to
|
|
|
27
27
|
size: number;
|
|
28
28
|
total: number;
|
|
29
29
|
}, aggregatedData?: TOtherData) => Paginated<T, TOtherData>;
|
|
30
|
-
export { paginationModel, searchModel, sortModel };
|
|
31
30
|
export type { Paginated, Pagination, Search, Sort };
|
|
31
|
+
export { paginationModel, searchModel, sortModel };
|
|
@@ -331,6 +331,23 @@ export declare const sessionCardSelect: {
|
|
|
331
331
|
identity: undefined;
|
|
332
332
|
generated: undefined;
|
|
333
333
|
}, {}, {}>;
|
|
334
|
+
suspended: import("drizzle-orm/pg-core").PgColumn<{
|
|
335
|
+
name: "suspended";
|
|
336
|
+
tableName: "card_review";
|
|
337
|
+
dataType: "boolean";
|
|
338
|
+
columnType: "PgBoolean";
|
|
339
|
+
data: boolean;
|
|
340
|
+
driverParam: boolean;
|
|
341
|
+
notNull: true;
|
|
342
|
+
hasDefault: true;
|
|
343
|
+
isPrimaryKey: false;
|
|
344
|
+
isAutoincrement: false;
|
|
345
|
+
hasRuntimeDefault: false;
|
|
346
|
+
enumValues: undefined;
|
|
347
|
+
baseColumn: never;
|
|
348
|
+
identity: undefined;
|
|
349
|
+
generated: undefined;
|
|
350
|
+
}, {}, {}>;
|
|
334
351
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
335
352
|
name: "created_at";
|
|
336
353
|
tableName: "card_review";
|
|
@@ -336,6 +336,66 @@ export declare const session: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
336
336
|
identity: undefined;
|
|
337
337
|
generated: undefined;
|
|
338
338
|
}, {}, {}>;
|
|
339
|
+
entitlements: import("drizzle-orm/pg-core").PgColumn<{
|
|
340
|
+
name: "entitlements";
|
|
341
|
+
tableName: "session";
|
|
342
|
+
dataType: "array";
|
|
343
|
+
columnType: "PgArray";
|
|
344
|
+
data: string[];
|
|
345
|
+
driverParam: string | string[];
|
|
346
|
+
notNull: true;
|
|
347
|
+
hasDefault: true;
|
|
348
|
+
isPrimaryKey: false;
|
|
349
|
+
isAutoincrement: false;
|
|
350
|
+
hasRuntimeDefault: false;
|
|
351
|
+
enumValues: [string, ...string[]];
|
|
352
|
+
baseColumn: import("drizzle-orm").Column<{
|
|
353
|
+
name: "entitlements";
|
|
354
|
+
tableName: "session";
|
|
355
|
+
dataType: "string";
|
|
356
|
+
columnType: "PgText";
|
|
357
|
+
data: string;
|
|
358
|
+
driverParam: string;
|
|
359
|
+
notNull: false;
|
|
360
|
+
hasDefault: false;
|
|
361
|
+
isPrimaryKey: false;
|
|
362
|
+
isAutoincrement: false;
|
|
363
|
+
hasRuntimeDefault: false;
|
|
364
|
+
enumValues: [string, ...string[]];
|
|
365
|
+
baseColumn: never;
|
|
366
|
+
identity: undefined;
|
|
367
|
+
generated: undefined;
|
|
368
|
+
}, {}, {}>;
|
|
369
|
+
identity: undefined;
|
|
370
|
+
generated: undefined;
|
|
371
|
+
}, {}, {
|
|
372
|
+
baseBuilder: import("drizzle-orm/pg-core").PgColumnBuilder<{
|
|
373
|
+
name: "entitlements";
|
|
374
|
+
dataType: "string";
|
|
375
|
+
columnType: "PgText";
|
|
376
|
+
data: string;
|
|
377
|
+
enumValues: [string, ...string[]];
|
|
378
|
+
driverParam: string;
|
|
379
|
+
}, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
|
|
380
|
+
size: undefined;
|
|
381
|
+
}>;
|
|
382
|
+
completedProfile: import("drizzle-orm/pg-core").PgColumn<{
|
|
383
|
+
name: "completed_profile";
|
|
384
|
+
tableName: "session";
|
|
385
|
+
dataType: "boolean";
|
|
386
|
+
columnType: "PgBoolean";
|
|
387
|
+
data: boolean;
|
|
388
|
+
driverParam: boolean;
|
|
389
|
+
notNull: true;
|
|
390
|
+
hasDefault: true;
|
|
391
|
+
isPrimaryKey: false;
|
|
392
|
+
isAutoincrement: false;
|
|
393
|
+
hasRuntimeDefault: false;
|
|
394
|
+
enumValues: undefined;
|
|
395
|
+
baseColumn: never;
|
|
396
|
+
identity: undefined;
|
|
397
|
+
generated: undefined;
|
|
398
|
+
}, {}, {}>;
|
|
339
399
|
};
|
|
340
400
|
dialect: "pg";
|
|
341
401
|
}>;
|
|
@@ -765,6 +825,23 @@ export declare const userSettings: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
765
825
|
identity: undefined;
|
|
766
826
|
generated: undefined;
|
|
767
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
|
+
}, {}, {}>;
|
|
768
845
|
university: import("drizzle-orm/pg-core").PgColumn<{
|
|
769
846
|
name: "university";
|
|
770
847
|
tableName: "user_settings";
|
|
@@ -816,6 +893,23 @@ export declare const userSettings: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
816
893
|
identity: undefined;
|
|
817
894
|
generated: undefined;
|
|
818
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
|
+
}, {}, {}>;
|
|
819
913
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
820
914
|
name: "created_at";
|
|
821
915
|
tableName: "user_settings";
|
|
@@ -920,6 +920,23 @@ export declare const cardReviews: import("drizzle-orm/pg-core").PgTableWithColum
|
|
|
920
920
|
identity: undefined;
|
|
921
921
|
generated: undefined;
|
|
922
922
|
}, {}, {}>;
|
|
923
|
+
suspended: import("drizzle-orm/pg-core").PgColumn<{
|
|
924
|
+
name: "suspended";
|
|
925
|
+
tableName: "card_review";
|
|
926
|
+
dataType: "boolean";
|
|
927
|
+
columnType: "PgBoolean";
|
|
928
|
+
data: boolean;
|
|
929
|
+
driverParam: boolean;
|
|
930
|
+
notNull: true;
|
|
931
|
+
hasDefault: true;
|
|
932
|
+
isPrimaryKey: false;
|
|
933
|
+
isAutoincrement: false;
|
|
934
|
+
hasRuntimeDefault: false;
|
|
935
|
+
enumValues: undefined;
|
|
936
|
+
baseColumn: never;
|
|
937
|
+
identity: undefined;
|
|
938
|
+
generated: undefined;
|
|
939
|
+
}, {}, {}>;
|
|
923
940
|
userDeckStudyId: import("drizzle-orm/pg-core").PgColumn<{
|
|
924
941
|
name: "user_deck_study_id";
|
|
925
942
|
tableName: "card_review";
|
|
@@ -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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const EMAILFooter
|
|
1
|
+
export declare const EMAILFooter: string;
|
|
@@ -2,8 +2,10 @@ import { type EmailAccountDeletionValues } from './accountDeletion';
|
|
|
2
2
|
import { type EmailAdminPurchaseAlertValues } from './adminPurchaseAlert';
|
|
3
3
|
import { type EmailCardDemandValues } from './cardDemand';
|
|
4
4
|
import { type EmailCardDemandActionValues } from './cardDemandAction';
|
|
5
|
+
import { type EmailDeleteAccountRequestValues } from './deleteAccountRequest';
|
|
5
6
|
import { type EmailConfirmAccountValues } from './emailVerification';
|
|
6
7
|
import { type EmailForgotPasswordValues } from './forgotPassword';
|
|
8
|
+
import { type EmailPaymentExpiryReminderValues } from './paymentExpiryReminder';
|
|
7
9
|
import { type EmailPurchaseConfirmationValues } from './purchaseConfirmation';
|
|
8
10
|
import { type EmailPrePaymentDetailsValues } from './purchasePrePayment';
|
|
9
11
|
import { type EmailPurchaseRefundValues } from './purchaseRefund';
|
|
@@ -19,8 +21,10 @@ export interface EmailTemplateFunctions {
|
|
|
19
21
|
PurchaseConfirmation: (data: EmailPurchaseConfirmationValues) => EmailTemplateType;
|
|
20
22
|
AdminPurchaseAlert: (data: EmailAdminPurchaseAlertValues) => EmailTemplateType;
|
|
21
23
|
AccountDeletion: (data: EmailAccountDeletionValues) => EmailTemplateType;
|
|
24
|
+
DeleteAccountRequest: (data: EmailDeleteAccountRequestValues) => EmailTemplateType;
|
|
22
25
|
CardDemand: (data: EmailCardDemandValues) => EmailTemplateType;
|
|
23
26
|
CardDemandAction: (data: EmailCardDemandActionValues) => EmailTemplateType;
|
|
27
|
+
PaymentExpiryReminder: (data: EmailPaymentExpiryReminderValues) => EmailTemplateType;
|
|
24
28
|
}
|
|
25
29
|
export type EmailTemplate = keyof EmailTemplateFunctions;
|
|
26
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,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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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;
|
|
4
|
+
export declare const MAX_CARDS_TO_FETCH = 50;
|
|
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
|
+
};
|
|
19
|
+
export declare const THRESHOLD_CARDS_FOR_REFETCH = 10;
|
|
20
|
+
export declare const isRecommendedLearningSettings: (learnDailyLimit: number | null, newCardsPerDeckDailyLimit: number | null) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Card as FSRSCard } from 'ts-fsrs';
|
|
2
|
+
import { type ReviewRating } from '../types/fsrs';
|
|
3
|
+
import type { ICardReview, IReviewLog } from '../types/study';
|
|
4
|
+
export declare const gradeCard: (card: ICardReview, rating: ReviewRating, durationInSeconds: number) => {
|
|
5
|
+
nextCard: ICardReview;
|
|
6
|
+
reviewLog: IReviewLog;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Give a {@link ICardReview}, returns the review {@link Date} for each {@link ReviewRating}.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getReviewDateForEachRating(card: ICardReview): Record<ReviewRating, Date>;
|
|
12
|
+
export declare function mergeFsrsCard(fsrsCard: FSRSCard, card: ICardReview): ICardReview;
|
|
13
|
+
export declare function newCardReview(userDeckStudyId: string, cardId: string): ICardReview;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReviewRating } from '../types/fsrs';
|
|
2
|
+
import type { ISessionCard, ISessionData } from '../types/study';
|
|
3
|
+
export declare const RECENTLY_REVIEWED_SET_SIZE = 5;
|
|
4
|
+
export declare const defaultSessionData: ISessionData;
|
|
5
|
+
export interface SessionProgress {
|
|
6
|
+
reviewsCompleted: number;
|
|
7
|
+
correctGrades: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Encapsulates the stateful logic shared across platforms for a flashcard study session:
|
|
11
|
+
* - Recently-reviewed set (prevents immediate card repetition)
|
|
12
|
+
* - Progress counters (total reviews, correct grades)
|
|
13
|
+
* - Next card selection (delegates to getNextCardFromSession)
|
|
14
|
+
*
|
|
15
|
+
* Usage: hold an instance in a ref (React/RN), call nextCard() on each render
|
|
16
|
+
* and onRate() whenever the user grades a card.
|
|
17
|
+
*/
|
|
18
|
+
export declare class FlashcardSessionManager {
|
|
19
|
+
private recentlyReviewed;
|
|
20
|
+
private _reviewsCompleted;
|
|
21
|
+
private _correctGrades;
|
|
22
|
+
getProgress(): SessionProgress;
|
|
23
|
+
nextCard(data: ISessionData): ISessionCard | undefined;
|
|
24
|
+
onRate(cardId: string, rating: ReviewRating): SessionProgress;
|
|
25
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReviewRating } from '../types/fsrs';
|
|
2
|
+
import type { ISessionCard, ISessionData } from '../types/study';
|
|
3
|
+
export declare function getNextCardFromSession(data: ISessionData, recentlyReviewed?: Set<string>): ISessionCard | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Remove a card from session data without grading it (e.g. suspend + skip).
|
|
6
|
+
* Properly decrements the matching stats bucket and total.
|
|
7
|
+
*/
|
|
8
|
+
export declare function skipCardFromSessionData(data: ISessionData, cardId: string): ISessionData;
|
|
9
|
+
/**
|
|
10
|
+
* Computes the next session data after grading a card.
|
|
11
|
+
*
|
|
12
|
+
* Simulates the card grading and if the next review is within ~10 minutes,
|
|
13
|
+
* keeps the card in the session and updates the respective counter.
|
|
14
|
+
*
|
|
15
|
+
* If the card's state is `New`, then the card exists in `newCards`.
|
|
16
|
+
* If the card is any other state, then the card exists in `reviewCards`.
|
|
17
|
+
*
|
|
18
|
+
* @param grade The grade given to the card
|
|
19
|
+
* @param data The current session data
|
|
20
|
+
* @param cardId The id of the card that was graded
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeCardFromSessionData(grade: ReviewRating, data: ISessionData, cardId: string): ISessionData;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the card from the session data.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSessionCard(sessionData: ISessionData, cardId: string): ISessionCard | undefined;
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
273
|
+
readonly a4: string;
|
|
274
274
|
readonly a6: string;
|
|
275
275
|
readonly a7: string;
|
|
276
276
|
readonly a8: string;
|
|
@@ -50,3 +50,13 @@ export interface IDeckDetail extends IDeck {
|
|
|
50
50
|
ownerInfo: IOwnerInfo;
|
|
51
51
|
cards: ICard[];
|
|
52
52
|
}
|
|
53
|
+
export interface ICardUserState {
|
|
54
|
+
cardId: string;
|
|
55
|
+
suspended: boolean;
|
|
56
|
+
toReview: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface ICardMedia {
|
|
59
|
+
id: string;
|
|
60
|
+
side: 'front' | 'back';
|
|
61
|
+
url: string;
|
|
62
|
+
}
|
|
@@ -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
|
+
}
|