Skip to content

Commit c8f7e5f

Browse files
committed
- add storage add-on
1 parent 612cd13 commit c8f7e5f

File tree

9 files changed

+425
-189
lines changed

9 files changed

+425
-189
lines changed

addons/system-admin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"models":{"138a81fa1f16435":{"_id":"138a81fa1f16435","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":{}},"135c71078810af2":{"_id":"135c71078810af2","_name":"RuntimeChannel","_inherit":["RuntimeComponent"],"sync":{},"loadSystem":{"params":[{"name":"system","type":"object"}]},"createSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"updateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"deleteSchema":{"params":[{"name":"id","type":"string"}]},"createModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"updateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"deleteModel":{"params":[{"name":"id","type":"string"}]},"createType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"updateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"deleteType":{"params":[{"name":"id","type":"string"}]},"createComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"updateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"deleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"createBehavior":{"params":[{"name":"behavior","type":"object"}]},"updateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"deleteBehavior":{"params":[{"name":"id","type":"string"}]}}},"schemas":{"10374180581a41f":{"_id":"10374180581a41f","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":"method"},"104ad1f48518376":{"_id":"104ad1f48518376","_name":"RuntimeChannel","sync":"event","loadSystem":"event","createSchema":"event","updateSchema":"event","deleteSchema":"event","createModel":"event","updateModel":"event","deleteModel":"event","createType":"event","updateType":"event","deleteType":"event","createComponent":"event","updateComponent":"event","deleteComponent":"event","createBehavior":"event","updateBehavior":"event","deleteBehavior":"event"}},"types":{},"behaviors":{"1c00c107e01c9b3":{"_id":"1c00c107e01c9b3","component":"RuntimeAdmin","state":"start","action":"function start() {\n var RuntimeChannel = null,\n runtimeChannel = null;\n \n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n localStorage.setItem('system-designer-message', JSON.stringify(message));\n });\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('metamodel').type(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n $db.Runtime.remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('metamodel').schema(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('metamodel').type(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n $component.removeFromMemory(id);\n }, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n $db.RuntimeType.remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component);\n }, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db.RuntimeBehavior.insert(component);\n }, true);\n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n });\n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db.RuntimeBehavior.remove({'_id': id}); \n }, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n this.loadSystem(JSON.parse(this.require('db').system()));\n });\n\n window.addEventListener('storage', function (e) {\n if (e.key === 'system-designer-message') {\n $db.RuntimeMessage.insert(JSON.parse(e.newValue));\n }\n });\n \n this.require('logger').info('admin is started');\n } else {\n this.require('logger').info('admin is already started');\n }\n}","useCoreAPI":true,"core":true}},"components":{"RuntimeAdmin":{"admin":{"_id":"admin","_core":true}}},"name":"system-admin","version":"0.5.0","description":"Runtime Component administration ","_id":"18ed81de331252c","master":false,"subsystem":false}
1+
{"models":{"138a81fa1f16435":{"_id":"138a81fa1f16435","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":{}},"135c71078810af2":{"_id":"135c71078810af2","_name":"RuntimeChannel","_inherit":["RuntimeComponent"],"sync":{},"loadSystem":{"params":[{"name":"system","type":"object"}]},"createSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"updateSchema":{"params":[{"name":"id","type":"string"},{"name":"schema","type":"object"}]},"deleteSchema":{"params":[{"name":"id","type":"string"}]},"createModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"updateModel":{"params":[{"name":"id","type":"string"},{"name":"model","type":"object"}]},"deleteModel":{"params":[{"name":"id","type":"string"}]},"createType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"updateType":{"params":[{"name":"id","type":"string"},{"name":"type","type":"object"}]},"deleteType":{"params":[{"name":"id","type":"string"}]},"createComponent":{"params":[{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"updateComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"},{"name":"component","type":"object"}]},"deleteComponent":{"params":[{"name":"id","type":"string"},{"name":"collection","type":"string"}]},"createBehavior":{"params":[{"name":"behavior","type":"object"}]},"updateBehavior":{"params":[{"name":"id","type":"string"},{"name":"behavior","type":"object"}]},"deleteBehavior":{"params":[{"name":"id","type":"string"}]}}},"schemas":{"10374180581a41f":{"_id":"10374180581a41f","_name":"RuntimeAdmin","_inherit":["RuntimeComponent"],"_core":true,"start":"method"},"104ad1f48518376":{"_id":"104ad1f48518376","_name":"RuntimeChannel","sync":"event","loadSystem":"event","createSchema":"event","updateSchema":"event","deleteSchema":"event","createModel":"event","updateModel":"event","deleteModel":"event","createType":"event","updateType":"event","deleteType":"event","createComponent":"event","updateComponent":"event","deleteComponent":"event","createBehavior":"event","updateBehavior":"event","deleteBehavior":"event"}},"types":{},"behaviors":{"1c00c107e01c9b3":{"_id":"1c00c107e01c9b3","component":"RuntimeAdmin","state":"start","action":"function start() {\n var RuntimeChannel = null,\n runtimeChannel = null;\n \n if (!this.require('channel-admin')) {\n RuntimeChannel = this.require('RuntimeChannel');\n runtimeChannel = new RuntimeChannel({\n '_id': 'channel-admin',\n '_core': true\n });\n \n runtimeChannel.on('send', function send(message) {\n this.require('storage').set('system-designer-message', message);\n });\n \n // schema change events\n runtimeChannel.on('createSchema', function createSchema(id, schema) {\n this.require('metamodel').schema(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateSchema', function updateSchema(id, schema) {\n this.require('metamodel').type(schema);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteSchema', function deleteSchema(id) {\n $db.Runtime.remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // model change events\n runtimeChannel.on('createModel', function createModel(id, model) {\n this.require('metamodel').schema(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateModel', function updateModel(id, model) {\n this.require('metamodel').type(model);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteModel', function deleteModel(id) {\n $db['Runtime'].remove({'_id': id});\n this.require('metamodel').create();\n $component.removeFromMemory(id);\n }, true);\n \n // type change events\n runtimeChannel.on('createType', function createType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('updateType', function updateType(id, type) {\n this.require('metamodel').type(type);\n this.require('metamodel').create();\n }, true);\n \n runtimeChannel.on('deleteType', function deleteType(id) {\n $db.RuntimeType.remove({'_id': id});\n this.require('metamodel').create();\n }, true);\n \n // component change events\n runtimeChannel.on('createComponent', function createComponent(model, component) {\n $db[model].insert(component);\n }, true);\n \n runtimeChannel.on('updateComponent', function updateComponent(id, collection, component) {\n $db[collection].update({'_id': id}, component);\n }, true);\n \n runtimeChannel.on('deleteComponent', function deleteComponent(id, collection) {\n $db[collection].remove({'_id': id});\n }, true);\n \n // behavior change events\n runtimeChannel.on('createBehavior', function createBehavior(component) {\n $db.RuntimeBehavior.insert(component);\n }, true);\n runtimeChannel.on('updateBehavior', function updateBehavior(id, behavior) {\n this.require(id).action(behavior.action);\n });\n runtimeChannel.on('deleteBehavior', function deleteBehavior(id) {\n $db.RuntimeBehavior.remove({'_id': id}); \n }, true);\n \n // System Designer event\n runtimeChannel.on('sync', function sync() {\n this.loadSystem(JSON.parse(this.require('db').system()));\n });\n \n this.require('storage').on('changed', function (obj) {\n if (typeof obj['system-designer-message'] !== 'undefined') {\n $db.RuntimeMessage.insert(obj['system-designer-message'].newValue);\n }\n }, true);\n \n this.require('logger').info('admin is started');\n } else {\n this.require('logger').info('admin is already started');\n }\n}","useCoreAPI":true,"core":true}},"components":{"RuntimeAdmin":{"admin":{"_id":"admin","_core":true}}},"name":"system-admin","version":"0.6.0","description":"Runtime Component administration ","_id":"18ed81de331252c","master":false,"subsystem":false}

addons/system-storage.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"system-storage","master":false,"subsystem":false,"version":"0.0.1","description":"Runtime storage system","schemas":{"12fa8181ce127a0":{"_id":"12fa8181ce127a0","_name":"RuntimeStorage","_inherit":["RuntimeComponent"],"_core":true,"store":"property","get":"method","set":"method","remove":"method","clear":"method","changed":"event"}},"behaviors":{"1ca0f1020412d4f":{"_id":"1ca0f1020412d4f","component":"RuntimeStorage","state":"get","action":"function get(key) {\n var result = null;\n \n if (typeof this.store()[key]) {\n result = this.store()[key];\n }\n return result;\n}","useCoreAPI":false,"core":true},"16764100d51b5f8":{"_id":"16764100d51b5f8","component":"RuntimeStorage","state":"set","action":"function set(key, value) {\n var store = this.store(),\n item = {};\n \n store[key] = value;\n this.store(store);\n \n item[key] = JSON.stringify(value);\n \n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.setItem(key, JSON.stringify(value)); \n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":true},"134b616b1016f60":{"_id":"134b616b1016f60","component":"RuntimeStorage","state":"clear","action":"function clear() {\n this.store({});\n \n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.clear(); \n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":true},"14c7f1a8431b3d5":{"_id":"14c7f1a8431b3d5","component":"RuntimeStorage","state":"init","action":"function init(conf) {\n switch (true) {\n case typeof localStorage !== 'undefined':\n \n // init \n var keys = Object.keys(localStorage),\n store = {},\n i = 0,\n length = 0;\n \n length = keys.length; \n for (i = 0; i < length; i++) { \n store[keys[i]] = JSON.parse(localStorage[keys[i]]);\n }\n this.store(store);\n \n // event\n window.addEventListener('storage', function (e) {\n var obj = {},\n store = this.store();\n \n store[e.key] = JSON.parse(e.newValue)\n this.store(store);\n \n obj[e.key] = {};\n obj[e.key].oldValue = JSON.parse(e.oldValue);\n obj[e.key].newValue = JSON.parse(e.newValue);\n \n this.changed(obj);\n }.bind(this));\n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":true},"1a4921ac7112bd4":{"_id":"1a4921ac7112bd4","component":"RuntimeStorage","state":"remove","action":"function remove(key) {\n var store = this.store();\n \n delete store[key];\n this.store(store);\n \n switch (true) {\n case typeof localStorage !== 'undefined':\n localStorage.removeItem(key); \n break;\n default:\n break;\n }\n}","useCoreAPI":false,"core":true}},"types":{},"components":{"RuntimeStorage":{"storage":{"_id":"storage","_core":true}}},"_id":"15de81d295153db","models":{"1f4141671514c2c":{"_id":"1f4141671514c2c","_name":"RuntimeStorage","get":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"set":{"params":[{"name":"key","type":"string","mandatory":true,"default":""},{"name":"value","type":"any","mandatory":true,"default":null}]},"changed":{"params":[{"name":"changed","type":"object","mandatory":true,"default":{}}]},"clear":{},"remove":{"params":[{"name":"key","type":"string","mandatory":true,"default":""}]},"_core":true,"store":{"type":"object","readOnly":false,"mandatory":false,"default":{}}}}}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "system-runtime",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "Runtime, the System Runtime Environment",
55
"license": "Apache-2.0",
66
"homepage": "https://system-runtime.github.io",

0 commit comments

Comments
 (0)