@metricinsights/pp-dev 0.3.0 → 0.3.1

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 (101) hide show
  1. package/README.md +51 -41
  2. package/bin/pp-dev.js +4 -10
  3. package/dist/cjs/cli.js +590 -0
  4. package/dist/cjs/cli.js.map +1 -0
  5. package/dist/cjs/helpers.js +29 -0
  6. package/dist/cjs/helpers.js.map +1 -0
  7. package/dist/cjs/index-24d6a380.js +292 -0
  8. package/dist/cjs/index-24d6a380.js.map +1 -0
  9. package/dist/cjs/index.js +28 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/package.json +113 -0
  12. package/dist/cjs/plugin-24dd0a43.js +878 -0
  13. package/dist/cjs/plugin-24dd0a43.js.map +1 -0
  14. package/dist/cjs/plugin.js +20 -0
  15. package/dist/cjs/plugin.js.map +1 -0
  16. package/dist/{cli.js → esm/cli.js} +211 -23
  17. package/dist/esm/cli.js.map +1 -0
  18. package/dist/esm/helpers.js +25 -0
  19. package/dist/esm/helpers.js.map +1 -0
  20. package/dist/{index.js → esm/index-833c47d2.js} +97 -11
  21. package/dist/esm/index-833c47d2.js.map +1 -0
  22. package/dist/esm/index.js +20 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/package.json +113 -0
  25. package/dist/esm/plugin-ecb1c54a.js +843 -0
  26. package/dist/esm/plugin-ecb1c54a.js.map +1 -0
  27. package/dist/esm/plugin.js +14 -0
  28. package/dist/esm/plugin.js.map +1 -0
  29. package/dist/types/cli.d.ts +3 -0
  30. package/dist/types/helpers.d.ts +24 -0
  31. package/dist/types/index.d.ts +18 -0
  32. package/dist/{plugin.d.ts → types/plugin.d.ts} +4 -2
  33. package/package.json +23 -8
  34. package/pp-dev.d.ts +1 -1
  35. package/dist/api/assets.d.ts +0 -15
  36. package/dist/api/assets.js +0 -58
  37. package/dist/api/assets.js.map +0 -1
  38. package/dist/api/base.d.ts +0 -5
  39. package/dist/api/base.js +0 -7
  40. package/dist/api/base.js.map +0 -1
  41. package/dist/api/constants.d.ts +0 -1
  42. package/dist/api/constants.js +0 -2
  43. package/dist/api/constants.js.map +0 -1
  44. package/dist/api/index.d.ts +0 -2
  45. package/dist/api/index.js +0 -3
  46. package/dist/api/index.js.map +0 -1
  47. package/dist/api/page.d.ts +0 -16
  48. package/dist/api/page.js +0 -43
  49. package/dist/api/page.js.map +0 -1
  50. package/dist/banner/header.d.ts +0 -2
  51. package/dist/banner/header.js +0 -10
  52. package/dist/banner/header.js.map +0 -1
  53. package/dist/cli.d.ts +0 -1
  54. package/dist/cli.js.map +0 -1
  55. package/dist/client/rollup.config.d.ts +0 -2
  56. package/dist/constants.d.ts +0 -6
  57. package/dist/constants.js +0 -18
  58. package/dist/constants.js.map +0 -1
  59. package/dist/index.d.ts +0 -13
  60. package/dist/index.js.map +0 -1
  61. package/dist/lib/client.service.d.ts +0 -16
  62. package/dist/lib/client.service.js +0 -59
  63. package/dist/lib/client.service.js.map +0 -1
  64. package/dist/lib/dist.service.d.ts +0 -31
  65. package/dist/lib/dist.service.js +0 -148
  66. package/dist/lib/dist.service.js.map +0 -1
  67. package/dist/lib/helpers/content-encoding.helper.d.ts +0 -3
  68. package/dist/lib/helpers/content-encoding.helper.js +0 -26
  69. package/dist/lib/helpers/content-encoding.helper.js.map +0 -1
  70. package/dist/lib/helpers/server.d.ts +0 -14
  71. package/dist/lib/helpers/server.js +0 -40
  72. package/dist/lib/helpers/server.js.map +0 -1
  73. package/dist/lib/helpers/url.helper.d.ts +0 -7
  74. package/dist/lib/helpers/url.helper.js +0 -40
  75. package/dist/lib/helpers/url.helper.js.map +0 -1
  76. package/dist/lib/load-pp-data.middleware.d.ts +0 -5
  77. package/dist/lib/load-pp-data.middleware.js +0 -28
  78. package/dist/lib/load-pp-data.middleware.js.map +0 -1
  79. package/dist/lib/pp-redirect.middleware.d.ts +0 -3
  80. package/dist/lib/pp-redirect.middleware.js +0 -21
  81. package/dist/lib/pp-redirect.middleware.js.map +0 -1
  82. package/dist/lib/pp.middleware.d.ts +0 -27
  83. package/dist/lib/pp.middleware.js +0 -155
  84. package/dist/lib/pp.middleware.js.map +0 -1
  85. package/dist/lib/proxy-cache.middleware.d.ts +0 -18
  86. package/dist/lib/proxy-cache.middleware.js +0 -51
  87. package/dist/lib/proxy-cache.middleware.js.map +0 -1
  88. package/dist/lib/proxy-pass.middleware.d.ts +0 -11
  89. package/dist/lib/proxy-pass.middleware.js +0 -90
  90. package/dist/lib/proxy-pass.middleware.js.map +0 -1
  91. package/dist/lib/rewrite-response.middleware.d.ts +0 -6
  92. package/dist/lib/rewrite-response.middleware.js +0 -23
  93. package/dist/lib/rewrite-response.middleware.js.map +0 -1
  94. package/dist/plugin.js +0 -76
  95. package/dist/plugin.js.map +0 -1
  96. package/dist/plugins/client-injection-plugin.d.ts +0 -12
  97. package/dist/plugins/client-injection-plugin.js +0 -57
  98. package/dist/plugins/client-injection-plugin.js.map +0 -1
  99. package/dist/shortcuts.d.ts +0 -12
  100. package/dist/shortcuts.js +0 -93
  101. package/dist/shortcuts.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # pp-dev
2
2
 
3
- Portal Page development framework and build tool.
3
+ The PP Dev Helper is a development framework and build tool for Metric Insights' Portal Pages, designed to make the lives of PP developers easier:
4
+ - build your Portal Page
5
+ - run/test locally with API requests proxied to a Metric Insights server
6
+ - a lot more (to be documented soon!)
4
7
 
5
- This package is based on [Vite](https://vitejs.dev/) tool.
8
+ pp-dev is based on [Vite](https://vitejs.dev/).
6
9
 
7
10
  ## Usage
8
11
 
@@ -12,13 +15,14 @@ Package installation
12
15
  $ npm i @metricinsights/pp-dev
13
16
  ```
14
17
 
15
- ### Define configuration
18
+ ### Define Configuration
16
19
 
17
- You need to create the file with the name `pp-dev.config` and extension `js` or
18
- `cjs` (if you define type `module` in package.json) or `ts` if you want to use Typescript, or `json`.
19
- You also can define configuration in `package.json` with the `pp-dev` key
20
+ You'll need to create a file with the name `pp-dev.config` and extension `js` or
21
+ `cjs` (if you define type `module` in package.json), or `ts` if you want to use TypeScript, or `json`.
20
22
 
21
- Config examples:
23
+ Alternatively, you can define configuration in your `package.json` via the `pp-dev` key
24
+
25
+ Generic configuration examples:
22
26
 
23
27
  - JavaScript
24
28
 
@@ -29,12 +33,12 @@ Config examples:
29
33
  * @type {import('@metricinsights/pp-dev').PPDevConfig}
30
34
  */
31
35
  module.exports = {
32
- backendBaseURL: 'https://example.metricinsights.com',
36
+ backendBaseURL: 'https://mi.company.com',
33
37
  portalPageId: 1,
34
38
  };
35
39
  ```
36
40
 
37
- - Typescript
41
+ - TypeScript
38
42
 
39
43
  ```typescript
40
44
  // pp-dev.config.ts
@@ -42,23 +46,23 @@ module.exports = {
42
46
  import { PPDevConfig } from '@metricinsights/pp-dev';
43
47
 
44
48
  const config: PPDevConfig = {
45
- backendBaseURL: 'https://example.metricinsights.com',
49
+ backendBaseURL: 'https://mi.company.com',
46
50
  portalPageId: 1,
47
51
  };
48
52
 
49
53
  export default config;
50
54
  ```
51
55
 
52
- - JSON (`pp-dev.config.json`)
56
+ - JSON as `pp-dev.config.json`
53
57
 
54
58
  ```json
55
59
  {
56
- "backendBaseURL": "https://example.metricinsights.com",
60
+ "backendBaseURL": "https://mi.company.com",
57
61
  "portalPageId": 1
58
62
  }
59
63
  ```
60
64
 
61
- - JSON in `package.json` file
65
+ - JSON as `package.json`
62
66
 
63
67
  ```json
64
68
  {
@@ -66,16 +70,38 @@ export default config;
66
70
  "version": "1.0.0",
67
71
  "scripts": {},
68
72
  "pp-dev": {
69
- "backendBaseURL": "https://example.metricinsights.com",
73
+ "backendBaseURL": "https://mi.company.com",
70
74
  "portalPageId": 1
71
75
  }
72
76
  }
73
77
  ```
74
78
 
79
+ ## [Next.js](https://nextjs.org/) Configuration
80
+
81
+ To use the PP Dev Helper with Next.js:
82
+
83
+ 1. Add pp-dev config to your root directory.
84
+
85
+ 2. Change your `dev` script in `package.json` to `pp-dev next`.
86
+
87
+ 3. Finally, wrap your next.config with a `withPPDev` function.
88
+
89
+ ```javascript
90
+ // next.config.js
91
+
92
+ const { withPPDev } = require('@metricinsights/pp-dev');
93
+
94
+ module.exports = withPPDev({
95
+ // your next config
96
+ });
97
+ ```
98
+
99
+
100
+
75
101
  ### Vite configuration
76
102
 
77
- If you need to change something in the build you can define `vite.config` file.
78
- More description you can find [here](https://vitejs.dev/config/)
103
+ If you need to change something in the build you can define a `vite.config` file.
104
+ More details [Vite Confighere](https://vitejs.dev/config/)
79
105
 
80
106
  ### Configuration API description
81
107
 
@@ -83,7 +109,7 @@ More description you can find [here](https://vitejs.dev/config/)
83
109
 
84
110
  Type: String
85
111
 
86
- Example: `https://example.metricinsights.com`
112
+ Example: `https://mi.company.com`
87
113
 
88
114
  Description: Defines the backend URL (Metric Insights instance) that is used for proxying requests to the MI backend
89
115
 
@@ -93,7 +119,7 @@ Type: Number
93
119
 
94
120
  Example: `1`
95
121
 
96
- Description: Defines the Portal Page Id that used to get portal page variables values.
122
+ Description: Defines the Portal Page ID that used to get Portal Page Variable values.
97
123
 
98
124
  #### `miHudLess`
99
125
 
@@ -113,7 +139,7 @@ Default: `false`
113
139
 
114
140
  Example: `true`
115
141
 
116
- Description: Disables template variables transforming. Used when you develop the portal page without a template
142
+ Description: Disables Template Variables transformation. Used when developing a Portal Page without a template
117
143
 
118
144
  #### `enableProxyCache`
119
145
 
@@ -138,9 +164,10 @@ Description: Defines proxy cache TTL in milliseconds
138
164
  - `pp-dev` or `pp-dev serve` or `pp-dev dev` runs application in development mode
139
165
  - `pp-dev build` starts the application build. Will create `dist` and `dist-zip` folders. `dist` folder contains unzipped build files. `dist-zip` contains file `<package-name>.zip` with files from the `dist` folder
140
166
 
141
- ## Migration guide from old portal page helper to new
142
167
 
143
- 1. You need to initialize npm in your portal page repository (if you have `package.json` file in PP folder, you can skip this step):
168
+ ## Migration guide from old Portal Page Helper to new
169
+
170
+ 1. Initialize npm in your portal page repository (if you have `package.json` file in PP folder, you can skip this step):
144
171
 
145
172
  Go to portal page folder and run command. This command will create `package.json` file in your folder
146
173
 
@@ -148,35 +175,18 @@ Description: Defines proxy cache TTL in milliseconds
148
175
  $ npm init
149
176
  ```
150
177
 
151
- 2. You need to install this package by this command:
178
+ 2. Install this package by this command:
152
179
  ```shell
153
180
  $ npm i @metricinsights/pp-dev
154
181
  ```
155
- 3. You need to create two scripts in `package.json` script section.
182
+ 3. Create two scripts in `package.json` script section.
156
183
 
157
184
  - `start` script: `"start": "pp-dev"`
158
185
  - `build` script: `"build": "pp-dev build"`
159
186
 
160
- 4. You need to change all paths to the file in index.html to the absolute path.
187
+ 4. Change all paths to the file in index.html to the absolute path.
161
188
  If you have a path like `/pt/main.js` this must be changed to `/main.js`.
162
189
  Also, you may need to add `type="module"` to every script that is added by the `script` tag with the `src` property.
163
190
  Actually would be good to have only one `script` tag with the `src` tag.
164
191
  Every other JS file will be imported with construction like this `import helper from './helpers';`
165
192
 
166
- ## [Next.js](https://nextjs.org/) support
167
-
168
- If you want to use Portal Page helper with Next.js, you need to add pp-dev config to your root directory.
169
-
170
- Then you need to change your `dev` script in `package.json` to `pp-dev next`.
171
-
172
- The last step is to wrap your next config with `withPPDev` function.
173
-
174
- ```javascript
175
- // next.config.js
176
-
177
- const { withPPDev } = require('@metricinsights/pp-dev');
178
-
179
- module.exports = withPPDev({
180
- // your next config
181
- });
182
- ```
package/bin/pp-dev.js CHANGED
@@ -13,12 +13,8 @@ if (!import.meta.url.includes('node_modules')) {
13
13
  global.__pp_dev_start_time = performance.now();
14
14
 
15
15
  // check debug mode first before requiring the CLI.
16
- const debugIndex = process.argv.findIndex((arg) =>
17
- /^(?:-d|--debug)$/.test(arg),
18
- );
19
- const filterIndex = process.argv.findIndex((arg) =>
20
- /^(?:-f|--filter)$/.test(arg),
21
- );
16
+ const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg));
17
+ const filterIndex = process.argv.findIndex((arg) => /^(?:-f|--filter)$/.test(arg));
22
18
  const profileIndex = process.argv.indexOf('--profile');
23
19
 
24
20
  if (debugIndex > 0) {
@@ -33,9 +29,7 @@ if (debugIndex > 0) {
33
29
  .map((v) => `pp-dev:${v},vite:${v}`)
34
30
  .join(',');
35
31
  }
36
- process.env.DEBUG = `${
37
- process.env.DEBUG ? process.env.DEBUG + ',' : ''
38
- }${value}`;
32
+ process.env.DEBUG = `${process.env.DEBUG ? process.env.DEBUG + ',' : ''}${value}`;
39
33
 
40
34
  if (filterIndex > 0) {
41
35
  const filter = process.argv[filterIndex + 1];
@@ -48,7 +42,7 @@ if (debugIndex > 0) {
48
42
  }
49
43
 
50
44
  function start() {
51
- return import('../dist/cli.js');
45
+ return import('../dist/esm/cli.js');
52
46
  }
53
47
 
54
48
  if (profileIndex > 0) {