d365fo-mcp 1.21.0 → 1.22.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 +2 -2
- package/bridge/D365MetadataBridge/Services/MetadataWriteService.cs +130 -1
- package/dist/bridge/bridgeAdapter.d.ts +3 -0
- package/dist/bridge/bridgeAdapter.js +33 -4
- package/dist/bridge/bridgeFailure.d.ts +23 -0
- package/dist/bridge/bridgeFailure.js +28 -0
- package/dist/bridge/bridgeReadiness.d.ts +10 -0
- package/dist/bridge/bridgeReadiness.js +13 -0
- package/dist/bridge/index.d.ts +1 -1
- package/dist/bridge/index.js +1 -1
- package/dist/cli/commands/doctor.d.ts +1 -1
- package/dist/cli/commands/doctor.js +14 -3
- package/dist/config/settings.js +5 -1
- package/dist/config/xrefSetup.d.ts +14 -0
- package/dist/config/xrefSetup.js +22 -0
- package/dist/index.js +1 -1
- package/dist/knowledge/kernelEdts.d.ts +54 -0
- package/dist/knowledge/kernelEdts.js +158 -0
- package/dist/metadata/symbolIndex.d.ts +35 -2
- package/dist/metadata/symbolIndex.js +226 -63
- package/dist/metadata/types.d.ts +5 -0
- package/dist/metadata/xmlParser.d.ts +16 -2
- package/dist/metadata/xmlParser.js +41 -5
- package/dist/prompts/systemInstructions.js +4 -1
- package/dist/scripts/build-database.js +205 -74
- package/dist/scripts/build-fts.js +205 -74
- package/dist/scripts/extract-metadata.js +47 -9
- package/dist/scripts/startupIndexWorker.js +202 -72
- package/dist/server/toolSchemas/buildD365foProject.js +1 -1
- package/dist/server/toolSchemas/d365foFile.js +1 -1
- package/dist/server/toolSchemas/runSystestClass.js +1 -1
- package/dist/server/toolSchemas/search.js +1 -1
- package/dist/tools/analysis/findReferences.js +126 -15
- package/dist/tools/analysis/prefixDiagnostics.js +18 -13
- package/dist/tools/analysis/search.js +1 -1
- package/dist/tools/analysis/validateCode.js +4 -3
- package/dist/tools/analysis/validateObjectNaming.js +11 -4
- package/dist/tools/analysis/validateXpp.d.ts +1 -0
- package/dist/tools/analysis/validateXpp.js +191 -15
- package/dist/tools/d365foFile.js +62 -8
- package/dist/tools/knowledge/methodSignature.js +1 -1
- package/dist/tools/knowledge/xppKnowledge.js +3 -3
- package/dist/tools/prepare/prepareCreate.js +6 -3
- package/dist/tools/readers/edtInfo.js +7 -0
- package/dist/tools/readers/formInfo.js +16 -1
- package/dist/tools/readers/getMethodSource.js +19 -2
- package/dist/tools/readers/getObjectInfo.js +1 -1
- package/dist/tools/readers/getWorkspaceInfo.js +12 -2
- package/dist/tools/readers/mapInfo.d.ts +4 -2
- package/dist/tools/readers/mapInfo.js +81 -2
- package/dist/tools/readers/objectXml.js +24 -1
- package/dist/tools/responseCaps.js +9 -0
- package/dist/tools/sdlc/buildProject.d.ts +16 -0
- package/dist/tools/sdlc/buildProject.js +235 -18
- package/dist/tools/sdlc/compilerMetadataPrune.d.ts +16 -0
- package/dist/tools/sdlc/compilerMetadataPrune.js +44 -1
- package/dist/tools/sdlc/odataActionGuard.d.ts +66 -0
- package/dist/tools/sdlc/odataActionGuard.js +226 -0
- package/dist/tools/sdlc/runBpCheck.js +14 -8
- package/dist/tools/sdlc/sysTestRunner.d.ts +19 -1
- package/dist/tools/sdlc/sysTestRunner.js +153 -35
- package/dist/tools/sdlc/undoLastModification.js +26 -2
- package/dist/tools/sdlc/updateSymbolIndex.js +10 -6
- package/dist/tools/smart/codeGen.js +7 -1
- package/dist/tools/smart/generateSmartForm.js +9 -0
- package/dist/tools/smart/generateSmartReport.js +9 -0
- package/dist/tools/smart/generateSmartTable.js +24 -2
- package/dist/tools/specs/opSpecs.d.ts +13 -0
- package/dist/tools/specs/opSpecs.js +17 -1
- package/dist/tools/toolHandler.js +6 -6
- package/dist/tools/write/compileLabels.d.ts +4 -2
- package/dist/tools/write/compileLabels.js +33 -9
- package/dist/tools/write/createD365File.js +35 -9
- package/dist/tools/write/deleteD365File.js +6 -0
- package/dist/tools/write/directXmlWriters.d.ts +43 -1
- package/dist/tools/write/directXmlWriters.js +183 -13
- package/dist/tools/write/edtBaseTypeFromExtends.d.ts +31 -0
- package/dist/tools/write/edtBaseTypeFromExtends.js +65 -0
- package/dist/tools/write/enumValueNames.d.ts +44 -0
- package/dist/tools/write/enumValueNames.js +130 -0
- package/dist/tools/write/inlineXppValidation.d.ts +7 -1
- package/dist/tools/write/inlineXppValidation.js +21 -4
- package/dist/tools/write/methodXmlFallback.d.ts +23 -0
- package/dist/tools/write/methodXmlFallback.js +36 -0
- package/dist/tools/write/modifyD365File.d.ts +15 -1
- package/dist/tools/write/modifyD365File.js +62 -32
- package/dist/tools/write/resolveReferences.d.ts +2 -1
- package/dist/tools/write/resolveReferences.js +39 -1
- package/dist/tools/xml/generateD365Xml.js +6 -2
- package/dist/tools/xml/xmlTemplateGenerator.d.ts +13 -0
- package/dist/tools/xml/xmlTemplateGenerator.js +46 -5
- package/dist/utils/axEnumProperties.d.ts +18 -0
- package/dist/utils/axEnumProperties.js +26 -0
- package/dist/utils/crossModelWriteGuard.js +6 -2
- package/dist/utils/effectivePrefix.js +12 -10
- package/dist/utils/eolUtils.d.ts +13 -0
- package/dist/utils/eolUtils.js +26 -0
- package/dist/utils/indexedXmlLookup.d.ts +28 -1
- package/dist/utils/indexedXmlLookup.js +45 -4
- package/dist/utils/methodSourceSpans.d.ts +32 -0
- package/dist/utils/methodSourceSpans.js +100 -0
- package/dist/utils/modelClassifier.d.ts +10 -0
- package/dist/utils/modelClassifier.js +23 -1
- package/dist/utils/modelPrefixInference.js +3 -3
- package/dist/utils/objectFileLookup.js +1 -0
- package/dist/utils/objectNaming.d.ts +11 -0
- package/dist/utils/objectNaming.js +46 -1
- package/dist/utils/objectNamingRules.js +14 -4
- package/dist/workspace/projectFile.d.ts +23 -3
- package/dist/workspace/projectFile.js +67 -36
- package/dist/workspace/projectMembership.js +2 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ Call `get_workspace_info()` before doing anything with D365FO objects.
|
|
|
22
22
|
|
|
23
23
|
## Terminal Prohibition
|
|
24
24
|
|
|
25
|
-
PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integration. Never use `run_in_terminal` or generate scripts as a fallback when an MCP tool fails — STOP and report the error verbatim.
|
|
25
|
+
PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integration. Never use `run_command_in_terminal` / `run_in_terminal` (or any other terminal tool) or generate scripts as a fallback when an MCP tool fails — STOP and report the error verbatim.
|
|
26
26
|
|
|
27
27
|
## Core Tool Mapping
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ PowerShell / any terminal command **WILL HANG** in VS 2022 / VS 2026 MCP integra
|
|
|
32
32
|
| Plan a new object before creating it | `prepare(mode="create", goal, objectName, objectType)` — returns collision check, naming, EDT/label hints + `groundingToken` |
|
|
33
33
|
| Create a D365FO object | `d365fo_file(action="create")` (never `create_file`) |
|
|
34
34
|
| Edit an existing object | `d365fo_file(action="modify")` (applies immediately — confirm in chat first) |
|
|
35
|
-
| Revert the last write | `d365fo_file(action="undo", filePath)` — git-tracked → checkout HEAD (discards ALL uncommitted changes to that file); untracked → deleted |
|
|
35
|
+
| Revert the last write | `d365fo_file(action="undo", filePath)` — git-tracked → checkout HEAD (discards ALL uncommitted changes to that file); untracked → deleted only if created this session |
|
|
36
36
|
| Search objects | `search` — multiple via `search(queries[])`, custom-only via `search(scope="extensions")` |
|
|
37
37
|
| Read any object's metadata | `get_object_info(objectType, name, options?)` — objectType ∈ class/table/form/query/view/enum/edt/report/data-entity/menu-item/service/map/config-key/security-policy/macro. 2+ known names: `get_object_info(objects=[{objectType,objectName},…])` — ONE call, never a loop |
|
|
38
38
|
| Method signature for CoC | `get_object_info(objectType="class", name, options={method, include:"signature"})` (already returned by `prepare(mode="change")`) |
|
|
@@ -751,6 +751,7 @@ namespace D365MetadataBridge.Services
|
|
|
751
751
|
case "int": case "integer": axEdt = new AxEdtInt { Name = name }; break;
|
|
752
752
|
case "real": axEdt = new AxEdtReal { Name = name }; break;
|
|
753
753
|
case "date": axEdt = new AxEdtDate { Name = name }; break;
|
|
754
|
+
case "time": case "timeofday": axEdt = new AxEdtTime { Name = name }; break;
|
|
754
755
|
case "utcdatetime": case "datetime": axEdt = new AxEdtUtcDateTime { Name = name }; break;
|
|
755
756
|
case "int64": axEdt = new AxEdtInt64 { Name = name }; break;
|
|
756
757
|
case "enum": axEdt = new AxEdtEnum { Name = name }; break;
|
|
@@ -1478,6 +1479,22 @@ namespace D365MetadataBridge.Services
|
|
|
1478
1479
|
|
|
1479
1480
|
return new { success = true, operation = "add-method", objectType, objectName, methodName, api = "IMetaViewProvider.Update" };
|
|
1480
1481
|
}
|
|
1482
|
+
case "data-entity":
|
|
1483
|
+
{
|
|
1484
|
+
var axEntity = _provider.DataEntityViews.Read(objectName)
|
|
1485
|
+
?? throw new ArgumentException($"Data entity '{objectName}' not found");
|
|
1486
|
+
var msi = GetModelSaveInfoForObject(_provider.DataEntityViews, objectName);
|
|
1487
|
+
|
|
1488
|
+
if (!TryUpdateMethodSourceInPlace(axEntity, methodName, source))
|
|
1489
|
+
{
|
|
1490
|
+
var axMethod = new AxMethod { Name = methodName, Source = source };
|
|
1491
|
+
((dynamic)axEntity).Methods.Add(axMethod);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
((IMetaDataEntityViewProvider)_provider.DataEntityViews).Update(axEntity, msi);
|
|
1495
|
+
|
|
1496
|
+
return new { success = true, operation = "add-method", objectType, objectName, methodName, api = "IMetaDataEntityViewProvider.Update" };
|
|
1497
|
+
}
|
|
1481
1498
|
case "form-extension":
|
|
1482
1499
|
{
|
|
1483
1500
|
var axExt = _provider.FormExtensions.Read(objectName)
|
|
@@ -1572,6 +1589,8 @@ namespace D365MetadataBridge.Services
|
|
|
1572
1589
|
var axTable = _provider.Tables.Read(tableName);
|
|
1573
1590
|
if (axTable != null)
|
|
1574
1591
|
{
|
|
1592
|
+
if (HasMemberNamed(axTable.Fields, fieldName))
|
|
1593
|
+
return AlreadyPresent("add-field", tableName, $"field '{fieldName}'", "Use modify-field to change it.", "IMetaTableProvider.Update");
|
|
1575
1594
|
var msi = GetModelSaveInfoForObject(_provider.Tables, tableName);
|
|
1576
1595
|
axTable.AddField(axField);
|
|
1577
1596
|
var tableProvider = _provider.Tables as IMetaTableProvider
|
|
@@ -1583,6 +1602,8 @@ namespace D365MetadataBridge.Services
|
|
|
1583
1602
|
var axExt = _provider.TableExtensions.Read(tableName);
|
|
1584
1603
|
if (axExt != null)
|
|
1585
1604
|
{
|
|
1605
|
+
if (HasMemberNamed(axExt.Fields, fieldName))
|
|
1606
|
+
return AlreadyPresent("add-field", tableName, $"field '{fieldName}'", "Use modify-field to change it.", "IMetaTableExtensionProvider.Update");
|
|
1586
1607
|
var msi = GetModelSaveInfoForObject(_provider.TableExtensions, tableName);
|
|
1587
1608
|
axExt.Fields.Add(axField);
|
|
1588
1609
|
var extProvider = _provider.TableExtensions as IMetaTableExtensionProvider
|
|
@@ -1594,6 +1615,30 @@ namespace D365MetadataBridge.Services
|
|
|
1594
1615
|
throw new ArgumentException($"Table or table-extension '{tableName}' not found");
|
|
1595
1616
|
}
|
|
1596
1617
|
|
|
1618
|
+
/// <summary>
|
|
1619
|
+
/// True when a metadata collection already holds a member of this name (by its Name
|
|
1620
|
+
/// property, case-insensitive, as the AOT compares names).
|
|
1621
|
+
/// </summary>
|
|
1622
|
+
/// <remarks>
|
|
1623
|
+
/// The table Add* writes did not look before adding. A field group the caller re-sends
|
|
1624
|
+
/// (table create already writes AutoReport, AutoLookup, …) failed inside the SDK with
|
|
1625
|
+
/// "already exists among elements" and stopped the batch it was in, and the comment on
|
|
1626
|
+
/// the enum add-field path records AddField ending up with the field twice.
|
|
1627
|
+
/// </remarks>
|
|
1628
|
+
private static bool HasMemberNamed(System.Collections.IEnumerable items, string name)
|
|
1629
|
+
{
|
|
1630
|
+
foreach (var item in items)
|
|
1631
|
+
{
|
|
1632
|
+
var itemName = item?.GetType().GetProperty("Name")?.GetValue(item) as string;
|
|
1633
|
+
if (string.Equals(itemName, name, StringComparison.OrdinalIgnoreCase)) return true;
|
|
1634
|
+
}
|
|
1635
|
+
return false;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/// <summary>The skip answer for an element that is already there: nothing written, and why.</summary>
|
|
1639
|
+
private static object AlreadyPresent(string operation, string objectName, string what, string hint, string api) =>
|
|
1640
|
+
new { success = true, operation, objectName, skipped = true, reason = $"{what} already exists on '{objectName}', nothing was written. {hint}", api };
|
|
1641
|
+
|
|
1597
1642
|
/// <summary>
|
|
1598
1643
|
/// add-field on a data-entity-view-extension: appends an AxDataEntityViewMappedField
|
|
1599
1644
|
/// to <Fields>, optionally registering it in a base-entity field group.
|
|
@@ -1705,7 +1750,7 @@ namespace D365MetadataBridge.Services
|
|
|
1705
1750
|
?? throw new ArgumentException($"EDT '{objectName}' not found");
|
|
1706
1751
|
var msi = GetModelSaveInfoForObject(_provider.Edts, objectName);
|
|
1707
1752
|
if (!SetAxEdtProperty(obj, propertyPath, propertyValue))
|
|
1708
|
-
throw new ArgumentException($"Unknown AxEdt property '{propertyPath}' — nothing was written. Supported: label, helpText, extends, stringSize, referenceTable.");
|
|
1753
|
+
throw new ArgumentException($"Unknown AxEdt property '{propertyPath}' — nothing was written. Supported: label, helpText, extends, stringSize, referenceTable, enumType (enum EDTs).");
|
|
1709
1754
|
((IMetaEdtProvider)_provider.Edts).Update(obj, msi);
|
|
1710
1755
|
return new { success = true, operation = "modify-property", objectType, objectName, propertyPath, propertyValue, api = "Update" };
|
|
1711
1756
|
}
|
|
@@ -1951,6 +1996,17 @@ namespace D365MetadataBridge.Services
|
|
|
1951
1996
|
((IMetaViewProvider)_provider.Views).Update(obj, msi);
|
|
1952
1997
|
return new { success = true, operation = "replace-code", objectType, objectName, methodName, api = "Update" };
|
|
1953
1998
|
}
|
|
1999
|
+
case "data-entity":
|
|
2000
|
+
{
|
|
2001
|
+
var obj = _provider.DataEntityViews.Read(objectName)
|
|
2002
|
+
?? throw new ArgumentException($"Data entity '{objectName}' not found");
|
|
2003
|
+
var msi = GetModelSaveInfoForObject(_provider.DataEntityViews, objectName);
|
|
2004
|
+
var replaced = ReplaceInMethods(obj, methodName, oldCode, newCode);
|
|
2005
|
+
if (!replaced)
|
|
2006
|
+
throw new InvalidOperationException($"oldCode not found in {objectName}" + (methodName != null ? $".{methodName}" : ""));
|
|
2007
|
+
((IMetaDataEntityViewProvider)_provider.DataEntityViews).Update(obj, msi);
|
|
2008
|
+
return new { success = true, operation = "replace-code", objectType, objectName, methodName, api = "Update" };
|
|
2009
|
+
}
|
|
1954
2010
|
case "form-extension":
|
|
1955
2011
|
{
|
|
1956
2012
|
var obj = _provider.FormExtensions.Read(objectName)
|
|
@@ -2051,6 +2107,16 @@ namespace D365MetadataBridge.Services
|
|
|
2051
2107
|
((IMetaViewProvider)_provider.Views).Update(obj, msi);
|
|
2052
2108
|
return new { success = true, operation = "remove-method", objectType, objectName, methodName, api = "IMetaViewProvider.Update" };
|
|
2053
2109
|
}
|
|
2110
|
+
case "data-entity":
|
|
2111
|
+
{
|
|
2112
|
+
var obj = _provider.DataEntityViews.Read(objectName)
|
|
2113
|
+
?? throw new ArgumentException($"Data entity '{objectName}' not found");
|
|
2114
|
+
var msi = GetModelSaveInfoForObject(_provider.DataEntityViews, objectName);
|
|
2115
|
+
if (!RemoveMethodByName(obj, methodName))
|
|
2116
|
+
throw new InvalidOperationException($"Method '{methodName}' not found on data entity '{objectName}'");
|
|
2117
|
+
((IMetaDataEntityViewProvider)_provider.DataEntityViews).Update(obj, msi);
|
|
2118
|
+
return new { success = true, operation = "remove-method", objectType, objectName, methodName, api = "IMetaDataEntityViewProvider.Update" };
|
|
2119
|
+
}
|
|
2054
2120
|
case "form-extension":
|
|
2055
2121
|
{
|
|
2056
2122
|
var obj = _provider.FormExtensions.Read(objectName)
|
|
@@ -2132,6 +2198,8 @@ namespace D365MetadataBridge.Services
|
|
|
2132
2198
|
var axTable = _provider.Tables.Read(tableName);
|
|
2133
2199
|
if (axTable != null)
|
|
2134
2200
|
{
|
|
2201
|
+
if (HasMemberNamed(axTable.Indexes, indexName))
|
|
2202
|
+
return AlreadyPresent("add-index", tableName, $"index '{indexName}'", "To change it, remove-index then add-index.", "IMetaTableProvider.Update");
|
|
2135
2203
|
var msi = GetModelSaveInfoForObject(_provider.Tables, tableName);
|
|
2136
2204
|
axTable.AddIndex(axIdx);
|
|
2137
2205
|
((IMetaTableProvider)_provider.Tables).Update(axTable, msi);
|
|
@@ -2141,6 +2209,8 @@ namespace D365MetadataBridge.Services
|
|
|
2141
2209
|
var axExt = _provider.TableExtensions.Read(tableName);
|
|
2142
2210
|
if (axExt != null)
|
|
2143
2211
|
{
|
|
2212
|
+
if (HasMemberNamed(axExt.Indexes, indexName))
|
|
2213
|
+
return AlreadyPresent("add-index", tableName, $"index '{indexName}'", "To change it, remove-index then add-index.", "IMetaTableExtensionProvider.Update");
|
|
2144
2214
|
var msi = GetModelSaveInfoForObject(_provider.TableExtensions, tableName);
|
|
2145
2215
|
axExt.Indexes.Add(axIdx);
|
|
2146
2216
|
var extProvider = _provider.TableExtensions as IMetaTableExtensionProvider
|
|
@@ -2443,6 +2513,8 @@ namespace D365MetadataBridge.Services
|
|
|
2443
2513
|
var axTable = _provider.Tables.Read(tableName);
|
|
2444
2514
|
if (axTable != null)
|
|
2445
2515
|
{
|
|
2516
|
+
if (HasMemberNamed(axTable.Relations, relationName))
|
|
2517
|
+
return AlreadyPresent("add-relation", tableName, $"relation '{relationName}'", "To change it, remove-relation then add-relation.", "IMetaTableProvider.Update");
|
|
2446
2518
|
var msi = GetModelSaveInfoForObject(_provider.Tables, tableName);
|
|
2447
2519
|
axTable.AddRelation(axRel);
|
|
2448
2520
|
((IMetaTableProvider)_provider.Tables).Update(axTable, msi);
|
|
@@ -2520,6 +2592,8 @@ namespace D365MetadataBridge.Services
|
|
|
2520
2592
|
};
|
|
2521
2593
|
}
|
|
2522
2594
|
|
|
2595
|
+
if (HasMemberNamed(axExt.Relations, relationName))
|
|
2596
|
+
return AlreadyPresent("add-relation", tableName, $"relation '{relationName}'", "To change it, remove-relation then add-relation.", "IMetaTableExtensionProvider.Update");
|
|
2523
2597
|
axExt.Relations.Add(axRel);
|
|
2524
2598
|
extProvider.Update(axExt, msi);
|
|
2525
2599
|
return new
|
|
@@ -2619,6 +2693,8 @@ namespace D365MetadataBridge.Services
|
|
|
2619
2693
|
var axTable = _provider.Tables.Read(tableName);
|
|
2620
2694
|
if (axTable != null)
|
|
2621
2695
|
{
|
|
2696
|
+
if (HasMemberNamed(axTable.FieldGroups, groupName))
|
|
2697
|
+
return AlreadyPresent("add-field-group", tableName, $"field group '{groupName}'", "Use add-field-to-field-group to add fields to it.", "IMetaTableProvider.Update");
|
|
2622
2698
|
var msi = GetModelSaveInfoForObject(_provider.Tables, tableName);
|
|
2623
2699
|
axTable.AddFieldGroup(axFg);
|
|
2624
2700
|
((IMetaTableProvider)_provider.Tables).Update(axTable, msi);
|
|
@@ -2628,6 +2704,8 @@ namespace D365MetadataBridge.Services
|
|
|
2628
2704
|
var axExt = _provider.TableExtensions.Read(tableName);
|
|
2629
2705
|
if (axExt != null)
|
|
2630
2706
|
{
|
|
2707
|
+
if (HasMemberNamed(axExt.FieldGroups, groupName))
|
|
2708
|
+
return AlreadyPresent("add-field-group", tableName, $"field group '{groupName}'", "Use add-field-to-field-group to add fields to it.", "IMetaTableExtensionProvider.Update");
|
|
2631
2709
|
var msi = GetModelSaveInfoForObject(_provider.TableExtensions, tableName);
|
|
2632
2710
|
axExt.FieldGroups.Add(axFg);
|
|
2633
2711
|
var extProvider = _provider.TableExtensions as IMetaTableExtensionProvider
|
|
@@ -2727,6 +2805,11 @@ namespace D365MetadataBridge.Services
|
|
|
2727
2805
|
if (targetFg == null)
|
|
2728
2806
|
throw new InvalidOperationException($"Field group '{groupName}' not found on table '{tableName}'");
|
|
2729
2807
|
|
|
2808
|
+
foreach (AxTableFieldGroupField existing in targetFg.Fields)
|
|
2809
|
+
{
|
|
2810
|
+
if (string.Equals(existing.DataField, fieldName, StringComparison.OrdinalIgnoreCase))
|
|
2811
|
+
return new { success = true, operation = "add-field-to-field-group", objectName = tableName, groupName, fieldName, extendBaseFieldGroup = false, skipped = true, reason = $"field '{fieldName}' already in field group '{groupName}'", api = "IMetaTableProvider.Update" };
|
|
2812
|
+
}
|
|
2730
2813
|
targetFg.AddField(new AxTableFieldGroupField { DataField = fieldName });
|
|
2731
2814
|
|
|
2732
2815
|
((IMetaTableProvider)_provider.Tables).Update(axTable, msi);
|
|
@@ -2776,6 +2859,11 @@ namespace D365MetadataBridge.Services
|
|
|
2776
2859
|
$"Field group '{groupName}' not found on table-extension '{tableName}'. " +
|
|
2777
2860
|
"If it is a group defined by the BASE table, pass extendBaseFieldGroup=true to append the field through <FieldGroupExtensions> instead.");
|
|
2778
2861
|
|
|
2862
|
+
foreach (AxTableFieldGroupField existing in targetFg.Fields)
|
|
2863
|
+
{
|
|
2864
|
+
if (string.Equals(existing.DataField, fieldName, StringComparison.OrdinalIgnoreCase))
|
|
2865
|
+
return new { success = true, operation = "add-field-to-field-group", objectName = tableName, groupName, fieldName, extendBaseFieldGroup = false, skipped = true, reason = $"field '{fieldName}' already in field group '{groupName}'", api = "IMetaTableExtensionProvider.Update" };
|
|
2866
|
+
}
|
|
2779
2867
|
targetFg.AddField(new AxTableFieldGroupField { DataField = fieldName });
|
|
2780
2868
|
extProvider.Update(axExt, msi);
|
|
2781
2869
|
return new { success = true, operation = "add-field-to-field-group", objectName = tableName, groupName, fieldName, extendBaseFieldGroup = false, api = "IMetaTableExtensionProvider.Update" };
|
|
@@ -3558,6 +3646,30 @@ namespace D365MetadataBridge.Services
|
|
|
3558
3646
|
// HELPERS: Table Field Creation
|
|
3559
3647
|
// ========================
|
|
3560
3648
|
|
|
3649
|
+
/// <summary>
|
|
3650
|
+
/// Kernel EDTs: defined by the X++ runtime, with no AxEdt file, so IMetaEdtProvider.Exists
|
|
3651
|
+
/// answers false for them although shipped tables use them (DataAreaId 841 fields, UserId
|
|
3652
|
+
/// 331, RecId 319, ValidFromDateTime 245 ...). Derived by census + readEdt probe on
|
|
3653
|
+
/// 7.0.7996.33 (#1179). Mirrors src/knowledge/kernelEdts.ts; a parity test keeps the two equal.
|
|
3654
|
+
/// </summary>
|
|
3655
|
+
private static readonly HashSet<string> KernelEdtNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
|
3656
|
+
{
|
|
3657
|
+
"DataAreaId", "SelectableDataArea", "UserId", "RecId", "ValidFromDateTime", "ValidToDateTime",
|
|
3658
|
+
"ValidFromDate", "ValidToDate", "TableName", "FieldName", "CreatedDateTime", "RelationType",
|
|
3659
|
+
"FieldId", "TimeOfDay", "ClassName", "ClassId", "TableId", "IdentifierName",
|
|
3660
|
+
"SecurityRoleAotName", "ModifiedDateTime", "SecurityRoleName", "CreatedBy", "EnumName", "SysRowVersionNumber",
|
|
3661
|
+
"CreatedTransactionId", "NetworkAlias", "ExtendedTypeId", "PartitionKey", "UtilElementName", "UserIdStr",
|
|
3662
|
+
"MethodName", "RecVersion", "InstalledLanguageId", "NetworkDomain", "ModifiedBy", "FormName",
|
|
3663
|
+
"QueryName", "SequenceNum", "EnumId", "SecurityDutyName", "ConfigurationKeyName", "SecurityDutyIdentifier",
|
|
3664
|
+
"MenuItemName", "ReportName", "ResourceName", "ConfigurationKeyId", "ExtendedDataTypeName", "Partition",
|
|
3665
|
+
"MoneyMST", "UtilElementId", "Sid", "SecurityPrivilegeName", "SecurityPrivilegeIdentifier", "SecurableName",
|
|
3666
|
+
"SecurityRoleDescription", "MetadataXmlObject", "PreferredLocale", "WorkflowCategoryName", "MenuItemNameDisplay", "WorkflowTypeName",
|
|
3667
|
+
"LicenseCodeId", "SegregationOfDutiesRuleName", "IndexName", "RowNumber", "ModelName", "WebUrlItemName",
|
|
3668
|
+
"MenuItemNameAction", "DeploymentRecId", "MenuItemNameOutput", "ServiceName", "TableCollectionName", "ModelElementRecid",
|
|
3669
|
+
"SecurityRisk", "SecurityMitigation", "SegregationOfDutiesOverrideComment", "TitleFields", "GlobalObjectCacheScope", "WorkflowApprovalName",
|
|
3670
|
+
"Money", "AssemblyName", "SecurityDutyDescription", "SegmentedEntryField", "Sha1HashCode",
|
|
3671
|
+
};
|
|
3672
|
+
|
|
3561
3673
|
/// <summary>
|
|
3562
3674
|
/// Refuse to write an <ExtendedDataType> naming an EDT the provider does not know.
|
|
3563
3675
|
/// The metadata writer accepts any string here, so a misspelled EDT serialized fine
|
|
@@ -3567,9 +3679,13 @@ namespace D365MetadataBridge.Services
|
|
|
3567
3679
|
/// Deliberately fails OPEN when the provider itself throws (an Exists() that cannot
|
|
3568
3680
|
/// answer is not evidence the EDT is missing, and blocking a valid write on a
|
|
3569
3681
|
/// provider hiccup is a worse failure than the one this guards).
|
|
3682
|
+
///
|
|
3683
|
+
/// A kernel EDT passes without asking: Exists() answers false for every one of them
|
|
3684
|
+
/// (they have no AxEdt file), although shipped tables use them thousands of times (#1179).
|
|
3570
3685
|
/// </summary>
|
|
3571
3686
|
private void RequireExtendedDataTypeExists(string fieldName, string edtName, string what)
|
|
3572
3687
|
{
|
|
3688
|
+
if (KernelEdtNames.Contains(edtName)) return;
|
|
3573
3689
|
bool known;
|
|
3574
3690
|
try { known = _provider.Edts.Exists(edtName); }
|
|
3575
3691
|
catch { return; }
|
|
@@ -3602,6 +3718,12 @@ namespace D365MetadataBridge.Services
|
|
|
3602
3718
|
case "date":
|
|
3603
3719
|
axField = new AxTableFieldDate();
|
|
3604
3720
|
break;
|
|
3721
|
+
case "time":
|
|
3722
|
+
case "timeofday":
|
|
3723
|
+
// 77 shipped fields on the kernel EDT TimeOfDay are AxTableFieldTime; without
|
|
3724
|
+
// this case "Time" fell to default and was looked up as an EDT name.
|
|
3725
|
+
axField = new AxTableFieldTime();
|
|
3726
|
+
break;
|
|
3605
3727
|
case "utcdatetime":
|
|
3606
3728
|
case "datetime":
|
|
3607
3729
|
axField = new AxTableFieldUtcDateTime();
|
|
@@ -3795,6 +3917,13 @@ namespace D365MetadataBridge.Services
|
|
|
3795
3917
|
strEdt.StringSize = ss;
|
|
3796
3918
|
break;
|
|
3797
3919
|
case "referencetable": edt.ReferenceTable = value; break;
|
|
3920
|
+
case "enumtype":
|
|
3921
|
+
// Only an enum EDT has an EnumType. Every shipped child of an enum EDT
|
|
3922
|
+
// states it (1,512 of 1,512, equal to the parent's), so without this an
|
|
3923
|
+
// enum EDT created through the bridge had no enum at all.
|
|
3924
|
+
if (edt is not AxEdtEnum enumEdt) return false;
|
|
3925
|
+
enumEdt.EnumType = value;
|
|
3926
|
+
break;
|
|
3798
3927
|
case "basetype": break; // handled at construction time
|
|
3799
3928
|
default:
|
|
3800
3929
|
Console.Error.WriteLine($"[WriteService] Unknown AxEdt property: {prop}");
|
|
@@ -369,6 +369,7 @@ export declare function bridgeRemoveMethod(bridge: BridgeClient | undefined, obj
|
|
|
369
369
|
export declare function bridgeAddIndex(bridge: BridgeClient | undefined, tableName: string, indexName: string, fields?: string[], allowDuplicates?: boolean, alternateKey?: boolean): Promise<{
|
|
370
370
|
success: boolean;
|
|
371
371
|
message: string;
|
|
372
|
+
skipped?: boolean;
|
|
372
373
|
} | null>;
|
|
373
374
|
/**
|
|
374
375
|
* Removes an index from a table via the C# bridge.
|
|
@@ -419,6 +420,7 @@ export declare function bridgeAddRelation(bridge: BridgeClient | undefined, tabl
|
|
|
419
420
|
success: boolean;
|
|
420
421
|
message: string;
|
|
421
422
|
propertiesWritten?: boolean;
|
|
423
|
+
skipped?: boolean;
|
|
422
424
|
} | null>;
|
|
423
425
|
/**
|
|
424
426
|
* Removes a relation from a table via the C# bridge.
|
|
@@ -433,6 +435,7 @@ export declare function bridgeRemoveRelation(bridge: BridgeClient | undefined, t
|
|
|
433
435
|
export declare function bridgeAddFieldGroup(bridge: BridgeClient | undefined, tableName: string, groupName: string, label?: string, fields?: string[]): Promise<{
|
|
434
436
|
success: boolean;
|
|
435
437
|
message: string;
|
|
438
|
+
skipped?: boolean;
|
|
436
439
|
} | null>;
|
|
437
440
|
/**
|
|
438
441
|
* Removes a field group from a table via the C# bridge.
|
|
@@ -1687,9 +1687,10 @@ export async function bridgeAddIndex(bridge, tableName, indexName, fields, allow
|
|
|
1687
1687
|
const result = await bridge.addIndex(tableName, indexName, fields, allowDuplicates, alternateKey);
|
|
1688
1688
|
return {
|
|
1689
1689
|
success: result.success,
|
|
1690
|
-
|
|
1690
|
+
skipped: result.skipped === true,
|
|
1691
|
+
message: skippedMessage(result, `Index '${indexName}'`) ?? (result.success
|
|
1691
1692
|
? `✅ Index '${indexName}' added via ${result.api}`
|
|
1692
|
-
: `Bridge addIndex returned success=false
|
|
1693
|
+
: `Bridge addIndex returned success=false`),
|
|
1693
1694
|
};
|
|
1694
1695
|
}
|
|
1695
1696
|
catch (e) {
|
|
@@ -1826,6 +1827,9 @@ export async function bridgeAddRelation(bridge, tableName, relationName, related
|
|
|
1826
1827
|
return null;
|
|
1827
1828
|
try {
|
|
1828
1829
|
const result = await bridge.addRelation(tableName, relationName, relatedTable, constraints, properties);
|
|
1830
|
+
const skip = skippedMessage(result, `Relation '${relationName}'`);
|
|
1831
|
+
if (skip)
|
|
1832
|
+
return { success: true, skipped: true, message: skip };
|
|
1829
1833
|
// An older bridge binary silently ignores the extra params; it echoes back only
|
|
1830
1834
|
// what it set, so the response says whether the on-disk fallback is still needed.
|
|
1831
1835
|
const r = result;
|
|
@@ -1837,6 +1841,7 @@ export async function bridgeAddRelation(bridge, tableName, relationName, related
|
|
|
1837
1841
|
const note = typeof r.note === 'string' ? ` ${r.note}` : '';
|
|
1838
1842
|
return {
|
|
1839
1843
|
success: result.success,
|
|
1844
|
+
skipped: false,
|
|
1840
1845
|
propertiesWritten,
|
|
1841
1846
|
message: result.success
|
|
1842
1847
|
? `✅ Relation '${relationName}' added via ${result.api}` +
|
|
@@ -1887,11 +1892,35 @@ export async function bridgeAddFieldGroup(bridge, tableName, groupName, label, f
|
|
|
1887
1892
|
return null;
|
|
1888
1893
|
try {
|
|
1889
1894
|
const result = await bridge.addFieldGroup(tableName, groupName, label, fields);
|
|
1895
|
+
// Table create always writes the Auto* groups, so "add-field-group AutoReport
|
|
1896
|
+
// with fields [A, B]" finds the group there. Skipping the whole call dropped the
|
|
1897
|
+
// fields the caller asked for; put the missing ones into the existing group.
|
|
1898
|
+
if (result.skipped === true && fields && fields.length > 0) {
|
|
1899
|
+
const added = [];
|
|
1900
|
+
const present = [];
|
|
1901
|
+
for (const field of fields) {
|
|
1902
|
+
const r = await bridge.addFieldToFieldGroup(tableName, groupName, field);
|
|
1903
|
+
if (r.skipped === true)
|
|
1904
|
+
present.push(field);
|
|
1905
|
+
else if (r.success)
|
|
1906
|
+
added.push(field);
|
|
1907
|
+
else
|
|
1908
|
+
return { success: false, message: `Bridge addFieldToFieldGroup(${groupName}, ${field}) returned success=false` + (added.length ? ` after adding ${added.join(', ')}` : '') };
|
|
1909
|
+
}
|
|
1910
|
+
if (added.length > 0) {
|
|
1911
|
+
return {
|
|
1912
|
+
success: true,
|
|
1913
|
+
message: `✅ Field group '${groupName}' already existed — added ${added.join(', ')} to it` +
|
|
1914
|
+
(present.length ? ` (${present.join(', ')} already in it)` : ''),
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1890
1918
|
return {
|
|
1891
1919
|
success: result.success,
|
|
1892
|
-
|
|
1920
|
+
skipped: result.skipped === true,
|
|
1921
|
+
message: skippedMessage(result, `Field group '${groupName}'`) ?? (result.success
|
|
1893
1922
|
? `✅ Field group '${groupName}' added via ${result.api}`
|
|
1894
|
-
: `Bridge addFieldGroup returned success=false
|
|
1923
|
+
: `Bridge addFieldGroup returned success=false`),
|
|
1895
1924
|
};
|
|
1896
1925
|
}
|
|
1897
1926
|
catch (e) {
|
|
@@ -72,6 +72,29 @@ export declare function recordBridgeFailure(operation: string, error: unknown, o
|
|
|
72
72
|
}): BridgeFailure;
|
|
73
73
|
/** One-line description of a failure, for a tool that wants to name it in its own message. */
|
|
74
74
|
export declare function describeBridgeFailure(failure: BridgeFailure): string;
|
|
75
|
+
/**
|
|
76
|
+
* The bridge's own message when it refused a VALUE the caller passed, else null.
|
|
77
|
+
*
|
|
78
|
+
* A create the bridge throws on falls back to the XML template. That is right for
|
|
79
|
+
* a bridge that cannot do the job (a model its provider does not know, an
|
|
80
|
+
* unsupported type), but not when the bridge validated a value and rejected it:
|
|
81
|
+
* the template writes the same value unchecked, and the invalid object reaches
|
|
82
|
+
* disk with "⚠️ Written by the local XML template". Seen with tableType
|
|
83
|
+
* "RegularTable". The C# enum-property validators word these as "'X' is not a
|
|
84
|
+
* valid <Property>" or "Invalid <Property> 'X'", both as -32602 (invalid params),
|
|
85
|
+
* and their lists of valid values are complete.
|
|
86
|
+
*
|
|
87
|
+
* The field EDT check ("extended data type 'X' does not exist — nothing was
|
|
88
|
+
* written") is deliberately NOT one of them: it asks IMetaEdtProvider.Exists, which
|
|
89
|
+
* answers "not found" for the kernel EDTs that have no AOT file — RecId, UserId,
|
|
90
|
+
* DataAreaId, ValidFromDateTime, ValidToDateTime, TimeOfDay, TableName, FieldId,
|
|
91
|
+
* CreatedDateTime (probed on 10.0 / 7.0.7996.33; together several thousand shipped
|
|
92
|
+
* table fields). Refusing on it would turn a valid create (a date-effective table's
|
|
93
|
+
* ValidFrom/ValidTo) into "Nothing was written", where the template writes it right.
|
|
94
|
+
* The bridge now lets the kernel EDTs it knows through (KernelEdtNames, #1179), but its
|
|
95
|
+
* Exists() is still only as complete as that list, so the check stays out of here.
|
|
96
|
+
*/
|
|
97
|
+
export declare function rejectedBridgeInput(failure: BridgeFailure): string | null;
|
|
75
98
|
/**
|
|
76
99
|
* The note appended to a response that was produced while the bridge was throwing.
|
|
77
100
|
* It has to say what the answer IS (index/disk data) as well as what went wrong —
|
|
@@ -75,6 +75,34 @@ export function recordBridgeFailure(operation, error, options) {
|
|
|
75
75
|
export function describeBridgeFailure(failure) {
|
|
76
76
|
return `${BRIDGE_FAILURE_MARKER} ${failure.operation} — ${failure.reason}`;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The bridge's own message when it refused a VALUE the caller passed, else null.
|
|
80
|
+
*
|
|
81
|
+
* A create the bridge throws on falls back to the XML template. That is right for
|
|
82
|
+
* a bridge that cannot do the job (a model its provider does not know, an
|
|
83
|
+
* unsupported type), but not when the bridge validated a value and rejected it:
|
|
84
|
+
* the template writes the same value unchecked, and the invalid object reaches
|
|
85
|
+
* disk with "⚠️ Written by the local XML template". Seen with tableType
|
|
86
|
+
* "RegularTable". The C# enum-property validators word these as "'X' is not a
|
|
87
|
+
* valid <Property>" or "Invalid <Property> 'X'", both as -32602 (invalid params),
|
|
88
|
+
* and their lists of valid values are complete.
|
|
89
|
+
*
|
|
90
|
+
* The field EDT check ("extended data type 'X' does not exist — nothing was
|
|
91
|
+
* written") is deliberately NOT one of them: it asks IMetaEdtProvider.Exists, which
|
|
92
|
+
* answers "not found" for the kernel EDTs that have no AOT file — RecId, UserId,
|
|
93
|
+
* DataAreaId, ValidFromDateTime, ValidToDateTime, TimeOfDay, TableName, FieldId,
|
|
94
|
+
* CreatedDateTime (probed on 10.0 / 7.0.7996.33; together several thousand shipped
|
|
95
|
+
* table fields). Refusing on it would turn a valid create (a date-effective table's
|
|
96
|
+
* ValidFrom/ValidTo) into "Nothing was written", where the template writes it right.
|
|
97
|
+
* The bridge now lets the kernel EDTs it knows through (KernelEdtNames, #1179), but its
|
|
98
|
+
* Exists() is still only as complete as that list, so the check stays out of here.
|
|
99
|
+
*/
|
|
100
|
+
export function rejectedBridgeInput(failure) {
|
|
101
|
+
const m = /Bridge error \[-32602\]: ([\s\S]*)$/.exec(failure.reason);
|
|
102
|
+
if (!m)
|
|
103
|
+
return null;
|
|
104
|
+
return /\bis not a valid\b|^Invalid \w+ '/.test(m[1]) ? m[1].trim() : null;
|
|
105
|
+
}
|
|
78
106
|
/**
|
|
79
107
|
* The note appended to a response that was produced while the bridge was throwing.
|
|
80
108
|
* It has to say what the answer IS (index/disk data) as well as what went wrong —
|
|
@@ -36,6 +36,7 @@ export interface BridgeReadinessSource {
|
|
|
36
36
|
bridge?: {
|
|
37
37
|
isReady?: boolean;
|
|
38
38
|
metadataAvailable?: boolean;
|
|
39
|
+
xrefAvailable?: boolean;
|
|
39
40
|
};
|
|
40
41
|
bridgeStartup?: BridgeStartup;
|
|
41
42
|
}
|
|
@@ -69,6 +70,15 @@ export type BridgeStartupState = 'ready' | 'starting' | 'unavailable';
|
|
|
69
70
|
* misreported as "not connected".
|
|
70
71
|
*/
|
|
71
72
|
export declare function bridgeStartupState(context: BridgeReadinessSource): BridgeStartupState;
|
|
73
|
+
/** Whether the cross-reference database can be read right now, and if not, why. */
|
|
74
|
+
export type XrefAvailability = 'ready' | 'starting' | 'not-connected' | 'no-xref';
|
|
75
|
+
/**
|
|
76
|
+
* Classify cross-reference access without waiting. There are three ways to have
|
|
77
|
+
* none, each with its own fix: a bridge still starting (retry), no bridge (fix
|
|
78
|
+
* the bridge), and a running bridge without a cross-reference database
|
|
79
|
+
* (configure one).
|
|
80
|
+
*/
|
|
81
|
+
export declare function xrefAvailability(context: BridgeReadinessSource): XrefAvailability;
|
|
72
82
|
/**
|
|
73
83
|
* Wait (bounded) for a bridge startup that is still in flight.
|
|
74
84
|
*
|
|
@@ -68,6 +68,19 @@ export function bridgeStartupState(context) {
|
|
|
68
68
|
return 'starting';
|
|
69
69
|
return 'unavailable';
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Classify cross-reference access without waiting. There are three ways to have
|
|
73
|
+
* none, each with its own fix: a bridge still starting (retry), no bridge (fix
|
|
74
|
+
* the bridge), and a running bridge without a cross-reference database
|
|
75
|
+
* (configure one).
|
|
76
|
+
*/
|
|
77
|
+
export function xrefAvailability(context) {
|
|
78
|
+
switch (bridgeStartupState(context)) {
|
|
79
|
+
case 'starting': return 'starting';
|
|
80
|
+
case 'unavailable': return 'not-connected';
|
|
81
|
+
default: return context.bridge?.xrefAvailable ? 'ready' : 'no-xref';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
71
84
|
/**
|
|
72
85
|
* Wait (bounded) for a bridge startup that is still in flight.
|
|
73
86
|
*
|
package/dist/bridge/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
export { BridgeClient, createBridgeClient } from './bridgeClient.js';
|
|
18
18
|
export type { BridgeClientOptions, BridgeReadyPayload, BridgeInfoPayload } from './bridgeClient.js';
|
|
19
19
|
export * from './bridgeTypes.js';
|
|
20
|
-
export { isBridgeFailure, describeBridgeFailure, renderBridgeFailureNote, recordBridgeFailure, runWithBridgeFailureScope, BRIDGE_FAILURE_MARKER, } from './bridgeFailure.js';
|
|
20
|
+
export { isBridgeFailure, describeBridgeFailure, rejectedBridgeInput, renderBridgeFailureNote, recordBridgeFailure, runWithBridgeFailureScope, BRIDGE_FAILURE_MARKER, } from './bridgeFailure.js';
|
|
21
21
|
export type { BridgeFailure, BridgeAttempt } from './bridgeFailure.js';
|
|
22
22
|
export { tryBridgeTable, tryBridgeClass, tryBridgeMethodSource, tryBridgeEnum, tryBridgeEdt, tryBridgeForm, tryBridgeReferences, tryBridgeSearch, tryBridgeQuery, tryBridgeView, tryBridgeDataEntity, tryBridgeReport, bridgeRefreshProvider, bridgeValidateAfterWrite, bridgeResolveObject, canBridgeCreate, canBridgeModify, bridgeCreateObject, bridgeCreateSmartTable, bridgeAddMethod, bridgeRemoveMethod, bridgeAddField, bridgeModifyField, bridgeRenameField, bridgeRemoveField, bridgeReplaceAllFields, bridgeAddIndex, bridgeAddFullTextIndex, bridgeRemoveFullTextIndex, bridgeAddTableMapping, bridgeRemoveTableMapping, bridgeRemoveIndex, bridgeAddRelation, bridgeRemoveRelation, bridgeAddFieldGroup, bridgeRemoveFieldGroup, bridgeAddFieldToFieldGroup, bridgeAddEnumValue, bridgeModifyEnumValue, bridgeRemoveEnumValue, bridgeAddControl, bridgeAddDataSource, bridgeSetProperty, bridgeReplaceCode, bridgeAddFieldModification, bridgeAddMenuItemToMenu, bridgeBatchModify, bridgeGetCapabilities, bridgeDiscoverFormPatterns, tryBridgeSecurityArtifact, tryBridgeMenuItem, tryBridgeTableExtensions, tryBridgeCompletion, tryBridgeCocExtensions, tryBridgeEventHandlers, tryBridgeApiUsageCallers, } from './bridgeAdapter.js';
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/bridge/index.js
CHANGED
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
export { BridgeClient, createBridgeClient } from './bridgeClient.js';
|
|
18
18
|
export * from './bridgeTypes.js';
|
|
19
|
-
export { isBridgeFailure, describeBridgeFailure, renderBridgeFailureNote, recordBridgeFailure, runWithBridgeFailureScope, BRIDGE_FAILURE_MARKER, } from './bridgeFailure.js';
|
|
19
|
+
export { isBridgeFailure, describeBridgeFailure, rejectedBridgeInput, renderBridgeFailureNote, recordBridgeFailure, runWithBridgeFailureScope, BRIDGE_FAILURE_MARKER, } from './bridgeFailure.js';
|
|
20
20
|
export { tryBridgeTable, tryBridgeClass, tryBridgeMethodSource, tryBridgeEnum, tryBridgeEdt, tryBridgeForm, tryBridgeReferences, tryBridgeSearch, tryBridgeQuery, tryBridgeView, tryBridgeDataEntity, tryBridgeReport, bridgeRefreshProvider, bridgeValidateAfterWrite, bridgeResolveObject, canBridgeCreate, canBridgeModify, bridgeCreateObject, bridgeCreateSmartTable, bridgeAddMethod, bridgeRemoveMethod, bridgeAddField, bridgeModifyField, bridgeRenameField, bridgeRemoveField, bridgeReplaceAllFields, bridgeAddIndex, bridgeAddFullTextIndex, bridgeRemoveFullTextIndex, bridgeAddTableMapping, bridgeRemoveTableMapping, bridgeRemoveIndex, bridgeAddRelation, bridgeRemoveRelation, bridgeAddFieldGroup, bridgeRemoveFieldGroup, bridgeAddFieldToFieldGroup, bridgeAddEnumValue, bridgeModifyEnumValue, bridgeRemoveEnumValue, bridgeAddControl, bridgeAddDataSource, bridgeSetProperty, bridgeReplaceCode, bridgeAddFieldModification, bridgeAddMenuItemToMenu, bridgeBatchModify, bridgeGetCapabilities, bridgeDiscoverFormPatterns, tryBridgeSecurityArtifact, tryBridgeMenuItem, tryBridgeTableExtensions, tryBridgeCompletion, tryBridgeCocExtensions, tryBridgeEventHandlers, tryBridgeApiUsageCallers, } from './bridgeAdapter.js';
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -65,7 +65,7 @@ export declare function missingPathFix(setting: import('../../config/settings.js
|
|
|
65
65
|
* meant a user who had already pinned the prefix was still told their model's
|
|
66
66
|
* naming wins (it does not) and offered the fix they had already applied (#893).
|
|
67
67
|
*/
|
|
68
|
-
export declare function checkPrefixResolution(configuredPrefix: string, modelName: string | null, modelObjectNames: string[], label: string, pinned?: boolean, noPrefix?: boolean): CheckResult[];
|
|
68
|
+
export declare function checkPrefixResolution(configuredPrefix: string, modelName: string | null, modelObjectNames: string[], label: string, pinned?: boolean, noPrefix?: boolean, asGiven?: boolean): CheckResult[];
|
|
69
69
|
/**
|
|
70
70
|
* A SQL server configured while SQL itself stays off.
|
|
71
71
|
*
|
|
@@ -9,6 +9,7 @@ import * as fs from 'node:fs';
|
|
|
9
9
|
import { relative, resolve } from 'node:path';
|
|
10
10
|
import { p } from '../ui.js';
|
|
11
11
|
import { serializeValue, settingByPath } from '../../config/settings.js';
|
|
12
|
+
import { xrefSetupAdvice } from '../../config/xrefSetup.js';
|
|
12
13
|
import { bridgeFreshness } from '../bridgeSources.js';
|
|
13
14
|
import { bridgeBuildCommand, dataRoot, installMode, isWindows, paths, repoRoot } from '../context.js';
|
|
14
15
|
import { commandExists } from '../exec.js';
|
|
@@ -275,7 +276,17 @@ async function checkWorkspaceDetection(store, label) {
|
|
|
275
276
|
* meant a user who had already pinned the prefix was still told their model's
|
|
276
277
|
* naming wins (it does not) and offered the fix they had already applied (#893).
|
|
277
278
|
*/
|
|
278
|
-
export function checkPrefixResolution(configuredPrefix, modelName, modelObjectNames, label, pinned = false, noPrefix = false) {
|
|
279
|
+
export function checkPrefixResolution(configuredPrefix, modelName, modelObjectNames, label, pinned = false, noPrefix = false, asGiven = false) {
|
|
280
|
+
// naming.prefixSource=as-given (#1134): the server renames nothing, so there is
|
|
281
|
+
// no prefix or token to check — the convention lives in the instruction file.
|
|
282
|
+
if (asGiven) {
|
|
283
|
+
return [{
|
|
284
|
+
severity: 'ok',
|
|
285
|
+
message: `${label}: names as given (naming.prefixSource=as-given) — nothing is prefixed or renamed, ` +
|
|
286
|
+
`extensions included; the convention is the one in the project's instruction file` +
|
|
287
|
+
(configuredPrefix ? ` (naming.prefix "${configuredPrefix}" is not applied)` : ''),
|
|
288
|
+
}];
|
|
289
|
+
}
|
|
279
290
|
// naming.prefixSource=none: no prefix by decision (#1085), so there is nothing
|
|
280
291
|
// to infer, pin or warn about — only what the server does instead.
|
|
281
292
|
if (noPrefix) {
|
|
@@ -543,7 +554,7 @@ export function checkXrefConfigured(store) {
|
|
|
543
554
|
return {
|
|
544
555
|
severity: 'info',
|
|
545
556
|
message: 'Cross-reference database not configured — find_references uses a name-based search instead of DYNAMICSXREFDB',
|
|
546
|
-
fix:
|
|
557
|
+
fix: xrefSetupAdvice(s => s),
|
|
547
558
|
};
|
|
548
559
|
}
|
|
549
560
|
/**
|
|
@@ -635,7 +646,7 @@ export async function doctorCommand() {
|
|
|
635
646
|
// config file (loadEnv), and the CLI never projects one onto the other.
|
|
636
647
|
const prefixSource = (process.env.EXTENSION_PREFIX_SOURCE
|
|
637
648
|
?? String(readSetting(root.store, settingByPath('naming.prefixSource')) ?? '')).trim().toLowerCase();
|
|
638
|
-
for (const r of checkPrefixResolution(configuredPrefix, detection.modelName, names, 'Naming', prefixSource === 'config', prefixSource === 'none'))
|
|
649
|
+
for (const r of checkPrefixResolution(configuredPrefix, detection.modelName, names, 'Naming', prefixSource === 'config', prefixSource === 'none', prefixSource === 'as-given'))
|
|
639
650
|
emit(r);
|
|
640
651
|
// C# bridge: the only write path; Windows-only.
|
|
641
652
|
if (isWindows) {
|
package/dist/config/settings.js
CHANGED
|
@@ -261,13 +261,17 @@ export const SETTINGS = [
|
|
|
261
261
|
'`naming.prefix`. Pin it when one model carries several feature prefixes that share a stem — inference learns ' +
|
|
262
262
|
'the shared stem, while the objects you write need the full one. `none` is for teams that use no prefix ' +
|
|
263
263
|
'(e.g. a suffix convention with `naming.suffix`): new objects, fields and methods keep the name as given, ' +
|
|
264
|
-
'and extension elements/classes embed the model name (CustTable.MyModel, CustTable_MyModel_Extension).
|
|
264
|
+
'and extension elements/classes embed the model name (CustTable.MyModel, CustTable_MyModel_Extension). ' +
|
|
265
|
+
'`as-given` goes further: the server renames nothing, extensions included, and only refuses a name that ' +
|
|
266
|
+
'cannot be an AOT name (no dot on an element extension, no `_Extension` on a class extension) — state the ' +
|
|
267
|
+
'convention in the project\'s instruction file (AGENTS.md, CLAUDE.md, .github/copilot-instructions.md). See ' +
|
|
265
268
|
'[Where the prefix comes from](CUSTOM_EXTENSIONS.md#where-the-prefix-comes-from).',
|
|
266
269
|
default: 'model',
|
|
267
270
|
choices: [
|
|
268
271
|
{ value: 'model', hint: 'the model\'s own objects decide, falling back to naming.prefix' },
|
|
269
272
|
{ value: 'config', hint: 'always naming.prefix, inference off (pre-1.8.2 behaviour)' },
|
|
270
273
|
{ value: 'none', hint: 'no prefix at all — names as given; extensions embed the model name' },
|
|
274
|
+
{ value: 'as-given', hint: 'never rename — every name as given, extensions too; convention in your instruction file' },
|
|
271
275
|
],
|
|
272
276
|
},
|
|
273
277
|
{
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to give the bridge its cross-reference database. One definition for every
|
|
3
|
+
* place that has to say it (find_references when it falls back, and doctor), so
|
|
4
|
+
* they cannot drift apart. It names both places the settings can live: the
|
|
5
|
+
* server reads the `env` block of .mcp.json first, and the config file only
|
|
6
|
+
* after it, so advice naming only the config file is incomplete.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The advice as a lowercase clause ("set …"), for the caller to lead in to.
|
|
10
|
+
* `code` formats setting names and values: backticks for Markdown (the
|
|
11
|
+
* default), identity for plain terminal output.
|
|
12
|
+
*/
|
|
13
|
+
export declare function xrefSetupAdvice(code?: (s: string) => string): string;
|
|
14
|
+
//# sourceMappingURL=xrefSetup.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How to give the bridge its cross-reference database. One definition for every
|
|
3
|
+
* place that has to say it (find_references when it falls back, and doctor), so
|
|
4
|
+
* they cannot drift apart. It names both places the settings can live: the
|
|
5
|
+
* server reads the `env` block of .mcp.json first, and the config file only
|
|
6
|
+
* after it, so advice naming only the config file is incomplete.
|
|
7
|
+
*/
|
|
8
|
+
import { settingByPath } from './settings.js';
|
|
9
|
+
/**
|
|
10
|
+
* The advice as a lowercase clause ("set …"), for the caller to lead in to.
|
|
11
|
+
* `code` formats setting names and values: backticks for Markdown (the
|
|
12
|
+
* default), identity for plain terminal output.
|
|
13
|
+
*/
|
|
14
|
+
export function xrefSetupAdvice(code = s => `\`${s}\``) {
|
|
15
|
+
const name = settingByPath('bridge.xrefDbName');
|
|
16
|
+
const server = settingByPath('bridge.xrefDbServer');
|
|
17
|
+
return `set ${code(name.env)} to the cross-reference database (usually ${code('DYNAMICSXREFDB')}), ` +
|
|
18
|
+
`and ${code(server.env)} if SQL Server is not on this machine. Put them in the ${code('env')} block ` +
|
|
19
|
+
`of ${code('.mcp.json')}, or set ${code(name.path)} / ${code(server.path)} in the config file. ` +
|
|
20
|
+
`Then restart the MCP server.`;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=xrefSetup.js.map
|