Skip to content

Commit 77a979d

Browse files
authored
Merge pull request #701 from russrimm/russ
Update Power Apps Code Apps instructions: refine project context, improve folder structure, and clarify PowerProvider implementation
2 parents 7ebb991 + 836e4fc commit 77a979d

File tree

1 file changed

+38
-49
lines changed

1 file changed

+38
-49
lines changed

instructions/power-apps-code-apps.instructions.md

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
99

1010
## Project Context
1111

12-
- **Power Apps Code Apps (Preview)**: Code-first web app development with Power Platform integration
12+
- **Power Apps Code Apps**: Code-first web app development with Power Platform integration
1313
- **TypeScript + React**: Recommended frontend stack with Vite bundler
14-
- **Power Platform SDK**: @microsoft/power-apps (current version ^0.3.1) for connector integration
14+
- **Power Platform SDK**: @microsoft/power-apps (current version ^1.0.3) for connector integration
1515
- **PAC CLI**: Power Platform CLI for project management and deployment
1616
- **Port 3000**: Required for local development with Power Platform SDK
1717
- **Power Apps Premium**: End-user licensing requirement for production use
@@ -25,14 +25,15 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
2525
src/
2626
├── components/ # Reusable UI components
2727
├── hooks/ # Custom React hooks for Power Platform
28-
├── services/ # Generated connector services (PAC CLI)
29-
├── models/ # Generated TypeScript models (PAC CLI)
28+
├── generated/
29+
│ ├── services/ # Generated connector services (PAC CLI)
30+
│ └── models/ # Generated TypeScript models (PAC CLI)
3031
├── utils/ # Utility functions and helpers
3132
├── types/ # TypeScript type definitions
32-
├── PowerProvider.tsx # Power Platform initialization
33+
├── PowerProvider.tsx # Power Platform context wrapper
3334
└── main.tsx # Application entry point
3435
```
35-
- Keep generated files (`services/`, `models/`) separate from custom code
36+
- Keep generated files (`generated/services/`, `generated/models/`) separate from custom code
3637
- Use consistent naming conventions (kebab-case for files, PascalCase for components)
3738

3839
### TypeScript Configuration
@@ -77,7 +78,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
7778
```typescript
7879
// Example: Using custom PCF control for data visualization
7980
import { PCFControlWrapper } from './components/PCFControlWrapper';
80-
81+
8182
const MyComponent = () => {
8283
return (
8384
<PCFControlWrapper
@@ -95,7 +96,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
9596
- **Embed Power BI reports**: Integrate interactive dashboards and reports
9697
```typescript
9798
import { PowerBIEmbed } from 'powerbi-client-react';
98-
99+
99100
const DashboardComponent = () => {
100101
return (
101102
<PowerBIEmbed
@@ -123,12 +124,12 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
123124
const processDocument = async (file: File) => {
124125
const formData = new FormData();
125126
formData.append('file', file);
126-
127+
127128
const result = await AIBuilderService.ProcessDocument({
128129
modelId: 'document-processing-model-id',
129130
document: formData
130131
});
131-
132+
132133
return result.extractedFields;
133134
};
134135
```
@@ -141,12 +142,12 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
141142
```typescript
142143
import { DirectLine } from 'botframework-directlinejs';
143144
import { WebChat } from 'botframework-webchat';
144-
145+
145146
const ChatbotComponent = () => {
146147
const directLine = new DirectLine({
147148
token: chatbotToken
148149
});
149-
150+
150151
return (
151152
<div style={{ height: '400px', width: '100%' }}>
152153
<WebChat directLine={directLine} />
@@ -159,23 +160,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
159160
- Use generated TypeScript services from PAC CLI for connector operations
160161
- Implement proper authentication flows with Microsoft Entra ID
161162
- Handle connector consent dialogs and permission management
162-
- PowerProvider implementation pattern:
163+
- PowerProvider implementation pattern (no SDK initialization required in v1.0):
163164
```typescript
164-
import { initialize } from "@microsoft/power-apps/app";
165-
import { useEffect, type ReactNode } from "react";
165+
import type { ReactNode } from "react";
166166

167167
export default function PowerProvider({ children }: { children: ReactNode }) {
168-
useEffect(() => {
169-
const initApp = async () => {
170-
try {
171-
await initialize();
172-
console.log('Power Platform SDK initialized successfully');
173-
} catch (error) {
174-
console.error('Failed to initialize Power Platform SDK:', error);
175-
}
176-
};
177-
initApp();
178-
}, []);
179168
return <>{children}</>;
180169
}
181170
```
@@ -221,7 +210,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
221210
// Handle polymorphic customer lookup (Account or Contact)
222211
const customerType = record.customerType; // 'account' or 'contact'
223212
const customerId = record.customerId;
224-
const customer = customerType === 'account'
213+
const customer = customerType === 'account'
225214
? await AccountService.get(customerId)
226215
: await ContactService.get(customerId);
227216
```
@@ -257,7 +246,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
257246
const transaction = db.transaction(['data'], 'readwrite');
258247
transaction.objectStore('data').put({ id: key, data, timestamp: Date.now() });
259248
}
260-
249+
261250
async loadData(key: string) {
262251
const db = await this.openDB();
263252
const transaction = db.transaction(['data'], 'readonly');
@@ -397,9 +386,9 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
397386
onClick: () => void;
398387
children: React.ReactNode;
399388
}
400-
401-
export const Button: React.FC<ButtonProps> = ({
402-
variant, size, disabled, onClick, children
389+
390+
export const Button: React.FC<ButtonProps> = ({
391+
variant, size, disabled, onClick, children
403392
}) => {
404393
const classes = `btn btn-${variant} btn-${size} ${disabled ? 'btn-disabled' : ''}`;
405394
return <button className={classes} onClick={onClick} disabled={disabled}>{children}</button>;
@@ -416,14 +405,14 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
416405
theme: 'light',
417406
toggleTheme: () => {}
418407
});
419-
408+
420409
export const ThemeProvider: React.FC<{children: ReactNode}> = ({ children }) => {
421410
const [theme, setTheme] = useState<'light' | 'dark'>('light');
422-
411+
423412
const toggleTheme = () => {
424413
setTheme(prev => prev === 'light' ? 'dark' : 'light');
425414
};
426-
415+
427416
return (
428417
<ThemeContext.Provider value={{ theme, toggleTheme }}>
429418
<div className={`theme-${theme}`}>{children}</div>
@@ -441,7 +430,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
441430
.card-container {
442431
container-type: inline-size;
443432
}
444-
433+
445434
@container (min-width: 400px) {
446435
.card {
447436
display: grid;
@@ -456,7 +445,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
456445
- **Framer Motion integration**: Smooth animations and transitions
457446
```typescript
458447
import { motion, AnimatePresence } from 'framer-motion';
459-
448+
460449
const AnimatedCard = () => {
461450
return (
462451
<motion.div
@@ -480,8 +469,8 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
480469
- **ARIA implementation**: Proper semantic markup and ARIA attributes
481470
```typescript
482471
// Example: Accessible modal component
483-
const Modal: React.FC<{isOpen: boolean, onClose: () => void, children: ReactNode}> = ({
484-
isOpen, onClose, children
472+
const Modal: React.FC<{isOpen: boolean, onClose: () => void, children: ReactNode}> = ({
473+
isOpen, onClose, children
485474
}) => {
486475
useEffect(() => {
487476
if (isOpen) {
@@ -491,11 +480,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
491480
}
492481
return () => { document.body.style.overflow = 'unset'; };
493482
}, [isOpen]);
494-
483+
495484
return (
496-
<div
497-
role="dialog"
498-
aria-modal="true"
485+
<div
486+
role="dialog"
487+
aria-modal="true"
499488
aria-labelledby="modal-title"
500489
className={isOpen ? 'modal-open' : 'modal-hidden'}
501490
>
@@ -512,10 +501,10 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
512501
- **React-intl integration**: Multi-language support
513502
```typescript
514503
import { FormattedMessage, useIntl } from 'react-intl';
515-
504+
516505
const WelcomeMessage = ({ userName }: { userName: string }) => {
517506
const intl = useIntl();
518-
507+
519508
return (
520509
<h1>
521510
<FormattedMessage
@@ -539,8 +528,8 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
539528
- Content Security Policy (CSP) not yet supported
540529
- Storage SAS IP restrictions not supported
541530
- No Power Platform Git integration
542-
- No Dataverse solutions support
543-
- No native Azure Application Insights integration
531+
- Dataverse solutions supported, but solution packager and source code integration are limited
532+
- Application Insights supported through SDK logger configuration (no built-in native integration)
544533

545534
### Workarounds
546535

@@ -567,7 +556,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
567556
- **Package installation failures**: Clear npm cache with `npm cache clean --force` and reinstall
568557
- **TypeScript compilation errors**: Check verbatimModuleSyntax setting and SDK compatibility
569558
- **Connector permission errors**: Ensure proper consent flow and admin permissions
570-
- **PowerProvider initialization errors**: Check console for SDK initialization failures
559+
- **PowerProvider issues**: Ensure v1.0 apps do not wait on SDK initialization
571560
- **Vite dev server issues**: Ensure host and port configuration match requirements
572561

573562
### Deployment Issues
@@ -577,11 +566,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
577566
- **Connector unavailable**: Verify connector setup in Power Platform and connection status
578567
- **Performance issues**: Optimize bundle size with `npm run build --report` and implement caching
579568
- **Environment mismatch**: Confirm correct environment selection with `pac env list`
580-
- **App timeout errors**: Check PowerProvider.tsx implementation and network connectivity
569+
- **App timeout errors**: Check build output and network connectivity
581570

582571
### Runtime Issues
583572

584-
- **"App timed out" errors**: Verify npm run build was executed and PowerProvider is error-free
573+
- **"App timed out" errors**: Verify npm run build was executed and the deployment output is valid
585574
- **Connector authentication prompts**: Ensure proper consent flow implementation
586575
- **Data loading failures**: Check network requests and connector permissions
587576
- **UI rendering issues**: Verify Fluent UI compatibility and responsive design implementation

0 commit comments

Comments
 (0)