diff --git a/pyproject.toml b/pyproject.toml index 50ead13..1b19b4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,4 +26,7 @@ reuse-surface = "reuse_surface.cli:main" [tool.setuptools.packages.find] where = ["."] -include = ["reuse_surface*"] \ No newline at end of file +include = ["reuse_surface*"] + +[tool.setuptools.package-data] +reuse_surface = ["hub/hub-registration.schema.yaml"] \ No newline at end of file diff --git a/reuse_surface/hub/hub-registration.schema.yaml b/reuse_surface/hub/hub-registration.schema.yaml new file mode 100644 index 0000000..84bff23 --- /dev/null +++ b/reuse_surface/hub/hub-registration.schema.yaml @@ -0,0 +1,148 @@ +$schema: https://json-schema.org/draft/2020-12/schema +$id: https://reuse-surface.local/schemas/hub-registration.schema.yaml +title: Federation Hub Repo Registration +description: > + Schema for a repository registration stored by the federation hub service. + Extends federation source fields with hub metadata. +type: object +additionalProperties: false +required: [repo, url, enabled, domain] +properties: + repo: + type: string + minLength: 1 + pattern: '^[a-z][a-z0-9-]*$' + description: Stable repository slug (primary key) + url: + type: string + format: uri + pattern: '^https?://' + description: Published HTTP(S) URL to capabilities.yaml + enabled: + type: boolean + required: + type: boolean + default: false + domain: + type: string + minLength: 1 + description: Capability domain label (e.g. helix_forge) + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + default: 86400 + auth_env: + type: string + minLength: 1 + description: > + Hub-side environment variable name holding a token for fetching this + source index (not exposed in API responses) + auth_header: + type: string + minLength: 1 + default: Authorization + registered_at: + type: string + format: date-time + description: Hub metadata — set on create + updated_at: + type: string + format: date-time + description: Hub metadata — set on create/update + registered_by: + type: string + description: Optional actor label from write token or client header +$defs: + registration_request: + type: object + additionalProperties: false + required: [repo, url, domain] + properties: + repo: + type: string + minLength: 1 + pattern: '^[a-z][a-z0-9-]*$' + url: + type: string + format: uri + pattern: '^https?://' + enabled: + type: boolean + default: true + required: + type: boolean + default: false + domain: + type: string + minLength: 1 + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + default: 86400 + auth_env: + type: string + minLength: 1 + auth_header: + type: string + minLength: 1 + default: Authorization + registered_by: + type: string + registration_update: + type: object + additionalProperties: false + properties: + url: + type: string + format: uri + pattern: '^https?://' + enabled: + type: boolean + required: + type: boolean + domain: + type: string + minLength: 1 + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + auth_env: + type: string + minLength: 1 + auth_header: + type: string + minLength: 1 + registered_by: + type: string + minProperties: 1 + repo_list: + type: object + additionalProperties: false + required: [repos, count] + properties: + repos: + type: array + items: + $ref: '#' + count: + type: integer + minimum: 0 + error_response: + type: object + additionalProperties: false + required: [error, message] + properties: + error: + type: string + message: + type: string + details: + type: array + items: + type: string \ No newline at end of file diff --git a/reuse_surface/hub/store.py b/reuse_surface/hub/store.py index 2a3b9ad..56acd19 100644 --- a/reuse_surface/hub/store.py +++ b/reuse_surface/hub/store.py @@ -9,9 +9,7 @@ from typing import Any import yaml from jsonschema import Draft202012Validator -from reuse_surface.registry import ROOT - -SCHEMA_PATH = ROOT / "schemas" / "hub-registration.schema.yaml" +SCHEMA_PATH = Path(__file__).resolve().parent / "hub-registration.schema.yaml" def _utc_now() -> str: