@pptb/types 1.0.18 → 1.0.19-beta.1

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.
Files changed (3) hide show
  1. package/README.md +135 -154
  2. package/dataverseAPI.d.ts +13 -8
  3. package/package.json +5 -3
package/README.md CHANGED
@@ -2,36 +2,36 @@
2
2
 
3
3
  TypeScript type definitions for Power Platform ToolBox 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)
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
35
 
36
36
  ## Installation
37
37
 
@@ -274,30 +274,30 @@ await dataverseAPI.publishCustomizations("account");
274
274
  ### Deploy Solutions
275
275
 
276
276
  ```typescript
277
- // Read solution file and convert to base64
277
+ // Read solution file (returns Buffer/Uint8Array depending on runtime)
278
278
  const solutionFile = await toolboxAPI.fileSystem.readBinary("/path/to/MySolution.zip");
279
- const base64Content = btoa(String.fromCharCode(...new Uint8Array(solutionFile)));
280
279
 
281
- // Deploy solution with default options
282
- const result = await dataverseAPI.deploySolution(base64Content);
280
+ // Deploy solution with default options (binary input is accepted)
281
+ const result = await dataverseAPI.deploySolution(solutionFile);
283
282
  console.log("Solution deployment started. Import Job ID:", result.ImportJobId);
284
283
 
285
- // Deploy solution with custom options
286
- const result = await dataverseAPI.deploySolution(base64Content, {
284
+ // Deploy solution with custom options using the same binary payload
285
+ const customResult = await dataverseAPI.deploySolution(solutionFile, {
287
286
  publishWorkflows: true,
288
287
  overwriteUnmanagedCustomizations: false,
289
288
  skipProductUpdateDependencies: false,
290
289
  convertToManaged: false,
291
290
  });
292
- console.log("Import Job ID:", result.ImportJobId);
291
+ console.log("Import Job ID:", customResult.ImportJobId);
293
292
 
294
- // Deploy with a specific import job ID for tracking
293
+ // Deploy with a specific import job ID using an explicitly encoded base64 string
295
294
  const importJobId = crypto.randomUUID();
296
- const result = await dataverseAPI.deploySolution(base64Content, {
297
- importJobId: importJobId,
295
+ const base64Content = btoa(String.fromCharCode(...new Uint8Array(solutionFile)));
296
+ const trackedResult = await dataverseAPI.deploySolution(base64Content, {
297
+ importJobId,
298
298
  publishWorkflows: true,
299
299
  });
300
- console.log("Tracking import with job ID:", result.ImportJobId);
300
+ console.log("Tracking import with job ID:", trackedResult.ImportJobId);
301
301
 
302
302
  // Track the import progress
303
303
  const status = await dataverseAPI.getImportJobStatus(result.ImportJobId);
@@ -336,39 +336,33 @@ Core platform features organized into namespaces:
336
336
 
337
337
  #### Connections
338
338
 
339
- - **getActiveConnection()**: Promise<DataverseConnection | null>
340
- - Returns the currently active Dataverse connection or null if none is active
339
+ - **getActiveConnection()**: Promise<DataverseConnection | null>
340
+ - Returns the currently active Dataverse connection or null if none is active
341
341
 
342
342
  #### Utils
343
343
 
344
- - **showNotification(options: NotificationOptions)**: Promise<void>
345
-
346
- - Displays a ToolBox notification. `options.type` supports `info | success | warning | error` and `duration` in ms (0 = persistent)
347
-
348
- - **copyToClipboard(text: string)**: Promise<void>
349
-
350
- - Copies the provided text into the system clipboard
351
-
352
- - **saveFile(defaultPath: string, content: any)**: Promise<string | null>
344
+ - **showNotification(options: NotificationOptions)**: Promise<void>
345
+ - Displays a ToolBox notification. `options.type` supports `info | success | warning | error` and `duration` in ms (0 = persistent)
353
346
 
354
- - Opens a save dialog and writes the content. Returns the saved file path or null if canceled
347
+ - **copyToClipboard(text: string)**: Promise<void>
348
+ - Copies the provided text into the system clipboard
355
349
 
356
- - **selectPath(options?: SelectPathOptions)**: Promise<string | null>
350
+ - **saveFile(defaultPath: string, content: any)**: Promise<string | null>
351
+ - Opens a save dialog and writes the content. Returns the saved file path or null if canceled
357
352
 
358
- - Opens a native dialog to select either a file or folder (defaults to file)
359
- - Supports custom titles, button labels, default paths, and filters when selecting files
360
- - Returns the selected path or null if the user cancels
353
+ - **selectPath(options?: SelectPathOptions)**: Promise<string | null>
354
+ - Opens a native dialog to select either a file or folder (defaults to file)
355
+ - Supports custom titles, button labels, default paths, and filters when selecting files
356
+ - Returns the selected path or null if the user cancels
361
357
 
362
- - **getCurrentTheme()**: Promise<"light" | "dark">
358
+ - **getCurrentTheme()**: Promise<"light" | "dark">
359
+ - Returns the current UI theme setting
363
360
 
364
- - Returns the current UI theme setting
365
-
366
- - **executeParallel(...operations)**: Promise<T[]>
367
-
368
- - Executes multiple async operations in parallel using Promise.all
369
- - Accepts promises or functions that return promises as variadic arguments
370
- - Returns an array of results in the same order as the operations
371
- - Example:
361
+ - **executeParallel(...operations)**: Promise<T[]>
362
+ - Executes multiple async operations in parallel using Promise.all
363
+ - Accepts promises or functions that return promises as variadic arguments
364
+ - Returns an array of results in the same order as the operations
365
+ - Example:
372
366
  ```typescript
373
367
  const [account, contact, opportunities] = await toolboxAPI.utils.executeParallel(
374
368
  dataverseAPI.retrieve("account", id1),
@@ -377,65 +371,57 @@ Core platform features organized into namespaces:
377
371
  );
378
372
  ```
379
373
 
380
- - **showLoading(message?: string)**: Promise<void>
381
-
382
- - Displays a loading overlay with spinner in the tool's context
383
- - Optional message parameter (defaults to "Loading...")
384
- - Example: `await toolboxAPI.utils.showLoading('Fetching records...');`
374
+ - **showLoading(message?: string)**: Promise<void>
375
+ - Displays a loading overlay with spinner in the tool's context
376
+ - Optional message parameter (defaults to "Loading...")
377
+ - Example: `await toolboxAPI.utils.showLoading('Fetching records...');`
385
378
 
386
- - **hideLoading()**: Promise<void>
387
- - Hides the loading overlay
388
- - Should be called in a finally block to ensure it's always hidden
379
+ - **hideLoading()**: Promise<void>
380
+ - Hides the loading overlay
381
+ - Should be called in a finally block to ensure it's always hidden
389
382
 
390
383
  #### Terminal
391
384
 
392
- - **create(options: TerminalOptions)**: Promise<Terminal>
393
-
394
- - Creates a new terminal attached to the tool (tool ID is auto-determined)
395
-
396
- - **execute(terminalId: string, command: string)**: Promise<TerminalCommandResult>
397
-
398
- - Executes a command in the specified terminal and returns its result
385
+ - **create(options: TerminalOptions)**: Promise<Terminal>
386
+ - Creates a new terminal attached to the tool (tool ID is auto-determined)
399
387
 
400
- - **close(terminalId: string)**: Promise<void>
388
+ - **execute(terminalId: string, command: string)**: Promise<TerminalCommandResult>
389
+ - Executes a command in the specified terminal and returns its result
401
390
 
402
- - Closes the specified terminal
391
+ - **close(terminalId: string)**: Promise<void>
392
+ - Closes the specified terminal
403
393
 
404
- - **get(terminalId: string)**: Promise<Terminal | undefined>
394
+ - **get(terminalId: string)**: Promise<Terminal | undefined>
395
+ - Gets a single terminal by id, if it exists
405
396
 
406
- - Gets a single terminal by id, if it exists
397
+ - **list()**: Promise<Terminal[]>
398
+ - Lists all terminals created by this tool
407
399
 
408
- - **list()**: Promise<Terminal[]>
409
-
410
- - Lists all terminals created by this tool
411
-
412
- - **setVisibility(terminalId: string, visible: boolean)**: Promise<void>
413
- - Shows or hides the terminal UI for the specified terminal id
400
+ - **setVisibility(terminalId: string, visible: boolean)**: Promise<void>
401
+ - Shows or hides the terminal UI for the specified terminal id
414
402
 
415
403
  #### Events
416
404
 
417
- - **getHistory(limit?: number)**: Promise<ToolBoxEventPayload[]>
418
-
419
- - Returns recent ToolBox events for this tool, newest first. Use `limit` to cap the number of entries
420
-
421
- - **on(callback: (event: any, payload: ToolBoxEventPayload) => void)**: void
422
-
423
- - Subscribes to ToolBox events
424
- - Events available:
425
- - `tool:loaded` - A tool has been loaded
426
- - `tool:unloaded` - A tool has been unloaded
427
- - `connection:created` - A new connection was created
428
- - `connection:updated` - An existing connection was updated
429
- - `connection:deleted` - A connection was deleted
430
- - `notification:shown` - A notification was displayed
431
- - `terminal:created` - A new terminal was created
432
- - `terminal:closed` - A terminal was closed
433
- - `terminal:output` - Terminal produced output
434
- - `terminal:command:completed` - A terminal command finished executing
435
- - `terminal:error` - A terminal error occurred
436
-
437
- - **off(callback: (event: any, payload: ToolBoxEventPayload) => void)**: void
438
- - Removes a previously registered event listener
405
+ - **getHistory(limit?: number)**: Promise<ToolBoxEventPayload[]>
406
+ - Returns recent ToolBox events for this tool, newest first. Use `limit` to cap the number of entries
407
+
408
+ - **on(callback: (event: any, payload: ToolBoxEventPayload) => void)**: void
409
+ - Subscribes to ToolBox events
410
+ - Events available:
411
+ - `tool:loaded` - A tool has been loaded
412
+ - `tool:unloaded` - A tool has been unloaded
413
+ - `connection:created` - A new connection was created
414
+ - `connection:updated` - An existing connection was updated
415
+ - `connection:deleted` - A connection was deleted
416
+ - `notification:shown` - A notification was displayed
417
+ - `terminal:created` - A new terminal was created
418
+ - `terminal:closed` - A terminal was closed
419
+ - `terminal:output` - Terminal produced output
420
+ - `terminal:command:completed` - A terminal command finished executing
421
+ - `terminal:error` - A terminal error occurred
422
+
423
+ - **off(callback: (event: any, payload: ToolBoxEventPayload) => void)**: void
424
+ - Removes a previously registered event listener
439
425
 
440
426
  ### Dataverse API (`window.dataverseAPI`)
441
427
 
@@ -443,64 +429,59 @@ Complete HTTP client for interacting with Microsoft Dataverse:
443
429
 
444
430
  #### CRUD Operations
445
431
 
446
- - **create(entityLogicalName: string, record: Record<string, unknown>)**: Promise<{id: string, ...}>
432
+ - **create(entityLogicalName: string, record: Record<string, unknown>)**: Promise<{id: string, ...}>
433
+ - Creates a new record in Dataverse
434
+ - Returns the created record ID and any returned fields
447
435
 
448
- - Creates a new record in Dataverse
449
- - Returns the created record ID and any returned fields
436
+ - **retrieve(entityLogicalName: string, id: string, columns?: string[])**: Promise<Record<string, unknown>>
437
+ - Retrieves a single record by ID
438
+ - Optional columns array to select specific fields
450
439
 
451
- - **retrieve(entityLogicalName: string, id: string, columns?: string[])**: Promise<Record<string, unknown>>
440
+ - **update(entityLogicalName: string, id: string, record: Record<string, unknown>)**: Promise<void>
441
+ - Updates an existing record
452
442
 
453
- - Retrieves a single record by ID
454
- - Optional columns array to select specific fields
455
-
456
- - **update(entityLogicalName: string, id: string, record: Record<string, unknown>)**: Promise<void>
457
-
458
- - Updates an existing record
459
-
460
- - **delete(entityLogicalName: string, id: string)**: Promise<void>
461
- - Deletes a record
443
+ - **delete(entityLogicalName: string, id: string)**: Promise<void>
444
+ - Deletes a record
462
445
 
463
446
  #### Query Operations
464
447
 
465
- - **fetchXmlQuery(fetchXml: string)**: Promise<{value: Record<string, unknown>[], ...}>
448
+ - **fetchXmlQuery(fetchXml: string)**: Promise<{value: Record<string, unknown>[], ...}>
449
+ - Executes a FetchXML query
450
+ - Returns object with value array containing matching records
466
451
 
467
- - Executes a FetchXML query
468
- - Returns object with value array containing matching records
469
-
470
- - **retrieveMultiple(fetchXml: string)**: Promise<{value: Record<string, unknown>[], ...}>
471
- - Alias for fetchXmlQuery for backward compatibility
452
+ - **retrieveMultiple(fetchXml: string)**: Promise<{value: Record<string, unknown>[], ...}>
453
+ - Alias for fetchXmlQuery for backward compatibility
472
454
 
473
455
  #### Metadata Operations
474
456
 
475
- - **getEntityMetadata(entityLogicalName: string)**: Promise<EntityMetadata>
476
-
477
- - Retrieves metadata for a specific entity
457
+ - **getEntityMetadata(entityLogicalName: string)**: Promise<EntityMetadata>
458
+ - Retrieves metadata for a specific entity
478
459
 
479
- - **getAllEntitiesMetadata()**: Promise<{value: EntityMetadata[]}>
480
- - Retrieves metadata for all entities
460
+ - **getAllEntitiesMetadata()**: Promise<{value: EntityMetadata[]}>
461
+ - Retrieves metadata for all entities
481
462
 
482
463
  #### Advanced Operations
483
464
 
484
- - **execute(request: ExecuteRequest)**: Promise<Record<string, unknown>>
485
- - Executes a Dataverse Web API action or function
486
- - Supports both bound and unbound operations
487
- - **publishCustomizations(tableLogicalName?: string)**: Promise<void>
488
- - Publishes pending customizations. When `tableLogicalName` is omitted it runs PublishAllXml; otherwise it publishes only the specified table.
489
- - **deploySolution(base64SolutionContent: string, options?: DeploySolutionOptions, connectionTarget?: "primary" | "secondary")**: Promise<{ImportJobId: string}>
490
- - Deploys (imports) a solution to the Dataverse environment
491
- - Takes a base64-encoded solution zip file
492
- - Supports optional parameters for customizing the import (publishWorkflows, overwriteUnmanagedCustomizations, etc.)
493
- - Returns an ImportJobId for tracking the import progress
494
- - **getImportJobStatus(importJobId: string, connectionTarget?: "primary" | "secondary")**: Promise<Record<string, unknown>>
495
- - Gets the status of a solution import job
496
- - Returns import job details including progress, completion status, and error information
497
- - Use to track the progress of a solution deployment initiated with deploySolution
465
+ - **execute(request: ExecuteRequest)**: Promise<Record<string, unknown>>
466
+ - Executes a Dataverse Web API action or function
467
+ - Supports both bound and unbound operations
468
+ - **publishCustomizations(tableLogicalName?: string)**: Promise<void>
469
+ - Publishes pending customizations. When `tableLogicalName` is omitted it runs PublishAllXml; otherwise it publishes only the specified table.
470
+ - **deploySolution(base64SolutionContent: string, options?: DeploySolutionOptions, connectionTarget?: "primary" | "secondary")**: Promise<{ImportJobId: string}>
471
+ - Deploys (imports) a solution to the Dataverse environment
472
+ - Takes a base64-encoded solution zip file
473
+ - Supports optional parameters for customizing the import (publishWorkflows, overwriteUnmanagedCustomizations, etc.)
474
+ - Returns an ImportJobId for tracking the import progress
475
+ - **getImportJobStatus(importJobId: string, connectionTarget?: "primary" | "secondary")**: Promise<Record<string, unknown>>
476
+ - Gets the status of a solution import job
477
+ - Returns import job details including progress, completion status, and error information
478
+ - Use to track the progress of a solution deployment initiated with deploySolution
498
479
 
499
480
  ### Security Notes
500
481
 
501
- - **Access Tokens**: Tools do NOT have direct access to access tokens. All Dataverse operations are authenticated automatically by the platform.
502
- - **Connection Context**: Tools only receive the connection URL, not sensitive credentials.
503
- - **Secure Storage**: All tokens and secrets are encrypted and managed by the platform.
482
+ - **Access Tokens**: Tools do NOT have direct access to access tokens. All Dataverse operations are authenticated automatically by the platform.
483
+ - **Connection Context**: Tools only receive the connection URL, not sensitive credentials.
484
+ - **Secure Storage**: All tokens and secrets are encrypted and managed by the platform.
504
485
 
505
486
  For detailed examples and best practices, see the [Dataverse API Documentation](../docs/DATAVERSE_API.md).
506
487
 
package/dataverseAPI.d.ts CHANGED
@@ -45,6 +45,11 @@ declare namespace DataverseAPI {
45
45
  value: EntityMetadata[];
46
46
  }
47
47
 
48
+ /**
49
+ * Supported inputs for solution deployment payloads
50
+ */
51
+ export type SolutionContentInput = string | ArrayBuffer | ArrayBufferView;
52
+
48
53
  /**
49
54
  * Record creation result
50
55
  */
@@ -601,21 +606,20 @@ declare namespace DataverseAPI {
601
606
  /**
602
607
  * Deploy (import) a solution to the Dataverse environment
603
608
  *
604
- * @param base64SolutionContent - Base64-encoded solution zip file content
609
+ * @param solutionContent - Base64-encoded solution zip string or binary data (Buffer, Uint8Array, ArrayBuffer)
605
610
  * @param options - Optional import settings to customize the deployment
606
611
  * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
607
612
  * @returns Object containing the ImportJobId for tracking the import progress
608
613
  *
609
614
  * @example
610
615
  * // Read solution file and deploy with default options
611
- * const solutionFile = await toolboxAPI.filesystem.readBinary('/path/to/solution.zip');
612
- * const base64Content = btoa(String.fromCharCode(...new Uint8Array(solutionFile)));
613
- * const result = await dataverseAPI.deploySolution(base64Content);
616
+ * const solutionFile = await toolboxAPI.fileSystem.readBinary('/path/to/solution.zip');
617
+ * const result = await dataverseAPI.deploySolution(solutionFile);
614
618
  * console.log('Import Job ID:', result.ImportJobId);
615
619
  *
616
620
  * @example
617
621
  * // Deploy solution with custom options
618
- * const result = await dataverseAPI.deploySolution(base64Content, {
622
+ * const result = await dataverseAPI.deploySolution(solutionFile, {
619
623
  * publishWorkflows: true,
620
624
  * overwriteUnmanagedCustomizations: false,
621
625
  * skipProductUpdateDependencies: false,
@@ -624,8 +628,9 @@ declare namespace DataverseAPI {
624
628
  * console.log('Solution deployment started. Import Job ID:', result.ImportJobId);
625
629
  *
626
630
  * @example
627
- * // Deploy solution with specific import job ID for tracking
631
+ * // Deploy solution using a manually encoded base64 string with specific import job ID
628
632
  * const importJobId = crypto.randomUUID();
633
+ * const base64Content = btoa(String.fromCharCode(...new Uint8Array(solutionFile)));
629
634
  * const result = await dataverseAPI.deploySolution(base64Content, {
630
635
  * importJobId: importJobId,
631
636
  * publishWorkflows: true
@@ -634,12 +639,12 @@ declare namespace DataverseAPI {
634
639
  *
635
640
  * @example
636
641
  * // Multi-connection tool using secondary connection
637
- * const result = await dataverseAPI.deploySolution(base64Content, {
642
+ * const result = await dataverseAPI.deploySolution(solutionFile, {
638
643
  * publishWorkflows: true
639
644
  * }, 'secondary');
640
645
  */
641
646
  deploySolution: (
642
- base64SolutionContent: string,
647
+ solutionContent: SolutionContentInput,
643
648
  options?: {
644
649
  /**
645
650
  * Optional GUID to track the import job. If not provided, Dataverse generates one.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pptb/types",
3
- "version": "1.0.18",
3
+ "version": "1.0.19-beta.1",
4
4
  "description": "TypeScript type definitions for Power Platform ToolBox API",
5
5
  "main": "index.d.ts",
6
6
  "types": "index.d.ts",
@@ -20,7 +20,9 @@
20
20
  "directory": "packages"
21
21
  },
22
22
  "scripts": {
23
- "publish:stable": "pnpm publish --access public --tag latest",
24
- "publish:beta": "pnpm publish --access public --tag beta"
23
+ "version:beta": "pnpm version prerelease --preid beta --no-git-tag-version",
24
+ "version:stable": "pnpm version patch --no-git-tag-version",
25
+ "publish:stable": "pnpm publish --access public --tag latest --no-git-checks",
26
+ "publish:beta": "pnpm publish --access public --tag beta --no-git-checks"
25
27
  }
26
28
  }