Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ jobs:

- run: bun install --frozen-lockfile

# Emits dist/, which is what the reference host and the typecheck
# resolve @corbits/mailbox through — so everything downstream proves
# the published artifact, not just the sources.
- name: build
run: bun run build

# bun copies `file:` dependencies at install time, before dist/ exists;
# a forced reinstall refreshes the copy with the built output.
- name: refresh reference-host dependency copy
run: bun install --force

- name: typecheck
run: bun run typecheck

- name: unit + integration tests
run: bun run --cwd packages/mailbox test:coverage

# Emits dist/, which is also what the reference host resolves through —
# so this proves the published artifact, not just the sources.
- name: build
run: bun run build
run: bun run test:coverage

- name: reference-host acceptance
run: bun test --cwd examples/reference-host
Expand All @@ -54,8 +60,7 @@ jobs:
- name: node consumer smoke test
run: |
set -euo pipefail
TARBALL="$(cd packages/mailbox && npm pack --silent)"
TARBALL="$PWD/packages/mailbox/$TARBALL"
TARBALL="$PWD/$(npm pack --silent)"
mkdir -p "$RUNNER_TEMP/consumer" && cd "$RUNNER_TEMP/consumer"
npm init -y >/dev/null && npm pkg set type=module >/dev/null
npm install "$TARBALL"
Expand Down
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

How `@corbits/mailbox` is put together, and what it does and does not ask of
the host that mounts it. For install, the mount snippet, the route table and the
response contracts, see the [package README](./packages/mailbox/README.md) —
response contracts, see the [README](./README.md) —
this document is about structure and reasoning, and does not repeat them.

## The shape of the thing
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
# corbits-mailbox

Home of **[`@corbits/mailbox`](./packages/mailbox)** — a universal,
principal-keyed inbox, mountable onto a Hono host backed by an Interchange-shaped
Postgres. Its tables live in a dedicated `mailbox` schema in the host's database,
foreign-keyed to the host's `tenant` and `principal` tables. Backend only; this
package ships no UI.
**[`@corbits/mailbox`](./package.json)** — a universal, principal-keyed inbox,
mountable onto a Hono host backed by an Interchange-shaped Postgres. Its tables
live in a dedicated `mailbox` schema in the host's database, foreign-keyed to
the host's `tenant` and `principal` tables. Backend only; this package ships no
UI.

See the [package README](./packages/mailbox/README.md) for install, the mount
snippet and the seams, and [ARCHITECTURE.md](./ARCHITECTURE.md) for the data model.
Requires `@intx` 0.2.2 or newer.

See [ARCHITECTURE.md](./ARCHITECTURE.md) for the data model.

## Install

```sh
# from npm (ships prebuilt dist/)
bun add @corbits/mailbox

# from git (prepare hook builds dist/ on the way in)
bun add github:corbitsdev/corbits-mailbox
```

## Layout

| | |
| --- | --- |
| `packages/mailbox` | The published package. Owns `principal_mail` (the message, immutable) and `mailbox` (the management layer, created eagerly with each message). |
| `src/` | The published package. Owns `principal_mail` (the message, immutable) and `mailbox` (the management layer, created eagerly with each message). |
| `examples/reference-host` | Mounts it on a real `@intx/hub-api` app against a live Postgres and asserts the acceptance scenarios end to end. |

## Working on it
Expand All @@ -23,8 +34,8 @@ bun install
docker run -d --name mailbox-pg -p 5433:5432 \
-e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=mailbox_core postgres:16

bun run --cwd packages/mailbox test # unit + integration
bun run --cwd packages/mailbox build # dist/ (JS + .d.ts)
bun run test # unit + integration
bun run build # dist/ (JS + .d.ts)
bun test --cwd examples/reference-host # acceptance scenarios
```

Expand Down
81 changes: 36 additions & 45 deletions bun.lock

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion examples/reference-host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "bun test"
},
"dependencies": {
"@corbits/mailbox": "workspace:*",
"@corbits/mailbox": "file:../..",
"@intx/db": "0.2.2",
"@intx/hub-api": "0.2.2",
"@intx/hub-sessions": "0.2.2",
Expand Down
85 changes: 78 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,89 @@
{
"name": "corbits-mailbox",
"private": true,
"license": "LGPL-2.1-only",
"name": "@corbits/mailbox",
"version": "0.1.0",
"type": "module",
"workspaces": ["packages/*", "examples/*"],
"license": "LGPL-2.1-only",
"description": "Universal principal-keyed inbox, mountable onto any Interchange host. Requires @intx 0.2.2 or newer.",
"keywords": [
"corbits",
"interchange",
"intx",
"mailbox",
"inbox",
"hono",
"drizzle",
"postgres"
],
"author": "Corbits",
"homepage": "https://github.com/corbitsdev/corbits-mailbox#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/corbitsdev/corbits-mailbox.git"
},
"bugs": {
"url": "https://github.com/corbitsdev/corbits-mailbox/issues"
},
"engines": {
"node": ">=22"
},
"corbits": {
"minimumIntxVersion": "0.2.2"
},
"workspaces": [
"examples/*"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"files": [
"dist",
"src",
"!src/**/*.test.ts",
"!src/test-helpers.ts",
"LICENSE",
"README.md"
],
"sideEffects": false,
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.build.json",
"prepack": "bun run build",
"prepare": "node scripts/prepare.mjs",
"typecheck": "tsc --noEmit",
"build": "bun run --cwd packages/mailbox build",
"test": "bun run --cwd packages/mailbox test",
"test:acceptance": "bun run build && bun test --cwd examples/reference-host"
"test": "bun test src",
"test:coverage": "bun test src --coverage",
"test:acceptance": "bun run build && bun install --force && bun test --cwd examples/reference-host"
},
"dependencies": {
"@hono/standard-validator": "0.2.3",
"@standard-community/standard-json": "0.3.5",
"@standard-community/standard-openapi": "0.2.9",
"arktype": "2.1.29",
"hono-openapi": "1.3.1"
},
"peerDependencies": {
"@intx/log": "^0.2.2",
"@intx/mime": "^0.2.2",
"@intx/types": "^0.2.2",
"drizzle-orm": "^0.45.2",
"hono": "^4.12.0",
"postgres": "^3.4.0"
},
"devDependencies": {
"@intx/log": "0.2.2",
"@intx/mime": "0.2.2",
"@intx/types": "0.2.2",
"@types/bun": "1.1.14",
"@types/json-schema": "7.0.15",
"@types/node": "22.10.5",
"drizzle-orm": "0.45.2",
"hono": "4.12.32",
"openapi-types": "12.1.3",
"postgres": "3.4.9",
"typescript": "5.7.2"
},
"overrides": {
Expand Down
Loading
Loading