aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/world/service/crud.lux36
-rw-r--r--stdlib/source/lux/world/service/inventory.lux34
2 files changed, 70 insertions, 0 deletions
diff --git a/stdlib/source/lux/world/service/crud.lux b/stdlib/source/lux/world/service/crud.lux
new file mode 100644
index 000000000..f27bda2a3
--- /dev/null
+++ b/stdlib/source/lux/world/service/crud.lux
@@ -0,0 +1,36 @@
+(.module:
+ [lux #*
+ [control
+ [identity (#+ ID)]
+ [security
+ [capability (#+ Capability)]]]
+ [data
+ ["." error (#+ Error)]]
+ [time
+ ["." instant (#+ Instant)]]])
+
+(type: #export Time
+ {#created Instant
+ #updated Instant})
+
+(type: #export (Can-Create ! code entity storage)
+ (Capability [Instant entity]
+ (! (Error (ID code entity storage)))))
+
+(type: #export (Can-Retrieve ! code entity storage)
+ (Capability (ID code entity storage)
+ (! (Error [Time entity]))))
+
+(type: #export (Can-Update ! code entity storage)
+ (Capability [(ID code entity storage) Instant entity]
+ (! (Error Any))))
+
+(type: #export (Can-Delete ! code entity storage)
+ (Capability (ID code entity storage)
+ (! (Error Any))))
+
+(type: #export (CRUD ! code entity storage)
+ [(Can-Create ! code entity storage)
+ (Can-Retrieve ! code entity storage)
+ (Can-Update ! code entity storage)
+ (Can-Delete ! code entity storage)])
diff --git a/stdlib/source/lux/world/service/inventory.lux b/stdlib/source/lux/world/service/inventory.lux
new file mode 100644
index 000000000..00b20e71a
--- /dev/null
+++ b/stdlib/source/lux/world/service/inventory.lux
@@ -0,0 +1,34 @@
+(.module:
+ [lux #*
+ [control
+ [identity (#+ ID)]
+ [security
+ [capability (#+ Capability)]]]
+ [data
+ [error (#+ Error)]]])
+
+(with-expansions [<vars> (as-is ! $ @ owner property)
+ <owner> (as-is (ID @ owner $))
+ <property> (as-is (ID @ property $))]
+ (type: #export (Can-Own <vars>)
+ (Capability [<owner> <property>]
+ (! (Error Any))))
+
+ (type: #export (Can-Disown <vars>)
+ (Capability [<owner> <property>]
+ (! (Error Any))))
+
+ (type: #export (Can-Check <vars>)
+ (Capability [<owner> <property>]
+ (! (Error Bit))))
+
+ (type: #export (Can-List <vars>)
+ (Capability <owner>
+ (! (Error (List <property>)))))
+
+ (type: #export (Inventory <vars>)
+ [(Can-Own <vars>)
+ (Can-Disown <vars>)
+ (Can-Check <vars>)
+ (Can-List <vars>)])
+ )