{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "SGC internal warehouse fulfilment feed v1", "description": "Committed delivery and receipt facts. Quantity is in thousandths of the original item unit. This feed is not a stock replication command or current balance projection.", "type": "object", "required": ["schema", "items", "has_more", "next_cursor"], "properties": { "schema": { "const": "sgc.warehouse.fulfilment-feed.v1" }, "items": { "type": "array", "maxItems": 100, "items": { "$ref": "#/$defs/event" } }, "has_more": { "type": "boolean" }, "next_cursor": { "type": "string", "minLength": 1 } }, "$defs": { "id": { "type": "integer", "minimum": 1 }, "registry": { "type": "object", "required": ["id", "code", "name"], "properties": { "id": { "$ref": "#/$defs/id" }, "code": { "type": "string" }, "name": { "type": "string" } } }, "actor": { "type": "object", "required": ["id", "name"], "properties": { "id": { "$ref": "#/$defs/id" }, "name": { "type": "string" } } }, "line": { "type": "object", "required": ["request_line_index", "item", "quantity_milli", "use", "destination", "equipment", "stock_operation_id"], "properties": { "request_line_index": { "type": "integer", "minimum": 0 }, "item": { "allOf": [ { "$ref": "#/$defs/registry" }, { "required": ["unit"], "properties": { "unit": { "type": "string" } } } ] }, "quantity_milli": { "type": "integer", "minimum": 1 }, "use": { "enum": ["internal", "equipment"] }, "destination": { "type": "string" }, "equipment": { "oneOf": [ { "type": "null" }, { "type": "object", "required": ["id", "code", "description"], "properties": { "id": { "$ref": "#/$defs/id" }, "code": { "type": "string" }, "description": { "type": "string" } } } ] }, "stock_operation_id": { "$ref": "#/$defs/id" } } }, "event": { "type": "object", "required": ["schema", "idempotency_key", "tenant_id", "event_id", "event_version", "action", "occurred_at", "actor", "request", "lines", "delivery_event_key", "payload_sha256"], "properties": { "schema": { "const": "sgc.warehouse.fulfilment-event.v1" }, "idempotency_key": { "type": "string", "pattern": "^sgc:[1-9][0-9]*:warehouse-event:[1-9][0-9]*$" }, "tenant_id": { "$ref": "#/$defs/id" }, "event_id": { "$ref": "#/$defs/id" }, "event_version": { "type": "integer", "minimum": 1 }, "action": { "enum": ["deliver", "receive"] }, "occurred_at": { "type": "string", "format": "date-time" }, "actor": { "$ref": "#/$defs/actor" }, "request": { "type": "object", "required": ["id", "reference", "document_type", "work_context_key", "requester", "warehouse", "cost_center", "destination"], "properties": { "id": { "$ref": "#/$defs/id" }, "reference": { "type": "string", "pattern": "^RA-[1-9][0-9]*$" }, "document_type": { "const": "internal_warehouse_request" }, "work_context_key": { "enum": ["procurement.internal", null] }, "requester": { "$ref": "#/$defs/actor" }, "warehouse": { "$ref": "#/$defs/registry" }, "cost_center": { "$ref": "#/$defs/registry" }, "destination": { "type": "string" } } }, "lines": { "type": "array", "maxItems": 50, "items": { "$ref": "#/$defs/line" } }, "delivery_event_key": { "type": ["string", "null"] }, "payload_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" } }, "oneOf": [ { "properties": { "action": { "const": "deliver" }, "lines": { "minItems": 1 }, "delivery_event_key": { "type": "null" } } }, { "properties": { "action": { "const": "receive" }, "lines": { "maxItems": 0 }, "delivery_event_key": { "type": "string", "pattern": "^sgc:[1-9][0-9]*:warehouse-event:[1-9][0-9]*$" } } } ] } } }