@mohsinonxrm/pptb-dataverse-request-studio 1.1.4 → 1.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +413 -0
- package/README.md +196 -102
- package/SECURITY.md +9 -6
- package/dist/assets/AssociateMode-d9KnV2ms.js +1 -0
- package/dist/assets/AssociateTargetsEditor-CuQhdosb.js +1 -0
- package/dist/assets/BatchMode-CHTXXyh5.js +11 -0
- package/dist/assets/BinaryColumnPickers-xRDRVLGn.js +1 -0
- package/dist/assets/BulkDeleteMode-8wZ9ILFr.js +1 -0
- package/dist/assets/BulkWriteMode-Rw-BEdWo.js +6 -0
- package/dist/assets/DisassociateMode-CKUtzpgc.js +2 -0
- package/dist/assets/ExecuteWorkflowMode-lUjZeNYk.js +1 -0
- package/dist/assets/ManageFileMode-BWGAVS0m.js +1 -0
- package/dist/assets/ManageImageMode-BrOtm2A4.js +1 -0
- package/dist/assets/MergeMode-dDHs2-no.js +1 -0
- package/dist/assets/PredefinedQueryMode-B4zzRppz.js +1 -0
- package/dist/assets/RetrieveNextLinkMode-bLLnlOMS.js +1 -0
- package/dist/assets/cssMode-DL5lLcAs.js +4 -0
- package/dist/assets/{freemarker2-CY0Qd_yj.js → freemarker2-BCOyezro.js} +2 -2
- package/dist/assets/handlebars-OAtZzz2T.js +1 -0
- package/dist/assets/html-DEDOENUr.js +1 -0
- package/dist/assets/htmlMode-CbTgJqB3.js +4 -0
- package/dist/assets/index-DGsVifiB.js +702 -0
- package/dist/assets/javascript-CZCBdW2I.js +1 -0
- package/dist/assets/jsonMode-DlcExoVE.js +10 -0
- package/dist/assets/liquid-DqAKLfE-.js +1 -0
- package/dist/assets/mdx-NkZXeCnk.js +1 -0
- package/dist/assets/{monaco-editor-ErGqj9vD.js → monacoSetup-BIbZ_vQb.js} +194 -183
- package/dist/assets/monacoSetup-DvqauXKu.css +1 -0
- package/dist/assets/python-DewoE6OC.js +1 -0
- package/dist/assets/razor-41Lf02tV.js +1 -0
- package/dist/assets/{tsMode-B1b3lx86.js → tsMode-DRTJQ7Fk.js} +2 -2
- package/dist/assets/typescript-C7yUoo-S.js +1 -0
- package/dist/assets/xml-D8F8OJXA.js +1 -0
- package/dist/assets/yaml-DGFY75wt.js +1 -0
- package/dist/icons/icon.svg +10 -13
- package/dist/index.html +61 -4
- package/index.html +60 -1
- package/package.json +17 -4
- package/dist/assets/cssMode-DHcTSP5p.js +0 -4
- package/dist/assets/handlebars-BQEEw1Ke.js +0 -1
- package/dist/assets/html-BXibA6yW.js +0 -1
- package/dist/assets/htmlMode-BIOKXbRP.js +0 -4
- package/dist/assets/index-Dap9jY4Q.js +0 -682
- package/dist/assets/javascript-BY4qn0pJ.js +0 -1
- package/dist/assets/jsonMode-BzZNqTrE.js +0 -10
- package/dist/assets/liquid-noPAIv1T.js +0 -1
- package/dist/assets/mdx-Ccyf8KqT.js +0 -1
- package/dist/assets/monaco-editor-I3pIE735.css +0 -1
- package/dist/assets/python-CTl0fa86.js +0 -1
- package/dist/assets/razor-DoNzFhT2.js +0 -1
- package/dist/assets/typescript-ONTfb8eq.js +0 -1
- package/dist/assets/xml-6DyixHd0.js +0 -1
- package/dist/assets/yaml-B9La2-TQ.js +0 -1
package/README.md
CHANGED
|
@@ -1,84 +1,124 @@
|
|
|
1
1
|
# Dataverse Request Studio for Power Platform ToolBox
|
|
2
2
|
|
|
3
3
|
A metadata-driven studio for composing, previewing, and executing Microsoft
|
|
4
|
-
Dataverse Web API requests — covering OData reads, record writes,
|
|
5
|
-
associations, bound and unbound action/function
|
|
6
|
-
|
|
4
|
+
Dataverse Web API requests — covering OData reads, record writes, bulk writes
|
|
5
|
+
and bulk-delete jobs, table associations, bound and unbound action/function
|
|
6
|
+
invocation, on-demand workflows, `$batch` / ExecuteMultiple envelopes, and
|
|
7
|
+
file / image / attachment operations.
|
|
7
8
|
|
|
8
9
|
Built for [Power Platform ToolBox](https://www.powerplatformtoolbox.com/) with
|
|
9
10
|
React 18, Fluent UI v9, TypeScript, and live Dataverse metadata integration.
|
|
10
11
|
|
|
11
12
|
[](https://www.npmjs.com/package/@mohsinonxrm/pptb-dataverse-request-studio)
|
|
13
|
+
[](https://www.npmjs.com/package/@mohsinonxrm/pptb-dataverse-request-studio?activeTab=versions)
|
|
12
14
|

|
|
13
15
|

|
|
14
16
|

|
|
15
|
-

|
|
16
18
|

|
|
17
19
|
|
|
18
20
|
---
|
|
19
21
|
|
|
20
22
|
## ✨ Features
|
|
21
23
|
|
|
22
|
-
DRS ships with **
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
DRS ships with **23 request modes** in 7 groups. Every mode is
|
|
25
|
+
metadata-driven and generates the correct OData / Web API shape. The
|
|
26
|
+
single-request modes emit ready-to-copy code in ten formats: `fetch`, `Xrm.WebApi`,
|
|
27
|
+
`Xrm.WebApi.executeMultiple`, `XMLHttpRequest`, Power Automate, C#, PowerShell,
|
|
28
|
+
cURL, JSON, and an OpenAPI 3 document; the `$batch` and ExecuteMultiple
|
|
29
|
+
modes have their own HTTP / fetch / C# / PPTB outputs.
|
|
26
30
|
|
|
27
31
|
### 📖 Read group
|
|
28
32
|
|
|
29
33
|
- **Retrieve Multiple** — full OData query composer with `$select`, `$filter`,
|
|
30
|
-
`$orderby`, `$expand
|
|
31
|
-
aggregate), and a virtualized results
|
|
32
|
-
`@odata.nextLink
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
`$orderby`, `$expand` (nested, with inner `$filter` / `$orderby` / `$top`),
|
|
35
|
+
`$top`, `$count`, `$apply` (groupby / aggregate), and a virtualized results
|
|
36
|
+
grid with infinite scroll via `@odata.nextLink`, **Retrieve all** (pauses
|
|
37
|
+
every 50,000 rows with **Continue**), CSV / JSON export, per-column filters,
|
|
38
|
+
row search, density and persisted column widths.
|
|
39
|
+
Address shortcut chips in the `$filter` builder; paste any OData URL to load
|
|
40
|
+
it into the builder.
|
|
41
|
+
- **Retrieve Single** — one record by primary key (GUID), with `$select` /
|
|
42
|
+
`$expand`.
|
|
35
43
|
- **Retrieve NextLink** — paste a `@odata.nextLink` URL to continue paging
|
|
36
44
|
any query.
|
|
37
45
|
- **Predefined Query** — execute saved-query (`?savedQuery=<id>`) and
|
|
38
|
-
user-query (`?userQuery=<id>`) URLs against an entity set
|
|
39
|
-
results grid that matches the source view's
|
|
46
|
+
user-query (`?userQuery=<id>`) URLs against an entity set, or over a row's
|
|
47
|
+
related records; layout-aware results grid that matches the source view's
|
|
48
|
+
column order.
|
|
40
49
|
|
|
41
50
|
### ✏️ Write group
|
|
42
51
|
|
|
43
|
-
- **Create Record** — `POST /<set>` with metadata-driven field-set editor
|
|
44
|
-
Required-field guard
|
|
45
|
-
|
|
52
|
+
- **Create Record** — `POST /<set>` with a metadata-driven field-set editor or
|
|
53
|
+
a raw JSON body. Required-field guard, `Prefer: return=representation`,
|
|
54
|
+
optional `$select` return list, duplicate detection and the `MSCRM.*`
|
|
55
|
+
bypass-header family. **Retrieve this record** from the result card.
|
|
46
56
|
- **Update Record** — `PATCH /<set>(<id>)` multi-field OR
|
|
47
|
-
`PUT /<set>(<id>)/<col>` single-column
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
`PUT /<set>(<id>)/<col>` single-column (Code tab only), with a before →
|
|
58
|
+
after diff.
|
|
59
|
+
**Require existing record** (`If-Match: *`) is the default, so a wrong GUID
|
|
60
|
+
returns 404 instead of creating a record.
|
|
61
|
+
- **Upsert Record** — full upsert / create-only / update-only / ETag-guarded
|
|
62
|
+
variants, by GUID or alternate key (alternate key: Code tab only).
|
|
51
63
|
- **Delete Record** — `DELETE /<set>(<id>)` with a typed-confirmation safety
|
|
52
64
|
affordance + cascade-impact preview. Single-property delete via
|
|
53
|
-
`DELETE /<set>(<id>)/<col>`
|
|
54
|
-
- **Merge Records** — `POST /Merge` for `account` / `contact` / `
|
|
55
|
-
with target + subordinate record cards, field-override matrix,
|
|
56
|
-
PerformParentingChecks / SuppressDuplicateDetection settings.
|
|
65
|
+
`DELETE /<set>(<id>)/<col>` is composed for the Code tab.
|
|
66
|
+
- **Merge Records** — `POST /Merge` for `account` / `contact` / `lead` /
|
|
67
|
+
`incident` with target + subordinate record cards, field-override matrix,
|
|
68
|
+
and PerformParentingChecks / SuppressDuplicateDetection settings.
|
|
69
|
+
|
|
70
|
+
### 📦 Bulk group
|
|
71
|
+
|
|
72
|
+
- **Bulk Write** — `CreateMultiple` / `UpdateMultiple` / `UpsertMultiple` /
|
|
73
|
+
`DeleteMultiple` over a grid of rows, with a per-table support check.
|
|
74
|
+
- **Bulk Delete Job** — a `BulkDelete` system job built from a query, with a
|
|
75
|
+
scheduled or immediate start and live job-status polling.
|
|
57
76
|
|
|
58
77
|
### 🔗 Relate group
|
|
59
78
|
|
|
60
79
|
- **Associate** — links related records via `POST /<set>(<id>)/<nav>/$ref`
|
|
61
|
-
for collection-valued navs
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
for collection-valued navs (one request per target, already-linked targets
|
|
81
|
+
skipped), or `PATCH @odata.bind` for single-valued. Cardinality detected
|
|
82
|
+
from metadata; verb auto-flips with the picker. Polymorphic lookups
|
|
83
|
+
(Customer / Owner / `regardingobjectid`) fully supported.
|
|
65
84
|
- **Disassociate** — `DELETE /$ref` for collection-valued, `PATCH @odata.bind: null`
|
|
66
85
|
for single-valued. Same polymorphism story.
|
|
86
|
+
- Single-valued PATCHes carry `If-Match: *`, so a wrong source id can't create
|
|
87
|
+
a record. Multi-target results are reported per target.
|
|
67
88
|
|
|
68
89
|
### ⚡ Execute group
|
|
69
90
|
|
|
70
|
-
- **Execute Action** — OOB
|
|
71
|
-
|
|
72
|
-
`POST /<Action>`. CSDL-driven parameter form with type-aware
|
|
73
|
-
required-first UX, Form ↔ JSON toggle, EntityReference
|
|
74
|
-
|
|
91
|
+
- **Execute Action** — OOB action invocation via bound
|
|
92
|
+
`POST /<set>(<id>)/Microsoft.Dynamics.CRM.<Action>`, collection-bound, OR
|
|
93
|
+
unbound `POST /<Action>`. CSDL-driven parameter form with type-aware
|
|
94
|
+
controls: required-first UX, Form ↔ JSON toggle, EntityReference (existing
|
|
95
|
+
record) or EntitySpecific (existing record or new instance) /
|
|
96
|
+
EntityCollection / Edm primitives / collections / Enum / OptionSet
|
|
97
|
+
enrichment.
|
|
98
|
+
- **Execute Custom API** / **Execute Custom Action** — the same composer,
|
|
99
|
+
listing every Custom API and every custom process action, Microsoft's own
|
|
100
|
+
included. Classification comes from Dataverse data (`customapi`,
|
|
101
|
+
`workflow` + `sdkmessage`); the name is only a fallback when those lookups
|
|
102
|
+
fail.
|
|
75
103
|
- **Execute Function** — OData function calls with parameter aliasing
|
|
76
|
-
(`?@p1=...`) vs inline
|
|
77
|
-
|
|
104
|
+
(`?@p1=...`) vs inline literals, valid OData literals and escaping, run from
|
|
105
|
+
the built URL.
|
|
78
106
|
- **Execute Workflow** — runs on-demand workflows via
|
|
79
107
|
`POST /workflows(<id>)/Microsoft.Dynamics.CRM.ExecuteWorkflow` with the
|
|
80
|
-
bound record id
|
|
81
|
-
|
|
108
|
+
bound record id, showing the workflow's declared input arguments.
|
|
109
|
+
|
|
110
|
+
### 🧺 Batch group
|
|
111
|
+
|
|
112
|
+
- **`$batch` Request** — compose a `$batch` from groups of requests: change
|
|
113
|
+
sets (atomic, with `$n` Content-ID references) or independent requests, with
|
|
114
|
+
continue-on-error. Add the last request of a read, write, relate or execute
|
|
115
|
+
mode; per-part results with
|
|
116
|
+
status and body. A batch that mixes change sets and independent requests
|
|
117
|
+
is sent as consecutive ToolBox calls. Needs PPTB 1.2.7+.
|
|
118
|
+
- **ExecuteMultiple** — the ExecuteMultiple pattern (independent requests,
|
|
119
|
+
continue-on-error, return responses) on the `$batch` engine, with SDK
|
|
120
|
+
`ExecuteMultipleRequest` (C#), raw `$batch` and PPTB code. Needs PPTB
|
|
121
|
+
1.2.7+.
|
|
82
122
|
|
|
83
123
|
### 💾 Binary group
|
|
84
124
|
|
|
@@ -98,13 +138,24 @@ curl, PowerShell).
|
|
|
98
138
|
GET `/$value` OR `Initialize{...}BlocksDownload` / `DownloadBlock` for
|
|
99
139
|
download.
|
|
100
140
|
|
|
141
|
+
> The binary modes compose the request pipeline and its code, but the PPTB
|
|
142
|
+
> Dataverse API doesn't expose these chunked operations, so **Execute returns
|
|
143
|
+
> `501 Not Implemented`** in this group. Run the generated code from the Code
|
|
144
|
+
> tab instead.
|
|
145
|
+
|
|
101
146
|
### 🔍 Cross-cutting capabilities
|
|
102
147
|
|
|
103
148
|
- **Live metadata** — Tables, columns, relationships, alternate keys, action
|
|
104
|
-
/ function CSDL all fetched lazily from the host's `dataverseAPI
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
149
|
+
/ function CSDL all fetched lazily from the host's `dataverseAPI`, cached per
|
|
150
|
+
org with in-flight promise dedup. Switching the PPTB connection resets the
|
|
151
|
+
prepared request and reloads metadata for the new environment.
|
|
152
|
+
- **Request headers through PPTB 1.2.7+** — Create / Update / Upsert /
|
|
153
|
+
Delete / Merge / Bulk Write / Execute Action / Execute Workflow headers
|
|
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.
|
|
108
159
|
- **Antipattern advisories** — Surfaces real-time guidance per the
|
|
109
160
|
[Microsoft query-antipatterns doc](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/query-antipatterns):
|
|
110
161
|
`FilteringOnCalculatedColumns`, `LargeAmountOfLogicalAttributes`, large-text
|
|
@@ -113,17 +164,23 @@ curl, PowerShell).
|
|
|
113
164
|
- **Polymorphic lookup support** — Customer, Owner, and multi-target lookups
|
|
114
165
|
(`regardingobjectid`) emit the correct target-disambiguated
|
|
115
166
|
`<navName>@odata.bind` binding shape automatically.
|
|
116
|
-
- **Code generators** — Every mode emits the same request as
|
|
117
|
-
`Xrm.WebApi
|
|
118
|
-
`
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
-
|
|
122
|
-
|
|
123
|
-
rename / delete / overwrite
|
|
124
|
-
-
|
|
125
|
-
|
|
126
|
-
|
|
167
|
+
- **Code generators** — Every single-request mode emits the same request as `fetch`,
|
|
168
|
+
`Xrm.WebApi` (CRUD helpers or `Xrm.WebApi.online.execute`),
|
|
169
|
+
`Xrm.WebApi.online.executeMultiple`, `XMLHttpRequest`, C# `HttpClient`,
|
|
170
|
+
PowerShell `Invoke-RestMethod`, cURL, a JSON description and an OpenAPI 3
|
|
171
|
+
document, plus a field-by-field Power Automate (Dataverse connector) sheet.
|
|
172
|
+
Multi-request pipelines render as full ordered sequences.
|
|
173
|
+
- **Saved-request library** — per-connection, versioned, up to 200 requests
|
|
174
|
+
across all modes, with auto-suggested names, rename / delete / overwrite and
|
|
175
|
+
dirty-state detection. Export / import as JSON, export as a Postman /
|
|
176
|
+
Insomnia / Bruno collection, and copy or move requests from other
|
|
177
|
+
connections. A library that can't be read is never overwritten.
|
|
178
|
+
- **Recent runs** — click a run to restore it into its mode. Each mode keeps
|
|
179
|
+
its unsaved request when you switch modes.
|
|
180
|
+
- **Results** — CSV export (formulas neutralised for spreadsheets), JSON
|
|
181
|
+
export, Copy as TSV, and response-size hints.
|
|
182
|
+
- **Accessibility** — labelled inputs, readable badges and live-region
|
|
183
|
+
announcements; render errors are contained per pane.
|
|
127
184
|
|
|
128
185
|
---
|
|
129
186
|
|
|
@@ -162,14 +219,21 @@ curl, PowerShell).
|
|
|
162
219
|
|
|
163
220
|
### Prerequisites
|
|
164
221
|
|
|
165
|
-
- [Power Platform ToolBox](https://www.powerplatformtoolbox.com/)
|
|
222
|
+
- [Power Platform ToolBox](https://www.powerplatformtoolbox.com/) **1.2.0 or
|
|
223
|
+
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.
|
|
166
227
|
- A connection to a Dataverse environment
|
|
167
|
-
- For local development: **Node.js
|
|
228
|
+
- For local development: **Node.js 22.22.2+, 24.15+ or 26+** and **npm** (see
|
|
229
|
+
`engines` in `package.json`)
|
|
168
230
|
|
|
169
231
|
### Installation
|
|
170
232
|
|
|
171
233
|
Dataverse Request Studio is available as a tool in Power Platform ToolBox.
|
|
172
|
-
Install it from the tool gallery or load it as a custom tool.
|
|
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
|
|
236
|
+
gold Insider icon.
|
|
173
237
|
|
|
174
238
|
---
|
|
175
239
|
|
|
@@ -192,9 +256,15 @@ npm run dev
|
|
|
192
256
|
# TypeScript-only check (fast)
|
|
193
257
|
npm run typecheck
|
|
194
258
|
|
|
259
|
+
# Unit tests (Vitest)
|
|
260
|
+
npm test
|
|
261
|
+
|
|
195
262
|
# Production build
|
|
196
263
|
npm run build
|
|
197
264
|
|
|
265
|
+
# Bundle size report
|
|
266
|
+
npm run build:analyze
|
|
267
|
+
|
|
198
268
|
# Preview the production build locally
|
|
199
269
|
npm run preview
|
|
200
270
|
|
|
@@ -210,9 +280,9 @@ npm run finalize-package
|
|
|
210
280
|
DRS runs in two modes:
|
|
211
281
|
|
|
212
282
|
- **Standalone** (`npm run dev`) — opens in a regular browser tab. Useful
|
|
213
|
-
for UI iteration
|
|
214
|
-
|
|
215
|
-
|
|
283
|
+
for UI iteration only: without the host bridge no live metadata loads, and
|
|
284
|
+
Execute returns `501 Not Implemented` ("Running standalone: Execute needs
|
|
285
|
+
the PPTB host"); the Bulk modes report it as an error result.
|
|
216
286
|
- **Embedded in PPTB** — loads inside the PPTB iframe. The host injects
|
|
217
287
|
`window.dataverseAPI` (typed) and `window.toolboxAPI`. Execute runs
|
|
218
288
|
against the active Dataverse connection.
|
|
@@ -233,7 +303,8 @@ commit style, code style, and PR guidance.
|
|
|
233
303
|
| **Monaco Editor** | 0.54 | JSON / code editor for body authoring and Code tab |
|
|
234
304
|
| **@fluentui-contrib/react-data-grid-react-window** | 1.4 | Virtualized results grid |
|
|
235
305
|
| **@dnd-kit** | 6.3 | Drag-reordering for filter / orderby / select clauses |
|
|
236
|
-
| **@pptb/types** | 1.2.
|
|
306
|
+
| **@pptb/types** | 1.2.7 | Power Platform ToolBox host API types |
|
|
307
|
+
| **Vitest** | 5 | Unit tests (request engine, code generators, storage) |
|
|
237
308
|
|
|
238
309
|
---
|
|
239
310
|
|
|
@@ -244,7 +315,7 @@ src/
|
|
|
244
315
|
App.tsx — root, ThemedApp, Frame, mode router
|
|
245
316
|
main.tsx — Vite entry point
|
|
246
317
|
|
|
247
|
-
modes/ —
|
|
318
|
+
modes/ — request-mode components (23 modes)
|
|
248
319
|
RetrieveMultipleMode.tsx
|
|
249
320
|
RetrieveSingleMode.tsx
|
|
250
321
|
RetrieveNextLinkMode.tsx
|
|
@@ -252,56 +323,74 @@ src/
|
|
|
252
323
|
CreateMode.tsx / UpdateMode.tsx / UpsertMode.tsx / DeleteMode.tsx
|
|
253
324
|
MergeMode.tsx
|
|
254
325
|
AssociateMode.tsx / DisassociateMode.tsx
|
|
255
|
-
ExecuteActionMode.tsx /
|
|
326
|
+
ExecuteActionMode.tsx — Execute Action / Custom API / Custom Action
|
|
327
|
+
ExecuteFunctionMode.tsx / ExecuteWorkflowMode.tsx
|
|
256
328
|
ManageFileMode.tsx / ManageImageMode.tsx / ManageAttachmentMode.tsx
|
|
329
|
+
BulkWriteMode.tsx / BulkDeleteMode.tsx
|
|
330
|
+
BatchMode.tsx + batch/ — $batch Request and ExecuteMultiple
|
|
331
|
+
StubMode.tsx — fallback for an unknown mode id
|
|
257
332
|
|
|
258
333
|
editors/ — clause editors shared across modes
|
|
259
334
|
filter/ — FilterEditor + value inputs + operator catalog
|
|
335
|
+
expand/ — $expand tree navigation
|
|
260
336
|
FieldSetEditor.tsx — metadata-driven write-side form
|
|
261
337
|
SelectEditor.tsx, OrderbyEditor.tsx, ExpandEditor.tsx, ApplyEditor.tsx
|
|
262
338
|
ActionParamForm.tsx — CSDL-driven action / function params
|
|
263
339
|
BinarySourceCard.tsx, BinaryPipelineCard.tsx, BinaryColumnPickers.tsx
|
|
264
|
-
HeadersEditor.tsx, BypassEditor.tsx
|
|
265
|
-
ActionPicker.tsx,
|
|
340
|
+
HeadersEditor.tsx, BypassEditor.tsx, PreconditionEditor.tsx
|
|
341
|
+
ActionPicker.tsx, NavPropertyPicker.tsx, PasteODataDialog.tsx
|
|
266
342
|
...
|
|
267
343
|
|
|
268
344
|
engine/ — URL / body construction + code generation
|
|
269
345
|
urlBuilder.ts — central URL builder for every mode
|
|
270
346
|
executeBuilders.ts — action / function / workflow body builders
|
|
271
347
|
binaryBuilders.ts — file / image / attachment pipelines
|
|
272
|
-
codeGenerators.ts —
|
|
348
|
+
codeGenerators.ts — fetch, Xrm.WebApi (+ executeMultiple), XHR,
|
|
349
|
+
Power Automate, C#, PowerShell, cURL, JSON
|
|
350
|
+
openApiGenerator.ts — OpenAPI 3 document for the current request
|
|
351
|
+
collectionFormats.ts, savedToCollection.ts
|
|
352
|
+
— Postman / Insomnia / Bruno collection export
|
|
353
|
+
bulkWrite*.ts, bulkDelete*.ts, batch/
|
|
354
|
+
— Bulk Write, Bulk Delete Job, $batch engine
|
|
355
|
+
sensitiveHeaders.ts — credential / impersonation header policy
|
|
273
356
|
runtime.ts — single dispatch point for execute
|
|
274
357
|
dataverseExecutor.ts — live executor over the host's dataverseAPI
|
|
275
358
|
odataParser.ts — round-trips OData URL strings ↔ state
|
|
359
|
+
antipatterns.tsx, bypassAdvisories.tsx, hostHeaderAdvisories.tsx
|
|
360
|
+
— advisory detectors
|
|
276
361
|
|
|
277
362
|
host/ — PPTB bridge + metadata loaders
|
|
278
363
|
pptbBridge.ts — typed wrapper over window.dataverseAPI
|
|
279
364
|
metadataProvider.ts — entity / attribute / relationship loaders
|
|
280
365
|
csdlProvider.ts — $metadata XML parsing + action / function index
|
|
281
|
-
cache.ts —
|
|
366
|
+
cache.ts — per-org metadata caches (TTL + in-flight dedup)
|
|
282
367
|
useLiveMetadata.ts, useColumnDetail.ts, useScopedEntities.ts, …
|
|
283
368
|
|
|
284
369
|
primitives/ — small reusable UI bits
|
|
285
|
-
|
|
370
|
+
ClauseTreeItem.tsx, SectionHeader.tsx, ModeCard.tsx, RequestTypePicker.tsx
|
|
286
371
|
StatusPill.tsx, MethodPill.tsx, AdvisoryDrawer.tsx, advisories.ts
|
|
287
372
|
NavPathColumnPicker.tsx — N:1 drill-down column picker for filter / apply
|
|
288
|
-
KvGrid.tsx, Sortable.tsx, SegmentedToggle.tsx, …
|
|
373
|
+
RecordPicker.tsx, KvGrid.tsx, Sortable.tsx, SegmentedToggle.tsx, …
|
|
289
374
|
|
|
290
|
-
shell/ —
|
|
291
|
-
|
|
292
|
-
UrlBar.tsx, MainTabs.tsx, SettingsDrawer.tsx
|
|
375
|
+
shell/ — header / sidebar / URL bar / tabs / drawers
|
|
376
|
+
FrameHeader.tsx, ModeShell.tsx, Sidebar.tsx
|
|
377
|
+
UrlBar.tsx, UrlTokens.tsx, MainTabs.tsx, SettingsDrawer.tsx
|
|
293
378
|
|
|
294
379
|
state/ — per-mode state shapes + persistence
|
|
295
380
|
readState.ts, writeState.ts, relateState.ts, executeState.ts, binaryState.ts
|
|
296
381
|
savedRequests.ts — localStorage persistence (per-org scope)
|
|
382
|
+
useSavedRequests.tsx — shared saved-request store
|
|
383
|
+
modeDrafts.ts — unsaved request per mode (this session)
|
|
297
384
|
SaveContext.tsx — cross-mode save/load context
|
|
385
|
+
validateRequest.tsx — pre-execute request validation
|
|
298
386
|
displaySettings.ts — display preferences
|
|
299
387
|
|
|
300
388
|
registry/ — request-type catalogue
|
|
301
|
-
requestTypes.ts —
|
|
389
|
+
requestTypes.ts — 23 request types grouped into 7 groups
|
|
302
390
|
|
|
303
391
|
views/ — output panes
|
|
304
|
-
CodeView.tsx — Code tab:
|
|
392
|
+
CodeView.tsx — Code tab: one sub-tab per code format
|
|
393
|
+
PowerAutomatePane.tsx — Power Automate field-by-field sheet
|
|
305
394
|
ResultsView.tsx — tabs (Detail/Grid/JSON/Headers) + error state
|
|
306
395
|
results/ — grid + cell renderers + flattening
|
|
307
396
|
detail/ — record detail card
|
|
@@ -313,34 +402,39 @@ src/
|
|
|
313
402
|
|
|
314
403
|
## 📋 Web API coverage
|
|
315
404
|
|
|
405
|
+
✅ = compose + Execute in PPTB · ✅ 1.2.7+ = Execute needs PPTB 1.2.7 or
|
|
406
|
+
later · 📝 = compose + Code tab only (not available through the PPTB
|
|
407
|
+
Dataverse API)
|
|
408
|
+
|
|
316
409
|
| Operation | Status |
|
|
317
410
|
|---|---|
|
|
318
411
|
| Retrieve Multiple (full OData) | ✅ |
|
|
319
|
-
| Retrieve Single (by GUID
|
|
320
|
-
| `@odata.nextLink` paging | ✅ |
|
|
321
|
-
|
|
|
412
|
+
| Retrieve Single (by GUID) | ✅ |
|
|
413
|
+
| `@odata.nextLink` paging, Retrieve all | ✅ |
|
|
414
|
+
| `Prefer: odata.maxpagesize` (page size) | ✅ 1.2.7+ (older ToolBox: Execute keeps `$top` instead) |
|
|
415
|
+
| Predefined / user queries (incl. over related records) | ✅ |
|
|
322
416
|
| `$apply` (groupby / aggregate) | ✅ |
|
|
323
417
|
| Lambda filter (`any` / `all`) | ✅ |
|
|
324
418
|
| `$expand` (single + collection, nested) | ✅ |
|
|
325
419
|
| Polymorphic lookups (Customer, Owner, regardingobjectid) | ✅ |
|
|
326
420
|
| Create / Update / Upsert / Delete | ✅ |
|
|
327
|
-
| `Prefer: return=representation` | ✅ |
|
|
328
|
-
| Optimistic concurrency (`If-Match`
|
|
329
|
-
| `MSCRM.*` bypass family (custom plug-ins, flows, async) | ✅ |
|
|
330
|
-
| Single-property PUT / DELETE |
|
|
331
|
-
| Alternate-key upsert |
|
|
421
|
+
| `Prefer: return=representation` | ✅ (ToolBox always sends it on writes) |
|
|
422
|
+
| Optimistic concurrency (`If-Match` / `If-None-Match`) | ✅ 1.2.7+ |
|
|
423
|
+
| `MSCRM.*` bypass family (custom plug-ins, flows, async) | ✅ 1.2.7+ |
|
|
424
|
+
| Single-property PUT / DELETE | 📝 |
|
|
425
|
+
| Alternate-key upsert | 📝 |
|
|
332
426
|
| Associate / Disassociate (collection + single-valued) | ✅ |
|
|
333
|
-
| Merge (account / contact / incident) | ✅ |
|
|
427
|
+
| Merge (account / contact / lead / incident) | ✅ |
|
|
334
428
|
| Execute Action (OOB / Custom API / Custom Action) | ✅ |
|
|
335
429
|
| Execute Function | ✅ |
|
|
336
430
|
| Execute Workflow | ✅ |
|
|
337
|
-
|
|
|
338
|
-
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
341
|
-
|
|
|
342
|
-
|
|
|
343
|
-
|
|
|
431
|
+
| `CreateMultiple` / `UpdateMultiple` / `UpsertMultiple` / `DeleteMultiple` | ✅ |
|
|
432
|
+
| `BulkDelete` async job | ✅ |
|
|
433
|
+
| `$batch` (change sets + independent requests) | ✅ 1.2.7+ |
|
|
434
|
+
| `ExecuteMultiple` pattern | ✅ 1.2.7+ |
|
|
435
|
+
| File column (upload / download / delete) | 📝 |
|
|
436
|
+
| Image column (thumbnail / full-size) | 📝 |
|
|
437
|
+
| Attachment / Note (inline + message-based) | 📝 |
|
|
344
438
|
|
|
345
439
|
---
|
|
346
440
|
|
|
@@ -353,18 +447,18 @@ commit style, code style, repo layout, and PR guidance.
|
|
|
353
447
|
|
|
354
448
|
## 📋 Roadmap
|
|
355
449
|
|
|
356
|
-
|
|
357
|
-
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
-
|
|
362
|
-
-
|
|
363
|
-
-
|
|
364
|
-
-
|
|
365
|
-
-
|
|
366
|
-
-
|
|
367
|
-
|
|
450
|
+
Planned work is tracked in the repository's
|
|
451
|
+
[milestones](https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/milestones)
|
|
452
|
+
and [issues](https://github.com/mohsinonxrm/pptb-mxrm-dataverse-request-studio/issues).
|
|
453
|
+
Ideas under consideration include:
|
|
454
|
+
|
|
455
|
+
- Request variables (`{{var}}`) and persistent request history
|
|
456
|
+
- FetchXML and Dataverse Search API modes
|
|
457
|
+
- A metadata browser mode
|
|
458
|
+
- Comparing responses across runs or environments
|
|
459
|
+
- Importing Postman / Insomnia collections and cURL commands
|
|
460
|
+
- More code-generation targets (C# ServiceClient / IOrganizationService,
|
|
461
|
+
Python, the PowerShell Dataverse module)
|
|
368
462
|
|
|
369
463
|
---
|
|
370
464
|
|
package/SECURITY.md
CHANGED
|
@@ -30,16 +30,19 @@ in a browser. Vulnerability reports of interest:
|
|
|
30
30
|
triggers code execution on load, exfiltrates localStorage from another
|
|
31
31
|
org scope, or escapes the per-org scoping bucket.
|
|
32
32
|
- **Dependency vulnerabilities** — known CVEs in production dependencies
|
|
33
|
-
(`@fluentui/*`, `monaco-editor`, `@
|
|
34
|
-
shipped bundle.
|
|
33
|
+
(`@fluentui/*`, `monaco-editor`, `@monaco-editor/react`, `@dnd-kit/*`,
|
|
34
|
+
`react`, etc.) that affect the shipped bundle. Dev-only tooling
|
|
35
|
+
(`@pptb/types`, Vite, TypeScript, Prettier) isn't shipped.
|
|
35
36
|
|
|
36
37
|
## Out of scope
|
|
37
38
|
|
|
38
39
|
- **Mistakes the user makes against their own environment** — DRS lets you
|
|
39
|
-
Delete, Update, and Merge records.
|
|
40
|
-
confirmation;
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
Delete, Update, and Merge records. Delete and Bulk Delete Job require typed
|
|
41
|
+
confirmation; bulk and batch deletes and Merge don't. Beyond that, the user
|
|
42
|
+
is responsible for what they send.
|
|
43
|
+
- **Standalone-mode Execute errors** — the standalone build (`npm run dev`)
|
|
44
|
+
has no host bridge, so Execute returns `501 Not Implemented` ("Running
|
|
45
|
+
standalone: Execute needs the PPTB host"). This is by design, not a bug.
|
|
43
46
|
- **Antipattern advisories** — the studio surfaces guidance per the
|
|
44
47
|
Microsoft query-antipatterns doc, but it's advisory only; the request
|
|
45
48
|
still goes through if the user proceeds.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as ae,b6 as se,bL as U,r,u as re,e as oe,bM as ne,bN as le,bO as ie,f as de,bP as ce,bQ as ue,ba as ge,i as I,k as he,T as be,l as pe,bR as me,bS as ye,bG as ve,bH as fe,bT as R,L as Se,q as xe,t as a,H as Te,B as Pe,D as Ne,J as je,w as we,bU as ke,y as Ce,z as Me,A as Ie,G as Re,R as Ae,bV as D,U as He,S as Fe,I as Le,bm as $e,aT as Be,bn as qe,b5 as Ee,a9 as Oe,Y as P,bl as Ue,Z as De,a$ as ze}from"./index-DGsVifiB.js";import{A as Ve,N as We}from"./AssociateTargetsEditor-CuQhdosb.js";const Ge=()=>({table:"",sourceId:null,navProperty:null,targets:[],targetNames:{},headers:Le(),dirty:new Set});function _e({themeMode:d}){const p=ae("associate"),n=se("associate",U,Ge),[e,c]=r.useState(n.state),{table:N}=re(e.table||null),{entities:A}=oe(),[H,F]=r.useState("source"),[m,j]=r.useState("builder"),[L,w]=r.useState(null),[V,$]=r.useState(!1),[W,G]=r.useState([]),[y,v]=r.useState(n.lastSavedId),[f,S]=r.useState(n.lastSavedHash),[B,k]=r.useState(""),b=r.useMemo(()=>ne(e),[e,N]),J=r.useMemo(()=>le(e),[e,N]),l=r.useMemo(()=>ie(e),[e,N]),x=de(e.table),o=e.navProperty?x?.navigationProperties.find(t=>t.name===e.navProperty):void 0,q=o?ce(o):!1,u=q?"PATCH":"POST",C=t=>c(s=>{const i=new Set(s.dirty);return i.add(t),{...s,dirty:i}}),T=(t,s,i)=>{c(M=>({...M,[t]:s})),i&&C(i)},Q=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.":null:"Pick a navigation property.":"Pick a source record.":"Pick a source table first.",Y=async()=>{$(!0);const t=await Be.associate(e);w(t),$(!1),j("results"),G(s=>[{id:`r-${Date.now()}`,snapshot:g,modeId:"associate",url:b.relativeUrl,method:u,ts:Date.now(),status:t.status,ms:t.ms,rowCount:D(t,l.length)??0},...s].slice(0,8)),c(s=>({...s,dirty:new Set}))},g=r.useMemo(()=>ue(e),[e]);ge("associate",g,y,f);const Z=r.useMemo(()=>I(g),[g]),E=f===null?!0:Z!==f,_=t=>{v(t.id),S(I(t.state))},O=t=>{if(t.modeId!=="associate")return;const s=t.state;if(A.length>0&&!A.some(i=>i.logicalName===s.table)){$e(`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(U(s)),v(t.id),S(I(s)),w(null),k(""),F("source")},K=t=>{const s=qe(t,"associate");if(!s)return;const i=y,M=f;O(s),v(i),S(M)};he(r.useMemo(()=>e.table?{state:g,modeId:"associate",dirty:E,lastSavedId:y,onSaved:_,onLoadSaved:O}:null,[g,E,y,e.table]));const X=[{id:"source",label:"Target",meta:x?.displayName??"Pick a table",items:[{id:"source",icon:pe,iconFilled:be,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?z(o.cardinality):"pick one",items:[{id:"nav",icon:ye,iconFilled:me,label:o?o.name:"Navigation property",code:!!o,badge:o?z(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:fe,iconFilled:ve,label:q?"Target record":"Target records",badge:e.targets.length||null,badgeAppearance:"tint",badgeColor:e.targets.length>0?"success":"subtle",dirty:e.dirty.has("targets")},...l.length>0?[{id:"preview",icon:R,iconFilled:R,label:`${l.length} request${l.length===1?"":"s"}`,badge:l.length,badgeAppearance:"ghost"}]:[]]},{id:"headers",label:"Headers",meta:`${e.headers.filter(t=>t.enabled).length} active`,items:[{id:"headers",icon:xe,iconFilled:Se,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(we,{table:e.table,onTableChange:t=>{c(s=>({...s,table:t,sourceId:null,navProperty:null,targets:[],targetNames:{},dirty:new Set(["source","nav","targets"])})),k(""),w(null),v(void 0),S(null)},recordId:e.sourceId,onRecordChange:(t,s)=>{T("sourceId",t,"source"),k(s??"")},group:"relate",sub:"Pick the source entity and the record that the relationship anchors on."});break;case"nav":h=a.jsx(We,{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(Pe,{layout:"multiline",intent:"info",children:a.jsxs(Ne,{children:[a.jsx(je,{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(Ve,{table:e.table,navProperty:e.navProperty,targets:e.targets,setTargets:t=>T("targets",t,"targets"),targetNames:e.targetNames,setTargetNames:t=>T("targetNames",t),group:"relate",resolvedMethod:o?u:null});break;case"preview":h=a.jsx(Je,{requests:l});break;case"headers":h=a.jsx(Te,{items:e.headers,setItems:t=>T("headers",t,"headers"),group:"relate"});break}const ee=ke(u,Ce(e.headers,null)),te={method:u,built:b,headers:ee,body:J,entityLogical:b.entityLogical,multiRequests:l.length>1?l.map(t=>({method:t.method,relativeUrl:t.relativeUrl,body:t.body,description:`target ${t.targetId}`})):void 0};return a.jsx(Me,{sidebar:a.jsx(Fe,{type:p,urlPreview:b.relativeNoBase,sections:X,activeNode:H,onSelect:t=>{F(t),j("builder")},recents:W,onRecentClick:K}),urlBar:a.jsx(He,{method:u,url:b.relativeUrl,executeVerb:p.executeVerb,disabledReason:Q,loading:V,onExecute:Y}),children:a.jsxs(Ie,{tab:m,onTabChange:j,resultCount:D(L,l.length),children:[m==="builder"&&h,m==="code"&&a.jsx(Re,{themeMode:d,inputs:te}),m==="results"&&a.jsx(Ae,{result:L,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 Je({requests:d}){const p=Ee();return a.jsxs("div",{children:[a.jsx(Oe,{icon:R,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:ze(p.inlineCard),style:{padding:12,maxWidth:980,fontFamily:P.fontFamilyMonospace,fontSize:11},children:[d.map((n,e)=>a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"60px 1fr",gap:8,padding:"8px 0",borderBottom:e<d.length-1?`1px solid ${P.colorNeutralStroke3}`:"none"},children:[a.jsx(Ue,{appearance:"filled",color:n.method==="POST"?"success":"warning",style:{fontWeight:700,justifySelf:"start"},children:n.method}),a.jsxs("div",{style:{minWidth:0},children:[a.jsx("div",{style:{wordBreak:"break-all"},children:n.relativeUrl}),a.jsx("div",{style:{marginTop:4,color:P.colorNeutralForeground3},children:JSON.stringify(n.body)})]})]},n.targetId)),d.length===0&&a.jsx(De,{style:{color:P.colorNeutralForeground3,fontStyle:"italic",padding:"12px 4px",textAlign:"center",display:"block"},children:"No requests queued — pick at least one target on the Related pane."})]})]})}function z(d){switch(d){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}export{_e as AssociateMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as j,u as I,t as e,a9 as k,bR as v,a5 as E,bj as L,b3 as K,Y as r,bl as p,Z as b,r as P,b5 as U,B as S,D as O,aD as B,c0 as G,bK as H,O as V,aP as J,a$ as Y,b4 as Z,aB as _,J as Q}from"./index-DGsVifiB.js";function ne({table:t,value:s,onChange:n,group:o="relate",forOperation:u,footer:y}){const g=j(t)?.navigationProperties??[],d=g.find(i=>i.name===s);return I(d?.targetEntity??null),e.jsxs("div",{children:[e.jsx(k,{icon:v,title:"Navigation property",sub:"Cardinality is detected from metadata — the URL bar verb + shape adapt automatically.",group:o}),e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(E,{label:"Navigation property",children:e.jsx(L,{value:d?.name??"",selectedOptions:d?[d.name]:[],onOptionSelect:(i,x)=>n(x.optionValue??null),placeholder:"Pick a navigation property…",children:g.map(i=>e.jsx(K,{value:i.name,text:i.name,children:e.jsx(X,{nav:i,forOperation:u})},i.name))})}),d&&e.jsx("div",{style:{marginTop:16},children:e.jsx(ee,{nav:d,forOperation:u})}),y&&e.jsx("div",{style:{marginTop:14},children:y})]})]})}function X({nav:t,forOperation:s}){const n=j(t.targetEntity),o=R(t,s);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:r.fontFamilyMonospace,fontWeight:600},children:t.name}),e.jsx(p,{appearance:"ghost",size:"extra-small",children:M(t.cardinality)}),e.jsx(p,{appearance:"tint",color:"brand",size:"extra-small",style:{marginLeft:"auto"},children:o})]}),e.jsxs(b,{style:{color:r.colorNeutralForeground3},children:["→ ",n?.displayName??t.targetEntity," · ",te(t.cardinality)]})]})}function ee({nav:t,forOperation:s}){const n=j(t.targetEntity),o=R(t,s),u=t.cardinality==="ManyToOne"?"single-valued":"collection-valued",y=o==="POST"?r.colorPaletteGreenForeground1:o==="PATCH"?r.colorPaletteDarkOrangeForeground1:r.colorPaletteRedForeground1;return e.jsxs("div",{style:{border:`1px solid ${r.colorNeutralStroke2}`,borderRadius:r.borderRadiusMedium,padding:12,background:r.colorNeutralBackground1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(v,{style:{width:18,height:18,color:r.colorBrandForeground1}}),e.jsx("strong",{style:{fontFamily:r.fontFamilyMonospace,fontSize:13},children:t.name}),e.jsx(p,{appearance:"tint",color:"brand",children:M(t.cardinality)}),e.jsx("span",{style:{flexGrow:1}}),e.jsx(p,{appearance:"filled",style:{background:y,color:r.colorNeutralForegroundOnBrand,fontWeight:700},children:o})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",rowGap:4,fontSize:11},children:[e.jsx("span",{style:{color:r.colorNeutralForeground3},children:"Target entity"}),e.jsxs("span",{style:{fontFamily:r.fontFamilyMonospace},children:[n?.entitySetName??t.targetEntity," ",e.jsxs(b,{style:{color:r.colorNeutralForeground3},children:["· ",n?.displayName??t.targetEntity]})]}),e.jsx("span",{style:{color:r.colorNeutralForeground3},children:"Cardinality"}),e.jsxs("span",{children:[u," (",t.cardinality,")"]}),e.jsx("span",{style:{color:r.colorNeutralForeground3},children:"Relationship"}),e.jsx("span",{style:{fontFamily:r.fontFamilyMonospace,fontSize:10},children:t.relationshipName})]})]})}function M(t){switch(t){case"OneToMany":return"1:N";case"ManyToOne":return"N:1";case"ManyToMany":return"N:N"}}function te(t){return t==="ManyToOne"?"single-valued lookup":"collection-valued"}function R(t,s){return t.cardinality==="ManyToOne"?"PATCH":s==="disassociate"?"DELETE":"POST"}function ae({table:t,navProperty:s,targets:n,setTargets:o,targetNames:u,setTargetNames:y,group:N="relate",resolvedMethod:g}){const[d,i]=P.useState({}),x=u??d,F=y??i,C=U(),W=j(t),h=s?W?.navigationProperties.find(a=>a.name===s):void 0,m=h?j(h.targetEntity):void 0,l=h?.cardinality==="ManyToOne",w=l?1:1/0,[z,A]=P.useState(0);if(!h)return e.jsxs("div",{children:[e.jsx(k,{icon:v,title:"Target records",sub:"Pick a navigation property first.",group:N}),e.jsx(S,{layout:"multiline",intent:"info",style:{maxWidth:720},children:e.jsxs(O,{children:["Switch to the ",e.jsx("strong",{children:"Navigation property"})," pane and pick one — the target entity comes from there."]})})]});const T=n.length>=w,D=(a,c)=>{if(!a||n.includes(a)||T)return;const f=l?[a]:[...n,a];o(f),c&&F({...x,[a]:c}),A(q=>q+1)},$=a=>{if(o(n.filter(c=>c!==a)),x[a]!=null){const c={...x};delete c[a],F(c)}};return e.jsxs("div",{children:[e.jsxs(k,{icon:v,title:l?"Target record":"Target records",sub:e.jsx("span",{children:l?e.jsxs(e.Fragment,{children:["One target is allowed for ",e.jsx("code",{children:h.cardinality})," nav props — the server PUT 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(p,{appearance:"tint",color:n.length>0?"brand":"subtle",children:[n.length," target",n.length===1?"":"s"]}),g&&e.jsx(p,{appearance:"filled",color:g==="POST"?"success":"informative",style:{fontWeight:700},children:g}),!l&&n.length>1&&e.jsx(B,{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(p,{appearance:"ghost",icon:e.jsx(G,{style:{width:12,height:12}}),children:[n.length," requests queued"]})})]}),e.jsx("div",{className:Y(C.inlineCard),style:{padding:12,marginBottom:14,maxWidth:880},children:n.length===0?e.jsxs(b,{style:{padding:"12px 4px",color:r.colorNeutralForeground3,fontStyle:"italic",display:"block",textAlign:"center"},children:["No targets selected — use the picker below to choose"," ",l?"one":"one or more"," ",e.jsx("strong",{children:m?.displayName??h.targetEntity})," record",l?"":"s","."]}):e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n.map((a,c)=>{const f=x[a];return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 4px",borderBottom:c<n.length-1?`1px solid ${r.colorNeutralStroke3}`:"none"},children:[e.jsx(H,{size:"small",name:f??"?",avatar:{color:"colorful"}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600},children:f??e.jsx("span",{style:{fontStyle:"italic",color:r.colorNeutralForeground3},children:"(name not resolved)"})}),e.jsxs("div",{style:{fontFamily:r.fontFamilyMonospace,fontSize:10,color:r.colorNeutralForeground3},children:["/",m?.entitySetName??"?","(",a,")"]})]}),e.jsx(B,{content:"Remove target",relationship:"label",children:e.jsx(V,{size:"small",appearance:"subtle",icon:e.jsx(J,{}),onClick:()=>$(a),"aria-label":"Remove target"})})]},a)})})}),!T&&e.jsxs("div",{style:{maxWidth:560},children:[e.jsx(E,{label:l?"Pick target":"Add target",hint:l?`Pick a single ${m?.displayName??"record"} — the PUT sets this as the lookup value.`:`Each pick queues a separate POST. Currently ${n.length} target${n.length===1?"":"s"} queued.`,children:e.jsx(Z,{table:m?.logicalName??h.targetEntity,selectedId:null,onPick:a=>D(a?.id??null,a?.primary),placeholder:`Search ${m?.displayName??"record"}s…`},z)}),!l&&e.jsxs(b,{style:{display:"block",marginTop:6,color:r.colorNeutralForeground3},children:[e.jsx(_,{style:{width:12,height:12,verticalAlign:"middle"}})," picking a record adds it to the queue and resets the picker for the next pick."]})]}),T&&l&&e.jsx(S,{layout:"multiline",intent:"info",style:{maxWidth:720,marginTop:12},children:e.jsxs(O,{children:[e.jsx(Q,{children:"Single-valued nav property — one target only."}),"To change the target, remove the current one first. The server PUT atomically replaces the previous lookup value."]})})]})}export{ae as A,ne as N};
|