buildzr 0.0.3__tar.gz → 0.0.5__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.
Files changed (40) hide show
  1. {buildzr-0.0.3 → buildzr-0.0.5}/PKG-INFO +1 -1
  2. buildzr-0.0.5/buildzr/__about__.py +1 -0
  3. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/interfaces/interfaces.py +8 -3
  4. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/relations.py +49 -10
  5. {buildzr-0.0.3 → buildzr-0.0.5}/tests/test_dsl.py +45 -0
  6. buildzr-0.0.3/buildzr/__about__.py +0 -1
  7. {buildzr-0.0.3 → buildzr-0.0.5}/.gitignore +0 -0
  8. {buildzr-0.0.3 → buildzr-0.0.5}/CONTRIBUTING.md +0 -0
  9. {buildzr-0.0.3 → buildzr-0.0.5}/LICENSE.md +0 -0
  10. {buildzr-0.0.3 → buildzr-0.0.5}/README.md +0 -0
  11. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/__init__.py +0 -0
  12. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/__init__.py +0 -0
  13. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/dsl.py +0 -0
  14. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/explorer.py +0 -0
  15. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/expression.py +0 -0
  16. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/factory/__init__.py +0 -0
  17. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/factory/gen_id.py +0 -0
  18. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/dsl/interfaces/__init__.py +0 -0
  19. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/encoders/__init__.py +0 -0
  20. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/encoders/encoder.py +0 -0
  21. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/models/__init__.py +0 -0
  22. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/models/generate.sh +0 -0
  23. {buildzr-0.0.3 → buildzr-0.0.5}/buildzr/models/models.py +0 -0
  24. {buildzr-0.0.3 → buildzr-0.0.5}/pyproject.toml +0 -0
  25. {buildzr-0.0.3 → buildzr-0.0.5}/tests/__init__.py +0 -0
  26. {buildzr-0.0.3 → buildzr-0.0.5}/tests/abstract_builder.py +0 -0
  27. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/__init__.py +0 -0
  28. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/component_view.py +0 -0
  29. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/container_view.py +0 -0
  30. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/container_view_sugar.py +0 -0
  31. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/groups.py +0 -0
  32. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/implied_relationships.py +0 -0
  33. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/simple.py +0 -0
  34. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/simple_dsl.py +0 -0
  35. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/system_context_view.py +0 -0
  36. {buildzr-0.0.3 → buildzr-0.0.5}/tests/samples/system_landscape_view.py +0 -0
  37. {buildzr-0.0.3 → buildzr-0.0.5}/tests/test_explorer.py +0 -0
  38. {buildzr-0.0.3 → buildzr-0.0.5}/tests/test_expression.py +0 -0
  39. {buildzr-0.0.3 → buildzr-0.0.5}/tests/test_views.py +0 -0
  40. {buildzr-0.0.3 → buildzr-0.0.5}/tests/test_workspaces.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: buildzr
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Structurizr for the `buildzr`s 🧱⚒️
5
5
  Project-URL: homepage, https://github.com/amirulmenjeni/buildzr
6
6
  Project-URL: issues, https://github.com/amirulmenjeni/buildzr/issues
@@ -0,0 +1 @@
1
+ VERSION = "0.0.5"
@@ -52,6 +52,11 @@ class BindLeft(ABC, Generic[TSrc, TDst]):
52
52
 
53
53
  class BindRight(ABC, Generic[TSrc, TDst]):
54
54
 
55
+ @overload
56
+ @abstractmethod
57
+ def __rshift__(self, other: TDst) -> 'DslRelationship[TSrc, TDst]':
58
+ ...
59
+
55
60
  @overload
56
61
  @abstractmethod
57
62
  def __rshift__(self, description_and_technology: Tuple[str, str]) -> BindLeft[TSrc, TDst]:
@@ -64,11 +69,11 @@ class BindRight(ABC, Generic[TSrc, TDst]):
64
69
 
65
70
  @overload
66
71
  @abstractmethod
67
- def __rshift__(self, multiple_destinations: List[BindLeftLate[TDst]]) -> 'List[DslRelationship[TSrc, TDst]]':
72
+ def __rshift__(self, multiple_destinations: List[Union[TDst, BindLeftLate[TDst]]]) -> 'List[DslRelationship[TSrc, TDst]]':
68
73
  ...
69
74
 
70
75
  @abstractmethod
71
- def __rshift__(self, other: Union[str, Tuple[str, str], List[BindLeftLate[TDst]]]) -> Union[BindLeft[TSrc, TDst], 'List[DslRelationship[TSrc, TDst]]']:
76
+ def __rshift__(self, other: Union[TDst, str, Tuple[str, str], List[Union[TDst, BindLeftLate[TDst]]]]) -> Union[BindLeft[TSrc, TDst], 'DslRelationship[TSrc, TDst]', 'List[DslRelationship[TSrc, TDst]]']:
72
77
  ...
73
78
 
74
79
  class DslWorkspaceElement(ABC):
@@ -204,4 +209,4 @@ class DslViewsElement(ABC):
204
209
  @property
205
210
  @abstractmethod
206
211
  def parent(self) -> DslWorkspaceElement:
207
- pass
212
+ pass
@@ -37,6 +37,14 @@ def _is_container_fluent_relationship(
37
37
  ) -> TypeIs['_FluentRelationship[buildzr.dsl.Container]']:
38
38
  return isinstance(obj._parent, buildzr.dsl.Container)
39
39
 
40
+ def _is_list_of_dslelements_or_usesfromlates(
41
+ obj: list
42
+ ) -> TypeIs[List[Union[DslElement, '_UsesFromLate[DslElement]']]]:
43
+ return all(
44
+ isinstance(item, DslElement) or isinstance(item, _UsesFromLate)
45
+ for item in obj
46
+ )
47
+
40
48
  @dataclass
41
49
  class With:
42
50
  tags: Optional[Set[str]] = None
@@ -306,7 +314,18 @@ class DslElementRelationOverrides(DslElement):
306
314
  elements.
307
315
  """
308
316
 
309
- @overload # type: ignore[override]
317
+ # TODO: Check why need to ignore the override error here.
318
+ @overload # type: ignore[override]
319
+ def __rshift__(self, other: DslElement) -> _Relationship[Self, DslElement]:
320
+ """
321
+ Create a relationship between the source element and the destination
322
+ without specifying description or technology.
323
+
324
+ Example: `source >> destination`.
325
+ """
326
+ ...
327
+
328
+ @overload
310
329
  def __rshift__(self, description_and_technology: Tuple[str, str]) -> _UsesFrom[Self, DslElement]:
311
330
  ...
312
331
 
@@ -319,29 +338,49 @@ class DslElementRelationOverrides(DslElement):
319
338
  ...
320
339
 
321
340
  @overload
322
- def __rshift__(self, multiple_destinations: List[_UsesFromLate[DslElement]]) -> List[_Relationship[Self, DslElement]]:
341
+ def __rshift__(self, multiple_destinations: List[Union[DslElement, _UsesFromLate[DslElement]]]) -> List[_Relationship[Self, DslElement]]:
323
342
  ...
324
343
 
325
344
  def __rshift__(
326
345
  self,
327
346
  other: Union[
347
+ DslElement,
328
348
  str,
329
349
  Tuple[str, str],
330
350
  _RelationshipDescription[DslElement],
331
- List[_UsesFromLate[DslElement]]
332
- ]) -> Union[_UsesFrom[Self, DslElement], List[_Relationship[Self, DslElement]]]:
333
- if isinstance(other, str):
351
+ List[Union[DslElement, _UsesFromLate[DslElement]]]
352
+ ]) -> Union[_UsesFrom[Self, DslElement], _Relationship[Self, DslElement], List[_Relationship[Self, DslElement]]]:
353
+ if isinstance(other, DslElement):
354
+ return cast(
355
+ _Relationship[Self, DslElement],
356
+ cast(
357
+ _UsesFrom[Self, DslElement],
358
+ _UsesFrom(self)
359
+ ) >> other
360
+ )
361
+ elif isinstance(other, str):
334
362
  return _UsesFrom(self, other)
335
363
  elif isinstance(other, tuple):
336
364
  return _UsesFrom(self, description=other[0], technology=other[1])
337
365
  elif isinstance(other, _RelationshipDescription):
338
366
  return _UsesFrom(self, description=other._description, technology=other._technology)
339
- elif isinstance(other, list):
340
- relationships = []
367
+ elif _is_list_of_dslelements_or_usesfromlates(other):
368
+ relationships: List[_Relationship[Self, DslElement]] = []
341
369
  for dest in other:
342
- dest.set_source(self)
343
- relationships.append(dest.get_relationship())
344
- return cast(List[_Relationship[Self, DslElement]], relationships)
370
+ if isinstance(dest, _UsesFromLate):
371
+ dest.set_source(self)
372
+ relationships.append(dest.get_relationship())
373
+ elif isinstance(dest, DslElement):
374
+ relationships.append(
375
+ cast(
376
+ _Relationship[Self, DslElement],
377
+ cast(
378
+ _UsesFrom[Self, DslElement],
379
+ _UsesFrom(self)
380
+ ) >> dest
381
+ )
382
+ )
383
+ return relationships
345
384
  else:
346
385
  raise TypeError(f"Unsupported operand type for >>: '{type(self).__name__}' and {type(other).__name__}")
347
386
 
@@ -799,3 +799,48 @@ def test_grouping() -> Optional[None]:
799
799
  assert a.container().a1.model.relationships[0].destinationId == b.container().b1.model.id
800
800
  assert b.container().b2.component().c1.model.group == "Company 2"
801
801
  assert a.model.relationships[1].destinationId == w.software_system().c.model.id
802
+
803
+ def test_dsl_relationship_without_desc() -> Optional[None]:
804
+
805
+ w = Workspace("w")\
806
+ .contains(
807
+ Person("User"),
808
+ SoftwareSystem("Software 1"),
809
+ SoftwareSystem("Software 2"),
810
+ )\
811
+ .where(lambda w: [
812
+ # TODO: Check why mypy fails here.
813
+ w.person().user >> w.software_system().software_1,
814
+ ])
815
+
816
+ assert w.person().user.model.relationships[0].description == ""
817
+ assert w.person().user.model.relationships[0].technology == ""
818
+ assert w.person().user.model.relationships[0].destinationId == w.software_system().software_1.model.id
819
+
820
+ def test_dsl_relationship_without_desc_multiple_dest() -> Optional[None]:
821
+
822
+ w = Workspace("w")\
823
+ .contains(
824
+ Person("User"),
825
+ SoftwareSystem("Software 1"),
826
+ SoftwareSystem("Software 2"),
827
+ SoftwareSystem("Software 3"),
828
+ )\
829
+ .where(lambda w: [
830
+ w.person().user >> [
831
+ w.software_system().software_1,
832
+ desc("browses") >> w.software_system().software_2,
833
+ w.software_system().software_3,
834
+ ]
835
+ ])
836
+
837
+ assert len(w.person().user.model.relationships) == 3
838
+ assert not w.person().user.model.relationships[0].description
839
+ assert not w.person().user.model.relationships[0].technology
840
+ assert w.person().user.model.relationships[1].description == "browses"
841
+ assert not w.person().user.model.relationships[1].technology
842
+ assert not w.person().user.model.relationships[2].description
843
+ assert not w.person().user.model.relationships[2].technology
844
+ assert w.person().user.model.relationships[0].destinationId == w.software_system().software_1.model.id
845
+ assert w.person().user.model.relationships[1].destinationId == w.software_system().software_2.model.id
846
+ assert w.person().user.model.relationships[2].destinationId == w.software_system().software_3.model.id
@@ -1 +0,0 @@
1
- VERSION = "0.0.3"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes