airgen-cli 0.1.5 → 0.1.6
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/dist/commands/implementation.js +31 -11
- package/package.json +1 -1
|
@@ -21,6 +21,33 @@ async function fetchAllRequirements(client, tenant, project) {
|
|
|
21
21
|
}
|
|
22
22
|
return all.filter((r) => !r.deleted && !r.deletedAt);
|
|
23
23
|
}
|
|
24
|
+
/** Fetch a single requirement by its resolved ID (ref or full colon ID). */
|
|
25
|
+
async function fetchRequirement(client, tenant, project, resolvedId) {
|
|
26
|
+
// Try direct GET by ref/ID first (works for both ref and full colon ID)
|
|
27
|
+
try {
|
|
28
|
+
const data = await client.get(`/requirements/${tenant}/${project}/${resolvedId}`);
|
|
29
|
+
if (data.record)
|
|
30
|
+
return data.record;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Not found via direct endpoint — fall through to paginated search
|
|
34
|
+
}
|
|
35
|
+
// Paginated search as fallback
|
|
36
|
+
for (let page = 1; page <= MAX_PAGES; page++) {
|
|
37
|
+
const data = await client.get(`/requirements/${tenant}/${project}`, {
|
|
38
|
+
page: String(page),
|
|
39
|
+
limit: String(PAGE_SIZE),
|
|
40
|
+
});
|
|
41
|
+
const items = data.data ?? [];
|
|
42
|
+
const found = items.find(r => r.id === resolvedId);
|
|
43
|
+
if (found)
|
|
44
|
+
return found;
|
|
45
|
+
const totalPages = data.meta?.totalPages ?? 1;
|
|
46
|
+
if (page >= totalPages)
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
24
51
|
function getImplStatus(tags) {
|
|
25
52
|
if (!tags)
|
|
26
53
|
return null;
|
|
@@ -74,9 +101,7 @@ export function registerImplementationCommands(program, client) {
|
|
|
74
101
|
process.exit(1);
|
|
75
102
|
}
|
|
76
103
|
const resolvedId = await resolveRequirementId(client, tenant, project, requirement);
|
|
77
|
-
|
|
78
|
-
const reqData = await client.get(`/requirements/${tenant}/${project}`, { page: "1", limit: "100" });
|
|
79
|
-
const req = (reqData.data ?? []).find(r => r.id === resolvedId);
|
|
104
|
+
const req = await fetchRequirement(client, tenant, project, resolvedId);
|
|
80
105
|
if (!req) {
|
|
81
106
|
console.error(`Requirement ${requirement} not found.`);
|
|
82
107
|
process.exit(1);
|
|
@@ -226,9 +251,7 @@ export function registerImplementationCommands(program, client) {
|
|
|
226
251
|
}
|
|
227
252
|
try {
|
|
228
253
|
const resolvedId = await resolveRequirementId(client, tenant, project, item.ref);
|
|
229
|
-
|
|
230
|
-
const reqData = await client.get(`/requirements/${tenant}/${project}`, { page: "1", limit: "100" });
|
|
231
|
-
const req = (reqData.data ?? []).find(r => r.id === resolvedId);
|
|
254
|
+
const req = await fetchRequirement(client, tenant, project, resolvedId);
|
|
232
255
|
if (!req) {
|
|
233
256
|
errors.push(`${item.ref}: not found`);
|
|
234
257
|
failed++;
|
|
@@ -279,9 +302,7 @@ export function registerImplementationCommands(program, client) {
|
|
|
279
302
|
.option("--line <n>", "Line number (for file type)")
|
|
280
303
|
.action(async (tenant, project, requirement, opts) => {
|
|
281
304
|
const resolvedId = await resolveRequirementId(client, tenant, project, requirement);
|
|
282
|
-
|
|
283
|
-
const reqData = await client.get(`/requirements/${tenant}/${project}`, { page: "1", limit: "100" });
|
|
284
|
-
const req = (reqData.data ?? []).find(r => r.id === resolvedId);
|
|
305
|
+
const req = await fetchRequirement(client, tenant, project, resolvedId);
|
|
285
306
|
if (!req) {
|
|
286
307
|
console.error(`Requirement ${requirement} not found.`);
|
|
287
308
|
process.exit(1);
|
|
@@ -319,8 +340,7 @@ export function registerImplementationCommands(program, client) {
|
|
|
319
340
|
.requiredOption("--path <path>", "Artifact path")
|
|
320
341
|
.action(async (tenant, project, requirement, opts) => {
|
|
321
342
|
const resolvedId = await resolveRequirementId(client, tenant, project, requirement);
|
|
322
|
-
const
|
|
323
|
-
const req = (reqData.data ?? []).find(r => r.id === resolvedId);
|
|
343
|
+
const req = await fetchRequirement(client, tenant, project, resolvedId);
|
|
324
344
|
if (!req) {
|
|
325
345
|
console.error(`Requirement ${requirement} not found.`);
|
|
326
346
|
process.exit(1);
|