type-bridge 2.0.2__tar.gz → 2.1.0__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 (146) hide show
  1. {type_bridge-2.0.2 → type_bridge-2.1.0}/.gitignore +1 -0
  2. {type_bridge-2.0.2 → type_bridge-2.1.0}/PKG-INFO +84 -85
  3. type_bridge-2.1.0/README.md +156 -0
  4. {type_bridge-2.0.2 → type_bridge-2.1.0}/pyproject.toml +8 -6
  5. type_bridge-2.1.0/type_bridge/__init__.py +90 -0
  6. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/_backend.py +2 -2
  7. type_bridge-2.1.0/type_bridge/_runtime_projection.py +92 -0
  8. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/_rust_runtime.py +22 -64
  9. type_bridge-2.1.0/type_bridge/attribute/__init__.py +18 -0
  10. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/base.py +20 -12
  11. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/boolean.py +6 -2
  12. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/date.py +15 -11
  13. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/datetime.py +15 -11
  14. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/datetimetz.py +15 -11
  15. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/decimal.py +4 -0
  16. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/double.py +4 -0
  17. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/duration.py +13 -9
  18. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/flags.py +39 -12
  19. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/integer.py +4 -0
  20. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/numeric.py +2 -2
  21. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/attribute/string.py +20 -16
  22. type_bridge-2.1.0/type_bridge/crud/__init__.py +76 -0
  23. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/has_lookup.py +5 -5
  24. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/hooks.py +1 -1
  25. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/lookup.py +1 -1
  26. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/patterns.py +2 -1
  27. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/role_lookup.py +2 -2
  28. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/role_players.py +4 -3
  29. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/rust_manager.py +10 -5
  30. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/strategies.py +13 -3
  31. type_bridge-2.1.0/type_bridge/crud/typedb_manager.py +12 -0
  32. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/types.py +3 -3
  33. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/aggregate.py +1 -1
  34. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/arithmetic.py +1 -1
  35. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/base.py +1 -1
  36. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/boolean.py +1 -1
  37. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/builtin.py +1 -1
  38. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/comparison.py +1 -1
  39. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/iid.py +1 -1
  40. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/role_player.py +2 -2
  41. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/string.py +1 -1
  42. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/utils.py +1 -1
  43. type_bridge-2.1.0/type_bridge/fields/__init__.py +18 -0
  44. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/fields/base.py +38 -21
  45. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/fields/role.py +29 -15
  46. type_bridge-2.1.0/type_bridge/migration/__init__.py +160 -0
  47. type_bridge-2.1.0/type_bridge/migration/__main__.py +16 -0
  48. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/_adoption_authority.py +1 -1
  49. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/_adoption_import.py +1 -1
  50. type_bridge-2.1.0/type_bridge/migration/_archive_base.py +50 -0
  51. type_bridge-2.1.0/type_bridge/migration/_archive_imports.py +156 -0
  52. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/_lower.py +5 -5
  53. type_bridge-2.0.2/type_bridge/migration/operations.py → type_bridge-2.1.0/type_bridge/migration/_operations.py +6 -5
  54. type_bridge-2.0.2/type_bridge/migration/ref.py → type_bridge-2.1.0/type_bridge/migration/_ref.py +1 -1
  55. type_bridge-2.1.0/type_bridge/migration/exceptions.py +34 -0
  56. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/introspection.py +5 -3
  57. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/loader.py +11 -4
  58. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/sidecar.py +2 -2
  59. type_bridge-2.1.0/type_bridge/migration/snapshots.py +36 -0
  60. type_bridge-2.1.0/type_bridge/migration/state.py +124 -0
  61. type_bridge-2.1.0/type_bridge/models/__init__.py +19 -0
  62. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/base.py +34 -19
  63. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/entity.py +24 -12
  64. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/registry.py +5 -1
  65. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/relation.py +22 -13
  66. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/role.py +15 -6
  67. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/schema_scanner.py +11 -5
  68. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/models/utils.py +21 -12
  69. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/proxy.py +0 -9
  70. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/query/__init__.py +26 -15
  71. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/query/ast.py +2 -2
  72. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/session.py +7 -65
  73. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/__init__.py +3 -3
  74. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/_descriptors.py +16 -10
  75. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/_remote_terminal.py +1 -1
  76. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/_terminal.py +3 -1
  77. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/query.py +4 -2
  78. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/references.py +22 -12
  79. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/remote_query.py +1 -1
  80. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/remote_session.py +3 -3
  81. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/results.py +3 -3
  82. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/session.py +6 -5
  83. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typedb_driver.py +34 -32
  84. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/validation.py +6 -3
  85. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/version.py +3 -3
  86. type_bridge-2.0.2/README.md +0 -157
  87. type_bridge-2.0.2/type_bridge/__init__.py +0 -141
  88. type_bridge-2.0.2/type_bridge/_runtime_projection.py +0 -33
  89. type_bridge-2.0.2/type_bridge/attribute/__init__.py +0 -58
  90. type_bridge-2.0.2/type_bridge/crud/__init__.py +0 -41
  91. type_bridge-2.0.2/type_bridge/crud/typedb_manager.py +0 -19
  92. type_bridge-2.0.2/type_bridge/fields/__init__.py +0 -29
  93. type_bridge-2.0.2/type_bridge/generator/__init__.py +0 -231
  94. type_bridge-2.0.2/type_bridge/generator/__main__.py +0 -176
  95. type_bridge-2.0.2/type_bridge/generator/annotations.py +0 -235
  96. type_bridge-2.0.2/type_bridge/generator/api_dto.py +0 -577
  97. type_bridge-2.0.2/type_bridge/generator/dto_config.py +0 -382
  98. type_bridge-2.0.2/type_bridge/generator/models.py +0 -447
  99. type_bridge-2.0.2/type_bridge/generator/naming.py +0 -73
  100. type_bridge-2.0.2/type_bridge/generator/parser.py +0 -306
  101. type_bridge-2.0.2/type_bridge/generator/template_loader.py +0 -88
  102. type_bridge-2.0.2/type_bridge/generator/templates/_dto_macros.jinja +0 -269
  103. type_bridge-2.0.2/type_bridge/generator/templates/api_dto.py.jinja +0 -163
  104. type_bridge-2.0.2/type_bridge/generator/typeql.pest +0 -654
  105. type_bridge-2.0.2/type_bridge/generator/utils/__init__.py +0 -11
  106. type_bridge-2.0.2/type_bridge/generator/utils/common.py +0 -92
  107. type_bridge-2.0.2/type_bridge/generator/utils/types.py +0 -31
  108. type_bridge-2.0.2/type_bridge/migration/__init__.py +0 -221
  109. type_bridge-2.0.2/type_bridge/migration/__main__.py +0 -48
  110. type_bridge-2.0.2/type_bridge/migration/_generate.py +0 -220
  111. type_bridge-2.0.2/type_bridge/migration/_ir_dump.py +0 -127
  112. type_bridge-2.0.2/type_bridge/migration/author.py +0 -140
  113. type_bridge-2.0.2/type_bridge/migration/base.py +0 -98
  114. type_bridge-2.0.2/type_bridge/migration/breaking.py +0 -149
  115. type_bridge-2.0.2/type_bridge/migration/diff.py +0 -564
  116. type_bridge-2.0.2/type_bridge/migration/exceptions.py +0 -141
  117. type_bridge-2.0.2/type_bridge/migration/executor.py +0 -916
  118. type_bridge-2.0.2/type_bridge/migration/generator.py +0 -164
  119. type_bridge-2.0.2/type_bridge/migration/info.py +0 -251
  120. type_bridge-2.0.2/type_bridge/migration/registry.py +0 -223
  121. type_bridge-2.0.2/type_bridge/migration/schema_manager.py +0 -424
  122. type_bridge-2.0.2/type_bridge/migration/simple_migration.py +0 -129
  123. type_bridge-2.0.2/type_bridge/migration/snapshots.py +0 -313
  124. type_bridge-2.0.2/type_bridge/migration/state.py +0 -411
  125. type_bridge-2.0.2/type_bridge/models/__init__.py +0 -23
  126. {type_bridge-2.0.2 → type_bridge-2.1.0}/LICENSE +0 -0
  127. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/_rust.py +0 -0
  128. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/coercion.py +0 -0
  129. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/aggregates.py +0 -0
  130. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/exceptions.py +0 -0
  131. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/formatting.py +0 -0
  132. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/crud/utils.py +0 -0
  133. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/__init__.py +0 -0
  134. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/expressions/functions.py +0 -0
  135. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/state_schema.py +0 -0
  136. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/migration/utils.py +0 -0
  137. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/py.typed +0 -0
  138. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/query/compiler.py +0 -0
  139. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/query/parser.py +0 -0
  140. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/query_v2.py +0 -0
  141. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/reserved_words.py +0 -0
  142. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/rules.py +0 -0
  143. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/page.py +0 -0
  144. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typed/remote_limits.py +0 -0
  145. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typeql/__init__.py +0 -0
  146. {type_bridge-2.0.2 → type_bridge-2.1.0}/type_bridge/typeql/annotations.py +0 -0
@@ -52,3 +52,4 @@ type-bridge-core/**/target/
52
52
 
53
53
  # Plan 12 generator cross-language parity build output (ephemeral)
54
54
  type-bridge-core/crates/node/tests/parity/generated/
55
+ examples/generated/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: type-bridge
3
- Version: 2.0.2
3
+ Version: 2.1.0
4
4
  Summary: Typed Python, TypeScript, and Rust application tooling for TypeDB
5
5
  Project-URL: Homepage, https://github.com/ds1sqe/type-bridge
6
6
  Project-URL: Repository, https://github.com/ds1sqe/type-bridge
@@ -23,7 +23,7 @@ Requires-Python: <3.15,>=3.12
23
23
  Requires-Dist: isodate==0.7.2
24
24
  Requires-Dist: jinja2>=3.1.0
25
25
  Requires-Dist: pydantic>=2.12.4
26
- Requires-Dist: type-bridge-core==2.0.2
26
+ Requires-Dist: type-bridge-core==2.1.0
27
27
  Requires-Dist: typer>=0.15.0
28
28
  Requires-Dist: typing-extensions>=4.12
29
29
  Provides-Extra: dev
@@ -45,7 +45,7 @@ Requires-Dist: mkdocs-section-index>=0.3; extra == 'docs'
45
45
  Requires-Dist: mkdocs>=1.6; extra == 'docs'
46
46
  Requires-Dist: mkdocstrings[python]>=0.27; extra == 'docs'
47
47
  Provides-Extra: typedb-driver
48
- Requires-Dist: typedb-driver<3.13,>=3.8; (python_version < '3.14') and extra == 'typedb-driver'
48
+ Requires-Dist: typedb-driver<3.13,>=3.11; (python_version < '3.14') and extra == 'typedb-driver'
49
49
  Requires-Dist: typedb-driver==3.12.1; (python_version >= '3.14') and extra == 'typedb-driver'
50
50
  Description-Content-Type: text/markdown
51
51
 
@@ -63,73 +63,79 @@ Description-Content-Type: text/markdown
63
63
  </p>
64
64
 
65
65
  TypeBridge is a typed application toolkit for [TypeDB](https://typedb.com/).
66
- It defines and evolves schemas, generates application models, and provides
67
- native Python, TypeScript/Node, and Rust data APIs. One Rust semantic engine
68
- owns schema, query, migration, validation, and ORM behavior across every SDK
69
- and the standalone query server.
66
+ A versioned Split-YAML workspace is the schema authority. TypeBridge validates
67
+ that workspace and generates Python, TypeScript/Node, and Rust bindings that
68
+ share one Rust-owned schema, query, migration, validation, and ORM engine.
70
69
 
71
- ## One system, several ways in
70
+ ## One system, three generated SDKs
72
71
 
73
- 2.0.2 is a compatibility-notice and dependency-security maintenance release. Read the
74
- [exact expanded 2.1 inventory and safe pins](https://github.com/ds1sqe/type-bridge/releases/tag/v2.0.2)
75
- before upgrading beyond 2.0.x. No API is removed or new warning added here.
76
-
77
- | Surface | Use it for | Distribution |
72
+ | Surface | Generated application API | Distribution |
78
73
  | --- | --- | --- |
79
- | Python | Declarative Pydantic models, CRUD, queries, schema management | [`type-bridge`](https://pypi.org/project/type-bridge/) |
80
- | TypeScript / Node | Branded models, typed managers, queries, native runtime | [`@type-bridge/node`](https://www.npmjs.com/package/@type-bridge/node) |
81
- | Rust | Generated schema crates, async CRUD and immutable queries | [`type-bridge`](https://crates.io/crates/type-bridge) |
82
- | CLI and generators | Split-YAML schemas, migrations, Python/Node/Rust projections | Included with the Python package |
83
- | Server | Remote V2 query execution over the same contracts | `ghcr.io/ds1sqe/type-bridge-server` |
84
-
85
- TypeBridge is designed around TypeDB rather than flattened into a relational
86
- ORM shape:
74
+ | Python | Value classes, model managers, transactions, direct/remote queries | [`type-bridge`](https://pypi.org/project/type-bridge/) |
75
+ | TypeScript / Node | Branded values, model managers, native and remote queries | [`@type-bridge/node`](https://www.npmjs.com/package/@type-bridge/node) |
76
+ | Rust | Schema-bound create/model types, async CRUD and immutable queries | [`type-bridge`](https://crates.io/crates/type-bridge) |
77
+ | CLI | Split-YAML checks, migrations, and all three projections | Included with the Python package |
78
+ | Server | Remote V2 query execution over the same generated contract | `ghcr.io/ds1sqe/type-bridge-server` |
87
79
 
88
- - attributes remain independent types owned by entities and relations;
89
- - roles, inheritance, cardinality, ordering, `@key`, and `@unique` stay typed;
90
- - schema generation and migration use the same rules as runtime queries;
91
- - direct and remote immutable queries preserve typed, owner-aware results;
92
- - Python and Node are thin facades over the shared Rust runtime.
80
+ TypeBridge preserves TypeDB concepts directly: independent attributes,
81
+ entities, relations, roles, inheritance, cardinality, ordering, keys, and
82
+ uniqueness remain typed from schema through hydrated results.
93
83
 
94
- ## Start with Python
84
+ ## Start from Split-YAML
95
85
 
96
- Requires Python 3.12–3.14 and a supported TypeDB 3.x server.
86
+ Install the CLI and Python runtime:
97
87
 
98
88
  ```bash
99
89
  pip install type-bridge
100
90
  ```
101
91
 
102
- ```python
103
- from type_bridge import Database, Entity, Flag, Integer, Key, SchemaManager, String
92
+ Create `typebridge.yaml`, a schema-set manifest, and one or more schema
93
+ fragments. Configure the generated package output in the workspace, then run:
104
94
 
105
- class PersonId(String):
106
- pass
95
+ ```bash
96
+ type-bridge --manifest typebridge.yaml schema check
97
+ type-bridge --manifest typebridge.yaml schema generate
98
+ type-bridge --manifest typebridge.yaml migration make --name initial
99
+ type-bridge --manifest typebridge.yaml migration apply --environment development
100
+ ```
101
+
102
+ One generation snapshot writes every configured Python, TypeScript, and Rust
103
+ package. Generated packages privately embed the verified authority used by
104
+ their managers and direct or remote queries, so ordinary applications never
105
+ configure or read an external authority JSON. A workspace deploying the optional
106
+ generic server can additionally configure `artifacts.schema-authority.output`;
107
+ the server mounts that generated, source-free artifact instead of compiling
108
+ YAML or accepting a user-maintained JSON schema.
107
109
 
108
- class Age(Integer):
109
- pass
110
+ The generated Python package owns the concise single-type manager:
110
111
 
111
- class Person(Entity):
112
- person_id: PersonId = Flag(Key)
113
- age: Age | None = None
112
+ ```python
113
+ from app_models import Age, Person, PersonId
114
+ from type_bridge import Database
114
115
 
115
116
  db = Database(address="localhost:1729", database="example")
116
117
  db.connect()
117
- db.create_database()
118
-
119
- schema = SchemaManager(db)
120
- schema.register(Person)
121
- schema.sync_schema()
122
118
 
123
119
  ada = Person(person_id=PersonId("ada"), age=Age(36))
124
120
  Person.manager(db).put(ada)
125
121
  people = Person.manager(db).filter(age__gte=18).all()
126
122
  ```
127
123
 
124
+ Use its package-local query session when a query spans types:
125
+
126
+ ```python
127
+ session = Person.query(db)
128
+ person = session.exact(Person)
129
+ adults = (
130
+ session.query(person)
131
+ .where(person.field(Person.age).gte(Age(18)))
132
+ .rows(limit=100)
133
+ )
134
+ ```
135
+
128
136
  Continue with the [Python quick start](https://ds1sqe.github.io/type-bridge/getting-started/quickstart/),
129
- then choose the [model](https://ds1sqe.github.io/type-bridge/guide/models/),
130
- [data](https://ds1sqe.github.io/type-bridge/guide/data/), or
131
- [schema](https://ds1sqe.github.io/type-bridge/guide/schema-workflows/)
132
- workflow.
137
+ [Split-YAML reference](https://ds1sqe.github.io/type-bridge/guide/split-yaml-v1/),
138
+ and [data guide](https://ds1sqe.github.io/type-bridge/guide/data/).
133
139
 
134
140
  ## TypeScript / Node
135
141
 
@@ -137,55 +143,50 @@ workflow.
137
143
  npm install @type-bridge/node
138
144
  ```
139
145
 
140
- ```ts
141
- import { Entity, Key, attr, field } from "@type-bridge/node";
142
-
143
- class PersonId extends attr.String("person-id") {}
144
- class Person extends Entity("person", {
145
- personId: field(PersonId, Key),
146
- }) {}
146
+ Import application values from the generated package and connection primitives
147
+ from `@type-bridge/node`:
147
148
 
148
- const ada = new Person({ personId: new PersonId("ada") });
149
+ ```ts
150
+ import { RustDatabase } from "@type-bridge/node";
151
+ import { Age, Person, PersonId } from "./generated/models/index.js";
152
+
153
+ const db = RustDatabase.connect("localhost:1729", "example", {
154
+ username: "admin",
155
+ password: "password",
156
+ });
157
+ const ada = Person.create({
158
+ personId: PersonId.create("ada"),
159
+ age: Age.create(36n),
160
+ });
161
+ Person.manager(db).put(ada);
162
+ const people = Person.manager(db).filter({ age__gte: Age.create(18n) }).all();
149
163
  ```
150
164
 
151
165
  See the [TypeScript/Node guide](https://ds1sqe.github.io/type-bridge/guide/typescript/)
152
- for native targets, database lifecycle, managers, queries, and generation.
166
+ for generated managers, transactions, and direct/remote queries.
153
167
 
154
- ## Schema-first and Rust workflows
168
+ ## Rust
155
169
 
156
- The V2 workspace makes a versioned Split-YAML schema the authority and projects
157
- it into each configured SDK:
170
+ The same workspace emits a schema-bound Rust crate. The generated SDK uses
171
+ Rust 1.88+ and the crates.io `type-bridge` runtime:
158
172
 
159
- ```bash
160
- type-bridge --manifest typebridge.yaml schema check
161
- type-bridge --manifest typebridge.yaml schema generate
162
- type-bridge --manifest typebridge.yaml migration make --name initial
163
- type-bridge --manifest typebridge.yaml migration apply --environment development
173
+ ```toml
174
+ [dependencies]
175
+ type-bridge = "2"
164
176
  ```
165
177
 
166
- The generated Rust SDK requires Rust 1.88+ and, starting with 2.0.1, resolves
167
- from crates.io with `type-bridge = "2"`. TypeBridge 2.0.0 remains available
168
- from its exact Git revision. Follow the
169
- [Rust client guide](https://ds1sqe.github.io/type-bridge/guide/rust/) and
170
- [Split-YAML reference](https://ds1sqe.github.io/type-bridge/guide/split-yaml-v1/)
171
- for the reproducible setup.
178
+ Follow the [Rust client guide](https://ds1sqe.github.io/type-bridge/guide/rust/)
179
+ for generation, direct execution, transactions, and remote queries.
172
180
 
173
181
  ## Documentation
174
182
 
175
183
  - [Install a surface](https://ds1sqe.github.io/type-bridge/getting-started/installation/)
176
- - [Choose an SDK](https://ds1sqe.github.io/type-bridge/guide/sdks/)
177
- - [Model TypeDB data](https://ds1sqe.github.io/type-bridge/guide/models/)
178
- - [Read and write data](https://ds1sqe.github.io/type-bridge/guide/data/)
184
+ - [Model data in Split-YAML](https://ds1sqe.github.io/type-bridge/guide/models/)
185
+ - [Read and write generated models](https://ds1sqe.github.io/type-bridge/guide/data/)
179
186
  - [Manage schemas and migrations](https://ds1sqe.github.io/type-bridge/guide/schema-workflows/)
180
- - [Run the server](https://ds1sqe.github.io/type-bridge/guide/server-container/)
181
- - [Upgrade to 2.0](https://ds1sqe.github.io/type-bridge/guide/upgrade-v2/)
182
- - [Python API reference](https://ds1sqe.github.io/type-bridge/reference/)
183
-
184
- TypeBridge 2.0.x supports TypeDB 3.8–3.12. Support for 3.8 and 3.10 is
185
- deprecated and scheduled for removal in 2.1; consult the
186
- [compatibility matrix](https://ds1sqe.github.io/type-bridge/development/typedb/#server-and-driver-compatibility)
187
- and [deprecation inventory](https://ds1sqe.github.io/type-bridge/guide/v2-deprecations/)
188
- before upgrading production deployments.
187
+ - [Run the query server](https://ds1sqe.github.io/type-bridge/guide/server-container/)
188
+ - [Browse the Cargo package index](https://ds1sqe.github.io/type-bridge/guide/cargo-packages/)
189
+ - [Compatibility and removals](https://ds1sqe.github.io/type-bridge/guide/v2-deprecations/)
189
190
 
190
191
  ## Development
191
192
 
@@ -197,12 +198,10 @@ uv run pytest
197
198
  uv run --extra docs mkdocs build --strict
198
199
  ```
199
200
 
200
- See [DEVELOPMENT.md](DEVELOPMENT.md) for repository layout, test tiers, docs
201
- architecture, and contribution checks.
201
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for repository boundaries and verification.
202
202
 
203
203
  ## License
204
204
 
205
205
  TypeBridge-authored code is MIT licensed. Native artifacts also include
206
206
  third-party TypeDB components under Apache-2.0 and MPL-2.0; exact notices ship
207
- with each artifact and are documented in
208
- [`type-bridge-core/vendor/README.md`](type-bridge-core/vendor/README.md).
207
+ with each artifact.
@@ -0,0 +1,156 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/ds1sqe/type-bridge/master/docs/assets/typebridge-hero.svg" alt="TypeBridge connects typed Python, TypeScript, and Rust applications to TypeDB through one semantic engine." width="100%">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://github.com/ds1sqe/type-bridge/actions/workflows/ci.yml"><img src="https://github.com/ds1sqe/type-bridge/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
7
+ <a href="https://pypi.org/project/type-bridge/"><img src="https://img.shields.io/pypi/v/type-bridge.svg" alt="PyPI"></a>
8
+ <a href="https://www.npmjs.com/package/@type-bridge/node"><img src="https://img.shields.io/npm/v/%40type-bridge%2Fnode.svg" alt="npm"></a>
9
+ <a href="https://crates.io/crates/type-bridge"><img src="https://img.shields.io/crates/v/type-bridge.svg" alt="crates.io"></a>
10
+ <a href="https://ds1sqe.github.io/type-bridge/"><img src="https://img.shields.io/badge/docs-TypeBridge-67e8f9" alt="Documentation"></a>
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-8b5cf6.svg" alt="MIT license"></a>
12
+ </p>
13
+
14
+ TypeBridge is a typed application toolkit for [TypeDB](https://typedb.com/).
15
+ A versioned Split-YAML workspace is the schema authority. TypeBridge validates
16
+ that workspace and generates Python, TypeScript/Node, and Rust bindings that
17
+ share one Rust-owned schema, query, migration, validation, and ORM engine.
18
+
19
+ ## One system, three generated SDKs
20
+
21
+ | Surface | Generated application API | Distribution |
22
+ | --- | --- | --- |
23
+ | Python | Value classes, model managers, transactions, direct/remote queries | [`type-bridge`](https://pypi.org/project/type-bridge/) |
24
+ | TypeScript / Node | Branded values, model managers, native and remote queries | [`@type-bridge/node`](https://www.npmjs.com/package/@type-bridge/node) |
25
+ | Rust | Schema-bound create/model types, async CRUD and immutable queries | [`type-bridge`](https://crates.io/crates/type-bridge) |
26
+ | CLI | Split-YAML checks, migrations, and all three projections | Included with the Python package |
27
+ | Server | Remote V2 query execution over the same generated contract | `ghcr.io/ds1sqe/type-bridge-server` |
28
+
29
+ TypeBridge preserves TypeDB concepts directly: independent attributes,
30
+ entities, relations, roles, inheritance, cardinality, ordering, keys, and
31
+ uniqueness remain typed from schema through hydrated results.
32
+
33
+ ## Start from Split-YAML
34
+
35
+ Install the CLI and Python runtime:
36
+
37
+ ```bash
38
+ pip install type-bridge
39
+ ```
40
+
41
+ Create `typebridge.yaml`, a schema-set manifest, and one or more schema
42
+ fragments. Configure the generated package output in the workspace, then run:
43
+
44
+ ```bash
45
+ type-bridge --manifest typebridge.yaml schema check
46
+ type-bridge --manifest typebridge.yaml schema generate
47
+ type-bridge --manifest typebridge.yaml migration make --name initial
48
+ type-bridge --manifest typebridge.yaml migration apply --environment development
49
+ ```
50
+
51
+ One generation snapshot writes every configured Python, TypeScript, and Rust
52
+ package. Generated packages privately embed the verified authority used by
53
+ their managers and direct or remote queries, so ordinary applications never
54
+ configure or read an external authority JSON. A workspace deploying the optional
55
+ generic server can additionally configure `artifacts.schema-authority.output`;
56
+ the server mounts that generated, source-free artifact instead of compiling
57
+ YAML or accepting a user-maintained JSON schema.
58
+
59
+ The generated Python package owns the concise single-type manager:
60
+
61
+ ```python
62
+ from app_models import Age, Person, PersonId
63
+ from type_bridge import Database
64
+
65
+ db = Database(address="localhost:1729", database="example")
66
+ db.connect()
67
+
68
+ ada = Person(person_id=PersonId("ada"), age=Age(36))
69
+ Person.manager(db).put(ada)
70
+ people = Person.manager(db).filter(age__gte=18).all()
71
+ ```
72
+
73
+ Use its package-local query session when a query spans types:
74
+
75
+ ```python
76
+ session = Person.query(db)
77
+ person = session.exact(Person)
78
+ adults = (
79
+ session.query(person)
80
+ .where(person.field(Person.age).gte(Age(18)))
81
+ .rows(limit=100)
82
+ )
83
+ ```
84
+
85
+ Continue with the [Python quick start](https://ds1sqe.github.io/type-bridge/getting-started/quickstart/),
86
+ [Split-YAML reference](https://ds1sqe.github.io/type-bridge/guide/split-yaml-v1/),
87
+ and [data guide](https://ds1sqe.github.io/type-bridge/guide/data/).
88
+
89
+ ## TypeScript / Node
90
+
91
+ ```bash
92
+ npm install @type-bridge/node
93
+ ```
94
+
95
+ Import application values from the generated package and connection primitives
96
+ from `@type-bridge/node`:
97
+
98
+ ```ts
99
+ import { RustDatabase } from "@type-bridge/node";
100
+ import { Age, Person, PersonId } from "./generated/models/index.js";
101
+
102
+ const db = RustDatabase.connect("localhost:1729", "example", {
103
+ username: "admin",
104
+ password: "password",
105
+ });
106
+ const ada = Person.create({
107
+ personId: PersonId.create("ada"),
108
+ age: Age.create(36n),
109
+ });
110
+ Person.manager(db).put(ada);
111
+ const people = Person.manager(db).filter({ age__gte: Age.create(18n) }).all();
112
+ ```
113
+
114
+ See the [TypeScript/Node guide](https://ds1sqe.github.io/type-bridge/guide/typescript/)
115
+ for generated managers, transactions, and direct/remote queries.
116
+
117
+ ## Rust
118
+
119
+ The same workspace emits a schema-bound Rust crate. The generated SDK uses
120
+ Rust 1.88+ and the crates.io `type-bridge` runtime:
121
+
122
+ ```toml
123
+ [dependencies]
124
+ type-bridge = "2"
125
+ ```
126
+
127
+ Follow the [Rust client guide](https://ds1sqe.github.io/type-bridge/guide/rust/)
128
+ for generation, direct execution, transactions, and remote queries.
129
+
130
+ ## Documentation
131
+
132
+ - [Install a surface](https://ds1sqe.github.io/type-bridge/getting-started/installation/)
133
+ - [Model data in Split-YAML](https://ds1sqe.github.io/type-bridge/guide/models/)
134
+ - [Read and write generated models](https://ds1sqe.github.io/type-bridge/guide/data/)
135
+ - [Manage schemas and migrations](https://ds1sqe.github.io/type-bridge/guide/schema-workflows/)
136
+ - [Run the query server](https://ds1sqe.github.io/type-bridge/guide/server-container/)
137
+ - [Browse the Cargo package index](https://ds1sqe.github.io/type-bridge/guide/cargo-packages/)
138
+ - [Compatibility and removals](https://ds1sqe.github.io/type-bridge/guide/v2-deprecations/)
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 uv sync --extra dev
144
+ uv run pytest
145
+ ./test.sh
146
+ ./scripts/check.sh all
147
+ uv run --extra docs mkdocs build --strict
148
+ ```
149
+
150
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for repository boundaries and verification.
151
+
152
+ ## License
153
+
154
+ TypeBridge-authored code is MIT licensed. Native artifacts also include
155
+ third-party TypeDB components under Apache-2.0 and MPL-2.0; exact notices ship
156
+ with each artifact.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "type-bridge"
7
- version = "2.0.2"
7
+ version = "2.1.0"
8
8
  description = "Typed Python, TypeScript, and Rust application tooling for TypeDB"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12,<3.15"
@@ -30,7 +30,7 @@ dependencies = [
30
30
  "jinja2>=3.1.0",
31
31
  "typer>=0.15.0",
32
32
  # The facade and native semantic engine are one release unit.
33
- "type-bridge-core==2.0.2",
33
+ "type-bridge-core==2.1.0",
34
34
  "typing-extensions>=4.12",
35
35
  ]
36
36
 
@@ -55,8 +55,8 @@ dev = [
55
55
  # server. The first native driver line supporting CPython 3.14 is band 9,
56
56
  # so that interpreter has a dedicated native-constructor smoke; direct
57
57
  # connections from that lane require a 3.12 server. The ORM itself uses
58
- # the embedded Rust runtime and continues to serve TypeDB 3.8 through 3.12
59
- # on every supported interpreter.
58
+ # the embedded Rust runtime and serves TypeDB 3.11 and 3.12 on every
59
+ # supported interpreter.
60
60
  "typedb-driver~=3.11.5; python_version < '3.14'",
61
61
  "typedb-driver==3.12.1; python_version >= '3.14'",
62
62
  "pytest>=9.0.1",
@@ -80,7 +80,7 @@ docs = [
80
80
  "mkdocs-section-index>=0.3",
81
81
  ]
82
82
  typedb-driver = [
83
- "typedb-driver>=3.8,<3.13; python_version < '3.14'",
83
+ "typedb-driver>=3.11,<3.13; python_version < '3.14'",
84
84
  "typedb-driver==3.12.1; python_version >= '3.14'",
85
85
  ]
86
86
 
@@ -115,6 +115,9 @@ mypy_path = ["typings"]
115
115
  line-length = 100
116
116
  target-version = "py312"
117
117
 
118
+ [tool.ruff.format]
119
+ exclude = ["type-bridge-core/crates/schema-codegen/src/python/query.pyi"]
120
+
118
121
  [tool.ruff.lint]
119
122
  select = ["E", "F", "I", "N", "W", "UP"]
120
123
  ignore = [
@@ -144,7 +147,6 @@ branch = true
144
147
  omit = [
145
148
  "type_bridge/__main__.py",
146
149
  "type_bridge/migration/__main__.py",
147
- "type_bridge/generator/__main__.py",
148
150
  ]
149
151
 
150
152
  [tool.coverage.report]
@@ -0,0 +1,90 @@
1
+ """Python SDK for generated TypeBridge applications and retained query APIs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from type_bridge.proxy import ProxyDatabase, ProxyError
8
+ from type_bridge.query import Query, QueryBuilder
9
+ from type_bridge.session import (
10
+ Connection,
11
+ Database,
12
+ TransactionContext,
13
+ )
14
+ from type_bridge.typedb_driver import Credentials, TransactionType, TypeDB, create_driver_options
15
+
16
+ if TYPE_CHECKING:
17
+ from type_bridge.crud.exceptions import (
18
+ EntityNotFoundError,
19
+ KeyAttributeError,
20
+ NotUniqueError,
21
+ RelationNotFoundError,
22
+ )
23
+ from type_bridge.crud.hooks import CrudEvent, CrudHook, HookCancelled
24
+ from type_bridge.migration.exceptions import SchemaConflictError, SchemaValidationError
25
+ from type_bridge.migration.introspection import SchemaIntrospector
26
+
27
+ __version__ = "2.1.0"
28
+
29
+
30
+ _LAZY_EXPORTS: dict[str, tuple[str, str]] = {
31
+ "CrudEvent": ("type_bridge.crud.hooks", "CrudEvent"),
32
+ "CrudHook": ("type_bridge.crud.hooks", "CrudHook"),
33
+ "HookCancelled": ("type_bridge.crud.hooks", "HookCancelled"),
34
+ "EntityNotFoundError": ("type_bridge.crud.exceptions", "EntityNotFoundError"),
35
+ "RelationNotFoundError": ("type_bridge.crud.exceptions", "RelationNotFoundError"),
36
+ "NotUniqueError": ("type_bridge.crud.exceptions", "NotUniqueError"),
37
+ "KeyAttributeError": ("type_bridge.crud.exceptions", "KeyAttributeError"),
38
+ "SchemaIntrospector": ("type_bridge.migration.introspection", "SchemaIntrospector"),
39
+ "SchemaConflictError": ("type_bridge.migration.exceptions", "SchemaConflictError"),
40
+ "SchemaValidationError": ("type_bridge.migration.exceptions", "SchemaValidationError"),
41
+ }
42
+
43
+
44
+ def __getattr__(name: str) -> Any:
45
+ """Load retained compatibility identities without importing authoring eagerly."""
46
+ target = _LAZY_EXPORTS.get(name)
47
+ if target is None:
48
+ from type_bridge.migration._archive_imports import archive_attribute
49
+
50
+ return archive_attribute(__name__, name)
51
+
52
+ from importlib import import_module
53
+
54
+ module_name, attribute_name = target
55
+ value = getattr(import_module(module_name), attribute_name)
56
+ globals()[name] = value
57
+ return value
58
+
59
+
60
+ __all__ = [
61
+ # Database and session
62
+ "Connection",
63
+ "Database",
64
+ "TransactionContext",
65
+ # TypeDB driver (re-exported for convenience)
66
+ "Credentials",
67
+ "TransactionType",
68
+ "TypeDB",
69
+ "create_driver_options",
70
+ # Query
71
+ "Query",
72
+ "QueryBuilder",
73
+ # Hooks
74
+ "CrudEvent",
75
+ "CrudHook",
76
+ "HookCancelled",
77
+ # Proxy
78
+ "ProxyDatabase",
79
+ "ProxyError",
80
+ # CRUD Exceptions
81
+ "EntityNotFoundError",
82
+ "RelationNotFoundError",
83
+ "NotUniqueError",
84
+ "KeyAttributeError",
85
+ # Schema
86
+ "SchemaIntrospector",
87
+ # Schema exceptions
88
+ "SchemaConflictError",
89
+ "SchemaValidationError",
90
+ ]
@@ -33,6 +33,6 @@ def manager_class(default_manager: type[Any]) -> type[Any]:
33
33
  if default_manager.__name__ == "RustTypeDBManager":
34
34
  return default_manager
35
35
 
36
- from type_bridge.crud.rust_manager import RustTypeDBManager
36
+ from type_bridge.crud.rust_manager import _QueryRustTypeDBManager
37
37
 
38
- return RustTypeDBManager
38
+ return _QueryRustTypeDBManager
@@ -0,0 +1,92 @@
1
+ """Thin forwarding facade for generated V2 runtime projections."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from typing import TYPE_CHECKING
7
+
8
+ if TYPE_CHECKING:
9
+ from type_bridge_core import PyProjectedModelManager, PyRuntimeProjection
10
+
11
+ from type_bridge._rust_runtime import rust_core, rust_database_for, rust_transaction_for
12
+
13
+
14
+ class GeneratedEntityProjection:
15
+ """Nominal marker implemented only by generated entity model bases."""
16
+
17
+ __slots__ = ()
18
+
19
+
20
+ class GeneratedRelationProjection:
21
+ """Nominal marker implemented only by generated relation model bases."""
22
+
23
+ __slots__ = ()
24
+
25
+
26
+ _installed_projection_by_model: dict[type[object], PyRuntimeProjection] = {}
27
+
28
+
29
+ def install_runtime_projection(
30
+ projection_json: str,
31
+ semantic_fingerprint_json: str,
32
+ projection_fingerprint_json: str,
33
+ models: Sequence[tuple[type[object], type[object] | None]],
34
+ ) -> PyRuntimeProjection:
35
+ """Verify and install one generated package's native projection."""
36
+ installed = rust_core().PyRuntimeProjection(
37
+ projection_json,
38
+ semantic_fingerprint_json,
39
+ projection_fingerprint_json,
40
+ list(models),
41
+ )
42
+ for model, _reference in models:
43
+ _installed_projection_by_model[model] = installed
44
+ return installed
45
+
46
+
47
+ def _installed_projection_for(model: type[object]) -> PyRuntimeProjection:
48
+ try:
49
+ return _installed_projection_by_model[model]
50
+ except KeyError:
51
+ raise TypeError("query builder requires an exact installed generated model class") from None
52
+
53
+
54
+ def projected_query_builder_match_entity_for(
55
+ model: type[GeneratedEntityProjection],
56
+ variable: str,
57
+ filters: dict[str, object],
58
+ ) -> str:
59
+ """Compile a raw-query entity match from verified generated projection facts."""
60
+ projection = _installed_projection_for(model)
61
+ return projection.query_builder_match_entity(model, variable, filters)
62
+
63
+
64
+ def projected_query_builder_insert_entity_for(
65
+ instance: GeneratedEntityProjection,
66
+ variable: str,
67
+ ) -> str:
68
+ """Compile a raw-query entity insert from one exact generated value."""
69
+ projection = _installed_projection_for(type(instance))
70
+ return projection.query_builder_insert_entity(instance, variable)
71
+
72
+
73
+ def projected_query_builder_match_relation_for(
74
+ model: type[GeneratedRelationProjection],
75
+ variable: str,
76
+ role_players: dict[str, str] | None,
77
+ ) -> str:
78
+ """Compile a raw-query relation match from verified generated role tokens."""
79
+ projection = _installed_projection_for(model)
80
+ return projection.query_builder_match_relation(model, variable, role_players)
81
+
82
+
83
+ def projected_manager_for(
84
+ projection: PyRuntimeProjection,
85
+ model: type[object],
86
+ connection: object,
87
+ ) -> PyProjectedModelManager:
88
+ """Bind a package projection to an existing native connection handle."""
89
+ transaction = rust_transaction_for(connection)
90
+ if transaction is not None:
91
+ return projection.manager_for_transaction(model, transaction)
92
+ return projection.manager_for_database(model, rust_database_for(connection))