pptb-standard-sample-tool 0.0.11 → 0.1.2
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 +185 -89
- package/dist/app.js +543 -0
- package/dist/index.html +72 -42
- package/dist/styles.css +270 -108
- package/package.json +37 -16
- package/dist/index.js +0 -205
- package/dist/index.js.map +0 -1
- package/tsconfig.json +0 -25
package/README.md
CHANGED
|
@@ -1,141 +1,237 @@
|
|
|
1
|
-
#
|
|
1
|
+
# HTML Sample Tool
|
|
2
2
|
|
|
3
|
-
A complete example tool
|
|
3
|
+
A complete example tool for Power Platform Tool Box built with HTML, CSS, and TypeScript.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- ✅
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
This sample demonstrates:
|
|
8
|
+
|
|
9
|
+
- ✅ **ToolBox API Integration**
|
|
10
|
+
- Connection management and status display
|
|
11
|
+
- Notifications (success, info, warning, error)
|
|
12
|
+
- Clipboard operations
|
|
13
|
+
- File save dialogs
|
|
14
|
+
- Theme detection
|
|
15
|
+
- Terminal creation and command execution
|
|
16
|
+
- Event subscription and handling
|
|
17
|
+
|
|
18
|
+
- ✅ **Dataverse API Usage**
|
|
19
|
+
- FetchXML queries
|
|
20
|
+
- CRUD operations (Create, Read, Update, Delete)
|
|
21
|
+
- Entity metadata retrieval
|
|
22
|
+
- Error handling
|
|
23
|
+
|
|
24
|
+
- ✅ **Best Practices**
|
|
25
|
+
- TypeScript with full type safety
|
|
26
|
+
- Event-driven architecture
|
|
27
|
+
- Proper error handling
|
|
28
|
+
- Clean, modern UI design
|
|
29
|
+
- Responsive layout
|
|
13
30
|
|
|
14
|
-
##
|
|
31
|
+
## Installation
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
example-tool/
|
|
18
|
-
├── src/
|
|
19
|
-
│ ├── index.html # Main UI
|
|
20
|
-
│ ├── index.ts # Tool logic (TypeScript)
|
|
21
|
-
│ └── styles.css # Styling
|
|
22
|
-
├── dist/ # Compiled output (after build)
|
|
23
|
-
│ ├── index.html
|
|
24
|
-
│ ├── index.js
|
|
25
|
-
│ ├── index.js.map
|
|
26
|
-
│ └── styles.css
|
|
27
|
-
├── package.json
|
|
28
|
-
├── tsconfig.json
|
|
29
|
-
└── README.md
|
|
30
|
-
```
|
|
33
|
+
### Prerequisites
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
- Node.js 18 or higher
|
|
36
|
+
- Power Platform Tool Box desktop application
|
|
33
37
|
|
|
34
|
-
Install
|
|
38
|
+
### Install Dependencies
|
|
35
39
|
|
|
36
40
|
```bash
|
|
37
41
|
npm install
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Build the tool:
|
|
44
|
+
### Build
|
|
43
45
|
|
|
44
46
|
```bash
|
|
45
47
|
npm run build
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
This compiles the TypeScript source in `src/` to JavaScript in `dist/`.
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
## Project Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
html-sample/
|
|
56
|
+
├── src/
|
|
57
|
+
│ └── app.ts # Main application logic (TypeScript)
|
|
58
|
+
├── index.html # Main HTML file (entry point)
|
|
59
|
+
├── styles.css # Stylesheet
|
|
60
|
+
├── package.json # Package configuration
|
|
61
|
+
├── tsconfig.json # TypeScript configuration
|
|
62
|
+
└── README.md # This file
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
## Usage
|
|
65
|
+
## Usage
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
```javascript
|
|
58
|
-
await window.toolboxAPI.installTool('@powerplatform/example-tool');
|
|
59
|
-
```
|
|
67
|
+
### Install in Power Platform Tool Box
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
1. Open Power Platform Tool Box
|
|
70
|
+
2. Go to Tools section
|
|
71
|
+
3. Click "Install Tool"
|
|
72
|
+
4. Enter the path to this directory or publish to npm and use the package name
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
const html = await window.toolboxAPI.getToolWebviewHtml(
|
|
69
|
-
'@powerplatform/example-tool',
|
|
70
|
-
'https://your-env.crm.dynamics.com',
|
|
71
|
-
'your-access-token'
|
|
72
|
-
);
|
|
73
|
-
```
|
|
74
|
+
### Features Overview
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
#### Connection Status
|
|
77
|
+
- Shows current Dataverse connection details
|
|
78
|
+
- Displays environment type (Production, Sandbox, Dev)
|
|
79
|
+
- Updates automatically when connection changes
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
#### ToolBox API Examples
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
**Notifications:**
|
|
84
|
+
- Test different notification types
|
|
85
|
+
- Success, info, warning, and error messages
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
**Utilities:**
|
|
88
|
+
- Copy data to clipboard
|
|
89
|
+
- Get current theme (light/dark)
|
|
90
|
+
- Save data to file with native dialog
|
|
82
91
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
**Terminal:**
|
|
93
|
+
- Create isolated terminal instances
|
|
94
|
+
- Execute shell commands
|
|
95
|
+
- View command output
|
|
96
|
+
- Close terminal when done
|
|
97
|
+
|
|
98
|
+
#### Dataverse API Examples
|
|
99
|
+
|
|
100
|
+
**Query Records:**
|
|
101
|
+
- FetchXML query to retrieve top 10 accounts
|
|
102
|
+
- Display results with formatting
|
|
103
|
+
|
|
104
|
+
**CRUD Operations:**
|
|
105
|
+
- Create new account records
|
|
106
|
+
- Update existing records
|
|
107
|
+
- Delete records
|
|
108
|
+
- Full error handling
|
|
109
|
+
|
|
110
|
+
**Metadata:**
|
|
111
|
+
- Retrieve entity metadata
|
|
112
|
+
- Display entity information and attributes
|
|
113
|
+
|
|
114
|
+
#### Event Log
|
|
115
|
+
- Real-time event logging
|
|
116
|
+
- Color-coded by severity
|
|
117
|
+
- Timestamp for each entry
|
|
118
|
+
- Clear log functionality
|
|
119
|
+
|
|
120
|
+
## Development
|
|
121
|
+
|
|
122
|
+
### Watch Mode
|
|
123
|
+
|
|
124
|
+
During development, you can use watch mode to automatically recompile on changes:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run watch
|
|
87
128
|
```
|
|
88
129
|
|
|
89
|
-
###
|
|
130
|
+
### Type Safety
|
|
131
|
+
|
|
132
|
+
This tool uses TypeScript with the `@pptb/types` package for full type safety:
|
|
90
133
|
|
|
91
134
|
```typescript
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
135
|
+
/// <reference types="@pptb/types" />
|
|
136
|
+
|
|
137
|
+
// Type-safe API access
|
|
138
|
+
const toolbox: typeof window.toolboxAPI = window.toolboxAPI;
|
|
139
|
+
const dataverse: typeof window.dataverseAPI = window.dataverseAPI;
|
|
97
140
|
```
|
|
98
141
|
|
|
99
|
-
###
|
|
142
|
+
### Customization
|
|
143
|
+
|
|
144
|
+
1. **Modify UI:** Edit `index.html` and `styles.css`
|
|
145
|
+
2. **Add Features:** Update `src/app.ts`
|
|
146
|
+
3. **Rebuild:** Run `npm run build`
|
|
147
|
+
4. **Reload Tool:** In Power Platform Tool Box, close and reopen the tool
|
|
148
|
+
|
|
149
|
+
## API Usage Examples
|
|
150
|
+
|
|
151
|
+
### ToolBox API
|
|
100
152
|
|
|
101
153
|
```typescript
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
154
|
+
// Show notification
|
|
155
|
+
await toolbox.utils.showNotification({
|
|
156
|
+
title: 'Success',
|
|
157
|
+
body: 'Operation completed',
|
|
158
|
+
type: 'success',
|
|
159
|
+
duration: 3000
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Get active connection
|
|
163
|
+
const connection = await toolbox.connections.getActiveConnection();
|
|
164
|
+
|
|
165
|
+
// Create terminal
|
|
166
|
+
const terminal = await toolbox.terminal.create({
|
|
167
|
+
name: 'My Terminal'
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Subscribe to events
|
|
171
|
+
toolbox.events.on((event, payload) => {
|
|
172
|
+
console.log('Event:', payload.event, payload.data);
|
|
105
173
|
});
|
|
106
174
|
```
|
|
107
175
|
|
|
108
|
-
###
|
|
176
|
+
### Dataverse API
|
|
109
177
|
|
|
110
178
|
```typescript
|
|
111
|
-
|
|
112
|
-
const
|
|
179
|
+
// Query with FetchXML
|
|
180
|
+
const result = await dataverse.fetchXmlQuery(`
|
|
181
|
+
<fetch top="10">
|
|
182
|
+
<entity name="account">
|
|
183
|
+
<attribute name="name" />
|
|
184
|
+
</entity>
|
|
185
|
+
</fetch>
|
|
186
|
+
`);
|
|
187
|
+
|
|
188
|
+
// Create record
|
|
189
|
+
const account = await dataverse.create('account', {
|
|
190
|
+
name: 'Contoso Ltd',
|
|
191
|
+
emailaddress1: 'info@contoso.com'
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Update record
|
|
195
|
+
await dataverse.update('account', accountId, {
|
|
196
|
+
telephone1: '555-0100'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Delete record
|
|
200
|
+
await dataverse.delete('account', accountId);
|
|
201
|
+
|
|
202
|
+
// Get metadata
|
|
203
|
+
const metadata = await dataverse.getEntityMetadata('account');
|
|
113
204
|
```
|
|
114
205
|
|
|
115
|
-
##
|
|
206
|
+
## Troubleshooting
|
|
207
|
+
|
|
208
|
+
### Build Errors
|
|
209
|
+
|
|
210
|
+
If you encounter TypeScript errors:
|
|
211
|
+
1. Ensure `@pptb/types` is installed: `npm install`
|
|
212
|
+
2. Check TypeScript version: `tsc --version` (should be 5.x)
|
|
213
|
+
3. Clean and rebuild: `rm -rf dist && npm run build`
|
|
214
|
+
|
|
215
|
+
### API Not Available
|
|
116
216
|
|
|
117
|
-
|
|
217
|
+
If `toolboxAPI` or `dataverseAPI` is undefined:
|
|
218
|
+
- The tool must be loaded within Power Platform Tool Box
|
|
219
|
+
- These APIs are injected by the toolboxAPIBridge
|
|
220
|
+
- They are not available in a standalone browser
|
|
118
221
|
|
|
119
|
-
|
|
120
|
-
- Event type definitions
|
|
121
|
-
- Connection and Tool interfaces
|
|
122
|
-
- Notification options
|
|
123
|
-
- And more...
|
|
222
|
+
### Connection Issues
|
|
124
223
|
|
|
125
|
-
|
|
224
|
+
If connection is null:
|
|
225
|
+
- Open Power Platform Tool Box
|
|
226
|
+
- Create a connection to a Dataverse environment
|
|
227
|
+
- The tool will automatically detect the connection
|
|
126
228
|
|
|
127
|
-
|
|
229
|
+
## Resources
|
|
128
230
|
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
- **Strict Mode**: Enabled with additional safety checks:
|
|
133
|
-
- `noUnusedLocals`: Warns about unused local variables
|
|
134
|
-
- `noUnusedParameters`: Warns about unused function parameters
|
|
135
|
-
- `noFallthroughCasesInSwitch`: Ensures all switch cases handle control flow
|
|
136
|
-
- `useDefineForClassFields`: Modern class field semantics
|
|
137
|
-
- `moduleDetection`: Force module detection
|
|
231
|
+
- [Tool Development Guide](../../docs/TOOL_DEVELOPMENT.md)
|
|
232
|
+
- [API Reference](../../packages/README.md)
|
|
233
|
+
- [Power Platform Tool Box Repository](https://github.com/PowerPlatform-ToolBox/desktop-app)
|
|
138
234
|
|
|
139
235
|
## License
|
|
140
236
|
|
|
141
|
-
|
|
237
|
+
GPL-3.0 - See LICENSE file in repository root
|