From d4557fd8b8f171be5ebe4901e6476cfa52b0d340 Mon Sep 17 00:00:00 2001 From: anadoris007 Date: Mon, 20 Apr 2026 22:02:44 +0530 Subject: [PATCH] feat(narrative): add frontend API client Five named exports covering narrative endpoints, following the existing pattern in frontend/src/api/simulation.js (service + requestWithRetry + named exports). Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/api/narrative.js | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 frontend/src/api/narrative.js diff --git a/frontend/src/api/narrative.js b/frontend/src/api/narrative.js new file mode 100644 index 00000000..70d37fb2 --- /dev/null +++ b/frontend/src/api/narrative.js @@ -0,0 +1,42 @@ +import service, { requestWithRetry } from './index' + +/** + * Get the full generated story for a simulation. + * @param {string} simId + */ +export const getFullStory = (simId) => { + return service.get(`/api/narrative/story/${simId}`) +} + +/** + * Get a single round's story beat. + * @param {string} simId + * @param {number} roundNum + */ +export const getRoundStory = (simId, roundNum) => { + return service.get(`/api/narrative/story/${simId}/round/${roundNum}`) +} + +/** + * Translate a round on demand — generates prose via LLM and stores the beat. + * @param {Object} data - { sim_id, round, platform?, tone? } + */ +export const translateRound = (data) => { + return requestWithRetry(() => service.post('/api/narrative/translate', data), 3, 2000) +} + +/** + * Get extended character roster with emotional state. + * @param {string} simId + */ +export const getCharacters = (simId) => { + return service.get(`/api/narrative/characters/${simId}`) +} + +/** + * Bootstrap narrative character profiles from existing OASIS profiles. + * @param {string} simId + */ +export const initCharacters = (simId) => { + return requestWithRetry(() => service.post(`/api/narrative/characters/${simId}/init`), 3, 1000) +}