@memberjunction/server 5.40.2 → 5.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentSessions/HostInstance.d.ts +19 -0
- package/dist/agentSessions/HostInstance.d.ts.map +1 -0
- package/dist/agentSessions/HostInstance.js +48 -0
- package/dist/agentSessions/HostInstance.js.map +1 -0
- package/dist/agentSessions/SessionJanitor.d.ts +97 -0
- package/dist/agentSessions/SessionJanitor.d.ts.map +1 -0
- package/dist/agentSessions/SessionJanitor.js +222 -0
- package/dist/agentSessions/SessionJanitor.js.map +1 -0
- package/dist/agentSessions/SessionManager.d.ts +142 -0
- package/dist/agentSessions/SessionManager.d.ts.map +1 -0
- package/dist/agentSessions/SessionManager.js +308 -0
- package/dist/agentSessions/SessionManager.js.map +1 -0
- package/dist/agentSessions/index.d.ts +5 -0
- package/dist/agentSessions/index.d.ts.map +1 -0
- package/dist/agentSessions/index.js +31 -0
- package/dist/agentSessions/index.js.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.d.ts +102 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.d.ts.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.js +164 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.js.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.d.ts +66 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.d.ts.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.js +86 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.js.map +1 -0
- package/dist/auth/initializeProviders.d.ts.map +1 -1
- package/dist/auth/initializeProviders.js +4 -2
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -2
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +41 -7
- package/dist/context.js.map +1 -1
- package/dist/generated/generated.d.ts +1296 -49
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +50343 -43421
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/ResolverBase.js +1 -1
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.js +9 -10
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -54
- package/dist/index.js.map +1 -1
- package/dist/integration/CustomColumnPromoter.d.ts +108 -0
- package/dist/integration/CustomColumnPromoter.d.ts.map +1 -0
- package/dist/integration/CustomColumnPromoter.js +508 -0
- package/dist/integration/CustomColumnPromoter.js.map +1 -0
- package/dist/logging/StartupLogger.d.ts +177 -0
- package/dist/logging/StartupLogger.d.ts.map +1 -0
- package/dist/logging/StartupLogger.js +354 -0
- package/dist/logging/StartupLogger.js.map +1 -0
- package/dist/logging/variablesLoggingMiddleware.d.ts.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.js +21 -2
- package/dist/logging/variablesLoggingMiddleware.js.map +1 -1
- package/dist/resolvers/AgentSessionResolver.d.ts +42 -0
- package/dist/resolvers/AgentSessionResolver.d.ts.map +1 -0
- package/dist/resolvers/AgentSessionResolver.js +152 -0
- package/dist/resolvers/AgentSessionResolver.js.map +1 -0
- package/dist/resolvers/EntityPermissionResolver.d.ts +16 -0
- package/dist/resolvers/EntityPermissionResolver.d.ts.map +1 -0
- package/dist/resolvers/EntityPermissionResolver.js +95 -0
- package/dist/resolvers/EntityPermissionResolver.js.map +1 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts +27 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts.map +1 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.js +136 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.js.map +1 -0
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +101 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.js +544 -42
- package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
- package/dist/resolvers/RealtimeBridgeResolver.d.ts +121 -0
- package/dist/resolvers/RealtimeBridgeResolver.d.ts.map +1 -0
- package/dist/resolvers/RealtimeBridgeResolver.js +533 -0
- package/dist/resolvers/RealtimeBridgeResolver.js.map +1 -0
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts +688 -0
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -0
- package/dist/resolvers/RealtimeClientSessionResolver.js +1774 -0
- package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -0
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts +432 -0
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts.map +1 -0
- package/dist/resolvers/RemoteBrowserActionResolver.js +1108 -0
- package/dist/resolvers/RemoteBrowserActionResolver.js.map +1 -0
- package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.js +0 -7
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/rest/setupRESTEndpoints.d.ts.map +1 -1
- package/dist/rest/setupRESTEndpoints.js +5 -3
- package/dist/rest/setupRESTEndpoints.js.map +1 -1
- package/dist/services/ScheduledJobsService.d.ts.map +1 -1
- package/dist/services/ScheduledJobsService.js +6 -5
- package/dist/services/ScheduledJobsService.js.map +1 -1
- package/package.json +83 -74
- package/src/__tests__/RealtimeBridgeResolver.test.ts +100 -0
- package/src/__tests__/RealtimeClientSessionResolver.test.ts +2605 -0
- package/src/__tests__/RemoteBrowserAudioStream.test.ts +181 -0
- package/src/__tests__/RemoteBrowserGoalEngine.test.ts +144 -0
- package/src/__tests__/SessionJanitor.test.ts +234 -0
- package/src/__tests__/SessionManager.test.ts +465 -0
- package/src/__tests__/remoteBrowserGoalRegistry.test.ts +81 -0
- package/src/__tests__/subscriptionRedaction.test.ts +5 -0
- package/src/agentSessions/HostInstance.ts +53 -0
- package/src/agentSessions/SessionJanitor.ts +267 -0
- package/src/agentSessions/SessionManager.ts +446 -0
- package/src/agentSessions/index.ts +32 -0
- package/src/agentSessions/remoteBrowserGoalEngine.ts +191 -0
- package/src/agentSessions/remoteBrowserGoalRegistry.ts +122 -0
- package/src/auth/initializeProviders.ts +4 -2
- package/src/config.ts +13 -2
- package/src/context.ts +42 -7
- package/src/generated/generated.ts +33808 -29025
- package/src/generic/ResolverBase.ts +1 -1
- package/src/generic/RunViewResolver.ts +9 -9
- package/src/index.ts +128 -54
- package/src/integration/CustomColumnPromoter.ts +597 -0
- package/src/logging/StartupLogger.ts +441 -0
- package/src/logging/variablesLoggingMiddleware.ts +25 -5
- package/src/resolvers/AgentSessionResolver.ts +138 -0
- package/src/resolvers/EntityPermissionResolver.ts +73 -0
- package/src/resolvers/ExecuteRemoteOperationResolver.ts +108 -0
- package/src/resolvers/IntegrationDiscoveryResolver.ts +396 -37
- package/src/resolvers/RealtimeBridgeResolver.ts +450 -0
- package/src/resolvers/RealtimeClientSessionResolver.ts +2162 -0
- package/src/resolvers/RemoteBrowserActionResolver.ts +1122 -0
- package/src/resolvers/RunAIAgentResolver.ts +1 -9
- package/src/rest/setupRESTEndpoints.ts +5 -3
- package/src/services/ScheduledJobsService.ts +6 -5
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { configInfo } from '../config.js';
|
|
2
|
+
import { LogStatus } from '@memberjunction/core';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import type { Ora } from 'ora';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Server log verbosity levels, ordered from least to most chatty.
|
|
8
|
+
*
|
|
9
|
+
* Reuses the SAME enum shape as `telemetry.level` in `config.ts` so operators
|
|
10
|
+
* have a single knob (`telemetry.level` in mj.config.cjs) that governs both
|
|
11
|
+
* telemetry verbosity and server-log verbosity — there is no parallel setting.
|
|
12
|
+
*
|
|
13
|
+
* Ordering (ascending): `minimal` < `standard` < `verbose` < `debug`.
|
|
14
|
+
*/
|
|
15
|
+
export type ServerLogLevel = 'minimal' | 'standard' | 'verbose' | 'debug';
|
|
16
|
+
|
|
17
|
+
/** Numeric rank for each level, used for `>=` threshold comparisons. */
|
|
18
|
+
const LEVEL_RANK: Record<ServerLogLevel, number> = {
|
|
19
|
+
minimal: 0,
|
|
20
|
+
standard: 1,
|
|
21
|
+
verbose: 2,
|
|
22
|
+
debug: 3,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A single captured startup phase timing (e.g. "DB Pool Connect: 412ms").
|
|
27
|
+
* Buffered during startup and either printed individually (verbose+) or
|
|
28
|
+
* collapsed into the one-line `Startup` summary (standard).
|
|
29
|
+
*/
|
|
30
|
+
type PhaseTiming = {
|
|
31
|
+
/** Human-readable phase label. */
|
|
32
|
+
Label: string;
|
|
33
|
+
/** Elapsed milliseconds for the phase. */
|
|
34
|
+
Ms: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Fields gathered during startup that are rendered into the compact
|
|
39
|
+
* `standard`-level summary block. All optional — the renderer degrades
|
|
40
|
+
* gracefully when a field was never set.
|
|
41
|
+
*/
|
|
42
|
+
type StartupSummaryData = {
|
|
43
|
+
/** Server package version (e.g. "5.40.2"); omitted from the header if absent. */
|
|
44
|
+
Version?: string;
|
|
45
|
+
/** Database platform label, e.g. "SQL Server" or "PostgreSQL". */
|
|
46
|
+
DbPlatform?: string;
|
|
47
|
+
/** Database connection string fragment, e.g. "localhost:1433/MJ_DB". */
|
|
48
|
+
DbConnection?: string;
|
|
49
|
+
/** Count of entities loaded into metadata. */
|
|
50
|
+
EntityCount?: number;
|
|
51
|
+
/** Absolute path to the resolved config file (omitted from the block if absent). */
|
|
52
|
+
ConfigPath?: string;
|
|
53
|
+
/** Names of registered auth providers. */
|
|
54
|
+
AuthProviders: string[];
|
|
55
|
+
/** Whether the REST API is enabled. */
|
|
56
|
+
RestEnabled?: boolean;
|
|
57
|
+
/** Count of active scheduled jobs (or 0 / suspended). */
|
|
58
|
+
ScheduledJobCount?: number;
|
|
59
|
+
/** Public URL the server is ready at. */
|
|
60
|
+
ReadyUrl?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* MJServer-local startup + per-request log gating helper.
|
|
65
|
+
*
|
|
66
|
+
* Holds the resolved {@link ServerLogLevel} (from `telemetry.level`) and exposes
|
|
67
|
+
* a small surface for level-gated logging, startup phase-timing capture, and the
|
|
68
|
+
* compact summary block printed once at the end of boot.
|
|
69
|
+
*
|
|
70
|
+
* This is deliberately NOT a `BaseSingleton` and does NOT touch
|
|
71
|
+
* `@memberjunction/core` logging internals — it is a thin, process-local gate
|
|
72
|
+
* that wraps `console.*` / `LogStatus`. The point is the *gating*, not a new
|
|
73
|
+
* logging framework.
|
|
74
|
+
*
|
|
75
|
+
* Usage:
|
|
76
|
+
* ```ts
|
|
77
|
+
* const logger = new StartupLogger();
|
|
78
|
+
* logger.LogIf('verbose', 'Registered auth provider: azure');
|
|
79
|
+
* const t = logger.StartPhase();
|
|
80
|
+
* // ... work ...
|
|
81
|
+
* logger.EndPhase('DB Pool Connect', t);
|
|
82
|
+
* logger.PrintSummary();
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export class StartupLogger {
|
|
86
|
+
private readonly resolvedLevel: ServerLogLevel;
|
|
87
|
+
private readonly phaseTimings: PhaseTiming[] = [];
|
|
88
|
+
private readonly summary: StartupSummaryData = { AuthProviders: [] };
|
|
89
|
+
/** Transient boot spinner — active only at `standard` level on a TTY (see {@link spinnerEnabled}). */
|
|
90
|
+
private spinner: Ora | null = null;
|
|
91
|
+
/** Interval that ticks the live elapsed counter on the spinner line. */
|
|
92
|
+
private bootTimer: ReturnType<typeof setInterval> | null = null;
|
|
93
|
+
/** Wall-clock start of the boot indicator, for the live elapsed counter. */
|
|
94
|
+
private bootStartMs = 0;
|
|
95
|
+
/** Most recent phase label, shown on the spinner line. */
|
|
96
|
+
private currentPhase?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param level Optional explicit level override (primarily for tests).
|
|
100
|
+
* When omitted, the level is resolved from config.
|
|
101
|
+
*/
|
|
102
|
+
constructor(level?: ServerLogLevel) {
|
|
103
|
+
this.resolvedLevel = level ?? StartupLogger.resolveLevelFromConfig();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The resolved log level in effect for this logger instance.
|
|
108
|
+
*/
|
|
109
|
+
public get Level(): ServerLogLevel {
|
|
110
|
+
return this.resolvedLevel;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Resolves the active server log level from configuration.
|
|
115
|
+
*
|
|
116
|
+
* Source of truth is `telemetry.level` (the pre-existing enum), so a single
|
|
117
|
+
* operator knob governs both telemetry and server logging. Defaults to
|
|
118
|
+
* `standard` when unset or unrecognized.
|
|
119
|
+
*/
|
|
120
|
+
public static resolveLevelFromConfig(): ServerLogLevel {
|
|
121
|
+
const raw = configInfo.telemetry?.level;
|
|
122
|
+
if (raw === 'minimal' || raw === 'standard' || raw === 'verbose' || raw === 'debug') {
|
|
123
|
+
return raw;
|
|
124
|
+
}
|
|
125
|
+
return 'standard';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* True when the active level is at least `minLevel` (using the ascending
|
|
130
|
+
* `minimal < standard < verbose < debug` ordering).
|
|
131
|
+
*/
|
|
132
|
+
public IsAtLeast(minLevel: ServerLogLevel): boolean {
|
|
133
|
+
return LEVEL_RANK[this.resolvedLevel] >= LEVEL_RANK[minLevel];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Logs `message` only when the active level is at least `minLevel`.
|
|
138
|
+
* Routes through MJ's `LogStatus` so the line participates in MJ's
|
|
139
|
+
* standard status-logging pipeline.
|
|
140
|
+
*/
|
|
141
|
+
public LogIf(minLevel: ServerLogLevel, message: string): void {
|
|
142
|
+
if (this.IsAtLeast(minLevel)) {
|
|
143
|
+
LogStatus(message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Starts a phase timer. Returns an opaque start timestamp to pass to
|
|
149
|
+
* {@link EndPhase}.
|
|
150
|
+
*/
|
|
151
|
+
public StartPhase(): number {
|
|
152
|
+
return performance.now();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* True when the transient boot spinner should animate: only at `standard`
|
|
157
|
+
* level AND when stdout is an interactive TTY. In non-TTY contexts (Docker,
|
|
158
|
+
* systemd, piped logs) a spinner emits escape codes that pollute log
|
|
159
|
+
* aggregation, and at `verbose`+ the inline phase lines would fight it — so
|
|
160
|
+
* both fall back to plain, line-oriented output.
|
|
161
|
+
*/
|
|
162
|
+
private get spinnerEnabled(): boolean {
|
|
163
|
+
return this.resolvedLevel === 'standard' && process.stdout.isTTY === true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Prefix for the transient boot indicator (no rocket — we haven't launched yet). */
|
|
167
|
+
private static readonly BOOT_LABEL = 'Bootstrapping MemberJunction Server';
|
|
168
|
+
|
|
169
|
+
/** Composes the boot label, plus the current phase when known (no elapsed counter). */
|
|
170
|
+
private bootText(phase?: string): string {
|
|
171
|
+
return phase ? `${StartupLogger.BOOT_LABEL} · ${phase}` : StartupLogger.BOOT_LABEL;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Repaints the spinner line with the current phase and a live elapsed counter. */
|
|
175
|
+
private refreshBootText(): void {
|
|
176
|
+
if (this.spinner) {
|
|
177
|
+
const elapsed = ((performance.now() - this.bootStartMs) / 1000).toFixed(1);
|
|
178
|
+
this.spinner.text = `${this.bootText(this.currentPhase)} ${elapsed}s`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Begins the transient "Bootstrapping…" indicator, replaced by the 🚀 summary
|
|
184
|
+
* block once {@link PrintSummary} runs (so the rocket appears only after launch).
|
|
185
|
+
*
|
|
186
|
+
* - `standard` + TTY: an animated, self-clearing `ora` spinner (its glyph is the
|
|
187
|
+
* leading "working" icon; phase status is appended inline).
|
|
188
|
+
* - `verbose`/`debug`, or non-TTY at `standard`: a single plain line with an
|
|
189
|
+
* hourglass icon (can't be cleared, but inline phase logs / the final block
|
|
190
|
+
* carry the detail). `minimal` stays silent.
|
|
191
|
+
*/
|
|
192
|
+
public StartBoot(): void {
|
|
193
|
+
if (this.spinner) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (this.spinnerEnabled) {
|
|
197
|
+
this.bootStartMs = performance.now();
|
|
198
|
+
this.spinner = ora({ text: this.bootText(), stream: process.stdout }).start();
|
|
199
|
+
// Tick the elapsed counter independently of ora's glyph animation. Unref'd so
|
|
200
|
+
// it never keeps the event loop alive; cleared by StopBoot before the block prints.
|
|
201
|
+
this.bootTimer = setInterval(() => this.refreshBootText(), 200);
|
|
202
|
+
this.bootTimer.unref();
|
|
203
|
+
} else if (this.resolvedLevel !== 'minimal') {
|
|
204
|
+
// eslint-disable-next-line no-console
|
|
205
|
+
console.log(`⏳ ${this.bootText()}…`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Marks the beginning of a named phase: updates the spinner status (when active)
|
|
211
|
+
* and returns a start timestamp to pass to {@link EndPhase}. Pure timing helper
|
|
212
|
+
* when the spinner is disabled — equivalent to {@link StartPhase}.
|
|
213
|
+
*
|
|
214
|
+
* @param phase Friendly label for the upcoming phase, shown after the boot label.
|
|
215
|
+
*/
|
|
216
|
+
public BeginPhase(phase: string): number {
|
|
217
|
+
this.currentPhase = phase;
|
|
218
|
+
this.refreshBootText();
|
|
219
|
+
return performance.now();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Stops and clears the boot spinner + its elapsed-counter interval. Safe to call when inactive. */
|
|
223
|
+
public StopBoot(): void {
|
|
224
|
+
if (this.bootTimer) {
|
|
225
|
+
clearInterval(this.bootTimer);
|
|
226
|
+
this.bootTimer = null;
|
|
227
|
+
}
|
|
228
|
+
if (this.spinner) {
|
|
229
|
+
this.spinner.stop();
|
|
230
|
+
this.spinner = null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Records the elapsed time for a phase since `startedAt`, buffering it for the
|
|
236
|
+
* summary. At `verbose`+ the phase is also printed immediately (matching the
|
|
237
|
+
* legacy `⏱️ [Startup] X: Yms` lines); at `standard` it is collapsed into the
|
|
238
|
+
* one-line `Startup` summary printed by {@link PrintSummary}.
|
|
239
|
+
*
|
|
240
|
+
* @returns A fresh timestamp, so callers can chain phases ergonomically.
|
|
241
|
+
*/
|
|
242
|
+
public EndPhase(label: string, startedAt: number): number {
|
|
243
|
+
const ms = performance.now() - startedAt;
|
|
244
|
+
this.phaseTimings.push({ Label: label, Ms: ms });
|
|
245
|
+
if (this.IsAtLeast('verbose')) {
|
|
246
|
+
// eslint-disable-next-line no-console
|
|
247
|
+
console.log(`⏱️ [Startup] ${label}: ${ms.toFixed(0)}ms`);
|
|
248
|
+
}
|
|
249
|
+
return performance.now();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Records the server package version for the summary header. */
|
|
253
|
+
public SetVersion(version: string | undefined): void {
|
|
254
|
+
this.summary.Version = version;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Records the resolved config-file path for the summary `Config` line. */
|
|
258
|
+
public SetConfigPath(path: string | undefined): void {
|
|
259
|
+
this.summary.ConfigPath = path;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Records DB platform + connection + entity count for the summary `DB` line. */
|
|
263
|
+
public SetDatabaseInfo(platform: string, connection: string, entityCount: number): void {
|
|
264
|
+
this.summary.DbPlatform = platform;
|
|
265
|
+
this.summary.DbConnection = connection;
|
|
266
|
+
this.summary.EntityCount = entityCount;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Adds a registered auth-provider name to the summary `Auth` line. */
|
|
270
|
+
public AddAuthProvider(name: string): void {
|
|
271
|
+
this.summary.AuthProviders.push(name);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Records whether the REST API is enabled for the summary `Auth` line. */
|
|
275
|
+
public SetRestEnabled(enabled: boolean): void {
|
|
276
|
+
this.summary.RestEnabled = enabled;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Records the active scheduled-job count for the summary `Auth` line. */
|
|
280
|
+
public SetScheduledJobCount(count: number): void {
|
|
281
|
+
this.summary.ScheduledJobCount = count;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Records the ready URL for the summary `Ready` line. */
|
|
285
|
+
public SetReadyUrl(url: string): void {
|
|
286
|
+
this.summary.ReadyUrl = url;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Prints the boot summary appropriate for the active level:
|
|
291
|
+
* - `minimal`: only the `Ready <url>` line.
|
|
292
|
+
* - `standard`: the compact ~8-line summary block (with phases collapsed).
|
|
293
|
+
* - `verbose`/`debug`: the same compact block (individual phase lines and
|
|
294
|
+
* all detail lines were already printed inline during boot).
|
|
295
|
+
*/
|
|
296
|
+
public PrintSummary(): void {
|
|
297
|
+
// Clear the transient spinner before any block output so the line it
|
|
298
|
+
// occupied is replaced cleanly by the summary.
|
|
299
|
+
this.StopBoot();
|
|
300
|
+
if (this.resolvedLevel === 'minimal') {
|
|
301
|
+
this.printReadyLineOnly();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
this.printSummaryBlock();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Prints just the ready URL (minimal level). */
|
|
308
|
+
private printReadyLineOnly(): void {
|
|
309
|
+
if (this.summary.ReadyUrl) {
|
|
310
|
+
// eslint-disable-next-line no-console
|
|
311
|
+
console.log(`🚀 Ready ${this.summary.ReadyUrl}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Renders and prints the multi-line compact summary block. */
|
|
316
|
+
private printSummaryBlock(): void {
|
|
317
|
+
const lines = this.buildSummaryLines();
|
|
318
|
+
// eslint-disable-next-line no-console
|
|
319
|
+
console.log('\n' + lines.join('\n') + '\n');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Builds the array of summary lines (header + indented detail rows). */
|
|
323
|
+
private buildSummaryLines(): string[] {
|
|
324
|
+
const lines: string[] = [];
|
|
325
|
+
lines.push(this.buildHeaderLine());
|
|
326
|
+
lines.push(this.buildDbLine());
|
|
327
|
+
lines.push(this.buildConfigLine());
|
|
328
|
+
lines.push(this.buildAuthLine());
|
|
329
|
+
lines.push(this.buildStartupLine());
|
|
330
|
+
lines.push(this.buildReadyLine());
|
|
331
|
+
return lines.filter((l) => l.length > 0);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** `🚀 MemberJunction Server · v<version>` (version omitted if unknown). */
|
|
335
|
+
private buildHeaderLine(): string {
|
|
336
|
+
const version = this.summary.Version ? ` · v${this.summary.Version}` : '';
|
|
337
|
+
return `🚀 MemberJunction Server${version}`;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** ` DB <platform> · <connection> · <N> entities`. */
|
|
341
|
+
private buildDbLine(): string {
|
|
342
|
+
if (!this.summary.DbPlatform) {
|
|
343
|
+
return '';
|
|
344
|
+
}
|
|
345
|
+
const parts = [this.summary.DbPlatform];
|
|
346
|
+
if (this.summary.DbConnection) {
|
|
347
|
+
parts.push(this.summary.DbConnection);
|
|
348
|
+
}
|
|
349
|
+
if (this.summary.EntityCount != null) {
|
|
350
|
+
parts.push(`${this.summary.EntityCount} entities`);
|
|
351
|
+
}
|
|
352
|
+
return ` DB ${parts.join(' · ')}`;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** ` Config <path>` (omitted when no config file was resolved). */
|
|
356
|
+
private buildConfigLine(): string {
|
|
357
|
+
if (!this.summary.ConfigPath) {
|
|
358
|
+
return '';
|
|
359
|
+
}
|
|
360
|
+
return ` Config ${this.summary.ConfigPath}`;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** ` Auth <providers> REST <on/off> · <N> scheduled jobs`. */
|
|
364
|
+
private buildAuthLine(): string {
|
|
365
|
+
const providers = this.summary.AuthProviders.length > 0
|
|
366
|
+
? this.summary.AuthProviders.join(', ')
|
|
367
|
+
: 'none';
|
|
368
|
+
const rest = this.summary.RestEnabled == null
|
|
369
|
+
? ''
|
|
370
|
+
: `REST ${this.summary.RestEnabled ? 'on' : 'off'}`;
|
|
371
|
+
const jobs = this.summary.ScheduledJobCount == null
|
|
372
|
+
? ''
|
|
373
|
+
: `${this.summary.ScheduledJobCount} scheduled jobs`;
|
|
374
|
+
const trailer = [rest, jobs].filter((s) => s.length > 0).join(' · ');
|
|
375
|
+
const trailerPart = trailer ? ` ${trailer}` : '';
|
|
376
|
+
return ` Auth ${providers}${trailerPart}`;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* ` Startup <total>s (<phase> <x>s · … · other <z>s)`.
|
|
381
|
+
*
|
|
382
|
+
* The headline `<total>` is the TRUE wall-clock since process start — in Node,
|
|
383
|
+
* `performance.now()` is measured from `performance.timeOrigin` (≈ process
|
|
384
|
+
* start), so it captures the entire bootstrap (module import, config load,
|
|
385
|
+
* ServerBootstrap, and `serve()`), not just the timed phases. The parenthetical
|
|
386
|
+
* lists each captured phase; `other` is the unattributed remainder (import +
|
|
387
|
+
* config + any untimed setup) shown only when it's non-trivial.
|
|
388
|
+
*/
|
|
389
|
+
private buildStartupLine(): string {
|
|
390
|
+
if (this.phaseTimings.length === 0) {
|
|
391
|
+
return '';
|
|
392
|
+
}
|
|
393
|
+
const totalMs = performance.now();
|
|
394
|
+
const phaseSumMs = this.phaseTimings.reduce((sum, p) => sum + p.Ms, 0);
|
|
395
|
+
const otherMs = totalMs - phaseSumMs;
|
|
396
|
+
const parts = this.phaseTimings.map(
|
|
397
|
+
(p) => `${this.shortPhaseLabel(p.Label)} ${(p.Ms / 1000).toFixed(1)}s`,
|
|
398
|
+
);
|
|
399
|
+
// Surface unattributed boot time only when it's meaningful (>50ms), so the
|
|
400
|
+
// line stays clean when phases already account for ~all of startup.
|
|
401
|
+
if (otherMs > 50) {
|
|
402
|
+
parts.push(`other ${(otherMs / 1000).toFixed(1)}s`);
|
|
403
|
+
}
|
|
404
|
+
return ` Startup ${(totalMs / 1000).toFixed(1)}s (${parts.join(' · ')})`;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Abbreviates a verbose phase label into a compact token for the collapsed
|
|
409
|
+
* summary line (e.g. "Metadata + Provider Setup" → "metadata").
|
|
410
|
+
*/
|
|
411
|
+
private shortPhaseLabel(label: string): string {
|
|
412
|
+
const lower = label.toLowerCase();
|
|
413
|
+
if (lower.includes('metadata') || lower.includes('provider')) {
|
|
414
|
+
return 'metadata';
|
|
415
|
+
}
|
|
416
|
+
if (lower.includes('schema')) {
|
|
417
|
+
return 'schema';
|
|
418
|
+
}
|
|
419
|
+
if (lower.includes('db') || lower.includes('pool')) {
|
|
420
|
+
return 'db';
|
|
421
|
+
}
|
|
422
|
+
if (lower.includes('resolver') || lower.includes('middleware')) {
|
|
423
|
+
return 'resolvers';
|
|
424
|
+
}
|
|
425
|
+
if (lower.includes('apollo') || lower.includes('express')) {
|
|
426
|
+
return 'http';
|
|
427
|
+
}
|
|
428
|
+
if (lower.includes('telemetry') || lower.includes('cache')) {
|
|
429
|
+
return 'cache';
|
|
430
|
+
}
|
|
431
|
+
return lower.split(' ')[0];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** ` Ready <url>`. */
|
|
435
|
+
private buildReadyLine(): string {
|
|
436
|
+
if (!this.summary.ReadyUrl) {
|
|
437
|
+
return '';
|
|
438
|
+
}
|
|
439
|
+
return ` Ready ${this.summary.ReadyUrl}`;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
@@ -6,6 +6,22 @@ import { configInfo } from '../config.js';
|
|
|
6
6
|
import type { AppContext } from '../types.js';
|
|
7
7
|
import { redactArg } from './secretRedactor.js';
|
|
8
8
|
import { hasNoLogParameter, getNoLogFields } from './NoLog.js';
|
|
9
|
+
import { StartupLogger } from './StartupLogger.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Memoized "is the server log level `debug`?" check. The per-resolver
|
|
13
|
+
* variables echo is gated behind BOTH `logVariables` (opt-in redaction path)
|
|
14
|
+
* AND `level === 'debug'` — it is a raw, constantly-on debug line, so it should
|
|
15
|
+
* never fire unless an operator explicitly opted into debug verbosity. Config
|
|
16
|
+
* is immutable post-boot, so caching the resolution is safe.
|
|
17
|
+
*/
|
|
18
|
+
let isDebugLevelCache: boolean | undefined;
|
|
19
|
+
function isDebugLogLevel(): boolean {
|
|
20
|
+
if (isDebugLevelCache === undefined) {
|
|
21
|
+
isDebugLevelCache = StartupLogger.resolveLevelFromConfig() === 'debug';
|
|
22
|
+
}
|
|
23
|
+
return isDebugLevelCache;
|
|
24
|
+
}
|
|
9
25
|
|
|
10
26
|
/**
|
|
11
27
|
* Structural shape of a type-graphql `@Arg` parameter metadata entry. Mirrors the
|
|
@@ -147,11 +163,15 @@ export const variablesLoggingMiddleware: MiddlewareFn<AppContext> = async (actio
|
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
165
|
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
166
|
+
// Raw per-resolver variables echo — gated to debug-only so it never streams
|
|
167
|
+
// constantly even when an operator turns on logVariables at a lower level.
|
|
168
|
+
if (isDebugLogLevel()) {
|
|
169
|
+
// eslint-disable-next-line no-console
|
|
170
|
+
console.dir(
|
|
171
|
+
{ operation: action.info.fieldName, args: redactedArgs },
|
|
172
|
+
{ depth: null, breakLength: 200 },
|
|
173
|
+
);
|
|
174
|
+
}
|
|
155
175
|
|
|
156
176
|
if (hasUndecoratedCustomArg && resolverEntry) {
|
|
157
177
|
const signature = `${resolverEntry.target.name}.${resolverEntry.methodName}`;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GraphQL resolver for the AI Agent Session record lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Exposes start / close / heartbeat mutations over {@link SessionManager}, each running under the
|
|
5
|
+
* request's `contextUser` + request-scoped `IMetadataProvider`. Enforces two authorization gates:
|
|
6
|
+
* - **Open**: `CanRun` on the target agent (delegated to {@link SessionManager.CreateSession}).
|
|
7
|
+
* - **Close / Heartbeat**: inbound ownership — the session's `UserID` must equal `contextUser.ID`.
|
|
8
|
+
*
|
|
9
|
+
* The audio/media transport and the long-lived realtime run are out of scope here (P5); this
|
|
10
|
+
* resolver only manipulates the durable session record.
|
|
11
|
+
*
|
|
12
|
+
* @module @memberjunction/server
|
|
13
|
+
*/
|
|
14
|
+
import { Resolver, Mutation, Arg, Ctx, ObjectType, Field } from 'type-graphql';
|
|
15
|
+
import { AppContext } from '../types.js';
|
|
16
|
+
import { UserInfo, IMetadataProvider, LogError } from '@memberjunction/core';
|
|
17
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
18
|
+
import { MJAIAgentSessionEntity } from '@memberjunction/core-entities';
|
|
19
|
+
import { ResolverBase } from '../generic/ResolverBase.js';
|
|
20
|
+
import { GetReadWriteProvider } from '../util.js';
|
|
21
|
+
import { SessionManager, SessionAuthorizationError } from '../agentSessions/index.js';
|
|
22
|
+
|
|
23
|
+
/** Result of {@link AgentSessionResolver.StartAgentSession}. */
|
|
24
|
+
@ObjectType()
|
|
25
|
+
export class StartAgentSessionResult {
|
|
26
|
+
/** ID of the newly created session. */
|
|
27
|
+
@Field()
|
|
28
|
+
agentSessionId: string;
|
|
29
|
+
|
|
30
|
+
/** Lifecycle status of the session (always `Active` on a successful start). */
|
|
31
|
+
@Field()
|
|
32
|
+
status: string;
|
|
33
|
+
|
|
34
|
+
/** ID of the conversation the session is attached to (supplied or freshly created). */
|
|
35
|
+
@Field()
|
|
36
|
+
conversationId: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resolver for the AI Agent Session record lifecycle. A single {@link SessionManager} instance is
|
|
41
|
+
* shared across requests — it holds no per-user/provider state (only heartbeat-coalescing
|
|
42
|
+
* timestamps), and every method is passed the request `contextUser` + provider explicitly.
|
|
43
|
+
*/
|
|
44
|
+
@Resolver()
|
|
45
|
+
export class AgentSessionResolver extends ResolverBase {
|
|
46
|
+
private readonly sessionManager = new SessionManager();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Open a new session for an agent. Authorization (`CanRun`) is enforced inside
|
|
50
|
+
* {@link SessionManager.CreateSession}; a denial surfaces as a thrown error and no row is written.
|
|
51
|
+
*/
|
|
52
|
+
@Mutation(() => StartAgentSessionResult)
|
|
53
|
+
async StartAgentSession(
|
|
54
|
+
@Arg('agentId') agentId: string,
|
|
55
|
+
@Ctx() { userPayload, providers }: AppContext,
|
|
56
|
+
@Arg('conversationId', { nullable: true }) conversationId?: string,
|
|
57
|
+
@Arg('lastSessionId', { nullable: true }) lastSessionId?: string,
|
|
58
|
+
@Arg('configJson', { nullable: true }) configJson?: string,
|
|
59
|
+
): Promise<StartAgentSessionResult> {
|
|
60
|
+
const { contextUser, provider } = this.requireUserAndProvider(userPayload, providers);
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const session = await this.sessionManager.CreateSession(
|
|
64
|
+
{ agentID: agentId, userID: contextUser.ID, conversationID: conversationId, lastSessionID: lastSessionId, config: configJson },
|
|
65
|
+
contextUser,
|
|
66
|
+
provider,
|
|
67
|
+
);
|
|
68
|
+
return { agentSessionId: session.ID, status: session.Status, conversationId: session.ConversationID ?? '' };
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (err instanceof SessionAuthorizationError) {
|
|
71
|
+
throw new Error(err.message); // authorization denial — no session created
|
|
72
|
+
}
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Close a session. Rejects unless the caller owns it. Returns `true` on a successful (or
|
|
79
|
+
* idempotent) close, `false` if the session can't be loaded.
|
|
80
|
+
*/
|
|
81
|
+
@Mutation(() => Boolean)
|
|
82
|
+
async CloseAgentSession(
|
|
83
|
+
@Arg('agentSessionId') agentSessionId: string,
|
|
84
|
+
@Ctx() { userPayload, providers }: AppContext,
|
|
85
|
+
): Promise<boolean> {
|
|
86
|
+
const { contextUser, provider } = this.requireUserAndProvider(userPayload, providers);
|
|
87
|
+
await this.assertOwnership(agentSessionId, contextUser, provider);
|
|
88
|
+
return this.sessionManager.CloseSession(agentSessionId, contextUser, provider);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Record activity on a session (coalesced). Rejects unless the caller owns it. Returns `true`
|
|
93
|
+
* when the heartbeat was accepted (written or coalesced), `false` if the session is gone/closed.
|
|
94
|
+
*/
|
|
95
|
+
@Mutation(() => Boolean)
|
|
96
|
+
async AgentSessionHeartbeat(
|
|
97
|
+
@Arg('agentSessionId') agentSessionId: string,
|
|
98
|
+
@Ctx() { userPayload, providers }: AppContext,
|
|
99
|
+
): Promise<boolean> {
|
|
100
|
+
const { contextUser, provider } = this.requireUserAndProvider(userPayload, providers);
|
|
101
|
+
await this.assertOwnership(agentSessionId, contextUser, provider);
|
|
102
|
+
return this.sessionManager.Heartbeat(agentSessionId, contextUser, provider);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ----- internals -------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
/** Resolve the request user + read-write provider, throwing a clear error if unauthenticated. */
|
|
108
|
+
private requireUserAndProvider(
|
|
109
|
+
userPayload: AppContext['userPayload'],
|
|
110
|
+
providers: AppContext['providers'],
|
|
111
|
+
): { contextUser: UserInfo; provider: IMetadataProvider } {
|
|
112
|
+
const contextUser = this.GetUserFromPayload(userPayload);
|
|
113
|
+
if (!contextUser) {
|
|
114
|
+
throw new Error('Not authenticated: no user context for agent session operation');
|
|
115
|
+
}
|
|
116
|
+
return { contextUser, provider: GetReadWriteProvider(providers) };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Inbound ownership gate (the one genuinely new session-authz primitive): the session's `UserID`
|
|
121
|
+
* must equal the caller's. Throws on mismatch or when the session can't be loaded.
|
|
122
|
+
*/
|
|
123
|
+
private async assertOwnership(
|
|
124
|
+
agentSessionId: string,
|
|
125
|
+
contextUser: UserInfo,
|
|
126
|
+
provider: IMetadataProvider,
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
const session = await provider.GetEntityObject<MJAIAgentSessionEntity>('MJ: AI Agent Sessions', contextUser);
|
|
129
|
+
const loaded = await session.Load(agentSessionId);
|
|
130
|
+
if (!loaded) {
|
|
131
|
+
throw new Error(`Agent session ${agentSessionId} not found`);
|
|
132
|
+
}
|
|
133
|
+
if (!UUIDsEqual(session.UserID, contextUser.ID)) {
|
|
134
|
+
LogError(`AgentSessionResolver: ownership check failed — user ${contextUser.ID} attempted to operate on session ${agentSessionId} owned by ${session.UserID}`);
|
|
135
|
+
throw new Error('Not authorized: you do not own this agent session');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Arg, Ctx, Field, ObjectType, Query, Resolver } from 'type-graphql';
|
|
2
|
+
import { LogError } from '@memberjunction/core';
|
|
3
|
+
import { AppContext } from '../types.js';
|
|
4
|
+
import { ResolverBase } from '../generic/ResolverBase.js';
|
|
5
|
+
import { RequireSystemUser } from '../directives/RequireSystemUser.js';
|
|
6
|
+
import { GetReadOnlyProvider } from '../util.js';
|
|
7
|
+
import { UserCache } from '@memberjunction/sqlserver-dataprovider';
|
|
8
|
+
|
|
9
|
+
@ObjectType()
|
|
10
|
+
class EntityPermissionResult {
|
|
11
|
+
@Field(() => String)
|
|
12
|
+
declare EntityName: string;
|
|
13
|
+
|
|
14
|
+
@Field(() => Boolean)
|
|
15
|
+
declare CanRead: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ObjectType()
|
|
19
|
+
class CheckEntityPermissionsResult {
|
|
20
|
+
@Field(() => Boolean)
|
|
21
|
+
declare Success: boolean;
|
|
22
|
+
|
|
23
|
+
@Field(() => [EntityPermissionResult])
|
|
24
|
+
declare Results: EntityPermissionResult[];
|
|
25
|
+
|
|
26
|
+
@Field(() => String, { nullable: true })
|
|
27
|
+
ErrorMessage?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Resolver()
|
|
31
|
+
export class EntityPermissionResolver extends ResolverBase {
|
|
32
|
+
|
|
33
|
+
@RequireSystemUser()
|
|
34
|
+
@Query(() => CheckEntityPermissionsResult)
|
|
35
|
+
async CheckEntityPermissionsSystemUser(
|
|
36
|
+
@Arg('EntityNames', () => [String]) entityNames: string[],
|
|
37
|
+
@Arg('UserEmail', () => String) userEmail: string,
|
|
38
|
+
@Ctx() context: AppContext
|
|
39
|
+
): Promise<CheckEntityPermissionsResult> {
|
|
40
|
+
try {
|
|
41
|
+
const user = UserCache.Instance.Users.find(
|
|
42
|
+
u => u.Email.toLowerCase().trim() === userEmail.toLowerCase().trim()
|
|
43
|
+
);
|
|
44
|
+
if (!user) {
|
|
45
|
+
return { Success: false, Results: [], ErrorMessage: `User not found: ${userEmail}` };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Use the per-request provider (not the global default) so entity metadata + permission
|
|
49
|
+
// evaluation resolve against the connection servicing THIS request.
|
|
50
|
+
const md = GetReadOnlyProvider(context.providers, { allowFallbackToReadWrite: true });
|
|
51
|
+
const results: EntityPermissionResult[] = [];
|
|
52
|
+
|
|
53
|
+
for (const name of entityNames) {
|
|
54
|
+
const entityInfo = md.EntityByName(name);
|
|
55
|
+
if (!entityInfo) {
|
|
56
|
+
results.push({ EntityName: name, CanRead: false });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const perms = entityInfo.GetUserPermisions(user);
|
|
60
|
+
results.push({ EntityName: name, CanRead: perms?.CanRead ?? false });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { Success: true, Results: results };
|
|
64
|
+
} catch (err) {
|
|
65
|
+
LogError(err);
|
|
66
|
+
return {
|
|
67
|
+
Success: false,
|
|
68
|
+
Results: [],
|
|
69
|
+
ErrorMessage: `EntityPermissionResolver::CheckEntityPermissionsSystemUser --- ${err instanceof Error ? err.message : String(err)}`
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|