# This repo is intended to be a library of apps used across multiple
# projects, and we want to ensure certain dependency relationships. Please
# think through any changes you make to this file carefully, and don't just
# casually modify these linting rules to "fix the build".

[importlinter]
root_packages =
    openedx_catalog
    openedx_learning
    openedx_content
    openedx_tagging
    openedx_django_lib
    openedx_core

# This is layering between our top-level src folders (mostly Django apps).
# This should be updated as new Django apps are added.
# It's possible this might need to grow into multiple rules.
[importlinter:contract:src_layering]
name = "top-level source folders are layered correctly"
type = layers
layers =
    # Learning-domain features (currently CBE; Learning Pathways to follow).
    # May build on content, catalog and tagging. Nothing below may import it:
    # in particular, openedx_tagging must never know that CBE exists.
    openedx_learning

    # Content: authoring-side models and APIs. May reference catalog models
    # (e.g. to associate content with a CourseRun).
    openedx_content

    # Catalog: the enrollable things (course runs, catalog courses, pathways).
    # Not aware of content; must never import openedx_content. See
    # docs/openedx_catalog/decisions/0001-catalog-models-usage.rst
    openedx_catalog

    # Tagging is very simple & fundamental. Should probably not depend on any other Django apps.
    openedx_tagging

    # Django utilities. Should not depend on any of the real apps (above).
    openedx_django_lib

    # This just an empty shell package, to expose the __version__ number.
    # Should not depend on anything.
    openedx_core

# This is "applet" layering, within our Content djangoapp.
# Every new applet should be added to  this list when it it created.
[importlinter:contract:content_applet_layering]
name = "openedx_content's internal applets are layered correctly"
type = layers
layers=
    # The public API is at the top. None of the internal applets should call to it.
    openedx_content.api

    # The "backup_restore" applet handles the new export and import mechanism.
    openedx_content.applets.backup_restore

    # The "components" applet is responsible for storing versioned Components,
    # which in Open edX Studio terminology maps to things like individual
    # Problems, Videos, and blocks of HTML text. This is also the type we would
    # associate with a single "leaf" XBlock–one that is not a container type and
    # has no child elements.
    # The "containers" app is built on top of publishing, and is a peer to
    # "components" but they do not depend on each other.
    openedx_content.applets.components | openedx_content.applets.containers

    # The "media" applet stores the simplest pieces of binary and text data,
    # without versioning information. These belong to a single Learning Package.
    openedx_content.applets.media

    # The "collections" applet stores arbitrary groupings of PublishableEntities.
    # Its only dependency should be the publishing app.
    openedx_content.applets.collections

    # The lowest layer is "publishing", which holds the basic primitives needed
    # to create Learning Packages and manage the draft and publish states for
    # various types of content.
    openedx_content.applets.publishing
