insite-users-client 2.4.0 → 2.6.0
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/README.md +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# insite-users-client
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/insite-users-client)
|
|
4
|
+
|
|
3
5
|
Client-side library for users, organizations, and roles in inSite. Subscribes to publications over WebSocket and wires data into reactive structures (orgs, users, current user) with automatic cross-linking and sync.
|
|
4
6
|
|
|
5
7
|
Part of [inSite](../../README.md) — requires [insite-ws](../ws/README.md) and [insite-subscriptions-client](../subscriptions-client/README.md).
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{SubscriptionGroup as v}from"insite-subscriptions-client";import{getAll as O}from"@nesvet/n";function u(r){r.null={_id:null,title:"",initials:"\u2014",displayLabel:"\u2014",isOrg:!0,users:Object.assign(new Set,{sorted:[]})}}function a(r){if(r)for(let t of r.added)t.isOrg=!0,t.users=Object.assign(new Set,{sorted:[]});else this.values.orgs.null.users.clear(),this.values.orgs.null.users.sorted.length=0}function c(r){let t=this.values.orgs;if(r){let{users:s,extendedOrgs:o}=this.values;for(let n of r){let i=t.get(n._id);i.owners=n.owners.map(l=>s.get(l)||t.get(l)),i.slaveOrgs=O(t,n.slaveOrgs,!0),i.note=n.note,i._l=0}let d=[];for(let n of o.sorted){let i=t.get(n._id);for(let l of i.slaveOrgs)l._l=i._l+1;d.push(i)}t.sortedHierarchically=d,this.isLoaded&&(this.items.users.emitUpdate(),this.items.orgs.emitUpdate(r))}else{for(let s of t.sorted)delete s.owners,delete s.slaveOrgs,delete s.note,delete s._l;delete t.sortedHierarchically}}import{getAll as f}from"@nesvet/n";function g(r){if(r){let t=this.values.roles;for(let s of r)s.ownInvolves=f(t,s.ownInvolves,!0),s.involves=f(t,s.involves,!0),s._l=0;for(let s of t.sorted)for(let o of s.ownInvolves)o._l=s._l+1;this.isLoaded&&this.items.users.emitUpdate(r)}}function h(r){if(r){let t=r.slaveIds.join(",");if(r.slavesSnapshot!==t){r.slavesSnapshot=t;let s=[],o=[],d=[],{users:n,orgs:i}=this.values;for(let l of r.slaveIds){let e=n.get(l);e?(s.push(e),o.push(e)):(e=i.get(l),e&&(s.push(e),d.push(e)))}r.slaves=s,r.slaveUsers=o,r.slaveOrgs=d}}}import{getAll as S,removeOne as U}from"@nesvet/n";function m(r){if(r){let t=this.values.users,s=this.values.user,o=this.values.orgs;t.get(s._id)!==s&&(t.set(s._id,s),t.sorted[t.sorted.findIndex(e=>e._id===s._id)]=s);let d=r.findIndex(e=>e._id===s._id);~d&&(r[d]=s);let n=r.added.findIndex(e=>e._id===s._id);~n&&(r.added[n]=s);for(let e of r.added)e.isUser=!0;let i,l=new Set;for(let e of r){let p=o.get(e.orgId)??o.null;e.org!==p&&(e.org&&(e.org.users.delete(e),U(e.org.users.sorted,e)),e.org=p,e.org.users.add(e),e.org.users.sorted.push(e)),l.add(e.org),e===s&&(i=!0)}for(let e of l)e.users.sorted.sort(t.sortCompareFunction);if(r.deleted.length)for(let e of[...o.sorted,o.null])for(let p of e.users)t.has(p._id)||(e.users.delete(p),U(e.users.sorted,p));this.isLoaded&&(i&&this.items.user.emitUpdate(),this.items.orgs.emitUpdate())}}function x(r){let t=this.values.users;if(r){let s=this.values.roles;for(let o of r){let d=t.get(o._id);d.roles=S(s,o.roleIds,!0)}}else for(let s of t.sorted)delete s.roles}var b=class extends v{constructor({values:t,...s}){super([["orgs",t?.orgs??"map",a,u],["users",t?.users??"map",m],["user",t?.user??[!0],h]],s)}isExtended=!1;extend(){if(this.isExtended===!1)return this.isExtended=null,this.attach([["roles","map",g],["extendedUsers","map","users.extended",x,!0],["extendedOrgs","map","orgs.extended",c,!0]]).then(()=>{this.isExtended=!0})}unextend(){this.isExtended&&(this.isExtended=!1,this.detach(["roles","extendedUsers","extendedOrgs"]))}};export{b as UsersSubscriptionGroup};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/UsersSubscriptionGroup.ts", "../src/orgs.ts", "../src/roles.ts", "../src/user.ts", "../src/users.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tSubscriptionGroup,\n\ttype SubscriptionMapWithSubscription,\n\ttype SubscriptionObjectWithSubscription\n} from \"insite-subscriptions-client\";\nimport { handleExtendedOrgs, handleOrgs, handleOrgsBeforeSubscribe } from \"./orgs\";\nimport { handleRoles } from \"./roles\";\nimport { handleUser } from \"./user\";\nimport { handleExtendedUsers, handleUsers } from \"./users\";\nimport type { UsersSubscriptionGroupOptions } from \"./types\";\n\n\nexport class UsersSubscriptionGroup extends SubscriptionGroup<[\n\t[ \"orgs\", SubscriptionMapWithSubscription | \"map\", typeof handleOrgs, typeof handleOrgsBeforeSubscribe ],\n\t[ \"users\", SubscriptionMapWithSubscription | \"map\", typeof handleUsers ],\n\t[ \"user\", SubscriptionObjectWithSubscription | [ true ], typeof handleUser ]\n] | [\n\t[ \"roles\", \"map\", typeof handleRoles ],\n\t[ \"extendedUsers\", \"map\", \"users.extended\", typeof handleExtendedUsers, true ],\n\t[ \"extendedOrgs\", \"map\", \"orgs.extended\", typeof handleExtendedOrgs, true ]\n]> {\n\tconstructor({ values, ...options }: UsersSubscriptionGroupOptions) {\n\t\tsuper([\n\t\t\t[ \"orgs\", values?.orgs ?? \"map\", handleOrgs, handleOrgsBeforeSubscribe ],\n\t\t\t[ \"users\", values?.users ?? \"map\", handleUsers ],\n\t\t\t[ \"user\", values?.user ?? [ true ], handleUser ]\n\t\t], options);\n\t}\n\t\n\tisExtended: boolean | null = false;\n\t\n\textend() {\n\t\t\n\t\tif (this.isExtended === false) {\n\t\t\tthis.isExtended = null;\n\t\t\t\n\t\t\treturn this.attach([\n\t\t\t\t[ \"roles\", \"map\", handleRoles ],\n\t\t\t\t[ \"extendedUsers\", \"map\", \"users.extended\", handleExtendedUsers, true ],\n\t\t\t\t[ \"extendedOrgs\", \"map\", \"orgs.extended\", handleExtendedOrgs, true ]\n\t\t\t]).then(() => {\n\t\t\t\t\n\t\t\t\tthis.isExtended = true;\n\t\t\t\t\n\t\t\t});\n\t\t}\n\t}\n\t\n\tunextend() {\n\t\t\n\t\tif (this.isExtended) {\n\t\t\tthis.isExtended = false;\n\t\t\t\n\t\t\tthis.detach([ \"roles\", \"extendedUsers\", \"extendedOrgs\" ]);\n\t\t}\n\t\t\n\t}\n\t\n}\n", "import { getAll } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type {\n\tOrg,\n\tOrgExtension,\n\tOrgs,\n\tOrgsExtended,\n\tUser\n} from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport function handleOrgsBeforeSubscribe(orgs: Orgs) {\n\torgs.null = {\n\t\t_id: null,\n\t\ttitle: \"\",\n\t\tinitials: \"\u2014\",\n\t\tdisplayLabel: \"\u2014\",\n\t\tisOrg: true,\n\t\tusers: Object.assign(new Set<User>(), { sorted: [] })\n\t};\n\t\n}\n\n/** @this UsersSubscriptionGroup */\nexport function handleOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Org> | null) {\n\tif (updated)\n\t\tfor (const org of updated.added) {\n\t\t\torg.isOrg = true;\n\t\t\t\n\t\t\torg.users = Object.assign(new Set<User>(), { sorted: [] });\n\t\t}\n\telse {\n\t\tthis.values.orgs.null.users.clear();\n\t\tthis.values.orgs.null.users.sorted.length = 0;\n\t}\n\t\n}\n\n/** @this UsersSubscriptionGroup */\nexport function handleExtendedOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<OrgExtension> | null) {\n\t\n\tconst orgs = this.values.orgs as OrgsExtended;\n\t\n\tif (updated) {\n\t\tconst { users, extendedOrgs } = this.values;\n\t\t\n\t\tfor (const orgExtension of updated) {\n\t\t\tconst org = orgs.get(orgExtension._id)!;\n\t\t\t\n\t\t\torg.owners = orgExtension.owners.map(_id => users.get(_id) || orgs.get(_id));\n\t\t\torg.slaveOrgs = getAll(orgs, orgExtension.slaveOrgs, true);\n\t\t\torg.note = orgExtension.note;\n\t\t\torg._l = 0;\n\t\t}\n\t\t\n\t\tconst sortedHierarchically = [];\n\t\t\n\t\tfor (const orgExtension of extendedOrgs.sorted) {\n\t\t\tconst org = orgs.get(orgExtension._id)!;\n\t\t\t\n\t\t\tfor (const slaveOrg of org.slaveOrgs!)\n\t\t\t\tslaveOrg._l = org._l! + 1;\n\t\t\t\n\t\t\tsortedHierarchically.push(org);\n\t\t}\n\t\t\n\t\torgs.sortedHierarchically = sortedHierarchically;\n\t\t\n\t\tif (this.isLoaded) {\n\t\t\tthis.items.users.emitUpdate();\n\t\t\tthis.items.orgs.emitUpdate(updated);\n\t\t}\n\t} else {\n\t\tfor (const org of orgs.sorted) {\n\t\t\tdelete org.owners;\n\t\t\tdelete org.slaveOrgs;\n\t\t\tdelete org.note;\n\t\t\tdelete org._l;\n\t\t}\n\t\tdelete orgs.sortedHierarchically;\n\t}\n\t\n}\n", "import { getAll } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type { Role, Roles } from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleRoles(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Role> | null) {\n\tif (updated) {\n\t\tconst roles = this.values.roles as Roles;\n\t\t\n\t\tfor (const role of updated) {\n\t\t\trole.ownInvolves = getAll(roles, role.ownInvolves as unknown as string[], true);\n\t\t\trole.involves = getAll(roles, role.involves as unknown as string[], true);\n\t\t\trole._l = 0;\n\t\t}\n\t\t\n\t\tfor (const role of roles.sorted)\n\t\t\tfor (const involvedRole of role.ownInvolves)\n\t\t\t\tinvolvedRole._l = role._l + 1;\n\t\t\n\t\tif (this.isLoaded)\n\t\t\tthis.items.users.emitUpdate(updated);\n\t}\n\t\n}\n", "import type { CurrentUser } from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleUser(this: UsersSubscriptionGroup, user: CurrentUser) {\n\tif (user) {\n\t\t\n\t\tconst slavesSnapshot = user.slaveIds.join(\",\");\n\t\t\n\t\tif (user.slavesSnapshot !== slavesSnapshot) {\n\t\t\tuser.slavesSnapshot = slavesSnapshot;\n\t\t\t\n\t\t\tconst slaves = [];\n\t\t\tconst slaveUsers = [];\n\t\t\tconst slaveOrgs = [];\n\t\t\t\n\t\t\tconst { users, orgs } = this.values;\n\t\t\t\n\t\t\tfor (const _id of user.slaveIds) {\n\t\t\t\tlet slave = users.get(_id);\n\t\t\t\tif (slave) {\n\t\t\t\t\tslaves.push(slave);\n\t\t\t\t\tslaveUsers.push(slave);\n\t\t\t\t} else {\n\t\t\t\t\tslave = orgs.get(_id);\n\t\t\t\t\tif (slave) {\n\t\t\t\t\t\tslaves.push(slave);\n\t\t\t\t\t\tslaveOrgs.push(slave);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tuser.slaves = slaves;\n\t\t\tuser.slaveUsers = slaveUsers;\n\t\t\tuser.slaveOrgs = slaveOrgs;\n\t\t}\n\t}\n\t\n}\n", "import { getAll, removeOne } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type {\n\tCurrentUser,\n\tNullOrg,\n\tOrg,\n\tOrgs,\n\tRoles,\n\tUser,\n\tUserExtension,\n\tUsers,\n\tUsersExtended\n} from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleUsers(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<User> | null) {\n\tif (updated) {\n\t\tconst users = this.values.users as Users;\n\t\tconst currentUser = this.values.user as CurrentUser;\n\t\tconst orgs = this.values.orgs as Orgs;\n\t\t\n\t\tif (users.get(currentUser._id) !== currentUser) {\n\t\t\tusers.set(currentUser._id, currentUser);\n\t\t\tusers.sorted[users.sorted.findIndex(user => user._id === currentUser._id)] = currentUser;\n\t\t}\n\t\tconst updatedUserIndex = updated.findIndex(user => user._id === currentUser._id);\n\t\t\n\t\tif (~updatedUserIndex)\n\t\t\tupdated[updatedUserIndex] = currentUser;\n\t\t\n\t\tconst addedUserIndex = updated.added.findIndex(user => user._id === currentUser._id);\n\t\t\n\t\tif (~addedUserIndex)\n\t\t\tupdated.added[
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["SubscriptionGroup", "getAll", "handleOrgsBeforeSubscribe", "orgs", "handleOrgs", "updated", "org", "handleExtendedOrgs", "users", "extendedOrgs", "orgExtension", "_id", "sortedHierarchically", "slaveOrg", "getAll", "handleRoles", "updated", "roles", "role", "involvedRole", "handleUser", "user", "slavesSnapshot", "slaves", "slaveUsers", "slaveOrgs", "users", "orgs", "_id", "slave", "getAll", "removeOne", "handleUsers", "updated", "users", "currentUser", "orgs", "user", "updatedUserIndex", "shouldUpdateUser", "orgsToSortUsers", "org", "handleExtendedUsers", "roles", "userExtension", "UsersSubscriptionGroup", "SubscriptionGroup", "values", "options", "handleOrgs", "handleOrgsBeforeSubscribe", "handleUsers", "handleUser", "
|
|
4
|
+
"sourcesContent": ["import {\n\tSubscriptionGroup,\n\ttype SubscriptionMapWithSubscription,\n\ttype SubscriptionObjectWithSubscription\n} from \"insite-subscriptions-client\";\nimport { handleExtendedOrgs, handleOrgs, handleOrgsBeforeSubscribe } from \"./orgs\";\nimport { handleRoles } from \"./roles\";\nimport { handleUser } from \"./user\";\nimport { handleExtendedUsers, handleUsers } from \"./users\";\nimport type { UsersSubscriptionGroupOptions } from \"./types\";\n\n\nexport class UsersSubscriptionGroup extends SubscriptionGroup<[\n\t[ \"orgs\", SubscriptionMapWithSubscription | \"map\", typeof handleOrgs, typeof handleOrgsBeforeSubscribe ],\n\t[ \"users\", SubscriptionMapWithSubscription | \"map\", typeof handleUsers ],\n\t[ \"user\", SubscriptionObjectWithSubscription | [ true ], typeof handleUser ]\n] | [\n\t[ \"roles\", \"map\", typeof handleRoles ],\n\t[ \"extendedUsers\", \"map\", \"users.extended\", typeof handleExtendedUsers, true ],\n\t[ \"extendedOrgs\", \"map\", \"orgs.extended\", typeof handleExtendedOrgs, true ]\n]> {\n\tconstructor({ values, ...options }: UsersSubscriptionGroupOptions) {\n\t\tsuper([\n\t\t\t[ \"orgs\", values?.orgs ?? \"map\", handleOrgs, handleOrgsBeforeSubscribe ],\n\t\t\t[ \"users\", values?.users ?? \"map\", handleUsers ],\n\t\t\t[ \"user\", values?.user ?? [ true ], handleUser ]\n\t\t], options);\n\t}\n\t\n\tisExtended: boolean | null = false;\n\t\n\textend() {\n\t\t\n\t\tif (this.isExtended === false) {\n\t\t\tthis.isExtended = null;\n\t\t\t\n\t\t\treturn this.attach([\n\t\t\t\t[ \"roles\", \"map\", handleRoles ],\n\t\t\t\t[ \"extendedUsers\", \"map\", \"users.extended\", handleExtendedUsers, true ],\n\t\t\t\t[ \"extendedOrgs\", \"map\", \"orgs.extended\", handleExtendedOrgs, true ]\n\t\t\t]).then(() => {\n\t\t\t\t\n\t\t\t\tthis.isExtended = true;\n\t\t\t\t\n\t\t\t});\n\t\t}\n\t}\n\t\n\tunextend() {\n\t\t\n\t\tif (this.isExtended) {\n\t\t\tthis.isExtended = false;\n\t\t\t\n\t\t\tthis.detach([ \"roles\", \"extendedUsers\", \"extendedOrgs\" ]);\n\t\t}\n\t\t\n\t}\n\t\n}\n", "import { getAll } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type {\n\tOrg,\n\tOrgExtension,\n\tOrgs,\n\tOrgsExtended,\n\tUser\n} from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport function handleOrgsBeforeSubscribe(orgs: Orgs) {\n\torgs.null = {\n\t\t_id: null,\n\t\ttitle: \"\",\n\t\tinitials: \"\u2014\",\n\t\tdisplayLabel: \"\u2014\",\n\t\tisOrg: true,\n\t\tusers: Object.assign(new Set<User>(), { sorted: [] })\n\t};\n\t\n}\n\n/** @this UsersSubscriptionGroup */\nexport function handleOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Org> | null) {\n\tif (updated)\n\t\tfor (const org of updated.added) {\n\t\t\torg.isOrg = true;\n\t\t\t\n\t\t\torg.users = Object.assign(new Set<User>(), { sorted: [] });\n\t\t}\n\telse {\n\t\tthis.values.orgs.null.users.clear();\n\t\tthis.values.orgs.null.users.sorted.length = 0;\n\t}\n\t\n}\n\n/** @this UsersSubscriptionGroup */\nexport function handleExtendedOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<OrgExtension> | null) {\n\t\n\tconst orgs = this.values.orgs as OrgsExtended;\n\t\n\tif (updated) {\n\t\tconst { users, extendedOrgs } = this.values;\n\t\t\n\t\tfor (const orgExtension of updated) {\n\t\t\tconst org = orgs.get(orgExtension._id)!;\n\t\t\t\n\t\t\torg.owners = orgExtension.owners.map(_id => users.get(_id) || orgs.get(_id));\n\t\t\torg.slaveOrgs = getAll(orgs, orgExtension.slaveOrgs, true);\n\t\t\torg.note = orgExtension.note;\n\t\t\torg._l = 0;\n\t\t}\n\t\t\n\t\tconst sortedHierarchically = [];\n\t\t\n\t\tfor (const orgExtension of extendedOrgs.sorted) {\n\t\t\tconst org = orgs.get(orgExtension._id)!;\n\t\t\t\n\t\t\tfor (const slaveOrg of org.slaveOrgs!)\n\t\t\t\tslaveOrg._l = org._l! + 1;\n\t\t\t\n\t\t\tsortedHierarchically.push(org);\n\t\t}\n\t\t\n\t\torgs.sortedHierarchically = sortedHierarchically;\n\t\t\n\t\tif (this.isLoaded) {\n\t\t\tthis.items.users.emitUpdate();\n\t\t\tthis.items.orgs.emitUpdate(updated);\n\t\t}\n\t} else {\n\t\tfor (const org of orgs.sorted) {\n\t\t\tdelete org.owners;\n\t\t\tdelete org.slaveOrgs;\n\t\t\tdelete org.note;\n\t\t\tdelete org._l;\n\t\t}\n\t\tdelete orgs.sortedHierarchically;\n\t}\n\t\n}\n", "import { getAll } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type { Role, Roles } from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleRoles(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Role> | null) {\n\tif (updated) {\n\t\tconst roles = this.values.roles as Roles;\n\t\t\n\t\tfor (const role of updated) {\n\t\t\trole.ownInvolves = getAll(roles, role.ownInvolves as unknown as string[], true);\n\t\t\trole.involves = getAll(roles, role.involves as unknown as string[], true);\n\t\t\trole._l = 0;\n\t\t}\n\t\t\n\t\tfor (const role of roles.sorted)\n\t\t\tfor (const involvedRole of role.ownInvolves)\n\t\t\t\tinvolvedRole._l = role._l + 1;\n\t\t\n\t\tif (this.isLoaded)\n\t\t\tthis.items.users.emitUpdate(updated);\n\t}\n\t\n}\n", "import type { CurrentUser } from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleUser(this: UsersSubscriptionGroup, user: CurrentUser) {\n\tif (user) {\n\t\t\n\t\tconst slavesSnapshot = user.slaveIds.join(\",\");\n\t\t\n\t\tif (user.slavesSnapshot !== slavesSnapshot) {\n\t\t\tuser.slavesSnapshot = slavesSnapshot;\n\t\t\t\n\t\t\tconst slaves = [];\n\t\t\tconst slaveUsers = [];\n\t\t\tconst slaveOrgs = [];\n\t\t\t\n\t\t\tconst { users, orgs } = this.values;\n\t\t\t\n\t\t\tfor (const _id of user.slaveIds) {\n\t\t\t\tlet slave = users.get(_id);\n\t\t\t\tif (slave) {\n\t\t\t\t\tslaves.push(slave);\n\t\t\t\t\tslaveUsers.push(slave);\n\t\t\t\t} else {\n\t\t\t\t\tslave = orgs.get(_id);\n\t\t\t\t\tif (slave) {\n\t\t\t\t\t\tslaves.push(slave);\n\t\t\t\t\t\tslaveOrgs.push(slave);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tuser.slaves = slaves;\n\t\t\tuser.slaveUsers = slaveUsers;\n\t\t\tuser.slaveOrgs = slaveOrgs;\n\t\t}\n\t}\n\t\n}\n", "import { getAll, removeOne } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated } from \"insite-subscriptions-client\";\nimport type {\n\tCurrentUser,\n\tNullOrg,\n\tOrg,\n\tOrgs,\n\tRoles,\n\tUser,\n\tUserExtension,\n\tUsers,\n\tUsersExtended\n} from \"./types\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\n/** @this UsersSubscriptionGroup */\nexport function handleUsers(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<User> | null) {\n\tif (updated) {\n\t\tconst users = this.values.users as Users;\n\t\tconst currentUser = this.values.user as CurrentUser;\n\t\tconst orgs = this.values.orgs as Orgs;\n\t\t\n\t\tif (users.get(currentUser._id) !== currentUser) {\n\t\t\tusers.set(currentUser._id, currentUser);\n\t\t\tusers.sorted[users.sorted.findIndex(user => user._id === currentUser._id)] = currentUser;\n\t\t}\n\t\tconst updatedUserIndex = updated.findIndex(user => user._id === currentUser._id);\n\t\t\n\t\tif (~updatedUserIndex)\n\t\t\tupdated[updatedUserIndex] = currentUser;\n\t\t\n\t\tconst addedUserIndex = updated.added.findIndex(user => user._id === currentUser._id);\n\t\t\n\t\tif (~addedUserIndex)\n\t\t\tupdated.added[addedUserIndex] = currentUser;\n\t\t\n\t\tfor (const user of updated.added)\n\t\t\tuser.isUser = true;\n\t\t\n\t\tlet shouldUpdateUser;\n\t\tconst orgsToSortUsers = new Set<NullOrg | Org>();\n\t\t\n\t\tfor (const user of updated) {\n\t\t\tconst org = orgs.get(user.orgId) ?? orgs.null;\n\t\t\t\n\t\t\tif (user.org !== org) {\n\t\t\t\tif (user.org) {\n\t\t\t\t\tuser.org.users.delete(user);\n\t\t\t\t\tremoveOne(user.org.users.sorted, user);\n\t\t\t\t}\n\t\t\t\tuser.org = org;\n\t\t\t\tuser.org.users.add(user);\n\t\t\t\tuser.org.users.sorted.push(user);\n\t\t\t}\n\t\t\t\n\t\t\torgsToSortUsers.add(user.org);\n\t\t\t\n\t\t\tif (user === currentUser)\n\t\t\t\tshouldUpdateUser = true;\n\t\t}\n\t\t\n\t\tfor (const org of orgsToSortUsers)\n\t\t\torg.users.sorted.sort(users.sortCompareFunction!);\n\t\t\n\t\tif (updated.deleted.length)\n\t\t\tfor (const org of [ ...orgs.sorted, orgs.null ])\n\t\t\t\tfor (const user of org.users)\n\t\t\t\t\tif (!users.has(user._id)) {\n\t\t\t\t\t\torg.users.delete(user);\n\t\t\t\t\t\tremoveOne(org.users.sorted, user);\n\t\t\t\t\t}\n\t\t\n\t\tif (this.isLoaded) {\n\t\t\tif (shouldUpdateUser)\n\t\t\t\tthis.items.user.emitUpdate();\n\t\t\tthis.items.orgs.emitUpdate();\n\t\t}\n\t}\n\t\n}\n\n/** @this UsersSubscriptionGroup */\nexport function handleExtendedUsers(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<UserExtension> | null) {\n\t\n\tconst users = this.values.users as UsersExtended;\n\t\n\tif (updated) {\n\t\tconst roles = this.values.roles as Roles;\n\t\t\n\t\tfor (const userExtension of updated) {\n\t\t\tconst user = users.get(userExtension._id)!;\n\t\t\t\n\t\t\tuser.roles = getAll(roles, userExtension.roleIds, true);\n\t\t}\n\t} else\n\t\tfor (const user of users.sorted)\n\t\t\tdelete user.roles;\n\t\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OACC,qBAAAA,MAGM,8BCJP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,MAAM,KAAK,WAAW,EAE7B,CAED,CAGO,SAASG,EAAkDV,EAAuD,CAExH,IAAMC,EAAQ,KAAK,OAAO,MAE1B,GAAID,EAAS,CACZ,IAAMW,EAAQ,KAAK,OAAO,MAE1B,QAAWC,KAAiBZ,EAAS,CACpC,IAAMI,EAAOH,EAAM,IAAIW,EAAc,GAAG,EAExCR,EAAK,MAAQP,EAAOc,EAAOC,EAAc,QAAS,EAAI,CACvD,CACD,KACC,SAAWR,KAAQH,EAAM,OACxB,OAAOG,EAAK,KAEf,CJvFO,IAAMS,EAAN,cAAqCC,CAQzC,CACF,YAAY,CAAE,OAAAC,EAAQ,GAAGC,CAAQ,EAAkC,CAClE,MAAM,CACL,CAAE,OAAQD,GAAQ,MAAQ,MAAOE,EAAYC,CAA0B,EACvE,CAAE,QAASH,GAAQ,OAAS,MAAOI,CAAY,EAC/C,CAAE,OAAQJ,GAAQ,MAAQ,CAAE,EAAK,EAAGK,CAAW,CAChD,EAAGJ,CAAO,CACX,CAEA,WAA6B,GAE7B,QAAS,CAER,GAAI,KAAK,aAAe,GACvB,YAAK,WAAa,KAEX,KAAK,OAAO,CAClB,CAAE,QAAS,MAAOK,CAAY,EAC9B,CAAE,gBAAiB,MAAO,iBAAkBC,EAAqB,EAAK,EACtE,CAAE,eAAgB,MAAO,gBAAiBC,EAAoB,EAAK,CACpE,CAAC,EAAE,KAAK,IAAM,CAEb,KAAK,WAAa,EAEnB,CAAC,CAEH,CAEA,UAAW,CAEN,KAAK,aACR,KAAK,WAAa,GAElB,KAAK,OAAO,CAAE,QAAS,gBAAiB,cAAe,CAAC,EAG1D,CAED",
|
|
6
|
+
"names": ["SubscriptionGroup", "getAll", "handleOrgsBeforeSubscribe", "orgs", "handleOrgs", "updated", "org", "handleExtendedOrgs", "users", "extendedOrgs", "orgExtension", "_id", "sortedHierarchically", "slaveOrg", "getAll", "handleRoles", "updated", "roles", "role", "involvedRole", "handleUser", "user", "slavesSnapshot", "slaves", "slaveUsers", "slaveOrgs", "users", "orgs", "_id", "slave", "getAll", "removeOne", "handleUsers", "updated", "users", "currentUser", "orgs", "user", "updatedUserIndex", "addedUserIndex", "shouldUpdateUser", "orgsToSortUsers", "org", "handleExtendedUsers", "roles", "userExtension", "UsersSubscriptionGroup", "SubscriptionGroup", "values", "options", "handleOrgs", "handleOrgsBeforeSubscribe", "handleUsers", "handleUser", "handleRoles", "handleExtendedUsers", "handleExtendedOrgs"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insite-users-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Client-side users API for inSite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"insite",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@nesvet/n": "^1.2.1",
|
|
43
|
-
"insite-common": "^2.
|
|
44
|
-
"insite-subscriptions-client": "^2.
|
|
43
|
+
"insite-common": "^2.6.0",
|
|
44
|
+
"insite-subscriptions-client": "^2.6.0"
|
|
45
45
|
},
|
|
46
|
-
"packageManager": "bun@1.3.9",
|
|
47
46
|
"engines": {
|
|
48
|
-
"
|
|
47
|
+
"bun": ">=1.4.4",
|
|
48
|
+
"node": ">=22.0.0"
|
|
49
49
|
}
|
|
50
50
|
}
|