Skip to content

Commit

Permalink
Merge pull request #33 from Mavennet/vc-referencing
Browse files Browse the repository at this point in the history
replace product obj with hash link in creation, transformation, trans…
  • Loading branch information
vivienfan authored Aug 8, 2022
2 parents 9d1c2f1 + e432d15 commit 08e092a
Show file tree
Hide file tree
Showing 32 changed files with 475 additions and 450 deletions.
1 change: 1 addition & 0 deletions lib/events/dto/createProduct/create.dto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export declare class AGENT_CreateProductDTO extends CreateProductDTOBase {
export declare class CORE_CreateProductDTO extends CreateProductDTOBase {
productId: string;
productVC: ProductVCDTO;
productVCHash: string;
eventId: string;
eventVC: CreationEventDetailsDTO;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/events/dto/createProduct/create.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ __decorate([
(0, class_transformer_1.Type)(() => products_1.ProductVCDTO),
__metadata("design:type", products_1.ProductVCDTO)
], CORE_CreateProductDTO.prototype, "productVC", void 0);
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, swagger_1.ApiProperty)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], CORE_CreateProductDTO.prototype, "productVCHash", void 0);
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, swagger_1.ApiProperty)(),
Expand Down
3 changes: 1 addition & 2 deletions lib/events/dto/createProduct/event.credentialSubject.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { PlaceDTO, OrganizationDTO } from '../../../general';
import { ProductDTO } from '../../../products';
import { EVENT_TYPE } from '../../../events';
export declare class AGENT_CreationEventCredentialSubjectDTO {
eventType: EVENT_TYPE;
place: PlaceDTO;
actor: OrganizationDTO[];
products: ProductDTO[];
products: string[];
}
export declare class CORE_CreationEventCredentialSubjectDTO extends AGENT_CreationEventCredentialSubjectDTO {
eventId: string;
Expand Down
4 changes: 1 addition & 3 deletions lib/events/dto/createProduct/event.credentialSubject.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ exports.CORE_CreationEventCredentialSubjectDTO = exports.AGENT_CreationEventCred
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
const general_1 = require("../../../general");
const products_1 = require("../../../products");
const swagger_1 = require("@nestjs/swagger");
const events_1 = require("../../../events");
class AGENT_CreationEventCredentialSubjectDTO {
Expand Down Expand Up @@ -43,8 +42,7 @@ __decorate([
(0, swagger_1.ApiProperty)(),
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => products_1.ProductDTO),
(0, class_validator_1.IsUrl)({ each: true }),
__metadata("design:type", Array)
], AGENT_CreationEventCredentialSubjectDTO.prototype, "products", void 0);
exports.AGENT_CreationEventCredentialSubjectDTO = AGENT_CreationEventCredentialSubjectDTO;
Expand Down
3 changes: 1 addition & 2 deletions lib/events/dto/transfer/event.credentialSubject.dto.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { TRANSFER_EVENT_TYPE } from '../../constants';
import { PlaceDTO, OrganizationDTO } from '../../../general';
import { ProductDTO } from '../../../products';
export declare class AGENT_TransferEventCredentialSubjectDTO {
place: PlaceDTO;
products: ProductDTO[];
products: string[];
actor: OrganizationDTO[];
initiator: string;
receiver: string;
Expand Down
4 changes: 1 addition & 3 deletions lib/events/dto/transfer/event.credentialSubject.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
const constants_1 = require("../../constants");
const general_1 = require("../../../general");
const products_1 = require("../../../products");
class AGENT_TransferEventCredentialSubjectDTO {
}
__decorate([
Expand All @@ -26,8 +25,7 @@ __decorate([
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => products_1.ProductDTO),
(0, class_validator_1.IsUrl)({ each: true }),
__metadata("design:type", Array)
], AGENT_TransferEventCredentialSubjectDTO.prototype, "products", void 0);
__decorate([
Expand Down
3 changes: 1 addition & 2 deletions lib/events/dto/transfer/transfer.dto.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PlaceDTO, OrganizationDTO } from '../../../general';
import { CORE_TransferEventDetailsDTO } from './event.vc.dto';
import { ProductDTO } from '../../../products';
export declare class CORE_TransferProductDTO {
requestId: number;
productId: string;
Expand All @@ -10,6 +9,7 @@ export declare class CORE_TransferProductDTO {
export declare class AGENT_TransferProductDTO {
requestId: number;
productId: string;
productVCHash: string;
place: PlaceDTO;
portOfEntry?: PlaceDTO;
portOfArrival?: PlaceDTO;
Expand All @@ -18,6 +18,5 @@ export declare class AGENT_TransferProductDTO {
receiptLocation?: PlaceDTO;
receiver: string;
price: string;
products: ProductDTO[];
actor: OrganizationDTO[];
}
14 changes: 6 additions & 8 deletions lib/events/dto/transfer/transfer.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const swagger_1 = require("@nestjs/swagger");
const general_1 = require("../../../general");
const class_transformer_1 = require("class-transformer");
const event_vc_dto_1 = require("./event.vc.dto");
const products_1 = require("../../../products");
class CORE_TransferProductDTO {
}
__decorate([
Expand Down Expand Up @@ -58,6 +57,12 @@ __decorate([
(0, class_validator_1.IsUUID)(),
__metadata("design:type", String)
], AGENT_TransferProductDTO.prototype, "productId", void 0);
__decorate([
(0, swagger_1.ApiProperty)(),
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], AGENT_TransferProductDTO.prototype, "productVCHash", void 0);
__decorate([
(0, swagger_1.ApiProperty)(),
(0, class_validator_1.IsNotEmptyObject)(),
Expand Down Expand Up @@ -111,13 +116,6 @@ __decorate([
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], AGENT_TransferProductDTO.prototype, "price", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => products_1.ProductDTO),
__metadata("design:type", Array)
], AGENT_TransferProductDTO.prototype, "products", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
Expand Down
4 changes: 1 addition & 3 deletions lib/events/dto/transform/event.credentialSubject.dto.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PlaceDTO, OrganizationDTO } from '../../../general';
import { TRANSFORMATION_EVENT_TYPE } from '../../constants/transformationEventType';
import { ProductDTO } from '../../../products';
export declare class AGENT_TransformationEventCredentialSubjectDTO {
eventType: TRANSFORMATION_EVENT_TYPE;
place: PlaceDTO;
Expand All @@ -9,7 +8,6 @@ export declare class AGENT_TransformationEventCredentialSubjectDTO {
export declare class CORE_TransformationEventCredentialSubjectDTO extends AGENT_TransformationEventCredentialSubjectDTO {
eventId: string;
eventTime: string;
products: ProductDTO[];
products: string[];
consumedProducts: string[];
newProducts: string[];
}
9 changes: 1 addition & 8 deletions lib/events/dto/transform/event.credentialSubject.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const class_transformer_1 = require("class-transformer");
const general_1 = require("../../../general");
const transformationEventType_1 = require("../../constants/transformationEventType");
const swagger_1 = require("@nestjs/swagger");
const products_1 = require("../../../products");
class AGENT_TransformationEventCredentialSubjectDTO {
}
__decorate([
Expand Down Expand Up @@ -57,18 +56,12 @@ __decorate([
(0, swagger_1.ApiProperty)(),
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => products_1.ProductDTO),
(0, class_validator_1.IsUrl)({ each: true }),
__metadata("design:type", Array)
], CORE_TransformationEventCredentialSubjectDTO.prototype, "products", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
__metadata("design:type", Array)
], CORE_TransformationEventCredentialSubjectDTO.prototype, "consumedProducts", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
__metadata("design:type", Array)
], CORE_TransformationEventCredentialSubjectDTO.prototype, "newProducts", void 0);
exports.CORE_TransformationEventCredentialSubjectDTO = CORE_TransformationEventCredentialSubjectDTO;
5 changes: 3 additions & 2 deletions lib/events/dto/transform/transform.dto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { TransformProductSuccessorDTO } from './transformProductSuccessor.dto';
import { AGENT_TransformationEventCredentialSubjectDTO } from './event.credentialSubject.dto';
import { AGENT_COMPACT_CreateProductDTO } from '../createProduct';
import { CORE_TransformationEventDetailsDTO } from './event.vc.dto';
import { ProductCredentialSubjectDTO, ProductDTO } from '../../../products';
import { ProductCredentialSubjectDTO } from '../../../products';
import { ProductHashDTO } from '../../../general';
export declare class AGENT_COMPACT_TransformProductDTO {
newProducts: AGENT_COMPACT_CreateProductDTO[];
sku?: string;
Expand All @@ -13,7 +14,7 @@ export declare class CORE_TransformProductsDTO {
successors: TransformProductSuccessorDTO[];
}
export declare class AGENT_TransformProductsDTO {
consumedProducts: ProductDTO[];
consumedProducts: ProductHashDTO[];
newProducts: ProductCredentialSubjectDTO[];
eventCredentialSubject: AGENT_TransformationEventCredentialSubjectDTO;
}
3 changes: 2 additions & 1 deletion lib/events/dto/transform/transform.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const event_credentialSubject_dto_1 = require("./event.credentialSubject.dto");
const createProduct_1 = require("../createProduct");
const event_vc_dto_1 = require("./event.vc.dto");
const products_1 = require("../../../products");
const general_1 = require("../../../general");
class AGENT_COMPACT_TransformProductDTO {
}
__decorate([
Expand Down Expand Up @@ -65,7 +66,7 @@ __decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => products_1.ProductDTO),
(0, class_transformer_1.Type)(() => general_1.ProductHashDTO),
__metadata("design:type", Array)
], AGENT_TransformProductsDTO.prototype, "consumedProducts", void 0);
__decorate([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { ProductVCDTO } from '../../../products/dto/product.vc.dto';
export declare class TransformProductSuccessorDTO {
productId: string;
productVC: ProductVCDTO;
productVCHash: string;
}
5 changes: 5 additions & 0 deletions lib/events/dto/transform/transformProductSuccessor.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ __decorate([
(0, class_transformer_1.Type)(() => product_vc_dto_1.ProductVCDTO),
__metadata("design:type", product_vc_dto_1.ProductVCDTO)
], TransformProductSuccessorDTO.prototype, "productVC", void 0);
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], TransformProductSuccessorDTO.prototype, "productVCHash", void 0);
exports.TransformProductSuccessorDTO = TransformProductSuccessorDTO;
6 changes: 5 additions & 1 deletion lib/events/dto/transport/event.credentialSubject.dto.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { EventDTO } from '../../../general';
import { EventDTO, ProductHashDTO, PlaceDTO, OrganizationDTO } from '../../../general';
import { TRANSPORTATION_TYPE, TRANSPORT_EVENT_TYPE } from '../../constants';
export declare class AGENT_TransportationEventCredentialSubjectDTO {
eventType: TRANSPORT_EVENT_TYPE;
place: PlaceDTO;
actor: OrganizationDTO[];
products: ProductHashDTO[];
deliveryMethod: TRANSPORTATION_TYPE;
trackingNumber: string;
scn: string;
Expand Down
26 changes: 26 additions & 0 deletions lib/events/dto/transport/event.credentialSubject.dto.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,37 @@ var __metadata = (this && this.__metadata) || function (k, v) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.CORE_TransportationEventCredentialSubjectDTO = exports.AGENT_TransportationEventCredentialSubjectDTO = void 0;
const class_validator_1 = require("class-validator");
const class_transformer_1 = require("class-transformer");
const general_1 = require("../../../general");
const constants_1 = require("../../constants");
const constants_2 = require("../../../products/constants");
class AGENT_TransportationEventCredentialSubjectDTO {
}
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsEnum)(constants_1.TRANSPORT_EVENT_TYPE),
__metadata("design:type", String)
], AGENT_TransportationEventCredentialSubjectDTO.prototype, "eventType", void 0);
__decorate([
(0, class_validator_1.IsNotEmptyObject)(),
(0, class_validator_1.ValidateNested)(),
(0, class_transformer_1.Type)(() => general_1.PlaceDTO),
__metadata("design:type", general_1.PlaceDTO)
], AGENT_TransportationEventCredentialSubjectDTO.prototype, "place", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => general_1.OrganizationDTO),
__metadata("design:type", Array)
], AGENT_TransportationEventCredentialSubjectDTO.prototype, "actor", void 0);
__decorate([
(0, class_validator_1.IsArray)(),
(0, class_validator_1.ArrayMinSize)(1),
(0, class_validator_1.ValidateNested)({ each: true }),
(0, class_transformer_1.Type)(() => general_1.ProductHashDTO),
__metadata("design:type", Array)
], AGENT_TransportationEventCredentialSubjectDTO.prototype, "products", void 0);
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsEnum)(constants_1.TRANSPORTATION_TYPE),
Expand Down
1 change: 1 addition & 0 deletions lib/general/dto/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export * from './parcelDelivery.dto';
export * from './physicalSpecs.dto';
export * from './place.dto';
export * from './postalAddress.dto';
export * from './productHash.dto';
export * from './property.dto';
export * from './proof.dto';
1 change: 1 addition & 0 deletions lib/general/dto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ __exportStar(require("./parcelDelivery.dto"), exports);
__exportStar(require("./physicalSpecs.dto"), exports);
__exportStar(require("./place.dto"), exports);
__exportStar(require("./postalAddress.dto"), exports);
__exportStar(require("./productHash.dto"), exports);
__exportStar(require("./property.dto"), exports);
__exportStar(require("./proof.dto"), exports);
4 changes: 4 additions & 0 deletions lib/general/dto/productHash.dto.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class ProductHashDTO {
productId: string;
productVCHash: string;
}
26 changes: 26 additions & 0 deletions lib/general/dto/productHash.dto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductHashDTO = void 0;
const class_validator_1 = require("class-validator");
class ProductHashDTO {
}
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsUUID)(),
__metadata("design:type", String)
], ProductHashDTO.prototype, "productId", void 0);
__decorate([
(0, class_validator_1.IsNotEmpty)(),
(0, class_validator_1.IsString)(),
__metadata("design:type", String)
], ProductHashDTO.prototype, "productVCHash", void 0);
exports.ProductHashDTO = ProductHashDTO;
Loading

0 comments on commit 08e092a

Please sign in to comment.