@agelum/backend 0.1.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 +401 -0
- package/dist/client/hooks.d.ts +65 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +339 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +37 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/manager.d.ts +137 -0
- package/dist/client/manager.d.ts.map +1 -0
- package/dist/client/manager.js +292 -0
- package/dist/client/manager.js.map +1 -0
- package/dist/client/provider.d.ts +25 -0
- package/dist/client/provider.d.ts.map +1 -0
- package/dist/client/provider.js +121 -0
- package/dist/client/provider.js.map +1 -0
- package/dist/client/revalidation.d.ts +101 -0
- package/dist/client/revalidation.d.ts.map +1 -0
- package/dist/client/revalidation.js +313 -0
- package/dist/client/revalidation.js.map +1 -0
- package/dist/client/session.d.ts +84 -0
- package/dist/client/session.d.ts.map +1 -0
- package/dist/client/session.js +186 -0
- package/dist/client/session.js.map +1 -0
- package/dist/client/sse-client.d.ts +81 -0
- package/dist/client/sse-client.d.ts.map +1 -0
- package/dist/client/sse-client.js +221 -0
- package/dist/client/sse-client.js.map +1 -0
- package/dist/client/storage.d.ts +124 -0
- package/dist/client/storage.d.ts.map +1 -0
- package/dist/client/storage.js +441 -0
- package/dist/client/storage.js.map +1 -0
- package/dist/client/trpc.d.ts +12 -0
- package/dist/client/trpc.d.ts.map +1 -0
- package/dist/client/trpc.js +36 -0
- package/dist/client/trpc.js.map +1 -0
- package/dist/client/types.d.ts +10 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +3 -0
- package/dist/client/types.js.map +1 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +26 -0
- package/dist/client.js.map +1 -0
- package/dist/config/schema.d.ts +261 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +69 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/analyzer.d.ts +15 -0
- package/dist/core/analyzer.d.ts.map +1 -0
- package/dist/core/analyzer.js +217 -0
- package/dist/core/analyzer.js.map +1 -0
- package/dist/core/driver.d.ts +7 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/driver.js +261 -0
- package/dist/core/driver.js.map +1 -0
- package/dist/core/function.d.ts +97 -0
- package/dist/core/function.d.ts.map +1 -0
- package/dist/core/function.js +252 -0
- package/dist/core/function.js.map +1 -0
- package/dist/core/sse.d.ts +98 -0
- package/dist/core/sse.d.ts.map +1 -0
- package/dist/core/sse.js +331 -0
- package/dist/core/sse.js.map +1 -0
- package/dist/core/types.d.ts +179 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/examples/teamhub-integration.d.ts +56 -0
- package/dist/examples/teamhub-integration.d.ts.map +1 -0
- package/dist/examples/teamhub-integration.js +188 -0
- package/dist/examples/teamhub-integration.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/localStorage.d.ts +13 -0
- package/dist/providers/localStorage.d.ts.map +1 -0
- package/dist/providers/localStorage.js +64 -0
- package/dist/providers/localStorage.js.map +1 -0
- package/dist/providers/memory.d.ts +13 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/memory.js +40 -0
- package/dist/providers/memory.js.map +1 -0
- package/dist/providers/redis.d.ts +14 -0
- package/dist/providers/redis.d.ts.map +1 -0
- package/dist/providers/redis.js +36 -0
- package/dist/providers/redis.js.map +1 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +34 -0
- package/dist/server.js.map +1 -0
- package/dist/trpc/hooks.d.ts +82 -0
- package/dist/trpc/hooks.d.ts.map +1 -0
- package/dist/trpc/hooks.js +282 -0
- package/dist/trpc/hooks.js.map +1 -0
- package/dist/trpc/router.d.ts +75 -0
- package/dist/trpc/router.d.ts.map +1 -0
- package/dist/trpc/router.js +160 -0
- package/dist/trpc/router.js.map +1 -0
- package/dist/trpc/types.d.ts +105 -0
- package/dist/trpc/types.d.ts.map +1 -0
- package/dist/trpc/types.js +6 -0
- package/dist/trpc/types.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReactiveDb = createReactiveDb;
|
|
4
|
+
const analyzer_1 = require("./analyzer");
|
|
5
|
+
const memory_1 = require("../providers/memory");
|
|
6
|
+
const redis_1 = require("../providers/redis");
|
|
7
|
+
const sse_1 = require("./sse");
|
|
8
|
+
/**
|
|
9
|
+
* Reactive SQL driver that intercepts all Drizzle operations
|
|
10
|
+
*/
|
|
11
|
+
class ReactiveSqlDriver {
|
|
12
|
+
originalDb;
|
|
13
|
+
config;
|
|
14
|
+
cache;
|
|
15
|
+
subscribers = new Map();
|
|
16
|
+
queryMetadata = new Map();
|
|
17
|
+
constructor(originalDb, config) {
|
|
18
|
+
this.originalDb = originalDb;
|
|
19
|
+
this.config = config;
|
|
20
|
+
// Initialize cache provider based on config
|
|
21
|
+
this.cache = this.initializeCacheProvider();
|
|
22
|
+
// Wrap the original database methods
|
|
23
|
+
this.wrapDrizzleMethods();
|
|
24
|
+
}
|
|
25
|
+
initializeCacheProvider() {
|
|
26
|
+
const provider = this.config.cache?.server?.provider || 'memory';
|
|
27
|
+
switch (provider) {
|
|
28
|
+
case 'redis':
|
|
29
|
+
return new redis_1.RedisProvider();
|
|
30
|
+
case 'memory':
|
|
31
|
+
default:
|
|
32
|
+
return new memory_1.MemoryProvider();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
wrapDrizzleMethods() {
|
|
36
|
+
// Intercept the execute method which is the core SQL execution point
|
|
37
|
+
if (this.originalDb.execute) {
|
|
38
|
+
const originalExecute = this.originalDb.execute.bind(this.originalDb);
|
|
39
|
+
this.originalDb.execute = async (query, params) => {
|
|
40
|
+
return this.interceptQuery(query, params, originalExecute);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Intercept select/insert/update/delete methods
|
|
44
|
+
const methods = ['select', 'insert', 'update', 'delete'];
|
|
45
|
+
methods.forEach((method) => {
|
|
46
|
+
if (this.originalDb[method]) {
|
|
47
|
+
const originalMethod = this.originalDb[method].bind(this.originalDb);
|
|
48
|
+
this.originalDb[method] = (...args) => {
|
|
49
|
+
const queryBuilder = originalMethod(...args);
|
|
50
|
+
return this.wrapQueryBuilder(queryBuilder, method.toUpperCase());
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
wrapQueryBuilder(queryBuilder, operation) {
|
|
56
|
+
// Wrap query execution methods
|
|
57
|
+
if (queryBuilder.execute) {
|
|
58
|
+
const originalExecute = queryBuilder.execute.bind(queryBuilder);
|
|
59
|
+
queryBuilder.execute = async () => {
|
|
60
|
+
const sql = queryBuilder.toSQL?.() || { sql: 'unknown', params: [] };
|
|
61
|
+
return this.interceptQuery(sql, sql.params, originalExecute);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Wrap other execution methods like .all(), .get(), etc.
|
|
65
|
+
const execMethods = ['all', 'get', 'run', 'values'];
|
|
66
|
+
execMethods.forEach((method) => {
|
|
67
|
+
if (queryBuilder[method]) {
|
|
68
|
+
const originalMethod = queryBuilder[method].bind(queryBuilder);
|
|
69
|
+
queryBuilder[method] = async () => {
|
|
70
|
+
const sql = queryBuilder.toSQL?.() || { sql: 'unknown', params: [] };
|
|
71
|
+
return this.interceptQuery(sql, sql.params, originalMethod);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return queryBuilder;
|
|
76
|
+
}
|
|
77
|
+
async interceptQuery(query, params = [], originalExecute) {
|
|
78
|
+
// Extract SQL string from query object or use directly
|
|
79
|
+
const sqlString = typeof query === 'string' ? query : query.sql || 'unknown';
|
|
80
|
+
const queryParams = params || query.params || [];
|
|
81
|
+
// Analyze the SQL to understand what it does
|
|
82
|
+
const analysis = (0, analyzer_1.analyzeSql)(sqlString, queryParams);
|
|
83
|
+
const cacheKey = this.generateCacheKey(analysis, queryParams);
|
|
84
|
+
// Handle SELECT queries with caching
|
|
85
|
+
if (analysis.operation === 'SELECT') {
|
|
86
|
+
return this.handleSelectQuery(analysis, cacheKey, originalExecute);
|
|
87
|
+
}
|
|
88
|
+
// Handle mutations (INSERT/UPDATE/DELETE) with invalidation
|
|
89
|
+
return this.handleMutationQuery(analysis, originalExecute);
|
|
90
|
+
}
|
|
91
|
+
generateCacheKey(analysis, params) {
|
|
92
|
+
// Create a deterministic cache key from the query
|
|
93
|
+
const keyParts = [
|
|
94
|
+
analysis.table,
|
|
95
|
+
analysis.operation,
|
|
96
|
+
JSON.stringify(analysis.whereKeys.sort()),
|
|
97
|
+
JSON.stringify(params),
|
|
98
|
+
];
|
|
99
|
+
return keyParts.join(':');
|
|
100
|
+
}
|
|
101
|
+
async handleSelectQuery(analysis, cacheKey, originalExecute) {
|
|
102
|
+
// Try to get from cache first
|
|
103
|
+
const cached = await this.cache.get(cacheKey);
|
|
104
|
+
if (cached) {
|
|
105
|
+
console.log(`[ReactiveDB] Cache hit for ${analysis.table}`);
|
|
106
|
+
return cached;
|
|
107
|
+
}
|
|
108
|
+
// Execute the original query
|
|
109
|
+
console.log(`[ReactiveDB] Cache miss, executing query on ${analysis.table}`);
|
|
110
|
+
const result = await originalExecute();
|
|
111
|
+
// Cache the result
|
|
112
|
+
const ttl = this.getTtlForTable(analysis.table);
|
|
113
|
+
await this.cache.set(cacheKey, result, ttl);
|
|
114
|
+
// Store query metadata for invalidation
|
|
115
|
+
this.queryMetadata.set(cacheKey, {
|
|
116
|
+
key: cacheKey,
|
|
117
|
+
dependencies: [analysis.table],
|
|
118
|
+
lastExecuted: Date.now(),
|
|
119
|
+
ttl,
|
|
120
|
+
organizationId: analysis.organizationId,
|
|
121
|
+
});
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
async handleMutationQuery(analysis, originalExecute) {
|
|
125
|
+
console.log(`🔥 [ReactiveDB] MUTATION DETECTED: ${analysis.operation} on ${analysis.table} - This WILL trigger SSE broadcast`);
|
|
126
|
+
// Execute the mutation
|
|
127
|
+
const result = await originalExecute();
|
|
128
|
+
// Invalidate related queries
|
|
129
|
+
await this.invalidateRelatedQueries(analysis);
|
|
130
|
+
// Broadcast invalidation events
|
|
131
|
+
await this.broadcastInvalidation(analysis);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
async invalidateRelatedQueries(analysis) {
|
|
135
|
+
const { table } = analysis;
|
|
136
|
+
const relatedTables = this.config.relations[table] || [];
|
|
137
|
+
// Find all queries that depend on this table or related tables
|
|
138
|
+
const tablesToInvalidate = [table, ...relatedTables];
|
|
139
|
+
const keysToInvalidate = [];
|
|
140
|
+
for (const [cacheKey, metadata] of this.queryMetadata.entries()) {
|
|
141
|
+
const shouldInvalidate = metadata.dependencies.some((dep) => tablesToInvalidate.includes(dep));
|
|
142
|
+
if (shouldInvalidate) {
|
|
143
|
+
keysToInvalidate.push(cacheKey);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Invalidate cache entries
|
|
147
|
+
console.log(`[ReactiveDB] Invalidating ${keysToInvalidate.length} cached queries for ${table}`);
|
|
148
|
+
await Promise.all(keysToInvalidate.map((key) => this.cache.del(key)));
|
|
149
|
+
// Remove metadata for invalidated queries
|
|
150
|
+
keysToInvalidate.forEach((key) => this.queryMetadata.delete(key));
|
|
151
|
+
}
|
|
152
|
+
async broadcastInvalidation(analysis) {
|
|
153
|
+
const { table, organizationId } = analysis;
|
|
154
|
+
if (!organizationId)
|
|
155
|
+
return;
|
|
156
|
+
const subscribers = this.subscribers.get(organizationId);
|
|
157
|
+
if (!subscribers)
|
|
158
|
+
return;
|
|
159
|
+
// Create invalidation event
|
|
160
|
+
const event = {
|
|
161
|
+
type: 'invalidation',
|
|
162
|
+
table,
|
|
163
|
+
organizationId,
|
|
164
|
+
affectedQueries: Array.from(this.queryMetadata.keys()).filter((key) => {
|
|
165
|
+
const metadata = this.queryMetadata.get(key);
|
|
166
|
+
return metadata?.dependencies.includes(table);
|
|
167
|
+
}),
|
|
168
|
+
eventId: `evt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
169
|
+
requiresAck: true,
|
|
170
|
+
timestamp: Date.now(),
|
|
171
|
+
};
|
|
172
|
+
// Notify all subscribers
|
|
173
|
+
subscribers.forEach((callback) => {
|
|
174
|
+
try {
|
|
175
|
+
callback(event);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error('[ReactiveDB] Error in invalidation callback:', error);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
// Broadcast to SSE subscribers for real-time updates
|
|
182
|
+
try {
|
|
183
|
+
await (0, sse_1.broadcastInvalidation)(organizationId, {
|
|
184
|
+
type: 'invalidation',
|
|
185
|
+
table,
|
|
186
|
+
organizationId,
|
|
187
|
+
affectedQueries: event.affectedQueries,
|
|
188
|
+
timestamp: Date.now(),
|
|
189
|
+
operation: analysis.operation,
|
|
190
|
+
affectedKeys: analysis.whereKeys,
|
|
191
|
+
});
|
|
192
|
+
console.log(`[ReactiveDriver] SSE broadcast sent for org: ${organizationId}, table: ${table}`);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.warn('[ReactiveDriver] SSE broadcast failed:', error);
|
|
196
|
+
// Continue execution - local invalidation still works
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
getTtlForTable(table) {
|
|
200
|
+
// Smart TTL based on table type
|
|
201
|
+
switch (table) {
|
|
202
|
+
case 'agent':
|
|
203
|
+
case 'organization':
|
|
204
|
+
return 300; // 5 minutes for relatively stable data
|
|
205
|
+
case 'message':
|
|
206
|
+
return 60; // 1 minute for frequently changing data
|
|
207
|
+
case 'memory':
|
|
208
|
+
return 180; // 3 minutes for memory data
|
|
209
|
+
default:
|
|
210
|
+
return 120; // 2 minutes default
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Public methods for the ReactiveDb interface
|
|
214
|
+
async query(sql, params) {
|
|
215
|
+
return this.interceptQuery(sql, params, async () => {
|
|
216
|
+
return await this.originalDb.execute(sql, params);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
getCache() {
|
|
220
|
+
return this.cache;
|
|
221
|
+
}
|
|
222
|
+
subscribe(organizationId, callback) {
|
|
223
|
+
if (!this.subscribers.has(organizationId)) {
|
|
224
|
+
this.subscribers.set(organizationId, new Set());
|
|
225
|
+
}
|
|
226
|
+
this.subscribers.get(organizationId).add(callback);
|
|
227
|
+
// Return unsubscribe function
|
|
228
|
+
return () => {
|
|
229
|
+
const orgSubscribers = this.subscribers.get(organizationId);
|
|
230
|
+
if (orgSubscribers) {
|
|
231
|
+
orgSubscribers.delete(callback);
|
|
232
|
+
if (orgSubscribers.size === 0) {
|
|
233
|
+
this.subscribers.delete(organizationId);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
getOriginalDb() {
|
|
239
|
+
return this.originalDb;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create a reactive database instance
|
|
244
|
+
* This is the main entry point for the library
|
|
245
|
+
*/
|
|
246
|
+
function createReactiveDb(drizzleDb, config) {
|
|
247
|
+
console.log('[ReactiveDB] Initializing reactive database with config:', {
|
|
248
|
+
relations: Object.keys(config.relations),
|
|
249
|
+
cacheProvider: config.cache?.server?.provider || 'memory',
|
|
250
|
+
realtimeEnabled: config.realtime?.enabled ?? true,
|
|
251
|
+
});
|
|
252
|
+
const driver = new ReactiveSqlDriver(drizzleDb, config);
|
|
253
|
+
return {
|
|
254
|
+
db: driver.getOriginalDb(),
|
|
255
|
+
config,
|
|
256
|
+
query: driver.query.bind(driver),
|
|
257
|
+
getCache: driver.getCache.bind(driver),
|
|
258
|
+
subscribe: driver.subscribe.bind(driver),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/core/driver.ts"],"names":[],"mappings":";;AAqTA,4CAmBC;AAhUD,yCAAuC;AACvC,gDAAoD;AACpD,8CAAkD;AAClD,+BAA6C;AAE7C;;GAEG;AACH,MAAM,iBAAiB;IAKD;IAAyB;IAJrC,KAAK,CAAe;IACpB,WAAW,GAAG,IAAI,GAAG,EAAqC,CAAA;IAC1D,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAA;IAExD,YAAoB,UAAe,EAAU,MAAsB;QAA/C,eAAU,GAAV,UAAU,CAAK;QAAU,WAAM,GAAN,MAAM,CAAgB;QACjE,4CAA4C;QAC5C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;QAE3C,qCAAqC;QACrC,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAEO,uBAAuB;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,IAAI,QAAQ,CAAA;QAEhE,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,OAAO;gBACV,OAAO,IAAI,qBAAa,EAAE,CAAA;YAC5B,KAAK,QAAQ,CAAC;YACd;gBACE,OAAO,IAAI,uBAAc,EAAE,CAAA;QAC/B,CAAC;IACH,CAAC;IAEO,kBAAkB;QACxB,qEAAqE;QACrE,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,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AAS,CAAC;QACxC,aAAa,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,IAAI,QAAQ;QACzD,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI;KAClD,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAEvD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,aAAa,EAAE;QAC1B,MAAM;QACN,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;KACzC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define reactive functions with explicit dependencies
|
|
3
|
+
* Core building block that works both standalone and with tRPC
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { ReactiveDb } from './types';
|
|
7
|
+
export interface ReactiveFunctionConfig<TInput = any, TOutput = any> {
|
|
8
|
+
/** Function name (used for cache keys and tRPC procedure names) */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Input validation schema */
|
|
11
|
+
input: z.ZodType<TInput>;
|
|
12
|
+
/** Tables this function depends on (for cache invalidation) */
|
|
13
|
+
dependencies: string[];
|
|
14
|
+
/** Optional: Specific invalidation conditions */
|
|
15
|
+
invalidateWhen?: Record<string, (change: InvalidationChange) => boolean>;
|
|
16
|
+
/** Cache configuration */
|
|
17
|
+
cache?: {
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
ttl?: number;
|
|
20
|
+
key?: (input: TInput) => string;
|
|
21
|
+
};
|
|
22
|
+
/** The actual function logic - clean and simple */
|
|
23
|
+
handler: (input: TInput, db: ReactiveDb) => Promise<TOutput>;
|
|
24
|
+
}
|
|
25
|
+
export interface InvalidationChange {
|
|
26
|
+
table: string;
|
|
27
|
+
operation: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
28
|
+
keys: string[];
|
|
29
|
+
timestamp: number;
|
|
30
|
+
}
|
|
31
|
+
export interface ReactiveFunction<TInput = any, TOutput = any> {
|
|
32
|
+
/** Function configuration */
|
|
33
|
+
config: ReactiveFunctionConfig<TInput, TOutput>;
|
|
34
|
+
/** Execute the function standalone (server-side) */
|
|
35
|
+
execute: (input: TInput, db: ReactiveDb) => Promise<TOutput>;
|
|
36
|
+
/** Get cache key for input */
|
|
37
|
+
getCacheKey: (input: TInput) => string;
|
|
38
|
+
/** Check if function should be invalidated by a change */
|
|
39
|
+
shouldInvalidate: (change: InvalidationChange) => boolean;
|
|
40
|
+
/** Get function metadata for tRPC integration */
|
|
41
|
+
getMetadata: () => ReactiveFunctionMetadata;
|
|
42
|
+
/** Get tRPC-compatible handler (for tRPC router integration) */
|
|
43
|
+
getTrpcHandler: (db: ReactiveDb) => (opts: any) => Promise<TOutput>;
|
|
44
|
+
}
|
|
45
|
+
export interface ReactiveFunctionMetadata {
|
|
46
|
+
name: string;
|
|
47
|
+
dependencies: string[];
|
|
48
|
+
cacheEnabled: boolean;
|
|
49
|
+
cacheTtl: number;
|
|
50
|
+
hasInvalidationRules: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Define a reactive function - the core building block
|
|
54
|
+
*/
|
|
55
|
+
export declare function defineReactiveFunction<TInput = any, TOutput = any>(config: ReactiveFunctionConfig<TInput, TOutput>): ReactiveFunction<TInput, TOutput>;
|
|
56
|
+
/**
|
|
57
|
+
* Registry for managing reactive functions
|
|
58
|
+
*/
|
|
59
|
+
export declare class ReactiveFunctionRegistry {
|
|
60
|
+
private functions;
|
|
61
|
+
/**
|
|
62
|
+
* Register a reactive function
|
|
63
|
+
*/
|
|
64
|
+
register(name: string, fn: ReactiveFunction): void;
|
|
65
|
+
/**
|
|
66
|
+
* Execute a registered function
|
|
67
|
+
*/
|
|
68
|
+
execute<T>(name: string, input: any, db: ReactiveDb): Promise<T>;
|
|
69
|
+
/**
|
|
70
|
+
* Get function by name
|
|
71
|
+
*/
|
|
72
|
+
get(name: string): ReactiveFunction | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Get all registered function names
|
|
75
|
+
*/
|
|
76
|
+
getFunctionNames(): string[];
|
|
77
|
+
/**
|
|
78
|
+
* Get registry statistics
|
|
79
|
+
*/
|
|
80
|
+
getStats(): {
|
|
81
|
+
totalFunctions: number;
|
|
82
|
+
functionsByDependency: Record<string, string[]>;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Clear all functions
|
|
86
|
+
*/
|
|
87
|
+
clear(): void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get or create global reactive function registry
|
|
91
|
+
*/
|
|
92
|
+
export declare function getReactiveFunctionRegistry(): ReactiveFunctionRegistry;
|
|
93
|
+
/**
|
|
94
|
+
* Helper to register a reactive function globally
|
|
95
|
+
*/
|
|
96
|
+
export declare function registerReactiveFunction(name: string, config: ReactiveFunctionConfig): ReactiveFunction;
|
|
97
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../src/core/function.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,GAAG,EAAE,OAAO,GAAG,GAAG;IACjE,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAA;IAEZ,8BAA8B;IAC9B,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAExB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,EAAE,CAAA;IA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+
* Core building block that works both standalone and with tRPC
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ReactiveFunctionRegistry = void 0;
|
|
8
|
+
exports.defineReactiveFunction = defineReactiveFunction;
|
|
9
|
+
exports.getReactiveFunctionRegistry = getReactiveFunctionRegistry;
|
|
10
|
+
exports.registerReactiveFunction = registerReactiveFunction;
|
|
11
|
+
/**
|
|
12
|
+
* Define a reactive function - the core building block
|
|
13
|
+
*/
|
|
14
|
+
function defineReactiveFunction(config) {
|
|
15
|
+
// Validate configuration
|
|
16
|
+
if (!config.name) {
|
|
17
|
+
throw new Error('ReactiveFunction requires name');
|
|
18
|
+
}
|
|
19
|
+
if (!config.input) {
|
|
20
|
+
throw new Error('ReactiveFunction requires input schema');
|
|
21
|
+
}
|
|
22
|
+
if (!config.dependencies || config.dependencies.length === 0) {
|
|
23
|
+
throw new Error('ReactiveFunction requires dependencies array');
|
|
24
|
+
}
|
|
25
|
+
if (!config.handler) {
|
|
26
|
+
throw new Error('ReactiveFunction requires handler function');
|
|
27
|
+
}
|
|
28
|
+
// Default cache configuration
|
|
29
|
+
const cacheConfig = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
ttl: 300, // 5 minutes default
|
|
32
|
+
key: (input) => `${config.name}:${JSON.stringify(input)}`,
|
|
33
|
+
...config.cache,
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Execute the function (standalone server-side execution)
|
|
37
|
+
*/
|
|
38
|
+
const execute = async (input, db) => {
|
|
39
|
+
// Validate input
|
|
40
|
+
const validatedInput = config.input.parse(input);
|
|
41
|
+
// Generate cache key
|
|
42
|
+
const cacheKey = getCacheKey(validatedInput);
|
|
43
|
+
console.log(`[ReactiveFunction] Executing function with cache key: ${cacheKey}`);
|
|
44
|
+
try {
|
|
45
|
+
// Check cache if enabled
|
|
46
|
+
if (cacheConfig.enabled) {
|
|
47
|
+
const cached = await getCachedResult(db, cacheKey);
|
|
48
|
+
if (cached && !isCacheStale(cached, cacheConfig.ttl)) {
|
|
49
|
+
console.log(`[ReactiveFunction] Cache hit for ${cacheKey}`);
|
|
50
|
+
return cached.data;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Execute function handler - clean and simple
|
|
54
|
+
const result = await config.handler(validatedInput, db);
|
|
55
|
+
// Cache result if enabled
|
|
56
|
+
if (cacheConfig.enabled) {
|
|
57
|
+
await cacheResult(db, cacheKey, result, cacheConfig.ttl, {
|
|
58
|
+
dependencies: config.dependencies,
|
|
59
|
+
timestamp: Date.now(),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(`[ReactiveFunction] Execution error for ${cacheKey}:`, error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Get cache key for input
|
|
71
|
+
*/
|
|
72
|
+
const getCacheKey = (input) => {
|
|
73
|
+
return cacheConfig.key(input);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Check if function should be invalidated by a change
|
|
77
|
+
*/
|
|
78
|
+
const shouldInvalidate = (change) => {
|
|
79
|
+
// Check if the changed table is in our dependencies
|
|
80
|
+
if (!config.dependencies.includes(change.table)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
// Check custom invalidation rules
|
|
84
|
+
if (config.invalidateWhen && config.invalidateWhen[change.table]) {
|
|
85
|
+
try {
|
|
86
|
+
return config.invalidateWhen[change.table](change);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.warn('[ReactiveFunction] Invalidation rule error:', error);
|
|
90
|
+
// Default to invalidate on error for safety
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Default: invalidate if table is in dependencies
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Get function metadata for tRPC integration
|
|
99
|
+
*/
|
|
100
|
+
const getMetadata = () => {
|
|
101
|
+
return {
|
|
102
|
+
name: config.name,
|
|
103
|
+
dependencies: config.dependencies,
|
|
104
|
+
cacheEnabled: cacheConfig.enabled,
|
|
105
|
+
cacheTtl: cacheConfig.ttl,
|
|
106
|
+
hasInvalidationRules: !!config.invalidateWhen,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Get tRPC-compatible handler that wraps the reactive function
|
|
111
|
+
*/
|
|
112
|
+
const getTrpcHandler = (db) => {
|
|
113
|
+
return async (opts) => {
|
|
114
|
+
// Simply delegate to the execute method with the reactive database
|
|
115
|
+
return execute(opts.input, db);
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
config,
|
|
120
|
+
execute,
|
|
121
|
+
getCacheKey,
|
|
122
|
+
shouldInvalidate,
|
|
123
|
+
getMetadata,
|
|
124
|
+
getTrpcHandler,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Registry for managing reactive functions
|
|
129
|
+
*/
|
|
130
|
+
class ReactiveFunctionRegistry {
|
|
131
|
+
functions = new Map();
|
|
132
|
+
/**
|
|
133
|
+
* Register a reactive function
|
|
134
|
+
*/
|
|
135
|
+
register(name, fn) {
|
|
136
|
+
this.functions.set(name, fn);
|
|
137
|
+
console.log(`[ReactiveRegistry] Registered function: ${name}`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Execute a registered function
|
|
141
|
+
*/
|
|
142
|
+
async execute(name, input, db) {
|
|
143
|
+
const fn = this.functions.get(name);
|
|
144
|
+
if (!fn) {
|
|
145
|
+
throw new Error(`ReactiveFunction '${name}' not found`);
|
|
146
|
+
}
|
|
147
|
+
return fn.execute(input, db);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get function by name
|
|
151
|
+
*/
|
|
152
|
+
get(name) {
|
|
153
|
+
return this.functions.get(name);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get all registered function names
|
|
157
|
+
*/
|
|
158
|
+
getFunctionNames() {
|
|
159
|
+
return Array.from(this.functions.keys());
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get registry statistics
|
|
163
|
+
*/
|
|
164
|
+
getStats() {
|
|
165
|
+
const functionsByDependency = {};
|
|
166
|
+
for (const [name, fn] of this.functions) {
|
|
167
|
+
const metadata = fn.getMetadata();
|
|
168
|
+
for (const dep of metadata.dependencies) {
|
|
169
|
+
if (!functionsByDependency[dep]) {
|
|
170
|
+
functionsByDependency[dep] = [];
|
|
171
|
+
}
|
|
172
|
+
functionsByDependency[dep].push(name);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
totalFunctions: this.functions.size,
|
|
177
|
+
functionsByDependency,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Clear all functions
|
|
182
|
+
*/
|
|
183
|
+
clear() {
|
|
184
|
+
this.functions.clear();
|
|
185
|
+
console.log('[ReactiveRegistry] Cleared all functions');
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.ReactiveFunctionRegistry = ReactiveFunctionRegistry;
|
|
189
|
+
// Global registry instance
|
|
190
|
+
let globalRegistry = null;
|
|
191
|
+
/**
|
|
192
|
+
* Get or create global reactive function registry
|
|
193
|
+
*/
|
|
194
|
+
function getReactiveFunctionRegistry() {
|
|
195
|
+
if (!globalRegistry) {
|
|
196
|
+
globalRegistry = new ReactiveFunctionRegistry();
|
|
197
|
+
}
|
|
198
|
+
return globalRegistry;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Helper to register a reactive function globally
|
|
202
|
+
*/
|
|
203
|
+
function registerReactiveFunction(name, config) {
|
|
204
|
+
const fn = defineReactiveFunction(config);
|
|
205
|
+
const registry = getReactiveFunctionRegistry();
|
|
206
|
+
registry.register(name, fn);
|
|
207
|
+
return fn;
|
|
208
|
+
}
|
|
209
|
+
// Helper functions for caching (simplified for now)
|
|
210
|
+
/**
|
|
211
|
+
* Get cached result from database
|
|
212
|
+
*/
|
|
213
|
+
async function getCachedResult(db, cacheKey) {
|
|
214
|
+
try {
|
|
215
|
+
// In a real implementation, this would use the cache provider
|
|
216
|
+
// For now, we simulate cache behavior
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.warn(`[ReactiveFunction] Cache get error:`, error);
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Check if cached result is stale
|
|
226
|
+
*/
|
|
227
|
+
function isCacheStale(cached, ttl) {
|
|
228
|
+
const age = Date.now() - cached.timestamp;
|
|
229
|
+
return age > ttl * 1000; // Convert TTL to milliseconds
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Cache function result
|
|
233
|
+
*/
|
|
234
|
+
async function cacheResult(db, cacheKey, data, ttl, metadata) {
|
|
235
|
+
try {
|
|
236
|
+
// In a real implementation, this would use the cache provider
|
|
237
|
+
console.log(`[ReactiveFunction] Caching result for ${cacheKey} with TTL ${ttl}s`);
|
|
238
|
+
// Store with metadata for invalidation
|
|
239
|
+
const cacheEntry = {
|
|
240
|
+
data,
|
|
241
|
+
timestamp: Date.now(),
|
|
242
|
+
ttl: ttl * 1000,
|
|
243
|
+
metadata,
|
|
244
|
+
};
|
|
245
|
+
// This would actually cache the data
|
|
246
|
+
// await db.setCache(cacheKey, cacheEntry, ttl)
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
console.warn(`[ReactiveFunction] Cache set error:`, error);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../src/core/function.ts"],"names":[],"mappings":";AAAA;;;GAGG;;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