evrythng / epcis2.js

EPCIS 2.0 Javascript SDK
Apache License 2.0
35 stars 4 forks source link

add convenience methods for id-key URIs #9

Closed domguinard closed 3 years ago

domguinard commented 3 years ago

(suggested by Scott at Zebra) Add convenience methods to construct id-key uris...

  const myGcp = '0195500';
  const myProduct = {
                      id: 500406,
                      serialNo: '123456786703'
                    };
  const myLocation = {
                       id: 00001,
                       ext: 0,
                      }

  utils.getSgtinUri(myGcp, myProduct.id, myProduct.serialNo); // returns 'urn:epc:id:sgtin:0195500.500406.123456786703'
  utils.getSglnUri(myGcp, myLocation.id, mylocation.ext); // returns 'urn:epc:id:sgln:0195500.00001.0'
domguinard commented 3 years ago

We are starting to work on this. Do you have in mind which IDs you'd like to get helpers for? Is the list of GS1 primary identifiers what you are after (SGTIN, SGLN, SGRAI, SSCC, etc).

clementh59 commented 3 years ago

With the next version of epcis2.js, you'll be able to easily build a SGTIN URI:

const urn = buildSGTINUri('0614141', '112345', '400'); // returns 'urn:epc:id:sgtin:0614141.112345.400'

Similar function are available for SGLN, SSCC, GRAI, GIAI, GSRN, GSRNP, GDTI, CPI, SGCN, GINC, GSIN, ITIP, GID.

Each function are based on the fields defined in the gs1 official documentation.

domguinard commented 3 years ago

Added to release 1.1.0.