@pocketprep/types 1.16.26 → 1.18.1

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,12 @@
1
+ /**
2
+ * Common base for every API response resource.
3
+ *
4
+ * Responses are Parse-free and use ISO-8601 timestamp strings. Pointer
5
+ * fields hold raw id strings (or string arrays); the Nest repository layer
6
+ * translates Mongo storage shape into this contract at the boundary.
7
+ */
8
+ export interface BaseResource {
9
+ id: string
10
+ createdAt: string
11
+ updatedAt: string
12
+ }
@@ -0,0 +1,82 @@
1
+ import { BaseResource } from './BaseResource'
2
+
3
+ export interface MockExam extends BaseResource {
4
+ name: string
5
+ description?: string
6
+ enabled: boolean
7
+ durationSeconds: number
8
+ questionSerials: string[]
9
+ }
10
+
11
+ export interface ExamMetadata extends BaseResource {
12
+ hideReferences: boolean
13
+ examGuid: string
14
+ archivedCount: number
15
+ freeCount?: number
16
+ totalCount?: number
17
+ nativeAppName: string
18
+ releaseInfo?: {
19
+ name: string
20
+ description: string
21
+ message: string
22
+ }
23
+ descriptiveName: string
24
+ version: string
25
+ compositeKey: string
26
+ description?: string
27
+ isFree: boolean
28
+ /** Ids of the MockExams associated with this exam. */
29
+ mockExams: string[]
30
+ sunsetAt?: string
31
+ minorVersionMessaging?: {
32
+ type: 'newQuestions' | 'newMockExams'
33
+ count: number
34
+ }
35
+ appId?: string
36
+ knowledgeAreas?: {
37
+ [key: string]: {
38
+ name: string
39
+ count: number
40
+ specialCount: number
41
+ }
42
+ }
43
+ itemCount?: number
44
+ classicQuestions?: number
45
+ specialQuestions?: number
46
+ }
47
+
48
+ export interface Bundle extends BaseResource {
49
+ name: string
50
+ /** Ids of the ExamMetadata records in this bundle. */
51
+ exams: string[]
52
+ ios?: {
53
+ currentVersion: string
54
+ minVersion: string
55
+ appStoreId: string
56
+ appStoreURI: string
57
+ appStoreIds: string[]
58
+ }
59
+ android?: {
60
+ currentVersion: string
61
+ minVersion: string
62
+ appStoreId: string
63
+ appStoreURI: string
64
+ appStoreIds: string[]
65
+ }
66
+ isDisabled: boolean
67
+ seatPricingModel?: {
68
+ costPerSeat: number
69
+ customExamPrices?: { [examGuid: string]: number }
70
+ }
71
+ }
72
+
73
+ export interface FetchBundlesParams {
74
+ platform?: 'iOS' | 'Android'
75
+ appStoreId?: string
76
+ }
77
+
78
+ export interface FetchBundlesResponse {
79
+ bundles: Bundle[]
80
+ exams: ExamMetadata[]
81
+ mockExams: MockExam[]
82
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseResource } from './BaseResource'
2
+
3
+ export interface KeywordDefinition extends BaseResource {
4
+ keyword: string
5
+ definition: string
6
+ serial: string
7
+ /** ExamMetadata id (pointer flattened). */
8
+ examMetadata?: string
9
+ }
10
+
11
+ export interface SearchKeywordDefinitionsParams {
12
+ examMetadataId: string
13
+ serials: string[]
14
+ }
15
+
16
+ export interface SearchKeywordDefinitionsResponse {
17
+ keywords: KeywordDefinition[]
18
+ }
@@ -0,0 +1,7 @@
1
+ export interface CheckLevelUpEligibilityParams {
2
+ examGuid: string
3
+ }
4
+
5
+ export interface CheckLevelUpEligibilityResponse {
6
+ eligible: boolean
7
+ }
@@ -0,0 +1,74 @@
1
+ import { BloomTaxonomyLevel, Subtopic } from '../Study/Class'
2
+ import { IMatrixLabels, TPassageLabel } from '../CMS/Class'
3
+
4
+ import { BaseResource } from './BaseResource'
5
+
6
+ /** Shape of an individual choice on a Question. Matches Parse's stored shape. */
7
+ export interface QuestionChoice {
8
+ text?: string
9
+ isCorrect: boolean
10
+ id: string
11
+ labelIndex?: number
12
+ }
13
+
14
+ /** Image-with-alt structure used by passage and explanation. */
15
+ export interface QuestionImage {
16
+ url: string
17
+ altText: string
18
+ longAltText?: string
19
+ }
20
+
21
+ export interface Question extends BaseResource {
22
+ prompt: string
23
+ /** Subject id (pointer flattened). */
24
+ subject: string
25
+ subtopicId?: string
26
+ bloomTaxonomyLevel?: BloomTaxonomyLevel
27
+ choices: QuestionChoice[]
28
+ passage?: string
29
+ passageImage?: QuestionImage
30
+ explanation?: string
31
+ explanationImage?: QuestionImage
32
+ references?: string[]
33
+ serial: string
34
+ /** ExamMetadata id (pointer flattened). */
35
+ examMetadata: string
36
+ compositeKey: string
37
+ type:
38
+ | 'Multiple Choice'
39
+ | 'Multiple Correct Response'
40
+ | 'True/False'
41
+ | 'Matrix Checkbox'
42
+ | 'Matrix Radio Button'
43
+ | 'Multi-Part Multiple Choice'
44
+ | 'Build List'
45
+ addedDate: string
46
+ isArchived: boolean
47
+ isFree: boolean
48
+ isMockQuestion: boolean
49
+ /** QuestionScenario id (pointer flattened, optional). */
50
+ questionScenario?: string
51
+ matrixLabels?: IMatrixLabels
52
+ matrixChoiceLayout?: string[][]
53
+ passageLabel?: TPassageLabel
54
+ mpmcLabels?: string[]
55
+ }
56
+
57
+ export interface Subject extends BaseResource {
58
+ name: string
59
+ isArchived: boolean
60
+ /** ExamMetadata id (pointer flattened). */
61
+ examMetadata: string
62
+ questionCount?: number
63
+ subtopics?: Subtopic[]
64
+ }
65
+
66
+ export interface FetchQotdParams {
67
+ daysSinceEpoch: number
68
+ count?: number
69
+ }
70
+
71
+ export interface FetchQotdResponse {
72
+ questions: Question[]
73
+ subjects: Subject[]
74
+ }
@@ -0,0 +1,9 @@
1
+ import { BaseResource } from './BaseResource'
2
+
3
+ export interface Session extends BaseResource {
4
+ sessionToken: string
5
+ expiresAt: string
6
+ /** User id (pointer flattened). */
7
+ user: string
8
+ createdWith?: { action: string; authProvider: string }
9
+ }
package/API/User.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { BaseResource } from './BaseResource'
2
+
3
+ export interface QuizSettings {
4
+ showCheckAnswerButton?: boolean
5
+ showAnswersAtEnd?: boolean
6
+ enableKeyboardShortcuts?: boolean
7
+ }
8
+
9
+ /**
10
+ * User response shape. Sensitive columns (`password`, `_hashed_password`,
11
+ * `stripeCustomerId`) are stripped at the flatten boundary so they never
12
+ * reach this contract.
13
+ */
14
+ export interface User extends BaseResource {
15
+ email: string
16
+ firstName?: string
17
+ lastName?: string
18
+ username?: string
19
+ company?: string
20
+ currentApp?: string
21
+ currentExamGuid?: string
22
+ /** UserExamMetadata id (pointer flattened — UEM itself is no longer hydrated). */
23
+ currentUserExamMetadata?: string
24
+ lastActiveAt?: string
25
+ onboardingCompleted?: boolean
26
+ quizSettings?: QuizSettings
27
+ title?: string
28
+ version?: string
29
+ webConfig?: Record<string, unknown>
30
+ }
package/API/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './BaseResource'
2
+ export * from './Bundle'
3
+ export * from './Question'
4
+ export * from './KeywordDefinition'
5
+ export * from './Session'
6
+ export * from './User'
7
+ export * from './LevelUp'
@@ -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/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import * as CMS from './CMS'
4
4
  import * as Teach from './Teach'
5
5
  import * as Support from './Support'
6
6
  import * as AI from './AI'
7
+ import * as API from './API'
7
8
 
8
9
  export {
9
10
  Study,
@@ -11,6 +12,7 @@ export {
11
12
  Teach,
12
13
  Support,
13
14
  AI,
15
+ API,
14
16
  }
15
17
 
16
18
  export type Payload<T extends Parse.Object> = T extends Parse.Object<infer R>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/types",
3
- "version": "1.16.26",
3
+ "version": "1.18.1",
4
4
  "description": "Pocket Prep type declarations",
5
5
  "repository": {
6
6
  "type": "git",