Structured UUID pattern library with encode/decode support
Project description
fraiseql-uuid
UUID v4 compliant pattern with encoded metadata for the FraiseQL ecosystem.
Status: โ v0.1.0 Production-Ready | ๐ Type-Safe (ty strict) | ๐ SBOM Available
Installation
pip install fraiseql-uuid
Quick Start
from fraiseql_uuid import Pattern, UUIDGenerator
# Create pattern
pattern = Pattern()
# Generate UUID
gen = UUIDGenerator(pattern, table_code="012345")
uuid = gen.generate(instance=1)
print(uuid) # โ "01234521-0000-4000-8000-000000000001"
# Decode UUID
decoded = pattern.decode(uuid)
print(decoded["table_code"]) # โ "012345"
print(decoded["instance"]) # โ 1
UUID Format
Code notation: {table:6}{type:2}-{func:4}-4{scen:3}-8{scen:1}{test:2}-{inst:12}
Docs notation: TTTTTTDD-FFFF-4SSS-8STT-IIIIIIIIIIII
Components
| Symbol | Component | Length | Default | Description |
|---|---|---|---|---|
| T | table_code | 6 | - | Table/Entity code (required) |
| D | seed_dir | 2 | 21 | Seed directory (21=general, 22=mutation, 23=query) |
| F | function | 4 | 0 | Function code |
| 4 | version | 1 | 4 | UUID v4 version bit (fixed) |
| S | scenario | 4 | 0 | Test scenario (split 3+1 for v4 compliance) |
| 8 | variant | 1 | 8 | UUID variant bit (fixed) |
| T | test_case | 2 | 0 | Test case number |
| I | instance | 12 | - | Instance number (required) |
Example
01234521-0042-4100-8015-000000000001
โ โ โ โ โ โ โ โ โโ instance: 1
โ โ โ โ โ โ โโโโ test_case: 15
โ โ โ โ โ โโโโโโ scenario: 1000 (split as 100 + 0)
โ โ โ โ โโโโโโโโโ variant: 8
โ โ โ โโโโโโโโโโโโ version: 4
โ โ โโโโโโโโโโโโโโโ function: 42
โ โโโโโโโโโโโโโโโโโ table: 012345
โโโโโโโโโโโโโโโโโโโโโโโโ seed_dir: 21
Usage Examples
Basic Generation
from fraiseql_uuid import Pattern
pattern = Pattern()
# Minimal - uses defaults
uuid = pattern.generate(table_code="012345", instance=1)
# โ "01234521-0000-4000-8000-000000000001"
# Full parameters
uuid = pattern.generate(
table_code="123456",
seed_dir=22, # mutation tests
function=42,
scenario=1000,
test_case=5,
instance=999
)
# โ "12345622-0042-4100-8005-000000000999"
Batch Generation
from fraiseql_uuid import Pattern, UUIDGenerator
pattern = Pattern()
gen = UUIDGenerator(pattern, table_code="012345", scenario=1000)
# Generate batch
uuids = gen.generate_batch(count=5)
# โ ["01234521-0000-4100-8000-000000000001",
# "01234521-0000-4100-8000-000000000002",
# ...]
Decoding
from fraiseql_uuid import Pattern
pattern = Pattern()
decoded = pattern.decode("01234521-0042-4100-8015-000000000001")
print(decoded["table_code"]) # โ "012345"
print(decoded["seed_dir"]) # โ 21
print(decoded["function"]) # โ 42
print(decoded["scenario"]) # โ 1000
print(decoded["test_case"]) # โ 15
print(decoded["instance"]) # โ 1
Validation
from fraiseql_uuid import Pattern, UUIDValidator
pattern = Pattern()
validator = UUIDValidator(pattern)
result = validator.validate("01234521-0000-4000-8000-000000000001")
print(result.valid) # โ True
result = validator.validate("not-a-uuid")
print(result.valid) # โ False
print(result.error) # โ "Invalid UUID format: not-a-uuid"
Caching
from fraiseql_uuid import UUIDCache
cache = UUIDCache()
# Store generated UUIDs
cache.set("users", instance=1, uuid="01234521-0000-4000-8000-000000000001")
cache.set("users", instance=2, uuid="01234521-0000-4000-8000-000000000002")
# Retrieve from cache
uuid = cache.get("users", instance=1)
print(uuid) # โ "01234521-0000-4000-8000-000000000001"
CLI Usage
# Generate UUID
fraiseql-uuid generate --table 012345 --instance 1
# Generate batch
fraiseql-uuid generate --table 012345 --count 10
# Decode UUID
fraiseql-uuid decode 01234521-0000-4000-8000-000000000001
# Validate UUID
fraiseql-uuid validate 01234521-0000-4000-8000-000000000001
UUID v4 Compliance
All generated UUIDs are UUID v4 compliant:
- Version bit
4in the correct position - Variant bit
8in the correct position - Can be used anywhere standard UUIDs are expected
- Compatible with database UUID columns
- Parseable by standard UUID libraries
import uuid
# Works with standard UUID library
generated = pattern.generate(table_code="012345", instance=1)
parsed = uuid.UUID(generated)
print(parsed.version) # โ 4
print(parsed.variant) # โ uuid.RFC_4122
Development
# Install for development
git clone https://github.com/fraiseql/fraiseql-seed
cd fraiseql-seed
uv sync
# Run tests
uv run pytest packages/fraiseql-uuid/tests -v
# Type check
uv run ty check packages/fraiseql-uuid/src
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fraiseql_uuid-0.1.2.tar.gz.
File metadata
- Download URL: fraiseql_uuid-0.1.2.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35e0a41d00c14486936210ee36f7046e26f3f54186ce1cd289830fdd6b05eebf
|
|
| MD5 |
26d0c9e83113bc5f360d71897acf7c64
|
|
| BLAKE2b-256 |
a7631951dcf180002393ec64505f080e48a9786e12fdea16b717e1ce1d260852
|
Provenance
The following attestation bundles were made for fraiseql_uuid-0.1.2.tar.gz:
Publisher:
deploy.yml on fraiseql/fraiseql-seed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fraiseql_uuid-0.1.2.tar.gz -
Subject digest:
35e0a41d00c14486936210ee36f7046e26f3f54186ce1cd289830fdd6b05eebf - Sigstore transparency entry: 1154393391
- Sigstore integration time:
-
Permalink:
fraiseql/fraiseql-seed@4a1d4f1a47fc48f63643703cf736d94cd48c2043 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fraiseql
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@4a1d4f1a47fc48f63643703cf736d94cd48c2043 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fraiseql_uuid-0.1.2-py3-none-any.whl.
File metadata
- Download URL: fraiseql_uuid-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf3ff0115f1c81071639f16b99c7ab9bffd2d1577f37bccd44bee0e2ad28aa45
|
|
| MD5 |
fae1964e649fe376947b8af8ee7779d9
|
|
| BLAKE2b-256 |
8c4798b1974eb9c55d717abddf053e80ede86eab2281ebefd3177810a0ffc089
|
Provenance
The following attestation bundles were made for fraiseql_uuid-0.1.2-py3-none-any.whl:
Publisher:
deploy.yml on fraiseql/fraiseql-seed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fraiseql_uuid-0.1.2-py3-none-any.whl -
Subject digest:
bf3ff0115f1c81071639f16b99c7ab9bffd2d1577f37bccd44bee0e2ad28aa45 - Sigstore transparency entry: 1154393393
- Sigstore integration time:
-
Permalink:
fraiseql/fraiseql-seed@4a1d4f1a47fc48f63643703cf736d94cd48c2043 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/fraiseql
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@4a1d4f1a47fc48f63643703cf736d94cd48c2043 -
Trigger Event:
push
-
Statement type: