@memberjunction/core-entities 6.1.0-edge.1 → 6.1.0-edge.3

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/LICENSE CHANGED
@@ -1,7 +1,183 @@
1
- ISC License
1
+ Business Source License 1.1
2
2
 
3
- Copyright (c) 2023 MemberJunction
3
+ License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB plc.
4
5
 
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+ -----------------------------------------------------------------------------
6
7
 
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8
+ Parameters
9
+
10
+ Licensor: Blue Cypress, Inc.
11
+
12
+ Licensed Work: MemberJunction.
13
+ The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
14
+
15
+ Additional Use Grant: Subject to the terms of this License, Licensor grants
16
+ you the following additional rights to make Production
17
+ Use of the Licensed Work.
18
+
19
+ 1. Internal Use
20
+
21
+ You may make production use of the Licensed Work for
22
+ your own internal business or organizational operations.
23
+
24
+ 2. Nonprofit Use
25
+
26
+ If you are a Nonprofit, you may make production use of
27
+ the Licensed Work for the operations and activities of
28
+ your Organizational Family.
29
+
30
+ 3. MemberJunction Certified Program Use
31
+
32
+ If you are authorized by Licensor under the
33
+ MemberJunction Certified Program to provide professional
34
+ services using the Licensed Work, you may make
35
+ production use of the Licensed Work in providing such
36
+ professional services to a client, provided that:
37
+
38
+ (a) the Licensed Work is deployed in, and the applicable
39
+ production use occurs within, an environment owned,
40
+ leased, licensed, subscribed to, or otherwise controlled
41
+ by that client; and
42
+
43
+ (b) the production use is for that client's own internal
44
+ business or organizational operations or is otherwise
45
+ independently permitted to that client under this
46
+ Additional Use Grant.
47
+
48
+ 4. Definitions Applicable to the Additional Use Grant
49
+
50
+ "Affiliate" means, with respect to a specified Person,
51
+ any other Person that directly or indirectly Controls,
52
+ is Controlled by, or is under common Control with such
53
+ specified Person.
54
+
55
+ "Control" (including the terms "Controls," "Controlled
56
+ by," and "under common Control with") means the direct
57
+ or indirect possession of the power to direct or cause
58
+ the direction of the management and policies of a
59
+ Person, whether through ownership of voting interests,
60
+ by contract, or otherwise.
61
+
62
+ "Organizational Family" means, with respect to a Person,
63
+ (a) such Person and its Affiliates, and (b) any
64
+ nonprofit organization, governmental entity, chapter,
65
+ division, local affiliate, regional affiliate, state
66
+ affiliate, national affiliate, or other entity that is
67
+ formally affiliated with such Person through governing
68
+ documents, a charter, bylaws, a membership agreement, or
69
+ another written organizational instrument, and is
70
+ recognized under such documents as part of the same
71
+ organizational structure.
72
+
73
+ "Nonprofit" means a Person recognized by the Internal
74
+ Revenue Service as exempt from federal income taxation
75
+ under Section 501(c)(3), 501(c)(4), 501(c)(5), or
76
+ 501(c)(6) of the Internal Revenue Code, or a foreign
77
+ organization recognized under substantially equivalent
78
+ laws.
79
+
80
+ A Person claiming eligibility as a Nonprofit shall, upon
81
+ Licensor's reasonable request, provide documentation
82
+ reasonably sufficient to demonstrate that it qualifies
83
+ as a Nonprofit. If such Person materially misrepresents,
84
+ or is unable to demonstrate, its qualification as a
85
+ Nonprofit, the rights granted to such Person under
86
+ Section 2 of this Additional Use Grant shall terminate.
87
+
88
+ "MemberJunction Certified Program" means Licensor's
89
+ then-current program for certifying and authorizing a
90
+ Person to provide professional services using the
91
+ Licensed Work.
92
+
93
+ "Person" means any individual, corporation, limited
94
+ liability company, partnership, association, nonprofit
95
+ organization, governmental entity, or other legal or
96
+ organizational entity.
97
+
98
+ Change Date: Four (4) years from the date the Licensed Work is first
99
+ made available.
100
+
101
+ Change License: MIT License.
102
+
103
+ For information about alternative licensing arrangements for the Licensed
104
+ Work, please contact Blue Cypress, Inc.
105
+
106
+ -----------------------------------------------------------------------------
107
+
108
+ Terms
109
+
110
+ The Licensor hereby grants you the right to copy, modify, create derivative
111
+ works, redistribute, and make non-production use of the Licensed Work. The
112
+ Licensor may make an Additional Use Grant, above, permitting limited
113
+ production use.
114
+
115
+ Effective on the Change Date, or the fourth anniversary of the first publicly
116
+ available distribution of a specific version of the Licensed Work under this
117
+ License, whichever comes first, the Licensor hereby grants you rights under
118
+ the terms of the Change License, and the rights granted in the paragraph
119
+ above terminate.
120
+
121
+ If your use of the Licensed Work does not comply with the requirements
122
+ currently in effect as described in this License, you must purchase a
123
+ commercial license from the Licensor, its affiliated entities, or authorized
124
+ resellers, or you must refrain from using the Licensed Work.
125
+
126
+ All copies of the original and modified Licensed Work, and derivative works
127
+ of the Licensed Work, are subject to this License. This License applies
128
+ separately for each version of the Licensed Work and the Change Date may vary
129
+ for each version of the Licensed Work released by Licensor.
130
+
131
+ You must conspicuously display this License on each original or modified copy
132
+ of the Licensed Work. If you receive the Licensed Work in original or
133
+ modified form from a third party, the terms and conditions set forth in this
134
+ License apply to your use of that work.
135
+
136
+ Any use of the Licensed Work in violation of this License will automatically
137
+ terminate your rights under this License for the current and all other
138
+ versions of the Licensed Work.
139
+
140
+ This License does not grant you any right in any trademark or logo of
141
+ Licensor or its affiliates (provided that you may use a trademark or logo of
142
+ Licensor as expressly required by this License).
143
+
144
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
145
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
146
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
147
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
148
+ TITLE.
149
+
150
+ MariaDB hereby grants you permission to use this License's text to license
151
+ your works, and to refer to it using the trademark "Business Source License",
152
+ as long as you comply with the Covenants of Licensor below.
153
+
154
+ -----------------------------------------------------------------------------
155
+
156
+ Covenants of Licensor
157
+
158
+ In consideration of the right to use this License's text and the "Business
159
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
160
+ other recipients of the licensed work to be provided by Licensor:
161
+
162
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
163
+ or a license that is compatible with GPL Version 2.0 or a later version,
164
+ where "compatible" means that software provided under the Change License
165
+ can be included in a program with software provided under GPL Version 2.0
166
+ or a later version. Licensor may specify additional Change Licenses without
167
+ limitation.
168
+
169
+ 2. To either: (a) specify an additional grant of rights to use that does not
170
+ impose any additional restriction on the right granted in this License, as
171
+ the Additional Use Grant; or (b) insert the text "None".
172
+
173
+ 3. To specify a Change Date.
174
+
175
+ 4. Not to modify this License in any other way.
176
+
177
+ -----------------------------------------------------------------------------
178
+
179
+ Notice
180
+
181
+ The Business Source License (this document, or the "License") is not an Open
182
+ Source license. However, the Licensed Work will eventually be made available
183
+ under an Open Source License, as stated in this License.
@@ -1 +1 @@
1
- {"version":3,"file":"MJDashboardEntityExtended.d.ts","sourceRoot":"","sources":["../../src/custom/MJDashboardEntityExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,mBAAmB,EAA+B,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAsC,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,qBACa,yBAA0B,SAAQ,iBAAiB;IACrD,SAAS,IAAI,OAAO;IA4B3B;;;;OAIG;IACa,QAAQ,IAAI,gBAAgB;IAmC5C;;;OAGG;IACmB,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAoBhF"}
1
+ {"version":3,"file":"MJDashboardEntityExtended.d.ts","sourceRoot":"","sources":["../../src/custom/MJDashboardEntityExtended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,mBAAmB,EAA+B,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAkD,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AA+CnE,qBACa,yBAA0B,SAAQ,iBAAiB;IACrD,SAAS,IAAI,OAAO;IA4B3B;;;;OAIG;IACa,QAAQ,IAAI,gBAAgB;IA8G5C;;;OAGG;IACmB,MAAM,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAiDhF"}
@@ -5,9 +5,52 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { BaseEntity, LogError } from "@memberjunction/core";
8
- import { RegisterClass, ValidationErrorInfo } from "@memberjunction/global";
8
+ import { RegisterClass, UUIDsEqual, ValidationErrorInfo } from "@memberjunction/global";
9
9
  import { MJDashboardEntity } from "../generated/entity_subclasses.js";
10
10
  import { DashboardEngine } from "../engines/dashboards.js";
11
+ /**
12
+ * The owner as stored in the database, ignoring any pending change to `UserID`.
13
+ *
14
+ * `BaseEntity` keeps the loaded value on the field as `OldValue`, which is what makes this
15
+ * answerable without a round trip. For a record that was loaded and not modified, `OldValue`
16
+ * and the current value agree; the two diverge exactly when someone is trying to change the
17
+ * owner, which is the case this exists to see through.
18
+ *
19
+ * **`OldValue` is only trustworthy when the server loaded the row itself.**
20
+ * `ResolverBase.UpdateRecord` takes two paths: when the entity has `TrackRecordChanges` it
21
+ * re-reads the record server-side, but when it does NOT, it hydrates from the client-supplied
22
+ * `OldValues___` — and first-set hydration writes `Value` *and* `OldValue`. On that path
23
+ * `OldValue` is attacker-controlled and both gates below would read whatever the caller sent.
24
+ * `MJ: Dashboards` ships with `TrackRecordChanges = 1`, but it is an ordinary admin-editable
25
+ * field — MJ has already shipped a migration disabling it on other transient entities — and
26
+ * `EntityInfo` declares it `boolean = null` with no coercion, so a metadata row missing the key
27
+ * reads falsy too. Either way this returns `null` rather than a guessable value, and the
28
+ * callers withhold the owner shortcut instead of trusting it.
29
+ *
30
+ * Note this is a CONSERVATIVE proxy for the real condition. `ResolverBase` re-reads when
31
+ * `TrackRecordChanges || !input.OldValues___`, so a caller that supplies no `OldValues___` also
32
+ * gets a server-loaded row and a trustworthy `OldValue` — this returns null there anyway,
33
+ * costing that caller the owner shortcut. That is the safe direction to be wrong in, and it
34
+ * only ever falls back to the pre-existing engine check. The precise fix is for `BaseEntity` to
35
+ * expose whether the instance was server-hydrated; until it does, this errs toward refusing to
36
+ * trust.
37
+ *
38
+ * Deliberately a MODULE-LEVEL function, not a class member. A `protected` (or `private`) method
39
+ * makes the subclass structurally distinct from `MJDashboardEntity`, and the codebase assigns
40
+ * across those two types (`BaseDashboard`'s `DashboardConfig.dashboard`), so adding one breaks
41
+ * compilation in consumers that never touch this logic.
42
+ */
43
+ function persistedUserID(entity) {
44
+ if (!entity.EntityInfo?.TrackRecordChanges) {
45
+ // Fail closed. Without server-side re-read there is no trustworthy persisted value
46
+ // here, and the alternative — falling back to `entity.UserID` — is precisely the
47
+ // client-supplied value the gate exists to distrust.
48
+ return null;
49
+ }
50
+ const field = entity.GetFieldByName('UserID');
51
+ const persisted = field?.OldValue;
52
+ return typeof persisted === 'string' && persisted.length > 0 ? persisted : entity.UserID;
53
+ }
11
54
  let MJDashboardEntityExtended = class MJDashboardEntityExtended extends MJDashboardEntity {
12
55
  NewRecord() {
13
56
  try {
@@ -49,12 +92,78 @@ let MJDashboardEntityExtended = class MJDashboardEntityExtended extends MJDashbo
49
92
  result.Errors.push(new ValidationErrorInfo('Permission', 'You must be logged in to save a dashboard', null));
50
93
  return result;
51
94
  }
52
- // For existing records (not new), check edit permission
95
+ // For existing records (not new), check edit permission.
96
+ //
97
+ // Ownership is answered from THIS ROW, not from the engine. GetDashboardPermissions reads
98
+ // DashboardEngine's backing array directly, so an engine that was never Config()'d is
99
+ // indistinguishable from "this dashboard grants you nothing" — and every caller is refused,
100
+ // the owner included. That is not hypothetical: any process using the default `task`
101
+ // startup mode defers engine pre-warm, which is why `mj sync push` failed on a dashboard
102
+ // whose UserID *was* the pushing user.
103
+ //
104
+ // The owner case needs no cache — the persisted `UserID` is on the record being validated.
105
+ // Resolving it first fixes the defect without weakening the gate: a non-owner still cannot
106
+ // pass on an unevaluable cache, which is the direction a permission check should fail.
107
+ // Validate() is synchronous and cannot await Config(), so a non-owner whose grant lives
108
+ // only in the engine is refused when the cache is cold — the pre-existing behaviour for
109
+ // that case, deliberately left as-is rather than opened up.
53
110
  if (this.IsSaved) {
54
- const permissions = DashboardEngine.Instance.GetDashboardPermissions(this.ID, currentUser.ID);
55
- if (!permissions.CanEdit) {
111
+ const persistedOwnerID = persistedUserID(this);
112
+ // NOTE — supersedes upstream's `ownsRecord` fallback (255d506404, "a dashboard's owner
113
+ // can save when the engine is unloaded"). That fix solved the same cold-cache problem by
114
+ // trusting `this.UserID` whenever `DashboardEngine.Instance.Loaded` was false — but
115
+ // `UserID` is client-settable on the update path, so a caller who can load a dashboard
116
+ // could set it to themselves and, on any process where the engine happens to be cold,
117
+ // be granted edit on someone else's record. Reading the PERSISTED owner fixes the cold
118
+ // cache the same way (the row carries the answer; no engine needed) without ever
119
+ // trusting a value the caller supplied.
120
+ // The check MUST read the persisted owner, never `this.UserID`. `UserID` is a settable
121
+ // field on UpdateMJDashboardInput, and ResolverBase.UpdateRecord loads the row and then
122
+ // applies the client's values BEFORE Save() runs Validate(). Trusting the in-memory
123
+ // value would let any user who can load a dashboard send
124
+ // `UpdateMJDashboard(ID: <someone else's>, UserID: <self>)`, satisfy the owner branch
125
+ // with the value they just supplied, and take ownership of the record.
126
+ //
127
+ // A NULL persisted owner means that value is not trustworthy here (see
128
+ // persistedUserID). It must not open the owner branch — but it must not refuse the save
129
+ // either. Refusing turns an auditing setting into a total outage: nobody, owner
130
+ // included, could update any dashboard. Instead the owner shortcut is simply withheld
131
+ // and the engine decides, which is exactly the behaviour before this fix existed. That
132
+ // is strictly no weaker than the shipped baseline while still closing the escalation.
133
+ if (persistedOwnerID === null || !UUIDsEqual(persistedOwnerID, currentUser.ID)) {
134
+ const permissions = DashboardEngine.Instance.GetDashboardPermissions(this.ID, currentUser.ID);
135
+ if (!permissions.CanEdit) {
136
+ result.Success = false;
137
+ result.Errors.push(new ValidationErrorInfo('Permission', 'You do not have permission to edit this dashboard', this.ID));
138
+ }
139
+ }
140
+ // Reassigning ownership is an owner-only act, and separate from being able to edit.
141
+ // A user granted CanEdit through a share must not be able to make the dashboard theirs.
142
+ //
143
+ // ⚠️ KNOWN LIMITATION when `persistedOwnerID` is null (change tracking off). `Dirty` is
144
+ // `Value !== OldValue`, and on that path BOTH sides come from the client: the resolver
145
+ // hydrates from `OldValues___`, and first-set hydration writes `Value` *and* `OldValue`.
146
+ // A caller who sends `OldValues___.UserID = <self>` alongside `UserID = <self>` presents
147
+ // a field that is NOT dirty while the value is already theirs, so this gate does not
148
+ // fire and the transfer proceeds. It catches an honest client, not a hostile one.
149
+ //
150
+ // This is deliberately not "fixed" by tightening the predicate — every signal reachable
151
+ // from here is client-supplied on that path. The real fix is for `BaseEntity` to expose
152
+ // whether the instance was server-hydrated (or for this to do a provider round-trip),
153
+ // and `Validate()` being synchronous is what rules the round-trip out today. Until then
154
+ // the shipped default (`TrackRecordChanges = 1`) is what keeps this closed, and that
155
+ // coupling is now stated rather than assumed.
156
+ if (persistedOwnerID === null) {
157
+ const field = this.GetFieldByName('UserID');
158
+ if (field?.Dirty) {
159
+ result.Success = false;
160
+ result.Errors.push(new ValidationErrorInfo('UserID', 'Dashboard ownership cannot be transferred while change tracking is disabled for ' +
161
+ 'MJ: Dashboards, because the current owner cannot be verified.', this.ID));
162
+ }
163
+ }
164
+ else if (!UUIDsEqual(this.UserID, persistedOwnerID) && !UUIDsEqual(persistedOwnerID, currentUser.ID)) {
56
165
  result.Success = false;
57
- result.Errors.push(new ValidationErrorInfo('Permission', 'You do not have permission to edit this dashboard', this.ID));
166
+ result.Errors.push(new ValidationErrorInfo('UserID', 'Only the owner of a dashboard can transfer its ownership', this.ID));
58
167
  }
59
168
  }
60
169
  return result;
@@ -70,7 +179,35 @@ let MJDashboardEntityExtended = class MJDashboardEntityExtended extends MJDashbo
70
179
  LogError('Cannot delete dashboard: User not authenticated');
71
180
  return false;
72
181
  }
73
- // Check delete permission
182
+ // The owner is answered from the persisted row, for the same reason as in Validate():
183
+ // it needs no cache, and a cache that is merely stale — a dashboard created since the
184
+ // last Config() is absent from the backing array — otherwise refuses its own owner.
185
+ //
186
+ // A null answer means the persisted owner is not trustworthy (see persistedUserID), so
187
+ // this shortcut is skipped and the delete falls through to the engine. Unlike Validate(),
188
+ // that costs nothing here beyond a load — the engine is the authoritative source, and
189
+ // this path is async and can consult it.
190
+ const persistedOwnerID = persistedUserID(this);
191
+ if (persistedOwnerID !== null && UUIDsEqual(persistedOwnerID, currentUser.ID)) {
192
+ return super.Delete(options);
193
+ }
194
+ // Not the owner, so the grant can only come from the engine. Unlike Validate(), this path
195
+ // is async, so it can load the engine rather than guess.
196
+ //
197
+ // The load is GUARDED because it is the one thing here that can throw, and `Delete()` is
198
+ // documented to report logical failure by RETURNING FALSE, not by throwing — callers check
199
+ // the boolean and read `LatestResult`. Letting a Config() rejection escape would change
200
+ // this method's contract for every caller as a side effect of consulting the engine, and it
201
+ // would do so only on the cold-cache path, which is the one nobody exercises. A failure to
202
+ // load the permission source is a refusal to delete, which is the safe direction: it can
203
+ // never turn into an accidental grant.
204
+ try {
205
+ await DashboardEngine.Instance.Config(false, currentUser, this.ProviderToUse);
206
+ }
207
+ catch (err) {
208
+ LogError(`Cannot delete dashboard ${this.ID}: loading dashboard permissions failed: ${err}`);
209
+ return false;
210
+ }
74
211
  const permissions = DashboardEngine.Instance.GetDashboardPermissions(this.ID, currentUser.ID);
75
212
  if (!permissions.CanDelete) {
76
213
  LogError(`User ${currentUser.ID} does not have permission to delete dashboard ${this.ID}`);
@@ -1 +1 @@
1
- {"version":3,"file":"MJDashboardEntityExtended.js","sourceRoot":"","sources":["../../src/custom/MJDashboardEntityExtended.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAA0C,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAoB,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGjD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,iBAAiB;IACrD,SAAS;QACZ,IAAG,CAAC;YACA,KAAK,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,oBAAoB,GAAG;gBACzB,OAAO,EAAE,CAAC;gBACV,SAAS,EAAE,GAAG;gBACd,SAAS,EAAE,IAAI;gBACf,WAAW,EAAE,IAAI;gBACjB,KAAK,EAAE,EAAE;aACZ,CAAA;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;YACxD,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAExC,MAAM,EAAE,GAAG,IAAI,CAAC,aAA6C,CAAC;YAC9D,IAAG,EAAE,CAAC,WAAW,EAAC,CAAC;gBACf,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAC1C,CAAC;YAED,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAM,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,sBAAsB,CAAC,CAAC;YACjC,QAA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U,EAAE,MAAM,GAAG,0BAA0B,EAAE;IAIhF;;;;OAIG;IACI,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI;CAOtF"}
@@ -74,11 +74,9 @@ export class FileStorageEngineBase extends BaseEngine {
74
74
  * Consumers should filter/sort as needed (e.g., by provider.IsActive).
75
75
  */
76
76
  get AccountsWithProviders() {
77
- const providerMap = new Map();
78
- this.Providers.forEach(p => providerMap.set(p.ID, p));
79
77
  return this.Accounts
80
78
  .map(account => {
81
- const provider = providerMap.get(account.ProviderID);
79
+ const provider = this.Providers.find(p => UUIDsEqual(p.ID, account.ProviderID));
82
80
  if (!provider)
83
81
  return null;
84
82
  return { account, provider };
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorageEngine.js","sourceRoot":"","sources":["../../src/engines/FileStorageEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyD,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,qBAAsB,SAAQ,UAAiC;IAA5E;;QAUY,cAAS,GAAiC,EAAE,CAAC;QAC7C,eAAU,GAAkC,EAAE,CAAC;IAkH3D,CAAC;IA5HG;;;;OAIG;IACI,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,EAAyB,CAAC;IACtD,CAAC;IAKD;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAC,YAAsB,EAAE,WAAsB,EAAE,QAA4B;QAC5F,MAAM,OAAO,GAAwC;YACjD;gBACI,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,2BAA2B;gBACvC,YAAY,EAAE,WAAW;gBACzB,UAAU,EAAE,IAAI;aACnB;YACD;gBACI,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,4BAA4B;gBACxC,YAAY,EAAE,YAAY;gBAC1B,UAAU,EAAE,IAAI;aACnB;SACJ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ailCache {
185
185
  */
186
186
  PeripheralDataStale: boolean;
187
187
  }
188
+ /**
189
+ * Inputs to {@link ConversationEngine.LoadDetailWindow}.
190
+ */
191
+ export interface LoadDetailWindowParams {
192
+ ConversationID: string;
193
+ /**
194
+ * Exclusive: return rows with `Sequence` below this. Omit for the latest window.
195
+ *
196
+ * `Sequence` is the cursor, NOT the primary key — `MJ: Conversation Details.ID` is a
197
+ * uniqueidentifier, and `RunViewParams.AfterKey` is a PK seek that rejects any non-PK
198
+ * `OrderBy`, so it cannot express chat order.
199
+ */
200
+ BeforeSequence?: number;
201
+ /** Timeline items the caller is trying to fill. Default {@link DEFAULT_WINDOW_PAGE_SIZE}. */
202
+ PageSize?: number;
203
+ /** Raw rows to pull per attempt. Default `PageSize * 3`. */
204
+ RawOverread?: number;
205
+ }
206
+ /**
207
+ * One page of a conversation's transcript plus the peripheral data its rows need.
208
+ *
209
+ * Deliberately NOT a {@link ConversationDetailCache} — that type is the FULL-history
210
+ * contract and is what `GetAgentContextWindow` consumes. Keeping the shapes distinct is
211
+ * what stops a window from being written into `_detailCache` by accident.
212
+ */
213
+ export interface DetailWindowLoadResult {
214
+ /** The window's rows, chronological by `Sequence`. */
215
+ Details: MJConversationDetailEntity[];
216
+ /** Agent runs keyed by conversation detail ID. */
217
+ AgentRunsByDetailId: Map<string, MJAIAgentRunEntity>;
218
+ /** User avatars keyed by UserID. */
219
+ UserAvatars: Map<string, UserAvatarInfo>;
220
+ /** Ratings keyed by conversation detail ID. */
221
+ RatingsByDetailId: Map<string, RatingJSON[]>;
222
+ /** Parsed artifacts keyed by conversation detail ID. */
223
+ ArtifactsByDetailId: Map<string, ArtifactJSON[]>;
224
+ /** True when at least one row exists below {@link OldestSequence}. */
225
+ HasMoreAbove: boolean;
226
+ /** `Sequence` of the oldest loaded row — the next older fetch's exclusive bound. */
227
+ OldestSequence: number | null;
228
+ /** `Sequence` of the newest loaded row. Used to detect live appends. */
229
+ NewestSequence: number | null;
230
+ /**
231
+ * True when a read underlying this window FAILED, as opposed to returning nothing.
232
+ *
233
+ * Without this the two are indistinguishable, and the difference matters more than it
234
+ * looks: `HasMoreAbove: false` from a failed read means "you have reached the start of
235
+ * the conversation", so a consumer folds a transport blip into its cursor and stops
236
+ * offering to page. Nothing later restores it. A failed read must leave the caller's
237
+ * paging state alone, which it can only do if it can tell the two apart.
238
+ *
239
+ * Set when the row read failed, when the older-rows probe failed, or when a widening
240
+ * retry failed. Peripheral failures do NOT set it — those already degrade to empty maps
241
+ * and the transcript still renders.
242
+ */
243
+ Failed: boolean;
244
+ }
188
245
  /**
189
246
  * ConversationEngine provides centralized, reactive caching for conversations,
190
247
  * conversation details (messages), and peripheral data (agent runs, artifacts).
@@ -454,11 +511,123 @@ export declare class ConversationEngine extends BaseEngine<ConversationEngine> {
454
511
  * @returns The full cache entry with all peripheral data
455
512
  */
456
513
  LoadConversationDetails(conversationId: string, contextUser: UserInfo, forceRefresh?: boolean): Promise<ConversationDetailCache>;
514
+ /**
515
+ * Loads ONE page of a conversation's transcript — the chat area's windowed history read.
516
+ *
517
+ * Additive counterpart to {@link LoadConversationDetails}, which stays the FULL-history
518
+ * API. Opening a long conversation must not transfer and hydrate every row, so this
519
+ * reads the newest `RawOverread` rows below an optional `Sequence` bound, completes any
520
+ * realtime session the page landed inside, probes whether older rows remain, and loads
521
+ * peripherals for just those rows.
522
+ *
523
+ * The result is deliberately NOT written to `_detailCache`. That cache is keyed by
524
+ * conversation id alone, and {@link GetAgentContextWindow} reads it as complete history —
525
+ * a partial entry there would silently starve the agent of everything before the summary
526
+ * boundary, with no error. Use a separate partial cache if incremental caching is needed.
527
+ *
528
+ * Does not throw for a read that FAILS — a failed load returns an empty window flagged
529
+ * {@link DetailWindowLoadResult.Failed} so the caller can leave its paging state intact
530
+ * rather than mistaking the failure for the start of the conversation.
531
+ *
532
+ * It is not, however, exception-proof: there is no `try/catch` here, so a provider that
533
+ * REJECTS rather than returning `Success: false` propagates out to the caller. That path
534
+ * is left deliberately — it degrades better than the handled one, because an exception
535
+ * skips the cursor write entirely and the caller's paging state survives untouched.
536
+ *
537
+ * ### Round-trip profile — the counterweight to the payload win
538
+ *
539
+ * This trades ONE fat query for several thin ones. Per page:
540
+ *
541
+ * 1. {@link fetchDetailRowsBySequence} — always
542
+ * 2. {@link expandOldestSession} — only when the oldest row is session-stamped
543
+ * 3. {@link hasOlderDetails} — always, in parallel with (4)
544
+ * 4. {@link buildWindowPeripherals} — one batched `RunViews` of 3
545
+ * 5. {@link loadWindowUsers} — whenever the window references any user
546
+ * 6-7. {@link buildWindowArtifactMap} — up to two SEQUENTIAL reads, and it cannot batch
547
+ * them: the version ids come from the junction rows and the artifact ids from the
548
+ * versions.
549
+ *
550
+ * That is 3-6 round trips / 5-9 queries per page, against the single
551
+ * `GetConversationComplete` call that previously covered the ENTIRE conversation.
552
+ *
553
+ * For first paint this is unambiguously the right trade — the old call scaled with total
554
+ * conversation length, this one does not. For a reader paging back it inverts: past
555
+ * roughly ten pages the cumulative round trips exceed the old single load.
556
+ *
557
+ * The lever for that is `PageSize`, NOT this method. The per-page cost above is fixed
558
+ * regardless of how many rows come back, so a larger page for OLDER pages amortizes it
559
+ * over more content — and unlike first paint, a reader who has scrolled up has already
560
+ * committed to reading back. If paging up ever feels slow, that is the number to raise.
561
+ *
562
+ * @param params - Conversation, optional `Sequence` bound, and page sizing
563
+ * @param contextUser - The requesting user (entity RLS applies)
564
+ */
565
+ LoadDetailWindow(params: LoadDetailWindowParams, contextUser: UserInfo): Promise<DetailWindowLoadResult>;
566
+ /**
567
+ * Reads the newest `maxRows` detail rows below an optional `Sequence` bound and returns
568
+ * them in CHRONOLOGICAL order.
569
+ *
570
+ * The query is `Sequence DESC` because the interesting end of a transcript is the tail;
571
+ * the reversal happens here so every caller downstream sees oldest-to-newest.
572
+ *
573
+ * @returns The page in ascending `Sequence` order, or null when the read failed.
574
+ */
575
+ private fetchDetailRowsBySequence;
576
+ /**
577
+ * Completes a realtime session the page landed part-way through.
578
+ *
579
+ * Rows stamped with an `AgentSessionID` collapse into ONE session card in the UI. When
580
+ * the oldest row of a page is stamped, the rest of that session sits below the page
581
+ * boundary — without this read the card renders from a partial row set AND the same
582
+ * session reappears on the next older page.
583
+ *
584
+ * @returns The page with any missing session rows prepended, still chronological.
585
+ */
586
+ private expandOldestSession;
587
+ /**
588
+ * Probes whether any row exists below the window's oldest `Sequence` — i.e. whether the
589
+ * UI should show its "earlier messages" sentinel.
590
+ *
591
+ * A one-row probe rather than `page.length === MaxRows`: session expansion changes the
592
+ * row count, so a full page can look short and a short page can look full.
593
+ *
594
+ * Returns a TRI-STATE rather than a boolean. "No older rows" and "could not find out"
595
+ * are both `HasOlder: false`, and only the second must leave the caller's cursor alone.
596
+ */
597
+ private hasOlderDetails;
457
598
  /**
458
599
  * Builds a full ConversationDetailCache from raw GetConversationComplete query results.
459
600
  * Hydrates entity objects and parses peripheral JSON data in one pass.
460
601
  */
461
602
  private buildDetailCacheFromRawData;
603
+ /**
604
+ * Loads peripheral data for ONE window's rows.
605
+ *
606
+ * Sibling of {@link buildDetailCacheFromRawData}, which cannot be reused here: that
607
+ * method parses the `AgentRunsJSON` / `ArtifactsJSON` / `RatingsJSON` columns that only
608
+ * the GetConversationComplete stored query produces. A windowed RunView returns none of
609
+ * them, so each peripheral is a real query.
610
+ *
611
+ * A failing peripheral degrades to an empty map — the transcript still renders.
612
+ */
613
+ private buildWindowPeripherals;
614
+ /**
615
+ * Loads the users a window references — message authors (for avatars) and raters (for
616
+ * the denormalized `UserName` on each rating).
617
+ */
618
+ private loadWindowUsers;
619
+ /**
620
+ * Rebuilds the window's artifact cards from the three tables GetConversationComplete
621
+ * joins: the detail↔version junction, the version, then the artifact.
622
+ *
623
+ * This cannot be one batched call — the version ids come from the junction rows, and
624
+ * the artifact ids from the versions — so it is two sequential follow-up reads. Rows
625
+ * whose version or artifact is missing are dropped, matching the stored query's INNER
626
+ * JOIN semantics.
627
+ */
628
+ private buildWindowArtifactMap;
629
+ /** Reads the artifact rows behind a window's artifact versions. */
630
+ private loadArtifactsByIds;
462
631
  /**
463
632
  * Refreshes conversation details by re-running the GetConversationComplete query
464
633
  * and surgically merging results into the existing cache. Existing objects that