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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,294 @@
1
+ # Changelog
2
+
3
+ All notable changes to FetchXML Studio will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.2.2-beta.1] - 2026-05-25
9
+
10
+ ### ✨ Added
11
+
12
+ #### Tool-to-Tool (T2T) Invocation — Caller
13
+
14
+ FetchXML Studio can now send the active query to any other PPTB tool that accepts a FetchXML prefill payload. Requires **PPTB host ≥ 1.2.2**.
15
+
16
+ - **Send to Tool button** — A new "Send to Tool" button appears in the toolbar (alongside Save View) whenever the PPTB host exposes the `toolboxAPI.invocation` API. Three interaction modes depending on how many target tools are configured:
17
+ - *No tools configured* — Button is disabled with a tooltip pointing to Settings → Tool Integration.
18
+ - *One tool configured* — Single button; click launches the tool directly.
19
+ - *Multiple tools configured* — Dropdown menu listing all configured tools; click an item to launch.
20
+ - **Settings → Tool Integration section** — New section in the Settings drawer to manage the list of target tool npm package IDs (e.g. `@linked365/pptb-bulk-data-studio`). Supports add (text input + Enter/Add button) and remove (× button per item). The list is persisted via `toolboxAPI.settings` alongside other display preferences.
21
+ - **Active connection forwarding** — The caller automatically retrieves the currently active Dataverse connection and forwards its ID as `primaryConnectionId` when launching the target tool, so the callee opens against the same environment.
22
+ - **`pptb.config.json`** — Added PPTB callee contract file at the repository root. Declares the prefill schema this tool accepts when *receiving* a T2T invocation from another tool (see [Callee Contract](#-callee-contract-pptbconfigjson) in the README). `viewRef` is modelled as a Dataverse EntityReference: required fields `id` (UUID string) and `entityLogicalName` (enum: `"savedquery"` | `"userquery"`).
23
+
24
+ ### 🏗️ Technical
25
+
26
+ - `src/features/fetchxml/api/invocation.ts` — New module. Defines a local `InvocationAPI` interface (mirrors the PPTB host API not yet in `@pptb/types`) and exposes `isT2TSupported()` and `sendFetchXmlToTool(targetToolId, { fetchXml, entityLogicalName })`.
27
+ - `src/features/fetchxml/ui/Toolbar/SendToToolButton.tsx` — New toolbar component. Handles the disabled / single / multi-tool rendering variants; calls `sendFetchXmlToTool`; surfaces errors via `toolboxAPI.utils.showNotification`.
28
+ - `src/features/fetchxml/model/displaySettings.ts` — Added `targetTools: string[]` (default `[]`) to `DisplaySettings` interface and `defaultDisplaySettings`.
29
+ - `src/features/fetchxml/ui/Settings/SettingsDrawer.tsx` — Added Tool Integration section with add/remove UI. Added `Input`, `Field`, `Add20Regular`, `Dismiss16Regular`, `PlugConnected20Regular` to imports.
30
+ - `src/features/fetchxml/ui/RightPane/PreviewTabs.tsx` — Added `sendToToolButton?: ReactNode` prop; rendered unconditionally (all tabs) next to `saveViewButton`.
31
+ - `src/app/AppShell.tsx` — Imports `SendToToolButton` + `isT2TSupported`; passes `sendToToolButton` prop to `PreviewTabs` gated on `isT2TSupported()`.
32
+ - `package.json` — `features.minAPI` bumped from `1.2.0` → `1.2.2` to reflect the new PPTB host requirement. `scheduler` added to `devDependencies` (required peer dep of `@fluentui/react-context-selector` that was missing from the install tree).
33
+
34
+ #### Packaging fixes (resolves #33)
35
+
36
+ - **`icon` path corrected** — `"icon"` field in `package.json` was missing the `icons/` directory prefix (`"icon-insider.svg"` → `"icons/icon-insider.svg"`). Icon was not resolvable by PPTB at install time.
37
+ - **`files` array expanded** — Added `"icons"`, `"index.html"`, `"LICENSE"`, `"README.md"`, `"CHANGELOG.md"`, `"SECURITY.md"` alongside the existing `"dist"` and `"npm-shrinkwrap.json"` entries. Previously the `icons/` folder (referenced by the `"icon"` field) and all root-level docs were absent from the published package.
38
+ - **Production source maps disabled** — Added `sourcemap: false` to `vite.config.ts` `build` options. Monaco worker source maps were silently adding ~17 MB to the package; disabling them brings the published size down to ~3–4 MB.
39
+
40
+ ---
41
+
42
+ ## [1.2.1] - 2026-04-07
43
+
44
+ ### ✨ Added
45
+
46
+ - **Copy button in editor mode** — The FetchXML editor toolbar now includes a Copy button when in editor mode, making it consistent with the read-only toolbar. Previously Copy was only available when the editor was not in edit mode.
47
+
48
+ ### 🔧 Fixed
49
+
50
+ - **Results grid column overlap** — Column widths are now estimated dynamically from header text (capped at 400 px) so adjacent columns no longer overlap on first render. All cells use `TableCellLayout truncate` for clean overflow.
51
+ - **Results grid header/row misalignment** — Removed a stray CSS class from `DataGridBody` that was causing header and row widths to drift out of sync when the grid had overflowing content.
52
+ - **Alias validation in property editors** — Typing an invalid alias character (space, hyphen, special character) in `AttributeEditor` or `LinkEntityEditor` now sanitizes the value in real time: invalid characters are stripped, and a leading digit is prefixed with `_`.
53
+ - **Alias validation in parser** — When parsing FetchXML (both *Parse to Tree* and *Execute*), invalid aliases are now automatically sanitized. A parse warning describes the correction (e.g. *"Alias 'this is id' had invalid characters and was corrected to 'thisisid'."*) instead of silently forwarding the invalid alias to Dataverse where it would cause an API error.
54
+ - **Execute blocked when alias warnings are present** — Clicking Execute in editor mode now validates the XML completely before sending it to Dataverse. If parse warnings exist (e.g. an invalid alias that wasn't auto-corrected via *Parse to Tree*), execution is blocked and the warning is surfaced in a message bar above the editor with a hint to use *Parse to Tree* to auto-correct. Previously the bad alias was silently sent to Dataverse and the error appeared in the Results tab.
55
+ - **Editor state preserved across tab switches** — Switching from the FetchXML tab to Results or LayoutXML and back no longer resets editor mode or discards the edited XML. The editor component is now always mounted (hidden via `display: none` when not active) so Monaco state — editor mode toggle, cursor position, edit buffer — is fully preserved.
56
+ - **Validate contradictory messages** — *Validate* no longer shows both a "Valid" success message and warnings simultaneously. When warnings are present, validate now shows each warning plus an "Action required" notice and stops — the "Valid" success message is only shown when there are zero warnings.
57
+ - **Parse to Tree corrections shown as informational** — Auto-corrected alias warnings from *Parse to Tree* are now shown with `intent="info"` (blue) rather than `intent="warning"` (yellow), correctly communicating that the tool has already resolved the problem.
58
+ - **Execute API errors surfaced** — Dataverse API errors that occur during query execution are now captured and displayed in a message bar in the Results tab. Previously they were only visible in the browser console.
59
+
60
+ ### 🏗️ Technical
61
+
62
+ - Added `src/features/fetchxml/model/aliasUtils.ts` — `isValidAlias()` and `sanitizeAlias()` shared utilities enforcing the Dataverse alias constraint (`[A-Za-z_][A-Za-z0-9_]*`).
63
+ - `fetchxmlParser.ts` — `parseAttribute` and `parseLinkEntity` now import `sanitizeAlias`; invalid aliases are corrected in place and described in the parse warning rather than propagated as-is.
64
+ - `PreviewTabs.tsx` — `FetchXmlEditor` is always mounted; `handleExecute` blocks on parse warnings; navigating back to the FetchXML tab clears any stale editor validation error banner.
65
+ - `AppShell.tsx` — `handleExecute` accepts an optional `xmlOverride` (used when editor mode is active); `executeError` state threads Dataverse API errors back to the `PreviewTabs` message bar.
66
+
67
+ ---
68
+
69
+ ## [1.2.0] - 2026-04-03
70
+
71
+ ### ✨ Added
72
+
73
+ #### Query Scope Settings
74
+ - **Entity Scope Mode** — New setting (persisted across sessions) to control which entities appear in the entity dropdown:
75
+ - **Publisher + Solution** — Select a publisher, then narrow to specific solutions; only entities belonging to those solutions are shown
76
+ - **Solution Only** — Skip the publisher step and pick solutions directly
77
+ - **All Entities** — Show every entity in the environment (no solution filter)
78
+ - **Advanced Find Only toggle** — When enabled (default), entities and attributes are limited to those marked `IsValidForAdvancedFind = true`, matching the classic Advanced Find behavior. Disabling shows all entities and attributes — including system and developer-only tables — useful for building admin or integration queries. The filter is applied locally so toggling is instant with no additional API call.
79
+ - Scope mode and Advanced Find preference are persisted individually via `toolboxAPI.settings` and survive across sessions.
80
+
81
+ #### Monaco Editor — Local Bundling
82
+ - Monaco is now fully bundled in `dist/` instead of being fetched from a CDN at runtime.
83
+ - Eliminates CSP errors and ensures line numbers, syntax highlighting, and all editor features work correctly in the PPTB host environment without network access to external CDNs.
84
+
85
+ ### 🔧 Fixed
86
+
87
+ - **Internal solutions in Solution-only mode** — Solutions from `isreadonly = true` publishers (Microsoft, system publishers) are now excluded from the solution picker, consistent with what Publisher + Solution mode shows. Previously some Microsoft-owned visible solutions appeared in the list.
88
+ - **Parse-to-tree no longer resets the entity** — Pasting FetchXML into the editor and clicking "Parse to Tree" no longer wipes the selected entity. The validation that auto-clears the entity selection now only fires when there is an active solution filter in place (i.e. specific solutions have been selected) and the entity has dropped out of scope — not when the entity was set programmatically via the XML editor.
89
+ - **Entity list cache race condition** — `loadAllEntities` no longer accepts an `advancedFindOnly` parameter. It always fetches all entities from the server (no `$filter=IsValidForAdvancedFind eq true`). The Advanced Find filter is now applied locally in the EntitySelector `memo`. This eliminates a bug where an earlier `advancedFindOnly=true` load could poison the cache and cause subsequent `advancedFindOnly=false` calls to silently return the wrong (filtered) set.
90
+ - **Privilege check console noise** — `checkPrivilegeByName` errors for privileges that don't exist in the environment (e.g. `prvDeleteGitorganization` for system tables) are now logged as `console.warn` instead of `console.error`. The UI behavior is unchanged.
91
+ - **CSP exception** — Removed the invalid `*.crm*.dynamics.com` wildcard from `cspExceptions` (browsers reject multi-depth subdomain wildcards). The only `connect-src` exception kept is `https://*.dynamics.com`.
92
+
93
+ ### 🏗️ Technical
94
+
95
+ - `useAccessMode` preloads only the AF-valid entity metadata cache (`allEntityMetadataCache`) on startup — used by publisher-solution and solution-only modes. The all-entities cache is populated lazily the first time "All Entities" scope mode is used.
96
+ - `loadAllEntities` / `useLazyMetadata.loadEntities` signatures simplified (no `advancedFindOnly` param — always fetches everything).
97
+ - `vite.config.ts` — `manualChunks` splits Monaco into its own chunk (`monaco-editor-*.js`, ~3.7 MB; `monaco-editor-*.css`, ~145 kB).
98
+ - TypeScript strict compile: **zero errors** (`tsc -b --noEmit`).
99
+
100
+ ---
101
+
102
+ ## [1.1.0] - 2026-03-23
103
+
104
+ ### ⬆️ Upgraded
105
+
106
+ - **`@pptb/types` 1.0.7 → 1.2.0** — now the authoritative source for all PPTB host API types (`window.dataverseAPI`, `window.toolboxAPI`). Added to `tsconfig.app.json` `types` array so global augmentations apply project-wide without per-file triple-slash references.
107
+ - **`features.minAPI`** set to `"1.2.0"` in `package.json` to enforce the correct PPTB host version at install time.
108
+
109
+ ### ✨ Added
110
+
111
+ #### Native File Save Dialog
112
+ - Both export paths (local ExcelJS export and Dataverse `ExportToExcel` action) now use `window.toolboxAPI.fileSystem.saveFile` when running inside the PPTB desktop host, presenting a native OS save-file dialog instead of a forced browser blob download.
113
+ - Graceful fallback to browser blob/anchor download when running in standalone or dev context (i.e. when `window.toolboxAPI` is not available).
114
+
115
+ #### Connection Environment Awareness
116
+ - `PptbContext` now exposes `environment?: "Dev" | "Test" | "UAT" | "Production"` sourced from the active `DataverseConnection`.
117
+ - Subscribes to `connection:updated`, `connection:created`, and `connection:deleted` PPTB events to keep the field in sync dynamically.
118
+
119
+ #### Package Manifest Hardening
120
+ - Added top-level `"icon"` field pointing to `icons/icon.svg` (replacing deprecated `configurations.iconUrl`).
121
+ - `"features"` block added: `{ "multiConnection": "none", "minAPI": "1.2.0" }`.
122
+ - `cspExceptions` migrated from plain-string arrays to the required object format with `domain` + `exceptionReason` fields (+ `optional: true` on style-src).
123
+ - Added `"validate": "pptb-validate"` npm script for pre-publish manifest validation.
124
+ - Added `"finalize-package": "npm run build && npm shrinkwrap"` convenience script.
125
+
126
+ ### ♻️ Refactored
127
+
128
+ #### `pptbClient.ts`
129
+ - Removed the entire hand-written `declare global { interface Window { dataverseAPI?: { ... } } }` block (~60 lines). The `window.dataverseAPI` global is now typed entirely by `@pptb/types`.
130
+ - Added local `DataverseFetchXmlResponse` interface to capture OData response annotations beyond what `@pptb/types` `FetchXmlResult` declares (`@Microsoft.Dynamics.CRM.totalrecordcount`, `morerecords`, `pagingcookie`, `totalrecordcountlimitexceeded`). These are OData wire annotations returned directly by Dataverse — not fabricated by PPTB — so the cast is safe at runtime.
131
+ - `downloadBase64File()` changed from `void` to `async Promise<void>`; uses `fileSystem.saveFile` when available.
132
+
133
+ #### `usePptbContext.ts`
134
+ - Removed the entire hand-written `declare global { interface Window { toolboxAPI?: { ... } } }` block. The `window.toolboxAPI` global is now typed entirely by `@pptb/types`.
135
+ - `PptbContext` interface: removed legacy `organizationId?: string` (not present in `DataverseConnection` v1.2.0 types); replaced with `environment?: "Dev" | "Test" | "UAT" | "Production"`.
136
+
137
+ #### `excelExport.ts`
138
+ - `downloadExcelFile()` changed from `void` to `async Promise<void>`; uses `fileSystem.saveFile` when available.
139
+
140
+ #### `AppShell.tsx`
141
+ - Both download call sites updated with `await` to match the new async signatures.
142
+
143
+ ### 🔧 Technical
144
+
145
+ - TypeScript strict compile: **zero errors** (`tsc -b --noEmit`).
146
+ - `pptb-validate`: **✔ Validation passed**.
147
+
148
+ ---
149
+
150
+ ## [1.0.6] - 2026-01-14
151
+
152
+ ### ✨ Added
153
+
154
+ #### Select Attributes Dialog (#12)
155
+ - **Bulk Attribute Selection**: New "Select Attributes" modal dialog for efficient multi-attribute selection
156
+ - Accessible from entity and link-entity context menus in the tree view
157
+ - Works on root entity, link-entities, and nested link-entities at any level
158
+ - **Smart Selection Grid**: DataGrid showing all available entity attributes
159
+ - Three sortable columns: Logical Name, Display Name, and Data Type
160
+ - Pre-selects currently selected attributes with checkboxes
161
+ - Multi-select support for bulk add/remove operations
162
+ - **Search & Filter**: Integrated SearchBox for quick attribute filtering
163
+ - Filters across all columns (logical name, display name, data type)
164
+ - Real-time filtering as you type
165
+ - **Fixed Headers**: Column headers remain visible while scrolling through attributes
166
+ - **Confirmation Required**: Changes only applied when user clicks Apply button
167
+ - Cancel button discards changes without affecting the tree
168
+ - **Smart Updates**: Intelligently adds new attributes and removes deselected ones
169
+ - Preserves existing attributes that remain selected
170
+ - Maintains attribute order and properties
171
+ - **Performance**: Leverages metadata cache for fast attribute loading
172
+ - Falls back to API loading if attributes not cached
173
+ - Shows only attributes valid for Advanced Find
174
+
175
+ ### 🔧 Technical
176
+
177
+ - Added `SelectAttributesDialog` component with FluentUI DataGrid
178
+ - New `UPDATE_ATTRIBUTES` action in builderStore for bulk attribute operations
179
+ - Enhanced TreeView with dialog state management and attribute loading
180
+ - Integrated with existing metadata caching system
181
+
182
+ ## [1.0.0] - 2024-12-15
183
+
184
+ ### 🎉 Initial Release
185
+
186
+ FetchXML Studio v1.0.0 - A powerful FetchXML query builder for Power Platform ToolBox.
187
+
188
+ ### ✨ Features
189
+
190
+ #### Query Builder
191
+ - Tree-based visual query builder with hierarchical FetchXML structure
192
+ - Full entity, attribute, filter, order, and link-entity support
193
+ - Context-aware properties panel for each node type
194
+ - Nested filter groups with AND/OR logic
195
+ - Support for all FetchXML operators (60+ operators)
196
+ - Aggregate queries with groupby and distinct
197
+ - Query hints for performance optimization
198
+
199
+ #### Relationships & Joins
200
+ - Relationship picker with 1:N, N:1, N:N categorization
201
+ - Inner and outer join support
202
+ - Filter link-entity for any/all/not any/not all scenarios
203
+ - Value-of conditions for cross-entity comparisons
204
+ - Entity name conditions for outer join filtering
205
+
206
+ #### Results Grid
207
+ - Virtualized DataGrid for large datasets (react-window)
208
+ - Rich cell rendering for lookups, option sets, dates, currency
209
+ - Multi-column sorting (click + Shift+click)
210
+ - Row selection (single and multi-select)
211
+ - Resizable and reorderable columns
212
+ - Formatted values with raw value toggle
213
+
214
+ #### FetchXML Editor
215
+ - Monaco editor with XML syntax highlighting
216
+ - Bi-directional editing (visual ↔ XML)
217
+ - Parse FetchXML to visual builder
218
+ - Copy to clipboard
219
+ - LayoutXML preview tab
220
+
221
+ #### Views
222
+ - Load system and personal views
223
+ - Optimized view execution via SavedQuery/UserQuery APIs
224
+ - Save queries as personal views
225
+ - Update existing views
226
+ - Solution-aware save (add to solution)
227
+
228
+ #### Data Operations
229
+ - Export to Excel with native data types
230
+ - Delete selected records
231
+ - Bulk delete jobs (async)
232
+ - Run on-demand workflows on selection
233
+ - Batch progress tracking with ETA
234
+
235
+ #### User Experience
236
+ - Dark/Light theme support (follows PPTB theme)
237
+ - Lazy metadata loading
238
+ - Intelligent caching (per-session)
239
+ - Resizable split panes
240
+ - Keyboard shortcuts (Ctrl+Enter to execute)
241
+
242
+ #### Security
243
+ - Privilege-aware operations
244
+ - Export/Delete privilege checks
245
+ - Bulk delete privilege validation
246
+ - Workflow execution privilege checks
247
+
248
+ ### 🏗️ Technical
249
+
250
+ - Built with React 19 and TypeScript 5.9
251
+ - Fluent UI v9 components
252
+ - Monaco Editor integration
253
+ - ExcelJS for native Excel export
254
+ - Vite build tooling
255
+ - Power Platform ToolBox integration via @pptb/types
256
+
257
+ ### 📚 Documentation
258
+
259
+ - Comprehensive README with feature overview
260
+ - Debug logging system documentation
261
+ - Project structure guide
262
+ - Contributing guidelines
263
+
264
+ ---
265
+
266
+ ## Development History
267
+
268
+ ### Pre-release commits (dev branch)
269
+
270
+ - `feat: Beta release enhancements - Settings, Export, and UX improvements`
271
+ - `feat(preview): add LayoutXML tab to preview pane`
272
+ - `feat(commands): add record action commands - delete, bulk delete, workflow`
273
+ - `feat(columns): Add/Edit Columns panels with related entity support`
274
+ - `feat(export): add Export to Excel with status feedback and privilege check`
275
+ - `feat(paging): fix paging with cookies and page size support`
276
+ - `feat(grid): multi-entity metadata & column display name fixes`
277
+ - `feat(builder): Sprint 1 - Foundation & Layout improvements`
278
+ - `feat(save): implement Save View functionality`
279
+ - `feat(sort): Add multi-column sort with FetchXML integration`
280
+ - `feat(results): Add Column from Results Grid`
281
+ - `feat(views): Load view LayoutXML for column configuration`
282
+ - `feat(layout): Add column resize and reorder`
283
+ - `feat(layout): Add LayoutXML foundation`
284
+ - `feat(filter): Add filter link-entity support for any/not any/all scenarios`
285
+ - `feat(condition): Add valueof cross-entity comparison`
286
+ - `feat(condition): Add valueof same-row column comparison`
287
+ - `feat(condition): Add entityname support for outer join filtering`
288
+ - `feat(views): Add Load View picker and optimized view execution`
289
+ - `feat(parser): Add FetchXML parser with Monaco editor dialog`
290
+ - `feat: Implement Phases 1-4 - DataGrid UI polish`
291
+ - `feat: add filter consistency, cascading validation, and global metadata caching`
292
+ - `feat(entity-selector): implement advanced filtering with publisher/solution multiselect`
293
+ - `feat(ui): add resizable panes with visual grip indicators and command bar`
294
+ - `Initial commit - setup main branch`
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.1-blue)
5
+ ![Version](https://img.shields.io/badge/version-1.2.2--beta.1-orange)
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.0-orange)
9
+ ![PPTB Types](https://img.shields.io/badge/%40pptb%2Ftypes-1.2.2--beta.1-orange)
10
10
 
11
11
  ## ✨ Features
12
12
 
@@ -63,8 +63,13 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
63
63
  - **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
64
  - **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
65
 
66
- ### 🔒 Privilege-Aware
67
- - **Security checks** — Validates user privileges before every destructive or restricted operation
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
68
73
  - **Export privilege check** — Only shows Dataverse export option if user has access
69
74
  - **Delete privilege check** — Validates entity-specific delete permissions before enabling delete actions
70
75
  - **Bulk delete privilege check** — Validates `prvBulkDelete` before surfacing bulk delete
@@ -75,7 +80,7 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
75
80
 
76
81
  ```
77
82
  ┌─────────────────────────────────────────────────────────────────────────┐
78
- │ [Entity Selector ▼] [Load View ▼] [Save View] [⚙ Settings]│
83
+ │ [Entity Selector ▼] [Load View ▼] [Save View] [Send to Tool ▼] [⚙] │
79
84
  ├──────────────────────┬──────────────────────────────────────────────────┤
80
85
  │ │ [FetchXML] [LayoutXML] [Results] [▶ Execute]│
81
86
  │ Query Tree ├──────────────────────────────────────────────────┤
@@ -169,7 +174,7 @@ disableAllDebug();
169
174
  | **Monaco Editor** | 0.54 | VS Code XML editor for FetchXML authoring |
170
175
  | **react-window** | 2 | Virtualized list rendering for large datasets |
171
176
  | **ExcelJS** | 4.4 | Native `.xlsx` generation with typed cells |
172
- | **@pptb/types** | 1.2.0 | Power Platform ToolBox host API types (`window.dataverseAPI`, `window.toolboxAPI`) |
177
+ | **@pptb/types** | 1.2.2-beta.1 | Power Platform ToolBox host API types (`window.dataverseAPI`, `window.toolboxAPI`) |
173
178
 
174
179
  ## 📁 Project Structure
175
180
 
@@ -182,7 +187,8 @@ src/
182
187
  │ │ ├── pptbClient.ts # window.dataverseAPI wrapper (all Dataverse ops)
183
188
  │ │ ├── dataverseMetadata.ts # Lazy metadata loading with cache + dedup
184
189
  │ │ ├── excelExport.ts # Local ExcelJS export with native types
185
- │ │ └── formattedValues.ts # OData @FormattedValue annotation helpers
190
+ │ │ ├── formattedValues.ts # OData @FormattedValue annotation helpers
191
+ │ │ └── invocation.ts # T2T caller API (isT2TSupported, sendFetchXmlToTool)
186
192
  │ ├── model/
187
193
  │ │ ├── nodes.ts # FetchXML node TypeScript definitions
188
194
  │ │ ├── fetchxml.ts # FetchXML XML generation
@@ -200,7 +206,8 @@ src/
200
206
  │ │ └── PropertiesPanel/
201
207
  │ │ └── editors/ # Node-specific property editors
202
208
  │ ├── RightPane/ # Monaco editor, LayoutXML viewer, results grid
203
- │ ├── Toolbar/ # Entity selector, load view picker, save button
209
+ │ ├── Toolbar/ # Entity selector, load view picker, save button,
210
+ │ │ # send-to-tool button
204
211
  │ ├── Dialogs/ # Save view, select attributes, delete, bulk
205
212
  │ │ # delete, workflow picker, solution picker
206
213
  │ └── Settings/ # Settings drawer (display preferences)
@@ -238,6 +245,56 @@ src/
238
245
  | Filter link-entity (any/all) | ✅ |
239
246
  | Query hints | ✅ |
240
247
 
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
+
241
298
  ## 🤝 Contributing
242
299
 
243
300
  Contributions are welcome! Please feel free to submit a Pull Request.
package/SECURITY.md ADDED
@@ -0,0 +1,13 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please do **not** open a public issue.
6
+ Use GitHub Security Advisories: <https://github.com/mohsinonxrm/pptb-mxrm-fetchxml-studio/security/advisories/new>
7
+
8
+ ## Scope
9
+
10
+ - Authentication flows
11
+ - Token handling
12
+ - Dataverse request logging
13
+ - Dependency vulnerabilities