@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,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Simple tRPC router integration for reactive functions
|
|
4
|
+
*
|
|
5
|
+
* This is just a thin wrapper that:
|
|
6
|
+
* 1. Takes reactive functions
|
|
7
|
+
* 2. Exposes them as tRPC procedures
|
|
8
|
+
* 3. That's it!
|
|
9
|
+
*
|
|
10
|
+
* All the reactive logic (caching, invalidation, etc.) is handled
|
|
11
|
+
* by the reactive functions themselves.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ReactiveRouter = void 0;
|
|
15
|
+
exports.createReactiveRouter = createReactiveRouter;
|
|
16
|
+
exports.createRouterFromFunctions = createRouterFromFunctions;
|
|
17
|
+
const server_1 = require("@trpc/server");
|
|
18
|
+
/**
|
|
19
|
+
* Create typed tRPC instance with ReactiveHandlerContext
|
|
20
|
+
*/
|
|
21
|
+
const createTypedTRPC = () => server_1.initTRPC.context().create();
|
|
22
|
+
/**
|
|
23
|
+
* Simple reactive tRPC router - just exposes reactive functions as tRPC procedures
|
|
24
|
+
*/
|
|
25
|
+
class ReactiveRouter {
|
|
26
|
+
t;
|
|
27
|
+
db;
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
procedures = new Map();
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.db = config.db;
|
|
32
|
+
this.t = server_1.initTRPC.context().create();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Add a reactive function as a tRPC query
|
|
36
|
+
* Uses the function's name automatically
|
|
37
|
+
*/
|
|
38
|
+
addQuery(reactiveFunction) {
|
|
39
|
+
const name = reactiveFunction.config.name;
|
|
40
|
+
const handler = reactiveFunction.getTrpcHandler(this.db);
|
|
41
|
+
const procedure = this.t.procedure
|
|
42
|
+
.input(reactiveFunction.config.input)
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
.query(async (opts) => handler(opts));
|
|
45
|
+
this.procedures.set(name, procedure);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Add a reactive function as a tRPC mutation
|
|
50
|
+
* Uses the function's name automatically
|
|
51
|
+
*/
|
|
52
|
+
addMutation(reactiveFunction) {
|
|
53
|
+
const name = reactiveFunction.config.name;
|
|
54
|
+
const handler = reactiveFunction.getTrpcHandler(this.db);
|
|
55
|
+
const procedure = this.t.procedure
|
|
56
|
+
.input(reactiveFunction.config.input)
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
.mutation(async (opts) => handler(opts));
|
|
59
|
+
this.procedures.set(name, procedure);
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Add a reactive function as a tRPC query with custom name (optional override)
|
|
64
|
+
*/
|
|
65
|
+
addQueryWithName(name, reactiveFunction) {
|
|
66
|
+
const handler = reactiveFunction.getTrpcHandler(this.db);
|
|
67
|
+
const procedure = this.t.procedure
|
|
68
|
+
.input(reactiveFunction.config.input)
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
.query(async (opts) => handler(opts));
|
|
71
|
+
this.procedures.set(name, procedure);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Add a reactive function as a tRPC mutation with custom name (optional override)
|
|
76
|
+
*/
|
|
77
|
+
addMutationWithName(name, reactiveFunction) {
|
|
78
|
+
const handler = reactiveFunction.getTrpcHandler(this.db);
|
|
79
|
+
const procedure = this.t.procedure
|
|
80
|
+
.input(reactiveFunction.config.input)
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
.mutation(async (opts) => handler(opts));
|
|
83
|
+
this.procedures.set(name, procedure);
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Build the final tRPC router
|
|
88
|
+
*/
|
|
89
|
+
build() {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
const routerObj = {};
|
|
92
|
+
for (const [name, procedure] of this.procedures) {
|
|
93
|
+
// Support nested router structure (e.g., 'users.getAll' -> { users: { getAll: procedure } })
|
|
94
|
+
const parts = name.split('.');
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
let current = routerObj;
|
|
97
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
98
|
+
if (!current[parts[i]]) {
|
|
99
|
+
current[parts[i]] = {};
|
|
100
|
+
}
|
|
101
|
+
current = current[parts[i]];
|
|
102
|
+
}
|
|
103
|
+
current[parts[parts.length - 1]] = procedure;
|
|
104
|
+
}
|
|
105
|
+
// Recursively wrap nested objects into tRPC routers
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
const wrapRouters = (node) => {
|
|
108
|
+
const entries = Object.entries(node);
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
const built = {};
|
|
111
|
+
for (const [key, value] of entries) {
|
|
112
|
+
// Heuristic: a procedure in tRPC has a _def property; nested routers won't
|
|
113
|
+
const isProcedure = value && typeof value === 'object' && '_def' in value;
|
|
114
|
+
if (!isProcedure && value && typeof value === 'object') {
|
|
115
|
+
// Nested group: wrap its children first, then create a router
|
|
116
|
+
built[key] = this.t.router(wrapRouters(value));
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
built[key] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return built;
|
|
123
|
+
};
|
|
124
|
+
const normalized = wrapRouters(routerObj);
|
|
125
|
+
return this.t.router(normalized);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get registered procedure names
|
|
129
|
+
*/
|
|
130
|
+
getProcedureNames() {
|
|
131
|
+
return Array.from(this.procedures.keys());
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get router statistics
|
|
135
|
+
*/
|
|
136
|
+
getStats() {
|
|
137
|
+
return {
|
|
138
|
+
totalProcedures: this.procedures.size,
|
|
139
|
+
procedureNames: this.getProcedureNames(),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.ReactiveRouter = ReactiveRouter;
|
|
144
|
+
/**
|
|
145
|
+
* Create a reactive tRPC router (simple factory function)
|
|
146
|
+
*/
|
|
147
|
+
function createReactiveRouter(config) {
|
|
148
|
+
return new ReactiveRouter(config);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Helper to create a router from a collection of reactive functions
|
|
152
|
+
*/
|
|
153
|
+
function createRouterFromFunctions(db, functions) {
|
|
154
|
+
const router = createReactiveRouter({ db });
|
|
155
|
+
for (const [name, { type, fn }] of Object.entries(functions)) {
|
|
156
|
+
if (type === 'query') {
|
|
157
|
+
// Use custom name if provided, otherwise use function's name
|
|
158
|
+
if (name !== fn.config.name) {
|
|
159
|
+
router.addQueryWithName(name, fn);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
router.addQuery(fn);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Use custom name if provided, otherwise use function's name
|
|
167
|
+
if (name !== fn.config.name) {
|
|
168
|
+
router.addMutationWithName(name, fn);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
router.addMutation(fn);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return router;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/trpc/router.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAyKH,oDAIC;AAKD,8DA4BC;AA5MD,yCAAuC;AASvC;;GAEG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,iBAAQ,CAAC,OAAO,EAA0B,CAAC,MAAM,EAAE,CAAA;AAGjF;;GAEG;AACH,MAAa,cAAc;IACjB,CAAC,CAAW;IACZ,EAAE,CAAY;IACtB,8DAA8D;IACtD,UAAU,GAAG,IAAI,GAAG,EAAe,CAAA;IAE3C,YAAY,MAA4B;QACtC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;QACnB,IAAI,CAAC,CAAC,GAAG,iBAAQ,CAAC,OAAO,EAA0B,CAAC,MAAM,EAAE,CAAA;IAC9D,CAAC;IAED;;;OAGG;IACH,QAAQ,CACN,gBAAmD;QAEnD,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAA;QACzC,MAAM,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACxD,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,SA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nC,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CACvC,EAAc,EACd,SAGC;IAED,MAAM,MAAM,GAAG,oBAAoB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IAE3C,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC7D,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,6DAA6D;YAC7D,IAAI,IAAI,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5B,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YACnC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YACrB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,IAAI,IAAI,KAAK,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5B,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YACtC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tRPC type definitions for reactive router
|
|
3
|
+
*/
|
|
4
|
+
import type { AnyRouter } from '@trpc/server';
|
|
5
|
+
import type { ReactiveRouter } from './router';
|
|
6
|
+
import type { ReactiveDb } from '../core/types';
|
|
7
|
+
import type { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Type for reactive router instance
|
|
10
|
+
*/
|
|
11
|
+
export type ReactiveRouterInstance = ReactiveRouter;
|
|
12
|
+
/**
|
|
13
|
+
* Type for built tRPC router with reactive features
|
|
14
|
+
* Note: Use `typeof router` from your built router for full type inference
|
|
15
|
+
*/
|
|
16
|
+
export type BuiltReactiveRouter = AnyRouter;
|
|
17
|
+
/**
|
|
18
|
+
* Handler context with reactive database
|
|
19
|
+
*/
|
|
20
|
+
export interface ReactiveHandlerContext {
|
|
21
|
+
db: ReactiveDb;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for reactive procedures
|
|
25
|
+
*/
|
|
26
|
+
export interface ReactiveProcedureConfig<TInput = unknown, TOutput = unknown> {
|
|
27
|
+
input?: z.ZodType<TInput>;
|
|
28
|
+
dependencies?: string[];
|
|
29
|
+
invalidates?: string[];
|
|
30
|
+
handler: (opts: {
|
|
31
|
+
input: TInput;
|
|
32
|
+
ctx: ReactiveHandlerContext;
|
|
33
|
+
}) => Promise<TOutput>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reactive query procedure configuration
|
|
37
|
+
*/
|
|
38
|
+
export interface ReactiveQueryConfig<TInput = unknown, TOutput = unknown> extends ReactiveProcedureConfig<TInput, TOutput> {
|
|
39
|
+
dependencies: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reactive mutation procedure configuration
|
|
43
|
+
*/
|
|
44
|
+
export interface ReactiveMutationConfig<TInput = unknown, TOutput = unknown> extends ReactiveProcedureConfig<TInput, TOutput> {
|
|
45
|
+
invalidates: string[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Reactive subscription procedure configuration
|
|
49
|
+
*/
|
|
50
|
+
export interface ReactiveSubscriptionConfig<TInput = unknown, TOutput = unknown> {
|
|
51
|
+
input?: z.ZodType<TInput>;
|
|
52
|
+
dependencies: string[];
|
|
53
|
+
handler: (opts: {
|
|
54
|
+
input: TInput;
|
|
55
|
+
ctx: ReactiveHandlerContext;
|
|
56
|
+
}) => AsyncIterable<TOutput>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Cache entry metadata
|
|
60
|
+
*/
|
|
61
|
+
export interface CacheEntry<T = unknown> {
|
|
62
|
+
data: T;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
dependencies: string[];
|
|
65
|
+
ttl: number;
|
|
66
|
+
organizationId?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reactive procedure metadata
|
|
70
|
+
*/
|
|
71
|
+
export interface ReactiveProcedureMetadata {
|
|
72
|
+
name: string;
|
|
73
|
+
type: 'query' | 'mutation' | 'subscription';
|
|
74
|
+
dependencies?: string[];
|
|
75
|
+
invalidates?: string[];
|
|
76
|
+
cacheConfig?: {
|
|
77
|
+
ttl?: number;
|
|
78
|
+
enabled?: boolean;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Router builder interface
|
|
83
|
+
*/
|
|
84
|
+
export interface ReactiveRouterBuilder {
|
|
85
|
+
query<TInput, TOutput>(name: string, config: ReactiveQueryConfig<TInput, TOutput>): ReactiveRouterBuilder;
|
|
86
|
+
mutation<TInput, TOutput>(name: string, config: ReactiveMutationConfig<TInput, TOutput>): ReactiveRouterBuilder;
|
|
87
|
+
subscription<TInput, TOutput>(name: string, config: ReactiveSubscriptionConfig<TInput, TOutput>): ReactiveRouterBuilder;
|
|
88
|
+
build(): BuiltReactiveRouter;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Invalidation context for mutations
|
|
92
|
+
*/
|
|
93
|
+
export interface InvalidationContext {
|
|
94
|
+
mutation: string;
|
|
95
|
+
input: unknown;
|
|
96
|
+
timestamp: number;
|
|
97
|
+
organizationId?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Router statistics
|
|
101
|
+
*/
|
|
102
|
+
export interface RouterStats {
|
|
103
|
+
totalProcedures: number;
|
|
104
|
+
queries: number;
|
|
105
|
+
mutations: number;
|
|
106
|
+
subscriptions: number;
|
|
107
|
+
cacheHitRate: number;
|
|
108
|
+
averageResponseTime: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Error types for reactive router
|
|
112
|
+
*/
|
|
113
|
+
export type ReactiveRouterError = 'CACHE_ERROR' | 'INVALIDATION_ERROR' | 'BROADCAST_ERROR' | 'PROCEDURE_ERROR' | 'ORGANIZATION_NOT_FOUND';
|
|
114
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/trpc/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAA;AAEnD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,UAAU,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC1E,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,sBAAsB,CAAA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACpF;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,CACtE,SAAQ,uBAAuB,CAAC,MAAM,E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AE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3C,qBAAqB,CAAA;IAExB,QAAQ,CAAC,MAAM,EAAE,OAAO,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9C,qBAAqB,CAAA;IAExB,YAAY,CAAC,MAAM,EAAE,OAAO,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,GAClD,qBAAqB,CAAA;IAExB,KAAK,IAAI,mBAAmB,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/trpc/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/package.json
CHANGED