Schema repository implementation for database metadata retrieval.
This namespace provides the concrete implementation of ISchemaProvider, connecting to the database through existing adapter protocols to fetch table and column metadata.
Responsibilities:
Caching: computed entity configurations are cached in an atom inside the
long-lived SchemaRepository component (populated on first access). Table
schemas only change at migration/deploy time, so the cache lives as long
as the component. Use reset-cache! (or recreate the component via
(ig-repl/reset)) to invalidate after a migration.
Schema repository implementation for database metadata retrieval. This namespace provides the concrete implementation of ISchemaProvider, connecting to the database through existing adapter protocols to fetch table and column metadata. Responsibilities: - Fetch raw database metadata using adapter protocols - Coordinate with pure core functions for parsing and merging - Cache entity configurations for performance - Provide entity discovery based on configuration Caching: computed entity configurations are cached in an atom inside the long-lived SchemaRepository component (populated on first access). Table schemas only change at migration/deploy time, so the cache lives as long as the component. Use `reset-cache!` (or recreate the component via (ig-repl/reset)) to invalidate after a migration.
(create-schema-repository db-ctx config)(create-schema-repository db-ctx config malli-schemas)Create new SchemaRepository instance.
Args: db-ctx: Database context map with :adapter and :datasource config: Admin configuration map with :entity-discovery and :entities malli-schemas: Optional map of entity-name → Malli schema. When provided, enum fields are auto-detected from the schema and rendered as select widgets without manual config.
Returns:
SchemaRepository instance implementing ISchemaProvider.
Entity configurations are cached per instance (populated on first
access); see reset-cache! to invalidate.
Example: (create-schema-repository db-ctx {:entity-discovery {:mode :allowlist :allowlist #{:users}} :entities {:users {:label "System Users"}}} {:users boundary.user.schema/User})
Create new SchemaRepository instance.
Args:
db-ctx: Database context map with :adapter and :datasource
config: Admin configuration map with :entity-discovery and :entities
malli-schemas: Optional map of entity-name → Malli schema.
When provided, enum fields are auto-detected from the schema
and rendered as select widgets without manual config.
Returns:
SchemaRepository instance implementing ISchemaProvider.
Entity configurations are cached per instance (populated on first
access); see `reset-cache!` to invalidate.
Example:
(create-schema-repository db-ctx
{:entity-discovery {:mode :allowlist
:allowlist #{:users}}
:entities {:users {:label "System Users"}}}
{:users boundary.user.schema/User})(get-editable-fields schema-provider entity-name)Get list of editable field names for an entity.
Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name
Returns: Vector of editable field name keywords
Example: (get-editable-fields provider :users) ;=> [:name :email :role :active]
Get list of editable field names for an entity. Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name Returns: Vector of editable field name keywords Example: (get-editable-fields provider :users) ;=> [:name :email :role :active]
(get-entity-field-names schema-provider entity-name)Get list of all field names for an entity.
Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name
Returns: Vector of field name keywords
Example: (get-entity-field-names provider :users) ;=> [:id :email :name :role :active :created-at ...]
Get list of all field names for an entity. Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name Returns: Vector of field name keywords Example: (get-entity-field-names provider :users) ;=> [:id :email :name :role :active :created-at ...]
(get-entity-primary-key schema-provider entity-name)Get primary key field name for an entity.
Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name
Returns: Keyword primary key field name (defaults to :id)
Example: (get-entity-primary-key provider :users) ;=> :id
Get primary key field name for an entity. Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name Returns: Keyword primary key field name (defaults to :id) Example: (get-entity-primary-key provider :users) ;=> :id
(get-list-fields schema-provider entity-name)Get list of fields to display in list view.
Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name
Returns: Vector of field name keywords for list view
Example: (get-list-fields provider :users) ;=> [:email :name :role :active :created-at]
Get list of fields to display in list view. Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name Returns: Vector of field name keywords for list view Example: (get-list-fields provider :users) ;=> [:email :name :role :active :created-at]
(get-searchable-fields schema-provider entity-name)Get list of searchable field names for an entity.
Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name
Returns: Vector of searchable field name keywords
Example: (get-searchable-fields provider :users) ;=> [:email :name]
Get list of searchable field names for an entity. Args: schema-provider: ISchemaProvider implementation entity-name: Keyword entity name Returns: Vector of searchable field name keywords Example: (get-searchable-fields provider :users) ;=> [:email :name]
(list-all-database-tables _db-ctx)Development helper: List all tables in the database.
Useful for debugging and understanding what tables are available.
Week 2+: This will be used for :all and :denylist discovery modes.
Args: db-ctx: Database context map
Returns: Vector of table names as keywords
Note: Implementation depends on database type - will need to query information_schema or similar.
Development helper: List all tables in the database.
Useful for debugging and understanding what tables are available.
Week 2+: This will be used for :all and :denylist discovery modes.
Args:
db-ctx: Database context map
Returns:
Vector of table names as keywords
Note: Implementation depends on database type - will need to query
information_schema or similar.(reset-cache! schema-repository)Clear the repository's cached entity configurations.
Call after a schema migration (or from the REPL) to force fresh database metadata on the next access. Recreating the component — e.g. via (ig-repl/reset) — has the same effect.
Clear the repository's cached entity configurations. Call after a schema migration (or from the REPL) to force fresh database metadata on the next access. Recreating the component — e.g. via (ig-repl/reset) — has the same effect.
(summarize-entity-config entity-config)Create human-readable summary of entity configuration.
Useful for debugging, logging, and understanding what was auto-detected vs manually configured.
Args: entity-config: Entity configuration map
Returns: Summary map with key statistics
Example: (summarize-entity-config entity-config) ;=> {:entity-name :users ; :label "Users" ; :total-fields 10 ; :visible-fields 8 ; :editable-fields 5 ; :searchable-fields 2 ; :readonly-fields #{:id :created-at :updated-at} ; :hidden-fields #{:password-hash :deleted-at}}
Create human-readable summary of entity configuration.
Useful for debugging, logging, and understanding what was auto-detected
vs manually configured.
Args:
entity-config: Entity configuration map
Returns:
Summary map with key statistics
Example:
(summarize-entity-config entity-config)
;=> {:entity-name :users
; :label "Users"
; :total-fields 10
; :visible-fields 8
; :editable-fields 5
; :searchable-fields 2
; :readonly-fields #{:id :created-at :updated-at}
; :hidden-fields #{:password-hash :deleted-at}}(validate-entity-config entity-config)Validate entity configuration against schema.
Args: entity-config: Entity configuration map
Returns: {:valid? true} or {:valid? false :errors ...}
Example: (validate-entity-config {:label "Users" :table-name :users ...})
Validate entity configuration against schema.
Args:
entity-config: Entity configuration map
Returns:
{:valid? true} or {:valid? false :errors ...}
Example:
(validate-entity-config {:label "Users" :table-name :users ...})cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |