Current section

Files

Jump to
caravela CHANGELOG.md
Raw

CHANGELOG.md

# Changelog
All notable changes to Caravela are documented here.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.3.0] — 2026-04-17
Phase 3 — multi-tenancy, API versioning, Absinthe/GraphQL generation.
### Added
- `use Caravela.Domain, multi_tenant: true` — opts into row-level
multi-tenancy. `Caravela.Tenant` auto-injects a `:tenant_id`
(`:binary_id`, `null: false`) field into every entity, and the
generated context gains `scope_tenant/2` + `inject_tenant_id/2`
helpers driven by `context.tenant.id`.
- Migrations in multi-tenant domains add the `tenant_id` column and
composite `[:tenant_id, :<fk>]` indexes alongside each FK index, plus
a standalone `[:tenant_id]` index on tables with no FKs.
- `version "v1"` DSL directive — all generated Elixir modules and file
paths are namespaced under the version segment
(`MyApp.Library.V1.Book`, `MyAppWeb.V1.BookController`,
`lib/my_app/library/v1/book.ex`). The router snippet is emitted at
`scope "/api/v1", MyAppWeb.V1`. Table names stay version-free so rows
are shared across versions.
- Two new compile-time validations: invalid version format (must match
`~r/^v\d+$/`) and manual `:tenant_id` declarations colliding with
auto-injection.
- `Caravela.Gen.GraphQL` — renders Absinthe object types, query object,
and mutation object (with typed input objects) for the domain. Every
resolver delegates to the generated context, so authorization, hooks,
and tenant scoping apply to GraphQL for free. Tenant-injected fields
are hidden from both object and input types.
- `mix caravela.gen.graphql` task — checks for Absinthe at runtime and
prints an actionable error if the optional dependencies are missing.
- Generated controllers read `conn.assigns[:tenant]` into the context
when the domain is multi-tenant.
## [0.2.0] — 2026-04-17
Phase 2 — hooks, permissions, Phoenix context + JSON API generators.
### Added
- Hook DSL: `on_create/2`, `on_update/2`, `on_delete/2` on any entity.
Hooks run between authorization and the final `Repo` call in the
generated context. `on_delete` may return `{:error, reason}` to
abort the delete.
- Permission DSL: `can_read/2`, `can_create/2`, `can_update/2`,
`can_delete/2`. `can_read` is applied as an Ecto query filter;
the other three return booleans and a `false` short-circuits the
context function with `{:error, :unauthorized}`.
- Compiled domain modules expose `__caravela_hook__/4` and
`__caravela_permission__` dispatch functions with safe fallbacks.
- Three new compile-time validations: hook / permission arity, unknown
entity references, duplicate (action, entity) declarations.
- `Caravela.Gen.Context` — Phoenix context generator with CRUD
functions per entity (`list_`, `get_`, `get_!`, `change_`,
`create_`, `update_`, `delete_`).
- `Caravela.Gen.Controller` — JSON controller generator (REST actions,
standard status codes, changeset → 422 translation).
- `Caravela.Gen.RouterScope` — prints the `scope "/api", MyAppWeb do …
end` snippet to paste into the host app's router.
- `Caravela.Gen.Custom` — preserves user code below the
`# --- CUSTOM ---` marker across regenerations. Schemas, contexts,
and controllers all ship with the marker.
- Mix tasks: `caravela.gen.context`, `caravela.gen.api`, and the
all-in-one `caravela.gen`.
## [0.1.0] — 2026-04-17
Initial public release. Phase 1 — DSL, compiler, and schema/migration
generators.
### Added
- `Caravela.Domain` DSL: `entity`, `field`, `relation`.
- `Caravela.Compiler` with six compile-time validations: unknown field
types, numeric-constraint/type mismatches, duplicate entities,
dangling relation targets, incompatible cardinality, circular
required `belongs_to` chains.
- `Caravela.Gen.EctoSchema` — Ecto schema generator (with changeset,
required/format/length/numeric validations).
- `Caravela.Gen.Migration` — Ecto migration generator, topologically
sorted, with foreign-key indexes and appropriate `on_delete` rules
derived from `required:`.
- `mix caravela.gen.schema MyApp.Domains.<Module>` task with
`--dry-run` and `--force` options.
- `:binary_id` primary and foreign keys by default.
[Unreleased]: https://github.com/rsousacode/caravela/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/rsousacode/caravela/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/rsousacode/caravela/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/rsousacode/caravela/releases/tag/v0.1.0