@kapeta/local-cluster-service 0.63.0 → 0.63.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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/src/storm/UIServer.d.ts +7 -0
- package/dist/cjs/src/storm/UIServer.js +8 -3
- package/dist/cjs/src/storm/routes.js +1 -0
- package/dist/esm/src/storm/UIServer.d.ts +7 -0
- package/dist/esm/src/storm/UIServer.js +8 -3
- package/dist/esm/src/storm/routes.js +1 -0
- package/package.json +1 -1
- package/src/storm/UIServer.ts +17 -3
- package/src/storm/routes.ts +4 -19
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.63.1](https://github.com/kapetacom/local-cluster-service/compare/v0.63.0...v0.63.1) (2024-08-20)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* handle port conflict and hanging response on close ([#219](https://github.com/kapetacom/local-cluster-service/issues/219)) ([e4f3b26](https://github.com/kapetacom/local-cluster-service/commit/e4f3b268fec9958aa315a186a306d2350354452b))
|
7
|
+
|
1
8
|
# [0.63.0](https://github.com/kapetacom/local-cluster-service/compare/v0.62.2...v0.63.0) (2024-08-15)
|
2
9
|
|
3
10
|
|
@@ -1,4 +1,11 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { Server } from 'http';
|
1
3
|
import { StormEventPage } from './events';
|
4
|
+
declare module 'express-serve-static-core' {
|
5
|
+
interface Application {
|
6
|
+
listen(port: number, callback?: (err?: Error) => void): Server;
|
7
|
+
}
|
8
|
+
}
|
2
9
|
export declare class UIServer {
|
3
10
|
private readonly express;
|
4
11
|
private readonly systemId;
|
@@ -29,11 +29,16 @@ class UIServer {
|
|
29
29
|
window.sessionStorage.clear();
|
30
30
|
</script>`);
|
31
31
|
});
|
32
|
-
this.express.all('/*',
|
32
|
+
this.express.all('/*', (req, res) => {
|
33
33
|
(0, page_utils_1.readPageFromDisk)(this.systemId, req.params[0], req.method, res);
|
34
34
|
});
|
35
|
-
return new Promise((resolve) => {
|
36
|
-
this.server = this.express.listen(this.port, () => {
|
35
|
+
return new Promise((resolve, reject) => {
|
36
|
+
this.server = this.express.listen(this.port, (err) => {
|
37
|
+
if (err) {
|
38
|
+
console.error('Failed to start UI server', err);
|
39
|
+
reject(err);
|
40
|
+
return;
|
41
|
+
}
|
37
42
|
console.log(`UI Server started on port ${this.port}`);
|
38
43
|
resolve();
|
39
44
|
});
|
@@ -100,6 +100,7 @@ router.delete('/:handle/ui', async (req, res) => {
|
|
100
100
|
server.close();
|
101
101
|
delete UI_SERVERS[conversationId];
|
102
102
|
}
|
103
|
+
res.status(200).json({ status: 'ok' });
|
103
104
|
});
|
104
105
|
router.post('/:handle/ui/iterative', async (req, res) => {
|
105
106
|
const handle = req.params.handle;
|
@@ -1,4 +1,11 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { Server } from 'http';
|
1
3
|
import { StormEventPage } from './events';
|
4
|
+
declare module 'express-serve-static-core' {
|
5
|
+
interface Application {
|
6
|
+
listen(port: number, callback?: (err?: Error) => void): Server;
|
7
|
+
}
|
8
|
+
}
|
2
9
|
export declare class UIServer {
|
3
10
|
private readonly express;
|
4
11
|
private readonly systemId;
|
@@ -29,11 +29,16 @@ class UIServer {
|
|
29
29
|
window.sessionStorage.clear();
|
30
30
|
</script>`);
|
31
31
|
});
|
32
|
-
this.express.all('/*',
|
32
|
+
this.express.all('/*', (req, res) => {
|
33
33
|
(0, page_utils_1.readPageFromDisk)(this.systemId, req.params[0], req.method, res);
|
34
34
|
});
|
35
|
-
return new Promise((resolve) => {
|
36
|
-
this.server = this.express.listen(this.port, () => {
|
35
|
+
return new Promise((resolve, reject) => {
|
36
|
+
this.server = this.express.listen(this.port, (err) => {
|
37
|
+
if (err) {
|
38
|
+
console.error('Failed to start UI server', err);
|
39
|
+
reject(err);
|
40
|
+
return;
|
41
|
+
}
|
37
42
|
console.log(`UI Server started on port ${this.port}`);
|
38
43
|
resolve();
|
39
44
|
});
|
@@ -100,6 +100,7 @@ router.delete('/:handle/ui', async (req, res) => {
|
|
100
100
|
server.close();
|
101
101
|
delete UI_SERVERS[conversationId];
|
102
102
|
}
|
103
|
+
res.status(200).json({ status: 'ok' });
|
103
104
|
});
|
104
105
|
router.post('/:handle/ui/iterative', async (req, res) => {
|
105
106
|
const handle = req.params.handle;
|
package/package.json
CHANGED
package/src/storm/UIServer.ts
CHANGED
@@ -8,6 +8,15 @@ import { clusterService } from '../clusterService';
|
|
8
8
|
import { Server } from 'http';
|
9
9
|
import { StormEventPage } from './events';
|
10
10
|
|
11
|
+
declare module 'express-serve-static-core' {
|
12
|
+
interface Application {
|
13
|
+
// Adds error callback support
|
14
|
+
// From the docs:
|
15
|
+
// All the forms of Node’s http.Server.listen() method are in fact actually supported.
|
16
|
+
listen(port: number, callback?: (err?: Error) => void): Server;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
11
20
|
export class UIServer {
|
12
21
|
private readonly express: Express;
|
13
22
|
private readonly systemId: string;
|
@@ -33,12 +42,17 @@ export class UIServer {
|
|
33
42
|
);
|
34
43
|
});
|
35
44
|
|
36
|
-
this.express.all('/*',
|
45
|
+
this.express.all('/*', (req: Request, res: Response) => {
|
37
46
|
readPageFromDisk(this.systemId, req.params[0], req.method, res);
|
38
47
|
});
|
39
48
|
|
40
|
-
return new Promise<void>((resolve) => {
|
41
|
-
this.server = this.express.listen(this.port, () => {
|
49
|
+
return new Promise<void>((resolve, reject) => {
|
50
|
+
this.server = this.express.listen(this.port, (err) => {
|
51
|
+
if (err) {
|
52
|
+
console.error('Failed to start UI server', err);
|
53
|
+
reject(err);
|
54
|
+
return;
|
55
|
+
}
|
42
56
|
console.log(`UI Server started on port ${this.port}`);
|
43
57
|
resolve();
|
44
58
|
});
|
package/src/storm/routes.ts
CHANGED
@@ -13,15 +13,8 @@ import { stringBody } from '../middleware/stringBody';
|
|
13
13
|
import { KapetaBodyRequest } from '../types';
|
14
14
|
import { StormCodegenRequest, StormContextRequest, StormCreateBlockRequest, StormStream } from './stream';
|
15
15
|
|
16
|
-
import {
|
17
|
-
|
18
|
-
stormClient,
|
19
|
-
UIPagePrompt,
|
20
|
-
UIPageEditPrompt,
|
21
|
-
UIPageEditRequest,
|
22
|
-
UIPageSamplePrompt,
|
23
|
-
} from './stormClient';
|
24
|
-
import { Page, StormEvent, StormEventPage, StormEventPhaseType, UIShell, UserJourneyScreen } from './events';
|
16
|
+
import { ConversationIdHeader, stormClient, UIPagePrompt, UIPageEditPrompt, UIPageEditRequest } from './stormClient';
|
17
|
+
import { Page, StormEvent, StormEventPage, StormEventPhaseType, UserJourneyScreen } from './events';
|
25
18
|
|
26
19
|
import {
|
27
20
|
createPhaseEndEvent,
|
@@ -33,18 +26,9 @@ import {
|
|
33
26
|
import { StormCodegen } from './codegen';
|
34
27
|
import { assetManager } from '../assetManager';
|
35
28
|
import uuid from 'node-uuid';
|
36
|
-
import {
|
37
|
-
import {
|
38
|
-
readConversationFromFile,
|
39
|
-
readPageFromDisk,
|
40
|
-
readPageFromDiskAsString,
|
41
|
-
SystemIdHeader,
|
42
|
-
writeConversationToFile,
|
43
|
-
writePageToDisk,
|
44
|
-
} from './page-utils';
|
29
|
+
import { readPageFromDisk, readPageFromDiskAsString, SystemIdHeader, writePageToDisk } from './page-utils';
|
45
30
|
import { UIServer } from './UIServer';
|
46
31
|
import { PageQueue } from './PageGenerator';
|
47
|
-
import FSExtra from 'fs-extra';
|
48
32
|
|
49
33
|
const UI_SERVERS: { [key: string]: UIServer } = {};
|
50
34
|
const router = Router();
|
@@ -140,6 +124,7 @@ router.delete('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
|
|
140
124
|
server.close();
|
141
125
|
delete UI_SERVERS[conversationId];
|
142
126
|
}
|
127
|
+
res.status(200).json({ status: 'ok' });
|
143
128
|
});
|
144
129
|
|
145
130
|
router.post('/:handle/ui/iterative', async (req: KapetaBodyRequest, res: Response) => {
|