@mohsinonxrm/pptb-dataverse-request-studio 1.4.0 → 1.5.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +406 -0
  2. package/README.md +94 -17
  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 +11 -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,412 @@ 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] - 2026-11-07
11
+
12
+ Writes ask before they're sent, naming the environment, and Production gets a
13
+ safe mode that's on by default ([#241]). Read and execute requests send their
14
+ headers, and impersonation is never dropped silently ([#109]). The entity scope
15
+ moves from Settings to a button in the header ([#42]). Ids, names and filter
16
+ values are checked and typed before they go into a URL ([#221]). The sidebar
17
+ works with a screen reader and the keyboard ([#243]).
18
+
19
+ It was iterated through `1.5.0-beta.1` (detailed below). Since that beta, the
20
+ Insider icon, the README badges and the release workflow changed (listed here).
21
+
22
+ Request headers need **Power Platform ToolBox 1.2.7 or later**. On older hosts
23
+ a request with an impersonation header isn't sent, and DRS explains why.
24
+
25
+ ### ✨ Added
26
+
27
+ - **Writes ask before they're sent**, naming the environment and its type, and
28
+ **Production safe mode** is on by default ([#241]).
29
+ - **The entity scope is a button in the header** ([#42]).
30
+ - **Read, Execute Function, Associate / Disassociate and Bulk Delete Job send
31
+ their headers**, and impersonation is never dropped silently ([#109]).
32
+ - **Execute Custom API and Custom Action list your own operations first**.
33
+
34
+ ### 🛡️ Security and data safety
35
+
36
+ - **Ids, names, filter values and function parameters are checked and typed**
37
+ before they go into a URL, and imported saved requests are checked deeply
38
+ ([#221]).
39
+
40
+ ### 🐛 Fixed since 1.4.0
41
+
42
+ Listed under the beta below. Among them: the sidebar with a screen reader and
43
+ the keyboard ([#243]), expired metadata that was served as fresh ([#334]), and
44
+ choosing a file no longer reads it into memory ([#222]).
45
+
46
+ ### 🔄 Changed
47
+
48
+ - **The Insider icon's gold corner is bigger, deeper gold and flush with the
49
+ corner** ([#363]). The old stamp's right point sat inside the hexagon's edge,
50
+ leaving a thin blue gap, and the light gold faded at small sizes. The stamp
51
+ now fills the corner, about 1.5 times larger, in two tones of gold
52
+ (`#CC8A00` and `#F2A100`) split on the same diagonal as the blue.
53
+ Prerelease builds only; the release icon is unchanged. Same change as
54
+ FetchXML Studio.
55
+ - **The README's badges show in the ToolBox** ([#373]). Power Platform ToolBox
56
+ shows a tool's README in a window that only loads images from GitHub, so the
57
+ `img.shields.io` badges didn't appear there. They're now SVG files in
58
+ `assets/badges/`, linked from `raw.githubusercontent.com` as in Command Bar
59
+ Studio and FetchXML Studio, and generated from `package.json` by
60
+ `npm run badges`: version, Power Platform ToolBox ≥ 1.2.0, `@pptb/types`,
61
+ React, TypeScript, Fluent UI and license. The version badge links to npm, in
62
+ place of the npm `latest` and `beta` badges. The links point at `main`, so
63
+ the ToolBox shows them from the 1.5.0 release on.
64
+
65
+ ### 🔧 Internal
66
+
67
+ - **Releases check what they must update** ([#372]). A new `check-release.mjs`
68
+ runs in CI (every PR, and pushes to the long-lived branches) and in the
69
+ release build. It fails when any of these don't match `package.json`'s
70
+ version:
71
+ - the version's shape (`X.Y.Z`, `X.Y.Z-beta.N` or `X.Y.Z-rc.N`);
72
+ - `package-lock.json`;
73
+ - the CHANGELOG (a dated `[X.Y.Z]` section with entries, under a single
74
+ `[Unreleased]`);
75
+ - after the build, the bundled icon (the Insider icon for pre-releases).
76
+
77
+ The GitHub Release notes are built by the same script: the PPTB requirement,
78
+ the CHANGELOG section and a link to the full CHANGELOG, then GitHub's PR
79
+ list. A release no longer falls back to a PR list alone when the section is
80
+ missing, because the check fails first. RELEASING.md gains a table of what
81
+ every release changes and an *After every release* checklist, and forward
82
+ merges now keep the higher version. Ported from FetchXML Studio's check.
83
+ - **The release check covers the README badges** ([#373]): the files in
84
+ `assets/badges/` match `package.json`, the README shows them, and no README
85
+ image comes from `img.shields.io`.
86
+ - **The release workflow is hardened** ([#376]), as FetchXML Studio's was.
87
+ - **Separate jobs:** `release.yml` is split into `build`, `publish` and
88
+ `github-release`. The job that installs and runs the dependencies
89
+ (`npm ci --ignore-scripts`, no cache, tests, build) only reads the
90
+ repository. Only `publish` can get the npm OIDC token, only for a tag push,
91
+ and it installs no project dependencies: it publishes the tarball `build`
92
+ packed. Only `github-release` can write to the repository.
93
+ - **More checks before publishing:** the release build now also runs the
94
+ runtime audit, lint and the root-absolute asset check, so a tag on a commit
95
+ that skipped CI can't publish. The package-contents check now runs on the
96
+ tarball that gets published, not a dry-run pack.
97
+ - **Pinned versions:** npm is pinned to 11.21.1 instead of `npm@latest`, and
98
+ Node to 24.22.0. Actions are pinned by commit SHA (checkout v7.0.1,
99
+ setup-node v7.1.0, upload-artifact v7.0.2, download-artifact v8.0.2), each
100
+ at least 14 days old.
101
+ - **Rehearsal:** running the workflow by hand runs every check and
102
+ `npm publish --dry-run`, with no npm token and no GitHub Release. A stable
103
+ version that isn't on `main` yet rehearses as `latest`, with a warning.
104
+ - **`latest` can't move back:** a stable tag gets `latest` only for main's own
105
+ version line, and a `support/X.Y` commit is checked first. Support branches
106
+ merge forward into `main`, so before this, a support release first published
107
+ (or retried after a failed publish) once its commit had reached `main` would
108
+ have gone to `latest`.
109
+ - **CI** uses the same Node and action pins and `npm ci --ignore-scripts`,
110
+ doesn't keep the checkout's token, and runs the runtime audit.
111
+ - **RELEASING.md** covers the jobs, the pins, re-runs and rehearsals; how to
112
+ bring a `support/X.Y` cut from an older tag onto this workflow before its
113
+ first tag; and the recommended `publish` environment and `v*` tag ruleset.
114
+
115
+ ### ⚠️ Known issues
116
+
117
+ - **`$batch` continue-on-error:** ToolBox's `$batch` response parser fails when
118
+ a failed request is followed by more requests. DRS explains it and suggests
119
+ putting requests that might fail last ([#198]).
120
+ - **Execute modes on very large environments:** ToolBox can't load a
121
+ `$metadata` document over 16 MB until a ToolBox release includes
122
+ [PowerPlatformToolBox/desktop-app#737](https://github.com/PowerPlatformToolBox/desktop-app/pull/737);
123
+ DRS explains the limit ([#79]).
124
+ - **ToolBox VS Code extension:** Monaco's workers may run on the main thread,
125
+ so JSON IntelliSense may not work there ([#255]).
126
+ - **Binary modes** (file / image / attachment) compose the request and its
127
+ code, but Execute returns 501 because ToolBox doesn't expose those
128
+ operations.
129
+
130
+ [#42]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/42
131
+ [#79]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/79
132
+ [#109]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/109
133
+ [#198]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/198
134
+ [#221]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/221
135
+ [#222]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/222
136
+ [#241]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/241
137
+ [#243]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/243
138
+ [#255]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/255
139
+ [#334]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/334
140
+ [#363]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/363
141
+ [#372]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/372
142
+ [#373]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/373
143
+ [#376]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/376
144
+
145
+ ## [1.5.0-beta.1] - 2026-10-30
146
+
147
+ The first 1.5.0 beta. Writes now ask before they're sent, naming the
148
+ environment, and Production gets a safe mode that's on by default ([#241]).
149
+ Read and execute requests send their headers, and impersonation is never
150
+ dropped silently ([#109]). The entity scope moves from Settings to a button in
151
+ the header ([#42]). Ids, names and filter values are checked and typed before
152
+ they go into a URL ([#221]). There are also accessibility, metadata-cache and
153
+ copy fixes, and 272 new tests for the write path.
154
+
155
+ Still a **prerelease** on the npm `beta` tag, with the gold Insider icon.
156
+ Power Platform ToolBox **1.2.7 or later** is recommended: older hosts can't
157
+ send request headers, so a request with an impersonation header isn't sent
158
+ on them.
159
+
160
+ ### ✨ Added
161
+
162
+ - **The entity scope is a button in the header** ([#42]), after the request
163
+ type, instead of Settings → Query Scope. It reads **Choose scope** until you
164
+ pick one, then the scope itself (`Contoso › Sales Core v1.2.0`, `+1` for
165
+ more, or **All entities**), with the full list as a tooltip when it's cut
166
+ off. Its popover holds the entity source, publishers, solutions and
167
+ Advanced Find only, and changes apply right away, per environment as
168
+ before:
169
+ - removing a publisher also removes its solutions;
170
+ - solutions are grouped Unmanaged / Managed, show `Name vX.Y.Z`, and search
171
+ matches the name, unique name or version;
172
+ - on first run a tip points at the button, once per environment;
173
+ - without a scope, the entity picker is disabled and reads "Choose a scope
174
+ to list entities", and the pane's **Choose scope** opens the popover. With
175
+ one, it counts the entities in scope.
176
+
177
+ The same design as FetchXML Studio's and Command Bar Studio's. Settings
178
+ keeps a pointer to the button.
179
+ - **Writes ask before they're sent** ([#241]). The confirmation names the
180
+ target: the environment (connection name, URL and type, with Production
181
+ highlighted), the operation, the table and the scope. Execute and Ctrl+Enter
182
+ both go through it.
183
+ - Merge, Execute Action / Custom API / Custom Action, Execute Workflow, Bulk
184
+ Write, `$batch` and ExecuteMultiple with writes, and multi-target
185
+ Associate / Disassociate always ask.
186
+ - Create, Update, Upsert, Delete and single-target Associate / Disassociate
187
+ ask on a Production connection.
188
+ - On Production, and for more than 100 records (or batch writes) anywhere,
189
+ you type the table (or operation) name before the button enables.
190
+ - If the connection changes while the confirmation is open, nothing is sent.
191
+ - The Bulk Delete Job confirmation names the environment too.
192
+ - **The header shows the connection and its environment type** inside
193
+ ToolBox too, with Production in red ([#241]).
194
+ - **Production safe mode** in Settings → Safety, on by default ([#241]).
195
+ - **README: "What this tool changes"** lists every request that changes data,
196
+ when it asks, and what DRS stores locally ([#241]).
197
+ - **Read, Execute Function, Associate / Disassociate and Bulk Delete Job
198
+ requests send their headers** ([#109]). The Headers pane says which rows
199
+ Execute sends and marks the rest as Code tab only. Later pages of a
200
+ Retrieve Multiple send the first page's headers, so they run as the same
201
+ user. It's an allow-list, so a plain read still sends none and never asks
202
+ for consent:
203
+ - impersonation (`MSCRMCallerID`, and a new `CallerObjectId` preset for
204
+ the Microsoft Entra object id) in all of them;
205
+ - `If-None-Match` and `Consistency` on reads. A matching etag shows as
206
+ **304 Not Modified**, not as an error;
207
+ - the bypass headers on Associate / Disassociate.
208
+ The page size's `Prefer` still keeps ToolBox's
209
+ `odata.include-annotations="*"`; other preferences stay in the Code tab.
210
+ - **Impersonation is never dropped silently** ([#109]).
211
+ - On a ToolBox older than 1.2.7, which can't send headers, a request with
212
+ an impersonation header isn't sent, instead of running as you. The same
213
+ goes for Associate / Disassociate with a bypass header.
214
+ - Both impersonation headers at once, or the presets' all-zero
215
+ placeholder, aren't sent either.
216
+ - A declined header prompt on Associate / Disassociate asks once and sends
217
+ nothing, rather than falling back to a request without your headers.
218
+ - **Execute Custom API and Custom Action list your own operations first**
219
+ ([#248]). A Dynamics org has well over a thousand of them, nearly all
220
+ Microsoft's. The Operation list now groups them:
221
+ - **Your org & ISVs** first, **Microsoft** below. Nothing is hidden, and
222
+ search covers both groups (publisher names too).
223
+ - Each one shows its solution's publisher, and so does the summary card.
224
+ - The Scope list counts your own operations per scope ("12 ops, 2 yours").
225
+ - Execute Action (WinOpportunity, QualifyLead, …) is unchanged.
226
+
227
+ ### 🐛 Fixed
228
+
229
+ - **The sidebar works with a screen reader and the keyboard** ([#243]). It
230
+ announced itself as a tree, but arrow keys did nothing, nested clauses
231
+ were read as top-level ones, and every parent said "expanded" although
232
+ nothing collapses. It's now a "Request structure" navigation landmark:
233
+ - each section has a heading and is a list named by it, and nested
234
+ clauses (an `$expand` relationship's clauses, required parameters, Bulk
235
+ Write rows) are nested lists, so their level is read;
236
+ - Tab moves between clauses, Enter or Space opens one, and the open one
237
+ is marked as current;
238
+ - the chevrons, which looked collapsible but weren't, are gone;
239
+ - the "modified" marker and the ✓ badge are read out;
240
+ - keyboard focus shows a ring inside the sidebar;
241
+ - the table name after an expanded relationship (`primarycontactid →
242
+ Contact`) has enough contrast to read.
243
+ - **Small labels are readable again** ([#330]). Badges such as "req",
244
+ "null", "File", "max 32 MB", "soon", "lookup" and the Results count used
245
+ Fluent's extra-small size, a 10px dot, so their text spilled out or was
246
+ cut off. They now use the small size, as the sidebar badges do since
247
+ [#200].
248
+ - **Expired metadata is refetched, not served as fresh** ([#334]). The table
249
+ list, and the columns of a table not yet loaded this session, are cached
250
+ for an hour. When that hour is up and they're fetched again, other pickers
251
+ now wait for the fetch instead of getting the old data, and a failed fetch
252
+ is retried on the next use instead of the old data counting as fresh for
253
+ another hour.
254
+ - **Retrieve Multiple's checks run once the table's columns arrive**
255
+ ([#347]). A saved request loaded before its table's metadata showed no
256
+ advisories, and Execute wasn't blocked for a query Dataverse rejects, until
257
+ you changed something.
258
+ - **Save and the Saved library use the current request and environment**
259
+ ([#347]). The header kept calling the handlers from when the mode last
260
+ published them, so they could read old data. Loading a saved Retrieve
261
+ Multiple request whose table this environment doesn't have now says so,
262
+ even when the table list arrived after the mode opened.
263
+ - **Text follow-ups** ([#317]):
264
+ - Associate and Disassociate say "Target record" when one target is
265
+ picked or the relationship takes only one, in the pane and the sidebar,
266
+ and "Target records" otherwise.
267
+ - An action or function that returns `Collection(<type>)` lists one item's
268
+ properties when the type is known, and a Custom API response with a
269
+ publisher prefix (`msdyn_ActivateProcessesResponse`) lists its
270
+ properties and is labelled complex, instead of being described as an
271
+ entity. On a Dynamics org that's several hundred operations.
272
+ - **Copy buttons go through ToolBox and say whether they worked** ([#242]).
273
+ Inside ToolBox, the webview can refuse the browser clipboard, and a
274
+ refused copy did nothing at all: you then pasted whatever was on the
275
+ clipboard before. Every Copy button (URL bar, Code tab, results, write
276
+ result, previews, Power Automate, …) now uses ToolBox's own clipboard
277
+ inside ToolBox (the browser's outside it), and confirms the copy with a
278
+ short "Copied" note or on the button itself. When it fails, it says
279
+ "Couldn't copy" and what to do instead. Retrieve NextLink's Paste says
280
+ when the clipboard can't be read.
281
+ - **Choosing a file no longer reads it into memory** ([#222]). Manage File,
282
+ Image and Attachment Data keep the file's name, size and type only: Execute
283
+ can't send binary content from inside ToolBox, and the Code tab uses a
284
+ placeholder for the bytes, so a large file used to freeze the tool for
285
+ nothing. Manage Image previews the chosen image through an object URL (up
286
+ to 5 MB). A pasted base64 body is capped at 10 MB, with a message.
287
+ - **Non-ASCII file names work in generated upload code** ([#222]). The
288
+ `x-ms-file-name` header only takes ASCII (and `fetch` / XHR throw on such
289
+ a header), so a name like `报告.pdf` or `Résumé.docx` travels as the
290
+ `x-ms-file-name` query parameter instead, as Microsoft documents, in both
291
+ the single-request and chunked uploads.
292
+ - **Invalidating one table's metadata now refetches it** ([#335]). The next
293
+ read used to return the old table from the in-memory registry. Nothing
294
+ invalidates a single table yet, so this changes nothing you can see today.
295
+ - **"Advanced Find only" works, and is off by default** ([#44]), matching
296
+ FetchXML Studio:
297
+ - Off: the table, column and relationship pickers offer everything.
298
+ - On: they offer only what Advanced Find shows (`IsValidForAdvancedFind`).
299
+ Image and File columns are always offered.
300
+ - Metadata now loads unfiltered, and only the pickers are scoped, so a
301
+ column already in a request keeps working either way. Before, the switch
302
+ did nothing, and columns and relationships that Advanced Find hides were
303
+ never offered.
304
+ - The read pickers still never offer columns that can't be read, and new
305
+ sorts, filter rules and functions start on a column the picker offers.
306
+ - The Create form doesn't treat columns Advanced Find hides (such as
307
+ `owneridtype`) as required, as before.
308
+ - A setting saved by an earlier version is reset to off once.
309
+ - Loading a saved request, pasting a URL and a batch item's entity set
310
+ check the table against every table, so a saved request for a table
311
+ outside the Query Scope loads instead of being reported missing.
312
+ - **Ids and names are checked before they go into a URL** ([#221]). A record
313
+ id must be a GUID, and a navigation property or column name a plain name,
314
+ before Execute enables. This applies in Associate, Disassociate, Execute
315
+ Action / Function / Workflow, Predefined Query and the file, image and
316
+ attachment modes. The other modes already checked. The executor refuses
317
+ them too, so a value like `x)/other_nav` can't send a different request.
318
+ - **A query function on a related table's column is caught inside `any` /
319
+ `all` too** ([#336]). Dataverse rejects a function such as `EqualUserId`
320
+ whose column runs through a relationship
321
+ (`PropertyName='parentcustomerid_account/ownerid'`). Outside a lambda
322
+ this already blocked Execute with an explanation; inside one it wasn't
323
+ checked, so the request was sent and failed.
324
+ - **Filter values are typed** ([#221]). A number, GUID or date column's
325
+ value goes into `$filter` unquoted only when it is one. Anything else is
326
+ quoted and escaped, and Execute is blocked with a message naming the value,
327
+ instead of a Dataverse 400. The DateTime fallback now escapes quotes. The
328
+ same applies to the Dataverse query functions (`LastXDays`, `Under`, …),
329
+ `$expand` inner filters and Bulk Delete Job. Filter column, lambda and
330
+ `$expand` names must be names too. EntityName columns (`objecttypecode`)
331
+ are now compared as strings, as the Web API expects.
332
+ - **Execute Function parameters are typed the same way** ([#221]). GUID and
333
+ date values go into the URL unquoted only when they are one, and record
334
+ references are escaped.
335
+ - **Imported saved requests are checked deeply** ([#221]). Entries whose
336
+ ids, names or query trees would change the URL are skipped, and the import
337
+ status says which and why. Copying or moving from another connection's
338
+ library applies the same check.
339
+ - **Retrieve Single no longer turns on `If-None-Match: null`** by default
340
+ ([#109]). Execute sends that header now, and `null` never matches an etag;
341
+ saved requests that have it still run without it.
342
+ - **Time zone independent times in a DST gap keep their digits** ([#337]).
343
+ Such a time is stored as typed, with no conversion. When it fell in the
344
+ hour your clocks skip (02:30 on a spring-forward day), the results grid and
345
+ the Update / Merge comparison showed it an hour later, and changing only
346
+ its date, or just clicking into the time picker and out, sent the later
347
+ time. The time picker itself still shows it an hour on, because it can
348
+ only hold a local time.
349
+ - **Exported URLs encode spaces** ([#221]). Postman, Insomnia and Bruno
350
+ collections, cURL / fetch / XHR / C# / PowerShell code and the HTTP-action
351
+ URIs write `%20`. The URL bar still shows spaces.
352
+
353
+ ### 🔧 Internal
354
+
355
+ - **Release model leftovers** ([#197]):
356
+ - `.github/dependabot.yml` sends grouped weekly updates into `dev` with a 14-day
357
+ cooldown, the same policy as FetchXML Studio and Command Bar Studio.
358
+ `RELEASING.md` describes it.
359
+ - `SECURITY.md` has the shared supported-versions table.
360
+ - **Alternate-key column types go through the shared type lookup**
361
+ ([#318]). Key columns typed separately (#64) now resolve the way every
362
+ other column does, Image and File included. No visible change: a key
363
+ column can't be an Image or File column.
364
+ - **Saved-request tests no longer re-import the store per test** ([#319]).
365
+ The store's startup (credential scrub, then read) is one function,
366
+ `startSavedStore()`, that the module runs at load and the tests call
367
+ directly. Those tests went from about 415 ms to about 20 ms each, so
368
+ they no longer time out when several test runs share the machine. One
369
+ test still loads the module afresh to check the startup wiring.
370
+ - **ESLint and a package check in CI** ([#273]), as in FetchXML Studio and
371
+ Command Bar Studio:
372
+ - `npm run lint` runs ESLint (recommended JS / TypeScript rules, React
373
+ hooks, jsx-a11y) with no warnings allowed, in CI. It also stops direct
374
+ `navigator.clipboard` use (#242). Fixing its findings removed dead code
375
+ and caught a crash: the `$apply` editor called two hooks after an early
376
+ return, so React threw when a table's metadata arrived after the
377
+ editor first rendered.
378
+ - CI and the release workflow check what `npm pack` would publish: the
379
+ files ToolBox needs, no sources or source maps, and a size budget.
380
+ - `npm run finalize-package` is gone; CI and the release workflow cover
381
+ it. `minAPI` stays at 1.2.0: DRS detects what the host can do at
382
+ runtime.
383
+ - **Tests for the write path** ([#235]): 272 new tests, 804 in all.
384
+ - A parity test checks, mode by mode, that Execute sends exactly what the
385
+ Code tab shows: method, URL, body and headers, apart from the documented
386
+ differences (headers the host builds, the reads' allow-list and page
387
+ size).
388
+ - The write executors' refusals: PUT of one column, alternate-key Upsert,
389
+ single-property Delete, unsafe ids, and impersonation on an older
390
+ ToolBox.
391
+ - Modules that had no tests: date and time values, the bypass headers,
392
+ workflow arguments, request validation, the query advisories, mode
393
+ drafts, the metadata cache and provider, and the ToolBox bridge's events.
394
+
395
+ [#197]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/197
396
+ [#42]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/42
397
+ [#347]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/347
398
+ [#330]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/330
399
+ [#242]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/242
400
+ [#317]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/317
401
+ [#334]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/334
402
+ [#235]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/235
403
+ [#273]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/273
404
+ [#319]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/319
405
+ [#318]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/318
406
+ [#248]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/248
407
+ [#335]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/335
408
+ [#222]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/222
409
+ [#44]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/44
410
+ [#336]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/336
411
+ [#109]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/109
412
+ [#221]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/221
413
+ [#337]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/337
414
+ [#241]: https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues/241
415
+
10
416
  ## [1.4.0] - 2026-10-30
11
417
 
12
418
  The first stable release since 1.1.4, and the biggest so far. The work planned
package/README.md CHANGED
@@ -9,13 +9,13 @@ file / image / attachment operations.
9
9
  Built for [Power Platform ToolBox](https://www.powerplatformtoolbox.com/) with
10
10
  React 18, Fluent UI v9, TypeScript, and live Dataverse metadata integration.
11
11
 
12
- [![npm](https://img.shields.io/npm/v/@mohsinonxrm/pptb-dataverse-request-studio?label=npm)](https://www.npmjs.com/package/@mohsinonxrm/pptb-dataverse-request-studio)
13
- [![npm beta](https://img.shields.io/npm/v/@mohsinonxrm/pptb-dataverse-request-studio/beta?label=beta&color=orange)](https://www.npmjs.com/package/@mohsinonxrm/pptb-dataverse-request-studio?activeTab=versions)
14
- ![React](https://img.shields.io/badge/React-18-61DAFB?logo=react)
15
- ![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6?logo=typescript)
16
- ![Fluent UI](https://img.shields.io/badge/Fluent%20UI-v9-0078D4?logo=microsoft)
17
- ![PPTB Types](https://img.shields.io/badge/%40pptb%2Ftypes-1.2.7-orange)
18
- ![License](https://img.shields.io/badge/license-AGPL--3.0--only-green)
12
+ [![Version](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/version.svg)](https://www.npmjs.com/package/@mohsinonxrm/pptb-dataverse-request-studio)
13
+ ![Power Platform ToolBox 1.2.0 or later](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/pptb.svg)
14
+ ![@pptb/types 1.2.7](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/pptb-types.svg)
15
+ ![React 18](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/react.svg)
16
+ ![TypeScript 5.9](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/typescript.svg)
17
+ ![Fluent UI v9](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/fluent-ui.svg)
18
+ ![License AGPL-3.0-only](https://raw.githubusercontent.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/refs/heads/main/assets/badges/license.svg)
19
19
 
20
20
  ---
21
21
 
@@ -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`)
@@ -233,9 +240,70 @@ modes have their own HTTP / fetch / C# / PPTB outputs.
233
240
  Dataverse Request Studio is available as a tool in Power Platform ToolBox.
234
241
  Install it from the tool gallery or load it as a custom tool. Stable releases
235
242
  are published to npm under the `latest` tag. Prereleases of the next version
236
- are published under the `beta` tag (for example `1.5.0-beta.1`) and use the
243
+ are published under the `beta` tag (for example `1.6.0-beta.1`) and use the
237
244
  gold Insider icon.
238
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
+
239
307
  ---
240
308
 
241
309
  ## 🛠️ Development
@@ -272,10 +340,18 @@ npm run preview
272
340
  # Validate manifest against PPTB registry rules
273
341
  npm run validate
274
342
 
275
- # Pre-publish: validate → build
276
- npm run finalize-package
343
+ # Lint (ESLint, no warnings allowed)
344
+ npm run lint
345
+
346
+ # Regenerate the README badges in assets/badges/ from package.json
347
+ npm run badges
277
348
  ```
278
349
 
350
+ The badges at the top of this README are SVG files in `assets/badges/`, linked from
351
+ `raw.githubusercontent.com`: Power Platform ToolBox shows the README in a window that only
352
+ loads images from GitHub, so `img.shields.io` badges don't appear there
353
+ ([RELEASING.md](https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/blob/dev/RELEASING.md#readme-images)).
354
+
279
355
  ### Standalone vs PPTB-embedded
280
356
 
281
357
  DRS runs in two modes:
@@ -422,6 +498,7 @@ Dataverse API)
422
498
  | `Prefer: return=representation` | ✅ (ToolBox always sends it on writes) |
423
499
  | Optimistic concurrency (`If-Match` / `If-None-Match`) | ✅ 1.2.7+ |
424
500
  | `MSCRM.*` bypass family (custom plug-ins, flows, async) | ✅ 1.2.7+ |
501
+ | Impersonation (`MSCRMCallerID` / `CallerObjectId`) on every mode | ✅ 1.2.7+ |
425
502
  | Single-property PUT / DELETE | 📝 |
426
503
  | Alternate-key upsert | 📝 |
427
504
  | 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};