@ankhorage/atlas 0.19.2 → 0.20.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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -0
- package/.next/build-manifest.json +3 -3
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +12 -0
- package/.next/server/app/_global-error/page.js +1 -1
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/dependency-graph/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/inventory/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/workspace/inventory/route/build-manifest.json +12 -0
- package/.next/server/app/api/workspace/inventory/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/workspace/inventory/route.js +10 -0
- package/.next/server/app/api/workspace/inventory/route.js.map +5 -0
- package/.next/server/app/api/workspace/inventory/route.js.nft.json +1 -0
- package/.next/server/app/api/workspace/inventory/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/workspace/retry/route.js +2 -2
- package/.next/server/app/api/workspace/retry/route.js.nft.json +1 -1
- package/.next/server/app/api/workspace/selection/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/workspace/selection/route/build-manifest.json +12 -0
- package/.next/server/app/api/workspace/selection/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/workspace/selection/route.js +11 -0
- package/.next/server/app/api/workspace/selection/route.js.map +5 -0
- package/.next/server/app/api/workspace/selection/route.js.nft.json +1 -0
- package/.next/server/app/api/workspace/selection/route_client-reference-manifest.js +3 -0
- package/.next/server/app/page/server-reference-manifest.json +5 -5
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app-paths-manifest.json +2 -0
- package/.next/server/chunks/[root-of-the-server]__0o38po8._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0o38po8._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__13u3w6h._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__13u3w6h._.js.map +1 -0
- package/.next/server/chunks/{[externals]__16594cb._.js → [root-of-the-server]__14-p326._.js} +2 -2
- package/.next/server/chunks/[root-of-the-server]__14-p326._.js.map +1 -0
- package/.next/server/chunks/_08j7hwz._.js +5 -0
- package/.next/server/chunks/_08j7hwz._.js.map +1 -0
- package/.next/server/chunks/_0qw9gtg._.js +3 -0
- package/.next/server/chunks/_0qw9gtg._.js.map +1 -0
- package/.next/server/chunks/_0s0tudb._.js +3 -0
- package/.next/server/chunks/_0s0tudb._.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_workspace_inventory_route_actions_1d1a228.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_workspace_selection_route_actions_1-bxxis.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_workspace_selection_route_actions_1-bxxis.js.map +1 -0
- package/.next/server/chunks/node_modules_16e4rf7._.js +4 -4
- package/.next/server/chunks/ssr/[root-of-the-server]__0_6mxrx._.js +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__1o19g7g._.js → [root-of-the-server]__1b7nej0._.js} +1 -1
- package/.next/server/chunks/ssr/_0lahb16._.js +1 -1
- package/.next/server/chunks/ssr/_14-yori._.js +1 -1
- package/.next/server/chunks/ssr/_14-yori._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +6 -6
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/paradox/badges/npm.svg +3 -3
- package/paradox/diagrams/architecture-overview.mmd +59 -5
- package/paradox/diagrams/export-graph.mmd +12 -0
- package/paradox/diagrams/module-relationships.mmd +47 -5
- package/paradox/index.html +601 -70
- package/paradox/paradox.json +1390 -170
- package/src/app/api/workspace/inventory/route.ts +21 -0
- package/src/app/api/workspace/selection/route.ts +22 -0
- package/src/features/workspace/adapters/inbound/next/createWorkspaceInventoryRoute.ts +38 -0
- package/src/features/workspace/adapters/inbound/next/createWorkspaceProgressResponse.ts +67 -0
- package/src/features/workspace/adapters/inbound/next/createWorkspaceSelectionRoute.ts +90 -0
- package/src/features/workspace/application/use-cases/classifyWorkspaceRepositoryFailure.ts +105 -0
- package/src/features/workspace/composition/analyzeWorkspaceRepositoryAsync.ts +79 -0
- package/src/features/workspace/composition/createWorkspaceRepositoryRuntime.ts +100 -102
- package/src/features/workspace/composition/createWorkspaceRepositoryStatus.ts +12 -8
- package/src/features/workspace/composition/loadWorkspaceProjectSourceAsync.ts +90 -2
- package/src/features/workspace/composition/loadWorkspaceRepositoryBatchAsync.ts +39 -10
- package/src/features/workspace/composition/updateWorkspaceRepositoryRuntimeAsync.ts +137 -0
- package/src/features/workspace/utils/settleBoundedAsync.ts +17 -10
- package/src/types/workspace.ts +42 -0
- package/.next/server/chunks/_0clm3_5._.js +0 -3
- package/.next/server/chunks/_0clm3_5._.js.map +0 -1
- /package/.next/server/chunks/{[externals]__16594cb._.js.map → _next-internal_server_app_api_workspace_inventory_route_actions_1d1a228.js.map} +0 -0
- /package/.next/server/chunks/ssr/{[root-of-the-server]__1o19g7g._.js.map → [root-of-the-server]__1b7nej0._.js.map} +0 -0
- /package/.next/static/{GOvrWiGb2JX15cd-oOcf6 → CthQ01_AjZZJxjY_Q1XBz}/_buildManifest.js +0 -0
- /package/.next/static/{GOvrWiGb2JX15cd-oOcf6 → CthQ01_AjZZJxjY_Q1XBz}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{GOvrWiGb2JX15cd-oOcf6 → CthQ01_AjZZJxjY_Q1XBz}/_ssgManifest.js +0 -0
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
createProjectAnalysisSnapshotAsync,
|
|
5
|
-
createSourceGraphFromProjectAnalysisSnapshots,
|
|
6
|
-
projectDependencyGraphFromProjectAnalysisSnapshots,
|
|
7
|
-
} from '@ankhorage/dependency-graph';
|
|
8
3
|
import type { ProjectInspection } from '@ankhorage/project-detector/types';
|
|
9
4
|
import type {
|
|
10
5
|
GitHubRepositoryAuthentication,
|
|
11
6
|
GitHubRepositoryDiscoveryRepository,
|
|
12
7
|
} from '@ankhorage/repository/github';
|
|
13
8
|
|
|
14
|
-
import { inspectProjectForAnalysisAsync } from '@/features/project-analysis/adapters/outbound/project-detector/inspectProjectForAnalysisAsync';
|
|
15
|
-
import { selectParserLanguage } from '@/features/project-analysis/application/use-cases/selectParserLanguage';
|
|
16
|
-
import { createProjectFileTreeAsync } from '@/features/project-analysis/composition/createProjectFileTreeAsync';
|
|
17
|
-
import { parseProjectSource } from '@/features/project-source/application/use-cases/parseProjectSource';
|
|
18
|
-
import { loadProjectSourceAsync } from '@/features/project-source/composition/loadProjectSourceAsync';
|
|
19
9
|
import {
|
|
20
10
|
createWorkspaceAnalysisCache,
|
|
21
11
|
type WorkspaceAnalysisCache,
|
|
22
12
|
} from '@/features/workspace/application/use-cases/createWorkspaceAnalysisCache';
|
|
13
|
+
import { analyzeWorkspaceRepositoryAsync } from '@/features/workspace/composition/analyzeWorkspaceRepositoryAsync';
|
|
23
14
|
import type {
|
|
24
15
|
RepositoryAnalysis,
|
|
25
16
|
WorkspaceRepositoryRuntimeResult,
|
|
26
17
|
} from '@/features/workspace/composition/composeWorkspaceRepositoryRuntimeResult';
|
|
27
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
WorkspaceRepositoryProgress,
|
|
20
|
+
WorkspaceRuntimeState,
|
|
21
|
+
} from '@/features/workspace/composition/loadWorkspaceRepositoryBatchAsync';
|
|
28
22
|
import { loadWorkspaceRepositoryBatchAsync } from '@/features/workspace/composition/loadWorkspaceRepositoryBatchAsync';
|
|
23
|
+
import {
|
|
24
|
+
updateWorkspaceRepositoryRuntimeAsync,
|
|
25
|
+
validateWorkspaceRepositoryRuntime,
|
|
26
|
+
} from '@/features/workspace/composition/updateWorkspaceRepositoryRuntimeAsync';
|
|
29
27
|
import type { ProjectSource, ResolvedProjectSource } from '@/types/projectSource';
|
|
30
28
|
|
|
31
29
|
/*** Own process-local GitHub workspace state and revision-keyed portable analysis snapshots. */
|
|
@@ -54,9 +52,26 @@ function createWorkspaceRuntimeActions(
|
|
|
54
52
|
dependencies,
|
|
55
53
|
runtimeId,
|
|
56
54
|
repositoryId,
|
|
57
|
-
authorization,
|
|
55
|
+
authorization ?? anonymousAuthorization,
|
|
56
|
+
signal
|
|
57
|
+
),
|
|
58
|
+
updateAsync: (runtimeId, input, authorization, signal) =>
|
|
59
|
+
updateWorkspaceRepositoryRuntimeAsync(
|
|
60
|
+
workspaces,
|
|
61
|
+
cache,
|
|
62
|
+
dependencies,
|
|
63
|
+
runtimeId,
|
|
64
|
+
input,
|
|
65
|
+
authorization ?? anonymousAuthorization,
|
|
58
66
|
signal
|
|
59
67
|
),
|
|
68
|
+
validateAsync: (runtimeId, source, authorization) =>
|
|
69
|
+
validateWorkspaceRepositoryRuntime(
|
|
70
|
+
workspaces,
|
|
71
|
+
runtimeId,
|
|
72
|
+
source,
|
|
73
|
+
authorization ?? anonymousAuthorization
|
|
74
|
+
),
|
|
60
75
|
};
|
|
61
76
|
}
|
|
62
77
|
|
|
@@ -71,16 +86,20 @@ async function loadWorkspaceRuntimeAsync(
|
|
|
71
86
|
const workspace = runtimeWorkspace(input);
|
|
72
87
|
const runtimeId = randomUUID();
|
|
73
88
|
retainWorkspace(workspaces, runtimeId, workspace);
|
|
74
|
-
return runWorkspaceOperationAsync(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
return runWorkspaceOperationAsync(
|
|
90
|
+
workspace,
|
|
91
|
+
operationSignal =>
|
|
92
|
+
loadWorkspaceRepositoriesAsync(
|
|
93
|
+
workspace,
|
|
94
|
+
input.repositories,
|
|
95
|
+
runtimeId,
|
|
96
|
+
cache,
|
|
97
|
+
dependencies,
|
|
98
|
+
workspaceRepositoryAuthorization(input),
|
|
99
|
+
operationSignal,
|
|
100
|
+
input.onProgress
|
|
101
|
+
),
|
|
102
|
+
signal
|
|
84
103
|
);
|
|
85
104
|
}
|
|
86
105
|
|
|
@@ -108,16 +127,19 @@ async function retryWorkspaceRuntimeAsync(
|
|
|
108
127
|
);
|
|
109
128
|
if (workspace.statuses.get(repository.id)?.status === 'successful')
|
|
110
129
|
throw new WorkspaceRepositoryRuntimeError('stale', 'Only failed repositories can be retried.');
|
|
111
|
-
return runWorkspaceOperationAsync(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
return runWorkspaceOperationAsync(
|
|
131
|
+
workspace,
|
|
132
|
+
operationSignal =>
|
|
133
|
+
loadWorkspaceRepositoriesAsync(
|
|
134
|
+
workspace,
|
|
135
|
+
[repository],
|
|
136
|
+
runtimeId,
|
|
137
|
+
cache,
|
|
138
|
+
dependencies,
|
|
139
|
+
authorization,
|
|
140
|
+
operationSignal
|
|
141
|
+
),
|
|
142
|
+
signal
|
|
121
143
|
);
|
|
122
144
|
}
|
|
123
145
|
|
|
@@ -125,10 +147,12 @@ async function retryWorkspaceRuntimeAsync(
|
|
|
125
147
|
function runtimeWorkspace(input: WorkspaceRepositoryRuntimeInput): WorkspaceRuntimeState {
|
|
126
148
|
return {
|
|
127
149
|
active: false,
|
|
150
|
+
abortController: undefined,
|
|
128
151
|
entries: new Map(),
|
|
129
152
|
generation: 0,
|
|
130
153
|
repositories: input.repositories,
|
|
131
154
|
source: input.source,
|
|
155
|
+
authorizationScope: input.authorizationScope ?? 'anonymous',
|
|
132
156
|
statuses: new Map(),
|
|
133
157
|
};
|
|
134
158
|
}
|
|
@@ -144,21 +168,22 @@ function workspaceRepositoryAuthorization(
|
|
|
144
168
|
}
|
|
145
169
|
|
|
146
170
|
/*** Analyze only the requested repositories, then recompose the whole workspace from retained snapshots. */
|
|
147
|
-
async function
|
|
171
|
+
export async function loadWorkspaceRepositoriesAsync(
|
|
148
172
|
workspace: WorkspaceRuntimeState,
|
|
149
173
|
repositories: readonly GitHubRepositoryDiscoveryRepository[],
|
|
150
174
|
runtimeId: string,
|
|
151
175
|
cache: WorkspaceAnalysisCache<RepositoryAnalysis>,
|
|
152
176
|
dependencies: WorkspaceRepositoryRuntimeDependencies,
|
|
153
177
|
authorization: WorkspaceRepositoryAuthorization,
|
|
154
|
-
signal?: AbortSignal
|
|
178
|
+
signal?: AbortSignal,
|
|
179
|
+
onProgress?: WorkspaceRepositoryProgress
|
|
155
180
|
): Promise<WorkspaceRepositoryRuntimeResult> {
|
|
156
181
|
return loadWorkspaceRepositoryBatchAsync(
|
|
157
182
|
workspace,
|
|
158
183
|
repositories,
|
|
159
184
|
runtimeId,
|
|
160
185
|
async (repository, operationSignal) =>
|
|
161
|
-
|
|
186
|
+
analyzeWorkspaceRepositoryAsync(
|
|
162
187
|
repository,
|
|
163
188
|
authorization.authentication,
|
|
164
189
|
authorization.authorizationScope,
|
|
@@ -166,87 +191,39 @@ async function loadRepositoriesAsync(
|
|
|
166
191
|
dependencies,
|
|
167
192
|
operationSignal
|
|
168
193
|
),
|
|
169
|
-
signal
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/*** Resolve one immutable revision and materialize it only when its validated portable snapshot is absent. */
|
|
174
|
-
async function analyzeRepositoryAsync(
|
|
175
|
-
repository: GitHubRepositoryDiscoveryRepository,
|
|
176
|
-
authentication: GitHubRepositoryAuthentication,
|
|
177
|
-
authorizationScope: string,
|
|
178
|
-
cache: WorkspaceAnalysisCache<RepositoryAnalysis>,
|
|
179
|
-
dependencies: WorkspaceRepositoryRuntimeDependencies,
|
|
180
|
-
signal?: AbortSignal
|
|
181
|
-
): Promise<RepositoryAnalysis> {
|
|
182
|
-
const revision = await dependencies.resolveRevisionAsync(repository.url, authentication, signal);
|
|
183
|
-
const key = workspaceAnalysisCacheKey(revision, authorizationScope);
|
|
184
|
-
const cached = cache.getAnalysis(key);
|
|
185
|
-
if (cached !== undefined) return cached;
|
|
186
|
-
const source = parseProjectSource(repository.url);
|
|
187
|
-
if (source.kind !== 'github') throw new Error('Workspace repositories must be GitHub sources.');
|
|
188
|
-
const resolved = await (dependencies.materializeAsync ?? loadProjectSourceAsync)(
|
|
189
|
-
{ ...source, revision: revision.revision.commitSha },
|
|
190
194
|
signal,
|
|
191
|
-
|
|
195
|
+
onProgress
|
|
192
196
|
);
|
|
193
|
-
try {
|
|
194
|
-
const inspection = await (dependencies.inspectAsync ?? inspectProjectForAnalysisAsync)(
|
|
195
|
-
resolved.rootPath
|
|
196
|
-
);
|
|
197
|
-
const analysis = await createProjectAnalysisSnapshotAsync({ id: repository.id, inspection });
|
|
198
|
-
const sourceGraph = createSourceGraphFromProjectAnalysisSnapshots([analysis]);
|
|
199
|
-
const dependencyGraph = projectDependencyGraphFromProjectAnalysisSnapshots(sourceGraph, [
|
|
200
|
-
analysis,
|
|
201
|
-
]);
|
|
202
|
-
const language = selectParserLanguage(inspection.detection);
|
|
203
|
-
const value = {
|
|
204
|
-
analysis,
|
|
205
|
-
files: await createProjectFileTreeAsync(
|
|
206
|
-
inspection,
|
|
207
|
-
dependencyGraph,
|
|
208
|
-
language.language,
|
|
209
|
-
resolved.rootPath
|
|
210
|
-
),
|
|
211
|
-
language,
|
|
212
|
-
};
|
|
213
|
-
cache.setAnalysis(key, value);
|
|
214
|
-
return value;
|
|
215
|
-
} finally {
|
|
216
|
-
await resolved.cleanupAsync();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/*** Scope immutable analyses to the GitHub identity that was authorized to read them. */
|
|
221
|
-
function workspaceAnalysisCacheKey(
|
|
222
|
-
revision: Awaited<ReturnType<WorkspaceRepositoryRuntimeDependencies['resolveRevisionAsync']>>,
|
|
223
|
-
authorization: string
|
|
224
|
-
) {
|
|
225
|
-
return {
|
|
226
|
-
authorization,
|
|
227
|
-
provider: 'github' as const,
|
|
228
|
-
repositoryId: revision.repository.id,
|
|
229
|
-
revision: revision.revision.commitSha,
|
|
230
|
-
schemaVersion: ANALYSIS_SCHEMA_VERSION,
|
|
231
|
-
};
|
|
232
197
|
}
|
|
233
198
|
|
|
234
199
|
/*** Reject overlapping retry work before it can duplicate materialization or produce stale responses. */
|
|
235
|
-
async function runWorkspaceOperationAsync<Result>(
|
|
200
|
+
export async function runWorkspaceOperationAsync<Result>(
|
|
236
201
|
workspace: WorkspaceRuntimeState,
|
|
237
|
-
operation: () => Promise<Result
|
|
202
|
+
operation: (signal: AbortSignal) => Promise<Result>,
|
|
203
|
+
signal?: AbortSignal,
|
|
204
|
+
supersede = false
|
|
238
205
|
): Promise<Result> {
|
|
239
|
-
if (workspace.active) {
|
|
206
|
+
if (workspace.active && !supersede) {
|
|
240
207
|
throw new WorkspaceRepositoryRuntimeError(
|
|
241
208
|
'rate-limited',
|
|
242
209
|
'A workspace operation is already in progress. Try again shortly.'
|
|
243
210
|
);
|
|
244
211
|
}
|
|
212
|
+
workspace.abortController?.abort(
|
|
213
|
+
new DOMException('A newer workspace operation superseded this one.', 'AbortError')
|
|
214
|
+
);
|
|
215
|
+
const controller = new AbortController();
|
|
216
|
+
const operationSignal =
|
|
217
|
+
signal === undefined ? controller.signal : AbortSignal.any([signal, controller.signal]);
|
|
245
218
|
workspace.active = true;
|
|
219
|
+
workspace.abortController = controller;
|
|
246
220
|
try {
|
|
247
|
-
return await operation();
|
|
221
|
+
return await operation(operationSignal);
|
|
248
222
|
} finally {
|
|
249
|
-
workspace.
|
|
223
|
+
if (workspace.abortController === controller) {
|
|
224
|
+
workspace.active = false;
|
|
225
|
+
workspace.abortController = undefined;
|
|
226
|
+
}
|
|
250
227
|
}
|
|
251
228
|
}
|
|
252
229
|
|
|
@@ -277,6 +254,19 @@ export interface WorkspaceRepositoryRuntime {
|
|
|
277
254
|
authorization?: WorkspaceRepositoryAuthorization,
|
|
278
255
|
signal?: AbortSignal
|
|
279
256
|
) => Promise<WorkspaceRepositoryRuntimeResult>;
|
|
257
|
+
/*** Apply the #357 selection diff to this request-local runtime. */
|
|
258
|
+
readonly updateAsync: (
|
|
259
|
+
runtimeId: string,
|
|
260
|
+
input: WorkspaceRepositoryRuntimeUpdate,
|
|
261
|
+
authorization?: WorkspaceRepositoryAuthorization,
|
|
262
|
+
signal?: AbortSignal
|
|
263
|
+
) => Promise<WorkspaceRepositoryRuntimeResult>;
|
|
264
|
+
/*** Verify a request-local runtime before a transport begins a streaming response. */
|
|
265
|
+
readonly validateAsync: (
|
|
266
|
+
runtimeId: string,
|
|
267
|
+
source: string,
|
|
268
|
+
authorization?: WorkspaceRepositoryAuthorization
|
|
269
|
+
) => void;
|
|
280
270
|
}
|
|
281
271
|
|
|
282
272
|
export interface WorkspaceRepositoryRuntimeDependencies {
|
|
@@ -301,6 +291,8 @@ interface WorkspaceRepositoryRuntimeInput {
|
|
|
301
291
|
readonly authentication?: GitHubRepositoryAuthentication;
|
|
302
292
|
readonly authorizationScope?: string;
|
|
303
293
|
readonly repositories: readonly GitHubRepositoryDiscoveryRepository[];
|
|
294
|
+
/*** Receive credential-free snapshots as individual repositories complete, in completion order. */
|
|
295
|
+
readonly onProgress?: WorkspaceRepositoryProgress;
|
|
304
296
|
readonly source: string;
|
|
305
297
|
}
|
|
306
298
|
|
|
@@ -309,6 +301,13 @@ export interface WorkspaceRepositoryAuthorization {
|
|
|
309
301
|
readonly authorizationScope: string;
|
|
310
302
|
}
|
|
311
303
|
|
|
304
|
+
/*** Trusted selection changes supplied by the navigation owner; repository records remain server-validated. */
|
|
305
|
+
export interface WorkspaceRepositoryRuntimeUpdate {
|
|
306
|
+
readonly addedRepositories: readonly GitHubRepositoryDiscoveryRepository[];
|
|
307
|
+
readonly removedRepositoryIds: readonly string[];
|
|
308
|
+
readonly onProgress?: WorkspaceRepositoryProgress;
|
|
309
|
+
}
|
|
310
|
+
|
|
312
311
|
const anonymousAuthorization: WorkspaceRepositoryAuthorization = {
|
|
313
312
|
authentication: 'anonymous',
|
|
314
313
|
authorizationScope: 'anonymous',
|
|
@@ -324,5 +323,4 @@ export class WorkspaceRepositoryRuntimeError extends Error {
|
|
|
324
323
|
}
|
|
325
324
|
}
|
|
326
325
|
|
|
327
|
-
const ANALYSIS_SCHEMA_VERSION = 1;
|
|
328
326
|
const MAXIMUM_RUNTIME_WORKSPACES = 32;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import type { GitHubRepositoryDiscoveryRepository } from '@ankhorage/repository/github';
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
classifyWorkspaceRepositoryFailure,
|
|
5
|
+
workspaceRepositoryFailureDescription,
|
|
6
|
+
} from '@/features/workspace/application/use-cases/classifyWorkspaceRepositoryFailure';
|
|
3
7
|
import type { WorkspaceRepositoryLoadStatus } from '@/types/workspace';
|
|
4
8
|
|
|
5
9
|
/*** Build a credential-free runtime status record for one repository operation. */
|
|
6
10
|
export function createWorkspaceRepositoryStatus(
|
|
7
11
|
repository: GitHubRepositoryDiscoveryRepository,
|
|
8
|
-
status: WorkspaceRepositoryLoadStatus['status']
|
|
12
|
+
status: WorkspaceRepositoryLoadStatus['status'],
|
|
13
|
+
error?: unknown
|
|
9
14
|
): WorkspaceRepositoryLoadStatus {
|
|
15
|
+
const failure =
|
|
16
|
+
status === 'successful' || status === 'loading'
|
|
17
|
+
? undefined
|
|
18
|
+
: classifyWorkspaceRepositoryFailure(error);
|
|
10
19
|
return {
|
|
11
20
|
repository: { id: repository.id, name: repository.name, owner: repository.owner },
|
|
12
21
|
status,
|
|
13
|
-
...(
|
|
22
|
+
...(failure === undefined
|
|
14
23
|
? {}
|
|
15
|
-
: {
|
|
16
|
-
description:
|
|
17
|
-
status === 'cancelled'
|
|
18
|
-
? 'Loading was cancelled.'
|
|
19
|
-
: 'Repository materialization failed.',
|
|
20
|
-
}),
|
|
24
|
+
: { description: workspaceRepositoryFailureDescription(failure), failure }),
|
|
21
25
|
};
|
|
22
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DependencyGraph } from '@ankhorage/dependency-graph';
|
|
2
2
|
import type { ProjectInspection } from '@ankhorage/project-detector/types';
|
|
3
|
+
import type { GitHubRepositoryDiscoveryRepository } from '@ankhorage/repository/github';
|
|
3
4
|
import {
|
|
4
5
|
type GitHubRepositoryAuthentication,
|
|
5
6
|
type GitHubRepositoryRevisionResolutionResult,
|
|
@@ -16,12 +17,18 @@ import {
|
|
|
16
17
|
createWorkspaceRepositoryRuntime,
|
|
17
18
|
type WorkspaceRepositoryAuthorization,
|
|
18
19
|
type WorkspaceRepositoryRuntime,
|
|
20
|
+
WorkspaceRepositoryRuntimeError,
|
|
19
21
|
} from '@/features/workspace/composition/createWorkspaceRepositoryRuntime';
|
|
20
22
|
import { loadWorkspaceAsync } from '@/features/workspace/composition/loadWorkspaceAsync';
|
|
23
|
+
import type { WorkspaceRepositoryProgress } from '@/features/workspace/composition/loadWorkspaceRepositoryBatchAsync';
|
|
21
24
|
import { resolveWorkspaceStartupSource } from '@/features/workspace/composition/resolveWorkspaceStartupSource';
|
|
22
25
|
import type { ProjectSource, ResolvedProjectSource } from '@/types/projectSource';
|
|
23
|
-
import type {
|
|
24
|
-
|
|
26
|
+
import type {
|
|
27
|
+
WorkspaceLoadResult,
|
|
28
|
+
WorkspaceRepositoryInventoryOption,
|
|
29
|
+
WorkspaceRepositoryLoadStatus,
|
|
30
|
+
WorkspaceSelectionRequest,
|
|
31
|
+
} from '@/types/workspace';
|
|
25
32
|
import { getProjectName } from '@/utils/getProjectName';
|
|
26
33
|
import { parseProjectPath } from '@/utils/parseProjectPath';
|
|
27
34
|
|
|
@@ -50,6 +57,87 @@ export function retryWorkspaceRepositoryAsync(
|
|
|
50
57
|
);
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
/*** Discover only credential-free repository metadata for a request-scoped GitHub owner inventory. */
|
|
61
|
+
export async function discoverWorkspaceInventoryAsync(
|
|
62
|
+
source: string,
|
|
63
|
+
authorization: WorkspaceRepositoryAuthorization
|
|
64
|
+
): Promise<{
|
|
65
|
+
readonly owner: string;
|
|
66
|
+
readonly repositories: readonly WorkspaceRepositoryInventoryOption[];
|
|
67
|
+
}> {
|
|
68
|
+
const discovery = await discoverWorkspaceGitHubSourcesAsync(
|
|
69
|
+
source,
|
|
70
|
+
new Set(),
|
|
71
|
+
undefined,
|
|
72
|
+
authorization.authentication
|
|
73
|
+
);
|
|
74
|
+
return { owner: source, repositories: discovery.repositories };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*** Validate a browser selection against current authorized inventory before creating a streaming runtime operation. */
|
|
78
|
+
export async function createWorkspaceSelectionOperationAsync(
|
|
79
|
+
input: WorkspaceSelectionRequest,
|
|
80
|
+
authorization: WorkspaceRepositoryAuthorization,
|
|
81
|
+
signal?: AbortSignal
|
|
82
|
+
) {
|
|
83
|
+
const discovery = await discoverWorkspaceGitHubSourcesAsync(
|
|
84
|
+
input.source,
|
|
85
|
+
new Set(),
|
|
86
|
+
undefined,
|
|
87
|
+
authorization.authentication
|
|
88
|
+
);
|
|
89
|
+
const repositories = selectedInventoryRepositories(
|
|
90
|
+
discovery.repositories,
|
|
91
|
+
input.addedRepositoryIds
|
|
92
|
+
);
|
|
93
|
+
if (input.runtimeId === undefined)
|
|
94
|
+
return {
|
|
95
|
+
runAsync: (onProgress: WorkspaceRepositoryProgress, streamSignal: AbortSignal) =>
|
|
96
|
+
defaultWorkspaceRepositoryRuntime.loadAsync(
|
|
97
|
+
{
|
|
98
|
+
authentication: authorization.authentication,
|
|
99
|
+
authorizationScope: authorization.authorizationScope,
|
|
100
|
+
onProgress,
|
|
101
|
+
repositories,
|
|
102
|
+
source: input.source,
|
|
103
|
+
},
|
|
104
|
+
signal === undefined ? streamSignal : AbortSignal.any([signal, streamSignal])
|
|
105
|
+
),
|
|
106
|
+
};
|
|
107
|
+
const { runtimeId } = input;
|
|
108
|
+
defaultWorkspaceRepositoryRuntime.validateAsync(runtimeId, input.source, authorization);
|
|
109
|
+
return {
|
|
110
|
+
runAsync: (onProgress: WorkspaceRepositoryProgress, streamSignal: AbortSignal) =>
|
|
111
|
+
defaultWorkspaceRepositoryRuntime.updateAsync(
|
|
112
|
+
runtimeId,
|
|
113
|
+
{
|
|
114
|
+
addedRepositories: repositories,
|
|
115
|
+
onProgress,
|
|
116
|
+
removedRepositoryIds: input.removedRepositoryIds,
|
|
117
|
+
},
|
|
118
|
+
authorization,
|
|
119
|
+
signal === undefined ? streamSignal : AbortSignal.any([signal, streamSignal])
|
|
120
|
+
),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/*** Resolve opaque browser IDs exclusively from the fresh authorized inventory. */
|
|
125
|
+
function selectedInventoryRepositories(
|
|
126
|
+
inventory: readonly GitHubRepositoryDiscoveryRepository[],
|
|
127
|
+
ids: readonly string[]
|
|
128
|
+
): readonly GitHubRepositoryDiscoveryRepository[] {
|
|
129
|
+
const byId = new Map(inventory.map(repository => [repository.id, repository]));
|
|
130
|
+
if (ids.some(id => !byId.has(id)))
|
|
131
|
+
throw new WorkspaceRepositoryRuntimeError(
|
|
132
|
+
'invalid',
|
|
133
|
+
'A selected repository is unavailable for this source and account.'
|
|
134
|
+
);
|
|
135
|
+
return ids.flatMap(id => {
|
|
136
|
+
const repository = byId.get(id);
|
|
137
|
+
return repository === undefined ? [] : [repository];
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
53
141
|
/*** Load the configured local project or discover GitHub sources supplied by the browser query. */
|
|
54
142
|
export async function loadWorkspaceProjectSourceAsync(
|
|
55
143
|
sourceValue: string | undefined,
|
|
@@ -11,13 +11,19 @@ import type { WorkspaceRepositoryLoadStatus } from '@/types/workspace';
|
|
|
11
11
|
|
|
12
12
|
export interface WorkspaceRuntimeState {
|
|
13
13
|
active: boolean;
|
|
14
|
+
readonly authorizationScope: string;
|
|
15
|
+
abortController?: AbortController;
|
|
14
16
|
readonly entries: Map<string, RepositoryAnalysis>;
|
|
15
17
|
generation: number;
|
|
16
|
-
|
|
18
|
+
repositories: readonly GitHubRepositoryDiscoveryRepository[];
|
|
17
19
|
readonly source: string;
|
|
18
20
|
readonly statuses: Map<string, WorkspaceRepositoryLoadStatus>;
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
export type WorkspaceRepositoryProgress = (
|
|
24
|
+
result: WorkspaceRepositoryRuntimeResult
|
|
25
|
+
) => void | Promise<void>;
|
|
26
|
+
|
|
21
27
|
/*** Load one bounded batch and retain only credential-free workspace analysis results. */
|
|
22
28
|
export async function loadWorkspaceRepositoryBatchAsync(
|
|
23
29
|
workspace: WorkspaceRuntimeState,
|
|
@@ -27,16 +33,16 @@ export async function loadWorkspaceRepositoryBatchAsync(
|
|
|
27
33
|
repository: GitHubRepositoryDiscoveryRepository,
|
|
28
34
|
signal?: AbortSignal
|
|
29
35
|
) => Promise<RepositoryAnalysis>,
|
|
30
|
-
signal?: AbortSignal
|
|
36
|
+
signal?: AbortSignal,
|
|
37
|
+
onProgress?: WorkspaceRepositoryProgress
|
|
31
38
|
): Promise<WorkspaceRepositoryRuntimeResult> {
|
|
32
39
|
const generation = workspace.generation + 1;
|
|
33
40
|
workspace.generation = generation;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (repository === undefined) continue;
|
|
41
|
+
for (const repository of repositories)
|
|
42
|
+
workspace.statuses.set(repository.id, createWorkspaceRepositoryStatus(repository, 'loading'));
|
|
43
|
+
await publishWorkspaceProgress(workspace, runtimeId, generation, onProgress);
|
|
44
|
+
await settleBoundedAsync(repositories, 4, analyzeAsync, signal, async (repository, outcome) => {
|
|
45
|
+
if (workspace.generation !== generation) return;
|
|
40
46
|
if (outcome.status === 'fulfilled') {
|
|
41
47
|
workspace.entries.set(repository.id, outcome.value);
|
|
42
48
|
workspace.statuses.set(
|
|
@@ -48,11 +54,15 @@ export async function loadWorkspaceRepositoryBatchAsync(
|
|
|
48
54
|
repository.id,
|
|
49
55
|
createWorkspaceRepositoryStatus(
|
|
50
56
|
repository,
|
|
51
|
-
isCancellation(outcome.reason) ? 'cancelled' : 'failed'
|
|
57
|
+
isCancellation(outcome.reason) ? 'cancelled' : 'failed',
|
|
58
|
+
outcome.reason
|
|
52
59
|
)
|
|
53
60
|
);
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
await publishWorkspaceProgress(workspace, runtimeId, generation, onProgress);
|
|
63
|
+
});
|
|
64
|
+
if (workspace.generation !== generation)
|
|
65
|
+
throw new DOMException('A newer workspace operation superseded this one.', 'AbortError');
|
|
56
66
|
return composeWorkspaceRepositoryRuntimeResult({
|
|
57
67
|
entries: workspace.entries,
|
|
58
68
|
repositories: workspace.repositories,
|
|
@@ -62,6 +72,25 @@ export async function loadWorkspaceRepositoryBatchAsync(
|
|
|
62
72
|
});
|
|
63
73
|
}
|
|
64
74
|
|
|
75
|
+
/*** Publish a complete credential-free snapshot after each observable repository state transition. */
|
|
76
|
+
async function publishWorkspaceProgress(
|
|
77
|
+
workspace: WorkspaceRuntimeState,
|
|
78
|
+
runtimeId: string,
|
|
79
|
+
generation: number,
|
|
80
|
+
onProgress: WorkspaceRepositoryProgress | undefined
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
if (workspace.generation !== generation) return;
|
|
83
|
+
await onProgress?.(
|
|
84
|
+
composeWorkspaceRepositoryRuntimeResult({
|
|
85
|
+
entries: workspace.entries,
|
|
86
|
+
repositories: workspace.repositories,
|
|
87
|
+
runtimeId,
|
|
88
|
+
source: workspace.source,
|
|
89
|
+
statuses: workspace.statuses,
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
65
94
|
/*** Keep deliberate cancellation distinct from a failed repository materialization. */
|
|
66
95
|
function isCancellation(error: unknown): boolean {
|
|
67
96
|
return error instanceof DOMException
|