Skip to content

Commit 52c3644

Browse files
committed
Continue server API migration and add Local Mem Local DB login modes - PR_26158_023-server-api-migration-pass-3-login-environments
1 parent 4ea9df5 commit 52c3644

27 files changed

Lines changed: 583 additions & 280 deletions

admin/db-viewer.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<meta charset="utf-8">
66
<base href="/">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<title>Mock DB - GameFoundryStudio</title>
9-
<meta name="description" content="Admin-only read-only mock DB viewer for GameFoundryStudio project data diagnostics.">
8+
<title>Local Mem DB - GameFoundryStudio</title>
9+
<meta name="description" content="Admin-only read-only Local Mem DB viewer for GameFoundryStudio project data diagnostics.">
1010
<link rel="icon" href="/favicon.svg">
1111
<link rel="stylesheet" href="assets/theme-v2/css/theme.css">
1212
</head>
@@ -16,25 +16,25 @@
1616
<main data-admin-only="true">
1717
<section class="page-title">
1818
<div class="container">
19-
<div class="kicker">Admin Only / Mock DB</div>
20-
<h1>Mock DB</h1>
21-
<p class="lede">Read-only mock DB dump for project tables, relationships, and data diagnostics.</p>
19+
<div class="kicker">Admin Only / Local Mem DB</div>
20+
<h1>Local Mem DB</h1>
21+
<p class="lede">Read-only Local Mem DB dump for project tables, relationships, and data diagnostics.</p>
2222
</div>
2323
</section>
2424
<section class="section">
2525
<div class="container container--tool-wide">
2626
<div class="tool-workspace tool-workspace--wide">
2727
<aside class="tool-column tool-group-build">
2828
<div class="tool-column-header">
29-
<h2>Mock DB</h2>
29+
<h2>Local Mem DB</h2>
3030
</div>
3131
<div class="accordion-stack">
3232
<details class="vertical-accordion" open>
3333
<summary>Scope</summary>
3434
<div class="accordion-body content-stack">
35-
<p>Current tool mock DB records are displayed as a read-only human-readable dump.</p>
35+
<p>Current tool Local Mem DB records are displayed as a read-only human-readable dump.</p>
3636
<p>Use the diagnostics panel to confirm table attribution, relationships, and table bleed checks.</p>
37-
<button class="btn btn--compact" type="button" data-admin-db-clear>Clear Mock DB</button>
37+
<button class="btn btn--compact" type="button" data-admin-db-clear>Clear Local Mem DB</button>
3838
</div>
3939
</details>
4040
</div>
@@ -43,13 +43,13 @@ <h2>Mock DB</h2>
4343
<section class="tool-center-panel content-stack" aria-labelledby="admin-db-viewer-title" data-admin-db-viewer>
4444
<div class="content-cluster">
4545
<div>
46-
<div class="kicker">Mock DB</div>
47-
<h2 id="admin-db-viewer-title">Mock DB</h2>
46+
<div class="kicker">Local Mem DB</div>
47+
<h2 id="admin-db-viewer-title">Local Mem DB</h2>
4848
</div>
49-
<span class="status" role="status" data-admin-db-status>Loading mock DB records.</span>
49+
<span class="status" role="status" data-admin-db-status>Loading Local Mem DB records.</span>
5050
</div>
51-
<div class="action-group" role="group" aria-label="Mock DB table filters" data-admin-db-filters></div>
52-
<section class="content-stack" aria-label="Mock DB tables" data-admin-db-tables></section>
51+
<div class="action-group" role="group" aria-label="Local Mem DB table filters" data-admin-db-filters></div>
52+
<section class="content-stack" aria-label="Local Mem DB tables" data-admin-db-tables></section>
5353
</section>
5454
<aside class="tool-column tool-group-build">
5555
<div class="tool-column-header">

admin/db-viewer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function localModeSelected() {
1313
request.setRequestHeader("Accept", "application/json");
1414
request.send(null);
1515
const payload = request.responseText ? JSON.parse(request.responseText) : null;
16-
return request.status >= 200 && request.status < 300 && payload?.data?.mode === "local";
16+
return request.status >= 200 && request.status < 300 && payload?.data?.mode === "local-mem";
1717
} catch {
1818
return false;
1919
}
@@ -31,17 +31,17 @@ async function loadLocalDbViewer() {
3131
return;
3232
}
3333
if (!devRuntimeAllowed()) {
34-
showGatewayStatus("Mock DB is available only in the local dev runtime.");
34+
showGatewayStatus("Local Mem DB is available only in the local dev runtime.");
3535
return;
3636
}
3737
if (!localModeSelected()) {
38-
showGatewayStatus("Mock DB is available only in Local mode.");
38+
showGatewayStatus("Local Mem DB is available only in Local Mem mode until Local DB adapter is configured.");
3939
return;
4040
}
4141
const module = await import("../src/engine/api/mock-db-viewer-ui.js");
4242
module.startMockDbViewer(document);
4343
}
4444

4545
loadLocalDbViewer().catch((error) => {
46-
console.error("Unable to load Local Mock DB viewer.", error);
46+
console.error("Unable to load Local Mem DB viewer.", error);
4747
});

admin/tools-progress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function renderToolsProgress() {
112112
row.append(cell);
113113
progressBody.append(row);
114114
if (progressSummary) {
115-
progressSummary.textContent = "Tool registry API unavailable. Start the Local/DEV server API and refresh.";
115+
progressSummary.textContent = "Tool registry API unavailable. Start the local server API and refresh.";
116116
}
117117
return;
118118
}

assets/theme-v2/js/gamefoundry-partials.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@
163163
authenticated: Boolean(session.authenticated),
164164
diagnostic: session.diagnostic || "",
165165
displayName: session.authenticated ? session.displayName || session.label || "Account" : "Login",
166-
mode: session.mode || "local",
166+
mode: session.mode || "local-mem",
167167
roleSlugs: Array.isArray(session.roleSlugs) ? session.roleSlugs : []
168168
};
169169
} catch (error) {
170170
return {
171171
authenticated: false,
172-
diagnostic: "Server session API is unavailable. Start the Local/DEV server API before using protected pages.",
172+
diagnostic: "Server session API is unavailable. Start the local server API before using protected pages.",
173173
displayName: "Login",
174174
mode: "missing-api",
175175
roleSlugs: []

assets/theme-v2/js/login-session.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ function renderUserButtons(mode) {
5757
}
5858

5959
userControls.replaceChildren();
60-
if (mode.id === "dev") {
60+
if (mode.usersEnabled === false) {
6161
userControls.hidden = true;
6262
if (userStatus) {
63-
userStatus.textContent = "DEV mode uses read-only/demo JSON access. No users are selectable.";
63+
userStatus.textContent = mode.diagnostic || "No local users are selectable for this environment.";
6464
}
6565
return;
6666
}
@@ -103,7 +103,7 @@ function renderError(error) {
103103
modeTitle.textContent = "Session API unavailable";
104104
}
105105
if (modeDescription) {
106-
modeDescription.textContent = "Start the Local/DEV server API to select a session.";
106+
modeDescription.textContent = "Start the local server API to select a session.";
107107
}
108108
if (modeStatus) {
109109
modeStatus.textContent = `Login/session diagnostic: ${message}`;
@@ -130,7 +130,16 @@ function render() {
130130
modeDescription.textContent = mode.description;
131131
}
132132
if (modeStatus) {
133-
modeStatus.textContent = `${mode.label} mode selected.`;
133+
const environment = session.environment || mode.environment || mode.label;
134+
const persistence = session.persistence || mode.persistence || "";
135+
const statusParts = [`Environment: ${environment}`];
136+
if (persistence) {
137+
statusParts.push(`Persistence: ${persistence}`);
138+
}
139+
if (session.diagnostic || mode.diagnostic) {
140+
statusParts.push(`Diagnostic: ${session.diagnostic || mode.diagnostic}`);
141+
}
142+
modeStatus.textContent = statusParts.join(". ") + ".";
134143
}
135144
renderUserButtons(mode);
136145
updateContinueLink();
@@ -142,7 +151,7 @@ function render() {
142151
modeButtons.forEach((button) => {
143152
button.addEventListener("click", () => {
144153
try {
145-
setSessionMode(button.dataset.loginMode || "local");
154+
setSessionMode(button.dataset.loginMode || "local-mem");
146155
dispatchModeChanged();
147156
render();
148157
} catch (error) {
@@ -157,7 +166,7 @@ userControls?.addEventListener("click", (event) => {
157166
return;
158167
}
159168
try {
160-
setSessionMode("local");
169+
setSessionMode("local-mem");
161170
setSessionUser(button.dataset.loginUser || "");
162171
dispatchSessionChanged();
163172
render();

assets/theme-v2/js/tool-display-mode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
const diagnostic = document.createElement("p");
149149
diagnostic.className = "status";
150150
diagnostic.setAttribute("role", "status");
151-
diagnostic.textContent = "Tool navigation could not load from the server API. Start the Local/DEV server API and refresh.";
151+
diagnostic.textContent = "Tool navigation could not load from the server API. Start the local server API and refresh.";
152152
body.appendChild(diagnostic);
153153
}
154154
}

docs_build/dev/admin-notes/index.txt

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
[ ] http://127.0.0.1:5500/admin/db-viewer.html
3-
4-
[ ] Tiles
5-
-
2+
[ ] move
3+
src\assets\fonts\0xProtoNerdFont\ to assets\theme-v2\fonts\
4+
src\assets\fonts\vector_battle\ to assets\theme-v2\fonts\
5+
delete src\assets\
66

77
[ ] Project Life Cycle
88

@@ -19,7 +19,7 @@
1919
- left to right easiest to hardest
2020
- build off of, type, enemy, heros, levels, etc.
2121

22-
[x] Admin notes
22+
[.] Admin notes
2323
- reads txt file (this one) and displays
2424
- if a note has [subnote] it should be a link on the page and display [subnote].txt
2525
- example [other] should display other.txt,
@@ -35,3 +35,24 @@
3535
- each section will have a start end time
3636
- The test/debug page will be the location for test,
3737
- only on when run from test
38+
39+
[ ] Before UAT, add a milestone:
40+
41+
Security Gate 1
42+
43+
Requirements:
44+
45+
Server-side session
46+
Server-side auth
47+
Server-side role checks
48+
Server-side ownership checks
49+
API layer between UI and DB
50+
No direct browser DB writes
51+
52+
Scoring it today 2026-06-06:
53+
Data Model 8/10
54+
Role Model 8/10
55+
UI Protection 7/10
56+
Real Security 1/10
57+
58+
because true security doesn't exist until the server validates every request.
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
# PR_26158_022 Browser Mock Remaining Audit
1+
# PR_26158_024 Browser Mock Remaining Audit
22

3-
## Audit Scope
3+
## Scope
44

5-
Active browser/tool files changed or adjacent to PR_26158_020/021:
5+
Focused audit for browser-visible files and adjacent server/API cleanup touched in PR_26158_024:
66

7+
- `admin/db-viewer.html`
78
- `admin/db-viewer.js`
8-
- `assets/theme-v2/js/login-session.js`
9-
- `assets/theme-v2/js/tool-display-mode.js`
10-
- `admin/tools-progress.js`
11-
- `toolbox/tools-page-accordions.js`
12-
- `toolbox/project-journey/project-journey.js`
13-
- toolbox API clients under `toolbox/*/*-api-client.js`
14-
- engine API clients under `src/engine/api/`
9+
- `src/engine/api/mock-db-api-client.js`
10+
- `src/engine/api/mock-db-viewer-ui.js`
11+
- `src/dev-runtime/server/mock-api-router.mjs`
12+
- `src/dev-runtime/persistence/mock-db-store.js`
13+
- `tests/playwright/tools/AdminDbViewer.spec.mjs`
14+
- `tests/playwright/tools/LoginSessionMode.spec.mjs`
1515

16-
## Findings
16+
## Static Import Boundary
1717

1818
| Check | Status | Evidence |
1919
| --- | --- | --- |
20-
| Active browser files import `src/dev-runtime` directly. | PASS | Focused `rg` found no active browser entry imports after migration. |
21-
| Active browser files import mock repositories directly. | PASS | Remaining `*-mock-repository.js` imports are repository/server-dev implementation files only. |
22-
| Active browser files import `mock-db-store` or dev persistence. | PASS | `src/engine/persistence/mock-db-store.js` was removed; browser files use API clients. |
23-
| Active browser files import static Toolbox registry records directly. | PASS | Toolbox page, Project Journey, Admin Tools Progress, and Tool Display Mode now use `toolbox/tool-registry-api-client.js`. |
24-
| Active browser files keep page-local mock DB snapshots or fake records. | PASS | Palette invalid/empty source modes are server-owned; DB Viewer reads `/api/mock-db/snapshot`. |
25-
| Active browser files use `localStorage`/`sessionStorage` for mock DB/session fallback. | PASS | Migrated files use session/Mock DB API clients; permitted Workspace/sessionStorage contracts in unrelated shared runtime files were not modified. |
20+
| Browser files import `src/dev-runtime` directly. | PASS | `rg -n '^import .*src/dev-runtime|import\\(.*src/dev-runtime' assets admin toolbox src -g '*.js' -g '!src/dev-runtime/**' ...` returned no matches. |
21+
| Browser files import static `toolRegistry.js` directly. | PASS | `rg -n '^import .*toolRegistry\\.js|import\\(.*toolRegistry\\.js' ...` returned no matches. |
22+
| Browser files import mock repositories directly. | PASS | Refined `rg` excluding repository implementation files returned no matches. |
2623

27-
## Remaining Matches And Classification
24+
## Local Mode Cleanup
2825

29-
`rg` still finds mock/dev strings in these categories:
30-
31-
- `src/dev-runtime/server/mock-api-router.mjs`: PASS, server/dev runtime API owner.
32-
- `toolbox/*/*-mock-repository.js`, `toolbox/colors/palette-workspace-repository.js`, `toolbox/colors/palette-source-mock-db.js`: PASS, server/dev-only repository/data source modules imported by the dev server router.
33-
- `src/shared/toolbox/*` imports of `toolbox/toolRegistry.js`: AUDIT NOTE, product registry/shared shell metadata outside the active browser files changed by this migration pass. The adjacent active consumers were migrated to the server-backed registry endpoint.
26+
| Check | Status | Evidence |
27+
| --- | --- | --- |
28+
| Local login shows only Local Mem and Local DB. | PASS | Login Playwright lane asserts exact labels. |
29+
| DEV/UAT/Prod are not local login buttons. | PASS | Login Playwright lane asserts no DEV, UAT, or Prod buttons. |
30+
| Server rejects legacy `modeId: "local"`. | PASS | API contract probe returned 500 with `Unknown local login environment: local`. |
31+
| Local DB does not fall back to Local Mem. | PASS | API contract probe verified Local DB snapshot fails with `Local DB adapter not configured`. |
32+
| DB Viewer user-facing wording says Local Mem DB. | PASS | Admin DB Viewer Playwright asserts Local Mem DB headings, status text, clear/seed controls, and dialogs. |
3433

35-
## Command Evidence
34+
## Remaining Internal Matches
3635

37-
- `rg -n "dev-runtime|toolRegistry\\.js|mock-db-store|mock-repository|palette-workspace-repository|palette-source-mock-db|localStorage|sessionStorage" admin assets/theme-v2/js toolbox src/engine/api -g "*.js" -g "*.mjs" --glob "!archive/**" --glob "!**/start_of_day/**" --glob "!node_modules/**" --glob "!tmp/**"`
38-
- Remaining results were only server/dev repository implementation modules.
36+
- `toolbox/*/*-mock-repository.js` and `toolbox/colors/palette-workspace-repository.js` remain server/data-source implementation modules, not active browser entry imports.
37+
- `/api/mock-db/*` route names and `mock-db-*` module filenames remain stable internal API contracts.
38+
- Internal exception text `Invalid mock DB audit user key` remains in non-user-facing audit validation.

0 commit comments

Comments
 (0)