@glowlabs-org/events-sdk 1.0.0 → 1.0.1

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
@@ -24,8 +24,8 @@ The following zones are currently available:
24
24
  | 1 | Clean Grid Project |
25
25
  | 2 | Coming Soon Zone |
26
26
 
27
- - Use `zoneId: 0` (with `zoneName: "All Zones"`) to emit to or listen to all zones.
28
- - The SDK types and runtime validation now officially support `zoneId: 0` and `zoneName: "All Zones"` everywhere (emitter, listener, event types).
27
+ - Use `zoneId: 0` (with `zoneName: "All Zones"`) to listen to all zones. **Emitters must be constructed with a specific zoneId (not 0).**
28
+ - The SDK types and runtime validation now officially support `zoneId: 0` and `zoneName: "All Zones"` everywhere for listeners, but not for emitters.
29
29
 
30
30
  ---
31
31
 
@@ -33,11 +33,13 @@ The following zones are currently available:
33
33
 
34
34
  Currently supported event types and versions:
35
35
 
36
- | Event Name | Version | Payload Type | Description |
37
- | ------------------ | ------- | ------------------------- | ----------------------------------- |
38
- | `audit.pushed` | 1 | `AuditPushedV1Payload` | Emitted when an audit is pushed |
39
- | `audit.slashed` | 1 | `AuditSlashedV1Payload` | Emitted when a farm is slashed |
40
- | `audit.pfees.paid` | 1 | `AuditPfeesPaidV1Payload` | Emitted when protocol fees are paid |
36
+ | Event Name | Version | Payload Type | Description |
37
+ | --------------------- | ------- | ----------------------------- | -------------------------------------- |
38
+ | `audit.pushed` | 1 | `AuditPushedV1Payload` | Emitted when an audit is pushed |
39
+ | `audit.slashed` | 1 | `AuditSlashedV1Payload` | Emitted when a farm is slashed |
40
+ | `audit.pfees.paid` | 1 | `AuditPfeesPaidV1Payload` | Paid (by applicationId) |
41
+ | `audit.pfees.paid` | 2 | `AuditPfeesPaidV2Payload` | Paid (by farmId) |
42
+ | `application.created` | 1 | `ApplicationCreatedV1Payload` | Emitted when an application is created |
41
43
 
42
44
  ---
43
45
 
@@ -72,10 +74,26 @@ export interface AuditSlashedV1Payload {
72
74
  - `farmId` must be a 32-byte hex string (e.g., `0x...`).
73
75
  - `slasher` must be a valid Ethereum address (0x...40 hex chars).
74
76
 
75
- ### `audit.pfees.paid` v1
77
+ ### `audit.pfees.paid` v1 (by applicationId)
76
78
 
77
79
  ```ts
78
80
  export interface AuditPfeesPaidV1Payload {
81
+ applicationId: string; // bytes32 hex string (0x...)
82
+ payer: string; // Ethereum address (0x...)
83
+ amount_12Decimals: string; // uint256 (decimal) − 12 implied decimals
84
+ }
85
+ ```
86
+
87
+ **Validation:**
88
+
89
+ - `applicationId` must be a 32-byte hex string (e.g., `0x...`).
90
+ - `payer` must be a valid Ethereum address (0x...40 hex chars).
91
+ - `amount_12Decimals` must be a decimal string representing an unsigned big integer (12 implied decimals).
92
+
93
+ ### `audit.pfees.paid` v2 (by farmId)
94
+
95
+ ```ts
96
+ export interface AuditPfeesPaidV2Payload {
79
97
  farmId: string; // bytes32 hex string (0x...)
80
98
  payer: string; // Ethereum address (0x...)
81
99
  amount_12Decimals: string; // uint256 (decimal) − 12 implied decimals
@@ -88,6 +106,26 @@ export interface AuditPfeesPaidV1Payload {
88
106
  - `payer` must be a valid Ethereum address (0x...40 hex chars).
89
107
  - `amount_12Decimals` must be a decimal string representing an unsigned big integer (12 implied decimals).
90
108
 
109
+ ### `application.created` v1
110
+
111
+ ```ts
112
+ export interface ApplicationCreatedV1Payload {
113
+ gcaAddress: string; // Ethereum address (0x...)
114
+ lat: number;
115
+ lng: number;
116
+ estimatedCostOfPowerPerKWh: number;
117
+ estimatedKWhGeneratedPerYear: number;
118
+ installerCompanyName: string;
119
+ }
120
+ ```
121
+
122
+ **Validation:**
123
+
124
+ - `gcaAddress` must be a valid Ethereum address (0x...40 hex chars).
125
+ - `lat` and `lng` are numbers (coordinates).
126
+ - `estimatedCostOfPowerPerKWh` and `estimatedKWhGeneratedPerYear` are numbers.
127
+ - `installerCompanyName` is a string.
128
+
91
129
  ---
92
130
 
93
131
  ## ✨ Usage Example
@@ -115,12 +153,33 @@ listener.onEvent("audit.slashed", 1, (event) => {
115
153
  listener.onEvent("audit.pfees.paid", 1, (event) => {
116
154
  console.log(
117
155
  "Received audit.pfees.paid v1:",
156
+ event.applicationId,
157
+ event.payer,
158
+ event.amount_12Decimals
159
+ );
160
+ });
161
+
162
+ listener.onEvent("audit.pfees.paid", 2, (event) => {
163
+ console.log(
164
+ "Received audit.pfees.paid v2:",
118
165
  event.farmId,
119
166
  event.payer,
120
167
  event.amount_12Decimals
121
168
  );
122
169
  });
123
170
 
171
+ listener.onEvent("application.created", 1, (event) => {
172
+ console.log(
173
+ "Received application.created v1:",
174
+ event.gcaAddress,
175
+ event.lat,
176
+ event.lng,
177
+ event.estimatedCostOfPowerPerKWh,
178
+ event.estimatedKWhGeneratedPerYear,
179
+ event.installerCompanyName
180
+ );
181
+ });
182
+
124
183
  await listener.start();
125
184
  // To stop listening:
126
185
  // await listener.stop();
@@ -131,10 +190,11 @@ await listener.start();
131
190
  ```ts
132
191
  import { createGlowEventEmitter } from "@glowlabs-org/events-sdk";
133
192
 
193
+ // You must construct the emitter with a specific zoneId (not 0)
134
194
  const emitter = createGlowEventEmitter({
135
195
  username: "admin",
136
196
  password: "your-password-here",
137
- zoneId: 1,
197
+ zoneId: 1, // must be a specific zone
138
198
  });
139
199
 
140
200
  await emitter.emit({
@@ -160,62 +220,47 @@ await emitter.emit({
160
220
  eventType: "audit.pfees.paid",
161
221
  schemaVersion: 1,
162
222
  payload: {
163
- farmId: "0x...",
223
+ applicationId: "0x...",
164
224
  payer: "0x...",
165
225
  amount_12Decimals: "1000000000000",
166
226
  },
167
227
  });
168
228
 
169
- await emitter.disconnect();
170
- ```
171
-
172
- ### 🌐 Emitting or Listening to All Zones
173
-
174
- You can emit to or listen to **all zones at once** by passing `zoneId: 0` to the emitter or listener.
175
-
176
- #### Emit to All Zones
177
-
178
- ```ts
179
- import { createGlowEventEmitter } from "@glowlabs-org/events-sdk";
180
-
181
- const emitter = createGlowEventEmitter({
182
- username: "admin",
183
- password: "your-password-here",
184
- zoneId: 0, // special value for all zones
185
- });
186
-
187
- await emitter.emit({
188
- eventType: "audit.pushed",
189
- schemaVersion: 1,
190
- payload: {
191
- farmId: "0x...",
192
- protocolFeeUSDPrice_12Decimals: "...",
193
- expectedProduction_12Decimals: "...",
194
- },
195
- });
196
-
197
229
  await emitter.emit({
198
- eventType: "audit.slashed",
199
- schemaVersion: 1,
230
+ eventType: "audit.pfees.paid",
231
+ schemaVersion: 2,
200
232
  payload: {
201
233
  farmId: "0x...",
202
- slasher: "0x...",
234
+ payer: "0x...",
235
+ amount_12Decimals: "1000000000000",
203
236
  },
204
237
  });
205
238
 
206
239
  await emitter.emit({
207
- eventType: "audit.pfees.paid",
240
+ eventType: "application.created",
208
241
  schemaVersion: 1,
209
242
  payload: {
210
- farmId: "0x...",
211
- payer: "0x...",
212
- amount_12Decimals: "1000000000000",
243
+ gcaAddress: "0x...",
244
+ lat: 45.5017,
245
+ lng: -73.5673,
246
+ estimatedCostOfPowerPerKWh: 0.12,
247
+ estimatedKWhGeneratedPerYear: 10000,
248
+ installerCompanyName: "SolarCo",
213
249
  },
214
250
  });
215
251
 
216
252
  await emitter.disconnect();
217
253
  ```
218
254
 
255
+ > **Note:**
256
+ >
257
+ > - The emitter will automatically publish each event to both the global (zone 0) and the specific zone exchange.
258
+ > - You cannot construct an emitter for zoneId: 0, and you cannot specify zoneId per emit call.
259
+
260
+ ### 🌐 Listening to All Zones
261
+
262
+ You can listen to **all zones at once** by passing `zoneId: 0` to the listener. **Emitters must always use a specific zone.**
263
+
219
264
  #### Listen to All Zones
220
265
 
221
266
  ```ts
@@ -243,12 +288,33 @@ listener.onEvent("audit.slashed", 1, (event) => {
243
288
  listener.onEvent("audit.pfees.paid", 1, (event) => {
244
289
  console.log(
245
290
  "Received audit.pfees.paid v1 from any zone:",
291
+ event.applicationId,
292
+ event.payer,
293
+ event.amount_12Decimals
294
+ );
295
+ });
296
+
297
+ listener.onEvent("audit.pfees.paid", 2, (event) => {
298
+ console.log(
299
+ "Received audit.pfees.paid v2 from any zone:",
246
300
  event.farmId,
247
301
  event.payer,
248
302
  event.amount_12Decimals
249
303
  );
250
304
  });
251
305
 
306
+ listener.onEvent("application.created", 1, (event) => {
307
+ console.log(
308
+ "Received application.created v1 from any zone:",
309
+ event.gcaAddress,
310
+ event.lat,
311
+ event.lng,
312
+ event.estimatedCostOfPowerPerKWh,
313
+ event.estimatedKWhGeneratedPerYear,
314
+ event.installerCompanyName
315
+ );
316
+ });
317
+
252
318
  await listener.start();
253
319
  // To stop listening:
254
320
  // await listener.stop();
@@ -4,29 +4,62 @@ export declare const baseEventZ: z.ZodObject<{
4
4
  id: z.ZodString;
5
5
  zoneId: z.ZodEffects<z.ZodNumber, number, number>;
6
6
  zoneName: z.ZodEnum<[string, ...string[]]>;
7
- schemaVersion: z.ZodLiteral<1>;
7
+ schemaVersion: z.ZodEffects<z.ZodNumber, 1 | 2, number>;
8
8
  eventType: z.ZodEnum<["audit.pushed", "audit.slashed", "audit.pfees.paid"]>;
9
9
  timeStamp: z.ZodNumber;
10
10
  }, "strip", z.ZodTypeAny, {
11
11
  id: string;
12
12
  zoneId: number;
13
13
  zoneName: string;
14
- schemaVersion: 1;
14
+ schemaVersion: 1 | 2;
15
15
  eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
16
16
  timeStamp: number;
17
17
  }, {
18
18
  id: string;
19
19
  zoneId: number;
20
20
  zoneName: string;
21
- schemaVersion: 1;
21
+ schemaVersion: number;
22
22
  eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
23
23
  timeStamp: number;
24
24
  }>;
25
- export interface BaseEvent {
25
+ export interface BaseEventAuditPushedV1 {
26
26
  id: string;
27
27
  zoneId: number;
28
28
  zoneName: ZoneName;
29
29
  schemaVersion: 1;
30
- eventType: "audit.pushed" | "audit.slashed" | "audit.pfees.paid";
30
+ eventType: "audit.pushed";
31
+ timeStamp: number;
32
+ }
33
+ export interface BaseEventAuditSlashedV1 {
34
+ id: string;
35
+ zoneId: number;
36
+ zoneName: ZoneName;
37
+ schemaVersion: 1;
38
+ eventType: "audit.slashed";
39
+ timeStamp: number;
40
+ }
41
+ export interface BaseEventAuditPfeesPaidV1 {
42
+ id: string;
43
+ zoneId: number;
44
+ zoneName: ZoneName;
45
+ schemaVersion: 1;
46
+ eventType: "audit.pfees.paid";
47
+ timeStamp: number;
48
+ }
49
+ export interface BaseEventAuditPfeesPaidV2 {
50
+ id: string;
51
+ zoneId: number;
52
+ zoneName: ZoneName;
53
+ schemaVersion: 2;
54
+ eventType: "audit.pfees.paid";
55
+ timeStamp: number;
56
+ }
57
+ export interface BaseEventApplicationCreatedV1 {
58
+ id: string;
59
+ zoneId: number;
60
+ zoneName: ZoneName;
61
+ schemaVersion: 1;
62
+ eventType: "application.created";
31
63
  timeStamp: number;
32
64
  }
65
+ export type BaseEvent = BaseEventAuditPushedV1 | BaseEventAuditSlashedV1 | BaseEventAuditPfeesPaidV1 | BaseEventAuditPfeesPaidV2 | BaseEventApplicationCreatedV1;
@@ -11,7 +11,12 @@ exports.baseEventZ = zod_1.z.object({
11
11
  message: "Invalid zoneId",
12
12
  }),
13
13
  zoneName: zod_1.z.enum(zoneNames),
14
- schemaVersion: zod_1.z.literal(1),
14
+ schemaVersion: zod_1.z
15
+ .number()
16
+ .int()
17
+ .refine((v) => v === 1 || v === 2, {
18
+ message: "Invalid schemaVersion",
19
+ }),
15
20
  eventType: zod_1.z.enum(["audit.pushed", "audit.slashed", "audit.pfees.paid"]),
16
21
  timeStamp: zod_1.z.number().int(),
17
22
  });
package/dist/emitter.d.ts CHANGED
@@ -8,7 +8,6 @@ interface CreateGlowEventEmitterOptions {
8
8
  interface EmitEventArgs<T extends EventType, V extends EventVersion<T>> {
9
9
  eventType: T;
10
10
  schemaVersion: V;
11
- zoneId: number;
12
11
  payload: EventPayload<T, V>;
13
12
  }
14
13
  export declare function createGlowEventEmitter({ username, password, zoneId, exchangePrefix, }: CreateGlowEventEmitterOptions): {
package/dist/emitter.js CHANGED
@@ -11,8 +11,9 @@ const zones_1 = require("./zones");
11
11
  function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "glow.zone-", }) {
12
12
  let amqpConnection = null;
13
13
  let amqpChannel = null;
14
- // Use a special exchange for all zones if zoneId is 0
15
- const exchangeName = `${exchangePrefix}${zoneId}.events`;
14
+ // Exchanges for global and specific zone
15
+ const globalExchangeName = `${exchangePrefix}0.events`;
16
+ const zoneExchangeName = `${exchangePrefix}${zoneId}.events`;
16
17
  function buildAmqpUrl() {
17
18
  const url = new URL(`amqp://${username}:${password}@turntable.proxy.rlwy.net:50784`);
18
19
  return url.toString();
@@ -23,16 +24,21 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
23
24
  amqpChannel = (await amqpConnection.createChannel());
24
25
  }
25
26
  if (amqpChannel) {
26
- await amqpChannel.assertExchange(exchangeName, "topic", {
27
+ await amqpChannel.assertExchange(globalExchangeName, "topic", {
28
+ durable: true,
29
+ });
30
+ await amqpChannel.assertExchange(zoneExchangeName, "topic", {
27
31
  durable: true,
28
32
  });
29
33
  }
30
34
  }
31
35
  async function emit(args) {
32
- const { eventType, schemaVersion, zoneId, payload } = args;
36
+ const { eventType, schemaVersion, payload } = args;
33
37
  const zoneName = zones_1.zoneMap[String(zoneId)];
34
38
  if (!zoneName)
35
39
  throw new Error(`Invalid zoneId: ${zoneId}`);
40
+ if (zoneId === 0)
41
+ throw new Error("Cannot emit events with zoneId 0. Use a specific zone emitter.");
36
42
  const event = {
37
43
  id: (0, uuid_1.v4)(),
38
44
  eventType,
@@ -46,7 +52,9 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
46
52
  (0, utils_1.validateEventPayload)(event.eventType, event.schemaVersion, event);
47
53
  const routingKey = `${event.eventType}.v${event.schemaVersion}`;
48
54
  await connectIfNeeded();
49
- amqpChannel.publish(exchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
55
+ // Emit to both the global and the specific zone exchange
56
+ amqpChannel.publish(globalExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
57
+ amqpChannel.publish(zoneExchangeName, routingKey, Buffer.from(JSON.stringify(event)), { persistent: true });
50
58
  }
51
59
  async function disconnect() {
52
60
  if (amqpConnection) {
@@ -4,13 +4,21 @@ exports.getEventSchema = getEventSchema;
4
4
  const audit_pushed_v1_1 = require("./schemas/audit-pushed.v1");
5
5
  const audit_slashed_v1_1 = require("./schemas/audit-slashed.v1");
6
6
  const audit_pfees_paid_v1_1 = require("./schemas/audit-pfees-paid.v1");
7
+ const audit_pfees_paid_v2_1 = require("./schemas/audit-pfees-paid.v2");
7
8
  const base_event_1 = require("./base-event");
9
+ const application_created_v1_1 = require("./schemas/application-created.v1");
8
10
  const eventTypeRegistry = {
9
11
  "audit.pushed:v1": base_event_1.baseEventZ.extend({ payload: audit_pushed_v1_1.auditPushedV1PayloadZ }),
10
12
  "audit.slashed:v1": base_event_1.baseEventZ.extend({ payload: audit_slashed_v1_1.auditSlashedV1PayloadZ }),
11
13
  "audit.pfees.paid:v1": base_event_1.baseEventZ.extend({
12
14
  payload: audit_pfees_paid_v1_1.auditPfeesPaidV1PayloadZ,
13
15
  }),
16
+ "audit.pfees.paid:v2": base_event_1.baseEventZ.extend({
17
+ payload: audit_pfees_paid_v2_1.auditPfeesPaidV2PayloadZ,
18
+ }),
19
+ "application.created:v1": base_event_1.baseEventZ.extend({
20
+ payload: application_created_v1_1.applicationCreatedV1PayloadZ,
21
+ }),
14
22
  // Add more event types/versions here
15
23
  };
16
24
  function getEventSchema(eventType, version) {
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export declare const applicationCreatedV1PayloadZ: z.ZodObject<{
3
+ gcaAddress: z.ZodString;
4
+ lat: z.ZodNumber;
5
+ lng: z.ZodNumber;
6
+ estimatedCostOfPowerPerKWh: z.ZodNumber;
7
+ estimatedKWhGeneratedPerYear: z.ZodNumber;
8
+ installerCompanyName: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ gcaAddress: string;
11
+ lat: number;
12
+ lng: number;
13
+ estimatedCostOfPowerPerKWh: number;
14
+ estimatedKWhGeneratedPerYear: number;
15
+ installerCompanyName: string;
16
+ }, {
17
+ gcaAddress: string;
18
+ lat: number;
19
+ lng: number;
20
+ estimatedCostOfPowerPerKWh: number;
21
+ estimatedKWhGeneratedPerYear: number;
22
+ installerCompanyName: string;
23
+ }>;
24
+ export interface ApplicationCreatedV1Payload extends z.infer<typeof applicationCreatedV1PayloadZ> {
25
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applicationCreatedV1PayloadZ = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.applicationCreatedV1PayloadZ = zod_1.z.object({
6
+ gcaAddress: zod_1.z.string().regex(/^0x[a-fA-F0-9]{40}$/), // eth address
7
+ lat: zod_1.z.number(),
8
+ lng: zod_1.z.number(),
9
+ estimatedCostOfPowerPerKWh: zod_1.z.number(),
10
+ estimatedKWhGeneratedPerYear: zod_1.z.number(),
11
+ installerCompanyName: zod_1.z.string(),
12
+ });
@@ -1,14 +1,14 @@
1
1
  import { z } from "zod";
2
2
  export declare const auditPfeesPaidV1PayloadZ: z.ZodObject<{
3
- farmId: z.ZodString;
3
+ applicationId: z.ZodString;
4
4
  payer: z.ZodString;
5
5
  amount_12Decimals: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- farmId: string;
7
+ applicationId: string;
8
8
  payer: string;
9
9
  amount_12Decimals: string;
10
10
  }, {
11
- farmId: string;
11
+ applicationId: string;
12
12
  payer: string;
13
13
  amount_12Decimals: string;
14
14
  }>;
@@ -6,7 +6,7 @@ const hexBytes32 = /^0x[0-9a-fA-F]{64}$/;
6
6
  const ethAddress = /^0x[0-9a-fA-F]{40}$/;
7
7
  const uint256 = /^[0-9]+$/;
8
8
  exports.auditPfeesPaidV1PayloadZ = zod_1.z.object({
9
- farmId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
9
+ applicationId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
10
10
  payer: zod_1.z.string().regex(ethAddress, "Ethereum address"),
11
11
  amount_12Decimals: zod_1.z
12
12
  .string()
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ export declare const auditPfeesPaidV2PayloadZ: z.ZodObject<{
3
+ farmId: z.ZodString;
4
+ payer: z.ZodString;
5
+ amount_12Decimals: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ farmId: string;
8
+ payer: string;
9
+ amount_12Decimals: string;
10
+ }, {
11
+ farmId: string;
12
+ payer: string;
13
+ amount_12Decimals: string;
14
+ }>;
15
+ export type AuditPfeesPaidV2Payload = z.infer<typeof auditPfeesPaidV2PayloadZ>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.auditPfeesPaidV2PayloadZ = void 0;
4
+ const zod_1 = require("zod");
5
+ const hexBytes32 = /^0x[0-9a-fA-F]{64}$/;
6
+ const ethAddress = /^0x[0-9a-fA-F]{40}$/;
7
+ const uint256 = /^[0-9]+$/;
8
+ exports.auditPfeesPaidV2PayloadZ = zod_1.z.object({
9
+ farmId: zod_1.z.string().regex(hexBytes32, "bytes32 hex string"),
10
+ payer: zod_1.z.string().regex(ethAddress, "Ethereum address"),
11
+ amount_12Decimals: zod_1.z
12
+ .string()
13
+ .regex(uint256, "uint256 (decimal) − 12 implied decimals"),
14
+ });
package/dist/types.d.ts CHANGED
@@ -2,8 +2,16 @@ import type { BaseEvent } from "./base-event";
2
2
  import type { AuditPushedV1Payload } from "./schemas/audit-pushed.v1";
3
3
  import type { AuditSlashedV1Payload } from "./schemas/audit-slashed.v1";
4
4
  import type { AuditPfeesPaidV1Payload } from "./schemas/audit-pfees-paid.v1";
5
+ import type { AuditPfeesPaidV2Payload } from "./schemas/audit-pfees-paid.v2";
6
+ import type { ApplicationCreatedV1Payload } from "./schemas/application-created.v1";
5
7
  export type EventType = BaseEvent["eventType"];
6
- export type EventVersion<T extends EventType> = T extends "audit.pushed" ? 1 : T extends "audit.slashed" ? 1 : T extends "audit.pfees.paid" ? 1 : never;
8
+ type EventTypeToVersion = {
9
+ "audit.pushed": 1;
10
+ "audit.slashed": 1;
11
+ "audit.pfees.paid": 1 | 2;
12
+ "application.created": 1;
13
+ };
14
+ export type EventVersion<T extends EventType> = T extends keyof EventTypeToVersion ? EventTypeToVersion[T] : never;
7
15
  export interface EventPayloadMap {
8
16
  "audit.pushed": {
9
17
  1: AuditPushedV1Payload;
@@ -13,9 +21,14 @@ export interface EventPayloadMap {
13
21
  };
14
22
  "audit.pfees.paid": {
15
23
  1: AuditPfeesPaidV1Payload;
24
+ 2: AuditPfeesPaidV2Payload;
25
+ };
26
+ "application.created": {
27
+ 1: ApplicationCreatedV1Payload;
16
28
  };
17
29
  }
18
30
  export type EventPayload<T extends EventType, V extends EventVersion<T>> = T extends keyof EventPayloadMap ? V extends keyof EventPayloadMap[T] ? EventPayloadMap[T][V] : never : never;
19
31
  export interface GlowEvent<TPayload> extends Omit<BaseEvent, "payload"> {
20
32
  payload: TPayload;
21
33
  }
34
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/events-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Typed event SDK for Glow, powered by RabbitMQ and Zod.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",