# Features — intersect_lambda

Evidence date: 2026-10-12. Revision: `main` `5f2193a` (2024-12-13, "updated code").

The source repository does not contain a feature list. Status below is from the SAM templates, handlers, and git history on `main`. Both `README.md` files describe the AWS SAM hello-world sample. That sample is not this product.

Planned features written as a roadmap: **none found**.

## Current features (main)

| Feature | What it does | Evidence | Status |
|---|---|---|---|
| Immediate HTML send | `POST /sendmail` with `to`, `subject`, `htmlContent` sends one HTML email through the SES API | `Lambda/send-mail/app.mjs`, `Lambda/template.yaml` `SendMailFunction` | Implemented on the Simpleflow stack. Not in `prod/template.yaml` |
| Direct-send validation | Missing `to`, `subject`, or `htmlContent` returns 400. Non-POST returns 405. Invalid JSON returns 500 | `Lambda/send-mail/app.mjs` | Implemented |
| CORS on direct send | `OPTIONS /sendmail` returns 200. Responses allow origin `*` and headers `authorization`, `x-client-info`, `apikey`, `content-type` | `send-mail/app.mjs` | Implemented. The handler does not check those headers |
| Fixed direct-send sender | `Source` is `no-reply@simpleflowhub.app` | `send-mail/app.mjs` | Implemented as a literal |
| Queue drain | Read up to 15 `send_que` rows with `status` 0 and send them | `Lambda/send-que/app.mjs`, `prod/sendque/app.mjs` | Implemented. Two copies |
| One-minute schedule | EventBridge `rate(1 minute)`, input `{}` | Both `template.yaml` files, event `SendQueScheduler` | Implemented. Package description says "15 unsent every 60 sec" |
| Manual queue trigger | `POST /sendque` runs the same drain. `OPTIONS /sendque` also runs it, because the handler ignores the event | `Lambda/template.yaml` only | Implemented on Simpleflow. Prod has no API |
| Queue status write-back | Accepted send (`accepted.length > 0`) writes `status` 1. Completed send with nothing accepted writes `status` 2. `result` stores the nodemailer response JSON | Both queue handlers | Implemented |
| Simpleflow send-error status | A thrown send writes `status` 2 and `result` as the error message JSON | `Lambda/send-que/app.mjs` since `5f2193a` | Implemented on Simpleflow only |
| Configurable queue sender | `from` is SSM `/intersectcloud-ses/no-reply-email` | Both live queue handlers | Implemented |
| HTML plus text part | HTML is `email.body`. Text is `email.body` with closing tags stripped | Both queue handlers | Implemented |
| Single attachment | If `attachment` is set, one nodemailer attachment uses that value as `path` and the last `/` segment as the filename | Both queue handlers | Implemented. No S3 client in the live path |
| Secrets from SSM | Supabase URL, service-role key, SES SMTP user, SES SMTP password, no-reply address | Both queue handlers and the IAM statements in both templates | Implemented. Parameter names differ for the service-role key |
| JSON Lambda logs | `LoggingConfig.LogFormat: JSON` | Both templates, function globals | Implemented |
| SonarQube on main | Bitbucket Pipelines runs the SonarQube scan pipe. No deploy | `bitbucket-pipelines.yml`, `sonar-project.properties` | Implemented |
| SAM deploy config | Stack names `Simpleflow` and `prod`, `CAPABILITY_IAM`, confirm changeset, resolve S3 | `Lambda/samconfig.toml`, `prod/samconfig.toml` | Configured. A successful deploy is not recorded in git |

## Completed, from git history

These are present on `main`. The dates are when they first appeared.

| When | Commit | Feature |
|---|---|---|
| 2024-09-30 | `d20b7f4`, `26005da` | Sonar project key and the Pipelines scan step |
| 2024-09-30 | `0cf1d2f` | `SendMailFunction` and `/sendmail` |
| 2024-10-01 | `8eb500d` | Simpleflow `SendQueFunction`, `/sendque`, and the one-minute schedule |
| 2024-11-15 | `ff6800d` | Separate `prod/` queue stack, schedule only, sender from SSM |
| 2024-12-13 | `5f2193a` | Simpleflow queue sender moved from a literal address to SSM. Simpleflow send exceptions set `status` 2. Prod service-role parameter renamed |

## In development

Nothing in the tree is marked as unfinished work that SAM will deploy. There is no feature branch.

These files look like drafts and are not on the deploy path:

| File | Why it is not a current feature |
|---|---|
| `Lambda/send-que/app copy.mjs` | SAM handler is `app.lambdaHandler` in `app.mjs`. This copy exports `handler`, is CommonJS syntax inside `.mjs`, and has a syntax error (`const sesPassword = = await`). It sketches S3 presigned attachments, a hardcoded Supabase URL `https://alb.simpleflowhub.app`, and different parameter names |
| `prod/template copy.yaml` | SAM reads `template.yaml`. This copy still uses `CodeUri: send-que/`, which is not a directory under `prod/`, and it still names the pre-`5f2193a` service-role parameter |

## Changed behaviour still visible in code

| Change | Where it shows |
|---|---|
| Queue sender was the literal `no-reply@simpleflowhub.app` until `5f2193a` | Direct send still uses that literal. The queue uses SSM. `app copy.mjs` still contains the literal |
| Prod Supabase key parameter changed in `5f2193a` from `/intersectcloud-supabase-deployment/JwtSecret/ServiceRoleKey` to `/Supabase-Simpleflow-Production/JwtSecret/ServiceRoleKey` | `prod/template.yaml` and `prod/sendque/app.mjs` use the new name. `prod/template copy.yaml` still lists the old name on account `761018868594`. Simpleflow still uses the deployment parameter on account `021891581915` |
| Application Insights and hello-world outputs were in the first prod template and commented out the same day (`0b5cd27`) | Still present as comments in `prod/template.yaml` |
| VPC config was added commented (`54dcc1c`) and was never uncommented | `Lambda/template.yaml` globals |

## Deprecated or unused

| Item | Evidence | Status |
|---|---|---|
| SAM hello-world sample | READMEs, both `events/event.json` files, commented `HelloWorldApi` outputs | Not a function in either template. The event file's body is `{"message":"hello world"}`, which would fail FR-002 if it were posted to `/sendmail` |
| Mocha unit tests | `"test": "mocha tests/unit/"` and devDependencies `mocha`, `chai` in all three `package.json` files. `.npmignore` is `tests/*` | No `tests/` directory is committed |
| `axios` | Dependency of all three functions | Not imported by any handler |
| `@aws-sdk/client-ses` and `@aws-sdk/client-ssm` on the queue functions | Queue `package.json` | Queue handler uses `aws-sdk` v2 `SSM` and nodemailer. The SES v3 client is used only by `send-mail/app.mjs` |
| `Lambda/package-lock.json` | Lockfile name `Lambda`, `"packages": {}` | No `Lambda/package.json` beside it |
| Commented VPC, Application Insights, hello-world outputs | Templates | Not deployed by the current YAML |
| `AmazonSESFullAccess` | Both functions' policies | Implemented, and broader than the two SES actions the code calls. Not unused |

## Not features of this repository

- Creating or editing `send_que` rows. This repo only selects `status` 0 and updates `status` and `result`.
- Supabase auth, row-level security, and the table schema. Not in git.
- SES identity verification and SMTP credential issuance. The code assumes they already exist.
- A deployment pipeline. `samconfig.toml` supports a manual `sam deploy`. Bitbucket Pipelines only runs SonarQube.
- User interface, login, and roles.
- S3 attachment storage. Mentioned only in the unused `app copy.mjs`, with bucket name `your-bucket-name`.
