@pocketprep/types 1.16.26 → 1.17.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.
@@ -0,0 +1,56 @@
1
+ import { UserJSON } from '../Class'
2
+
3
+ /**
4
+ * REST API contracts for the Nest `AuthController`.
5
+ */
6
+
7
+ /**
8
+ * POST /auth/register
9
+ *
10
+ * Create a new user account. Returns the persisted user with sensitive
11
+ * fields (password hashes, Stripe customer id) stripped.
12
+ */
13
+ export type register = (params: {
14
+ email: string
15
+ password: string
16
+ name: string
17
+ }) => UserJSON
18
+
19
+ /**
20
+ * POST /auth/login
21
+ *
22
+ * Exchange credentials for a session token. Returns a deliberately trimmed
23
+ * user envelope — only the fields a client needs immediately after login.
24
+ * Full user data is available via /users/me using the returned session token.
25
+ */
26
+ export type login = (params: {
27
+ email: string
28
+ password: string
29
+ }) => {
30
+ sessionToken: string
31
+ user: {
32
+ id: string
33
+ email: string
34
+ firstName?: string
35
+ lastName?: string
36
+ }
37
+ }
38
+
39
+ /**
40
+ * GET /auth/profile
41
+ *
42
+ * Returns the authenticated user with sensitive fields stripped. Equivalent
43
+ * to GET /users/me but lives under /auth for legacy compatibility.
44
+ */
45
+ export type getProfile = () => UserJSON
46
+
47
+ /**
48
+ * POST /auth/logout
49
+ *
50
+ * Invalidates the session token supplied via the `x-parse-session-token`
51
+ * header. Always responds with a generic success message regardless of
52
+ * whether the token was already invalid.
53
+ */
54
+ export type logout = () => {
55
+ message: string
56
+ }
@@ -0,0 +1,20 @@
1
+ import { BundleJSON } from '../Class'
2
+
3
+ /**
4
+ * REST API contracts for the Nest `BundlesController`.
5
+ */
6
+
7
+ /**
8
+ * GET /bundles
9
+ *
10
+ * Fetch active bundles. When both `platform` and `appStoreId` are supplied,
11
+ * results are filtered to bundles matching that App Store entry; otherwise
12
+ * all active bundles are returned. Supplying only one of the two is an
13
+ * error (HTTP 400).
14
+ */
15
+ export type fetchBundles = (params: {
16
+ platform?: 'iOS' | 'Android'
17
+ appStoreId?: string
18
+ }) => {
19
+ bundles: BundleJSON[]
20
+ }
@@ -0,0 +1,185 @@
1
+ import {
2
+ ConceptQuizJSON,
3
+ ExamMetadataJSON,
4
+ GlobalQuestionMetricJSON,
5
+ LicenseJSON,
6
+ PrebuiltQuizJSON,
7
+ QuestionJSON,
8
+ QuizJSON,
9
+ SubscriptionJSON,
10
+ UserExamMetadataJSON,
11
+ UserJSON,
12
+ } from '../Class'
13
+ import { TLevelUpProgress } from '../Cloud'
14
+
15
+ /**
16
+ * REST API contracts for the Nest `ExamsController`.
17
+ *
18
+ * Mirrors the `Study.Cloud` convention: each endpoint is exported as a
19
+ * callable type signature whose first argument is the request payload
20
+ * (path + query + body merged) and whose return type is the response body.
21
+ *
22
+ * Consume via:
23
+ * type Params = Parameters<Study.Api.Exams.fetchQotd>[0]
24
+ * type Response = ReturnType<Study.Api.Exams.fetchQotd>
25
+ */
26
+
27
+ /**
28
+ * Subset of `Question` shape returned by the keyword search endpoint —
29
+ * intentionally trimmed for clients that only need a quick keyword glossary.
30
+ */
31
+ export interface KeywordSummary {
32
+ serial: string
33
+ keyword: string
34
+ definition: string
35
+ }
36
+
37
+ /**
38
+ * GET /exams/:examMetadataId/qotd
39
+ *
40
+ * Returns one or more Question(s) of the Day for the given exam.
41
+ * The day is clamped to within ±1 of today server-side; clients
42
+ * cannot request arbitrary historical or future questions.
43
+ */
44
+ export type fetchQotd = (params: {
45
+ examMetadataId: string
46
+ daysSinceEpoch: number
47
+ count?: number
48
+ }) => QuestionJSON[]
49
+
50
+ /**
51
+ * GET /exams/:examMetadataId/questions/quiz
52
+ *
53
+ * Build a quiz: select `questionCount` eligible questions for the user,
54
+ * filtered by subject and quiz-mode-style `include` flags. The
55
+ * `result` envelope mirrors the legacy Cloud function's response shape.
56
+ */
57
+ export type fetchQuizQuestions = (params: {
58
+ examMetadataId: string
59
+ questionCount: number
60
+ quizMode?: number
61
+ subjectIds?: string[]
62
+ includeNew?: boolean
63
+ includeAnswered?: boolean
64
+ includeFlagged?: boolean
65
+ includeIncorrect?: boolean
66
+ includeMatrixQuestions?: boolean
67
+ includeBuildListQuestions?: boolean
68
+ includeMPMCQuestions?: boolean
69
+ }) => {
70
+ result: QuestionJSON[]
71
+ }
72
+
73
+ /**
74
+ * GET /exams/:examMetadataId/question-metrics
75
+ *
76
+ * Returns global (cross-user, aggregate) metrics for the supplied question
77
+ * serials, or every question on the exam if `serials` is omitted.
78
+ * Duplicate metric rows per serial are collapsed by most-recent
79
+ * `_updated_at`.
80
+ */
81
+ export type fetchGlobalQuestionMetrics = (params: {
82
+ examMetadataId: string
83
+ serials?: string[]
84
+ }) => GlobalQuestionMetricJSON[]
85
+
86
+ /**
87
+ * POST /exams/:examMetadataId/keyword-definitions/search
88
+ *
89
+ * Returns the keyword glossary entries for the supplied question serials.
90
+ * POST + `/search` suffix is used so the (potentially unbounded) `serials`
91
+ * array doesn't need to live in a query string.
92
+ */
93
+ export type searchKeywordDefinitions = (params: {
94
+ examMetadataId: string
95
+ serials: string[]
96
+ }) => {
97
+ keywords: KeywordSummary[]
98
+ }
99
+
100
+ /**
101
+ * POST /exams/:examMetadataId/questions/by-quiz-ids
102
+ *
103
+ * Returns the full set of questions that appeared in the given quizzes,
104
+ * scoped to the authenticated user. Used by clients to rehydrate quiz
105
+ * history without re-fetching the full question pool.
106
+ */
107
+ export type fetchQuestionsByQuizIds = (params: {
108
+ examMetadataId: string
109
+ quizIds: string[]
110
+ }) => QuestionJSON[]
111
+
112
+ /**
113
+ * POST /exams/:examMetadataId/quiz
114
+ *
115
+ * Records a completed quiz and triggers downstream side effects:
116
+ * answer updates, global metrics, level-up progress, and (optionally)
117
+ * a recommended next quiz.
118
+ */
119
+ export type recordQuiz = (params: {
120
+ examMetadataId: string
121
+ answers: {
122
+ isCorrect: boolean
123
+ selectedChoices: string[]
124
+ questionSerial: string
125
+ }[]
126
+ durationSeconds: number
127
+ mode: number
128
+ platform: string
129
+ startedAt: string
130
+ mockExamId?: string
131
+ levelSubjectId?: string
132
+ prebuiltQuizId?: string
133
+ conceptQuizId?: string
134
+ includeRecommendedNext?: boolean
135
+ }) => {
136
+ quiz: QuizJSON
137
+ globalMetrics: GlobalQuestionMetricJSON[]
138
+ levelUpProgress?: TLevelUpProgress
139
+ feedback?: {
140
+ progressDescription?: string
141
+ }
142
+ }
143
+
144
+ /**
145
+ * GET /exams/:examMetadataId/user-data
146
+ *
147
+ * Bulk-fetch every piece of state the client needs for an exam in one
148
+ * round trip: user, exam metadata, quiz history, subscriptions, referral
149
+ * info, level-up data, optional question metrics, assignments, licenses,
150
+ * and concept quizzes. `lastFetchedAt` lets clients pull only deltas.
151
+ */
152
+ export type fetchUserData = (params: {
153
+ examMetadataId: string
154
+ lastFetchedAt?: string
155
+ includeQuestionMetrics?: boolean
156
+ }) => {
157
+ user: UserJSON
158
+ examMetadata: ExamMetadataJSON
159
+ userExamMetadata?: UserExamMetadataJSON
160
+ quizzes: QuizJSON[]
161
+ subscriptions: SubscriptionJSON[]
162
+ referralInfo?: {
163
+ redeemedUsersCount: number
164
+ code: string
165
+ }
166
+ subjectsWithLevels: {
167
+ subjectName: string
168
+ subjectId: string
169
+ levels: number[]
170
+ }[]
171
+ questionMetrics?: {
172
+ answeredCorrectlyCount: number
173
+ answeredIncorrectlyCount: number
174
+ questionSerial: string
175
+ choiceStats: Partial<Record<string, number>>
176
+ examGuid: string
177
+ objectId: string
178
+ }[]
179
+ assignments: PrebuiltQuizJSON[]
180
+ licenses: LicenseJSON[]
181
+ userFlags: {
182
+ assignmentsEnabled: boolean
183
+ }
184
+ conceptQuizzes?: ConceptQuizJSON[]
185
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * REST API contracts for the Nest `LevelUpController`.
3
+ */
4
+
5
+ /**
6
+ * GET /level-up/eligibility
7
+ *
8
+ * Returns whether the given exam (or its parent bundle) is enrolled in the
9
+ * LevelUp adaptive-difficulty program.
10
+ */
11
+ export type checkLevelUpEligibility = (params: {
12
+ examGuid: string
13
+ }) => {
14
+ eligible: boolean
15
+ }
@@ -0,0 +1,37 @@
1
+ import { UserJSON, UserExamMetadataJSON } from '../Class'
2
+
3
+ /**
4
+ * REST API contracts for the Nest `UsersController`.
5
+ */
6
+
7
+ /**
8
+ * GET /users/me
9
+ *
10
+ * Returns the authenticated user (with currentUserExamMetadata hydrated).
11
+ * Sensitive fields (password hashes, Stripe customer id) are stripped at
12
+ * the schema's `toJSON` boundary.
13
+ */
14
+ export type getCurrentUser = () => UserJSON
15
+
16
+ /**
17
+ * GET /users
18
+ *
19
+ * Returns every user in the system, sensitive fields stripped. Listing
20
+ * endpoint — should be admin-gated at the route level.
21
+ */
22
+ export type findAll = () => UserJSON[]
23
+
24
+ /**
25
+ * PUT /users/me/current-exam
26
+ *
27
+ * Sets the authenticated user's currently-selected exam. Finds or creates
28
+ * the corresponding `UserExamMetadata`. Short-circuits with
29
+ * `isSameExam: true` when the user is already on the requested exam.
30
+ */
31
+ export type updateCurrentExam = (params: {
32
+ examMetadataId: string
33
+ }) => {
34
+ isSameExam: boolean
35
+ isBrandNewExam: boolean
36
+ uem: UserExamMetadataJSON
37
+ }
@@ -0,0 +1,7 @@
1
+ import * as Auth from './Auth'
2
+ import * as Bundles from './Bundles'
3
+ import * as Exams from './Exams'
4
+ import * as LevelUp from './LevelUp'
5
+ import * as Users from './Users'
6
+
7
+ export { Auth, Bundles, Exams, LevelUp, Users }
package/Study/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
+ import * as Api from './Api'
1
2
  import * as Class from './Class'
2
3
  import * as Cloud from './Cloud'
3
4
 
4
- export { Class, Cloud }
5
+ export { Api, Class, Cloud }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/types",
3
- "version": "1.16.26",
3
+ "version": "1.17.0",
4
4
  "description": "Pocket Prep type declarations",
5
5
  "repository": {
6
6
  "type": "git",