@pptb/types 1.0.13 → 1.0.16
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 +18 -2
- package/dataverseAPI.d.ts +63 -6
- package/index.d.ts +2 -2
- package/package.json +20 -20
- package/toolboxAPI.d.ts +29 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @pptb/types
|
|
2
2
|
|
|
3
|
-
TypeScript type definitions for Power Platform
|
|
3
|
+
TypeScript type definitions for Power Platform ToolBox APIs.
|
|
4
4
|
|
|
5
5
|
- [@pptb/types](#pptbtypes)
|
|
6
6
|
- [Installation](#installation)
|
|
@@ -103,6 +103,16 @@ if (filePath) {
|
|
|
103
103
|
console.log("File saved to:", filePath);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
// Select a folder for exporting assets
|
|
107
|
+
const targetFolder = await toolboxAPI.utils.selectPath({
|
|
108
|
+
type: "folder",
|
|
109
|
+
title: "Choose export directory",
|
|
110
|
+
defaultPath: "/Users/me/Downloads",
|
|
111
|
+
});
|
|
112
|
+
if (!targetFolder) {
|
|
113
|
+
console.log("User canceled folder selection");
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
// Get current theme
|
|
107
117
|
const theme = await toolboxAPI.utils.getCurrentTheme();
|
|
108
118
|
console.log("Current theme:", theme); // "light" or "dark"
|
|
@@ -263,7 +273,7 @@ await dataverseAPI.publishCustomizations("account");
|
|
|
263
273
|
|
|
264
274
|
## API Reference
|
|
265
275
|
|
|
266
|
-
The Power Platform
|
|
276
|
+
The Power Platform ToolBox exposes two main APIs to tools:
|
|
267
277
|
|
|
268
278
|
### ToolBox API (`window.toolboxAPI`)
|
|
269
279
|
|
|
@@ -288,6 +298,12 @@ Core platform features organized into namespaces:
|
|
|
288
298
|
|
|
289
299
|
- Opens a save dialog and writes the content. Returns the saved file path or null if canceled
|
|
290
300
|
|
|
301
|
+
- **selectPath(options?: SelectPathOptions)**: Promise<string | null>
|
|
302
|
+
|
|
303
|
+
- Opens a native dialog to select either a file or folder (defaults to file)
|
|
304
|
+
- Supports custom titles, button labels, default paths, and filters when selecting files
|
|
305
|
+
- Returns the selected path or null if the user cancels
|
|
306
|
+
|
|
291
307
|
- **getCurrentTheme()**: Promise<"light" | "dark">
|
|
292
308
|
|
|
293
309
|
- Returns the current UI theme setting
|
package/dataverseAPI.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Power Platform
|
|
2
|
+
* Power Platform ToolBox - Dataverse API Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* Dataverse Web API exposed to tools via window.dataverseAPI
|
|
5
5
|
*/
|
|
@@ -23,10 +23,21 @@ declare namespace DataverseAPI {
|
|
|
23
23
|
DisplayName?: {
|
|
24
24
|
LocalizedLabels: Array<{ Label: string; LanguageCode: number }>;
|
|
25
25
|
};
|
|
26
|
-
Attributes?: unknown[];
|
|
27
26
|
[key: string]: unknown;
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
export type EntityRelatedMetadataBasePath = "Attributes" | "Keys" | "ManyToOneRelationships" | "OneToManyRelationships" | "ManyToManyRelationships" | "Privileges";
|
|
30
|
+
|
|
31
|
+
export type EntityRelatedMetadataPath =
|
|
32
|
+
| EntityRelatedMetadataBasePath
|
|
33
|
+
| `${EntityRelatedMetadataBasePath}/${string}`
|
|
34
|
+
| `${EntityRelatedMetadataBasePath}(${string})`
|
|
35
|
+
| `${EntityRelatedMetadataBasePath}(${string})/${string}`;
|
|
36
|
+
|
|
37
|
+
type EntityRelatedMetadataRecordPath = `${EntityRelatedMetadataBasePath}/${string}` | `${EntityRelatedMetadataBasePath}(${string})` | `${EntityRelatedMetadataBasePath}(${string})/${string}`;
|
|
38
|
+
|
|
39
|
+
export type EntityRelatedMetadataResponse<P extends EntityRelatedMetadataPath> = P extends EntityRelatedMetadataRecordPath ? Record<string, unknown> : { value: Record<string, unknown>[] };
|
|
40
|
+
|
|
30
41
|
/**
|
|
31
42
|
* Entity metadata collection response
|
|
32
43
|
*/
|
|
@@ -307,6 +318,47 @@ declare namespace DataverseAPI {
|
|
|
307
318
|
* console.log('Filtered attributes:', attributes.value);
|
|
308
319
|
*
|
|
309
320
|
* @example
|
|
321
|
+
* // Get a single attribute definition (returns an object, not a collection)
|
|
322
|
+
* const nameAttribute = await dataverseAPI.getEntityRelatedMetadata(
|
|
323
|
+
* 'account',
|
|
324
|
+
* "Attributes(LogicalName='name')"
|
|
325
|
+
* );
|
|
326
|
+
* console.log('Attribute type:', nameAttribute.AttributeType);
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* // Drill into an attribute's option set
|
|
330
|
+
* const industryOptions = await dataverseAPI.getEntityRelatedMetadata(
|
|
331
|
+
* 'account',
|
|
332
|
+
* "Attributes(LogicalName='industrycode')/OptionSet"
|
|
333
|
+
* );
|
|
334
|
+
* console.log('Industry options:', industryOptions.Options);
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* // Retrieve keys defined on the entity
|
|
338
|
+
* const keys = await dataverseAPI.getEntityRelatedMetadata('account', 'Keys');
|
|
339
|
+
* console.log('Entity keys:', keys.value);
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* // Retrieve many-to-one relationships (collection)
|
|
343
|
+
* const m2oRelationships = await dataverseAPI.getEntityRelatedMetadata('account', 'ManyToOneRelationships');
|
|
344
|
+
* console.log('Many-to-one count:', m2oRelationships.value.length);
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* // Retrieve one-to-many relationships (collection)
|
|
348
|
+
* const o2mRelationships = await dataverseAPI.getEntityRelatedMetadata('account', 'OneToManyRelationships');
|
|
349
|
+
* console.log('One-to-many relationships:', o2mRelationships.value.map((rel) => rel.SchemaName));
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* // Retrieve many-to-many relationships (collection)
|
|
353
|
+
* const m2mRelationships = await dataverseAPI.getEntityRelatedMetadata('account', 'ManyToManyRelationships');
|
|
354
|
+
* console.log('Many-to-many relationships:', m2mRelationships.value.map((rel) => rel.SchemaName));
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* // Retrieve privileges (collection)
|
|
358
|
+
* const privileges = await dataverseAPI.getEntityRelatedMetadata('account', 'Privileges');
|
|
359
|
+
* console.log('Privilege names:', privileges.value.map((priv) => priv.Name));
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
310
362
|
* // Get one-to-many relationships
|
|
311
363
|
* const relationships = await dataverseAPI.getEntityRelatedMetadata(
|
|
312
364
|
* 'account',
|
|
@@ -318,7 +370,12 @@ declare namespace DataverseAPI {
|
|
|
318
370
|
* // Multi-connection tool using secondary connection
|
|
319
371
|
* const attributes = await dataverseAPI.getEntityRelatedMetadata('account', 'Attributes', ['LogicalName'], 'secondary');
|
|
320
372
|
*/
|
|
321
|
-
getEntityRelatedMetadata:
|
|
373
|
+
getEntityRelatedMetadata: <P extends EntityRelatedMetadataPath>(
|
|
374
|
+
entityLogicalName: string,
|
|
375
|
+
relatedPath: P,
|
|
376
|
+
selectColumns?: string[],
|
|
377
|
+
connectionTarget?: "primary" | "secondary",
|
|
378
|
+
) => Promise<EntityRelatedMetadataResponse<P>>;
|
|
322
379
|
|
|
323
380
|
/**
|
|
324
381
|
* Get solutions from the environment
|
|
@@ -356,7 +413,7 @@ declare namespace DataverseAPI {
|
|
|
356
413
|
* @example
|
|
357
414
|
* // Get top 10 active accounts with specific fields
|
|
358
415
|
* const result = await dataverseAPI.queryData(
|
|
359
|
-
* '
|
|
416
|
+
* 'accounts?$select=name,emailaddress1,telephone1&$filter=statecode eq 0&$orderby=name&$top=10'
|
|
360
417
|
* );
|
|
361
418
|
* console.log(`Found ${result.value.length} records`);
|
|
362
419
|
* result.value.forEach(record => {
|
|
@@ -366,7 +423,7 @@ declare namespace DataverseAPI {
|
|
|
366
423
|
* @example
|
|
367
424
|
* // Query with expand to include related records
|
|
368
425
|
* const result = await dataverseAPI.queryData(
|
|
369
|
-
* '
|
|
426
|
+
* 'accounts?$select=name,accountid&$expand=contact_customer_accounts($select=fullname,emailaddress1)&$top=5'
|
|
370
427
|
* );
|
|
371
428
|
*
|
|
372
429
|
* @example
|
|
@@ -377,7 +434,7 @@ declare namespace DataverseAPI {
|
|
|
377
434
|
*
|
|
378
435
|
* @example
|
|
379
436
|
* // Multi-connection tool using secondary connection
|
|
380
|
-
* const result = await dataverseAPI.queryData('
|
|
437
|
+
* const result = await dataverseAPI.queryData('contacts?$filter=statecode eq 0', 'secondary');
|
|
381
438
|
*/
|
|
382
439
|
queryData: (odataQuery: string, connectionTarget?: "primary" | "secondary") => Promise<{ value: Record<string, unknown>[] }>;
|
|
383
440
|
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Power Platform
|
|
2
|
+
* Power Platform ToolBox API Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* This is the main entry point for TypeScript type definitions.
|
|
5
5
|
* Tools can reference specific APIs they need:
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
/// <reference path="./dataverseAPI.d.ts" />
|
|
19
19
|
|
|
20
20
|
// Re-export all namespaces for convenience
|
|
21
|
-
export * from "./toolboxAPI";
|
|
22
21
|
export * from "./dataverseAPI";
|
|
22
|
+
export * from "./toolboxAPI";
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
"name": "@pptb/types",
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"description": "TypeScript type definitions for Power Platform ToolBox API",
|
|
5
|
+
"main": "index.d.ts",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"powerplatform",
|
|
9
|
+
"pptb",
|
|
10
|
+
"toolbox",
|
|
11
|
+
"types",
|
|
12
|
+
"typescript",
|
|
13
|
+
"dataverse"
|
|
14
|
+
],
|
|
15
|
+
"author": "Power Platform ToolBox",
|
|
16
|
+
"license": "GPL-3.0",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/PowerPlatformToolBox/desktop-app.git",
|
|
20
|
+
"directory": "packages"
|
|
21
|
+
}
|
|
22
22
|
}
|
package/toolboxAPI.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Power Platform
|
|
2
|
+
* Power Platform ToolBox - ToolBox API Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* Core ToolBox API exposed to tools via window.toolboxAPI
|
|
5
5
|
*/
|
|
@@ -27,6 +27,26 @@ declare namespace ToolBoxAPI {
|
|
|
27
27
|
duration?: number; // Duration in milliseconds, 0 for persistent
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* File dialog filter definition
|
|
32
|
+
*/
|
|
33
|
+
export interface FileDialogFilter {
|
|
34
|
+
name: string;
|
|
35
|
+
extensions: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Options for selecting a file or folder path
|
|
40
|
+
*/
|
|
41
|
+
export interface SelectPathOptions {
|
|
42
|
+
type?: "file" | "folder";
|
|
43
|
+
title?: string;
|
|
44
|
+
message?: string;
|
|
45
|
+
buttonLabel?: string;
|
|
46
|
+
defaultPath?: string;
|
|
47
|
+
filters?: FileDialogFilter[];
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
/**
|
|
31
51
|
* Event types that can be emitted by the ToolBox
|
|
32
52
|
*/
|
|
@@ -128,17 +148,17 @@ declare namespace ToolBoxAPI {
|
|
|
128
148
|
* Get the currently active Dataverse connection
|
|
129
149
|
*/
|
|
130
150
|
getActiveConnection: () => Promise<DataverseConnection | null>;
|
|
131
|
-
|
|
151
|
+
|
|
132
152
|
/**
|
|
133
153
|
* Get the secondary connection for multi-connection tools
|
|
134
154
|
*/
|
|
135
155
|
getSecondaryConnection: () => Promise<DataverseConnection | null>;
|
|
136
|
-
|
|
156
|
+
|
|
137
157
|
/**
|
|
138
158
|
* Get the secondary connection URL for multi-connection tools
|
|
139
159
|
*/
|
|
140
160
|
getSecondaryConnectionUrl: () => Promise<string | null>;
|
|
141
|
-
|
|
161
|
+
|
|
142
162
|
/**
|
|
143
163
|
* Get the secondary connection ID for multi-connection tools
|
|
144
164
|
*/
|
|
@@ -164,6 +184,11 @@ declare namespace ToolBoxAPI {
|
|
|
164
184
|
*/
|
|
165
185
|
saveFile: (defaultPath: string, content: any) => Promise<string | null>;
|
|
166
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Open a native dialog to select either a file or a folder and return the chosen path
|
|
189
|
+
*/
|
|
190
|
+
selectPath: (options?: SelectPathOptions) => Promise<string | null>;
|
|
191
|
+
|
|
167
192
|
/**
|
|
168
193
|
* Get the current UI theme (light or dark)
|
|
169
194
|
*/
|