@claimscore/event-schemas 0.1.0-beta.2

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.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # event-schemas
2
+
3
+ Single source of truth for all Covalynt Kafka event schemas, defined as `.proto` files and compiled to typed clients per language.
4
+
5
+ See the [Event Schemas ADR](https://www.notion.so/Event-Schemas-ADR-33d12233cdbc80c7831fc2ddec9095b0) for full context and decisions.
6
+
7
+ ---
8
+
9
+ ## How it works
10
+
11
+ 1. Schemas are written as `.proto` files under `schemas/{domain}/`
12
+ 2. [`buf`](https://buf.build/) compiles them to TypeScript under `gen/node/`
13
+ 3. Generated files are **committed** — CI fails if they drift from the source
14
+ 4. The npm package `@claimscore/event-schemas` is published on every `v*` git tag
15
+ 5. Schemas are registered in the Confluent Schema Registry on every merge to `main`
16
+
17
+ ---
18
+
19
+ ## Naming convention
20
+
21
+ `{domain}.{entity}.{event}.{version}` → e.g. `organization.invitation.created.v1`
22
+
23
+ - Proto file: `schemas/organization/v1/invitation_created.proto`
24
+ - Kafka topic subject: `organization.invitation.created.v1-value`
25
+ - Package: `organization.v1`
26
+
27
+ ---
28
+
29
+ ## Adding a new schema
30
+
31
+ 1. Create `schemas/{domain}/v{N}/{entity}_{event}.proto`
32
+ 2. Run `buf generate` locally
33
+ 3. Export the new type from `gen/node/index.ts`
34
+ 4. Open a PR — CI will lint, check for breaking changes, and verify generated files match
35
+
36
+ **Backward compatibility rules (BACKWARD mode):**
37
+ - New fields must be `optional`
38
+ - Never remove a field — mark it `reserved` instead
39
+ - Breaking changes require a new version (e.g. `invitation_created_v2.proto`)
40
+
41
+ ---
42
+
43
+ ## Consuming in Node.js
44
+
45
+ ```bash
46
+ npm install @claimscore/event-schemas
47
+ ```
48
+
49
+ Add to your `.npmrc` (or set via environment):
50
+ ```
51
+ @claimscore:registry=https://registry.npmjs.org/
52
+ ```
53
+
54
+ Usage:
55
+ ```ts
56
+ import { InvitationCreated } from '@claimscore/event-schemas/organization/v1/invitation_created';
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Local development
62
+
63
+ **Prerequisites:** [`buf`](https://buf.build/docs/installation)
64
+
65
+ ```bash
66
+ # Lint all schemas
67
+ buf lint
68
+
69
+ # Check for breaking changes against main
70
+ buf breaking --against '.git#branch=main'
71
+
72
+ # Regenerate TypeScript types
73
+ buf generate
74
+ ```
75
+
76
+ ---
77
+
78
+ ## CI variables required
79
+
80
+ | Variable | Description |
81
+ |----------|-------------|
82
+ | `SCHEMA_REGISTRY_URL` | Base URL of the Confluent Schema Registry on GCP |
83
+ | `SCHEMA_REGISTRY_API_KEY` | Base64-encoded `key:secret` for registry auth |
@@ -0,0 +1,31 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ export declare const protobufPackage = "account.v1";
3
+ export interface AccountActivated {
4
+ accountId: string;
5
+ email: string;
6
+ firstName: string;
7
+ lastName: string;
8
+ organizationId: string;
9
+ organizationName: string;
10
+ invitationId: string;
11
+ }
12
+ export declare const AccountActivated: MessageFns<AccountActivated>;
13
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
14
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
15
+ [K in keyof T]?: DeepPartial<T[K]>;
16
+ } : Partial<T>;
17
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
18
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
19
+ [K in keyof P]: Exact<P[K], I[K]>;
20
+ } & {
21
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
22
+ };
23
+ export interface MessageFns<T> {
24
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
25
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
26
+ fromJSON(object: any): T;
27
+ toJSON(message: T): unknown;
28
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
29
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
30
+ }
31
+ export {};
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.7
5
+ // protoc unknown
6
+ // source: account/v1/account_activated.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AccountActivated = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ exports.protobufPackage = "account.v1";
12
+ function createBaseAccountActivated() {
13
+ return {
14
+ accountId: "",
15
+ email: "",
16
+ firstName: "",
17
+ lastName: "",
18
+ organizationId: "",
19
+ organizationName: "",
20
+ invitationId: "",
21
+ };
22
+ }
23
+ exports.AccountActivated = {
24
+ encode(message, writer = new wire_1.BinaryWriter()) {
25
+ if (message.accountId !== "") {
26
+ writer.uint32(10).string(message.accountId);
27
+ }
28
+ if (message.email !== "") {
29
+ writer.uint32(18).string(message.email);
30
+ }
31
+ if (message.firstName !== "") {
32
+ writer.uint32(26).string(message.firstName);
33
+ }
34
+ if (message.lastName !== "") {
35
+ writer.uint32(34).string(message.lastName);
36
+ }
37
+ if (message.organizationId !== "") {
38
+ writer.uint32(42).string(message.organizationId);
39
+ }
40
+ if (message.organizationName !== "") {
41
+ writer.uint32(50).string(message.organizationName);
42
+ }
43
+ if (message.invitationId !== "") {
44
+ writer.uint32(58).string(message.invitationId);
45
+ }
46
+ return writer;
47
+ },
48
+ decode(input, length) {
49
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
50
+ const end = length === undefined ? reader.len : reader.pos + length;
51
+ const message = createBaseAccountActivated();
52
+ while (reader.pos < end) {
53
+ const tag = reader.uint32();
54
+ switch (tag >>> 3) {
55
+ case 1: {
56
+ if (tag !== 10) {
57
+ break;
58
+ }
59
+ message.accountId = reader.string();
60
+ continue;
61
+ }
62
+ case 2: {
63
+ if (tag !== 18) {
64
+ break;
65
+ }
66
+ message.email = reader.string();
67
+ continue;
68
+ }
69
+ case 3: {
70
+ if (tag !== 26) {
71
+ break;
72
+ }
73
+ message.firstName = reader.string();
74
+ continue;
75
+ }
76
+ case 4: {
77
+ if (tag !== 34) {
78
+ break;
79
+ }
80
+ message.lastName = reader.string();
81
+ continue;
82
+ }
83
+ case 5: {
84
+ if (tag !== 42) {
85
+ break;
86
+ }
87
+ message.organizationId = reader.string();
88
+ continue;
89
+ }
90
+ case 6: {
91
+ if (tag !== 50) {
92
+ break;
93
+ }
94
+ message.organizationName = reader.string();
95
+ continue;
96
+ }
97
+ case 7: {
98
+ if (tag !== 58) {
99
+ break;
100
+ }
101
+ message.invitationId = reader.string();
102
+ continue;
103
+ }
104
+ }
105
+ if ((tag & 7) === 4 || tag === 0) {
106
+ break;
107
+ }
108
+ reader.skip(tag & 7);
109
+ }
110
+ return message;
111
+ },
112
+ fromJSON(object) {
113
+ return {
114
+ accountId: isSet(object.accountId)
115
+ ? globalThis.String(object.accountId)
116
+ : isSet(object.account_id)
117
+ ? globalThis.String(object.account_id)
118
+ : "",
119
+ email: isSet(object.email) ? globalThis.String(object.email) : "",
120
+ firstName: isSet(object.firstName)
121
+ ? globalThis.String(object.firstName)
122
+ : isSet(object.first_name)
123
+ ? globalThis.String(object.first_name)
124
+ : "",
125
+ lastName: isSet(object.lastName)
126
+ ? globalThis.String(object.lastName)
127
+ : isSet(object.last_name)
128
+ ? globalThis.String(object.last_name)
129
+ : "",
130
+ organizationId: isSet(object.organizationId)
131
+ ? globalThis.String(object.organizationId)
132
+ : isSet(object.organization_id)
133
+ ? globalThis.String(object.organization_id)
134
+ : "",
135
+ organizationName: isSet(object.organizationName)
136
+ ? globalThis.String(object.organizationName)
137
+ : isSet(object.organization_name)
138
+ ? globalThis.String(object.organization_name)
139
+ : "",
140
+ invitationId: isSet(object.invitationId)
141
+ ? globalThis.String(object.invitationId)
142
+ : isSet(object.invitation_id)
143
+ ? globalThis.String(object.invitation_id)
144
+ : "",
145
+ };
146
+ },
147
+ toJSON(message) {
148
+ const obj = {};
149
+ if (message.accountId !== "") {
150
+ obj.accountId = message.accountId;
151
+ }
152
+ if (message.email !== "") {
153
+ obj.email = message.email;
154
+ }
155
+ if (message.firstName !== "") {
156
+ obj.firstName = message.firstName;
157
+ }
158
+ if (message.lastName !== "") {
159
+ obj.lastName = message.lastName;
160
+ }
161
+ if (message.organizationId !== "") {
162
+ obj.organizationId = message.organizationId;
163
+ }
164
+ if (message.organizationName !== "") {
165
+ obj.organizationName = message.organizationName;
166
+ }
167
+ if (message.invitationId !== "") {
168
+ obj.invitationId = message.invitationId;
169
+ }
170
+ return obj;
171
+ },
172
+ create(base) {
173
+ return exports.AccountActivated.fromPartial(base ?? {});
174
+ },
175
+ fromPartial(object) {
176
+ const message = createBaseAccountActivated();
177
+ message.accountId = object.accountId ?? "";
178
+ message.email = object.email ?? "";
179
+ message.firstName = object.firstName ?? "";
180
+ message.lastName = object.lastName ?? "";
181
+ message.organizationId = object.organizationId ?? "";
182
+ message.organizationName = object.organizationName ?? "";
183
+ message.invitationId = object.invitationId ?? "";
184
+ return message;
185
+ },
186
+ };
187
+ function isSet(value) {
188
+ return value !== null && value !== undefined;
189
+ }
@@ -0,0 +1,34 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ export declare const protobufPackage = "case.v1";
3
+ export interface CaseCreated {
4
+ caseId: string;
5
+ caseName: string;
6
+ organizationId: string;
7
+ country: string;
8
+ createdBy: string;
9
+ timestamp: string;
10
+ caseNumber: string;
11
+ court: string;
12
+ jurisdiction: string[];
13
+ timezone?: string | undefined;
14
+ }
15
+ export declare const CaseCreated: MessageFns<CaseCreated>;
16
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
17
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
18
+ [K in keyof T]?: DeepPartial<T[K]>;
19
+ } : Partial<T>;
20
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
21
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
22
+ [K in keyof P]: Exact<P[K], I[K]>;
23
+ } & {
24
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
25
+ };
26
+ export interface MessageFns<T> {
27
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
28
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
29
+ fromJSON(object: any): T;
30
+ toJSON(message: T): unknown;
31
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
32
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
33
+ }
34
+ export {};
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.11.7
5
+ // protoc unknown
6
+ // source: case/v1/case_created.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.CaseCreated = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ exports.protobufPackage = "case.v1";
12
+ function createBaseCaseCreated() {
13
+ return {
14
+ caseId: "",
15
+ caseName: "",
16
+ organizationId: "",
17
+ country: "",
18
+ createdBy: "",
19
+ timestamp: "",
20
+ caseNumber: "",
21
+ court: "",
22
+ jurisdiction: [],
23
+ timezone: undefined,
24
+ };
25
+ }
26
+ exports.CaseCreated = {
27
+ encode(message, writer = new wire_1.BinaryWriter()) {
28
+ if (message.caseId !== "") {
29
+ writer.uint32(10).string(message.caseId);
30
+ }
31
+ if (message.caseName !== "") {
32
+ writer.uint32(18).string(message.caseName);
33
+ }
34
+ if (message.organizationId !== "") {
35
+ writer.uint32(26).string(message.organizationId);
36
+ }
37
+ if (message.country !== "") {
38
+ writer.uint32(34).string(message.country);
39
+ }
40
+ if (message.createdBy !== "") {
41
+ writer.uint32(42).string(message.createdBy);
42
+ }
43
+ if (message.timestamp !== "") {
44
+ writer.uint32(50).string(message.timestamp);
45
+ }
46
+ if (message.caseNumber !== "") {
47
+ writer.uint32(58).string(message.caseNumber);
48
+ }
49
+ if (message.court !== "") {
50
+ writer.uint32(66).string(message.court);
51
+ }
52
+ for (const v of message.jurisdiction) {
53
+ writer.uint32(74).string(v);
54
+ }
55
+ if (message.timezone !== undefined) {
56
+ writer.uint32(82).string(message.timezone);
57
+ }
58
+ return writer;
59
+ },
60
+ decode(input, length) {
61
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
62
+ const end = length === undefined ? reader.len : reader.pos + length;
63
+ const message = createBaseCaseCreated();
64
+ while (reader.pos < end) {
65
+ const tag = reader.uint32();
66
+ switch (tag >>> 3) {
67
+ case 1: {
68
+ if (tag !== 10) {
69
+ break;
70
+ }
71
+ message.caseId = reader.string();
72
+ continue;
73
+ }
74
+ case 2: {
75
+ if (tag !== 18) {
76
+ break;
77
+ }
78
+ message.caseName = reader.string();
79
+ continue;
80
+ }
81
+ case 3: {
82
+ if (tag !== 26) {
83
+ break;
84
+ }
85
+ message.organizationId = reader.string();
86
+ continue;
87
+ }
88
+ case 4: {
89
+ if (tag !== 34) {
90
+ break;
91
+ }
92
+ message.country = reader.string();
93
+ continue;
94
+ }
95
+ case 5: {
96
+ if (tag !== 42) {
97
+ break;
98
+ }
99
+ message.createdBy = reader.string();
100
+ continue;
101
+ }
102
+ case 6: {
103
+ if (tag !== 50) {
104
+ break;
105
+ }
106
+ message.timestamp = reader.string();
107
+ continue;
108
+ }
109
+ case 7: {
110
+ if (tag !== 58) {
111
+ break;
112
+ }
113
+ message.caseNumber = reader.string();
114
+ continue;
115
+ }
116
+ case 8: {
117
+ if (tag !== 66) {
118
+ break;
119
+ }
120
+ message.court = reader.string();
121
+ continue;
122
+ }
123
+ case 9: {
124
+ if (tag !== 74) {
125
+ break;
126
+ }
127
+ message.jurisdiction.push(reader.string());
128
+ continue;
129
+ }
130
+ case 10: {
131
+ if (tag !== 82) {
132
+ break;
133
+ }
134
+ message.timezone = reader.string();
135
+ continue;
136
+ }
137
+ }
138
+ if ((tag & 7) === 4 || tag === 0) {
139
+ break;
140
+ }
141
+ reader.skip(tag & 7);
142
+ }
143
+ return message;
144
+ },
145
+ fromJSON(object) {
146
+ return {
147
+ caseId: isSet(object.caseId)
148
+ ? globalThis.String(object.caseId)
149
+ : isSet(object.case_id)
150
+ ? globalThis.String(object.case_id)
151
+ : "",
152
+ caseName: isSet(object.caseName)
153
+ ? globalThis.String(object.caseName)
154
+ : isSet(object.case_name)
155
+ ? globalThis.String(object.case_name)
156
+ : "",
157
+ organizationId: isSet(object.organizationId)
158
+ ? globalThis.String(object.organizationId)
159
+ : isSet(object.organization_id)
160
+ ? globalThis.String(object.organization_id)
161
+ : "",
162
+ country: isSet(object.country) ? globalThis.String(object.country) : "",
163
+ createdBy: isSet(object.createdBy)
164
+ ? globalThis.String(object.createdBy)
165
+ : isSet(object.created_by)
166
+ ? globalThis.String(object.created_by)
167
+ : "",
168
+ timestamp: isSet(object.timestamp) ? globalThis.String(object.timestamp) : "",
169
+ caseNumber: isSet(object.caseNumber)
170
+ ? globalThis.String(object.caseNumber)
171
+ : isSet(object.case_number)
172
+ ? globalThis.String(object.case_number)
173
+ : "",
174
+ court: isSet(object.court) ? globalThis.String(object.court) : "",
175
+ jurisdiction: globalThis.Array.isArray(object?.jurisdiction)
176
+ ? object.jurisdiction.map((e) => globalThis.String(e))
177
+ : [],
178
+ timezone: isSet(object.timezone) ? globalThis.String(object.timezone) : undefined,
179
+ };
180
+ },
181
+ toJSON(message) {
182
+ const obj = {};
183
+ if (message.caseId !== "") {
184
+ obj.caseId = message.caseId;
185
+ }
186
+ if (message.caseName !== "") {
187
+ obj.caseName = message.caseName;
188
+ }
189
+ if (message.organizationId !== "") {
190
+ obj.organizationId = message.organizationId;
191
+ }
192
+ if (message.country !== "") {
193
+ obj.country = message.country;
194
+ }
195
+ if (message.createdBy !== "") {
196
+ obj.createdBy = message.createdBy;
197
+ }
198
+ if (message.timestamp !== "") {
199
+ obj.timestamp = message.timestamp;
200
+ }
201
+ if (message.caseNumber !== "") {
202
+ obj.caseNumber = message.caseNumber;
203
+ }
204
+ if (message.court !== "") {
205
+ obj.court = message.court;
206
+ }
207
+ if (message.jurisdiction?.length) {
208
+ obj.jurisdiction = message.jurisdiction;
209
+ }
210
+ if (message.timezone !== undefined) {
211
+ obj.timezone = message.timezone;
212
+ }
213
+ return obj;
214
+ },
215
+ create(base) {
216
+ return exports.CaseCreated.fromPartial(base ?? {});
217
+ },
218
+ fromPartial(object) {
219
+ const message = createBaseCaseCreated();
220
+ message.caseId = object.caseId ?? "";
221
+ message.caseName = object.caseName ?? "";
222
+ message.organizationId = object.organizationId ?? "";
223
+ message.country = object.country ?? "";
224
+ message.createdBy = object.createdBy ?? "";
225
+ message.timestamp = object.timestamp ?? "";
226
+ message.caseNumber = object.caseNumber ?? "";
227
+ message.court = object.court ?? "";
228
+ message.jurisdiction = object.jurisdiction?.map((e) => e) || [];
229
+ message.timezone = object.timezone ?? undefined;
230
+ return message;
231
+ },
232
+ };
233
+ function isSet(value) {
234
+ return value !== null && value !== undefined;
235
+ }
@@ -0,0 +1,32 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ export declare const protobufPackage = "case.v1";
3
+ export interface PermissionCreated {
4
+ caseId: string;
5
+ caseName: string;
6
+ accountId: string;
7
+ email: string;
8
+ firstName: string;
9
+ roleName: string;
10
+ organizationId: string;
11
+ managerAccountId: string;
12
+ }
13
+ export declare const PermissionCreated: MessageFns<PermissionCreated>;
14
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
15
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
16
+ [K in keyof T]?: DeepPartial<T[K]>;
17
+ } : Partial<T>;
18
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
19
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
20
+ [K in keyof P]: Exact<P[K], I[K]>;
21
+ } & {
22
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
23
+ };
24
+ export interface MessageFns<T> {
25
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
26
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
27
+ fromJSON(object: any): T;
28
+ toJSON(message: T): unknown;
29
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
30
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
31
+ }
32
+ export {};