Share via


@microsoft/power-apps package

Classes

OperationExecutor

Executes operations using the plugin.

DefaultDataOperationOrchestrator

RuntimeDataOperations provides a unified interface for performing data operations across different data sources.

ConnectorDataOperationExecutor

ConnectorDataOperation provides functionality for performing CRUD operations against connector data sources using the Runtime Data Client.

DataverseDataOperationExecutor

DataverseDataOperation provides functionality for performing CRUD operations against the Dataverse data source using the XRM WebApi or runtime metadata client.

MockDataOperationExecutor
PowerDataRuntimeError

Base error class for PowerDataRuntime operations

RuntimeDataSourceService

RuntimeDataSourceService provides functionality for managing and retrieving data source information.

RuntimeMetadataOperations

RuntimeMetadataOperations provides functionality for retrieving metadata about connections and APIs.

PowerDataRuntime

PowerDataRuntime provides a unified interface for data and metadata operations in the Power runtime environment.

default

Singleton provider for managing data sources information.

RuntimeClientProvider

RuntimeClientProvider manages the lifecycle of runtime clients for data and metadata operations. Implements a lazy initialization pattern for clients and ensures proper error handling.

RuntimeDataClient

RuntimeDataClient handles data operations through PowerOperationExecutor

RuntimeMetadataClient

RuntimeMetadataClient handles metadata operations through PowerOperationExecutor

Log
DefaultPowerAppsBridge
CompatibleMessageReceiver
IncompatibleMessageReceiver
SendMessage
SendMessageOperation

Interfaces

IAppContext
IConfig
IContext
IHostContext
IUserContext
IApiDefinition
IApiResponseInfo
IClientConfig

Base interface for client configuration

IConnectionApi

Interface for connection API details

IConnectionReference

Interface for connection reference details

IFieldSchema

Interface for field schema information

IHttpHeaders

Interface for HTTP request headers

IHttpRequestConfig

Interface for HTTP request configuration

IMetadataOperationConfig

Interface for metadata operation configuration

IMetadataOperations

Interface for metadata operations

IOperationContext

Base interface for operation context

IPowerDataSourcesInfoProvider

Interface for PowerDataSourcesInfoProvider

IRuntimeClientProvider

Interface for runtime client provider

IRuntimeDataClient

Interface for runtime data client

IRuntimeMetadataClient

Interface for runtime metadata client

ITableSchema

Interface for table schema information

IXrmContext

Interface defining the XRM context shape

ODataResponse

Interface for OData response format

IConnectorOperationConfig

Interface for connector operation configuration

DataverseDataSourceInfo

Interface for data source info

ILinkedEnvironmentMetadata
HttpErrorResponse
PowerDataRuntimeHttpError
IPowerDataRuntimeInitParams

Interface for PowerDataRuntime initialization parameters

IConnectorOperation

Interface for connector-specific operations

IDataOperation

Interface for custom data operations

IDataOperationExecutor
IDataOperationOrchestrator

Interface for performing CRUD operations on data sources

IDataSourceInfo

Interface for data source info

IOperationOptions

Base interface for operation options The parameters must be defined as OData query parameters

IOperationResult

Base interface for operation results

IPowerDataRuntime

Main PowerDataRuntime interface providing access to data operations

IPowerOperationExecutor

Interface for PowerOperationExecutor This interface defines the method for executing operations

EntityMetadataExpands
EntityMetadataSelects
GetEntityMetadataOptions
SendMessagePlugin
ILogger

Type Aliases

Connection
Connections
DataClient
IDataverseRequest

Interface for Dataverse-specific requests

OperationExecutionResponse

Interface for operation execution result

RequestBody

Type alias for request body in data operations

ResponseData

Type alias for possible response data formats

ConnectionReferences

Type for connection references mapping

DatabaseReferences
MockDataStore
DataSourcesInfo

Type definition for data source configuration

DataverseMetadataRequest
EntityMetadata
PowerAppsBridge
CompatibilityCheckerResult
CompatibleReceiverMessage
MessageReceiver
AppLoadClientState
AppLoadNonOptimalReason
AppLoadResult
AppLoadUnsuccessfulReason
Metric
NetworkRequestMetric
NetworkRequestMetricData
SessionLoadSummaryMetric
SessionLoadSummaryMetricData

Enums

@microsoft/power-apps.DataSourceServiceError
DataSources

Supported data source types in the PowerDataRuntime

HttpMethod

HTTP methods supported by the client

ErrorCodes

Error types specific to DataRuntime

ConnectorOperationName

Enum for ConnectorDataOperation operation names.

DataverseOperationName

Enum for DataverseDataOperation operation names.

HeaderNames
DataOperationErrorMessages

Functions

setConfig(IConfig)
getContext()
getClient(DataSourcesInfo)
getDataOperationExecutor()
setDataOperationExecutor(IDataOperationExecutor)
loadConnections()
createRecordAsync<TInput, TResult>(DataSourcesInfo, string, TInput)

Creates a new record in the specified table.

deleteRecordAsync(DataSourcesInfo, string, string)

Deletes a record from the specified table.

executeAsync<TRequest, TResult>(DataSourcesInfo, IDataOperation<TRequest>)

Executes a data operation.

retrieveMultipleRecordsAsync<TResult>(DataSourcesInfo, string, IOperationOptions)

Retrieves multiple records from the specified table.

retrieveRecordAsync<TResult>(DataSourcesInfo, string, string, IOperationOptions)

Retrieves a record from the specified table.

updateRecordAsync<TInput, TResult>(DataSourcesInfo, string, string, TInput)

Updates an existing record in the specified table.

arrayBufferToBase64(ArrayBuffer)
convertArrayBufferToString(ArrayBuffer)
extractDataverseUrlParts(string)

Extracts the Dataverse base URL and encoded path from a full Dataverse API URL.

strictEncode(string)

Strict encode: encodeURIComponent, but also encode ( and )

extractSkipToken(undefined | string)

Extracts the skip token from the next link URL.

createMockDataExecutor(MockDataStore<unknown>)
convertOptionsToQueryString(IOperationOptions)

Converts operation options to a query string format.

createErrorResponse<T>(unknown, string)

Handles operation errors and creates an error OperationResult

getErrorMessage(unknown)

Retrieves the error message from an error object.

parseHttpPluginError(unknown)

Parses an error from the HTTP plugin and returns a PowerDataRuntimeHttpError object.

getExecutor()
getPowerSdkInstance(DataSourcesInfo)

Builds (or retrieves) a singleton runtime context based on provided data sources. Must be called after initializeRuntime() has injected the OperationExecutor.

getPowerDataRuntime(IPowerDataSourcesInfoProvider, IPowerOperationExecutor)

Gets or creates a singleton instance of PowerDataRuntime

resetPowerDataRuntimeInstance()

Resets the PowerDataRuntime singleton instance. Useful for testing or reinitialization.

isOperationResult<TResponse>(unknown)
getAssociatedMenuBehaviorName(0 | 1 | 2)
getAssociatedMenuGroupName(0 | 1 | 2 | 3)
getAttributeRequiredLevelName(0 | 1 | 2 | 3)
getAttributeTypeCodeName(0 | 1 | 2 | 4 | 8 | 16 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20)
getCascadeTypeName(0 | 1 | 2 | 4 | 3 | 5)
getEntityClusterModeName(0 | 1 | 2)
getOwnershipTypeName(0 | 1 | 2 | 4 | 8 | 16 | 32)
getPrivilegeTypeName(0 | 1 | 2 | 4 | 8 | 3 | 5 | 6 | 7)
getRelationshipTypeName(0 | 1)
getSecurityTypesName(0 | 1 | 2 | 8 | 16)
executePluginAsync<T>(string, string, unknown[], (args: unknown) => void)
initializeLogger(ILogger)
getAppLoadedPerformanceData()

Variables

CRM_GLOBAL_METADATA_VERSION
CRM_TOTAL_RECORD_COUNT
CRM_TOTAL_RECORD_COUNT_LIMIT_EXCEEDED
ODATA_CONTEXT
ODATA_NEXT_LINK
ErrorMessages
UnknownErrorMessage

Function Details

setConfig(IConfig)

function setConfig(config: IConfig)

Parameters

config
IConfig

getContext()

function getContext(): Promise<IContext>

Returns

Promise<IContext>

getClient(DataSourcesInfo)

function getClient(dataSourcesInfo: DataSourcesInfo): DataClient

Parameters

dataSourcesInfo
DataSourcesInfo

Returns

getDataOperationExecutor()

function getDataOperationExecutor(): IDataOperationExecutor | undefined

Returns

setDataOperationExecutor(IDataOperationExecutor)

function setDataOperationExecutor(dataOperationExecutorOverride: IDataOperationExecutor)

Parameters

dataOperationExecutorOverride
IDataOperationExecutor

loadConnections()

function loadConnections(): Promise<void>

Returns

Promise<void>

createRecordAsync<TInput, TResult>(DataSourcesInfo, string, TInput)

Creates a new record in the specified table.

function createRecordAsync<TInput, TResult>(dataSourcesInfo: DataSourcesInfo, tableName: string, record: TInput): Promise<IOperationResult<TResult>>

Parameters

dataSourcesInfo
DataSourcesInfo

The data sources information.

tableName

string

The name of the table to create the record in.

record

TInput

The record to create.

Returns

Promise<IOperationResult<TResult>>

A promise that resolves to the created record.

deleteRecordAsync(DataSourcesInfo, string, string)

Deletes a record from the specified table.

function deleteRecordAsync(dataSourcesInfo: DataSourcesInfo, tableName: string, recordId: string): Promise<IOperationResult<void>>

Parameters

dataSourcesInfo
DataSourcesInfo

The data sources information.

tableName

string

The name of the table to delete the record from.

recordId

string

The ID of the record to delete.

Returns

Promise<IOperationResult<void>>

A promise that resolves to the result of the delete operation.

executeAsync<TRequest, TResult>(DataSourcesInfo, IDataOperation<TRequest>)

Executes a data operation.

function executeAsync<TRequest, TResult>(dataSourcesInfo: DataSourcesInfo, operation: IDataOperation<TRequest>): Promise<IOperationResult<TResult>>

Parameters

dataSourcesInfo
DataSourcesInfo
operation

IDataOperation<TRequest>

The data operation to execute.

Returns

Promise<IOperationResult<TResult>>

  • A promise that resolves to the result of the operation.

retrieveMultipleRecordsAsync<TResult>(DataSourcesInfo, string, IOperationOptions)

Retrieves multiple records from the specified table.

function retrieveMultipleRecordsAsync<TResult>(dataSourcesInfo: DataSourcesInfo, tableName: string, options?: IOperationOptions): Promise<IOperationResult<TResult[]>>

Parameters

dataSourcesInfo
DataSourcesInfo

The data sources information.

tableName

string

The name of the table to create the record in.

options
IOperationOptions

Optional operation options.

Returns

Promise<IOperationResult<TResult[]>>

  • A promise that resolves to the created record.

retrieveRecordAsync<TResult>(DataSourcesInfo, string, string, IOperationOptions)

Retrieves a record from the specified table.

function retrieveRecordAsync<TResult>(dataSourcesInfo: DataSourcesInfo, tableName: string, recordId: string, options?: IOperationOptions): Promise<IOperationResult<TResult>>

Parameters

dataSourcesInfo
DataSourcesInfo
tableName

string

The name of the table to retrieve the record from.

recordId

string

The ID of the record to retrieve.

options
IOperationOptions

Optional operation options.

Returns

Promise<IOperationResult<TResult>>

A promise that resolves to the retrieved record.

updateRecordAsync<TInput, TResult>(DataSourcesInfo, string, string, TInput)

Updates an existing record in the specified table.

function updateRecordAsync<TInput, TResult>(dataSourcesInfo: DataSourcesInfo, tableName: string, recordId: string, changes: TInput): Promise<IOperationResult<TResult>>

Parameters

dataSourcesInfo
DataSourcesInfo

The data sources information.

tableName

string

The name of the table to create the record in.

recordId

string

The ID of the record to update.

changes

TInput

The changes to apply to the record.

Returns

Promise<IOperationResult<TResult>>

  • A promise that resolves to the created record.

arrayBufferToBase64(ArrayBuffer)

function arrayBufferToBase64(buffer: ArrayBuffer): string

Parameters

buffer

ArrayBuffer

Returns

string

convertArrayBufferToString(ArrayBuffer)

function convertArrayBufferToString(buf: ArrayBuffer): string

Parameters

buf

ArrayBuffer

Returns

string

extractDataverseUrlParts(string)

Extracts the Dataverse base URL and encoded path from a full Dataverse API URL.

function extractDataverseUrlParts(url: string): { baseUrl: string, encodedPath: string }

Parameters

url

string

The full Dataverse API URL (should contain /api/data/v9.0/)

Returns

{ baseUrl: string, encodedPath: string }

An object with baseUrl (up to /api/data/v9.0) and encodedPath (strict encoded path after /api/data/v9.0/)

strictEncode(string)

Strict encode: encodeURIComponent, but also encode ( and )

function strictEncode(str: string): string

Parameters

str

string

Returns

string

extractSkipToken(undefined | string)

Extracts the skip token from the next link URL.

function extractSkipToken(nextLink: undefined | string): string | undefined

Parameters

nextLink

undefined | string

The @odata.nextLink URL containing the skip token

Returns

string | undefined

The extracted skip token or undefined if not found.

createMockDataExecutor(MockDataStore<unknown>)

function createMockDataExecutor(data: MockDataStore<unknown>): MockDataOperationExecutor

Parameters

data

MockDataStore<unknown>

Returns

convertOptionsToQueryString(IOperationOptions)

Converts operation options to a query string format.

function convertOptionsToQueryString(options?: IOperationOptions): string

Parameters

options
IOperationOptions

The operation options to convert.

Returns

string

The formatted query string.

createErrorResponse<T>(unknown, string)

Handles operation errors and creates an error OperationResult

function createErrorResponse<T>(error: unknown, friendlyMessage: string): IOperationResult<T>

Parameters

error

unknown

The error object or OperationResult

friendlyMessage

string

A friendly message to include in the error

Returns

getErrorMessage(unknown)

Retrieves the error message from an error object.

function getErrorMessage(error: unknown): string

Parameters

error

unknown

The error to handle, which can be an instance of Error or IOperationResult.

Returns

string

The error message if applicable, or throws the error if it's a PowerDataRuntimeError.

parseHttpPluginError(unknown)

Parses an error from the HTTP plugin and returns a PowerDataRuntimeHttpError object.

function parseHttpPluginError(error: unknown): PowerDataRuntimeHttpError

Parameters

error

unknown

The error to parse, which should be an array with a nested array.

Returns

A PowerDataRuntimeHttpError object containing the message and response.

getExecutor()

function getExecutor(): IPowerOperationExecutor

Returns

getPowerSdkInstance(DataSourcesInfo)

Builds (or retrieves) a singleton runtime context based on provided data sources. Must be called after initializeRuntime() has injected the OperationExecutor.

function getPowerSdkInstance(dataSourcesInfo: DataSourcesInfo): Promise<PowerDataRuntime>

Parameters

dataSourcesInfo
DataSourcesInfo

Returns

Promise<PowerDataRuntime>

getPowerDataRuntime(IPowerDataSourcesInfoProvider, IPowerOperationExecutor)

Gets or creates a singleton instance of PowerDataRuntime

function getPowerDataRuntime(powerDataSourcesInfoProvider: IPowerDataSourcesInfoProvider, powerOperationExecutor: IPowerOperationExecutor): PowerDataRuntime

Parameters

powerDataSourcesInfoProvider
IPowerDataSourcesInfoProvider

Data sources info provider to initialize the PowerDataRuntime

powerOperationExecutor
IPowerOperationExecutor

Optional power operation executor to initialize the PowerDataRuntime

Returns

PowerDataRuntime instance

resetPowerDataRuntimeInstance()

Resets the PowerDataRuntime singleton instance. Useful for testing or reinitialization.

function resetPowerDataRuntimeInstance()

isOperationResult<TResponse>(unknown)

function isOperationResult<TResponse>(result: unknown): result

Parameters

result

unknown

Returns

result

getAssociatedMenuBehaviorName(0 | 1 | 2)

function getAssociatedMenuBehaviorName(value: 0 | 1 | 2): "UseCollectionName" | "UseLabel" | "DoNotDisplay"

Parameters

value

0 | 1 | 2

Returns

"UseCollectionName" | "UseLabel" | "DoNotDisplay"

getAssociatedMenuGroupName(0 | 1 | 2 | 3)

function getAssociatedMenuGroupName(value: 0 | 1 | 2 | 3): "Details" | "Sales" | "Service" | "Marketing"

Parameters

value

0 | 1 | 2 | 3

Returns

"Details" | "Sales" | "Service" | "Marketing"

getAttributeRequiredLevelName(0 | 1 | 2 | 3)

function getAttributeRequiredLevelName(value: 0 | 1 | 2 | 3): "None" | "SystemRequired" | "ApplicationRequired" | "Recommended"

Parameters

value

0 | 1 | 2 | 3

Returns

"None" | "SystemRequired" | "ApplicationRequired" | "Recommended"

getAttributeTypeCodeName(0 | 1 | 2 | 4 | 8 | 16 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20)

function getAttributeTypeCodeName(value: 0 | 1 | 2 | 4 | 8 | 16 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20): "Boolean" | "Customer" | "DateTime" | "Decimal" | "Double" | "Integer" | "Lookup" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "String" | "Uniqueidentifier" | "CalendarRules" | "Virtual" | "BigInt" | "ManagedProperty" | "EntityName"

Parameters

value

0 | 1 | 2 | 4 | 8 | 16 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20

Returns

"Boolean" | "Customer" | "DateTime" | "Decimal" | "Double" | "Integer" | "Lookup" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "String" | "Uniqueidentifier" | "CalendarRules" | "Virtual" | "BigInt" | "ManagedProperty" | "EntityName"

getCascadeTypeName(0 | 1 | 2 | 4 | 3 | 5)

function getCascadeTypeName(value: 0 | 1 | 2 | 4 | 3 | 5): "UserOwned" | "NoCascade" | "Cascade" | "Active" | "RemoveLink" | "Restrict"

Parameters

value

0 | 1 | 2 | 4 | 3 | 5

Returns

"UserOwned" | "NoCascade" | "Cascade" | "Active" | "RemoveLink" | "Restrict"

getEntityClusterModeName(0 | 1 | 2)

function getEntityClusterModeName(value: 0 | 1 | 2): "Partitioned" | "Replicated" | "Local"

Parameters

value

0 | 1 | 2

Returns

"Partitioned" | "Replicated" | "Local"

getOwnershipTypeName(0 | 1 | 2 | 4 | 8 | 16 | 32)

function getOwnershipTypeName(value: 0 | 1 | 2 | 4 | 8 | 16 | 32): "None" | "UserOwned" | "TeamOwned" | "BusinessOwned" | "OrganizationOwned" | "BusinessParented" | "Filtered"

Parameters

value

0 | 1 | 2 | 4 | 8 | 16 | 32

Returns

"None" | "UserOwned" | "TeamOwned" | "BusinessOwned" | "OrganizationOwned" | "BusinessParented" | "Filtered"

getPrivilegeTypeName(0 | 1 | 2 | 4 | 8 | 3 | 5 | 6 | 7)

function getPrivilegeTypeName(value: 0 | 1 | 2 | 4 | 8 | 3 | 5 | 6 | 7): "None" | "Create" | "Read" | "Write" | "Delete" | "Assign" | "Share" | "Append" | "AppendTo"

Parameters

value

0 | 1 | 2 | 4 | 8 | 3 | 5 | 6 | 7

Returns

"None" | "Create" | "Read" | "Write" | "Delete" | "Assign" | "Share" | "Append" | "AppendTo"

getRelationshipTypeName(0 | 1)

function getRelationshipTypeName(value: 0 | 1): "OneToManyRelationship" | "ManyToManyRelationship"

Parameters

value

0 | 1

Returns

"OneToManyRelationship" | "ManyToManyRelationship"

getSecurityTypesName(0 | 1 | 2 | 8 | 16)

function getSecurityTypesName(value: 0 | 1 | 2 | 8 | 16): "None" | "Append" | "ParentChild" | "Pointer" | "Inheritance"

Parameters

value

0 | 1 | 2 | 8 | 16

Returns

"None" | "Append" | "ParentChild" | "Pointer" | "Inheritance"

executePluginAsync<T>(string, string, unknown[], (args: unknown) => void)

function executePluginAsync<T>(pluginName: string, pluginAction: string, params?: unknown[], update?: (args: unknown) => void): Promise<T>

Parameters

pluginName

string

pluginAction

string

params

unknown[]

update

(args: unknown) => void

Returns

Promise<T>

initializeLogger(ILogger)

function initializeLogger(logger: ILogger): Promise<void>

Parameters

logger
ILogger

Returns

Promise<void>

getAppLoadedPerformanceData()

function getAppLoadedPerformanceData(): object

Returns

object

Variable Details

CRM_GLOBAL_METADATA_VERSION

CRM_GLOBAL_METADATA_VERSION: "@Microsoft.Dynamics.CRM.globalmetadataversion"

Type

@Microsoft.Dynamics.CRM.globalmetadataversion

CRM_TOTAL_RECORD_COUNT

CRM_TOTAL_RECORD_COUNT: "@Microsoft.Dynamics.CRM.totalrecordcount"

Type

@Microsoft.Dynamics.CRM.totalrecordcount

CRM_TOTAL_RECORD_COUNT_LIMIT_EXCEEDED

CRM_TOTAL_RECORD_COUNT_LIMIT_EXCEEDED: "@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded"

Type

@Microsoft.Dynamics.CRM.totalrecordcountlimitexceeded

ODATA_CONTEXT

ODATA_CONTEXT: "@odata.context"

Type

@odata.context

ODATA_NEXT_LINK: "@odata.nextLink"

Type

@odata.nextLink

ErrorMessages

ErrorMessages: {[key in ErrorCodes]?: string;}

Type

{[key in ErrorCodes]?: string;}

UnknownErrorMessage

UnknownErrorMessage: "An unknown error occurred"

Type

"An unknown error occurred"