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.
Files changed (177) hide show
  1. package/.eslintignore +0 -0
  2. package/.eslintrc.json +0 -0
  3. package/.idea/php.xml +18 -0
  4. package/.idea/vcs.xml +0 -1
  5. package/CONTRIBUTING.md +0 -15
  6. package/LICENSE +0 -21
  7. package/README.md +16 -16
  8. package/babel.config.js +7 -0
  9. package/build/index.js +1 -1
  10. package/build/index.js.map +1 -1
  11. package/build/types/Client.d.ts +35 -8
  12. package/build/types/ObservableInterface.d.ts +8 -1
  13. package/build/types/connections/ConnectionAssets.d.ts +16 -0
  14. package/build/types/connections/RestApiConnection.d.ts +14 -0
  15. package/build/types/connections/WebApiConnection.d.ts +17 -12
  16. package/build/types/connections/WebSocketConnection.d.ts +16 -14
  17. package/build/types/dtos/Dto.d.ts +1 -1
  18. package/build/types/dtos/protocol/Envelope.d.ts +2 -2
  19. package/build/types/index.d.ts +5 -19
  20. package/package.json +1 -1
  21. package/scripts/getPackageJson.js +25 -0
  22. package/scripts/testMock.js +1 -0
  23. package/src/Client.ts +239 -0
  24. package/src/ObservableInterface.ts +39 -0
  25. package/src/connections/ConnectionAssets.ts +19 -0
  26. package/src/connections/RestApiConnection.ts +47 -0
  27. package/src/connections/WebApiConnection.ts +78 -0
  28. package/src/connections/WebSocketConnection.ts +95 -0
  29. package/src/dtos/Dto.ts +45 -0
  30. package/src/dtos/Message.ts +16 -0
  31. package/src/dtos/Permission.ts +12 -0
  32. package/src/dtos/Role.ts +12 -0
  33. package/src/dtos/Room.ts +15 -0
  34. package/src/dtos/RoomMember.ts +13 -0
  35. package/src/dtos/RoomSummary.ts +12 -0
  36. package/src/dtos/Space.ts +15 -0
  37. package/src/dtos/SpaceMember.ts +14 -0
  38. package/src/dtos/Topic.ts +12 -0
  39. package/src/dtos/User.ts +15 -0
  40. package/src/dtos/UserState.ts +16 -0
  41. package/src/dtos/protocol/Envelope.ts +12 -0
  42. package/src/dtos/protocol/commands/AssignRole.ts +12 -0
  43. package/src/dtos/protocol/commands/CreateMessage.ts +12 -0
  44. package/src/dtos/protocol/commands/CreateRole.ts +12 -0
  45. package/src/dtos/protocol/commands/CreateRoom.ts +12 -0
  46. package/src/dtos/protocol/commands/CreateSpace.ts +10 -0
  47. package/src/dtos/protocol/commands/CreateTopic.ts +12 -0
  48. package/src/dtos/protocol/commands/DeassignRole.ts +12 -0
  49. package/src/dtos/protocol/commands/DeleteRole.ts +11 -0
  50. package/src/dtos/protocol/commands/DeleteRoom.ts +10 -0
  51. package/src/dtos/protocol/commands/DeleteSpace.ts +10 -0
  52. package/src/dtos/protocol/commands/DeleteTopic.ts +10 -0
  53. package/src/dtos/protocol/commands/GetComputedPermissions.ts +13 -0
  54. package/src/dtos/protocol/commands/GetRolePermissions.ts +13 -0
  55. package/src/dtos/protocol/commands/GetRoomMembers.ts +10 -0
  56. package/src/dtos/protocol/commands/GetSession.ts +8 -0
  57. package/src/dtos/protocol/commands/GetSpaceMembers.ts +10 -0
  58. package/src/dtos/protocol/commands/GetSpaceRooms.ts +10 -0
  59. package/src/dtos/protocol/commands/GetUserPermissions.ts +13 -0
  60. package/src/dtos/protocol/commands/JoinRoom.ts +10 -0
  61. package/src/dtos/protocol/commands/JoinSpace.ts +10 -0
  62. package/src/dtos/protocol/commands/LeaveRoom.ts +10 -0
  63. package/src/dtos/protocol/commands/LeaveSpace.ts +10 -0
  64. package/src/dtos/protocol/commands/SetRolePermissions.ts +16 -0
  65. package/src/dtos/protocol/commands/SetUserPermissions.ts +16 -0
  66. package/src/dtos/protocol/events/Bye.ts +10 -0
  67. package/src/dtos/protocol/events/Error.ts +11 -0
  68. package/src/dtos/protocol/events/NewMessage.ts +13 -0
  69. package/src/dtos/protocol/events/NewRole.ts +14 -0
  70. package/src/dtos/protocol/events/NewRoom.ts +14 -0
  71. package/src/dtos/protocol/events/NewTopic.ts +14 -0
  72. package/src/dtos/protocol/events/Ok.ts +8 -0
  73. package/src/dtos/protocol/events/Permissions.ts +13 -0
  74. package/src/dtos/protocol/events/RoleDeleted.ts +11 -0
  75. package/src/dtos/protocol/events/RoomDeleted.ts +10 -0
  76. package/src/dtos/protocol/events/RoomJoined.ts +13 -0
  77. package/src/dtos/protocol/events/RoomLeft.ts +10 -0
  78. package/src/dtos/protocol/events/RoomMemberJoined.ts +13 -0
  79. package/src/dtos/protocol/events/RoomMemberLeft.ts +10 -0
  80. package/src/dtos/protocol/events/RoomMembers.ts +13 -0
  81. package/src/dtos/protocol/events/Session.ts +17 -0
  82. package/src/dtos/protocol/events/SpaceDeleted.ts +10 -0
  83. package/src/dtos/protocol/events/SpaceJoined.ts +13 -0
  84. package/src/dtos/protocol/events/SpaceLeft.ts +10 -0
  85. package/src/dtos/protocol/events/SpaceMemberJoined.ts +13 -0
  86. package/src/dtos/protocol/events/SpaceMemberLeft.ts +10 -0
  87. package/src/dtos/protocol/events/SpaceMemberUpdate.ts +13 -0
  88. package/src/dtos/protocol/events/SpaceMembers.ts +13 -0
  89. package/src/dtos/protocol/events/SpaceRooms.ts +13 -0
  90. package/src/dtos/protocol/events/TopicDeleted.ts +10 -0
  91. package/src/index.ts +14 -0
  92. package/src/protocol.ts +113 -0
  93. package/tsconfig.json +2 -2
  94. package/webpack.config.js +69 -0
  95. package/build/types/Token.d.ts +0 -5
  96. package/build/types/connections/ConnectionInterface.d.ts +0 -17
  97. package/build/types/dtos/protocol/EnvelopeMeta.d.ts +0 -6
  98. package/old/dist/Client.d.ts +0 -76
  99. package/old/dist/ObservableInterface.d.ts +0 -9
  100. package/old/dist/Token.d.ts +0 -5
  101. package/old/dist/connections/ConnectionInterface.d.ts +0 -17
  102. package/old/dist/connections/WebApiConnection.d.ts +0 -15
  103. package/old/dist/connections/WebSocketConnection.d.ts +0 -19
  104. package/old/dist/dtos/Dto.d.ts +0 -16
  105. package/old/dist/dtos/Message.d.ts +0 -9
  106. package/old/dist/dtos/Permission.d.ts +0 -7
  107. package/old/dist/dtos/Role.d.ts +0 -7
  108. package/old/dist/dtos/Room.d.ts +0 -8
  109. package/old/dist/dtos/RoomMember.d.ts +0 -6
  110. package/old/dist/dtos/RoomSummary.d.ts +0 -7
  111. package/old/dist/dtos/Space.d.ts +0 -8
  112. package/old/dist/dtos/SpaceMember.d.ts +0 -7
  113. package/old/dist/dtos/Topic.d.ts +0 -7
  114. package/old/dist/dtos/User.d.ts +0 -9
  115. package/old/dist/dtos/UserState.d.ts +0 -8
  116. package/old/dist/dtos/protocol/Envelope.d.ts +0 -7
  117. package/old/dist/dtos/protocol/EnvelopeMeta.d.ts +0 -6
  118. package/old/dist/dtos/protocol/ProtocolMessage.d.ts +0 -7
  119. package/old/dist/dtos/protocol/ProtocolMetaData.d.ts +0 -6
  120. package/old/dist/dtos/protocol/commands/AssignRole.d.ts +0 -7
  121. package/old/dist/dtos/protocol/commands/CreateMessage.d.ts +0 -7
  122. package/old/dist/dtos/protocol/commands/CreateRole.d.ts +0 -7
  123. package/old/dist/dtos/protocol/commands/CreateRoom.d.ts +0 -7
  124. package/old/dist/dtos/protocol/commands/CreateSpace.d.ts +0 -5
  125. package/old/dist/dtos/protocol/commands/CreateTopic.d.ts +0 -7
  126. package/old/dist/dtos/protocol/commands/DeassignRole.d.ts +0 -7
  127. package/old/dist/dtos/protocol/commands/DeleteRole.d.ts +0 -6
  128. package/old/dist/dtos/protocol/commands/DeleteRoom.d.ts +0 -5
  129. package/old/dist/dtos/protocol/commands/DeleteSpace.d.ts +0 -5
  130. package/old/dist/dtos/protocol/commands/DeleteTopic.d.ts +0 -5
  131. package/old/dist/dtos/protocol/commands/GetComputedPermissions.d.ts +0 -8
  132. package/old/dist/dtos/protocol/commands/GetRolePermissions.d.ts +0 -8
  133. package/old/dist/dtos/protocol/commands/GetRoomMembers.d.ts +0 -5
  134. package/old/dist/dtos/protocol/commands/GetSession.d.ts +0 -4
  135. package/old/dist/dtos/protocol/commands/GetSpaceMembers.d.ts +0 -5
  136. package/old/dist/dtos/protocol/commands/GetSpaceRooms.d.ts +0 -5
  137. package/old/dist/dtos/protocol/commands/GetUserPermissions.d.ts +0 -8
  138. package/old/dist/dtos/protocol/commands/JoinRoom.d.ts +0 -5
  139. package/old/dist/dtos/protocol/commands/JoinSpace.d.ts +0 -5
  140. package/old/dist/dtos/protocol/commands/LeaveRoom.d.ts +0 -5
  141. package/old/dist/dtos/protocol/commands/LeaveSpace.d.ts +0 -5
  142. package/old/dist/dtos/protocol/commands/SetRolePermissions.d.ts +0 -9
  143. package/old/dist/dtos/protocol/commands/SetUserPermissions.d.ts +0 -9
  144. package/old/dist/dtos/protocol/events/Bye.d.ts +0 -5
  145. package/old/dist/dtos/protocol/events/Error.d.ts +0 -6
  146. package/old/dist/dtos/protocol/events/NewMessage.d.ts +0 -6
  147. package/old/dist/dtos/protocol/events/NewRole.d.ts +0 -7
  148. package/old/dist/dtos/protocol/events/NewRoom.d.ts +0 -7
  149. package/old/dist/dtos/protocol/events/NewTopic.d.ts +0 -7
  150. package/old/dist/dtos/protocol/events/Ok.d.ts +0 -4
  151. package/old/dist/dtos/protocol/events/Permissions.d.ts +0 -6
  152. package/old/dist/dtos/protocol/events/RoleDeleted.d.ts +0 -6
  153. package/old/dist/dtos/protocol/events/RoomDeleted.d.ts +0 -5
  154. package/old/dist/dtos/protocol/events/RoomJoined.d.ts +0 -6
  155. package/old/dist/dtos/protocol/events/RoomLeft.d.ts +0 -5
  156. package/old/dist/dtos/protocol/events/RoomMemberJoined.d.ts +0 -6
  157. package/old/dist/dtos/protocol/events/RoomMemberLeft.d.ts +0 -5
  158. package/old/dist/dtos/protocol/events/RoomMembers.d.ts +0 -6
  159. package/old/dist/dtos/protocol/events/Session.d.ts +0 -9
  160. package/old/dist/dtos/protocol/events/SpaceDeleted.d.ts +0 -5
  161. package/old/dist/dtos/protocol/events/SpaceJoined.d.ts +0 -6
  162. package/old/dist/dtos/protocol/events/SpaceLeft.d.ts +0 -5
  163. package/old/dist/dtos/protocol/events/SpaceMemberJoined.d.ts +0 -6
  164. package/old/dist/dtos/protocol/events/SpaceMemberLeft.d.ts +0 -5
  165. package/old/dist/dtos/protocol/events/SpaceMemberUpdate.d.ts +0 -6
  166. package/old/dist/dtos/protocol/events/SpaceMembers.d.ts +0 -6
  167. package/old/dist/dtos/protocol/events/SpaceRooms.d.ts +0 -6
  168. package/old/dist/dtos/protocol/events/TopicDeleted.d.ts +0 -5
  169. package/old/dist/index.d.ts +0 -27
  170. package/old/dist/index.js +0 -1916
  171. package/old/dist/index.js.map +0 -1
  172. package/old/dist/protocol.d.ts +0 -7
  173. package/old/dist/pserv-js-client.js +0 -2
  174. package/old/dist/pserv-js-client.js.map +0 -1
  175. package/old/package-lock.json +0 -2654
  176. package/old/package.json +0 -22
  177. 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
@@ -2,6 +2,5 @@
2
2
  <project version="4">
3
3
  <component name="VcsDirectoryMappings">
4
4
  <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- <mapping directory="$PROJECT_DIR$/myLibrary" vcs="Git" />
6
5
  </component>
7
6
  </project>
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
- JavaScript client library to handle connection with Polfan chat service with TypeScript support.
2
+ TypeScript client library to handle connection with Polfan chat service.
3
3
 
4
4
  ## How to use?
5
5
 
6
6
  ```js
7
- // Create a client; WebSocket and WebApi connections are supported.
8
- const connection = new PServ.connections.WebSocket({
9
- url: 'wss://s1.polfan.pl/ws',
10
- token: await PServ.getToken('login', 'password', 'Client Name')
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 events.
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 on connect.
18
- connection.on('connect', () => client.exec(new PServ.data.commands.CreateMessage({
19
- content: 'Hello world!',
20
- topicId: 'xxxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
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
- // Connect to server.
24
- connection.connect();
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
  ```
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ presets: [["@babel/env"]],
3
+ plugins: [
4
+ ["@babel/plugin-proposal-class-properties"],
5
+ ["@babel/plugin-transform-typescript"],
6
+ ],
7
+ };