Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guardian analytics: bottom-up data traceability #4232

Merged
merged 63 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
9a32ee6
create new page
Stepan-Kirjakov Aug 30, 2024
4a958ae
update
Stepan-Kirjakov Sep 2, 2024
9be95d6
[skip ci] Add swagger.yaml
envision-ci-agent Sep 2, 2024
03efac4
update
Stepan-Kirjakov Sep 2, 2024
974b558
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Sep 2, 2024
a86ee04
update
Stepan-Kirjakov Sep 3, 2024
0df1ffa
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Sep 3, 2024
ffa02fd
update
Stepan-Kirjakov Sep 3, 2024
2898e32
[skip ci] Add swagger.yaml
envision-ci-agent Sep 3, 2024
2133dd8
update
Stepan-Kirjakov Sep 4, 2024
7101f5c
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Sep 4, 2024
156e7e7
update
Stepan-Kirjakov Sep 6, 2024
544d3ed
update
Stepan-Kirjakov Sep 6, 2024
16085eb
update
Stepan-Kirjakov Sep 9, 2024
ca8fb4a
update
Stepan-Kirjakov Sep 11, 2024
06eed3b
update
Stepan-Kirjakov Sep 13, 2024
7d33252
update
Stepan-Kirjakov Sep 16, 2024
c97eff4
[skip ci] Add swagger.yaml
envision-ci-agent Sep 16, 2024
170e1cd
update
Stepan-Kirjakov Sep 17, 2024
1cb09db
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Sep 17, 2024
f5727d0
update
Stepan-Kirjakov Sep 17, 2024
f8ac0b1
fix
Stepan-Kirjakov Sep 17, 2024
dacf978
update
Stepan-Kirjakov Sep 18, 2024
c54dc4f
[skip ci] Add swagger.yaml
envision-ci-agent Sep 18, 2024
bb040e9
update
Stepan-Kirjakov Sep 23, 2024
8e8bcd2
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Sep 23, 2024
f997b08
update
Stepan-Kirjakov Sep 24, 2024
a4bbade
update
Stepan-Kirjakov Sep 25, 2024
9d5a28f
update
Stepan-Kirjakov Sep 26, 2024
e2dc65c
[skip ci] Add swagger.yaml
envision-ci-agent Sep 26, 2024
a4f6061
update
Stepan-Kirjakov Sep 27, 2024
9883fcf
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Sep 27, 2024
148ff60
update
Stepan-Kirjakov Sep 30, 2024
e67d903
[skip ci] Add swagger.yaml
envision-ci-agent Sep 30, 2024
985ecb0
update
Stepan-Kirjakov Oct 1, 2024
aae8b29
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 1, 2024
dac0c94
[skip ci] Add swagger.yaml
envision-ci-agent Oct 1, 2024
5bddde2
fix
Stepan-Kirjakov Oct 1, 2024
d3cb92d
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 1, 2024
3cb99f9
update
Stepan-Kirjakov Oct 2, 2024
8a9d94b
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 2, 2024
333d90f
update
Stepan-Kirjakov Oct 3, 2024
1621a85
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 3, 2024
5d55bf7
fix
Stepan-Kirjakov Oct 4, 2024
4a56c98
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 4, 2024
87c35c0
fix
Stepan-Kirjakov Oct 4, 2024
4b929b5
[skip ci] Add swagger.yaml
envision-ci-agent Oct 4, 2024
bf2c056
fix
Stepan-Kirjakov Oct 4, 2024
d57bb5d
Merge branch 'feature/3336' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 4, 2024
4706c67
[skip ci] Add swagger.yaml
envision-ci-agent Oct 4, 2024
90753f4
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 7, 2024
3fa8134
fix
Stepan-Kirjakov Oct 7, 2024
5022598
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 7, 2024
17d59e0
fix
Stepan-Kirjakov Oct 7, 2024
03188d8
fix
Stepan-Kirjakov Oct 8, 2024
26c52af
fix
Stepan-Kirjakov Oct 8, 2024
3388ef8
fix
Stepan-Kirjakov Oct 8, 2024
c851ab5
fix
Stepan-Kirjakov Oct 8, 2024
f93b1ef
fix
Stepan-Kirjakov Oct 9, 2024
71266f2
Merge branch 'develop' into feature/3336
Stepan-Kirjakov Oct 9, 2024
da2d5f1
fix
Stepan-Kirjakov Oct 9, 2024
39ff028
fix
Stepan-Kirjakov Oct 9, 2024
3acf694
fix
Stepan-Kirjakov Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
608 changes: 608 additions & 0 deletions api-gateway/src/api/service/policy-statistics.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api-gateway/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { cacheProvider } from './helpers/providers/cache-provider.js';
import { CacheService } from './helpers/cache-service.js';
import { PermissionsApi } from './api/service/permissions.js';
import { WorkerTasksController } from './api/service/worker-tasks.js';
import { PolicyStatisticsApi } from './api/service/policy-statistics.js';
import { loggerMongoProvider, pinoLoggerProvider } from './helpers/providers/index.js';

// const JSON_REQUEST_LIMIT = process.env.JSON_REQUEST_LIMIT || '1mb';
Expand Down Expand Up @@ -92,6 +93,7 @@ import { loggerMongoProvider, pinoLoggerProvider } from './helpers/providers/ind
RecordApi,
AISuggestionsAPI,
PermissionsApi,
PolicyStatisticsApi,
WorkerTasksController
],
providers: [
Expand Down
196 changes: 190 additions & 6 deletions api-gateway/src/helpers/guardians.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ import {
} from '@guardian/interfaces';
import { IAuthUser, NatsService } from '@guardian/common';
import { NewTask } from './task-manager.js';
import { ModuleDTO, TagDTO, ThemeDTO, TokenDTO, ToolDTO } from '#middlewares';
import {
ModuleDTO,
TagDTO,
ThemeDTO,
TokenDTO,
ToolDTO,
StatisticDefinitionDTO,
StatisticAssessmentDTO,
StatisticAssessmentRelationshipsDTO,
StatisticDefinitionRelationshipsDTO
} from '#middlewares';

/**
* Filters type
Expand Down Expand Up @@ -527,7 +537,7 @@ export class Guardians extends NatsService {
* @returns {any} Demo Key
*/
public async generateDemoKey(role: string, userId: string): Promise<any> {
return await this.sendMessage(MessageAPI.GENERATE_DEMO_KEY, {role, userId});
return await this.sendMessage(MessageAPI.GENERATE_DEMO_KEY, { role, userId });
}

/**
Expand All @@ -537,7 +547,7 @@ export class Guardians extends NatsService {
* @param userId
*/
public async generateDemoKeyAsync(role: string, task: NewTask, userId: string): Promise<NewTask> {
return await this.sendMessage(MessageAPI.GENERATE_DEMO_KEY_ASYNC, {role, task, userId});
return await this.sendMessage(MessageAPI.GENERATE_DEMO_KEY_ASYNC, { role, task, userId });
}

/**
Expand Down Expand Up @@ -2823,7 +2833,7 @@ export class Guardians extends NatsService {
* @param pageSize
*/
public async getAllWorkerTasks(user: IAuthUser, pageIndex: number, pageSize: number): Promise<any> {
return this.sendMessage(QueueEvents.GET_TASKS_BY_USER, {userId: user.id.toString(), pageIndex, pageSize});
return this.sendMessage(QueueEvents.GET_TASKS_BY_USER, { userId: user.id.toString(), pageIndex, pageSize });
}

/**
Expand All @@ -2832,7 +2842,7 @@ export class Guardians extends NatsService {
* @param userId
*/
public async restartTask(taskId: string, userId: string) {
return this.sendMessage(QueueEvents.RESTART_TASK, {taskId, userId});
return this.sendMessage(QueueEvents.RESTART_TASK, { taskId, userId });
}

/**
Expand All @@ -2841,6 +2851,180 @@ export class Guardians extends NatsService {
* @param userId
*/
public async deleteTask(taskId: string, userId: string) {
return this.sendMessage(QueueEvents.DELETE_TASK, {taskId, userId});
return this.sendMessage(QueueEvents.DELETE_TASK, { taskId, userId });
}

/**
* Create statistic definition
*
* @param definition
* @param owner
* @returns statistic
*/
public async createStatisticDefinition(definition: StatisticDefinitionDTO, owner: IOwner): Promise<StatisticDefinitionDTO> {
return await this.sendMessage(MessageAPI.CREATE_STATISTIC_DEFINITION, { definition, owner });
}

/**
* Return statistic definitions
*
* @param filters
* @param owner
*
* @returns {ResponseAndCount<StatisticDefinitionDTO>}
*/
public async getStatisticDefinitions(filters: IFilter, owner: IOwner): Promise<ResponseAndCount<StatisticDefinitionDTO>> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_DEFINITIONS, { filters, owner });
}

/**
* Get statistic definition
*
* @param id
* @param owner
* @returns Operation Success
*/
public async getStatisticDefinitionById(definitionId: string, owner: IOwner): Promise<StatisticDefinitionDTO> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_DEFINITION, { definitionId, owner });
}

/**
* Get relationships
*
* @param id
* @param owner
*
* @returns Relationships
*/
public async getStatisticRelationships(definitionId: string, owner: IOwner): Promise<StatisticDefinitionRelationshipsDTO> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_RELATIONSHIPS, { definitionId, owner });
}

/**
* Return documents
*
* @param id
* @param owner
* @param pageIndex
* @param pageSize
*
* @returns {ResponseAndCount<any>}
*/
public async getStatisticDocuments(
definitionId: string,
owner: IOwner,
pageIndex?: number,
pageSize?: number
): Promise<ResponseAndCount<any>> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_DOCUMENTS, { definitionId, owner, pageIndex, pageSize });
}

/**
* Update statistic definition
*
* @param id
* @param definition
* @param owner
*
* @returns theme
*/
public async updateStatisticDefinition(
definitionId: string,
definition: StatisticDefinitionDTO,
owner: IOwner
): Promise<StatisticDefinitionDTO> {
return await this.sendMessage(MessageAPI.UPDATE_STATISTIC_DEFINITION, { definitionId, definition, owner });
}

/**
* Delete statistic definition
*
* @param id
* @param owner
*
* @returns Operation Success
*/
public async deleteStatisticDefinition(definitionId: string, owner: IOwner): Promise<boolean> {
return await this.sendMessage(MessageAPI.DELETE_STATISTIC_DEFINITION, { definitionId, owner });
}

/**
* Delete statistic definition
*
* @param id
* @param owner
*
* @returns Operation Success
*/
public async publishStatisticDefinition(definitionId: string, owner: IOwner): Promise<StatisticDefinitionDTO> {
return await this.sendMessage(MessageAPI.PUBLISH_STATISTIC_DEFINITION, { definitionId, owner });
}

/**
* Create statistic assessment
*
* @param id
* @param report
* @param owner
*
* @returns statistic report
*/
public async createStatisticAssessment(
definitionId: string,
assessment: StatisticAssessmentDTO,
owner: IOwner
): Promise<StatisticAssessmentDTO> {
return await this.sendMessage(MessageAPI.CREATE_STATISTIC_ASSESSMENT, { definitionId, assessment, owner });
}

/**
* Return statistic assessments
*
* @param definitionId
* @param filters
* @param owner
*
* @returns {ResponseAndCount<StatisticAssessmentDTO>}
*/
public async getStatisticAssessments(
definitionId: string,
filters: IFilter,
owner: IOwner
): Promise<ResponseAndCount<StatisticAssessmentDTO>> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_ASSESSMENTS, { definitionId, filters, owner });
}

/**
* Get statistic assessment
*
* @param definitionId
* @param assessmentId
* @param owner
*
* @returns Operation Success
*/
public async getStatisticAssessment(
definitionId: string,
assessmentId: string,
owner: IOwner
): Promise<StatisticAssessmentDTO> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_ASSESSMENT, { definitionId, assessmentId, owner });
}

/**
* Get statistic assessment relationships
*
* @param definitionId
* @param assessmentId
* @param owner
*
* @returns Operation Success
*/
public async getStatisticAssessmentRelationships(
definitionId: string,
assessmentId: string,
owner: IOwner
): Promise<StatisticAssessmentRelationshipsDTO> {
return await this.sendMessage(MessageAPI.GET_STATISTIC_ASSESSMENT_RELATIONSHIPS, { definitionId, assessmentId, owner });
}
}
57 changes: 0 additions & 57 deletions api-gateway/src/middlewares/validation/schemas/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { UserRole } from '@guardian/interfaces';
import { Expose } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
import { Match } from '../../../helpers/decorators/match.validator.js';
import { PolicyDTO } from './policies.dto.js';

export class AccountsResponseDTO {
@ApiProperty()
Expand Down Expand Up @@ -120,62 +119,6 @@ export class CredentialSubjectDTO {
type: string;
}

export class ProofDTO {
@ApiProperty()
type: string;

@ApiProperty()
created: Date;

@ApiProperty()
verificationMethod: string;

@ApiProperty()
proofPurpose: string;

@ApiProperty()
jws: string;
}

export class VcDocumentDTO {
@ApiProperty()
id: string;

@ApiProperty()
type: string[];

@ApiProperty()
issuer: string;

@ApiProperty()
issuanceDate: Date;

@ApiProperty()
'@context': string[]

@ApiProperty()
credentialSubject: CredentialSubjectDTO;

@ApiProperty()
proof: ProofDTO;
}

export class AggregatedDTOItem {
@ApiProperty()
did: string;

@ApiProperty()
hederaAccountId: string;

@ApiProperty()
vcDocument: VcDocumentDTO;

@ApiProperty()
policies: PolicyDTO;
}

export type AggregatedDTO = AggregatedDTOItem[]

class UserDTO {
@ApiProperty()
username: string;
Expand Down
Loading