@tamasha/kafka-schema-validation 1.0.0

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,67 @@
1
+ # @tamasha/kafka-schema-validation
2
+
3
+ Kafka topic schema validation framework with type-safe message definitions.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @tamasha/kafka-schema-validation
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Using the Default Schema Registry
14
+
15
+ ```typescript
16
+ import { TopicSchemaRegistry, DEFAULT_TOPIC_SCHEMAS } from '@tamasha/kafka-schema-validation';
17
+
18
+ const registry = new TopicSchemaRegistry(DEFAULT_TOPIC_SCHEMAS);
19
+
20
+ // Validate a message
21
+ const payload = registry.validateMessage('user-events', messageValue, 'produce');
22
+ ```
23
+
24
+ ### Defining Custom Schemas
25
+
26
+ ```typescript
27
+ import { defineAction, defineTopic, defineTopicSchemas } from '@tamasha/kafka-schema-validation';
28
+
29
+ const mySchema = defineTopic({
30
+ actionField: 'action',
31
+ partitionField: 'userId',
32
+ actions: {
33
+ created: defineAction<{ action: 'created'; userId: string; }>({
34
+ fields: {
35
+ action: { type: 'string', literal: 'created' },
36
+ userId: { type: 'string' },
37
+ },
38
+ }),
39
+ },
40
+ });
41
+
42
+ const schemas = defineTopicSchemas({
43
+ 'my-topic': mySchema,
44
+ });
45
+ ```
46
+
47
+ ### Type-Safe Message Types
48
+
49
+ ```typescript
50
+ import type { UserEventMessage, OrderEventMessage } from '@tamasha/kafka-schema-validation';
51
+
52
+ function handleUserEvent(message: UserEventMessage) {
53
+ // TypeScript knows the exact shape of the message
54
+ }
55
+ ```
56
+
57
+ ## Available Topics
58
+
59
+ - `user-events` - User login/logout events
60
+ - `order-events` - Order created/fulfilled events
61
+ - `wallet` - Wallet deposit success/failed events
62
+ - `call` - Call start/ended events
63
+ - `audience.updates` - Audience entry/exit events
64
+
65
+ ## License
66
+
67
+ MIT
@@ -0,0 +1,20 @@
1
+ export declare const AUDIENCE_UPDATE_TOPIC: "audience.updates";
2
+ export declare const audienceUpdateSchema: import("./base").TopicSchema<{
3
+ entry: import("./base").ActionSchema<{
4
+ action: "entry";
5
+ user_id: string;
6
+ workspace_id: string;
7
+ timestamp: number;
8
+ audience_id: string;
9
+ properties?: object;
10
+ }>;
11
+ exit: import("./base").ActionSchema<{
12
+ action: "exit";
13
+ user_id: string;
14
+ workspace_id: string;
15
+ timestamp: number;
16
+ audience_id: string;
17
+ properties?: object;
18
+ }>;
19
+ }>;
20
+ //# sourceMappingURL=audienceEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audienceEvents.d.ts","sourceRoot":"","sources":["../src/audienceEvents.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,EAAG,kBAA2B,CAAC;AAEjE,eAAO,MAAM,oBAAoB;;gBAKb,OAAO;iBACN,MAAM;sBACD,MAAM;mBACT,MAAM;qBACJ,MAAM;qBACN,MAAM;;;gBAYX,MAAM;iBACL,MAAM;sBACD,MAAM;mBACT,MAAM;qBACJ,MAAM;qBACN,MAAM;;EAY7B,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.audienceUpdateSchema = exports.AUDIENCE_UPDATE_TOPIC = void 0;
4
+ const base_1 = require("./base");
5
+ exports.AUDIENCE_UPDATE_TOPIC = "audience.updates";
6
+ exports.audienceUpdateSchema = (0, base_1.defineTopic)({
7
+ actionField: "action",
8
+ partitionField: "user_id",
9
+ actions: {
10
+ entry: (0, base_1.defineAction)({
11
+ fields: {
12
+ "action": { type: "string", literal: 'entry' },
13
+ "user_id": { type: "string" },
14
+ "workspace_id": { type: "string" },
15
+ "timestamp": { type: "number" },
16
+ "audience_id": { type: "string" },
17
+ "properties": { type: "object", optional: true }
18
+ },
19
+ }),
20
+ exit: (0, base_1.defineAction)({
21
+ fields: {
22
+ "action": { type: "string", literal: 'exit' },
23
+ "user_id": { type: "string" },
24
+ "workspace_id": { type: "string" },
25
+ "timestamp": { type: "number" },
26
+ "audience_id": { type: "string" },
27
+ "properties": { type: "object", optional: true }
28
+ },
29
+ })
30
+ },
31
+ });
32
+ //# sourceMappingURL=audienceEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audienceEvents.js","sourceRoot":"","sources":["../src/audienceEvents.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAEtC,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEpD,QAAA,oBAAoB,GAAG,IAAA,kBAAW,EAAC;IAC5C,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE;QACL,KAAK,EAAE,IAAA,mBAAY,EAOhB;YACC,MAAM,EAAE;gBACJ,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE;gBAC9C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC7B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAClC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC/B,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;aACnD;SACJ,CAAC;QACF,IAAI,EAAE,IAAA,mBAAY,EAOf;YACC,MAAM,EAAE;gBACJ,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;gBAC7C,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC7B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAClC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC/B,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACjC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;aACnD;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
package/dist/base.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ export type PrimitiveType = "string" | "number" | "boolean" | "object" | "array" | "null" | "enum";
2
+ export interface FieldRule {
3
+ readonly type: PrimitiveType | readonly PrimitiveType[];
4
+ readonly optional?: boolean;
5
+ readonly literal?: string | number | boolean | null;
6
+ readonly fields?: Readonly<Record<string, FieldRule>>;
7
+ readonly enumValues?: readonly (string | number)[];
8
+ }
9
+ interface ActionSchemaRuntime {
10
+ readonly fields: Readonly<Record<string, FieldRule>>;
11
+ }
12
+ export interface ActionSchema<Payload> extends ActionSchemaRuntime {
13
+ readonly __payload?: (payload: Payload) => Payload;
14
+ }
15
+ export interface TopicSchema<Actions extends Record<string, ActionSchema<any>> = Record<string, ActionSchema<any>>> {
16
+ readonly actionField?: string;
17
+ readonly partitionField?: string;
18
+ readonly actions: Actions;
19
+ }
20
+ export type TopicSchemas = Record<string, TopicSchema<any>>;
21
+ export declare const defineAction: <Payload>(schema: ActionSchemaRuntime) => ActionSchema<Payload>;
22
+ export declare const defineTopic: <Actions extends Record<string, ActionSchema<any>>>(schema: TopicSchema<Actions>) => TopicSchema<Actions>;
23
+ export declare const defineTopicSchemas: <Schemas extends TopicSchemas>(schemas: Schemas) => Schemas;
24
+ export declare class TopicSchemaRegistry {
25
+ private readonly schemas;
26
+ constructor(initial?: TopicSchemas);
27
+ register(topic: string, schema: TopicSchema<any>): void;
28
+ get(topic: string): TopicSchema<any> | undefined;
29
+ validateMessage(topic: string, rawValue: unknown, context: "produce" | "consume"): Record<string, unknown>;
30
+ getPartitionKey(topic: string, payload: Record<string, unknown>): string | undefined;
31
+ private parsePayload;
32
+ private validateFields;
33
+ }
34
+ export type ActionPayload<Schema extends ActionSchema<any>> = Schema extends ActionSchema<infer Payload> ? Payload : never;
35
+ export type TopicActionPayloadMap<Schema extends TopicSchema<any>> = {
36
+ [Action in keyof Schema["actions"]]: ActionPayload<Schema["actions"][Action]>;
37
+ };
38
+ export type TopicMessage<Schema extends TopicSchema<any>> = TopicActionPayloadMap<Schema>[keyof Schema["actions"]];
39
+ export type TopicMessageMap<Schemas extends TopicSchemas> = {
40
+ [Topic in keyof Schemas]: TopicMessage<Schemas[Topic]>;
41
+ };
42
+ export {};
43
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACnB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AAEb,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,aAAa,EAAE,CAAC;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CACtD;AAED,UAAU,mBAAmB;IACzB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACxD;AAED,MAAM,WAAW,YAAY,CAAC,OAAO,CAAE,SAAQ,mBAAmB;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CACtD;AAED,MAAM,WAAW,WAAW,CACxB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,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DzB;AAkDD,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS,YAAY,CAAC,GAAG,CAAC,IAAI,MAAM,SAAS,YAAY,CAAC,MAAM,OAAO,CAAC,GAClG,OAAO,GACP,KAAK,CAAC;AAEZ,MAAM,MAAM,qBAAqB,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,IAAI;KAChE,MAAM,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;CAChF,CAAC;AAEF,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AAEnH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,YAAY,IAAI;KACvD,KAAK,IAAI,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CACzD,CAAC"}
package/dist/base.js ADDED
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TopicSchemaRegistry = exports.defineTopicSchemas = exports.defineTopic = exports.defineAction = void 0;
4
+ const defineAction = (schema) => schema;
5
+ exports.defineAction = defineAction;
6
+ const defineTopic = (schema) => schema;
7
+ exports.defineTopic = defineTopic;
8
+ const defineTopicSchemas = (schemas) => schemas;
9
+ exports.defineTopicSchemas = defineTopicSchemas;
10
+ class TopicSchemaRegistry {
11
+ constructor(initial) {
12
+ this.schemas = new Map();
13
+ if (initial) {
14
+ for (const [topic, schema] of Object.entries(initial)) {
15
+ this.register(topic, schema);
16
+ }
17
+ }
18
+ }
19
+ register(topic, schema) {
20
+ if (!topic)
21
+ throw new Error("[TopicSchemaRegistry] topic name is required.");
22
+ if (!schema || typeof schema !== "object") {
23
+ throw new Error("[TopicSchemaRegistry] schema must be an object.");
24
+ }
25
+ if (!schema.actions || Object.keys(schema.actions).length === 0) {
26
+ throw new Error("[TopicSchemaRegistry] schema.actions must include at least one action validator.");
27
+ }
28
+ this.schemas.set(topic, schema);
29
+ }
30
+ get(topic) {
31
+ return this.schemas.get(topic);
32
+ }
33
+ validateMessage(topic, rawValue, context) {
34
+ const schema = this.schemas.get(topic);
35
+ if (!schema) {
36
+ return this.parsePayload(rawValue, topic, context);
37
+ }
38
+ const payload = this.parsePayload(rawValue, topic, context);
39
+ const actionField = schema.actionField ?? "action";
40
+ const actionValue = resolvePath(payload, actionField);
41
+ if (typeof actionValue !== "string" || !actionValue.length) {
42
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': ` +
43
+ `action field '${actionField}' must resolve to a non-empty string.`);
44
+ }
45
+ const actionSchema = schema.actions[actionValue];
46
+ if (!actionSchema) {
47
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': ` +
48
+ `no schema registered for action '${actionValue}'.`);
49
+ }
50
+ this.validateFields(topic, actionValue, payload, actionSchema.fields, context);
51
+ return payload;
52
+ }
53
+ getPartitionKey(topic, payload) {
54
+ const schema = this.schemas.get(topic);
55
+ if (!schema?.partitionField)
56
+ return undefined;
57
+ const value = resolvePath(payload, schema.partitionField);
58
+ if (value === undefined || value === null || value === "") {
59
+ throw new Error(`[TopicSchemaRegistry] partition field '${schema.partitionField}' missing for topic '${topic}'.`);
60
+ }
61
+ return String(value);
62
+ }
63
+ parsePayload(rawValue, topic, context) {
64
+ if (rawValue === null || rawValue === undefined) {
65
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': message value is empty.`);
66
+ }
67
+ if (isRecord(rawValue)) {
68
+ return rawValue;
69
+ }
70
+ const text = typeof rawValue === "string"
71
+ ? rawValue
72
+ : Buffer.isBuffer(rawValue)
73
+ ? rawValue.toString("utf-8")
74
+ : undefined;
75
+ if (text === undefined) {
76
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': ` +
77
+ "message value must be string, Buffer, or object.");
78
+ }
79
+ const trimmed = text.trim();
80
+ if (!trimmed.length) {
81
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': message value is empty.`);
82
+ }
83
+ let parsed;
84
+ try {
85
+ parsed = JSON.parse(trimmed);
86
+ }
87
+ catch (err) {
88
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': ` +
89
+ `invalid JSON (${formatError(err)}).`);
90
+ }
91
+ if (!isRecord(parsed)) {
92
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}': payload must be a JSON object.`);
93
+ }
94
+ return parsed;
95
+ }
96
+ validateFields(topic, action, payload, fields, context) {
97
+ for (const [path, rule] of Object.entries(fields)) {
98
+ const value = resolvePath(payload, path);
99
+ if (value === undefined || value === null) {
100
+ if (!rule.optional) {
101
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}' (action '${action}'): ` +
102
+ `missing required field '${path}'.`);
103
+ }
104
+ continue;
105
+ }
106
+ const typeDefinition = rule.type;
107
+ const arrayType = isPrimitiveTypeArray(typeDefinition);
108
+ const validType = arrayType
109
+ ? typeDefinition.some((t) => typeMatches(value, t))
110
+ : typeMatches(value, typeDefinition);
111
+ if (!validType) {
112
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}' (action '${action}'): ` +
113
+ `field '${path}' must match type '${String(rule.type)}'.`);
114
+ }
115
+ const isEnumType = arrayType ? typeDefinition.includes("enum") : typeDefinition === "enum";
116
+ if (isEnumType) {
117
+ if (!rule.enumValues?.length) {
118
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}' (action '${action}'): ` +
119
+ `field '${path}' with type 'enum' must define 'enumValues'.`);
120
+ }
121
+ if (!rule.enumValues.includes(value)) {
122
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}' (action '${action}'): ` +
123
+ `field '${path}' must be one of [${rule.enumValues.join(", ")}], got '${String(value)}'.`);
124
+ }
125
+ }
126
+ const isObjectType = arrayType ? typeDefinition.includes("object") : typeDefinition === "object";
127
+ if (isObjectType && rule.fields && isRecord(value)) {
128
+ this.validateFields(topic, action, value, rule.fields, context);
129
+ }
130
+ if (rule.literal !== undefined && value !== rule.literal) {
131
+ throw new Error(`[TopicSchemaRegistry] ${context} validation failed for topic '${topic}' (action '${action}'): ` +
132
+ `field '${path}' must equal '${String(rule.literal)}'.`);
133
+ }
134
+ }
135
+ }
136
+ }
137
+ exports.TopicSchemaRegistry = TopicSchemaRegistry;
138
+ function isRecord(value) {
139
+ if (typeof value !== "object" || value === null)
140
+ return false;
141
+ if (Array.isArray(value))
142
+ return false;
143
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(value))
144
+ return false;
145
+ return true;
146
+ }
147
+ function resolvePath(root, path) {
148
+ const segments = path.split(".").filter(Boolean);
149
+ if (segments.length === 0)
150
+ return root;
151
+ return segments.reduce((current, segment) => {
152
+ if (current === undefined || current === null)
153
+ return undefined;
154
+ if (!isRecord(current))
155
+ return undefined;
156
+ return current[segment];
157
+ }, root);
158
+ }
159
+ function typeMatches(value, type) {
160
+ switch (type) {
161
+ case "string":
162
+ return typeof value === "string";
163
+ case "number":
164
+ return typeof value === "number" && Number.isFinite(value);
165
+ case "boolean":
166
+ return typeof value === "boolean";
167
+ case "object":
168
+ return isRecord(value);
169
+ case "array":
170
+ return Array.isArray(value);
171
+ case "enum":
172
+ return typeof value === "string" || typeof value === "number";
173
+ case "null":
174
+ return value === null;
175
+ default:
176
+ return false;
177
+ }
178
+ }
179
+ function formatError(err) {
180
+ return err instanceof Error ? err.message : String(err);
181
+ }
182
+ function isPrimitiveTypeArray(type) {
183
+ return Array.isArray(type);
184
+ }
185
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":";;;AAmCO,MAAM,YAAY,GAAG,CAAU,MAA2B,E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C,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/D,KAAK,SAAS;YACV,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;QACtC,KAAK,QAAQ;YACT,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,OAAO;YACR,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChC,KAAK,MAAM;YACP,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;QAClE,KAAK,MAAM;YACP,OAAO,KAAK,KAAK,IAAI,CAAC;QAC1B;YACI,OAAO,KAAK,CAAC;IACrB,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,GAAY;IAC7B,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,oBAAoB,CACzB,IAA8C;IAE9C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,34 @@
1
+ export declare const CALL_EVENT_TOPIC: "call";
2
+ export declare const callEventsSchema: import("./base").TopicSchema<{
3
+ call_ended: import("./base").ActionSchema<{
4
+ payload: {
5
+ action: "call_ended";
6
+ user_id: number;
7
+ workspace_id: number;
8
+ timestamp: number;
9
+ event_id: string;
10
+ properties: {
11
+ session_duration: number;
12
+ reason: "LOW_BALANCE" | "HOST_LEFT" | "USER_LEFT";
13
+ session_id: string;
14
+ host_player_id: number;
15
+ accepted_player_id: number;
16
+ };
17
+ };
18
+ }>;
19
+ call_start: import("./base").ActionSchema<{
20
+ payload: {
21
+ action: "call_start";
22
+ user_id: number;
23
+ workspace_id: number;
24
+ timestamp: number;
25
+ event_id: string;
26
+ properties: {
27
+ host_player_id: number;
28
+ accepted_player_id: number;
29
+ session_id: string;
30
+ };
31
+ };
32
+ }>;
33
+ }>;
34
+ //# sourceMappingURL=callEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callEvents.d.ts","sourceRoot":"","sources":["../src/callEvents.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,EAAG,MAAe,CAAC;AAEhD,eAAO,MAAM,gBAAgB;;iBAKR;YACL,MAAM,EAAE,YAAY,CAAC;YACrB,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE;gBACR,gBAAgB,EAAE,MAAM,CAAC;gBACzB,MAAM,EAAE,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;gBAClD,UAAU,EAAE,MAAM,CAAC;gBACnB,cAAc,EAAE,MAAM,CAAC;gBACvB,kBAAkB,EAAE,MAAM,CAAC;aAC9B,CAAC;SACL;;;iBAwBQ;YACL,MAAM,EAAE,YAAY,CAAC;YACrB,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE;gBACR,cAAc,EAAE,MAAM,CAAC;gBACvB,kBAAkB,EAAE,MAAM,CAAC;gBAC3B,UAAU,EAAE,MAAM,CAAC;aACtB,CAAC;SACL;;EAmBX,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callEventsSchema = exports.CALL_EVENT_TOPIC = void 0;
4
+ const base_1 = require("./base");
5
+ exports.CALL_EVENT_TOPIC = "call";
6
+ exports.callEventsSchema = (0, base_1.defineTopic)({
7
+ actionField: "payload.action",
8
+ partitionField: "payload.user_id",
9
+ actions: {
10
+ call_ended: (0, base_1.defineAction)({
11
+ fields: {
12
+ "payload.action": { type: "string", literal: "call_ended" },
13
+ "payload.user_id": { type: "number" },
14
+ "payload.workspace_id": { type: "number" },
15
+ "payload.timestamp": { type: "number" },
16
+ "payload.event_id": { type: "string" },
17
+ "payload.properties": {
18
+ type: "object",
19
+ fields: {
20
+ session_duration: { type: "number" },
21
+ reason: {
22
+ type: "enum",
23
+ enumValues: ["LOW_BALANCE", "HOST_LEFT", "USER_LEFT"],
24
+ },
25
+ session_id: { type: "string" },
26
+ host_player_id: { type: "number" },
27
+ accepted_player_id: { type: "number" },
28
+ },
29
+ },
30
+ },
31
+ }),
32
+ call_start: (0, base_1.defineAction)({
33
+ fields: {
34
+ "payload.action": { type: "string", literal: "call_start" },
35
+ "payload.user_id": { type: "number" },
36
+ "payload.workspace_id": { type: "number" },
37
+ "payload.timestamp": { type: "number" },
38
+ "payload.event_id": { type: "string" },
39
+ "payload.properties": {
40
+ type: "object",
41
+ fields: {
42
+ host_player_id: { type: "number" },
43
+ accepted_player_id: { type: "number" },
44
+ session_id: { type: "string" },
45
+ },
46
+ },
47
+ },
48
+ }),
49
+ },
50
+ });
51
+ //# sourceMappingURL=callEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callEvents.js","sourceRoot":"","sources":["../src/callEvents.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAEtC,QAAA,gBAAgB,GAAG,MAAe,CAAC;AAEnC,QAAA,gBAAgB,GAAG,IAAA,kBAAW,EAAC;IACxC,WAAW,EAAE,gBAAgB;IAC7B,cAAc,EAAE,iBAAiB;IACjC,OAAO,EAAE;QACL,UAAU,EAAE,IAAA,mBAAY,EAerB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC3D,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,sBAAsB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1C,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACtC,oBAAoB,EAAE;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACpC,MAAM,EAAE;4BACJ,IAAI,EAAE,MAAM;4BACZ,UAAU,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,WAAW,CAAC;yBACxD;wBACD,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAC9B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAClC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBACzC;iBACJ;aACJ;SACJ,CAAC;QACF,UAAU,EAAE,IAAA,mBAAY,EAarB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;gBAC3D,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,sBAAsB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1C,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACtC,oBAAoB,EAAE;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACJ,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAClC,kBAAkB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACtC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;qBACjC;iBACJ;aACJ;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { TopicActionPayloadMap, TopicMessage, TopicMessageMap } from "./base";
2
+ import { userEventsSchema } from "./userEvents";
3
+ import { orderEventsSchema } from "./orderEvents";
4
+ import { walletEventsSchema } from "./walletEvents";
5
+ import { callEventsSchema } from "./callEvents";
6
+ import { audienceUpdateSchema } from "./audienceEvents";
7
+ export { defineAction, defineTopic, defineTopicSchemas, TopicSchemaRegistry, type PrimitiveType, type FieldRule, type ActionSchema, type TopicSchema, type TopicSchemas, type ActionPayload, type TopicActionPayloadMap, type TopicMessage, type TopicMessageMap, } from "./base";
8
+ export { USER_EVENTS_TOPIC, userEventsSchema } from "./userEvents";
9
+ export { ORDER_EVENTS_TOPIC, orderEventsSchema } from "./orderEvents";
10
+ export { WALLET_EVENT_TOPIC, walletEventsSchema } from "./walletEvents";
11
+ export { CALL_EVENT_TOPIC, callEventsSchema } from "./callEvents";
12
+ export { AUDIENCE_UPDATE_TOPIC, audienceUpdateSchema } from "./audienceEvents";
13
+ export declare const DEFAULT_TOPIC_SCHEMAS: {
14
+ readonly "user-events": import("./base").TopicSchema<{
15
+ login: import("./base").ActionSchema<{
16
+ payload: {
17
+ action: "login";
18
+ userId: string;
19
+ timestamp: number;
20
+ service: string;
21
+ sessionId?: string;
22
+ };
23
+ }>;
24
+ logout: import("./base").ActionSchema<{
25
+ payload: {
26
+ action: "logout";
27
+ userId: string;
28
+ timestamp: number;
29
+ service: string;
30
+ reason?: string;
31
+ };
32
+ }>;
33
+ }>;
34
+ readonly "order-events": import("./base").TopicSchema<{
35
+ created: import("./base").ActionSchema<{
36
+ payload: {
37
+ status: "created";
38
+ orderId: string;
39
+ timestamp: number;
40
+ service: string;
41
+ amount: number;
42
+ };
43
+ }>;
44
+ fulfilled: import("./base").ActionSchema<{
45
+ payload: {
46
+ status: "fulfilled";
47
+ orderId: string;
48
+ timestamp: number;
49
+ service: string;
50
+ amount?: number;
51
+ shipmentId?: string;
52
+ };
53
+ }>;
54
+ }>;
55
+ readonly wallet: import("./base").TopicSchema<{
56
+ deposit_success: import("./base").ActionSchema<{
57
+ payload: {
58
+ action: "deposit_success";
59
+ user_id: number;
60
+ workspace_id: number;
61
+ timestamp: number;
62
+ event_id: string;
63
+ properties: {
64
+ amount: number;
65
+ currency?: string;
66
+ transaction_id: string;
67
+ gateway: "Applepay" | "Gplay" | "Razorpay" | "Juspay" | "Cashfree" | "Pay3" | "Paytm";
68
+ is_first_deposit: boolean;
69
+ };
70
+ };
71
+ }>;
72
+ deposit_failed: import("./base").ActionSchema<{
73
+ payload: {
74
+ action: "deposit_failed";
75
+ user_id: number;
76
+ workspace_id: number;
77
+ timestamp: number;
78
+ event_id: string;
79
+ properties: {
80
+ amount: number;
81
+ currency?: string;
82
+ transaction_id: string;
83
+ gateway: "Applepay" | "Gplay" | "Razorpay" | "Juspay" | "Cashfree" | "Pay3" | "Paytm";
84
+ is_first_deposit: boolean;
85
+ };
86
+ };
87
+ }>;
88
+ }>;
89
+ readonly call: import("./base").TopicSchema<{
90
+ call_ended: import("./base").ActionSchema<{
91
+ payload: {
92
+ action: "call_ended";
93
+ user_id: number;
94
+ workspace_id: number;
95
+ timestamp: number;
96
+ event_id: string;
97
+ properties: {
98
+ session_duration: number;
99
+ reason: "LOW_BALANCE" | "HOST_LEFT" | "USER_LEFT";
100
+ session_id: string;
101
+ host_player_id: number;
102
+ accepted_player_id: number;
103
+ };
104
+ };
105
+ }>;
106
+ call_start: import("./base").ActionSchema<{
107
+ payload: {
108
+ action: "call_start";
109
+ user_id: number;
110
+ workspace_id: number;
111
+ timestamp: number;
112
+ event_id: string;
113
+ properties: {
114
+ host_player_id: number;
115
+ accepted_player_id: number;
116
+ session_id: string;
117
+ };
118
+ };
119
+ }>;
120
+ }>;
121
+ readonly "audience.updates": import("./base").TopicSchema<{
122
+ entry: import("./base").ActionSchema<{
123
+ action: "entry";
124
+ user_id: string;
125
+ workspace_id: string;
126
+ timestamp: number;
127
+ audience_id: string;
128
+ properties?: object;
129
+ }>;
130
+ exit: import("./base").ActionSchema<{
131
+ action: "exit";
132
+ user_id: string;
133
+ workspace_id: string;
134
+ timestamp: number;
135
+ audience_id: string;
136
+ properties?: object;
137
+ }>;
138
+ }>;
139
+ };
140
+ export type DefaultTopicSchemas = typeof DEFAULT_TOPIC_SCHEMAS;
141
+ export type UserEventPayloads = TopicActionPayloadMap<typeof userEventsSchema>;
142
+ export type UserEventMessage = TopicMessage<typeof userEventsSchema>;
143
+ export type OrderEventPayloads = TopicActionPayloadMap<typeof orderEventsSchema>;
144
+ export type OrderEventMessage = TopicMessage<typeof orderEventsSchema>;
145
+ export type WalletEventPayloads = TopicActionPayloadMap<typeof walletEventsSchema>;
146
+ export type WalletEventMessage = TopicMessage<typeof walletEventsSchema>;
147
+ export type CallEventPayloads = TopicActionPayloadMap<typeof callEventsSchema>;
148
+ export type CallEventMessage = TopicMessage<typeof callEventsSchema>;
149
+ export type AudienceEventPayloads = TopicActionPayloadMap<typeof audienceUpdateSchema>;
150
+ export type AudienceEventMessage = TopicMessage<typeof audienceUpdateSchema>;
151
+ export type DefaultTopicActionPayloads<Topic extends keyof DefaultTopicSchemas> = TopicActionPayloadMap<DefaultTopicSchemas[Topic]>;
152
+ export type DefaultTopicMessageMap = TopicMessageMap<DefaultTopicSchemas>;
153
+ export type KafkaEventMessage = DefaultTopicMessageMap[keyof DefaultTopicMessageMap];
154
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,qBAAqB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAClG,OAAO,EAAqB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAsB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAoB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAyB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,EACH,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,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C,CAAC;AAEzE,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACvF,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAG7E,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,MAAM,mBAAmB,IAAI,qBAAqB,CACnG,mBAAmB,CAAC,KAAK,CAAC,CAC7B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,MAAM,sBAAsB,CAAC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TOPIC_SCHEMAS = exports.audienceUpdateSchema = exports.AUDIENCE_UPDATE_TOPIC = exports.callEventsSchema = exports.CALL_EVENT_TOPIC = exports.walletEventsSchema = exports.WALLET_EVENT_TOPIC = exports.orderEventsSchema = exports.ORDER_EVENTS_TOPIC = exports.userEventsSchema = exports.USER_EVENTS_TOPIC = exports.TopicSchemaRegistry = exports.defineTopicSchemas = exports.defineTopic = exports.defineAction = void 0;
4
+ const base_1 = require("./base");
5
+ const userEvents_1 = require("./userEvents");
6
+ const orderEvents_1 = require("./orderEvents");
7
+ const walletEvents_1 = require("./walletEvents");
8
+ const callEvents_1 = require("./callEvents");
9
+ const audienceEvents_1 = require("./audienceEvents");
10
+ // Re-export base types and classes
11
+ var base_2 = require("./base");
12
+ Object.defineProperty(exports, "defineAction", { enumerable: true, get: function () { return base_2.defineAction; } });
13
+ Object.defineProperty(exports, "defineTopic", { enumerable: true, get: function () { return base_2.defineTopic; } });
14
+ Object.defineProperty(exports, "defineTopicSchemas", { enumerable: true, get: function () { return base_2.defineTopicSchemas; } });
15
+ Object.defineProperty(exports, "TopicSchemaRegistry", { enumerable: true, get: function () { return base_2.TopicSchemaRegistry; } });
16
+ // Re-export topic constants and schemas
17
+ var userEvents_2 = require("./userEvents");
18
+ Object.defineProperty(exports, "USER_EVENTS_TOPIC", { enumerable: true, get: function () { return userEvents_2.USER_EVENTS_TOPIC; } });
19
+ Object.defineProperty(exports, "userEventsSchema", { enumerable: true, get: function () { return userEvents_2.userEventsSchema; } });
20
+ var orderEvents_2 = require("./orderEvents");
21
+ Object.defineProperty(exports, "ORDER_EVENTS_TOPIC", { enumerable: true, get: function () { return orderEvents_2.ORDER_EVENTS_TOPIC; } });
22
+ Object.defineProperty(exports, "orderEventsSchema", { enumerable: true, get: function () { return orderEvents_2.orderEventsSchema; } });
23
+ var walletEvents_2 = require("./walletEvents");
24
+ Object.defineProperty(exports, "WALLET_EVENT_TOPIC", { enumerable: true, get: function () { return walletEvents_2.WALLET_EVENT_TOPIC; } });
25
+ Object.defineProperty(exports, "walletEventsSchema", { enumerable: true, get: function () { return walletEvents_2.walletEventsSchema; } });
26
+ var callEvents_2 = require("./callEvents");
27
+ Object.defineProperty(exports, "CALL_EVENT_TOPIC", { enumerable: true, get: function () { return callEvents_2.CALL_EVENT_TOPIC; } });
28
+ Object.defineProperty(exports, "callEventsSchema", { enumerable: true, get: function () { return callEvents_2.callEventsSchema; } });
29
+ var audienceEvents_2 = require("./audienceEvents");
30
+ Object.defineProperty(exports, "AUDIENCE_UPDATE_TOPIC", { enumerable: true, get: function () { return audienceEvents_2.AUDIENCE_UPDATE_TOPIC; } });
31
+ Object.defineProperty(exports, "audienceUpdateSchema", { enumerable: true, get: function () { return audienceEvents_2.audienceUpdateSchema; } });
32
+ // Default topic schemas registry
33
+ exports.DEFAULT_TOPIC_SCHEMAS = (0, base_1.defineTopicSchemas)({
34
+ [userEvents_1.USER_EVENTS_TOPIC]: userEvents_1.userEventsSchema,
35
+ [orderEvents_1.ORDER_EVENTS_TOPIC]: orderEvents_1.orderEventsSchema,
36
+ [walletEvents_1.WALLET_EVENT_TOPIC]: walletEvents_1.walletEventsSchema,
37
+ [callEvents_1.CALL_EVENT_TOPIC]: callEvents_1.callEventsSchema,
38
+ [audienceEvents_1.AUDIENCE_UPDATE_TOPIC]: audienceEvents_1.audienceUpdateSchema,
39
+ });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAkG;AAClG,6CAAmE;AACnE,+CAAsE;AACtE,iDAAwE;AACxE,6CAAkE;AAClE,qDAA+E;AAE/E,mCAAmC;AACnC,+BAcgB;AAbZ,oGAAA,YAAY,OAAA;AACZ,mGAAA,WAAW,OAAA;AACX,0GAAA,kBAAkB,OAAA;AAClB,2GAAA,mBAAmB,OAAA;AAYvB,wCAAwC;AACxC,2CAAmE;AAA1D,+GAAA,iBAAiB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAC5C,6CAAsE;AAA7D,iHAAA,kBAAkB,OAAA;AAAE,gHAAA,iBAAiB,OAAA;AAC9C,+CAAwE;AAA/D,kHAAA,kBAAkB,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAC/C,2CAAkE;AAAzD,8GAAA,gBAAgB,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAC3C,mDAA+E;AAAtE,uHAAA,qBAAqB,OAAA;AAAE,sHAAA,oBAAoB,OAAA;AAEpD,iCAAiC;AACpB,QAAA,qBAAqB,GAAG,IAAA,yBAAkB,EAAC;IACpD,CAAC,8BAAiB,CAAC,EAAE,6BAAgB;IACrC,CAAC,gCAAkB,CAAC,EAAE,+BAAiB;IACvC,CAAC,iCAAkB,CAAC,EAAE,iCAAkB;IACxC,CAAC,6BAAgB,CAAC,EAAE,6BAAgB;IACpC,CAAC,sCAAqB,CAAC,EAAE,qCAAoB;CACvC,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const ORDER_EVENTS_TOPIC: "order-events";
2
+ export declare const orderEventsSchema: import("./base").TopicSchema<{
3
+ created: import("./base").ActionSchema<{
4
+ payload: {
5
+ status: "created";
6
+ orderId: string;
7
+ timestamp: number;
8
+ service: string;
9
+ amount: number;
10
+ };
11
+ }>;
12
+ fulfilled: import("./base").ActionSchema<{
13
+ payload: {
14
+ status: "fulfilled";
15
+ orderId: string;
16
+ timestamp: number;
17
+ service: string;
18
+ amount?: number;
19
+ shipmentId?: string;
20
+ };
21
+ }>;
22
+ }>;
23
+ //# sourceMappingURL=orderEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderEvents.d.ts","sourceRoot":"","sources":["../src/orderEvents.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,EAAG,cAAuB,CAAC;AAE1D,eAAO,MAAM,iBAAiB;;iBAKT;YACL,MAAM,EAAE,SAAS,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,EAAE,MAAM,CAAC;SAClB;;;iBAWQ;YACL,MAAM,EAAE,WAAW,CAAC;YACpB,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,UAAU,CAAC,EAAE,MAAM,CAAC;SACvB;;EAYX,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orderEventsSchema = exports.ORDER_EVENTS_TOPIC = void 0;
4
+ const base_1 = require("./base");
5
+ exports.ORDER_EVENTS_TOPIC = "order-events";
6
+ exports.orderEventsSchema = (0, base_1.defineTopic)({
7
+ actionField: "payload.status",
8
+ partitionField: "payload.orderId",
9
+ actions: {
10
+ created: (0, base_1.defineAction)({
11
+ fields: {
12
+ "payload.status": { type: "string", literal: "created" },
13
+ "payload.orderId": { type: "string" },
14
+ "payload.timestamp": { type: "number" },
15
+ "payload.service": { type: "string" },
16
+ "payload.amount": { type: "number" },
17
+ },
18
+ }),
19
+ fulfilled: (0, base_1.defineAction)({
20
+ fields: {
21
+ "payload.status": { type: "string", literal: "fulfilled" },
22
+ "payload.orderId": { type: "string" },
23
+ "payload.timestamp": { type: "number" },
24
+ "payload.service": { type: "string" },
25
+ "payload.amount": { type: "number", optional: true },
26
+ "payload.shipmentId": { type: "string", optional: true },
27
+ },
28
+ }),
29
+ },
30
+ });
31
+ //# sourceMappingURL=orderEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orderEvents.js","sourceRoot":"","sources":["../src/orderEvents.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAEtC,QAAA,kBAAkB,GAAG,cAAuB,CAAC;AAE7C,QAAA,iBAAiB,GAAG,IAAA,kBAAW,EAAC;IACzC,WAAW,EAAE,gBAAgB;IAC7B,cAAc,EAAE,iBAAiB;IACjC,OAAO,EAAE;QACL,OAAO,EAAE,IAAA,mBAAY,EAQlB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE;gBACxD,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aACvC;SACJ,CAAC;QACF,SAAS,EAAE,IAAA,mBAAY,EASpB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE;gBAC1D,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACpD,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC3D;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ export declare const USER_EVENTS_TOPIC: "user-events";
2
+ export declare const userEventsSchema: import("./base").TopicSchema<{
3
+ login: import("./base").ActionSchema<{
4
+ payload: {
5
+ action: "login";
6
+ userId: string;
7
+ timestamp: number;
8
+ service: string;
9
+ sessionId?: string;
10
+ };
11
+ }>;
12
+ logout: import("./base").ActionSchema<{
13
+ payload: {
14
+ action: "logout";
15
+ userId: string;
16
+ timestamp: number;
17
+ service: string;
18
+ reason?: string;
19
+ };
20
+ }>;
21
+ }>;
22
+ //# sourceMappingURL=userEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userEvents.d.ts","sourceRoot":"","sources":["../src/userEvents.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,EAAG,aAAsB,CAAC;AAExD,eAAO,MAAM,gBAAgB;;iBAKR;YACL,MAAM,EAAE,OAAO,CAAC;YAChB,MAAM,EAAE,MAAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,SAAS,CAAC,EAAE,MAAM,CAAC;SACtB;;;iBAWQ;YACL,MAAM,EAAE,QAAQ,CAAC;YACjB,MAAM,EAAE,MAAM,CAAC;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,OAAO,EAAE,MAAM,CAAC;YAChB,MAAM,CAAC,EAAE,MAAM,CAAC;SACnB;;EAWX,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.userEventsSchema = exports.USER_EVENTS_TOPIC = void 0;
4
+ const base_1 = require("./base");
5
+ exports.USER_EVENTS_TOPIC = "user-events";
6
+ exports.userEventsSchema = (0, base_1.defineTopic)({
7
+ actionField: "payload.action",
8
+ partitionField: "payload.userId",
9
+ actions: {
10
+ login: (0, base_1.defineAction)({
11
+ fields: {
12
+ "payload.action": { type: "string", literal: "login" },
13
+ "payload.userId": { type: "string" },
14
+ "payload.timestamp": { type: "number" },
15
+ "payload.service": { type: "string" },
16
+ "payload.sessionId": { type: "string", optional: true },
17
+ },
18
+ }),
19
+ logout: (0, base_1.defineAction)({
20
+ fields: {
21
+ "payload.action": { type: "string", literal: "logout" },
22
+ "payload.userId": { type: "string" },
23
+ "payload.timestamp": { type: "number" },
24
+ "payload.service": { type: "string" },
25
+ "payload.reason": { type: "string", optional: true },
26
+ },
27
+ }),
28
+ },
29
+ });
30
+ //# sourceMappingURL=userEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userEvents.js","sourceRoot":"","sources":["../src/userEvents.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAEtC,QAAA,iBAAiB,GAAG,aAAsB,CAAC;AAE3C,QAAA,gBAAgB,GAAG,IAAA,kBAAW,EAAC;IACxC,WAAW,EAAE,gBAAgB;IAC7B,cAAc,EAAE,gBAAgB;IAChC,OAAO,EAAE;QACL,KAAK,EAAE,IAAA,mBAAY,EAQhB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE;gBACtD,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACpC,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC1D;SACJ,CAAC;QACF,MAAM,EAAE,IAAA,mBAAY,EAQjB;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE;gBACvD,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACpC,mBAAmB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACrC,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;aACvD;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ export declare const WALLET_EVENT_TOPIC: "wallet";
2
+ export declare const walletEventsSchema: import("./base").TopicSchema<{
3
+ deposit_success: import("./base").ActionSchema<{
4
+ payload: {
5
+ action: "deposit_success";
6
+ user_id: number;
7
+ workspace_id: number;
8
+ timestamp: number;
9
+ event_id: string;
10
+ properties: {
11
+ amount: number;
12
+ currency?: string;
13
+ transaction_id: string;
14
+ gateway: "Applepay" | "Gplay" | "Razorpay" | "Juspay" | "Cashfree" | "Pay3" | "Paytm";
15
+ is_first_deposit: boolean;
16
+ };
17
+ };
18
+ }>;
19
+ deposit_failed: import("./base").ActionSchema<{
20
+ payload: {
21
+ action: "deposit_failed";
22
+ user_id: number;
23
+ workspace_id: number;
24
+ timestamp: number;
25
+ event_id: string;
26
+ properties: {
27
+ amount: number;
28
+ currency?: string;
29
+ transaction_id: string;
30
+ gateway: "Applepay" | "Gplay" | "Razorpay" | "Juspay" | "Cashfree" | "Pay3" | "Paytm";
31
+ is_first_deposit: boolean;
32
+ };
33
+ };
34
+ }>;
35
+ }>;
36
+ //# sourceMappingURL=walletEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletEvents.d.ts","sourceRoot":"","sources":["../src/walletEvents.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,EAAG,QAAiB,CAAC;AAEpD,eAAO,MAAM,kBAAkB;;iBAKV;YACL,MAAM,EAAE,iBAAiB,CAAC;YAC1B,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC;gBACf,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAClB,cAAc,EAAE,MAAM,CAAC;gBACvB,OAAO,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;gBACtF,gBAAgB,EAAE,OAAO,CAAC;aAC7B,CAAC;SACL;;;iBAqBQ;YACL,MAAM,EAAE,gBAAgB,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC;YAChB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE;gBACR,MAAM,EAAE,MAAM,CAAC;gBACf,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAClB,cAAc,EAAE,MAAM,CAAC;gBACvB,OAAO,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;gBACtF,gBAAgB,EAAE,OAAO,CAAC;aAC7B,CAAC;SACL;;EAqBX,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walletEventsSchema = exports.WALLET_EVENT_TOPIC = void 0;
4
+ const base_1 = require("./base");
5
+ exports.WALLET_EVENT_TOPIC = "wallet";
6
+ exports.walletEventsSchema = (0, base_1.defineTopic)({
7
+ actionField: "payload.action",
8
+ partitionField: "payload.user_id",
9
+ actions: {
10
+ deposit_success: (0, base_1.defineAction)({
11
+ fields: {
12
+ "payload.action": { type: "string", literal: "deposit_success" },
13
+ "payload.user_id": { type: "number" },
14
+ "payload.workspace_id": { type: "number" },
15
+ "payload.timestamp": { type: "number" },
16
+ "payload.event_id": { type: "string" },
17
+ "payload.properties": {
18
+ type: "object",
19
+ fields: {
20
+ amount: { type: "number" },
21
+ currency: { type: "string", optional: true },
22
+ transaction_id: { type: "string" },
23
+ gateway: { type: "enum", enumValues: ["Applepay", "Gplay", "Razorpay", "Juspay", "Cashfree", "Pay3", "Paytm"] },
24
+ is_first_deposit: { type: "boolean" },
25
+ },
26
+ },
27
+ },
28
+ }),
29
+ deposit_failed: (0, base_1.defineAction)({
30
+ fields: {
31
+ "payload.action": { type: "string", literal: "deposit_failed" },
32
+ "payload.user_id": { type: "number" },
33
+ "payload.workspace_id": { type: "number" },
34
+ "payload.timestamp": { type: "number" },
35
+ "payload.event_id": { type: "string" },
36
+ "payload.properties": {
37
+ type: "object",
38
+ fields: {
39
+ amount: { type: "number" },
40
+ currency: { type: "string", optional: true },
41
+ transaction_id: { type: "string" },
42
+ gateway: { type: "enum", enumValues: ["Applepay", "Gplay", "Razorpay", "Juspay", "Cashfree", "Pay3", "Paytm"] },
43
+ is_first_deposit: { type: "boolean" },
44
+ },
45
+ },
46
+ },
47
+ }),
48
+ },
49
+ });
50
+ //# sourceMappingURL=walletEvents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletEvents.js","sourceRoot":"","sources":["../src/walletEvents.ts"],"names":[],"mappings":";;;AAAA,iCAAmD;AAEtC,QAAA,kBAAkB,GAAG,QAAiB,CAAC;AAEvC,QAAA,kBAAkB,GAAG,IAAA,kBAAW,EAAC;IAC1C,WAAW,EAAE,gBAAgB;IAC7B,cAAc,EAAE,iBAAiB;IACjC,OAAO,EAAE;QACL,eAAe,EAAE,IAAA,mBAAY,EAe1B;YACC,MAAM,EAAE;gBACJ,gBAAgB,EAAE,EAAE,IAAI,EAAE,Q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,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;wBAC5C,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBAClC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;wBAC/G,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;qBACxC;iBACJ;aACJ;SACJ,CAAC;KACL;CACJ,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@tamasha/kafka-schema-validation",
3
+ "version": "1.0.0",
4
+ "description": "Kafka topic schema validation framework with type-safe message definitions",
5
+ "keywords": [
6
+ "kafka",
7
+ "schema",
8
+ "validation",
9
+ "typescript"
10
+ ],
11
+ "homepage": "https://github.com/tamasha/tamasha-packages#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/tamasha/tamasha-packages/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/tamasha/tamasha-packages.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Tamasha Team",
21
+ "type": "commonjs",
22
+ "main": "dist/index.js",
23
+ "types": "dist/index.d.ts",
24
+ "files": [
25
+ "dist/**/*",
26
+ "README.md"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "clean": "rimraf dist",
31
+ "prepublishOnly": "npm run clean && npm run build"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.0.0",
35
+ "rimraf": "^5.0.0",
36
+ "typescript": "^5.0.0"
37
+ },
38
+ "engines": {
39
+ "node": ">=18.0.0"
40
+ }
41
+ }