Skip to content

Commit

Permalink
Merge pull request #35 from evrythng/latest_schema_updates
Browse files Browse the repository at this point in the history
Latest schema updates
  • Loading branch information
PercheEtienne authored May 18, 2022
2 parents 69bf5e8 + c9734da commit d834a70
Show file tree
Hide file tree
Showing 27 changed files with 917 additions and 905 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ EPCIS 2.0 brings the following highlights to the table:

## Installation

### NPM

Install as an app dependency:

```
Expand Down Expand Up @@ -51,6 +53,21 @@ import { setup } from 'epcis2.js';
import * as epcis from 'epcis2.js';
```

### CDN

Or use a simple script tag to load it from the CDN:
```html
<script src="https://cdn.jsdelivr.net/npm/epcis2.js@2.2.0/dist/epcis2.browser.js"></script>
```

Then use in a browser `script` tag using the `epcis2` global variable:
```html
<script>
const doc = new epcis2.EPCISDocument();
</script>
```


## Getting started example

Thanks to our SDK, creating an EPCIS 2.0 document is simple. In this example, we show how to create it
Expand Down Expand Up @@ -516,3 +533,8 @@ Finally run `node example_with_creation_from_setters.js`.
1. Before deploying, make sure to run the linter: `npm run lint`.

2. Make sure to run the unit tests: `npm run test`.

### Versioning

When contributing, please make sure to update the version of the library in the `package.json` file. You'll also need to
update the CDN links in the `README` as well as the `example/web-example/index.html`'s CDN link.
2 changes: 1 addition & 1 deletion example/node_example/example_with_creation_from_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { ObjectEvent, setup, EPCISDocument, capture, fieldNames, eventEpcRelType
// you can override the global parameter with the setup function
setup({
apiUrl: 'https://api.evrythng.io/v2/epcis/',
EPCISDocumentContext: 'https://id.gs1.org/epcis-context.jsonld',
EPCISDocumentContext: 'https://ref.gs1.org/standards/epcis/2.0/epcis-context.jsonld',
EPCISDocumentSchemaVersion: '2.0',
headers: {
'content-type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion example/node_example/example_with_creation_from_setters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
// you can override the global parameter with the setup function
setup({
apiUrl: 'https://api.evrythng.io/v2/epcis/',
EPCISDocumentContext: 'https://id.gs1.org/epcis-context.jsonld',
EPCISDocumentContext: 'https://ref.gs1.org/standards/epcis/2.0/epcis-context.jsonld',
EPCISDocumentSchemaVersion: '2.0',
headers: {
'content-type': 'application/json',
Expand Down
14 changes: 5 additions & 9 deletions example/node_example/example_with_full_possibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
AssociationEvent,
ObjectEvent,
ExtendedEvent,
EPCISDocument,
EPCISDocument,
EPCISHeader,
EPCISMasterData,
ErrorDeclaration,
Expand All @@ -20,7 +20,7 @@ const {
SensorElement,
BizLocation,
Ilmd,
setup,
setup,
capture,
cbv,
vtype
Expand All @@ -35,7 +35,7 @@ setup({
},
eventTimeZoneOffset: '-02:00',
timeout: '3000',
EPCISDocumentContext: 'https://id.gs1.org/epcis-context.jsonld',
EPCISDocumentContext: 'https://ref.gs1.org/standards/epcis/2.0/epcis-context.jsonld',
EPCISDocumentSchemaVersion: '2.0',
documentValidation: true,
validationMode: 'fast' //'full' otherwise
Expand Down Expand Up @@ -343,10 +343,6 @@ const buildAssociationEvent = () => {
"ext1:string": "string"
}
],
"persistentDisposition": {
"set": ["completeness_verified"],
"unset": ["completeness_inferred"]
},
"ext1:float": "20",
"ext1:time": "2013-06-08T14:58:56.591Z",
"ext1:array": [
Expand Down Expand Up @@ -405,7 +401,7 @@ const buildExtendedEvent = () => {
const buildEPCISMasterDataExample = () => {
return new EPCISMasterData({
vocabularyList: [
{
{
type: vtype.BusinessLocationID,
vocabularyElementList: [
{
Expand Down Expand Up @@ -530,4 +526,4 @@ const sendACaptureRequestExample = async () => {
}
}

sendACaptureRequestExample();
sendACaptureRequestExample();
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@
"bizLocation":{
"id":"urn:epc:id:sgln:0614141.00888.0"
},
"persistentDisposition":{
"set":[
"completeness_verified"
],
"unset":[
"completeness_inferred"
]
},
"ext1:float":"20",
"ext1:time":"2013-06-08T14:58:56.591Z",
"ext1:array":[
Expand Down
2 changes: 1 addition & 1 deletion example/react-example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
// you can override the global parameter with the setup function
setup({
apiUrl: 'https://api.evrythng.io/v2/epcis/',
EPCISDocumentContext: 'https://id.gs1.org/epcis-context.jsonld',
EPCISDocumentContext: 'https://ref.gs1.org/standards/epcis/2.0/epcis-context.jsonld',
EPCISDocumentSchemaVersion: '2.0',
headers: {
'content-type': 'application/json',
Expand Down
21 changes: 21 additions & 0 deletions example/web-example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>EPCIS2.js demo</title>
<script src="https://cdn.jsdelivr.net/npm/epcis2.js@2.2.0/dist/epcis2.browser.js" defer></script>
<script>
window.onload = () => {
const doc = new epcis2.EPCISDocument();
console.log(doc.toObject());
document.getElementById('epcisDocument').innerText = JSON.stringify(doc.toObject());
}
</script>
</head>
<body>
EPCISDocument:
<br/>
<br/>
<div id="epcisDocument"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "epcis2.js",
"version": "2.1.0",
"version": "2.2.0",
"description": "Javascript SDK for the EPCIS 2.0 standard",
"main": "dist/epcis2.node.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/entity/events/AggregationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Event, { fieldToFunctions } from './Event';

const invalidFields = ['ilmd', 'epcList', 'quantityList'];
const invalidFields = ['ilmd', 'epcList', 'quantityList', 'persistentDisposition'];

export default class AggregationEvent extends Event {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/entity/events/AssociationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Event, { fieldToFunctions } from './Event';

const invalidFields = ['ilmd', 'epcList', 'quantityList'];
const invalidFields = ['ilmd', 'epcList', 'quantityList', 'persistentDisposition'];

export default class AssociationEvent extends Event {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/entity/events/TransactionEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Event, { fieldToFunctions } from './Event';

const invalidFields = ['ilmd', 'childEPCs', 'childQuantityList'];
const invalidFields = ['ilmd', 'childEPCs', 'childQuantityList', 'persistentDisposition'];

export default class TransactionEvent extends Event {
/**
Expand Down
Loading

0 comments on commit d834a70

Please sign in to comment.