Skip to content

feat: save and load mapping files to/from GitHub - #140

Draft
kyuchia wants to merge 8 commits into
mainfrom
feat/github-storage
Draft

feat: save and load mapping files to/from GitHub#140
kyuchia wants to merge 8 commits into
mainfrom
feat/github-storage

Conversation

@kyuchia

@kyuchia kyuchia commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Moves the .csv suffix to the GitHub backend boundary.

  • Callers (MappingStorage, PouchDbLocalStore, nameToPath) use bare names, so the logged-out PouchDB lookup keeps matching.
  • The GitHub backend adds .csv on read/write/delete and strips it from listFiles output.

Verified

  • Save: file lands on GitHub as <name>.csv with clean CSV content.
  • Read-back: edited a value directly on GitHub and confirmed it loads back into Cress (proves the read path goes through the remote, not local).

Still open (not in this PR)

  • Delete/list dashboard wiring. Deleting in the dashboard currently removes the local PouchDB copy only; the GitHub copy is untouched until deleteMapping is wired.
  • Option 1 vs Option 2 backend decision (pending meeting).
  • Logged-in path was verified with a manually supplied token, not the real OAuth login UI.

kyuchia added 7 commits June 15, 2026 12:57
Backend-agnostic core shared by both storage options under discussion
(Worker-proxy vs user-owned repo):

- csv.ts: RFC 4180 CSV serialize/parse (base64 image fields, quotes,
  commas, newlines)
- cressRows.ts: bridge between Cress's [headers, ...rowObjects] payload
  and string[][]
- backend.ts: StorageBackend interface + Conflict/NotAuthenticated errors
- MappingStorage.ts: orchestration (SHA conflict check, logged-out
  PouchDB fallback per #138)
- GitHubUserRepoBackend.ts: contents-API backend (repo assumed to exist;
  POST /user/repos deferred to ensureRepo() stub)
- PouchDbLocalStore.ts: adapter onto existing Storage.ts (skeleton)
…r repo) (#3)

Both StorageBackend implementations behind the shared interface, so the
meeting can choose between them with working code rather than on paper:

- GitHubUserRepoBackend.ensureRepo(): real impl (GET /repos check +
  POST /user/repos with auto_init, idempotent). Option 2 is end-to-end
  capable against the user's own repo.
- WorkerBackend (new): Option 1, routes /files/{read,write,list,delete}
  through a lab Worker that holds GitHub write creds; user token used for
  authz. Frontend complete and mock-tested; Worker endpoints not yet
  built (current Worker only does OAuth exchange).

Mock-tested: ensureRepo create/no-op/idempotent, WorkerBackend CRUD +
conflict, and an interchangeability check proving MappingStorage behaves
identically with either backend injected.
@kyuchia

kyuchia commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator Author

Logged in via manually supplied token, showing ensureRepo auto-create + the .csv filename boundary:

Screenshots: Cress editor → auto-created repo → CSV on GitHub

[Image 1: Cress editor]
pr140-1-editor

[Image 2: auto-created cress-mappings repo, demo-mapping.csv]
pr140-2-repo-auto-created

[Image 3: CSV content on GitHub]
pr140-3-csv-on-github

@kyuchia kyuchia changed the title feat: save and load mapping files to/from GitHub (#3) feat: save and load mapping files to/from GitHub Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant