github-issue-tower-defence-management 1.128.0 → 1.129.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.
Files changed (43) hide show
  1. package/.github/workflows/console-ui.yml +1 -1
  2. package/.github/workflows/empty-format-test-job.yml +1 -1
  3. package/.github/workflows/format.yml +1 -1
  4. package/.github/workflows/publish.yml +1 -1
  5. package/.github/workflows/test.yml +1 -1
  6. package/CHANGELOG.md +14 -0
  7. package/README.md +3 -3
  8. package/bin/adapter/entry-points/console/ui-dist/assets/index-Dr5qin37.js +103 -0
  9. package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
  10. package/bin/adapter/entry-points/console/webServer.js +56 -3
  11. package/bin/adapter/entry-points/console/webServer.js.map +1 -1
  12. package/bin/domain/entities/WorkflowStatus.js +6 -1
  13. package/bin/domain/entities/WorkflowStatus.js.map +1 -1
  14. package/bin/domain/usecases/console/GenerateConsoleListsUseCase.js +1 -0
  15. package/bin/domain/usecases/console/GenerateConsoleListsUseCase.js.map +1 -1
  16. package/package.json +3 -3
  17. package/src/adapter/entry-points/console/ui/src/features/console/components/content/ConsoleMarkdownContent.stories.tsx +1 -2
  18. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleCaches.ts +2 -4
  19. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleOperations.test.ts +7 -7
  20. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleOperations.ts +15 -18
  21. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleTabData.ts +2 -5
  22. package/src/adapter/entry-points/console/ui/src/features/console/lib/consoleApi.test.ts +22 -25
  23. package/src/adapter/entry-points/console/ui/src/features/console/lib/consoleApi.ts +12 -23
  24. package/src/adapter/entry-points/console/ui/src/features/console/lib/imageProxy.test.ts +7 -10
  25. package/src/adapter/entry-points/console/ui/src/features/console/lib/imageProxy.ts +2 -9
  26. package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsoleItemDetailContainer.tsx +2 -4
  27. package/src/adapter/entry-points/console/ui-dist/assets/index-Dr5qin37.js +103 -0
  28. package/src/adapter/entry-points/console/ui-dist/index.html +1 -1
  29. package/src/adapter/entry-points/console/webServer.test.ts +283 -6
  30. package/src/adapter/entry-points/console/webServer.ts +64 -0
  31. package/src/domain/entities/WorkflowStatus.ts +5 -0
  32. package/src/domain/usecases/SetupTowerDefenceProjectUseCase.test.ts +92 -2
  33. package/src/domain/usecases/console/GenerateConsoleListsUseCase.test.ts +2 -0
  34. package/src/domain/usecases/console/GenerateConsoleListsUseCase.ts +1 -0
  35. package/types/adapter/entry-points/console/webServer.d.ts +5 -1
  36. package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
  37. package/types/domain/entities/WorkflowStatus.d.ts +1 -0
  38. package/types/domain/entities/WorkflowStatus.d.ts.map +1 -1
  39. package/types/domain/usecases/console/GenerateConsoleListsUseCase.d.ts.map +1 -1
  40. package/bin/adapter/entry-points/console/ui-dist/assets/index-8H0HejYa.js +0 -103
  41. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleToken.test.ts +0 -41
  42. package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleToken.ts +0 -64
  43. package/src/adapter/entry-points/console/ui-dist/assets/index-8H0HejYa.js +0 -103
@@ -1,41 +0,0 @@
1
- import { act, renderHook } from '@testing-library/react';
2
- import { useConsoleToken } from './useConsoleToken';
3
-
4
- describe('useConsoleToken', () => {
5
- beforeEach(() => {
6
- localStorage.clear();
7
- window.history.replaceState({}, '', '/');
8
- });
9
-
10
- it('reads the token from the query string and appends it to data urls', () => {
11
- window.history.replaceState({}, '', '/?k=secret');
12
- const { result } = renderHook(() => useConsoleToken());
13
- expect(result.current.token).toBe('secret');
14
- expect(result.current.appendToken('./prs/list.json')).toBe(
15
- './prs/list.json?k=secret',
16
- );
17
- expect(result.current.appendToken('./api/itembody?url=x')).toBe(
18
- './api/itembody?url=x&k=secret',
19
- );
20
- });
21
-
22
- it('persists the token to localStorage', () => {
23
- window.history.replaceState({}, '', '/?k=persisted');
24
- renderHook(() => useConsoleToken());
25
- expect(localStorage.getItem('tdpm-console-token')).toBe('persisted');
26
- });
27
-
28
- it('reads a persisted token when no query token exists', () => {
29
- localStorage.setItem('tdpm-console-token', 'stored');
30
- const { result } = renderHook(() => useConsoleToken());
31
- expect(result.current.token).toBe('stored');
32
- });
33
-
34
- it('returns the url unchanged when there is no token', () => {
35
- const { result } = renderHook(() => useConsoleToken());
36
- act(() => {});
37
- expect(result.current.appendToken('./prs/list.json')).toBe(
38
- './prs/list.json',
39
- );
40
- });
41
- });
@@ -1,64 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
-
3
- const CONSOLE_TOKEN_STORAGE_KEY = 'tdpm-console-token';
4
-
5
- const readTokenFromLocation = (search: string): string | null => {
6
- const params = new URLSearchParams(search);
7
- const tokenFromQuery = params.get('k');
8
- if (tokenFromQuery !== null && tokenFromQuery !== '') {
9
- return tokenFromQuery;
10
- }
11
- return null;
12
- };
13
-
14
- const readPersistedToken = (): string | null => {
15
- if (typeof localStorage === 'undefined') {
16
- return null;
17
- }
18
- const persisted = localStorage.getItem(CONSOLE_TOKEN_STORAGE_KEY);
19
- return persisted !== null && persisted !== '' ? persisted : null;
20
- };
21
-
22
- export type ConsoleTokenState = {
23
- token: string | null;
24
- appendToken: (dataUrl: string) => string;
25
- };
26
-
27
- export const useConsoleToken = (): ConsoleTokenState => {
28
- const [token, setToken] = useState<string | null>(() => {
29
- const search = typeof window === 'undefined' ? '' : window.location.search;
30
- return readTokenFromLocation(search) ?? readPersistedToken();
31
- });
32
-
33
- useEffect(() => {
34
- if (token === null) {
35
- return;
36
- }
37
- if (typeof localStorage !== 'undefined') {
38
- localStorage.setItem(CONSOLE_TOKEN_STORAGE_KEY, token);
39
- }
40
- }, [token]);
41
-
42
- useEffect(() => {
43
- if (typeof window === 'undefined') {
44
- return;
45
- }
46
- const tokenFromQuery = readTokenFromLocation(window.location.search);
47
- if (tokenFromQuery !== null) {
48
- setToken(tokenFromQuery);
49
- }
50
- }, []);
51
-
52
- const appendToken = useCallback(
53
- (dataUrl: string): string => {
54
- if (token === null) {
55
- return dataUrl;
56
- }
57
- const separator = dataUrl.includes('?') ? '&' : '?';
58
- return `${dataUrl}${separator}k=${encodeURIComponent(token)}`;
59
- },
60
- [token],
61
- );
62
-
63
- return { token, appendToken };
64
- };