@playcademy/sandbox 0.1.11 → 0.2.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/README.md +43 -69
- package/dist/cli.js +1955 -682
- package/dist/config.js +1 -0
- package/dist/server.js +1952 -679
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -180,103 +180,77 @@ All production Playcademy APIs are available under the `/api` prefix, including
|
|
|
180
180
|
|
|
181
181
|
## TimeBack Integration Testing
|
|
182
182
|
|
|
183
|
-
The sandbox supports three
|
|
183
|
+
The sandbox supports TimeBack integration testing in three modes: mock (offline), local (Docker), and remote (real TimeBack API).
|
|
184
184
|
|
|
185
|
-
###
|
|
185
|
+
### TimeBack Modes
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
| Mode | Description |
|
|
188
|
+
| :----------- | :-------------------------------------------------------------------- |
|
|
189
|
+
| **Mock** | No external dependencies, works offline. Uses generated mock data. |
|
|
190
|
+
| **Local** | Connect to a local TimeBack instance (Docker). |
|
|
191
|
+
| **Remote** | Real course IDs + API credentials. Tests against actual TimeBack API. |
|
|
192
|
+
| **Disabled** | No TimeBack config. TimeBack routes return errors. |
|
|
188
193
|
|
|
189
|
-
|
|
190
|
-
# Enable local mode
|
|
191
|
-
TIMEBACK_LOCAL=true
|
|
194
|
+
### CLI Options
|
|
192
195
|
|
|
193
|
-
|
|
194
|
-
TIMEBACK_ONEROSTER_API_URL=http://localhost:9000
|
|
195
|
-
TIMEBACK_CALIPER_API_URL=http://localhost:9001
|
|
196
|
+
When running the sandbox standalone, configure TimeBack via CLI flags:
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
```bash
|
|
199
|
+
# Local TimeBack (Docker)
|
|
200
|
+
bunx @playcademy/sandbox \
|
|
201
|
+
--timeback-local \
|
|
202
|
+
--timeback-oneroster-url http://localhost:8080/ims/oneroster \
|
|
203
|
+
--timeback-caliper-url http://localhost:8080/caliper \
|
|
204
|
+
--timeback-student-id your-student-id
|
|
205
|
+
|
|
206
|
+
# Remote TimeBack (requires env vars for credentials)
|
|
207
|
+
bunx @playcademy/sandbox \
|
|
208
|
+
--timeback-student-id your-student-sourcedId
|
|
200
209
|
```
|
|
201
210
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
-
|
|
208
|
-
|
|
209
|
-
**Requirements:**
|
|
210
|
-
|
|
211
|
-
- Install and run `@superbuilders/timeback-local` Docker container
|
|
211
|
+
| Option | Description |
|
|
212
|
+
| :------------------------- | :---------------------------------- |
|
|
213
|
+
| `--timeback-local` | Enable local TimeBack mode (Docker) |
|
|
214
|
+
| `--timeback-oneroster-url` | OneRoster API URL |
|
|
215
|
+
| `--timeback-caliper-url` | Caliper API URL |
|
|
216
|
+
| `--timeback-course-id` | Course ID for enrollments |
|
|
217
|
+
| `--timeback-student-id` | Student ID to link to demo user |
|
|
212
218
|
|
|
213
|
-
###
|
|
219
|
+
### Environment Variables
|
|
214
220
|
|
|
215
|
-
|
|
221
|
+
For remote TimeBack (or as alternative to CLI flags):
|
|
216
222
|
|
|
217
223
|
```bash
|
|
218
|
-
#
|
|
224
|
+
# TimeBack API credentials (required for remote mode)
|
|
219
225
|
TIMEBACK_ONEROSTER_API_URL=https://api.timeback.org/ims/oneroster
|
|
220
226
|
TIMEBACK_API_CLIENT_ID=your-client-id
|
|
221
227
|
TIMEBACK_API_CLIENT_SECRET=your-client-secret
|
|
222
228
|
TIMEBACK_API_AUTH_URL=https://auth.timeback.org
|
|
223
229
|
|
|
224
|
-
#
|
|
225
|
-
SANDBOX_TIMEBACK_COURSE_ID=your-existing-course-id
|
|
230
|
+
# Link sandbox demo user to a real TimeBack student
|
|
226
231
|
SANDBOX_TIMEBACK_STUDENT_ID=your-student-sourcedId
|
|
232
|
+
SANDBOX_TIMEBACK_COURSE_ID=your-course-id
|
|
227
233
|
```
|
|
228
234
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
- ✅ Tests against real TimeBack
|
|
232
|
-
- ✅ See actual events in TimeBack dashboard
|
|
233
|
-
- ✅ Full production simulation
|
|
234
|
-
|
|
235
|
-
**Pre-Seeding (Required for Local Testing):**
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
SANDBOX_TIMEBACK_COURSE_ID=your-existing-course-id
|
|
239
|
-
SANDBOX_TIMEBACK_STUDENT_ID=your-existing-student-sourcedId
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
These are **required** (not optional) for local TimeBack testing because the sandbox uses mock authentication. CLI commands like `playcademy timeback setup` won't work against the sandbox - you must use existing TimeBack resources.
|
|
243
|
-
|
|
244
|
-
**How to get these IDs:**
|
|
245
|
-
|
|
246
|
-
1. Run `playcademy timeback setup` against the **platform** once (not sandbox)
|
|
247
|
-
2. Get `courseId` from the output or your TimeBack dashboard
|
|
248
|
-
3. Get `studentId` (sourcedId) from your TimeBack student roster
|
|
249
|
-
4. Set them in `.env` for future local development
|
|
250
|
-
|
|
251
|
-
What they do:
|
|
252
|
-
|
|
253
|
-
- `SANDBOX_TIMEBACK_COURSE_ID` - Links your game to an existing TimeBack course
|
|
254
|
-
- `SANDBOX_TIMEBACK_STUDENT_ID` - Links the sandbox demo user to a real TimeBack student
|
|
235
|
+
### With Vite Plugin
|
|
255
236
|
|
|
256
|
-
|
|
237
|
+
When using `@playcademy/vite-plugin`, TimeBack enrollments and roles can be configured directly in `vite.config.ts` for a streamlined experience. See the [Vite plugin documentation](../vite-plugin/README.md#timeback-options-timeback) for details.
|
|
257
238
|
|
|
258
|
-
|
|
239
|
+
The Vite plugin also provides a `t` hotkey to cycle through TimeBack roles during development.
|
|
259
240
|
|
|
260
|
-
### Runtime Testing
|
|
241
|
+
### Runtime Testing
|
|
261
242
|
|
|
262
|
-
Once
|
|
243
|
+
Once configured, your game can use the SDK to submit activities:
|
|
263
244
|
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
# 2. Test in your game - TimeBack just works!
|
|
269
|
-
client.timeback.endActivity({
|
|
270
|
-
activityData: { activityId: 'test-1' },
|
|
271
|
-
scoreData: { correctQuestions: 8, totalQuestions: 10 },
|
|
272
|
-
timingData: { durationSeconds: 300 }
|
|
245
|
+
```typescript
|
|
246
|
+
await client.timeback.endActivity({
|
|
247
|
+
correctQuestions: 8,
|
|
248
|
+
totalQuestions: 10,
|
|
273
249
|
})
|
|
274
|
-
|
|
275
|
-
# 3. Check your TimeBack dashboard - events appear in real-time!
|
|
276
250
|
```
|
|
277
251
|
|
|
278
252
|
**Note on CLI Commands:**
|
|
279
|
-
The sandbox provides TimeBack management endpoints, but CLI commands (`playcademy timeback setup`, `verify`) require Better Auth authentication and won't work against the sandbox. These commands should be run against the platform.
|
|
253
|
+
The sandbox provides TimeBack management endpoints, but CLI commands (`playcademy timeback setup`, `verify`) require Better Auth authentication and won't work against the sandbox. These commands should be run against the platform.
|
|
280
254
|
|
|
281
255
|
### Available TimeBack Endpoints
|
|
282
256
|
|