@pptb/types 1.0.14 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @pptb/types
2
2
 
3
- TypeScript type definitions for Power Platform Tool Box APIs.
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 Tool Box exposes two main APIs to tools:
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 Tool Box - Dataverse API Type Definitions
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: (entityLogicalName: string, relatedPath: string, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
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
- * '$select=name,emailaddress1,telephone1&$filter=statecode eq 0&$orderby=name&$top=10'
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
- * '$select=name,accountid&$expand=contact_customer_accounts($select=fullname,emailaddress1)&$top=5'
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('$filter=statecode eq 0', 'secondary');
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 Tool Box API Type Definitions
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
- "name": "@pptb/types",
3
- "version": "1.0.14",
4
- "description": "TypeScript type definitions for Power Platform Tool Box 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 Tool Box",
16
- "license": "GPL-3.0",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/PowerPlatformToolBox/desktop-app.git",
20
- "directory": "packages"
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 Tool Box - ToolBox API Type Definitions
2
+ * Power Platform ToolBox - ToolBox API Type Definitions
3
3
  *
4
4
  * Core ToolBox API exposed to tools via window.toolboxAPI
5
5
  */