kitcn 0.0.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/bin/intent.js +3 -0
  2. package/dist/aggregate/index.d.ts +388 -0
  3. package/dist/aggregate/index.js +37 -0
  4. package/dist/api-entry-BckXqaLb.js +66 -0
  5. package/dist/auth/client/index.d.ts +37 -0
  6. package/dist/auth/client/index.js +217 -0
  7. package/dist/auth/config/index.d.ts +45 -0
  8. package/dist/auth/config/index.js +24 -0
  9. package/dist/auth/generated/index.d.ts +2 -0
  10. package/dist/auth/generated/index.js +3 -0
  11. package/dist/auth/http/index.d.ts +64 -0
  12. package/dist/auth/http/index.js +461 -0
  13. package/dist/auth/index.d.ts +221 -0
  14. package/dist/auth/index.js +1398 -0
  15. package/dist/auth/nextjs/index.d.ts +50 -0
  16. package/dist/auth/nextjs/index.js +81 -0
  17. package/dist/auth-store-Cljlmdmi.js +197 -0
  18. package/dist/builder-CBdG5W6A.js +1974 -0
  19. package/dist/caller-factory-cTXNvYdz.js +216 -0
  20. package/dist/cli.mjs +13264 -0
  21. package/dist/codegen-lF80HSWu.mjs +3416 -0
  22. package/dist/context-utils-HPC5nXzx.d.ts +17 -0
  23. package/dist/create-schema-odyF4kCy.js +156 -0
  24. package/dist/create-schema-orm-DOyiNDCx.js +246 -0
  25. package/dist/crpc/index.d.ts +105 -0
  26. package/dist/crpc/index.js +169 -0
  27. package/dist/customFunctions-C0voKmtx.js +144 -0
  28. package/dist/error-BZEnI7Sq.js +41 -0
  29. package/dist/generated-contract-disabled-Cih4eITO.js +50 -0
  30. package/dist/generated-contract-disabled-D-sOFy92.d.ts +354 -0
  31. package/dist/http-types-DqJubRPJ.d.ts +292 -0
  32. package/dist/meta-utils-0Pu0Nrap.js +117 -0
  33. package/dist/middleware-BUybuv9n.d.ts +34 -0
  34. package/dist/middleware-C2qTZ3V7.js +84 -0
  35. package/dist/orm/index.d.ts +17 -0
  36. package/dist/orm/index.js +10713 -0
  37. package/dist/plugins/index.d.ts +2 -0
  38. package/dist/plugins/index.js +3 -0
  39. package/dist/procedure-caller-DtxLmGwA.d.ts +1467 -0
  40. package/dist/procedure-caller-MWcxhQDv.js +349 -0
  41. package/dist/query-context-B8o6-8kC.js +1518 -0
  42. package/dist/query-context-CFZqIvD7.d.ts +42 -0
  43. package/dist/query-options-Dw7cOyXl.js +121 -0
  44. package/dist/ratelimit/index.d.ts +269 -0
  45. package/dist/ratelimit/index.js +856 -0
  46. package/dist/ratelimit/react/index.d.ts +76 -0
  47. package/dist/ratelimit/react/index.js +183 -0
  48. package/dist/react/index.d.ts +1284 -0
  49. package/dist/react/index.js +2526 -0
  50. package/dist/rsc/index.d.ts +276 -0
  51. package/dist/rsc/index.js +233 -0
  52. package/dist/runtime-CtvJPkur.js +2453 -0
  53. package/dist/server/index.d.ts +5 -0
  54. package/dist/server/index.js +6 -0
  55. package/dist/solid/index.d.ts +1221 -0
  56. package/dist/solid/index.js +2940 -0
  57. package/dist/transformer-DtDhR3Lc.js +194 -0
  58. package/dist/types-BTb_4BaU.d.ts +42 -0
  59. package/dist/types-BiJE7qxR.d.ts +4 -0
  60. package/dist/types-DEJpkIhw.d.ts +88 -0
  61. package/dist/types-HhO_R6pd.d.ts +213 -0
  62. package/dist/validators-B7oIJCAp.js +279 -0
  63. package/dist/validators-vzRKjBJC.d.ts +88 -0
  64. package/dist/watcher.mjs +96 -0
  65. package/dist/where-clause-compiler-DdjN63Io.d.ts +4756 -0
  66. package/package.json +107 -34
  67. package/skills/convex/SKILL.md +486 -0
  68. package/skills/convex/references/features/aggregates.md +353 -0
  69. package/skills/convex/references/features/auth-admin.md +446 -0
  70. package/skills/convex/references/features/auth-organizations.md +1141 -0
  71. package/skills/convex/references/features/auth-polar.md +579 -0
  72. package/skills/convex/references/features/auth.md +470 -0
  73. package/skills/convex/references/features/create-plugins.md +153 -0
  74. package/skills/convex/references/features/http.md +676 -0
  75. package/skills/convex/references/features/migrations.md +162 -0
  76. package/skills/convex/references/features/orm.md +1166 -0
  77. package/skills/convex/references/features/react.md +657 -0
  78. package/skills/convex/references/features/scheduling.md +267 -0
  79. package/skills/convex/references/features/testing.md +209 -0
  80. package/skills/convex/references/setup/auth.md +501 -0
  81. package/skills/convex/references/setup/biome.md +190 -0
  82. package/skills/convex/references/setup/doc-guidelines.md +145 -0
  83. package/skills/convex/references/setup/index.md +761 -0
  84. package/skills/convex/references/setup/next.md +116 -0
  85. package/skills/convex/references/setup/react.md +175 -0
  86. package/skills/convex/references/setup/server.md +473 -0
  87. package/skills/convex/references/setup/start.md +67 -0
  88. package/LICENSE +0 -21
  89. package/README.md +0 -0
  90. package/dist/index.d.mts +0 -5
  91. package/dist/index.d.mts.map +0 -1
  92. package/dist/index.mjs +0 -6
  93. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,349 @@
1
+ import { i as decodeWire, o as encodeWire } from "./transformer-DtDhR3Lc.js";
2
+ import { h as CRPCError } from "./builder-CBdG5W6A.js";
3
+ import { z } from "zod";
4
+
5
+ //#region src/server/env.ts
6
+ function createEnv(options) {
7
+ const { schema, runtimeEnv, cache = true, codegenFallback = false } = options;
8
+ let cached;
9
+ return () => {
10
+ if (cache && cached) return cached;
11
+ const isCodegenParse = globalThis.__KITCN_CODEGEN__ === true || codegenFallback;
12
+ const runtimeEnvSource = runtimeEnv ?? process.env;
13
+ const runtimeEnvSnapshot = {};
14
+ for (const [key, zodType] of Object.entries(schema.shape)) {
15
+ const undefinedParse = zodType.safeParse(void 0);
16
+ if (undefinedParse.success) {
17
+ if (Object.hasOwn(runtimeEnvSource, key) || Object.getOwnPropertyDescriptor(runtimeEnvSource, key) !== void 0 || key in runtimeEnvSource) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
18
+ else if (!isCodegenParse && undefinedParse.data !== void 0) runtimeEnvSnapshot[key] = runtimeEnvSource[key];
19
+ continue;
20
+ }
21
+ runtimeEnvSnapshot[key] = runtimeEnvSource[key];
22
+ }
23
+ const envForParse = isCodegenParse ? {
24
+ ...Object.fromEntries(Object.entries(schema.shape).map(([key, zodType]) => {
25
+ const result = zodType.safeParse(void 0);
26
+ if (!result.success) {
27
+ if (zodType instanceof z.ZodEnum && Array.isArray(zodType.options) && zodType.options.length > 0) return [key, zodType.options[0]];
28
+ return [key, ""];
29
+ }
30
+ return [key, typeof result.data === "string" ? result.data : void 0];
31
+ })),
32
+ ...Object.fromEntries(Object.entries(runtimeEnvSnapshot).filter(([, value]) => value !== void 0))
33
+ } : runtimeEnvSnapshot;
34
+ const parsed = schema.safeParse(envForParse);
35
+ if (!parsed.success) throw new CRPCError({
36
+ code: "INTERNAL_SERVER_ERROR",
37
+ message: "Invalid environment variables"
38
+ });
39
+ if (cache) cached = parsed.data;
40
+ return parsed.data;
41
+ };
42
+ }
43
+
44
+ //#endregion
45
+ //#region src/server/procedure-caller.ts
46
+ const FUNCTION_REFERENCE_METADATA_KEY = "__kitcnFunctionReference";
47
+ function typedProcedureResolver(functionReference, resolver) {
48
+ const typedResolver = resolver;
49
+ typedResolver[FUNCTION_REFERENCE_METADATA_KEY] = functionReference;
50
+ return typedResolver;
51
+ }
52
+ function getGeneratedFunctionReference(functionReference) {
53
+ return functionReference;
54
+ }
55
+ function isRecord(value) {
56
+ return typeof value === "object" && value !== null;
57
+ }
58
+ function isProcedureType(value) {
59
+ return value === "query" || value === "mutation" || value === "action";
60
+ }
61
+ function isProcedureDefinition(value) {
62
+ return isRecord(value) && isProcedureType(value._type);
63
+ }
64
+ function getProcedureTypeFromExport(value) {
65
+ const crpcType = value._crpcMeta?.type;
66
+ if (isProcedureType(crpcType)) return crpcType;
67
+ if (value.isQuery === true) return "query";
68
+ if (value.isMutation === true) return "mutation";
69
+ if (value.isAction === true) return "action";
70
+ return null;
71
+ }
72
+ function isProcedureExport(value) {
73
+ if (value === null || typeof value !== "object" && typeof value !== "function") return false;
74
+ const exportValue = value;
75
+ if (typeof exportValue._handler !== "function") return false;
76
+ return getProcedureTypeFromExport(exportValue) !== null;
77
+ }
78
+ function decodeProcedureResult(procedure, value) {
79
+ return decodeWire(value, procedure.__kitcnTransformer);
80
+ }
81
+ function encodeProcedureInput(procedure, value) {
82
+ return encodeWire(value, procedure.__kitcnTransformer);
83
+ }
84
+ async function executeProcedure(procedure, mode, pathString, ctx, input) {
85
+ if (mode === "handler") {
86
+ if (typeof procedure.__kitcnRawHandler === "function") return procedure.__kitcnRawHandler({
87
+ ctx,
88
+ input
89
+ });
90
+ if (typeof procedure._handler === "function") return procedure._handler(ctx, input);
91
+ throw new Error(`[kitcn] Resolved procedure does not expose a raw handler: "${pathString}".`);
92
+ }
93
+ return decodeProcedureResult(procedure, await procedure._handler?.(ctx, input));
94
+ }
95
+ function getNodeAtPath(api, path) {
96
+ let current = api;
97
+ for (const segment of path) {
98
+ if (!isRecord(current)) return;
99
+ current = current[segment];
100
+ if (current === void 0) return;
101
+ }
102
+ return current;
103
+ }
104
+ function getContextType(ctx) {
105
+ if (!isRecord(ctx)) return "unknown";
106
+ const hasDb = "db" in ctx;
107
+ const hasRunQuery = typeof ctx.runQuery === "function";
108
+ const hasRunMutation = typeof ctx.runMutation === "function";
109
+ const hasRunAction = typeof ctx.runAction === "function";
110
+ if (!hasDb && (hasRunQuery || hasRunMutation || hasRunAction)) return "action";
111
+ if (hasRunMutation) return "mutation";
112
+ if (hasDb) return "query";
113
+ return "unknown";
114
+ }
115
+ function assertCanInvoke(ctxType, procedureType, pathString, opts = {}) {
116
+ if (ctxType === "action") {
117
+ if (!opts.supportsActionContext) throw new Error(`[kitcn] Action context is not supported by createCaller(ctx): "${pathString}".`);
118
+ if (procedureType === "action") throw new Error(`[kitcn] Cannot call action procedures from action context: "${pathString}".`);
119
+ return;
120
+ }
121
+ if (ctxType !== "query" && ctxType !== "mutation") throw new Error(`[kitcn] Unsupported context for createCaller(ctx): "${pathString}".`);
122
+ if (ctxType === "query" && procedureType !== "query") throw new Error(`[kitcn] Cannot call ${procedureType} procedures from query context: "${pathString}".`);
123
+ if (ctxType === "mutation" && procedureType === "action") throw new Error(`[kitcn] Mutation context cannot call action procedures: "${pathString}".`);
124
+ }
125
+ function createRecursiveProxy(path, ctx, opts, mode) {
126
+ return new Proxy(() => {}, {
127
+ get(_target, prop) {
128
+ if (typeof prop === "symbol") return;
129
+ if (prop === "then") return;
130
+ return createRecursiveProxy([...path, prop], ctx, opts, mode);
131
+ },
132
+ async apply(_target, _thisArg, argsList) {
133
+ const pathString = path.join(".");
134
+ const node = getNodeAtPath(opts.api, path);
135
+ if (node === void 0) throw new Error(`[kitcn] Invalid procedure path: "${pathString}".`);
136
+ if (!isProcedureDefinition(node)) throw new Error(`[kitcn] Path does not resolve to a procedure: "${pathString}".`);
137
+ assertCanInvoke(getContextType(ctx), node._type, pathString);
138
+ const resolved = await opts.resolver(path);
139
+ if (!isProcedureExport(resolved)) throw new Error(`[kitcn] Resolved value is not a cRPC procedure: "${pathString}".`);
140
+ const resolvedType = getProcedureTypeFromExport(resolved);
141
+ if (resolvedType !== node._type) throw new Error(`[kitcn] Procedure type mismatch at "${pathString}". Expected "${node._type}" but got "${resolvedType ?? "unknown"}".`);
142
+ return executeProcedure(resolved, mode, pathString, ctx, argsList[0] ?? {});
143
+ }
144
+ });
145
+ }
146
+ function hasProcedurePrefix(registry, key) {
147
+ const prefix = `${key}.`;
148
+ for (const path in registry) if (path.startsWith(prefix)) return true;
149
+ return false;
150
+ }
151
+ function getResolverFunctionReference(resolver) {
152
+ return resolver[FUNCTION_REFERENCE_METADATA_KEY];
153
+ }
154
+ async function executeActionContextProcedure(ctx, procedureType, procedure, pathString, resolver, input) {
155
+ const ctxValue = ctx;
156
+ const functionReference = getResolverFunctionReference(resolver);
157
+ if (!functionReference) throw new Error(`[kitcn] Missing function reference metadata for action context dispatch: "${pathString}".`);
158
+ const encodedInput = procedure ? encodeProcedureInput(procedure, input) : input;
159
+ const runner = procedureType === "query" ? ctxValue.runQuery : ctxValue.runMutation;
160
+ if (typeof runner !== "function") {
161
+ const runnerName = procedureType === "query" ? "runQuery" : "runMutation";
162
+ throw new Error(`[kitcn] Action context is missing ctx.${runnerName} for "${pathString}".`);
163
+ }
164
+ const result = await runner(functionReference, encodedInput);
165
+ return procedure ? decodeProcedureResult(procedure, result) : result;
166
+ }
167
+ async function executeActionContextActionProcedure(ctx, procedure, pathString, resolver, input) {
168
+ const ctxValue = ctx;
169
+ const functionReference = getResolverFunctionReference(resolver);
170
+ if (!functionReference) throw new Error(`[kitcn] Missing function reference metadata for action context dispatch: "${pathString}".`);
171
+ if (typeof ctxValue.runAction !== "function") throw new Error(`[kitcn] Action context is missing ctx.runAction for "${pathString}".`);
172
+ const encodedInput = procedure ? encodeProcedureInput(procedure, input) : input;
173
+ const result = await ctxValue.runAction(functionReference, encodedInput);
174
+ return procedure ? decodeProcedureResult(procedure, result) : result;
175
+ }
176
+ function getScheduleRunner(ctx, pathString, mode) {
177
+ const scheduler = ctx.scheduler;
178
+ if (!scheduler || typeof scheduler !== "object") throw new Error(`[kitcn] Context is missing ctx.scheduler for "${pathString}".`);
179
+ if (mode.type === "after") {
180
+ if (typeof scheduler.runAfter !== "function") throw new Error(`[kitcn] Context is missing ctx.scheduler.runAfter for "${pathString}".`);
181
+ return (functionReference, args) => scheduler.runAfter?.(mode.delayMs, functionReference, args);
182
+ }
183
+ if (typeof scheduler.runAt !== "function") throw new Error(`[kitcn] Context is missing ctx.scheduler.runAt for "${pathString}".`);
184
+ return (functionReference, args) => scheduler.runAt?.(mode.timestamp, functionReference, args);
185
+ }
186
+ async function executeScheduledProcedure(ctx, mode, procedure, pathString, resolver, input) {
187
+ const functionReference = getResolverFunctionReference(resolver);
188
+ if (!functionReference) throw new Error(`[kitcn] Missing function reference metadata for schedule dispatch: "${pathString}".`);
189
+ return getScheduleRunner(ctx, pathString, mode)(functionReference, procedure ? encodeProcedureInput(procedure, input) : input);
190
+ }
191
+ function createActionsRegistryProxy(path, ctx, registry) {
192
+ return new Proxy(() => {}, {
193
+ get(_target, prop) {
194
+ if (typeof prop === "symbol") return;
195
+ if (prop === "then") return;
196
+ return createActionsRegistryProxy([...path, prop], ctx, registry);
197
+ },
198
+ async apply(_target, _thisArg, argsList) {
199
+ const pathString = path.join(".");
200
+ const entry = registry[pathString];
201
+ if (!entry) {
202
+ if (hasProcedurePrefix(registry, pathString)) throw new Error(`[kitcn] Path does not resolve to an action procedure: "${pathString}".`);
203
+ throw new Error(`[kitcn] Invalid procedure path: "${pathString}".`);
204
+ }
205
+ const [procedureType, resolveProcedure] = entry;
206
+ if (procedureType !== "action") throw new Error(`[kitcn] Path does not resolve to an action procedure: "${pathString}".`);
207
+ if (getContextType(ctx) !== "action") throw new Error(`[kitcn] Action procedures require action context: "${pathString}".`);
208
+ const resolved = await resolveProcedure();
209
+ const procedure = isProcedureExport(resolved) ? resolved : null;
210
+ const canDispatchDirectly = !!getResolverFunctionReference(resolveProcedure);
211
+ if (!procedure && !canDispatchDirectly) throw new Error(`[kitcn] Resolved value is not a cRPC procedure: "${pathString}".`);
212
+ const resolvedType = procedure ? getProcedureTypeFromExport(procedure) : null;
213
+ if (procedure && resolvedType !== procedureType) throw new Error(`[kitcn] Procedure type mismatch at "${pathString}". Expected "${procedureType}" but got "${resolvedType ?? "unknown"}".`);
214
+ return executeActionContextActionProcedure(ctx, procedure, pathString, resolveProcedure, argsList[0] ?? {});
215
+ }
216
+ });
217
+ }
218
+ function createScheduledRegistryProxy(path, ctx, registry, mode) {
219
+ return new Proxy(() => {}, {
220
+ get(_target, prop) {
221
+ if (typeof prop === "symbol") return;
222
+ if (prop === "then") return;
223
+ return createScheduledRegistryProxy([...path, prop], ctx, registry, mode);
224
+ },
225
+ async apply(_target, _thisArg, argsList) {
226
+ const pathString = path.join(".");
227
+ const entry = registry[pathString];
228
+ if (!entry) {
229
+ if (hasProcedurePrefix(registry, pathString)) throw new Error(`[kitcn] Path does not resolve to a schedulable procedure: "${pathString}".`);
230
+ throw new Error(`[kitcn] Invalid procedure path: "${pathString}".`);
231
+ }
232
+ const [procedureType, resolveProcedure] = entry;
233
+ if (procedureType === "query") throw new Error(`[kitcn] Cannot schedule query procedures: "${pathString}".`);
234
+ const ctxType = getContextType(ctx);
235
+ if (ctxType !== "mutation" && ctxType !== "action") throw new Error(`[kitcn] Scheduling requires mutation or action context: "${pathString}".`);
236
+ const resolved = await resolveProcedure();
237
+ const procedure = isProcedureExport(resolved) ? resolved : null;
238
+ const canDispatchDirectly = !!getResolverFunctionReference(resolveProcedure);
239
+ if (!procedure && !canDispatchDirectly) throw new Error(`[kitcn] Resolved value is not a cRPC procedure: "${pathString}".`);
240
+ const resolvedType = procedure ? getProcedureTypeFromExport(procedure) : null;
241
+ if (procedure && resolvedType !== procedureType) throw new Error(`[kitcn] Procedure type mismatch at "${pathString}". Expected "${procedureType}" but got "${resolvedType ?? "unknown"}".`);
242
+ return executeScheduledProcedure(ctx, mode, procedure, pathString, resolveProcedure, argsList[0] ?? {});
243
+ }
244
+ });
245
+ }
246
+ function createScheduleNamespace(ctx, registry) {
247
+ return {
248
+ after: (delayMs) => createScheduledRegistryProxy([], ctx, registry, {
249
+ type: "after",
250
+ delayMs
251
+ }),
252
+ at: (timestamp) => createScheduledRegistryProxy([], ctx, registry, {
253
+ type: "at",
254
+ timestamp
255
+ }),
256
+ now: createScheduledRegistryProxy([], ctx, registry, {
257
+ type: "after",
258
+ delayMs: 0
259
+ }),
260
+ cancel: async (id) => {
261
+ const scheduler = ctx.scheduler;
262
+ if (!scheduler || typeof scheduler !== "object") throw new Error("[kitcn] Context is missing ctx.scheduler for \"schedule.cancel\".");
263
+ if (typeof scheduler.cancel !== "function") throw new Error("[kitcn] Context is missing ctx.scheduler.cancel for \"schedule.cancel\".");
264
+ return scheduler.cancel(id);
265
+ }
266
+ };
267
+ }
268
+ function createRegistryProxy(path, ctx, registry, mode, supportsActionContext) {
269
+ return new Proxy(() => {}, {
270
+ get(_target, prop) {
271
+ if (typeof prop === "symbol") return;
272
+ if (prop === "then") return;
273
+ if (mode === "caller" && path.length === 0 && prop === "actions") return createActionsRegistryProxy([], ctx, registry);
274
+ if (mode === "caller" && path.length === 0 && prop === "schedule") return createScheduleNamespace(ctx, registry);
275
+ return createRegistryProxy([...path, prop], ctx, registry, mode, supportsActionContext);
276
+ },
277
+ async apply(_target, _thisArg, argsList) {
278
+ const pathString = path.join(".");
279
+ const entry = registry[pathString];
280
+ if (!entry) {
281
+ if (hasProcedurePrefix(registry, pathString)) throw new Error(`[kitcn] Path does not resolve to a procedure: "${pathString}".`);
282
+ throw new Error(`[kitcn] Invalid procedure path: "${pathString}".`);
283
+ }
284
+ const [procedureType, resolveProcedure] = entry;
285
+ const ctxType = getContextType(ctx);
286
+ assertCanInvoke(ctxType, procedureType, pathString, { supportsActionContext });
287
+ const resolved = await resolveProcedure();
288
+ const procedure = isProcedureExport(resolved) ? resolved : null;
289
+ const canDispatchDirectly = mode === "caller" && ctxType === "action" && !!getResolverFunctionReference(resolveProcedure);
290
+ if (!procedure && !canDispatchDirectly) throw new Error(`[kitcn] Resolved value is not a cRPC procedure: "${pathString}".`);
291
+ const resolvedType = procedure ? getProcedureTypeFromExport(procedure) : null;
292
+ if (procedure && resolvedType !== procedureType) throw new Error(`[kitcn] Procedure type mismatch at "${pathString}". Expected "${procedureType}" but got "${resolvedType ?? "unknown"}".`);
293
+ const input = argsList[0] ?? {};
294
+ if (ctxType === "action" && mode === "caller") {
295
+ if (procedureType === "action") throw new Error(`[kitcn] Cannot call action procedures from action context: "${pathString}".`);
296
+ return executeActionContextProcedure(ctx, procedureType, procedure, pathString, resolveProcedure, input);
297
+ }
298
+ if (!procedure) throw new Error(`[kitcn] Resolved value is not a cRPC procedure: "${pathString}".`);
299
+ return executeProcedure(procedure, mode, pathString, ctx, input);
300
+ }
301
+ });
302
+ }
303
+ function defineProcedure(type) {
304
+ return { _type: type };
305
+ }
306
+ function createProcedureCallerFactory(opts) {
307
+ return function createCaller(ctx) {
308
+ return createRecursiveProxy([], ctx, opts, "caller");
309
+ };
310
+ }
311
+ function createProcedureHandlerFactory(opts) {
312
+ return function createHandler(ctx) {
313
+ return createRecursiveProxy([], ctx, opts, "handler");
314
+ };
315
+ }
316
+ function createGenericCallerFactory(registry) {
317
+ return function createCaller(ctx) {
318
+ return createRegistryProxy([], ctx, registry, "caller", true);
319
+ };
320
+ }
321
+ function createGenericHandlerFactory(registry) {
322
+ return function createHandler(ctx) {
323
+ return createRegistryProxy([], ctx, registry, "handler", false);
324
+ };
325
+ }
326
+ function createGeneratedRegistryRuntime(createRegistryOrRegistry) {
327
+ let cachedRegistry;
328
+ let cachedCallerFactory;
329
+ let cachedHandlerFactory;
330
+ const getRegistry = () => {
331
+ cachedRegistry ??= typeof createRegistryOrRegistry === "function" ? createRegistryOrRegistry() : createRegistryOrRegistry;
332
+ return cachedRegistry;
333
+ };
334
+ const getCallerFactory = () => {
335
+ cachedCallerFactory ??= createGenericCallerFactory(getRegistry().procedureRegistry);
336
+ return cachedCallerFactory;
337
+ };
338
+ const getHandlerFactory = () => {
339
+ cachedHandlerFactory ??= createGenericHandlerFactory(getRegistry().handlerRegistry);
340
+ return cachedHandlerFactory;
341
+ };
342
+ return {
343
+ getCallerFactory,
344
+ getHandlerFactory
345
+ };
346
+ }
347
+
348
+ //#endregion
349
+ export { createProcedureHandlerFactory as a, typedProcedureResolver as c, createProcedureCallerFactory as i, createEnv as l, createGenericCallerFactory as n, defineProcedure as o, createGenericHandlerFactory as r, getGeneratedFunctionReference as s, createGeneratedRegistryRuntime as t };