@kapeta/local-cluster-service 0.71.1 → 0.71.3
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/CHANGELOG.md +15 -0
- package/dist/cjs/src/storm/PageGenerator.js +1 -1
- package/dist/cjs/src/storm/UIServer.js +26 -4
- package/dist/cjs/src/storm/routes.js +2 -1
- package/dist/esm/src/storm/PageGenerator.js +1 -1
- package/dist/esm/src/storm/UIServer.js +26 -4
- package/dist/esm/src/storm/routes.js +2 -1
- package/package.json +1 -1
- package/src/storm/PageGenerator.ts +1 -1
- package/src/storm/UIServer.ts +26 -4
- package/src/storm/routes.ts +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.71.3](https://github.com/kapetacom/local-cluster-service/compare/v0.71.2...v0.71.3) (2024-09-18)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Let client know the new reset url ([efabbaa](https://github.com/kapetacom/local-cluster-service/commit/efabbaa4ce9aaf38cc98d6b31383d09d03ad0e9d))
|
7
|
+
* Reset page can redirect ([7efbc06](https://github.com/kapetacom/local-cluster-service/commit/7efbc06710226c4edba277749e0a8909fc010219))
|
8
|
+
|
9
|
+
## [0.71.2](https://github.com/kapetacom/local-cluster-service/compare/v0.71.1...v0.71.2) (2024-09-18)
|
10
|
+
|
11
|
+
|
12
|
+
### Bug Fixes
|
13
|
+
|
14
|
+
* send initial screen errors too ([#253](https://github.com/kapetacom/local-cluster-service/issues/253)) ([386dabb](https://github.com/kapetacom/local-cluster-service/commit/386dabb0acb07384691242ecf4cc3081e0d04a05))
|
15
|
+
|
1
16
|
## [0.71.1](https://github.com/kapetacom/local-cluster-service/compare/v0.71.0...v0.71.1) (2024-09-17)
|
2
17
|
|
3
18
|
|
@@ -268,7 +268,7 @@ class PageQueue extends node_events_1.EventEmitter {
|
|
268
268
|
});
|
269
269
|
await screenStream.waitForDone();
|
270
270
|
if (!pageEvent) {
|
271
|
-
throw new Error('No page was generated');
|
271
|
+
throw new Error('No page was generated for ' + prompt.name);
|
272
272
|
}
|
273
273
|
await this.processPageEventWithReferences(pageEvent);
|
274
274
|
}
|
@@ -29,11 +29,33 @@ class UIServer {
|
|
29
29
|
async start() {
|
30
30
|
const app = (0, express_1.default)();
|
31
31
|
app.get('/_reset', (req, res) => {
|
32
|
+
/**
|
33
|
+
* Reset page clears local storage and session storage. If a redirect path is provided,
|
34
|
+
* it will redirect to that path.
|
35
|
+
*/
|
32
36
|
res.send(`
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
<html><head>
|
38
|
+
<script>
|
39
|
+
window.localStorage.clear();
|
40
|
+
window.sessionStorage.clear();
|
41
|
+
|
42
|
+
function isValidURL(url) {
|
43
|
+
try {
|
44
|
+
const parsedURL = new URL(url, window.location.origin);
|
45
|
+
return ['http:', 'https:'].includes(parsedURL.protocol);
|
46
|
+
} catch (e) {
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
const params = new URLSearchParams(window.location.search);
|
52
|
+
const redirect_path = params.get('redirect_path');
|
53
|
+
|
54
|
+
if (redirect_path && isValidURL(redirect_path)) {
|
55
|
+
window.location.href = redirect_path;
|
56
|
+
}
|
57
|
+
</script>
|
58
|
+
</head><body></body></html>`);
|
37
59
|
});
|
38
60
|
// Make it possible to serve static assets
|
39
61
|
app.use(express_1.default.static((0, path_1.join)((0, page_utils_1.getSystemBaseDir)(this.systemId), 'public'), { fallthrough: true }));
|
@@ -66,7 +66,7 @@ router.post('/ui/serve/:systemId', async (req, res) => {
|
|
66
66
|
if (!svr.isRunning()) {
|
67
67
|
await UI_SERVERS[systemId].start();
|
68
68
|
}
|
69
|
-
res.status(200).send({ status: 'running', url: svr.getUrl() });
|
69
|
+
res.status(200).send({ status: 'running', url: svr.getUrl(), resetUrl: svr.resolveUrlFromPath('/_reset') });
|
70
70
|
});
|
71
71
|
router.post('/ui/create-system/:handle/:systemId', async (req, res) => {
|
72
72
|
const systemId = req.params.systemId;
|
@@ -394,6 +394,7 @@ router.post('/:handle/ui', async (req, res) => {
|
|
394
394
|
})
|
395
395
|
.catch((e) => {
|
396
396
|
console.error('Failed to generate page for screen %s', screen.name, e);
|
397
|
+
sendError(e, res);
|
397
398
|
});
|
398
399
|
}
|
399
400
|
if (userJourneysStream.isAborted()) {
|
@@ -268,7 +268,7 @@ class PageQueue extends node_events_1.EventEmitter {
|
|
268
268
|
});
|
269
269
|
await screenStream.waitForDone();
|
270
270
|
if (!pageEvent) {
|
271
|
-
throw new Error('No page was generated');
|
271
|
+
throw new Error('No page was generated for ' + prompt.name);
|
272
272
|
}
|
273
273
|
await this.processPageEventWithReferences(pageEvent);
|
274
274
|
}
|
@@ -29,11 +29,33 @@ class UIServer {
|
|
29
29
|
async start() {
|
30
30
|
const app = (0, express_1.default)();
|
31
31
|
app.get('/_reset', (req, res) => {
|
32
|
+
/**
|
33
|
+
* Reset page clears local storage and session storage. If a redirect path is provided,
|
34
|
+
* it will redirect to that path.
|
35
|
+
*/
|
32
36
|
res.send(`
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
<html><head>
|
38
|
+
<script>
|
39
|
+
window.localStorage.clear();
|
40
|
+
window.sessionStorage.clear();
|
41
|
+
|
42
|
+
function isValidURL(url) {
|
43
|
+
try {
|
44
|
+
const parsedURL = new URL(url, window.location.origin);
|
45
|
+
return ['http:', 'https:'].includes(parsedURL.protocol);
|
46
|
+
} catch (e) {
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
const params = new URLSearchParams(window.location.search);
|
52
|
+
const redirect_path = params.get('redirect_path');
|
53
|
+
|
54
|
+
if (redirect_path && isValidURL(redirect_path)) {
|
55
|
+
window.location.href = redirect_path;
|
56
|
+
}
|
57
|
+
</script>
|
58
|
+
</head><body></body></html>`);
|
37
59
|
});
|
38
60
|
// Make it possible to serve static assets
|
39
61
|
app.use(express_1.default.static((0, path_1.join)((0, page_utils_1.getSystemBaseDir)(this.systemId), 'public'), { fallthrough: true }));
|
@@ -66,7 +66,7 @@ router.post('/ui/serve/:systemId', async (req, res) => {
|
|
66
66
|
if (!svr.isRunning()) {
|
67
67
|
await UI_SERVERS[systemId].start();
|
68
68
|
}
|
69
|
-
res.status(200).send({ status: 'running', url: svr.getUrl() });
|
69
|
+
res.status(200).send({ status: 'running', url: svr.getUrl(), resetUrl: svr.resolveUrlFromPath('/_reset') });
|
70
70
|
});
|
71
71
|
router.post('/ui/create-system/:handle/:systemId', async (req, res) => {
|
72
72
|
const systemId = req.params.systemId;
|
@@ -394,6 +394,7 @@ router.post('/:handle/ui', async (req, res) => {
|
|
394
394
|
})
|
395
395
|
.catch((e) => {
|
396
396
|
console.error('Failed to generate page for screen %s', screen.name, e);
|
397
|
+
sendError(e, res);
|
397
398
|
});
|
398
399
|
}
|
399
400
|
if (userJourneysStream.isAborted()) {
|
package/package.json
CHANGED
@@ -300,7 +300,7 @@ export class PageQueue extends EventEmitter {
|
|
300
300
|
|
301
301
|
await screenStream.waitForDone();
|
302
302
|
if (!pageEvent) {
|
303
|
-
throw new Error('No page was generated');
|
303
|
+
throw new Error('No page was generated for ' + prompt.name);
|
304
304
|
}
|
305
305
|
await this.processPageEventWithReferences(pageEvent);
|
306
306
|
}
|
package/src/storm/UIServer.ts
CHANGED
@@ -30,12 +30,34 @@ export class UIServer {
|
|
30
30
|
public async start() {
|
31
31
|
const app = express();
|
32
32
|
app.get('/_reset', (req: Request, res: Response) => {
|
33
|
+
/**
|
34
|
+
* Reset page clears local storage and session storage. If a redirect path is provided,
|
35
|
+
* it will redirect to that path.
|
36
|
+
*/
|
33
37
|
res.send(
|
34
38
|
`
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
<html><head>
|
40
|
+
<script>
|
41
|
+
window.localStorage.clear();
|
42
|
+
window.sessionStorage.clear();
|
43
|
+
|
44
|
+
function isValidURL(url) {
|
45
|
+
try {
|
46
|
+
const parsedURL = new URL(url, window.location.origin);
|
47
|
+
return ['http:', 'https:'].includes(parsedURL.protocol);
|
48
|
+
} catch (e) {
|
49
|
+
return false;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
const params = new URLSearchParams(window.location.search);
|
54
|
+
const redirect_path = params.get('redirect_path');
|
55
|
+
|
56
|
+
if (redirect_path && isValidURL(redirect_path)) {
|
57
|
+
window.location.href = redirect_path;
|
58
|
+
}
|
59
|
+
</script>
|
60
|
+
</head><body></body></html>`
|
39
61
|
);
|
40
62
|
});
|
41
63
|
|
package/src/storm/routes.ts
CHANGED
@@ -97,7 +97,7 @@ router.post('/ui/serve/:systemId', async (req: KapetaBodyRequest, res: Response)
|
|
97
97
|
await UI_SERVERS[systemId].start();
|
98
98
|
}
|
99
99
|
|
100
|
-
res.status(200).send({ status: 'running', url: svr.getUrl() });
|
100
|
+
res.status(200).send({ status: 'running', url: svr.getUrl(), resetUrl: svr.resolveUrlFromPath('/_reset') });
|
101
101
|
});
|
102
102
|
|
103
103
|
router.post('/ui/create-system/:handle/:systemId', async (req: KapetaBodyRequest, res: Response) => {
|
@@ -497,6 +497,7 @@ router.post('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
|
|
497
497
|
})
|
498
498
|
.catch((e) => {
|
499
499
|
console.error('Failed to generate page for screen %s', screen.name, e);
|
500
|
+
sendError(e as any, res);
|
500
501
|
});
|
501
502
|
}
|
502
503
|
|