{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openjuvenile.org/schemas/v0.1/core.schema.json",
  "title": "Product record – core",
  "description": "A product record describes one sellable product variant, identified by its GTIN. The core contains identity, brand, manufacturer, dimensions, weights, multilingual texts and status. Compliance, media, compatibility and category profiles are separate modules referenced from here.",
  "$comment": "Draft 0.1 – open for comment. Field levels: MUST = listed in `required`; otherwise `x-openjuvenile-level` is should, may or conditional.",
  "type": "object",
  "properties": {
    "$schema": {
      "description": "URI of the schema the record conforms to, so that editors can validate it.",
      "type": "string",
      "format": "uri",
      "x-openjuvenile-level": "may",
      "examples": ["https://openjuvenile.org/schemas/v0.1/core.schema.json"]
    },
    "specVersion": {
      "description": "Version of the specification the record conforms to.",
      "type": "string",
      "enum": ["0.1"],
      "examples": ["0.1"]
    },
    "gtin": {
      "$ref": "#/$defs/gtin",
      "description": "Global Trade Item Number of this product variant: 8, 12, 13 or 14 digits with a valid check digit. Primary identifier of the record."
    },
    "brand": {
      "description": "The brand under which the product is sold.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Brand name as shown on the product and its packaging.",
          "type": "string",
          "minLength": 1,
          "examples": ["Example Brand"]
        },
        "website": {
          "$ref": "#/$defs/url",
          "description": "Website of the brand.",
          "x-openjuvenile-level": "may"
        }
      },
      "required": ["name"],
      "additionalProperties": false
    },
    "manufacturer": {
      "$ref": "#/$defs/party",
      "description": "The manufacturer of the product. GPSR Art. 19 requires the manufacturer's name, postal and electronic address in every online offer."
    },
    "euResponsiblePerson": {
      "$ref": "#/$defs/responsiblePerson",
      "description": "The person established in the EU who is responsible for the product when the manufacturer is established outside the EU (GPSR Art. 19).",
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "The manufacturer is established outside the EU (manufacturer.postalAddress.country is not an EU member state)."
    },
    "modelName": {
      "description": "Model name as used by the brand, without variant details such as colour.",
      "type": "string",
      "minLength": 1,
      "examples": ["Pebble Travel Stroller"]
    },
    "modelNumber": {
      "description": "The manufacturer's article number for this model or variant.",
      "type": "string",
      "minLength": 1,
      "x-openjuvenile-level": "should",
      "examples": ["EB-PTS-26"]
    },
    "modelYear": {
      "description": "Model year as communicated by the brand.",
      "type": "integer",
      "minimum": 1990,
      "maximum": 2100,
      "x-openjuvenile-level": "may",
      "examples": [2026]
    },
    "variant": {
      "description": "What distinguishes this variant from other variants of the same model.",
      "type": "object",
      "properties": {
        "colorName": {
          "$ref": "#/$defs/localizedString",
          "description": "Colour name as communicated to consumers, per language.",
          "x-openjuvenile-level": "should"
        },
        "colorCode": {
          "description": "Colour code used by the brand in its own systems.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "may",
          "examples": ["GRA"]
        },
        "size": {
          "description": "Size designation, if the model is available in sizes.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "may",
          "examples": ["74/80"]
        }
      },
      "additionalProperties": false,
      "x-openjuvenile-level": "should"
    },
    "category": {
      "description": "Product category. The category code determines which category profile applies.",
      "type": "object",
      "properties": {
        "code": {
          "description": "Category code of this standard. Records with code stroller or car-seat MUST contain the matching profile.",
          "$comment": "TODO(review): the category list is a first draft and follows the planned profiles.",
          "type": "string",
          "enum": [
            "stroller",
            "car-seat",
            "nursery-furniture",
            "mattress",
            "carrier",
            "feeding",
            "textile",
            "safety-product",
            "toy",
            "other"
          ],
          "examples": ["stroller"]
        },
        "gs1GpcBrick": {
          "description": "GS1 Global Product Classification (GPC) brick code: 8 digits.",
          "type": "string",
          "pattern": "^\\d{8}$",
          "x-openjuvenile-level": "should"
        }
      },
      "required": ["code"],
      "additionalProperties": false
    },
    "title": {
      "$ref": "#/$defs/localizedString",
      "description": "Product title for listings, per language."
    },
    "shortDescription": {
      "$ref": "#/$defs/localizedString",
      "description": "One or two sentences that describe the product, per language.",
      "x-openjuvenile-level": "should"
    },
    "description": {
      "$ref": "#/$defs/localizedString",
      "description": "Full product description, per language. Plain text; paragraphs are separated by a blank line.",
      "x-openjuvenile-level": "should"
    },
    "keyFeatures": {
      "description": "Short feature statements in order of importance, each per language.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/localizedString",
        "description": "One feature statement, per language."
      },
      "minItems": 1,
      "x-openjuvenile-level": "may"
    },
    "ageRange": {
      "description": "Age range the product is intended for, as stated by the manufacturer.",
      "type": "object",
      "properties": {
        "minMonths": {
          "description": "Minimum age in months.",
          "type": "integer",
          "minimum": 0,
          "examples": [0]
        },
        "maxMonths": {
          "description": "Maximum age in months.",
          "type": "integer",
          "minimum": 0,
          "x-openjuvenile-level": "should",
          "examples": [48]
        }
      },
      "required": ["minMonths"],
      "additionalProperties": false,
      "x-openjuvenile-level": "should"
    },
    "dimensions": {
      "description": "Outer dimensions in centimetres.",
      "type": "object",
      "properties": {
        "assembled": {
          "$ref": "#/$defs/dimensions",
          "description": "Dimensions of the product ready for use."
        },
        "packaged": {
          "$ref": "#/$defs/dimensions",
          "description": "Dimensions of the retail packaging.",
          "x-openjuvenile-level": "should"
        }
      },
      "required": ["assembled"],
      "additionalProperties": false
    },
    "weight": {
      "description": "Weights in kilograms.",
      "type": "object",
      "properties": {
        "netKg": {
          "description": "Weight of the product without packaging, in kg.",
          "type": "number",
          "exclusiveMinimum": 0,
          "examples": [6.9]
        },
        "grossKg": {
          "description": "Weight including the retail packaging, in kg.",
          "type": "number",
          "exclusiveMinimum": 0,
          "x-openjuvenile-level": "should",
          "examples": [8.4]
        }
      },
      "required": ["netKg"],
      "additionalProperties": false
    },
    "countryOfOrigin": {
      "$ref": "#/$defs/countryCode",
      "description": "Country of origin of the product.",
      "x-openjuvenile-level": "should"
    },
    "lifecycle": {
      "description": "Market status of the product.",
      "type": "object",
      "properties": {
        "status": {
          "description": "announced: not yet available · active: available · discontinued: no longer produced.",
          "type": "string",
          "enum": ["announced", "active", "discontinued"],
          "examples": ["active"]
        },
        "launchDate": {
          "$ref": "#/$defs/date",
          "description": "Date from which the product is or was available.",
          "x-openjuvenile-level": "should"
        },
        "discontinuedDate": {
          "$ref": "#/$defs/date",
          "description": "Date from which the product is no longer produced.",
          "x-openjuvenile-level": "conditional",
          "x-openjuvenile-condition": "status is discontinued."
        }
      },
      "required": ["status"],
      "additionalProperties": false,
      "x-openjuvenile-level": "should",
      "if": {
        "properties": { "status": { "const": "discontinued" } },
        "required": ["status"]
      },
      "then": { "required": ["discontinuedDate"] }
    },
    "profiles": {
      "description": "Category profiles with category-specific fields, keyed by profile name. The profile that matches category.code MUST be present.",
      "type": "object",
      "properties": {
        "stroller": {
          "$ref": "profiles/stroller.schema.json",
          "description": "Profile for strollers, prams and buggies.",
          "x-openjuvenile-level": "conditional",
          "x-openjuvenile-condition": "category.code is stroller."
        },
        "carSeat": {
          "$ref": "profiles/car-seat.schema.json",
          "description": "Profile for child car seats.",
          "x-openjuvenile-level": "conditional",
          "x-openjuvenile-condition": "category.code is car-seat."
        }
      },
      "additionalProperties": false,
      "x-openjuvenile-level": "conditional",
      "x-openjuvenile-condition": "category.code has a category profile (stroller, car-seat)."
    },
    "compliance": {
      "$ref": "compliance.schema.json",
      "description": "Compliance module: markets, regulations, standards, test reports, warnings and Digital Product Passport."
    },
    "media": {
      "$ref": "media.schema.json",
      "description": "Media module: images, documents, videos and 3D/AR models."
    },
    "compatibility": {
      "$ref": "compatibility.schema.json",
      "description": "Compatibility module: products this product can be combined with.",
      "x-openjuvenile-level": "may"
    }
  },
  "required": [
    "specVersion",
    "gtin",
    "brand",
    "manufacturer",
    "modelName",
    "category",
    "title",
    "dimensions",
    "weight",
    "compliance",
    "media"
  ],
  "patternProperties": {
    "^x-": {
      "description": "Extension fields. Names start with x- and are ignored by consumers that do not know them."
    }
  },
  "additionalProperties": false,
  "allOf": [
    {
      "$comment": "GPSR Art. 19: EU responsible person for manufacturers established outside the EU.",
      "if": {
        "properties": {
          "manufacturer": {
            "properties": {
              "postalAddress": {
                "properties": {
                  "country": { "not": { "$ref": "#/$defs/euMemberState" } }
                },
                "required": ["country"]
              }
            },
            "required": ["postalAddress"]
          }
        },
        "required": ["manufacturer"]
      },
      "then": { "required": ["euResponsiblePerson"] }
    },
    {
      "if": {
        "properties": {
          "category": { "properties": { "code": { "const": "stroller" } }, "required": ["code"] }
        },
        "required": ["category"]
      },
      "then": {
        "required": ["profiles"],
        "properties": { "profiles": { "required": ["stroller"] } }
      }
    },
    {
      "if": {
        "properties": {
          "category": { "properties": { "code": { "const": "car-seat" } }, "required": ["code"] }
        },
        "required": ["category"]
      },
      "then": {
        "required": ["profiles"],
        "properties": { "profiles": { "required": ["carSeat"] } }
      }
    }
  ],
  "$defs": {
    "gtin": {
      "description": "GTIN-8, GTIN-12, GTIN-13 or GTIN-14 with a valid GS1 check digit.",
      "type": "string",
      "pattern": "^(\\d{8}|\\d{12}|\\d{13}|\\d{14})$",
      "format": "gtin",
      "examples": ["9521234567899"]
    },
    "localizedString": {
      "description": "Text per language. Keys are BCP 47 language tags (for example en, de, de-AT), values are non-empty strings. At least one language.",
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$"
      },
      "additionalProperties": { "type": "string", "minLength": 1 },
      "minProperties": 1,
      "examples": [{ "en": "Graphite", "de": "Graphit" }]
    },
    "countryCode": {
      "description": "ISO 3166-1 alpha-2 country code in upper case.",
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "examples": ["AT"]
    },
    "euMemberState": {
      "description": "ISO 3166-1 alpha-2 codes of the EU member states.",
      "type": "string",
      "enum": [
        "AT",
        "BE",
        "BG",
        "CY",
        "CZ",
        "DE",
        "DK",
        "EE",
        "ES",
        "FI",
        "FR",
        "GR",
        "HR",
        "HU",
        "IE",
        "IT",
        "LT",
        "LU",
        "LV",
        "MT",
        "NL",
        "PL",
        "PT",
        "RO",
        "SE",
        "SI",
        "SK"
      ]
    },
    "languageCode": {
      "description": "BCP 47 language tag.",
      "type": "string",
      "pattern": "^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$",
      "examples": ["en"]
    },
    "url": {
      "description": "Absolute https or http URL.",
      "type": "string",
      "format": "uri",
      "pattern": "^https?://",
      "examples": ["https://example.com"]
    },
    "email": {
      "description": "Email address.",
      "type": "string",
      "format": "email",
      "examples": ["productsafety@example.com"]
    },
    "date": {
      "description": "Calendar date in ISO 8601 format (YYYY-MM-DD).",
      "type": "string",
      "format": "date",
      "examples": ["2026-02-01"]
    },
    "dimensions": {
      "description": "Length, width and height in centimetres.",
      "type": "object",
      "properties": {
        "lengthCm": {
          "description": "Length (depth) in cm.",
          "type": "number",
          "exclusiveMinimum": 0,
          "examples": [85]
        },
        "widthCm": {
          "description": "Width in cm.",
          "type": "number",
          "exclusiveMinimum": 0,
          "examples": [48]
        },
        "heightCm": {
          "description": "Height in cm.",
          "type": "number",
          "exclusiveMinimum": 0,
          "examples": [104]
        }
      },
      "required": ["lengthCm", "widthCm", "heightCm"],
      "additionalProperties": false
    },
    "postalAddress": {
      "description": "Postal address.",
      "type": "object",
      "properties": {
        "streetAddress": {
          "description": "Street and house number, or post office box.",
          "type": "string",
          "minLength": 1,
          "examples": ["1 Example Street"]
        },
        "postalCode": {
          "description": "Postal code, if the country uses postal codes.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "should",
          "examples": ["1010"]
        },
        "locality": {
          "description": "City or town.",
          "type": "string",
          "minLength": 1,
          "examples": ["Example City"]
        },
        "region": {
          "description": "State, province or region, where part of the address.",
          "type": "string",
          "minLength": 1,
          "x-openjuvenile-level": "may"
        },
        "country": {
          "$ref": "#/$defs/countryCode",
          "description": "Country of the address (ISO 3166-1 alpha-2)."
        }
      },
      "required": ["streetAddress", "locality", "country"],
      "additionalProperties": false
    },
    "party": {
      "description": "An economic operator with contact details.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Name of the company.",
          "type": "string",
          "minLength": 1,
          "examples": ["Example Brand Ltd."]
        },
        "postalAddress": {
          "$ref": "#/$defs/postalAddress",
          "description": "Postal address at which the company can be contacted."
        },
        "email": {
          "$ref": "#/$defs/email",
          "description": "Electronic address at which the company can be contacted."
        },
        "website": {
          "$ref": "#/$defs/url",
          "description": "Website of the company.",
          "x-openjuvenile-level": "should"
        }
      },
      "required": ["name", "postalAddress", "email"],
      "additionalProperties": false
    },
    "responsiblePerson": {
      "description": "The EU responsible person with contact details.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Name of the company or person.",
          "type": "string",
          "minLength": 1,
          "examples": ["Example EU Representative GmbH"]
        },
        "postalAddress": {
          "$ref": "#/$defs/postalAddress",
          "description": "Postal address in the EU."
        },
        "email": {
          "$ref": "#/$defs/email",
          "description": "Electronic address at which the responsible person can be contacted."
        }
      },
      "required": ["name", "postalAddress", "email"],
      "additionalProperties": false
    }
  }
}
