@crownpeak/dqm-react-component 1.1.0 → 1.2.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 (163) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +52 -24
  3. package/dist/DQMSidebar.d.ts.map +1 -1
  4. package/dist/ErrorBoundary.d.ts.map +1 -1
  5. package/dist/__tests__/setup.d.ts +1 -0
  6. package/dist/__tests__/setup.d.ts.map +1 -0
  7. package/dist/__tests__/utils.d.ts +145 -0
  8. package/dist/__tests__/utils.d.ts.map +1 -0
  9. package/dist/auth-ui/assets/index-YKFZYENy.js +158 -0
  10. package/dist/auth-ui/index.html +1 -1
  11. package/dist/components/auth/DQMLogin.d.ts.map +1 -1
  12. package/dist/components/auth/index.d.ts +0 -1
  13. package/dist/components/auth/index.d.ts.map +1 -1
  14. package/dist/components/cards/AISummaryCard.d.ts +2 -0
  15. package/dist/components/cards/AISummaryCard.d.ts.map +1 -0
  16. package/dist/components/cards/index.d.ts +1 -0
  17. package/dist/components/cards/index.d.ts.map +1 -1
  18. package/dist/components/common/LanguageSwitch.d.ts +5 -0
  19. package/dist/components/common/LanguageSwitch.d.ts.map +1 -0
  20. package/dist/components/common/LanguageSwitchBase.d.ts +16 -0
  21. package/dist/components/common/LanguageSwitchBase.d.ts.map +1 -0
  22. package/dist/components/common/index.d.ts +1 -0
  23. package/dist/components/common/index.d.ts.map +1 -1
  24. package/dist/components/modals/AISettingsDialog.d.ts +61 -0
  25. package/dist/components/modals/AISettingsDialog.d.ts.map +1 -0
  26. package/dist/components/modals/HighlightModal.d.ts +45 -0
  27. package/dist/components/modals/HighlightModal.d.ts.map +1 -0
  28. package/dist/components/modals/LoginOverlay.d.ts +22 -0
  29. package/dist/components/modals/LoginOverlay.d.ts.map +1 -0
  30. package/dist/components/modals/index.d.ts +9 -0
  31. package/dist/components/modals/index.d.ts.map +1 -0
  32. package/dist/components/renderers/BrowserViewRenderer.d.ts.map +1 -1
  33. package/dist/components/renderers/ShadowDOMRenderer.d.ts.map +1 -1
  34. package/dist/components/sidebar/index.d.ts +1 -0
  35. package/dist/components/sidebar/index.d.ts.map +1 -1
  36. package/dist/context/ai/AIContext.d.ts +13 -0
  37. package/dist/context/ai/AIContext.d.ts.map +1 -0
  38. package/dist/context/ai/index.d.ts +12 -0
  39. package/dist/context/ai/index.d.ts.map +1 -0
  40. package/dist/context/ai/types.d.ts +161 -0
  41. package/dist/context/ai/types.d.ts.map +1 -0
  42. package/dist/context/ai/useAIEngine.d.ts +10 -0
  43. package/dist/context/ai/useAIEngine.d.ts.map +1 -0
  44. package/dist/context/ai/useAISummary.d.ts +10 -0
  45. package/dist/context/ai/useAISummary.d.ts.map +1 -0
  46. package/dist/context/ai/useAITranslation.d.ts +10 -0
  47. package/dist/context/ai/useAITranslation.d.ts.map +1 -0
  48. package/dist/context/ai/useTranslationCache.d.ts +9 -0
  49. package/dist/context/ai/useTranslationCache.d.ts.map +1 -0
  50. package/dist/dqm-widget.esm.js +394 -264
  51. package/dist/dqm-widget.iife.js +76 -25
  52. package/dist/hooks/index.d.ts +10 -0
  53. package/dist/hooks/index.d.ts.map +1 -0
  54. package/dist/hooks/useAnalysis.d.ts +43 -0
  55. package/dist/hooks/useAnalysis.d.ts.map +1 -0
  56. package/dist/hooks/useAuthentication.d.ts +49 -0
  57. package/dist/hooks/useAuthentication.d.ts.map +1 -0
  58. package/dist/hooks/useHighlightActions.d.ts +37 -0
  59. package/dist/hooks/useHighlightActions.d.ts.map +1 -0
  60. package/dist/hooks/useHighlights.d.ts +72 -0
  61. package/dist/hooks/useHighlights.d.ts.map +1 -0
  62. package/dist/html-pages/DQMWidget.d.ts.map +1 -1
  63. package/dist/html-pages/index.d.ts.map +1 -1
  64. package/dist/i18n/auth/de.d.ts +25 -0
  65. package/dist/i18n/auth/de.d.ts.map +1 -0
  66. package/dist/i18n/auth/en.d.ts +26 -0
  67. package/dist/i18n/auth/en.d.ts.map +1 -0
  68. package/dist/i18n/auth/es.d.ts +25 -0
  69. package/dist/i18n/auth/es.d.ts.map +1 -0
  70. package/dist/i18n/auth/index.d.ts +8 -0
  71. package/dist/i18n/auth/index.d.ts.map +1 -0
  72. package/dist/i18n/common/de.d.ts +18 -0
  73. package/dist/i18n/common/de.d.ts.map +1 -0
  74. package/dist/i18n/common/en.d.ts +19 -0
  75. package/dist/i18n/common/en.d.ts.map +1 -0
  76. package/dist/i18n/common/es.d.ts +18 -0
  77. package/dist/i18n/common/es.d.ts.map +1 -0
  78. package/dist/i18n/common/index.d.ts +8 -0
  79. package/dist/i18n/common/index.d.ts.map +1 -0
  80. package/dist/i18n/demo/de.d.ts +104 -0
  81. package/dist/i18n/demo/de.d.ts.map +1 -0
  82. package/dist/i18n/demo/en.d.ts +105 -0
  83. package/dist/i18n/demo/en.d.ts.map +1 -0
  84. package/dist/i18n/demo/es.d.ts +104 -0
  85. package/dist/i18n/demo/es.d.ts.map +1 -0
  86. package/dist/i18n/demo/index.d.ts +8 -0
  87. package/dist/i18n/demo/index.d.ts.map +1 -0
  88. package/dist/i18n/index.d.ts +673 -0
  89. package/dist/i18n/index.d.ts.map +1 -0
  90. package/dist/i18n/sidebar/de.d.ts +89 -0
  91. package/dist/i18n/sidebar/de.d.ts.map +1 -0
  92. package/dist/i18n/sidebar/en.d.ts +90 -0
  93. package/dist/i18n/sidebar/en.d.ts.map +1 -0
  94. package/dist/i18n/sidebar/es.d.ts +89 -0
  95. package/dist/i18n/sidebar/es.d.ts.map +1 -0
  96. package/dist/i18n/sidebar/index.d.ts +8 -0
  97. package/dist/i18n/sidebar/index.d.ts.map +1 -0
  98. package/dist/i18n.d.ts +8 -0
  99. package/dist/i18n.d.ts.map +1 -0
  100. package/dist/index.cjs +61 -31
  101. package/dist/index.cjs.map +1 -1
  102. package/dist/index.d.ts +7 -1
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.html +3 -3
  105. package/dist/index.js +17795 -7252
  106. package/dist/index.js.map +1 -1
  107. package/dist/locale.d.ts +25 -0
  108. package/dist/locale.d.ts.map +1 -0
  109. package/dist/mocks/browser.d.ts +23 -0
  110. package/dist/mocks/browser.d.ts.map +1 -0
  111. package/dist/mocks/handlers.d.ts +32 -0
  112. package/dist/mocks/handlers.d.ts.map +1 -0
  113. package/dist/mocks/index.d.ts +7 -0
  114. package/dist/mocks/index.d.ts.map +1 -0
  115. package/dist/mocks/server.d.ts +24 -0
  116. package/dist/mocks/server.d.ts.map +1 -0
  117. package/dist/server/routes/auth.js +0 -10
  118. package/dist/server/routes/auth.js.map +1 -1
  119. package/dist/store/api/dqmApi.d.ts +1793 -0
  120. package/dist/store/api/dqmApi.d.ts.map +1 -0
  121. package/dist/store/api/index.d.ts +6 -0
  122. package/dist/store/api/index.d.ts.map +1 -0
  123. package/dist/store/index.d.ts +57 -0
  124. package/dist/store/index.d.ts.map +1 -0
  125. package/dist/store/localeSlice.d.ts +6 -0
  126. package/dist/store/localeSlice.d.ts.map +1 -0
  127. package/dist/store/slices/aiSlice.d.ts +134 -0
  128. package/dist/store/slices/aiSlice.d.ts.map +1 -0
  129. package/dist/store/slices/analysisSlice.d.ts +54 -0
  130. package/dist/store/slices/analysisSlice.d.ts.map +1 -0
  131. package/dist/store/slices/authSlice.d.ts +170 -0
  132. package/dist/store/slices/authSlice.d.ts.map +1 -0
  133. package/dist/store/slices/highlightSlice.d.ts +188 -0
  134. package/dist/store/slices/highlightSlice.d.ts.map +1 -0
  135. package/dist/store/slices/index.d.ts +12 -0
  136. package/dist/store/slices/index.d.ts.map +1 -0
  137. package/dist/types.d.ts +27 -8
  138. package/dist/types.d.ts.map +1 -1
  139. package/dist/utils/aiJsonClient.d.ts +23 -0
  140. package/dist/utils/aiJsonClient.d.ts.map +1 -0
  141. package/dist/utils/colors/GenerateCategoryColors.d.ts.map +1 -1
  142. package/dist/utils/logger.d.ts +107 -0
  143. package/dist/utils/logger.d.ts.map +1 -0
  144. package/dist/utils/openaiJsonClient.d.ts +8 -0
  145. package/dist/utils/openaiJsonClient.d.ts.map +1 -0
  146. package/dist/utils/sanitizeHtmlDocument.d.ts +4 -0
  147. package/dist/utils/sanitizeHtmlDocument.d.ts.map +1 -0
  148. package/dist/utils/secureStorage.d.ts +95 -0
  149. package/dist/utils/secureStorage.d.ts.map +1 -0
  150. package/dist/utils/storage.d.ts.map +1 -1
  151. package/dist/utils/translationCache.d.ts +45 -0
  152. package/dist/utils/translationCache.d.ts.map +1 -0
  153. package/dist/utils/translationUtils.d.ts +52 -0
  154. package/dist/utils/translationUtils.d.ts.map +1 -0
  155. package/package.json +48 -10
  156. package/AUTHENTICATION.md +0 -281
  157. package/BACKEND-API.md +0 -1829
  158. package/DEVELOPMENT.md +0 -374
  159. package/EXAMPLES.md +0 -381
  160. package/QUICKSTART.md +0 -207
  161. package/dist/auth-ui/assets/index-CczTRrba.js +0 -158
  162. package/dist/components/auth/OAuth2CallbackHandler.d.ts +0 -15
  163. package/dist/components/auth/OAuth2CallbackHandler.d.ts.map +0 -1
package/EXAMPLES.md DELETED
@@ -1,381 +0,0 @@
1
- # Example Usage
2
-
3
- This directory contains example implementations of the `@crownpeak/dqm-react-component`.
4
-
5
- ## Basic React App Example
6
-
7
- ```tsx
8
- import React, {useState} from 'react';
9
- import {DQMSidebar} from '@crownpeak/dqm-react-component';
10
-
11
- function App() {
12
- const [sidebarOpen, setSidebarOpen] = useState(false);
13
-
14
- // Set DQM credentials (e.g., from environment variables)
15
- React.useEffect(() => {
16
- localStorage.setItem('dqm_apiKey', process.env.REACT_APP_DQM_API_KEY);
17
- localStorage.setItem('dqm_websiteID', process.env.REACT_APP_DQM_WEBSITE_ID);
18
- }, []);
19
-
20
- return (
21
- <div>
22
- <h1>My Application with DQM</h1>
23
- <p>This page is monitored by Crownpeak DQM for quality assurance.</p>
24
-
25
- <DQMSidebar
26
- open={sidebarOpen}
27
- onClose={() => setSidebarOpen(false)}
28
- onOpen={() => setSidebarOpen(true)}
29
- />
30
- </div>
31
- );
32
- }
33
-
34
- export default App;
35
- ```
36
-
37
- ## Next.js Example
38
-
39
- ```tsx
40
- // pages/_app.tsx
41
- import type {AppProps} from 'next/app';
42
- import {useEffect, useState} from 'react';
43
- import {DQMSidebar} from '@crownpeak/dqm-react-component';
44
- import {createTheme} from '@mui/material/styles';
45
-
46
- const theme = createTheme();
47
-
48
- function MyApp({Component, pageProps}: AppProps) {
49
- const [sidebarOpen, setSidebarOpen] = useState(false);
50
-
51
- useEffect(() => {
52
- if (typeof window !== 'undefined') {
53
- localStorage.setItem('dqm_apiKey', process.env.NEXT_PUBLIC_DQM_API_KEY!);
54
- localStorage.setItem('dqm_websiteID', process.env.NEXT_PUBLIC_DQM_WEBSITE_ID!);
55
- }
56
- }, []);
57
-
58
- return (
59
- <>
60
- <Component {...pageProps} />
61
- <DQMSidebar
62
- open={sidebarOpen}
63
- onClose={() => setSidebarOpen(false)}
64
- onOpen={() => setSidebarOpen(true)}
65
- />
66
- </>
67
- );
68
- }
69
-
70
- export default MyApp;
71
- ```
72
-
73
- ## TypeScript Example with Custom Configuration
74
-
75
- ```tsx
76
- import React, { useState, useCallback } from 'react';
77
- import { DQMSidebar, ErrorBoundary } from '@crownpeak/dqm-react-component';
78
- import type { DQMSidebarProps } from '@crownpeak/dqm-react-component';
79
-
80
- interface DQMConfig {
81
- apiKey: string;
82
- websiteId: string;
83
- enabled: boolean;
84
- }
85
-
86
- const config: DQMConfig = {
87
- apiKey: process.env.REACT_APP_DQM_API_KEY!,
88
- websiteId: process.env.REACT_APP_DQM_WEBSITE_ID!,
89
- enabled: process.env.NODE_ENV === 'production'
90
- };
91
-
92
- function App() {
93
- const [sidebarOpen, setSidebarOpen] = useState(false);
94
-
95
- React.useEffect(() => {
96
- if (config.enabled) {
97
- localStorage.setItem('dqm_apiKey', config.apiKey);
98
- localStorage.setItem('dqm_websiteID', config.websiteId);
99
- }
100
- }, []);
101
-
102
- const handleOpen = useCallback(() => {
103
- setSidebarOpen(true);
104
- }, []);
105
-
106
- const handleClose = useCallback(() => {
107
- setSidebarOpen(false);
108
- }, []);
109
-
110
- if (!config.enabled) {
111
- return <div>DQM is disabled in this environment</div>;
112
- }
113
-
114
- return (
115
- <ErrorBoundary>
116
- <div>
117
- <h1>App with DQM Quality Monitoring</h1>
118
- <DQMSidebar
119
- open={sidebarOpen}
120
- onClose={handleClose}
121
- onOpen={handleOpen}
122
- />
123
- </div>
124
- </ErrorBoundary>
125
- );
126
- }
127
-
128
- export default App;
129
- ```
130
-
131
- ## Conditional Rendering (Development Only)
132
-
133
- ```tsx
134
- import React from 'react';
135
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
136
-
137
- function App() {
138
- const [sidebarOpen, setSidebarOpen] = React.useState(false);
139
- const isDevelopment = process.env.NODE_ENV === 'development';
140
-
141
- return (
142
- <div>
143
- <h1>My App</h1>
144
-
145
- {/* Only show DQM in development */}
146
- {isDevelopment && (
147
- <DQMSidebar
148
- open={sidebarOpen}
149
- onClose={() => setSidebarOpen(false)}
150
- onOpen={() => setSidebarOpen(true)}
151
- />
152
- )}
153
- </div>
154
- );
155
- }
156
- ```
157
-
158
- ## With Custom Button Trigger
159
-
160
- ```tsx
161
- import React, { useState } from 'react';
162
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
163
- import { Button } from '@mui/material';
164
- import { Assessment } from '@mui/icons-material';
165
-
166
- function App() {
167
- const [sidebarOpen, setSidebarOpen] = useState(false);
168
-
169
- return (
170
- <div>
171
- <header>
172
- <Button
173
- variant="outlined"
174
- startIcon={<Assessment />}
175
- onClick={() => setSidebarOpen(true)}
176
- >
177
- Quality Check
178
- </Button>
179
- </header>
180
-
181
- <main>
182
- <h1>Content</h1>
183
- </main>
184
-
185
- <DQMSidebar
186
- open={sidebarOpen}
187
- onClose={() => setSidebarOpen(false)}
188
- onOpen={() => setSidebarOpen(true)}
189
- />
190
- </div>
191
- );
192
- }
193
- ```
194
-
195
- ## With Overlay/Toolbar Configuration
196
-
197
- Use `overlayConfig` to offset the sidebar when toolbars or overlays are present.
198
-
199
- ### Auto-Detection (Toolbar Selector)
200
-
201
- ```tsx
202
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
203
-
204
- function App() {
205
- const [sidebarOpen, setSidebarOpen] = useState(false);
206
-
207
- return (
208
- <DQMSidebar
209
- open={sidebarOpen}
210
- onClose={() => setSidebarOpen(false)}
211
- onOpen={() => setSidebarOpen(true)}
212
- config={{
213
- overlayConfig: {
214
- // Example toolbar anchored to the top edge
215
- selector: '.preview-toolbar',
216
- validateIframe: false
217
- }
218
- }}
219
- />
220
- );
221
- }
222
- ```
223
- ### Auto-Detection (Custom Selector)
224
-
225
- ```tsx
226
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
227
-
228
- function App() {
229
- const [open, setOpen] = useState(false);
230
-
231
- return (
232
- <DQMSidebar
233
- open={open}
234
- onClose={() => setOpen(false)}
235
- onOpen={() => setOpen(true)}
236
- config={{
237
- overlayConfig: {
238
- selector: 'iframe#my-overlay',
239
- }
240
- }}
241
- />
242
- );
243
- }
244
- ```
245
-
246
- ### Custom Selector
247
-
248
- ```tsx
249
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
250
-
251
- function App() {
252
- const [open, setOpen] = useState(false);
253
-
254
- return (
255
- <DQMSidebar
256
- open={open}
257
- onClose={() => setOpen(false)}
258
- onOpen={() => setOpen(true)}
259
- config={{
260
- overlayConfig: {
261
- // Custom selector for your admin toolbar
262
- selector: '.admin-toolbar-header',
263
- // Disable iFrame validation for non-iFrame elements
264
- validateIframe: false,
265
- }
266
- }}
267
- />
268
- );
269
- }
270
- ```
271
-
272
- ### Manual Offset (for Cross-Origin iFrames)
273
-
274
- When the overlay is a cross-origin iFrame that fills the entire screen but has
275
- a smaller internal toolbar, auto-detection won't work. Use manual offset:
276
-
277
- ```tsx
278
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
279
-
280
- function App() {
281
- const [open, setOpen] = useState(false);
282
-
283
- return (
284
- <DQMSidebar
285
- open={open}
286
- onClose={() => setOpen(false)}
287
- onOpen={() => setOpen(true)}
288
- config={{
289
- overlayConfig: {
290
- // Manual offset: 50px from the top
291
- manualOffset: {
292
- position: 'top',
293
- pixels: 50
294
- }
295
- }
296
- }}
297
- />
298
- );
299
- }
300
- ```
301
-
302
- ### Disable Overlay Detection
303
-
304
- ```tsx
305
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
306
-
307
- function App() {
308
- const [open, setOpen] = useState(false);
309
-
310
- return (
311
- <DQMSidebar
312
- open={open}
313
- onClose={() => setOpen(false)}
314
- onOpen={() => setOpen(true)}
315
- config={{
316
- overlayConfig: {
317
- // Disable all overlay detection
318
- selector: null
319
- }
320
- }}
321
- />
322
- );
323
- }
324
- ```
325
-
326
- ### Disable Logout Button
327
-
328
- ```tsx
329
- import { DQMSidebar } from '@crownpeak/dqm-react-component';
330
-
331
- function App() {
332
- const [open, setOpen] = useState(false);
333
-
334
- return (
335
- <DQMSidebar
336
- open={open}
337
- onClose={() => setOpen(false)}
338
- onOpen={() => setOpen(true)}
339
- config={{
340
- // Host app controls session lifecycle; hide logout control in the sidebar
341
- disableLogout: true,
342
- }}
343
- />
344
- );
345
- }
346
- ```
347
-
348
- ### Advanced: Using the Hook Directly
349
-
350
- For custom UI components that need overlay information:
351
-
352
- ```tsx
353
- import { useOverlayResistant } from '@crownpeak/dqm-react-component';
354
- import type { OverlayInfo } from '@crownpeak/dqm-react-component';
355
-
356
- function MyFloatingButton() {
357
- const overlay: OverlayInfo = useOverlayResistant({
358
- selector: '...',
359
- validateIframe: true,
360
- pollMs: 1000,
361
- });
362
-
363
- return (
364
- <button
365
- style={{
366
- position: 'fixed',
367
- top: overlay.present
368
- ? `${overlay.contentOffset.top + 16}px`
369
- : '16px',
370
- right: '16px',
371
- zIndex: 9999,
372
- }}
373
- >
374
- {overlay.present
375
- ? `Toolbar at ${overlay.position} (${overlay.height}px)`
376
- : 'No toolbar detected'}
377
- </button>
378
- );
379
- }
380
- ```
381
-
package/QUICKSTART.md DELETED
@@ -1,207 +0,0 @@
1
- # 🚀 Quick Start Guide
2
-
3
- ## Installation
4
-
5
- ```bash
6
- npm install
7
- ```
8
-
9
- ## Build
10
-
11
- ```bash
12
- npm run build
13
- ```
14
-
15
- ### Build widget only (for standalone script usage)
16
-
17
- ```bash
18
- npm run build:widget
19
- npm run serve:widget # preview demos at http://localhost:4173/test/demo-iife.html etc.
20
- ```
21
-
22
- ## Start Development
23
-
24
- ```bash
25
- npm run dev
26
- ```
27
-
28
- This starts:
29
- - ✅ **Frontend**: http://localhost:5173 (Vite Dev Server)
30
- - ✅ **Backend**: http://localhost:3001 (Express API)
31
-
32
- ## Test the Integration
33
-
34
- ### 1. Open Frontend
35
- Navigate to http://localhost:5173
36
-
37
- ### 2. Configure Backend Mode
38
- The test harness is already configured to use the backend:
39
-
40
- ```tsx
41
- config={{
42
- authBackendUrl: 'http://localhost:3001',
43
- useLocalStorage: true,
44
- }}
45
- ```
46
-
47
- ### 3. Login with Credentials
48
- - Enter your Crownpeak DQM API Key
49
- - Enter your Website ID
50
- - Click "Continue"
51
-
52
- The backend will:
53
- 1. Validate credentials with Crownpeak DQM API
54
- 2. Issue a session token
55
- 3. Store token in localStorage
56
-
57
- ### 4. Analyze HTML
58
- - Paste HTML in the editor
59
- - Click "Start Analysis"
60
- - All requests go through `http://localhost:3001/dqm/*`
61
-
62
- ## Architecture
63
-
64
- ```mermaid
65
- graph LR
66
- A[React App<br/>Port 5173]
67
- B[Express API<br/>Port 3001]
68
- C[Crownpeak DQM<br/>API]
69
-
70
- A -->|HTTP Requests| B
71
- B -->|Proxied Requests| C
72
-
73
- A -.->|sessionToken<br/>localStorage| A
74
- B -.->|apiKey + websiteId<br/>in-memory · Redis-ready| B
75
-
76
- subgraph Frontend
77
- A
78
- A1[DQMSidebar]
79
- A2[Login UI]
80
- A3[HTML Editor]
81
- end
82
-
83
- subgraph Backend
84
- B
85
- B1[Auth Routes]
86
- B2[DQM Proxy]
87
- B3[Sessions]
88
- end
89
-
90
- subgraph External
91
- C
92
- C1[Analysis]
93
- C2[Highlights]
94
- C3[Checkpoints]
95
- end
96
- ```
97
-
98
- ## Two Authentication Modes
99
-
100
- ### Backend Mode (Production)
101
- ```tsx
102
- config={{
103
- authBackendUrl: 'http://localhost:3001',
104
- }}
105
- ```
106
- - ✅ Secure session tokens
107
- - ✅ API keys never exposed to client
108
- - ✅ Centralized access control
109
-
110
- ### Direct Mode (Development)
111
- ```tsx
112
- config={{
113
- apiKey: 'YOUR_API_KEY',
114
- websiteId: 'YOUR_WEBSITE_ID',
115
- }}
116
- ```
117
- - ✅ No backend required
118
- - ✅ Quick testing
119
- - ✅ Props or localStorage
120
-
121
- ## API Endpoints
122
-
123
- ### Authentication
124
- - `POST /auth/login` - Login with credentials
125
- - `POST /auth/logout` - Invalidate session
126
- - `GET /auth/session` - Get session info
127
-
128
- ### DQM Proxy
129
- - `POST /dqm/assets` - Start analysis
130
- - `GET /dqm/assets/:id` - Get results
131
- - `GET /dqm/assets/:id/pagehighlight/all` - All highlights
132
- - `GET /dqm/assets/:id/pagehighlight/:cpId` - Single highlight
133
-
134
- All DQM endpoints require `Authorization: Bearer <sessionToken>`
135
-
136
- ## Scripts
137
-
138
- ```bash
139
- # Development
140
- npm run dev # Start both servers
141
- npm run dev:client # Frontend only
142
- npm run dev:server # Backend only
143
-
144
- # Build
145
- npm run build # Build all
146
- npm run build:lib # Build React library
147
- npm run build:server # Build Express server
148
-
149
- # Production
150
- npm run start:server # Run built server
151
- ```
152
-
153
- ## Environment Setup
154
-
155
- Copy `.env.example` to `.env`:
156
-
157
- ```env
158
- PORT=3001
159
- CORS_ORIGINS=http://localhost:5173
160
- DQM_API_BASE_URL=https://api.crownpeak.net/dqm-cms/v1
161
- JWT_SECRET=your-secret-key
162
- ```
163
-
164
- ## Documentation
165
-
166
- - **[BACKEND-API.md](./BACKEND-API.md)** - Backend API specification
167
- - **[DEVELOPMENT.md](./DEVELOPMENT.md)** - Development guide
168
- - **[server/README.md](./server/README.md)** - Server documentation
169
- - **[AUTHENTICATION.md](./AUTHENTICATION.md)** - Auth flow details
170
- - **[EXAMPLES.md](./EXAMPLES.md)** - Integration examples
171
-
172
- ## Testing
173
-
174
- ### Test Backend Health
175
- ```bash
176
- curl http://localhost:3001/health
177
- ```
178
-
179
- ### Test Login
180
- ```bash
181
- curl -X POST http://localhost:3001/auth/login \
182
- -H "Content-Type: application/json" \
183
- -d '{"apiKey":"YOUR_KEY","websiteId":"YOUR_ID"}'
184
- ```
185
-
186
- ### Test Analysis
187
- ```bash
188
- curl -X POST http://localhost:3001/dqm/assets \
189
- -H "Authorization: Bearer YOUR_TOKEN" \
190
- -H "Content-Type: application/json" \
191
- -d '{"html":"<html><body>Test</body></html>"}'
192
- ```
193
-
194
- ## Features
195
-
196
- ✅ **Modular Backend** - Express.js with clean architecture
197
- ✅ **Session Management** - In-memory store (Redis-ready)
198
- ✅ **DQM API Proxy** - All analysis endpoints
199
- ✅ **CORS & Security** - Helmet.js, CORS whitelist
200
- ✅ **Auto-reload** - TSX watch mode for development
201
- ✅ **Concurrent Servers** - Frontend + Backend in one command
202
- ✅ **TypeScript** - Full type safety
203
- ✅ **Error Handling** - Centralized middleware
204
-
205
- ## License
206
-
207
- MIT