@metricinsights/pp-dev 1.5.0-beta.3 → 1.5.0-beta.31

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 (72) hide show
  1. package/README.md +200 -145
  2. package/dist/cjs/auth.provider-fI0tFsf5.js +2 -0
  3. package/dist/cjs/auth.provider-fI0tFsf5.js.map +1 -0
  4. package/dist/cjs/cli.js +1 -1
  5. package/dist/cjs/cli.js.map +1 -1
  6. package/dist/cjs/index-Ty1d2YCg.js +2 -0
  7. package/dist/cjs/index-Ty1d2YCg.js.map +1 -0
  8. package/dist/cjs/index.js +1 -1
  9. package/dist/cjs/migrate-Gi9k9cLw.js +2 -0
  10. package/dist/cjs/migrate-Gi9k9cLw.js.map +1 -0
  11. package/dist/cjs/package.json +2 -135
  12. package/dist/cjs/plugin.js +1 -1
  13. package/dist/cjs/plugin.js.map +1 -1
  14. package/dist/cjs/request-capture.middleware-6DhFLyIz.js +2 -0
  15. package/dist/cjs/request-capture.middleware-6DhFLyIz.js.map +1 -0
  16. package/dist/cjs/version-manifest-CVBuIKBS.js +2 -0
  17. package/dist/cjs/version-manifest-CVBuIKBS.js.map +1 -0
  18. package/dist/cjs/version-plugin-DBdqn2Rn.js +2 -0
  19. package/dist/cjs/version-plugin-DBdqn2Rn.js.map +1 -0
  20. package/dist/client/client.js +278 -126
  21. package/dist/client/client.js.map +1 -1
  22. package/dist/client/request-inspector.css +3 -0
  23. package/dist/client/request-inspector.css.map +1 -0
  24. package/dist/client/request-inspector.html +87 -0
  25. package/dist/client/request-inspector.js +549 -0
  26. package/dist/client/request-inspector.js.map +1 -0
  27. package/dist/client/variables-editor.css +3 -0
  28. package/dist/client/variables-editor.css.map +1 -0
  29. package/dist/client/variables-editor.html +44 -0
  30. package/dist/client/variables-editor.js +3474 -0
  31. package/dist/client/variables-editor.js.map +1 -0
  32. package/dist/esm/auth.provider-DDUsu1H1.js +2 -0
  33. package/dist/esm/auth.provider-DDUsu1H1.js.map +1 -0
  34. package/dist/esm/cli.js +1 -1
  35. package/dist/esm/cli.js.map +1 -1
  36. package/dist/esm/index-tD-QICGk.js +2 -0
  37. package/dist/esm/index-tD-QICGk.js.map +1 -0
  38. package/dist/esm/index.js +1 -1
  39. package/dist/esm/migrate-CCBRuVfj.js +2 -0
  40. package/dist/esm/{migrate-B2gJ62fm.js.map → migrate-CCBRuVfj.js.map} +1 -1
  41. package/dist/esm/package.json +2 -135
  42. package/dist/esm/plugin.js +1 -1
  43. package/dist/esm/plugin.js.map +1 -1
  44. package/dist/esm/request-capture.middleware-VElwjU1W.js +2 -0
  45. package/dist/esm/request-capture.middleware-VElwjU1W.js.map +1 -0
  46. package/dist/esm/version-manifest-CyzmnFOe.js +2 -0
  47. package/dist/esm/version-manifest-CyzmnFOe.js.map +1 -0
  48. package/dist/esm/version-plugin-6rxIgQ-I.js +2 -0
  49. package/dist/esm/version-plugin-6rxIgQ-I.js.map +1 -0
  50. package/dist/types/helpers.d.ts +29 -0
  51. package/dist/types/index.d.ts +15 -156
  52. package/dist/types/plugin.d.ts +8 -0
  53. package/dist/types/pp-dev-config-D889A-PO.d.ts +189 -0
  54. package/docs/features.md +2 -1
  55. package/package.json +26 -35
  56. package/dist/CHANGELOG.md +0 -442
  57. package/dist/README.md +0 -724
  58. package/dist/cjs/index-CCUrjlJE.js +0 -2
  59. package/dist/cjs/index-CCUrjlJE.js.map +0 -1
  60. package/dist/cjs/migrate-BYno__sx.js +0 -2
  61. package/dist/cjs/migrate-BYno__sx.js.map +0 -1
  62. package/dist/cjs/plugin-D_RXI7ru.js +0 -2
  63. package/dist/cjs/plugin-D_RXI7ru.js.map +0 -1
  64. package/dist/cjs/version-plugin-Bf4jLh17.js +0 -2
  65. package/dist/cjs/version-plugin-Bf4jLh17.js.map +0 -1
  66. package/dist/esm/index-BazQY12s.js +0 -2
  67. package/dist/esm/index-BazQY12s.js.map +0 -1
  68. package/dist/esm/migrate-B2gJ62fm.js +0 -2
  69. package/dist/esm/plugin-NIWxLreC.js +0 -2
  70. package/dist/esm/plugin-NIWxLreC.js.map +0 -1
  71. package/dist/esm/version-plugin-DwuZCHob.js +0 -2
  72. package/dist/esm/version-plugin-DwuZCHob.js.map +0 -1
package/dist/README.md DELETED
@@ -1,724 +0,0 @@
1
- # pp-dev
2
-
3
- <p align="center">
4
- <a href="https://www.npmjs.com/package/@metricinsights/pp-dev"><img alt="npm" src="https://img.shields.io/npm/v/%40metricinsights%2Fpp-dev?logo=npm&label=npm%20package"></a>
5
- <a href="https://github.com/mi-examples/pp-dev/releases"><img alt="Release" src="https://img.shields.io/github/v/release/mi-examples/pp-dev?label=release"></a>
6
- <a href="https://github.com/mi-examples/pp-dev/actions/workflows/ci.yml"><img alt="GitHub Workflow CI Status (with event)" src="https://github.com/mi-examples/pp-dev/actions/workflows/ci.yml/badge.svg?branch=develop"></a>
7
- </p>
8
-
9
- The PP Dev Helper is a development framework and build tool for Metric Insights' Portal Pages, designed to make the
10
- lives of PP developers easier:
11
-
12
- - Build and test Portal Pages locally
13
- - Proxy API requests to a Metric Insights server
14
- - Hot module replacement for faster development
15
- - Image optimization and asset management
16
- - Template variable transformation
17
- - Code synchronization with Metric Insights instances
18
-
19
- pp-dev is based on [Vite](https://vitejs.dev/).
20
-
21
- 📸 **[Feature tour](./docs/features.md)** — screenshots of the dev panel, Request Inspector, and Variables Editor.
22
-
23
- ## Installation
24
-
25
- ```bash
26
- npm install @metricinsights/pp-dev
27
- ```
28
-
29
- ### Peer Dependencies
30
-
31
- This package requires Next.js as a peer dependency for certain functionality:
32
-
33
- ```bash
34
- npm install next@^15
35
- ```
36
-
37
- **Note**: pp-dev requires Next.js version 15 or higher (but less than 17) to be installed in your project. This is a peer dependency, meaning it won't be automatically installed with pp-dev.
38
-
39
- ## Package Structure
40
-
41
- The pp-dev package provides multiple entry points for different use cases:
42
-
43
- ```javascript
44
- // Main package (includes everything)
45
- import ppDev from '@metricinsights/pp-dev';
46
-
47
- // Plugin only (for Vite integration)
48
- import { vitePPDev } from '@metricinsights/pp-dev/plugin';
49
-
50
- // Helpers only (defineConfig and utility functions)
51
- import { defineConfig } from '@metricinsights/pp-dev/helpers';
52
-
53
- // Client assets (for development UI)
54
- import '@metricinsights/pp-dev/client/css/client.css';
55
- ```
56
-
57
- ## Configuration
58
-
59
- ### Configuration File
60
-
61
- Create a configuration file named `pp-dev.config` with one of these extensions:
62
-
63
- - `.ts` (recommended)
64
- - `.js` or `.cjs` (for CommonJS)
65
- - `.json`
66
-
67
- Alternatively, you can define configuration in your `package.json` using the `pp-dev` key.
68
-
69
- ### Configuration Examples
70
-
71
- #### TypeScript (recommended)
72
-
73
- ```typescript
74
- // pp-dev.config.ts
75
- import { defineConfig } from '@metricinsights/pp-dev';
76
-
77
- export default defineConfig({
78
- mi: {
79
- url: 'https://mi.company.com',
80
- token: process.env.MI_ACCESS_TOKEN,
81
- mode: 'standalone',
82
- apiVersion: 7,
83
- },
84
- app: {
85
- id: 123,
86
- type: 'template',
87
- },
88
- });
89
- ```
90
-
91
- #### JavaScript (CommonJS)
92
-
93
- ```javascript
94
- // pp-dev.config.js
95
- const { defineConfig } = require('@metricinsights/pp-dev');
96
-
97
- module.exports = defineConfig({
98
- mi: {
99
- url: 'https://mi.company.com',
100
- mode: 'standalone',
101
- apiVersion: 7,
102
- },
103
- app: {
104
- id: 123,
105
- type: 'template',
106
- },
107
- });
108
- ```
109
-
110
- #### JSON
111
-
112
- ```json
113
- {
114
- "mi": {
115
- "url": "https://mi.company.com",
116
- "mode": "standalone",
117
- "apiVersion": 7
118
- },
119
- "app": {
120
- "id": 123,
121
- "type": "template"
122
- }
123
- }
124
- ```
125
-
126
- #### package.json
127
-
128
- ```json
129
- {
130
- "name": "my-portal-page",
131
- "pp-dev": {
132
- "mi": {
133
- "url": "https://mi.company.com",
134
- "mode": "standalone"
135
- },
136
- "app": {
137
- "id": 123
138
- }
139
- }
140
- }
141
- ```
142
-
143
- ## Configuration Options
144
-
145
- ### `mi` — Metric Insights connection
146
-
147
- | Field | Type | Default | Description |
148
- |--------------|-----------------------------------|----------------|-----------------------------------------------------------|
149
- | `url` | `string` | — | URL of the Metric Insights instance |
150
- | `token` | `string` | `MI_ACCESS_TOKEN` env | Personal access token for authentication |
151
- | `mode` | `'standalone' \| 'embedding'` | `'standalone'` | Standalone hides the MI navigation; embedding keeps it |
152
- | `include` | `'top-bar' \| 'shared-components'`| — | Bundle MI top-bar assets into the build (requires `standalone`) |
153
- | `apiVersion` | `6 \| 7` | `7` | MI API version to target |
154
-
155
- ### `app` — Portal Page identity
156
-
157
- | Field | Type | Default | Description |
158
- |--------|----------------------------|--------------------------|-------------------------------------------------------------|
159
- | `id` | `number` | — | Portal Page ID used to fetch template variables |
160
- | `type` | `'template' \| 'page'` | `'template'` | `template` syncs back to MI; `page` is standalone-only |
161
- | `name` | `string` | `package.json#name` | Template name on the MI instance (usually auto-resolved) |
162
-
163
- ### `proxy` — Request proxying
164
-
165
- | Field | Type | Default | Description |
166
- |---------------------|-----------|----------|------------------------------------------------------|
167
- | `cache` | `boolean` | `true` | Enable caching of proxied requests |
168
- | `cacheTtl` | `number` | `600000` | Cache TTL in milliseconds (10 minutes) |
169
- | `tls.allowSelfSigned` | `boolean` | `false` | Allow self-signed SSL certificates on the MI server |
170
-
171
- ### `build` — Build output
172
-
173
- | Field | Type | Default | Description |
174
- |---------------------|-------------------------------------------------------------|----------|--------------------------------------------------------------------------------------|
175
- | `outDir` | `string` | `'dist'` | Output directory |
176
- | `zip` | `boolean \| { fileName?: string; outDir?: string; inDir?: string }` | `true` | Zip build output. Object form customizes filename and directories. |
177
- | `versionFile` | `boolean \| { enabled?: boolean; fileNameTemplate?: string }` | `true` | Write a VERSION file into the build |
178
- | `imageOptimisations`| `boolean \| Record<string, unknown>` | `true` | Image optimization. See [vite-plugin-image-optimizer](https://www.npmjs.com/package/vite-plugin-image-optimizer#plugin-options) for object options |
179
-
180
- ### `inspector` — Request Inspector
181
-
182
- | Field | Type | Default | Description |
183
- |----------------|-----------|-------------|----------------------------------------------------------------|
184
- | `enabled` | `boolean` | `true` | Enable the request inspector |
185
- | `maxMemory` | `number` | `104857600` | Max total body memory (bytes) before oldest entries are evicted (default 100 MB) |
186
- | `captureLimit` | `number` | `10485760` | Max body size captured per request/response (bytes, default 10 MB). Larger bodies are stored truncated. |
187
-
188
- ### `sync` — Template sync
189
-
190
- | Field | Type | Default | Description |
191
- |--------------|----------|-------------|-----------------------------------------|
192
- | `backupsDir` | `string` | `'backups'` | Directory for backups from the MI server |
193
-
194
- ### `devPanel` — Dev panel appearance
195
-
196
- | Field | Type | Default | Description |
197
- |------------|-----------------------------------------------------------------|------------------|-----------------------------------------------------------------------------|
198
- | `position` | `'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `'bottom-right'` | Screen corner the dev panel is anchored to |
199
- | `hidden` | `boolean` | `false` | Fully hide the panel. Restore in the browser with `?pp-dev-panel=show` |
200
- | `autoHide` | `boolean` | `false` | Panel slides behind the screen edge leaving a thin strip; hover reveals it |
201
-
202
- These values are **defaults**: the panel itself has a settings popover (gear icon) with a corner
203
- picker, an auto-hide toggle and a hide button, and the panel can be dragged by its grip handle and
204
- snapped to any corner. Runtime choices are persisted in the browser's `localStorage`
205
- (`pp-dev-info-position`, `pp-dev-info-auto-hide`, `pp-dev-info-hidden`) and take precedence over
206
- the config until "Reset to config defaults" is clicked in the popover. The URL params
207
- `?pp-dev-panel=show` / `?pp-dev-panel=hide` set a persistent override too — handy for restoring a
208
- hidden panel or taking clean screenshots. Note that `localStorage` is origin-scoped, so overrides
209
- apply to every pp-dev app served on the same host and port. See the [Dev Panel](#dev-panel)
210
- section for the full feature description.
211
-
212
- ### `users` — Working as other users
213
-
214
- | Field | Type | Default | Description |
215
- |-----------|-----------|---------|--------------------------------------------------------------------------------------------------------------|
216
- | `persist` | `boolean` | `false` | Keep the users added with an API token between dev server runs, in `~/.pp-dev/users/` (readable by you only) |
217
-
218
- See [Working as other users](#working-as-other-users).
219
-
220
- ### Validation
221
-
222
- pp-dev validates your config at startup and reports problems clearly:
223
-
224
- | Condition | Behaviour |
225
- |---|---|
226
- | `mi.include` set + `mi.mode !== 'standalone'` | error |
227
- | `mi.url` missing + `mi.mode === 'embedding'` or `app.type === 'template'` | error |
228
- | `mi.url` missing + `mi.mode === 'standalone'` + `app.type === 'page'` | warning |
229
- | `app.type === 'template'` without `app.id` | error |
230
- | `app.type === 'page'` + `mi.mode === 'standalone'` without `app.id` | error |
231
- | `app.name` missing and no `package.json#name` | error |
232
- | `devPanel.position` not one of the four corners | error |
233
-
234
- ### Environment Variables
235
-
236
- | Variable | Description |
237
- |----------------------------------|-------------------------------------------------------------------------------------|
238
- | `MI_ACCESS_TOKEN` | Default value for `mi.token` when not set in config |
239
- | `PP_DEV_DIST_ZIP` | `true`/`false` — override `build.zip` for `pp-dev build` / `pp-dev next-build` |
240
- | `PP_DEV_DIST_ZIP_DIR` | Override the ZIP output directory (`build.zip.outDir`) |
241
- | `PP_DEV_DIST_ZIP_FILENAME` | Override the ZIP file name (`build.zip.fileName`) |
242
- | `PP_DEV_VERSION_MANIFEST` | `true`/`false` — override `build.versionFile` (VERSION/BUILD-MANIFEST generation) |
243
- | `PP_DEV_VERSION_FILE_TEMPLATE` | Override the VERSION file name template |
244
-
245
- The `PP_DEV_DIST_ZIP*`/`PP_DEV_VERSION_*` variables are read by `pp-dev build` and
246
- `pp-dev next-build`; an equivalent CLI flag always takes precedence over its env var. See
247
- [Build](#build) / [Next.js Build](#nextjs-build).
248
-
249
- **Local development and network exposure**: pp-dev is a **development** tool. It assumes a trusted machine. Personal access tokens and session helpers are still sensitive: they can authenticate to your Metric Insights backend as you.
250
-
251
- - Prefer binding the dev server to **`localhost`** when you do not need access from other devices. If you use **`--host`** (or equivalent) so the app listens on **all interfaces** or your LAN, other machines on the same network can reach the dev server and its dev-only routes. Treat that like exposing credentials: use only on networks you trust, or restrict access with your OS firewall.
252
- - Do not commit real tokens; keep them in `.env` (gitignored) or your secret store.
253
-
254
- ## Migrating from 0.x
255
-
256
- Run the built-in codemod to upgrade your config automatically:
257
-
258
- ```bash
259
- npx @metricinsights/pp-dev migrate
260
- ```
261
-
262
- Options:
263
-
264
- | Option | Description |
265
- |---|---|
266
- | `[config]` | Path to config file (auto-detected if omitted) |
267
- | `--dry-run` | Preview the migrated output without writing |
268
- | `--format ts\|js\|json` | Override output format |
269
- | `--output <file>` | Write to a specific file instead of overwriting |
270
- | `--no-backup` | Skip creating a `.bak` backup of the original |
271
-
272
- The command detects flat 0.x configs and legacy `pp-watch.config.*` files, converts them to the new grouped format, and writes a `.bak` backup before overwriting.
273
-
274
- **Field mapping** (0.x → 1.0):
275
-
276
- | 0.x | 1.0 |
277
- |---|---|
278
- | `backendBaseURL` | `mi.url` |
279
- | `personalAccessToken` | `mi.token` |
280
- | `miHudLess: true` | `mi.mode: 'standalone'` |
281
- | `miHudLess: false` | `mi.mode: 'embedding'` |
282
- | `integrateMiTopBar: true` | `mi.mode: 'standalone'`, `mi.include: 'top-bar'` |
283
- | `integrateMiTopBar: { addSharedComponentsScripts: true }` | `mi.include: 'shared-components'` |
284
- | `v7Features: true` | `mi.apiVersion: 7` |
285
- | `v7Features: false` | `mi.apiVersion: 6` |
286
- | `appId` / `portalPageId` | `app.id` |
287
- | `templateName` | `app.name` (usually omit — auto-resolved from `package.json#name`) |
288
- | `templateLess: true` | `app.type: 'page'` |
289
- | `templateLess: false` | `app.type: 'template'` |
290
- | `enableProxyCache` | `proxy.cache` |
291
- | `proxyCacheTTL` | `proxy.cacheTtl` |
292
- | `disableSSLValidation: true` | `proxy.tls.allowSelfSigned: true` |
293
- | `distZip` | `build.zip` |
294
- | `versionPlugin` | `build.versionFile` |
295
- | `imageOptimizer` | `build.imageOptimisations` |
296
- | `outDir` | `build.outDir` |
297
- | `syncBackupsDir` | `sync.backupsDir` |
298
-
299
- ## CLI Commands
300
-
301
- ### Global Options
302
-
303
- | Option | Description |
304
- | ------------------------ | -------------------------------------------------------------------------------- |
305
- | `-c, --config <file>` | Path to configuration file (default: `pp-dev.config.js`) |
306
- | `--base <path>` | Public base path (default: `/`) |
307
- | `-l, --logLevel <level>` | Log level: `trace`, `debug`, `info`, `warn`, `error`, `silent` (default: `info`) |
308
- | `--clearScreen` | Clear screen before logging |
309
- | `--mode <mode>` | Environment mode: `development`, `production`, `test` (default: `development`) |
310
-
311
- ### Development Server
312
-
313
- ```bash
314
- pp-dev [root] [options]
315
- # Aliases: pp-dev dev, pp-dev serve
316
- ```
317
-
318
- | Option | Default | Description |
319
- | --------------- | ----------- | --------------------------------- |
320
- | `[root]` | `.` | Root directory of the application |
321
- | `--host <host>` | `localhost` | Server hostname |
322
- | `--port <port>` | `3000` | Server port |
323
- | `--open [path]` | - | Open browser on server start |
324
- | `--strictPort` | - | Exit if port is already in use |
325
-
326
- **Development Shortcuts**:
327
-
328
- - `l` - Proxy re-login (refresh authentication)
329
- - `r` - Restart dev server
330
- - `u` - Show server URLs
331
- - `q` - Quit dev server
332
-
333
- ### Next.js Development
334
-
335
- ```bash
336
- pp-dev next [options]
337
- # Aliases: pp-dev next-server, pp-dev next-dev
338
- ```
339
-
340
- | Option | Default | Description |
341
- | --------------- | ----------- | --------------------------------- |
342
- | `[root]` | `.` | Root directory of the application |
343
- | `--port <port>` | `3000` | Server port |
344
- | `--host <host>` | `localhost` | Server hostname |
345
-
346
- ### Build
347
-
348
- ```bash
349
- pp-dev build [options]
350
- ```
351
-
352
- | Option | Default | Description |
353
- | ------------------------------- | --------- | ------------------------------------------------------ |
354
- | `[root]` | `.` | Root directory of the application |
355
- | `--target <target>` | `modules` | Transpile target |
356
- | `--outDir <dir>` | `dist` | Output directory |
357
- | `--assetsDir <dir>` | `assets` | Assets directory under outDir |
358
- | `--changelog [file]` | `true` | Create changelog file |
359
- | `--distZip` / `--no-distZip` | see below | Override `build.zip` — pack (or skip) the output ZIP |
360
- | `--distZipDir <dir>` | see below | Override the ZIP output directory (`build.zip.outDir`) |
361
- | `--distZipFilename <file>` | see below | Override the ZIP file name (`build.zip.fileName`) |
362
- | `--versionManifest` / `--no-versionManifest` | see below | Override `build.versionFile` — emit (or skip) VERSION/BUILD-MANIFEST |
363
- | `--versionFileTemplate <tpl>` | see below | Override the VERSION file name template |
364
-
365
- The `--distZip*`/`--versionManifest*` flags (and their `PP_DEV_*` env var equivalents, see
366
- [Environment Variables](#environment-variables)) let CI or ad-hoc builds override the `build.zip`
367
- and `build.versionFile` config without editing `pp-dev.config`. Precedence: CLI flag > env var >
368
- config file > built-in default. The same flags are available on `pp-dev next-build` (below).
369
-
370
- ### Next.js Build
371
-
372
- ```bash
373
- pp-dev next-build [options]
374
- ```
375
-
376
- Plain `next build` only produces the Next.js static export — no VERSION file, BUILD-MANIFEST, or
377
- ZIP archive. `pp-dev next-build` runs `next build` and then applies the same post-build steps as
378
- `pp-dev build`, so Next.js and Vite templates produce build artifacts in the same format:
379
-
380
- 1. Runs `next build` (requires `output: 'export'` in `next.config`)
381
- 2. Writes `VERSION-*.json` + `BUILD-MANIFEST.json` into the export directory (`build.versionFile`)
382
- 3. Zips the export directory into `dist-zip/<name>.zip` (`build.zip`)
383
-
384
- If a project using `withPPDev()` still runs plain `next build` (e.g. directly, or via a `build`
385
- script nobody updated), `withPPDev()` prints a console warning during the production build phase
386
- suggesting `pp-dev next-build` instead. The warning is suppressed automatically when the build was
387
- started by `pp-dev next-build` itself.
388
-
389
- Use it in place of `next build` in your `package.json`:
390
-
391
- ```json
392
- {
393
- "scripts": {
394
- "build": "pp-dev next-build --changelog"
395
- }
396
- }
397
- ```
398
-
399
- | Option | Default | Description |
400
- | ------------------------------- | --------- | ------------------------------------------------------ |
401
- | `[root]` | `.` | Root directory of the application |
402
- | `--changelog [file]` | `true` | Create changelog file |
403
- | `--distZip` / `--no-distZip` | see below | Override `build.zip` — pack (or skip) the output ZIP |
404
- | `--distZipDir <dir>` | see below | Override the ZIP output directory (`build.zip.outDir`) |
405
- | `--distZipFilename <file>` | see below | Override the ZIP file name (`build.zip.fileName`) |
406
- | `--versionManifest` / `--no-versionManifest` | see below | Override `build.versionFile` — emit (or skip) VERSION/BUILD-MANIFEST |
407
- | `--versionFileTemplate <tpl>` | see below | Override the VERSION file name template |
408
-
409
- ### Migration
410
-
411
- ```bash
412
- pp-dev migrate [config] [options]
413
- ```
414
-
415
- | Option | Description |
416
- |---|---|
417
- | `[config]` | Config file to migrate (auto-detected if omitted) |
418
- | `--dry-run` | Preview output without writing |
419
- | `--format ts\|js\|json` | Output format |
420
- | `--output <file>` | Write to a specific path |
421
- | `--no-backup` | Skip `.bak` backup |
422
-
423
- ### Changelog Generation
424
-
425
- ```bash
426
- pp-dev changelog [oldAssetPath] [newAssetPath] [options]
427
- ```
428
-
429
- | Option | Default | Description |
430
- | ------------------------ | ---------------- | -------------------------- |
431
- | `[oldAssetPath]` | - | Path to previous assets |
432
- | `[newAssetPath]` | - | Path to current assets |
433
- | `--oldAssetsPath <path>` | - | Path to previous assets |
434
- | `--newAssetsPath <path>` | - | Path to current assets |
435
- | `--destination <path>` | `.` | Changelog output directory |
436
- | `--filename <name>` | `CHANGELOG.html` | Changelog filename |
437
-
438
- ### Icon Font Generation
439
-
440
- ```bash
441
- pp-dev generate-icon-font [source] [destination] [options]
442
- ```
443
-
444
- | Option | Default | Description |
445
- | ---------------------- | ----------- | ------------------------------- |
446
- | `[source]` | - | Source directory with SVG icons |
447
- | `[destination]` | - | Output directory |
448
- | `--source <path>` | - | Source directory with SVG icons |
449
- | `--destination <path>` | - | Output directory |
450
- | `--fontName <name>` | `icon-font` | Font name |
451
-
452
- ## Next.js Integration
453
-
454
- 1. Add a `pp-dev.config.ts` to your project root
455
- 2. Update `package.json` scripts:
456
- ```json
457
- {
458
- "scripts": {
459
- "dev": "pp-dev next",
460
- "build": "pp-dev next-build"
461
- }
462
- }
463
- ```
464
- `pp-dev next-build` replaces a plain `next build` so the Next.js template produces the same
465
- VERSION/BUILD-MANIFEST/ZIP artifacts as `pp-dev build` — see [Next.js Build](#nextjs-build).
466
- 3. Wrap your Next.js config:
467
-
468
- ```javascript
469
- // next.config.js
470
- const { withPPDev } = require('@metricinsights/pp-dev');
471
-
472
- module.exports = withPPDev({
473
- // your Next.js config
474
- });
475
- ```
476
-
477
- ## Vite Configuration
478
-
479
- For custom build configuration, create a `vite.config` file. See [Vite Configuration](https://vitejs.dev/config/) for details.
480
-
481
- ## Dev Panel
482
-
483
- pp-dev injects a floating dev panel into every served page. It shows the pp-dev version (linked to npm), the backend URL, the template mode and the App ID, and hosts the template **Sync** button and the [Users](#working-as-other-users) button. Since 1.0 the panel is fully repositionable and can be hidden.
484
-
485
- ![Dev panel settings popover](./docs/screenshots/03-panel-settings.png)
486
-
487
- ### Position
488
-
489
- The panel can be anchored to any of the four screen corners (default: bottom-right). Three ways to move it:
490
-
491
- - **Drag & snap** — grab the grip handle (six dots on the panel's left side) and drag; on release the panel snaps to the nearest corner. Dragging works across iframes and is cancelled with <kbd>Escape</kbd>.
492
- - **Settings popover** — click the gear icon and pick a corner in the 2×2 grid.
493
- - **Config default** — set `devPanel.position` in `pp-dev.config` (see below).
494
-
495
- The minimize arrow, the panel's shadow, rounded corner and slide direction all mirror automatically for left/top placements. Sync notification popups stack from the screen edge opposite the panel so they never cover it.
496
-
497
- ### Auto-hide
498
-
499
- Toggle **Auto-hide** in the settings popover (or set `devPanel.autoHide: true`). The panel slides behind the nearest screen edge leaving a 4px accent strip; hovering the strip for ~300 ms slides it out, and it hides again ~500 ms after the pointer leaves. Keyboard focus inside the panel keeps it revealed. While auto-hide is active the minimize arrow acts as a **pin** button that returns the panel to normal mode.
500
-
501
- ### Theme
502
-
503
- The settings popover has an **Auto / Dark / Light** switcher. "Auto" follows the OS/browser preference; the other two force an override. The choice is shared (via the same `localStorage` key) with the standalone [Request Inspector](#request-inspector) and [Variables Editor](#variables-editor) pages, which also each have their own copy of the switcher for when they're opened directly without the panel present.
504
-
505
- ### Hiding and restoring
506
-
507
- **Hide panel** in the settings popover (or `devPanel.hidden: true`) removes the panel from view entirely. To bring it back, open any page with `?pp-dev-panel=show` in the URL — the override persists across reloads. The symmetric `?pp-dev-panel=hide` hides it, which is handy for demos and clean screenshots.
508
-
509
- ### State persistence
510
-
511
- Runtime choices are saved in the browser's `localStorage` (`pp-dev-info-position`, `pp-dev-info-auto-hide`, `pp-dev-info-hidden`, `pp-dev-info-theme`) and take precedence over config values. **Reset to config defaults** in the settings popover clears all overrides. Storage is origin-scoped: overrides apply to every pp-dev app served on the same host and port, and a Metric Insights page that clears origin storage will reset them to config defaults.
512
-
513
- ### Configuration
514
-
515
- ```typescript
516
- // pp-dev.config.ts
517
- export default defineConfig({
518
- devPanel: {
519
- position: 'bottom-right', // 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
520
- hidden: false, // hide the panel entirely (restore with ?pp-dev-panel=show)
521
- autoHide: false, // slide behind the screen edge, reveal on hover
522
- },
523
- });
524
- ```
525
-
526
- See the [`devPanel` option reference](#devpanel--dev-panel-appearance) for details.
527
-
528
- ### Page variables
529
-
530
- For pages with a template (`app.type: 'template'`), the settings popover has:
531
-
532
- - **Reload variables** — refetches the page's live variable values from MI right now (bypassing the usual request-level cache) and reloads the page, so `[VarName]` substitution reflects a just-saved value without restarting the dev server.
533
- - **Open variables editor…** — opens the standalone [Variables Editor](#variables-editor) page.
534
-
535
- Pages without a template (`app.type: 'page'`) have no variables, so this group — and the button that opens the editor — is hidden.
536
-
537
- ### Variables Editor
538
-
539
- A standalone page at `/@pp-dev/variables-editor`, alongside the [Request Inspector](#request-inspector), with two tabs:
540
-
541
- - **Schema** — view/edit the template's `__template_variables.json` (add/remove variables, change type, default, `additional_options`, etc.), with a raw-JSON escape hatch.
542
-
543
- ![Variables Editor — Schema tab](./docs/screenshots/06-editor-schema.png)
544
-
545
- - **Values** — edit the page's live variable values in place, with type-aware widgets (searchable select for `static` options, a per-item form for `list`, …). A JSON mode (`View/edit raw JSON`) shows/accepts the same values as plain JSON — list-type values as native arrays, not double-escaped strings — with **Save to JSON file…** / **Import from JSON file…** buttons, and flags values that don't match a declared option, changed since the last load, or aren't in the schema.
546
-
547
- The pages the dev server serves substitute `[VarName]` from its own copy of the values, loaded from MI with the page data. **Save** updates that copy too, so every tab (any user) shows the saved values on its next load. When the values in MI change some other way (edited in MI itself, or the update after a save failed), the Values tab shows **Update local pages · N** in its bottom-right corner; its tooltip lists the values that differ, and a click updates the copy.
548
-
549
- ![Variables Editor — Values tab](./docs/screenshots/09-editor-values.png)
550
-
551
- Both the active tab and Values' JSON mode are reflected in the URL (`?tab=values&mode=json`), so a specific view can be bookmarked or shared.
552
-
553
- See the [feature tour](./docs/features.md#variables-editor) for more screenshots, including the advanced/raw-JSON views and the theme switcher.
554
-
555
- See [`TEMPLATE_VARIABLES.md`](./TEMPLATE_VARIABLES.md) — also shipped inside the published package — for the `__template_variables.json` schema this feature reads.
556
-
557
- ## Working as other users
558
-
559
- Check how a Portal Page looks and behaves for users with other permissions, groups or data access, without restarting pp-dev or logging out. Add users in the dev panel's **Users** popover (the people icon) and open the page as any of them — side by side with your own tab.
560
-
561
- ![Users popover](./docs/screenshots/13-users-popover.png)
562
-
563
- ### How it works
564
-
565
- Every saved user gets its own host: `<name>.localhost:<port>`. The browser sends that host with every request of the tab (fetches, images, links, reloads, tabs opened from it, WebSockets) and keeps cookies and storage per host, so pp-dev knows whom each request is for, and the users' MI sessions never mix. Browsers resolve `*.localhost` to your machine on their own.
566
-
567
- - **`localhost:<port>`** works as the **default user**: you, unless you check another user in the popover.
568
- - **`<name>.localhost:<port>`** works as that user. Its dev panel's Users button is purple, so the tab is never taken for your own.
569
- - **The dev panel itself** (sync, page variables, Variables Editor, Request Inspector) always works as you, on every host.
570
-
571
- ### Requirements
572
-
573
- - **Your own API token** (`mi.token` or `MI_ACCESS_TOKEN`): the dev panel works as you through it. Without it the popover explains why users can't be added.
574
- - **The dev server opened on `localhost`**: hosts like `<name>.localhost` don't exist on an IP address or a custom domain; there pp-dev works as before, without users.
575
-
576
- ### Adding users
577
-
578
- - **API token**: the token is checked with MI before the user is added. SSO users can only be added this way.
579
- - **Username + password** (local MI users): pp-dev adds the user and opens MI's usual login page on the user's own host. You log in there as in MI — 2FA included — and pp-dev never sees the password. Until then the user is *not logged in yet*; once MI ends the session it is *session expired* and **Log in** opens the login page again.
580
-
581
- The name becomes the user's host, so it may contain only lowercase latin letters, digits and `-`, must start with a letter and be at most 32 characters long.
582
-
583
- **Edit** on a user added with an API token renames it or replaces its token (a new token is checked with MI; left empty, the current one stays). While the dev server runs, a page load on its old host (an open tab, a bookmark) moves to the new one, and requests from tabs still open there keep working as the user. A user that logs in with a password can't be edited, since its MI session lives in its host's cookies: remove it and add it again.
584
-
585
- ### Logging out and removing
586
-
587
- Logging out on a user's host ends that user's MI session (or token) as it would in MI, removes the user, and sends the tab back to `localhost`. **×** in the popover removes a user without logging it out of MI. Either way pp-dev drops what it cached for that user.
588
-
589
- ### Keeping users between runs
590
-
591
- Users live as long as the dev server. With `users: { persist: true }` the users added with an API token are kept in `~/.pp-dev/users/<hash>.json` — one file per project and MI instance, readable by you only, outside the project so it never ends up in git or a build. Passwords and MI sessions are never written. On start, every kept token is checked with MI again; one MI turns down shows as *API token turned down by MI*.
592
-
593
- ```typescript
594
- // pp-dev.config.ts
595
- export default defineConfig({
596
- users: {
597
- persist: true,
598
- },
599
- });
600
- ```
601
-
602
- ### REST API
603
-
604
- The popover uses a small JSON API:
605
-
606
- | Method | Path | Description |
607
- |----------|-------------------------|---------------------------------------------------------------------------------------------------|
608
- | `GET` | `/@api/users` | The users (name, kind, state, MI user, `origin`, `loginUrl`), the default user, and whether users are available |
609
- | `POST` | `/@api/users` | Add a user: `{ "name", "token" }`, or `{ "name", "kind": "session" }` to log in with a password |
610
- | `PUT` | `/@api/users/default` | Make a user the default: `{ "name" }`, or `{ "name": null }` for you |
611
- | `PATCH` | `/@api/users/:name` | Edit a user added with an API token: `{ "name" }` to rename it, `{ "token" }` to replace its token |
612
- | `DELETE` | `/@api/users/:name` | Remove a user |
613
-
614
- Tokens and MI sessions are never sent back.
615
-
616
- ## Request Inspector
617
-
618
- pp-dev includes a built-in request inspector that captures every proxied and locally-served HTTP request made during development. It is enabled by default.
619
-
620
- ### Web UI
621
-
622
- Open `http://localhost:3000/@pp-dev/inspector` (replace port as needed) in any browser tab while the dev server is running. The UI shows:
623
-
624
- - A scrollable list of captured requests with method, status, source badge, and timing
625
- - A tag with the user whose tab made the request, and a user filter, once you [work as other users](#working-as-other-users)
626
- - Full request and response headers, with a **Copy** button per section. Credentials are kept out: an `Authorization` value and the MI session cookie show as `<redacted>`
627
- - Request and response bodies rendered as text for JSON/HTML/CSS/plain-text content types, with **Copy** and **Save** buttons
628
- - Binary bodies (images, fonts, archives) show metadata only and offer a **Save** button
629
-
630
- ![Request Inspector — request list](./docs/screenshots/04-inspector-list.png)
631
-
632
- Selecting a request opens the detail pane with headers and a syntax-highlighted body:
633
-
634
- ![Request Inspector — request detail](./docs/screenshots/05-inspector-detail.png)
635
- - A **Clear** button in the top-right removes all stored entries
636
-
637
- ### Source badges
638
-
639
- Each request in the list displays a colored letter badge to the left of the HTTP status:
640
-
641
- | Badge | Color | Meaning |
642
- |-------|--------|----------------------------------------------|
643
- | `P` | Purple | Forwarded to the upstream Metric Insights server (proxy) |
644
- | `C` | Amber | Served from the local proxy cache |
645
- | `L` | Grey | Served locally (static file, dev route, etc.) |
646
-
647
- ### Console banner
648
-
649
- The dev panel script prints a one-line banner to the browser DevTools console when the page loads:
650
-
651
- ```
652
- pp-dev 🔍 Request Inspector → http://localhost:3000/@pp-dev/inspector
653
- ```
654
-
655
- The message persists in DevTools history so it is visible even when you open the console after the page has loaded.
656
-
657
- ### REST API
658
-
659
- The inspector also exposes a lightweight JSON API, useful for tooling and AI agents:
660
-
661
- | Method | Path | Description |
662
- |----------|-------------------------|---------------------------------------------|
663
- | `GET` | `/@api/requests` | Paginated list of captured requests (metadata only, no bodies) |
664
- | `GET` | `/@api/requests/:id` | Full entry including captured request/response bodies (base64-encoded) |
665
- | `GET` | `/@api/requests/stats` | Store stats: entry count, memory usage, limits |
666
- | `DELETE` | `/@api/requests` | Clear all stored entries |
667
-
668
- `GET /@api/requests` accepts `?limit=` (default 50) and `?offset=` query parameters for pagination.
669
-
670
- Bodies in `GET /@api/requests/:id` are returned as base64 strings in `requestBody` / `responseBody` fields alongside `requestContentType` / `responseContentType`. A `*Truncated: true` flag indicates the body exceeded `captureLimit` and was cut off.
671
-
672
- ### Configuration
673
-
674
- ```typescript
675
- // pp-dev.config.ts
676
- export default defineConfig({
677
- inspector: {
678
- enabled: true, // set to false to disable entirely
679
- maxMemory: 100 * 1024 * 1024, // evict oldest entries above 100 MB
680
- captureLimit: 10 * 1024 * 1024, // capture at most 10 MB per body
681
- },
682
- });
683
- ```
684
-
685
- ## Troubleshooting
686
-
687
- ### Common Issues
688
-
689
- #### Next.js Peer Dependency Error
690
-
691
- If you encounter an error like "Next.js is required but not available":
692
-
693
- 1. **Install Next.js in your project:**
694
-
695
- ```bash
696
- npm install next@^15
697
- ```
698
-
699
- 2. **Verify the installation:**
700
-
701
- ```bash
702
- npm list next
703
- ```
704
-
705
- 3. **Check your package.json:**
706
- ```json
707
- {
708
- "dependencies": {
709
- "next": "^15.0.0"
710
- }
711
- }
712
- ```
713
-
714
- #### Version Compatibility
715
-
716
- - **pp-dev** requires Next.js version 15 or higher (but less than 17)
717
- - **Node.js** version 24 or higher is required
718
- - **TypeScript** version 5 or higher is recommended
719
-
720
- ### Getting Help
721
-
722
- - Check the [GitHub Issues](https://github.com/mi-examples/pp-dev-js/issues) for known problems
723
- - Review the [CHANGELOG.md](./CHANGELOG.md) for recent changes
724
- - Ensure all peer dependencies are properly installed