Repository navigation
feat!: make spools the headless backend for business software - #57
Open
calvinbrewer wants to merge 7 commits into
Open
calvinbrewer wants to merge 7 commits into
calvinbrewer wants to merge 7 commits into
Conversation
A Spool can run as the CRM's server with no interface, behind a front end of your own. Everything the CRM does for whoever asks is an operation, defined once and reached by the interface's server functions, the HTTP API and the server's own code alike. - httpApi and headlessServer: every operation over HTTP, with no web framework - a typed client, and src/crm.types.ts generated from the config - API keys, opt-in, sealed by the vault and ending after 90 days by default - Clerk without TanStack Start, and Better Auth with a bearer session - create-spools --headless - docs for headless mode across the README and the docs site BREAKING CHANGE: the AES vault (@swirls/spools/vault/aes, VAULT_KEY, VAULT_OLD_KEYS) is removed. CipherStash is the vault, and a production server does not start without the CS_* variables. Clerk takes a session only from the front end at APP_URL or the ones named in authorizedParties. See docs/upgrading.md. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The racing tests gave the one copy that runs 150 ms of work and expected every other copy to arrive within it. On a slow runner some arrived after, and were given the kept answer instead of in_progress. The copy that runs now waits for the others' answers, so the outcome does not depend on speed. Co-Authored-By: Claude Fable 5.2 <[email protected]>
An app already on TanStack Start can use a Spool as its backend and keep its own pages. - serveApi (@swirls/spools/api/http): the HTTP API as the handlers of two route files. The starter mounts it, so a new Spool serves /api/v1 - startClient (@swirls/spools/start/client): the typed client that asks the API in-process on the server and over HTTP in the browser - createQueries (@swirls/spools/query): every operation as query and mutation options for TanStack Query, with nothing imported but the client's types; a mutation marks what was read from the Spool stale - the route-adapters lint rule takes the framework's handlers made with options - docs: "In a TanStack Start app" on the Headless page Co-Authored-By: Claude Fable 5.2 <[email protected]>
…pickers The state behind a list, a record's form and a relation picker, with no markup: useListState, useRecordForm and useRelationSearch from @swirls/spools/react, over pure rules in crm/list-state.ts and crm/record-state.ts that the address of a list and a form's save share. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Rename the public crm names to spool names, move email sequences, mailbox and calendar sync, marketing and contact tracking into opt-in modules from @swirls/spools/modules, and rewrite the site and docs around the backend for business software you vibe code. BREAKING CHANGE: the names that said crm say spool (spool.config.json, defineSpool, spoolConfig, staffHandler and the rest), and a Spool has sequences, mailbox, marketing and contact tracking only when it lists each module in defineSpool. See docs/upgrading.md. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A Spool chooses its vault again: cipherstash(), which a new Spool starts with, or aes() from @swirls/spools/vault/aes, which seals with AES-256-GCM under VAULT_KEY and needs no outside service. A production server does not start without its vault's variables, and outside production both use the same development stand-in. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A clean install no longer got @clerk/tanstack-react-start once the starter stopped using it, so the Clerk adapter for TanStack Start did not type-check in CI. It is a dev dependency of the framework now, and @clerk/backend moves to ^3.36.0 so both share one copy. That version takes a cookie as a session only when its header carries Clerk's session category, so the test's stand-in token carries it too. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Spools becomes the headless backend for business software you build with coding agents. It runs behind one HTTP API and draws nothing, so the front end is the app's own, on any framework. A CRM is the first thing built on it, and the starter is still one.
httpApi()answers each atPOST <base>/<name>, describes itself atGET <base>and as OpenAPI 3.1.headlessServer()is a whole Spool with no web framework: the API, every endpoint (sign-in, files, the assistant, webhooks, cron) and the app's own routes. The starter'ssrc/server.tsis that, andbun run devserves it with no build.@swirls/spools/client,/query,/reactand/state.spools genwritessrc/spool.types.ts, so the client knows every field of an app's objects.@swirls/spools/modules. Without one, its tables are not made, its operations and routes are not there, and its part of the config is refused.cipherstash()is the one a new Spool starts with.aes()seals with AES-256-GCM under aVAULT_KEYthe app keeps and needs no outside service.Breaking changes
spool.config.json,src/spool.types.ts,bun run gen,defineSpool({ config }),spoolConfig(),staffHandler,StaffUser,SpoolRecord, andspool_eventin.swirlsfiles.modules: [sequences, mailbox, marketing, contactTracking]todefineSpoolto keep all four.CS_*variables for CipherStash, orVAULT_KEYfor AES. Outside production a stand-in seals with a key that is in the source, and what it sealed is refused once the vault has its keys.api_keys; removesguide_progressand thetypecolumn ofsaved_views. Runbun run gen, thenbun run db:pushor your migration.docs/upgrading.mdhas the steps and the full list of renamed names.Verification
bun run verifypasses on PGlite: 809 unit and 555 integration tests, with types, lint and formatting.bun run check:packagepasses: it builds and packs the packages, makes a new Spool from them and runs it.Not covered
"encrypted"in the config are still stored as plaintext.🤖 Generated with Claude Code
Ask Polylane for an impact assessment of this pull request: