Skip to content

Commit a2da07a

Browse files
committed
Merge PR_26179_ALFA_011 Objects Manager MVP
2 parents 13ed907 + f622fce commit a2da07a

13 files changed

Lines changed: 1714 additions & 22 deletions

assets/toolbox/objects/js/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getSessionCurrent } from "../../../../src/api/session-api-client.js";
12
import {
23
createServerRepositoryClient,
34
readServerToolConstants,
@@ -110,6 +111,23 @@ function setText(element, value) {
110111
}
111112
}
112113

114+
function currentSession() {
115+
try {
116+
return getSessionCurrent();
117+
} catch {
118+
return { authenticated: false };
119+
}
120+
}
121+
122+
function redirectGuestWriteAction() {
123+
if (currentSession()?.authenticated === true) {
124+
return false;
125+
}
126+
setText(elements.log, "Sign in before saving Objects.");
127+
window.location.href = new URL("/account/sign-in.html", window.location.href).href;
128+
return true;
129+
}
130+
113131
function listItem(text) {
114132
const item = document.createElement("li");
115133
item.textContent = text;
@@ -585,6 +603,9 @@ function readPersistedObjects() {
585603
}
586604

587605
function persistDraftedObjects(nextObjects) {
606+
if (redirectGuestWriteAction()) {
607+
return null;
608+
}
588609
const normalizedObjects = nextObjects.map(cloneObject);
589610
let result = objectsRepository.replaceObjects(normalizedObjects);
590611
if (result?.error) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# PR_26179_ALFA_011 Branch Validation
2+
3+
| Check | Result | Evidence |
4+
| --- | --- | --- |
5+
| Project Instructions read | PASS | `dev/build/ProjectInstructions/PROJECT_INSTRUCTIONS_VERSION.md` and `PROJECT_INSTRUCTIONS.md` read before implementation. |
6+
| Branch | PASS | Work performed on `PR_26179_ALFA_011-objects-manager-mvp`. |
7+
| Main sync before branch | PASS | `main...origin/main` was `0 0` before branch creation. |
8+
| Canonical report path | PASS | Reports generated under `dev/reports/`. |
9+
| Canonical ZIP path | PASS | ZIP generated under `dev/workspace/zips/`. |
10+
| Legacy output paths avoided | PASS | No new `docs_build/` or `tmp/` artifacts used for this PR. |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# PR_26179_ALFA_011 Manual Validation Notes
2+
3+
## Recommended Owner Checks
4+
5+
1. Start the local API/site using the approved developer command.
6+
2. Open `toolbox/objects/index.html`.
7+
3. Confirm Objects loads the Object Builder table.
8+
4. Sign in as a Creator.
9+
5. Add a Hero object and save.
10+
6. Refresh the page and confirm the Hero remains.
11+
7. Edit the object, save, refresh, and confirm the edit remains.
12+
8. Delete the object, refresh, and confirm the table is empty.
13+
9. Click Seed Starter Objects and confirm Hero, Projectile, and Wall appear.
14+
10. Sign out, attempt a save, and confirm redirect to `account/sign-in.html`.
15+
16+
## Notes
17+
18+
- No fallback test lane was required because targeted validation passed.
19+
- No runtime data is owned by the browser page.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# PR_26179_ALFA_011 Objects Manager MVP Report
2+
3+
## Product Owner Testable Outcome
4+
5+
The Objects tool now saves and reloads object rows through the server API/database contract. A signed-in Creator can add, edit, delete, seed starter objects, validate setup, reload the page, and see persisted Objects data for the current Game Hub game.
6+
7+
## Implementation Summary
8+
9+
- Added a DB-backed Objects API service for `object_definition_records`.
10+
- Routed the active Objects tool repository away from the mock repository and into the shared API service path.
11+
- Preserved the browser as an API client only; the server owns record keys, game scoping, and audit fields.
12+
- Added guest write protection so create/update/delete actions redirect to `account/sign-in.html`.
13+
- Kept the existing Theme V2 Objects UI and table workflow intact.
14+
15+
## What Can The Product Owner Test After Applying This ZIP?
16+
17+
Open `toolbox/objects/index.html`, sign in as a Creator, add an object, save it, refresh the page, edit it, delete it, seed starter objects, and confirm the rows persist through the API/database path. As a guest, attempt to save a row and confirm the browser redirects to sign-in.
18+
19+
## Playwright Coverage
20+
21+
- `dev/tests/playwright/tools/ObjectsTool.spec.mjs`
22+
- Covers production copy, object table workflow, guest redirect, persisted add/edit/delete, sprite-linked rows, catalog prefills, and Toolbox beta routing.
23+
24+
## Manual Validation
25+
26+
- Open Objects from Toolbox.
27+
- Confirm the Object Builder table loads without console errors.
28+
- Add a Hero object and save.
29+
- Refresh and confirm the Hero remains.
30+
- Edit the object name/state and save.
31+
- Refresh and confirm edits remain.
32+
- Delete the object and refresh.
33+
- Sign out, try to save, and confirm redirect to `account/sign-in.html`.
34+
35+
## Stack Context
36+
37+
- Part of stacked MVP sequence: yes.
38+
- Previous PR dependency: `PR_26179_ALFA_010-objects-inventory-audit`.
39+
- Next PR dependency: `PR_26179_ALFA_012-objects-properties-mvp`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# PR_26179_ALFA_011 Requirement Checklist
2+
3+
| Requirement | Result | Notes |
4+
| --- | --- | --- |
5+
| Implement Objects Manager MVP exactly as described | PASS | Objects Manager now supports API/database-backed add, edit, delete, seed, validate, reload persistence. |
6+
| Use Local API / Local DB contract | PASS | Browser uses `createServerRepositoryClient("objects")`; server routes Objects to `createObjectsApiService`. |
7+
| Browser must not own product data | PASS | Browser submits object rows to API; persistence, keys, game scoping, and audit fields are server-owned. |
8+
| No page-local product data arrays | PASS | No authoritative object records are stored in page-local arrays; page state mirrors API data only. |
9+
| No silent fallbacks | PASS | Missing setup raises controlled Objects API setup errors instead of returning fake rows. |
10+
| Use Theme V2 classes first | PASS | Existing Theme V2 tool layout and button/table classes remain in use. |
11+
| No inline styles/scripts/events | PASS | No inline styles, script blocks, or inline event handlers were added. |
12+
| Targeted Playwright for Objects Manager | PASS | Objects Playwright lane passed 7/7. |
13+
| `git diff --check` | PASS | Whitespace check passed. |
14+
| `npm run validate:canonical-structure` | PASS | Canonical structure guardrail passed. |
15+
| Fallback `npm run test:workspace-v2` | PASS | Not required because targeted validation passed. |
16+
| Required reports and ZIP | PASS | Reports created under `dev/reports/`; ZIP created under `dev/workspace/zips/`. |
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# PR_26179_ALFA_011 Validation Lane
2+
3+
## Lane
4+
5+
Objects Manager focused lane.
6+
7+
## Coverage
8+
9+
- Service-level DB adapter behavior for `createObjectsApiService`.
10+
- Browser Objects workflow against the shared API route.
11+
- Guest write redirect.
12+
- Reload persistence.
13+
- Toolbox registry visibility for Objects beta.
14+
15+
## Result
16+
17+
PASS. Objects API service tests passed 3/3. Objects Playwright tests passed 7/7.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# PR_26179_ALFA_011 Validation Report
2+
3+
## Commands
4+
5+
| Command | Result |
6+
| --- | --- |
7+
| `node --check src/dev-runtime/toolbox-api/alfa-tool-services.mjs` | PASS |
8+
| `node --check src/dev-runtime/server/local-api-router.mjs` | PASS |
9+
| `node --check assets/toolbox/objects/js/index.js` | PASS |
10+
| `node --check dev/tests/dev-runtime/ObjectsApiService.test.mjs` | PASS |
11+
| `node --check dev/tests/playwright/tools/ObjectsTool.spec.mjs` | PASS |
12+
| `node ./dev/scripts/run-node-test-files.mjs dev/tests/dev-runtime/ObjectsApiService.test.mjs` | PASS, 3/3 |
13+
| `git diff --check` | PASS |
14+
| `npm run validate:canonical-structure` | PASS |
15+
| `npx playwright test dev/tests/playwright/tools/ObjectsTool.spec.mjs --config=dev/config/playwright.config.cjs --project=playwright --workers=1 --reporter=list` | PASS, 7/7 |
16+
17+
## Result
18+
19+
PASS. Required targeted validation passed. `npm run test:workspace-v2` fallback was not required.
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
dev/build/ProjectInstructions/PROJECT_INSTRUCTIONS.md
2-
dev/reports/PR_26180_OWNER_002-add-delta-to-canonical-active-teams_report.md
3-
dev/reports/PR_26180_OWNER_002-add-delta-to-canonical-active-teams_validation-checklist.md
4-
dev/reports/PR_26180_OWNER_002-add-delta-to-canonical-active-teams_manual-validation-notes.md
5-
dev/reports/codex_changed_files.txt
6-
dev/reports/codex_review.diff
1+
M assets/toolbox/objects/js/index.js
2+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_branch-validation.md
3+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_manual-validation-notes.md
4+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_report.md
5+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_requirement-checklist.md
6+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_validation-lane.md
7+
A dev/reports/PR_26179_ALFA_011-objects-manager-mvp_validation-report.md
8+
M dev/reports/codex_changed_files.txt
9+
M dev/reports/codex_review.diff
10+
A dev/tests/dev-runtime/ObjectsApiService.test.mjs
11+
M dev/tests/playwright/tools/ObjectsTool.spec.mjs
12+
M src/dev-runtime/server/local-api-router.mjs
13+
M src/dev-runtime/toolbox-api/alfa-tool-services.mjs

0 commit comments

Comments
 (0)