resource-engine-devtools 0.1.0__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 (88) hide show
  1. resource_engine_devtools/__init__.py +6 -0
  2. resource_engine_devtools/ai/__init__.py +1 -0
  3. resource_engine_devtools/ai/example.py +66 -0
  4. resource_engine_devtools/ai/installer.py +424 -0
  5. resource_engine_devtools/ai/skill/SKILL.md +130 -0
  6. resource_engine_devtools/ai/skill/examples/README.md +7 -0
  7. resource_engine_devtools/ai/skill/examples/invoices/__init__.py +0 -0
  8. resource_engine_devtools/ai/skill/examples/invoices/app.py +245 -0
  9. resource_engine_devtools/ai/skill/examples/invoices/application/__init__.py +0 -0
  10. resource_engine_devtools/ai/skill/examples/invoices/application/actions.py +61 -0
  11. resource_engine_devtools/ai/skill/examples/invoices/application/balances.py +51 -0
  12. resource_engine_devtools/ai/skill/examples/invoices/application/customers.py +35 -0
  13. resource_engine_devtools/ai/skill/examples/invoices/application/hooks.py +61 -0
  14. resource_engine_devtools/ai/skill/examples/invoices/application/processes.py +80 -0
  15. resource_engine_devtools/ai/skill/examples/invoices/application/resource.py +112 -0
  16. resource_engine_devtools/ai/skill/examples/invoices/application/schemas.py +164 -0
  17. resource_engine_devtools/ai/skill/examples/invoices/application/tags.py +77 -0
  18. resource_engine_devtools/ai/skill/examples/invoices/authz.py +126 -0
  19. resource_engine_devtools/ai/skill/examples/invoices/bootstrap.py +80 -0
  20. resource_engine_devtools/ai/skill/examples/invoices/domain/__init__.py +0 -0
  21. resource_engine_devtools/ai/skill/examples/invoices/domain/entities.py +112 -0
  22. resource_engine_devtools/ai/skill/examples/invoices/domain/events.py +22 -0
  23. resource_engine_devtools/ai/skill/examples/invoices/domain/state_machine.py +88 -0
  24. resource_engine_devtools/ai/skill/examples/invoices/infrastructure/__init__.py +0 -0
  25. resource_engine_devtools/ai/skill/examples/invoices/infrastructure/persistence.py +121 -0
  26. resource_engine_devtools/ai/skill/examples/invoices/locale/en/LC_MESSAGES/messages.po +682 -0
  27. resource_engine_devtools/ai/skill/examples/invoices/locale/es/LC_MESSAGES/messages.po +685 -0
  28. resource_engine_devtools/ai/skill/examples/invoices/notifications.py +47 -0
  29. resource_engine_devtools/ai/skill/examples/invoices/templates/email/base.html +7 -0
  30. resource_engine_devtools/ai/skill/examples/invoices/templates/email/invoice_approved.html +5 -0
  31. resource_engine_devtools/ai/skill/examples/invoices/templates/email/invoice_approved.subject.txt +1 -0
  32. resource_engine_devtools/ai/skill/examples/invoices/templates/email/invoice_approved.txt +5 -0
  33. resource_engine_devtools/ai/skill/examples/invoices/tests/conftest.py +40 -0
  34. resource_engine_devtools/ai/skill/examples/invoices/tests/test_invoices_engine.py +241 -0
  35. resource_engine_devtools/ai/skill/examples/invoices/worker.py +53 -0
  36. resource_engine_devtools/ai/skill/llms.txt +25 -0
  37. resource_engine_devtools/ai/skill/references/anti-patterns.md +209 -0
  38. resource_engine_devtools/ai/skill/references/docstrings.md +97 -0
  39. resource_engine_devtools/ai/skill/references/errors.md +81 -0
  40. resource_engine_devtools/ai/skill/references/lifecycle.md +118 -0
  41. resource_engine_devtools/ai/skill/references/permissions.md +111 -0
  42. resource_engine_devtools/ai/skill/references/resource.md +301 -0
  43. resource_engine_devtools/ai/skill/references/state-machines.md +126 -0
  44. resource_engine_devtools/ai/skill/references/testing.md +80 -0
  45. resource_engine_devtools/ai/templates/agents_block.md +26 -0
  46. resource_engine_devtools/ai/templates/cursor_rule.mdc +7 -0
  47. resource_engine_devtools/check.py +67 -0
  48. resource_engine_devtools/cli.py +1112 -0
  49. resource_engine_devtools/consumer_scaffold.py +715 -0
  50. resource_engine_devtools/contracts.py +471 -0
  51. resource_engine_devtools/db.py +132 -0
  52. resource_engine_devtools/declarations_check.py +116 -0
  53. resource_engine_devtools/documentation/__init__.py +10 -0
  54. resource_engine_devtools/documentation/docstrings.py +72 -0
  55. resource_engine_devtools/documentation/generators/__init__.py +9 -0
  56. resource_engine_devtools/documentation/generators/ai_context.py +121 -0
  57. resource_engine_devtools/documentation/generators/api.py +63 -0
  58. resource_engine_devtools/documentation/generators/json.py +12 -0
  59. resource_engine_devtools/documentation/generators/markdown.py +687 -0
  60. resource_engine_devtools/documentation/generators/mermaid.py +22 -0
  61. resource_engine_devtools/documentation/generators/site.py +379 -0
  62. resource_engine_devtools/documentation/generators/site_assets/site.css +62 -0
  63. resource_engine_devtools/documentation/generators/site_assets/site.js +54 -0
  64. resource_engine_devtools/documentation/i18n.py +185 -0
  65. resource_engine_devtools/documentation/introspector.py +563 -0
  66. resource_engine_devtools/documentation/locale/ca/LC_MESSAGES/docs.po +628 -0
  67. resource_engine_devtools/documentation/locale/es/LC_MESSAGES/docs.po +627 -0
  68. resource_engine_devtools/documentation/model.py +311 -0
  69. resource_engine_devtools/documentation/validator.py +128 -0
  70. resource_engine_devtools/emails.py +172 -0
  71. resource_engine_devtools/events_check.py +124 -0
  72. resource_engine_devtools/gates_check.py +133 -0
  73. resource_engine_devtools/hooks_check.py +287 -0
  74. resource_engine_devtools/i18n.py +312 -0
  75. resource_engine_devtools/loader.py +93 -0
  76. resource_engine_devtools/logic_check.py +136 -0
  77. resource_engine_devtools/mcp_server.py +685 -0
  78. resource_engine_devtools/py.typed +0 -0
  79. resource_engine_devtools/scaffold.py +805 -0
  80. resource_engine_devtools/scaffold_parts.py +637 -0
  81. resource_engine_devtools/source_edit.py +424 -0
  82. resource_engine_devtools/templates_check.py +59 -0
  83. resource_engine_devtools/worker.py +68 -0
  84. resource_engine_devtools-0.1.0.dist-info/METADATA +38 -0
  85. resource_engine_devtools-0.1.0.dist-info/RECORD +88 -0
  86. resource_engine_devtools-0.1.0.dist-info/WHEEL +4 -0
  87. resource_engine_devtools-0.1.0.dist-info/entry_points.txt +2 -0
  88. resource_engine_devtools-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,121 @@
1
+ """SQLAlchemy mapping of the invoices domain. Only infrastructure imports SQLAlchemy."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from resource_engine_sqlalchemy import NAMING_CONVENTION, engine_tables, map_engine, map_views
6
+ from sqlalchemy import (
7
+ Column,
8
+ Date,
9
+ DateTime,
10
+ ForeignKey,
11
+ Integer,
12
+ MetaData,
13
+ Numeric,
14
+ String,
15
+ Table,
16
+ Text,
17
+ UniqueConstraint,
18
+ )
19
+ from sqlalchemy.orm import registry as orm_registry
20
+
21
+ from invoices.domain.entities import Customer, Invoice, InvoicePayment, InvoiceTag, Tag
22
+
23
+ # One MetaData for the module's tables and the engine's: Alembic autogenerate
24
+ # sees both (examples/invoices/migrations). The convention names constraints.
25
+ metadata = MetaData(naming_convention=NAMING_CONVENTION)
26
+ mapper_registry = orm_registry(metadata=metadata)
27
+
28
+ customers_table = Table(
29
+ "customers",
30
+ metadata,
31
+ Column("id", Integer, primary_key=True, autoincrement=True),
32
+ Column("name", String(200), nullable=False),
33
+ Column("tax_id", String(20), nullable=False),
34
+ Column("country", String(2), nullable=False),
35
+ Column("email", String(320), nullable=True),
36
+ Column("organization", String(100), nullable=True, index=True),
37
+ UniqueConstraint("organization", "tax_id"),
38
+ )
39
+
40
+ invoices_table = Table(
41
+ "invoices",
42
+ metadata,
43
+ Column("id", Integer, primary_key=True, autoincrement=True),
44
+ Column("customer", String(200), nullable=False),
45
+ Column("amount", Numeric(12, 2, asdecimal=True), nullable=False),
46
+ Column("issue_date", Date, nullable=True),
47
+ # the engine checks the reference (RE-E108, RE-E109); the key backs it up
48
+ Column("customer_id", Integer, ForeignKey("customers.id"), nullable=True, index=True),
49
+ Column("notes", Text, nullable=True),
50
+ Column("status", String(32), nullable=False),
51
+ Column("rejection_reason", Text, nullable=True),
52
+ Column("version", Integer, nullable=False, default=1),
53
+ Column("status_changed_at", DateTime(timezone=True), nullable=True, index=True),
54
+ Column("delivery_status", String(32), nullable=False, server_default="unsent"),
55
+ # tenant (organization) when the app runs tenant-scoped; every query filters by it
56
+ Column("organization", String(100), nullable=True, index=True),
57
+ )
58
+
59
+ tags_table = Table(
60
+ "tags",
61
+ metadata,
62
+ Column("id", Integer, primary_key=True, autoincrement=True),
63
+ Column("name", String(50), nullable=False),
64
+ Column("color", String(20), nullable=False),
65
+ Column("organization", String(100), nullable=True, index=True),
66
+ UniqueConstraint("organization", "name"),
67
+ )
68
+
69
+ invoice_tags_table = Table(
70
+ "invoice_tags",
71
+ metadata,
72
+ Column("id", Integer, primary_key=True, autoincrement=True),
73
+ Column("invoice_id", Integer, ForeignKey("invoices.id"), nullable=False, index=True),
74
+ Column("tag_id", Integer, ForeignKey("tags.id"), nullable=False, index=True),
75
+ Column("organization", String(100), nullable=True, index=True),
76
+ UniqueConstraint("invoice_id", "tag_id"),
77
+ )
78
+
79
+ invoice_payments_table = Table(
80
+ "invoice_payments",
81
+ metadata,
82
+ Column("id", Integer, primary_key=True, autoincrement=True),
83
+ # one process instance per invoice (the correlation key)
84
+ Column("invoice_id", Integer, ForeignKey("invoices.id"), nullable=False, unique=True),
85
+ Column("amount", Numeric(12, 2, asdecimal=True), nullable=False),
86
+ Column("status", String(32), nullable=False),
87
+ Column("status_changed_at", DateTime(timezone=True), nullable=True, index=True),
88
+ Column("organization", String(100), nullable=True, index=True),
89
+ )
90
+
91
+ engine = engine_tables(
92
+ metadata,
93
+ documents=True,
94
+ authz=True,
95
+ api_keys=True,
96
+ audit=True,
97
+ idempotency=True,
98
+ outbox=True, # events stored with each change, then fed to processes and brokers
99
+ inbox=True, # messages already handled (exactly-once processes)
100
+ locks=True, # one worker at a time for single jobs
101
+ activity=True, # what the worker did, for the explorer (jobs, runs, deliveries)
102
+ )
103
+
104
+ _mapped = False
105
+
106
+
107
+ def map_entities() -> None:
108
+ """Idempotently map domain entities to tables."""
109
+ global _mapped
110
+ if not _mapped:
111
+ mapper_registry.map_imperatively(Customer, customers_table)
112
+ mapper_registry.map_imperatively(Invoice, invoices_table)
113
+ mapper_registry.map_imperatively(Tag, tags_table)
114
+ mapper_registry.map_imperatively(InvoiceTag, invoice_tags_table)
115
+ mapper_registry.map_imperatively(InvoicePayment, invoice_payments_table)
116
+ # views (customer_balances): mapped onto their GROUP BY query, no table
117
+ from invoices.bootstrap import registry
118
+
119
+ map_views(mapper_registry, registry)
120
+ map_engine(mapper_registry, engine)
121
+ _mapped = True