polfan-server-js-client 0.2.43 → 0.2.45

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 (29) hide show
  1. package/.idea/workspace.xml +57 -23
  2. package/build/index.cjs.js +61 -1
  3. package/build/index.cjs.js.map +1 -1
  4. package/build/index.umd.js +1 -1
  5. package/build/index.umd.js.map +1 -1
  6. package/build/types/AbstractChatClient.d.ts +8 -1
  7. package/build/types/state-tracker/ChatStateTracker.d.ts +5 -0
  8. package/build/types/state-tracker/RelationshipsManager.d.ts +15 -0
  9. package/build/types/types/src/index.d.ts +7 -1
  10. package/build/types/types/src/schemes/UserRelationship.d.ts +8 -0
  11. package/build/types/types/src/schemes/commands/CreateRelationship.d.ts +5 -0
  12. package/build/types/types/src/schemes/commands/DeleteRelationship.d.ts +5 -0
  13. package/build/types/types/src/schemes/commands/GetRelationships.d.ts +2 -0
  14. package/build/types/types/src/schemes/events/NewRelationship.d.ts +4 -0
  15. package/build/types/types/src/schemes/events/RelationshipDeleted.d.ts +4 -0
  16. package/build/types/types/src/schemes/events/Relationships.d.ts +4 -0
  17. package/package.json +1 -1
  18. package/src/AbstractChatClient.ts +8 -1
  19. package/src/state-tracker/ChatStateTracker.ts +6 -0
  20. package/src/state-tracker/RelationshipsManager.ts +68 -0
  21. package/src/state-tracker/RoomsManager.ts +1 -1
  22. package/src/types/src/index.ts +13 -0
  23. package/src/types/src/schemes/UserRelationship.ts +9 -0
  24. package/src/types/src/schemes/commands/CreateRelationship.ts +6 -0
  25. package/src/types/src/schemes/commands/DeleteRelationship.ts +6 -0
  26. package/src/types/src/schemes/commands/GetRelationships.ts +3 -0
  27. package/src/types/src/schemes/events/NewRelationship.ts +5 -0
  28. package/src/types/src/schemes/events/RelationshipDeleted.ts +5 -0
  29. package/src/types/src/schemes/events/Relationships.ts +5 -0
@@ -4,7 +4,7 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Update schemes" />
7
+ <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Relationships support" />
8
8
  <option name="SHOW_DIALOG" value="false" />
9
9
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
10
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -46,24 +46,24 @@
46
46
  <option name="hideEmptyMiddlePackages" value="true" />
47
47
  <option name="showLibraryContents" value="true" />
48
48
  </component>
49
- <component name="PropertiesComponent">{
50
- &quot;keyToString&quot;: {
51
- &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
52
- &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager&quot;: &quot;true&quot;,
53
- &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
54
- &quot;git-widget-placeholder&quot;: &quot;master&quot;,
55
- &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
56
- &quot;junie.onboarding.icon.badge.shown&quot;: &quot;true&quot;,
57
- &quot;last_opened_file_path&quot;: &quot;//wsl.localhost/Debian/home/jarek/polfan-js-client-library&quot;,
58
- &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
59
- &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
60
- &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
61
- &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
62
- &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
63
- &quot;ts.external.directory.path&quot;: &quot;\\\\wsl.localhost\\Debian\\home\\jarek\\polfan-js-client-library\\node_modules\\typescript\\lib&quot;,
64
- &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
49
+ <component name="PropertiesComponent"><![CDATA[{
50
+ "keyToString": {
51
+ "RunOnceActivity.ShowReadmeOnStart": "true",
52
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
53
+ "RunOnceActivity.git.unshallow": "true",
54
+ "git-widget-placeholder": "master",
55
+ "ignore.virus.scanning.warn.message": "true",
56
+ "junie.onboarding.icon.badge.shown": "true",
57
+ "last_opened_file_path": "//wsl.localhost/Debian/home/jarek/polfan-js-client-library",
58
+ "node.js.detected.package.eslint": "true",
59
+ "node.js.detected.package.tslint": "true",
60
+ "node.js.selected.package.eslint": "(autodetect)",
61
+ "node.js.selected.package.tslint": "(autodetect)",
62
+ "nodejs_package_manager_path": "npm",
63
+ "ts.external.directory.path": "\\\\wsl.localhost\\Debian\\home\\jarek\\polfan-js-client-library\\node_modules\\typescript\\lib",
64
+ "vue.rearranger.settings.migration": "true"
65
65
  }
66
- }</component>
66
+ }]]></component>
67
67
  <component name="SharedIndexes">
68
68
  <attachedChunks>
69
69
  <set>
@@ -119,7 +119,9 @@
119
119
  <workItem from="1752705788150" duration="3566000" />
120
120
  <workItem from="1752756543261" duration="1956000" />
121
121
  <workItem from="1752834023436" duration="2601000" />
122
- <workItem from="1753062168800" duration="4435000" />
122
+ <workItem from="1753062168800" duration="4938000" />
123
+ <workItem from="1753441064452" duration="1184000" />
124
+ <workItem from="1753954931871" duration="6117000" />
123
125
  </task>
124
126
  <task id="LOCAL-00001" summary="Emoticons objects">
125
127
  <option name="closed" value="true" />
@@ -473,7 +475,39 @@
473
475
  <option name="project" value="LOCAL" />
474
476
  <updated>1753215397205</updated>
475
477
  </task>
476
- <option name="localTasksCounter" value="45" />
478
+ <task id="LOCAL-00045" summary="Fix for incorrectly emitted RoomUpdated event">
479
+ <option name="closed" value="true" />
480
+ <created>1753379371012</created>
481
+ <option name="number" value="00045" />
482
+ <option name="presentableId" value="LOCAL-00045" />
483
+ <option name="project" value="LOCAL" />
484
+ <updated>1753379371012</updated>
485
+ </task>
486
+ <task id="LOCAL-00046" summary="Fix for incorrectly emitted RoomUpdated event">
487
+ <option name="closed" value="true" />
488
+ <created>1753379410620</created>
489
+ <option name="number" value="00046" />
490
+ <option name="presentableId" value="LOCAL-00046" />
491
+ <option name="project" value="LOCAL" />
492
+ <updated>1753379410620</updated>
493
+ </task>
494
+ <task id="LOCAL-00047" summary="Fix for incorrectly emitted RoomUpdated event">
495
+ <option name="closed" value="true" />
496
+ <created>1753379731857</created>
497
+ <option name="number" value="00047" />
498
+ <option name="presentableId" value="LOCAL-00047" />
499
+ <option name="project" value="LOCAL" />
500
+ <updated>1753379731857</updated>
501
+ </task>
502
+ <task id="LOCAL-00048" summary="Relationships support">
503
+ <option name="closed" value="true" />
504
+ <created>1754149839341</created>
505
+ <option name="number" value="00048" />
506
+ <option name="presentableId" value="LOCAL-00048" />
507
+ <option name="project" value="LOCAL" />
508
+ <updated>1754149839341</updated>
509
+ </task>
510
+ <option name="localTasksCounter" value="49" />
477
511
  <servers />
478
512
  </component>
479
513
  <component name="TypeScriptGeneratedFilesManager">
@@ -491,8 +525,6 @@
491
525
  </option>
492
526
  </component>
493
527
  <component name="VcsManagerConfiguration">
494
- <MESSAGE value="Emoticons support" />
495
- <MESSAGE value="Emoticon permissions support" />
496
528
  <MESSAGE value="Permission related changes in protocol types" />
497
529
  <MESSAGE value="ClassicText room type" />
498
530
  <MESSAGE value="Restore support for nullable parameter in permission overwrites id function" />
@@ -516,6 +548,8 @@
516
548
  <MESSAGE value="Adapt FilesClient to new files API" />
517
549
  <MESSAGE value="Fix global emoticons support" />
518
550
  <MESSAGE value="Update schemes" />
519
- <option name="LAST_COMMIT_MESSAGE" value="Update schemes" />
551
+ <MESSAGE value="Fix for incorrectly emitted RoomUpdated event" />
552
+ <MESSAGE value="Relationships support" />
553
+ <option name="LAST_COMMIT_MESSAGE" value="Relationships support" />
520
554
  </component>
521
555
  </project>
@@ -1094,7 +1094,7 @@ class RoomsManager {
1094
1094
  this.addJoinedRooms(ev.room);
1095
1095
  }
1096
1096
  handleRoomUpdated(ev) {
1097
- if (this.list.has(ev.room)) {
1097
+ if (this.list.has(ev.room.id)) {
1098
1098
  this.list.set(ev.room);
1099
1099
  }
1100
1100
  }
@@ -1912,6 +1912,61 @@ class UsersManager {
1912
1912
  this.users.set(...users);
1913
1913
  }
1914
1914
  }
1915
+ ;// CONCATENATED MODULE: ./src/state-tracker/RelationshipsManager.ts
1916
+ function RelationshipsManager_defineProperty(obj, key, value) { key = RelationshipsManager_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1917
+ function RelationshipsManager_toPropertyKey(arg) { var key = RelationshipsManager_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
1918
+ function RelationshipsManager_toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1919
+
1920
+
1921
+ const getId = (refUserId, type) => `${refUserId}-${type}`;
1922
+ const getIdFromRelationship = relationship => getId(relationship.refUserId, relationship.type);
1923
+ class RelationshipsManager {
1924
+ constructor(tracker) {
1925
+ this.tracker = tracker;
1926
+ RelationshipsManager_defineProperty(this, "relationships", new ObservableIndexedObjectCollection(getIdFromRelationship));
1927
+ RelationshipsManager_defineProperty(this, "promises", new PromiseRegistry());
1928
+ this.tracker.client.on('Relationships', ev => this.handleRelationships(ev));
1929
+ this.tracker.client.on('NewRelationship', ev => this.handleNewRelationship(ev));
1930
+ this.tracker.client.on('RelationshipDeleted', ev => this.handleRelationshipDeleted(ev));
1931
+ this.tracker.client.on('Session', () => this.handleSession());
1932
+ }
1933
+ async get() {
1934
+ if (this.promises.notExist('all')) {
1935
+ this.promises.registerByFunction(async () => {
1936
+ const result = await this.tracker.client.send('GetRelationships', {});
1937
+ if (result.error) {
1938
+ throw result.error;
1939
+ }
1940
+ }, 'all');
1941
+ }
1942
+ await this.promises.get('all');
1943
+ return this.relationships;
1944
+ }
1945
+ async exists(refUserId, type) {
1946
+ await this.get();
1947
+ return this.relationships.has(getId(refUserId, type));
1948
+ }
1949
+ handleRelationships(ev) {
1950
+ this.relationships.deleteAll();
1951
+ ev.relationships.forEach(relationship => {
1952
+ this.relationships.set(relationship);
1953
+ });
1954
+ }
1955
+ handleNewRelationship(ev) {
1956
+ if (this.promises.has('all')) {
1957
+ this.relationships.set(ev.relationship);
1958
+ }
1959
+ }
1960
+ handleRelationshipDeleted(ev) {
1961
+ if (this.promises.has('all')) {
1962
+ this.relationships.delete(getIdFromRelationship(ev.relationship));
1963
+ }
1964
+ }
1965
+ handleSession() {
1966
+ this.promises.forgetAll();
1967
+ this.relationships.deleteAll();
1968
+ }
1969
+ }
1915
1970
  ;// CONCATENATED MODULE: ./src/state-tracker/ChatStateTracker.ts
1916
1971
  function ChatStateTracker_defineProperty(obj, key, value) { key = ChatStateTracker_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1917
1972
  function ChatStateTracker_toPropertyKey(arg) { var key = ChatStateTracker_toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -1922,6 +1977,7 @@ function ChatStateTracker_toPrimitive(input, hint) { if (typeof input !== "objec
1922
1977
 
1923
1978
 
1924
1979
 
1980
+
1925
1981
  class ChatStateTracker {
1926
1982
  constructor(client) {
1927
1983
  this.client = client;
@@ -1945,6 +2001,10 @@ class ChatStateTracker {
1945
2001
  * Users related state.
1946
2002
  */
1947
2003
  ChatStateTracker_defineProperty(this, "users", new UsersManager(this));
2004
+ /**
2005
+ * State of relationships with other users.
2006
+ */
2007
+ ChatStateTracker_defineProperty(this, "relationships", new RelationshipsManager(this));
1948
2008
  ChatStateTracker_defineProperty(this, "_me", null);
1949
2009
  ChatStateTracker_defineProperty(this, "deferredSession", new DeferredTask());
1950
2010
  this.client.on('Session', ev => this.handleSession(ev));