Define a thin authoring model for defentity.pg that stays close to PG
semantics while enabling output-file based generation.
This model should work with the existing backbone:
rt.postgresxt.dbl/script :xtalk .clj modulesdeftype.pgstatstrade-corestatstrade-v1 and gw-v2defentity.pg should:
deftype.pgThe true generation spec should be plain data, not macro expansion.
The normalized entity spec should include:
Generators should consume entity specs and emit normal source files for:
flowchart LR
AUTHOR["defentity.pg"]
SPEC["normalized entity spec"]
HELPER["helper generator"]
QUERY["query/xt.db generator"]
POLICY["policy generator"]
TEST["test generator"]
FILES["real output files"]
AUTHOR --> SPEC
SPEC --> HELPER
SPEC --> QUERY
SPEC --> POLICY
SPEC --> TEST
HELPER --> FILES
QUERY --> FILES
POLICY --> FILES
TEST --> FILES
This is intentionally close to current PG code:
(defentity.pg Space
{:helpers [:crud :archive :membership]
:queries [:get :list :dashboard]}
[:organisation {:type :ref :required true :ref {:ns tuo/Organisation}}
:owner {:type :ref :required true :ref {:ns tub/User}}
:visibility {:type :enum :required true :enum {:ns -/EnumSpaceVisibility}}
:status {:type :enum :required true :enum {:ns -/EnumSpaceStatus}}])
Notes:
:helpers and :queries are generation hints, not execution semanticsConceptual example:
{:entity/id 'Space
:entity/ns 'gwdb.platform.spaces.type-space-base
:application "gw"
:db/schema "gw_type"
:fields [...]
:helpers [:crud :archive :membership]
:queries [:get :list :dashboard]}
This data should be what downstream generators consume.
The first generation target should be helper functions as normal defn.pg
source code.
For a Space entity, likely outputs are:
create-spaceupdate-spacepurge-spaceget-spacelist-spacesadd-space-memberremove-space-memberThese should be written to output files, not hidden in macroexpansion.
These belong in defentity.pg generation:
These should not be forced into defentity.pg yet:
defentity.pg generation should not bypass xt.db.
Later generation stages should be able to emit or support:
xt.db-compatible schema/query supportl/script :xtalk .clj operational modules that compose those piecesfoundation-base.defentity.pg authoring macro that records that spec.Space slice.Can you improve this documentation?Edit on GitHub
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 |