fix
parent
bdc7470ab6
commit
4cf524cdf2
|
@ -131,7 +131,7 @@ export class RayconnectSdk extends RayconnectBase {
|
|||
LoginWithPassword(
|
||||
data = { username: "guest", password: "guest" },
|
||||
TimeOutNumber = 30000
|
||||
): any {
|
||||
): Promise<any> {
|
||||
this.loginData = data;
|
||||
this.socket.emit("loginup", data);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rayconnect-client",
|
||||
"version": "0.11.27",
|
||||
"version": "0.11.29",
|
||||
"description": "rayconnect client",
|
||||
"main": "dist/rayconnect.js",
|
||||
"types": "dist/rayconnect.d.ts",
|
||||
|
|
|
@ -2,11 +2,12 @@ import { Observable } from 'rxjs';
|
|||
import { RayconnectBase } from './core/base';
|
||||
import { RayconnectSdk } from './core/sdk'
|
||||
import { Options, CallType, ExecuteType, QueryType, ServerData } from './core/types'
|
||||
|
||||
import { NimkatDB } from './storage/nimkat'
|
||||
|
||||
class Rayconnect extends RayconnectSdk {
|
||||
|
||||
private plugin: any = undefined
|
||||
private nimkat: NimkatDB = new NimkatDB()
|
||||
constructor(ops: Options = RayconnectBase.DefaultOps, token: any = undefined, config: any = true) {
|
||||
super(ops, token, config);
|
||||
}
|
||||
|
@ -45,12 +46,90 @@ class Rayconnect extends RayconnectSdk {
|
|||
*/
|
||||
Run(param: CallType) {
|
||||
const exec: ExecuteType = this.makeExec(param, this.plugin);
|
||||
|
||||
|
||||
return this.RequestBack(exec)
|
||||
}
|
||||
|
||||
|
||||
|
||||
account = {
|
||||
|
||||
otp: {
|
||||
verify: this.VerifyPhone,
|
||||
getCode: this.RequestOTP
|
||||
},
|
||||
signIn: (username: string, password: string) => {
|
||||
|
||||
return this.LoginWithPassword({
|
||||
username,
|
||||
password
|
||||
})
|
||||
},
|
||||
|
||||
signUp: (email: string, username: string, password: string) => {
|
||||
|
||||
},
|
||||
signOut: () => {
|
||||
|
||||
},
|
||||
changePassword: () => {
|
||||
|
||||
},
|
||||
changeUsername: () => {
|
||||
|
||||
},
|
||||
resetPassword: () => {
|
||||
|
||||
},
|
||||
destroy: () => {
|
||||
|
||||
},
|
||||
change: () => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
store = {
|
||||
run: ()=>{
|
||||
return this.nimkat.loadPermission();
|
||||
},
|
||||
add: (type: string, attributes: object) => {
|
||||
return this.nimkat.create(type, attributes)
|
||||
},
|
||||
find: (type: string, id: string) => {
|
||||
return this.nimkat.find(type, id);
|
||||
|
||||
},
|
||||
findAll: (type: string = "+all") => {
|
||||
return this.nimkat.findAll(type);
|
||||
|
||||
},
|
||||
remove: (type: string, id: string) => {
|
||||
return this.nimkat.delete(type, id);
|
||||
|
||||
},
|
||||
update: (type: string, id: string, attributes: object) => {
|
||||
return this.nimkat.update(type, attributes, id);
|
||||
|
||||
},
|
||||
on: (event: string, callback: Function) => {
|
||||
|
||||
},
|
||||
changeAccess: (type: string, action: string, userID: string) => {
|
||||
|
||||
return this.nimkat.changePermissionAccess(action, type, userID);
|
||||
|
||||
},
|
||||
hasAccess: (action: string) => {
|
||||
return this.nimkat.hasPermission(action);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Func(queryObj: QueryType): Observable<ServerData> {
|
||||
|
||||
const self = this
|
||||
|
@ -110,7 +189,7 @@ class Rayconnect extends RayconnectSdk {
|
|||
sender: data.uid,
|
||||
token: data.token,
|
||||
data: objectData,
|
||||
body:self.requestDataConvertor(objectData),
|
||||
body: self.requestDataConvertor(objectData),
|
||||
date: data.info.date,
|
||||
send: send,
|
||||
});
|
||||
|
@ -130,7 +209,7 @@ class Rayconnect extends RayconnectSdk {
|
|||
self.socket.on(event, Event)
|
||||
// Provide a way of canceling event
|
||||
return function unsubscribe() {
|
||||
|
||||
|
||||
self.socket.off(event, Event);
|
||||
|
||||
};
|
||||
|
|
|
@ -6,10 +6,10 @@ export class CloudStorageService {
|
|||
Keys: Map<any, any> = new Map()
|
||||
|
||||
|
||||
setItem(key: string, value: string) {
|
||||
setItem(key: string, value: string, type?:string) {
|
||||
return this.SetCloudStorage({
|
||||
key,
|
||||
value
|
||||
value,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
import { emitDataWithError, emitDataWithTimeout } from '../core/events';
|
||||
import { Provider } from "../providers/provider";
|
||||
import uuid from "../core/uuid";
|
||||
|
||||
const uuidGenerator = new uuid();
|
||||
|
||||
export class NimkatDB {
|
||||
|
||||
private socket: any;
|
||||
private permissions: string[] = [];
|
||||
constructor() {
|
||||
this.socket = Provider.CurrentConnection;
|
||||
}
|
||||
|
||||
create(type: string, value: object) {
|
||||
const id = uuidGenerator.uuid();
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_store_create",
|
||||
response_key: "nimkat_store_created_" + id,
|
||||
value: {
|
||||
id,
|
||||
value,
|
||||
type
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
update(type: string, value: object, id: string) {
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_store_update",
|
||||
response_key: "nimkat_store_updated_" + id,
|
||||
value: {
|
||||
id,
|
||||
value,
|
||||
type
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
find(type: string, id: string) {
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_store_find",
|
||||
response_key: "nimkat_store_finded_" + id,
|
||||
value: {
|
||||
id,
|
||||
type
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
findAll(type: string) {
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_store_findall",
|
||||
response_key: "nimkat_store_findall_" + type,
|
||||
value: {
|
||||
type
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
delete(type: string, id: string) {
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_store_delete",
|
||||
response_key: "nimkat_store_deleted_" + id,
|
||||
value: {
|
||||
id,
|
||||
type
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
changePermissionAccess(action: string, type: string, uid: string) {
|
||||
return emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_permission_change_" + uid,
|
||||
response_key: "nimkat_permission_changed_" + uid,
|
||||
value: {
|
||||
uid,
|
||||
type,
|
||||
action
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
hasPermission(action: string) {
|
||||
const result = this.permissions.find((item) => {
|
||||
return item == action
|
||||
})
|
||||
|
||||
if (result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async loadPermission() {
|
||||
const data: any = await emitDataWithTimeout(this.socket, {
|
||||
key: "nimkat_permission_get",
|
||||
response_key: "nimkat_permission_got",
|
||||
value: {
|
||||
|
||||
},
|
||||
});
|
||||
this.permissions = data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue