Repository navigation
Add a Dataverse template generated from the Web API's CSDL metadata - #433
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | a2aa8fa | Nov 26 2026, 06:35 PM |
fcc0c0b to
7eeac0e
Compare
The template generator reads OData CSDL documents and turns them into OpenAPI descriptions: rows of every table, associations, bound and unbound actions and functions, and $metadata. OpenAPI server variables become inputs of every method, validated as host names, so each Dataverse call names its environment. The template connects through the organization's own Microsoft Entra application and lists the user's environments on its page.
createRow writes only to entity sets the environment lists, operations that change existing data are updates, and environment tokens are never saved for a grant that changed meanwhile or offered again after Dataverse rejected them. Collections and primitive results are typed inside value, complex types keep their navigation properties, and only optional path parameters are left out.
| `INSERT INTO resource_token (userId, resource, accessToken, expiresAt) | ||
| SELECT ?, ?, ?, ? WHERE EXISTS ( | ||
| SELECT 1 FROM account WHERE userId = ? AND providerId = ? AND refreshToken = ? | ||
| ) |
There was a problem hiding this comment.
Parallel refreshes skip caching tokens
Concurrent refreshes for different environments can read the same stored value. If the first batch rotates account.refreshToken, the second batch's cache insert matches nothing. That call succeeds, but its next request must contact Microsoft again, adding delay and token requests.
Guard cache writes with a stable connection version rather than a refresh token that sibling requests also rotate.
There was a problem hiding this comment.
Leaving this as is. The second request still gets and uses its token; only the cache write is skipped, so the next call to that environment refreshes once more. Saving it would need the condition this guard removes. The rotated refresh token from the first request stays saved, and the previous one stays valid with Microsoft.
There was a problem hiding this comment.
That’s right. The second request still returns and uses its newly issued access token; only its cache write is skipped, so a later call to that environment refreshes again. The guard also prevents a refresh completing after disconnect/reconnect from restoring stale state. I’ll treat this as an intentional cache-efficiency tradeoff, not a correctness issue or merge blocker.
Adds a Microsoft Dataverse template. Like the other REST templates, it exposes the vendor API's own shape: every table's rows through the Web API's entity-set operations, and each action and function of the Web API as a typed method.
Changes
packages/template-generator/src/csdl.ts(new): turns an OData v4 CSDL$metadatadocument into an OpenAPI description./{entitySet}list and create,/{entitySet}({id})get, update and delete, and$refassociate and disassociate.@aliasquery parameters.{variable}in a server URL becomes a required input of every method. The runtime substitutes it and accepts only a host name, so a value can never add a path, credentials or another address. Dataverse uses this forenvironment, because every Web API call names its environment in its address.runtime/rest.ts: server variables,@aliasquery parameters sent as JSON, and optional OData function parameters left out of the call. Only parameters the description marks optional (optionalPathParameters) are left out. The file is copied into all REST templates; their behavior is unchanged.value, so those methods return{ value }. Complex types keep their navigation properties, such as the principal inPrincipalAccess.templates/dataverse:listRows,getRow,createRow,updateRow,deleteRow,associateRows,disassociateRows,getMetadata,callActionfor actions a solution adds, and the typed actions and functions such aswhoAmI,addPrivilegesRoleandpublishXml.listEnvironmentsreads the Global Discovery Service and returns each environment's host as methods take it.network_requiredwith the origin to allow.createRowwrites only to an entity set that the environment's service document lists. OData addresses unbound actions the same way, and an action must keep its own change class.createonly adds something new. Operations that also change what exists, such as granting privileges, adding team members or importing over existing customizations, areupdate.MICROSOFT_CLIENT_ID,MICROSOFT_CLIENT_SECRET) with the delegated Dynamics CRMuser_impersonationpermission. Managed sign-in is not offered yet. The managed broker would have to issue a token per environment, and that will come separately.Screenshots
New template, so there are no before images. Connected and setup, at 1280 px light and 390 px dark:
The not-connected and failed states are not shown. They use #422's layout unchanged.
Verification
network_required, rejected tokens, a refresh that finishes after the grant changed,createRowagainst an action's address, and setup without OAuth.rest.ts.pnpm checkis clean.whoAmI,retrieveVersion,retrieveUserPrivileges(bound),retrieveCurrentOrganization(an enum argument) andgetMetadata.Known limits
$batch(multipart/mixed) is not offered.getMetadatamay exceed the 8 MiB response limit in environments with many Dynamics 365 apps. The trial environment's document is 6.8 MB.

Confidence Score: 5/5
The PR appears safe to merge; the remaining token-caching issue is non-blocking.Findings
Summary
Adds a Dataverse template with typed methods generated from CSDL metadata.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Dataverse method] --> B[Check connection and request] B --> C{createRow?} C -->|Yes| D[Read service document] D --> E{Request succeeded?} E -->|No| F[Return recovery details] E -->|Yes| G[Check entity set] C -->|No| H[Check approval] G --> H H --> I[Send request with environment token] I --> J[Return data or recovery details]Reviews (3) · Last reviewed commit: "Report blocked environments and throttli..." · Reviewed by Greptile