Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:hashgraph/guardian into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Stepan-Kirjakov committed Jan 31, 2025
2 parents 0f6f021 + 8dd82b8 commit ee28898
Show file tree
Hide file tree
Showing 34 changed files with 4,583 additions and 4,345 deletions.
2 changes: 1 addition & 1 deletion ai-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@nestjs/common": "^9.4.1",
"@nestjs/core": "^9.4.1",
"@types/express": "^4.17.18",
"@types/node": "^20.8.0",
"@types/node": "^22.10.10",
"dotenv": "^16.3.1",
"module-alias": "^2.2.2",
"express": "^4.18.2",
Expand Down
2 changes: 1 addition & 1 deletion analytics-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@types/gulp": "^4",
"@types/gulp-rename": "^2",
"@types/jszip": "^3.4.1",
"@types/node": "^18.16.0",
"@types/node": "^22.10.10",
"@types/ws": "^8.2.2",
"chai": "^4.3.4",
"cross-env": "^7.0.3",
Expand Down
4 changes: 2 additions & 2 deletions api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Envision Blockchain Solutions <[email protected]>",
"dependencies": {
"@fastify/formbody": "^7.4.0",
"@fastify/multipart": "^8.2.0",
"@fastify/multipart": "^8.3.1",
"@fastify/static": "^7.0.0",
"@guardian/common": "^3.0.0",
"@guardian/interfaces": "^3.0.0",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@types/gulp": "^4",
"@types/gulp-rename": "^2",
"@types/jszip": "^3.4.1",
"@types/node": "^18.16.0",
"@types/node": "^22.10.10",
"@types/ws": "^8.2.2",
"chai": "^4.3.4",
"cross-env": "^7.0.3",
Expand Down
65 changes: 59 additions & 6 deletions api-gateway/src/api/service/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2826,8 +2826,8 @@ export class PolicyApi {
// UserRole.STANDARD_REGISTRY,
)
@ApiOperation({
summary: 'Create dru-run savepoint.',
description: 'Create dru-run savepoint.' + ONLY_SR
summary: 'Create dry-run savepoint.',
description: 'Create dry-run savepoint.' + ONLY_SR
})
@ApiParam({
name: 'policyId',
Expand Down Expand Up @@ -2882,8 +2882,8 @@ export class PolicyApi {
// UserRole.STANDARD_REGISTRY,
)
@ApiOperation({
summary: 'Delete dru-run savepoint.',
description: 'Delete dru-run savepoint.' + ONLY_SR
summary: 'Delete dry-run savepoint.',
description: 'Delete dry-run savepoint.' + ONLY_SR
})
@ApiParam({
name: 'policyId',
Expand Down Expand Up @@ -2929,6 +2929,59 @@ export class PolicyApi {
}
}

/**
* Get savepoint state.
*/
@Get('/:policyId/savepoint/restore')
@Auth(
Permissions.POLICIES_POLICY_UPDATE
// UserRole.STANDARD_REGISTRY,
)
@ApiOperation({
summary: 'Get savepoint state.',
description: 'Get savepoint state.' + ONLY_SR
})
@ApiParam({
name: 'policyId',
type: String,
description: 'Policy Id',
required: true,
example: Examples.DB_ID
})
@ApiBody({
description: '.'
})
@ApiOkResponse({
description: '.'
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO
})
@ApiExtraModels(InternalServerErrorDTO)
@HttpCode(HttpStatus.OK)
async getSavepointState(
@AuthUser() user: IAuthUser,
@Param('policyId') policyId: string,
@Req() req
) {
const engineService = new PolicyEngine();
const owner = new EntityOwner(user);
const policy = await engineService.accessPolicy(policyId, owner, 'read');
if (!PolicyHelper.isDryRunMode(policy)) {
throw new HttpException('Invalid status.', HttpStatus.FORBIDDEN);
}

const invalidedCacheTags = [`${PREFIXES.POLICIES}${policyId}/navigation`, `${PREFIXES.POLICIES}${policyId}/groups`];
await this.cacheService.invalidate(getCacheKey([req.url, ...invalidedCacheTags], user));

try {
return await engineService.getSavepointState(owner, policyId);
} catch (error) {
await InternalException(error, this.logger);
}
}

/**
* Clear dry-run state.
*/
Expand All @@ -2938,8 +2991,8 @@ export class PolicyApi {
// UserRole.STANDARD_REGISTRY,
)
@ApiOperation({
summary: 'Restore dru-run savepoint.',
description: 'Restore dru-run savepoint.' + ONLY_SR
summary: 'Restore dry-run savepoint.',
description: 'Restore dry-run savepoint.' + ONLY_SR
})
@ApiParam({
name: 'policyId',
Expand Down
12 changes: 12 additions & 0 deletions api-gateway/src/helpers/policy-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@ export class PolicyEngine extends NatsService {
return await this.sendMessage(PolicyEngineEvents.RESTORE_SAVEPOINT, {model, owner, policyId});
}

/**
* Get savepoint state
* @param owner
* @param policyId
*/
public async getSavepointState(
owner: IOwner,
policyId: string
) {
return await this.sendMessage(PolicyEngineEvents.GET_SAVEPOINT, {owner, policyId});
}

/**
* Get Virtual Documents
* @param policyId
Expand Down
2 changes: 1 addition & 1 deletion application-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/http-errors": "^2.0.1",
"@types/js-yaml": "^4.0.5",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.9",
"@types/node": "^22.10.10",
"@types/swagger-ui-express": "^4.1.3",
"chai": "^4.3.7",
"chai-http": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion auth-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/gulp": "^4",
"@types/gulp-rename": "^2",
"@types/jsonwebtoken": "^8.5.4",
"@types/node": "^18.16.0",
"@types/node": "^22.10.10",
"@types/node-vault": "^0",
"chai": "^4.3.4",
"cross-env": "^7.0.3",
Expand Down
4 changes: 2 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@nestjs/common": "^9.4.1",
"@nestjs/core": "^9.4.1",
"@nestjs/microservices": "^9.4.1",
"jsonld-signatures": "7.0.0",
"jsonld-signatures": "11.5.0",
"@transmute/credentials-context": "0.7.0-unstable.80",
"@transmute/did-context": "0.7.0-unstable.80",
"@transmute/ed25519-signature-2018": "0.7.0-unstable.80",
Expand Down Expand Up @@ -60,7 +60,7 @@
"@types/gulp": "^4",
"@types/gulp-rename": "^2",
"@types/jszip": "^3.4.1",
"@types/node": "^18.16.0",
"@types/node": "^22.10.10",
"mocha-junit-reporter": "^2.0.2",
"tslint": "^6.1.3",
"typescript": "^4.5.5",
Expand Down
Loading

0 comments on commit ee28898

Please sign in to comment.