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

feat: implement processAssociationEvent function #128

Merged
merged 7 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
179 changes: 178 additions & 1 deletion app-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@
"@type": "WebRenderingTemplate2022"
}
],
"type": ["VerifiableCredential", "DigitalTraceabilityEvent"],
"type": ["DigitalTraceabilityEvent"],
"dlrLinkTitle": "Object Event",
"dlrIdentificationKeyType": "gtin",
"dlrVerificationPage": "http://localhost:3003/verify"
Expand Down Expand Up @@ -933,6 +933,183 @@
}
]
},
{
"name": "Issue Association Event",
"id": "issue_association_event",
"components": [
{
"name": "JsonForm",
"type": "EntryData",
"props": {
"schema": {
"url": "https://jargon.sh/user/unece/traceabilityEvents/v/0.5.0/artefacts/jsonSchemas/AssociationEvent.json?class=AssociationEvent"
},
"data": {
"type": ["AssociationEvent", "Event"],
"id": "010501234567890021951350380",
"processType": "Weaving",
"eventTime": "2024-09-01T12:00:00",
"action": "Add",
"disposition": "https://ref.gs1.org/cbv/Disp-active",
"bizStep": "https://ref.gs1.org/cbv/BizStep-commissioning",
"bizLocation": "https://id.gs1.org/414/9520123456788",
"sensorElementList": [
{
"sensorMetadata": {
"device": {
"type": ["Item"],
"id": "https://id.gs1.org/01/09520123456788/21/12345",
"name": "EV battery 300Ah."
},
"dataProcessingMethod": "https://standards.org/sensorMethod#1234"
},
"sensorReport": [
{
"time": "2024-07-24T12:00:00",
"sensorType": "https://samplesensors.com/model1234",
"value": 25,
"uom": "KGM"
},
{
"time": "2024-07-24T12:00:00",
"sensorType": "https://samplesensors.com/model1234",
"value": 25,
"uom": "KGM"
}
],
"sensorIntegrityProof": "https://jargon.sh"
},
{
"sensorMetadata": {
"device": {
"type": ["Item"],
"id": "https://id.gs1.org/01/09520123456788/21/12345",
"name": "EV battery 300Ah."
},
"dataProcessingMethod": "https://standards.org/sensorMethod#1234"
},
"sensorReport": [
{
"time": "2024-07-24T12:00:00",
"sensorType": "https://samplesensors.com/model1234",
"value": 25,
"uom": "KGM"
},
{
"time": "2024-07-24T12:00:00",
"sensorType": "https://samplesensors.com/model1234",
"value": 25,
"uom": "KGM"
}
],
"sensorIntegrityProof": "https://jargon.sh"
}
],
"parentEPC": {
"type": ["Item"],
"id": "https://id.gs1.org/01/09520123456788/21/12345",
"name": "EV battery 300Ah."
},
"childEPCList": [
{
"type": ["Item"],
"id": "https://id.gs1.org/01/09520123456788/21/12345",
"name": "EV battery 300Ah."
},
{
"type": ["Item"],
"id": "https://id.gs1.org/01/09520123456788/21/12345",
"name": "EV battery 300Ah."
}
],
"childQuantityList": [
{
"productId": "https://id.gs1.org/01/09520123456788/21/12345",
"productName": "EV battery 300Ah.",
"quantity": 20,
"uom": "KGM"
},
{
"productId": "https://id.gs1.org/01/09520123456788/21/12345",
"productName": "EV battery 300Ah.",
"quantity": 20,
"uom": "KGM"
}
]
},
"constructData": {
"mappingFields": [],
"dummyFields": [],
"generationFields": [
{
"path": "/eventID",
"handler": "generateIdWithSerialNumber"
}
]
},
"className": "json-form",
"style": {
"margin": "40px auto",
"paddingTop": "40px",
"width": "80%"
}
}
},
{
"name": "CustomButton",
"type": "Submit",
"props": {}
}
],
"services": [
{
"name": "processAssociationEvent",
"parameters": [
{
"vckit": {
"vckitAPIUrl": "http://localhost:3332/v2",
"issuer": "did:web:uncefact.github.io:project-vckit:test-and-development"
},
"epcisAssociationEvent": {
"context": [
"https://jargon.sh/user/unece/traceabilityEvents/v/0.5.0/artefacts/jsonldContexts/traceabilityEvents.jsonld?class=traceabilityEvents"
],
"renderTemplate": [
{
"template": "<div><h2>Association Event</h2></div>",
"@type": "WebRenderingTemplate2022"
}
],
"type": ["DigitalTraceabilityEvent"],
"dlrLinkTitle": "Association Event",
"dlrIdentificationKeyType": "gtin",
"dlrVerificationPage": "http://localhost:3003/verify"
},
"dlr": {
"dlrAPIUrl": "http://localhost:3000",
"dlrAPIKey": "test123",
"namespace": "gs1",
"linkRegisterPath": "/api/resolver"
},
"storage": {
"url": "http://localhost:3334/v1/documents",
"params": {
"resultPath": "/uri",
"bucket": "verifiable-credentials"
},
"options": {
"method": "POST",
"headers": {
"Content-Type": "application/json"
}
}
},
"identifierKeyPath": "/id"
}
]
}
]
},
{
"name": "Issue DIA",
"id": "produce_product",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 26
sidebar_position: 45
title: Process Aggregation Event
---

Expand Down
88 changes: 88 additions & 0 deletions documentation/docs/mock-apps/services/process-association-event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
sidebar_position: 44
title: Process Association Event
---

import Disclaimer from '../../\_disclaimer.mdx';

<Disclaimer />

## Description

The `processAssociationEvent` service is responsible for processing an [Association Event (DTE)](https://uncefact.github.io/spec-untp/docs/specification/DigitalTraceabilityEvents), issuing a [Verifiable Credential (VC)](https://uncefact.github.io/spec-untp/docs/specification/VerifiableCredentials), uploading it to the [Storage service](/docs/mock-apps/dependent-services/storage-service), registering the link to the stored DTE with the [Identity Resolver service](/docs/mock-apps/dependent-services/identity-resolution-service). It handles the entire lifecycle of creating and managing an association event, from data input to storage and resolution.

## Diagram

```mermaid
sequenceDiagram
participant C as Client
participant P as processAssociationEvent
participant V as VCKit
participant S as Storage
participant D as DLR
C->>P: Call processAssociationEvent(associationEvent, context)
P->>P: Validate context
P->>P: Extract identifier
P->>V: Issue VC
V-->>P: Return VC
P->>S: Upload VC
S-->>P: Return VC URL
P->>D: Register link resolver
D-->>P: Return resolver URL
P-->>C: Return association event VC and resolver URL
```

## Example

```json
{
"name": "processAssociationEvent",
"parameters": [
{
"vckit": {
"vckitAPIUrl": "https://api.vckit.example.com",
"issuer": "did:example:123456789abcdefghi"
},
"epcisAssociationEvent": {
"context": [
"https://jargon.sh/user/unece/traceabilityEvents/v/0.5.0/artefacts/jsonldContexts/traceabilityEvents.jsonld?class=traceabilityEvents"
],
"type": ["VerifiableCredential", "DigitalTraceabilityEvent"],
"renderTemplate": [
{
"template": "<div><h2>Association Event</h2></div>",
"@type": "WebRenderingTemplate2022"
}
],
"dlrIdentificationKeyType": "gtin",
"dlrLinkTitle": "Association Event",
"dlrVerificationPage": "https://verify.example.com"
},
"storage": {
"url": "https://storage.example.com/upload",
"params": {
"bucket": "bucket-name",
"resultPath": "/url"
}
},
"dlr": {
"dlrAPIUrl": "https://dlr.example.com/api",
"dlrAPIKey": "dlr-api-key-12345",
"namespace": "gs1",
"linkRegisterPath": "/api/resolver"
},
"identifierKeyPath": "/id"
}
]
}
```

## Definitions

| Property | Required | Description | Type |
| --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| vckit | Yes | Configuration for the VCKit service | [VCKit](/docs/mock-apps/common/vckit) |
| epcisAssociationEvent | Yes | Configuration for the EPCIS Association Event Event | [Credential](/docs/mock-apps/common/credential) |
| storage | Yes | Configuration for storage service | [Storage](/docs/mock-apps/common/storage) |
| dlr | Yes | Configuration for the Digital Link Resolver | [IDR](/docs/mock-apps/common/idr) |
| identifierKeyPath | Yes | JSON path to the identifier in the credential subject or the association for function and arguments of JSON path to construct identifier | [IdentifierKeyPath](/docs/mock-apps/common/identifier-key-path) |
Loading
Loading