@microsoft/power-apps-native-host 0.2.22
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/LICENSE +112 -0
- package/README.md +59 -0
- package/app.plugin.js +4 -0
- package/lib/NOTICE.txt +1659 -0
- package/lib/commonjs/ErrorBoundary.js +128 -0
- package/lib/commonjs/auth/AuthContext.js +281 -0
- package/lib/commonjs/bridge/NativePowerAppsBridge.js +279 -0
- package/lib/commonjs/bridge/setupNativeHost.js +65 -0
- package/lib/commonjs/connections/ConnectionSetupScreen.js +531 -0
- package/lib/commonjs/connections/disambiguate.js +88 -0
- package/lib/commonjs/connections/types.js +58 -0
- package/lib/commonjs/connections/useConnectionSetup.js +236 -0
- package/lib/commonjs/controls/FilePicker.js +183 -0
- package/lib/commonjs/controls/ImagePicker.js +236 -0
- package/lib/commonjs/index.js +246 -0
- package/lib/commonjs/logger.js +27 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/platform/PowerPlatformConnectionApi.js +606 -0
- package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +194 -0
- package/lib/commonjs/platform/resolveConnections.js +264 -0
- package/lib/commonjs/platform/useConnectionRefs.js +270 -0
- package/lib/commonjs/provider/PowerAppsHostProvider.js +336 -0
- package/lib/commonjs/provider/PowerAppsProvider.js +351 -0
- package/lib/commonjs/telemetry/index.js +70 -0
- package/lib/commonjs/theme/ThemeProvider.js +80 -0
- package/lib/commonjs/theme/tokens.js +50 -0
- package/lib/commonjs/utils/dataverseUtils.js +98 -0
- package/lib/commonjs/utils/isDevPlayer.js +27 -0
- package/lib/module/ErrorBoundary.js +122 -0
- package/lib/module/auth/AuthContext.js +276 -0
- package/lib/module/bridge/NativePowerAppsBridge.js +273 -0
- package/lib/module/bridge/setupNativeHost.js +62 -0
- package/lib/module/connections/ConnectionSetupScreen.js +526 -0
- package/lib/module/connections/disambiguate.js +83 -0
- package/lib/module/connections/types.js +60 -0
- package/lib/module/connections/useConnectionSetup.js +233 -0
- package/lib/module/controls/FilePicker.js +178 -0
- package/lib/module/controls/ImagePicker.js +231 -0
- package/lib/module/index.js +41 -0
- package/lib/module/logger.js +22 -0
- package/lib/module/package.json +1 -0
- package/lib/module/platform/PowerPlatformConnectionApi.js +595 -0
- package/lib/module/platform/PowerPlatformEnvironmentApi.js +186 -0
- package/lib/module/platform/resolveConnections.js +259 -0
- package/lib/module/platform/useConnectionRefs.js +267 -0
- package/lib/module/provider/PowerAppsHostProvider.js +332 -0
- package/lib/module/provider/PowerAppsProvider.js +345 -0
- package/lib/module/telemetry/index.js +55 -0
- package/lib/module/theme/ThemeProvider.js +63 -0
- package/lib/module/theme/tokens.js +46 -0
- package/lib/module/utils/dataverseUtils.js +90 -0
- package/lib/module/utils/isDevPlayer.js +23 -0
- package/lib/typescript/commonjs/ErrorBoundary.d.ts +30 -0
- package/lib/typescript/commonjs/auth/AuthContext.d.ts +57 -0
- package/lib/typescript/commonjs/bridge/NativePowerAppsBridge.d.ts +112 -0
- package/lib/typescript/commonjs/bridge/setupNativeHost.d.ts +39 -0
- package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +107 -0
- package/lib/typescript/commonjs/connections/disambiguate.d.ts +43 -0
- package/lib/typescript/commonjs/connections/types.d.ts +91 -0
- package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +96 -0
- package/lib/typescript/commonjs/controls/FilePicker.d.ts +65 -0
- package/lib/typescript/commonjs/controls/ImagePicker.d.ts +76 -0
- package/lib/typescript/commonjs/index.d.ts +42 -0
- package/lib/typescript/commonjs/logger.d.ts +11 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/platform/PowerPlatformConnectionApi.d.ts +205 -0
- package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +108 -0
- package/lib/typescript/commonjs/platform/resolveConnections.d.ts +86 -0
- package/lib/typescript/commonjs/platform/useConnectionRefs.d.ts +126 -0
- package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +123 -0
- package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +148 -0
- package/lib/typescript/commonjs/telemetry/index.d.ts +48 -0
- package/lib/typescript/commonjs/theme/ThemeProvider.d.ts +30 -0
- package/lib/typescript/commonjs/theme/tokens.d.ts +27 -0
- package/lib/typescript/commonjs/utils/dataverseUtils.d.ts +39 -0
- package/lib/typescript/commonjs/utils/isDevPlayer.d.ts +19 -0
- package/lib/typescript/module/ErrorBoundary.d.ts +30 -0
- package/lib/typescript/module/auth/AuthContext.d.ts +57 -0
- package/lib/typescript/module/bridge/NativePowerAppsBridge.d.ts +112 -0
- package/lib/typescript/module/bridge/setupNativeHost.d.ts +39 -0
- package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +107 -0
- package/lib/typescript/module/connections/disambiguate.d.ts +43 -0
- package/lib/typescript/module/connections/types.d.ts +91 -0
- package/lib/typescript/module/connections/useConnectionSetup.d.ts +96 -0
- package/lib/typescript/module/controls/FilePicker.d.ts +65 -0
- package/lib/typescript/module/controls/ImagePicker.d.ts +76 -0
- package/lib/typescript/module/index.d.ts +42 -0
- package/lib/typescript/module/logger.d.ts +11 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/platform/PowerPlatformConnectionApi.d.ts +205 -0
- package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +108 -0
- package/lib/typescript/module/platform/resolveConnections.d.ts +86 -0
- package/lib/typescript/module/platform/useConnectionRefs.d.ts +126 -0
- package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +123 -0
- package/lib/typescript/module/provider/PowerAppsProvider.d.ts +148 -0
- package/lib/typescript/module/telemetry/index.d.ts +48 -0
- package/lib/typescript/module/theme/ThemeProvider.d.ts +30 -0
- package/lib/typescript/module/theme/tokens.d.ts +27 -0
- package/lib/typescript/module/utils/dataverseUtils.d.ts +39 -0
- package/lib/typescript/module/utils/isDevPlayer.d.ts +19 -0
- package/package.json +119 -0
- package/scripts/build-ios-base.js +96 -0
- package/scripts/bundle.js +95 -0
- package/scripts/generate-connector-schemas.js +75 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — setupNativeHost
|
|
3
|
+
*
|
|
4
|
+
* Registers a NativePowerAppsBridge on the JS global (globalThis.powerAppsBridge)
|
|
5
|
+
* so the @microsoft/power-apps SDK picks it up automatically on the first data
|
|
6
|
+
* operation. The SDK reads globalThis.powerAppsBridge in getBridge() before
|
|
7
|
+
* falling back to the web DefaultPowerAppsBridge.
|
|
8
|
+
*
|
|
9
|
+
* Call this once at app root before any data operations. Re-calling with updated
|
|
10
|
+
* options (e.g. when connections change) is safe — it updates the existing bridge
|
|
11
|
+
* in-place without resetting the SDK's cached bridge promise.
|
|
12
|
+
*/
|
|
13
|
+
import type { NativeBridgeOptions } from './NativePowerAppsBridge.js';
|
|
14
|
+
/**
|
|
15
|
+
* Registers a NativePowerAppsBridge for all @microsoft/power-apps SDK calls.
|
|
16
|
+
*
|
|
17
|
+
* On first call, creates a NativePowerAppsBridge and injects it into
|
|
18
|
+
* `globalThis.powerAppsBridge`. Subsequent calls update the bridge's options
|
|
19
|
+
* in-place so connection references and data sources can change without
|
|
20
|
+
* rebuilding the bridge (important because the SDK caches the bridge instance
|
|
21
|
+
* after first use).
|
|
22
|
+
*
|
|
23
|
+
* Idempotent with the same options reference — no-op if nothing changed.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // App.tsx (root)
|
|
28
|
+
* import { setupNativeHost } from '@microsoft/power-apps-native-host';
|
|
29
|
+
*
|
|
30
|
+
* setupNativeHost({
|
|
31
|
+
* getConnectorToken: (apiId) => msalClient.acquireToken({ resource: apiId }),
|
|
32
|
+
* getDataverseToken: (datasetName) => msalClient.acquireToken({ resource: datasetName }),
|
|
33
|
+
* dataSources: appManifest.dataSources,
|
|
34
|
+
* connections: appManifest.connections,
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function setupNativeHost(options: NativeBridgeOptions): void;
|
|
39
|
+
//# sourceMappingURL=setupNativeHost.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — ConnectionSetupScreen
|
|
3
|
+
*
|
|
4
|
+
* A ready-made React Native screen that drives the "create missing connections"
|
|
5
|
+
* flow before the Power Apps player is shown.
|
|
6
|
+
*
|
|
7
|
+
* Intended usage in an expo-router layout:
|
|
8
|
+
*
|
|
9
|
+
* // app/(app)/_layout.tsx
|
|
10
|
+
* import { ConnectionSetupScreen } from '@microsoft/power-apps-native-host';
|
|
11
|
+
*
|
|
12
|
+
* if (missingConnectors.length > 0) {
|
|
13
|
+
* return (
|
|
14
|
+
* <ConnectionSetupScreen
|
|
15
|
+
* missingConnectors={missingConnectors} // from useConnectionRefs
|
|
16
|
+
* schemaMap={schemaMap}
|
|
17
|
+
* environmentId={powerConfig.environmentId}
|
|
18
|
+
* region={powerConfig.region}
|
|
19
|
+
* acquireToken={acquireToken}
|
|
20
|
+
* onAllConnected={(resolvedIds) => {
|
|
21
|
+
* // resolvedIds: Record<apiId, connectionId>
|
|
22
|
+
* // Store them, then set missingConnectors = [] to unmount this screen.
|
|
23
|
+
* }}
|
|
24
|
+
* onSkip={() => { ... }} // optional — hide skip button if not provided
|
|
25
|
+
* />
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* What the screen does for each missing connector, in order:
|
|
30
|
+
* 1. Shows connector name / description (fetched from API).
|
|
31
|
+
* 2. "Connect" button → calls createConnection → shows an in-app WebView
|
|
32
|
+
* with the OAuth consent URL.
|
|
33
|
+
* 3. "Done" button in WebView header → calls checkNow() to confirm status.
|
|
34
|
+
* 4. On Connected → advances to the next missing connector.
|
|
35
|
+
* 5. When all connectors are resolved → calls onAllConnected.
|
|
36
|
+
*
|
|
37
|
+
* The component has zero production dependencies beyond react-native.
|
|
38
|
+
* It purposely does NOT depend on expo-router or any navigation library —
|
|
39
|
+
* the consuming app decides how to render it (full-screen, modal, etc.).
|
|
40
|
+
*/
|
|
41
|
+
import React from 'react';
|
|
42
|
+
import type { ConnectorSchema } from '../platform/useConnectionRefs.js';
|
|
43
|
+
export interface MissingConnectorEntry {
|
|
44
|
+
/** Connector API ID (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
|
|
45
|
+
apiId: string;
|
|
46
|
+
/** Local ref ID from power.config.json (for correlation). */
|
|
47
|
+
localRefId: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ConnectionSetupScreenProps {
|
|
50
|
+
/**
|
|
51
|
+
* List of connectors that have no Connected connection.
|
|
52
|
+
* Each entry has the apiId and localRefId from the disambiguation result.
|
|
53
|
+
*/
|
|
54
|
+
missingConnectors: MissingConnectorEntry[];
|
|
55
|
+
/**
|
|
56
|
+
* Connector schema map (from generate-connector-schemas / schemaMap).
|
|
57
|
+
* Used to map apiId → connectorId (short name) for API calls.
|
|
58
|
+
*/
|
|
59
|
+
schemaMap: Record<string, ConnectorSchema>;
|
|
60
|
+
environmentId: string;
|
|
61
|
+
region?: string;
|
|
62
|
+
acquireToken: (scopes: string[]) => Promise<string | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Called when all missing connections have been resolved.
|
|
65
|
+
* `resolvedIds` maps apiId → connectionId for all newly created connections.
|
|
66
|
+
*/
|
|
67
|
+
onAllConnected: (resolvedIds: Record<string, string>) => void;
|
|
68
|
+
/**
|
|
69
|
+
* If provided, a "Skip" button is shown. Useful for non-blocking connection flows.
|
|
70
|
+
* The app should handle the case where connections remain unresolved.
|
|
71
|
+
*/
|
|
72
|
+
onSkip?: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* The ISV/wrap-app AAD client ID (from auth.config.json `msal.clientId`).
|
|
75
|
+
* Passed to `useConnectionSetup` so the ISV's service principal is granted
|
|
76
|
+
* access on each newly created connection, fixing the APIM 403 for
|
|
77
|
+
* third-party app tokens.
|
|
78
|
+
*/
|
|
79
|
+
isvClientId?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Optional custom renderer for the OAuth WebView.
|
|
82
|
+
* Receives the consent URL and a dismiss callback.
|
|
83
|
+
* If not provided, `Linking.openURL()` is used to open the URL in the system browser.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // Using react-native-webview:
|
|
87
|
+
* renderOAuthWebView={(url, onDone) => (
|
|
88
|
+
* <Modal visible animationType="slide">
|
|
89
|
+
* <WebView source={{ uri: url }} />
|
|
90
|
+
* <Button title="Done" onPress={onDone} />
|
|
91
|
+
* </Modal>
|
|
92
|
+
* )}
|
|
93
|
+
*/
|
|
94
|
+
renderOAuthWebView?: (url: string, onDone: () => void) => React.ReactNode;
|
|
95
|
+
/** Optional title override (default: "Set up connections"). */
|
|
96
|
+
title?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Full-screen component that steps the user through creating each missing
|
|
100
|
+
* connection before the Power Apps player is launched.
|
|
101
|
+
*
|
|
102
|
+
* The screen works through missing connectors sequentially. Once all are
|
|
103
|
+
* resolved `onAllConnected` fires and the parent app should unmount this
|
|
104
|
+
* component and proceed to launch the app.
|
|
105
|
+
*/
|
|
106
|
+
export declare function ConnectionSetupScreen({ missingConnectors, schemaMap, environmentId, region, acquireToken, isvClientId, onAllConnected, onSkip, renderOAuthWebView, title, }: ConnectionSetupScreenProps): React.JSX.Element;
|
|
107
|
+
//# sourceMappingURL=ConnectionSetupScreen.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — connection disambiguation logic
|
|
3
|
+
*
|
|
4
|
+
* Pure function that matches power.config.json connectionReferences to the
|
|
5
|
+
* connection instances available in the user's Power Platform environment.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the core of ConnectionPipeline.matchConnectionsToUsages in the web
|
|
8
|
+
* host but is self-contained — it does not require IConnectionService or any
|
|
9
|
+
* other web-host dependency.
|
|
10
|
+
*/
|
|
11
|
+
import type { NativeConnectionInstance, NativeConnectionResolution } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Disambiguate a set of connection references against the user's available
|
|
14
|
+
* connection instances.
|
|
15
|
+
*
|
|
16
|
+
* Rules (in priority order):
|
|
17
|
+
* 1. If exactly one `Connected` connection matches the reference apiId → resolved.
|
|
18
|
+
* 2. If zero connections match (or none are Connected) → missing.
|
|
19
|
+
* 3. If multiple Connected connections match → ambiguous (needs user pick).
|
|
20
|
+
*
|
|
21
|
+
* @param connectionReferences The `connectionReferences` object from power.config.json,
|
|
22
|
+
* keyed by local reference ID.
|
|
23
|
+
* @param allConnectionsByApiId All connection instances fetched from the
|
|
24
|
+
* Power Platform connectivity API, keyed by
|
|
25
|
+
* connector apiId.
|
|
26
|
+
*/
|
|
27
|
+
export declare function disambiguateConnections(connectionReferences: Record<string, {
|
|
28
|
+
id: string;
|
|
29
|
+
dataSources: string[];
|
|
30
|
+
}>, allConnectionsByApiId: Record<string, NativeConnectionInstance[]>): NativeConnectionResolution[];
|
|
31
|
+
/**
|
|
32
|
+
* Extract the connection UUID from a raw connection name returned by the API.
|
|
33
|
+
*
|
|
34
|
+
* The API returns names like:
|
|
35
|
+
* "shared_office365users/abc12345def6789012345678901234ab" (connector-prefixed)
|
|
36
|
+
* "abc12345def6789012345678901234ab" (bare UUID, no dashes)
|
|
37
|
+
* "abc12345-def6-7890-1234-5678901234ab" (UUID with dashes)
|
|
38
|
+
*
|
|
39
|
+
* Returns the 32-char hex ID (dashes stripped) or the raw string if no UUID
|
|
40
|
+
* pattern is found.
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractConnectionId(rawName: string): string;
|
|
43
|
+
//# sourceMappingURL=disambiguate.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — connection disambiguation types
|
|
3
|
+
*
|
|
4
|
+
* Defines the native-host-specific types for connection resolution. The web
|
|
5
|
+
* host equivalents live in @microsoft/power-apps-host, but the native host
|
|
6
|
+
* implements a lighter version that does not depend on IConnectionService.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolved authorization state of a connection instance.
|
|
10
|
+
*
|
|
11
|
+
* - `Connected` — platform status is Connected AND the ISV appid is in the connection ACL.
|
|
12
|
+
* - `NeedsAclGrant` — platform status is Connected but the ISV appid is missing from the ACL.
|
|
13
|
+
* - `NotConnected` — platform status is anything other than Connected.
|
|
14
|
+
*/
|
|
15
|
+
export declare enum ConnectionStatus {
|
|
16
|
+
Connected = "Connected",
|
|
17
|
+
NeedsAclGrant = "NeedsAclGrant",
|
|
18
|
+
NotConnected = "NotConnected"
|
|
19
|
+
}
|
|
20
|
+
/** A single connection instance returned by the Power Platform connectivity API. */
|
|
21
|
+
export interface NativeConnectionInstance {
|
|
22
|
+
/** Extracted connection UUID (hex, no dashes). */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Full resource name from the API (connector-prefixed, e.g. "shared_office365users/abc123"). */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Connector API identifier (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
|
|
27
|
+
apiId: string;
|
|
28
|
+
/** Resolved authorization status of this connection. */
|
|
29
|
+
status: ConnectionStatus;
|
|
30
|
+
/** Optional human-readable display name from the API. */
|
|
31
|
+
displayName?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of attempting to match a single connection reference to an instance.
|
|
35
|
+
*
|
|
36
|
+
* - `resolved` — exactly one Connected connection found; `connectionId` is set.
|
|
37
|
+
* - `missing` — no connections found for this connector in the user's environment.
|
|
38
|
+
* - `ambiguous` — multiple Connected connections found; the app must pick one.
|
|
39
|
+
*/
|
|
40
|
+
export type NativeDisambiguationResult = {
|
|
41
|
+
kind: 'resolved';
|
|
42
|
+
connectionId: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'missing';
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'ambiguous';
|
|
47
|
+
candidates: NativeConnectionInstance[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Disambiguation result for a single connection reference (one apiId, possibly
|
|
51
|
+
* mapped to multiple data source names in the final connections map).
|
|
52
|
+
*/
|
|
53
|
+
export interface NativeConnectionResolution {
|
|
54
|
+
/** Local reference key in power.config.json connectionReferences (e.g. "office365users-1"). */
|
|
55
|
+
localRefId: string;
|
|
56
|
+
/** Connector API ID (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
|
|
57
|
+
apiId: string;
|
|
58
|
+
/** Data source names this reference covers (e.g. ["office365users"]). */
|
|
59
|
+
dataSources: string[];
|
|
60
|
+
result: NativeDisambiguationResult;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Callback invoked when a connection reference has multiple Connected candidate
|
|
64
|
+
* connections. The consuming app should present a native picker UI (e.g. a
|
|
65
|
+
* bottom sheet) and return the selected connection ID.
|
|
66
|
+
*
|
|
67
|
+
* Return `null` to leave the connection unresolved (the SDK will receive an
|
|
68
|
+
* empty `connectionName` and data operations for that connector will fail).
|
|
69
|
+
*
|
|
70
|
+
* @param context.localRefId — local reference key from power.config.json
|
|
71
|
+
* @param context.apiId — connector API identifier
|
|
72
|
+
* @param context.candidates — list of Connected connection instances to choose from
|
|
73
|
+
*/
|
|
74
|
+
export type OnDisambiguationNeeded = (context: {
|
|
75
|
+
localRefId: string;
|
|
76
|
+
apiId: string;
|
|
77
|
+
candidates: NativeConnectionInstance[];
|
|
78
|
+
}) => Promise<string | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Callback invoked when the user has no connection for a required connector.
|
|
81
|
+
*
|
|
82
|
+
* The consuming app can redirect to the Power Apps maker portal or show an
|
|
83
|
+
* in-app connection setup flow. Return `true` to indicate the user has
|
|
84
|
+
* created a connection and the hook should retry; return `false` to leave the
|
|
85
|
+
* connection unresolved.
|
|
86
|
+
*/
|
|
87
|
+
export type OnMissingConnection = (context: {
|
|
88
|
+
localRefId: string;
|
|
89
|
+
apiId: string;
|
|
90
|
+
}) => Promise<boolean>;
|
|
91
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host — useConnectionSetup
|
|
3
|
+
*
|
|
4
|
+
* A hook that drives the "create missing connection" flow for a single connector.
|
|
5
|
+
*
|
|
6
|
+
* Usage pattern (in the ConnectionSetupScreen):
|
|
7
|
+
*
|
|
8
|
+
* const setup = useConnectionSetup({
|
|
9
|
+
* connectorId: 'shared_office365users',
|
|
10
|
+
* environmentId,
|
|
11
|
+
* region,
|
|
12
|
+
* acquireToken,
|
|
13
|
+
* onConnected: (connectionId) => { ... mark resolved, advance to next ... }
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Render setup.consentUrl in a WebView when setup.phase === 'oauth'
|
|
17
|
+
* // Call setup.startCreate() to trigger connection creation
|
|
18
|
+
* // Call setup.checkNow() to re-poll after WebView finishes
|
|
19
|
+
*/
|
|
20
|
+
import type { NativeConnectionInstance } from '../connections/types.js';
|
|
21
|
+
/**
|
|
22
|
+
* The current phase of the connection setup flow for one connector.
|
|
23
|
+
*
|
|
24
|
+
* idle — not yet started.
|
|
25
|
+
* creating — POST in progress (showing a spinner).
|
|
26
|
+
* oauth — connection created; OAuth consent URL is ready (show WebView).
|
|
27
|
+
* confirming — WebView dismissed; polling for Connected status.
|
|
28
|
+
* connected — connection is Connected; ready to proceed.
|
|
29
|
+
* error — unrecoverable error; `errorMessage` is set.
|
|
30
|
+
*/
|
|
31
|
+
export type ConnectionSetupPhase = 'idle' | 'creating' | 'oauth' | 'confirming' | 'connected' | 'error';
|
|
32
|
+
export interface UseConnectionSetupOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Connector short name (e.g. "shared_office365users").
|
|
35
|
+
* Must match the connectorId used in the connectivity API (schema.name from schemaMap).
|
|
36
|
+
*/
|
|
37
|
+
connectorId: string;
|
|
38
|
+
environmentId: string;
|
|
39
|
+
/** Cluster region (default "prod"). */
|
|
40
|
+
region?: string;
|
|
41
|
+
acquireToken: (scopes: string[]) => Promise<string | null>;
|
|
42
|
+
/** Called with the resolved `NativeConnectionInstance` when the connection is Connected. */
|
|
43
|
+
onConnected?: (instance: NativeConnectionInstance) => void;
|
|
44
|
+
/**
|
|
45
|
+
* The ISV/wrap-app AAD client ID (from auth.config.json `msal.clientId`).
|
|
46
|
+
* After connection creation, `addAadAppToConnectionAcl` is called to append
|
|
47
|
+
* the ISV's client ID to the connection ACE's AppIds list. This is required
|
|
48
|
+
* so that APIM accepts tokens bearing this appid at runtime (otherwise APIM
|
|
49
|
+
* returns 403 "missing connection ACL" for all third-party app tokens).
|
|
50
|
+
*/
|
|
51
|
+
isvClientId?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Redirect URL passed to the getConsentLink API call.
|
|
54
|
+
* Defaults to the standard native-client redirect accepted by Power Platform.
|
|
55
|
+
*/
|
|
56
|
+
oauthRedirectUrl?: string;
|
|
57
|
+
/** Polling options forwarded to pollConnectionStatus. */
|
|
58
|
+
polling?: {
|
|
59
|
+
intervalMs?: number;
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface UseConnectionSetupResult {
|
|
64
|
+
/** Current phase of the flow. */
|
|
65
|
+
phase: ConnectionSetupPhase;
|
|
66
|
+
/** OAuth consent URL — render in a WebView when phase === 'oauth'. */
|
|
67
|
+
consentUrl: string | null;
|
|
68
|
+
/** Error message when phase === 'error'. */
|
|
69
|
+
errorMessage: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Start the connection creation flow.
|
|
72
|
+
* Transitions: idle/error → creating → (oauth | connected | error).
|
|
73
|
+
*/
|
|
74
|
+
startCreate: () => Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Call after the OAuth WebView is dismissed (or anytime during 'oauth' phase)
|
|
77
|
+
* to immediately poll the connection status instead of waiting for the next
|
|
78
|
+
* scheduled poll interval.
|
|
79
|
+
* Transitions: oauth → confirming → (connected | error).
|
|
80
|
+
*/
|
|
81
|
+
checkNow: () => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Call after the in-app browser session completes.
|
|
84
|
+
*
|
|
85
|
+
* If a `code` (CommitTokenCode) was returned in the redirect URL, it is
|
|
86
|
+
* POSTed to `confirmConsentCode` before polling. If no code is provided
|
|
87
|
+
* (custom-scheme redirect or dismiss), polling starts immediately.
|
|
88
|
+
*
|
|
89
|
+
* Transitions: oauth → confirming → (connected | error).
|
|
90
|
+
*/
|
|
91
|
+
completeConsent: (code?: string) => Promise<void>;
|
|
92
|
+
/** Reset the flow back to idle (e.g., for a retry). */
|
|
93
|
+
reset: () => void;
|
|
94
|
+
}
|
|
95
|
+
export declare function useConnectionSetup({ connectorId, environmentId, region, acquireToken, onConnected, isvClientId, oauthRedirectUrl, polling, }: UseConnectionSetupOptions): UseConnectionSetupResult;
|
|
96
|
+
//# sourceMappingURL=useConnectionSetup.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle, type TextStyle } from 'react-native';
|
|
3
|
+
export interface PickedFileInfo {
|
|
4
|
+
uri: string;
|
|
5
|
+
name: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
/** File-compatible object ready for generated Dataverse upload methods. */
|
|
8
|
+
file: File;
|
|
9
|
+
/** Raw bytes of the file, ready to pass to lower-level upload APIs. */
|
|
10
|
+
bytes: Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
export interface FilePickerProps {
|
|
13
|
+
label?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The file name to display.
|
|
16
|
+
* - In view mode: the name of the existing Dataverse file.
|
|
17
|
+
* - In edit mode: the existing file name; falls back to the name of a newly picked file.
|
|
18
|
+
*/
|
|
19
|
+
fileName?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* If provided, the file name row becomes tappable: calls this to obtain the
|
|
22
|
+
* raw bytes, writes them to the device cache, and opens the system share sheet.
|
|
23
|
+
*/
|
|
24
|
+
onDownload?: () => Promise<Uint8Array>;
|
|
25
|
+
/** Share sheet dialog title. Defaults to `fileName`. */
|
|
26
|
+
shareTitle?: string;
|
|
27
|
+
/**
|
|
28
|
+
* If provided, a pick/replace button is shown.
|
|
29
|
+
* Called with the picked file and its pre-read bytes; the parent passes
|
|
30
|
+
* `bytes` directly to the upload service at save time.
|
|
31
|
+
*/
|
|
32
|
+
onChange?: (file: PickedFileInfo) => void;
|
|
33
|
+
/** MIME type filter for the document picker. Defaults to all files. */
|
|
34
|
+
acceptedTypes?: string[];
|
|
35
|
+
/** Override the initial pick button label. */
|
|
36
|
+
pickButtonLabel?: string;
|
|
37
|
+
/** Override the replace button label after a file exists. */
|
|
38
|
+
replaceButtonLabel?: string;
|
|
39
|
+
/** Override the button label while the picked file is being read. */
|
|
40
|
+
readingLabel?: string;
|
|
41
|
+
/** Override the outer container (adds margin below by default). */
|
|
42
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
43
|
+
/** Override the label text style. */
|
|
44
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
45
|
+
/** Override the file-name row container. */
|
|
46
|
+
fileRowStyle?: StyleProp<ViewStyle>;
|
|
47
|
+
/** Override the file-name text. */
|
|
48
|
+
fileNameStyle?: StyleProp<TextStyle>;
|
|
49
|
+
/** Override the pick/replace button container. */
|
|
50
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
51
|
+
/** Override the pick/replace button text. */
|
|
52
|
+
buttonTextStyle?: StyleProp<TextStyle>;
|
|
53
|
+
/** Accent colour used for icons, borders and text. Defaults to `'#0078d4'`. */
|
|
54
|
+
accentColor?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A unified file component for view and edit scenarios.
|
|
58
|
+
*
|
|
59
|
+
* - Pass `onDownload` alone for a read-only row that opens the share sheet on tap.
|
|
60
|
+
* - Pass `onChange` alone for a pick-only button (e.g. in an edit form).
|
|
61
|
+
* - Pass both to show the existing file name (tappable to download) alongside a
|
|
62
|
+
* replace button — useful when the edit screen should also allow previewing.
|
|
63
|
+
*/
|
|
64
|
+
export declare function FilePicker({ label, fileName, onDownload, shareTitle, onChange, acceptedTypes, pickButtonLabel, replaceButtonLabel, readingLabel, containerStyle, labelStyle, fileRowStyle, fileNameStyle, buttonStyle, buttonTextStyle, accentColor, }: FilePickerProps): React.JSX.Element;
|
|
65
|
+
//# sourceMappingURL=FilePicker.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle, type TextStyle, type ImageStyle } from 'react-native';
|
|
3
|
+
import * as ExpoImagePicker from 'expo-image-picker';
|
|
4
|
+
export interface PickedImageInfo {
|
|
5
|
+
uri: string;
|
|
6
|
+
name: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
base64: string;
|
|
9
|
+
/** File-compatible object ready for generated Dataverse upload methods. */
|
|
10
|
+
file: File;
|
|
11
|
+
/** Raw bytes of the image, ready to pass to lower-level upload APIs. */
|
|
12
|
+
bytes: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export interface ImagePickerProps {
|
|
15
|
+
label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Base64 string from Dataverse (the `cr_assetimage` thumbnail).
|
|
18
|
+
* The component builds the preview data URI internally.
|
|
19
|
+
* Pass `null` / `undefined` when there is no existing image.
|
|
20
|
+
*/
|
|
21
|
+
initialBase64?: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Called when the user picks a new image.
|
|
24
|
+
* Receives the base64-encoded string, ready to include in a Dataverse PATCH body.
|
|
25
|
+
* Called with `null` if the user clears the image (future use).
|
|
26
|
+
*/
|
|
27
|
+
onChange?: (base64: string | null) => void;
|
|
28
|
+
/** Called when the user picks a new image. Includes a generated-service-ready File object. */
|
|
29
|
+
onImageChange?: (image: PickedImageInfo | null) => void;
|
|
30
|
+
/** File name used when the selected image asset does not provide one. */
|
|
31
|
+
imageFileName?: string;
|
|
32
|
+
/** JPEG/PNG compression quality passed to expo-image-picker. Defaults to 0.8. */
|
|
33
|
+
quality?: number;
|
|
34
|
+
/** Enable the platform image editor after selecting or taking a photo. Defaults to false. */
|
|
35
|
+
allowsEditing?: boolean;
|
|
36
|
+
/** Android-only crop aspect ratio used when `allowsEditing` is true. */
|
|
37
|
+
aspect?: [number, number];
|
|
38
|
+
/** Android-only crop shape used when `allowsEditing` is true. */
|
|
39
|
+
cropShape?: ExpoImagePicker.CropShape;
|
|
40
|
+
/** Include EXIF metadata in the Expo picker asset. Defaults to false. */
|
|
41
|
+
exif?: boolean;
|
|
42
|
+
/** Use Android's legacy media picker. Defaults to false. */
|
|
43
|
+
legacy?: boolean;
|
|
44
|
+
/** Override the camera button label. */
|
|
45
|
+
cameraButtonLabel?: string;
|
|
46
|
+
/** Override the initial image-library button label. */
|
|
47
|
+
selectButtonLabel?: string;
|
|
48
|
+
/** Override the image-library button label after an image exists. */
|
|
49
|
+
changeButtonLabel?: string;
|
|
50
|
+
/** Override the button label while the picked image is being read. */
|
|
51
|
+
readingLabel?: string;
|
|
52
|
+
/** Override the outer container (adds margin below by default). */
|
|
53
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
54
|
+
/** Override the label text style. */
|
|
55
|
+
labelStyle?: StyleProp<TextStyle>;
|
|
56
|
+
/** Override the button row container. */
|
|
57
|
+
buttonRowStyle?: StyleProp<ViewStyle>;
|
|
58
|
+
/** Override each button container. */
|
|
59
|
+
buttonStyle?: StyleProp<ViewStyle>;
|
|
60
|
+
/** Override each button text. */
|
|
61
|
+
buttonTextStyle?: StyleProp<TextStyle>;
|
|
62
|
+
/** Override the image preview. */
|
|
63
|
+
previewStyle?: StyleProp<ImageStyle>;
|
|
64
|
+
/** Accent colour used for icons, borders and text. Defaults to `'#0078d4'`. */
|
|
65
|
+
accentColor?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A self-contained image picker that shows a preview and lets the user
|
|
69
|
+
* choose a new image from the library. Works on Android and iOS.
|
|
70
|
+
*
|
|
71
|
+
* - Existing images are seeded from a Dataverse base64 string via `initialBase64`.
|
|
72
|
+
* - On pick, the image is returned as base64 for legacy callers and as a
|
|
73
|
+
* File-compatible object for generated Dataverse upload methods.
|
|
74
|
+
*/
|
|
75
|
+
export declare function ImagePicker({ label, initialBase64, onChange, containerStyle, labelStyle, buttonRowStyle, buttonStyle, buttonTextStyle, previewStyle, accentColor, onImageChange, imageFileName, quality, allowsEditing, aspect, cropShape, exif, legacy, cameraButtonLabel, selectButtonLabel, changeButtonLabel, readingLabel, }: ImagePickerProps): React.JSX.Element;
|
|
76
|
+
//# sourceMappingURL=ImagePicker.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* power-apps-native-host
|
|
3
|
+
* React Native host integration for @microsoft/power-apps
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export { NativePowerAppsBridge } from './bridge/NativePowerAppsBridge.js';
|
|
7
|
+
export type { NativeBridgeOptions, CdsDataSourceConfig, AppConnection, AppConnectionReference } from './bridge/NativePowerAppsBridge.js';
|
|
8
|
+
export { buildConnectionReferences } from './bridge/NativePowerAppsBridge.js';
|
|
9
|
+
export { setupNativeHost } from './bridge/setupNativeHost.js';
|
|
10
|
+
export { AuthProvider, useAuth } from './auth/AuthContext.js';
|
|
11
|
+
export type { AuthState, AuthProviderProps } from './auth/AuthContext.js';
|
|
12
|
+
export type { AuthConfig, MsalAuthConfig, IntuneConfig } from '@microsoft/power-apps-native-auth';
|
|
13
|
+
export { PowerAppsHostProvider } from './provider/PowerAppsHostProvider.js';
|
|
14
|
+
export type { PowerAppsHostProviderProps } from './provider/PowerAppsHostProvider.js';
|
|
15
|
+
export { PowerAppsProvider } from './provider/PowerAppsProvider.js';
|
|
16
|
+
export type { PowerAppsProviderProps, PowerConfig } from './provider/PowerAppsProvider.js';
|
|
17
|
+
export { fetchInstanceUrl, buildCdsDataSources, buildEnvironmentEndpoint, POWER_PLATFORM_API_SCOPE } from './platform/PowerPlatformEnvironmentApi.js';
|
|
18
|
+
export type { LinkedEnvironmentMetadata, DatabaseReference, DatabaseReferenceDataSource } from './platform/PowerPlatformEnvironmentApi.js';
|
|
19
|
+
export { useConnectionRefs } from './platform/useConnectionRefs.js';
|
|
20
|
+
export type { UseConnectionRefsOptions, UseConnectionRefsResult, ConnectorSchema } from './platform/useConnectionRefs.js';
|
|
21
|
+
export { fetchConnectorMetadata, fetchConnectionsForConnector, createConnection, pollConnectionStatus, confirmConsentCode, fetchAppLaunchData, } from './platform/PowerPlatformConnectionApi.js';
|
|
22
|
+
export type { ConnectorMetadata, CreateConnectionResult, AppLaunchResult, } from './platform/PowerPlatformConnectionApi.js';
|
|
23
|
+
export { disambiguateConnections, extractConnectionId } from './connections/disambiguate.js';
|
|
24
|
+
export type { NativeConnectionInstance, NativeConnectionResolution, NativeDisambiguationResult, OnDisambiguationNeeded, OnMissingConnection, } from './connections/types.js';
|
|
25
|
+
export { useConnectionSetup } from './connections/useConnectionSetup.js';
|
|
26
|
+
export type { ConnectionSetupPhase, UseConnectionSetupOptions, UseConnectionSetupResult, } from './connections/useConnectionSetup.js';
|
|
27
|
+
export { ConnectionSetupScreen } from './connections/ConnectionSetupScreen.js';
|
|
28
|
+
export type { MissingConnectorEntry, ConnectionSetupScreenProps, } from './connections/ConnectionSetupScreen.js';
|
|
29
|
+
export { ThemeProvider, useThemeTokens, useThemeControl } from './theme/ThemeProvider.js';
|
|
30
|
+
export type { ThemeProviderProps, ThemeControl } from './theme/ThemeProvider.js';
|
|
31
|
+
export { lightTheme, darkTheme } from './theme/tokens.js';
|
|
32
|
+
export type { ThemeTokens } from './theme/tokens.js';
|
|
33
|
+
export { FilePicker } from './controls/FilePicker.js';
|
|
34
|
+
export type { FilePickerProps, PickedFileInfo } from './controls/FilePicker.js';
|
|
35
|
+
export { ImagePicker } from './controls/ImagePicker.js';
|
|
36
|
+
export type { ImagePickerProps, PickedImageInfo } from './controls/ImagePicker.js';
|
|
37
|
+
export { isDevPlayer } from './utils/isDevPlayer.js';
|
|
38
|
+
export { base64ToDataverseUploadFile, base64ToUint8Array, createDataverseUploadFile, } from './utils/dataverseUtils.js';
|
|
39
|
+
export { getAppLogger, configureAppLogger, HostOperationNames } from './telemetry/index.js';
|
|
40
|
+
export type { ILogger } from '@microsoft/power-apps-native-common';
|
|
41
|
+
export { ErrorBoundary } from './ErrorBoundary.js';
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conditional debug logger for power-apps-native-host.
|
|
3
|
+
*
|
|
4
|
+
* Debug logs (debugLog / debugWarn) are only emitted when the JS bundle
|
|
5
|
+
* is running inside the Power Apps Dev Player (detected via
|
|
6
|
+
* `Constants.expoConfig.extra.isDevPlayer`). They are silenced in release
|
|
7
|
+
* APKs generated from the template so the production log stream stays clean.
|
|
8
|
+
*/
|
|
9
|
+
export declare function debugLog(...args: unknown[]): void;
|
|
10
|
+
export declare function debugWarn(...args: unknown[]): void;
|
|
11
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|