@mohsinonxrm/pptb-fetchxml-studio 1.2.2-beta.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  A powerful, modern FetchXML query builder and data explorer for [Power Platform ToolBox](https://github.com/PowerPlatformToolBox/desktop-app). Inspired by the XrmToolBox FetchXML Builder, reimagined with React 18, Fluent UI v9, and seamless Dataverse integration.
4
4
 
5
- ![Version](https://img.shields.io/badge/version-1.2.2--beta.1-orange)
5
+ ![Version](https://img.shields.io/badge/version-1.3.0-blue)
6
6
  ![React](https://img.shields.io/badge/React-18-61DAFB?logo=react)
7
7
  ![TypeScript](https://img.shields.io/badge/TypeScript-5.9-3178C6?logo=typescript)
8
8
  ![Fluent UI](https://img.shields.io/badge/Fluent%20UI-v9-0078D4?logo=microsoft)
9
- ![PPTB Types](https://img.shields.io/badge/%40pptb%2Ftypes-1.2.2--beta.1-orange)
9
+ ![PPTB Types](https://img.shields.io/badge/%40pptb%2Ftypes-1.2.0-orange)
10
10
 
11
11
  ## ✨ Features
12
12
 
@@ -53,6 +53,16 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
53
53
  - **Smart updates** — Adds new selections and removes deselected attributes while preserving existing order and properties
54
54
  - **Search & filter** — Real-time filtering across logical name, display name, and data type columns
55
55
 
56
+ ### 🔀 Code Generation
57
+ - **Code tab** — New tab in the right pane that generates ready-to-use code from the current query in seven formats
58
+ - **C# QueryExpression** — Full SDK object graph (`QueryExpression`, `ColumnSet`, `FilterExpression`, `ConditionExpression`, `LinkEntity`, `OrderExpression`) via the Dataverse `FetchXmlToQueryExpression` API; supports aggregate queries with `XrmAggregateType` and `XrmDateTimeGrouping`
59
+ - **C# FetchExpression** — Simple `new FetchExpression(@"...")` wrapper using a verbatim string literal
60
+ - **JavaScript** — `Xrm.WebApi.retrieveMultipleRecords` call for model-driven apps and PCF components
61
+ - **pac CLI** — `pac org fetch --xml "..."` command for the Power Platform CLI
62
+ - **Power Automate** — Field-by-field form mirroring the Dataverse "List rows" connector UI; table name resolved from `EntityDefinitions` metadata (not a heuristic), each field individually copyable
63
+ - **Web API** — Full OData URL with request headers, cURL snippet, and PowerShell `Invoke-RestMethod` example; entity set name resolved from metadata
64
+ - **SQL** — Dataverse-generated T-SQL via `FetchXMLToSQL` (undocumented API, labelled Preview)
65
+
56
66
  ### 🎨 User Experience
57
67
  - **Dark/Light themes** — Follows Power Platform ToolBox theme with Fluent UI tokens
58
68
  - **Lazy metadata loading** — Loads only what's needed, when it's needed
@@ -63,13 +73,8 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
63
73
  - **Query scope settings** — Control which entities appear in the entity picker: *Publisher + Solution* (full filter), *Solution Only*, or *All Entities* (no filter). Persisted across sessions.
64
74
  - **Advanced Find Only toggle** — When on (default), limits entities and attributes to those marked `IsValidForAdvancedFind = true`. Disable to access all entities including system and developer tables. Filter is applied locally — toggling is instant with no additional API call.
65
75
 
66
- ### � Tool-to-Tool (T2T) Integration
67
- - **Send to Tool button** — Launch any other PPTB tool directly from FetchXML Studio, pre-loading it with the current FetchXML query and active Dataverse connection. Appears automatically when running on PPTB host ≥ 1.2.2.
68
- - **Multi-tool picker** — Configure one or more target tools in Settings → Tool Integration. When multiple tools are configured, the button shows a dropdown menu.
69
- - **Active connection forwarding** — The active Dataverse connection is forwarded automatically so the target tool opens against the same environment.
70
- - **Inbound prefill** — FetchXML Studio also accepts incoming T2T invocations from other tools (see [Callee Contract](#-callee-contract-pptbconfigjson) below).
71
-
72
- ### �🔒 Privilege-Aware
76
+ ### 🔒 Privilege-Aware
77
+ - **Security checks** — Validates user privileges before every destructive or restricted operation
73
78
  - **Export privilege check** — Only shows Dataverse export option if user has access
74
79
  - **Delete privilege check** — Validates entity-specific delete permissions before enabling delete actions
75
80
  - **Bulk delete privilege check** — Validates `prvBulkDelete` before surfacing bulk delete
@@ -80,9 +85,9 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
80
85
 
81
86
  ```
82
87
  ┌─────────────────────────────────────────────────────────────────────────┐
83
- │ [Entity Selector ▼] [Load View ▼] [Save View] [Send to Tool ▼] [⚙] │
88
+ │ [Entity Selector ▼] [Load View ▼] [Save View] [⚙ Settings]│
84
89
  ├──────────────────────┬──────────────────────────────────────────────────┤
85
- │ │ [FetchXML] [LayoutXML] [Results] [▶ Execute]│
90
+ │ │ [FetchXML] [LayoutXML] [Results] [Code] [▶ Execute]│
86
91
  │ Query Tree ├──────────────────────────────────────────────────┤
87
92
  │ │ │
88
93
  │ 📁 fetch │ Results Grid / Monaco Editor │
@@ -174,7 +179,7 @@ disableAllDebug();
174
179
  | **Monaco Editor** | 0.54 | VS Code XML editor for FetchXML authoring |
175
180
  | **react-window** | 2 | Virtualized list rendering for large datasets |
176
181
  | **ExcelJS** | 4.4 | Native `.xlsx` generation with typed cells |
177
- | **@pptb/types** | 1.2.2-beta.1 | Power Platform ToolBox host API types (`window.dataverseAPI`, `window.toolboxAPI`) |
182
+ | **@pptb/types** | 1.2.0 | Power Platform ToolBox host API types (`window.dataverseAPI`, `window.toolboxAPI`) |
178
183
 
179
184
  ## 📁 Project Structure
180
185
 
@@ -187,8 +192,7 @@ src/
187
192
  │ │ ├── pptbClient.ts # window.dataverseAPI wrapper (all Dataverse ops)
188
193
  │ │ ├── dataverseMetadata.ts # Lazy metadata loading with cache + dedup
189
194
  │ │ ├── excelExport.ts # Local ExcelJS export with native types
190
- │ │ ├── formattedValues.ts # OData @FormattedValue annotation helpers
191
- │ │ └── invocation.ts # T2T caller API (isT2TSupported, sendFetchXmlToTool)
195
+ │ │ └── formattedValues.ts # OData @FormattedValue annotation helpers
192
196
  │ ├── model/
193
197
  │ │ ├── nodes.ts # FetchXML node TypeScript definitions
194
198
  │ │ ├── fetchxml.ts # FetchXML XML generation
@@ -198,6 +202,10 @@ src/
198
202
  │ │ ├── operators.ts # Operator definitions by attribute type
199
203
  │ │ ├── displaySettings.ts # Display settings types and defaults
200
204
  │ │ └── treeUtils.ts # Tree traversal utilities
205
+ │ ├── engine/
206
+ │ │ ├── queryExpressionTypes.ts # QE JSON schema interfaces (number | string enums)
207
+ │ │ ├── queryExpressionCodegen.ts # C# SDK code emitter (resolveEnum, unwrapODataValue)
208
+ │ │ └── fetchxmlCodeGenerators.ts # Sync generators: FetchExpr, JS, pac, PA, WebAPI
201
209
  │ ├── state/
202
210
  │ │ ├── builderStore.tsx # React context + reducer state management
203
211
  │ │ └── cache.ts # Per-session in-memory metadata cache
@@ -205,9 +213,9 @@ src/
205
213
  │ ├── LeftPane/ # Tree view + context-aware properties panel
206
214
  │ │ └── PropertiesPanel/
207
215
  │ │ └── editors/ # Node-specific property editors
208
- │ ├── RightPane/ # Monaco editor, LayoutXML viewer, results grid
209
- │ ├── Toolbar/ # Entity selector, load view picker, save button,
210
- │ │ # send-to-tool button
216
+ │ ├── RightPane/ # Monaco editor, LayoutXML viewer, results grid,
217
+ │ │ # code generation panel, Power Automate pane
218
+ │ ├── Toolbar/ # Entity selector, load view picker, save button
211
219
  │ ├── Dialogs/ # Save view, select attributes, delete, bulk
212
220
  │ │ # delete, workflow picker, solution picker
213
221
  │ └── Settings/ # Settings drawer (display preferences)
@@ -245,56 +253,6 @@ src/
245
253
  | Filter link-entity (any/all) | ✅ |
246
254
  | Query hints | ✅ |
247
255
 
248
- ## 🔗 Callee Contract (`pptb.config.json`)
249
-
250
- FetchXML Studio declares a PPTB [Inter-Tool Invocation](https://github.com/PowerPlatformToolBox/desktop-app) callee contract in `pptb.config.json` at the repository root. Any other PPTB tool can launch FetchXML Studio and pre-populate it by passing a prefill payload that matches the following schema:
251
-
252
- ```json
253
- {
254
- "fetchXml": "<fetch><entity name=\"account\">...</entity></fetch>",
255
- "entityLogicalName": "account"
256
- }
257
- ```
258
-
259
- | Field | Type | Required | Description |
260
- |---|---|---|---|
261
- | `fetchXml` | `string` | Recommended | Full serialized FetchXML query string |
262
- | `entityLogicalName` | `string` | Recommended | Root entity logical name (e.g. `"account"`) |
263
- | `viewRef` | `object` | Optional | EntityReference to an existing view. Use instead of `fetchXml` + `entityLogicalName` when launching from a view context. |
264
- | `viewRef.id` | `string` (uuid) | Required if viewRef | GUID of the view record |
265
- | `viewRef.entityLogicalName` | `"savedquery"` \| `"userquery"` | Required if viewRef | Dataverse entity logical name — `savedquery` = system/public view, `userquery` = personal view |
266
-
267
- All fields are optional in the schema; at runtime FetchXML Studio expects either `viewRef` **or** both `fetchXml` + `entityLogicalName` to be present.
268
-
269
- > **Note:** Callee-side behavior (consuming an inbound prefill on launch) is planned for a future release. The contract file and schema are declared now so other tools can reference them.
270
-
271
- ### Sending a query from another PPTB tool
272
-
273
- To launch FetchXML Studio from your own PPTB tool with a pre-loaded query:
274
-
275
- ```typescript
276
- await window.toolboxAPI.invocation.launchTool(
277
- "@mohsinonxrm/pptb-fetchxml-studio",
278
- {
279
- fetchXml: "<fetch><entity name=\"account\"><attribute name=\"name\"/></entity></fetch>",
280
- entityLogicalName: "account",
281
- },
282
- { primaryConnectionId: connection?.id ?? null },
283
- );
284
- ```
285
-
286
- ### Configuring outbound targets (Send to Tool)
287
-
288
- To send FetchXML Studio queries *to* another tool:
289
-
290
- 1. Open **Settings** (⚙ icon in the toolbar)
291
- 2. Scroll to **Tool Integration**
292
- 3. Enter the target tool's npm package ID (e.g. `@linked365/pptb-bulk-data-studio`) and click **Add**
293
-
294
- The "Send to Tool" button will appear in the toolbar. Multiple tools show a dropdown picker.
295
-
296
- ---
297
-
298
256
  ## 🤝 Contributing
299
257
 
300
258
  Contributions are welcome! Please feel free to submit a Pull Request.