Step 3 of the platform-ification. The SDK is the first integration
artefact FleetCrown (and the rest) will install. Lives at
packages/sdk/ as an npm workspace member of the orangecat repo —
single source of truth, one CI pipeline, lock-step PRs when schemas
change.
Package layout (packages/sdk/):
- package.json — ESM-only, "type": "module", clean "exports" map,
declares Node ≥18, sideEffects: false for tree-shaking, marked
public so it can be published to npm later (UNLICENSED for now).
- tsconfig.json (type-check) + tsconfig.build.json (emit to dist/).
- src/errors.ts — OrangeCatError + OrangeCatErrorCode enum mirroring
CONVENTIONS.md §3. `.isRetryable` for SDK retry logic and consumer
branches.
- src/http.ts — fetch transport. Built-in: 20s timeout (matches
FleetCrown's useFetch), exp backoff retry (3 attempts) on network /
5xx / 429 honouring Retry-After, auto-generated Idempotency-Key on
mutating requests (forward-compatible — server dedup planned),
bearer + X-OrangeCat-Key headers, User-Agent identifying the SDK,
AbortSignal composition.
- src/types.ts — request/response types for the 9 v1 entity creates.
Hand-written for v0.1 (OpenAPI codegen is a follow-up). Each response
type intersects Record<string, unknown> so additive server fields
don't break consumers.
- src/client.ts — OrangeCatClient with resource namespaces
(client.products.create(…), .services.create(…), etc.) +
client.discovery() for startup-time version sanity check.
- src/index.ts — public exports.
- README.md — quickstart, auth, error handling, reliability features,
versioning policy.
OrangeCat root package.json gains `"workspaces": ["packages/*"]`.
`npm install` symlinks @orangecat/sdk into node_modules.
Contract reality check while building the SDK exposed two drifts from
the conventions doc — fixed both:
- Server returns `error: { code, message, details }` (nested object),
not `error: string + code` (flat) as the doc claimed. Fixed
src/lib/openapi/responses.ts to describe the real shape and updated
CONVENTIONS.md §3 with the actual wire format + the SDK's
case-normalisation (server sends UPPERCASE, SDK matches lowercase).
- This is what end-to-end SDK testing is FOR. The doc is the
aspirational contract; the server is the running reality; the SDK
is what proves they match.
Smoke test (against local /api/v1):
- DISCOVERY OK: v1 - 9 entities, /api/v1/openapi.json
- AUTH ERROR (expected): unauthorized / HTTP 401 - Unauthorized
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Step 2 of the platform-ification. The /api/v1/ surface is now described
in a machine-readable contract that can never drift from the server,
because it's generated from the same Zod schemas the server validates
against.
What ships:
- @asteasolutions/zod-to-openapi@7.3.4 added (peers on zod ^3.20.2, we
run 3.25.76 — compatible without a Zod upgrade).
- src/lib/openapi/registry.ts — extends Zod with .openapi(), single
shared OpenAPIRegistry.
- src/lib/openapi/responses.ts — apiSuccess<T> and apiError envelope
schemas matching src/lib/api/standardResponse.ts.
- src/lib/openapi/registerV1Routes.ts — maps every public entity type
in PUBLIC_API_ENTITY_TYPES to its Zod schema and builds the operation
(request body, response shape, common error responses, IntegrationKey
security scheme).
- src/lib/openapi/spec.ts — memoised generator. One call per process.
- GET /api/v1/openapi.json — public, cached 5 minutes, returns the spec.
- Discovery endpoint (/api/v1) now exposes the spec URL + conventions
link so SDKs and curious devs can find them.
- /settings/integrations page links openapi.json and discovery so users
see the contract they're integrating against.
docs/api/CONVENTIONS.md — the rulebook everything under /v1 follows:
versioning policy, response envelope, canonical error codes, idempotency
(planned), rate limits, pagination (planned, cursor-based), naming,
timestamps, Bitcoin amount handling (BTC not sats), webhooks (planned —
HMAC-SHA-256 signed with the integration key), SDK guidance, and a
discipline checklist for landing new public endpoints.
Smoke test: `curl /api/v1/openapi.json` returns a ~41 KB OpenAPI 3.1
document with 10 paths (9 entity POSTs + discovery), 26 schemas, and
the IntegrationKey security scheme.
Next: TypeScript SDK package (probably dev/orangecat-sdk as a new repo)
generated from this spec. After that, the first FleetCrown-side
integration spike consumes the SDK.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Fix currency defaults (SATS → CHF) across forms, configs, and API routes
- Remove @ts-nocheck from socialService.ts and improve type safety
- Replace console.log statements with proper logger utility in production code
- Additional type safety improvements and code quality enhancements
- Documentation updates for improved maintainability
All changes follow DRY, SSOT, and separation of concerns principles.
- Fixed messaging service Supabase insert/update type errors
- Fixed profile hooks (useProfileForm, useAuth, useActiveRoute, useMobileMenu)
- Added missing type exports (UserProduct, UserService, UserCause, Profile with email)
- Fixed messaging API route type errors
- Updated Database types for proper Supabase type safety
Note: Some TypeScript errors remain in non-critical areas (commerce, entity configs, tests) but core messaging and profile functionality is type-safe.
- Refactor wallet components from old structure to new wallets/
- Add contact email column and migrations
- Fix location implementation and integration
- Update profile editing and dashboard components
- Add comprehensive testing and validation
- Update documentation and architecture guides
- Add performance indexes and audit logging
- Fix various bugs and improve UX