codapact 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "CodaPact generation manifest v1",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "version": {"const": 1, "type": "integer"},
8
+ "contract": {
9
+ "type": "object", "additionalProperties": false,
10
+ "properties": {
11
+ "source": {"type": "string", "minLength": 1},
12
+ "type": {"const": "openapi"},
13
+ "allow_private": {"type": "boolean"}
14
+ }
15
+ },
16
+ "output": {
17
+ "type": "object", "additionalProperties": false,
18
+ "properties": {"directory": {"type": "string", "minLength": 1}}
19
+ },
20
+ "client": {
21
+ "type": "object", "additionalProperties": false,
22
+ "properties": {
23
+ "language": {"const": "python"},
24
+ "package": {"type": "string", "minLength": 1}
25
+ }
26
+ },
27
+ "cli": {
28
+ "type": "object", "additionalProperties": false,
29
+ "properties": {
30
+ "style": {"const": "argparse"},
31
+ "slug": {"type": "string", "minLength": 1},
32
+ "definition": {"type": ["string", "null"], "minLength": 1}
33
+ }
34
+ },
35
+ "runtime": {
36
+ "type": "object", "additionalProperties": false,
37
+ "properties": {
38
+ "config_directory": {"type": ["string", "null"], "minLength": 1},
39
+ "defaults": {
40
+ "type": "object", "additionalProperties": false,
41
+ "properties": {
42
+ "base_url": {"type": ["string", "null"], "minLength": 1},
43
+ "timeout": {"type": "number", "exclusiveMinimum": 0, "maximum": 120},
44
+ "allow_private": {"type": "boolean"},
45
+ "policy": {
46
+ "type": "object", "additionalProperties": false,
47
+ "properties": {
48
+ "allow": {"type": ["array", "null"], "items": {"type": "string"}},
49
+ "deny": {"type": "array", "items": {"type": "string"}}
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
codapact/values.py ADDED
@@ -0,0 +1,33 @@
1
+ """Shared data-only merge and safe naming rules."""
2
+
3
+ import re
4
+ from copy import deepcopy
5
+ from typing import Any
6
+
7
+ from codapact.errors import CodaError
8
+
9
+
10
+ def merge(base: dict[str, Any], update: dict[str, Any]) -> dict[str, Any]:
11
+ """Merge maps recursively; empty maps reset, lists/scalars/null replace."""
12
+ result = deepcopy(base)
13
+ for key, value in update.items():
14
+ result[key] = (
15
+ merge(result[key], value)
16
+ if isinstance(value, dict) and value and isinstance(result.get(key), dict)
17
+ else deepcopy(value)
18
+ )
19
+ return result
20
+
21
+
22
+ def slug_name(value: str) -> str:
23
+ if (
24
+ not re.fullmatch(r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*", value)
25
+ or len(value) > 50
26
+ or re.fullmatch(r"(?:con|prn|aux|nul|com[0-9]|lpt[0-9])", value)
27
+ ):
28
+ raise CodaError("slug must be a safe lowercase name with optional hyphens")
29
+ return value
30
+
31
+
32
+ def default_slug(package: str) -> str:
33
+ return slug_name(re.sub(r"-+", "-", package.replace("_", "-")).strip("-"))
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: codapact
3
+ Version: 0.1.0
4
+ Summary: Contracts into callable tools: pluggable API client and CLI generation.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Dist: pyyaml>=6.0.3,<7
8
+ Requires-Dist: jsonschema>=4.25.1,<5
9
+ Requires-Python: >=3.13
10
+ Project-URL: Homepage, https://github.com/mikejhill/codapact
11
+ Project-URL: Documentation, https://github.com/mikejhill/codapact#readme
12
+ Project-URL: Changelog, https://github.com/mikejhill/codapact/blob/main/CHANGELOG.md
13
+ Project-URL: Issues, https://github.com/mikejhill/codapact/issues
14
+ Description-Content-Type: text/markdown
15
+
16
+ # CodaPact
17
+
18
+ ![CodaPact wordmark](branding/wordmark.svg)
19
+
20
+ **Contracts into callable tools.**
21
+
22
+ This first iteration generates an installable, typed Python client and a
23
+ scriptable CLI from a local or remote OpenAPI contract. The package, module, and
24
+ generator CLI are named `codapact`. Install a published release with
25
+ `uv tool install codapact`, or use the source workflow below.
26
+
27
+ ```powershell
28
+ uv sync
29
+ uv run codapact generate examples/pets.yaml --output .tmp/pets-client --package pets_client
30
+ uv build
31
+ uv pip install --no-deps .tmp/pets-client
32
+ uv run pets-client --config examples/runtime.json get-pet --arg-pet-id 7
33
+ ```
34
+
35
+ The example server address is intentionally inert. Override `base_url` with your
36
+ own trusted endpoint and set the environment variable referenced by the runtime
37
+ configuration. Tests use isolated loopback HTTP servers and synthetic credentials.
38
+
39
+ ```python
40
+ from pets_client import Client
41
+
42
+ client = Client(settings={"auth": {"token": {"env": "PETS_TOKEN"}}})
43
+ pet = client.get_pet(parameters={"pet_id": 7})
44
+ ```
45
+
46
+ Reusable generation values are supported with `uv run codapact generate
47
+ --manifest examples/pets.codapact.yaml`. The resulting `pets` command discovers
48
+ `config.json` and `auth.json` in `$XDG_CONFIG_HOME/pets` or `~/.config/pets`.
49
+ Override its directory with `pets --config-dir PATH ...`. See the configuration
50
+ guide for precedence, credential-file permissions, and every generation override.
51
+
52
+ - [Architecture and extension contracts](docs/architecture.md)
53
+ - [Supported features and safety boundaries](docs/support.md)
54
+ - [CLI definition and runtime configuration](docs/configuration.md)
55
+ - [Release process](docs/releasing.md)
56
+ - [Verification evidence and limits](docs/verification.md)
57
+ - [Asynchronous mutation testing and open alerts](docs/mutation.md)
58
+
59
+ Run `uv run poe check` for formatting, lint, type checking, and tests. Generated
60
+ packages depend on this runtime at the exact generator version. For unreleased
61
+ source changes, install the local runtime wheel and generated wheel together.
62
+ The end-to-end test proves that workflow in a fresh environment.
@@ -0,0 +1,21 @@
1
+ codapact/__init__.py,sha256=SUG8C-2_faK6uN3iTf_yzXGzTmIB-2mJ5vLbAnyH6qE,98
2
+ codapact/__main__.py,sha256=kqQs8Oyeu8L_gHWlWytNCU_PgnNu-GsZEAsZxxVycvw,3828
3
+ codapact/cli.py,sha256=XvYvKS1AqdpFgXbNDDZmET045zCbAv5PbjXG6q8MrpY,5060
4
+ codapact/configuration.py,sha256=me9nJdA0xVANvr3OhDsUzsnvb4EsA4IHGfCNSF4N0ao,5414
5
+ codapact/errors.py,sha256=QGCbVu3wZMagjMJwcdUm82yzCw5X-B9--IBr90rXEQ4,847
6
+ codapact/generation.py,sha256=5-X1G4ABpojVBCV9ZMexx2aa0ZXSw-nlxwmtRoma1-Y,9767
7
+ codapact/loading.py,sha256=wrNfdYDrXiU3anp8Ra2XEpPVRt--tgljUN_EANz_TPc,5116
8
+ codapact/model.py,sha256=zBJaNBD4QWHMdc4Y-I36TIkBdeP_lHA7lUry8IJI9z8,2619
9
+ codapact/net.py,sha256=pO9a8liTQYa848q9j5QLXOLzeGwbdpqFAx2_uhWK3hs,4067
10
+ codapact/openapi.py,sha256=RgHDXldiyYSDTsc4iI8qz2VoVSxnMK_6mDH8-DxZk3c,13764
11
+ codapact/profiles.py,sha256=KpbEgkd9ODFt0cqbyNfY2p5vFH4kHwWbKBaeeUTxaAs,6902
12
+ codapact/project.py,sha256=lgdaAPo0QyXGC8S0CyjHhwEjql4yks9L8-bT6cRHpJE,6169
13
+ codapact/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ codapact/runtime.py,sha256=tFmCLRjaTVxd7kDb9hWhp8NWcRlyiiPlOT8f7n3mogA,12472
15
+ codapact/schemas/generation.v1.json,sha256=M9wnzLs57uJcq5GUpq3WcDbPuxNmb29zLFXiuZOZ-M0,1910
16
+ codapact/values.py,sha256=9BM0-7kIUHrOuhWXhFo3TZ0UXibFDYrR5jQBJPvw5kc,1023
17
+ codapact-0.1.0.dist-info/licenses/LICENSE,sha256=MrM1ktUwGhqY5Eq9uprukyzAi7-UApuuTroNfjlRxPA,1066
18
+ codapact-0.1.0.dist-info/WHEEL,sha256=3NO1oYsF7mANFUWVdyEQLM-zmecczWWEmmF5rEbXrWk,80
19
+ codapact-0.1.0.dist-info/entry_points.txt,sha256=XQ7lpiFJgOGEAV_mJP1B_BHsJ_Epd-rDPz-shmvpLdI,53
20
+ codapact-0.1.0.dist-info/METADATA,sha256=Bp4SQD4AUChvXw6beiCDnF6X7b-BFGEWxD_pnWWBE2w,2684
21
+ codapact-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.13.6
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ codapact = codapact.__main__:main
3
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mike Hill
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.