@kapeta/local-cluster-service 0.62.2 → 0.63.0

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 CHANGED
@@ -1,3 +1,10 @@
1
+ # [0.63.0](https://github.com/kapetacom/local-cluster-service/compare/v0.62.2...v0.63.0) (2024-08-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add reset endpoint for resetting localStorage in UI server ([#218](https://github.com/kapetacom/local-cluster-service/issues/218)) ([1dd1edc](https://github.com/kapetacom/local-cluster-service/commit/1dd1edcba982f40b853569fd408e6ed561495686))
7
+
1
8
  ## [0.62.2](https://github.com/kapetacom/local-cluster-service/compare/v0.62.1...v0.62.2) (2024-08-14)
2
9
 
3
10
 
@@ -8,4 +8,5 @@ export declare class UIServer {
8
8
  start(): Promise<void>;
9
9
  close(): void;
10
10
  resolveUrl(screenData: StormEventPage): string;
11
+ resolveUrlFromPath(path: string): string;
11
12
  }
@@ -22,6 +22,13 @@ class UIServer {
22
22
  }
23
23
  async start() {
24
24
  this.port = await clusterService_1.clusterService.getNextAvailablePort(this.port);
25
+ this.express.get('/_reset', (req, res) => {
26
+ res.send(`
27
+ <script>
28
+ window.localStorage.clear();
29
+ window.sessionStorage.clear();
30
+ </script>`);
31
+ });
25
32
  this.express.all('/*', async (req, res) => {
26
33
  (0, page_utils_1.readPageFromDisk)(this.systemId, req.params[0], req.method, res);
27
34
  });
@@ -40,8 +47,11 @@ class UIServer {
40
47
  }
41
48
  }
42
49
  resolveUrl(screenData) {
43
- const path = screenData.payload.path.startsWith('/') ? screenData.payload.path : `/${screenData.payload.path}`;
44
- return `http://localhost:${this.port}${path}`;
50
+ return this.resolveUrlFromPath(screenData.payload.path);
51
+ }
52
+ resolveUrlFromPath(path) {
53
+ const resolvedPath = path.startsWith('/') ? path : `/${path}`;
54
+ return `http://localhost:${this.port}${resolvedPath}`;
45
55
  }
46
56
  }
47
57
  exports.UIServer = UIServer;
@@ -375,5 +375,14 @@ export interface StormEventReferenceClassification {
375
375
  created: number;
376
376
  payload: ReferenceClassification;
377
377
  }
378
- export type StormEvent = StormEventCreateBlock | StormEventCreateConnection | StormEventCreatePlanProperties | StormEventInvalidResponse | StormEventPlanRetry | StormEventCreateDSL | StormEventCreateDSLResource | StormEventError | StormEventScreen | StormEventScreenCandidate | StormEventFileLogical | StormEventFileState | StormEventFileDone | StormEventFileFailed | StormEventFileChunk | StormEventDone | StormEventDefinitionChange | StormEventErrorClassifier | StormEventCodeFix | StormEventErrorDetails | StormEventBlockReady | StormEventPhases | StormEventBlockStatus | StormEventCreateDSLRetry | StormEventUserJourney | StormEventUIShell | StormEventPage | StormEventPageUrl | StormEventPromptImprove | StormEventLandingPage | StormEventReferenceClassification | StormEventApiBase;
378
+ export interface StormEventUIStarted {
379
+ type: 'UI_SERVER_STARTED';
380
+ reason: string;
381
+ created: number;
382
+ payload: {
383
+ conversationId: string;
384
+ resetUrl: string;
385
+ };
386
+ }
387
+ export type StormEvent = StormEventCreateBlock | StormEventCreateConnection | StormEventCreatePlanProperties | StormEventInvalidResponse | StormEventPlanRetry | StormEventCreateDSL | StormEventCreateDSLResource | StormEventError | StormEventScreen | StormEventScreenCandidate | StormEventFileLogical | StormEventFileState | StormEventFileDone | StormEventFileFailed | StormEventFileChunk | StormEventDone | StormEventDefinitionChange | StormEventErrorClassifier | StormEventCodeFix | StormEventErrorDetails | StormEventBlockReady | StormEventPhases | StormEventBlockStatus | StormEventCreateDSLRetry | StormEventUserJourney | StormEventUIShell | StormEventPage | StormEventPageUrl | StormEventPromptImprove | StormEventLandingPage | StormEventReferenceClassification | StormEventApiBase | StormEventUIStarted;
379
388
  export {};
@@ -247,6 +247,15 @@ router.post('/:handle/ui', async (req, res) => {
247
247
  await waitForStormStream(shellsStream);
248
248
  UI_SERVERS[outerConversationId] = new UIServer_1.UIServer(outerConversationId);
249
249
  await UI_SERVERS[outerConversationId].start();
250
+ sendEvent(res, {
251
+ type: 'UI_SERVER_STARTED',
252
+ reason: '',
253
+ payload: {
254
+ conversationId: outerConversationId,
255
+ resetUrl: UI_SERVERS[outerConversationId].resolveUrlFromPath('/_reset'),
256
+ },
257
+ created: Date.now(),
258
+ });
250
259
  // Get the pages (5 at a time)
251
260
  const pagePromises = [];
252
261
  onRequestAborted(req, res, () => {
@@ -8,4 +8,5 @@ export declare class UIServer {
8
8
  start(): Promise<void>;
9
9
  close(): void;
10
10
  resolveUrl(screenData: StormEventPage): string;
11
+ resolveUrlFromPath(path: string): string;
11
12
  }
@@ -22,6 +22,13 @@ class UIServer {
22
22
  }
23
23
  async start() {
24
24
  this.port = await clusterService_1.clusterService.getNextAvailablePort(this.port);
25
+ this.express.get('/_reset', (req, res) => {
26
+ res.send(`
27
+ <script>
28
+ window.localStorage.clear();
29
+ window.sessionStorage.clear();
30
+ </script>`);
31
+ });
25
32
  this.express.all('/*', async (req, res) => {
26
33
  (0, page_utils_1.readPageFromDisk)(this.systemId, req.params[0], req.method, res);
27
34
  });
@@ -40,8 +47,11 @@ class UIServer {
40
47
  }
41
48
  }
42
49
  resolveUrl(screenData) {
43
- const path = screenData.payload.path.startsWith('/') ? screenData.payload.path : `/${screenData.payload.path}`;
44
- return `http://localhost:${this.port}${path}`;
50
+ return this.resolveUrlFromPath(screenData.payload.path);
51
+ }
52
+ resolveUrlFromPath(path) {
53
+ const resolvedPath = path.startsWith('/') ? path : `/${path}`;
54
+ return `http://localhost:${this.port}${resolvedPath}`;
45
55
  }
46
56
  }
47
57
  exports.UIServer = UIServer;
@@ -375,5 +375,14 @@ export interface StormEventReferenceClassification {
375
375
  created: number;
376
376
  payload: ReferenceClassification;
377
377
  }
378
- export type StormEvent = StormEventCreateBlock | StormEventCreateConnection | StormEventCreatePlanProperties | StormEventInvalidResponse | StormEventPlanRetry | StormEventCreateDSL | StormEventCreateDSLResource | StormEventError | StormEventScreen | StormEventScreenCandidate | StormEventFileLogical | StormEventFileState | StormEventFileDone | StormEventFileFailed | StormEventFileChunk | StormEventDone | StormEventDefinitionChange | StormEventErrorClassifier | StormEventCodeFix | StormEventErrorDetails | StormEventBlockReady | StormEventPhases | StormEventBlockStatus | StormEventCreateDSLRetry | StormEventUserJourney | StormEventUIShell | StormEventPage | StormEventPageUrl | StormEventPromptImprove | StormEventLandingPage | StormEventReferenceClassification | StormEventApiBase;
378
+ export interface StormEventUIStarted {
379
+ type: 'UI_SERVER_STARTED';
380
+ reason: string;
381
+ created: number;
382
+ payload: {
383
+ conversationId: string;
384
+ resetUrl: string;
385
+ };
386
+ }
387
+ export type StormEvent = StormEventCreateBlock | StormEventCreateConnection | StormEventCreatePlanProperties | StormEventInvalidResponse | StormEventPlanRetry | StormEventCreateDSL | StormEventCreateDSLResource | StormEventError | StormEventScreen | StormEventScreenCandidate | StormEventFileLogical | StormEventFileState | StormEventFileDone | StormEventFileFailed | StormEventFileChunk | StormEventDone | StormEventDefinitionChange | StormEventErrorClassifier | StormEventCodeFix | StormEventErrorDetails | StormEventBlockReady | StormEventPhases | StormEventBlockStatus | StormEventCreateDSLRetry | StormEventUserJourney | StormEventUIShell | StormEventPage | StormEventPageUrl | StormEventPromptImprove | StormEventLandingPage | StormEventReferenceClassification | StormEventApiBase | StormEventUIStarted;
379
388
  export {};
@@ -247,6 +247,15 @@ router.post('/:handle/ui', async (req, res) => {
247
247
  await waitForStormStream(shellsStream);
248
248
  UI_SERVERS[outerConversationId] = new UIServer_1.UIServer(outerConversationId);
249
249
  await UI_SERVERS[outerConversationId].start();
250
+ sendEvent(res, {
251
+ type: 'UI_SERVER_STARTED',
252
+ reason: '',
253
+ payload: {
254
+ conversationId: outerConversationId,
255
+ resetUrl: UI_SERVERS[outerConversationId].resolveUrlFromPath('/_reset'),
256
+ },
257
+ created: Date.now(),
258
+ });
250
259
  // Get the pages (5 at a time)
251
260
  const pagePromises = [];
252
261
  onRequestAborted(req, res, () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.62.2",
3
+ "version": "0.63.0",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -23,6 +23,16 @@ export class UIServer {
23
23
  public async start() {
24
24
  this.port = await clusterService.getNextAvailablePort(this.port);
25
25
 
26
+ this.express.get('/_reset', (req: Request, res: Response) => {
27
+ res.send(
28
+ `
29
+ <script>
30
+ window.localStorage.clear();
31
+ window.sessionStorage.clear();
32
+ </script>`
33
+ );
34
+ });
35
+
26
36
  this.express.all('/*', async (req: Request, res: Response) => {
27
37
  readPageFromDisk(this.systemId, req.params[0], req.method, res);
28
38
  });
@@ -44,7 +54,11 @@ export class UIServer {
44
54
  }
45
55
 
46
56
  resolveUrl(screenData: StormEventPage) {
47
- const path = screenData.payload.path.startsWith('/') ? screenData.payload.path : `/${screenData.payload.path}`;
48
- return `http://localhost:${this.port}${path}`;
57
+ return this.resolveUrlFromPath(screenData.payload.path);
58
+ }
59
+
60
+ resolveUrlFromPath(path: string) {
61
+ const resolvedPath = path.startsWith('/') ? path : `/${path}`;
62
+ return `http://localhost:${this.port}${resolvedPath}`;
49
63
  }
50
64
  }
@@ -264,7 +264,13 @@ export interface StormEventFileChunk extends StormEventFileBase {
264
264
  }
265
265
 
266
266
  export interface StormEventApiBase {
267
- type: 'API_STREAM_CHUNK' | 'API_STREAM_DONE' | 'API_STREAM_FAILED' | 'API_STREAM_STATE' | 'API_STREAM_START' | 'API_STREAM_CHUNK_RESET';
267
+ type:
268
+ | 'API_STREAM_CHUNK'
269
+ | 'API_STREAM_DONE'
270
+ | 'API_STREAM_FAILED'
271
+ | 'API_STREAM_STATE'
272
+ | 'API_STREAM_START'
273
+ | 'API_STREAM_CHUNK_RESET';
268
274
  payload: StormEventFileBasePayload;
269
275
  }
270
276
 
@@ -445,6 +451,16 @@ export interface StormEventReferenceClassification {
445
451
  payload: ReferenceClassification;
446
452
  }
447
453
 
454
+ export interface StormEventUIStarted {
455
+ type: 'UI_SERVER_STARTED';
456
+ reason: string;
457
+ created: number;
458
+ payload: {
459
+ conversationId: string;
460
+ resetUrl: string;
461
+ };
462
+ }
463
+
448
464
  export type StormEvent =
449
465
  | StormEventCreateBlock
450
466
  | StormEventCreateConnection
@@ -477,4 +493,5 @@ export type StormEvent =
477
493
  | StormEventPromptImprove
478
494
  | StormEventLandingPage
479
495
  | StormEventReferenceClassification
480
- | StormEventApiBase;
496
+ | StormEventApiBase
497
+ | StormEventUIStarted;
@@ -325,6 +325,16 @@ router.post('/:handle/ui', async (req: KapetaBodyRequest, res: Response) => {
325
325
  UI_SERVERS[outerConversationId] = new UIServer(outerConversationId);
326
326
  await UI_SERVERS[outerConversationId].start();
327
327
 
328
+ sendEvent(res, {
329
+ type: 'UI_SERVER_STARTED',
330
+ reason: '',
331
+ payload: {
332
+ conversationId: outerConversationId,
333
+ resetUrl: UI_SERVERS[outerConversationId].resolveUrlFromPath('/_reset'),
334
+ },
335
+ created: Date.now(),
336
+ });
337
+
328
338
  // Get the pages (5 at a time)
329
339
 
330
340
  const pagePromises: Promise<void>[] = [];