d365fo-mcp 1.26.1 → 1.26.2
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/bridge/bridgeClient.d.ts +50 -0
- package/dist/bridge/bridgeClient.js +131 -0
- package/dist/bridge/udeLaunchPaths.d.ts +20 -0
- package/dist/bridge/udeLaunchPaths.js +34 -0
- package/dist/config/settings.js +22 -0
- package/dist/index.js +19 -0
- package/dist/metadata/symbolIndex.d.ts +7 -0
- package/dist/metadata/symbolIndex.js +36 -1
- package/dist/scripts/build-database.js +52 -3
- package/dist/scripts/build-fts.js +52 -3
- package/dist/scripts/extract-binary-models.js +20 -0
- package/dist/scripts/extract-metadata.js +20 -0
- package/dist/scripts/startupIndexWorker.js +52 -3
- package/dist/server/transport.js +5 -0
- package/dist/tools/readers/classInfo.js +29 -5
- package/dist/tools/readers/diskFallback.d.ts +30 -0
- package/dist/tools/readers/diskFallback.js +61 -0
- package/dist/tools/readers/edtInfo.js +7 -0
- package/dist/tools/readers/formInfo.js +14 -0
- package/dist/tools/sdlc/modelReindex.d.ts +30 -1
- package/dist/tools/sdlc/modelReindex.js +98 -6
- package/dist/tools/sdlc/updateSymbolIndex.d.ts +17 -0
- package/dist/tools/sdlc/updateSymbolIndex.js +21 -0
- package/dist/tools/toolHandler.js +6 -2
- package/dist/utils/modelClassifier.d.ts +2 -0
- package/dist/utils/modelClassifier.js +4 -0
- package/dist/utils/nameArguments.d.ts +22 -0
- package/dist/utils/nameArguments.js +59 -0
- package/dist/utils/objectFileLookup.js +5 -2
- package/package.json +1 -1
|
@@ -41,6 +41,18 @@ export declare const READY_TIMEOUT_MS: number;
|
|
|
41
41
|
* retried against a respawned child.
|
|
42
42
|
*/
|
|
43
43
|
export declare function isTransientError(err: unknown): boolean;
|
|
44
|
+
/** The paths the child is started with. They decide which platform DLLs and metadata it loads. */
|
|
45
|
+
export interface BridgeLaunchPaths {
|
|
46
|
+
packagesPath: string;
|
|
47
|
+
referencePackagesPath?: string;
|
|
48
|
+
binPath?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One string per platform the child would load from these paths. The bin folder is resolved
|
|
52
|
+
* through junctions, so a `Current` link moved to a newer platform folder changes it even
|
|
53
|
+
* though the configured path string stays the same.
|
|
54
|
+
*/
|
|
55
|
+
export declare function launchFingerprint(paths: BridgeLaunchPaths): string;
|
|
44
56
|
export interface BridgeClientOptions {
|
|
45
57
|
axdb?: AxDbConfig;
|
|
46
58
|
/** Path to the D365MetadataBridge.exe (auto-detected if omitted) */
|
|
@@ -77,6 +89,17 @@ export interface BridgeClientOptions {
|
|
|
77
89
|
healthcheckMs?: number;
|
|
78
90
|
/** Max child respawns per 60s before giving up (default: BRIDGE_MAX_RESTARTS env or 3) */
|
|
79
91
|
maxRestarts?: number;
|
|
92
|
+
/**
|
|
93
|
+
* How often, at most, a call checks whether the platform under the child changed
|
|
94
|
+
* (default: BRIDGE_PLATFORM_CHECK_MS env or 60000, 0 = disabled).
|
|
95
|
+
*/
|
|
96
|
+
platformCheckMs?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Re-reads the launch paths from their source (UDE: the newest XPP config), so a platform
|
|
99
|
+
* update that writes a new config is followed. Without it, only junction moves under the
|
|
100
|
+
* paths the client was started with are detected. Returning null keeps the current paths.
|
|
101
|
+
*/
|
|
102
|
+
resolveLaunchPaths?: () => Promise<BridgeLaunchPaths | null> | BridgeLaunchPaths | null;
|
|
80
103
|
}
|
|
81
104
|
export declare class BridgeClient extends EventEmitter {
|
|
82
105
|
private process;
|
|
@@ -89,6 +112,14 @@ export declare class BridgeClient extends EventEmitter {
|
|
|
89
112
|
private restartPromise;
|
|
90
113
|
private restartTimestamps;
|
|
91
114
|
private healthTimer;
|
|
115
|
+
/** Fingerprint of the paths the running child was started with (see launchFingerprint). */
|
|
116
|
+
private startedFingerprint;
|
|
117
|
+
private lastPlatformCheck;
|
|
118
|
+
private platformCheck;
|
|
119
|
+
/** The folders the running child loaded, junctions resolved: the way back from a failed switch. */
|
|
120
|
+
private startedRealPaths;
|
|
121
|
+
/** The paths as configured. They stay watched even while the child runs on resolved ones. */
|
|
122
|
+
private watchedPaths;
|
|
92
123
|
readonly options: BridgeClientOptions;
|
|
93
124
|
private startedExePath;
|
|
94
125
|
constructor(options: BridgeClientOptions);
|
|
@@ -140,6 +171,24 @@ export declare class BridgeClient extends EventEmitter {
|
|
|
140
171
|
* crash loops — past the cap the error tells the user where to look.
|
|
141
172
|
*/
|
|
142
173
|
restart(): Promise<BridgeReadyPayload>;
|
|
174
|
+
/**
|
|
175
|
+
* Restart the child on the new platform when the platform under it changed.
|
|
176
|
+
*
|
|
177
|
+
* The child loads the platform DLLs once, at start, and keeps them loaded and locked. After a
|
|
178
|
+
* platform update (a new XPP config on UDE, or a `Current` junction moved to a newer folder) it
|
|
179
|
+
* kept answering from the old platform until the server restarted, and the old folder could
|
|
180
|
+
* not be removed. At most once per platformCheckMs, and only while no call is in flight (a
|
|
181
|
+
* restart rejects in-flight calls), this re-reads the launch paths and restarts on a change.
|
|
182
|
+
* A failed check or switch is logged and never fails the call that triggered it.
|
|
183
|
+
*/
|
|
184
|
+
private followPlatformChange;
|
|
185
|
+
/**
|
|
186
|
+
* Restart the child on `next`. A restart ends the old child first, so when the new platform
|
|
187
|
+
* does not start, or starts without the metadata the old one had, go back to the folders
|
|
188
|
+
* that worked: otherwise nothing would call the bridge again and it would stay unavailable
|
|
189
|
+
* until the server restarts.
|
|
190
|
+
*/
|
|
191
|
+
private switchPlatform;
|
|
143
192
|
/** Periodic idle ping (BRIDGE_HEALTHCHECK_MS > 0) — proactively respawns a dead/wedged child. */
|
|
144
193
|
private startHealthcheck;
|
|
145
194
|
/**
|
|
@@ -339,5 +388,6 @@ export declare function createBridgeClient(options: {
|
|
|
339
388
|
xrefServer?: string;
|
|
340
389
|
xrefDatabase?: string;
|
|
341
390
|
logFile?: string;
|
|
391
|
+
resolveLaunchPaths?: BridgeClientOptions['resolveLaunchPaths'];
|
|
342
392
|
}): Promise<BridgeClient | null>;
|
|
343
393
|
//# sourceMappingURL=bridgeClient.d.ts.map
|
|
@@ -68,7 +68,10 @@ const CALL_TIMEOUT_MS = envInt('BRIDGE_CALL_TIMEOUT_MS', 60_000); // 60s per cal
|
|
|
68
68
|
const MAX_RETRIES = envIntZero('BRIDGE_MAX_RETRIES', 2); // retries for READ calls only (0 = disabled)
|
|
69
69
|
const HEALTHCHECK_MS = envIntZero('BRIDGE_HEALTHCHECK_MS', 0); // idle ping interval (0 = disabled)
|
|
70
70
|
const MAX_RESTARTS = envInt('BRIDGE_MAX_RESTARTS', 3); // max child respawns per minute
|
|
71
|
+
const PLATFORM_CHECK_MS = envIntZero('BRIDGE_PLATFORM_CHECK_MS', 60_000); // platform-change check (0 = disabled)
|
|
71
72
|
const RESTART_WINDOW_MS = 60_000;
|
|
73
|
+
/** A platform that failed to start is tried again after this many check intervals. */
|
|
74
|
+
const FAILED_PLATFORM_BACKOFF = 10;
|
|
72
75
|
const PING_TIMEOUT_MS = 5_000;
|
|
73
76
|
const RETRY_BASE_DELAY_MS = 250;
|
|
74
77
|
const KILL_GRACE_MS = envInt('BRIDGE_KILL_GRACE_MS', 2_000); // stdin-end → SIGTERM
|
|
@@ -128,6 +131,43 @@ async function settledWithin(promise, ms) {
|
|
|
128
131
|
clearTimeout(timer);
|
|
129
132
|
}
|
|
130
133
|
}
|
|
134
|
+
/** The real path of `p` (junctions and symlinks followed), or `p` itself when it cannot be resolved. */
|
|
135
|
+
function realPathOrSelf(p) {
|
|
136
|
+
try {
|
|
137
|
+
return fs.realpathSync.native(p);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return p;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* One string per platform the child would load from these paths. The bin folder is resolved
|
|
145
|
+
* through junctions, so a `Current` link moved to a newer platform folder changes it even
|
|
146
|
+
* though the configured path string stays the same.
|
|
147
|
+
*/
|
|
148
|
+
export function launchFingerprint(paths) {
|
|
149
|
+
const bin = paths.binPath ?? path.join(paths.packagesPath, 'bin');
|
|
150
|
+
return [bin, paths.packagesPath, paths.referencePackagesPath ?? '']
|
|
151
|
+
.map(p => (p ? realPathOrSelf(p) : ''))
|
|
152
|
+
.join('|')
|
|
153
|
+
.toLowerCase();
|
|
154
|
+
}
|
|
155
|
+
/** Just the launch paths of `from`, all three set, so assigning them replaces every one. */
|
|
156
|
+
function launchPaths(from) {
|
|
157
|
+
return {
|
|
158
|
+
packagesPath: from.packagesPath,
|
|
159
|
+
referencePackagesPath: from.referencePackagesPath,
|
|
160
|
+
binPath: from.binPath,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** The same paths with junctions and symlinks followed. */
|
|
164
|
+
function realLaunchPaths(from) {
|
|
165
|
+
return {
|
|
166
|
+
packagesPath: realPathOrSelf(from.packagesPath),
|
|
167
|
+
referencePackagesPath: from.referencePackagesPath && realPathOrSelf(from.referencePackagesPath),
|
|
168
|
+
binPath: from.binPath && realPathOrSelf(from.binPath),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
131
171
|
export class BridgeClient extends EventEmitter {
|
|
132
172
|
process = null;
|
|
133
173
|
lineReader = new BridgeLineReader();
|
|
@@ -139,11 +179,20 @@ export class BridgeClient extends EventEmitter {
|
|
|
139
179
|
restartPromise = null;
|
|
140
180
|
restartTimestamps = [];
|
|
141
181
|
healthTimer = null;
|
|
182
|
+
/** Fingerprint of the paths the running child was started with (see launchFingerprint). */
|
|
183
|
+
startedFingerprint;
|
|
184
|
+
lastPlatformCheck = 0;
|
|
185
|
+
platformCheck = null;
|
|
186
|
+
/** The folders the running child loaded, junctions resolved: the way back from a failed switch. */
|
|
187
|
+
startedRealPaths;
|
|
188
|
+
/** The paths as configured. They stay watched even while the child runs on resolved ones. */
|
|
189
|
+
watchedPaths;
|
|
142
190
|
options;
|
|
143
191
|
startedExePath;
|
|
144
192
|
constructor(options) {
|
|
145
193
|
super();
|
|
146
194
|
this.options = options;
|
|
195
|
+
this.watchedPaths = launchPaths(options);
|
|
147
196
|
}
|
|
148
197
|
/** Whether the bridge process is running and the metadata provider initialized */
|
|
149
198
|
get isReady() { return this._isReady && !this._disposed; }
|
|
@@ -175,6 +224,9 @@ export class BridgeClient extends EventEmitter {
|
|
|
175
224
|
async spawnAndWaitReady() {
|
|
176
225
|
const exePath = this.resolveBridgeExe();
|
|
177
226
|
this.startedExePath = exePath;
|
|
227
|
+
this.startedFingerprint = launchFingerprint(this.options);
|
|
228
|
+
this.startedRealPaths = realLaunchPaths(this.options);
|
|
229
|
+
this.lastPlatformCheck = Date.now();
|
|
178
230
|
const args = [
|
|
179
231
|
'--packages-path', this.options.packagesPath,
|
|
180
232
|
];
|
|
@@ -338,6 +390,7 @@ export class BridgeClient extends EventEmitter {
|
|
|
338
390
|
const maxRetries = RETRYABLE_METHODS.has(method) ? (this.options.maxRetries ?? MAX_RETRIES) : 0;
|
|
339
391
|
for (let attempt = 0;; attempt++) {
|
|
340
392
|
try {
|
|
393
|
+
await this.followPlatformChange();
|
|
341
394
|
if (this.restartPromise)
|
|
342
395
|
await this.restartPromise;
|
|
343
396
|
return await this.callOnce(method, params);
|
|
@@ -356,6 +409,7 @@ export class BridgeClient extends EventEmitter {
|
|
|
356
409
|
}
|
|
357
410
|
/** Live SQL is never replayed, including reads. Server SQL budget is at most 45s. */
|
|
358
411
|
async callAxDb(method, params) {
|
|
412
|
+
await this.followPlatformChange();
|
|
359
413
|
if (this.restartPromise)
|
|
360
414
|
await this.restartPromise;
|
|
361
415
|
return this.callOnce(method, params, 50_000);
|
|
@@ -468,6 +522,83 @@ export class BridgeClient extends EventEmitter {
|
|
|
468
522
|
}
|
|
469
523
|
return this.readyPayload;
|
|
470
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Restart the child on the new platform when the platform under it changed.
|
|
527
|
+
*
|
|
528
|
+
* The child loads the platform DLLs once, at start, and keeps them loaded and locked. After a
|
|
529
|
+
* platform update (a new XPP config on UDE, or a `Current` junction moved to a newer folder) it
|
|
530
|
+
* kept answering from the old platform until the server restarted, and the old folder could
|
|
531
|
+
* not be removed. At most once per platformCheckMs, and only while no call is in flight (a
|
|
532
|
+
* restart rejects in-flight calls), this re-reads the launch paths and restarts on a change.
|
|
533
|
+
* A failed check or switch is logged and never fails the call that triggered it.
|
|
534
|
+
*/
|
|
535
|
+
followPlatformChange() {
|
|
536
|
+
if (this.platformCheck)
|
|
537
|
+
return this.platformCheck;
|
|
538
|
+
const intervalMs = this.options.platformCheckMs ?? PLATFORM_CHECK_MS;
|
|
539
|
+
if (!intervalMs || !this._isReady || this._disposed || this.restartPromise || !this.startedFingerprint) {
|
|
540
|
+
return Promise.resolve();
|
|
541
|
+
}
|
|
542
|
+
if (Date.now() - this.lastPlatformCheck < intervalMs)
|
|
543
|
+
return Promise.resolve();
|
|
544
|
+
if (this.pending.size > 0)
|
|
545
|
+
return Promise.resolve(); // checked again by the next call
|
|
546
|
+
this.platformCheck = (async () => {
|
|
547
|
+
this.lastPlatformCheck = Date.now();
|
|
548
|
+
try {
|
|
549
|
+
const next = (await this.options.resolveLaunchPaths?.()) ?? this.watchedPaths;
|
|
550
|
+
if (launchFingerprint(next) === this.startedFingerprint)
|
|
551
|
+
return;
|
|
552
|
+
// A link that points nowhere, or a folder still being filled: keep the running child.
|
|
553
|
+
if (!fs.existsSync(next.binPath ?? path.join(next.packagesPath, 'bin')))
|
|
554
|
+
return;
|
|
555
|
+
if (this.pending.size > 0 || this._disposed) {
|
|
556
|
+
this.lastPlatformCheck = 0; // a call started meanwhile: try again on the next one
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const bin = realPathOrSelf(next.binPath ?? path.join(next.packagesPath, 'bin'));
|
|
560
|
+
console.error(`[BridgeClient] The platform changed (bin ${bin}). Restarting the bridge on it.`);
|
|
561
|
+
await this.switchPlatform(next);
|
|
562
|
+
}
|
|
563
|
+
catch (err) {
|
|
564
|
+
console.error(`[BridgeClient] Platform check failed: ${err instanceof Error ? err.message : err}`);
|
|
565
|
+
}
|
|
566
|
+
})().finally(() => {
|
|
567
|
+
this.platformCheck = null;
|
|
568
|
+
});
|
|
569
|
+
return this.platformCheck;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Restart the child on `next`. A restart ends the old child first, so when the new platform
|
|
573
|
+
* does not start, or starts without the metadata the old one had, go back to the folders
|
|
574
|
+
* that worked: otherwise nothing would call the bridge again and it would stay unavailable
|
|
575
|
+
* until the server restarts.
|
|
576
|
+
*/
|
|
577
|
+
async switchPlatform(next) {
|
|
578
|
+
const previous = this.startedRealPaths ?? launchPaths(this.options);
|
|
579
|
+
const watched = this.watchedPaths;
|
|
580
|
+
const hadMetadata = this.metadataAvailable;
|
|
581
|
+
Object.assign(this.options, launchPaths(next));
|
|
582
|
+
try {
|
|
583
|
+
await this.restart();
|
|
584
|
+
if (hadMetadata && !this.metadataAvailable)
|
|
585
|
+
throw new Error('it started without metadata');
|
|
586
|
+
this.watchedPaths = launchPaths(next);
|
|
587
|
+
}
|
|
588
|
+
catch (err) {
|
|
589
|
+
console.error(`[BridgeClient] The new platform did not start (${err instanceof Error ? err.message : err}). ` +
|
|
590
|
+
'Going back to the previous one; it is tried again later.');
|
|
591
|
+
Object.assign(this.options, previous);
|
|
592
|
+
this.watchedPaths = watched;
|
|
593
|
+
try {
|
|
594
|
+
await this.restart();
|
|
595
|
+
}
|
|
596
|
+
finally {
|
|
597
|
+
const intervalMs = this.options.platformCheckMs ?? PLATFORM_CHECK_MS;
|
|
598
|
+
this.lastPlatformCheck = Date.now() + (FAILED_PLATFORM_BACKOFF - 1) * intervalMs;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
471
602
|
/** Periodic idle ping (BRIDGE_HEALTHCHECK_MS > 0) — proactively respawns a dead/wedged child. */
|
|
472
603
|
startHealthcheck() {
|
|
473
604
|
const intervalMs = this.options.healthcheckMs ?? HEALTHCHECK_MS;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UDE: where the bridge should load the platform from now.
|
|
3
|
+
*
|
|
4
|
+
* Only the platform moves. The server resolves its model store, its path checks and its
|
|
5
|
+
* symbol index from the XPP config it started with, so the bridge — which writes into
|
|
6
|
+
* `packagesPath` — must stay on that environment: a config of another environment is never
|
|
7
|
+
* followed, however new it is, and `packagesPath` is always the one the child started with.
|
|
8
|
+
*/
|
|
9
|
+
import { XppConfigProvider, type XppEnvironmentConfig } from '../utils/xppConfigProvider.js';
|
|
10
|
+
import type { BridgeLaunchPaths } from './bridgeClient.js';
|
|
11
|
+
/**
|
|
12
|
+
* The launch paths of the newest XPP config of the started environment (same config name
|
|
13
|
+
* and model store; `pin` is XPP_CONFIG_NAME), or null to keep the current paths: no such
|
|
14
|
+
* config, or its platform folder has no `bin` yet.
|
|
15
|
+
*/
|
|
16
|
+
export declare function udeLaunchPaths(started: {
|
|
17
|
+
config: XppEnvironmentConfig;
|
|
18
|
+
packagesPath: string;
|
|
19
|
+
}, pin: string | undefined, provider?: XppConfigProvider): Promise<BridgeLaunchPaths | null>;
|
|
20
|
+
//# sourceMappingURL=udeLaunchPaths.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UDE: where the bridge should load the platform from now.
|
|
3
|
+
*
|
|
4
|
+
* Only the platform moves. The server resolves its model store, its path checks and its
|
|
5
|
+
* symbol index from the XPP config it started with, so the bridge — which writes into
|
|
6
|
+
* `packagesPath` — must stay on that environment: a config of another environment is never
|
|
7
|
+
* followed, however new it is, and `packagesPath` is always the one the child started with.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
import * as path from 'node:path';
|
|
11
|
+
import { XppConfigProvider } from '../utils/xppConfigProvider.js';
|
|
12
|
+
const folderKey = (p) => path.resolve(p).toLowerCase();
|
|
13
|
+
/**
|
|
14
|
+
* The launch paths of the newest XPP config of the started environment (same config name
|
|
15
|
+
* and model store; `pin` is XPP_CONFIG_NAME), or null to keep the current paths: no such
|
|
16
|
+
* config, or its platform folder has no `bin` yet.
|
|
17
|
+
*/
|
|
18
|
+
export async function udeLaunchPaths(started, pin, provider = new XppConfigProvider()) {
|
|
19
|
+
// listConfigs sorts newest first.
|
|
20
|
+
const next = (await provider.listConfigs()).find(c => c.configName === started.config.configName
|
|
21
|
+
&& (!pin || c.configName === pin || c.fullFilename === pin)
|
|
22
|
+
&& folderKey(c.customPackagesPath) === folderKey(started.config.customPackagesPath));
|
|
23
|
+
if (!next)
|
|
24
|
+
return null;
|
|
25
|
+
const binPath = path.join(next.microsoftPackagesPath, 'bin');
|
|
26
|
+
if (!existsSync(binPath))
|
|
27
|
+
return null;
|
|
28
|
+
return {
|
|
29
|
+
packagesPath: started.packagesPath,
|
|
30
|
+
referencePackagesPath: next.microsoftPackagesPath,
|
|
31
|
+
binPath,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=udeLaunchPaths.js.map
|
package/dist/config/settings.js
CHANGED
|
@@ -531,6 +531,18 @@ export const SETTINGS = [
|
|
|
531
531
|
'and shrinks the index, at the cost of label lookup.',
|
|
532
532
|
default: true,
|
|
533
533
|
},
|
|
534
|
+
{
|
|
535
|
+
path: 'index.reindexChangedOnStartup',
|
|
536
|
+
env: 'REINDEX_CHANGED_ON_STARTUP',
|
|
537
|
+
section: 'index',
|
|
538
|
+
tier: 'advanced',
|
|
539
|
+
type: 'boolean',
|
|
540
|
+
label: 'Re-index changed custom models on start',
|
|
541
|
+
description: 'Shortly after start, re-index the files of the custom models of the workspace that changed while the server was ' +
|
|
542
|
+
'not running (a git pull, a branch switch, a Visual Studio session), in the background, as ' +
|
|
543
|
+
'update_symbol_index(model) does. Off = the index stays as it was until update_symbol_index runs.',
|
|
544
|
+
default: true,
|
|
545
|
+
},
|
|
534
546
|
{
|
|
535
547
|
path: 'index.labelLanguages',
|
|
536
548
|
env: 'LABEL_LANGUAGES',
|
|
@@ -976,6 +988,16 @@ export const SETTINGS = [
|
|
|
976
988
|
description: 'Circuit breaker: after this many respawns within 60 s the server stops trying.',
|
|
977
989
|
default: 3,
|
|
978
990
|
},
|
|
991
|
+
{
|
|
992
|
+
path: 'bridge.platformCheckMs',
|
|
993
|
+
env: 'BRIDGE_PLATFORM_CHECK_MS',
|
|
994
|
+
section: 'bridge',
|
|
995
|
+
tier: 'advanced',
|
|
996
|
+
type: 'int',
|
|
997
|
+
label: 'Platform check interval (ms)',
|
|
998
|
+
description: 'How often, at most, a bridge call checks whether the platform changed (a new XPP config, or a junction moved to a newer platform folder) and restarts the bridge on it. 0 = off.',
|
|
999
|
+
default: 60000,
|
|
1000
|
+
},
|
|
979
1001
|
{
|
|
980
1002
|
path: 'bridge.exePath',
|
|
981
1003
|
env: 'D365FO_BRIDGE_EXE_PATH',
|
package/dist/index.js
CHANGED
|
@@ -528,11 +528,26 @@ async function initializeBridge(targetContext) {
|
|
|
528
528
|
catch (error) {
|
|
529
529
|
console.error(`[AxDB] SQL configuration unavailable: ${error}`);
|
|
530
530
|
}
|
|
531
|
+
// UDE: a platform update writes a new XPP config whose FrameworkDirectory is the new
|
|
532
|
+
// platform folder. The bridge re-reads it (at most once a minute, see BridgeClient) and
|
|
533
|
+
// restarts on the new platform instead of serving the old one until the server restarts.
|
|
534
|
+
// Paths pinned in .mcp.json context are the user's choice and are not followed.
|
|
535
|
+
const startedXpp = devEnvType === 'ude' && !configMgr.getContext()?.microsoftPackagesPath
|
|
536
|
+
? await configMgr.getActiveXppConfig()
|
|
537
|
+
: null;
|
|
538
|
+
const startedPackagesPath = packagesPath;
|
|
539
|
+
const resolveLaunchPaths = startedXpp && startedPackagesPath
|
|
540
|
+
? async () => {
|
|
541
|
+
const { udeLaunchPaths } = await import('./bridge/udeLaunchPaths.js');
|
|
542
|
+
return udeLaunchPaths({ config: startedXpp, packagesPath: startedPackagesPath }, process.env.XPP_CONFIG_NAME || undefined);
|
|
543
|
+
}
|
|
544
|
+
: undefined;
|
|
531
545
|
const bridge = await createBridgeClient({
|
|
532
546
|
axdb,
|
|
533
547
|
packagesPath,
|
|
534
548
|
referencePackagesPath,
|
|
535
549
|
binPath,
|
|
550
|
+
resolveLaunchPaths,
|
|
536
551
|
xrefServer,
|
|
537
552
|
xrefDatabase,
|
|
538
553
|
logFile: configMgr.getContext()?.bridgeLogFile ?? undefined,
|
|
@@ -774,6 +789,9 @@ async function main() {
|
|
|
774
789
|
// Resolve dbReady AFTER context is patched — tools can now run with real index.
|
|
775
790
|
resolveDbReady();
|
|
776
791
|
log.ok(`Database loaded in ${Date.now() - dbLoadStart} ms — all tools fully operational`);
|
|
792
|
+
// Files changed while the server was down (git pull, branch switch, VS) are
|
|
793
|
+
// re-indexed once in the background, so reads do not miss them.
|
|
794
|
+
void import('./tools/sdlc/modelReindex.js').then(m => m.scheduleStartupReindex(stubContext, line => log.detail(line)));
|
|
777
795
|
// The in-memory stub symbol index is also unreachable once swapped.
|
|
778
796
|
try {
|
|
779
797
|
stubIndex.close();
|
|
@@ -911,6 +929,7 @@ async function main() {
|
|
|
911
929
|
if (status.detail)
|
|
912
930
|
log.detail(status.detail);
|
|
913
931
|
logXrefSqlite(context);
|
|
932
|
+
void import('./tools/sdlc/modelReindex.js').then(m => m.scheduleStartupReindex(context, line => log.detail(line)));
|
|
914
933
|
}
|
|
915
934
|
console.log('');
|
|
916
935
|
const toolCatalog = [
|
|
@@ -810,6 +810,13 @@ export declare class XppSymbolIndex {
|
|
|
810
810
|
*/
|
|
811
811
|
getAllLabelFilePaths(): string[];
|
|
812
812
|
/** ISO timestamp of the last full or incremental index update, or null. */
|
|
813
|
+
/**
|
|
814
|
+
* The moment up to which this model's files are known to be in the index: the start of
|
|
815
|
+
* the build that indexed it, or of the last start-up pass that brought it up to date.
|
|
816
|
+
* Unlike last_indexed_at, a single file write does not move it.
|
|
817
|
+
*/
|
|
818
|
+
getModelSyncedAt(model: string): string | null;
|
|
819
|
+
setModelSyncedAt(model: string, isoTime: string): void;
|
|
813
820
|
getLastIndexedAt(): string | null;
|
|
814
821
|
/**
|
|
815
822
|
* Record one observation of a metadata property value.
|
|
@@ -2279,6 +2279,7 @@ export class XppSymbolIndex {
|
|
|
2279
2279
|
return wrapped;
|
|
2280
2280
|
}
|
|
2281
2281
|
async indexMetadataDirectory(metadataPath, modelNames, opts) {
|
|
2282
|
+
const startedAt = new Date().toISOString();
|
|
2282
2283
|
// Never let a progress listener's own failure abort an index build.
|
|
2283
2284
|
const report = (p) => {
|
|
2284
2285
|
try {
|
|
@@ -2515,6 +2516,8 @@ export class XppSymbolIndex {
|
|
|
2515
2516
|
log.ok(`Indexed ${models.length} model(s) in ${duration}s (FTS rebuilt in ${ftsDuration}s)`);
|
|
2516
2517
|
}
|
|
2517
2518
|
this.touchLastIndexed();
|
|
2519
|
+
for (const model of models)
|
|
2520
|
+
this.setModelSyncedAt(model, startedAt);
|
|
2518
2521
|
}
|
|
2519
2522
|
/**
|
|
2520
2523
|
* Sort models by JSON file count descending.
|
|
@@ -3494,7 +3497,17 @@ export class XppSymbolIndex {
|
|
|
3494
3497
|
}
|
|
3495
3498
|
/** Every distinct file path the symbols table holds for a model. */
|
|
3496
3499
|
getModelFilePaths(model) {
|
|
3497
|
-
const
|
|
3500
|
+
const db = this.getReadDb();
|
|
3501
|
+
// `model = ? COLLATE NOCASE` cannot use an index on model: on a 2.5 GB database it
|
|
3502
|
+
// scanned all of symbols, 1.3-1.8 s on the event loop. Find the stored spelling(s)
|
|
3503
|
+
// first (a few ms), then match them exactly.
|
|
3504
|
+
const key = model.toLowerCase();
|
|
3505
|
+
const spellings = db.prepare(`SELECT DISTINCT model FROM symbols`).all()
|
|
3506
|
+
.map(r => r.model)
|
|
3507
|
+
.filter(m => m?.toLowerCase() === key);
|
|
3508
|
+
if (spellings.length === 0)
|
|
3509
|
+
return [];
|
|
3510
|
+
const rows = db.prepare(`SELECT DISTINCT file_path FROM symbols WHERE model IN (${spellings.map(() => '?').join(', ')})`).all(...spellings);
|
|
3498
3511
|
return rows.map(r => r.file_path);
|
|
3499
3512
|
}
|
|
3500
3513
|
/** Every path indexed_files records for a model, as stored. */
|
|
@@ -3516,6 +3529,28 @@ export class XppSymbolIndex {
|
|
|
3516
3529
|
}
|
|
3517
3530
|
}
|
|
3518
3531
|
/** ISO timestamp of the last full or incremental index update, or null. */
|
|
3532
|
+
/**
|
|
3533
|
+
* The moment up to which this model's files are known to be in the index: the start of
|
|
3534
|
+
* the build that indexed it, or of the last start-up pass that brought it up to date.
|
|
3535
|
+
* Unlike last_indexed_at, a single file write does not move it.
|
|
3536
|
+
*/
|
|
3537
|
+
getModelSyncedAt(model) {
|
|
3538
|
+
try {
|
|
3539
|
+
const row = this.getReadDb().prepare(`SELECT value FROM _index_meta WHERE key = ?`).get(`model_synced_at:${model.toLowerCase()}`);
|
|
3540
|
+
return row?.value ?? null;
|
|
3541
|
+
}
|
|
3542
|
+
catch {
|
|
3543
|
+
return null;
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
setModelSyncedAt(model, isoTime) {
|
|
3547
|
+
try {
|
|
3548
|
+
this.db.prepare(`INSERT OR REPLACE INTO _index_meta (key, value) VALUES (?, ?)`).run(`model_synced_at:${model.toLowerCase()}`, isoTime);
|
|
3549
|
+
}
|
|
3550
|
+
catch {
|
|
3551
|
+
// Bookkeeping is best-effort
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3519
3554
|
getLastIndexedAt() {
|
|
3520
3555
|
try {
|
|
3521
3556
|
const row = this.getReadDb().prepare(`SELECT value FROM _index_meta WHERE key = 'last_indexed_at'`).get();
|
|
@@ -555,6 +555,16 @@ var SETTINGS = [
|
|
|
555
555
|
description: 'Builds the labels database so labels(action="search") and label reuse work. Disabling it speeds up the build and shrinks the index, at the cost of label lookup.',
|
|
556
556
|
default: true
|
|
557
557
|
},
|
|
558
|
+
{
|
|
559
|
+
path: "index.reindexChangedOnStartup",
|
|
560
|
+
env: "REINDEX_CHANGED_ON_STARTUP",
|
|
561
|
+
section: "index",
|
|
562
|
+
tier: "advanced",
|
|
563
|
+
type: "boolean",
|
|
564
|
+
label: "Re-index changed custom models on start",
|
|
565
|
+
description: "Shortly after start, re-index the files of the custom models of the workspace that changed while the server was not running (a git pull, a branch switch, a Visual Studio session), in the background, as update_symbol_index(model) does. Off = the index stays as it was until update_symbol_index runs.",
|
|
566
|
+
default: true
|
|
567
|
+
},
|
|
558
568
|
{
|
|
559
569
|
path: "index.labelLanguages",
|
|
560
570
|
env: "LABEL_LANGUAGES",
|
|
@@ -954,6 +964,16 @@ var SETTINGS = [
|
|
|
954
964
|
description: "Circuit breaker: after this many respawns within 60 s the server stops trying.",
|
|
955
965
|
default: 3
|
|
956
966
|
},
|
|
967
|
+
{
|
|
968
|
+
path: "bridge.platformCheckMs",
|
|
969
|
+
env: "BRIDGE_PLATFORM_CHECK_MS",
|
|
970
|
+
section: "bridge",
|
|
971
|
+
tier: "advanced",
|
|
972
|
+
type: "int",
|
|
973
|
+
label: "Platform check interval (ms)",
|
|
974
|
+
description: "How often, at most, a bridge call checks whether the platform changed (a new XPP config, or a junction moved to a newer platform folder) and restarts the bridge on it. 0 = off.",
|
|
975
|
+
default: 6e4
|
|
976
|
+
},
|
|
957
977
|
{
|
|
958
978
|
path: "bridge.exePath",
|
|
959
979
|
env: "D365FO_BRIDGE_EXE_PATH",
|
|
@@ -3591,6 +3611,7 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
3591
3611
|
return wrapped;
|
|
3592
3612
|
}
|
|
3593
3613
|
async indexMetadataDirectory(metadataPath, modelNames, opts) {
|
|
3614
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3594
3615
|
const report = (p) => {
|
|
3595
3616
|
try {
|
|
3596
3617
|
opts?.onProgress?.(p);
|
|
@@ -3748,6 +3769,7 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
3748
3769
|
log.ok(`Indexed ${models.length} model(s) in ${duration}s (FTS rebuilt in ${ftsDuration}s)`);
|
|
3749
3770
|
}
|
|
3750
3771
|
this.touchLastIndexed();
|
|
3772
|
+
for (const model of models) this.setModelSyncedAt(model, startedAt);
|
|
3751
3773
|
}
|
|
3752
3774
|
/**
|
|
3753
3775
|
* Sort models by JSON file count descending.
|
|
@@ -4730,9 +4752,13 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
4730
4752
|
}
|
|
4731
4753
|
/** Every distinct file path the symbols table holds for a model. */
|
|
4732
4754
|
getModelFilePaths(model) {
|
|
4733
|
-
const
|
|
4734
|
-
|
|
4735
|
-
).all(model);
|
|
4755
|
+
const db = this.getReadDb();
|
|
4756
|
+
const key = model.toLowerCase();
|
|
4757
|
+
const spellings = db.prepare(`SELECT DISTINCT model FROM symbols`).all().map((r) => r.model).filter((m) => m?.toLowerCase() === key);
|
|
4758
|
+
if (spellings.length === 0) return [];
|
|
4759
|
+
const rows = db.prepare(
|
|
4760
|
+
`SELECT DISTINCT file_path FROM symbols WHERE model IN (${spellings.map(() => "?").join(", ")})`
|
|
4761
|
+
).all(...spellings);
|
|
4736
4762
|
return rows.map((r) => r.file_path);
|
|
4737
4763
|
}
|
|
4738
4764
|
/** Every path indexed_files records for a model, as stored. */
|
|
@@ -4755,6 +4781,29 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
4755
4781
|
}
|
|
4756
4782
|
}
|
|
4757
4783
|
/** ISO timestamp of the last full or incremental index update, or null. */
|
|
4784
|
+
/**
|
|
4785
|
+
* The moment up to which this model's files are known to be in the index: the start of
|
|
4786
|
+
* the build that indexed it, or of the last start-up pass that brought it up to date.
|
|
4787
|
+
* Unlike last_indexed_at, a single file write does not move it.
|
|
4788
|
+
*/
|
|
4789
|
+
getModelSyncedAt(model) {
|
|
4790
|
+
try {
|
|
4791
|
+
const row = this.getReadDb().prepare(
|
|
4792
|
+
`SELECT value FROM _index_meta WHERE key = ?`
|
|
4793
|
+
).get(`model_synced_at:${model.toLowerCase()}`);
|
|
4794
|
+
return row?.value ?? null;
|
|
4795
|
+
} catch {
|
|
4796
|
+
return null;
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
setModelSyncedAt(model, isoTime) {
|
|
4800
|
+
try {
|
|
4801
|
+
this.db.prepare(
|
|
4802
|
+
`INSERT OR REPLACE INTO _index_meta (key, value) VALUES (?, ?)`
|
|
4803
|
+
).run(`model_synced_at:${model.toLowerCase()}`, isoTime);
|
|
4804
|
+
} catch {
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4758
4807
|
getLastIndexedAt() {
|
|
4759
4808
|
try {
|
|
4760
4809
|
const row = this.getReadDb().prepare(
|
|
@@ -555,6 +555,16 @@ var SETTINGS = [
|
|
|
555
555
|
description: 'Builds the labels database so labels(action="search") and label reuse work. Disabling it speeds up the build and shrinks the index, at the cost of label lookup.',
|
|
556
556
|
default: true
|
|
557
557
|
},
|
|
558
|
+
{
|
|
559
|
+
path: "index.reindexChangedOnStartup",
|
|
560
|
+
env: "REINDEX_CHANGED_ON_STARTUP",
|
|
561
|
+
section: "index",
|
|
562
|
+
tier: "advanced",
|
|
563
|
+
type: "boolean",
|
|
564
|
+
label: "Re-index changed custom models on start",
|
|
565
|
+
description: "Shortly after start, re-index the files of the custom models of the workspace that changed while the server was not running (a git pull, a branch switch, a Visual Studio session), in the background, as update_symbol_index(model) does. Off = the index stays as it was until update_symbol_index runs.",
|
|
566
|
+
default: true
|
|
567
|
+
},
|
|
558
568
|
{
|
|
559
569
|
path: "index.labelLanguages",
|
|
560
570
|
env: "LABEL_LANGUAGES",
|
|
@@ -954,6 +964,16 @@ var SETTINGS = [
|
|
|
954
964
|
description: "Circuit breaker: after this many respawns within 60 s the server stops trying.",
|
|
955
965
|
default: 3
|
|
956
966
|
},
|
|
967
|
+
{
|
|
968
|
+
path: "bridge.platformCheckMs",
|
|
969
|
+
env: "BRIDGE_PLATFORM_CHECK_MS",
|
|
970
|
+
section: "bridge",
|
|
971
|
+
tier: "advanced",
|
|
972
|
+
type: "int",
|
|
973
|
+
label: "Platform check interval (ms)",
|
|
974
|
+
description: "How often, at most, a bridge call checks whether the platform changed (a new XPP config, or a junction moved to a newer platform folder) and restarts the bridge on it. 0 = off.",
|
|
975
|
+
default: 6e4
|
|
976
|
+
},
|
|
957
977
|
{
|
|
958
978
|
path: "bridge.exePath",
|
|
959
979
|
env: "D365FO_BRIDGE_EXE_PATH",
|
|
@@ -3530,6 +3550,7 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
3530
3550
|
return wrapped;
|
|
3531
3551
|
}
|
|
3532
3552
|
async indexMetadataDirectory(metadataPath, modelNames, opts) {
|
|
3553
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3533
3554
|
const report = (p) => {
|
|
3534
3555
|
try {
|
|
3535
3556
|
opts?.onProgress?.(p);
|
|
@@ -3687,6 +3708,7 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
3687
3708
|
log.ok(`Indexed ${models.length} model(s) in ${duration}s (FTS rebuilt in ${ftsDuration}s)`);
|
|
3688
3709
|
}
|
|
3689
3710
|
this.touchLastIndexed();
|
|
3711
|
+
for (const model of models) this.setModelSyncedAt(model, startedAt);
|
|
3690
3712
|
}
|
|
3691
3713
|
/**
|
|
3692
3714
|
* Sort models by JSON file count descending.
|
|
@@ -4669,9 +4691,13 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
4669
4691
|
}
|
|
4670
4692
|
/** Every distinct file path the symbols table holds for a model. */
|
|
4671
4693
|
getModelFilePaths(model) {
|
|
4672
|
-
const
|
|
4673
|
-
|
|
4674
|
-
).all(model);
|
|
4694
|
+
const db = this.getReadDb();
|
|
4695
|
+
const key = model.toLowerCase();
|
|
4696
|
+
const spellings = db.prepare(`SELECT DISTINCT model FROM symbols`).all().map((r) => r.model).filter((m) => m?.toLowerCase() === key);
|
|
4697
|
+
if (spellings.length === 0) return [];
|
|
4698
|
+
const rows = db.prepare(
|
|
4699
|
+
`SELECT DISTINCT file_path FROM symbols WHERE model IN (${spellings.map(() => "?").join(", ")})`
|
|
4700
|
+
).all(...spellings);
|
|
4675
4701
|
return rows.map((r) => r.file_path);
|
|
4676
4702
|
}
|
|
4677
4703
|
/** Every path indexed_files records for a model, as stored. */
|
|
@@ -4694,6 +4720,29 @@ Point the installation at a drive with room (a full index needs several GB): re-
|
|
|
4694
4720
|
}
|
|
4695
4721
|
}
|
|
4696
4722
|
/** ISO timestamp of the last full or incremental index update, or null. */
|
|
4723
|
+
/**
|
|
4724
|
+
* The moment up to which this model's files are known to be in the index: the start of
|
|
4725
|
+
* the build that indexed it, or of the last start-up pass that brought it up to date.
|
|
4726
|
+
* Unlike last_indexed_at, a single file write does not move it.
|
|
4727
|
+
*/
|
|
4728
|
+
getModelSyncedAt(model) {
|
|
4729
|
+
try {
|
|
4730
|
+
const row = this.getReadDb().prepare(
|
|
4731
|
+
`SELECT value FROM _index_meta WHERE key = ?`
|
|
4732
|
+
).get(`model_synced_at:${model.toLowerCase()}`);
|
|
4733
|
+
return row?.value ?? null;
|
|
4734
|
+
} catch {
|
|
4735
|
+
return null;
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
setModelSyncedAt(model, isoTime) {
|
|
4739
|
+
try {
|
|
4740
|
+
this.db.prepare(
|
|
4741
|
+
`INSERT OR REPLACE INTO _index_meta (key, value) VALUES (?, ?)`
|
|
4742
|
+
).run(`model_synced_at:${model.toLowerCase()}`, isoTime);
|
|
4743
|
+
} catch {
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4697
4746
|
getLastIndexedAt() {
|
|
4698
4747
|
try {
|
|
4699
4748
|
const row = this.getReadDb().prepare(
|