mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
Update Power Apps Code Apps instructions: refine project context, improve folder structure, and clarify PowerProvider implementation
This commit is contained in:
@@ -9,9 +9,9 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
|
|
||||||
## Project Context
|
## Project Context
|
||||||
|
|
||||||
- **Power Apps Code Apps (Preview)**: Code-first web app development with Power Platform integration
|
- **Power Apps Code Apps**: Code-first web app development with Power Platform integration
|
||||||
- **TypeScript + React**: Recommended frontend stack with Vite bundler
|
- **TypeScript + React**: Recommended frontend stack with Vite bundler
|
||||||
- **Power Platform SDK**: @microsoft/power-apps (current version ^0.3.1) for connector integration
|
- **Power Platform SDK**: @microsoft/power-apps (current version ^1.0.3) for connector integration
|
||||||
- **PAC CLI**: Power Platform CLI for project management and deployment
|
- **PAC CLI**: Power Platform CLI for project management and deployment
|
||||||
- **Port 3000**: Required for local development with Power Platform SDK
|
- **Port 3000**: Required for local development with Power Platform SDK
|
||||||
- **Power Apps Premium**: End-user licensing requirement for production use
|
- **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,
|
|||||||
src/
|
src/
|
||||||
├── components/ # Reusable UI components
|
├── components/ # Reusable UI components
|
||||||
├── hooks/ # Custom React hooks for Power Platform
|
├── hooks/ # Custom React hooks for Power Platform
|
||||||
├── services/ # Generated connector services (PAC CLI)
|
├── generated/
|
||||||
├── models/ # Generated TypeScript models (PAC CLI)
|
│ ├── services/ # Generated connector services (PAC CLI)
|
||||||
|
│ └── models/ # Generated TypeScript models (PAC CLI)
|
||||||
├── utils/ # Utility functions and helpers
|
├── utils/ # Utility functions and helpers
|
||||||
├── types/ # TypeScript type definitions
|
├── types/ # TypeScript type definitions
|
||||||
├── PowerProvider.tsx # Power Platform initialization
|
├── PowerProvider.tsx # Power Platform context wrapper
|
||||||
└── main.tsx # Application entry point
|
└── main.tsx # Application entry point
|
||||||
```
|
```
|
||||||
- Keep generated files (`services/`, `models/`) separate from custom code
|
- Keep generated files (`generated/services/`, `generated/models/`) separate from custom code
|
||||||
- Use consistent naming conventions (kebab-case for files, PascalCase for components)
|
- Use consistent naming conventions (kebab-case for files, PascalCase for components)
|
||||||
|
|
||||||
### TypeScript Configuration
|
### TypeScript Configuration
|
||||||
@@ -77,7 +78,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
```typescript
|
```typescript
|
||||||
// Example: Using custom PCF control for data visualization
|
// Example: Using custom PCF control for data visualization
|
||||||
import { PCFControlWrapper } from './components/PCFControlWrapper';
|
import { PCFControlWrapper } from './components/PCFControlWrapper';
|
||||||
|
|
||||||
const MyComponent = () => {
|
const MyComponent = () => {
|
||||||
return (
|
return (
|
||||||
<PCFControlWrapper
|
<PCFControlWrapper
|
||||||
@@ -95,7 +96,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **Embed Power BI reports**: Integrate interactive dashboards and reports
|
- **Embed Power BI reports**: Integrate interactive dashboards and reports
|
||||||
```typescript
|
```typescript
|
||||||
import { PowerBIEmbed } from 'powerbi-client-react';
|
import { PowerBIEmbed } from 'powerbi-client-react';
|
||||||
|
|
||||||
const DashboardComponent = () => {
|
const DashboardComponent = () => {
|
||||||
return (
|
return (
|
||||||
<PowerBIEmbed
|
<PowerBIEmbed
|
||||||
@@ -123,12 +124,12 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
const processDocument = async (file: File) => {
|
const processDocument = async (file: File) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
|
||||||
const result = await AIBuilderService.ProcessDocument({
|
const result = await AIBuilderService.ProcessDocument({
|
||||||
modelId: 'document-processing-model-id',
|
modelId: 'document-processing-model-id',
|
||||||
document: formData
|
document: formData
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.extractedFields;
|
return result.extractedFields;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -141,12 +142,12 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
```typescript
|
```typescript
|
||||||
import { DirectLine } from 'botframework-directlinejs';
|
import { DirectLine } from 'botframework-directlinejs';
|
||||||
import { WebChat } from 'botframework-webchat';
|
import { WebChat } from 'botframework-webchat';
|
||||||
|
|
||||||
const ChatbotComponent = () => {
|
const ChatbotComponent = () => {
|
||||||
const directLine = new DirectLine({
|
const directLine = new DirectLine({
|
||||||
token: chatbotToken
|
token: chatbotToken
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ height: '400px', width: '100%' }}>
|
<div style={{ height: '400px', width: '100%' }}>
|
||||||
<WebChat directLine={directLine} />
|
<WebChat directLine={directLine} />
|
||||||
@@ -159,23 +160,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- Use generated TypeScript services from PAC CLI for connector operations
|
- Use generated TypeScript services from PAC CLI for connector operations
|
||||||
- Implement proper authentication flows with Microsoft Entra ID
|
- Implement proper authentication flows with Microsoft Entra ID
|
||||||
- Handle connector consent dialogs and permission management
|
- Handle connector consent dialogs and permission management
|
||||||
- PowerProvider implementation pattern:
|
- PowerProvider implementation pattern (no SDK initialization required in v1.0):
|
||||||
```typescript
|
```typescript
|
||||||
import { initialize } from "@microsoft/power-apps/app";
|
import type { ReactNode } from "react";
|
||||||
import { useEffect, type ReactNode } from "react";
|
|
||||||
|
|
||||||
export default function PowerProvider({ children }: { children: ReactNode }) {
|
export default function PowerProvider({ children }: { children: ReactNode }) {
|
||||||
useEffect(() => {
|
|
||||||
const initApp = async () => {
|
|
||||||
try {
|
|
||||||
await initialize();
|
|
||||||
console.log('Power Platform SDK initialized successfully');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to initialize Power Platform SDK:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
initApp();
|
|
||||||
}, []);
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -221,7 +210,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
// Handle polymorphic customer lookup (Account or Contact)
|
// Handle polymorphic customer lookup (Account or Contact)
|
||||||
const customerType = record.customerType; // 'account' or 'contact'
|
const customerType = record.customerType; // 'account' or 'contact'
|
||||||
const customerId = record.customerId;
|
const customerId = record.customerId;
|
||||||
const customer = customerType === 'account'
|
const customer = customerType === 'account'
|
||||||
? await AccountService.get(customerId)
|
? await AccountService.get(customerId)
|
||||||
: await ContactService.get(customerId);
|
: await ContactService.get(customerId);
|
||||||
```
|
```
|
||||||
@@ -257,7 +246,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
const transaction = db.transaction(['data'], 'readwrite');
|
const transaction = db.transaction(['data'], 'readwrite');
|
||||||
transaction.objectStore('data').put({ id: key, data, timestamp: Date.now() });
|
transaction.objectStore('data').put({ id: key, data, timestamp: Date.now() });
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadData(key: string) {
|
async loadData(key: string) {
|
||||||
const db = await this.openDB();
|
const db = await this.openDB();
|
||||||
const transaction = db.transaction(['data'], 'readonly');
|
const transaction = db.transaction(['data'], 'readonly');
|
||||||
@@ -397,9 +386,9 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Button: React.FC<ButtonProps> = ({
|
export const Button: React.FC<ButtonProps> = ({
|
||||||
variant, size, disabled, onClick, children
|
variant, size, disabled, onClick, children
|
||||||
}) => {
|
}) => {
|
||||||
const classes = `btn btn-${variant} btn-${size} ${disabled ? 'btn-disabled' : ''}`;
|
const classes = `btn btn-${variant} btn-${size} ${disabled ? 'btn-disabled' : ''}`;
|
||||||
return <button className={classes} onClick={onClick} disabled={disabled}>{children}</button>;
|
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,
|
|||||||
theme: 'light',
|
theme: 'light',
|
||||||
toggleTheme: () => {}
|
toggleTheme: () => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ThemeProvider: React.FC<{children: ReactNode}> = ({ children }) => {
|
export const ThemeProvider: React.FC<{children: ReactNode}> = ({ children }) => {
|
||||||
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
const [theme, setTheme] = useState<'light' | 'dark'>('light');
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
setTheme(prev => prev === 'light' ? 'dark' : 'light');
|
setTheme(prev => prev === 'light' ? 'dark' : 'light');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeContext.Provider value={{ theme, toggleTheme }}>
|
<ThemeContext.Provider value={{ theme, toggleTheme }}>
|
||||||
<div className={`theme-${theme}`}>{children}</div>
|
<div className={`theme-${theme}`}>{children}</div>
|
||||||
@@ -441,7 +430,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
.card-container {
|
.card-container {
|
||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@container (min-width: 400px) {
|
@container (min-width: 400px) {
|
||||||
.card {
|
.card {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -456,7 +445,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **Framer Motion integration**: Smooth animations and transitions
|
- **Framer Motion integration**: Smooth animations and transitions
|
||||||
```typescript
|
```typescript
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
|
|
||||||
const AnimatedCard = () => {
|
const AnimatedCard = () => {
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
@@ -480,8 +469,8 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **ARIA implementation**: Proper semantic markup and ARIA attributes
|
- **ARIA implementation**: Proper semantic markup and ARIA attributes
|
||||||
```typescript
|
```typescript
|
||||||
// Example: Accessible modal component
|
// Example: Accessible modal component
|
||||||
const Modal: React.FC<{isOpen: boolean, onClose: () => void, children: ReactNode}> = ({
|
const Modal: React.FC<{isOpen: boolean, onClose: () => void, children: ReactNode}> = ({
|
||||||
isOpen, onClose, children
|
isOpen, onClose, children
|
||||||
}) => {
|
}) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
@@ -491,11 +480,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
}
|
}
|
||||||
return () => { document.body.style.overflow = 'unset'; };
|
return () => { document.body.style.overflow = 'unset'; };
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-labelledby="modal-title"
|
aria-labelledby="modal-title"
|
||||||
className={isOpen ? 'modal-open' : 'modal-hidden'}
|
className={isOpen ? 'modal-open' : 'modal-hidden'}
|
||||||
>
|
>
|
||||||
@@ -512,10 +501,10 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **React-intl integration**: Multi-language support
|
- **React-intl integration**: Multi-language support
|
||||||
```typescript
|
```typescript
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
const WelcomeMessage = ({ userName }: { userName: string }) => {
|
const WelcomeMessage = ({ userName }: { userName: string }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<h1>
|
<h1>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@@ -539,8 +528,8 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- Content Security Policy (CSP) not yet supported
|
- Content Security Policy (CSP) not yet supported
|
||||||
- Storage SAS IP restrictions not supported
|
- Storage SAS IP restrictions not supported
|
||||||
- No Power Platform Git integration
|
- No Power Platform Git integration
|
||||||
- No Dataverse solutions support
|
- Dataverse solutions supported, but solution packager and source code integration are limited
|
||||||
- No native Azure Application Insights integration
|
- Application Insights supported through SDK logger configuration (no built-in native integration)
|
||||||
|
|
||||||
### Workarounds
|
### Workarounds
|
||||||
|
|
||||||
@@ -567,7 +556,7 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **Package installation failures**: Clear npm cache with `npm cache clean --force` and reinstall
|
- **Package installation failures**: Clear npm cache with `npm cache clean --force` and reinstall
|
||||||
- **TypeScript compilation errors**: Check verbatimModuleSyntax setting and SDK compatibility
|
- **TypeScript compilation errors**: Check verbatimModuleSyntax setting and SDK compatibility
|
||||||
- **Connector permission errors**: Ensure proper consent flow and admin permissions
|
- **Connector permission errors**: Ensure proper consent flow and admin permissions
|
||||||
- **PowerProvider initialization errors**: Check console for SDK initialization failures
|
- **PowerProvider issues**: Ensure v1.0 apps do not wait on SDK initialization
|
||||||
- **Vite dev server issues**: Ensure host and port configuration match requirements
|
- **Vite dev server issues**: Ensure host and port configuration match requirements
|
||||||
|
|
||||||
### Deployment Issues
|
### Deployment Issues
|
||||||
@@ -577,11 +566,11 @@ Instructions for generating high-quality Power Apps Code Apps using TypeScript,
|
|||||||
- **Connector unavailable**: Verify connector setup in Power Platform and connection status
|
- **Connector unavailable**: Verify connector setup in Power Platform and connection status
|
||||||
- **Performance issues**: Optimize bundle size with `npm run build --report` and implement caching
|
- **Performance issues**: Optimize bundle size with `npm run build --report` and implement caching
|
||||||
- **Environment mismatch**: Confirm correct environment selection with `pac env list`
|
- **Environment mismatch**: Confirm correct environment selection with `pac env list`
|
||||||
- **App timeout errors**: Check PowerProvider.tsx implementation and network connectivity
|
- **App timeout errors**: Check build output and network connectivity
|
||||||
|
|
||||||
### Runtime Issues
|
### Runtime Issues
|
||||||
|
|
||||||
- **"App timed out" errors**: Verify npm run build was executed and PowerProvider is error-free
|
- **"App timed out" errors**: Verify npm run build was executed and the deployment output is valid
|
||||||
- **Connector authentication prompts**: Ensure proper consent flow implementation
|
- **Connector authentication prompts**: Ensure proper consent flow implementation
|
||||||
- **Data loading failures**: Check network requests and connector permissions
|
- **Data loading failures**: Check network requests and connector permissions
|
||||||
- **UI rendering issues**: Verify Fluent UI compatibility and responsive design implementation
|
- **UI rendering issues**: Verify Fluent UI compatibility and responsive design implementation
|
||||||
|
|||||||
Reference in New Issue
Block a user