@timeback/masterytrack 0.1.1-beta.20260219190739

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 (41) hide show
  1. package/README.md +225 -0
  2. package/dist/client.d.ts +32 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/constants.d.ts +19 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/errors.d.ts +1 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +1504 -0
  9. package/dist/factory.d.ts +23 -0
  10. package/dist/factory.d.ts.map +1 -0
  11. package/dist/index.d.ts +449 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +16943 -0
  14. package/dist/lib/index.d.ts +4 -0
  15. package/dist/lib/index.d.ts.map +1 -0
  16. package/dist/lib/resolve.d.ts +25 -0
  17. package/dist/lib/resolve.d.ts.map +1 -0
  18. package/dist/lib/token-provider.d.ts +34 -0
  19. package/dist/lib/token-provider.d.ts.map +1 -0
  20. package/dist/lib/transport.d.ts +28 -0
  21. package/dist/lib/transport.d.ts.map +1 -0
  22. package/dist/public-types.d.ts +210 -0
  23. package/dist/public-types.d.ts.map +1 -0
  24. package/dist/public-types.js +0 -0
  25. package/dist/resources/assignments.d.ts +30 -0
  26. package/dist/resources/assignments.d.ts.map +1 -0
  27. package/dist/resources/authorizer.d.ts +22 -0
  28. package/dist/resources/authorizer.d.ts.map +1 -0
  29. package/dist/resources/index.d.ts +4 -0
  30. package/dist/resources/index.d.ts.map +1 -0
  31. package/dist/resources/inventory.d.ts +23 -0
  32. package/dist/resources/inventory.d.ts.map +1 -0
  33. package/dist/types/client.d.ts +61 -0
  34. package/dist/types/client.d.ts.map +1 -0
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/index.d.ts.map +1 -0
  37. package/dist/types.d.ts +2 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/utils.d.ts +11 -0
  40. package/dist/utils.d.ts.map +1 -0
  41. package/package.json +42 -0
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # @timeback/masterytrack
2
+
3
+ TypeScript client for the MasteryTrack API — test inventory, assignment delivery, and student assessment management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @timeback/masterytrack
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { MasteryTrackClient } from '@timeback/masterytrack'
15
+
16
+ const client = new MasteryTrackClient({
17
+ env: 'staging', // or 'production'
18
+ auth: {
19
+ apiKey: 'your-api-key',
20
+ email: 'your-registered-email@example.com',
21
+ },
22
+ })
23
+
24
+ // Search available tests
25
+ const { data: tests } = await client.inventory.search({ subject: 'Math' })
26
+
27
+ // Assign a test to a student
28
+ const result = await client.assignments.assign({
29
+ student_email: 'student@example.com',
30
+ timeback_id: '_677e37c49e904cafcc66fdb4',
31
+ })
32
+
33
+ // Invalidate an assignment
34
+ await client.assignments.invalidate({
35
+ student_email: 'student@example.com',
36
+ assignment_id: 123,
37
+ })
38
+ ```
39
+
40
+ ## Client Structure
41
+
42
+ ```typescript
43
+ const client = new MasteryTrackClient(options)
44
+
45
+ // Authentication
46
+ client.authorizer.getToken(email?) // Get a fresh JWT
47
+
48
+ // Inventory
49
+ client.inventory.search(params?) // Search and filter available tests
50
+
51
+ // Assignments
52
+ client.assignments.assign(input) // Assign a test to a student
53
+ client.assignments.invalidate(input) // Invalidate student assignments
54
+
55
+ // Utilities
56
+ client.checkAuth() // Verify credentials are valid
57
+ client.getTransport() // Access the underlying transport
58
+ ```
59
+
60
+ ### Inventory Search
61
+
62
+ Search and filter tests with optional parameters:
63
+
64
+ ```typescript
65
+ // List all supported tests
66
+ const { data } = await client.inventory.search()
67
+
68
+ // Filter by criteria
69
+ const { data } = await client.inventory.search({
70
+ name: 'Math',
71
+ grade: 'Third Grade',
72
+ subject: 'Math',
73
+ timeback_id: '_677e37c49e904cafcc66fdb4',
74
+ all: true, // include non-supported tests
75
+ })
76
+ ```
77
+
78
+ ### Assignments
79
+
80
+ Assign tests by `timeback_id` or by `subject` (optionally with `grade_rank`):
81
+
82
+ ```typescript
83
+ // Assign by timeback_id
84
+ await client.assignments.assign({
85
+ student_email: 'student@example.com',
86
+ timeback_id: '_677e37c49e904cafcc66fdb4',
87
+ })
88
+
89
+ // Assign by subject and grade
90
+ await client.assignments.assign({
91
+ student_email: 'student@example.com',
92
+ subject: 'Math',
93
+ grade_rank: 3,
94
+ })
95
+
96
+ // Invalidate by assignment ID
97
+ await client.assignments.invalidate({
98
+ student_email: 'student@example.com',
99
+ assignment_id: 123,
100
+ })
101
+
102
+ // Invalidate by timeback_id
103
+ await client.assignments.invalidate({
104
+ student_email: 'student@example.com',
105
+ timeback_id: '_677e37c49e904cafcc66fdb4',
106
+ })
107
+ ```
108
+
109
+ ### Authentication
110
+
111
+ MasteryTrack uses API key + email authentication (not OAuth2). The client handles JWT token acquisition and caching automatically:
112
+
113
+ ```typescript
114
+ // Environment mode (recommended)
115
+ const client = new MasteryTrackClient({
116
+ env: 'staging', // or 'production'
117
+ auth: {
118
+ apiKey: 'your-api-key',
119
+ email: 'your-registered-email@example.com',
120
+ },
121
+ })
122
+
123
+ // Explicit URL mode
124
+ const client = new MasteryTrackClient({
125
+ baseUrl: 'https://custom-api.example.com',
126
+ auth: {
127
+ apiKey: 'your-api-key',
128
+ email: 'your-registered-email@example.com',
129
+ },
130
+ })
131
+
132
+ // Verify credentials
133
+ const result = await client.checkAuth()
134
+ if (result.ok) {
135
+ console.log(`Auth OK (${result.latencyMs}ms)`)
136
+ }
137
+ ```
138
+
139
+ JWTs are cached and automatically refreshed before expiry.
140
+
141
+ ### Error Handling
142
+
143
+ ```typescript
144
+ import { MasteryTrackError, NotFoundError, UnauthorizedError } from '@timeback/masterytrack/errors'
145
+
146
+ try {
147
+ await client.assignments.assign(input)
148
+ } catch (error) {
149
+ if (error instanceof UnauthorizedError) {
150
+ console.log('Invalid API key or email')
151
+ } else if (error instanceof MasteryTrackError) {
152
+ console.log(error.statusCode) // HTTP status
153
+ console.log(error.message) // Error message
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### Custom Transport
159
+
160
+ For advanced use cases, provide your own transport and authenticator:
161
+
162
+ ```typescript
163
+ const client = new MasteryTrackClient({
164
+ transport: {
165
+ baseUrl: 'https://custom.example.com',
166
+ request: async (path, options) => { /* ... */ },
167
+ requestRaw: async (path, options) => { /* ... */ },
168
+ },
169
+ authenticator: {
170
+ getToken: async () => 'your-jwt',
171
+ invalidate: () => {},
172
+ checkAuth: async () => ({ ok: true, latencyMs: 0, checks: {} }),
173
+ },
174
+ })
175
+ ```
176
+
177
+ ## Configuration
178
+
179
+ ```typescript
180
+ new MasteryTrackClient({
181
+ // Environment mode (recommended)
182
+ env: 'staging' | 'production',
183
+ auth: {
184
+ apiKey: string,
185
+ email: string,
186
+ },
187
+
188
+ // OR Explicit URL mode
189
+ baseUrl: string,
190
+ auth: {
191
+ apiKey: string,
192
+ email: string,
193
+ },
194
+
195
+ // OR Custom transport mode
196
+ transport: MasteryTrackTransportLike,
197
+ authenticator: MasteryTrackAuthenticatorLike,
198
+
199
+ // Optional
200
+ timeout?: number, // Request timeout in ms (default: 30000)
201
+ })
202
+ ```
203
+
204
+ Environment variables fallback:
205
+
206
+ - `TIMEBACK_MASTERYTRACK_API_KEY` / `MASTERYTRACK_API_KEY`
207
+ - `TIMEBACK_MASTERYTRACK_EMAIL` / `MASTERYTRACK_EMAIL`
208
+ - `TIMEBACK_MASTERYTRACK_BASE_URL` / `MASTERYTRACK_BASE_URL`
209
+
210
+ ## Debug Mode
211
+
212
+ Enable debug logging by setting `DEBUG=1` or `DEBUG=true`:
213
+
214
+ ```bash
215
+ DEBUG=1 bun run my-script.ts
216
+ ```
217
+
218
+ This outputs detailed logs for HTTP requests and authentication:
219
+
220
+ ```bash
221
+ [2026-02-17T10:30:00.000Z] DEBUG [masterytrack:http] → POST https://api.example.com/authorizer
222
+ [2026-02-17T10:30:00.500Z] DEBUG [masterytrack:http] ← 200 OK (500ms)
223
+ [2026-02-17T10:30:00.501Z] DEBUG [masterytrack:http] → GET https://api.example.com/authoring/inventory/search
224
+ [2026-02-17T10:30:00.800Z] DEBUG [masterytrack:http] ← 200 OK (299ms)
225
+ ```
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MasteryTrack Client
3
+ *
4
+ * Main entry point for the MasteryTrack SDK.
5
+ */
6
+ /**
7
+ * MasteryTrack API client.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const client = new MasteryTrackClient({
12
+ * env: 'staging',
13
+ * auth: {
14
+ * apiKey: 'your-api-key',
15
+ * email: 'your-registered-email@example.com',
16
+ * },
17
+ * })
18
+ * ```
19
+ */
20
+ export declare const MasteryTrackClient: {
21
+ new (config?: import("./types").MasteryTrackClientConfig): {
22
+ readonly transport: import("./types").MasteryTrackTransportLike;
23
+ readonly authenticator: import("./types").MasteryTrackAuthenticatorLike;
24
+ readonly authorizer: import("./resources").AuthorizerResource;
25
+ readonly inventory: import("./resources").InventoryResource;
26
+ readonly assignments: import("./resources").AssignmentsResource;
27
+ getTransport(): import("./types").MasteryTrackTransportLike;
28
+ checkAuth(): Promise<import("@timeback/internal-client-infra").AuthCheckResult>;
29
+ };
30
+ };
31
+ export type { MasteryTrackClientInstance } from './types';
32
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;CAA6B,CAAA;AAE5D,YAAY,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * MasteryTrack Constants
3
+ *
4
+ * Configuration constants for the MasteryTrack client.
5
+ */
6
+ export declare const MASTERYTRACK_BASE_URLS: {
7
+ readonly staging: "https://l407b3xadi.execute-api.us-east-1.amazonaws.com/dev";
8
+ readonly production: "https://l407b3xadi.execute-api.us-east-1.amazonaws.com/prod";
9
+ };
10
+ /**
11
+ * Environment variable names for MasteryTrack configuration fallback.
12
+ * Priority: TIMEBACK_MASTERYTRACK_* > MASTERYTRACK_*
13
+ */
14
+ export declare const MASTERYTRACK_ENV_VARS: {
15
+ readonly baseUrl: readonly ["TIMEBACK_MASTERYTRACK_BASE_URL", "MASTERYTRACK_BASE_URL"];
16
+ readonly apiKey: readonly ["TIMEBACK_MASTERYTRACK_API_KEY", "MASTERYTRACK_API_KEY"];
17
+ readonly email: readonly ["TIMEBACK_MASTERYTRACK_EMAIL", "MASTERYTRACK_EMAIL"];
18
+ };
19
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,sBAAsB;;;CAGzB,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAA"}
@@ -0,0 +1 @@
1
+ export { ForbiddenError, InputValidationError, ApiError as MasteryTrackError, NotFoundError, UnauthorizedError, ValidationError } from '@timeback/internal-client-infra';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACN,QAAQ,IAAI,iBAAiB,EAC7B,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,CAAA"}