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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +162 -26
  2. package/compatibility/current.json +87 -0
  3. package/lib/NOTICE.txt +140 -1226
  4. package/lib/commonjs/auth/AuthContext.js +74 -18
  5. package/lib/commonjs/auth/AuthContext.web.js +32 -0
  6. package/lib/commonjs/auth/completePowerAppsAuthSession.js +16 -0
  7. package/lib/commonjs/bridge/NativePowerAppsBridge.js +20 -17
  8. package/lib/commonjs/bridge/PowerPagesBridge.js +157 -0
  9. package/lib/commonjs/bridge/bridgeState.js +40 -0
  10. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  11. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  12. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  13. package/lib/commonjs/connections/connectionState.js +96 -0
  14. package/lib/commonjs/connections/disambiguate.js +19 -11
  15. package/lib/commonjs/connections/resolveConnections.js +347 -0
  16. package/lib/commonjs/connections/types.js +106 -0
  17. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +128 -65
  18. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  19. package/lib/commonjs/controls/FilePicker.js +6 -0
  20. package/lib/commonjs/controls/ImagePicker.js +8 -0
  21. package/lib/commonjs/index.js +188 -6
  22. package/lib/commonjs/logger.js +9 -6
  23. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  24. package/lib/commonjs/offline/useOfflineIntegration.js +12 -0
  25. package/lib/commonjs/offline/useOfflineIntegration.web.js +11 -0
  26. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +46 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  28. package/lib/commonjs/platform/DataverseDataSources.js +14 -0
  29. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +49 -0
  30. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  31. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  32. package/lib/commonjs/provider/PowerAppsHostProvider.js +156 -25
  33. package/lib/commonjs/provider/PowerAppsHostProvider.web.js +41 -0
  34. package/lib/commonjs/provider/PowerAppsProvider.js +229 -133
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +216 -0
  36. package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
  37. package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
  38. package/lib/commonjs/telemetry/index.js +22 -3
  39. package/lib/module/auth/AuthContext.js +74 -18
  40. package/lib/module/auth/AuthContext.web.js +26 -0
  41. package/lib/module/auth/completePowerAppsAuthSession.js +11 -0
  42. package/lib/module/bridge/NativePowerAppsBridge.js +21 -18
  43. package/lib/module/bridge/PowerPagesBridge.js +151 -0
  44. package/lib/module/bridge/bridgeState.js +34 -0
  45. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  46. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  47. package/lib/module/connections/connectionMetadata.js +112 -0
  48. package/lib/module/connections/connectionState.js +82 -0
  49. package/lib/module/connections/disambiguate.js +19 -12
  50. package/lib/module/connections/resolveConnections.js +342 -0
  51. package/lib/module/connections/types.js +91 -0
  52. package/lib/module/{platform → connections}/useConnectionRefs.js +129 -66
  53. package/lib/module/connections/useConnectionSetup.js +113 -54
  54. package/lib/module/controls/FilePicker.js +6 -0
  55. package/lib/module/controls/ImagePicker.js +8 -0
  56. package/lib/module/index.js +14 -6
  57. package/lib/module/logger.js +8 -6
  58. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  59. package/lib/module/offline/useOfflineIntegration.js +3 -0
  60. package/lib/module/offline/useOfflineIntegration.web.js +7 -0
  61. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +42 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  63. package/lib/module/platform/DataverseDataSources.js +10 -0
  64. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +45 -0
  65. package/lib/module/platform/GlobalDiscovery.js +45 -0
  66. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  67. package/lib/module/provider/PowerAppsHostProvider.js +159 -28
  68. package/lib/module/provider/PowerAppsHostProvider.web.js +36 -0
  69. package/lib/module/provider/PowerAppsProvider.js +233 -137
  70. package/lib/module/provider/SessionDetailsGesture.js +211 -0
  71. package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
  72. package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
  73. package/lib/module/telemetry/index.js +15 -4
  74. package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
  75. package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +21 -0
  76. package/lib/typescript/commonjs/auth/completePowerAppsAuthSession.d.ts +8 -0
  77. package/lib/typescript/commonjs/bridge/PowerPagesBridge.d.ts +18 -0
  78. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  79. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  80. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  81. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  82. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  83. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  84. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +19 -19
  85. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  86. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +33 -24
  87. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  88. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  89. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  90. package/lib/typescript/commonjs/index.d.ts +20 -10
  91. package/lib/typescript/commonjs/logger.d.ts +4 -4
  92. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  93. package/lib/typescript/commonjs/offline/useOfflineIntegration.d.ts +2 -0
  94. package/lib/typescript/commonjs/offline/useOfflineIntegration.web.d.ts +4 -0
  95. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  97. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +27 -0
  98. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  99. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  100. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  101. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.web.d.ts +5 -0
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +32 -10
  104. package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
  105. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  106. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  107. package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
  108. package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
  109. package/lib/typescript/module/auth/AuthContext.web.d.ts +21 -0
  110. package/lib/typescript/module/auth/completePowerAppsAuthSession.d.ts +8 -0
  111. package/lib/typescript/module/bridge/PowerPagesBridge.d.ts +18 -0
  112. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  113. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  114. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  115. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  116. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  117. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  118. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +19 -19
  119. package/lib/typescript/module/connections/types.d.ts +129 -1
  120. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +33 -24
  121. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  122. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  123. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  124. package/lib/typescript/module/index.d.ts +24 -14
  125. package/lib/typescript/module/logger.d.ts +4 -4
  126. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  127. package/lib/typescript/module/offline/useOfflineIntegration.d.ts +2 -0
  128. package/lib/typescript/module/offline/useOfflineIntegration.web.d.ts +4 -0
  129. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  131. package/lib/typescript/module/platform/DataverseDataSources.d.ts +27 -0
  132. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  133. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  134. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  135. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.web.d.ts +5 -0
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +34 -12
  138. package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
  139. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  140. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  141. package/lib/typescript/module/telemetry/index.d.ts +13 -1
  142. package/package.json +43 -18
  143. package/scripts/build-ios-base.js +66 -27
  144. package/scripts/bundle.js +212 -5
  145. package/scripts/generate-connector-schemas.js +8 -6
  146. package/scripts/metro-logger.js +213 -0
  147. package/scripts/start-web.mjs +137 -0
  148. package/scripts/upgrade/runtime.js +463 -0
  149. package/scripts/upgrade/system.js +244 -0
  150. package/scripts/upgrade-authoring.js +534 -0
  151. package/scripts/upgrade.js +188 -0
  152. package/scripts/wrap.js +536 -0
  153. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  154. package/lib/commonjs/platform/resolveConnections.js +0 -264
  155. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  156. package/lib/module/platform/resolveConnections.js +0 -259
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { parseArgs: parseNodeArgs } = require('node:util');
8
+ const { runAuthoringCommand } = require('./upgrade-authoring');
9
+ const {
10
+ HOST_PACKAGE,
11
+ buildUpgradePlan,
12
+ readJson,
13
+ } = require('./upgrade/runtime');
14
+ const {
15
+ UPGRADE_JOURNAL_PATH,
16
+ assertNoActiveUpgrade,
17
+ cleanupRejects,
18
+ detectPackageManager,
19
+ executePhase,
20
+ recoverInterruptedUpgrade,
21
+ reportNativeProjectState,
22
+ shouldValidate,
23
+ withUpgradeLock,
24
+ writeRejects,
25
+ } = require('./upgrade/system');
26
+
27
+ const PROFILE_PATH = path.join(__dirname, '..', 'compatibility', 'current.json');
28
+ const MIGRATIONS_PATH = path.join(__dirname, '..', 'compatibility', 'migrations');
29
+
30
+ function parseArgs(argv) {
31
+ const help = argv.includes('--help') || argv.includes('-h');
32
+ const { values, positionals } = parseNodeArgs({
33
+ args: help ? argv.filter(value => !['--help', '-h'].includes(value)) : argv,
34
+ allowPositionals: true,
35
+ strict: true,
36
+ options: {
37
+ 'dry-run': { type: 'boolean' },
38
+ 'no-install': { type: 'boolean' },
39
+ project: { type: 'string', default: process.cwd() },
40
+ 'from-tag': { type: 'string' },
41
+ 'from-version': { type: 'string' },
42
+ message: { type: 'string' },
43
+ id: { type: 'string' },
44
+ },
45
+ });
46
+ const fromVersion = values['from-version'] === undefined ? undefined : parsePositiveInteger(values['from-version']);
47
+ return {
48
+ command: positionals[0] || 'upgrade',
49
+ fromTag: values['from-tag'] || process.env.MIGRATION_BASE_TAG || null,
50
+ fromVersion,
51
+ dryRun: Boolean(values['dry-run']),
52
+ install: !values['no-install'],
53
+ project: path.resolve(values.project),
54
+ message: values.message,
55
+ id: values.id,
56
+ help,
57
+ };
58
+ }
59
+
60
+ function printHelp() {
61
+ console.log(`Usage: upgrade-template [command] [options]
62
+
63
+ Commands: upgrade, change, check, build
64
+
65
+ Options:
66
+ --dry-run Show changes without writing or installing
67
+ --no-install Write changes without installation or state advancement
68
+ --project PATH Project path (defaults to current directory)
69
+ --from-tag TAG Version tag for change/check
70
+ --from-version N Source template version for legacy apps
71
+ --message TEXT Changelog description
72
+ --id ID Migration ID
73
+ -h, --help Show this help`);
74
+ }
75
+
76
+ function parsePositiveInteger(value) {
77
+ const parsed = Number(value);
78
+ if (!Number.isInteger(parsed) || parsed < 1) throw new Error('--from-version must be a positive integer');
79
+ return parsed;
80
+ }
81
+
82
+ function findProjectRoot(startPath) {
83
+ let current = path.resolve(startPath);
84
+ if (fs.existsSync(current) && fs.statSync(current).isFile()) current = path.dirname(current);
85
+ while (true) {
86
+ const packagePath = path.join(current, 'package.json');
87
+ if (fs.existsSync(packagePath)) {
88
+ const packageJson = readJson(packagePath);
89
+ const dependencies = { ...packageJson.dependencies, ...packageJson.devDependencies };
90
+ if (dependencies.expo || dependencies[HOST_PACKAGE]) return current;
91
+ }
92
+ const parent = path.dirname(current);
93
+ if (parent === current) break;
94
+ current = parent;
95
+ }
96
+ throw new Error(`Could not find an Expo project from ${startPath}`);
97
+ }
98
+
99
+ function printPlan(projectRoot, profile, operations, conflicts, dryRun) {
100
+ console.log(`${dryRun ? '[dry-run] ' : ''}Target compatibility profile: ${profile.id} (Expo SDK ${profile.expoSdk})`);
101
+ if (!operations.length) {
102
+ console.log('Project files already match the target profile.');
103
+ return;
104
+ }
105
+ for (const operation of operations) {
106
+ console.log(`\n${path.relative(projectRoot, operation.filePath)}`);
107
+ for (const change of operation.changes) console.log(` - ${change}`);
108
+ for (const warning of operation.warnings || []) console.log(` ! ${warning}`);
109
+ }
110
+ if (conflicts.length) {
111
+ console.log(`\n${conflicts.length} patch conflict(s) require manual resolution.`);
112
+ }
113
+ }
114
+
115
+ async function main(argv = process.argv.slice(2)) {
116
+ const options = parseArgs(argv);
117
+ if (options.help) {
118
+ printHelp();
119
+ return;
120
+ }
121
+
122
+ if (!['upgrade', 'change', 'check', 'build'].includes(options.command)) {
123
+ throw new Error(`Unknown command: ${options.command}`);
124
+ }
125
+ if (options.command !== 'upgrade') {
126
+ await runAuthoringCommand(options.command, options.project, options);
127
+ return;
128
+ }
129
+
130
+ const projectRoot = findProjectRoot(options.project);
131
+ if (options.dryRun) await assertNoActiveUpgrade(projectRoot);
132
+ const runUpgrade = async () => {
133
+ const journalPath = path.join(projectRoot, UPGRADE_JOURNAL_PATH);
134
+ if (options.dryRun && fs.existsSync(journalPath)) {
135
+ throw new Error('An interrupted upgrade journal exists; rerun without --dry-run to recover it first');
136
+ }
137
+ recoverInterruptedUpgrade(projectRoot);
138
+ const profile = readJson(PROFILE_PATH);
139
+ const hostVersion = readJson(path.join(__dirname, '..', 'package.json')).version;
140
+ const fullPlan = buildUpgradePlan(projectRoot, profile, hostVersion, options.fromVersion, MIGRATIONS_PATH, options.install || options.dryRun);
141
+ const { operations, conflicts, migration, targetProfile, hasMore } = fullPlan;
142
+ printPlan(projectRoot, profile, operations, conflicts, options.dryRun);
143
+
144
+ if (conflicts.length) {
145
+ if (options.dryRun) throw new Error(`Dry run found patch conflicts; rerun without --dry-run to write .rej files for manual resolution.`);
146
+ writeRejects(operations);
147
+ throw new Error(`Patch conflicts were written as .rej files. Resolve them, delete the .rej files, and rerun the upgrade.`);
148
+ }
149
+ if (options.dryRun) return;
150
+
151
+ reportNativeProjectState(projectRoot);
152
+ const packageManager = detectPackageManager(projectRoot);
153
+
154
+ if (!options.install) {
155
+ executePhase(projectRoot, operations, packageManager, false);
156
+ cleanupRejects(projectRoot, migration);
157
+ console.log('\nApplied project files without installation or advancing template state. Rerun without --no-install to validate and record the upgrade.');
158
+ return;
159
+ }
160
+
161
+ if (migration) {
162
+ console.log(`\nApplying template ${migration.fromTemplateVersion} -> ${migration.toTemplateVersion} (${migration.id})...`);
163
+ }
164
+ const needsInstall = shouldValidate(migration, operations);
165
+ executePhase(projectRoot, operations, packageManager, needsInstall, undefined, targetProfile.expoDoctorVersion);
166
+ cleanupRejects(projectRoot, migration);
167
+ if (hasMore) {
168
+ console.log(`\nTemplate version ${migration.toTemplateVersion} completed successfully.`);
169
+ console.log(`Run npx --package ${HOST_PACKAGE}@latest upgrade-template for the next version.`);
170
+ } else {
171
+ console.log('\nUpgrade completed successfully.');
172
+ }
173
+ };
174
+ if (options.dryRun) return runUpgrade();
175
+ return withUpgradeLock(projectRoot, runUpgrade);
176
+ }
177
+
178
+ if (require.main === module) {
179
+ main().catch(error => {
180
+ console.error(`[upgrade-template] ${error.message}`);
181
+ process.exitCode = 1;
182
+ });
183
+ }
184
+
185
+ module.exports = {
186
+ main,
187
+ parseArgs,
188
+ };