@cyco77/pptb-fast-record-counter 0.1.6
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 +674 -0
- package/README.md +441 -0
- package/dist/assets/fast-record-counter_small-CcFp3TaT.png +0 -0
- package/dist/assets/index-CakrR5ie.js +9 -0
- package/dist/index.html +14 -0
- package/index.html +12 -0
- package/npm-shrinkwrap.json +3544 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
# Fast Record Counter
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="icon/fast-record-counter_small.png" alt="Fast Record Counter Logo" width="314" height="150">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A Power Platform Tool Box (PPTB) tool for counting records across all entities in your Dynamics 365/Dataverse environment. This tool provides a fast and efficient way to get record counts for all customizable entities with filtering capabilities.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## Screenshots
|
|
12
|
+
|
|
13
|
+
### Dark Theme
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
### Light Theme
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
### Core Capabilities
|
|
24
|
+
|
|
25
|
+
- 📊 **Entity List Display** - View all customizable entities in your Dataverse environment
|
|
26
|
+
- 🎯 **Solution Filtering** - Filter entities by solution with dropdown selector (shows only entities in selected solution)
|
|
27
|
+
- 🔢 **Fast Record Counting** - Count records for all filtered entities with a single click
|
|
28
|
+
- 🔍 **Entity Name Filtering** - Filter entities by display name or logical name in real-time
|
|
29
|
+
- 📋 **Sortable Data Grid** - Sort entities by display name, logical name, or record count
|
|
30
|
+
- 🎯 **Batch Counting** - Count records for all filtered entities sequentially
|
|
31
|
+
- 📢 **Visual Notifications** - Toast notifications for all operations
|
|
32
|
+
- 📝 **Progress Tracking** - Real-time loading indicators for each entity being counted
|
|
33
|
+
- 🎨 **Theme Support** - Automatic light/dark theme switching based on PPTB settings
|
|
34
|
+
- 📏 **Resizable Columns** - Adjust column widths to your preference
|
|
35
|
+
|
|
36
|
+
### Technical Stack
|
|
37
|
+
|
|
38
|
+
- ✅ React 18 with TypeScript
|
|
39
|
+
- ✅ Fluent UI React Components for consistent Microsoft design
|
|
40
|
+
- ✅ Vite for fast development and optimized builds
|
|
41
|
+
- ✅ Power Platform Toolbox API integration
|
|
42
|
+
- ✅ Dataverse API for querying plugin data
|
|
43
|
+
- ✅ Custom hooks for state management
|
|
44
|
+
- ✅ Centralized logging service
|
|
45
|
+
- ✅ Hot Module Replacement (HMR) for development
|
|
46
|
+
|
|
47
|
+
## Structure
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
pptb-fast-record-counter/
|
|
51
|
+
├── src/
|
|
52
|
+
│ ├── components/
|
|
53
|
+
│ │ ├── EntitiesDataGrid.tsx # Data grid for entities with record counts
|
|
54
|
+
│ │ ├── Filter.tsx # Entity name filtering and count button
|
|
55
|
+
│ │ └── Overview.tsx # Main container component
|
|
56
|
+
│ ├── hooks/
|
|
57
|
+
│ │ ├── useConnection.ts # Dataverse connection management
|
|
58
|
+
│ │ ├── useToolboxAPI.ts # PPTB API integration hook
|
|
59
|
+
│ │ └── useToolboxEvents.ts # PPTB event subscription
|
|
60
|
+
│ ├── services/
|
|
61
|
+
│ │ ├── dataverseService.ts # Dataverse API queries
|
|
62
|
+
│ │ └── loggerService.ts # Centralized logging singleton
|
|
63
|
+
│ ├── types/
|
|
64
|
+
│ │ ├── entity.ts # Entity type definitions
|
|
65
|
+
│ │ └── solution.ts # Solution type definitions
|
|
66
|
+
│ ├── App.tsx # Main application component
|
|
67
|
+
│ ├── main.tsx # Entry point
|
|
68
|
+
│ └── index.css # Global styling
|
|
69
|
+
├── dist/ # Build output
|
|
70
|
+
├── index.html
|
|
71
|
+
├── package.json
|
|
72
|
+
├── tsconfig.json
|
|
73
|
+
└── vite.config.ts
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
### Prerequisites
|
|
79
|
+
|
|
80
|
+
- Node.js >= 18.0.0
|
|
81
|
+
- npm or yarn
|
|
82
|
+
- Power Platform Toolbox installed
|
|
83
|
+
|
|
84
|
+
### Setup
|
|
85
|
+
|
|
86
|
+
1. Clone the repository:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git clone https://github.com/cyco77/pptb-fast-record-counter.git
|
|
90
|
+
cd pptb-fast-record-counter
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
2. Install dependencies:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm install
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Development
|
|
100
|
+
|
|
101
|
+
### Development Server
|
|
102
|
+
|
|
103
|
+
Start development server with HMR:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm run dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The tool will be available at `http://localhost:5173`
|
|
110
|
+
|
|
111
|
+
### Watch Mode
|
|
112
|
+
|
|
113
|
+
Build the tool in watch mode for continuous updates:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm run watch
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Production Build
|
|
120
|
+
|
|
121
|
+
Build the optimized production version:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm run build
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The output will be in the `dist/` directory.
|
|
128
|
+
|
|
129
|
+
### Preview Build
|
|
130
|
+
|
|
131
|
+
Preview the production build locally:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npm run preview
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
### In Power Platform Toolbox
|
|
140
|
+
|
|
141
|
+
1. Build the tool:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run build
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
2. Package the tool (creates npm-shrinkwrap.json):
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npm run finalize-package
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
3. Install in Power Platform Toolbox using the PPTB interface
|
|
154
|
+
|
|
155
|
+
4. Connect to a Dataverse environment
|
|
156
|
+
|
|
157
|
+
5. Launch the tool to view entities and count records
|
|
158
|
+
|
|
159
|
+
### User Interface
|
|
160
|
+
|
|
161
|
+
#### Filter Section
|
|
162
|
+
|
|
163
|
+
- **Solution Dropdown**: Select a specific solution to view only its entities, or "All" for all customizable entities
|
|
164
|
+
- **Filter Entities SearchBox**: Real-time search by entity display name or logical name
|
|
165
|
+
- **Count Records Button**: Execute record counting for all filtered entities
|
|
166
|
+
|
|
167
|
+
#### Data Grid
|
|
168
|
+
|
|
169
|
+
- **Display Name**: The user-friendly name of the entity
|
|
170
|
+
- **Logical Name**: The schema name of the entity
|
|
171
|
+
- **Record Count**: Number of records (populated after counting)
|
|
172
|
+
- Click column headers to sort
|
|
173
|
+
- Drag column borders to resize
|
|
174
|
+
- View tooltips on hover for full text content
|
|
175
|
+
|
|
176
|
+
#### Counting Process
|
|
177
|
+
|
|
178
|
+
1. Select a solution from the dropdown (optional - leave as "All" for all entities)
|
|
179
|
+
2. Filter entities using the search box (optional)
|
|
180
|
+
3. Click "Count Records" button
|
|
181
|
+
4. Watch as each entity shows "Loading..." status
|
|
182
|
+
5. Record counts appear in real-time as they complete
|
|
183
|
+
6. Receive a notification when all counts are finished
|
|
184
|
+
|
|
185
|
+
## API Usage
|
|
186
|
+
|
|
187
|
+
The tool demonstrates various Power Platform Toolbox and Dataverse API features:
|
|
188
|
+
|
|
189
|
+
### Connection Management
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
// Get current connection
|
|
193
|
+
const connection = await window.toolboxAPI.getConnection();
|
|
194
|
+
console.log(connection.connectionUrl);
|
|
195
|
+
|
|
196
|
+
// Listen for connection changes
|
|
197
|
+
window.toolboxAPI.onToolboxEvent((event, payload) => {
|
|
198
|
+
if (event === "connection:updated") {
|
|
199
|
+
// Refresh data with new connection
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Dataverse Queries
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// Query solutions
|
|
208
|
+
const solutions = await window.dataverseAPI.queryData(
|
|
209
|
+
`solutions?$select=solutionid,friendlyname,uniquename&$filter=isvisible eq true&$orderby=friendlyname asc`
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Query entity definitions
|
|
213
|
+
const entities = await window.dataverseAPI.queryData(
|
|
214
|
+
`EntityDefinitions?$select=LogicalName,DisplayName,EntitySetName&$filter=IsCustomizable/Value eq true`
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// Get entities in a solution via solution components
|
|
218
|
+
const components = await window.dataverseAPI.queryData(
|
|
219
|
+
`solutioncomponents?$select=objectid&$filter=_solutionid_value eq ${solutionId} and componenttype eq 1`
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
// Count records for an entity
|
|
223
|
+
const count = await window.dataverseAPI.queryData(
|
|
224
|
+
`${entitySetName}?$top=1&$count=true`
|
|
225
|
+
);
|
|
226
|
+
const recordCount = count["@odata.count"];
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Notifications
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
await window.toolboxAPI.utils.showNotification({
|
|
233
|
+
title: "Record Count Complete",
|
|
234
|
+
body: "Successfully counted records for 150 entities",
|
|
235
|
+
type: "success",
|
|
236
|
+
duration: 3000,
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Theme Management
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
// Get current theme
|
|
244
|
+
const theme = await window.toolboxAPI.utils.getCurrentTheme();
|
|
245
|
+
// Returns 'light' or 'dark'
|
|
246
|
+
|
|
247
|
+
// Listen for theme changes
|
|
248
|
+
window.toolboxAPI.onToolboxEvent((event) => {
|
|
249
|
+
if (event === "settings:updated") {
|
|
250
|
+
updateThemeBasedOnSettings();
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Event Subscription
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
// Subscribe to all PPTB events
|
|
259
|
+
window.toolboxAPI.onToolboxEvent((event, payload) => {
|
|
260
|
+
console.log("Event:", event);
|
|
261
|
+
console.log("Data:", payload.data);
|
|
262
|
+
|
|
263
|
+
// Handle specific events
|
|
264
|
+
switch (event) {
|
|
265
|
+
case "connection:created":
|
|
266
|
+
case "connection:updated":
|
|
267
|
+
refreshConnection();
|
|
268
|
+
break;
|
|
269
|
+
case "connection:deleted":
|
|
270
|
+
clearData();
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Architecture
|
|
277
|
+
|
|
278
|
+
### Custom Hooks
|
|
279
|
+
|
|
280
|
+
- **useConnection**: Manages Dataverse connection state and refresh logic
|
|
281
|
+
- **useToolboxEvents**: Subscribes to PPTB events and handles callbacks
|
|
282
|
+
- **useToolboxAPI**: Provides access to PPTB API utilities
|
|
283
|
+
|
|
284
|
+
### Services
|
|
285
|
+
|
|
286
|
+
- **loggerService**: Singleton service for centralized logging with callback pattern
|
|
287
|
+
|
|
288
|
+
- Methods: `info()`, `success()`, `warning()`, `error()`
|
|
289
|
+
- Eliminates prop drilling for logging across components
|
|
290
|
+
|
|
291
|
+
- **dataverseService**: Handles all Dataverse API queries
|
|
292
|
+
- Queries solutions and entity definitions with metadata
|
|
293
|
+
- Filters entities by solution using solution components
|
|
294
|
+
- Counts records for entities using EntitySetName
|
|
295
|
+
- Maps raw API responses to typed models
|
|
296
|
+
|
|
297
|
+
### Type Safety
|
|
298
|
+
|
|
299
|
+
Full TypeScript coverage with:
|
|
300
|
+
|
|
301
|
+
- Interface definitions for all data models
|
|
302
|
+
- Type-safe API responses
|
|
303
|
+
- Strongly typed component props
|
|
304
|
+
- PPTB API types from `@pptb/types` package
|
|
305
|
+
|
|
306
|
+
## Configuration
|
|
307
|
+
|
|
308
|
+
### Vite Build Configuration
|
|
309
|
+
|
|
310
|
+
The tool uses a custom Vite configuration for PPTB compatibility:
|
|
311
|
+
|
|
312
|
+
- **IIFE format**: Bundles as Immediately Invoked Function Expression for iframe compatibility
|
|
313
|
+
- **Single bundle**: Uses `inlineDynamicImports` to avoid module loading issues with file:// URLs
|
|
314
|
+
- **HTML transformation**: Custom plugin removes `type="module"` and moves scripts to end of body
|
|
315
|
+
- **Chunk size limit**: Set to 1000 kB to accommodate Fluent UI bundle size
|
|
316
|
+
|
|
317
|
+
## Data Models
|
|
318
|
+
|
|
319
|
+
### Entity
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
{
|
|
323
|
+
logicalname: string; // Schema name (e.g., "account")
|
|
324
|
+
displayname: string; // User-friendly name (e.g., "Account")
|
|
325
|
+
entitysetname: string; // Plural API name (e.g., "accounts")
|
|
326
|
+
recordCount?: number; // Count of records (populated after counting)
|
|
327
|
+
isLoading?: boolean; // Loading state during counting
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### Solution
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
{
|
|
335
|
+
solutionid: string; // Unique identifier of the solution
|
|
336
|
+
friendlyname: string; // Display name of the solution
|
|
337
|
+
uniquename: string; // Schema name of the solution
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Troubleshooting
|
|
342
|
+
|
|
343
|
+
### Build Issues
|
|
344
|
+
|
|
345
|
+
If you encounter chunk size warnings:
|
|
346
|
+
|
|
347
|
+
- The tool uses IIFE format which requires a single bundle
|
|
348
|
+
- Chunk size limit is configured in `vite.config.ts`
|
|
349
|
+
- This is expected for Fluent UI components
|
|
350
|
+
|
|
351
|
+
### Connection Issues
|
|
352
|
+
|
|
353
|
+
- Ensure you're connected to a Dataverse environment in PPTB
|
|
354
|
+
- Verify permissions to read entity metadata
|
|
355
|
+
- Check that you have access to the entities you're trying to count
|
|
356
|
+
|
|
357
|
+
### Counting Takes Too Long
|
|
358
|
+
|
|
359
|
+
- The tool counts entities sequentially to avoid API throttling
|
|
360
|
+
- Filter entities to count only specific ones
|
|
361
|
+
- Large environments with many entities will take longer
|
|
362
|
+
|
|
363
|
+
### Record Count Shows Zero
|
|
364
|
+
|
|
365
|
+
- Ensure the entity has records in your environment
|
|
366
|
+
- Verify you have permissions to read records from the entity
|
|
367
|
+
- Check the console logs for any API errors
|
|
368
|
+
|
|
369
|
+
### Theme Not Updating
|
|
370
|
+
|
|
371
|
+
- The tool automatically syncs with PPTB theme settings
|
|
372
|
+
- Check console for theme update events
|
|
373
|
+
- Verify PPTB version supports theme API
|
|
374
|
+
|
|
375
|
+
## Contributing
|
|
376
|
+
|
|
377
|
+
Contributions are welcome! Please:
|
|
378
|
+
|
|
379
|
+
1. Fork the repository
|
|
380
|
+
2. Create a feature branch
|
|
381
|
+
3. Make your changes with appropriate TypeScript types
|
|
382
|
+
4. Test the build process
|
|
383
|
+
5. Submit a pull request
|
|
384
|
+
|
|
385
|
+
### GitHub Actions
|
|
386
|
+
|
|
387
|
+
The project includes automated CI/CD workflows:
|
|
388
|
+
|
|
389
|
+
#### CI Workflow (`.github/workflows/ci.yml`)
|
|
390
|
+
|
|
391
|
+
Runs on every push and pull request to `main` and `develop` branches:
|
|
392
|
+
|
|
393
|
+
- **Build and Test**:
|
|
394
|
+
|
|
395
|
+
- Tests on Node.js 18.x and 20.x
|
|
396
|
+
- TypeScript type checking
|
|
397
|
+
- Build verification
|
|
398
|
+
- Uploads build artifacts
|
|
399
|
+
|
|
400
|
+
- **Lint Check**:
|
|
401
|
+
|
|
402
|
+
- Runs ESLint if configured
|
|
403
|
+
- Validates code quality
|
|
404
|
+
|
|
405
|
+
- **Security Audit**:
|
|
406
|
+
|
|
407
|
+
- Checks for npm package vulnerabilities
|
|
408
|
+
- Fails on critical vulnerabilities
|
|
409
|
+
- Warns on high-severity issues
|
|
410
|
+
|
|
411
|
+
- **Package Validation**:
|
|
412
|
+
- Validates package.json structure
|
|
413
|
+
- Creates npm-shrinkwrap.json
|
|
414
|
+
- Verifies all required fields
|
|
415
|
+
|
|
416
|
+
#### Release Workflow (`.github/workflows/release.yml`)
|
|
417
|
+
|
|
418
|
+
Triggered when pushing a version tag (e.g., `v1.0.0`):
|
|
419
|
+
|
|
420
|
+
- Builds the project
|
|
421
|
+
- Creates distribution packages (tar.gz and zip)
|
|
422
|
+
- Creates GitHub release with auto-generated notes
|
|
423
|
+
- Attaches build artifacts to release
|
|
424
|
+
|
|
425
|
+
**To create a release:**
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
# Update version in package.json
|
|
429
|
+
npm version patch # or minor, major
|
|
430
|
+
|
|
431
|
+
# Push with tags
|
|
432
|
+
git push origin main --tags
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
## License
|
|
436
|
+
|
|
437
|
+
MIT - See LICENSE file for details
|
|
438
|
+
|
|
439
|
+
## Author
|
|
440
|
+
|
|
441
|
+
Lars Hildebrandt
|
|
Binary file
|