@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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example integration with Agelum using the corrected reactive function architecture
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactiveConfig } from '../core/types';
|
|
5
|
+
export declare const agelumReactiveConfig: ReactiveConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Get all agents for an organization
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAgents: import("../core/function").ReactiveFunction<{
|
|
10
|
+
organizationId: string;
|
|
11
|
+
}, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Get agent with detailed statistics
|
|
14
|
+
*/
|
|
15
|
+
export declare const getAgentWithStats: import("../core/function").ReactiveFunction<{
|
|
16
|
+
organizationId: string;
|
|
17
|
+
agentId: string;
|
|
18
|
+
}, {
|
|
19
|
+
agent: any;
|
|
20
|
+
stats: {
|
|
21
|
+
messageCount: any;
|
|
22
|
+
memoryCount: any;
|
|
23
|
+
lastActive: any;
|
|
24
|
+
};
|
|
25
|
+
recentMessages: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Update agent data
|
|
29
|
+
*/
|
|
30
|
+
export declare const updateAgent: import("../core/function").ReactiveFunction<{
|
|
31
|
+
organizationId: string;
|
|
32
|
+
data: {
|
|
33
|
+
name?: string | undefined;
|
|
34
|
+
role?: string | undefined;
|
|
35
|
+
systemPrompt?: string | undefined;
|
|
36
|
+
isActive?: boolean | undefined;
|
|
37
|
+
};
|
|
38
|
+
id: string;
|
|
39
|
+
}, unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* Example: How to use getAgents function
|
|
42
|
+
*/
|
|
43
|
+
export declare function loadAgentsExample(organizationId: string, reactiveDb: any): Promise<unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Example: How to use getAgentWithStats function
|
|
46
|
+
*/
|
|
47
|
+
export declare function loadAgentDetailsExample(organizationId: string, agentId: string, reactiveDb: any): Promise<{
|
|
48
|
+
agent: any;
|
|
49
|
+
stats: {
|
|
50
|
+
messageCount: any;
|
|
51
|
+
memoryCount: any;
|
|
52
|
+
lastActive: any;
|
|
53
|
+
};
|
|
54
|
+
recentMessages: unknown;
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=teamhub-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamhub-integration.d.ts","sourceRoot":"","sources":["../../src/examples/teamhub-integration.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGnD,eAAO,MAAM,oBAAoB,EAAE,cAelC,CAAA;AAID;;GAEG;AACH,eAAO,MAAM,SAAS;;WAgBpB,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;EA8D5B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;WAoCtB,CAAA;AAIF;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,GAAG,oBAMhB;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,GAAG;;;;;;;;GAYhB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Example integration with Agelum using the corrected reactive function architecture
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateAgent = exports.getAgentWithStats = exports.getAgents = exports.agelumReactiveConfig = void 0;
|
|
7
|
+
exports.loadAgentsExample = loadAgentsExample;
|
|
8
|
+
exports.loadAgentDetailsExample = loadAgentDetailsExample;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const function_1 = require("../core/function");
|
|
11
|
+
// Generic Agelum reactive configuration (no hardcoded fields)
|
|
12
|
+
exports.agelumReactiveConfig = {
|
|
13
|
+
relations: {
|
|
14
|
+
agent: ['message.fromAgentId', 'memory.agentId'],
|
|
15
|
+
organization: ['agent.organizationId', 'tool.organizationId'],
|
|
16
|
+
message: ['agent.fromAgentId', 'agent.toAgentId'],
|
|
17
|
+
memory: ['agent.agentId'],
|
|
18
|
+
tool: ['organization.id'],
|
|
19
|
+
},
|
|
20
|
+
cache: {
|
|
21
|
+
server: { provider: 'memory' },
|
|
22
|
+
client: { provider: 'localStorage' },
|
|
23
|
+
},
|
|
24
|
+
realtime: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
// Example reactive functions using the corrected API
|
|
29
|
+
/**
|
|
30
|
+
* Get all agents for an organization
|
|
31
|
+
*/
|
|
32
|
+
exports.getAgents = (0, function_1.defineReactiveFunction)({
|
|
33
|
+
name: 'agents.getAll',
|
|
34
|
+
input: zod_1.z.object({
|
|
35
|
+
organizationId: zod_1.z.string(),
|
|
36
|
+
}),
|
|
37
|
+
dependencies: ['agent'],
|
|
38
|
+
handler: async (input, db) => {
|
|
39
|
+
return db.query(`
|
|
40
|
+
SELECT * FROM agents
|
|
41
|
+
WHERE organization_id = $1
|
|
42
|
+
ORDER BY created_at DESC
|
|
43
|
+
`, [input.organizationId]);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Get agent with detailed statistics
|
|
48
|
+
*/
|
|
49
|
+
exports.getAgentWithStats = (0, function_1.defineReactiveFunction)({
|
|
50
|
+
name: 'agents.getWithStats',
|
|
51
|
+
input: zod_1.z.object({
|
|
52
|
+
organizationId: zod_1.z.string(),
|
|
53
|
+
agentId: zod_1.z.string(),
|
|
54
|
+
}),
|
|
55
|
+
dependencies: ['agent', 'message', 'memory'],
|
|
56
|
+
invalidateWhen: {
|
|
57
|
+
agent: (change) => change.keys.includes('agentId'),
|
|
58
|
+
message: (change) => change.keys.includes('agentId'),
|
|
59
|
+
memory: (change) => change.keys.includes('agentId'),
|
|
60
|
+
},
|
|
61
|
+
cache: {
|
|
62
|
+
ttl: 180, // 3 minutes for detailed stats
|
|
63
|
+
},
|
|
64
|
+
handler: async (input, db) => {
|
|
65
|
+
const [agent, messageCount, memoryCount, lastMessage] = await Promise.all([
|
|
66
|
+
db.query(`
|
|
67
|
+
SELECT * FROM agents
|
|
68
|
+
WHERE id = $1 AND organization_id = $2
|
|
69
|
+
`, [input.agentId, input.organizationId]),
|
|
70
|
+
db.query(`
|
|
71
|
+
SELECT COUNT(*) as count FROM messages
|
|
72
|
+
WHERE from_agent_id = $1
|
|
73
|
+
`, [input.agentId]),
|
|
74
|
+
db.query(`
|
|
75
|
+
SELECT COUNT(*) as count FROM memory
|
|
76
|
+
WHERE agent_id = $1
|
|
77
|
+
`, [input.agentId]),
|
|
78
|
+
db.query(`
|
|
79
|
+
SELECT * FROM messages
|
|
80
|
+
WHERE from_agent_id = $1
|
|
81
|
+
ORDER BY created_at DESC
|
|
82
|
+
LIMIT 1
|
|
83
|
+
`, [input.agentId]),
|
|
84
|
+
]);
|
|
85
|
+
return {
|
|
86
|
+
agent: agent[0],
|
|
87
|
+
stats: {
|
|
88
|
+
messageCount: messageCount[0]?.count || 0,
|
|
89
|
+
memoryCount: memoryCount[0]?.count || 0,
|
|
90
|
+
lastActive: lastMessage[0]?.created_at || null,
|
|
91
|
+
},
|
|
92
|
+
recentMessages: lastMessage,
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Update agent data
|
|
98
|
+
*/
|
|
99
|
+
exports.updateAgent = (0, function_1.defineReactiveFunction)({
|
|
100
|
+
name: 'agents.update',
|
|
101
|
+
input: zod_1.z.object({
|
|
102
|
+
organizationId: zod_1.z.string(),
|
|
103
|
+
id: zod_1.z.string(),
|
|
104
|
+
data: zod_1.z.object({
|
|
105
|
+
name: zod_1.z.string().optional(),
|
|
106
|
+
role: zod_1.z.string().optional(),
|
|
107
|
+
systemPrompt: zod_1.z.string().optional(),
|
|
108
|
+
isActive: zod_1.z.boolean().optional(),
|
|
109
|
+
}),
|
|
110
|
+
}),
|
|
111
|
+
dependencies: ['agent'],
|
|
112
|
+
invalidateWhen: {
|
|
113
|
+
agent: (change) => change.keys.includes('id'),
|
|
114
|
+
},
|
|
115
|
+
handler: async (input, db) => {
|
|
116
|
+
const updateFields = Object.entries(input.data)
|
|
117
|
+
.filter(([_, value]) => value !== undefined)
|
|
118
|
+
.map(([key, _], index) => `${key} = $${index + 3}`)
|
|
119
|
+
.join(', ');
|
|
120
|
+
const updateValues = Object.values(input.data).filter((value) => value !== undefined);
|
|
121
|
+
return db.query(`
|
|
122
|
+
UPDATE agents
|
|
123
|
+
SET ${updateFields}, updated_at = NOW()
|
|
124
|
+
WHERE id = $1 AND organization_id = $2
|
|
125
|
+
RETURNING *
|
|
126
|
+
`, [input.id, input.organizationId, ...updateValues]);
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
// Example usage patterns (React components would go in separate .tsx files)
|
|
130
|
+
/**
|
|
131
|
+
* Example: How to use getAgents function
|
|
132
|
+
*/
|
|
133
|
+
async function loadAgentsExample(organizationId, reactiveDb) {
|
|
134
|
+
// Standalone usage (server-side)
|
|
135
|
+
const agents = await exports.getAgents.execute({ organizationId }, reactiveDb);
|
|
136
|
+
console.log('Loaded agents:', agents.length);
|
|
137
|
+
return agents;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Example: How to use getAgentWithStats function
|
|
141
|
+
*/
|
|
142
|
+
async function loadAgentDetailsExample(organizationId, agentId, reactiveDb) {
|
|
143
|
+
// This function can be called both ways:
|
|
144
|
+
// 1. Standalone: await getAgentWithStats.execute({ organizationId, agentId }, reactiveDb)
|
|
145
|
+
// 2. Via tRPC: trpc.agents.getWithStats.useQuery({ organizationId, agentId })
|
|
146
|
+
const agentDetails = await exports.getAgentWithStats.execute({ organizationId, agentId }, reactiveDb);
|
|
147
|
+
console.log('Loaded agent details for:', agentId);
|
|
148
|
+
return agentDetails;
|
|
149
|
+
}
|
|
150
|
+
// Example of how to set up tRPC router with these functions
|
|
151
|
+
/*
|
|
152
|
+
import { createReactiveRouter } from '../trpc/router'
|
|
153
|
+
|
|
154
|
+
export function createTeamHubRouter(db, config) {
|
|
155
|
+
return createReactiveRouter({ db, config })
|
|
156
|
+
.addQuery(getAgents) // Uses 'agents.getAll' automatically
|
|
157
|
+
.addQuery(getAgentWithStats) // Uses 'agents.getWithStats' automatically
|
|
158
|
+
.addMutation(updateAgent) // Uses 'agents.update' automatically
|
|
159
|
+
.build()
|
|
160
|
+
}
|
|
161
|
+
*/
|
|
162
|
+
// Example of server-side usage
|
|
163
|
+
/*
|
|
164
|
+
export async function serverSideExample(reactiveDb) {
|
|
165
|
+
// Functions can be executed directly on the server
|
|
166
|
+
const agents = await getAgents.execute(
|
|
167
|
+
{ organizationId: 'org-123' },
|
|
168
|
+
reactiveDb
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
const agentDetails = await getAgentWithStats.execute(
|
|
172
|
+
{ organizationId: 'org-123', agentId: 'agent-456' },
|
|
173
|
+
reactiveDb
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const updatedAgent = await updateAgent.execute(
|
|
177
|
+
{
|
|
178
|
+
organizationId: 'org-123',
|
|
179
|
+
id: 'agent-456',
|
|
180
|
+
data: { name: 'Updated Agent Name' }
|
|
181
|
+
},
|
|
182
|
+
reactiveDb
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
return { agents, agentDetails, updatedAgent }
|
|
186
|
+
}
|
|
187
|
+
*/
|
|
188
|
+
//# sourceMappingURL=teamhub-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teamhub-integration.js","sourceRoot":"","sources":["../../src/examples/teamhub-integration.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAgKH,8CAQC;AAKD,0DAeC;AA1LD,6BAAuB;AACvB,+CAAyD;AAGzD,8DAA8D;AACjD,QAAA,oBAAoB,GAAmB;IAClD,SAAS,EAAE;QACT,KAAK,EAAE,CAAC,qBAAqB,EAAE,gBAAgB,CAAC;QAChD,YAAY,EAAE,CAAC,sBAAsB,EAAE,qBAAqB,CAAC;QAC7D,OAAO,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,CAAC;QACjD,MAAM,EAAE,CAAC,eAAe,CAAC;QACzB,IAAI,EAAE,CAAC,iBAAiB,CAAC;KAC1B;IACD,KAAK,EAAE;QACL,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAC9B,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE;KACrC;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,IAAI;KACd;CACF,CAAA;AAED,qDAAqD;AAErD;;GAEG;AACU,QAAA,SAAS,GAAG,IAAA,iCAAsB,EAAC;IAC9C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE;KAC3B,CAAC;IACF,YAAY,EAAE,CAAC,OAAO,CAAC;IACvB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC3B,OAAO,EAAE,CAAC,KAAK,CACb;;;;KAID,EACC,CAAC,KAAK,CAAC,cAAc,CAAC,CACvB,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,iCAAsB,EAAC;IACtD,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,OAAC,C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CAAC,IAAI,CAAC,CAAA;QAEb,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CACnD,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAC/B,CAAA;QAED,OAAO,EAAE,CAAC,KAAK,CACb;;YAEM,YAAY;;;KAGnB,EACC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,cAAc,EAAE,GAAG,YAAY,CAAC,CAClD,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAEF,4EAA4E;AAE5E;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,cAAsB,EACtB,UAAe;IAEf,iCAAiC;IACjC,MAAM,MAAM,GAAG,MAAM,iBAAS,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,EAAE,UAAU,CAAC,CAAA;IACtE,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAG,MAAgB,CAAC,MAAM,CAAC,CAAA;IACvD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAC3C,cAAsB,EACtB,OAAe,EACf,UAAe;IAEf,yCAAyC;IACzC,0FAA0F;IAC1F,8EAA8E;IAE9E,MAAM,YAAY,GAAG,MAAM,yBAAiB,CAAC,OAAO,CAClD,EAAE,cAAc,EAAE,OAAO,EAAE,EAC3B,UAAU,CACX,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAA;IACjD,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,4DAA4D;AAE5D;;;;;;;;;;EAUE;AAEF,+BAA+B;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;EAwBE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @drizzle/reactive - Zero configuration, maximum intelligence
|
|
3
|
+
*
|
|
4
|
+
* A reactive database library that provides automatic caching, real-time synchronization,
|
|
5
|
+
* and intelligent invalidation for Drizzle ORM applications.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // server/db.ts - Minimal setup
|
|
10
|
+
* export const db = createReactiveDb(drizzle, {
|
|
11
|
+
* relations: {
|
|
12
|
+
* agent: ['organization', 'message.fromAgentId', 'memory.agentId'],
|
|
13
|
+
* organization: ['agent.organizationId', 'tool.organizationId'],
|
|
14
|
+
* },
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* // client/hooks.ts - Zero configuration usage
|
|
18
|
+
* const { data: agents } = useReactive('agents.findMany', { organizationId })
|
|
19
|
+
* // ✅ Shows cache instantly
|
|
20
|
+
* // ✅ Smart revalidation (only active hooks first)
|
|
21
|
+
* // ✅ Auto real-time mode
|
|
22
|
+
* // ✅ Handles page refresh gracefully
|
|
23
|
+
* // ✅ Recovers missed events
|
|
24
|
+
* // ✅ Type-safe with tRPC
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export { createReactiveDb } from './core/driver';
|
|
28
|
+
export { defineReactiveFunction } from './core/function';
|
|
29
|
+
export type { ReactiveConfig, ReactiveDb } from './core/types';
|
|
30
|
+
export { createReactiveRouter, ReactiveRouter } from './trpc/router';
|
|
31
|
+
export type { ReactiveRouterInstance, BuiltReactiveRouter } from './trpc/types';
|
|
32
|
+
export type { ReactiveFunction, ReactiveFunctionConfig, InvalidationRule, CacheStrategy, RealtimeConfig, } from './config/schema';
|
|
33
|
+
export { RedisProvider } from './providers/redis';
|
|
34
|
+
export { MemoryProvider } from './providers/memory';
|
|
35
|
+
export { LocalStorageProvider } from './providers/localStorage';
|
|
36
|
+
export { analyzeSql } from './core/analyzer';
|
|
37
|
+
export { createSSEStream, broadcastInvalidation, acknowledgeEvent, getSSEManager, SSEManager, } from './core/sse';
|
|
38
|
+
export declare const version = "0.1.0";
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAQ/E,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAA;AAGnB,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @drizzle/reactive - Zero configuration, maximum intelligence
|
|
4
|
+
*
|
|
5
|
+
* A reactive database library that provides automatic caching, real-time synchronization,
|
|
6
|
+
* and intelligent invalidation for Drizzle ORM applications.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // server/db.ts - Minimal setup
|
|
11
|
+
* export const db = createReactiveDb(drizzle, {
|
|
12
|
+
* relations: {
|
|
13
|
+
* agent: ['organization', 'message.fromAgentId', 'memory.agentId'],
|
|
14
|
+
* organization: ['agent.organizationId', 'tool.organizationId'],
|
|
15
|
+
* },
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* // client/hooks.ts - Zero configuration usage
|
|
19
|
+
* const { data: agents } = useReactive('agents.findMany', { organizationId })
|
|
20
|
+
* // ✅ Shows cache instantly
|
|
21
|
+
* // ✅ Smart revalidation (only active hooks first)
|
|
22
|
+
* // ✅ Auto real-time mode
|
|
23
|
+
* // ✅ Handles page refresh gracefully
|
|
24
|
+
* // ✅ Recovers missed events
|
|
25
|
+
* // ✅ Type-safe with tRPC
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.version = exports.SSEManager = exports.getSSEManager = exports.acknowledgeEvent = exports.broadcastInvalidation = exports.createSSEStream = exports.analyzeSql = exports.LocalStorageProvider = exports.MemoryProvider = exports.RedisProvider = exports.ReactiveRouter = exports.createReactiveRouter = exports.defineReactiveFunction = exports.createReactiveDb = void 0;
|
|
30
|
+
// Core exports
|
|
31
|
+
var driver_1 = require("./core/driver");
|
|
32
|
+
Object.defineProperty(exports, "createReactiveDb", { enumerable: true, get: function () { return driver_1.createReactiveDb; } });
|
|
33
|
+
var function_1 = require("./core/function");
|
|
34
|
+
Object.defineProperty(exports, "defineReactiveFunction", { enumerable: true, get: function () { return function_1.defineReactiveFunction; } });
|
|
35
|
+
// tRPC integration exports
|
|
36
|
+
var router_1 = require("./trpc/router");
|
|
37
|
+
Object.defineProperty(exports, "createReactiveRouter", { enumerable: true, get: function () { return router_1.createReactiveRouter; } });
|
|
38
|
+
Object.defineProperty(exports, "ReactiveRouter", { enumerable: true, get: function () { return router_1.ReactiveRouter; } });
|
|
39
|
+
// Provider exports
|
|
40
|
+
var redis_1 = require("./providers/redis");
|
|
41
|
+
Object.defineProperty(exports, "RedisProvider", { enumerable: true, get: function () { return redis_1.RedisProvider; } });
|
|
42
|
+
var memory_1 = require("./providers/memory");
|
|
43
|
+
Object.defineProperty(exports, "MemoryProvider", { enumerable: true, get: function () { return memory_1.MemoryProvider; } });
|
|
44
|
+
var localStorage_1 = require("./providers/localStorage");
|
|
45
|
+
Object.defineProperty(exports, "LocalStorageProvider", { enumerable: true, get: function () { return localStorage_1.LocalStorageProvider; } });
|
|
46
|
+
// Utility exports
|
|
47
|
+
var analyzer_1 = require("./core/analyzer");
|
|
48
|
+
Object.defineProperty(exports, "analyzeSql", { enumerable: true, get: function () { return analyzer_1.analyzeSql; } });
|
|
49
|
+
var sse_1 = require("./core/sse");
|
|
50
|
+
Object.defineProperty(exports, "createSSEStream", { enumerable: true, get: function () { return sse_1.createSSEStream; } });
|
|
51
|
+
Object.defineProperty(exports, "broadcastInvalidation", { enumerable: true, get: function () { return sse_1.broadcastInvalidation; } });
|
|
52
|
+
Object.defineProperty(exports, "acknowledgeEvent", { enumerable: true, get: function () { return sse_1.acknowledgeEvent; } });
|
|
53
|
+
Object.defineProperty(exports, "getSSEManager", { enumerable: true, get: function () { return sse_1.getSSEManager; } });
|
|
54
|
+
Object.defineProperty(exports, "SSEManager", { enumerable: true, get: function () { return sse_1.SSEManager; } });
|
|
55
|
+
// Version
|
|
56
|
+
exports.version = '0.1.0';
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,eAAe;AACf,wCAAgD;AAAvC,0GAAA,gBAAgB,OAAA;AACzB,4CAAwD;AAA/C,kHAAA,sBAAsB,OAAA;AAG/B,2BAA2B;AAC3B,wCAAoE;AAA3D,8GAAA,oBAAoB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAiB7C,mBAAmB;AACnB,2CAAiD;AAAxC,sGAAA,aAAa,OAAA;AACtB,6CAAmD;AAA1C,wGAAA,cAAc,OAAA;AACvB,yDAA+D;AAAtD,oHAAA,oBAAoB,OAAA;AAE7B,kBAAkB;AAClB,4CAA4C;AAAnC,sGAAA,UAAU,OAAA;AACnB,kCAMmB;AALjB,sGAAA,eAAe,OAAA;AACf,4GAAA,qBAAqB,OAAA;AACrB,uGAAA,gBAAgB,OAAA;AAChB,oGAAA,aAAa,OAAA;AACb,iGAAA,UAAU,OAAA;AAGZ,UAAU;AACG,QAAA,OAAO,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CacheProvider } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* LocalStorage cache provider implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class LocalStorageProvider implements CacheProvider {
|
|
6
|
+
private prefix;
|
|
7
|
+
get<T>(key: string): Promise<T | null>;
|
|
8
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
9
|
+
del(key: string): Promise<void>;
|
|
10
|
+
invalidate(pattern: string): Promise<void>;
|
|
11
|
+
clear(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=localStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStorage.d.ts","sourceRoot":"","sources":["../../src/providers/localStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;GAEG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,MAAM,CAAuB;IAE/B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAiBtC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAY7B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalStorageProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* LocalStorage cache provider implementation
|
|
6
|
+
*/
|
|
7
|
+
class LocalStorageProvider {
|
|
8
|
+
prefix = '@drizzle/reactive:';
|
|
9
|
+
async get(key) {
|
|
10
|
+
try {
|
|
11
|
+
const item = localStorage.getItem(this.prefix + key);
|
|
12
|
+
if (!item)
|
|
13
|
+
return null;
|
|
14
|
+
const parsed = JSON.parse(item);
|
|
15
|
+
if (parsed.expires && Date.now() > parsed.expires) {
|
|
16
|
+
localStorage.removeItem(this.prefix + key);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return parsed.value;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async set(key, value, ttl) {
|
|
26
|
+
try {
|
|
27
|
+
const expires = ttl ? Date.now() + ttl * 1000 : undefined;
|
|
28
|
+
const item = JSON.stringify({ value, expires });
|
|
29
|
+
localStorage.setItem(this.prefix + key, item);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Handle localStorage quota exceeded
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async del(key) {
|
|
36
|
+
localStorage.removeItem(this.prefix + key);
|
|
37
|
+
}
|
|
38
|
+
async invalidate(pattern) {
|
|
39
|
+
const regex = new RegExp(pattern.replace('*', '.*'));
|
|
40
|
+
const keysToDelete = [];
|
|
41
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
42
|
+
const key = localStorage.key(i);
|
|
43
|
+
if (key?.startsWith(this.prefix)) {
|
|
44
|
+
const unprefixedKey = key.slice(this.prefix.length);
|
|
45
|
+
if (regex.test(unprefixedKey)) {
|
|
46
|
+
keysToDelete.push(key);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
keysToDelete.forEach((key) => localStorage.removeItem(key));
|
|
51
|
+
}
|
|
52
|
+
async clear() {
|
|
53
|
+
const keysToDelete = [];
|
|
54
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
55
|
+
const key = localStorage.key(i);
|
|
56
|
+
if (key?.startsWith(this.prefix)) {
|
|
57
|
+
keysToDelete.push(key);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
keysToDelete.forEach((key) => localStorage.removeItem(key));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.LocalStorageProvider = LocalStorageProvider;
|
|
64
|
+
//# sourceMappingURL=localStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../src/providers/localStorage.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,oBAAoB;IACvB,MAAM,GAAG,oBAAoB,CAAA;IAErC,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;YACpD,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAA;YAEtB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC/B,IAAI,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;gBAClD,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;gBAC1C,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,MAAM,CAAC,KAAK,CAAA;Q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,IAAI,CAAC,GAAG,CAAC,CAAA;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;QAED,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,YAAY,GAAa,EAAE,CAAA;QAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAC/B,IAAI,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QAED,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7D,CAAC;CACF;AA/DD,oDA+DC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CacheProvider } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* In-memory cache provider implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemoryProvider implements CacheProvider {
|
|
6
|
+
private cache;
|
|
7
|
+
get<T>(key: string): Promise<T | null>;
|
|
8
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
9
|
+
del(key: string): Promise<void>;
|
|
10
|
+
invalidate(pattern: string): Promise<void>;
|
|
11
|
+
clear(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/providers/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;GAEG;AACH,qBAAa,cAAe,YAAW,aAAa;IAClD,OAAO,CAAC,KAAK,CAAsD;IAE7D,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAYtC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* In-memory cache provider implementation
|
|
6
|
+
*/
|
|
7
|
+
class MemoryProvider {
|
|
8
|
+
cache = new Map();
|
|
9
|
+
async get(key) {
|
|
10
|
+
const item = this.cache.get(key);
|
|
11
|
+
if (!item)
|
|
12
|
+
return null;
|
|
13
|
+
if (item.expires && Date.now() > item.expires) {
|
|
14
|
+
this.cache.delete(key);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return item.value;
|
|
18
|
+
}
|
|
19
|
+
async set(key, value, ttl) {
|
|
20
|
+
const expires = ttl ? Date.now() + ttl * 1000 : undefined;
|
|
21
|
+
this.cache.set(key, { value, expires });
|
|
22
|
+
}
|
|
23
|
+
async del(key) {
|
|
24
|
+
this.cache.delete(key);
|
|
25
|
+
}
|
|
26
|
+
async invalidate(pattern) {
|
|
27
|
+
// Simple pattern matching for now
|
|
28
|
+
const regex = new RegExp(pattern.replace('*', '.*'));
|
|
29
|
+
for (const key of this.cache.keys()) {
|
|
30
|
+
if (regex.test(key)) {
|
|
31
|
+
this.cache.delete(key);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async clear() {
|
|
36
|
+
this.cache.clear();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.MemoryProvider = MemoryProvider;
|
|
40
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/providers/memory.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,cAAc;IACjB,KAAK,GAAG,IAAI,GAAG,EAA4C,CAAA;IAEnE,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChC,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAA;QAEtB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW,EAAE,KAAQ,EAAE,GAAY;QAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;QACzD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,kCAAkC;QAClC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;QACpD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;CACF;AArCD,wCAqCC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CacheProvider } from '../core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Redis cache provider implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare class RedisProvider implements CacheProvider {
|
|
6
|
+
private redisClient?;
|
|
7
|
+
constructor(redisClient?: any | undefined);
|
|
8
|
+
get<T>(key: string): Promise<T | null>;
|
|
9
|
+
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
10
|
+
del(key: string): Promise<void>;
|
|
11
|
+
invalidate(pattern: string): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/providers/redis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD;;GAEG;AACH,qBAAa,aAAc,YAAW,aAAa;IACrC,OAAO,CAAC,WAAW,CAAC;gBAAZ,WAAW,CAAC,EAAE,GAAG,YAAA;IAI/B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMtC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU1D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Redis cache provider implementation
|
|
6
|
+
*/
|
|
7
|
+
class RedisProvider {
|
|
8
|
+
redisClient;
|
|
9
|
+
constructor(redisClient) {
|
|
10
|
+
this.redisClient = redisClient;
|
|
11
|
+
// TODO: Initialize Redis client
|
|
12
|
+
}
|
|
13
|
+
async get(key) {
|
|
14
|
+
// TODO: Implement Redis get
|
|
15
|
+
console.warn('@drizzle/reactive: Redis provider not yet implemented', key);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
async set(key, value, ttl) {
|
|
19
|
+
// TODO: Implement Redis set
|
|
20
|
+
console.warn('@drizzle/reactive: Redis provider not yet implemented', key, value, ttl);
|
|
21
|
+
}
|
|
22
|
+
async del(key) {
|
|
23
|
+
// TODO: Implement Redis delete
|
|
24
|
+
console.warn('@drizzle/reactive: Redis provider not yet implemented', key);
|
|
25
|
+
}
|
|
26
|
+
async invalidate(pattern) {
|
|
27
|
+
// TODO: Implement Redis pattern invalidation
|
|
28
|
+
console.warn('@drizzle/reactive: Redis provider not yet implemented', pattern);
|
|
29
|
+
}
|
|
30
|
+
async clear() {
|
|
31
|
+
// TODO: Implement Redis clear
|
|
32
|
+
console.warn('@drizzle/reactive: Redis provider not yet implemented');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.RedisProvider = RedisProvider;
|
|
36
|
+
//# sourceMappingURL=redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/providers/redis.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,aAAa;IACJ;IAApB,YAAoB,WAAiB;QAAjB,gBAAW,GAAX,WAAW,CAAM;QACnC,gCAAgC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,4BAA4B;QAC5B,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,GAAG,CAAC,CAAA;QAC1E,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,GAAW,EAAE,KAAQ,EAAE,GAAY;QAC9C,4BAA4B;QAC5B,OAAO,CAAC,IAAI,CACV,uDAAuD,EACvD,GAAG,EACH,KAAK,EACL,GAAG,CACJ,CAAA;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,+BAA+B;QAC/B,OAAO,CAAC,IAAI,CAAC,uDAAuD,EAAE,GAAG,CAAC,CAAA;IAC5E,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,6CAA6C;QAC7C,OAAO,CAAC,IAAI,CACV,uDAAuD,EACvD,OAAO,CACR,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,8BAA8B;QAC9B,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAA;IACvE,CAAC;CACF;AAtCD,sCAsCC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only exports for @drizzle/reactive
|
|
3
|
+
* Import this with: import { ... } from '@drizzle/reactive/server'
|
|
4
|
+
* This avoids importing React Context on the server
|
|
5
|
+
*/
|
|
6
|
+
export { createReactiveDb } from './core/driver';
|
|
7
|
+
export { defineReactiveFunction } from './core/function';
|
|
8
|
+
export type { ReactiveConfig, ReactiveDb, InvalidationEvent, } from './core/types';
|
|
9
|
+
export { createReactiveRouter, ReactiveRouter } from './trpc/router';
|
|
10
|
+
export type { ReactiveRouterInstance, BuiltReactiveRouter } from './trpc/types';
|
|
11
|
+
export { RedisProvider } from './providers/redis';
|
|
12
|
+
export { MemoryProvider } from './providers/memory';
|
|
13
|
+
export { analyzeSql } from './core/analyzer';
|
|
14
|
+
export { createSSEStream, broadcastInvalidation, acknowledgeEvent, getSSEManager, SSEManager, } from './core/sse';
|
|
15
|
+
export type { ReactiveFunction, ReactiveFunctionConfig, InvalidationRule, CacheStrategy, RealtimeConfig, } from './config/schema';
|
|
16
|
+
export declare const version = "0.1.0";
|
|
17
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,YAAY,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACpE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAG/E,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACb,UAAU,GACX,MAAM,YAAY,CAAA;AAGnB,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAA;AAGxB,eAAO,MAAM,OAAO,UAAU,CAAA"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Server-only exports for @drizzle/reactive
|
|
4
|
+
* Import this with: import { ... } from '@drizzle/reactive/server'
|
|
5
|
+
* This avoids importing React Context on the server
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.version = exports.SSEManager = exports.getSSEManager = exports.acknowledgeEvent = exports.broadcastInvalidation = exports.createSSEStream = exports.analyzeSql = exports.MemoryProvider = exports.RedisProvider = exports.ReactiveRouter = exports.createReactiveRouter = exports.defineReactiveFunction = exports.createReactiveDb = void 0;
|
|
9
|
+
// Core database exports
|
|
10
|
+
var driver_1 = require("./core/driver");
|
|
11
|
+
Object.defineProperty(exports, "createReactiveDb", { enumerable: true, get: function () { return driver_1.createReactiveDb; } });
|
|
12
|
+
var function_1 = require("./core/function");
|
|
13
|
+
Object.defineProperty(exports, "defineReactiveFunction", { enumerable: true, get: function () { return function_1.defineReactiveFunction; } });
|
|
14
|
+
// tRPC integration exports
|
|
15
|
+
var router_1 = require("./trpc/router");
|
|
16
|
+
Object.defineProperty(exports, "createReactiveRouter", { enumerable: true, get: function () { return router_1.createReactiveRouter; } });
|
|
17
|
+
Object.defineProperty(exports, "ReactiveRouter", { enumerable: true, get: function () { return router_1.ReactiveRouter; } });
|
|
18
|
+
// Server-side providers
|
|
19
|
+
var redis_1 = require("./providers/redis");
|
|
20
|
+
Object.defineProperty(exports, "RedisProvider", { enumerable: true, get: function () { return redis_1.RedisProvider; } });
|
|
21
|
+
var memory_1 = require("./providers/memory");
|
|
22
|
+
Object.defineProperty(exports, "MemoryProvider", { enumerable: true, get: function () { return memory_1.MemoryProvider; } });
|
|
23
|
+
// Server-side utilities
|
|
24
|
+
var analyzer_1 = require("./core/analyzer");
|
|
25
|
+
Object.defineProperty(exports, "analyzeSql", { enumerable: true, get: function () { return analyzer_1.analyzeSql; } });
|
|
26
|
+
var sse_1 = require("./core/sse");
|
|
27
|
+
Object.defineProperty(exports, "createSSEStream", { enumerable: true, get: function () { return sse_1.createSSEStream; } });
|
|
28
|
+
Object.defineProperty(exports, "broadcastInvalidation", { enumerable: true, get: function () { return sse_1.broadcastInvalidation; } });
|
|
29
|
+
Object.defineProperty(exports, "acknowledgeEvent", { enumerable: true, get: function () { return sse_1.acknowledgeEvent; } });
|
|
30
|
+
Object.defineProperty(exports, "getSSEManager", { enumerable: true, get: function () { return sse_1.getSSEManager; } });
|
|
31
|
+
Object.defineProperty(exports, "SSEManager", { enumerable: true, get: function () { return sse_1.SSEManager; } });
|
|
32
|
+
// Version
|
|
33
|
+
exports.version = '0.1.0';
|
|
34
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,wBAAwB;AACxB,wCAAgD;AAAvC,0GAAA,gBAAgB,OAAA;AACzB,4CAAwD;AAA/C,kHAAA,sBAAsB,OAAA;AAO/B,2BAA2B;AAC3B,wCAAoE;AAA3D,8GAAA,oBAAoB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAG7C,wBAAwB;AACxB,2CAAiD;AAAxC,sGAAA,aAAa,OAAA;AACtB,6CAAmD;AAA1C,wGAAA,cAAc,OAAA;AAEvB,wBAAwB;AACxB,4CAA4C;AAAnC,sGAAA,UAAU,OAAA;AACnB,kCAMmB;AALjB,sGAAA,eAAe,OAAA;AACf,4GAAA,qBAAqB,OAAA;AACrB,uGAAA,gBAAgB,OAAA;AAChB,oGAAA,aAAa,OAAA;AACb,iGAAA,UAAU,OAAA;AAYZ,UAAU;AACG,QAAA,OAAO,GAAG,OAAO,CAAA"}
|