@playcademy/sandbox 0.2.3 → 0.3.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 +20 -16
- package/dist/cli.js +808 -569
- package/dist/config.d.ts +38 -2
- package/dist/config.js +31 -5
- package/dist/constants.d.ts +193 -0
- package/dist/constants.js +231 -0
- package/dist/mocks/timeback.d.ts +30 -0
- package/dist/server.d.ts +21 -2
- package/dist/server.js +796 -461
- package/package.json +5 -1
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import { TimebackOrgType, TimebackUserRole } from '@playcademy/data/types';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Configuration Type Definitions
|
|
3
5
|
*/
|
|
6
|
+
|
|
4
7
|
type TimebackMode = 'local' | 'remote' | 'disabled';
|
|
8
|
+
/**
|
|
9
|
+
* Organization configuration input for sandbox.
|
|
10
|
+
* All fields optional since they can be derived from defaults.
|
|
11
|
+
*/
|
|
12
|
+
interface TimebackOrganizationInput {
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
type?: TimebackOrgType;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Timeback configuration input for sandbox.
|
|
19
|
+
* All fields optional since they can be derived from defaults.
|
|
20
|
+
*/
|
|
5
21
|
interface TimebackConfig {
|
|
6
22
|
mode: TimebackMode;
|
|
7
23
|
onerosterApiUrl?: string;
|
|
@@ -10,12 +26,22 @@ interface TimebackConfig {
|
|
|
10
26
|
clientSecret?: string;
|
|
11
27
|
authUrl?: string;
|
|
12
28
|
courseId?: string;
|
|
13
|
-
|
|
29
|
+
timebackId?: string;
|
|
30
|
+
organization?: TimebackOrganizationInput;
|
|
31
|
+
role?: TimebackUserRole;
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Authentication configuration input for sandbox.
|
|
35
|
+
* All fields required.
|
|
36
|
+
*/
|
|
15
37
|
interface AuthConfig {
|
|
16
38
|
betterAuthSecret: string;
|
|
17
39
|
gameJwtSecret: string;
|
|
18
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Sandbox configuration input for sandbox.
|
|
43
|
+
* All fields required.
|
|
44
|
+
*/
|
|
19
45
|
interface SandboxConfig {
|
|
20
46
|
embedded: boolean;
|
|
21
47
|
auth: AuthConfig;
|
|
@@ -36,8 +62,18 @@ declare function hasTimebackCredentials(): boolean;
|
|
|
36
62
|
declare function hasTimebackFullConfig(): boolean;
|
|
37
63
|
declare function requireTimebackCredentials(): TimebackConfig;
|
|
38
64
|
declare function configureTimeback(options: Partial<TimebackConfig>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Get the effective Timeback mode for display.
|
|
67
|
+
* Returns null if timeback is not configured, otherwise 'mock', 'remote', or 'local'.
|
|
68
|
+
*
|
|
69
|
+
* Logic:
|
|
70
|
+
* - No timebackId → null (timeback disabled)
|
|
71
|
+
* - timebackId='mock' or no credentials → 'mock'
|
|
72
|
+
* - timebackId=real + credentials → actual mode ('remote' or 'local')
|
|
73
|
+
*/
|
|
74
|
+
declare function getTimebackDisplayMode(): 'mock' | 'remote' | 'local' | null;
|
|
39
75
|
|
|
40
76
|
declare const config: SandboxConfig;
|
|
41
77
|
|
|
42
|
-
export { config, configureTimeback, hasTimebackCredentials, hasTimebackFullConfig, isTimebackEnabled, requireTimebackCredentials, setEmbeddedMode };
|
|
78
|
+
export { config, configureTimeback, getTimebackDisplayMode, hasTimebackCredentials, hasTimebackFullConfig, isTimebackEnabled, requireTimebackCredentials, setEmbeddedMode };
|
|
43
79
|
export type { AuthConfig, SandboxConfig, TimebackConfig, TimebackMode };
|
package/dist/config.js
CHANGED
|
@@ -53,7 +53,7 @@ function hasTimebackCredentials() {
|
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
function hasTimebackFullConfig() {
|
|
56
|
-
return hasTimebackCredentials() && !!(config.timeback.courseId && config.timeback.
|
|
56
|
+
return hasTimebackCredentials() && !!(config.timeback.courseId && config.timeback.timebackId);
|
|
57
57
|
}
|
|
58
58
|
function requireTimebackCredentials() {
|
|
59
59
|
if (hasTimebackCredentials())
|
|
@@ -107,10 +107,35 @@ function configureTimeback(options) {
|
|
|
107
107
|
config.timeback.courseId = options.courseId;
|
|
108
108
|
process.env.SANDBOX_TIMEBACK_COURSE_ID = options.courseId;
|
|
109
109
|
}
|
|
110
|
-
if (options.
|
|
111
|
-
config.timeback.
|
|
112
|
-
process.env.SANDBOX_TIMEBACK_STUDENT_ID = options.
|
|
110
|
+
if (options.timebackId) {
|
|
111
|
+
config.timeback.timebackId = options.timebackId;
|
|
112
|
+
process.env.SANDBOX_TIMEBACK_STUDENT_ID = options.timebackId;
|
|
113
|
+
const isMockMode = options.timebackId === "mock";
|
|
114
|
+
process.env.SANDBOX_TIMEBACK_MOCK_MODE = isMockMode ? "true" : "false";
|
|
113
115
|
}
|
|
116
|
+
if (options.organization) {
|
|
117
|
+
config.timeback.organization = options.organization;
|
|
118
|
+
process.env.SANDBOX_TIMEBACK_ORG_ID = options.organization.id;
|
|
119
|
+
if (options.organization.name) {
|
|
120
|
+
process.env.SANDBOX_TIMEBACK_ORG_NAME = options.organization.name;
|
|
121
|
+
}
|
|
122
|
+
if (options.organization.type) {
|
|
123
|
+
process.env.SANDBOX_TIMEBACK_ORG_TYPE = options.organization.type;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (options.role) {
|
|
127
|
+
config.timeback.role = options.role;
|
|
128
|
+
process.env.SANDBOX_TIMEBACK_ROLE = options.role;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getTimebackDisplayMode() {
|
|
132
|
+
const { timebackId, mode } = config.timeback;
|
|
133
|
+
if (!timebackId)
|
|
134
|
+
return null;
|
|
135
|
+
if (timebackId === "mock" || !hasTimebackCredentials()) {
|
|
136
|
+
return "mock";
|
|
137
|
+
}
|
|
138
|
+
return mode;
|
|
114
139
|
}
|
|
115
140
|
|
|
116
141
|
// src/config/mutators.ts
|
|
@@ -134,7 +159,7 @@ var config = {
|
|
|
134
159
|
clientSecret: process.env.TIMEBACK_API_CLIENT_SECRET,
|
|
135
160
|
authUrl: process.env.TIMEBACK_API_AUTH_URL,
|
|
136
161
|
courseId: process.env.SANDBOX_TIMEBACK_COURSE_ID,
|
|
137
|
-
|
|
162
|
+
timebackId: process.env.SANDBOX_TIMEBACK_STUDENT_ID
|
|
138
163
|
}
|
|
139
164
|
};
|
|
140
165
|
process.env.BETTER_AUTH_SECRET = config.auth.betterAuthSecret;
|
|
@@ -146,6 +171,7 @@ export {
|
|
|
146
171
|
isTimebackEnabled,
|
|
147
172
|
hasTimebackFullConfig,
|
|
148
173
|
hasTimebackCredentials,
|
|
174
|
+
getTimebackDisplayMode,
|
|
149
175
|
configureTimeback,
|
|
150
176
|
config
|
|
151
177
|
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Item } from '@playcademy/data/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Demo user data for sandbox testing
|
|
5
|
+
*/
|
|
6
|
+
declare const DEMO_USER_IDS: {
|
|
7
|
+
readonly player: "00000000-0000-0000-0000-000000000001";
|
|
8
|
+
readonly developer: "00000000-0000-0000-0000-000000000002";
|
|
9
|
+
readonly admin: "00000000-0000-0000-0000-000000000003";
|
|
10
|
+
readonly pendingDeveloper: "00000000-0000-0000-0000-000000000004";
|
|
11
|
+
readonly unverifiedPlayer: "00000000-0000-0000-0000-000000000005";
|
|
12
|
+
};
|
|
13
|
+
declare const DEMO_USERS: {
|
|
14
|
+
readonly admin: {
|
|
15
|
+
readonly id: "00000000-0000-0000-0000-000000000003";
|
|
16
|
+
readonly name: "Admin User";
|
|
17
|
+
readonly username: "admin_user";
|
|
18
|
+
readonly email: "admin@playcademy.com";
|
|
19
|
+
readonly emailVerified: true;
|
|
20
|
+
readonly image: null;
|
|
21
|
+
readonly role: "admin";
|
|
22
|
+
readonly developerStatus: "approved";
|
|
23
|
+
readonly createdAt: Date;
|
|
24
|
+
readonly updatedAt: Date;
|
|
25
|
+
};
|
|
26
|
+
readonly player: {
|
|
27
|
+
readonly id: "00000000-0000-0000-0000-000000000001";
|
|
28
|
+
readonly name: "Player User";
|
|
29
|
+
readonly username: "player_user";
|
|
30
|
+
readonly email: "player@playcademy.com";
|
|
31
|
+
readonly emailVerified: true;
|
|
32
|
+
readonly image: null;
|
|
33
|
+
readonly role: "player";
|
|
34
|
+
readonly developerStatus: "none";
|
|
35
|
+
readonly createdAt: Date;
|
|
36
|
+
readonly updatedAt: Date;
|
|
37
|
+
};
|
|
38
|
+
readonly developer: {
|
|
39
|
+
readonly id: "00000000-0000-0000-0000-000000000002";
|
|
40
|
+
readonly name: "Developer User";
|
|
41
|
+
readonly username: "developer_user";
|
|
42
|
+
readonly email: "developer@playcademy.com";
|
|
43
|
+
readonly emailVerified: true;
|
|
44
|
+
readonly image: null;
|
|
45
|
+
readonly role: "developer";
|
|
46
|
+
readonly developerStatus: "approved";
|
|
47
|
+
readonly createdAt: Date;
|
|
48
|
+
readonly updatedAt: Date;
|
|
49
|
+
};
|
|
50
|
+
readonly pendingDeveloper: {
|
|
51
|
+
readonly id: "00000000-0000-0000-0000-000000000004";
|
|
52
|
+
readonly name: "Pending Developer";
|
|
53
|
+
readonly username: "pending_dev";
|
|
54
|
+
readonly email: "pending@playcademy.com";
|
|
55
|
+
readonly emailVerified: true;
|
|
56
|
+
readonly image: null;
|
|
57
|
+
readonly role: "developer";
|
|
58
|
+
readonly developerStatus: "pending";
|
|
59
|
+
readonly createdAt: Date;
|
|
60
|
+
readonly updatedAt: Date;
|
|
61
|
+
};
|
|
62
|
+
readonly unverifiedPlayer: {
|
|
63
|
+
readonly id: "00000000-0000-0000-0000-000000000005";
|
|
64
|
+
readonly name: "Unverified Player";
|
|
65
|
+
readonly username: "unverified_player";
|
|
66
|
+
readonly email: "unverified@playcademy.com";
|
|
67
|
+
readonly emailVerified: false;
|
|
68
|
+
readonly image: null;
|
|
69
|
+
readonly role: "player";
|
|
70
|
+
readonly developerStatus: "none";
|
|
71
|
+
readonly createdAt: Date;
|
|
72
|
+
readonly updatedAt: Date;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
declare const DEMO_USER: {
|
|
76
|
+
readonly id: "00000000-0000-0000-0000-000000000001";
|
|
77
|
+
readonly name: "Player User";
|
|
78
|
+
readonly username: "player_user";
|
|
79
|
+
readonly email: "player@playcademy.com";
|
|
80
|
+
readonly emailVerified: true;
|
|
81
|
+
readonly image: null;
|
|
82
|
+
readonly role: "player";
|
|
83
|
+
readonly developerStatus: "none";
|
|
84
|
+
readonly createdAt: Date;
|
|
85
|
+
readonly updatedAt: Date;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Demo token mappings for sandbox authentication
|
|
90
|
+
*/
|
|
91
|
+
declare const DEMO_TOKENS: {
|
|
92
|
+
readonly 'sandbox-demo-token': {
|
|
93
|
+
readonly id: "00000000-0000-0000-0000-000000000001";
|
|
94
|
+
readonly name: "Player User";
|
|
95
|
+
readonly username: "player_user";
|
|
96
|
+
readonly email: "player@playcademy.com";
|
|
97
|
+
readonly emailVerified: true;
|
|
98
|
+
readonly image: null;
|
|
99
|
+
readonly role: "player";
|
|
100
|
+
readonly developerStatus: "none";
|
|
101
|
+
readonly createdAt: Date;
|
|
102
|
+
readonly updatedAt: Date;
|
|
103
|
+
};
|
|
104
|
+
readonly 'sandbox-admin-token': {
|
|
105
|
+
readonly id: "00000000-0000-0000-0000-000000000003";
|
|
106
|
+
readonly name: "Admin User";
|
|
107
|
+
readonly username: "admin_user";
|
|
108
|
+
readonly email: "admin@playcademy.com";
|
|
109
|
+
readonly emailVerified: true;
|
|
110
|
+
readonly image: null;
|
|
111
|
+
readonly role: "admin";
|
|
112
|
+
readonly developerStatus: "approved";
|
|
113
|
+
readonly createdAt: Date;
|
|
114
|
+
readonly updatedAt: Date;
|
|
115
|
+
};
|
|
116
|
+
readonly 'sandbox-player-token': {
|
|
117
|
+
readonly id: "00000000-0000-0000-0000-000000000001";
|
|
118
|
+
readonly name: "Player User";
|
|
119
|
+
readonly username: "player_user";
|
|
120
|
+
readonly email: "player@playcademy.com";
|
|
121
|
+
readonly emailVerified: true;
|
|
122
|
+
readonly image: null;
|
|
123
|
+
readonly role: "player";
|
|
124
|
+
readonly developerStatus: "none";
|
|
125
|
+
readonly createdAt: Date;
|
|
126
|
+
readonly updatedAt: Date;
|
|
127
|
+
};
|
|
128
|
+
readonly 'sandbox-developer-token': {
|
|
129
|
+
readonly id: "00000000-0000-0000-0000-000000000002";
|
|
130
|
+
readonly name: "Developer User";
|
|
131
|
+
readonly username: "developer_user";
|
|
132
|
+
readonly email: "developer@playcademy.com";
|
|
133
|
+
readonly emailVerified: true;
|
|
134
|
+
readonly image: null;
|
|
135
|
+
readonly role: "developer";
|
|
136
|
+
readonly developerStatus: "approved";
|
|
137
|
+
readonly createdAt: Date;
|
|
138
|
+
readonly updatedAt: Date;
|
|
139
|
+
};
|
|
140
|
+
readonly 'sandbox-pending-dev-token': {
|
|
141
|
+
readonly id: "00000000-0000-0000-0000-000000000004";
|
|
142
|
+
readonly name: "Pending Developer";
|
|
143
|
+
readonly username: "pending_dev";
|
|
144
|
+
readonly email: "pending@playcademy.com";
|
|
145
|
+
readonly emailVerified: true;
|
|
146
|
+
readonly image: null;
|
|
147
|
+
readonly role: "developer";
|
|
148
|
+
readonly developerStatus: "pending";
|
|
149
|
+
readonly createdAt: Date;
|
|
150
|
+
readonly updatedAt: Date;
|
|
151
|
+
};
|
|
152
|
+
readonly 'sandbox-unverified-token': {
|
|
153
|
+
readonly id: "00000000-0000-0000-0000-000000000005";
|
|
154
|
+
readonly name: "Unverified Player";
|
|
155
|
+
readonly username: "unverified_player";
|
|
156
|
+
readonly email: "unverified@playcademy.com";
|
|
157
|
+
readonly emailVerified: false;
|
|
158
|
+
readonly image: null;
|
|
159
|
+
readonly role: "player";
|
|
160
|
+
readonly developerStatus: "none";
|
|
161
|
+
readonly createdAt: Date;
|
|
162
|
+
readonly updatedAt: Date;
|
|
163
|
+
};
|
|
164
|
+
readonly 'mock-game-token-for-local-dev': {
|
|
165
|
+
readonly id: "00000000-0000-0000-0000-000000000001";
|
|
166
|
+
readonly name: "Player User";
|
|
167
|
+
readonly username: "player_user";
|
|
168
|
+
readonly email: "player@playcademy.com";
|
|
169
|
+
readonly emailVerified: true;
|
|
170
|
+
readonly image: null;
|
|
171
|
+
readonly role: "player";
|
|
172
|
+
readonly developerStatus: "none";
|
|
173
|
+
readonly createdAt: Date;
|
|
174
|
+
readonly updatedAt: Date;
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
declare const DEMO_TOKEN = "sandbox-demo-token";
|
|
178
|
+
declare const MOCK_GAME_ID = "mock-game-id-from-template";
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Demo items and inventory data for sandbox testing
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
declare const PLAYCADEMY_CREDITS_ID: string;
|
|
185
|
+
declare const SAMPLE_ITEMS: Omit<Item, 'createdAt'>[];
|
|
186
|
+
declare const SAMPLE_INVENTORY: {
|
|
187
|
+
id: string;
|
|
188
|
+
userId: "00000000-0000-0000-0000-000000000001";
|
|
189
|
+
itemId: string;
|
|
190
|
+
quantity: number;
|
|
191
|
+
}[];
|
|
192
|
+
|
|
193
|
+
export { DEMO_TOKEN, DEMO_TOKENS, DEMO_USER, DEMO_USERS, DEMO_USER_IDS, MOCK_GAME_ID, PLAYCADEMY_CREDITS_ID, SAMPLE_INVENTORY, SAMPLE_ITEMS };
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, {
|
|
22
|
+
get: all[name],
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
set: (newValue) => all[name] = () => newValue
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
// src/constants/demo-users.ts
|
|
32
|
+
var now = new Date;
|
|
33
|
+
var DEMO_USER_IDS = {
|
|
34
|
+
player: "00000000-0000-0000-0000-000000000001",
|
|
35
|
+
developer: "00000000-0000-0000-0000-000000000002",
|
|
36
|
+
admin: "00000000-0000-0000-0000-000000000003",
|
|
37
|
+
pendingDeveloper: "00000000-0000-0000-0000-000000000004",
|
|
38
|
+
unverifiedPlayer: "00000000-0000-0000-0000-000000000005"
|
|
39
|
+
};
|
|
40
|
+
var DEMO_USERS = {
|
|
41
|
+
admin: {
|
|
42
|
+
id: DEMO_USER_IDS.admin,
|
|
43
|
+
name: "Admin User",
|
|
44
|
+
username: "admin_user",
|
|
45
|
+
email: "admin@playcademy.com",
|
|
46
|
+
emailVerified: true,
|
|
47
|
+
image: null,
|
|
48
|
+
role: "admin",
|
|
49
|
+
developerStatus: "approved",
|
|
50
|
+
createdAt: now,
|
|
51
|
+
updatedAt: now
|
|
52
|
+
},
|
|
53
|
+
player: {
|
|
54
|
+
id: DEMO_USER_IDS.player,
|
|
55
|
+
name: "Player User",
|
|
56
|
+
username: "player_user",
|
|
57
|
+
email: "player@playcademy.com",
|
|
58
|
+
emailVerified: true,
|
|
59
|
+
image: null,
|
|
60
|
+
role: "player",
|
|
61
|
+
developerStatus: "none",
|
|
62
|
+
createdAt: now,
|
|
63
|
+
updatedAt: now
|
|
64
|
+
},
|
|
65
|
+
developer: {
|
|
66
|
+
id: DEMO_USER_IDS.developer,
|
|
67
|
+
name: "Developer User",
|
|
68
|
+
username: "developer_user",
|
|
69
|
+
email: "developer@playcademy.com",
|
|
70
|
+
emailVerified: true,
|
|
71
|
+
image: null,
|
|
72
|
+
role: "developer",
|
|
73
|
+
developerStatus: "approved",
|
|
74
|
+
createdAt: now,
|
|
75
|
+
updatedAt: now
|
|
76
|
+
},
|
|
77
|
+
pendingDeveloper: {
|
|
78
|
+
id: DEMO_USER_IDS.pendingDeveloper,
|
|
79
|
+
name: "Pending Developer",
|
|
80
|
+
username: "pending_dev",
|
|
81
|
+
email: "pending@playcademy.com",
|
|
82
|
+
emailVerified: true,
|
|
83
|
+
image: null,
|
|
84
|
+
role: "developer",
|
|
85
|
+
developerStatus: "pending",
|
|
86
|
+
createdAt: now,
|
|
87
|
+
updatedAt: now
|
|
88
|
+
},
|
|
89
|
+
unverifiedPlayer: {
|
|
90
|
+
id: DEMO_USER_IDS.unverifiedPlayer,
|
|
91
|
+
name: "Unverified Player",
|
|
92
|
+
username: "unverified_player",
|
|
93
|
+
email: "unverified@playcademy.com",
|
|
94
|
+
emailVerified: false,
|
|
95
|
+
image: null,
|
|
96
|
+
role: "player",
|
|
97
|
+
developerStatus: "none",
|
|
98
|
+
createdAt: now,
|
|
99
|
+
updatedAt: now
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var DEMO_USER = DEMO_USERS.player;
|
|
103
|
+
// src/constants/demo-tokens.ts
|
|
104
|
+
var DEMO_TOKENS = {
|
|
105
|
+
"sandbox-demo-token": DEMO_USERS.player,
|
|
106
|
+
"sandbox-admin-token": DEMO_USERS.admin,
|
|
107
|
+
"sandbox-player-token": DEMO_USERS.player,
|
|
108
|
+
"sandbox-developer-token": DEMO_USERS.developer,
|
|
109
|
+
"sandbox-pending-dev-token": DEMO_USERS.pendingDeveloper,
|
|
110
|
+
"sandbox-unverified-token": DEMO_USERS.unverifiedPlayer,
|
|
111
|
+
"mock-game-token-for-local-dev": DEMO_USERS.player
|
|
112
|
+
};
|
|
113
|
+
var DEMO_TOKEN = "sandbox-demo-token";
|
|
114
|
+
var MOCK_GAME_ID = "mock-game-id-from-template";
|
|
115
|
+
// src/constants/demo-items.ts
|
|
116
|
+
var DEMO_ITEM_IDS = {
|
|
117
|
+
playcademyCredits: "10000000-0000-0000-0000-000000000001",
|
|
118
|
+
foundingMemberBadge: "10000000-0000-0000-0000-000000000002",
|
|
119
|
+
earlyAdopterBadge: "10000000-0000-0000-0000-000000000003",
|
|
120
|
+
firstGameBadge: "10000000-0000-0000-0000-000000000004",
|
|
121
|
+
commonSword: "10000000-0000-0000-0000-000000000005",
|
|
122
|
+
smallHealthPotion: "10000000-0000-0000-0000-000000000006",
|
|
123
|
+
smallBackpack: "10000000-0000-0000-0000-000000000007"
|
|
124
|
+
};
|
|
125
|
+
var PLAYCADEMY_CREDITS_ID = DEMO_ITEM_IDS.playcademyCredits;
|
|
126
|
+
var SAMPLE_ITEMS = [
|
|
127
|
+
{
|
|
128
|
+
id: PLAYCADEMY_CREDITS_ID,
|
|
129
|
+
slug: "PLAYCADEMY_CREDITS",
|
|
130
|
+
gameId: null,
|
|
131
|
+
displayName: "PLAYCADEMY credits",
|
|
132
|
+
description: "The main currency used across PLAYCADEMY.",
|
|
133
|
+
type: "currency",
|
|
134
|
+
isPlaceable: false,
|
|
135
|
+
imageUrl: "http://playcademy-sandbox.local/playcademy-credit.png",
|
|
136
|
+
metadata: {
|
|
137
|
+
rarity: "common"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: DEMO_ITEM_IDS.foundingMemberBadge,
|
|
142
|
+
slug: "FOUNDING_MEMBER_BADGE",
|
|
143
|
+
gameId: null,
|
|
144
|
+
displayName: "Founding Member Badge",
|
|
145
|
+
description: "Reserved for founding core team of the PLAYCADEMY platform.",
|
|
146
|
+
type: "badge",
|
|
147
|
+
isPlaceable: false,
|
|
148
|
+
imageUrl: null,
|
|
149
|
+
metadata: {
|
|
150
|
+
rarity: "legendary"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: DEMO_ITEM_IDS.earlyAdopterBadge,
|
|
155
|
+
slug: "EARLY_ADOPTER_BADGE",
|
|
156
|
+
gameId: null,
|
|
157
|
+
displayName: "Early Adopter Badge",
|
|
158
|
+
description: "Awarded to users who joined during the beta phase.",
|
|
159
|
+
type: "badge",
|
|
160
|
+
isPlaceable: false,
|
|
161
|
+
imageUrl: null,
|
|
162
|
+
metadata: {
|
|
163
|
+
rarity: "epic"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: DEMO_ITEM_IDS.firstGameBadge,
|
|
168
|
+
slug: "FIRST_GAME_BADGE",
|
|
169
|
+
gameId: null,
|
|
170
|
+
displayName: "First Game Played",
|
|
171
|
+
description: "Awarded for playing your first game in the Playcademy platform.",
|
|
172
|
+
type: "badge",
|
|
173
|
+
isPlaceable: false,
|
|
174
|
+
imageUrl: "http://playcademy-sandbox.local/first-game-badge.png",
|
|
175
|
+
metadata: {
|
|
176
|
+
rarity: "uncommon"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: DEMO_ITEM_IDS.commonSword,
|
|
181
|
+
slug: "COMMON_SWORD",
|
|
182
|
+
gameId: null,
|
|
183
|
+
displayName: "Common Sword",
|
|
184
|
+
description: "A basic sword, good for beginners.",
|
|
185
|
+
type: "unlock",
|
|
186
|
+
isPlaceable: false,
|
|
187
|
+
imageUrl: "http://playcademy-sandbox.local/common-sword.png",
|
|
188
|
+
metadata: undefined
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: DEMO_ITEM_IDS.smallHealthPotion,
|
|
192
|
+
slug: "SMALL_HEALTH_POTION",
|
|
193
|
+
gameId: null,
|
|
194
|
+
displayName: "Small Health Potion",
|
|
195
|
+
description: "Restores a small amount of health.",
|
|
196
|
+
type: "other",
|
|
197
|
+
isPlaceable: false,
|
|
198
|
+
imageUrl: "http://playcademy-sandbox.local/small-health-potion.png",
|
|
199
|
+
metadata: undefined
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: DEMO_ITEM_IDS.smallBackpack,
|
|
203
|
+
slug: "SMALL_BACKPACK",
|
|
204
|
+
gameId: null,
|
|
205
|
+
displayName: "Small Backpack",
|
|
206
|
+
description: "Increases your inventory capacity by 5 slots.",
|
|
207
|
+
type: "upgrade",
|
|
208
|
+
isPlaceable: false,
|
|
209
|
+
imageUrl: "http://playcademy-sandbox.local/small-backpack.png",
|
|
210
|
+
metadata: undefined
|
|
211
|
+
}
|
|
212
|
+
];
|
|
213
|
+
var SAMPLE_INVENTORY = [
|
|
214
|
+
{
|
|
215
|
+
id: "20000000-0000-0000-0000-000000000001",
|
|
216
|
+
userId: DEMO_USER.id,
|
|
217
|
+
itemId: PLAYCADEMY_CREDITS_ID,
|
|
218
|
+
quantity: 1000
|
|
219
|
+
}
|
|
220
|
+
];
|
|
221
|
+
export {
|
|
222
|
+
SAMPLE_ITEMS,
|
|
223
|
+
SAMPLE_INVENTORY,
|
|
224
|
+
PLAYCADEMY_CREDITS_ID,
|
|
225
|
+
MOCK_GAME_ID,
|
|
226
|
+
DEMO_USER_IDS,
|
|
227
|
+
DEMO_USERS,
|
|
228
|
+
DEMO_USER,
|
|
229
|
+
DEMO_TOKENS,
|
|
230
|
+
DEMO_TOKEN
|
|
231
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TimeBack Mock Data
|
|
3
|
+
*
|
|
4
|
+
* Pure mock data generators for local development.
|
|
5
|
+
* Used by route handlers when mock mode is enabled.
|
|
6
|
+
*/
|
|
7
|
+
import type { AuthenticatedUser, GameUser, TimebackStudentProfile, User, UserEnrollment, UserTimebackData } from '@playcademy/data/types';
|
|
8
|
+
import type { DatabaseInstance } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Check if TimeBack should return mock data instead of calling real APIs.
|
|
11
|
+
* True when timebackId is 'mock' (auto-generated IDs in sandbox).
|
|
12
|
+
*/
|
|
13
|
+
export declare function shouldMockTimeback(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Generate mock student profile from sandbox config.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getMockStudentProfile(): TimebackStudentProfile;
|
|
18
|
+
/**
|
|
19
|
+
* Generate mock enrollments from seeded game integrations.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getMockEnrollments(db: DatabaseInstance): Promise<UserEnrollment[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Generate complete mock TimeBack data for a user.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getMockTimebackData(db: DatabaseInstance, timebackId: string, gameId?: string): Promise<UserTimebackData>;
|
|
26
|
+
/**
|
|
27
|
+
* Build a complete user response with mock timeback data.
|
|
28
|
+
* Used to bypass api-core when in mock mode (avoids real API calls).
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildMockUserResponse(db: DatabaseInstance, user: User, gameId?: string): Promise<AuthenticatedUser | GameUser>;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import * as _playcademy_realtime_server_sandbox from '@playcademy/realtime/server/sandbox';
|
|
2
2
|
import * as _playcademy_realtime_server from '@playcademy/realtime/server';
|
|
3
3
|
import * as _hono_node_server from '@hono/node-server';
|
|
4
|
+
import { TimebackOrgType, TimebackUserRole } from '@playcademy/data/types';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Configuration Type Definitions
|
|
7
8
|
*/
|
|
9
|
+
|
|
8
10
|
type TimebackMode = 'local' | 'remote' | 'disabled';
|
|
11
|
+
/**
|
|
12
|
+
* Organization configuration input for sandbox.
|
|
13
|
+
* All fields optional since they can be derived from defaults.
|
|
14
|
+
*/
|
|
15
|
+
interface TimebackOrganizationInput {
|
|
16
|
+
id?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
type?: TimebackOrgType;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Timeback configuration input for sandbox.
|
|
22
|
+
* All fields optional since they can be derived from defaults.
|
|
23
|
+
*/
|
|
9
24
|
interface TimebackConfig {
|
|
10
25
|
mode: TimebackMode;
|
|
11
26
|
onerosterApiUrl?: string;
|
|
@@ -14,7 +29,9 @@ interface TimebackConfig {
|
|
|
14
29
|
clientSecret?: string;
|
|
15
30
|
authUrl?: string;
|
|
16
31
|
courseId?: string;
|
|
17
|
-
|
|
32
|
+
timebackId?: string;
|
|
33
|
+
organization?: TimebackOrganizationInput;
|
|
34
|
+
role?: TimebackUserRole;
|
|
18
35
|
}
|
|
19
36
|
|
|
20
37
|
/**
|
|
@@ -296,7 +313,9 @@ declare const version: string;
|
|
|
296
313
|
declare function startServer(port: number, project?: ProjectInfo, options?: Omit<ServerOptions, 'port' | 'project'>): Promise<{
|
|
297
314
|
main: _hono_node_server.ServerType;
|
|
298
315
|
realtime: Bun.Server<_playcademy_realtime_server.WebSocketData> | _playcademy_realtime_server_sandbox.SandboxRealtimeServer | null;
|
|
299
|
-
|
|
316
|
+
timebackMode: "local" | "remote" | "mock" | null;
|
|
317
|
+
setRole: (role: TimebackUserRole) => void;
|
|
318
|
+
stop: () => Promise<void>;
|
|
300
319
|
}>;
|
|
301
320
|
|
|
302
321
|
export { startServer, version };
|