Skip to content

Commit 1ad8c16

Browse files
authored
Merge pull request #34 from OriginTrail/update/epcis-v2
Update/epcis v2
2 parents 4ef0e13 + dcde78b commit 1ad8c16

17 files changed

Lines changed: 3351 additions & 945 deletions

docs/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
* [Launch an IPO](build-a-dkg-node-ai-agent/advanced-features-and-toolkits/dkg-paranets/initial-paranet-offerings-ipos/launching-your-ipo.md)
4040
* [Incentives pool](build-a-dkg-node-ai-agent/advanced-features-and-toolkits/dkg-paranets/initial-paranet-offerings-ipos/paranets-incentives-pool.md)
4141
* [IPO voting](build-a-dkg-node-ai-agent/advanced-features-and-toolkits/dkg-paranets/initial-paranet-offerings-ipos/ipo-voting.md)
42+
* [Plugins](build-a-dkg-node-ai-agent/plugins/README.md)
43+
* [EPCIS Plugin](build-a-dkg-node-ai-agent/plugins/epcis-plugin.md)
4244
* [Contributing a plugin](build-a-dkg-node-ai-agent/contributing-a-plugin.md)
4345

4446
## Contribute to the DKG 
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Plugins
2+
3+
This section documents plugins that extend DKG Node functionality.
4+
5+
Plugins can expose:
6+
7+
- API endpoints
8+
- MCP tools
9+
- Integration-specific behavior and configuration
10+
11+
## Available Plugins
12+
13+
- [EPCIS Plugin](epcis-plugin.md)
14+
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# EPCIS Plugin
2+
3+
The EPCIS plugin integrates EPCIS 2.0 supply-chain event data with the DKG Node.
4+
5+
It provides both HTTP endpoints and MCP tools for:
6+
7+
- capturing EPCIS documents
8+
- checking capture status
9+
- querying events with filters
10+
- retrieving published assets by UAL
11+
12+
## Source
13+
14+
- Plugin code: `packages/plugin-epcis/src/index.ts`
15+
- Query service: `packages/plugin-epcis/src/services/epcisQueryService.ts`
16+
- Integration guide: `packages/plugin-epcis/docs/EPCIS-Integration-Guide.md`
17+
18+
## Quick Start
19+
20+
1. Ensure publisher plugin and epcis plugin is enabled in server plugin registration:
21+
- `apps/agent/src/server/index.ts` should include `dkgPublisherPlugin` in the `plugins` array.
22+
- `apps/agent/src/server/index.ts` should include `epcisPlugin` in the `plugins` array.
23+
2. Run publisher plugin setup:
24+
- `cd packages/plugin-dkg-publisher && npm run setup`
25+
- This initializes publisher configuration (including `.env.publisher`) for the publisher flow.
26+
3. Configure runtime environment:
27+
- `EXPO_PUBLIC_MCP_URL=http://localhost:9200` (local same-host setup)
28+
4. Start the DKG Node server.
29+
5. Submit an EPCIS document via `POST /epcis/capture`.
30+
6. Query captured events via `GET /epcis/events`.
31+
32+
## Capabilities
33+
34+
### API Endpoints
35+
36+
- `POST /epcis/capture`
37+
Accepts an EPCIS document and sends it to publisher flow.
38+
Returns a numeric `captureID` on success.
39+
40+
- `GET /epcis/capture/:captureID`
41+
Gets publisher-tracked status for numeric capture IDs.
42+
43+
- `GET /epcis/events`
44+
Queries EPCIS events with filtering and pagination.
45+
46+
- `GET /epcis/asset/*ual`
47+
Retrieves an EPCIS asset by UAL.
48+
49+
### MCP Tools
50+
51+
- `epcis-query`
52+
- `epcis-track-item`
53+
54+
## Configuration
55+
56+
Required runtime env var:
57+
58+
- `EXPO_PUBLIC_MCP_URL` (example local setup: `http://localhost:9200`)
59+
60+
Runtime dependency:
61+
62+
- Publisher API must be available through the same server URL (or routed URL) used by `EXPO_PUBLIC_MCP_URL`.
63+
64+
If `EXPO_PUBLIC_MCP_URL` is not set, capture and status calls that depend on publisher will fail.
65+
66+
## Example Requests
67+
68+
### Capture EPCIS document
69+
70+
```bash
71+
curl -X POST "http://localhost:9200/epcis/capture" \
72+
-H "Content-Type: application/json" \
73+
-d '{
74+
"epcisDocument": {
75+
"@context": {
76+
"@vocab": "https://gs1.github.io/EPCIS/",
77+
"epcis": "https://gs1.github.io/EPCIS/",
78+
"cbv": "https://ref.gs1.org/cbv/",
79+
"type": "@type",
80+
"id": "@id"
81+
},
82+
"type": "EPCISDocument",
83+
"schemaVersion": "2.0",
84+
"creationDate": "2024-03-01T08:00:00Z",
85+
"epcisBody": {
86+
"eventList": [
87+
{
88+
"type": "ObjectEvent",
89+
"eventTime": "2024-03-01T08:00:00.000Z",
90+
"eventTimeZoneOffset": "+00:00",
91+
"epcList": ["urn:epc:id:sgtin:4012345.011111.1001"],
92+
"action": "ADD",
93+
"bizStep": "https://ref.gs1.org/cbv/BizStep-receiving",
94+
"disposition": "https://ref.gs1.org/cbv/Disp-in_progress",
95+
"readPoint": { "id": "urn:epc:id:sgln:4012345.00001.0" },
96+
"bizLocation": { "id": "urn:epc:id:sgln:4012345.00001.0" },
97+
"bizTransactionList": [
98+
{
99+
"type": "https://ref.gs1.org/cbv/BTT-po",
100+
"bizTransaction": "urn:epc:id:gdti:4012345.00001.PO-2024-001"
101+
}
102+
]
103+
}
104+
]
105+
}
106+
},
107+
"publishOptions": {
108+
"privacy": "private",
109+
"epochs": 12
110+
}
111+
}'
112+
```
113+
114+
### Check capture status
115+
116+
```bash
117+
curl "http://localhost:9200/epcis/capture/123"
118+
```
119+
120+
### Query events with filters
121+
122+
```bash
123+
curl "http://localhost:9200/epcis/events?epc=urn:epc:id:sgtin:4012345.011111.1001&fullTrace=true&limit=50&offset=0"
124+
```
125+
126+
## Query Notes
127+
128+
- `fullTrace` (HTTP query) supports: `"true"` or `"false"`
129+
- `limit`: integer `1..1000`
130+
- `offset`: integer `>= 0`
131+
- `bizStep` accepts shorthand (for example `assembling`) or full URI
132+
133+
## Response and Validation Notes
134+
135+
- `POST /epcis/capture` validates the EPCIS document structure before publishing.
136+
- `GET /epcis/capture/:captureID` expects numeric capture IDs from publisher responses.
137+
- `GET /epcis/events` rejects invalid pagination and empty-string filter parameters.
138+
139+
## Troubleshooting
140+
141+
- `Publisher endpoint not configured. Set EXPO_PUBLIC_MCP_URL in .env`
142+
Set `EXPO_PUBLIC_MCP_URL` in runtime environment.
143+
144+
- `Invalid captureID format`
145+
Use numeric capture IDs returned by `POST /epcis/capture`.
146+
147+
- `Parameter 'limit' must be an integer between 1 and 1000`
148+
Ensure pagination values are valid integers.
149+
150+
## Related Documentation
151+
152+
For full EPCIS field-level details and examples, see:
153+
154+
- `packages/plugin-epcis/docs/EPCIS-Integration-Guide.md`
155+

package-lock.json

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)