insite-users-client 2.3.3 → 2.3.4
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/bun.lock +935 -0
- package/dist/UsersSubscriptionGroup.d.ts +41 -15
- package/dist/UsersSubscriptionGroup.d.ts.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/orgs.d.ts +2 -33
- package/dist/orgs.d.ts.map +1 -1
- package/dist/roles.d.ts +2 -8
- package/dist/roles.d.ts.map +1 -1
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/user.d.ts +1 -12
- package/dist/user.d.ts.map +1 -1
- package/dist/users.d.ts +2 -30
- package/dist/users.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,50 @@
|
|
|
1
|
-
import { SubscriptionGroup, type
|
|
1
|
+
import { SubscriptionGroup, type SubscriptionMapWithSubscription, type SubscriptionObjectWithSubscription } from "insite-subscriptions-client";
|
|
2
2
|
import { handleExtendedOrgs, handleOrgs, handleOrgsBeforeSubscribe } from "./orgs";
|
|
3
3
|
import { handleRoles } from "./roles";
|
|
4
4
|
import { handleUser } from "./user";
|
|
5
5
|
import { handleExtendedUsers, handleUsers } from "./users";
|
|
6
|
-
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import type { UsersSubscriptionGroupOptions } from "./types";
|
|
7
|
+
export declare class UsersSubscriptionGroup extends SubscriptionGroup<[
|
|
8
|
+
[
|
|
9
|
+
"orgs",
|
|
10
|
+
SubscriptionMapWithSubscription | "map",
|
|
11
|
+
typeof handleOrgs,
|
|
12
|
+
typeof handleOrgsBeforeSubscribe
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"users",
|
|
16
|
+
SubscriptionMapWithSubscription | "map",
|
|
17
|
+
typeof handleUsers
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"user",
|
|
21
|
+
SubscriptionObjectWithSubscription | [true],
|
|
22
|
+
typeof handleUser
|
|
23
|
+
]
|
|
24
|
+
] | [
|
|
25
|
+
[
|
|
26
|
+
"roles",
|
|
27
|
+
"map",
|
|
28
|
+
typeof handleRoles
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"extendedUsers",
|
|
32
|
+
"map",
|
|
33
|
+
"users.extended",
|
|
34
|
+
typeof handleExtendedUsers,
|
|
35
|
+
true
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
"extendedOrgs",
|
|
39
|
+
"map",
|
|
40
|
+
"orgs.extended",
|
|
41
|
+
typeof handleExtendedOrgs,
|
|
42
|
+
true
|
|
43
|
+
]
|
|
44
|
+
]> {
|
|
45
|
+
constructor({ values, ...options }: UsersSubscriptionGroupOptions);
|
|
10
46
|
isExtended: boolean | null;
|
|
11
47
|
extend(): Promise<void> | undefined;
|
|
12
48
|
unextend(): void;
|
|
13
|
-
static handleValues({ orgs, users, user }: {
|
|
14
|
-
orgs: SubscriptionMapWithSubscription;
|
|
15
|
-
users: SubscriptionMapWithSubscription;
|
|
16
|
-
user: SubscriptionObjectWithSubscription;
|
|
17
|
-
}, options: SubscriptionGroupOptions): SubscriptionGroup<((string | typeof handleOrgs | typeof handleOrgsBeforeSubscribe | SubscriptionMapWithSubscription<(Record<string, any> & {
|
|
18
|
-
_id: string;
|
|
19
|
-
}) | import("insite-subscriptions-client/dist/SubscriptionMap").SubscriptionMapItem>)[] | (string | typeof handleUsers | SubscriptionMapWithSubscription<(Record<string, any> & {
|
|
20
|
-
_id: string;
|
|
21
|
-
}) | import("insite-subscriptions-client/dist/SubscriptionMap").SubscriptionMapItem>)[] | (string | typeof handleUser | SubscriptionObjectWithSubscription)[])[]>;
|
|
22
49
|
}
|
|
23
|
-
export {};
|
|
24
50
|
//# sourceMappingURL=UsersSubscriptionGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsersSubscriptionGroup.d.ts","sourceRoot":"","sources":["../src/UsersSubscriptionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK
|
|
1
|
+
{"version":3,"file":"UsersSubscriptionGroup.d.ts","sourceRoot":"","sources":["../src/UsersSubscriptionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAG7D,qBAAa,sBAAuB,SAAQ,iBAAiB,CAAC;IAC7D;QAAE,MAAM;QAAE,+BAA+B,GAAG,KAAK;QAAE,OAAO,UAAU;QAAE,OAAO,yBAAyB;KAAE;IACxG;QAAE,OAAO;QAAE,+BAA+B,GAAG,KAAK;QAAE,OAAO,WAAW;KAAE;IACxE;QAAE,MAAM;QAAE,kCAAkC,GAAG,CAAE,IAAI,CAAE;QAAE,OAAO,UAAU;KAAE;CAC5E,GAAG;IACH;QAAE,OAAO;QAAE,KAAK;QAAE,OAAO,WAAW;KAAE;IACtC;QAAE,eAAe;QAAE,KAAK;QAAE,gBAAgB;QAAE,OAAO,mBAAmB;QAAE,IAAI;KAAE;IAC9E;QAAE,cAAc;QAAE,KAAK;QAAE,eAAe;QAAE,OAAO,kBAAkB;QAAE,IAAI;KAAE;CAC3E,CAAC;gBACW,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,6BAA6B;IAQjE,UAAU,EAAE,OAAO,GAAG,IAAI,CAAS;IAEnC,MAAM;IAiBN,QAAQ;CAUR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export type { NullOrg, Org, OrgExtended, Orgs, OrgsExtended } from "./
|
|
2
|
-
export type { Role, Roles } from "./roles";
|
|
3
|
-
export type { CurrentUser } from "./user";
|
|
4
|
-
export type { User, UserExtended, Users, UsersExtended } from "./users";
|
|
1
|
+
export type { CurrentUser, NullOrg, Org, OrgExtended, Orgs, OrgsExtended, Role, Roles, User, UserExtended, Users, UsersExtended, UsersSubscriptionGroupOptions } from "./types";
|
|
5
2
|
export * from "./UsersSubscriptionGroup";
|
|
6
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAChL,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Object.defineProperty;var v=(e,r,s)=>r in e?S(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s;var u=(e,r,s)=>v(e,typeof r!="symbol"?r+"":r,s);import{SubscriptionGroup as _}from"insite-subscriptions-client";import{getAll as y}from"@nesvet/n";function a(e){e.null={_id:null,title:"",isOrg:!0,users:Object.assign(new Set,{sorted:[]})}}function c(e){if(e)for(let r of e.added)r.isOrg=!0,r.users=Object.assign(new Set,{sorted:[]});else this.values.orgs.null.users.clear(),this.values.orgs.null.users.sorted.length=0}function f(e){let r=this.values.orgs;if(e){let{users:s,extendedOrgs:o}=this.values;for(let l of e){let i=r.get(l._id);i.owners=l.owners.map(d=>s.get(d)||r.get(d)),i.slaveOrgs=y(r,l.slaveOrgs,!0),i.note=l.note,i._l=0}let n=[];for(let l of o.sorted){let i=r.get(l._id);for(let d of i.slaveOrgs)d._l=i._l+1;n.push(i)}r.sortedHierarchically=n,this.isLoaded&&(this.items.users.emitUpdate(),this.items.orgs.emitUpdate(e))}else{for(let s of r.sorted)delete s.owners,delete s.slaveOrgs,delete s.note,delete s._l;delete r.sortedHierarchically}}import{getAll as g}from"@nesvet/n";function h(e){if(e){let r=this.values.roles;for(let s of e)s.ownInvolves=g(r,s.ownInvolves,!0),s.involves=g(r,s.involves,!0),s._l=0;for(let s of r.sorted)for(let o of s.ownInvolves)o._l=s._l+1;this.isLoaded&&this.items.users.emitUpdate(e)}}function U(e){if(e){let r=e.slaveIds.join(",");if(e.slavesSnapshot!==r){e.slavesSnapshot=r;let s=[],o=[],n=[],{users:l,orgs:i}=this.values;for(let d of e.slaveIds){let t=l.get(d);t?(s.push(t),o.push(t)):(t=i.get(d),t&&(s.push(t),n.push(t)))}e.slaves=s,e.slaveUsers=o,e.slaveOrgs=n}}}import{getAll as E,removeOne as m}from"@nesvet/n";function x(e){if(e){let r=this.values.users,s=this.values.user,o=this.values.orgs;r.get(s._id)!==s&&(r.set(s._id,s),r.sorted[r.sorted.findIndex(t=>t._id===s._id)]=s);let n=e.findIndex(t=>t._id===s._id);~n&&(e[n]=s),~e.added.findIndex(t=>t._id===s._id)&&(e.added[n]=s);for(let t of e.added)t.isUser=!0;let i,d=new Set;for(let t of e){let p=o.get(t.orgId)??o.null;t.org!==p&&(t.org&&(t.org.users.delete(t),m(t.org.users.sorted,t)),t.org=p,t.org.users.add(t),t.org.users.sorted.push(t)),d.add(t.org),t===s&&(i=!0)}for(let t of d)t.users.sorted.sort(r.sortCompareFunction);if(e.deleted.length)for(let t of[...o.sorted,o.null])for(let p of t.users)r.has(p._id)||(t.users.delete(p),m(t.users.sorted,p));this.isLoaded&&(i&&this.items.user.emitUpdate(),this.items.orgs.emitUpdate())}}function b(e){let r=this.values.users;if(e){let s=this.values.roles;for(let o of e){let n=r.get(o._id);n.roles=E(s,o.roleIds,!0)}}else for(let s of r.sorted)delete s.roles}var O=class extends _{constructor({values:s,...o}){super([["orgs",s?.orgs??"map",c,a],["users",s?.users??"map",x],["user",s?.user??[!0],U]],o);u(this,"isExtended",!1)}extend(){if(this.isExtended===!1)return this.isExtended=null,this.attach([["roles","map",h],["extendedUsers","map","users.extended",b,!0],["extendedOrgs","map","orgs.extended",f,!0]]).then(()=>{this.isExtended=!0})}unextend(){this.isExtended&&(this.isExtended=!1,this.detach(["roles","extendedUsers","extendedOrgs"]))}};export{O 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
|
-
"sources": ["../src/UsersSubscriptionGroup.ts", "
|
|
4
|
-
"sourcesContent": ["import {\n\tSubscriptionGroup,\n\ttype SubscriptionGroupOptions,\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\";\n\n\nconst basisDefinitions = [\n\t[ \"orgs\", \"map\", handleOrgs, handleOrgsBeforeSubscribe ],\n\t[ \"users\", \"map\", handleUsers ],\n\t[ \"user\", [ true ], handleUser ]\n];\n\nconst extendedDefinitions = [\n\t[ \"roles\", \"map\", handleRoles ],\n\t[ \"extendedUsers\", \"map\", \"users.extended\", handleExtendedUsers, true ],\n\t[ \"extendedOrgs\", \"map\", \"orgs.extended\", handleExtendedOrgs, true ]\n];\n\nexport class UsersSubscriptionGroup extends SubscriptionGroup<typeof basisDefinitions | typeof extendedDefinitions> {\n\tconstructor(options: SubscriptionGroupOptions) {\n\t\tsuper(basisDefinitions, 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(extendedDefinitions).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\t\n\tstatic handleValues({\n\t\torgs,\n\t\tusers,\n\t\tuser\n\t}: {\n\t\torgs: SubscriptionMapWithSubscription;\n\t\tusers: SubscriptionMapWithSubscription;\n\t\tuser: SubscriptionObjectWithSubscription;\n\t}, options: SubscriptionGroupOptions) {\n\t\treturn new SubscriptionGroup([\n\t\t\t[ \"orgs\", orgs, handleOrgs, handleOrgsBeforeSubscribe ],\n\t\t\t[ \"users\", users, handleUsers ],\n\t\t\t[ \"user\", user, handleUser ]\n\t\t], options);\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\ntype Options = {\n\tsignal?: AbortSignal;\n\ttimeout?: number;\n};\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(\n\t\texecutor?: (resolve: Resolve<T>, reject: Reject) => void,\n\t\toptions?: Options\n\t) {\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\tif (options?.signal)\n\t\t\tif (options.signal.aborted)\n\t\t\t\tthis.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\telse {\n\t\t\t\tconst abortListener = () => this.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\t\t\n\t\t\t\toptions.signal.addEventListener(\"abort\", abortListener);\n\t\t\t\t\n\t\t\t\tthis.finally(() => options.signal?.removeEventListener(\"abort\", abortListener));\n\t\t\t}\n\t\t\n\t\tif (typeof options?.timeout === \"number\" && Number.isFinite(options.timeout)) {\n\t\t\tconst timeout = setTimeout(() => this.reject(new DOMException(\"Timeout exceeded\", \"TimeoutError\")), options.timeout);\n\t\t\t\n\t\t\tthis.finally(() => clearTimeout(timeout));\n\t\t}\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: T | unknown;\n\t\n\treadonly resolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treadonly reject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\t\n\tstatic resolved<U>(value: U): StatefulPromise<U> {\n\t\treturn new StatefulPromise<U>(resolve => resolve(value));\n\t}\n\t\n\tstatic rejected(reason: unknown): StatefulPromise<never> {\n\t\treturn new StatefulPromise((_, reject) => reject(reason));\n\t}\n\t\n}\n", "import { noop } from \"./noop.js\";\nimport { StatefulPromise } from \"./StatefulPromise.js\";\n\n\ntype Callback = (...args: any[]) => unknown;// eslint-disable-line @typescript-eslint/no-explicit-any\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\n\ntype DebouncedFunction<C extends Callback> = {\n\t(this: ThisParameterType<C>, ...args: Parameters<C>): Promise<Awaited<ReturnType<C>>>;\n};\n\nexport type Debounced<C extends Callback, R extends ReturnType<C>> = DebouncedFunction<C> & {\n\tcallback: C;\n\tpromise: StatefulPromise<R>;\n\tresolve: (value: R) => void;\n\treject: (reason?: unknown) => void;\n\trun(): Promise<R>;\n\tclear(shouldRun?: boolean): Promise<void>;\n};\n\n\nexport function debounce<C extends Callback, R extends ReturnType<C>>(callback: C, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet maxWaitTimeout: ReturnType<typeof setTimeout> | undefined;\n\tlet end: number | undefined;\n\tlet context: ThisParameterType<C>;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: R;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\t\n\t\t\tdebounced.resolve(result);\n\t\t\t\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\t\n\t\trun();\n\t\t\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\ttry {\n\t\t\tresult = await callback.apply(context, args) as R;\n\t\t\t\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tdebounced.reject(error);\n\t\t\t\n\t\t\tthrow error;\n\t\t}\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<C, R> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (!debounced.promise.isPending)\n\t\t\tdebounced.promise = new StatefulPromise<R>((resolve, reject) => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\tdebounced.reject = reject;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\t\n\t\t\t\t\tinitial = false;\n\t\t\t\t\t\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\t\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<C>, {\n\t\tcallback,\n\t\tpromise: StatefulPromise.resolved(undefined as unknown as R),\n\t\tresolve: noop,\n\t\treject: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: StatefulPromise.resolved(undefined), // eslint-disable-line unicorn/no-useless-undefined\n\tresolve: noop,\n\treject: noop,\n\trun: noop,\n\tclear: noop\n}) as Debounced<() => void, void>;\n\n\nexport function throttle(callback: Callback, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nexport function getAll<V>(map: Map<any, V>, keys: any[], onlyExisting: true): V[];\nexport function getAll<V>(map: Map<any, V>, keys: any[], onlyExisting?: false): (V | undefined)[];\nexport function getAll<V>(map: Map<any, V>, keys: any[], onlyExisting = false) {\n\t\n\tconst items = [];\n\t\n\tif (onlyExisting)\n\t\tfor (const key of keys) {\n\t\t\tconst item = map.get(key);\n\t\t\tif (item !== undefined)\n\t\t\t\titems.push(item);\n\t\t}\n\telse\n\t\tfor (const key of keys)\n\t\t\titems.push(map.get(key));\n\t\n\treturn items;\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function removeOne<T>(array: T[], item: T): boolean {\n\tconst i = array.indexOf(item);\n\tif (i > -1) {\n\t\tarray.splice(i, 1);\n\t\t\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\n", "import { getAll } from \"@nesvet/n\";\nimport type { SubscriptionMapUpdated, SubscriptionMapWithSubscription } from \"insite-subscriptions-client\";\nimport type { User } from \"./users\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport type Org = {\n\t_id: string;\n\ttitle: string;\n\tisOrg: true;\n\tusers: Set<User> & { sorted: User[] };\n};\n\nexport type NullOrg = Omit<Org, \"_id\"> & { _id: null };\n\ntype OrgExtension = {\n\t_id: string;\n\towners: string[];\n\tslaveOrgs: string[];\n\tnote: string;\n};\n\nexport type OrgExtended = Org & {\n\towners?: (OrgExtended | User)[];\n\tslaveOrgs?: OrgExtended[];\n\tnote?: string;\n\t_l?: number;\n};\n\ntype OrgsExtra = {\n\tnull: NullOrg;\n};\n\nexport type Orgs = OrgsExtra & SubscriptionMapWithSubscription<Org>;\n\nexport type OrgsExtended = OrgsExtra & SubscriptionMapWithSubscription<OrgExtended> & {\n\tsortedHierarchically?: OrgExtended[];\n};\n\n\nexport function handleOrgsBeforeSubscribe(orgs: Orgs) {\n\torgs.null = {\n\t\t_id: null,\n\t\ttitle: \"\",\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, SubscriptionMapWithSubscription } from \"insite-subscriptions-client\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport type Role = {\n\t_id: string;\n\townInvolves: Role[];\n\tinvolves: Role[];\n\t_l: number;\n};\n\nexport type Roles = SubscriptionMapWithSubscription<Role>;\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 { Abilities, AbilitiesSchema } from \"insite-common\";\nimport type { Org } from \"./orgs\";\nimport type { User, UserExtended } from \"./users\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport type CurrentUser<AS extends AbilitiesSchema = AbilitiesSchema> = UserExtended & {\n\tabilities: Abilities<AS>;\n\tsessionId?: string;\n\tslaveIds: string[];\n\tslavesSnapshot: string;\n\tslaves: (Org | User)[];\n\tslaveUsers: User[];\n\tslaveOrgs: Org[];\n};\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, SubscriptionMapWithSubscription } from \"insite-subscriptions-client\";\nimport type { NullOrg, Org, Orgs } from \"./orgs\";\nimport type { Role, Roles } from \"./roles\";\nimport type { CurrentUser } from \"./user\";\nimport type { UsersSubscriptionGroup } from \"./UsersSubscriptionGroup\";\n\n\nexport type User = {\n\t_id: string;\n\tisUser: true;\n\temail: string;\n\tname: {\n\t\tfirst: string;\n\t\tmiddle: string;\n\t\tlast: string;\n\t};\n\torgId: string;\n\tjob: string;\n\tinitials: string;\n\tdisplayLabel: string;\n\tavatarUrl: string;\n\tisOnline: boolean;\n\torg: NullOrg | Org;\n};\n\ntype UserExtension = {\n\t_id: string;\n\troleIds: string[];\n};\n\nexport type UserExtended = User & {\n\troles?: Role[];\n};\n\nexport type Users = SubscriptionMapWithSubscription<User>;\n\nexport type UsersExtended = SubscriptionMapWithSubscription<UserExtended>;\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[updatedUserIndex] = 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": "oKAAA,OACC,qBAAAA,
|
|
6
|
-
"names": ["SubscriptionGroup", "
|
|
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\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[updatedUserIndex] = 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": "oKAAA,OACC,qBAAAA,MAGM,8BCJP,OAAS,UAAAC,MAAc,YAYhB,SAASC,EAA0BC,EAAY,CACrDA,EAAK,KAAO,CACX,IAAK,KACL,MAAO,GACP,MAAO,GACP,MAAO,OAAO,OAAO,IAAI,IAAa,CAAE,OAAQ,CAAC,CAAE,CAAC,CACrD,CAED,CAGO,SAASC,EAAyCC,EAA6C,CACrG,GAAIA,EACH,QAAWC,KAAOD,EAAQ,MACzBC,EAAI,MAAQ,GAEZA,EAAI,MAAQ,OAAO,OAAO,IAAI,IAAa,CAAE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AN,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,EAGXK,EAAA,kBAA6B,GAF7B,CAIA,QAAS,CAER,GAAI,KAAK,aAAe,GACvB,YAAK,WAAa,KAEX,KAAK,OAAO,CAClB,CAAE,QAAS,MAAOC,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", "shouldUpdateUser", "orgsToSortUsers", "org", "handleExtendedUsers", "roles", "userExtension", "UsersSubscriptionGroup", "SubscriptionGroup", "values", "options", "handleOrgs", "handleOrgsBeforeSubscribe", "handleUsers", "handleUser", "__publicField", "handleRoles", "handleExtendedUsers", "handleExtendedOrgs"]
|
|
7
7
|
}
|
package/dist/orgs.d.ts
CHANGED
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
import type { SubscriptionMapUpdated
|
|
2
|
-
import type {
|
|
1
|
+
import type { SubscriptionMapUpdated } from "insite-subscriptions-client";
|
|
2
|
+
import type { Org, OrgExtension, Orgs } from "./types";
|
|
3
3
|
import type { UsersSubscriptionGroup } from "./UsersSubscriptionGroup";
|
|
4
|
-
export type Org = {
|
|
5
|
-
_id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
isOrg: true;
|
|
8
|
-
users: Set<User> & {
|
|
9
|
-
sorted: User[];
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export type NullOrg = Omit<Org, "_id"> & {
|
|
13
|
-
_id: null;
|
|
14
|
-
};
|
|
15
|
-
type OrgExtension = {
|
|
16
|
-
_id: string;
|
|
17
|
-
owners: string[];
|
|
18
|
-
slaveOrgs: string[];
|
|
19
|
-
note: string;
|
|
20
|
-
};
|
|
21
|
-
export type OrgExtended = Org & {
|
|
22
|
-
owners?: (OrgExtended | User)[];
|
|
23
|
-
slaveOrgs?: OrgExtended[];
|
|
24
|
-
note?: string;
|
|
25
|
-
_l?: number;
|
|
26
|
-
};
|
|
27
|
-
type OrgsExtra = {
|
|
28
|
-
null: NullOrg;
|
|
29
|
-
};
|
|
30
|
-
export type Orgs = OrgsExtra & SubscriptionMapWithSubscription<Org>;
|
|
31
|
-
export type OrgsExtended = OrgsExtra & SubscriptionMapWithSubscription<OrgExtended> & {
|
|
32
|
-
sortedHierarchically?: OrgExtended[];
|
|
33
|
-
};
|
|
34
4
|
export declare function handleOrgsBeforeSubscribe(orgs: Orgs): void;
|
|
35
5
|
/** @this UsersSubscriptionGroup */
|
|
36
6
|
export declare function handleOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Org> | null): void;
|
|
37
7
|
/** @this UsersSubscriptionGroup */
|
|
38
8
|
export declare function handleExtendedOrgs(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<OrgExtension> | null): void;
|
|
39
|
-
export {};
|
|
40
9
|
//# sourceMappingURL=orgs.d.ts.map
|
package/dist/orgs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orgs.d.ts","sourceRoot":"","sources":["../src/orgs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE
|
|
1
|
+
{"version":3,"file":"orgs.d.ts","sourceRoot":"","sources":["../src/orgs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EACX,GAAG,EACH,YAAY,EACZ,IAAI,EAGJ,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,QAQnD;AAED,mCAAmC;AACnC,wBAAgB,UAAU,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAAC,GAAG,CAAC,GAAG,IAAI,QAYnG;AAED,mCAAmC;AACnC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,IAAI,QA2CpH"}
|
package/dist/roles.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type { SubscriptionMapUpdated
|
|
1
|
+
import type { SubscriptionMapUpdated } from "insite-subscriptions-client";
|
|
2
|
+
import type { Role } from "./types";
|
|
2
3
|
import type { UsersSubscriptionGroup } from "./UsersSubscriptionGroup";
|
|
3
|
-
export type Role = {
|
|
4
|
-
_id: string;
|
|
5
|
-
ownInvolves: Role[];
|
|
6
|
-
involves: Role[];
|
|
7
|
-
_l: number;
|
|
8
|
-
};
|
|
9
|
-
export type Roles = SubscriptionMapWithSubscription<Role>;
|
|
10
4
|
/** @this UsersSubscriptionGroup */
|
|
11
5
|
export declare function handleRoles(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<Role> | null): void;
|
|
12
6
|
//# sourceMappingURL=roles.d.ts.map
|
package/dist/roles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC,GAAG,IAAI,QAkBrG"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Abilities, AbilitiesSchema } from "insite-common";
|
|
2
|
+
import type { SubscriptionGroupOptions, SubscriptionMapWithSubscription, SubscriptionObjectWithSubscription } from "insite-subscriptions-client";
|
|
3
|
+
export type UsersSubscriptionGroupOptions = SubscriptionGroupOptions & {
|
|
4
|
+
values?: {
|
|
5
|
+
orgs: SubscriptionMapWithSubscription;
|
|
6
|
+
users: SubscriptionMapWithSubscription;
|
|
7
|
+
user: SubscriptionObjectWithSubscription;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type Org = {
|
|
11
|
+
_id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
isOrg: true;
|
|
14
|
+
users: Set<User> & {
|
|
15
|
+
sorted: User[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type NullOrg = Omit<Org, "_id"> & {
|
|
19
|
+
_id: null;
|
|
20
|
+
};
|
|
21
|
+
export type OrgExtension = {
|
|
22
|
+
_id: string;
|
|
23
|
+
owners: string[];
|
|
24
|
+
slaveOrgs: string[];
|
|
25
|
+
note: string;
|
|
26
|
+
};
|
|
27
|
+
export type OrgExtended = Org & {
|
|
28
|
+
owners?: (OrgExtended | User)[];
|
|
29
|
+
slaveOrgs?: OrgExtended[];
|
|
30
|
+
note?: string;
|
|
31
|
+
_l?: number;
|
|
32
|
+
};
|
|
33
|
+
type OrgsExtra = {
|
|
34
|
+
null: NullOrg;
|
|
35
|
+
};
|
|
36
|
+
export type Orgs = OrgsExtra & SubscriptionMapWithSubscription<Org>;
|
|
37
|
+
export type OrgsExtended = OrgsExtra & SubscriptionMapWithSubscription<OrgExtended> & {
|
|
38
|
+
sortedHierarchically?: OrgExtended[];
|
|
39
|
+
};
|
|
40
|
+
export type Role = {
|
|
41
|
+
_id: string;
|
|
42
|
+
ownInvolves: Role[];
|
|
43
|
+
involves: Role[];
|
|
44
|
+
_l: number;
|
|
45
|
+
};
|
|
46
|
+
export type Roles = SubscriptionMapWithSubscription<Role>;
|
|
47
|
+
export type CurrentUser<AS extends AbilitiesSchema = AbilitiesSchema> = UserExtended & {
|
|
48
|
+
abilities: Abilities<AS>;
|
|
49
|
+
sessionId?: string;
|
|
50
|
+
slaveIds: string[];
|
|
51
|
+
slavesSnapshot: string;
|
|
52
|
+
slaves: (Org | User)[];
|
|
53
|
+
slaveUsers: User[];
|
|
54
|
+
slaveOrgs: Org[];
|
|
55
|
+
};
|
|
56
|
+
export type User = {
|
|
57
|
+
_id: string;
|
|
58
|
+
isUser: true;
|
|
59
|
+
email: string;
|
|
60
|
+
name: {
|
|
61
|
+
first: string;
|
|
62
|
+
middle: string;
|
|
63
|
+
last: string;
|
|
64
|
+
};
|
|
65
|
+
orgId: string;
|
|
66
|
+
job: string;
|
|
67
|
+
initials: string;
|
|
68
|
+
displayLabel: string;
|
|
69
|
+
avatarUrl: string;
|
|
70
|
+
isOnline: boolean;
|
|
71
|
+
org: NullOrg | Org;
|
|
72
|
+
};
|
|
73
|
+
export type UserExtension = {
|
|
74
|
+
_id: string;
|
|
75
|
+
roleIds: string[];
|
|
76
|
+
};
|
|
77
|
+
export type UserExtended = User & {
|
|
78
|
+
roles?: Role[];
|
|
79
|
+
};
|
|
80
|
+
export type Users = SubscriptionMapWithSubscription<User>;
|
|
81
|
+
export type UsersExtended = SubscriptionMapWithSubscription<UserExtended>;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,KAAK,EACX,wBAAwB,EACxB,+BAA+B,EAC/B,kCAAkC,EAClC,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,GAAG;IACtE,MAAM,CAAC,EAAE;QACR,IAAI,EAAE,+BAA+B,CAAC;QACtC,KAAK,EAAE,+BAA+B,CAAC;QACvC,IAAI,EAAE,kCAAkC,CAAC;KACzC,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG;QAAE,MAAM,EAAE,IAAI,EAAE,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM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,IAAI,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,GAAG,EAAE,OAAO,GAAG,GAAG,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG;IACjC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG,+BAA+B,CAAC,YAAY,CAAC,CAAC"}
|
package/dist/user.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Org } from "./orgs";
|
|
3
|
-
import type { User, UserExtended } from "./users";
|
|
1
|
+
import type { CurrentUser } from "./types";
|
|
4
2
|
import type { UsersSubscriptionGroup } from "./UsersSubscriptionGroup";
|
|
5
|
-
export type CurrentUser<AS extends AbilitiesSchema = AbilitiesSchema> = UserExtended & {
|
|
6
|
-
abilities: Abilities<AS>;
|
|
7
|
-
sessionId?: string;
|
|
8
|
-
slaveIds: string[];
|
|
9
|
-
slavesSnapshot: string;
|
|
10
|
-
slaves: (Org | User)[];
|
|
11
|
-
slaveUsers: User[];
|
|
12
|
-
slaveOrgs: Org[];
|
|
13
|
-
};
|
|
14
3
|
/** @this UsersSubscriptionGroup */
|
|
15
4
|
export declare function handleUser(this: UsersSubscriptionGroup, user: CurrentUser): void;
|
|
16
5
|
//# sourceMappingURL=user.d.ts.map
|
package/dist/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../src/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,mCAAmC;AACnC,wBAAgB,UAAU,CAAC,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,WAAW,QAkCzE"}
|
package/dist/users.d.ts
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
import type { SubscriptionMapUpdated
|
|
2
|
-
import type {
|
|
3
|
-
import type { Role } from "./roles";
|
|
1
|
+
import type { SubscriptionMapUpdated } from "insite-subscriptions-client";
|
|
2
|
+
import type { User, UserExtension } from "./types";
|
|
4
3
|
import type { UsersSubscriptionGroup } from "./UsersSubscriptionGroup";
|
|
5
|
-
export type User = {
|
|
6
|
-
_id: string;
|
|
7
|
-
isUser: true;
|
|
8
|
-
email: string;
|
|
9
|
-
name: {
|
|
10
|
-
first: string;
|
|
11
|
-
middle: string;
|
|
12
|
-
last: string;
|
|
13
|
-
};
|
|
14
|
-
orgId: string;
|
|
15
|
-
job: string;
|
|
16
|
-
initials: string;
|
|
17
|
-
displayLabel: string;
|
|
18
|
-
avatarUrl: string;
|
|
19
|
-
isOnline: boolean;
|
|
20
|
-
org: NullOrg | Org;
|
|
21
|
-
};
|
|
22
|
-
type UserExtension = {
|
|
23
|
-
_id: string;
|
|
24
|
-
roleIds: string[];
|
|
25
|
-
};
|
|
26
|
-
export type UserExtended = User & {
|
|
27
|
-
roles?: Role[];
|
|
28
|
-
};
|
|
29
|
-
export type Users = SubscriptionMapWithSubscription<User>;
|
|
30
|
-
export type UsersExtended = SubscriptionMapWithSubscription<UserExtended>;
|
|
31
4
|
/** @this UsersSubscriptionGroup */
|
|
32
5
|
export declare function handleUsers(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<User> | null): void;
|
|
33
6
|
/** @this UsersSubscriptionGroup */
|
|
34
7
|
export declare function handleExtendedUsers(this: UsersSubscriptionGroup, updated: SubscriptionMapUpdated<UserExtension> | null): void;
|
|
35
|
-
export {};
|
|
36
8
|
//# sourceMappingURL=users.d.ts.map
|
package/dist/users.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EAMX,IAAI,EACJ,aAAa,EAGb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGvE,mCAAmC;AACnC,wBAAgB,WAAW,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAAC,IAAI,CAAC,GAAG,IAAI,QA+DrG;AAED,mCAAmC;AACnC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,CAAC,aAAa,CAAC,GAAG,IAAI,QAgBtH"}
|