25 Commits

Author SHA1 Message Date
0a0e59bc4c 2.1.2 2022-01-10 17:26:25 -06:00
ee7b468930 Move NPM package to kosmos namespace 2022-01-10 17:26:07 -06:00
9b1d2db6e4 2.1.1 2022-01-10 17:22:09 -06:00
fde95e4278 Add repo info to package.json 2022-01-10 17:21:47 -06:00
1d6b90b858 2.1.0 2022-01-10 17:20:16 -06:00
b5e2e5c3e1 Merge pull request 'Add some channel properties' (#1) from chore/add_channel_properties into master
Reviewed-on: #1
2022-01-10 23:19:45 +00:00
fadd43363f Add some channel properties
* `isLogged` to determine if a channel is logged publicly in a format that
  allows us to retrieve messages when coming back online.
* `description` for a general description of the channel (vs.
  topic/subject)
2022-01-07 16:38:22 -06:00
d2be0ad361 2.0.0 2021-08-25 17:30:45 +02:00
a273db8839 Merge pull request #1 from 67P/feature/spaces_to_accounts
Refactor spaces to accounts, add separate channel documents
2021-08-25 17:29:23 +02:00
e06a4f0ac9 Add topic to channel objects 2021-08-20 15:08:30 +02:00
ec6bb0b2ba Fix wrong path in channels.remove() 2021-08-20 14:50:19 +02:00
87f0a3572d Update lockfile 2021-07-30 09:57:46 +02:00
ae5cd48cb1 Update build 2021-07-30 09:57:40 +02:00
3601440d9d Add chat channels/rooms 2021-07-30 09:57:26 +02:00
86c2ac04ba Allow null values for optional account properties 2021-07-30 09:57:07 +02:00
e6ab24db9a Remove trailing slashes from account ids 2021-07-28 22:29:33 +02:00
45b716037c getConfig returns an object 2021-07-28 22:08:25 +02:00
0c6cda2213 Revert "Add missing remotestoragejs dependency"
This reverts commit b74ed46037.
2021-07-28 16:35:14 +02:00
b74ed46037 Add missing remotestoragejs dependency 2021-07-28 16:29:06 +02:00
7c1ba68023 Fix getIds method
getListing returns the list of items directly, not inside an "items" property
2021-07-28 16:27:20 +02:00
4539e891bf Build when versioning 2021-07-28 14:54:22 +02:00
8ad60aa249 WIP Convert spaces into accounts 2021-07-28 14:45:09 +02:00
f92d87bdde 1.1.0 2018-05-01 16:44:58 +02:00
28d389388d Add botka URL to space object 2018-05-01 16:44:16 +02:00
8dc7f497c4 1.0.0 2017-06-12 18:02:31 +02:00
4 changed files with 2636 additions and 56 deletions

2
dist/build.js vendored
View File

@@ -1 +1 @@
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("remotestoragejs"));else if("function"==typeof define&&define.amd)define(["remotestoragejs"],t);else{var r=t("object"==typeof exports?require("remotestoragejs"):e.RemoteStorage);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,function(e){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),n=function(e){var t=o.util.extend,r={id:{type:"string"},createdAt:{type:"string",format:"date-time"},updatedAt:{type:"string",format:"date-time"}};e.declareType("space",{type:"object",properties:t({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:[]}},r),required:["id","name","protocol","server"]});var n={spaces:{getAll:function(){return e.getAll("spaces/")},store:function(t){return t.createdAt||(t.createdAt=(new Date).toISOString()),e.storeObject("space","spaces/"+t.id,t)},remove:function(t){return e.remove("spaces/"+t)}},client:e};return{exports:n}};t.default={name:"kosmos",builder:n}},function(t,r){t.exports=e}])}); !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){e.declareType("chat-account",{type:"object",properties:{id:{type:"string"},protocol:{type:"string",default:"IRC",enum:["IRC","XMPP"]},username:{type:["string","null"]},password:{type:["string","null"]},nickname:{type:["string","null"]},server:{type:"object",properties:{hostname:{type:["string","null"]},port:{type:["number","null"]},secure:{type:"boolean"}}},botkaURL:{type:["string","null"]}},required:["id","protocol"]}),e.declareType("chat-channel",{type:"object",properties:{id:{type:"string"},accountId:{type:"string"},displayName:{type:["string","null"]},userNickname:{type:["string","null"]},topic:{type:["string","null"]},description:{type:["string","null"]},isLogged:{type:["boolean","null"]}},required:["id","accountId"]});var t={accounts:{getIds:function(){return e.getListing("chat/").then(function(e){return Object.keys(e).map(function(e){return e.replace(/\/$/,"")})})},getConfig:function(t){return e.getObject("chat/"+t+"/account")},storeConfig:function(t){return e.storeObject("chat-account","chat/"+t.id+"/account",t)},remove:function(t){return e.remove("chat/"+t+"/account")}},channels:{getAll:function(t){return e.getAll("chat/"+t+"/channels/")},store:function(t){return e.storeObject("chat-channel","chat/"+t.accountId+"/channels/"+t.id,t)},remove:function(t,n){return e.remove("chat/"+t+"/channels/"+n)}},client:e};return{exports:t}};t.default={name:"kosmos",builder:n}}])});

133
index.js
View File

@@ -1,94 +1,123 @@
var RemoteStorage = require('remotestoragejs'); const Kosmos = function(privateClient/*, publicClient*/) {
var Kosmos = function(privateClient/*, publicClient*/) {
var extend = RemoteStorage.util.extend;
// //
// Types/Schemas // Types/Schemas
// //
var baseProperties = { privateClient.declareType('chat-account', {
"id": {
"type": "string"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
}
};
privateClient.declareType('space', {
"type": "object", "type": "object",
"properties": extend({ "properties": {
"id": { "id": {
"type": "string", "type": "string",
}, },
"name": {
"type": "string",
},
"protocol": { "protocol": {
"type": "string", "type": "string",
"default": "IRC", "default": "IRC",
"enum": ["IRC", "XMPP", "Mattermost", "Slack"] "enum": ["IRC", "XMPP"] // Mattermost, Slack, ...
},
"username": {
"type": [ "string", "null" ]
},
"password": {
"type": [ "string", "null" ]
},
"nickname": {
"type": [ "string", "null" ]
}, },
"server": { "server": {
"type": "object", "type": "object",
"properties": { "properties": {
"hostname": { "hostname": {
"type": "string" "type": [ "string", "null" ]
}, },
"port": { "port": {
"type": "number" "type": [ "number", "null" ]
}, },
"secure": { "secure": {
"type": "boolean" "type": "boolean"
}, }
"username": {
"type": "string"
},
"password": {
"type": "string"
},
"nickname": {
"type": "string"
},
} }
}, },
"channels": { "botkaURL": {
"type": "array", "type": [ "string", "null" ]
"default": [] }
},
"required": [
"id",
"protocol"
]
});
privateClient.declareType('chat-channel', {
"type": "object",
"properties": {
"id": {
"type": "string",
}, },
}, baseProperties), "accountId": {
"required": ["id", "name", "protocol", "server"] "type": "string"
},
"displayName": {
"type": [ "string", "null" ]
},
"userNickname": {
"type": [ "string", "null" ]
},
"topic": {
"type": [ "string", "null" ]
},
"description": {
"type": [ "string", "null" ]
},
"isLogged": {
"type": [ "boolean", "null" ]
}
},
"required": [
"id",
"accountId"
]
}); });
// //
// Public functions // Public functions
// //
var kosmos = { const kosmos = {
spaces: { accounts: {
getIds() {
getAll() { return privateClient.getListing('chat/').then(listing => {
return privateClient.getAll('spaces/'); return Object.keys(listing).map(id => id.replace(/\/$/, ''));
});
}, },
store(params) { getConfig(id) {
if (!params.createdAt) { params.createdAt = new Date().toISOString(); } return privateClient.getObject(`chat/${id}/account`);
return privateClient.storeObject('space', `spaces/${params.id}`, params);
}, },
storeConfig(obj) {
return privateClient.storeObject('chat-account', `chat/${obj.id}/account`, obj);
},
// TODO recursively remove all files
remove(id) { remove(id) {
return privateClient.remove(`spaces/${id}`); return privateClient.remove(`chat/${id}/account`);
} }
},
channels: {
getAll(accountId) {
return privateClient.getAll(`chat/${accountId}/channels/`);
},
store(obj) {
return privateClient.storeObject('chat-channel', `chat/${obj.accountId}/channels/${obj.id}`, obj);
},
remove(accountId, id) {
return privateClient.remove(`chat/${accountId}/channels/${id}`);
}
}, },
// TODO remove // TODO remove

2547
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,17 @@
{ {
"name": "remotestorage-module-kosmos", "name": "@kosmos/remotestorage-module-kosmos",
"version": "0.1.0", "version": "2.1.2",
"description": "remoteStorage module for Kosmos clients", "description": "remoteStorage module for Kosmos clients",
"repository": {
"type": "git",
"url": "https://gitea.kosmos.org/kosmos/rs-module-kosmos.git"
},
"main": "./dist/build.js", "main": "./dist/build.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack -w", "dev": "webpack -w",
"build": "NODE_ENV=production webpack", "build": "NODE_ENV=production webpack",
"prepublish": "npm run build && git add build" "version": "npm run build && git add dist"
}, },
"author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)", "author": "Kosmos Contributors <mail@kosmos.org> (https://kosmos.org)",
"license": "MIT", "license": "MIT",