Skip to content

Commit 88b63fd

Browse files
feat: 4743 Data Entry Updatability (#5586)
#4743 Data Entry Updatability
1 parent 75f328d commit 88b63fd

File tree

51 files changed

+2839
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2839
-410
lines changed

api-gateway/src/api/service/policy.ts

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,4 +4440,100 @@ export class PolicyApi {
44404440
}
44414441

44424442
//#endregion
4443+
4444+
//#region VC Docs
4445+
4446+
/**
4447+
* Create new version VC document
4448+
*/
4449+
@Post('/:policyId/create-new-version-vc-document')
4450+
@Auth(
4451+
Permissions.POLICIES_POLICY_EXECUTE,
4452+
Permissions.POLICIES_POLICY_MANAGE,
4453+
)
4454+
@ApiOperation({
4455+
summary: 'Create new version vc document.',
4456+
description: 'Create new version vc document.',
4457+
})
4458+
@ApiParam({
4459+
name: 'policyId',
4460+
type: String,
4461+
description: 'Policy Id',
4462+
required: true,
4463+
example: Examples.DB_ID
4464+
})
4465+
@ApiBody({
4466+
description: 'Data',
4467+
type: Object
4468+
})
4469+
@ApiOkResponse({
4470+
description: 'Successful operation.',
4471+
})
4472+
@ApiInternalServerErrorResponse({
4473+
description: 'Internal server error.',
4474+
type: InternalServerErrorDTO,
4475+
})
4476+
@HttpCode(HttpStatus.OK)
4477+
async createNewVersionVcDocument(
4478+
@AuthUser() user: IAuthUser,
4479+
@Param('policyId') policyId: string,
4480+
@Body() body: any,
4481+
): Promise<any> {
4482+
try {
4483+
const engineService = new PolicyEngine();
4484+
return await engineService.createNewVersionVcDocument(user, policyId, body);
4485+
} catch (error) {
4486+
error.code = HttpStatus.UNPROCESSABLE_ENTITY;
4487+
await InternalException(error, this.logger, user.id);
4488+
}
4489+
}
4490+
4491+
/**
4492+
* Get all version VC documents
4493+
*/
4494+
@Get('/:policyId/get-all-version-vc-documents/:documentId')
4495+
@Auth(
4496+
Permissions.POLICIES_POLICY_EXECUTE,
4497+
Permissions.POLICIES_POLICY_MANAGE,
4498+
)
4499+
@ApiOperation({
4500+
summary: 'Get all version VC documents.',
4501+
description: 'Get all version VC documents.',
4502+
})
4503+
@ApiParam({
4504+
name: 'policyId',
4505+
type: String,
4506+
description: 'Policy Id',
4507+
required: true,
4508+
example: Examples.DB_ID
4509+
})
4510+
@ApiParam({
4511+
name: 'documentId',
4512+
type: String,
4513+
description: 'Document Id',
4514+
required: true,
4515+
example: Examples.DB_ID
4516+
})
4517+
@ApiOkResponse({
4518+
description: 'Successful operation.'
4519+
})
4520+
@ApiInternalServerErrorResponse({
4521+
description: 'Internal server error.',
4522+
type: InternalServerErrorDTO,
4523+
})
4524+
@HttpCode(HttpStatus.OK)
4525+
async getAllVersionVcDocuments(
4526+
@AuthUser() user: IAuthUser,
4527+
@Param('policyId') policyId: string,
4528+
@Param('documentId') documentId: string
4529+
): Promise<any> {
4530+
try {
4531+
const engineService = new PolicyEngine();
4532+
return await engineService.getAllVersionVcDocuments(user, policyId, documentId);
4533+
} catch (error) {
4534+
error.code = HttpStatus.UNPROCESSABLE_ENTITY;
4535+
await InternalException(error, this.logger, user.id);
4536+
}
4537+
}
4538+
//#endregion
44434539
}

api-gateway/src/helpers/policy-engine.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,4 +1572,32 @@ export class PolicyEngine extends NatsService {
15721572
): Promise<{ documents: any[], count: number }> {
15731573
return await this.sendMessage(PolicyEngineEvents.GET_POLICY_REPOSITORY_DOCUMENTS, { user, policyId, filters });
15741574
}
1575+
1576+
/**
1577+
* Create new version policy document
1578+
* @param user
1579+
* @param policyId
1580+
* @param data
1581+
*/
1582+
public async createNewVersionVcDocument(
1583+
user: IAuthUser,
1584+
policyId: string,
1585+
data: any
1586+
): Promise<any> {
1587+
return await this.sendMessage(PolicyEngineEvents.CREATE_NEW_VERSION_VC_DOCUMENT, { user, policyId, data });
1588+
}
1589+
1590+
/**
1591+
* Get all new version policy documents
1592+
* @param user
1593+
* @param policyId
1594+
* @param documentId
1595+
*/
1596+
public async getAllVersionVcDocuments(
1597+
user: IAuthUser,
1598+
policyId: string,
1599+
documentId: string,
1600+
): Promise<any> {
1601+
return await this.sendMessage(PolicyEngineEvents.GET_All_NEW_VERSION_VC_DOCUMENTS, { user, policyId, documentId });
1602+
}
15751603
}

common/src/entity/vc-document.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,18 @@ export class VcDocument extends RestoreEntity implements IVCDocument {
267267
@Property({ persist: false, nullable: true })
268268
_oldTableFileIds?: ObjectId[];
269269

270+
/**
271+
* Last VC Version
272+
*/
273+
@Property({ nullable: true })
274+
oldVersion?: boolean;
275+
276+
/**
277+
* Original VC doc id for revision
278+
*/
279+
@Property({ nullable: true })
280+
initId?: string;
281+
270282
/**
271283
* Document defaults
272284
*/
@@ -323,6 +335,8 @@ export class VcDocument extends RestoreEntity implements IVCDocument {
323335
prop.relayerAccount = this.relayerAccount;
324336
prop.processingStatus = this.processingStatus;
325337
prop.policyId = this.policyId;
338+
prop.oldVersion = this.oldVersion;
339+
prop.initId = this.initId;
326340
return prop;
327341
}
328342

common/src/hedera-modules/message/message-body.interface.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ export interface VcMessageBody extends MessageBody {
297297
* Option
298298
*/
299299
option: any;
300+
/**
301+
* InitId
302+
*/
303+
initId: string;
300304
}
301305

302306
/**
@@ -401,23 +405,23 @@ export interface SynchronizationMessageBody extends MessageBody {
401405
/**
402406
* User DID
403407
*/
404-
user?: string,
408+
user?: string;
405409
/**
406410
* Policy ID (Topic ID)
407411
*/
408-
policy?: string,
412+
policy?: string;
409413
/**
410414
* Policy Type
411415
*/
412-
policyType?: MultiPolicyType,
416+
policyType?: MultiPolicyType;
413417
/**
414418
* Message Id
415419
*/
416-
messageId?: string,
420+
messageId?: string;
417421
/**
418422
* Token Id
419423
*/
420-
tokenId?: string,
424+
tokenId?: string;
421425
/**
422426
* Token amount
423427
*/

common/src/hedera-modules/message/vc-message.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export class VCMessage extends Message {
7272
* Option
7373
*/
7474
public option: any;
75+
/**
76+
* InitId
77+
*/
78+
public initId: string;
7579

7680
constructor(
7781
action: MessageAction,
@@ -98,6 +102,7 @@ export class VCMessage extends Message {
98102
this.document = document.getDocument();
99103
this.hash = document.toCredentialHash();
100104
this.issuer = document.getIssuerDid();
105+
this.initId = document.getInitId();
101106
if (proof.type === SignatureType.BbsBlsSignature2020) {
102107
this.encodedData = true;
103108
} else {
@@ -197,6 +202,14 @@ export class VCMessage extends Message {
197202
this.startMessage = messageId;
198203
}
199204

205+
/**
206+
* Set initId
207+
* @param initId
208+
*/
209+
public setInitId(initId: string): void {
210+
this.initId = initId;
211+
}
212+
200213
/**
201214
* Get documents
202215
*/
@@ -216,6 +229,7 @@ export class VCMessage extends Message {
216229
lang: this.lang,
217230
account: this.account,
218231
issuer: this.issuer,
232+
initId: this.initId,
219233
relationships: this.relationships,
220234
encodedData: this.encodedData,
221235
documentStatus: this.documentStatus,
@@ -309,6 +323,7 @@ export class VCMessage extends Message {
309323
_message._id = json.id;
310324
_message._status = json.status;
311325
_message.issuer = json.issuer;
326+
_message.initId = json.initId;
312327
_message.relationships = json.relationships;
313328
_message.documentStatus = json.documentStatus;
314329
_message.encodedData = json.encodedData || json.type === MessageType.EVCDocument;
@@ -359,6 +374,7 @@ export class VCMessage extends Message {
359374
action: this.action,
360375
lang: this.lang,
361376
issuer: this.issuer,
377+
initId: this.initId,
362378
relationships: this.relationships,
363379
hash: this.hash,
364380
encodedData: this.encodedData,
@@ -386,6 +402,7 @@ export class VCMessage extends Message {
386402
public override toJson(): any {
387403
const result = super.toJson();
388404
result.issuer = this.issuer;
405+
result.initId = this.initId;
389406
result.hash = this.hash;
390407
result.relationships = this.relationships;
391408
result.document = this.document;
@@ -406,6 +423,7 @@ export class VCMessage extends Message {
406423

407424
const result = Message._fromJson(new VCMessage(json.action), json);
408425
result.issuer = json.issuer;
426+
result.initId = json.initId;
409427
result.hash = json.hash;
410428
result.relationships = json.relationships;
411429
result.document = json.document;
@@ -420,9 +438,13 @@ export class VCMessage extends Message {
420438
}
421439

422440
/**
423-
* Get User DID
441+
* Set initId
424442
*/
425443
public override getOwner(): string {
426444
return this.issuer;
427445
}
446+
447+
public setInit(initId: string) {
448+
this.initId = initId;
449+
}
428450
}

common/src/hedera-modules/vcjs/vc-document.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export class VcDocument {
9898
* @protected
9999
*/
100100
protected evidences: any[];
101+
/**
102+
* InitId
103+
* @protected
104+
*/
105+
protected initId: string;
101106

102107
/**
103108
* Constructor
@@ -189,6 +194,23 @@ export class VcDocument {
189194
}
190195
}
191196

197+
/**
198+
* Get initId
199+
*/
200+
public getInitId(): string {
201+
if (this.initId) {
202+
return this.initId;
203+
}
204+
return null;
205+
}
206+
207+
/**
208+
* Set initId
209+
*/
210+
public setInitId(initId: string) {
211+
this.initId = initId;
212+
}
213+
192214
/**
193215
* Get issuance date
194216
*/

common/src/xlsx/xlsx-to-json.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export class XlsxToJson {
316316
readOnly: true,
317317
isPrivate: undefined,
318318
property: undefined,
319+
isUpdatable: false,
319320
});
320321
fields.push({
321322
name: 'ref',
@@ -333,6 +334,7 @@ export class XlsxToJson {
333334
readOnly: true,
334335
isPrivate: undefined,
335336
property: undefined,
337+
isUpdatable: false,
336338
});
337339
fields.push({
338340
name: 'guardianVersion',
@@ -350,6 +352,7 @@ export class XlsxToJson {
350352
readOnly: true,
351353
isPrivate: undefined,
352354
property: undefined,
355+
isUpdatable: false,
353356
});
354357
}
355358
const conditions = conditionCache.map(c => c.toJson());
@@ -390,7 +393,8 @@ export class XlsxToJson {
390393
customType: null,
391394
property: null,
392395
isRef: null,
393-
order: row
396+
order: row,
397+
isUpdatable: false,
394398
};
395399
try {
396400
const key = XlsxToJson.getFieldKey(worksheet, table, row, xlsxResult);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="dialog-body">
2+
{{text}}
3+
</div>
4+
<div class="dialog-footer">
5+
<div class="action-buttons">
6+
<div class="dialog-button">
7+
<button
8+
(click)="onClose()"
9+
class="guardian-button guardian-button-secondary">{{closeBtnName}}</button>
10+
</div>
11+
<div class="dialog-button">
12+
<button
13+
(click)="onSave()"
14+
class="guardian-button guardian-button-primary">{{okBtnName}}</button>
15+
</div>
16+
</div>
17+
</div>

0 commit comments

Comments
 (0)