@microsoft/power-apps-native-host 0.2.22 → 0.3.0

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 (156) hide show
  1. package/README.md +162 -26
  2. package/compatibility/current.json +87 -0
  3. package/lib/NOTICE.txt +140 -1226
  4. package/lib/commonjs/auth/AuthContext.js +74 -18
  5. package/lib/commonjs/auth/AuthContext.web.js +32 -0
  6. package/lib/commonjs/auth/completePowerAppsAuthSession.js +16 -0
  7. package/lib/commonjs/bridge/NativePowerAppsBridge.js +20 -17
  8. package/lib/commonjs/bridge/PowerPagesBridge.js +157 -0
  9. package/lib/commonjs/bridge/bridgeState.js +40 -0
  10. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  11. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  12. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  13. package/lib/commonjs/connections/connectionState.js +96 -0
  14. package/lib/commonjs/connections/disambiguate.js +19 -11
  15. package/lib/commonjs/connections/resolveConnections.js +347 -0
  16. package/lib/commonjs/connections/types.js +106 -0
  17. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +128 -65
  18. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  19. package/lib/commonjs/controls/FilePicker.js +6 -0
  20. package/lib/commonjs/controls/ImagePicker.js +8 -0
  21. package/lib/commonjs/index.js +188 -6
  22. package/lib/commonjs/logger.js +9 -6
  23. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  24. package/lib/commonjs/offline/useOfflineIntegration.js +12 -0
  25. package/lib/commonjs/offline/useOfflineIntegration.web.js +11 -0
  26. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +46 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  28. package/lib/commonjs/platform/DataverseDataSources.js +14 -0
  29. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +49 -0
  30. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  31. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  32. package/lib/commonjs/provider/PowerAppsHostProvider.js +156 -25
  33. package/lib/commonjs/provider/PowerAppsHostProvider.web.js +41 -0
  34. package/lib/commonjs/provider/PowerAppsProvider.js +229 -133
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +216 -0
  36. package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
  37. package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
  38. package/lib/commonjs/telemetry/index.js +22 -3
  39. package/lib/module/auth/AuthContext.js +74 -18
  40. package/lib/module/auth/AuthContext.web.js +26 -0
  41. package/lib/module/auth/completePowerAppsAuthSession.js +11 -0
  42. package/lib/module/bridge/NativePowerAppsBridge.js +21 -18
  43. package/lib/module/bridge/PowerPagesBridge.js +151 -0
  44. package/lib/module/bridge/bridgeState.js +34 -0
  45. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  46. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  47. package/lib/module/connections/connectionMetadata.js +112 -0
  48. package/lib/module/connections/connectionState.js +82 -0
  49. package/lib/module/connections/disambiguate.js +19 -12
  50. package/lib/module/connections/resolveConnections.js +342 -0
  51. package/lib/module/connections/types.js +91 -0
  52. package/lib/module/{platform → connections}/useConnectionRefs.js +129 -66
  53. package/lib/module/connections/useConnectionSetup.js +113 -54
  54. package/lib/module/controls/FilePicker.js +6 -0
  55. package/lib/module/controls/ImagePicker.js +8 -0
  56. package/lib/module/index.js +14 -6
  57. package/lib/module/logger.js +8 -6
  58. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  59. package/lib/module/offline/useOfflineIntegration.js +3 -0
  60. package/lib/module/offline/useOfflineIntegration.web.js +7 -0
  61. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +42 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  63. package/lib/module/platform/DataverseDataSources.js +10 -0
  64. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +45 -0
  65. package/lib/module/platform/GlobalDiscovery.js +45 -0
  66. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  67. package/lib/module/provider/PowerAppsHostProvider.js +159 -28
  68. package/lib/module/provider/PowerAppsHostProvider.web.js +36 -0
  69. package/lib/module/provider/PowerAppsProvider.js +233 -137
  70. package/lib/module/provider/SessionDetailsGesture.js +211 -0
  71. package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
  72. package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
  73. package/lib/module/telemetry/index.js +15 -4
  74. package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
  75. package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +21 -0
  76. package/lib/typescript/commonjs/auth/completePowerAppsAuthSession.d.ts +8 -0
  77. package/lib/typescript/commonjs/bridge/PowerPagesBridge.d.ts +18 -0
  78. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  79. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  80. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  81. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  82. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  83. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  84. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +19 -19
  85. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  86. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +33 -24
  87. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  88. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  89. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  90. package/lib/typescript/commonjs/index.d.ts +20 -10
  91. package/lib/typescript/commonjs/logger.d.ts +4 -4
  92. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  93. package/lib/typescript/commonjs/offline/useOfflineIntegration.d.ts +2 -0
  94. package/lib/typescript/commonjs/offline/useOfflineIntegration.web.d.ts +4 -0
  95. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  97. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +27 -0
  98. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  99. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  100. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  101. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.web.d.ts +5 -0
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +32 -10
  104. package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
  105. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  106. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  107. package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
  108. package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
  109. package/lib/typescript/module/auth/AuthContext.web.d.ts +21 -0
  110. package/lib/typescript/module/auth/completePowerAppsAuthSession.d.ts +8 -0
  111. package/lib/typescript/module/bridge/PowerPagesBridge.d.ts +18 -0
  112. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  113. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  114. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  115. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  116. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  117. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  118. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +19 -19
  119. package/lib/typescript/module/connections/types.d.ts +129 -1
  120. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +33 -24
  121. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  122. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  123. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  124. package/lib/typescript/module/index.d.ts +24 -14
  125. package/lib/typescript/module/logger.d.ts +4 -4
  126. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  127. package/lib/typescript/module/offline/useOfflineIntegration.d.ts +2 -0
  128. package/lib/typescript/module/offline/useOfflineIntegration.web.d.ts +4 -0
  129. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  131. package/lib/typescript/module/platform/DataverseDataSources.d.ts +27 -0
  132. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  133. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  134. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  135. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.web.d.ts +5 -0
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +34 -12
  138. package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
  139. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  140. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  141. package/lib/typescript/module/telemetry/index.d.ts +13 -1
  142. package/package.json +43 -18
  143. package/scripts/build-ios-base.js +66 -27
  144. package/scripts/bundle.js +212 -5
  145. package/scripts/generate-connector-schemas.js +8 -6
  146. package/scripts/metro-logger.js +213 -0
  147. package/scripts/start-web.mjs +137 -0
  148. package/scripts/upgrade/runtime.js +463 -0
  149. package/scripts/upgrade/system.js +244 -0
  150. package/scripts/upgrade-authoring.js +534 -0
  151. package/scripts/upgrade.js +188 -0
  152. package/scripts/wrap.js +536 -0
  153. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  154. package/lib/commonjs/platform/resolveConnections.js +0 -264
  155. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  156. package/lib/module/platform/resolveConnections.js +0 -259
@@ -7,14 +7,12 @@
7
7
  * These mirror the endpoints used by ConnectorsApi in @microsoft/power-apps-common
8
8
  * but are implemented as plain async functions so they have no external dependencies.
9
9
  */
10
- import type { NativeConnectionInstance } from '../connections/types';
10
+ import type { DatabaseReference } from '../platform/DataverseDataSources';
11
+ import type { ConnectionInput, ConnectionParameterSet, ConnectionRequirement, ConnectionUsageInput, NativeConnectionInstance, ResourceConsentRequirement } from './types';
11
12
  import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge';
12
- /**
13
- * Token scope for the Power Apps RP (api.powerapps.com).
14
- * Required when calling modifyPermissions to register a service principal
15
- * in the connection ACE so that APIM accepts third-party app tokens at runtime.
16
- */
17
- export declare const SERVICE_POWERAPPS_SCOPE = "https://service.powerapps.com/.default";
13
+ export declare class AppLaunchAccessDeniedError extends Error {
14
+ constructor();
15
+ }
18
16
  /** Subset of connector metadata returned by the Power Platform API. */
19
17
  export interface ConnectorMetadata {
20
18
  /** Short connector name, e.g. "shared_office365users". */
@@ -25,8 +23,15 @@ export interface ConnectorMetadata {
25
23
  iconUri: string;
26
24
  /** Description text. */
27
25
  description: string;
28
- /** Whether this is a first-party (Microsoft-published) connector. */
29
- isFirstParty: boolean;
26
+ /** Environment-specific APIM runtime URL used for connector requests. */
27
+ primaryRuntimeUrl: string;
28
+ scopes: {
29
+ will: string[];
30
+ wont: string[];
31
+ };
32
+ /** Whether the connector authenticates through an OAuth consent flow. */
33
+ hasOAuthParameter: boolean;
34
+ parameterSets: ConnectionParameterSet[];
30
35
  }
31
36
  /**
32
37
  * Fetch metadata for a single connector from the Power Platform API.
@@ -43,6 +48,8 @@ export declare function fetchConnectorMetadata(connectorId: string, environmentI
43
48
  * Returns only the `NativeConnectionInstance` shape used by the disambiguation layer.
44
49
  */
45
50
  export declare function fetchConnectionsForConnector(connectorId: string, environmentId: string, region: string, token: string): Promise<NativeConnectionInstance[]>;
51
+ /** Delete a single connection instance from the user's environment. */
52
+ export declare function deleteConnection(connectorId: string, connectionId: string, environmentId: string, region: string, token: string): Promise<boolean>;
46
53
  /**
47
54
  * Result of initiating an OAuth connection creation.
48
55
  *
@@ -51,8 +58,7 @@ export declare function fetchConnectionsForConnector(connectorId: string, enviro
51
58
  * user can complete the OAuth consent flow. Poll `pollConnectionStatus`
52
59
  * until the status changes to "Connected".
53
60
  *
54
- * `connected` — the connection was created and is already Connected (e.g.,
55
- * first-party SSO connections that do not need explicit OAuth consent).
61
+ * `connected` — the connection resource was created in Connected state.
56
62
  *
57
63
  * `error` — creation failed; `message` contains the error description.
58
64
  */
@@ -71,7 +77,7 @@ export type CreateConnectionResult = {
71
77
  * Create a new connection for a connector in the user's environment.
72
78
  *
73
79
  * Calls:
74
- * POST {envBase}/connectivity/apis/{connectorId}/connections
80
+ * PUT {envBase}/connectivity/connectors/{connectorId}/connections/{connectionId}
75
81
  *
76
82
  * If the response contains a `consentLink`, the connection needs OAuth
77
83
  * completion (caller should open the URL and then poll `pollConnectionStatus`).
@@ -86,7 +92,8 @@ export type CreateConnectionResult = {
86
92
  * will redirect the user here after consent. Defaults to
87
93
  * the standard native-client redirect accepted by Power Platform.
88
94
  */
89
- export declare function createConnection(connectorId: string, environmentId: string, region: string, token: string, displayName?: string, oauthRedirectUrl?: string): Promise<CreateConnectionResult>;
95
+ export declare function createConnection(connectorId: string, environmentId: string, region: string, token: string, displayName?: string, oauthRedirectUrl?: string, input?: ConnectionInput): Promise<CreateConnectionResult>;
96
+ export declare function repairConnection(connectorId: string, connectionName: string, environmentId: string, region: string, token: string, oauthRedirectUrl?: string, input?: ConnectionInput, requiresApiConsent?: boolean): Promise<CreateConnectionResult>;
90
97
  /**
91
98
  * Poll a connection's status until it is "Connected" or a timeout is reached.
92
99
  *
@@ -101,6 +108,7 @@ export declare function createConnection(connectorId: string, environmentId: str
101
108
  export declare function pollConnectionStatus(connectorId: string, connectionName: string, environmentId: string, region: string, acquireToken: (scopes: string[]) => Promise<string | null>, options?: {
102
109
  intervalMs?: number;
103
110
  timeoutMs?: number;
111
+ signal?: AbortSignal;
104
112
  }): Promise<NativeConnectionInstance | null>;
105
113
  /**
106
114
  * Confirm a consent code returned by the APIM consent server in the OAuth
@@ -141,13 +149,38 @@ export interface AppLaunchResult {
141
149
  * has no linked Dataverse database).
142
150
  */
143
151
  dataverseOrgUrl: string;
152
+ /** Dataverse table metadata returned by the app launch endpoint. */
153
+ databaseReferences: Record<string, DatabaseReference>;
144
154
  /**
145
155
  * Connector short-names (e.g. "shared_office365users") for which the
146
156
  * launch API found no "Connected" connection instance for the signed-in
147
157
  * user. These connectors need the connection setup flow.
148
158
  */
149
159
  missingConnectors: string[];
160
+ /** Missing requirements keyed by the app's local connection-reference ID. */
161
+ missingConnectionReferences: ConnectionRequirement[];
162
+ /** Every app requirement, including references resolved by the launch API. */
163
+ connectionRequirements: ConnectionRequirement[];
164
+ /** Connected candidates retained for explicit per-reference disambiguation. */
165
+ connectionCandidates: Record<string, NativeConnectionInstance[]>;
166
+ /** Non-connector protected resources requiring explicit user disclosure. */
167
+ resourceConsents: ResourceConsentRequirement[];
168
+ /** Configuration errors that make bridge connection binding ambiguous. */
169
+ configurationErrors: string[];
170
+ /** Durable app-to-connection bindings returned by launch or the app connections API. */
171
+ registeredConnectionUsages: RegisteredConnectionUsage[];
172
+ /** True when at least one selected local reference/action is not durably registered. */
173
+ requiresConnectionConsent: boolean;
174
+ }
175
+ export interface RegisteredConnectionUsage {
176
+ reference: string;
177
+ apiId: string;
178
+ connectionId: string;
179
+ appActions: string[];
150
180
  }
181
+ export declare function fetchAppConnectionUsages(appId: string, environmentId: string, region: string, token: string): Promise<RegisteredConnectionUsage[]>;
182
+ export declare function postConnectionUsage(appId: string, usage: ConnectionUsageInput, environmentId: string, region: string, token: string): Promise<void>;
183
+ export declare function reportScopeConsents(appId: string, usages: ConnectionUsageInput[], environmentId: string, region: string, token: string): Promise<void>;
151
184
  /**
152
185
  * Fetch app launch data from the Power Platform environment-scoped launch
153
186
  * endpoint and process it into the shape the NativePowerAppsBridge needs.
@@ -160,7 +193,7 @@ export interface AppLaunchResult {
160
193
  * — Dataverse org URL
161
194
  *
162
195
  * Endpoint (environment-scoped, same base as all Power Platform API calls):
163
- * GET {envEndpoint}/powerapps/apps/{appId}/launch
196
+ * POST {envEndpoint}/powerapps/apps/{appId}/launch
164
197
  * ?api-version=2&lastKnownGoodPublishedVersion=true
165
198
  *
166
199
  * Authentication: bearer token for {@link powerPlatformScope}`(region)`.
@@ -169,37 +202,13 @@ export interface AppLaunchResult {
169
202
  * @param environmentId - Environment GUID.
170
203
  * @param region - Cluster region (default "prod").
171
204
  * @param token - Bearer token for {@link powerPlatformScope}`(region)`.
172
- * @returns Processed launch data, or `null` if the call fails.
205
+ * @returns Processed launch data, or `null` when the app is not found.
173
206
  */
174
207
  export declare function fetchAppLaunchData(appId: string, environmentId: string, region: string, token: string): Promise<AppLaunchResult | null>;
175
208
  /**
176
- * Decode the `oid` (object ID) claim from a JWT access token.
177
- *
178
- * The oid claim is in the base64url-encoded payload section (middle part).
179
- * Available in Hermes (React Native) via the global `atob`.
180
- */
181
- export declare function parseJwtOid(jwtToken: string): string | null;
182
- /**
183
- * Add the ISV's AAD application (client) ID to the connection's ACL AppIds
184
- * list via the Power Apps RP `addAadAppToConnectionAcl` endpoint.
185
- *
186
- * The RP finds the user's existing ACE (identified by `userOid`) and appends
187
- * `isvClientId` to its `AppIds` list. APIM's stage-2 token check verifies
188
- * that the requesting token's `appid` is present in this list, so without
189
- * this call APIM returns 403 "missing connection ACL" for third-party tokens.
190
- *
191
- * POST https://api.powerapps.com/providers/Microsoft.PowerApps/environments/{environmentId}
192
- * /apis/{connectorId}/connections/{connectionId}/addAadAppToConnectionAcl
193
- * ?api-version=2016-11-01
194
- *
195
- * Body: { "aadApplicationId": "<ISV client ID>", "objectId": "<user OID>" }
196
- *
197
- * @param connectorId - Connector short name (e.g. "shared_office365users").
198
- * @param connectionId - Bare 32-char hex connection ID.
199
- * @param environmentId - Environment GUID.
200
- * @param isvClientId - The ISV's AAD application (client) ID.
201
- * @param userOid - The signed-in user's AAD object ID (oid JWT claim).
202
- * @param token - Bearer token for `https://service.powerapps.com/.default`.
209
+ * Grant the calling application's delegated access to a connection for the
210
+ * signed-in user. The backend derives both identities from the token and
211
+ * selects the most specific applicable user, group, or tenant ACL.
203
212
  */
204
- export declare function addAadAppToConnectionAcl(connectorId: string, connectionId: string, environmentId: string, isvClientId: string, userOid: string, token: string): Promise<boolean>;
213
+ export declare function grantConnectionUserConsent(connectorId: string, connectionId: string, environmentId: string, region: string, token: string): Promise<boolean>;
205
214
  //# sourceMappingURL=PowerPlatformConnectionApi.d.ts.map
@@ -0,0 +1,66 @@
1
+ import type { ConnectionInput, ConnectionParameterDefinition, ConnectionParameterSet, ConnectionUsageInput } from './types';
2
+ export interface ConsentLinkDefinition {
3
+ redirectUrl: string;
4
+ }
5
+ export type SerializedConnectionParameters = {
6
+ connectionParameters: ConnectionInput['parameters'];
7
+ } | {
8
+ connectionParametersSet: {
9
+ name: string;
10
+ values: Record<string, {
11
+ value: ConnectionInput['parameters'][string];
12
+ }>;
13
+ };
14
+ };
15
+ export interface RawConnectionParameter {
16
+ type?: string;
17
+ defaultValue?: string | boolean | number;
18
+ uiDefinition?: {
19
+ displayName?: string;
20
+ constraints?: {
21
+ required?: string | boolean;
22
+ hidden?: string | boolean;
23
+ capability?: string[];
24
+ allowedValues?: Array<{
25
+ value?: string;
26
+ displayName?: string;
27
+ }>;
28
+ };
29
+ };
30
+ }
31
+ export interface RawConnectionParameterSet {
32
+ name?: string;
33
+ uiDefinition?: {
34
+ displayName?: string;
35
+ };
36
+ connectionParameters?: Record<string, RawConnectionParameter>;
37
+ parameters?: Record<string, RawConnectionParameter>;
38
+ }
39
+ export declare function parseConnectionParameters(parameters: Record<string, RawConnectionParameter> | undefined): ConnectionParameterDefinition[];
40
+ export declare function buildConnectionParameterSets(connectionParameters: Record<string, RawConnectionParameter> | undefined, parameterSets: RawConnectionParameterSet[] | undefined): ConnectionParameterSet[];
41
+ export declare function hasOAuthParameter(parameters: Record<string, RawConnectionParameter> | undefined): boolean;
42
+ export declare function buildConnectionUserConsentUrl(environmentEndpoint: string, connectorId: string, connectionId: string): string;
43
+ export declare function getAppLaunchFailureMessage(status: number, statusText: string, responseText: string): string | null;
44
+ export declare function isAppLaunchAccessDenied(status: number, responseText: string): boolean;
45
+ export declare function buildConsentLinkDefinition(redirectUrl: string): ConsentLinkDefinition;
46
+ export declare function serializeConnectionParameters(input?: ConnectionInput): SerializedConnectionParameters;
47
+ export declare function buildConnectionUsageUrl(environmentBaseUrl: string, environmentId: string, usage: ConnectionUsageInput): string;
48
+ export declare function buildConnectionUsageRequest(appId: string, usage: ConnectionUsageInput): {
49
+ properties: {
50
+ reference: string;
51
+ resourceId: string;
52
+ appActions: string[];
53
+ };
54
+ };
55
+ export declare function buildScopeConsentUrl(environmentBaseUrl: string, appId: string): string;
56
+ export declare function buildScopeConsentRequest(usages: ConnectionUsageInput[]): {
57
+ consents: Array<{
58
+ connectionId: string;
59
+ consentType: 'userConsent';
60
+ scopes: {
61
+ will: string[];
62
+ wont: string[];
63
+ };
64
+ }>;
65
+ };
66
+ //# sourceMappingURL=connectionMetadata.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { AppLaunchResult } from './PowerPlatformConnectionApi';
2
+ import type { RegisteredConnectionUsage } from './PowerPlatformConnectionApi';
3
+ import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge';
4
+ import type { ConnectionRequirement } from './types';
5
+ export declare function isTransientConnectionConsentStatus(status: number): boolean;
6
+ export declare function shouldGrantConnectionUserConsent(requirement: Pick<ConnectionRequirement, 'sharedConnectionId'>, runningInDevPlayer: boolean): boolean;
7
+ export declare function getConnectionNamesRequiringAclGrant(connectionRefs: Record<string, AppConnectionReference>, connectionRequirements: ConnectionRequirement[]): string[];
8
+ export declare function invalidateFailedAclGrants(result: AppLaunchResult, failedConnectionNames: ReadonlySet<string>): void;
9
+ export declare function selectLaunchConnection(result: AppLaunchResult, localRefId: string, connectionId: string): boolean;
10
+ export declare function getUnregisteredConnectionRequirements(result: AppLaunchResult, usages?: RegisteredConnectionUsage[]): ConnectionRequirement[];
11
+ export declare function applyRegisteredConnectionSelections(result: AppLaunchResult, usages: RegisteredConnectionUsage[]): void;
12
+ export declare function hasRegisteredConnectionConsent(result: AppLaunchResult, usages?: RegisteredConnectionUsage[]): boolean;
13
+ export declare function applyRegisteredConnectionUsages(result: AppLaunchResult, usages: RegisteredConnectionUsage[]): void;
14
+ export declare function shouldPersistConnectionUsages(runningInDevPlayer: boolean, appId: string | undefined): boolean;
15
+ export declare function shouldShowConnectionReview(runningInDevPlayer: boolean, requiresConnectionConsent: boolean, hasResourceConsents: boolean): boolean;
16
+ //# sourceMappingURL=connectionState.d.ts.map
@@ -27,6 +27,7 @@ import type { NativeConnectionInstance, NativeConnectionResolution } from './typ
27
27
  export declare function disambiguateConnections(connectionReferences: Record<string, {
28
28
  id: string;
29
29
  dataSources: string[];
30
+ sharedConnectionId?: string;
30
31
  }>, allConnectionsByApiId: Record<string, NativeConnectionInstance[]>): NativeConnectionResolution[];
31
32
  /**
32
33
  * Extract the connection UUID from a raw connection name returned by the API.
@@ -36,8 +37,9 @@ export declare function disambiguateConnections(connectionReferences: Record<str
36
37
  * "abc12345def6789012345678901234ab" (bare UUID, no dashes)
37
38
  * "abc12345-def6-7890-1234-5678901234ab" (UUID with dashes)
38
39
  *
39
- * Returns the 32-char hex ID (dashes stripped) or the raw string if no UUID
40
- * pattern is found.
40
+ * Returns the terminal resource name exactly as supplied by Power Platform.
41
+ * Some connectors require dashed GUIDs while others use compact IDs.
41
42
  */
42
43
  export declare function extractConnectionId(rawName: string): string;
44
+ export declare function connectionIdsEqual(left: string, right: string): boolean;
43
45
  //# sourceMappingURL=disambiguate.d.ts.map
@@ -5,19 +5,18 @@
5
5
  * useConnectionRefs:
6
6
  *
7
7
  * • resolveViaStaticRefs — per-connector resolution using the static
8
- * connectionReferences map from power.config.json. Used by the Dev Player
9
- * and during local development (no appId) or when the launch API is
10
- * unavailable. Handles pre-disambiguation ACL grants so inaccessible
11
- * connections are excluded before the user is asked to pick.
8
+ * connectionReferences map from power.config.json. Used only by Dev Player
9
+ * for unpublished local apps. Handles pre-disambiguation ACL grants so
10
+ * inaccessible connections are excluded before the user is asked to pick.
12
11
  *
13
- * • applyAclGrants — post-resolution ACL grants used by the fast path
12
+ * • applyAclGrants — post-resolution user consent used by the fast path
14
13
  * (production APKs via fetchAppLaunchData).
15
14
  *
16
15
  * Both helpers return / consume the shared AppLaunchResult shape so the
17
16
  * hook orchestrator can handle them uniformly.
18
17
  */
19
18
  import type { AppLaunchResult } from './PowerPlatformConnectionApi';
20
- import type { OnDisambiguationNeeded, OnMissingConnection } from '../connections/types';
19
+ import type { ConnectionReferenceConfig, ConnectionRequirement, OnDisambiguationNeeded, OnMissingConnection } from './types';
21
20
  import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge';
22
21
  /**
23
22
  * Connector schema entry generated by `generate-connector-schemas`.
@@ -28,6 +27,10 @@ export interface ConnectorSchema {
28
27
  name: string;
29
28
  properties: {
30
29
  primaryRuntimeUrl: string;
30
+ scopes?: {
31
+ will?: string[];
32
+ wont?: string[];
33
+ };
31
34
  };
32
35
  }
33
36
  export interface StaticRefsOptions {
@@ -35,19 +38,16 @@ export interface StaticRefsOptions {
35
38
  * Static connectionReferences from power.config.json.
36
39
  * Shape: { [refId]: { id: string; dataSources: string[] } }
37
40
  */
38
- connectionReferences: Record<string, {
39
- id: string;
40
- dataSources: string[];
41
- }>;
41
+ connectionReferences: Record<string, ConnectionReferenceConfig>;
42
42
  /** Connector schema map keyed by data source name. */
43
43
  schemaMap: Record<string, ConnectorSchema>;
44
44
  environmentId: string;
45
45
  region: string;
46
- /** Used for ACL grants and the Dataverse instanceUrl fetch. */
46
+ /** Used for connection consent and the Dataverse instanceUrl fetch. */
47
47
  acquireToken: (scopes: string[]) => Promise<string | null>;
48
48
  /** Pre-acquired Power Platform API bearer token. */
49
49
  token: string;
50
- /** ISV client ID — when provided, runs pre-disambiguation ACL grants. */
50
+ /** ISV client ID — when provided, runs pre-disambiguation user consent. */
51
51
  isvClientId?: string;
52
52
  onDisambiguationNeeded?: OnDisambiguationNeeded;
53
53
  onMissingConnection?: OnMissingConnection;
@@ -59,7 +59,7 @@ export interface StaticRefsOptions {
59
59
  * 1. Build an apiId → schema lookup.
60
60
  * 2. In parallel: fetch the Dataverse instanceUrl and all connection instances
61
61
  * for every connector.
62
- * 3. If `isvClientId` is set, run pre-disambiguation ACL grants — connections
62
+ * 3. If `isvClientId` is set, run pre-disambiguation user consent — connections
63
63
  * where the grant fails are marked `NeedsAclGrant` and excluded from
64
64
  * resolution, prompting the user to create a new connection.
65
65
  * 4. Disambiguate: resolve single matches, invoke callbacks for ambiguous /
@@ -69,18 +69,18 @@ export interface StaticRefsOptions {
69
69
  */
70
70
  export declare function resolveViaStaticRefs({ connectionReferences, schemaMap, environmentId, region, acquireToken, token, isvClientId, onDisambiguationNeeded, onMissingConnection, }: StaticRefsOptions): Promise<AppLaunchResult>;
71
71
  /**
72
- * Run idempotent post-resolution ACL grants on behalf of the ISV app.
72
+ * Run idempotent post-resolution delegated consent grants for the calling app.
73
73
  *
74
74
  * Used by the fast path (production APKs via `fetchAppLaunchData`) where the
75
- * launch API has already resolved the user's connections — grants are applied
76
- * after the fact so APIM accepts tokens issued to the ISV's AAD app.
75
+ * launch API has already resolved the user's connections. Grants are applied
76
+ * only to user-selected connections; fixed shared connections are already
77
+ * authorized by their owner and must not receive delegated user consent.
77
78
  *
78
79
  * For the slow path the grants run before disambiguation inside
79
80
  * `resolveViaStaticRefs`, where they can still influence which connections
80
81
  * are considered available.
81
82
  *
82
- * Failures are swallowed — a failed grant will surface as a 403 at runtime
83
- * when the connector is called.
83
+ * Returns the connection names whose ACL grants failed so callers can fail closed.
84
84
  */
85
- export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, environmentId: string, isvClientId: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<void>;
85
+ export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, connectionRequirements: ConnectionRequirement[], environmentId: string, region: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<Set<string>>;
86
86
  //# sourceMappingURL=resolveConnections.d.ts.map
@@ -17,18 +17,146 @@ export declare enum ConnectionStatus {
17
17
  NeedsAclGrant = "NeedsAclGrant",
18
18
  NotConnected = "NotConnected"
19
19
  }
20
+ export interface ConnectionReferenceConfig {
21
+ id: string;
22
+ dataSources: string[];
23
+ displayName?: string;
24
+ iconUri?: string;
25
+ appActions?: string[];
26
+ sharedConnectionId?: string;
27
+ gatewayObjectIdHint?: string;
28
+ authenticationType?: string;
29
+ parameterSetName?: string;
30
+ workflowDetails?: {
31
+ workflowEntityId?: string;
32
+ workflowDisplayName?: string;
33
+ workflowName?: string;
34
+ };
35
+ dataSets?: Record<string, unknown>;
36
+ dependencies?: Record<string, unknown>;
37
+ dependents?: string[];
38
+ nestedActions?: Array<{
39
+ actionName?: string;
40
+ apiName?: string;
41
+ flowConnectionRef?: string;
42
+ }>;
43
+ parameterHintsV2?: Record<string, {
44
+ value?: unknown;
45
+ }>;
46
+ [key: string]: unknown;
47
+ }
48
+ export interface ConnectionRequirement {
49
+ localRefId: string;
50
+ apiId: string;
51
+ connectorId: string;
52
+ dataSources: string[];
53
+ displayName?: string;
54
+ iconUri?: string;
55
+ appActions?: string[];
56
+ sharedConnectionId?: string;
57
+ gatewayObjectIdHint?: string;
58
+ authenticationType?: string;
59
+ parameterSetName?: string;
60
+ apiScopes: {
61
+ will: string[];
62
+ wont: string[];
63
+ };
64
+ isFlowDependent: boolean;
65
+ }
66
+ export type ConnectionParameterType = 'string' | 'securestring' | 'boolean' | 'integer' | 'clientcertificate';
67
+ export interface ConnectionParameterDefinition {
68
+ name: string;
69
+ displayName: string;
70
+ type: ConnectionParameterType;
71
+ required: boolean;
72
+ hidden: boolean;
73
+ capabilities?: string[];
74
+ allowedValues?: Array<{
75
+ value: string;
76
+ displayName: string;
77
+ }>;
78
+ defaultValue?: string | boolean | number;
79
+ }
80
+ export interface ConnectionParameterSet {
81
+ /** Undefined for a connector's single, non-parameter-set authentication definition. */
82
+ name?: string;
83
+ displayName: string;
84
+ parameters: ConnectionParameterDefinition[];
85
+ requiresApiConsent: boolean;
86
+ gatewayParameterName?: string;
87
+ }
88
+ export type ConnectionParameterValue = string | boolean | number | {
89
+ pfx: string;
90
+ password: string;
91
+ } | {
92
+ gatewayObjectId: string;
93
+ };
94
+ export interface ConnectionInput {
95
+ parameterSetName?: string;
96
+ gatewayObjectId?: string;
97
+ gatewayParameterName?: string;
98
+ parameters: Record<string, ConnectionParameterValue>;
99
+ }
100
+ export interface ConnectionConsentDetails {
101
+ localRefId: string;
102
+ connectorId: string;
103
+ displayName: string;
104
+ description: string;
105
+ appActions: string[];
106
+ }
107
+ export interface ResourceConsentRequirement {
108
+ resourceId: string;
109
+ displayName: string;
110
+ }
111
+ export interface ConnectionUsageInput {
112
+ localRefId: string;
113
+ apiId: string;
114
+ connectionId: string;
115
+ dataSources: string[];
116
+ appActions: string[];
117
+ apiScopes: {
118
+ will: string[];
119
+ wont: string[];
120
+ };
121
+ }
122
+ export declare function normalizeApiId(apiId: string): string;
123
+ export declare function getConnectorId(apiId: string): string;
124
+ export declare function getConnectionDatasetName(reference: {
125
+ dataSets?: Record<string, unknown>;
126
+ }): string;
127
+ export declare function getFlowConnectionName(reference: ConnectionReferenceConfig): string;
128
+ export declare function getFlowDataSourceNames(reference: ConnectionReferenceConfig): string[];
129
+ export declare function buildConnectionRequirements(connectionReferences: Record<string, ConnectionReferenceConfig>, scopesByApiId?: Record<string, {
130
+ will: string[];
131
+ wont: string[];
132
+ }>): ConnectionRequirement[];
133
+ export declare function isCompositeConnectionApiId(apiId: string): boolean;
134
+ export declare function findConnectionDataSourceConflicts(requirements: ConnectionRequirement[]): string[];
135
+ export declare function hasCompleteStaticConnectionConfig(connectionReferences: Record<string, ConnectionReferenceConfig>, schemaMap: Record<string, {
136
+ name: string;
137
+ properties: {
138
+ primaryRuntimeUrl: string;
139
+ };
140
+ }>): boolean;
141
+ export declare function buildConnectionResolutionKey(appId: string | undefined, environmentId: string, connectionReferences: Record<string, ConnectionReferenceConfig>): string;
20
142
  /** A single connection instance returned by the Power Platform connectivity API. */
21
143
  export interface NativeConnectionInstance {
22
- /** Extracted connection UUID (hex, no dashes). */
144
+ /** Terminal connection resource name exactly as returned by Power Platform. */
23
145
  id: string;
24
146
  /** Full resource name from the API (connector-prefixed, e.g. "shared_office365users/abc123"). */
25
147
  name: string;
26
148
  /** Connector API identifier (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
27
149
  apiId: string;
150
+ /** Object ID of the connection owner when returned by the connectivity API. */
151
+ ownerId?: string;
28
152
  /** Resolved authorization status of this connection. */
29
153
  status: ConnectionStatus;
30
154
  /** Optional human-readable display name from the API. */
31
155
  displayName?: string;
156
+ accountName?: string;
157
+ parameterSetName?: string;
158
+ isAuthenticated?: boolean;
159
+ statusErrorCode?: string;
32
160
  }
33
161
  /**
34
162
  * Result of attempting to match a single connection reference to an instance.
@@ -30,9 +30,12 @@
30
30
  * },
31
31
  * });
32
32
  */
33
- import { type OnDisambiguationNeeded, type OnMissingConnection } from '../connections/types';
33
+ import type { DatabaseReference } from '../platform/DataverseDataSources';
34
+ import type { OnDisambiguationNeeded, OnMissingConnection } from '../connections/types';
34
35
  import type { ConnectorSchema } from './resolveConnections';
35
36
  import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge';
37
+ import type { ConnectionRequirement, ResourceConsentRequirement } from './types';
38
+ import type { ConnectionReferenceConfig } from './types';
36
39
  export type { ConnectorSchema } from './resolveConnections';
37
40
  export interface UseConnectionRefsOptions {
38
41
  isSignedIn: boolean;
@@ -46,23 +49,19 @@ export interface UseConnectionRefsOptions {
46
49
  region?: string;
47
50
  /**
48
51
  * PowerApps app GUID (from power.config.json `appId`).
49
- * When provided (and not running inside the Dev Player), connection
50
- * references are fetched at runtime from the PowerApps RP
51
- * `/apps/{appId}/launch` endpoint and take precedence over the static
52
- * `connectionReferences` object below.
53
- * Leave undefined during local development to use the static fallback.
52
+ * Outside Dev Player, app and connection metadata is fetched exclusively
53
+ * from the PowerApps RP `/apps/{appId}/launch` endpoint.
54
54
  */
55
55
  appId?: string;
56
56
  /**
57
57
  * The connectionReferences map from power.config.json.
58
+ * Used only in Dev Player for unpublished local apps.
58
59
  * Shape: { [refId]: { id: string; dataSources: string[] } }
59
60
  */
60
- connectionReferences: Record<string, {
61
- id: string;
62
- dataSources: string[];
63
- }>;
61
+ connectionReferences: Record<string, ConnectionReferenceConfig>;
64
62
  /**
65
63
  * Connector schema map keyed by data source name.
64
+ * Used only in Dev Player for unpublished local apps.
66
65
  * Generated automatically by generate-connector-schemas.
67
66
  * Shape: { [dataSourceName]: ConnectorSchema }
68
67
  */
@@ -80,10 +79,11 @@ export interface UseConnectionRefsOptions {
80
79
  */
81
80
  onMissingConnection?: OnMissingConnection;
82
81
  /**
83
- * The ISV's AAD application (client) ID. When provided, each resolved
84
- * `Connected` connection is checked via `addAadAppToConnectionAcl`.
82
+ * The ISV's AAD application (client) ID. When provided, each user-selected
83
+ * `Connected` connection is granted through delegated user consent. Fixed
84
+ * shared connections skip this grant in published apps.
85
85
  * Connections where the grant fails are marked `NeedsAclGrant` and treated
86
- * as missing so the setup screen can guide the user to create a new one.
86
+ * as missing so the setup screen can guide the user to create a new one.
87
87
  */
88
88
  isvClientId?: string;
89
89
  }
@@ -91,12 +91,25 @@ export interface UseConnectionRefsResult {
91
91
  connectionRefs: Record<string, AppConnectionReference>;
92
92
  isReady: boolean;
93
93
  error: string | null;
94
+ errorKind: ConnectionResolutionErrorKind | null;
94
95
  /**
95
96
  * API IDs of connectors for which no connection was found (or the user did
96
97
  * not resolve during disambiguation). Useful for surfacing a "Set up
97
98
  * connections" prompt in the app UI.
98
99
  */
99
100
  missingConnectors: string[];
101
+ /** Unresolved requirements keyed by the app's local connection-reference ID. */
102
+ missingConnectionReferences: ConnectionRequirement[];
103
+ /** Every connection reference required by the app. */
104
+ connectionRequirements: ConnectionRequirement[];
105
+ /** Non-connector protected resources returned by app launch metadata. */
106
+ resourceConsents: ResourceConsentRequirement[];
107
+ /** Blocking connection configuration errors. */
108
+ configurationErrors: string[];
109
+ /** Whether selected connection references still need durable app usage consent. */
110
+ requiresConnectionConsent: boolean;
111
+ /** Identity of the app/environment/config represented by this result. */
112
+ resolvedConfigKey: string | null;
100
113
  /**
101
114
  * The Dataverse org URL for this environment (e.g. "https://org12345.crm.dynamics.com").
102
115
  * Fetched from the Power Platform environment metadata independently of whether a
@@ -104,23 +117,19 @@ export interface UseConnectionRefsResult {
104
117
  * Empty string until isReady is true or if the environment has no linked Dataverse database.
105
118
  */
106
119
  dataverseOrgUrl: string;
120
+ /** Database references resolved from the RP launch response. */
121
+ databaseReferences: Record<string, DatabaseReference>;
107
122
  }
123
+ export type ConnectionResolutionErrorKind = 'app-access-denied' | 'generic';
108
124
  /**
109
125
  * Resolves Power Platform connection references for the current user, with
110
126
  * disambiguation support for environments where multiple connections exist for
111
127
  * the same connector.
112
128
  *
113
- * On sign-in this hook:
114
- * 1. If `appId` is set (production template), fetches connection references
115
- * from the PowerApps RP `/apps/{appId}/launch` endpoint and uses those
116
- * in place of the static `connectionReferences` from power.config.json.
117
- * 2. Acquires a Power Platform API token.
118
- * 3. In parallel: fetches the Dataverse instanceUrl and ALL connections for
119
- * each configured connector.
120
- * 4. Runs disambiguation: resolves single matches, invokes `onDisambiguationNeeded`
121
- * for multiple matches, and invokes `onMissingConnection` for absent ones.
122
- * 5. Pre-warms the Dataverse token in the MSAL cache.
123
- * 6. Sets isReady=true with the fully-populated connections map.
129
+ * Outside Dev Player, the published app launch endpoint is authoritative.
130
+ * Dev Player resolves unpublished local references through per-connector APIs.
131
+ * Both paths disambiguate candidates, pre-warm Dataverse authentication, and
132
+ * return a fully populated bridge configuration.
124
133
  */
125
134
  export declare function useConnectionRefs({ isSignedIn, acquireToken, appId, environmentId, region, connectionReferences, schemaMap, onDisambiguationNeeded, onMissingConnection, isvClientId, }: UseConnectionRefsOptions): UseConnectionRefsResult;
126
135
  //# sourceMappingURL=useConnectionRefs.d.ts.map