@unifiedflow/cli 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.
Files changed (35) hide show
  1. package/README.md +85 -0
  2. package/dist/idl/unified_flow.json +1889 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +443 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/services/backfill.d.ts +2 -0
  8. package/dist/services/backfill.d.ts.map +1 -0
  9. package/dist/services/backfill.js +358 -0
  10. package/dist/services/backfill.js.map +1 -0
  11. package/dist/services/csvDiff.d.ts +68 -0
  12. package/dist/services/csvDiff.d.ts.map +1 -0
  13. package/dist/services/csvDiff.js +318 -0
  14. package/dist/services/csvDiff.js.map +1 -0
  15. package/dist/services/decoder.d.ts +3 -0
  16. package/dist/services/decoder.d.ts.map +1 -0
  17. package/dist/services/decoder.js +43 -0
  18. package/dist/services/decoder.js.map +1 -0
  19. package/dist/services/eventNormalizer.d.ts +63 -0
  20. package/dist/services/eventNormalizer.d.ts.map +1 -0
  21. package/dist/services/eventNormalizer.js +212 -0
  22. package/dist/services/eventNormalizer.js.map +1 -0
  23. package/dist/services/eventParser.d.ts +7 -0
  24. package/dist/services/eventParser.d.ts.map +1 -0
  25. package/dist/services/eventParser.js +130 -0
  26. package/dist/services/eventParser.js.map +1 -0
  27. package/dist/services/rpc.d.ts +10 -0
  28. package/dist/services/rpc.d.ts.map +1 -0
  29. package/dist/services/rpc.js +203 -0
  30. package/dist/services/rpc.js.map +1 -0
  31. package/dist/services/streamIndexer.d.ts +2 -0
  32. package/dist/services/streamIndexer.d.ts.map +1 -0
  33. package/dist/services/streamIndexer.js +367 -0
  34. package/dist/services/streamIndexer.js.map +1 -0
  35. package/package.json +42 -0
@@ -0,0 +1,318 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildExactRecordKey = buildExactRecordKey;
4
+ exports.parseCsvText = parseCsvText;
5
+ exports.computeCsvDiff = computeCsvDiff;
6
+ exports.mapCsvRowsToStreams = mapCsvRowsToStreams;
7
+ function toNumber(value, fallback = 0) {
8
+ if (value === undefined || value === null || value === "") {
9
+ return fallback;
10
+ }
11
+ const parsed = Number(value);
12
+ return Number.isFinite(parsed) ? parsed : fallback;
13
+ }
14
+ function toBoolean(value, fallback = false) {
15
+ if (value === undefined || value === null || value === "") {
16
+ return fallback;
17
+ }
18
+ if (typeof value === "boolean") {
19
+ return value;
20
+ }
21
+ const text = String(value).trim().toLowerCase();
22
+ if (text === "true" || text === "1")
23
+ return true;
24
+ if (text === "false" || text === "0")
25
+ return false;
26
+ return fallback;
27
+ }
28
+ function normalizeMilestones(value) {
29
+ if (value === undefined || value === null) {
30
+ return "";
31
+ }
32
+ return String(value).trim();
33
+ }
34
+ function normalizeCsvRecord(row) {
35
+ const recipient = String(row.recipient ?? "").trim();
36
+ const id = row.id ? String(row.id).trim() : undefined;
37
+ return {
38
+ matchKey: id || (recipient ? `recipient:${recipient.toLowerCase()}` : `row:${Math.random().toString(36).slice(2, 10)}`),
39
+ id,
40
+ recipient,
41
+ amount: toNumber(row.amount, 0),
42
+ mint: String(row.mint ?? "").trim(),
43
+ type: toNumber(row.type, 0),
44
+ duration: toNumber(row.duration, 0),
45
+ cliffDuration: toNumber(row.cliffDuration, 0),
46
+ cancelable: toBoolean(row.cancelable, true),
47
+ milestones: normalizeMilestones(row.milestones),
48
+ creator: row.creator,
49
+ };
50
+ }
51
+ function normalizeStreamRecord(stream) {
52
+ const recipient = String(stream.recipient ?? "").trim();
53
+ const id = stream.id ? String(stream.id).trim() : undefined;
54
+ return {
55
+ matchKey: id || (recipient ? `recipient:${recipient.toLowerCase()}` : `row:${Math.random().toString(36).slice(2, 10)}`),
56
+ id,
57
+ recipient,
58
+ amount: toNumber(stream.totalAmount ?? stream.amount, 0),
59
+ mint: String(stream.mint ?? "").trim(),
60
+ type: toNumber(stream.vestingType ?? stream.type, 0),
61
+ duration: toNumber(stream.endTs, 0) - toNumber(stream.startTs, 0),
62
+ cliffDuration: toNumber(stream.cliffTs, 0) - toNumber(stream.startTs, 0),
63
+ cancelable: toBoolean(stream.cancelable, true),
64
+ milestones: normalizeMilestones(stream.milestones),
65
+ creator: stream.creator ? String(stream.creator) : undefined,
66
+ };
67
+ }
68
+ function buildExactRecordKey(record) {
69
+ return [
70
+ record.recipient.trim().toLowerCase(),
71
+ record.mint.trim(),
72
+ record.type,
73
+ record.amount,
74
+ record.duration,
75
+ record.cliffDuration,
76
+ record.cancelable ? 1 : 0,
77
+ record.milestones.trim(),
78
+ ].join("|");
79
+ }
80
+ function buildIdentityRecordKey(record) {
81
+ return [record.recipient.trim().toLowerCase(), record.mint.trim(), record.type].join("|");
82
+ }
83
+ /**
84
+ * Robust CSV parser that parses text into key-value objects, converting numeric and boolean fields appropriately.
85
+ */
86
+ function parseCsvText(csvText) {
87
+ const lines = csvText
88
+ .split(/\r?\n/)
89
+ .map((line) => line.trim())
90
+ .filter((line) => line.length > 0);
91
+ if (lines.length === 0)
92
+ return [];
93
+ const headers = lines[0].split(",").map((header) => header.trim().toLowerCase());
94
+ const rows = [];
95
+ for (let i = 1; i < lines.length; i++) {
96
+ const values = lines[i].split(",").map((value) => value.trim());
97
+ if (values.length < headers.length)
98
+ continue;
99
+ const row = {};
100
+ headers.forEach((header, index) => {
101
+ const val = values[index];
102
+ if (val === undefined || val === "")
103
+ return;
104
+ if (header === "id") {
105
+ row.id = val;
106
+ return;
107
+ }
108
+ if (header === "recipient") {
109
+ row.recipient = val;
110
+ return;
111
+ }
112
+ if (header === "amount" || header === "type" || header === "duration") {
113
+ row[header] = toNumber(val, 0);
114
+ return;
115
+ }
116
+ if (header === "cliffduration" || header === "cliff_duration") {
117
+ row.cliffDuration = toNumber(val, 0);
118
+ return;
119
+ }
120
+ if (header === "cancelable") {
121
+ row.cancelable = toBoolean(val, true);
122
+ return;
123
+ }
124
+ if (header === "mint") {
125
+ row.mint = val;
126
+ return;
127
+ }
128
+ if (header === "milestones") {
129
+ row.milestones = values
130
+ .slice(index)
131
+ .map((value) => value.trim())
132
+ .filter(Boolean)
133
+ .join(";");
134
+ return;
135
+ }
136
+ });
137
+ rows.push(row);
138
+ }
139
+ return rows;
140
+ }
141
+ function pickFirstUnmatched(candidates, matchedRefIds) {
142
+ return candidates.find((candidate) => !matchedRefIds.has(candidate.matchKey)) ?? null;
143
+ }
144
+ function pushChange(changes, field, oldVal, newVal) {
145
+ if (oldVal === newVal)
146
+ return;
147
+ changes.push({ field, oldVal, newVal });
148
+ }
149
+ /**
150
+ * Compute the diff between incoming CSV rows and a set of reference rows.
151
+ */
152
+ function computeCsvDiff(newRows, refStreams, mode) {
153
+ const added = [];
154
+ const modified = [];
155
+ const deleted = [];
156
+ const unchanged = [];
157
+ const normalizedNewRows = newRows.map(normalizeCsvRecord);
158
+ const normalizedRefRows = refStreams.map((stream) => Object.prototype.hasOwnProperty.call(stream, "totalAmount") || Object.prototype.hasOwnProperty.call(stream, "vestingType")
159
+ ? normalizeStreamRecord(stream)
160
+ : normalizeCsvRecord(stream));
161
+ const refExactKeyBuckets = new Map();
162
+ const refIdentityKeyBuckets = new Map();
163
+ const consumedRefIndexes = new Set();
164
+ normalizedRefRows.forEach((stream, index) => {
165
+ const exactKey = buildExactRecordKey(stream);
166
+ const identityKey = buildIdentityRecordKey(stream);
167
+ if (!refExactKeyBuckets.has(exactKey)) {
168
+ refExactKeyBuckets.set(exactKey, []);
169
+ }
170
+ refExactKeyBuckets.get(exactKey).push(index);
171
+ if (!refIdentityKeyBuckets.has(identityKey)) {
172
+ refIdentityKeyBuckets.set(identityKey, []);
173
+ }
174
+ refIdentityKeyBuckets.get(identityKey).push(index);
175
+ });
176
+ const takeFirstUnusedIndex = (indexes) => indexes.find((index) => !consumedRefIndexes.has(index));
177
+ if (mode === "create") {
178
+ normalizedNewRows.forEach((row, idx) => {
179
+ added.push({
180
+ id: row.id || `StreamCSV-NEW-${idx}-${Math.random().toString(36).substring(2, 6).toUpperCase()}`,
181
+ recipient: row.recipient || "Unknown Recipient",
182
+ amount: row.amount,
183
+ mint: row.mint || "Unknown Mint",
184
+ type: row.type,
185
+ duration: row.duration,
186
+ cliffDuration: row.cliffDuration,
187
+ cancelable: row.cancelable,
188
+ milestones: row.milestones,
189
+ isNew: true,
190
+ });
191
+ });
192
+ normalizedRefRows.forEach((stream, idx) => {
193
+ unchanged.push({
194
+ id: stream.id || `StreamCSV-UNCH-${idx}`,
195
+ recipient: stream.recipient,
196
+ amount: stream.amount,
197
+ duration: stream.duration,
198
+ cliffDuration: stream.cliffDuration,
199
+ cancelable: stream.cancelable,
200
+ type: stream.type,
201
+ milestones: stream.milestones,
202
+ });
203
+ });
204
+ return { added, modified, deleted: [], unchanged, mode };
205
+ }
206
+ normalizedNewRows.forEach((row, idx) => {
207
+ if (mode === "edit" && row.id) {
208
+ const normalizedRowId = row.id.trim();
209
+ const refIndexById = normalizedRefRows.findIndex((refRow, refIndex) => !consumedRefIndexes.has(refIndex) &&
210
+ String(refRow.id || "").trim() === normalizedRowId);
211
+ if (refIndexById >= 0) {
212
+ consumedRefIndexes.add(refIndexById);
213
+ const matchedStream = normalizedRefRows[refIndexById];
214
+ const changes = [];
215
+ pushChange(changes, "amount", matchedStream.amount, row.amount);
216
+ pushChange(changes, "duration", matchedStream.duration, row.duration);
217
+ pushChange(changes, "cliffDuration", matchedStream.cliffDuration, row.cliffDuration);
218
+ pushChange(changes, "milestones", matchedStream.milestones, row.milestones);
219
+ if (changes.length > 0) {
220
+ modified.push({
221
+ id: matchedStream.id || normalizedRowId || `StreamCSV-MOD-${idx}`,
222
+ recipient: matchedStream.recipient,
223
+ changes,
224
+ details: {
225
+ creator: matchedStream.creator,
226
+ mint: matchedStream.mint,
227
+ type: matchedStream.type,
228
+ amount: row.amount,
229
+ duration: row.duration,
230
+ cliffDuration: row.cliffDuration,
231
+ milestones: row.milestones,
232
+ },
233
+ });
234
+ }
235
+ else {
236
+ unchanged.push({
237
+ id: matchedStream.id || normalizedRowId || `StreamCSV-UNCH-${idx}`,
238
+ recipient: matchedStream.recipient,
239
+ amount: matchedStream.amount,
240
+ duration: matchedStream.duration,
241
+ cliffDuration: matchedStream.cliffDuration,
242
+ cancelable: matchedStream.cancelable,
243
+ type: matchedStream.type,
244
+ milestones: matchedStream.milestones,
245
+ });
246
+ }
247
+ }
248
+ return;
249
+ }
250
+ const exactKey = buildExactRecordKey(normalizeCsvRecord(row));
251
+ const identityKey = buildIdentityRecordKey(normalizeCsvRecord(row));
252
+ const exactCandidateIndex = takeFirstUnusedIndex(refExactKeyBuckets.get(exactKey) || []);
253
+ if (exactCandidateIndex !== undefined) {
254
+ consumedRefIndexes.add(exactCandidateIndex);
255
+ const matchedStream = normalizedRefRows[exactCandidateIndex];
256
+ unchanged.push({
257
+ id: matchedStream.id || row.id || `StreamCSV-UNCH-${idx}`,
258
+ recipient: matchedStream.recipient,
259
+ amount: matchedStream.amount,
260
+ duration: matchedStream.duration,
261
+ cliffDuration: matchedStream.cliffDuration,
262
+ cancelable: matchedStream.cancelable,
263
+ type: matchedStream.type,
264
+ milestones: matchedStream.milestones,
265
+ });
266
+ return;
267
+ }
268
+ const identityCandidateIndex = takeFirstUnusedIndex(refIdentityKeyBuckets.get(identityKey) || []);
269
+ if (!identityCandidateIndex && identityCandidateIndex !== 0) {
270
+ // Edit mode represents updates to existing on-chain streams only.
271
+ return;
272
+ }
273
+ consumedRefIndexes.add(identityCandidateIndex);
274
+ const matchedStream = normalizedRefRows[identityCandidateIndex];
275
+ const changes = [];
276
+ pushChange(changes, "amount", matchedStream.amount, row.amount);
277
+ pushChange(changes, "duration", matchedStream.duration, row.duration);
278
+ pushChange(changes, "cliffDuration", matchedStream.cliffDuration, row.cliffDuration);
279
+ pushChange(changes, "milestones", matchedStream.milestones, row.milestones);
280
+ if (changes.length > 0) {
281
+ modified.push({
282
+ id: matchedStream.id || row.id || `StreamCSV-MOD-${idx}`,
283
+ recipient: matchedStream.recipient,
284
+ changes,
285
+ details: {
286
+ creator: matchedStream.creator,
287
+ mint: row.mint || matchedStream.mint,
288
+ type: row.type,
289
+ amount: row.amount,
290
+ duration: row.duration,
291
+ cliffDuration: row.cliffDuration,
292
+ cancelable: row.cancelable,
293
+ milestones: row.milestones,
294
+ },
295
+ });
296
+ }
297
+ else {
298
+ unchanged.push({
299
+ id: matchedStream.id || row.id || `StreamCSV-UNCH-${idx}`,
300
+ recipient: matchedStream.recipient,
301
+ amount: matchedStream.amount,
302
+ duration: matchedStream.duration,
303
+ cliffDuration: matchedStream.cliffDuration,
304
+ cancelable: matchedStream.cancelable,
305
+ type: matchedStream.type,
306
+ milestones: matchedStream.milestones,
307
+ });
308
+ }
309
+ });
310
+ return { added: [], modified, deleted: [], unchanged, mode };
311
+ }
312
+ /**
313
+ * Utility to map CSV rows into diff-friendly records.
314
+ */
315
+ function mapCsvRowsToStreams(rows) {
316
+ return rows.map((row) => normalizeCsvRecord(row));
317
+ }
318
+ //# sourceMappingURL=csvDiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csvDiff.js","sourceRoot":"","sources":["../../src/services/csvDiff.ts"],"names":[],"mappings":";;AAkIA,kDAWC;AASD,oCAiEC;AAcD,wCAgMC;AAKD,kDAEC;AAjXD,SAAS,QAAQ,CAAC,KAAc,EAAE,QAAQ,GAAG,CAAC;IAC5C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrD,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,QAAQ,GAAG,KAAK;IACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,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AAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC;gBACb,EAAE,EAAE,aAAa,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,kBAAkB,GAAG,EAAE;gBACzD,SAAS,EAAE,aAAa,CAAC,SAAS;gBAClC,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC5B,QAAQ,EAAE,aAAa,CAAC,QAAQ;gBAChC,aAAa,EAAE,aAAa,CAAC,aAAa;gBAC1C,UAAU,EAAE,aAAa,CAAC,UAAU;gBACpC,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,IAAc;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ export declare const coder: anchor.BorshCoder<string, string>;
3
+ //# sourceMappingURL=decoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoder.d.ts","sourceRoot":"","sources":["../../src/services/decoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,KAAK,mCAA2C,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.coder = void 0;
40
+ const anchor = __importStar(require("@coral-xyz/anchor"));
41
+ const unified_flow_json_1 = __importDefault(require("../idl/unified_flow.json"));
42
+ exports.coder = new anchor.BorshCoder(unified_flow_json_1.default);
43
+ //# sourceMappingURL=decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decoder.js","sourceRoot":"","sources":["../../src/services/decoder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAC5C,iFAA2C;AAE9B,QAAA,KAAK,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,2BAAiB,CAAC,CAAC"}
@@ -0,0 +1,63 @@
1
+ export declare function normalizeStreamCreated(event: Record<string, unknown>): {
2
+ stream: string;
3
+ creator: string;
4
+ recipient: string;
5
+ mint: string;
6
+ vault: string;
7
+ totalAmount: bigint;
8
+ startTs: bigint;
9
+ cliffTs: bigint;
10
+ endTs: bigint;
11
+ vestingType: number;
12
+ milestoneCount: number;
13
+ cancelable: boolean;
14
+ nonce: bigint;
15
+ } | null;
16
+ export declare function normalizeTokensClaimed(event: Record<string, unknown>): {
17
+ stream: string;
18
+ recipient: string;
19
+ mint: string;
20
+ claimable: bigint;
21
+ feeLamports: bigint;
22
+ withdrawnTotal: bigint;
23
+ } | null;
24
+ export declare function normalizeMilestoneUnlocked(event: Record<string, unknown>): {
25
+ stream: string;
26
+ milestone: string;
27
+ index: number;
28
+ amount: bigint;
29
+ unlockTs: bigint | null;
30
+ } | null;
31
+ export declare function normalizeStreamCancelled(event: Record<string, unknown>): {
32
+ stream: string;
33
+ creator: string;
34
+ recipient: string;
35
+ vestedAmount: bigint;
36
+ returnedToCreator: bigint;
37
+ claimableForRecipient: bigint;
38
+ timestamp: bigint;
39
+ } | null;
40
+ export declare function normalizeMilestoneEdited(event: Record<string, unknown>): {
41
+ stream: string;
42
+ milestone: string;
43
+ index: number;
44
+ oldAmount: bigint;
45
+ newAmount: bigint;
46
+ timestamp: bigint;
47
+ } | null;
48
+ export declare function normalizeLinearEdited(event: Record<string, unknown>): {
49
+ stream: string;
50
+ oldEndTs: bigint;
51
+ newEndTs: bigint;
52
+ oldTotalAmount: bigint;
53
+ newTotalAmount: bigint;
54
+ topupAmount: bigint;
55
+ timestamp: bigint;
56
+ } | null;
57
+ export declare function normalizeCliffEdited(event: Record<string, unknown>): {
58
+ stream: string;
59
+ oldCliffTs: bigint;
60
+ newCliffTs: bigint;
61
+ timestamp: bigint;
62
+ } | null;
63
+ //# sourceMappingURL=eventNormalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventNormalizer.d.ts","sourceRoot":"","sources":["../../src/services/eventNormalizer.ts"],"names":[],"mappings":"AAoEA,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;;SAkCpE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;SAoBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;SAkBxE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;SAsBtE;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;SAoBtE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;SAsBnE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;SAgBlE"}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeStreamCreated = normalizeStreamCreated;
4
+ exports.normalizeTokensClaimed = normalizeTokensClaimed;
5
+ exports.normalizeMilestoneUnlocked = normalizeMilestoneUnlocked;
6
+ exports.normalizeStreamCancelled = normalizeStreamCancelled;
7
+ exports.normalizeMilestoneEdited = normalizeMilestoneEdited;
8
+ exports.normalizeLinearEdited = normalizeLinearEdited;
9
+ exports.normalizeCliffEdited = normalizeCliffEdited;
10
+ function firstDefined(event, keys) {
11
+ for (const key of keys) {
12
+ const value = event[key];
13
+ if (value !== undefined && value !== null) {
14
+ return value;
15
+ }
16
+ }
17
+ return undefined;
18
+ }
19
+ function asString(value) {
20
+ if (value === undefined || value === null) {
21
+ return null;
22
+ }
23
+ if (typeof value === "string") {
24
+ return value;
25
+ }
26
+ if (typeof value === "object" || typeof value === "bigint" || typeof value === "number" || typeof value === "boolean") {
27
+ return value.toString();
28
+ }
29
+ return null;
30
+ }
31
+ function asBigInt(value, fallback) {
32
+ if (value === undefined || value === null) {
33
+ return fallback ?? null;
34
+ }
35
+ try {
36
+ return BigInt(value.toString());
37
+ }
38
+ catch {
39
+ return fallback ?? null;
40
+ }
41
+ }
42
+ function asNumber(value, fallback) {
43
+ if (value === undefined || value === null) {
44
+ return fallback ?? null;
45
+ }
46
+ const parsed = Number(value.toString());
47
+ return Number.isFinite(parsed) ? parsed : fallback ?? null;
48
+ }
49
+ function asBoolean(value, fallback = false) {
50
+ if (value === undefined || value === null) {
51
+ return fallback;
52
+ }
53
+ if (typeof value === "boolean") {
54
+ return value;
55
+ }
56
+ const text = value.toString().toLowerCase();
57
+ if (text === "true")
58
+ return true;
59
+ if (text === "false")
60
+ return false;
61
+ if (text === "1")
62
+ return true;
63
+ if (text === "0")
64
+ return false;
65
+ return fallback;
66
+ }
67
+ function normalizeStreamCreated(event) {
68
+ const stream = asString(firstDefined(event, ["stream", "streamKey", "stream_address"]));
69
+ const creator = asString(firstDefined(event, ["creator"]));
70
+ const recipient = asString(firstDefined(event, ["recipient"]));
71
+ const mint = asString(firstDefined(event, ["mint"]));
72
+ const vault = asString(firstDefined(event, ["vault"]));
73
+ const totalAmount = asBigInt(firstDefined(event, ["total_amount", "totalAmount"]));
74
+ const startTs = asBigInt(firstDefined(event, ["start_ts", "startTs"]));
75
+ const cliffTsRaw = firstDefined(event, ["cliff_ts", "cliffTs"]);
76
+ const endTs = asBigInt(firstDefined(event, ["end_ts", "endTs"]));
77
+ const vestingType = asNumber(firstDefined(event, ["vesting_type", "vestingType"]), 0);
78
+ const milestoneCount = asNumber(firstDefined(event, ["milestone_count", "milestoneCount"]), 0);
79
+ const cancelable = asBoolean(firstDefined(event, ["cancelable"]), false);
80
+ const nonce = asBigInt(firstDefined(event, ["nonce"]), 0n);
81
+ if (!stream || !creator || !recipient || !mint || !vault || totalAmount === null || startTs === null || endTs === null || vestingType === null || milestoneCount === null || nonce === null) {
82
+ return null;
83
+ }
84
+ return {
85
+ stream,
86
+ creator,
87
+ recipient,
88
+ mint,
89
+ vault,
90
+ totalAmount,
91
+ startTs,
92
+ cliffTs: asBigInt(cliffTsRaw, startTs) ?? startTs,
93
+ endTs,
94
+ vestingType,
95
+ milestoneCount,
96
+ cancelable,
97
+ nonce,
98
+ };
99
+ }
100
+ function normalizeTokensClaimed(event) {
101
+ const stream = asString(firstDefined(event, ["stream"]));
102
+ const recipient = asString(firstDefined(event, ["recipient"]));
103
+ const mint = asString(firstDefined(event, ["mint"]));
104
+ const claimable = asBigInt(firstDefined(event, ["claimable"]));
105
+ const feeLamports = asBigInt(firstDefined(event, ["fee_lamports", "feeLamports"]));
106
+ const withdrawnTotal = asBigInt(firstDefined(event, ["withdrawn_total", "withdrawnTotal"]));
107
+ if (!stream || !recipient || !mint || claimable === null || feeLamports === null || withdrawnTotal === null) {
108
+ return null;
109
+ }
110
+ return {
111
+ stream,
112
+ recipient,
113
+ mint,
114
+ claimable,
115
+ feeLamports,
116
+ withdrawnTotal,
117
+ };
118
+ }
119
+ function normalizeMilestoneUnlocked(event) {
120
+ const stream = asString(firstDefined(event, ["stream"]));
121
+ const milestone = asString(firstDefined(event, ["milestone"]));
122
+ const index = asNumber(firstDefined(event, ["index"]), 0);
123
+ const amount = asBigInt(firstDefined(event, ["amount"]));
124
+ const unlockTs = asBigInt(firstDefined(event, ["unlock_ts", "unlockTs"]));
125
+ if (!stream || !milestone || index === null || amount === null) {
126
+ return null;
127
+ }
128
+ return {
129
+ stream,
130
+ milestone,
131
+ index,
132
+ amount,
133
+ unlockTs,
134
+ };
135
+ }
136
+ function normalizeStreamCancelled(event) {
137
+ const stream = asString(firstDefined(event, ["stream"]));
138
+ const creator = asString(firstDefined(event, ["creator"]));
139
+ const recipient = asString(firstDefined(event, ["recipient"]));
140
+ const vestedAmount = asBigInt(firstDefined(event, ["vested_amount", "vestedAmount"]));
141
+ const returnedToCreator = asBigInt(firstDefined(event, ["returned_to_creator", "returnedToCreator"]));
142
+ const claimableForRecipient = asBigInt(firstDefined(event, ["claimable_for_recipient", "claimableForRecipient"]));
143
+ const timestamp = asBigInt(firstDefined(event, ["timestamp"]));
144
+ if (!stream || !creator || !recipient || vestedAmount === null || returnedToCreator === null || claimableForRecipient === null || timestamp === null) {
145
+ return null;
146
+ }
147
+ return {
148
+ stream,
149
+ creator,
150
+ recipient,
151
+ vestedAmount,
152
+ returnedToCreator,
153
+ claimableForRecipient,
154
+ timestamp,
155
+ };
156
+ }
157
+ function normalizeMilestoneEdited(event) {
158
+ const stream = asString(firstDefined(event, ["stream"]));
159
+ const milestone = asString(firstDefined(event, ["milestone"]));
160
+ const index = asNumber(firstDefined(event, ["index"]), 0);
161
+ const oldAmount = asBigInt(firstDefined(event, ["old_amount", "oldAmount"]));
162
+ const newAmount = asBigInt(firstDefined(event, ["new_amount", "newAmount"]));
163
+ const timestamp = asBigInt(firstDefined(event, ["timestamp"]));
164
+ if (!stream || !milestone || index === null || oldAmount === null || newAmount === null || timestamp === null) {
165
+ return null;
166
+ }
167
+ return {
168
+ stream,
169
+ milestone,
170
+ index,
171
+ oldAmount,
172
+ newAmount,
173
+ timestamp,
174
+ };
175
+ }
176
+ function normalizeLinearEdited(event) {
177
+ const stream = asString(firstDefined(event, ["stream"]));
178
+ const oldEndTs = asBigInt(firstDefined(event, ["old_end_ts", "oldEndTs"]));
179
+ const newEndTs = asBigInt(firstDefined(event, ["new_end_ts", "newEndTs"]));
180
+ const oldTotalAmount = asBigInt(firstDefined(event, ["old_total_amount", "oldTotalAmount"]));
181
+ const newTotalAmount = asBigInt(firstDefined(event, ["new_total_amount", "newTotalAmount"]));
182
+ const topupAmount = asBigInt(firstDefined(event, ["topup_amount", "topupAmount"]));
183
+ const timestamp = asBigInt(firstDefined(event, ["timestamp"]));
184
+ if (!stream || oldEndTs === null || newEndTs === null || oldTotalAmount === null || newTotalAmount === null || topupAmount === null || timestamp === null) {
185
+ return null;
186
+ }
187
+ return {
188
+ stream,
189
+ oldEndTs,
190
+ newEndTs,
191
+ oldTotalAmount,
192
+ newTotalAmount,
193
+ topupAmount,
194
+ timestamp,
195
+ };
196
+ }
197
+ function normalizeCliffEdited(event) {
198
+ const stream = asString(firstDefined(event, ["stream"]));
199
+ const oldCliffTs = asBigInt(firstDefined(event, ["old_cliff_ts", "oldCliffTs"]));
200
+ const newCliffTs = asBigInt(firstDefined(event, ["new_cliff_ts", "newCliffTs"]));
201
+ const timestamp = asBigInt(firstDefined(event, ["timestamp"]));
202
+ if (!stream || oldCliffTs === null || newCliffTs === null || timestamp === null) {
203
+ return null;
204
+ }
205
+ return {
206
+ stream,
207
+ oldCliffTs,
208
+ newCliffTs,
209
+ timestamp,
210
+ };
211
+ }
212
+ //# sourceMappingURL=eventNormalizer.js.map