@mohsinonxrm/pptb-dataverse-request-studio 1.4.0-beta.3 → 1.5.0-beta.1

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +375 -0
  2. package/README.md +81 -11
  3. package/SECURITY.md +8 -1
  4. package/dist/assets/AssociateMode-mu2ai0TV.js +1 -0
  5. package/dist/assets/AssociateTargetsEditor-BoH9Qxe8.js +1 -0
  6. package/dist/assets/BatchMode-BVAfFgPy.js +11 -0
  7. package/dist/assets/BinaryColumnPickers-DYpKoRIO.js +1 -0
  8. package/dist/assets/BulkDeleteMode-Df-XirlR.js +1 -0
  9. package/dist/assets/BulkWriteMode-UXREEvbe.js +6 -0
  10. package/dist/assets/DisassociateMode-CKBL5nUo.js +2 -0
  11. package/dist/assets/ExecuteWorkflowMode-4EWco-ze.js +1 -0
  12. package/dist/assets/ManageFileMode-BFNwxuEY.js +1 -0
  13. package/dist/assets/ManageImageMode-DX0AdPN1.js +1 -0
  14. package/dist/assets/MergeMode-BzyXLu1b.js +1 -0
  15. package/dist/assets/PredefinedQueryMode-BT-HdZHF.js +1 -0
  16. package/dist/assets/RetrieveNextLinkMode-QBuIwdgS.js +1 -0
  17. package/dist/assets/{cssMode-B4BP9f3X.js → cssMode-DRNC4UuD.js} +1 -1
  18. package/dist/assets/{freemarker2-DFKOu_2v.js → freemarker2-BITb8GyO.js} +1 -1
  19. package/dist/assets/{handlebars-cWHtgvCj.js → handlebars-BbDVduNH.js} +1 -1
  20. package/dist/assets/{html-DSPQITYl.js → html-Ru2Cy2VS.js} +1 -1
  21. package/dist/assets/{htmlMode-Cr-uAXsT.js → htmlMode-DeMh8vPt.js} +1 -1
  22. package/dist/assets/index-XmEQbXiX.js +703 -0
  23. package/dist/assets/{javascript-B3oRul8j.js → javascript-DLj2yjBO.js} +1 -1
  24. package/dist/assets/{jsonMode-_zXsQ367.js → jsonMode-DOHFeg2H.js} +1 -1
  25. package/dist/assets/{liquid-Cib5dNaW.js → liquid-udbJGOUP.js} +1 -1
  26. package/dist/assets/{mdx-8A_8JwPK.js → mdx-B6ABiFDH.js} +1 -1
  27. package/dist/assets/{monacoSetup-DObeMDBe.js → monacoSetup-CEhMjQNN.js} +3 -3
  28. package/dist/assets/{python-DsudPCj1.js → python-DDgBOsRh.js} +1 -1
  29. package/dist/assets/{razor-CrmV2uj7.js → razor-DGf0KCTP.js} +1 -1
  30. package/dist/assets/{tsMode-BnycW89y.js → tsMode-D4ZDTisA.js} +1 -1
  31. package/dist/assets/{typescript-Bs6iTDav.js → typescript-CJFgy1iR.js} +1 -1
  32. package/dist/assets/{xml-DuKZPRNV.js → xml-BXhJpCm5.js} +1 -1
  33. package/dist/assets/{yaml-DDDa6myK.js → yaml-B7iGwJkY.js} +1 -1
  34. package/dist/index.html +1 -1
  35. package/package.json +10 -3
  36. package/dist/assets/AssociateMode-Bs_R9XbQ.js +0 -1
  37. package/dist/assets/AssociateTargetsEditor-CVWE3tbv.js +0 -1
  38. package/dist/assets/BatchMode-XGXMc2XF.js +0 -11
  39. package/dist/assets/BinaryColumnPickers-mrnLqk3Z.js +0 -1
  40. package/dist/assets/BulkDeleteMode-DowWcbnA.js +0 -1
  41. package/dist/assets/BulkWriteMode-Dt3M0dGV.js +0 -6
  42. package/dist/assets/DisassociateMode-qIc2CUpE.js +0 -2
  43. package/dist/assets/ExecuteWorkflowMode-Ce6sKYci.js +0 -1
  44. package/dist/assets/ManageFileMode-CcNSQkJf.js +0 -1
  45. package/dist/assets/ManageImageMode-Dn4P4D6H.js +0 -1
  46. package/dist/assets/MergeMode-DzPQq2Ao.js +0 -1
  47. package/dist/assets/PredefinedQueryMode-CaQqp2lm.js +0 -1
  48. package/dist/assets/RetrieveNextLinkMode-BNbknSwe.js +0 -1
  49. package/dist/assets/index-D0g0tm7R.js +0 -702
package/CHANGELOG.md CHANGED
@@ -7,6 +7,381 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.0-beta.1] - 2026-10-30
11
+
12
+ The first 1.5.0 beta. Writes now ask before they're sent, naming the
13
+ environment, and Production gets a safe mode that's on by default ([#241]).
14
+ Read and execute requests send their headers, and impersonation is never
15
+ dropped silently ([#109]). The entity scope moves from Settings to a button in
16
+ the header ([#42]). Ids, names and filter values are checked and typed before
17
+ they go into a URL ([#221]). There are also accessibility, metadata-cache and
18
+ copy fixes, and 272 new tests for the write path.
19
+
20
+ Still a **prerelease** on the npm `beta` tag, with the gold Insider icon.
21
+ Power Platform ToolBox **1.2.7 or later** is recommended: older hosts can't
22
+ send request headers, so a request with an impersonation header isn't sent
23
+ on them.
24
+
25
+ ### ✨ Added
26
+
27
+ - **The entity scope is a button in the header** ([#42]), after the request
28
+ type, instead of Settings → Query Scope. It reads **Choose scope** until you
29
+ pick one, then the scope itself (`Contoso › Sales Core v1.2.0`, `+1` for
30
+ more, or **All entities**), with the full list as a tooltip when it's cut
31
+ off. Its popover holds the entity source, publishers, solutions and
32
+ Advanced Find only, and changes apply right away, per environment as
33
+ before:
34
+ - removing a publisher also removes its solutions;
35
+ - solutions are grouped Unmanaged / Managed, show `Name vX.Y.Z`, and search
36
+ matches the name, unique name or version;
37
+ - on first run a tip points at the button, once per environment;
38
+ - without a scope, the entity picker is disabled and reads "Choose a scope
39
+ to list entities", and the pane's **Choose scope** opens the popover. With
40
+ one, it counts the entities in scope.
41
+
42
+ The same design as FetchXML Studio's and Command Bar Studio's. Settings
43
+ keeps a pointer to the button.
44
+ - **Writes ask before they're sent** ([#241]). The confirmation names the
45
+ target: the environment (connection name, URL and type, with Production
46
+ highlighted), the operation, the table and the scope. Execute and Ctrl+Enter
47
+ both go through it.
48
+ - Merge, Execute Action / Custom API / Custom Action, Execute Workflow, Bulk
49
+ Write, `$batch` and ExecuteMultiple with writes, and multi-target
50
+ Associate / Disassociate always ask.
51
+ - Create, Update, Upsert, Delete and single-target Associate / Disassociate
52
+ ask on a Production connection.
53
+ - On Production, and for more than 100 records (or batch writes) anywhere,
54
+ you type the table (or operation) name before the button enables.
55
+ - If the connection changes while the confirmation is open, nothing is sent.
56
+ - The Bulk Delete Job confirmation names the environment too.
57
+ - **The header shows the connection and its environment type** inside
58
+ ToolBox too, with Production in red ([#241]).
59
+ - **Production safe mode** in Settings → Safety, on by default ([#241]).
60
+ - **README: "What this tool changes"** lists every request that changes data,
61
+ when it asks, and what DRS stores locally ([#241]).
62
+ - **Read, Execute Function, Associate / Disassociate and Bulk Delete Job
63
+ requests send their headers** ([#109]). The Headers pane says which rows
64
+ Execute sends and marks the rest as Code tab only. Later pages of a
65
+ Retrieve Multiple send the first page's headers, so they run as the same
66
+ user. It's an allow-list, so a plain read still sends none and never asks
67
+ for consent:
68
+ - impersonation (`MSCRMCallerID`, and a new `CallerObjectId` preset for
69
+ the Microsoft Entra object id) in all of them;
70
+ - `If-None-Match` and `Consistency` on reads. A matching etag shows as
71
+ **304 Not Modified**, not as an error;
72
+ - the bypass headers on Associate / Disassociate.
73
+ The page size's `Prefer` still keeps ToolBox's
74
+ `odata.include-annotations="*"`; other preferences stay in the Code tab.
75
+ - **Impersonation is never dropped silently** ([#109]).
76
+ - On a ToolBox older than 1.2.7, which can't send headers, a request with
77
+ an impersonation header isn't sent, instead of running as you. The same
78
+ goes for Associate / Disassociate with a bypass header.
79
+ - Both impersonation headers at once, or the presets' all-zero
80
+ placeholder, aren't sent either.
81
+ - A declined header prompt on Associate / Disassociate asks once and sends
82
+ nothing, rather than falling back to a request without your headers.
83
+ - **Execute Custom API and Custom Action list your own operations first**
84
+ ([#248]). A Dynamics org has well over a thousand of them, nearly all
85
+ Microsoft's. The Operation list now groups them:
86
+ - **Your org & ISVs** first, **Microsoft** below. Nothing is hidden, and
87
+ search covers both groups (publisher names too).
88
+ - Each one shows its solution's publisher, and so does the summary card.
89
+ - The Scope list counts your own operations per scope ("12 ops, 2 yours").
90
+ - Execute Action (WinOpportunity, QualifyLead, …) is unchanged.
91
+
92
+ ### 🐛 Fixed
93
+
94
+ - **The sidebar works with a screen reader and the keyboard** ([#243]). It
95
+ announced itself as a tree, but arrow keys did nothing, nested clauses
96
+ were read as top-level ones, and every parent said "expanded" although
97
+ nothing collapses. It's now a "Request structure" navigation landmark:
98
+ - each section has a heading and is a list named by it, and nested
99
+ clauses (an `$expand` relationship's clauses, required parameters, Bulk
100
+ Write rows) are nested lists, so their level is read;
101
+ - Tab moves between clauses, Enter or Space opens one, and the open one
102
+ is marked as current;
103
+ - the chevrons, which looked collapsible but weren't, are gone;
104
+ - the "modified" marker and the ✓ badge are read out;
105
+ - keyboard focus shows a ring inside the sidebar;
106
+ - the table name after an expanded relationship (`primarycontactid →
107
+ Contact`) has enough contrast to read.
108
+ - **Small labels are readable again** ([#330]). Badges such as "req",
109
+ "null", "File", "max 32 MB", "soon", "lookup" and the Results count used
110
+ Fluent's extra-small size, a 10px dot, so their text spilled out or was
111
+ cut off. They now use the small size, as the sidebar badges do since
112
+ [#200].
113
+ - **Expired metadata is refetched, not served as fresh** ([#334]). The table
114
+ list, and the columns of a table not yet loaded this session, are cached
115
+ for an hour. When that hour is up and they're fetched again, other pickers
116
+ now wait for the fetch instead of getting the old data, and a failed fetch
117
+ is retried on the next use instead of the old data counting as fresh for
118
+ another hour.
119
+ - **Retrieve Multiple's checks run once the table's columns arrive**
120
+ ([#347]). A saved request loaded before its table's metadata showed no
121
+ advisories, and Execute wasn't blocked for a query Dataverse rejects, until
122
+ you changed something.
123
+ - **Save and the Saved library use the current request and environment**
124
+ ([#347]). The header kept calling the handlers from when the mode last
125
+ published them, so they could read old data. Loading a saved Retrieve
126
+ Multiple request whose table this environment doesn't have now says so,
127
+ even when the table list arrived after the mode opened.
128
+ - **Text follow-ups** ([#317]):
129
+ - Associate and Disassociate say "Target record" when one target is
130
+ picked or the relationship takes only one, in the pane and the sidebar,
131
+ and "Target records" otherwise.
132
+ - An action or function that returns `Collection(<type>)` lists one item's
133
+ properties when the type is known, and a Custom API response with a
134
+ publisher prefix (`msdyn_ActivateProcessesResponse`) lists its
135
+ properties and is labelled complex, instead of being described as an
136
+ entity. On a Dynamics org that's several hundred operations.
137
+ - **Copy buttons go through ToolBox and say whether they worked** ([#242]).
138
+ Inside ToolBox, the webview can refuse the browser clipboard, and a
139
+ refused copy did nothing at all: you then pasted whatever was on the
140
+ clipboard before. Every Copy button (URL bar, Code tab, results, write
141
+ result, previews, Power Automate, …) now uses ToolBox's own clipboard
142
+ inside ToolBox (the browser's outside it), and confirms the copy with a
143
+ short "Copied" note or on the button itself. When it fails, it says
144
+ "Couldn't copy" and what to do instead. Retrieve NextLink's Paste says
145
+ when the clipboard can't be read.
146
+ - **Choosing a file no longer reads it into memory** ([#222]). Manage File,
147
+ Image and Attachment Data keep the file's name, size and type only: Execute
148
+ can't send binary content from inside ToolBox, and the Code tab uses a
149
+ placeholder for the bytes, so a large file used to freeze the tool for
150
+ nothing. Manage Image previews the chosen image through an object URL (up
151
+ to 5 MB). A pasted base64 body is capped at 10 MB, with a message.
152
+ - **Non-ASCII file names work in generated upload code** ([#222]). The
153
+ `x-ms-file-name` header only takes ASCII (and `fetch` / XHR throw on such
154
+ a header), so a name like `报告.pdf` or `Résumé.docx` travels as the
155
+ `x-ms-file-name` query parameter instead, as Microsoft documents, in both
156
+ the single-request and chunked uploads.
157
+ - **Invalidating one table's metadata now refetches it** ([#335]). The next
158
+ read used to return the old table from the in-memory registry. Nothing
159
+ invalidates a single table yet, so this changes nothing you can see today.
160
+ - **"Advanced Find only" works, and is off by default** ([#44]), matching
161
+ FetchXML Studio:
162
+ - Off: the table, column and relationship pickers offer everything.
163
+ - On: they offer only what Advanced Find shows (`IsValidForAdvancedFind`).
164
+ Image and File columns are always offered.
165
+ - Metadata now loads unfiltered, and only the pickers are scoped, so a
166
+ column already in a request keeps working either way. Before, the switch
167
+ did nothing, and columns and relationships that Advanced Find hides were
168
+ never offered.
169
+ - The read pickers still never offer columns that can't be read, and new
170
+ sorts, filter rules and functions start on a column the picker offers.
171
+ - The Create form doesn't treat columns Advanced Find hides (such as
172
+ `owneridtype`) as required, as before.
173
+ - A setting saved by an earlier version is reset to off once.
174
+ - Loading a saved request, pasting a URL and a batch item's entity set
175
+ check the table against every table, so a saved request for a table
176
+ outside the Query Scope loads instead of being reported missing.
177
+ - **Ids and names are checked before they go into a URL** ([#221]). A record
178
+ id must be a GUID, and a navigation property or column name a plain name,
179
+ before Execute enables. This applies in Associate, Disassociate, Execute
180
+ Action / Function / Workflow, Predefined Query and the file, image and
181
+ attachment modes. The other modes already checked. The executor refuses
182
+ them too, so a value like `x)/other_nav` can't send a different request.
183
+ - **A query function on a related table's column is caught inside `any` /
184
+ `all` too** ([#336]). Dataverse rejects a function such as `EqualUserId`
185
+ whose column runs through a relationship
186
+ (`PropertyName='parentcustomerid_account/ownerid'`). Outside a lambda
187
+ this already blocked Execute with an explanation; inside one it wasn't
188
+ checked, so the request was sent and failed.
189
+ - **Filter values are typed** ([#221]). A number, GUID or date column's
190
+ value goes into `$filter` unquoted only when it is one. Anything else is
191
+ quoted and escaped, and Execute is blocked with a message naming the value,
192
+ instead of a Dataverse 400. The DateTime fallback now escapes quotes. The
193
+ same applies to the Dataverse query functions (`LastXDays`, `Under`, …),
194
+ `$expand` inner filters and Bulk Delete Job. Filter column, lambda and
195
+ `$expand` names must be names too. EntityName columns (`objecttypecode`)
196
+ are now compared as strings, as the Web API expects.
197
+ - **Execute Function parameters are typed the same way** ([#221]). GUID and
198
+ date values go into the URL unquoted only when they are one, and record
199
+ references are escaped.
200
+ - **Imported saved requests are checked deeply** ([#221]). Entries whose
201
+ ids, names or query trees would change the URL are skipped, and the import
202
+ status says which and why. Copying or moving from another connection's
203
+ library applies the same check.
204
+ - **Retrieve Single no longer turns on `If-None-Match: null`** by default
205
+ ([#109]). Execute sends that header now, and `null` never matches an etag;
206
+ saved requests that have it still run without it.
207
+ - **Time zone independent times in a DST gap keep their digits** ([#337]).
208
+ Such a time is stored as typed, with no conversion. When it fell in the
209
+ hour your clocks skip (02:30 on a spring-forward day), the results grid and
210
+ the Update / Merge comparison showed it an hour later, and changing only
211
+ its date, or just clicking into the time picker and out, sent the later
212
+ time. The time picker itself still shows it an hour on, because it can
213
+ only hold a local time.
214
+ - **Exported URLs encode spaces** ([#221]). Postman, Insomnia and Bruno
215
+ collections, cURL / fetch / XHR / C# / PowerShell code and the HTTP-action
216
+ URIs write `%20`. The URL bar still shows spaces.
217
+
218
+ ### 🔧 Internal
219
+
220
+ - **Release model leftovers** ([#197]):
221
+ - `.github/dependabot.yml` sends grouped weekly updates into `dev` with a 14-day
222
+ cooldown, the same policy as FetchXML Studio and Command Bar Studio.
223
+ `RELEASING.md` describes it.
224
+ - `SECURITY.md` has the shared supported-versions table.
225
+ - **Alternate-key column types go through the shared type lookup**
226
+ ([#318]). Key columns typed separately (#64) now resolve the way every
227
+ other column does, Image and File included. No visible change: a key
228
+ column can't be an Image or File column.
229
+ - **Saved-request tests no longer re-import the store per test** ([#319]).
230
+ The store's startup (credential scrub, then read) is one function,
231
+ `startSavedStore()`, that the module runs at load and the tests call
232
+ directly. Those tests went from about 415 ms to about 20 ms each, so
233
+ they no longer time out when several test runs share the machine. One
234
+ test still loads the module afresh to check the startup wiring.
235
+ - **ESLint and a package check in CI** ([#273]), as in FetchXML Studio and
236
+ Command Bar Studio:
237
+ - `npm run lint` runs ESLint (recommended JS / TypeScript rules, React
238
+ hooks, jsx-a11y) with no warnings allowed, in CI. It also stops direct
239
+ `navigator.clipboard` use (#242). Fixing its findings removed dead code
240
+ and caught a crash: the `$apply` editor called two hooks after an early
241
+ return, so React threw when a table's metadata arrived after the
242
+ editor first rendered.
243
+ - CI and the release workflow check what `npm pack` would publish: the
244
+ files ToolBox needs, no sources or source maps, and a size budget.
245
+ - `npm run finalize-package` is gone; CI and the release workflow cover
246
+ it. `minAPI` stays at 1.2.0: DRS detects what the host can do at
247
+ runtime.
248
+ - **Tests for the write path** ([#235]): 272 new tests, 804 in all.
249
+ - A parity test checks, mode by mode, that Execute sends exactly what the
250
+ Code tab shows: method, URL, body and headers, apart from the documented
251
+ differences (headers the host builds, the reads' allow-list and page
252
+ size).
253
+ - The write executors' refusals: PUT of one column, alternate-key Upsert,
254
+ single-property Delete, unsafe ids, and impersonation on an older
255
+ ToolBox.
256
+ - Modules that had no tests: date and time values, the bypass headers,
257
+ workflow arguments, request validation, the query advisories, mode
258
+ drafts, the metadata cache and provider, and the ToolBox bridge's events.
259
+
260
+ [#197]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/197
261
+ [#42]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/42
262
+ [#347]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/347
263
+ [#330]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/330
264
+ [#242]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/242
265
+ [#317]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/317
266
+ [#334]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/334
267
+ [#235]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/235
268
+ [#273]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/273
269
+ [#319]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/319
270
+ [#318]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/318
271
+ [#248]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/248
272
+ [#335]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/335
273
+ [#222]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/222
274
+ [#44]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/44
275
+ [#336]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/336
276
+ [#109]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/109
277
+ [#221]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/221
278
+ [#337]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/337
279
+ [#241]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/241
280
+
281
+ ## [1.4.0] - 2026-10-30
282
+
283
+ The first stable release since 1.1.4, and the biggest so far. The work planned
284
+ for v1.2.0, v1.3.0 and v1.4.0 ships together, so there are no 1.2.x or 1.3.x
285
+ releases. It was iterated through `1.4.0-beta.1` to `1.4.0-beta.3` (detailed
286
+ below), and each beta was verified end to end in Power Platform ToolBox
287
+ against live Dataverse environments.
288
+
289
+ Request headers and page sizes on Execute need **Power Platform ToolBox 1.2.7
290
+ or later**. On older versions DRS keeps working and explains what can't be
291
+ sent.
292
+
293
+ ### ✨ Added
294
+
295
+ - **Four new modes:** Bulk Write (`CreateMultiple` / `UpdateMultiple` /
296
+ `UpsertMultiple`), Bulk Delete Job, `$batch` (change sets with `$n`
297
+ references) and ExecuteMultiple ([#8], [#10], [#9], [#11]).
298
+ - **Request headers through ToolBox 1.2.7+:** the Headers pane, `Prefer`
299
+ (page size, annotations) and `If-Match` are sent on Execute, and the write,
300
+ Execute Action and Execute Workflow modes send impersonation and bypass
301
+ headers, after a one-time approval in ToolBox ([#43], [#23], [#266]).
302
+ - **A reworked results grid:** paging that honours your page size, Retrieve all
303
+ that pauses every 50,000 rows, CSV / JSON export and Copy as TSV ([#12],
304
+ [#219], [#223]).
305
+ - **A portable saved-request library:** export / import, other connections'
306
+ libraries, and requests that never overwrite or silently lose each other.
307
+ - **Smaller additions:** an OpenAPI 3 document in the Code tab, Recent runs that
308
+ restore a request, Predefined Query over a row's related records, and Execute
309
+ Workflow's declared input arguments ([#28], [#2], [#5], [#4]).
310
+
311
+ ### 🔄 Changed
312
+
313
+ - **Update sends `If-Match: *` by default** on ToolBox 1.2.7+, so an Update of a
314
+ record that doesn't exist fails instead of creating it.
315
+ - **Execute Custom API / Custom Action list every operation by type**, and each
316
+ mode keeps its unsaved request when you switch modes.
317
+ - **In-app dialogs** replace the browser's native confirm / alert boxes, and
318
+ errors show the real status.
319
+ - **Faster startup:** Monaco and the less-used modes load on demand.
320
+
321
+ ### 🛡️ Security and data safety
322
+
323
+ - **Credential headers are never sent, saved or exported** ([#217]).
324
+ - **CSV export and Copy as TSV neutralise spreadsheet formulas** ([#239]).
325
+ - **The Monaco editor bundles DOMPurify 3.4.17**, and CI and the release
326
+ workflow check it.
327
+ - **Writes can't create records by accident:** Update and single-valued
328
+ Associate / Disassociate guard against it on every ToolBox version.
329
+
330
+ ### 🐛 Fixed since the last stable release
331
+
332
+ Dozens of fixes, listed under each beta below. The ones found while testing the
333
+ betas:
334
+ - Manage Image Data and Manage File Data list their columns ([#305]).
335
+ - Malformed ETags are caught before they're sent ([#264]).
336
+ - A startup race that could leave DRS without a connection ([#281]).
337
+ - Execute Workflow can retry a failed workflow list ([#306]).
338
+
339
+ ### ⚠️ Known issues
340
+
341
+ - **`$batch` continue-on-error:** ToolBox's `$batch` response parser fails when
342
+ a failed request is followed by more requests. DRS explains it and suggests
343
+ putting requests that might fail last ([#198]).
344
+ - **Execute modes on very large environments:** ToolBox 1.2.7 and 1.2.8 can't
345
+ load a `$metadata` document over 16 MB. The fix is merged in ToolBox
346
+ ([PowerPlatformToolBox/desktop-app#737](https://github.com/PowerPlatformToolBox/desktop-app/pull/737));
347
+ until a ToolBox release includes it, DRS explains the limit ([#79]).
348
+ - **ToolBox VS Code extension:** Monaco's workers may run on the main thread,
349
+ so JSON IntelliSense may not work there ([#255]).
350
+ - **Tool icon:** ToolBox draws SVG tool icons as a single-colour mask until
351
+ [PowerPlatformToolBox/desktop-app#738](https://github.com/PowerPlatformToolBox/desktop-app/pull/738)
352
+ ships ([#25]).
353
+ - **Sidebar keyboard navigation:** the clause tree has no arrow-key model yet
354
+ ([#243]).
355
+ - **Binary modes** (file / image / attachment) compose the request and its
356
+ code, but Execute returns 501 because ToolBox doesn't expose those
357
+ operations.
358
+
359
+ [#2]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/2
360
+ [#4]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/4
361
+ [#5]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/5
362
+ [#8]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/8
363
+ [#9]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/9
364
+ [#10]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/10
365
+ [#11]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/11
366
+ [#12]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/12
367
+ [#23]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/23
368
+ [#25]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/25
369
+ [#28]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/28
370
+ [#43]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/43
371
+ [#79]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/79
372
+ [#198]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/198
373
+ [#217]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/217
374
+ [#219]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/219
375
+ [#223]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/223
376
+ [#239]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/239
377
+ [#243]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/243
378
+ [#255]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/255
379
+ [#264]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/264
380
+ [#266]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/266
381
+ [#281]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/281
382
+ [#305]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/305
383
+ [#306]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/306
384
+
10
385
  ## [1.4.0-beta.3] - 2026-10-27
11
386
 
12
387
  The third 1.4.0 beta fixes what a full regression pass on beta.2 turned up
package/README.md CHANGED
@@ -152,10 +152,15 @@ modes have their own HTTP / fetch / C# / PPTB outputs.
152
152
  - **Request headers through PPTB 1.2.7+** — Create / Update / Upsert /
153
153
  Delete / Merge / Bulk Write / Execute Action / Execute Workflow headers
154
154
  (preconditions, `MSCRM.*` bypass, duplicate detection, impersonation) are
155
- sent as additional headers after you approve them once in ToolBox, and so is
156
- the page size of paged reads. On older hosts, write requests that depend on
157
- a precondition or bypass header are blocked with an explanation.
158
- `Authorization` / `Cookie` headers are never sent, saved or exported.
155
+ sent as additional headers after you approve them once in ToolBox. The
156
+ read modes, Execute Function, Associate / Disassociate and Bulk Delete Job send an
157
+ allow-list: impersonation (`MSCRMCallerID`, `CallerObjectId`) everywhere,
158
+ plus `If-None-Match`, `Consistency` and the page size on reads, and the
159
+ bypass headers on Associate / Disassociate; the Headers pane marks the
160
+ rest as Code tab only. On older hosts, requests that depend on a
161
+ precondition, bypass or impersonation header are blocked with an
162
+ explanation. `Authorization` / `Cookie` headers are never sent, saved or
163
+ exported.
159
164
  - **Antipattern advisories** — Surfaces real-time guidance per the
160
165
  [Microsoft query-antipatterns doc](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/query-antipatterns):
161
166
  `FilteringOnCalculatedColumns`, `LargeAmountOfLogicalAttributes`, large-text
@@ -221,9 +226,11 @@ modes have their own HTTP / fetch / C# / PPTB outputs.
221
226
 
222
227
  - [Power Platform ToolBox](https://www.powerplatformtoolbox.com/) **1.2.0 or
223
228
  later** (the tool declares `minAPI: 1.2.0`). **1.2.7 or later** is
224
- recommended: it sends the write and execute modes' request headers and the
225
- page size, and is required for
226
- the `$batch` and ExecuteMultiple modes.
229
+ recommended: it sends request headers (impersonation, preconditions,
230
+ bypass) and the page size, and is required for
231
+ the `$batch` and ExecuteMultiple modes. DRS detects what the host can do
232
+ at runtime, so `minAPI` stays at 1.2.0 rather than locking out older
233
+ hosts (#273).
227
234
  - A connection to a Dataverse environment
228
235
  - For local development: **Node.js 22.22.2+, 24.15+ or 26+** and **npm** (see
229
236
  `engines` in `package.json`)
@@ -231,10 +238,72 @@ modes have their own HTTP / fetch / C# / PPTB outputs.
231
238
  ### Installation
232
239
 
233
240
  Dataverse Request Studio is available as a tool in Power Platform ToolBox.
234
- Install it from the tool gallery or load it as a custom tool. Prereleases are
235
- published to npm under the `beta` tag (for example `1.4.0-beta.1`) and use the
241
+ Install it from the tool gallery or load it as a custom tool. Stable releases
242
+ are published to npm under the `latest` tag. Prereleases of the next version
243
+ are published under the `beta` tag (for example `1.5.0-beta.1`) and use the
236
244
  gold Insider icon.
237
245
 
246
+ ### Choose the entity scope
247
+
248
+ The entity pickers list the entities in the scope shown on the **scope button**
249
+ in the header, after the request type. On first run it reads **Choose scope**
250
+ and a tip points at it. Open it to pick where entities come from:
251
+
252
+ - **Publisher → solution** (default): one or more publishers, then their
253
+ solutions;
254
+ - **Solution only**: one or more solutions;
255
+ - **All entities**: everything in the environment.
256
+
257
+ **Advanced Find only** is there too. Changes apply right away, and the scope is
258
+ remembered per environment.
259
+
260
+ ---
261
+
262
+ ## ✏️ What this tool changes
263
+
264
+ Dataverse Request Studio only reads from Dataverse until you send a request
265
+ from one of the write, relate, execute, bulk or batch modes. Every request runs
266
+ as the connected user (or the user an impersonation header names), so Dataverse
267
+ applies that user's security roles.
268
+
269
+ **Before a write is sent, it asks.** The confirmation names the target: the
270
+ environment (connection name, URL and type, with Production highlighted), the
271
+ operation, the table and the scope. The header shows the connection and its
272
+ type at all times.
273
+
274
+ | Request | When it asks |
275
+ |---|---|
276
+ | **Merge**, **Execute Action / Custom API / Custom Action**, **Execute Workflow**, **Bulk Write**, `$batch` / **ExecuteMultiple** with any write, **Associate / Disassociate** with more than one target | Always |
277
+ | **Create**, **Update**, **Upsert**, single-target **Associate / Disassociate** | On a Production connection, with **Production safe mode** on (the default; Settings → Safety) |
278
+ | **Delete** | Always for a whole row: type the record's name and acknowledge, in the mode itself. On a Production connection with safe mode on, the confirmation above as well |
279
+ | **Bulk Delete Job** | Always: the confirmation names the environment, counts the matching rows, and you type the table name |
280
+ | Reads (Retrieve, Predefined Query, Execute Function, downloads) | Never |
281
+
282
+ On a Production connection with safe mode on, and for more than 100 records (or
283
+ more than 100 writes in a batch) on any connection, you type the table name (or
284
+ the action name, or `batch` / `ExecuteMultiple`) before the confirm button
285
+ enables. Execute and Ctrl+Enter go through the same confirmation. If the
286
+ connection changes while the confirmation is open, nothing is sent.
287
+
288
+ What each request does in Dataverse is exactly what the URL bar and the Code
289
+ tab show: one Web API request (or one per target for Associate / Disassociate,
290
+ or one `$batch` per group). The binary modes (file, image, attachment) don't
291
+ send anything from inside ToolBox: Execute returns 501, and you copy the request
292
+ from the Code tab.
293
+
294
+ **Stored on your machine, not in Dataverse:**
295
+
296
+ - **Saved requests** — in the browser storage of the ToolBox tool window, one
297
+ library per environment (`drs:saved-requests:v1:<host>`). If a library can't
298
+ be read, it's copied to a backup key instead of being overwritten. Export and
299
+ Import write and read JSON files you pick.
300
+ - **Settings** (logical names, value display, entity scope, Advanced Find,
301
+ density, column widths, Production safe mode) — in ToolBox's settings store
302
+ for this tool.
303
+ - **Exports** (CSV, JSON, Postman, Insomnia, Bruno, OpenAPI) — only to files you
304
+ choose. Credential headers (`Authorization`, cookies) are never saved or
305
+ exported.
306
+
238
307
  ---
239
308
 
240
309
  ## 🛠️ Development
@@ -271,8 +340,8 @@ npm run preview
271
340
  # Validate manifest against PPTB registry rules
272
341
  npm run validate
273
342
 
274
- # Pre-publish: validate → build
275
- npm run finalize-package
343
+ # Lint (ESLint, no warnings allowed)
344
+ npm run lint
276
345
  ```
277
346
 
278
347
  ### Standalone vs PPTB-embedded
@@ -421,6 +490,7 @@ Dataverse API)
421
490
  | `Prefer: return=representation` | ✅ (ToolBox always sends it on writes) |
422
491
  | Optimistic concurrency (`If-Match` / `If-None-Match`) | ✅ 1.2.7+ |
423
492
  | `MSCRM.*` bypass family (custom plug-ins, flows, async) | ✅ 1.2.7+ |
493
+ | Impersonation (`MSCRMCallerID` / `CallerObjectId`) on every mode | ✅ 1.2.7+ |
424
494
  | Single-property PUT / DELETE | 📝 |
425
495
  | Alternate-key upsert | 📝 |
426
496
  | Associate / Disassociate (collection + single-valued) | ✅ |
package/SECURITY.md CHANGED
@@ -49,6 +49,13 @@ in a browser. Vulnerability reports of interest:
49
49
 
50
50
  ## Supported versions
51
51
 
52
- Only the latest released minor version on `main` receives security fixes.
52
+ | Version | Supported |
53
+ |---|---|
54
+ | The current stable release (npm `latest`) | ✅ Fixes and security fixes |
55
+ | The previous minor release | ✅ Critical and security fixes for 30 days after the next minor ships (npm `support-X.Y`) |
56
+ | Betas (npm `beta`) | Fixed in the next beta |
57
+ | Anything older | ❌ |
58
+
59
+ See [RELEASING.md](RELEASING.md) → *Supported versions*.
53
60
 
54
61
  Thanks for helping keep the tool safe.
@@ -0,0 +1 @@
1
+ import{k as le,b9 as ie,bQ as z,l as r,u as de,n as ce,bR as ue,bS as ge,bT as he,f as be,bU as pe,bc as me,bV as ye,be as ve,p as M,q as W,t as fe,T as Se,v as xe,bW as Pe,bX as Te,bL as Ne,bM as je,bY as A,L as ke,z as we,A as a,H as Ce,N as Ie,O as Me,V as Re,D as Ae,bZ as Le,I as J,J as He,K as $e,P as Fe,R as qe,b_ as R,U as Be,S as Ee,Q as Ue,b0 as Oe,b1 as De,bs as Ve,b8 as ze,ah as We,a2 as T,bq as Je,a3 as Qe,br as _e}from"./index-XmEQbXiX.js";import{t as Ge,A as Ke,N as Xe}from"./AssociateTargetsEditor-BoH9Qxe8.js";const Ye=()=>({table:"",sourceId:null,navProperty:null,targets:[],targetNames:{},headers:Ue(),dirty:new Set});function st({themeMode:d}){const p=le("associate"),l=ie("associate",z,Ye),[e,c]=r.useState(l.state),{table:N}=de(e.table||null),{allEntities:L}=ce(),[H,$]=r.useState("source"),[m,j]=r.useState("builder"),[F,k]=r.useState(null),[_,q]=r.useState(!1),[G,K]=r.useState([]),[y,v]=r.useState(l.lastSavedId),[f,S]=r.useState(l.lastSavedHash),[B,w]=r.useState(""),b=r.useMemo(()=>ue(e),[e,N]),X=r.useMemo(()=>ge(e),[e,N]),n=r.useMemo(()=>he(e),[e,N]),x=be(e.table),o=e.navProperty?x?.navigationProperties.find(t=>t.name===e.navProperty):void 0,E=o?pe(o):!1,u=E?"PATCH":"POST",C=t=>c(s=>{const i=new Set(s.dirty);return i.add(t),{...s,dirty:i}}),P=(t,s,i)=>{c(I=>({...I,[t]:s})),i&&C(i)},Y=me([["Source record id",e.sourceId],...e.targets.map(t=>["Target record id",t])],[["Navigation property",e.navProperty]]),Z=x?e.sourceId?e.navProperty?e.targets.length===0?"Pick at least one target record.":e.headers.some(t=>t.enabled&&!t.name)?"Fix empty header name.":Y:"Pick a navigation property.":"Pick a source record.":"Pick a source table first.",ee=async()=>{q(!0);const t=await De.associate(e,J(e.headers,null));k(t),q(!1),j("results"),K(s=>[{id:`r-${Date.now()}`,snapshot:g,modeId:"associate",url:b.relativeUrl,method:u,ts:Date.now(),status:t.status,ms:t.ms,rowCount:R(t,n.length)??0,summary:`${R(t,n.length)??0} of ${n.length} linked`},...s].slice(0,8)),c(s=>({...s,dirty:new Set}))},g=r.useMemo(()=>ye(e),[e]);ve("associate",g,y,f);const te=r.useMemo(()=>M(g),[g]),U=f===null?!0:te!==f,ae=t=>{v(t.id),S(M(t.state))},O=t=>{if(t.modeId!=="associate")return;const s=t.state;if(L.length>0&&!L.some(i=>i.logicalName===s.table)){Oe(`Can't load "${t.name}": entity \`${s.table}\` isn't available in this environment. The solution may have been removed or you may be connected to a different org.`);return}c(z(s)),v(t.id),S(M(s)),k(null),w(""),$("source")},se=t=>{const s=Ve(t,"associate");if(!s)return;const i=y,I=f;O(s),v(i),S(I)},D=W(ae),V=W(O);fe(r.useMemo(()=>e.table?{state:g,modeId:"associate",dirty:U,lastSavedId:y,onSaved:D,onLoadSaved:V}:null,[g,U,y,e.table,D,V]));const re=[{id:"source",label:"Target",meta:x?.displayName??"Pick a table",items:[{id:"source",icon:xe,iconFilled:Se,label:e.sourceId?B||`${x?.displayName??""} (selected)`:"Pick a record",badge:o?u:null,badgeAppearance:"tint",badgeColor:"brand",dirty:e.dirty.has("source")}]},{id:"relationship",label:"Relationship",meta:o?Q(o.cardinality):"pick one",items:[{id:"nav",icon:Te,iconFilled:Pe,label:o?o.name:"Navigation property",code:!!o,badge:o?Q(o.cardinality):null,badgeAppearance:"ghost",dirty:e.dirty.has("nav")}]},{id:"targets",label:"Related",meta:e.targets.length?`${e.targets.length} target${e.targets.length===1?"":"s"}`:"none",items:[{id:"targets",icon:je,iconFilled:Ne,label:Ge(E,e.targets.length),badge:e.targets.length||null,badgeAppearance:"tint",badgeColor:e.targets.length>0?"success":"subtle",dirty:e.dirty.has("targets")},...n.length>0?[{id:"preview",icon:A,iconFilled:A,label:`${n.length} request${n.length===1?"":"s"}`,badge:n.length,badgeAppearance:"ghost"}]:[]]},{id:"headers",label:"Headers",meta:`${e.headers.filter(t=>t.enabled).length} active`,items:[{id:"headers",icon:we,iconFilled:ke,label:"HTTP headers",badge:e.headers.filter(t=>t.enabled).length||null,dirty:e.dirty.has("headers")}]}];let h;switch(H){case"source":h=a.jsx(Ae,{table:e.table,onTableChange:t=>{c(s=>({...s,table:t,sourceId:null,navProperty:null,targets:[],targetNames:{},dirty:new Set(["source","nav","targets"])})),w(""),k(null),v(void 0),S(null)},recordId:e.sourceId,onRecordChange:(t,s)=>{P("sourceId",t,"source"),w(s??"")},group:"relate",sub:"Pick the source entity and the record that the relationship anchors on."});break;case"nav":h=a.jsx(Xe,{table:e.table,value:e.navProperty,onChange:t=>{c(s=>({...s,navProperty:t,targets:[],targetNames:{}})),C("nav"),C("targets")},group:"relate",forOperation:"associate",footer:a.jsx(Ie,{layout:"multiline",intent:"info",children:a.jsxs(Me,{children:[a.jsx(Re,{children:"How cardinality drives the request"}),a.jsx("strong",{children:"Collection-valued"})," (1:N / N:N) → ",a.jsx("code",{children:"POST /…/$ref"})," with one request per target. ",a.jsx("strong",{children:"Single-valued"})," (N:1) →"," ",a.jsx("code",{children:"PATCH /source(id)"})," with body"," ",a.jsx("code",{children:'{ "<nav>@odata.bind": "<target-set>(<id>)" }'})," (one target). This is the docs-preferred shape — the URL bar verb updates automatically. The PATCH is sent with ",a.jsx("code",{children:"If-Match: *"}),", so a wrong source id fails with 404 instead of creating a record; Power Platform ToolBox asks you to approve that header once."," ",a.jsx("a",{href:"https://learn.microsoft.com/en-us/power-apps/developer/data-platform/webapi/associate-disassociate-entities-using-web-api",target:"_blank",rel:"noopener noreferrer",style:{color:"inherit"},children:"MS Learn ↗"})]})})});break;case"targets":h=a.jsx(Ke,{table:e.table,navProperty:e.navProperty,targets:e.targets,setTargets:t=>P("targets",t,"targets"),targetNames:e.targetNames,setTargetNames:t=>P("targetNames",t),group:"relate",resolvedMethod:o?u:null});break;case"preview":h=a.jsx(Ze,{requests:n});break;case"headers":h=a.jsx(Ce,{policy:"relate",items:e.headers,setItems:t=>P("headers",t,"headers"),group:"relate"});break}const oe=Le(u,J(e.headers,null)),ne={method:u,built:b,headers:oe,body:X,entityLogical:b.entityLogical,multiRequests:n.length>1?n.map(t=>({method:t.method,relativeUrl:t.relativeUrl,body:t.body,description:`target ${t.targetId}`})):void 0};return a.jsx(He,{sidebar:a.jsx(Ee,{type:p,urlPreview:b.relativeNoBase,sections:re,activeNode:H,onSelect:t=>{$(t),j("builder")},recents:G,onRecentClick:se}),urlBar:a.jsx(Be,{method:u,url:b.relativeUrl,executeVerb:p.executeVerb,writeConfirm:{operation:o?`Associate (${o.name})`:"Associate",table:e.table,scope:{kind:"records",count:Math.max(1,e.targets.length)},highImpact:e.targets.length>1},disabledReason:Z,loading:_,onExecute:ee}),children:a.jsxs($e,{tab:m,onTabChange:j,resultCount:R(F,n.length),children:[m==="builder"&&h,m==="code"&&a.jsx(Fe,{themeMode:d,inputs:ne}),m==="results"&&a.jsx(qe,{result:F,mode:"single",table:e.table,writeContext:{operation:"associate",table:e.table,recordId:e.sourceId,recordName:B||null,navProperty:e.navProperty??void 0,targetCount:e.targets.length,targetNames:e.targets.map(t=>e.targetNames[t]).filter(t=>!!t),targetNameById:e.targetNames}})]})})}function Ze({requests:d}){const p=ze();return a.jsxs("div",{children:[a.jsx(We,{icon:A,title:`Generated requests (${d.length})`,sub:"Each target queues a separate HTTP request. For large counts, prefer a $batch request.",group:"relate"}),a.jsxs("div",{className:_e(p.inlineCard),style:{padding:12,maxWidth:980,fontFamily:T.fontFamilyMonospace,fontSize:11},children:[d.map((l,e)=>a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"60px 1fr",gap:8,padding:"8px 0",borderBottom:e<d.length-1?`1px solid ${T.colorNeutralStroke3}`:"none"},children:[a.jsx(Je,{appearance:"filled",color:l.method==="POST"?"success":"warning",style:{fontWeight:700,justifySelf:"start"},children:l.method}),a.jsxs("div",{style:{minWidth:0},children:[a.jsx("div",{style:{wordBreak:"break-all"},children:l.relativeUrl}),a.jsx("div",{style:{marginTop:4,color:T.colorNeutralForeground3},children:JSON.stringify(l.body)})]})]},l.targetId)),d.length===0&&a.jsx(Qe,{style:{color:T.colorNeutralForeground3,fontStyle:"italic",padding:"12px 4px",textAlign:"center",display:"block"},children:"No requests queued — pick at least one target on the Related pane."})]})]})}function Q(d){switch(d){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}export{st as AssociateMode};
@@ -0,0 +1 @@
1
+ import{f,b3 as G,b7 as K,u as V,A as e,ah as S,bW as b,ad as B,bn as J,b5 as U,a2 as a,bq as u,a3 as v,l as O,b8 as X,N as C,O as E,aL as M,c5 as Y,bP as _,Y as Q,aX as Z,br as ee,b6 as te,aJ as ne,V as ae}from"./index-XmEQbXiX.js";function ie({table:t,value:l,onChange:n,group:i="relate",forOperation:p,footer:y}){const g=f(t)?.navigationProperties??[],d=g.find(s=>s.name===l),T=G(),F=g.filter(s=>K(s,T)||s.name===l);return V(d?.targetEntity??null),e.jsxs("div",{children:[e.jsx(S,{icon:b,title:"Navigation property",sub:"Cardinality is detected from metadata — the URL bar verb + shape adapt automatically.",group:i}),e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(B,{label:"Navigation property",children:e.jsx(J,{value:d?.name??"",selectedOptions:d?[d.name]:[],onOptionSelect:(s,m)=>n(m.optionValue??null),placeholder:"Pick a navigation property…",children:F.map(s=>e.jsx(U,{value:s.name,text:s.name,children:e.jsx(re,{nav:s,forOperation:p})},s.name))})}),d&&e.jsx("div",{style:{marginTop:16},children:e.jsx(le,{nav:d,forOperation:p})}),y&&e.jsx("div",{style:{marginTop:14},children:y})]})]})}function re({nav:t,forOperation:l}){const n=f(t.targetEntity),i=W(t,l);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontFamily:a.fontFamilyMonospace,fontWeight:600},children:t.name}),e.jsx(u,{appearance:"ghost",size:"small",children:R(t.cardinality)}),e.jsx(u,{appearance:"tint",color:"brand",size:"small",style:{marginLeft:"auto"},children:i})]}),e.jsxs(v,{style:{color:a.colorNeutralForeground3},children:["→ ",n?.displayName??t.targetEntity," · ",se(t.cardinality)]})]})}function le({nav:t,forOperation:l}){const n=f(t.targetEntity),i=W(t,l),p=t.cardinality==="ManyToOne"?"single-valued":"collection-valued",y=i==="POST"?a.colorPaletteGreenForeground1:i==="PATCH"?a.colorPaletteDarkOrangeForeground1:a.colorPaletteRedForeground1;return e.jsxs("div",{style:{border:`1px solid ${a.colorNeutralStroke2}`,borderRadius:a.borderRadiusMedium,padding:12,background:a.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(b,{style:{width:18,height:18,color:a.colorBrandForeground1}}),e.jsx("strong",{style:{fontFamily:a.fontFamilyMonospace,fontSize:13},children:t.name}),e.jsx(u,{appearance:"tint",color:"brand",children:R(t.cardinality)}),e.jsx("span",{style:{flexGrow:1}}),e.jsx(u,{appearance:"filled",style:{background:y,color:a.colorNeutralForegroundOnBrand,fontWeight:700},children:i})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",rowGap:4,fontSize:11},children:[e.jsx("span",{style:{color:a.colorNeutralForeground3},children:"Target entity"}),e.jsxs("span",{style:{fontFamily:a.fontFamilyMonospace},children:[n?.entitySetName??t.targetEntity," ",e.jsxs(v,{style:{color:a.colorNeutralForeground3},children:["· ",n?.displayName??t.targetEntity]})]}),e.jsx("span",{style:{color:a.colorNeutralForeground3},children:"Cardinality"}),e.jsxs("span",{children:[p," (",t.cardinality,")"]}),e.jsx("span",{style:{color:a.colorNeutralForeground3},children:"Relationship"}),e.jsx("span",{style:{fontFamily:a.fontFamilyMonospace,fontSize:10},children:t.relationshipName})]})]})}function R(t){switch(t){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}function se(t){return t==="ManyToOne"?"single-valued lookup":"collection-valued"}function W(t,l){return t.cardinality==="ManyToOne"?"PATCH":l==="disassociate"?"DELETE":"POST"}function A(t,l){return t||l===1?"Target record":"Target records"}function ce({table:t,navProperty:l,targets:n,setTargets:i,targetNames:p,setTargetNames:y,group:N="relate",resolvedMethod:g,sub:d,verb:T="POST"}){const[F,s]=O.useState({}),m=p??F,P=y??s,w=X(),q=f(t),h=l?q?.navigationProperties.find(r=>r.name===l):void 0,x=h?f(h.targetEntity):void 0,o=h?.cardinality==="ManyToOne",z=o?1:1/0,[$,D]=O.useState(0);if(!h)return e.jsxs("div",{children:[e.jsx(S,{icon:b,title:A(!1,n.length),sub:"Pick a navigation property first.",group:N}),e.jsx(C,{layout:"multiline",intent:"info",style:{maxWidth:720},children:e.jsxs(E,{children:["Switch to the ",e.jsx("strong",{children:"Navigation property"})," pane and pick one — the target entity comes from there."]})})]});const k=n.length>=z,I=(r,c)=>{if(!r||n.includes(r)||k)return;const j=o?[r]:[...n,r];i(j),c&&P({...m,[r]:c}),D(L=>L+1)},H=r=>{if(i(n.filter(c=>c!==r)),m[r]!=null){const c={...m};delete c[r],P(c)}};return e.jsxs("div",{children:[e.jsxs(S,{icon:b,title:A(o,n.length),sub:e.jsx("span",{children:d??(o?e.jsxs(e.Fragment,{children:["One target is allowed for ",e.jsx("code",{children:h.cardinality})," nav props — a PATCH with"," ",e.jsxs("code",{children:[h.name,"@odata.bind"]})," sets the lookup."]}):e.jsxs(e.Fragment,{children:["One or more targets — each fires a separate POST request. For many targets, Dataverse recommends a ",e.jsx("code",{children:"$batch"})," request."]}))}),group:N,children:[e.jsxs(u,{appearance:"tint",color:n.length>0?"brand":"subtle",children:[n.length," target",n.length===1?"":"s"]}),g&&e.jsx(u,{appearance:"filled",color:g==="POST"?"success":"informative",style:{fontWeight:700},children:g}),!o&&n.length>1&&e.jsx(M,{content:"Will fire one request per target — Dataverse recommends $batch for large counts. Batch transport lands in a later pass.",relationship:"description",children:e.jsxs(u,{appearance:"ghost",icon:e.jsx(Y,{style:{width:12,height:12}}),children:[n.length," requests queued"]})})]}),e.jsx("div",{className:ee(w.inlineCard),style:{padding:12,marginBottom:14,maxWidth:880},children:n.length===0?e.jsxs(v,{style:{padding:"12px 4px",color:a.colorNeutralForeground3,fontStyle:"italic",display:"block",textAlign:"center"},children:["No targets selected — use the picker below to choose"," ",o?"one":"one or more"," ",e.jsx("strong",{children:x?.displayName??h.targetEntity})," record",o?"":"s","."]}):e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n.map((r,c)=>{const j=m[r];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 4px",borderBottom:c<n.length-1?`1px solid ${a.colorNeutralStroke3}`:"none"},children:[e.jsx(_,{size:"small",name:j??"?",avatar:{color:"colorful"}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:j??e.jsx("span",{style:{fontStyle:"italic",color:a.colorNeutralForeground3},children:"(name not resolved)"})}),e.jsxs("div",{style:{fontFamily:a.fontFamilyMonospace,fontSize:10,color:a.colorNeutralForeground3},children:["/",x?.entitySetName??"?","(",r,")"]})]}),e.jsx(M,{content:"Remove target",relationship:"label",children:e.jsx(Q,{size:"small",appearance:"subtle",icon:e.jsx(Z,{}),onClick:()=>H(r),"aria-label":"Remove target"})})]},r)})})}),!k&&e.jsxs("div",{style:{maxWidth:560},children:[e.jsx(B,{label:o?"Pick target":"Add target",hint:o?`Pick a single ${x?.displayName??"record"} — the PATCH sets this as the lookup value.`:`Each pick queues a separate ${T}. Currently ${n.length} target${n.length===1?"":"s"} queued.`,children:e.jsx(te,{table:x?.logicalName??h.targetEntity,selectedId:null,onPick:r=>I(r?.id??null,r?.primary),placeholder:`Search ${x?.displayName??"record"}s…`},$)}),!o&&e.jsxs(v,{style:{display:"block",marginTop:6,color:a.colorNeutralForeground3},children:[e.jsx(ne,{style:{width:12,height:12,verticalAlign:"middle"}})," picking a record adds it to the queue and resets the picker for the next pick."]})]}),k&&o&&e.jsx(C,{layout:"multiline",intent:"info",style:{maxWidth:720,marginTop:12},children:e.jsxs(E,{children:[e.jsx(ae,{children:"Single-valued nav property — one target only."}),"To change the target, remove the current one first. The PATCH replaces the previous lookup value."]})})]})}export{ce as A,ie as N,A as t};