playcademy 0.11.14 → 0.12.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/dist/constants.d.ts +72 -1
- package/dist/constants.js +46 -0
- package/dist/db.d.ts +61 -0
- package/dist/db.js +671 -0
- package/dist/edge-play/src/constants.ts +3 -28
- package/dist/{types.d.ts → index.d.ts} +118 -14
- package/dist/index.js +4650 -6635
- package/dist/templates/api/sample-route-with-db.ts.template +141 -0
- package/dist/templates/config/playcademy.config.js.template +4 -0
- package/dist/templates/config/playcademy.config.json.template +3 -0
- package/dist/templates/config/timeback-config.js.template +8 -0
- package/dist/templates/database/db-index.ts.template +21 -0
- package/dist/templates/database/db-schema-index.ts.template +8 -0
- package/dist/templates/database/db-schema-scores.ts.template +43 -0
- package/dist/templates/database/db-schema-users.ts.template +23 -0
- package/dist/templates/database/db-seed.ts.template +52 -0
- package/dist/templates/database/db-types.ts.template +21 -0
- package/dist/templates/database/drizzle-config.ts.template +13 -0
- package/dist/templates/database/package.json.template +20 -0
- package/dist/templates/gitignore.template +17 -0
- package/dist/templates/playcademy-gitignore.template +3 -0
- package/dist/utils.d.ts +31 -14
- package/dist/utils.js +523 -490
- package/package.json +19 -3
- package/dist/templates/backend-config.js.template +0 -6
- package/dist/templates/playcademy.config.js.template +0 -4
- package/dist/templates/playcademy.config.json.template +0 -3
- package/dist/templates/timeback-config.js.template +0 -17
- /package/dist/templates/{sample-route.ts → api/sample-route.ts.template} +0 -0
- /package/dist/templates/{integrations-config.js.template → config/integrations-config.js.template} +0 -0
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
export { GAME_WORKER_DOMAINS, PLAYCADEMY_BASE_URLS, PLAYCADEMY_DOMAINS } from '@playcademy/constants';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* API routes related constants
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Default directory for custom API routes
|
|
8
|
+
* Used when integrations.customRoutes.directory is not specified in config
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_API_ROUTES_DIRECTORY = "server/api";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Database-related constants
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Default directory for database files
|
|
17
|
+
*/
|
|
18
|
+
declare const DEFAULT_DATABASE_DIRECTORY = "db";
|
|
19
|
+
/**
|
|
20
|
+
* Default directory for database schema files
|
|
21
|
+
*/
|
|
22
|
+
declare const DEFAULT_SCHEMA_DIRECTORY = "db/schema";
|
|
23
|
+
/**
|
|
24
|
+
* Default path for seed file
|
|
25
|
+
*/
|
|
26
|
+
declare const DEFAULT_SEED_FILE = "db/seed.ts";
|
|
27
|
+
|
|
3
28
|
/**
|
|
4
29
|
* HTTP server constants for CLI OAuth callback handling
|
|
5
30
|
*/
|
|
@@ -10,6 +35,46 @@ declare const CALLBACK_PATH = "/callback";
|
|
|
10
35
|
/** Timeout for SSO authentication in milliseconds (30 seconds) */
|
|
11
36
|
declare const SSO_AUTH_TIMEOUT_MS = 30000;
|
|
12
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Path constants for CLI directories and files
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* CLI workspace directories (local to project)
|
|
43
|
+
*/
|
|
44
|
+
declare const CLI_DIRECTORIES: {
|
|
45
|
+
/** Root directory for CLI artifacts in workspace */
|
|
46
|
+
readonly WORKSPACE: ".playcademy";
|
|
47
|
+
/** Database directory within workspace */
|
|
48
|
+
readonly DATABASE: ".playcademy/db";
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* CLI user directories (in home directory)
|
|
52
|
+
*/
|
|
53
|
+
declare const CLI_USER_DIRECTORIES: {
|
|
54
|
+
/** User config directory for auth, games store, etc. */
|
|
55
|
+
readonly CONFIG: ".playcademy";
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Default output paths
|
|
59
|
+
*/
|
|
60
|
+
declare const CLI_DEFAULT_OUTPUTS: {
|
|
61
|
+
/** Default worker bundle output for debug command */
|
|
62
|
+
readonly WORKER_BUNDLE: ".playcademy/worker-bundle.js";
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* CLI file names
|
|
66
|
+
*/
|
|
67
|
+
declare const CLI_FILES: {
|
|
68
|
+
/** Auth store file in user config directory */
|
|
69
|
+
readonly AUTH_STORE: "auth.json";
|
|
70
|
+
/** Games deployment info store */
|
|
71
|
+
readonly GAMES_STORE: "games.json";
|
|
72
|
+
/** Dev server PID file */
|
|
73
|
+
readonly DEV_SERVER_PID: "dev-server.pid";
|
|
74
|
+
/** Initial database file (before miniflare) */
|
|
75
|
+
readonly INITIAL_DATABASE: "initial.sqlite";
|
|
76
|
+
};
|
|
77
|
+
|
|
13
78
|
/**
|
|
14
79
|
* Default port numbers for local development servers
|
|
15
80
|
*/
|
|
@@ -25,4 +90,10 @@ declare const DEFAULT_PORTS: {
|
|
|
25
90
|
*/
|
|
26
91
|
declare const CONFIG_FILE_NAMES: string[];
|
|
27
92
|
|
|
28
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Cloudflare Workers compatibility date
|
|
95
|
+
* Update when adopting new Cloudflare features or breaking changes
|
|
96
|
+
*/
|
|
97
|
+
declare const CLOUDFLARE_COMPATIBILITY_DATE = "2024-01-01";
|
|
98
|
+
|
|
99
|
+
export { CALLBACK_PATH, CALLBACK_PORT, CLI_DEFAULT_OUTPUTS, CLI_DIRECTORIES, CLI_FILES, CLI_USER_DIRECTORIES, CLOUDFLARE_COMPATIBILITY_DATE, CONFIG_FILE_NAMES, DEFAULT_API_ROUTES_DIRECTORY, DEFAULT_DATABASE_DIRECTORY, DEFAULT_PORTS, DEFAULT_SCHEMA_DIRECTORY, DEFAULT_SEED_FILE, SSO_AUTH_TIMEOUT_MS };
|
package/dist/constants.js
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
+
// src/constants/api.ts
|
|
2
|
+
var DEFAULT_API_ROUTES_DIRECTORY = "server/api";
|
|
3
|
+
|
|
4
|
+
// src/constants/database.ts
|
|
5
|
+
var DEFAULT_DATABASE_DIRECTORY = "db";
|
|
6
|
+
var DEFAULT_SCHEMA_DIRECTORY = "db/schema";
|
|
7
|
+
var DEFAULT_SEED_FILE = "db/seed.ts";
|
|
8
|
+
|
|
1
9
|
// src/constants/http-server.ts
|
|
2
10
|
var CALLBACK_PORT = 6175;
|
|
3
11
|
var CALLBACK_PATH = "/callback";
|
|
4
12
|
var SSO_AUTH_TIMEOUT_MS = 3e4;
|
|
5
13
|
|
|
14
|
+
// src/constants/paths.ts
|
|
15
|
+
var CLI_DIRECTORIES = {
|
|
16
|
+
/** Root directory for CLI artifacts in workspace */
|
|
17
|
+
WORKSPACE: ".playcademy",
|
|
18
|
+
/** Database directory within workspace */
|
|
19
|
+
DATABASE: ".playcademy/db"
|
|
20
|
+
};
|
|
21
|
+
var CLI_USER_DIRECTORIES = {
|
|
22
|
+
/** User config directory for auth, games store, etc. */
|
|
23
|
+
CONFIG: ".playcademy"
|
|
24
|
+
};
|
|
25
|
+
var CLI_DEFAULT_OUTPUTS = {
|
|
26
|
+
/** Default worker bundle output for debug command */
|
|
27
|
+
WORKER_BUNDLE: ".playcademy/worker-bundle.js"
|
|
28
|
+
};
|
|
29
|
+
var CLI_FILES = {
|
|
30
|
+
/** Auth store file in user config directory */
|
|
31
|
+
AUTH_STORE: "auth.json",
|
|
32
|
+
/** Games deployment info store */
|
|
33
|
+
GAMES_STORE: "games.json",
|
|
34
|
+
/** Dev server PID file */
|
|
35
|
+
DEV_SERVER_PID: "dev-server.pid",
|
|
36
|
+
/** Initial database file (before miniflare) */
|
|
37
|
+
INITIAL_DATABASE: "initial.sqlite"
|
|
38
|
+
};
|
|
39
|
+
|
|
6
40
|
// src/constants/ports.ts
|
|
7
41
|
var DEFAULT_PORTS = {
|
|
8
42
|
/** Sandbox server (mock platform API) */
|
|
@@ -66,11 +100,23 @@ var BADGES = {
|
|
|
66
100
|
EARLY_ADOPTER: ITEM_SLUGS.EARLY_ADOPTER_BADGE,
|
|
67
101
|
FIRST_GAME: ITEM_SLUGS.FIRST_GAME_BADGE
|
|
68
102
|
};
|
|
103
|
+
|
|
104
|
+
// src/constants/index.ts
|
|
105
|
+
var CLOUDFLARE_COMPATIBILITY_DATE = "2024-01-01";
|
|
69
106
|
export {
|
|
70
107
|
CALLBACK_PATH,
|
|
71
108
|
CALLBACK_PORT,
|
|
109
|
+
CLI_DEFAULT_OUTPUTS,
|
|
110
|
+
CLI_DIRECTORIES,
|
|
111
|
+
CLI_FILES,
|
|
112
|
+
CLI_USER_DIRECTORIES,
|
|
113
|
+
CLOUDFLARE_COMPATIBILITY_DATE,
|
|
72
114
|
CONFIG_FILE_NAMES,
|
|
115
|
+
DEFAULT_API_ROUTES_DIRECTORY,
|
|
116
|
+
DEFAULT_DATABASE_DIRECTORY,
|
|
73
117
|
DEFAULT_PORTS,
|
|
118
|
+
DEFAULT_SCHEMA_DIRECTORY,
|
|
119
|
+
DEFAULT_SEED_FILE,
|
|
74
120
|
GAME_WORKER_DOMAINS,
|
|
75
121
|
PLAYCADEMY_BASE_URLS,
|
|
76
122
|
PLAYCADEMY_DOMAINS,
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Development Database Path Helper
|
|
5
|
+
*
|
|
6
|
+
* Provides a helper for drizzle.config.ts to locate the development database.
|
|
7
|
+
* Handles the miniflare database detection and fallback to initial.sqlite.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Get the path to the development database for use in drizzle.config.ts
|
|
11
|
+
*
|
|
12
|
+
* This function:
|
|
13
|
+
* - Checks for an existing miniflare database (created by `playcademy dev`)
|
|
14
|
+
* - Falls back to initial.sqlite if miniflare DB doesn't exist
|
|
15
|
+
* - Creates the database file if it doesn't exist
|
|
16
|
+
* - Migrates initial.sqlite to miniflare DB on first detection
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { getDevDbPath } from 'playcademy'
|
|
21
|
+
* import { defineConfig } from 'drizzle-kit'
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig({
|
|
24
|
+
* schema: './db/schema/index.ts',
|
|
25
|
+
* dbCredentials: { url: getDevDbPath() },
|
|
26
|
+
* // ...
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function getDevDbPath(): string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Database Reset Utility
|
|
34
|
+
*
|
|
35
|
+
* Utility for resetting the local development database
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Reset the database by dropping all tables and recreating from schema
|
|
40
|
+
*
|
|
41
|
+
* This function:
|
|
42
|
+
* 1. Drops all user tables dynamically (queries sqlite_master)
|
|
43
|
+
* 2. Runs `drizzle-kit push` to recreate tables from your schema
|
|
44
|
+
* 3. Returns a connected drizzle instance ready for seeding
|
|
45
|
+
*
|
|
46
|
+
* @returns Better-sqlite3 Database instance with schema applied
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { drizzle } from 'drizzle-orm/better-sqlite3'
|
|
51
|
+
* import { resetDatabase } from 'playcademy/db'
|
|
52
|
+
* import * as schema from './schema'
|
|
53
|
+
*
|
|
54
|
+
* const sqlite = resetDatabase()
|
|
55
|
+
* const db = drizzle(sqlite, { schema })
|
|
56
|
+
* await db.insert(schema.users).values({ ... })
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function resetDatabase(): Database.Database;
|
|
60
|
+
|
|
61
|
+
export { getDevDbPath as getPath, resetDatabase };
|