polfan-server-js-client 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +0 -0
- package/.eslintrc.json +0 -0
- package/.idea/php.xml +18 -0
- package/.idea/vcs.xml +0 -1
- package/CONTRIBUTING.md +0 -15
- package/LICENSE +0 -21
- package/README.md +16 -16
- package/babel.config.js +7 -0
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/types/Client.d.ts +35 -8
- package/build/types/ObservableInterface.d.ts +8 -1
- package/build/types/connections/ConnectionAssets.d.ts +16 -0
- package/build/types/connections/RestApiConnection.d.ts +14 -0
- package/build/types/connections/WebApiConnection.d.ts +17 -12
- package/build/types/connections/WebSocketConnection.d.ts +16 -14
- package/build/types/dtos/Dto.d.ts +1 -1
- package/build/types/dtos/protocol/Envelope.d.ts +2 -2
- package/build/types/index.d.ts +5 -19
- package/package.json +1 -1
- package/scripts/getPackageJson.js +25 -0
- package/scripts/testMock.js +1 -0
- package/src/Client.ts +239 -0
- package/src/ObservableInterface.ts +39 -0
- package/src/connections/ConnectionAssets.ts +19 -0
- package/src/connections/RestApiConnection.ts +47 -0
- package/src/connections/WebApiConnection.ts +78 -0
- package/src/connections/WebSocketConnection.ts +95 -0
- package/src/dtos/Dto.ts +45 -0
- package/src/dtos/Message.ts +16 -0
- package/src/dtos/Permission.ts +12 -0
- package/src/dtos/Role.ts +12 -0
- package/src/dtos/Room.ts +15 -0
- package/src/dtos/RoomMember.ts +13 -0
- package/src/dtos/RoomSummary.ts +12 -0
- package/src/dtos/Space.ts +15 -0
- package/src/dtos/SpaceMember.ts +14 -0
- package/src/dtos/Topic.ts +12 -0
- package/src/dtos/User.ts +15 -0
- package/src/dtos/UserState.ts +16 -0
- package/src/dtos/protocol/Envelope.ts +12 -0
- package/src/dtos/protocol/commands/AssignRole.ts +12 -0
- package/src/dtos/protocol/commands/CreateMessage.ts +12 -0
- package/src/dtos/protocol/commands/CreateRole.ts +12 -0
- package/src/dtos/protocol/commands/CreateRoom.ts +12 -0
- package/src/dtos/protocol/commands/CreateSpace.ts +10 -0
- package/src/dtos/protocol/commands/CreateTopic.ts +12 -0
- package/src/dtos/protocol/commands/DeassignRole.ts +12 -0
- package/src/dtos/protocol/commands/DeleteRole.ts +11 -0
- package/src/dtos/protocol/commands/DeleteRoom.ts +10 -0
- package/src/dtos/protocol/commands/DeleteSpace.ts +10 -0
- package/src/dtos/protocol/commands/DeleteTopic.ts +10 -0
- package/src/dtos/protocol/commands/GetComputedPermissions.ts +13 -0
- package/src/dtos/protocol/commands/GetRolePermissions.ts +13 -0
- package/src/dtos/protocol/commands/GetRoomMembers.ts +10 -0
- package/src/dtos/protocol/commands/GetSession.ts +8 -0
- package/src/dtos/protocol/commands/GetSpaceMembers.ts +10 -0
- package/src/dtos/protocol/commands/GetSpaceRooms.ts +10 -0
- package/src/dtos/protocol/commands/GetUserPermissions.ts +13 -0
- package/src/dtos/protocol/commands/JoinRoom.ts +10 -0
- package/src/dtos/protocol/commands/JoinSpace.ts +10 -0
- package/src/dtos/protocol/commands/LeaveRoom.ts +10 -0
- package/src/dtos/protocol/commands/LeaveSpace.ts +10 -0
- package/src/dtos/protocol/commands/SetRolePermissions.ts +16 -0
- package/src/dtos/protocol/commands/SetUserPermissions.ts +16 -0
- package/src/dtos/protocol/events/Bye.ts +10 -0
- package/src/dtos/protocol/events/Error.ts +11 -0
- package/src/dtos/protocol/events/NewMessage.ts +13 -0
- package/src/dtos/protocol/events/NewRole.ts +14 -0
- package/src/dtos/protocol/events/NewRoom.ts +14 -0
- package/src/dtos/protocol/events/NewTopic.ts +14 -0
- package/src/dtos/protocol/events/Ok.ts +8 -0
- package/src/dtos/protocol/events/Permissions.ts +13 -0
- package/src/dtos/protocol/events/RoleDeleted.ts +11 -0
- package/src/dtos/protocol/events/RoomDeleted.ts +10 -0
- package/src/dtos/protocol/events/RoomJoined.ts +13 -0
- package/src/dtos/protocol/events/RoomLeft.ts +10 -0
- package/src/dtos/protocol/events/RoomMemberJoined.ts +13 -0
- package/src/dtos/protocol/events/RoomMemberLeft.ts +10 -0
- package/src/dtos/protocol/events/RoomMembers.ts +13 -0
- package/src/dtos/protocol/events/Session.ts +17 -0
- package/src/dtos/protocol/events/SpaceDeleted.ts +10 -0
- package/src/dtos/protocol/events/SpaceJoined.ts +13 -0
- package/src/dtos/protocol/events/SpaceLeft.ts +10 -0
- package/src/dtos/protocol/events/SpaceMemberJoined.ts +13 -0
- package/src/dtos/protocol/events/SpaceMemberLeft.ts +10 -0
- package/src/dtos/protocol/events/SpaceMemberUpdate.ts +13 -0
- package/src/dtos/protocol/events/SpaceMembers.ts +13 -0
- package/src/dtos/protocol/events/SpaceRooms.ts +13 -0
- package/src/dtos/protocol/events/TopicDeleted.ts +10 -0
- package/src/index.ts +14 -0
- package/src/protocol.ts +113 -0
- package/tsconfig.json +2 -2
- package/webpack.config.js +69 -0
- package/build/types/Token.d.ts +0 -5
- package/build/types/connections/ConnectionInterface.d.ts +0 -17
- package/build/types/dtos/protocol/EnvelopeMeta.d.ts +0 -6
- package/old/dist/Client.d.ts +0 -76
- package/old/dist/ObservableInterface.d.ts +0 -9
- package/old/dist/Token.d.ts +0 -5
- package/old/dist/connections/ConnectionInterface.d.ts +0 -17
- package/old/dist/connections/WebApiConnection.d.ts +0 -15
- package/old/dist/connections/WebSocketConnection.d.ts +0 -19
- package/old/dist/dtos/Dto.d.ts +0 -16
- package/old/dist/dtos/Message.d.ts +0 -9
- package/old/dist/dtos/Permission.d.ts +0 -7
- package/old/dist/dtos/Role.d.ts +0 -7
- package/old/dist/dtos/Room.d.ts +0 -8
- package/old/dist/dtos/RoomMember.d.ts +0 -6
- package/old/dist/dtos/RoomSummary.d.ts +0 -7
- package/old/dist/dtos/Space.d.ts +0 -8
- package/old/dist/dtos/SpaceMember.d.ts +0 -7
- package/old/dist/dtos/Topic.d.ts +0 -7
- package/old/dist/dtos/User.d.ts +0 -9
- package/old/dist/dtos/UserState.d.ts +0 -8
- package/old/dist/dtos/protocol/Envelope.d.ts +0 -7
- package/old/dist/dtos/protocol/EnvelopeMeta.d.ts +0 -6
- package/old/dist/dtos/protocol/ProtocolMessage.d.ts +0 -7
- package/old/dist/dtos/protocol/ProtocolMetaData.d.ts +0 -6
- package/old/dist/dtos/protocol/commands/AssignRole.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/CreateMessage.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/CreateRole.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/CreateRoom.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/CreateSpace.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/CreateTopic.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/DeassignRole.d.ts +0 -7
- package/old/dist/dtos/protocol/commands/DeleteRole.d.ts +0 -6
- package/old/dist/dtos/protocol/commands/DeleteRoom.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/DeleteSpace.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/DeleteTopic.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/GetComputedPermissions.d.ts +0 -8
- package/old/dist/dtos/protocol/commands/GetRolePermissions.d.ts +0 -8
- package/old/dist/dtos/protocol/commands/GetRoomMembers.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/GetSession.d.ts +0 -4
- package/old/dist/dtos/protocol/commands/GetSpaceMembers.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/GetSpaceRooms.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/GetUserPermissions.d.ts +0 -8
- package/old/dist/dtos/protocol/commands/JoinRoom.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/JoinSpace.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/LeaveRoom.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/LeaveSpace.d.ts +0 -5
- package/old/dist/dtos/protocol/commands/SetRolePermissions.d.ts +0 -9
- package/old/dist/dtos/protocol/commands/SetUserPermissions.d.ts +0 -9
- package/old/dist/dtos/protocol/events/Bye.d.ts +0 -5
- package/old/dist/dtos/protocol/events/Error.d.ts +0 -6
- package/old/dist/dtos/protocol/events/NewMessage.d.ts +0 -6
- package/old/dist/dtos/protocol/events/NewRole.d.ts +0 -7
- package/old/dist/dtos/protocol/events/NewRoom.d.ts +0 -7
- package/old/dist/dtos/protocol/events/NewTopic.d.ts +0 -7
- package/old/dist/dtos/protocol/events/Ok.d.ts +0 -4
- package/old/dist/dtos/protocol/events/Permissions.d.ts +0 -6
- package/old/dist/dtos/protocol/events/RoleDeleted.d.ts +0 -6
- package/old/dist/dtos/protocol/events/RoomDeleted.d.ts +0 -5
- package/old/dist/dtos/protocol/events/RoomJoined.d.ts +0 -6
- package/old/dist/dtos/protocol/events/RoomLeft.d.ts +0 -5
- package/old/dist/dtos/protocol/events/RoomMemberJoined.d.ts +0 -6
- package/old/dist/dtos/protocol/events/RoomMemberLeft.d.ts +0 -5
- package/old/dist/dtos/protocol/events/RoomMembers.d.ts +0 -6
- package/old/dist/dtos/protocol/events/Session.d.ts +0 -9
- package/old/dist/dtos/protocol/events/SpaceDeleted.d.ts +0 -5
- package/old/dist/dtos/protocol/events/SpaceJoined.d.ts +0 -6
- package/old/dist/dtos/protocol/events/SpaceLeft.d.ts +0 -5
- package/old/dist/dtos/protocol/events/SpaceMemberJoined.d.ts +0 -6
- package/old/dist/dtos/protocol/events/SpaceMemberLeft.d.ts +0 -5
- package/old/dist/dtos/protocol/events/SpaceMemberUpdate.d.ts +0 -6
- package/old/dist/dtos/protocol/events/SpaceMembers.d.ts +0 -6
- package/old/dist/dtos/protocol/events/SpaceRooms.d.ts +0 -6
- package/old/dist/dtos/protocol/events/TopicDeleted.d.ts +0 -5
- package/old/dist/index.d.ts +0 -27
- package/old/dist/index.js +0 -1916
- package/old/dist/index.js.map +0 -1
- package/old/dist/protocol.d.ts +0 -7
- package/old/dist/pserv-js-client.js +0 -2
- package/old/dist/pserv-js-client.js.map +0 -1
- package/old/package-lock.json +0 -2654
- package/old/package.json +0 -22
- package/old/tsconfig.json +0 -12
package/.eslintignore
ADDED
|
File without changes
|
package/.eslintrc.json
ADDED
|
File without changes
|
package/.idea/php.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="MessDetectorOptionsConfiguration">
|
|
4
|
+
<option name="transferred" value="true" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="PHPCSFixerOptionsConfiguration">
|
|
7
|
+
<option name="transferred" value="true" />
|
|
8
|
+
</component>
|
|
9
|
+
<component name="PHPCodeSnifferOptionsConfiguration">
|
|
10
|
+
<option name="transferred" value="true" />
|
|
11
|
+
</component>
|
|
12
|
+
<component name="PhpStanOptionsConfiguration">
|
|
13
|
+
<option name="transferred" value="true" />
|
|
14
|
+
</component>
|
|
15
|
+
<component name="PsalmOptionsConfiguration">
|
|
16
|
+
<option name="transferred" value="true" />
|
|
17
|
+
</component>
|
|
18
|
+
</project>
|
package/.idea/vcs.xml
CHANGED
package/CONTRIBUTING.md
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
When contributing to this repository, please first discuss the change you wish to make via issue,
|
|
4
|
-
email, or any other method with the owners of this repository before working on a change.
|
|
5
|
-
|
|
6
|
-
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
|
7
|
-
|
|
8
|
-
## Pull Request Guidelines
|
|
9
|
-
|
|
10
|
-
1. Please ensure your proposal will not radically change current functionality or bring along breaking changes.
|
|
11
|
-
2. PRs only consisting of typo fixes (or other automated contributions), will not be accepted.
|
|
12
|
-
3. Do not add any dependencies to the project.
|
|
13
|
-
4. Document your changes thoroughly.
|
|
14
|
-
5. Ensure coverage is complete (`npm run coverage` should show 100% coverage) and that none of the tests fail.
|
|
15
|
-
6. Be reactive to any comments, reviews or change requests entered in your pull request.
|
package/LICENSE
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Francisco Hodge
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# pserv-js-client-library
|
|
2
|
-
|
|
2
|
+
TypeScript client library to handle connection with Polfan chat service.
|
|
3
3
|
|
|
4
4
|
## How to use?
|
|
5
5
|
|
|
6
6
|
```js
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
const client = new PServ.Client(connection);
|
|
7
|
+
(async function () {
|
|
8
|
+
// Request new token and create client instance.
|
|
9
|
+
const tokenData = await PServ.Client.getToken('login', 'pass');
|
|
10
|
+
const client = new PServ.Client.createByToken(tokenData.token);
|
|
13
11
|
|
|
14
|
-
// Bind the listener for each NewMessage
|
|
15
|
-
client.on('NewMessage', ev => `${ev.message.author.nick} wrote: ${ev.message.content}`);
|
|
12
|
+
// Bind the listener for each NewMessage event:
|
|
13
|
+
client.on('NewMessage', ev => `${ev.message.author.nick} wrote: ${ev.message.content}`);
|
|
16
14
|
|
|
17
|
-
// Send a message to the server
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}))
|
|
15
|
+
// Send a message to the server:
|
|
16
|
+
client.sendCommand(new PServ.commands.CreateMessage({
|
|
17
|
+
content: 'Hello world!',
|
|
18
|
+
topicId: 'xxxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
|
|
19
|
+
}));
|
|
22
20
|
|
|
23
|
-
//
|
|
24
|
-
|
|
21
|
+
// You can handle result for specific command with returned promise:
|
|
22
|
+
const result = client.sendCommand(new PServ.commands.GetSpaceMembers({id: 'xxx'}));
|
|
23
|
+
console.log('Space member list', result.members)
|
|
24
|
+
})();
|
|
25
25
|
```
|