@pptb/types 1.0.14 → 1.0.17
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 +2 -2
- package/dataverseAPI.d.ts +63 -6
- package/index.d.ts +2 -2
- package/package.json +20 -20
- package/toolboxAPI.d.ts +65 -11
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)
|
|
@@ -273,7 +273,7 @@ await dataverseAPI.publishCustomizations("account");
|
|
|
273
273
|
|
|
274
274
|
## API Reference
|
|
275
275
|
|
|
276
|
-
The Power Platform
|
|
276
|
+
The Power Platform ToolBox exposes two main APIs to tools:
|
|
277
277
|
|
|
278
278
|
### ToolBox API (`window.toolboxAPI`)
|
|
279
279
|
|
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.17",
|
|
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
|
*/
|
|
@@ -179,16 +179,6 @@ declare namespace ToolBoxAPI {
|
|
|
179
179
|
*/
|
|
180
180
|
copyToClipboard: (text: string) => Promise<void>;
|
|
181
181
|
|
|
182
|
-
/**
|
|
183
|
-
* Open a save file dialog and write content
|
|
184
|
-
*/
|
|
185
|
-
saveFile: (defaultPath: string, content: any) => Promise<string | null>;
|
|
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
|
-
|
|
192
182
|
/**
|
|
193
183
|
* Get the current UI theme (light or dark)
|
|
194
184
|
*/
|
|
@@ -220,6 +210,65 @@ declare namespace ToolBoxAPI {
|
|
|
220
210
|
hideLoading: () => Promise<void>;
|
|
221
211
|
}
|
|
222
212
|
|
|
213
|
+
/**
|
|
214
|
+
* FileSystem namespace - filesystem operations for tools
|
|
215
|
+
*/
|
|
216
|
+
export interface FileSystemAPI {
|
|
217
|
+
/**
|
|
218
|
+
* Read a file as UTF-8 text
|
|
219
|
+
* Ideal for configs (pcfconfig.json, package.json)
|
|
220
|
+
*/
|
|
221
|
+
readText: (path: string) => Promise<string>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Read a file as raw binary data (Buffer)
|
|
225
|
+
* For images, ZIPs, manifests that need to be hashed, uploaded, or parsed as non-text
|
|
226
|
+
* Returns a Node.js Buffer which Electron can properly serialize over IPC
|
|
227
|
+
* Tools can convert to ArrayBuffer using buffer.buffer if needed
|
|
228
|
+
*/
|
|
229
|
+
readBinary: (path: string) => Promise<Buffer>;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Check if a file or directory exists
|
|
233
|
+
* Lightweight existence check before attempting reads/writes
|
|
234
|
+
*/
|
|
235
|
+
exists: (path: string) => Promise<boolean>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Get file or directory metadata
|
|
239
|
+
* Confirms users picked the correct folder/file and shows info in UI
|
|
240
|
+
*/
|
|
241
|
+
stat: (path: string) => Promise<{ type: "file" | "directory"; size: number; mtime: string }>;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Read directory contents
|
|
245
|
+
* Enumerate folder contents when tools need to show selectable files or validate structure
|
|
246
|
+
*/
|
|
247
|
+
readDirectory: (path: string) => Promise<Array<{ name: string; type: "file" | "directory" }>>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Write text content to a file
|
|
251
|
+
* Save generated files (manifests, logs) without forcing users through save dialog
|
|
252
|
+
*/
|
|
253
|
+
writeText: (path: string, content: string) => Promise<void>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Create a directory (recursive)
|
|
257
|
+
* Ensure target folders exist before writing scaffolding artifacts
|
|
258
|
+
*/
|
|
259
|
+
createDirectory: (path: string) => Promise<void>;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Open a save file dialog and write content
|
|
263
|
+
*/
|
|
264
|
+
saveFile: (defaultPath: string, content: any) => Promise<string | null>;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Open a native dialog to select either a file or a folder and return the chosen path
|
|
268
|
+
*/
|
|
269
|
+
selectPath: (options?: SelectPathOptions) => Promise<string | null>;
|
|
270
|
+
}
|
|
271
|
+
|
|
223
272
|
/**
|
|
224
273
|
* Terminal namespace - context-aware terminal operations
|
|
225
274
|
*/
|
|
@@ -323,6 +372,11 @@ declare namespace ToolBoxAPI {
|
|
|
323
372
|
*/
|
|
324
373
|
utils: UtilsAPI;
|
|
325
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Filesystem operations
|
|
377
|
+
*/
|
|
378
|
+
fileSystem: FileSystemAPI;
|
|
379
|
+
|
|
326
380
|
/**
|
|
327
381
|
* Tool-specific settings (context-aware)
|
|
328
382
|
*/
|