@agelum/backend 0.1.1 → 0.1.2
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/dist/client/hooks.d.ts +65 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/manager.d.ts +137 -0
- package/dist/client/manager.d.ts.map +1 -0
- package/dist/client/provider.d.ts +25 -0
- package/dist/client/provider.d.ts.map +1 -0
- package/dist/client/revalidation.d.ts +101 -0
- package/dist/client/revalidation.d.ts.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/storage.d.ts +126 -0
- package/dist/client/storage.d.ts.map +1 -0
- package/dist/client/trpc.d.ts +12 -0
- package/dist/client/trpc.d.ts.map +1 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/config/schema.d.ts +250 -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/driver.d.ts +7 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/driver.js +262 -0
- package/dist/core/driver.js.map +1 -0
- package/dist/core/function.d.ts +103 -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/types.d.ts +196 -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 +192 -0
- package/dist/examples/teamhub-integration.js.map +1 -0
- package/dist/index.d.ts +40 -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/memory.d.ts +13 -0
- package/dist/providers/memory.d.ts.map +1 -0
- package/dist/providers/redis.d.ts +14 -0
- package/dist/providers/redis.d.ts.map +1 -0
- package/dist/server.d.ts +18 -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/index.d.ts +9 -0
- package/dist/trpc/index.d.ts.map +1 -0
- package/dist/trpc/index.js +19 -0
- package/dist/trpc/index.js.map +1 -0
- package/dist/trpc/router.d.ts +76 -0
- package/dist/trpc/router.d.ts.map +1 -0
- package/dist/trpc/router.js +177 -0
- package/dist/trpc/router.js.map +1 -0
- package/dist/trpc/types.d.ts +114 -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 +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration schema validation using Zod
|
|
4
|
+
*/
|
|
5
|
+
export declare const cacheConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
6
|
+
server: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
provider: z.ZodDefault<z.ZodOptional<z.ZodEnum<["redis", "memory"]>>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
provider: "redis" | "memory";
|
|
10
|
+
}, {
|
|
11
|
+
provider?: "redis" | "memory" | undefined;
|
|
12
|
+
}>>;
|
|
13
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
14
|
+
provider: z.ZodDefault<z.ZodOptional<z.ZodEnum<["localStorage", "sessionStorage"]>>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
provider: "localStorage" | "sessionStorage";
|
|
17
|
+
}, {
|
|
18
|
+
provider?: "localStorage" | "sessionStorage" | undefined;
|
|
19
|
+
}>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
server?: {
|
|
22
|
+
provider: "redis" | "memory";
|
|
23
|
+
} | undefined;
|
|
24
|
+
client?: {
|
|
25
|
+
provider: "localStorage" | "sessionStorage";
|
|
26
|
+
} | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
server?: {
|
|
29
|
+
provider?: "redis" | "memory" | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
client?: {
|
|
32
|
+
provider?: "localStorage" | "sessionStorage" | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
}>>;
|
|
35
|
+
export declare const realtimeConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
37
|
+
transport: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"sse">>>;
|
|
38
|
+
fallback: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"polling">>>;
|
|
39
|
+
reliability: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
acknowledgments: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
41
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
42
|
+
retryDelays: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>;
|
|
43
|
+
periodicHeartbeat: z.ZodDefault<z.ZodOptional<z.ZodLiteral<false>>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
acknowledgments: boolean;
|
|
46
|
+
maxRetries: number;
|
|
47
|
+
retryDelays: number[];
|
|
48
|
+
periodicHeartbeat: false;
|
|
49
|
+
}, {
|
|
50
|
+
acknowledgments?: boolean | undefined;
|
|
51
|
+
maxRetries?: number | undefined;
|
|
52
|
+
retryDelays?: number[] | undefined;
|
|
53
|
+
periodicHeartbeat?: false | undefined;
|
|
54
|
+
}>>;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
transport: "sse";
|
|
58
|
+
fallback: "polling";
|
|
59
|
+
reliability?: {
|
|
60
|
+
acknowledgments: boolean;
|
|
61
|
+
maxRetries: number;
|
|
62
|
+
retryDelays: number[];
|
|
63
|
+
periodicHeartbeat: false;
|
|
64
|
+
} | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
enabled?: boolean | undefined;
|
|
67
|
+
transport?: "sse" | undefined;
|
|
68
|
+
fallback?: "polling" | undefined;
|
|
69
|
+
reliability?: {
|
|
70
|
+
acknowledgments?: boolean | undefined;
|
|
71
|
+
maxRetries?: number | undefined;
|
|
72
|
+
retryDelays?: number[] | undefined;
|
|
73
|
+
periodicHeartbeat?: false | undefined;
|
|
74
|
+
} | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
export declare const reactiveConfigSchema: z.ZodObject<{
|
|
77
|
+
relations: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>;
|
|
78
|
+
cache: z.ZodOptional<z.ZodObject<{
|
|
79
|
+
server: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
provider: z.ZodDefault<z.ZodOptional<z.ZodEnum<["redis", "memory"]>>>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
provider: "redis" | "memory";
|
|
83
|
+
}, {
|
|
84
|
+
provider?: "redis" | "memory" | undefined;
|
|
85
|
+
}>>;
|
|
86
|
+
client: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
provider: z.ZodDefault<z.ZodOptional<z.ZodEnum<["localStorage", "sessionStorage"]>>>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
provider: "localStorage" | "sessionStorage";
|
|
90
|
+
}, {
|
|
91
|
+
provider?: "localStorage" | "sessionStorage" | undefined;
|
|
92
|
+
}>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
server?: {
|
|
95
|
+
provider: "redis" | "memory";
|
|
96
|
+
} | undefined;
|
|
97
|
+
client?: {
|
|
98
|
+
provider: "localStorage" | "sessionStorage";
|
|
99
|
+
} | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
server?: {
|
|
102
|
+
provider?: "redis" | "memory" | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
client?: {
|
|
105
|
+
provider?: "localStorage" | "sessionStorage" | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
}>>;
|
|
108
|
+
realtime: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
110
|
+
transport: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"sse">>>;
|
|
111
|
+
fallback: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"polling">>>;
|
|
112
|
+
reliability: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
acknowledgments: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
114
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
115
|
+
retryDelays: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>;
|
|
116
|
+
periodicHeartbeat: z.ZodDefault<z.ZodOptional<z.ZodLiteral<false>>>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
acknowledgments: boolean;
|
|
119
|
+
maxRetries: number;
|
|
120
|
+
retryDelays: number[];
|
|
121
|
+
periodicHeartbeat: false;
|
|
122
|
+
}, {
|
|
123
|
+
acknowledgments?: boolean | undefined;
|
|
124
|
+
maxRetries?: number | undefined;
|
|
125
|
+
retryDelays?: number[] | undefined;
|
|
126
|
+
periodicHeartbeat?: false | undefined;
|
|
127
|
+
}>>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
enabled: boolean;
|
|
130
|
+
transport: "sse";
|
|
131
|
+
fallback: "polling";
|
|
132
|
+
reliability?: {
|
|
133
|
+
acknowledgments: boolean;
|
|
134
|
+
maxRetries: number;
|
|
135
|
+
retryDelays: number[];
|
|
136
|
+
periodicHeartbeat: false;
|
|
137
|
+
} | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
enabled?: boolean | undefined;
|
|
140
|
+
transport?: "sse" | undefined;
|
|
141
|
+
fallback?: "polling" | undefined;
|
|
142
|
+
reliability?: {
|
|
143
|
+
acknowledgments?: boolean | undefined;
|
|
144
|
+
maxRetries?: number | undefined;
|
|
145
|
+
retryDelays?: number[] | undefined;
|
|
146
|
+
periodicHeartbeat?: false | undefined;
|
|
147
|
+
} | undefined;
|
|
148
|
+
}>>;
|
|
149
|
+
}, "strip", z.ZodTypeAny, {
|
|
150
|
+
relations: Record<string, string[]>;
|
|
151
|
+
cache?: {
|
|
152
|
+
server?: {
|
|
153
|
+
provider: "redis" | "memory";
|
|
154
|
+
} | undefined;
|
|
155
|
+
client?: {
|
|
156
|
+
provider: "localStorage" | "sessionStorage";
|
|
157
|
+
} | undefined;
|
|
158
|
+
} | undefined;
|
|
159
|
+
realtime?: {
|
|
160
|
+
enabled: boolean;
|
|
161
|
+
transport: "sse";
|
|
162
|
+
fallback: "polling";
|
|
163
|
+
reliability?: {
|
|
164
|
+
acknowledgments: boolean;
|
|
165
|
+
maxRetries: number;
|
|
166
|
+
retryDelays: number[];
|
|
167
|
+
periodicHeartbeat: false;
|
|
168
|
+
} | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
relations: Record<string, string[]>;
|
|
172
|
+
cache?: {
|
|
173
|
+
server?: {
|
|
174
|
+
provider?: "redis" | "memory" | undefined;
|
|
175
|
+
} | undefined;
|
|
176
|
+
client?: {
|
|
177
|
+
provider?: "localStorage" | "sessionStorage" | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
} | undefined;
|
|
180
|
+
realtime?: {
|
|
181
|
+
enabled?: boolean | undefined;
|
|
182
|
+
transport?: "sse" | undefined;
|
|
183
|
+
fallback?: "polling" | undefined;
|
|
184
|
+
reliability?: {
|
|
185
|
+
acknowledgments?: boolean | undefined;
|
|
186
|
+
maxRetries?: number | undefined;
|
|
187
|
+
retryDelays?: number[] | undefined;
|
|
188
|
+
periodicHeartbeat?: false | undefined;
|
|
189
|
+
} | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
}>;
|
|
192
|
+
export declare const reactiveFunctionConfigSchema: z.ZodObject<{
|
|
193
|
+
id: z.ZodString;
|
|
194
|
+
input: z.ZodAny;
|
|
195
|
+
dependencies: z.ZodArray<z.ZodString, "many">;
|
|
196
|
+
invalidateWhen: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>>;
|
|
197
|
+
handler: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
id: string;
|
|
200
|
+
dependencies: string[];
|
|
201
|
+
handler: (...args: unknown[]) => unknown;
|
|
202
|
+
input?: any;
|
|
203
|
+
invalidateWhen?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
id: string;
|
|
206
|
+
dependencies: string[];
|
|
207
|
+
handler: (...args: unknown[]) => unknown;
|
|
208
|
+
input?: any;
|
|
209
|
+
invalidateWhen?: Record<string, (...args: unknown[]) => unknown> | undefined;
|
|
210
|
+
}>;
|
|
211
|
+
export declare const invalidationRuleSchema: z.ZodObject<{
|
|
212
|
+
table: z.ZodString;
|
|
213
|
+
condition: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
|
|
214
|
+
scope: z.ZodDefault<z.ZodOptional<z.ZodEnum<["global", "organization", "user"]>>>;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
table: string;
|
|
217
|
+
scope: "organization" | "global" | "user";
|
|
218
|
+
condition?: ((...args: unknown[]) => unknown) | undefined;
|
|
219
|
+
}, {
|
|
220
|
+
table: string;
|
|
221
|
+
condition?: ((...args: unknown[]) => unknown) | undefined;
|
|
222
|
+
scope?: "organization" | "global" | "user" | undefined;
|
|
223
|
+
}>;
|
|
224
|
+
export declare const cacheStrategySchema: z.ZodObject<{
|
|
225
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
staleWhileRevalidate: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
227
|
+
backgroundRevalidation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
228
|
+
priority: z.ZodDefault<z.ZodOptional<z.ZodEnum<["high", "medium", "low"]>>>;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
staleWhileRevalidate: boolean;
|
|
231
|
+
backgroundRevalidation: boolean;
|
|
232
|
+
priority: "high" | "medium" | "low";
|
|
233
|
+
ttl?: number | undefined;
|
|
234
|
+
}, {
|
|
235
|
+
ttl?: number | undefined;
|
|
236
|
+
staleWhileRevalidate?: boolean | undefined;
|
|
237
|
+
backgroundRevalidation?: boolean | undefined;
|
|
238
|
+
priority?: "high" | "medium" | "low" | undefined;
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* Type exports from schemas
|
|
242
|
+
*/
|
|
243
|
+
export type ReactiveConfigSchema = z.infer<typeof reactiveConfigSchema>;
|
|
244
|
+
export type ReactiveFunctionConfigSchema = z.infer<typeof reactiveFunctionConfigSchema>;
|
|
245
|
+
export type InvalidationRule = z.infer<typeof invalidationRuleSchema>;
|
|
246
|
+
export type CacheStrategy = z.infer<typeof cacheStrategySchema>;
|
|
247
|
+
export type RealtimeConfig = z.infer<typeof realtimeConfigSchema>;
|
|
248
|
+
export type { ReactiveFunction, ReactiveFunctionConfig, } from '../core/function';
|
|
249
|
+
export type { ReactiveConfig, } from '../core/types';
|
|
250
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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Property(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cacheStrategySchema = exports.invalidationRuleSchema = exports.reactiveFunctionConfigSchema = exports.reactiveConfigSchema = exports.realtimeConfigSchema = exports.cacheConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Configuration schema validation using Zod
|
|
7
|
+
*/
|
|
8
|
+
exports.cacheConfigSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
server: zod_1.z
|
|
11
|
+
.object({
|
|
12
|
+
provider: zod_1.z.enum(['redis', 'memory']).optional().default('memory'),
|
|
13
|
+
})
|
|
14
|
+
.optional(),
|
|
15
|
+
client: zod_1.z
|
|
16
|
+
.object({
|
|
17
|
+
provider: zod_1.z
|
|
18
|
+
.enum(['localStorage', 'sessionStorage'])
|
|
19
|
+
.optional()
|
|
20
|
+
.default('localStorage'),
|
|
21
|
+
})
|
|
22
|
+
.optional(),
|
|
23
|
+
})
|
|
24
|
+
.optional();
|
|
25
|
+
exports.realtimeConfigSchema = zod_1.z
|
|
26
|
+
.object({
|
|
27
|
+
enabled: zod_1.z.boolean().optional().default(true),
|
|
28
|
+
transport: zod_1.z.literal('sse').optional().default('sse'),
|
|
29
|
+
fallback: zod_1.z.literal('polling').optional().default('polling'),
|
|
30
|
+
reliability: zod_1.z
|
|
31
|
+
.object({
|
|
32
|
+
acknowledgments: zod_1.z.boolean().optional().default(true),
|
|
33
|
+
maxRetries: zod_1.z.number().optional().default(3),
|
|
34
|
+
retryDelays: zod_1.z
|
|
35
|
+
.array(zod_1.z.number())
|
|
36
|
+
.optional()
|
|
37
|
+
.default([2000, 5000, 10000]),
|
|
38
|
+
periodicHeartbeat: zod_1.z.literal(false).optional().default(false),
|
|
39
|
+
})
|
|
40
|
+
.optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional();
|
|
43
|
+
exports.reactiveConfigSchema = zod_1.z.object({
|
|
44
|
+
relations: zod_1.z.record(zod_1.z.string(), zod_1.z.array(zod_1.z.string())),
|
|
45
|
+
cache: exports.cacheConfigSchema,
|
|
46
|
+
realtime: exports.realtimeConfigSchema,
|
|
47
|
+
});
|
|
48
|
+
exports.reactiveFunctionConfigSchema = zod_1.z.object({
|
|
49
|
+
id: zod_1.z.string(),
|
|
50
|
+
input: zod_1.z.any(), // Zod schema
|
|
51
|
+
dependencies: zod_1.z.array(zod_1.z.string()),
|
|
52
|
+
invalidateWhen: zod_1.z.record(zod_1.z.string(), zod_1.z.function()).optional(),
|
|
53
|
+
handler: zod_1.z.function(),
|
|
54
|
+
});
|
|
55
|
+
exports.invalidationRuleSchema = zod_1.z.object({
|
|
56
|
+
table: zod_1.z.string(),
|
|
57
|
+
condition: zod_1.z.function().optional(),
|
|
58
|
+
scope: zod_1.z
|
|
59
|
+
.enum(['global', 'organization', 'user'])
|
|
60
|
+
.optional()
|
|
61
|
+
.default('organization'),
|
|
62
|
+
});
|
|
63
|
+
exports.cacheStrategySchema = zod_1.z.object({
|
|
64
|
+
ttl: zod_1.z.number().optional(),
|
|
65
|
+
staleWhileRevalidate: zod_1.z.boolean().optional().default(true),
|
|
66
|
+
backgroundRevalidation: zod_1.z.boolean().optional().default(true),
|
|
67
|
+
priority: zod_1.z.enum(['high', 'medium', 'low']).optional().default('medium'),
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEvB;;GAEG;AAEU,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,MAAM,EAAE,OAAC;SACN,MAAM,CAAC;QACN,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;KACnE,CAAC;SACD,QAAQ,EAAE;IACb,MAAM,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AE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;CACzE,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SqlAnalysis } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Advanced SQL analyzer that extracts metadata from queries
|
|
4
|
+
* This is core to the reactive system's intelligence
|
|
5
|
+
*/
|
|
6
|
+
export declare function analyzeSql(sql: string, params?: any[]): SqlAnalysis;
|
|
7
|
+
/**
|
|
8
|
+
* Utility function to check if a query affects a specific table
|
|
9
|
+
*/
|
|
10
|
+
export declare function queryAffectsTable(sql: string, tableName: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Utility function to extract all table references from a complex query
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractAllTableReferences(sql: string): string[];
|
|
15
|
+
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/core/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,WAAW,CA0BnE;AA2LD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGzE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAsB/D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactiveConfig, ReactiveDb, DrizzleDatabase } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a reactive database instance
|
|
4
|
+
* This is the main entry point for the library
|
|
5
|
+
*/
|
|
6
|
+
export declare function createReactiveDb<TDrizzle extends DrizzleDatabase>(drizzleDb: TDrizzle, config: ReactiveConfig): ReactiveDb<TDrizzle>;
|
|
7
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../src/core/driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,eAAe,EAKhB,MAAM,SAAS,CAAA;AA6ShB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,SAAS,eAAe,EAC/D,SAAS,EAAE,QAAQ,EACnB,MAAM,EAAE,cAAc,GACrB,UAAU,CAAC,QAAQ,CAAC,CAgBtB"}
|
|
@@ -0,0 +1,262 @@
|
|
|
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(query, params));
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Intercept select/insert/update/delete methods
|
|
44
|
+
const methods = ['select', 'insert', 'update', 'delete'];
|
|
45
|
+
methods.forEach((method) => {
|
|
46
|
+
const dbMethod = this.originalDb[method];
|
|
47
|
+
if (dbMethod) {
|
|
48
|
+
const originalMethod = dbMethod.bind(this.originalDb);
|
|
49
|
+
this.originalDb[method] = (...args) => {
|
|
50
|
+
const queryBuilder = originalMethod(...args);
|
|
51
|
+
return this.wrapQueryBuilder(queryBuilder, method.toUpperCase());
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
wrapQueryBuilder(queryBuilder, operation) {
|
|
57
|
+
// Wrap query execution methods
|
|
58
|
+
if (queryBuilder.execute) {
|
|
59
|
+
const originalExecute = queryBuilder.execute.bind(queryBuilder);
|
|
60
|
+
queryBuilder.execute = async () => {
|
|
61
|
+
const sql = queryBuilder.toSQL?.() || { sql: 'unknown', params: [] };
|
|
62
|
+
return this.interceptQuery(sql, sql.params, originalExecute);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Wrap other execution methods like .all(), .get(), etc.
|
|
66
|
+
const execMethods = ['all', 'get', 'run', 'values'];
|
|
67
|
+
execMethods.forEach((method) => {
|
|
68
|
+
if (queryBuilder[method]) {
|
|
69
|
+
const originalMethod = queryBuilder[method].bind(queryBuilder);
|
|
70
|
+
queryBuilder[method] = async () => {
|
|
71
|
+
const sql = queryBuilder.toSQL?.() || { sql: 'unknown', params: [] };
|
|
72
|
+
return this.interceptQuery(sql, sql.params, originalMethod);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return queryBuilder;
|
|
77
|
+
}
|
|
78
|
+
async interceptQuery(query, params = [], originalExecute) {
|
|
79
|
+
// Extract SQL string from query object or use directly
|
|
80
|
+
const sqlString = typeof query === 'string' ? query : query.sql || 'unknown';
|
|
81
|
+
const queryParams = params || query.params || [];
|
|
82
|
+
// Analyze the SQL to understand what it does
|
|
83
|
+
const analysis = (0, analyzer_1.analyzeSql)(sqlString, queryParams);
|
|
84
|
+
const cacheKey = this.generateCacheKey(analysis, queryParams);
|
|
85
|
+
// Handle SELECT queries with caching
|
|
86
|
+
if (analysis.operation === 'SELECT') {
|
|
87
|
+
return this.handleSelectQuery(analysis, cacheKey, originalExecute);
|
|
88
|
+
}
|
|
89
|
+
// Handle mutations (INSERT/UPDATE/DELETE) with invalidation
|
|
90
|
+
return this.handleMutationQuery(analysis, originalExecute);
|
|
91
|
+
}
|
|
92
|
+
generateCacheKey(analysis, params) {
|
|
93
|
+
// Create a deterministic cache key from the query
|
|
94
|
+
const keyParts = [
|
|
95
|
+
analysis.table,
|
|
96
|
+
analysis.operation,
|
|
97
|
+
JSON.stringify(analysis.whereKeys.sort()),
|
|
98
|
+
JSON.stringify(params),
|
|
99
|
+
];
|
|
100
|
+
return keyParts.join(':');
|
|
101
|
+
}
|
|
102
|
+
async handleSelectQuery(analysis, cacheKey, originalExecute) {
|
|
103
|
+
// Try to get from cache first
|
|
104
|
+
const cached = await this.cache.get(cacheKey);
|
|
105
|
+
if (cached) {
|
|
106
|
+
console.log(`[ReactiveDB] Cache hit for ${analysis.table}`);
|
|
107
|
+
return cached;
|
|
108
|
+
}
|
|
109
|
+
// Execute the original query
|
|
110
|
+
console.log(`[ReactiveDB] Cache miss, executing query on ${analysis.table}`);
|
|
111
|
+
const result = await originalExecute();
|
|
112
|
+
// Cache the result
|
|
113
|
+
const ttl = this.getTtlForTable(analysis.table);
|
|
114
|
+
await this.cache.set(cacheKey, result, ttl);
|
|
115
|
+
// Store query metadata for invalidation
|
|
116
|
+
this.queryMetadata.set(cacheKey, {
|
|
117
|
+
key: cacheKey,
|
|
118
|
+
dependencies: [analysis.table],
|
|
119
|
+
lastExecuted: Date.now(),
|
|
120
|
+
ttl,
|
|
121
|
+
organizationId: analysis.organizationId,
|
|
122
|
+
});
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
async handleMutationQuery(analysis, originalExecute) {
|
|
126
|
+
console.log(`🔥 [ReactiveDB] MUTATION DETECTED: ${analysis.operation} on ${analysis.table} - This WILL trigger SSE broadcast`);
|
|
127
|
+
// Execute the mutation
|
|
128
|
+
const result = await originalExecute();
|
|
129
|
+
// Invalidate related queries
|
|
130
|
+
await this.invalidateRelatedQueries(analysis);
|
|
131
|
+
// Broadcast invalidation events
|
|
132
|
+
await this.broadcastInvalidation(analysis);
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
async invalidateRelatedQueries(analysis) {
|
|
136
|
+
const { table } = analysis;
|
|
137
|
+
const relatedTables = this.config.relations[table] || [];
|
|
138
|
+
// Find all queries that depend on this table or related tables
|
|
139
|
+
const tablesToInvalidate = [table, ...relatedTables];
|
|
140
|
+
const keysToInvalidate = [];
|
|
141
|
+
for (const [cacheKey, metadata] of this.queryMetadata.entries()) {
|
|
142
|
+
const shouldInvalidate = metadata.dependencies.some((dep) => tablesToInvalidate.includes(dep));
|
|
143
|
+
if (shouldInvalidate) {
|
|
144
|
+
keysToInvalidate.push(cacheKey);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Invalidate cache entries
|
|
148
|
+
console.log(`[ReactiveDB] Invalidating ${keysToInvalidate.length} cached queries for ${table}`);
|
|
149
|
+
await Promise.all(keysToInvalidate.map((key) => this.cache.del(key)));
|
|
150
|
+
// Remove metadata for invalidated queries
|
|
151
|
+
keysToInvalidate.forEach((key) => this.queryMetadata.delete(key));
|
|
152
|
+
}
|
|
153
|
+
async broadcastInvalidation(analysis) {
|
|
154
|
+
const { table, organizationId } = analysis;
|
|
155
|
+
if (!organizationId)
|
|
156
|
+
return;
|
|
157
|
+
const subscribers = this.subscribers.get(organizationId);
|
|
158
|
+
if (!subscribers)
|
|
159
|
+
return;
|
|
160
|
+
// Create invalidation event
|
|
161
|
+
const event = {
|
|
162
|
+
type: 'invalidation',
|
|
163
|
+
table,
|
|
164
|
+
organizationId,
|
|
165
|
+
affectedQueries: Array.from(this.queryMetadata.keys()).filter((key) => {
|
|
166
|
+
const metadata = this.queryMetadata.get(key);
|
|
167
|
+
return metadata?.dependencies.includes(table);
|
|
168
|
+
}),
|
|
169
|
+
eventId: `evt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
170
|
+
requiresAck: true,
|
|
171
|
+
timestamp: Date.now(),
|
|
172
|
+
};
|
|
173
|
+
// Notify all subscribers
|
|
174
|
+
subscribers.forEach((callback) => {
|
|
175
|
+
try {
|
|
176
|
+
callback(event);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
console.error('[ReactiveDB] Error in invalidation callback:', error);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
// Broadcast to SSE subscribers for real-time updates
|
|
183
|
+
try {
|
|
184
|
+
await (0, sse_1.broadcastInvalidation)(organizationId, {
|
|
185
|
+
type: 'invalidation',
|
|
186
|
+
table,
|
|
187
|
+
organizationId,
|
|
188
|
+
affectedQueries: event.affectedQueries,
|
|
189
|
+
timestamp: Date.now(),
|
|
190
|
+
operation: analysis.operation,
|
|
191
|
+
affectedKeys: analysis.whereKeys,
|
|
192
|
+
});
|
|
193
|
+
console.log(`[ReactiveDriver] SSE broadcast sent for org: ${organizationId}, table: ${table}`);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
console.warn('[ReactiveDriver] SSE broadcast failed:', error);
|
|
197
|
+
// Continue execution - local invalidation still works
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
getTtlForTable(table) {
|
|
201
|
+
// Smart TTL based on table type
|
|
202
|
+
switch (table) {
|
|
203
|
+
case 'agent':
|
|
204
|
+
case 'organization':
|
|
205
|
+
return 300; // 5 minutes for relatively stable data
|
|
206
|
+
case 'message':
|
|
207
|
+
return 60; // 1 minute for frequently changing data
|
|
208
|
+
case 'memory':
|
|
209
|
+
return 180; // 3 minutes for memory data
|
|
210
|
+
default:
|
|
211
|
+
return 120; // 2 minutes default
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Public methods for the ReactiveDb interface
|
|
215
|
+
async query(sql, params) {
|
|
216
|
+
return this.interceptQuery(sql, params, async () => {
|
|
217
|
+
return await this.originalDb.execute(sql, params);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
getCache() {
|
|
221
|
+
return this.cache;
|
|
222
|
+
}
|
|
223
|
+
subscribe(organizationId, callback) {
|
|
224
|
+
if (!this.subscribers.has(organizationId)) {
|
|
225
|
+
this.subscribers.set(organizationId, new Set());
|
|
226
|
+
}
|
|
227
|
+
this.subscribers.get(organizationId).add(callback);
|
|
228
|
+
// Return unsubscribe function
|
|
229
|
+
return () => {
|
|
230
|
+
const orgSubscribers = this.subscribers.get(organizationId);
|
|
231
|
+
if (orgSubscribers) {
|
|
232
|
+
orgSubscribers.delete(callback);
|
|
233
|
+
if (orgSubscribers.size === 0) {
|
|
234
|
+
this.subscribers.delete(organizationId);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
getOriginalDb() {
|
|
240
|
+
return this.originalDb;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create a reactive database instance
|
|
245
|
+
* This is the main entry point for the library
|
|
246
|
+
*/
|
|
247
|
+
function createReactiveDb(drizzleDb, config) {
|
|
248
|
+
console.log('[ReactiveDB] Initializing reactive database with config:', {
|
|
249
|
+
relations: Object.keys(config.relations),
|
|
250
|
+
cacheProvider: config.cache?.server?.provider || 'memory',
|
|
251
|
+
realtimeEnabled: config.realtime?.enabled ?? true,
|
|
252
|
+
});
|
|
253
|
+
const driver = new ReactiveSqlDriver(drizzleDb, config);
|
|
254
|
+
return {
|
|
255
|
+
db: driver.getOriginalDb(),
|
|
256
|
+
config,
|
|
257
|
+
query: driver.query.bind(driver),
|
|
258
|
+
getCache: driver.getCache.bind(driver),
|
|
259
|
+
subscribe: driver.subscribe.bind(driver),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../src/core/driver.ts"],"names":[],"mappings":";;AAyTA,4CAmBC;AAnUD,yCAAuC;AACvC,gDAAoD;AACpD,8CAAkD;AAClD,+BAA6C;AAE7C;;GAEG;AACH,MAAM,iBAAiB;IAKD;IAA8B;IAJ1C,KAAK,CAAe;IACpB,WAAW,GAAG,IAAI,GAAG,EAAqC,CAAA;IAC1D,aAAa,GAAG,IAAI,GAAG,EAAyB,CAAA;IAExD,YAAoB,UAAoB,EAAU,MAAsB;QAApD,eAAU,GAAV,UAAU,CAAU;QAAU,WAAM,GAAN,MAAM,CAAgB;QACtE,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,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