@pptb/types 1.0.7 → 1.0.9
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 +74 -0
- package/dataverseAPI.d.ts +7 -4
- package/package.json +2 -2
- package/toolboxAPI.d.ts +29 -4
package/README.md
CHANGED
|
@@ -2,6 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript type definitions for Power Platform Tool Box APIs.
|
|
4
4
|
|
|
5
|
+
- [@pptb/types](#pptbtypes)
|
|
6
|
+
- [Installation](#installation)
|
|
7
|
+
- [Overview](#overview)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Include all type definitions](#include-all-type-definitions)
|
|
10
|
+
- [Include specific API types](#include-specific-api-types)
|
|
11
|
+
- [ToolBox API Examples](#toolbox-api-examples)
|
|
12
|
+
- [Connections](#connections)
|
|
13
|
+
- [Utilities](#utilities)
|
|
14
|
+
- [Terminal Operations](#terminal-operations)
|
|
15
|
+
- [Events](#events)
|
|
16
|
+
- [Dataverse API Examples](#dataverse-api-examples)
|
|
17
|
+
- [CRUD Operations](#crud-operations)
|
|
18
|
+
- [FetchXML Queries](#fetchxml-queries)
|
|
19
|
+
- [Metadata Operations](#metadata-operations)
|
|
20
|
+
- [Execute Actions/Functions](#execute-actionsfunctions)
|
|
21
|
+
- [API Reference](#api-reference)
|
|
22
|
+
- [ToolBox API (`window.toolboxAPI`)](#toolbox-api-windowtoolboxapi)
|
|
23
|
+
- [Connections](#connections-1)
|
|
24
|
+
- [Utils](#utils)
|
|
25
|
+
- [Terminal](#terminal)
|
|
26
|
+
- [Events](#events-1)
|
|
27
|
+
- [Dataverse API (`window.dataverseAPI`)](#dataverse-api-windowdataverseapi)
|
|
28
|
+
- [CRUD Operations](#crud-operations-1)
|
|
29
|
+
- [Query Operations](#query-operations)
|
|
30
|
+
- [Metadata Operations](#metadata-operations-1)
|
|
31
|
+
- [Advanced Operations](#advanced-operations)
|
|
32
|
+
- [Security Notes](#security-notes)
|
|
33
|
+
- [Publishing the package to npm](#publishing-the-package-to-npm)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
|
|
5
36
|
## Installation
|
|
6
37
|
|
|
7
38
|
```bash
|
|
@@ -75,6 +106,24 @@ if (filePath) {
|
|
|
75
106
|
// Get current theme
|
|
76
107
|
const theme = await toolboxAPI.utils.getCurrentTheme();
|
|
77
108
|
console.log("Current theme:", theme); // "light" or "dark"
|
|
109
|
+
|
|
110
|
+
// Execute multiple operations in parallel
|
|
111
|
+
const [account, contact, opportunities] = await toolboxAPI.utils.executeParallel(
|
|
112
|
+
dataverseAPI.retrieve('account', accountId, ['name']),
|
|
113
|
+
dataverseAPI.retrieve('contact', contactId, ['fullname']),
|
|
114
|
+
dataverseAPI.fetchXmlQuery(opportunityFetchXml)
|
|
115
|
+
);
|
|
116
|
+
console.log('All data fetched:', account, contact, opportunities);
|
|
117
|
+
|
|
118
|
+
// Show loading screen during operations
|
|
119
|
+
await toolboxAPI.utils.showLoading('Processing data...');
|
|
120
|
+
try {
|
|
121
|
+
// Perform operations
|
|
122
|
+
await processData();
|
|
123
|
+
} finally {
|
|
124
|
+
// Always hide loading
|
|
125
|
+
await toolboxAPI.utils.hideLoading();
|
|
126
|
+
}
|
|
78
127
|
```
|
|
79
128
|
|
|
80
129
|
### Terminal Operations
|
|
@@ -234,8 +283,33 @@ Core platform features organized into namespaces:
|
|
|
234
283
|
- Opens a save dialog and writes the content. Returns the saved file path or null if canceled
|
|
235
284
|
|
|
236
285
|
- **getCurrentTheme()**: Promise<"light" | "dark">
|
|
286
|
+
|
|
237
287
|
- Returns the current UI theme setting
|
|
238
288
|
|
|
289
|
+
- **executeParallel(...operations)**: Promise<T[]>
|
|
290
|
+
|
|
291
|
+
- Executes multiple async operations in parallel using Promise.all
|
|
292
|
+
- Accepts promises or functions that return promises as variadic arguments
|
|
293
|
+
- Returns an array of results in the same order as the operations
|
|
294
|
+
- Example:
|
|
295
|
+
```typescript
|
|
296
|
+
const [account, contact, opportunities] = await toolboxAPI.utils.executeParallel(
|
|
297
|
+
dataverseAPI.retrieve('account', id1),
|
|
298
|
+
dataverseAPI.retrieve('contact', id2),
|
|
299
|
+
dataverseAPI.fetchXmlQuery(fetchXml)
|
|
300
|
+
);
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
- **showLoading(message?: string)**: Promise<void>
|
|
304
|
+
|
|
305
|
+
- Displays a loading overlay with spinner in the tool's context
|
|
306
|
+
- Optional message parameter (defaults to "Loading...")
|
|
307
|
+
- Example: `await toolboxAPI.utils.showLoading('Fetching records...');`
|
|
308
|
+
|
|
309
|
+
- **hideLoading()**: Promise<void>
|
|
310
|
+
- Hides the loading overlay
|
|
311
|
+
- Should be called in a finally block to ensure it's always hidden
|
|
312
|
+
|
|
239
313
|
#### Terminal
|
|
240
314
|
|
|
241
315
|
- **create(options: TerminalOptions)**: Promise<Terminal>
|
package/dataverseAPI.d.ts
CHANGED
|
@@ -205,17 +205,20 @@ declare namespace DataverseAPI {
|
|
|
205
205
|
* Get metadata for a specific entity
|
|
206
206
|
*
|
|
207
207
|
* @param entityLogicalName - Logical name of the entity
|
|
208
|
+
* @param searchByLogicalName - Whether to search by logical name (true) or metadata ID (false)
|
|
208
209
|
* @param selectColumns - Optional array of column names to retrieve (retrieves all if not specified)
|
|
209
210
|
* @returns Object containing entity metadata
|
|
210
211
|
*
|
|
211
212
|
* @example
|
|
212
|
-
* const metadata = await dataverseAPI.getEntityMetadata('account');
|
|
213
|
+
* const metadata = await dataverseAPI.getEntityMetadata('account', true, ['LogicalName', 'DisplayName']);
|
|
214
|
+
* console.log('Logical Name:', metadata.LogicalName);
|
|
213
215
|
* console.log('Display Name:', metadata.DisplayName?.LocalizedLabels[0]?.Label);
|
|
214
|
-
* console.log('Attributes:', metadata.Attributes?.length);
|
|
215
216
|
*
|
|
216
217
|
* @example
|
|
217
|
-
* // Get
|
|
218
|
-
* const metadata = await dataverseAPI.getEntityMetadata('
|
|
218
|
+
* // Get entity metadata by metadata ID
|
|
219
|
+
* const metadata = await dataverseAPI.getEntityMetadata('00000000-0000-0000-0000-000000000001', false, ['LogicalName', 'DisplayName']);
|
|
220
|
+
* console.log('Entity Metadata ID:', metadata.MetadataId);
|
|
221
|
+
* console.log('Logical Name:', metadata.LogicalName);
|
|
219
222
|
* console.log('Display Name:', metadata.DisplayName?.LocalizedLabels[0]?.Label);
|
|
220
223
|
*/
|
|
221
224
|
getEntityMetadata: (entityLogicalName: string, searchByLogicalName: boolean, selectColumns?: string[]) => Promise<EntityMetadata>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pptb/types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "TypeScript type definitions for Power Platform Tool Box API",
|
|
5
5
|
"main": "index.d.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "GPL-3.0",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/PowerPlatformToolBox/desktop-app.git",
|
|
20
20
|
"directory": "packages"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/toolboxAPI.d.ts
CHANGED
|
@@ -145,6 +145,31 @@ declare namespace ToolBoxAPI {
|
|
|
145
145
|
* Get the current UI theme (light or dark)
|
|
146
146
|
*/
|
|
147
147
|
getCurrentTheme: () => Promise<"light" | "dark">;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Execute multiple async operations in parallel using Promise.all
|
|
151
|
+
* @param operations Variable number of promises or async function calls
|
|
152
|
+
* @returns Promise that resolves when all operations complete with an array of results
|
|
153
|
+
* @example
|
|
154
|
+
* // Execute multiple API calls in parallel
|
|
155
|
+
* const [account, contact, opportunities] = await toolboxAPI.utils.executeParallel(
|
|
156
|
+
* dataverseAPI.retrieve('account', '123'),
|
|
157
|
+
* dataverseAPI.retrieve('contact', '456'),
|
|
158
|
+
* dataverseAPI.fetchXmlQuery(fetchXml)
|
|
159
|
+
* );
|
|
160
|
+
*/
|
|
161
|
+
executeParallel: <T = any>(...operations: Array<Promise<T> | (() => Promise<T>)>) => Promise<T[]>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Show a loading screen in the tool's context
|
|
165
|
+
* @param message Optional message to display (default: "Loading...")
|
|
166
|
+
*/
|
|
167
|
+
showLoading: (message?: string) => Promise<void>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Hide the loading screen in the tool's context
|
|
171
|
+
*/
|
|
172
|
+
hideLoading: () => Promise<void>;
|
|
148
173
|
}
|
|
149
174
|
|
|
150
175
|
/**
|
|
@@ -211,14 +236,14 @@ declare namespace ToolBoxAPI {
|
|
|
211
236
|
* Get all settings for this tool
|
|
212
237
|
* @returns Promise resolving to an object with all settings (empty object if no settings exist)
|
|
213
238
|
*/
|
|
214
|
-
|
|
239
|
+
getAll: () => Promise<Record<string, any>>;
|
|
215
240
|
|
|
216
241
|
/**
|
|
217
242
|
* Get a specific setting by key
|
|
218
243
|
* @param key The setting key to retrieve
|
|
219
244
|
* @returns Promise resolving to the setting value, or undefined if not found
|
|
220
245
|
*/
|
|
221
|
-
|
|
246
|
+
get: (key: string) => Promise<any>;
|
|
222
247
|
|
|
223
248
|
/**
|
|
224
249
|
* Set a specific setting by key
|
|
@@ -226,14 +251,14 @@ declare namespace ToolBoxAPI {
|
|
|
226
251
|
* @param value The value to store (can be any JSON-serializable value)
|
|
227
252
|
* @returns Promise that resolves when the setting is saved
|
|
228
253
|
*/
|
|
229
|
-
|
|
254
|
+
set: (key: string, value: any) => Promise<void>;
|
|
230
255
|
|
|
231
256
|
/**
|
|
232
257
|
* Set all settings (replaces entire settings object)
|
|
233
258
|
* @param settings The settings object to store
|
|
234
259
|
* @returns Promise that resolves when the settings are saved
|
|
235
260
|
*/
|
|
236
|
-
|
|
261
|
+
setAll: (settings: Record<string, any>) => Promise<void>;
|
|
237
262
|
}
|
|
238
263
|
|
|
239
264
|
/**
|