openepcis / openepcis-event-sentry

Helps with detecting EPCIS event profile, defines event profile validation rules and validates EPCIS event against them
Apache License 2.0
2 stars 0 forks source link

Develop JSON Schema for Event Profile 'Transformation Event with extension and event Hash ID' #13

Open albert-verdeny opened 2 days ago

albert-verdeny commented 2 days ago

Dear Anish (@anishjain1401 ) and Projjal

This is an Event Profile that combines a number of the atomic units of logic that we collectively identified in our shared Google doc, while trying to minimise overlap with the other event profile tests.

Set of rules

  1. "type" must be TransformationEvent
  2. "readPoint" must not be empty
  3. "eventID" has the syntax of an Event Hash ID, as defined in the CBV (doesn't need to verify that the value is correct)
  4. "bizStep" must be either commissioning or creating_class_instance
  5. The event must contain an extension "ext:eventProfile", where ext maps to http://example.com/ext/ in the "@context"
  6. "bizLocation" must not be empty if output products are specified
  7. "bizLocation" must be empty if no output products are specified

Please let me know if something is unclear.

Best regards, Albert

anishjain1401 commented 1 day ago

Thanks @albert-verdeny , for sharing profile rules - I will reach out to you if something is unclear

projjal-gop commented 1 day ago

Hi @anishjain1401 I have come up with a draft JSON schema can you kindly look into it

{ "$schema": "http://json-schema.org/draft-07/schema#", "allOf": [ { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "@context": { "type": "array", "items": { "anyOf": [ { "type": "string" }, { "type": "object", "patternProperties": { "ext": { "type": "string", "const": "http://example.com/ext/" } }, "additionalProperties": true } ] }, "minItems": 1 }, "type": { "type": "string", "enum": [ "TransformationEvent" ] }, "action": { "type": "string" }, "readPoint": { "type": "object", "properties": { "id": { "type": "string", "minLength": 13 } }, "required": [ "id" ] }, "eventID": { "type": "string", "pattern": "^ni:///sha-256;[a-f0-9]{64}\\?ver=CBV2.0$" }, "bizStep": { "type": "string", "enum": [ "commissioning", "creating_class_instance" ] }, "inputEPCList": { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true }, "outputEPCList": { "type": "array", "items": { "type": "string" }, "minItems": 0, "uniqueItems": true }, "bizLocation": { "type": "object", "properties": { "id": { "type": "string" } }, "required": [ "id" ] }, "ext:eventProfile": { "type": "string" } }, "required": [ "inputEPCList", "outputEPCList", "action", "readPoint", "eventID", "type", "bizStep", "@context", "ext:eventProfile" ], "if": { "properties": { "outputEPCList": { "maxItems": 0 } } }, "then": { "required": [ "inputEPCList", "outputEPCList", "action", "readPoint", "eventID", "type", "bizStep", "@context", "ext:eventProfile" ] }, "else": { "required": [ "inputEPCList", "outputEPCList", "action", "readPoint", "eventID", "type", "bizStep", "@context", "ext:eventProfile", "bizLocation" ] }, "additionalProperties": true } ] }

anishjain1401 commented 13 hours ago

Sure @projjal-gop , thanks for the schema - I will take a look into schema and surely connect with you.