messagebirds 0.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.
@@ -0,0 +1,10 @@
1
+ /target
2
+ node_modules/
3
+ dist/
4
+ *.log
5
+ .env
6
+ .DS_Store
7
+ .next/
8
+ *.tsbuildinfo
9
+ ui/AGENTS.md
10
+ ui/CLAUDE.md
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.4
2
+ Name: messagebirds
3
+ Version: 0.1.0
4
+ Summary: Python client SDK for MessageBirds, an open-source event-driven Customer Data & Engagement Platform
5
+ Project-URL: Repository, https://github.com/Mullassery/MessageBirds
6
+ Project-URL: Issues, https://github.com/Mullassery/MessageBirds/issues
7
+ Author-email: Georgi Mammen Mullassery <mullassery@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Requires-Python: >=3.9
19
+ Requires-Dist: requests>=2.28
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=7.0; extra == 'dev'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # messagebirds
25
+
26
+ Python client SDK for [MessageBirds](https://github.com/Mullassery/MessageBirds), an
27
+ open-source, event-driven Customer Data & Engagement Platform.
28
+
29
+ Mirrors `sdk/js` exactly in scope: `MessageBirdsClient` covers the core
30
+ send-an-event / read-a-profile loop (the same three methods the TS client
31
+ exposes), not one method per API endpoint. Everything else — audiences,
32
+ governance, channels, templates, journeys — is typed in `messagebirds.types`
33
+ for use with your own `requests` calls against the REST API, the same role
34
+ `apiFetch<T>` plays against the TS types for `ui/`.
35
+
36
+ ## Install
37
+
38
+ ```bash
39
+ pip install messagebirds
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```python
45
+ from messagebirds import MessageBirdsClient, EventEnvelope
46
+
47
+ client = MessageBirdsClient("http://localhost:8080")
48
+
49
+ envelope: EventEnvelope = {
50
+ "event_id": "...",
51
+ "event_type": "commerce.product_view",
52
+ "timestamp": "2026-09-18T00:00:00Z",
53
+ "source": {"type": "web", "name": "website"},
54
+ "identity": [{"namespace": "anonymous_id", "value": "anon-1", "primary": True, "source": "sdk"}],
55
+ "schema": {"name": "commerce.product_view", "version": "1.0"},
56
+ "data": {"product_id": "p1"},
57
+ "context": {"profile_updates": {"core/person@1.0": {"first_name": "Jane"}}},
58
+ "tenant_id": "...",
59
+ }
60
+
61
+ client.send_event(envelope)
62
+ profile = client.find_profile_by_identity("<tenant_id>", "anonymous_id", "anon-1")
63
+ ```
64
+
65
+ ## Development
66
+
67
+ ```bash
68
+ pip install -e ".[dev]"
69
+ pytest
70
+ ```
71
+
72
+ ## License
73
+
74
+ Apache-2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,51 @@
1
+ # messagebirds
2
+
3
+ Python client SDK for [MessageBirds](https://github.com/Mullassery/MessageBirds), an
4
+ open-source, event-driven Customer Data & Engagement Platform.
5
+
6
+ Mirrors `sdk/js` exactly in scope: `MessageBirdsClient` covers the core
7
+ send-an-event / read-a-profile loop (the same three methods the TS client
8
+ exposes), not one method per API endpoint. Everything else — audiences,
9
+ governance, channels, templates, journeys — is typed in `messagebirds.types`
10
+ for use with your own `requests` calls against the REST API, the same role
11
+ `apiFetch<T>` plays against the TS types for `ui/`.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install messagebirds
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ from messagebirds import MessageBirdsClient, EventEnvelope
23
+
24
+ client = MessageBirdsClient("http://localhost:8080")
25
+
26
+ envelope: EventEnvelope = {
27
+ "event_id": "...",
28
+ "event_type": "commerce.product_view",
29
+ "timestamp": "2026-09-18T00:00:00Z",
30
+ "source": {"type": "web", "name": "website"},
31
+ "identity": [{"namespace": "anonymous_id", "value": "anon-1", "primary": True, "source": "sdk"}],
32
+ "schema": {"name": "commerce.product_view", "version": "1.0"},
33
+ "data": {"product_id": "p1"},
34
+ "context": {"profile_updates": {"core/person@1.0": {"first_name": "Jane"}}},
35
+ "tenant_id": "...",
36
+ }
37
+
38
+ client.send_event(envelope)
39
+ profile = client.find_profile_by_identity("<tenant_id>", "anonymous_id", "anon-1")
40
+ ```
41
+
42
+ ## Development
43
+
44
+ ```bash
45
+ pip install -e ".[dev]"
46
+ pytest
47
+ ```
48
+
49
+ ## License
50
+
51
+ Apache-2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "messagebirds"
7
+ version = "0.1.0"
8
+ description = "Python client SDK for MessageBirds, an open-source event-driven Customer Data & Engagement Platform"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [{ name = "Georgi Mammen Mullassery", email = "mullassery@gmail.com" }]
12
+ requires-python = ">=3.9"
13
+ dependencies = ["requests>=2.28"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ ]
24
+
25
+ [project.optional-dependencies]
26
+ dev = ["pytest>=7.0"]
27
+
28
+ [project.urls]
29
+ Repository = "https://github.com/Mullassery/MessageBirds"
30
+ Issues = "https://github.com/Mullassery/MessageBirds/issues"
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ packages = ["src/messagebirds"]
34
+
35
+ [tool.hatch.build.targets.sdist]
36
+ include = ["src/messagebirds", "LICENSE", "README.md"]
@@ -0,0 +1,108 @@
1
+ from .client import ApiError, MessageBirdsClient
2
+ from .types import (
3
+ ActivationSummary,
4
+ AttributeOp,
5
+ AudienceDefinition,
6
+ AudienceStatus,
7
+ BlockedProfile,
8
+ Channel,
9
+ Condition,
10
+ ConsentEvent,
11
+ ConsentState,
12
+ ConsentSummary,
13
+ ConsentView,
14
+ ContactPolicy,
15
+ DeadLetterEventView,
16
+ Destination,
17
+ Effect,
18
+ EventDetail,
19
+ EventEnvelope,
20
+ EventSource,
21
+ EventSummary,
22
+ FieldDef,
23
+ FieldProvenance,
24
+ FieldType,
25
+ IdentityAuditEntry,
26
+ IdentityAuditKind,
27
+ IdentityNode,
28
+ IdentityRef,
29
+ IdentityView,
30
+ JourneyDefinition,
31
+ JourneyRun,
32
+ JourneyRunEvent,
33
+ JourneyStatus,
34
+ Membership,
35
+ MembershipKind,
36
+ MergeSuggestion,
37
+ MessageTemplate,
38
+ MixinDef,
39
+ MixinStatus,
40
+ Node,
41
+ Policy,
42
+ PolicySimulateResponse,
43
+ ProfileView,
44
+ Reason,
45
+ RenderedTemplate,
46
+ RunEventKind,
47
+ RunStatus,
48
+ SchemaDefinition,
49
+ SchemaRef,
50
+ SchemaStatus,
51
+ SplitBranch,
52
+ Trigger,
53
+ )
54
+
55
+ __all__ = [
56
+ "MessageBirdsClient",
57
+ "ApiError",
58
+ "ActivationSummary",
59
+ "AttributeOp",
60
+ "AudienceDefinition",
61
+ "AudienceStatus",
62
+ "BlockedProfile",
63
+ "Channel",
64
+ "Condition",
65
+ "ConsentEvent",
66
+ "ConsentState",
67
+ "ConsentSummary",
68
+ "ConsentView",
69
+ "ContactPolicy",
70
+ "DeadLetterEventView",
71
+ "Destination",
72
+ "Effect",
73
+ "EventDetail",
74
+ "EventEnvelope",
75
+ "EventSource",
76
+ "EventSummary",
77
+ "FieldDef",
78
+ "FieldProvenance",
79
+ "FieldType",
80
+ "IdentityAuditEntry",
81
+ "IdentityAuditKind",
82
+ "IdentityNode",
83
+ "IdentityRef",
84
+ "IdentityView",
85
+ "JourneyDefinition",
86
+ "JourneyRun",
87
+ "JourneyRunEvent",
88
+ "JourneyStatus",
89
+ "Membership",
90
+ "MembershipKind",
91
+ "MergeSuggestion",
92
+ "MessageTemplate",
93
+ "MixinDef",
94
+ "MixinStatus",
95
+ "Node",
96
+ "Policy",
97
+ "PolicySimulateResponse",
98
+ "ProfileView",
99
+ "Reason",
100
+ "RenderedTemplate",
101
+ "RunEventKind",
102
+ "RunStatus",
103
+ "SchemaDefinition",
104
+ "SchemaRef",
105
+ "SchemaStatus",
106
+ "SplitBranch",
107
+ "Trigger",
108
+ ]
@@ -0,0 +1,54 @@
1
+ from __future__ import annotations
2
+
3
+ import requests
4
+
5
+ from .types import EventEnvelope, ProfileView
6
+
7
+
8
+ class ApiError(Exception):
9
+ """Mirrors `sdk/js`'s `ApiError` — raised for any non-2xx, non-404 response."""
10
+
11
+ def __init__(self, status: int, message: str) -> None:
12
+ super().__init__(message)
13
+ self.status = status
14
+
15
+
16
+ class MessageBirdsClient:
17
+ """
18
+ Mirrors `sdk/js`'s `MessageBirdsClient` exactly: the core send-an-event,
19
+ read-a-profile loop, not a method per API endpoint. For everything
20
+ else, build your own request against `base_url` — the `messagebirds`
21
+ package's `types` module gives you typed dict shapes for the response,
22
+ the same role `apiFetch<T>` plays against the TS types for `ui/`.
23
+ """
24
+
25
+ def __init__(self, base_url: str, *, session: requests.Session | None = None) -> None:
26
+ self.base_url = base_url.rstrip("/")
27
+ self._session = session or requests.Session()
28
+
29
+ def send_event(self, envelope: EventEnvelope) -> dict[str, str]:
30
+ res = self._session.post(f"{self.base_url}/events", json=envelope)
31
+ if not res.ok:
32
+ raise ApiError(res.status_code, f"POST /events failed: {res.text}")
33
+ return res.json()
34
+
35
+ def get_profile(self, profile_id: str) -> ProfileView | None:
36
+ res = self._session.get(f"{self.base_url}/profiles/{profile_id}")
37
+ if res.status_code == 404:
38
+ return None
39
+ if not res.ok:
40
+ raise ApiError(res.status_code, f"GET /profiles/{profile_id} failed: {res.text}")
41
+ return res.json()
42
+
43
+ def find_profile_by_identity(
44
+ self, tenant_id: str, namespace: str, value: str
45
+ ) -> ProfileView | None:
46
+ res = self._session.get(
47
+ f"{self.base_url}/profiles/by-identity",
48
+ params={"tenant_id": tenant_id, "namespace": namespace, "value": value},
49
+ )
50
+ if res.status_code == 404:
51
+ return None
52
+ if not res.ok:
53
+ raise ApiError(res.status_code, f"GET /profiles/by-identity failed: {res.text}")
54
+ return res.json()
File without changes
@@ -0,0 +1,466 @@
1
+ """
2
+ Typed dict mirrors of the MessageBirds API's JSON shapes.
3
+
4
+ Kept in lockstep with `sdk/js/src/types.ts`, which is itself kept in
5
+ lockstep with the Rust types it names in each docstring. Python is
6
+ dynamically typed, so nothing here is enforced at runtime — these exist
7
+ for editor/mypy support when building your own requests against
8
+ `MessageBirdsClient.request`, the same role `apiFetch<T>` plays for
9
+ `ui/` against the TS types.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Any, Literal, TypedDict
15
+
16
+
17
+ class IdentityRef(TypedDict, total=False):
18
+ """Mirrors `mb_core::IdentityRef`."""
19
+
20
+ namespace: str
21
+ value: str
22
+ primary: bool
23
+ source: str
24
+ confidence: float
25
+
26
+
27
+ class EventSource(TypedDict):
28
+ """Mirrors `mb_core::EventSource`."""
29
+
30
+ type: str
31
+ name: str
32
+
33
+
34
+ class SchemaRef(TypedDict):
35
+ """Mirrors `mb_core::SchemaRef`."""
36
+
37
+ name: str
38
+ version: str
39
+
40
+
41
+ class EventEnvelope(TypedDict, total=False):
42
+ """
43
+ Mirrors `mb_core::EventEnvelope`. `context["profile_updates"]`, if
44
+ present, is a map of mixin key (`"core/person@1.0"`) to the field
45
+ values this event contributes to that mixin — see docs/OCDS.md.
46
+ """
47
+
48
+ event_id: str
49
+ event_type: str
50
+ timestamp: str
51
+ source: EventSource
52
+ identity: list[IdentityRef]
53
+ context: dict[str, Any]
54
+ data: dict[str, Any]
55
+ schema: SchemaRef
56
+ consent: Any
57
+ governance: Any
58
+ correlation_id: str
59
+ trace_id: str
60
+ tenant_id: str
61
+
62
+
63
+ class FieldProvenance(TypedDict):
64
+ """Mirrors `mb_profile::FieldProvenance`."""
65
+
66
+ profile_id: str
67
+ mixin_key: str
68
+ field_path: str
69
+ value: Any
70
+ source: str
71
+ event_id: str
72
+ applied_policy: str
73
+ updated_at: str
74
+
75
+
76
+ class ProfileView(TypedDict):
77
+ """Response shape of `GET /profiles/{id}` and `GET /profiles/by-identity`."""
78
+
79
+ id: str
80
+ tenant_id: str
81
+ mixins: dict[str, dict[str, Any]]
82
+ created_at: str
83
+ updated_at: str
84
+ provenance: list[FieldProvenance]
85
+
86
+
87
+ class IdentityNode(TypedDict):
88
+ """Mirrors `mb_identity::IdentityNode`."""
89
+
90
+ id: str
91
+ tenant_id: str
92
+ namespace: str
93
+ value_hash: str
94
+ profile_id: str
95
+ confidence: float
96
+ source: str
97
+ first_seen_at: str
98
+ last_seen_at: str
99
+
100
+
101
+ IdentityAuditKind = Literal["linked", "merged", "split"]
102
+
103
+
104
+ class IdentityAuditEntry(TypedDict):
105
+ """
106
+ Mirrors `mb_identity::IdentityAuditEntry`. `namespace`/`value_hash`
107
+ are `None` for `"merged"` entries, which record a whole-profile
108
+ merge rather than one identity claim.
109
+ """
110
+
111
+ id: str
112
+ tenant_id: str
113
+ kind: IdentityAuditKind
114
+ namespace: str | None
115
+ value_hash: str | None
116
+ profile_id: str
117
+ previous_profile_id: str | None
118
+ source: str
119
+ created_at: str
120
+
121
+
122
+ class IdentityView(TypedDict):
123
+ """Response shape of `GET /profiles/{id}/identity`."""
124
+
125
+ nodes: list[IdentityNode]
126
+ audit: list[IdentityAuditEntry]
127
+
128
+
129
+ class MergeSuggestion(TypedDict):
130
+ """
131
+ One entry in `GET /profiles/{id}/merge-suggestions` — a
132
+ confidence-scored candidate for a manual merge. Never applied
133
+ automatically.
134
+ """
135
+
136
+ profile_id: str
137
+ score: float
138
+
139
+
140
+ class EventSummary(TypedDict):
141
+ """One row of `GET /profiles/{id}/events`."""
142
+
143
+ id: str
144
+ event_type: str
145
+ schema_name: str
146
+ schema_version: str
147
+ identity: list[IdentityRef]
148
+ data: dict[str, Any]
149
+ received_at: str
150
+ occurred_at: str
151
+
152
+
153
+ class EventDetail(TypedDict):
154
+ """Response of `GET /events/{id}` — a single event, in full."""
155
+
156
+ id: str
157
+ tenant_id: str
158
+ event_type: str
159
+ schema_name: str
160
+ schema_version: str
161
+ identity: list[IdentityRef]
162
+ context: dict[str, Any]
163
+ data: dict[str, Any]
164
+ profile_id: str
165
+ received_at: str
166
+ occurred_at: str
167
+
168
+
169
+ FieldType = Literal["string", "number", "boolean", "object", "array"]
170
+
171
+
172
+ class FieldDef(TypedDict, total=False):
173
+ """Mirrors `mb_schema_registry::FieldDef`."""
174
+
175
+ type: FieldType
176
+ required: bool
177
+ enum: list[Any] | None
178
+ labels: list[str]
179
+
180
+
181
+ SchemaStatus = Literal["active", "deprecated"]
182
+
183
+
184
+ class SchemaDefinition(TypedDict):
185
+ """Mirrors `mb_schema_registry::Schema` — response of `GET /schemas/{name}/{version}`."""
186
+
187
+ id: str
188
+ name: str
189
+ version: str
190
+ fields: dict[str, FieldDef]
191
+ status: SchemaStatus
192
+ created_at: str
193
+
194
+
195
+ MixinStatus = Literal["active", "deprecated"]
196
+
197
+
198
+ class MixinDef(TypedDict):
199
+ """Mirrors `mb_mixins::MixinDef` — response of `GET /mixins/{namespace}/{name}/{version}`."""
200
+
201
+ id: str
202
+ namespace: str
203
+ name: str
204
+ version: str
205
+ fields: dict[str, FieldDef]
206
+ status: MixinStatus
207
+ created_at: str
208
+
209
+
210
+ AttributeOp = Literal[
211
+ "equals", "not_equals", "exists", "not_exists", "greater_than", "less_than", "contains"
212
+ ]
213
+
214
+ # Mirrors `mb_audiences::Condition`. Externally tagged on the wire
215
+ # (`{"attribute": {...}}`, not `{"type": "attribute", ...}`) — plain
216
+ # dicts, not a TypedDict union, since Python has no discriminated-union
217
+ # construct that maps cleanly onto externally-tagged serde output.
218
+ Condition = dict[str, Any]
219
+
220
+ AudienceStatus = Literal["active", "archived"]
221
+
222
+
223
+ class AudienceDefinition(TypedDict):
224
+ """Mirrors `mb_audiences::AudienceDefinition`."""
225
+
226
+ id: str
227
+ tenant_id: str
228
+ name: str
229
+ version: int
230
+ conditions: Condition
231
+ status: AudienceStatus
232
+ created_at: str
233
+
234
+
235
+ MembershipKind = Literal["entered", "exited"]
236
+
237
+
238
+ class Membership(TypedDict):
239
+ """Mirrors `mb_audiences::Membership` — current membership state."""
240
+
241
+ audience_id: str
242
+ profile_id: str
243
+ entered_at: str
244
+ exited_at: str | None
245
+
246
+
247
+ class Destination(TypedDict):
248
+ """Mirrors `mb_connectors::Destination`."""
249
+
250
+ id: str
251
+ tenant_id: str
252
+ kind: str
253
+ name: str
254
+ config: dict[str, Any]
255
+ supported_actions: list[str]
256
+ created_at: str
257
+
258
+
259
+ # Mirrors `mb_governance::Reason` — why an activation was denied.
260
+ # Internally tagged on `"kind"` (safe here since `Reason` isn't
261
+ # recursive) — again a plain dict rather than a TypedDict union.
262
+ Reason = dict[str, Any]
263
+
264
+
265
+ class BlockedProfile(TypedDict):
266
+ """One profile skipped during activation, and why."""
267
+
268
+ profile_id: str
269
+ reasons: list[Reason]
270
+
271
+
272
+ class ActivationSummary(TypedDict):
273
+ """Response of `POST /audiences/{id}/activate`."""
274
+
275
+ sent: int
276
+ failed: int
277
+ blocked: list[BlockedProfile]
278
+
279
+
280
+ class DeadLetterEventView(TypedDict):
281
+ """One row of `GET /dead-letter-events`."""
282
+
283
+ id: str
284
+ event_id: str
285
+ schema_name: str
286
+ schema_version: str
287
+ source: str
288
+ reason: str
289
+ raw_payload: Any
290
+ created_at: str
291
+
292
+
293
+ Effect = Literal["allow", "deny"]
294
+
295
+
296
+ class Policy(TypedDict):
297
+ """Mirrors `mb_governance::Policy`."""
298
+
299
+ id: str
300
+ tenant_id: str
301
+ label: str
302
+ action: str
303
+ effect: Effect
304
+ priority: int
305
+ created_at: str
306
+
307
+
308
+ class ConsentEvent(TypedDict):
309
+ """Mirrors `mb_governance::ConsentEvent` — one append-only consent record."""
310
+
311
+ id: str
312
+ tenant_id: str
313
+ profile_id: str
314
+ purpose: str
315
+ granted: bool
316
+ source: str
317
+ jurisdiction: str | None
318
+ consent_version: str | None
319
+ expires_at: str | None
320
+ created_at: str
321
+
322
+
323
+ class ConsentState(TypedDict):
324
+ """Mirrors `mb_governance::ConsentState` — derived current state for one purpose."""
325
+
326
+ purpose: str
327
+ granted: bool
328
+ source: str
329
+ updated_at: str
330
+
331
+
332
+ class ConsentView(TypedDict):
333
+ """Response of `GET /profiles/{id}/consent`."""
334
+
335
+ current: list[ConsentState]
336
+ history: list[ConsentEvent]
337
+
338
+
339
+ class ConsentSummary(TypedDict):
340
+ granted: int
341
+ missing: int
342
+ total: int
343
+
344
+
345
+ class PolicySimulateResponse(TypedDict):
346
+ """Response of `POST /policy-simulate` (Section 49)."""
347
+
348
+ allowed_fields: list[str]
349
+ blocked_fields: list[str]
350
+ applicable_policies: list[Reason]
351
+ consent_summary: ConsentSummary | None
352
+ final_decision: Literal["allow", "deny", "partial"]
353
+
354
+
355
+ class Channel(TypedDict):
356
+ """Mirrors `mb_channels::Channel`. Only `kind: "webhook"` has a real transport."""
357
+
358
+ id: str
359
+ tenant_id: str
360
+ kind: str
361
+ name: str
362
+ config: Any
363
+ created_at: str
364
+
365
+
366
+ class MessageTemplate(TypedDict):
367
+ """Mirrors `mb_templates::MessageTemplate`."""
368
+
369
+ id: str
370
+ tenant_id: str
371
+ channel_kind: str
372
+ name: str
373
+ version: int
374
+ subject: str | None
375
+ body: str
376
+ created_at: str
377
+
378
+
379
+ class RenderedTemplate(TypedDict):
380
+ """Mirrors `mb_templates::RenderedTemplate`."""
381
+
382
+ subject: str | None
383
+ body: str
384
+ missing_variables: list[str]
385
+
386
+
387
+ # Mirrors `mb_journeys::Trigger`. Internally tagged on `"kind"`, like `NodeKind`.
388
+ Trigger = dict[str, Any]
389
+
390
+
391
+ class SplitBranch(TypedDict):
392
+ """Mirrors `mb_journeys::SplitBranch`."""
393
+
394
+ next: str
395
+ weight: int
396
+
397
+
398
+ # Mirrors `mb_journeys::NodeKind` flattened with `id` into `mb_journeys::Node`
399
+ # — internally tagged on `"kind"` (not recursive, unlike `Condition`).
400
+ Node = dict[str, Any]
401
+
402
+ JourneyStatus = Literal["active", "archived"]
403
+
404
+
405
+ class JourneyDefinition(TypedDict):
406
+ """Mirrors `mb_journeys::JourneyDefinition`. Graph is a flat node list, not nested."""
407
+
408
+ id: str
409
+ tenant_id: str
410
+ name: str
411
+ version: int
412
+ trigger: Trigger
413
+ nodes: list[Node]
414
+ entry_node: str
415
+ status: JourneyStatus
416
+ created_at: str
417
+
418
+
419
+ RunStatus = Literal["running", "waiting", "completed", "failed"]
420
+
421
+
422
+ class JourneyRun(TypedDict):
423
+ """Mirrors `mb_journeys::JourneyRun`."""
424
+
425
+ id: str
426
+ tenant_id: str
427
+ journey_id: str
428
+ profile_id: str
429
+ current_node: str
430
+ status: RunStatus
431
+ wake_at: str | None
432
+ started_at: str
433
+ updated_at: str
434
+
435
+
436
+ RunEventKind = Literal[
437
+ "entered",
438
+ "waited",
439
+ "branched",
440
+ "action_sent",
441
+ "action_suppressed",
442
+ "action_failed",
443
+ "completed",
444
+ ]
445
+
446
+
447
+ class JourneyRunEvent(TypedDict):
448
+ """Mirrors `mb_journeys::JourneyRunEvent` — one append-only step log entry."""
449
+
450
+ id: str
451
+ run_id: str
452
+ node_id: str
453
+ kind: RunEventKind
454
+ detail: str | None
455
+ created_at: str
456
+
457
+
458
+ class ContactPolicy(TypedDict):
459
+ """Mirrors `mb_journeys::ContactPolicy`. `channel_id: None` applies across all channels."""
460
+
461
+ id: str
462
+ tenant_id: str
463
+ max_messages: int
464
+ window_days: int
465
+ channel_id: str | None
466
+ created_at: str