aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2019-01-08 20:56:55 -0400
committerEduardo Julian2019-01-08 20:56:55 -0400
commit086090d4d5c730415ae781a274d076c035d6084a (patch)
treea3a9f0ad7a4d06423e988238f22935c0e3a121b3 /stdlib
parentb0d4c7349f12c0828c0466c3a98965139f3cb8b4 (diff)
Added some service capabilities.
Diffstat (limited to 'stdlib')
-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>)])
+ )