@mohsinonxrm/pptb-fetchxml-studio 1.2.2-beta.1 → 1.2.3-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 CHANGED
@@ -5,6 +5,54 @@ All notable changes to FetchXML Studio will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### ✨ Added
11
+
12
+ #### Tool-to-Tool (T2T) — capability-based tool discovery
13
+
14
+ The "Send to Tool" target list is now populated automatically via the PPTB capability registry instead of a manually maintained list. Requires **`@pptb/types` ≥ 1.2.3-beta.0** and a host that exposes capability discovery.
15
+
16
+ - **Automatic discovery** — FetchXML Studio calls `toolboxAPI.invocation.findToolsByCapability("fetchxml")` to find installed tools that declare the `fetchxml` capability, excludes itself, and lists them in the Send to Tool button (single button for one match, dropdown for several). Hidden when no matches or when the host lacks discovery — feature-detected at runtime, so older hosts degrade gracefully.
17
+ - **One-way send** — Launches now pass `noReturn: true`, the dedicated flag for the "Send To" pattern, which suppresses the callee's "Return to [Caller]" banner since FXS isn't waiting for data back.
18
+
19
+ ### 🔧 Changed
20
+
21
+ - **Removed the manual "Tool Integration" settings.** The Settings → Tool Integration section and the `targetTools` display setting are gone; discovery replaces them entirely.
22
+
23
+ ### 🏗️ Technical
24
+
25
+ - Bumped `@pptb/types` `1.2.2-beta.1` → `1.2.3-beta.0`, which now types `invocation.findToolsByCapability` / `getKnownCapabilityTags`, the `capabilities` field on `InvocationConfig`, the `CapabilityTag`/`KnownCapabilityTag` types, and `launchTool`'s `noReturn` option. Removed the local `InvocationAPI` interface in `invocation.ts` in favor of the now-published host types.
26
+ - `src/features/fetchxml/api/invocation.ts` — Added `DiscoveredTool` + `discoverFetchXmlTools()` (feature-detected; filters out our own id; defaults `name` to `id`); added `noReturn: true` to `sendFetchXmlToTool`.
27
+ - `src/shared/hooks/useSendToTools.ts` — New hook; discovers send targets once on mount.
28
+ - `src/app/AppShell.tsx` — Uses `useSendToTools`; Send to Tool slot now gated on `isT2TSupported() && sendToTools.length > 0`.
29
+ - `src/features/fetchxml/ui/Toolbar/SendToToolButton.tsx` — Prop changed from `targetTools: string[]` to `tools: DiscoveredTool[]`; labels use the discovered tool name.
30
+ - `src/features/fetchxml/ui/Settings/SettingsDrawer.tsx` — Removed the Tool Integration section, its handlers/state/styles, and now-unused imports.
31
+ - `src/features/fetchxml/model/displaySettings.ts` — Removed `targetTools` from `DisplaySettings` and the defaults.
32
+
33
+ ## [1.2.2-beta.2] - 2026-06-16
34
+
35
+ ### ✨ Added
36
+
37
+ #### Tool-to-Tool (T2T) Invocation — Callee (prefill + return)
38
+
39
+ FetchXML Studio can now be *launched by* another PPTB tool, pre-populated with an inbound query, and hand a query back. Completes the round-trip alongside the existing caller support.
40
+
41
+ - **Inbound prefill** — On launch via T2T, FetchXML Studio reads its launch context and pre-populates the builder. Resolution priority is `fetchXml` → `viewRef` → `entityLogicalName`: a `fetchXml` string is loaded directly; a `viewRef` has its FetchXML retrieved from the referenced `savedquery`/`userquery`; and a bare `entityLogicalName` starts a fresh query on that entity. When `fetchXml` is present the root entity is **derived from the FetchXML itself** and any `entityLogicalName` hint is ignored, because a mismatched value would break this metadata-driven tool's lookups.
42
+ - **Return FetchXML button** — When launched as a callee, a "Return FetchXML" button appears in the FetchXML toolbar. It returns `{ fetchXml }` (the current editor-or-tree query) to the caller via `returnData()`, which the host resolves as the caller's `launchTool(...)` result. This is intentionally separate from the host-injected "Return to [Caller]" banner, which only navigates back and resolves the caller's promise with `null`.
43
+ - **`pptb.config.json`** — Added the `fetchxml` capability tag (for discovery via `findToolsByCapability`) and a `returnTopic` describing the `{ fetchXml }` return shape. Relaxed the prefill contract so `entityLogicalName` is optional/hint-only.
44
+
45
+ ### 🏗️ Technical
46
+
47
+ - `src/features/fetchxml/api/invocation.ts` — Added callee helpers: `getLaunchContext()`, `resolveLaunchPrefill(context)` (returns a `{ kind: "fetchxml" | "entity" }` action following the `fetchXml` → `viewRef` → `entityLogicalName` priority; resolves `viewRef` by reusing the `dataverseAPI.queryData` view-read route filtered to a single record), `returnDataToInvokingTool(data)`, and `returnFetchXmlToInvokingTool(fetchXml)`. Added `FetchXmlStudioLaunchPrefill` type and `LaunchPrefillAction` union.
48
+ - `src/shared/hooks/useLaunchContext.ts` — New hook. Calls `getLaunchContext()` once on mount and exposes `{ loading, isCallee, context }` so detection happens in one place.
49
+ - `src/app/AppShell.tsx` — Consumes the prefill exactly once on launch (loads incoming FetchXML via `builder.loadFetchXml`), and passes `isCallee` to `PreviewTabs`.
50
+ - `src/features/fetchxml/ui/RightPane/PreviewTabs.tsx` — Added `isCallee?` prop and a `ReturnFetchXmlButton` (gated on `isCallee`) rendered next to Execute; uses a `getCurrentXml()` helper that returns the live editor buffer when in editor mode.
51
+
52
+ ### 🔧 Changed
53
+
54
+ - **"Send to Tool" button visibility** — The caller button is now hidden entirely unless at least one target tool is configured under Settings → Tool Integration (previously it rendered as a disabled button with a tooltip). The two T2T toolbar actions are now strictly capability-gated and never change meaning by mode: **Return FetchXML** shows only when launched as a callee (`isCallee`); **Send to Tool** shows only when targets are configured.
55
+
8
56
  ## [1.2.2-beta.1] - 2026-05-25
9
57
 
10
58
  ### ✨ Added
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.2.3--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.2--beta.1-orange)
9
+ ![PPTB Types](https://img.shields.io/badge/%40pptb%2Ftypes-1.2.3--beta.0-orange)
10
10
 
11
11
  ## ✨ Features
12
12
 
@@ -64,8 +64,8 @@ A powerful, modern FetchXML query builder and data explorer for [Power Platform
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
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.
67
+ - **Send to Tool button** — Launch another PPTB tool directly from FetchXML Studio, pre-loading it with the current FetchXML query and active Dataverse connection (one-way handoff).
68
+ - **Automatic tool discovery** — Targets are discovered via the PPTB capability registry — installed tools that declare the `fetchxml` capability. A single match shows one button; several show a dropdown picker. No configuration needed.
69
69
  - **Active connection forwarding** — The active Dataverse connection is forwarded automatically so the target tool opens against the same environment.
70
70
  - **Inbound prefill** — FetchXML Studio also accepts incoming T2T invocations from other tools (see [Callee Contract](#-callee-contract-pptbconfigjson) below).
71
71
 
@@ -247,51 +247,59 @@ src/
247
247
 
248
248
  ## 🔗 Callee Contract (`pptb.config.json`)
249
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:
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, and declares the `fetchxml` capability so callers can discover it. Any other PPTB tool can launch FetchXML Studio and pre-populate it by passing a prefill payload that matches the following schema:
251
251
 
252
252
  ```json
253
253
  {
254
- "fetchXml": "<fetch><entity name=\"account\">...</entity></fetch>",
255
- "entityLogicalName": "account"
254
+ "fetchXml": "<fetch><entity name=\"account\">...</entity></fetch>"
256
255
  }
257
256
  ```
258
257
 
259
258
  | Field | Type | Required | Description |
260
259
  |---|---|---|---|
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. |
260
+ | `fetchXml` | `string` | One of these three | Full serialized FetchXML query string. The root entity is parsed from this. |
261
+ | `viewRef` | `object` | One of these three | EntityReference to an existing view. The FetchXML is retrieved from the view record. |
262
+ | `entityLogicalName` | `string` | One of these three | Root entity logical name (e.g. `"account"`). Starts a fresh query on that entity. **Ignored when `fetchXml` is present** — the root entity is then derived from the FetchXML, since a mismatched value would break this metadata-driven tool's lookups. |
264
263
  | `viewRef.id` | `string` (uuid) | Required if viewRef | GUID of the view record |
265
264
  | `viewRef.entityLogicalName` | `"savedquery"` \| `"userquery"` | Required if viewRef | Dataverse entity logical name — `savedquery` = system/public view, `userquery` = personal view |
266
265
 
267
- All fields are optional in the schema; at runtime FetchXML Studio expects either `viewRef` **or** both `fetchXml` + `entityLogicalName` to be present.
266
+ Resolution priority at runtime: **`fetchXml` → `viewRef` → `entityLogicalName`**. With no prefill (a standalone launch) the tool opens empty.
268
267
 
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.
268
+ ### Returning a query to the caller
269
+
270
+ When FetchXML Studio is launched by another tool, a **Return FetchXML** button appears in the FetchXML toolbar. Clicking it returns the current query to the caller:
271
+
272
+ ```json
273
+ { "fetchXml": "<fetch>...</fetch>" }
274
+ ```
275
+
276
+ The caller receives this as the resolved value of `launchTool(...)`. This is distinct from the host-injected "Return to [Caller]" banner, which simply navigates back and resolves the caller's promise with `null` (no data).
270
277
 
271
278
  ### Sending a query from another PPTB tool
272
279
 
273
280
  To launch FetchXML Studio from your own PPTB tool with a pre-loaded query:
274
281
 
275
282
  ```typescript
276
- await window.toolboxAPI.invocation.launchTool(
283
+ const result = await window.toolboxAPI.invocation.launchTool(
277
284
  "@mohsinonxrm/pptb-fetchxml-studio",
278
- {
279
- fetchXml: "<fetch><entity name=\"account\"><attribute name=\"name\"/></entity></fetch>",
280
- entityLogicalName: "account",
281
- },
285
+ { fetchXml: "<fetch><entity name=\"account\"><attribute name=\"name\"/></entity></fetch>" },
282
286
  { primaryConnectionId: connection?.id ?? null },
283
287
  );
288
+
289
+ // If the user clicks "Return FetchXML", result is { fetchXml }.
290
+ // If they close the window or click the host's back banner, result is null.
291
+ const editedFetchXml = (result as { fetchXml?: string } | null)?.fetchXml;
284
292
  ```
285
293
 
286
- ### Configuring outbound targets (Send to Tool)
294
+ ### Sending a query to another tool (Send to Tool)
287
295
 
288
- To send FetchXML Studio queries *to* another tool:
296
+ FetchXML Studio discovers send targets automatically — no configuration needed. It calls the host capability registry (`toolboxAPI.invocation.findToolsByCapability("fetchxml")`) to find installed tools that declare the `fetchxml` capability in their own `pptb.config.json`, and lists them in a **Send to Tool** button (a single button for one match, a dropdown picker for several). The button is hidden when no other `fetchxml`-capable tools are installed, or on hosts that don't support capability discovery.
289
297
 
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**
298
+ The launch is one-way (`noReturn: true`) — FetchXML Studio hands the current query off and does not wait for data back. Any tool that wants to appear here only needs to declare:
293
299
 
294
- The "Send to Tool" button will appear in the toolbar. Multiple tools show a dropdown picker.
300
+ ```json
301
+ { "invocation": { "version": "1.0.0", "capabilities": ["fetchxml"], "prefill": { "properties": { "fetchXml": { "type": "string" } } } } }
302
+ ```
295
303
 
296
304
  ---
297
305