@microsoft/power-apps-native-host 0.2.25 → 0.3.3

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 (154) hide show
  1. package/README.md +21 -10
  2. package/compatibility/current.json +31 -4
  3. package/lib/NOTICE.txt +1325 -24
  4. package/lib/commonjs/auth/AuthContext.js +110 -33
  5. package/lib/commonjs/bridge/NativePowerAppsBridge.js +11 -18
  6. package/lib/commonjs/bridge/PowerPagesBridge.js +27 -8
  7. package/lib/commonjs/bridge/bridgeState.js +40 -0
  8. package/lib/commonjs/config/babelConfig.js +13 -0
  9. package/lib/commonjs/config/expoConfig.js +71 -0
  10. package/lib/commonjs/config/metroConfig.js +70 -0
  11. package/lib/commonjs/config/metroLogger.js +182 -0
  12. package/lib/commonjs/config/tamaguiConfig.js +98 -0
  13. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  14. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  15. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  16. package/lib/commonjs/connections/connectionState.js +96 -0
  17. package/lib/commonjs/connections/disambiguate.js +19 -11
  18. package/lib/commonjs/connections/resolveConnections.js +348 -0
  19. package/lib/commonjs/connections/types.js +106 -0
  20. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +130 -65
  21. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  22. package/lib/commonjs/controls/FilePicker.js +6 -0
  23. package/lib/commonjs/controls/ImagePicker.js +8 -0
  24. package/lib/commonjs/index.js +167 -4
  25. package/lib/commonjs/logger.js +9 -6
  26. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +48 -0
  28. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  29. package/lib/commonjs/platform/DataverseDataSources.js +18 -0
  30. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +94 -0
  31. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  32. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  33. package/lib/commonjs/provider/PowerAppsHostProvider.js +157 -25
  34. package/lib/commonjs/provider/PowerAppsProvider.js +178 -134
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +208 -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 +110 -33
  40. package/lib/module/bridge/NativePowerAppsBridge.js +12 -19
  41. package/lib/module/bridge/PowerPagesBridge.js +27 -8
  42. package/lib/module/bridge/bridgeState.js +34 -0
  43. package/lib/module/config/babelConfig.js +9 -0
  44. package/lib/module/config/expoConfig.js +67 -0
  45. package/lib/module/config/metroConfig.js +65 -0
  46. package/lib/module/config/metroLogger.js +175 -0
  47. package/lib/module/config/tamaguiConfig.js +93 -0
  48. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  49. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  50. package/lib/module/connections/connectionMetadata.js +112 -0
  51. package/lib/module/connections/connectionState.js +82 -0
  52. package/lib/module/connections/disambiguate.js +19 -12
  53. package/lib/module/connections/resolveConnections.js +343 -0
  54. package/lib/module/connections/types.js +91 -0
  55. package/lib/module/{platform → connections}/useConnectionRefs.js +131 -66
  56. package/lib/module/connections/useConnectionSetup.js +113 -54
  57. package/lib/module/controls/FilePicker.js +6 -0
  58. package/lib/module/controls/ImagePicker.js +8 -0
  59. package/lib/module/index.js +14 -4
  60. package/lib/module/logger.js +8 -6
  61. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +44 -0
  63. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  64. package/lib/module/platform/DataverseDataSources.js +13 -0
  65. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +89 -0
  66. package/lib/module/platform/GlobalDiscovery.js +45 -0
  67. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  68. package/lib/module/provider/PowerAppsHostProvider.js +160 -28
  69. package/lib/module/provider/PowerAppsProvider.js +182 -138
  70. package/lib/module/provider/SessionDetailsGesture.js +203 -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 +1 -0
  76. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  77. package/lib/typescript/commonjs/config/babelConfig.d.ts +12 -0
  78. package/lib/typescript/commonjs/config/expoConfig.d.ts +21 -0
  79. package/lib/typescript/commonjs/config/metroConfig.d.ts +6 -0
  80. package/lib/typescript/commonjs/config/metroLogger.d.ts +21 -0
  81. package/lib/typescript/commonjs/config/tamaguiConfig.d.ts +1792 -0
  82. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  83. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  84. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  85. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  86. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  87. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +22 -20
  88. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  89. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +36 -25
  90. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  91. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  92. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  93. package/lib/typescript/commonjs/index.d.ts +18 -10
  94. package/lib/typescript/commonjs/logger.d.ts +4 -4
  95. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  97. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  98. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +28 -0
  99. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  100. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  101. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +54 -9
  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 +1 -0
  110. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  111. package/lib/typescript/module/config/babelConfig.d.ts +12 -0
  112. package/lib/typescript/module/config/expoConfig.d.ts +21 -0
  113. package/lib/typescript/module/config/metroConfig.d.ts +6 -0
  114. package/lib/typescript/module/config/metroLogger.d.ts +21 -0
  115. package/lib/typescript/module/config/tamaguiConfig.d.ts +1792 -0
  116. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  117. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  118. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  119. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  120. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  121. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +22 -20
  122. package/lib/typescript/module/connections/types.d.ts +129 -1
  123. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +36 -25
  124. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  125. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  126. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  127. package/lib/typescript/module/index.d.ts +18 -10
  128. package/lib/typescript/module/logger.d.ts +4 -4
  129. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  131. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  132. package/lib/typescript/module/platform/DataverseDataSources.d.ts +28 -0
  133. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  134. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  135. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +54 -9
  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 +52 -13
  143. package/scripts/build-codegen-package.js +283 -0
  144. package/scripts/start-web.mjs +9 -5
  145. package/scripts/upgrade/runtime.js +139 -24
  146. package/scripts/upgrade-authoring.js +274 -180
  147. package/scripts/upgrade.js +10 -16
  148. package/src/config/generated-config.d.ts +4 -0
  149. package/src/config/index.d.ts +3 -0
  150. package/src/config/tsconfig.json +26 -0
  151. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  152. package/lib/commonjs/platform/resolveConnections.js +0 -264
  153. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  154. package/lib/module/platform/resolveConnections.js +0 -259
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useConnectionSetup = useConnectionSetup;
7
7
  var _react = require("react");
8
- var _PowerPlatformConnectionApi = require("../platform/PowerPlatformConnectionApi.js");
8
+ var _PowerPlatformConnectionApi = require("./PowerPlatformConnectionApi.js");
9
9
  var _PowerPlatformEnvironmentApi = require("../platform/PowerPlatformEnvironmentApi.js");
10
10
  var _disambiguate = require("../connections/disambiguate.js");
11
+ var _connectionState = require("./connectionState.js");
12
+ var _isDevPlayer = require("../utils/isDevPlayer.js");
11
13
  var _logger = require("../logger.js");
12
14
  var _index = require("../telemetry/index.js");
13
15
  /*!
@@ -55,7 +57,7 @@ function useConnectionSetup({
55
57
  region = 'prod',
56
58
  acquireToken,
57
59
  onConnected,
58
- isvClientId,
60
+ sharedConnectionId,
59
61
  oauthRedirectUrl,
60
62
  polling
61
63
  }) {
@@ -67,44 +69,53 @@ function useConnectionSetup({
67
69
  const connectionNameRef = (0, _react.useRef)(null);
68
70
  // Prevent concurrent startCreate / checkNow calls.
69
71
  const inFlightRef = (0, _react.useRef)(false);
72
+ const operationRef = (0, _react.useRef)(null);
73
+ const beginOperation = (0, _react.useCallback)(() => {
74
+ operationRef.current?.abort();
75
+ const controller = new AbortController();
76
+ operationRef.current = controller;
77
+ return controller;
78
+ }, []);
79
+ (0, _react.useEffect)(() => () => operationRef.current?.abort(), []);
70
80
  const handleConnected = (0, _react.useCallback)(async instance => {
71
81
  setPhase('connected');
72
82
  setConsentUrl(null);
83
+ if (!(0, _connectionState.shouldGrantConnectionUserConsent)({
84
+ sharedConnectionId
85
+ }, _isDevPlayer.isDevPlayer)) {
86
+ onConnected?.(instance);
87
+ return;
88
+ }
73
89
 
74
- // The RP auto-writes the user as Owner when a connection is created.
75
- // However, APIM also checks that the requesting appid is present in the
76
- // ACE's AppIds list. For third-party ISV tokens this is never populated
77
- // automatically — we must explicitly add the ISV's client ID to the
78
- // connection ACL so that APIM accepts tokens bearing that appid at runtime.
79
- if (isvClientId) {
80
- const paToken = await acquireToken([_PowerPlatformConnectionApi.SERVICE_POWERAPPS_SCOPE]);
81
- const userOid = paToken ? (0, _PowerPlatformConnectionApi.parseJwtOid)(paToken) : null;
82
- if (!paToken || !userOid) {
83
- setPhase('error');
84
- setErrorMessage('Connection was created, but access could not be granted to this app. Please try again.');
85
- (0, _logger.debugWarn)('[useConnectionSetup] could not grant connection ACL: missing Power Apps token or user OID');
86
- (0, _index.getAppLogger)().trackErrorEvent(_index.HostOperationNames.PlatformConnectionAclGrant, {
87
- phase: 'setupConnectionAcl',
88
- reason: !paToken ? 'missingPowerAppsToken' : 'missingUserOid'
89
- });
90
- return;
91
- }
92
- const aclGranted = await (0, _PowerPlatformConnectionApi.addAadAppToConnectionAcl)(connectorId, instance.id, environmentId, isvClientId, userOid, paToken);
93
- if (!aclGranted) {
94
- setPhase('error');
95
- setErrorMessage('Connection was created, but access could not be granted to this app. Please try again.');
96
- (0, _index.getAppLogger)().trackErrorEvent(_index.HostOperationNames.PlatformConnectionAclGrant, {
97
- phase: 'setupConnectionAcl',
98
- reason: 'aclGrantRejected'
99
- });
100
- return;
101
- }
90
+ // APIM checks the requesting appid against the user's effective ACL.
91
+ // User consent lets RP select the applicable direct, group, or tenant ACL.
92
+ const consentToken = await acquireToken([(0, _PowerPlatformEnvironmentApi.connectionUserConsentScope)(region)]);
93
+ if (!consentToken) {
94
+ setPhase('error');
95
+ setErrorMessage('Connection was created, but access could not be granted to this app. Please try again.');
96
+ (0, _logger.debugWarn)('[useConnectionSetup] could not grant connection consent: missing Power Platform token');
97
+ (0, _index.getAppLogger)().trackErrorEvent(_index.HostOperationNames.PlatformConnectionAclGrant, {
98
+ phase: 'setupConnectionAcl',
99
+ reason: 'missingPowerPlatformToken'
100
+ });
101
+ return;
102
+ }
103
+ const aclGranted = await (0, _PowerPlatformConnectionApi.grantConnectionUserConsent)(connectorId, instance.id, environmentId, region, consentToken);
104
+ if (!aclGranted) {
105
+ setPhase('error');
106
+ setErrorMessage('Connection was created, but access could not be granted to this app. Please try again.');
107
+ (0, _index.getAppLogger)().trackErrorEvent(_index.HostOperationNames.PlatformConnectionAclGrant, {
108
+ phase: 'setupConnectionAcl',
109
+ reason: 'aclGrantRejected'
110
+ });
111
+ return;
102
112
  }
103
113
  onConnected?.(instance);
104
- }, [onConnected, acquireToken, connectorId, environmentId, isvClientId]);
105
- const startCreate = (0, _react.useCallback)(async () => {
114
+ }, [onConnected, acquireToken, connectorId, environmentId, region, sharedConnectionId]);
115
+ const startCreate = (0, _react.useCallback)(async input => {
106
116
  if (inFlightRef.current) return;
107
117
  inFlightRef.current = true;
118
+ const operation = beginOperation();
108
119
  setPhase('creating');
109
120
  setErrorMessage(null);
110
121
  setConsentUrl(null);
@@ -116,7 +127,7 @@ function useConnectionSetup({
116
127
  setErrorMessage('Failed to acquire authentication token');
117
128
  return;
118
129
  }
119
- const result = await (0, _PowerPlatformConnectionApi.createConnection)(connectorId, environmentId, region, token, undefined, oauthRedirectUrl);
130
+ const result = await (0, _PowerPlatformConnectionApi.createConnection)(connectorId, environmentId, region, token, undefined, oauthRedirectUrl, input);
120
131
  if (result.status === 'error') {
121
132
  setPhase('error');
122
133
  setErrorMessage(result.message);
@@ -127,10 +138,11 @@ function useConnectionSetup({
127
138
  // Connection is already Connected — poll once to get the full instance.
128
139
  const instance = await (0, _PowerPlatformConnectionApi.pollConnectionStatus)(connectorId, result.connectionName, environmentId, region, acquireToken, {
129
140
  timeoutMs: 10_000,
130
- ...polling
141
+ ...polling,
142
+ signal: operation.signal
131
143
  });
132
144
  if (instance) {
133
- handleConnected(instance);
145
+ await handleConnected(instance);
134
146
  } else {
135
147
  // Already created but not Connected yet — treat as oauth phase without a URL.
136
148
  setPhase('oauth');
@@ -141,36 +153,77 @@ function useConnectionSetup({
141
153
  // status === 'pending': show the OAuth URL in a WebView.
142
154
  setConsentUrl(result.consentLink);
143
155
  setPhase('oauth');
144
-
145
- // Start background polling immediately — the user may finish OAuth quickly.
146
- const instance = await (0, _PowerPlatformConnectionApi.pollConnectionStatus)(connectorId, result.connectionName, environmentId, region, acquireToken, polling);
147
-
148
- // If the phase changed while we were polling (e.g., user dismissed WebView
149
- // and checkNow already resolved it), don't override.
150
- if (instance && phase !== 'connected') {
151
- handleConnected(instance);
152
- } else if (!instance && phase !== 'connected') {
156
+ } finally {
157
+ inFlightRef.current = false;
158
+ }
159
+ }, [connectorId, environmentId, region, acquireToken, polling, handleConnected, beginOperation]);
160
+ const startRepair = (0, _react.useCallback)(async (instance, input, requiresApiConsent = true) => {
161
+ if (inFlightRef.current) return;
162
+ inFlightRef.current = true;
163
+ const operation = beginOperation();
164
+ setPhase('creating');
165
+ setErrorMessage(null);
166
+ setConsentUrl(null);
167
+ connectionNameRef.current = instance.name;
168
+ try {
169
+ const token = await acquireToken([(0, _PowerPlatformEnvironmentApi.powerPlatformScope)(region)]);
170
+ if (!token) {
171
+ setPhase('error');
172
+ setErrorMessage('Failed to acquire authentication token');
173
+ return;
174
+ }
175
+ const result = await (0, _PowerPlatformConnectionApi.repairConnection)(connectorId, instance.name, environmentId, region, token, oauthRedirectUrl, input, requiresApiConsent);
176
+ if (result.status === 'error') {
153
177
  setPhase('error');
154
- setErrorMessage('Connection setup timed out. Please try again.');
178
+ setErrorMessage(result.message);
179
+ return;
180
+ }
181
+ connectionNameRef.current = result.connectionName;
182
+ if (result.status === 'pending') {
183
+ setConsentUrl(result.consentLink);
184
+ setPhase('oauth');
185
+ } else {
186
+ const repaired = await (0, _PowerPlatformConnectionApi.pollConnectionStatus)(connectorId, result.connectionName, environmentId, region, acquireToken, {
187
+ timeoutMs: 10_000,
188
+ ...polling,
189
+ signal: operation.signal
190
+ });
191
+ if (repaired) await handleConnected(repaired);else {
192
+ setPhase('error');
193
+ setErrorMessage('The connection was updated but did not become active.');
194
+ }
155
195
  }
156
196
  } finally {
157
197
  inFlightRef.current = false;
158
198
  }
159
- }, [connectorId, environmentId, region, acquireToken, polling, handleConnected, phase]);
199
+ }, [acquireToken, beginOperation, connectorId, environmentId, handleConnected, oauthRedirectUrl, polling, region]);
200
+ const useExisting = (0, _react.useCallback)(async instance => {
201
+ if (inFlightRef.current) return;
202
+ inFlightRef.current = true;
203
+ setPhase('confirming');
204
+ setErrorMessage(null);
205
+ try {
206
+ await handleConnected(instance);
207
+ } finally {
208
+ inFlightRef.current = false;
209
+ }
210
+ }, [handleConnected]);
160
211
  const checkNow = (0, _react.useCallback)(async () => {
161
212
  const name = connectionNameRef.current;
162
213
  if (!name || inFlightRef.current) return;
163
214
  if (phase !== 'oauth' && phase !== 'confirming') return;
164
215
  inFlightRef.current = true;
216
+ const operation = beginOperation();
165
217
  setPhase('confirming');
166
218
  try {
167
219
  const instance = await (0, _PowerPlatformConnectionApi.pollConnectionStatus)(connectorId, name, environmentId, region, acquireToken, {
168
220
  intervalMs: 1000,
169
221
  timeoutMs: 30_000,
170
- ...polling
222
+ ...polling,
223
+ signal: operation.signal
171
224
  });
172
225
  if (instance) {
173
- handleConnected(instance);
226
+ await handleConnected(instance);
174
227
  } else {
175
228
  // Not yet connected — go back to oauth so the user can retry.
176
229
  setPhase('oauth');
@@ -179,8 +232,10 @@ function useConnectionSetup({
179
232
  } finally {
180
233
  inFlightRef.current = false;
181
234
  }
182
- }, [phase, environmentId, region, acquireToken, polling, handleConnected]);
235
+ }, [phase, connectorId, environmentId, region, acquireToken, polling, handleConnected, beginOperation]);
183
236
  const reset = (0, _react.useCallback)(() => {
237
+ operationRef.current?.abort();
238
+ operationRef.current = null;
184
239
  inFlightRef.current = false;
185
240
  connectionNameRef.current = null;
186
241
  setPhase('idle');
@@ -200,6 +255,7 @@ function useConnectionSetup({
200
255
  const name = connectionNameRef.current;
201
256
  if (!name || inFlightRef.current) return;
202
257
  inFlightRef.current = true;
258
+ const operation = beginOperation();
203
259
  setPhase('confirming');
204
260
  try {
205
261
  if (code) {
@@ -212,10 +268,11 @@ function useConnectionSetup({
212
268
  const instance = await (0, _PowerPlatformConnectionApi.pollConnectionStatus)(connectorId, name, environmentId, region, acquireToken, {
213
269
  intervalMs: 1000,
214
270
  timeoutMs: 30_000,
215
- ...polling
271
+ ...polling,
272
+ signal: operation.signal
216
273
  });
217
274
  if (instance) {
218
- handleConnected(instance);
275
+ await handleConnected(instance);
219
276
  } else {
220
277
  setPhase('oauth');
221
278
  setErrorMessage('Connection is not yet active. Complete the sign-in and try again.');
@@ -223,12 +280,14 @@ function useConnectionSetup({
223
280
  } finally {
224
281
  inFlightRef.current = false;
225
282
  }
226
- }, [connectorId, environmentId, region, acquireToken, polling, handleConnected]);
283
+ }, [connectorId, environmentId, region, acquireToken, polling, handleConnected, beginOperation]);
227
284
  return {
228
285
  phase,
229
286
  consentUrl,
230
287
  errorMessage,
231
288
  startCreate,
289
+ startRepair,
290
+ useExisting,
232
291
  checkNow,
233
292
  completeConsent,
234
293
  reset
@@ -24,6 +24,9 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
24
24
  */
25
25
  function FilePicker({
26
26
  label,
27
+ testID,
28
+ fileRowTestID,
29
+ pickButtonTestID,
27
30
  fileName,
28
31
  onDownload,
29
32
  shareTitle,
@@ -90,6 +93,7 @@ function FilePicker({
90
93
  }
91
94
  };
92
95
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
96
+ testID: testID,
93
97
  style: [styles.container, containerStyle],
94
98
  children: [label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
95
99
  style: [styles.label, {
@@ -97,6 +101,7 @@ function FilePicker({
97
101
  }, labelStyle],
98
102
  children: label
99
103
  }) : null, displayName ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
104
+ testID: fileRowTestID,
100
105
  style: [styles.fileRow, fileRowStyle],
101
106
  onPress: onDownload ? download : undefined,
102
107
  activeOpacity: onDownload ? 0.7 : 1,
@@ -120,6 +125,7 @@ function FilePicker({
120
125
  color: accent
121
126
  }))]
122
127
  }) : null, onChange ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
128
+ testID: pickButtonTestID,
123
129
  style: [styles.button, {
124
130
  borderColor: accent,
125
131
  backgroundColor: bg
@@ -22,6 +22,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
22
22
  */
23
23
  function ImagePicker({
24
24
  label = 'Image',
25
+ testID,
26
+ cameraButtonTestID,
27
+ selectButtonTestID,
28
+ previewTestID,
25
29
  initialBase64,
26
30
  onChange,
27
31
  containerStyle,
@@ -136,6 +140,7 @@ function ImagePicker({
136
140
  }
137
141
  };
138
142
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
143
+ testID: testID,
139
144
  style: [styles.container, containerStyle],
140
145
  children: [label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
141
146
  style: [styles.label, {
@@ -145,6 +150,7 @@ function ImagePicker({
145
150
  }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
146
151
  style: [styles.buttonRow, buttonRowStyle],
147
152
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
153
+ testID: cameraButtonTestID,
148
154
  style: [styles.button, {
149
155
  borderColor: accentColor_resolved,
150
156
  backgroundColor: bg
@@ -166,6 +172,7 @@ function ImagePicker({
166
172
  children: reading ? readingLabel : cameraButtonLabel
167
173
  })]
168
174
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
175
+ testID: selectButtonTestID,
169
176
  style: [styles.button, {
170
177
  borderColor: accentColor_resolved,
171
178
  backgroundColor: bg
@@ -188,6 +195,7 @@ function ImagePicker({
188
195
  })]
189
196
  })]
190
197
  }), previewUri ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
198
+ testID: previewTestID,
191
199
  source: {
192
200
  uri: previewUri
193
201
  },
@@ -90,7 +90,13 @@ Object.defineProperty(exports, "base64ToUint8Array", {
90
90
  Object.defineProperty(exports, "buildCdsDataSources", {
91
91
  enumerable: true,
92
92
  get: function () {
93
- return _PowerPlatformEnvironmentApi.buildCdsDataSources;
93
+ return _DataverseDataSources.buildCdsDataSources;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "buildConnectionParameterSets", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _connectionMetadata.buildConnectionParameterSets;
94
100
  }
95
101
  });
96
102
  Object.defineProperty(exports, "buildConnectionReferences", {
@@ -99,12 +105,60 @@ Object.defineProperty(exports, "buildConnectionReferences", {
99
105
  return _NativePowerAppsBridge.buildConnectionReferences;
100
106
  }
101
107
  });
108
+ Object.defineProperty(exports, "buildConnectionRequirements", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _types.buildConnectionRequirements;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "buildConnectionResolutionKey", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _types.buildConnectionResolutionKey;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "buildConnectionUsageRequest", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _connectionMetadata.buildConnectionUsageRequest;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "buildConnectionUsageUrl", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _connectionMetadata.buildConnectionUsageUrl;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "buildConnectionUserConsentUrl", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _connectionMetadata.buildConnectionUserConsentUrl;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "buildConsentLinkDefinition", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _connectionMetadata.buildConsentLinkDefinition;
142
+ }
143
+ });
102
144
  Object.defineProperty(exports, "buildEnvironmentEndpoint", {
103
145
  enumerable: true,
104
146
  get: function () {
105
147
  return _PowerPlatformEnvironmentApi.buildEnvironmentEndpoint;
106
148
  }
107
149
  });
150
+ Object.defineProperty(exports, "buildScopeConsentRequest", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _connectionMetadata.buildScopeConsentRequest;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "buildScopeConsentUrl", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _connectionMetadata.buildScopeConsentUrl;
160
+ }
161
+ });
108
162
  Object.defineProperty(exports, "completePowerAppsAuthSession", {
109
163
  enumerable: true,
110
164
  get: function () {
@@ -141,6 +195,12 @@ Object.defineProperty(exports, "darkTheme", {
141
195
  return _tokens.darkTheme;
142
196
  }
143
197
  });
198
+ Object.defineProperty(exports, "deleteConnection", {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _PowerPlatformConnectionApi.deleteConnection;
202
+ }
203
+ });
144
204
  Object.defineProperty(exports, "disambiguateConnections", {
145
205
  enumerable: true,
146
206
  get: function () {
@@ -153,6 +213,12 @@ Object.defineProperty(exports, "extractConnectionId", {
153
213
  return _disambiguate.extractConnectionId;
154
214
  }
155
215
  });
216
+ Object.defineProperty(exports, "fetchAppConnectionUsages", {
217
+ enumerable: true,
218
+ get: function () {
219
+ return _PowerPlatformConnectionApi.fetchAppConnectionUsages;
220
+ }
221
+ });
156
222
  Object.defineProperty(exports, "fetchAppLaunchData", {
157
223
  enumerable: true,
158
224
  get: function () {
@@ -174,7 +240,13 @@ Object.defineProperty(exports, "fetchConnectorMetadata", {
174
240
  Object.defineProperty(exports, "fetchInstanceUrl", {
175
241
  enumerable: true,
176
242
  get: function () {
177
- return _PowerPlatformEnvironmentApi.fetchInstanceUrl;
243
+ return _DataverseGlobalDiscoveryApi.fetchInstanceUrl;
244
+ }
245
+ });
246
+ Object.defineProperty(exports, "findConnectionDataSourceConflicts", {
247
+ enumerable: true,
248
+ get: function () {
249
+ return _types.findConnectionDataSourceConflicts;
178
250
  }
179
251
  });
180
252
  Object.defineProperty(exports, "getAppLogger", {
@@ -183,6 +255,36 @@ Object.defineProperty(exports, "getAppLogger", {
183
255
  return _index.getAppLogger;
184
256
  }
185
257
  });
258
+ Object.defineProperty(exports, "getConnectorId", {
259
+ enumerable: true,
260
+ get: function () {
261
+ return _types.getConnectorId;
262
+ }
263
+ });
264
+ Object.defineProperty(exports, "getCustomerTelemetryLogger", {
265
+ enumerable: true,
266
+ get: function () {
267
+ return _index.getCustomerTelemetryLogger;
268
+ }
269
+ });
270
+ Object.defineProperty(exports, "hasCompleteStaticConnectionConfig", {
271
+ enumerable: true,
272
+ get: function () {
273
+ return _types.hasCompleteStaticConnectionConfig;
274
+ }
275
+ });
276
+ Object.defineProperty(exports, "hasOAuthParameter", {
277
+ enumerable: true,
278
+ get: function () {
279
+ return _connectionMetadata.hasOAuthParameter;
280
+ }
281
+ });
282
+ Object.defineProperty(exports, "isCompositeConnectionApiId", {
283
+ enumerable: true,
284
+ get: function () {
285
+ return _types.isCompositeConnectionApiId;
286
+ }
287
+ });
186
288
  Object.defineProperty(exports, "isDevPlayer", {
187
289
  enumerable: true,
188
290
  get: function () {
@@ -195,12 +297,48 @@ Object.defineProperty(exports, "lightTheme", {
195
297
  return _tokens.lightTheme;
196
298
  }
197
299
  });
300
+ Object.defineProperty(exports, "normalizeApiId", {
301
+ enumerable: true,
302
+ get: function () {
303
+ return _types.normalizeApiId;
304
+ }
305
+ });
306
+ Object.defineProperty(exports, "parseConnectionParameters", {
307
+ enumerable: true,
308
+ get: function () {
309
+ return _connectionMetadata.parseConnectionParameters;
310
+ }
311
+ });
198
312
  Object.defineProperty(exports, "pollConnectionStatus", {
199
313
  enumerable: true,
200
314
  get: function () {
201
315
  return _PowerPlatformConnectionApi.pollConnectionStatus;
202
316
  }
203
317
  });
318
+ Object.defineProperty(exports, "postConnectionUsage", {
319
+ enumerable: true,
320
+ get: function () {
321
+ return _PowerPlatformConnectionApi.postConnectionUsage;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, "repairConnection", {
325
+ enumerable: true,
326
+ get: function () {
327
+ return _PowerPlatformConnectionApi.repairConnection;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, "reportScopeConsents", {
331
+ enumerable: true,
332
+ get: function () {
333
+ return _PowerPlatformConnectionApi.reportScopeConsents;
334
+ }
335
+ });
336
+ Object.defineProperty(exports, "serializeConnectionParameters", {
337
+ enumerable: true,
338
+ get: function () {
339
+ return _connectionMetadata.serializeConnectionParameters;
340
+ }
341
+ });
204
342
  Object.defineProperty(exports, "setupNativeHost", {
205
343
  enumerable: true,
206
344
  get: function () {
@@ -213,6 +351,24 @@ Object.defineProperty(exports, "setupPowerPagesHost", {
213
351
  return _PowerPagesBridge.setupPowerPagesHost;
214
352
  }
215
353
  });
354
+ Object.defineProperty(exports, "shouldPersistConnectionUsages", {
355
+ enumerable: true,
356
+ get: function () {
357
+ return _connectionState.shouldPersistConnectionUsages;
358
+ }
359
+ });
360
+ Object.defineProperty(exports, "shouldShowConnectionReview", {
361
+ enumerable: true,
362
+ get: function () {
363
+ return _connectionState.shouldShowConnectionReview;
364
+ }
365
+ });
366
+ Object.defineProperty(exports, "updateBridgeOptionsInPlace", {
367
+ enumerable: true,
368
+ get: function () {
369
+ return _bridgeState.updateBridgeOptionsInPlace;
370
+ }
371
+ });
216
372
  Object.defineProperty(exports, "useAuth", {
217
373
  enumerable: true,
218
374
  get: function () {
@@ -243,17 +399,24 @@ Object.defineProperty(exports, "useThemeTokens", {
243
399
  return _ThemeProvider.useThemeTokens;
244
400
  }
245
401
  });
402
+ require("@microsoft/power-apps-native-assets");
246
403
  var _NativePowerAppsBridge = require("./bridge/NativePowerAppsBridge.js");
247
404
  var _PowerPagesBridge = require("./bridge/PowerPagesBridge.js");
248
405
  var _setupNativeHost = require("./bridge/setupNativeHost.js");
406
+ var _bridgeState = require("./bridge/bridgeState.js");
249
407
  var _AuthContext = require("./auth/AuthContext");
250
408
  var _completePowerAppsAuthSession = require("./auth/completePowerAppsAuthSession.js");
251
409
  var _PowerAppsHostProvider = require("./provider/PowerAppsHostProvider");
252
410
  var _PowerAppsProvider = require("./provider/PowerAppsProvider.js");
253
411
  var _PowerPlatformEnvironmentApi = require("./platform/PowerPlatformEnvironmentApi.js");
254
- var _useConnectionRefs = require("./platform/useConnectionRefs.js");
255
- var _PowerPlatformConnectionApi = require("./platform/PowerPlatformConnectionApi.js");
412
+ var _DataverseGlobalDiscoveryApi = require("./platform/DataverseGlobalDiscoveryApi.js");
413
+ var _DataverseDataSources = require("./platform/DataverseDataSources.js");
414
+ var _useConnectionRefs = require("./connections/useConnectionRefs.js");
415
+ var _PowerPlatformConnectionApi = require("./connections/PowerPlatformConnectionApi.js");
256
416
  var _disambiguate = require("./connections/disambiguate.js");
417
+ var _connectionState = require("./connections/connectionState.js");
418
+ var _types = require("./connections/types.js");
419
+ var _connectionMetadata = require("./connections/connectionMetadata.js");
257
420
  var _useConnectionSetup = require("./connections/useConnectionSetup.js");
258
421
  var _ConnectionSetupScreen = require("./connections/ConnectionSetupScreen.js");
259
422
  var _ThemeProvider = require("./theme/ThemeProvider.js");
@@ -5,23 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.debugLog = debugLog;
7
7
  exports.debugWarn = debugWarn;
8
+ exports.isDebugLoggingEnabled = isDebugLoggingEnabled;
8
9
  var _isDevPlayer = require("./utils/isDevPlayer.js");
9
10
  /**
10
11
  * Conditional debug logger for power-apps-native-host.
11
12
  *
12
- * Debug logs (debugLog / debugWarn) are only emitted when the JS bundle
13
- * is running inside the Power Apps Dev Player (detected via
14
- * `Constants.expoConfig.extra.isDevPlayer`). They are silenced in release
15
- * APKs generated from the template so the production log stream stays clean.
13
+ * Debug logs (debugLog / debugWarn) are emitted in development bundles or when
14
+ * running inside Power Apps Dev Player. They remain silent in wrapped release
15
+ * apps so the production log stream stays clean.
16
16
  */
17
17
 
18
+ function isDebugLoggingEnabled() {
19
+ return __DEV__ || _isDevPlayer.isDevPlayer;
20
+ }
18
21
  function debugLog(...args) {
19
- if (_isDevPlayer.isDevPlayer) {
22
+ if (isDebugLoggingEnabled()) {
20
23
  console.log(...args);
21
24
  }
22
25
  }
23
26
  function debugWarn(...args) {
24
- if (_isDevPlayer.isDevPlayer) {
27
+ if (isDebugLoggingEnabled()) {
25
28
  console.warn(...args);
26
29
  }
27
30
  }