@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.
- package/README.md +162 -26
- package/compatibility/current.json +87 -0
- package/lib/NOTICE.txt +140 -1226
- package/lib/commonjs/auth/AuthContext.js +74 -18
- package/lib/commonjs/auth/AuthContext.web.js +32 -0
- package/lib/commonjs/auth/completePowerAppsAuthSession.js +16 -0
- package/lib/commonjs/bridge/NativePowerAppsBridge.js +20 -17
- package/lib/commonjs/bridge/PowerPagesBridge.js +157 -0
- package/lib/commonjs/bridge/bridgeState.js +40 -0
- package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
- package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
- package/lib/commonjs/connections/connectionMetadata.js +127 -0
- package/lib/commonjs/connections/connectionState.js +96 -0
- package/lib/commonjs/connections/disambiguate.js +19 -11
- package/lib/commonjs/connections/resolveConnections.js +347 -0
- package/lib/commonjs/connections/types.js +106 -0
- package/lib/commonjs/{platform → connections}/useConnectionRefs.js +128 -65
- package/lib/commonjs/connections/useConnectionSetup.js +111 -52
- package/lib/commonjs/controls/FilePicker.js +6 -0
- package/lib/commonjs/controls/ImagePicker.js +8 -0
- package/lib/commonjs/index.js +188 -6
- package/lib/commonjs/logger.js +9 -6
- package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
- package/lib/commonjs/offline/useOfflineIntegration.js +12 -0
- package/lib/commonjs/offline/useOfflineIntegration.web.js +11 -0
- package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +46 -0
- package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
- package/lib/commonjs/platform/DataverseDataSources.js +14 -0
- package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +49 -0
- package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
- package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
- package/lib/commonjs/provider/PowerAppsHostProvider.js +156 -25
- package/lib/commonjs/provider/PowerAppsHostProvider.web.js +41 -0
- package/lib/commonjs/provider/PowerAppsProvider.js +229 -133
- package/lib/commonjs/provider/SessionDetailsGesture.js +216 -0
- package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
- package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
- package/lib/commonjs/telemetry/index.js +22 -3
- package/lib/module/auth/AuthContext.js +74 -18
- package/lib/module/auth/AuthContext.web.js +26 -0
- package/lib/module/auth/completePowerAppsAuthSession.js +11 -0
- package/lib/module/bridge/NativePowerAppsBridge.js +21 -18
- package/lib/module/bridge/PowerPagesBridge.js +151 -0
- package/lib/module/bridge/bridgeState.js +34 -0
- package/lib/module/connections/ConnectionSetupScreen.js +460 -81
- package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
- package/lib/module/connections/connectionMetadata.js +112 -0
- package/lib/module/connections/connectionState.js +82 -0
- package/lib/module/connections/disambiguate.js +19 -12
- package/lib/module/connections/resolveConnections.js +342 -0
- package/lib/module/connections/types.js +91 -0
- package/lib/module/{platform → connections}/useConnectionRefs.js +129 -66
- package/lib/module/connections/useConnectionSetup.js +113 -54
- package/lib/module/controls/FilePicker.js +6 -0
- package/lib/module/controls/ImagePicker.js +8 -0
- package/lib/module/index.js +14 -6
- package/lib/module/logger.js +8 -6
- package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
- package/lib/module/offline/useOfflineIntegration.js +3 -0
- package/lib/module/offline/useOfflineIntegration.web.js +7 -0
- package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +42 -0
- package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
- package/lib/module/platform/DataverseDataSources.js +10 -0
- package/lib/module/platform/DataverseGlobalDiscoveryApi.js +45 -0
- package/lib/module/platform/GlobalDiscovery.js +45 -0
- package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
- package/lib/module/provider/PowerAppsHostProvider.js +159 -28
- package/lib/module/provider/PowerAppsHostProvider.web.js +36 -0
- package/lib/module/provider/PowerAppsProvider.js +233 -137
- package/lib/module/provider/SessionDetailsGesture.js +211 -0
- package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
- package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
- package/lib/module/telemetry/index.js +15 -4
- package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
- package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +21 -0
- package/lib/typescript/commonjs/auth/completePowerAppsAuthSession.d.ts +8 -0
- package/lib/typescript/commonjs/bridge/PowerPagesBridge.d.ts +18 -0
- package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
- package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
- package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
- package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
- package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
- package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
- package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +19 -19
- package/lib/typescript/commonjs/connections/types.d.ts +129 -1
- package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +33 -24
- package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
- package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
- package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
- package/lib/typescript/commonjs/index.d.ts +20 -10
- package/lib/typescript/commonjs/logger.d.ts +4 -4
- package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
- package/lib/typescript/commonjs/offline/useOfflineIntegration.d.ts +2 -0
- package/lib/typescript/commonjs/offline/useOfflineIntegration.web.d.ts +4 -0
- package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
- package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
- package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +27 -0
- package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
- package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
- package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
- package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
- package/lib/typescript/commonjs/provider/PowerAppsHostProvider.web.d.ts +5 -0
- package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +32 -10
- package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
- package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
- package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
- package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
- package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
- package/lib/typescript/module/auth/AuthContext.web.d.ts +21 -0
- package/lib/typescript/module/auth/completePowerAppsAuthSession.d.ts +8 -0
- package/lib/typescript/module/bridge/PowerPagesBridge.d.ts +18 -0
- package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
- package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
- package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
- package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
- package/lib/typescript/module/connections/connectionState.d.ts +16 -0
- package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
- package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +19 -19
- package/lib/typescript/module/connections/types.d.ts +129 -1
- package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +33 -24
- package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
- package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
- package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
- package/lib/typescript/module/index.d.ts +24 -14
- package/lib/typescript/module/logger.d.ts +4 -4
- package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
- package/lib/typescript/module/offline/useOfflineIntegration.d.ts +2 -0
- package/lib/typescript/module/offline/useOfflineIntegration.web.d.ts +4 -0
- package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
- package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
- package/lib/typescript/module/platform/DataverseDataSources.d.ts +27 -0
- package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
- package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
- package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
- package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
- package/lib/typescript/module/provider/PowerAppsHostProvider.web.d.ts +5 -0
- package/lib/typescript/module/provider/PowerAppsProvider.d.ts +34 -12
- package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
- package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
- package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
- package/lib/typescript/module/telemetry/index.d.ts +13 -1
- package/package.json +43 -18
- package/scripts/build-ios-base.js +66 -27
- package/scripts/bundle.js +212 -5
- package/scripts/generate-connector-schemas.js +8 -6
- package/scripts/metro-logger.js +213 -0
- package/scripts/start-web.mjs +137 -0
- package/scripts/upgrade/runtime.js +463 -0
- package/scripts/upgrade/system.js +244 -0
- package/scripts/upgrade-authoring.js +534 -0
- package/scripts/upgrade.js +188 -0
- package/scripts/wrap.js +536 -0
- package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
- package/lib/commonjs/platform/resolveConnections.js +0 -264
- package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
- package/lib/module/platform/resolveConnections.js +0 -259
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/*!
|
|
4
|
-
* power-apps-native-host — resolveConnections
|
|
5
|
-
*
|
|
6
|
-
* Pure async helpers for the two connection-resolution strategies used by
|
|
7
|
-
* useConnectionRefs:
|
|
8
|
-
*
|
|
9
|
-
* • resolveViaStaticRefs — per-connector resolution using the static
|
|
10
|
-
* connectionReferences map from power.config.json. Used by the Dev Player
|
|
11
|
-
* and during local development (no appId) or when the launch API is
|
|
12
|
-
* unavailable. Handles pre-disambiguation ACL grants so inaccessible
|
|
13
|
-
* connections are excluded before the user is asked to pick.
|
|
14
|
-
*
|
|
15
|
-
* • applyAclGrants — post-resolution ACL grants used by the fast path
|
|
16
|
-
* (production APKs via fetchAppLaunchData).
|
|
17
|
-
*
|
|
18
|
-
* Both helpers return / consume the shared AppLaunchResult shape so the
|
|
19
|
-
* hook orchestrator can handle them uniformly.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { addAadAppToConnectionAcl, parseJwtOid, SERVICE_POWERAPPS_SCOPE } from "./PowerPlatformConnectionApi.js";
|
|
23
|
-
import { fetchInstanceUrl, buildEnvironmentEndpoint } from "./PowerPlatformEnvironmentApi.js";
|
|
24
|
-
import { disambiguateConnections, extractConnectionId } from "../connections/disambiguate.js";
|
|
25
|
-
import { ConnectionStatus } from "../connections/types.js";
|
|
26
|
-
const API_VERSION = '1';
|
|
27
|
-
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// ConnectorSchema
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Connector schema entry generated by `generate-connector-schemas`.
|
|
34
|
-
* Keyed by data source name in the `schemaMap` passed to `useConnectionRefs`.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// resolveViaStaticRefs
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Resolve connections from the static `connectionReferences` map.
|
|
43
|
-
*
|
|
44
|
-
* Steps:
|
|
45
|
-
* 1. Build an apiId → schema lookup.
|
|
46
|
-
* 2. In parallel: fetch the Dataverse instanceUrl and all connection instances
|
|
47
|
-
* for every connector.
|
|
48
|
-
* 3. If `isvClientId` is set, run pre-disambiguation ACL grants — connections
|
|
49
|
-
* where the grant fails are marked `NeedsAclGrant` and excluded from
|
|
50
|
-
* resolution, prompting the user to create a new connection.
|
|
51
|
-
* 4. Disambiguate: resolve single matches, invoke callbacks for ambiguous /
|
|
52
|
-
* missing cases, perform one-shot retries when `onMissingConnection` returns
|
|
53
|
-
* `true`.
|
|
54
|
-
* 5. Build and return an `AppLaunchResult`-shaped object.
|
|
55
|
-
*/
|
|
56
|
-
export async function resolveViaStaticRefs({
|
|
57
|
-
connectionReferences,
|
|
58
|
-
schemaMap,
|
|
59
|
-
environmentId,
|
|
60
|
-
region,
|
|
61
|
-
acquireToken,
|
|
62
|
-
token,
|
|
63
|
-
isvClientId,
|
|
64
|
-
onDisambiguationNeeded,
|
|
65
|
-
onMissingConnection
|
|
66
|
-
}) {
|
|
67
|
-
// Build apiId → schema lookup from the static refs.
|
|
68
|
-
const schemaByApiId = Object.fromEntries(Object.values(connectionReferences).map(ref => {
|
|
69
|
-
const schema = ref.dataSources.map(ds => schemaMap[ds]).find(Boolean);
|
|
70
|
-
return schema ? [ref.id, schema] : null;
|
|
71
|
-
}).filter(entry => entry !== null));
|
|
72
|
-
const base = buildEnvironmentEndpoint(environmentId, region);
|
|
73
|
-
const headers = {
|
|
74
|
-
Authorization: `Bearer ${token}`
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// Fetch Dataverse instanceUrl and all connection instances in parallel.
|
|
78
|
-
const [instanceUrl, ...connResults] = await Promise.all([fetchInstanceUrl(environmentId, region, acquireToken, token), ...Object.entries(connectionReferences).map(async ([localRefId, ref]) => {
|
|
79
|
-
const schema = schemaByApiId[ref.id];
|
|
80
|
-
if (!schema) {
|
|
81
|
-
return {
|
|
82
|
-
localRefId,
|
|
83
|
-
apiId: ref.id,
|
|
84
|
-
dataSources: ref.dataSources,
|
|
85
|
-
instances: []
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
const url = `${base}/connectivity/apis/${schema.name}/connections` + `?api-version=${API_VERSION}&$filter=environment eq '${environmentId}'`;
|
|
89
|
-
try {
|
|
90
|
-
const res = await fetch(url, {
|
|
91
|
-
headers
|
|
92
|
-
});
|
|
93
|
-
if (!res.ok) {
|
|
94
|
-
return {
|
|
95
|
-
localRefId,
|
|
96
|
-
apiId: ref.id,
|
|
97
|
-
dataSources: ref.dataSources,
|
|
98
|
-
instances: []
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const body = await res.json();
|
|
102
|
-
const instances = (body.value ?? []).map(c => ({
|
|
103
|
-
id: extractConnectionId(c.name),
|
|
104
|
-
name: c.name,
|
|
105
|
-
apiId: ref.id,
|
|
106
|
-
status: c.properties?.statuses?.[0]?.status === 'Connected' ? ConnectionStatus.Connected : ConnectionStatus.NotConnected,
|
|
107
|
-
displayName: c.properties?.displayName
|
|
108
|
-
}));
|
|
109
|
-
return {
|
|
110
|
-
localRefId,
|
|
111
|
-
apiId: ref.id,
|
|
112
|
-
dataSources: ref.dataSources,
|
|
113
|
-
instances
|
|
114
|
-
};
|
|
115
|
-
} catch {
|
|
116
|
-
return {
|
|
117
|
-
localRefId,
|
|
118
|
-
apiId: ref.id,
|
|
119
|
-
dataSources: ref.dataSources,
|
|
120
|
-
instances: []
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
})]);
|
|
124
|
-
|
|
125
|
-
// Pre-disambiguation ACL grants (ISV apps only).
|
|
126
|
-
//
|
|
127
|
-
// Connections where the grant fails are marked NeedsAclGrant so
|
|
128
|
-
// disambiguation treats them as unavailable and surfaces the
|
|
129
|
-
// "missing connection" flow, steering the user to create a new one.
|
|
130
|
-
if (isvClientId) {
|
|
131
|
-
const paToken = await acquireToken([SERVICE_POWERAPPS_SCOPE]);
|
|
132
|
-
const paOid = paToken ? parseJwtOid(paToken) : null;
|
|
133
|
-
if (paToken && paOid) {
|
|
134
|
-
await Promise.all(connResults.map(async r => {
|
|
135
|
-
const connId = schemaByApiId[r.apiId]?.name;
|
|
136
|
-
if (!connId) return;
|
|
137
|
-
await Promise.all(r.instances.map(async inst => {
|
|
138
|
-
if (inst.status !== ConnectionStatus.Connected) return;
|
|
139
|
-
const ok = await addAadAppToConnectionAcl(connId, inst.id, environmentId, isvClientId, paOid, paToken);
|
|
140
|
-
if (!ok) inst.status = ConnectionStatus.NeedsAclGrant;
|
|
141
|
-
}));
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Disambiguation.
|
|
147
|
-
const allConnectionsByApiId = {};
|
|
148
|
-
for (const r of connResults) {
|
|
149
|
-
allConnectionsByApiId[r.apiId] = r.instances;
|
|
150
|
-
}
|
|
151
|
-
const disambiguationResults = disambiguateConnections(connectionReferences, allConnectionsByApiId);
|
|
152
|
-
const resolvedIds = {};
|
|
153
|
-
const unresolvedApiIds = [];
|
|
154
|
-
for (const dr of disambiguationResults) {
|
|
155
|
-
if (dr.result.kind === 'resolved') {
|
|
156
|
-
resolvedIds[dr.localRefId] = dr.result.connectionId;
|
|
157
|
-
} else if (dr.result.kind === 'ambiguous') {
|
|
158
|
-
const picked = onDisambiguationNeeded ? await onDisambiguationNeeded({
|
|
159
|
-
localRefId: dr.localRefId,
|
|
160
|
-
apiId: dr.apiId,
|
|
161
|
-
candidates: dr.result.candidates
|
|
162
|
-
}) : null;
|
|
163
|
-
// Fall back to the first Connected candidate so the app can still start.
|
|
164
|
-
resolvedIds[dr.localRefId] = picked ?? dr.result.candidates[0]?.id ?? '';
|
|
165
|
-
} else {
|
|
166
|
-
// kind === 'missing'
|
|
167
|
-
let retried = false;
|
|
168
|
-
if (onMissingConnection) {
|
|
169
|
-
retried = await onMissingConnection({
|
|
170
|
-
localRefId: dr.localRefId,
|
|
171
|
-
apiId: dr.apiId
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (retried) {
|
|
175
|
-
// One-shot retry for this specific connector.
|
|
176
|
-
const schema = schemaByApiId[dr.apiId];
|
|
177
|
-
if (schema) {
|
|
178
|
-
try {
|
|
179
|
-
const url = `${base}/connectivity/apis/${schema.name}/connections` + `?api-version=${API_VERSION}&$filter=environment eq '${environmentId}'`;
|
|
180
|
-
const res = await fetch(url, {
|
|
181
|
-
headers
|
|
182
|
-
});
|
|
183
|
-
if (res.ok) {
|
|
184
|
-
const body = await res.json();
|
|
185
|
-
const retryInstances = (body.value ?? []).map(c => ({
|
|
186
|
-
id: extractConnectionId(c.name),
|
|
187
|
-
name: c.name,
|
|
188
|
-
apiId: dr.apiId,
|
|
189
|
-
status: c.properties?.statuses?.[0]?.status === 'Connected' ? ConnectionStatus.Connected : ConnectionStatus.NotConnected
|
|
190
|
-
}));
|
|
191
|
-
const connected = retryInstances.find(i => i.status === ConnectionStatus.Connected);
|
|
192
|
-
if (connected) {
|
|
193
|
-
resolvedIds[dr.localRefId] = connected.id;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
} catch {
|
|
198
|
-
// Fall through to missing.
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
resolvedIds[dr.localRefId] = '';
|
|
203
|
-
unresolvedApiIds.push(dr.apiId);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
const dataverseOrgUrl = (instanceUrl ?? '').replace(/\/$/, '');
|
|
207
|
-
|
|
208
|
-
// Build the final AppConnectionReference map.
|
|
209
|
-
const connectionRefs = {};
|
|
210
|
-
for (const [localRefId, ref] of Object.entries(connectionReferences)) {
|
|
211
|
-
const schema = schemaByApiId[ref.id];
|
|
212
|
-
const connectionName = resolvedIds[localRefId] ?? '';
|
|
213
|
-
const isDataverse = ref.id.includes('commondataserviceforapps');
|
|
214
|
-
const entry = {
|
|
215
|
-
apiId: ref.id,
|
|
216
|
-
runtimeUrl: schema?.properties.primaryRuntimeUrl ?? '',
|
|
217
|
-
connectionName,
|
|
218
|
-
datasetName: isDataverse ? dataverseOrgUrl : ''
|
|
219
|
-
};
|
|
220
|
-
for (const ds of ref.dataSources) {
|
|
221
|
-
connectionRefs[ds] = entry;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return {
|
|
225
|
-
connectionRefs,
|
|
226
|
-
dataverseOrgUrl,
|
|
227
|
-
missingConnectors: unresolvedApiIds
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ---------------------------------------------------------------------------
|
|
232
|
-
// applyAclGrants
|
|
233
|
-
// ---------------------------------------------------------------------------
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Run idempotent post-resolution ACL grants on behalf of the ISV app.
|
|
237
|
-
*
|
|
238
|
-
* Used by the fast path (production APKs via `fetchAppLaunchData`) where the
|
|
239
|
-
* launch API has already resolved the user's connections — grants are applied
|
|
240
|
-
* after the fact so APIM accepts tokens issued to the ISV's AAD app.
|
|
241
|
-
*
|
|
242
|
-
* For the slow path the grants run before disambiguation inside
|
|
243
|
-
* `resolveViaStaticRefs`, where they can still influence which connections
|
|
244
|
-
* are considered available.
|
|
245
|
-
*
|
|
246
|
-
* Failures are swallowed — a failed grant will surface as a 403 at runtime
|
|
247
|
-
* when the connector is called.
|
|
248
|
-
*/
|
|
249
|
-
export async function applyAclGrants(connectionRefs, environmentId, isvClientId, acquireToken) {
|
|
250
|
-
const paToken = await acquireToken([SERVICE_POWERAPPS_SCOPE]);
|
|
251
|
-
const paOid = paToken ? parseJwtOid(paToken) : null;
|
|
252
|
-
if (!paToken || !paOid) return;
|
|
253
|
-
const seen = new Set();
|
|
254
|
-
await Promise.all(Object.values(connectionRefs).map(async ref => {
|
|
255
|
-
if (!ref.connectionName || seen.has(ref.connectionName)) return;
|
|
256
|
-
seen.add(ref.connectionName);
|
|
257
|
-
await addAadAppToConnectionAcl(ref.apiId, ref.connectionName, environmentId, isvClientId, paOid, paToken);
|
|
258
|
-
}));
|
|
259
|
-
}
|