Skip to content

Commit 8a02ad4

Browse files
committed
refactor: some typing changes to appease the unit tests
1 parent 8430e18 commit 8a02ad4

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

src/stix/providers/workbench/workbench.repository.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';
21
import { HttpService } from '@nestjs/axios';
2+
import { ConsoleLogger, Inject, Injectable } from '@nestjs/common';
3+
import { plainToInstance } from 'class-transformer';
34
import { lastValueFrom, map } from 'rxjs';
45
import {
56
TaxiiBadRequestException,
67
TaxiiNotFoundException,
78
TaxiiServiceUnavailableException,
89
} from 'src/common/exceptions';
10+
import { StixIdentityPrefix, WORKBENCH_OPTIONS, WorkbenchRESTEndpoint } from 'src/stix/constants';
11+
import { AttackObjectDto } from 'src/stix/dto/attack-object.dto';
12+
import { StixBundleDto } from 'src/stix/dto/stix-bundle.dto';
13+
import { WorkbenchCollectionBundleDto } from 'src/stix/dto/workbench-collection-bundle.dto';
914
import {
1015
WorkbenchCollectionDto,
1116
WorkbenchCollectionStixProperties,
1217
} from 'src/stix/dto/workbench-collection.dto';
13-
import { plainToInstance } from 'class-transformer';
14-
import { WorkbenchCollectionBundleDto } from 'src/stix/dto/workbench-collection-bundle.dto';
15-
import { AttackObjectDto } from 'src/stix/dto/attack-object.dto';
16-
import { StixIdentityPrefix, WorkbenchRESTEndpoint } from 'src/stix/constants';
1718
import { WorkbenchConnectOptionsInterface } from 'src/stix/interfaces/workbench-connect-options.interface';
18-
import { WORKBENCH_OPTIONS } from 'src/stix/constants';
19-
import { StixBundleDto } from 'src/stix/dto/stix-bundle.dto';
2019

2120
interface WorkbenchCollectionResponseDto {
2221
_id: string;
@@ -45,8 +44,8 @@ export class WorkbenchRepository {
4544
* @param url Base URL of the target Workbench REST API instance
4645
* @private
4746
*/
48-
49-
private async fetchHttp(url: string): Promise<unknown> {
47+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
48+
private async fetchHttp(url: string): Promise<any> {
5049
this.logger.debug(`Sending HTTP GET request to ${url}`, this.constructor.name);
5150

5251
let data;

src/taxii/providers/manifest/dto/manifest-record.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type StixCoreFields = {
88
modified?: string | Date;
99
};
1010

11-
type ManifestRecordInput = StixCoreFields | { stix: StixCoreFields };
11+
export type ManifestRecordInput = StixCoreFields | { stix: StixCoreFields };
1212

1313
/**
1414
* The manifest-record type captures metadata about a single version of an object, indicated by the id property. The

src/taxii/providers/manifest/manifest.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ObjectService } from '../object';
44
import { ObjectFiltersDto } from '../filter/dto';
55
import { MatchDto } from 'src/common/models/match/match.dto';
66
import { PaginationService } from '../pagination';
7-
import { ManifestDto, ManifestRecordDto } from './dto';
7+
import { ManifestDto, ManifestRecordDto, ManifestRecordInput } from './dto';
88

99
@Injectable()
1010
export class ManifestService {
@@ -40,7 +40,7 @@ export class ManifestService {
4040
const manifestRecords: ManifestRecordDto[] = [];
4141

4242
for await (const object of stixObjects) {
43-
manifestRecords.push(new ManifestRecordDto(object));
43+
manifestRecords.push(new ManifestRecordDto(object as ManifestRecordInput));
4444
}
4545

4646
// Paginate the manifest-records and return the appropriate page

src/taxii/providers/pagination/pagination.service.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Injectable } from '@nestjs/common';
2-
import { TaxiiLoggerService as Logger } from 'src/common/logger';
2+
import { isNumber } from '@nestjs/common/utils/shared.utils';
33
import { TaxiiNotFoundException } from 'src/common/exceptions';
4+
import { TaxiiLoggerService as Logger } from 'src/common/logger';
45
import { EnvelopeDto } from '../envelope';
5-
import { isNumber } from '@nestjs/common/utils/shared.utils';
66
import { ManifestDto, ManifestRecordDto } from '../manifest/dto';
77
import { VersionsDto } from '../version/dto/versions.dto';
88
// import { StixObjectDto } from "src/stix/dto/stix-object.dto";
@@ -84,11 +84,7 @@ export class PaginationService {
8484
*/
8585
async getEnvelope(objects: object[], limit?: number, next?: number): Promise<EnvelopeDto> {
8686
const page = await this.getPage(objects, limit, next);
87-
return new EnvelopeDto({
88-
more: page.more,
89-
next: page.next,
90-
objects: page.items,
91-
});
87+
return new EnvelopeDto({ ...page });
9288
}
9389

9490
/**

0 commit comments

Comments
 (0)