@togatherlabs/event-sdk 1.0.17 → 1.0.18
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
CHANGED
|
@@ -206,6 +206,58 @@ print(decoded)
|
|
|
206
206
|
* Use `int64` for timestamps, `string` for IDs/emails, etc.
|
|
207
207
|
|
|
208
208
|
|
|
209
|
+
## How to Type a Event
|
|
210
|
+
|
|
211
|
+
A Event will have many fields like
|
|
212
|
+
```proto
|
|
213
|
+
message DomainEventExample {
|
|
214
|
+
/// event name (e.g. "user.account.created")
|
|
215
|
+
string event_name = 1;
|
|
216
|
+
/// Schema version (e.g."v1"), reciving systems can use this to deserialize the payload accordingly with version
|
|
217
|
+
string event_version = 2;
|
|
218
|
+
/// The entity or aggregate this event belongs to (for partitioning)
|
|
219
|
+
string aggregate_id = 3;
|
|
220
|
+
/// Binary-encoded event data (the inner protobuf message),will be typed check events for specific event
|
|
221
|
+
bytes payload = 4;
|
|
222
|
+
/// Epoch timestamp in milliseconds when the event was created,indicate when this action was recorded by the system
|
|
223
|
+
int64 timestamp = 5;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
### How should you type a event
|
|
227
|
+
```proto
|
|
228
|
+
syntax = "proto3";
|
|
229
|
+
|
|
230
|
+
package admin.v1;
|
|
231
|
+
|
|
232
|
+
import "google/protobuf/descriptor.proto";
|
|
233
|
+
|
|
234
|
+
extend google.protobuf.FieldOptions {
|
|
235
|
+
string fixed_value = 50001;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
message Payload {
|
|
239
|
+
string id = 10; // Account ID
|
|
240
|
+
string email = 11; // Account email
|
|
241
|
+
string name = 12; // Account name
|
|
242
|
+
int64 created_at = 13; // Account creation timestamp
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
message AdminAccountCreated {
|
|
246
|
+
// Common metadata fields (in every event)
|
|
247
|
+
// "admin.account.created"
|
|
248
|
+
string event_name = 1 [(fixed_value) = "admin.account.created"];
|
|
249
|
+
|
|
250
|
+
string event_version = 2; // "v1"
|
|
251
|
+
string aggregate_id = 3; // Account ID for partitioning
|
|
252
|
+
int64 timestamp = 4; // When event was created
|
|
253
|
+
string trace_id = 5; // For distributed tracing
|
|
254
|
+
|
|
255
|
+
Payload payload = 9; // Event-specific data
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
check the docs to see why this decistion was taken: [docs](./docs/how_to_type_event.md)
|
|
260
|
+
|
|
209
261
|
## Troubleshooting
|
|
210
262
|
|
|
211
263
|
* **ModuleNotFoundError in Python**
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.10.0 with parameter "target=js+dts,import_extension=none"
|
|
2
|
+
// @generated from file admin/v1/admin_created.proto (package admin.v1, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import type { GenExtension, GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
|
|
6
|
+
import type { Message } from "@bufbuild/protobuf";
|
|
7
|
+
import type { FieldOptions } from "@bufbuild/protobuf/wkt";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Describes the file admin/v1/admin_created.proto.
|
|
11
|
+
*/
|
|
12
|
+
export declare const file_admin_v1_admin_created: GenFile;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @generated from message admin.v1.Payload
|
|
16
|
+
*/
|
|
17
|
+
export declare type Payload = Message<"admin.v1.Payload"> & {
|
|
18
|
+
/**
|
|
19
|
+
* @generated from field: string id = 10;
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @generated from field: string email = 11;
|
|
25
|
+
*/
|
|
26
|
+
email: string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @generated from field: string first_name = 12;
|
|
30
|
+
*/
|
|
31
|
+
firstName: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @generated from field: string last_name = 13;
|
|
35
|
+
*/
|
|
36
|
+
lastName: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @generated from field: int64 created_at = 14;
|
|
40
|
+
*/
|
|
41
|
+
createdAt: bigint;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Describes the message admin.v1.Payload.
|
|
46
|
+
* Use `create(PayloadSchema)` to create a new message.
|
|
47
|
+
*/
|
|
48
|
+
export declare const PayloadSchema: GenMessage<Payload>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @generated from message admin.v1.AdminAccountCreated
|
|
52
|
+
*/
|
|
53
|
+
export declare type AdminAccountCreated = Message<"admin.v1.AdminAccountCreated"> & {
|
|
54
|
+
/**
|
|
55
|
+
* @generated from field: string event_name = 1;
|
|
56
|
+
*/
|
|
57
|
+
eventName: string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @generated from field: int32 event_version = 2;
|
|
61
|
+
*/
|
|
62
|
+
eventVersion: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @generated from field: string aggregate_id = 3;
|
|
66
|
+
*/
|
|
67
|
+
aggregateId: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @generated from field: int64 timestamp = 4;
|
|
71
|
+
*/
|
|
72
|
+
timestamp: bigint;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @generated from field: string trace_id = 5;
|
|
76
|
+
*/
|
|
77
|
+
traceId: string;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @generated from field: admin.v1.Payload payload = 9;
|
|
81
|
+
*/
|
|
82
|
+
payload?: Payload;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Describes the message admin.v1.AdminAccountCreated.
|
|
87
|
+
* Use `create(AdminAccountCreatedSchema)` to create a new message.
|
|
88
|
+
*/
|
|
89
|
+
export declare const AdminAccountCreatedSchema: GenMessage<AdminAccountCreated>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @generated from extension: string fixed_value = 50001;
|
|
93
|
+
*/
|
|
94
|
+
export declare const fixed_value: GenExtension<FieldOptions, string>;
|
|
95
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @generated by protoc-gen-es v2.10.0 with parameter "target=js+dts,import_extension=none"
|
|
2
|
+
// @generated from file admin/v1/admin_created.proto (package admin.v1, syntax proto3)
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import { extDesc, fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
|
|
6
|
+
import { file_google_protobuf_descriptor } from "@bufbuild/protobuf/wkt";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Describes the file admin/v1/admin_created.proto.
|
|
10
|
+
*/
|
|
11
|
+
export const file_admin_v1_admin_created = /*@__PURE__*/
|
|
12
|
+
fileDesc("ChxhZG1pbi92MS9hZG1pbl9jcmVhdGVkLnByb3RvEghhZG1pbi52MSJfCgdQYXlsb2FkEgoKAmlkGAogASgJEg0KBWVtYWlsGAsgASgJEhIKCmZpcnN0X25hbWUYDCABKAkSEQoJbGFzdF9uYW1lGA0gASgJEhIKCmNyZWF0ZWRfYXQYDiABKAMiwQEKE0FkbWluQWNjb3VudENyZWF0ZWQSLQoKZXZlbnRfbmFtZRgBIAEoCUIZirUYFWFkbWluLmFjY291bnQuY3JlYXRlZBIcCg1ldmVudF92ZXJzaW9uGAIgASgFQgWKtRgBMRIUCgxhZ2dyZWdhdGVfaWQYAyABKAkSEQoJdGltZXN0YW1wGAQgASgDEhAKCHRyYWNlX2lkGAUgASgJEiIKB3BheWxvYWQYCSABKAsyES5hZG1pbi52MS5QYXlsb2FkOkAKC2ZpeGVkX3ZhbHVlEh0uZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucxjRhgMgASgJUgpmaXhlZFZhbHVlQmIKDGNvbS5hZG1pbi52MUIRQWRtaW5DcmVhdGVkUHJvdG9QAaICA0FYWKoCCEFkbWluLlYxygIIQWRtaW5cVjHiAhRBZG1pblxWMVxHUEJNZXRhZGF0YeoCCUFkbWluOjpWMWIGcHJvdG8z", [file_google_protobuf_descriptor]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Describes the message admin.v1.Payload.
|
|
16
|
+
* Use `create(PayloadSchema)` to create a new message.
|
|
17
|
+
*/
|
|
18
|
+
export const PayloadSchema = /*@__PURE__*/
|
|
19
|
+
messageDesc(file_admin_v1_admin_created, 0);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Describes the message admin.v1.AdminAccountCreated.
|
|
23
|
+
* Use `create(AdminAccountCreatedSchema)` to create a new message.
|
|
24
|
+
*/
|
|
25
|
+
export const AdminAccountCreatedSchema = /*@__PURE__*/
|
|
26
|
+
messageDesc(file_admin_v1_admin_created, 1);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @generated from extension: string fixed_value = 50001;
|
|
30
|
+
*/
|
|
31
|
+
export const fixed_value = /*@__PURE__*/
|
|
32
|
+
extDesc(file_admin_v1_admin_created, 0);
|
|
33
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './admin_created_pb';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './admin_created_pb';
|
package/gen/ts/index.d.ts
CHANGED
package/gen/ts/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@togatherlabs/event-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Shared Protobuf event schemas and generated code for toGather microservices",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./user/v1": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@commitlint/cli": "^20.1.0",
|
|
22
22
|
"@commitlint/config-conventional": "^20.0.0",
|
|
23
23
|
"@commitlint/cz-commitlint": "^20.1.0",
|
|
24
|
+
"@commitlint/types": "^20.0.0",
|
|
24
25
|
"commitizen": "^4.3.1",
|
|
25
26
|
"husky": "^9.1.7",
|
|
26
27
|
"inquirer": "^9.3.8",
|