Search by

glueful / thallo-collections

msowah

Developer-defined data collections with a public CRUD/query API, as a removable Thallo capability pack.

Package info

github.com/glueful/thallo-collections

pkg:composer/glueful/thallo-collections

Statistics

Installs: 76

Dependents: 1

Suggesters: 0

Stars: 0


README

Developer-defined data collections for Thallo — schemas backed by real per-collection tables, with an auto-generated CRUD/query API, an admin schema builder, per-operation access policies, soft relations, and emitted change events — packaged as a capability pack. It depends only on the framework and glueful/thallo-contracts, and an operator can switch it off without touching the core.

Each collection is a first-class table (coll_<name>), not a JSON blob, so rows are queryable, indexable, and relationable like any other table — while the schema is defined and evolved entirely through the admin API.

What it provides

  • Schema management (CollectionManager) — create a collection (validated name → coll_<name> table with the standard system columns: id, uuid, timestamps, created_by_*/updated_by_*), add/drop fields, add/remove indexes, replace the access policy, set field order, and drop the collection. In-place field-type changes are blocked; destructive ops require a typed confirmation (waived on an empty table).
  • Field types — collections. string (VARCHAR), text (TEXT), integer (INT/BIGINT), decimal, boolean, date, datetime, json, email, url, enum, relation, asset. Each declares filterable/sortable/indexable capabilities.
  • Public data API — GET/POST/PATCH/DELETE /v1/collections/{name} (list with filter/sort/ field-projection/expand + offset pagination, get, create, bulk-create, update, delete). Behind an optional API key + a per-collection scope gate (collections.{name}.{read|write|delete}) driven by the collection's access policy.
  • Admin schema API — /v1/admin/collections (index/show/store/add-field/drop-field/add-index/ drop-index/update-access/destroy) behind auth + Aegis content_permission.
  • Access policy — per operation {read, write, delete}, each public (no auth) or scoped (api-key scope OR the caller's session permission). Defaults to all-scoped.
  • Soft relations — a relation field targets another collection (collection:<name>) or the framework users table (users); existence-validated, one-level batch expand, restrict-on-delete.
  • Change events — pure CollectionRow{Created,Updated,Deleted} (data) and Collection{Created,Updated,Dropped} (schema) events for subscribers (audit, analytics, webhooks, search) to consume without coupling to the pack.

The capability

The provider registers a single capability in boot():

new Capability('thallo.collections', label: 'Collections', description: '…');
  • Enabled by default. An operator turns it off or on in the admin under Extensions › Capabilities. The switch is stored system-wide and overrides the deploy-time thallo.capabilities config map.
  • Gated, not just UI. When disabled, the public + admin routes are never registered (requests 404, not a live-but-disabled handler). Migrations run on install, not enable, so disabling the capability preserves the collection_definitions metadata and every coll_* data table.
  • Permissions. The pack declares collections.manage, collections.schema.manage, and collections.data.manage; the host app grants them to administrator in its own dependent migration.

Boundary

Depends on glueful/thallo-contracts and glueful/framework — and never on glueful/thallo (the application). The repo's composer boundaries check enforces this at both the Composer-dependency and source level (no Thallo\Core\ references in src/ or routes/).

Install

The pack ships with Thallo: glueful/thallo-core requires it at the same version and the project's config/serviceproviders.php loads its provider, so there is nothing to install or enable per pack. Its metadata tables are created by php glueful migrate:run with the rest of the schema.

Switching the capability off (Extensions › Capabilities) drops it from GET /v1/admin/capabilities, so the collections admin section hides and the public /v1/collections/* surface is gone. Existing coll_* tables remain on disk.

Contributing

This repository is a read-only mirror, published from glueful/thallo on every release; its main is overwritten by the next split, so nothing can land here. Issues and pull requests belong in glueful/thallo, where this code lives at packages/thallo-collections/.