From 1539a3d1ab0b743f2d2e620bf50cb53c8057781b Mon Sep 17 00:00:00 2001 From: simvalery Date: Tue, 6 Feb 2024 20:33:16 +0400 Subject: [PATCH] hotfix 2.21.1: fix update worker settings propagation (#3203) * fix update worker settings Signed-off-by: artembuslaev * fix Signed-off-by: artembuslaev * update version Signed-off-by: simvalery Signed-off-by: simvalery * [skip ci] Add swagger.yaml * update settings Signed-off-by: simvalery Signed-off-by: simvalery * fix fint Signed-off-by: simvalery Signed-off-by: simvalery --------- Signed-off-by: artembuslaev Signed-off-by: simvalery Co-authored-by: artembuslaev Co-authored-by: envision-ci-agent --- ai-service/package.json | 2 +- analytics-service/package.json | 6 +- api-gateway/package.json | 6 +- api-tests/package.json | 2 +- auth-service/package.json | 6 +- common/package.json | 4 +- frontend/package.json | 2 +- .../copy-schema-dialog/copy-schema-dialog.ts | 1 - .../schema-configuration.component.ts | 1 - .../service-status.component.ts | 1 - .../settings-view.component.html | 34 ++--- .../settings-view/settings-view.component.ts | 126 +++++++++++------- .../src/app/views/login/login.component.ts | 1 - .../app/views/schemas/schemas.component.ts | 1 - guardian-service/package.json | 6 +- interfaces/package.json | 2 +- logger-service/package.json | 6 +- mrv-sender/package.json | 4 +- notification-service/package.json | 6 +- package.json | 2 +- policy-service/package.json | 6 +- swagger-analytics.yaml | 2 +- swagger.yaml | 2 +- topic-viewer/package.json | 2 +- tree-viewer/package.json | 2 +- worker-service/package.json | 6 +- worker-service/src/api/worker.ts | 25 ++-- 27 files changed, 141 insertions(+), 123 deletions(-) diff --git a/ai-service/package.json b/ai-service/package.json index a9712abd88..09b301ee09 100644 --- a/ai-service/package.json +++ b/ai-service/package.json @@ -1,6 +1,6 @@ { "name": "ai-service", - "version": "2.21.0", + "version": "2.21.1", "main": "dist/app.js", "license": "MIT", "dependencies": { diff --git a/analytics-service/package.json b/analytics-service/package.json index 469f9de0d1..26579f8aeb 100644 --- a/analytics-service/package.json +++ b/analytics-service/package.json @@ -13,8 +13,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@nestjs/common": "^9.4.1", "@nestjs/core": "^9.4.1", "@nestjs/jwt": "^10.0.3", @@ -81,5 +81,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/api-gateway/package.json b/api-gateway/package.json index ac2f097bae..1bbac8f1e4 100644 --- a/api-gateway/package.json +++ b/api-gateway/package.json @@ -12,8 +12,8 @@ }, "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@nestjs/common": "^9.4.1", "@nestjs/core": "^9.4.1", "@nestjs/jwt": "^10.0.3", @@ -82,5 +82,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/api-tests/package.json b/api-tests/package.json index 0c87e55e3a..2bdeaf1082 100644 --- a/api-tests/package.json +++ b/api-tests/package.json @@ -1,6 +1,6 @@ { "name": "api-tests", - "version": "2.21.0", + "version": "2.21.1", "description": "API Tests", "main": "index.js", "scripts": { diff --git a/auth-service/package.json b/auth-service/package.json index 19270a93b5..b6d86deb6b 100644 --- a/auth-service/package.json +++ b/auth-service/package.json @@ -10,8 +10,8 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@meeco/cryppo": "^2.0.2", "@mikro-orm/core": "5.7.12", "@mikro-orm/mongodb": "5.7.12", @@ -74,5 +74,5 @@ "start": "node dist/index.js", "test": "mocha tests/**/*.test.js --reporter mocha-junit-reporter --reporter-options mochaFile=../test_results/ui-service.xml" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/common/package.json b/common/package.json index c86e51c182..6294a73e42 100644 --- a/common/package.json +++ b/common/package.json @@ -5,7 +5,7 @@ "@azure/identity": "^3.2.2", "@azure/keyvault-secrets": "^4.7.0", "@google-cloud/secret-manager": "^4.2.2", - "@guardian/interfaces": "^2.21.0", + "@guardian/interfaces": "^2.21.1", "@hashgraph/sdk": "2.34.1", "@mattrglobal/jsonld-signatures-bbs": "^1.1.2", "@meeco/cryppo": "^2.0.2", @@ -83,5 +83,5 @@ "test:local": "mocha tests/**/*.test.js --exit", "test:stability": "mocha tests/stability.test.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/frontend/package.json b/frontend/package.json index b12053c67c..005ee533a0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -74,5 +74,5 @@ "test": "ng test", "watch": "ng build --watch --configuration development --output-path ../www-data" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/frontend/src/app/modules/schema-engine/copy-schema-dialog/copy-schema-dialog.ts b/frontend/src/app/modules/schema-engine/copy-schema-dialog/copy-schema-dialog.ts index 5259c68924..114c71a371 100644 --- a/frontend/src/app/modules/schema-engine/copy-schema-dialog/copy-schema-dialog.ts +++ b/frontend/src/app/modules/schema-engine/copy-schema-dialog/copy-schema-dialog.ts @@ -53,7 +53,6 @@ export class CopySchemaDialog { this.policies = data.policies || []; this.modules = data.modules || []; this.tools = data.tools || []; - console.log(this); } public get isSystem(): boolean { diff --git a/frontend/src/app/modules/schema-engine/schema-configuration/schema-configuration.component.ts b/frontend/src/app/modules/schema-engine/schema-configuration/schema-configuration.component.ts index 866e2d2230..b043eaf152 100644 --- a/frontend/src/app/modules/schema-engine/schema-configuration/schema-configuration.component.ts +++ b/frontend/src/app/modules/schema-engine/schema-configuration/schema-configuration.component.ts @@ -191,7 +191,6 @@ export class SchemaConfigurationComponent implements OnInit { isRef: false, customType: 'hederaAccount' }; - console.log(this); } get currentEntity(): any { diff --git a/frontend/src/app/views/admin/service-status/service-status.component.ts b/frontend/src/app/views/admin/service-status/service-status.component.ts index 3aa6bf6a24..0d6035f546 100644 --- a/frontend/src/app/views/admin/service-status/service-status.component.ts +++ b/frontend/src/app/views/admin/service-status/service-status.component.ts @@ -21,7 +21,6 @@ export class ServiceStatusComponent implements OnInit { private route: ActivatedRoute, private router: Router ) { - console.log(this); this.servicesStates = this.wsService.getServicesStatesArray(); this.last = this.route?.snapshot?.queryParams?.last; try { diff --git a/frontend/src/app/views/admin/settings-view/settings-view.component.html b/frontend/src/app/views/admin/settings-view/settings-view.component.html index 29e9466dd0..967ea895ed 100644 --- a/frontend/src/app/views/admin/settings-view/settings-view.component.html +++ b/frontend/src/app/views/admin/settings-view/settings-view.component.html @@ -1,26 +1,3 @@ - -
@@ -53,8 +30,15 @@

Settings

- + +
+
+ +
diff --git a/frontend/src/app/views/admin/settings-view/settings-view.component.ts b/frontend/src/app/views/admin/settings-view/settings-view.component.ts index 05e48943ba..fd9d521588 100644 --- a/frontend/src/app/views/admin/settings-view/settings-view.component.ts +++ b/frontend/src/app/views/admin/settings-view/settings-view.component.ts @@ -1,55 +1,85 @@ -import { Component, OnInit } from '@angular/core'; -import { FormBuilder, Validators } from '@angular/forms'; +import { Component, OnDestroy, OnInit } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { CommonSettings } from '@guardian/interfaces'; import { SettingsService } from 'src/app/services/settings.service'; +import { Subscription } from 'rxjs' @Component({ - selector: 'app-settings-view', - templateUrl: './settings-view.component.html', + selector: 'app-settings-view', + templateUrl: './settings-view.component.html', styleUrls: ['./settings-view.component.scss'] }) -export class SettingsViewComponent implements OnInit { - dataForm = this.fb.group({ - operatorId: ['', Validators.compose([ - Validators.required, - Validators.pattern(/^\d+\.\d+\.\d+$/) - ])], - operatorKey: ['', Validators.compose([ - Validators.required, - Validators.minLength(5) - ])], - ipfsStorageApiKey: ['', Validators.compose([ - Validators.required, - Validators.minLength(5) - ])] - }); - isLoading: boolean = true; - - constructor( - private fb: FormBuilder, - private settingsService: SettingsService) { - } - - ngOnInit() { - this.settingsService.getSettings() - .subscribe((result: CommonSettings) => { - this.dataForm.patchValue(result); - this.isLoading = false - }, (error) => { - this.isLoading = true - }); - } - - onSubmit() { - if (this.dataForm.valid) { - this.isLoading = true; - this.settingsService.updateSettings(this.dataForm.value) - .subscribe(() => { - this.isLoading = false; - }, () => { - this.isLoading = false; - this.ngOnInit(); - }); - } - } +export class SettingsViewComponent implements OnInit, OnDestroy{ + dataForm = this.fb.group({ + operatorId: [ + '', Validators.compose([ + Validators.required, + Validators.pattern(/^\d+\.\d+\.\d+$/) + ])], + operatorKey: [ + '', Validators.compose([ + Validators.required, + Validators.minLength(5) + ])], + ipfsStorageApiKey: [ + '', Validators.compose([ + Validators.required, + Validators.minLength(5) + ])] + }); + isLoading: boolean = true; + + keyAndProof = this.fb.group({ + key: ['', Validators.required], + proof: ['', Validators.required] + }) + + private subscription: Subscription; + + constructor( + private fb: FormBuilder, + private settingsService: SettingsService) { + this.subscription = new Subscription(); + } + + ngOnInit() { + this.subscription.add( + this.settingsService.getSettings() + .subscribe((result: CommonSettings) => { + this.dataForm.patchValue(result); + this.isLoading = false + }, (error) => { + this.isLoading = true + }) + ); + + this.subscription.add( + this.keyAndProof.valueChanges.subscribe(values => { + this.dataForm.patchValue({ + ipfsStorageApiKey: `${values.key};${values.proof}` + }) + }) + ); + } + + getFormControl(formGroup: FormGroup, name: string): FormControl { + return formGroup.get(name) as FormControl; + } + + ngOnDestroy() { + this.subscription.unsubscribe() + } + + onSubmit() { + if (this.dataForm.valid) { + this.isLoading = true; + this.settingsService.updateSettings(this.dataForm.value) + .subscribe(() => { + this.isLoading = false; + }, () => { + this.isLoading = false; + this.ngOnInit(); + }); + } + } } diff --git a/frontend/src/app/views/login/login.component.ts b/frontend/src/app/views/login/login.component.ts index 14f4c80eed..8777ccf142 100644 --- a/frontend/src/app/views/login/login.component.ts +++ b/frontend/src/app/views/login/login.component.ts @@ -72,7 +72,6 @@ export class LoginComponent implements OnInit, OnDestroy { } ngOnInit() { - console.log(this); this.testUsers$ = this.otherService.getAllUsers(); this.loading = false; this.redirect().finally(() => { diff --git a/frontend/src/app/views/schemas/schemas.component.ts b/frontend/src/app/views/schemas/schemas.component.ts index ebc15fcf8c..6ddf65b20d 100644 --- a/frontend/src/app/views/schemas/schemas.component.ts +++ b/frontend/src/app/views/schemas/schemas.component.ts @@ -184,7 +184,6 @@ export class SchemaConfigComponent implements OnInit { const topic = this.route.snapshot.queryParams['topic']; this.type = this.getType(type); this.currentTopic = topic && topic !== 'all' ? topic : ''; - console.log(this); this.loadProfile(); } diff --git a/guardian-service/package.json b/guardian-service/package.json index 7ddb9e11ce..5a7babc504 100644 --- a/guardian-service/package.json +++ b/guardian-service/package.json @@ -16,8 +16,8 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@hashgraph/sdk": "2.34.1", "@mattrglobal/jsonld-signatures-bbs": "^1.1.2", "@meeco/cryppo": "^2.0.2", @@ -98,5 +98,5 @@ "test:local": "mocha tests/**/*.test.js --exit", "test:stability": "mocha tests/stability.test.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/interfaces/package.json b/interfaces/package.json index dc8f526607..b9d53c8ed1 100644 --- a/interfaces/package.json +++ b/interfaces/package.json @@ -32,5 +32,5 @@ "prepack": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/logger-service/package.json b/logger-service/package.json index 69c3736dee..8af7d224b6 100644 --- a/logger-service/package.json +++ b/logger-service/package.json @@ -5,8 +5,8 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@mikro-orm/core": "5.7.12", "@mikro-orm/mongodb": "5.7.12", "@nestjs/common": "^9.4.1", @@ -53,5 +53,5 @@ "start": "node dist/index.js", "watch": "nodemon src/index.ts" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/mrv-sender/package.json b/mrv-sender/package.json index 5e34ada85d..b7a89fccd0 100644 --- a/mrv-sender/package.json +++ b/mrv-sender/package.json @@ -5,7 +5,7 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "^2.21.0", + "@guardian/common": "^2.21.1", "@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", @@ -43,5 +43,5 @@ "dev:docker": "nodemon .", "start": "node dist/index.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/notification-service/package.json b/notification-service/package.json index 3b115ccbb9..fe003e4b42 100644 --- a/notification-service/package.json +++ b/notification-service/package.json @@ -5,8 +5,8 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@mikro-orm/core": "5.7.12", "@mikro-orm/mongodb": "5.7.12", "@nestjs/common": "^9.4.1", @@ -52,5 +52,5 @@ "start": "node dist/index.js", "watch": "nodemon src/index.ts" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/package.json b/package.json index b08a3ae2dd..ccf19e6045 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "ai-service", "notification-service" ], - "version": "2.21.0", + "version": "2.21.1", "devDependencies": { "detect-secrets": "^1.0.6" }, diff --git a/policy-service/package.json b/policy-service/package.json index df30469a9b..21296934bd 100644 --- a/policy-service/package.json +++ b/policy-service/package.json @@ -15,8 +15,8 @@ "image-size": "1.0.2" }, "dependencies": { - "@guardian/common": "2.21.0", - "@guardian/interfaces": "2.21.0", + "@guardian/common": "2.21.1", + "@guardian/interfaces": "2.21.1", "@hashgraph/sdk": "2.34.1", "@mattrglobal/jsonld-signatures-bbs": "^1.1.2", "@meeco/cryppo": "2.0.2", @@ -96,5 +96,5 @@ "test:local": "mocha tests/**/*.test.js", "test:stability": "mocha tests/stability.test.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/swagger-analytics.yaml b/swagger-analytics.yaml index 126aba3f53..a013c2f23e 100644 --- a/swagger-analytics.yaml +++ b/swagger-analytics.yaml @@ -208,7 +208,7 @@ info: the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation. - version: 2.21.0 + version: 2.21.1 contact: name: API developer url: https://envisionblockchain.com diff --git a/swagger.yaml b/swagger.yaml index b29c040f23..ee9936f103 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -9823,7 +9823,7 @@ info: the heart of the Guardian solution is a sophisticated Policy Workflow Engine (PWE) that enables applications to offer a requirements-based tokenization implementation. - version: 2.21.0 + version: 2.21.1 contact: name: API developer url: https://envisionblockchain.com diff --git a/topic-viewer/package.json b/topic-viewer/package.json index 0b7e628cc2..4652b8a541 100644 --- a/topic-viewer/package.json +++ b/topic-viewer/package.json @@ -29,5 +29,5 @@ "dev": "tsc -w", "start": "node dist/index.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/tree-viewer/package.json b/tree-viewer/package.json index ce6dd53a80..a548bc0835 100644 --- a/tree-viewer/package.json +++ b/tree-viewer/package.json @@ -27,5 +27,5 @@ "dev": "tsc -w", "start": "node dist/index.js" }, - "version": "2.21.0" + "version": "2.21.1" } diff --git a/worker-service/package.json b/worker-service/package.json index c31f513e17..edd49555a1 100644 --- a/worker-service/package.json +++ b/worker-service/package.json @@ -1,8 +1,8 @@ { "author": "Envision Blockchain Solutions ", "dependencies": { - "@guardian/common": "^2.21.0", - "@guardian/interfaces": "^2.21.0", + "@guardian/common": "^2.21.1", + "@guardian/interfaces": "^2.21.1", "@hashgraph/sdk": "2.34.1", "@nestjs/common": "^9.4.1", "@nestjs/core": "^9.4.1", @@ -64,5 +64,5 @@ }, "type": "module", "types": "dist/index.d.ts", - "version": "2.21.0" + "version": "2.21.1" } diff --git a/worker-service/src/api/worker.ts b/worker-service/src/api/worker.ts index 13fa0ab798..c58d36da8d 100644 --- a/worker-service/src/api/worker.ts +++ b/worker-service/src/api/worker.ts @@ -1,4 +1,4 @@ -import { Logger, MessageBrokerChannel, MessageResponse, NatsService, NotificationHelper, Users, ValidateConfiguration } from '@guardian/common'; +import { Logger, MessageBrokerChannel, MessageResponse, NatsService, NotificationHelper, SecretManager, Users, } from '@guardian/common'; import { ExternalMessageEvents, GenerateUUIDv4, ITask, ITaskResult, WorkerEvents, WorkerTaskType } from '@guardian/interfaces'; import { HederaSDKHelper, NetworkOptions } from './helpers/hedera-sdk-helper'; import { IpfsClientClass } from './ipfs-client-class'; @@ -97,8 +97,8 @@ export class Worker extends NatsService { private readonly taskTimeout: number; constructor( - private readonly w3cKey: string, - private readonly w3cProof: string + private w3cKey: string, + private w3cProof: string ) { super(); this.ipfsClient = new IpfsClientClass( @@ -191,12 +191,21 @@ export class Worker extends NatsService { this.subscribe(WorkerEvents.UPDATE_SETTINGS, async (msg: any) => { try { - this.ipfsClient = new IpfsClientClass( - this.w3cKey, - this.w3cProof + const ipfsStorageApiKey = msg?.ipfsStorageApiKey; + if (!ipfsStorageApiKey) { + throw new Error('Ipfs storage api key setting is empty'); + } + const [w3cKey, w3cProof] = ipfsStorageApiKey.split(';'); + const ipfsClient = new IpfsClientClass( + w3cKey, + w3cProof ); - const validator = new ValidateConfiguration(); - await validator.validate(); + await ipfsClient.createClient(); + this.w3cKey = w3cKey; + this.w3cProof = w3cProof; + this.ipfsClient = ipfsClient; + const secretManager = SecretManager.New(); + await secretManager.setSecrets('apikey/ipfs', { IPFS_STORAGE_API_KEY: ipfsStorageApiKey }); } catch (error) { this.logger.error(`Update settings error, ${error.message}`, ['WORKER']); }