@memberjunction/generic-database-provider 6.2.0-edge.3 → 6.2.0-edge.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/dist/GenericDatabaseProvider.d.ts +153 -35
- package/dist/GenericDatabaseProvider.d.ts.map +1 -1
- package/dist/GenericDatabaseProvider.js +341 -87
- package/dist/GenericDatabaseProvider.js.map +1 -1
- package/dist/SqlLogger.js +2 -2
- package/dist/SqlLogger.js.map +1 -1
- package/dist/TransactionAffinity.d.ts +73 -0
- package/dist/TransactionAffinity.d.ts.map +1 -0
- package/dist/TransactionAffinity.js +120 -0
- package/dist/TransactionAffinity.js.map +1 -0
- package/dist/UserCache.d.ts +277 -11
- package/dist/UserCache.d.ts.map +1 -1
- package/dist/UserCache.js +610 -23
- package/dist/UserCache.js.map +1 -1
- package/dist/queryPagingEngine.d.ts +41 -3
- package/dist/queryPagingEngine.d.ts.map +1 -1
- package/dist/queryPagingEngine.js +99 -15
- package/dist/queryPagingEngine.js.map +1 -1
- package/package.json +14 -14
package/dist/SqlLogger.js
CHANGED
|
@@ -118,8 +118,8 @@ export class SqlLoggingSessionImpl {
|
|
|
118
118
|
if (this.options.logRecordChangeMetadata !== true && simpleSQLFallback) {
|
|
119
119
|
processedQuery = simpleSQLFallback;
|
|
120
120
|
// Tag the description only when the logged text actually differs from what ran.
|
|
121
|
-
// A save on an entity without record-change tracking
|
|
122
|
-
// byte-identical to the executed SQL (
|
|
121
|
+
// A save on an entity without record-change tracking can hand over a fallback that is
|
|
122
|
+
// byte-identical to the executed SQL (a forced update), and tagging that would misreport it.
|
|
123
123
|
if (description && simpleSQLFallback !== query && !description.includes('(core SP call only)')) {
|
|
124
124
|
logEntry = logEntry.replace(`-- ${description}\n`, `-- ${description} (core SP call only)\n`);
|
|
125
125
|
}
|
package/dist/SqlLogger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlLogger.js","sourceRoot":"","sources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AAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;wBACvD,MAAM,IAAI,CAAC,CAAC,CAAC,yBAAyB;oBACxC,CAAC;yBAAM,CAAC;wBACN,MAAM,IAAI,CAAC,CAAC,CAAC,4BAA4B;wBACzC,MAAM;oBACR,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,MAAM,EAAE,CAAC;gBACX,CAAC;YACH,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9E,UAAU,GAAG,MAAM,CAAC;QACtB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;OAQG;IACK,0BAA0B,CAAC,GAAW;QAC5C,OAAO,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACK,4BAA4B,CAAC,GAAW;QAC9C,0DAA0D;QAC1D,kGAAkG;QAClG,6FAA6F;QAC7F,MAAM,YAAY,GAChB,qPAAqP,CAAC;QACxP,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC/C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACK,4BAA4B,CAAC,GAAW;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,+BAA+B,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;CAEF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One logical caller's claim on one provider's ambient transaction. `Epoch` is null while the begin
|
|
3
|
+
* that created it is still in flight, names the transaction once that begin succeeds, and is
|
|
4
|
+
* {@link RELEASED_EPOCH} once a begin that never bound it failed.
|
|
5
|
+
*/
|
|
6
|
+
export interface TransactionMembership {
|
|
7
|
+
readonly Owner: TransactionAffinity;
|
|
8
|
+
Epoch: number | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Which async scope a provider's ambient transaction belongs to (#4786).
|
|
12
|
+
*
|
|
13
|
+
* A provider instance is shared — the global `Metadata.Provider` most of all — so "a transaction is
|
|
14
|
+
* open on this instance" does not mean "this caller is part of it". Routing every query to the open
|
|
15
|
+
* handle captured unrelated callers: their reads ran inside someone else's transaction, their writes
|
|
16
|
+
* were rolled back with it, and reads queued behind its COMMIT failed. Membership is therefore carried
|
|
17
|
+
* by the async context of the code that began the transaction — descendants inherit it, everything
|
|
18
|
+
* else runs on the pool.
|
|
19
|
+
*
|
|
20
|
+
* The transaction is identified by an epoch that is replaced on every outermost begin and cleared when
|
|
21
|
+
* the transaction ends, so a membership outlives its transaction harmlessly: it simply stops matching.
|
|
22
|
+
*
|
|
23
|
+
* Limits: `Claim()` must run in the synchronous prefix of the call the caller awaits — a begin reached
|
|
24
|
+
* after an `await` inside a helper does not make the helper's caller a member. Conversely, a claim
|
|
25
|
+
* in the synchronous prefix of work the caller does NOT await (a fire-and-forget call, a synchronous
|
|
26
|
+
* event listener) lands in the caller's context too, making the launcher (the emitter) a member.
|
|
27
|
+
* Work the provider launches itself runs under {@link RunDetached}, which contains it.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TransactionAffinity {
|
|
30
|
+
private _epoch;
|
|
31
|
+
private _lastEpoch;
|
|
32
|
+
/** The open transaction's epoch, or null when none is open. */
|
|
33
|
+
get CurrentEpoch(): number | null;
|
|
34
|
+
/** True when the current async context began, or descends from the scope that began, the open transaction. */
|
|
35
|
+
get IsCallerMember(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The calling scope's membership, creating one if it has none that is pending or current. MUST be
|
|
38
|
+
* called synchronously before the begin's first `await`: `enterWith` in the synchronous prefix of an
|
|
39
|
+
* awaited call is what makes the membership visible to the caller once its `await` resumes.
|
|
40
|
+
*/
|
|
41
|
+
Claim(): TransactionMembership;
|
|
42
|
+
/** An outermost physical BEGIN succeeded: a new transaction that no existing membership belongs to. */
|
|
43
|
+
OpenEpoch(): void;
|
|
44
|
+
/** The transaction ended — committed, rolled back or abandoned — so every membership in it is stale. */
|
|
45
|
+
CloseEpoch(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Make a claimed membership part of the open transaction (as its opener, or joining it). A begin
|
|
48
|
+
* that claimed the same pending membership before another begin released it (two begins queued
|
|
49
|
+
* from one scope) still binds it: that scope did ask for a transaction.
|
|
50
|
+
*/
|
|
51
|
+
Bind(membership: TransactionMembership): void;
|
|
52
|
+
/**
|
|
53
|
+
* A begin failed: kill the claim it made if nothing bound it. A pending membership is shared by
|
|
54
|
+
* reference with everything the claiming scope forked since the claim (pollers, timers), so left
|
|
55
|
+
* pending it would be reused by that scope's next begin and retroactively make all of that work
|
|
56
|
+
* part of a transaction it never asked for. A membership already bound to the open transaction
|
|
57
|
+
* is left alone: a member whose nested begin failed is still a member.
|
|
58
|
+
*/
|
|
59
|
+
Release(membership: TransactionMembership): void;
|
|
60
|
+
/**
|
|
61
|
+
* Run `fn` as a member of the open transaction whatever scope called it. For the provider's own
|
|
62
|
+
* transaction-control SQL (savepoints), which may legitimately be issued from another scope — a
|
|
63
|
+
* pool that settles graphs after `Promise.all`, `ReleaseIndependentInstance` — and must still reach
|
|
64
|
+
* the handle.
|
|
65
|
+
*/
|
|
66
|
+
RunAsMember<T>(fn: () => Promise<T>): Promise<T>;
|
|
67
|
+
/** Run `fn` with no membership on this owner — work that must not ride the caller's transaction. */
|
|
68
|
+
RunDetached<T>(fn: () => Promise<T>): Promise<T>;
|
|
69
|
+
private assertOwned;
|
|
70
|
+
private findMembership;
|
|
71
|
+
private otherOwnersMemberships;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=TransactionAffinity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionAffinity.d.ts","sourceRoot":"","sources":["../src/TransactionAffinity.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAeD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,UAAU,CAAK;IAEvB,+DAA+D;IAC/D,IAAW,YAAY,IAAI,MAAM,GAAG,IAAI,CAEvC;IAED,8GAA8G;IAC9G,IAAW,cAAc,IAAI,OAAO,CAEnC;IAED;;;;OAIG;IACI,KAAK,IAAI,qBAAqB;IAUrC,uGAAuG;IAChG,SAAS,IAAI,IAAI;IAIxB,wGAAwG;IACjG,UAAU,IAAI,IAAI;IAIzB;;;;OAIG;IACI,IAAI,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAQpD;;;;;;OAMG;IACI,OAAO,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAOvD;;;;;OAKG;IACI,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAOvD,oGAAoG;IAC7F,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIvD,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,sBAAsB;CAGjC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Epoch of a claim whose begin failed. Real epochs start at 1 and the open epoch is never 0, so a
|
|
4
|
+
* released membership matches no transaction and `Claim()` never reuses it.
|
|
5
|
+
*/
|
|
6
|
+
const RELEASED_EPOCH = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Process-wide, keyed by owner inside the store: an async context can be inside transactions on
|
|
9
|
+
* several providers at once (a per-request provider and the global one), and one AsyncLocalStorage
|
|
10
|
+
* per provider instance would be one per GraphQL request.
|
|
11
|
+
*/
|
|
12
|
+
const memberships = new AsyncLocalStorage();
|
|
13
|
+
/**
|
|
14
|
+
* Which async scope a provider's ambient transaction belongs to (#4786).
|
|
15
|
+
*
|
|
16
|
+
* A provider instance is shared — the global `Metadata.Provider` most of all — so "a transaction is
|
|
17
|
+
* open on this instance" does not mean "this caller is part of it". Routing every query to the open
|
|
18
|
+
* handle captured unrelated callers: their reads ran inside someone else's transaction, their writes
|
|
19
|
+
* were rolled back with it, and reads queued behind its COMMIT failed. Membership is therefore carried
|
|
20
|
+
* by the async context of the code that began the transaction — descendants inherit it, everything
|
|
21
|
+
* else runs on the pool.
|
|
22
|
+
*
|
|
23
|
+
* The transaction is identified by an epoch that is replaced on every outermost begin and cleared when
|
|
24
|
+
* the transaction ends, so a membership outlives its transaction harmlessly: it simply stops matching.
|
|
25
|
+
*
|
|
26
|
+
* Limits: `Claim()` must run in the synchronous prefix of the call the caller awaits — a begin reached
|
|
27
|
+
* after an `await` inside a helper does not make the helper's caller a member. Conversely, a claim
|
|
28
|
+
* in the synchronous prefix of work the caller does NOT await (a fire-and-forget call, a synchronous
|
|
29
|
+
* event listener) lands in the caller's context too, making the launcher (the emitter) a member.
|
|
30
|
+
* Work the provider launches itself runs under {@link RunDetached}, which contains it.
|
|
31
|
+
*/
|
|
32
|
+
export class TransactionAffinity {
|
|
33
|
+
constructor() {
|
|
34
|
+
this._epoch = null;
|
|
35
|
+
this._lastEpoch = 0;
|
|
36
|
+
}
|
|
37
|
+
/** The open transaction's epoch, or null when none is open. */
|
|
38
|
+
get CurrentEpoch() {
|
|
39
|
+
return this._epoch;
|
|
40
|
+
}
|
|
41
|
+
/** True when the current async context began, or descends from the scope that began, the open transaction. */
|
|
42
|
+
get IsCallerMember() {
|
|
43
|
+
return this._epoch !== null && this.findMembership()?.Epoch === this._epoch;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The calling scope's membership, creating one if it has none that is pending or current. MUST be
|
|
47
|
+
* called synchronously before the begin's first `await`: `enterWith` in the synchronous prefix of an
|
|
48
|
+
* awaited call is what makes the membership visible to the caller once its `await` resumes.
|
|
49
|
+
*/
|
|
50
|
+
Claim() {
|
|
51
|
+
const existing = this.findMembership();
|
|
52
|
+
if (existing && (existing.Epoch === null || existing.Epoch === this._epoch)) {
|
|
53
|
+
return existing;
|
|
54
|
+
}
|
|
55
|
+
const fresh = { Owner: this, Epoch: null };
|
|
56
|
+
memberships.enterWith([...this.otherOwnersMemberships(), fresh]);
|
|
57
|
+
return fresh;
|
|
58
|
+
}
|
|
59
|
+
/** An outermost physical BEGIN succeeded: a new transaction that no existing membership belongs to. */
|
|
60
|
+
OpenEpoch() {
|
|
61
|
+
this._epoch = ++this._lastEpoch;
|
|
62
|
+
}
|
|
63
|
+
/** The transaction ended — committed, rolled back or abandoned — so every membership in it is stale. */
|
|
64
|
+
CloseEpoch() {
|
|
65
|
+
this._epoch = null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Make a claimed membership part of the open transaction (as its opener, or joining it). A begin
|
|
69
|
+
* that claimed the same pending membership before another begin released it (two begins queued
|
|
70
|
+
* from one scope) still binds it: that scope did ask for a transaction.
|
|
71
|
+
*/
|
|
72
|
+
Bind(membership) {
|
|
73
|
+
this.assertOwned(membership, 'Bind');
|
|
74
|
+
if (this._epoch === null) {
|
|
75
|
+
throw new Error('TransactionAffinity.Bind: there is no open transaction to bind the membership to');
|
|
76
|
+
}
|
|
77
|
+
membership.Epoch = this._epoch;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A begin failed: kill the claim it made if nothing bound it. A pending membership is shared by
|
|
81
|
+
* reference with everything the claiming scope forked since the claim (pollers, timers), so left
|
|
82
|
+
* pending it would be reused by that scope's next begin and retroactively make all of that work
|
|
83
|
+
* part of a transaction it never asked for. A membership already bound to the open transaction
|
|
84
|
+
* is left alone: a member whose nested begin failed is still a member.
|
|
85
|
+
*/
|
|
86
|
+
Release(membership) {
|
|
87
|
+
this.assertOwned(membership, 'Release');
|
|
88
|
+
if (membership.Epoch === null) {
|
|
89
|
+
membership.Epoch = RELEASED_EPOCH;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Run `fn` as a member of the open transaction whatever scope called it. For the provider's own
|
|
94
|
+
* transaction-control SQL (savepoints), which may legitimately be issued from another scope — a
|
|
95
|
+
* pool that settles graphs after `Promise.all`, `ReleaseIndependentInstance` — and must still reach
|
|
96
|
+
* the handle.
|
|
97
|
+
*/
|
|
98
|
+
RunAsMember(fn) {
|
|
99
|
+
if (this._epoch === null) {
|
|
100
|
+
return fn();
|
|
101
|
+
}
|
|
102
|
+
return memberships.run([...this.otherOwnersMemberships(), { Owner: this, Epoch: this._epoch }], fn);
|
|
103
|
+
}
|
|
104
|
+
/** Run `fn` with no membership on this owner — work that must not ride the caller's transaction. */
|
|
105
|
+
RunDetached(fn) {
|
|
106
|
+
return memberships.run(this.otherOwnersMemberships(), fn);
|
|
107
|
+
}
|
|
108
|
+
assertOwned(membership, operation) {
|
|
109
|
+
if (membership.Owner !== this) {
|
|
110
|
+
throw new Error(`TransactionAffinity.${operation}: the membership was claimed on another TransactionAffinity`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
findMembership() {
|
|
114
|
+
return memberships.getStore()?.find((m) => m.Owner === this);
|
|
115
|
+
}
|
|
116
|
+
otherOwnersMemberships() {
|
|
117
|
+
return (memberships.getStore() ?? []).filter((m) => m.Owner !== this);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=TransactionAffinity.js.map
|
|
@@ -0,0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O,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IACjE,CAAC;IAEO,sBAAsB;QAC1B,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;IAC1E,CAAC;CACJ"}
|
package/dist/UserCache.d.ts
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import { UserInfo, type DatabaseProviderBase } from '@memberjunction/core';
|
|
2
2
|
import { BaseSingleton } from '@memberjunction/global';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Key this cache writes to the shared store to tell other processes that users changed. It lives in
|
|
5
|
+
* the default category, which MJAPI publishes as a key-only notice (see `MJServer/src/sharedCache.ts`),
|
|
6
|
+
* so a change costs one small message per server rather than a payload.
|
|
7
|
+
*/
|
|
8
|
+
export declare const USER_CACHE_STAMP_KEY = "__MJ_UserCache_Stamp__";
|
|
9
|
+
/**
|
|
10
|
+
* Server-side cache of users and their roles, shared by every consumer in the process.
|
|
5
11
|
*
|
|
6
12
|
* Dialect-neutral: {@link UserCache.Refresh} takes a {@link DatabaseProviderBase} and reads through
|
|
7
|
-
* `ExecuteSQL` / `QuoteSchemaAndView`, so SQL Server and PostgreSQL
|
|
8
|
-
* implementation rather than each hand-rolling a `vwUsers` + `vwUserRoles` load.
|
|
13
|
+
* `ExecuteSQL` / `QuoteSchemaAndView`, so SQL Server and PostgreSQL share one implementation.
|
|
9
14
|
*
|
|
10
|
-
*
|
|
11
|
-
* even if bundlers duplicate this module across multiple execution paths.
|
|
15
|
+
* It keeps itself current by four independent routes, because each can be bypassed by the next:
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
17
|
+
* 1. **Local writes** — refreshes on `MJ: Users` / `MJ: User Roles` save and delete events, so the
|
|
18
|
+
* process making the change does not have to remember to.
|
|
19
|
+
* 2. **Other processes** — a refresh for a local write stamps {@link USER_CACHE_STAMP_KEY} in the
|
|
20
|
+
* shared store, and peers refresh on that notice. Clearing the shared cache (`mj sync push`,
|
|
21
|
+
* `mj codegen`, `mj migrate`) has the same effect.
|
|
22
|
+
* 3. **Writers that bypass both** (raw SQL, another application) —
|
|
23
|
+
* {@link RefreshIfChangedInDatabase} compares two counts and a timestamp against the database and
|
|
24
|
+
* reloads only on a difference. MJAPI runs it on the engine-sweep interval.
|
|
25
|
+
* 4. **A miss is not a negative fact** — {@link FindUser} falls back to an authoritative single-row
|
|
26
|
+
* read, so a user this process has not heard about is looked up rather than denied.
|
|
27
|
+
*
|
|
28
|
+
* Extends `BaseSingleton` so bundler duplication cannot produce a second instance. The class NAME is
|
|
29
|
+
* load-bearing: `BaseSingleton` keys its global store on the constructor name, so renaming it hands
|
|
30
|
+
* every existing holder a second, empty instance.
|
|
15
31
|
*/
|
|
16
32
|
export declare class UserCache extends BaseSingleton<UserCache> {
|
|
17
33
|
/**
|
|
@@ -20,6 +36,63 @@ export declare class UserCache extends BaseSingleton<UserCache> {
|
|
|
20
36
|
* `.find()`. Callers already treat a missing system user as `undefined`.
|
|
21
37
|
*/
|
|
22
38
|
private _users;
|
|
39
|
+
/** The provider the last {@link Refresh} read through; every self-refresh reuses it. */
|
|
40
|
+
private _provider;
|
|
41
|
+
/** Event subscriptions are made once per process. */
|
|
42
|
+
private _wired;
|
|
43
|
+
private _unsubscribeCacheEvents;
|
|
44
|
+
private _refreshTimer;
|
|
45
|
+
/** Consecutive windows the pending reload has waited for an open transaction. */
|
|
46
|
+
private _transactionWaits;
|
|
47
|
+
/**
|
|
48
|
+
* The providers that raised the pending changes, so the reload waits for THEIR transactions.
|
|
49
|
+
* MJServer builds a provider per request, and a resolver's save runs on that one — not on the
|
|
50
|
+
* process-wide provider this cache reads through, whose depth is always 0. Waiting on the
|
|
51
|
+
* wrong provider is the same as not waiting at all.
|
|
52
|
+
*/
|
|
53
|
+
private readonly _pendingWriters;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the pending reload has a change of OUR OWN to announce. Sticky, because a local
|
|
56
|
+
* change and an incoming peer notice collapse into one reload: carrying the intent on the timer
|
|
57
|
+
* meant whichever event scheduled last decided it, so a peer notice landing inside the debounce
|
|
58
|
+
* window demoted a local write to "someone else's change" and no peer ever heard about it. The
|
|
59
|
+
* transaction wait stretches that window to seconds.
|
|
60
|
+
*/
|
|
61
|
+
private _announcePending;
|
|
62
|
+
private _stalenessTimer;
|
|
63
|
+
/** The periodic full reload. See {@link scheduleAutoRefresh}. */
|
|
64
|
+
private _autoRefreshTimer;
|
|
65
|
+
/**
|
|
66
|
+
* The reload interval the host configured, kept so that a later `Refresh(provider)` without one
|
|
67
|
+
* — the authentication miss path, the roles/users sync — re-arms the same schedule instead of
|
|
68
|
+
* silently ending it.
|
|
69
|
+
*/
|
|
70
|
+
private _autoRefreshIntervalMs;
|
|
71
|
+
/** In-flight reload, so a burst of events costs one database read. */
|
|
72
|
+
private _refreshInFlight;
|
|
73
|
+
/** What the database reported at the last reload; the staleness check compares against it. */
|
|
74
|
+
private _lastStamp;
|
|
75
|
+
/** Lookups that missed both the cache and the database recently, so a retry storm cannot form. */
|
|
76
|
+
private readonly _recentMisses;
|
|
77
|
+
/** How long a burst of user changes is collected before one reload runs. */
|
|
78
|
+
static ChangeDebounceMs: number;
|
|
79
|
+
/**
|
|
80
|
+
* Upper bound of the random extra delay before reloading after another server's notice, so a
|
|
81
|
+
* fleet does not query the database in lockstep.
|
|
82
|
+
*/
|
|
83
|
+
static PeerNoticeJitterMs: number;
|
|
84
|
+
/** How long {@link FindUser} remembers that a lookup found nothing, before it asks again. */
|
|
85
|
+
static MissRetryIntervalMs: number;
|
|
86
|
+
/** How long to wait before re-checking whether the writing transaction has settled. */
|
|
87
|
+
static TransactionWaitMs: number;
|
|
88
|
+
/**
|
|
89
|
+
* How many {@link TransactionWaitMs} windows a pending reload waits for an open transaction
|
|
90
|
+
* before giving up. At the defaults that is 15 s; a unit of work still open after that is
|
|
91
|
+
* stuck, and the periodic staleness check will catch whatever it eventually commits.
|
|
92
|
+
*/
|
|
93
|
+
static MaxTransactionWaits: number;
|
|
94
|
+
/** Upper bound on remembered misses, so a probing attacker cannot grow the map without limit. */
|
|
95
|
+
static MaxRememberedMisses: number;
|
|
23
96
|
/**
|
|
24
97
|
* Use UserCache.Instance to get the singleton instance.
|
|
25
98
|
*/
|
|
@@ -35,10 +108,16 @@ export declare class UserCache extends BaseSingleton<UserCache> {
|
|
|
35
108
|
*/
|
|
36
109
|
GetSystemUser(): UserInfo;
|
|
37
110
|
/**
|
|
38
|
-
* This method will refresh the cache with the latest data from the database
|
|
111
|
+
* This method will refresh the cache with the latest data from the database, and subscribes this
|
|
112
|
+
* process to the changes that make it stale (see the class comment).
|
|
39
113
|
* @param provider - the configured database provider to read through. Works on any dialect —
|
|
40
114
|
* the SQL is built with the provider's own quoting and core-schema name.
|
|
41
|
-
* @param autoRefreshIntervalMS - optional
|
|
115
|
+
* @param autoRefreshIntervalMS - optional; when set, the whole cache is also reloaded on this
|
|
116
|
+
* interval. The subscriptions make that unnecessary for most hosts;
|
|
117
|
+
* {@link StartStalenessChecks} is the cheaper periodic safety net. **Omit it to
|
|
118
|
+
* keep whatever schedule an earlier call set** — `Refresh` is also called from
|
|
119
|
+
* paths that know nothing about scheduling, and those must not end it. Pass `0`
|
|
120
|
+
* to turn the schedule off.
|
|
42
121
|
*/
|
|
43
122
|
Refresh(provider: DatabaseProviderBase, autoRefreshIntervalMS?: number): Promise<void>;
|
|
44
123
|
/**
|
|
@@ -61,9 +140,41 @@ export declare class UserCache extends BaseSingleton<UserCache> {
|
|
|
61
140
|
*/
|
|
62
141
|
SetUsers(users: UserInfo[]): void;
|
|
63
142
|
/**
|
|
64
|
-
* Reads
|
|
143
|
+
* Reads the users and user-roles base views through the provider and stitches each user's roles
|
|
144
|
+
* onto it.
|
|
145
|
+
*
|
|
146
|
+
* **Why not `RunView`?** `DatabaseProviderBase` is an `IRunViewProvider`, so this could go
|
|
147
|
+
* through the standard read path and inherit its shared-cache invalidation. It deliberately does
|
|
148
|
+
* not, for three reasons:
|
|
149
|
+
* 1. **Bootstrap.** Server-side `RunView` requires a `contextUser` and throws without one
|
|
150
|
+
* (`CheckUserReadPermissions`). This cache is what produces the system user MJAPI then passes
|
|
151
|
+
* to everything else, so at first load there is no `UserInfo` to read as.
|
|
152
|
+
* 2. **It must be unfiltered.** `RunView` applies the reading user's entity permission, row-level
|
|
153
|
+
* security and field-level projection (`buildFieldSecuritySelectList`). This cache is
|
|
154
|
+
* process-global and answers "who is this?" for every request, so a set scoped to whichever
|
|
155
|
+
* user happened to bootstrap — or missing `Email` because a deployment denied that field to
|
|
156
|
+
* their role — would silently break identity for everyone else.
|
|
157
|
+
* 3. **It would put the user table in the shared cache.** `MJ: Users` is cacheable, so a
|
|
158
|
+
* `RunView` load would publish every user row (names, emails, employee links) into Redis,
|
|
159
|
+
* where today nothing about users is stored.
|
|
160
|
+
*
|
|
161
|
+
* The freshness that `RunView` would have brought is provided instead by the subscriptions on
|
|
162
|
+
* this class — see the class comment.
|
|
163
|
+
* @param whereClause - optional predicate on `vwUsers` (already quoted and escaped), for
|
|
164
|
+
* {@link FindUser}'s single-row read.
|
|
165
|
+
*/
|
|
166
|
+
protected LoadUsers(provider: DatabaseProviderBase, whereClause?: string): Promise<UserInfo[] | undefined>;
|
|
167
|
+
/**
|
|
168
|
+
* ` WHERE UserID IN (…)` for the users just loaded, or null when there are none (no query at
|
|
169
|
+
* all then). IDs come from the database, and are still shape-checked before interpolation.
|
|
170
|
+
*/
|
|
171
|
+
private rolesForUsersPredicate;
|
|
172
|
+
/**
|
|
173
|
+
* The quoted schema and base view for an entity, from metadata when it is loaded (a deployment
|
|
174
|
+
* may point the entity at a different view), falling back to the core schema and the
|
|
175
|
+
* conventional name — this cache is loaded during bootstrap, before metadata on some hosts.
|
|
65
176
|
*/
|
|
66
|
-
|
|
177
|
+
private viewFor;
|
|
67
178
|
static get Instance(): UserCache;
|
|
68
179
|
get Users(): UserInfo[];
|
|
69
180
|
static get Users(): UserInfo[];
|
|
@@ -74,5 +185,160 @@ export declare class UserCache extends BaseSingleton<UserCache> {
|
|
|
74
185
|
* @returns
|
|
75
186
|
*/
|
|
76
187
|
UserByName(name: string, caseSensitive?: boolean): UserInfo | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Finds a user by ID or email. **Prefer this over `Users.find(...)` on any path that decides
|
|
190
|
+
* whether a request is allowed.** A plain `find` renders "this process has not loaded that user"
|
|
191
|
+
* as "that user does not exist", which is how a newly created account is rejected as invalid
|
|
192
|
+
* until the server restarts.
|
|
193
|
+
*
|
|
194
|
+
* A miss here is checked against the database (one indexed row read) and, when the user is
|
|
195
|
+
* really there, added to the cache so later lookups are free. A user that the database does not
|
|
196
|
+
* have either is remembered as absent for {@link MissRetryIntervalMs}, so a bad credential
|
|
197
|
+
* cannot turn into a query per request.
|
|
198
|
+
*
|
|
199
|
+
* @returns The user, or undefined when neither the cache nor the database has it.
|
|
200
|
+
*/
|
|
201
|
+
FindUser(criteria: {
|
|
202
|
+
ID?: string;
|
|
203
|
+
Email?: string;
|
|
204
|
+
}): Promise<UserInfo | undefined>;
|
|
205
|
+
/**
|
|
206
|
+
* Remembers that the database did not have this lookup either, pruning as it goes: the map is
|
|
207
|
+
* keyed by whatever a caller asked for, so a credential-stuffing run of distinct addresses
|
|
208
|
+
* would otherwise grow it without limit.
|
|
209
|
+
*/
|
|
210
|
+
private rememberMiss;
|
|
211
|
+
/** The cached answer for {@link FindUser}'s criteria, without touching the database. */
|
|
212
|
+
private findCached;
|
|
213
|
+
private missKey;
|
|
214
|
+
/** Predicate for the single-row read; values are escaped, and the ID is checked for shape. */
|
|
215
|
+
private whereFor;
|
|
216
|
+
/**
|
|
217
|
+
* Subscribes this process to what makes the cache stale: local writes to the two entities, and
|
|
218
|
+
* shared-cache events from other processes. Runs once.
|
|
219
|
+
*/
|
|
220
|
+
private wire;
|
|
221
|
+
/** A user or user-role row changed in THIS process: reload, then tell the others. */
|
|
222
|
+
private handleEntityEvent;
|
|
223
|
+
/**
|
|
224
|
+
* Another process changed users (the stamp key), or a tool cleared the shared cache after
|
|
225
|
+
* changing the database (a RunView category clear). Either way this cache may be stale.
|
|
226
|
+
*/
|
|
227
|
+
private handleSharedCacheEvent;
|
|
228
|
+
/**
|
|
229
|
+
* Reloads after `delayMs`, collecting a burst into one read.
|
|
230
|
+
* @param publishToPeers - true when this process made the change, so other processes are told.
|
|
231
|
+
*/
|
|
232
|
+
private scheduleRefresh;
|
|
233
|
+
/**
|
|
234
|
+
* The provider a save or delete was made through: the entity's own, which on a server is the
|
|
235
|
+
* per-request instance. Falls back to the event's provider (`remote-invalidate` carries it
|
|
236
|
+
* there and has no entity).
|
|
237
|
+
*/
|
|
238
|
+
private writerOf;
|
|
239
|
+
/** Whether a provider tracks transaction depth, which is all this cache needs from it. */
|
|
240
|
+
private isDatabaseProvider;
|
|
241
|
+
/**
|
|
242
|
+
* True while a provider that raised one of the pending changes still has an open transaction,
|
|
243
|
+
* and the reload should keep waiting. Bounded: a transaction that never settles (a leaked
|
|
244
|
+
* handle) must not hold the reload forever — the periodic staleness check is the backstop, and
|
|
245
|
+
* the next user write re-arms this one.
|
|
246
|
+
*/
|
|
247
|
+
private transactionStillOpen;
|
|
248
|
+
/**
|
|
249
|
+
* Reloads the cache from the provider it was last refreshed through. Concurrent calls share one
|
|
250
|
+
* read. Does nothing when this process never had a provider (a host that only calls
|
|
251
|
+
* {@link SetUsers}).
|
|
252
|
+
*/
|
|
253
|
+
RefreshNow(): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Tells other processes that users changed, by writing {@link USER_CACHE_STAMP_KEY} to the
|
|
256
|
+
* shared store. A store that is private to this process publishes nothing, so this is a no-op
|
|
257
|
+
* there. Never throws: failing to notify peers must not fail the write that caused it.
|
|
258
|
+
*/
|
|
259
|
+
private publishStamp;
|
|
260
|
+
/**
|
|
261
|
+
* Compares the database with what this cache was built from — two counts and the newest
|
|
262
|
+
* `__mj_UpdatedAt` — and reloads only when they differ. Two small aggregate queries, so it is
|
|
263
|
+
* cheap enough to run on an interval. A deleted role row changes a count; a deactivation, or any
|
|
264
|
+
* other edit, moves `__mj_UpdatedAt`.
|
|
265
|
+
*
|
|
266
|
+
* It runs in two situations, and is skipped otherwise:
|
|
267
|
+
*
|
|
268
|
+
* - **`MJ: Users` or `MJ: User Roles` declares `TrustServerCacheCompletely = false`** — rows can
|
|
269
|
+
* change without an event (raw SQL, another application, a restore), and this is the only thing
|
|
270
|
+
* that can find them.
|
|
271
|
+
* - **This process shares its cache with other processes.** Then a change made on a peer reaches
|
|
272
|
+
* this one only as a pub/sub notice, and pub/sub delivers at most once with no replay after a
|
|
273
|
+
* reconnect. A lost notice is harmless for a GRANT — a new user or role is a cache miss, and a
|
|
274
|
+
* miss falls back to an authoritative read in {@link FindUser}. It is not harmless for a
|
|
275
|
+
* REVOCATION: a removed role or a deactivated user is a cache HIT that still carries the old
|
|
276
|
+
* state, and nothing re-reads it. Without this check a dropped notice would leave a revoked user
|
|
277
|
+
* authorised on that peer until the next user write or a restart. Revocation is a security
|
|
278
|
+
* control, so the cost — one cheap query per process per interval — is paid wherever peers
|
|
279
|
+
* exist.
|
|
280
|
+
*
|
|
281
|
+
* A single process with a private cache has no peer whose notice it can miss, so it issues no
|
|
282
|
+
* query — which keeps a serverless database free to pause.
|
|
283
|
+
*
|
|
284
|
+
* @returns true when the cache was reloaded.
|
|
285
|
+
*/
|
|
286
|
+
RefreshIfChangedInDatabase(): Promise<boolean>;
|
|
287
|
+
/**
|
|
288
|
+
* Arms the periodic full reload of users and roles, replacing any previous schedule.
|
|
289
|
+
*
|
|
290
|
+
* The timer ticks every `intervalMs`, but it reads the database **only when `MJ: Users` or
|
|
291
|
+
* `MJ: User Roles` declares `TrustServerCacheCompletely = false`** — see
|
|
292
|
+
* {@link usersMayChangeWithoutAnEvent}. A tick with nothing declared costs one in-memory lookup
|
|
293
|
+
* and issues no query, so an entity marked later is honoured on the next tick without a restart.
|
|
294
|
+
*
|
|
295
|
+
* Why the reload is conditional: a recurring query prevents a serverless database from pausing,
|
|
296
|
+
* and when every mutation flows through `BaseEntity` there is nothing for a reload to discover —
|
|
297
|
+
* a local save raises an event, a save on another process publishes the shared stamp, and
|
|
298
|
+
* {@link FindUser} falls back to an authoritative read on a miss. The reload therefore earns its
|
|
299
|
+
* cost only where rows can appear without an event.
|
|
300
|
+
*
|
|
301
|
+
* `Refresh` may be called more than once in a process (a bootstrap pass, then host
|
|
302
|
+
* configuration); each call re-arms this single timer rather than starting another chain.
|
|
303
|
+
*
|
|
304
|
+
* @param intervalMs Tick interval. `0` or absent leaves the timer off.
|
|
305
|
+
*/
|
|
306
|
+
private scheduleAutoRefresh;
|
|
307
|
+
/**
|
|
308
|
+
* Whether {@link RefreshIfChangedInDatabase} should query: rows can change without an event, or
|
|
309
|
+
* peers share this cache and one of their notices could have been lost. See that method for why
|
|
310
|
+
* the second case cannot be left to the event path.
|
|
311
|
+
*/
|
|
312
|
+
private stalenessCheckWarranted;
|
|
313
|
+
/** Whether other processes read and write the same cache store as this one. */
|
|
314
|
+
private peersShareThisCache;
|
|
315
|
+
/**
|
|
316
|
+
* Whether `MJ: Users` or `MJ: User Roles` has **declared** that its rows can change without
|
|
317
|
+
* firing an event — the only thing a periodic database check can discover.
|
|
318
|
+
*
|
|
319
|
+
* `Entity.TrustServerCacheCompletely` is that declaration: true (the default) means every
|
|
320
|
+
* mutation flows through `BaseEntity.Save()`, which this cache already hears. Polling such an
|
|
321
|
+
* entity buys nothing and costs a recurring query, which on Azure SQL serverless prevents
|
|
322
|
+
* auto-pause outright — the interval cannot fix that, only not running can.
|
|
323
|
+
*
|
|
324
|
+
* Nothing is lost for the case that motivated this cache's rework (a new user unable to log
|
|
325
|
+
* in): a save in any process raises an event, a save in another process publishes the shared
|
|
326
|
+
* stamp, and a lookup that misses still falls back to an authoritative read in `FindUser`. So
|
|
327
|
+
* even a user inserted by raw SQL can authenticate without this poll — it is the backstop for
|
|
328
|
+
* out-of-band writes. It is one of the two conditions under which the staleness check runs; see
|
|
329
|
+
* {@link stalenessCheckWarranted}.
|
|
330
|
+
*/
|
|
331
|
+
private usersMayChangeWithoutAnEvent;
|
|
332
|
+
/** Runs {@link RefreshIfChangedInDatabase} on an interval. `intervalMs <= 0` stops it. */
|
|
333
|
+
StartStalenessChecks(intervalMs: number): void;
|
|
334
|
+
StopStalenessChecks(): void;
|
|
335
|
+
private stampsMatch;
|
|
336
|
+
/**
|
|
337
|
+
* Row counts and the newest update timestamp across both views. A user row's own
|
|
338
|
+
* `__mj_UpdatedAt` covers edits and deactivations; the counts cover creates and deletes.
|
|
339
|
+
*/
|
|
340
|
+
private readDatabaseStamp;
|
|
341
|
+
/** Stops the timers and event subscriptions this cache owns. For tests and clean shutdown. */
|
|
342
|
+
Dispose(): void;
|
|
77
343
|
}
|
|
78
344
|
//# sourceMappingURL=UserCache.d.ts.map
|
package/dist/UserCache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserCache.d.ts","sourceRoot":"","sources":["../src/UserCache.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"UserCache.d.ts","sourceRoot":"","sources":["../src/UserCache.ts"],"names":[],"mappings":"AAAA,OAAO,EACiG,QAAQ,EACtF,KAAK,oBAAoB,EAClD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAmE,MAAM,wBAAwB,CAAC;AAqBxH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAO7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,SAAU,SAAQ,aAAa,CAAC,SAAS,CAAC;IACnD;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAkB;IAEhC,wFAAwF;IACxF,O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