@playcademy/sandbox 0.3.2 → 0.3.4
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 +39 -49
- package/dist/cli.js +10387 -23763
- package/dist/server.d.ts +0 -33
- package/dist/server.js +70695 -84086
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Local development server for isolated Playcademy game development.**
|
|
4
4
|
|
|
5
|
-
The Playcademy sandbox provides a complete local simulation of the Playcademy platform
|
|
5
|
+
The Playcademy sandbox provides a complete local simulation of the Playcademy platform API for development and testing.
|
|
6
6
|
|
|
7
7
|
## What is the Sandbox?
|
|
8
8
|
|
|
@@ -20,21 +20,18 @@ It's a "mock Playcademy platform" running on your machine that behaves just like
|
|
|
20
20
|
- **Isolated Environment**: Completely local execution with no external dependencies.
|
|
21
21
|
- **Zero Configuration**: Automatic database setup and seeding.
|
|
22
22
|
- **Full API Compatibility**: All Playcademy APIs available locally.
|
|
23
|
-
- **Integrated Real-time Server**: Built-in WebSocket server for multiplayer features.
|
|
24
23
|
- **Fast Development Cycle**: Quick startup with persistent local database.
|
|
25
24
|
|
|
26
25
|
## How It Works
|
|
27
26
|
|
|
28
|
-
The sandbox runs
|
|
27
|
+
The sandbox runs a local API server to provide a complete development environment. When using our Vite templates, this is handled automatically.
|
|
29
28
|
|
|
30
29
|
```mermaid
|
|
31
30
|
graph TD
|
|
32
31
|
subgraph "Your Machine"
|
|
33
32
|
A["Your Game (in browser)"] --> B["@playcademy/sdk"];
|
|
34
33
|
B --> C["API Server (localhost:4321)"];
|
|
35
|
-
|
|
36
|
-
C --> E["Local PGlite Database"];
|
|
37
|
-
D --> E;
|
|
34
|
+
C --> D["Local PGlite Database"];
|
|
38
35
|
end
|
|
39
36
|
```
|
|
40
37
|
|
|
@@ -66,7 +63,7 @@ npm run dev
|
|
|
66
63
|
|
|
67
64
|
:::
|
|
68
65
|
|
|
69
|
-
You'll see output confirming that
|
|
66
|
+
You'll see output confirming that the sandbox is running:
|
|
70
67
|
|
|
71
68
|
```
|
|
72
69
|
VITE v6.3.5
|
|
@@ -77,8 +74,7 @@ VITE v6.3.5
|
|
|
77
74
|
PLAYCADEMY v0.1.0
|
|
78
75
|
|
|
79
76
|
➜ Game: playground
|
|
80
|
-
➜
|
|
81
|
-
➜ Realtime: ws://localhost:4322
|
|
77
|
+
➜ Sandbox: http://localhost:4321/api
|
|
82
78
|
```
|
|
83
79
|
|
|
84
80
|
```typescript
|
|
@@ -92,11 +88,6 @@ export default defineConfig({
|
|
|
92
88
|
playcademy({
|
|
93
89
|
sandbox: {
|
|
94
90
|
autoStart: true,
|
|
95
|
-
url: 'http://localhost:4321/api',
|
|
96
|
-
realtime: {
|
|
97
|
-
enabled: true,
|
|
98
|
-
port: 4322,
|
|
99
|
-
},
|
|
100
91
|
},
|
|
101
92
|
}),
|
|
102
93
|
],
|
|
@@ -113,39 +104,38 @@ You can run the sandbox as a standalone process from the command line.
|
|
|
113
104
|
# Run with defaults
|
|
114
105
|
bunx @playcademy/sandbox
|
|
115
106
|
|
|
116
|
-
# Run with custom
|
|
117
|
-
bunx @playcademy/sandbox --port 8080 --
|
|
107
|
+
# Run with custom port and verbose logging
|
|
108
|
+
bunx @playcademy/sandbox --port 8080 --verbose
|
|
118
109
|
```
|
|
119
110
|
|
|
120
111
|
```bash [pnpm]
|
|
121
|
-
pnpm dlx @playcademy/sandbox --port 8080 --
|
|
112
|
+
pnpm dlx @playcademy/sandbox --port 8080 --verbose
|
|
122
113
|
```
|
|
123
114
|
|
|
124
115
|
```bash [yarn]
|
|
125
|
-
yarn dlx @playcademy/sandbox --port 8080 --
|
|
116
|
+
yarn dlx @playcademy/sandbox --port 8080 --verbose
|
|
126
117
|
```
|
|
127
118
|
|
|
128
119
|
```bash [npm]
|
|
129
|
-
npx @playcademy/sandbox --port 8080 --
|
|
120
|
+
npx @playcademy/sandbox --port 8080 --verbose
|
|
130
121
|
```
|
|
131
122
|
|
|
132
123
|
:::
|
|
133
124
|
|
|
134
125
|
#### Command-Line Options
|
|
135
126
|
|
|
136
|
-
| Option
|
|
137
|
-
|
|
|
138
|
-
| `--port <number>`
|
|
139
|
-
| `--verbose`
|
|
140
|
-
| `--
|
|
141
|
-
| `--
|
|
142
|
-
| `--
|
|
143
|
-
| `--
|
|
144
|
-
| `--
|
|
145
|
-
| `--
|
|
146
|
-
| `--
|
|
147
|
-
| `--project-
|
|
148
|
-
| `--project-slug <slug>` | | Sets the project slug for game seeding. | `undefined` |
|
|
127
|
+
| Option | Alias | Description | Default |
|
|
128
|
+
| :---------------------- | :---- | :--------------------------------------- | :---------- |
|
|
129
|
+
| `--port <number>` | `-p` | Port for the API server. | `4321` |
|
|
130
|
+
| `--verbose` | `-v` | Enables verbose logging for debugging. | `false` |
|
|
131
|
+
| `--quiet` | `-q` | Quiet mode (suppress interactive output) | `false` |
|
|
132
|
+
| `--no-seed` | | Disables seeding of demo data. | seeds |
|
|
133
|
+
| `--recreate-db` | | Recreate the on-disk database on start. | `false` |
|
|
134
|
+
| `--memory` | | Use in-memory database (no persistence). | `false` |
|
|
135
|
+
| `--db-path <path>` | | Custom path for the database file. | `undefined` |
|
|
136
|
+
| `--config-path <path>` | | Path to playcademy.config.json. | `cwd` |
|
|
137
|
+
| `--project-name <name>` | | Sets the project name for game seeding. | `undefined` |
|
|
138
|
+
| `--project-slug <slug>` | | Sets the project slug for game seeding. | `undefined` |
|
|
149
139
|
|
|
150
140
|
#### Manual SDK Configuration
|
|
151
141
|
|
|
@@ -156,7 +146,6 @@ import { PlaycademyClient } from '@playcademy/sdk'
|
|
|
156
146
|
|
|
157
147
|
const client = await PlaycademyClient.init({
|
|
158
148
|
baseUrl: 'http://localhost:4321/api',
|
|
159
|
-
realtimeUrl: 'ws://localhost:4322',
|
|
160
149
|
// In manual mode, you must provide a mock token
|
|
161
150
|
token: 'mock-dev-token',
|
|
162
151
|
})
|
|
@@ -167,7 +156,6 @@ const client = await PlaycademyClient.init({
|
|
|
167
156
|
| Feature | Description |
|
|
168
157
|
| :------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
169
158
|
| **API Simulation** | Emulates the entire Playcademy backend API for users, games, inventory, etc. |
|
|
170
|
-
| **Real-time Server** | Provides WebSocket-based real-time channels for multiplayer communication. |
|
|
171
159
|
| **Data Persistence** | Persists data to disk by default (survives restarts). Use `--recreate-db` to reset, `--memory` for in-memory only, or `--db-path` for custom location. |
|
|
172
160
|
| **Mock Data** | Automatically seeds with demo users and data on first run or when database is empty. |
|
|
173
161
|
| **Game Context** | When run via the Vite plugin, it automatically registers your current project as a mock game. |
|
|
@@ -178,7 +166,6 @@ Once running, the sandbox provides several key endpoints:
|
|
|
178
166
|
|
|
179
167
|
- **Health Check**: `GET /health`
|
|
180
168
|
- **API Base URL**: `/api`
|
|
181
|
-
- **Real-time URL**: `ws://localhost:{realtimePort}`
|
|
182
169
|
|
|
183
170
|
All production Playcademy APIs are available under the `/api` prefix, including `/users`, `/games`, `/inventory`, and more.
|
|
184
171
|
|
|
@@ -212,13 +199,17 @@ bunx @playcademy/sandbox \
|
|
|
212
199
|
--timeback-student-id your-student-sourcedId
|
|
213
200
|
```
|
|
214
201
|
|
|
215
|
-
| Option | Description
|
|
216
|
-
| :------------------------------- |
|
|
217
|
-
| `--timeback-local` | Enable local TimeBack mode (Docker)
|
|
218
|
-
| `--timeback-oneroster-url <url>` | OneRoster API URL
|
|
219
|
-
| `--timeback-caliper-url <url>` | Caliper API URL
|
|
220
|
-
| `--timeback-course-id <id>` | Course ID for enrollments
|
|
221
|
-
| `--timeback-student-id <id>` | Student ID to link to demo user
|
|
202
|
+
| Option | Description |
|
|
203
|
+
| :------------------------------- | :-------------------------------------------------------- |
|
|
204
|
+
| `--timeback-local` | Enable local TimeBack mode (Docker) |
|
|
205
|
+
| `--timeback-oneroster-url <url>` | OneRoster API URL |
|
|
206
|
+
| `--timeback-caliper-url <url>` | Caliper API URL |
|
|
207
|
+
| `--timeback-course-id <id>` | Course ID for enrollments |
|
|
208
|
+
| `--timeback-student-id <id>` | Student ID to link to demo user |
|
|
209
|
+
| `--timeback-role <role>` | User role (student, parent, teacher, administrator) |
|
|
210
|
+
| `--timeback-org-id <id>` | Organization ID |
|
|
211
|
+
| `--timeback-org-name <name>` | Organization display name |
|
|
212
|
+
| `--timeback-org-type <type>` | Organization type (school, district, department, etc.) |
|
|
222
213
|
|
|
223
214
|
### Environment Variables
|
|
224
215
|
|
|
@@ -304,13 +295,12 @@ This should return a JSON object with the status:
|
|
|
304
295
|
|
|
305
296
|
### Common Issues
|
|
306
297
|
|
|
307
|
-
| Issue | Solution
|
|
308
|
-
| :----------------------------- |
|
|
309
|
-
| **Sandbox doesn't start** | When using Vite, check that `autoStart: true` in `vite.config.ts` and `@playcademy/vite-plugin` is installed. Check terminal for errors.
|
|
310
|
-
| **API calls return HTML** | This indicates the API server isn't running or is on a different port. Check your sandbox `url` configuration.
|
|
311
|
-
| **
|
|
312
|
-
| **
|
|
313
|
-
| **Data persists unexpectedly** | By default, the sandbox persists data to disk. Use `--recreate-db` to reset the database, or `--memory` for session-only data that doesn't persist. |
|
|
298
|
+
| Issue | Solution |
|
|
299
|
+
| :----------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
300
|
+
| **Sandbox doesn't start** | When using Vite, check that `autoStart: true` in `vite.config.ts` and `@playcademy/vite-plugin` is installed. Check terminal for errors. |
|
|
301
|
+
| **API calls return HTML** | This indicates the API server isn't running or is on a different port. Check your sandbox `url` configuration. |
|
|
302
|
+
| **Port conflicts** | The sandbox uses port 4321 by default. If another process is using this port, stop it or use `--port` to specify a different port. |
|
|
303
|
+
| **Data persists unexpectedly** | By default, the sandbox persists data to disk. Use `--recreate-db` to reset the database, or `--memory` for session-only data that doesn't persist. |
|
|
314
304
|
|
|
315
305
|
## Production vs. Sandbox
|
|
316
306
|
|