First draft
This commit is contained in:
		
							parent
							
								
									cb0b8760ed
								
							
						
					
					
						commit
						e1a4347c1c
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| node_modules | ||||
							
								
								
									
										35
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								.jshintrc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| { | ||||
|   "predef": [ | ||||
|     "global", | ||||
|     "Promise", | ||||
|     "require", | ||||
|     "process", | ||||
|     "module", | ||||
|     "exports" | ||||
|   ], | ||||
|   "browser": false, | ||||
|   "boss": true, | ||||
|   "curly": true, | ||||
|   "debug": false, | ||||
|   "devel": true, | ||||
|   "eqeqeq": true, | ||||
|   "evil": true, | ||||
|   "forin": false, | ||||
|   "immed": false, | ||||
|   "laxbreak": false, | ||||
|   "newcap": true, | ||||
|   "noarg": true, | ||||
|   "noempty": false, | ||||
|   "nonew": false, | ||||
|   "nomen": false, | ||||
|   "onevar": false, | ||||
|   "plusplus": false, | ||||
|   "regexp": false, | ||||
|   "undef": true, | ||||
|   "sub": true, | ||||
|   "strict": false, | ||||
|   "white": false, | ||||
|   "eqnull": true, | ||||
|   "esnext": true, | ||||
|   "unused": true | ||||
| } | ||||
							
								
								
									
										180
									
								
								dist/build.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								dist/build.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,180 @@ | ||||
| (function webpackUniversalModuleDefinition(root, factory) { | ||||
| 	if(typeof exports === 'object' && typeof module === 'object') | ||||
| 		module.exports = factory(require("remotestoragejs")); | ||||
| 	else if(typeof define === 'function' && define.amd) | ||||
| 		define(["remotestoragejs"], factory); | ||||
| 	else { | ||||
| 		var a = typeof exports === 'object' ? factory(require("remotestoragejs")) : factory(root["RemoteStorage"]); | ||||
| 		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||||
| 	} | ||||
| })(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { | ||||
| return /******/ (function(modules) { // webpackBootstrap
 | ||||
| /******/ 	// The module cache
 | ||||
| /******/ 	var installedModules = {}; | ||||
| /******/ | ||||
| /******/ 	// The require function
 | ||||
| /******/ 	function __webpack_require__(moduleId) { | ||||
| /******/ | ||||
| /******/ 		// Check if module is in cache
 | ||||
| /******/ 		if(installedModules[moduleId]) | ||||
| /******/ 			return installedModules[moduleId].exports; | ||||
| /******/ | ||||
| /******/ 		// Create a new module (and put it into the cache)
 | ||||
| /******/ 		var module = installedModules[moduleId] = { | ||||
| /******/ 			exports: {}, | ||||
| /******/ 			id: moduleId, | ||||
| /******/ 			loaded: false | ||||
| /******/ 		}; | ||||
| /******/ | ||||
| /******/ 		// Execute the module function
 | ||||
| /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||||
| /******/ | ||||
| /******/ 		// Flag the module as loaded
 | ||||
| /******/ 		module.loaded = true; | ||||
| /******/ | ||||
| /******/ 		// Return the exports of the module
 | ||||
| /******/ 		return module.exports; | ||||
| /******/ 	} | ||||
| /******/ | ||||
| /******/ | ||||
| /******/ 	// expose the modules object (__webpack_modules__)
 | ||||
| /******/ 	__webpack_require__.m = modules; | ||||
| /******/ | ||||
| /******/ 	// expose the module cache
 | ||||
| /******/ 	__webpack_require__.c = installedModules; | ||||
| /******/ | ||||
| /******/ 	// __webpack_public_path__
 | ||||
| /******/ 	__webpack_require__.p = ""; | ||||
| /******/ | ||||
| /******/ 	// Load entry module and return exports
 | ||||
| /******/ 	return __webpack_require__(0); | ||||
| /******/ }) | ||||
| /************************************************************************/ | ||||
| /******/ ([ | ||||
| /* 0 */ | ||||
| /***/ function(module, exports, __webpack_require__) { | ||||
| 
 | ||||
| 	'use strict'; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * File: Kosmos | ||||
| 	 * | ||||
| 	 * Maintainer: - Sebastian Kippe <sebastian@kip.pe> | ||||
| 	 * Version:    - 0.1.0 | ||||
| 	 * | ||||
| 	 * This module manages data related to the Kosmos group communication suite | ||||
| 	 */ | ||||
| 	 | ||||
| 	var RemoteStorage = __webpack_require__(1); | ||||
| 	 | ||||
| 	RemoteStorage.defineModule('kosmos', function (privateClient /*, publicClient*/) { | ||||
| 	 | ||||
| 	  var extend = RemoteStorage.util.extend; | ||||
| 	 | ||||
| 	  //
 | ||||
| 	  // Types/Schemas
 | ||||
| 	  //
 | ||||
| 	 | ||||
| 	  var baseProperties = { | ||||
| 	    "id": { | ||||
| 	      "type": "string" | ||||
| 	    }, | ||||
| 	    "createdAt": { | ||||
| 	      "type": "string", | ||||
| 	      "format": "date-time" | ||||
| 	    }, | ||||
| 	    "updatedAt": { | ||||
| 	      "type": "string", | ||||
| 	      "format": "date-time" | ||||
| 	    } | ||||
| 	  }; | ||||
| 	 | ||||
| 	  privateClient.declareType('space', { | ||||
| 	    "type": "object", | ||||
| 	    "properties": extend({ | ||||
| 	      "id": { | ||||
| 	        "type": "string" | ||||
| 	      }, | ||||
| 	      "name": { | ||||
| 	        "type": "string" | ||||
| 	      }, | ||||
| 	      "protocol": { | ||||
| 	        "type": "string", | ||||
| 	        "default": "IRC", | ||||
| 	        "enum": ["IRC", "XMPP", "Mattermost", "Slack"] | ||||
| 	      }, | ||||
| 	      "server": { | ||||
| 	        "type": "object", | ||||
| 	        "properties": { | ||||
| 	          "hostname": { | ||||
| 	            "type": "string" | ||||
| 	          }, | ||||
| 	          "port": { | ||||
| 	            "type": "number" | ||||
| 	          }, | ||||
| 	          "secure": { | ||||
| 	            "type": "boolean" | ||||
| 	          }, | ||||
| 	          "username": { | ||||
| 	            "type": "string" | ||||
| 	          }, | ||||
| 	          "password": { | ||||
| 	            "type": "string" | ||||
| 	          }, | ||||
| 	          "nickname": { | ||||
| 	            "type": "string" | ||||
| 	          } | ||||
| 	        } | ||||
| 	      }, | ||||
| 	      "channels": { | ||||
| 	        "type": "array", | ||||
| 	        "default": [] | ||||
| 	      } | ||||
| 	    }, baseProperties), | ||||
| 	    "required": ["id", "name", "protocol", "server"] | ||||
| 	  }); | ||||
| 	 | ||||
| 	  //
 | ||||
| 	  // Public functions
 | ||||
| 	  //
 | ||||
| 	 | ||||
| 	  var kosmos = { | ||||
| 	 | ||||
| 	    spaces: { | ||||
| 	      getAll: function getAll() { | ||||
| 	        return privateClient.getAll('spaces/'); | ||||
| 	      }, | ||||
| 	      store: function store(params) { | ||||
| 	        if (!params.createdAt) { | ||||
| 	          params.createdAt = new Date().toISOString(); | ||||
| 	        } | ||||
| 	 | ||||
| 	        return privateClient.storeObject('space', 'spaces/' + params.id, params); | ||||
| 	      }, | ||||
| 	      remove: function remove(id) { | ||||
| 	        return privateClient.remove('spaces/' + id); | ||||
| 	      } | ||||
| 	    }, | ||||
| 	 | ||||
| 	    // TODO remove
 | ||||
| 	    client: privateClient | ||||
| 	  }; | ||||
| 	 | ||||
| 	  //
 | ||||
| 	  // Return public functions
 | ||||
| 	  //
 | ||||
| 	 | ||||
| 	  return { exports: kosmos }; | ||||
| 	}); | ||||
| 
 | ||||
| /***/ }, | ||||
| /* 1 */ | ||||
| /***/ function(module, exports) { | ||||
| 
 | ||||
| 	module.exports = __WEBPACK_EXTERNAL_MODULE_1__; | ||||
| 
 | ||||
| /***/ } | ||||
| /******/ ]) | ||||
| }); | ||||
| ; | ||||
| //# sourceMappingURL=build.js.map
 | ||||
							
								
								
									
										1
									
								
								dist/build.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								dist/build.js.map
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										113
									
								
								index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,113 @@ | ||||
| /** | ||||
|  * File: Kosmos | ||||
|  * | ||||
|  * Maintainer: - Sebastian Kippe <sebastian@kip.pe> | ||||
|  * Version:    - 0.1.0 | ||||
|  * | ||||
|  * This module manages data related to the Kosmos group communication suite | ||||
|  */ | ||||
| 
 | ||||
| var RemoteStorage = require('remotestoragejs'); | ||||
| 
 | ||||
| RemoteStorage.defineModule('kosmos', function(privateClient/*, publicClient*/) { | ||||
| 
 | ||||
|   var extend = RemoteStorage.util.extend; | ||||
| 
 | ||||
|   //
 | ||||
|   // Types/Schemas
 | ||||
|   //
 | ||||
| 
 | ||||
|   var baseProperties = { | ||||
|     "id": { | ||||
|       "type": "string" | ||||
|     }, | ||||
|     "createdAt": { | ||||
|       "type": "string", | ||||
|       "format": "date-time" | ||||
|     }, | ||||
|     "updatedAt": { | ||||
|       "type": "string", | ||||
|       "format": "date-time" | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   privateClient.declareType('space', { | ||||
|     "type": "object", | ||||
|     "properties": extend({ | ||||
|       "id": { | ||||
|         "type": "string", | ||||
|       }, | ||||
|       "name": { | ||||
|         "type": "string", | ||||
|       }, | ||||
|       "protocol": { | ||||
|         "type": "string", | ||||
|         "default": "IRC", | ||||
|         "enum": ["IRC", "XMPP", "Mattermost", "Slack"] | ||||
|       }, | ||||
|       "server": { | ||||
|         "type": "object", | ||||
|         "properties": { | ||||
|           "hostname": { | ||||
|             "type": "string" | ||||
|           }, | ||||
|           "port": { | ||||
|             "type": "number" | ||||
|           }, | ||||
|           "secure": { | ||||
|             "type": "boolean" | ||||
|           }, | ||||
|           "username": { | ||||
|             "type": "string" | ||||
|           }, | ||||
|           "password": { | ||||
|             "type": "string" | ||||
|           }, | ||||
|           "nickname": { | ||||
|             "type": "string" | ||||
|           }, | ||||
|         } | ||||
|       }, | ||||
|       "channels": { | ||||
|         "type": "array", | ||||
|         "default": [] | ||||
|       }, | ||||
|     }, baseProperties), | ||||
|     "required": ["id", "name", "protocol", "server"] | ||||
|   }); | ||||
| 
 | ||||
|   //
 | ||||
|   // Public functions
 | ||||
|   //
 | ||||
| 
 | ||||
|   var kosmos = { | ||||
| 
 | ||||
|     spaces: { | ||||
| 
 | ||||
|       getAll() { | ||||
|         return privateClient.getAll('spaces/'); | ||||
|       }, | ||||
| 
 | ||||
|       store(params) { | ||||
|         if (!params.createdAt) { params.createdAt = new Date().toISOString(); } | ||||
| 
 | ||||
|         return privateClient.storeObject('space', `spaces/${params.id}`, params); | ||||
|       }, | ||||
| 
 | ||||
|       remove(id) { | ||||
|         return privateClient.remove(`spaces/${id}`); | ||||
|       } | ||||
| 
 | ||||
|     }, | ||||
| 
 | ||||
|     // TODO remove
 | ||||
|     client: privateClient | ||||
|   }; | ||||
| 
 | ||||
|   //
 | ||||
|   // Return public functions
 | ||||
|   //
 | ||||
| 
 | ||||
|   return { exports: kosmos }; | ||||
| 
 | ||||
| }); | ||||
							
								
								
									
										19
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| { | ||||
|   "name": "remotestorage-module-kosmos", | ||||
|   "version": "0.1.0", | ||||
|   "description": "remoteStorage module for Kosmos clients", | ||||
|   "main": "./dist/build.js", | ||||
|   "scripts": { | ||||
|     "test": "echo \"Error: no test specified\" && exit 1", | ||||
|     "dev": "webpack -w", | ||||
|     "build": "NODE_ENV=production webpack" | ||||
|   }, | ||||
|   "author": "Kosmos Developers <mail@kosmos.org> (https://kosmos.org)", | ||||
|   "license": "MIT", | ||||
|   "devDependencies": { | ||||
|     "babel-core": "^6.18.2", | ||||
|     "babel-loader": "^6.2.7", | ||||
|     "babel-preset-es2015": "^6.18.0", | ||||
|     "webpack": "^1.13.2" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										32
									
								
								webpack.config.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								webpack.config.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| var webpack = require('webpack'); | ||||
| var isProd = (process.env.NODE_ENV === 'production'); | ||||
| 
 | ||||
| // minimize only in production
 | ||||
| var plugins = isProd ? [new webpack.optimize.UglifyJsPlugin({minimize: true })] : [] | ||||
| 
 | ||||
| module.exports = { | ||||
|   entry: './index.js', | ||||
|   // source map not in production
 | ||||
|   devtool: !isProd && 'source-map', | ||||
|   output: { | ||||
|     filename: __dirname + '/dist/build.js', | ||||
|     libraryTarget: 'umd' | ||||
|   }, | ||||
|   externals: { | ||||
|     "remotestoragejs": { | ||||
|       root: "RemoteStorage", // <script src='remotestorage.js'> will resolve in this.RemoteStorage
 | ||||
|       commonjs2: "remotestoragejs", // require('remotestoragejs')
 | ||||
|       commonjs: "remotestoragejs", // require('remotestoragejs')
 | ||||
|       amd: "remotestoragejs" // define(['remotestoragejs'], ...)
 | ||||
|     } | ||||
|   }, | ||||
|   module: { | ||||
|     loaders: [ | ||||
|       { test: /\.js$/, exclude: '/node_modules|dist/', loader: 'babel?presets[]=es2015' }, | ||||
|     ] | ||||
|   }, | ||||
|   resolve: { | ||||
|     extensions: ['', '.js'] | ||||
|   }, | ||||
|   plugins: plugins | ||||
| }; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user