@mohsinonxrm/pptb-fetchxml-studio 1.2.2-beta.1 → 1.2.2-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 CHANGED
@@ -5,6 +5,31 @@ 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
+ ## [1.2.2-beta.2] - 2026-06-16
11
+
12
+ ### ✨ Added
13
+
14
+ #### Tool-to-Tool (T2T) Invocation — Callee (prefill + return)
15
+
16
+ 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.
17
+
18
+ - **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.
19
+ - **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`.
20
+ - **`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.
21
+
22
+ ### 🏗️ Technical
23
+
24
+ - `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.
25
+ - `src/shared/hooks/useLaunchContext.ts` — New hook. Calls `getLaunchContext()` once on mount and exposes `{ loading, isCallee, context }` so detection happens in one place.
26
+ - `src/app/AppShell.tsx` — Consumes the prefill exactly once on launch (loads incoming FetchXML via `builder.loadFetchXml`), and passes `isCallee` to `PreviewTabs`.
27
+ - `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.
28
+
29
+ ### 🔧 Changed
30
+
31
+ - **"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.
32
+
8
33
  ## [1.2.2-beta.1] - 2026-05-25
9
34
 
10
35
  ### ✨ Added
package/README.md CHANGED
@@ -247,40 +247,48 @@ 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
294
  ### Configuring outbound targets (Send to Tool)