@glowlabs-org/events-sdk 1.0.17 → 1.0.19
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 +35 -14
- package/dist/base-event.d.ts +16 -0
- package/dist/base-event.js +1 -0
- package/dist/emitter.d.ts +2 -1
- package/dist/emitter.js +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ Currently supported event types and versions:
|
|
|
72
72
|
| `fraction.sold` | "v2-alpha" | `FractionSoldV2AlphaPayload` | Fraction sold between creator and buyer |
|
|
73
73
|
| `fraction.closed` | "v2-alpha" | `FractionClosedV2AlphaPayload` | Fraction closed/cancelled |
|
|
74
74
|
|
|
75
|
+
> **Environment:** All events include an `environment` field that defaults to `"production"`. You can set it to `"staging"` when creating an emitter.
|
|
76
|
+
|
|
75
77
|
---
|
|
76
78
|
|
|
77
79
|
### Event Types Enum
|
|
@@ -277,26 +279,44 @@ export interface FractionClosedV2AlphaPayload {
|
|
|
277
279
|
}
|
|
278
280
|
```
|
|
279
281
|
|
|
280
|
-
````
|
|
281
|
-
|
|
282
282
|
**Validation:**
|
|
283
283
|
|
|
284
|
-
- `
|
|
285
|
-
- `
|
|
286
|
-
- `
|
|
284
|
+
- `fractionId` is a string identifier.
|
|
285
|
+
- `transactionHash` must be a 32-byte hex string.
|
|
286
|
+
- `blockNumber`, `step`, `totalSteps`, and `amount` must be decimal strings representing unsigned big integers.
|
|
287
|
+
- `token`, `owner`, `creator`, and `buyer` must be valid Ethereum addresses.
|
|
287
288
|
|
|
288
|
-
|
|
289
|
+
---
|
|
289
290
|
|
|
290
291
|
```ts
|
|
291
|
-
export interface
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
export interface FractionSoldV2AlphaPayload {
|
|
293
|
+
fractionId: string;
|
|
294
|
+
transactionHash: string; // bytes32 hex string (0x...)
|
|
295
|
+
blockNumber: string; // uint256 (decimal)
|
|
296
|
+
logIndex: number;
|
|
297
|
+
creator: string; // Ethereum address (0x...)
|
|
298
|
+
buyer: string; // Ethereum address (0x...)
|
|
299
|
+
step: string; // uint256 (decimal)
|
|
300
|
+
amount: string; // uint256 (decimal)
|
|
301
|
+
timestamp: number;
|
|
298
302
|
}
|
|
299
|
-
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### `fraction.closed` v2-alpha
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
export interface FractionClosedV2AlphaPayload {
|
|
309
|
+
fractionId: string;
|
|
310
|
+
transactionHash: string; // bytes32 hex string (0x...)
|
|
311
|
+
blockNumber: string; // uint256 (decimal)
|
|
312
|
+
logIndex: number;
|
|
313
|
+
token: string; // Ethereum address (0x...)
|
|
314
|
+
owner: string; // Ethereum address (0x...)
|
|
315
|
+
timestamp: number;
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
300
320
|
|
|
301
321
|
### `application.created` v2-alpha
|
|
302
322
|
|
|
@@ -403,6 +423,7 @@ const emitter = createGlowEventEmitter({
|
|
|
403
423
|
password: "your-password-here",
|
|
404
424
|
zoneId: getZoneId("CleanGridProject"), // must be a specific zone
|
|
405
425
|
host: "my.rabbitmq.host:5672", // Optional: override the default host
|
|
426
|
+
environment: "staging", // Optional: defaults to "production"
|
|
406
427
|
});
|
|
407
428
|
|
|
408
429
|
await emitter.emit({
|
package/dist/base-event.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const baseEventZ: z.ZodObject<{
|
|
|
7
7
|
schemaVersion: z.ZodEnum<["v1", "v2", "v2-alpha"]>;
|
|
8
8
|
eventType: z.ZodEnum<[EventType, ...EventType[]]>;
|
|
9
9
|
timeStamp: z.ZodNumber;
|
|
10
|
+
environment: z.ZodDefault<z.ZodEnum<["staging", "production"]>>;
|
|
10
11
|
}, "strip", z.ZodTypeAny, {
|
|
11
12
|
id: string;
|
|
12
13
|
zoneId: number;
|
|
@@ -14,6 +15,7 @@ export declare const baseEventZ: z.ZodObject<{
|
|
|
14
15
|
schemaVersion: "v1" | "v2" | "v2-alpha";
|
|
15
16
|
eventType: EventType;
|
|
16
17
|
timeStamp: number;
|
|
18
|
+
environment: "staging" | "production";
|
|
17
19
|
}, {
|
|
18
20
|
id: string;
|
|
19
21
|
zoneId: number;
|
|
@@ -21,6 +23,7 @@ export declare const baseEventZ: z.ZodObject<{
|
|
|
21
23
|
schemaVersion: "v1" | "v2" | "v2-alpha";
|
|
22
24
|
eventType: EventType;
|
|
23
25
|
timeStamp: number;
|
|
26
|
+
environment?: "staging" | "production" | undefined;
|
|
24
27
|
}>;
|
|
25
28
|
export interface BaseEventAuditPushedV1 {
|
|
26
29
|
id: string;
|
|
@@ -29,6 +32,7 @@ export interface BaseEventAuditPushedV1 {
|
|
|
29
32
|
schemaVersion: "v1";
|
|
30
33
|
eventType: "audit.pushed";
|
|
31
34
|
timeStamp: number;
|
|
35
|
+
environment: "staging" | "production";
|
|
32
36
|
}
|
|
33
37
|
export interface BaseEventAuditSlashedV1 {
|
|
34
38
|
id: string;
|
|
@@ -37,6 +41,7 @@ export interface BaseEventAuditSlashedV1 {
|
|
|
37
41
|
schemaVersion: "v1";
|
|
38
42
|
eventType: "audit.slashed";
|
|
39
43
|
timeStamp: number;
|
|
44
|
+
environment: "staging" | "production";
|
|
40
45
|
}
|
|
41
46
|
export interface BaseEventAuditPfeesPaidV1 {
|
|
42
47
|
id: string;
|
|
@@ -45,6 +50,7 @@ export interface BaseEventAuditPfeesPaidV1 {
|
|
|
45
50
|
schemaVersion: "v1";
|
|
46
51
|
eventType: "audit.pfees.paid";
|
|
47
52
|
timeStamp: number;
|
|
53
|
+
environment: "staging" | "production";
|
|
48
54
|
}
|
|
49
55
|
export interface BaseEventAuditPfeesPaidV2 {
|
|
50
56
|
id: string;
|
|
@@ -53,6 +59,7 @@ export interface BaseEventAuditPfeesPaidV2 {
|
|
|
53
59
|
schemaVersion: "v2";
|
|
54
60
|
eventType: "audit.pfees.paid";
|
|
55
61
|
timeStamp: number;
|
|
62
|
+
environment: "staging" | "production";
|
|
56
63
|
}
|
|
57
64
|
export interface BaseEventAuditPfeesPaidV2Alpha {
|
|
58
65
|
id: string;
|
|
@@ -61,6 +68,7 @@ export interface BaseEventAuditPfeesPaidV2Alpha {
|
|
|
61
68
|
schemaVersion: "v2-alpha";
|
|
62
69
|
eventType: "audit.pfees.paid";
|
|
63
70
|
timeStamp: number;
|
|
71
|
+
environment: "staging" | "production";
|
|
64
72
|
}
|
|
65
73
|
export interface BaseEventApplicationCreatedV1 {
|
|
66
74
|
id: string;
|
|
@@ -69,6 +77,7 @@ export interface BaseEventApplicationCreatedV1 {
|
|
|
69
77
|
schemaVersion: "v1";
|
|
70
78
|
eventType: "application.created";
|
|
71
79
|
timeStamp: number;
|
|
80
|
+
environment: "staging" | "production";
|
|
72
81
|
}
|
|
73
82
|
export interface BaseEventApplicationCreatedV2Alpha {
|
|
74
83
|
id: string;
|
|
@@ -77,6 +86,7 @@ export interface BaseEventApplicationCreatedV2Alpha {
|
|
|
77
86
|
schemaVersion: "v2-alpha";
|
|
78
87
|
eventType: "application.created";
|
|
79
88
|
timeStamp: number;
|
|
89
|
+
environment: "staging" | "production";
|
|
80
90
|
}
|
|
81
91
|
export interface BaseEventApplicationPriceQuoteV2Alpha {
|
|
82
92
|
id: string;
|
|
@@ -85,6 +95,7 @@ export interface BaseEventApplicationPriceQuoteV2Alpha {
|
|
|
85
95
|
schemaVersion: "v2-alpha";
|
|
86
96
|
eventType: "application.price.quote";
|
|
87
97
|
timeStamp: number;
|
|
98
|
+
environment: "staging" | "production";
|
|
88
99
|
}
|
|
89
100
|
export interface BaseEventGctlMintedV2Alpha {
|
|
90
101
|
id: string;
|
|
@@ -93,6 +104,7 @@ export interface BaseEventGctlMintedV2Alpha {
|
|
|
93
104
|
schemaVersion: "v2-alpha";
|
|
94
105
|
eventType: "gctl.minted";
|
|
95
106
|
timeStamp: number;
|
|
107
|
+
environment: "staging" | "production";
|
|
96
108
|
}
|
|
97
109
|
export interface BaseEventAuditorFeesPaidV2Alpha {
|
|
98
110
|
id: string;
|
|
@@ -101,6 +113,7 @@ export interface BaseEventAuditorFeesPaidV2Alpha {
|
|
|
101
113
|
schemaVersion: "v2-alpha";
|
|
102
114
|
eventType: "auditor.fees.paid";
|
|
103
115
|
timeStamp: number;
|
|
116
|
+
environment: "staging" | "production";
|
|
104
117
|
}
|
|
105
118
|
export interface BaseEventFractionCreatedV2Alpha {
|
|
106
119
|
id: string;
|
|
@@ -109,6 +122,7 @@ export interface BaseEventFractionCreatedV2Alpha {
|
|
|
109
122
|
schemaVersion: "v2-alpha";
|
|
110
123
|
eventType: "fraction.created";
|
|
111
124
|
timeStamp: number;
|
|
125
|
+
environment: "staging" | "production";
|
|
112
126
|
}
|
|
113
127
|
export interface BaseEventFractionSoldV2Alpha {
|
|
114
128
|
id: string;
|
|
@@ -117,6 +131,7 @@ export interface BaseEventFractionSoldV2Alpha {
|
|
|
117
131
|
schemaVersion: "v2-alpha";
|
|
118
132
|
eventType: "fraction.sold";
|
|
119
133
|
timeStamp: number;
|
|
134
|
+
environment: "staging" | "production";
|
|
120
135
|
}
|
|
121
136
|
export interface BaseEventFractionClosedV2Alpha {
|
|
122
137
|
id: string;
|
|
@@ -125,5 +140,6 @@ export interface BaseEventFractionClosedV2Alpha {
|
|
|
125
140
|
schemaVersion: "v2-alpha";
|
|
126
141
|
eventType: "fraction.closed";
|
|
127
142
|
timeStamp: number;
|
|
143
|
+
environment: "staging" | "production";
|
|
128
144
|
}
|
|
129
145
|
export type BaseEvent = BaseEventAuditPushedV1 | BaseEventAuditSlashedV1 | BaseEventAuditPfeesPaidV1 | BaseEventAuditPfeesPaidV2 | BaseEventAuditPfeesPaidV2Alpha | BaseEventApplicationCreatedV1 | BaseEventApplicationCreatedV2Alpha | BaseEventApplicationPriceQuoteV2Alpha | BaseEventGctlMintedV2Alpha | BaseEventAuditorFeesPaidV2Alpha | BaseEventFractionCreatedV2Alpha | BaseEventFractionSoldV2Alpha | BaseEventFractionClosedV2Alpha;
|
package/dist/base-event.js
CHANGED
|
@@ -15,4 +15,5 @@ exports.baseEventZ = zod_1.z.object({
|
|
|
15
15
|
schemaVersion: zod_1.z.enum(["v1", "v2", "v2-alpha"]),
|
|
16
16
|
eventType: zod_1.z.enum(Object.values(event_types_1.eventTypes)),
|
|
17
17
|
timeStamp: zod_1.z.number().int(),
|
|
18
|
+
environment: zod_1.z.enum(["staging", "production"]).default("production"),
|
|
18
19
|
});
|
package/dist/emitter.d.ts
CHANGED
|
@@ -5,13 +5,14 @@ interface CreateGlowEventEmitterOptions {
|
|
|
5
5
|
zoneId: number;
|
|
6
6
|
exchangePrefix?: string;
|
|
7
7
|
host?: string;
|
|
8
|
+
environment?: "staging" | "production";
|
|
8
9
|
}
|
|
9
10
|
interface EmitEventArgs<T extends EventType, V extends keyof EventPayloadMap[T]> {
|
|
10
11
|
eventType: T;
|
|
11
12
|
schemaVersion: V;
|
|
12
13
|
payload: EventPayload<T, V>;
|
|
13
14
|
}
|
|
14
|
-
export declare function createGlowEventEmitter({ username, password, zoneId, exchangePrefix, host, }: CreateGlowEventEmitterOptions): {
|
|
15
|
+
export declare function createGlowEventEmitter({ username, password, zoneId, exchangePrefix, host, environment, }: CreateGlowEventEmitterOptions): {
|
|
15
16
|
emit: <T extends EventType, V extends keyof import("./types").EventPayloadMap[T]>(args: EmitEventArgs<T, V>) => Promise<void>;
|
|
16
17
|
disconnect: () => Promise<void>;
|
|
17
18
|
};
|
package/dist/emitter.js
CHANGED
|
@@ -8,7 +8,7 @@ const amqplib_1 = __importDefault(require("amqplib"));
|
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
10
|
const zones_1 = require("./zones");
|
|
11
|
-
function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "glow.zone-", host = "turntable.proxy.rlwy.net:50784", }) {
|
|
11
|
+
function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "glow.zone-", host = "turntable.proxy.rlwy.net:50784", environment = "production", }) {
|
|
12
12
|
let amqpConnection = null;
|
|
13
13
|
let amqpChannel = null;
|
|
14
14
|
// Exchanges for global and specific zone
|
|
@@ -41,8 +41,6 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
|
|
|
41
41
|
const zoneName = zones_1.zoneMap[zoneId];
|
|
42
42
|
if (!zoneName)
|
|
43
43
|
throw new Error(`Invalid zoneId: ${zoneId}`);
|
|
44
|
-
if (zoneId === 0)
|
|
45
|
-
throw new Error("Cannot emit events with zoneId 0. Use a specific zone emitter.");
|
|
46
44
|
const event = {
|
|
47
45
|
id: (0, uuid_1.v4)(),
|
|
48
46
|
eventType,
|
|
@@ -50,6 +48,7 @@ function createGlowEventEmitter({ username, password, zoneId, exchangePrefix = "
|
|
|
50
48
|
zoneId,
|
|
51
49
|
zoneName,
|
|
52
50
|
timeStamp: Date.now(),
|
|
51
|
+
environment,
|
|
53
52
|
payload,
|
|
54
53
|
};
|
|
55
54
|
(0, utils_1.validateZoneNameAndId)(event.zoneId, event.zoneName);
|