@elisra-devops/docgen-data-provider 1.129.0 → 1.131.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elisra-devops/docgen-data-provider",
3
- "version": "1.129.0",
3
+ "version": "1.131.0",
4
4
  "description": "A document generator data provider, aimed to retrive data from azure devops",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4413,9 +4413,6 @@ export default class ResultDataProvider {
4413
4413
  const relatedUrl = relation.url;
4414
4414
  try {
4415
4415
  const wi = await TFSServices.getItemContent(relatedUrl, this.token);
4416
- if (wi.fields['System.State'] === 'Closed') {
4417
- continue;
4418
- }
4419
4416
  if (
4420
4417
  selectedLinkedFieldSet.has('associatedRequirement') &&
4421
4418
  wi.fields['System.WorkItemType'] === 'Requirement'
@@ -514,6 +514,37 @@ export default class TicketsDataProvider {
514
514
  }
515
515
  }
516
516
 
517
+ /**
518
+ * Returns the project's work item type names and the complete set of valid state names.
519
+ * Used to validate SVD work-item filter options before generation so callers receive
520
+ * a descriptive error instead of a silent zero-result document.
521
+ *
522
+ * Types come from GET _apis/wit/workitemtypes (value[].name).
523
+ * States are extracted from the transitions map keys on the same response — each key
524
+ * is a state name — avoiding N extra per-type state calls.
525
+ *
526
+ * @param project - The project name.
527
+ * @returns An object with `types` (work item type names) and `states` (all state names across types).
528
+ */
529
+ async GetWorkItemTypeStates(project: string): Promise<{ types: string[]; states: string[] }> {
530
+ try {
531
+ const url = `${this.orgUrl}${project}/_apis/wit/workitemtypes`;
532
+ const { value: workItemTypes } = await TFSServices.getItemContent(url, this.token);
533
+ const types: string[] = (workItemTypes ?? []).map((t: any) => t?.name).filter(Boolean);
534
+ // transitions is a map whose keys are state names (e.g. { "Active": [...], "Closed": [...] })
535
+ const stateSet = new Set<string>();
536
+ for (const t of workItemTypes ?? []) {
537
+ for (const stateName of Object.keys(t?.transitions ?? {})) {
538
+ if (stateName) stateSet.add(stateName);
539
+ }
540
+ }
541
+ return { types, states: Array.from(stateSet) };
542
+ } catch (err: any) {
543
+ logger.error(`Error fetching work item type states: ${err.message}`);
544
+ throw err;
545
+ }
546
+ }
547
+
517
548
  /**
518
549
  * fetches linked queries
519
550
  * @param queries fetched queries
@@ -5127,7 +5127,7 @@ describe('ResultDataProvider', () => {
5127
5127
  });
5128
5128
 
5129
5129
  describe('appendLinkedRelations', () => {
5130
- it('should append requirement/bug/cr when enabled and skip closed items', async () => {
5130
+ it('should append requirement/bug/cr when enabled, including closed items', async () => {
5131
5131
  const relations = [
5132
5132
  { rel: 'System.LinkTypes.Related', url: 'https://example.com/wi/1' },
5133
5133
  { rel: 'System.LinkTypes.Related', url: 'https://example.com/wi/2' },
@@ -5191,7 +5191,7 @@ describe('ResultDataProvider', () => {
5191
5191
  expect(relatedRequirements[0]).toEqual(
5192
5192
  expect.objectContaining({ id: 1, customerId: 'CUST-1', workItemType: 'Requirement' })
5193
5193
  );
5194
- expect(relatedBugs).toHaveLength(1);
5194
+ expect(relatedBugs).toHaveLength(2);
5195
5195
  expect(relatedCRs).toHaveLength(1);
5196
5196
  });
5197
5197