LCOV - code coverage report
Current view: top level - matchscore/domain/permission - entity.clj Coverage Total Hit
Test: lcov.info Lines: 90.6 % 32 29
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns matchscore.domain.permission.entity
       2              :   "Lightweight schemas for the permission domain.
       3              : 
       4              :   The Casbin enforcer is the source of truth for *assignments* (`g`)
       5              :   and *policies* (`p`). The `roles` Postgres table is purely a lookup
       6              :   catalog (display_name, description, scope) used by the admin UI. We
       7              :   keep schemas here so callers (handlers, GraphQL, tests) share a
       8              :   single shape.")
       9              : 
      10              : 
      11            4 : (def Role
      12              :   "A row from the `roles` lookup table."
      13            8 :   [:map
      14            8 :    [:name
      15           28 :     [:string {:min 1
      16              :               :max 200}]]
      17           20 :    [:display-name {:optional true}
      18           12 :     [:maybe :string]]
      19           20 :    [:description {:optional true}
      20           12 :     [:maybe :string]]
      21           20 :    [:scope [:enum "global"]]])
      22              : 
      23              : 
      24            4 : (def Assignment
      25              :   "One Casbin `g` row: user `user-uuid` holds `role` in `domain`."
      26           92 :   [:map [:user-uuid [:string {:min 1}]] [:role [:string {:min 1}]] [:domain [:string {:min 1}]]])
      27              : 
      28              : 
      29            4 : (def Policy
      30              :   "One Casbin `p` row."
      31            8 :   [:map
      32           28 :    [:role [:string {:min 1}]]
      33           28 :    [:domain [:string {:min 1}]]
      34           28 :    [:obj-type [:string {:min 1}]]
      35           28 :    [:action [:string {:min 1}]]
      36           24 :    [:cond {:optional true}
      37              :     :string]
      38           20 :    [:effect {:optional true}
      39           16 :     [:enum "allow" "deny"]]])
      40              : 
      41              : 
      42            4 : (defn assignment-row->map
      43              :  "Convert a Casbin grouping row (`[user role dom]`) to an Assignment map."
      44              :  [[user role dom]]
      45            0 :  {:user-uuid user
      46            0 :   :role      role
      47            0 :   :domain    dom})
      48              : 
      49              : 
      50            4 : (defn policy-row->map
      51              :  "Convert a Casbin policy row (`[sub dom obj-type act cond eft]`) to a
      52              :   Policy map."
      53              :  [[sub dom obj-type act cond-expr eft]]
      54           16 :  {:role     sub
      55            2 :   :domain   dom
      56            2 :   :obj-type obj-type
      57            2 :   :action   act
      58            2 :   :cond     cond-expr
      59            2 :   :effect   eft})
        

Generated by: LCOV version 2.0-1