@playcademy/sandbox 0.1.0-beta.8 → 0.1.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.
@@ -1,11 +1,158 @@
1
- import type { Item, User } from '@playcademy/data/schemas';
2
- export declare const DEMO_USER: User;
3
- export declare const DEMO_TOKEN = "demo-token";
1
+ import type { Item } from '@playcademy/data/types';
2
+ export declare const DEMO_USERS: {
3
+ readonly admin: {
4
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
5
+ readonly name: "Admin User";
6
+ readonly username: "admin_user";
7
+ readonly email: "admin@playcademy.com";
8
+ readonly emailVerified: true;
9
+ readonly image: null;
10
+ readonly role: "admin";
11
+ readonly developerStatus: "approved";
12
+ readonly createdAt: Date;
13
+ readonly updatedAt: Date;
14
+ };
15
+ readonly player: {
16
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
17
+ readonly name: "Player User";
18
+ readonly username: "player_user";
19
+ readonly email: "player@playcademy.com";
20
+ readonly emailVerified: true;
21
+ readonly image: null;
22
+ readonly role: "player";
23
+ readonly developerStatus: "none";
24
+ readonly createdAt: Date;
25
+ readonly updatedAt: Date;
26
+ };
27
+ readonly developer: {
28
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
29
+ readonly name: "Developer User";
30
+ readonly username: "developer_user";
31
+ readonly email: "developer@playcademy.com";
32
+ readonly emailVerified: true;
33
+ readonly image: null;
34
+ readonly role: "developer";
35
+ readonly developerStatus: "approved";
36
+ readonly createdAt: Date;
37
+ readonly updatedAt: Date;
38
+ };
39
+ readonly pendingDeveloper: {
40
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
41
+ readonly name: "Pending Developer";
42
+ readonly username: "pending_dev";
43
+ readonly email: "pending@playcademy.com";
44
+ readonly emailVerified: true;
45
+ readonly image: null;
46
+ readonly role: "developer";
47
+ readonly developerStatus: "pending";
48
+ readonly createdAt: Date;
49
+ readonly updatedAt: Date;
50
+ };
51
+ readonly unverifiedPlayer: {
52
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
53
+ readonly name: "Unverified Player";
54
+ readonly username: "unverified_player";
55
+ readonly email: "unverified@playcademy.com";
56
+ readonly emailVerified: false;
57
+ readonly image: null;
58
+ readonly role: "player";
59
+ readonly developerStatus: "none";
60
+ readonly createdAt: Date;
61
+ readonly updatedAt: Date;
62
+ };
63
+ };
64
+ export declare const DEMO_TOKENS: {
65
+ readonly 'sandbox-demo-token': {
66
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
67
+ readonly name: "Admin User";
68
+ readonly username: "admin_user";
69
+ readonly email: "admin@playcademy.com";
70
+ readonly emailVerified: true;
71
+ readonly image: null;
72
+ readonly role: "admin";
73
+ readonly developerStatus: "approved";
74
+ readonly createdAt: Date;
75
+ readonly updatedAt: Date;
76
+ };
77
+ readonly 'sandbox-admin-token': {
78
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
79
+ readonly name: "Admin User";
80
+ readonly username: "admin_user";
81
+ readonly email: "admin@playcademy.com";
82
+ readonly emailVerified: true;
83
+ readonly image: null;
84
+ readonly role: "admin";
85
+ readonly developerStatus: "approved";
86
+ readonly createdAt: Date;
87
+ readonly updatedAt: Date;
88
+ };
89
+ readonly 'sandbox-player-token': {
90
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
91
+ readonly name: "Player User";
92
+ readonly username: "player_user";
93
+ readonly email: "player@playcademy.com";
94
+ readonly emailVerified: true;
95
+ readonly image: null;
96
+ readonly role: "player";
97
+ readonly developerStatus: "none";
98
+ readonly createdAt: Date;
99
+ readonly updatedAt: Date;
100
+ };
101
+ readonly 'sandbox-developer-token': {
102
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
103
+ readonly name: "Developer User";
104
+ readonly username: "developer_user";
105
+ readonly email: "developer@playcademy.com";
106
+ readonly emailVerified: true;
107
+ readonly image: null;
108
+ readonly role: "developer";
109
+ readonly developerStatus: "approved";
110
+ readonly createdAt: Date;
111
+ readonly updatedAt: Date;
112
+ };
113
+ readonly 'sandbox-pending-dev-token': {
114
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
115
+ readonly name: "Pending Developer";
116
+ readonly username: "pending_dev";
117
+ readonly email: "pending@playcademy.com";
118
+ readonly emailVerified: true;
119
+ readonly image: null;
120
+ readonly role: "developer";
121
+ readonly developerStatus: "pending";
122
+ readonly createdAt: Date;
123
+ readonly updatedAt: Date;
124
+ };
125
+ readonly 'sandbox-unverified-token': {
126
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
127
+ readonly name: "Unverified Player";
128
+ readonly username: "unverified_player";
129
+ readonly email: "unverified@playcademy.com";
130
+ readonly emailVerified: false;
131
+ readonly image: null;
132
+ readonly role: "player";
133
+ readonly developerStatus: "none";
134
+ readonly createdAt: Date;
135
+ readonly updatedAt: Date;
136
+ };
137
+ };
138
+ export declare const DEMO_USER: {
139
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
140
+ readonly name: "Admin User";
141
+ readonly username: "admin_user";
142
+ readonly email: "admin@playcademy.com";
143
+ readonly emailVerified: true;
144
+ readonly image: null;
145
+ readonly role: "admin";
146
+ readonly developerStatus: "approved";
147
+ readonly createdAt: Date;
148
+ readonly updatedAt: Date;
149
+ };
150
+ export declare const DEMO_TOKEN = "sandbox-demo-token";
4
151
  export declare const PLAYCADEMY_CREDITS_ID: `${string}-${string}-${string}-${string}-${string}`;
5
152
  export declare const SAMPLE_ITEMS: Omit<Item, 'createdAt'>[];
6
153
  export declare const SAMPLE_INVENTORY: {
7
154
  id: `${string}-${string}-${string}-${string}-${string}`;
8
- userId: string;
155
+ userId: `${string}-${string}-${string}-${string}-${string}`;
9
156
  itemId: `${string}-${string}-${string}-${string}-${string}`;
10
157
  quantity: number;
11
158
  }[];
@@ -1,5 +1,5 @@
1
1
  import { PGlite } from '@electric-sql/pglite';
2
- import * as schema from '@playcademy/data/schemas';
2
+ import * as schema from '@playcademy/data/tables';
3
3
  import type { PgliteDatabase } from 'drizzle-orm/pglite';
4
4
  export declare function setupDatabase(customPath?: string): Promise<PgliteDatabase<typeof schema> & {
5
5
  $client: PGlite;
@@ -1,16 +1,16 @@
1
1
  import { setupDatabase } from '.';
2
2
  import type { ProjectInfo } from '../types';
3
3
  export declare function seedDemoData(db: Awaited<ReturnType<typeof setupDatabase>>): Promise<{
4
- id: string;
5
- name: string;
6
- username: string | null;
7
- email: string;
8
- emailVerified: boolean;
9
- image: string | null;
10
- role: "admin" | "player" | "developer";
11
- developerStatus: "none" | "pending" | "approved";
12
- createdAt: Date;
13
- updatedAt: Date;
4
+ readonly id: `${string}-${string}-${string}-${string}-${string}`;
5
+ readonly name: "Admin User";
6
+ readonly username: "admin_user";
7
+ readonly email: "admin@playcademy.com";
8
+ readonly emailVerified: true;
9
+ readonly image: null;
10
+ readonly role: "admin";
11
+ readonly developerStatus: "approved";
12
+ readonly createdAt: Date;
13
+ readonly updatedAt: Date;
14
14
  }>;
15
15
  export declare function generateLevelConfigs(): {
16
16
  level: number;
@@ -21,12 +21,14 @@ export declare function seedCurrentProjectGame(db: Awaited<ReturnType<typeof set
21
21
  id: string;
22
22
  createdAt: Date | null;
23
23
  updatedAt: Date | null;
24
- displayName: string;
25
24
  developerId: string | null;
26
25
  slug: string;
26
+ displayName: string;
27
27
  version: string;
28
- assetBundleBase: string;
28
+ gameType: "hosted" | "external";
29
+ assetBundleBase: string | null;
30
+ externalUrl: string | null;
29
31
  platform: "web" | "godot" | "unity";
30
32
  mapElementId: string | null;
31
- metadata: unknown;
33
+ metadata: import("@playcademy/data/tables").GameMetadata;
32
34
  } | undefined>;
@@ -1,2 +1,5 @@
1
1
  import type { Context, Next } from 'hono';
2
+ /**
3
+ * Setup authentication middleware for sandbox
4
+ */
2
5
  export declare function setupAuth(): (c: Context, next: Next) => Promise<void>;
@@ -1,2 +1,22 @@
1
+ import { ApiError } from '@playcademy/api-core/errors';
1
2
  import type { Context } from 'hono';
3
+ /**
4
+ * Create a standardized error response that matches the API contract
5
+ */
6
+ export declare function createErrorResponse(error: ApiError): {
7
+ error: {
8
+ code: string;
9
+ message: string;
10
+ details: unknown;
11
+ };
12
+ };
13
+ /**
14
+ * Create a standardized error response for unknown errors
15
+ */
16
+ export declare function createUnknownErrorResponse(error: unknown): {
17
+ error: {
18
+ code: string;
19
+ message: string;
20
+ };
21
+ };
2
22
  export declare function handleApiError(c: Context, error: unknown): Response;
@@ -0,0 +1,17 @@
1
+ import { createRealtimeServer } from '@playcademy/realtime/server';
2
+ import type { SandboxRealtimeServer } from '@playcademy/realtime/server/sandbox';
3
+ import type { ServerOptions } from '../types';
4
+ /**
5
+ * Starts the realtime server with sandbox-specific configuration.
6
+ *
7
+ * This function handles:
8
+ * - Conditional startup based on options
9
+ * - Sandbox-specific authentication secrets
10
+ * - Quiet mode for clean embedded logging
11
+ * - Error handling with graceful degradation
12
+ *
13
+ * @param realtimeOptions - Realtime configuration from ServerOptions
14
+ * @param betterAuthSecret - Authentication secret for realtime server
15
+ * @returns Promise resolving to realtime server instance or null
16
+ */
17
+ export declare function startRealtimeServer(realtimeOptions: NonNullable<ServerOptions['realtime']>, betterAuthSecret: string): Promise<SandboxRealtimeServer | Awaited<ReturnType<typeof createRealtimeServer>> | null>;
package/dist/pglite.data CHANGED
Binary file
package/dist/pglite.wasm CHANGED
Binary file
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const achievementsRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const characterRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -10,3 +10,11 @@ export { mapRouter, mapsRouter } from './maps';
10
10
  export { shopListingsRouter } from './shop-listings';
11
11
  export { devRouter } from './dev';
12
12
  export { levelsRouter } from './levels';
13
+ export { leaderboardRouter } from './leaderboard';
14
+ export { realtimeRouter } from './realtime';
15
+ export { characterRouter } from './character';
16
+ export { spriteRouter } from './sprite';
17
+ export { timebackRouter } from './timeback';
18
+ export { achievementsRouter } from './achievements';
19
+ export { ltiRouter } from './lti';
20
+ export { notificationsRouter } from './notifications';
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const leaderboardRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const ltiRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const notificationsRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const realtimeRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const spriteRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,3 @@
1
+ import { Hono } from 'hono';
2
+ import type { HonoEnv } from '../types';
3
+ export declare const timebackRouter: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
package/dist/server.d.ts CHANGED
@@ -1,3 +1,7 @@
1
- import type { ServerOptions } from './types';
2
- export declare function startServer(options: ServerOptions): Promise<import("@hono/node-server").ServerType>;
1
+ import type { ProjectInfo, ServerOptions } from './types';
2
+ export declare function startServer(port: number, project?: ProjectInfo, options?: Omit<ServerOptions, 'port' | 'project'>): Promise<{
3
+ main: import("@hono/node-server").ServerType;
4
+ realtime: Bun.Server | import("@playcademy/realtime/server/sandbox").SandboxRealtimeServer | null;
5
+ stop: () => void;
6
+ }>;
3
7
  export declare const version: string;