tba-durability-audit 0.4.0.dev2__tar.gz
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.
- tba_durability_audit-0.4.0.dev2/PKG-INFO +25 -0
- tba_durability_audit-0.4.0.dev2/README.md +3 -0
- tba_durability_audit-0.4.0.dev2/pyproject.toml +23 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/__init__.py +5 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/inventory.py +22 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/operations/__init__.py +1 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/operations/audit.py +51 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/py.typed +1 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/specifications/__init__.py +1 -0
- tba_durability_audit-0.4.0.dev2/src/tba_durability_audit/specifications/audit.py +39 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-durability-audit
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Carrier-neutral layer-30 durable table operations.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.15
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: tba-bases-replay (==0.4.0.dev2)
|
|
14
|
+
Requires-Dist: tba-contracts-identity (==0.4.0.dev2)
|
|
15
|
+
Requires-Dist: tba-contracts-security-trust (==0.1.0)
|
|
16
|
+
Requires-Dist: tba-primitives-identity (==0.4.0.dev2)
|
|
17
|
+
Requires-Dist: tba-storage-audit (==0.4.0.dev2)
|
|
18
|
+
Requires-Dist: tba-storage-tenancy (==0.4.0.dev2)
|
|
19
|
+
Requires-Dist: tigrbl (==0.4.5.dev8)
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# tba-durability-audit
|
|
23
|
+
|
|
24
|
+
Carrier-neutral layer-30 durable operations and derived table specifications.
|
|
25
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-durability-audit"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Carrier-neutral layer-30 durable table operations."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"tigrbl==0.4.5.dev8",
|
|
10
|
+
"tba-primitives-identity==0.4.0.dev2",
|
|
11
|
+
"tba-contracts-identity==0.4.0.dev2",
|
|
12
|
+
"tba-bases-replay==0.4.0.dev2",
|
|
13
|
+
"tba-contracts-security-trust==0.1.0",
|
|
14
|
+
"tba-storage-audit==0.4.0.dev2",
|
|
15
|
+
"tba-storage-tenancy==0.4.0.dev2",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["poetry-core>=1.0.0"]
|
|
20
|
+
build-backend = "poetry.core.masonry.api"
|
|
21
|
+
|
|
22
|
+
[tool.poetry]
|
|
23
|
+
packages = [{ include = "tba_durability_audit", from = "src" }]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Immutable inventory of this durable family's table specifications."""
|
|
2
|
+
|
|
3
|
+
from . import specifications as _specifications
|
|
4
|
+
|
|
5
|
+
RUNTIME_TABLE_SPECS = tuple(
|
|
6
|
+
value
|
|
7
|
+
for name, value in vars(_specifications).items()
|
|
8
|
+
if name.endswith("RuntimeSpec") and getattr(value, "model", None) is not None
|
|
9
|
+
)
|
|
10
|
+
RUNTIME_TABLES = tuple(spec.model for spec in RUNTIME_TABLE_SPECS)
|
|
11
|
+
RUNTIME_OPERATION_BY_ALIAS = {
|
|
12
|
+
operation.alias: operation
|
|
13
|
+
for spec in RUNTIME_TABLE_SPECS
|
|
14
|
+
for operation in spec.ops
|
|
15
|
+
if operation.extra.get("owner_layer") == "30-storage-runtime"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"RUNTIME_OPERATION_BY_ALIAS",
|
|
20
|
+
"RUNTIME_TABLE_SPECS",
|
|
21
|
+
"RUNTIME_TABLES",
|
|
22
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .audit import *
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Durable audit-event operations and compatibility adapters."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from tigrbl import (
|
|
9
|
+
create_table_record,
|
|
10
|
+
database_from_context,
|
|
11
|
+
field_value,
|
|
12
|
+
list_table_records,
|
|
13
|
+
payload_from_context,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def append_audit_event_record(ctx: Mapping[str, Any]) -> Any:
|
|
18
|
+
from tba_storage_audit.tables import AuditEvent
|
|
19
|
+
from tba_storage_tenancy.tables import Tenant
|
|
20
|
+
|
|
21
|
+
db = database_from_context(ctx)
|
|
22
|
+
payload = dict(payload_from_context(ctx))
|
|
23
|
+
if payload.get("tenant_id") is None:
|
|
24
|
+
tenants = await list_table_records(Tenant, db, {})
|
|
25
|
+
if tenants:
|
|
26
|
+
payload["tenant_id"] = field_value(tenants[0], "id")
|
|
27
|
+
return await create_table_record(AuditEvent, db, payload)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
async def list_audit_event_records(ctx: Mapping[str, Any]) -> list[Any]:
|
|
31
|
+
from tba_storage_audit.tables import AuditEvent
|
|
32
|
+
|
|
33
|
+
filters = {
|
|
34
|
+
key: value
|
|
35
|
+
for key, value in dict(payload_from_context(ctx)).items()
|
|
36
|
+
if value is not None
|
|
37
|
+
}
|
|
38
|
+
return await list_table_records(AuditEvent, database_from_context(ctx), filters)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async def append_audit_event_async(*, db: Any, **payload: Any) -> Any:
|
|
42
|
+
"""Append using an explicitly injected transaction/session."""
|
|
43
|
+
|
|
44
|
+
return await append_audit_event_record({"payload": payload, "db": db})
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"append_audit_event_async",
|
|
49
|
+
"append_audit_event_record",
|
|
50
|
+
"list_audit_event_records",
|
|
51
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .audit import *
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Audit-event alias and executable runtime specification."""
|
|
2
|
+
|
|
3
|
+
from tba_storage_audit.tables import AuditEvent
|
|
4
|
+
|
|
5
|
+
from tigrbl import deriveTableSpec
|
|
6
|
+
from tigrbl import makeOp
|
|
7
|
+
from tba_durability_audit.operations.audit import (
|
|
8
|
+
append_audit_event_record,
|
|
9
|
+
list_audit_event_records,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
AuditEventTable = AuditEvent
|
|
14
|
+
AuditEventRuntimeSpec = deriveTableSpec(
|
|
15
|
+
AuditEventTable,
|
|
16
|
+
ops=(
|
|
17
|
+
makeOp(
|
|
18
|
+
extra={"owner_layer": "30-storage-runtime"},
|
|
19
|
+
expose_routes=False,
|
|
20
|
+
expose_rpc=False,
|
|
21
|
+
expose_method=True,
|
|
22
|
+
tx_scope="read_write",
|
|
23
|
+
alias="append",
|
|
24
|
+
handler=append_audit_event_record,
|
|
25
|
+
),
|
|
26
|
+
makeOp(
|
|
27
|
+
extra={"owner_layer": "30-storage-runtime"},
|
|
28
|
+
expose_routes=False,
|
|
29
|
+
expose_rpc=False,
|
|
30
|
+
expose_method=True,
|
|
31
|
+
alias="list_events",
|
|
32
|
+
handler=list_audit_event_records,
|
|
33
|
+
tx_scope="read_only",
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
__all__ = ["AuditEventRuntimeSpec", "AuditEventTable"]
|