# Features — edge_functions

Evidence date: 2026-10-16.

Source: `git@bitbucket.org:overdrive/edge_functions.git`, `main` at `7449104` (2024-05-02).

"Current" means the behaviour is in a file on that commit and is not commented out. There is no issue tracker, changelog, or roadmap in the repository. Nothing is marked planned unless a comment describes behaviour the running lines do not perform. Those comments are recorded as inactive source, not as a committed plan.

The scaffold bearer token in the function comments is not copied here.

## Current features

### F-01 — `hello` greets with `sites.name`

`supabase/functions/hello/index.ts`. Endpoint `/functions/v1/hello`.

Cold start logs `Hello from Functions!` and builds a Supabase client from `SUPABASE_URL` and `SUPABASE_ANON_KEY`. Each request runs `from('sites').select('name').limit(1).single()` and returns `{ "message": "Hello <sites.name>!" }` as JSON. The request body is ignored. A query error is logged and the message becomes `Hello undefined!` with HTTP 200.

Origin: `7449104`, the only commit that contains function source. The file still has the CLI scaffold comment (`POST`, body `{"name":"Functions"}`).

Status: **current**. Confidence: high for the source. Whether it is deployed is **Unknown / Requires Confirmation**.

### F-02 — `callsheet` downloads a fixed call-cycle workbook

`supabase/functions/callsheet/index.ts`. Endpoint `/functions/v1/callsheet`.

Downloads bucket `uploads`, object `callsheet/CMR_CALL_CYCLE_2023.xlsx`, using the same URL and anon key as `hello`. Reads the file with `xlsx` from `https://deno.land/x/flat/mod.ts` and logs `SheetNames`.

The HTTP response is always the initial payload `{ "message": {}, "result": {}, "sent": {} }` when `xlsx.read` returns. Download `error` is discarded.

`readXLSX` is imported and unused.

Status: **current** as a download-and-log handler. It does not return sheet data. Confidence: high.

### F-03 — `upload_sj` source targets `report_sj`

`supabase/functions/upload_sj/index.ts`. Endpoint `/functions/v1/upload_sj`.

The running lines try to:

- build a second client from `SUPABASE_STORAGE_URL` and `SUPABASE_ANON_STORAGE_KEY`;
- pass that client into `createClient` from `npm:@supabase/storage-js`;
- download `FState Region ALL CHANNEL REPORTS 10 MARCH 2024.xlsx` from `from('uploads/callsheet')`;
- `read` the file with `npm:xlsx/mod`, then `read` the first sheet with `{ header: 1 }`;
- `upsert` the result into `report_sj`.

Both the error branch and the success branch assign to `data` after `const { data, error }`, and the error branch then `throw error`. The `Response` under those branches is not reached.

`decode` from `npm:std/encoding/base64` is imported and unused. `Deno.serve` is declared `(req, res)`. `res` is unused. `req` is unused.

Status: **current** as committed source. **Not** a completed upload feature. Confidence: high that the `const` assignment throws if execution gets that far. The storage-js call shape was not executed in this inspection.

### F-04 — Supabase CLI project

`package.json` has one devDependency, `supabase` `^1.151.1`. The lockfile resolves `1.151.1` and names the package `datafy_edge_fuctions`. There are no npm scripts.

`supabase/config.toml` sets `project_id = "datafy_edge_fuctions"`. The rest of the file is the local stack from `supabase init` (ports, Postgres 15, auth, storage `50MiB`, Studio, Inbucket, Realtime, Analytics, experimental S3 env placeholders). There is no `[functions.*]` table.

`supabase/seed.sql` exists and is empty. There is no `supabase/migrations` directory.

`supabase/.gitignore` ignores `.branches`, `.temp`, and `.env`.

Status: **current**. Confidence: high.

### F-05 — Documented local serve and `hello` deploy

`readme.txt`.

- Install Deno on Windows, then the Supabase CLI via the quickstart links in that file.
- `npx supabase init` and `npx supabase functions new hello`.
- `npx supabase start` and `npx supabase functions serve --no-verify-jwt`.
- Local hello URL `http://127.0.0.1:54321/functions/v1/hello`.
- `npx supabase login` and `npx supabase functions deploy hello --no-verify-jwt`.
- Hosted URL `https://natpyffafbqetnbeoctm.supabase.co/functions/v1/hello`.
- Example `supabase secrets set MY_NAME=Chewbacca`. No function reads `MY_NAME`.

The readme does not mention `callsheet` or `upload_sj`. Those directories were added in the same commit as the readme.

Status: **current** as documentation. The commands were not re-run. Deploy result is **Unknown / Requires Confirmation**.

### F-06 — Deno editor support

`.vscode/extensions.json` recommends `denoland.vscode-deno`.

`.vscode/settings.json` enables Deno on `supabase/functions`, turns on `deno.lint` and `deno.unstable`, and sets the TypeScript formatter to `denoland.vscode-deno`.

Status: **current**. Confidence: high. There is no `deno.json`.

### F-07 — SonarQube pipeline on `main`

`bitbucket-pipelines.yml` runs on branch `main` only. Image `maven:3.3.9`. Step "SonarQube analysis" uses pipe `sonarsource/sonarqube-scan:2.0.1` with `SONAR_HOST_URL` and `SONAR_TOKEN`. Cache `~/.sonar`. Clone depth `full`.

`sonar-project.properties` sets only `sonar.projectKey=overdrive_edge_functions_d17c9661-3898-4839-85d2-04c487089cf1`.

Added in `323c389` and `2f97818` (2024-03-29), before the functions existed. The pipeline does not deploy or test.

Status: **current** as config. Confidence: high for the YAML. Whether the Bitbucket variables are still set is **Unknown**.

## Incomplete or inactive source

### F-08 — Per-sheet CSV inside `callsheet`

Commented block in `callsheet/index.ts`: for each sheet, `readCSV`, log it, and assign `data.result`. Also commented: download `FState Region ALL CHANNEL REPORTS 10 MARCH 2024.xlsx` via an undefined `storage` binding, and a hello-style response from `req.json()`.

`readCSV` is not imported. The live payload fields stay empty objects.

Status: **inactive** (comments). Not a planned feature. Nobody wrote a ticket or a readme line for it. Confidence: high.

### F-09 — Request-path file selection in `upload_sj`

Commented: `const filePath = req.url.substring(1)`. The download uses a hardcoded filename instead.

Status: **inactive**. Confidence: high.

## Planned features

None documented. `readme.txt` stops at deploying `hello` and an example secret.

## In development

Git has no branch other than `main` and no commit after 2024-05-02. Nothing is in development inside this repository.

`callsheet` and `upload_sj` look unfinished (empty response, unreachable return). That is the state of `main`, not a separate in-progress branch.

## Completed features

No feature is marked complete. `hello` is the only handler that returns the JSON it builds, and its deploy state was not checked. `upload_sj` does not finish. `callsheet` does not return the workbook contents the comments discuss.

## Recently changed

The only functional change is `7449104` (2024-05-02), which added the readme, CLI config, editor settings, and all three functions together. Sonar files landed on 2024-03-29 and have not changed. There is no delta after May 2024 to call recent as of this evidence date.

## Deprecated or removed

No function directory was removed. History does not show a renamed endpoint. The initial `.gitignore` (`3ee659a`) is still the root ignore file. It is a generic template (Node, Java, Python, Maven, JetBrains, media). It was not replaced when the Supabase tree arrived.

## Not in this repository

The onboarding issue listed `sonarqube_scan.bat`. It is not on `main` at `7449104` and no commit mentions it.

No tests, no Dockerfile, no import map, no RLS, no seed data, and no frontend.
