tba-storage-authority-graph 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.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: tba-storage-authority-graph
3
+ Version: 0.4.0.dev2
4
+ Summary: Owned authority-graph identity database tables and migrations.
5
+ License: Apache-2.0
6
+ Requires-Python: >=3.10,<3.15
7
+ Classifier: License :: OSI Approved :: Apache Software License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: tba-primitives-identity[storage] (>=0.4.0.dev2)
15
+ Requires-Dist: tigrbl (>=0.4.4.dev1,<0.5)
16
+ Requires-Dist: tigrbl-migrations (>=0.4.5.dev4)
17
+ Description-Content-Type: text/markdown
18
+
19
+ # tba-storage-authority-graph
20
+
21
+ Owns the `tigrbl.identity.storage.authority-graph` schema component.
22
+
@@ -0,0 +1,3 @@
1
+ # tba-storage-authority-graph
2
+
3
+ Owns the `tigrbl.identity.storage.authority-graph` schema component.
@@ -0,0 +1,20 @@
1
+ [project]
2
+ name = "tba-storage-authority-graph"
3
+ version = "0.4.0.dev2"
4
+ description = "Owned authority-graph identity database tables and migrations."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10,<3.15"
7
+ license = { text = "Apache-2.0" }
8
+ dependencies = [
9
+ "tigrbl>=0.4.4.dev1,<0.5",
10
+ "tigrbl-migrations>=0.4.5.dev4",
11
+ "tba-primitives-identity[storage]>=0.4.0.dev2",
12
+ ]
13
+
14
+ [build-system]
15
+ requires = ["poetry-core>=1.0.0"]
16
+ build-backend = "poetry.core.masonry.api"
17
+
18
+ [tool.poetry]
19
+ packages = [{ include = "tba_storage_authority_graph", from = "src" }]
20
+ include = ["src/tba_storage_authority_graph/component.toml"]
@@ -0,0 +1,7 @@
1
+ """Standalone identity storage component."""
2
+
3
+ from .manifest import MANIFEST, load_manifest
4
+ from .tables import * # noqa: F401,F403
5
+ from .tables import TABLE_MODEL_BY_NAME, TABLE_MODEL_BY_TABLENAME, TABLE_MODELS
6
+
7
+ __all__ = ["MANIFEST", "load_manifest", "TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME"] + [model.__name__ for model in TABLE_MODELS]
@@ -0,0 +1,29 @@
1
+ manifest_version = "1.0.0"
2
+
3
+ [component]
4
+ id = "tigrbl.identity.storage.authority-graph"
5
+ distribution = "tba-storage-authority-graph"
6
+ import_root = "tba_storage_authority_graph"
7
+
8
+ [schema]
9
+ contract = "1.0.0"
10
+ migration_head = "d7c60dd1-6611-58b2-8f62-5ca0e066afbd"
11
+ migrations_package = "tba_storage_authority_graph.migrations.versions"
12
+
13
+ [[schema.objects]]
14
+ id = "tigrbl.identity.storage.authority-graph:table:authority_derivation_graphs"
15
+ kind = "table"
16
+ physical_name = "authn.authority_derivation_graphs"
17
+ model = "tba_storage_authority_graph.tables:AuthorityDerivationGraph"
18
+
19
+ [[schema.objects]]
20
+ id = "tigrbl.identity.storage.authority-graph:table:authority_derivation_graph_nodes"
21
+ kind = "table"
22
+ physical_name = "authn.authority_derivation_graph_nodes"
23
+ model = "tba_storage_authority_graph.tables:AuthorityDerivationGraphNode"
24
+
25
+ [[schema.objects]]
26
+ id = "tigrbl.identity.storage.authority-graph:table:authority_derivation_graph_edges"
27
+ kind = "table"
28
+ physical_name = "authn.authority_derivation_graph_edges"
29
+ model = "tba_storage_authority_graph.tables:AuthorityDerivationGraphEdge"
@@ -0,0 +1,9 @@
1
+ """Installed component manifest access."""
2
+ from importlib.resources import as_file, files
3
+ from tigrbl_migrations import StorageManifest
4
+
5
+ def load_manifest() -> StorageManifest:
6
+ with as_file(files(__package__).joinpath("component.toml")) as path:
7
+ return StorageManifest.from_toml(path)
8
+
9
+ MANIFEST = load_manifest()
@@ -0,0 +1,23 @@
1
+ """Initial owned schema for tigrbl.identity.storage.authority-graph."""
2
+ from tigrbl_migrations import Migration
3
+ from tba_storage_authority_graph.tables import TABLE_MODELS
4
+
5
+ REVISION = "d7c60dd1-6611-58b2-8f62-5ca0e066afbd"
6
+
7
+ def upgrade(connection):
8
+ for model in TABLE_MODELS:
9
+ model.__table__.create(bind=connection, checkfirst=True)
10
+
11
+ def downgrade(connection):
12
+ for model in reversed(TABLE_MODELS):
13
+ model.__table__.drop(bind=connection, checkfirst=True)
14
+
15
+ MIGRATION = Migration(
16
+ component="tigrbl.identity.storage.authority-graph",
17
+ revision=REVISION,
18
+ parents=(),
19
+ kind="standard",
20
+ reversible=True,
21
+ upgrade=upgrade,
22
+ downgrade=downgrade,
23
+ )
@@ -0,0 +1,14 @@
1
+ """Owned mapped-table inventory."""
2
+
3
+ from .authority_derivation_graph import AuthorityDerivationGraph, AuthorityDerivationGraphNode, AuthorityDerivationGraphEdge
4
+
5
+ TABLE_MODELS = (
6
+ AuthorityDerivationGraph,
7
+ AuthorityDerivationGraphNode,
8
+ AuthorityDerivationGraphEdge,
9
+ )
10
+ TABLE_MODEL_BY_NAME = {model.__name__: model for model in TABLE_MODELS}
11
+ TABLE_MODEL_BY_TABLENAME = {model.__tablename__: model for model in TABLE_MODELS}
12
+ __all__ = [model.__name__ for model in TABLE_MODELS] + [
13
+ "TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME",
14
+ ]
@@ -0,0 +1,53 @@
1
+ """Shared abstract columns for graph-backed storage tables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from tba_primitives_identity.orm import (
8
+ Boolean,
9
+ JSON,
10
+ Mapped,
11
+ RestOltpTable,
12
+ S,
13
+ String,
14
+ Timestamped,
15
+ acol,
16
+ )
17
+
18
+
19
+ class GraphBase(RestOltpTable, Timestamped):
20
+ __abstract__ = True
21
+
22
+ graph_key: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
23
+ tenant_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
24
+ realm: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
25
+ status: Mapped[str] = acol(storage=S(String(32), nullable=False, default="active", index=True))
26
+ graph_metadata: Mapped[dict[str, Any] | None] = acol(storage=S(JSON, nullable=True))
27
+
28
+
29
+ class GraphNodeBase(RestOltpTable, Timestamped):
30
+ __abstract__ = True
31
+
32
+ node_key: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
33
+ kind: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
34
+ tenant_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
35
+ realm: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
36
+ ref_table: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
37
+ ref_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
38
+ node_metadata: Mapped[dict[str, Any] | None] = acol(storage=S(JSON, nullable=True))
39
+
40
+
41
+ class GraphEdgeBase(RestOltpTable, Timestamped):
42
+ __abstract__ = True
43
+
44
+ edge_key: Mapped[str] = acol(storage=S(String(1000), nullable=False, index=True))
45
+ kind: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
46
+ tenant_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
47
+ realm: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
48
+ active: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=True, index=True))
49
+ revoked: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=False, index=True))
50
+ edge_metadata: Mapped[dict[str, Any] | None] = acol(storage=S(JSON, nullable=True))
51
+
52
+
53
+ __all__ = ["GraphBase", "GraphNodeBase", "GraphEdgeBase"]
@@ -0,0 +1,15 @@
1
+ """Authority derivation graph table exports."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from ._table import (
6
+ AuthorityDerivationGraph,
7
+ AuthorityDerivationGraphEdge,
8
+ AuthorityDerivationGraphNode,
9
+ )
10
+
11
+ __all__ = [
12
+ "AuthorityDerivationGraph",
13
+ "AuthorityDerivationGraphNode",
14
+ "AuthorityDerivationGraphEdge",
15
+ ]
@@ -0,0 +1,94 @@
1
+ """Durable authority derivation graph tables."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from sqlalchemy import Index, UniqueConstraint
6
+
7
+ from tba_primitives_identity.orm import (
8
+ ForeignKeySpec,
9
+ GUIDPk,
10
+ JSON,
11
+ Mapped,
12
+ PgUUID,
13
+ S,
14
+ String,
15
+ UUID,
16
+ acol,
17
+ )
18
+ from tba_storage_authority_graph.tables._graph_base import GraphBase, GraphEdgeBase, GraphNodeBase
19
+
20
+
21
+ class AuthorityDerivationGraph(GraphBase, GUIDPk):
22
+ __tablename__ = "authority_derivation_graphs"
23
+ __table_args__ = (
24
+ UniqueConstraint("graph_key", name="uq_authority_derivation_graph_key"),
25
+ {"extend_existing": True, "schema": "authn"},
26
+ )
27
+
28
+
29
+ class AuthorityDerivationGraphNode(GraphNodeBase, GUIDPk):
30
+ __tablename__ = "authority_derivation_graph_nodes"
31
+ __table_args__ = (
32
+ UniqueConstraint("graph_id", "node_key", name="uq_authority_derivation_graph_node_key"),
33
+ Index("ix_authority_derivation_graph_node_graph_kind", "graph_id", "kind"),
34
+ Index("ix_authority_derivation_graph_node_tenant_kind", "tenant_id", "kind"),
35
+ {"extend_existing": True, "schema": "authn"},
36
+ )
37
+
38
+ graph_id: Mapped[UUID] = acol(
39
+ storage=S(
40
+ PgUUID(as_uuid=True),
41
+ fk=ForeignKeySpec(target="authn.authority_derivation_graphs.id"),
42
+ nullable=False,
43
+ index=True,
44
+ )
45
+ )
46
+
47
+
48
+ class AuthorityDerivationGraphEdge(GraphEdgeBase, GUIDPk):
49
+ __tablename__ = "authority_derivation_graph_edges"
50
+ __table_args__ = (
51
+ UniqueConstraint("graph_id", "edge_key", name="uq_authority_derivation_graph_edge_key"),
52
+ Index("ix_authority_derivation_graph_edge_src_kind", "graph_id", "src_id", "kind"),
53
+ Index("ix_authority_derivation_graph_edge_dst_kind", "graph_id", "dst_id", "kind"),
54
+ Index("ix_authority_derivation_graph_edge_tenant_kind", "tenant_id", "kind"),
55
+ {"extend_existing": True, "schema": "authn"},
56
+ )
57
+
58
+ graph_id: Mapped[UUID] = acol(
59
+ storage=S(
60
+ PgUUID(as_uuid=True),
61
+ fk=ForeignKeySpec(target="authn.authority_derivation_graphs.id"),
62
+ nullable=False,
63
+ index=True,
64
+ )
65
+ )
66
+ src_id: Mapped[UUID] = acol(
67
+ storage=S(
68
+ PgUUID(as_uuid=True),
69
+ fk=ForeignKeySpec(target="authn.authority_derivation_graph_nodes.id"),
70
+ nullable=False,
71
+ index=True,
72
+ )
73
+ )
74
+ dst_id: Mapped[UUID] = acol(
75
+ storage=S(
76
+ PgUUID(as_uuid=True),
77
+ fk=ForeignKeySpec(target="authn.authority_derivation_graph_nodes.id"),
78
+ nullable=False,
79
+ index=True,
80
+ )
81
+ )
82
+ policy_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
83
+ policy_version_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
84
+ policy_version: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
85
+ provenance_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
86
+ scopes: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
87
+ constraints: Mapped[list | None] = acol(storage=S(JSON, nullable=True))
88
+
89
+
90
+ __all__ = [
91
+ "AuthorityDerivationGraph",
92
+ "AuthorityDerivationGraphNode",
93
+ "AuthorityDerivationGraphEdge",
94
+ ]