infrahub-server 1.2.0b1__py3-none-any.whl → 1.2.1__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.
Files changed (297) hide show
  1. infrahub/api/dependencies.py +6 -6
  2. infrahub/api/diff/validation_models.py +7 -7
  3. infrahub/api/schema.py +1 -1
  4. infrahub/artifacts/models.py +1 -3
  5. infrahub/artifacts/tasks.py +1 -3
  6. infrahub/cli/__init__.py +13 -9
  7. infrahub/cli/constants.py +3 -0
  8. infrahub/cli/db.py +165 -183
  9. infrahub/cli/upgrade.py +146 -0
  10. infrahub/computed_attribute/gather.py +185 -0
  11. infrahub/computed_attribute/models.py +239 -11
  12. infrahub/computed_attribute/tasks.py +77 -442
  13. infrahub/computed_attribute/triggers.py +11 -45
  14. infrahub/config.py +43 -32
  15. infrahub/context.py +14 -0
  16. infrahub/core/account.py +4 -4
  17. infrahub/core/attribute.py +57 -57
  18. infrahub/core/branch/tasks.py +12 -9
  19. infrahub/core/changelog/diff.py +16 -8
  20. infrahub/core/changelog/models.py +189 -26
  21. infrahub/core/constants/__init__.py +5 -1
  22. infrahub/core/constants/infrahubkind.py +2 -0
  23. infrahub/core/constraint/node/runner.py +9 -8
  24. infrahub/core/diff/branch_differ.py +10 -10
  25. infrahub/core/diff/ipam_diff_parser.py +4 -5
  26. infrahub/core/diff/model/diff.py +27 -27
  27. infrahub/core/diff/model/path.py +3 -3
  28. infrahub/core/diff/query/merge.py +20 -17
  29. infrahub/core/diff/query_parser.py +4 -4
  30. infrahub/core/graph/__init__.py +1 -1
  31. infrahub/core/initialization.py +1 -10
  32. infrahub/core/ipam/constants.py +3 -4
  33. infrahub/core/ipam/reconciler.py +12 -12
  34. infrahub/core/ipam/utilization.py +10 -13
  35. infrahub/core/manager.py +34 -34
  36. infrahub/core/merge.py +7 -7
  37. infrahub/core/migrations/__init__.py +2 -3
  38. infrahub/core/migrations/graph/__init__.py +9 -4
  39. infrahub/core/migrations/graph/m017_add_core_profile.py +1 -5
  40. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +4 -4
  41. infrahub/core/migrations/graph/m020_duplicate_edges.py +160 -0
  42. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +51 -0
  43. infrahub/core/migrations/graph/{m020_add_generate_template_attr.py → m022_add_generate_template_attr.py} +3 -3
  44. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +96 -0
  45. infrahub/core/migrations/query/attribute_add.py +2 -2
  46. infrahub/core/migrations/query/node_duplicate.py +18 -21
  47. infrahub/core/migrations/query/schema_attribute_update.py +2 -2
  48. infrahub/core/migrations/schema/models.py +19 -4
  49. infrahub/core/migrations/schema/tasks.py +2 -2
  50. infrahub/core/migrations/shared.py +16 -16
  51. infrahub/core/models.py +15 -6
  52. infrahub/core/node/__init__.py +29 -28
  53. infrahub/core/node/base.py +2 -4
  54. infrahub/core/node/constraints/attribute_uniqueness.py +2 -2
  55. infrahub/core/node/constraints/grouped_uniqueness.py +99 -47
  56. infrahub/core/node/constraints/interface.py +1 -2
  57. infrahub/core/node/delete_validator.py +3 -5
  58. infrahub/core/node/ipam.py +4 -4
  59. infrahub/core/node/permissions.py +7 -7
  60. infrahub/core/node/resource_manager/ip_address_pool.py +6 -6
  61. infrahub/core/node/resource_manager/ip_prefix_pool.py +6 -6
  62. infrahub/core/node/resource_manager/number_pool.py +3 -3
  63. infrahub/core/path.py +12 -12
  64. infrahub/core/property.py +11 -11
  65. infrahub/core/protocols.py +5 -0
  66. infrahub/core/protocols_base.py +21 -21
  67. infrahub/core/query/__init__.py +33 -33
  68. infrahub/core/query/attribute.py +6 -4
  69. infrahub/core/query/diff.py +3 -3
  70. infrahub/core/query/node.py +82 -32
  71. infrahub/core/query/relationship.py +24 -24
  72. infrahub/core/query/resource_manager.py +2 -0
  73. infrahub/core/query/standard_node.py +3 -3
  74. infrahub/core/query/subquery.py +9 -9
  75. infrahub/core/registry.py +13 -15
  76. infrahub/core/relationship/constraints/count.py +3 -4
  77. infrahub/core/relationship/constraints/peer_kind.py +3 -4
  78. infrahub/core/relationship/constraints/profiles_kind.py +2 -2
  79. infrahub/core/relationship/model.py +40 -46
  80. infrahub/core/schema/attribute_schema.py +9 -9
  81. infrahub/core/schema/basenode_schema.py +93 -44
  82. infrahub/core/schema/computed_attribute.py +3 -3
  83. infrahub/core/schema/definitions/core/__init__.py +13 -19
  84. infrahub/core/schema/definitions/core/account.py +151 -148
  85. infrahub/core/schema/definitions/core/artifact.py +122 -113
  86. infrahub/core/schema/definitions/core/builtin.py +19 -16
  87. infrahub/core/schema/definitions/core/check.py +61 -53
  88. infrahub/core/schema/definitions/core/core.py +17 -0
  89. infrahub/core/schema/definitions/core/generator.py +89 -85
  90. infrahub/core/schema/definitions/core/graphql_query.py +72 -70
  91. infrahub/core/schema/definitions/core/group.py +96 -93
  92. infrahub/core/schema/definitions/core/ipam.py +176 -235
  93. infrahub/core/schema/definitions/core/lineage.py +18 -16
  94. infrahub/core/schema/definitions/core/menu.py +42 -40
  95. infrahub/core/schema/definitions/core/permission.py +144 -142
  96. infrahub/core/schema/definitions/core/profile.py +16 -27
  97. infrahub/core/schema/definitions/core/propose_change.py +88 -79
  98. infrahub/core/schema/definitions/core/propose_change_comment.py +170 -165
  99. infrahub/core/schema/definitions/core/propose_change_validator.py +290 -288
  100. infrahub/core/schema/definitions/core/repository.py +231 -225
  101. infrahub/core/schema/definitions/core/resource_pool.py +156 -166
  102. infrahub/core/schema/definitions/core/template.py +27 -12
  103. infrahub/core/schema/definitions/core/transform.py +85 -76
  104. infrahub/core/schema/definitions/core/webhook.py +127 -101
  105. infrahub/core/schema/definitions/internal.py +16 -16
  106. infrahub/core/schema/dropdown.py +3 -4
  107. infrahub/core/schema/generated/attribute_schema.py +15 -18
  108. infrahub/core/schema/generated/base_node_schema.py +12 -14
  109. infrahub/core/schema/generated/node_schema.py +3 -5
  110. infrahub/core/schema/generated/relationship_schema.py +9 -11
  111. infrahub/core/schema/generic_schema.py +2 -2
  112. infrahub/core/schema/manager.py +20 -9
  113. infrahub/core/schema/node_schema.py +4 -2
  114. infrahub/core/schema/relationship_schema.py +7 -7
  115. infrahub/core/schema/schema_branch.py +276 -138
  116. infrahub/core/schema/schema_branch_computed.py +41 -4
  117. infrahub/core/task/task.py +3 -3
  118. infrahub/core/task/user_task.py +15 -15
  119. infrahub/core/utils.py +20 -18
  120. infrahub/core/validators/__init__.py +1 -3
  121. infrahub/core/validators/aggregated_checker.py +2 -2
  122. infrahub/core/validators/attribute/choices.py +2 -2
  123. infrahub/core/validators/attribute/enum.py +2 -2
  124. infrahub/core/validators/attribute/kind.py +2 -2
  125. infrahub/core/validators/attribute/length.py +2 -2
  126. infrahub/core/validators/attribute/optional.py +2 -2
  127. infrahub/core/validators/attribute/regex.py +2 -2
  128. infrahub/core/validators/attribute/unique.py +2 -2
  129. infrahub/core/validators/checks_runner.py +25 -2
  130. infrahub/core/validators/determiner.py +1 -3
  131. infrahub/core/validators/interface.py +6 -2
  132. infrahub/core/validators/model.py +22 -3
  133. infrahub/core/validators/models/validate_migration.py +17 -4
  134. infrahub/core/validators/node/attribute.py +2 -2
  135. infrahub/core/validators/node/generate_profile.py +2 -2
  136. infrahub/core/validators/node/hierarchy.py +3 -5
  137. infrahub/core/validators/node/inherit_from.py +27 -5
  138. infrahub/core/validators/node/relationship.py +2 -2
  139. infrahub/core/validators/relationship/count.py +4 -4
  140. infrahub/core/validators/relationship/optional.py +2 -2
  141. infrahub/core/validators/relationship/peer.py +2 -2
  142. infrahub/core/validators/shared.py +2 -2
  143. infrahub/core/validators/tasks.py +8 -0
  144. infrahub/core/validators/uniqueness/checker.py +22 -21
  145. infrahub/core/validators/uniqueness/index.py +2 -2
  146. infrahub/core/validators/uniqueness/model.py +11 -11
  147. infrahub/database/__init__.py +26 -22
  148. infrahub/database/metrics.py +7 -1
  149. infrahub/dependencies/builder/constraint/grouped/node_runner.py +1 -3
  150. infrahub/dependencies/component/registry.py +2 -2
  151. infrahub/events/__init__.py +25 -2
  152. infrahub/events/artifact_action.py +13 -25
  153. infrahub/events/branch_action.py +26 -18
  154. infrahub/events/generator.py +71 -0
  155. infrahub/events/group_action.py +10 -24
  156. infrahub/events/models.py +10 -16
  157. infrahub/events/node_action.py +87 -32
  158. infrahub/events/repository_action.py +5 -18
  159. infrahub/events/schema_action.py +4 -9
  160. infrahub/events/utils.py +16 -0
  161. infrahub/events/validator_action.py +55 -0
  162. infrahub/exceptions.py +23 -24
  163. infrahub/generators/models.py +1 -3
  164. infrahub/git/base.py +7 -7
  165. infrahub/git/integrator.py +26 -25
  166. infrahub/git/models.py +22 -9
  167. infrahub/git/repository.py +3 -3
  168. infrahub/git/tasks.py +67 -49
  169. infrahub/git/utils.py +48 -0
  170. infrahub/git/worktree.py +1 -2
  171. infrahub/git_credential/askpass.py +1 -2
  172. infrahub/graphql/analyzer.py +12 -0
  173. infrahub/graphql/app.py +13 -15
  174. infrahub/graphql/context.py +6 -0
  175. infrahub/graphql/initialization.py +3 -0
  176. infrahub/graphql/loaders/node.py +2 -12
  177. infrahub/graphql/loaders/peers.py +77 -0
  178. infrahub/graphql/loaders/shared.py +13 -0
  179. infrahub/graphql/manager.py +13 -10
  180. infrahub/graphql/mutations/artifact_definition.py +5 -5
  181. infrahub/graphql/mutations/computed_attribute.py +4 -5
  182. infrahub/graphql/mutations/graphql_query.py +5 -5
  183. infrahub/graphql/mutations/ipam.py +50 -70
  184. infrahub/graphql/mutations/main.py +164 -141
  185. infrahub/graphql/mutations/menu.py +5 -5
  186. infrahub/graphql/mutations/models.py +2 -4
  187. infrahub/graphql/mutations/node_getter/by_default_filter.py +10 -10
  188. infrahub/graphql/mutations/node_getter/by_hfid.py +1 -3
  189. infrahub/graphql/mutations/node_getter/by_id.py +1 -3
  190. infrahub/graphql/mutations/node_getter/interface.py +1 -2
  191. infrahub/graphql/mutations/proposed_change.py +7 -7
  192. infrahub/graphql/mutations/relationship.py +67 -35
  193. infrahub/graphql/mutations/repository.py +8 -8
  194. infrahub/graphql/mutations/resource_manager.py +3 -3
  195. infrahub/graphql/mutations/schema.py +4 -4
  196. infrahub/graphql/mutations/webhook.py +137 -0
  197. infrahub/graphql/parser.py +4 -4
  198. infrahub/graphql/queries/diff/tree.py +4 -4
  199. infrahub/graphql/queries/ipam.py +2 -2
  200. infrahub/graphql/queries/relationship.py +2 -2
  201. infrahub/graphql/queries/search.py +2 -2
  202. infrahub/graphql/resolvers/many_relationship.py +264 -0
  203. infrahub/graphql/resolvers/resolver.py +13 -110
  204. infrahub/graphql/subscription/graphql_query.py +2 -0
  205. infrahub/graphql/types/event.py +20 -11
  206. infrahub/graphql/types/node.py +2 -2
  207. infrahub/graphql/utils.py +2 -2
  208. infrahub/groups/ancestors.py +29 -0
  209. infrahub/groups/parsers.py +107 -0
  210. infrahub/menu/generator.py +7 -7
  211. infrahub/menu/menu.py +0 -10
  212. infrahub/menu/models.py +117 -16
  213. infrahub/menu/repository.py +111 -0
  214. infrahub/menu/utils.py +5 -8
  215. infrahub/message_bus/messages/__init__.py +1 -11
  216. infrahub/message_bus/messages/check_generator_run.py +2 -0
  217. infrahub/message_bus/messages/finalize_validator_execution.py +3 -0
  218. infrahub/message_bus/messages/request_generatordefinition_check.py +2 -0
  219. infrahub/message_bus/operations/__init__.py +0 -2
  220. infrahub/message_bus/operations/check/generator.py +1 -0
  221. infrahub/message_bus/operations/event/__init__.py +2 -2
  222. infrahub/message_bus/operations/finalize/validator.py +51 -1
  223. infrahub/message_bus/operations/requests/generator_definition.py +19 -19
  224. infrahub/message_bus/operations/requests/proposed_change.py +3 -1
  225. infrahub/pools/number.py +2 -4
  226. infrahub/proposed_change/tasks.py +37 -28
  227. infrahub/pytest_plugin.py +13 -10
  228. infrahub/server.py +1 -2
  229. infrahub/services/adapters/event/__init__.py +1 -1
  230. infrahub/task_manager/event.py +23 -9
  231. infrahub/tasks/artifact.py +2 -4
  232. infrahub/telemetry/__init__.py +0 -0
  233. infrahub/telemetry/constants.py +9 -0
  234. infrahub/telemetry/database.py +86 -0
  235. infrahub/telemetry/models.py +65 -0
  236. infrahub/telemetry/task_manager.py +77 -0
  237. infrahub/{tasks/telemetry.py → telemetry/tasks.py} +49 -56
  238. infrahub/telemetry/utils.py +11 -0
  239. infrahub/trace.py +4 -4
  240. infrahub/transformations/tasks.py +2 -2
  241. infrahub/trigger/catalogue.py +2 -5
  242. infrahub/trigger/constants.py +0 -8
  243. infrahub/trigger/models.py +14 -1
  244. infrahub/trigger/setup.py +90 -0
  245. infrahub/trigger/tasks.py +35 -90
  246. infrahub/utils.py +11 -1
  247. infrahub/validators/__init__.py +0 -0
  248. infrahub/validators/events.py +42 -0
  249. infrahub/validators/tasks.py +41 -0
  250. infrahub/webhook/gather.py +17 -0
  251. infrahub/webhook/models.py +22 -5
  252. infrahub/webhook/tasks.py +44 -19
  253. infrahub/webhook/triggers.py +22 -5
  254. infrahub/workers/infrahub_async.py +2 -2
  255. infrahub/workers/utils.py +2 -2
  256. infrahub/workflows/catalogue.py +28 -20
  257. infrahub/workflows/initialization.py +1 -3
  258. infrahub/workflows/models.py +1 -1
  259. infrahub/workflows/utils.py +10 -1
  260. infrahub_sdk/client.py +27 -8
  261. infrahub_sdk/config.py +3 -0
  262. infrahub_sdk/context.py +13 -0
  263. infrahub_sdk/exceptions.py +6 -0
  264. infrahub_sdk/generator.py +4 -1
  265. infrahub_sdk/graphql.py +45 -13
  266. infrahub_sdk/node.py +69 -20
  267. infrahub_sdk/protocols_base.py +32 -11
  268. infrahub_sdk/query_groups.py +6 -35
  269. infrahub_sdk/schema/__init__.py +55 -26
  270. infrahub_sdk/schema/main.py +8 -0
  271. infrahub_sdk/task/__init__.py +10 -0
  272. infrahub_sdk/task/manager.py +12 -6
  273. infrahub_sdk/testing/schemas/animal.py +9 -0
  274. infrahub_sdk/timestamp.py +12 -4
  275. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/METADATA +3 -2
  276. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/RECORD +289 -260
  277. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/entry_points.txt +1 -0
  278. infrahub_testcontainers/constants.py +2 -0
  279. infrahub_testcontainers/container.py +157 -12
  280. infrahub_testcontainers/docker-compose.test.yml +31 -6
  281. infrahub_testcontainers/helpers.py +18 -73
  282. infrahub_testcontainers/host.py +41 -0
  283. infrahub_testcontainers/measurements.py +93 -0
  284. infrahub_testcontainers/models.py +38 -0
  285. infrahub_testcontainers/performance_test.py +166 -0
  286. infrahub_testcontainers/plugin.py +136 -0
  287. infrahub_testcontainers/prometheus.yml +30 -0
  288. infrahub/message_bus/messages/event_branch_create.py +0 -11
  289. infrahub/message_bus/messages/event_branch_delete.py +0 -11
  290. infrahub/message_bus/messages/event_branch_rebased.py +0 -9
  291. infrahub/message_bus/messages/event_node_mutated.py +0 -15
  292. infrahub/message_bus/messages/event_schema_update.py +0 -9
  293. infrahub/message_bus/operations/event/node.py +0 -20
  294. infrahub/message_bus/operations/event/schema.py +0 -17
  295. infrahub/webhook/constants.py +0 -1
  296. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/LICENSE.txt +0 -0
  297. {infrahub_server-1.2.0b1.dist-info → infrahub_server-1.2.1.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from infrahub.core.constants import PathType
6
6
  from infrahub.core.path import DataPath, GroupedDataPaths
@@ -61,7 +61,7 @@ class NodeGenerateProfileValidatorQuery(SchemaValidatorQuery):
61
61
  class NodeGenerateProfileChecker(ConstraintCheckerInterface):
62
62
  query_classes = [NodeGenerateProfileValidatorQuery]
63
63
 
64
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
64
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
65
65
  self.db = db
66
66
  self.branch = branch
67
67
 
@@ -1,15 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from infrahub.core.constants import PathType
6
6
  from infrahub.core.path import DataPath, GroupedDataPaths
7
7
  from infrahub.core.schema import NodeSchema
8
8
 
9
9
  from ..interface import ConstraintCheckerInterface
10
- from ..shared import (
11
- SchemaValidatorQuery,
12
- )
10
+ from ..shared import SchemaValidatorQuery
13
11
 
14
12
  if TYPE_CHECKING:
15
13
  from infrahub.core.branch import Branch
@@ -145,7 +143,7 @@ class NodeHierarchyUpdateValidatorQuery(SchemaValidatorQuery):
145
143
  class NodeHierarchyChecker(ConstraintCheckerInterface):
146
144
  query_classes = [NodeHierarchyUpdateValidatorQuery]
147
145
 
148
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
146
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
149
147
  self.db = db
150
148
  self.branch = branch
151
149
 
@@ -1,12 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Optional
3
+ from typing import TYPE_CHECKING
4
4
 
5
5
  from infrahub_sdk.utils import compare_lists
6
6
 
7
7
  from infrahub.core.constants import PathType
8
8
  from infrahub.core.path import DataPath, GroupedDataPaths
9
- from infrahub.core.schema import NodeSchema
9
+ from infrahub.core.schema import MainSchemaTypes, NodeSchema
10
+ from infrahub.exceptions import SchemaNotFoundError
10
11
 
11
12
  from ..interface import ConstraintCheckerInterface
12
13
 
@@ -18,7 +19,7 @@ if TYPE_CHECKING:
18
19
 
19
20
 
20
21
  class NodeInheritFromChecker(ConstraintCheckerInterface):
21
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
22
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
22
23
  self.db = db
23
24
  self.branch = branch
24
25
 
@@ -41,8 +42,29 @@ class NodeInheritFromChecker(ConstraintCheckerInterface):
41
42
  return grouped_data_paths_list
42
43
 
43
44
  _, removed, _ = compare_lists(list1=current_schema.inherit_from, list2=request.node_schema.inherit_from)
44
-
45
- if removed:
45
+ current_inherit_from_ids = {
46
+ g.id: g.kind
47
+ for g in [
48
+ self.db.schema.get(name=n, branch=request.branch, duplicate=False) for n in current_schema.inherit_from
49
+ ]
50
+ }
51
+
52
+ # Gather IDs for each inherited node in use for candidate schema
53
+ request_inherited: list[MainSchemaTypes] = []
54
+ for n in request.node_schema.inherit_from:
55
+ try:
56
+ schema = request.schema_branch.get(name=n, duplicate=False)
57
+ except SchemaNotFoundError:
58
+ schema = self.db.schema.get(name=n, branch=request.branch, duplicate=False)
59
+ request_inherited.append(schema)
60
+ request_inherit_from_ids = {g.id: g.kind for g in request_inherited}
61
+
62
+ # Compare IDs to find out if some inherited nodes were removed
63
+ # Comparing IDs helps us in understanding if a node was renamed or really removed
64
+ _, removed_ids, _ = compare_lists(
65
+ list1=list(current_inherit_from_ids.keys()), list2=list(request_inherit_from_ids.keys())
66
+ )
67
+ if removed := [current_inherit_from_ids[k] for k in removed_ids]:
46
68
  group_data_path.add_data_path(
47
69
  DataPath(
48
70
  branch=str(request.branch.name),
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Optional
3
+ from typing import TYPE_CHECKING
4
4
 
5
5
  from ..interface import ConstraintCheckerInterface
6
6
  from ..query import NodeNotPresentValidatorQuery
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
16
16
  class NodeRelationshipAddChecker(ConstraintCheckerInterface):
17
17
  query_classes = [NodeNotPresentValidatorQuery]
18
18
 
19
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None):
19
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None):
20
20
  self.db = db
21
21
  self.branch = branch
22
22
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from infrahub.core.constants import PathType, RelationshipCardinality
6
6
  from infrahub.core.path import DataPath, GroupedDataPaths
@@ -22,8 +22,8 @@ class RelationshipCountUpdateValidatorQuery(RelationshipSchemaValidatorQuery):
22
22
 
23
23
  def __init__(
24
24
  self,
25
- min_count_override: Optional[int] = None,
26
- max_count_override: Optional[int] = None,
25
+ min_count_override: int | None = None,
26
+ max_count_override: int | None = None,
27
27
  **kwargs: Any,
28
28
  ) -> None:
29
29
  self.min_count_override = min_count_override
@@ -150,7 +150,7 @@ class RelationshipCountUpdateValidatorQuery(RelationshipSchemaValidatorQuery):
150
150
  class RelationshipCountChecker(ConstraintCheckerInterface):
151
151
  query_classes = [RelationshipCountUpdateValidatorQuery]
152
152
 
153
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
153
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
154
154
  self.db = db
155
155
  self.branch = branch
156
156
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from infrahub.core.constants import PathType
6
6
  from infrahub.core.path import DataPath, GroupedDataPaths
@@ -82,7 +82,7 @@ class RelationshipOptionalUpdateValidatorQuery(RelationshipSchemaValidatorQuery)
82
82
  class RelationshipOptionalChecker(ConstraintCheckerInterface):
83
83
  query_classes = [RelationshipOptionalUpdateValidatorQuery]
84
84
 
85
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
85
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
86
86
  self.db = db
87
87
  self.branch = branch
88
88
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Optional
3
+ from typing import TYPE_CHECKING, Any
4
4
 
5
5
  from infrahub.core.constants import PathType
6
6
  from infrahub.core.path import DataPath, GroupedDataPaths
@@ -108,7 +108,7 @@ class RelationshipPeerUpdateValidatorQuery(RelationshipSchemaValidatorQuery):
108
108
  class RelationshipPeerChecker(ConstraintCheckerInterface):
109
109
  query_classes = [RelationshipPeerUpdateValidatorQuery]
110
110
 
111
- def __init__(self, db: InfrahubDatabase, branch: Optional[Branch] = None) -> None:
111
+ def __init__(self, db: InfrahubDatabase, branch: Branch | None = None) -> None:
112
112
  self.db = db
113
113
  self.branch = branch
114
114
 
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Union
3
+ from typing import Any
4
4
 
5
5
  from infrahub.core.path import GroupedDataPaths, SchemaPath # noqa: TC001
6
6
  from infrahub.core.query import Query, QueryType
@@ -12,7 +12,7 @@ class SchemaValidatorQuery(Query):
12
12
 
13
13
  def __init__(
14
14
  self,
15
- node_schema: Union[NodeSchema, GenericSchema],
15
+ node_schema: NodeSchema | GenericSchema,
16
16
  schema_path: SchemaPath,
17
17
  **kwargs: Any,
18
18
  ) -> None:
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from typing import TYPE_CHECKING
4
+
3
5
  from infrahub_sdk.batch import InfrahubBatch
4
6
  from prefect import flow, task
5
7
  from prefect.cache_policies import NONE
@@ -18,6 +20,9 @@ from infrahub.workflows.utils import add_tags
18
20
 
19
21
  from .models.validate_migration import SchemaValidateMigrationData, SchemaValidatorPathResponseData
20
22
 
23
+ if TYPE_CHECKING:
24
+ from infrahub.core.schema.schema_branch import SchemaBranch
25
+
21
26
 
22
27
  @flow(name="schema_validate_migrations", flow_run_name="Validate schema migrations", persist_result=True)
23
28
  async def schema_validate_migrations(
@@ -43,6 +48,7 @@ async def schema_validate_migrations(
43
48
  constraint_name=constraint.constraint_name,
44
49
  node_schema=schema,
45
50
  schema_path=constraint.path,
51
+ schema_branch=message.schema_branch,
46
52
  service=service,
47
53
  )
48
54
 
@@ -62,6 +68,7 @@ async def schema_path_validate(
62
68
  constraint_name: str,
63
69
  node_schema: NodeSchema | GenericSchema,
64
70
  schema_path: SchemaPath,
71
+ schema_branch: SchemaBranch,
65
72
  service: InfrahubServices,
66
73
  ) -> SchemaValidatorPathResponseData:
67
74
  async with service.database.start_session() as db:
@@ -70,6 +77,7 @@ async def schema_path_validate(
70
77
  constraint_name=constraint_name,
71
78
  node_schema=node_schema,
72
79
  schema_path=schema_path,
80
+ schema_branch=schema_branch,
73
81
  )
74
82
 
75
83
  component_registry = get_component_registry()
@@ -1,21 +1,16 @@
1
+ from __future__ import annotations
2
+
1
3
  import asyncio
2
4
  from itertools import chain
3
- from typing import Optional, Union
5
+ from typing import TYPE_CHECKING
4
6
 
5
7
  from infrahub.core import registry
6
8
  from infrahub.core.branch import Branch
7
9
  from infrahub.core.path import DataPath, GroupedDataPaths
8
- from infrahub.core.query import QueryResult
9
- from infrahub.core.schema import (
10
- AttributeSchema,
11
- MainSchemaTypes,
12
- RelationshipSchema,
13
- )
10
+ from infrahub.core.schema import AttributeSchema, MainSchemaTypes, RelationshipSchema
14
11
  from infrahub.core.validators.uniqueness.index import UniquenessQueryResultsIndex
15
- from infrahub.database import InfrahubDatabase
16
12
 
17
13
  from ..interface import ConstraintCheckerInterface
18
- from ..model import SchemaConstraintValidatorRequest
19
14
  from .model import (
20
15
  NodeUniquenessQueryRequest,
21
16
  NonUniqueAttribute,
@@ -26,10 +21,16 @@ from .model import (
26
21
  )
27
22
  from .query import NodeUniqueAttributeConstraintQuery
28
23
 
24
+ if TYPE_CHECKING:
25
+ from infrahub.core.query import QueryResult
26
+ from infrahub.database import InfrahubDatabase
27
+
28
+ from ..model import SchemaConstraintValidatorRequest
29
+
29
30
 
30
31
  def get_attribute_path_from_string(
31
32
  path: str, schema: MainSchemaTypes
32
- ) -> tuple[Union[AttributeSchema, RelationshipSchema], Optional[str]]:
33
+ ) -> tuple[AttributeSchema | RelationshipSchema, str | None]:
33
34
  if "__" in path:
34
35
  name, property_name = path.split("__")
35
36
  else:
@@ -45,7 +46,7 @@ def get_attribute_path_from_string(
45
46
 
46
47
  class UniquenessChecker(ConstraintCheckerInterface):
47
48
  def __init__(
48
- self, db: InfrahubDatabase, branch: Optional[Union[Branch, str]] = None, max_concurrent_execution: int = 5
49
+ self, db: InfrahubDatabase, branch: Branch | str | None = None, max_concurrent_execution: int = 5
49
50
  ) -> None:
50
51
  self.db = db
51
52
  self.branch = branch
@@ -130,22 +131,22 @@ class UniquenessChecker(ConstraintCheckerInterface):
130
131
 
131
132
  branch = await self.get_branch()
132
133
  schema_branch = self.db.schema.get_schema_branch(name=branch.name)
133
- path_groups = schema.get_unique_constraint_schema_attribute_paths(
134
- include_unique_attributes=True, schema_branch=schema_branch
135
- )
136
- for constraint_group in path_groups:
134
+ uniqueness_constraint_paths = schema.get_unique_constraint_schema_attribute_paths(schema_branch=schema_branch)
135
+ for uniqueness_constraint_path in uniqueness_constraint_paths:
137
136
  non_unique_nodes_by_id: dict[str, NonUniqueNode] = {}
138
137
  constraint_group_relationship_identifiers = [
139
138
  schema_attribute_path.relationship_schema.get_identifier()
140
- for schema_attribute_path in constraint_group
139
+ for schema_attribute_path in uniqueness_constraint_path.attributes_paths
141
140
  if schema_attribute_path.relationship_schema
142
141
  ]
143
142
  constraint_group_attribute_names = [
144
143
  schema_attribute_path.attribute_schema.name
145
- for schema_attribute_path in constraint_group
144
+ for schema_attribute_path in uniqueness_constraint_path.attributes_paths
146
145
  if schema_attribute_path.attribute_schema
147
146
  ]
148
- node_ids_in_violation = results_index.get_node_ids_for_path_group(path_group=constraint_group)
147
+ node_ids_in_violation = results_index.get_node_ids_for_path_group(
148
+ path_group=uniqueness_constraint_path.attributes_paths
149
+ )
149
150
  for result in query_results:
150
151
  node_id = str(result.get("node_id"))
151
152
  if node_id not in node_ids_in_violation:
@@ -189,14 +190,14 @@ class UniquenessChecker(ConstraintCheckerInterface):
189
190
 
190
191
  def get_uniqueness_violations(
191
192
  self, non_unique_node: NonUniqueNode
192
- ) -> set[Union[NonUniqueAttribute, NonUniqueRelatedAttribute]]:
193
- constraint_violations: set[Union[NonUniqueAttribute, NonUniqueRelatedAttribute]] = set()
193
+ ) -> set[NonUniqueAttribute | NonUniqueRelatedAttribute]:
194
+ constraint_violations: set[NonUniqueAttribute | NonUniqueRelatedAttribute] = set()
194
195
  for attribute_schema in non_unique_node.node_schema.unique_attributes:
195
196
  violation = non_unique_node.get_attribute_violation(attribute_schema.name)
196
197
  if violation:
197
198
  constraint_violations.add(violation)
198
199
  for uniqueness_constraint in non_unique_node.node_schema.uniqueness_constraints or []:
199
- constraint_spec: list[tuple[Union[AttributeSchema, RelationshipSchema], Optional[str]]] = []
200
+ constraint_spec: list[tuple[AttributeSchema | RelationshipSchema, str | None]] = []
200
201
  for element in uniqueness_constraint:
201
202
  sub_schema, property_name = get_attribute_path_from_string(element, non_unique_node.node_schema)
202
203
  constraint_spec.append((sub_schema, property_name))
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from collections import defaultdict
4
- from typing import TYPE_CHECKING, Any, Iterable, Optional
4
+ from typing import TYPE_CHECKING, Any, Iterable
5
5
 
6
6
  if TYPE_CHECKING:
7
7
  from infrahub.core.query import QueryResult
@@ -29,7 +29,7 @@ class GroupedIndexKey:
29
29
 
30
30
 
31
31
  class UniquenessQueryResultsIndex:
32
- def __init__(self, query_results: Iterable[QueryResult], exclude_node_ids: Optional[set[str]] = None) -> None:
32
+ def __init__(self, query_results: Iterable[QueryResult], exclude_node_ids: set[str] | None = None) -> None:
33
33
  self._relationship_index: dict[str, dict[str, set[str]]] = {}
34
34
  self._attribute_index: dict[str, dict[Any, set[str]]] = {}
35
35
  self._node_index: dict[str, dict[str, Any]] = {}
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional, Union
1
+ from typing import Any
2
2
 
3
3
  from pydantic import BaseModel, Field
4
4
 
@@ -8,8 +8,8 @@ from infrahub.core.schema import AttributeSchema, MainSchemaTypes, RelationshipS
8
8
 
9
9
  class QueryRelationshipAttributePath(BaseModel):
10
10
  identifier: str
11
- attribute_name: Optional[str] = Field(default=None)
12
- value: Optional[Any] = Field(default=None)
11
+ attribute_name: str | None = Field(default=None)
12
+ value: Any | None = Field(default=None)
13
13
 
14
14
  def __hash__(self) -> int:
15
15
  to_hash = self.identifier
@@ -22,8 +22,8 @@ class QueryRelationshipAttributePath(BaseModel):
22
22
 
23
23
  class QueryAttributePath(BaseModel):
24
24
  attribute_name: str
25
- property_name: Optional[str] = Field(default=None)
26
- value: Optional[Any] = Field(default=None)
25
+ property_name: str | None = Field(default=None)
26
+ value: Any | None = Field(default=None)
27
27
 
28
28
  def __hash__(self) -> int:
29
29
  to_hash = self.attribute_name
@@ -118,8 +118,8 @@ class NonUniqueNode(BaseModel):
118
118
  non_unique_related_attributes: list[NonUniqueRelatedAttribute] = Field(default_factory=list)
119
119
 
120
120
  def get_relationship_violation(
121
- self, relationship_name: str, attribute_name: Optional[str]
122
- ) -> Optional[NonUniqueRelatedAttribute]:
121
+ self, relationship_name: str, attribute_name: str | None
122
+ ) -> NonUniqueRelatedAttribute | None:
123
123
  attribute_names = {attribute_name}
124
124
  if attribute_name is None:
125
125
  attribute_names.add("id")
@@ -128,16 +128,16 @@ class NonUniqueNode(BaseModel):
128
128
  return nura
129
129
  return None
130
130
 
131
- def get_attribute_violation(self, attribute_name: str) -> Optional[NonUniqueAttribute]:
131
+ def get_attribute_violation(self, attribute_name: str) -> NonUniqueAttribute | None:
132
132
  for nua in self.non_unique_attributes:
133
133
  if nua.attribute_name == attribute_name:
134
134
  return nua
135
135
  return None
136
136
 
137
137
  def get_constraint_violation(
138
- self, constraint_specifications: list[tuple[Union[AttributeSchema, RelationshipSchema], Optional[str]]]
139
- ) -> Optional[list[Union[NonUniqueAttribute, NonUniqueRelatedAttribute]]]:
140
- violations: list[Union[NonUniqueAttribute, NonUniqueRelatedAttribute]] = []
138
+ self, constraint_specifications: list[tuple[AttributeSchema | RelationshipSchema, str | None]]
139
+ ) -> list[NonUniqueAttribute | NonUniqueRelatedAttribute] | None:
140
+ violations: list[NonUniqueAttribute | NonUniqueRelatedAttribute] = []
141
141
  for sub_schema, property_name in constraint_specifications:
142
142
  if isinstance(sub_schema, AttributeSchema):
143
143
  attribute_violation = self.get_attribute_violation(sub_schema.name)
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import asyncio
4
4
  import random
5
5
  from dataclasses import dataclass
6
- from typing import TYPE_CHECKING, Any, Callable, Coroutine, Optional, TypeVar, Union
6
+ from typing import TYPE_CHECKING, Any, Callable, Coroutine, TypeVar
7
7
 
8
8
  from neo4j import (
9
9
  READ_ACCESS,
@@ -34,7 +34,7 @@ from infrahub.utils import InfrahubStringEnum
34
34
 
35
35
  from .constants import DatabaseType, Neo4jRuntime
36
36
  from .memgraph import DatabaseManagerMemgraph
37
- from .metrics import QUERY_EXECUTION_METRICS, TRANSACTION_RETRIES
37
+ from .metrics import CONNECTION_POOL_USAGE, QUERY_EXECUTION_METRICS, TRANSACTION_RETRIES
38
38
  from .neo4j import DatabaseManagerNeo4j
39
39
 
40
40
  if TYPE_CHECKING:
@@ -69,7 +69,7 @@ class InfrahubDatabaseSessionMode(InfrahubStringEnum):
69
69
  WRITE = "write"
70
70
 
71
71
 
72
- def get_branch_name(branch: Optional[Union[Branch, str]] = None) -> str:
72
+ def get_branch_name(branch: Branch | str | None = None) -> str:
73
73
  if not branch:
74
74
  return registry.default_branch
75
75
  if isinstance(branch, str):
@@ -82,43 +82,39 @@ class DatabaseSchemaManager:
82
82
  def __init__(self, db: InfrahubDatabase) -> None:
83
83
  self._db = db
84
84
 
85
- def get(self, name: str, branch: Optional[Union[Branch, str]] = None, duplicate: bool = True) -> MainSchemaTypes:
85
+ def get(self, name: str, branch: Branch | str | None = None, duplicate: bool = True) -> MainSchemaTypes:
86
86
  branch_name = get_branch_name(branch=branch)
87
87
  if branch_name not in self._db._schemas:
88
88
  return registry.schema.get(name=name, branch=branch, duplicate=duplicate)
89
89
  return self._db._schemas[branch_name].get(name=name, duplicate=duplicate)
90
90
 
91
- def get_node_schema(
92
- self, name: str, branch: Optional[Union[Branch, str]] = None, duplicate: bool = True
93
- ) -> NodeSchema:
91
+ def get_node_schema(self, name: str, branch: Branch | str | None = None, duplicate: bool = True) -> NodeSchema:
94
92
  schema = self.get(name=name, branch=branch, duplicate=duplicate)
95
93
  if schema.is_node_schema:
96
94
  return schema
97
95
 
98
96
  raise ValueError("The selected node is not of type NodeSchema")
99
97
 
100
- def set(self, name: str, schema: MainSchemaTypes, branch: Optional[str] = None) -> int:
98
+ def set(self, name: str, schema: MainSchemaTypes, branch: str | None = None) -> int:
101
99
  branch_name = get_branch_name(branch=branch)
102
100
  if branch_name not in self._db._schemas:
103
101
  return registry.schema.set(name=name, schema=schema, branch=branch)
104
102
  return self._db._schemas[branch_name].set(name=name, schema=schema)
105
103
 
106
- def has(self, name: str, branch: Optional[Union[Branch, str]] = None) -> bool:
104
+ def has(self, name: str, branch: Branch | str | None = None) -> bool:
107
105
  branch_name = get_branch_name(branch=branch)
108
106
  if branch_name not in self._db._schemas:
109
107
  return registry.schema.has(name=name, branch=branch)
110
108
  return self._db._schemas[branch_name].has(name=name)
111
109
 
112
- def get_full(
113
- self, branch: Optional[Union[Branch, str]] = None, duplicate: bool = True
114
- ) -> dict[str, MainSchemaTypes]:
110
+ def get_full(self, branch: Branch | str | None = None, duplicate: bool = True) -> dict[str, MainSchemaTypes]:
115
111
  branch_name = get_branch_name(branch=branch)
116
112
  if branch_name not in self._db._schemas:
117
113
  return registry.schema.get_full(branch=branch)
118
114
  return self._db._schemas[branch_name].get_all(duplicate=duplicate)
119
115
 
120
116
  async def get_full_safe(
121
- self, branch: Optional[Union[Branch, str]] = None, duplicate: bool = True
117
+ self, branch: Branch | str | None = None, duplicate: bool = True
122
118
  ) -> dict[str, MainSchemaTypes]:
123
119
  await lock.registry.local_schema_wait()
124
120
  return self.get_full(branch=branch, duplicate=duplicate)
@@ -206,10 +202,10 @@ class InfrahubDatabase:
206
202
 
207
203
  return {}
208
204
 
209
- def add_schema(self, schema: SchemaBranch, name: Optional[str] = None) -> None:
205
+ def add_schema(self, schema: SchemaBranch, name: str | None = None) -> None:
210
206
  self._schemas[name or schema.name] = schema
211
207
 
212
- def start_session(self, read_only: bool = False, schemas: Optional[list[SchemaBranch]] = None) -> InfrahubDatabase:
208
+ def start_session(self, read_only: bool = False, schemas: list[SchemaBranch] | None = None) -> InfrahubDatabase:
213
209
  """Create a new InfrahubDatabase object in Session mode."""
214
210
  session_mode = InfrahubDatabaseSessionMode.WRITE
215
211
  if read_only:
@@ -229,7 +225,7 @@ class InfrahubDatabase:
229
225
  **context,
230
226
  )
231
227
 
232
- def start_transaction(self, schemas: Optional[list[SchemaBranch]] = None) -> InfrahubDatabase:
228
+ def start_transaction(self, schemas: list[SchemaBranch] | None = None) -> InfrahubDatabase:
233
229
  context = self.get_context()
234
230
 
235
231
  return self.__class__(
@@ -261,7 +257,7 @@ class InfrahubDatabase:
261
257
  self._is_session_local = True
262
258
  return self._session
263
259
 
264
- async def transaction(self, name: Optional[str]) -> AsyncTransaction:
260
+ async def transaction(self, name: str | None) -> AsyncTransaction:
265
261
  if self._transaction:
266
262
  return self._transaction
267
263
 
@@ -290,9 +286,9 @@ class InfrahubDatabase:
290
286
 
291
287
  async def __aexit__(
292
288
  self,
293
- exc_type: Optional[type[BaseException]],
294
- exc_value: Optional[BaseException],
295
- traceback: Optional[TracebackType],
289
+ exc_type: type[BaseException] | None,
290
+ exc_value: BaseException | None,
291
+ traceback: TracebackType | None,
296
292
  ):
297
293
  if self._mode == InfrahubDatabaseMode.SESSION:
298
294
  return await self._session.close()
@@ -335,6 +331,14 @@ class InfrahubDatabase:
335
331
  context: dict[str, str] | None = None,
336
332
  type: QueryType | None = None,
337
333
  ) -> tuple[list[Record], dict[str, Any]]:
334
+ connpool_usage = self._driver._pool.in_use_connection_count(self._driver._pool.address)
335
+ CONNECTION_POOL_USAGE.labels(self._driver._pool.address).set(float(connpool_usage))
336
+
337
+ if config.SETTINGS.database.max_concurrent_queries:
338
+ while connpool_usage > config.SETTINGS.database.max_concurrent_queries: # noqa: ASYNC110
339
+ await asyncio.sleep(config.SETTINGS.database.max_concurrent_queries_delay)
340
+ connpool_usage = self._driver._pool.in_use_connection_count(self._driver._pool.address)
341
+
338
342
  with trace.get_tracer(__name__).start_as_current_span("execute_db_query_with_metadata") as span:
339
343
  span.set_attribute("query", query)
340
344
  if name:
@@ -385,9 +389,9 @@ class InfrahubDatabase:
385
389
  return results, response._metadata or {}
386
390
 
387
391
  async def run_query(
388
- self, query: str, params: Optional[dict[str, Any]] = None, name: Optional[str] = "undefined"
392
+ self, query: str, params: dict[str, Any] | None = None, name: str | None = "undefined"
389
393
  ) -> AsyncResult:
390
- _query: Union[str | Query] = query
394
+ _query: str | Query = query
391
395
  if self.is_transaction:
392
396
  execution_method = await self.transaction(name=name)
393
397
  else:
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from prometheus_client import Counter, Histogram
3
+ from prometheus_client import Counter, Gauge, Histogram
4
4
 
5
5
  METRIC_PREFIX = "infrahub_db"
6
6
 
@@ -16,3 +16,9 @@ TRANSACTION_RETRIES = Counter(
16
16
  "Number of transaction that have been retried due to transcient error",
17
17
  labelnames=["name"],
18
18
  )
19
+
20
+ CONNECTION_POOL_USAGE = Gauge(
21
+ f"{METRIC_PREFIX}_last_connection_pool_usage",
22
+ "Number of last known active connections in the pool",
23
+ labelnames=["address"],
24
+ )
@@ -13,9 +13,7 @@ class NodeConstraintRunnerDependency(DependencyBuilder[NodeConstraintRunner]):
13
13
  return NodeConstraintRunner(
14
14
  db=context.db,
15
15
  branch=context.branch,
16
- node_constraints=[
17
- NodeGroupedUniquenessConstraintDependency.build(context=context),
18
- ],
16
+ uniqueness_constraint=NodeGroupedUniquenessConstraintDependency.build(context=context),
19
17
  relationship_manager_constraints=[
20
18
  RelationshipPeerKindConstraintDependency.build(context=context),
21
19
  RelationshipCountConstraintDependency.build(context=context),
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import inspect
4
- from typing import TYPE_CHECKING, Optional, TypeVar
4
+ from typing import TYPE_CHECKING, TypeVar
5
5
 
6
6
  from ..interface import DependencyBuilderContext
7
7
  from .exceptions import UntrackedDependencyError
@@ -17,7 +17,7 @@ T = TypeVar("T")
17
17
 
18
18
 
19
19
  class ComponentDependencyRegistry:
20
- the_instance: Optional[ComponentDependencyRegistry] = None
20
+ the_instance: ComponentDependencyRegistry | None = None
21
21
 
22
22
  def __init__(self) -> None:
23
23
  self._available_components: dict[type, type[DependencyBuilder]] = {}
@@ -1,4 +1,27 @@
1
+ from .artifact_action import ArtifactCreatedEvent, ArtifactUpdatedEvent
2
+ from .branch_action import BranchCreatedEvent, BranchDeletedEvent, BranchMergedEvent, BranchRebasedEvent
3
+ from .group_action import GroupMemberAddedEvent, GroupMemberRemovedEvent
1
4
  from .models import EventMeta, InfrahubEvent
2
- from .node_action import NodeMutatedEvent
5
+ from .node_action import NodeCreatedEvent, NodeDeletedEvent, NodeUpdatedEvent
6
+ from .repository_action import CommitUpdatedEvent
7
+ from .validator_action import ValidatorFailedEvent, ValidatorPassedEvent, ValidatorStartedEvent
3
8
 
4
- __all__ = ["EventMeta", "InfrahubEvent", "NodeMutatedEvent"]
9
+ __all__ = [
10
+ "ArtifactCreatedEvent",
11
+ "ArtifactUpdatedEvent",
12
+ "BranchCreatedEvent",
13
+ "BranchDeletedEvent",
14
+ "BranchMergedEvent",
15
+ "BranchRebasedEvent",
16
+ "CommitUpdatedEvent",
17
+ "EventMeta",
18
+ "GroupMemberAddedEvent",
19
+ "GroupMemberRemovedEvent",
20
+ "InfrahubEvent",
21
+ "NodeCreatedEvent",
22
+ "NodeDeletedEvent",
23
+ "NodeUpdatedEvent",
24
+ "ValidatorFailedEvent",
25
+ "ValidatorPassedEvent",
26
+ "ValidatorStartedEvent",
27
+ ]