@atolis-hq/wake 0.2.89 → 0.2.90
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.
|
@@ -494,7 +494,11 @@ async function openItemModal(repo, number, boardItem) {
|
|
|
494
494
|
|
|
495
495
|
async function ensureDetail() {
|
|
496
496
|
if (!loaded.has('detail')) {
|
|
497
|
-
|
|
497
|
+
const itemPath =
|
|
498
|
+
boardItem && boardItem.workItemKey
|
|
499
|
+
? '/items/' + encodeURIComponent(boardItem.workItemKey)
|
|
500
|
+
: '/items/' + encodeURIComponent(repo) + '/' + number;
|
|
501
|
+
loaded.set('detail', await getJson(itemPath));
|
|
498
502
|
}
|
|
499
503
|
return loaded.get('detail');
|
|
500
504
|
}
|
|
@@ -138,6 +138,7 @@ export async function buildBoard(input) {
|
|
|
138
138
|
totalCostUsd: 0,
|
|
139
139
|
};
|
|
140
140
|
return {
|
|
141
|
+
workItemKey: item.workItemKey,
|
|
141
142
|
repo: item.issue.repo,
|
|
142
143
|
number: item.issue.number,
|
|
143
144
|
title: item.issue.title,
|
|
@@ -293,15 +294,15 @@ async function listSourceStates(sourceStateRoot) {
|
|
|
293
294
|
}
|
|
294
295
|
}
|
|
295
296
|
export async function buildItemDetail(input) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
297
|
+
const workItemKey = input.workItemKey ??
|
|
298
|
+
(input.resourceIndex === undefined ||
|
|
299
|
+
input.provider === undefined ||
|
|
300
|
+
input.repo === undefined ||
|
|
301
|
+
input.issueNumber === undefined
|
|
302
|
+
? undefined
|
|
303
|
+
: await input.resourceIndex.resolve(buildResourceUri(input.provider, 'issue', `${input.repo}#${input.issueNumber}`)));
|
|
304
|
+
if (workItemKey === undefined)
|
|
303
305
|
return null;
|
|
304
|
-
}
|
|
305
306
|
const item = await input.stateStore.readIssueState(workItemKey);
|
|
306
307
|
if (item === null) {
|
|
307
308
|
return null;
|
|
@@ -38,11 +38,22 @@ function extractBearerToken(req) {
|
|
|
38
38
|
return undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Parses `/items/<
|
|
41
|
+
* Parses `/items/<workItemKey>[/events]` and the legacy
|
|
42
|
+
* `/items/<repo-with-slashes>/<issueNumber>[/events]` form where repo itself
|
|
42
43
|
* may contain a `/` (e.g. `owner/name`), so the split can't assume a fixed arity.
|
|
43
44
|
*/
|
|
44
45
|
function parseItemPath(segments) {
|
|
45
46
|
const trailingIsEvents = segments.at(-1) === 'events';
|
|
47
|
+
const itemSegments = trailingIsEvents ? segments.slice(0, -1) : segments;
|
|
48
|
+
if (itemSegments.length === 1) {
|
|
49
|
+
const workItemKey = itemSegments[0];
|
|
50
|
+
if (workItemKey === undefined || workItemKey.length === 0)
|
|
51
|
+
return null;
|
|
52
|
+
return {
|
|
53
|
+
workItemKey,
|
|
54
|
+
...(trailingIsEvents ? { suffix: 'events' } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
46
57
|
const numberIndex = trailingIsEvents ? segments.length - 2 : segments.length - 1;
|
|
47
58
|
const issueNumberRaw = segments[numberIndex];
|
|
48
59
|
const issueNumber = issueNumberRaw === undefined ? Number.NaN : Number(issueNumberRaw);
|
|
@@ -372,19 +383,21 @@ async function handleRequest(req, res, options, now, projectionUpdater) {
|
|
|
372
383
|
sendJson(res, 200, await buildBoard({ stateStore, config, now: now() }));
|
|
373
384
|
return;
|
|
374
385
|
}
|
|
375
|
-
if (resource === 'items' && segments.length >=
|
|
386
|
+
if (resource === 'items' && segments.length >= 2) {
|
|
376
387
|
const parsed = parseItemPath(segments.slice(1));
|
|
377
388
|
if (parsed === null) {
|
|
378
|
-
sendJson(res, 400, { error: 'expected /items/<repo>/<issueNumber>' });
|
|
389
|
+
sendJson(res, 400, { error: 'expected /items/<workItemKey> or /items/<repo>/<issueNumber>' });
|
|
379
390
|
return;
|
|
380
391
|
}
|
|
381
|
-
const itemDetailInput =
|
|
382
|
-
stateStore,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
const itemDetailInput = 'workItemKey' in parsed
|
|
393
|
+
? { stateStore, workItemKey: parsed.workItemKey }
|
|
394
|
+
: {
|
|
395
|
+
stateStore,
|
|
396
|
+
resourceIndex,
|
|
397
|
+
provider: configuredTicketSource(config),
|
|
398
|
+
repo: parsed.repo,
|
|
399
|
+
issueNumber: parsed.issueNumber,
|
|
400
|
+
};
|
|
388
401
|
if (parsed.suffix === 'events') {
|
|
389
402
|
const detail = await buildItemDetail(itemDetailInput);
|
|
390
403
|
sendJson(res, 200, detail?.events ?? []);
|
package/dist/src/version.js
CHANGED