@lon-ask/dockit 0.1.1 → 0.1.4

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 (140) hide show
  1. package/LICENSE +21 -674
  2. package/README.md +618 -328
  3. package/SKILL.md +61 -110
  4. package/apps/client/dist/assets/{index-CqOXxsEZ.js → index-DzadxeQH.js} +2 -2
  5. package/apps/client/dist/index.html +1 -1
  6. package/apps/client/index.html +12 -0
  7. package/apps/client/package.json +26 -0
  8. package/apps/client/src/App.tsx +18 -0
  9. package/apps/client/src/api/client.ts +54 -0
  10. package/apps/client/src/components/BuildPanel.tsx +77 -0
  11. package/apps/client/src/components/DocViewer.tsx +76 -0
  12. package/apps/client/src/components/EntryDetail.tsx +322 -0
  13. package/apps/client/src/components/EntryForm.tsx +117 -0
  14. package/apps/client/src/components/EntryList.tsx +165 -0
  15. package/apps/client/src/components/GlobalSearchBar.tsx +166 -0
  16. package/apps/client/src/components/Layout.tsx +57 -0
  17. package/apps/client/src/components/SearchBar.tsx +103 -0
  18. package/apps/client/src/components/SourceForm.tsx +497 -0
  19. package/apps/client/src/hooks/useTheme.ts +19 -0
  20. package/apps/client/src/index.css +77 -0
  21. package/apps/client/src/main.tsx +13 -0
  22. package/apps/client/src/types.ts +105 -0
  23. package/apps/client/vite.config.ts +13 -0
  24. package/apps/server/dist/core/domain/entry.js +20 -0
  25. package/apps/server/dist/core/domain/entry.js.map +1 -0
  26. package/apps/server/dist/core/domain/errors.js +33 -0
  27. package/apps/server/dist/core/domain/errors.js.map +1 -0
  28. package/apps/server/dist/core/domain/knowledge-graph.js +2 -0
  29. package/apps/server/dist/core/domain/knowledge-graph.js.map +1 -0
  30. package/apps/server/dist/core/domain/types.js +2 -0
  31. package/apps/server/dist/core/domain/types.js.map +1 -0
  32. package/apps/server/dist/core/ports/IBuildRepository.js +2 -0
  33. package/apps/server/dist/core/ports/IBuildRepository.js.map +1 -0
  34. package/apps/server/dist/core/ports/IDocumentNormalizer.js +2 -0
  35. package/apps/server/dist/core/ports/IDocumentNormalizer.js.map +1 -0
  36. package/apps/server/dist/core/ports/IDocumentStore.js +2 -0
  37. package/apps/server/dist/core/ports/IDocumentStore.js.map +1 -0
  38. package/apps/server/dist/core/ports/IEntryReadModel.js +2 -0
  39. package/apps/server/dist/core/ports/IEntryReadModel.js.map +1 -0
  40. package/apps/server/dist/core/ports/IEntryRepository.js +2 -0
  41. package/apps/server/dist/core/ports/IEntryRepository.js.map +1 -0
  42. package/apps/server/dist/core/ports/IKnowledgeGraph.js +2 -0
  43. package/apps/server/dist/core/ports/IKnowledgeGraph.js.map +1 -0
  44. package/apps/server/dist/core/ports/IPathResolver.js +2 -0
  45. package/apps/server/dist/core/ports/IPathResolver.js.map +1 -0
  46. package/apps/server/dist/core/ports/ISearchEngine.js +2 -0
  47. package/apps/server/dist/core/ports/ISearchEngine.js.map +1 -0
  48. package/apps/server/dist/core/ports/ISourceProcessor.js +2 -0
  49. package/apps/server/dist/core/ports/ISourceProcessor.js.map +1 -0
  50. package/apps/server/dist/core/ports/ISourceRepository.js +2 -0
  51. package/apps/server/dist/core/ports/ISourceRepository.js.map +1 -0
  52. package/apps/server/dist/core/usecases/BuildUseCase.js +76 -0
  53. package/apps/server/dist/core/usecases/BuildUseCase.js.map +1 -0
  54. package/apps/server/dist/core/usecases/ConfigUseCase.js +62 -0
  55. package/apps/server/dist/core/usecases/ConfigUseCase.js.map +1 -0
  56. package/apps/server/dist/core/usecases/SearchUseCase.js +17 -0
  57. package/apps/server/dist/core/usecases/SearchUseCase.js.map +1 -0
  58. package/apps/server/dist/index.js +86 -0
  59. package/apps/server/dist/index.js.map +1 -0
  60. package/apps/server/dist/infrastructure/filesystem/FileSystemDocumentStore.js +25 -0
  61. package/apps/server/dist/infrastructure/filesystem/FileSystemDocumentStore.js.map +1 -0
  62. package/apps/server/dist/infrastructure/graph/GraphSearchDecorator.js +42 -0
  63. package/apps/server/dist/infrastructure/graph/GraphSearchDecorator.js.map +1 -0
  64. package/apps/server/dist/infrastructure/graph/GraphifyKnowledgeGraph.js +145 -0
  65. package/apps/server/dist/infrastructure/graph/GraphifyKnowledgeGraph.js.map +1 -0
  66. package/apps/server/dist/infrastructure/graph/index.js +3 -0
  67. package/apps/server/dist/infrastructure/graph/index.js.map +1 -0
  68. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteBuildRepository.js +21 -0
  69. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteBuildRepository.js.map +1 -0
  70. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryReadModel.js +11 -0
  71. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryReadModel.js.map +1 -0
  72. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryRepository.js +59 -0
  73. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteEntryRepository.js.map +1 -0
  74. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteSourceRepository.js +47 -0
  75. package/apps/server/dist/infrastructure/persistence/sqlite/SqliteSourceRepository.js.map +1 -0
  76. package/apps/server/dist/infrastructure/persistence/sqlite/connection.js +50 -0
  77. package/apps/server/dist/infrastructure/persistence/sqlite/connection.js.map +1 -0
  78. package/apps/server/dist/infrastructure/search/SearchEngineFactory.js +32 -0
  79. package/apps/server/dist/infrastructure/search/SearchEngineFactory.js.map +1 -0
  80. package/apps/server/dist/infrastructure/search/json/JsonSearchEngine.js +147 -0
  81. package/apps/server/dist/infrastructure/search/json/JsonSearchEngine.js.map +1 -0
  82. package/apps/server/dist/infrastructure/search/vector/EmbeddingService.js +23 -0
  83. package/apps/server/dist/infrastructure/search/vector/EmbeddingService.js.map +1 -0
  84. package/apps/server/dist/infrastructure/search/vector/VectorSearchEngine.js +378 -0
  85. package/apps/server/dist/infrastructure/search/vector/VectorSearchEngine.js.map +1 -0
  86. package/apps/server/dist/infrastructure/source-processors/AntoraSourceProcessor.js +11 -0
  87. package/apps/server/dist/infrastructure/source-processors/AntoraSourceProcessor.js.map +1 -0
  88. package/apps/server/dist/infrastructure/source-processors/AsciidocSourceProcessor.js +9 -0
  89. package/apps/server/dist/infrastructure/source-processors/AsciidocSourceProcessor.js.map +1 -0
  90. package/apps/server/dist/infrastructure/source-processors/DocumentNormalizer.js +11 -0
  91. package/apps/server/dist/infrastructure/source-processors/DocumentNormalizer.js.map +1 -0
  92. package/apps/server/dist/infrastructure/source-processors/GithubMarkdownSourceProcessor.js +9 -0
  93. package/apps/server/dist/infrastructure/source-processors/GithubMarkdownSourceProcessor.js.map +1 -0
  94. package/apps/server/dist/infrastructure/source-processors/MavenSourceProcessor.js +9 -0
  95. package/apps/server/dist/infrastructure/source-processors/MavenSourceProcessor.js.map +1 -0
  96. package/apps/server/dist/infrastructure/source-processors/PathResolver.js +5 -0
  97. package/apps/server/dist/infrastructure/source-processors/PathResolver.js.map +1 -0
  98. package/apps/server/dist/infrastructure/source-processors/SourceCodeSourceProcessor.js +269 -0
  99. package/apps/server/dist/infrastructure/source-processors/SourceCodeSourceProcessor.js.map +1 -0
  100. package/apps/server/dist/infrastructure/source-processors/ZipSourceProcessor.js +9 -0
  101. package/apps/server/dist/infrastructure/source-processors/ZipSourceProcessor.js.map +1 -0
  102. package/apps/server/dist/mcp-http.js +93 -0
  103. package/apps/server/dist/mcp-http.js.map +1 -0
  104. package/apps/server/dist/mcp.js +339 -0
  105. package/apps/server/dist/mcp.js.map +1 -0
  106. package/apps/server/dist/routes/build.js +89 -0
  107. package/apps/server/dist/routes/build.js.map +1 -0
  108. package/apps/server/dist/routes/entries.js +52 -0
  109. package/apps/server/dist/routes/entries.js.map +1 -0
  110. package/apps/server/dist/routes/graph.js +58 -0
  111. package/apps/server/dist/routes/graph.js.map +1 -0
  112. package/apps/server/dist/routes/search.js +24 -0
  113. package/apps/server/dist/routes/search.js.map +1 -0
  114. package/apps/server/dist/routes/sources.js +100 -0
  115. package/apps/server/dist/routes/sources.js.map +1 -0
  116. package/apps/server/dist/routes/viewer.js +22 -0
  117. package/apps/server/dist/routes/viewer.js.map +1 -0
  118. package/apps/server/dist/services/antora.js +222 -0
  119. package/apps/server/dist/services/antora.js.map +1 -0
  120. package/apps/server/dist/services/asciidoc.js +206 -0
  121. package/apps/server/dist/services/asciidoc.js.map +1 -0
  122. package/apps/server/dist/services/configLoader.js +150 -0
  123. package/apps/server/dist/services/configLoader.js.map +1 -0
  124. package/apps/server/dist/services/githubMarkdown.js +221 -0
  125. package/apps/server/dist/services/githubMarkdown.js.map +1 -0
  126. package/apps/server/dist/services/maven.js +148 -0
  127. package/apps/server/dist/services/maven.js.map +1 -0
  128. package/apps/server/dist/services/normalizer.js +42 -0
  129. package/apps/server/dist/services/normalizer.js.map +1 -0
  130. package/apps/server/dist/services/paths.js +5 -0
  131. package/apps/server/dist/services/paths.js.map +1 -0
  132. package/apps/server/dist/services/textExtractor.js +46 -0
  133. package/apps/server/dist/services/textExtractor.js.map +1 -0
  134. package/apps/server/dist/services/zip.js +63 -0
  135. package/apps/server/dist/services/zip.js.map +1 -0
  136. package/apps/server/package.json +38 -0
  137. package/apps/server/src/infrastructure/source-processors/SourceCodeSourceProcessor.ts +9 -2
  138. package/bin/commands/dev.ts +2 -2
  139. package/bin/commands/serve.ts +2 -2
  140. package/package.json +22 -4
@@ -0,0 +1,105 @@
1
+ export type EntryStatus = 'pending' | 'building' | 'ready' | 'error';
2
+ export type SourceType = 'zip' | 'antora' | 'maven' | 'asciidoc' | 'github-markdown' | 'source-code';
3
+ export type SourceStatus = 'pending' | 'building' | 'ready' | 'error';
4
+ export type BuildStatus = 'pending' | 'building' | 'ready' | 'error';
5
+
6
+ export interface Entry {
7
+ id: string;
8
+ name: string;
9
+ version: string;
10
+ description: string;
11
+ status: EntryStatus;
12
+ source_count?: number;
13
+ created_at: string;
14
+ updated_at: string;
15
+ }
16
+
17
+ export interface Source {
18
+ id: string;
19
+ entry_id: string;
20
+ type: SourceType;
21
+ label: string;
22
+ config: SourceConfig;
23
+ status: SourceStatus;
24
+ created_at: string;
25
+ }
26
+
27
+ export interface ZipSourceConfig {
28
+ url?: string;
29
+ localPath?: string;
30
+ }
31
+
32
+ export interface AntoraSourceConfig {
33
+ repoUrl?: string;
34
+ zipPath?: string;
35
+ localPath?: string;
36
+ playbookOverrides?: Record<string, unknown>;
37
+ graphifyEnabled?: boolean;
38
+ graphifySourcePath?: string;
39
+ }
40
+
41
+ export interface MavenSourceConfig {
42
+ groupId: string;
43
+ artifactId: string;
44
+ version: string;
45
+ classifier?: string;
46
+ useMavenCommand?: boolean;
47
+ localJar?: string;
48
+ }
49
+
50
+ export interface AsciidocSourceConfig {
51
+ repoUrl?: string;
52
+ zipPath?: string;
53
+ localPath?: string;
54
+ sourcePath?: string;
55
+ graphifyEnabled?: boolean;
56
+ graphifySourcePath?: string;
57
+ }
58
+
59
+ export interface GithubMarkdownSourceConfig {
60
+ repoUrl?: string;
61
+ localPath?: string;
62
+ sourcePath?: string;
63
+ branch?: string;
64
+ graphifyEnabled?: boolean;
65
+ graphifySourcePath?: string;
66
+ }
67
+
68
+ export interface SourceCodeSourceConfig {
69
+ repoUrl?: string;
70
+ localPath?: string;
71
+ zipPath?: string;
72
+ sourcePath?: string;
73
+ branch?: string;
74
+ graphifySourcePath?: string;
75
+ }
76
+
77
+ export type SourceConfig = ZipSourceConfig | AntoraSourceConfig | MavenSourceConfig | AsciidocSourceConfig | GithubMarkdownSourceConfig | SourceCodeSourceConfig;
78
+
79
+ export interface Build {
80
+ id: string;
81
+ entry_id: string;
82
+ status: BuildStatus;
83
+ log: string;
84
+ started_at: string;
85
+ finished_at: string;
86
+ }
87
+
88
+ export interface EntryDetail extends Entry {
89
+ sources: Source[];
90
+ latestBuild: Build | null;
91
+ }
92
+
93
+ export interface SearchResult {
94
+ path: string;
95
+ title: string;
96
+ headings: string[];
97
+ snippet: string;
98
+ }
99
+
100
+ export interface BuildStatusResponse {
101
+ status: 'none' | BuildStatus;
102
+ log: string;
103
+ startedAt: string;
104
+ finishedAt: string;
105
+ }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import tailwindcss from '@tailwindcss/vite';
4
+
5
+ export default defineConfig({
6
+ plugins: [tailwindcss(), react()],
7
+ server: {
8
+ port: 5173,
9
+ proxy: {
10
+ '/api': 'http://localhost:3001',
11
+ },
12
+ },
13
+ });
@@ -0,0 +1,20 @@
1
+ export function canTransitionTo(current, next) {
2
+ const transitions = {
3
+ pending: ['building'],
4
+ building: ['ready', 'error'],
5
+ ready: ['building'],
6
+ error: ['building'],
7
+ };
8
+ return transitions[current]?.includes(next) ?? false;
9
+ }
10
+ export function generateEntryId(name, version) {
11
+ const namePart = name
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9]+/g, '-')
14
+ .replace(/^-+|-+$/g, '');
15
+ const versionPart = version
16
+ .toLowerCase()
17
+ .replace(/[^a-z0-9x]+/g, '');
18
+ return `${namePart}-${versionPart}`;
19
+ }
20
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../src/core/domain/entry.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,OAAoB,EAAE,IAAiB;IACrE,MAAM,WAAW,GAAuC;QACtD,OAAO,EAAE,CAAC,UAAU,CAAC;QACrB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;QAC5B,KAAK,EAAE,CAAC,UAAU,CAAC;QACnB,KAAK,EAAE,CAAC,UAAU,CAAC;KACpB,CAAC;IACF,OAAO,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAAe;IAC3D,MAAM,QAAQ,GAAG,IAAI;SAClB,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,MAAM,WAAW,GAAG,OAAO;SACxB,WAAW,EAAE;SACb,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAC/B,OAAO,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,33 @@
1
+ export class DomainError extends Error {
2
+ code;
3
+ constructor(message, code) {
4
+ super(message);
5
+ this.code = code;
6
+ this.name = 'DomainError';
7
+ }
8
+ }
9
+ export class NotFoundError extends DomainError {
10
+ constructor(resource, id) {
11
+ super(`${resource} not found: ${id}`, 'NOT_FOUND');
12
+ this.name = 'NotFoundError';
13
+ }
14
+ }
15
+ export class ValidationError extends DomainError {
16
+ field;
17
+ value;
18
+ constructor(message, field, value) {
19
+ super(message, 'VALIDATION_ERROR');
20
+ this.field = field;
21
+ this.value = value;
22
+ this.name = 'ValidationError';
23
+ }
24
+ }
25
+ export class BuildError extends DomainError {
26
+ entryId;
27
+ constructor(message, entryId) {
28
+ super(`Build failed for entry ${entryId}: ${message}`, 'BUILD_ERROR');
29
+ this.entryId = entryId;
30
+ this.name = 'BuildError';
31
+ }
32
+ }
33
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/core/domain/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACS;IAA7C,YAAY,OAAe,EAAkB,IAAY;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,SAAI,GAAJ,IAAI,CAAQ;QAEvD,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,YAAY,QAAgB,EAAE,EAAU;QACtC,KAAK,CAAC,GAAG,QAAQ,eAAe,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,WAAW;IACD;IAAgC;IAA7E,YAAY,OAAe,EAAkB,KAAc,EAAkB,KAAe;QAC1F,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QADQ,UAAK,GAAL,KAAK,CAAS;QAAkB,UAAK,GAAL,KAAK,CAAU;QAE1F,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,WAAW;IACI;IAA7C,YAAY,OAAe,EAAkB,OAAe;QAC1D,KAAK,CAAC,0BAA0B,OAAO,KAAK,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;QAD3B,YAAO,GAAP,OAAO,CAAQ;QAE1D,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=knowledge-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledge-graph.js","sourceRoot":"","sources":["../../../src/core/domain/knowledge-graph.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/domain/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IBuildRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IBuildRepository.js","sourceRoot":"","sources":["../../../src/core/ports/IBuildRepository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDocumentNormalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDocumentNormalizer.js","sourceRoot":"","sources":["../../../src/core/ports/IDocumentNormalizer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IDocumentStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDocumentStore.js","sourceRoot":"","sources":["../../../src/core/ports/IDocumentStore.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IEntryReadModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntryReadModel.js","sourceRoot":"","sources":["../../../src/core/ports/IEntryReadModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IEntryRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntryRepository.js","sourceRoot":"","sources":["../../../src/core/ports/IEntryRepository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IKnowledgeGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IKnowledgeGraph.js","sourceRoot":"","sources":["../../../src/core/ports/IKnowledgeGraph.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IPathResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPathResolver.js","sourceRoot":"","sources":["../../../src/core/ports/IPathResolver.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ISearchEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ISearchEngine.js","sourceRoot":"","sources":["../../../src/core/ports/ISearchEngine.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ISourceProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ISourceProcessor.js","sourceRoot":"","sources":["../../../src/core/ports/ISourceProcessor.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ISourceRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ISourceRepository.js","sourceRoot":"","sources":["../../../src/core/ports/ISourceRepository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ import path from 'node:path';
2
+ import { BuildError } from '../../core/domain/errors.js';
3
+ export class BuildUseCase {
4
+ buildRepo;
5
+ sourceRepo;
6
+ entryRepo;
7
+ searchEngine;
8
+ processors;
9
+ documentNormalizer;
10
+ pathResolver;
11
+ constructor(buildRepo, sourceRepo, entryRepo, searchEngine, processors, documentNormalizer, pathResolver) {
12
+ this.buildRepo = buildRepo;
13
+ this.sourceRepo = sourceRepo;
14
+ this.entryRepo = entryRepo;
15
+ this.searchEngine = searchEngine;
16
+ this.processors = processors;
17
+ this.documentNormalizer = documentNormalizer;
18
+ this.pathResolver = pathResolver;
19
+ }
20
+ async build(entryId) {
21
+ const sources = await this.sourceRepo.findByEntryId(entryId);
22
+ if (sources.length === 0)
23
+ throw new BuildError('Entry has no sources', entryId);
24
+ await this.entryRepo.updateStatus(entryId, 'building');
25
+ const build = await this.buildRepo.create(entryId);
26
+ const logLines = [];
27
+ const log = (msg) => logLines.push(`[${new Date().toISOString()}] ${msg}`);
28
+ log('Build started');
29
+ const entryDir = path.join(this.pathResolver.dataRoot, entryId);
30
+ const bundleDir = path.join(entryDir, 'bundle');
31
+ try {
32
+ const normalizedSources = [];
33
+ const scProcessor = this.processors.find((p) => p.sourceType === 'source-code');
34
+ for (const source of sources) {
35
+ const sourceDir = path.join(entryDir, 'sources', source.id);
36
+ log(`Processing source [${source.type}]: ${source.label}`);
37
+ await this.sourceRepo.updateStatus(source.id, 'building');
38
+ try {
39
+ const processor = this.processors.find((p) => p.sourceType === source.type);
40
+ if (!processor)
41
+ throw new BuildError(`No processor for source type: ${source.type}`, entryId);
42
+ const outputDir = await processor.process(source, sourceDir, entryDir, entryId, log);
43
+ normalizedSources.push({ label: source.label, dir: outputDir });
44
+ const sourceConfig = source.config;
45
+ if (sourceConfig.graphifyEnabled && scProcessor?.runGraphify) {
46
+ log(` Graphify enabled — generating knowledge graph...`);
47
+ await scProcessor.runGraphify(sourceConfig, entryDir, log);
48
+ }
49
+ await this.sourceRepo.updateStatus(source.id, 'ready');
50
+ }
51
+ catch (err) {
52
+ await this.sourceRepo.updateStatus(source.id, 'error');
53
+ const message = err instanceof Error ? err.message : String(err);
54
+ log(` ERROR processing source ${source.label}: ${message}`);
55
+ throw err;
56
+ }
57
+ }
58
+ log('Normalizing documentation bundle');
59
+ const htmlSources = this.documentNormalizer.filterSources(normalizedSources, sources);
60
+ const htmlFiles = this.documentNormalizer.normalize(htmlSources, bundleDir, log);
61
+ log('Building search index');
62
+ await this.searchEngine.buildIndex(entryId, htmlFiles.map((f) => ({ relativePath: f, fullPath: path.join(bundleDir, f) })), log);
63
+ const fullLog = logLines.join('\n');
64
+ await this.buildRepo.update(build.id, 'ready', fullLog);
65
+ await this.entryRepo.updateStatus(entryId, 'ready');
66
+ return { buildId: build.id, entryId, status: 'ready', log: fullLog };
67
+ }
68
+ catch (err) {
69
+ const fullLog = logLines.join('\n');
70
+ await this.buildRepo.update(build.id, 'error', fullLog);
71
+ await this.entryRepo.updateStatus(entryId, 'error');
72
+ return { buildId: build.id, entryId, status: 'error', log: fullLog };
73
+ }
74
+ }
75
+ }
76
+ //# sourceMappingURL=BuildUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildUseCase.js","sourceRoot":"","sources":["../../../src/core/usecases/BuildUseCase.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAS7B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AASzD,MAAM,OAAO,YAAY;IAEJ;IACA;IACA;IACA;IACA;IACA;IACA;IAPnB,YACmB,SAA2B,EAC3B,UAA6B,EAC7B,SAA2B,EAC3B,YAA2B,EAC3B,UAA8B,EAC9B,kBAAuC,EACvC,YAA2B;QAN3B,cAAS,GAAT,SAAS,CAAkB;QAC3B,eAAU,GAAV,UAAU,CAAmB;QAC7B,cAAS,GAAT,SAAS,CAAkB;QAC3B,iBAAY,GAAZ,YAAY,CAAe;QAC3B,e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C;YACpC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACxD,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACpD,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,62 @@
1
+ import { NotFoundError, ValidationError } from '../domain/errors.js';
2
+ import { generateEntryId } from '../domain/entry.js';
3
+ export class ConfigUseCase {
4
+ entryRepo;
5
+ sourceRepo;
6
+ constructor(entryRepo, sourceRepo) {
7
+ this.entryRepo = entryRepo;
8
+ this.sourceRepo = sourceRepo;
9
+ }
10
+ async listEntries() {
11
+ return this.entryRepo.findAll();
12
+ }
13
+ async getEntry(id) {
14
+ return this.entryRepo.findById(id);
15
+ }
16
+ async getEntryWithSources(id) {
17
+ const entry = await this.entryRepo.findById(id);
18
+ if (!entry)
19
+ return undefined;
20
+ const sources = await this.sourceRepo.findByEntryId(id);
21
+ return { ...entry, sources };
22
+ }
23
+ async createEntry(input) {
24
+ if (!input.name?.trim())
25
+ throw new ValidationError('Entry name is required', 'name', input.name);
26
+ if (!input.version?.trim())
27
+ throw new ValidationError('Entry version is required', 'version', input.version);
28
+ const id = input.id ?? generateEntryId(input.name, input.version);
29
+ return this.entryRepo.create({ ...input, id });
30
+ }
31
+ async updateEntry(id, input) {
32
+ const existing = await this.entryRepo.findById(id);
33
+ if (!existing)
34
+ throw new NotFoundError('Entry', id);
35
+ await this.entryRepo.update(id, input);
36
+ }
37
+ async deleteEntry(id) {
38
+ const existing = await this.entryRepo.findById(id);
39
+ if (!existing)
40
+ throw new NotFoundError('Entry', id);
41
+ await this.entryRepo.delete(id);
42
+ }
43
+ async createSource(entryId, input) {
44
+ const entry = await this.entryRepo.findById(entryId);
45
+ if (!entry)
46
+ throw new NotFoundError('Entry', entryId);
47
+ return this.sourceRepo.create(entryId, input);
48
+ }
49
+ async updateSource(id, input) {
50
+ const existing = await this.sourceRepo.findById(id);
51
+ if (!existing)
52
+ throw new NotFoundError('Source', id);
53
+ await this.sourceRepo.update(id, input);
54
+ }
55
+ async deleteSource(id) {
56
+ const existing = await this.sourceRepo.findById(id);
57
+ if (!existing)
58
+ throw new NotFoundError('Source', id);
59
+ await this.sourceRepo.delete(id);
60
+ }
61
+ }
62
+ //# sourceMappingURL=ConfigUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigUseCase.js","sourceRoot":"","sources":["../../../src/core/usecases/ConfigUseCase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,OAAO,aAAa;IAEL;IACA;IAFnB,YACmB,SAA2B,EAC3B,UAA6B;QAD7B,cAAS,GAAT,SAAS,CAAkB;QAC3B,eAAU,GAAV,UAAU,CAAmB;IAC7C,CAAC;IAEJ,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,EAAU;QAClC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAC7B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACxD,OAAO,EAAE,GAAG,KAAK,EAA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,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,KAAwB;QACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ export class SearchUseCase {
2
+ searchEngine;
3
+ constructor(searchEngine) {
4
+ this.searchEngine = searchEngine;
5
+ }
6
+ async searchEntry(entryId, query, limit = 20) {
7
+ if (!query.trim())
8
+ return [];
9
+ return this.searchEngine.search(entryId, query, limit);
10
+ }
11
+ async globalSearch(query, limit = 30) {
12
+ if (!query.trim())
13
+ return [];
14
+ return this.searchEngine.globalSearch(query, limit);
15
+ }
16
+ }
17
+ //# sourceMappingURL=SearchUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchUseCase.js","sourceRoot":"","sources":["../../../src/core/usecases/SearchUseCase.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,YAA2B;QAA3B,iBAAY,GAAZ,YAAY,CAAe;IAAG,CAAC;IAE5D,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,KAAa,EAAE,KAAK,GAAG,EAAE;QAC1D,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAa,EAAE,KAAK,GAAG,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;CACF"}
@@ -0,0 +1,86 @@
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { getDb } from './infrastructure/persistence/sqlite/connection.js';
6
+ import { SqliteEntryRepository } from './infrastructure/persistence/sqlite/SqliteEntryRepository.js';
7
+ import { SqliteSourceRepository } from './infrastructure/persistence/sqlite/SqliteSourceRepository.js';
8
+ import { SqliteBuildRepository } from './infrastructure/persistence/sqlite/SqliteBuildRepository.js';
9
+ import { createSearchEngine } from './infrastructure/search/SearchEngineFactory.js';
10
+ import { SearchUseCase } from './core/usecases/SearchUseCase.js';
11
+ import { BuildUseCase } from './core/usecases/BuildUseCase.js';
12
+ import { ConfigUseCase } from './core/usecases/ConfigUseCase.js';
13
+ import { NotFoundError, ValidationError } from './core/domain/errors.js';
14
+ import { ZipSourceProcessor } from './infrastructure/source-processors/ZipSourceProcessor.js';
15
+ import { AntoraSourceProcessor } from './infrastructure/source-processors/AntoraSourceProcessor.js';
16
+ import { AsciidocSourceProcessor } from './infrastructure/source-processors/AsciidocSourceProcessor.js';
17
+ import { MavenSourceProcessor } from './infrastructure/source-processors/MavenSourceProcessor.js';
18
+ import { GithubMarkdownSourceProcessor } from './infrastructure/source-processors/GithubMarkdownSourceProcessor.js';
19
+ import { SourceCodeSourceProcessor } from './infrastructure/source-processors/SourceCodeSourceProcessor.js';
20
+ import { DocumentNormalizer } from './infrastructure/source-processors/DocumentNormalizer.js';
21
+ import { PathResolver } from './infrastructure/source-processors/PathResolver.js';
22
+ import { SqliteEntryReadModel } from './infrastructure/persistence/sqlite/SqliteEntryReadModel.js';
23
+ import { createEntryRoutes } from './routes/entries.js';
24
+ import { createSearchRoutes } from './routes/search.js';
25
+ import { createBuildRoutes } from './routes/build.js';
26
+ import { createSourceRoutes, createSourceFlatRoutes } from './routes/sources.js';
27
+ import viewerRoutes from './routes/viewer.js';
28
+ import { createGraphRoutes } from './routes/graph.js';
29
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
+ const PORT = process.env.PORT || 3001;
31
+ async function main() {
32
+ const app = express();
33
+ app.use(cors());
34
+ app.use(express.json());
35
+ const db = getDb();
36
+ const entryRepo = new SqliteEntryRepository(db);
37
+ const sourceRepo = new SqliteSourceRepository(db);
38
+ const buildRepo = new SqliteBuildRepository(db);
39
+ const entryReadModel = new SqliteEntryReadModel(db);
40
+ const searchEngine = await createSearchEngine(entryReadModel);
41
+ const configUseCase = new ConfigUseCase(entryRepo, sourceRepo);
42
+ const searchUseCase = new SearchUseCase(searchEngine);
43
+ const processors = [
44
+ new ZipSourceProcessor(),
45
+ new AntoraSourceProcessor(),
46
+ new AsciidocSourceProcessor(),
47
+ new MavenSourceProcessor(),
48
+ new GithubMarkdownSourceProcessor(),
49
+ new SourceCodeSourceProcessor(),
50
+ ];
51
+ const documentNormalizer = new DocumentNormalizer();
52
+ const pathResolver = new PathResolver();
53
+ const buildUseCase = new BuildUseCase(buildRepo, sourceRepo, entryRepo, searchEngine, processors, documentNormalizer, pathResolver);
54
+ app.use('/api/entries', createEntryRoutes(configUseCase));
55
+ app.use('/api/entries/:entryId/sources', createSourceRoutes(configUseCase));
56
+ app.use('/api/sources', createSourceFlatRoutes(configUseCase));
57
+ app.use('/api', createBuildRoutes(buildUseCase, configUseCase, buildRepo));
58
+ app.use('/api', createSearchRoutes(searchUseCase));
59
+ app.use('/api', createGraphRoutes(buildRepo, configUseCase));
60
+ app.use('/api', viewerRoutes);
61
+ // Global error handler — catches domain errors thrown by use cases
62
+ app.use((err, _req, res, _next) => {
63
+ if (err instanceof NotFoundError) {
64
+ res.status(404).json({ error: err.message, code: err.code });
65
+ return;
66
+ }
67
+ if (err instanceof ValidationError) {
68
+ const body = { error: err.message, code: err.code };
69
+ if (err.field)
70
+ body.field = err.field;
71
+ res.status(400).json(body);
72
+ return;
73
+ }
74
+ console.error('Unhandled error:', err);
75
+ const message = err instanceof Error ? err.message : 'Internal server error';
76
+ res.status(500).json({ error: message });
77
+ });
78
+ app.listen(PORT, () => {
79
+ console.log(`Dockit server running on http://localhost:${PORT}`);
80
+ });
81
+ }
82
+ main().catch((err) => {
83
+ console.error('Failed to start server:', err);
84
+ process.exit(1);
85
+ });
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAU,MAAM,mDAAmD,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8DAA8D,CAAC;AACrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8DAA8D,CAAC;AACrG,OAAO,EAAE,k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AK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC;QAC7E,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,6CAA6C,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { DATA_ROOT } from '../../services/paths.js';
4
+ export class FileSystemDocumentStore {
5
+ async getDocument(entryId, docPath) {
6
+ const resolved = path.resolve(DATA_ROOT, entryId, 'bundle', docPath);
7
+ const dataRoot = path.resolve(DATA_ROOT);
8
+ if (!resolved.startsWith(dataRoot)) {
9
+ throw new Error('Invalid document path');
10
+ }
11
+ if (!fs.existsSync(resolved)) {
12
+ throw new Error(`Document not found: ${docPath} for entry ${entryId}`);
13
+ }
14
+ return fs.readFileSync(resolved, 'utf-8');
15
+ }
16
+ async documentExists(entryId, docPath) {
17
+ const resolved = path.resolve(DATA_ROOT, entryId, 'bundle', docPath);
18
+ const dataRoot = path.resolve(DATA_ROOT);
19
+ if (!resolved.startsWith(dataRoot)) {
20
+ return false;
21
+ }
22
+ return fs.existsSync(resolved);
23
+ }
24
+ }
25
+ //# sourceMappingURL=FileSystemDocumentStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSystemDocumentStore.js","sourceRoot":"","sources":["../../../src/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
+ knowledgeGraph;
4
+ capability;
5
+ constructor(engine, knowledgeGraph) {
6
+ this.engine = engine;
7
+ this.knowledgeGraph = knowledgeGraph;
8
+ this.capability = engine.capability;
9
+ }
10
+ async buildIndex(entryId, htmlFiles, log) {
11
+ return this.engine.buildIndex(entryId, htmlFiles, log);
12
+ }
13
+ async search(entryId, query, limit = 10) {
14
+ const results = await this.engine.search(entryId, query, limit);
15
+ if (!this.knowledgeGraph.exists() || results.length === 0)
16
+ return results;
17
+ const graphResult = this.knowledgeGraph.query(query);
18
+ if (graphResult.totalNodes === 0)
19
+ return results;
20
+ const graphNames = new Set(graphResult.nodes.map((n) => n.name.toLowerCase()));
21
+ const scored = results.map((r) => {
22
+ let boost = 0;
23
+ const titleWords = r.title.toLowerCase().split(/\s+/);
24
+ const snippetWords = r.snippet.toLowerCase().split(/\s+/);
25
+ for (const word of titleWords) {
26
+ if (graphNames.has(word))
27
+ boost += 0.3;
28
+ }
29
+ for (const word of snippetWords) {
30
+ if (graphNames.has(word))
31
+ boost += 0.1;
32
+ }
33
+ return { ...r, _score: boost };
34
+ });
35
+ scored.sort((a, b) => (b._score || 0) - (a._score || 0));
36
+ return scored.slice(0, limit);
37
+ }
38
+ async globalSearch(query, limit = 20) {
39
+ return this.engine.globalSearch(query, limit);
40
+ }
41
+ }
42
+ //# sourceMappingURL=GraphSearchDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphSearchDecorator.js","sourceRoot":"","sources":["../../../src/infrastructure/graph/GraphSearchDecorator.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,oBAAoB;IAIZ;IACA;IAJV,UAAU,CAAmB;IAEtC,YACmB,MAAqB,EACrB,cAA+B;QAD/B,WAAM,GAAN,MAAM,CAAe;QACrB,mBAAc,GAAd,cAAc,CAAiB;QAEhD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe,EAAE,SAAqB,E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