Skip to main content

Shared data models and validation helpers for UnitySVC packages

Project description

unitysvc-core

Shared data models, JSON schemas, and validation helpers for the UnitySVC ecosystem. This package is audience-neutral: it contains only the foundational types and helpers that are consumed by the UnitySVC backend, the customer SDK, the admin CLI, and the seller SDK.

It intentionally does not include any CLI, HTTP client, or audience-specific helpers. Those live in the corresponding packages:

  • unitysvc-sellers — seller SDK + usvc_seller CLI, catalog builders (populate_from_iterator, render_template_file, convert_convenience_fields_to_documents, etc.)
  • unitysvc — customer SDK + usvc CLI
  • unitysvc-admin — admin CLI

What's inside

src/unitysvc_core/
├── models/
│   ├── base.py            # All enums (status, type, currency, rate-limit, etc.)
│   ├── pricing.py         # PriceStr, UsageData, all *PriceData classes,
│   │                      # Pricing union, validate_pricing, cost calculation
│   ├── documents.py       # DocumentData
│   ├── service.py         # RateLimit, ServiceConstraints, AccessInterfaceData,
│   │                      # UpstreamAccessConfigData
│   ├── validators.py      # validate_name, validate_service_options,
│   │                      # suggest_valid_name, SUPPORTED_SERVICE_OPTIONS
│   ├── provider_v1.py     # Provider file schema + ProviderData
│   ├── offering_v1.py     # Offering file schema + ServiceOfferingData
│   ├── listing_v1.py      # Listing file schema + ServiceListingData
│   ├── promotion_v1.py    # Promotion file schema + PromotionData
│   └── service_group_v1.py
├── schema/                # Generated JSON schemas
├── validator.py           # DataValidator — per-file schema validation,
│                          # union-field reference checks, API-key secret
│                          # scanning, Jinja2 syntax validation, etc.
└── utils.py               # Content hashing, mime/extension helpers,
                           # data file loaders (JSON/TOML + overrides),
                           # schema-based file discovery

What's deliberately NOT here

  • CLI codetyper, rich, no entry points
  • HTTP clients — no httpx, no API wrappers
  • Seller catalog builderspopulate_from_iterator, render_template_file, convert_convenience_fields_to_documents, execute_script_content live in unitysvc-sellers
  • Seller-catalog-layout validationvalidate_provider_status, validate_all_service_directories, resolve_provider_name, resolve_service_name_for_listing live in unitysvc-sellers

Installation

pip install unitysvc-core

Dependencies: pydantic, email-validator, jsonschema, jinja2, json5, tomli-w. No typer, no rich, no httpx.

Usage

from pathlib import Path

import unitysvc_core
from unitysvc_core.models import ProviderV1, OfferingV1, ListingV1
from unitysvc_core.models.pricing import UsageData, validate_pricing
from unitysvc_core.validator import DataValidator

# Validate a single catalog directory
validator = DataValidator(
    data_dir=Path("./catalog"),
    schema_dir=Path(unitysvc_core.__file__).parent / "schema",
)
results = validator.validate_all()

# Typed pricing + cost calculation
pricing = validate_pricing({
    "type": "one_million_tokens",
    "input": "0.50",
    "output": "1.50",
})
cost = pricing.calculate_cost(UsageData(input_tokens=1_000, output_tokens=500))

History

This package was split out of unitysvc-services (see unitysvc/unitysvc-services#99). The seller CLI, catalog builders, and seller-catalog-layout validators moved to unitysvc-sellers.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitysvc_core-0.1.2.tar.gz (75.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitysvc_core-0.1.2-py3-none-any.whl (76.6 kB view details)

Uploaded Python 3

File details

Details for the file unitysvc_core-0.1.2.tar.gz.

File metadata

  • Download URL: unitysvc_core-0.1.2.tar.gz
  • Upload date:
  • Size: 75.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unitysvc_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 326d7b8cdb99b841a9e523e989512aee3d4aed6e74dc85681d5c5f6f1cef4240
MD5 f6e5ae75b83700237c2b96e7b10274ff
BLAKE2b-256 c5ee6ef2f9c29713b26890af418c8db6ff7d03ea85627617beed7c536ec6c5a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitysvc_core-0.1.2.tar.gz:

Publisher: publish.yml on unitysvc/unitysvc-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unitysvc_core-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: unitysvc_core-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 76.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unitysvc_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e519ccc4cfd75ebf52e1b340901e045bd5ed8eb1461a2ccb30c8d2123c475848
MD5 7a69a208f17b8e1af78bcd1a42aa2324
BLAKE2b-256 fd8bba205490f29cd30be52c2b6ec711144164e5538a50f1a4a4b1dba85d93ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitysvc_core-0.1.2-py3-none-any.whl:

Publisher: publish.yml on unitysvc/unitysvc-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page