@pptb/types 1.2.4-beta.3 → 1.2.4-beta.5

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
@@ -8,7 +8,7 @@ TypeScript type definitions for Power Platform ToolBox APIs, plus a built-in CLI
8
8
  - [Quick start](#quick-start)
9
9
  - [CLI options](#cli-options)
10
10
  - [What is validated](#what-is-validated)
11
- - [pptb.config.json (optional)](#pptbconfigjson-optional)
11
+ - [pptb.config.json (optional)](#pptbconfigjson-optional)
12
12
  - [Overview](#overview)
13
13
  - [Usage](#usage)
14
14
  - [Include all type definitions](#include-all-type-definitions)
@@ -19,12 +19,22 @@ TypeScript type definitions for Power Platform ToolBox APIs, plus a built-in CLI
19
19
  - [Terminal Operations](#terminal-operations)
20
20
  - [Events](#events)
21
21
  - [Inter-Tool Invocation](#inter-tool-invocation)
22
+ - [Caller: launching another tool with prefill data](#caller-launching-another-tool-with-prefill-data)
23
+ - [Caller: tag-based capability discovery](#caller-tag-based-capability-discovery)
24
+ - [Callee: reading prefill data and returning a result](#callee-reading-prefill-data-and-returning-a-result)
25
+ - [Declaring your invocation contract](#declaring-your-invocation-contract)
22
26
  - [Dataverse API Examples](#dataverse-api-examples)
23
27
  - [CRUD Operations](#crud-operations)
24
28
  - [FetchXML Queries](#fetchxml-queries)
25
29
  - [Metadata Operations](#metadata-operations)
26
30
  - [Execute Actions/Functions](#execute-actionsfunctions)
27
31
  - [Deploy Solutions](#deploy-solutions)
32
+ - [Power Platform API Examples](#power-platform-api-examples)
33
+ - [Using Power Apps API](#using-power-apps-api)
34
+ - [Using Power Automate API](#using-power-automate-api)
35
+ - [Using Environment Management API](#using-environment-management-api)
36
+ - [Using Governance API](#using-governance-api)
37
+ - [Available Categories](#available-categories)
28
38
  - [API Reference](#api-reference)
29
39
  - [ToolBox API (`window.toolboxAPI`)](#toolbox-api-windowtoolboxapi)
30
40
  - [Connections](#connections-1)
@@ -37,6 +47,8 @@ TypeScript type definitions for Power Platform ToolBox APIs, plus a built-in CLI
37
47
  - [Query Operations](#query-operations)
38
48
  - [Metadata Operations](#metadata-operations-1)
39
49
  - [Advanced Operations](#advanced-operations)
50
+ - [Power Platform API (`window.powerplatformAPI`)](#power-platform-api-windowpowerplatformapi)
51
+ - [Category Methods](#category-methods)
40
52
  - [Security Notes](#security-notes)
41
53
  - [Publishing the package to npm](#publishing-the-package-to-npm)
42
54
  - [License](#license)
@@ -116,14 +128,14 @@ The validator checks every field that the official review pipeline inspects:
116
128
 
117
129
  In addition to `package.json`, the validator automatically checks a `pptb.config.json` file if one is present in the same directory. This file declares tool-to-tool communication contracts and other PPTB-specific metadata.
118
130
 
119
- | Field | Required | Rules |
120
- | --------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
121
- | `invocation.version` | ✅\*\* | Must be a valid **semantic version** string (e.g. `"1.0.0"`). Tool developers own this version and bump it when the invocation contract changes. |
122
- | `invocation.capabilities` | ❌ | Array of non-empty string tags (e.g. `["entity-picker"]`). Used by callers to discover this tool via `findToolsByCapability`. |
123
- | `invocation.prefill` | ❌ | JSON-schema-style object describing data callers can pre-populate |
124
- | `invocation.prefill.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
125
- | `invocation.returnTopic` | ❌ | JSON-schema-style object describing the data this tool returns to its caller |
126
- | `invocation.returnTopic.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
131
+ | Field | Required | Rules |
132
+ | ----------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
133
+ | `invocation.version` | ✅\*\* | Must be a valid **semantic version** string (e.g. `"1.0.0"`). Tool developers own this version and bump it when the invocation contract changes. |
134
+ | `invocation.capabilities` | ❌ | Array of non-empty string tags (e.g. `["entity-picker"]`). Used by callers to discover this tool via `findToolsByCapability`. |
135
+ | `invocation.prefill` | ❌ | JSON-schema-style object describing data callers can pre-populate |
136
+ | `invocation.prefill.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
137
+ | `invocation.returnTopic` | ❌ | JSON-schema-style object describing the data this tool returns to its caller |
138
+ | `invocation.returnTopic.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
127
139
 
128
140
  > \*\* Required only when the `invocation` object is present.
129
141
 
@@ -153,10 +165,11 @@ In addition to `package.json`, the validator automatically checks a `pptb.config
153
165
 
154
166
  ## Overview
155
167
 
156
- The `@pptb/types` package provides TypeScript definitions for two main APIs:
168
+ The `@pptb/types` package provides TypeScript definitions for three main APIs:
157
169
 
158
170
  1. **ToolBox API** (`window.toolboxAPI`) - Core platform features (connections, utilities, terminals, events)
159
171
  2. **Dataverse API** (`window.dataverseAPI`) - Microsoft Dataverse Web API operations
172
+ 3. **Power Platform API** (`window.powerplatformAPI`) - Power Platform Admin APIs with generic HTTP methods
160
173
 
161
174
  ## Usage
162
175
 
@@ -165,9 +178,10 @@ The `@pptb/types` package provides TypeScript definitions for two main APIs:
165
178
  ```typescript
166
179
  /// <reference types="@pptb/types" />
167
180
 
168
- // Both APIs are now available
181
+ // All APIs are now available
169
182
  const toolbox = window.toolboxAPI;
170
183
  const dataverse = window.dataverseAPI;
184
+ const powerplatform = window.powerplatformAPI;
171
185
  ```
172
186
 
173
187
  ### Include specific API types
@@ -178,6 +192,9 @@ const dataverse = window.dataverseAPI;
178
192
 
179
193
  // Only Dataverse API types
180
194
  /// <reference types="@pptb/types/dataverseAPI" />
195
+
196
+ // Only Power Platform API types
197
+ /// <reference types="@pptb/types/powerplatformAPI" />
181
198
  ```
182
199
 
183
200
  ## ToolBox API Examples
@@ -299,10 +316,7 @@ Tools can launch one another and pass data between them using the `invocation` n
299
316
  ```typescript
300
317
  // Tool A – launches the entity-picker tool and waits for a selection
301
318
  // The callee automatically inherits this tool's FXS connection
302
- const result = await toolboxAPI.invocation.launchTool(
303
- "@my-org/entity-picker",
304
- { entityName: "account", allowMultiSelect: false },
305
- );
319
+ const result = await toolboxAPI.invocation.launchTool("@my-org/entity-picker", { entityName: "account", allowMultiSelect: false });
306
320
 
307
321
  if (result !== null) {
308
322
  console.log("Selected record id:", (result as { selectedId: string }).selectedId);
@@ -339,7 +353,7 @@ if (ctx) {
339
353
  }
340
354
  ```
341
355
 
342
- > **Tip:** A tool that was *not* launched by another tool receives `null` from `getLaunchContext()`.
356
+ > **Tip:** A tool that was _not_ launched by another tool receives `null` from `getLaunchContext()`.
343
357
  > Use this to show a standalone UI or redirect accordingly.
344
358
 
345
359
  > **Auto-close**: after calling `returnData`, PPTB automatically closes the callee window. The callee does **not** need to close itself.
@@ -523,9 +537,84 @@ await waitForImport(result.ImportJobId);
523
537
 
524
538
  > **Note:** `deploySolution` automatically supplies `PublishWorkflows` and `OverwriteUnmanagedCustomizations` with a default value of `false` when you do not specify them, aligning with Dataverse's ImportSolution requirements.
525
539
 
540
+ ## Power Platform API Examples
541
+
542
+ The Power Platform API provides generic HTTP methods for all Power Platform Admin API categories:
543
+
544
+ ### Using Power Apps API
545
+
546
+ ```typescript
547
+ // Get an admin app
548
+ const app = await powerplatformAPI.PowerApps.Get("environments/{environmentId}/apps/{app}?api-version=2024-10-01");
549
+
550
+ // List all apps in an environment
551
+ const apps = await powerplatformAPI.PowerApps.Get("environments/{environmentId}/apps?api-version=2024-10-01");
552
+
553
+ // Create a new app
554
+ await powerplatformAPI.PowerApps.Post("environments/{environmentId}/apps?api-version=2024-10-01", {
555
+ name: "My App",
556
+ environmentId: "{environmentId}",
557
+ });
558
+
559
+ // Update an app
560
+ await powerplatformAPI.PowerApps.Patch("environments/{environmentId}/apps/{appId}?api-version=2024-10-01", {
561
+ name: "Updated App Name",
562
+ });
563
+
564
+ // Delete an app
565
+ await powerplatformAPI.PowerApps.Delete("environments/{environmentId}/apps/{appId}?api-version=2024-10-01");
566
+ ```
567
+
568
+ ### Using Power Automate API
569
+
570
+ ```typescript
571
+ // List flows
572
+ const flows = await powerplatformAPI.PowerAutomate.Get("environments/{environmentId}/flows?api-version=2024-10-01");
573
+
574
+ // Get flow details
575
+ const flow = await powerplatformAPI.PowerAutomate.Get("environments/{environmentId}/flows/{flowId}?api-version=2024-10-01");
576
+ ```
577
+
578
+ ### Using Environment Management API
579
+
580
+ ```typescript
581
+ // List environments
582
+ const environments = await powerplatformAPI.EnvironmentManagement.Get("environments?api-version=2024-10-01");
583
+
584
+ // Get environment details
585
+ const env = await powerplatformAPI.EnvironmentManagement.Get("environments/{environmentId}?api-version=2024-10-01");
586
+ ```
587
+
588
+ ### Using Governance API
589
+
590
+ ```typescript
591
+ // Get governance data
592
+ const data = await powerplatformAPI.Governance.Get("environments/{environmentId}/governance?api-version=2024-10-01");
593
+ ```
594
+
595
+ ### Available Categories
596
+
597
+ The Power Platform API exposes the following categories, each with `Get`, `Post`, `Put`, `Patch`, and `Delete` methods:
598
+
599
+ - **Analytics** - `https://api.powerplatform.com/analytics`
600
+ - **AppManagement** - `https://api.powerplatform.com/appmanagement`
601
+ - **Authorization** - `https://api.powerplatform.com/authorization`
602
+ - **Connectivity** - `https://api.powerplatform.com/connectivity`
603
+ - **CopilotStudio** - `https://api.powerplatform.com/copilotstudio`
604
+ - **Dynamics** - `https://api.powerplatform.com/dynamics`
605
+ - **EnvironmentManagement** - `https://api.powerplatform.com/environmentmanagement`
606
+ - **Governance** - `https://api.powerplatform.com/governance`
607
+ - **Licensing** - `https://api.powerplatform.com/licensing`
608
+ - **PowerApps** - `https://api.powerplatform.com/powerapps`
609
+ - **PowerAutomate** - `https://api.powerplatform.com/powerautomate`
610
+ - **PowerPages** - `https://api.powerplatform.com/powerpages`
611
+ - **ResourceQuery** - `https://api.powerplatform.com/resourcequery`
612
+ - **UserManagement** - `https://api.powerplatform.com/usermanagement`
613
+ - **WorkflowAgents** - `https://api.powerplatform.com/workflowagents`
614
+
526
615
  ## API Reference
527
616
 
528
- The Power Platform ToolBox exposes two main APIs to tools:
617
+ The Power Platform ToolBox exposes three main APIs to tools:
529
618
 
530
619
  ### ToolBox API (`window.toolboxAPI`)
531
620
 
@@ -533,8 +622,9 @@ Core platform features organized into namespaces:
533
622
 
534
623
  #### Connections
535
624
 
536
- - **getActiveConnection()**: Promise<DataverseConnection | null>
537
- - Returns the currently active Dataverse connection or null if none is active
625
+ - **getActiveConnection()**: Promise<Connection | null>
626
+ - Returns the currently active connection or null if none is active
627
+ - Includes `enabledForPowerPlatformAPI` so tools can decide whether to use Power Platform API
538
628
 
539
629
  #### Utils
540
630
 
@@ -568,15 +658,6 @@ Core platform features organized into namespaces:
568
658
  );
569
659
  ```
570
660
 
571
- - **showLoading(message?: string)**: Promise<void>
572
- - Displays a loading overlay with spinner in the tool's context
573
- - Optional message parameter (defaults to "Loading...")
574
- - Example: `await toolboxAPI.utils.showLoading('Fetching records...');`
575
-
576
- - **hideLoading()**: Promise<void>
577
- - Hides the loading overlay
578
- - Should be called in a finally block to ensure it's always hidden
579
-
580
661
  #### Terminal
581
662
 
582
663
  - **create(options: TerminalOptions)**: Promise<Terminal>
@@ -697,6 +778,50 @@ Complete HTTP client for interacting with Microsoft Dataverse:
697
778
  - Returns import job details including progress, completion status, and error information
698
779
  - Use to track the progress of a solution deployment initiated with deploySolution
699
780
 
781
+ ### Power Platform API (`window.powerplatformAPI`)
782
+
783
+ Generic HTTP client for Power Platform Admin APIs covering all categories:
784
+
785
+ #### Category Methods
786
+
787
+ Each category (Analytics, AppManagement, Authorization, Connectivity, CopilotStudio, Dynamics, EnvironmentManagement, Governance, Licensing, PowerApps, PowerAutomate, PowerPages, ResourceQuery, UserManagement, WorkflowAgents) exposes:
788
+
789
+ - **Get(path?, connectionTarget?, headers?)**: Promise<PowerPlatformResponse>
790
+ - Makes a GET request to the category endpoint
791
+ - Example: `powerplatformAPI.PowerApps.Get('environments/{environmentId}/apps/{app}?api-version=2024-10-01')`
792
+
793
+ - **Post(path?, body?, connectionTarget?, headers?)**: Promise<PowerPlatformResponse>
794
+ - Makes a POST request to the category endpoint
795
+
796
+ - **Put(path?, body?, connectionTarget?, headers?)**: Promise<PowerPlatformResponse>
797
+ - Makes a PUT request to the category endpoint
798
+
799
+ - **Patch(path?, body?, connectionTarget?, headers?)**: Promise<PowerPlatformResponse>
800
+ - Makes a PATCH request to the category endpoint
801
+
802
+ - **Delete(path?, connectionTarget?, headers?, body?)**: Promise<PowerPlatformResponse>
803
+ - Makes a DELETE request to the category endpoint
804
+
805
+ Available categories and their base URLs:
806
+
807
+ | Category | Base URL |
808
+ | --------------------- | ----------------------------------------------------- |
809
+ | Analytics | `https://api.powerplatform.com/analytics` |
810
+ | AppManagement | `https://api.powerplatform.com/appmanagement` |
811
+ | Authorization | `https://api.powerplatform.com/authorization` |
812
+ | Connectivity | `https://api.powerplatform.com/connectivity` |
813
+ | CopilotStudio | `https://api.powerplatform.com/copilotstudio` |
814
+ | Dynamics | `https://api.powerplatform.com/dynamics` |
815
+ | EnvironmentManagement | `https://api.powerplatform.com/environmentmanagement` |
816
+ | Governance | `https://api.powerplatform.com/governance` |
817
+ | Licensing | `https://api.powerplatform.com/licensing` |
818
+ | PowerApps | `https://api.powerplatform.com/powerapps` |
819
+ | PowerAutomate | `https://api.powerplatform.com/powerautomate` |
820
+ | PowerPages | `https://api.powerplatform.com/powerpages` |
821
+ | ResourceQuery | `https://api.powerplatform.com/resourcequery` |
822
+ | UserManagement | `https://api.powerplatform.com/usermanagement` |
823
+ | WorkflowAgents | `https://api.powerplatform.com/workflowagents` |
824
+
700
825
  ### Security Notes
701
826
 
702
827
  - **Access Tokens**: Tools do NOT have direct access to access tokens. All Dataverse operations are authenticated automatically by the platform.
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/triple-slash-reference */
1
2
  /**
2
3
  * Power Platform ToolBox API Type Definitions
3
4
  *
@@ -16,9 +17,11 @@
16
17
 
17
18
  /// <reference path="./toolboxAPI.d.ts" />
18
19
  /// <reference path="./dataverseAPI.d.ts" />
20
+ /// <reference path="./powerplatformAPI.d.ts" />
19
21
  /// <reference path="./pptbConfig.d.ts" />
20
22
 
21
23
  // Re-export all namespaces for convenience
22
24
  export * from "./dataverseAPI";
23
- export * from "./toolboxAPI";
25
+ export * from "./powerplatformAPI";
24
26
  export * from "./pptbConfig";
27
+ export * from "./toolboxAPI";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pptb/types",
3
- "version": "1.2.4-beta.3",
3
+ "version": "1.2.4-beta.5",
4
4
  "description": "Type definitions for Power Platform ToolBox APIs and validity checks for tool packages",
5
5
  "main": "index.d.ts",
6
6
  "types": "index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "index.d.ts",
30
30
  "toolboxAPI.d.ts",
31
31
  "dataverseAPI.d.ts",
32
+ "powerplatformAPI.d.ts",
32
33
  "pptbConfig.d.ts",
33
34
  "bin/",
34
35
  "README.md"
package/toolboxAPI.d.ts CHANGED
@@ -75,9 +75,9 @@ declare namespace ToolBoxAPI {
75
75
  }
76
76
 
77
77
  /**
78
- * Dataverse connection configuration
78
+ * Power Platform ToolBox connection configuration
79
79
  */
80
- export interface DataverseConnection {
80
+ export interface Connection {
81
81
  id: string;
82
82
  name: string;
83
83
  url: string;
@@ -85,6 +85,7 @@ declare namespace ToolBoxAPI {
85
85
  category?: string;
86
86
  environmentColor?: string;
87
87
  categoryColor?: string;
88
+ enabledForPowerPlatformAPI?: boolean;
88
89
  createdAt?: string;
89
90
  lastUsedAt?: string;
90
91
  /**
@@ -95,6 +96,11 @@ declare namespace ToolBoxAPI {
95
96
  isActive?: boolean;
96
97
  }
97
98
 
99
+ /**
100
+ * @deprecated Use Connection instead.
101
+ */
102
+ export type DataverseConnection = Connection;
103
+
98
104
  /**
99
105
  * Tool information
100
106
  */
@@ -150,12 +156,12 @@ declare namespace ToolBoxAPI {
150
156
  /**
151
157
  * Get the currently active Dataverse connection
152
158
  */
153
- getActiveConnection: () => Promise<DataverseConnection | null>;
159
+ getActiveConnection: () => Promise<Connection | null>;
154
160
 
155
161
  /**
156
162
  * Get the secondary connection for multi-connection tools
157
163
  */
158
- getSecondaryConnection: () => Promise<DataverseConnection | null>;
164
+ getSecondaryConnection: () => Promise<Connection | null>;
159
165
  }
160
166
 
161
167
  /**
@@ -498,7 +504,11 @@ declare namespace ToolBoxAPI {
498
504
  * @param prefillData Data to pre-populate the target tool's state
499
505
  * @param options Optional connection overrides and launch flags
500
506
  */
501
- launchTool: (targetToolId: string, prefillData?: Record<string, unknown>, options?: { primaryConnectionId?: string | null; secondaryConnectionId?: string | null; noReturn?: boolean }) => Promise<unknown>;
507
+ launchTool: (
508
+ targetToolId: string,
509
+ prefillData?: Record<string, unknown>,
510
+ options?: { primaryConnectionId?: string | null; secondaryConnectionId?: string | null; noReturn?: boolean },
511
+ ) => Promise<unknown>;
502
512
 
503
513
  /**
504
514
  * Find installed tools that declare a given capability tag in their