d365fo-mcp 1.17.4 → 1.19.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/.github/copilot-instructions.md +1 -0
- package/README.md +1 -1
- package/bridge/D365MetadataBridge/Program.cs +2 -1
- package/bridge/D365MetadataBridge/Services/CrossReferenceService.cs +230 -25
- package/bridge/D365MetadataBridge/Services/MetadataWriteService.cs +21 -13
- package/dist/bridge/bridgeAdapter.d.ts +25 -0
- package/dist/bridge/bridgeAdapter.js +121 -26
- package/dist/bridge/bridgeTypes.d.ts +18 -0
- package/dist/cli/commands/doctor.d.ts +8 -0
- package/dist/cli/commands/doctor.js +24 -0
- package/dist/cli/ui.d.ts +9 -2
- package/dist/cli/ui.js +8 -1
- package/dist/config/settings.js +40 -0
- package/dist/index.js +1 -1
- package/dist/metadata/modelDescriptor.d.ts +139 -2
- package/dist/metadata/modelDescriptor.js +249 -3
- package/dist/metadata/symbolIndex.d.ts +42 -0
- package/dist/metadata/symbolIndex.js +73 -8
- package/dist/scripts/build-database.js +93 -7
- package/dist/scripts/build-fts.js +93 -7
- package/dist/scripts/extract-metadata.js +33 -0
- package/dist/scripts/startupIndexWorker.js +60 -7
- package/dist/server/toolAnnotations.js +1 -1
- package/dist/server/toolSchemas/buildD365foProject.d.ts +8 -0
- package/dist/server/toolSchemas/buildD365foProject.js +8 -0
- package/dist/server/toolSchemas/d365foFile.js +11 -9
- package/dist/server/toolSchemas/findReferences.d.ts +0 -1
- package/dist/server/toolSchemas/findReferences.js +3 -4
- package/dist/server/toolSchemas/index.d.ts +8 -1
- package/dist/tools/analysis/findReferences.d.ts +33 -0
- package/dist/tools/analysis/findReferences.js +294 -41
- package/dist/tools/analysis/validateObjectNaming.js +15 -4
- package/dist/tools/d365foFile.d.ts +2 -1
- package/dist/tools/d365foFile.js +36 -10
- package/dist/tools/readers/classInfo.js +58 -6
- package/dist/tools/readers/edtInfo.d.ts +21 -0
- package/dist/tools/readers/edtInfo.js +50 -5
- package/dist/tools/readers/getMethodSource.d.ts +12 -1
- package/dist/tools/readers/getMethodSource.js +75 -20
- package/dist/tools/readers/getWorkspaceInfo.js +53 -6
- package/dist/tools/readers/tableInfo.js +24 -1
- package/dist/tools/sdlc/aosRuntime.d.ts +51 -0
- package/dist/tools/sdlc/aosRuntime.js +246 -0
- package/dist/tools/sdlc/aosRuntimePowerShell.d.ts +3 -0
- package/dist/tools/sdlc/aosRuntimePowerShell.js +176 -0
- package/dist/tools/sdlc/aosWebConfig.d.ts +9 -0
- package/dist/tools/sdlc/aosWebConfig.js +50 -0
- package/dist/tools/sdlc/buildProject.d.ts +24 -2
- package/dist/tools/sdlc/buildProject.js +639 -154
- package/dist/tools/sdlc/compilerMetadataPrune.d.ts +50 -0
- package/dist/tools/sdlc/compilerMetadataPrune.js +129 -0
- package/dist/tools/sdlc/updateSymbolIndex.d.ts +1 -0
- package/dist/tools/sdlc/updateSymbolIndex.js +26 -0
- package/dist/tools/smart/codeGen.js +55 -50
- package/dist/tools/smart/generateSmartTable.d.ts +3 -3
- package/dist/tools/smart/generateSmartTable.js +3 -3
- package/dist/tools/specs/d365foFileOpSpecs.js +37 -0
- package/dist/tools/specs/opSpecs.js +46 -0
- package/dist/tools/write/createProject.d.ts +27 -0
- package/dist/tools/write/createProject.js +188 -0
- package/dist/tools/write/directXmlWriters.d.ts +31 -0
- package/dist/tools/write/directXmlWriters.js +133 -0
- package/dist/tools/write/formDataSourceNote.d.ts +22 -0
- package/dist/tools/write/formDataSourceNote.js +64 -0
- package/dist/tools/write/inlineIndexUpsert.js +6 -0
- package/dist/tools/write/inlineWriteVerification.d.ts +1 -1
- package/dist/tools/write/inlineWriteVerification.js +10 -1
- package/dist/tools/write/modifyD365File.d.ts +11 -0
- package/dist/tools/write/modifyD365File.js +155 -19
- package/dist/tools/write/preserveMetadataElements.js +1 -0
- package/dist/tools/write/projectAction.d.ts +12 -0
- package/dist/tools/write/projectAction.js +175 -0
- package/dist/utils/configManager.d.ts +10 -2
- package/dist/utils/configManager.js +16 -2
- package/dist/utils/formExtensionControlXml.js +59 -19
- package/dist/utils/indexedMethodSource.d.ts +76 -0
- package/dist/utils/indexedMethodSource.js +108 -0
- package/dist/utils/methodBodyHint.d.ts +12 -0
- package/dist/utils/methodBodyHint.js +12 -0
- package/dist/utils/modelClassifier.d.ts +26 -0
- package/dist/utils/modelClassifier.js +52 -3
- package/dist/utils/objectFileLookup.d.ts +41 -0
- package/dist/utils/objectFileLookup.js +84 -0
- package/dist/utils/objectNaming.js +12 -5
- package/dist/utils/objectNamingRules.d.ts +2 -0
- package/dist/utils/objectNamingRules.js +73 -5
- package/dist/utils/pathContainment.d.ts +13 -1
- package/dist/utils/pathContainment.js +97 -1
- package/dist/utils/toolProgressMessage.js +4 -0
- package/dist/utils/xmlScan.js +7 -1
- package/dist/workspace/projectMembership.d.ts +15 -0
- package/dist/workspace/projectMembership.js +17 -0
- package/dist/workspace/projectScaffold.d.ts +117 -0
- package/dist/workspace/projectScaffold.js +568 -0
- package/package.json +4 -4
|
@@ -74,6 +74,7 @@ PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integra
|
|
|
74
74
|
- `model-name` → class `{Target}_{ModelName}_Extension`, element `{Target}.{ModelName}`
|
|
75
75
|
|
|
76
76
|
Pass the BASE object name to `d365fo_file(action="create")` and let the tool inject the token — don't hand-build the infix.
|
|
77
|
+
These patterns describe how the tool names extensions, and the tool applies them itself — editing them here does not change the names it writes. Change the style with `d365fo-mcp config naming`.
|
|
77
78
|
|
|
78
79
|
### Reuse & diff safety
|
|
79
80
|
|
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ This server pre-indexes your entire D365FO installation (580 000+ symbols across
|
|
|
52
52
|
| 🛡️ **Grounded generation** | Fail-closed gates: `prepare` issues grounding tokens, `validate_code(mode="references")` proves every identifier, `validate_code(mode="syntax")` enforces best practices — hallucinated code never reaches disk |
|
|
53
53
|
| 🧩 **Form pattern engine** | Complete catalog of Microsoft form patterns and sub-patterns: recommends the right pattern, clones reference forms with datasource re-binding, **deterministically expands** patterns that have no reference form, **auto-repairs** a form's missing required controls, validates structure and blocks invalid writes |
|
|
54
54
|
| ✍️ **Safe metadata writes** | C# bridge uses Microsoft's own `IMetadataProvider` wherever it can express the object; the few types and ops it cannot go through structured XML writers with ambiguity guards — never blind string replacement. Automatic `.rnrproj` registration, one-call undo |
|
|
55
|
-
| 🏗️ **SDLC integration** | MSBuild compilation with structured diagnostics, DB sync, xppbp best practices, SysTestRunner — all from chat |
|
|
55
|
+
| 🏗️ **SDLC integration** | MSBuild compilation with structured diagnostics, DB sync, xppbp best practices, SysTestRunner — all from chat. Optional `restartAos: true` refreshes the matching local IIS/IIS Express runtime after a successful build and requested sync. [Runtime restart](docs/AOS_RUNTIME_RESTART.md) |
|
|
56
56
|
| 📐 **X++ knowledge base** | Queryable rules: select grammar, CoC authoring, financial dimensions, the posting engine (`LedgerVoucher`), number sequences, `SysExtension`, Electronic Reporting, AX2012→D365FO migration — prevents deprecated APIs |
|
|
57
57
|
|
|
58
58
|
### Pattern-grounded form development
|
|
@@ -530,7 +530,8 @@ Options:
|
|
|
530
530
|
Microsoft-shipped metadata in UDE environments.
|
|
531
531
|
--bin-path <path> Explicit DLL directory (UDE: microsoftPackagesPath\bin). If omitted, uses {packages-path}\bin.
|
|
532
532
|
--xref-server <server> SQL Server for cross-reference DB (default: localhost)
|
|
533
|
-
--xref-database <db> Cross-reference database name
|
|
533
|
+
--xref-database <db> Cross-reference database name, e.g. DYNAMICSXREFDB
|
|
534
|
+
(no default: without it cross-references are off)
|
|
534
535
|
--log-file <path> Write all diagnostic logs to this file (append mode)
|
|
535
536
|
--help Show this help
|
|
536
537
|
|
|
@@ -169,11 +169,16 @@ namespace D365MetadataBridge.Services
|
|
|
169
169
|
|
|
170
170
|
var pathVariants = new List<string>();
|
|
171
171
|
bool memberQualified = false;
|
|
172
|
-
if (objectPath.
|
|
172
|
+
if (objectPath.Contains("/"))
|
|
173
173
|
{
|
|
174
|
-
// Explicit
|
|
174
|
+
// Explicit path — as given: an AOT path ("/Tables/SalesTable/Methods/initFromX")
|
|
175
|
+
// or a metadata one ("Table/SalesTable"). An X++ one gets its metadata twin below.
|
|
175
176
|
pathVariants.Add(objectPath);
|
|
176
|
-
memberQualified = objectPath.Contains("/Methods/") || objectPath.Contains("/Fields/")
|
|
177
|
+
memberQualified = objectPath.Contains("/Methods/") || objectPath.Contains("/Fields/") ||
|
|
178
|
+
objectPath.Contains("/Method/") || objectPath.Contains("/TableField") ||
|
|
179
|
+
objectPath.Contains("/EnumValues/") || objectPath.Contains("/EnumValue/") ||
|
|
180
|
+
objectPath.Contains("/TableIndexs/") || objectPath.Contains("/TableIndex/") ||
|
|
181
|
+
objectPath.Contains("/TableFieldGroups/") || objectPath.Contains("/TableFieldGroup/");
|
|
177
182
|
}
|
|
178
183
|
else if (objectPath.Contains("."))
|
|
179
184
|
{
|
|
@@ -190,16 +195,33 @@ namespace D365MetadataBridge.Services
|
|
|
190
195
|
pathVariants.Add($"/{c}/{owner}/Methods/{member}");
|
|
191
196
|
pathVariants.Add($"/{c}/{owner}/Fields/{member}");
|
|
192
197
|
}
|
|
198
|
+
pathVariants.Add($"/Enums/{owner}/EnumValues/{member}");
|
|
199
|
+
// "Form.DataSource.method": a form data source's method.
|
|
200
|
+
var ownerDot = owner.IndexOf('.');
|
|
201
|
+
if (ownerDot > 0 && owner.IndexOf('.', ownerDot + 1) < 0)
|
|
202
|
+
pathVariants.Add($"/Forms/{owner.Substring(0, ownerDot)}/DataSources/{owner.Substring(ownerDot + 1)}/Methods/{member}");
|
|
193
203
|
}
|
|
194
204
|
else
|
|
195
205
|
{
|
|
196
206
|
// Bare name — we do not know which AOT type it is, so try every container
|
|
197
|
-
// that can be the TARGET of a reference.
|
|
198
|
-
//
|
|
199
|
-
//
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
//
|
|
207
|
+
// that can be the TARGET of a reference. A target is stored in one of TWO
|
|
208
|
+
// shapes, depending on which provider wrote the reference:
|
|
209
|
+
//
|
|
210
|
+
// X++ code (provider Xppc.exe): plural + leading slash — "/Tables/<name>",
|
|
211
|
+
// "/Edts/<name>", children "/Tables/<name>/Fields/<f>", ".../Methods/<m>".
|
|
212
|
+
// Declarative metadata (provider Metadata): singular, NO leading slash, and
|
|
213
|
+
// for an EDT its concrete subtype — "Table/<name>", "Form/<name>",
|
|
214
|
+
// "EdtString/<name>", children "Table/<name>/TableFieldString/<f>",
|
|
215
|
+
// "Table/<name>/Method/<m>". Source paths of these rows carry the referencing
|
|
216
|
+
// property ("Form/F/FormDataSourceRoot/<name>?Table").
|
|
217
|
+
//
|
|
218
|
+
// Only the first shape used to be queried, on the belief — stated here — that
|
|
219
|
+
// targets were always plural + slash. On a live DYNAMICSXREFDB (platform
|
|
220
|
+
// 7.0.7858, 19.5M references) the second shape holds 2.3M of them, every one
|
|
221
|
+
// Kind 2: a table's form data sources, relations, entity mappings and field
|
|
222
|
+
// bindings, and the table fields typed with an EDT. A where-used on a custom
|
|
223
|
+
// table returned 334 of its 785 references; on a custom EDT, 12 of 108, and
|
|
224
|
+
// none of the fields using it.
|
|
203
225
|
//
|
|
204
226
|
// Edts/Maps/Reports/MenuItem* were missing here, so a where-used on any of
|
|
205
227
|
// them returned zero rows and the TS caller silently degraded to its
|
|
@@ -217,6 +239,17 @@ namespace D365MetadataBridge.Services
|
|
|
217
239
|
}
|
|
218
240
|
}
|
|
219
241
|
|
|
242
|
+
// Every X++-shaped target also exists in the metadata shape; query both,
|
|
243
|
+
// whichever way the target was given. A table field or enum value may also come
|
|
244
|
+
// from an extension, which is matched by pattern (see AddExtensionMembers).
|
|
245
|
+
var extensionPatterns = new List<string>();
|
|
246
|
+
foreach (var p in pathVariants.ToList())
|
|
247
|
+
{
|
|
248
|
+
AddMetadataTwins(p, pathVariants);
|
|
249
|
+
AddExtensionMembers(p, extensionPatterns);
|
|
250
|
+
}
|
|
251
|
+
pathVariants = pathVariants.Distinct(StringComparer.Ordinal).ToList();
|
|
252
|
+
|
|
220
253
|
// Also add sub-paths (methods, fields) so we catch method-level references.
|
|
221
254
|
// A member-qualified target already points at an exact leaf path, so adding
|
|
222
255
|
// "/%" children would wrongly pull in unrelated nested references — skip it.
|
|
@@ -241,31 +274,52 @@ namespace D365MetadataBridge.Services
|
|
|
241
274
|
allParams.Add(($"@P{i}", pathVariants[i]));
|
|
242
275
|
}
|
|
243
276
|
var likeConditions = new List<string>();
|
|
244
|
-
|
|
277
|
+
var likePatterns = extraPaths.Concat(extensionPatterns).ToList();
|
|
278
|
+
for (int i = 0; i < likePatterns.Count; i++)
|
|
245
279
|
{
|
|
246
280
|
var pname = $"@L{i}";
|
|
247
281
|
likeConditions.Add($"tgt.Path LIKE {pname}");
|
|
248
|
-
allParams.Add((pname,
|
|
282
|
+
allParams.Add((pname, likePatterns[i]));
|
|
249
283
|
}
|
|
250
284
|
|
|
251
285
|
var whereClause = $"tgt.Path IN ({string.Join(",", paramNames)})";
|
|
252
286
|
if (likeConditions.Count > 0)
|
|
253
287
|
whereClause += $" OR {string.Join(" OR ", likeConditions)}";
|
|
254
288
|
|
|
289
|
+
// Rows are capped PER SHAPE and the totals counted separately. With one cap for
|
|
290
|
+
// both, rows sorted by source path put every "/Classes/…" code row before any
|
|
291
|
+
// "Form/…" metadata row, so a table with 500 code references (CustTable)
|
|
292
|
+
// returned no metadata at all — the very rows this lookup exists to add. The
|
|
293
|
+
// candidate names are resolved once: the LIKEs against Names are the costly
|
|
294
|
+
// part, the joins on [References].TargetId are indexed. The totals join the
|
|
295
|
+
// source name exactly as the rows do: [References] keeps rows whose SourceId is
|
|
296
|
+
// no longer in Names (77 of the 93 references to one table field on a live
|
|
297
|
+
// database), and counting those made the rows look like a sample of a total
|
|
298
|
+
// nobody could list.
|
|
299
|
+
string ShapeRows(string shape) => $@"
|
|
300
|
+
SELECT * FROM (
|
|
301
|
+
SELECT TOP ({RowsPerShape})
|
|
302
|
+
src.Path AS SourcePath, t.Path AS TargetPath, sm.Module AS SourceModule,
|
|
303
|
+
r.Kind, r.Line, r.[Column]
|
|
304
|
+
FROM #xrefTargets t
|
|
305
|
+
INNER JOIN [References] r ON r.TargetId = t.Id
|
|
306
|
+
INNER JOIN dbo.Names src ON src.Id = r.SourceId
|
|
307
|
+
LEFT JOIN dbo.Modules sm ON sm.Id = src.ModuleId
|
|
308
|
+
WHERE {shape}
|
|
309
|
+
ORDER BY src.Path, r.Line) AS shapeRows";
|
|
255
310
|
var query = $@"
|
|
256
|
-
SELECT
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
INNER JOIN
|
|
265
|
-
INNER JOIN dbo.Names src ON src.Id = r.SourceId
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
ORDER BY src.Path, r.Line";
|
|
311
|
+
SELECT tgt.Id, tgt.Path INTO #xrefTargets FROM dbo.Names tgt WHERE ({whereClause});
|
|
312
|
+
SELECT SourcePath, TargetPath, SourceModule, Kind, Line, [Column] FROM (
|
|
313
|
+
{ShapeRows("t.Path LIKE N'/%'")}
|
|
314
|
+
UNION ALL
|
|
315
|
+
{ShapeRows("t.Path NOT LIKE N'/%'")}
|
|
316
|
+
) AS rows
|
|
317
|
+
ORDER BY CASE WHEN TargetPath LIKE N'/%' THEN 0 ELSE 1 END, SourcePath, Line;
|
|
318
|
+
SELECT COUNT(*), SUM(CASE WHEN t.Path LIKE N'/%' THEN 0 ELSE 1 END)
|
|
319
|
+
FROM #xrefTargets t INNER JOIN [References] r ON r.TargetId = t.Id
|
|
320
|
+
INNER JOIN dbo.Names src ON src.Id = r.SourceId;
|
|
321
|
+
DROP TABLE #xrefTargets;";
|
|
322
|
+
int total = 0, metadataTotal = 0;
|
|
269
323
|
|
|
270
324
|
try
|
|
271
325
|
{
|
|
@@ -300,6 +354,11 @@ namespace D365MetadataBridge.Services
|
|
|
300
354
|
CallerMethod = srcSeg == "Methods" ? srcSegName : null,
|
|
301
355
|
});
|
|
302
356
|
}
|
|
357
|
+
if (reader.NextResult() && reader.Read())
|
|
358
|
+
{
|
|
359
|
+
total = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
|
|
360
|
+
metadataTotal = reader.IsDBNull(1) ? 0 : reader.GetInt32(1);
|
|
361
|
+
}
|
|
303
362
|
}
|
|
304
363
|
}
|
|
305
364
|
}
|
|
@@ -309,7 +368,153 @@ namespace D365MetadataBridge.Services
|
|
|
309
368
|
throw QueryFailed("findReferences", objectPath, ex);
|
|
310
369
|
}
|
|
311
370
|
|
|
312
|
-
|
|
371
|
+
// count: rows returned; total / metadataTotal: every matching reference.
|
|
372
|
+
return new { objectPath, count = references.Count, total, metadataTotal, references };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/// <summary>Rows returned per target shape (X++ code, declarative metadata).</summary>
|
|
376
|
+
private const int RowsPerShape = 500;
|
|
377
|
+
|
|
378
|
+
/// <summary>
|
|
379
|
+
/// The singular metadata type names a plural X++ container is stored under, with
|
|
380
|
+
/// every EDT subtype found as a target in a live DYNAMICSXREFDB.
|
|
381
|
+
/// </summary>
|
|
382
|
+
private static readonly Dictionary<string, string[]> MetadataTypes = new Dictionary<string, string[]>(StringComparer.Ordinal)
|
|
383
|
+
{
|
|
384
|
+
["Tables"] = new[] { "Table" },
|
|
385
|
+
["Classes"] = new[] { "Class" },
|
|
386
|
+
["Enums"] = new[] { "Enum" },
|
|
387
|
+
["Views"] = new[] { "View" },
|
|
388
|
+
["DataEntityViews"] = new[] { "DataEntityView" },
|
|
389
|
+
["Queries"] = new[] { "QuerySimple", "QueryComposite" },
|
|
390
|
+
["Forms"] = new[] { "Form" },
|
|
391
|
+
["Maps"] = new[] { "Map" },
|
|
392
|
+
["Reports"] = new[] { "Report" },
|
|
393
|
+
["MenuItemDisplays"] = new[] { "MenuItemDisplay" },
|
|
394
|
+
["MenuItemActions"] = new[] { "MenuItemAction" },
|
|
395
|
+
["MenuItemOutputs"] = new[] { "MenuItemOutput" },
|
|
396
|
+
["Edts"] = new[]
|
|
397
|
+
{
|
|
398
|
+
"EdtString", "EdtReal", "EdtEnum", "EdtInt64", "EdtDate", "EdtInt", "EdtUtcDateTime",
|
|
399
|
+
"EdtContainer", "EdtGuid", "EdtTime",
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
/// <summary>
|
|
404
|
+
/// The segment a field is stored under in the metadata shape, per container — it
|
|
405
|
+
/// names the field's type, so there is one per type. Every segment found as a
|
|
406
|
+
/// target in a live DYNAMICSXREFDB. Listed rather than matched with
|
|
407
|
+
/// "TableField%": in LIKE "%" also crosses "/", so "Table/T/TableField%/Name"
|
|
408
|
+
/// matched the field group "Table/T/TableFieldGroup/Name" as well — and a table
|
|
409
|
+
/// with a field and a field group of the same name is common
|
|
410
|
+
/// (AccountingDistributionTemplate.Name).
|
|
411
|
+
/// </summary>
|
|
412
|
+
private static readonly Dictionary<string, string[]> MetadataFieldSegments = new Dictionary<string, string[]>(StringComparer.Ordinal)
|
|
413
|
+
{
|
|
414
|
+
["Tables"] = new[]
|
|
415
|
+
{
|
|
416
|
+
"TableFieldString", "TableFieldEnum", "TableFieldReal", "TableFieldInt64", "TableFieldInt",
|
|
417
|
+
"TableFieldDate", "TableFieldUtcDateTime", "TableFieldGuid", "TableFieldContainer", "TableFieldTime",
|
|
418
|
+
},
|
|
419
|
+
["Maps"] = new[]
|
|
420
|
+
{
|
|
421
|
+
"MapFieldString", "MapFieldEnum", "MapFieldReal", "MapFieldInt64", "MapFieldInt",
|
|
422
|
+
"MapFieldDate", "MapFieldUtcDateTime", "MapFieldGuid", "MapFieldContainer", "MapFieldTime",
|
|
423
|
+
},
|
|
424
|
+
["Views"] = new[]
|
|
425
|
+
{
|
|
426
|
+
"ViewFieldBound", "ViewFieldComputedString", "ViewFieldComputedEnum", "ViewFieldComputedReal",
|
|
427
|
+
"ViewFieldComputedInt64", "ViewFieldComputedInt", "ViewFieldComputedDate", "ViewFieldComputedUtcDateTime",
|
|
428
|
+
},
|
|
429
|
+
["DataEntityViews"] = new[]
|
|
430
|
+
{
|
|
431
|
+
"DataEntityViewMappedField", "DataEntityViewUnmappedFieldString", "DataEntityViewUnmappedFieldEnum",
|
|
432
|
+
"DataEntityViewUnmappedFieldReal", "DataEntityViewUnmappedFieldInt64", "DataEntityViewUnmappedFieldInt",
|
|
433
|
+
"DataEntityViewUnmappedFieldDate", "DataEntityViewUnmappedFieldUtcDateTime",
|
|
434
|
+
"DataEntityViewUnmappedFieldGuid", "DataEntityViewUnmappedFieldContainer",
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/// <summary>
|
|
439
|
+
/// Add the metadata twin of an X++-shaped target path: "/Tables/T" → "Table/T",
|
|
440
|
+
/// "/Edts/E" → "EdtString/E", … ; for a member, "/Views/V/Methods/m" →
|
|
441
|
+
/// "View/V/Method/m" (tables, classes, forms, views, data entities, maps) and
|
|
442
|
+
/// "/Tables/T/Fields/f" → "Table/T/TableFieldString/f", "Table/T/TableFieldEnum/f", …
|
|
443
|
+
/// (tables, maps, views, data entities); "/Tables/T/TableIndexs/i" → "Table/T/TableIndex/i",
|
|
444
|
+
/// "/Tables/T/TableFieldGroups/g" → "Table/T/TableFieldGroup/g"; a form data source's
|
|
445
|
+
/// method "/Forms/F/DataSources/DS/Methods/m" → "Form/F/FormDataSourceRoot/DS/Method/m".
|
|
446
|
+
/// Metadata-shaped and unknown paths add nothing.
|
|
447
|
+
/// </summary>
|
|
448
|
+
private static void AddMetadataTwins(string xppPath, List<string> exact)
|
|
449
|
+
{
|
|
450
|
+
if (!xppPath.StartsWith("/")) return;
|
|
451
|
+
var parts = xppPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
|
452
|
+
if (parts.Length < 2 || !MetadataTypes.TryGetValue(parts[0], out var types)) return;
|
|
453
|
+
if (parts.Length == 2)
|
|
454
|
+
{
|
|
455
|
+
foreach (var t in types) exact.Add($"{t}/{parts[1]}");
|
|
456
|
+
}
|
|
457
|
+
else if (parts.Length == 4)
|
|
458
|
+
{
|
|
459
|
+
if (parts[2] == "Methods")
|
|
460
|
+
{
|
|
461
|
+
foreach (var t in types) exact.Add($"{t}/{parts[1]}/Method/{parts[3]}");
|
|
462
|
+
}
|
|
463
|
+
else if (parts[2] == "Fields" && MetadataFieldSegments.TryGetValue(parts[0], out var segments))
|
|
464
|
+
{
|
|
465
|
+
foreach (var t in types)
|
|
466
|
+
foreach (var s in segments) exact.Add($"{t}/{parts[1]}/{s}/{parts[3]}");
|
|
467
|
+
}
|
|
468
|
+
else if (parts[2] == "EnumValues" && parts[0] == "Enums")
|
|
469
|
+
{
|
|
470
|
+
exact.Add($"Enum/{parts[1]}/EnumValue/{parts[3]}");
|
|
471
|
+
}
|
|
472
|
+
// X++ spells these "TableIndexs" / "TableFieldGroups"; metadata singular.
|
|
473
|
+
else if (parts[2] == "TableIndexs")
|
|
474
|
+
{
|
|
475
|
+
foreach (var t in types) exact.Add($"{t}/{parts[1]}/TableIndex/{parts[3]}");
|
|
476
|
+
}
|
|
477
|
+
else if (parts[2] == "TableFieldGroups")
|
|
478
|
+
{
|
|
479
|
+
foreach (var t in types) exact.Add($"{t}/{parts[1]}/TableFieldGroup/{parts[3]}");
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
else if (parts.Length == 6 && parts[0] == "Forms" && parts[2] == "DataSources" && parts[4] == "Methods")
|
|
483
|
+
{
|
|
484
|
+
// A form data source's method: "/Forms/F/DataSources/DS/Methods/m" and
|
|
485
|
+
// "Form/F/FormDataSourceRoot/DS/Method/m". Every data source is stored at the
|
|
486
|
+
// root, joined ones included, under its own name (not its table's).
|
|
487
|
+
exact.Add($"Form/{parts[1]}/FormDataSourceRoot/{parts[3]}/Method/{parts[5]}");
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/// <summary>
|
|
492
|
+
/// A field a table extension adds, and a value an enum extension adds, are stored
|
|
493
|
+
/// under the extension only, in both shapes: "/TableExtensions/T.Ext/Fields/f" and
|
|
494
|
+
/// "TableExtension/T.Ext/TableFieldString/f", "/EnumExtensions/E.Ext/EnumValues/v"
|
|
495
|
+
/// and "EnumExtension/E.Ext/EnumValue/v". On a live DYNAMICSXREFDB that is 17,788 and
|
|
496
|
+
/// 8,769 references, and a where-used on "PurchLine.<added field>" found none of them:
|
|
497
|
+
/// "/Tables/PurchLine/Fields/<f>" has no references at all. An extension is always
|
|
498
|
+
/// named "<base>.<suffix>" (every one of the 1,104 on that database), so the
|
|
499
|
+
/// suffix is the only wildcard; the member segment after it is exact.
|
|
500
|
+
/// </summary>
|
|
501
|
+
private static void AddExtensionMembers(string xppPath, List<string> patterns)
|
|
502
|
+
{
|
|
503
|
+
var parts = xppPath.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
|
504
|
+
if (!xppPath.StartsWith("/") || parts.Length != 4) return;
|
|
505
|
+
var baseName = EscapeLike(parts[1]);
|
|
506
|
+
var member = EscapeLike(parts[3]);
|
|
507
|
+
if (parts[0] == "Tables" && parts[2] == "Fields")
|
|
508
|
+
{
|
|
509
|
+
patterns.Add($"/TableExtensions/{baseName}.%/Fields/{member}");
|
|
510
|
+
foreach (var s in MetadataFieldSegments["Tables"])
|
|
511
|
+
patterns.Add($"TableExtension/{baseName}.%/{s}/{member}");
|
|
512
|
+
}
|
|
513
|
+
else if (parts[0] == "Enums" && parts[2] == "EnumValues")
|
|
514
|
+
{
|
|
515
|
+
patterns.Add($"/EnumExtensions/{baseName}.%/EnumValues/{member}");
|
|
516
|
+
patterns.Add($"EnumExtension/{baseName}.%/EnumValue/{member}");
|
|
517
|
+
}
|
|
313
518
|
}
|
|
314
519
|
|
|
315
520
|
// ============================================================
|
|
@@ -3483,14 +3483,11 @@ namespace D365MetadataBridge.Services
|
|
|
3483
3483
|
?? throw new ArgumentException($"Form extension '{objectName}' not found");
|
|
3484
3484
|
var msi = GetModelSaveInfoForObject(_provider.FormExtensions, objectName);
|
|
3485
3485
|
|
|
3486
|
-
// Same idempotency rule as the form branch below: skip on a
|
|
3487
|
-
// and on a different-named data source already bound to the same table.
|
|
3486
|
+
// Same idempotency rule as the form branch below: skip on a NAME match only.
|
|
3488
3487
|
foreach (AxFormDataSourceRoot existing in axExt.DataSources)
|
|
3489
3488
|
{
|
|
3490
3489
|
if (string.Equals(existing.Name, dsName, StringComparison.OrdinalIgnoreCase))
|
|
3491
3490
|
return new { success = true, operation = "add-data-source", objectType, objectName, dsName, table, skipped = true, reason = $"data source '{dsName}' already exists", api = "IMetaFormExtensionProvider.Update" };
|
|
3492
|
-
if (string.Equals(existing.Table, table, StringComparison.OrdinalIgnoreCase))
|
|
3493
|
-
return new { success = true, operation = "add-data-source", objectType, objectName, dsName, table, skipped = true, reason = $"data source '{existing.Name}' already binds table '{table}'", api = "IMetaFormExtensionProvider.Update" };
|
|
3494
3491
|
}
|
|
3495
3492
|
|
|
3496
3493
|
axExt.DataSources.Add((AxFormDataSourceRoot)CreateFormDataSourceRoot(dsName, table, joinSource, linkType));
|
|
@@ -3506,18 +3503,23 @@ namespace D365MetadataBridge.Services
|
|
|
3506
3503
|
?? throw new ArgumentException($"Form '{objectName}' not found");
|
|
3507
3504
|
var msi = GetModelSaveInfoForObject(_provider.Forms, objectName);
|
|
3508
3505
|
|
|
3509
|
-
// Idempotency: don't append a duplicate.
|
|
3510
|
-
//
|
|
3511
|
-
// right table)
|
|
3512
|
-
//
|
|
3513
|
-
//
|
|
3506
|
+
// Idempotency: don't append a duplicate. A data source with the same NAME
|
|
3507
|
+
// already there is a real conflict (it may be a template stub already bound
|
|
3508
|
+
// to the right table), so skip that one.
|
|
3509
|
+
//
|
|
3510
|
+
// A different-named data source already bound to the same TABLE is NOT a
|
|
3511
|
+
// conflict and must still be written. This used to skip too, on the theory
|
|
3512
|
+
// that "adding a second binding to the same table is almost always an
|
|
3513
|
+
// accident" — which is simply untrue: a form routinely joins one table into
|
|
3514
|
+
// several branches of its query. Microsoft's own PurchLineBackOrder carries
|
|
3515
|
+
// PurchTable and PurchTable1, both over PurchTable, with different link
|
|
3516
|
+
// types. The rule silently dropped three legitimate data sources and, because
|
|
3517
|
+
// `skipped` never reached the caller, reported all three as added.
|
|
3514
3518
|
foreach (var existing in axForm.DataSources)
|
|
3515
3519
|
{
|
|
3516
3520
|
dynamic dyn = existing;
|
|
3517
3521
|
if (string.Equals((string)dyn.Name, dsName, StringComparison.OrdinalIgnoreCase))
|
|
3518
3522
|
return new { success = true, operation = "add-data-source", objectType, objectName, dsName, table, skipped = true, reason = $"data source '{dsName}' already exists", api = "IMetaFormProvider.Update" };
|
|
3519
|
-
if (string.Equals((string)dyn.Table, table, StringComparison.OrdinalIgnoreCase))
|
|
3520
|
-
return new { success = true, operation = "add-data-source", objectType, objectName, dsName, table, skipped = true, reason = $"data source '{(string)dyn.Name}' already binds table '{table}'", api = "IMetaFormProvider.Update" };
|
|
3521
3523
|
}
|
|
3522
3524
|
|
|
3523
3525
|
axForm.AddDataSource(CreateFormDataSourceRoot(dsName, table, joinSource, linkType));
|
|
@@ -4326,8 +4328,14 @@ namespace D365MetadataBridge.Services
|
|
|
4326
4328
|
}
|
|
4327
4329
|
if (!string.IsNullOrEmpty(label))
|
|
4328
4330
|
{
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
+
// The caption is not always "Label": field controls carry Label, buttons
|
|
4332
|
+
// and menu buttons carry Text, groups and tab pages carry Caption. Always
|
|
4333
|
+
// assigning Label left every Button without a caption (#1047).
|
|
4334
|
+
var captionProperty = new[] { "Label", "Text", "Caption" }
|
|
4335
|
+
.Select(n => ctrlType.GetProperty(n))
|
|
4336
|
+
.FirstOrDefault(p => p != null && p.CanWrite && p.PropertyType == typeof(string));
|
|
4337
|
+
if (captionProperty != null) captionProperty.SetValue(ctrl, label);
|
|
4338
|
+
else unsupportedProperties.Add("label");
|
|
4331
4339
|
}
|
|
4332
4340
|
return ctrl;
|
|
4333
4341
|
}
|
|
@@ -234,6 +234,27 @@ export declare function bridgeResolveObject(bridge: BridgeClient | undefined, ob
|
|
|
234
234
|
export declare function unappliedSuffix(result: {
|
|
235
235
|
unsupportedProperties?: string[];
|
|
236
236
|
}): string;
|
|
237
|
+
/** What a bridge write returns when it declined to do anything. */
|
|
238
|
+
export interface BridgeSkippable {
|
|
239
|
+
skipped?: boolean;
|
|
240
|
+
reason?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Renders a bridge result that declined the write, or null when it did write.
|
|
244
|
+
*
|
|
245
|
+
* The bridge has long been able to answer `{ success: true, skipped: true, reason }`
|
|
246
|
+
* — it did the honest thing and said it changed nothing. Nothing on this side read
|
|
247
|
+
* `skipped`, so every decline fell through the caller's `result.success` branch and
|
|
248
|
+
* was rendered "✅ … added": a write that never happened, reported as one, with the
|
|
249
|
+
* bridge's own explanation discarded on the way past.
|
|
250
|
+
*
|
|
251
|
+
* `success` from the bridge means "this did not fail", NOT "the object changed".
|
|
252
|
+
* Any wrapper whose operation can skip must ask this before claiming a write.
|
|
253
|
+
*
|
|
254
|
+
* Exactly the lesson unappliedSuffix() above was added for, one field over — which
|
|
255
|
+
* is why both live here together.
|
|
256
|
+
*/
|
|
257
|
+
export declare function skippedMessage(result: BridgeSkippable, subject: string): string | null;
|
|
237
258
|
/**
|
|
238
259
|
* Checks if bridge can handle this create operation.
|
|
239
260
|
*/
|
|
@@ -319,6 +340,7 @@ export declare function bridgeAddField(bridge: BridgeClient | undefined, tableNa
|
|
|
319
340
|
}): Promise<{
|
|
320
341
|
success: boolean;
|
|
321
342
|
message: string;
|
|
343
|
+
skipped?: boolean;
|
|
322
344
|
} | null>;
|
|
323
345
|
/**
|
|
324
346
|
* Sets a property via the C# bridge (IMetadataProvider.Update()).
|
|
@@ -425,6 +447,7 @@ export declare function bridgeRemoveFieldGroup(bridge: BridgeClient | undefined,
|
|
|
425
447
|
export declare function bridgeAddFieldToFieldGroup(bridge: BridgeClient | undefined, tableName: string, groupName: string, fieldName: string, extendBaseFieldGroup?: boolean): Promise<{
|
|
426
448
|
success: boolean;
|
|
427
449
|
message: string;
|
|
450
|
+
skipped?: boolean;
|
|
428
451
|
} | null>;
|
|
429
452
|
/**
|
|
430
453
|
* Modifies field properties on a table via the C# bridge.
|
|
@@ -488,6 +511,7 @@ export declare function bridgeAddControl(bridge: BridgeClient | undefined, formN
|
|
|
488
511
|
export declare function bridgeAddDataSource(bridge: BridgeClient | undefined, objectType: string, objectName: string, dsName: string, table: string, joinSource?: string, linkType?: string): Promise<{
|
|
489
512
|
success: boolean;
|
|
490
513
|
message: string;
|
|
514
|
+
skipped?: boolean;
|
|
491
515
|
} | null>;
|
|
492
516
|
/**
|
|
493
517
|
* Adds or updates a FieldModification entry in a table-extension via the C# bridge.
|
|
@@ -503,6 +527,7 @@ export declare function bridgeAddFieldModification(bridge: BridgeClient | undefi
|
|
|
503
527
|
export declare function bridgeAddMenuItemToMenu(bridge: BridgeClient | undefined, menuName: string, menuItemToAdd: string, menuItemToAddType?: string): Promise<{
|
|
504
528
|
success: boolean;
|
|
505
529
|
message: string;
|
|
530
|
+
skipped?: boolean;
|
|
506
531
|
} | null>;
|
|
507
532
|
/**
|
|
508
533
|
* Executes multiple write operations on a single object in one bridge call.
|